##// END OF EJS Templates
* IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail...
walter.doerwald -
Show More
@@ -1,390 +1,391 b''
1 1 """
2 2 ``astyle`` provides classes for adding style (foreground and background color;
3 3 bold; blink; etc.) to terminal and curses output.
4 4 """
5 5
6 6
7 7 import sys, os
8 8
9 9 try:
10 10 import curses
11 11 except ImportError:
12 12 curses = None
13 13
14 14
15 15 COLOR_BLACK = 0
16 16 COLOR_RED = 1
17 17 COLOR_GREEN = 2
18 18 COLOR_YELLOW = 3
19 19 COLOR_BLUE = 4
20 20 COLOR_MAGENTA = 5
21 21 COLOR_CYAN = 6
22 22 COLOR_WHITE = 7
23 23
24 24 A_BLINK = 1<<0 # Blinking text
25 25 A_BOLD = 1<<1 # Extra bright or bold text
26 26 A_DIM = 1<<2 # Half bright text
27 27 A_REVERSE = 1<<3 # Reverse-video text
28 28 A_STANDOUT = 1<<4 # The best highlighting mode available
29 29 A_UNDERLINE = 1<<5 # Underlined text
30 30
31 31
32 32 class Style(object):
33 33 """
34 34 Store foreground color, background color and attribute (bold, underlined
35 35 etc.).
36 36 """
37 37 __slots__ = ("fg", "bg", "attrs")
38 38
39 39 COLORNAMES = {
40 40 "black": COLOR_BLACK,
41 41 "red": COLOR_RED,
42 42 "green": COLOR_GREEN,
43 43 "yellow": COLOR_YELLOW,
44 44 "blue": COLOR_BLUE,
45 45 "magenta": COLOR_MAGENTA,
46 46 "cyan": COLOR_CYAN,
47 47 "white": COLOR_WHITE,
48 48 }
49 49 ATTRNAMES = {
50 50 "blink": A_BLINK,
51 51 "bold": A_BOLD,
52 52 "dim": A_DIM,
53 53 "reverse": A_REVERSE,
54 54 "standout": A_STANDOUT,
55 55 "underline": A_UNDERLINE,
56 56 }
57 57
58 58 def __init__(self, fg, bg, attrs=0):
59 59 """
60 60 Create a ``Style`` object with ``fg`` as the foreground color,
61 61 ``bg`` as the background color and ``attrs`` as the attributes.
62 62
63 63 Examples:
64 64
65 65 >>> Style(COLOR_RED, COLOR_BLACK)
66 66 >>> Style(COLOR_YELLOW, COLOR_BLUE, A_BOLD|A_UNDERLINE)
67 67 """
68 68 self.fg = fg
69 69 self.bg = bg
70 70 self.attrs = attrs
71 71
72 72 def __call__(self, *args):
73 73 text = Text()
74 74 for arg in args:
75 75 if isinstance(arg, Text):
76 76 text.extend(arg)
77 77 else:
78 78 text.append((self, arg))
79 79 return text
80 80
81 81 def __eq__(self, other):
82 82 return self.fg == other.fg and self.bg == other.bg and self.attrs == other.attrs
83 83
84 84 def __neq__(self, other):
85 85 return self.fg != other.fg or self.bg != other.bg or self.attrs != other.attrs
86 86
87 87 def __repr__(self):
88 88 color2name = ("black", "red", "green", "yellow", "blue", "magenta", "cyan", "white")
89 89 attrs2name = ("blink", "bold", "dim", "reverse", "standout", "underline")
90 90
91 91 return "<%s fg=%s bg=%s attrs=%s>" % (
92 92 self.__class__.__name__, color2name[self.fg], color2name[self.bg],
93 93 "|".join([attrs2name[b] for b in xrange(6) if self.attrs&(1<<b)]) or 0)
94 94
95 95 def fromstr(cls, value):
96 96 """
97 97 Create a ``Style`` object from a string. The format looks like this:
98 98 ``"red:black:bold|blink"``.
99 99 """
100 100 # defaults
101 101 fg = COLOR_WHITE
102 102 bg = COLOR_BLACK
103 103 attrs = 0
104 104
105 105 parts = value.split(":")
106 106 if len(parts) > 0:
107 107 fg = cls.COLORNAMES[parts[0].lower()]
108 108 if len(parts) > 1:
109 109 bg = cls.COLORNAMES[parts[1].lower()]
110 110 if len(parts) > 2:
111 111 for strattr in parts[2].split("|"):
112 112 attrs |= cls.ATTRNAMES[strattr.lower()]
113 113 return cls(fg, bg, attrs)
114 114 fromstr = classmethod(fromstr)
115 115
116 116 def fromenv(cls, name, default):
117 117 """
118 118 Create a ``Style`` from an environment variable named ``name``
119 119 (using ``default`` if the environment variable doesn't exist).
120 120 """
121 121 return cls.fromstr(os.environ.get(name, default))
122 122 fromenv = classmethod(fromenv)
123 123
124 124
125 125 def switchstyle(s1, s2):
126 126 """
127 127 Return the ANSI escape sequence needed to switch from style ``s1`` to
128 128 style ``s2``.
129 129 """
130 130 attrmask = (A_BLINK|A_BOLD|A_UNDERLINE|A_REVERSE)
131 131 a1 = s1.attrs & attrmask
132 132 a2 = s2.attrs & attrmask
133 133
134 134 args = []
135 135 if s1 != s2:
136 136 # do we have to get rid of the bold/underline/blink bit?
137 137 # (can only be done by a reset)
138 138 # use reset when our target color is the default color
139 139 # (this is shorter than 37;40)
140 140 if (a1 & ~a2 or s2==style_default):
141 141 args.append("0")
142 142 s1 = style_default
143 143 a1 = 0
144 144
145 145 # now we know that old and new color have the same boldness,
146 146 # or the new color is bold and the old isn't,
147 147 # i.e. we only might have to switch bold on, not off
148 148 if not (a1 & A_BOLD) and (a2 & A_BOLD):
149 149 args.append("1")
150 150
151 151 # Fix underline
152 152 if not (a1 & A_UNDERLINE) and (a2 & A_UNDERLINE):
153 153 args.append("4")
154 154
155 155 # Fix blink
156 156 if not (a1 & A_BLINK) and (a2 & A_BLINK):
157 157 args.append("5")
158 158
159 159 # Fix reverse
160 160 if not (a1 & A_REVERSE) and (a2 & A_REVERSE):
161 161 args.append("7")
162 162
163 163 # Fix foreground color
164 164 if s1.fg != s2.fg:
165 165 args.append("3%d" % s2.fg)
166 166
167 167 # Finally fix the background color
168 168 if s1.bg != s2.bg:
169 169 args.append("4%d" % s2.bg)
170 170
171 171 if args:
172 172 return "\033[%sm" % ";".join(args)
173 173 return ""
174 174
175 175
176 176 class Text(list):
177 177 """
178 178 A colored string. A ``Text`` object is a sequence, the sequence
179 179 items will be ``(style, string)`` tuples.
180 180 """
181 181
182 182 def __init__(self, *args):
183 183 list.__init__(self)
184 184 self.append(*args)
185 185
186 186 def __repr__(self):
187 187 return "%s.%s(%s)" % (
188 188 self.__class__.__module__, self.__class__.__name__,
189 189 list.__repr__(self)[1:-1])
190 190
191 191 def append(self, *args):
192 192 for arg in args:
193 193 if isinstance(arg, Text):
194 194 self.extend(arg)
195 195 elif isinstance(arg, tuple): # must be (style, string)
196 196 list.append(self, arg)
197 197 elif isinstance(arg, unicode):
198 198 list.append(self, (style_default, arg))
199 199 else:
200 200 list.append(self, (style_default, str(arg)))
201 201
202 202 def insert(self, index, *args):
203 203 self[index:index] = Text(*args)
204 204
205 205 def __add__(self, other):
206 206 new = Text()
207 207 new.append(self)
208 208 new.append(other)
209 209 return new
210 210
211 211 def __iadd__(self, other):
212 212 self.append(other)
213 213 return self
214 214
215 215 def format(self, styled=True):
216 216 """
217 217 This generator yields the strings that will make up the final
218 218 colorized string.
219 219 """
220 220 if styled:
221 221 oldstyle = style_default
222 222 for (style, string) in self:
223 223 if not isinstance(style, (int, long)):
224 224 switch = switchstyle(oldstyle, style)
225 225 if switch:
226 226 yield switch
227 227 if string:
228 228 yield string
229 229 oldstyle = style
230 230 switch = switchstyle(oldstyle, style_default)
231 231 if switch:
232 232 yield switch
233 233 else:
234 234 for (style, string) in self:
235 235 if not isinstance(style, (int, long)):
236 236 yield string
237 237
238 238 def string(self, styled=True):
239 239 """
240 240 Return the resulting string (with escape sequences, if ``styled``
241 241 is true).
242 242 """
243 243 return "".join(self.format(styled))
244 244
245 245 def __str__(self):
246 246 """
247 247 Return ``self`` as a string (without ANSI escape sequences).
248 248 """
249 249 return self.string(False)
250 250
251 251 def write(self, stream, styled=True):
252 252 """
253 253 Write ``self`` to the output stream ``stream`` (with escape sequences,
254 254 if ``styled`` is true).
255 255 """
256 256 for part in self.format(styled):
257 257 stream.write(part)
258 258
259 259 def __xrepr__(self, mode="default"):
260 260 yield (-1, True)
261 261 for info in self:
262 262 yield info
263 263
264 264
265 265 def streamstyle(stream, styled=None):
266 266 """
267 267 If ``styled`` is ``None``, return whether ``stream`` refers to a terminal.
268 268 If this can't be determined (either because ``stream`` doesn't refer to a
269 269 real OS file, or because you're on Windows) return ``False``. If ``styled``
270 270 is not ``None`` ``styled`` will be returned unchanged.
271 271 """
272 272 if styled is None:
273 273 try:
274 274 styled = os.isatty(stream.fileno())
275 275 except (KeyboardInterrupt, SystemExit):
276 276 raise
277 277 except Exception:
278 278 styled = False
279 279 return styled
280 280
281 281
282 282 def write(stream, styled, *texts):
283 283 """
284 284 Write ``texts`` to ``stream``.
285 285 """
286 286 text = Text(*texts)
287 287 text.write(stream, streamstyle(stream, styled))
288 288
289 289
290 290 def writeln(stream, styled, *texts):
291 291 """
292 292 Write ``texts`` to ``stream`` and finish with a line feed.
293 293 """
294 294 write(stream, styled, *texts)
295 295 stream.write("\n")
296 296
297 297
298 298 class Stream(object):
299 299 """
300 300 Stream wrapper that adds color output.
301 301 """
302 302 def __init__(self, stream, styled=None):
303 303 self.stream = stream
304 304 self.styled = streamstyle(stream, styled)
305 305
306 306 def write(self, *texts):
307 307 write(self.stream, self.styled, *texts)
308 308
309 309 def writeln(self, *texts):
310 310 writeln(self.stream, self.styled, *texts)
311 311
312 312 def __getattr__(self, name):
313 313 return getattr(self.stream, name)
314 314
315 315
316 316 class stdout(object):
317 317 """
318 318 Stream wrapper for ``sys.stdout`` that adds color output.
319 319 """
320 320 def write(self, *texts):
321 321 write(sys.stdout, None, *texts)
322 322
323 323 def writeln(self, *texts):
324 324 writeln(sys.stdout, None, *texts)
325 325
326 326 def __getattr__(self, name):
327 327 return getattr(sys.stdout, name)
328 328 stdout = stdout()
329 329
330 330
331 331 class stderr(object):
332 332 """
333 333 Stream wrapper for ``sys.stderr`` that adds color output.
334 334 """
335 335 def write(self, *texts):
336 336 write(sys.stderr, None, *texts)
337 337
338 338 def writeln(self, *texts):
339 339 writeln(sys.stderr, None, *texts)
340 340
341 341 def __getattr__(self, name):
342 342 return getattr(sys.stdout, name)
343 343 stderr = stderr()
344 344
345 345
346 346 if curses is not None:
347 347 # This is probably just range(8)
348 348 COLOR2CURSES = [
349 349 COLOR_BLACK,
350 350 COLOR_RED,
351 351 COLOR_GREEN,
352 352 COLOR_YELLOW,
353 353 COLOR_BLUE,
354 354 COLOR_MAGENTA,
355 355 COLOR_CYAN,
356 356 COLOR_WHITE,
357 357 ]
358 358
359 359 A2CURSES = {
360 360 A_BLINK: curses.A_BLINK,
361 361 A_BOLD: curses.A_BOLD,
362 362 A_DIM: curses.A_DIM,
363 363 A_REVERSE: curses.A_REVERSE,
364 364 A_STANDOUT: curses.A_STANDOUT,
365 365 A_UNDERLINE: curses.A_UNDERLINE,
366 366 }
367 367
368 368
369 369 # default style
370 370 style_default = Style.fromstr("white:black")
371 371
372 372 # Styles for datatypes
373 373 style_type_none = Style.fromstr("magenta:black")
374 374 style_type_bool = Style.fromstr("magenta:black")
375 375 style_type_number = Style.fromstr("yellow:black")
376 376 style_type_datetime = Style.fromstr("magenta:black")
377 style_type_type = Style.fromstr("cyan:black")
377 378
378 379 # Style for URLs and file/directory names
379 380 style_url = Style.fromstr("green:black")
380 381 style_dir = Style.fromstr("cyan:black")
381 382 style_file = Style.fromstr("green:black")
382 383
383 384 # Style for ellipsis (when an output has been shortened
384 385 style_ellisis = Style.fromstr("red:black")
385 386
386 387 # Style for displaying exceptions
387 388 style_error = Style.fromstr("red:black")
388 389
389 390 # Style for displaying non-existing attributes
390 391 style_nodata = Style.fromstr("red:black")
@@ -1,1665 +1,1679 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
16 16 class UnassignedKeyError(Exception):
17 17 """
18 18 Exception that is used for reporting unassigned keys.
19 19 """
20 20
21 21
22 22 class UnknownCommandError(Exception):
23 23 """
24 24 Exception that is used for reporting unknown command (this should never
25 25 happen).
26 26 """
27 27
28 28
29 29 class CommandError(Exception):
30 30 """
31 31 Exception that is used for reporting that a command can't be executed.
32 32 """
33 33
34 34
35 35 class Keymap(dict):
36 36 """
37 37 Stores mapping of keys to commands.
38 38 """
39 39 def __init__(self):
40 40 self._keymap = {}
41 41
42 42 def __setitem__(self, key, command):
43 43 if isinstance(key, str):
44 44 for c in key:
45 45 dict.__setitem__(self, ord(c), command)
46 46 else:
47 47 dict.__setitem__(self, key, command)
48 48
49 49 def __getitem__(self, key):
50 50 if isinstance(key, str):
51 51 key = ord(key)
52 52 return dict.__getitem__(self, key)
53 53
54 54 def __detitem__(self, key):
55 55 if isinstance(key, str):
56 56 key = ord(key)
57 57 dict.__detitem__(self, key)
58 58
59 59 def register(self, command, *keys):
60 60 for key in keys:
61 61 self[key] = command
62 62
63 63 def get(self, key, default=None):
64 64 if isinstance(key, str):
65 65 key = ord(key)
66 66 return dict.get(self, key, default)
67 67
68 68 def findkey(self, command, default=ipipe.noitem):
69 69 for (key, commandcandidate) in self.iteritems():
70 70 if commandcandidate == command:
71 71 return key
72 72 if default is ipipe.noitem:
73 73 raise KeyError(command)
74 74 return default
75 75
76 76
77 77 class _BrowserCachedItem(object):
78 78 # This is used internally by ``ibrowse`` to store a item together with its
79 79 # marked status.
80 80 __slots__ = ("item", "marked")
81 81
82 82 def __init__(self, item):
83 83 self.item = item
84 84 self.marked = False
85 85
86 86
87 87 class _BrowserHelp(object):
88 88 style_header = astyle.Style.fromstr("yellow:black:bold")
89 89 # This is used internally by ``ibrowse`` for displaying the help screen.
90 90 def __init__(self, browser):
91 91 self.browser = browser
92 92
93 93 def __xrepr__(self, mode):
94 94 yield (-1, True)
95 95 if mode == "header" or mode == "footer":
96 96 yield (astyle.style_default, "ibrowse help screen")
97 97 else:
98 98 yield (astyle.style_default, repr(self))
99 99
100 def __xiter__(self, mode):
100 def __iter__(self):
101 101 # Get reverse key mapping
102 102 allkeys = {}
103 103 for (key, cmd) in self.browser.keymap.iteritems():
104 104 allkeys.setdefault(cmd, []).append(key)
105 105
106 106 fields = ("key", "description")
107 107
108 108 commands = []
109 109 for name in dir(self.browser):
110 110 if name.startswith("cmd_"):
111 111 command = getattr(self.browser, name)
112 112 commands.append((inspect.getsourcelines(command)[-1], name[4:], command))
113 113 commands.sort()
114 114 commands = [(c[1], c[2]) for c in commands]
115 115 for (i, (name, command)) in enumerate(commands):
116 116 if i:
117 117 yield ipipe.Fields(fields, key="", description="")
118 118
119 119 description = command.__doc__
120 120 if description is None:
121 121 lines = []
122 122 else:
123 123 lines = [l.strip() for l in description.splitlines() if l.strip()]
124 124 description = "\n".join(lines)
125 125 lines = textwrap.wrap(description, 60)
126 126 keys = allkeys.get(name, [])
127 127
128 yield ipipe.Fields(fields, description=astyle.Text((self.style_header, name)))
128 yield ipipe.Fields(fields, key="", description=astyle.Text((self.style_header, name)))
129 129 for i in xrange(max(len(keys), len(lines))):
130 130 try:
131 131 key = self.browser.keylabel(keys[i])
132 132 except IndexError:
133 133 key = ""
134 134 try:
135 135 line = lines[i]
136 136 except IndexError:
137 137 line = ""
138 138 yield ipipe.Fields(fields, key=key, description=line)
139 139
140 140
141 141 class _BrowserLevel(object):
142 142 # This is used internally to store the state (iterator, fetch items,
143 143 # position of cursor and screen, etc.) of one browser level
144 144 # An ``ibrowse`` object keeps multiple ``_BrowserLevel`` objects in
145 145 # a stack.
146 146 def __init__(self, browser, input, iterator, mainsizey, *attrs):
147 147 self.browser = browser
148 148 self.input = input
149 149 self.header = [x for x in ipipe.xrepr(input, "header") if not isinstance(x[0], int)]
150 150 # iterator for the input
151 151 self.iterator = iterator
152 152
153 153 # is the iterator exhausted?
154 154 self.exhausted = False
155 155
156 156 # attributes to be display (autodetected if empty)
157 157 self.attrs = attrs
158 158
159 159 # fetched items (+ marked flag)
160 160 self.items = ipipe.deque()
161 161
162 162 # Number of marked objects
163 163 self.marked = 0
164 164
165 165 # Vertical cursor position
166 166 self.cury = 0
167 167
168 168 # Horizontal cursor position
169 169 self.curx = 0
170 170
171 171 # Index of first data column
172 172 self.datastartx = 0
173 173
174 174 # Index of first data line
175 175 self.datastarty = 0
176 176
177 177 # height of the data display area
178 178 self.mainsizey = mainsizey
179 179
180 180 # width of the data display area (changes when scrolling)
181 181 self.mainsizex = 0
182 182
183 183 # Size of row number (changes when scrolling)
184 184 self.numbersizex = 0
185 185
186 # Attribute names to display (in this order)
186 # Attributes to display (in this order)
187 187 self.displayattrs = []
188 188
189 # index and name of attribute under the cursor
189 # index and attribute under the cursor
190 190 self.displayattr = (None, ipipe.noitem)
191 191
192 # Maps attribute names to column widths
192 # Maps attributes to column widths
193 193 self.colwidths = {}
194 194
195 195 # Set of hidden attributes
196 196 self.hiddenattrs = set()
197 197
198 198 # This takes care of all the caches etc.
199 199 self.moveto(0, 0, refresh=True)
200 200
201 201 def fetch(self, count):
202 202 # Try to fill ``self.items`` with at least ``count`` objects.
203 203 have = len(self.items)
204 204 while not self.exhausted and have < count:
205 205 try:
206 206 item = self.iterator.next()
207 207 except StopIteration:
208 208 self.exhausted = True
209 209 break
210 except (KeyboardInterrupt, SystemExit):
211 raise
212 except Exception, exc:
213 have += 1
214 self.items.append(_BrowserCachedItem(exc))
215 self.exhausted = True
216 break
210 217 else:
211 218 have += 1
212 219 self.items.append(_BrowserCachedItem(item))
213 220
214 221 def calcdisplayattrs(self):
215 222 # Calculate which attributes are available from the objects that are
216 223 # currently visible on screen (and store it in ``self.displayattrs``)
217 224
218 attrnames = set()
225 attrs = set()
219 226 self.displayattrs = []
220 227 if self.attrs:
221 228 # If the browser object specifies a fixed list of attributes,
222 229 # simply use it (removing hidden attributes).
223 for attrname in self.attrs:
224 if attrname not in attrnames and attrname not in self.hiddenattrs:
225 self.displayattrs.append(attrname)
226 attrnames.add(attrname)
230 for attr in self.attrs:
231 attr = ipipe.upgradexattr(attr)
232 if attr not in attrs and attr not in self.hiddenattrs:
233 self.displayattrs.append(attr)
234 attrs.add(attr)
227 235 else:
228 236 endy = min(self.datastarty+self.mainsizey, len(self.items))
229 237 for i in xrange(self.datastarty, endy):
230 for attrname in ipipe.xattrs(self.items[i].item, "default"):
231 if attrname not in attrnames and attrname not in self.hiddenattrs:
232 self.displayattrs.append(attrname)
233 attrnames.add(attrname)
238 for attr in ipipe.xattrs(self.items[i].item, "default"):
239 if attr not in attrs and attr not in self.hiddenattrs:
240 self.displayattrs.append(attr)
241 attrs.add(attr)
234 242
235 243 def getrow(self, i):
236 244 # Return a dictinary with the attributes for the object
237 245 # ``self.items[i]``. Attribute names are taken from
238 246 # ``self.displayattrs`` so ``calcdisplayattrs()`` must have been
239 247 # called before.
240 248 row = {}
241 249 item = self.items[i].item
242 for attrname in self.displayattrs:
250 for attr in self.displayattrs:
243 251 try:
244 value = ipipe._getattr(item, attrname, ipipe.noitem)
252 value = attr.value(item)
245 253 except (KeyboardInterrupt, SystemExit):
246 254 raise
247 255 except Exception, exc:
248 256 value = exc
249 257 # only store attribute if it exists (or we got an exception)
250 258 if value is not ipipe.noitem:
251 259 # remember alignment, length and colored text
252 row[attrname] = ipipe.xformat(value, "cell", self.browser.maxattrlength)
260 row[attr] = ipipe.xformat(value, "cell", self.browser.maxattrlength)
253 261 return row
254 262
255 263 def calcwidths(self):
256 264 # Recalculate the displayed fields and their widths.
257 265 # ``calcdisplayattrs()'' must have been called and the cache
258 266 # for attributes of the objects on screen (``self.displayrows``)
259 267 # must have been filled. This returns a dictionary mapping
260 268 # column names to widths.
261 269 self.colwidths = {}
262 270 for row in self.displayrows:
263 for attrname in self.displayattrs:
271 for attr in self.displayattrs:
264 272 try:
265 length = row[attrname][1]
273 length = row[attr][1]
266 274 except KeyError:
267 275 length = 0
268 276 # always add attribute to colwidths, even if it doesn't exist
269 if attrname not in self.colwidths:
270 self.colwidths[attrname] = len(ipipe._attrname(attrname))
271 newwidth = max(self.colwidths[attrname], length)
272 self.colwidths[attrname] = newwidth
277 if attr not in self.colwidths:
278 self.colwidths[attr] = len(attr.name())
279 newwidth = max(self.colwidths[attr], length)
280 self.colwidths[attr] = newwidth
273 281
274 282 # How many characters do we need to paint the largest item number?
275 283 self.numbersizex = len(str(self.datastarty+self.mainsizey-1))
276 284 # How must space have we got to display data?
277 285 self.mainsizex = self.browser.scrsizex-self.numbersizex-3
278 286 # width of all columns
279 287 self.datasizex = sum(self.colwidths.itervalues()) + len(self.colwidths)
280 288
281 289 def calcdisplayattr(self):
282 290 # Find out which attribute the cursor is on and store this
283 291 # information in ``self.displayattr``.
284 292 pos = 0
285 for (i, attrname) in enumerate(self.displayattrs):
286 if pos+self.colwidths[attrname] >= self.curx:
287 self.displayattr = (i, attrname)
293 for (i, attr) in enumerate(self.displayattrs):
294 if pos+self.colwidths[attr] >= self.curx:
295 self.displayattr = (i, attr)
288 296 break
289 pos += self.colwidths[attrname]+1
297 pos += self.colwidths[attr]+1
290 298 else:
291 299 self.displayattr = (None, ipipe.noitem)
292 300
293 301 def moveto(self, x, y, refresh=False):
294 302 # Move the cursor to the position ``(x,y)`` (in data coordinates,
295 303 # not in screen coordinates). If ``refresh`` is true, all cached
296 304 # values will be recalculated (e.g. because the list has been
297 305 # resorted, so screen positions etc. are no longer valid).
298 306 olddatastarty = self.datastarty
299 307 oldx = self.curx
300 308 oldy = self.cury
301 309 x = int(x+0.5)
302 310 y = int(y+0.5)
303 311 newx = x # remember where we wanted to move
304 312 newy = y # remember where we wanted to move
305 313
306 314 scrollbordery = min(self.browser.scrollbordery, self.mainsizey//2)
307 315 scrollborderx = min(self.browser.scrollborderx, self.mainsizex//2)
308 316
309 317 # Make sure that the cursor didn't leave the main area vertically
310 318 if y < 0:
311 319 y = 0
312 320 # try to get enough items to fill the screen
313 321 self.fetch(max(y+scrollbordery+1, self.mainsizey))
314 322 if y >= len(self.items):
315 323 y = max(0, len(self.items)-1)
316 324
317 325 # Make sure that the cursor stays on screen vertically
318 326 if y < self.datastarty+scrollbordery:
319 327 self.datastarty = max(0, y-scrollbordery)
320 328 elif y >= self.datastarty+self.mainsizey-scrollbordery:
321 329 self.datastarty = max(0, min(y-self.mainsizey+scrollbordery+1,
322 330 len(self.items)-self.mainsizey))
323 331
324 332 if refresh: # Do we need to refresh the complete display?
325 333 self.calcdisplayattrs()
326 334 endy = min(self.datastarty+self.mainsizey, len(self.items))
327 335 self.displayrows = map(self.getrow, xrange(self.datastarty, endy))
328 336 self.calcwidths()
329 337 # Did we scroll vertically => update displayrows
330 338 # and various other attributes
331 339 elif self.datastarty != olddatastarty:
332 340 # Recalculate which attributes we have to display
333 341 olddisplayattrs = self.displayattrs
334 342 self.calcdisplayattrs()
335 343 # If there are new attributes, recreate the cache
336 344 if self.displayattrs != olddisplayattrs:
337 345 endy = min(self.datastarty+self.mainsizey, len(self.items))
338 346 self.displayrows = map(self.getrow, xrange(self.datastarty, endy))
339 347 elif self.datastarty<olddatastarty: # we did scroll up
340 348 # drop rows from the end
341 349 del self.displayrows[self.datastarty-olddatastarty:]
342 350 # fetch new items
343 351 for i in xrange(min(olddatastarty, self.datastarty+self.mainsizey)-1,
344 352 self.datastarty-1, -1):
345 353 try:
346 354 row = self.getrow(i)
347 355 except IndexError:
348 356 # we didn't have enough objects to fill the screen
349 357 break
350 358 self.displayrows.insert(0, row)
351 359 else: # we did scroll down
352 360 # drop rows from the start
353 361 del self.displayrows[:self.datastarty-olddatastarty]
354 362 # fetch new items
355 363 for i in xrange(max(olddatastarty+self.mainsizey, self.datastarty),
356 364 self.datastarty+self.mainsizey):
357 365 try:
358 366 row = self.getrow(i)
359 367 except IndexError:
360 368 # we didn't have enough objects to fill the screen
361 369 break
362 370 self.displayrows.append(row)
363 371 self.calcwidths()
364 372
365 373 # Make sure that the cursor didn't leave the data area horizontally
366 374 if x < 0:
367 375 x = 0
368 376 elif x >= self.datasizex:
369 377 x = max(0, self.datasizex-1)
370 378
371 379 # Make sure that the cursor stays on screen horizontally
372 380 if x < self.datastartx+scrollborderx:
373 381 self.datastartx = max(0, x-scrollborderx)
374 382 elif x >= self.datastartx+self.mainsizex-scrollborderx:
375 383 self.datastartx = max(0, min(x-self.mainsizex+scrollborderx+1,
376 384 self.datasizex-self.mainsizex))
377 385
378 386 if x == oldx and y == oldy and (x != newx or y != newy): # couldn't move
379 387 self.browser.beep()
380 388 else:
381 389 self.curx = x
382 390 self.cury = y
383 391 self.calcdisplayattr()
384 392
385 393 def sort(self, key, reverse=False):
386 394 """
387 395 Sort the currently list of items using the key function ``key``. If
388 396 ``reverse`` is true the sort order is reversed.
389 397 """
390 398 curitem = self.items[self.cury] # Remember where the cursor is now
391 399
392 400 # Sort items
393 401 def realkey(item):
394 402 return key(item.item)
395 403 self.items = ipipe.deque(sorted(self.items, key=realkey, reverse=reverse))
396 404
397 405 # Find out where the object under the cursor went
398 406 cury = self.cury
399 407 for (i, item) in enumerate(self.items):
400 408 if item is curitem:
401 409 cury = i
402 410 break
403 411
404 412 self.moveto(self.curx, cury, refresh=True)
405 413
406 414
407 415 class _CommandInput(object):
408 416 keymap = Keymap()
409 417 keymap.register("left", curses.KEY_LEFT)
410 418 keymap.register("right", curses.KEY_RIGHT)
411 419 keymap.register("home", curses.KEY_HOME, "\x01") # Ctrl-A
412 420 keymap.register("end", curses.KEY_END, "\x05") # Ctrl-E
413 421 # FIXME: What's happening here?
414 422 keymap.register("backspace", curses.KEY_BACKSPACE, "\x08\x7f")
415 423 keymap.register("delete", curses.KEY_DC)
416 424 keymap.register("delend", 0x0b) # Ctrl-K
417 425 keymap.register("execute", "\r\n")
418 426 keymap.register("up", curses.KEY_UP)
419 427 keymap.register("down", curses.KEY_DOWN)
420 428 keymap.register("incsearchup", curses.KEY_PPAGE)
421 429 keymap.register("incsearchdown", curses.KEY_NPAGE)
422 430 keymap.register("exit", "\x18"), # Ctrl-X
423 431
424 432 def __init__(self, prompt):
425 433 self.prompt = prompt
426 434 self.history = []
427 435 self.maxhistory = 100
428 436 self.input = ""
429 437 self.curx = 0
430 438 self.cury = -1 # blank line
431 439
432 440 def start(self):
433 441 self.input = ""
434 442 self.curx = 0
435 443 self.cury = -1 # blank line
436 444
437 445 def handlekey(self, browser, key):
438 446 cmdname = self.keymap.get(key, None)
439 447 if cmdname is not None:
440 448 cmdfunc = getattr(self, "cmd_%s" % cmdname, None)
441 449 if cmdfunc is not None:
442 450 return cmdfunc(browser)
443 451 curses.beep()
444 452 elif key != -1:
445 453 try:
446 454 char = chr(key)
447 455 except ValueError:
448 456 curses.beep()
449 457 else:
450 458 return self.handlechar(browser, char)
451 459
452 460 def handlechar(self, browser, char):
453 461 self.input = self.input[:self.curx] + char + self.input[self.curx:]
454 462 self.curx += 1
455 463 return True
456 464
457 465 def dohistory(self):
458 466 self.history.insert(0, self.input)
459 467 del self.history[:-self.maxhistory]
460 468
461 469 def cmd_backspace(self, browser):
462 470 if self.curx:
463 471 self.input = self.input[:self.curx-1] + self.input[self.curx:]
464 472 self.curx -= 1
465 473 return True
466 474 else:
467 475 curses.beep()
468 476
469 477 def cmd_delete(self, browser):
470 478 if self.curx<len(self.input):
471 479 self.input = self.input[:self.curx] + self.input[self.curx+1:]
472 480 return True
473 481 else:
474 482 curses.beep()
475 483
476 484 def cmd_delend(self, browser):
477 485 if self.curx<len(self.input):
478 486 self.input = self.input[:self.curx]
479 487 return True
480 488
481 489 def cmd_left(self, browser):
482 490 if self.curx:
483 491 self.curx -= 1
484 492 return True
485 493 else:
486 494 curses.beep()
487 495
488 496 def cmd_right(self, browser):
489 497 if self.curx < len(self.input):
490 498 self.curx += 1
491 499 return True
492 500 else:
493 501 curses.beep()
494 502
495 503 def cmd_home(self, browser):
496 504 if self.curx:
497 505 self.curx = 0
498 506 return True
499 507 else:
500 508 curses.beep()
501 509
502 510 def cmd_end(self, browser):
503 511 if self.curx < len(self.input):
504 512 self.curx = len(self.input)
505 513 return True
506 514 else:
507 515 curses.beep()
508 516
509 517 def cmd_up(self, browser):
510 518 if self.cury < len(self.history)-1:
511 519 self.cury += 1
512 520 self.input = self.history[self.cury]
513 521 self.curx = len(self.input)
514 522 return True
515 523 else:
516 524 curses.beep()
517 525
518 526 def cmd_down(self, browser):
519 527 if self.cury >= 0:
520 528 self.cury -= 1
521 529 if self.cury>=0:
522 530 self.input = self.history[self.cury]
523 531 else:
524 532 self.input = ""
525 533 self.curx = len(self.input)
526 534 return True
527 535 else:
528 536 curses.beep()
529 537
530 538 def cmd_incsearchup(self, browser):
531 539 prefix = self.input[:self.curx]
532 540 cury = self.cury
533 541 while True:
534 542 cury += 1
535 543 if cury >= len(self.history):
536 544 break
537 545 if self.history[cury].startswith(prefix):
538 546 self.input = self.history[cury]
539 547 self.cury = cury
540 548 return True
541 549 curses.beep()
542 550
543 551 def cmd_incsearchdown(self, browser):
544 552 prefix = self.input[:self.curx]
545 553 cury = self.cury
546 554 while True:
547 555 cury -= 1
548 556 if cury <= 0:
549 557 break
550 558 if self.history[cury].startswith(prefix):
551 559 self.input = self.history[self.cury]
552 560 self.cury = cury
553 561 return True
554 562 curses.beep()
555 563
556 564 def cmd_exit(self, browser):
557 565 browser.mode = "default"
558 566 return True
559 567
560 568 def cmd_execute(self, browser):
561 569 raise NotImplementedError
562 570
563 571
564 572 class _CommandGoto(_CommandInput):
565 573 def __init__(self):
566 574 _CommandInput.__init__(self, "goto object #")
567 575
568 576 def handlechar(self, browser, char):
569 577 # Only accept digits
570 578 if not "0" <= char <= "9":
571 579 curses.beep()
572 580 else:
573 581 return _CommandInput.handlechar(self, browser, char)
574 582
575 583 def cmd_execute(self, browser):
576 584 level = browser.levels[-1]
577 585 if self.input:
578 586 self.dohistory()
579 587 level.moveto(level.curx, int(self.input))
580 588 browser.mode = "default"
581 589 return True
582 590
583 591
584 592 class _CommandFind(_CommandInput):
585 593 def __init__(self):
586 594 _CommandInput.__init__(self, "find expression")
587 595
588 596 def cmd_execute(self, browser):
589 597 level = browser.levels[-1]
590 598 if self.input:
591 599 self.dohistory()
592 600 while True:
593 601 cury = level.cury
594 602 level.moveto(level.curx, cury+1)
595 603 if cury == level.cury:
596 604 curses.beep()
597 605 break # hit end
598 606 item = level.items[level.cury].item
599 607 try:
600 608 globals = ipipe.getglobals(None)
601 609 if eval(self.input, globals, ipipe.AttrNamespace(item)):
602 610 break # found something
603 611 except (KeyboardInterrupt, SystemExit):
604 612 raise
605 613 except Exception, exc:
606 614 browser.report(exc)
607 615 curses.beep()
608 616 break # break on error
609 617 browser.mode = "default"
610 618 return True
611 619
612 620
613 621 class _CommandFindBackwards(_CommandInput):
614 622 def __init__(self):
615 623 _CommandInput.__init__(self, "find backwards expression")
616 624
617 625 def cmd_execute(self, browser):
618 626 level = browser.levels[-1]
619 627 if self.input:
620 628 self.dohistory()
621 629 while level.cury:
622 630 level.moveto(level.curx, level.cury-1)
623 631 item = level.items[level.cury].item
624 632 try:
625 633 globals = ipipe.getglobals(None)
626 634 if eval(self.input, globals, ipipe.AttrNamespace(item)):
627 635 break # found something
628 636 except (KeyboardInterrupt, SystemExit):
629 637 raise
630 638 except Exception, exc:
631 639 browser.report(exc)
632 640 curses.beep()
633 641 break # break on error
634 642 else:
635 643 curses.beep()
636 644 browser.mode = "default"
637 645 return True
638 646
639 647
640 648 class ibrowse(ipipe.Display):
641 649 # Show this many lines from the previous screen when paging horizontally
642 650 pageoverlapx = 1
643 651
644 652 # Show this many lines from the previous screen when paging vertically
645 653 pageoverlapy = 1
646 654
647 655 # Start scrolling when the cursor is less than this number of columns
648 656 # away from the left or right screen edge
649 657 scrollborderx = 10
650 658
651 659 # Start scrolling when the cursor is less than this number of lines
652 660 # away from the top or bottom screen edge
653 661 scrollbordery = 5
654 662
655 663 # Accelerate by this factor when scrolling horizontally
656 664 acceleratex = 1.05
657 665
658 666 # Accelerate by this factor when scrolling vertically
659 667 acceleratey = 1.05
660 668
661 669 # The maximum horizontal scroll speed
662 670 # (as a factor of the screen width (i.e. 0.5 == half a screen width)
663 671 maxspeedx = 0.5
664 672
665 673 # The maximum vertical scroll speed
666 674 # (as a factor of the screen height (i.e. 0.5 == half a screen height)
667 675 maxspeedy = 0.5
668 676
669 677 # The maximum number of header lines for browser level
670 678 # if the nesting is deeper, only the innermost levels are displayed
671 679 maxheaders = 5
672 680
673 681 # The approximate maximum length of a column entry
674 682 maxattrlength = 200
675 683
676 684 # Styles for various parts of the GUI
677 685 style_objheadertext = astyle.Style.fromstr("white:black:bold|reverse")
678 686 style_objheadernumber = astyle.Style.fromstr("white:blue:bold|reverse")
679 687 style_objheaderobject = astyle.Style.fromstr("white:black:reverse")
680 688 style_colheader = astyle.Style.fromstr("blue:white:reverse")
681 689 style_colheaderhere = astyle.Style.fromstr("green:black:bold|reverse")
682 690 style_colheadersep = astyle.Style.fromstr("blue:black:reverse")
683 691 style_number = astyle.Style.fromstr("blue:white:reverse")
684 692 style_numberhere = astyle.Style.fromstr("green:black:bold|reverse")
685 693 style_sep = astyle.Style.fromstr("blue:black")
686 694 style_data = astyle.Style.fromstr("white:black")
687 695 style_datapad = astyle.Style.fromstr("blue:black:bold")
688 696 style_footer = astyle.Style.fromstr("black:white")
689 697 style_report = astyle.Style.fromstr("white:black")
690 698
691 699 # Column separator in header
692 700 headersepchar = "|"
693 701
694 702 # Character for padding data cell entries
695 703 datapadchar = "."
696 704
697 705 # Column separator in data area
698 706 datasepchar = "|"
699 707
700 708 # Character to use for "empty" cell (i.e. for non-existing attributes)
701 709 nodatachar = "-"
702 710
703 711 # Prompts for modes that require keyboard input
704 712 prompts = {
705 713 "goto": _CommandGoto(),
706 714 "find": _CommandFind(),
707 715 "findbackwards": _CommandFindBackwards()
708 716 }
709 717
710 718 # Maps curses key codes to "function" names
711 719 keymap = Keymap()
712 720 keymap.register("quit", "q")
713 721 keymap.register("up", curses.KEY_UP)
714 722 keymap.register("down", curses.KEY_DOWN)
715 723 keymap.register("pageup", curses.KEY_PPAGE)
716 724 keymap.register("pagedown", curses.KEY_NPAGE)
717 725 keymap.register("left", curses.KEY_LEFT)
718 726 keymap.register("right", curses.KEY_RIGHT)
719 727 keymap.register("home", curses.KEY_HOME, "\x01")
720 728 keymap.register("end", curses.KEY_END, "\x05")
721 729 keymap.register("prevattr", "<\x1b")
722 730 keymap.register("nextattr", ">\t")
723 731 keymap.register("pick", "p")
724 732 keymap.register("pickattr", "P")
725 733 keymap.register("pickallattrs", "C")
726 734 keymap.register("pickmarked", "m")
727 735 keymap.register("pickmarkedattr", "M")
728 736 keymap.register("enterdefault", "\r\n")
729 737 # FIXME: What's happening here?
730 738 keymap.register("leave", curses.KEY_BACKSPACE, "x\x08\x7f")
731 739 keymap.register("hideattr", "h")
732 740 keymap.register("unhideattrs", "H")
733 741 keymap.register("help", "?")
734 742 keymap.register("enter", "e")
735 743 keymap.register("enterattr", "E")
736 744 keymap.register("detail", "d")
737 745 keymap.register("detailattr", "D")
738 746 keymap.register("tooglemark", " ")
739 747 keymap.register("markrange", "r")
740 748 keymap.register("sortattrasc", "v")
741 749 keymap.register("sortattrdesc", "V")
742 750 keymap.register("goto", "g")
743 751 keymap.register("find", "f")
744 752 keymap.register("findbackwards", "b")
745 753
746 754 def __init__(self, *attrs):
747 755 """
748 756 Create a new browser. If ``attrs`` is not empty, it is the list
749 757 of attributes that will be displayed in the browser, otherwise
750 758 these will be determined by the objects on screen.
751 759 """
752 760 self.attrs = attrs
753 761
754 762 # Stack of browser levels
755 763 self.levels = []
756 764 # how many colums to scroll (Changes when accelerating)
757 765 self.stepx = 1.
758 766
759 767 # how many rows to scroll (Changes when accelerating)
760 768 self.stepy = 1.
761 769
762 770 # Beep on the edges of the data area? (Will be set to ``False``
763 771 # once the cursor hits the edge of the screen, so we don't get
764 772 # multiple beeps).
765 773 self._dobeep = True
766 774
767 775 # Cache for registered ``curses`` colors and styles.
768 776 self._styles = {}
769 777 self._colors = {}
770 778 self._maxcolor = 1
771 779
772 780 # How many header lines do we want to paint (the numbers of levels
773 781 # we have, but with an upper bound)
774 782 self._headerlines = 1
775 783
776 784 # Index of first header line
777 785 self._firstheaderline = 0
778 786
779 787 # curses window
780 788 self.scr = None
781 789 # report in the footer line (error, executed command etc.)
782 790 self._report = None
783 791
784 792 # value to be returned to the caller (set by commands)
785 793 self.returnvalue = None
786 794
787 795 # The mode the browser is in
788 796 # e.g. normal browsing or entering an argument for a command
789 797 self.mode = "default"
790 798
791 799 # set by the SIGWINCH signal handler
792 800 self.resized = False
793 801
794 802 def nextstepx(self, step):
795 803 """
796 804 Accelerate horizontally.
797 805 """
798 806 return max(1., min(step*self.acceleratex,
799 807 self.maxspeedx*self.levels[-1].mainsizex))
800 808
801 809 def nextstepy(self, step):
802 810 """
803 811 Accelerate vertically.
804 812 """
805 813 return max(1., min(step*self.acceleratey,
806 814 self.maxspeedy*self.levels[-1].mainsizey))
807 815
808 816 def getstyle(self, style):
809 817 """
810 818 Register the ``style`` with ``curses`` or get it from the cache,
811 819 if it has been registered before.
812 820 """
813 821 try:
814 822 return self._styles[style.fg, style.bg, style.attrs]
815 823 except KeyError:
816 824 attrs = 0
817 825 for b in astyle.A2CURSES:
818 826 if style.attrs & b:
819 827 attrs |= astyle.A2CURSES[b]
820 828 try:
821 829 color = self._colors[style.fg, style.bg]
822 830 except KeyError:
823 831 curses.init_pair(
824 832 self._maxcolor,
825 833 astyle.COLOR2CURSES[style.fg],
826 834 astyle.COLOR2CURSES[style.bg]
827 835 )
828 836 color = curses.color_pair(self._maxcolor)
829 837 self._colors[style.fg, style.bg] = color
830 838 self._maxcolor += 1
831 839 c = color | attrs
832 840 self._styles[style.fg, style.bg, style.attrs] = c
833 841 return c
834 842
835 843 def addstr(self, y, x, begx, endx, text, style):
836 844 """
837 845 A version of ``curses.addstr()`` that can handle ``x`` coordinates
838 846 that are outside the screen.
839 847 """
840 848 text2 = text[max(0, begx-x):max(0, endx-x)]
841 849 if text2:
842 850 self.scr.addstr(y, max(x, begx), text2, self.getstyle(style))
843 851 return len(text)
844 852
845 853 def addchr(self, y, x, begx, endx, c, l, style):
846 854 x0 = max(x, begx)
847 855 x1 = min(x+l, endx)
848 856 if x1>x0:
849 857 self.scr.addstr(y, x0, c*(x1-x0), self.getstyle(style))
850 858 return l
851 859
852 860 def _calcheaderlines(self, levels):
853 861 # Calculate how many headerlines do we have to display, if we have
854 862 # ``levels`` browser levels
855 863 if levels is None:
856 864 levels = len(self.levels)
857 865 self._headerlines = min(self.maxheaders, levels)
858 866 self._firstheaderline = levels-self._headerlines
859 867
860 868 def getstylehere(self, style):
861 869 """
862 870 Return a style for displaying the original style ``style``
863 871 in the row the cursor is on.
864 872 """
865 873 return astyle.Style(style.fg, astyle.COLOR_BLUE, style.attrs | astyle.A_BOLD)
866 874
867 875 def report(self, msg):
868 876 """
869 877 Store the message ``msg`` for display below the footer line. This
870 878 will be displayed as soon as the screen is redrawn.
871 879 """
872 880 self._report = msg
873 881
874 882 def enter(self, item, mode, *attrs):
875 883 """
876 884 Enter the object ``item`` in the mode ``mode``. If ``attrs`` is
877 885 specified, it will be used as a fixed list of attributes to display.
878 886 """
879 887 try:
880 888 iterator = ipipe.xiter(item, mode)
881 889 except (KeyboardInterrupt, SystemExit):
882 890 raise
883 891 except Exception, exc:
884 892 curses.beep()
885 893 self.report(exc)
886 894 else:
887 895 self._calcheaderlines(len(self.levels)+1)
888 896 level = _BrowserLevel(
889 897 self,
890 898 item,
891 899 iterator,
892 900 self.scrsizey-1-self._headerlines-2,
893 901 *attrs
894 902 )
895 903 self.levels.append(level)
896 904
897 905 def startkeyboardinput(self, mode):
898 906 """
899 907 Enter mode ``mode``, which requires keyboard input.
900 908 """
901 909 self.mode = mode
902 910 self.prompts[mode].start()
903 911
904 912 def keylabel(self, keycode):
905 913 """
906 914 Return a pretty name for the ``curses`` key ``keycode`` (used in the
907 915 help screen and in reports about unassigned keys).
908 916 """
909 917 if keycode <= 0xff:
910 918 specialsnames = {
911 919 ord("\n"): "RETURN",
912 920 ord(" "): "SPACE",
913 921 ord("\t"): "TAB",
914 922 ord("\x7f"): "DELETE",
915 923 ord("\x08"): "BACKSPACE",
916 924 }
917 925 if keycode in specialsnames:
918 926 return specialsnames[keycode]
919 927 elif 0x00 < keycode < 0x20:
920 928 return "CTRL-%s" % chr(keycode + 64)
921 929 return repr(chr(keycode))
922 930 for name in dir(curses):
923 931 if name.startswith("KEY_") and getattr(curses, name) == keycode:
924 932 return name
925 933 return str(keycode)
926 934
927 935 def beep(self, force=False):
928 936 if force or self._dobeep:
929 937 curses.beep()
930 938 # don't beep again (as long as the same key is pressed)
931 939 self._dobeep = False
932 940
933 941 def cmd_up(self):
934 942 """
935 943 Move the cursor to the previous row.
936 944 """
937 945 level = self.levels[-1]
938 946 self.report("up")
939 947 level.moveto(level.curx, level.cury-self.stepy)
940 948
941 949 def cmd_down(self):
942 950 """
943 951 Move the cursor to the next row.
944 952 """
945 953 level = self.levels[-1]
946 954 self.report("down")
947 955 level.moveto(level.curx, level.cury+self.stepy)
948 956
949 957 def cmd_pageup(self):
950 958 """
951 959 Move the cursor up one page.
952 960 """
953 961 level = self.levels[-1]
954 962 self.report("page up")
955 963 level.moveto(level.curx, level.cury-level.mainsizey+self.pageoverlapy)
956 964
957 965 def cmd_pagedown(self):
958 966 """
959 967 Move the cursor down one page.
960 968 """
961 969 level = self.levels[-1]
962 970 self.report("page down")
963 971 level.moveto(level.curx, level.cury+level.mainsizey-self.pageoverlapy)
964 972
965 973 def cmd_left(self):
966 974 """
967 975 Move the cursor left.
968 976 """
969 977 level = self.levels[-1]
970 978 self.report("left")
971 979 level.moveto(level.curx-self.stepx, level.cury)
972 980
973 981 def cmd_right(self):
974 982 """
975 983 Move the cursor right.
976 984 """
977 985 level = self.levels[-1]
978 986 self.report("right")
979 987 level.moveto(level.curx+self.stepx, level.cury)
980 988
981 989 def cmd_home(self):
982 990 """
983 991 Move the cursor to the first column.
984 992 """
985 993 level = self.levels[-1]
986 994 self.report("home")
987 995 level.moveto(0, level.cury)
988 996
989 997 def cmd_end(self):
990 998 """
991 999 Move the cursor to the last column.
992 1000 """
993 1001 level = self.levels[-1]
994 1002 self.report("end")
995 1003 level.moveto(level.datasizex+level.mainsizey-self.pageoverlapx, level.cury)
996 1004
997 1005 def cmd_prevattr(self):
998 1006 """
999 1007 Move the cursor one attribute column to the left.
1000 1008 """
1001 1009 level = self.levels[-1]
1002 1010 if level.displayattr[0] is None or level.displayattr[0] == 0:
1003 1011 self.beep()
1004 1012 else:
1005 1013 self.report("prevattr")
1006 1014 pos = 0
1007 1015 for (i, attrname) in enumerate(level.displayattrs):
1008 1016 if i == level.displayattr[0]-1:
1009 1017 break
1010 1018 pos += level.colwidths[attrname] + 1
1011 1019 level.moveto(pos, level.cury)
1012 1020
1013 1021 def cmd_nextattr(self):
1014 1022 """
1015 1023 Move the cursor one attribute column to the right.
1016 1024 """
1017 1025 level = self.levels[-1]
1018 1026 if level.displayattr[0] is None or level.displayattr[0] == len(level.displayattrs)-1:
1019 1027 self.beep()
1020 1028 else:
1021 1029 self.report("nextattr")
1022 1030 pos = 0
1023 1031 for (i, attrname) in enumerate(level.displayattrs):
1024 1032 if i == level.displayattr[0]+1:
1025 1033 break
1026 1034 pos += level.colwidths[attrname] + 1
1027 1035 level.moveto(pos, level.cury)
1028 1036
1029 1037 def cmd_pick(self):
1030 1038 """
1031 1039 'Pick' the object under the cursor (i.e. the row the cursor is on).
1032 1040 This leaves the browser and returns the picked object to the caller.
1033 (In IPython this object will be available as the '_' variable.)
1041 (In IPython this object will be available as the ``_`` variable.)
1034 1042 """
1035 1043 level = self.levels[-1]
1036 1044 self.returnvalue = level.items[level.cury].item
1037 1045 return True
1038 1046
1039 1047 def cmd_pickattr(self):
1040 1048 """
1041 1049 'Pick' the attribute under the cursor (i.e. the row/column the
1042 1050 cursor is on).
1043 1051 """
1044 1052 level = self.levels[-1]
1045 attrname = level.displayattr[1]
1046 if attrname is ipipe.noitem:
1053 attr = level.displayattr[1]
1054 if attr is ipipe.noitem:
1047 1055 curses.beep()
1048 self.report(AttributeError(ipipe._attrname(attrname)))
1056 self.report(CommandError("no column under cursor"))
1049 1057 return
1050 attr = ipipe._getattr(level.items[level.cury].item, attrname)
1051 if attr is ipipe.noitem:
1058 value = attr.value(level.items[level.cury].item)
1059 if value is ipipe.noitem:
1052 1060 curses.beep()
1053 self.report(AttributeError(ipipe._attrname(attrname)))
1061 self.report(AttributeError(attr.name()))
1054 1062 else:
1055 self.returnvalue = attr
1063 self.returnvalue = value
1056 1064 return True
1057 1065
1058 1066 def cmd_pickallattrs(self):
1059 1067 """
1060 1068 Pick' the complete column under the cursor (i.e. the attribute under
1061 1069 the cursor) from all currently fetched objects. These attributes
1062 1070 will be returned as a list.
1063 1071 """
1064 1072 level = self.levels[-1]
1065 attrname = level.displayattr[1]
1066 if attrname is ipipe.noitem:
1073 attr = level.displayattr[1]
1074 if attr is ipipe.noitem:
1067 1075 curses.beep()
1068 self.report(AttributeError(ipipe._attrname(attrname)))
1076 self.report(CommandError("no column under cursor"))
1069 1077 return
1070 1078 result = []
1071 1079 for cache in level.items:
1072 attr = ipipe._getattr(cache.item, attrname)
1073 if attr is not ipipe.noitem:
1074 result.append(attr)
1080 value = attr.value(cache.item)
1081 if value is not ipipe.noitem:
1082 result.append(value)
1075 1083 self.returnvalue = result
1076 1084 return True
1077 1085
1078 1086 def cmd_pickmarked(self):
1079 1087 """
1080 1088 'Pick' marked objects. Marked objects will be returned as a list.
1081 1089 """
1082 1090 level = self.levels[-1]
1083 1091 self.returnvalue = [cache.item for cache in level.items if cache.marked]
1084 1092 return True
1085 1093
1086 1094 def cmd_pickmarkedattr(self):
1087 1095 """
1088 1096 'Pick' the attribute under the cursor from all marked objects
1089 1097 (This returns a list).
1090 1098 """
1091 1099
1092 1100 level = self.levels[-1]
1093 attrname = level.displayattr[1]
1094 if attrname is ipipe.noitem:
1101 attr = level.displayattr[1]
1102 if attr is ipipe.noitem:
1095 1103 curses.beep()
1096 self.report(AttributeError(ipipe._attrname(attrname)))
1104 self.report(CommandError("no column under cursor"))
1097 1105 return
1098 1106 result = []
1099 1107 for cache in level.items:
1100 1108 if cache.marked:
1101 attr = ipipe._getattr(cache.item, attrname)
1102 if attr is not ipipe.noitem:
1103 result.append(attr)
1109 value = attr.value(cache.item)
1110 if value is not ipipe.noitem:
1111 result.append(value)
1104 1112 self.returnvalue = result
1105 1113 return True
1106 1114
1107 1115 def cmd_markrange(self):
1108 1116 """
1109 1117 Mark all objects from the last marked object before the current cursor
1110 1118 position to the cursor position.
1111 1119 """
1112 1120 level = self.levels[-1]
1113 1121 self.report("markrange")
1114 1122 start = None
1115 1123 if level.items:
1116 1124 for i in xrange(level.cury, -1, -1):
1117 1125 if level.items[i].marked:
1118 1126 start = i
1119 1127 break
1120 1128 if start is None:
1121 1129 self.report(CommandError("no mark before cursor"))
1122 1130 curses.beep()
1123 1131 else:
1124 1132 for i in xrange(start, level.cury+1):
1125 1133 cache = level.items[i]
1126 1134 if not cache.marked:
1127 1135 cache.marked = True
1128 1136 level.marked += 1
1129 1137
1130 1138 def cmd_enterdefault(self):
1131 1139 """
1132 1140 Enter the object under the cursor. (what this mean depends on the object
1133 itself (i.e. how it implements the '__xiter__' method). This opens a new
1141 itself (i.e. how it implements the ``__xiter__`` method). This opens a new
1134 1142 browser 'level'.
1135 1143 """
1136 1144 level = self.levels[-1]
1137 1145 try:
1138 1146 item = level.items[level.cury].item
1139 1147 except IndexError:
1140 1148 self.report(CommandError("No object"))
1141 1149 curses.beep()
1142 1150 else:
1143 1151 self.report("entering object (default mode)...")
1144 1152 self.enter(item, "default")
1145 1153
1146 1154 def cmd_leave(self):
1147 1155 """
1148 1156 Leave the current browser level and go back to the previous one.
1149 1157 """
1150 1158 self.report("leave")
1151 1159 if len(self.levels) > 1:
1152 1160 self._calcheaderlines(len(self.levels)-1)
1153 1161 self.levels.pop(-1)
1154 1162 else:
1155 1163 self.report(CommandError("This is the last level"))
1156 1164 curses.beep()
1157 1165
1158 1166 def cmd_enter(self):
1159 1167 """
1160 1168 Enter the object under the cursor. If the object provides different
1161 1169 enter modes a menu of all modes will be presented; choose one and enter
1162 1170 it (via the 'enter' or 'enterdefault' command).
1163 1171 """
1164 1172 level = self.levels[-1]
1165 1173 try:
1166 1174 item = level.items[level.cury].item
1167 1175 except IndexError:
1168 1176 self.report(CommandError("No object"))
1169 1177 curses.beep()
1170 1178 else:
1171 1179 self.report("entering object...")
1172 1180 self.enter(item, None)
1173 1181
1174 1182 def cmd_enterattr(self):
1175 1183 """
1176 1184 Enter the attribute under the cursor.
1177 1185 """
1178 1186 level = self.levels[-1]
1179 attrname = level.displayattr[1]
1180 if attrname is ipipe.noitem:
1187 attr = level.displayattr[1]
1188 if attr is ipipe.noitem:
1181 1189 curses.beep()
1182 self.report(AttributeError(ipipe._attrname(attrname)))
1190 self.report(CommandError("no column under cursor"))
1183 1191 return
1184 1192 try:
1185 1193 item = level.items[level.cury].item
1186 1194 except IndexError:
1187 1195 self.report(CommandError("No object"))
1188 1196 curses.beep()
1189 1197 else:
1190 attr = ipipe._getattr(item, attrname)
1191 if attr is ipipe.noitem:
1192 self.report(AttributeError(ipipe._attrname(attrname)))
1198 value = attr.value(item)
1199 name = attr.name()
1200 if value is ipipe.noitem:
1201 self.report(AttributeError(name))
1193 1202 else:
1194 self.report("entering object attribute %s..." % ipipe._attrname(attrname))
1195 self.enter(attr, None)
1203 self.report("entering object attribute %s..." % name)
1204 self.enter(value, None)
1196 1205
1197 1206 def cmd_detail(self):
1198 1207 """
1199 1208 Show a detail view of the object under the cursor. This shows the
1200 1209 name, type, doc string and value of the object attributes (and it
1201 1210 might show more attributes than in the list view, depending on
1202 1211 the object).
1203 1212 """
1204 1213 level = self.levels[-1]
1205 1214 try:
1206 1215 item = level.items[level.cury].item
1207 1216 except IndexError:
1208 1217 self.report(CommandError("No object"))
1209 1218 curses.beep()
1210 1219 else:
1211 1220 self.report("entering detail view for object...")
1212 self.enter(item, "detail")
1221 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
1222 self.enter(attrs, "detail")
1213 1223
1214 1224 def cmd_detailattr(self):
1215 1225 """
1216 1226 Show a detail view of the attribute under the cursor.
1217 1227 """
1218 1228 level = self.levels[-1]
1219 attrname = level.displayattr[1]
1220 if attrname is ipipe.noitem:
1229 attr = level.displayattr[1]
1230 if attr is ipipe.noitem:
1221 1231 curses.beep()
1222 self.report(AttributeError(ipipe._attrname(attrname)))
1232 self.report(CommandError("no attribute"))
1223 1233 return
1224 1234 try:
1225 1235 item = level.items[level.cury].item
1226 1236 except IndexError:
1227 1237 self.report(CommandError("No object"))
1228 1238 curses.beep()
1229 1239 else:
1230 attr = ipipe._getattr(item, attrname)
1231 if attr is ipipe.noitem:
1232 self.report(AttributeError(ipipe._attrname(attrname)))
1240 try:
1241 item = attr.value(item)
1242 except (KeyboardInterrupt, SystemExit):
1243 raise
1244 except Exception, exc:
1245 self.report(exc)
1233 1246 else:
1234 self.report("entering detail view for attribute...")
1235 self.enter(attr, "detail")
1247 self.report("entering detail view for attribute %s..." % attr.name())
1248 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
1249 self.enter(attrs, "detail")
1236 1250
1237 1251 def cmd_tooglemark(self):
1238 1252 """
1239 1253 Mark/unmark the object under the cursor. Marked objects have a '!'
1240 1254 after the row number).
1241 1255 """
1242 1256 level = self.levels[-1]
1243 1257 self.report("toggle mark")
1244 1258 try:
1245 1259 item = level.items[level.cury]
1246 1260 except IndexError: # no items?
1247 1261 pass
1248 1262 else:
1249 1263 if item.marked:
1250 1264 item.marked = False
1251 1265 level.marked -= 1
1252 1266 else:
1253 1267 item.marked = True
1254 1268 level.marked += 1
1255 1269
1256 1270 def cmd_sortattrasc(self):
1257 1271 """
1258 1272 Sort the objects (in ascending order) using the attribute under
1259 1273 the cursor as the sort key.
1260 1274 """
1261 1275 level = self.levels[-1]
1262 attrname = level.displayattr[1]
1263 if attrname is ipipe.noitem:
1276 attr = level.displayattr[1]
1277 if attr is ipipe.noitem:
1264 1278 curses.beep()
1265 self.report(AttributeError(ipipe._attrname(attrname)))
1279 self.report(CommandError("no column under cursor"))
1266 1280 return
1267 self.report("sort by %s (ascending)" % ipipe._attrname(attrname))
1281 self.report("sort by %s (ascending)" % attr.name())
1268 1282 def key(item):
1269 1283 try:
1270 return ipipe._getattr(item, attrname, None)
1284 return attr.value(item)
1271 1285 except (KeyboardInterrupt, SystemExit):
1272 1286 raise
1273 1287 except Exception:
1274 1288 return None
1275 1289 level.sort(key)
1276 1290
1277 1291 def cmd_sortattrdesc(self):
1278 1292 """
1279 1293 Sort the objects (in descending order) using the attribute under
1280 1294 the cursor as the sort key.
1281 1295 """
1282 1296 level = self.levels[-1]
1283 attrname = level.displayattr[1]
1284 if attrname is ipipe.noitem:
1297 attr = level.displayattr[1]
1298 if attr is ipipe.noitem:
1285 1299 curses.beep()
1286 self.report(AttributeError(ipipe._attrname(attrname)))
1300 self.report(CommandError("no column under cursor"))
1287 1301 return
1288 self.report("sort by %s (descending)" % ipipe._attrname(attrname))
1302 self.report("sort by %s (descending)" % attr.name())
1289 1303 def key(item):
1290 1304 try:
1291 return ipipe._getattr(item, attrname, None)
1305 return attr.value(item)
1292 1306 except (KeyboardInterrupt, SystemExit):
1293 1307 raise
1294 1308 except Exception:
1295 1309 return None
1296 1310 level.sort(key, reverse=True)
1297 1311
1298 1312 def cmd_hideattr(self):
1299 1313 """
1300 1314 Hide the attribute under the cursor.
1301 1315 """
1302 1316 level = self.levels[-1]
1303 1317 if level.displayattr[0] is None:
1304 1318 self.beep()
1305 1319 else:
1306 1320 self.report("hideattr")
1307 1321 level.hiddenattrs.add(level.displayattr[1])
1308 1322 level.moveto(level.curx, level.cury, refresh=True)
1309 1323
1310 1324 def cmd_unhideattrs(self):
1311 1325 """
1312 1326 Make all attributes visible again.
1313 1327 """
1314 1328 level = self.levels[-1]
1315 1329 self.report("unhideattrs")
1316 1330 level.hiddenattrs.clear()
1317 1331 level.moveto(level.curx, level.cury, refresh=True)
1318 1332
1319 1333 def cmd_goto(self):
1320 1334 """
1321 1335 Jump to a row. The row number can be entered at the
1322 1336 bottom of the screen.
1323 1337 """
1324 1338 self.startkeyboardinput("goto")
1325 1339
1326 1340 def cmd_find(self):
1327 1341 """
1328 1342 Search forward for a row. The search condition can be entered at the
1329 1343 bottom of the screen.
1330 1344 """
1331 1345 self.startkeyboardinput("find")
1332 1346
1333 1347 def cmd_findbackwards(self):
1334 1348 """
1335 1349 Search backward for a row. The search condition can be entered at the
1336 1350 bottom of the screen.
1337 1351 """
1338 1352 self.startkeyboardinput("findbackwards")
1339 1353
1340 1354 def cmd_help(self):
1341 1355 """
1342 1356 Opens the help screen as a new browser level, describing keyboard
1343 1357 shortcuts.
1344 1358 """
1345 1359 for level in self.levels:
1346 1360 if isinstance(level.input, _BrowserHelp):
1347 1361 curses.beep()
1348 1362 self.report(CommandError("help already active"))
1349 1363 return
1350 1364
1351 1365 self.enter(_BrowserHelp(self), "default")
1352 1366
1353 1367 def cmd_quit(self):
1354 1368 """
1355 1369 Quit the browser and return to the IPython prompt.
1356 1370 """
1357 1371 self.returnvalue = None
1358 1372 return True
1359 1373
1360 1374 def sigwinchhandler(self, signal, frame):
1361 1375 self.resized = True
1362 1376
1363 1377 def _dodisplay(self, scr):
1364 1378 """
1365 1379 This method is the workhorse of the browser. It handles screen
1366 1380 drawing and the keyboard.
1367 1381 """
1368 1382 self.scr = scr
1369 1383 curses.halfdelay(1)
1370 1384 footery = 2
1371 1385
1372 1386 keys = []
1373 1387 for key in ("quit", "help"):
1374 1388 key = self.keymap.findkey(key, None)
1375 1389 if key is not None:
1376 1390 keys.append("%s=quit" % self.keylabel(key))
1377 1391 helpmsg = " | %s" % " ".join(keys)
1378 1392
1379 1393 scr.clear()
1380 1394 msg = "Fetching first batch of objects..."
1381 1395 (self.scrsizey, self.scrsizex) = scr.getmaxyx()
1382 1396 scr.addstr(self.scrsizey//2, (self.scrsizex-len(msg))//2, msg)
1383 1397 scr.refresh()
1384 1398
1385 1399 lastc = -1
1386 1400
1387 1401 self.levels = []
1388 1402 # enter the first level
1389 1403 self.enter(self.input, ipipe.xiter(self.input, "default"), *self.attrs)
1390 1404
1391 1405 self._calcheaderlines(None)
1392 1406
1393 1407 while True:
1394 1408 level = self.levels[-1]
1395 1409 (self.scrsizey, self.scrsizex) = scr.getmaxyx()
1396 1410 level.mainsizey = self.scrsizey-1-self._headerlines-footery
1397 1411
1398 1412 # Paint object header
1399 1413 for i in xrange(self._firstheaderline, self._firstheaderline+self._headerlines):
1400 1414 lv = self.levels[i]
1401 1415 posx = 0
1402 1416 posy = i-self._firstheaderline
1403 1417 endx = self.scrsizex
1404 1418 if i: # not the first level
1405 1419 msg = " (%d/%d" % (self.levels[i-1].cury, len(self.levels[i-1].items))
1406 1420 if not self.levels[i-1].exhausted:
1407 1421 msg += "+"
1408 1422 msg += ") "
1409 1423 endx -= len(msg)+1
1410 1424 posx += self.addstr(posy, posx, 0, endx, " ibrowse #%d: " % i, self.style_objheadertext)
1411 1425 for (style, text) in lv.header:
1412 1426 posx += self.addstr(posy, posx, 0, endx, text, self.style_objheaderobject)
1413 1427 if posx >= endx:
1414 1428 break
1415 1429 if i:
1416 1430 posx += self.addstr(posy, posx, 0, self.scrsizex, msg, self.style_objheadernumber)
1417 1431 posx += self.addchr(posy, posx, 0, self.scrsizex, " ", self.scrsizex-posx, self.style_objheadernumber)
1418 1432
1419 1433 if not level.items:
1420 1434 self.addchr(self._headerlines, 0, 0, self.scrsizex, " ", self.scrsizex, self.style_colheader)
1421 1435 self.addstr(self._headerlines+1, 0, 0, self.scrsizex, " <empty>", astyle.style_error)
1422 1436 scr.clrtobot()
1423 1437 else:
1424 1438 # Paint column headers
1425 1439 scr.move(self._headerlines, 0)
1426 1440 scr.addstr(" %*s " % (level.numbersizex, "#"), self.getstyle(self.style_colheader))
1427 1441 scr.addstr(self.headersepchar, self.getstyle(self.style_colheadersep))
1428 1442 begx = level.numbersizex+3
1429 1443 posx = begx-level.datastartx
1430 for attrname in level.displayattrs:
1431 strattrname = ipipe._attrname(attrname)
1432 cwidth = level.colwidths[attrname]
1433 header = strattrname.ljust(cwidth)
1434 if attrname == level.displayattr[1]:
1444 for attr in level.displayattrs:
1445 attrname = attr.name()
1446 cwidth = level.colwidths[attr]
1447 header = attrname.ljust(cwidth)
1448 if attr is level.displayattr[1]:
1435 1449 style = self.style_colheaderhere
1436 1450 else:
1437 1451 style = self.style_colheader
1438 1452 posx += self.addstr(self._headerlines, posx, begx, self.scrsizex, header, style)
1439 1453 posx += self.addstr(self._headerlines, posx, begx, self.scrsizex, self.headersepchar, self.style_colheadersep)
1440 1454 if posx >= self.scrsizex:
1441 1455 break
1442 1456 else:
1443 1457 scr.addstr(" "*(self.scrsizex-posx), self.getstyle(self.style_colheader))
1444 1458
1445 1459 # Paint rows
1446 1460 posy = self._headerlines+1+level.datastarty
1447 1461 for i in xrange(level.datastarty, min(level.datastarty+level.mainsizey, len(level.items))):
1448 1462 cache = level.items[i]
1449 1463 if i == level.cury:
1450 1464 style = self.style_numberhere
1451 1465 else:
1452 1466 style = self.style_number
1453 1467
1454 1468 posy = self._headerlines+1+i-level.datastarty
1455 1469 posx = begx-level.datastartx
1456 1470
1457 1471 scr.move(posy, 0)
1458 1472 scr.addstr(" %*d%s" % (level.numbersizex, i, " !"[cache.marked]), self.getstyle(style))
1459 1473 scr.addstr(self.headersepchar, self.getstyle(self.style_sep))
1460 1474
1461 1475 for attrname in level.displayattrs:
1462 1476 cwidth = level.colwidths[attrname]
1463 1477 try:
1464 1478 (align, length, parts) = level.displayrows[i-level.datastarty][attrname]
1465 1479 except KeyError:
1466 1480 align = 2
1467 1481 style = astyle.style_nodata
1468 1482 if i == level.cury:
1469 1483 style = self.getstylehere(style)
1470 1484 padstyle = self.style_datapad
1471 1485 sepstyle = self.style_sep
1472 1486 if i == level.cury:
1473 1487 padstyle = self.getstylehere(padstyle)
1474 1488 sepstyle = self.getstylehere(sepstyle)
1475 1489 if align == 2:
1476 1490 posx += self.addchr(posy, posx, begx, self.scrsizex, self.nodatachar, cwidth, style)
1477 1491 else:
1478 1492 if align == 1:
1479 1493 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, cwidth-length, padstyle)
1480 1494 elif align == 0:
1481 1495 pad1 = (cwidth-length)//2
1482 1496 pad2 = cwidth-length-len(pad1)
1483 1497 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, pad1, padstyle)
1484 1498 for (style, text) in parts:
1485 1499 if i == level.cury:
1486 1500 style = self.getstylehere(style)
1487 1501 posx += self.addstr(posy, posx, begx, self.scrsizex, text, style)
1488 1502 if posx >= self.scrsizex:
1489 1503 break
1490 1504 if align == -1:
1491 1505 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, cwidth-length, padstyle)
1492 1506 elif align == 0:
1493 1507 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, pad2, padstyle)
1494 1508 posx += self.addstr(posy, posx, begx, self.scrsizex, self.datasepchar, sepstyle)
1495 1509 else:
1496 1510 scr.clrtoeol()
1497 1511
1498 1512 # Add blank row headers for the rest of the screen
1499 1513 for posy in xrange(posy+1, self.scrsizey-2):
1500 1514 scr.addstr(posy, 0, " " * (level.numbersizex+2), self.getstyle(self.style_colheader))
1501 1515 scr.clrtoeol()
1502 1516
1503 1517 posy = self.scrsizey-footery
1504 1518 # Display footer
1505 1519 scr.addstr(posy, 0, " "*self.scrsizex, self.getstyle(self.style_footer))
1506 1520
1507 1521 if level.exhausted:
1508 1522 flag = ""
1509 1523 else:
1510 1524 flag = "+"
1511 1525
1512 1526 endx = self.scrsizex-len(helpmsg)-1
1513 1527 scr.addstr(posy, endx, helpmsg, self.getstyle(self.style_footer))
1514 1528
1515 1529 posx = 0
1516 1530 msg = " %d%s objects (%d marked): " % (len(level.items), flag, level.marked)
1517 1531 posx += self.addstr(posy, posx, 0, endx, msg, self.style_footer)
1518 1532 try:
1519 1533 item = level.items[level.cury].item
1520 1534 except IndexError: # empty
1521 1535 pass
1522 1536 else:
1523 1537 for (nostyle, text) in ipipe.xrepr(item, "footer"):
1524 1538 if not isinstance(nostyle, int):
1525 1539 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
1526 1540 if posx >= endx:
1527 1541 break
1528 1542
1529 1543 attrstyle = [(astyle.style_default, "no attribute")]
1530 attrname = level.displayattr[1]
1531 if attrname is not ipipe.noitem and attrname is not None:
1544 attr = level.displayattr[1]
1545 if attr is not ipipe.noitem and not isinstance(attr, ipipe.SelfDescriptor):
1532 1546 posx += self.addstr(posy, posx, 0, endx, " | ", self.style_footer)
1533 posx += self.addstr(posy, posx, 0, endx, ipipe._attrname(attrname), self.style_footer)
1547 posx += self.addstr(posy, posx, 0, endx, attr.name(), self.style_footer)
1534 1548 posx += self.addstr(posy, posx, 0, endx, ": ", self.style_footer)
1535 1549 try:
1536 attr = ipipe._getattr(item, attrname)
1550 value = attr.value(item)
1537 1551 except (SystemExit, KeyboardInterrupt):
1538 1552 raise
1539 1553 except Exception, exc:
1540 1554 attr = exc
1541 if attr is not ipipe.noitem:
1542 attrstyle = ipipe.xrepr(attr, "footer")
1555 if value is not ipipe.noitem:
1556 attrstyle = ipipe.xrepr(value, "footer")
1543 1557 for (nostyle, text) in attrstyle:
1544 1558 if not isinstance(nostyle, int):
1545 1559 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
1546 1560 if posx >= endx:
1547 1561 break
1548 1562
1549 1563 try:
1550 1564 # Display input prompt
1551 1565 if self.mode in self.prompts:
1552 1566 history = self.prompts[self.mode]
1553 1567 posx = 0
1554 1568 posy = self.scrsizey-1
1555 1569 posx += self.addstr(posy, posx, 0, endx, history.prompt, astyle.style_default)
1556 1570 posx += self.addstr(posy, posx, 0, endx, " [", astyle.style_default)
1557 1571 if history.cury==-1:
1558 1572 text = "new"
1559 1573 else:
1560 1574 text = str(history.cury+1)
1561 1575 posx += self.addstr(posy, posx, 0, endx, text, astyle.style_type_number)
1562 1576 if history.history:
1563 1577 posx += self.addstr(posy, posx, 0, endx, "/", astyle.style_default)
1564 1578 posx += self.addstr(posy, posx, 0, endx, str(len(history.history)), astyle.style_type_number)
1565 1579 posx += self.addstr(posy, posx, 0, endx, "]: ", astyle.style_default)
1566 1580 inputstartx = posx
1567 1581 posx += self.addstr(posy, posx, 0, endx, history.input, astyle.style_default)
1568 1582 # Display report
1569 1583 else:
1570 1584 if self._report is not None:
1571 1585 if isinstance(self._report, Exception):
1572 1586 style = self.getstyle(astyle.style_error)
1573 1587 if self._report.__class__.__module__ == "exceptions":
1574 1588 msg = "%s: %s" % \
1575 1589 (self._report.__class__.__name__, self._report)
1576 1590 else:
1577 1591 msg = "%s.%s: %s" % \
1578 1592 (self._report.__class__.__module__,
1579 1593 self._report.__class__.__name__, self._report)
1580 1594 else:
1581 1595 style = self.getstyle(self.style_report)
1582 1596 msg = self._report
1583 1597 scr.addstr(self.scrsizey-1, 0, msg[:self.scrsizex], style)
1584 1598 self._report = None
1585 1599 else:
1586 1600 scr.move(self.scrsizey-1, 0)
1587 1601 except curses.error:
1588 1602 # Protect against errors from writing to the last line
1589 1603 pass
1590 1604 scr.clrtoeol()
1591 1605
1592 1606 # Position cursor
1593 1607 if self.mode in self.prompts:
1594 1608 history = self.prompts[self.mode]
1595 1609 scr.move(self.scrsizey-1, inputstartx+history.curx)
1596 1610 else:
1597 1611 scr.move(
1598 1612 1+self._headerlines+level.cury-level.datastarty,
1599 1613 level.numbersizex+3+level.curx-level.datastartx
1600 1614 )
1601 1615 scr.refresh()
1602 1616
1603 1617 # Check keyboard
1604 1618 while True:
1605 1619 c = scr.getch()
1606 1620 if self.resized:
1607 1621 size = fcntl.ioctl(0, tty.TIOCGWINSZ, "12345678")
1608 1622 size = struct.unpack("4H", size)
1609 1623 oldsize = scr.getmaxyx()
1610 1624 scr.erase()
1611 1625 curses.resize_term(size[0], size[1])
1612 1626 newsize = scr.getmaxyx()
1613 1627 scr.erase()
1614 1628 for l in self.levels:
1615 1629 l.mainsizey += newsize[0]-oldsize[0]
1616 1630 l.moveto(l.curx, l.cury, refresh=True)
1617 1631 scr.refresh()
1618 1632 self.resized = False
1619 1633 break # Redisplay
1620 1634 if self.mode in self.prompts:
1621 1635 if self.prompts[self.mode].handlekey(self, c):
1622 1636 break # Redisplay
1623 1637 else:
1624 1638 # if no key is pressed slow down and beep again
1625 1639 if c == -1:
1626 1640 self.stepx = 1.
1627 1641 self.stepy = 1.
1628 1642 self._dobeep = True
1629 1643 else:
1630 1644 # if a different key was pressed slow down and beep too
1631 1645 if c != lastc:
1632 1646 lastc = c
1633 1647 self.stepx = 1.
1634 1648 self.stepy = 1.
1635 1649 self._dobeep = True
1636 1650 cmdname = self.keymap.get(c, None)
1637 1651 if cmdname is None:
1638 1652 self.report(
1639 1653 UnassignedKeyError("Unassigned key %s" %
1640 1654 self.keylabel(c)))
1641 1655 else:
1642 1656 cmdfunc = getattr(self, "cmd_%s" % cmdname, None)
1643 1657 if cmdfunc is None:
1644 1658 self.report(
1645 1659 UnknownCommandError("Unknown command %r" %
1646 1660 (cmdname,)))
1647 1661 elif cmdfunc():
1648 1662 returnvalue = self.returnvalue
1649 1663 self.returnvalue = None
1650 1664 return returnvalue
1651 1665 self.stepx = self.nextstepx(self.stepx)
1652 1666 self.stepy = self.nextstepy(self.stepy)
1653 1667 curses.flushinp() # get rid of type ahead
1654 1668 break # Redisplay
1655 1669 self.scr = None
1656 1670
1657 1671 def display(self):
1658 1672 if hasattr(curses, "resize_term"):
1659 1673 oldhandler = signal.signal(signal.SIGWINCH, self.sigwinchhandler)
1660 1674 try:
1661 1675 return curses.wrapper(self._dodisplay)
1662 1676 finally:
1663 1677 signal.signal(signal.SIGWINCH, oldhandler)
1664 1678 else:
1665 1679 return curses.wrapper(self._dodisplay)
This diff has been collapsed as it changes many lines, (596 lines changed) Show them Hide them
@@ -1,1853 +1,2121 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 ``ls`` (listing the
19 19 current directory, ``ienv`` (listing environment variables), ``ipwd`` (listing
20 20 user account) 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 ``browse`` 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)``. This method must return a
41 41 sequence of attribute names. This sequence may also contain integers, which
42 42 will be treated as sequence indizes. Also supported is ``None``, which uses
43 43 the object itself and callables which will be called with the object as the
44 44 an argument. If ``__xattrs__()`` isn't implemented ``(None,)`` will be used as
45 45 the attribute sequence (i.e. the object itself (it's ``repr()`` format) will
46 46 be being displayed. The global function ``xattrs()`` implements this
47 47 functionality.
48 48
49 49 * When an object ``foo`` is displayed in the header, footer or table cell of the
50 50 browser ``foo.__xrepr__(mode)`` is called. Mode can be ``"header"`` or
51 51 ``"footer"`` for the header or footer line and ``"cell"`` for a table cell.
52 52 ``__xrepr__()```must return an iterable (e.g. by being a generator) which
53 53 produces the following items: The first item should be a tuple containing
54 54 the alignment (-1 left aligned, 0 centered and 1 right aligned) and whether
55 55 the complete output must be displayed or if the browser is allowed to stop
56 56 output after enough text has been produced (e.g. a syntax highlighted text
57 57 line would use ``True``, but for a large data structure (i.e. a nested list,
58 58 tuple or dictionary) ``False`` would be used). The other output ``__xrepr__()``
59 59 may produce is tuples of ``Style```objects and text (which contain the text
60 60 representation of the object; see the ``astyle`` module). If ``__xrepr__()``
61 61 recursively outputs a data structure the function ``xrepr(object, mode)`` can
62 62 be used and ``"default"`` must be passed as the mode in these calls. This in
63 63 turn calls the ``__xrepr__()`` method on ``object`` (or uses ``repr(object)``
64 64 as the string representation if ``__xrepr__()`` doesn't exist).
65 65
66 66 * Objects that can be iterated by ``Pipe``s must implement the method
67 67 ``__xiter__(self, mode)``. ``mode`` can take the following values:
68 68
69 69 - ``"default"``: This is the default value and ist always used by pipeline
70 70 expressions. Other values are only used in the browser.
71 71 - ``None``: This value is passed by the browser. The object must return an
72 72 iterable of ``XMode`` objects describing all modes supported by the object.
73 73 (This should never include ``"default"`` or ``None``).
74 74 - Any other value that the object supports.
75 75
76 76 The global function ``xiter()`` can be called to get such an iterator. If
77 77 the method ``_xiter__`` isn't implemented, ``xiter()`` falls back to
78 78 ``__iter__``. In addition to that, dictionaries and modules receive special
79 79 treatment (returning an iterator over ``(key, value)`` pairs). This makes it
80 80 possible to use dictionaries and modules in pipeline expressions, for example:
81 81
82 82 >>> import sys
83 83 >>> sys | ifilter("isinstance(value, int)") | idump
84 84 key |value
85 85 api_version| 1012
86 86 dllhandle | 503316480
87 87 hexversion | 33817328
88 88 maxint |2147483647
89 89 maxunicode | 65535
90 90 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
91 91 ...
92 92
93 93 Note: The expression strings passed to ``ifilter()`` and ``isort()`` can
94 94 refer to the object to be filtered or sorted via the variable ``_`` and to any
95 95 of the attributes of the object, i.e.:
96 96
97 97 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
98 98
99 99 does the same as
100 100
101 101 >>> sys.modules | ifilter("value is not None") | isort("key.lower()")
102 102
103 103 In addition to expression strings, it's possible to pass callables (taking
104 104 the object as an argument) to ``ifilter()``, ``isort()`` and ``ieval()``:
105 105
106 106 >>> sys | ifilter(lambda _:isinstance(_.value, int)) \
107 107 ... | ieval(lambda _: (_.key, hex(_.value))) | idump
108 108 0 |1
109 109 api_version|0x3f4
110 110 dllhandle |0x1e000000
111 111 hexversion |0x20402f0
112 112 maxint |0x7fffffff
113 113 maxunicode |0xffff
114 114 """
115 115
116 116 import sys, os, os.path, stat, glob, new, csv, datetime, types
117 117 import itertools, mimetypes
118 118
119 119 try: # Python 2.3 compatibility
120 120 import collections
121 121 except ImportError:
122 122 deque = list
123 123 else:
124 124 deque = collections.deque
125 125
126 126 try: # Python 2.3 compatibility
127 127 set
128 128 except NameError:
129 129 import sets
130 130 set = sets.Set
131 131
132 132 try: # Python 2.3 compatibility
133 133 sorted
134 134 except NameError:
135 135 def sorted(iterator, key=None, reverse=False):
136 136 items = list(iterator)
137 137 if key is not None:
138 138 items.sort(lambda i1, i2: cmp(key(i1), key(i2)))
139 139 else:
140 140 items.sort()
141 141 if reverse:
142 142 items.reverse()
143 143 return items
144 144
145 145 try:
146 146 import pwd
147 147 except ImportError:
148 148 pwd = None
149 149
150 150 try:
151 151 import grp
152 152 except ImportError:
153 153 grp = None
154 154
155 155 import path
156 156 try:
157 157 from IPython import genutils, ipapi
158 158 except ImportError:
159 159 genutils = None
160 160 ipapi = None
161 161
162 162 import astyle
163 163
164 164
165 165 __all__ = [
166 166 "ifile", "ils", "iglob", "iwalk", "ipwdentry", "ipwd", "igrpentry", "igrp",
167 167 "icsv", "ix", "ichain", "isort", "ifilter", "ieval", "ienum", "ienv",
168 168 "idump", "iless"
169 169 ]
170 170
171 171
172 172 os.stat_float_times(True) # enable microseconds
173 173
174 174
175 175 class AttrNamespace(object):
176 176 """
177 177 Helper class that is used for providing a namespace for evaluating
178 178 expressions containing attribute names of an object.
179 179 """
180 180 def __init__(self, wrapped):
181 181 self.wrapped = wrapped
182 182
183 183 def __getitem__(self, name):
184 184 if name == "_":
185 185 return self.wrapped
186 186 try:
187 187 return getattr(self.wrapped, name)
188 188 except AttributeError:
189 189 raise KeyError(name)
190 190
191 191 # Python 2.3 compatibility
192 192 # use eval workaround to find out which names are used in the
193 193 # eval string and put them into the locals. This works for most
194 194 # normal uses case, bizarre ones like accessing the locals()
195 195 # will fail
196 196 try:
197 197 eval("_", None, AttrNamespace(None))
198 198 except TypeError:
199 199 real_eval = eval
200 200 def eval(codestring, _globals, _locals):
201 201 """
202 202 eval(source[, globals[, locals]]) -> value
203 203
204 204 Evaluate the source in the context of globals and locals.
205 205 The source may be a string representing a Python expression
206 206 or a code object as returned by compile().
207 207 The globals must be a dictionary and locals can be any mappping.
208 208
209 209 This function is a workaround for the shortcomings of
210 210 Python 2.3's eval.
211 211 """
212 212
213 213 if isinstance(codestring, basestring):
214 214 code = compile(codestring, "_eval", "eval")
215 215 else:
216 216 code = codestring
217 217 newlocals = {}
218 218 for name in code.co_names:
219 219 try:
220 220 newlocals[name] = _locals[name]
221 221 except KeyError:
222 222 pass
223 223 return real_eval(code, _globals, newlocals)
224 224
225 225
226 226 noitem = object()
227 227
228 228 def item(iterator, index, default=noitem):
229 229 """
230 230 Return the ``index``th item from the iterator ``iterator``.
231 231 ``index`` must be an integer (negative integers are relative to the
232 232 end (i.e. the last item produced by the iterator)).
233 233
234 234 If ``default`` is given, this will be the default value when
235 235 the iterator doesn't contain an item at this position. Otherwise an
236 236 ``IndexError`` will be raised.
237 237
238 238 Note that using this function will partially or totally exhaust the
239 239 iterator.
240 240 """
241 241 i = index
242 242 if i>=0:
243 243 for item in iterator:
244 244 if not i:
245 245 return item
246 246 i -= 1
247 247 else:
248 248 i = -index
249 249 cache = deque()
250 250 for item in iterator:
251 251 cache.append(item)
252 252 if len(cache)>i:
253 253 cache.popleft()
254 254 if len(cache)==i:
255 255 return cache.popleft()
256 256 if default is noitem:
257 257 raise IndexError(index)
258 258 else:
259 259 return default
260 260
261 261
262 262 def getglobals(g):
263 263 if g is None:
264 264 if ipapi is not None:
265 265 api = ipapi.get()
266 266 if api is not None:
267 267 return api.user_ns
268 268 return globals()
269 269 return g
270 270
271 271
272 class Descriptor(object):
273 def __hash__(self):
274 return hash(self.__class__) ^ hash(self.key())
275
276 def __eq__(self, other):
277 return self.__class__ is other.__class__ and self.key() == other.key()
278
279 def __ne__(self, other):
280 return self.__class__ is not other.__class__ or self.key() != other.key()
281
282 def key(self):
283 pass
284
285 def name(self):
286 key = self.key()
287 if key is None:
288 return "_"
289 return str(key)
290
291 def attrtype(self, obj):
292 pass
293
294 def valuetype(self, obj):
295 pass
296
297 def value(self, obj):
298 pass
299
300 def doc(self, obj):
301 pass
302
303 def shortdoc(self, obj):
304 doc = self.doc(obj)
305 if doc is not None:
306 doc = doc.strip().splitlines()[0].strip()
307 return doc
308
309 def iter(self, obj):
310 return xiter(self.value(obj))
311
312
313 class SelfDescriptor(Descriptor):
314 def key(self):
315 return None
316
317 def attrtype(self, obj):
318 return "self"
319
320 def valuetype(self, obj):
321 return type(obj)
322
323 def value(self, obj):
324 return obj
325
326 def __repr__(self):
327 return "Self"
328
329 selfdescriptor = SelfDescriptor() # there's no need for more than one
330
331
332 class AttributeDescriptor(Descriptor):
333 __slots__ = ("_name", "_doc")
334
335 def __init__(self, name, doc=None):
336 self._name = name
337 self._doc = doc
338
339 def key(self):
340 return self._name
341
342 def doc(self, obj):
343 return self._doc
344
345 def attrtype(self, obj):
346 return "attr"
347
348 def valuetype(self, obj):
349 return type(getattr(obj, self._name))
350
351 def value(self, obj):
352 return getattr(obj, self._name)
353
354 def __repr__(self):
355 if self._doc is None:
356 return "Attribute(%r)" % self._name
357 else:
358 return "Attribute(%r, %r)" % (self._name, self._doc)
359
360
361 class IndexDescriptor(Descriptor):
362 __slots__ = ("_index",)
363
364 def __init__(self, index):
365 self._index = index
366
367 def key(self):
368 return self._index
369
370 def attrtype(self, obj):
371 return "item"
372
373 def valuetype(self, obj):
374 return type(obj[self._index])
375
376 def value(self, obj):
377 return obj[self._index]
378
379 def __repr__(self):
380 return "Index(%r)" % self._index
381
382
383 class MethodDescriptor(Descriptor):
384 __slots__ = ("_name", "_doc")
385
386 def __init__(self, name, doc=None):
387 self._name = name
388 self._doc = doc
389
390 def key(self):
391 return self._name
392
393 def doc(self, obj):
394 if self._doc is None:
395 return getattr(obj, self._name).__doc__
396 return self._doc
397
398 def attrtype(self, obj):
399 return "method"
400
401 def valuetype(self, obj):
402 return type(self.value(obj))
403
404 def value(self, obj):
405 return getattr(obj, self._name)()
406
407 def __repr__(self):
408 if self._doc is None:
409 return "Method(%r)" % self._name
410 else:
411 return "Method(%r, %r)" % (self._name, self._doc)
412
413
414 class IterAttributeDescriptor(Descriptor):
415 __slots__ = ("_name", "_doc")
416
417 def __init__(self, name, doc=None):
418 self._name = name
419 self._doc = doc
420
421 def key(self):
422 return self._name
423
424 def doc(self, obj):
425 return self._doc
426
427 def attrtype(self, obj):
428 return "iter"
429
430 def valuetype(self, obj):
431 return noitem
432
433 def value(self, obj):
434 return noitem
435
436 def iter(self, obj):
437 return xiter(getattr(obj, self._name))
438
439 def __repr__(self):
440 if self._doc is None:
441 return "IterAttribute(%r)" % self._name
442 else:
443 return "IterAttribute(%r, %r)" % (self._name, self._doc)
444
445
446 class IterMethodDescriptor(Descriptor):
447 __slots__ = ("_name", "_doc")
448
449 def __init__(self, name, doc=None):
450 self._name = name
451 self._doc = doc
452
453 def key(self):
454 return self._name
455
456 def doc(self, obj):
457 if self._doc is None:
458 return getattr(obj, self._name).__doc__
459 return self._doc
460
461 def attrtype(self, obj):
462 return "itermethod"
463
464 def valuetype(self, obj):
465 return noitem
466
467 def value(self, obj):
468 return noitem
469
470 def iter(self, obj):
471 return xiter(getattr(obj, self._name)())
472
473 def __repr__(self):
474 if self._doc is None:
475 return "IterMethod(%r)" % self._name
476 else:
477 return "IterMethod(%r, %r)" % (self._name, self._doc)
478
479
480 class FunctionDescriptor(Descriptor):
481 __slots__ = ("_function", "_name", "_doc")
482
483 def __init__(self, function, name=None, doc=None):
484 self._function = function
485 self._name = name
486 self._doc = doc
487
488 def key(self):
489 return self._function
490
491 def name(self):
492 if self._name is not None:
493 return self._name
494 return getattr(self._function, "__xname__", self._function.__name__)
495
496 def doc(self, obj):
497 if self._doc is None:
498 return self._function.__doc__
499 return self._doc
500
501 def attrtype(self, obj):
502 return "function"
503
504 def valuetype(self, obj):
505 return type(self._function(obj))
506
507 def value(self, obj):
508 return self._function(obj)
509
510 def __repr__(self):
511 if self._doc is None:
512 return "Function(%r)" % self._name
513 else:
514 return "Function(%r, %r)" % (self._name, self._doc)
515
516
272 517 class Table(object):
273 518 """
274 519 A ``Table`` is an object that produces items (just like a normal Python
275 520 iterator/generator does) and can be used as the first object in a pipeline
276 521 expression. The displayhook will open the default browser for such an object
277 522 (instead of simply printing the ``repr()`` result).
278 523 """
279 524
280 525 # We want to support ``foo`` and ``foo()`` in pipeline expression:
281 526 # So we implement the required operators (``|`` and ``+``) in the metaclass,
282 527 # instantiate the class and forward the operator to the instance
283 528 class __metaclass__(type):
284 529 def __iter__(self):
285 530 return iter(self())
286 531
287 532 def __or__(self, other):
288 533 return self() | other
289 534
290 535 def __add__(self, other):
291 536 return self() + other
292 537
293 538 def __radd__(self, other):
294 539 return other + self()
295 540
296 541 def __getitem__(self, index):
297 542 return self()[index]
298 543
299 544 def __getitem__(self, index):
300 545 return item(self, index)
301 546
302 547 def __contains__(self, item):
303 548 for haveitem in self:
304 549 if item == haveitem:
305 550 return True
306 551 return False
307 552
308 553 def __or__(self, other):
309 554 # autoinstantiate right hand side
310 555 if isinstance(other, type) and issubclass(other, (Table, Display)):
311 556 other = other()
312 557 # treat simple strings and functions as ``ieval`` instances
313 558 elif not isinstance(other, Display) and not isinstance(other, Table):
314 559 other = ieval(other)
315 560 # forward operations to the right hand side
316 561 return other.__ror__(self)
317 562
318 563 def __add__(self, other):
319 564 # autoinstantiate right hand side
320 565 if isinstance(other, type) and issubclass(other, Table):
321 566 other = other()
322 567 return ichain(self, other)
323 568
324 569 def __radd__(self, other):
325 570 # autoinstantiate left hand side
326 571 if isinstance(other, type) and issubclass(other, Table):
327 572 other = other()
328 573 return ichain(other, self)
329 574
330 575 def __iter__(self):
331 576 return xiter(self, "default")
332 577
333 578
334 579 class Pipe(Table):
335 580 """
336 581 A ``Pipe`` is an object that can be used in a pipeline expression. It
337 582 processes the objects it gets from its input ``Table``/``Pipe``. Note that
338 583 a ``Pipe`` object can't be used as the first object in a pipeline
339 584 expression, as it doesn't produces items itself.
340 585 """
341 586 class __metaclass__(Table.__metaclass__):
342 587 def __ror__(self, input):
343 588 return input | self()
344 589
345 590 def __ror__(self, input):
346 591 # autoinstantiate left hand side
347 592 if isinstance(input, type) and issubclass(input, Table):
348 593 input = input()
349 594 self.input = input
350 595 return self
351 596
352 597
353 def _getattr(obj, name, default=noitem):
354 """
355 Internal helper for getting an attribute of an item. If ``name`` is ``None``
356 return the object itself. If ``name`` is an integer, use ``__getitem__``
357 instead. If the attribute or item does not exist, return ``default``.
358 """
359 if name is None:
360 return obj
361 elif isinstance(name, basestring):
362 if name.endswith("()"):
363 return getattr(obj, name[:-2], default)()
364 else:
365 return getattr(obj, name, default)
366 elif callable(name):
367 try:
368 return name(obj)
369 except AttributeError:
370 return default
371 else:
372 try:
373 return obj[name]
374 except IndexError:
375 return default
376
377
378 def _attrname(name):
379 """
380 Internal helper that gives a proper name for the attribute ``name``
381 (which might be ``None`` or an ``int``).
382 """
383 if name is None:
384 return "_"
385 elif isinstance(name, basestring):
386 return name
387 elif callable(name):
388 return getattr(name, "__xname__", name.__name__)
389 else:
390 return str(name)
391
392
393 def xrepr(item, mode):
598 def xrepr(item, mode="default"):
394 599 try:
395 600 func = item.__xrepr__
396 601 except AttributeError:
397 602 pass
398 603 else:
399 604 try:
400 605 for x in func(mode):
401 606 yield x
402 607 except (KeyboardInterrupt, SystemExit):
403 608 raise
404 609 except Exception:
405 610 yield (astyle.style_default, repr(item))
406 611 return
407 612 if item is None:
408 613 yield (astyle.style_type_none, repr(item))
409 614 elif isinstance(item, bool):
410 615 yield (astyle.style_type_bool, repr(item))
411 616 elif isinstance(item, str):
412 617 if mode == "cell":
413 618 yield (astyle.style_default, repr(item.expandtabs(tab))[1:-1])
414 619 else:
415 620 yield (astyle.style_default, repr(item))
416 621 elif isinstance(item, unicode):
417 622 if mode == "cell":
418 623 yield (astyle.style_default, repr(item.expandtabs(tab))[2:-1])
419 624 else:
420 625 yield (astyle.style_default, repr(item))
421 626 elif isinstance(item, (int, long, float)):
422 627 yield (1, True)
423 628 yield (astyle.style_type_number, repr(item))
424 629 elif isinstance(item, complex):
425 630 yield (astyle.style_type_number, repr(item))
426 631 elif isinstance(item, datetime.datetime):
427 632 if mode == "cell":
428 633 # Don't use strftime() here, as this requires year >= 1900
429 634 yield (astyle.style_type_datetime,
430 635 "%04d-%02d-%02d %02d:%02d:%02d.%06d" % \
431 636 (item.year, item.month, item.day,
432 637 item.hour, item.minute, item.second,
433 638 item.microsecond),
434 639 )
435 640 else:
436 641 yield (astyle.style_type_datetime, repr(item))
437 642 elif isinstance(item, datetime.date):
438 643 if mode == "cell":
439 644 yield (astyle.style_type_datetime,
440 645 "%04d-%02d-%02d" % (item.year, item.month, item.day))
441 646 else:
442 647 yield (astyle.style_type_datetime, repr(item))
443 648 elif isinstance(item, datetime.time):
444 649 if mode == "cell":
445 650 yield (astyle.style_type_datetime,
446 651 "%02d:%02d:%02d.%06d" % \
447 652 (item.hour, item.minute, item.second, item.microsecond))
448 653 else:
449 654 yield (astyle.style_type_datetime, repr(item))
450 655 elif isinstance(item, datetime.timedelta):
451 656 yield (astyle.style_type_datetime, repr(item))
657 elif isinstance(item, type):
658 if item.__module__ == "__builtin__":
659 yield (astyle.style_type_type, item.__name__)
660 else:
661 yield (astyle.style_type_type, "%s.%s" % (item.__module__, item.__name__))
452 662 elif isinstance(item, Exception):
453 663 if item.__class__.__module__ == "exceptions":
454 664 classname = item.__class__.__name__
455 665 else:
456 666 classname = "%s.%s" % \
457 667 (item.__class__.__module__, item.__class__.__name__)
458 668 if mode == "header" or mode == "footer":
459 669 yield (astyle.style_error, "%s: %s" % (classname, item))
460 670 else:
461 671 yield (astyle.style_error, classname)
462 672 elif isinstance(item, (list, tuple)):
463 673 if mode == "header" or mode == "footer":
464 674 if item.__class__.__module__ == "__builtin__":
465 675 classname = item.__class__.__name__
466 676 else:
467 677 classname = "%s.%s" % \
468 678 (item.__class__.__module__,item.__class__.__name__)
469 679 yield (astyle.style_default,
470 680 "<%s object with %d items at 0x%x>" % \
471 681 (classname, len(item), id(item)))
472 682 else:
473 683 yield (-1, False)
474 684 if isinstance(item, list):
475 685 yield (astyle.style_default, "[")
476 686 end = "]"
477 687 else:
478 688 yield (astyle.style_default, "(")
479 689 end = ")"
480 690 for (i, subitem) in enumerate(item):
481 691 if i:
482 692 yield (astyle.style_default, ", ")
483 693 for part in xrepr(subitem, "default"):
484 694 yield part
485 695 yield (astyle.style_default, end)
486 696 elif isinstance(item, (dict, types.DictProxyType)):
487 697 if mode == "header" or mode == "footer":
488 698 if item.__class__.__module__ == "__builtin__":
489 699 classname = item.__class__.__name__
490 700 else:
491 701 classname = "%s.%s" % \
492 702 (item.__class__.__module__,item.__class__.__name__)
493 703 yield (astyle.style_default,
494 704 "<%s object with %d items at 0x%x>" % \
495 705 (classname, len(item), id(item)))
496 706 else:
497 707 yield (-1, False)
498 708 if isinstance(item, dict):
499 709 yield (astyle.style_default, "{")
500 710 end = "}"
501 711 else:
502 712 yield (astyle.style_default, "dictproxy((")
503 713 end = "})"
504 714 for (i, (key, value)) in enumerate(item.iteritems()):
505 715 if i:
506 716 yield (astyle.style_default, ", ")
507 717 for part in xrepr(key, "default"):
508 718 yield part
509 719 yield (astyle.style_default, ": ")
510 720 for part in xrepr(value, "default"):
511 721 yield part
512 722 yield (astyle.style_default, end)
513 723 else:
514 724 yield (astyle.style_default, repr(item))
515 725
516 726
517 def xattrs(item, mode):
727 def upgradexattr(attr):
728 if attr is None:
729 return selfdescriptor
730 elif isinstance(attr, Descriptor):
731 return attr
732 elif isinstance(attr, str):
733 if attr.endswith("()"):
734 if attr.startswith("-"):
735 return IterMethodDescriptor(attr[1:-2])
736 else:
737 return MethodDescriptor(attr[:-2])
738 else:
739 if attr.startswith("-"):
740 return IterAttributeDescriptor(attr[1:])
741 else:
742 return AttributeDescriptor(attr)
743 elif isinstance(attr, (int, long)):
744 return IndexDescriptor(attr)
745 elif callable(attr):
746 return FunctionDescriptor(attr)
747 else:
748 raise TypeError("can't handle descriptor %r" % attr)
749
750
751 def xattrs(item, mode="default"):
518 752 try:
519 753 func = item.__xattrs__
520 754 except AttributeError:
521 755 if mode == "detail":
522 return dir(item)
756 for attrname in dir(item):
757 yield AttributeDescriptor(attrname)
523 758 else:
524 return (None,)
759 yield selfdescriptor
525 760 else:
526 try:
527 return func(mode)
528 except (KeyboardInterrupt, SystemExit):
529 raise
530 except Exception:
531 return (None,)
761 for attr in func(mode):
762 yield upgradexattr(attr)
532 763
533 764
534 def xiter(item, mode):
535 if mode == "detail":
536 def items():
537 for name in xattrs(item, mode):
538 yield XAttr(item, name)
539 return items()
765 def _isdict(item):
766 try:
767 itermeth = item.__class__.__iter__
768 except (AttributeError, TypeError):
769 return False
770 return itermeth is dict.__iter__ or itermeth is types.DictProxyType.__iter__
771
772
773 def _isstr(item):
774 if not isinstance(item, basestring):
775 return False
776 try:
777 itermeth = item.__class__.__iter__
778 except AttributeError:
779 return True
780 return False # ``__iter__`` has been redefined
781
782
783 def xiter(item, mode="default"):
540 784 try:
541 785 func = item.__xiter__
542 786 except AttributeError:
543 if isinstance(item, (dict, types.DictProxyType)):
787 if _isdict(item):
544 788 def items(item):
545 789 fields = ("key", "value")
546 790 for (key, value) in item.iteritems():
547 791 yield Fields(fields, key=key, value=value)
548 792 return items(item)
549 793 elif isinstance(item, new.module):
550 794 def items(item):
551 795 fields = ("key", "value")
552 796 for key in sorted(item.__dict__):
553 797 yield Fields(fields, key=key, value=getattr(item, key))
554 798 return items(item)
555 elif isinstance(item, basestring):
556 if not len(item):
799 elif _isstr(item):
800 if not item:
557 801 raise ValueError("can't enter empty string")
558 802 lines = item.splitlines()
559 803 if len(lines) <= 1:
560 804 raise ValueError("can't enter one line string")
561 805 return iter(lines)
562 806 return iter(item)
563 807 else:
564 808 return iter(func(mode)) # iter() just to be safe
565 809
566 810
567 811 class ichain(Pipe):
568 812 """
569 813 Chains multiple ``Table``s into one.
570 814 """
571 815
572 816 def __init__(self, *iters):
573 817 self.iters = iters
574 818
575 def __xiter__(self, mode):
819 def __iter__(self):
576 820 return itertools.chain(*self.iters)
577 821
578 822 def __xrepr__(self, mode):
579 823 if mode == "header" or mode == "footer":
580 824 for (i, item) in enumerate(self.iters):
581 825 if i:
582 826 yield (astyle.style_default, "+")
583 827 if isinstance(item, Pipe):
584 828 yield (astyle.style_default, "(")
585 829 for part in xrepr(item, mode):
586 830 yield part
587 831 if isinstance(item, Pipe):
588 832 yield (astyle.style_default, ")")
589 833 else:
590 834 yield (astyle.style_default, repr(self))
591 835
592 836 def __repr__(self):
593 837 args = ", ".join([repr(it) for it in self.iters])
594 838 return "%s.%s(%s)" % \
595 839 (self.__class__.__module__, self.__class__.__name__, args)
596 840
597 841
598 842 class ifile(path.path):
599 843 """
600 844 file (or directory) object.
601 845 """
602 846
603 847 def __add_(self, other):
604 848 return ifile(path._base(self) + other)
605 849
606 850 def __radd_(self, other):
607 851 return ifile(other + path._base(self))
608 852
609 853 def __div_(self, other):
610 854 return ifile(path.__div__(self, other))
611 855
612 856 def getcwd():
613 857 return ifile(path.path.getcwd())
614 858 getcwd.__doc__ = path.path.getcwd.__doc__
615 859 getcwd = staticmethod(getcwd)
616 860
617 861 def abspath(self):
618 862 return ifile(path.path.abspath(self))
619 863 abspath.__doc__ = path.path.abspath.__doc__
620 864
621 865 def normcase(self):
622 866 return ifile(path.path.normcase(self))
623 867 normcase.__doc__ = path.path.normcase.__doc__
624 868
625 869 def normpath(self):
626 870 return ifile(path.path.normpath(self))
627 871 normpath.__doc__ = path.path.normpath.__doc__
628 872
629 873 def realpath(self):
630 874 return ifile(path.path.realpath(self))
631 875 realpath.__doc__ = path.path.realpath.__doc__
632 876
633 877 def expanduser(self):
634 878 return ifile(path.path.expanduser(self))
635 879 expanduser.__doc__ = path.path.expanduser.__doc__
636 880
637 881 def expandvars(self):
638 882 return ifile(path.path.expandvars(self))
639 883 expandvars.__doc__ = path.path.expandvars.__doc__
640 884
641 885 def dirname(self):
642 886 return ifile(path.path.dirname(self))
643 887 dirname.__doc__ = path.path.dirname.__doc__
644 888
645 889 parent = property(dirname, None, None, path.path.parent.__doc__)
646 890
647 891 def splitpath(self):
648 892 (parent, child) = path.path.splitpath(self)
649 893 return (ifile(parent), child)
650 894 splitpath.__doc__ = path.path.splitpath.__doc__
651 895
652 896 def splitdrive(self):
653 897 (drive, rel) = path.path.splitdrive(self)
654 898 return (ifile(drive), rel)
655 899 splitdrive.__doc__ = path.path.splitdrive.__doc__
656 900
657 901 def splitext(self):
658 902 (filename, ext) = path.path.splitext(self)
659 903 return (ifile(filename), ext)
660 904 splitext.__doc__ = path.path.splitext.__doc__
661 905
662 906 if hasattr(path.path, "splitunc"):
663 907 def splitunc(self):
664 908 (unc, rest) = path.path.splitunc(self)
665 909 return (ifile(unc), rest)
666 910 splitunc.__doc__ = path.path.splitunc.__doc__
667 911
668 912 def _get_uncshare(self):
669 913 unc, r = os.path.splitunc(self)
670 914 return ifile(unc)
671 915
672 916 uncshare = property(
673 917 _get_uncshare, None, None,
674 918 """ The UNC mount point for this path.
675 919 This is empty for paths on local drives. """)
676 920
677 921 def joinpath(self, *args):
678 922 return ifile(path.path.joinpath(self, *args))
679 923 joinpath.__doc__ = path.path.joinpath.__doc__
680 924
681 925 def splitall(self):
682 926 return map(ifile, path.path.splitall(self))
683 927 splitall.__doc__ = path.path.splitall.__doc__
684 928
685 929 def relpath(self):
686 930 return ifile(path.path.relpath(self))
687 931 relpath.__doc__ = path.path.relpath.__doc__
688 932
689 933 def relpathto(self, dest):
690 934 return ifile(path.path.relpathto(self, dest))
691 935 relpathto.__doc__ = path.path.relpathto.__doc__
692 936
693 937 def listdir(self, pattern=None):
694 938 return [ifile(child) for child in path.path.listdir(self, pattern)]
695 939 listdir.__doc__ = path.path.listdir.__doc__
696 940
697 941 def dirs(self, pattern=None):
698 942 return [ifile(child) for child in path.path.dirs(self, pattern)]
699 943 dirs.__doc__ = path.path.dirs.__doc__
700 944
701 945 def files(self, pattern=None):
702 946 return [ifile(child) for child in path.path.files(self, pattern)]
703 947 files.__doc__ = path.path.files.__doc__
704 948
705 949 def walk(self, pattern=None):
706 950 for child in path.path.walk(self, pattern):
707 951 yield ifile(child)
708 952 walk.__doc__ = path.path.walk.__doc__
709 953
710 954 def walkdirs(self, pattern=None):
711 955 for child in path.path.walkdirs(self, pattern):
712 956 yield ifile(child)
713 957 walkdirs.__doc__ = path.path.walkdirs.__doc__
714 958
715 959 def walkfiles(self, pattern=None):
716 960 for child in path.path.walkfiles(self, pattern):
717 961 yield ifile(child)
718 962 walkfiles.__doc__ = path.path.walkfiles.__doc__
719 963
720 964 def glob(self, pattern):
721 965 return map(ifile, path.path.glob(self, pattern))
722 966 glob.__doc__ = path.path.glob.__doc__
723 967
724 968 if hasattr(os, 'readlink'):
725 969 def readlink(self):
726 970 return ifile(path.path.readlink(self))
727 971 readlink.__doc__ = path.path.readlink.__doc__
728 972
729 973 def readlinkabs(self):
730 974 return ifile(path.path.readlinkabs(self))
731 975 readlinkabs.__doc__ = path.path.readlinkabs.__doc__
732 976
733 977 def getmode(self):
734 978 return self.stat().st_mode
735 979 mode = property(getmode, None, None, "Access mode")
736 980
737 981 def gettype(self):
738 982 data = [
739 983 (stat.S_ISREG, "file"),
740 984 (stat.S_ISDIR, "dir"),
741 985 (stat.S_ISCHR, "chardev"),
742 986 (stat.S_ISBLK, "blockdev"),
743 987 (stat.S_ISFIFO, "fifo"),
744 988 (stat.S_ISLNK, "symlink"),
745 989 (stat.S_ISSOCK,"socket"),
746 990 ]
747 991 lstat = self.lstat()
748 992 if lstat is not None:
749 993 types = set([text for (func, text) in data if func(lstat.st_mode)])
750 994 else:
751 995 types = set()
752 996 m = self.mode
753 997 types.update([text for (func, text) in data if func(m)])
754 998 return ", ".join(types)
755 999 type = property(gettype, None, None, "file type (file, directory, link, etc.)")
756 1000
757 1001 def getmodestr(self):
758 1002 m = self.mode
759 1003 data = [
760 1004 (stat.S_IRUSR, "-r"),
761 1005 (stat.S_IWUSR, "-w"),
762 1006 (stat.S_IXUSR, "-x"),
763 1007 (stat.S_IRGRP, "-r"),
764 1008 (stat.S_IWGRP, "-w"),
765 1009 (stat.S_IXGRP, "-x"),
766 1010 (stat.S_IROTH, "-r"),
767 1011 (stat.S_IWOTH, "-w"),
768 1012 (stat.S_IXOTH, "-x"),
769 1013 ]
770 1014 return "".join([text[bool(m&bit)] for (bit, text) in data])
771 1015
772 1016 modestr = property(getmodestr, None, None, "Access mode as string")
773 1017
774 1018 def getblocks(self):
775 1019 return self.stat().st_blocks
776 1020 blocks = property(getblocks, None, None, "File size in blocks")
777 1021
778 1022 def getblksize(self):
779 1023 return self.stat().st_blksize
780 1024 blksize = property(getblksize, None, None, "Filesystem block size")
781 1025
782 1026 def getdev(self):
783 1027 return self.stat().st_dev
784 1028 dev = property(getdev)
785 1029
786 1030 def getnlink(self):
787 1031 return self.stat().st_nlink
788 1032 nlink = property(getnlink, None, None, "Number of links")
789 1033
790 1034 def getuid(self):
791 1035 return self.stat().st_uid
792 1036 uid = property(getuid, None, None, "User id of file owner")
793 1037
794 1038 def getgid(self):
795 1039 return self.stat().st_gid
796 1040 gid = property(getgid, None, None, "Group id of file owner")
797 1041
798 1042 def getowner(self):
799 1043 stat = self.stat()
800 1044 try:
801 1045 return pwd.getpwuid(stat.st_uid).pw_name
802 1046 except KeyError:
803 1047 return stat.st_uid
804 1048 owner = property(getowner, None, None, "Owner name (or id)")
805 1049
806 1050 def getgroup(self):
807 1051 stat = self.stat()
808 1052 try:
809 1053 return grp.getgrgid(stat.st_gid).gr_name
810 1054 except KeyError:
811 1055 return stat.st_gid
812 1056 group = property(getgroup, None, None, "Group name (or id)")
813 1057
814 1058 def getadate(self):
815 1059 return datetime.datetime.utcfromtimestamp(self.atime)
816 1060 adate = property(getadate, None, None, "Access date")
817 1061
818 1062 def getcdate(self):
819 1063 return datetime.datetime.utcfromtimestamp(self.ctime)
820 1064 cdate = property(getcdate, None, None, "Creation date")
821 1065
822 1066 def getmdate(self):
823 1067 return datetime.datetime.utcfromtimestamp(self.mtime)
824 1068 mdate = property(getmdate, None, None, "Modification date")
825 1069
826 def getmimetype(self):
1070 def mimetype(self):
1071 """
1072 Return MIME type guessed from the extension.
1073 """
827 1074 return mimetypes.guess_type(self.basename())[0]
828 mimetype = property(getmimetype, None, None, "MIME type")
829 1075
830 def getencoding(self):
1076 def encoding(self):
1077 """
1078 Return guessed compression (like "compress" or "gzip").
1079 """
831 1080 return mimetypes.guess_type(self.basename())[1]
832 encoding = property(getencoding, None, None, "Compression")
833 1081
834 1082 def __repr__(self):
835 1083 return "ifile(%s)" % path._base.__repr__(self)
836 1084
837 defaultattrs = (None, "type", "size", "modestr", "owner", "group", "mdate")
838
839 1085 def __xattrs__(self, mode):
840 1086 if mode == "detail":
841 1087 return (
842 "name", "basename()", "abspath()", "realpath()",
843 "type", "mode", "modestr", "stat()", "lstat()",
844 "uid", "gid", "owner", "group", "dev", "nlink",
845 "ctime", "mtime", "atime", "cdate", "mdate", "adate",
846 "size", "blocks", "blksize", "isdir()", "islink()",
847 "mimetype", "encoding"
1088 "name",
1089 "basename()",
1090 "abspath()",
1091 "realpath()",
1092 "type",
1093 "mode",
1094 "modestr",
1095 "stat()",
1096 "lstat()",
1097 "uid",
1098 "gid",
1099 "owner",
1100 "group",
1101 "dev",
1102 "nlink",
1103 "ctime",
1104 "mtime",
1105 "atime",
1106 "cdate",
1107 "mdate",
1108 "adate",
1109 "size",
1110 "blocks",
1111 "blksize",
1112 "isdir()",
1113 "islink()",
1114 "mimetype()",
1115 "encoding()",
1116 "-listdir()",
1117 "-dirs()",
1118 "-files()",
1119 "-walk()",
1120 "-walkdirs()",
1121 "-walkfiles()",
848 1122 )
849 return self.defaultattrs
1123 else:
1124 return (None, "type", "size", "modestr", "owner", "group", "mdate")
850 1125
851 1126 def __xrepr__(self, mode):
852 1127 try:
853 1128 if self.isdir():
854 1129 name = "idir"
855 1130 style = astyle.style_dir
856 1131 else:
857 1132 name = "ifile"
858 1133 style = astyle.style_file
859 1134 except IOError:
860 1135 name = "ifile"
861 1136 style = astyle.style_default
862 1137 if mode == "cell" or mode in "header" or mode == "footer":
863 1138 abspath = repr(path._base(self.normpath()))
864 1139 if abspath.startswith("u"):
865 1140 abspath = abspath[2:-1]
866 1141 else:
867 1142 abspath = abspath[1:-1]
868 1143 if mode == "cell":
869 1144 yield (style, abspath)
870 1145 else:
871 1146 yield (style, "%s(%s)" % (name, abspath))
872 1147 else:
873 1148 yield (style, repr(self))
874 1149
875 def __xiter__(self, mode):
1150 def __iter__(self):
876 1151 if self.isdir():
877 1152 yield iparentdir(self / os.pardir)
878 1153 for child in sorted(self.listdir()):
879 1154 yield child
880 1155 else:
881 1156 f = self.open("rb")
882 1157 for line in f:
883 1158 yield line
884 1159 f.close()
885 1160
886 1161
887 1162 class iparentdir(ifile):
888 1163 def __xrepr__(self, mode):
889 1164 if mode == "cell":
890 1165 yield (astyle.style_dir, os.pardir)
891 1166 else:
892 1167 for part in ifile.__xrepr__(self, mode):
893 1168 yield part
894 1169
895 1170
896 1171 class ils(Table):
897 1172 """
898 1173 List the current (or a specific) directory.
899 1174
900 1175 Examples:
901 1176
902 1177 >>> ils
903 1178 >>> ils("/usr/local/lib/python2.4")
904 1179 >>> ils("~")
905 1180 """
906 1181 def __init__(self, base=os.curdir):
907 1182 self.base = os.path.expanduser(base)
908 1183
909 def __xiter__(self, mode):
910 return xiter(ifile(self.base), mode)
1184 def __iter__(self):
1185 return xiter(ifile(self.base))
911 1186
912 1187 def __xrepr__(self, mode):
913 1188 return ifile(self.base).__xrepr__(mode)
914 1189
915 1190 def __repr__(self):
916 1191 return "%s.%s(%r)" % \
917 1192 (self.__class__.__module__, self.__class__.__name__, self.base)
918 1193
919 1194
920 1195 class iglob(Table):
921 1196 """
922 1197 List all files and directories matching a specified pattern.
923 1198 (See ``glob.glob()`` for more info.).
924 1199
925 1200 Examples:
926 1201
927 1202 >>> iglob("*.py")
928 1203 """
929 1204 def __init__(self, glob):
930 1205 self.glob = glob
931 1206
932 def __xiter__(self, mode):
1207 def __iter__(self):
933 1208 for name in glob.glob(self.glob):
934 1209 yield ifile(name)
935 1210
936 1211 def __xrepr__(self, mode):
937 1212 if mode == "header" or mode == "footer" or mode == "cell":
938 1213 yield (astyle.style_default,
939 1214 "%s(%r)" % (self.__class__.__name__, self.glob))
940 1215 else:
941 1216 yield (astyle.style_default, repr(self))
942 1217
943 1218 def __repr__(self):
944 1219 return "%s.%s(%r)" % \
945 1220 (self.__class__.__module__, self.__class__.__name__, self.glob)
946 1221
947 1222
948 1223 class iwalk(Table):
949 1224 """
950 1225 List all files and directories in a directory and it's subdirectory.
951 1226
952 1227 >>> iwalk
953 1228 >>> iwalk("/usr/local/lib/python2.4")
954 1229 >>> iwalk("~")
955 1230 """
956 1231 def __init__(self, base=os.curdir, dirs=True, files=True):
957 1232 self.base = os.path.expanduser(base)
958 1233 self.dirs = dirs
959 1234 self.files = files
960 1235
961 def __xiter__(self, mode):
1236 def __iter__(self):
962 1237 for (dirpath, dirnames, filenames) in os.walk(self.base):
963 1238 if self.dirs:
964 1239 for name in sorted(dirnames):
965 1240 yield ifile(os.path.join(dirpath, name))
966 1241 if self.files:
967 1242 for name in sorted(filenames):
968 1243 yield ifile(os.path.join(dirpath, name))
969 1244
970 1245 def __xrepr__(self, mode):
971 1246 if mode == "header" or mode == "footer" or mode == "cell":
972 1247 yield (astyle.style_default,
973 1248 "%s(%r)" % (self.__class__.__name__, self.base))
974 1249 else:
975 1250 yield (astyle.style_default, repr(self))
976 1251
977 1252 def __repr__(self):
978 1253 return "%s.%s(%r)" % \
979 1254 (self.__class__.__module__, self.__class__.__name__, self.base)
980 1255
981 1256
982 1257 class ipwdentry(object):
983 1258 """
984 1259 ``ipwdentry`` objects encapsulate entries in the Unix user account and
985 1260 password database.
986 1261 """
987 1262 def __init__(self, id):
988 1263 self._id = id
989 1264 self._entry = None
990 1265
991 1266 def _getentry(self):
992 1267 if self._entry is None:
993 1268 if isinstance(self._id, basestring):
994 1269 self._entry = pwd.getpwnam(self._id)
995 1270 else:
996 1271 self._entry = pwd.getpwuid(self._id)
997 1272 return self._entry
998 1273
999 1274 def getname(self):
1000 1275 if isinstance(self._id, basestring):
1001 1276 return self._id
1002 1277 else:
1003 1278 return self._getentry().pw_name
1004 1279 name = property(getname, None, None, "User name")
1005 1280
1006 1281 def getpasswd(self):
1007 1282 return self._getentry().pw_passwd
1008 1283 passwd = property(getpasswd, None, None, "Password")
1009 1284
1010 1285 def getuid(self):
1011 1286 if isinstance(self._id, basestring):
1012 1287 return self._getentry().pw_uid
1013 1288 else:
1014 1289 return self._id
1015 1290 uid = property(getuid, None, None, "User id")
1016 1291
1017 1292 def getgid(self):
1018 1293 return self._getentry().pw_gid
1019 1294 gid = property(getgid, None, None, "Primary group id")
1020 1295
1021 1296 def getgroup(self):
1022 1297 return igrpentry(self.gid)
1023 1298 group = property(getgroup, None, None, "Group")
1024 1299
1025 1300 def getgecos(self):
1026 1301 return self._getentry().pw_gecos
1027 1302 gecos = property(getgecos, None, None, "Information (e.g. full user name)")
1028 1303
1029 1304 def getdir(self):
1030 1305 return self._getentry().pw_dir
1031 1306 dir = property(getdir, None, None, "$HOME directory")
1032 1307
1033 1308 def getshell(self):
1034 1309 return self._getentry().pw_shell
1035 1310 shell = property(getshell, None, None, "Login shell")
1036 1311
1037 1312 def __xattrs__(self, mode):
1038 return ("name", "passwd", "uid", "gid", "gecos", "dir", "shell")
1313 return ("name", "passwd", "uid", "gid", "gecos", "dir", "shell")
1039 1314
1040 1315 def __repr__(self):
1041 1316 return "%s.%s(%r)" % \
1042 1317 (self.__class__.__module__, self.__class__.__name__, self._id)
1043 1318
1044 1319
1045 1320 class ipwd(Table):
1046 1321 """
1047 1322 List all entries in the Unix user account and password database.
1048 1323
1049 1324 Example:
1050 1325
1051 1326 >>> ipwd | isort("uid")
1052 1327 """
1053 1328 def __iter__(self):
1054 1329 for entry in pwd.getpwall():
1055 1330 yield ipwdentry(entry.pw_name)
1056 1331
1057 1332 def __xrepr__(self, mode):
1058 1333 if mode == "header" or mode == "footer" or mode == "cell":
1059 1334 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1060 1335 else:
1061 1336 yield (astyle.style_default, repr(self))
1062 1337
1063 1338
1064 1339 class igrpentry(object):
1065 1340 """
1066 1341 ``igrpentry`` objects encapsulate entries in the Unix group database.
1067 1342 """
1068 1343 def __init__(self, id):
1069 1344 self._id = id
1070 1345 self._entry = None
1071 1346
1072 1347 def _getentry(self):
1073 1348 if self._entry is None:
1074 1349 if isinstance(self._id, basestring):
1075 1350 self._entry = grp.getgrnam(self._id)
1076 1351 else:
1077 1352 self._entry = grp.getgrgid(self._id)
1078 1353 return self._entry
1079 1354
1080 1355 def getname(self):
1081 1356 if isinstance(self._id, basestring):
1082 1357 return self._id
1083 1358 else:
1084 1359 return self._getentry().gr_name
1085 1360 name = property(getname, None, None, "Group name")
1086 1361
1087 1362 def getpasswd(self):
1088 1363 return self._getentry().gr_passwd
1089 1364 passwd = property(getpasswd, None, None, "Password")
1090 1365
1091 1366 def getgid(self):
1092 1367 if isinstance(self._id, basestring):
1093 1368 return self._getentry().gr_gid
1094 1369 else:
1095 1370 return self._id
1096 1371 gid = property(getgid, None, None, "Group id")
1097 1372
1098 1373 def getmem(self):
1099 1374 return self._getentry().gr_mem
1100 1375 mem = property(getmem, None, None, "Members")
1101 1376
1102 1377 def __xattrs__(self, mode):
1103 1378 return ("name", "passwd", "gid", "mem")
1104 1379
1105 1380 def __xrepr__(self, mode):
1106 1381 if mode == "header" or mode == "footer" or mode == "cell":
1107 1382 yield (astyle.style_default, "group ")
1108 1383 try:
1109 1384 yield (astyle.style_default, self.name)
1110 1385 except KeyError:
1111 1386 if isinstance(self._id, basestring):
1112 1387 yield (astyle.style_default, self.name_id)
1113 1388 else:
1114 1389 yield (astyle.style_type_number, str(self._id))
1115 1390 else:
1116 1391 yield (astyle.style_default, repr(self))
1117 1392
1118 def __xiter__(self, mode):
1393 def __iter__(self):
1119 1394 for member in self.mem:
1120 1395 yield ipwdentry(member)
1121 1396
1122 1397 def __repr__(self):
1123 1398 return "%s.%s(%r)" % \
1124 1399 (self.__class__.__module__, self.__class__.__name__, self._id)
1125 1400
1126 1401
1127 1402 class igrp(Table):
1128 1403 """
1129 1404 This ``Table`` lists all entries in the Unix group database.
1130 1405 """
1131 def __xiter__(self, mode):
1406 def __iter__(self):
1132 1407 for entry in grp.getgrall():
1133 1408 yield igrpentry(entry.gr_name)
1134 1409
1135 1410 def __xrepr__(self, mode):
1136 1411 if mode == "header" or mode == "footer":
1137 1412 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1138 1413 else:
1139 1414 yield (astyle.style_default, repr(self))
1140 1415
1141 1416
1142 1417 class Fields(object):
1143 1418 def __init__(self, fieldnames, **fields):
1144 self.__fieldnames = fieldnames
1419 self.__fieldnames = [upgradexattr(fieldname) for fieldname in fieldnames]
1145 1420 for (key, value) in fields.iteritems():
1146 1421 setattr(self, key, value)
1147 1422
1148 1423 def __xattrs__(self, mode):
1149 1424 return self.__fieldnames
1150 1425
1151 1426 def __xrepr__(self, mode):
1152 1427 yield (-1, False)
1153 1428 if mode == "header" or mode == "cell":
1154 1429 yield (astyle.style_default, self.__class__.__name__)
1155 1430 yield (astyle.style_default, "(")
1156 1431 for (i, f) in enumerate(self.__fieldnames):
1157 1432 if i:
1158 1433 yield (astyle.style_default, ", ")
1159 yield (astyle.style_default, f)
1434 yield (astyle.style_default, f.name())
1160 1435 yield (astyle.style_default, "=")
1161 1436 for part in xrepr(getattr(self, f), "default"):
1162 1437 yield part
1163 1438 yield (astyle.style_default, ")")
1164 1439 elif mode == "footer":
1165 1440 yield (astyle.style_default, self.__class__.__name__)
1166 1441 yield (astyle.style_default, "(")
1167 1442 for (i, f) in enumerate(self.__fieldnames):
1168 1443 if i:
1169 1444 yield (astyle.style_default, ", ")
1170 yield (astyle.style_default, f)
1445 yield (astyle.style_default, f.name())
1171 1446 yield (astyle.style_default, ")")
1172 1447 else:
1173 1448 yield (astyle.style_default, repr(self))
1174 1449
1175 1450
1176 1451 class FieldTable(Table, list):
1177 1452 def __init__(self, *fields):
1178 1453 Table.__init__(self)
1179 1454 list.__init__(self)
1180 1455 self.fields = fields
1181 1456
1182 1457 def add(self, **fields):
1183 1458 self.append(Fields(self.fields, **fields))
1184 1459
1185 def __xiter__(self, mode):
1186 return list.__iter__(self)
1187
1188 1460 def __xrepr__(self, mode):
1189 1461 yield (-1, False)
1190 1462 if mode == "header" or mode == "footer":
1191 1463 yield (astyle.style_default, self.__class__.__name__)
1192 1464 yield (astyle.style_default, "(")
1193 1465 for (i, f) in enumerate(self.__fieldnames):
1194 1466 if i:
1195 1467 yield (astyle.style_default, ", ")
1196 1468 yield (astyle.style_default, f)
1197 1469 yield (astyle.style_default, ")")
1198 1470 else:
1199 1471 yield (astyle.style_default, repr(self))
1200 1472
1201 1473 def __repr__(self):
1202 1474 return "<%s.%s object with fields=%r at 0x%x>" % \
1203 1475 (self.__class__.__module__, self.__class__.__name__,
1204 1476 ", ".join(map(repr, self.fields)), id(self))
1205 1477
1206 1478
1207 1479 class List(list):
1208 1480 def __xattrs__(self, mode):
1209 1481 return xrange(len(self))
1210 1482
1211 1483 def __xrepr__(self, mode):
1212 1484 yield (-1, False)
1213 1485 if mode == "header" or mode == "cell" or mode == "footer" or mode == "default":
1214 1486 yield (astyle.style_default, self.__class__.__name__)
1215 1487 yield (astyle.style_default, "(")
1216 1488 for (i, item) in enumerate(self):
1217 1489 if i:
1218 1490 yield (astyle.style_default, ", ")
1219 1491 for part in xrepr(item, "default"):
1220 1492 yield part
1221 1493 yield (astyle.style_default, ")")
1222 1494 else:
1223 1495 yield (astyle.style_default, repr(self))
1224 1496
1225 1497
1226 1498 class ienv(Table):
1227 1499 """
1228 1500 List environment variables.
1229 1501
1230 1502 Example:
1231 1503
1232 1504 >>> ienv
1233 1505 """
1234 1506
1235 def __xiter__(self, mode):
1507 def __iter__(self):
1236 1508 fields = ("key", "value")
1237 1509 for (key, value) in os.environ.iteritems():
1238 1510 yield Fields(fields, key=key, value=value)
1239 1511
1240 1512 def __xrepr__(self, mode):
1241 1513 if mode == "header" or mode == "cell":
1242 1514 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1243 1515 else:
1244 1516 yield (astyle.style_default, repr(self))
1245 1517
1246 1518
1247 1519 class icsv(Pipe):
1248 1520 """
1249 1521 This ``Pipe`` lists turn the input (with must be a pipe outputting lines
1250 1522 or an ``ifile``) into lines of CVS columns.
1251 1523 """
1252 1524 def __init__(self, **csvargs):
1253 1525 """
1254 1526 Create an ``icsv`` object. ``cvsargs`` will be passed through as
1255 1527 keyword arguments to ``cvs.reader()``.
1256 1528 """
1257 1529 self.csvargs = csvargs
1258 1530
1259 def __xiter__(self, mode):
1531 def __iter__(self):
1260 1532 input = self.input
1261 1533 if isinstance(input, ifile):
1262 1534 input = input.open("rb")
1263 1535 reader = csv.reader(input, **self.csvargs)
1264 1536 for line in reader:
1265 1537 yield List(line)
1266 1538
1267 1539 def __xrepr__(self, mode):
1268 1540 yield (-1, False)
1269 1541 if mode == "header" or mode == "footer":
1270 1542 input = getattr(self, "input", None)
1271 1543 if input is not None:
1272 1544 for part in xrepr(input, mode):
1273 1545 yield part
1274 1546 yield (astyle.style_default, " | ")
1275 1547 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1276 1548 for (i, (name, value)) in enumerate(self.csvargs.iteritems()):
1277 1549 if i:
1278 1550 yield (astyle.style_default, ", ")
1279 1551 yield (astyle.style_default, name)
1280 1552 yield (astyle.style_default, "=")
1281 1553 for part in xrepr(value, "default"):
1282 1554 yield part
1283 1555 yield (astyle.style_default, ")")
1284 1556 else:
1285 1557 yield (astyle.style_default, repr(self))
1286 1558
1287 1559 def __repr__(self):
1288 1560 args = ", ".join(["%s=%r" % item for item in self.csvargs.iteritems()])
1289 1561 return "<%s.%s %s at 0x%x>" % \
1290 1562 (self.__class__.__module__, self.__class__.__name__, args, id(self))
1291 1563
1292 1564
1293 1565 class ix(Table):
1294 1566 """
1295 1567 Execute a system command and list its output as lines
1296 1568 (similar to ``os.popen()``).
1297 1569
1298 1570 Examples:
1299 1571
1300 1572 >>> ix("ps x")
1301 1573 >>> ix("find .") | ifile
1302 1574 """
1303 1575 def __init__(self, cmd):
1304 1576 self.cmd = cmd
1305 1577 self._pipeout = None
1306 1578
1307 def __xiter__(self, mode="default"):
1579 def __iter__(self):
1308 1580 (_pipein, self._pipeout) = os.popen4(self.cmd)
1309 1581 _pipein.close()
1310 1582 for l in self._pipeout:
1311 1583 yield l.rstrip("\r\n")
1312 1584 self._pipeout.close()
1313 1585 self._pipeout = None
1314 1586
1315 1587 def __del__(self):
1316 1588 if self._pipeout is not None and not self._pipeout.closed:
1317 1589 self._pipeout.close()
1318 1590 self._pipeout = None
1319 1591
1320 1592 def __xrepr__(self, mode):
1321 1593 if mode == "header" or mode == "footer":
1322 1594 yield (astyle.style_default,
1323 1595 "%s(%r)" % (self.__class__.__name__, self.cmd))
1324 1596 else:
1325 1597 yield (astyle.style_default, repr(self))
1326 1598
1327 1599 def __repr__(self):
1328 1600 return "%s.%s(%r)" % \
1329 1601 (self.__class__.__module__, self.__class__.__name__, self.cmd)
1330 1602
1331 1603
1332 1604 class ifilter(Pipe):
1333 1605 """
1334 1606 Filter an input pipe. Only objects where an expression evaluates to true
1335 1607 (and doesn't raise an exception) are listed.
1336 1608
1337 1609 Examples:
1338 1610
1339 1611 >>> ils | ifilter("_.isfile() and size>1000")
1340 1612 >>> igrp | ifilter("len(mem)")
1341 1613 >>> sys.modules | ifilter(lambda _:_.value is not None)
1342 1614 """
1343 1615
1344 1616 def __init__(self, expr, globals=None, errors="raiseifallfail"):
1345 1617 """
1346 1618 Create an ``ifilter`` object. ``expr`` can be a callable or a string
1347 1619 containing an expression. ``globals`` will be used as the global
1348 1620 namespace for calling string expressions (defaulting to IPython's
1349 1621 user namespace). ``errors`` specifies how exception during evaluation
1350 1622 of ``expr`` are handled:
1351 1623
1352 1624 * ``drop``: drop all items that have errors;
1353 1625
1354 1626 * ``keep``: keep all items that have errors;
1355 1627
1356 1628 * ``keeperror``: keep the exception of all items that have errors;
1357 1629
1358 1630 * ``raise``: raise the exception;
1359 1631
1360 1632 * ``raiseifallfail``: raise the first exception if all items have errors;
1361 1633 otherwise drop those with errors (this is the default).
1362 1634 """
1363 1635 self.expr = expr
1364 1636 self.globals = globals
1365 1637 self.errors = errors
1366 1638
1367 def __xiter__(self, mode):
1639 def __iter__(self):
1368 1640 if callable(self.expr):
1369 1641 test = self.expr
1370 1642 else:
1371 1643 g = getglobals(self.globals)
1372 1644 expr = compile(self.expr, "ipipe-expression", "eval")
1373 1645 def test(item):
1374 1646 return eval(expr, g, AttrNamespace(item))
1375 1647
1376 1648 ok = 0
1377 1649 exc_info = None
1378 for item in xiter(self.input, mode):
1650 for item in xiter(self.input):
1379 1651 try:
1380 1652 if test(item):
1381 1653 yield item
1382 1654 ok += 1
1383 1655 except (KeyboardInterrupt, SystemExit):
1384 1656 raise
1385 1657 except Exception, exc:
1386 1658 if self.errors == "drop":
1387 1659 pass # Ignore errors
1388 1660 elif self.errors == "keep":
1389 1661 yield item
1390 1662 elif self.errors == "keeperror":
1391 1663 yield exc
1392 1664 elif self.errors == "raise":
1393 1665 raise
1394 1666 elif self.errors == "raiseifallfail":
1395 1667 if exc_info is None:
1396 1668 exc_info = sys.exc_info()
1397 1669 if not ok and exc_info is not None:
1398 1670 raise exc_info[0], exc_info[1], exc_info[2]
1399 1671
1400 1672 def __xrepr__(self, mode):
1401 1673 if mode == "header" or mode == "footer":
1402 1674 input = getattr(self, "input", None)
1403 1675 if input is not None:
1404 1676 for part in xrepr(input, mode):
1405 1677 yield part
1406 1678 yield (astyle.style_default, " | ")
1407 1679 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1408 1680 for part in xrepr(self.expr, "default"):
1409 1681 yield part
1410 1682 yield (astyle.style_default, ")")
1411 1683 else:
1412 1684 yield (astyle.style_default, repr(self))
1413 1685
1414 1686 def __repr__(self):
1415 1687 return "<%s.%s expr=%r at 0x%x>" % \
1416 1688 (self.__class__.__module__, self.__class__.__name__,
1417 1689 self.expr, id(self))
1418 1690
1419 1691
1420 1692 class ieval(Pipe):
1421 1693 """
1422 1694 Evaluate an expression for each object in the input pipe.
1423 1695
1424 1696 Examples:
1425 1697
1426 1698 >>> ils | ieval("_.abspath()")
1427 1699 >>> sys.path | ieval(ifile)
1428 1700 """
1429 1701
1430 1702 def __init__(self, expr, globals=None, errors="raiseifallfail"):
1431 1703 """
1432 1704 Create an ``ieval`` object. ``expr`` can be a callable or a string
1433 1705 containing an expression. For the meaning of ``globals`` and
1434 1706 ``errors`` see ``ifilter``.
1435 1707 """
1436 1708 self.expr = expr
1437 1709 self.globals = globals
1438 1710 self.errors = errors
1439 1711
1440 def __xiter__(self, mode):
1712 def __iter__(self):
1441 1713 if callable(self.expr):
1442 1714 do = self.expr
1443 1715 else:
1444 1716 g = getglobals(self.globals)
1445 1717 expr = compile(self.expr, "ipipe-expression", "eval")
1446 1718 def do(item):
1447 1719 return eval(expr, g, AttrNamespace(item))
1448 1720
1449 1721 ok = 0
1450 1722 exc_info = None
1451 for item in xiter(self.input, mode):
1723 for item in xiter(self.input):
1452 1724 try:
1453 1725 yield do(item)
1454 1726 except (KeyboardInterrupt, SystemExit):
1455 1727 raise
1456 1728 except Exception, exc:
1457 1729 if self.errors == "drop":
1458 1730 pass # Ignore errors
1459 1731 elif self.errors == "keep":
1460 1732 yield item
1461 1733 elif self.errors == "keeperror":
1462 1734 yield exc
1463 1735 elif self.errors == "raise":
1464 1736 raise
1465 1737 elif self.errors == "raiseifallfail":
1466 1738 if exc_info is None:
1467 1739 exc_info = sys.exc_info()
1468 1740 if not ok and exc_info is not None:
1469 1741 raise exc_info[0], exc_info[1], exc_info[2]
1470 1742
1471 1743 def __xrepr__(self, mode):
1472 1744 if mode == "header" or mode == "footer":
1473 1745 input = getattr(self, "input", None)
1474 1746 if input is not None:
1475 1747 for part in xrepr(input, mode):
1476 1748 yield part
1477 1749 yield (astyle.style_default, " | ")
1478 1750 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1479 1751 for part in xrepr(self.expr, "default"):
1480 1752 yield part
1481 1753 yield (astyle.style_default, ")")
1482 1754 else:
1483 1755 yield (astyle.style_default, repr(self))
1484 1756
1485 1757 def __repr__(self):
1486 1758 return "<%s.%s expr=%r at 0x%x>" % \
1487 1759 (self.__class__.__module__, self.__class__.__name__,
1488 1760 self.expr, id(self))
1489 1761
1490 1762
1491 1763 class ienum(Pipe):
1492 1764 """
1493 1765 Enumerate the input pipe (i.e. wrap each input object in an object
1494 1766 with ``index`` and ``object`` attributes).
1495 1767
1496 1768 Examples:
1497 1769
1498 1770 >>> xrange(20) | ieval("_,_*_") | ienum | ifilter("index % 2 == 0") | ieval("object")
1499 1771 """
1500 def __xiter__(self, mode):
1772 def __iter__(self):
1501 1773 fields = ("index", "object")
1502 for (index, object) in enumerate(xiter(self.input, mode)):
1774 for (index, object) in enumerate(xiter(self.input)):
1503 1775 yield Fields(fields, index=index, object=object)
1504 1776
1505 1777
1506 1778 class isort(Pipe):
1507 1779 """
1508 1780 Sorts the input pipe.
1509 1781
1510 1782 Examples:
1511 1783
1512 1784 >>> ils | isort("size")
1513 1785 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
1514 1786 """
1515 1787
1516 1788 def __init__(self, key=None, globals=None, reverse=False):
1517 1789 """
1518 1790 Create an ``isort`` object. ``key`` can be a callable or a string
1519 1791 containing an expression (or ``None`` in which case the items
1520 1792 themselves will be sorted). If ``reverse`` is true the sort order
1521 1793 will be reversed. For the meaning of ``globals`` see ``ifilter``.
1522 1794 """
1523 1795 self.key = key
1524 1796 self.globals = globals
1525 1797 self.reverse = reverse
1526 1798
1527 def __xiter__(self, mode):
1799 def __iter__(self):
1528 1800 if self.key is None:
1529 items = sorted(
1530 xiter(self.input, mode),
1531 reverse=self.reverse
1532 )
1801 items = sorted(xiter(self.input), reverse=self.reverse)
1533 1802 elif callable(self.key):
1534 items = sorted(
1535 xiter(self.input, mode),
1536 key=self.key,
1537 reverse=self.reverse
1538 )
1803 items = sorted(xiter(self.input), key=self.key, reverse=self.reverse)
1539 1804 else:
1540 1805 g = getglobals(self.globals)
1541 1806 key = compile(self.key, "ipipe-expression", "eval")
1542 1807 def realkey(item):
1543 1808 return eval(key, g, AttrNamespace(item))
1544 1809 items = sorted(
1545 1810 xiter(self.input, mode),
1546 1811 key=realkey,
1547 1812 reverse=self.reverse
1548 1813 )
1549 1814 for item in items:
1550 1815 yield item
1551 1816
1552 1817 def __xrepr__(self, mode):
1553 1818 if mode == "header" or mode == "footer":
1554 1819 input = getattr(self, "input", None)
1555 1820 if input is not None:
1556 1821 for part in xrepr(input, mode):
1557 1822 yield part
1558 1823 yield (astyle.style_default, " | ")
1559 1824 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1560 1825 for part in xrepr(self.key, "default"):
1561 1826 yield part
1562 1827 if self.reverse:
1563 1828 yield (astyle.style_default, ", ")
1564 1829 for part in xrepr(True, "default"):
1565 1830 yield part
1566 1831 yield (astyle.style_default, ")")
1567 1832 else:
1568 1833 yield (astyle.style_default, repr(self))
1569 1834
1570 1835 def __repr__(self):
1571 1836 return "<%s.%s key=%r reverse=%r at 0x%x>" % \
1572 1837 (self.__class__.__module__, self.__class__.__name__,
1573 1838 self.key, self.reverse, id(self))
1574 1839
1575 1840
1576 1841 tab = 3 # for expandtabs()
1577 1842
1578 1843 def _format(field):
1579 1844 if isinstance(field, str):
1580 1845 text = repr(field.expandtabs(tab))[1:-1]
1581 1846 elif isinstance(field, unicode):
1582 1847 text = repr(field.expandtabs(tab))[2:-1]
1583 1848 elif isinstance(field, datetime.datetime):
1584 1849 # Don't use strftime() here, as this requires year >= 1900
1585 1850 text = "%04d-%02d-%02d %02d:%02d:%02d.%06d" % \
1586 1851 (field.year, field.month, field.day,
1587 1852 field.hour, field.minute, field.second, field.microsecond)
1588 1853 elif isinstance(field, datetime.date):
1589 1854 text = "%04d-%02d-%02d" % (field.year, field.month, field.day)
1590 1855 else:
1591 1856 text = repr(field)
1592 1857 return text
1593 1858
1594 1859
1595 1860 class Display(object):
1596 1861 class __metaclass__(type):
1597 1862 def __ror__(self, input):
1598 1863 return input | self()
1599 1864
1600 1865 def __ror__(self, input):
1601 1866 self.input = input
1602 1867 return self
1603 1868
1604 1869 def display(self):
1605 1870 pass
1606 1871
1607 1872
1608 1873 class iless(Display):
1609 1874 cmd = "less --quit-if-one-screen --LONG-PROMPT --LINE-NUMBERS --chop-long-lines --shift=8 --RAW-CONTROL-CHARS"
1610 1875
1611 1876 def display(self):
1612 1877 try:
1613 1878 pager = os.popen(self.cmd, "w")
1614 1879 try:
1615 1880 for item in xiter(self.input, "default"):
1616 attrs = xattrs(item, "default")
1617 attrs = ["%s=%s" % (a, _format(_getattr(item, a))) for a in attrs]
1881 attrs = tuple(_upgradexattrs(item, "default"))
1882 attrs = ["%s=%s" % (a.name(item), a.value(item)) for a in attrs]
1618 1883 pager.write(" ".join(attrs))
1619 1884 pager.write("\n")
1620 1885 finally:
1621 1886 pager.close()
1622 1887 except Exception, exc:
1623 1888 print "%s: %s" % (exc.__class__.__name__, str(exc))
1624 1889
1625 1890
1626 1891 def xformat(value, mode, maxlength):
1627 1892 align = None
1628 1893 full = True
1629 1894 width = 0
1630 1895 text = astyle.Text()
1631 1896 for (style, part) in xrepr(value, mode):
1632 1897 # only consider the first result
1633 1898 if align is None:
1634 1899 if isinstance(style, int):
1635 1900 # (style, text) really is (alignment, stop)
1636 1901 align = style
1637 1902 full = part
1638 1903 continue
1639 1904 else:
1640 1905 align = -1
1641 1906 full = True
1642 1907 if not isinstance(style, int):
1643 1908 text.append((style, part))
1644 1909 width += len(part)
1645 1910 if width >= maxlength and not full:
1646 1911 text.append((astyle.style_ellisis, "..."))
1647 1912 width += 3
1648 1913 break
1649 1914 if align is None: # default to left alignment
1650 1915 align = -1
1651 1916 return (align, width, text)
1652 1917
1653 1918
1654 1919 class idump(Display):
1655 1920 # The approximate maximum length of a column entry
1656 1921 maxattrlength = 200
1657 1922
1658 1923 # Style for column names
1659 1924 style_header = astyle.Style.fromstr("white:black:bold")
1660 1925
1661 1926 def __init__(self, *attrs):
1662 self.attrs = attrs
1927 self.attrs = [upgradexattr(attr) for attr in attrs]
1663 1928 self.headerpadchar = " "
1664 1929 self.headersepchar = "|"
1665 1930 self.datapadchar = " "
1666 1931 self.datasepchar = "|"
1667 1932
1668 1933 def display(self):
1669 1934 stream = genutils.Term.cout
1670 1935 allattrs = []
1671 allattrset = set()
1936 attrset = set()
1672 1937 colwidths = {}
1673 1938 rows = []
1674 1939 for item in xiter(self.input, "default"):
1675 1940 row = {}
1676 1941 attrs = self.attrs
1677 1942 if not attrs:
1678 1943 attrs = xattrs(item, "default")
1679 for attrname in attrs:
1680 if attrname not in allattrset:
1681 allattrs.append(attrname)
1682 allattrset.add(attrname)
1683 colwidths[attrname] = len(_attrname(attrname))
1944 for attr in attrs:
1945 if attr not in attrset:
1946 allattrs.append(attr)
1947 attrset.add(attr)
1948 colwidths[attr] = len(attr.name())
1684 1949 try:
1685 value = _getattr(item, attrname, None)
1950 value = attr.value(item)
1686 1951 except (KeyboardInterrupt, SystemExit):
1687 1952 raise
1688 1953 except Exception, exc:
1689 1954 value = exc
1690 1955 (align, width, text) = xformat(value, "cell", self.maxattrlength)
1691 colwidths[attrname] = max(colwidths[attrname], width)
1956 colwidths[attr] = max(colwidths[attr], width)
1692 1957 # remember alignment, length and colored parts
1693 row[attrname] = (align, width, text)
1958 row[attr] = (align, width, text)
1694 1959 rows.append(row)
1695 1960
1696 1961 stream.write("\n")
1697 for (i, attrname) in enumerate(allattrs):
1698 self.style_header(_attrname(attrname)).write(stream)
1699 spc = colwidths[attrname] - len(_attrname(attrname))
1962 for (i, attr) in enumerate(allattrs):
1963 attrname = attr.name()
1964 self.style_header(attrname).write(stream)
1965 spc = colwidths[attr] - len(attrname)
1700 1966 if i < len(colwidths)-1:
1701 1967 stream.write(self.headerpadchar*spc)
1702 1968 stream.write(self.headersepchar)
1703 1969 stream.write("\n")
1704 1970
1705 1971 for row in rows:
1706 for (i, attrname) in enumerate(allattrs):
1707 (align, width, text) = row[attrname]
1708 spc = colwidths[attrname] - width
1972 for (i, attr) in enumerate(allattrs):
1973 (align, width, text) = row[attr]
1974 spc = colwidths[attr] - width
1709 1975 if align == -1:
1710 1976 text.write(stream)
1711 1977 if i < len(colwidths)-1:
1712 1978 stream.write(self.datapadchar*spc)
1713 1979 elif align == 0:
1714 spc = colwidths[attrname] - width
1980 spc = colwidths[attr] - width
1715 1981 spc1 = spc//2
1716 1982 spc2 = spc-spc1
1717 1983 stream.write(self.datapadchar*spc1)
1718 1984 text.write(stream)
1719 1985 if i < len(colwidths)-1:
1720 1986 stream.write(self.datapadchar*spc2)
1721 1987 else:
1722 1988 stream.write(self.datapadchar*spc)
1723 1989 text.write(stream)
1724 1990 if i < len(colwidths)-1:
1725 1991 stream.write(self.datasepchar)
1726 1992 stream.write("\n")
1727 1993
1728 1994
1729 1995 class XMode(object):
1730 1996 """
1731 1997 An ``XMode`` object describes one enter mode available for an object
1732 1998 """
1733 1999 def __init__(self, object, mode, title=None, description=None):
1734 2000 """
1735 2001 Create a new ``XMode`` object for the object ``object``. This object
1736 2002 must support the enter mode ``mode`` (i.e. ``object.__xiter__(mode)``
1737 2003 must return an iterable). ``title`` and ``description`` will be
1738 2004 displayed in the browser when selecting among the available modes.
1739 2005 """
1740 2006 self.object = object
1741 2007 self.mode = mode
1742 2008 self.title = title
1743 2009 self.description = description
1744 2010
1745 2011 def __repr__(self):
1746 2012 return "<%s.%s object mode=%r at 0x%x>" % \
1747 2013 (self.__class__.__module__, self.__class__.__name__,
1748 2014 self.mode, id(self))
1749 2015
1750 2016 def __xrepr__(self, mode):
1751 2017 if mode == "header" or mode == "footer":
1752 2018 yield (astyle.style_default, self.title)
1753 2019 else:
1754 2020 yield (astyle.style_default, repr(self))
1755 2021
1756 2022 def __xattrs__(self, mode):
1757 2023 if mode == "detail":
2024 return ("object", "mode")
2025 else:
1758 2026 return ("object", "mode", "title", "description")
1759 return ("title", "description")
1760 2027
1761 2028 def __xiter__(self, mode):
1762 2029 return xiter(self.object, self.mode)
1763 2030
1764 2031
1765 class XAttr(object):
1766 def __init__(self, object, name):
1767 self.name = _attrname(name)
2032 class AttributeDetail(Table):
2033 def __init__(self, object, descriptor):
2034 self.object = object
2035 self.descriptor = descriptor
1768 2036
1769 try:
1770 self.value = _getattr(object, name)
1771 except (KeyboardInterrupt, SystemExit):
1772 raise
1773 except Exception, exc:
1774 if exc.__class__.__module__ == "exceptions":
1775 self.value = exc.__class__.__name__
1776 else:
1777 self.value = "%s.%s" % \
1778 (exc.__class__.__module__, exc.__class__.__name__)
1779 self.type = self.value
1780 else:
1781 t = type(self.value)
1782 if t.__module__ == "__builtin__":
1783 self.type = t.__name__
1784 else:
1785 self.type = "%s.%s" % (t.__module__, t.__name__)
2037 def __iter__(self):
2038 return self.descriptor.iter(self.object)
1786 2039
1787 doc = None
1788 if isinstance(name, basestring):
1789 if name.endswith("()"):
1790 doc = getattr(getattr(object, name[:-2]), "__doc__", None)
1791 else:
1792 try:
1793 meta = getattr(type(object), name)
1794 except AttributeError:
1795 pass
1796 else:
1797 if isinstance(meta, property):
1798 doc = getattr(meta, "__doc__", None)
1799 elif callable(name):
1800 doc = getattr(name, "__doc__", None)
1801 if isinstance(doc, basestring):
1802 doc = doc.strip()
1803 self.doc = doc
2040 def name(self):
2041 return self.descriptor.name()
2042
2043 def attrtype(self):
2044 return self.descriptor.attrtype(self.object)
2045
2046 def valuetype(self):
2047 return self.descriptor.valuetype(self.object)
2048
2049 def doc(self):
2050 return self.descriptor.doc(self.object)
2051
2052 def shortdoc(self):
2053 return self.descriptor.shortdoc(self.object)
2054
2055 def value(self):
2056 return self.descriptor.value(self.object)
1804 2057
1805 2058 def __xattrs__(self, mode):
1806 return ("name", "type", "doc", "value")
2059 attrs = ("name()", "attrtype()", "valuetype()", "value()", "shortdoc()")
2060 if mode == "detail":
2061 attrs += ("doc()",)
2062 return attrs
2063
2064 def __xrepr__(self, mode):
2065 yield (-1, True)
2066 yield (astyle.style_default, self.attrtype())
2067 yield (astyle.style_default, "(")
2068 for part in xrepr(self.valuetype()):
2069 yield part
2070 yield (astyle.style_default, ") ")
2071 yield (astyle.style_default, self.name())
2072 yield (astyle.style_default, " of ")
2073 for part in xrepr(self.object):
2074 yield part
1807 2075
1808 2076
1809 2077 try:
1810 2078 from ibrowse import ibrowse
1811 2079 except ImportError:
1812 2080 # No curses (probably Windows) => use ``idump`` as the default display.
1813 2081 defaultdisplay = idump
1814 2082 else:
1815 2083 defaultdisplay = ibrowse
1816 2084 __all__.append("ibrowse")
1817 2085
1818 2086
1819 2087 # If we're running under IPython, install an IPython displayhook that
1820 2088 # returns the object from Display.display(), else install a displayhook
1821 2089 # directly as sys.displayhook
1822 2090 api = None
1823 2091 if ipapi is not None:
1824 2092 try:
1825 2093 api = ipapi.get()
1826 2094 except AttributeError:
1827 2095 pass
1828 2096
1829 2097 if api is not None:
1830 2098 def displayhook(self, obj):
1831 2099 if isinstance(obj, type) and issubclass(obj, Table):
1832 2100 obj = obj()
1833 2101 if isinstance(obj, Table):
1834 2102 obj = obj | defaultdisplay
1835 2103 if isinstance(obj, Display):
1836 2104 return obj.display()
1837 2105 else:
1838 2106 raise ipapi.TryNext
1839 2107 api.set_hook("result_display", displayhook)
1840 2108 else:
1841 2109 def installdisplayhook():
1842 2110 _originalhook = sys.displayhook
1843 2111 def displayhook(obj):
1844 2112 if isinstance(obj, type) and issubclass(obj, Table):
1845 2113 obj = obj()
1846 2114 if isinstance(obj, Table):
1847 2115 obj = obj | defaultdisplay
1848 2116 if isinstance(obj, Display):
1849 2117 return obj.display()
1850 2118 else:
1851 2119 _originalhook(obj)
1852 2120 sys.displayhook = displayhook
1853 2121 installdisplayhook()
@@ -1,5673 +1,5694 b''
1 1 2006-07-27 Walter Doerwald <walter@livinglogic.de>
2 2
3 3 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
4 4 not running under IPython.
5 5
6 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
7 and make it iterable (iterating over the attribute itself). Add two new
8 magic strings for __xattrs__(): If the string starts with "-", the attribute
9 will not be displayed in ibrowse's detail view (but it can still be
10 iterated over). This makes it possible to add attributes that are large
11 lists or generator methods to the detail view. Replace magic attribute names
12 and _attrname() and _getattr() with "descriptors": For each type of magic
13 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
14 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
15 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
16 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
17 are still supported.
18
19 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
20 fails in ibrowse.fetch(), the exception object is added as the last item
21 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
22 a generator throws an exception midway through execution.
23
24 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
25 encoding into methods.
26
6 27 2006-07-26 Ville Vainio <vivainio@gmail.com>
7 28
8 29 * iplib.py: history now stores multiline input as single
9 30 history entries. Patch by Jorgen Cederlof.
10 31
11 32 2006-07-18 Walter Doerwald <walter@livinglogic.de>
12 33
13 34 * IPython/Extensions/ibrowse.py: Make cursor visible over
14 35 non existing attributes.
15 36
16 37 2006-07-14 Walter Doerwald <walter@livinglogic.de>
17 38
18 39 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
19 40 error output of the running command doesn't mess up the screen.
20 41
21 42 2006-07-13 Walter Doerwald <walter@livinglogic.de>
22 43
23 44 * IPython/Extensions/ipipe.py (isort): Make isort usable without
24 45 argument. This sorts the items themselves.
25 46
26 47 2006-07-12 Walter Doerwald <walter@livinglogic.de>
27 48
28 49 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
29 50 Compile expression strings into code objects. This should speed
30 51 up ifilter and friends somewhat.
31 52
32 53 2006-07-08 Ville Vainio <vivainio@gmail.com>
33 54
34 55 * Magic.py: %cpaste now strips > from the beginning of lines
35 56 to ease pasting quoted code from emails. Contributed by
36 57 Stefan van der Walt.
37 58
38 59 2006-06-29 Ville Vainio <vivainio@gmail.com>
39 60
40 61 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
41 62 mode, patch contributed by Darren Dale. NEEDS TESTING!
42 63
43 64 2006-06-28 Walter Doerwald <walter@livinglogic.de>
44 65
45 66 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
46 67 a blue background. Fix fetching new display rows when the browser
47 68 scrolls more than a screenful (e.g. by using the goto command).
48 69
49 70 2006-06-27 Ville Vainio <vivainio@gmail.com>
50 71
51 72 * Magic.py (_inspect, _ofind) Apply David Huard's
52 73 patch for displaying the correct docstring for 'property'
53 74 attributes.
54 75
55 76 2006-06-23 Walter Doerwald <walter@livinglogic.de>
56 77
57 78 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
58 79 commands into the methods implementing them.
59 80
60 81 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
61 82
62 83 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
63 84 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
64 85 autoindent support was authored by Jin Liu.
65 86
66 87 2006-06-22 Walter Doerwald <walter@livinglogic.de>
67 88
68 89 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
69 90 for keymaps with a custom class that simplifies handling.
70 91
71 92 2006-06-19 Walter Doerwald <walter@livinglogic.de>
72 93
73 94 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
74 95 resizing. This requires Python 2.5 to work.
75 96
76 97 2006-06-16 Walter Doerwald <walter@livinglogic.de>
77 98
78 99 * IPython/Extensions/ibrowse.py: Add two new commands to
79 100 ibrowse: "hideattr" (mapped to "h") hides the attribute under
80 101 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
81 102 attributes again. Remapped the help command to "?". Display
82 103 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
83 104 as keys for the "home" and "end" commands. Add three new commands
84 105 to the input mode for "find" and friends: "delend" (CTRL-K)
85 106 deletes to the end of line. "incsearchup" searches upwards in the
86 107 command history for an input that starts with the text before the cursor.
87 108 "incsearchdown" does the same downwards. Removed a bogus mapping of
88 109 the x key to "delete".
89 110
90 111 2006-06-15 Ville Vainio <vivainio@gmail.com>
91 112
92 113 * iplib.py, hooks.py: Added new generate_prompt hook that can be
93 114 used to create prompts dynamically, instead of the "old" way of
94 115 assigning "magic" strings to prompt_in1 and prompt_in2. The old
95 116 way still works (it's invoked by the default hook), of course.
96 117
97 118 * Prompts.py: added generate_output_prompt hook for altering output
98 119 prompt
99 120
100 121 * Release.py: Changed version string to 0.7.3.svn.
101 122
102 123 2006-06-15 Walter Doerwald <walter@livinglogic.de>
103 124
104 125 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
105 126 the call to fetch() always tries to fetch enough data for at least one
106 127 full screen. This makes it possible to simply call moveto(0,0,True) in
107 128 the constructor. Fix typos and removed the obsolete goto attribute.
108 129
109 130 2006-06-12 Ville Vainio <vivainio@gmail.com>
110 131
111 132 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
112 133 allowing $variable interpolation within multiline statements,
113 134 though so far only with "sh" profile for a testing period.
114 135 The patch also enables splitting long commands with \ but it
115 136 doesn't work properly yet.
116 137
117 138 2006-06-12 Walter Doerwald <walter@livinglogic.de>
118 139
119 140 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
120 141 input history and the position of the cursor in the input history for
121 142 the find, findbackwards and goto command.
122 143
123 144 2006-06-10 Walter Doerwald <walter@livinglogic.de>
124 145
125 146 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
126 147 implements the basic functionality of browser commands that require
127 148 input. Reimplement the goto, find and findbackwards commands as
128 149 subclasses of _CommandInput. Add an input history and keymaps to those
129 150 commands. Add "\r" as a keyboard shortcut for the enterdefault and
130 151 execute commands.
131 152
132 153 2006-06-07 Ville Vainio <vivainio@gmail.com>
133 154
134 155 * iplib.py: ipython mybatch.ipy exits ipython immediately after
135 156 running the batch files instead of leaving the session open.
136 157
137 158 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
138 159
139 160 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
140 161 the original fix was incomplete. Patch submitted by W. Maier.
141 162
142 163 2006-06-07 Ville Vainio <vivainio@gmail.com>
143 164
144 165 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
145 166 Confirmation prompts can be supressed by 'quiet' option.
146 167 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
147 168
148 169 2006-06-06 *** Released version 0.7.2
149 170
150 171 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
151 172
152 173 * IPython/Release.py (version): Made 0.7.2 final for release.
153 174 Repo tagged and release cut.
154 175
155 176 2006-06-05 Ville Vainio <vivainio@gmail.com>
156 177
157 178 * Magic.py (magic_rehashx): Honor no_alias list earlier in
158 179 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
159 180
160 181 * upgrade_dir.py: try import 'path' module a bit harder
161 182 (for %upgrade)
162 183
163 184 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
164 185
165 186 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
166 187 instead of looping 20 times.
167 188
168 189 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
169 190 correctly at initialization time. Bug reported by Krishna Mohan
170 191 Gundu <gkmohan-AT-gmail.com> on the user list.
171 192
172 193 * IPython/Release.py (version): Mark 0.7.2 version to start
173 194 testing for release on 06/06.
174 195
175 196 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
176 197
177 198 * scripts/irunner: thin script interface so users don't have to
178 199 find the module and call it as an executable, since modules rarely
179 200 live in people's PATH.
180 201
181 202 * IPython/irunner.py (InteractiveRunner.__init__): added
182 203 delaybeforesend attribute to control delays with newer versions of
183 204 pexpect. Thanks to detailed help from pexpect's author, Noah
184 205 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
185 206 correctly (it works in NoColor mode).
186 207
187 208 * IPython/iplib.py (handle_normal): fix nasty crash reported on
188 209 SAGE list, from improper log() calls.
189 210
190 211 2006-05-31 Ville Vainio <vivainio@gmail.com>
191 212
192 213 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
193 214 with args in parens to work correctly with dirs that have spaces.
194 215
195 216 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
196 217
197 218 * IPython/Logger.py (Logger.logstart): add option to log raw input
198 219 instead of the processed one. A -r flag was added to the
199 220 %logstart magic used for controlling logging.
200 221
201 222 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
202 223
203 224 * IPython/iplib.py (InteractiveShell.__init__): add check for the
204 225 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
205 226 recognize the option. After a bug report by Will Maier. This
206 227 closes #64 (will do it after confirmation from W. Maier).
207 228
208 229 * IPython/irunner.py: New module to run scripts as if manually
209 230 typed into an interactive environment, based on pexpect. After a
210 231 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
211 232 ipython-user list. Simple unittests in the tests/ directory.
212 233
213 234 * tools/release: add Will Maier, OpenBSD port maintainer, to
214 235 recepients list. We are now officially part of the OpenBSD ports:
215 236 http://www.openbsd.org/ports.html ! Many thanks to Will for the
216 237 work.
217 238
218 239 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
219 240
220 241 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
221 242 so that it doesn't break tkinter apps.
222 243
223 244 * IPython/iplib.py (_prefilter): fix bug where aliases would
224 245 shadow variables when autocall was fully off. Reported by SAGE
225 246 author William Stein.
226 247
227 248 * IPython/OInspect.py (Inspector.__init__): add a flag to control
228 249 at what detail level strings are computed when foo? is requested.
229 250 This allows users to ask for example that the string form of an
230 251 object is only computed when foo?? is called, or even never, by
231 252 setting the object_info_string_level >= 2 in the configuration
232 253 file. This new option has been added and documented. After a
233 254 request by SAGE to be able to control the printing of very large
234 255 objects more easily.
235 256
236 257 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
237 258
238 259 * IPython/ipmaker.py (make_IPython): remove the ipython call path
239 260 from sys.argv, to be 100% consistent with how Python itself works
240 261 (as seen for example with python -i file.py). After a bug report
241 262 by Jeffrey Collins.
242 263
243 264 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
244 265 nasty bug which was preventing custom namespaces with -pylab,
245 266 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
246 267 compatibility (long gone from mpl).
247 268
248 269 * IPython/ipapi.py (make_session): name change: create->make. We
249 270 use make in other places (ipmaker,...), it's shorter and easier to
250 271 type and say, etc. I'm trying to clean things before 0.7.2 so
251 272 that I can keep things stable wrt to ipapi in the chainsaw branch.
252 273
253 274 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
254 275 python-mode recognizes our debugger mode. Add support for
255 276 autoindent inside (X)emacs. After a patch sent in by Jin Liu
256 277 <m.liu.jin-AT-gmail.com> originally written by
257 278 doxgen-AT-newsmth.net (with minor modifications for xemacs
258 279 compatibility)
259 280
260 281 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
261 282 tracebacks when walking the stack so that the stack tracking system
262 283 in emacs' python-mode can identify the frames correctly.
263 284
264 285 * IPython/ipmaker.py (make_IPython): make the internal (and
265 286 default config) autoedit_syntax value false by default. Too many
266 287 users have complained to me (both on and off-list) about problems
267 288 with this option being on by default, so I'm making it default to
268 289 off. It can still be enabled by anyone via the usual mechanisms.
269 290
270 291 * IPython/completer.py (Completer.attr_matches): add support for
271 292 PyCrust-style _getAttributeNames magic method. Patch contributed
272 293 by <mscott-AT-goldenspud.com>. Closes #50.
273 294
274 295 * IPython/iplib.py (InteractiveShell.__init__): remove the
275 296 deletion of exit/quit from __builtin__, which can break
276 297 third-party tools like the Zope debugging console. The
277 298 %exit/%quit magics remain. In general, it's probably a good idea
278 299 not to delete anything from __builtin__, since we never know what
279 300 that will break. In any case, python now (for 2.5) will support
280 301 'real' exit/quit, so this issue is moot. Closes #55.
281 302
282 303 * IPython/genutils.py (with_obj): rename the 'with' function to
283 304 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
284 305 becomes a language keyword. Closes #53.
285 306
286 307 * IPython/FakeModule.py (FakeModule.__init__): add a proper
287 308 __file__ attribute to this so it fools more things into thinking
288 309 it is a real module. Closes #59.
289 310
290 311 * IPython/Magic.py (magic_edit): add -n option to open the editor
291 312 at a specific line number. After a patch by Stefan van der Walt.
292 313
293 314 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
294 315
295 316 * IPython/iplib.py (edit_syntax_error): fix crash when for some
296 317 reason the file could not be opened. After automatic crash
297 318 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
298 319 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
299 320 (_should_recompile): Don't fire editor if using %bg, since there
300 321 is no file in the first place. From the same report as above.
301 322 (raw_input): protect against faulty third-party prefilters. After
302 323 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
303 324 while running under SAGE.
304 325
305 326 2006-05-23 Ville Vainio <vivainio@gmail.com>
306 327
307 328 * ipapi.py: Stripped down ip.to_user_ns() to work only as
308 329 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
309 330 now returns None (again), unless dummy is specifically allowed by
310 331 ipapi.get(allow_dummy=True).
311 332
312 333 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
313 334
314 335 * IPython: remove all 2.2-compatibility objects and hacks from
315 336 everywhere, since we only support 2.3 at this point. Docs
316 337 updated.
317 338
318 339 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
319 340 Anything requiring extra validation can be turned into a Python
320 341 property in the future. I used a property for the db one b/c
321 342 there was a nasty circularity problem with the initialization
322 343 order, which right now I don't have time to clean up.
323 344
324 345 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
325 346 another locking bug reported by Jorgen. I'm not 100% sure though,
326 347 so more testing is needed...
327 348
328 349 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
329 350
330 351 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
331 352 local variables from any routine in user code (typically executed
332 353 with %run) directly into the interactive namespace. Very useful
333 354 when doing complex debugging.
334 355 (IPythonNotRunning): Changed the default None object to a dummy
335 356 whose attributes can be queried as well as called without
336 357 exploding, to ease writing code which works transparently both in
337 358 and out of ipython and uses some of this API.
338 359
339 360 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
340 361
341 362 * IPython/hooks.py (result_display): Fix the fact that our display
342 363 hook was using str() instead of repr(), as the default python
343 364 console does. This had gone unnoticed b/c it only happened if
344 365 %Pprint was off, but the inconsistency was there.
345 366
346 367 2006-05-15 Ville Vainio <vivainio@gmail.com>
347 368
348 369 * Oinspect.py: Only show docstring for nonexisting/binary files
349 370 when doing object??, closing ticket #62
350 371
351 372 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
352 373
353 374 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
354 375 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
355 376 was being released in a routine which hadn't checked if it had
356 377 been the one to acquire it.
357 378
358 379 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
359 380
360 381 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
361 382
362 383 2006-04-11 Ville Vainio <vivainio@gmail.com>
363 384
364 385 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
365 386 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
366 387 prefilters, allowing stuff like magics and aliases in the file.
367 388
368 389 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
369 390 added. Supported now are "%clear in" and "%clear out" (clear input and
370 391 output history, respectively). Also fixed CachedOutput.flush to
371 392 properly flush the output cache.
372 393
373 394 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
374 395 half-success (and fail explicitly).
375 396
376 397 2006-03-28 Ville Vainio <vivainio@gmail.com>
377 398
378 399 * iplib.py: Fix quoting of aliases so that only argless ones
379 400 are quoted
380 401
381 402 2006-03-28 Ville Vainio <vivainio@gmail.com>
382 403
383 404 * iplib.py: Quote aliases with spaces in the name.
384 405 "c:\program files\blah\bin" is now legal alias target.
385 406
386 407 * ext_rehashdir.py: Space no longer allowed as arg
387 408 separator, since space is legal in path names.
388 409
389 410 2006-03-16 Ville Vainio <vivainio@gmail.com>
390 411
391 412 * upgrade_dir.py: Take path.py from Extensions, correcting
392 413 %upgrade magic
393 414
394 415 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
395 416
396 417 * hooks.py: Only enclose editor binary in quotes if legal and
397 418 necessary (space in the name, and is an existing file). Fixes a bug
398 419 reported by Zachary Pincus.
399 420
400 421 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
401 422
402 423 * Manual: thanks to a tip on proper color handling for Emacs, by
403 424 Eric J Haywiser <ejh1-AT-MIT.EDU>.
404 425
405 426 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
406 427 by applying the provided patch. Thanks to Liu Jin
407 428 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
408 429 XEmacs/Linux, I'm trusting the submitter that it actually helps
409 430 under win32/GNU Emacs. Will revisit if any problems are reported.
410 431
411 432 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
412 433
413 434 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
414 435 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
415 436
416 437 2006-03-12 Ville Vainio <vivainio@gmail.com>
417 438
418 439 * Magic.py (magic_timeit): Added %timeit magic, contributed by
419 440 Torsten Marek.
420 441
421 442 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
422 443
423 444 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
424 445 line ranges works again.
425 446
426 447 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
427 448
428 449 * IPython/iplib.py (showtraceback): add back sys.last_traceback
429 450 and friends, after a discussion with Zach Pincus on ipython-user.
430 451 I'm not 100% sure, but after thinking about it quite a bit, it may
431 452 be OK. Testing with the multithreaded shells didn't reveal any
432 453 problems, but let's keep an eye out.
433 454
434 455 In the process, I fixed a few things which were calling
435 456 self.InteractiveTB() directly (like safe_execfile), which is a
436 457 mistake: ALL exception reporting should be done by calling
437 458 self.showtraceback(), which handles state and tab-completion and
438 459 more.
439 460
440 461 2006-03-01 Ville Vainio <vivainio@gmail.com>
441 462
442 463 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
443 464 To use, do "from ipipe import *".
444 465
445 466 2006-02-24 Ville Vainio <vivainio@gmail.com>
446 467
447 468 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
448 469 "cleanly" and safely than the older upgrade mechanism.
449 470
450 471 2006-02-21 Ville Vainio <vivainio@gmail.com>
451 472
452 473 * Magic.py: %save works again.
453 474
454 475 2006-02-15 Ville Vainio <vivainio@gmail.com>
455 476
456 477 * Magic.py: %Pprint works again
457 478
458 479 * Extensions/ipy_sane_defaults.py: Provide everything provided
459 480 in default ipythonrc, to make it possible to have a completely empty
460 481 ipythonrc (and thus completely rc-file free configuration)
461 482
462 483 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
463 484
464 485 * IPython/hooks.py (editor): quote the call to the editor command,
465 486 to allow commands with spaces in them. Problem noted by watching
466 487 Ian Oswald's video about textpad under win32 at
467 488 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
468 489
469 490 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
470 491 describing magics (we haven't used @ for a loong time).
471 492
472 493 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
473 494 contributed by marienz to close
474 495 http://www.scipy.net/roundup/ipython/issue53.
475 496
476 497 2006-02-10 Ville Vainio <vivainio@gmail.com>
477 498
478 499 * genutils.py: getoutput now works in win32 too
479 500
480 501 * completer.py: alias and magic completion only invoked
481 502 at the first "item" in the line, to avoid "cd %store"
482 503 nonsense.
483 504
484 505 2006-02-09 Ville Vainio <vivainio@gmail.com>
485 506
486 507 * test/*: Added a unit testing framework (finally).
487 508 '%run runtests.py' to run test_*.
488 509
489 510 * ipapi.py: Exposed runlines and set_custom_exc
490 511
491 512 2006-02-07 Ville Vainio <vivainio@gmail.com>
492 513
493 514 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
494 515 instead use "f(1 2)" as before.
495 516
496 517 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
497 518
498 519 * IPython/demo.py (IPythonDemo): Add new classes to the demo
499 520 facilities, for demos processed by the IPython input filter
500 521 (IPythonDemo), and for running a script one-line-at-a-time as a
501 522 demo, both for pure Python (LineDemo) and for IPython-processed
502 523 input (IPythonLineDemo). After a request by Dave Kohel, from the
503 524 SAGE team.
504 525 (Demo.edit): added an edit() method to the demo objects, to edit
505 526 the in-memory copy of the last executed block.
506 527
507 528 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
508 529 processing to %edit, %macro and %save. These commands can now be
509 530 invoked on the unprocessed input as it was typed by the user
510 531 (without any prefilters applied). After requests by the SAGE team
511 532 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
512 533
513 534 2006-02-01 Ville Vainio <vivainio@gmail.com>
514 535
515 536 * setup.py, eggsetup.py: easy_install ipython==dev works
516 537 correctly now (on Linux)
517 538
518 539 * ipy_user_conf,ipmaker: user config changes, removed spurious
519 540 warnings
520 541
521 542 * iplib: if rc.banner is string, use it as is.
522 543
523 544 * Magic: %pycat accepts a string argument and pages it's contents.
524 545
525 546
526 547 2006-01-30 Ville Vainio <vivainio@gmail.com>
527 548
528 549 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
529 550 Now %store and bookmarks work through PickleShare, meaning that
530 551 concurrent access is possible and all ipython sessions see the
531 552 same database situation all the time, instead of snapshot of
532 553 the situation when the session was started. Hence, %bookmark
533 554 results are immediately accessible from othes sessions. The database
534 555 is also available for use by user extensions. See:
535 556 http://www.python.org/pypi/pickleshare
536 557
537 558 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
538 559
539 560 * aliases can now be %store'd
540 561
541 562 * path.py moved to Extensions so that pickleshare does not need
542 563 IPython-specific import. Extensions added to pythonpath right
543 564 at __init__.
544 565
545 566 * iplib.py: ipalias deprecated/redundant; aliases are converted and
546 567 called with _ip.system and the pre-transformed command string.
547 568
548 569 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
549 570
550 571 * IPython/iplib.py (interact): Fix that we were not catching
551 572 KeyboardInterrupt exceptions properly. I'm not quite sure why the
552 573 logic here had to change, but it's fixed now.
553 574
554 575 2006-01-29 Ville Vainio <vivainio@gmail.com>
555 576
556 577 * iplib.py: Try to import pyreadline on Windows.
557 578
558 579 2006-01-27 Ville Vainio <vivainio@gmail.com>
559 580
560 581 * iplib.py: Expose ipapi as _ip in builtin namespace.
561 582 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
562 583 and ip_set_hook (-> _ip.set_hook) redundant. % and !
563 584 syntax now produce _ip.* variant of the commands.
564 585
565 586 * "_ip.options().autoedit_syntax = 2" automatically throws
566 587 user to editor for syntax error correction without prompting.
567 588
568 589 2006-01-27 Ville Vainio <vivainio@gmail.com>
569 590
570 591 * ipmaker.py: Give "realistic" sys.argv for scripts (without
571 592 'ipython' at argv[0]) executed through command line.
572 593 NOTE: this DEPRECATES calling ipython with multiple scripts
573 594 ("ipython a.py b.py c.py")
574 595
575 596 * iplib.py, hooks.py: Added configurable input prefilter,
576 597 named 'input_prefilter'. See ext_rescapture.py for example
577 598 usage.
578 599
579 600 * ext_rescapture.py, Magic.py: Better system command output capture
580 601 through 'var = !ls' (deprecates user-visible %sc). Same notation
581 602 applies for magics, 'var = %alias' assigns alias list to var.
582 603
583 604 * ipapi.py: added meta() for accessing extension-usable data store.
584 605
585 606 * iplib.py: added InteractiveShell.getapi(). New magics should be
586 607 written doing self.getapi() instead of using the shell directly.
587 608
588 609 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
589 610 %store foo >> ~/myfoo.txt to store variables to files (in clean
590 611 textual form, not a restorable pickle).
591 612
592 613 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
593 614
594 615 * usage.py, Magic.py: added %quickref
595 616
596 617 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
597 618
598 619 * GetoptErrors when invoking magics etc. with wrong args
599 620 are now more helpful:
600 621 GetoptError: option -l not recognized (allowed: "qb" )
601 622
602 623 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
603 624
604 625 * IPython/demo.py (Demo.show): Flush stdout after each block, so
605 626 computationally intensive blocks don't appear to stall the demo.
606 627
607 628 2006-01-24 Ville Vainio <vivainio@gmail.com>
608 629
609 630 * iplib.py, hooks.py: 'result_display' hook can return a non-None
610 631 value to manipulate resulting history entry.
611 632
612 633 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
613 634 to instance methods of IPApi class, to make extending an embedded
614 635 IPython feasible. See ext_rehashdir.py for example usage.
615 636
616 637 * Merged 1071-1076 from branches/0.7.1
617 638
618 639
619 640 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
620 641
621 642 * tools/release (daystamp): Fix build tools to use the new
622 643 eggsetup.py script to build lightweight eggs.
623 644
624 645 * Applied changesets 1062 and 1064 before 0.7.1 release.
625 646
626 647 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
627 648 see the raw input history (without conversions like %ls ->
628 649 ipmagic("ls")). After a request from W. Stein, SAGE
629 650 (http://modular.ucsd.edu/sage) developer. This information is
630 651 stored in the input_hist_raw attribute of the IPython instance, so
631 652 developers can access it if needed (it's an InputList instance).
632 653
633 654 * Versionstring = 0.7.2.svn
634 655
635 656 * eggsetup.py: A separate script for constructing eggs, creates
636 657 proper launch scripts even on Windows (an .exe file in
637 658 \python24\scripts).
638 659
639 660 * ipapi.py: launch_new_instance, launch entry point needed for the
640 661 egg.
641 662
642 663 2006-01-23 Ville Vainio <vivainio@gmail.com>
643 664
644 665 * Added %cpaste magic for pasting python code
645 666
646 667 2006-01-22 Ville Vainio <vivainio@gmail.com>
647 668
648 669 * Merge from branches/0.7.1 into trunk, revs 1052-1057
649 670
650 671 * Versionstring = 0.7.2.svn
651 672
652 673 * eggsetup.py: A separate script for constructing eggs, creates
653 674 proper launch scripts even on Windows (an .exe file in
654 675 \python24\scripts).
655 676
656 677 * ipapi.py: launch_new_instance, launch entry point needed for the
657 678 egg.
658 679
659 680 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
660 681
661 682 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
662 683 %pfile foo would print the file for foo even if it was a binary.
663 684 Now, extensions '.so' and '.dll' are skipped.
664 685
665 686 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
666 687 bug, where macros would fail in all threaded modes. I'm not 100%
667 688 sure, so I'm going to put out an rc instead of making a release
668 689 today, and wait for feedback for at least a few days.
669 690
670 691 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
671 692 it...) the handling of pasting external code with autoindent on.
672 693 To get out of a multiline input, the rule will appear for most
673 694 users unchanged: two blank lines or change the indent level
674 695 proposed by IPython. But there is a twist now: you can
675 696 add/subtract only *one or two spaces*. If you add/subtract three
676 697 or more (unless you completely delete the line), IPython will
677 698 accept that line, and you'll need to enter a second one of pure
678 699 whitespace. I know it sounds complicated, but I can't find a
679 700 different solution that covers all the cases, with the right
680 701 heuristics. Hopefully in actual use, nobody will really notice
681 702 all these strange rules and things will 'just work'.
682 703
683 704 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
684 705
685 706 * IPython/iplib.py (interact): catch exceptions which can be
686 707 triggered asynchronously by signal handlers. Thanks to an
687 708 automatic crash report, submitted by Colin Kingsley
688 709 <tercel-AT-gentoo.org>.
689 710
690 711 2006-01-20 Ville Vainio <vivainio@gmail.com>
691 712
692 713 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
693 714 (%rehashdir, very useful, try it out) of how to extend ipython
694 715 with new magics. Also added Extensions dir to pythonpath to make
695 716 importing extensions easy.
696 717
697 718 * %store now complains when trying to store interactively declared
698 719 classes / instances of those classes.
699 720
700 721 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
701 722 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
702 723 if they exist, and ipy_user_conf.py with some defaults is created for
703 724 the user.
704 725
705 726 * Startup rehashing done by the config file, not InterpreterExec.
706 727 This means system commands are available even without selecting the
707 728 pysh profile. It's the sensible default after all.
708 729
709 730 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
710 731
711 732 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
712 733 multiline code with autoindent on working. But I am really not
713 734 sure, so this needs more testing. Will commit a debug-enabled
714 735 version for now, while I test it some more, so that Ville and
715 736 others may also catch any problems. Also made
716 737 self.indent_current_str() a method, to ensure that there's no
717 738 chance of the indent space count and the corresponding string
718 739 falling out of sync. All code needing the string should just call
719 740 the method.
720 741
721 742 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
722 743
723 744 * IPython/Magic.py (magic_edit): fix check for when users don't
724 745 save their output files, the try/except was in the wrong section.
725 746
726 747 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
727 748
728 749 * IPython/Magic.py (magic_run): fix __file__ global missing from
729 750 script's namespace when executed via %run. After a report by
730 751 Vivian.
731 752
732 753 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
733 754 when using python 2.4. The parent constructor changed in 2.4, and
734 755 we need to track it directly (we can't call it, as it messes up
735 756 readline and tab-completion inside our pdb would stop working).
736 757 After a bug report by R. Bernstein <rocky-AT-panix.com>.
737 758
738 759 2006-01-16 Ville Vainio <vivainio@gmail.com>
739 760
740 761 * Ipython/magic.py: Reverted back to old %edit functionality
741 762 that returns file contents on exit.
742 763
743 764 * IPython/path.py: Added Jason Orendorff's "path" module to
744 765 IPython tree, http://www.jorendorff.com/articles/python/path/.
745 766 You can get path objects conveniently through %sc, and !!, e.g.:
746 767 sc files=ls
747 768 for p in files.paths: # or files.p
748 769 print p,p.mtime
749 770
750 771 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
751 772 now work again without considering the exclusion regexp -
752 773 hence, things like ',foo my/path' turn to 'foo("my/path")'
753 774 instead of syntax error.
754 775
755 776
756 777 2006-01-14 Ville Vainio <vivainio@gmail.com>
757 778
758 779 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
759 780 ipapi decorators for python 2.4 users, options() provides access to rc
760 781 data.
761 782
762 783 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
763 784 as path separators (even on Linux ;-). Space character after
764 785 backslash (as yielded by tab completer) is still space;
765 786 "%cd long\ name" works as expected.
766 787
767 788 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
768 789 as "chain of command", with priority. API stays the same,
769 790 TryNext exception raised by a hook function signals that
770 791 current hook failed and next hook should try handling it, as
771 792 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
772 793 requested configurable display hook, which is now implemented.
773 794
774 795 2006-01-13 Ville Vainio <vivainio@gmail.com>
775 796
776 797 * IPython/platutils*.py: platform specific utility functions,
777 798 so far only set_term_title is implemented (change terminal
778 799 label in windowing systems). %cd now changes the title to
779 800 current dir.
780 801
781 802 * IPython/Release.py: Added myself to "authors" list,
782 803 had to create new files.
783 804
784 805 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
785 806 shell escape; not a known bug but had potential to be one in the
786 807 future.
787 808
788 809 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
789 810 extension API for IPython! See the module for usage example. Fix
790 811 OInspect for docstring-less magic functions.
791 812
792 813
793 814 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
794 815
795 816 * IPython/iplib.py (raw_input): temporarily deactivate all
796 817 attempts at allowing pasting of code with autoindent on. It
797 818 introduced bugs (reported by Prabhu) and I can't seem to find a
798 819 robust combination which works in all cases. Will have to revisit
799 820 later.
800 821
801 822 * IPython/genutils.py: remove isspace() function. We've dropped
802 823 2.2 compatibility, so it's OK to use the string method.
803 824
804 825 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
805 826
806 827 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
807 828 matching what NOT to autocall on, to include all python binary
808 829 operators (including things like 'and', 'or', 'is' and 'in').
809 830 Prompted by a bug report on 'foo & bar', but I realized we had
810 831 many more potential bug cases with other operators. The regexp is
811 832 self.re_exclude_auto, it's fairly commented.
812 833
813 834 2006-01-12 Ville Vainio <vivainio@gmail.com>
814 835
815 836 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
816 837 Prettified and hardened string/backslash quoting with ipsystem(),
817 838 ipalias() and ipmagic(). Now even \ characters are passed to
818 839 %magics, !shell escapes and aliases exactly as they are in the
819 840 ipython command line. Should improve backslash experience,
820 841 particularly in Windows (path delimiter for some commands that
821 842 won't understand '/'), but Unix benefits as well (regexps). %cd
822 843 magic still doesn't support backslash path delimiters, though. Also
823 844 deleted all pretense of supporting multiline command strings in
824 845 !system or %magic commands. Thanks to Jerry McRae for suggestions.
825 846
826 847 * doc/build_doc_instructions.txt added. Documentation on how to
827 848 use doc/update_manual.py, added yesterday. Both files contributed
828 849 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
829 850 doc/*.sh for deprecation at a later date.
830 851
831 852 * /ipython.py Added ipython.py to root directory for
832 853 zero-installation (tar xzvf ipython.tgz; cd ipython; python
833 854 ipython.py) and development convenience (no need to keep doing
834 855 "setup.py install" between changes).
835 856
836 857 * Made ! and !! shell escapes work (again) in multiline expressions:
837 858 if 1:
838 859 !ls
839 860 !!ls
840 861
841 862 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
842 863
843 864 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
844 865 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
845 866 module in case-insensitive installation. Was causing crashes
846 867 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
847 868
848 869 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
849 870 <marienz-AT-gentoo.org>, closes
850 871 http://www.scipy.net/roundup/ipython/issue51.
851 872
852 873 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
853 874
854 875 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
855 876 problem of excessive CPU usage under *nix and keyboard lag under
856 877 win32.
857 878
858 879 2006-01-10 *** Released version 0.7.0
859 880
860 881 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
861 882
862 883 * IPython/Release.py (revision): tag version number to 0.7.0,
863 884 ready for release.
864 885
865 886 * IPython/Magic.py (magic_edit): Add print statement to %edit so
866 887 it informs the user of the name of the temp. file used. This can
867 888 help if you decide later to reuse that same file, so you know
868 889 where to copy the info from.
869 890
870 891 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
871 892
872 893 * setup_bdist_egg.py: little script to build an egg. Added
873 894 support in the release tools as well.
874 895
875 896 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
876 897
877 898 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
878 899 version selection (new -wxversion command line and ipythonrc
879 900 parameter). Patch contributed by Arnd Baecker
880 901 <arnd.baecker-AT-web.de>.
881 902
882 903 * IPython/iplib.py (embed_mainloop): fix tab-completion in
883 904 embedded instances, for variables defined at the interactive
884 905 prompt of the embedded ipython. Reported by Arnd.
885 906
886 907 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
887 908 it can be used as a (stateful) toggle, or with a direct parameter.
888 909
889 910 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
890 911 could be triggered in certain cases and cause the traceback
891 912 printer not to work.
892 913
893 914 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
894 915
895 916 * IPython/iplib.py (_should_recompile): Small fix, closes
896 917 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
897 918
898 919 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
899 920
900 921 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
901 922 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
902 923 Moad for help with tracking it down.
903 924
904 925 * IPython/iplib.py (handle_auto): fix autocall handling for
905 926 objects which support BOTH __getitem__ and __call__ (so that f [x]
906 927 is left alone, instead of becoming f([x]) automatically).
907 928
908 929 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
909 930 Ville's patch.
910 931
911 932 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
912 933
913 934 * IPython/iplib.py (handle_auto): changed autocall semantics to
914 935 include 'smart' mode, where the autocall transformation is NOT
915 936 applied if there are no arguments on the line. This allows you to
916 937 just type 'foo' if foo is a callable to see its internal form,
917 938 instead of having it called with no arguments (typically a
918 939 mistake). The old 'full' autocall still exists: for that, you
919 940 need to set the 'autocall' parameter to 2 in your ipythonrc file.
920 941
921 942 * IPython/completer.py (Completer.attr_matches): add
922 943 tab-completion support for Enthoughts' traits. After a report by
923 944 Arnd and a patch by Prabhu.
924 945
925 946 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
926 947
927 948 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
928 949 Schmolck's patch to fix inspect.getinnerframes().
929 950
930 951 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
931 952 for embedded instances, regarding handling of namespaces and items
932 953 added to the __builtin__ one. Multiple embedded instances and
933 954 recursive embeddings should work better now (though I'm not sure
934 955 I've got all the corner cases fixed, that code is a bit of a brain
935 956 twister).
936 957
937 958 * IPython/Magic.py (magic_edit): added support to edit in-memory
938 959 macros (automatically creates the necessary temp files). %edit
939 960 also doesn't return the file contents anymore, it's just noise.
940 961
941 962 * IPython/completer.py (Completer.attr_matches): revert change to
942 963 complete only on attributes listed in __all__. I realized it
943 964 cripples the tab-completion system as a tool for exploring the
944 965 internals of unknown libraries (it renders any non-__all__
945 966 attribute off-limits). I got bit by this when trying to see
946 967 something inside the dis module.
947 968
948 969 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
949 970
950 971 * IPython/iplib.py (InteractiveShell.__init__): add .meta
951 972 namespace for users and extension writers to hold data in. This
952 973 follows the discussion in
953 974 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
954 975
955 976 * IPython/completer.py (IPCompleter.complete): small patch to help
956 977 tab-completion under Emacs, after a suggestion by John Barnard
957 978 <barnarj-AT-ccf.org>.
958 979
959 980 * IPython/Magic.py (Magic.extract_input_slices): added support for
960 981 the slice notation in magics to use N-M to represent numbers N...M
961 982 (closed endpoints). This is used by %macro and %save.
962 983
963 984 * IPython/completer.py (Completer.attr_matches): for modules which
964 985 define __all__, complete only on those. After a patch by Jeffrey
965 986 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
966 987 speed up this routine.
967 988
968 989 * IPython/Logger.py (Logger.log): fix a history handling bug. I
969 990 don't know if this is the end of it, but the behavior now is
970 991 certainly much more correct. Note that coupled with macros,
971 992 slightly surprising (at first) behavior may occur: a macro will in
972 993 general expand to multiple lines of input, so upon exiting, the
973 994 in/out counters will both be bumped by the corresponding amount
974 995 (as if the macro's contents had been typed interactively). Typing
975 996 %hist will reveal the intermediate (silently processed) lines.
976 997
977 998 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
978 999 pickle to fail (%run was overwriting __main__ and not restoring
979 1000 it, but pickle relies on __main__ to operate).
980 1001
981 1002 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
982 1003 using properties, but forgot to make the main InteractiveShell
983 1004 class a new-style class. Properties fail silently, and
984 1005 mysteriously, with old-style class (getters work, but
985 1006 setters don't do anything).
986 1007
987 1008 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
988 1009
989 1010 * IPython/Magic.py (magic_history): fix history reporting bug (I
990 1011 know some nasties are still there, I just can't seem to find a
991 1012 reproducible test case to track them down; the input history is
992 1013 falling out of sync...)
993 1014
994 1015 * IPython/iplib.py (handle_shell_escape): fix bug where both
995 1016 aliases and system accesses where broken for indented code (such
996 1017 as loops).
997 1018
998 1019 * IPython/genutils.py (shell): fix small but critical bug for
999 1020 win32 system access.
1000 1021
1001 1022 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1002 1023
1003 1024 * IPython/iplib.py (showtraceback): remove use of the
1004 1025 sys.last_{type/value/traceback} structures, which are non
1005 1026 thread-safe.
1006 1027 (_prefilter): change control flow to ensure that we NEVER
1007 1028 introspect objects when autocall is off. This will guarantee that
1008 1029 having an input line of the form 'x.y', where access to attribute
1009 1030 'y' has side effects, doesn't trigger the side effect TWICE. It
1010 1031 is important to note that, with autocall on, these side effects
1011 1032 can still happen.
1012 1033 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1013 1034 trio. IPython offers these three kinds of special calls which are
1014 1035 not python code, and it's a good thing to have their call method
1015 1036 be accessible as pure python functions (not just special syntax at
1016 1037 the command line). It gives us a better internal implementation
1017 1038 structure, as well as exposing these for user scripting more
1018 1039 cleanly.
1019 1040
1020 1041 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1021 1042 file. Now that they'll be more likely to be used with the
1022 1043 persistance system (%store), I want to make sure their module path
1023 1044 doesn't change in the future, so that we don't break things for
1024 1045 users' persisted data.
1025 1046
1026 1047 * IPython/iplib.py (autoindent_update): move indentation
1027 1048 management into the _text_ processing loop, not the keyboard
1028 1049 interactive one. This is necessary to correctly process non-typed
1029 1050 multiline input (such as macros).
1030 1051
1031 1052 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1032 1053 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1033 1054 which was producing problems in the resulting manual.
1034 1055 (magic_whos): improve reporting of instances (show their class,
1035 1056 instead of simply printing 'instance' which isn't terribly
1036 1057 informative).
1037 1058
1038 1059 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1039 1060 (minor mods) to support network shares under win32.
1040 1061
1041 1062 * IPython/winconsole.py (get_console_size): add new winconsole
1042 1063 module and fixes to page_dumb() to improve its behavior under
1043 1064 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1044 1065
1045 1066 * IPython/Magic.py (Macro): simplified Macro class to just
1046 1067 subclass list. We've had only 2.2 compatibility for a very long
1047 1068 time, yet I was still avoiding subclassing the builtin types. No
1048 1069 more (I'm also starting to use properties, though I won't shift to
1049 1070 2.3-specific features quite yet).
1050 1071 (magic_store): added Ville's patch for lightweight variable
1051 1072 persistence, after a request on the user list by Matt Wilkie
1052 1073 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1053 1074 details.
1054 1075
1055 1076 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1056 1077 changed the default logfile name from 'ipython.log' to
1057 1078 'ipython_log.py'. These logs are real python files, and now that
1058 1079 we have much better multiline support, people are more likely to
1059 1080 want to use them as such. Might as well name them correctly.
1060 1081
1061 1082 * IPython/Magic.py: substantial cleanup. While we can't stop
1062 1083 using magics as mixins, due to the existing customizations 'out
1063 1084 there' which rely on the mixin naming conventions, at least I
1064 1085 cleaned out all cross-class name usage. So once we are OK with
1065 1086 breaking compatibility, the two systems can be separated.
1066 1087
1067 1088 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1068 1089 anymore, and the class is a fair bit less hideous as well. New
1069 1090 features were also introduced: timestamping of input, and logging
1070 1091 of output results. These are user-visible with the -t and -o
1071 1092 options to %logstart. Closes
1072 1093 http://www.scipy.net/roundup/ipython/issue11 and a request by
1073 1094 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1074 1095
1075 1096 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1076 1097
1077 1098 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1078 1099 better handle backslashes in paths. See the thread 'More Windows
1079 1100 questions part 2 - \/ characters revisited' on the iypthon user
1080 1101 list:
1081 1102 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1082 1103
1083 1104 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1084 1105
1085 1106 (InteractiveShell.__init__): change threaded shells to not use the
1086 1107 ipython crash handler. This was causing more problems than not,
1087 1108 as exceptions in the main thread (GUI code, typically) would
1088 1109 always show up as a 'crash', when they really weren't.
1089 1110
1090 1111 The colors and exception mode commands (%colors/%xmode) have been
1091 1112 synchronized to also take this into account, so users can get
1092 1113 verbose exceptions for their threaded code as well. I also added
1093 1114 support for activating pdb inside this exception handler as well,
1094 1115 so now GUI authors can use IPython's enhanced pdb at runtime.
1095 1116
1096 1117 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1097 1118 true by default, and add it to the shipped ipythonrc file. Since
1098 1119 this asks the user before proceeding, I think it's OK to make it
1099 1120 true by default.
1100 1121
1101 1122 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1102 1123 of the previous special-casing of input in the eval loop. I think
1103 1124 this is cleaner, as they really are commands and shouldn't have
1104 1125 a special role in the middle of the core code.
1105 1126
1106 1127 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1107 1128
1108 1129 * IPython/iplib.py (edit_syntax_error): added support for
1109 1130 automatically reopening the editor if the file had a syntax error
1110 1131 in it. Thanks to scottt who provided the patch at:
1111 1132 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1112 1133 version committed).
1113 1134
1114 1135 * IPython/iplib.py (handle_normal): add suport for multi-line
1115 1136 input with emtpy lines. This fixes
1116 1137 http://www.scipy.net/roundup/ipython/issue43 and a similar
1117 1138 discussion on the user list.
1118 1139
1119 1140 WARNING: a behavior change is necessarily introduced to support
1120 1141 blank lines: now a single blank line with whitespace does NOT
1121 1142 break the input loop, which means that when autoindent is on, by
1122 1143 default hitting return on the next (indented) line does NOT exit.
1123 1144
1124 1145 Instead, to exit a multiline input you can either have:
1125 1146
1126 1147 - TWO whitespace lines (just hit return again), or
1127 1148 - a single whitespace line of a different length than provided
1128 1149 by the autoindent (add or remove a space).
1129 1150
1130 1151 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1131 1152 module to better organize all readline-related functionality.
1132 1153 I've deleted FlexCompleter and put all completion clases here.
1133 1154
1134 1155 * IPython/iplib.py (raw_input): improve indentation management.
1135 1156 It is now possible to paste indented code with autoindent on, and
1136 1157 the code is interpreted correctly (though it still looks bad on
1137 1158 screen, due to the line-oriented nature of ipython).
1138 1159 (MagicCompleter.complete): change behavior so that a TAB key on an
1139 1160 otherwise empty line actually inserts a tab, instead of completing
1140 1161 on the entire global namespace. This makes it easier to use the
1141 1162 TAB key for indentation. After a request by Hans Meine
1142 1163 <hans_meine-AT-gmx.net>
1143 1164 (_prefilter): add support so that typing plain 'exit' or 'quit'
1144 1165 does a sensible thing. Originally I tried to deviate as little as
1145 1166 possible from the default python behavior, but even that one may
1146 1167 change in this direction (thread on python-dev to that effect).
1147 1168 Regardless, ipython should do the right thing even if CPython's
1148 1169 '>>>' prompt doesn't.
1149 1170 (InteractiveShell): removed subclassing code.InteractiveConsole
1150 1171 class. By now we'd overridden just about all of its methods: I've
1151 1172 copied the remaining two over, and now ipython is a standalone
1152 1173 class. This will provide a clearer picture for the chainsaw
1153 1174 branch refactoring.
1154 1175
1155 1176 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1156 1177
1157 1178 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1158 1179 failures for objects which break when dir() is called on them.
1159 1180
1160 1181 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1161 1182 distinct local and global namespaces in the completer API. This
1162 1183 change allows us to properly handle completion with distinct
1163 1184 scopes, including in embedded instances (this had never really
1164 1185 worked correctly).
1165 1186
1166 1187 Note: this introduces a change in the constructor for
1167 1188 MagicCompleter, as a new global_namespace parameter is now the
1168 1189 second argument (the others were bumped one position).
1169 1190
1170 1191 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1171 1192
1172 1193 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1173 1194 embedded instances (which can be done now thanks to Vivian's
1174 1195 frame-handling fixes for pdb).
1175 1196 (InteractiveShell.__init__): Fix namespace handling problem in
1176 1197 embedded instances. We were overwriting __main__ unconditionally,
1177 1198 and this should only be done for 'full' (non-embedded) IPython;
1178 1199 embedded instances must respect the caller's __main__. Thanks to
1179 1200 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1180 1201
1181 1202 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1182 1203
1183 1204 * setup.py: added download_url to setup(). This registers the
1184 1205 download address at PyPI, which is not only useful to humans
1185 1206 browsing the site, but is also picked up by setuptools (the Eggs
1186 1207 machinery). Thanks to Ville and R. Kern for the info/discussion
1187 1208 on this.
1188 1209
1189 1210 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1190 1211
1191 1212 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1192 1213 This brings a lot of nice functionality to the pdb mode, which now
1193 1214 has tab-completion, syntax highlighting, and better stack handling
1194 1215 than before. Many thanks to Vivian De Smedt
1195 1216 <vivian-AT-vdesmedt.com> for the original patches.
1196 1217
1197 1218 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1198 1219
1199 1220 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1200 1221 sequence to consistently accept the banner argument. The
1201 1222 inconsistency was tripping SAGE, thanks to Gary Zablackis
1202 1223 <gzabl-AT-yahoo.com> for the report.
1203 1224
1204 1225 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1205 1226
1206 1227 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1207 1228 Fix bug where a naked 'alias' call in the ipythonrc file would
1208 1229 cause a crash. Bug reported by Jorgen Stenarson.
1209 1230
1210 1231 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1211 1232
1212 1233 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1213 1234 startup time.
1214 1235
1215 1236 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1216 1237 instances had introduced a bug with globals in normal code. Now
1217 1238 it's working in all cases.
1218 1239
1219 1240 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1220 1241 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1221 1242 has been introduced to set the default case sensitivity of the
1222 1243 searches. Users can still select either mode at runtime on a
1223 1244 per-search basis.
1224 1245
1225 1246 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1226 1247
1227 1248 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1228 1249 attributes in wildcard searches for subclasses. Modified version
1229 1250 of a patch by Jorgen.
1230 1251
1231 1252 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1232 1253
1233 1254 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1234 1255 embedded instances. I added a user_global_ns attribute to the
1235 1256 InteractiveShell class to handle this.
1236 1257
1237 1258 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1238 1259
1239 1260 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1240 1261 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1241 1262 (reported under win32, but may happen also in other platforms).
1242 1263 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1243 1264
1244 1265 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1245 1266
1246 1267 * IPython/Magic.py (magic_psearch): new support for wildcard
1247 1268 patterns. Now, typing ?a*b will list all names which begin with a
1248 1269 and end in b, for example. The %psearch magic has full
1249 1270 docstrings. Many thanks to JΓΆrgen Stenarson
1250 1271 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1251 1272 implementing this functionality.
1252 1273
1253 1274 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1254 1275
1255 1276 * Manual: fixed long-standing annoyance of double-dashes (as in
1256 1277 --prefix=~, for example) being stripped in the HTML version. This
1257 1278 is a latex2html bug, but a workaround was provided. Many thanks
1258 1279 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1259 1280 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1260 1281 rolling. This seemingly small issue had tripped a number of users
1261 1282 when first installing, so I'm glad to see it gone.
1262 1283
1263 1284 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1264 1285
1265 1286 * IPython/Extensions/numeric_formats.py: fix missing import,
1266 1287 reported by Stephen Walton.
1267 1288
1268 1289 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1269 1290
1270 1291 * IPython/demo.py: finish demo module, fully documented now.
1271 1292
1272 1293 * IPython/genutils.py (file_read): simple little utility to read a
1273 1294 file and ensure it's closed afterwards.
1274 1295
1275 1296 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1276 1297
1277 1298 * IPython/demo.py (Demo.__init__): added support for individually
1278 1299 tagging blocks for automatic execution.
1279 1300
1280 1301 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1281 1302 syntax-highlighted python sources, requested by John.
1282 1303
1283 1304 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1284 1305
1285 1306 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1286 1307 finishing.
1287 1308
1288 1309 * IPython/genutils.py (shlex_split): moved from Magic to here,
1289 1310 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1290 1311
1291 1312 * IPython/demo.py (Demo.__init__): added support for silent
1292 1313 blocks, improved marks as regexps, docstrings written.
1293 1314 (Demo.__init__): better docstring, added support for sys.argv.
1294 1315
1295 1316 * IPython/genutils.py (marquee): little utility used by the demo
1296 1317 code, handy in general.
1297 1318
1298 1319 * IPython/demo.py (Demo.__init__): new class for interactive
1299 1320 demos. Not documented yet, I just wrote it in a hurry for
1300 1321 scipy'05. Will docstring later.
1301 1322
1302 1323 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1303 1324
1304 1325 * IPython/Shell.py (sigint_handler): Drastic simplification which
1305 1326 also seems to make Ctrl-C work correctly across threads! This is
1306 1327 so simple, that I can't beleive I'd missed it before. Needs more
1307 1328 testing, though.
1308 1329 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1309 1330 like this before...
1310 1331
1311 1332 * IPython/genutils.py (get_home_dir): add protection against
1312 1333 non-dirs in win32 registry.
1313 1334
1314 1335 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1315 1336 bug where dict was mutated while iterating (pysh crash).
1316 1337
1317 1338 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1318 1339
1319 1340 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1320 1341 spurious newlines added by this routine. After a report by
1321 1342 F. Mantegazza.
1322 1343
1323 1344 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1324 1345
1325 1346 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1326 1347 calls. These were a leftover from the GTK 1.x days, and can cause
1327 1348 problems in certain cases (after a report by John Hunter).
1328 1349
1329 1350 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1330 1351 os.getcwd() fails at init time. Thanks to patch from David Remahl
1331 1352 <chmod007-AT-mac.com>.
1332 1353 (InteractiveShell.__init__): prevent certain special magics from
1333 1354 being shadowed by aliases. Closes
1334 1355 http://www.scipy.net/roundup/ipython/issue41.
1335 1356
1336 1357 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1337 1358
1338 1359 * IPython/iplib.py (InteractiveShell.complete): Added new
1339 1360 top-level completion method to expose the completion mechanism
1340 1361 beyond readline-based environments.
1341 1362
1342 1363 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1343 1364
1344 1365 * tools/ipsvnc (svnversion): fix svnversion capture.
1345 1366
1346 1367 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1347 1368 attribute to self, which was missing. Before, it was set by a
1348 1369 routine which in certain cases wasn't being called, so the
1349 1370 instance could end up missing the attribute. This caused a crash.
1350 1371 Closes http://www.scipy.net/roundup/ipython/issue40.
1351 1372
1352 1373 2005-08-16 Fernando Perez <fperez@colorado.edu>
1353 1374
1354 1375 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1355 1376 contains non-string attribute. Closes
1356 1377 http://www.scipy.net/roundup/ipython/issue38.
1357 1378
1358 1379 2005-08-14 Fernando Perez <fperez@colorado.edu>
1359 1380
1360 1381 * tools/ipsvnc: Minor improvements, to add changeset info.
1361 1382
1362 1383 2005-08-12 Fernando Perez <fperez@colorado.edu>
1363 1384
1364 1385 * IPython/iplib.py (runsource): remove self.code_to_run_src
1365 1386 attribute. I realized this is nothing more than
1366 1387 '\n'.join(self.buffer), and having the same data in two different
1367 1388 places is just asking for synchronization bugs. This may impact
1368 1389 people who have custom exception handlers, so I need to warn
1369 1390 ipython-dev about it (F. Mantegazza may use them).
1370 1391
1371 1392 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1372 1393
1373 1394 * IPython/genutils.py: fix 2.2 compatibility (generators)
1374 1395
1375 1396 2005-07-18 Fernando Perez <fperez@colorado.edu>
1376 1397
1377 1398 * IPython/genutils.py (get_home_dir): fix to help users with
1378 1399 invalid $HOME under win32.
1379 1400
1380 1401 2005-07-17 Fernando Perez <fperez@colorado.edu>
1381 1402
1382 1403 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1383 1404 some old hacks and clean up a bit other routines; code should be
1384 1405 simpler and a bit faster.
1385 1406
1386 1407 * IPython/iplib.py (interact): removed some last-resort attempts
1387 1408 to survive broken stdout/stderr. That code was only making it
1388 1409 harder to abstract out the i/o (necessary for gui integration),
1389 1410 and the crashes it could prevent were extremely rare in practice
1390 1411 (besides being fully user-induced in a pretty violent manner).
1391 1412
1392 1413 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1393 1414 Nothing major yet, but the code is simpler to read; this should
1394 1415 make it easier to do more serious modifications in the future.
1395 1416
1396 1417 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1397 1418 which broke in .15 (thanks to a report by Ville).
1398 1419
1399 1420 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1400 1421 be quite correct, I know next to nothing about unicode). This
1401 1422 will allow unicode strings to be used in prompts, amongst other
1402 1423 cases. It also will prevent ipython from crashing when unicode
1403 1424 shows up unexpectedly in many places. If ascii encoding fails, we
1404 1425 assume utf_8. Currently the encoding is not a user-visible
1405 1426 setting, though it could be made so if there is demand for it.
1406 1427
1407 1428 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1408 1429
1409 1430 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1410 1431
1411 1432 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1412 1433
1413 1434 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1414 1435 code can work transparently for 2.2/2.3.
1415 1436
1416 1437 2005-07-16 Fernando Perez <fperez@colorado.edu>
1417 1438
1418 1439 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1419 1440 out of the color scheme table used for coloring exception
1420 1441 tracebacks. This allows user code to add new schemes at runtime.
1421 1442 This is a minimally modified version of the patch at
1422 1443 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1423 1444 for the contribution.
1424 1445
1425 1446 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1426 1447 slightly modified version of the patch in
1427 1448 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1428 1449 to remove the previous try/except solution (which was costlier).
1429 1450 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1430 1451
1431 1452 2005-06-08 Fernando Perez <fperez@colorado.edu>
1432 1453
1433 1454 * IPython/iplib.py (write/write_err): Add methods to abstract all
1434 1455 I/O a bit more.
1435 1456
1436 1457 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1437 1458 warning, reported by Aric Hagberg, fix by JD Hunter.
1438 1459
1439 1460 2005-06-02 *** Released version 0.6.15
1440 1461
1441 1462 2005-06-01 Fernando Perez <fperez@colorado.edu>
1442 1463
1443 1464 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1444 1465 tab-completion of filenames within open-quoted strings. Note that
1445 1466 this requires that in ~/.ipython/ipythonrc, users change the
1446 1467 readline delimiters configuration to read:
1447 1468
1448 1469 readline_remove_delims -/~
1449 1470
1450 1471
1451 1472 2005-05-31 *** Released version 0.6.14
1452 1473
1453 1474 2005-05-29 Fernando Perez <fperez@colorado.edu>
1454 1475
1455 1476 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1456 1477 with files not on the filesystem. Reported by Eliyahu Sandler
1457 1478 <eli@gondolin.net>
1458 1479
1459 1480 2005-05-22 Fernando Perez <fperez@colorado.edu>
1460 1481
1461 1482 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1462 1483 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1463 1484
1464 1485 2005-05-19 Fernando Perez <fperez@colorado.edu>
1465 1486
1466 1487 * IPython/iplib.py (safe_execfile): close a file which could be
1467 1488 left open (causing problems in win32, which locks open files).
1468 1489 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1469 1490
1470 1491 2005-05-18 Fernando Perez <fperez@colorado.edu>
1471 1492
1472 1493 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1473 1494 keyword arguments correctly to safe_execfile().
1474 1495
1475 1496 2005-05-13 Fernando Perez <fperez@colorado.edu>
1476 1497
1477 1498 * ipython.1: Added info about Qt to manpage, and threads warning
1478 1499 to usage page (invoked with --help).
1479 1500
1480 1501 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1481 1502 new matcher (it goes at the end of the priority list) to do
1482 1503 tab-completion on named function arguments. Submitted by George
1483 1504 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1484 1505 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1485 1506 for more details.
1486 1507
1487 1508 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1488 1509 SystemExit exceptions in the script being run. Thanks to a report
1489 1510 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1490 1511 producing very annoying behavior when running unit tests.
1491 1512
1492 1513 2005-05-12 Fernando Perez <fperez@colorado.edu>
1493 1514
1494 1515 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1495 1516 which I'd broken (again) due to a changed regexp. In the process,
1496 1517 added ';' as an escape to auto-quote the whole line without
1497 1518 splitting its arguments. Thanks to a report by Jerry McRae
1498 1519 <qrs0xyc02-AT-sneakemail.com>.
1499 1520
1500 1521 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1501 1522 possible crashes caused by a TokenError. Reported by Ed Schofield
1502 1523 <schofield-AT-ftw.at>.
1503 1524
1504 1525 2005-05-06 Fernando Perez <fperez@colorado.edu>
1505 1526
1506 1527 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1507 1528
1508 1529 2005-04-29 Fernando Perez <fperez@colorado.edu>
1509 1530
1510 1531 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
1511 1532 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
1512 1533 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1513 1534 which provides support for Qt interactive usage (similar to the
1514 1535 existing one for WX and GTK). This had been often requested.
1515 1536
1516 1537 2005-04-14 *** Released version 0.6.13
1517 1538
1518 1539 2005-04-08 Fernando Perez <fperez@colorado.edu>
1519 1540
1520 1541 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1521 1542 from _ofind, which gets called on almost every input line. Now,
1522 1543 we only try to get docstrings if they are actually going to be
1523 1544 used (the overhead of fetching unnecessary docstrings can be
1524 1545 noticeable for certain objects, such as Pyro proxies).
1525 1546
1526 1547 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1527 1548 for completers. For some reason I had been passing them the state
1528 1549 variable, which completers never actually need, and was in
1529 1550 conflict with the rlcompleter API. Custom completers ONLY need to
1530 1551 take the text parameter.
1531 1552
1532 1553 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1533 1554 work correctly in pysh. I've also moved all the logic which used
1534 1555 to be in pysh.py here, which will prevent problems with future
1535 1556 upgrades. However, this time I must warn users to update their
1536 1557 pysh profile to include the line
1537 1558
1538 1559 import_all IPython.Extensions.InterpreterExec
1539 1560
1540 1561 because otherwise things won't work for them. They MUST also
1541 1562 delete pysh.py and the line
1542 1563
1543 1564 execfile pysh.py
1544 1565
1545 1566 from their ipythonrc-pysh.
1546 1567
1547 1568 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1548 1569 robust in the face of objects whose dir() returns non-strings
1549 1570 (which it shouldn't, but some broken libs like ITK do). Thanks to
1550 1571 a patch by John Hunter (implemented differently, though). Also
1551 1572 minor improvements by using .extend instead of + on lists.
1552 1573
1553 1574 * pysh.py:
1554 1575
1555 1576 2005-04-06 Fernando Perez <fperez@colorado.edu>
1556 1577
1557 1578 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1558 1579 by default, so that all users benefit from it. Those who don't
1559 1580 want it can still turn it off.
1560 1581
1561 1582 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1562 1583 config file, I'd forgotten about this, so users were getting it
1563 1584 off by default.
1564 1585
1565 1586 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1566 1587 consistency. Now magics can be called in multiline statements,
1567 1588 and python variables can be expanded in magic calls via $var.
1568 1589 This makes the magic system behave just like aliases or !system
1569 1590 calls.
1570 1591
1571 1592 2005-03-28 Fernando Perez <fperez@colorado.edu>
1572 1593
1573 1594 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1574 1595 expensive string additions for building command. Add support for
1575 1596 trailing ';' when autocall is used.
1576 1597
1577 1598 2005-03-26 Fernando Perez <fperez@colorado.edu>
1578 1599
1579 1600 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1580 1601 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1581 1602 ipython.el robust against prompts with any number of spaces
1582 1603 (including 0) after the ':' character.
1583 1604
1584 1605 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1585 1606 continuation prompt, which misled users to think the line was
1586 1607 already indented. Closes debian Bug#300847, reported to me by
1587 1608 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1588 1609
1589 1610 2005-03-23 Fernando Perez <fperez@colorado.edu>
1590 1611
1591 1612 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1592 1613 properly aligned if they have embedded newlines.
1593 1614
1594 1615 * IPython/iplib.py (runlines): Add a public method to expose
1595 1616 IPython's code execution machinery, so that users can run strings
1596 1617 as if they had been typed at the prompt interactively.
1597 1618 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1598 1619 methods which can call the system shell, but with python variable
1599 1620 expansion. The three such methods are: __IPYTHON__.system,
1600 1621 .getoutput and .getoutputerror. These need to be documented in a
1601 1622 'public API' section (to be written) of the manual.
1602 1623
1603 1624 2005-03-20 Fernando Perez <fperez@colorado.edu>
1604 1625
1605 1626 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1606 1627 for custom exception handling. This is quite powerful, and it
1607 1628 allows for user-installable exception handlers which can trap
1608 1629 custom exceptions at runtime and treat them separately from
1609 1630 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1610 1631 Mantegazza <mantegazza-AT-ill.fr>.
1611 1632 (InteractiveShell.set_custom_completer): public API function to
1612 1633 add new completers at runtime.
1613 1634
1614 1635 2005-03-19 Fernando Perez <fperez@colorado.edu>
1615 1636
1616 1637 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1617 1638 allow objects which provide their docstrings via non-standard
1618 1639 mechanisms (like Pyro proxies) to still be inspected by ipython's
1619 1640 ? system.
1620 1641
1621 1642 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1622 1643 automatic capture system. I tried quite hard to make it work
1623 1644 reliably, and simply failed. I tried many combinations with the
1624 1645 subprocess module, but eventually nothing worked in all needed
1625 1646 cases (not blocking stdin for the child, duplicating stdout
1626 1647 without blocking, etc). The new %sc/%sx still do capture to these
1627 1648 magical list/string objects which make shell use much more
1628 1649 conveninent, so not all is lost.
1629 1650
1630 1651 XXX - FIX MANUAL for the change above!
1631 1652
1632 1653 (runsource): I copied code.py's runsource() into ipython to modify
1633 1654 it a bit. Now the code object and source to be executed are
1634 1655 stored in ipython. This makes this info accessible to third-party
1635 1656 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1636 1657 Mantegazza <mantegazza-AT-ill.fr>.
1637 1658
1638 1659 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1639 1660 history-search via readline (like C-p/C-n). I'd wanted this for a
1640 1661 long time, but only recently found out how to do it. For users
1641 1662 who already have their ipythonrc files made and want this, just
1642 1663 add:
1643 1664
1644 1665 readline_parse_and_bind "\e[A": history-search-backward
1645 1666 readline_parse_and_bind "\e[B": history-search-forward
1646 1667
1647 1668 2005-03-18 Fernando Perez <fperez@colorado.edu>
1648 1669
1649 1670 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1650 1671 LSString and SList classes which allow transparent conversions
1651 1672 between list mode and whitespace-separated string.
1652 1673 (magic_r): Fix recursion problem in %r.
1653 1674
1654 1675 * IPython/genutils.py (LSString): New class to be used for
1655 1676 automatic storage of the results of all alias/system calls in _o
1656 1677 and _e (stdout/err). These provide a .l/.list attribute which
1657 1678 does automatic splitting on newlines. This means that for most
1658 1679 uses, you'll never need to do capturing of output with %sc/%sx
1659 1680 anymore, since ipython keeps this always done for you. Note that
1660 1681 only the LAST results are stored, the _o/e variables are
1661 1682 overwritten on each call. If you need to save their contents
1662 1683 further, simply bind them to any other name.
1663 1684
1664 1685 2005-03-17 Fernando Perez <fperez@colorado.edu>
1665 1686
1666 1687 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1667 1688 prompt namespace handling.
1668 1689
1669 1690 2005-03-16 Fernando Perez <fperez@colorado.edu>
1670 1691
1671 1692 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1672 1693 classic prompts to be '>>> ' (final space was missing, and it
1673 1694 trips the emacs python mode).
1674 1695 (BasePrompt.__str__): Added safe support for dynamic prompt
1675 1696 strings. Now you can set your prompt string to be '$x', and the
1676 1697 value of x will be printed from your interactive namespace. The
1677 1698 interpolation syntax includes the full Itpl support, so
1678 1699 ${foo()+x+bar()} is a valid prompt string now, and the function
1679 1700 calls will be made at runtime.
1680 1701
1681 1702 2005-03-15 Fernando Perez <fperez@colorado.edu>
1682 1703
1683 1704 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1684 1705 avoid name clashes in pylab. %hist still works, it just forwards
1685 1706 the call to %history.
1686 1707
1687 1708 2005-03-02 *** Released version 0.6.12
1688 1709
1689 1710 2005-03-02 Fernando Perez <fperez@colorado.edu>
1690 1711
1691 1712 * IPython/iplib.py (handle_magic): log magic calls properly as
1692 1713 ipmagic() function calls.
1693 1714
1694 1715 * IPython/Magic.py (magic_time): Improved %time to support
1695 1716 statements and provide wall-clock as well as CPU time.
1696 1717
1697 1718 2005-02-27 Fernando Perez <fperez@colorado.edu>
1698 1719
1699 1720 * IPython/hooks.py: New hooks module, to expose user-modifiable
1700 1721 IPython functionality in a clean manner. For now only the editor
1701 1722 hook is actually written, and other thigns which I intend to turn
1702 1723 into proper hooks aren't yet there. The display and prefilter
1703 1724 stuff, for example, should be hooks. But at least now the
1704 1725 framework is in place, and the rest can be moved here with more
1705 1726 time later. IPython had had a .hooks variable for a long time for
1706 1727 this purpose, but I'd never actually used it for anything.
1707 1728
1708 1729 2005-02-26 Fernando Perez <fperez@colorado.edu>
1709 1730
1710 1731 * IPython/ipmaker.py (make_IPython): make the default ipython
1711 1732 directory be called _ipython under win32, to follow more the
1712 1733 naming peculiarities of that platform (where buggy software like
1713 1734 Visual Sourcesafe breaks with .named directories). Reported by
1714 1735 Ville Vainio.
1715 1736
1716 1737 2005-02-23 Fernando Perez <fperez@colorado.edu>
1717 1738
1718 1739 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1719 1740 auto_aliases for win32 which were causing problems. Users can
1720 1741 define the ones they personally like.
1721 1742
1722 1743 2005-02-21 Fernando Perez <fperez@colorado.edu>
1723 1744
1724 1745 * IPython/Magic.py (magic_time): new magic to time execution of
1725 1746 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1726 1747
1727 1748 2005-02-19 Fernando Perez <fperez@colorado.edu>
1728 1749
1729 1750 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1730 1751 into keys (for prompts, for example).
1731 1752
1732 1753 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1733 1754 prompts in case users want them. This introduces a small behavior
1734 1755 change: ipython does not automatically add a space to all prompts
1735 1756 anymore. To get the old prompts with a space, users should add it
1736 1757 manually to their ipythonrc file, so for example prompt_in1 should
1737 1758 now read 'In [\#]: ' instead of 'In [\#]:'.
1738 1759 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1739 1760 file) to control left-padding of secondary prompts.
1740 1761
1741 1762 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1742 1763 the profiler can't be imported. Fix for Debian, which removed
1743 1764 profile.py because of License issues. I applied a slightly
1744 1765 modified version of the original Debian patch at
1745 1766 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1746 1767
1747 1768 2005-02-17 Fernando Perez <fperez@colorado.edu>
1748 1769
1749 1770 * IPython/genutils.py (native_line_ends): Fix bug which would
1750 1771 cause improper line-ends under win32 b/c I was not opening files
1751 1772 in binary mode. Bug report and fix thanks to Ville.
1752 1773
1753 1774 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1754 1775 trying to catch spurious foo[1] autocalls. My fix actually broke
1755 1776 ',/' autoquote/call with explicit escape (bad regexp).
1756 1777
1757 1778 2005-02-15 *** Released version 0.6.11
1758 1779
1759 1780 2005-02-14 Fernando Perez <fperez@colorado.edu>
1760 1781
1761 1782 * IPython/background_jobs.py: New background job management
1762 1783 subsystem. This is implemented via a new set of classes, and
1763 1784 IPython now provides a builtin 'jobs' object for background job
1764 1785 execution. A convenience %bg magic serves as a lightweight
1765 1786 frontend for starting the more common type of calls. This was
1766 1787 inspired by discussions with B. Granger and the BackgroundCommand
1767 1788 class described in the book Python Scripting for Computational
1768 1789 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1769 1790 (although ultimately no code from this text was used, as IPython's
1770 1791 system is a separate implementation).
1771 1792
1772 1793 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1773 1794 to control the completion of single/double underscore names
1774 1795 separately. As documented in the example ipytonrc file, the
1775 1796 readline_omit__names variable can now be set to 2, to omit even
1776 1797 single underscore names. Thanks to a patch by Brian Wong
1777 1798 <BrianWong-AT-AirgoNetworks.Com>.
1778 1799 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1779 1800 be autocalled as foo([1]) if foo were callable. A problem for
1780 1801 things which are both callable and implement __getitem__.
1781 1802 (init_readline): Fix autoindentation for win32. Thanks to a patch
1782 1803 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1783 1804
1784 1805 2005-02-12 Fernando Perez <fperez@colorado.edu>
1785 1806
1786 1807 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1787 1808 which I had written long ago to sort out user error messages which
1788 1809 may occur during startup. This seemed like a good idea initially,
1789 1810 but it has proven a disaster in retrospect. I don't want to
1790 1811 change much code for now, so my fix is to set the internal 'debug'
1791 1812 flag to true everywhere, whose only job was precisely to control
1792 1813 this subsystem. This closes issue 28 (as well as avoiding all
1793 1814 sorts of strange hangups which occur from time to time).
1794 1815
1795 1816 2005-02-07 Fernando Perez <fperez@colorado.edu>
1796 1817
1797 1818 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1798 1819 previous call produced a syntax error.
1799 1820
1800 1821 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1801 1822 classes without constructor.
1802 1823
1803 1824 2005-02-06 Fernando Perez <fperez@colorado.edu>
1804 1825
1805 1826 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1806 1827 completions with the results of each matcher, so we return results
1807 1828 to the user from all namespaces. This breaks with ipython
1808 1829 tradition, but I think it's a nicer behavior. Now you get all
1809 1830 possible completions listed, from all possible namespaces (python,
1810 1831 filesystem, magics...) After a request by John Hunter
1811 1832 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1812 1833
1813 1834 2005-02-05 Fernando Perez <fperez@colorado.edu>
1814 1835
1815 1836 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1816 1837 the call had quote characters in it (the quotes were stripped).
1817 1838
1818 1839 2005-01-31 Fernando Perez <fperez@colorado.edu>
1819 1840
1820 1841 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1821 1842 Itpl.itpl() to make the code more robust against psyco
1822 1843 optimizations.
1823 1844
1824 1845 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1825 1846 of causing an exception. Quicker, cleaner.
1826 1847
1827 1848 2005-01-28 Fernando Perez <fperez@colorado.edu>
1828 1849
1829 1850 * scripts/ipython_win_post_install.py (install): hardcode
1830 1851 sys.prefix+'python.exe' as the executable path. It turns out that
1831 1852 during the post-installation run, sys.executable resolves to the
1832 1853 name of the binary installer! I should report this as a distutils
1833 1854 bug, I think. I updated the .10 release with this tiny fix, to
1834 1855 avoid annoying the lists further.
1835 1856
1836 1857 2005-01-27 *** Released version 0.6.10
1837 1858
1838 1859 2005-01-27 Fernando Perez <fperez@colorado.edu>
1839 1860
1840 1861 * IPython/numutils.py (norm): Added 'inf' as optional name for
1841 1862 L-infinity norm, included references to mathworld.com for vector
1842 1863 norm definitions.
1843 1864 (amin/amax): added amin/amax for array min/max. Similar to what
1844 1865 pylab ships with after the recent reorganization of names.
1845 1866 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1846 1867
1847 1868 * ipython.el: committed Alex's recent fixes and improvements.
1848 1869 Tested with python-mode from CVS, and it looks excellent. Since
1849 1870 python-mode hasn't released anything in a while, I'm temporarily
1850 1871 putting a copy of today's CVS (v 4.70) of python-mode in:
1851 1872 http://ipython.scipy.org/tmp/python-mode.el
1852 1873
1853 1874 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1854 1875 sys.executable for the executable name, instead of assuming it's
1855 1876 called 'python.exe' (the post-installer would have produced broken
1856 1877 setups on systems with a differently named python binary).
1857 1878
1858 1879 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1859 1880 references to os.linesep, to make the code more
1860 1881 platform-independent. This is also part of the win32 coloring
1861 1882 fixes.
1862 1883
1863 1884 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1864 1885 lines, which actually cause coloring bugs because the length of
1865 1886 the line is very difficult to correctly compute with embedded
1866 1887 escapes. This was the source of all the coloring problems under
1867 1888 Win32. I think that _finally_, Win32 users have a properly
1868 1889 working ipython in all respects. This would never have happened
1869 1890 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1870 1891
1871 1892 2005-01-26 *** Released version 0.6.9
1872 1893
1873 1894 2005-01-25 Fernando Perez <fperez@colorado.edu>
1874 1895
1875 1896 * setup.py: finally, we have a true Windows installer, thanks to
1876 1897 the excellent work of Viktor Ransmayr
1877 1898 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1878 1899 Windows users. The setup routine is quite a bit cleaner thanks to
1879 1900 this, and the post-install script uses the proper functions to
1880 1901 allow a clean de-installation using the standard Windows Control
1881 1902 Panel.
1882 1903
1883 1904 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1884 1905 environment variable under all OSes (including win32) if
1885 1906 available. This will give consistency to win32 users who have set
1886 1907 this variable for any reason. If os.environ['HOME'] fails, the
1887 1908 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1888 1909
1889 1910 2005-01-24 Fernando Perez <fperez@colorado.edu>
1890 1911
1891 1912 * IPython/numutils.py (empty_like): add empty_like(), similar to
1892 1913 zeros_like() but taking advantage of the new empty() Numeric routine.
1893 1914
1894 1915 2005-01-23 *** Released version 0.6.8
1895 1916
1896 1917 2005-01-22 Fernando Perez <fperez@colorado.edu>
1897 1918
1898 1919 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1899 1920 automatic show() calls. After discussing things with JDH, it
1900 1921 turns out there are too many corner cases where this can go wrong.
1901 1922 It's best not to try to be 'too smart', and simply have ipython
1902 1923 reproduce as much as possible the default behavior of a normal
1903 1924 python shell.
1904 1925
1905 1926 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1906 1927 line-splitting regexp and _prefilter() to avoid calling getattr()
1907 1928 on assignments. This closes
1908 1929 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1909 1930 readline uses getattr(), so a simple <TAB> keypress is still
1910 1931 enough to trigger getattr() calls on an object.
1911 1932
1912 1933 2005-01-21 Fernando Perez <fperez@colorado.edu>
1913 1934
1914 1935 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1915 1936 docstring under pylab so it doesn't mask the original.
1916 1937
1917 1938 2005-01-21 *** Released version 0.6.7
1918 1939
1919 1940 2005-01-21 Fernando Perez <fperez@colorado.edu>
1920 1941
1921 1942 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1922 1943 signal handling for win32 users in multithreaded mode.
1923 1944
1924 1945 2005-01-17 Fernando Perez <fperez@colorado.edu>
1925 1946
1926 1947 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1927 1948 instances with no __init__. After a crash report by Norbert Nemec
1928 1949 <Norbert-AT-nemec-online.de>.
1929 1950
1930 1951 2005-01-14 Fernando Perez <fperez@colorado.edu>
1931 1952
1932 1953 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1933 1954 names for verbose exceptions, when multiple dotted names and the
1934 1955 'parent' object were present on the same line.
1935 1956
1936 1957 2005-01-11 Fernando Perez <fperez@colorado.edu>
1937 1958
1938 1959 * IPython/genutils.py (flag_calls): new utility to trap and flag
1939 1960 calls in functions. I need it to clean up matplotlib support.
1940 1961 Also removed some deprecated code in genutils.
1941 1962
1942 1963 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1943 1964 that matplotlib scripts called with %run, which don't call show()
1944 1965 themselves, still have their plotting windows open.
1945 1966
1946 1967 2005-01-05 Fernando Perez <fperez@colorado.edu>
1947 1968
1948 1969 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1949 1970 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1950 1971
1951 1972 2004-12-19 Fernando Perez <fperez@colorado.edu>
1952 1973
1953 1974 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1954 1975 parent_runcode, which was an eyesore. The same result can be
1955 1976 obtained with Python's regular superclass mechanisms.
1956 1977
1957 1978 2004-12-17 Fernando Perez <fperez@colorado.edu>
1958 1979
1959 1980 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1960 1981 reported by Prabhu.
1961 1982 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1962 1983 sys.stderr) instead of explicitly calling sys.stderr. This helps
1963 1984 maintain our I/O abstractions clean, for future GUI embeddings.
1964 1985
1965 1986 * IPython/genutils.py (info): added new utility for sys.stderr
1966 1987 unified info message handling (thin wrapper around warn()).
1967 1988
1968 1989 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1969 1990 composite (dotted) names on verbose exceptions.
1970 1991 (VerboseTB.nullrepr): harden against another kind of errors which
1971 1992 Python's inspect module can trigger, and which were crashing
1972 1993 IPython. Thanks to a report by Marco Lombardi
1973 1994 <mlombard-AT-ma010192.hq.eso.org>.
1974 1995
1975 1996 2004-12-13 *** Released version 0.6.6
1976 1997
1977 1998 2004-12-12 Fernando Perez <fperez@colorado.edu>
1978 1999
1979 2000 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1980 2001 generated by pygtk upon initialization if it was built without
1981 2002 threads (for matplotlib users). After a crash reported by
1982 2003 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1983 2004
1984 2005 * IPython/ipmaker.py (make_IPython): fix small bug in the
1985 2006 import_some parameter for multiple imports.
1986 2007
1987 2008 * IPython/iplib.py (ipmagic): simplified the interface of
1988 2009 ipmagic() to take a single string argument, just as it would be
1989 2010 typed at the IPython cmd line.
1990 2011 (ipalias): Added new ipalias() with an interface identical to
1991 2012 ipmagic(). This completes exposing a pure python interface to the
1992 2013 alias and magic system, which can be used in loops or more complex
1993 2014 code where IPython's automatic line mangling is not active.
1994 2015
1995 2016 * IPython/genutils.py (timing): changed interface of timing to
1996 2017 simply run code once, which is the most common case. timings()
1997 2018 remains unchanged, for the cases where you want multiple runs.
1998 2019
1999 2020 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2000 2021 bug where Python2.2 crashes with exec'ing code which does not end
2001 2022 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2002 2023 before.
2003 2024
2004 2025 2004-12-10 Fernando Perez <fperez@colorado.edu>
2005 2026
2006 2027 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2007 2028 -t to -T, to accomodate the new -t flag in %run (the %run and
2008 2029 %prun options are kind of intermixed, and it's not easy to change
2009 2030 this with the limitations of python's getopt).
2010 2031
2011 2032 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2012 2033 the execution of scripts. It's not as fine-tuned as timeit.py,
2013 2034 but it works from inside ipython (and under 2.2, which lacks
2014 2035 timeit.py). Optionally a number of runs > 1 can be given for
2015 2036 timing very short-running code.
2016 2037
2017 2038 * IPython/genutils.py (uniq_stable): new routine which returns a
2018 2039 list of unique elements in any iterable, but in stable order of
2019 2040 appearance. I needed this for the ultraTB fixes, and it's a handy
2020 2041 utility.
2021 2042
2022 2043 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2023 2044 dotted names in Verbose exceptions. This had been broken since
2024 2045 the very start, now x.y will properly be printed in a Verbose
2025 2046 traceback, instead of x being shown and y appearing always as an
2026 2047 'undefined global'. Getting this to work was a bit tricky,
2027 2048 because by default python tokenizers are stateless. Saved by
2028 2049 python's ability to easily add a bit of state to an arbitrary
2029 2050 function (without needing to build a full-blown callable object).
2030 2051
2031 2052 Also big cleanup of this code, which had horrendous runtime
2032 2053 lookups of zillions of attributes for colorization. Moved all
2033 2054 this code into a few templates, which make it cleaner and quicker.
2034 2055
2035 2056 Printout quality was also improved for Verbose exceptions: one
2036 2057 variable per line, and memory addresses are printed (this can be
2037 2058 quite handy in nasty debugging situations, which is what Verbose
2038 2059 is for).
2039 2060
2040 2061 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2041 2062 the command line as scripts to be loaded by embedded instances.
2042 2063 Doing so has the potential for an infinite recursion if there are
2043 2064 exceptions thrown in the process. This fixes a strange crash
2044 2065 reported by Philippe MULLER <muller-AT-irit.fr>.
2045 2066
2046 2067 2004-12-09 Fernando Perez <fperez@colorado.edu>
2047 2068
2048 2069 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2049 2070 to reflect new names in matplotlib, which now expose the
2050 2071 matlab-compatible interface via a pylab module instead of the
2051 2072 'matlab' name. The new code is backwards compatible, so users of
2052 2073 all matplotlib versions are OK. Patch by J. Hunter.
2053 2074
2054 2075 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2055 2076 of __init__ docstrings for instances (class docstrings are already
2056 2077 automatically printed). Instances with customized docstrings
2057 2078 (indep. of the class) are also recognized and all 3 separate
2058 2079 docstrings are printed (instance, class, constructor). After some
2059 2080 comments/suggestions by J. Hunter.
2060 2081
2061 2082 2004-12-05 Fernando Perez <fperez@colorado.edu>
2062 2083
2063 2084 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2064 2085 warnings when tab-completion fails and triggers an exception.
2065 2086
2066 2087 2004-12-03 Fernando Perez <fperez@colorado.edu>
2067 2088
2068 2089 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2069 2090 be triggered when using 'run -p'. An incorrect option flag was
2070 2091 being set ('d' instead of 'D').
2071 2092 (manpage): fix missing escaped \- sign.
2072 2093
2073 2094 2004-11-30 *** Released version 0.6.5
2074 2095
2075 2096 2004-11-30 Fernando Perez <fperez@colorado.edu>
2076 2097
2077 2098 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2078 2099 setting with -d option.
2079 2100
2080 2101 * setup.py (docfiles): Fix problem where the doc glob I was using
2081 2102 was COMPLETELY BROKEN. It was giving the right files by pure
2082 2103 accident, but failed once I tried to include ipython.el. Note:
2083 2104 glob() does NOT allow you to do exclusion on multiple endings!
2084 2105
2085 2106 2004-11-29 Fernando Perez <fperez@colorado.edu>
2086 2107
2087 2108 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2088 2109 the manpage as the source. Better formatting & consistency.
2089 2110
2090 2111 * IPython/Magic.py (magic_run): Added new -d option, to run
2091 2112 scripts under the control of the python pdb debugger. Note that
2092 2113 this required changing the %prun option -d to -D, to avoid a clash
2093 2114 (since %run must pass options to %prun, and getopt is too dumb to
2094 2115 handle options with string values with embedded spaces). Thanks
2095 2116 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2096 2117 (magic_who_ls): added type matching to %who and %whos, so that one
2097 2118 can filter their output to only include variables of certain
2098 2119 types. Another suggestion by Matthew.
2099 2120 (magic_whos): Added memory summaries in kb and Mb for arrays.
2100 2121 (magic_who): Improve formatting (break lines every 9 vars).
2101 2122
2102 2123 2004-11-28 Fernando Perez <fperez@colorado.edu>
2103 2124
2104 2125 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2105 2126 cache when empty lines were present.
2106 2127
2107 2128 2004-11-24 Fernando Perez <fperez@colorado.edu>
2108 2129
2109 2130 * IPython/usage.py (__doc__): document the re-activated threading
2110 2131 options for WX and GTK.
2111 2132
2112 2133 2004-11-23 Fernando Perez <fperez@colorado.edu>
2113 2134
2114 2135 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2115 2136 the -wthread and -gthread options, along with a new -tk one to try
2116 2137 and coordinate Tk threading with wx/gtk. The tk support is very
2117 2138 platform dependent, since it seems to require Tcl and Tk to be
2118 2139 built with threads (Fedora1/2 appears NOT to have it, but in
2119 2140 Prabhu's Debian boxes it works OK). But even with some Tk
2120 2141 limitations, this is a great improvement.
2121 2142
2122 2143 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2123 2144 info in user prompts. Patch by Prabhu.
2124 2145
2125 2146 2004-11-18 Fernando Perez <fperez@colorado.edu>
2126 2147
2127 2148 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2128 2149 EOFErrors and bail, to avoid infinite loops if a non-terminating
2129 2150 file is fed into ipython. Patch submitted in issue 19 by user,
2130 2151 many thanks.
2131 2152
2132 2153 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2133 2154 autoquote/parens in continuation prompts, which can cause lots of
2134 2155 problems. Closes roundup issue 20.
2135 2156
2136 2157 2004-11-17 Fernando Perez <fperez@colorado.edu>
2137 2158
2138 2159 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2139 2160 reported as debian bug #280505. I'm not sure my local changelog
2140 2161 entry has the proper debian format (Jack?).
2141 2162
2142 2163 2004-11-08 *** Released version 0.6.4
2143 2164
2144 2165 2004-11-08 Fernando Perez <fperez@colorado.edu>
2145 2166
2146 2167 * IPython/iplib.py (init_readline): Fix exit message for Windows
2147 2168 when readline is active. Thanks to a report by Eric Jones
2148 2169 <eric-AT-enthought.com>.
2149 2170
2150 2171 2004-11-07 Fernando Perez <fperez@colorado.edu>
2151 2172
2152 2173 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2153 2174 sometimes seen by win2k/cygwin users.
2154 2175
2155 2176 2004-11-06 Fernando Perez <fperez@colorado.edu>
2156 2177
2157 2178 * IPython/iplib.py (interact): Change the handling of %Exit from
2158 2179 trying to propagate a SystemExit to an internal ipython flag.
2159 2180 This is less elegant than using Python's exception mechanism, but
2160 2181 I can't get that to work reliably with threads, so under -pylab
2161 2182 %Exit was hanging IPython. Cross-thread exception handling is
2162 2183 really a bitch. Thaks to a bug report by Stephen Walton
2163 2184 <stephen.walton-AT-csun.edu>.
2164 2185
2165 2186 2004-11-04 Fernando Perez <fperez@colorado.edu>
2166 2187
2167 2188 * IPython/iplib.py (raw_input_original): store a pointer to the
2168 2189 true raw_input to harden against code which can modify it
2169 2190 (wx.py.PyShell does this and would otherwise crash ipython).
2170 2191 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2171 2192
2172 2193 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2173 2194 Ctrl-C problem, which does not mess up the input line.
2174 2195
2175 2196 2004-11-03 Fernando Perez <fperez@colorado.edu>
2176 2197
2177 2198 * IPython/Release.py: Changed licensing to BSD, in all files.
2178 2199 (name): lowercase name for tarball/RPM release.
2179 2200
2180 2201 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2181 2202 use throughout ipython.
2182 2203
2183 2204 * IPython/Magic.py (Magic._ofind): Switch to using the new
2184 2205 OInspect.getdoc() function.
2185 2206
2186 2207 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2187 2208 of the line currently being canceled via Ctrl-C. It's extremely
2188 2209 ugly, but I don't know how to do it better (the problem is one of
2189 2210 handling cross-thread exceptions).
2190 2211
2191 2212 2004-10-28 Fernando Perez <fperez@colorado.edu>
2192 2213
2193 2214 * IPython/Shell.py (signal_handler): add signal handlers to trap
2194 2215 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2195 2216 report by Francesc Alted.
2196 2217
2197 2218 2004-10-21 Fernando Perez <fperez@colorado.edu>
2198 2219
2199 2220 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2200 2221 to % for pysh syntax extensions.
2201 2222
2202 2223 2004-10-09 Fernando Perez <fperez@colorado.edu>
2203 2224
2204 2225 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2205 2226 arrays to print a more useful summary, without calling str(arr).
2206 2227 This avoids the problem of extremely lengthy computations which
2207 2228 occur if arr is large, and appear to the user as a system lockup
2208 2229 with 100% cpu activity. After a suggestion by Kristian Sandberg
2209 2230 <Kristian.Sandberg@colorado.edu>.
2210 2231 (Magic.__init__): fix bug in global magic escapes not being
2211 2232 correctly set.
2212 2233
2213 2234 2004-10-08 Fernando Perez <fperez@colorado.edu>
2214 2235
2215 2236 * IPython/Magic.py (__license__): change to absolute imports of
2216 2237 ipython's own internal packages, to start adapting to the absolute
2217 2238 import requirement of PEP-328.
2218 2239
2219 2240 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2220 2241 files, and standardize author/license marks through the Release
2221 2242 module instead of having per/file stuff (except for files with
2222 2243 particular licenses, like the MIT/PSF-licensed codes).
2223 2244
2224 2245 * IPython/Debugger.py: remove dead code for python 2.1
2225 2246
2226 2247 2004-10-04 Fernando Perez <fperez@colorado.edu>
2227 2248
2228 2249 * IPython/iplib.py (ipmagic): New function for accessing magics
2229 2250 via a normal python function call.
2230 2251
2231 2252 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2232 2253 from '@' to '%', to accomodate the new @decorator syntax of python
2233 2254 2.4.
2234 2255
2235 2256 2004-09-29 Fernando Perez <fperez@colorado.edu>
2236 2257
2237 2258 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2238 2259 matplotlib.use to prevent running scripts which try to switch
2239 2260 interactive backends from within ipython. This will just crash
2240 2261 the python interpreter, so we can't allow it (but a detailed error
2241 2262 is given to the user).
2242 2263
2243 2264 2004-09-28 Fernando Perez <fperez@colorado.edu>
2244 2265
2245 2266 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2246 2267 matplotlib-related fixes so that using @run with non-matplotlib
2247 2268 scripts doesn't pop up spurious plot windows. This requires
2248 2269 matplotlib >= 0.63, where I had to make some changes as well.
2249 2270
2250 2271 * IPython/ipmaker.py (make_IPython): update version requirement to
2251 2272 python 2.2.
2252 2273
2253 2274 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2254 2275 banner arg for embedded customization.
2255 2276
2256 2277 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2257 2278 explicit uses of __IP as the IPython's instance name. Now things
2258 2279 are properly handled via the shell.name value. The actual code
2259 2280 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2260 2281 is much better than before. I'll clean things completely when the
2261 2282 magic stuff gets a real overhaul.
2262 2283
2263 2284 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2264 2285 minor changes to debian dir.
2265 2286
2266 2287 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2267 2288 pointer to the shell itself in the interactive namespace even when
2268 2289 a user-supplied dict is provided. This is needed for embedding
2269 2290 purposes (found by tests with Michel Sanner).
2270 2291
2271 2292 2004-09-27 Fernando Perez <fperez@colorado.edu>
2272 2293
2273 2294 * IPython/UserConfig/ipythonrc: remove []{} from
2274 2295 readline_remove_delims, so that things like [modname.<TAB> do
2275 2296 proper completion. This disables [].TAB, but that's a less common
2276 2297 case than module names in list comprehensions, for example.
2277 2298 Thanks to a report by Andrea Riciputi.
2278 2299
2279 2300 2004-09-09 Fernando Perez <fperez@colorado.edu>
2280 2301
2281 2302 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2282 2303 blocking problems in win32 and osx. Fix by John.
2283 2304
2284 2305 2004-09-08 Fernando Perez <fperez@colorado.edu>
2285 2306
2286 2307 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2287 2308 for Win32 and OSX. Fix by John Hunter.
2288 2309
2289 2310 2004-08-30 *** Released version 0.6.3
2290 2311
2291 2312 2004-08-30 Fernando Perez <fperez@colorado.edu>
2292 2313
2293 2314 * setup.py (isfile): Add manpages to list of dependent files to be
2294 2315 updated.
2295 2316
2296 2317 2004-08-27 Fernando Perez <fperez@colorado.edu>
2297 2318
2298 2319 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2299 2320 for now. They don't really work with standalone WX/GTK code
2300 2321 (though matplotlib IS working fine with both of those backends).
2301 2322 This will neeed much more testing. I disabled most things with
2302 2323 comments, so turning it back on later should be pretty easy.
2303 2324
2304 2325 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2305 2326 autocalling of expressions like r'foo', by modifying the line
2306 2327 split regexp. Closes
2307 2328 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2308 2329 Riley <ipythonbugs-AT-sabi.net>.
2309 2330 (InteractiveShell.mainloop): honor --nobanner with banner
2310 2331 extensions.
2311 2332
2312 2333 * IPython/Shell.py: Significant refactoring of all classes, so
2313 2334 that we can really support ALL matplotlib backends and threading
2314 2335 models (John spotted a bug with Tk which required this). Now we
2315 2336 should support single-threaded, WX-threads and GTK-threads, both
2316 2337 for generic code and for matplotlib.
2317 2338
2318 2339 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2319 2340 -pylab, to simplify things for users. Will also remove the pylab
2320 2341 profile, since now all of matplotlib configuration is directly
2321 2342 handled here. This also reduces startup time.
2322 2343
2323 2344 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2324 2345 shell wasn't being correctly called. Also in IPShellWX.
2325 2346
2326 2347 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2327 2348 fine-tune banner.
2328 2349
2329 2350 * IPython/numutils.py (spike): Deprecate these spike functions,
2330 2351 delete (long deprecated) gnuplot_exec handler.
2331 2352
2332 2353 2004-08-26 Fernando Perez <fperez@colorado.edu>
2333 2354
2334 2355 * ipython.1: Update for threading options, plus some others which
2335 2356 were missing.
2336 2357
2337 2358 * IPython/ipmaker.py (__call__): Added -wthread option for
2338 2359 wxpython thread handling. Make sure threading options are only
2339 2360 valid at the command line.
2340 2361
2341 2362 * scripts/ipython: moved shell selection into a factory function
2342 2363 in Shell.py, to keep the starter script to a minimum.
2343 2364
2344 2365 2004-08-25 Fernando Perez <fperez@colorado.edu>
2345 2366
2346 2367 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2347 2368 John. Along with some recent changes he made to matplotlib, the
2348 2369 next versions of both systems should work very well together.
2349 2370
2350 2371 2004-08-24 Fernando Perez <fperez@colorado.edu>
2351 2372
2352 2373 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2353 2374 tried to switch the profiling to using hotshot, but I'm getting
2354 2375 strange errors from prof.runctx() there. I may be misreading the
2355 2376 docs, but it looks weird. For now the profiling code will
2356 2377 continue to use the standard profiler.
2357 2378
2358 2379 2004-08-23 Fernando Perez <fperez@colorado.edu>
2359 2380
2360 2381 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2361 2382 threaded shell, by John Hunter. It's not quite ready yet, but
2362 2383 close.
2363 2384
2364 2385 2004-08-22 Fernando Perez <fperez@colorado.edu>
2365 2386
2366 2387 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2367 2388 in Magic and ultraTB.
2368 2389
2369 2390 * ipython.1: document threading options in manpage.
2370 2391
2371 2392 * scripts/ipython: Changed name of -thread option to -gthread,
2372 2393 since this is GTK specific. I want to leave the door open for a
2373 2394 -wthread option for WX, which will most likely be necessary. This
2374 2395 change affects usage and ipmaker as well.
2375 2396
2376 2397 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2377 2398 handle the matplotlib shell issues. Code by John Hunter
2378 2399 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2379 2400 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2380 2401 broken (and disabled for end users) for now, but it puts the
2381 2402 infrastructure in place.
2382 2403
2383 2404 2004-08-21 Fernando Perez <fperez@colorado.edu>
2384 2405
2385 2406 * ipythonrc-pylab: Add matplotlib support.
2386 2407
2387 2408 * matplotlib_config.py: new files for matplotlib support, part of
2388 2409 the pylab profile.
2389 2410
2390 2411 * IPython/usage.py (__doc__): documented the threading options.
2391 2412
2392 2413 2004-08-20 Fernando Perez <fperez@colorado.edu>
2393 2414
2394 2415 * ipython: Modified the main calling routine to handle the -thread
2395 2416 and -mpthread options. This needs to be done as a top-level hack,
2396 2417 because it determines which class to instantiate for IPython
2397 2418 itself.
2398 2419
2399 2420 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2400 2421 classes to support multithreaded GTK operation without blocking,
2401 2422 and matplotlib with all backends. This is a lot of still very
2402 2423 experimental code, and threads are tricky. So it may still have a
2403 2424 few rough edges... This code owes a lot to
2404 2425 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2405 2426 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2406 2427 to John Hunter for all the matplotlib work.
2407 2428
2408 2429 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2409 2430 options for gtk thread and matplotlib support.
2410 2431
2411 2432 2004-08-16 Fernando Perez <fperez@colorado.edu>
2412 2433
2413 2434 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2414 2435 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2415 2436 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2416 2437
2417 2438 2004-08-11 Fernando Perez <fperez@colorado.edu>
2418 2439
2419 2440 * setup.py (isfile): Fix build so documentation gets updated for
2420 2441 rpms (it was only done for .tgz builds).
2421 2442
2422 2443 2004-08-10 Fernando Perez <fperez@colorado.edu>
2423 2444
2424 2445 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2425 2446
2426 2447 * iplib.py : Silence syntax error exceptions in tab-completion.
2427 2448
2428 2449 2004-08-05 Fernando Perez <fperez@colorado.edu>
2429 2450
2430 2451 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2431 2452 'color off' mark for continuation prompts. This was causing long
2432 2453 continuation lines to mis-wrap.
2433 2454
2434 2455 2004-08-01 Fernando Perez <fperez@colorado.edu>
2435 2456
2436 2457 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2437 2458 for building ipython to be a parameter. All this is necessary
2438 2459 right now to have a multithreaded version, but this insane
2439 2460 non-design will be cleaned up soon. For now, it's a hack that
2440 2461 works.
2441 2462
2442 2463 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2443 2464 args in various places. No bugs so far, but it's a dangerous
2444 2465 practice.
2445 2466
2446 2467 2004-07-31 Fernando Perez <fperez@colorado.edu>
2447 2468
2448 2469 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2449 2470 fix completion of files with dots in their names under most
2450 2471 profiles (pysh was OK because the completion order is different).
2451 2472
2452 2473 2004-07-27 Fernando Perez <fperez@colorado.edu>
2453 2474
2454 2475 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2455 2476 keywords manually, b/c the one in keyword.py was removed in python
2456 2477 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2457 2478 This is NOT a bug under python 2.3 and earlier.
2458 2479
2459 2480 2004-07-26 Fernando Perez <fperez@colorado.edu>
2460 2481
2461 2482 * IPython/ultraTB.py (VerboseTB.text): Add another
2462 2483 linecache.checkcache() call to try to prevent inspect.py from
2463 2484 crashing under python 2.3. I think this fixes
2464 2485 http://www.scipy.net/roundup/ipython/issue17.
2465 2486
2466 2487 2004-07-26 *** Released version 0.6.2
2467 2488
2468 2489 2004-07-26 Fernando Perez <fperez@colorado.edu>
2469 2490
2470 2491 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2471 2492 fail for any number.
2472 2493 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2473 2494 empty bookmarks.
2474 2495
2475 2496 2004-07-26 *** Released version 0.6.1
2476 2497
2477 2498 2004-07-26 Fernando Perez <fperez@colorado.edu>
2478 2499
2479 2500 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2480 2501
2481 2502 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2482 2503 escaping '()[]{}' in filenames.
2483 2504
2484 2505 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2485 2506 Python 2.2 users who lack a proper shlex.split.
2486 2507
2487 2508 2004-07-19 Fernando Perez <fperez@colorado.edu>
2488 2509
2489 2510 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2490 2511 for reading readline's init file. I follow the normal chain:
2491 2512 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2492 2513 report by Mike Heeter. This closes
2493 2514 http://www.scipy.net/roundup/ipython/issue16.
2494 2515
2495 2516 2004-07-18 Fernando Perez <fperez@colorado.edu>
2496 2517
2497 2518 * IPython/iplib.py (__init__): Add better handling of '\' under
2498 2519 Win32 for filenames. After a patch by Ville.
2499 2520
2500 2521 2004-07-17 Fernando Perez <fperez@colorado.edu>
2501 2522
2502 2523 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2503 2524 autocalling would be triggered for 'foo is bar' if foo is
2504 2525 callable. I also cleaned up the autocall detection code to use a
2505 2526 regexp, which is faster. Bug reported by Alexander Schmolck.
2506 2527
2507 2528 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2508 2529 '?' in them would confuse the help system. Reported by Alex
2509 2530 Schmolck.
2510 2531
2511 2532 2004-07-16 Fernando Perez <fperez@colorado.edu>
2512 2533
2513 2534 * IPython/GnuplotInteractive.py (__all__): added plot2.
2514 2535
2515 2536 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2516 2537 plotting dictionaries, lists or tuples of 1d arrays.
2517 2538
2518 2539 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2519 2540 optimizations.
2520 2541
2521 2542 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2522 2543 the information which was there from Janko's original IPP code:
2523 2544
2524 2545 03.05.99 20:53 porto.ifm.uni-kiel.de
2525 2546 --Started changelog.
2526 2547 --make clear do what it say it does
2527 2548 --added pretty output of lines from inputcache
2528 2549 --Made Logger a mixin class, simplifies handling of switches
2529 2550 --Added own completer class. .string<TAB> expands to last history
2530 2551 line which starts with string. The new expansion is also present
2531 2552 with Ctrl-r from the readline library. But this shows, who this
2532 2553 can be done for other cases.
2533 2554 --Added convention that all shell functions should accept a
2534 2555 parameter_string This opens the door for different behaviour for
2535 2556 each function. @cd is a good example of this.
2536 2557
2537 2558 04.05.99 12:12 porto.ifm.uni-kiel.de
2538 2559 --added logfile rotation
2539 2560 --added new mainloop method which freezes first the namespace
2540 2561
2541 2562 07.05.99 21:24 porto.ifm.uni-kiel.de
2542 2563 --added the docreader classes. Now there is a help system.
2543 2564 -This is only a first try. Currently it's not easy to put new
2544 2565 stuff in the indices. But this is the way to go. Info would be
2545 2566 better, but HTML is every where and not everybody has an info
2546 2567 system installed and it's not so easy to change html-docs to info.
2547 2568 --added global logfile option
2548 2569 --there is now a hook for object inspection method pinfo needs to
2549 2570 be provided for this. Can be reached by two '??'.
2550 2571
2551 2572 08.05.99 20:51 porto.ifm.uni-kiel.de
2552 2573 --added a README
2553 2574 --bug in rc file. Something has changed so functions in the rc
2554 2575 file need to reference the shell and not self. Not clear if it's a
2555 2576 bug or feature.
2556 2577 --changed rc file for new behavior
2557 2578
2558 2579 2004-07-15 Fernando Perez <fperez@colorado.edu>
2559 2580
2560 2581 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2561 2582 cache was falling out of sync in bizarre manners when multi-line
2562 2583 input was present. Minor optimizations and cleanup.
2563 2584
2564 2585 (Logger): Remove old Changelog info for cleanup. This is the
2565 2586 information which was there from Janko's original code:
2566 2587
2567 2588 Changes to Logger: - made the default log filename a parameter
2568 2589
2569 2590 - put a check for lines beginning with !@? in log(). Needed
2570 2591 (even if the handlers properly log their lines) for mid-session
2571 2592 logging activation to work properly. Without this, lines logged
2572 2593 in mid session, which get read from the cache, would end up
2573 2594 'bare' (with !@? in the open) in the log. Now they are caught
2574 2595 and prepended with a #.
2575 2596
2576 2597 * IPython/iplib.py (InteractiveShell.init_readline): added check
2577 2598 in case MagicCompleter fails to be defined, so we don't crash.
2578 2599
2579 2600 2004-07-13 Fernando Perez <fperez@colorado.edu>
2580 2601
2581 2602 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2582 2603 of EPS if the requested filename ends in '.eps'.
2583 2604
2584 2605 2004-07-04 Fernando Perez <fperez@colorado.edu>
2585 2606
2586 2607 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2587 2608 escaping of quotes when calling the shell.
2588 2609
2589 2610 2004-07-02 Fernando Perez <fperez@colorado.edu>
2590 2611
2591 2612 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2592 2613 gettext not working because we were clobbering '_'. Fixes
2593 2614 http://www.scipy.net/roundup/ipython/issue6.
2594 2615
2595 2616 2004-07-01 Fernando Perez <fperez@colorado.edu>
2596 2617
2597 2618 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2598 2619 into @cd. Patch by Ville.
2599 2620
2600 2621 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2601 2622 new function to store things after ipmaker runs. Patch by Ville.
2602 2623 Eventually this will go away once ipmaker is removed and the class
2603 2624 gets cleaned up, but for now it's ok. Key functionality here is
2604 2625 the addition of the persistent storage mechanism, a dict for
2605 2626 keeping data across sessions (for now just bookmarks, but more can
2606 2627 be implemented later).
2607 2628
2608 2629 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2609 2630 persistent across sections. Patch by Ville, I modified it
2610 2631 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2611 2632 added a '-l' option to list all bookmarks.
2612 2633
2613 2634 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2614 2635 center for cleanup. Registered with atexit.register(). I moved
2615 2636 here the old exit_cleanup(). After a patch by Ville.
2616 2637
2617 2638 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2618 2639 characters in the hacked shlex_split for python 2.2.
2619 2640
2620 2641 * IPython/iplib.py (file_matches): more fixes to filenames with
2621 2642 whitespace in them. It's not perfect, but limitations in python's
2622 2643 readline make it impossible to go further.
2623 2644
2624 2645 2004-06-29 Fernando Perez <fperez@colorado.edu>
2625 2646
2626 2647 * IPython/iplib.py (file_matches): escape whitespace correctly in
2627 2648 filename completions. Bug reported by Ville.
2628 2649
2629 2650 2004-06-28 Fernando Perez <fperez@colorado.edu>
2630 2651
2631 2652 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2632 2653 the history file will be called 'history-PROFNAME' (or just
2633 2654 'history' if no profile is loaded). I was getting annoyed at
2634 2655 getting my Numerical work history clobbered by pysh sessions.
2635 2656
2636 2657 * IPython/iplib.py (InteractiveShell.__init__): Internal
2637 2658 getoutputerror() function so that we can honor the system_verbose
2638 2659 flag for _all_ system calls. I also added escaping of #
2639 2660 characters here to avoid confusing Itpl.
2640 2661
2641 2662 * IPython/Magic.py (shlex_split): removed call to shell in
2642 2663 parse_options and replaced it with shlex.split(). The annoying
2643 2664 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2644 2665 to backport it from 2.3, with several frail hacks (the shlex
2645 2666 module is rather limited in 2.2). Thanks to a suggestion by Ville
2646 2667 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2647 2668 problem.
2648 2669
2649 2670 (Magic.magic_system_verbose): new toggle to print the actual
2650 2671 system calls made by ipython. Mainly for debugging purposes.
2651 2672
2652 2673 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2653 2674 doesn't support persistence. Reported (and fix suggested) by
2654 2675 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2655 2676
2656 2677 2004-06-26 Fernando Perez <fperez@colorado.edu>
2657 2678
2658 2679 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2659 2680 continue prompts.
2660 2681
2661 2682 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2662 2683 function (basically a big docstring) and a few more things here to
2663 2684 speedup startup. pysh.py is now very lightweight. We want because
2664 2685 it gets execfile'd, while InterpreterExec gets imported, so
2665 2686 byte-compilation saves time.
2666 2687
2667 2688 2004-06-25 Fernando Perez <fperez@colorado.edu>
2668 2689
2669 2690 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2670 2691 -NUM', which was recently broken.
2671 2692
2672 2693 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2673 2694 in multi-line input (but not !!, which doesn't make sense there).
2674 2695
2675 2696 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2676 2697 It's just too useful, and people can turn it off in the less
2677 2698 common cases where it's a problem.
2678 2699
2679 2700 2004-06-24 Fernando Perez <fperez@colorado.edu>
2680 2701
2681 2702 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2682 2703 special syntaxes (like alias calling) is now allied in multi-line
2683 2704 input. This is still _very_ experimental, but it's necessary for
2684 2705 efficient shell usage combining python looping syntax with system
2685 2706 calls. For now it's restricted to aliases, I don't think it
2686 2707 really even makes sense to have this for magics.
2687 2708
2688 2709 2004-06-23 Fernando Perez <fperez@colorado.edu>
2689 2710
2690 2711 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2691 2712 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2692 2713
2693 2714 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2694 2715 extensions under Windows (after code sent by Gary Bishop). The
2695 2716 extensions considered 'executable' are stored in IPython's rc
2696 2717 structure as win_exec_ext.
2697 2718
2698 2719 * IPython/genutils.py (shell): new function, like system() but
2699 2720 without return value. Very useful for interactive shell work.
2700 2721
2701 2722 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2702 2723 delete aliases.
2703 2724
2704 2725 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2705 2726 sure that the alias table doesn't contain python keywords.
2706 2727
2707 2728 2004-06-21 Fernando Perez <fperez@colorado.edu>
2708 2729
2709 2730 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2710 2731 non-existent items are found in $PATH. Reported by Thorsten.
2711 2732
2712 2733 2004-06-20 Fernando Perez <fperez@colorado.edu>
2713 2734
2714 2735 * IPython/iplib.py (complete): modified the completer so that the
2715 2736 order of priorities can be easily changed at runtime.
2716 2737
2717 2738 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2718 2739 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2719 2740
2720 2741 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2721 2742 expand Python variables prepended with $ in all system calls. The
2722 2743 same was done to InteractiveShell.handle_shell_escape. Now all
2723 2744 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2724 2745 expansion of python variables and expressions according to the
2725 2746 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2726 2747
2727 2748 Though PEP-215 has been rejected, a similar (but simpler) one
2728 2749 seems like it will go into Python 2.4, PEP-292 -
2729 2750 http://www.python.org/peps/pep-0292.html.
2730 2751
2731 2752 I'll keep the full syntax of PEP-215, since IPython has since the
2732 2753 start used Ka-Ping Yee's reference implementation discussed there
2733 2754 (Itpl), and I actually like the powerful semantics it offers.
2734 2755
2735 2756 In order to access normal shell variables, the $ has to be escaped
2736 2757 via an extra $. For example:
2737 2758
2738 2759 In [7]: PATH='a python variable'
2739 2760
2740 2761 In [8]: !echo $PATH
2741 2762 a python variable
2742 2763
2743 2764 In [9]: !echo $$PATH
2744 2765 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2745 2766
2746 2767 (Magic.parse_options): escape $ so the shell doesn't evaluate
2747 2768 things prematurely.
2748 2769
2749 2770 * IPython/iplib.py (InteractiveShell.call_alias): added the
2750 2771 ability for aliases to expand python variables via $.
2751 2772
2752 2773 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2753 2774 system, now there's a @rehash/@rehashx pair of magics. These work
2754 2775 like the csh rehash command, and can be invoked at any time. They
2755 2776 build a table of aliases to everything in the user's $PATH
2756 2777 (@rehash uses everything, @rehashx is slower but only adds
2757 2778 executable files). With this, the pysh.py-based shell profile can
2758 2779 now simply call rehash upon startup, and full access to all
2759 2780 programs in the user's path is obtained.
2760 2781
2761 2782 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2762 2783 functionality is now fully in place. I removed the old dynamic
2763 2784 code generation based approach, in favor of a much lighter one
2764 2785 based on a simple dict. The advantage is that this allows me to
2765 2786 now have thousands of aliases with negligible cost (unthinkable
2766 2787 with the old system).
2767 2788
2768 2789 2004-06-19 Fernando Perez <fperez@colorado.edu>
2769 2790
2770 2791 * IPython/iplib.py (__init__): extended MagicCompleter class to
2771 2792 also complete (last in priority) on user aliases.
2772 2793
2773 2794 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2774 2795 call to eval.
2775 2796 (ItplNS.__init__): Added a new class which functions like Itpl,
2776 2797 but allows configuring the namespace for the evaluation to occur
2777 2798 in.
2778 2799
2779 2800 2004-06-18 Fernando Perez <fperez@colorado.edu>
2780 2801
2781 2802 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2782 2803 better message when 'exit' or 'quit' are typed (a common newbie
2783 2804 confusion).
2784 2805
2785 2806 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2786 2807 check for Windows users.
2787 2808
2788 2809 * IPython/iplib.py (InteractiveShell.user_setup): removed
2789 2810 disabling of colors for Windows. I'll test at runtime and issue a
2790 2811 warning if Gary's readline isn't found, as to nudge users to
2791 2812 download it.
2792 2813
2793 2814 2004-06-16 Fernando Perez <fperez@colorado.edu>
2794 2815
2795 2816 * IPython/genutils.py (Stream.__init__): changed to print errors
2796 2817 to sys.stderr. I had a circular dependency here. Now it's
2797 2818 possible to run ipython as IDLE's shell (consider this pre-alpha,
2798 2819 since true stdout things end up in the starting terminal instead
2799 2820 of IDLE's out).
2800 2821
2801 2822 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2802 2823 users who haven't # updated their prompt_in2 definitions. Remove
2803 2824 eventually.
2804 2825 (multiple_replace): added credit to original ASPN recipe.
2805 2826
2806 2827 2004-06-15 Fernando Perez <fperez@colorado.edu>
2807 2828
2808 2829 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2809 2830 list of auto-defined aliases.
2810 2831
2811 2832 2004-06-13 Fernando Perez <fperez@colorado.edu>
2812 2833
2813 2834 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2814 2835 install was really requested (so setup.py can be used for other
2815 2836 things under Windows).
2816 2837
2817 2838 2004-06-10 Fernando Perez <fperez@colorado.edu>
2818 2839
2819 2840 * IPython/Logger.py (Logger.create_log): Manually remove any old
2820 2841 backup, since os.remove may fail under Windows. Fixes bug
2821 2842 reported by Thorsten.
2822 2843
2823 2844 2004-06-09 Fernando Perez <fperez@colorado.edu>
2824 2845
2825 2846 * examples/example-embed.py: fixed all references to %n (replaced
2826 2847 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2827 2848 for all examples and the manual as well.
2828 2849
2829 2850 2004-06-08 Fernando Perez <fperez@colorado.edu>
2830 2851
2831 2852 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2832 2853 alignment and color management. All 3 prompt subsystems now
2833 2854 inherit from BasePrompt.
2834 2855
2835 2856 * tools/release: updates for windows installer build and tag rpms
2836 2857 with python version (since paths are fixed).
2837 2858
2838 2859 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2839 2860 which will become eventually obsolete. Also fixed the default
2840 2861 prompt_in2 to use \D, so at least new users start with the correct
2841 2862 defaults.
2842 2863 WARNING: Users with existing ipythonrc files will need to apply
2843 2864 this fix manually!
2844 2865
2845 2866 * setup.py: make windows installer (.exe). This is finally the
2846 2867 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2847 2868 which I hadn't included because it required Python 2.3 (or recent
2848 2869 distutils).
2849 2870
2850 2871 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2851 2872 usage of new '\D' escape.
2852 2873
2853 2874 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2854 2875 lacks os.getuid())
2855 2876 (CachedOutput.set_colors): Added the ability to turn coloring
2856 2877 on/off with @colors even for manually defined prompt colors. It
2857 2878 uses a nasty global, but it works safely and via the generic color
2858 2879 handling mechanism.
2859 2880 (Prompt2.__init__): Introduced new escape '\D' for continuation
2860 2881 prompts. It represents the counter ('\#') as dots.
2861 2882 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2862 2883 need to update their ipythonrc files and replace '%n' with '\D' in
2863 2884 their prompt_in2 settings everywhere. Sorry, but there's
2864 2885 otherwise no clean way to get all prompts to properly align. The
2865 2886 ipythonrc shipped with IPython has been updated.
2866 2887
2867 2888 2004-06-07 Fernando Perez <fperez@colorado.edu>
2868 2889
2869 2890 * setup.py (isfile): Pass local_icons option to latex2html, so the
2870 2891 resulting HTML file is self-contained. Thanks to
2871 2892 dryice-AT-liu.com.cn for the tip.
2872 2893
2873 2894 * pysh.py: I created a new profile 'shell', which implements a
2874 2895 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2875 2896 system shell, nor will it become one anytime soon. It's mainly
2876 2897 meant to illustrate the use of the new flexible bash-like prompts.
2877 2898 I guess it could be used by hardy souls for true shell management,
2878 2899 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2879 2900 profile. This uses the InterpreterExec extension provided by
2880 2901 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2881 2902
2882 2903 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2883 2904 auto-align itself with the length of the previous input prompt
2884 2905 (taking into account the invisible color escapes).
2885 2906 (CachedOutput.__init__): Large restructuring of this class. Now
2886 2907 all three prompts (primary1, primary2, output) are proper objects,
2887 2908 managed by the 'parent' CachedOutput class. The code is still a
2888 2909 bit hackish (all prompts share state via a pointer to the cache),
2889 2910 but it's overall far cleaner than before.
2890 2911
2891 2912 * IPython/genutils.py (getoutputerror): modified to add verbose,
2892 2913 debug and header options. This makes the interface of all getout*
2893 2914 functions uniform.
2894 2915 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2895 2916
2896 2917 * IPython/Magic.py (Magic.default_option): added a function to
2897 2918 allow registering default options for any magic command. This
2898 2919 makes it easy to have profiles which customize the magics globally
2899 2920 for a certain use. The values set through this function are
2900 2921 picked up by the parse_options() method, which all magics should
2901 2922 use to parse their options.
2902 2923
2903 2924 * IPython/genutils.py (warn): modified the warnings framework to
2904 2925 use the Term I/O class. I'm trying to slowly unify all of
2905 2926 IPython's I/O operations to pass through Term.
2906 2927
2907 2928 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2908 2929 the secondary prompt to correctly match the length of the primary
2909 2930 one for any prompt. Now multi-line code will properly line up
2910 2931 even for path dependent prompts, such as the new ones available
2911 2932 via the prompt_specials.
2912 2933
2913 2934 2004-06-06 Fernando Perez <fperez@colorado.edu>
2914 2935
2915 2936 * IPython/Prompts.py (prompt_specials): Added the ability to have
2916 2937 bash-like special sequences in the prompts, which get
2917 2938 automatically expanded. Things like hostname, current working
2918 2939 directory and username are implemented already, but it's easy to
2919 2940 add more in the future. Thanks to a patch by W.J. van der Laan
2920 2941 <gnufnork-AT-hetdigitalegat.nl>
2921 2942 (prompt_specials): Added color support for prompt strings, so
2922 2943 users can define arbitrary color setups for their prompts.
2923 2944
2924 2945 2004-06-05 Fernando Perez <fperez@colorado.edu>
2925 2946
2926 2947 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2927 2948 code to load Gary Bishop's readline and configure it
2928 2949 automatically. Thanks to Gary for help on this.
2929 2950
2930 2951 2004-06-01 Fernando Perez <fperez@colorado.edu>
2931 2952
2932 2953 * IPython/Logger.py (Logger.create_log): fix bug for logging
2933 2954 with no filename (previous fix was incomplete).
2934 2955
2935 2956 2004-05-25 Fernando Perez <fperez@colorado.edu>
2936 2957
2937 2958 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2938 2959 parens would get passed to the shell.
2939 2960
2940 2961 2004-05-20 Fernando Perez <fperez@colorado.edu>
2941 2962
2942 2963 * IPython/Magic.py (Magic.magic_prun): changed default profile
2943 2964 sort order to 'time' (the more common profiling need).
2944 2965
2945 2966 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2946 2967 so that source code shown is guaranteed in sync with the file on
2947 2968 disk (also changed in psource). Similar fix to the one for
2948 2969 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2949 2970 <yann.ledu-AT-noos.fr>.
2950 2971
2951 2972 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2952 2973 with a single option would not be correctly parsed. Closes
2953 2974 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2954 2975 introduced in 0.6.0 (on 2004-05-06).
2955 2976
2956 2977 2004-05-13 *** Released version 0.6.0
2957 2978
2958 2979 2004-05-13 Fernando Perez <fperez@colorado.edu>
2959 2980
2960 2981 * debian/: Added debian/ directory to CVS, so that debian support
2961 2982 is publicly accessible. The debian package is maintained by Jack
2962 2983 Moffit <jack-AT-xiph.org>.
2963 2984
2964 2985 * Documentation: included the notes about an ipython-based system
2965 2986 shell (the hypothetical 'pysh') into the new_design.pdf document,
2966 2987 so that these ideas get distributed to users along with the
2967 2988 official documentation.
2968 2989
2969 2990 2004-05-10 Fernando Perez <fperez@colorado.edu>
2970 2991
2971 2992 * IPython/Logger.py (Logger.create_log): fix recently introduced
2972 2993 bug (misindented line) where logstart would fail when not given an
2973 2994 explicit filename.
2974 2995
2975 2996 2004-05-09 Fernando Perez <fperez@colorado.edu>
2976 2997
2977 2998 * IPython/Magic.py (Magic.parse_options): skip system call when
2978 2999 there are no options to look for. Faster, cleaner for the common
2979 3000 case.
2980 3001
2981 3002 * Documentation: many updates to the manual: describing Windows
2982 3003 support better, Gnuplot updates, credits, misc small stuff. Also
2983 3004 updated the new_design doc a bit.
2984 3005
2985 3006 2004-05-06 *** Released version 0.6.0.rc1
2986 3007
2987 3008 2004-05-06 Fernando Perez <fperez@colorado.edu>
2988 3009
2989 3010 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2990 3011 operations to use the vastly more efficient list/''.join() method.
2991 3012 (FormattedTB.text): Fix
2992 3013 http://www.scipy.net/roundup/ipython/issue12 - exception source
2993 3014 extract not updated after reload. Thanks to Mike Salib
2994 3015 <msalib-AT-mit.edu> for pinning the source of the problem.
2995 3016 Fortunately, the solution works inside ipython and doesn't require
2996 3017 any changes to python proper.
2997 3018
2998 3019 * IPython/Magic.py (Magic.parse_options): Improved to process the
2999 3020 argument list as a true shell would (by actually using the
3000 3021 underlying system shell). This way, all @magics automatically get
3001 3022 shell expansion for variables. Thanks to a comment by Alex
3002 3023 Schmolck.
3003 3024
3004 3025 2004-04-04 Fernando Perez <fperez@colorado.edu>
3005 3026
3006 3027 * IPython/iplib.py (InteractiveShell.interact): Added a special
3007 3028 trap for a debugger quit exception, which is basically impossible
3008 3029 to handle by normal mechanisms, given what pdb does to the stack.
3009 3030 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3010 3031
3011 3032 2004-04-03 Fernando Perez <fperez@colorado.edu>
3012 3033
3013 3034 * IPython/genutils.py (Term): Standardized the names of the Term
3014 3035 class streams to cin/cout/cerr, following C++ naming conventions
3015 3036 (I can't use in/out/err because 'in' is not a valid attribute
3016 3037 name).
3017 3038
3018 3039 * IPython/iplib.py (InteractiveShell.interact): don't increment
3019 3040 the prompt if there's no user input. By Daniel 'Dang' Griffith
3020 3041 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3021 3042 Francois Pinard.
3022 3043
3023 3044 2004-04-02 Fernando Perez <fperez@colorado.edu>
3024 3045
3025 3046 * IPython/genutils.py (Stream.__init__): Modified to survive at
3026 3047 least importing in contexts where stdin/out/err aren't true file
3027 3048 objects, such as PyCrust (they lack fileno() and mode). However,
3028 3049 the recovery facilities which rely on these things existing will
3029 3050 not work.
3030 3051
3031 3052 2004-04-01 Fernando Perez <fperez@colorado.edu>
3032 3053
3033 3054 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3034 3055 use the new getoutputerror() function, so it properly
3035 3056 distinguishes stdout/err.
3036 3057
3037 3058 * IPython/genutils.py (getoutputerror): added a function to
3038 3059 capture separately the standard output and error of a command.
3039 3060 After a comment from dang on the mailing lists. This code is
3040 3061 basically a modified version of commands.getstatusoutput(), from
3041 3062 the standard library.
3042 3063
3043 3064 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3044 3065 '!!' as a special syntax (shorthand) to access @sx.
3045 3066
3046 3067 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3047 3068 command and return its output as a list split on '\n'.
3048 3069
3049 3070 2004-03-31 Fernando Perez <fperez@colorado.edu>
3050 3071
3051 3072 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3052 3073 method to dictionaries used as FakeModule instances if they lack
3053 3074 it. At least pydoc in python2.3 breaks for runtime-defined
3054 3075 functions without this hack. At some point I need to _really_
3055 3076 understand what FakeModule is doing, because it's a gross hack.
3056 3077 But it solves Arnd's problem for now...
3057 3078
3058 3079 2004-02-27 Fernando Perez <fperez@colorado.edu>
3059 3080
3060 3081 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3061 3082 mode would behave erratically. Also increased the number of
3062 3083 possible logs in rotate mod to 999. Thanks to Rod Holland
3063 3084 <rhh@StructureLABS.com> for the report and fixes.
3064 3085
3065 3086 2004-02-26 Fernando Perez <fperez@colorado.edu>
3066 3087
3067 3088 * IPython/genutils.py (page): Check that the curses module really
3068 3089 has the initscr attribute before trying to use it. For some
3069 3090 reason, the Solaris curses module is missing this. I think this
3070 3091 should be considered a Solaris python bug, but I'm not sure.
3071 3092
3072 3093 2004-01-17 Fernando Perez <fperez@colorado.edu>
3073 3094
3074 3095 * IPython/genutils.py (Stream.__init__): Changes to try to make
3075 3096 ipython robust against stdin/out/err being closed by the user.
3076 3097 This is 'user error' (and blocks a normal python session, at least
3077 3098 the stdout case). However, Ipython should be able to survive such
3078 3099 instances of abuse as gracefully as possible. To simplify the
3079 3100 coding and maintain compatibility with Gary Bishop's Term
3080 3101 contributions, I've made use of classmethods for this. I think
3081 3102 this introduces a dependency on python 2.2.
3082 3103
3083 3104 2004-01-13 Fernando Perez <fperez@colorado.edu>
3084 3105
3085 3106 * IPython/numutils.py (exp_safe): simplified the code a bit and
3086 3107 removed the need for importing the kinds module altogether.
3087 3108
3088 3109 2004-01-06 Fernando Perez <fperez@colorado.edu>
3089 3110
3090 3111 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3091 3112 a magic function instead, after some community feedback. No
3092 3113 special syntax will exist for it, but its name is deliberately
3093 3114 very short.
3094 3115
3095 3116 2003-12-20 Fernando Perez <fperez@colorado.edu>
3096 3117
3097 3118 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3098 3119 new functionality, to automagically assign the result of a shell
3099 3120 command to a variable. I'll solicit some community feedback on
3100 3121 this before making it permanent.
3101 3122
3102 3123 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3103 3124 requested about callables for which inspect couldn't obtain a
3104 3125 proper argspec. Thanks to a crash report sent by Etienne
3105 3126 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3106 3127
3107 3128 2003-12-09 Fernando Perez <fperez@colorado.edu>
3108 3129
3109 3130 * IPython/genutils.py (page): patch for the pager to work across
3110 3131 various versions of Windows. By Gary Bishop.
3111 3132
3112 3133 2003-12-04 Fernando Perez <fperez@colorado.edu>
3113 3134
3114 3135 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3115 3136 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3116 3137 While I tested this and it looks ok, there may still be corner
3117 3138 cases I've missed.
3118 3139
3119 3140 2003-12-01 Fernando Perez <fperez@colorado.edu>
3120 3141
3121 3142 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3122 3143 where a line like 'p,q=1,2' would fail because the automagic
3123 3144 system would be triggered for @p.
3124 3145
3125 3146 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3126 3147 cleanups, code unmodified.
3127 3148
3128 3149 * IPython/genutils.py (Term): added a class for IPython to handle
3129 3150 output. In most cases it will just be a proxy for stdout/err, but
3130 3151 having this allows modifications to be made for some platforms,
3131 3152 such as handling color escapes under Windows. All of this code
3132 3153 was contributed by Gary Bishop, with minor modifications by me.
3133 3154 The actual changes affect many files.
3134 3155
3135 3156 2003-11-30 Fernando Perez <fperez@colorado.edu>
3136 3157
3137 3158 * IPython/iplib.py (file_matches): new completion code, courtesy
3138 3159 of Jeff Collins. This enables filename completion again under
3139 3160 python 2.3, which disabled it at the C level.
3140 3161
3141 3162 2003-11-11 Fernando Perez <fperez@colorado.edu>
3142 3163
3143 3164 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3144 3165 for Numeric.array(map(...)), but often convenient.
3145 3166
3146 3167 2003-11-05 Fernando Perez <fperez@colorado.edu>
3147 3168
3148 3169 * IPython/numutils.py (frange): Changed a call from int() to
3149 3170 int(round()) to prevent a problem reported with arange() in the
3150 3171 numpy list.
3151 3172
3152 3173 2003-10-06 Fernando Perez <fperez@colorado.edu>
3153 3174
3154 3175 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3155 3176 prevent crashes if sys lacks an argv attribute (it happens with
3156 3177 embedded interpreters which build a bare-bones sys module).
3157 3178 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3158 3179
3159 3180 2003-09-24 Fernando Perez <fperez@colorado.edu>
3160 3181
3161 3182 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3162 3183 to protect against poorly written user objects where __getattr__
3163 3184 raises exceptions other than AttributeError. Thanks to a bug
3164 3185 report by Oliver Sander <osander-AT-gmx.de>.
3165 3186
3166 3187 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3167 3188 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3168 3189
3169 3190 2003-09-09 Fernando Perez <fperez@colorado.edu>
3170 3191
3171 3192 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3172 3193 unpacking a list whith a callable as first element would
3173 3194 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3174 3195 Collins.
3175 3196
3176 3197 2003-08-25 *** Released version 0.5.0
3177 3198
3178 3199 2003-08-22 Fernando Perez <fperez@colorado.edu>
3179 3200
3180 3201 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3181 3202 improperly defined user exceptions. Thanks to feedback from Mark
3182 3203 Russell <mrussell-AT-verio.net>.
3183 3204
3184 3205 2003-08-20 Fernando Perez <fperez@colorado.edu>
3185 3206
3186 3207 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3187 3208 printing so that it would print multi-line string forms starting
3188 3209 with a new line. This way the formatting is better respected for
3189 3210 objects which work hard to make nice string forms.
3190 3211
3191 3212 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3192 3213 autocall would overtake data access for objects with both
3193 3214 __getitem__ and __call__.
3194 3215
3195 3216 2003-08-19 *** Released version 0.5.0-rc1
3196 3217
3197 3218 2003-08-19 Fernando Perez <fperez@colorado.edu>
3198 3219
3199 3220 * IPython/deep_reload.py (load_tail): single tiny change here
3200 3221 seems to fix the long-standing bug of dreload() failing to work
3201 3222 for dotted names. But this module is pretty tricky, so I may have
3202 3223 missed some subtlety. Needs more testing!.
3203 3224
3204 3225 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3205 3226 exceptions which have badly implemented __str__ methods.
3206 3227 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3207 3228 which I've been getting reports about from Python 2.3 users. I
3208 3229 wish I had a simple test case to reproduce the problem, so I could
3209 3230 either write a cleaner workaround or file a bug report if
3210 3231 necessary.
3211 3232
3212 3233 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3213 3234 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3214 3235 a bug report by Tjabo Kloppenburg.
3215 3236
3216 3237 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3217 3238 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3218 3239 seems rather unstable. Thanks to a bug report by Tjabo
3219 3240 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3220 3241
3221 3242 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3222 3243 this out soon because of the critical fixes in the inner loop for
3223 3244 generators.
3224 3245
3225 3246 * IPython/Magic.py (Magic.getargspec): removed. This (and
3226 3247 _get_def) have been obsoleted by OInspect for a long time, I
3227 3248 hadn't noticed that they were dead code.
3228 3249 (Magic._ofind): restored _ofind functionality for a few literals
3229 3250 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3230 3251 for things like "hello".capitalize?, since that would require a
3231 3252 potentially dangerous eval() again.
3232 3253
3233 3254 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3234 3255 logic a bit more to clean up the escapes handling and minimize the
3235 3256 use of _ofind to only necessary cases. The interactive 'feel' of
3236 3257 IPython should have improved quite a bit with the changes in
3237 3258 _prefilter and _ofind (besides being far safer than before).
3238 3259
3239 3260 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3240 3261 obscure, never reported). Edit would fail to find the object to
3241 3262 edit under some circumstances.
3242 3263 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3243 3264 which were causing double-calling of generators. Those eval calls
3244 3265 were _very_ dangerous, since code with side effects could be
3245 3266 triggered. As they say, 'eval is evil'... These were the
3246 3267 nastiest evals in IPython. Besides, _ofind is now far simpler,
3247 3268 and it should also be quite a bit faster. Its use of inspect is
3248 3269 also safer, so perhaps some of the inspect-related crashes I've
3249 3270 seen lately with Python 2.3 might be taken care of. That will
3250 3271 need more testing.
3251 3272
3252 3273 2003-08-17 Fernando Perez <fperez@colorado.edu>
3253 3274
3254 3275 * IPython/iplib.py (InteractiveShell._prefilter): significant
3255 3276 simplifications to the logic for handling user escapes. Faster
3256 3277 and simpler code.
3257 3278
3258 3279 2003-08-14 Fernando Perez <fperez@colorado.edu>
3259 3280
3260 3281 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3261 3282 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3262 3283 but it should be quite a bit faster. And the recursive version
3263 3284 generated O(log N) intermediate storage for all rank>1 arrays,
3264 3285 even if they were contiguous.
3265 3286 (l1norm): Added this function.
3266 3287 (norm): Added this function for arbitrary norms (including
3267 3288 l-infinity). l1 and l2 are still special cases for convenience
3268 3289 and speed.
3269 3290
3270 3291 2003-08-03 Fernando Perez <fperez@colorado.edu>
3271 3292
3272 3293 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3273 3294 exceptions, which now raise PendingDeprecationWarnings in Python
3274 3295 2.3. There were some in Magic and some in Gnuplot2.
3275 3296
3276 3297 2003-06-30 Fernando Perez <fperez@colorado.edu>
3277 3298
3278 3299 * IPython/genutils.py (page): modified to call curses only for
3279 3300 terminals where TERM=='xterm'. After problems under many other
3280 3301 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3281 3302
3282 3303 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3283 3304 would be triggered when readline was absent. This was just an old
3284 3305 debugging statement I'd forgotten to take out.
3285 3306
3286 3307 2003-06-20 Fernando Perez <fperez@colorado.edu>
3287 3308
3288 3309 * IPython/genutils.py (clock): modified to return only user time
3289 3310 (not counting system time), after a discussion on scipy. While
3290 3311 system time may be a useful quantity occasionally, it may much
3291 3312 more easily be skewed by occasional swapping or other similar
3292 3313 activity.
3293 3314
3294 3315 2003-06-05 Fernando Perez <fperez@colorado.edu>
3295 3316
3296 3317 * IPython/numutils.py (identity): new function, for building
3297 3318 arbitrary rank Kronecker deltas (mostly backwards compatible with
3298 3319 Numeric.identity)
3299 3320
3300 3321 2003-06-03 Fernando Perez <fperez@colorado.edu>
3301 3322
3302 3323 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3303 3324 arguments passed to magics with spaces, to allow trailing '\' to
3304 3325 work normally (mainly for Windows users).
3305 3326
3306 3327 2003-05-29 Fernando Perez <fperez@colorado.edu>
3307 3328
3308 3329 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3309 3330 instead of pydoc.help. This fixes a bizarre behavior where
3310 3331 printing '%s' % locals() would trigger the help system. Now
3311 3332 ipython behaves like normal python does.
3312 3333
3313 3334 Note that if one does 'from pydoc import help', the bizarre
3314 3335 behavior returns, but this will also happen in normal python, so
3315 3336 it's not an ipython bug anymore (it has to do with how pydoc.help
3316 3337 is implemented).
3317 3338
3318 3339 2003-05-22 Fernando Perez <fperez@colorado.edu>
3319 3340
3320 3341 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3321 3342 return [] instead of None when nothing matches, also match to end
3322 3343 of line. Patch by Gary Bishop.
3323 3344
3324 3345 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3325 3346 protection as before, for files passed on the command line. This
3326 3347 prevents the CrashHandler from kicking in if user files call into
3327 3348 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3328 3349 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3329 3350
3330 3351 2003-05-20 *** Released version 0.4.0
3331 3352
3332 3353 2003-05-20 Fernando Perez <fperez@colorado.edu>
3333 3354
3334 3355 * setup.py: added support for manpages. It's a bit hackish b/c of
3335 3356 a bug in the way the bdist_rpm distutils target handles gzipped
3336 3357 manpages, but it works. After a patch by Jack.
3337 3358
3338 3359 2003-05-19 Fernando Perez <fperez@colorado.edu>
3339 3360
3340 3361 * IPython/numutils.py: added a mockup of the kinds module, since
3341 3362 it was recently removed from Numeric. This way, numutils will
3342 3363 work for all users even if they are missing kinds.
3343 3364
3344 3365 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3345 3366 failure, which can occur with SWIG-wrapped extensions. After a
3346 3367 crash report from Prabhu.
3347 3368
3348 3369 2003-05-16 Fernando Perez <fperez@colorado.edu>
3349 3370
3350 3371 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3351 3372 protect ipython from user code which may call directly
3352 3373 sys.excepthook (this looks like an ipython crash to the user, even
3353 3374 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3354 3375 This is especially important to help users of WxWindows, but may
3355 3376 also be useful in other cases.
3356 3377
3357 3378 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3358 3379 an optional tb_offset to be specified, and to preserve exception
3359 3380 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3360 3381
3361 3382 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3362 3383
3363 3384 2003-05-15 Fernando Perez <fperez@colorado.edu>
3364 3385
3365 3386 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3366 3387 installing for a new user under Windows.
3367 3388
3368 3389 2003-05-12 Fernando Perez <fperez@colorado.edu>
3369 3390
3370 3391 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3371 3392 handler for Emacs comint-based lines. Currently it doesn't do
3372 3393 much (but importantly, it doesn't update the history cache). In
3373 3394 the future it may be expanded if Alex needs more functionality
3374 3395 there.
3375 3396
3376 3397 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3377 3398 info to crash reports.
3378 3399
3379 3400 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3380 3401 just like Python's -c. Also fixed crash with invalid -color
3381 3402 option value at startup. Thanks to Will French
3382 3403 <wfrench-AT-bestweb.net> for the bug report.
3383 3404
3384 3405 2003-05-09 Fernando Perez <fperez@colorado.edu>
3385 3406
3386 3407 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3387 3408 to EvalDict (it's a mapping, after all) and simplified its code
3388 3409 quite a bit, after a nice discussion on c.l.py where Gustavo
3389 3410 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3390 3411
3391 3412 2003-04-30 Fernando Perez <fperez@colorado.edu>
3392 3413
3393 3414 * IPython/genutils.py (timings_out): modified it to reduce its
3394 3415 overhead in the common reps==1 case.
3395 3416
3396 3417 2003-04-29 Fernando Perez <fperez@colorado.edu>
3397 3418
3398 3419 * IPython/genutils.py (timings_out): Modified to use the resource
3399 3420 module, which avoids the wraparound problems of time.clock().
3400 3421
3401 3422 2003-04-17 *** Released version 0.2.15pre4
3402 3423
3403 3424 2003-04-17 Fernando Perez <fperez@colorado.edu>
3404 3425
3405 3426 * setup.py (scriptfiles): Split windows-specific stuff over to a
3406 3427 separate file, in an attempt to have a Windows GUI installer.
3407 3428 That didn't work, but part of the groundwork is done.
3408 3429
3409 3430 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3410 3431 indent/unindent with 4 spaces. Particularly useful in combination
3411 3432 with the new auto-indent option.
3412 3433
3413 3434 2003-04-16 Fernando Perez <fperez@colorado.edu>
3414 3435
3415 3436 * IPython/Magic.py: various replacements of self.rc for
3416 3437 self.shell.rc. A lot more remains to be done to fully disentangle
3417 3438 this class from the main Shell class.
3418 3439
3419 3440 * IPython/GnuplotRuntime.py: added checks for mouse support so
3420 3441 that we don't try to enable it if the current gnuplot doesn't
3421 3442 really support it. Also added checks so that we don't try to
3422 3443 enable persist under Windows (where Gnuplot doesn't recognize the
3423 3444 option).
3424 3445
3425 3446 * IPython/iplib.py (InteractiveShell.interact): Added optional
3426 3447 auto-indenting code, after a patch by King C. Shu
3427 3448 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3428 3449 get along well with pasting indented code. If I ever figure out
3429 3450 how to make that part go well, it will become on by default.
3430 3451
3431 3452 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3432 3453 crash ipython if there was an unmatched '%' in the user's prompt
3433 3454 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3434 3455
3435 3456 * IPython/iplib.py (InteractiveShell.interact): removed the
3436 3457 ability to ask the user whether he wants to crash or not at the
3437 3458 'last line' exception handler. Calling functions at that point
3438 3459 changes the stack, and the error reports would have incorrect
3439 3460 tracebacks.
3440 3461
3441 3462 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3442 3463 pass through a peger a pretty-printed form of any object. After a
3443 3464 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3444 3465
3445 3466 2003-04-14 Fernando Perez <fperez@colorado.edu>
3446 3467
3447 3468 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3448 3469 all files in ~ would be modified at first install (instead of
3449 3470 ~/.ipython). This could be potentially disastrous, as the
3450 3471 modification (make line-endings native) could damage binary files.
3451 3472
3452 3473 2003-04-10 Fernando Perez <fperez@colorado.edu>
3453 3474
3454 3475 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3455 3476 handle only lines which are invalid python. This now means that
3456 3477 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3457 3478 for the bug report.
3458 3479
3459 3480 2003-04-01 Fernando Perez <fperez@colorado.edu>
3460 3481
3461 3482 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3462 3483 where failing to set sys.last_traceback would crash pdb.pm().
3463 3484 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3464 3485 report.
3465 3486
3466 3487 2003-03-25 Fernando Perez <fperez@colorado.edu>
3467 3488
3468 3489 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3469 3490 before printing it (it had a lot of spurious blank lines at the
3470 3491 end).
3471 3492
3472 3493 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3473 3494 output would be sent 21 times! Obviously people don't use this
3474 3495 too often, or I would have heard about it.
3475 3496
3476 3497 2003-03-24 Fernando Perez <fperez@colorado.edu>
3477 3498
3478 3499 * setup.py (scriptfiles): renamed the data_files parameter from
3479 3500 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3480 3501 for the patch.
3481 3502
3482 3503 2003-03-20 Fernando Perez <fperez@colorado.edu>
3483 3504
3484 3505 * IPython/genutils.py (error): added error() and fatal()
3485 3506 functions.
3486 3507
3487 3508 2003-03-18 *** Released version 0.2.15pre3
3488 3509
3489 3510 2003-03-18 Fernando Perez <fperez@colorado.edu>
3490 3511
3491 3512 * setupext/install_data_ext.py
3492 3513 (install_data_ext.initialize_options): Class contributed by Jack
3493 3514 Moffit for fixing the old distutils hack. He is sending this to
3494 3515 the distutils folks so in the future we may not need it as a
3495 3516 private fix.
3496 3517
3497 3518 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3498 3519 changes for Debian packaging. See his patch for full details.
3499 3520 The old distutils hack of making the ipythonrc* files carry a
3500 3521 bogus .py extension is gone, at last. Examples were moved to a
3501 3522 separate subdir under doc/, and the separate executable scripts
3502 3523 now live in their own directory. Overall a great cleanup. The
3503 3524 manual was updated to use the new files, and setup.py has been
3504 3525 fixed for this setup.
3505 3526
3506 3527 * IPython/PyColorize.py (Parser.usage): made non-executable and
3507 3528 created a pycolor wrapper around it to be included as a script.
3508 3529
3509 3530 2003-03-12 *** Released version 0.2.15pre2
3510 3531
3511 3532 2003-03-12 Fernando Perez <fperez@colorado.edu>
3512 3533
3513 3534 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3514 3535 long-standing problem with garbage characters in some terminals.
3515 3536 The issue was really that the \001 and \002 escapes must _only_ be
3516 3537 passed to input prompts (which call readline), but _never_ to
3517 3538 normal text to be printed on screen. I changed ColorANSI to have
3518 3539 two classes: TermColors and InputTermColors, each with the
3519 3540 appropriate escapes for input prompts or normal text. The code in
3520 3541 Prompts.py got slightly more complicated, but this very old and
3521 3542 annoying bug is finally fixed.
3522 3543
3523 3544 All the credit for nailing down the real origin of this problem
3524 3545 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3525 3546 *Many* thanks to him for spending quite a bit of effort on this.
3526 3547
3527 3548 2003-03-05 *** Released version 0.2.15pre1
3528 3549
3529 3550 2003-03-03 Fernando Perez <fperez@colorado.edu>
3530 3551
3531 3552 * IPython/FakeModule.py: Moved the former _FakeModule to a
3532 3553 separate file, because it's also needed by Magic (to fix a similar
3533 3554 pickle-related issue in @run).
3534 3555
3535 3556 2003-03-02 Fernando Perez <fperez@colorado.edu>
3536 3557
3537 3558 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3538 3559 the autocall option at runtime.
3539 3560 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3540 3561 across Magic.py to start separating Magic from InteractiveShell.
3541 3562 (Magic._ofind): Fixed to return proper namespace for dotted
3542 3563 names. Before, a dotted name would always return 'not currently
3543 3564 defined', because it would find the 'parent'. s.x would be found,
3544 3565 but since 'x' isn't defined by itself, it would get confused.
3545 3566 (Magic.magic_run): Fixed pickling problems reported by Ralf
3546 3567 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3547 3568 that I'd used when Mike Heeter reported similar issues at the
3548 3569 top-level, but now for @run. It boils down to injecting the
3549 3570 namespace where code is being executed with something that looks
3550 3571 enough like a module to fool pickle.dump(). Since a pickle stores
3551 3572 a named reference to the importing module, we need this for
3552 3573 pickles to save something sensible.
3553 3574
3554 3575 * IPython/ipmaker.py (make_IPython): added an autocall option.
3555 3576
3556 3577 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3557 3578 the auto-eval code. Now autocalling is an option, and the code is
3558 3579 also vastly safer. There is no more eval() involved at all.
3559 3580
3560 3581 2003-03-01 Fernando Perez <fperez@colorado.edu>
3561 3582
3562 3583 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3563 3584 dict with named keys instead of a tuple.
3564 3585
3565 3586 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3566 3587
3567 3588 * setup.py (make_shortcut): Fixed message about directories
3568 3589 created during Windows installation (the directories were ok, just
3569 3590 the printed message was misleading). Thanks to Chris Liechti
3570 3591 <cliechti-AT-gmx.net> for the heads up.
3571 3592
3572 3593 2003-02-21 Fernando Perez <fperez@colorado.edu>
3573 3594
3574 3595 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3575 3596 of ValueError exception when checking for auto-execution. This
3576 3597 one is raised by things like Numeric arrays arr.flat when the
3577 3598 array is non-contiguous.
3578 3599
3579 3600 2003-01-31 Fernando Perez <fperez@colorado.edu>
3580 3601
3581 3602 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3582 3603 not return any value at all (even though the command would get
3583 3604 executed).
3584 3605 (xsys): Flush stdout right after printing the command to ensure
3585 3606 proper ordering of commands and command output in the total
3586 3607 output.
3587 3608 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3588 3609 system/getoutput as defaults. The old ones are kept for
3589 3610 compatibility reasons, so no code which uses this library needs
3590 3611 changing.
3591 3612
3592 3613 2003-01-27 *** Released version 0.2.14
3593 3614
3594 3615 2003-01-25 Fernando Perez <fperez@colorado.edu>
3595 3616
3596 3617 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3597 3618 functions defined in previous edit sessions could not be re-edited
3598 3619 (because the temp files were immediately removed). Now temp files
3599 3620 are removed only at IPython's exit.
3600 3621 (Magic.magic_run): Improved @run to perform shell-like expansions
3601 3622 on its arguments (~users and $VARS). With this, @run becomes more
3602 3623 like a normal command-line.
3603 3624
3604 3625 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3605 3626 bugs related to embedding and cleaned up that code. A fairly
3606 3627 important one was the impossibility to access the global namespace
3607 3628 through the embedded IPython (only local variables were visible).
3608 3629
3609 3630 2003-01-14 Fernando Perez <fperez@colorado.edu>
3610 3631
3611 3632 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3612 3633 auto-calling to be a bit more conservative. Now it doesn't get
3613 3634 triggered if any of '!=()<>' are in the rest of the input line, to
3614 3635 allow comparing callables. Thanks to Alex for the heads up.
3615 3636
3616 3637 2003-01-07 Fernando Perez <fperez@colorado.edu>
3617 3638
3618 3639 * IPython/genutils.py (page): fixed estimation of the number of
3619 3640 lines in a string to be paged to simply count newlines. This
3620 3641 prevents over-guessing due to embedded escape sequences. A better
3621 3642 long-term solution would involve stripping out the control chars
3622 3643 for the count, but it's potentially so expensive I just don't
3623 3644 think it's worth doing.
3624 3645
3625 3646 2002-12-19 *** Released version 0.2.14pre50
3626 3647
3627 3648 2002-12-19 Fernando Perez <fperez@colorado.edu>
3628 3649
3629 3650 * tools/release (version): Changed release scripts to inform
3630 3651 Andrea and build a NEWS file with a list of recent changes.
3631 3652
3632 3653 * IPython/ColorANSI.py (__all__): changed terminal detection
3633 3654 code. Seems to work better for xterms without breaking
3634 3655 konsole. Will need more testing to determine if WinXP and Mac OSX
3635 3656 also work ok.
3636 3657
3637 3658 2002-12-18 *** Released version 0.2.14pre49
3638 3659
3639 3660 2002-12-18 Fernando Perez <fperez@colorado.edu>
3640 3661
3641 3662 * Docs: added new info about Mac OSX, from Andrea.
3642 3663
3643 3664 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3644 3665 allow direct plotting of python strings whose format is the same
3645 3666 of gnuplot data files.
3646 3667
3647 3668 2002-12-16 Fernando Perez <fperez@colorado.edu>
3648 3669
3649 3670 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3650 3671 value of exit question to be acknowledged.
3651 3672
3652 3673 2002-12-03 Fernando Perez <fperez@colorado.edu>
3653 3674
3654 3675 * IPython/ipmaker.py: removed generators, which had been added
3655 3676 by mistake in an earlier debugging run. This was causing trouble
3656 3677 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3657 3678 for pointing this out.
3658 3679
3659 3680 2002-11-17 Fernando Perez <fperez@colorado.edu>
3660 3681
3661 3682 * Manual: updated the Gnuplot section.
3662 3683
3663 3684 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3664 3685 a much better split of what goes in Runtime and what goes in
3665 3686 Interactive.
3666 3687
3667 3688 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3668 3689 being imported from iplib.
3669 3690
3670 3691 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3671 3692 for command-passing. Now the global Gnuplot instance is called
3672 3693 'gp' instead of 'g', which was really a far too fragile and
3673 3694 common name.
3674 3695
3675 3696 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3676 3697 bounding boxes generated by Gnuplot for square plots.
3677 3698
3678 3699 * IPython/genutils.py (popkey): new function added. I should
3679 3700 suggest this on c.l.py as a dict method, it seems useful.
3680 3701
3681 3702 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3682 3703 to transparently handle PostScript generation. MUCH better than
3683 3704 the previous plot_eps/replot_eps (which I removed now). The code
3684 3705 is also fairly clean and well documented now (including
3685 3706 docstrings).
3686 3707
3687 3708 2002-11-13 Fernando Perez <fperez@colorado.edu>
3688 3709
3689 3710 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3690 3711 (inconsistent with options).
3691 3712
3692 3713 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3693 3714 manually disabled, I don't know why. Fixed it.
3694 3715 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3695 3716 eps output.
3696 3717
3697 3718 2002-11-12 Fernando Perez <fperez@colorado.edu>
3698 3719
3699 3720 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3700 3721 don't propagate up to caller. Fixes crash reported by François
3701 3722 Pinard.
3702 3723
3703 3724 2002-11-09 Fernando Perez <fperez@colorado.edu>
3704 3725
3705 3726 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3706 3727 history file for new users.
3707 3728 (make_IPython): fixed bug where initial install would leave the
3708 3729 user running in the .ipython dir.
3709 3730 (make_IPython): fixed bug where config dir .ipython would be
3710 3731 created regardless of the given -ipythondir option. Thanks to Cory
3711 3732 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3712 3733
3713 3734 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3714 3735 type confirmations. Will need to use it in all of IPython's code
3715 3736 consistently.
3716 3737
3717 3738 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3718 3739 context to print 31 lines instead of the default 5. This will make
3719 3740 the crash reports extremely detailed in case the problem is in
3720 3741 libraries I don't have access to.
3721 3742
3722 3743 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3723 3744 line of defense' code to still crash, but giving users fair
3724 3745 warning. I don't want internal errors to go unreported: if there's
3725 3746 an internal problem, IPython should crash and generate a full
3726 3747 report.
3727 3748
3728 3749 2002-11-08 Fernando Perez <fperez@colorado.edu>
3729 3750
3730 3751 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3731 3752 otherwise uncaught exceptions which can appear if people set
3732 3753 sys.stdout to something badly broken. Thanks to a crash report
3733 3754 from henni-AT-mail.brainbot.com.
3734 3755
3735 3756 2002-11-04 Fernando Perez <fperez@colorado.edu>
3736 3757
3737 3758 * IPython/iplib.py (InteractiveShell.interact): added
3738 3759 __IPYTHON__active to the builtins. It's a flag which goes on when
3739 3760 the interaction starts and goes off again when it stops. This
3740 3761 allows embedding code to detect being inside IPython. Before this
3741 3762 was done via __IPYTHON__, but that only shows that an IPython
3742 3763 instance has been created.
3743 3764
3744 3765 * IPython/Magic.py (Magic.magic_env): I realized that in a
3745 3766 UserDict, instance.data holds the data as a normal dict. So I
3746 3767 modified @env to return os.environ.data instead of rebuilding a
3747 3768 dict by hand.
3748 3769
3749 3770 2002-11-02 Fernando Perez <fperez@colorado.edu>
3750 3771
3751 3772 * IPython/genutils.py (warn): changed so that level 1 prints no
3752 3773 header. Level 2 is now the default (with 'WARNING' header, as
3753 3774 before). I think I tracked all places where changes were needed in
3754 3775 IPython, but outside code using the old level numbering may have
3755 3776 broken.
3756 3777
3757 3778 * IPython/iplib.py (InteractiveShell.runcode): added this to
3758 3779 handle the tracebacks in SystemExit traps correctly. The previous
3759 3780 code (through interact) was printing more of the stack than
3760 3781 necessary, showing IPython internal code to the user.
3761 3782
3762 3783 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3763 3784 default. Now that the default at the confirmation prompt is yes,
3764 3785 it's not so intrusive. François' argument that ipython sessions
3765 3786 tend to be complex enough not to lose them from an accidental C-d,
3766 3787 is a valid one.
3767 3788
3768 3789 * IPython/iplib.py (InteractiveShell.interact): added a
3769 3790 showtraceback() call to the SystemExit trap, and modified the exit
3770 3791 confirmation to have yes as the default.
3771 3792
3772 3793 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3773 3794 this file. It's been gone from the code for a long time, this was
3774 3795 simply leftover junk.
3775 3796
3776 3797 2002-11-01 Fernando Perez <fperez@colorado.edu>
3777 3798
3778 3799 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3779 3800 added. If set, IPython now traps EOF and asks for
3780 3801 confirmation. After a request by François Pinard.
3781 3802
3782 3803 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3783 3804 of @abort, and with a new (better) mechanism for handling the
3784 3805 exceptions.
3785 3806
3786 3807 2002-10-27 Fernando Perez <fperez@colorado.edu>
3787 3808
3788 3809 * IPython/usage.py (__doc__): updated the --help information and
3789 3810 the ipythonrc file to indicate that -log generates
3790 3811 ./ipython.log. Also fixed the corresponding info in @logstart.
3791 3812 This and several other fixes in the manuals thanks to reports by
3792 3813 François Pinard <pinard-AT-iro.umontreal.ca>.
3793 3814
3794 3815 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3795 3816 refer to @logstart (instead of @log, which doesn't exist).
3796 3817
3797 3818 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3798 3819 AttributeError crash. Thanks to Christopher Armstrong
3799 3820 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3800 3821 introduced recently (in 0.2.14pre37) with the fix to the eval
3801 3822 problem mentioned below.
3802 3823
3803 3824 2002-10-17 Fernando Perez <fperez@colorado.edu>
3804 3825
3805 3826 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3806 3827 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3807 3828
3808 3829 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3809 3830 this function to fix a problem reported by Alex Schmolck. He saw
3810 3831 it with list comprehensions and generators, which were getting
3811 3832 called twice. The real problem was an 'eval' call in testing for
3812 3833 automagic which was evaluating the input line silently.
3813 3834
3814 3835 This is a potentially very nasty bug, if the input has side
3815 3836 effects which must not be repeated. The code is much cleaner now,
3816 3837 without any blanket 'except' left and with a regexp test for
3817 3838 actual function names.
3818 3839
3819 3840 But an eval remains, which I'm not fully comfortable with. I just
3820 3841 don't know how to find out if an expression could be a callable in
3821 3842 the user's namespace without doing an eval on the string. However
3822 3843 that string is now much more strictly checked so that no code
3823 3844 slips by, so the eval should only happen for things that can
3824 3845 really be only function/method names.
3825 3846
3826 3847 2002-10-15 Fernando Perez <fperez@colorado.edu>
3827 3848
3828 3849 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3829 3850 OSX information to main manual, removed README_Mac_OSX file from
3830 3851 distribution. Also updated credits for recent additions.
3831 3852
3832 3853 2002-10-10 Fernando Perez <fperez@colorado.edu>
3833 3854
3834 3855 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3835 3856 terminal-related issues. Many thanks to Andrea Riciputi
3836 3857 <andrea.riciputi-AT-libero.it> for writing it.
3837 3858
3838 3859 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3839 3860 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3840 3861
3841 3862 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3842 3863 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3843 3864 <syver-en-AT-online.no> who both submitted patches for this problem.
3844 3865
3845 3866 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3846 3867 global embedding to make sure that things don't overwrite user
3847 3868 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3848 3869
3849 3870 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3850 3871 compatibility. Thanks to Hayden Callow
3851 3872 <h.callow-AT-elec.canterbury.ac.nz>
3852 3873
3853 3874 2002-10-04 Fernando Perez <fperez@colorado.edu>
3854 3875
3855 3876 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3856 3877 Gnuplot.File objects.
3857 3878
3858 3879 2002-07-23 Fernando Perez <fperez@colorado.edu>
3859 3880
3860 3881 * IPython/genutils.py (timing): Added timings() and timing() for
3861 3882 quick access to the most commonly needed data, the execution
3862 3883 times. Old timing() renamed to timings_out().
3863 3884
3864 3885 2002-07-18 Fernando Perez <fperez@colorado.edu>
3865 3886
3866 3887 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3867 3888 bug with nested instances disrupting the parent's tab completion.
3868 3889
3869 3890 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3870 3891 all_completions code to begin the emacs integration.
3871 3892
3872 3893 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3873 3894 argument to allow titling individual arrays when plotting.
3874 3895
3875 3896 2002-07-15 Fernando Perez <fperez@colorado.edu>
3876 3897
3877 3898 * setup.py (make_shortcut): changed to retrieve the value of
3878 3899 'Program Files' directory from the registry (this value changes in
3879 3900 non-english versions of Windows). Thanks to Thomas Fanslau
3880 3901 <tfanslau-AT-gmx.de> for the report.
3881 3902
3882 3903 2002-07-10 Fernando Perez <fperez@colorado.edu>
3883 3904
3884 3905 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3885 3906 a bug in pdb, which crashes if a line with only whitespace is
3886 3907 entered. Bug report submitted to sourceforge.
3887 3908
3888 3909 2002-07-09 Fernando Perez <fperez@colorado.edu>
3889 3910
3890 3911 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3891 3912 reporting exceptions (it's a bug in inspect.py, I just set a
3892 3913 workaround).
3893 3914
3894 3915 2002-07-08 Fernando Perez <fperez@colorado.edu>
3895 3916
3896 3917 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3897 3918 __IPYTHON__ in __builtins__ to show up in user_ns.
3898 3919
3899 3920 2002-07-03 Fernando Perez <fperez@colorado.edu>
3900 3921
3901 3922 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3902 3923 name from @gp_set_instance to @gp_set_default.
3903 3924
3904 3925 * IPython/ipmaker.py (make_IPython): default editor value set to
3905 3926 '0' (a string), to match the rc file. Otherwise will crash when
3906 3927 .strip() is called on it.
3907 3928
3908 3929
3909 3930 2002-06-28 Fernando Perez <fperez@colorado.edu>
3910 3931
3911 3932 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3912 3933 of files in current directory when a file is executed via
3913 3934 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3914 3935
3915 3936 * setup.py (manfiles): fix for rpm builds, submitted by RA
3916 3937 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3917 3938
3918 3939 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3919 3940 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3920 3941 string!). A. Schmolck caught this one.
3921 3942
3922 3943 2002-06-27 Fernando Perez <fperez@colorado.edu>
3923 3944
3924 3945 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3925 3946 defined files at the cmd line. __name__ wasn't being set to
3926 3947 __main__.
3927 3948
3928 3949 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3929 3950 regular lists and tuples besides Numeric arrays.
3930 3951
3931 3952 * IPython/Prompts.py (CachedOutput.__call__): Added output
3932 3953 supression for input ending with ';'. Similar to Mathematica and
3933 3954 Matlab. The _* vars and Out[] list are still updated, just like
3934 3955 Mathematica behaves.
3935 3956
3936 3957 2002-06-25 Fernando Perez <fperez@colorado.edu>
3937 3958
3938 3959 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3939 3960 .ini extensions for profiels under Windows.
3940 3961
3941 3962 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3942 3963 string form. Fix contributed by Alexander Schmolck
3943 3964 <a.schmolck-AT-gmx.net>
3944 3965
3945 3966 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3946 3967 pre-configured Gnuplot instance.
3947 3968
3948 3969 2002-06-21 Fernando Perez <fperez@colorado.edu>
3949 3970
3950 3971 * IPython/numutils.py (exp_safe): new function, works around the
3951 3972 underflow problems in Numeric.
3952 3973 (log2): New fn. Safe log in base 2: returns exact integer answer
3953 3974 for exact integer powers of 2.
3954 3975
3955 3976 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3956 3977 properly.
3957 3978
3958 3979 2002-06-20 Fernando Perez <fperez@colorado.edu>
3959 3980
3960 3981 * IPython/genutils.py (timing): new function like
3961 3982 Mathematica's. Similar to time_test, but returns more info.
3962 3983
3963 3984 2002-06-18 Fernando Perez <fperez@colorado.edu>
3964 3985
3965 3986 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3966 3987 according to Mike Heeter's suggestions.
3967 3988
3968 3989 2002-06-16 Fernando Perez <fperez@colorado.edu>
3969 3990
3970 3991 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3971 3992 system. GnuplotMagic is gone as a user-directory option. New files
3972 3993 make it easier to use all the gnuplot stuff both from external
3973 3994 programs as well as from IPython. Had to rewrite part of
3974 3995 hardcopy() b/c of a strange bug: often the ps files simply don't
3975 3996 get created, and require a repeat of the command (often several
3976 3997 times).
3977 3998
3978 3999 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3979 4000 resolve output channel at call time, so that if sys.stderr has
3980 4001 been redirected by user this gets honored.
3981 4002
3982 4003 2002-06-13 Fernando Perez <fperez@colorado.edu>
3983 4004
3984 4005 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3985 4006 IPShell. Kept a copy with the old names to avoid breaking people's
3986 4007 embedded code.
3987 4008
3988 4009 * IPython/ipython: simplified it to the bare minimum after
3989 4010 Holger's suggestions. Added info about how to use it in
3990 4011 PYTHONSTARTUP.
3991 4012
3992 4013 * IPython/Shell.py (IPythonShell): changed the options passing
3993 4014 from a string with funky %s replacements to a straight list. Maybe
3994 4015 a bit more typing, but it follows sys.argv conventions, so there's
3995 4016 less special-casing to remember.
3996 4017
3997 4018 2002-06-12 Fernando Perez <fperez@colorado.edu>
3998 4019
3999 4020 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4000 4021 command. Thanks to a suggestion by Mike Heeter.
4001 4022 (Magic.magic_pfile): added behavior to look at filenames if given
4002 4023 arg is not a defined object.
4003 4024 (Magic.magic_save): New @save function to save code snippets. Also
4004 4025 a Mike Heeter idea.
4005 4026
4006 4027 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4007 4028 plot() and replot(). Much more convenient now, especially for
4008 4029 interactive use.
4009 4030
4010 4031 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4011 4032 filenames.
4012 4033
4013 4034 2002-06-02 Fernando Perez <fperez@colorado.edu>
4014 4035
4015 4036 * IPython/Struct.py (Struct.__init__): modified to admit
4016 4037 initialization via another struct.
4017 4038
4018 4039 * IPython/genutils.py (SystemExec.__init__): New stateful
4019 4040 interface to xsys and bq. Useful for writing system scripts.
4020 4041
4021 4042 2002-05-30 Fernando Perez <fperez@colorado.edu>
4022 4043
4023 4044 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4024 4045 documents. This will make the user download smaller (it's getting
4025 4046 too big).
4026 4047
4027 4048 2002-05-29 Fernando Perez <fperez@colorado.edu>
4028 4049
4029 4050 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4030 4051 fix problems with shelve and pickle. Seems to work, but I don't
4031 4052 know if corner cases break it. Thanks to Mike Heeter
4032 4053 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4033 4054
4034 4055 2002-05-24 Fernando Perez <fperez@colorado.edu>
4035 4056
4036 4057 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4037 4058 macros having broken.
4038 4059
4039 4060 2002-05-21 Fernando Perez <fperez@colorado.edu>
4040 4061
4041 4062 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4042 4063 introduced logging bug: all history before logging started was
4043 4064 being written one character per line! This came from the redesign
4044 4065 of the input history as a special list which slices to strings,
4045 4066 not to lists.
4046 4067
4047 4068 2002-05-20 Fernando Perez <fperez@colorado.edu>
4048 4069
4049 4070 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4050 4071 be an attribute of all classes in this module. The design of these
4051 4072 classes needs some serious overhauling.
4052 4073
4053 4074 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4054 4075 which was ignoring '_' in option names.
4055 4076
4056 4077 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4057 4078 'Verbose_novars' to 'Context' and made it the new default. It's a
4058 4079 bit more readable and also safer than verbose.
4059 4080
4060 4081 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4061 4082 triple-quoted strings.
4062 4083
4063 4084 * IPython/OInspect.py (__all__): new module exposing the object
4064 4085 introspection facilities. Now the corresponding magics are dummy
4065 4086 wrappers around this. Having this module will make it much easier
4066 4087 to put these functions into our modified pdb.
4067 4088 This new object inspector system uses the new colorizing module,
4068 4089 so source code and other things are nicely syntax highlighted.
4069 4090
4070 4091 2002-05-18 Fernando Perez <fperez@colorado.edu>
4071 4092
4072 4093 * IPython/ColorANSI.py: Split the coloring tools into a separate
4073 4094 module so I can use them in other code easier (they were part of
4074 4095 ultraTB).
4075 4096
4076 4097 2002-05-17 Fernando Perez <fperez@colorado.edu>
4077 4098
4078 4099 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4079 4100 fixed it to set the global 'g' also to the called instance, as
4080 4101 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4081 4102 user's 'g' variables).
4082 4103
4083 4104 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4084 4105 global variables (aliases to _ih,_oh) so that users which expect
4085 4106 In[5] or Out[7] to work aren't unpleasantly surprised.
4086 4107 (InputList.__getslice__): new class to allow executing slices of
4087 4108 input history directly. Very simple class, complements the use of
4088 4109 macros.
4089 4110
4090 4111 2002-05-16 Fernando Perez <fperez@colorado.edu>
4091 4112
4092 4113 * setup.py (docdirbase): make doc directory be just doc/IPython
4093 4114 without version numbers, it will reduce clutter for users.
4094 4115
4095 4116 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4096 4117 execfile call to prevent possible memory leak. See for details:
4097 4118 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4098 4119
4099 4120 2002-05-15 Fernando Perez <fperez@colorado.edu>
4100 4121
4101 4122 * IPython/Magic.py (Magic.magic_psource): made the object
4102 4123 introspection names be more standard: pdoc, pdef, pfile and
4103 4124 psource. They all print/page their output, and it makes
4104 4125 remembering them easier. Kept old names for compatibility as
4105 4126 aliases.
4106 4127
4107 4128 2002-05-14 Fernando Perez <fperez@colorado.edu>
4108 4129
4109 4130 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4110 4131 what the mouse problem was. The trick is to use gnuplot with temp
4111 4132 files and NOT with pipes (for data communication), because having
4112 4133 both pipes and the mouse on is bad news.
4113 4134
4114 4135 2002-05-13 Fernando Perez <fperez@colorado.edu>
4115 4136
4116 4137 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4117 4138 bug. Information would be reported about builtins even when
4118 4139 user-defined functions overrode them.
4119 4140
4120 4141 2002-05-11 Fernando Perez <fperez@colorado.edu>
4121 4142
4122 4143 * IPython/__init__.py (__all__): removed FlexCompleter from
4123 4144 __all__ so that things don't fail in platforms without readline.
4124 4145
4125 4146 2002-05-10 Fernando Perez <fperez@colorado.edu>
4126 4147
4127 4148 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4128 4149 it requires Numeric, effectively making Numeric a dependency for
4129 4150 IPython.
4130 4151
4131 4152 * Released 0.2.13
4132 4153
4133 4154 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4134 4155 profiler interface. Now all the major options from the profiler
4135 4156 module are directly supported in IPython, both for single
4136 4157 expressions (@prun) and for full programs (@run -p).
4137 4158
4138 4159 2002-05-09 Fernando Perez <fperez@colorado.edu>
4139 4160
4140 4161 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4141 4162 magic properly formatted for screen.
4142 4163
4143 4164 * setup.py (make_shortcut): Changed things to put pdf version in
4144 4165 doc/ instead of doc/manual (had to change lyxport a bit).
4145 4166
4146 4167 * IPython/Magic.py (Profile.string_stats): made profile runs go
4147 4168 through pager (they are long and a pager allows searching, saving,
4148 4169 etc.)
4149 4170
4150 4171 2002-05-08 Fernando Perez <fperez@colorado.edu>
4151 4172
4152 4173 * Released 0.2.12
4153 4174
4154 4175 2002-05-06 Fernando Perez <fperez@colorado.edu>
4155 4176
4156 4177 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4157 4178 introduced); 'hist n1 n2' was broken.
4158 4179 (Magic.magic_pdb): added optional on/off arguments to @pdb
4159 4180 (Magic.magic_run): added option -i to @run, which executes code in
4160 4181 the IPython namespace instead of a clean one. Also added @irun as
4161 4182 an alias to @run -i.
4162 4183
4163 4184 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4164 4185 fixed (it didn't really do anything, the namespaces were wrong).
4165 4186
4166 4187 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4167 4188
4168 4189 * IPython/__init__.py (__all__): Fixed package namespace, now
4169 4190 'import IPython' does give access to IPython.<all> as
4170 4191 expected. Also renamed __release__ to Release.
4171 4192
4172 4193 * IPython/Debugger.py (__license__): created new Pdb class which
4173 4194 functions like a drop-in for the normal pdb.Pdb but does NOT
4174 4195 import readline by default. This way it doesn't muck up IPython's
4175 4196 readline handling, and now tab-completion finally works in the
4176 4197 debugger -- sort of. It completes things globally visible, but the
4177 4198 completer doesn't track the stack as pdb walks it. That's a bit
4178 4199 tricky, and I'll have to implement it later.
4179 4200
4180 4201 2002-05-05 Fernando Perez <fperez@colorado.edu>
4181 4202
4182 4203 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4183 4204 magic docstrings when printed via ? (explicit \'s were being
4184 4205 printed).
4185 4206
4186 4207 * IPython/ipmaker.py (make_IPython): fixed namespace
4187 4208 identification bug. Now variables loaded via logs or command-line
4188 4209 files are recognized in the interactive namespace by @who.
4189 4210
4190 4211 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4191 4212 log replay system stemming from the string form of Structs.
4192 4213
4193 4214 * IPython/Magic.py (Macro.__init__): improved macros to properly
4194 4215 handle magic commands in them.
4195 4216 (Magic.magic_logstart): usernames are now expanded so 'logstart
4196 4217 ~/mylog' now works.
4197 4218
4198 4219 * IPython/iplib.py (complete): fixed bug where paths starting with
4199 4220 '/' would be completed as magic names.
4200 4221
4201 4222 2002-05-04 Fernando Perez <fperez@colorado.edu>
4202 4223
4203 4224 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4204 4225 allow running full programs under the profiler's control.
4205 4226
4206 4227 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4207 4228 mode to report exceptions verbosely but without formatting
4208 4229 variables. This addresses the issue of ipython 'freezing' (it's
4209 4230 not frozen, but caught in an expensive formatting loop) when huge
4210 4231 variables are in the context of an exception.
4211 4232 (VerboseTB.text): Added '--->' markers at line where exception was
4212 4233 triggered. Much clearer to read, especially in NoColor modes.
4213 4234
4214 4235 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4215 4236 implemented in reverse when changing to the new parse_options().
4216 4237
4217 4238 2002-05-03 Fernando Perez <fperez@colorado.edu>
4218 4239
4219 4240 * IPython/Magic.py (Magic.parse_options): new function so that
4220 4241 magics can parse options easier.
4221 4242 (Magic.magic_prun): new function similar to profile.run(),
4222 4243 suggested by Chris Hart.
4223 4244 (Magic.magic_cd): fixed behavior so that it only changes if
4224 4245 directory actually is in history.
4225 4246
4226 4247 * IPython/usage.py (__doc__): added information about potential
4227 4248 slowness of Verbose exception mode when there are huge data
4228 4249 structures to be formatted (thanks to Archie Paulson).
4229 4250
4230 4251 * IPython/ipmaker.py (make_IPython): Changed default logging
4231 4252 (when simply called with -log) to use curr_dir/ipython.log in
4232 4253 rotate mode. Fixed crash which was occuring with -log before
4233 4254 (thanks to Jim Boyle).
4234 4255
4235 4256 2002-05-01 Fernando Perez <fperez@colorado.edu>
4236 4257
4237 4258 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4238 4259 was nasty -- though somewhat of a corner case).
4239 4260
4240 4261 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4241 4262 text (was a bug).
4242 4263
4243 4264 2002-04-30 Fernando Perez <fperez@colorado.edu>
4244 4265
4245 4266 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4246 4267 a print after ^D or ^C from the user so that the In[] prompt
4247 4268 doesn't over-run the gnuplot one.
4248 4269
4249 4270 2002-04-29 Fernando Perez <fperez@colorado.edu>
4250 4271
4251 4272 * Released 0.2.10
4252 4273
4253 4274 * IPython/__release__.py (version): get date dynamically.
4254 4275
4255 4276 * Misc. documentation updates thanks to Arnd's comments. Also ran
4256 4277 a full spellcheck on the manual (hadn't been done in a while).
4257 4278
4258 4279 2002-04-27 Fernando Perez <fperez@colorado.edu>
4259 4280
4260 4281 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4261 4282 starting a log in mid-session would reset the input history list.
4262 4283
4263 4284 2002-04-26 Fernando Perez <fperez@colorado.edu>
4264 4285
4265 4286 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4266 4287 all files were being included in an update. Now anything in
4267 4288 UserConfig that matches [A-Za-z]*.py will go (this excludes
4268 4289 __init__.py)
4269 4290
4270 4291 2002-04-25 Fernando Perez <fperez@colorado.edu>
4271 4292
4272 4293 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4273 4294 to __builtins__ so that any form of embedded or imported code can
4274 4295 test for being inside IPython.
4275 4296
4276 4297 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4277 4298 changed to GnuplotMagic because it's now an importable module,
4278 4299 this makes the name follow that of the standard Gnuplot module.
4279 4300 GnuplotMagic can now be loaded at any time in mid-session.
4280 4301
4281 4302 2002-04-24 Fernando Perez <fperez@colorado.edu>
4282 4303
4283 4304 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4284 4305 the globals (IPython has its own namespace) and the
4285 4306 PhysicalQuantity stuff is much better anyway.
4286 4307
4287 4308 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4288 4309 embedding example to standard user directory for
4289 4310 distribution. Also put it in the manual.
4290 4311
4291 4312 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4292 4313 instance as first argument (so it doesn't rely on some obscure
4293 4314 hidden global).
4294 4315
4295 4316 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4296 4317 delimiters. While it prevents ().TAB from working, it allows
4297 4318 completions in open (... expressions. This is by far a more common
4298 4319 case.
4299 4320
4300 4321 2002-04-23 Fernando Perez <fperez@colorado.edu>
4301 4322
4302 4323 * IPython/Extensions/InterpreterPasteInput.py: new
4303 4324 syntax-processing module for pasting lines with >>> or ... at the
4304 4325 start.
4305 4326
4306 4327 * IPython/Extensions/PhysicalQ_Interactive.py
4307 4328 (PhysicalQuantityInteractive.__int__): fixed to work with either
4308 4329 Numeric or math.
4309 4330
4310 4331 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4311 4332 provided profiles. Now we have:
4312 4333 -math -> math module as * and cmath with its own namespace.
4313 4334 -numeric -> Numeric as *, plus gnuplot & grace
4314 4335 -physics -> same as before
4315 4336
4316 4337 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4317 4338 user-defined magics wouldn't be found by @magic if they were
4318 4339 defined as class methods. Also cleaned up the namespace search
4319 4340 logic and the string building (to use %s instead of many repeated
4320 4341 string adds).
4321 4342
4322 4343 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4323 4344 of user-defined magics to operate with class methods (cleaner, in
4324 4345 line with the gnuplot code).
4325 4346
4326 4347 2002-04-22 Fernando Perez <fperez@colorado.edu>
4327 4348
4328 4349 * setup.py: updated dependency list so that manual is updated when
4329 4350 all included files change.
4330 4351
4331 4352 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4332 4353 the delimiter removal option (the fix is ugly right now).
4333 4354
4334 4355 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4335 4356 all of the math profile (quicker loading, no conflict between
4336 4357 g-9.8 and g-gnuplot).
4337 4358
4338 4359 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4339 4360 name of post-mortem files to IPython_crash_report.txt.
4340 4361
4341 4362 * Cleanup/update of the docs. Added all the new readline info and
4342 4363 formatted all lists as 'real lists'.
4343 4364
4344 4365 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4345 4366 tab-completion options, since the full readline parse_and_bind is
4346 4367 now accessible.
4347 4368
4348 4369 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4349 4370 handling of readline options. Now users can specify any string to
4350 4371 be passed to parse_and_bind(), as well as the delimiters to be
4351 4372 removed.
4352 4373 (InteractiveShell.__init__): Added __name__ to the global
4353 4374 namespace so that things like Itpl which rely on its existence
4354 4375 don't crash.
4355 4376 (InteractiveShell._prefilter): Defined the default with a _ so
4356 4377 that prefilter() is easier to override, while the default one
4357 4378 remains available.
4358 4379
4359 4380 2002-04-18 Fernando Perez <fperez@colorado.edu>
4360 4381
4361 4382 * Added information about pdb in the docs.
4362 4383
4363 4384 2002-04-17 Fernando Perez <fperez@colorado.edu>
4364 4385
4365 4386 * IPython/ipmaker.py (make_IPython): added rc_override option to
4366 4387 allow passing config options at creation time which may override
4367 4388 anything set in the config files or command line. This is
4368 4389 particularly useful for configuring embedded instances.
4369 4390
4370 4391 2002-04-15 Fernando Perez <fperez@colorado.edu>
4371 4392
4372 4393 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4373 4394 crash embedded instances because of the input cache falling out of
4374 4395 sync with the output counter.
4375 4396
4376 4397 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4377 4398 mode which calls pdb after an uncaught exception in IPython itself.
4378 4399
4379 4400 2002-04-14 Fernando Perez <fperez@colorado.edu>
4380 4401
4381 4402 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4382 4403 readline, fix it back after each call.
4383 4404
4384 4405 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4385 4406 method to force all access via __call__(), which guarantees that
4386 4407 traceback references are properly deleted.
4387 4408
4388 4409 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4389 4410 improve printing when pprint is in use.
4390 4411
4391 4412 2002-04-13 Fernando Perez <fperez@colorado.edu>
4392 4413
4393 4414 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4394 4415 exceptions aren't caught anymore. If the user triggers one, he
4395 4416 should know why he's doing it and it should go all the way up,
4396 4417 just like any other exception. So now @abort will fully kill the
4397 4418 embedded interpreter and the embedding code (unless that happens
4398 4419 to catch SystemExit).
4399 4420
4400 4421 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4401 4422 and a debugger() method to invoke the interactive pdb debugger
4402 4423 after printing exception information. Also added the corresponding
4403 4424 -pdb option and @pdb magic to control this feature, and updated
4404 4425 the docs. After a suggestion from Christopher Hart
4405 4426 (hart-AT-caltech.edu).
4406 4427
4407 4428 2002-04-12 Fernando Perez <fperez@colorado.edu>
4408 4429
4409 4430 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4410 4431 the exception handlers defined by the user (not the CrashHandler)
4411 4432 so that user exceptions don't trigger an ipython bug report.
4412 4433
4413 4434 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4414 4435 configurable (it should have always been so).
4415 4436
4416 4437 2002-03-26 Fernando Perez <fperez@colorado.edu>
4417 4438
4418 4439 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4419 4440 and there to fix embedding namespace issues. This should all be
4420 4441 done in a more elegant way.
4421 4442
4422 4443 2002-03-25 Fernando Perez <fperez@colorado.edu>
4423 4444
4424 4445 * IPython/genutils.py (get_home_dir): Try to make it work under
4425 4446 win9x also.
4426 4447
4427 4448 2002-03-20 Fernando Perez <fperez@colorado.edu>
4428 4449
4429 4450 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4430 4451 sys.displayhook untouched upon __init__.
4431 4452
4432 4453 2002-03-19 Fernando Perez <fperez@colorado.edu>
4433 4454
4434 4455 * Released 0.2.9 (for embedding bug, basically).
4435 4456
4436 4457 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4437 4458 exceptions so that enclosing shell's state can be restored.
4438 4459
4439 4460 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4440 4461 naming conventions in the .ipython/ dir.
4441 4462
4442 4463 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4443 4464 from delimiters list so filenames with - in them get expanded.
4444 4465
4445 4466 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4446 4467 sys.displayhook not being properly restored after an embedded call.
4447 4468
4448 4469 2002-03-18 Fernando Perez <fperez@colorado.edu>
4449 4470
4450 4471 * Released 0.2.8
4451 4472
4452 4473 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4453 4474 some files weren't being included in a -upgrade.
4454 4475 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4455 4476 on' so that the first tab completes.
4456 4477 (InteractiveShell.handle_magic): fixed bug with spaces around
4457 4478 quotes breaking many magic commands.
4458 4479
4459 4480 * setup.py: added note about ignoring the syntax error messages at
4460 4481 installation.
4461 4482
4462 4483 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4463 4484 streamlining the gnuplot interface, now there's only one magic @gp.
4464 4485
4465 4486 2002-03-17 Fernando Perez <fperez@colorado.edu>
4466 4487
4467 4488 * IPython/UserConfig/magic_gnuplot.py: new name for the
4468 4489 example-magic_pm.py file. Much enhanced system, now with a shell
4469 4490 for communicating directly with gnuplot, one command at a time.
4470 4491
4471 4492 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4472 4493 setting __name__=='__main__'.
4473 4494
4474 4495 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4475 4496 mini-shell for accessing gnuplot from inside ipython. Should
4476 4497 extend it later for grace access too. Inspired by Arnd's
4477 4498 suggestion.
4478 4499
4479 4500 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4480 4501 calling magic functions with () in their arguments. Thanks to Arnd
4481 4502 Baecker for pointing this to me.
4482 4503
4483 4504 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4484 4505 infinitely for integer or complex arrays (only worked with floats).
4485 4506
4486 4507 2002-03-16 Fernando Perez <fperez@colorado.edu>
4487 4508
4488 4509 * setup.py: Merged setup and setup_windows into a single script
4489 4510 which properly handles things for windows users.
4490 4511
4491 4512 2002-03-15 Fernando Perez <fperez@colorado.edu>
4492 4513
4493 4514 * Big change to the manual: now the magics are all automatically
4494 4515 documented. This information is generated from their docstrings
4495 4516 and put in a latex file included by the manual lyx file. This way
4496 4517 we get always up to date information for the magics. The manual
4497 4518 now also has proper version information, also auto-synced.
4498 4519
4499 4520 For this to work, an undocumented --magic_docstrings option was added.
4500 4521
4501 4522 2002-03-13 Fernando Perez <fperez@colorado.edu>
4502 4523
4503 4524 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4504 4525 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4505 4526
4506 4527 2002-03-12 Fernando Perez <fperez@colorado.edu>
4507 4528
4508 4529 * IPython/ultraTB.py (TermColors): changed color escapes again to
4509 4530 fix the (old, reintroduced) line-wrapping bug. Basically, if
4510 4531 \001..\002 aren't given in the color escapes, lines get wrapped
4511 4532 weirdly. But giving those screws up old xterms and emacs terms. So
4512 4533 I added some logic for emacs terms to be ok, but I can't identify old
4513 4534 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4514 4535
4515 4536 2002-03-10 Fernando Perez <fperez@colorado.edu>
4516 4537
4517 4538 * IPython/usage.py (__doc__): Various documentation cleanups and
4518 4539 updates, both in usage docstrings and in the manual.
4519 4540
4520 4541 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4521 4542 handling of caching. Set minimum acceptabe value for having a
4522 4543 cache at 20 values.
4523 4544
4524 4545 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4525 4546 install_first_time function to a method, renamed it and added an
4526 4547 'upgrade' mode. Now people can update their config directory with
4527 4548 a simple command line switch (-upgrade, also new).
4528 4549
4529 4550 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4530 4551 @file (convenient for automagic users under Python >= 2.2).
4531 4552 Removed @files (it seemed more like a plural than an abbrev. of
4532 4553 'file show').
4533 4554
4534 4555 * IPython/iplib.py (install_first_time): Fixed crash if there were
4535 4556 backup files ('~') in .ipython/ install directory.
4536 4557
4537 4558 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4538 4559 system. Things look fine, but these changes are fairly
4539 4560 intrusive. Test them for a few days.
4540 4561
4541 4562 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4542 4563 the prompts system. Now all in/out prompt strings are user
4543 4564 controllable. This is particularly useful for embedding, as one
4544 4565 can tag embedded instances with particular prompts.
4545 4566
4546 4567 Also removed global use of sys.ps1/2, which now allows nested
4547 4568 embeddings without any problems. Added command-line options for
4548 4569 the prompt strings.
4549 4570
4550 4571 2002-03-08 Fernando Perez <fperez@colorado.edu>
4551 4572
4552 4573 * IPython/UserConfig/example-embed-short.py (ipshell): added
4553 4574 example file with the bare minimum code for embedding.
4554 4575
4555 4576 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4556 4577 functionality for the embeddable shell to be activated/deactivated
4557 4578 either globally or at each call.
4558 4579
4559 4580 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4560 4581 rewriting the prompt with '--->' for auto-inputs with proper
4561 4582 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4562 4583 this is handled by the prompts class itself, as it should.
4563 4584
4564 4585 2002-03-05 Fernando Perez <fperez@colorado.edu>
4565 4586
4566 4587 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4567 4588 @logstart to avoid name clashes with the math log function.
4568 4589
4569 4590 * Big updates to X/Emacs section of the manual.
4570 4591
4571 4592 * Removed ipython_emacs. Milan explained to me how to pass
4572 4593 arguments to ipython through Emacs. Some day I'm going to end up
4573 4594 learning some lisp...
4574 4595
4575 4596 2002-03-04 Fernando Perez <fperez@colorado.edu>
4576 4597
4577 4598 * IPython/ipython_emacs: Created script to be used as the
4578 4599 py-python-command Emacs variable so we can pass IPython
4579 4600 parameters. I can't figure out how to tell Emacs directly to pass
4580 4601 parameters to IPython, so a dummy shell script will do it.
4581 4602
4582 4603 Other enhancements made for things to work better under Emacs'
4583 4604 various types of terminals. Many thanks to Milan Zamazal
4584 4605 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4585 4606
4586 4607 2002-03-01 Fernando Perez <fperez@colorado.edu>
4587 4608
4588 4609 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4589 4610 that loading of readline is now optional. This gives better
4590 4611 control to emacs users.
4591 4612
4592 4613 * IPython/ultraTB.py (__date__): Modified color escape sequences
4593 4614 and now things work fine under xterm and in Emacs' term buffers
4594 4615 (though not shell ones). Well, in emacs you get colors, but all
4595 4616 seem to be 'light' colors (no difference between dark and light
4596 4617 ones). But the garbage chars are gone, and also in xterms. It
4597 4618 seems that now I'm using 'cleaner' ansi sequences.
4598 4619
4599 4620 2002-02-21 Fernando Perez <fperez@colorado.edu>
4600 4621
4601 4622 * Released 0.2.7 (mainly to publish the scoping fix).
4602 4623
4603 4624 * IPython/Logger.py (Logger.logstate): added. A corresponding
4604 4625 @logstate magic was created.
4605 4626
4606 4627 * IPython/Magic.py: fixed nested scoping problem under Python
4607 4628 2.1.x (automagic wasn't working).
4608 4629
4609 4630 2002-02-20 Fernando Perez <fperez@colorado.edu>
4610 4631
4611 4632 * Released 0.2.6.
4612 4633
4613 4634 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4614 4635 option so that logs can come out without any headers at all.
4615 4636
4616 4637 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4617 4638 SciPy.
4618 4639
4619 4640 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4620 4641 that embedded IPython calls don't require vars() to be explicitly
4621 4642 passed. Now they are extracted from the caller's frame (code
4622 4643 snatched from Eric Jones' weave). Added better documentation to
4623 4644 the section on embedding and the example file.
4624 4645
4625 4646 * IPython/genutils.py (page): Changed so that under emacs, it just
4626 4647 prints the string. You can then page up and down in the emacs
4627 4648 buffer itself. This is how the builtin help() works.
4628 4649
4629 4650 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4630 4651 macro scoping: macros need to be executed in the user's namespace
4631 4652 to work as if they had been typed by the user.
4632 4653
4633 4654 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4634 4655 execute automatically (no need to type 'exec...'). They then
4635 4656 behave like 'true macros'. The printing system was also modified
4636 4657 for this to work.
4637 4658
4638 4659 2002-02-19 Fernando Perez <fperez@colorado.edu>
4639 4660
4640 4661 * IPython/genutils.py (page_file): new function for paging files
4641 4662 in an OS-independent way. Also necessary for file viewing to work
4642 4663 well inside Emacs buffers.
4643 4664 (page): Added checks for being in an emacs buffer.
4644 4665 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4645 4666 same bug in iplib.
4646 4667
4647 4668 2002-02-18 Fernando Perez <fperez@colorado.edu>
4648 4669
4649 4670 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4650 4671 of readline so that IPython can work inside an Emacs buffer.
4651 4672
4652 4673 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4653 4674 method signatures (they weren't really bugs, but it looks cleaner
4654 4675 and keeps PyChecker happy).
4655 4676
4656 4677 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4657 4678 for implementing various user-defined hooks. Currently only
4658 4679 display is done.
4659 4680
4660 4681 * IPython/Prompts.py (CachedOutput._display): changed display
4661 4682 functions so that they can be dynamically changed by users easily.
4662 4683
4663 4684 * IPython/Extensions/numeric_formats.py (num_display): added an
4664 4685 extension for printing NumPy arrays in flexible manners. It
4665 4686 doesn't do anything yet, but all the structure is in
4666 4687 place. Ultimately the plan is to implement output format control
4667 4688 like in Octave.
4668 4689
4669 4690 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4670 4691 methods are found at run-time by all the automatic machinery.
4671 4692
4672 4693 2002-02-17 Fernando Perez <fperez@colorado.edu>
4673 4694
4674 4695 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4675 4696 whole file a little.
4676 4697
4677 4698 * ToDo: closed this document. Now there's a new_design.lyx
4678 4699 document for all new ideas. Added making a pdf of it for the
4679 4700 end-user distro.
4680 4701
4681 4702 * IPython/Logger.py (Logger.switch_log): Created this to replace
4682 4703 logon() and logoff(). It also fixes a nasty crash reported by
4683 4704 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4684 4705
4685 4706 * IPython/iplib.py (complete): got auto-completion to work with
4686 4707 automagic (I had wanted this for a long time).
4687 4708
4688 4709 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4689 4710 to @file, since file() is now a builtin and clashes with automagic
4690 4711 for @file.
4691 4712
4692 4713 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4693 4714 of this was previously in iplib, which had grown to more than 2000
4694 4715 lines, way too long. No new functionality, but it makes managing
4695 4716 the code a bit easier.
4696 4717
4697 4718 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4698 4719 information to crash reports.
4699 4720
4700 4721 2002-02-12 Fernando Perez <fperez@colorado.edu>
4701 4722
4702 4723 * Released 0.2.5.
4703 4724
4704 4725 2002-02-11 Fernando Perez <fperez@colorado.edu>
4705 4726
4706 4727 * Wrote a relatively complete Windows installer. It puts
4707 4728 everything in place, creates Start Menu entries and fixes the
4708 4729 color issues. Nothing fancy, but it works.
4709 4730
4710 4731 2002-02-10 Fernando Perez <fperez@colorado.edu>
4711 4732
4712 4733 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4713 4734 os.path.expanduser() call so that we can type @run ~/myfile.py and
4714 4735 have thigs work as expected.
4715 4736
4716 4737 * IPython/genutils.py (page): fixed exception handling so things
4717 4738 work both in Unix and Windows correctly. Quitting a pager triggers
4718 4739 an IOError/broken pipe in Unix, and in windows not finding a pager
4719 4740 is also an IOError, so I had to actually look at the return value
4720 4741 of the exception, not just the exception itself. Should be ok now.
4721 4742
4722 4743 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4723 4744 modified to allow case-insensitive color scheme changes.
4724 4745
4725 4746 2002-02-09 Fernando Perez <fperez@colorado.edu>
4726 4747
4727 4748 * IPython/genutils.py (native_line_ends): new function to leave
4728 4749 user config files with os-native line-endings.
4729 4750
4730 4751 * README and manual updates.
4731 4752
4732 4753 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4733 4754 instead of StringType to catch Unicode strings.
4734 4755
4735 4756 * IPython/genutils.py (filefind): fixed bug for paths with
4736 4757 embedded spaces (very common in Windows).
4737 4758
4738 4759 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4739 4760 files under Windows, so that they get automatically associated
4740 4761 with a text editor. Windows makes it a pain to handle
4741 4762 extension-less files.
4742 4763
4743 4764 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4744 4765 warning about readline only occur for Posix. In Windows there's no
4745 4766 way to get readline, so why bother with the warning.
4746 4767
4747 4768 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4748 4769 for __str__ instead of dir(self), since dir() changed in 2.2.
4749 4770
4750 4771 * Ported to Windows! Tested on XP, I suspect it should work fine
4751 4772 on NT/2000, but I don't think it will work on 98 et al. That
4752 4773 series of Windows is such a piece of junk anyway that I won't try
4753 4774 porting it there. The XP port was straightforward, showed a few
4754 4775 bugs here and there (fixed all), in particular some string
4755 4776 handling stuff which required considering Unicode strings (which
4756 4777 Windows uses). This is good, but hasn't been too tested :) No
4757 4778 fancy installer yet, I'll put a note in the manual so people at
4758 4779 least make manually a shortcut.
4759 4780
4760 4781 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4761 4782 into a single one, "colors". This now controls both prompt and
4762 4783 exception color schemes, and can be changed both at startup
4763 4784 (either via command-line switches or via ipythonrc files) and at
4764 4785 runtime, with @colors.
4765 4786 (Magic.magic_run): renamed @prun to @run and removed the old
4766 4787 @run. The two were too similar to warrant keeping both.
4767 4788
4768 4789 2002-02-03 Fernando Perez <fperez@colorado.edu>
4769 4790
4770 4791 * IPython/iplib.py (install_first_time): Added comment on how to
4771 4792 configure the color options for first-time users. Put a <return>
4772 4793 request at the end so that small-terminal users get a chance to
4773 4794 read the startup info.
4774 4795
4775 4796 2002-01-23 Fernando Perez <fperez@colorado.edu>
4776 4797
4777 4798 * IPython/iplib.py (CachedOutput.update): Changed output memory
4778 4799 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4779 4800 input history we still use _i. Did this b/c these variable are
4780 4801 very commonly used in interactive work, so the less we need to
4781 4802 type the better off we are.
4782 4803 (Magic.magic_prun): updated @prun to better handle the namespaces
4783 4804 the file will run in, including a fix for __name__ not being set
4784 4805 before.
4785 4806
4786 4807 2002-01-20 Fernando Perez <fperez@colorado.edu>
4787 4808
4788 4809 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4789 4810 extra garbage for Python 2.2. Need to look more carefully into
4790 4811 this later.
4791 4812
4792 4813 2002-01-19 Fernando Perez <fperez@colorado.edu>
4793 4814
4794 4815 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4795 4816 display SyntaxError exceptions properly formatted when they occur
4796 4817 (they can be triggered by imported code).
4797 4818
4798 4819 2002-01-18 Fernando Perez <fperez@colorado.edu>
4799 4820
4800 4821 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4801 4822 SyntaxError exceptions are reported nicely formatted, instead of
4802 4823 spitting out only offset information as before.
4803 4824 (Magic.magic_prun): Added the @prun function for executing
4804 4825 programs with command line args inside IPython.
4805 4826
4806 4827 2002-01-16 Fernando Perez <fperez@colorado.edu>
4807 4828
4808 4829 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4809 4830 to *not* include the last item given in a range. This brings their
4810 4831 behavior in line with Python's slicing:
4811 4832 a[n1:n2] -> a[n1]...a[n2-1]
4812 4833 It may be a bit less convenient, but I prefer to stick to Python's
4813 4834 conventions *everywhere*, so users never have to wonder.
4814 4835 (Magic.magic_macro): Added @macro function to ease the creation of
4815 4836 macros.
4816 4837
4817 4838 2002-01-05 Fernando Perez <fperez@colorado.edu>
4818 4839
4819 4840 * Released 0.2.4.
4820 4841
4821 4842 * IPython/iplib.py (Magic.magic_pdef):
4822 4843 (InteractiveShell.safe_execfile): report magic lines and error
4823 4844 lines without line numbers so one can easily copy/paste them for
4824 4845 re-execution.
4825 4846
4826 4847 * Updated manual with recent changes.
4827 4848
4828 4849 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4829 4850 docstring printing when class? is called. Very handy for knowing
4830 4851 how to create class instances (as long as __init__ is well
4831 4852 documented, of course :)
4832 4853 (Magic.magic_doc): print both class and constructor docstrings.
4833 4854 (Magic.magic_pdef): give constructor info if passed a class and
4834 4855 __call__ info for callable object instances.
4835 4856
4836 4857 2002-01-04 Fernando Perez <fperez@colorado.edu>
4837 4858
4838 4859 * Made deep_reload() off by default. It doesn't always work
4839 4860 exactly as intended, so it's probably safer to have it off. It's
4840 4861 still available as dreload() anyway, so nothing is lost.
4841 4862
4842 4863 2002-01-02 Fernando Perez <fperez@colorado.edu>
4843 4864
4844 4865 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4845 4866 so I wanted an updated release).
4846 4867
4847 4868 2001-12-27 Fernando Perez <fperez@colorado.edu>
4848 4869
4849 4870 * IPython/iplib.py (InteractiveShell.interact): Added the original
4850 4871 code from 'code.py' for this module in order to change the
4851 4872 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4852 4873 the history cache would break when the user hit Ctrl-C, and
4853 4874 interact() offers no way to add any hooks to it.
4854 4875
4855 4876 2001-12-23 Fernando Perez <fperez@colorado.edu>
4856 4877
4857 4878 * setup.py: added check for 'MANIFEST' before trying to remove
4858 4879 it. Thanks to Sean Reifschneider.
4859 4880
4860 4881 2001-12-22 Fernando Perez <fperez@colorado.edu>
4861 4882
4862 4883 * Released 0.2.2.
4863 4884
4864 4885 * Finished (reasonably) writing the manual. Later will add the
4865 4886 python-standard navigation stylesheets, but for the time being
4866 4887 it's fairly complete. Distribution will include html and pdf
4867 4888 versions.
4868 4889
4869 4890 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4870 4891 (MayaVi author).
4871 4892
4872 4893 2001-12-21 Fernando Perez <fperez@colorado.edu>
4873 4894
4874 4895 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4875 4896 good public release, I think (with the manual and the distutils
4876 4897 installer). The manual can use some work, but that can go
4877 4898 slowly. Otherwise I think it's quite nice for end users. Next
4878 4899 summer, rewrite the guts of it...
4879 4900
4880 4901 * Changed format of ipythonrc files to use whitespace as the
4881 4902 separator instead of an explicit '='. Cleaner.
4882 4903
4883 4904 2001-12-20 Fernando Perez <fperez@colorado.edu>
4884 4905
4885 4906 * Started a manual in LyX. For now it's just a quick merge of the
4886 4907 various internal docstrings and READMEs. Later it may grow into a
4887 4908 nice, full-blown manual.
4888 4909
4889 4910 * Set up a distutils based installer. Installation should now be
4890 4911 trivially simple for end-users.
4891 4912
4892 4913 2001-12-11 Fernando Perez <fperez@colorado.edu>
4893 4914
4894 4915 * Released 0.2.0. First public release, announced it at
4895 4916 comp.lang.python. From now on, just bugfixes...
4896 4917
4897 4918 * Went through all the files, set copyright/license notices and
4898 4919 cleaned up things. Ready for release.
4899 4920
4900 4921 2001-12-10 Fernando Perez <fperez@colorado.edu>
4901 4922
4902 4923 * Changed the first-time installer not to use tarfiles. It's more
4903 4924 robust now and less unix-dependent. Also makes it easier for
4904 4925 people to later upgrade versions.
4905 4926
4906 4927 * Changed @exit to @abort to reflect the fact that it's pretty
4907 4928 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4908 4929 becomes significant only when IPyhton is embedded: in that case,
4909 4930 C-D closes IPython only, but @abort kills the enclosing program
4910 4931 too (unless it had called IPython inside a try catching
4911 4932 SystemExit).
4912 4933
4913 4934 * Created Shell module which exposes the actuall IPython Shell
4914 4935 classes, currently the normal and the embeddable one. This at
4915 4936 least offers a stable interface we won't need to change when
4916 4937 (later) the internals are rewritten. That rewrite will be confined
4917 4938 to iplib and ipmaker, but the Shell interface should remain as is.
4918 4939
4919 4940 * Added embed module which offers an embeddable IPShell object,
4920 4941 useful to fire up IPython *inside* a running program. Great for
4921 4942 debugging or dynamical data analysis.
4922 4943
4923 4944 2001-12-08 Fernando Perez <fperez@colorado.edu>
4924 4945
4925 4946 * Fixed small bug preventing seeing info from methods of defined
4926 4947 objects (incorrect namespace in _ofind()).
4927 4948
4928 4949 * Documentation cleanup. Moved the main usage docstrings to a
4929 4950 separate file, usage.py (cleaner to maintain, and hopefully in the
4930 4951 future some perlpod-like way of producing interactive, man and
4931 4952 html docs out of it will be found).
4932 4953
4933 4954 * Added @profile to see your profile at any time.
4934 4955
4935 4956 * Added @p as an alias for 'print'. It's especially convenient if
4936 4957 using automagic ('p x' prints x).
4937 4958
4938 4959 * Small cleanups and fixes after a pychecker run.
4939 4960
4940 4961 * Changed the @cd command to handle @cd - and @cd -<n> for
4941 4962 visiting any directory in _dh.
4942 4963
4943 4964 * Introduced _dh, a history of visited directories. @dhist prints
4944 4965 it out with numbers.
4945 4966
4946 4967 2001-12-07 Fernando Perez <fperez@colorado.edu>
4947 4968
4948 4969 * Released 0.1.22
4949 4970
4950 4971 * Made initialization a bit more robust against invalid color
4951 4972 options in user input (exit, not traceback-crash).
4952 4973
4953 4974 * Changed the bug crash reporter to write the report only in the
4954 4975 user's .ipython directory. That way IPython won't litter people's
4955 4976 hard disks with crash files all over the place. Also print on
4956 4977 screen the necessary mail command.
4957 4978
4958 4979 * With the new ultraTB, implemented LightBG color scheme for light
4959 4980 background terminals. A lot of people like white backgrounds, so I
4960 4981 guess we should at least give them something readable.
4961 4982
4962 4983 2001-12-06 Fernando Perez <fperez@colorado.edu>
4963 4984
4964 4985 * Modified the structure of ultraTB. Now there's a proper class
4965 4986 for tables of color schemes which allow adding schemes easily and
4966 4987 switching the active scheme without creating a new instance every
4967 4988 time (which was ridiculous). The syntax for creating new schemes
4968 4989 is also cleaner. I think ultraTB is finally done, with a clean
4969 4990 class structure. Names are also much cleaner (now there's proper
4970 4991 color tables, no need for every variable to also have 'color' in
4971 4992 its name).
4972 4993
4973 4994 * Broke down genutils into separate files. Now genutils only
4974 4995 contains utility functions, and classes have been moved to their
4975 4996 own files (they had enough independent functionality to warrant
4976 4997 it): ConfigLoader, OutputTrap, Struct.
4977 4998
4978 4999 2001-12-05 Fernando Perez <fperez@colorado.edu>
4979 5000
4980 5001 * IPython turns 21! Released version 0.1.21, as a candidate for
4981 5002 public consumption. If all goes well, release in a few days.
4982 5003
4983 5004 * Fixed path bug (files in Extensions/ directory wouldn't be found
4984 5005 unless IPython/ was explicitly in sys.path).
4985 5006
4986 5007 * Extended the FlexCompleter class as MagicCompleter to allow
4987 5008 completion of @-starting lines.
4988 5009
4989 5010 * Created __release__.py file as a central repository for release
4990 5011 info that other files can read from.
4991 5012
4992 5013 * Fixed small bug in logging: when logging was turned on in
4993 5014 mid-session, old lines with special meanings (!@?) were being
4994 5015 logged without the prepended comment, which is necessary since
4995 5016 they are not truly valid python syntax. This should make session
4996 5017 restores produce less errors.
4997 5018
4998 5019 * The namespace cleanup forced me to make a FlexCompleter class
4999 5020 which is nothing but a ripoff of rlcompleter, but with selectable
5000 5021 namespace (rlcompleter only works in __main__.__dict__). I'll try
5001 5022 to submit a note to the authors to see if this change can be
5002 5023 incorporated in future rlcompleter releases (Dec.6: done)
5003 5024
5004 5025 * More fixes to namespace handling. It was a mess! Now all
5005 5026 explicit references to __main__.__dict__ are gone (except when
5006 5027 really needed) and everything is handled through the namespace
5007 5028 dicts in the IPython instance. We seem to be getting somewhere
5008 5029 with this, finally...
5009 5030
5010 5031 * Small documentation updates.
5011 5032
5012 5033 * Created the Extensions directory under IPython (with an
5013 5034 __init__.py). Put the PhysicalQ stuff there. This directory should
5014 5035 be used for all special-purpose extensions.
5015 5036
5016 5037 * File renaming:
5017 5038 ipythonlib --> ipmaker
5018 5039 ipplib --> iplib
5019 5040 This makes a bit more sense in terms of what these files actually do.
5020 5041
5021 5042 * Moved all the classes and functions in ipythonlib to ipplib, so
5022 5043 now ipythonlib only has make_IPython(). This will ease up its
5023 5044 splitting in smaller functional chunks later.
5024 5045
5025 5046 * Cleaned up (done, I think) output of @whos. Better column
5026 5047 formatting, and now shows str(var) for as much as it can, which is
5027 5048 typically what one gets with a 'print var'.
5028 5049
5029 5050 2001-12-04 Fernando Perez <fperez@colorado.edu>
5030 5051
5031 5052 * Fixed namespace problems. Now builtin/IPyhton/user names get
5032 5053 properly reported in their namespace. Internal namespace handling
5033 5054 is finally getting decent (not perfect yet, but much better than
5034 5055 the ad-hoc mess we had).
5035 5056
5036 5057 * Removed -exit option. If people just want to run a python
5037 5058 script, that's what the normal interpreter is for. Less
5038 5059 unnecessary options, less chances for bugs.
5039 5060
5040 5061 * Added a crash handler which generates a complete post-mortem if
5041 5062 IPython crashes. This will help a lot in tracking bugs down the
5042 5063 road.
5043 5064
5044 5065 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5045 5066 which were boud to functions being reassigned would bypass the
5046 5067 logger, breaking the sync of _il with the prompt counter. This
5047 5068 would then crash IPython later when a new line was logged.
5048 5069
5049 5070 2001-12-02 Fernando Perez <fperez@colorado.edu>
5050 5071
5051 5072 * Made IPython a package. This means people don't have to clutter
5052 5073 their sys.path with yet another directory. Changed the INSTALL
5053 5074 file accordingly.
5054 5075
5055 5076 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5056 5077 sorts its output (so @who shows it sorted) and @whos formats the
5057 5078 table according to the width of the first column. Nicer, easier to
5058 5079 read. Todo: write a generic table_format() which takes a list of
5059 5080 lists and prints it nicely formatted, with optional row/column
5060 5081 separators and proper padding and justification.
5061 5082
5062 5083 * Released 0.1.20
5063 5084
5064 5085 * Fixed bug in @log which would reverse the inputcache list (a
5065 5086 copy operation was missing).
5066 5087
5067 5088 * Code cleanup. @config was changed to use page(). Better, since
5068 5089 its output is always quite long.
5069 5090
5070 5091 * Itpl is back as a dependency. I was having too many problems
5071 5092 getting the parametric aliases to work reliably, and it's just
5072 5093 easier to code weird string operations with it than playing %()s
5073 5094 games. It's only ~6k, so I don't think it's too big a deal.
5074 5095
5075 5096 * Found (and fixed) a very nasty bug with history. !lines weren't
5076 5097 getting cached, and the out of sync caches would crash
5077 5098 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5078 5099 division of labor a bit better. Bug fixed, cleaner structure.
5079 5100
5080 5101 2001-12-01 Fernando Perez <fperez@colorado.edu>
5081 5102
5082 5103 * Released 0.1.19
5083 5104
5084 5105 * Added option -n to @hist to prevent line number printing. Much
5085 5106 easier to copy/paste code this way.
5086 5107
5087 5108 * Created global _il to hold the input list. Allows easy
5088 5109 re-execution of blocks of code by slicing it (inspired by Janko's
5089 5110 comment on 'macros').
5090 5111
5091 5112 * Small fixes and doc updates.
5092 5113
5093 5114 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5094 5115 much too fragile with automagic. Handles properly multi-line
5095 5116 statements and takes parameters.
5096 5117
5097 5118 2001-11-30 Fernando Perez <fperez@colorado.edu>
5098 5119
5099 5120 * Version 0.1.18 released.
5100 5121
5101 5122 * Fixed nasty namespace bug in initial module imports.
5102 5123
5103 5124 * Added copyright/license notes to all code files (except
5104 5125 DPyGetOpt). For the time being, LGPL. That could change.
5105 5126
5106 5127 * Rewrote a much nicer README, updated INSTALL, cleaned up
5107 5128 ipythonrc-* samples.
5108 5129
5109 5130 * Overall code/documentation cleanup. Basically ready for
5110 5131 release. Only remaining thing: licence decision (LGPL?).
5111 5132
5112 5133 * Converted load_config to a class, ConfigLoader. Now recursion
5113 5134 control is better organized. Doesn't include the same file twice.
5114 5135
5115 5136 2001-11-29 Fernando Perez <fperez@colorado.edu>
5116 5137
5117 5138 * Got input history working. Changed output history variables from
5118 5139 _p to _o so that _i is for input and _o for output. Just cleaner
5119 5140 convention.
5120 5141
5121 5142 * Implemented parametric aliases. This pretty much allows the
5122 5143 alias system to offer full-blown shell convenience, I think.
5123 5144
5124 5145 * Version 0.1.17 released, 0.1.18 opened.
5125 5146
5126 5147 * dot_ipython/ipythonrc (alias): added documentation.
5127 5148 (xcolor): Fixed small bug (xcolors -> xcolor)
5128 5149
5129 5150 * Changed the alias system. Now alias is a magic command to define
5130 5151 aliases just like the shell. Rationale: the builtin magics should
5131 5152 be there for things deeply connected to IPython's
5132 5153 architecture. And this is a much lighter system for what I think
5133 5154 is the really important feature: allowing users to define quickly
5134 5155 magics that will do shell things for them, so they can customize
5135 5156 IPython easily to match their work habits. If someone is really
5136 5157 desperate to have another name for a builtin alias, they can
5137 5158 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5138 5159 works.
5139 5160
5140 5161 2001-11-28 Fernando Perez <fperez@colorado.edu>
5141 5162
5142 5163 * Changed @file so that it opens the source file at the proper
5143 5164 line. Since it uses less, if your EDITOR environment is
5144 5165 configured, typing v will immediately open your editor of choice
5145 5166 right at the line where the object is defined. Not as quick as
5146 5167 having a direct @edit command, but for all intents and purposes it
5147 5168 works. And I don't have to worry about writing @edit to deal with
5148 5169 all the editors, less does that.
5149 5170
5150 5171 * Version 0.1.16 released, 0.1.17 opened.
5151 5172
5152 5173 * Fixed some nasty bugs in the page/page_dumb combo that could
5153 5174 crash IPython.
5154 5175
5155 5176 2001-11-27 Fernando Perez <fperez@colorado.edu>
5156 5177
5157 5178 * Version 0.1.15 released, 0.1.16 opened.
5158 5179
5159 5180 * Finally got ? and ?? to work for undefined things: now it's
5160 5181 possible to type {}.get? and get information about the get method
5161 5182 of dicts, or os.path? even if only os is defined (so technically
5162 5183 os.path isn't). Works at any level. For example, after import os,
5163 5184 os?, os.path?, os.path.abspath? all work. This is great, took some
5164 5185 work in _ofind.
5165 5186
5166 5187 * Fixed more bugs with logging. The sanest way to do it was to add
5167 5188 to @log a 'mode' parameter. Killed two in one shot (this mode
5168 5189 option was a request of Janko's). I think it's finally clean
5169 5190 (famous last words).
5170 5191
5171 5192 * Added a page_dumb() pager which does a decent job of paging on
5172 5193 screen, if better things (like less) aren't available. One less
5173 5194 unix dependency (someday maybe somebody will port this to
5174 5195 windows).
5175 5196
5176 5197 * Fixed problem in magic_log: would lock of logging out if log
5177 5198 creation failed (because it would still think it had succeeded).
5178 5199
5179 5200 * Improved the page() function using curses to auto-detect screen
5180 5201 size. Now it can make a much better decision on whether to print
5181 5202 or page a string. Option screen_length was modified: a value 0
5182 5203 means auto-detect, and that's the default now.
5183 5204
5184 5205 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5185 5206 go out. I'll test it for a few days, then talk to Janko about
5186 5207 licences and announce it.
5187 5208
5188 5209 * Fixed the length of the auto-generated ---> prompt which appears
5189 5210 for auto-parens and auto-quotes. Getting this right isn't trivial,
5190 5211 with all the color escapes, different prompt types and optional
5191 5212 separators. But it seems to be working in all the combinations.
5192 5213
5193 5214 2001-11-26 Fernando Perez <fperez@colorado.edu>
5194 5215
5195 5216 * Wrote a regexp filter to get option types from the option names
5196 5217 string. This eliminates the need to manually keep two duplicate
5197 5218 lists.
5198 5219
5199 5220 * Removed the unneeded check_option_names. Now options are handled
5200 5221 in a much saner manner and it's easy to visually check that things
5201 5222 are ok.
5202 5223
5203 5224 * Updated version numbers on all files I modified to carry a
5204 5225 notice so Janko and Nathan have clear version markers.
5205 5226
5206 5227 * Updated docstring for ultraTB with my changes. I should send
5207 5228 this to Nathan.
5208 5229
5209 5230 * Lots of small fixes. Ran everything through pychecker again.
5210 5231
5211 5232 * Made loading of deep_reload an cmd line option. If it's not too
5212 5233 kosher, now people can just disable it. With -nodeep_reload it's
5213 5234 still available as dreload(), it just won't overwrite reload().
5214 5235
5215 5236 * Moved many options to the no| form (-opt and -noopt
5216 5237 accepted). Cleaner.
5217 5238
5218 5239 * Changed magic_log so that if called with no parameters, it uses
5219 5240 'rotate' mode. That way auto-generated logs aren't automatically
5220 5241 over-written. For normal logs, now a backup is made if it exists
5221 5242 (only 1 level of backups). A new 'backup' mode was added to the
5222 5243 Logger class to support this. This was a request by Janko.
5223 5244
5224 5245 * Added @logoff/@logon to stop/restart an active log.
5225 5246
5226 5247 * Fixed a lot of bugs in log saving/replay. It was pretty
5227 5248 broken. Now special lines (!@,/) appear properly in the command
5228 5249 history after a log replay.
5229 5250
5230 5251 * Tried and failed to implement full session saving via pickle. My
5231 5252 idea was to pickle __main__.__dict__, but modules can't be
5232 5253 pickled. This would be a better alternative to replaying logs, but
5233 5254 seems quite tricky to get to work. Changed -session to be called
5234 5255 -logplay, which more accurately reflects what it does. And if we
5235 5256 ever get real session saving working, -session is now available.
5236 5257
5237 5258 * Implemented color schemes for prompts also. As for tracebacks,
5238 5259 currently only NoColor and Linux are supported. But now the
5239 5260 infrastructure is in place, based on a generic ColorScheme
5240 5261 class. So writing and activating new schemes both for the prompts
5241 5262 and the tracebacks should be straightforward.
5242 5263
5243 5264 * Version 0.1.13 released, 0.1.14 opened.
5244 5265
5245 5266 * Changed handling of options for output cache. Now counter is
5246 5267 hardwired starting at 1 and one specifies the maximum number of
5247 5268 entries *in the outcache* (not the max prompt counter). This is
5248 5269 much better, since many statements won't increase the cache
5249 5270 count. It also eliminated some confusing options, now there's only
5250 5271 one: cache_size.
5251 5272
5252 5273 * Added 'alias' magic function and magic_alias option in the
5253 5274 ipythonrc file. Now the user can easily define whatever names he
5254 5275 wants for the magic functions without having to play weird
5255 5276 namespace games. This gives IPython a real shell-like feel.
5256 5277
5257 5278 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5258 5279 @ or not).
5259 5280
5260 5281 This was one of the last remaining 'visible' bugs (that I know
5261 5282 of). I think if I can clean up the session loading so it works
5262 5283 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5263 5284 about licensing).
5264 5285
5265 5286 2001-11-25 Fernando Perez <fperez@colorado.edu>
5266 5287
5267 5288 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5268 5289 there's a cleaner distinction between what ? and ?? show.
5269 5290
5270 5291 * Added screen_length option. Now the user can define his own
5271 5292 screen size for page() operations.
5272 5293
5273 5294 * Implemented magic shell-like functions with automatic code
5274 5295 generation. Now adding another function is just a matter of adding
5275 5296 an entry to a dict, and the function is dynamically generated at
5276 5297 run-time. Python has some really cool features!
5277 5298
5278 5299 * Renamed many options to cleanup conventions a little. Now all
5279 5300 are lowercase, and only underscores where needed. Also in the code
5280 5301 option name tables are clearer.
5281 5302
5282 5303 * Changed prompts a little. Now input is 'In [n]:' instead of
5283 5304 'In[n]:='. This allows it the numbers to be aligned with the
5284 5305 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5285 5306 Python (it was a Mathematica thing). The '...' continuation prompt
5286 5307 was also changed a little to align better.
5287 5308
5288 5309 * Fixed bug when flushing output cache. Not all _p<n> variables
5289 5310 exist, so their deletion needs to be wrapped in a try:
5290 5311
5291 5312 * Figured out how to properly use inspect.formatargspec() (it
5292 5313 requires the args preceded by *). So I removed all the code from
5293 5314 _get_pdef in Magic, which was just replicating that.
5294 5315
5295 5316 * Added test to prefilter to allow redefining magic function names
5296 5317 as variables. This is ok, since the @ form is always available,
5297 5318 but whe should allow the user to define a variable called 'ls' if
5298 5319 he needs it.
5299 5320
5300 5321 * Moved the ToDo information from README into a separate ToDo.
5301 5322
5302 5323 * General code cleanup and small bugfixes. I think it's close to a
5303 5324 state where it can be released, obviously with a big 'beta'
5304 5325 warning on it.
5305 5326
5306 5327 * Got the magic function split to work. Now all magics are defined
5307 5328 in a separate class. It just organizes things a bit, and now
5308 5329 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5309 5330 was too long).
5310 5331
5311 5332 * Changed @clear to @reset to avoid potential confusions with
5312 5333 the shell command clear. Also renamed @cl to @clear, which does
5313 5334 exactly what people expect it to from their shell experience.
5314 5335
5315 5336 Added a check to the @reset command (since it's so
5316 5337 destructive, it's probably a good idea to ask for confirmation).
5317 5338 But now reset only works for full namespace resetting. Since the
5318 5339 del keyword is already there for deleting a few specific
5319 5340 variables, I don't see the point of having a redundant magic
5320 5341 function for the same task.
5321 5342
5322 5343 2001-11-24 Fernando Perez <fperez@colorado.edu>
5323 5344
5324 5345 * Updated the builtin docs (esp. the ? ones).
5325 5346
5326 5347 * Ran all the code through pychecker. Not terribly impressed with
5327 5348 it: lots of spurious warnings and didn't really find anything of
5328 5349 substance (just a few modules being imported and not used).
5329 5350
5330 5351 * Implemented the new ultraTB functionality into IPython. New
5331 5352 option: xcolors. This chooses color scheme. xmode now only selects
5332 5353 between Plain and Verbose. Better orthogonality.
5333 5354
5334 5355 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5335 5356 mode and color scheme for the exception handlers. Now it's
5336 5357 possible to have the verbose traceback with no coloring.
5337 5358
5338 5359 2001-11-23 Fernando Perez <fperez@colorado.edu>
5339 5360
5340 5361 * Version 0.1.12 released, 0.1.13 opened.
5341 5362
5342 5363 * Removed option to set auto-quote and auto-paren escapes by
5343 5364 user. The chances of breaking valid syntax are just too high. If
5344 5365 someone *really* wants, they can always dig into the code.
5345 5366
5346 5367 * Made prompt separators configurable.
5347 5368
5348 5369 2001-11-22 Fernando Perez <fperez@colorado.edu>
5349 5370
5350 5371 * Small bugfixes in many places.
5351 5372
5352 5373 * Removed the MyCompleter class from ipplib. It seemed redundant
5353 5374 with the C-p,C-n history search functionality. Less code to
5354 5375 maintain.
5355 5376
5356 5377 * Moved all the original ipython.py code into ipythonlib.py. Right
5357 5378 now it's just one big dump into a function called make_IPython, so
5358 5379 no real modularity has been gained. But at least it makes the
5359 5380 wrapper script tiny, and since ipythonlib is a module, it gets
5360 5381 compiled and startup is much faster.
5361 5382
5362 5383 This is a reasobably 'deep' change, so we should test it for a
5363 5384 while without messing too much more with the code.
5364 5385
5365 5386 2001-11-21 Fernando Perez <fperez@colorado.edu>
5366 5387
5367 5388 * Version 0.1.11 released, 0.1.12 opened for further work.
5368 5389
5369 5390 * Removed dependency on Itpl. It was only needed in one place. It
5370 5391 would be nice if this became part of python, though. It makes life
5371 5392 *a lot* easier in some cases.
5372 5393
5373 5394 * Simplified the prefilter code a bit. Now all handlers are
5374 5395 expected to explicitly return a value (at least a blank string).
5375 5396
5376 5397 * Heavy edits in ipplib. Removed the help system altogether. Now
5377 5398 obj?/?? is used for inspecting objects, a magic @doc prints
5378 5399 docstrings, and full-blown Python help is accessed via the 'help'
5379 5400 keyword. This cleans up a lot of code (less to maintain) and does
5380 5401 the job. Since 'help' is now a standard Python component, might as
5381 5402 well use it and remove duplicate functionality.
5382 5403
5383 5404 Also removed the option to use ipplib as a standalone program. By
5384 5405 now it's too dependent on other parts of IPython to function alone.
5385 5406
5386 5407 * Fixed bug in genutils.pager. It would crash if the pager was
5387 5408 exited immediately after opening (broken pipe).
5388 5409
5389 5410 * Trimmed down the VerboseTB reporting a little. The header is
5390 5411 much shorter now and the repeated exception arguments at the end
5391 5412 have been removed. For interactive use the old header seemed a bit
5392 5413 excessive.
5393 5414
5394 5415 * Fixed small bug in output of @whos for variables with multi-word
5395 5416 types (only first word was displayed).
5396 5417
5397 5418 2001-11-17 Fernando Perez <fperez@colorado.edu>
5398 5419
5399 5420 * Version 0.1.10 released, 0.1.11 opened for further work.
5400 5421
5401 5422 * Modified dirs and friends. dirs now *returns* the stack (not
5402 5423 prints), so one can manipulate it as a variable. Convenient to
5403 5424 travel along many directories.
5404 5425
5405 5426 * Fixed bug in magic_pdef: would only work with functions with
5406 5427 arguments with default values.
5407 5428
5408 5429 2001-11-14 Fernando Perez <fperez@colorado.edu>
5409 5430
5410 5431 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5411 5432 example with IPython. Various other minor fixes and cleanups.
5412 5433
5413 5434 * Version 0.1.9 released, 0.1.10 opened for further work.
5414 5435
5415 5436 * Added sys.path to the list of directories searched in the
5416 5437 execfile= option. It used to be the current directory and the
5417 5438 user's IPYTHONDIR only.
5418 5439
5419 5440 2001-11-13 Fernando Perez <fperez@colorado.edu>
5420 5441
5421 5442 * Reinstated the raw_input/prefilter separation that Janko had
5422 5443 initially. This gives a more convenient setup for extending the
5423 5444 pre-processor from the outside: raw_input always gets a string,
5424 5445 and prefilter has to process it. We can then redefine prefilter
5425 5446 from the outside and implement extensions for special
5426 5447 purposes.
5427 5448
5428 5449 Today I got one for inputting PhysicalQuantity objects
5429 5450 (from Scientific) without needing any function calls at
5430 5451 all. Extremely convenient, and it's all done as a user-level
5431 5452 extension (no IPython code was touched). Now instead of:
5432 5453 a = PhysicalQuantity(4.2,'m/s**2')
5433 5454 one can simply say
5434 5455 a = 4.2 m/s**2
5435 5456 or even
5436 5457 a = 4.2 m/s^2
5437 5458
5438 5459 I use this, but it's also a proof of concept: IPython really is
5439 5460 fully user-extensible, even at the level of the parsing of the
5440 5461 command line. It's not trivial, but it's perfectly doable.
5441 5462
5442 5463 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5443 5464 the problem of modules being loaded in the inverse order in which
5444 5465 they were defined in
5445 5466
5446 5467 * Version 0.1.8 released, 0.1.9 opened for further work.
5447 5468
5448 5469 * Added magics pdef, source and file. They respectively show the
5449 5470 definition line ('prototype' in C), source code and full python
5450 5471 file for any callable object. The object inspector oinfo uses
5451 5472 these to show the same information.
5452 5473
5453 5474 * Version 0.1.7 released, 0.1.8 opened for further work.
5454 5475
5455 5476 * Separated all the magic functions into a class called Magic. The
5456 5477 InteractiveShell class was becoming too big for Xemacs to handle
5457 5478 (de-indenting a line would lock it up for 10 seconds while it
5458 5479 backtracked on the whole class!)
5459 5480
5460 5481 FIXME: didn't work. It can be done, but right now namespaces are
5461 5482 all messed up. Do it later (reverted it for now, so at least
5462 5483 everything works as before).
5463 5484
5464 5485 * Got the object introspection system (magic_oinfo) working! I
5465 5486 think this is pretty much ready for release to Janko, so he can
5466 5487 test it for a while and then announce it. Pretty much 100% of what
5467 5488 I wanted for the 'phase 1' release is ready. Happy, tired.
5468 5489
5469 5490 2001-11-12 Fernando Perez <fperez@colorado.edu>
5470 5491
5471 5492 * Version 0.1.6 released, 0.1.7 opened for further work.
5472 5493
5473 5494 * Fixed bug in printing: it used to test for truth before
5474 5495 printing, so 0 wouldn't print. Now checks for None.
5475 5496
5476 5497 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5477 5498 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5478 5499 reaches by hand into the outputcache. Think of a better way to do
5479 5500 this later.
5480 5501
5481 5502 * Various small fixes thanks to Nathan's comments.
5482 5503
5483 5504 * Changed magic_pprint to magic_Pprint. This way it doesn't
5484 5505 collide with pprint() and the name is consistent with the command
5485 5506 line option.
5486 5507
5487 5508 * Changed prompt counter behavior to be fully like
5488 5509 Mathematica's. That is, even input that doesn't return a result
5489 5510 raises the prompt counter. The old behavior was kind of confusing
5490 5511 (getting the same prompt number several times if the operation
5491 5512 didn't return a result).
5492 5513
5493 5514 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5494 5515
5495 5516 * Fixed -Classic mode (wasn't working anymore).
5496 5517
5497 5518 * Added colored prompts using Nathan's new code. Colors are
5498 5519 currently hardwired, they can be user-configurable. For
5499 5520 developers, they can be chosen in file ipythonlib.py, at the
5500 5521 beginning of the CachedOutput class def.
5501 5522
5502 5523 2001-11-11 Fernando Perez <fperez@colorado.edu>
5503 5524
5504 5525 * Version 0.1.5 released, 0.1.6 opened for further work.
5505 5526
5506 5527 * Changed magic_env to *return* the environment as a dict (not to
5507 5528 print it). This way it prints, but it can also be processed.
5508 5529
5509 5530 * Added Verbose exception reporting to interactive
5510 5531 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
5511 5532 traceback. Had to make some changes to the ultraTB file. This is
5512 5533 probably the last 'big' thing in my mental todo list. This ties
5513 5534 in with the next entry:
5514 5535
5515 5536 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5516 5537 has to specify is Plain, Color or Verbose for all exception
5517 5538 handling.
5518 5539
5519 5540 * Removed ShellServices option. All this can really be done via
5520 5541 the magic system. It's easier to extend, cleaner and has automatic
5521 5542 namespace protection and documentation.
5522 5543
5523 5544 2001-11-09 Fernando Perez <fperez@colorado.edu>
5524 5545
5525 5546 * Fixed bug in output cache flushing (missing parameter to
5526 5547 __init__). Other small bugs fixed (found using pychecker).
5527 5548
5528 5549 * Version 0.1.4 opened for bugfixing.
5529 5550
5530 5551 2001-11-07 Fernando Perez <fperez@colorado.edu>
5531 5552
5532 5553 * Version 0.1.3 released, mainly because of the raw_input bug.
5533 5554
5534 5555 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5535 5556 and when testing for whether things were callable, a call could
5536 5557 actually be made to certain functions. They would get called again
5537 5558 once 'really' executed, with a resulting double call. A disaster
5538 5559 in many cases (list.reverse() would never work!).
5539 5560
5540 5561 * Removed prefilter() function, moved its code to raw_input (which
5541 5562 after all was just a near-empty caller for prefilter). This saves
5542 5563 a function call on every prompt, and simplifies the class a tiny bit.
5543 5564
5544 5565 * Fix _ip to __ip name in magic example file.
5545 5566
5546 5567 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5547 5568 work with non-gnu versions of tar.
5548 5569
5549 5570 2001-11-06 Fernando Perez <fperez@colorado.edu>
5550 5571
5551 5572 * Version 0.1.2. Just to keep track of the recent changes.
5552 5573
5553 5574 * Fixed nasty bug in output prompt routine. It used to check 'if
5554 5575 arg != None...'. Problem is, this fails if arg implements a
5555 5576 special comparison (__cmp__) which disallows comparing to
5556 5577 None. Found it when trying to use the PhysicalQuantity module from
5557 5578 ScientificPython.
5558 5579
5559 5580 2001-11-05 Fernando Perez <fperez@colorado.edu>
5560 5581
5561 5582 * Also added dirs. Now the pushd/popd/dirs family functions
5562 5583 basically like the shell, with the added convenience of going home
5563 5584 when called with no args.
5564 5585
5565 5586 * pushd/popd slightly modified to mimic shell behavior more
5566 5587 closely.
5567 5588
5568 5589 * Added env,pushd,popd from ShellServices as magic functions. I
5569 5590 think the cleanest will be to port all desired functions from
5570 5591 ShellServices as magics and remove ShellServices altogether. This
5571 5592 will provide a single, clean way of adding functionality
5572 5593 (shell-type or otherwise) to IP.
5573 5594
5574 5595 2001-11-04 Fernando Perez <fperez@colorado.edu>
5575 5596
5576 5597 * Added .ipython/ directory to sys.path. This way users can keep
5577 5598 customizations there and access them via import.
5578 5599
5579 5600 2001-11-03 Fernando Perez <fperez@colorado.edu>
5580 5601
5581 5602 * Opened version 0.1.1 for new changes.
5582 5603
5583 5604 * Changed version number to 0.1.0: first 'public' release, sent to
5584 5605 Nathan and Janko.
5585 5606
5586 5607 * Lots of small fixes and tweaks.
5587 5608
5588 5609 * Minor changes to whos format. Now strings are shown, snipped if
5589 5610 too long.
5590 5611
5591 5612 * Changed ShellServices to work on __main__ so they show up in @who
5592 5613
5593 5614 * Help also works with ? at the end of a line:
5594 5615 ?sin and sin?
5595 5616 both produce the same effect. This is nice, as often I use the
5596 5617 tab-complete to find the name of a method, but I used to then have
5597 5618 to go to the beginning of the line to put a ? if I wanted more
5598 5619 info. Now I can just add the ? and hit return. Convenient.
5599 5620
5600 5621 2001-11-02 Fernando Perez <fperez@colorado.edu>
5601 5622
5602 5623 * Python version check (>=2.1) added.
5603 5624
5604 5625 * Added LazyPython documentation. At this point the docs are quite
5605 5626 a mess. A cleanup is in order.
5606 5627
5607 5628 * Auto-installer created. For some bizarre reason, the zipfiles
5608 5629 module isn't working on my system. So I made a tar version
5609 5630 (hopefully the command line options in various systems won't kill
5610 5631 me).
5611 5632
5612 5633 * Fixes to Struct in genutils. Now all dictionary-like methods are
5613 5634 protected (reasonably).
5614 5635
5615 5636 * Added pager function to genutils and changed ? to print usage
5616 5637 note through it (it was too long).
5617 5638
5618 5639 * Added the LazyPython functionality. Works great! I changed the
5619 5640 auto-quote escape to ';', it's on home row and next to '. But
5620 5641 both auto-quote and auto-paren (still /) escapes are command-line
5621 5642 parameters.
5622 5643
5623 5644
5624 5645 2001-11-01 Fernando Perez <fperez@colorado.edu>
5625 5646
5626 5647 * Version changed to 0.0.7. Fairly large change: configuration now
5627 5648 is all stored in a directory, by default .ipython. There, all
5628 5649 config files have normal looking names (not .names)
5629 5650
5630 5651 * Version 0.0.6 Released first to Lucas and Archie as a test
5631 5652 run. Since it's the first 'semi-public' release, change version to
5632 5653 > 0.0.6 for any changes now.
5633 5654
5634 5655 * Stuff I had put in the ipplib.py changelog:
5635 5656
5636 5657 Changes to InteractiveShell:
5637 5658
5638 5659 - Made the usage message a parameter.
5639 5660
5640 5661 - Require the name of the shell variable to be given. It's a bit
5641 5662 of a hack, but allows the name 'shell' not to be hardwired in the
5642 5663 magic (@) handler, which is problematic b/c it requires
5643 5664 polluting the global namespace with 'shell'. This in turn is
5644 5665 fragile: if a user redefines a variable called shell, things
5645 5666 break.
5646 5667
5647 5668 - magic @: all functions available through @ need to be defined
5648 5669 as magic_<name>, even though they can be called simply as
5649 5670 @<name>. This allows the special command @magic to gather
5650 5671 information automatically about all existing magic functions,
5651 5672 even if they are run-time user extensions, by parsing the shell
5652 5673 instance __dict__ looking for special magic_ names.
5653 5674
5654 5675 - mainloop: added *two* local namespace parameters. This allows
5655 5676 the class to differentiate between parameters which were there
5656 5677 before and after command line initialization was processed. This
5657 5678 way, later @who can show things loaded at startup by the
5658 5679 user. This trick was necessary to make session saving/reloading
5659 5680 really work: ideally after saving/exiting/reloading a session,
5660 5681 *everything* should look the same, including the output of @who. I
5661 5682 was only able to make this work with this double namespace
5662 5683 trick.
5663 5684
5664 5685 - added a header to the logfile which allows (almost) full
5665 5686 session restoring.
5666 5687
5667 5688 - prepend lines beginning with @ or !, with a and log
5668 5689 them. Why? !lines: may be useful to know what you did @lines:
5669 5690 they may affect session state. So when restoring a session, at
5670 5691 least inform the user of their presence. I couldn't quite get
5671 5692 them to properly re-execute, but at least the user is warned.
5672 5693
5673 5694 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now