##// END OF EJS Templates
IPython/Extensions/ipipe.py (xiter): Make sure that iterating...
walter.doerwald -
Show More
@@ -1,1721 +1,1725 b''
1 1 # -*- coding: iso-8859-1 -*-
2 2
3 3 import curses, fcntl, signal, struct, tty, textwrap, inspect
4 4
5 5 import astyle, ipipe
6 6
7 7
8 8 # Python 2.3 compatibility
9 9 try:
10 10 set
11 11 except NameError:
12 12 import sets
13 13 set = sets.Set
14 14
15 15 # Python 2.3 compatibility
16 16 try:
17 17 sorted
18 18 except NameError:
19 19 from ipipe import sorted
20 20
21 21
22 22 class UnassignedKeyError(Exception):
23 23 """
24 24 Exception that is used for reporting unassigned keys.
25 25 """
26 26
27 27
28 28 class UnknownCommandError(Exception):
29 29 """
30 30 Exception that is used for reporting unknown commands (this should never
31 31 happen).
32 32 """
33 33
34 34
35 35 class CommandError(Exception):
36 36 """
37 37 Exception that is used for reporting that a command can't be executed.
38 38 """
39 39
40 40
41 41 class Keymap(dict):
42 42 """
43 43 Stores mapping of keys to commands.
44 44 """
45 45 def __init__(self):
46 46 self._keymap = {}
47 47
48 48 def __setitem__(self, key, command):
49 49 if isinstance(key, str):
50 50 for c in key:
51 51 dict.__setitem__(self, ord(c), command)
52 52 else:
53 53 dict.__setitem__(self, key, command)
54 54
55 55 def __getitem__(self, key):
56 56 if isinstance(key, str):
57 57 key = ord(key)
58 58 return dict.__getitem__(self, key)
59 59
60 60 def __detitem__(self, key):
61 61 if isinstance(key, str):
62 62 key = ord(key)
63 63 dict.__detitem__(self, key)
64 64
65 65 def register(self, command, *keys):
66 66 for key in keys:
67 67 self[key] = command
68 68
69 69 def get(self, key, default=None):
70 70 if isinstance(key, str):
71 71 key = ord(key)
72 72 return dict.get(self, key, default)
73 73
74 74 def findkey(self, command, default=ipipe.noitem):
75 75 for (key, commandcandidate) in self.iteritems():
76 76 if commandcandidate == command:
77 77 return key
78 78 if default is ipipe.noitem:
79 79 raise KeyError(command)
80 80 return default
81 81
82 82
83 83 class _BrowserCachedItem(object):
84 84 # This is used internally by ``ibrowse`` to store a item together with its
85 85 # marked status.
86 86 __slots__ = ("item", "marked")
87 87
88 88 def __init__(self, item):
89 89 self.item = item
90 90 self.marked = False
91 91
92 92
93 93 class _BrowserHelp(object):
94 94 style_header = astyle.Style.fromstr("yellow:black:bold")
95 95 # This is used internally by ``ibrowse`` for displaying the help screen.
96 96 def __init__(self, browser):
97 97 self.browser = browser
98 98
99 99 def __xrepr__(self, mode):
100 100 yield (-1, True)
101 101 if mode == "header" or mode == "footer":
102 102 yield (astyle.style_default, "ibrowse help screen")
103 103 else:
104 104 yield (astyle.style_default, repr(self))
105 105
106 106 def __iter__(self):
107 107 # Get reverse key mapping
108 108 allkeys = {}
109 109 for (key, cmd) in self.browser.keymap.iteritems():
110 110 allkeys.setdefault(cmd, []).append(key)
111 111
112 112 fields = ("key", "description")
113 113
114 114 commands = []
115 115 for name in dir(self.browser):
116 116 if name.startswith("cmd_"):
117 117 command = getattr(self.browser, name)
118 118 commands.append((inspect.getsourcelines(command)[-1], name[4:], command))
119 119 commands.sort()
120 120 commands = [(c[1], c[2]) for c in commands]
121 121 for (i, (name, command)) in enumerate(commands):
122 122 if i:
123 123 yield ipipe.Fields(fields, key="", description="")
124 124
125 125 description = command.__doc__
126 126 if description is None:
127 127 lines = []
128 128 else:
129 129 lines = [l.strip() for l in description.splitlines() if l.strip()]
130 130 description = "\n".join(lines)
131 131 lines = textwrap.wrap(description, 60)
132 132 keys = allkeys.get(name, [])
133 133
134 134 yield ipipe.Fields(fields, key="", description=astyle.Text((self.style_header, name)))
135 135 for i in xrange(max(len(keys), len(lines))):
136 136 try:
137 137 key = self.browser.keylabel(keys[i])
138 138 except IndexError:
139 139 key = ""
140 140 try:
141 141 line = lines[i]
142 142 except IndexError:
143 143 line = ""
144 144 yield ipipe.Fields(fields, key=key, description=line)
145 145
146 146
147 147 class _BrowserLevel(object):
148 148 # This is used internally to store the state (iterator, fetch items,
149 149 # position of cursor and screen, etc.) of one browser level
150 150 # An ``ibrowse`` object keeps multiple ``_BrowserLevel`` objects in
151 151 # a stack.
152 152 def __init__(self, browser, input,mainsizey, *attrs):
153 153 self.browser = browser
154 154 self.input = input
155 155 self.header = [x for x in ipipe.xrepr(input, "header") if not isinstance(x[0], int)]
156 156 # iterator for the input
157 157 self.iterator = ipipe.xiter(input)
158 158
159 159 # is the iterator exhausted?
160 160 self.exhausted = False
161 161
162 162 # attributes to be display (autodetected if empty)
163 163 self.attrs = attrs
164 164
165 165 # fetched items (+ marked flag)
166 166 self.items = ipipe.deque()
167 167
168 168 # Number of marked objects
169 169 self.marked = 0
170 170
171 171 # Vertical cursor position
172 172 self.cury = 0
173 173
174 174 # Horizontal cursor position
175 175 self.curx = 0
176 176
177 177 # Index of first data column
178 178 self.datastartx = 0
179 179
180 180 # Index of first data line
181 181 self.datastarty = 0
182 182
183 183 # height of the data display area
184 184 self.mainsizey = mainsizey
185 185
186 186 # width of the data display area (changes when scrolling)
187 187 self.mainsizex = 0
188 188
189 189 # Size of row number (changes when scrolling)
190 190 self.numbersizex = 0
191 191
192 192 # Attributes to display (in this order)
193 193 self.displayattrs = []
194 194
195 195 # index and attribute under the cursor
196 196 self.displayattr = (None, ipipe.noitem)
197 197
198 198 # Maps attributes to column widths
199 199 self.colwidths = {}
200 200
201 201 # Set of hidden attributes
202 202 self.hiddenattrs = set()
203 203
204 204 # This takes care of all the caches etc.
205 205 self.moveto(0, 0, refresh=True)
206 206
207 207 def fetch(self, count):
208 208 # Try to fill ``self.items`` with at least ``count`` objects.
209 209 have = len(self.items)
210 210 while not self.exhausted and have < count:
211 211 try:
212 212 item = self.iterator.next()
213 213 except StopIteration:
214 214 self.exhausted = True
215 215 break
216 216 except (KeyboardInterrupt, SystemExit):
217 217 raise
218 218 except Exception, exc:
219 219 have += 1
220 220 self.items.append(_BrowserCachedItem(exc))
221 221 self.exhausted = True
222 222 break
223 223 else:
224 224 have += 1
225 225 self.items.append(_BrowserCachedItem(item))
226 226
227 227 def calcdisplayattrs(self):
228 228 # Calculate which attributes are available from the objects that are
229 229 # currently visible on screen (and store it in ``self.displayattrs``)
230 230
231 231 attrs = set()
232 232 self.displayattrs = []
233 233 if self.attrs:
234 234 # If the browser object specifies a fixed list of attributes,
235 235 # simply use it (removing hidden attributes).
236 236 for attr in self.attrs:
237 237 attr = ipipe.upgradexattr(attr)
238 238 if attr not in attrs and attr not in self.hiddenattrs:
239 239 self.displayattrs.append(attr)
240 240 attrs.add(attr)
241 241 else:
242 242 endy = min(self.datastarty+self.mainsizey, len(self.items))
243 243 for i in xrange(self.datastarty, endy):
244 244 for attr in ipipe.xattrs(self.items[i].item, "default"):
245 245 if attr not in attrs and attr not in self.hiddenattrs:
246 246 self.displayattrs.append(attr)
247 247 attrs.add(attr)
248 248
249 249 def getrow(self, i):
250 250 # Return a dictionary with the attributes for the object
251 251 # ``self.items[i]``. Attribute names are taken from
252 252 # ``self.displayattrs`` so ``calcdisplayattrs()`` must have been
253 253 # called before.
254 254 row = {}
255 255 item = self.items[i].item
256 256 for attr in self.displayattrs:
257 257 try:
258 258 value = attr.value(item)
259 259 except (KeyboardInterrupt, SystemExit):
260 260 raise
261 261 except Exception, exc:
262 262 value = exc
263 263 # only store attribute if it exists (or we got an exception)
264 264 if value is not ipipe.noitem:
265 265 # remember alignment, length and colored text
266 266 row[attr] = ipipe.xformat(value, "cell", self.browser.maxattrlength)
267 267 return row
268 268
269 269 def calcwidths(self):
270 270 # Recalculate the displayed fields and their widths.
271 271 # ``calcdisplayattrs()'' must have been called and the cache
272 272 # for attributes of the objects on screen (``self.displayrows``)
273 273 # must have been filled. This sets ``self.colwidths`` which maps
274 274 # attribute descriptors to widths.
275 275 self.colwidths = {}
276 276 for row in self.displayrows:
277 277 for attr in self.displayattrs:
278 278 try:
279 279 length = row[attr][1]
280 280 except KeyError:
281 281 length = 0
282 282 # always add attribute to colwidths, even if it doesn't exist
283 283 if attr not in self.colwidths:
284 284 self.colwidths[attr] = len(attr.name())
285 285 newwidth = max(self.colwidths[attr], length)
286 286 self.colwidths[attr] = newwidth
287 287
288 288 # How many characters do we need to paint the largest item number?
289 289 self.numbersizex = len(str(self.datastarty+self.mainsizey-1))
290 290 # How must space have we got to display data?
291 291 self.mainsizex = self.browser.scrsizex-self.numbersizex-3
292 292 # width of all columns
293 293 self.datasizex = sum(self.colwidths.itervalues()) + len(self.colwidths)
294 294
295 295 def calcdisplayattr(self):
296 296 # Find out which attribute the cursor is on and store this
297 297 # information in ``self.displayattr``.
298 298 pos = 0
299 299 for (i, attr) in enumerate(self.displayattrs):
300 300 if pos+self.colwidths[attr] >= self.curx:
301 301 self.displayattr = (i, attr)
302 302 break
303 303 pos += self.colwidths[attr]+1
304 304 else:
305 305 self.displayattr = (None, ipipe.noitem)
306 306
307 307 def moveto(self, x, y, refresh=False):
308 308 # Move the cursor to the position ``(x,y)`` (in data coordinates,
309 309 # not in screen coordinates). If ``refresh`` is true, all cached
310 310 # values will be recalculated (e.g. because the list has been
311 311 # resorted, so screen positions etc. are no longer valid).
312 312 olddatastarty = self.datastarty
313 313 oldx = self.curx
314 314 oldy = self.cury
315 315 x = int(x+0.5)
316 316 y = int(y+0.5)
317 317 newx = x # remember where we wanted to move
318 318 newy = y # remember where we wanted to move
319 319
320 320 scrollbordery = min(self.browser.scrollbordery, self.mainsizey//2)
321 321 scrollborderx = min(self.browser.scrollborderx, self.mainsizex//2)
322 322
323 323 # Make sure that the cursor didn't leave the main area vertically
324 324 if y < 0:
325 325 y = 0
326 326 # try to get enough items to fill the screen
327 327 self.fetch(max(y+scrollbordery+1, self.mainsizey))
328 328 if y >= len(self.items):
329 329 y = max(0, len(self.items)-1)
330 330
331 331 # Make sure that the cursor stays on screen vertically
332 332 if y < self.datastarty+scrollbordery:
333 333 self.datastarty = max(0, y-scrollbordery)
334 334 elif y >= self.datastarty+self.mainsizey-scrollbordery:
335 335 self.datastarty = max(0, min(y-self.mainsizey+scrollbordery+1,
336 336 len(self.items)-self.mainsizey))
337 337
338 338 if refresh: # Do we need to refresh the complete display?
339 339 self.calcdisplayattrs()
340 340 endy = min(self.datastarty+self.mainsizey, len(self.items))
341 341 self.displayrows = map(self.getrow, xrange(self.datastarty, endy))
342 342 self.calcwidths()
343 343 # Did we scroll vertically => update displayrows
344 344 # and various other attributes
345 345 elif self.datastarty != olddatastarty:
346 346 # Recalculate which attributes we have to display
347 347 olddisplayattrs = self.displayattrs
348 348 self.calcdisplayattrs()
349 349 # If there are new attributes, recreate the cache
350 350 if self.displayattrs != olddisplayattrs:
351 351 endy = min(self.datastarty+self.mainsizey, len(self.items))
352 352 self.displayrows = map(self.getrow, xrange(self.datastarty, endy))
353 353 elif self.datastarty<olddatastarty: # we did scroll up
354 354 # drop rows from the end
355 355 del self.displayrows[self.datastarty-olddatastarty:]
356 356 # fetch new items
357 357 for i in xrange(min(olddatastarty, self.datastarty+self.mainsizey)-1,
358 358 self.datastarty-1, -1):
359 359 try:
360 360 row = self.getrow(i)
361 361 except IndexError:
362 362 # we didn't have enough objects to fill the screen
363 363 break
364 364 self.displayrows.insert(0, row)
365 365 else: # we did scroll down
366 366 # drop rows from the start
367 367 del self.displayrows[:self.datastarty-olddatastarty]
368 368 # fetch new items
369 369 for i in xrange(max(olddatastarty+self.mainsizey, self.datastarty),
370 370 self.datastarty+self.mainsizey):
371 371 try:
372 372 row = self.getrow(i)
373 373 except IndexError:
374 374 # we didn't have enough objects to fill the screen
375 375 break
376 376 self.displayrows.append(row)
377 377 self.calcwidths()
378 378
379 379 # Make sure that the cursor didn't leave the data area horizontally
380 380 if x < 0:
381 381 x = 0
382 382 elif x >= self.datasizex:
383 383 x = max(0, self.datasizex-1)
384 384
385 385 # Make sure that the cursor stays on screen horizontally
386 386 if x < self.datastartx+scrollborderx:
387 387 self.datastartx = max(0, x-scrollborderx)
388 388 elif x >= self.datastartx+self.mainsizex-scrollborderx:
389 389 self.datastartx = max(0, min(x-self.mainsizex+scrollborderx+1,
390 390 self.datasizex-self.mainsizex))
391 391
392 392 if x == oldx and y == oldy and (x != newx or y != newy): # couldn't move
393 393 self.browser.beep()
394 394 else:
395 395 self.curx = x
396 396 self.cury = y
397 397 self.calcdisplayattr()
398 398
399 399 def sort(self, key, reverse=False):
400 400 """
401 401 Sort the currently list of items using the key function ``key``. If
402 402 ``reverse`` is true the sort order is reversed.
403 403 """
404 404 curitem = self.items[self.cury] # Remember where the cursor is now
405 405
406 406 # Sort items
407 407 def realkey(item):
408 408 return key(item.item)
409 409 self.items = ipipe.deque(sorted(self.items, key=realkey, reverse=reverse))
410 410
411 411 # Find out where the object under the cursor went
412 412 cury = self.cury
413 413 for (i, item) in enumerate(self.items):
414 414 if item is curitem:
415 415 cury = i
416 416 break
417 417
418 418 self.moveto(self.curx, cury, refresh=True)
419 419
420 420 def refresh(self):
421 421 """
422 422 Restart iterating the input.
423 423 """
424 424 self.iterator = ipipe.xiter(self.input)
425 425 self.items.clear()
426 426 self.exhausted = False
427 427 self.datastartx = self.datastarty = 0
428 428 self.moveto(0, 0, refresh=True)
429 429
430 430 def refreshfind(self):
431 431 """
432 432 Restart iterating the input and go back to the same object as before
433 433 (if it can be found in the new iterator).
434 434 """
435 435 try:
436 436 oldobject = self.items[self.cury].item
437 437 except IndexError:
438 438 oldobject = ipipe.noitem
439 439 self.iterator = ipipe.xiter(self.input)
440 440 self.items.clear()
441 441 self.exhausted = False
442 442 while True:
443 443 self.fetch(len(self.items)+1)
444 444 if self.exhausted:
445 445 curses.beep()
446 446 self.datastartx = self.datastarty = 0
447 447 self.moveto(self.curx, 0, refresh=True)
448 448 break
449 449 if self.items[-1].item == oldobject:
450 450 self.datastartx = self.datastarty = 0
451 451 self.moveto(self.curx, len(self.items)-1, refresh=True)
452 452 break
453 453
454 454
455 455 class _CommandInput(object):
456 456 keymap = Keymap()
457 457 keymap.register("left", curses.KEY_LEFT)
458 458 keymap.register("right", curses.KEY_RIGHT)
459 459 keymap.register("home", curses.KEY_HOME, "\x01") # Ctrl-A
460 460 keymap.register("end", curses.KEY_END, "\x05") # Ctrl-E
461 461 # FIXME: What's happening here?
462 462 keymap.register("backspace", curses.KEY_BACKSPACE, "\x08\x7f")
463 463 keymap.register("delete", curses.KEY_DC)
464 464 keymap.register("delend", 0x0b) # Ctrl-K
465 465 keymap.register("execute", "\r\n")
466 466 keymap.register("up", curses.KEY_UP)
467 467 keymap.register("down", curses.KEY_DOWN)
468 468 keymap.register("incsearchup", curses.KEY_PPAGE)
469 469 keymap.register("incsearchdown", curses.KEY_NPAGE)
470 470 keymap.register("exit", "\x18"), # Ctrl-X
471 471
472 472 def __init__(self, prompt):
473 473 self.prompt = prompt
474 474 self.history = []
475 475 self.maxhistory = 100
476 476 self.input = ""
477 477 self.curx = 0
478 478 self.cury = -1 # blank line
479 479
480 480 def start(self):
481 481 self.input = ""
482 482 self.curx = 0
483 483 self.cury = -1 # blank line
484 484
485 485 def handlekey(self, browser, key):
486 486 cmdname = self.keymap.get(key, None)
487 487 if cmdname is not None:
488 488 cmdfunc = getattr(self, "cmd_%s" % cmdname, None)
489 489 if cmdfunc is not None:
490 490 return cmdfunc(browser)
491 491 curses.beep()
492 492 elif key != -1:
493 493 try:
494 494 char = chr(key)
495 495 except ValueError:
496 496 curses.beep()
497 497 else:
498 498 return self.handlechar(browser, char)
499 499
500 500 def handlechar(self, browser, char):
501 501 self.input = self.input[:self.curx] + char + self.input[self.curx:]
502 502 self.curx += 1
503 503 return True
504 504
505 505 def dohistory(self):
506 506 self.history.insert(0, self.input)
507 507 del self.history[:-self.maxhistory]
508 508
509 509 def cmd_backspace(self, browser):
510 510 if self.curx:
511 511 self.input = self.input[:self.curx-1] + self.input[self.curx:]
512 512 self.curx -= 1
513 513 return True
514 514 else:
515 515 curses.beep()
516 516
517 517 def cmd_delete(self, browser):
518 518 if self.curx<len(self.input):
519 519 self.input = self.input[:self.curx] + self.input[self.curx+1:]
520 520 return True
521 521 else:
522 522 curses.beep()
523 523
524 524 def cmd_delend(self, browser):
525 525 if self.curx<len(self.input):
526 526 self.input = self.input[:self.curx]
527 527 return True
528 528
529 529 def cmd_left(self, browser):
530 530 if self.curx:
531 531 self.curx -= 1
532 532 return True
533 533 else:
534 534 curses.beep()
535 535
536 536 def cmd_right(self, browser):
537 537 if self.curx < len(self.input):
538 538 self.curx += 1
539 539 return True
540 540 else:
541 541 curses.beep()
542 542
543 543 def cmd_home(self, browser):
544 544 if self.curx:
545 545 self.curx = 0
546 546 return True
547 547 else:
548 548 curses.beep()
549 549
550 550 def cmd_end(self, browser):
551 551 if self.curx < len(self.input):
552 552 self.curx = len(self.input)
553 553 return True
554 554 else:
555 555 curses.beep()
556 556
557 557 def cmd_up(self, browser):
558 558 if self.cury < len(self.history)-1:
559 559 self.cury += 1
560 560 self.input = self.history[self.cury]
561 561 self.curx = len(self.input)
562 562 return True
563 563 else:
564 564 curses.beep()
565 565
566 566 def cmd_down(self, browser):
567 567 if self.cury >= 0:
568 568 self.cury -= 1
569 569 if self.cury>=0:
570 570 self.input = self.history[self.cury]
571 571 else:
572 572 self.input = ""
573 573 self.curx = len(self.input)
574 574 return True
575 575 else:
576 576 curses.beep()
577 577
578 578 def cmd_incsearchup(self, browser):
579 579 prefix = self.input[:self.curx]
580 580 cury = self.cury
581 581 while True:
582 582 cury += 1
583 583 if cury >= len(self.history):
584 584 break
585 585 if self.history[cury].startswith(prefix):
586 586 self.input = self.history[cury]
587 587 self.cury = cury
588 588 return True
589 589 curses.beep()
590 590
591 591 def cmd_incsearchdown(self, browser):
592 592 prefix = self.input[:self.curx]
593 593 cury = self.cury
594 594 while True:
595 595 cury -= 1
596 596 if cury <= 0:
597 597 break
598 598 if self.history[cury].startswith(prefix):
599 599 self.input = self.history[self.cury]
600 600 self.cury = cury
601 601 return True
602 602 curses.beep()
603 603
604 604 def cmd_exit(self, browser):
605 605 browser.mode = "default"
606 606 return True
607 607
608 608 def cmd_execute(self, browser):
609 609 raise NotImplementedError
610 610
611 611
612 612 class _CommandGoto(_CommandInput):
613 613 def __init__(self):
614 614 _CommandInput.__init__(self, "goto object #")
615 615
616 616 def handlechar(self, browser, char):
617 617 # Only accept digits
618 618 if not "0" <= char <= "9":
619 619 curses.beep()
620 620 else:
621 621 return _CommandInput.handlechar(self, browser, char)
622 622
623 623 def cmd_execute(self, browser):
624 624 level = browser.levels[-1]
625 625 if self.input:
626 626 self.dohistory()
627 627 level.moveto(level.curx, int(self.input))
628 628 browser.mode = "default"
629 629 return True
630 630
631 631
632 632 class _CommandFind(_CommandInput):
633 633 def __init__(self):
634 634 _CommandInput.__init__(self, "find expression")
635 635
636 636 def cmd_execute(self, browser):
637 637 level = browser.levels[-1]
638 638 if self.input:
639 639 self.dohistory()
640 640 while True:
641 641 cury = level.cury
642 642 level.moveto(level.curx, cury+1)
643 643 if cury == level.cury:
644 644 curses.beep()
645 645 break # hit end
646 646 item = level.items[level.cury].item
647 647 try:
648 648 globals = ipipe.getglobals(None)
649 649 if eval(self.input, globals, ipipe.AttrNamespace(item)):
650 650 break # found something
651 651 except (KeyboardInterrupt, SystemExit):
652 652 raise
653 653 except Exception, exc:
654 654 browser.report(exc)
655 655 curses.beep()
656 656 break # break on error
657 657 browser.mode = "default"
658 658 return True
659 659
660 660
661 661 class _CommandFindBackwards(_CommandInput):
662 662 def __init__(self):
663 663 _CommandInput.__init__(self, "find backwards expression")
664 664
665 665 def cmd_execute(self, browser):
666 666 level = browser.levels[-1]
667 667 if self.input:
668 668 self.dohistory()
669 669 while level.cury:
670 670 level.moveto(level.curx, level.cury-1)
671 671 item = level.items[level.cury].item
672 672 try:
673 673 globals = ipipe.getglobals(None)
674 674 if eval(self.input, globals, ipipe.AttrNamespace(item)):
675 675 break # found something
676 676 except (KeyboardInterrupt, SystemExit):
677 677 raise
678 678 except Exception, exc:
679 679 browser.report(exc)
680 680 curses.beep()
681 681 break # break on error
682 682 else:
683 683 curses.beep()
684 684 browser.mode = "default"
685 685 return True
686 686
687 687
688 688 class ibrowse(ipipe.Display):
689 689 # Show this many lines from the previous screen when paging horizontally
690 690 pageoverlapx = 1
691 691
692 692 # Show this many lines from the previous screen when paging vertically
693 693 pageoverlapy = 1
694 694
695 695 # Start scrolling when the cursor is less than this number of columns
696 696 # away from the left or right screen edge
697 697 scrollborderx = 10
698 698
699 699 # Start scrolling when the cursor is less than this number of lines
700 700 # away from the top or bottom screen edge
701 701 scrollbordery = 5
702 702
703 703 # Accelerate by this factor when scrolling horizontally
704 704 acceleratex = 1.05
705 705
706 706 # Accelerate by this factor when scrolling vertically
707 707 acceleratey = 1.05
708 708
709 709 # The maximum horizontal scroll speed
710 710 # (as a factor of the screen width (i.e. 0.5 == half a screen width)
711 711 maxspeedx = 0.5
712 712
713 713 # The maximum vertical scroll speed
714 714 # (as a factor of the screen height (i.e. 0.5 == half a screen height)
715 715 maxspeedy = 0.5
716 716
717 717 # The maximum number of header lines for browser level
718 718 # if the nesting is deeper, only the innermost levels are displayed
719 719 maxheaders = 5
720 720
721 721 # The approximate maximum length of a column entry
722 722 maxattrlength = 200
723 723
724 724 # Styles for various parts of the GUI
725 725 style_objheadertext = astyle.Style.fromstr("white:black:bold|reverse")
726 726 style_objheadernumber = astyle.Style.fromstr("white:blue:bold|reverse")
727 727 style_objheaderobject = astyle.Style.fromstr("white:black:reverse")
728 728 style_colheader = astyle.Style.fromstr("blue:white:reverse")
729 729 style_colheaderhere = astyle.Style.fromstr("green:black:bold|reverse")
730 730 style_colheadersep = astyle.Style.fromstr("blue:black:reverse")
731 731 style_number = astyle.Style.fromstr("blue:white:reverse")
732 732 style_numberhere = astyle.Style.fromstr("green:black:bold|reverse")
733 733 style_sep = astyle.Style.fromstr("blue:black")
734 734 style_data = astyle.Style.fromstr("white:black")
735 735 style_datapad = astyle.Style.fromstr("blue:black:bold")
736 736 style_footer = astyle.Style.fromstr("black:white")
737 737 style_report = astyle.Style.fromstr("white:black")
738 738
739 739 # Column separator in header
740 740 headersepchar = "|"
741 741
742 742 # Character for padding data cell entries
743 743 datapadchar = "."
744 744
745 745 # Column separator in data area
746 746 datasepchar = "|"
747 747
748 748 # Character to use for "empty" cell (i.e. for non-existing attributes)
749 749 nodatachar = "-"
750 750
751 751 # Prompts for modes that require keyboard input
752 752 prompts = {
753 753 "goto": _CommandGoto(),
754 754 "find": _CommandFind(),
755 755 "findbackwards": _CommandFindBackwards()
756 756 }
757 757
758 758 # Maps curses key codes to "function" names
759 759 keymap = Keymap()
760 760 keymap.register("quit", "q")
761 761 keymap.register("up", curses.KEY_UP)
762 762 keymap.register("down", curses.KEY_DOWN)
763 763 keymap.register("pageup", curses.KEY_PPAGE)
764 764 keymap.register("pagedown", curses.KEY_NPAGE)
765 765 keymap.register("left", curses.KEY_LEFT)
766 766 keymap.register("right", curses.KEY_RIGHT)
767 767 keymap.register("home", curses.KEY_HOME, "\x01")
768 768 keymap.register("end", curses.KEY_END, "\x05")
769 769 keymap.register("prevattr", "<\x1b")
770 770 keymap.register("nextattr", ">\t")
771 771 keymap.register("pick", "p")
772 772 keymap.register("pickattr", "P")
773 773 keymap.register("pickallattrs", "C")
774 774 keymap.register("pickmarked", "m")
775 775 keymap.register("pickmarkedattr", "M")
776 776 keymap.register("hideattr", "h")
777 777 keymap.register("unhideattrs", "H")
778 778 keymap.register("help", "?")
779 779 keymap.register("enter", "\r\n")
780 780 keymap.register("enterattr", "E")
781 781 # FIXME: What's happening here?
782 782 keymap.register("leave", curses.KEY_BACKSPACE, "x\x08\x7f")
783 783 keymap.register("detail", "d")
784 784 keymap.register("detailattr", "D")
785 785 keymap.register("tooglemark", " ")
786 786 keymap.register("markrange", "%")
787 787 keymap.register("sortattrasc", "v")
788 788 keymap.register("sortattrdesc", "V")
789 789 keymap.register("goto", "g")
790 790 keymap.register("find", "f")
791 791 keymap.register("findbackwards", "b")
792 792 keymap.register("refresh", "r")
793 793 keymap.register("refreshfind", "R")
794 794
795 795 def __init__(self, *attrs):
796 796 """
797 797 Create a new browser. If ``attrs`` is not empty, it is the list
798 798 of attributes that will be displayed in the browser, otherwise
799 799 these will be determined by the objects on screen.
800 800 """
801 801 self.attrs = attrs
802 802
803 803 # Stack of browser levels
804 804 self.levels = []
805 805 # how many colums to scroll (Changes when accelerating)
806 806 self.stepx = 1.
807 807
808 808 # how many rows to scroll (Changes when accelerating)
809 809 self.stepy = 1.
810 810
811 811 # Beep on the edges of the data area? (Will be set to ``False``
812 812 # once the cursor hits the edge of the screen, so we don't get
813 813 # multiple beeps).
814 814 self._dobeep = True
815 815
816 816 # Cache for registered ``curses`` colors and styles.
817 817 self._styles = {}
818 818 self._colors = {}
819 819 self._maxcolor = 1
820 820
821 821 # How many header lines do we want to paint (the numbers of levels
822 822 # we have, but with an upper bound)
823 823 self._headerlines = 1
824 824
825 825 # Index of first header line
826 826 self._firstheaderline = 0
827 827
828 828 # curses window
829 829 self.scr = None
830 830 # report in the footer line (error, executed command etc.)
831 831 self._report = None
832 832
833 833 # value to be returned to the caller (set by commands)
834 834 self.returnvalue = None
835 835
836 836 # The mode the browser is in
837 837 # e.g. normal browsing or entering an argument for a command
838 838 self.mode = "default"
839 839
840 840 # set by the SIGWINCH signal handler
841 841 self.resized = False
842 842
843 843 def nextstepx(self, step):
844 844 """
845 845 Accelerate horizontally.
846 846 """
847 847 return max(1., min(step*self.acceleratex,
848 848 self.maxspeedx*self.levels[-1].mainsizex))
849 849
850 850 def nextstepy(self, step):
851 851 """
852 852 Accelerate vertically.
853 853 """
854 854 return max(1., min(step*self.acceleratey,
855 855 self.maxspeedy*self.levels[-1].mainsizey))
856 856
857 857 def getstyle(self, style):
858 858 """
859 859 Register the ``style`` with ``curses`` or get it from the cache,
860 860 if it has been registered before.
861 861 """
862 862 try:
863 863 return self._styles[style.fg, style.bg, style.attrs]
864 864 except KeyError:
865 865 attrs = 0
866 866 for b in astyle.A2CURSES:
867 867 if style.attrs & b:
868 868 attrs |= astyle.A2CURSES[b]
869 869 try:
870 870 color = self._colors[style.fg, style.bg]
871 871 except KeyError:
872 872 curses.init_pair(
873 873 self._maxcolor,
874 874 astyle.COLOR2CURSES[style.fg],
875 875 astyle.COLOR2CURSES[style.bg]
876 876 )
877 877 color = curses.color_pair(self._maxcolor)
878 878 self._colors[style.fg, style.bg] = color
879 879 self._maxcolor += 1
880 880 c = color | attrs
881 881 self._styles[style.fg, style.bg, style.attrs] = c
882 882 return c
883 883
884 884 def addstr(self, y, x, begx, endx, text, style):
885 885 """
886 886 A version of ``curses.addstr()`` that can handle ``x`` coordinates
887 887 that are outside the screen.
888 888 """
889 889 text2 = text[max(0, begx-x):max(0, endx-x)]
890 890 if text2:
891 891 self.scr.addstr(y, max(x, begx), text2, self.getstyle(style))
892 892 return len(text)
893 893
894 894 def addchr(self, y, x, begx, endx, c, l, style):
895 895 x0 = max(x, begx)
896 896 x1 = min(x+l, endx)
897 897 if x1>x0:
898 898 self.scr.addstr(y, x0, c*(x1-x0), self.getstyle(style))
899 899 return l
900 900
901 901 def _calcheaderlines(self, levels):
902 902 # Calculate how many headerlines do we have to display, if we have
903 903 # ``levels`` browser levels
904 904 if levels is None:
905 905 levels = len(self.levels)
906 906 self._headerlines = min(self.maxheaders, levels)
907 907 self._firstheaderline = levels-self._headerlines
908 908
909 909 def getstylehere(self, style):
910 910 """
911 911 Return a style for displaying the original style ``style``
912 912 in the row the cursor is on.
913 913 """
914 914 return astyle.Style(style.fg, astyle.COLOR_BLUE, style.attrs | astyle.A_BOLD)
915 915
916 916 def report(self, msg):
917 917 """
918 918 Store the message ``msg`` for display below the footer line. This
919 919 will be displayed as soon as the screen is redrawn.
920 920 """
921 921 self._report = msg
922 922
923 923 def enter(self, item, *attrs):
924 924 """
925 925 Enter the object ``item``. If ``attrs`` is specified, it will be used
926 926 as a fixed list of attributes to display.
927 927 """
928 if self.levels and item is self.levels[-1].input:
929 curses.beep()
930 self.report(CommandError("Recursion on input object"))
931 else:
928 932 oldlevels = len(self.levels)
929 933 self._calcheaderlines(oldlevels+1)
930 934 try:
931 935 level = _BrowserLevel(
932 936 self,
933 937 item,
934 938 self.scrsizey-1-self._headerlines-2,
935 939 *attrs
936 940 )
937 941 except (KeyboardInterrupt, SystemExit):
938 942 raise
939 943 except Exception, exc:
940 944 self._calcheaderlines(oldlevels)
941 945 curses.beep()
942 946 self.report(exc)
943 947 else:
944 948 self.levels.append(level)
945 949
946 950 def startkeyboardinput(self, mode):
947 951 """
948 952 Enter mode ``mode``, which requires keyboard input.
949 953 """
950 954 self.mode = mode
951 955 self.prompts[mode].start()
952 956
953 957 def keylabel(self, keycode):
954 958 """
955 959 Return a pretty name for the ``curses`` key ``keycode`` (used in the
956 960 help screen and in reports about unassigned keys).
957 961 """
958 962 if keycode <= 0xff:
959 963 specialsnames = {
960 964 ord("\n"): "RETURN",
961 965 ord(" "): "SPACE",
962 966 ord("\t"): "TAB",
963 967 ord("\x7f"): "DELETE",
964 968 ord("\x08"): "BACKSPACE",
965 969 }
966 970 if keycode in specialsnames:
967 971 return specialsnames[keycode]
968 972 elif 0x00 < keycode < 0x20:
969 973 return "CTRL-%s" % chr(keycode + 64)
970 974 return repr(chr(keycode))
971 975 for name in dir(curses):
972 976 if name.startswith("KEY_") and getattr(curses, name) == keycode:
973 977 return name
974 978 return str(keycode)
975 979
976 980 def beep(self, force=False):
977 981 if force or self._dobeep:
978 982 curses.beep()
979 983 # don't beep again (as long as the same key is pressed)
980 984 self._dobeep = False
981 985
982 986 def cmd_up(self):
983 987 """
984 988 Move the cursor to the previous row.
985 989 """
986 990 level = self.levels[-1]
987 991 self.report("up")
988 992 level.moveto(level.curx, level.cury-self.stepy)
989 993
990 994 def cmd_down(self):
991 995 """
992 996 Move the cursor to the next row.
993 997 """
994 998 level = self.levels[-1]
995 999 self.report("down")
996 1000 level.moveto(level.curx, level.cury+self.stepy)
997 1001
998 1002 def cmd_pageup(self):
999 1003 """
1000 1004 Move the cursor up one page.
1001 1005 """
1002 1006 level = self.levels[-1]
1003 1007 self.report("page up")
1004 1008 level.moveto(level.curx, level.cury-level.mainsizey+self.pageoverlapy)
1005 1009
1006 1010 def cmd_pagedown(self):
1007 1011 """
1008 1012 Move the cursor down one page.
1009 1013 """
1010 1014 level = self.levels[-1]
1011 1015 self.report("page down")
1012 1016 level.moveto(level.curx, level.cury+level.mainsizey-self.pageoverlapy)
1013 1017
1014 1018 def cmd_left(self):
1015 1019 """
1016 1020 Move the cursor left.
1017 1021 """
1018 1022 level = self.levels[-1]
1019 1023 self.report("left")
1020 1024 level.moveto(level.curx-self.stepx, level.cury)
1021 1025
1022 1026 def cmd_right(self):
1023 1027 """
1024 1028 Move the cursor right.
1025 1029 """
1026 1030 level = self.levels[-1]
1027 1031 self.report("right")
1028 1032 level.moveto(level.curx+self.stepx, level.cury)
1029 1033
1030 1034 def cmd_home(self):
1031 1035 """
1032 1036 Move the cursor to the first column.
1033 1037 """
1034 1038 level = self.levels[-1]
1035 1039 self.report("home")
1036 1040 level.moveto(0, level.cury)
1037 1041
1038 1042 def cmd_end(self):
1039 1043 """
1040 1044 Move the cursor to the last column.
1041 1045 """
1042 1046 level = self.levels[-1]
1043 1047 self.report("end")
1044 1048 level.moveto(level.datasizex+level.mainsizey-self.pageoverlapx, level.cury)
1045 1049
1046 1050 def cmd_prevattr(self):
1047 1051 """
1048 1052 Move the cursor one attribute column to the left.
1049 1053 """
1050 1054 level = self.levels[-1]
1051 1055 if level.displayattr[0] is None or level.displayattr[0] == 0:
1052 1056 self.beep()
1053 1057 else:
1054 1058 self.report("prevattr")
1055 1059 pos = 0
1056 1060 for (i, attrname) in enumerate(level.displayattrs):
1057 1061 if i == level.displayattr[0]-1:
1058 1062 break
1059 1063 pos += level.colwidths[attrname] + 1
1060 1064 level.moveto(pos, level.cury)
1061 1065
1062 1066 def cmd_nextattr(self):
1063 1067 """
1064 1068 Move the cursor one attribute column to the right.
1065 1069 """
1066 1070 level = self.levels[-1]
1067 1071 if level.displayattr[0] is None or level.displayattr[0] == len(level.displayattrs)-1:
1068 1072 self.beep()
1069 1073 else:
1070 1074 self.report("nextattr")
1071 1075 pos = 0
1072 1076 for (i, attrname) in enumerate(level.displayattrs):
1073 1077 if i == level.displayattr[0]+1:
1074 1078 break
1075 1079 pos += level.colwidths[attrname] + 1
1076 1080 level.moveto(pos, level.cury)
1077 1081
1078 1082 def cmd_pick(self):
1079 1083 """
1080 1084 'Pick' the object under the cursor (i.e. the row the cursor is on).
1081 1085 This leaves the browser and returns the picked object to the caller.
1082 1086 (In IPython this object will be available as the ``_`` variable.)
1083 1087 """
1084 1088 level = self.levels[-1]
1085 1089 self.returnvalue = level.items[level.cury].item
1086 1090 return True
1087 1091
1088 1092 def cmd_pickattr(self):
1089 1093 """
1090 1094 'Pick' the attribute under the cursor (i.e. the row/column the
1091 1095 cursor is on).
1092 1096 """
1093 1097 level = self.levels[-1]
1094 1098 attr = level.displayattr[1]
1095 1099 if attr is ipipe.noitem:
1096 1100 curses.beep()
1097 1101 self.report(CommandError("no column under cursor"))
1098 1102 return
1099 1103 value = attr.value(level.items[level.cury].item)
1100 1104 if value is ipipe.noitem:
1101 1105 curses.beep()
1102 1106 self.report(AttributeError(attr.name()))
1103 1107 else:
1104 1108 self.returnvalue = value
1105 1109 return True
1106 1110
1107 1111 def cmd_pickallattrs(self):
1108 1112 """
1109 1113 Pick' the complete column under the cursor (i.e. the attribute under
1110 1114 the cursor) from all currently fetched objects. These attributes
1111 1115 will be returned as a list.
1112 1116 """
1113 1117 level = self.levels[-1]
1114 1118 attr = level.displayattr[1]
1115 1119 if attr is ipipe.noitem:
1116 1120 curses.beep()
1117 1121 self.report(CommandError("no column under cursor"))
1118 1122 return
1119 1123 result = []
1120 1124 for cache in level.items:
1121 1125 value = attr.value(cache.item)
1122 1126 if value is not ipipe.noitem:
1123 1127 result.append(value)
1124 1128 self.returnvalue = result
1125 1129 return True
1126 1130
1127 1131 def cmd_pickmarked(self):
1128 1132 """
1129 1133 'Pick' marked objects. Marked objects will be returned as a list.
1130 1134 """
1131 1135 level = self.levels[-1]
1132 1136 self.returnvalue = [cache.item for cache in level.items if cache.marked]
1133 1137 return True
1134 1138
1135 1139 def cmd_pickmarkedattr(self):
1136 1140 """
1137 1141 'Pick' the attribute under the cursor from all marked objects
1138 1142 (This returns a list).
1139 1143 """
1140 1144
1141 1145 level = self.levels[-1]
1142 1146 attr = level.displayattr[1]
1143 1147 if attr is ipipe.noitem:
1144 1148 curses.beep()
1145 1149 self.report(CommandError("no column under cursor"))
1146 1150 return
1147 1151 result = []
1148 1152 for cache in level.items:
1149 1153 if cache.marked:
1150 1154 value = attr.value(cache.item)
1151 1155 if value is not ipipe.noitem:
1152 1156 result.append(value)
1153 1157 self.returnvalue = result
1154 1158 return True
1155 1159
1156 1160 def cmd_markrange(self):
1157 1161 """
1158 1162 Mark all objects from the last marked object before the current cursor
1159 1163 position to the cursor position.
1160 1164 """
1161 1165 level = self.levels[-1]
1162 1166 self.report("markrange")
1163 1167 start = None
1164 1168 if level.items:
1165 1169 for i in xrange(level.cury, -1, -1):
1166 1170 if level.items[i].marked:
1167 1171 start = i
1168 1172 break
1169 1173 if start is None:
1170 1174 self.report(CommandError("no mark before cursor"))
1171 1175 curses.beep()
1172 1176 else:
1173 1177 for i in xrange(start, level.cury+1):
1174 1178 cache = level.items[i]
1175 1179 if not cache.marked:
1176 1180 cache.marked = True
1177 1181 level.marked += 1
1178 1182
1179 1183 def cmd_enter(self):
1180 1184 """
1181 1185 Enter the object under the cursor. (what this mean depends on the object
1182 1186 itself (i.e. how it implements iteration). This opens a new browser 'level'.
1183 1187 """
1184 1188 level = self.levels[-1]
1185 1189 try:
1186 1190 item = level.items[level.cury].item
1187 1191 except IndexError:
1188 1192 self.report(CommandError("No object"))
1189 1193 curses.beep()
1190 1194 else:
1191 1195 self.report("entering object...")
1192 1196 self.enter(item)
1193 1197
1194 1198 def cmd_leave(self):
1195 1199 """
1196 1200 Leave the current browser level and go back to the previous one.
1197 1201 """
1198 1202 self.report("leave")
1199 1203 if len(self.levels) > 1:
1200 1204 self._calcheaderlines(len(self.levels)-1)
1201 1205 self.levels.pop(-1)
1202 1206 else:
1203 1207 self.report(CommandError("This is the last level"))
1204 1208 curses.beep()
1205 1209
1206 1210 def cmd_enterattr(self):
1207 1211 """
1208 1212 Enter the attribute under the cursor.
1209 1213 """
1210 1214 level = self.levels[-1]
1211 1215 attr = level.displayattr[1]
1212 1216 if attr is ipipe.noitem:
1213 1217 curses.beep()
1214 1218 self.report(CommandError("no column under cursor"))
1215 1219 return
1216 1220 try:
1217 1221 item = level.items[level.cury].item
1218 1222 except IndexError:
1219 1223 self.report(CommandError("No object"))
1220 1224 curses.beep()
1221 1225 else:
1222 1226 value = attr.value(item)
1223 1227 name = attr.name()
1224 1228 if value is ipipe.noitem:
1225 1229 self.report(AttributeError(name))
1226 1230 else:
1227 1231 self.report("entering object attribute %s..." % name)
1228 1232 self.enter(value)
1229 1233
1230 1234 def cmd_detail(self):
1231 1235 """
1232 1236 Show a detail view of the object under the cursor. This shows the
1233 1237 name, type, doc string and value of the object attributes (and it
1234 1238 might show more attributes than in the list view, depending on
1235 1239 the object).
1236 1240 """
1237 1241 level = self.levels[-1]
1238 1242 try:
1239 1243 item = level.items[level.cury].item
1240 1244 except IndexError:
1241 1245 self.report(CommandError("No object"))
1242 1246 curses.beep()
1243 1247 else:
1244 1248 self.report("entering detail view for object...")
1245 1249 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
1246 1250 self.enter(attrs)
1247 1251
1248 1252 def cmd_detailattr(self):
1249 1253 """
1250 1254 Show a detail view of the attribute under the cursor.
1251 1255 """
1252 1256 level = self.levels[-1]
1253 1257 attr = level.displayattr[1]
1254 1258 if attr is ipipe.noitem:
1255 1259 curses.beep()
1256 1260 self.report(CommandError("no attribute"))
1257 1261 return
1258 1262 try:
1259 1263 item = level.items[level.cury].item
1260 1264 except IndexError:
1261 1265 self.report(CommandError("No object"))
1262 1266 curses.beep()
1263 1267 else:
1264 1268 try:
1265 1269 item = attr.value(item)
1266 1270 except (KeyboardInterrupt, SystemExit):
1267 1271 raise
1268 1272 except Exception, exc:
1269 1273 self.report(exc)
1270 1274 else:
1271 1275 self.report("entering detail view for attribute %s..." % attr.name())
1272 1276 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
1273 1277 self.enter(attrs)
1274 1278
1275 1279 def cmd_tooglemark(self):
1276 1280 """
1277 1281 Mark/unmark the object under the cursor. Marked objects have a '!'
1278 1282 after the row number).
1279 1283 """
1280 1284 level = self.levels[-1]
1281 1285 self.report("toggle mark")
1282 1286 try:
1283 1287 item = level.items[level.cury]
1284 1288 except IndexError: # no items?
1285 1289 pass
1286 1290 else:
1287 1291 if item.marked:
1288 1292 item.marked = False
1289 1293 level.marked -= 1
1290 1294 else:
1291 1295 item.marked = True
1292 1296 level.marked += 1
1293 1297
1294 1298 def cmd_sortattrasc(self):
1295 1299 """
1296 1300 Sort the objects (in ascending order) using the attribute under
1297 1301 the cursor as the sort key.
1298 1302 """
1299 1303 level = self.levels[-1]
1300 1304 attr = level.displayattr[1]
1301 1305 if attr is ipipe.noitem:
1302 1306 curses.beep()
1303 1307 self.report(CommandError("no column under cursor"))
1304 1308 return
1305 1309 self.report("sort by %s (ascending)" % attr.name())
1306 1310 def key(item):
1307 1311 try:
1308 1312 return attr.value(item)
1309 1313 except (KeyboardInterrupt, SystemExit):
1310 1314 raise
1311 1315 except Exception:
1312 1316 return None
1313 1317 level.sort(key)
1314 1318
1315 1319 def cmd_sortattrdesc(self):
1316 1320 """
1317 1321 Sort the objects (in descending order) using the attribute under
1318 1322 the cursor as the sort key.
1319 1323 """
1320 1324 level = self.levels[-1]
1321 1325 attr = level.displayattr[1]
1322 1326 if attr is ipipe.noitem:
1323 1327 curses.beep()
1324 1328 self.report(CommandError("no column under cursor"))
1325 1329 return
1326 1330 self.report("sort by %s (descending)" % attr.name())
1327 1331 def key(item):
1328 1332 try:
1329 1333 return attr.value(item)
1330 1334 except (KeyboardInterrupt, SystemExit):
1331 1335 raise
1332 1336 except Exception:
1333 1337 return None
1334 1338 level.sort(key, reverse=True)
1335 1339
1336 1340 def cmd_hideattr(self):
1337 1341 """
1338 1342 Hide the attribute under the cursor.
1339 1343 """
1340 1344 level = self.levels[-1]
1341 1345 if level.displayattr[0] is None:
1342 1346 self.beep()
1343 1347 else:
1344 1348 self.report("hideattr")
1345 1349 level.hiddenattrs.add(level.displayattr[1])
1346 1350 level.moveto(level.curx, level.cury, refresh=True)
1347 1351
1348 1352 def cmd_unhideattrs(self):
1349 1353 """
1350 1354 Make all attributes visible again.
1351 1355 """
1352 1356 level = self.levels[-1]
1353 1357 self.report("unhideattrs")
1354 1358 level.hiddenattrs.clear()
1355 1359 level.moveto(level.curx, level.cury, refresh=True)
1356 1360
1357 1361 def cmd_goto(self):
1358 1362 """
1359 1363 Jump to a row. The row number can be entered at the
1360 1364 bottom of the screen.
1361 1365 """
1362 1366 self.startkeyboardinput("goto")
1363 1367
1364 1368 def cmd_find(self):
1365 1369 """
1366 1370 Search forward for a row. The search condition can be entered at the
1367 1371 bottom of the screen.
1368 1372 """
1369 1373 self.startkeyboardinput("find")
1370 1374
1371 1375 def cmd_findbackwards(self):
1372 1376 """
1373 1377 Search backward for a row. The search condition can be entered at the
1374 1378 bottom of the screen.
1375 1379 """
1376 1380 self.startkeyboardinput("findbackwards")
1377 1381
1378 1382 def cmd_refresh(self):
1379 1383 """
1380 1384 Refreshes the display by restarting the iterator.
1381 1385 """
1382 1386 level = self.levels[-1]
1383 1387 self.report("refresh")
1384 1388 level.refresh()
1385 1389
1386 1390 def cmd_refreshfind(self):
1387 1391 """
1388 1392 Refreshes the display by restarting the iterator and goes back to the
1389 1393 same object the cursor was on before restarting (if this object can't be
1390 1394 found the cursor jumps back to the first object).
1391 1395 """
1392 1396 level = self.levels[-1]
1393 1397 self.report("refreshfind")
1394 1398 level.refreshfind()
1395 1399
1396 1400 def cmd_help(self):
1397 1401 """
1398 1402 Opens the help screen as a new browser level, describing keyboard
1399 1403 shortcuts.
1400 1404 """
1401 1405 for level in self.levels:
1402 1406 if isinstance(level.input, _BrowserHelp):
1403 1407 curses.beep()
1404 1408 self.report(CommandError("help already active"))
1405 1409 return
1406 1410
1407 1411 self.enter(_BrowserHelp(self))
1408 1412
1409 1413 def cmd_quit(self):
1410 1414 """
1411 1415 Quit the browser and return to the IPython prompt.
1412 1416 """
1413 1417 self.returnvalue = None
1414 1418 return True
1415 1419
1416 1420 def sigwinchhandler(self, signal, frame):
1417 1421 self.resized = True
1418 1422
1419 1423 def _dodisplay(self, scr):
1420 1424 """
1421 1425 This method is the workhorse of the browser. It handles screen
1422 1426 drawing and the keyboard.
1423 1427 """
1424 1428 self.scr = scr
1425 1429 curses.halfdelay(1)
1426 1430 footery = 2
1427 1431
1428 1432 keys = []
1429 1433 for cmd in ("quit", "help"):
1430 1434 key = self.keymap.findkey(cmd, None)
1431 1435 if key is not None:
1432 1436 keys.append("%s=%s" % (self.keylabel(key), cmd))
1433 1437 helpmsg = " | %s" % " ".join(keys)
1434 1438
1435 1439 scr.clear()
1436 1440 msg = "Fetching first batch of objects..."
1437 1441 (self.scrsizey, self.scrsizex) = scr.getmaxyx()
1438 1442 scr.addstr(self.scrsizey//2, (self.scrsizex-len(msg))//2, msg)
1439 1443 scr.refresh()
1440 1444
1441 1445 lastc = -1
1442 1446
1443 1447 self.levels = []
1444 1448 # enter the first level
1445 1449 self.enter(self.input, *self.attrs)
1446 1450
1447 1451 self._calcheaderlines(None)
1448 1452
1449 1453 while True:
1450 1454 level = self.levels[-1]
1451 1455 (self.scrsizey, self.scrsizex) = scr.getmaxyx()
1452 1456 level.mainsizey = self.scrsizey-1-self._headerlines-footery
1453 1457
1454 1458 # Paint object header
1455 1459 for i in xrange(self._firstheaderline, self._firstheaderline+self._headerlines):
1456 1460 lv = self.levels[i]
1457 1461 posx = 0
1458 1462 posy = i-self._firstheaderline
1459 1463 endx = self.scrsizex
1460 1464 if i: # not the first level
1461 1465 msg = " (%d/%d" % (self.levels[i-1].cury, len(self.levels[i-1].items))
1462 1466 if not self.levels[i-1].exhausted:
1463 1467 msg += "+"
1464 1468 msg += ") "
1465 1469 endx -= len(msg)+1
1466 1470 posx += self.addstr(posy, posx, 0, endx, " ibrowse #%d: " % i, self.style_objheadertext)
1467 1471 for (style, text) in lv.header:
1468 1472 posx += self.addstr(posy, posx, 0, endx, text, self.style_objheaderobject)
1469 1473 if posx >= endx:
1470 1474 break
1471 1475 if i:
1472 1476 posx += self.addstr(posy, posx, 0, self.scrsizex, msg, self.style_objheadernumber)
1473 1477 posx += self.addchr(posy, posx, 0, self.scrsizex, " ", self.scrsizex-posx, self.style_objheadernumber)
1474 1478
1475 1479 if not level.items:
1476 1480 self.addchr(self._headerlines, 0, 0, self.scrsizex, " ", self.scrsizex, self.style_colheader)
1477 1481 self.addstr(self._headerlines+1, 0, 0, self.scrsizex, " <empty>", astyle.style_error)
1478 1482 scr.clrtobot()
1479 1483 else:
1480 1484 # Paint column headers
1481 1485 scr.move(self._headerlines, 0)
1482 1486 scr.addstr(" %*s " % (level.numbersizex, "#"), self.getstyle(self.style_colheader))
1483 1487 scr.addstr(self.headersepchar, self.getstyle(self.style_colheadersep))
1484 1488 begx = level.numbersizex+3
1485 1489 posx = begx-level.datastartx
1486 1490 for attr in level.displayattrs:
1487 1491 attrname = attr.name()
1488 1492 cwidth = level.colwidths[attr]
1489 1493 header = attrname.ljust(cwidth)
1490 1494 if attr is level.displayattr[1]:
1491 1495 style = self.style_colheaderhere
1492 1496 else:
1493 1497 style = self.style_colheader
1494 1498 posx += self.addstr(self._headerlines, posx, begx, self.scrsizex, header, style)
1495 1499 posx += self.addstr(self._headerlines, posx, begx, self.scrsizex, self.headersepchar, self.style_colheadersep)
1496 1500 if posx >= self.scrsizex:
1497 1501 break
1498 1502 else:
1499 1503 scr.addstr(" "*(self.scrsizex-posx), self.getstyle(self.style_colheader))
1500 1504
1501 1505 # Paint rows
1502 1506 posy = self._headerlines+1+level.datastarty
1503 1507 for i in xrange(level.datastarty, min(level.datastarty+level.mainsizey, len(level.items))):
1504 1508 cache = level.items[i]
1505 1509 if i == level.cury:
1506 1510 style = self.style_numberhere
1507 1511 else:
1508 1512 style = self.style_number
1509 1513
1510 1514 posy = self._headerlines+1+i-level.datastarty
1511 1515 posx = begx-level.datastartx
1512 1516
1513 1517 scr.move(posy, 0)
1514 1518 scr.addstr(" %*d%s" % (level.numbersizex, i, " !"[cache.marked]), self.getstyle(style))
1515 1519 scr.addstr(self.headersepchar, self.getstyle(self.style_sep))
1516 1520
1517 1521 for attrname in level.displayattrs:
1518 1522 cwidth = level.colwidths[attrname]
1519 1523 try:
1520 1524 (align, length, parts) = level.displayrows[i-level.datastarty][attrname]
1521 1525 except KeyError:
1522 1526 align = 2
1523 1527 style = astyle.style_nodata
1524 1528 if i == level.cury:
1525 1529 style = self.getstylehere(style)
1526 1530 padstyle = self.style_datapad
1527 1531 sepstyle = self.style_sep
1528 1532 if i == level.cury:
1529 1533 padstyle = self.getstylehere(padstyle)
1530 1534 sepstyle = self.getstylehere(sepstyle)
1531 1535 if align == 2:
1532 1536 posx += self.addchr(posy, posx, begx, self.scrsizex, self.nodatachar, cwidth, style)
1533 1537 else:
1534 1538 if align == 1:
1535 1539 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, cwidth-length, padstyle)
1536 1540 elif align == 0:
1537 1541 pad1 = (cwidth-length)//2
1538 1542 pad2 = cwidth-length-len(pad1)
1539 1543 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, pad1, padstyle)
1540 1544 for (style, text) in parts:
1541 1545 if i == level.cury:
1542 1546 style = self.getstylehere(style)
1543 1547 posx += self.addstr(posy, posx, begx, self.scrsizex, text, style)
1544 1548 if posx >= self.scrsizex:
1545 1549 break
1546 1550 if align == -1:
1547 1551 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, cwidth-length, padstyle)
1548 1552 elif align == 0:
1549 1553 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, pad2, padstyle)
1550 1554 posx += self.addstr(posy, posx, begx, self.scrsizex, self.datasepchar, sepstyle)
1551 1555 else:
1552 1556 scr.clrtoeol()
1553 1557
1554 1558 # Add blank row headers for the rest of the screen
1555 1559 for posy in xrange(posy+1, self.scrsizey-2):
1556 1560 scr.addstr(posy, 0, " " * (level.numbersizex+2), self.getstyle(self.style_colheader))
1557 1561 scr.clrtoeol()
1558 1562
1559 1563 posy = self.scrsizey-footery
1560 1564 # Display footer
1561 1565 scr.addstr(posy, 0, " "*self.scrsizex, self.getstyle(self.style_footer))
1562 1566
1563 1567 if level.exhausted:
1564 1568 flag = ""
1565 1569 else:
1566 1570 flag = "+"
1567 1571
1568 1572 endx = self.scrsizex-len(helpmsg)-1
1569 1573 scr.addstr(posy, endx, helpmsg, self.getstyle(self.style_footer))
1570 1574
1571 1575 posx = 0
1572 1576 msg = " %d%s objects (%d marked): " % (len(level.items), flag, level.marked)
1573 1577 posx += self.addstr(posy, posx, 0, endx, msg, self.style_footer)
1574 1578 try:
1575 1579 item = level.items[level.cury].item
1576 1580 except IndexError: # empty
1577 1581 pass
1578 1582 else:
1579 1583 for (nostyle, text) in ipipe.xrepr(item, "footer"):
1580 1584 if not isinstance(nostyle, int):
1581 1585 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
1582 1586 if posx >= endx:
1583 1587 break
1584 1588
1585 1589 attrstyle = [(astyle.style_default, "no attribute")]
1586 1590 attr = level.displayattr[1]
1587 1591 if attr is not ipipe.noitem and not isinstance(attr, ipipe.SelfDescriptor):
1588 1592 posx += self.addstr(posy, posx, 0, endx, " | ", self.style_footer)
1589 1593 posx += self.addstr(posy, posx, 0, endx, attr.name(), self.style_footer)
1590 1594 posx += self.addstr(posy, posx, 0, endx, ": ", self.style_footer)
1591 1595 try:
1592 1596 value = attr.value(item)
1593 1597 except (SystemExit, KeyboardInterrupt):
1594 1598 raise
1595 1599 except Exception, exc:
1596 1600 value = exc
1597 1601 if value is not ipipe.noitem:
1598 1602 attrstyle = ipipe.xrepr(value, "footer")
1599 1603 for (nostyle, text) in attrstyle:
1600 1604 if not isinstance(nostyle, int):
1601 1605 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
1602 1606 if posx >= endx:
1603 1607 break
1604 1608
1605 1609 try:
1606 1610 # Display input prompt
1607 1611 if self.mode in self.prompts:
1608 1612 history = self.prompts[self.mode]
1609 1613 posx = 0
1610 1614 posy = self.scrsizey-1
1611 1615 posx += self.addstr(posy, posx, 0, endx, history.prompt, astyle.style_default)
1612 1616 posx += self.addstr(posy, posx, 0, endx, " [", astyle.style_default)
1613 1617 if history.cury==-1:
1614 1618 text = "new"
1615 1619 else:
1616 1620 text = str(history.cury+1)
1617 1621 posx += self.addstr(posy, posx, 0, endx, text, astyle.style_type_number)
1618 1622 if history.history:
1619 1623 posx += self.addstr(posy, posx, 0, endx, "/", astyle.style_default)
1620 1624 posx += self.addstr(posy, posx, 0, endx, str(len(history.history)), astyle.style_type_number)
1621 1625 posx += self.addstr(posy, posx, 0, endx, "]: ", astyle.style_default)
1622 1626 inputstartx = posx
1623 1627 posx += self.addstr(posy, posx, 0, endx, history.input, astyle.style_default)
1624 1628 # Display report
1625 1629 else:
1626 1630 if self._report is not None:
1627 1631 if isinstance(self._report, Exception):
1628 1632 style = self.getstyle(astyle.style_error)
1629 1633 if self._report.__class__.__module__ == "exceptions":
1630 1634 msg = "%s: %s" % \
1631 1635 (self._report.__class__.__name__, self._report)
1632 1636 else:
1633 1637 msg = "%s.%s: %s" % \
1634 1638 (self._report.__class__.__module__,
1635 1639 self._report.__class__.__name__, self._report)
1636 1640 else:
1637 1641 style = self.getstyle(self.style_report)
1638 1642 msg = self._report
1639 1643 scr.addstr(self.scrsizey-1, 0, msg[:self.scrsizex], style)
1640 1644 self._report = None
1641 1645 else:
1642 1646 scr.move(self.scrsizey-1, 0)
1643 1647 except curses.error:
1644 1648 # Protect against errors from writing to the last line
1645 1649 pass
1646 1650 scr.clrtoeol()
1647 1651
1648 1652 # Position cursor
1649 1653 if self.mode in self.prompts:
1650 1654 history = self.prompts[self.mode]
1651 1655 scr.move(self.scrsizey-1, inputstartx+history.curx)
1652 1656 else:
1653 1657 scr.move(
1654 1658 1+self._headerlines+level.cury-level.datastarty,
1655 1659 level.numbersizex+3+level.curx-level.datastartx
1656 1660 )
1657 1661 scr.refresh()
1658 1662
1659 1663 # Check keyboard
1660 1664 while True:
1661 1665 c = scr.getch()
1662 1666 if self.resized:
1663 1667 size = fcntl.ioctl(0, tty.TIOCGWINSZ, "12345678")
1664 1668 size = struct.unpack("4H", size)
1665 1669 oldsize = scr.getmaxyx()
1666 1670 scr.erase()
1667 1671 curses.resize_term(size[0], size[1])
1668 1672 newsize = scr.getmaxyx()
1669 1673 scr.erase()
1670 1674 for l in self.levels:
1671 1675 l.mainsizey += newsize[0]-oldsize[0]
1672 1676 l.moveto(l.curx, l.cury, refresh=True)
1673 1677 scr.refresh()
1674 1678 self.resized = False
1675 1679 break # Redisplay
1676 1680 if self.mode in self.prompts:
1677 1681 if self.prompts[self.mode].handlekey(self, c):
1678 1682 break # Redisplay
1679 1683 else:
1680 1684 # if no key is pressed slow down and beep again
1681 1685 if c == -1:
1682 1686 self.stepx = 1.
1683 1687 self.stepy = 1.
1684 1688 self._dobeep = True
1685 1689 else:
1686 1690 # if a different key was pressed slow down and beep too
1687 1691 if c != lastc:
1688 1692 lastc = c
1689 1693 self.stepx = 1.
1690 1694 self.stepy = 1.
1691 1695 self._dobeep = True
1692 1696 cmdname = self.keymap.get(c, None)
1693 1697 if cmdname is None:
1694 1698 self.report(
1695 1699 UnassignedKeyError("Unassigned key %s" %
1696 1700 self.keylabel(c)))
1697 1701 else:
1698 1702 cmdfunc = getattr(self, "cmd_%s" % cmdname, None)
1699 1703 if cmdfunc is None:
1700 1704 self.report(
1701 1705 UnknownCommandError("Unknown command %r" %
1702 1706 (cmdname,)))
1703 1707 elif cmdfunc():
1704 1708 returnvalue = self.returnvalue
1705 1709 self.returnvalue = None
1706 1710 return returnvalue
1707 1711 self.stepx = self.nextstepx(self.stepx)
1708 1712 self.stepy = self.nextstepy(self.stepy)
1709 1713 curses.flushinp() # get rid of type ahead
1710 1714 break # Redisplay
1711 1715 self.scr = None
1712 1716
1713 1717 def display(self):
1714 1718 if hasattr(curses, "resize_term"):
1715 1719 oldhandler = signal.signal(signal.SIGWINCH, self.sigwinchhandler)
1716 1720 try:
1717 1721 return curses.wrapper(self._dodisplay)
1718 1722 finally:
1719 1723 signal.signal(signal.SIGWINCH, oldhandler)
1720 1724 else:
1721 1725 return curses.wrapper(self._dodisplay)
@@ -1,2133 +1,2139 b''
1 1 # -*- coding: iso-8859-1 -*-
2 2
3 3 """
4 4 ``ipipe`` provides classes to be used in an interactive Python session. Doing a
5 5 ``from ipipe import *`` is the preferred way to do this. The name of all
6 6 objects imported this way starts with ``i`` to minimize collisions.
7 7
8 8 ``ipipe`` supports "pipeline expressions", which is something resembling Unix
9 9 pipes. An example is:
10 10
11 11 >>> ienv | isort("key.lower()")
12 12
13 13 This gives a listing of all environment variables sorted by name.
14 14
15 15
16 16 There are three types of objects in a pipeline expression:
17 17
18 18 * ``Table``s: These objects produce items. Examples are ``ils`` (listing the
19 19 current directory, ``ienv`` (listing environment variables), ``ipwd`` (listing
20 20 user accounts) and ``igrp`` (listing user groups). A ``Table`` must be the
21 21 first object in a pipe expression.
22 22
23 23 * ``Pipe``s: These objects sit in the middle of a pipe expression. They
24 24 transform the input in some way (e.g. filtering or sorting it). Examples are:
25 25 ``ifilter`` (which filters the input pipe), ``isort`` (which sorts the input
26 26 pipe) and ``ieval`` (which evaluates a function or expression for each object
27 27 in the input pipe).
28 28
29 29 * ``Display``s: These objects can be put as the last object in a pipeline
30 30 expression. There are responsible for displaying the result of the pipeline
31 31 expression. If a pipeline expression doesn't end in a display object a default
32 32 display objects will be used. One example is ``ibrowse`` which is a ``curses``
33 33 based browser.
34 34
35 35
36 36 Adding support for pipeline expressions to your own objects can be done through
37 37 three extensions points (all of them optional):
38 38
39 39 * An object that will be displayed as a row by a ``Display`` object should
40 40 implement the method ``__xattrs__(self, mode)`` method or register an
41 41 implementation of the generic function ``xattrs``. For more info see ``xattrs``.
42 42
43 43 * When an object ``foo`` is displayed by a ``Display`` object, the generic
44 44 function ``xrepr`` is used.
45 45
46 46 * Objects that can be iterated by ``Pipe``s must iterable. For special cases,
47 47 where iteration for display is different than the normal iteration a special
48 48 implementation can be registered with the generic function ``xiter``. This makes
49 49 it possible to use dictionaries and modules in pipeline expressions, for example:
50 50
51 51 >>> import sys
52 52 >>> sys | ifilter("isinstance(value, int)") | idump
53 53 key |value
54 54 api_version| 1012
55 55 dllhandle | 503316480
56 56 hexversion | 33817328
57 57 maxint |2147483647
58 58 maxunicode | 65535
59 59 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
60 60 ...
61 61
62 62 Note: The expression strings passed to ``ifilter()`` and ``isort()`` can
63 63 refer to the object to be filtered or sorted via the variable ``_`` and to any
64 64 of the attributes of the object, i.e.:
65 65
66 66 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
67 67
68 68 does the same as
69 69
70 70 >>> sys.modules | ifilter("value is not None") | isort("key.lower()")
71 71
72 72 In addition to expression strings, it's possible to pass callables (taking
73 73 the object as an argument) to ``ifilter()``, ``isort()`` and ``ieval()``:
74 74
75 75 >>> sys | ifilter(lambda _:isinstance(_.value, int)) \
76 76 ... | ieval(lambda _: (_.key, hex(_.value))) | idump
77 77 0 |1
78 78 api_version|0x3f4
79 79 dllhandle |0x1e000000
80 80 hexversion |0x20402f0
81 81 maxint |0x7fffffff
82 82 maxunicode |0xffff
83 83 """
84 84
85 85 import sys, os, os.path, stat, glob, new, csv, datetime, types
86 86 import itertools, mimetypes
87 87
88 88 try: # Python 2.3 compatibility
89 89 import collections
90 90 except ImportError:
91 91 deque = list
92 92 else:
93 93 deque = collections.deque
94 94
95 95 try: # Python 2.3 compatibility
96 96 set
97 97 except NameError:
98 98 import sets
99 99 set = sets.Set
100 100
101 101 try: # Python 2.3 compatibility
102 102 sorted
103 103 except NameError:
104 104 def sorted(iterator, key=None, reverse=False):
105 105 items = list(iterator)
106 106 if key is not None:
107 107 items.sort(lambda i1, i2: cmp(key(i1), key(i2)))
108 108 else:
109 109 items.sort()
110 110 if reverse:
111 111 items.reverse()
112 112 return items
113 113
114 114 try:
115 115 import pwd
116 116 except ImportError:
117 117 pwd = None
118 118
119 119 try:
120 120 import grp
121 121 except ImportError:
122 122 grp = None
123 123
124 124 from IPython.external import simplegeneric
125 125
126 126 import path
127 127 try:
128 128 from IPython import genutils, ipapi
129 129 except ImportError:
130 130 genutils = None
131 131 ipapi = None
132 132
133 133 import astyle
134 134
135 135
136 136 __all__ = [
137 137 "ifile", "ils", "iglob", "iwalk", "ipwdentry", "ipwd", "igrpentry", "igrp",
138 138 "icsv", "ix", "ichain", "isort", "ifilter", "ieval", "ienum", "ienv",
139 139 "idump", "iless"
140 140 ]
141 141
142 142
143 143 os.stat_float_times(True) # enable microseconds
144 144
145 145
146 146 class AttrNamespace(object):
147 147 """
148 148 Helper class that is used for providing a namespace for evaluating
149 149 expressions containing attribute names of an object.
150 150 """
151 151 def __init__(self, wrapped):
152 152 self.wrapped = wrapped
153 153
154 154 def __getitem__(self, name):
155 155 if name == "_":
156 156 return self.wrapped
157 157 try:
158 158 return getattr(self.wrapped, name)
159 159 except AttributeError:
160 160 raise KeyError(name)
161 161
162 162 # Python 2.3 compatibility
163 163 # use eval workaround to find out which names are used in the
164 164 # eval string and put them into the locals. This works for most
165 165 # normal uses case, bizarre ones like accessing the locals()
166 166 # will fail
167 167 try:
168 168 eval("_", None, AttrNamespace(None))
169 169 except TypeError:
170 170 real_eval = eval
171 171 def eval(codestring, _globals, _locals):
172 172 """
173 173 eval(source[, globals[, locals]]) -> value
174 174
175 175 Evaluate the source in the context of globals and locals.
176 176 The source may be a string representing a Python expression
177 177 or a code object as returned by compile().
178 178 The globals must be a dictionary and locals can be any mappping.
179 179
180 180 This function is a workaround for the shortcomings of
181 181 Python 2.3's eval.
182 182 """
183 183
184 184 if isinstance(codestring, basestring):
185 185 code = compile(codestring, "_eval", "eval")
186 186 else:
187 187 code = codestring
188 188 newlocals = {}
189 189 for name in code.co_names:
190 190 try:
191 191 newlocals[name] = _locals[name]
192 192 except KeyError:
193 193 pass
194 194 return real_eval(code, _globals, newlocals)
195 195
196 196
197 197 noitem = object()
198 198
199 199 def item(iterator, index, default=noitem):
200 200 """
201 201 Return the ``index``th item from the iterator ``iterator``.
202 202 ``index`` must be an integer (negative integers are relative to the
203 203 end (i.e. the last items produced by the iterator)).
204 204
205 205 If ``default`` is given, this will be the default value when
206 206 the iterator doesn't contain an item at this position. Otherwise an
207 207 ``IndexError`` will be raised.
208 208
209 209 Note that using this function will partially or totally exhaust the
210 210 iterator.
211 211 """
212 212 i = index
213 213 if i>=0:
214 214 for item in iterator:
215 215 if not i:
216 216 return item
217 217 i -= 1
218 218 else:
219 219 i = -index
220 220 cache = deque()
221 221 for item in iterator:
222 222 cache.append(item)
223 223 if len(cache)>i:
224 224 cache.popleft()
225 225 if len(cache)==i:
226 226 return cache.popleft()
227 227 if default is noitem:
228 228 raise IndexError(index)
229 229 else:
230 230 return default
231 231
232 232
233 233 def getglobals(g):
234 234 """
235 235 Return the global namespace that is used for expression strings in
236 236 ``ifilter`` and others. This is ``g`` or (if ``g`` is ``None``) IPython's
237 237 user namespace.
238 238 """
239 239 if g is None:
240 240 if ipapi is not None:
241 241 api = ipapi.get()
242 242 if api is not None:
243 243 return api.user_ns
244 244 return globals()
245 245 return g
246 246
247 247
248 248 class Descriptor(object):
249 249 """
250 250 A ``Descriptor`` object is used for describing the attributes of objects.
251 251 """
252 252 def __hash__(self):
253 253 return hash(self.__class__) ^ hash(self.key())
254 254
255 255 def __eq__(self, other):
256 256 return self.__class__ is other.__class__ and self.key() == other.key()
257 257
258 258 def __ne__(self, other):
259 259 return self.__class__ is not other.__class__ or self.key() != other.key()
260 260
261 261 def key(self):
262 262 pass
263 263
264 264 def name(self):
265 265 """
266 266 Return the name of this attribute for display by a ``Display`` object
267 267 (e.g. as a column title).
268 268 """
269 269 key = self.key()
270 270 if key is None:
271 271 return "_"
272 272 return str(key)
273 273
274 274 def attrtype(self, obj):
275 275 """
276 276 Return the type of this attribute (i.e. something like "attribute" or
277 277 "method").
278 278 """
279 279
280 280 def valuetype(self, obj):
281 281 """
282 282 Return the type of this attribute value of the object ``obj``.
283 283 """
284 284
285 285 def value(self, obj):
286 286 """
287 287 Return the value of this attribute of the object ``obj``.
288 288 """
289 289
290 290 def doc(self, obj):
291 291 """
292 292 Return the documentation for this attribute.
293 293 """
294 294
295 295 def shortdoc(self, obj):
296 296 """
297 297 Return a short documentation for this attribute (defaulting to the
298 298 first line).
299 299 """
300 300 doc = self.doc(obj)
301 301 if doc is not None:
302 302 doc = doc.strip().splitlines()[0].strip()
303 303 return doc
304 304
305 305 def iter(self, obj):
306 306 """
307 307 Return an iterator for this attribute of the object ``obj``.
308 308 """
309 309 return xiter(self.value(obj))
310 310
311 311
312 312 class SelfDescriptor(Descriptor):
313 313 """
314 314 A ``SelfDescriptor`` describes the object itself.
315 315 """
316 316 def key(self):
317 317 return None
318 318
319 319 def attrtype(self, obj):
320 320 return "self"
321 321
322 322 def valuetype(self, obj):
323 323 return type(obj)
324 324
325 325 def value(self, obj):
326 326 return obj
327 327
328 328 def __repr__(self):
329 329 return "Self"
330 330
331 331 selfdescriptor = SelfDescriptor() # there's no need for more than one
332 332
333 333
334 334 class AttributeDescriptor(Descriptor):
335 335 """
336 336 An ``AttributeDescriptor`` describes a simple attribute of an object.
337 337 """
338 338 __slots__ = ("_name", "_doc")
339 339
340 340 def __init__(self, name, doc=None):
341 341 self._name = name
342 342 self._doc = doc
343 343
344 344 def key(self):
345 345 return self._name
346 346
347 347 def doc(self, obj):
348 348 return self._doc
349 349
350 350 def attrtype(self, obj):
351 351 return "attr"
352 352
353 353 def valuetype(self, obj):
354 354 return type(getattr(obj, self._name))
355 355
356 356 def value(self, obj):
357 357 return getattr(obj, self._name)
358 358
359 359 def __repr__(self):
360 360 if self._doc is None:
361 361 return "Attribute(%r)" % self._name
362 362 else:
363 363 return "Attribute(%r, %r)" % (self._name, self._doc)
364 364
365 365
366 366 class IndexDescriptor(Descriptor):
367 367 """
368 368 An ``IndexDescriptor`` describes an "attribute" of an object that is fetched
369 369 via ``__getitem__``.
370 370 """
371 371 __slots__ = ("_index",)
372 372
373 373 def __init__(self, index):
374 374 self._index = index
375 375
376 376 def key(self):
377 377 return self._index
378 378
379 379 def attrtype(self, obj):
380 380 return "item"
381 381
382 382 def valuetype(self, obj):
383 383 return type(obj[self._index])
384 384
385 385 def value(self, obj):
386 386 return obj[self._index]
387 387
388 388 def __repr__(self):
389 389 return "Index(%r)" % self._index
390 390
391 391
392 392 class MethodDescriptor(Descriptor):
393 393 """
394 394 A ``MethodDescriptor`` describes a method of an object that can be called
395 395 without argument. Note that this method shouldn't change the object.
396 396 """
397 397 __slots__ = ("_name", "_doc")
398 398
399 399 def __init__(self, name, doc=None):
400 400 self._name = name
401 401 self._doc = doc
402 402
403 403 def key(self):
404 404 return self._name
405 405
406 406 def doc(self, obj):
407 407 if self._doc is None:
408 408 return getattr(obj, self._name).__doc__
409 409 return self._doc
410 410
411 411 def attrtype(self, obj):
412 412 return "method"
413 413
414 414 def valuetype(self, obj):
415 415 return type(self.value(obj))
416 416
417 417 def value(self, obj):
418 418 return getattr(obj, self._name)()
419 419
420 420 def __repr__(self):
421 421 if self._doc is None:
422 422 return "Method(%r)" % self._name
423 423 else:
424 424 return "Method(%r, %r)" % (self._name, self._doc)
425 425
426 426
427 427 class IterAttributeDescriptor(Descriptor):
428 428 """
429 429 An ``IterAttributeDescriptor`` works like an ``AttributeDescriptor`` but
430 430 doesn't return an attribute values (because this value might be e.g. a large
431 431 list).
432 432 """
433 433 __slots__ = ("_name", "_doc")
434 434
435 435 def __init__(self, name, doc=None):
436 436 self._name = name
437 437 self._doc = doc
438 438
439 439 def key(self):
440 440 return self._name
441 441
442 442 def doc(self, obj):
443 443 return self._doc
444 444
445 445 def attrtype(self, obj):
446 446 return "iter"
447 447
448 448 def valuetype(self, obj):
449 449 return noitem
450 450
451 451 def value(self, obj):
452 452 return noitem
453 453
454 454 def iter(self, obj):
455 455 return xiter(getattr(obj, self._name))
456 456
457 457 def __repr__(self):
458 458 if self._doc is None:
459 459 return "IterAttribute(%r)" % self._name
460 460 else:
461 461 return "IterAttribute(%r, %r)" % (self._name, self._doc)
462 462
463 463
464 464 class IterMethodDescriptor(Descriptor):
465 465 """
466 466 An ``IterMethodDescriptor`` works like an ``MethodDescriptor`` but doesn't
467 467 return an attribute values (because this value might be e.g. a large list).
468 468 """
469 469 __slots__ = ("_name", "_doc")
470 470
471 471 def __init__(self, name, doc=None):
472 472 self._name = name
473 473 self._doc = doc
474 474
475 475 def key(self):
476 476 return self._name
477 477
478 478 def doc(self, obj):
479 479 if self._doc is None:
480 480 return getattr(obj, self._name).__doc__
481 481 return self._doc
482 482
483 483 def attrtype(self, obj):
484 484 return "itermethod"
485 485
486 486 def valuetype(self, obj):
487 487 return noitem
488 488
489 489 def value(self, obj):
490 490 return noitem
491 491
492 492 def iter(self, obj):
493 493 return xiter(getattr(obj, self._name)())
494 494
495 495 def __repr__(self):
496 496 if self._doc is None:
497 497 return "IterMethod(%r)" % self._name
498 498 else:
499 499 return "IterMethod(%r, %r)" % (self._name, self._doc)
500 500
501 501
502 502 class FunctionDescriptor(Descriptor):
503 503 """
504 504 A ``FunctionDescriptor`` turns a function into a descriptor. The function
505 505 will be called with the object to get the type and value of the attribute.
506 506 """
507 507 __slots__ = ("_function", "_name", "_doc")
508 508
509 509 def __init__(self, function, name=None, doc=None):
510 510 self._function = function
511 511 self._name = name
512 512 self._doc = doc
513 513
514 514 def key(self):
515 515 return self._function
516 516
517 517 def name(self):
518 518 if self._name is not None:
519 519 return self._name
520 520 return getattr(self._function, "__xname__", self._function.__name__)
521 521
522 522 def doc(self, obj):
523 523 if self._doc is None:
524 524 return self._function.__doc__
525 525 return self._doc
526 526
527 527 def attrtype(self, obj):
528 528 return "function"
529 529
530 530 def valuetype(self, obj):
531 531 return type(self._function(obj))
532 532
533 533 def value(self, obj):
534 534 return self._function(obj)
535 535
536 536 def __repr__(self):
537 537 if self._doc is None:
538 538 return "Function(%r)" % self._name
539 539 else:
540 540 return "Function(%r, %r)" % (self._name, self._doc)
541 541
542 542
543 543 class Table(object):
544 544 """
545 545 A ``Table`` is an object that produces items (just like a normal Python
546 546 iterator/generator does) and can be used as the first object in a pipeline
547 547 expression. The displayhook will open the default browser for such an object
548 548 (instead of simply printing the ``repr()`` result).
549 549 """
550 550
551 551 # We want to support ``foo`` and ``foo()`` in pipeline expression:
552 552 # So we implement the required operators (``|`` and ``+``) in the metaclass,
553 553 # instantiate the class and forward the operator to the instance
554 554 class __metaclass__(type):
555 555 def __iter__(self):
556 556 return iter(self())
557 557
558 558 def __or__(self, other):
559 559 return self() | other
560 560
561 561 def __add__(self, other):
562 562 return self() + other
563 563
564 564 def __radd__(self, other):
565 565 return other + self()
566 566
567 567 def __getitem__(self, index):
568 568 return self()[index]
569 569
570 570 def __getitem__(self, index):
571 571 return item(self, index)
572 572
573 573 def __contains__(self, item):
574 574 for haveitem in self:
575 575 if item == haveitem:
576 576 return True
577 577 return False
578 578
579 579 def __or__(self, other):
580 580 # autoinstantiate right hand side
581 581 if isinstance(other, type) and issubclass(other, (Table, Display)):
582 582 other = other()
583 583 # treat simple strings and functions as ``ieval`` instances
584 584 elif not isinstance(other, Display) and not isinstance(other, Table):
585 585 other = ieval(other)
586 586 # forward operations to the right hand side
587 587 return other.__ror__(self)
588 588
589 589 def __add__(self, other):
590 590 # autoinstantiate right hand side
591 591 if isinstance(other, type) and issubclass(other, Table):
592 592 other = other()
593 593 return ichain(self, other)
594 594
595 595 def __radd__(self, other):
596 596 # autoinstantiate left hand side
597 597 if isinstance(other, type) and issubclass(other, Table):
598 598 other = other()
599 599 return ichain(other, self)
600 600
601 601
602 602 class Pipe(Table):
603 603 """
604 604 A ``Pipe`` is an object that can be used in a pipeline expression. It
605 605 processes the objects it gets from its input ``Table``/``Pipe``. Note that
606 606 a ``Pipe`` object can't be used as the first object in a pipeline
607 607 expression, as it doesn't produces items itself.
608 608 """
609 609 class __metaclass__(Table.__metaclass__):
610 610 def __ror__(self, input):
611 611 return input | self()
612 612
613 613 def __ror__(self, input):
614 614 # autoinstantiate left hand side
615 615 if isinstance(input, type) and issubclass(input, Table):
616 616 input = input()
617 617 self.input = input
618 618 return self
619 619
620 620
621 621 def xrepr(item, mode="default"):
622 622 """
623 623 Generic function that adds color output and different display modes to ``repr``.
624 624
625 625 The result of an ``xrepr`` call is iterable and consists of ``(style, string)``
626 626 tuples. The ``style`` in this tuple must be a ``Style`` object from the
627 627 ``astring`` module. To reconfigure the output the first yielded tuple can be
628 628 a ``(aligment, full)`` tuple instead of a ``(style, string)`` tuple.
629 629 ``alignment`` can be -1 for left aligned, 0 for centered and 1 for right
630 630 aligned (the default is left alignment). ``full`` is a boolean that specifies
631 631 whether the complete output must be displayed or the ``Display`` object is
632 632 allowed to stop output after enough text has been produced (e.g. a syntax
633 633 highlighted text line would use ``True``, but for a large data structure
634 634 (i.e. a nested list, tuple or dictionary) ``False`` would be used).
635 635 The default is full output.
636 636
637 637 There are four different possible values for ``mode`` depending on where
638 638 the ``Display`` object will display ``item``:
639 639
640 640 * ``"header"``: ``item`` will be displayed in a header line (this is used by
641 641 ``ibrowse``).
642 642 * ``"footer"``: ``item`` will be displayed in a footer line (this is used by
643 643 ``ibrowse``).
644 644 * ``"cell"``: ``item`` will be displayed in a table cell/list.
645 645 * ``"default"``: default mode. If an ``xrepr`` implementation recursively
646 646 outputs objects, ``"default"`` must be passed in the recursive calls to
647 647 ``xrepr``.
648 648
649 649 If no implementation is registered for ``item``, ``xrepr`` will try the
650 650 ``__xrepr__`` method on ``item``. If ``item`` doesn't have an ``__xrepr__``
651 651 method it falls back to ``repr``/``__repr__`` for all modes.
652 652 """
653 653 try:
654 654 func = item.__xrepr__
655 655 except AttributeError:
656 656 yield (astyle.style_default, repr(item))
657 657 else:
658 658 try:
659 659 for x in func(mode):
660 660 yield x
661 661 except (KeyboardInterrupt, SystemExit):
662 662 raise
663 663 except Exception:
664 664 yield (astyle.style_default, repr(item))
665 665 xrepr = simplegeneric.generic(xrepr)
666 666
667 667
668 668 def xrepr_none(self, mode="default"):
669 669 yield (astyle.style_type_none, repr(self))
670 670 xrepr.when_object(None)(xrepr_none)
671 671
672 672
673 673 def xrepr_bool(self, mode="default"):
674 674 yield (astyle.style_type_bool, repr(self))
675 675 xrepr.when_type(bool)(xrepr_bool)
676 676
677 677
678 678 def xrepr_str(self, mode="default"):
679 679 if mode == "cell":
680 680 yield (astyle.style_default, repr(self.expandtabs(tab))[1:-1])
681 681 else:
682 682 yield (astyle.style_default, repr(self))
683 683 xrepr.when_type(str)(xrepr_str)
684 684
685 685
686 686 def xrepr_unicode(self, mode="default"):
687 687 if mode == "cell":
688 688 yield (astyle.style_default, repr(self.expandtabs(tab))[2:-1])
689 689 else:
690 690 yield (astyle.style_default, repr(self))
691 691 xrepr.when_type(unicode)(xrepr_unicode)
692 692
693 693
694 694 def xrepr_number(self, mode="default"):
695 695 yield (1, True)
696 696 yield (astyle.style_type_number, repr(self))
697 697 xrepr.when_type(int)(xrepr_number)
698 698 xrepr.when_type(long)(xrepr_number)
699 699 xrepr.when_type(float)(xrepr_number)
700 700
701 701
702 702 def xrepr_complex(self, mode="default"):
703 703 yield (astyle.style_type_number, repr(self))
704 704 xrepr.when_type(complex)(xrepr_number)
705 705
706 706
707 707 def xrepr_datetime(self, mode="default"):
708 708 if mode == "cell":
709 709 # Don't use strftime() here, as this requires year >= 1900
710 710 yield (astyle.style_type_datetime,
711 711 "%04d-%02d-%02d %02d:%02d:%02d.%06d" % \
712 712 (self.year, self.month, self.day,
713 713 self.hour, self.minute, self.second,
714 714 self.microsecond),
715 715 )
716 716 else:
717 717 yield (astyle.style_type_datetime, repr(self))
718 718 xrepr.when_type(datetime.datetime)(xrepr_datetime)
719 719
720 720
721 721 def xrepr_date(self, mode="default"):
722 722 if mode == "cell":
723 723 yield (astyle.style_type_datetime,
724 724 "%04d-%02d-%02d" % (self.year, self.month, self.day))
725 725 else:
726 726 yield (astyle.style_type_datetime, repr(self))
727 727 xrepr.when_type(datetime.date)(xrepr_date)
728 728
729 729
730 730 def xrepr_time(self, mode="default"):
731 731 if mode == "cell":
732 732 yield (astyle.style_type_datetime,
733 733 "%02d:%02d:%02d.%06d" % \
734 734 (self.hour, self.minute, self.second, self.microsecond))
735 735 else:
736 736 yield (astyle.style_type_datetime, repr(self))
737 737 xrepr.when_type(datetime.time)(xrepr_time)
738 738
739 739
740 740 def xrepr_timedelta(self, mode="default"):
741 741 yield (astyle.style_type_datetime, repr(self))
742 742 xrepr.when_type(datetime.timedelta)(xrepr_timedelta)
743 743
744 744
745 745 def xrepr_type(self, mode="default"):
746 746 if self.__module__ == "__builtin__":
747 747 yield (astyle.style_type_type, self.__name__)
748 748 else:
749 749 yield (astyle.style_type_type, "%s.%s" % (self.__module__, self.__name__))
750 750 xrepr.when_type(type)(xrepr_type)
751 751
752 752
753 753 def xrepr_exception(self, mode="default"):
754 754 if self.__class__.__module__ == "exceptions":
755 755 classname = self.__class__.__name__
756 756 else:
757 757 classname = "%s.%s" % \
758 758 (self.__class__.__module__, self.__class__.__name__)
759 759 if mode == "header" or mode == "footer":
760 760 yield (astyle.style_error, "%s: %s" % (classname, self))
761 761 else:
762 762 yield (astyle.style_error, classname)
763 763 xrepr.when_type(Exception)(xrepr_exception)
764 764
765 765
766 766 def xrepr_listtuple(self, mode="default"):
767 767 if mode == "header" or mode == "footer":
768 768 if self.__class__.__module__ == "__builtin__":
769 769 classname = self.__class__.__name__
770 770 else:
771 771 classname = "%s.%s" % \
772 772 (self.__class__.__module__,self.__class__.__name__)
773 773 yield (astyle.style_default,
774 774 "<%s object with %d items at 0x%x>" % \
775 775 (classname, len(self), id(self)))
776 776 else:
777 777 yield (-1, False)
778 778 if isinstance(self, list):
779 779 yield (astyle.style_default, "[")
780 780 end = "]"
781 781 else:
782 782 yield (astyle.style_default, "(")
783 783 end = ")"
784 784 for (i, subself) in enumerate(self):
785 785 if i:
786 786 yield (astyle.style_default, ", ")
787 787 for part in xrepr(subself, "default"):
788 788 yield part
789 789 yield (astyle.style_default, end)
790 790 xrepr.when_type(list)(xrepr_listtuple)
791 791 xrepr.when_type(tuple)(xrepr_listtuple)
792 792
793 793
794 794 def xrepr_dict(self, mode="default"):
795 795 if mode == "header" or mode == "footer":
796 796 if self.__class__.__module__ == "__builtin__":
797 797 classname = self.__class__.__name__
798 798 else:
799 799 classname = "%s.%s" % \
800 800 (self.__class__.__module__,self.__class__.__name__)
801 801 yield (astyle.style_default,
802 802 "<%s object with %d items at 0x%x>" % \
803 803 (classname, len(self), id(self)))
804 804 else:
805 805 yield (-1, False)
806 806 if isinstance(self, dict):
807 807 yield (astyle.style_default, "{")
808 808 end = "}"
809 809 else:
810 810 yield (astyle.style_default, "dictproxy((")
811 811 end = "})"
812 812 for (i, (key, value)) in enumerate(self.iteritems()):
813 813 if i:
814 814 yield (astyle.style_default, ", ")
815 815 for part in xrepr(key, "default"):
816 816 yield part
817 817 yield (astyle.style_default, ": ")
818 818 for part in xrepr(value, "default"):
819 819 yield part
820 820 yield (astyle.style_default, end)
821 821 xrepr.when_type(dict)(xrepr_dict)
822 822 xrepr.when_type(types.DictProxyType)(xrepr_dict)
823 823
824 824
825 825 def upgradexattr(attr):
826 826 """
827 827 Convert an attribute descriptor string to a real descriptor object.
828 828
829 829 If attr already is a descriptor object return if unmodified. A
830 830 ``SelfDescriptor`` will be returned if ``attr`` is ``None``. ``"foo"``
831 831 returns an ``AttributeDescriptor`` for the attribute named ``"foo"``.
832 832 ``"foo()"`` returns a ``MethodDescriptor`` for the method named ``"foo"``.
833 833 ``"-foo"`` will return an ``IterAttributeDescriptor`` for the attribute
834 834 named ``"foo"`` and ``"-foo()"`` will return an ``IterMethodDescriptor``
835 835 for the method named ``"foo"``. Furthermore integer will return the appropriate
836 836 ``IndexDescriptor`` and callables will return a ``FunctionDescriptor``.
837 837 """
838 838 if attr is None:
839 839 return selfdescriptor
840 840 elif isinstance(attr, Descriptor):
841 841 return attr
842 842 elif isinstance(attr, str):
843 843 if attr.endswith("()"):
844 844 if attr.startswith("-"):
845 845 return IterMethodDescriptor(attr[1:-2])
846 846 else:
847 847 return MethodDescriptor(attr[:-2])
848 848 else:
849 849 if attr.startswith("-"):
850 850 return IterAttributeDescriptor(attr[1:])
851 851 else:
852 852 return AttributeDescriptor(attr)
853 853 elif isinstance(attr, (int, long)):
854 854 return IndexDescriptor(attr)
855 855 elif callable(attr):
856 856 return FunctionDescriptor(attr)
857 857 else:
858 858 raise TypeError("can't handle descriptor %r" % attr)
859 859
860 860
861 861 def xattrs(item, mode="default"):
862 862 """
863 863 Generic function that returns an iterable of attribute descriptors
864 864 to be used for displaying the attributes ob the object ``item`` in display
865 865 mode ``mode``.
866 866
867 867 There are two possible modes:
868 868
869 869 * ``"detail"``: The ``Display`` object wants to display a detailed list
870 870 of the object attributes.
871 871 * ``"default"``: The ``Display`` object wants to display the object in a
872 872 list view.
873 873
874 874 If no implementation is registered for the object ``item`` ``xattrs`` falls
875 875 back to trying the ``__xattrs__`` method of the object. If this doesn't
876 876 exist either, ``dir(item)`` is used for ``"detail"`` mode and ``(None,)``
877 877 for ``"default"`` mode.
878 878
879 879 The implementation must yield attribute descriptor (see the class
880 880 ``Descriptor`` for more info). The ``__xattrs__`` method may also return
881 881 attribute descriptor string (and ``None``) which will be converted to real
882 882 descriptors by ``upgradexattr()``.
883 883 """
884 884 try:
885 885 func = item.__xattrs__
886 886 except AttributeError:
887 887 if mode == "detail":
888 888 for attrname in dir(item):
889 889 yield AttributeDescriptor(attrname)
890 890 else:
891 891 yield selfdescriptor
892 892 else:
893 893 for attr in func(mode):
894 894 yield upgradexattr(attr)
895 895 xattrs = simplegeneric.generic(xattrs)
896 896
897 897
898 898 def xattrs_complex(self, mode="default"):
899 899 if mode == "detail":
900 900 return (AttributeDescriptor("real"), AttributeDescriptor("imag"))
901 901 return (selfdescriptor,)
902 902 xattrs.when_type(complex)(xattrs_complex)
903 903
904 904
905 905 def _isdict(item):
906 906 try:
907 907 itermeth = item.__class__.__iter__
908 908 except (AttributeError, TypeError):
909 909 return False
910 910 return itermeth is dict.__iter__ or itermeth is types.DictProxyType.__iter__
911 911
912 912
913 913 def _isstr(item):
914 914 if not isinstance(item, basestring):
915 915 return False
916 916 try:
917 917 itermeth = item.__class__.__iter__
918 918 except AttributeError:
919 919 return True
920 920 return False # ``__iter__`` has been redefined
921 921
922 922
923 923 def xiter(item):
924 924 """
925 925 Generic function that implements iteration for pipeline expression. If no
926 926 implementation is registered for ``item`` ``xiter`` falls back to ``iter``.
927 927 """
928 928 try:
929 929 func = item.__xiter__
930 930 except AttributeError:
931 931 if _isdict(item):
932 932 def items(item):
933 933 fields = ("key", "value")
934 934 for (key, value) in item.iteritems():
935 935 yield Fields(fields, key=key, value=value)
936 936 return items(item)
937 937 elif isinstance(item, new.module):
938 938 def items(item):
939 939 fields = ("key", "value")
940 940 for key in sorted(item.__dict__):
941 941 yield Fields(fields, key=key, value=getattr(item, key))
942 942 return items(item)
943 943 elif _isstr(item):
944 944 if not item:
945 945 raise ValueError("can't enter empty string")
946 return iter(item.splitlines())
946 lines = item.splitlines()
947 if len(lines) == 1:
948 def iterone(item):
949 yield item
950 return iterone(item)
951 else:
952 return iter(lines)
947 953 return iter(item)
948 954 else:
949 955 return iter(func()) # iter() just to be safe
950 956 xiter = simplegeneric.generic(xiter)
951 957
952 958
953 959 class ichain(Pipe):
954 960 """
955 961 Chains multiple ``Table``s into one.
956 962 """
957 963
958 964 def __init__(self, *iters):
959 965 self.iters = iters
960 966
961 967 def __iter__(self):
962 968 return itertools.chain(*self.iters)
963 969
964 970 def __xrepr__(self, mode="default"):
965 971 if mode == "header" or mode == "footer":
966 972 for (i, item) in enumerate(self.iters):
967 973 if i:
968 974 yield (astyle.style_default, "+")
969 975 if isinstance(item, Pipe):
970 976 yield (astyle.style_default, "(")
971 977 for part in xrepr(item, mode):
972 978 yield part
973 979 if isinstance(item, Pipe):
974 980 yield (astyle.style_default, ")")
975 981 else:
976 982 yield (astyle.style_default, repr(self))
977 983
978 984 def __repr__(self):
979 985 args = ", ".join([repr(it) for it in self.iters])
980 986 return "%s.%s(%s)" % \
981 987 (self.__class__.__module__, self.__class__.__name__, args)
982 988
983 989
984 990 class ifile(path.path):
985 991 """
986 992 file (or directory) object.
987 993 """
988 994
989 995 def getmode(self):
990 996 return self.stat().st_mode
991 997 mode = property(getmode, None, None, "Access mode")
992 998
993 999 def gettype(self):
994 1000 data = [
995 1001 (stat.S_ISREG, "file"),
996 1002 (stat.S_ISDIR, "dir"),
997 1003 (stat.S_ISCHR, "chardev"),
998 1004 (stat.S_ISBLK, "blockdev"),
999 1005 (stat.S_ISFIFO, "fifo"),
1000 1006 (stat.S_ISLNK, "symlink"),
1001 1007 (stat.S_ISSOCK,"socket"),
1002 1008 ]
1003 1009 lstat = self.lstat()
1004 1010 if lstat is not None:
1005 1011 types = set([text for (func, text) in data if func(lstat.st_mode)])
1006 1012 else:
1007 1013 types = set()
1008 1014 m = self.mode
1009 1015 types.update([text for (func, text) in data if func(m)])
1010 1016 return ", ".join(types)
1011 1017 type = property(gettype, None, None, "file type (file, directory, link, etc.)")
1012 1018
1013 1019 def getmodestr(self):
1014 1020 m = self.mode
1015 1021 data = [
1016 1022 (stat.S_IRUSR, "-r"),
1017 1023 (stat.S_IWUSR, "-w"),
1018 1024 (stat.S_IXUSR, "-x"),
1019 1025 (stat.S_IRGRP, "-r"),
1020 1026 (stat.S_IWGRP, "-w"),
1021 1027 (stat.S_IXGRP, "-x"),
1022 1028 (stat.S_IROTH, "-r"),
1023 1029 (stat.S_IWOTH, "-w"),
1024 1030 (stat.S_IXOTH, "-x"),
1025 1031 ]
1026 1032 return "".join([text[bool(m&bit)] for (bit, text) in data])
1027 1033
1028 1034 modestr = property(getmodestr, None, None, "Access mode as string")
1029 1035
1030 1036 def getblocks(self):
1031 1037 return self.stat().st_blocks
1032 1038 blocks = property(getblocks, None, None, "File size in blocks")
1033 1039
1034 1040 def getblksize(self):
1035 1041 return self.stat().st_blksize
1036 1042 blksize = property(getblksize, None, None, "Filesystem block size")
1037 1043
1038 1044 def getdev(self):
1039 1045 return self.stat().st_dev
1040 1046 dev = property(getdev)
1041 1047
1042 1048 def getnlink(self):
1043 1049 return self.stat().st_nlink
1044 1050 nlink = property(getnlink, None, None, "Number of links")
1045 1051
1046 1052 def getuid(self):
1047 1053 return self.stat().st_uid
1048 1054 uid = property(getuid, None, None, "User id of file owner")
1049 1055
1050 1056 def getgid(self):
1051 1057 return self.stat().st_gid
1052 1058 gid = property(getgid, None, None, "Group id of file owner")
1053 1059
1054 1060 def getowner(self):
1055 1061 stat = self.stat()
1056 1062 try:
1057 1063 return pwd.getpwuid(stat.st_uid).pw_name
1058 1064 except KeyError:
1059 1065 return stat.st_uid
1060 1066 owner = property(getowner, None, None, "Owner name (or id)")
1061 1067
1062 1068 def getgroup(self):
1063 1069 stat = self.stat()
1064 1070 try:
1065 1071 return grp.getgrgid(stat.st_gid).gr_name
1066 1072 except KeyError:
1067 1073 return stat.st_gid
1068 1074 group = property(getgroup, None, None, "Group name (or id)")
1069 1075
1070 1076 def getadate(self):
1071 1077 return datetime.datetime.utcfromtimestamp(self.atime)
1072 1078 adate = property(getadate, None, None, "Access date")
1073 1079
1074 1080 def getcdate(self):
1075 1081 return datetime.datetime.utcfromtimestamp(self.ctime)
1076 1082 cdate = property(getcdate, None, None, "Creation date")
1077 1083
1078 1084 def getmdate(self):
1079 1085 return datetime.datetime.utcfromtimestamp(self.mtime)
1080 1086 mdate = property(getmdate, None, None, "Modification date")
1081 1087
1082 1088 def mimetype(self):
1083 1089 """
1084 1090 Return MIME type guessed from the extension.
1085 1091 """
1086 1092 return mimetypes.guess_type(self.basename())[0]
1087 1093
1088 1094 def encoding(self):
1089 1095 """
1090 1096 Return guessed compression (like "compress" or "gzip").
1091 1097 """
1092 1098 return mimetypes.guess_type(self.basename())[1]
1093 1099
1094 1100 def __repr__(self):
1095 1101 return "ifile(%s)" % path._base.__repr__(self)
1096 1102
1097 1103 if sys.platform == "win32":
1098 1104 defaultattrs = (None, "type", "size", "modestr", "mdate")
1099 1105 else:
1100 1106 defaultattrs = (None, "type", "size", "modestr", "owner", "group", "mdate")
1101 1107
1102 1108 def __xattrs__(self, mode="default"):
1103 1109 if mode == "detail":
1104 1110 return (
1105 1111 "name",
1106 1112 "basename()",
1107 1113 "abspath()",
1108 1114 "realpath()",
1109 1115 "type",
1110 1116 "mode",
1111 1117 "modestr",
1112 1118 "stat()",
1113 1119 "lstat()",
1114 1120 "uid",
1115 1121 "gid",
1116 1122 "owner",
1117 1123 "group",
1118 1124 "dev",
1119 1125 "nlink",
1120 1126 "ctime",
1121 1127 "mtime",
1122 1128 "atime",
1123 1129 "cdate",
1124 1130 "mdate",
1125 1131 "adate",
1126 1132 "size",
1127 1133 "blocks",
1128 1134 "blksize",
1129 1135 "isdir()",
1130 1136 "islink()",
1131 1137 "mimetype()",
1132 1138 "encoding()",
1133 1139 "-listdir()",
1134 1140 "-dirs()",
1135 1141 "-files()",
1136 1142 "-walk()",
1137 1143 "-walkdirs()",
1138 1144 "-walkfiles()",
1139 1145 )
1140 1146 else:
1141 1147 return self.defaultattrs
1142 1148
1143 1149
1144 1150 def xiter_ifile(self):
1145 1151 if self.isdir():
1146 1152 yield (self / os.pardir).abspath()
1147 1153 for child in sorted(self.listdir()):
1148 1154 yield child
1149 1155 else:
1150 1156 f = self.open("rb")
1151 1157 for line in f:
1152 1158 yield line
1153 1159 f.close()
1154 1160 xiter.when_type(ifile)(xiter_ifile)
1155 1161
1156 1162
1157 1163 # We need to implement ``xrepr`` for ``ifile`` as a generic function, because
1158 1164 # otherwise ``xrepr_str`` would kick in.
1159 1165 def xrepr_ifile(self, mode="default"):
1160 1166 try:
1161 1167 if self.isdir():
1162 1168 name = "idir"
1163 1169 style = astyle.style_dir
1164 1170 else:
1165 1171 name = "ifile"
1166 1172 style = astyle.style_file
1167 1173 except IOError:
1168 1174 name = "ifile"
1169 1175 style = astyle.style_default
1170 1176 if mode == "cell" or mode in "header" or mode == "footer":
1171 1177 abspath = repr(path._base(self.normpath()))
1172 1178 if abspath.startswith("u"):
1173 1179 abspath = abspath[2:-1]
1174 1180 else:
1175 1181 abspath = abspath[1:-1]
1176 1182 if mode == "cell":
1177 1183 yield (style, abspath)
1178 1184 else:
1179 1185 yield (style, "%s(%s)" % (name, abspath))
1180 1186 else:
1181 1187 yield (style, repr(self))
1182 1188 xrepr.when_type(ifile)(xrepr_ifile)
1183 1189
1184 1190
1185 1191 class ils(Table):
1186 1192 """
1187 1193 List the current (or a specified) directory.
1188 1194
1189 1195 Examples:
1190 1196
1191 1197 >>> ils
1192 1198 >>> ils("/usr/local/lib/python2.4")
1193 1199 >>> ils("~")
1194 1200 """
1195 1201 def __init__(self, base=os.curdir, dirs=True, files=True):
1196 1202 self.base = os.path.expanduser(base)
1197 1203 self.dirs = dirs
1198 1204 self.files = files
1199 1205
1200 1206 def __iter__(self):
1201 1207 base = ifile(self.base)
1202 1208 yield (base / os.pardir).abspath()
1203 1209 for child in base.listdir():
1204 1210 if self.dirs:
1205 1211 if self.files:
1206 1212 yield child
1207 1213 else:
1208 1214 if child.isdir():
1209 1215 yield child
1210 1216 elif self.files:
1211 1217 if not child.isdir():
1212 1218 yield child
1213 1219
1214 1220 def __xrepr__(self, mode="default"):
1215 1221 return xrepr(ifile(self.base), mode)
1216 1222
1217 1223 def __repr__(self):
1218 1224 return "%s.%s(%r)" % \
1219 1225 (self.__class__.__module__, self.__class__.__name__, self.base)
1220 1226
1221 1227
1222 1228 class iglob(Table):
1223 1229 """
1224 1230 List all files and directories matching a specified pattern.
1225 1231 (See ``glob.glob()`` for more info.).
1226 1232
1227 1233 Examples:
1228 1234
1229 1235 >>> iglob("*.py")
1230 1236 """
1231 1237 def __init__(self, glob):
1232 1238 self.glob = glob
1233 1239
1234 1240 def __iter__(self):
1235 1241 for name in glob.glob(self.glob):
1236 1242 yield ifile(name)
1237 1243
1238 1244 def __xrepr__(self, mode="default"):
1239 1245 if mode == "header" or mode == "footer" or mode == "cell":
1240 1246 yield (astyle.style_default,
1241 1247 "%s(%r)" % (self.__class__.__name__, self.glob))
1242 1248 else:
1243 1249 yield (astyle.style_default, repr(self))
1244 1250
1245 1251 def __repr__(self):
1246 1252 return "%s.%s(%r)" % \
1247 1253 (self.__class__.__module__, self.__class__.__name__, self.glob)
1248 1254
1249 1255
1250 1256 class iwalk(Table):
1251 1257 """
1252 1258 List all files and directories in a directory and it's subdirectory.
1253 1259
1254 1260 >>> iwalk
1255 1261 >>> iwalk("/usr/local/lib/python2.4")
1256 1262 >>> iwalk("~")
1257 1263 """
1258 1264 def __init__(self, base=os.curdir, dirs=True, files=True):
1259 1265 self.base = os.path.expanduser(base)
1260 1266 self.dirs = dirs
1261 1267 self.files = files
1262 1268
1263 1269 def __iter__(self):
1264 1270 for (dirpath, dirnames, filenames) in os.walk(self.base):
1265 1271 if self.dirs:
1266 1272 for name in sorted(dirnames):
1267 1273 yield ifile(os.path.join(dirpath, name))
1268 1274 if self.files:
1269 1275 for name in sorted(filenames):
1270 1276 yield ifile(os.path.join(dirpath, name))
1271 1277
1272 1278 def __xrepr__(self, mode="default"):
1273 1279 if mode == "header" or mode == "footer" or mode == "cell":
1274 1280 yield (astyle.style_default,
1275 1281 "%s(%r)" % (self.__class__.__name__, self.base))
1276 1282 else:
1277 1283 yield (astyle.style_default, repr(self))
1278 1284
1279 1285 def __repr__(self):
1280 1286 return "%s.%s(%r)" % \
1281 1287 (self.__class__.__module__, self.__class__.__name__, self.base)
1282 1288
1283 1289
1284 1290 class ipwdentry(object):
1285 1291 """
1286 1292 ``ipwdentry`` objects encapsulate entries in the Unix user account and
1287 1293 password database.
1288 1294 """
1289 1295 def __init__(self, id):
1290 1296 self._id = id
1291 1297 self._entry = None
1292 1298
1293 1299 def __eq__(self, other):
1294 1300 return self.__class__ is other.__class__ and self._id == other._id
1295 1301
1296 1302 def __ne__(self, other):
1297 1303 return self.__class__ is not other.__class__ or self._id != other._id
1298 1304
1299 1305 def _getentry(self):
1300 1306 if self._entry is None:
1301 1307 if isinstance(self._id, basestring):
1302 1308 self._entry = pwd.getpwnam(self._id)
1303 1309 else:
1304 1310 self._entry = pwd.getpwuid(self._id)
1305 1311 return self._entry
1306 1312
1307 1313 def getname(self):
1308 1314 if isinstance(self._id, basestring):
1309 1315 return self._id
1310 1316 else:
1311 1317 return self._getentry().pw_name
1312 1318 name = property(getname, None, None, "User name")
1313 1319
1314 1320 def getpasswd(self):
1315 1321 return self._getentry().pw_passwd
1316 1322 passwd = property(getpasswd, None, None, "Password")
1317 1323
1318 1324 def getuid(self):
1319 1325 if isinstance(self._id, basestring):
1320 1326 return self._getentry().pw_uid
1321 1327 else:
1322 1328 return self._id
1323 1329 uid = property(getuid, None, None, "User id")
1324 1330
1325 1331 def getgid(self):
1326 1332 return self._getentry().pw_gid
1327 1333 gid = property(getgid, None, None, "Primary group id")
1328 1334
1329 1335 def getgroup(self):
1330 1336 return igrpentry(self.gid)
1331 1337 group = property(getgroup, None, None, "Group")
1332 1338
1333 1339 def getgecos(self):
1334 1340 return self._getentry().pw_gecos
1335 1341 gecos = property(getgecos, None, None, "Information (e.g. full user name)")
1336 1342
1337 1343 def getdir(self):
1338 1344 return self._getentry().pw_dir
1339 1345 dir = property(getdir, None, None, "$HOME directory")
1340 1346
1341 1347 def getshell(self):
1342 1348 return self._getentry().pw_shell
1343 1349 shell = property(getshell, None, None, "Login shell")
1344 1350
1345 1351 def __xattrs__(self, mode="default"):
1346 1352 return ("name", "passwd", "uid", "gid", "gecos", "dir", "shell")
1347 1353
1348 1354 def __repr__(self):
1349 1355 return "%s.%s(%r)" % \
1350 1356 (self.__class__.__module__, self.__class__.__name__, self._id)
1351 1357
1352 1358
1353 1359 class ipwd(Table):
1354 1360 """
1355 1361 List all entries in the Unix user account and password database.
1356 1362
1357 1363 Example:
1358 1364
1359 1365 >>> ipwd | isort("uid")
1360 1366 """
1361 1367 def __iter__(self):
1362 1368 for entry in pwd.getpwall():
1363 1369 yield ipwdentry(entry.pw_name)
1364 1370
1365 1371 def __xrepr__(self, mode="default"):
1366 1372 if mode == "header" or mode == "footer" or mode == "cell":
1367 1373 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1368 1374 else:
1369 1375 yield (astyle.style_default, repr(self))
1370 1376
1371 1377
1372 1378 class igrpentry(object):
1373 1379 """
1374 1380 ``igrpentry`` objects encapsulate entries in the Unix group database.
1375 1381 """
1376 1382 def __init__(self, id):
1377 1383 self._id = id
1378 1384 self._entry = None
1379 1385
1380 1386 def __eq__(self, other):
1381 1387 return self.__class__ is other.__class__ and self._id == other._id
1382 1388
1383 1389 def __ne__(self, other):
1384 1390 return self.__class__ is not other.__class__ or self._id != other._id
1385 1391
1386 1392 def _getentry(self):
1387 1393 if self._entry is None:
1388 1394 if isinstance(self._id, basestring):
1389 1395 self._entry = grp.getgrnam(self._id)
1390 1396 else:
1391 1397 self._entry = grp.getgrgid(self._id)
1392 1398 return self._entry
1393 1399
1394 1400 def getname(self):
1395 1401 if isinstance(self._id, basestring):
1396 1402 return self._id
1397 1403 else:
1398 1404 return self._getentry().gr_name
1399 1405 name = property(getname, None, None, "Group name")
1400 1406
1401 1407 def getpasswd(self):
1402 1408 return self._getentry().gr_passwd
1403 1409 passwd = property(getpasswd, None, None, "Password")
1404 1410
1405 1411 def getgid(self):
1406 1412 if isinstance(self._id, basestring):
1407 1413 return self._getentry().gr_gid
1408 1414 else:
1409 1415 return self._id
1410 1416 gid = property(getgid, None, None, "Group id")
1411 1417
1412 1418 def getmem(self):
1413 1419 return self._getentry().gr_mem
1414 1420 mem = property(getmem, None, None, "Members")
1415 1421
1416 1422 def __xattrs__(self, mode="default"):
1417 1423 return ("name", "passwd", "gid", "mem")
1418 1424
1419 1425 def __xrepr__(self, mode="default"):
1420 1426 if mode == "header" or mode == "footer" or mode == "cell":
1421 1427 yield (astyle.style_default, "group ")
1422 1428 try:
1423 1429 yield (astyle.style_default, self.name)
1424 1430 except KeyError:
1425 1431 if isinstance(self._id, basestring):
1426 1432 yield (astyle.style_default, self.name_id)
1427 1433 else:
1428 1434 yield (astyle.style_type_number, str(self._id))
1429 1435 else:
1430 1436 yield (astyle.style_default, repr(self))
1431 1437
1432 1438 def __iter__(self):
1433 1439 for member in self.mem:
1434 1440 yield ipwdentry(member)
1435 1441
1436 1442 def __repr__(self):
1437 1443 return "%s.%s(%r)" % \
1438 1444 (self.__class__.__module__, self.__class__.__name__, self._id)
1439 1445
1440 1446
1441 1447 class igrp(Table):
1442 1448 """
1443 1449 This ``Table`` lists all entries in the Unix group database.
1444 1450 """
1445 1451 def __iter__(self):
1446 1452 for entry in grp.getgrall():
1447 1453 yield igrpentry(entry.gr_name)
1448 1454
1449 1455 def __xrepr__(self, mode="default"):
1450 1456 if mode == "header" or mode == "footer":
1451 1457 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1452 1458 else:
1453 1459 yield (astyle.style_default, repr(self))
1454 1460
1455 1461
1456 1462 class Fields(object):
1457 1463 def __init__(self, fieldnames, **fields):
1458 1464 self.__fieldnames = [upgradexattr(fieldname) for fieldname in fieldnames]
1459 1465 for (key, value) in fields.iteritems():
1460 1466 setattr(self, key, value)
1461 1467
1462 1468 def __xattrs__(self, mode="default"):
1463 1469 return self.__fieldnames
1464 1470
1465 1471 def __xrepr__(self, mode="default"):
1466 1472 yield (-1, False)
1467 1473 if mode == "header" or mode == "cell":
1468 1474 yield (astyle.style_default, self.__class__.__name__)
1469 1475 yield (astyle.style_default, "(")
1470 1476 for (i, f) in enumerate(self.__fieldnames):
1471 1477 if i:
1472 1478 yield (astyle.style_default, ", ")
1473 1479 yield (astyle.style_default, f.name())
1474 1480 yield (astyle.style_default, "=")
1475 1481 for part in xrepr(getattr(self, f), "default"):
1476 1482 yield part
1477 1483 yield (astyle.style_default, ")")
1478 1484 elif mode == "footer":
1479 1485 yield (astyle.style_default, self.__class__.__name__)
1480 1486 yield (astyle.style_default, "(")
1481 1487 for (i, f) in enumerate(self.__fieldnames):
1482 1488 if i:
1483 1489 yield (astyle.style_default, ", ")
1484 1490 yield (astyle.style_default, f.name())
1485 1491 yield (astyle.style_default, ")")
1486 1492 else:
1487 1493 yield (astyle.style_default, repr(self))
1488 1494
1489 1495
1490 1496 class FieldTable(Table, list):
1491 1497 def __init__(self, *fields):
1492 1498 Table.__init__(self)
1493 1499 list.__init__(self)
1494 1500 self.fields = fields
1495 1501
1496 1502 def add(self, **fields):
1497 1503 self.append(Fields(self.fields, **fields))
1498 1504
1499 1505 def __xrepr__(self, mode="default"):
1500 1506 yield (-1, False)
1501 1507 if mode == "header" or mode == "footer":
1502 1508 yield (astyle.style_default, self.__class__.__name__)
1503 1509 yield (astyle.style_default, "(")
1504 1510 for (i, f) in enumerate(self.__fieldnames):
1505 1511 if i:
1506 1512 yield (astyle.style_default, ", ")
1507 1513 yield (astyle.style_default, f)
1508 1514 yield (astyle.style_default, ")")
1509 1515 else:
1510 1516 yield (astyle.style_default, repr(self))
1511 1517
1512 1518 def __repr__(self):
1513 1519 return "<%s.%s object with fields=%r at 0x%x>" % \
1514 1520 (self.__class__.__module__, self.__class__.__name__,
1515 1521 ", ".join(map(repr, self.fields)), id(self))
1516 1522
1517 1523
1518 1524 class List(list):
1519 1525 def __xattrs__(self, mode="default"):
1520 1526 return xrange(len(self))
1521 1527
1522 1528 def __xrepr__(self, mode="default"):
1523 1529 yield (-1, False)
1524 1530 if mode == "header" or mode == "cell" or mode == "footer" or mode == "default":
1525 1531 yield (astyle.style_default, self.__class__.__name__)
1526 1532 yield (astyle.style_default, "(")
1527 1533 for (i, item) in enumerate(self):
1528 1534 if i:
1529 1535 yield (astyle.style_default, ", ")
1530 1536 for part in xrepr(item, "default"):
1531 1537 yield part
1532 1538 yield (astyle.style_default, ")")
1533 1539 else:
1534 1540 yield (astyle.style_default, repr(self))
1535 1541
1536 1542
1537 1543 class ienv(Table):
1538 1544 """
1539 1545 List environment variables.
1540 1546
1541 1547 Example:
1542 1548
1543 1549 >>> ienv
1544 1550 """
1545 1551
1546 1552 def __iter__(self):
1547 1553 fields = ("key", "value")
1548 1554 for (key, value) in os.environ.iteritems():
1549 1555 yield Fields(fields, key=key, value=value)
1550 1556
1551 1557 def __xrepr__(self, mode="default"):
1552 1558 if mode == "header" or mode == "cell":
1553 1559 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1554 1560 else:
1555 1561 yield (astyle.style_default, repr(self))
1556 1562
1557 1563
1558 1564 class icsv(Pipe):
1559 1565 """
1560 1566 This ``Pipe`` lists turn the input (with must be a pipe outputting lines
1561 1567 or an ``ifile``) into lines of CVS columns.
1562 1568 """
1563 1569 def __init__(self, **csvargs):
1564 1570 """
1565 1571 Create an ``icsv`` object. ``cvsargs`` will be passed through as
1566 1572 keyword arguments to ``cvs.reader()``.
1567 1573 """
1568 1574 self.csvargs = csvargs
1569 1575
1570 1576 def __iter__(self):
1571 1577 input = self.input
1572 1578 if isinstance(input, ifile):
1573 1579 input = input.open("rb")
1574 1580 reader = csv.reader(input, **self.csvargs)
1575 1581 for line in reader:
1576 1582 yield List(line)
1577 1583
1578 1584 def __xrepr__(self, mode="default"):
1579 1585 yield (-1, False)
1580 1586 if mode == "header" or mode == "footer":
1581 1587 input = getattr(self, "input", None)
1582 1588 if input is not None:
1583 1589 for part in xrepr(input, mode):
1584 1590 yield part
1585 1591 yield (astyle.style_default, " | ")
1586 1592 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1587 1593 for (i, (name, value)) in enumerate(self.csvargs.iteritems()):
1588 1594 if i:
1589 1595 yield (astyle.style_default, ", ")
1590 1596 yield (astyle.style_default, name)
1591 1597 yield (astyle.style_default, "=")
1592 1598 for part in xrepr(value, "default"):
1593 1599 yield part
1594 1600 yield (astyle.style_default, ")")
1595 1601 else:
1596 1602 yield (astyle.style_default, repr(self))
1597 1603
1598 1604 def __repr__(self):
1599 1605 args = ", ".join(["%s=%r" % item for item in self.csvargs.iteritems()])
1600 1606 return "<%s.%s %s at 0x%x>" % \
1601 1607 (self.__class__.__module__, self.__class__.__name__, args, id(self))
1602 1608
1603 1609
1604 1610 class ix(Table):
1605 1611 """
1606 1612 Execute a system command and list its output as lines
1607 1613 (similar to ``os.popen()``).
1608 1614
1609 1615 Examples:
1610 1616
1611 1617 >>> ix("ps x")
1612 1618 >>> ix("find .") | ifile
1613 1619 """
1614 1620 def __init__(self, cmd):
1615 1621 self.cmd = cmd
1616 1622 self._pipeout = None
1617 1623
1618 1624 def __iter__(self):
1619 1625 (_pipein, self._pipeout) = os.popen4(self.cmd)
1620 1626 _pipein.close()
1621 1627 for l in self._pipeout:
1622 1628 yield l.rstrip("\r\n")
1623 1629 self._pipeout.close()
1624 1630 self._pipeout = None
1625 1631
1626 1632 def __del__(self):
1627 1633 if self._pipeout is not None and not self._pipeout.closed:
1628 1634 self._pipeout.close()
1629 1635 self._pipeout = None
1630 1636
1631 1637 def __xrepr__(self, mode="default"):
1632 1638 if mode == "header" or mode == "footer":
1633 1639 yield (astyle.style_default,
1634 1640 "%s(%r)" % (self.__class__.__name__, self.cmd))
1635 1641 else:
1636 1642 yield (astyle.style_default, repr(self))
1637 1643
1638 1644 def __repr__(self):
1639 1645 return "%s.%s(%r)" % \
1640 1646 (self.__class__.__module__, self.__class__.__name__, self.cmd)
1641 1647
1642 1648
1643 1649 class ifilter(Pipe):
1644 1650 """
1645 1651 Filter an input pipe. Only objects where an expression evaluates to true
1646 1652 (and doesn't raise an exception) are listed.
1647 1653
1648 1654 Examples:
1649 1655
1650 1656 >>> ils | ifilter("_.isfile() and size>1000")
1651 1657 >>> igrp | ifilter("len(mem)")
1652 1658 >>> sys.modules | ifilter(lambda _:_.value is not None)
1653 1659 """
1654 1660
1655 1661 def __init__(self, expr, globals=None, errors="raiseifallfail"):
1656 1662 """
1657 1663 Create an ``ifilter`` object. ``expr`` can be a callable or a string
1658 1664 containing an expression. ``globals`` will be used as the global
1659 1665 namespace for calling string expressions (defaulting to IPython's
1660 1666 user namespace). ``errors`` specifies how exception during evaluation
1661 1667 of ``expr`` are handled:
1662 1668
1663 1669 * ``drop``: drop all items that have errors;
1664 1670
1665 1671 * ``keep``: keep all items that have errors;
1666 1672
1667 1673 * ``keeperror``: keep the exception of all items that have errors;
1668 1674
1669 1675 * ``raise``: raise the exception;
1670 1676
1671 1677 * ``raiseifallfail``: raise the first exception if all items have errors;
1672 1678 otherwise drop those with errors (this is the default).
1673 1679 """
1674 1680 self.expr = expr
1675 1681 self.globals = globals
1676 1682 self.errors = errors
1677 1683
1678 1684 def __iter__(self):
1679 1685 if callable(self.expr):
1680 1686 test = self.expr
1681 1687 else:
1682 1688 g = getglobals(self.globals)
1683 1689 expr = compile(self.expr, "ipipe-expression", "eval")
1684 1690 def test(item):
1685 1691 return eval(expr, g, AttrNamespace(item))
1686 1692
1687 1693 ok = 0
1688 1694 exc_info = None
1689 1695 for item in xiter(self.input):
1690 1696 try:
1691 1697 if test(item):
1692 1698 yield item
1693 1699 ok += 1
1694 1700 except (KeyboardInterrupt, SystemExit):
1695 1701 raise
1696 1702 except Exception, exc:
1697 1703 if self.errors == "drop":
1698 1704 pass # Ignore errors
1699 1705 elif self.errors == "keep":
1700 1706 yield item
1701 1707 elif self.errors == "keeperror":
1702 1708 yield exc
1703 1709 elif self.errors == "raise":
1704 1710 raise
1705 1711 elif self.errors == "raiseifallfail":
1706 1712 if exc_info is None:
1707 1713 exc_info = sys.exc_info()
1708 1714 if not ok and exc_info is not None:
1709 1715 raise exc_info[0], exc_info[1], exc_info[2]
1710 1716
1711 1717 def __xrepr__(self, mode="default"):
1712 1718 if mode == "header" or mode == "footer":
1713 1719 input = getattr(self, "input", None)
1714 1720 if input is not None:
1715 1721 for part in xrepr(input, mode):
1716 1722 yield part
1717 1723 yield (astyle.style_default, " | ")
1718 1724 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1719 1725 for part in xrepr(self.expr, "default"):
1720 1726 yield part
1721 1727 yield (astyle.style_default, ")")
1722 1728 else:
1723 1729 yield (astyle.style_default, repr(self))
1724 1730
1725 1731 def __repr__(self):
1726 1732 return "<%s.%s expr=%r at 0x%x>" % \
1727 1733 (self.__class__.__module__, self.__class__.__name__,
1728 1734 self.expr, id(self))
1729 1735
1730 1736
1731 1737 class ieval(Pipe):
1732 1738 """
1733 1739 Evaluate an expression for each object in the input pipe.
1734 1740
1735 1741 Examples:
1736 1742
1737 1743 >>> ils | ieval("_.abspath()")
1738 1744 >>> sys.path | ieval(ifile)
1739 1745 """
1740 1746
1741 1747 def __init__(self, expr, globals=None, errors="raiseifallfail"):
1742 1748 """
1743 1749 Create an ``ieval`` object. ``expr`` can be a callable or a string
1744 1750 containing an expression. For the meaning of ``globals`` and
1745 1751 ``errors`` see ``ifilter``.
1746 1752 """
1747 1753 self.expr = expr
1748 1754 self.globals = globals
1749 1755 self.errors = errors
1750 1756
1751 1757 def __iter__(self):
1752 1758 if callable(self.expr):
1753 1759 do = self.expr
1754 1760 else:
1755 1761 g = getglobals(self.globals)
1756 1762 expr = compile(self.expr, "ipipe-expression", "eval")
1757 1763 def do(item):
1758 1764 return eval(expr, g, AttrNamespace(item))
1759 1765
1760 1766 ok = 0
1761 1767 exc_info = None
1762 1768 for item in xiter(self.input):
1763 1769 try:
1764 1770 yield do(item)
1765 1771 except (KeyboardInterrupt, SystemExit):
1766 1772 raise
1767 1773 except Exception, exc:
1768 1774 if self.errors == "drop":
1769 1775 pass # Ignore errors
1770 1776 elif self.errors == "keep":
1771 1777 yield item
1772 1778 elif self.errors == "keeperror":
1773 1779 yield exc
1774 1780 elif self.errors == "raise":
1775 1781 raise
1776 1782 elif self.errors == "raiseifallfail":
1777 1783 if exc_info is None:
1778 1784 exc_info = sys.exc_info()
1779 1785 if not ok and exc_info is not None:
1780 1786 raise exc_info[0], exc_info[1], exc_info[2]
1781 1787
1782 1788 def __xrepr__(self, mode="default"):
1783 1789 if mode == "header" or mode == "footer":
1784 1790 input = getattr(self, "input", None)
1785 1791 if input is not None:
1786 1792 for part in xrepr(input, mode):
1787 1793 yield part
1788 1794 yield (astyle.style_default, " | ")
1789 1795 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1790 1796 for part in xrepr(self.expr, "default"):
1791 1797 yield part
1792 1798 yield (astyle.style_default, ")")
1793 1799 else:
1794 1800 yield (astyle.style_default, repr(self))
1795 1801
1796 1802 def __repr__(self):
1797 1803 return "<%s.%s expr=%r at 0x%x>" % \
1798 1804 (self.__class__.__module__, self.__class__.__name__,
1799 1805 self.expr, id(self))
1800 1806
1801 1807
1802 1808 class ienum(Pipe):
1803 1809 """
1804 1810 Enumerate the input pipe (i.e. wrap each input object in an object
1805 1811 with ``index`` and ``object`` attributes).
1806 1812
1807 1813 Examples:
1808 1814
1809 1815 >>> xrange(20) | ieval("_,_*_") | ienum | ifilter("index % 2 == 0") | ieval("object")
1810 1816 """
1811 1817 def __iter__(self):
1812 1818 fields = ("index", "object")
1813 1819 for (index, object) in enumerate(xiter(self.input)):
1814 1820 yield Fields(fields, index=index, object=object)
1815 1821
1816 1822
1817 1823 class isort(Pipe):
1818 1824 """
1819 1825 Sorts the input pipe.
1820 1826
1821 1827 Examples:
1822 1828
1823 1829 >>> ils | isort("size")
1824 1830 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
1825 1831 """
1826 1832
1827 1833 def __init__(self, key=None, globals=None, reverse=False):
1828 1834 """
1829 1835 Create an ``isort`` object. ``key`` can be a callable or a string
1830 1836 containing an expression (or ``None`` in which case the items
1831 1837 themselves will be sorted). If ``reverse`` is true the sort order
1832 1838 will be reversed. For the meaning of ``globals`` see ``ifilter``.
1833 1839 """
1834 1840 self.key = key
1835 1841 self.globals = globals
1836 1842 self.reverse = reverse
1837 1843
1838 1844 def __iter__(self):
1839 1845 if self.key is None:
1840 1846 items = sorted(xiter(self.input), reverse=self.reverse)
1841 1847 elif callable(self.key):
1842 1848 items = sorted(xiter(self.input), key=self.key, reverse=self.reverse)
1843 1849 else:
1844 1850 g = getglobals(self.globals)
1845 1851 key = compile(self.key, "ipipe-expression", "eval")
1846 1852 def realkey(item):
1847 1853 return eval(key, g, AttrNamespace(item))
1848 1854 items = sorted(xiter(self.input), key=realkey, reverse=self.reverse)
1849 1855 for item in items:
1850 1856 yield item
1851 1857
1852 1858 def __xrepr__(self, mode="default"):
1853 1859 if mode == "header" or mode == "footer":
1854 1860 input = getattr(self, "input", None)
1855 1861 if input is not None:
1856 1862 for part in xrepr(input, mode):
1857 1863 yield part
1858 1864 yield (astyle.style_default, " | ")
1859 1865 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1860 1866 for part in xrepr(self.key, "default"):
1861 1867 yield part
1862 1868 if self.reverse:
1863 1869 yield (astyle.style_default, ", ")
1864 1870 for part in xrepr(True, "default"):
1865 1871 yield part
1866 1872 yield (astyle.style_default, ")")
1867 1873 else:
1868 1874 yield (astyle.style_default, repr(self))
1869 1875
1870 1876 def __repr__(self):
1871 1877 return "<%s.%s key=%r reverse=%r at 0x%x>" % \
1872 1878 (self.__class__.__module__, self.__class__.__name__,
1873 1879 self.key, self.reverse, id(self))
1874 1880
1875 1881
1876 1882 tab = 3 # for expandtabs()
1877 1883
1878 1884 def _format(field):
1879 1885 if isinstance(field, str):
1880 1886 text = repr(field.expandtabs(tab))[1:-1]
1881 1887 elif isinstance(field, unicode):
1882 1888 text = repr(field.expandtabs(tab))[2:-1]
1883 1889 elif isinstance(field, datetime.datetime):
1884 1890 # Don't use strftime() here, as this requires year >= 1900
1885 1891 text = "%04d-%02d-%02d %02d:%02d:%02d.%06d" % \
1886 1892 (field.year, field.month, field.day,
1887 1893 field.hour, field.minute, field.second, field.microsecond)
1888 1894 elif isinstance(field, datetime.date):
1889 1895 text = "%04d-%02d-%02d" % (field.year, field.month, field.day)
1890 1896 else:
1891 1897 text = repr(field)
1892 1898 return text
1893 1899
1894 1900
1895 1901 class Display(object):
1896 1902 class __metaclass__(type):
1897 1903 def __ror__(self, input):
1898 1904 return input | self()
1899 1905
1900 1906 def __ror__(self, input):
1901 1907 self.input = input
1902 1908 return self
1903 1909
1904 1910 def display(self):
1905 1911 pass
1906 1912
1907 1913
1908 1914 class iless(Display):
1909 1915 cmd = "less --quit-if-one-screen --LONG-PROMPT --LINE-NUMBERS --chop-long-lines --shift=8 --RAW-CONTROL-CHARS"
1910 1916
1911 1917 def display(self):
1912 1918 try:
1913 1919 pager = os.popen(self.cmd, "w")
1914 1920 try:
1915 1921 for item in xiter(self.input):
1916 1922 first = False
1917 1923 for attr in xattrs(item, "default"):
1918 1924 if first:
1919 1925 first = False
1920 1926 else:
1921 1927 pager.write(" ")
1922 1928 attr = upgradexattr(attr)
1923 1929 if not isinstance(attr, SelfDescriptor):
1924 1930 pager.write(attr.name())
1925 1931 pager.write("=")
1926 1932 pager.write(str(attr.value(item)))
1927 1933 pager.write("\n")
1928 1934 finally:
1929 1935 pager.close()
1930 1936 except Exception, exc:
1931 1937 print "%s: %s" % (exc.__class__.__name__, str(exc))
1932 1938
1933 1939
1934 1940 def xformat(value, mode, maxlength):
1935 1941 align = None
1936 1942 full = True
1937 1943 width = 0
1938 1944 text = astyle.Text()
1939 1945 for (style, part) in xrepr(value, mode):
1940 1946 # only consider the first result
1941 1947 if align is None:
1942 1948 if isinstance(style, int):
1943 1949 # (style, text) really is (alignment, stop)
1944 1950 align = style
1945 1951 full = part
1946 1952 continue
1947 1953 else:
1948 1954 align = -1
1949 1955 full = True
1950 1956 if not isinstance(style, int):
1951 1957 text.append((style, part))
1952 1958 width += len(part)
1953 1959 if width >= maxlength and not full:
1954 1960 text.append((astyle.style_ellisis, "..."))
1955 1961 width += 3
1956 1962 break
1957 1963 if align is None: # default to left alignment
1958 1964 align = -1
1959 1965 return (align, width, text)
1960 1966
1961 1967
1962 1968 class idump(Display):
1963 1969 # The approximate maximum length of a column entry
1964 1970 maxattrlength = 200
1965 1971
1966 1972 # Style for column names
1967 1973 style_header = astyle.Style.fromstr("white:black:bold")
1968 1974
1969 1975 def __init__(self, *attrs):
1970 1976 self.attrs = [upgradexattr(attr) for attr in attrs]
1971 1977 self.headerpadchar = " "
1972 1978 self.headersepchar = "|"
1973 1979 self.datapadchar = " "
1974 1980 self.datasepchar = "|"
1975 1981
1976 1982 def display(self):
1977 1983 stream = genutils.Term.cout
1978 1984 allattrs = []
1979 1985 attrset = set()
1980 1986 colwidths = {}
1981 1987 rows = []
1982 1988 for item in xiter(self.input):
1983 1989 row = {}
1984 1990 attrs = self.attrs
1985 1991 if not attrs:
1986 1992 attrs = xattrs(item, "default")
1987 1993 for attr in attrs:
1988 1994 if attr not in attrset:
1989 1995 allattrs.append(attr)
1990 1996 attrset.add(attr)
1991 1997 colwidths[attr] = len(attr.name())
1992 1998 try:
1993 1999 value = attr.value(item)
1994 2000 except (KeyboardInterrupt, SystemExit):
1995 2001 raise
1996 2002 except Exception, exc:
1997 2003 value = exc
1998 2004 (align, width, text) = xformat(value, "cell", self.maxattrlength)
1999 2005 colwidths[attr] = max(colwidths[attr], width)
2000 2006 # remember alignment, length and colored parts
2001 2007 row[attr] = (align, width, text)
2002 2008 rows.append(row)
2003 2009
2004 2010 stream.write("\n")
2005 2011 for (i, attr) in enumerate(allattrs):
2006 2012 attrname = attr.name()
2007 2013 self.style_header(attrname).write(stream)
2008 2014 spc = colwidths[attr] - len(attrname)
2009 2015 if i < len(colwidths)-1:
2010 2016 stream.write(self.headerpadchar*spc)
2011 2017 stream.write(self.headersepchar)
2012 2018 stream.write("\n")
2013 2019
2014 2020 for row in rows:
2015 2021 for (i, attr) in enumerate(allattrs):
2016 2022 (align, width, text) = row[attr]
2017 2023 spc = colwidths[attr] - width
2018 2024 if align == -1:
2019 2025 text.write(stream)
2020 2026 if i < len(colwidths)-1:
2021 2027 stream.write(self.datapadchar*spc)
2022 2028 elif align == 0:
2023 2029 spc = colwidths[attr] - width
2024 2030 spc1 = spc//2
2025 2031 spc2 = spc-spc1
2026 2032 stream.write(self.datapadchar*spc1)
2027 2033 text.write(stream)
2028 2034 if i < len(colwidths)-1:
2029 2035 stream.write(self.datapadchar*spc2)
2030 2036 else:
2031 2037 stream.write(self.datapadchar*spc)
2032 2038 text.write(stream)
2033 2039 if i < len(colwidths)-1:
2034 2040 stream.write(self.datasepchar)
2035 2041 stream.write("\n")
2036 2042
2037 2043
2038 2044 class AttributeDetail(Table):
2039 2045 """
2040 2046 ``AttributeDetail`` objects are use for displaying a detailed list of object
2041 2047 attributes.
2042 2048 """
2043 2049 def __init__(self, object, descriptor):
2044 2050 self.object = object
2045 2051 self.descriptor = descriptor
2046 2052
2047 2053 def __iter__(self):
2048 2054 return self.descriptor.iter(self.object)
2049 2055
2050 2056 def name(self):
2051 2057 return self.descriptor.name()
2052 2058
2053 2059 def attrtype(self):
2054 2060 return self.descriptor.attrtype(self.object)
2055 2061
2056 2062 def valuetype(self):
2057 2063 return self.descriptor.valuetype(self.object)
2058 2064
2059 2065 def doc(self):
2060 2066 return self.descriptor.doc(self.object)
2061 2067
2062 2068 def shortdoc(self):
2063 2069 return self.descriptor.shortdoc(self.object)
2064 2070
2065 2071 def value(self):
2066 2072 return self.descriptor.value(self.object)
2067 2073
2068 2074 def __xattrs__(self, mode="default"):
2069 2075 attrs = ("name()", "attrtype()", "valuetype()", "value()", "shortdoc()")
2070 2076 if mode == "detail":
2071 2077 attrs += ("doc()",)
2072 2078 return attrs
2073 2079
2074 2080 def __xrepr__(self, mode="default"):
2075 2081 yield (-1, True)
2076 2082 valuetype = self.valuetype()
2077 2083 if valuetype is not noitem:
2078 2084 for part in xrepr(valuetype):
2079 2085 yield part
2080 2086 yield (astyle.style_default, " ")
2081 2087 yield (astyle.style_default, self.attrtype())
2082 2088 yield (astyle.style_default, " ")
2083 2089 yield (astyle.style_default, self.name())
2084 2090 yield (astyle.style_default, " of ")
2085 2091 for part in xrepr(self.object):
2086 2092 yield part
2087 2093
2088 2094
2089 2095 try:
2090 2096 from ibrowse import ibrowse
2091 2097 except ImportError:
2092 2098 # No curses (probably Windows) => use ``idump`` as the default display.
2093 2099 defaultdisplay = idump
2094 2100 else:
2095 2101 defaultdisplay = ibrowse
2096 2102 __all__.append("ibrowse")
2097 2103
2098 2104
2099 2105 # If we're running under IPython, install an IPython displayhook that
2100 2106 # returns the object from Display.display(), else install a displayhook
2101 2107 # directly as sys.displayhook
2102 2108 api = None
2103 2109 if ipapi is not None:
2104 2110 try:
2105 2111 api = ipapi.get()
2106 2112 except AttributeError:
2107 2113 pass
2108 2114
2109 2115 if api is not None:
2110 2116 def displayhook(self, obj):
2111 2117 if isinstance(obj, type) and issubclass(obj, Table):
2112 2118 obj = obj()
2113 2119 if isinstance(obj, Table):
2114 2120 obj = obj | defaultdisplay
2115 2121 if isinstance(obj, Display):
2116 2122 return obj.display()
2117 2123 else:
2118 2124 raise ipapi.TryNext
2119 2125 api.set_hook("result_display", displayhook)
2120 2126 else:
2121 2127 def installdisplayhook():
2122 2128 _originalhook = sys.displayhook
2123 2129 def displayhook(obj):
2124 2130 if isinstance(obj, type) and issubclass(obj, Table):
2125 2131 obj = obj()
2126 2132 if isinstance(obj, Table):
2127 2133 obj = obj | defaultdisplay
2128 2134 if isinstance(obj, Display):
2129 2135 return obj.display()
2130 2136 else:
2131 2137 _originalhook(obj)
2132 2138 sys.displayhook = displayhook
2133 2139 installdisplayhook()
@@ -1,6162 +1,6172 b''
1 2007-01-23 Walter Doerwald <walter@livinglogic.de>
2
3 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
4 a string containing a single line yields the string itself as the
5 only item.
6
7 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
8 object if it's the same as the one on the last level (This avoids
9 infinite recursion for one line strings).
10
1 11 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2 12
3 13 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
4 14 all output streams before printing tracebacks. This ensures that
5 15 user output doesn't end up interleaved with traceback output.
6 16
7 17 2007-01-10 Ville Vainio <vivainio@gmail.com>
8 18
9 19 * Extensions/envpersist.py: Turbocharged %env that remembers
10 20 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
11 21 "%env VISUAL=jed".
12 22
13 23 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
14 24
15 25 * IPython/iplib.py (showtraceback): ensure that we correctly call
16 26 custom handlers in all cases (some with pdb were slipping through,
17 27 but I'm not exactly sure why).
18 28
19 29 * IPython/Debugger.py (Tracer.__init__): added new class to
20 30 support set_trace-like usage of IPython's enhanced debugger.
21 31
22 32 2006-12-24 Ville Vainio <vivainio@gmail.com>
23 33
24 34 * ipmaker.py: more informative message when ipy_user_conf
25 35 import fails (suggest running %upgrade).
26 36
27 37 * tools/run_ipy_in_profiler.py: Utility to see where
28 38 the time during IPython startup is spent.
29 39
30 40 2006-12-20 Ville Vainio <vivainio@gmail.com>
31 41
32 42 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
33 43
34 44 * ipapi.py: Add new ipapi method, expand_alias.
35 45
36 46 * Release.py: Bump up version to 0.7.4.svn
37 47
38 48 2006-12-17 Ville Vainio <vivainio@gmail.com>
39 49
40 50 * Extensions/jobctrl.py: Fixed &cmd arg arg...
41 51 to work properly on posix too
42 52
43 53 * Release.py: Update revnum (version is still just 0.7.3).
44 54
45 55 2006-12-15 Ville Vainio <vivainio@gmail.com>
46 56
47 57 * scripts/ipython_win_post_install: create ipython.py in
48 58 prefix + "/scripts".
49 59
50 60 * Release.py: Update version to 0.7.3.
51 61
52 62 2006-12-14 Ville Vainio <vivainio@gmail.com>
53 63
54 64 * scripts/ipython_win_post_install: Overwrite old shortcuts
55 65 if they already exist
56 66
57 67 * Release.py: release 0.7.3rc2
58 68
59 69 2006-12-13 Ville Vainio <vivainio@gmail.com>
60 70
61 71 * Branch and update Release.py for 0.7.3rc1
62 72
63 73 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
64 74
65 75 * IPython/Shell.py (IPShellWX): update for current WX naming
66 76 conventions, to avoid a deprecation warning with current WX
67 77 versions. Thanks to a report by Danny Shevitz.
68 78
69 79 2006-12-12 Ville Vainio <vivainio@gmail.com>
70 80
71 81 * ipmaker.py: apply david cournapeau's patch to make
72 82 import_some work properly even when ipythonrc does
73 83 import_some on empty list (it was an old bug!).
74 84
75 85 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
76 86 Add deprecation note to ipythonrc and a url to wiki
77 87 in ipy_user_conf.py
78 88
79 89
80 90 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
81 91 as if it was typed on IPython command prompt, i.e.
82 92 as IPython script.
83 93
84 94 * example-magic.py, magic_grepl.py: remove outdated examples
85 95
86 96 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
87 97
88 98 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
89 99 is called before any exception has occurred.
90 100
91 101 2006-12-08 Ville Vainio <vivainio@gmail.com>
92 102
93 103 * Extensions/ipy_stock_completers.py.py: fix cd completer
94 104 to translate /'s to \'s again.
95 105
96 106 * completer.py: prevent traceback on file completions w/
97 107 backslash.
98 108
99 109 * Release.py: Update release number to 0.7.3b3 for release
100 110
101 111 2006-12-07 Ville Vainio <vivainio@gmail.com>
102 112
103 113 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
104 114 while executing external code. Provides more shell-like behaviour
105 115 and overall better response to ctrl + C / ctrl + break.
106 116
107 117 * tools/make_tarball.py: new script to create tarball straight from svn
108 118 (setup.py sdist doesn't work on win32).
109 119
110 120 * Extensions/ipy_stock_completers.py: fix cd completer to give up
111 121 on dirnames with spaces and use the default completer instead.
112 122
113 123 * Revision.py: Change version to 0.7.3b2 for release.
114 124
115 125 2006-12-05 Ville Vainio <vivainio@gmail.com>
116 126
117 127 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
118 128 pydb patch 4 (rm debug printing, py 2.5 checking)
119 129
120 130 2006-11-30 Walter Doerwald <walter@livinglogic.de>
121 131 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
122 132 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
123 133 "refreshfind" (mapped to "R") does the same but tries to go back to the same
124 134 object the cursor was on before the refresh. The command "markrange" is
125 135 mapped to "%" now.
126 136 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
127 137
128 138 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
129 139
130 140 * IPython/Magic.py (magic_debug): new %debug magic to activate the
131 141 interactive debugger on the last traceback, without having to call
132 142 %pdb and rerun your code. Made minor changes in various modules,
133 143 should automatically recognize pydb if available.
134 144
135 145 2006-11-28 Ville Vainio <vivainio@gmail.com>
136 146
137 147 * completer.py: If the text start with !, show file completions
138 148 properly. This helps when trying to complete command name
139 149 for shell escapes.
140 150
141 151 2006-11-27 Ville Vainio <vivainio@gmail.com>
142 152
143 153 * ipy_stock_completers.py: bzr completer submitted by Stefan van
144 154 der Walt. Clean up svn and hg completers by using a common
145 155 vcs_completer.
146 156
147 157 2006-11-26 Ville Vainio <vivainio@gmail.com>
148 158
149 159 * Remove ipconfig and %config; you should use _ip.options structure
150 160 directly instead!
151 161
152 162 * genutils.py: add wrap_deprecated function for deprecating callables
153 163
154 164 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
155 165 _ip.system instead. ipalias is redundant.
156 166
157 167 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
158 168 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
159 169 explicit.
160 170
161 171 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
162 172 completer. Try it by entering 'hg ' and pressing tab.
163 173
164 174 * macro.py: Give Macro a useful __repr__ method
165 175
166 176 * Magic.py: %whos abbreviates the typename of Macro for brevity.
167 177
168 178 2006-11-24 Walter Doerwald <walter@livinglogic.de>
169 179 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
170 180 we don't get a duplicate ipipe module, where registration of the xrepr
171 181 implementation for Text is useless.
172 182
173 183 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
174 184
175 185 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
176 186
177 187 2006-11-24 Ville Vainio <vivainio@gmail.com>
178 188
179 189 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
180 190 try to use "cProfile" instead of the slower pure python
181 191 "profile"
182 192
183 193 2006-11-23 Ville Vainio <vivainio@gmail.com>
184 194
185 195 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
186 196 Qt+IPython+Designer link in documentation.
187 197
188 198 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
189 199 correct Pdb object to %pydb.
190 200
191 201
192 202 2006-11-22 Walter Doerwald <walter@livinglogic.de>
193 203 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
194 204 generic xrepr(), otherwise the list implementation would kick in.
195 205
196 206 2006-11-21 Ville Vainio <vivainio@gmail.com>
197 207
198 208 * upgrade_dir.py: Now actually overwrites a nonmodified user file
199 209 with one from UserConfig.
200 210
201 211 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
202 212 it was missing which broke the sh profile.
203 213
204 214 * completer.py: file completer now uses explicit '/' instead
205 215 of os.path.join, expansion of 'foo' was broken on win32
206 216 if there was one directory with name 'foobar'.
207 217
208 218 * A bunch of patches from Kirill Smelkov:
209 219
210 220 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
211 221
212 222 * [patch 7/9] Implement %page -r (page in raw mode) -
213 223
214 224 * [patch 5/9] ScientificPython webpage has moved
215 225
216 226 * [patch 4/9] The manual mentions %ds, should be %dhist
217 227
218 228 * [patch 3/9] Kill old bits from %prun doc.
219 229
220 230 * [patch 1/9] Fix typos here and there.
221 231
222 232 2006-11-08 Ville Vainio <vivainio@gmail.com>
223 233
224 234 * completer.py (attr_matches): catch all exceptions raised
225 235 by eval of expr with dots.
226 236
227 237 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
228 238
229 239 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
230 240 input if it starts with whitespace. This allows you to paste
231 241 indented input from any editor without manually having to type in
232 242 the 'if 1:', which is convenient when working interactively.
233 243 Slightly modifed version of a patch by Bo Peng
234 244 <bpeng-AT-rice.edu>.
235 245
236 246 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
237 247
238 248 * IPython/irunner.py (main): modified irunner so it automatically
239 249 recognizes the right runner to use based on the extension (.py for
240 250 python, .ipy for ipython and .sage for sage).
241 251
242 252 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
243 253 visible in ipapi as ip.config(), to programatically control the
244 254 internal rc object. There's an accompanying %config magic for
245 255 interactive use, which has been enhanced to match the
246 256 funtionality in ipconfig.
247 257
248 258 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
249 259 so it's not just a toggle, it now takes an argument. Add support
250 260 for a customizable header when making system calls, as the new
251 261 system_header variable in the ipythonrc file.
252 262
253 263 2006-11-03 Walter Doerwald <walter@livinglogic.de>
254 264
255 265 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
256 266 generic functions (using Philip J. Eby's simplegeneric package).
257 267 This makes it possible to customize the display of third-party classes
258 268 without having to monkeypatch them. xiter() no longer supports a mode
259 269 argument and the XMode class has been removed. The same functionality can
260 270 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
261 271 One consequence of the switch to generic functions is that xrepr() and
262 272 xattrs() implementation must define the default value for the mode
263 273 argument themselves and xattrs() implementations must return real
264 274 descriptors.
265 275
266 276 * IPython/external: This new subpackage will contain all third-party
267 277 packages that are bundled with IPython. (The first one is simplegeneric).
268 278
269 279 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
270 280 directory which as been dropped in r1703.
271 281
272 282 * IPython/Extensions/ipipe.py (iless): Fixed.
273 283
274 284 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
275 285
276 286 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
277 287
278 288 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
279 289 handling in variable expansion so that shells and magics recognize
280 290 function local scopes correctly. Bug reported by Brian.
281 291
282 292 * scripts/ipython: remove the very first entry in sys.path which
283 293 Python auto-inserts for scripts, so that sys.path under IPython is
284 294 as similar as possible to that under plain Python.
285 295
286 296 * IPython/completer.py (IPCompleter.file_matches): Fix
287 297 tab-completion so that quotes are not closed unless the completion
288 298 is unambiguous. After a request by Stefan. Minor cleanups in
289 299 ipy_stock_completers.
290 300
291 301 2006-11-02 Ville Vainio <vivainio@gmail.com>
292 302
293 303 * ipy_stock_completers.py: Add %run and %cd completers.
294 304
295 305 * completer.py: Try running custom completer for both
296 306 "foo" and "%foo" if the command is just "foo". Ignore case
297 307 when filtering possible completions.
298 308
299 309 * UserConfig/ipy_user_conf.py: install stock completers as default
300 310
301 311 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
302 312 simplified readline history save / restore through a wrapper
303 313 function
304 314
305 315
306 316 2006-10-31 Ville Vainio <vivainio@gmail.com>
307 317
308 318 * strdispatch.py, completer.py, ipy_stock_completers.py:
309 319 Allow str_key ("command") in completer hooks. Implement
310 320 trivial completer for 'import' (stdlib modules only). Rename
311 321 ipy_linux_package_managers.py to ipy_stock_completers.py.
312 322 SVN completer.
313 323
314 324 * Extensions/ledit.py: %magic line editor for easily and
315 325 incrementally manipulating lists of strings. The magic command
316 326 name is %led.
317 327
318 328 2006-10-30 Ville Vainio <vivainio@gmail.com>
319 329
320 330 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
321 331 Bernsteins's patches for pydb integration.
322 332 http://bashdb.sourceforge.net/pydb/
323 333
324 334 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
325 335 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
326 336 custom completer hook to allow the users to implement their own
327 337 completers. See ipy_linux_package_managers.py for example. The
328 338 hook name is 'complete_command'.
329 339
330 340 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
331 341
332 342 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
333 343 Numeric leftovers.
334 344
335 345 * ipython.el (py-execute-region): apply Stefan's patch to fix
336 346 garbled results if the python shell hasn't been previously started.
337 347
338 348 * IPython/genutils.py (arg_split): moved to genutils, since it's a
339 349 pretty generic function and useful for other things.
340 350
341 351 * IPython/OInspect.py (getsource): Add customizable source
342 352 extractor. After a request/patch form W. Stein (SAGE).
343 353
344 354 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
345 355 window size to a more reasonable value from what pexpect does,
346 356 since their choice causes wrapping bugs with long input lines.
347 357
348 358 2006-10-28 Ville Vainio <vivainio@gmail.com>
349 359
350 360 * Magic.py (%run): Save and restore the readline history from
351 361 file around %run commands to prevent side effects from
352 362 %runned programs that might use readline (e.g. pydb).
353 363
354 364 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
355 365 invoking the pydb enhanced debugger.
356 366
357 367 2006-10-23 Walter Doerwald <walter@livinglogic.de>
358 368
359 369 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
360 370 call the base class method and propagate the return value to
361 371 ifile. This is now done by path itself.
362 372
363 373 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
364 374
365 375 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
366 376 api: set_crash_handler(), to expose the ability to change the
367 377 internal crash handler.
368 378
369 379 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
370 380 the various parameters of the crash handler so that apps using
371 381 IPython as their engine can customize crash handling. Ipmlemented
372 382 at the request of SAGE.
373 383
374 384 2006-10-14 Ville Vainio <vivainio@gmail.com>
375 385
376 386 * Magic.py, ipython.el: applied first "safe" part of Rocky
377 387 Bernstein's patch set for pydb integration.
378 388
379 389 * Magic.py (%unalias, %alias): %store'd aliases can now be
380 390 removed with '%unalias'. %alias w/o args now shows most
381 391 interesting (stored / manually defined) aliases last
382 392 where they catch the eye w/o scrolling.
383 393
384 394 * Magic.py (%rehashx), ext_rehashdir.py: files with
385 395 'py' extension are always considered executable, even
386 396 when not in PATHEXT environment variable.
387 397
388 398 2006-10-12 Ville Vainio <vivainio@gmail.com>
389 399
390 400 * jobctrl.py: Add new "jobctrl" extension for spawning background
391 401 processes with "&find /". 'import jobctrl' to try it out. Requires
392 402 'subprocess' module, standard in python 2.4+.
393 403
394 404 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
395 405 so if foo -> bar and bar -> baz, then foo -> baz.
396 406
397 407 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
398 408
399 409 * IPython/Magic.py (Magic.parse_options): add a new posix option
400 410 to allow parsing of input args in magics that doesn't strip quotes
401 411 (if posix=False). This also closes %timeit bug reported by
402 412 Stefan.
403 413
404 414 2006-10-03 Ville Vainio <vivainio@gmail.com>
405 415
406 416 * iplib.py (raw_input, interact): Return ValueError catching for
407 417 raw_input. Fixes infinite loop for sys.stdin.close() or
408 418 sys.stdout.close().
409 419
410 420 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
411 421
412 422 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
413 423 to help in handling doctests. irunner is now pretty useful for
414 424 running standalone scripts and simulate a full interactive session
415 425 in a format that can be then pasted as a doctest.
416 426
417 427 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
418 428 on top of the default (useless) ones. This also fixes the nasty
419 429 way in which 2.5's Quitter() exits (reverted [1785]).
420 430
421 431 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
422 432 2.5.
423 433
424 434 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
425 435 color scheme is updated as well when color scheme is changed
426 436 interactively.
427 437
428 438 2006-09-27 Ville Vainio <vivainio@gmail.com>
429 439
430 440 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
431 441 infinite loop and just exit. It's a hack, but will do for a while.
432 442
433 443 2006-08-25 Walter Doerwald <walter@livinglogic.de>
434 444
435 445 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
436 446 the constructor, this makes it possible to get a list of only directories
437 447 or only files.
438 448
439 449 2006-08-12 Ville Vainio <vivainio@gmail.com>
440 450
441 451 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
442 452 they broke unittest
443 453
444 454 2006-08-11 Ville Vainio <vivainio@gmail.com>
445 455
446 456 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
447 457 by resolving issue properly, i.e. by inheriting FakeModule
448 458 from types.ModuleType. Pickling ipython interactive data
449 459 should still work as usual (testing appreciated).
450 460
451 461 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
452 462
453 463 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
454 464 running under python 2.3 with code from 2.4 to fix a bug with
455 465 help(). Reported by the Debian maintainers, Norbert Tretkowski
456 466 <norbert-AT-tretkowski.de> and Alexandre Fayolle
457 467 <afayolle-AT-debian.org>.
458 468
459 469 2006-08-04 Walter Doerwald <walter@livinglogic.de>
460 470
461 471 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
462 472 (which was displaying "quit" twice).
463 473
464 474 2006-07-28 Walter Doerwald <walter@livinglogic.de>
465 475
466 476 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
467 477 the mode argument).
468 478
469 479 2006-07-27 Walter Doerwald <walter@livinglogic.de>
470 480
471 481 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
472 482 not running under IPython.
473 483
474 484 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
475 485 and make it iterable (iterating over the attribute itself). Add two new
476 486 magic strings for __xattrs__(): If the string starts with "-", the attribute
477 487 will not be displayed in ibrowse's detail view (but it can still be
478 488 iterated over). This makes it possible to add attributes that are large
479 489 lists or generator methods to the detail view. Replace magic attribute names
480 490 and _attrname() and _getattr() with "descriptors": For each type of magic
481 491 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
482 492 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
483 493 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
484 494 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
485 495 are still supported.
486 496
487 497 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
488 498 fails in ibrowse.fetch(), the exception object is added as the last item
489 499 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
490 500 a generator throws an exception midway through execution.
491 501
492 502 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
493 503 encoding into methods.
494 504
495 505 2006-07-26 Ville Vainio <vivainio@gmail.com>
496 506
497 507 * iplib.py: history now stores multiline input as single
498 508 history entries. Patch by Jorgen Cederlof.
499 509
500 510 2006-07-18 Walter Doerwald <walter@livinglogic.de>
501 511
502 512 * IPython/Extensions/ibrowse.py: Make cursor visible over
503 513 non existing attributes.
504 514
505 515 2006-07-14 Walter Doerwald <walter@livinglogic.de>
506 516
507 517 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
508 518 error output of the running command doesn't mess up the screen.
509 519
510 520 2006-07-13 Walter Doerwald <walter@livinglogic.de>
511 521
512 522 * IPython/Extensions/ipipe.py (isort): Make isort usable without
513 523 argument. This sorts the items themselves.
514 524
515 525 2006-07-12 Walter Doerwald <walter@livinglogic.de>
516 526
517 527 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
518 528 Compile expression strings into code objects. This should speed
519 529 up ifilter and friends somewhat.
520 530
521 531 2006-07-08 Ville Vainio <vivainio@gmail.com>
522 532
523 533 * Magic.py: %cpaste now strips > from the beginning of lines
524 534 to ease pasting quoted code from emails. Contributed by
525 535 Stefan van der Walt.
526 536
527 537 2006-06-29 Ville Vainio <vivainio@gmail.com>
528 538
529 539 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
530 540 mode, patch contributed by Darren Dale. NEEDS TESTING!
531 541
532 542 2006-06-28 Walter Doerwald <walter@livinglogic.de>
533 543
534 544 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
535 545 a blue background. Fix fetching new display rows when the browser
536 546 scrolls more than a screenful (e.g. by using the goto command).
537 547
538 548 2006-06-27 Ville Vainio <vivainio@gmail.com>
539 549
540 550 * Magic.py (_inspect, _ofind) Apply David Huard's
541 551 patch for displaying the correct docstring for 'property'
542 552 attributes.
543 553
544 554 2006-06-23 Walter Doerwald <walter@livinglogic.de>
545 555
546 556 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
547 557 commands into the methods implementing them.
548 558
549 559 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
550 560
551 561 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
552 562 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
553 563 autoindent support was authored by Jin Liu.
554 564
555 565 2006-06-22 Walter Doerwald <walter@livinglogic.de>
556 566
557 567 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
558 568 for keymaps with a custom class that simplifies handling.
559 569
560 570 2006-06-19 Walter Doerwald <walter@livinglogic.de>
561 571
562 572 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
563 573 resizing. This requires Python 2.5 to work.
564 574
565 575 2006-06-16 Walter Doerwald <walter@livinglogic.de>
566 576
567 577 * IPython/Extensions/ibrowse.py: Add two new commands to
568 578 ibrowse: "hideattr" (mapped to "h") hides the attribute under
569 579 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
570 580 attributes again. Remapped the help command to "?". Display
571 581 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
572 582 as keys for the "home" and "end" commands. Add three new commands
573 583 to the input mode for "find" and friends: "delend" (CTRL-K)
574 584 deletes to the end of line. "incsearchup" searches upwards in the
575 585 command history for an input that starts with the text before the cursor.
576 586 "incsearchdown" does the same downwards. Removed a bogus mapping of
577 587 the x key to "delete".
578 588
579 589 2006-06-15 Ville Vainio <vivainio@gmail.com>
580 590
581 591 * iplib.py, hooks.py: Added new generate_prompt hook that can be
582 592 used to create prompts dynamically, instead of the "old" way of
583 593 assigning "magic" strings to prompt_in1 and prompt_in2. The old
584 594 way still works (it's invoked by the default hook), of course.
585 595
586 596 * Prompts.py: added generate_output_prompt hook for altering output
587 597 prompt
588 598
589 599 * Release.py: Changed version string to 0.7.3.svn.
590 600
591 601 2006-06-15 Walter Doerwald <walter@livinglogic.de>
592 602
593 603 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
594 604 the call to fetch() always tries to fetch enough data for at least one
595 605 full screen. This makes it possible to simply call moveto(0,0,True) in
596 606 the constructor. Fix typos and removed the obsolete goto attribute.
597 607
598 608 2006-06-12 Ville Vainio <vivainio@gmail.com>
599 609
600 610 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
601 611 allowing $variable interpolation within multiline statements,
602 612 though so far only with "sh" profile for a testing period.
603 613 The patch also enables splitting long commands with \ but it
604 614 doesn't work properly yet.
605 615
606 616 2006-06-12 Walter Doerwald <walter@livinglogic.de>
607 617
608 618 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
609 619 input history and the position of the cursor in the input history for
610 620 the find, findbackwards and goto command.
611 621
612 622 2006-06-10 Walter Doerwald <walter@livinglogic.de>
613 623
614 624 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
615 625 implements the basic functionality of browser commands that require
616 626 input. Reimplement the goto, find and findbackwards commands as
617 627 subclasses of _CommandInput. Add an input history and keymaps to those
618 628 commands. Add "\r" as a keyboard shortcut for the enterdefault and
619 629 execute commands.
620 630
621 631 2006-06-07 Ville Vainio <vivainio@gmail.com>
622 632
623 633 * iplib.py: ipython mybatch.ipy exits ipython immediately after
624 634 running the batch files instead of leaving the session open.
625 635
626 636 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
627 637
628 638 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
629 639 the original fix was incomplete. Patch submitted by W. Maier.
630 640
631 641 2006-06-07 Ville Vainio <vivainio@gmail.com>
632 642
633 643 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
634 644 Confirmation prompts can be supressed by 'quiet' option.
635 645 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
636 646
637 647 2006-06-06 *** Released version 0.7.2
638 648
639 649 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
640 650
641 651 * IPython/Release.py (version): Made 0.7.2 final for release.
642 652 Repo tagged and release cut.
643 653
644 654 2006-06-05 Ville Vainio <vivainio@gmail.com>
645 655
646 656 * Magic.py (magic_rehashx): Honor no_alias list earlier in
647 657 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
648 658
649 659 * upgrade_dir.py: try import 'path' module a bit harder
650 660 (for %upgrade)
651 661
652 662 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
653 663
654 664 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
655 665 instead of looping 20 times.
656 666
657 667 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
658 668 correctly at initialization time. Bug reported by Krishna Mohan
659 669 Gundu <gkmohan-AT-gmail.com> on the user list.
660 670
661 671 * IPython/Release.py (version): Mark 0.7.2 version to start
662 672 testing for release on 06/06.
663 673
664 674 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
665 675
666 676 * scripts/irunner: thin script interface so users don't have to
667 677 find the module and call it as an executable, since modules rarely
668 678 live in people's PATH.
669 679
670 680 * IPython/irunner.py (InteractiveRunner.__init__): added
671 681 delaybeforesend attribute to control delays with newer versions of
672 682 pexpect. Thanks to detailed help from pexpect's author, Noah
673 683 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
674 684 correctly (it works in NoColor mode).
675 685
676 686 * IPython/iplib.py (handle_normal): fix nasty crash reported on
677 687 SAGE list, from improper log() calls.
678 688
679 689 2006-05-31 Ville Vainio <vivainio@gmail.com>
680 690
681 691 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
682 692 with args in parens to work correctly with dirs that have spaces.
683 693
684 694 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
685 695
686 696 * IPython/Logger.py (Logger.logstart): add option to log raw input
687 697 instead of the processed one. A -r flag was added to the
688 698 %logstart magic used for controlling logging.
689 699
690 700 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
691 701
692 702 * IPython/iplib.py (InteractiveShell.__init__): add check for the
693 703 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
694 704 recognize the option. After a bug report by Will Maier. This
695 705 closes #64 (will do it after confirmation from W. Maier).
696 706
697 707 * IPython/irunner.py: New module to run scripts as if manually
698 708 typed into an interactive environment, based on pexpect. After a
699 709 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
700 710 ipython-user list. Simple unittests in the tests/ directory.
701 711
702 712 * tools/release: add Will Maier, OpenBSD port maintainer, to
703 713 recepients list. We are now officially part of the OpenBSD ports:
704 714 http://www.openbsd.org/ports.html ! Many thanks to Will for the
705 715 work.
706 716
707 717 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
708 718
709 719 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
710 720 so that it doesn't break tkinter apps.
711 721
712 722 * IPython/iplib.py (_prefilter): fix bug where aliases would
713 723 shadow variables when autocall was fully off. Reported by SAGE
714 724 author William Stein.
715 725
716 726 * IPython/OInspect.py (Inspector.__init__): add a flag to control
717 727 at what detail level strings are computed when foo? is requested.
718 728 This allows users to ask for example that the string form of an
719 729 object is only computed when foo?? is called, or even never, by
720 730 setting the object_info_string_level >= 2 in the configuration
721 731 file. This new option has been added and documented. After a
722 732 request by SAGE to be able to control the printing of very large
723 733 objects more easily.
724 734
725 735 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
726 736
727 737 * IPython/ipmaker.py (make_IPython): remove the ipython call path
728 738 from sys.argv, to be 100% consistent with how Python itself works
729 739 (as seen for example with python -i file.py). After a bug report
730 740 by Jeffrey Collins.
731 741
732 742 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
733 743 nasty bug which was preventing custom namespaces with -pylab,
734 744 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
735 745 compatibility (long gone from mpl).
736 746
737 747 * IPython/ipapi.py (make_session): name change: create->make. We
738 748 use make in other places (ipmaker,...), it's shorter and easier to
739 749 type and say, etc. I'm trying to clean things before 0.7.2 so
740 750 that I can keep things stable wrt to ipapi in the chainsaw branch.
741 751
742 752 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
743 753 python-mode recognizes our debugger mode. Add support for
744 754 autoindent inside (X)emacs. After a patch sent in by Jin Liu
745 755 <m.liu.jin-AT-gmail.com> originally written by
746 756 doxgen-AT-newsmth.net (with minor modifications for xemacs
747 757 compatibility)
748 758
749 759 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
750 760 tracebacks when walking the stack so that the stack tracking system
751 761 in emacs' python-mode can identify the frames correctly.
752 762
753 763 * IPython/ipmaker.py (make_IPython): make the internal (and
754 764 default config) autoedit_syntax value false by default. Too many
755 765 users have complained to me (both on and off-list) about problems
756 766 with this option being on by default, so I'm making it default to
757 767 off. It can still be enabled by anyone via the usual mechanisms.
758 768
759 769 * IPython/completer.py (Completer.attr_matches): add support for
760 770 PyCrust-style _getAttributeNames magic method. Patch contributed
761 771 by <mscott-AT-goldenspud.com>. Closes #50.
762 772
763 773 * IPython/iplib.py (InteractiveShell.__init__): remove the
764 774 deletion of exit/quit from __builtin__, which can break
765 775 third-party tools like the Zope debugging console. The
766 776 %exit/%quit magics remain. In general, it's probably a good idea
767 777 not to delete anything from __builtin__, since we never know what
768 778 that will break. In any case, python now (for 2.5) will support
769 779 'real' exit/quit, so this issue is moot. Closes #55.
770 780
771 781 * IPython/genutils.py (with_obj): rename the 'with' function to
772 782 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
773 783 becomes a language keyword. Closes #53.
774 784
775 785 * IPython/FakeModule.py (FakeModule.__init__): add a proper
776 786 __file__ attribute to this so it fools more things into thinking
777 787 it is a real module. Closes #59.
778 788
779 789 * IPython/Magic.py (magic_edit): add -n option to open the editor
780 790 at a specific line number. After a patch by Stefan van der Walt.
781 791
782 792 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
783 793
784 794 * IPython/iplib.py (edit_syntax_error): fix crash when for some
785 795 reason the file could not be opened. After automatic crash
786 796 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
787 797 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
788 798 (_should_recompile): Don't fire editor if using %bg, since there
789 799 is no file in the first place. From the same report as above.
790 800 (raw_input): protect against faulty third-party prefilters. After
791 801 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
792 802 while running under SAGE.
793 803
794 804 2006-05-23 Ville Vainio <vivainio@gmail.com>
795 805
796 806 * ipapi.py: Stripped down ip.to_user_ns() to work only as
797 807 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
798 808 now returns None (again), unless dummy is specifically allowed by
799 809 ipapi.get(allow_dummy=True).
800 810
801 811 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
802 812
803 813 * IPython: remove all 2.2-compatibility objects and hacks from
804 814 everywhere, since we only support 2.3 at this point. Docs
805 815 updated.
806 816
807 817 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
808 818 Anything requiring extra validation can be turned into a Python
809 819 property in the future. I used a property for the db one b/c
810 820 there was a nasty circularity problem with the initialization
811 821 order, which right now I don't have time to clean up.
812 822
813 823 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
814 824 another locking bug reported by Jorgen. I'm not 100% sure though,
815 825 so more testing is needed...
816 826
817 827 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
818 828
819 829 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
820 830 local variables from any routine in user code (typically executed
821 831 with %run) directly into the interactive namespace. Very useful
822 832 when doing complex debugging.
823 833 (IPythonNotRunning): Changed the default None object to a dummy
824 834 whose attributes can be queried as well as called without
825 835 exploding, to ease writing code which works transparently both in
826 836 and out of ipython and uses some of this API.
827 837
828 838 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
829 839
830 840 * IPython/hooks.py (result_display): Fix the fact that our display
831 841 hook was using str() instead of repr(), as the default python
832 842 console does. This had gone unnoticed b/c it only happened if
833 843 %Pprint was off, but the inconsistency was there.
834 844
835 845 2006-05-15 Ville Vainio <vivainio@gmail.com>
836 846
837 847 * Oinspect.py: Only show docstring for nonexisting/binary files
838 848 when doing object??, closing ticket #62
839 849
840 850 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
841 851
842 852 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
843 853 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
844 854 was being released in a routine which hadn't checked if it had
845 855 been the one to acquire it.
846 856
847 857 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
848 858
849 859 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
850 860
851 861 2006-04-11 Ville Vainio <vivainio@gmail.com>
852 862
853 863 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
854 864 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
855 865 prefilters, allowing stuff like magics and aliases in the file.
856 866
857 867 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
858 868 added. Supported now are "%clear in" and "%clear out" (clear input and
859 869 output history, respectively). Also fixed CachedOutput.flush to
860 870 properly flush the output cache.
861 871
862 872 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
863 873 half-success (and fail explicitly).
864 874
865 875 2006-03-28 Ville Vainio <vivainio@gmail.com>
866 876
867 877 * iplib.py: Fix quoting of aliases so that only argless ones
868 878 are quoted
869 879
870 880 2006-03-28 Ville Vainio <vivainio@gmail.com>
871 881
872 882 * iplib.py: Quote aliases with spaces in the name.
873 883 "c:\program files\blah\bin" is now legal alias target.
874 884
875 885 * ext_rehashdir.py: Space no longer allowed as arg
876 886 separator, since space is legal in path names.
877 887
878 888 2006-03-16 Ville Vainio <vivainio@gmail.com>
879 889
880 890 * upgrade_dir.py: Take path.py from Extensions, correcting
881 891 %upgrade magic
882 892
883 893 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
884 894
885 895 * hooks.py: Only enclose editor binary in quotes if legal and
886 896 necessary (space in the name, and is an existing file). Fixes a bug
887 897 reported by Zachary Pincus.
888 898
889 899 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
890 900
891 901 * Manual: thanks to a tip on proper color handling for Emacs, by
892 902 Eric J Haywiser <ejh1-AT-MIT.EDU>.
893 903
894 904 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
895 905 by applying the provided patch. Thanks to Liu Jin
896 906 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
897 907 XEmacs/Linux, I'm trusting the submitter that it actually helps
898 908 under win32/GNU Emacs. Will revisit if any problems are reported.
899 909
900 910 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
901 911
902 912 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
903 913 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
904 914
905 915 2006-03-12 Ville Vainio <vivainio@gmail.com>
906 916
907 917 * Magic.py (magic_timeit): Added %timeit magic, contributed by
908 918 Torsten Marek.
909 919
910 920 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
911 921
912 922 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
913 923 line ranges works again.
914 924
915 925 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
916 926
917 927 * IPython/iplib.py (showtraceback): add back sys.last_traceback
918 928 and friends, after a discussion with Zach Pincus on ipython-user.
919 929 I'm not 100% sure, but after thinking about it quite a bit, it may
920 930 be OK. Testing with the multithreaded shells didn't reveal any
921 931 problems, but let's keep an eye out.
922 932
923 933 In the process, I fixed a few things which were calling
924 934 self.InteractiveTB() directly (like safe_execfile), which is a
925 935 mistake: ALL exception reporting should be done by calling
926 936 self.showtraceback(), which handles state and tab-completion and
927 937 more.
928 938
929 939 2006-03-01 Ville Vainio <vivainio@gmail.com>
930 940
931 941 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
932 942 To use, do "from ipipe import *".
933 943
934 944 2006-02-24 Ville Vainio <vivainio@gmail.com>
935 945
936 946 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
937 947 "cleanly" and safely than the older upgrade mechanism.
938 948
939 949 2006-02-21 Ville Vainio <vivainio@gmail.com>
940 950
941 951 * Magic.py: %save works again.
942 952
943 953 2006-02-15 Ville Vainio <vivainio@gmail.com>
944 954
945 955 * Magic.py: %Pprint works again
946 956
947 957 * Extensions/ipy_sane_defaults.py: Provide everything provided
948 958 in default ipythonrc, to make it possible to have a completely empty
949 959 ipythonrc (and thus completely rc-file free configuration)
950 960
951 961 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
952 962
953 963 * IPython/hooks.py (editor): quote the call to the editor command,
954 964 to allow commands with spaces in them. Problem noted by watching
955 965 Ian Oswald's video about textpad under win32 at
956 966 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
957 967
958 968 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
959 969 describing magics (we haven't used @ for a loong time).
960 970
961 971 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
962 972 contributed by marienz to close
963 973 http://www.scipy.net/roundup/ipython/issue53.
964 974
965 975 2006-02-10 Ville Vainio <vivainio@gmail.com>
966 976
967 977 * genutils.py: getoutput now works in win32 too
968 978
969 979 * completer.py: alias and magic completion only invoked
970 980 at the first "item" in the line, to avoid "cd %store"
971 981 nonsense.
972 982
973 983 2006-02-09 Ville Vainio <vivainio@gmail.com>
974 984
975 985 * test/*: Added a unit testing framework (finally).
976 986 '%run runtests.py' to run test_*.
977 987
978 988 * ipapi.py: Exposed runlines and set_custom_exc
979 989
980 990 2006-02-07 Ville Vainio <vivainio@gmail.com>
981 991
982 992 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
983 993 instead use "f(1 2)" as before.
984 994
985 995 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
986 996
987 997 * IPython/demo.py (IPythonDemo): Add new classes to the demo
988 998 facilities, for demos processed by the IPython input filter
989 999 (IPythonDemo), and for running a script one-line-at-a-time as a
990 1000 demo, both for pure Python (LineDemo) and for IPython-processed
991 1001 input (IPythonLineDemo). After a request by Dave Kohel, from the
992 1002 SAGE team.
993 1003 (Demo.edit): added an edit() method to the demo objects, to edit
994 1004 the in-memory copy of the last executed block.
995 1005
996 1006 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
997 1007 processing to %edit, %macro and %save. These commands can now be
998 1008 invoked on the unprocessed input as it was typed by the user
999 1009 (without any prefilters applied). After requests by the SAGE team
1000 1010 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1001 1011
1002 1012 2006-02-01 Ville Vainio <vivainio@gmail.com>
1003 1013
1004 1014 * setup.py, eggsetup.py: easy_install ipython==dev works
1005 1015 correctly now (on Linux)
1006 1016
1007 1017 * ipy_user_conf,ipmaker: user config changes, removed spurious
1008 1018 warnings
1009 1019
1010 1020 * iplib: if rc.banner is string, use it as is.
1011 1021
1012 1022 * Magic: %pycat accepts a string argument and pages it's contents.
1013 1023
1014 1024
1015 1025 2006-01-30 Ville Vainio <vivainio@gmail.com>
1016 1026
1017 1027 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1018 1028 Now %store and bookmarks work through PickleShare, meaning that
1019 1029 concurrent access is possible and all ipython sessions see the
1020 1030 same database situation all the time, instead of snapshot of
1021 1031 the situation when the session was started. Hence, %bookmark
1022 1032 results are immediately accessible from othes sessions. The database
1023 1033 is also available for use by user extensions. See:
1024 1034 http://www.python.org/pypi/pickleshare
1025 1035
1026 1036 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1027 1037
1028 1038 * aliases can now be %store'd
1029 1039
1030 1040 * path.py moved to Extensions so that pickleshare does not need
1031 1041 IPython-specific import. Extensions added to pythonpath right
1032 1042 at __init__.
1033 1043
1034 1044 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1035 1045 called with _ip.system and the pre-transformed command string.
1036 1046
1037 1047 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1038 1048
1039 1049 * IPython/iplib.py (interact): Fix that we were not catching
1040 1050 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1041 1051 logic here had to change, but it's fixed now.
1042 1052
1043 1053 2006-01-29 Ville Vainio <vivainio@gmail.com>
1044 1054
1045 1055 * iplib.py: Try to import pyreadline on Windows.
1046 1056
1047 1057 2006-01-27 Ville Vainio <vivainio@gmail.com>
1048 1058
1049 1059 * iplib.py: Expose ipapi as _ip in builtin namespace.
1050 1060 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1051 1061 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1052 1062 syntax now produce _ip.* variant of the commands.
1053 1063
1054 1064 * "_ip.options().autoedit_syntax = 2" automatically throws
1055 1065 user to editor for syntax error correction without prompting.
1056 1066
1057 1067 2006-01-27 Ville Vainio <vivainio@gmail.com>
1058 1068
1059 1069 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1060 1070 'ipython' at argv[0]) executed through command line.
1061 1071 NOTE: this DEPRECATES calling ipython with multiple scripts
1062 1072 ("ipython a.py b.py c.py")
1063 1073
1064 1074 * iplib.py, hooks.py: Added configurable input prefilter,
1065 1075 named 'input_prefilter'. See ext_rescapture.py for example
1066 1076 usage.
1067 1077
1068 1078 * ext_rescapture.py, Magic.py: Better system command output capture
1069 1079 through 'var = !ls' (deprecates user-visible %sc). Same notation
1070 1080 applies for magics, 'var = %alias' assigns alias list to var.
1071 1081
1072 1082 * ipapi.py: added meta() for accessing extension-usable data store.
1073 1083
1074 1084 * iplib.py: added InteractiveShell.getapi(). New magics should be
1075 1085 written doing self.getapi() instead of using the shell directly.
1076 1086
1077 1087 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1078 1088 %store foo >> ~/myfoo.txt to store variables to files (in clean
1079 1089 textual form, not a restorable pickle).
1080 1090
1081 1091 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1082 1092
1083 1093 * usage.py, Magic.py: added %quickref
1084 1094
1085 1095 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1086 1096
1087 1097 * GetoptErrors when invoking magics etc. with wrong args
1088 1098 are now more helpful:
1089 1099 GetoptError: option -l not recognized (allowed: "qb" )
1090 1100
1091 1101 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1092 1102
1093 1103 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1094 1104 computationally intensive blocks don't appear to stall the demo.
1095 1105
1096 1106 2006-01-24 Ville Vainio <vivainio@gmail.com>
1097 1107
1098 1108 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1099 1109 value to manipulate resulting history entry.
1100 1110
1101 1111 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1102 1112 to instance methods of IPApi class, to make extending an embedded
1103 1113 IPython feasible. See ext_rehashdir.py for example usage.
1104 1114
1105 1115 * Merged 1071-1076 from branches/0.7.1
1106 1116
1107 1117
1108 1118 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1109 1119
1110 1120 * tools/release (daystamp): Fix build tools to use the new
1111 1121 eggsetup.py script to build lightweight eggs.
1112 1122
1113 1123 * Applied changesets 1062 and 1064 before 0.7.1 release.
1114 1124
1115 1125 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1116 1126 see the raw input history (without conversions like %ls ->
1117 1127 ipmagic("ls")). After a request from W. Stein, SAGE
1118 1128 (http://modular.ucsd.edu/sage) developer. This information is
1119 1129 stored in the input_hist_raw attribute of the IPython instance, so
1120 1130 developers can access it if needed (it's an InputList instance).
1121 1131
1122 1132 * Versionstring = 0.7.2.svn
1123 1133
1124 1134 * eggsetup.py: A separate script for constructing eggs, creates
1125 1135 proper launch scripts even on Windows (an .exe file in
1126 1136 \python24\scripts).
1127 1137
1128 1138 * ipapi.py: launch_new_instance, launch entry point needed for the
1129 1139 egg.
1130 1140
1131 1141 2006-01-23 Ville Vainio <vivainio@gmail.com>
1132 1142
1133 1143 * Added %cpaste magic for pasting python code
1134 1144
1135 1145 2006-01-22 Ville Vainio <vivainio@gmail.com>
1136 1146
1137 1147 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1138 1148
1139 1149 * Versionstring = 0.7.2.svn
1140 1150
1141 1151 * eggsetup.py: A separate script for constructing eggs, creates
1142 1152 proper launch scripts even on Windows (an .exe file in
1143 1153 \python24\scripts).
1144 1154
1145 1155 * ipapi.py: launch_new_instance, launch entry point needed for the
1146 1156 egg.
1147 1157
1148 1158 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1149 1159
1150 1160 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1151 1161 %pfile foo would print the file for foo even if it was a binary.
1152 1162 Now, extensions '.so' and '.dll' are skipped.
1153 1163
1154 1164 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1155 1165 bug, where macros would fail in all threaded modes. I'm not 100%
1156 1166 sure, so I'm going to put out an rc instead of making a release
1157 1167 today, and wait for feedback for at least a few days.
1158 1168
1159 1169 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1160 1170 it...) the handling of pasting external code with autoindent on.
1161 1171 To get out of a multiline input, the rule will appear for most
1162 1172 users unchanged: two blank lines or change the indent level
1163 1173 proposed by IPython. But there is a twist now: you can
1164 1174 add/subtract only *one or two spaces*. If you add/subtract three
1165 1175 or more (unless you completely delete the line), IPython will
1166 1176 accept that line, and you'll need to enter a second one of pure
1167 1177 whitespace. I know it sounds complicated, but I can't find a
1168 1178 different solution that covers all the cases, with the right
1169 1179 heuristics. Hopefully in actual use, nobody will really notice
1170 1180 all these strange rules and things will 'just work'.
1171 1181
1172 1182 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1173 1183
1174 1184 * IPython/iplib.py (interact): catch exceptions which can be
1175 1185 triggered asynchronously by signal handlers. Thanks to an
1176 1186 automatic crash report, submitted by Colin Kingsley
1177 1187 <tercel-AT-gentoo.org>.
1178 1188
1179 1189 2006-01-20 Ville Vainio <vivainio@gmail.com>
1180 1190
1181 1191 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1182 1192 (%rehashdir, very useful, try it out) of how to extend ipython
1183 1193 with new magics. Also added Extensions dir to pythonpath to make
1184 1194 importing extensions easy.
1185 1195
1186 1196 * %store now complains when trying to store interactively declared
1187 1197 classes / instances of those classes.
1188 1198
1189 1199 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1190 1200 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1191 1201 if they exist, and ipy_user_conf.py with some defaults is created for
1192 1202 the user.
1193 1203
1194 1204 * Startup rehashing done by the config file, not InterpreterExec.
1195 1205 This means system commands are available even without selecting the
1196 1206 pysh profile. It's the sensible default after all.
1197 1207
1198 1208 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1199 1209
1200 1210 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1201 1211 multiline code with autoindent on working. But I am really not
1202 1212 sure, so this needs more testing. Will commit a debug-enabled
1203 1213 version for now, while I test it some more, so that Ville and
1204 1214 others may also catch any problems. Also made
1205 1215 self.indent_current_str() a method, to ensure that there's no
1206 1216 chance of the indent space count and the corresponding string
1207 1217 falling out of sync. All code needing the string should just call
1208 1218 the method.
1209 1219
1210 1220 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1211 1221
1212 1222 * IPython/Magic.py (magic_edit): fix check for when users don't
1213 1223 save their output files, the try/except was in the wrong section.
1214 1224
1215 1225 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1216 1226
1217 1227 * IPython/Magic.py (magic_run): fix __file__ global missing from
1218 1228 script's namespace when executed via %run. After a report by
1219 1229 Vivian.
1220 1230
1221 1231 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1222 1232 when using python 2.4. The parent constructor changed in 2.4, and
1223 1233 we need to track it directly (we can't call it, as it messes up
1224 1234 readline and tab-completion inside our pdb would stop working).
1225 1235 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1226 1236
1227 1237 2006-01-16 Ville Vainio <vivainio@gmail.com>
1228 1238
1229 1239 * Ipython/magic.py: Reverted back to old %edit functionality
1230 1240 that returns file contents on exit.
1231 1241
1232 1242 * IPython/path.py: Added Jason Orendorff's "path" module to
1233 1243 IPython tree, http://www.jorendorff.com/articles/python/path/.
1234 1244 You can get path objects conveniently through %sc, and !!, e.g.:
1235 1245 sc files=ls
1236 1246 for p in files.paths: # or files.p
1237 1247 print p,p.mtime
1238 1248
1239 1249 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1240 1250 now work again without considering the exclusion regexp -
1241 1251 hence, things like ',foo my/path' turn to 'foo("my/path")'
1242 1252 instead of syntax error.
1243 1253
1244 1254
1245 1255 2006-01-14 Ville Vainio <vivainio@gmail.com>
1246 1256
1247 1257 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1248 1258 ipapi decorators for python 2.4 users, options() provides access to rc
1249 1259 data.
1250 1260
1251 1261 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1252 1262 as path separators (even on Linux ;-). Space character after
1253 1263 backslash (as yielded by tab completer) is still space;
1254 1264 "%cd long\ name" works as expected.
1255 1265
1256 1266 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1257 1267 as "chain of command", with priority. API stays the same,
1258 1268 TryNext exception raised by a hook function signals that
1259 1269 current hook failed and next hook should try handling it, as
1260 1270 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1261 1271 requested configurable display hook, which is now implemented.
1262 1272
1263 1273 2006-01-13 Ville Vainio <vivainio@gmail.com>
1264 1274
1265 1275 * IPython/platutils*.py: platform specific utility functions,
1266 1276 so far only set_term_title is implemented (change terminal
1267 1277 label in windowing systems). %cd now changes the title to
1268 1278 current dir.
1269 1279
1270 1280 * IPython/Release.py: Added myself to "authors" list,
1271 1281 had to create new files.
1272 1282
1273 1283 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1274 1284 shell escape; not a known bug but had potential to be one in the
1275 1285 future.
1276 1286
1277 1287 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1278 1288 extension API for IPython! See the module for usage example. Fix
1279 1289 OInspect for docstring-less magic functions.
1280 1290
1281 1291
1282 1292 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1283 1293
1284 1294 * IPython/iplib.py (raw_input): temporarily deactivate all
1285 1295 attempts at allowing pasting of code with autoindent on. It
1286 1296 introduced bugs (reported by Prabhu) and I can't seem to find a
1287 1297 robust combination which works in all cases. Will have to revisit
1288 1298 later.
1289 1299
1290 1300 * IPython/genutils.py: remove isspace() function. We've dropped
1291 1301 2.2 compatibility, so it's OK to use the string method.
1292 1302
1293 1303 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1294 1304
1295 1305 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1296 1306 matching what NOT to autocall on, to include all python binary
1297 1307 operators (including things like 'and', 'or', 'is' and 'in').
1298 1308 Prompted by a bug report on 'foo & bar', but I realized we had
1299 1309 many more potential bug cases with other operators. The regexp is
1300 1310 self.re_exclude_auto, it's fairly commented.
1301 1311
1302 1312 2006-01-12 Ville Vainio <vivainio@gmail.com>
1303 1313
1304 1314 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1305 1315 Prettified and hardened string/backslash quoting with ipsystem(),
1306 1316 ipalias() and ipmagic(). Now even \ characters are passed to
1307 1317 %magics, !shell escapes and aliases exactly as they are in the
1308 1318 ipython command line. Should improve backslash experience,
1309 1319 particularly in Windows (path delimiter for some commands that
1310 1320 won't understand '/'), but Unix benefits as well (regexps). %cd
1311 1321 magic still doesn't support backslash path delimiters, though. Also
1312 1322 deleted all pretense of supporting multiline command strings in
1313 1323 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1314 1324
1315 1325 * doc/build_doc_instructions.txt added. Documentation on how to
1316 1326 use doc/update_manual.py, added yesterday. Both files contributed
1317 1327 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1318 1328 doc/*.sh for deprecation at a later date.
1319 1329
1320 1330 * /ipython.py Added ipython.py to root directory for
1321 1331 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1322 1332 ipython.py) and development convenience (no need to keep doing
1323 1333 "setup.py install" between changes).
1324 1334
1325 1335 * Made ! and !! shell escapes work (again) in multiline expressions:
1326 1336 if 1:
1327 1337 !ls
1328 1338 !!ls
1329 1339
1330 1340 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1331 1341
1332 1342 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1333 1343 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1334 1344 module in case-insensitive installation. Was causing crashes
1335 1345 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1336 1346
1337 1347 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1338 1348 <marienz-AT-gentoo.org>, closes
1339 1349 http://www.scipy.net/roundup/ipython/issue51.
1340 1350
1341 1351 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1342 1352
1343 1353 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1344 1354 problem of excessive CPU usage under *nix and keyboard lag under
1345 1355 win32.
1346 1356
1347 1357 2006-01-10 *** Released version 0.7.0
1348 1358
1349 1359 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1350 1360
1351 1361 * IPython/Release.py (revision): tag version number to 0.7.0,
1352 1362 ready for release.
1353 1363
1354 1364 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1355 1365 it informs the user of the name of the temp. file used. This can
1356 1366 help if you decide later to reuse that same file, so you know
1357 1367 where to copy the info from.
1358 1368
1359 1369 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1360 1370
1361 1371 * setup_bdist_egg.py: little script to build an egg. Added
1362 1372 support in the release tools as well.
1363 1373
1364 1374 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1365 1375
1366 1376 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1367 1377 version selection (new -wxversion command line and ipythonrc
1368 1378 parameter). Patch contributed by Arnd Baecker
1369 1379 <arnd.baecker-AT-web.de>.
1370 1380
1371 1381 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1372 1382 embedded instances, for variables defined at the interactive
1373 1383 prompt of the embedded ipython. Reported by Arnd.
1374 1384
1375 1385 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1376 1386 it can be used as a (stateful) toggle, or with a direct parameter.
1377 1387
1378 1388 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1379 1389 could be triggered in certain cases and cause the traceback
1380 1390 printer not to work.
1381 1391
1382 1392 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1383 1393
1384 1394 * IPython/iplib.py (_should_recompile): Small fix, closes
1385 1395 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1386 1396
1387 1397 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1388 1398
1389 1399 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1390 1400 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1391 1401 Moad for help with tracking it down.
1392 1402
1393 1403 * IPython/iplib.py (handle_auto): fix autocall handling for
1394 1404 objects which support BOTH __getitem__ and __call__ (so that f [x]
1395 1405 is left alone, instead of becoming f([x]) automatically).
1396 1406
1397 1407 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1398 1408 Ville's patch.
1399 1409
1400 1410 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1401 1411
1402 1412 * IPython/iplib.py (handle_auto): changed autocall semantics to
1403 1413 include 'smart' mode, where the autocall transformation is NOT
1404 1414 applied if there are no arguments on the line. This allows you to
1405 1415 just type 'foo' if foo is a callable to see its internal form,
1406 1416 instead of having it called with no arguments (typically a
1407 1417 mistake). The old 'full' autocall still exists: for that, you
1408 1418 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1409 1419
1410 1420 * IPython/completer.py (Completer.attr_matches): add
1411 1421 tab-completion support for Enthoughts' traits. After a report by
1412 1422 Arnd and a patch by Prabhu.
1413 1423
1414 1424 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1415 1425
1416 1426 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1417 1427 Schmolck's patch to fix inspect.getinnerframes().
1418 1428
1419 1429 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1420 1430 for embedded instances, regarding handling of namespaces and items
1421 1431 added to the __builtin__ one. Multiple embedded instances and
1422 1432 recursive embeddings should work better now (though I'm not sure
1423 1433 I've got all the corner cases fixed, that code is a bit of a brain
1424 1434 twister).
1425 1435
1426 1436 * IPython/Magic.py (magic_edit): added support to edit in-memory
1427 1437 macros (automatically creates the necessary temp files). %edit
1428 1438 also doesn't return the file contents anymore, it's just noise.
1429 1439
1430 1440 * IPython/completer.py (Completer.attr_matches): revert change to
1431 1441 complete only on attributes listed in __all__. I realized it
1432 1442 cripples the tab-completion system as a tool for exploring the
1433 1443 internals of unknown libraries (it renders any non-__all__
1434 1444 attribute off-limits). I got bit by this when trying to see
1435 1445 something inside the dis module.
1436 1446
1437 1447 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1438 1448
1439 1449 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1440 1450 namespace for users and extension writers to hold data in. This
1441 1451 follows the discussion in
1442 1452 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1443 1453
1444 1454 * IPython/completer.py (IPCompleter.complete): small patch to help
1445 1455 tab-completion under Emacs, after a suggestion by John Barnard
1446 1456 <barnarj-AT-ccf.org>.
1447 1457
1448 1458 * IPython/Magic.py (Magic.extract_input_slices): added support for
1449 1459 the slice notation in magics to use N-M to represent numbers N...M
1450 1460 (closed endpoints). This is used by %macro and %save.
1451 1461
1452 1462 * IPython/completer.py (Completer.attr_matches): for modules which
1453 1463 define __all__, complete only on those. After a patch by Jeffrey
1454 1464 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1455 1465 speed up this routine.
1456 1466
1457 1467 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1458 1468 don't know if this is the end of it, but the behavior now is
1459 1469 certainly much more correct. Note that coupled with macros,
1460 1470 slightly surprising (at first) behavior may occur: a macro will in
1461 1471 general expand to multiple lines of input, so upon exiting, the
1462 1472 in/out counters will both be bumped by the corresponding amount
1463 1473 (as if the macro's contents had been typed interactively). Typing
1464 1474 %hist will reveal the intermediate (silently processed) lines.
1465 1475
1466 1476 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1467 1477 pickle to fail (%run was overwriting __main__ and not restoring
1468 1478 it, but pickle relies on __main__ to operate).
1469 1479
1470 1480 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1471 1481 using properties, but forgot to make the main InteractiveShell
1472 1482 class a new-style class. Properties fail silently, and
1473 1483 mysteriously, with old-style class (getters work, but
1474 1484 setters don't do anything).
1475 1485
1476 1486 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1477 1487
1478 1488 * IPython/Magic.py (magic_history): fix history reporting bug (I
1479 1489 know some nasties are still there, I just can't seem to find a
1480 1490 reproducible test case to track them down; the input history is
1481 1491 falling out of sync...)
1482 1492
1483 1493 * IPython/iplib.py (handle_shell_escape): fix bug where both
1484 1494 aliases and system accesses where broken for indented code (such
1485 1495 as loops).
1486 1496
1487 1497 * IPython/genutils.py (shell): fix small but critical bug for
1488 1498 win32 system access.
1489 1499
1490 1500 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1491 1501
1492 1502 * IPython/iplib.py (showtraceback): remove use of the
1493 1503 sys.last_{type/value/traceback} structures, which are non
1494 1504 thread-safe.
1495 1505 (_prefilter): change control flow to ensure that we NEVER
1496 1506 introspect objects when autocall is off. This will guarantee that
1497 1507 having an input line of the form 'x.y', where access to attribute
1498 1508 'y' has side effects, doesn't trigger the side effect TWICE. It
1499 1509 is important to note that, with autocall on, these side effects
1500 1510 can still happen.
1501 1511 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1502 1512 trio. IPython offers these three kinds of special calls which are
1503 1513 not python code, and it's a good thing to have their call method
1504 1514 be accessible as pure python functions (not just special syntax at
1505 1515 the command line). It gives us a better internal implementation
1506 1516 structure, as well as exposing these for user scripting more
1507 1517 cleanly.
1508 1518
1509 1519 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1510 1520 file. Now that they'll be more likely to be used with the
1511 1521 persistance system (%store), I want to make sure their module path
1512 1522 doesn't change in the future, so that we don't break things for
1513 1523 users' persisted data.
1514 1524
1515 1525 * IPython/iplib.py (autoindent_update): move indentation
1516 1526 management into the _text_ processing loop, not the keyboard
1517 1527 interactive one. This is necessary to correctly process non-typed
1518 1528 multiline input (such as macros).
1519 1529
1520 1530 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1521 1531 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1522 1532 which was producing problems in the resulting manual.
1523 1533 (magic_whos): improve reporting of instances (show their class,
1524 1534 instead of simply printing 'instance' which isn't terribly
1525 1535 informative).
1526 1536
1527 1537 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1528 1538 (minor mods) to support network shares under win32.
1529 1539
1530 1540 * IPython/winconsole.py (get_console_size): add new winconsole
1531 1541 module and fixes to page_dumb() to improve its behavior under
1532 1542 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1533 1543
1534 1544 * IPython/Magic.py (Macro): simplified Macro class to just
1535 1545 subclass list. We've had only 2.2 compatibility for a very long
1536 1546 time, yet I was still avoiding subclassing the builtin types. No
1537 1547 more (I'm also starting to use properties, though I won't shift to
1538 1548 2.3-specific features quite yet).
1539 1549 (magic_store): added Ville's patch for lightweight variable
1540 1550 persistence, after a request on the user list by Matt Wilkie
1541 1551 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1542 1552 details.
1543 1553
1544 1554 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1545 1555 changed the default logfile name from 'ipython.log' to
1546 1556 'ipython_log.py'. These logs are real python files, and now that
1547 1557 we have much better multiline support, people are more likely to
1548 1558 want to use them as such. Might as well name them correctly.
1549 1559
1550 1560 * IPython/Magic.py: substantial cleanup. While we can't stop
1551 1561 using magics as mixins, due to the existing customizations 'out
1552 1562 there' which rely on the mixin naming conventions, at least I
1553 1563 cleaned out all cross-class name usage. So once we are OK with
1554 1564 breaking compatibility, the two systems can be separated.
1555 1565
1556 1566 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1557 1567 anymore, and the class is a fair bit less hideous as well. New
1558 1568 features were also introduced: timestamping of input, and logging
1559 1569 of output results. These are user-visible with the -t and -o
1560 1570 options to %logstart. Closes
1561 1571 http://www.scipy.net/roundup/ipython/issue11 and a request by
1562 1572 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1563 1573
1564 1574 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1565 1575
1566 1576 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1567 1577 better handle backslashes in paths. See the thread 'More Windows
1568 1578 questions part 2 - \/ characters revisited' on the iypthon user
1569 1579 list:
1570 1580 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1571 1581
1572 1582 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1573 1583
1574 1584 (InteractiveShell.__init__): change threaded shells to not use the
1575 1585 ipython crash handler. This was causing more problems than not,
1576 1586 as exceptions in the main thread (GUI code, typically) would
1577 1587 always show up as a 'crash', when they really weren't.
1578 1588
1579 1589 The colors and exception mode commands (%colors/%xmode) have been
1580 1590 synchronized to also take this into account, so users can get
1581 1591 verbose exceptions for their threaded code as well. I also added
1582 1592 support for activating pdb inside this exception handler as well,
1583 1593 so now GUI authors can use IPython's enhanced pdb at runtime.
1584 1594
1585 1595 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1586 1596 true by default, and add it to the shipped ipythonrc file. Since
1587 1597 this asks the user before proceeding, I think it's OK to make it
1588 1598 true by default.
1589 1599
1590 1600 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1591 1601 of the previous special-casing of input in the eval loop. I think
1592 1602 this is cleaner, as they really are commands and shouldn't have
1593 1603 a special role in the middle of the core code.
1594 1604
1595 1605 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1596 1606
1597 1607 * IPython/iplib.py (edit_syntax_error): added support for
1598 1608 automatically reopening the editor if the file had a syntax error
1599 1609 in it. Thanks to scottt who provided the patch at:
1600 1610 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1601 1611 version committed).
1602 1612
1603 1613 * IPython/iplib.py (handle_normal): add suport for multi-line
1604 1614 input with emtpy lines. This fixes
1605 1615 http://www.scipy.net/roundup/ipython/issue43 and a similar
1606 1616 discussion on the user list.
1607 1617
1608 1618 WARNING: a behavior change is necessarily introduced to support
1609 1619 blank lines: now a single blank line with whitespace does NOT
1610 1620 break the input loop, which means that when autoindent is on, by
1611 1621 default hitting return on the next (indented) line does NOT exit.
1612 1622
1613 1623 Instead, to exit a multiline input you can either have:
1614 1624
1615 1625 - TWO whitespace lines (just hit return again), or
1616 1626 - a single whitespace line of a different length than provided
1617 1627 by the autoindent (add or remove a space).
1618 1628
1619 1629 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1620 1630 module to better organize all readline-related functionality.
1621 1631 I've deleted FlexCompleter and put all completion clases here.
1622 1632
1623 1633 * IPython/iplib.py (raw_input): improve indentation management.
1624 1634 It is now possible to paste indented code with autoindent on, and
1625 1635 the code is interpreted correctly (though it still looks bad on
1626 1636 screen, due to the line-oriented nature of ipython).
1627 1637 (MagicCompleter.complete): change behavior so that a TAB key on an
1628 1638 otherwise empty line actually inserts a tab, instead of completing
1629 1639 on the entire global namespace. This makes it easier to use the
1630 1640 TAB key for indentation. After a request by Hans Meine
1631 1641 <hans_meine-AT-gmx.net>
1632 1642 (_prefilter): add support so that typing plain 'exit' or 'quit'
1633 1643 does a sensible thing. Originally I tried to deviate as little as
1634 1644 possible from the default python behavior, but even that one may
1635 1645 change in this direction (thread on python-dev to that effect).
1636 1646 Regardless, ipython should do the right thing even if CPython's
1637 1647 '>>>' prompt doesn't.
1638 1648 (InteractiveShell): removed subclassing code.InteractiveConsole
1639 1649 class. By now we'd overridden just about all of its methods: I've
1640 1650 copied the remaining two over, and now ipython is a standalone
1641 1651 class. This will provide a clearer picture for the chainsaw
1642 1652 branch refactoring.
1643 1653
1644 1654 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1645 1655
1646 1656 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1647 1657 failures for objects which break when dir() is called on them.
1648 1658
1649 1659 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1650 1660 distinct local and global namespaces in the completer API. This
1651 1661 change allows us to properly handle completion with distinct
1652 1662 scopes, including in embedded instances (this had never really
1653 1663 worked correctly).
1654 1664
1655 1665 Note: this introduces a change in the constructor for
1656 1666 MagicCompleter, as a new global_namespace parameter is now the
1657 1667 second argument (the others were bumped one position).
1658 1668
1659 1669 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1660 1670
1661 1671 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1662 1672 embedded instances (which can be done now thanks to Vivian's
1663 1673 frame-handling fixes for pdb).
1664 1674 (InteractiveShell.__init__): Fix namespace handling problem in
1665 1675 embedded instances. We were overwriting __main__ unconditionally,
1666 1676 and this should only be done for 'full' (non-embedded) IPython;
1667 1677 embedded instances must respect the caller's __main__. Thanks to
1668 1678 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1669 1679
1670 1680 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1671 1681
1672 1682 * setup.py: added download_url to setup(). This registers the
1673 1683 download address at PyPI, which is not only useful to humans
1674 1684 browsing the site, but is also picked up by setuptools (the Eggs
1675 1685 machinery). Thanks to Ville and R. Kern for the info/discussion
1676 1686 on this.
1677 1687
1678 1688 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1679 1689
1680 1690 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1681 1691 This brings a lot of nice functionality to the pdb mode, which now
1682 1692 has tab-completion, syntax highlighting, and better stack handling
1683 1693 than before. Many thanks to Vivian De Smedt
1684 1694 <vivian-AT-vdesmedt.com> for the original patches.
1685 1695
1686 1696 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1687 1697
1688 1698 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1689 1699 sequence to consistently accept the banner argument. The
1690 1700 inconsistency was tripping SAGE, thanks to Gary Zablackis
1691 1701 <gzabl-AT-yahoo.com> for the report.
1692 1702
1693 1703 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1694 1704
1695 1705 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1696 1706 Fix bug where a naked 'alias' call in the ipythonrc file would
1697 1707 cause a crash. Bug reported by Jorgen Stenarson.
1698 1708
1699 1709 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1700 1710
1701 1711 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1702 1712 startup time.
1703 1713
1704 1714 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1705 1715 instances had introduced a bug with globals in normal code. Now
1706 1716 it's working in all cases.
1707 1717
1708 1718 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1709 1719 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1710 1720 has been introduced to set the default case sensitivity of the
1711 1721 searches. Users can still select either mode at runtime on a
1712 1722 per-search basis.
1713 1723
1714 1724 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1715 1725
1716 1726 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1717 1727 attributes in wildcard searches for subclasses. Modified version
1718 1728 of a patch by Jorgen.
1719 1729
1720 1730 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1721 1731
1722 1732 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1723 1733 embedded instances. I added a user_global_ns attribute to the
1724 1734 InteractiveShell class to handle this.
1725 1735
1726 1736 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1727 1737
1728 1738 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1729 1739 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1730 1740 (reported under win32, but may happen also in other platforms).
1731 1741 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1732 1742
1733 1743 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1734 1744
1735 1745 * IPython/Magic.py (magic_psearch): new support for wildcard
1736 1746 patterns. Now, typing ?a*b will list all names which begin with a
1737 1747 and end in b, for example. The %psearch magic has full
1738 1748 docstrings. Many thanks to JΓΆrgen Stenarson
1739 1749 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1740 1750 implementing this functionality.
1741 1751
1742 1752 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1743 1753
1744 1754 * Manual: fixed long-standing annoyance of double-dashes (as in
1745 1755 --prefix=~, for example) being stripped in the HTML version. This
1746 1756 is a latex2html bug, but a workaround was provided. Many thanks
1747 1757 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1748 1758 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1749 1759 rolling. This seemingly small issue had tripped a number of users
1750 1760 when first installing, so I'm glad to see it gone.
1751 1761
1752 1762 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1753 1763
1754 1764 * IPython/Extensions/numeric_formats.py: fix missing import,
1755 1765 reported by Stephen Walton.
1756 1766
1757 1767 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1758 1768
1759 1769 * IPython/demo.py: finish demo module, fully documented now.
1760 1770
1761 1771 * IPython/genutils.py (file_read): simple little utility to read a
1762 1772 file and ensure it's closed afterwards.
1763 1773
1764 1774 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1765 1775
1766 1776 * IPython/demo.py (Demo.__init__): added support for individually
1767 1777 tagging blocks for automatic execution.
1768 1778
1769 1779 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1770 1780 syntax-highlighted python sources, requested by John.
1771 1781
1772 1782 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1773 1783
1774 1784 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1775 1785 finishing.
1776 1786
1777 1787 * IPython/genutils.py (shlex_split): moved from Magic to here,
1778 1788 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1779 1789
1780 1790 * IPython/demo.py (Demo.__init__): added support for silent
1781 1791 blocks, improved marks as regexps, docstrings written.
1782 1792 (Demo.__init__): better docstring, added support for sys.argv.
1783 1793
1784 1794 * IPython/genutils.py (marquee): little utility used by the demo
1785 1795 code, handy in general.
1786 1796
1787 1797 * IPython/demo.py (Demo.__init__): new class for interactive
1788 1798 demos. Not documented yet, I just wrote it in a hurry for
1789 1799 scipy'05. Will docstring later.
1790 1800
1791 1801 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1792 1802
1793 1803 * IPython/Shell.py (sigint_handler): Drastic simplification which
1794 1804 also seems to make Ctrl-C work correctly across threads! This is
1795 1805 so simple, that I can't beleive I'd missed it before. Needs more
1796 1806 testing, though.
1797 1807 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1798 1808 like this before...
1799 1809
1800 1810 * IPython/genutils.py (get_home_dir): add protection against
1801 1811 non-dirs in win32 registry.
1802 1812
1803 1813 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1804 1814 bug where dict was mutated while iterating (pysh crash).
1805 1815
1806 1816 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1807 1817
1808 1818 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1809 1819 spurious newlines added by this routine. After a report by
1810 1820 F. Mantegazza.
1811 1821
1812 1822 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1813 1823
1814 1824 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1815 1825 calls. These were a leftover from the GTK 1.x days, and can cause
1816 1826 problems in certain cases (after a report by John Hunter).
1817 1827
1818 1828 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1819 1829 os.getcwd() fails at init time. Thanks to patch from David Remahl
1820 1830 <chmod007-AT-mac.com>.
1821 1831 (InteractiveShell.__init__): prevent certain special magics from
1822 1832 being shadowed by aliases. Closes
1823 1833 http://www.scipy.net/roundup/ipython/issue41.
1824 1834
1825 1835 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1826 1836
1827 1837 * IPython/iplib.py (InteractiveShell.complete): Added new
1828 1838 top-level completion method to expose the completion mechanism
1829 1839 beyond readline-based environments.
1830 1840
1831 1841 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1832 1842
1833 1843 * tools/ipsvnc (svnversion): fix svnversion capture.
1834 1844
1835 1845 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1836 1846 attribute to self, which was missing. Before, it was set by a
1837 1847 routine which in certain cases wasn't being called, so the
1838 1848 instance could end up missing the attribute. This caused a crash.
1839 1849 Closes http://www.scipy.net/roundup/ipython/issue40.
1840 1850
1841 1851 2005-08-16 Fernando Perez <fperez@colorado.edu>
1842 1852
1843 1853 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1844 1854 contains non-string attribute. Closes
1845 1855 http://www.scipy.net/roundup/ipython/issue38.
1846 1856
1847 1857 2005-08-14 Fernando Perez <fperez@colorado.edu>
1848 1858
1849 1859 * tools/ipsvnc: Minor improvements, to add changeset info.
1850 1860
1851 1861 2005-08-12 Fernando Perez <fperez@colorado.edu>
1852 1862
1853 1863 * IPython/iplib.py (runsource): remove self.code_to_run_src
1854 1864 attribute. I realized this is nothing more than
1855 1865 '\n'.join(self.buffer), and having the same data in two different
1856 1866 places is just asking for synchronization bugs. This may impact
1857 1867 people who have custom exception handlers, so I need to warn
1858 1868 ipython-dev about it (F. Mantegazza may use them).
1859 1869
1860 1870 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1861 1871
1862 1872 * IPython/genutils.py: fix 2.2 compatibility (generators)
1863 1873
1864 1874 2005-07-18 Fernando Perez <fperez@colorado.edu>
1865 1875
1866 1876 * IPython/genutils.py (get_home_dir): fix to help users with
1867 1877 invalid $HOME under win32.
1868 1878
1869 1879 2005-07-17 Fernando Perez <fperez@colorado.edu>
1870 1880
1871 1881 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1872 1882 some old hacks and clean up a bit other routines; code should be
1873 1883 simpler and a bit faster.
1874 1884
1875 1885 * IPython/iplib.py (interact): removed some last-resort attempts
1876 1886 to survive broken stdout/stderr. That code was only making it
1877 1887 harder to abstract out the i/o (necessary for gui integration),
1878 1888 and the crashes it could prevent were extremely rare in practice
1879 1889 (besides being fully user-induced in a pretty violent manner).
1880 1890
1881 1891 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1882 1892 Nothing major yet, but the code is simpler to read; this should
1883 1893 make it easier to do more serious modifications in the future.
1884 1894
1885 1895 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1886 1896 which broke in .15 (thanks to a report by Ville).
1887 1897
1888 1898 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1889 1899 be quite correct, I know next to nothing about unicode). This
1890 1900 will allow unicode strings to be used in prompts, amongst other
1891 1901 cases. It also will prevent ipython from crashing when unicode
1892 1902 shows up unexpectedly in many places. If ascii encoding fails, we
1893 1903 assume utf_8. Currently the encoding is not a user-visible
1894 1904 setting, though it could be made so if there is demand for it.
1895 1905
1896 1906 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1897 1907
1898 1908 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1899 1909
1900 1910 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1901 1911
1902 1912 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1903 1913 code can work transparently for 2.2/2.3.
1904 1914
1905 1915 2005-07-16 Fernando Perez <fperez@colorado.edu>
1906 1916
1907 1917 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1908 1918 out of the color scheme table used for coloring exception
1909 1919 tracebacks. This allows user code to add new schemes at runtime.
1910 1920 This is a minimally modified version of the patch at
1911 1921 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1912 1922 for the contribution.
1913 1923
1914 1924 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1915 1925 slightly modified version of the patch in
1916 1926 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1917 1927 to remove the previous try/except solution (which was costlier).
1918 1928 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1919 1929
1920 1930 2005-06-08 Fernando Perez <fperez@colorado.edu>
1921 1931
1922 1932 * IPython/iplib.py (write/write_err): Add methods to abstract all
1923 1933 I/O a bit more.
1924 1934
1925 1935 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1926 1936 warning, reported by Aric Hagberg, fix by JD Hunter.
1927 1937
1928 1938 2005-06-02 *** Released version 0.6.15
1929 1939
1930 1940 2005-06-01 Fernando Perez <fperez@colorado.edu>
1931 1941
1932 1942 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1933 1943 tab-completion of filenames within open-quoted strings. Note that
1934 1944 this requires that in ~/.ipython/ipythonrc, users change the
1935 1945 readline delimiters configuration to read:
1936 1946
1937 1947 readline_remove_delims -/~
1938 1948
1939 1949
1940 1950 2005-05-31 *** Released version 0.6.14
1941 1951
1942 1952 2005-05-29 Fernando Perez <fperez@colorado.edu>
1943 1953
1944 1954 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1945 1955 with files not on the filesystem. Reported by Eliyahu Sandler
1946 1956 <eli@gondolin.net>
1947 1957
1948 1958 2005-05-22 Fernando Perez <fperez@colorado.edu>
1949 1959
1950 1960 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1951 1961 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1952 1962
1953 1963 2005-05-19 Fernando Perez <fperez@colorado.edu>
1954 1964
1955 1965 * IPython/iplib.py (safe_execfile): close a file which could be
1956 1966 left open (causing problems in win32, which locks open files).
1957 1967 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1958 1968
1959 1969 2005-05-18 Fernando Perez <fperez@colorado.edu>
1960 1970
1961 1971 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1962 1972 keyword arguments correctly to safe_execfile().
1963 1973
1964 1974 2005-05-13 Fernando Perez <fperez@colorado.edu>
1965 1975
1966 1976 * ipython.1: Added info about Qt to manpage, and threads warning
1967 1977 to usage page (invoked with --help).
1968 1978
1969 1979 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1970 1980 new matcher (it goes at the end of the priority list) to do
1971 1981 tab-completion on named function arguments. Submitted by George
1972 1982 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1973 1983 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1974 1984 for more details.
1975 1985
1976 1986 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1977 1987 SystemExit exceptions in the script being run. Thanks to a report
1978 1988 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1979 1989 producing very annoying behavior when running unit tests.
1980 1990
1981 1991 2005-05-12 Fernando Perez <fperez@colorado.edu>
1982 1992
1983 1993 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1984 1994 which I'd broken (again) due to a changed regexp. In the process,
1985 1995 added ';' as an escape to auto-quote the whole line without
1986 1996 splitting its arguments. Thanks to a report by Jerry McRae
1987 1997 <qrs0xyc02-AT-sneakemail.com>.
1988 1998
1989 1999 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1990 2000 possible crashes caused by a TokenError. Reported by Ed Schofield
1991 2001 <schofield-AT-ftw.at>.
1992 2002
1993 2003 2005-05-06 Fernando Perez <fperez@colorado.edu>
1994 2004
1995 2005 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1996 2006
1997 2007 2005-04-29 Fernando Perez <fperez@colorado.edu>
1998 2008
1999 2009 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2000 2010 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2001 2011 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2002 2012 which provides support for Qt interactive usage (similar to the
2003 2013 existing one for WX and GTK). This had been often requested.
2004 2014
2005 2015 2005-04-14 *** Released version 0.6.13
2006 2016
2007 2017 2005-04-08 Fernando Perez <fperez@colorado.edu>
2008 2018
2009 2019 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2010 2020 from _ofind, which gets called on almost every input line. Now,
2011 2021 we only try to get docstrings if they are actually going to be
2012 2022 used (the overhead of fetching unnecessary docstrings can be
2013 2023 noticeable for certain objects, such as Pyro proxies).
2014 2024
2015 2025 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2016 2026 for completers. For some reason I had been passing them the state
2017 2027 variable, which completers never actually need, and was in
2018 2028 conflict with the rlcompleter API. Custom completers ONLY need to
2019 2029 take the text parameter.
2020 2030
2021 2031 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2022 2032 work correctly in pysh. I've also moved all the logic which used
2023 2033 to be in pysh.py here, which will prevent problems with future
2024 2034 upgrades. However, this time I must warn users to update their
2025 2035 pysh profile to include the line
2026 2036
2027 2037 import_all IPython.Extensions.InterpreterExec
2028 2038
2029 2039 because otherwise things won't work for them. They MUST also
2030 2040 delete pysh.py and the line
2031 2041
2032 2042 execfile pysh.py
2033 2043
2034 2044 from their ipythonrc-pysh.
2035 2045
2036 2046 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2037 2047 robust in the face of objects whose dir() returns non-strings
2038 2048 (which it shouldn't, but some broken libs like ITK do). Thanks to
2039 2049 a patch by John Hunter (implemented differently, though). Also
2040 2050 minor improvements by using .extend instead of + on lists.
2041 2051
2042 2052 * pysh.py:
2043 2053
2044 2054 2005-04-06 Fernando Perez <fperez@colorado.edu>
2045 2055
2046 2056 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2047 2057 by default, so that all users benefit from it. Those who don't
2048 2058 want it can still turn it off.
2049 2059
2050 2060 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2051 2061 config file, I'd forgotten about this, so users were getting it
2052 2062 off by default.
2053 2063
2054 2064 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2055 2065 consistency. Now magics can be called in multiline statements,
2056 2066 and python variables can be expanded in magic calls via $var.
2057 2067 This makes the magic system behave just like aliases or !system
2058 2068 calls.
2059 2069
2060 2070 2005-03-28 Fernando Perez <fperez@colorado.edu>
2061 2071
2062 2072 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2063 2073 expensive string additions for building command. Add support for
2064 2074 trailing ';' when autocall is used.
2065 2075
2066 2076 2005-03-26 Fernando Perez <fperez@colorado.edu>
2067 2077
2068 2078 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2069 2079 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2070 2080 ipython.el robust against prompts with any number of spaces
2071 2081 (including 0) after the ':' character.
2072 2082
2073 2083 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2074 2084 continuation prompt, which misled users to think the line was
2075 2085 already indented. Closes debian Bug#300847, reported to me by
2076 2086 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2077 2087
2078 2088 2005-03-23 Fernando Perez <fperez@colorado.edu>
2079 2089
2080 2090 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2081 2091 properly aligned if they have embedded newlines.
2082 2092
2083 2093 * IPython/iplib.py (runlines): Add a public method to expose
2084 2094 IPython's code execution machinery, so that users can run strings
2085 2095 as if they had been typed at the prompt interactively.
2086 2096 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2087 2097 methods which can call the system shell, but with python variable
2088 2098 expansion. The three such methods are: __IPYTHON__.system,
2089 2099 .getoutput and .getoutputerror. These need to be documented in a
2090 2100 'public API' section (to be written) of the manual.
2091 2101
2092 2102 2005-03-20 Fernando Perez <fperez@colorado.edu>
2093 2103
2094 2104 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2095 2105 for custom exception handling. This is quite powerful, and it
2096 2106 allows for user-installable exception handlers which can trap
2097 2107 custom exceptions at runtime and treat them separately from
2098 2108 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2099 2109 Mantegazza <mantegazza-AT-ill.fr>.
2100 2110 (InteractiveShell.set_custom_completer): public API function to
2101 2111 add new completers at runtime.
2102 2112
2103 2113 2005-03-19 Fernando Perez <fperez@colorado.edu>
2104 2114
2105 2115 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2106 2116 allow objects which provide their docstrings via non-standard
2107 2117 mechanisms (like Pyro proxies) to still be inspected by ipython's
2108 2118 ? system.
2109 2119
2110 2120 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2111 2121 automatic capture system. I tried quite hard to make it work
2112 2122 reliably, and simply failed. I tried many combinations with the
2113 2123 subprocess module, but eventually nothing worked in all needed
2114 2124 cases (not blocking stdin for the child, duplicating stdout
2115 2125 without blocking, etc). The new %sc/%sx still do capture to these
2116 2126 magical list/string objects which make shell use much more
2117 2127 conveninent, so not all is lost.
2118 2128
2119 2129 XXX - FIX MANUAL for the change above!
2120 2130
2121 2131 (runsource): I copied code.py's runsource() into ipython to modify
2122 2132 it a bit. Now the code object and source to be executed are
2123 2133 stored in ipython. This makes this info accessible to third-party
2124 2134 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2125 2135 Mantegazza <mantegazza-AT-ill.fr>.
2126 2136
2127 2137 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2128 2138 history-search via readline (like C-p/C-n). I'd wanted this for a
2129 2139 long time, but only recently found out how to do it. For users
2130 2140 who already have their ipythonrc files made and want this, just
2131 2141 add:
2132 2142
2133 2143 readline_parse_and_bind "\e[A": history-search-backward
2134 2144 readline_parse_and_bind "\e[B": history-search-forward
2135 2145
2136 2146 2005-03-18 Fernando Perez <fperez@colorado.edu>
2137 2147
2138 2148 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2139 2149 LSString and SList classes which allow transparent conversions
2140 2150 between list mode and whitespace-separated string.
2141 2151 (magic_r): Fix recursion problem in %r.
2142 2152
2143 2153 * IPython/genutils.py (LSString): New class to be used for
2144 2154 automatic storage of the results of all alias/system calls in _o
2145 2155 and _e (stdout/err). These provide a .l/.list attribute which
2146 2156 does automatic splitting on newlines. This means that for most
2147 2157 uses, you'll never need to do capturing of output with %sc/%sx
2148 2158 anymore, since ipython keeps this always done for you. Note that
2149 2159 only the LAST results are stored, the _o/e variables are
2150 2160 overwritten on each call. If you need to save their contents
2151 2161 further, simply bind them to any other name.
2152 2162
2153 2163 2005-03-17 Fernando Perez <fperez@colorado.edu>
2154 2164
2155 2165 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2156 2166 prompt namespace handling.
2157 2167
2158 2168 2005-03-16 Fernando Perez <fperez@colorado.edu>
2159 2169
2160 2170 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2161 2171 classic prompts to be '>>> ' (final space was missing, and it
2162 2172 trips the emacs python mode).
2163 2173 (BasePrompt.__str__): Added safe support for dynamic prompt
2164 2174 strings. Now you can set your prompt string to be '$x', and the
2165 2175 value of x will be printed from your interactive namespace. The
2166 2176 interpolation syntax includes the full Itpl support, so
2167 2177 ${foo()+x+bar()} is a valid prompt string now, and the function
2168 2178 calls will be made at runtime.
2169 2179
2170 2180 2005-03-15 Fernando Perez <fperez@colorado.edu>
2171 2181
2172 2182 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2173 2183 avoid name clashes in pylab. %hist still works, it just forwards
2174 2184 the call to %history.
2175 2185
2176 2186 2005-03-02 *** Released version 0.6.12
2177 2187
2178 2188 2005-03-02 Fernando Perez <fperez@colorado.edu>
2179 2189
2180 2190 * IPython/iplib.py (handle_magic): log magic calls properly as
2181 2191 ipmagic() function calls.
2182 2192
2183 2193 * IPython/Magic.py (magic_time): Improved %time to support
2184 2194 statements and provide wall-clock as well as CPU time.
2185 2195
2186 2196 2005-02-27 Fernando Perez <fperez@colorado.edu>
2187 2197
2188 2198 * IPython/hooks.py: New hooks module, to expose user-modifiable
2189 2199 IPython functionality in a clean manner. For now only the editor
2190 2200 hook is actually written, and other thigns which I intend to turn
2191 2201 into proper hooks aren't yet there. The display and prefilter
2192 2202 stuff, for example, should be hooks. But at least now the
2193 2203 framework is in place, and the rest can be moved here with more
2194 2204 time later. IPython had had a .hooks variable for a long time for
2195 2205 this purpose, but I'd never actually used it for anything.
2196 2206
2197 2207 2005-02-26 Fernando Perez <fperez@colorado.edu>
2198 2208
2199 2209 * IPython/ipmaker.py (make_IPython): make the default ipython
2200 2210 directory be called _ipython under win32, to follow more the
2201 2211 naming peculiarities of that platform (where buggy software like
2202 2212 Visual Sourcesafe breaks with .named directories). Reported by
2203 2213 Ville Vainio.
2204 2214
2205 2215 2005-02-23 Fernando Perez <fperez@colorado.edu>
2206 2216
2207 2217 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2208 2218 auto_aliases for win32 which were causing problems. Users can
2209 2219 define the ones they personally like.
2210 2220
2211 2221 2005-02-21 Fernando Perez <fperez@colorado.edu>
2212 2222
2213 2223 * IPython/Magic.py (magic_time): new magic to time execution of
2214 2224 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2215 2225
2216 2226 2005-02-19 Fernando Perez <fperez@colorado.edu>
2217 2227
2218 2228 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2219 2229 into keys (for prompts, for example).
2220 2230
2221 2231 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2222 2232 prompts in case users want them. This introduces a small behavior
2223 2233 change: ipython does not automatically add a space to all prompts
2224 2234 anymore. To get the old prompts with a space, users should add it
2225 2235 manually to their ipythonrc file, so for example prompt_in1 should
2226 2236 now read 'In [\#]: ' instead of 'In [\#]:'.
2227 2237 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2228 2238 file) to control left-padding of secondary prompts.
2229 2239
2230 2240 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2231 2241 the profiler can't be imported. Fix for Debian, which removed
2232 2242 profile.py because of License issues. I applied a slightly
2233 2243 modified version of the original Debian patch at
2234 2244 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2235 2245
2236 2246 2005-02-17 Fernando Perez <fperez@colorado.edu>
2237 2247
2238 2248 * IPython/genutils.py (native_line_ends): Fix bug which would
2239 2249 cause improper line-ends under win32 b/c I was not opening files
2240 2250 in binary mode. Bug report and fix thanks to Ville.
2241 2251
2242 2252 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2243 2253 trying to catch spurious foo[1] autocalls. My fix actually broke
2244 2254 ',/' autoquote/call with explicit escape (bad regexp).
2245 2255
2246 2256 2005-02-15 *** Released version 0.6.11
2247 2257
2248 2258 2005-02-14 Fernando Perez <fperez@colorado.edu>
2249 2259
2250 2260 * IPython/background_jobs.py: New background job management
2251 2261 subsystem. This is implemented via a new set of classes, and
2252 2262 IPython now provides a builtin 'jobs' object for background job
2253 2263 execution. A convenience %bg magic serves as a lightweight
2254 2264 frontend for starting the more common type of calls. This was
2255 2265 inspired by discussions with B. Granger and the BackgroundCommand
2256 2266 class described in the book Python Scripting for Computational
2257 2267 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2258 2268 (although ultimately no code from this text was used, as IPython's
2259 2269 system is a separate implementation).
2260 2270
2261 2271 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2262 2272 to control the completion of single/double underscore names
2263 2273 separately. As documented in the example ipytonrc file, the
2264 2274 readline_omit__names variable can now be set to 2, to omit even
2265 2275 single underscore names. Thanks to a patch by Brian Wong
2266 2276 <BrianWong-AT-AirgoNetworks.Com>.
2267 2277 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2268 2278 be autocalled as foo([1]) if foo were callable. A problem for
2269 2279 things which are both callable and implement __getitem__.
2270 2280 (init_readline): Fix autoindentation for win32. Thanks to a patch
2271 2281 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2272 2282
2273 2283 2005-02-12 Fernando Perez <fperez@colorado.edu>
2274 2284
2275 2285 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2276 2286 which I had written long ago to sort out user error messages which
2277 2287 may occur during startup. This seemed like a good idea initially,
2278 2288 but it has proven a disaster in retrospect. I don't want to
2279 2289 change much code for now, so my fix is to set the internal 'debug'
2280 2290 flag to true everywhere, whose only job was precisely to control
2281 2291 this subsystem. This closes issue 28 (as well as avoiding all
2282 2292 sorts of strange hangups which occur from time to time).
2283 2293
2284 2294 2005-02-07 Fernando Perez <fperez@colorado.edu>
2285 2295
2286 2296 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2287 2297 previous call produced a syntax error.
2288 2298
2289 2299 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2290 2300 classes without constructor.
2291 2301
2292 2302 2005-02-06 Fernando Perez <fperez@colorado.edu>
2293 2303
2294 2304 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2295 2305 completions with the results of each matcher, so we return results
2296 2306 to the user from all namespaces. This breaks with ipython
2297 2307 tradition, but I think it's a nicer behavior. Now you get all
2298 2308 possible completions listed, from all possible namespaces (python,
2299 2309 filesystem, magics...) After a request by John Hunter
2300 2310 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2301 2311
2302 2312 2005-02-05 Fernando Perez <fperez@colorado.edu>
2303 2313
2304 2314 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2305 2315 the call had quote characters in it (the quotes were stripped).
2306 2316
2307 2317 2005-01-31 Fernando Perez <fperez@colorado.edu>
2308 2318
2309 2319 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2310 2320 Itpl.itpl() to make the code more robust against psyco
2311 2321 optimizations.
2312 2322
2313 2323 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2314 2324 of causing an exception. Quicker, cleaner.
2315 2325
2316 2326 2005-01-28 Fernando Perez <fperez@colorado.edu>
2317 2327
2318 2328 * scripts/ipython_win_post_install.py (install): hardcode
2319 2329 sys.prefix+'python.exe' as the executable path. It turns out that
2320 2330 during the post-installation run, sys.executable resolves to the
2321 2331 name of the binary installer! I should report this as a distutils
2322 2332 bug, I think. I updated the .10 release with this tiny fix, to
2323 2333 avoid annoying the lists further.
2324 2334
2325 2335 2005-01-27 *** Released version 0.6.10
2326 2336
2327 2337 2005-01-27 Fernando Perez <fperez@colorado.edu>
2328 2338
2329 2339 * IPython/numutils.py (norm): Added 'inf' as optional name for
2330 2340 L-infinity norm, included references to mathworld.com for vector
2331 2341 norm definitions.
2332 2342 (amin/amax): added amin/amax for array min/max. Similar to what
2333 2343 pylab ships with after the recent reorganization of names.
2334 2344 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2335 2345
2336 2346 * ipython.el: committed Alex's recent fixes and improvements.
2337 2347 Tested with python-mode from CVS, and it looks excellent. Since
2338 2348 python-mode hasn't released anything in a while, I'm temporarily
2339 2349 putting a copy of today's CVS (v 4.70) of python-mode in:
2340 2350 http://ipython.scipy.org/tmp/python-mode.el
2341 2351
2342 2352 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2343 2353 sys.executable for the executable name, instead of assuming it's
2344 2354 called 'python.exe' (the post-installer would have produced broken
2345 2355 setups on systems with a differently named python binary).
2346 2356
2347 2357 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2348 2358 references to os.linesep, to make the code more
2349 2359 platform-independent. This is also part of the win32 coloring
2350 2360 fixes.
2351 2361
2352 2362 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2353 2363 lines, which actually cause coloring bugs because the length of
2354 2364 the line is very difficult to correctly compute with embedded
2355 2365 escapes. This was the source of all the coloring problems under
2356 2366 Win32. I think that _finally_, Win32 users have a properly
2357 2367 working ipython in all respects. This would never have happened
2358 2368 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2359 2369
2360 2370 2005-01-26 *** Released version 0.6.9
2361 2371
2362 2372 2005-01-25 Fernando Perez <fperez@colorado.edu>
2363 2373
2364 2374 * setup.py: finally, we have a true Windows installer, thanks to
2365 2375 the excellent work of Viktor Ransmayr
2366 2376 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2367 2377 Windows users. The setup routine is quite a bit cleaner thanks to
2368 2378 this, and the post-install script uses the proper functions to
2369 2379 allow a clean de-installation using the standard Windows Control
2370 2380 Panel.
2371 2381
2372 2382 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2373 2383 environment variable under all OSes (including win32) if
2374 2384 available. This will give consistency to win32 users who have set
2375 2385 this variable for any reason. If os.environ['HOME'] fails, the
2376 2386 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2377 2387
2378 2388 2005-01-24 Fernando Perez <fperez@colorado.edu>
2379 2389
2380 2390 * IPython/numutils.py (empty_like): add empty_like(), similar to
2381 2391 zeros_like() but taking advantage of the new empty() Numeric routine.
2382 2392
2383 2393 2005-01-23 *** Released version 0.6.8
2384 2394
2385 2395 2005-01-22 Fernando Perez <fperez@colorado.edu>
2386 2396
2387 2397 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2388 2398 automatic show() calls. After discussing things with JDH, it
2389 2399 turns out there are too many corner cases where this can go wrong.
2390 2400 It's best not to try to be 'too smart', and simply have ipython
2391 2401 reproduce as much as possible the default behavior of a normal
2392 2402 python shell.
2393 2403
2394 2404 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2395 2405 line-splitting regexp and _prefilter() to avoid calling getattr()
2396 2406 on assignments. This closes
2397 2407 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2398 2408 readline uses getattr(), so a simple <TAB> keypress is still
2399 2409 enough to trigger getattr() calls on an object.
2400 2410
2401 2411 2005-01-21 Fernando Perez <fperez@colorado.edu>
2402 2412
2403 2413 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2404 2414 docstring under pylab so it doesn't mask the original.
2405 2415
2406 2416 2005-01-21 *** Released version 0.6.7
2407 2417
2408 2418 2005-01-21 Fernando Perez <fperez@colorado.edu>
2409 2419
2410 2420 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2411 2421 signal handling for win32 users in multithreaded mode.
2412 2422
2413 2423 2005-01-17 Fernando Perez <fperez@colorado.edu>
2414 2424
2415 2425 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2416 2426 instances with no __init__. After a crash report by Norbert Nemec
2417 2427 <Norbert-AT-nemec-online.de>.
2418 2428
2419 2429 2005-01-14 Fernando Perez <fperez@colorado.edu>
2420 2430
2421 2431 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2422 2432 names for verbose exceptions, when multiple dotted names and the
2423 2433 'parent' object were present on the same line.
2424 2434
2425 2435 2005-01-11 Fernando Perez <fperez@colorado.edu>
2426 2436
2427 2437 * IPython/genutils.py (flag_calls): new utility to trap and flag
2428 2438 calls in functions. I need it to clean up matplotlib support.
2429 2439 Also removed some deprecated code in genutils.
2430 2440
2431 2441 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2432 2442 that matplotlib scripts called with %run, which don't call show()
2433 2443 themselves, still have their plotting windows open.
2434 2444
2435 2445 2005-01-05 Fernando Perez <fperez@colorado.edu>
2436 2446
2437 2447 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2438 2448 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2439 2449
2440 2450 2004-12-19 Fernando Perez <fperez@colorado.edu>
2441 2451
2442 2452 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2443 2453 parent_runcode, which was an eyesore. The same result can be
2444 2454 obtained with Python's regular superclass mechanisms.
2445 2455
2446 2456 2004-12-17 Fernando Perez <fperez@colorado.edu>
2447 2457
2448 2458 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2449 2459 reported by Prabhu.
2450 2460 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2451 2461 sys.stderr) instead of explicitly calling sys.stderr. This helps
2452 2462 maintain our I/O abstractions clean, for future GUI embeddings.
2453 2463
2454 2464 * IPython/genutils.py (info): added new utility for sys.stderr
2455 2465 unified info message handling (thin wrapper around warn()).
2456 2466
2457 2467 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2458 2468 composite (dotted) names on verbose exceptions.
2459 2469 (VerboseTB.nullrepr): harden against another kind of errors which
2460 2470 Python's inspect module can trigger, and which were crashing
2461 2471 IPython. Thanks to a report by Marco Lombardi
2462 2472 <mlombard-AT-ma010192.hq.eso.org>.
2463 2473
2464 2474 2004-12-13 *** Released version 0.6.6
2465 2475
2466 2476 2004-12-12 Fernando Perez <fperez@colorado.edu>
2467 2477
2468 2478 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2469 2479 generated by pygtk upon initialization if it was built without
2470 2480 threads (for matplotlib users). After a crash reported by
2471 2481 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2472 2482
2473 2483 * IPython/ipmaker.py (make_IPython): fix small bug in the
2474 2484 import_some parameter for multiple imports.
2475 2485
2476 2486 * IPython/iplib.py (ipmagic): simplified the interface of
2477 2487 ipmagic() to take a single string argument, just as it would be
2478 2488 typed at the IPython cmd line.
2479 2489 (ipalias): Added new ipalias() with an interface identical to
2480 2490 ipmagic(). This completes exposing a pure python interface to the
2481 2491 alias and magic system, which can be used in loops or more complex
2482 2492 code where IPython's automatic line mangling is not active.
2483 2493
2484 2494 * IPython/genutils.py (timing): changed interface of timing to
2485 2495 simply run code once, which is the most common case. timings()
2486 2496 remains unchanged, for the cases where you want multiple runs.
2487 2497
2488 2498 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2489 2499 bug where Python2.2 crashes with exec'ing code which does not end
2490 2500 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2491 2501 before.
2492 2502
2493 2503 2004-12-10 Fernando Perez <fperez@colorado.edu>
2494 2504
2495 2505 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2496 2506 -t to -T, to accomodate the new -t flag in %run (the %run and
2497 2507 %prun options are kind of intermixed, and it's not easy to change
2498 2508 this with the limitations of python's getopt).
2499 2509
2500 2510 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2501 2511 the execution of scripts. It's not as fine-tuned as timeit.py,
2502 2512 but it works from inside ipython (and under 2.2, which lacks
2503 2513 timeit.py). Optionally a number of runs > 1 can be given for
2504 2514 timing very short-running code.
2505 2515
2506 2516 * IPython/genutils.py (uniq_stable): new routine which returns a
2507 2517 list of unique elements in any iterable, but in stable order of
2508 2518 appearance. I needed this for the ultraTB fixes, and it's a handy
2509 2519 utility.
2510 2520
2511 2521 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2512 2522 dotted names in Verbose exceptions. This had been broken since
2513 2523 the very start, now x.y will properly be printed in a Verbose
2514 2524 traceback, instead of x being shown and y appearing always as an
2515 2525 'undefined global'. Getting this to work was a bit tricky,
2516 2526 because by default python tokenizers are stateless. Saved by
2517 2527 python's ability to easily add a bit of state to an arbitrary
2518 2528 function (without needing to build a full-blown callable object).
2519 2529
2520 2530 Also big cleanup of this code, which had horrendous runtime
2521 2531 lookups of zillions of attributes for colorization. Moved all
2522 2532 this code into a few templates, which make it cleaner and quicker.
2523 2533
2524 2534 Printout quality was also improved for Verbose exceptions: one
2525 2535 variable per line, and memory addresses are printed (this can be
2526 2536 quite handy in nasty debugging situations, which is what Verbose
2527 2537 is for).
2528 2538
2529 2539 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2530 2540 the command line as scripts to be loaded by embedded instances.
2531 2541 Doing so has the potential for an infinite recursion if there are
2532 2542 exceptions thrown in the process. This fixes a strange crash
2533 2543 reported by Philippe MULLER <muller-AT-irit.fr>.
2534 2544
2535 2545 2004-12-09 Fernando Perez <fperez@colorado.edu>
2536 2546
2537 2547 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2538 2548 to reflect new names in matplotlib, which now expose the
2539 2549 matlab-compatible interface via a pylab module instead of the
2540 2550 'matlab' name. The new code is backwards compatible, so users of
2541 2551 all matplotlib versions are OK. Patch by J. Hunter.
2542 2552
2543 2553 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2544 2554 of __init__ docstrings for instances (class docstrings are already
2545 2555 automatically printed). Instances with customized docstrings
2546 2556 (indep. of the class) are also recognized and all 3 separate
2547 2557 docstrings are printed (instance, class, constructor). After some
2548 2558 comments/suggestions by J. Hunter.
2549 2559
2550 2560 2004-12-05 Fernando Perez <fperez@colorado.edu>
2551 2561
2552 2562 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2553 2563 warnings when tab-completion fails and triggers an exception.
2554 2564
2555 2565 2004-12-03 Fernando Perez <fperez@colorado.edu>
2556 2566
2557 2567 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2558 2568 be triggered when using 'run -p'. An incorrect option flag was
2559 2569 being set ('d' instead of 'D').
2560 2570 (manpage): fix missing escaped \- sign.
2561 2571
2562 2572 2004-11-30 *** Released version 0.6.5
2563 2573
2564 2574 2004-11-30 Fernando Perez <fperez@colorado.edu>
2565 2575
2566 2576 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2567 2577 setting with -d option.
2568 2578
2569 2579 * setup.py (docfiles): Fix problem where the doc glob I was using
2570 2580 was COMPLETELY BROKEN. It was giving the right files by pure
2571 2581 accident, but failed once I tried to include ipython.el. Note:
2572 2582 glob() does NOT allow you to do exclusion on multiple endings!
2573 2583
2574 2584 2004-11-29 Fernando Perez <fperez@colorado.edu>
2575 2585
2576 2586 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2577 2587 the manpage as the source. Better formatting & consistency.
2578 2588
2579 2589 * IPython/Magic.py (magic_run): Added new -d option, to run
2580 2590 scripts under the control of the python pdb debugger. Note that
2581 2591 this required changing the %prun option -d to -D, to avoid a clash
2582 2592 (since %run must pass options to %prun, and getopt is too dumb to
2583 2593 handle options with string values with embedded spaces). Thanks
2584 2594 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2585 2595 (magic_who_ls): added type matching to %who and %whos, so that one
2586 2596 can filter their output to only include variables of certain
2587 2597 types. Another suggestion by Matthew.
2588 2598 (magic_whos): Added memory summaries in kb and Mb for arrays.
2589 2599 (magic_who): Improve formatting (break lines every 9 vars).
2590 2600
2591 2601 2004-11-28 Fernando Perez <fperez@colorado.edu>
2592 2602
2593 2603 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2594 2604 cache when empty lines were present.
2595 2605
2596 2606 2004-11-24 Fernando Perez <fperez@colorado.edu>
2597 2607
2598 2608 * IPython/usage.py (__doc__): document the re-activated threading
2599 2609 options for WX and GTK.
2600 2610
2601 2611 2004-11-23 Fernando Perez <fperez@colorado.edu>
2602 2612
2603 2613 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2604 2614 the -wthread and -gthread options, along with a new -tk one to try
2605 2615 and coordinate Tk threading with wx/gtk. The tk support is very
2606 2616 platform dependent, since it seems to require Tcl and Tk to be
2607 2617 built with threads (Fedora1/2 appears NOT to have it, but in
2608 2618 Prabhu's Debian boxes it works OK). But even with some Tk
2609 2619 limitations, this is a great improvement.
2610 2620
2611 2621 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2612 2622 info in user prompts. Patch by Prabhu.
2613 2623
2614 2624 2004-11-18 Fernando Perez <fperez@colorado.edu>
2615 2625
2616 2626 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2617 2627 EOFErrors and bail, to avoid infinite loops if a non-terminating
2618 2628 file is fed into ipython. Patch submitted in issue 19 by user,
2619 2629 many thanks.
2620 2630
2621 2631 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2622 2632 autoquote/parens in continuation prompts, which can cause lots of
2623 2633 problems. Closes roundup issue 20.
2624 2634
2625 2635 2004-11-17 Fernando Perez <fperez@colorado.edu>
2626 2636
2627 2637 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2628 2638 reported as debian bug #280505. I'm not sure my local changelog
2629 2639 entry has the proper debian format (Jack?).
2630 2640
2631 2641 2004-11-08 *** Released version 0.6.4
2632 2642
2633 2643 2004-11-08 Fernando Perez <fperez@colorado.edu>
2634 2644
2635 2645 * IPython/iplib.py (init_readline): Fix exit message for Windows
2636 2646 when readline is active. Thanks to a report by Eric Jones
2637 2647 <eric-AT-enthought.com>.
2638 2648
2639 2649 2004-11-07 Fernando Perez <fperez@colorado.edu>
2640 2650
2641 2651 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2642 2652 sometimes seen by win2k/cygwin users.
2643 2653
2644 2654 2004-11-06 Fernando Perez <fperez@colorado.edu>
2645 2655
2646 2656 * IPython/iplib.py (interact): Change the handling of %Exit from
2647 2657 trying to propagate a SystemExit to an internal ipython flag.
2648 2658 This is less elegant than using Python's exception mechanism, but
2649 2659 I can't get that to work reliably with threads, so under -pylab
2650 2660 %Exit was hanging IPython. Cross-thread exception handling is
2651 2661 really a bitch. Thaks to a bug report by Stephen Walton
2652 2662 <stephen.walton-AT-csun.edu>.
2653 2663
2654 2664 2004-11-04 Fernando Perez <fperez@colorado.edu>
2655 2665
2656 2666 * IPython/iplib.py (raw_input_original): store a pointer to the
2657 2667 true raw_input to harden against code which can modify it
2658 2668 (wx.py.PyShell does this and would otherwise crash ipython).
2659 2669 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2660 2670
2661 2671 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2662 2672 Ctrl-C problem, which does not mess up the input line.
2663 2673
2664 2674 2004-11-03 Fernando Perez <fperez@colorado.edu>
2665 2675
2666 2676 * IPython/Release.py: Changed licensing to BSD, in all files.
2667 2677 (name): lowercase name for tarball/RPM release.
2668 2678
2669 2679 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2670 2680 use throughout ipython.
2671 2681
2672 2682 * IPython/Magic.py (Magic._ofind): Switch to using the new
2673 2683 OInspect.getdoc() function.
2674 2684
2675 2685 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2676 2686 of the line currently being canceled via Ctrl-C. It's extremely
2677 2687 ugly, but I don't know how to do it better (the problem is one of
2678 2688 handling cross-thread exceptions).
2679 2689
2680 2690 2004-10-28 Fernando Perez <fperez@colorado.edu>
2681 2691
2682 2692 * IPython/Shell.py (signal_handler): add signal handlers to trap
2683 2693 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2684 2694 report by Francesc Alted.
2685 2695
2686 2696 2004-10-21 Fernando Perez <fperez@colorado.edu>
2687 2697
2688 2698 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2689 2699 to % for pysh syntax extensions.
2690 2700
2691 2701 2004-10-09 Fernando Perez <fperez@colorado.edu>
2692 2702
2693 2703 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2694 2704 arrays to print a more useful summary, without calling str(arr).
2695 2705 This avoids the problem of extremely lengthy computations which
2696 2706 occur if arr is large, and appear to the user as a system lockup
2697 2707 with 100% cpu activity. After a suggestion by Kristian Sandberg
2698 2708 <Kristian.Sandberg@colorado.edu>.
2699 2709 (Magic.__init__): fix bug in global magic escapes not being
2700 2710 correctly set.
2701 2711
2702 2712 2004-10-08 Fernando Perez <fperez@colorado.edu>
2703 2713
2704 2714 * IPython/Magic.py (__license__): change to absolute imports of
2705 2715 ipython's own internal packages, to start adapting to the absolute
2706 2716 import requirement of PEP-328.
2707 2717
2708 2718 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2709 2719 files, and standardize author/license marks through the Release
2710 2720 module instead of having per/file stuff (except for files with
2711 2721 particular licenses, like the MIT/PSF-licensed codes).
2712 2722
2713 2723 * IPython/Debugger.py: remove dead code for python 2.1
2714 2724
2715 2725 2004-10-04 Fernando Perez <fperez@colorado.edu>
2716 2726
2717 2727 * IPython/iplib.py (ipmagic): New function for accessing magics
2718 2728 via a normal python function call.
2719 2729
2720 2730 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2721 2731 from '@' to '%', to accomodate the new @decorator syntax of python
2722 2732 2.4.
2723 2733
2724 2734 2004-09-29 Fernando Perez <fperez@colorado.edu>
2725 2735
2726 2736 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2727 2737 matplotlib.use to prevent running scripts which try to switch
2728 2738 interactive backends from within ipython. This will just crash
2729 2739 the python interpreter, so we can't allow it (but a detailed error
2730 2740 is given to the user).
2731 2741
2732 2742 2004-09-28 Fernando Perez <fperez@colorado.edu>
2733 2743
2734 2744 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2735 2745 matplotlib-related fixes so that using @run with non-matplotlib
2736 2746 scripts doesn't pop up spurious plot windows. This requires
2737 2747 matplotlib >= 0.63, where I had to make some changes as well.
2738 2748
2739 2749 * IPython/ipmaker.py (make_IPython): update version requirement to
2740 2750 python 2.2.
2741 2751
2742 2752 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2743 2753 banner arg for embedded customization.
2744 2754
2745 2755 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2746 2756 explicit uses of __IP as the IPython's instance name. Now things
2747 2757 are properly handled via the shell.name value. The actual code
2748 2758 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2749 2759 is much better than before. I'll clean things completely when the
2750 2760 magic stuff gets a real overhaul.
2751 2761
2752 2762 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2753 2763 minor changes to debian dir.
2754 2764
2755 2765 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2756 2766 pointer to the shell itself in the interactive namespace even when
2757 2767 a user-supplied dict is provided. This is needed for embedding
2758 2768 purposes (found by tests with Michel Sanner).
2759 2769
2760 2770 2004-09-27 Fernando Perez <fperez@colorado.edu>
2761 2771
2762 2772 * IPython/UserConfig/ipythonrc: remove []{} from
2763 2773 readline_remove_delims, so that things like [modname.<TAB> do
2764 2774 proper completion. This disables [].TAB, but that's a less common
2765 2775 case than module names in list comprehensions, for example.
2766 2776 Thanks to a report by Andrea Riciputi.
2767 2777
2768 2778 2004-09-09 Fernando Perez <fperez@colorado.edu>
2769 2779
2770 2780 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2771 2781 blocking problems in win32 and osx. Fix by John.
2772 2782
2773 2783 2004-09-08 Fernando Perez <fperez@colorado.edu>
2774 2784
2775 2785 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2776 2786 for Win32 and OSX. Fix by John Hunter.
2777 2787
2778 2788 2004-08-30 *** Released version 0.6.3
2779 2789
2780 2790 2004-08-30 Fernando Perez <fperez@colorado.edu>
2781 2791
2782 2792 * setup.py (isfile): Add manpages to list of dependent files to be
2783 2793 updated.
2784 2794
2785 2795 2004-08-27 Fernando Perez <fperez@colorado.edu>
2786 2796
2787 2797 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2788 2798 for now. They don't really work with standalone WX/GTK code
2789 2799 (though matplotlib IS working fine with both of those backends).
2790 2800 This will neeed much more testing. I disabled most things with
2791 2801 comments, so turning it back on later should be pretty easy.
2792 2802
2793 2803 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2794 2804 autocalling of expressions like r'foo', by modifying the line
2795 2805 split regexp. Closes
2796 2806 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2797 2807 Riley <ipythonbugs-AT-sabi.net>.
2798 2808 (InteractiveShell.mainloop): honor --nobanner with banner
2799 2809 extensions.
2800 2810
2801 2811 * IPython/Shell.py: Significant refactoring of all classes, so
2802 2812 that we can really support ALL matplotlib backends and threading
2803 2813 models (John spotted a bug with Tk which required this). Now we
2804 2814 should support single-threaded, WX-threads and GTK-threads, both
2805 2815 for generic code and for matplotlib.
2806 2816
2807 2817 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2808 2818 -pylab, to simplify things for users. Will also remove the pylab
2809 2819 profile, since now all of matplotlib configuration is directly
2810 2820 handled here. This also reduces startup time.
2811 2821
2812 2822 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2813 2823 shell wasn't being correctly called. Also in IPShellWX.
2814 2824
2815 2825 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2816 2826 fine-tune banner.
2817 2827
2818 2828 * IPython/numutils.py (spike): Deprecate these spike functions,
2819 2829 delete (long deprecated) gnuplot_exec handler.
2820 2830
2821 2831 2004-08-26 Fernando Perez <fperez@colorado.edu>
2822 2832
2823 2833 * ipython.1: Update for threading options, plus some others which
2824 2834 were missing.
2825 2835
2826 2836 * IPython/ipmaker.py (__call__): Added -wthread option for
2827 2837 wxpython thread handling. Make sure threading options are only
2828 2838 valid at the command line.
2829 2839
2830 2840 * scripts/ipython: moved shell selection into a factory function
2831 2841 in Shell.py, to keep the starter script to a minimum.
2832 2842
2833 2843 2004-08-25 Fernando Perez <fperez@colorado.edu>
2834 2844
2835 2845 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2836 2846 John. Along with some recent changes he made to matplotlib, the
2837 2847 next versions of both systems should work very well together.
2838 2848
2839 2849 2004-08-24 Fernando Perez <fperez@colorado.edu>
2840 2850
2841 2851 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2842 2852 tried to switch the profiling to using hotshot, but I'm getting
2843 2853 strange errors from prof.runctx() there. I may be misreading the
2844 2854 docs, but it looks weird. For now the profiling code will
2845 2855 continue to use the standard profiler.
2846 2856
2847 2857 2004-08-23 Fernando Perez <fperez@colorado.edu>
2848 2858
2849 2859 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2850 2860 threaded shell, by John Hunter. It's not quite ready yet, but
2851 2861 close.
2852 2862
2853 2863 2004-08-22 Fernando Perez <fperez@colorado.edu>
2854 2864
2855 2865 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2856 2866 in Magic and ultraTB.
2857 2867
2858 2868 * ipython.1: document threading options in manpage.
2859 2869
2860 2870 * scripts/ipython: Changed name of -thread option to -gthread,
2861 2871 since this is GTK specific. I want to leave the door open for a
2862 2872 -wthread option for WX, which will most likely be necessary. This
2863 2873 change affects usage and ipmaker as well.
2864 2874
2865 2875 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2866 2876 handle the matplotlib shell issues. Code by John Hunter
2867 2877 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2868 2878 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2869 2879 broken (and disabled for end users) for now, but it puts the
2870 2880 infrastructure in place.
2871 2881
2872 2882 2004-08-21 Fernando Perez <fperez@colorado.edu>
2873 2883
2874 2884 * ipythonrc-pylab: Add matplotlib support.
2875 2885
2876 2886 * matplotlib_config.py: new files for matplotlib support, part of
2877 2887 the pylab profile.
2878 2888
2879 2889 * IPython/usage.py (__doc__): documented the threading options.
2880 2890
2881 2891 2004-08-20 Fernando Perez <fperez@colorado.edu>
2882 2892
2883 2893 * ipython: Modified the main calling routine to handle the -thread
2884 2894 and -mpthread options. This needs to be done as a top-level hack,
2885 2895 because it determines which class to instantiate for IPython
2886 2896 itself.
2887 2897
2888 2898 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2889 2899 classes to support multithreaded GTK operation without blocking,
2890 2900 and matplotlib with all backends. This is a lot of still very
2891 2901 experimental code, and threads are tricky. So it may still have a
2892 2902 few rough edges... This code owes a lot to
2893 2903 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2894 2904 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2895 2905 to John Hunter for all the matplotlib work.
2896 2906
2897 2907 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2898 2908 options for gtk thread and matplotlib support.
2899 2909
2900 2910 2004-08-16 Fernando Perez <fperez@colorado.edu>
2901 2911
2902 2912 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2903 2913 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2904 2914 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2905 2915
2906 2916 2004-08-11 Fernando Perez <fperez@colorado.edu>
2907 2917
2908 2918 * setup.py (isfile): Fix build so documentation gets updated for
2909 2919 rpms (it was only done for .tgz builds).
2910 2920
2911 2921 2004-08-10 Fernando Perez <fperez@colorado.edu>
2912 2922
2913 2923 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2914 2924
2915 2925 * iplib.py : Silence syntax error exceptions in tab-completion.
2916 2926
2917 2927 2004-08-05 Fernando Perez <fperez@colorado.edu>
2918 2928
2919 2929 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2920 2930 'color off' mark for continuation prompts. This was causing long
2921 2931 continuation lines to mis-wrap.
2922 2932
2923 2933 2004-08-01 Fernando Perez <fperez@colorado.edu>
2924 2934
2925 2935 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2926 2936 for building ipython to be a parameter. All this is necessary
2927 2937 right now to have a multithreaded version, but this insane
2928 2938 non-design will be cleaned up soon. For now, it's a hack that
2929 2939 works.
2930 2940
2931 2941 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2932 2942 args in various places. No bugs so far, but it's a dangerous
2933 2943 practice.
2934 2944
2935 2945 2004-07-31 Fernando Perez <fperez@colorado.edu>
2936 2946
2937 2947 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2938 2948 fix completion of files with dots in their names under most
2939 2949 profiles (pysh was OK because the completion order is different).
2940 2950
2941 2951 2004-07-27 Fernando Perez <fperez@colorado.edu>
2942 2952
2943 2953 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2944 2954 keywords manually, b/c the one in keyword.py was removed in python
2945 2955 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2946 2956 This is NOT a bug under python 2.3 and earlier.
2947 2957
2948 2958 2004-07-26 Fernando Perez <fperez@colorado.edu>
2949 2959
2950 2960 * IPython/ultraTB.py (VerboseTB.text): Add another
2951 2961 linecache.checkcache() call to try to prevent inspect.py from
2952 2962 crashing under python 2.3. I think this fixes
2953 2963 http://www.scipy.net/roundup/ipython/issue17.
2954 2964
2955 2965 2004-07-26 *** Released version 0.6.2
2956 2966
2957 2967 2004-07-26 Fernando Perez <fperez@colorado.edu>
2958 2968
2959 2969 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2960 2970 fail for any number.
2961 2971 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2962 2972 empty bookmarks.
2963 2973
2964 2974 2004-07-26 *** Released version 0.6.1
2965 2975
2966 2976 2004-07-26 Fernando Perez <fperez@colorado.edu>
2967 2977
2968 2978 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2969 2979
2970 2980 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2971 2981 escaping '()[]{}' in filenames.
2972 2982
2973 2983 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2974 2984 Python 2.2 users who lack a proper shlex.split.
2975 2985
2976 2986 2004-07-19 Fernando Perez <fperez@colorado.edu>
2977 2987
2978 2988 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2979 2989 for reading readline's init file. I follow the normal chain:
2980 2990 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2981 2991 report by Mike Heeter. This closes
2982 2992 http://www.scipy.net/roundup/ipython/issue16.
2983 2993
2984 2994 2004-07-18 Fernando Perez <fperez@colorado.edu>
2985 2995
2986 2996 * IPython/iplib.py (__init__): Add better handling of '\' under
2987 2997 Win32 for filenames. After a patch by Ville.
2988 2998
2989 2999 2004-07-17 Fernando Perez <fperez@colorado.edu>
2990 3000
2991 3001 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2992 3002 autocalling would be triggered for 'foo is bar' if foo is
2993 3003 callable. I also cleaned up the autocall detection code to use a
2994 3004 regexp, which is faster. Bug reported by Alexander Schmolck.
2995 3005
2996 3006 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2997 3007 '?' in them would confuse the help system. Reported by Alex
2998 3008 Schmolck.
2999 3009
3000 3010 2004-07-16 Fernando Perez <fperez@colorado.edu>
3001 3011
3002 3012 * IPython/GnuplotInteractive.py (__all__): added plot2.
3003 3013
3004 3014 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3005 3015 plotting dictionaries, lists or tuples of 1d arrays.
3006 3016
3007 3017 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3008 3018 optimizations.
3009 3019
3010 3020 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3011 3021 the information which was there from Janko's original IPP code:
3012 3022
3013 3023 03.05.99 20:53 porto.ifm.uni-kiel.de
3014 3024 --Started changelog.
3015 3025 --make clear do what it say it does
3016 3026 --added pretty output of lines from inputcache
3017 3027 --Made Logger a mixin class, simplifies handling of switches
3018 3028 --Added own completer class. .string<TAB> expands to last history
3019 3029 line which starts with string. The new expansion is also present
3020 3030 with Ctrl-r from the readline library. But this shows, who this
3021 3031 can be done for other cases.
3022 3032 --Added convention that all shell functions should accept a
3023 3033 parameter_string This opens the door for different behaviour for
3024 3034 each function. @cd is a good example of this.
3025 3035
3026 3036 04.05.99 12:12 porto.ifm.uni-kiel.de
3027 3037 --added logfile rotation
3028 3038 --added new mainloop method which freezes first the namespace
3029 3039
3030 3040 07.05.99 21:24 porto.ifm.uni-kiel.de
3031 3041 --added the docreader classes. Now there is a help system.
3032 3042 -This is only a first try. Currently it's not easy to put new
3033 3043 stuff in the indices. But this is the way to go. Info would be
3034 3044 better, but HTML is every where and not everybody has an info
3035 3045 system installed and it's not so easy to change html-docs to info.
3036 3046 --added global logfile option
3037 3047 --there is now a hook for object inspection method pinfo needs to
3038 3048 be provided for this. Can be reached by two '??'.
3039 3049
3040 3050 08.05.99 20:51 porto.ifm.uni-kiel.de
3041 3051 --added a README
3042 3052 --bug in rc file. Something has changed so functions in the rc
3043 3053 file need to reference the shell and not self. Not clear if it's a
3044 3054 bug or feature.
3045 3055 --changed rc file for new behavior
3046 3056
3047 3057 2004-07-15 Fernando Perez <fperez@colorado.edu>
3048 3058
3049 3059 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3050 3060 cache was falling out of sync in bizarre manners when multi-line
3051 3061 input was present. Minor optimizations and cleanup.
3052 3062
3053 3063 (Logger): Remove old Changelog info for cleanup. This is the
3054 3064 information which was there from Janko's original code:
3055 3065
3056 3066 Changes to Logger: - made the default log filename a parameter
3057 3067
3058 3068 - put a check for lines beginning with !@? in log(). Needed
3059 3069 (even if the handlers properly log their lines) for mid-session
3060 3070 logging activation to work properly. Without this, lines logged
3061 3071 in mid session, which get read from the cache, would end up
3062 3072 'bare' (with !@? in the open) in the log. Now they are caught
3063 3073 and prepended with a #.
3064 3074
3065 3075 * IPython/iplib.py (InteractiveShell.init_readline): added check
3066 3076 in case MagicCompleter fails to be defined, so we don't crash.
3067 3077
3068 3078 2004-07-13 Fernando Perez <fperez@colorado.edu>
3069 3079
3070 3080 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3071 3081 of EPS if the requested filename ends in '.eps'.
3072 3082
3073 3083 2004-07-04 Fernando Perez <fperez@colorado.edu>
3074 3084
3075 3085 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3076 3086 escaping of quotes when calling the shell.
3077 3087
3078 3088 2004-07-02 Fernando Perez <fperez@colorado.edu>
3079 3089
3080 3090 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3081 3091 gettext not working because we were clobbering '_'. Fixes
3082 3092 http://www.scipy.net/roundup/ipython/issue6.
3083 3093
3084 3094 2004-07-01 Fernando Perez <fperez@colorado.edu>
3085 3095
3086 3096 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3087 3097 into @cd. Patch by Ville.
3088 3098
3089 3099 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3090 3100 new function to store things after ipmaker runs. Patch by Ville.
3091 3101 Eventually this will go away once ipmaker is removed and the class
3092 3102 gets cleaned up, but for now it's ok. Key functionality here is
3093 3103 the addition of the persistent storage mechanism, a dict for
3094 3104 keeping data across sessions (for now just bookmarks, but more can
3095 3105 be implemented later).
3096 3106
3097 3107 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3098 3108 persistent across sections. Patch by Ville, I modified it
3099 3109 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3100 3110 added a '-l' option to list all bookmarks.
3101 3111
3102 3112 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3103 3113 center for cleanup. Registered with atexit.register(). I moved
3104 3114 here the old exit_cleanup(). After a patch by Ville.
3105 3115
3106 3116 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3107 3117 characters in the hacked shlex_split for python 2.2.
3108 3118
3109 3119 * IPython/iplib.py (file_matches): more fixes to filenames with
3110 3120 whitespace in them. It's not perfect, but limitations in python's
3111 3121 readline make it impossible to go further.
3112 3122
3113 3123 2004-06-29 Fernando Perez <fperez@colorado.edu>
3114 3124
3115 3125 * IPython/iplib.py (file_matches): escape whitespace correctly in
3116 3126 filename completions. Bug reported by Ville.
3117 3127
3118 3128 2004-06-28 Fernando Perez <fperez@colorado.edu>
3119 3129
3120 3130 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3121 3131 the history file will be called 'history-PROFNAME' (or just
3122 3132 'history' if no profile is loaded). I was getting annoyed at
3123 3133 getting my Numerical work history clobbered by pysh sessions.
3124 3134
3125 3135 * IPython/iplib.py (InteractiveShell.__init__): Internal
3126 3136 getoutputerror() function so that we can honor the system_verbose
3127 3137 flag for _all_ system calls. I also added escaping of #
3128 3138 characters here to avoid confusing Itpl.
3129 3139
3130 3140 * IPython/Magic.py (shlex_split): removed call to shell in
3131 3141 parse_options and replaced it with shlex.split(). The annoying
3132 3142 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3133 3143 to backport it from 2.3, with several frail hacks (the shlex
3134 3144 module is rather limited in 2.2). Thanks to a suggestion by Ville
3135 3145 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3136 3146 problem.
3137 3147
3138 3148 (Magic.magic_system_verbose): new toggle to print the actual
3139 3149 system calls made by ipython. Mainly for debugging purposes.
3140 3150
3141 3151 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3142 3152 doesn't support persistence. Reported (and fix suggested) by
3143 3153 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3144 3154
3145 3155 2004-06-26 Fernando Perez <fperez@colorado.edu>
3146 3156
3147 3157 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3148 3158 continue prompts.
3149 3159
3150 3160 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3151 3161 function (basically a big docstring) and a few more things here to
3152 3162 speedup startup. pysh.py is now very lightweight. We want because
3153 3163 it gets execfile'd, while InterpreterExec gets imported, so
3154 3164 byte-compilation saves time.
3155 3165
3156 3166 2004-06-25 Fernando Perez <fperez@colorado.edu>
3157 3167
3158 3168 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3159 3169 -NUM', which was recently broken.
3160 3170
3161 3171 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3162 3172 in multi-line input (but not !!, which doesn't make sense there).
3163 3173
3164 3174 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3165 3175 It's just too useful, and people can turn it off in the less
3166 3176 common cases where it's a problem.
3167 3177
3168 3178 2004-06-24 Fernando Perez <fperez@colorado.edu>
3169 3179
3170 3180 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3171 3181 special syntaxes (like alias calling) is now allied in multi-line
3172 3182 input. This is still _very_ experimental, but it's necessary for
3173 3183 efficient shell usage combining python looping syntax with system
3174 3184 calls. For now it's restricted to aliases, I don't think it
3175 3185 really even makes sense to have this for magics.
3176 3186
3177 3187 2004-06-23 Fernando Perez <fperez@colorado.edu>
3178 3188
3179 3189 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3180 3190 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3181 3191
3182 3192 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3183 3193 extensions under Windows (after code sent by Gary Bishop). The
3184 3194 extensions considered 'executable' are stored in IPython's rc
3185 3195 structure as win_exec_ext.
3186 3196
3187 3197 * IPython/genutils.py (shell): new function, like system() but
3188 3198 without return value. Very useful for interactive shell work.
3189 3199
3190 3200 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3191 3201 delete aliases.
3192 3202
3193 3203 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3194 3204 sure that the alias table doesn't contain python keywords.
3195 3205
3196 3206 2004-06-21 Fernando Perez <fperez@colorado.edu>
3197 3207
3198 3208 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3199 3209 non-existent items are found in $PATH. Reported by Thorsten.
3200 3210
3201 3211 2004-06-20 Fernando Perez <fperez@colorado.edu>
3202 3212
3203 3213 * IPython/iplib.py (complete): modified the completer so that the
3204 3214 order of priorities can be easily changed at runtime.
3205 3215
3206 3216 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3207 3217 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3208 3218
3209 3219 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3210 3220 expand Python variables prepended with $ in all system calls. The
3211 3221 same was done to InteractiveShell.handle_shell_escape. Now all
3212 3222 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3213 3223 expansion of python variables and expressions according to the
3214 3224 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3215 3225
3216 3226 Though PEP-215 has been rejected, a similar (but simpler) one
3217 3227 seems like it will go into Python 2.4, PEP-292 -
3218 3228 http://www.python.org/peps/pep-0292.html.
3219 3229
3220 3230 I'll keep the full syntax of PEP-215, since IPython has since the
3221 3231 start used Ka-Ping Yee's reference implementation discussed there
3222 3232 (Itpl), and I actually like the powerful semantics it offers.
3223 3233
3224 3234 In order to access normal shell variables, the $ has to be escaped
3225 3235 via an extra $. For example:
3226 3236
3227 3237 In [7]: PATH='a python variable'
3228 3238
3229 3239 In [8]: !echo $PATH
3230 3240 a python variable
3231 3241
3232 3242 In [9]: !echo $$PATH
3233 3243 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3234 3244
3235 3245 (Magic.parse_options): escape $ so the shell doesn't evaluate
3236 3246 things prematurely.
3237 3247
3238 3248 * IPython/iplib.py (InteractiveShell.call_alias): added the
3239 3249 ability for aliases to expand python variables via $.
3240 3250
3241 3251 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3242 3252 system, now there's a @rehash/@rehashx pair of magics. These work
3243 3253 like the csh rehash command, and can be invoked at any time. They
3244 3254 build a table of aliases to everything in the user's $PATH
3245 3255 (@rehash uses everything, @rehashx is slower but only adds
3246 3256 executable files). With this, the pysh.py-based shell profile can
3247 3257 now simply call rehash upon startup, and full access to all
3248 3258 programs in the user's path is obtained.
3249 3259
3250 3260 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3251 3261 functionality is now fully in place. I removed the old dynamic
3252 3262 code generation based approach, in favor of a much lighter one
3253 3263 based on a simple dict. The advantage is that this allows me to
3254 3264 now have thousands of aliases with negligible cost (unthinkable
3255 3265 with the old system).
3256 3266
3257 3267 2004-06-19 Fernando Perez <fperez@colorado.edu>
3258 3268
3259 3269 * IPython/iplib.py (__init__): extended MagicCompleter class to
3260 3270 also complete (last in priority) on user aliases.
3261 3271
3262 3272 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3263 3273 call to eval.
3264 3274 (ItplNS.__init__): Added a new class which functions like Itpl,
3265 3275 but allows configuring the namespace for the evaluation to occur
3266 3276 in.
3267 3277
3268 3278 2004-06-18 Fernando Perez <fperez@colorado.edu>
3269 3279
3270 3280 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3271 3281 better message when 'exit' or 'quit' are typed (a common newbie
3272 3282 confusion).
3273 3283
3274 3284 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3275 3285 check for Windows users.
3276 3286
3277 3287 * IPython/iplib.py (InteractiveShell.user_setup): removed
3278 3288 disabling of colors for Windows. I'll test at runtime and issue a
3279 3289 warning if Gary's readline isn't found, as to nudge users to
3280 3290 download it.
3281 3291
3282 3292 2004-06-16 Fernando Perez <fperez@colorado.edu>
3283 3293
3284 3294 * IPython/genutils.py (Stream.__init__): changed to print errors
3285 3295 to sys.stderr. I had a circular dependency here. Now it's
3286 3296 possible to run ipython as IDLE's shell (consider this pre-alpha,
3287 3297 since true stdout things end up in the starting terminal instead
3288 3298 of IDLE's out).
3289 3299
3290 3300 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3291 3301 users who haven't # updated their prompt_in2 definitions. Remove
3292 3302 eventually.
3293 3303 (multiple_replace): added credit to original ASPN recipe.
3294 3304
3295 3305 2004-06-15 Fernando Perez <fperez@colorado.edu>
3296 3306
3297 3307 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3298 3308 list of auto-defined aliases.
3299 3309
3300 3310 2004-06-13 Fernando Perez <fperez@colorado.edu>
3301 3311
3302 3312 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3303 3313 install was really requested (so setup.py can be used for other
3304 3314 things under Windows).
3305 3315
3306 3316 2004-06-10 Fernando Perez <fperez@colorado.edu>
3307 3317
3308 3318 * IPython/Logger.py (Logger.create_log): Manually remove any old
3309 3319 backup, since os.remove may fail under Windows. Fixes bug
3310 3320 reported by Thorsten.
3311 3321
3312 3322 2004-06-09 Fernando Perez <fperez@colorado.edu>
3313 3323
3314 3324 * examples/example-embed.py: fixed all references to %n (replaced
3315 3325 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3316 3326 for all examples and the manual as well.
3317 3327
3318 3328 2004-06-08 Fernando Perez <fperez@colorado.edu>
3319 3329
3320 3330 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3321 3331 alignment and color management. All 3 prompt subsystems now
3322 3332 inherit from BasePrompt.
3323 3333
3324 3334 * tools/release: updates for windows installer build and tag rpms
3325 3335 with python version (since paths are fixed).
3326 3336
3327 3337 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3328 3338 which will become eventually obsolete. Also fixed the default
3329 3339 prompt_in2 to use \D, so at least new users start with the correct
3330 3340 defaults.
3331 3341 WARNING: Users with existing ipythonrc files will need to apply
3332 3342 this fix manually!
3333 3343
3334 3344 * setup.py: make windows installer (.exe). This is finally the
3335 3345 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3336 3346 which I hadn't included because it required Python 2.3 (or recent
3337 3347 distutils).
3338 3348
3339 3349 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3340 3350 usage of new '\D' escape.
3341 3351
3342 3352 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3343 3353 lacks os.getuid())
3344 3354 (CachedOutput.set_colors): Added the ability to turn coloring
3345 3355 on/off with @colors even for manually defined prompt colors. It
3346 3356 uses a nasty global, but it works safely and via the generic color
3347 3357 handling mechanism.
3348 3358 (Prompt2.__init__): Introduced new escape '\D' for continuation
3349 3359 prompts. It represents the counter ('\#') as dots.
3350 3360 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3351 3361 need to update their ipythonrc files and replace '%n' with '\D' in
3352 3362 their prompt_in2 settings everywhere. Sorry, but there's
3353 3363 otherwise no clean way to get all prompts to properly align. The
3354 3364 ipythonrc shipped with IPython has been updated.
3355 3365
3356 3366 2004-06-07 Fernando Perez <fperez@colorado.edu>
3357 3367
3358 3368 * setup.py (isfile): Pass local_icons option to latex2html, so the
3359 3369 resulting HTML file is self-contained. Thanks to
3360 3370 dryice-AT-liu.com.cn for the tip.
3361 3371
3362 3372 * pysh.py: I created a new profile 'shell', which implements a
3363 3373 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3364 3374 system shell, nor will it become one anytime soon. It's mainly
3365 3375 meant to illustrate the use of the new flexible bash-like prompts.
3366 3376 I guess it could be used by hardy souls for true shell management,
3367 3377 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3368 3378 profile. This uses the InterpreterExec extension provided by
3369 3379 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3370 3380
3371 3381 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3372 3382 auto-align itself with the length of the previous input prompt
3373 3383 (taking into account the invisible color escapes).
3374 3384 (CachedOutput.__init__): Large restructuring of this class. Now
3375 3385 all three prompts (primary1, primary2, output) are proper objects,
3376 3386 managed by the 'parent' CachedOutput class. The code is still a
3377 3387 bit hackish (all prompts share state via a pointer to the cache),
3378 3388 but it's overall far cleaner than before.
3379 3389
3380 3390 * IPython/genutils.py (getoutputerror): modified to add verbose,
3381 3391 debug and header options. This makes the interface of all getout*
3382 3392 functions uniform.
3383 3393 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3384 3394
3385 3395 * IPython/Magic.py (Magic.default_option): added a function to
3386 3396 allow registering default options for any magic command. This
3387 3397 makes it easy to have profiles which customize the magics globally
3388 3398 for a certain use. The values set through this function are
3389 3399 picked up by the parse_options() method, which all magics should
3390 3400 use to parse their options.
3391 3401
3392 3402 * IPython/genutils.py (warn): modified the warnings framework to
3393 3403 use the Term I/O class. I'm trying to slowly unify all of
3394 3404 IPython's I/O operations to pass through Term.
3395 3405
3396 3406 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3397 3407 the secondary prompt to correctly match the length of the primary
3398 3408 one for any prompt. Now multi-line code will properly line up
3399 3409 even for path dependent prompts, such as the new ones available
3400 3410 via the prompt_specials.
3401 3411
3402 3412 2004-06-06 Fernando Perez <fperez@colorado.edu>
3403 3413
3404 3414 * IPython/Prompts.py (prompt_specials): Added the ability to have
3405 3415 bash-like special sequences in the prompts, which get
3406 3416 automatically expanded. Things like hostname, current working
3407 3417 directory and username are implemented already, but it's easy to
3408 3418 add more in the future. Thanks to a patch by W.J. van der Laan
3409 3419 <gnufnork-AT-hetdigitalegat.nl>
3410 3420 (prompt_specials): Added color support for prompt strings, so
3411 3421 users can define arbitrary color setups for their prompts.
3412 3422
3413 3423 2004-06-05 Fernando Perez <fperez@colorado.edu>
3414 3424
3415 3425 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3416 3426 code to load Gary Bishop's readline and configure it
3417 3427 automatically. Thanks to Gary for help on this.
3418 3428
3419 3429 2004-06-01 Fernando Perez <fperez@colorado.edu>
3420 3430
3421 3431 * IPython/Logger.py (Logger.create_log): fix bug for logging
3422 3432 with no filename (previous fix was incomplete).
3423 3433
3424 3434 2004-05-25 Fernando Perez <fperez@colorado.edu>
3425 3435
3426 3436 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3427 3437 parens would get passed to the shell.
3428 3438
3429 3439 2004-05-20 Fernando Perez <fperez@colorado.edu>
3430 3440
3431 3441 * IPython/Magic.py (Magic.magic_prun): changed default profile
3432 3442 sort order to 'time' (the more common profiling need).
3433 3443
3434 3444 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3435 3445 so that source code shown is guaranteed in sync with the file on
3436 3446 disk (also changed in psource). Similar fix to the one for
3437 3447 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3438 3448 <yann.ledu-AT-noos.fr>.
3439 3449
3440 3450 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3441 3451 with a single option would not be correctly parsed. Closes
3442 3452 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3443 3453 introduced in 0.6.0 (on 2004-05-06).
3444 3454
3445 3455 2004-05-13 *** Released version 0.6.0
3446 3456
3447 3457 2004-05-13 Fernando Perez <fperez@colorado.edu>
3448 3458
3449 3459 * debian/: Added debian/ directory to CVS, so that debian support
3450 3460 is publicly accessible. The debian package is maintained by Jack
3451 3461 Moffit <jack-AT-xiph.org>.
3452 3462
3453 3463 * Documentation: included the notes about an ipython-based system
3454 3464 shell (the hypothetical 'pysh') into the new_design.pdf document,
3455 3465 so that these ideas get distributed to users along with the
3456 3466 official documentation.
3457 3467
3458 3468 2004-05-10 Fernando Perez <fperez@colorado.edu>
3459 3469
3460 3470 * IPython/Logger.py (Logger.create_log): fix recently introduced
3461 3471 bug (misindented line) where logstart would fail when not given an
3462 3472 explicit filename.
3463 3473
3464 3474 2004-05-09 Fernando Perez <fperez@colorado.edu>
3465 3475
3466 3476 * IPython/Magic.py (Magic.parse_options): skip system call when
3467 3477 there are no options to look for. Faster, cleaner for the common
3468 3478 case.
3469 3479
3470 3480 * Documentation: many updates to the manual: describing Windows
3471 3481 support better, Gnuplot updates, credits, misc small stuff. Also
3472 3482 updated the new_design doc a bit.
3473 3483
3474 3484 2004-05-06 *** Released version 0.6.0.rc1
3475 3485
3476 3486 2004-05-06 Fernando Perez <fperez@colorado.edu>
3477 3487
3478 3488 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3479 3489 operations to use the vastly more efficient list/''.join() method.
3480 3490 (FormattedTB.text): Fix
3481 3491 http://www.scipy.net/roundup/ipython/issue12 - exception source
3482 3492 extract not updated after reload. Thanks to Mike Salib
3483 3493 <msalib-AT-mit.edu> for pinning the source of the problem.
3484 3494 Fortunately, the solution works inside ipython and doesn't require
3485 3495 any changes to python proper.
3486 3496
3487 3497 * IPython/Magic.py (Magic.parse_options): Improved to process the
3488 3498 argument list as a true shell would (by actually using the
3489 3499 underlying system shell). This way, all @magics automatically get
3490 3500 shell expansion for variables. Thanks to a comment by Alex
3491 3501 Schmolck.
3492 3502
3493 3503 2004-04-04 Fernando Perez <fperez@colorado.edu>
3494 3504
3495 3505 * IPython/iplib.py (InteractiveShell.interact): Added a special
3496 3506 trap for a debugger quit exception, which is basically impossible
3497 3507 to handle by normal mechanisms, given what pdb does to the stack.
3498 3508 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3499 3509
3500 3510 2004-04-03 Fernando Perez <fperez@colorado.edu>
3501 3511
3502 3512 * IPython/genutils.py (Term): Standardized the names of the Term
3503 3513 class streams to cin/cout/cerr, following C++ naming conventions
3504 3514 (I can't use in/out/err because 'in' is not a valid attribute
3505 3515 name).
3506 3516
3507 3517 * IPython/iplib.py (InteractiveShell.interact): don't increment
3508 3518 the prompt if there's no user input. By Daniel 'Dang' Griffith
3509 3519 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3510 3520 Francois Pinard.
3511 3521
3512 3522 2004-04-02 Fernando Perez <fperez@colorado.edu>
3513 3523
3514 3524 * IPython/genutils.py (Stream.__init__): Modified to survive at
3515 3525 least importing in contexts where stdin/out/err aren't true file
3516 3526 objects, such as PyCrust (they lack fileno() and mode). However,
3517 3527 the recovery facilities which rely on these things existing will
3518 3528 not work.
3519 3529
3520 3530 2004-04-01 Fernando Perez <fperez@colorado.edu>
3521 3531
3522 3532 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3523 3533 use the new getoutputerror() function, so it properly
3524 3534 distinguishes stdout/err.
3525 3535
3526 3536 * IPython/genutils.py (getoutputerror): added a function to
3527 3537 capture separately the standard output and error of a command.
3528 3538 After a comment from dang on the mailing lists. This code is
3529 3539 basically a modified version of commands.getstatusoutput(), from
3530 3540 the standard library.
3531 3541
3532 3542 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3533 3543 '!!' as a special syntax (shorthand) to access @sx.
3534 3544
3535 3545 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3536 3546 command and return its output as a list split on '\n'.
3537 3547
3538 3548 2004-03-31 Fernando Perez <fperez@colorado.edu>
3539 3549
3540 3550 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3541 3551 method to dictionaries used as FakeModule instances if they lack
3542 3552 it. At least pydoc in python2.3 breaks for runtime-defined
3543 3553 functions without this hack. At some point I need to _really_
3544 3554 understand what FakeModule is doing, because it's a gross hack.
3545 3555 But it solves Arnd's problem for now...
3546 3556
3547 3557 2004-02-27 Fernando Perez <fperez@colorado.edu>
3548 3558
3549 3559 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3550 3560 mode would behave erratically. Also increased the number of
3551 3561 possible logs in rotate mod to 999. Thanks to Rod Holland
3552 3562 <rhh@StructureLABS.com> for the report and fixes.
3553 3563
3554 3564 2004-02-26 Fernando Perez <fperez@colorado.edu>
3555 3565
3556 3566 * IPython/genutils.py (page): Check that the curses module really
3557 3567 has the initscr attribute before trying to use it. For some
3558 3568 reason, the Solaris curses module is missing this. I think this
3559 3569 should be considered a Solaris python bug, but I'm not sure.
3560 3570
3561 3571 2004-01-17 Fernando Perez <fperez@colorado.edu>
3562 3572
3563 3573 * IPython/genutils.py (Stream.__init__): Changes to try to make
3564 3574 ipython robust against stdin/out/err being closed by the user.
3565 3575 This is 'user error' (and blocks a normal python session, at least
3566 3576 the stdout case). However, Ipython should be able to survive such
3567 3577 instances of abuse as gracefully as possible. To simplify the
3568 3578 coding and maintain compatibility with Gary Bishop's Term
3569 3579 contributions, I've made use of classmethods for this. I think
3570 3580 this introduces a dependency on python 2.2.
3571 3581
3572 3582 2004-01-13 Fernando Perez <fperez@colorado.edu>
3573 3583
3574 3584 * IPython/numutils.py (exp_safe): simplified the code a bit and
3575 3585 removed the need for importing the kinds module altogether.
3576 3586
3577 3587 2004-01-06 Fernando Perez <fperez@colorado.edu>
3578 3588
3579 3589 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3580 3590 a magic function instead, after some community feedback. No
3581 3591 special syntax will exist for it, but its name is deliberately
3582 3592 very short.
3583 3593
3584 3594 2003-12-20 Fernando Perez <fperez@colorado.edu>
3585 3595
3586 3596 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3587 3597 new functionality, to automagically assign the result of a shell
3588 3598 command to a variable. I'll solicit some community feedback on
3589 3599 this before making it permanent.
3590 3600
3591 3601 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3592 3602 requested about callables for which inspect couldn't obtain a
3593 3603 proper argspec. Thanks to a crash report sent by Etienne
3594 3604 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3595 3605
3596 3606 2003-12-09 Fernando Perez <fperez@colorado.edu>
3597 3607
3598 3608 * IPython/genutils.py (page): patch for the pager to work across
3599 3609 various versions of Windows. By Gary Bishop.
3600 3610
3601 3611 2003-12-04 Fernando Perez <fperez@colorado.edu>
3602 3612
3603 3613 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3604 3614 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3605 3615 While I tested this and it looks ok, there may still be corner
3606 3616 cases I've missed.
3607 3617
3608 3618 2003-12-01 Fernando Perez <fperez@colorado.edu>
3609 3619
3610 3620 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3611 3621 where a line like 'p,q=1,2' would fail because the automagic
3612 3622 system would be triggered for @p.
3613 3623
3614 3624 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3615 3625 cleanups, code unmodified.
3616 3626
3617 3627 * IPython/genutils.py (Term): added a class for IPython to handle
3618 3628 output. In most cases it will just be a proxy for stdout/err, but
3619 3629 having this allows modifications to be made for some platforms,
3620 3630 such as handling color escapes under Windows. All of this code
3621 3631 was contributed by Gary Bishop, with minor modifications by me.
3622 3632 The actual changes affect many files.
3623 3633
3624 3634 2003-11-30 Fernando Perez <fperez@colorado.edu>
3625 3635
3626 3636 * IPython/iplib.py (file_matches): new completion code, courtesy
3627 3637 of Jeff Collins. This enables filename completion again under
3628 3638 python 2.3, which disabled it at the C level.
3629 3639
3630 3640 2003-11-11 Fernando Perez <fperez@colorado.edu>
3631 3641
3632 3642 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3633 3643 for Numeric.array(map(...)), but often convenient.
3634 3644
3635 3645 2003-11-05 Fernando Perez <fperez@colorado.edu>
3636 3646
3637 3647 * IPython/numutils.py (frange): Changed a call from int() to
3638 3648 int(round()) to prevent a problem reported with arange() in the
3639 3649 numpy list.
3640 3650
3641 3651 2003-10-06 Fernando Perez <fperez@colorado.edu>
3642 3652
3643 3653 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3644 3654 prevent crashes if sys lacks an argv attribute (it happens with
3645 3655 embedded interpreters which build a bare-bones sys module).
3646 3656 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3647 3657
3648 3658 2003-09-24 Fernando Perez <fperez@colorado.edu>
3649 3659
3650 3660 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3651 3661 to protect against poorly written user objects where __getattr__
3652 3662 raises exceptions other than AttributeError. Thanks to a bug
3653 3663 report by Oliver Sander <osander-AT-gmx.de>.
3654 3664
3655 3665 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3656 3666 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3657 3667
3658 3668 2003-09-09 Fernando Perez <fperez@colorado.edu>
3659 3669
3660 3670 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3661 3671 unpacking a list whith a callable as first element would
3662 3672 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3663 3673 Collins.
3664 3674
3665 3675 2003-08-25 *** Released version 0.5.0
3666 3676
3667 3677 2003-08-22 Fernando Perez <fperez@colorado.edu>
3668 3678
3669 3679 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3670 3680 improperly defined user exceptions. Thanks to feedback from Mark
3671 3681 Russell <mrussell-AT-verio.net>.
3672 3682
3673 3683 2003-08-20 Fernando Perez <fperez@colorado.edu>
3674 3684
3675 3685 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3676 3686 printing so that it would print multi-line string forms starting
3677 3687 with a new line. This way the formatting is better respected for
3678 3688 objects which work hard to make nice string forms.
3679 3689
3680 3690 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3681 3691 autocall would overtake data access for objects with both
3682 3692 __getitem__ and __call__.
3683 3693
3684 3694 2003-08-19 *** Released version 0.5.0-rc1
3685 3695
3686 3696 2003-08-19 Fernando Perez <fperez@colorado.edu>
3687 3697
3688 3698 * IPython/deep_reload.py (load_tail): single tiny change here
3689 3699 seems to fix the long-standing bug of dreload() failing to work
3690 3700 for dotted names. But this module is pretty tricky, so I may have
3691 3701 missed some subtlety. Needs more testing!.
3692 3702
3693 3703 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3694 3704 exceptions which have badly implemented __str__ methods.
3695 3705 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3696 3706 which I've been getting reports about from Python 2.3 users. I
3697 3707 wish I had a simple test case to reproduce the problem, so I could
3698 3708 either write a cleaner workaround or file a bug report if
3699 3709 necessary.
3700 3710
3701 3711 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3702 3712 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3703 3713 a bug report by Tjabo Kloppenburg.
3704 3714
3705 3715 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3706 3716 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3707 3717 seems rather unstable. Thanks to a bug report by Tjabo
3708 3718 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3709 3719
3710 3720 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3711 3721 this out soon because of the critical fixes in the inner loop for
3712 3722 generators.
3713 3723
3714 3724 * IPython/Magic.py (Magic.getargspec): removed. This (and
3715 3725 _get_def) have been obsoleted by OInspect for a long time, I
3716 3726 hadn't noticed that they were dead code.
3717 3727 (Magic._ofind): restored _ofind functionality for a few literals
3718 3728 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3719 3729 for things like "hello".capitalize?, since that would require a
3720 3730 potentially dangerous eval() again.
3721 3731
3722 3732 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3723 3733 logic a bit more to clean up the escapes handling and minimize the
3724 3734 use of _ofind to only necessary cases. The interactive 'feel' of
3725 3735 IPython should have improved quite a bit with the changes in
3726 3736 _prefilter and _ofind (besides being far safer than before).
3727 3737
3728 3738 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3729 3739 obscure, never reported). Edit would fail to find the object to
3730 3740 edit under some circumstances.
3731 3741 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3732 3742 which were causing double-calling of generators. Those eval calls
3733 3743 were _very_ dangerous, since code with side effects could be
3734 3744 triggered. As they say, 'eval is evil'... These were the
3735 3745 nastiest evals in IPython. Besides, _ofind is now far simpler,
3736 3746 and it should also be quite a bit faster. Its use of inspect is
3737 3747 also safer, so perhaps some of the inspect-related crashes I've
3738 3748 seen lately with Python 2.3 might be taken care of. That will
3739 3749 need more testing.
3740 3750
3741 3751 2003-08-17 Fernando Perez <fperez@colorado.edu>
3742 3752
3743 3753 * IPython/iplib.py (InteractiveShell._prefilter): significant
3744 3754 simplifications to the logic for handling user escapes. Faster
3745 3755 and simpler code.
3746 3756
3747 3757 2003-08-14 Fernando Perez <fperez@colorado.edu>
3748 3758
3749 3759 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3750 3760 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3751 3761 but it should be quite a bit faster. And the recursive version
3752 3762 generated O(log N) intermediate storage for all rank>1 arrays,
3753 3763 even if they were contiguous.
3754 3764 (l1norm): Added this function.
3755 3765 (norm): Added this function for arbitrary norms (including
3756 3766 l-infinity). l1 and l2 are still special cases for convenience
3757 3767 and speed.
3758 3768
3759 3769 2003-08-03 Fernando Perez <fperez@colorado.edu>
3760 3770
3761 3771 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3762 3772 exceptions, which now raise PendingDeprecationWarnings in Python
3763 3773 2.3. There were some in Magic and some in Gnuplot2.
3764 3774
3765 3775 2003-06-30 Fernando Perez <fperez@colorado.edu>
3766 3776
3767 3777 * IPython/genutils.py (page): modified to call curses only for
3768 3778 terminals where TERM=='xterm'. After problems under many other
3769 3779 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3770 3780
3771 3781 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3772 3782 would be triggered when readline was absent. This was just an old
3773 3783 debugging statement I'd forgotten to take out.
3774 3784
3775 3785 2003-06-20 Fernando Perez <fperez@colorado.edu>
3776 3786
3777 3787 * IPython/genutils.py (clock): modified to return only user time
3778 3788 (not counting system time), after a discussion on scipy. While
3779 3789 system time may be a useful quantity occasionally, it may much
3780 3790 more easily be skewed by occasional swapping or other similar
3781 3791 activity.
3782 3792
3783 3793 2003-06-05 Fernando Perez <fperez@colorado.edu>
3784 3794
3785 3795 * IPython/numutils.py (identity): new function, for building
3786 3796 arbitrary rank Kronecker deltas (mostly backwards compatible with
3787 3797 Numeric.identity)
3788 3798
3789 3799 2003-06-03 Fernando Perez <fperez@colorado.edu>
3790 3800
3791 3801 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3792 3802 arguments passed to magics with spaces, to allow trailing '\' to
3793 3803 work normally (mainly for Windows users).
3794 3804
3795 3805 2003-05-29 Fernando Perez <fperez@colorado.edu>
3796 3806
3797 3807 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3798 3808 instead of pydoc.help. This fixes a bizarre behavior where
3799 3809 printing '%s' % locals() would trigger the help system. Now
3800 3810 ipython behaves like normal python does.
3801 3811
3802 3812 Note that if one does 'from pydoc import help', the bizarre
3803 3813 behavior returns, but this will also happen in normal python, so
3804 3814 it's not an ipython bug anymore (it has to do with how pydoc.help
3805 3815 is implemented).
3806 3816
3807 3817 2003-05-22 Fernando Perez <fperez@colorado.edu>
3808 3818
3809 3819 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3810 3820 return [] instead of None when nothing matches, also match to end
3811 3821 of line. Patch by Gary Bishop.
3812 3822
3813 3823 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3814 3824 protection as before, for files passed on the command line. This
3815 3825 prevents the CrashHandler from kicking in if user files call into
3816 3826 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3817 3827 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3818 3828
3819 3829 2003-05-20 *** Released version 0.4.0
3820 3830
3821 3831 2003-05-20 Fernando Perez <fperez@colorado.edu>
3822 3832
3823 3833 * setup.py: added support for manpages. It's a bit hackish b/c of
3824 3834 a bug in the way the bdist_rpm distutils target handles gzipped
3825 3835 manpages, but it works. After a patch by Jack.
3826 3836
3827 3837 2003-05-19 Fernando Perez <fperez@colorado.edu>
3828 3838
3829 3839 * IPython/numutils.py: added a mockup of the kinds module, since
3830 3840 it was recently removed from Numeric. This way, numutils will
3831 3841 work for all users even if they are missing kinds.
3832 3842
3833 3843 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3834 3844 failure, which can occur with SWIG-wrapped extensions. After a
3835 3845 crash report from Prabhu.
3836 3846
3837 3847 2003-05-16 Fernando Perez <fperez@colorado.edu>
3838 3848
3839 3849 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3840 3850 protect ipython from user code which may call directly
3841 3851 sys.excepthook (this looks like an ipython crash to the user, even
3842 3852 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3843 3853 This is especially important to help users of WxWindows, but may
3844 3854 also be useful in other cases.
3845 3855
3846 3856 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3847 3857 an optional tb_offset to be specified, and to preserve exception
3848 3858 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3849 3859
3850 3860 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3851 3861
3852 3862 2003-05-15 Fernando Perez <fperez@colorado.edu>
3853 3863
3854 3864 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3855 3865 installing for a new user under Windows.
3856 3866
3857 3867 2003-05-12 Fernando Perez <fperez@colorado.edu>
3858 3868
3859 3869 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3860 3870 handler for Emacs comint-based lines. Currently it doesn't do
3861 3871 much (but importantly, it doesn't update the history cache). In
3862 3872 the future it may be expanded if Alex needs more functionality
3863 3873 there.
3864 3874
3865 3875 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3866 3876 info to crash reports.
3867 3877
3868 3878 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3869 3879 just like Python's -c. Also fixed crash with invalid -color
3870 3880 option value at startup. Thanks to Will French
3871 3881 <wfrench-AT-bestweb.net> for the bug report.
3872 3882
3873 3883 2003-05-09 Fernando Perez <fperez@colorado.edu>
3874 3884
3875 3885 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3876 3886 to EvalDict (it's a mapping, after all) and simplified its code
3877 3887 quite a bit, after a nice discussion on c.l.py where Gustavo
3878 3888 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3879 3889
3880 3890 2003-04-30 Fernando Perez <fperez@colorado.edu>
3881 3891
3882 3892 * IPython/genutils.py (timings_out): modified it to reduce its
3883 3893 overhead in the common reps==1 case.
3884 3894
3885 3895 2003-04-29 Fernando Perez <fperez@colorado.edu>
3886 3896
3887 3897 * IPython/genutils.py (timings_out): Modified to use the resource
3888 3898 module, which avoids the wraparound problems of time.clock().
3889 3899
3890 3900 2003-04-17 *** Released version 0.2.15pre4
3891 3901
3892 3902 2003-04-17 Fernando Perez <fperez@colorado.edu>
3893 3903
3894 3904 * setup.py (scriptfiles): Split windows-specific stuff over to a
3895 3905 separate file, in an attempt to have a Windows GUI installer.
3896 3906 That didn't work, but part of the groundwork is done.
3897 3907
3898 3908 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3899 3909 indent/unindent with 4 spaces. Particularly useful in combination
3900 3910 with the new auto-indent option.
3901 3911
3902 3912 2003-04-16 Fernando Perez <fperez@colorado.edu>
3903 3913
3904 3914 * IPython/Magic.py: various replacements of self.rc for
3905 3915 self.shell.rc. A lot more remains to be done to fully disentangle
3906 3916 this class from the main Shell class.
3907 3917
3908 3918 * IPython/GnuplotRuntime.py: added checks for mouse support so
3909 3919 that we don't try to enable it if the current gnuplot doesn't
3910 3920 really support it. Also added checks so that we don't try to
3911 3921 enable persist under Windows (where Gnuplot doesn't recognize the
3912 3922 option).
3913 3923
3914 3924 * IPython/iplib.py (InteractiveShell.interact): Added optional
3915 3925 auto-indenting code, after a patch by King C. Shu
3916 3926 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3917 3927 get along well with pasting indented code. If I ever figure out
3918 3928 how to make that part go well, it will become on by default.
3919 3929
3920 3930 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3921 3931 crash ipython if there was an unmatched '%' in the user's prompt
3922 3932 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3923 3933
3924 3934 * IPython/iplib.py (InteractiveShell.interact): removed the
3925 3935 ability to ask the user whether he wants to crash or not at the
3926 3936 'last line' exception handler. Calling functions at that point
3927 3937 changes the stack, and the error reports would have incorrect
3928 3938 tracebacks.
3929 3939
3930 3940 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3931 3941 pass through a peger a pretty-printed form of any object. After a
3932 3942 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3933 3943
3934 3944 2003-04-14 Fernando Perez <fperez@colorado.edu>
3935 3945
3936 3946 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3937 3947 all files in ~ would be modified at first install (instead of
3938 3948 ~/.ipython). This could be potentially disastrous, as the
3939 3949 modification (make line-endings native) could damage binary files.
3940 3950
3941 3951 2003-04-10 Fernando Perez <fperez@colorado.edu>
3942 3952
3943 3953 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3944 3954 handle only lines which are invalid python. This now means that
3945 3955 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3946 3956 for the bug report.
3947 3957
3948 3958 2003-04-01 Fernando Perez <fperez@colorado.edu>
3949 3959
3950 3960 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3951 3961 where failing to set sys.last_traceback would crash pdb.pm().
3952 3962 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3953 3963 report.
3954 3964
3955 3965 2003-03-25 Fernando Perez <fperez@colorado.edu>
3956 3966
3957 3967 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3958 3968 before printing it (it had a lot of spurious blank lines at the
3959 3969 end).
3960 3970
3961 3971 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3962 3972 output would be sent 21 times! Obviously people don't use this
3963 3973 too often, or I would have heard about it.
3964 3974
3965 3975 2003-03-24 Fernando Perez <fperez@colorado.edu>
3966 3976
3967 3977 * setup.py (scriptfiles): renamed the data_files parameter from
3968 3978 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3969 3979 for the patch.
3970 3980
3971 3981 2003-03-20 Fernando Perez <fperez@colorado.edu>
3972 3982
3973 3983 * IPython/genutils.py (error): added error() and fatal()
3974 3984 functions.
3975 3985
3976 3986 2003-03-18 *** Released version 0.2.15pre3
3977 3987
3978 3988 2003-03-18 Fernando Perez <fperez@colorado.edu>
3979 3989
3980 3990 * setupext/install_data_ext.py
3981 3991 (install_data_ext.initialize_options): Class contributed by Jack
3982 3992 Moffit for fixing the old distutils hack. He is sending this to
3983 3993 the distutils folks so in the future we may not need it as a
3984 3994 private fix.
3985 3995
3986 3996 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3987 3997 changes for Debian packaging. See his patch for full details.
3988 3998 The old distutils hack of making the ipythonrc* files carry a
3989 3999 bogus .py extension is gone, at last. Examples were moved to a
3990 4000 separate subdir under doc/, and the separate executable scripts
3991 4001 now live in their own directory. Overall a great cleanup. The
3992 4002 manual was updated to use the new files, and setup.py has been
3993 4003 fixed for this setup.
3994 4004
3995 4005 * IPython/PyColorize.py (Parser.usage): made non-executable and
3996 4006 created a pycolor wrapper around it to be included as a script.
3997 4007
3998 4008 2003-03-12 *** Released version 0.2.15pre2
3999 4009
4000 4010 2003-03-12 Fernando Perez <fperez@colorado.edu>
4001 4011
4002 4012 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4003 4013 long-standing problem with garbage characters in some terminals.
4004 4014 The issue was really that the \001 and \002 escapes must _only_ be
4005 4015 passed to input prompts (which call readline), but _never_ to
4006 4016 normal text to be printed on screen. I changed ColorANSI to have
4007 4017 two classes: TermColors and InputTermColors, each with the
4008 4018 appropriate escapes for input prompts or normal text. The code in
4009 4019 Prompts.py got slightly more complicated, but this very old and
4010 4020 annoying bug is finally fixed.
4011 4021
4012 4022 All the credit for nailing down the real origin of this problem
4013 4023 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4014 4024 *Many* thanks to him for spending quite a bit of effort on this.
4015 4025
4016 4026 2003-03-05 *** Released version 0.2.15pre1
4017 4027
4018 4028 2003-03-03 Fernando Perez <fperez@colorado.edu>
4019 4029
4020 4030 * IPython/FakeModule.py: Moved the former _FakeModule to a
4021 4031 separate file, because it's also needed by Magic (to fix a similar
4022 4032 pickle-related issue in @run).
4023 4033
4024 4034 2003-03-02 Fernando Perez <fperez@colorado.edu>
4025 4035
4026 4036 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4027 4037 the autocall option at runtime.
4028 4038 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4029 4039 across Magic.py to start separating Magic from InteractiveShell.
4030 4040 (Magic._ofind): Fixed to return proper namespace for dotted
4031 4041 names. Before, a dotted name would always return 'not currently
4032 4042 defined', because it would find the 'parent'. s.x would be found,
4033 4043 but since 'x' isn't defined by itself, it would get confused.
4034 4044 (Magic.magic_run): Fixed pickling problems reported by Ralf
4035 4045 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4036 4046 that I'd used when Mike Heeter reported similar issues at the
4037 4047 top-level, but now for @run. It boils down to injecting the
4038 4048 namespace where code is being executed with something that looks
4039 4049 enough like a module to fool pickle.dump(). Since a pickle stores
4040 4050 a named reference to the importing module, we need this for
4041 4051 pickles to save something sensible.
4042 4052
4043 4053 * IPython/ipmaker.py (make_IPython): added an autocall option.
4044 4054
4045 4055 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4046 4056 the auto-eval code. Now autocalling is an option, and the code is
4047 4057 also vastly safer. There is no more eval() involved at all.
4048 4058
4049 4059 2003-03-01 Fernando Perez <fperez@colorado.edu>
4050 4060
4051 4061 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4052 4062 dict with named keys instead of a tuple.
4053 4063
4054 4064 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4055 4065
4056 4066 * setup.py (make_shortcut): Fixed message about directories
4057 4067 created during Windows installation (the directories were ok, just
4058 4068 the printed message was misleading). Thanks to Chris Liechti
4059 4069 <cliechti-AT-gmx.net> for the heads up.
4060 4070
4061 4071 2003-02-21 Fernando Perez <fperez@colorado.edu>
4062 4072
4063 4073 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4064 4074 of ValueError exception when checking for auto-execution. This
4065 4075 one is raised by things like Numeric arrays arr.flat when the
4066 4076 array is non-contiguous.
4067 4077
4068 4078 2003-01-31 Fernando Perez <fperez@colorado.edu>
4069 4079
4070 4080 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4071 4081 not return any value at all (even though the command would get
4072 4082 executed).
4073 4083 (xsys): Flush stdout right after printing the command to ensure
4074 4084 proper ordering of commands and command output in the total
4075 4085 output.
4076 4086 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4077 4087 system/getoutput as defaults. The old ones are kept for
4078 4088 compatibility reasons, so no code which uses this library needs
4079 4089 changing.
4080 4090
4081 4091 2003-01-27 *** Released version 0.2.14
4082 4092
4083 4093 2003-01-25 Fernando Perez <fperez@colorado.edu>
4084 4094
4085 4095 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4086 4096 functions defined in previous edit sessions could not be re-edited
4087 4097 (because the temp files were immediately removed). Now temp files
4088 4098 are removed only at IPython's exit.
4089 4099 (Magic.magic_run): Improved @run to perform shell-like expansions
4090 4100 on its arguments (~users and $VARS). With this, @run becomes more
4091 4101 like a normal command-line.
4092 4102
4093 4103 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4094 4104 bugs related to embedding and cleaned up that code. A fairly
4095 4105 important one was the impossibility to access the global namespace
4096 4106 through the embedded IPython (only local variables were visible).
4097 4107
4098 4108 2003-01-14 Fernando Perez <fperez@colorado.edu>
4099 4109
4100 4110 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4101 4111 auto-calling to be a bit more conservative. Now it doesn't get
4102 4112 triggered if any of '!=()<>' are in the rest of the input line, to
4103 4113 allow comparing callables. Thanks to Alex for the heads up.
4104 4114
4105 4115 2003-01-07 Fernando Perez <fperez@colorado.edu>
4106 4116
4107 4117 * IPython/genutils.py (page): fixed estimation of the number of
4108 4118 lines in a string to be paged to simply count newlines. This
4109 4119 prevents over-guessing due to embedded escape sequences. A better
4110 4120 long-term solution would involve stripping out the control chars
4111 4121 for the count, but it's potentially so expensive I just don't
4112 4122 think it's worth doing.
4113 4123
4114 4124 2002-12-19 *** Released version 0.2.14pre50
4115 4125
4116 4126 2002-12-19 Fernando Perez <fperez@colorado.edu>
4117 4127
4118 4128 * tools/release (version): Changed release scripts to inform
4119 4129 Andrea and build a NEWS file with a list of recent changes.
4120 4130
4121 4131 * IPython/ColorANSI.py (__all__): changed terminal detection
4122 4132 code. Seems to work better for xterms without breaking
4123 4133 konsole. Will need more testing to determine if WinXP and Mac OSX
4124 4134 also work ok.
4125 4135
4126 4136 2002-12-18 *** Released version 0.2.14pre49
4127 4137
4128 4138 2002-12-18 Fernando Perez <fperez@colorado.edu>
4129 4139
4130 4140 * Docs: added new info about Mac OSX, from Andrea.
4131 4141
4132 4142 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4133 4143 allow direct plotting of python strings whose format is the same
4134 4144 of gnuplot data files.
4135 4145
4136 4146 2002-12-16 Fernando Perez <fperez@colorado.edu>
4137 4147
4138 4148 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4139 4149 value of exit question to be acknowledged.
4140 4150
4141 4151 2002-12-03 Fernando Perez <fperez@colorado.edu>
4142 4152
4143 4153 * IPython/ipmaker.py: removed generators, which had been added
4144 4154 by mistake in an earlier debugging run. This was causing trouble
4145 4155 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4146 4156 for pointing this out.
4147 4157
4148 4158 2002-11-17 Fernando Perez <fperez@colorado.edu>
4149 4159
4150 4160 * Manual: updated the Gnuplot section.
4151 4161
4152 4162 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4153 4163 a much better split of what goes in Runtime and what goes in
4154 4164 Interactive.
4155 4165
4156 4166 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4157 4167 being imported from iplib.
4158 4168
4159 4169 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4160 4170 for command-passing. Now the global Gnuplot instance is called
4161 4171 'gp' instead of 'g', which was really a far too fragile and
4162 4172 common name.
4163 4173
4164 4174 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4165 4175 bounding boxes generated by Gnuplot for square plots.
4166 4176
4167 4177 * IPython/genutils.py (popkey): new function added. I should
4168 4178 suggest this on c.l.py as a dict method, it seems useful.
4169 4179
4170 4180 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4171 4181 to transparently handle PostScript generation. MUCH better than
4172 4182 the previous plot_eps/replot_eps (which I removed now). The code
4173 4183 is also fairly clean and well documented now (including
4174 4184 docstrings).
4175 4185
4176 4186 2002-11-13 Fernando Perez <fperez@colorado.edu>
4177 4187
4178 4188 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4179 4189 (inconsistent with options).
4180 4190
4181 4191 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4182 4192 manually disabled, I don't know why. Fixed it.
4183 4193 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4184 4194 eps output.
4185 4195
4186 4196 2002-11-12 Fernando Perez <fperez@colorado.edu>
4187 4197
4188 4198 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4189 4199 don't propagate up to caller. Fixes crash reported by François
4190 4200 Pinard.
4191 4201
4192 4202 2002-11-09 Fernando Perez <fperez@colorado.edu>
4193 4203
4194 4204 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4195 4205 history file for new users.
4196 4206 (make_IPython): fixed bug where initial install would leave the
4197 4207 user running in the .ipython dir.
4198 4208 (make_IPython): fixed bug where config dir .ipython would be
4199 4209 created regardless of the given -ipythondir option. Thanks to Cory
4200 4210 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4201 4211
4202 4212 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4203 4213 type confirmations. Will need to use it in all of IPython's code
4204 4214 consistently.
4205 4215
4206 4216 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4207 4217 context to print 31 lines instead of the default 5. This will make
4208 4218 the crash reports extremely detailed in case the problem is in
4209 4219 libraries I don't have access to.
4210 4220
4211 4221 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4212 4222 line of defense' code to still crash, but giving users fair
4213 4223 warning. I don't want internal errors to go unreported: if there's
4214 4224 an internal problem, IPython should crash and generate a full
4215 4225 report.
4216 4226
4217 4227 2002-11-08 Fernando Perez <fperez@colorado.edu>
4218 4228
4219 4229 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4220 4230 otherwise uncaught exceptions which can appear if people set
4221 4231 sys.stdout to something badly broken. Thanks to a crash report
4222 4232 from henni-AT-mail.brainbot.com.
4223 4233
4224 4234 2002-11-04 Fernando Perez <fperez@colorado.edu>
4225 4235
4226 4236 * IPython/iplib.py (InteractiveShell.interact): added
4227 4237 __IPYTHON__active to the builtins. It's a flag which goes on when
4228 4238 the interaction starts and goes off again when it stops. This
4229 4239 allows embedding code to detect being inside IPython. Before this
4230 4240 was done via __IPYTHON__, but that only shows that an IPython
4231 4241 instance has been created.
4232 4242
4233 4243 * IPython/Magic.py (Magic.magic_env): I realized that in a
4234 4244 UserDict, instance.data holds the data as a normal dict. So I
4235 4245 modified @env to return os.environ.data instead of rebuilding a
4236 4246 dict by hand.
4237 4247
4238 4248 2002-11-02 Fernando Perez <fperez@colorado.edu>
4239 4249
4240 4250 * IPython/genutils.py (warn): changed so that level 1 prints no
4241 4251 header. Level 2 is now the default (with 'WARNING' header, as
4242 4252 before). I think I tracked all places where changes were needed in
4243 4253 IPython, but outside code using the old level numbering may have
4244 4254 broken.
4245 4255
4246 4256 * IPython/iplib.py (InteractiveShell.runcode): added this to
4247 4257 handle the tracebacks in SystemExit traps correctly. The previous
4248 4258 code (through interact) was printing more of the stack than
4249 4259 necessary, showing IPython internal code to the user.
4250 4260
4251 4261 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4252 4262 default. Now that the default at the confirmation prompt is yes,
4253 4263 it's not so intrusive. François' argument that ipython sessions
4254 4264 tend to be complex enough not to lose them from an accidental C-d,
4255 4265 is a valid one.
4256 4266
4257 4267 * IPython/iplib.py (InteractiveShell.interact): added a
4258 4268 showtraceback() call to the SystemExit trap, and modified the exit
4259 4269 confirmation to have yes as the default.
4260 4270
4261 4271 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4262 4272 this file. It's been gone from the code for a long time, this was
4263 4273 simply leftover junk.
4264 4274
4265 4275 2002-11-01 Fernando Perez <fperez@colorado.edu>
4266 4276
4267 4277 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4268 4278 added. If set, IPython now traps EOF and asks for
4269 4279 confirmation. After a request by François Pinard.
4270 4280
4271 4281 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4272 4282 of @abort, and with a new (better) mechanism for handling the
4273 4283 exceptions.
4274 4284
4275 4285 2002-10-27 Fernando Perez <fperez@colorado.edu>
4276 4286
4277 4287 * IPython/usage.py (__doc__): updated the --help information and
4278 4288 the ipythonrc file to indicate that -log generates
4279 4289 ./ipython.log. Also fixed the corresponding info in @logstart.
4280 4290 This and several other fixes in the manuals thanks to reports by
4281 4291 François Pinard <pinard-AT-iro.umontreal.ca>.
4282 4292
4283 4293 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4284 4294 refer to @logstart (instead of @log, which doesn't exist).
4285 4295
4286 4296 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4287 4297 AttributeError crash. Thanks to Christopher Armstrong
4288 4298 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4289 4299 introduced recently (in 0.2.14pre37) with the fix to the eval
4290 4300 problem mentioned below.
4291 4301
4292 4302 2002-10-17 Fernando Perez <fperez@colorado.edu>
4293 4303
4294 4304 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4295 4305 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4296 4306
4297 4307 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4298 4308 this function to fix a problem reported by Alex Schmolck. He saw
4299 4309 it with list comprehensions and generators, which were getting
4300 4310 called twice. The real problem was an 'eval' call in testing for
4301 4311 automagic which was evaluating the input line silently.
4302 4312
4303 4313 This is a potentially very nasty bug, if the input has side
4304 4314 effects which must not be repeated. The code is much cleaner now,
4305 4315 without any blanket 'except' left and with a regexp test for
4306 4316 actual function names.
4307 4317
4308 4318 But an eval remains, which I'm not fully comfortable with. I just
4309 4319 don't know how to find out if an expression could be a callable in
4310 4320 the user's namespace without doing an eval on the string. However
4311 4321 that string is now much more strictly checked so that no code
4312 4322 slips by, so the eval should only happen for things that can
4313 4323 really be only function/method names.
4314 4324
4315 4325 2002-10-15 Fernando Perez <fperez@colorado.edu>
4316 4326
4317 4327 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4318 4328 OSX information to main manual, removed README_Mac_OSX file from
4319 4329 distribution. Also updated credits for recent additions.
4320 4330
4321 4331 2002-10-10 Fernando Perez <fperez@colorado.edu>
4322 4332
4323 4333 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4324 4334 terminal-related issues. Many thanks to Andrea Riciputi
4325 4335 <andrea.riciputi-AT-libero.it> for writing it.
4326 4336
4327 4337 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4328 4338 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4329 4339
4330 4340 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4331 4341 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4332 4342 <syver-en-AT-online.no> who both submitted patches for this problem.
4333 4343
4334 4344 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4335 4345 global embedding to make sure that things don't overwrite user
4336 4346 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4337 4347
4338 4348 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4339 4349 compatibility. Thanks to Hayden Callow
4340 4350 <h.callow-AT-elec.canterbury.ac.nz>
4341 4351
4342 4352 2002-10-04 Fernando Perez <fperez@colorado.edu>
4343 4353
4344 4354 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4345 4355 Gnuplot.File objects.
4346 4356
4347 4357 2002-07-23 Fernando Perez <fperez@colorado.edu>
4348 4358
4349 4359 * IPython/genutils.py (timing): Added timings() and timing() for
4350 4360 quick access to the most commonly needed data, the execution
4351 4361 times. Old timing() renamed to timings_out().
4352 4362
4353 4363 2002-07-18 Fernando Perez <fperez@colorado.edu>
4354 4364
4355 4365 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4356 4366 bug with nested instances disrupting the parent's tab completion.
4357 4367
4358 4368 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4359 4369 all_completions code to begin the emacs integration.
4360 4370
4361 4371 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4362 4372 argument to allow titling individual arrays when plotting.
4363 4373
4364 4374 2002-07-15 Fernando Perez <fperez@colorado.edu>
4365 4375
4366 4376 * setup.py (make_shortcut): changed to retrieve the value of
4367 4377 'Program Files' directory from the registry (this value changes in
4368 4378 non-english versions of Windows). Thanks to Thomas Fanslau
4369 4379 <tfanslau-AT-gmx.de> for the report.
4370 4380
4371 4381 2002-07-10 Fernando Perez <fperez@colorado.edu>
4372 4382
4373 4383 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4374 4384 a bug in pdb, which crashes if a line with only whitespace is
4375 4385 entered. Bug report submitted to sourceforge.
4376 4386
4377 4387 2002-07-09 Fernando Perez <fperez@colorado.edu>
4378 4388
4379 4389 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4380 4390 reporting exceptions (it's a bug in inspect.py, I just set a
4381 4391 workaround).
4382 4392
4383 4393 2002-07-08 Fernando Perez <fperez@colorado.edu>
4384 4394
4385 4395 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4386 4396 __IPYTHON__ in __builtins__ to show up in user_ns.
4387 4397
4388 4398 2002-07-03 Fernando Perez <fperez@colorado.edu>
4389 4399
4390 4400 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4391 4401 name from @gp_set_instance to @gp_set_default.
4392 4402
4393 4403 * IPython/ipmaker.py (make_IPython): default editor value set to
4394 4404 '0' (a string), to match the rc file. Otherwise will crash when
4395 4405 .strip() is called on it.
4396 4406
4397 4407
4398 4408 2002-06-28 Fernando Perez <fperez@colorado.edu>
4399 4409
4400 4410 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4401 4411 of files in current directory when a file is executed via
4402 4412 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4403 4413
4404 4414 * setup.py (manfiles): fix for rpm builds, submitted by RA
4405 4415 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4406 4416
4407 4417 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4408 4418 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4409 4419 string!). A. Schmolck caught this one.
4410 4420
4411 4421 2002-06-27 Fernando Perez <fperez@colorado.edu>
4412 4422
4413 4423 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4414 4424 defined files at the cmd line. __name__ wasn't being set to
4415 4425 __main__.
4416 4426
4417 4427 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4418 4428 regular lists and tuples besides Numeric arrays.
4419 4429
4420 4430 * IPython/Prompts.py (CachedOutput.__call__): Added output
4421 4431 supression for input ending with ';'. Similar to Mathematica and
4422 4432 Matlab. The _* vars and Out[] list are still updated, just like
4423 4433 Mathematica behaves.
4424 4434
4425 4435 2002-06-25 Fernando Perez <fperez@colorado.edu>
4426 4436
4427 4437 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4428 4438 .ini extensions for profiels under Windows.
4429 4439
4430 4440 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4431 4441 string form. Fix contributed by Alexander Schmolck
4432 4442 <a.schmolck-AT-gmx.net>
4433 4443
4434 4444 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4435 4445 pre-configured Gnuplot instance.
4436 4446
4437 4447 2002-06-21 Fernando Perez <fperez@colorado.edu>
4438 4448
4439 4449 * IPython/numutils.py (exp_safe): new function, works around the
4440 4450 underflow problems in Numeric.
4441 4451 (log2): New fn. Safe log in base 2: returns exact integer answer
4442 4452 for exact integer powers of 2.
4443 4453
4444 4454 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4445 4455 properly.
4446 4456
4447 4457 2002-06-20 Fernando Perez <fperez@colorado.edu>
4448 4458
4449 4459 * IPython/genutils.py (timing): new function like
4450 4460 Mathematica's. Similar to time_test, but returns more info.
4451 4461
4452 4462 2002-06-18 Fernando Perez <fperez@colorado.edu>
4453 4463
4454 4464 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4455 4465 according to Mike Heeter's suggestions.
4456 4466
4457 4467 2002-06-16 Fernando Perez <fperez@colorado.edu>
4458 4468
4459 4469 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4460 4470 system. GnuplotMagic is gone as a user-directory option. New files
4461 4471 make it easier to use all the gnuplot stuff both from external
4462 4472 programs as well as from IPython. Had to rewrite part of
4463 4473 hardcopy() b/c of a strange bug: often the ps files simply don't
4464 4474 get created, and require a repeat of the command (often several
4465 4475 times).
4466 4476
4467 4477 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4468 4478 resolve output channel at call time, so that if sys.stderr has
4469 4479 been redirected by user this gets honored.
4470 4480
4471 4481 2002-06-13 Fernando Perez <fperez@colorado.edu>
4472 4482
4473 4483 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4474 4484 IPShell. Kept a copy with the old names to avoid breaking people's
4475 4485 embedded code.
4476 4486
4477 4487 * IPython/ipython: simplified it to the bare minimum after
4478 4488 Holger's suggestions. Added info about how to use it in
4479 4489 PYTHONSTARTUP.
4480 4490
4481 4491 * IPython/Shell.py (IPythonShell): changed the options passing
4482 4492 from a string with funky %s replacements to a straight list. Maybe
4483 4493 a bit more typing, but it follows sys.argv conventions, so there's
4484 4494 less special-casing to remember.
4485 4495
4486 4496 2002-06-12 Fernando Perez <fperez@colorado.edu>
4487 4497
4488 4498 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4489 4499 command. Thanks to a suggestion by Mike Heeter.
4490 4500 (Magic.magic_pfile): added behavior to look at filenames if given
4491 4501 arg is not a defined object.
4492 4502 (Magic.magic_save): New @save function to save code snippets. Also
4493 4503 a Mike Heeter idea.
4494 4504
4495 4505 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4496 4506 plot() and replot(). Much more convenient now, especially for
4497 4507 interactive use.
4498 4508
4499 4509 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4500 4510 filenames.
4501 4511
4502 4512 2002-06-02 Fernando Perez <fperez@colorado.edu>
4503 4513
4504 4514 * IPython/Struct.py (Struct.__init__): modified to admit
4505 4515 initialization via another struct.
4506 4516
4507 4517 * IPython/genutils.py (SystemExec.__init__): New stateful
4508 4518 interface to xsys and bq. Useful for writing system scripts.
4509 4519
4510 4520 2002-05-30 Fernando Perez <fperez@colorado.edu>
4511 4521
4512 4522 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4513 4523 documents. This will make the user download smaller (it's getting
4514 4524 too big).
4515 4525
4516 4526 2002-05-29 Fernando Perez <fperez@colorado.edu>
4517 4527
4518 4528 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4519 4529 fix problems with shelve and pickle. Seems to work, but I don't
4520 4530 know if corner cases break it. Thanks to Mike Heeter
4521 4531 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4522 4532
4523 4533 2002-05-24 Fernando Perez <fperez@colorado.edu>
4524 4534
4525 4535 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4526 4536 macros having broken.
4527 4537
4528 4538 2002-05-21 Fernando Perez <fperez@colorado.edu>
4529 4539
4530 4540 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4531 4541 introduced logging bug: all history before logging started was
4532 4542 being written one character per line! This came from the redesign
4533 4543 of the input history as a special list which slices to strings,
4534 4544 not to lists.
4535 4545
4536 4546 2002-05-20 Fernando Perez <fperez@colorado.edu>
4537 4547
4538 4548 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4539 4549 be an attribute of all classes in this module. The design of these
4540 4550 classes needs some serious overhauling.
4541 4551
4542 4552 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4543 4553 which was ignoring '_' in option names.
4544 4554
4545 4555 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4546 4556 'Verbose_novars' to 'Context' and made it the new default. It's a
4547 4557 bit more readable and also safer than verbose.
4548 4558
4549 4559 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4550 4560 triple-quoted strings.
4551 4561
4552 4562 * IPython/OInspect.py (__all__): new module exposing the object
4553 4563 introspection facilities. Now the corresponding magics are dummy
4554 4564 wrappers around this. Having this module will make it much easier
4555 4565 to put these functions into our modified pdb.
4556 4566 This new object inspector system uses the new colorizing module,
4557 4567 so source code and other things are nicely syntax highlighted.
4558 4568
4559 4569 2002-05-18 Fernando Perez <fperez@colorado.edu>
4560 4570
4561 4571 * IPython/ColorANSI.py: Split the coloring tools into a separate
4562 4572 module so I can use them in other code easier (they were part of
4563 4573 ultraTB).
4564 4574
4565 4575 2002-05-17 Fernando Perez <fperez@colorado.edu>
4566 4576
4567 4577 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4568 4578 fixed it to set the global 'g' also to the called instance, as
4569 4579 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4570 4580 user's 'g' variables).
4571 4581
4572 4582 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4573 4583 global variables (aliases to _ih,_oh) so that users which expect
4574 4584 In[5] or Out[7] to work aren't unpleasantly surprised.
4575 4585 (InputList.__getslice__): new class to allow executing slices of
4576 4586 input history directly. Very simple class, complements the use of
4577 4587 macros.
4578 4588
4579 4589 2002-05-16 Fernando Perez <fperez@colorado.edu>
4580 4590
4581 4591 * setup.py (docdirbase): make doc directory be just doc/IPython
4582 4592 without version numbers, it will reduce clutter for users.
4583 4593
4584 4594 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4585 4595 execfile call to prevent possible memory leak. See for details:
4586 4596 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4587 4597
4588 4598 2002-05-15 Fernando Perez <fperez@colorado.edu>
4589 4599
4590 4600 * IPython/Magic.py (Magic.magic_psource): made the object
4591 4601 introspection names be more standard: pdoc, pdef, pfile and
4592 4602 psource. They all print/page their output, and it makes
4593 4603 remembering them easier. Kept old names for compatibility as
4594 4604 aliases.
4595 4605
4596 4606 2002-05-14 Fernando Perez <fperez@colorado.edu>
4597 4607
4598 4608 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4599 4609 what the mouse problem was. The trick is to use gnuplot with temp
4600 4610 files and NOT with pipes (for data communication), because having
4601 4611 both pipes and the mouse on is bad news.
4602 4612
4603 4613 2002-05-13 Fernando Perez <fperez@colorado.edu>
4604 4614
4605 4615 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4606 4616 bug. Information would be reported about builtins even when
4607 4617 user-defined functions overrode them.
4608 4618
4609 4619 2002-05-11 Fernando Perez <fperez@colorado.edu>
4610 4620
4611 4621 * IPython/__init__.py (__all__): removed FlexCompleter from
4612 4622 __all__ so that things don't fail in platforms without readline.
4613 4623
4614 4624 2002-05-10 Fernando Perez <fperez@colorado.edu>
4615 4625
4616 4626 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4617 4627 it requires Numeric, effectively making Numeric a dependency for
4618 4628 IPython.
4619 4629
4620 4630 * Released 0.2.13
4621 4631
4622 4632 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4623 4633 profiler interface. Now all the major options from the profiler
4624 4634 module are directly supported in IPython, both for single
4625 4635 expressions (@prun) and for full programs (@run -p).
4626 4636
4627 4637 2002-05-09 Fernando Perez <fperez@colorado.edu>
4628 4638
4629 4639 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4630 4640 magic properly formatted for screen.
4631 4641
4632 4642 * setup.py (make_shortcut): Changed things to put pdf version in
4633 4643 doc/ instead of doc/manual (had to change lyxport a bit).
4634 4644
4635 4645 * IPython/Magic.py (Profile.string_stats): made profile runs go
4636 4646 through pager (they are long and a pager allows searching, saving,
4637 4647 etc.)
4638 4648
4639 4649 2002-05-08 Fernando Perez <fperez@colorado.edu>
4640 4650
4641 4651 * Released 0.2.12
4642 4652
4643 4653 2002-05-06 Fernando Perez <fperez@colorado.edu>
4644 4654
4645 4655 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4646 4656 introduced); 'hist n1 n2' was broken.
4647 4657 (Magic.magic_pdb): added optional on/off arguments to @pdb
4648 4658 (Magic.magic_run): added option -i to @run, which executes code in
4649 4659 the IPython namespace instead of a clean one. Also added @irun as
4650 4660 an alias to @run -i.
4651 4661
4652 4662 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4653 4663 fixed (it didn't really do anything, the namespaces were wrong).
4654 4664
4655 4665 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4656 4666
4657 4667 * IPython/__init__.py (__all__): Fixed package namespace, now
4658 4668 'import IPython' does give access to IPython.<all> as
4659 4669 expected. Also renamed __release__ to Release.
4660 4670
4661 4671 * IPython/Debugger.py (__license__): created new Pdb class which
4662 4672 functions like a drop-in for the normal pdb.Pdb but does NOT
4663 4673 import readline by default. This way it doesn't muck up IPython's
4664 4674 readline handling, and now tab-completion finally works in the
4665 4675 debugger -- sort of. It completes things globally visible, but the
4666 4676 completer doesn't track the stack as pdb walks it. That's a bit
4667 4677 tricky, and I'll have to implement it later.
4668 4678
4669 4679 2002-05-05 Fernando Perez <fperez@colorado.edu>
4670 4680
4671 4681 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4672 4682 magic docstrings when printed via ? (explicit \'s were being
4673 4683 printed).
4674 4684
4675 4685 * IPython/ipmaker.py (make_IPython): fixed namespace
4676 4686 identification bug. Now variables loaded via logs or command-line
4677 4687 files are recognized in the interactive namespace by @who.
4678 4688
4679 4689 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4680 4690 log replay system stemming from the string form of Structs.
4681 4691
4682 4692 * IPython/Magic.py (Macro.__init__): improved macros to properly
4683 4693 handle magic commands in them.
4684 4694 (Magic.magic_logstart): usernames are now expanded so 'logstart
4685 4695 ~/mylog' now works.
4686 4696
4687 4697 * IPython/iplib.py (complete): fixed bug where paths starting with
4688 4698 '/' would be completed as magic names.
4689 4699
4690 4700 2002-05-04 Fernando Perez <fperez@colorado.edu>
4691 4701
4692 4702 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4693 4703 allow running full programs under the profiler's control.
4694 4704
4695 4705 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4696 4706 mode to report exceptions verbosely but without formatting
4697 4707 variables. This addresses the issue of ipython 'freezing' (it's
4698 4708 not frozen, but caught in an expensive formatting loop) when huge
4699 4709 variables are in the context of an exception.
4700 4710 (VerboseTB.text): Added '--->' markers at line where exception was
4701 4711 triggered. Much clearer to read, especially in NoColor modes.
4702 4712
4703 4713 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4704 4714 implemented in reverse when changing to the new parse_options().
4705 4715
4706 4716 2002-05-03 Fernando Perez <fperez@colorado.edu>
4707 4717
4708 4718 * IPython/Magic.py (Magic.parse_options): new function so that
4709 4719 magics can parse options easier.
4710 4720 (Magic.magic_prun): new function similar to profile.run(),
4711 4721 suggested by Chris Hart.
4712 4722 (Magic.magic_cd): fixed behavior so that it only changes if
4713 4723 directory actually is in history.
4714 4724
4715 4725 * IPython/usage.py (__doc__): added information about potential
4716 4726 slowness of Verbose exception mode when there are huge data
4717 4727 structures to be formatted (thanks to Archie Paulson).
4718 4728
4719 4729 * IPython/ipmaker.py (make_IPython): Changed default logging
4720 4730 (when simply called with -log) to use curr_dir/ipython.log in
4721 4731 rotate mode. Fixed crash which was occuring with -log before
4722 4732 (thanks to Jim Boyle).
4723 4733
4724 4734 2002-05-01 Fernando Perez <fperez@colorado.edu>
4725 4735
4726 4736 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4727 4737 was nasty -- though somewhat of a corner case).
4728 4738
4729 4739 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4730 4740 text (was a bug).
4731 4741
4732 4742 2002-04-30 Fernando Perez <fperez@colorado.edu>
4733 4743
4734 4744 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4735 4745 a print after ^D or ^C from the user so that the In[] prompt
4736 4746 doesn't over-run the gnuplot one.
4737 4747
4738 4748 2002-04-29 Fernando Perez <fperez@colorado.edu>
4739 4749
4740 4750 * Released 0.2.10
4741 4751
4742 4752 * IPython/__release__.py (version): get date dynamically.
4743 4753
4744 4754 * Misc. documentation updates thanks to Arnd's comments. Also ran
4745 4755 a full spellcheck on the manual (hadn't been done in a while).
4746 4756
4747 4757 2002-04-27 Fernando Perez <fperez@colorado.edu>
4748 4758
4749 4759 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4750 4760 starting a log in mid-session would reset the input history list.
4751 4761
4752 4762 2002-04-26 Fernando Perez <fperez@colorado.edu>
4753 4763
4754 4764 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4755 4765 all files were being included in an update. Now anything in
4756 4766 UserConfig that matches [A-Za-z]*.py will go (this excludes
4757 4767 __init__.py)
4758 4768
4759 4769 2002-04-25 Fernando Perez <fperez@colorado.edu>
4760 4770
4761 4771 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4762 4772 to __builtins__ so that any form of embedded or imported code can
4763 4773 test for being inside IPython.
4764 4774
4765 4775 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4766 4776 changed to GnuplotMagic because it's now an importable module,
4767 4777 this makes the name follow that of the standard Gnuplot module.
4768 4778 GnuplotMagic can now be loaded at any time in mid-session.
4769 4779
4770 4780 2002-04-24 Fernando Perez <fperez@colorado.edu>
4771 4781
4772 4782 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4773 4783 the globals (IPython has its own namespace) and the
4774 4784 PhysicalQuantity stuff is much better anyway.
4775 4785
4776 4786 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4777 4787 embedding example to standard user directory for
4778 4788 distribution. Also put it in the manual.
4779 4789
4780 4790 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4781 4791 instance as first argument (so it doesn't rely on some obscure
4782 4792 hidden global).
4783 4793
4784 4794 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4785 4795 delimiters. While it prevents ().TAB from working, it allows
4786 4796 completions in open (... expressions. This is by far a more common
4787 4797 case.
4788 4798
4789 4799 2002-04-23 Fernando Perez <fperez@colorado.edu>
4790 4800
4791 4801 * IPython/Extensions/InterpreterPasteInput.py: new
4792 4802 syntax-processing module for pasting lines with >>> or ... at the
4793 4803 start.
4794 4804
4795 4805 * IPython/Extensions/PhysicalQ_Interactive.py
4796 4806 (PhysicalQuantityInteractive.__int__): fixed to work with either
4797 4807 Numeric or math.
4798 4808
4799 4809 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4800 4810 provided profiles. Now we have:
4801 4811 -math -> math module as * and cmath with its own namespace.
4802 4812 -numeric -> Numeric as *, plus gnuplot & grace
4803 4813 -physics -> same as before
4804 4814
4805 4815 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4806 4816 user-defined magics wouldn't be found by @magic if they were
4807 4817 defined as class methods. Also cleaned up the namespace search
4808 4818 logic and the string building (to use %s instead of many repeated
4809 4819 string adds).
4810 4820
4811 4821 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4812 4822 of user-defined magics to operate with class methods (cleaner, in
4813 4823 line with the gnuplot code).
4814 4824
4815 4825 2002-04-22 Fernando Perez <fperez@colorado.edu>
4816 4826
4817 4827 * setup.py: updated dependency list so that manual is updated when
4818 4828 all included files change.
4819 4829
4820 4830 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4821 4831 the delimiter removal option (the fix is ugly right now).
4822 4832
4823 4833 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4824 4834 all of the math profile (quicker loading, no conflict between
4825 4835 g-9.8 and g-gnuplot).
4826 4836
4827 4837 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4828 4838 name of post-mortem files to IPython_crash_report.txt.
4829 4839
4830 4840 * Cleanup/update of the docs. Added all the new readline info and
4831 4841 formatted all lists as 'real lists'.
4832 4842
4833 4843 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4834 4844 tab-completion options, since the full readline parse_and_bind is
4835 4845 now accessible.
4836 4846
4837 4847 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4838 4848 handling of readline options. Now users can specify any string to
4839 4849 be passed to parse_and_bind(), as well as the delimiters to be
4840 4850 removed.
4841 4851 (InteractiveShell.__init__): Added __name__ to the global
4842 4852 namespace so that things like Itpl which rely on its existence
4843 4853 don't crash.
4844 4854 (InteractiveShell._prefilter): Defined the default with a _ so
4845 4855 that prefilter() is easier to override, while the default one
4846 4856 remains available.
4847 4857
4848 4858 2002-04-18 Fernando Perez <fperez@colorado.edu>
4849 4859
4850 4860 * Added information about pdb in the docs.
4851 4861
4852 4862 2002-04-17 Fernando Perez <fperez@colorado.edu>
4853 4863
4854 4864 * IPython/ipmaker.py (make_IPython): added rc_override option to
4855 4865 allow passing config options at creation time which may override
4856 4866 anything set in the config files or command line. This is
4857 4867 particularly useful for configuring embedded instances.
4858 4868
4859 4869 2002-04-15 Fernando Perez <fperez@colorado.edu>
4860 4870
4861 4871 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4862 4872 crash embedded instances because of the input cache falling out of
4863 4873 sync with the output counter.
4864 4874
4865 4875 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4866 4876 mode which calls pdb after an uncaught exception in IPython itself.
4867 4877
4868 4878 2002-04-14 Fernando Perez <fperez@colorado.edu>
4869 4879
4870 4880 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4871 4881 readline, fix it back after each call.
4872 4882
4873 4883 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4874 4884 method to force all access via __call__(), which guarantees that
4875 4885 traceback references are properly deleted.
4876 4886
4877 4887 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4878 4888 improve printing when pprint is in use.
4879 4889
4880 4890 2002-04-13 Fernando Perez <fperez@colorado.edu>
4881 4891
4882 4892 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4883 4893 exceptions aren't caught anymore. If the user triggers one, he
4884 4894 should know why he's doing it and it should go all the way up,
4885 4895 just like any other exception. So now @abort will fully kill the
4886 4896 embedded interpreter and the embedding code (unless that happens
4887 4897 to catch SystemExit).
4888 4898
4889 4899 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4890 4900 and a debugger() method to invoke the interactive pdb debugger
4891 4901 after printing exception information. Also added the corresponding
4892 4902 -pdb option and @pdb magic to control this feature, and updated
4893 4903 the docs. After a suggestion from Christopher Hart
4894 4904 (hart-AT-caltech.edu).
4895 4905
4896 4906 2002-04-12 Fernando Perez <fperez@colorado.edu>
4897 4907
4898 4908 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4899 4909 the exception handlers defined by the user (not the CrashHandler)
4900 4910 so that user exceptions don't trigger an ipython bug report.
4901 4911
4902 4912 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4903 4913 configurable (it should have always been so).
4904 4914
4905 4915 2002-03-26 Fernando Perez <fperez@colorado.edu>
4906 4916
4907 4917 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4908 4918 and there to fix embedding namespace issues. This should all be
4909 4919 done in a more elegant way.
4910 4920
4911 4921 2002-03-25 Fernando Perez <fperez@colorado.edu>
4912 4922
4913 4923 * IPython/genutils.py (get_home_dir): Try to make it work under
4914 4924 win9x also.
4915 4925
4916 4926 2002-03-20 Fernando Perez <fperez@colorado.edu>
4917 4927
4918 4928 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4919 4929 sys.displayhook untouched upon __init__.
4920 4930
4921 4931 2002-03-19 Fernando Perez <fperez@colorado.edu>
4922 4932
4923 4933 * Released 0.2.9 (for embedding bug, basically).
4924 4934
4925 4935 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4926 4936 exceptions so that enclosing shell's state can be restored.
4927 4937
4928 4938 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4929 4939 naming conventions in the .ipython/ dir.
4930 4940
4931 4941 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4932 4942 from delimiters list so filenames with - in them get expanded.
4933 4943
4934 4944 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4935 4945 sys.displayhook not being properly restored after an embedded call.
4936 4946
4937 4947 2002-03-18 Fernando Perez <fperez@colorado.edu>
4938 4948
4939 4949 * Released 0.2.8
4940 4950
4941 4951 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4942 4952 some files weren't being included in a -upgrade.
4943 4953 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4944 4954 on' so that the first tab completes.
4945 4955 (InteractiveShell.handle_magic): fixed bug with spaces around
4946 4956 quotes breaking many magic commands.
4947 4957
4948 4958 * setup.py: added note about ignoring the syntax error messages at
4949 4959 installation.
4950 4960
4951 4961 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4952 4962 streamlining the gnuplot interface, now there's only one magic @gp.
4953 4963
4954 4964 2002-03-17 Fernando Perez <fperez@colorado.edu>
4955 4965
4956 4966 * IPython/UserConfig/magic_gnuplot.py: new name for the
4957 4967 example-magic_pm.py file. Much enhanced system, now with a shell
4958 4968 for communicating directly with gnuplot, one command at a time.
4959 4969
4960 4970 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4961 4971 setting __name__=='__main__'.
4962 4972
4963 4973 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4964 4974 mini-shell for accessing gnuplot from inside ipython. Should
4965 4975 extend it later for grace access too. Inspired by Arnd's
4966 4976 suggestion.
4967 4977
4968 4978 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4969 4979 calling magic functions with () in their arguments. Thanks to Arnd
4970 4980 Baecker for pointing this to me.
4971 4981
4972 4982 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4973 4983 infinitely for integer or complex arrays (only worked with floats).
4974 4984
4975 4985 2002-03-16 Fernando Perez <fperez@colorado.edu>
4976 4986
4977 4987 * setup.py: Merged setup and setup_windows into a single script
4978 4988 which properly handles things for windows users.
4979 4989
4980 4990 2002-03-15 Fernando Perez <fperez@colorado.edu>
4981 4991
4982 4992 * Big change to the manual: now the magics are all automatically
4983 4993 documented. This information is generated from their docstrings
4984 4994 and put in a latex file included by the manual lyx file. This way
4985 4995 we get always up to date information for the magics. The manual
4986 4996 now also has proper version information, also auto-synced.
4987 4997
4988 4998 For this to work, an undocumented --magic_docstrings option was added.
4989 4999
4990 5000 2002-03-13 Fernando Perez <fperez@colorado.edu>
4991 5001
4992 5002 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4993 5003 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4994 5004
4995 5005 2002-03-12 Fernando Perez <fperez@colorado.edu>
4996 5006
4997 5007 * IPython/ultraTB.py (TermColors): changed color escapes again to
4998 5008 fix the (old, reintroduced) line-wrapping bug. Basically, if
4999 5009 \001..\002 aren't given in the color escapes, lines get wrapped
5000 5010 weirdly. But giving those screws up old xterms and emacs terms. So
5001 5011 I added some logic for emacs terms to be ok, but I can't identify old
5002 5012 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5003 5013
5004 5014 2002-03-10 Fernando Perez <fperez@colorado.edu>
5005 5015
5006 5016 * IPython/usage.py (__doc__): Various documentation cleanups and
5007 5017 updates, both in usage docstrings and in the manual.
5008 5018
5009 5019 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5010 5020 handling of caching. Set minimum acceptabe value for having a
5011 5021 cache at 20 values.
5012 5022
5013 5023 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5014 5024 install_first_time function to a method, renamed it and added an
5015 5025 'upgrade' mode. Now people can update their config directory with
5016 5026 a simple command line switch (-upgrade, also new).
5017 5027
5018 5028 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5019 5029 @file (convenient for automagic users under Python >= 2.2).
5020 5030 Removed @files (it seemed more like a plural than an abbrev. of
5021 5031 'file show').
5022 5032
5023 5033 * IPython/iplib.py (install_first_time): Fixed crash if there were
5024 5034 backup files ('~') in .ipython/ install directory.
5025 5035
5026 5036 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5027 5037 system. Things look fine, but these changes are fairly
5028 5038 intrusive. Test them for a few days.
5029 5039
5030 5040 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5031 5041 the prompts system. Now all in/out prompt strings are user
5032 5042 controllable. This is particularly useful for embedding, as one
5033 5043 can tag embedded instances with particular prompts.
5034 5044
5035 5045 Also removed global use of sys.ps1/2, which now allows nested
5036 5046 embeddings without any problems. Added command-line options for
5037 5047 the prompt strings.
5038 5048
5039 5049 2002-03-08 Fernando Perez <fperez@colorado.edu>
5040 5050
5041 5051 * IPython/UserConfig/example-embed-short.py (ipshell): added
5042 5052 example file with the bare minimum code for embedding.
5043 5053
5044 5054 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5045 5055 functionality for the embeddable shell to be activated/deactivated
5046 5056 either globally or at each call.
5047 5057
5048 5058 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5049 5059 rewriting the prompt with '--->' for auto-inputs with proper
5050 5060 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5051 5061 this is handled by the prompts class itself, as it should.
5052 5062
5053 5063 2002-03-05 Fernando Perez <fperez@colorado.edu>
5054 5064
5055 5065 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5056 5066 @logstart to avoid name clashes with the math log function.
5057 5067
5058 5068 * Big updates to X/Emacs section of the manual.
5059 5069
5060 5070 * Removed ipython_emacs. Milan explained to me how to pass
5061 5071 arguments to ipython through Emacs. Some day I'm going to end up
5062 5072 learning some lisp...
5063 5073
5064 5074 2002-03-04 Fernando Perez <fperez@colorado.edu>
5065 5075
5066 5076 * IPython/ipython_emacs: Created script to be used as the
5067 5077 py-python-command Emacs variable so we can pass IPython
5068 5078 parameters. I can't figure out how to tell Emacs directly to pass
5069 5079 parameters to IPython, so a dummy shell script will do it.
5070 5080
5071 5081 Other enhancements made for things to work better under Emacs'
5072 5082 various types of terminals. Many thanks to Milan Zamazal
5073 5083 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5074 5084
5075 5085 2002-03-01 Fernando Perez <fperez@colorado.edu>
5076 5086
5077 5087 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5078 5088 that loading of readline is now optional. This gives better
5079 5089 control to emacs users.
5080 5090
5081 5091 * IPython/ultraTB.py (__date__): Modified color escape sequences
5082 5092 and now things work fine under xterm and in Emacs' term buffers
5083 5093 (though not shell ones). Well, in emacs you get colors, but all
5084 5094 seem to be 'light' colors (no difference between dark and light
5085 5095 ones). But the garbage chars are gone, and also in xterms. It
5086 5096 seems that now I'm using 'cleaner' ansi sequences.
5087 5097
5088 5098 2002-02-21 Fernando Perez <fperez@colorado.edu>
5089 5099
5090 5100 * Released 0.2.7 (mainly to publish the scoping fix).
5091 5101
5092 5102 * IPython/Logger.py (Logger.logstate): added. A corresponding
5093 5103 @logstate magic was created.
5094 5104
5095 5105 * IPython/Magic.py: fixed nested scoping problem under Python
5096 5106 2.1.x (automagic wasn't working).
5097 5107
5098 5108 2002-02-20 Fernando Perez <fperez@colorado.edu>
5099 5109
5100 5110 * Released 0.2.6.
5101 5111
5102 5112 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5103 5113 option so that logs can come out without any headers at all.
5104 5114
5105 5115 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5106 5116 SciPy.
5107 5117
5108 5118 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5109 5119 that embedded IPython calls don't require vars() to be explicitly
5110 5120 passed. Now they are extracted from the caller's frame (code
5111 5121 snatched from Eric Jones' weave). Added better documentation to
5112 5122 the section on embedding and the example file.
5113 5123
5114 5124 * IPython/genutils.py (page): Changed so that under emacs, it just
5115 5125 prints the string. You can then page up and down in the emacs
5116 5126 buffer itself. This is how the builtin help() works.
5117 5127
5118 5128 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5119 5129 macro scoping: macros need to be executed in the user's namespace
5120 5130 to work as if they had been typed by the user.
5121 5131
5122 5132 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5123 5133 execute automatically (no need to type 'exec...'). They then
5124 5134 behave like 'true macros'. The printing system was also modified
5125 5135 for this to work.
5126 5136
5127 5137 2002-02-19 Fernando Perez <fperez@colorado.edu>
5128 5138
5129 5139 * IPython/genutils.py (page_file): new function for paging files
5130 5140 in an OS-independent way. Also necessary for file viewing to work
5131 5141 well inside Emacs buffers.
5132 5142 (page): Added checks for being in an emacs buffer.
5133 5143 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5134 5144 same bug in iplib.
5135 5145
5136 5146 2002-02-18 Fernando Perez <fperez@colorado.edu>
5137 5147
5138 5148 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5139 5149 of readline so that IPython can work inside an Emacs buffer.
5140 5150
5141 5151 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5142 5152 method signatures (they weren't really bugs, but it looks cleaner
5143 5153 and keeps PyChecker happy).
5144 5154
5145 5155 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5146 5156 for implementing various user-defined hooks. Currently only
5147 5157 display is done.
5148 5158
5149 5159 * IPython/Prompts.py (CachedOutput._display): changed display
5150 5160 functions so that they can be dynamically changed by users easily.
5151 5161
5152 5162 * IPython/Extensions/numeric_formats.py (num_display): added an
5153 5163 extension for printing NumPy arrays in flexible manners. It
5154 5164 doesn't do anything yet, but all the structure is in
5155 5165 place. Ultimately the plan is to implement output format control
5156 5166 like in Octave.
5157 5167
5158 5168 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5159 5169 methods are found at run-time by all the automatic machinery.
5160 5170
5161 5171 2002-02-17 Fernando Perez <fperez@colorado.edu>
5162 5172
5163 5173 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5164 5174 whole file a little.
5165 5175
5166 5176 * ToDo: closed this document. Now there's a new_design.lyx
5167 5177 document for all new ideas. Added making a pdf of it for the
5168 5178 end-user distro.
5169 5179
5170 5180 * IPython/Logger.py (Logger.switch_log): Created this to replace
5171 5181 logon() and logoff(). It also fixes a nasty crash reported by
5172 5182 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5173 5183
5174 5184 * IPython/iplib.py (complete): got auto-completion to work with
5175 5185 automagic (I had wanted this for a long time).
5176 5186
5177 5187 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5178 5188 to @file, since file() is now a builtin and clashes with automagic
5179 5189 for @file.
5180 5190
5181 5191 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5182 5192 of this was previously in iplib, which had grown to more than 2000
5183 5193 lines, way too long. No new functionality, but it makes managing
5184 5194 the code a bit easier.
5185 5195
5186 5196 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5187 5197 information to crash reports.
5188 5198
5189 5199 2002-02-12 Fernando Perez <fperez@colorado.edu>
5190 5200
5191 5201 * Released 0.2.5.
5192 5202
5193 5203 2002-02-11 Fernando Perez <fperez@colorado.edu>
5194 5204
5195 5205 * Wrote a relatively complete Windows installer. It puts
5196 5206 everything in place, creates Start Menu entries and fixes the
5197 5207 color issues. Nothing fancy, but it works.
5198 5208
5199 5209 2002-02-10 Fernando Perez <fperez@colorado.edu>
5200 5210
5201 5211 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5202 5212 os.path.expanduser() call so that we can type @run ~/myfile.py and
5203 5213 have thigs work as expected.
5204 5214
5205 5215 * IPython/genutils.py (page): fixed exception handling so things
5206 5216 work both in Unix and Windows correctly. Quitting a pager triggers
5207 5217 an IOError/broken pipe in Unix, and in windows not finding a pager
5208 5218 is also an IOError, so I had to actually look at the return value
5209 5219 of the exception, not just the exception itself. Should be ok now.
5210 5220
5211 5221 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5212 5222 modified to allow case-insensitive color scheme changes.
5213 5223
5214 5224 2002-02-09 Fernando Perez <fperez@colorado.edu>
5215 5225
5216 5226 * IPython/genutils.py (native_line_ends): new function to leave
5217 5227 user config files with os-native line-endings.
5218 5228
5219 5229 * README and manual updates.
5220 5230
5221 5231 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5222 5232 instead of StringType to catch Unicode strings.
5223 5233
5224 5234 * IPython/genutils.py (filefind): fixed bug for paths with
5225 5235 embedded spaces (very common in Windows).
5226 5236
5227 5237 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5228 5238 files under Windows, so that they get automatically associated
5229 5239 with a text editor. Windows makes it a pain to handle
5230 5240 extension-less files.
5231 5241
5232 5242 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5233 5243 warning about readline only occur for Posix. In Windows there's no
5234 5244 way to get readline, so why bother with the warning.
5235 5245
5236 5246 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5237 5247 for __str__ instead of dir(self), since dir() changed in 2.2.
5238 5248
5239 5249 * Ported to Windows! Tested on XP, I suspect it should work fine
5240 5250 on NT/2000, but I don't think it will work on 98 et al. That
5241 5251 series of Windows is such a piece of junk anyway that I won't try
5242 5252 porting it there. The XP port was straightforward, showed a few
5243 5253 bugs here and there (fixed all), in particular some string
5244 5254 handling stuff which required considering Unicode strings (which
5245 5255 Windows uses). This is good, but hasn't been too tested :) No
5246 5256 fancy installer yet, I'll put a note in the manual so people at
5247 5257 least make manually a shortcut.
5248 5258
5249 5259 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5250 5260 into a single one, "colors". This now controls both prompt and
5251 5261 exception color schemes, and can be changed both at startup
5252 5262 (either via command-line switches or via ipythonrc files) and at
5253 5263 runtime, with @colors.
5254 5264 (Magic.magic_run): renamed @prun to @run and removed the old
5255 5265 @run. The two were too similar to warrant keeping both.
5256 5266
5257 5267 2002-02-03 Fernando Perez <fperez@colorado.edu>
5258 5268
5259 5269 * IPython/iplib.py (install_first_time): Added comment on how to
5260 5270 configure the color options for first-time users. Put a <return>
5261 5271 request at the end so that small-terminal users get a chance to
5262 5272 read the startup info.
5263 5273
5264 5274 2002-01-23 Fernando Perez <fperez@colorado.edu>
5265 5275
5266 5276 * IPython/iplib.py (CachedOutput.update): Changed output memory
5267 5277 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5268 5278 input history we still use _i. Did this b/c these variable are
5269 5279 very commonly used in interactive work, so the less we need to
5270 5280 type the better off we are.
5271 5281 (Magic.magic_prun): updated @prun to better handle the namespaces
5272 5282 the file will run in, including a fix for __name__ not being set
5273 5283 before.
5274 5284
5275 5285 2002-01-20 Fernando Perez <fperez@colorado.edu>
5276 5286
5277 5287 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5278 5288 extra garbage for Python 2.2. Need to look more carefully into
5279 5289 this later.
5280 5290
5281 5291 2002-01-19 Fernando Perez <fperez@colorado.edu>
5282 5292
5283 5293 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5284 5294 display SyntaxError exceptions properly formatted when they occur
5285 5295 (they can be triggered by imported code).
5286 5296
5287 5297 2002-01-18 Fernando Perez <fperez@colorado.edu>
5288 5298
5289 5299 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5290 5300 SyntaxError exceptions are reported nicely formatted, instead of
5291 5301 spitting out only offset information as before.
5292 5302 (Magic.magic_prun): Added the @prun function for executing
5293 5303 programs with command line args inside IPython.
5294 5304
5295 5305 2002-01-16 Fernando Perez <fperez@colorado.edu>
5296 5306
5297 5307 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5298 5308 to *not* include the last item given in a range. This brings their
5299 5309 behavior in line with Python's slicing:
5300 5310 a[n1:n2] -> a[n1]...a[n2-1]
5301 5311 It may be a bit less convenient, but I prefer to stick to Python's
5302 5312 conventions *everywhere*, so users never have to wonder.
5303 5313 (Magic.magic_macro): Added @macro function to ease the creation of
5304 5314 macros.
5305 5315
5306 5316 2002-01-05 Fernando Perez <fperez@colorado.edu>
5307 5317
5308 5318 * Released 0.2.4.
5309 5319
5310 5320 * IPython/iplib.py (Magic.magic_pdef):
5311 5321 (InteractiveShell.safe_execfile): report magic lines and error
5312 5322 lines without line numbers so one can easily copy/paste them for
5313 5323 re-execution.
5314 5324
5315 5325 * Updated manual with recent changes.
5316 5326
5317 5327 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5318 5328 docstring printing when class? is called. Very handy for knowing
5319 5329 how to create class instances (as long as __init__ is well
5320 5330 documented, of course :)
5321 5331 (Magic.magic_doc): print both class and constructor docstrings.
5322 5332 (Magic.magic_pdef): give constructor info if passed a class and
5323 5333 __call__ info for callable object instances.
5324 5334
5325 5335 2002-01-04 Fernando Perez <fperez@colorado.edu>
5326 5336
5327 5337 * Made deep_reload() off by default. It doesn't always work
5328 5338 exactly as intended, so it's probably safer to have it off. It's
5329 5339 still available as dreload() anyway, so nothing is lost.
5330 5340
5331 5341 2002-01-02 Fernando Perez <fperez@colorado.edu>
5332 5342
5333 5343 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5334 5344 so I wanted an updated release).
5335 5345
5336 5346 2001-12-27 Fernando Perez <fperez@colorado.edu>
5337 5347
5338 5348 * IPython/iplib.py (InteractiveShell.interact): Added the original
5339 5349 code from 'code.py' for this module in order to change the
5340 5350 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5341 5351 the history cache would break when the user hit Ctrl-C, and
5342 5352 interact() offers no way to add any hooks to it.
5343 5353
5344 5354 2001-12-23 Fernando Perez <fperez@colorado.edu>
5345 5355
5346 5356 * setup.py: added check for 'MANIFEST' before trying to remove
5347 5357 it. Thanks to Sean Reifschneider.
5348 5358
5349 5359 2001-12-22 Fernando Perez <fperez@colorado.edu>
5350 5360
5351 5361 * Released 0.2.2.
5352 5362
5353 5363 * Finished (reasonably) writing the manual. Later will add the
5354 5364 python-standard navigation stylesheets, but for the time being
5355 5365 it's fairly complete. Distribution will include html and pdf
5356 5366 versions.
5357 5367
5358 5368 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5359 5369 (MayaVi author).
5360 5370
5361 5371 2001-12-21 Fernando Perez <fperez@colorado.edu>
5362 5372
5363 5373 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5364 5374 good public release, I think (with the manual and the distutils
5365 5375 installer). The manual can use some work, but that can go
5366 5376 slowly. Otherwise I think it's quite nice for end users. Next
5367 5377 summer, rewrite the guts of it...
5368 5378
5369 5379 * Changed format of ipythonrc files to use whitespace as the
5370 5380 separator instead of an explicit '='. Cleaner.
5371 5381
5372 5382 2001-12-20 Fernando Perez <fperez@colorado.edu>
5373 5383
5374 5384 * Started a manual in LyX. For now it's just a quick merge of the
5375 5385 various internal docstrings and READMEs. Later it may grow into a
5376 5386 nice, full-blown manual.
5377 5387
5378 5388 * Set up a distutils based installer. Installation should now be
5379 5389 trivially simple for end-users.
5380 5390
5381 5391 2001-12-11 Fernando Perez <fperez@colorado.edu>
5382 5392
5383 5393 * Released 0.2.0. First public release, announced it at
5384 5394 comp.lang.python. From now on, just bugfixes...
5385 5395
5386 5396 * Went through all the files, set copyright/license notices and
5387 5397 cleaned up things. Ready for release.
5388 5398
5389 5399 2001-12-10 Fernando Perez <fperez@colorado.edu>
5390 5400
5391 5401 * Changed the first-time installer not to use tarfiles. It's more
5392 5402 robust now and less unix-dependent. Also makes it easier for
5393 5403 people to later upgrade versions.
5394 5404
5395 5405 * Changed @exit to @abort to reflect the fact that it's pretty
5396 5406 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5397 5407 becomes significant only when IPyhton is embedded: in that case,
5398 5408 C-D closes IPython only, but @abort kills the enclosing program
5399 5409 too (unless it had called IPython inside a try catching
5400 5410 SystemExit).
5401 5411
5402 5412 * Created Shell module which exposes the actuall IPython Shell
5403 5413 classes, currently the normal and the embeddable one. This at
5404 5414 least offers a stable interface we won't need to change when
5405 5415 (later) the internals are rewritten. That rewrite will be confined
5406 5416 to iplib and ipmaker, but the Shell interface should remain as is.
5407 5417
5408 5418 * Added embed module which offers an embeddable IPShell object,
5409 5419 useful to fire up IPython *inside* a running program. Great for
5410 5420 debugging or dynamical data analysis.
5411 5421
5412 5422 2001-12-08 Fernando Perez <fperez@colorado.edu>
5413 5423
5414 5424 * Fixed small bug preventing seeing info from methods of defined
5415 5425 objects (incorrect namespace in _ofind()).
5416 5426
5417 5427 * Documentation cleanup. Moved the main usage docstrings to a
5418 5428 separate file, usage.py (cleaner to maintain, and hopefully in the
5419 5429 future some perlpod-like way of producing interactive, man and
5420 5430 html docs out of it will be found).
5421 5431
5422 5432 * Added @profile to see your profile at any time.
5423 5433
5424 5434 * Added @p as an alias for 'print'. It's especially convenient if
5425 5435 using automagic ('p x' prints x).
5426 5436
5427 5437 * Small cleanups and fixes after a pychecker run.
5428 5438
5429 5439 * Changed the @cd command to handle @cd - and @cd -<n> for
5430 5440 visiting any directory in _dh.
5431 5441
5432 5442 * Introduced _dh, a history of visited directories. @dhist prints
5433 5443 it out with numbers.
5434 5444
5435 5445 2001-12-07 Fernando Perez <fperez@colorado.edu>
5436 5446
5437 5447 * Released 0.1.22
5438 5448
5439 5449 * Made initialization a bit more robust against invalid color
5440 5450 options in user input (exit, not traceback-crash).
5441 5451
5442 5452 * Changed the bug crash reporter to write the report only in the
5443 5453 user's .ipython directory. That way IPython won't litter people's
5444 5454 hard disks with crash files all over the place. Also print on
5445 5455 screen the necessary mail command.
5446 5456
5447 5457 * With the new ultraTB, implemented LightBG color scheme for light
5448 5458 background terminals. A lot of people like white backgrounds, so I
5449 5459 guess we should at least give them something readable.
5450 5460
5451 5461 2001-12-06 Fernando Perez <fperez@colorado.edu>
5452 5462
5453 5463 * Modified the structure of ultraTB. Now there's a proper class
5454 5464 for tables of color schemes which allow adding schemes easily and
5455 5465 switching the active scheme without creating a new instance every
5456 5466 time (which was ridiculous). The syntax for creating new schemes
5457 5467 is also cleaner. I think ultraTB is finally done, with a clean
5458 5468 class structure. Names are also much cleaner (now there's proper
5459 5469 color tables, no need for every variable to also have 'color' in
5460 5470 its name).
5461 5471
5462 5472 * Broke down genutils into separate files. Now genutils only
5463 5473 contains utility functions, and classes have been moved to their
5464 5474 own files (they had enough independent functionality to warrant
5465 5475 it): ConfigLoader, OutputTrap, Struct.
5466 5476
5467 5477 2001-12-05 Fernando Perez <fperez@colorado.edu>
5468 5478
5469 5479 * IPython turns 21! Released version 0.1.21, as a candidate for
5470 5480 public consumption. If all goes well, release in a few days.
5471 5481
5472 5482 * Fixed path bug (files in Extensions/ directory wouldn't be found
5473 5483 unless IPython/ was explicitly in sys.path).
5474 5484
5475 5485 * Extended the FlexCompleter class as MagicCompleter to allow
5476 5486 completion of @-starting lines.
5477 5487
5478 5488 * Created __release__.py file as a central repository for release
5479 5489 info that other files can read from.
5480 5490
5481 5491 * Fixed small bug in logging: when logging was turned on in
5482 5492 mid-session, old lines with special meanings (!@?) were being
5483 5493 logged without the prepended comment, which is necessary since
5484 5494 they are not truly valid python syntax. This should make session
5485 5495 restores produce less errors.
5486 5496
5487 5497 * The namespace cleanup forced me to make a FlexCompleter class
5488 5498 which is nothing but a ripoff of rlcompleter, but with selectable
5489 5499 namespace (rlcompleter only works in __main__.__dict__). I'll try
5490 5500 to submit a note to the authors to see if this change can be
5491 5501 incorporated in future rlcompleter releases (Dec.6: done)
5492 5502
5493 5503 * More fixes to namespace handling. It was a mess! Now all
5494 5504 explicit references to __main__.__dict__ are gone (except when
5495 5505 really needed) and everything is handled through the namespace
5496 5506 dicts in the IPython instance. We seem to be getting somewhere
5497 5507 with this, finally...
5498 5508
5499 5509 * Small documentation updates.
5500 5510
5501 5511 * Created the Extensions directory under IPython (with an
5502 5512 __init__.py). Put the PhysicalQ stuff there. This directory should
5503 5513 be used for all special-purpose extensions.
5504 5514
5505 5515 * File renaming:
5506 5516 ipythonlib --> ipmaker
5507 5517 ipplib --> iplib
5508 5518 This makes a bit more sense in terms of what these files actually do.
5509 5519
5510 5520 * Moved all the classes and functions in ipythonlib to ipplib, so
5511 5521 now ipythonlib only has make_IPython(). This will ease up its
5512 5522 splitting in smaller functional chunks later.
5513 5523
5514 5524 * Cleaned up (done, I think) output of @whos. Better column
5515 5525 formatting, and now shows str(var) for as much as it can, which is
5516 5526 typically what one gets with a 'print var'.
5517 5527
5518 5528 2001-12-04 Fernando Perez <fperez@colorado.edu>
5519 5529
5520 5530 * Fixed namespace problems. Now builtin/IPyhton/user names get
5521 5531 properly reported in their namespace. Internal namespace handling
5522 5532 is finally getting decent (not perfect yet, but much better than
5523 5533 the ad-hoc mess we had).
5524 5534
5525 5535 * Removed -exit option. If people just want to run a python
5526 5536 script, that's what the normal interpreter is for. Less
5527 5537 unnecessary options, less chances for bugs.
5528 5538
5529 5539 * Added a crash handler which generates a complete post-mortem if
5530 5540 IPython crashes. This will help a lot in tracking bugs down the
5531 5541 road.
5532 5542
5533 5543 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5534 5544 which were boud to functions being reassigned would bypass the
5535 5545 logger, breaking the sync of _il with the prompt counter. This
5536 5546 would then crash IPython later when a new line was logged.
5537 5547
5538 5548 2001-12-02 Fernando Perez <fperez@colorado.edu>
5539 5549
5540 5550 * Made IPython a package. This means people don't have to clutter
5541 5551 their sys.path with yet another directory. Changed the INSTALL
5542 5552 file accordingly.
5543 5553
5544 5554 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5545 5555 sorts its output (so @who shows it sorted) and @whos formats the
5546 5556 table according to the width of the first column. Nicer, easier to
5547 5557 read. Todo: write a generic table_format() which takes a list of
5548 5558 lists and prints it nicely formatted, with optional row/column
5549 5559 separators and proper padding and justification.
5550 5560
5551 5561 * Released 0.1.20
5552 5562
5553 5563 * Fixed bug in @log which would reverse the inputcache list (a
5554 5564 copy operation was missing).
5555 5565
5556 5566 * Code cleanup. @config was changed to use page(). Better, since
5557 5567 its output is always quite long.
5558 5568
5559 5569 * Itpl is back as a dependency. I was having too many problems
5560 5570 getting the parametric aliases to work reliably, and it's just
5561 5571 easier to code weird string operations with it than playing %()s
5562 5572 games. It's only ~6k, so I don't think it's too big a deal.
5563 5573
5564 5574 * Found (and fixed) a very nasty bug with history. !lines weren't
5565 5575 getting cached, and the out of sync caches would crash
5566 5576 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5567 5577 division of labor a bit better. Bug fixed, cleaner structure.
5568 5578
5569 5579 2001-12-01 Fernando Perez <fperez@colorado.edu>
5570 5580
5571 5581 * Released 0.1.19
5572 5582
5573 5583 * Added option -n to @hist to prevent line number printing. Much
5574 5584 easier to copy/paste code this way.
5575 5585
5576 5586 * Created global _il to hold the input list. Allows easy
5577 5587 re-execution of blocks of code by slicing it (inspired by Janko's
5578 5588 comment on 'macros').
5579 5589
5580 5590 * Small fixes and doc updates.
5581 5591
5582 5592 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5583 5593 much too fragile with automagic. Handles properly multi-line
5584 5594 statements and takes parameters.
5585 5595
5586 5596 2001-11-30 Fernando Perez <fperez@colorado.edu>
5587 5597
5588 5598 * Version 0.1.18 released.
5589 5599
5590 5600 * Fixed nasty namespace bug in initial module imports.
5591 5601
5592 5602 * Added copyright/license notes to all code files (except
5593 5603 DPyGetOpt). For the time being, LGPL. That could change.
5594 5604
5595 5605 * Rewrote a much nicer README, updated INSTALL, cleaned up
5596 5606 ipythonrc-* samples.
5597 5607
5598 5608 * Overall code/documentation cleanup. Basically ready for
5599 5609 release. Only remaining thing: licence decision (LGPL?).
5600 5610
5601 5611 * Converted load_config to a class, ConfigLoader. Now recursion
5602 5612 control is better organized. Doesn't include the same file twice.
5603 5613
5604 5614 2001-11-29 Fernando Perez <fperez@colorado.edu>
5605 5615
5606 5616 * Got input history working. Changed output history variables from
5607 5617 _p to _o so that _i is for input and _o for output. Just cleaner
5608 5618 convention.
5609 5619
5610 5620 * Implemented parametric aliases. This pretty much allows the
5611 5621 alias system to offer full-blown shell convenience, I think.
5612 5622
5613 5623 * Version 0.1.17 released, 0.1.18 opened.
5614 5624
5615 5625 * dot_ipython/ipythonrc (alias): added documentation.
5616 5626 (xcolor): Fixed small bug (xcolors -> xcolor)
5617 5627
5618 5628 * Changed the alias system. Now alias is a magic command to define
5619 5629 aliases just like the shell. Rationale: the builtin magics should
5620 5630 be there for things deeply connected to IPython's
5621 5631 architecture. And this is a much lighter system for what I think
5622 5632 is the really important feature: allowing users to define quickly
5623 5633 magics that will do shell things for them, so they can customize
5624 5634 IPython easily to match their work habits. If someone is really
5625 5635 desperate to have another name for a builtin alias, they can
5626 5636 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5627 5637 works.
5628 5638
5629 5639 2001-11-28 Fernando Perez <fperez@colorado.edu>
5630 5640
5631 5641 * Changed @file so that it opens the source file at the proper
5632 5642 line. Since it uses less, if your EDITOR environment is
5633 5643 configured, typing v will immediately open your editor of choice
5634 5644 right at the line where the object is defined. Not as quick as
5635 5645 having a direct @edit command, but for all intents and purposes it
5636 5646 works. And I don't have to worry about writing @edit to deal with
5637 5647 all the editors, less does that.
5638 5648
5639 5649 * Version 0.1.16 released, 0.1.17 opened.
5640 5650
5641 5651 * Fixed some nasty bugs in the page/page_dumb combo that could
5642 5652 crash IPython.
5643 5653
5644 5654 2001-11-27 Fernando Perez <fperez@colorado.edu>
5645 5655
5646 5656 * Version 0.1.15 released, 0.1.16 opened.
5647 5657
5648 5658 * Finally got ? and ?? to work for undefined things: now it's
5649 5659 possible to type {}.get? and get information about the get method
5650 5660 of dicts, or os.path? even if only os is defined (so technically
5651 5661 os.path isn't). Works at any level. For example, after import os,
5652 5662 os?, os.path?, os.path.abspath? all work. This is great, took some
5653 5663 work in _ofind.
5654 5664
5655 5665 * Fixed more bugs with logging. The sanest way to do it was to add
5656 5666 to @log a 'mode' parameter. Killed two in one shot (this mode
5657 5667 option was a request of Janko's). I think it's finally clean
5658 5668 (famous last words).
5659 5669
5660 5670 * Added a page_dumb() pager which does a decent job of paging on
5661 5671 screen, if better things (like less) aren't available. One less
5662 5672 unix dependency (someday maybe somebody will port this to
5663 5673 windows).
5664 5674
5665 5675 * Fixed problem in magic_log: would lock of logging out if log
5666 5676 creation failed (because it would still think it had succeeded).
5667 5677
5668 5678 * Improved the page() function using curses to auto-detect screen
5669 5679 size. Now it can make a much better decision on whether to print
5670 5680 or page a string. Option screen_length was modified: a value 0
5671 5681 means auto-detect, and that's the default now.
5672 5682
5673 5683 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5674 5684 go out. I'll test it for a few days, then talk to Janko about
5675 5685 licences and announce it.
5676 5686
5677 5687 * Fixed the length of the auto-generated ---> prompt which appears
5678 5688 for auto-parens and auto-quotes. Getting this right isn't trivial,
5679 5689 with all the color escapes, different prompt types and optional
5680 5690 separators. But it seems to be working in all the combinations.
5681 5691
5682 5692 2001-11-26 Fernando Perez <fperez@colorado.edu>
5683 5693
5684 5694 * Wrote a regexp filter to get option types from the option names
5685 5695 string. This eliminates the need to manually keep two duplicate
5686 5696 lists.
5687 5697
5688 5698 * Removed the unneeded check_option_names. Now options are handled
5689 5699 in a much saner manner and it's easy to visually check that things
5690 5700 are ok.
5691 5701
5692 5702 * Updated version numbers on all files I modified to carry a
5693 5703 notice so Janko and Nathan have clear version markers.
5694 5704
5695 5705 * Updated docstring for ultraTB with my changes. I should send
5696 5706 this to Nathan.
5697 5707
5698 5708 * Lots of small fixes. Ran everything through pychecker again.
5699 5709
5700 5710 * Made loading of deep_reload an cmd line option. If it's not too
5701 5711 kosher, now people can just disable it. With -nodeep_reload it's
5702 5712 still available as dreload(), it just won't overwrite reload().
5703 5713
5704 5714 * Moved many options to the no| form (-opt and -noopt
5705 5715 accepted). Cleaner.
5706 5716
5707 5717 * Changed magic_log so that if called with no parameters, it uses
5708 5718 'rotate' mode. That way auto-generated logs aren't automatically
5709 5719 over-written. For normal logs, now a backup is made if it exists
5710 5720 (only 1 level of backups). A new 'backup' mode was added to the
5711 5721 Logger class to support this. This was a request by Janko.
5712 5722
5713 5723 * Added @logoff/@logon to stop/restart an active log.
5714 5724
5715 5725 * Fixed a lot of bugs in log saving/replay. It was pretty
5716 5726 broken. Now special lines (!@,/) appear properly in the command
5717 5727 history after a log replay.
5718 5728
5719 5729 * Tried and failed to implement full session saving via pickle. My
5720 5730 idea was to pickle __main__.__dict__, but modules can't be
5721 5731 pickled. This would be a better alternative to replaying logs, but
5722 5732 seems quite tricky to get to work. Changed -session to be called
5723 5733 -logplay, which more accurately reflects what it does. And if we
5724 5734 ever get real session saving working, -session is now available.
5725 5735
5726 5736 * Implemented color schemes for prompts also. As for tracebacks,
5727 5737 currently only NoColor and Linux are supported. But now the
5728 5738 infrastructure is in place, based on a generic ColorScheme
5729 5739 class. So writing and activating new schemes both for the prompts
5730 5740 and the tracebacks should be straightforward.
5731 5741
5732 5742 * Version 0.1.13 released, 0.1.14 opened.
5733 5743
5734 5744 * Changed handling of options for output cache. Now counter is
5735 5745 hardwired starting at 1 and one specifies the maximum number of
5736 5746 entries *in the outcache* (not the max prompt counter). This is
5737 5747 much better, since many statements won't increase the cache
5738 5748 count. It also eliminated some confusing options, now there's only
5739 5749 one: cache_size.
5740 5750
5741 5751 * Added 'alias' magic function and magic_alias option in the
5742 5752 ipythonrc file. Now the user can easily define whatever names he
5743 5753 wants for the magic functions without having to play weird
5744 5754 namespace games. This gives IPython a real shell-like feel.
5745 5755
5746 5756 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5747 5757 @ or not).
5748 5758
5749 5759 This was one of the last remaining 'visible' bugs (that I know
5750 5760 of). I think if I can clean up the session loading so it works
5751 5761 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5752 5762 about licensing).
5753 5763
5754 5764 2001-11-25 Fernando Perez <fperez@colorado.edu>
5755 5765
5756 5766 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5757 5767 there's a cleaner distinction between what ? and ?? show.
5758 5768
5759 5769 * Added screen_length option. Now the user can define his own
5760 5770 screen size for page() operations.
5761 5771
5762 5772 * Implemented magic shell-like functions with automatic code
5763 5773 generation. Now adding another function is just a matter of adding
5764 5774 an entry to a dict, and the function is dynamically generated at
5765 5775 run-time. Python has some really cool features!
5766 5776
5767 5777 * Renamed many options to cleanup conventions a little. Now all
5768 5778 are lowercase, and only underscores where needed. Also in the code
5769 5779 option name tables are clearer.
5770 5780
5771 5781 * Changed prompts a little. Now input is 'In [n]:' instead of
5772 5782 'In[n]:='. This allows it the numbers to be aligned with the
5773 5783 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5774 5784 Python (it was a Mathematica thing). The '...' continuation prompt
5775 5785 was also changed a little to align better.
5776 5786
5777 5787 * Fixed bug when flushing output cache. Not all _p<n> variables
5778 5788 exist, so their deletion needs to be wrapped in a try:
5779 5789
5780 5790 * Figured out how to properly use inspect.formatargspec() (it
5781 5791 requires the args preceded by *). So I removed all the code from
5782 5792 _get_pdef in Magic, which was just replicating that.
5783 5793
5784 5794 * Added test to prefilter to allow redefining magic function names
5785 5795 as variables. This is ok, since the @ form is always available,
5786 5796 but whe should allow the user to define a variable called 'ls' if
5787 5797 he needs it.
5788 5798
5789 5799 * Moved the ToDo information from README into a separate ToDo.
5790 5800
5791 5801 * General code cleanup and small bugfixes. I think it's close to a
5792 5802 state where it can be released, obviously with a big 'beta'
5793 5803 warning on it.
5794 5804
5795 5805 * Got the magic function split to work. Now all magics are defined
5796 5806 in a separate class. It just organizes things a bit, and now
5797 5807 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5798 5808 was too long).
5799 5809
5800 5810 * Changed @clear to @reset to avoid potential confusions with
5801 5811 the shell command clear. Also renamed @cl to @clear, which does
5802 5812 exactly what people expect it to from their shell experience.
5803 5813
5804 5814 Added a check to the @reset command (since it's so
5805 5815 destructive, it's probably a good idea to ask for confirmation).
5806 5816 But now reset only works for full namespace resetting. Since the
5807 5817 del keyword is already there for deleting a few specific
5808 5818 variables, I don't see the point of having a redundant magic
5809 5819 function for the same task.
5810 5820
5811 5821 2001-11-24 Fernando Perez <fperez@colorado.edu>
5812 5822
5813 5823 * Updated the builtin docs (esp. the ? ones).
5814 5824
5815 5825 * Ran all the code through pychecker. Not terribly impressed with
5816 5826 it: lots of spurious warnings and didn't really find anything of
5817 5827 substance (just a few modules being imported and not used).
5818 5828
5819 5829 * Implemented the new ultraTB functionality into IPython. New
5820 5830 option: xcolors. This chooses color scheme. xmode now only selects
5821 5831 between Plain and Verbose. Better orthogonality.
5822 5832
5823 5833 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5824 5834 mode and color scheme for the exception handlers. Now it's
5825 5835 possible to have the verbose traceback with no coloring.
5826 5836
5827 5837 2001-11-23 Fernando Perez <fperez@colorado.edu>
5828 5838
5829 5839 * Version 0.1.12 released, 0.1.13 opened.
5830 5840
5831 5841 * Removed option to set auto-quote and auto-paren escapes by
5832 5842 user. The chances of breaking valid syntax are just too high. If
5833 5843 someone *really* wants, they can always dig into the code.
5834 5844
5835 5845 * Made prompt separators configurable.
5836 5846
5837 5847 2001-11-22 Fernando Perez <fperez@colorado.edu>
5838 5848
5839 5849 * Small bugfixes in many places.
5840 5850
5841 5851 * Removed the MyCompleter class from ipplib. It seemed redundant
5842 5852 with the C-p,C-n history search functionality. Less code to
5843 5853 maintain.
5844 5854
5845 5855 * Moved all the original ipython.py code into ipythonlib.py. Right
5846 5856 now it's just one big dump into a function called make_IPython, so
5847 5857 no real modularity has been gained. But at least it makes the
5848 5858 wrapper script tiny, and since ipythonlib is a module, it gets
5849 5859 compiled and startup is much faster.
5850 5860
5851 5861 This is a reasobably 'deep' change, so we should test it for a
5852 5862 while without messing too much more with the code.
5853 5863
5854 5864 2001-11-21 Fernando Perez <fperez@colorado.edu>
5855 5865
5856 5866 * Version 0.1.11 released, 0.1.12 opened for further work.
5857 5867
5858 5868 * Removed dependency on Itpl. It was only needed in one place. It
5859 5869 would be nice if this became part of python, though. It makes life
5860 5870 *a lot* easier in some cases.
5861 5871
5862 5872 * Simplified the prefilter code a bit. Now all handlers are
5863 5873 expected to explicitly return a value (at least a blank string).
5864 5874
5865 5875 * Heavy edits in ipplib. Removed the help system altogether. Now
5866 5876 obj?/?? is used for inspecting objects, a magic @doc prints
5867 5877 docstrings, and full-blown Python help is accessed via the 'help'
5868 5878 keyword. This cleans up a lot of code (less to maintain) and does
5869 5879 the job. Since 'help' is now a standard Python component, might as
5870 5880 well use it and remove duplicate functionality.
5871 5881
5872 5882 Also removed the option to use ipplib as a standalone program. By
5873 5883 now it's too dependent on other parts of IPython to function alone.
5874 5884
5875 5885 * Fixed bug in genutils.pager. It would crash if the pager was
5876 5886 exited immediately after opening (broken pipe).
5877 5887
5878 5888 * Trimmed down the VerboseTB reporting a little. The header is
5879 5889 much shorter now and the repeated exception arguments at the end
5880 5890 have been removed. For interactive use the old header seemed a bit
5881 5891 excessive.
5882 5892
5883 5893 * Fixed small bug in output of @whos for variables with multi-word
5884 5894 types (only first word was displayed).
5885 5895
5886 5896 2001-11-17 Fernando Perez <fperez@colorado.edu>
5887 5897
5888 5898 * Version 0.1.10 released, 0.1.11 opened for further work.
5889 5899
5890 5900 * Modified dirs and friends. dirs now *returns* the stack (not
5891 5901 prints), so one can manipulate it as a variable. Convenient to
5892 5902 travel along many directories.
5893 5903
5894 5904 * Fixed bug in magic_pdef: would only work with functions with
5895 5905 arguments with default values.
5896 5906
5897 5907 2001-11-14 Fernando Perez <fperez@colorado.edu>
5898 5908
5899 5909 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5900 5910 example with IPython. Various other minor fixes and cleanups.
5901 5911
5902 5912 * Version 0.1.9 released, 0.1.10 opened for further work.
5903 5913
5904 5914 * Added sys.path to the list of directories searched in the
5905 5915 execfile= option. It used to be the current directory and the
5906 5916 user's IPYTHONDIR only.
5907 5917
5908 5918 2001-11-13 Fernando Perez <fperez@colorado.edu>
5909 5919
5910 5920 * Reinstated the raw_input/prefilter separation that Janko had
5911 5921 initially. This gives a more convenient setup for extending the
5912 5922 pre-processor from the outside: raw_input always gets a string,
5913 5923 and prefilter has to process it. We can then redefine prefilter
5914 5924 from the outside and implement extensions for special
5915 5925 purposes.
5916 5926
5917 5927 Today I got one for inputting PhysicalQuantity objects
5918 5928 (from Scientific) without needing any function calls at
5919 5929 all. Extremely convenient, and it's all done as a user-level
5920 5930 extension (no IPython code was touched). Now instead of:
5921 5931 a = PhysicalQuantity(4.2,'m/s**2')
5922 5932 one can simply say
5923 5933 a = 4.2 m/s**2
5924 5934 or even
5925 5935 a = 4.2 m/s^2
5926 5936
5927 5937 I use this, but it's also a proof of concept: IPython really is
5928 5938 fully user-extensible, even at the level of the parsing of the
5929 5939 command line. It's not trivial, but it's perfectly doable.
5930 5940
5931 5941 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5932 5942 the problem of modules being loaded in the inverse order in which
5933 5943 they were defined in
5934 5944
5935 5945 * Version 0.1.8 released, 0.1.9 opened for further work.
5936 5946
5937 5947 * Added magics pdef, source and file. They respectively show the
5938 5948 definition line ('prototype' in C), source code and full python
5939 5949 file for any callable object. The object inspector oinfo uses
5940 5950 these to show the same information.
5941 5951
5942 5952 * Version 0.1.7 released, 0.1.8 opened for further work.
5943 5953
5944 5954 * Separated all the magic functions into a class called Magic. The
5945 5955 InteractiveShell class was becoming too big for Xemacs to handle
5946 5956 (de-indenting a line would lock it up for 10 seconds while it
5947 5957 backtracked on the whole class!)
5948 5958
5949 5959 FIXME: didn't work. It can be done, but right now namespaces are
5950 5960 all messed up. Do it later (reverted it for now, so at least
5951 5961 everything works as before).
5952 5962
5953 5963 * Got the object introspection system (magic_oinfo) working! I
5954 5964 think this is pretty much ready for release to Janko, so he can
5955 5965 test it for a while and then announce it. Pretty much 100% of what
5956 5966 I wanted for the 'phase 1' release is ready. Happy, tired.
5957 5967
5958 5968 2001-11-12 Fernando Perez <fperez@colorado.edu>
5959 5969
5960 5970 * Version 0.1.6 released, 0.1.7 opened for further work.
5961 5971
5962 5972 * Fixed bug in printing: it used to test for truth before
5963 5973 printing, so 0 wouldn't print. Now checks for None.
5964 5974
5965 5975 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5966 5976 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5967 5977 reaches by hand into the outputcache. Think of a better way to do
5968 5978 this later.
5969 5979
5970 5980 * Various small fixes thanks to Nathan's comments.
5971 5981
5972 5982 * Changed magic_pprint to magic_Pprint. This way it doesn't
5973 5983 collide with pprint() and the name is consistent with the command
5974 5984 line option.
5975 5985
5976 5986 * Changed prompt counter behavior to be fully like
5977 5987 Mathematica's. That is, even input that doesn't return a result
5978 5988 raises the prompt counter. The old behavior was kind of confusing
5979 5989 (getting the same prompt number several times if the operation
5980 5990 didn't return a result).
5981 5991
5982 5992 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5983 5993
5984 5994 * Fixed -Classic mode (wasn't working anymore).
5985 5995
5986 5996 * Added colored prompts using Nathan's new code. Colors are
5987 5997 currently hardwired, they can be user-configurable. For
5988 5998 developers, they can be chosen in file ipythonlib.py, at the
5989 5999 beginning of the CachedOutput class def.
5990 6000
5991 6001 2001-11-11 Fernando Perez <fperez@colorado.edu>
5992 6002
5993 6003 * Version 0.1.5 released, 0.1.6 opened for further work.
5994 6004
5995 6005 * Changed magic_env to *return* the environment as a dict (not to
5996 6006 print it). This way it prints, but it can also be processed.
5997 6007
5998 6008 * Added Verbose exception reporting to interactive
5999 6009 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6000 6010 traceback. Had to make some changes to the ultraTB file. This is
6001 6011 probably the last 'big' thing in my mental todo list. This ties
6002 6012 in with the next entry:
6003 6013
6004 6014 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6005 6015 has to specify is Plain, Color or Verbose for all exception
6006 6016 handling.
6007 6017
6008 6018 * Removed ShellServices option. All this can really be done via
6009 6019 the magic system. It's easier to extend, cleaner and has automatic
6010 6020 namespace protection and documentation.
6011 6021
6012 6022 2001-11-09 Fernando Perez <fperez@colorado.edu>
6013 6023
6014 6024 * Fixed bug in output cache flushing (missing parameter to
6015 6025 __init__). Other small bugs fixed (found using pychecker).
6016 6026
6017 6027 * Version 0.1.4 opened for bugfixing.
6018 6028
6019 6029 2001-11-07 Fernando Perez <fperez@colorado.edu>
6020 6030
6021 6031 * Version 0.1.3 released, mainly because of the raw_input bug.
6022 6032
6023 6033 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6024 6034 and when testing for whether things were callable, a call could
6025 6035 actually be made to certain functions. They would get called again
6026 6036 once 'really' executed, with a resulting double call. A disaster
6027 6037 in many cases (list.reverse() would never work!).
6028 6038
6029 6039 * Removed prefilter() function, moved its code to raw_input (which
6030 6040 after all was just a near-empty caller for prefilter). This saves
6031 6041 a function call on every prompt, and simplifies the class a tiny bit.
6032 6042
6033 6043 * Fix _ip to __ip name in magic example file.
6034 6044
6035 6045 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6036 6046 work with non-gnu versions of tar.
6037 6047
6038 6048 2001-11-06 Fernando Perez <fperez@colorado.edu>
6039 6049
6040 6050 * Version 0.1.2. Just to keep track of the recent changes.
6041 6051
6042 6052 * Fixed nasty bug in output prompt routine. It used to check 'if
6043 6053 arg != None...'. Problem is, this fails if arg implements a
6044 6054 special comparison (__cmp__) which disallows comparing to
6045 6055 None. Found it when trying to use the PhysicalQuantity module from
6046 6056 ScientificPython.
6047 6057
6048 6058 2001-11-05 Fernando Perez <fperez@colorado.edu>
6049 6059
6050 6060 * Also added dirs. Now the pushd/popd/dirs family functions
6051 6061 basically like the shell, with the added convenience of going home
6052 6062 when called with no args.
6053 6063
6054 6064 * pushd/popd slightly modified to mimic shell behavior more
6055 6065 closely.
6056 6066
6057 6067 * Added env,pushd,popd from ShellServices as magic functions. I
6058 6068 think the cleanest will be to port all desired functions from
6059 6069 ShellServices as magics and remove ShellServices altogether. This
6060 6070 will provide a single, clean way of adding functionality
6061 6071 (shell-type or otherwise) to IP.
6062 6072
6063 6073 2001-11-04 Fernando Perez <fperez@colorado.edu>
6064 6074
6065 6075 * Added .ipython/ directory to sys.path. This way users can keep
6066 6076 customizations there and access them via import.
6067 6077
6068 6078 2001-11-03 Fernando Perez <fperez@colorado.edu>
6069 6079
6070 6080 * Opened version 0.1.1 for new changes.
6071 6081
6072 6082 * Changed version number to 0.1.0: first 'public' release, sent to
6073 6083 Nathan and Janko.
6074 6084
6075 6085 * Lots of small fixes and tweaks.
6076 6086
6077 6087 * Minor changes to whos format. Now strings are shown, snipped if
6078 6088 too long.
6079 6089
6080 6090 * Changed ShellServices to work on __main__ so they show up in @who
6081 6091
6082 6092 * Help also works with ? at the end of a line:
6083 6093 ?sin and sin?
6084 6094 both produce the same effect. This is nice, as often I use the
6085 6095 tab-complete to find the name of a method, but I used to then have
6086 6096 to go to the beginning of the line to put a ? if I wanted more
6087 6097 info. Now I can just add the ? and hit return. Convenient.
6088 6098
6089 6099 2001-11-02 Fernando Perez <fperez@colorado.edu>
6090 6100
6091 6101 * Python version check (>=2.1) added.
6092 6102
6093 6103 * Added LazyPython documentation. At this point the docs are quite
6094 6104 a mess. A cleanup is in order.
6095 6105
6096 6106 * Auto-installer created. For some bizarre reason, the zipfiles
6097 6107 module isn't working on my system. So I made a tar version
6098 6108 (hopefully the command line options in various systems won't kill
6099 6109 me).
6100 6110
6101 6111 * Fixes to Struct in genutils. Now all dictionary-like methods are
6102 6112 protected (reasonably).
6103 6113
6104 6114 * Added pager function to genutils and changed ? to print usage
6105 6115 note through it (it was too long).
6106 6116
6107 6117 * Added the LazyPython functionality. Works great! I changed the
6108 6118 auto-quote escape to ';', it's on home row and next to '. But
6109 6119 both auto-quote and auto-paren (still /) escapes are command-line
6110 6120 parameters.
6111 6121
6112 6122
6113 6123 2001-11-01 Fernando Perez <fperez@colorado.edu>
6114 6124
6115 6125 * Version changed to 0.0.7. Fairly large change: configuration now
6116 6126 is all stored in a directory, by default .ipython. There, all
6117 6127 config files have normal looking names (not .names)
6118 6128
6119 6129 * Version 0.0.6 Released first to Lucas and Archie as a test
6120 6130 run. Since it's the first 'semi-public' release, change version to
6121 6131 > 0.0.6 for any changes now.
6122 6132
6123 6133 * Stuff I had put in the ipplib.py changelog:
6124 6134
6125 6135 Changes to InteractiveShell:
6126 6136
6127 6137 - Made the usage message a parameter.
6128 6138
6129 6139 - Require the name of the shell variable to be given. It's a bit
6130 6140 of a hack, but allows the name 'shell' not to be hardwired in the
6131 6141 magic (@) handler, which is problematic b/c it requires
6132 6142 polluting the global namespace with 'shell'. This in turn is
6133 6143 fragile: if a user redefines a variable called shell, things
6134 6144 break.
6135 6145
6136 6146 - magic @: all functions available through @ need to be defined
6137 6147 as magic_<name>, even though they can be called simply as
6138 6148 @<name>. This allows the special command @magic to gather
6139 6149 information automatically about all existing magic functions,
6140 6150 even if they are run-time user extensions, by parsing the shell
6141 6151 instance __dict__ looking for special magic_ names.
6142 6152
6143 6153 - mainloop: added *two* local namespace parameters. This allows
6144 6154 the class to differentiate between parameters which were there
6145 6155 before and after command line initialization was processed. This
6146 6156 way, later @who can show things loaded at startup by the
6147 6157 user. This trick was necessary to make session saving/reloading
6148 6158 really work: ideally after saving/exiting/reloading a session,
6149 6159 *everything* should look the same, including the output of @who. I
6150 6160 was only able to make this work with this double namespace
6151 6161 trick.
6152 6162
6153 6163 - added a header to the logfile which allows (almost) full
6154 6164 session restoring.
6155 6165
6156 6166 - prepend lines beginning with @ or !, with a and log
6157 6167 them. Why? !lines: may be useful to know what you did @lines:
6158 6168 they may affect session state. So when restoring a session, at
6159 6169 least inform the user of their presence. I couldn't quite get
6160 6170 them to properly re-execute, but at least the user is warned.
6161 6171
6162 6172 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now