##// END OF EJS Templates
Add an input argument to *all* Display constructors....
walter.doerwald -
Show More
@@ -1,401 +1,398 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
260 260 try:
261 261 import ipipe
262 262 except ImportError:
263 263 pass
264 264 else:
265 265 def xrepr_astyle_text(self, mode="default"):
266 266 yield (-1, True)
267 267 for info in self:
268 268 yield info
269 try:
270 ipipe.xrepr.when_type(Text)(xrepr_astyle_text)
271 except Exception:
272 pass
269 ipipe.xrepr.when_type(Text)(xrepr_astyle_text)
273 270
274 271
275 272 def streamstyle(stream, styled=None):
276 273 """
277 274 If ``styled`` is ``None``, return whether ``stream`` refers to a terminal.
278 275 If this can't be determined (either because ``stream`` doesn't refer to a
279 276 real OS file, or because you're on Windows) return ``False``. If ``styled``
280 277 is not ``None`` ``styled`` will be returned unchanged.
281 278 """
282 279 if styled is None:
283 280 try:
284 281 styled = os.isatty(stream.fileno())
285 282 except (KeyboardInterrupt, SystemExit):
286 283 raise
287 284 except Exception:
288 285 styled = False
289 286 return styled
290 287
291 288
292 289 def write(stream, styled, *texts):
293 290 """
294 291 Write ``texts`` to ``stream``.
295 292 """
296 293 text = Text(*texts)
297 294 text.write(stream, streamstyle(stream, styled))
298 295
299 296
300 297 def writeln(stream, styled, *texts):
301 298 """
302 299 Write ``texts`` to ``stream`` and finish with a line feed.
303 300 """
304 301 write(stream, styled, *texts)
305 302 stream.write("\n")
306 303
307 304
308 305 class Stream(object):
309 306 """
310 307 Stream wrapper that adds color output.
311 308 """
312 309 def __init__(self, stream, styled=None):
313 310 self.stream = stream
314 311 self.styled = streamstyle(stream, styled)
315 312
316 313 def write(self, *texts):
317 314 write(self.stream, self.styled, *texts)
318 315
319 316 def writeln(self, *texts):
320 317 writeln(self.stream, self.styled, *texts)
321 318
322 319 def __getattr__(self, name):
323 320 return getattr(self.stream, name)
324 321
325 322
326 323 class stdout(object):
327 324 """
328 325 Stream wrapper for ``sys.stdout`` that adds color output.
329 326 """
330 327 def write(self, *texts):
331 328 write(sys.stdout, None, *texts)
332 329
333 330 def writeln(self, *texts):
334 331 writeln(sys.stdout, None, *texts)
335 332
336 333 def __getattr__(self, name):
337 334 return getattr(sys.stdout, name)
338 335 stdout = stdout()
339 336
340 337
341 338 class stderr(object):
342 339 """
343 340 Stream wrapper for ``sys.stderr`` that adds color output.
344 341 """
345 342 def write(self, *texts):
346 343 write(sys.stderr, None, *texts)
347 344
348 345 def writeln(self, *texts):
349 346 writeln(sys.stderr, None, *texts)
350 347
351 348 def __getattr__(self, name):
352 349 return getattr(sys.stdout, name)
353 350 stderr = stderr()
354 351
355 352
356 353 if curses is not None:
357 354 # This is probably just range(8)
358 355 COLOR2CURSES = [
359 356 COLOR_BLACK,
360 357 COLOR_RED,
361 358 COLOR_GREEN,
362 359 COLOR_YELLOW,
363 360 COLOR_BLUE,
364 361 COLOR_MAGENTA,
365 362 COLOR_CYAN,
366 363 COLOR_WHITE,
367 364 ]
368 365
369 366 A2CURSES = {
370 367 A_BLINK: curses.A_BLINK,
371 368 A_BOLD: curses.A_BOLD,
372 369 A_DIM: curses.A_DIM,
373 370 A_REVERSE: curses.A_REVERSE,
374 371 A_STANDOUT: curses.A_STANDOUT,
375 372 A_UNDERLINE: curses.A_UNDERLINE,
376 373 }
377 374
378 375
379 376 # default style
380 377 style_default = Style.fromstr("white:black")
381 378
382 379 # Styles for datatypes
383 380 style_type_none = Style.fromstr("magenta:black")
384 381 style_type_bool = Style.fromstr("magenta:black")
385 382 style_type_number = Style.fromstr("yellow:black")
386 383 style_type_datetime = Style.fromstr("magenta:black")
387 384 style_type_type = Style.fromstr("cyan:black")
388 385
389 386 # Style for URLs and file/directory names
390 387 style_url = Style.fromstr("green:black")
391 388 style_dir = Style.fromstr("cyan:black")
392 389 style_file = Style.fromstr("green:black")
393 390
394 391 # Style for ellipsis (when an output has been shortened
395 392 style_ellisis = Style.fromstr("red:black")
396 393
397 394 # Style for displaying exceptions
398 395 style_error = Style.fromstr("red:black")
399 396
400 397 # Style for displaying non-existing attributes
401 398 style_nodata = Style.fromstr("red:black")
@@ -1,1769 +1,1767 b''
1 1 # -*- coding: iso-8859-1 -*-
2 2
3 3 import curses, fcntl, signal, struct, tty, textwrap, inspect
4 4
5 5 from IPython import ipapi
6 6
7 7 import astyle, ipipe
8 8
9 9
10 10 # Python 2.3 compatibility
11 11 try:
12 12 set
13 13 except NameError:
14 14 import sets
15 15 set = sets.Set
16 16
17 17 # Python 2.3 compatibility
18 18 try:
19 19 sorted
20 20 except NameError:
21 21 from ipipe import sorted
22 22
23 23
24 24 class UnassignedKeyError(Exception):
25 25 """
26 26 Exception that is used for reporting unassigned keys.
27 27 """
28 28
29 29
30 30 class UnknownCommandError(Exception):
31 31 """
32 32 Exception that is used for reporting unknown commands (this should never
33 33 happen).
34 34 """
35 35
36 36
37 37 class CommandError(Exception):
38 38 """
39 39 Exception that is used for reporting that a command can't be executed.
40 40 """
41 41
42 42
43 43 class Keymap(dict):
44 44 """
45 45 Stores mapping of keys to commands.
46 46 """
47 47 def __init__(self):
48 48 self._keymap = {}
49 49
50 50 def __setitem__(self, key, command):
51 51 if isinstance(key, str):
52 52 for c in key:
53 53 dict.__setitem__(self, ord(c), command)
54 54 else:
55 55 dict.__setitem__(self, key, command)
56 56
57 57 def __getitem__(self, key):
58 58 if isinstance(key, str):
59 59 key = ord(key)
60 60 return dict.__getitem__(self, key)
61 61
62 62 def __detitem__(self, key):
63 63 if isinstance(key, str):
64 64 key = ord(key)
65 65 dict.__detitem__(self, key)
66 66
67 67 def register(self, command, *keys):
68 68 for key in keys:
69 69 self[key] = command
70 70
71 71 def get(self, key, default=None):
72 72 if isinstance(key, str):
73 73 key = ord(key)
74 74 return dict.get(self, key, default)
75 75
76 76 def findkey(self, command, default=ipipe.noitem):
77 77 for (key, commandcandidate) in self.iteritems():
78 78 if commandcandidate == command:
79 79 return key
80 80 if default is ipipe.noitem:
81 81 raise KeyError(command)
82 82 return default
83 83
84 84
85 85 class _BrowserCachedItem(object):
86 86 # This is used internally by ``ibrowse`` to store a item together with its
87 87 # marked status.
88 88 __slots__ = ("item", "marked")
89 89
90 90 def __init__(self, item):
91 91 self.item = item
92 92 self.marked = False
93 93
94 94
95 95 class _BrowserHelp(object):
96 96 style_header = astyle.Style.fromstr("yellow:black:bold")
97 97 # This is used internally by ``ibrowse`` for displaying the help screen.
98 98 def __init__(self, browser):
99 99 self.browser = browser
100 100
101 101 def __xrepr__(self, mode):
102 102 yield (-1, True)
103 103 if mode == "header" or mode == "footer":
104 104 yield (astyle.style_default, "ibrowse help screen")
105 105 else:
106 106 yield (astyle.style_default, repr(self))
107 107
108 108 def __iter__(self):
109 109 # Get reverse key mapping
110 110 allkeys = {}
111 111 for (key, cmd) in self.browser.keymap.iteritems():
112 112 allkeys.setdefault(cmd, []).append(key)
113 113
114 114 fields = ("key", "description")
115 115
116 116 commands = []
117 117 for name in dir(self.browser):
118 118 if name.startswith("cmd_"):
119 119 command = getattr(self.browser, name)
120 120 commands.append((inspect.getsourcelines(command)[-1], name[4:], command))
121 121 commands.sort()
122 122 commands = [(c[1], c[2]) for c in commands]
123 123 for (i, (name, command)) in enumerate(commands):
124 124 if i:
125 125 yield ipipe.Fields(fields, key="", description="")
126 126
127 127 description = command.__doc__
128 128 if description is None:
129 129 lines = []
130 130 else:
131 131 lines = [l.strip() for l in description.splitlines() if l.strip()]
132 132 description = "\n".join(lines)
133 133 lines = textwrap.wrap(description, 60)
134 134 keys = allkeys.get(name, [])
135 135
136 136 yield ipipe.Fields(fields, key="", description=astyle.Text((self.style_header, name)))
137 137 for i in xrange(max(len(keys), len(lines))):
138 138 try:
139 139 key = self.browser.keylabel(keys[i])
140 140 except IndexError:
141 141 key = ""
142 142 try:
143 143 line = lines[i]
144 144 except IndexError:
145 145 line = ""
146 146 yield ipipe.Fields(fields, key=key, description=line)
147 147
148 148
149 149 class _BrowserLevel(object):
150 150 # This is used internally to store the state (iterator, fetch items,
151 151 # position of cursor and screen, etc.) of one browser level
152 152 # An ``ibrowse`` object keeps multiple ``_BrowserLevel`` objects in
153 153 # a stack.
154 154 def __init__(self, browser, input, mainsizey, *attrs):
155 155 self.browser = browser
156 156 self.input = input
157 157 self.header = [x for x in ipipe.xrepr(input, "header") if not isinstance(x[0], int)]
158 158 # iterator for the input
159 159 self.iterator = ipipe.xiter(input)
160 160
161 161 # is the iterator exhausted?
162 162 self.exhausted = False
163 163
164 164 # attributes to be display (autodetected if empty)
165 165 self.attrs = attrs
166 166
167 167 # fetched items (+ marked flag)
168 168 self.items = ipipe.deque()
169 169
170 170 # Number of marked objects
171 171 self.marked = 0
172 172
173 173 # Vertical cursor position
174 174 self.cury = 0
175 175
176 176 # Horizontal cursor position
177 177 self.curx = 0
178 178
179 179 # Index of first data column
180 180 self.datastartx = 0
181 181
182 182 # Index of first data line
183 183 self.datastarty = 0
184 184
185 185 # height of the data display area
186 186 self.mainsizey = mainsizey
187 187
188 188 # width of the data display area (changes when scrolling)
189 189 self.mainsizex = 0
190 190
191 191 # Size of row number (changes when scrolling)
192 192 self.numbersizex = 0
193 193
194 194 # Attributes to display (in this order)
195 195 self.displayattrs = []
196 196
197 197 # index and attribute under the cursor
198 198 self.displayattr = (None, ipipe.noitem)
199 199
200 200 # Maps attributes to column widths
201 201 self.colwidths = {}
202 202
203 203 # Set of hidden attributes
204 204 self.hiddenattrs = set()
205 205
206 206 # This takes care of all the caches etc.
207 207 self.moveto(0, 0, refresh=True)
208 208
209 209 def fetch(self, count):
210 210 # Try to fill ``self.items`` with at least ``count`` objects.
211 211 have = len(self.items)
212 212 while not self.exhausted and have < count:
213 213 try:
214 214 item = self.iterator.next()
215 215 except StopIteration:
216 216 self.exhausted = True
217 217 break
218 218 except (KeyboardInterrupt, SystemExit):
219 219 raise
220 220 except Exception, exc:
221 221 have += 1
222 222 self.items.append(_BrowserCachedItem(exc))
223 223 self.exhausted = True
224 224 break
225 225 else:
226 226 have += 1
227 227 self.items.append(_BrowserCachedItem(item))
228 228
229 229 def calcdisplayattrs(self):
230 230 # Calculate which attributes are available from the objects that are
231 231 # currently visible on screen (and store it in ``self.displayattrs``)
232 232
233 233 attrs = set()
234 234 self.displayattrs = []
235 235 if self.attrs:
236 236 # If the browser object specifies a fixed list of attributes,
237 237 # simply use it (removing hidden attributes).
238 238 for attr in self.attrs:
239 239 attr = ipipe.upgradexattr(attr)
240 240 if attr not in attrs and attr not in self.hiddenattrs:
241 241 self.displayattrs.append(attr)
242 242 attrs.add(attr)
243 243 else:
244 244 endy = min(self.datastarty+self.mainsizey, len(self.items))
245 245 for i in xrange(self.datastarty, endy):
246 246 for attr in ipipe.xattrs(self.items[i].item, "default"):
247 247 if attr not in attrs and attr not in self.hiddenattrs:
248 248 self.displayattrs.append(attr)
249 249 attrs.add(attr)
250 250
251 251 def getrow(self, i):
252 252 # Return a dictionary with the attributes for the object
253 253 # ``self.items[i]``. Attribute names are taken from
254 254 # ``self.displayattrs`` so ``calcdisplayattrs()`` must have been
255 255 # called before.
256 256 row = {}
257 257 item = self.items[i].item
258 258 for attr in self.displayattrs:
259 259 try:
260 260 value = attr.value(item)
261 261 except (KeyboardInterrupt, SystemExit):
262 262 raise
263 263 except Exception, exc:
264 264 value = exc
265 265 # only store attribute if it exists (or we got an exception)
266 266 if value is not ipipe.noitem:
267 267 # remember alignment, length and colored text
268 268 row[attr] = ipipe.xformat(value, "cell", self.browser.maxattrlength)
269 269 return row
270 270
271 271 def calcwidths(self):
272 272 # Recalculate the displayed fields and their widths.
273 273 # ``calcdisplayattrs()'' must have been called and the cache
274 274 # for attributes of the objects on screen (``self.displayrows``)
275 275 # must have been filled. This sets ``self.colwidths`` which maps
276 276 # attribute descriptors to widths.
277 277 self.colwidths = {}
278 278 for row in self.displayrows:
279 279 for attr in self.displayattrs:
280 280 try:
281 281 length = row[attr][1]
282 282 except KeyError:
283 283 length = 0
284 284 # always add attribute to colwidths, even if it doesn't exist
285 285 if attr not in self.colwidths:
286 286 self.colwidths[attr] = len(attr.name())
287 287 newwidth = max(self.colwidths[attr], length)
288 288 self.colwidths[attr] = newwidth
289 289
290 290 # How many characters do we need to paint the largest item number?
291 291 self.numbersizex = len(str(self.datastarty+self.mainsizey-1))
292 292 # How must space have we got to display data?
293 293 self.mainsizex = self.browser.scrsizex-self.numbersizex-3
294 294 # width of all columns
295 295 self.datasizex = sum(self.colwidths.itervalues()) + len(self.colwidths)
296 296
297 297 def calcdisplayattr(self):
298 298 # Find out which attribute the cursor is on and store this
299 299 # information in ``self.displayattr``.
300 300 pos = 0
301 301 for (i, attr) in enumerate(self.displayattrs):
302 302 if pos+self.colwidths[attr] >= self.curx:
303 303 self.displayattr = (i, attr)
304 304 break
305 305 pos += self.colwidths[attr]+1
306 306 else:
307 307 self.displayattr = (None, ipipe.noitem)
308 308
309 309 def moveto(self, x, y, refresh=False):
310 310 # Move the cursor to the position ``(x,y)`` (in data coordinates,
311 311 # not in screen coordinates). If ``refresh`` is true, all cached
312 312 # values will be recalculated (e.g. because the list has been
313 313 # resorted, so screen positions etc. are no longer valid).
314 314 olddatastarty = self.datastarty
315 315 oldx = self.curx
316 316 oldy = self.cury
317 317 x = int(x+0.5)
318 318 y = int(y+0.5)
319 319 newx = x # remember where we wanted to move
320 320 newy = y # remember where we wanted to move
321 321
322 322 scrollbordery = min(self.browser.scrollbordery, self.mainsizey//2)
323 323 scrollborderx = min(self.browser.scrollborderx, self.mainsizex//2)
324 324
325 325 # Make sure that the cursor didn't leave the main area vertically
326 326 if y < 0:
327 327 y = 0
328 328 # try to get enough items to fill the screen
329 329 self.fetch(max(y+scrollbordery+1, self.mainsizey))
330 330 if y >= len(self.items):
331 331 y = max(0, len(self.items)-1)
332 332
333 333 # Make sure that the cursor stays on screen vertically
334 334 if y < self.datastarty+scrollbordery:
335 335 self.datastarty = max(0, y-scrollbordery)
336 336 elif y >= self.datastarty+self.mainsizey-scrollbordery:
337 337 self.datastarty = max(0, min(y-self.mainsizey+scrollbordery+1,
338 338 len(self.items)-self.mainsizey))
339 339
340 340 if refresh: # Do we need to refresh the complete display?
341 341 self.calcdisplayattrs()
342 342 endy = min(self.datastarty+self.mainsizey, len(self.items))
343 343 self.displayrows = map(self.getrow, xrange(self.datastarty, endy))
344 344 self.calcwidths()
345 345 # Did we scroll vertically => update displayrows
346 346 # and various other attributes
347 347 elif self.datastarty != olddatastarty:
348 348 # Recalculate which attributes we have to display
349 349 olddisplayattrs = self.displayattrs
350 350 self.calcdisplayattrs()
351 351 # If there are new attributes, recreate the cache
352 352 if self.displayattrs != olddisplayattrs:
353 353 endy = min(self.datastarty+self.mainsizey, len(self.items))
354 354 self.displayrows = map(self.getrow, xrange(self.datastarty, endy))
355 355 elif self.datastarty<olddatastarty: # we did scroll up
356 356 # drop rows from the end
357 357 del self.displayrows[self.datastarty-olddatastarty:]
358 358 # fetch new items
359 359 for i in xrange(min(olddatastarty, self.datastarty+self.mainsizey)-1,
360 360 self.datastarty-1, -1):
361 361 try:
362 362 row = self.getrow(i)
363 363 except IndexError:
364 364 # we didn't have enough objects to fill the screen
365 365 break
366 366 self.displayrows.insert(0, row)
367 367 else: # we did scroll down
368 368 # drop rows from the start
369 369 del self.displayrows[:self.datastarty-olddatastarty]
370 370 # fetch new items
371 371 for i in xrange(max(olddatastarty+self.mainsizey, self.datastarty),
372 372 self.datastarty+self.mainsizey):
373 373 try:
374 374 row = self.getrow(i)
375 375 except IndexError:
376 376 # we didn't have enough objects to fill the screen
377 377 break
378 378 self.displayrows.append(row)
379 379 self.calcwidths()
380 380
381 381 # Make sure that the cursor didn't leave the data area horizontally
382 382 if x < 0:
383 383 x = 0
384 384 elif x >= self.datasizex:
385 385 x = max(0, self.datasizex-1)
386 386
387 387 # Make sure that the cursor stays on screen horizontally
388 388 if x < self.datastartx+scrollborderx:
389 389 self.datastartx = max(0, x-scrollborderx)
390 390 elif x >= self.datastartx+self.mainsizex-scrollborderx:
391 391 self.datastartx = max(0, min(x-self.mainsizex+scrollborderx+1,
392 392 self.datasizex-self.mainsizex))
393 393
394 394 if x == oldx and y == oldy and (x != newx or y != newy): # couldn't move
395 395 self.browser.beep()
396 396 else:
397 397 self.curx = x
398 398 self.cury = y
399 399 self.calcdisplayattr()
400 400
401 401 def sort(self, key, reverse=False):
402 402 """
403 403 Sort the currently list of items using the key function ``key``. If
404 404 ``reverse`` is true the sort order is reversed.
405 405 """
406 406 curitem = self.items[self.cury] # Remember where the cursor is now
407 407
408 408 # Sort items
409 409 def realkey(item):
410 410 return key(item.item)
411 411 self.items = ipipe.deque(sorted(self.items, key=realkey, reverse=reverse))
412 412
413 413 # Find out where the object under the cursor went
414 414 cury = self.cury
415 415 for (i, item) in enumerate(self.items):
416 416 if item is curitem:
417 417 cury = i
418 418 break
419 419
420 420 self.moveto(self.curx, cury, refresh=True)
421 421
422 422 def refresh(self):
423 423 """
424 424 Restart iterating the input.
425 425 """
426 426 self.iterator = ipipe.xiter(self.input)
427 427 self.items.clear()
428 428 self.exhausted = False
429 429 self.datastartx = self.datastarty = 0
430 430 self.moveto(0, 0, refresh=True)
431 431
432 432 def refreshfind(self):
433 433 """
434 434 Restart iterating the input and go back to the same object as before
435 435 (if it can be found in the new iterator).
436 436 """
437 437 try:
438 438 oldobject = self.items[self.cury].item
439 439 except IndexError:
440 440 oldobject = ipipe.noitem
441 441 self.iterator = ipipe.xiter(self.input)
442 442 self.items.clear()
443 443 self.exhausted = False
444 444 while True:
445 445 self.fetch(len(self.items)+1)
446 446 if self.exhausted:
447 447 curses.beep()
448 448 self.datastartx = self.datastarty = 0
449 449 self.moveto(self.curx, 0, refresh=True)
450 450 break
451 451 if self.items[-1].item == oldobject:
452 452 self.datastartx = self.datastarty = 0
453 453 self.moveto(self.curx, len(self.items)-1, refresh=True)
454 454 break
455 455
456 456
457 457 class _CommandInput(object):
458 458 keymap = Keymap()
459 459 keymap.register("left", curses.KEY_LEFT)
460 460 keymap.register("right", curses.KEY_RIGHT)
461 461 keymap.register("home", curses.KEY_HOME, "\x01") # Ctrl-A
462 462 keymap.register("end", curses.KEY_END, "\x05") # Ctrl-E
463 463 # FIXME: What's happening here?
464 464 keymap.register("backspace", curses.KEY_BACKSPACE, "\x08\x7f")
465 465 keymap.register("delete", curses.KEY_DC)
466 466 keymap.register("delend", 0x0b) # Ctrl-K
467 467 keymap.register("execute", "\r\n")
468 468 keymap.register("up", curses.KEY_UP)
469 469 keymap.register("down", curses.KEY_DOWN)
470 470 keymap.register("incsearchup", curses.KEY_PPAGE)
471 471 keymap.register("incsearchdown", curses.KEY_NPAGE)
472 472 keymap.register("exit", "\x18"), # Ctrl-X
473 473
474 474 def __init__(self, prompt):
475 475 self.prompt = prompt
476 476 self.history = []
477 477 self.maxhistory = 100
478 478 self.input = ""
479 479 self.curx = 0
480 480 self.cury = -1 # blank line
481 481
482 482 def start(self):
483 483 self.input = ""
484 484 self.curx = 0
485 485 self.cury = -1 # blank line
486 486
487 487 def handlekey(self, browser, key):
488 488 cmdname = self.keymap.get(key, None)
489 489 if cmdname is not None:
490 490 cmdfunc = getattr(self, "cmd_%s" % cmdname, None)
491 491 if cmdfunc is not None:
492 492 return cmdfunc(browser)
493 493 curses.beep()
494 494 elif key != -1:
495 495 try:
496 496 char = chr(key)
497 497 except ValueError:
498 498 curses.beep()
499 499 else:
500 500 return self.handlechar(browser, char)
501 501
502 502 def handlechar(self, browser, char):
503 503 self.input = self.input[:self.curx] + char + self.input[self.curx:]
504 504 self.curx += 1
505 505 return True
506 506
507 507 def dohistory(self):
508 508 self.history.insert(0, self.input)
509 509 del self.history[:-self.maxhistory]
510 510
511 511 def cmd_backspace(self, browser):
512 512 if self.curx:
513 513 self.input = self.input[:self.curx-1] + self.input[self.curx:]
514 514 self.curx -= 1
515 515 return True
516 516 else:
517 517 curses.beep()
518 518
519 519 def cmd_delete(self, browser):
520 520 if self.curx<len(self.input):
521 521 self.input = self.input[:self.curx] + self.input[self.curx+1:]
522 522 return True
523 523 else:
524 524 curses.beep()
525 525
526 526 def cmd_delend(self, browser):
527 527 if self.curx<len(self.input):
528 528 self.input = self.input[:self.curx]
529 529 return True
530 530
531 531 def cmd_left(self, browser):
532 532 if self.curx:
533 533 self.curx -= 1
534 534 return True
535 535 else:
536 536 curses.beep()
537 537
538 538 def cmd_right(self, browser):
539 539 if self.curx < len(self.input):
540 540 self.curx += 1
541 541 return True
542 542 else:
543 543 curses.beep()
544 544
545 545 def cmd_home(self, browser):
546 546 if self.curx:
547 547 self.curx = 0
548 548 return True
549 549 else:
550 550 curses.beep()
551 551
552 552 def cmd_end(self, browser):
553 553 if self.curx < len(self.input):
554 554 self.curx = len(self.input)
555 555 return True
556 556 else:
557 557 curses.beep()
558 558
559 559 def cmd_up(self, browser):
560 560 if self.cury < len(self.history)-1:
561 561 self.cury += 1
562 562 self.input = self.history[self.cury]
563 563 self.curx = len(self.input)
564 564 return True
565 565 else:
566 566 curses.beep()
567 567
568 568 def cmd_down(self, browser):
569 569 if self.cury >= 0:
570 570 self.cury -= 1
571 571 if self.cury>=0:
572 572 self.input = self.history[self.cury]
573 573 else:
574 574 self.input = ""
575 575 self.curx = len(self.input)
576 576 return True
577 577 else:
578 578 curses.beep()
579 579
580 580 def cmd_incsearchup(self, browser):
581 581 prefix = self.input[:self.curx]
582 582 cury = self.cury
583 583 while True:
584 584 cury += 1
585 585 if cury >= len(self.history):
586 586 break
587 587 if self.history[cury].startswith(prefix):
588 588 self.input = self.history[cury]
589 589 self.cury = cury
590 590 return True
591 591 curses.beep()
592 592
593 593 def cmd_incsearchdown(self, browser):
594 594 prefix = self.input[:self.curx]
595 595 cury = self.cury
596 596 while True:
597 597 cury -= 1
598 598 if cury <= 0:
599 599 break
600 600 if self.history[cury].startswith(prefix):
601 601 self.input = self.history[self.cury]
602 602 self.cury = cury
603 603 return True
604 604 curses.beep()
605 605
606 606 def cmd_exit(self, browser):
607 607 browser.mode = "default"
608 608 return True
609 609
610 610 def cmd_execute(self, browser):
611 611 raise NotImplementedError
612 612
613 613
614 614 class _CommandGoto(_CommandInput):
615 615 def __init__(self):
616 616 _CommandInput.__init__(self, "goto object #")
617 617
618 618 def handlechar(self, browser, char):
619 619 # Only accept digits
620 620 if not "0" <= char <= "9":
621 621 curses.beep()
622 622 else:
623 623 return _CommandInput.handlechar(self, browser, char)
624 624
625 625 def cmd_execute(self, browser):
626 626 level = browser.levels[-1]
627 627 if self.input:
628 628 self.dohistory()
629 629 level.moveto(level.curx, int(self.input))
630 630 browser.mode = "default"
631 631 return True
632 632
633 633
634 634 class _CommandFind(_CommandInput):
635 635 def __init__(self):
636 636 _CommandInput.__init__(self, "find expression")
637 637
638 638 def cmd_execute(self, browser):
639 639 level = browser.levels[-1]
640 640 if self.input:
641 641 self.dohistory()
642 642 while True:
643 643 cury = level.cury
644 644 level.moveto(level.curx, cury+1)
645 645 if cury == level.cury:
646 646 curses.beep()
647 647 break # hit end
648 648 item = level.items[level.cury].item
649 649 try:
650 650 globals = ipipe.getglobals(None)
651 651 if eval(self.input, globals, ipipe.AttrNamespace(item)):
652 652 break # found something
653 653 except (KeyboardInterrupt, SystemExit):
654 654 raise
655 655 except Exception, exc:
656 656 browser.report(exc)
657 657 curses.beep()
658 658 break # break on error
659 659 browser.mode = "default"
660 660 return True
661 661
662 662
663 663 class _CommandFindBackwards(_CommandInput):
664 664 def __init__(self):
665 665 _CommandInput.__init__(self, "find backwards expression")
666 666
667 667 def cmd_execute(self, browser):
668 668 level = browser.levels[-1]
669 669 if self.input:
670 670 self.dohistory()
671 671 while level.cury:
672 672 level.moveto(level.curx, level.cury-1)
673 673 item = level.items[level.cury].item
674 674 try:
675 675 globals = ipipe.getglobals(None)
676 676 if eval(self.input, globals, ipipe.AttrNamespace(item)):
677 677 break # found something
678 678 except (KeyboardInterrupt, SystemExit):
679 679 raise
680 680 except Exception, exc:
681 681 browser.report(exc)
682 682 curses.beep()
683 683 break # break on error
684 684 else:
685 685 curses.beep()
686 686 browser.mode = "default"
687 687 return True
688 688
689 689
690 690 class ibrowse(ipipe.Display):
691 691 # Show this many lines from the previous screen when paging horizontally
692 692 pageoverlapx = 1
693 693
694 694 # Show this many lines from the previous screen when paging vertically
695 695 pageoverlapy = 1
696 696
697 697 # Start scrolling when the cursor is less than this number of columns
698 698 # away from the left or right screen edge
699 699 scrollborderx = 10
700 700
701 701 # Start scrolling when the cursor is less than this number of lines
702 702 # away from the top or bottom screen edge
703 703 scrollbordery = 5
704 704
705 705 # Accelerate by this factor when scrolling horizontally
706 706 acceleratex = 1.05
707 707
708 708 # Accelerate by this factor when scrolling vertically
709 709 acceleratey = 1.05
710 710
711 711 # The maximum horizontal scroll speed
712 712 # (as a factor of the screen width (i.e. 0.5 == half a screen width)
713 713 maxspeedx = 0.5
714 714
715 715 # The maximum vertical scroll speed
716 716 # (as a factor of the screen height (i.e. 0.5 == half a screen height)
717 717 maxspeedy = 0.5
718 718
719 719 # The maximum number of header lines for browser level
720 720 # if the nesting is deeper, only the innermost levels are displayed
721 721 maxheaders = 5
722 722
723 723 # The approximate maximum length of a column entry
724 724 maxattrlength = 200
725 725
726 726 # Styles for various parts of the GUI
727 727 style_objheadertext = astyle.Style.fromstr("white:black:bold|reverse")
728 728 style_objheadernumber = astyle.Style.fromstr("white:blue:bold|reverse")
729 729 style_objheaderobject = astyle.Style.fromstr("white:black:reverse")
730 730 style_colheader = astyle.Style.fromstr("blue:white:reverse")
731 731 style_colheaderhere = astyle.Style.fromstr("green:black:bold|reverse")
732 732 style_colheadersep = astyle.Style.fromstr("blue:black:reverse")
733 733 style_number = astyle.Style.fromstr("blue:white:reverse")
734 734 style_numberhere = astyle.Style.fromstr("green:black:bold|reverse")
735 735 style_sep = astyle.Style.fromstr("blue:black")
736 736 style_data = astyle.Style.fromstr("white:black")
737 737 style_datapad = astyle.Style.fromstr("blue:black:bold")
738 738 style_footer = astyle.Style.fromstr("black:white")
739 739 style_report = astyle.Style.fromstr("white:black")
740 740
741 741 # Column separator in header
742 742 headersepchar = "|"
743 743
744 744 # Character for padding data cell entries
745 745 datapadchar = "."
746 746
747 747 # Column separator in data area
748 748 datasepchar = "|"
749 749
750 750 # Character to use for "empty" cell (i.e. for non-existing attributes)
751 751 nodatachar = "-"
752 752
753 753 # Prompts for modes that require keyboard input
754 754 prompts = {
755 755 "goto": _CommandGoto(),
756 756 "find": _CommandFind(),
757 757 "findbackwards": _CommandFindBackwards()
758 758 }
759 759
760 760 # Maps curses key codes to "function" names
761 761 keymap = Keymap()
762 762 keymap.register("quit", "q")
763 763 keymap.register("up", curses.KEY_UP)
764 764 keymap.register("down", curses.KEY_DOWN)
765 765 keymap.register("pageup", curses.KEY_PPAGE)
766 766 keymap.register("pagedown", curses.KEY_NPAGE)
767 767 keymap.register("left", curses.KEY_LEFT)
768 768 keymap.register("right", curses.KEY_RIGHT)
769 769 keymap.register("home", curses.KEY_HOME, "\x01")
770 770 keymap.register("end", curses.KEY_END, "\x05")
771 771 keymap.register("prevattr", "<\x1b")
772 772 keymap.register("nextattr", ">\t")
773 773 keymap.register("pick", "p")
774 774 keymap.register("pickattr", "P")
775 775 keymap.register("pickallattrs", "C")
776 776 keymap.register("pickmarked", "m")
777 777 keymap.register("pickmarkedattr", "M")
778 778 keymap.register("pickinput", "i")
779 779 keymap.register("pickinputattr", "I")
780 780 keymap.register("hideattr", "h")
781 781 keymap.register("unhideattrs", "H")
782 782 keymap.register("help", "?")
783 783 keymap.register("enter", "\r\n")
784 784 keymap.register("enterattr", "E")
785 785 # FIXME: What's happening here?
786 786 keymap.register("leave", curses.KEY_BACKSPACE, "x\x08\x7f")
787 787 keymap.register("detail", "d")
788 788 keymap.register("detailattr", "D")
789 789 keymap.register("tooglemark", " ")
790 790 keymap.register("markrange", "%")
791 791 keymap.register("sortattrasc", "v")
792 792 keymap.register("sortattrdesc", "V")
793 793 keymap.register("goto", "g")
794 794 keymap.register("find", "f")
795 795 keymap.register("findbackwards", "b")
796 796 keymap.register("refresh", "r")
797 797 keymap.register("refreshfind", "R")
798 798
799 def __init__(self, input=None, attrs=None):
799 def __init__(self, input=None, *attrs):
800 800 """
801 801 Create a new browser. If ``attrs`` is not empty, it is the list
802 802 of attributes that will be displayed in the browser, otherwise
803 803 these will be determined by the objects on screen.
804 804 """
805 self.input = input
805 ipipe.Display.__init__(self, input)
806 806
807 if attrs is None:
808 attrs = ()
809 807 self.attrs = attrs
810 808
811 809 # Stack of browser levels
812 810 self.levels = []
813 811 # how many colums to scroll (Changes when accelerating)
814 812 self.stepx = 1.
815 813
816 814 # how many rows to scroll (Changes when accelerating)
817 815 self.stepy = 1.
818 816
819 817 # Beep on the edges of the data area? (Will be set to ``False``
820 818 # once the cursor hits the edge of the screen, so we don't get
821 819 # multiple beeps).
822 820 self._dobeep = True
823 821
824 822 # Cache for registered ``curses`` colors and styles.
825 823 self._styles = {}
826 824 self._colors = {}
827 825 self._maxcolor = 1
828 826
829 827 # How many header lines do we want to paint (the numbers of levels
830 828 # we have, but with an upper bound)
831 829 self._headerlines = 1
832 830
833 831 # Index of first header line
834 832 self._firstheaderline = 0
835 833
836 834 # curses window
837 835 self.scr = None
838 836 # report in the footer line (error, executed command etc.)
839 837 self._report = None
840 838
841 839 # value to be returned to the caller (set by commands)
842 840 self.returnvalue = None
843 841
844 842 # The mode the browser is in
845 843 # e.g. normal browsing or entering an argument for a command
846 844 self.mode = "default"
847 845
848 846 # set by the SIGWINCH signal handler
849 847 self.resized = False
850 848
851 849 def nextstepx(self, step):
852 850 """
853 851 Accelerate horizontally.
854 852 """
855 853 return max(1., min(step*self.acceleratex,
856 854 self.maxspeedx*self.levels[-1].mainsizex))
857 855
858 856 def nextstepy(self, step):
859 857 """
860 858 Accelerate vertically.
861 859 """
862 860 return max(1., min(step*self.acceleratey,
863 861 self.maxspeedy*self.levels[-1].mainsizey))
864 862
865 863 def getstyle(self, style):
866 864 """
867 865 Register the ``style`` with ``curses`` or get it from the cache,
868 866 if it has been registered before.
869 867 """
870 868 try:
871 869 return self._styles[style.fg, style.bg, style.attrs]
872 870 except KeyError:
873 871 attrs = 0
874 872 for b in astyle.A2CURSES:
875 873 if style.attrs & b:
876 874 attrs |= astyle.A2CURSES[b]
877 875 try:
878 876 color = self._colors[style.fg, style.bg]
879 877 except KeyError:
880 878 curses.init_pair(
881 879 self._maxcolor,
882 880 astyle.COLOR2CURSES[style.fg],
883 881 astyle.COLOR2CURSES[style.bg]
884 882 )
885 883 color = curses.color_pair(self._maxcolor)
886 884 self._colors[style.fg, style.bg] = color
887 885 self._maxcolor += 1
888 886 c = color | attrs
889 887 self._styles[style.fg, style.bg, style.attrs] = c
890 888 return c
891 889
892 890 def addstr(self, y, x, begx, endx, text, style):
893 891 """
894 892 A version of ``curses.addstr()`` that can handle ``x`` coordinates
895 893 that are outside the screen.
896 894 """
897 895 text2 = text[max(0, begx-x):max(0, endx-x)]
898 896 if text2:
899 897 self.scr.addstr(y, max(x, begx), text2, self.getstyle(style))
900 898 return len(text)
901 899
902 900 def addchr(self, y, x, begx, endx, c, l, style):
903 901 x0 = max(x, begx)
904 902 x1 = min(x+l, endx)
905 903 if x1>x0:
906 904 self.scr.addstr(y, x0, c*(x1-x0), self.getstyle(style))
907 905 return l
908 906
909 907 def _calcheaderlines(self, levels):
910 908 # Calculate how many headerlines do we have to display, if we have
911 909 # ``levels`` browser levels
912 910 if levels is None:
913 911 levels = len(self.levels)
914 912 self._headerlines = min(self.maxheaders, levels)
915 913 self._firstheaderline = levels-self._headerlines
916 914
917 915 def getstylehere(self, style):
918 916 """
919 917 Return a style for displaying the original style ``style``
920 918 in the row the cursor is on.
921 919 """
922 920 return astyle.Style(style.fg, astyle.COLOR_BLUE, style.attrs | astyle.A_BOLD)
923 921
924 922 def report(self, msg):
925 923 """
926 924 Store the message ``msg`` for display below the footer line. This
927 925 will be displayed as soon as the screen is redrawn.
928 926 """
929 927 self._report = msg
930 928
931 929 def enter(self, item, *attrs):
932 930 """
933 931 Enter the object ``item``. If ``attrs`` is specified, it will be used
934 932 as a fixed list of attributes to display.
935 933 """
936 934 if self.levels and item is self.levels[-1].input:
937 935 curses.beep()
938 936 self.report(CommandError("Recursion on input object"))
939 937 else:
940 938 oldlevels = len(self.levels)
941 939 self._calcheaderlines(oldlevels+1)
942 940 try:
943 941 level = _BrowserLevel(
944 942 self,
945 943 item,
946 944 self.scrsizey-1-self._headerlines-2,
947 945 *attrs
948 946 )
949 947 except (KeyboardInterrupt, SystemExit):
950 948 raise
951 949 except Exception, exc:
952 950 if not self.levels:
953 951 raise
954 952 self._calcheaderlines(oldlevels)
955 953 curses.beep()
956 954 self.report(exc)
957 955 else:
958 956 self.levels.append(level)
959 957
960 958 def startkeyboardinput(self, mode):
961 959 """
962 960 Enter mode ``mode``, which requires keyboard input.
963 961 """
964 962 self.mode = mode
965 963 self.prompts[mode].start()
966 964
967 965 def keylabel(self, keycode):
968 966 """
969 967 Return a pretty name for the ``curses`` key ``keycode`` (used in the
970 968 help screen and in reports about unassigned keys).
971 969 """
972 970 if keycode <= 0xff:
973 971 specialsnames = {
974 972 ord("\n"): "RETURN",
975 973 ord(" "): "SPACE",
976 974 ord("\t"): "TAB",
977 975 ord("\x7f"): "DELETE",
978 976 ord("\x08"): "BACKSPACE",
979 977 }
980 978 if keycode in specialsnames:
981 979 return specialsnames[keycode]
982 980 elif 0x00 < keycode < 0x20:
983 981 return "CTRL-%s" % chr(keycode + 64)
984 982 return repr(chr(keycode))
985 983 for name in dir(curses):
986 984 if name.startswith("KEY_") and getattr(curses, name) == keycode:
987 985 return name
988 986 return str(keycode)
989 987
990 988 def beep(self, force=False):
991 989 if force or self._dobeep:
992 990 curses.beep()
993 991 # don't beep again (as long as the same key is pressed)
994 992 self._dobeep = False
995 993
996 994 def cmd_up(self):
997 995 """
998 996 Move the cursor to the previous row.
999 997 """
1000 998 level = self.levels[-1]
1001 999 self.report("up")
1002 1000 level.moveto(level.curx, level.cury-self.stepy)
1003 1001
1004 1002 def cmd_down(self):
1005 1003 """
1006 1004 Move the cursor to the next row.
1007 1005 """
1008 1006 level = self.levels[-1]
1009 1007 self.report("down")
1010 1008 level.moveto(level.curx, level.cury+self.stepy)
1011 1009
1012 1010 def cmd_pageup(self):
1013 1011 """
1014 1012 Move the cursor up one page.
1015 1013 """
1016 1014 level = self.levels[-1]
1017 1015 self.report("page up")
1018 1016 level.moveto(level.curx, level.cury-level.mainsizey+self.pageoverlapy)
1019 1017
1020 1018 def cmd_pagedown(self):
1021 1019 """
1022 1020 Move the cursor down one page.
1023 1021 """
1024 1022 level = self.levels[-1]
1025 1023 self.report("page down")
1026 1024 level.moveto(level.curx, level.cury+level.mainsizey-self.pageoverlapy)
1027 1025
1028 1026 def cmd_left(self):
1029 1027 """
1030 1028 Move the cursor left.
1031 1029 """
1032 1030 level = self.levels[-1]
1033 1031 self.report("left")
1034 1032 level.moveto(level.curx-self.stepx, level.cury)
1035 1033
1036 1034 def cmd_right(self):
1037 1035 """
1038 1036 Move the cursor right.
1039 1037 """
1040 1038 level = self.levels[-1]
1041 1039 self.report("right")
1042 1040 level.moveto(level.curx+self.stepx, level.cury)
1043 1041
1044 1042 def cmd_home(self):
1045 1043 """
1046 1044 Move the cursor to the first column.
1047 1045 """
1048 1046 level = self.levels[-1]
1049 1047 self.report("home")
1050 1048 level.moveto(0, level.cury)
1051 1049
1052 1050 def cmd_end(self):
1053 1051 """
1054 1052 Move the cursor to the last column.
1055 1053 """
1056 1054 level = self.levels[-1]
1057 1055 self.report("end")
1058 1056 level.moveto(level.datasizex+level.mainsizey-self.pageoverlapx, level.cury)
1059 1057
1060 1058 def cmd_prevattr(self):
1061 1059 """
1062 1060 Move the cursor one attribute column to the left.
1063 1061 """
1064 1062 level = self.levels[-1]
1065 1063 if level.displayattr[0] is None or level.displayattr[0] == 0:
1066 1064 self.beep()
1067 1065 else:
1068 1066 self.report("prevattr")
1069 1067 pos = 0
1070 1068 for (i, attrname) in enumerate(level.displayattrs):
1071 1069 if i == level.displayattr[0]-1:
1072 1070 break
1073 1071 pos += level.colwidths[attrname] + 1
1074 1072 level.moveto(pos, level.cury)
1075 1073
1076 1074 def cmd_nextattr(self):
1077 1075 """
1078 1076 Move the cursor one attribute column to the right.
1079 1077 """
1080 1078 level = self.levels[-1]
1081 1079 if level.displayattr[0] is None or level.displayattr[0] == len(level.displayattrs)-1:
1082 1080 self.beep()
1083 1081 else:
1084 1082 self.report("nextattr")
1085 1083 pos = 0
1086 1084 for (i, attrname) in enumerate(level.displayattrs):
1087 1085 if i == level.displayattr[0]+1:
1088 1086 break
1089 1087 pos += level.colwidths[attrname] + 1
1090 1088 level.moveto(pos, level.cury)
1091 1089
1092 1090 def cmd_pick(self):
1093 1091 """
1094 1092 'Pick' the object under the cursor (i.e. the row the cursor is on).
1095 1093 This leaves the browser and returns the picked object to the caller.
1096 1094 (In IPython this object will be available as the ``_`` variable.)
1097 1095 """
1098 1096 level = self.levels[-1]
1099 1097 self.returnvalue = level.items[level.cury].item
1100 1098 return True
1101 1099
1102 1100 def cmd_pickattr(self):
1103 1101 """
1104 1102 'Pick' the attribute under the cursor (i.e. the row/column the
1105 1103 cursor is on).
1106 1104 """
1107 1105 level = self.levels[-1]
1108 1106 attr = level.displayattr[1]
1109 1107 if attr is ipipe.noitem:
1110 1108 curses.beep()
1111 1109 self.report(CommandError("no column under cursor"))
1112 1110 return
1113 1111 value = attr.value(level.items[level.cury].item)
1114 1112 if value is ipipe.noitem:
1115 1113 curses.beep()
1116 1114 self.report(AttributeError(attr.name()))
1117 1115 else:
1118 1116 self.returnvalue = value
1119 1117 return True
1120 1118
1121 1119 def cmd_pickallattrs(self):
1122 1120 """
1123 1121 Pick' the complete column under the cursor (i.e. the attribute under
1124 1122 the cursor) from all currently fetched objects. These attributes
1125 1123 will be returned as a list.
1126 1124 """
1127 1125 level = self.levels[-1]
1128 1126 attr = level.displayattr[1]
1129 1127 if attr is ipipe.noitem:
1130 1128 curses.beep()
1131 1129 self.report(CommandError("no column under cursor"))
1132 1130 return
1133 1131 result = []
1134 1132 for cache in level.items:
1135 1133 value = attr.value(cache.item)
1136 1134 if value is not ipipe.noitem:
1137 1135 result.append(value)
1138 1136 self.returnvalue = result
1139 1137 return True
1140 1138
1141 1139 def cmd_pickmarked(self):
1142 1140 """
1143 1141 'Pick' marked objects. Marked objects will be returned as a list.
1144 1142 """
1145 1143 level = self.levels[-1]
1146 1144 self.returnvalue = [cache.item for cache in level.items if cache.marked]
1147 1145 return True
1148 1146
1149 1147 def cmd_pickmarkedattr(self):
1150 1148 """
1151 1149 'Pick' the attribute under the cursor from all marked objects
1152 1150 (This returns a list).
1153 1151 """
1154 1152
1155 1153 level = self.levels[-1]
1156 1154 attr = level.displayattr[1]
1157 1155 if attr is ipipe.noitem:
1158 1156 curses.beep()
1159 1157 self.report(CommandError("no column under cursor"))
1160 1158 return
1161 1159 result = []
1162 1160 for cache in level.items:
1163 1161 if cache.marked:
1164 1162 value = attr.value(cache.item)
1165 1163 if value is not ipipe.noitem:
1166 1164 result.append(value)
1167 1165 self.returnvalue = result
1168 1166 return True
1169 1167
1170 1168 def cmd_pickinput(self):
1171 1169 """
1172 1170 Use the object under the cursor (i.e. the row the cursor is on) as
1173 1171 the next input line. This leaves the browser and puts the picked object
1174 1172 in the input.
1175 1173 """
1176 1174 level = self.levels[-1]
1177 1175 value = level.items[level.cury].item
1178 1176 self.returnvalue = None
1179 1177 api = ipapi.get()
1180 1178 api.set_next_input(str(value))
1181 1179 return True
1182 1180
1183 1181 def cmd_pickinputattr(self):
1184 1182 """
1185 1183 Use the attribute under the cursor i.e. the row/column the cursor is on)
1186 1184 as the next input line. This leaves the browser and puts the picked
1187 1185 object in the input.
1188 1186 """
1189 1187 level = self.levels[-1]
1190 1188 attr = level.displayattr[1]
1191 1189 if attr is ipipe.noitem:
1192 1190 curses.beep()
1193 1191 self.report(CommandError("no column under cursor"))
1194 1192 return
1195 1193 value = attr.value(level.items[level.cury].item)
1196 1194 if value is ipipe.noitem:
1197 1195 curses.beep()
1198 1196 self.report(AttributeError(attr.name()))
1199 1197 self.returnvalue = None
1200 1198 api = ipapi.get()
1201 1199 api.set_next_input(str(value))
1202 1200 return True
1203 1201
1204 1202 def cmd_markrange(self):
1205 1203 """
1206 1204 Mark all objects from the last marked object before the current cursor
1207 1205 position to the cursor position.
1208 1206 """
1209 1207 level = self.levels[-1]
1210 1208 self.report("markrange")
1211 1209 start = None
1212 1210 if level.items:
1213 1211 for i in xrange(level.cury, -1, -1):
1214 1212 if level.items[i].marked:
1215 1213 start = i
1216 1214 break
1217 1215 if start is None:
1218 1216 self.report(CommandError("no mark before cursor"))
1219 1217 curses.beep()
1220 1218 else:
1221 1219 for i in xrange(start, level.cury+1):
1222 1220 cache = level.items[i]
1223 1221 if not cache.marked:
1224 1222 cache.marked = True
1225 1223 level.marked += 1
1226 1224
1227 1225 def cmd_enter(self):
1228 1226 """
1229 1227 Enter the object under the cursor. (what this mean depends on the object
1230 1228 itself (i.e. how it implements iteration). This opens a new browser 'level'.
1231 1229 """
1232 1230 level = self.levels[-1]
1233 1231 try:
1234 1232 item = level.items[level.cury].item
1235 1233 except IndexError:
1236 1234 self.report(CommandError("No object"))
1237 1235 curses.beep()
1238 1236 else:
1239 1237 self.report("entering object...")
1240 1238 self.enter(item)
1241 1239
1242 1240 def cmd_leave(self):
1243 1241 """
1244 1242 Leave the current browser level and go back to the previous one.
1245 1243 """
1246 1244 self.report("leave")
1247 1245 if len(self.levels) > 1:
1248 1246 self._calcheaderlines(len(self.levels)-1)
1249 1247 self.levels.pop(-1)
1250 1248 else:
1251 1249 self.report(CommandError("This is the last level"))
1252 1250 curses.beep()
1253 1251
1254 1252 def cmd_enterattr(self):
1255 1253 """
1256 1254 Enter the attribute under the cursor.
1257 1255 """
1258 1256 level = self.levels[-1]
1259 1257 attr = level.displayattr[1]
1260 1258 if attr is ipipe.noitem:
1261 1259 curses.beep()
1262 1260 self.report(CommandError("no column under cursor"))
1263 1261 return
1264 1262 try:
1265 1263 item = level.items[level.cury].item
1266 1264 except IndexError:
1267 1265 self.report(CommandError("No object"))
1268 1266 curses.beep()
1269 1267 else:
1270 1268 value = attr.value(item)
1271 1269 name = attr.name()
1272 1270 if value is ipipe.noitem:
1273 1271 self.report(AttributeError(name))
1274 1272 else:
1275 1273 self.report("entering object attribute %s..." % name)
1276 1274 self.enter(value)
1277 1275
1278 1276 def cmd_detail(self):
1279 1277 """
1280 1278 Show a detail view of the object under the cursor. This shows the
1281 1279 name, type, doc string and value of the object attributes (and it
1282 1280 might show more attributes than in the list view, depending on
1283 1281 the object).
1284 1282 """
1285 1283 level = self.levels[-1]
1286 1284 try:
1287 1285 item = level.items[level.cury].item
1288 1286 except IndexError:
1289 1287 self.report(CommandError("No object"))
1290 1288 curses.beep()
1291 1289 else:
1292 1290 self.report("entering detail view for object...")
1293 1291 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
1294 1292 self.enter(attrs)
1295 1293
1296 1294 def cmd_detailattr(self):
1297 1295 """
1298 1296 Show a detail view of the attribute under the cursor.
1299 1297 """
1300 1298 level = self.levels[-1]
1301 1299 attr = level.displayattr[1]
1302 1300 if attr is ipipe.noitem:
1303 1301 curses.beep()
1304 1302 self.report(CommandError("no attribute"))
1305 1303 return
1306 1304 try:
1307 1305 item = level.items[level.cury].item
1308 1306 except IndexError:
1309 1307 self.report(CommandError("No object"))
1310 1308 curses.beep()
1311 1309 else:
1312 1310 try:
1313 1311 item = attr.value(item)
1314 1312 except (KeyboardInterrupt, SystemExit):
1315 1313 raise
1316 1314 except Exception, exc:
1317 1315 self.report(exc)
1318 1316 else:
1319 1317 self.report("entering detail view for attribute %s..." % attr.name())
1320 1318 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
1321 1319 self.enter(attrs)
1322 1320
1323 1321 def cmd_tooglemark(self):
1324 1322 """
1325 1323 Mark/unmark the object under the cursor. Marked objects have a '!'
1326 1324 after the row number).
1327 1325 """
1328 1326 level = self.levels[-1]
1329 1327 self.report("toggle mark")
1330 1328 try:
1331 1329 item = level.items[level.cury]
1332 1330 except IndexError: # no items?
1333 1331 pass
1334 1332 else:
1335 1333 if item.marked:
1336 1334 item.marked = False
1337 1335 level.marked -= 1
1338 1336 else:
1339 1337 item.marked = True
1340 1338 level.marked += 1
1341 1339
1342 1340 def cmd_sortattrasc(self):
1343 1341 """
1344 1342 Sort the objects (in ascending order) using the attribute under
1345 1343 the cursor as the sort key.
1346 1344 """
1347 1345 level = self.levels[-1]
1348 1346 attr = level.displayattr[1]
1349 1347 if attr is ipipe.noitem:
1350 1348 curses.beep()
1351 1349 self.report(CommandError("no column under cursor"))
1352 1350 return
1353 1351 self.report("sort by %s (ascending)" % attr.name())
1354 1352 def key(item):
1355 1353 try:
1356 1354 return attr.value(item)
1357 1355 except (KeyboardInterrupt, SystemExit):
1358 1356 raise
1359 1357 except Exception:
1360 1358 return None
1361 1359 level.sort(key)
1362 1360
1363 1361 def cmd_sortattrdesc(self):
1364 1362 """
1365 1363 Sort the objects (in descending order) using the attribute under
1366 1364 the cursor as the sort key.
1367 1365 """
1368 1366 level = self.levels[-1]
1369 1367 attr = level.displayattr[1]
1370 1368 if attr is ipipe.noitem:
1371 1369 curses.beep()
1372 1370 self.report(CommandError("no column under cursor"))
1373 1371 return
1374 1372 self.report("sort by %s (descending)" % attr.name())
1375 1373 def key(item):
1376 1374 try:
1377 1375 return attr.value(item)
1378 1376 except (KeyboardInterrupt, SystemExit):
1379 1377 raise
1380 1378 except Exception:
1381 1379 return None
1382 1380 level.sort(key, reverse=True)
1383 1381
1384 1382 def cmd_hideattr(self):
1385 1383 """
1386 1384 Hide the attribute under the cursor.
1387 1385 """
1388 1386 level = self.levels[-1]
1389 1387 if level.displayattr[0] is None:
1390 1388 self.beep()
1391 1389 else:
1392 1390 self.report("hideattr")
1393 1391 level.hiddenattrs.add(level.displayattr[1])
1394 1392 level.moveto(level.curx, level.cury, refresh=True)
1395 1393
1396 1394 def cmd_unhideattrs(self):
1397 1395 """
1398 1396 Make all attributes visible again.
1399 1397 """
1400 1398 level = self.levels[-1]
1401 1399 self.report("unhideattrs")
1402 1400 level.hiddenattrs.clear()
1403 1401 level.moveto(level.curx, level.cury, refresh=True)
1404 1402
1405 1403 def cmd_goto(self):
1406 1404 """
1407 1405 Jump to a row. The row number can be entered at the
1408 1406 bottom of the screen.
1409 1407 """
1410 1408 self.startkeyboardinput("goto")
1411 1409
1412 1410 def cmd_find(self):
1413 1411 """
1414 1412 Search forward for a row. The search condition can be entered at the
1415 1413 bottom of the screen.
1416 1414 """
1417 1415 self.startkeyboardinput("find")
1418 1416
1419 1417 def cmd_findbackwards(self):
1420 1418 """
1421 1419 Search backward for a row. The search condition can be entered at the
1422 1420 bottom of the screen.
1423 1421 """
1424 1422 self.startkeyboardinput("findbackwards")
1425 1423
1426 1424 def cmd_refresh(self):
1427 1425 """
1428 1426 Refreshes the display by restarting the iterator.
1429 1427 """
1430 1428 level = self.levels[-1]
1431 1429 self.report("refresh")
1432 1430 level.refresh()
1433 1431
1434 1432 def cmd_refreshfind(self):
1435 1433 """
1436 1434 Refreshes the display by restarting the iterator and goes back to the
1437 1435 same object the cursor was on before restarting (if this object can't be
1438 1436 found the cursor jumps back to the first object).
1439 1437 """
1440 1438 level = self.levels[-1]
1441 1439 self.report("refreshfind")
1442 1440 level.refreshfind()
1443 1441
1444 1442 def cmd_help(self):
1445 1443 """
1446 1444 Opens the help screen as a new browser level, describing keyboard
1447 1445 shortcuts.
1448 1446 """
1449 1447 for level in self.levels:
1450 1448 if isinstance(level.input, _BrowserHelp):
1451 1449 curses.beep()
1452 1450 self.report(CommandError("help already active"))
1453 1451 return
1454 1452
1455 1453 self.enter(_BrowserHelp(self))
1456 1454
1457 1455 def cmd_quit(self):
1458 1456 """
1459 1457 Quit the browser and return to the IPython prompt.
1460 1458 """
1461 1459 self.returnvalue = None
1462 1460 return True
1463 1461
1464 1462 def sigwinchhandler(self, signal, frame):
1465 1463 self.resized = True
1466 1464
1467 1465 def _dodisplay(self, scr):
1468 1466 """
1469 1467 This method is the workhorse of the browser. It handles screen
1470 1468 drawing and the keyboard.
1471 1469 """
1472 1470 self.scr = scr
1473 1471 curses.halfdelay(1)
1474 1472 footery = 2
1475 1473
1476 1474 keys = []
1477 1475 for cmd in ("quit", "help"):
1478 1476 key = self.keymap.findkey(cmd, None)
1479 1477 if key is not None:
1480 1478 keys.append("%s=%s" % (self.keylabel(key), cmd))
1481 1479 helpmsg = " | %s" % " ".join(keys)
1482 1480
1483 1481 scr.clear()
1484 1482 msg = "Fetching first batch of objects..."
1485 1483 (self.scrsizey, self.scrsizex) = scr.getmaxyx()
1486 1484 scr.addstr(self.scrsizey//2, (self.scrsizex-len(msg))//2, msg)
1487 1485 scr.refresh()
1488 1486
1489 1487 lastc = -1
1490 1488
1491 1489 self.levels = []
1492 1490 # enter the first level
1493 1491 self.enter(self.input, *self.attrs)
1494 1492
1495 1493 self._calcheaderlines(None)
1496 1494
1497 1495 while True:
1498 1496 level = self.levels[-1]
1499 1497 (self.scrsizey, self.scrsizex) = scr.getmaxyx()
1500 1498 level.mainsizey = self.scrsizey-1-self._headerlines-footery
1501 1499
1502 1500 # Paint object header
1503 1501 for i in xrange(self._firstheaderline, self._firstheaderline+self._headerlines):
1504 1502 lv = self.levels[i]
1505 1503 posx = 0
1506 1504 posy = i-self._firstheaderline
1507 1505 endx = self.scrsizex
1508 1506 if i: # not the first level
1509 1507 msg = " (%d/%d" % (self.levels[i-1].cury, len(self.levels[i-1].items))
1510 1508 if not self.levels[i-1].exhausted:
1511 1509 msg += "+"
1512 1510 msg += ") "
1513 1511 endx -= len(msg)+1
1514 1512 posx += self.addstr(posy, posx, 0, endx, " ibrowse #%d: " % i, self.style_objheadertext)
1515 1513 for (style, text) in lv.header:
1516 1514 posx += self.addstr(posy, posx, 0, endx, text, self.style_objheaderobject)
1517 1515 if posx >= endx:
1518 1516 break
1519 1517 if i:
1520 1518 posx += self.addstr(posy, posx, 0, self.scrsizex, msg, self.style_objheadernumber)
1521 1519 posx += self.addchr(posy, posx, 0, self.scrsizex, " ", self.scrsizex-posx, self.style_objheadernumber)
1522 1520
1523 1521 if not level.items:
1524 1522 self.addchr(self._headerlines, 0, 0, self.scrsizex, " ", self.scrsizex, self.style_colheader)
1525 1523 self.addstr(self._headerlines+1, 0, 0, self.scrsizex, " <empty>", astyle.style_error)
1526 1524 scr.clrtobot()
1527 1525 else:
1528 1526 # Paint column headers
1529 1527 scr.move(self._headerlines, 0)
1530 1528 scr.addstr(" %*s " % (level.numbersizex, "#"), self.getstyle(self.style_colheader))
1531 1529 scr.addstr(self.headersepchar, self.getstyle(self.style_colheadersep))
1532 1530 begx = level.numbersizex+3
1533 1531 posx = begx-level.datastartx
1534 1532 for attr in level.displayattrs:
1535 1533 attrname = attr.name()
1536 1534 cwidth = level.colwidths[attr]
1537 1535 header = attrname.ljust(cwidth)
1538 1536 if attr is level.displayattr[1]:
1539 1537 style = self.style_colheaderhere
1540 1538 else:
1541 1539 style = self.style_colheader
1542 1540 posx += self.addstr(self._headerlines, posx, begx, self.scrsizex, header, style)
1543 1541 posx += self.addstr(self._headerlines, posx, begx, self.scrsizex, self.headersepchar, self.style_colheadersep)
1544 1542 if posx >= self.scrsizex:
1545 1543 break
1546 1544 else:
1547 1545 scr.addstr(" "*(self.scrsizex-posx), self.getstyle(self.style_colheader))
1548 1546
1549 1547 # Paint rows
1550 1548 posy = self._headerlines+1+level.datastarty
1551 1549 for i in xrange(level.datastarty, min(level.datastarty+level.mainsizey, len(level.items))):
1552 1550 cache = level.items[i]
1553 1551 if i == level.cury:
1554 1552 style = self.style_numberhere
1555 1553 else:
1556 1554 style = self.style_number
1557 1555
1558 1556 posy = self._headerlines+1+i-level.datastarty
1559 1557 posx = begx-level.datastartx
1560 1558
1561 1559 scr.move(posy, 0)
1562 1560 scr.addstr(" %*d%s" % (level.numbersizex, i, " !"[cache.marked]), self.getstyle(style))
1563 1561 scr.addstr(self.headersepchar, self.getstyle(self.style_sep))
1564 1562
1565 1563 for attrname in level.displayattrs:
1566 1564 cwidth = level.colwidths[attrname]
1567 1565 try:
1568 1566 (align, length, parts) = level.displayrows[i-level.datastarty][attrname]
1569 1567 except KeyError:
1570 1568 align = 2
1571 1569 style = astyle.style_nodata
1572 1570 if i == level.cury:
1573 1571 style = self.getstylehere(style)
1574 1572 padstyle = self.style_datapad
1575 1573 sepstyle = self.style_sep
1576 1574 if i == level.cury:
1577 1575 padstyle = self.getstylehere(padstyle)
1578 1576 sepstyle = self.getstylehere(sepstyle)
1579 1577 if align == 2:
1580 1578 posx += self.addchr(posy, posx, begx, self.scrsizex, self.nodatachar, cwidth, style)
1581 1579 else:
1582 1580 if align == 1:
1583 1581 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, cwidth-length, padstyle)
1584 1582 elif align == 0:
1585 1583 pad1 = (cwidth-length)//2
1586 1584 pad2 = cwidth-length-len(pad1)
1587 1585 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, pad1, padstyle)
1588 1586 for (style, text) in parts:
1589 1587 if i == level.cury:
1590 1588 style = self.getstylehere(style)
1591 1589 posx += self.addstr(posy, posx, begx, self.scrsizex, text, style)
1592 1590 if posx >= self.scrsizex:
1593 1591 break
1594 1592 if align == -1:
1595 1593 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, cwidth-length, padstyle)
1596 1594 elif align == 0:
1597 1595 posx += self.addchr(posy, posx, begx, self.scrsizex, self.datapadchar, pad2, padstyle)
1598 1596 posx += self.addstr(posy, posx, begx, self.scrsizex, self.datasepchar, sepstyle)
1599 1597 else:
1600 1598 scr.clrtoeol()
1601 1599
1602 1600 # Add blank row headers for the rest of the screen
1603 1601 for posy in xrange(posy+1, self.scrsizey-2):
1604 1602 scr.addstr(posy, 0, " " * (level.numbersizex+2), self.getstyle(self.style_colheader))
1605 1603 scr.clrtoeol()
1606 1604
1607 1605 posy = self.scrsizey-footery
1608 1606 # Display footer
1609 1607 scr.addstr(posy, 0, " "*self.scrsizex, self.getstyle(self.style_footer))
1610 1608
1611 1609 if level.exhausted:
1612 1610 flag = ""
1613 1611 else:
1614 1612 flag = "+"
1615 1613
1616 1614 endx = self.scrsizex-len(helpmsg)-1
1617 1615 scr.addstr(posy, endx, helpmsg, self.getstyle(self.style_footer))
1618 1616
1619 1617 posx = 0
1620 1618 msg = " %d%s objects (%d marked): " % (len(level.items), flag, level.marked)
1621 1619 posx += self.addstr(posy, posx, 0, endx, msg, self.style_footer)
1622 1620 try:
1623 1621 item = level.items[level.cury].item
1624 1622 except IndexError: # empty
1625 1623 pass
1626 1624 else:
1627 1625 for (nostyle, text) in ipipe.xrepr(item, "footer"):
1628 1626 if not isinstance(nostyle, int):
1629 1627 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
1630 1628 if posx >= endx:
1631 1629 break
1632 1630
1633 1631 attrstyle = [(astyle.style_default, "no attribute")]
1634 1632 attr = level.displayattr[1]
1635 1633 if attr is not ipipe.noitem and not isinstance(attr, ipipe.SelfDescriptor):
1636 1634 posx += self.addstr(posy, posx, 0, endx, " | ", self.style_footer)
1637 1635 posx += self.addstr(posy, posx, 0, endx, attr.name(), self.style_footer)
1638 1636 posx += self.addstr(posy, posx, 0, endx, ": ", self.style_footer)
1639 1637 try:
1640 1638 value = attr.value(item)
1641 1639 except (SystemExit, KeyboardInterrupt):
1642 1640 raise
1643 1641 except Exception, exc:
1644 1642 value = exc
1645 1643 if value is not ipipe.noitem:
1646 1644 attrstyle = ipipe.xrepr(value, "footer")
1647 1645 for (nostyle, text) in attrstyle:
1648 1646 if not isinstance(nostyle, int):
1649 1647 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
1650 1648 if posx >= endx:
1651 1649 break
1652 1650
1653 1651 try:
1654 1652 # Display input prompt
1655 1653 if self.mode in self.prompts:
1656 1654 history = self.prompts[self.mode]
1657 1655 posx = 0
1658 1656 posy = self.scrsizey-1
1659 1657 posx += self.addstr(posy, posx, 0, endx, history.prompt, astyle.style_default)
1660 1658 posx += self.addstr(posy, posx, 0, endx, " [", astyle.style_default)
1661 1659 if history.cury==-1:
1662 1660 text = "new"
1663 1661 else:
1664 1662 text = str(history.cury+1)
1665 1663 posx += self.addstr(posy, posx, 0, endx, text, astyle.style_type_number)
1666 1664 if history.history:
1667 1665 posx += self.addstr(posy, posx, 0, endx, "/", astyle.style_default)
1668 1666 posx += self.addstr(posy, posx, 0, endx, str(len(history.history)), astyle.style_type_number)
1669 1667 posx += self.addstr(posy, posx, 0, endx, "]: ", astyle.style_default)
1670 1668 inputstartx = posx
1671 1669 posx += self.addstr(posy, posx, 0, endx, history.input, astyle.style_default)
1672 1670 # Display report
1673 1671 else:
1674 1672 if self._report is not None:
1675 1673 if isinstance(self._report, Exception):
1676 1674 style = self.getstyle(astyle.style_error)
1677 1675 if self._report.__class__.__module__ == "exceptions":
1678 1676 msg = "%s: %s" % \
1679 1677 (self._report.__class__.__name__, self._report)
1680 1678 else:
1681 1679 msg = "%s.%s: %s" % \
1682 1680 (self._report.__class__.__module__,
1683 1681 self._report.__class__.__name__, self._report)
1684 1682 else:
1685 1683 style = self.getstyle(self.style_report)
1686 1684 msg = self._report
1687 1685 scr.addstr(self.scrsizey-1, 0, msg[:self.scrsizex], style)
1688 1686 self._report = None
1689 1687 else:
1690 1688 scr.move(self.scrsizey-1, 0)
1691 1689 except curses.error:
1692 1690 # Protect against errors from writing to the last line
1693 1691 pass
1694 1692 scr.clrtoeol()
1695 1693
1696 1694 # Position cursor
1697 1695 if self.mode in self.prompts:
1698 1696 history = self.prompts[self.mode]
1699 1697 scr.move(self.scrsizey-1, inputstartx+history.curx)
1700 1698 else:
1701 1699 scr.move(
1702 1700 1+self._headerlines+level.cury-level.datastarty,
1703 1701 level.numbersizex+3+level.curx-level.datastartx
1704 1702 )
1705 1703 scr.refresh()
1706 1704
1707 1705 # Check keyboard
1708 1706 while True:
1709 1707 c = scr.getch()
1710 1708 if self.resized:
1711 1709 size = fcntl.ioctl(0, tty.TIOCGWINSZ, "12345678")
1712 1710 size = struct.unpack("4H", size)
1713 1711 oldsize = scr.getmaxyx()
1714 1712 scr.erase()
1715 1713 curses.resize_term(size[0], size[1])
1716 1714 newsize = scr.getmaxyx()
1717 1715 scr.erase()
1718 1716 for l in self.levels:
1719 1717 l.mainsizey += newsize[0]-oldsize[0]
1720 1718 l.moveto(l.curx, l.cury, refresh=True)
1721 1719 scr.refresh()
1722 1720 self.resized = False
1723 1721 break # Redisplay
1724 1722 if self.mode in self.prompts:
1725 1723 if self.prompts[self.mode].handlekey(self, c):
1726 1724 break # Redisplay
1727 1725 else:
1728 1726 # if no key is pressed slow down and beep again
1729 1727 if c == -1:
1730 1728 self.stepx = 1.
1731 1729 self.stepy = 1.
1732 1730 self._dobeep = True
1733 1731 else:
1734 1732 # if a different key was pressed slow down and beep too
1735 1733 if c != lastc:
1736 1734 lastc = c
1737 1735 self.stepx = 1.
1738 1736 self.stepy = 1.
1739 1737 self._dobeep = True
1740 1738 cmdname = self.keymap.get(c, None)
1741 1739 if cmdname is None:
1742 1740 self.report(
1743 1741 UnassignedKeyError("Unassigned key %s" %
1744 1742 self.keylabel(c)))
1745 1743 else:
1746 1744 cmdfunc = getattr(self, "cmd_%s" % cmdname, None)
1747 1745 if cmdfunc is None:
1748 1746 self.report(
1749 1747 UnknownCommandError("Unknown command %r" %
1750 1748 (cmdname,)))
1751 1749 elif cmdfunc():
1752 1750 returnvalue = self.returnvalue
1753 1751 self.returnvalue = None
1754 1752 return returnvalue
1755 1753 self.stepx = self.nextstepx(self.stepx)
1756 1754 self.stepy = self.nextstepy(self.stepy)
1757 1755 curses.flushinp() # get rid of type ahead
1758 1756 break # Redisplay
1759 1757 self.scr = None
1760 1758
1761 1759 def display(self):
1762 1760 if hasattr(curses, "resize_term"):
1763 1761 oldhandler = signal.signal(signal.SIGWINCH, self.sigwinchhandler)
1764 1762 try:
1765 1763 return curses.wrapper(self._dodisplay)
1766 1764 finally:
1767 1765 signal.signal(signal.SIGWINCH, oldhandler)
1768 1766 else:
1769 1767 return curses.wrapper(self._dodisplay)
@@ -1,1129 +1,1126 b''
1 1 # -*- coding: iso-8859-1 -*-
2 2
3 3 import ipipe, os, webbrowser, urllib
4 4 from IPython import ipapi
5 5 import wx
6 6 import wx.grid, wx.html
7 7
8 8 try:
9 9 sorted
10 10 except NameError:
11 11 from ipipe import sorted
12 12 try:
13 13 set
14 14 except:
15 15 from sets import Set as set
16 16
17 17
18 18 __all__ = ["igrid"]
19 19
20 20
21 21 help = """
22 22 <?xml version='1.0' encoding='iso-8859-1'?>
23 23 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
24 24 <html>
25 25 <head>
26 26 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
27 27 <link rel="stylesheet" href="igrid_help.css" type="text/css" />
28 28 <title>igrid help</title>
29 29 </head>
30 30 <body>
31 31 <h1>igrid help</h1>
32 32
33 33
34 34 <h2>Commands</h2>
35 35
36 36
37 37 <h3>pick (P)</h3>
38 38 <p>Pick the whole row (object is available as "_")</p>
39 39
40 40 <h3>pickattr (Shift-P)</h3>
41 41 <p>Pick the attribute under the cursor</p>
42 42
43 43 <h3>pickallattrs (Shift-C)</h3>
44 44 <p>Pick the complete column under the cursor (i.e. the attribute under the
45 45 cursor) from all currently fetched objects. These attributes will be returned
46 46 as a list.</p>
47 47
48 48 <h3>pickinput (I)</h3>
49 49 <p>Pick the current row as next input line in IPython. Additionally the row is stored as "_"</p>
50 50
51 51 <h3>pickinputattr (Shift-I)</h3>
52 52 <p>Pick the attribute under the cursor as next input line in IPython. Additionally the row is stored as "_"</p>
53 53
54 54 <h3>enter (E)</h3>
55 55 <p>Enter the object under the cursor. (what this mean depends on the object
56 56 itself, i.e. how it implements iteration). This opens a new browser 'level'.</p>
57 57
58 58 <h3>enterattr (Shift-E)</h3>
59 59 <p>Enter the attribute under the cursor.</p>
60 60
61 61 <h3>detail (D)</h3>
62 62 <p>Show a detail view of the object under the cursor. This shows the name,
63 63 type, doc string and value of the object attributes (and it might show more
64 64 attributes than in the list view, depending on the object).</p>
65 65
66 66 <h3>detailattr (Shift-D)</h3>
67 67 <p>Show a detail view of the attribute under the cursor.</p>
68 68
69 69 <h3>pickrows (M)</h3>
70 70 <p>Pick multiple selected rows (M)</p>
71 71
72 72 <h3>pickrowsattr (CTRL-M)</h3>
73 73 <p>From multiple selected rows pick the cells matching the attribute the cursor is in (CTRL-M)</p>
74 74
75 75 <h3>find (CTRL-F)</h3>
76 76 <p>Find text</p>
77 77
78 78 <h3>find_expression (CTRL-Shift-F)</h3>
79 79 <p>Find entries matching an expression</p>
80 80
81 81 <h3>find_next (F3)</h3>
82 82 <p>Find next occurrence</p>
83 83
84 84 <h3>find_previous (Shift-F3)</h3>
85 85 <p>Find previous occurrence</p>
86 86
87 87 <h3>sortattrasc (V)</h3>
88 88 <p>Sort the objects (in ascending order) using the attribute under the cursor as the sort key.</p>
89 89
90 90 <h3>sortattrdesc (Shift-V)</h3>
91 91 <p>Sort the objects (in descending order) using the attribute under the cursor as the sort key.</p>
92 92
93 93 <h3>refresh_once (R, F5)</h3>
94 94 <p>Refreshes the display by restarting the iterator</p>
95 95
96 96 <h3>refresh_every_second</h3>
97 97 <p>Refreshes the display by restarting the iterator every second until stopped by stop_refresh.</p>
98 98
99 99 <h3>refresh_interval</h3>
100 100 <p>Refreshes the display by restarting the iterator every X ms (X is a custom interval set by the user) until stopped by stop_refresh.</p>
101 101
102 102 <h3>stop_refresh</h3>
103 103 <p>Stops all refresh timers.</p>
104 104
105 105 <h3>leave (Backspace, DEL, X)</h3>
106 106 <p>Close current tab (and all the tabs to the right of the current one).</h3>
107 107
108 108 <h3>quit (ESC,Q)</h3>
109 109 <p>Quit igrid and return to the IPython prompt.</p>
110 110
111 111
112 112 <h2>Navigation</h2>
113 113
114 114
115 115 <h3>Jump to the last column of the current row (END, CTRL-E, CTRL-Right)</h3>
116 116
117 117 <h3>Jump to the first column of the current row (HOME, CTRL-A, CTRL-Left)</h3>
118 118
119 119 <h3>Move the cursor one column to the left (&lt;)</h3>
120 120
121 121 <h3>Move the cursor one column to the right (&gt;)</h3>
122 122
123 123 <h3>Jump to the first row in the current column (CTRL-Up)</h3>
124 124
125 125 <h3>Jump to the last row in the current column (CTRL-Down)</h3>
126 126
127 127 </body>
128 128 </html>
129 129
130 130 """
131 131
132 132
133 133 class IGridRenderer(wx.grid.PyGridCellRenderer):
134 134 """
135 135 This is a custom renderer for our IGridGrid
136 136 """
137 137 def __init__(self, table):
138 138 self.maxchars = 200
139 139 self.table = table
140 140 self.colormap = (
141 141 ( 0, 0, 0),
142 142 (174, 0, 0),
143 143 ( 0, 174, 0),
144 144 (174, 174, 0),
145 145 ( 0, 0, 174),
146 146 (174, 0, 174),
147 147 ( 0, 174, 174),
148 148 ( 64, 64, 64)
149 149 )
150 150
151 151 wx.grid.PyGridCellRenderer.__init__(self)
152 152
153 153 def _getvalue(self, row, col):
154 154 try:
155 155 value = self.table._displayattrs[col].value(self.table.items[row])
156 156 (align, width, text) = ipipe.xformat(value, "cell", self.maxchars)
157 157 except Exception, exc:
158 158 (align, width, text) = ipipe.xformat(exc, "cell", self.maxchars)
159 159 return (align, text)
160 160
161 161 def GetBestSize(self, grid, attr, dc, row, col):
162 162 text = grid.GetCellValue(row, col)
163 163 (align, text) = self._getvalue(row, col)
164 164 dc.SetFont(attr.GetFont())
165 165 (w, h) = dc.GetTextExtent(str(text))
166 166 return wx.Size(min(w+2, 600), h+2) # add border
167 167
168 168 def Draw(self, grid, attr, dc, rect, row, col, isSelected):
169 169 """
170 170 Takes care of drawing everything in the cell; aligns the text
171 171 """
172 172 text = grid.GetCellValue(row, col)
173 173 (align, text) = self._getvalue(row, col)
174 174 if isSelected:
175 175 bg = grid.GetSelectionBackground()
176 176 else:
177 177 bg = ["white", (240, 240, 240)][row%2]
178 178 dc.SetTextBackground(bg)
179 179 dc.SetBrush(wx.Brush(bg, wx.SOLID))
180 180 dc.SetPen(wx.TRANSPARENT_PEN)
181 181 dc.SetFont(attr.GetFont())
182 182 dc.DrawRectangleRect(rect)
183 183 dc.SetClippingRect(rect)
184 184 # Format the text
185 185 if align == -1: # left alignment
186 186 (width, height) = dc.GetTextExtent(str(text))
187 187 x = rect[0]+1
188 188 y = rect[1]+0.5*(rect[3]-height)
189 189
190 190 for (style, part) in text:
191 191 if isSelected:
192 192 fg = grid.GetSelectionForeground()
193 193 else:
194 194 fg = self.colormap[style.fg]
195 195 dc.SetTextForeground(fg)
196 196 (w, h) = dc.GetTextExtent(part)
197 197 dc.DrawText(part, x, y)
198 198 x += w
199 199 elif align == 0: # center alignment
200 200 (width, height) = dc.GetTextExtent(str(text))
201 201 x = rect[0]+0.5*(rect[2]-width)
202 202 y = rect[1]+0.5*(rect[3]-height)
203 203 for (style, part) in text:
204 204 if isSelected:
205 205 fg = grid.GetSelectionForeground()
206 206 else:
207 207 fg = self.colormap[style.fg]
208 208 dc.SetTextForeground(fg)
209 209 (w, h) = dc.GetTextExtent(part)
210 210 dc.DrawText(part, x, y)
211 211 x += w
212 212 else: # right alignment
213 213 (width, height) = dc.GetTextExtent(str(text))
214 214 x = rect[0]+rect[2]-1
215 215 y = rect[1]+0.5*(rect[3]-height)
216 216 for (style, part) in reversed(text):
217 217 (w, h) = dc.GetTextExtent(part)
218 218 x -= w
219 219 if isSelected:
220 220 fg = grid.GetSelectionForeground()
221 221 else:
222 222 fg = self.colormap[style.fg]
223 223 dc.SetTextForeground(fg)
224 224 dc.DrawText(part, x, y)
225 225 dc.DestroyClippingRegion()
226 226
227 227 def Clone(self):
228 228 return IGridRenderer(self.table)
229 229
230 230
231 231 class IGridTable(wx.grid.PyGridTableBase):
232 232 # The data table for the ``IGridGrid``. Some dirty tricks were used here:
233 233 # ``GetValue()`` does not get any values (or at least it does not return
234 234 # anything, accessing the values is done by the renderer)
235 235 # but rather tries to fetch the objects which were requested into the table.
236 236 # General behaviour is: Fetch the first X objects. If the user scrolls down
237 237 # to the last object another bunch of X objects is fetched (if possible)
238 238 def __init__(self, input, fontsize, *attrs):
239 239 wx.grid.PyGridTableBase.__init__(self)
240 240 self.input = input
241 241 self.iterator = ipipe.xiter(input)
242 242 self.items = []
243 243 self.attrs = [ipipe.upgradexattr(attr) for attr in attrs]
244 244 self._displayattrs = self.attrs[:]
245 245 self._displayattrset = set(self.attrs)
246 246 self.fontsize = fontsize
247 247 self._fetch(1)
248 248 self.timer = wx.Timer()
249 249 self.timer.Bind(wx.EVT_TIMER, self.refresh_content)
250 250
251 251 def GetAttr(self, *args):
252 252 attr = wx.grid.GridCellAttr()
253 253 attr.SetFont(wx.Font(self.fontsize, wx.TELETYPE, wx.NORMAL, wx.NORMAL))
254 254 return attr
255 255
256 256 def GetNumberRows(self):
257 257 return len(self.items)
258 258
259 259 def GetNumberCols(self):
260 260 return len(self._displayattrs)
261 261
262 262 def GetColLabelValue(self, col):
263 263 if col < len(self._displayattrs):
264 264 return self._displayattrs[col].name()
265 265 else:
266 266 return ""
267 267
268 268 def GetRowLabelValue(self, row):
269 269 return str(row)
270 270
271 271 def IsEmptyCell(self, row, col):
272 272 return False
273 273
274 274 def _append(self, item):
275 275 self.items.append(item)
276 276 # Nothing to do if the set of attributes has been fixed by the user
277 277 if not self.attrs:
278 278 for attr in ipipe.xattrs(item):
279 279 attr = ipipe.upgradexattr(attr)
280 280 if attr not in self._displayattrset:
281 281 self._displayattrs.append(attr)
282 282 self._displayattrset.add(attr)
283 283
284 284 def _fetch(self, count):
285 285 # Try to fill ``self.items`` with at least ``count`` objects.
286 286 have = len(self.items)
287 287 while self.iterator is not None and have < count:
288 288 try:
289 289 item = self.iterator.next()
290 290 except StopIteration:
291 291 self.iterator = None
292 292 break
293 293 except (KeyboardInterrupt, SystemExit):
294 294 raise
295 295 except Exception, exc:
296 296 have += 1
297 297 self._append(exc)
298 298 self.iterator = None
299 299 break
300 300 else:
301 301 have += 1
302 302 self._append(item)
303 303
304 304 def GetValue(self, row, col):
305 305 # some kind of dummy-function: does not return anything but "";
306 306 # (The value isn't use anyway)
307 307 # its main task is to trigger the fetch of new objects
308 308 sizing_needed = False
309 309 had_cols = len(self._displayattrs)
310 310 had_rows = len(self.items)
311 311 if row == had_rows - 1 and self.iterator is not None:
312 312 self._fetch(row + 20)
313 313 sizing_needed = True
314 314 have_rows = len(self.items)
315 315 have_cols = len(self._displayattrs)
316 316 if have_rows > had_rows:
317 317 msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, have_rows - had_rows)
318 318 self.GetView().ProcessTableMessage(msg)
319 319 sizing_needed = True
320 320 if row >= have_rows:
321 321 return ""
322 322 if have_cols != had_cols:
323 323 msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED, have_cols - had_cols)
324 324 self.GetView().ProcessTableMessage(msg)
325 325 sizing_needed = True
326 326 if sizing_needed:
327 327 self.GetView().AutoSizeColumns(False)
328 328 return ""
329 329
330 330 def SetValue(self, row, col, value):
331 331 pass
332 332
333 333 def refresh_content(self, event):
334 334 msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, 0, self.GetNumberRows())
335 335 self.GetView().ProcessTableMessage(msg)
336 336 self.iterator = ipipe.xiter(self.input)
337 337 self.items = []
338 338 self.attrs = [] # _append will calculate new displayattrs
339 339 self._fetch(1) # fetch one...
340 340 if self.items:
341 341 msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, 1)
342 342 self.GetView().ProcessTableMessage(msg)
343 343 self.GetValue(0, 0) # and trigger "fetch next 20"
344 344 item = self.items[0]
345 345 self.GetView().AutoSizeColumns(False)
346 346 panel = self.GetView().GetParent()
347 347 nb = panel.GetParent()
348 348 current = nb.GetSelection()
349 349 if nb.GetPage(current) == panel:
350 350 self.GetView().set_footer(item)
351 351
352 352 class IGridGrid(wx.grid.Grid):
353 353 # The actual grid
354 354 # all methods for selecting/sorting/picking/... data are implemented here
355 355 def __init__(self, panel, input, *attrs):
356 356 wx.grid.Grid.__init__(self, panel)
357 357 fontsize = 9
358 358 self.input = input
359 359 self.table = IGridTable(self.input, fontsize, *attrs)
360 360 self.SetTable(self.table, True)
361 361 self.SetSelectionMode(wx.grid.Grid.wxGridSelectRows)
362 362 self.SetDefaultRenderer(IGridRenderer(self.table))
363 363 self.EnableEditing(False)
364 364 self.Bind(wx.EVT_KEY_DOWN, self.key_pressed)
365 365 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.cell_doubleclicked)
366 366 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.cell_leftclicked)
367 367 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self.label_doubleclicked)
368 368 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_label_leftclick)
369 369 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self._on_selected_range)
370 370 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self._on_selected_cell)
371 371 self.current_selection = set()
372 372 self.maxchars = 200
373 373
374 374 def on_label_leftclick(self, event):
375 375 event.Skip()
376 376
377 377 def error_output(self, text):
378 378 wx.Bell()
379 379 frame = self.GetParent().GetParent().GetParent()
380 380 frame.SetStatusText(str(text))
381 381
382 382 def _on_selected_range(self, event):
383 383 # Internal update to the selection tracking lists
384 384 if event.Selecting():
385 385 # adding to the list...
386 386 self.current_selection.update(xrange(event.GetTopRow(), event.GetBottomRow()+1))
387 387 else:
388 388 # removal from list
389 389 for index in xrange(event.GetTopRow(), event.GetBottomRow()+1):
390 390 self.current_selection.discard(index)
391 391 event.Skip()
392 392
393 393 def _on_selected_cell(self, event):
394 394 # Internal update to the selection tracking list
395 395 self.current_selection = set([event.GetRow()])
396 396 event.Skip()
397 397
398 398 def sort(self, key, reverse=False):
399 399 """
400 400 Sort the current list of items using the key function ``key``. If
401 401 ``reverse`` is true the sort order is reversed.
402 402 """
403 403 row = self.GetGridCursorRow()
404 404 col = self.GetGridCursorCol()
405 405 curitem = self.table.items[row] # Remember where the cursor is now
406 406 # Sort items
407 407 def realkey(item):
408 408 try:
409 409 return key(item)
410 410 except (KeyboardInterrupt, SystemExit):
411 411 raise
412 412 except Exception:
413 413 return None
414 414 try:
415 415 self.table.items = ipipe.deque(sorted(self.table.items, key=realkey, reverse=reverse))
416 416 except TypeError, exc:
417 417 self.error_output("Exception encountered: %s" % exc)
418 418 return
419 419 # Find out where the object under the cursor went
420 420 for (i, item) in enumerate(self.table.items):
421 421 if item is curitem:
422 422 self.SetGridCursor(i,col)
423 423 self.MakeCellVisible(i,col)
424 424 self.Refresh()
425 425
426 426 def sortattrasc(self):
427 427 """
428 428 Sort in ascending order; sorting criteria is the current attribute
429 429 """
430 430 col = self.GetGridCursorCol()
431 431 attr = self.table._displayattrs[col]
432 432 frame = self.GetParent().GetParent().GetParent()
433 433 if attr is ipipe.noitem:
434 434 self.error_output("no column under cursor")
435 435 return
436 436 frame.SetStatusText("sort by %s (ascending)" % attr.name())
437 437 def key(item):
438 438 try:
439 439 return attr.value(item)
440 440 except (KeyboardInterrupt, SystemExit):
441 441 raise
442 442 except Exception:
443 443 return None
444 444 self.sort(key)
445 445
446 446 def sortattrdesc(self):
447 447 """
448 448 Sort in descending order; sorting criteria is the current attribute
449 449 """
450 450 col = self.GetGridCursorCol()
451 451 attr = self.table._displayattrs[col]
452 452 frame = self.GetParent().GetParent().GetParent()
453 453 if attr is ipipe.noitem:
454 454 self.error_output("no column under cursor")
455 455 return
456 456 frame.SetStatusText("sort by %s (descending)" % attr.name())
457 457 def key(item):
458 458 try:
459 459 return attr.value(item)
460 460 except (KeyboardInterrupt, SystemExit):
461 461 raise
462 462 except Exception:
463 463 return None
464 464 self.sort(key, reverse=True)
465 465
466 466 def label_doubleclicked(self, event):
467 467 row = event.GetRow()
468 468 col = event.GetCol()
469 469 if col == -1:
470 470 self.enter(row)
471 471
472 472 def _getvalue(self, row, col):
473 473 """
474 474 Gets the text which is displayed at ``(row, col)``
475 475 """
476 476 try:
477 477 value = self.table._displayattrs[col].value(self.table.items[row])
478 478 (align, width, text) = ipipe.xformat(value, "cell", self.maxchars)
479 479 except IndexError:
480 480 raise IndexError
481 481 except Exception, exc:
482 482 (align, width, text) = ipipe.xformat(exc, "cell", self.maxchars)
483 483 return text
484 484
485 485 def searchexpression(self, searchexp, startrow=None, search_forward=True ):
486 486 """
487 487 Find by expression
488 488 """
489 489 frame = self.GetParent().GetParent().GetParent()
490 490 if searchexp:
491 491 if search_forward:
492 492 if not startrow:
493 493 row = self.GetGridCursorRow()+1
494 494 else:
495 495 row = startrow + 1
496 496 while True:
497 497 try:
498 498 foo = self.table.GetValue(row, 0)
499 499 item = self.table.items[row]
500 500 try:
501 501 globals = ipipe.getglobals(None)
502 502 if eval(searchexp, globals, ipipe.AttrNamespace(item)):
503 503 self.SetGridCursor(row, 0) # found something
504 504 self.MakeCellVisible(row, 0)
505 505 break
506 506 except (KeyboardInterrupt, SystemExit):
507 507 raise
508 508 except Exception, exc:
509 509 frame.SetStatusText(str(exc))
510 510 wx.Bell()
511 511 break # break on error
512 512 except IndexError:
513 513 return
514 514 row += 1
515 515 else:
516 516 if not startrow:
517 517 row = self.GetGridCursorRow() - 1
518 518 else:
519 519 row = startrow - 1
520 520 while True:
521 521 try:
522 522 foo = self.table.GetValue(row, 0)
523 523 item = self.table.items[row]
524 524 try:
525 525 globals = ipipe.getglobals(None)
526 526 if eval(searchexp, globals, ipipe.AttrNamespace(item)):
527 527 self.SetGridCursor(row, 0) # found something
528 528 self.MakeCellVisible(row, 0)
529 529 break
530 530 except (KeyboardInterrupt, SystemExit):
531 531 raise
532 532 except Exception, exc:
533 533 frame.SetStatusText(str(exc))
534 534 wx.Bell()
535 535 break # break on error
536 536 except IndexError:
537 537 return
538 538 row -= 1
539 539
540 540
541 541 def search(self, searchtext, startrow=None, startcol=None, search_forward=True):
542 542 """
543 543 search for ``searchtext``, starting in ``(startrow, startcol)``;
544 544 if ``search_forward`` is true the direction is "forward"
545 545 """
546 546 searchtext = searchtext.lower()
547 547 if search_forward:
548 548 if startrow is not None and startcol is not None:
549 549 row = startrow
550 550 else:
551 551 startcol = self.GetGridCursorCol() + 1
552 552 row = self.GetGridCursorRow()
553 553 if startcol >= self.GetNumberCols():
554 554 startcol = 0
555 555 row += 1
556 556 while True:
557 557 for col in xrange(startcol, self.table.GetNumberCols()):
558 558 try:
559 559 foo = self.table.GetValue(row, col)
560 560 text = self._getvalue(row, col)
561 561 if searchtext in text.string().lower():
562 562 self.SetGridCursor(row, col)
563 563 self.MakeCellVisible(row, col)
564 564 return
565 565 except IndexError:
566 566 return
567 567 startcol = 0
568 568 row += 1
569 569 else:
570 570 if startrow is not None and startcol is not None:
571 571 row = startrow
572 572 else:
573 573 startcol = self.GetGridCursorCol() - 1
574 574 row = self.GetGridCursorRow()
575 575 if startcol < 0:
576 576 startcol = self.GetNumberCols() - 1
577 577 row -= 1
578 578 while True:
579 579 for col in xrange(startcol, -1, -1):
580 580 try:
581 581 foo = self.table.GetValue(row, col)
582 582 text = self._getvalue(row, col)
583 583 if searchtext in text.string().lower():
584 584 self.SetGridCursor(row, col)
585 585 self.MakeCellVisible(row, col)
586 586 return
587 587 except IndexError:
588 588 return
589 589 startcol = self.table.GetNumberCols()-1
590 590 row -= 1
591 591
592 592 def key_pressed(self, event):
593 593 """
594 594 Maps pressed keys to functions
595 595 """
596 596 frame = self.GetParent().GetParent().GetParent()
597 597 frame.SetStatusText("")
598 598 sh = event.ShiftDown()
599 599 ctrl = event.ControlDown()
600 600
601 601 keycode = event.GetKeyCode()
602 602 if keycode == ord("P"):
603 603 row = self.GetGridCursorRow()
604 604 if sh:
605 605 col = self.GetGridCursorCol()
606 606 self.pickattr(row, col)
607 607 else:
608 608 self.pick(row)
609 609 elif keycode == ord("M"):
610 610 if ctrl:
611 611 col = self.GetGridCursorCol()
612 612 self.pickrowsattr(sorted(self.current_selection), col)
613 613 else:
614 614 self.pickrows(sorted(self.current_selection))
615 615 elif keycode in (wx.WXK_BACK, wx.WXK_DELETE, ord("X")) and not (ctrl or sh):
616 616 self.delete_current_notebook()
617 617 elif keycode in (ord("E"), ord("\r")):
618 618 row = self.GetGridCursorRow()
619 619 if sh:
620 620 col = self.GetGridCursorCol()
621 621 self.enterattr(row, col)
622 622 else:
623 623 self.enter(row)
624 624 elif keycode == ord("E") and ctrl:
625 625 row = self.GetGridCursorRow()
626 626 self.SetGridCursor(row, self.GetNumberCols()-1)
627 627 elif keycode == wx.WXK_HOME or (keycode == ord("A") and ctrl):
628 628 row = self.GetGridCursorRow()
629 629 self.SetGridCursor(row, 0)
630 630 elif keycode == ord("C") and sh:
631 631 col = self.GetGridCursorCol()
632 632 attr = self.table._displayattrs[col]
633 633 result = []
634 634 for i in xrange(self.GetNumberRows()):
635 635 result.append(self.table._displayattrs[col].value(self.table.items[i]))
636 636 self.quit(result)
637 637 elif keycode in (wx.WXK_ESCAPE, ord("Q")) and not (ctrl or sh):
638 638 self.quit()
639 639 elif keycode == ord("<"):
640 640 row = self.GetGridCursorRow()
641 641 col = self.GetGridCursorCol()
642 642 if not event.ShiftDown():
643 643 newcol = col - 1
644 644 if newcol >= 0:
645 645 self.SetGridCursor(row, col - 1)
646 646 else:
647 647 newcol = col + 1
648 648 if newcol < self.GetNumberCols():
649 649 self.SetGridCursor(row, col + 1)
650 650 elif keycode == ord("D"):
651 651 col = self.GetGridCursorCol()
652 652 row = self.GetGridCursorRow()
653 653 if not sh:
654 654 self.detail(row, col)
655 655 else:
656 656 self.detail_attr(row, col)
657 657 elif keycode == ord("F") and ctrl:
658 658 if sh:
659 659 frame.enter_searchexpression(event)
660 660 else:
661 661 frame.enter_searchtext(event)
662 662 elif keycode == wx.WXK_F3:
663 663 if sh:
664 664 frame.find_previous(event)
665 665 else:
666 666 frame.find_next(event)
667 667 elif keycode == ord("V"):
668 668 if sh:
669 669 self.sortattrdesc()
670 670 else:
671 671 self.sortattrasc()
672 672 elif keycode == wx.WXK_DOWN:
673 673 row = self.GetGridCursorRow()
674 674 try:
675 675 item = self.table.items[row+1]
676 676 except IndexError:
677 677 item = self.table.items[row]
678 678 self.set_footer(item)
679 679 event.Skip()
680 680 elif keycode == wx.WXK_UP:
681 681 row = self.GetGridCursorRow()
682 682 if row >= 1:
683 683 item = self.table.items[row-1]
684 684 else:
685 685 item = self.table.items[row]
686 686 self.set_footer(item)
687 687 event.Skip()
688 688 elif keycode == wx.WXK_RIGHT:
689 689 row = self.GetGridCursorRow()
690 690 item = self.table.items[row]
691 691 self.set_footer(item)
692 692 event.Skip()
693 693 elif keycode == wx.WXK_LEFT:
694 694 row = self.GetGridCursorRow()
695 695 item = self.table.items[row]
696 696 self.set_footer(item)
697 697 event.Skip()
698 698 elif keycode == ord("R") or keycode == wx.WXK_F5:
699 699 self.table.refresh_content(event)
700 700 elif keycode == ord("I"):
701 701 row = self.GetGridCursorRow()
702 702 if not sh:
703 703 self.pickinput(row)
704 704 else:
705 705 col = self.GetGridCursorCol()
706 706 self.pickinputattr(row, col)
707 707 else:
708 708 event.Skip()
709 709
710 710 def delete_current_notebook(self):
711 711 """
712 712 deletes the current notebook tab
713 713 """
714 714 panel = self.GetParent()
715 715 nb = panel.GetParent()
716 716 current = nb.GetSelection()
717 717 count = nb.GetPageCount()
718 718 if count > 1:
719 719 for i in xrange(count-1, current-1, -1):
720 720 nb.DeletePage(i)
721 721 nb.GetCurrentPage().grid.SetFocus()
722 722 else:
723 723 frame = nb.GetParent()
724 724 frame.SetStatusText("This is the last level!")
725 725
726 726 def _doenter(self, value, *attrs):
727 727 """
728 728 "enter" a special item resulting in a new notebook tab
729 729 """
730 730 panel = self.GetParent()
731 731 nb = panel.GetParent()
732 732 frame = nb.GetParent()
733 733 current = nb.GetSelection()
734 734 count = nb.GetPageCount()
735 735 try: # if we want to enter something non-iterable, e.g. a function
736 736 if current + 1 == count and value is not self.input: # we have an event in the last tab
737 737 frame._add_notebook(value, *attrs)
738 738 elif value != self.input: # we have to delete all tabs newer than [panel] first
739 739 for i in xrange(count-1, current, -1): # some tabs don't close if we don't close in *reverse* order
740 740 nb.DeletePage(i)
741 741 frame._add_notebook(value)
742 742 except TypeError, exc:
743 743 if exc.__class__.__module__ == "exceptions":
744 744 msg = "%s: %s" % (exc.__class__.__name__, exc)
745 745 else:
746 746 msg = "%s.%s: %s" % (exc.__class__.__module__, exc.__class__.__name__, exc)
747 747 frame.SetStatusText(msg)
748 748
749 749 def enterattr(self, row, col):
750 750 try:
751 751 attr = self.table._displayattrs[col]
752 752 value = attr.value(self.table.items[row])
753 753 except Exception, exc:
754 754 self.error_output(str(exc))
755 755 else:
756 756 self._doenter(value)
757 757
758 758 def set_footer(self, item):
759 759 frame = self.GetParent().GetParent().GetParent()
760 760 frame.SetStatusText(" ".join([str(text) for (style, text) in ipipe.xformat(item, "footer", 20)[2]]), 0)
761 761
762 762 def enter(self, row):
763 763 try:
764 764 value = self.table.items[row]
765 765 except Exception, exc:
766 766 self.error_output(str(exc))
767 767 else:
768 768 self._doenter(value)
769 769
770 770 def detail(self, row, col):
771 771 """
772 772 shows a detail-view of the current cell
773 773 """
774 774 try:
775 775 attr = self.table._displayattrs[col]
776 776 item = self.table.items[row]
777 777 except Exception, exc:
778 778 self.error_output(str(exc))
779 779 else:
780 780 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
781 781 self._doenter(attrs)
782 782
783 783 def detail_attr(self, row, col):
784 784 try:
785 785 attr = self.table._displayattrs[col]
786 786 item = attr.value(self.table.items[row])
787 787 except Exception, exc:
788 788 self.error_output(str(exc))
789 789 else:
790 790 attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
791 791 self._doenter(attrs)
792 792
793 793 def quit(self, result=None):
794 794 """
795 795 quit
796 796 """
797 797 frame = self.GetParent().GetParent().GetParent()
798 798 if frame.helpdialog:
799 799 frame.helpdialog.Destroy()
800 800 app = frame.parent
801 801 if app is not None:
802 802 app.result = result
803 803 frame.Close()
804 804 frame.Destroy()
805 805
806 806 def cell_doubleclicked(self, event):
807 807 self.enterattr(event.GetRow(), event.GetCol())
808 808 event.Skip()
809 809
810 810 def cell_leftclicked(self, event):
811 811 row = event.GetRow()
812 812 item = self.table.items[row]
813 813 self.set_footer(item)
814 814 event.Skip()
815 815
816 816 def pick(self, row):
817 817 """
818 818 pick a single row and return to the IPython prompt
819 819 """
820 820 try:
821 821 value = self.table.items[row]
822 822 except Exception, exc:
823 823 self.error_output(str(exc))
824 824 else:
825 825 self.quit(value)
826 826
827 827 def pickinput(self, row):
828 828 try:
829 829 value = self.table.items[row]
830 830 except Exception, exc:
831 831 self.error_output(str(exc))
832 832 else:
833 833 api = ipapi.get()
834 834 api.set_next_input(str(value))
835 835 self.quit(value)
836 836
837 837 def pickinputattr(self, row, col):
838 838 try:
839 839 attr = self.table._displayattrs[col]
840 840 value = attr.value(self.table.items[row])
841 841 except Exception, exc:
842 842 self.error_output(str(exc))
843 843 else:
844 844 api = ipapi.get()
845 845 api.set_next_input(str(value))
846 846 self.quit(value)
847 847
848 848 def pickrows(self, rows):
849 849 """
850 850 pick multiple rows and return to the IPython prompt
851 851 """
852 852 try:
853 853 value = [self.table.items[row] for row in rows]
854 854 except Exception, exc:
855 855 self.error_output(str(exc))
856 856 else:
857 857 self.quit(value)
858 858
859 859 def pickrowsattr(self, rows, col):
860 860 """"
861 861 pick one column from multiple rows
862 862 """
863 863 values = []
864 864 try:
865 865 attr = self.table._displayattrs[col]
866 866 for row in rows:
867 867 try:
868 868 values.append(attr.value(self.table.items[row]))
869 869 except (SystemExit, KeyboardInterrupt):
870 870 raise
871 871 except Exception:
872 872 raise #pass
873 873 except Exception, exc:
874 874 self.error_output(str(exc))
875 875 else:
876 876 self.quit(values)
877 877
878 878 def pickattr(self, row, col):
879 879 try:
880 880 attr = self.table._displayattrs[col]
881 881 value = attr.value(self.table.items[row])
882 882 except Exception, exc:
883 883 self.error_output(str(exc))
884 884 else:
885 885 self.quit(value)
886 886
887 887
888 888 class IGridPanel(wx.Panel):
889 889 # Each IGridPanel contains an IGridGrid
890 890 def __init__(self, parent, input, *attrs):
891 891 wx.Panel.__init__(self, parent, -1)
892 892 self.grid = IGridGrid(self, input, *attrs)
893 893 self.grid.FitInside()
894 894 sizer = wx.BoxSizer(wx.VERTICAL)
895 895 sizer.Add(self.grid, proportion=1, flag=wx.EXPAND | wx.ALL, border=10)
896 896 self.SetSizer(sizer)
897 897 sizer.Fit(self)
898 898 sizer.SetSizeHints(self)
899 899
900 900
901 901 class IGridHTMLHelp(wx.Frame):
902 902 def __init__(self, parent, title, size):
903 903 wx.Frame.__init__(self, parent, -1, title, size=size)
904 904 html = wx.html.HtmlWindow(self)
905 905 if "gtk2" in wx.PlatformInfo:
906 906 html.SetStandardFonts()
907 907 html.SetPage(help)
908 908
909 909
910 910 class IGridFrame(wx.Frame):
911 911 maxtitlelen = 30
912 912
913 913 def __init__(self, parent, input):
914 914 title = " ".join([str(text) for (style, text) in ipipe.xformat(input, "header", 20)[2]])
915 915 wx.Frame.__init__(self, None, title=title, size=(640, 480))
916 916 self.menubar = wx.MenuBar()
917 917 self.menucounter = 100
918 918 self.m_help = wx.Menu()
919 919 self.m_search = wx.Menu()
920 920 self.m_sort = wx.Menu()
921 921 self.m_refresh = wx.Menu()
922 922 self.notebook = wx.Notebook(self, -1, style=0)
923 923 self.statusbar = self.CreateStatusBar(1, wx.ST_SIZEGRIP)
924 924 self.statusbar.SetFieldsCount(2)
925 925 self.SetStatusWidths([-1, 200])
926 926 self.parent = parent
927 927 self._add_notebook(input)
928 928 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
929 929 self.makemenu(self.m_sort, "&Sort (asc)\tV", "Sort ascending", self.sortasc)
930 930 self.makemenu(self.m_sort, "Sort (&desc)\tShift-V", "Sort descending", self.sortdesc)
931 931 self.makemenu(self.m_help, "&Help\tF1", "Help", self.display_help)
932 932 # self.makemenu(self.m_help, "&Show help in browser", "Show help in browser", self.display_help_in_browser)
933 933 self.makemenu(self.m_search, "&Find text\tCTRL-F", "Find text", self.enter_searchtext)
934 934 self.makemenu(self.m_search, "Find by &expression\tCTRL-Shift-F", "Find by expression", self.enter_searchexpression)
935 935 self.makemenu(self.m_search, "Find &next\tF3", "Find next", self.find_next)
936 936 self.makemenu(self.m_search, "Find &previous\tShift-F3", "Find previous", self.find_previous)
937 937 self.makemenu(self.m_refresh, "&Refresh once \tF5", "Refresh once", self.refresh_once)
938 938 self.makemenu(self.m_refresh, "Refresh every &1s", "Refresh every second", self.refresh_every_second)
939 939 self.makemenu(self.m_refresh, "Refresh every &X seconds", "Refresh every X seconds", self.refresh_interval)
940 940 self.makemenu(self.m_refresh, "&Stop all refresh timers", "Stop refresh timers", self.stop_refresh)
941 941 self.menubar.Append(self.m_search, "&Find")
942 942 self.menubar.Append(self.m_sort, "&Sort")
943 943 self.menubar.Append(self.m_refresh, "&Refresh")
944 944 self.menubar.Append(self.m_help, "&Help")
945 945 self.SetMenuBar(self.menubar)
946 946 self.searchtext = ""
947 947 self.searchexpression = ""
948 948 self.helpdialog = None
949 949 self.refresh_interval = 1000
950 950 self.SetStatusText("Refreshing inactive", 1)
951 951
952 952 def refresh_once(self, event):
953 953 table = self.notebook.GetPage(self.notebook.GetSelection()).grid.table
954 954 table.refresh_content(event)
955 955
956 956 def refresh_interval(self, event):
957 957 table = self.notebook.GetPage(self.notebook.GetSelection()).grid.table
958 958 dlg = wx.TextEntryDialog(self, "Enter refresh interval (milliseconds):", "Refresh timer:", defaultValue=str(self.refresh_interval))
959 959 if dlg.ShowModal() == wx.ID_OK:
960 960 try:
961 961 milliseconds = int(dlg.GetValue())
962 962 except ValueError, exc:
963 963 self.SetStatusText(str(exc))
964 964 else:
965 965 table.timer.Start(milliseconds=milliseconds, oneShot=False)
966 966 self.SetStatusText("Refresh timer set to %s ms" % milliseconds)
967 967 self.SetStatusText("Refresh interval: %s ms" % milliseconds, 1)
968 968 self.refresh_interval = milliseconds
969 969 dlg.Destroy()
970 970
971 971 def stop_refresh(self, event):
972 972 for i in xrange(self.notebook.GetPageCount()):
973 973 nb = self.notebook.GetPage(i)
974 974 nb.grid.table.timer.Stop()
975 975 self.SetStatusText("Refreshing inactive", 1)
976 976
977 977 def refresh_every_second(self, event):
978 978 table = self.notebook.GetPage(self.notebook.GetSelection()).grid.table
979 979 table.timer.Start(milliseconds=1000, oneShot=False)
980 980 self.SetStatusText("Refresh interval: 1000 ms", 1)
981 981
982 982 def sortasc(self, event):
983 983 grid = self.notebook.GetPage(self.notebook.GetSelection()).grid
984 984 grid.sortattrasc()
985 985
986 986 def sortdesc(self, event):
987 987 grid = self.notebook.GetPage(self.notebook.GetSelection()).grid
988 988 grid.sortattrdesc()
989 989
990 990 def find_previous(self, event):
991 991 """
992 992 find previous occurrences
993 993 """
994 994 grid = self.notebook.GetPage(self.notebook.GetSelection()).grid
995 995 if self.searchtext:
996 996 row = grid.GetGridCursorRow()
997 997 col = grid.GetGridCursorCol()
998 998 self.SetStatusText('Search mode: text; looking for %s' % self.searchtext)
999 999 if col-1 >= 0:
1000 1000 grid.search(self.searchtext, row, col-1, False)
1001 1001 else:
1002 1002 grid.search(self.searchtext, row-1, grid.table.GetNumberCols()-1, False)
1003 1003 elif self.searchexpression:
1004 1004 self.SetStatusText("Search mode: expression; looking for %s" % repr(self.searchexpression)[2:-1])
1005 1005 grid.searchexpression(searchexp=self.searchexpression, search_forward=False)
1006 1006 else:
1007 1007 self.SetStatusText("No search yet: please enter search-text or -expression")
1008 1008
1009 1009 def find_next(self, event):
1010 1010 """
1011 1011 find the next occurrence
1012 1012 """
1013 1013 grid = self.notebook.GetPage(self.notebook.GetSelection()).grid
1014 1014 if self.searchtext != "":
1015 1015 row = grid.GetGridCursorRow()
1016 1016 col = grid.GetGridCursorCol()
1017 1017 self.SetStatusText('Search mode: text; looking for %s' % self.searchtext)
1018 1018 if col+1 < grid.table.GetNumberCols():
1019 1019 grid.search(self.searchtext, row, col+1)
1020 1020 else:
1021 1021 grid.search(self.searchtext, row+1, 0)
1022 1022 elif self.searchexpression != "":
1023 1023 self.SetStatusText('Search mode: expression; looking for %s' % repr(self.searchexpression)[2:-1])
1024 1024 grid.searchexpression(searchexp=self.searchexpression)
1025 1025 else:
1026 1026 self.SetStatusText("No search yet: please enter search-text or -expression")
1027 1027
1028 1028 def display_help(self, event):
1029 1029 """
1030 1030 Display a help dialog
1031 1031 """
1032 1032 if self.helpdialog:
1033 1033 self.helpdialog.Destroy()
1034 1034 self.helpdialog = IGridHTMLHelp(None, title="Help", size=wx.Size(600,400))
1035 1035 self.helpdialog.Show()
1036 1036
1037 1037 def display_help_in_browser(self, event):
1038 1038 """
1039 1039 Show the help-HTML in a browser (as a ``HtmlWindow`` does not understand
1040 1040 CSS this looks better)
1041 1041 """
1042 1042 filename = urllib.pathname2url(os.path.abspath(os.path.join(os.path.dirname(__file__), "igrid_help.html")))
1043 1043 if not filename.startswith("file"):
1044 1044 filename = "file:" + filename
1045 1045 webbrowser.open(filename, new=1, autoraise=True)
1046 1046
1047 1047 def enter_searchexpression(self, event):
1048 1048 dlg = wx.TextEntryDialog(self, "Find:", "Find matching expression:", defaultValue=self.searchexpression)
1049 1049 if dlg.ShowModal() == wx.ID_OK:
1050 1050 self.searchexpression = dlg.GetValue()
1051 1051 self.searchtext = ""
1052 1052 self.SetStatusText('Search mode: expression; looking for %s' % repr(self.searchexpression)[2:-1])
1053 1053 self.notebook.GetPage(self.notebook.GetSelection()).grid.searchexpression(self.searchexpression)
1054 1054 dlg.Destroy()
1055 1055
1056 1056 def makemenu(self, menu, label, help, cmd):
1057 1057 menu.Append(self.menucounter, label, help)
1058 1058 self.Bind(wx.EVT_MENU, cmd, id=self.menucounter)
1059 1059 self.menucounter += 1
1060 1060
1061 1061 def _add_notebook(self, input, *attrs):
1062 1062 # Adds another notebook which has the starting object ``input``
1063 1063 panel = IGridPanel(self.notebook, input, *attrs)
1064 1064 text = str(ipipe.xformat(input, "header", self.maxtitlelen)[2])
1065 1065 if len(text) >= self.maxtitlelen:
1066 1066 text = text[:self.maxtitlelen].rstrip(".") + "..."
1067 1067 self.notebook.AddPage(panel, text, True)
1068 1068 panel.grid.SetFocus()
1069 1069 self.Layout()
1070 1070
1071 1071 def OnCloseWindow(self, event):
1072 1072 self.Destroy()
1073 1073
1074 1074 def enter_searchtext(self, event):
1075 1075 # Displays a dialog asking for the searchtext
1076 1076 dlg = wx.TextEntryDialog(self, "Find:", "Find in list", defaultValue=self.searchtext)
1077 1077 if dlg.ShowModal() == wx.ID_OK:
1078 1078 self.searchtext = dlg.GetValue()
1079 1079 self.searchexpression = ""
1080 1080 self.SetStatusText('Search mode: text; looking for %s' % self.searchtext)
1081 1081 self.notebook.GetPage(self.notebook.GetSelection()).grid.search(self.searchtext)
1082 1082 dlg.Destroy()
1083 1083
1084 1084
1085 1085 class App(wx.App):
1086 1086 def __init__(self, input):
1087 1087 self.input = input
1088 1088 self.result = None # Result to be returned to IPython. Set by quit().
1089 1089 wx.App.__init__(self)
1090 1090
1091 1091 def OnInit(self):
1092 1092 frame = IGridFrame(self, self.input)
1093 1093 frame.Show()
1094 1094 self.SetTopWindow(frame)
1095 1095 frame.Raise()
1096 1096 return True
1097 1097
1098 1098
1099 1099 class igrid(ipipe.Display):
1100 1100 """
1101 1101 This is a wx-based display object that can be used instead of ``ibrowse``
1102 1102 (which is curses-based) or ``idump`` (which simply does a print).
1103 1103 """
1104 1104
1105 def __init__(self, input=None):
1106 self.input = input
1107
1108 1105 if wx.VERSION < (2, 7):
1109 1106 def display(self):
1110 1107 try:
1111 # Try to create a "standalone" from. If this works we're probably
1108 # Try to create a "standalone" frame. If this works we're probably
1112 1109 # running with -wthread.
1113 1110 # Note that this sets the parent of the frame to None, but we can't
1114 1111 # pass a result object back to the shell anyway.
1115 1112 frame = IGridFrame(None, self.input)
1116 1113 frame.Show()
1117 1114 frame.Raise()
1118 1115 except wx.PyNoAppError:
1119 1116 # There's no wx application yet => create one.
1120 1117 app = App(self.input)
1121 1118 app.MainLoop()
1122 1119 return app.result
1123 1120 else:
1124 1121 # With wx 2.7 it gets simpler.
1125 1122 def display(self):
1126 1123 app = App(self.input)
1127 1124 app.MainLoop()
1128 1125 return app.result
1129 1126
@@ -1,2250 +1,2255 b''
1 1 # -*- coding: iso-8859-1 -*-
2 2
3 3 """
4 4 ``ipipe`` provides classes to be used in an interactive Python session. Doing a
5 5 ``from ipipe import *`` is the preferred way to do this. The name of all
6 6 objects imported this way starts with ``i`` to minimize collisions.
7 7
8 8 ``ipipe`` supports "pipeline expressions", which is something resembling Unix
9 9 pipes. An example is:
10 10
11 11 >>> ienv | isort("key.lower()")
12 12
13 13 This gives a listing of all environment variables sorted by name.
14 14
15 15
16 16 There are three types of objects in a pipeline expression:
17 17
18 18 * ``Table``s: These objects produce items. Examples are ``ils`` (listing the
19 19 current directory, ``ienv`` (listing environment variables), ``ipwd`` (listing
20 20 user accounts) and ``igrp`` (listing user groups). A ``Table`` must be the
21 21 first object in a pipe expression.
22 22
23 23 * ``Pipe``s: These objects sit in the middle of a pipe expression. They
24 24 transform the input in some way (e.g. filtering or sorting it). Examples are:
25 25 ``ifilter`` (which filters the input pipe), ``isort`` (which sorts the input
26 26 pipe) and ``ieval`` (which evaluates a function or expression for each object
27 27 in the input pipe).
28 28
29 29 * ``Display``s: These objects can be put as the last object in a pipeline
30 30 expression. There are responsible for displaying the result of the pipeline
31 31 expression. If a pipeline expression doesn't end in a display object a default
32 32 display objects will be used. One example is ``ibrowse`` which is a ``curses``
33 33 based browser.
34 34
35 35
36 36 Adding support for pipeline expressions to your own objects can be done through
37 37 three extensions points (all of them optional):
38 38
39 39 * An object that will be displayed as a row by a ``Display`` object should
40 40 implement the method ``__xattrs__(self, mode)`` method or register an
41 41 implementation of the generic function ``xattrs``. For more info see ``xattrs``.
42 42
43 43 * When an object ``foo`` is displayed by a ``Display`` object, the generic
44 44 function ``xrepr`` is used.
45 45
46 46 * Objects that can be iterated by ``Pipe``s must iterable. For special cases,
47 47 where iteration for display is different than the normal iteration a special
48 48 implementation can be registered with the generic function ``xiter``. This makes
49 49 it possible to use dictionaries and modules in pipeline expressions, for example:
50 50
51 51 >>> import sys
52 52 >>> sys | ifilter("isinstance(value, int)") | idump
53 53 key |value
54 54 api_version| 1012
55 55 dllhandle | 503316480
56 56 hexversion | 33817328
57 57 maxint |2147483647
58 58 maxunicode | 65535
59 59 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
60 60 ...
61 61
62 62 Note: The expression strings passed to ``ifilter()`` and ``isort()`` can
63 63 refer to the object to be filtered or sorted via the variable ``_`` and to any
64 64 of the attributes of the object, i.e.:
65 65
66 66 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
67 67
68 68 does the same as
69 69
70 70 >>> sys.modules | ifilter("value is not None") | isort("key.lower()")
71 71
72 72 In addition to expression strings, it's possible to pass callables (taking
73 73 the object as an argument) to ``ifilter()``, ``isort()`` and ``ieval()``:
74 74
75 75 >>> sys | ifilter(lambda _:isinstance(_.value, int)) \
76 76 ... | ieval(lambda _: (_.key, hex(_.value))) | idump
77 77 0 |1
78 78 api_version|0x3f4
79 79 dllhandle |0x1e000000
80 80 hexversion |0x20402f0
81 81 maxint |0x7fffffff
82 82 maxunicode |0xffff
83 83 """
84 84
85 85 import sys, os, os.path, stat, glob, new, csv, datetime, types
86 86 import itertools, mimetypes, StringIO
87 87
88 88 try: # Python 2.3 compatibility
89 89 import collections
90 90 except ImportError:
91 91 deque = list
92 92 else:
93 93 deque = collections.deque
94 94
95 95 try: # Python 2.3 compatibility
96 96 set
97 97 except NameError:
98 98 import sets
99 99 set = sets.Set
100 100
101 101 try: # Python 2.3 compatibility
102 102 sorted
103 103 except NameError:
104 104 def sorted(iterator, key=None, reverse=False):
105 105 items = list(iterator)
106 106 if key is not None:
107 107 items.sort(lambda i1, i2: cmp(key(i1), key(i2)))
108 108 else:
109 109 items.sort()
110 110 if reverse:
111 111 items.reverse()
112 112 return items
113 113
114 114 try:
115 115 import pwd
116 116 except ImportError:
117 117 pwd = None
118 118
119 119 try:
120 120 import grp
121 121 except ImportError:
122 122 grp = None
123 123
124 124 from IPython.external import simplegeneric
125 125
126 126 import path
127 127 try:
128 128 from IPython import genutils, ipapi
129 129 except ImportError:
130 130 genutils = None
131 131 ipapi = None
132 132
133 import astyle
134
135 133
136 134 __all__ = [
137 135 "ifile", "ils", "iglob", "iwalk", "ipwdentry", "ipwd", "igrpentry", "igrp",
138 136 "icsv", "ix", "ichain", "isort", "ifilter", "ieval", "ienum",
139 137 "ienv", "ihist", "icap", "idump", "iless"
140 138 ]
141 139
142 140
143 141 os.stat_float_times(True) # enable microseconds
144 142
145 143
146 144 class AttrNamespace(object):
147 145 """
148 146 Helper class that is used for providing a namespace for evaluating
149 147 expressions containing attribute names of an object.
150 148 """
151 149 def __init__(self, wrapped):
152 150 self.wrapped = wrapped
153 151
154 152 def __getitem__(self, name):
155 153 if name == "_":
156 154 return self.wrapped
157 155 try:
158 156 return getattr(self.wrapped, name)
159 157 except AttributeError:
160 158 raise KeyError(name)
161 159
162 160 # Python 2.3 compatibility
163 161 # use eval workaround to find out which names are used in the
164 162 # eval string and put them into the locals. This works for most
165 163 # normal uses case, bizarre ones like accessing the locals()
166 164 # will fail
167 165 try:
168 166 eval("_", None, AttrNamespace(None))
169 167 except TypeError:
170 168 real_eval = eval
171 169 def eval(codestring, _globals, _locals):
172 170 """
173 171 eval(source[, globals[, locals]]) -> value
174 172
175 173 Evaluate the source in the context of globals and locals.
176 174 The source may be a string representing a Python expression
177 175 or a code object as returned by compile().
178 176 The globals must be a dictionary and locals can be any mappping.
179 177
180 178 This function is a workaround for the shortcomings of
181 179 Python 2.3's eval.
182 180 """
183 181
184 182 if isinstance(codestring, basestring):
185 183 code = compile(codestring, "_eval", "eval")
186 184 else:
187 185 code = codestring
188 186 newlocals = {}
189 187 for name in code.co_names:
190 188 try:
191 189 newlocals[name] = _locals[name]
192 190 except KeyError:
193 191 pass
194 192 return real_eval(code, _globals, newlocals)
195 193
196 194
197 195 noitem = object()
198 196
199 197
200 198 def item(iterator, index, default=noitem):
201 199 """
202 200 Return the ``index``th item from the iterator ``iterator``.
203 201 ``index`` must be an integer (negative integers are relative to the
204 202 end (i.e. the last items produced by the iterator)).
205 203
206 204 If ``default`` is given, this will be the default value when
207 205 the iterator doesn't contain an item at this position. Otherwise an
208 206 ``IndexError`` will be raised.
209 207
210 208 Note that using this function will partially or totally exhaust the
211 209 iterator.
212 210 """
213 211 i = index
214 212 if i>=0:
215 213 for item in iterator:
216 214 if not i:
217 215 return item
218 216 i -= 1
219 217 else:
220 218 i = -index
221 219 cache = deque()
222 220 for item in iterator:
223 221 cache.append(item)
224 222 if len(cache)>i:
225 223 cache.popleft()
226 224 if len(cache)==i:
227 225 return cache.popleft()
228 226 if default is noitem:
229 227 raise IndexError(index)
230 228 else:
231 229 return default
232 230
233 231
234 232 def getglobals(g):
235 233 """
236 234 Return the global namespace that is used for expression strings in
237 235 ``ifilter`` and others. This is ``g`` or (if ``g`` is ``None``) IPython's
238 236 user namespace.
239 237 """
240 238 if g is None:
241 239 if ipapi is not None:
242 240 api = ipapi.get()
243 241 if api is not None:
244 242 return api.user_ns
245 243 return globals()
246 244 return g
247 245
248 246
249 247 class Descriptor(object):
250 248 """
251 249 A ``Descriptor`` object is used for describing the attributes of objects.
252 250 """
253 251 def __hash__(self):
254 252 return hash(self.__class__) ^ hash(self.key())
255 253
256 254 def __eq__(self, other):
257 255 return self.__class__ is other.__class__ and self.key() == other.key()
258 256
259 257 def __ne__(self, other):
260 258 return self.__class__ is not other.__class__ or self.key() != other.key()
261 259
262 260 def key(self):
263 261 pass
264 262
265 263 def name(self):
266 264 """
267 265 Return the name of this attribute for display by a ``Display`` object
268 266 (e.g. as a column title).
269 267 """
270 268 key = self.key()
271 269 if key is None:
272 270 return "_"
273 271 return str(key)
274 272
275 273 def attrtype(self, obj):
276 274 """
277 275 Return the type of this attribute (i.e. something like "attribute" or
278 276 "method").
279 277 """
280 278
281 279 def valuetype(self, obj):
282 280 """
283 281 Return the type of this attribute value of the object ``obj``.
284 282 """
285 283
286 284 def value(self, obj):
287 285 """
288 286 Return the value of this attribute of the object ``obj``.
289 287 """
290 288
291 289 def doc(self, obj):
292 290 """
293 291 Return the documentation for this attribute.
294 292 """
295 293
296 294 def shortdoc(self, obj):
297 295 """
298 296 Return a short documentation for this attribute (defaulting to the
299 297 first line).
300 298 """
301 299 doc = self.doc(obj)
302 300 if doc is not None:
303 301 doc = doc.strip().splitlines()[0].strip()
304 302 return doc
305 303
306 304 def iter(self, obj):
307 305 """
308 306 Return an iterator for this attribute of the object ``obj``.
309 307 """
310 308 return xiter(self.value(obj))
311 309
312 310
313 311 class SelfDescriptor(Descriptor):
314 312 """
315 313 A ``SelfDescriptor`` describes the object itself.
316 314 """
317 315 def key(self):
318 316 return None
319 317
320 318 def attrtype(self, obj):
321 319 return "self"
322 320
323 321 def valuetype(self, obj):
324 322 return type(obj)
325 323
326 324 def value(self, obj):
327 325 return obj
328 326
329 327 def __repr__(self):
330 328 return "Self"
331 329
332 330 selfdescriptor = SelfDescriptor() # there's no need for more than one
333 331
334 332
335 333 class AttributeDescriptor(Descriptor):
336 334 """
337 335 An ``AttributeDescriptor`` describes a simple attribute of an object.
338 336 """
339 337 __slots__ = ("_name", "_doc")
340 338
341 339 def __init__(self, name, doc=None):
342 340 self._name = name
343 341 self._doc = doc
344 342
345 343 def key(self):
346 344 return self._name
347 345
348 346 def doc(self, obj):
349 347 return self._doc
350 348
351 349 def attrtype(self, obj):
352 350 return "attr"
353 351
354 352 def valuetype(self, obj):
355 353 return type(getattr(obj, self._name))
356 354
357 355 def value(self, obj):
358 356 return getattr(obj, self._name)
359 357
360 358 def __repr__(self):
361 359 if self._doc is None:
362 360 return "Attribute(%r)" % self._name
363 361 else:
364 362 return "Attribute(%r, %r)" % (self._name, self._doc)
365 363
366 364
367 365 class IndexDescriptor(Descriptor):
368 366 """
369 367 An ``IndexDescriptor`` describes an "attribute" of an object that is fetched
370 368 via ``__getitem__``.
371 369 """
372 370 __slots__ = ("_index",)
373 371
374 372 def __init__(self, index):
375 373 self._index = index
376 374
377 375 def key(self):
378 376 return self._index
379 377
380 378 def attrtype(self, obj):
381 379 return "item"
382 380
383 381 def valuetype(self, obj):
384 382 return type(obj[self._index])
385 383
386 384 def value(self, obj):
387 385 return obj[self._index]
388 386
389 387 def __repr__(self):
390 388 return "Index(%r)" % self._index
391 389
392 390
393 391 class MethodDescriptor(Descriptor):
394 392 """
395 393 A ``MethodDescriptor`` describes a method of an object that can be called
396 394 without argument. Note that this method shouldn't change the object.
397 395 """
398 396 __slots__ = ("_name", "_doc")
399 397
400 398 def __init__(self, name, doc=None):
401 399 self._name = name
402 400 self._doc = doc
403 401
404 402 def key(self):
405 403 return self._name
406 404
407 405 def doc(self, obj):
408 406 if self._doc is None:
409 407 return getattr(obj, self._name).__doc__
410 408 return self._doc
411 409
412 410 def attrtype(self, obj):
413 411 return "method"
414 412
415 413 def valuetype(self, obj):
416 414 return type(self.value(obj))
417 415
418 416 def value(self, obj):
419 417 return getattr(obj, self._name)()
420 418
421 419 def __repr__(self):
422 420 if self._doc is None:
423 421 return "Method(%r)" % self._name
424 422 else:
425 423 return "Method(%r, %r)" % (self._name, self._doc)
426 424
427 425
428 426 class IterAttributeDescriptor(Descriptor):
429 427 """
430 428 An ``IterAttributeDescriptor`` works like an ``AttributeDescriptor`` but
431 429 doesn't return an attribute values (because this value might be e.g. a large
432 430 list).
433 431 """
434 432 __slots__ = ("_name", "_doc")
435 433
436 434 def __init__(self, name, doc=None):
437 435 self._name = name
438 436 self._doc = doc
439 437
440 438 def key(self):
441 439 return self._name
442 440
443 441 def doc(self, obj):
444 442 return self._doc
445 443
446 444 def attrtype(self, obj):
447 445 return "iter"
448 446
449 447 def valuetype(self, obj):
450 448 return noitem
451 449
452 450 def value(self, obj):
453 451 return noitem
454 452
455 453 def iter(self, obj):
456 454 return xiter(getattr(obj, self._name))
457 455
458 456 def __repr__(self):
459 457 if self._doc is None:
460 458 return "IterAttribute(%r)" % self._name
461 459 else:
462 460 return "IterAttribute(%r, %r)" % (self._name, self._doc)
463 461
464 462
465 463 class IterMethodDescriptor(Descriptor):
466 464 """
467 465 An ``IterMethodDescriptor`` works like an ``MethodDescriptor`` but doesn't
468 466 return an attribute values (because this value might be e.g. a large list).
469 467 """
470 468 __slots__ = ("_name", "_doc")
471 469
472 470 def __init__(self, name, doc=None):
473 471 self._name = name
474 472 self._doc = doc
475 473
476 474 def key(self):
477 475 return self._name
478 476
479 477 def doc(self, obj):
480 478 if self._doc is None:
481 479 return getattr(obj, self._name).__doc__
482 480 return self._doc
483 481
484 482 def attrtype(self, obj):
485 483 return "itermethod"
486 484
487 485 def valuetype(self, obj):
488 486 return noitem
489 487
490 488 def value(self, obj):
491 489 return noitem
492 490
493 491 def iter(self, obj):
494 492 return xiter(getattr(obj, self._name)())
495 493
496 494 def __repr__(self):
497 495 if self._doc is None:
498 496 return "IterMethod(%r)" % self._name
499 497 else:
500 498 return "IterMethod(%r, %r)" % (self._name, self._doc)
501 499
502 500
503 501 class FunctionDescriptor(Descriptor):
504 502 """
505 503 A ``FunctionDescriptor`` turns a function into a descriptor. The function
506 504 will be called with the object to get the type and value of the attribute.
507 505 """
508 506 __slots__ = ("_function", "_name", "_doc")
509 507
510 508 def __init__(self, function, name=None, doc=None):
511 509 self._function = function
512 510 self._name = name
513 511 self._doc = doc
514 512
515 513 def key(self):
516 514 return self._function
517 515
518 516 def name(self):
519 517 if self._name is not None:
520 518 return self._name
521 519 return getattr(self._function, "__xname__", self._function.__name__)
522 520
523 521 def doc(self, obj):
524 522 if self._doc is None:
525 523 return self._function.__doc__
526 524 return self._doc
527 525
528 526 def attrtype(self, obj):
529 527 return "function"
530 528
531 529 def valuetype(self, obj):
532 530 return type(self._function(obj))
533 531
534 532 def value(self, obj):
535 533 return self._function(obj)
536 534
537 535 def __repr__(self):
538 536 if self._doc is None:
539 537 return "Function(%r)" % self._name
540 538 else:
541 539 return "Function(%r, %r)" % (self._name, self._doc)
542 540
543 541
544 542 class Table(object):
545 543 """
546 544 A ``Table`` is an object that produces items (just like a normal Python
547 545 iterator/generator does) and can be used as the first object in a pipeline
548 546 expression. The displayhook will open the default browser for such an object
549 547 (instead of simply printing the ``repr()`` result).
550 548 """
551 549
552 550 # We want to support ``foo`` and ``foo()`` in pipeline expression:
553 551 # So we implement the required operators (``|`` and ``+``) in the metaclass,
554 552 # instantiate the class and forward the operator to the instance
555 553 class __metaclass__(type):
556 554 def __iter__(self):
557 555 return iter(self())
558 556
559 557 def __or__(self, other):
560 558 return self() | other
561 559
562 560 def __add__(self, other):
563 561 return self() + other
564 562
565 563 def __radd__(self, other):
566 564 return other + self()
567 565
568 566 def __getitem__(self, index):
569 567 return self()[index]
570 568
571 569 def __getitem__(self, index):
572 570 return item(self, index)
573 571
574 572 def __contains__(self, item):
575 573 for haveitem in self:
576 574 if item == haveitem:
577 575 return True
578 576 return False
579 577
580 578 def __or__(self, other):
581 579 # autoinstantiate right hand side
582 580 if isinstance(other, type) and issubclass(other, (Table, Display)):
583 581 other = other()
584 582 # treat simple strings and functions as ``ieval`` instances
585 583 elif not isinstance(other, Display) and not isinstance(other, Table):
586 584 other = ieval(other)
587 585 # forward operations to the right hand side
588 586 return other.__ror__(self)
589 587
590 588 def __add__(self, other):
591 589 # autoinstantiate right hand side
592 590 if isinstance(other, type) and issubclass(other, Table):
593 591 other = other()
594 592 return ichain(self, other)
595 593
596 594 def __radd__(self, other):
597 595 # autoinstantiate left hand side
598 596 if isinstance(other, type) and issubclass(other, Table):
599 597 other = other()
600 598 return ichain(other, self)
601 599
602 600
603 601 class Pipe(Table):
604 602 """
605 603 A ``Pipe`` is an object that can be used in a pipeline expression. It
606 604 processes the objects it gets from its input ``Table``/``Pipe``. Note that
607 605 a ``Pipe`` object can't be used as the first object in a pipeline
608 606 expression, as it doesn't produces items itself.
609 607 """
610 608 class __metaclass__(Table.__metaclass__):
611 609 def __ror__(self, input):
612 610 return input | self()
613 611
614 612 def __ror__(self, input):
615 613 # autoinstantiate left hand side
616 614 if isinstance(input, type) and issubclass(input, Table):
617 615 input = input()
618 616 self.input = input
619 617 return self
620 618
621 619
622 620 def xrepr(item, mode="default"):
623 621 """
624 622 Generic function that adds color output and different display modes to ``repr``.
625 623
626 624 The result of an ``xrepr`` call is iterable and consists of ``(style, string)``
627 625 tuples. The ``style`` in this tuple must be a ``Style`` object from the
628 626 ``astring`` module. To reconfigure the output the first yielded tuple can be
629 627 a ``(aligment, full)`` tuple instead of a ``(style, string)`` tuple.
630 628 ``alignment`` can be -1 for left aligned, 0 for centered and 1 for right
631 629 aligned (the default is left alignment). ``full`` is a boolean that specifies
632 630 whether the complete output must be displayed or the ``Display`` object is
633 631 allowed to stop output after enough text has been produced (e.g. a syntax
634 632 highlighted text line would use ``True``, but for a large data structure
635 633 (i.e. a nested list, tuple or dictionary) ``False`` would be used).
636 634 The default is full output.
637 635
638 636 There are four different possible values for ``mode`` depending on where
639 637 the ``Display`` object will display ``item``:
640 638
641 639 * ``"header"``: ``item`` will be displayed in a header line (this is used by
642 640 ``ibrowse``).
643 641 * ``"footer"``: ``item`` will be displayed in a footer line (this is used by
644 642 ``ibrowse``).
645 643 * ``"cell"``: ``item`` will be displayed in a table cell/list.
646 644 * ``"default"``: default mode. If an ``xrepr`` implementation recursively
647 645 outputs objects, ``"default"`` must be passed in the recursive calls to
648 646 ``xrepr``.
649 647
650 648 If no implementation is registered for ``item``, ``xrepr`` will try the
651 649 ``__xrepr__`` method on ``item``. If ``item`` doesn't have an ``__xrepr__``
652 650 method it falls back to ``repr``/``__repr__`` for all modes.
653 651 """
654 652 try:
655 653 func = item.__xrepr__
656 654 except AttributeError:
657 655 yield (astyle.style_default, repr(item))
658 656 else:
659 657 try:
660 658 for x in func(mode):
661 659 yield x
662 660 except (KeyboardInterrupt, SystemExit):
663 661 raise
664 662 except Exception:
665 663 yield (astyle.style_default, repr(item))
666 664 xrepr = simplegeneric.generic(xrepr)
667 665
668 666
669 667 def xrepr_none(self, mode="default"):
670 668 yield (astyle.style_type_none, repr(self))
671 669 xrepr.when_object(None)(xrepr_none)
672 670
673 671
674 672 def xrepr_noitem(self, mode="default"):
675 673 yield (2, True)
676 674 yield (astyle.style_nodata, "<?>")
677 675 xrepr.when_object(noitem)(xrepr_noitem)
678 676
679 677
680 678 def xrepr_bool(self, mode="default"):
681 679 yield (astyle.style_type_bool, repr(self))
682 680 xrepr.when_type(bool)(xrepr_bool)
683 681
684 682
685 683 def xrepr_str(self, mode="default"):
686 684 if mode == "cell":
687 685 yield (astyle.style_default, repr(self.expandtabs(tab))[1:-1])
688 686 else:
689 687 yield (astyle.style_default, repr(self))
690 688 xrepr.when_type(str)(xrepr_str)
691 689
692 690
693 691 def xrepr_unicode(self, mode="default"):
694 692 if mode == "cell":
695 693 yield (astyle.style_default, repr(self.expandtabs(tab))[2:-1])
696 694 else:
697 695 yield (astyle.style_default, repr(self))
698 696 xrepr.when_type(unicode)(xrepr_unicode)
699 697
700 698
701 699 def xrepr_number(self, mode="default"):
702 700 yield (1, True)
703 701 yield (astyle.style_type_number, repr(self))
704 702 xrepr.when_type(int)(xrepr_number)
705 703 xrepr.when_type(long)(xrepr_number)
706 704 xrepr.when_type(float)(xrepr_number)
707 705
708 706
709 707 def xrepr_complex(self, mode="default"):
710 708 yield (astyle.style_type_number, repr(self))
711 709 xrepr.when_type(complex)(xrepr_number)
712 710
713 711
714 712 def xrepr_datetime(self, mode="default"):
715 713 if mode == "cell":
716 714 # Don't use strftime() here, as this requires year >= 1900
717 715 yield (astyle.style_type_datetime,
718 716 "%04d-%02d-%02d %02d:%02d:%02d.%06d" % \
719 717 (self.year, self.month, self.day,
720 718 self.hour, self.minute, self.second,
721 719 self.microsecond),
722 720 )
723 721 else:
724 722 yield (astyle.style_type_datetime, repr(self))
725 723 xrepr.when_type(datetime.datetime)(xrepr_datetime)
726 724
727 725
728 726 def xrepr_date(self, mode="default"):
729 727 if mode == "cell":
730 728 yield (astyle.style_type_datetime,
731 729 "%04d-%02d-%02d" % (self.year, self.month, self.day))
732 730 else:
733 731 yield (astyle.style_type_datetime, repr(self))
734 732 xrepr.when_type(datetime.date)(xrepr_date)
735 733
736 734
737 735 def xrepr_time(self, mode="default"):
738 736 if mode == "cell":
739 737 yield (astyle.style_type_datetime,
740 738 "%02d:%02d:%02d.%06d" % \
741 739 (self.hour, self.minute, self.second, self.microsecond))
742 740 else:
743 741 yield (astyle.style_type_datetime, repr(self))
744 742 xrepr.when_type(datetime.time)(xrepr_time)
745 743
746 744
747 745 def xrepr_timedelta(self, mode="default"):
748 746 yield (astyle.style_type_datetime, repr(self))
749 747 xrepr.when_type(datetime.timedelta)(xrepr_timedelta)
750 748
751 749
752 750 def xrepr_type(self, mode="default"):
753 751 if self.__module__ == "__builtin__":
754 752 yield (astyle.style_type_type, self.__name__)
755 753 else:
756 754 yield (astyle.style_type_type, "%s.%s" % (self.__module__, self.__name__))
757 755 xrepr.when_type(type)(xrepr_type)
758 756
759 757
760 758 def xrepr_exception(self, mode="default"):
761 759 if self.__class__.__module__ == "exceptions":
762 760 classname = self.__class__.__name__
763 761 else:
764 762 classname = "%s.%s" % \
765 763 (self.__class__.__module__, self.__class__.__name__)
766 764 if mode == "header" or mode == "footer":
767 765 yield (astyle.style_error, "%s: %s" % (classname, self))
768 766 else:
769 767 yield (astyle.style_error, classname)
770 768 xrepr.when_type(Exception)(xrepr_exception)
771 769
772 770
773 771 def xrepr_listtuple(self, mode="default"):
774 772 if mode == "header" or mode == "footer":
775 773 if self.__class__.__module__ == "__builtin__":
776 774 classname = self.__class__.__name__
777 775 else:
778 776 classname = "%s.%s" % \
779 777 (self.__class__.__module__,self.__class__.__name__)
780 778 yield (astyle.style_default,
781 779 "<%s object with %d items at 0x%x>" % \
782 780 (classname, len(self), id(self)))
783 781 else:
784 782 yield (-1, False)
785 783 if isinstance(self, list):
786 784 yield (astyle.style_default, "[")
787 785 end = "]"
788 786 else:
789 787 yield (astyle.style_default, "(")
790 788 end = ")"
791 789 for (i, subself) in enumerate(self):
792 790 if i:
793 791 yield (astyle.style_default, ", ")
794 792 for part in xrepr(subself, "default"):
795 793 yield part
796 794 yield (astyle.style_default, end)
797 795 xrepr.when_type(list)(xrepr_listtuple)
798 796 xrepr.when_type(tuple)(xrepr_listtuple)
799 797
800 798
801 799 def xrepr_dict(self, mode="default"):
802 800 if mode == "header" or mode == "footer":
803 801 if self.__class__.__module__ == "__builtin__":
804 802 classname = self.__class__.__name__
805 803 else:
806 804 classname = "%s.%s" % \
807 805 (self.__class__.__module__,self.__class__.__name__)
808 806 yield (astyle.style_default,
809 807 "<%s object with %d items at 0x%x>" % \
810 808 (classname, len(self), id(self)))
811 809 else:
812 810 yield (-1, False)
813 811 if isinstance(self, dict):
814 812 yield (astyle.style_default, "{")
815 813 end = "}"
816 814 else:
817 815 yield (astyle.style_default, "dictproxy((")
818 816 end = "})"
819 817 for (i, (key, value)) in enumerate(self.iteritems()):
820 818 if i:
821 819 yield (astyle.style_default, ", ")
822 820 for part in xrepr(key, "default"):
823 821 yield part
824 822 yield (astyle.style_default, ": ")
825 823 for part in xrepr(value, "default"):
826 824 yield part
827 825 yield (astyle.style_default, end)
828 826 xrepr.when_type(dict)(xrepr_dict)
829 827 xrepr.when_type(types.DictProxyType)(xrepr_dict)
830 828
831 829
832 830 def upgradexattr(attr):
833 831 """
834 832 Convert an attribute descriptor string to a real descriptor object.
835 833
836 834 If attr already is a descriptor object return if unmodified. A
837 835 ``SelfDescriptor`` will be returned if ``attr`` is ``None``. ``"foo"``
838 836 returns an ``AttributeDescriptor`` for the attribute named ``"foo"``.
839 837 ``"foo()"`` returns a ``MethodDescriptor`` for the method named ``"foo"``.
840 838 ``"-foo"`` will return an ``IterAttributeDescriptor`` for the attribute
841 839 named ``"foo"`` and ``"-foo()"`` will return an ``IterMethodDescriptor``
842 840 for the method named ``"foo"``. Furthermore integer will return the appropriate
843 841 ``IndexDescriptor`` and callables will return a ``FunctionDescriptor``.
844 842 """
845 843 if attr is None:
846 844 return selfdescriptor
847 845 elif isinstance(attr, Descriptor):
848 846 return attr
849 847 elif isinstance(attr, str):
850 848 if attr.endswith("()"):
851 849 if attr.startswith("-"):
852 850 return IterMethodDescriptor(attr[1:-2])
853 851 else:
854 852 return MethodDescriptor(attr[:-2])
855 853 else:
856 854 if attr.startswith("-"):
857 855 return IterAttributeDescriptor(attr[1:])
858 856 else:
859 857 return AttributeDescriptor(attr)
860 858 elif isinstance(attr, (int, long)):
861 859 return IndexDescriptor(attr)
862 860 elif callable(attr):
863 861 return FunctionDescriptor(attr)
864 862 else:
865 863 raise TypeError("can't handle descriptor %r" % attr)
866 864
867 865
868 866 def xattrs(item, mode="default"):
869 867 """
870 868 Generic function that returns an iterable of attribute descriptors
871 869 to be used for displaying the attributes ob the object ``item`` in display
872 870 mode ``mode``.
873 871
874 872 There are two possible modes:
875 873
876 874 * ``"detail"``: The ``Display`` object wants to display a detailed list
877 875 of the object attributes.
878 876 * ``"default"``: The ``Display`` object wants to display the object in a
879 877 list view.
880 878
881 879 If no implementation is registered for the object ``item`` ``xattrs`` falls
882 880 back to trying the ``__xattrs__`` method of the object. If this doesn't
883 881 exist either, ``dir(item)`` is used for ``"detail"`` mode and ``(None,)``
884 882 for ``"default"`` mode.
885 883
886 884 The implementation must yield attribute descriptor (see the class
887 885 ``Descriptor`` for more info). The ``__xattrs__`` method may also return
888 886 attribute descriptor string (and ``None``) which will be converted to real
889 887 descriptors by ``upgradexattr()``.
890 888 """
891 889 try:
892 890 func = item.__xattrs__
893 891 except AttributeError:
894 892 if mode == "detail":
895 893 for attrname in dir(item):
896 894 yield AttributeDescriptor(attrname)
897 895 else:
898 896 yield selfdescriptor
899 897 else:
900 898 for attr in func(mode):
901 899 yield upgradexattr(attr)
902 900 xattrs = simplegeneric.generic(xattrs)
903 901
904 902
905 903 def xattrs_complex(self, mode="default"):
906 904 if mode == "detail":
907 905 return (AttributeDescriptor("real"), AttributeDescriptor("imag"))
908 906 return (selfdescriptor,)
909 907 xattrs.when_type(complex)(xattrs_complex)
910 908
911 909
912 910 def _isdict(item):
913 911 try:
914 912 itermeth = item.__class__.__iter__
915 913 except (AttributeError, TypeError):
916 914 return False
917 915 return itermeth is dict.__iter__ or itermeth is types.DictProxyType.__iter__
918 916
919 917
920 918 def _isstr(item):
921 919 if not isinstance(item, basestring):
922 920 return False
923 921 try:
924 922 itermeth = item.__class__.__iter__
925 923 except AttributeError:
926 924 return True
927 925 return False # ``__iter__`` has been redefined
928 926
929 927
930 928 def xiter(item):
931 929 """
932 930 Generic function that implements iteration for pipeline expression. If no
933 931 implementation is registered for ``item`` ``xiter`` falls back to ``iter``.
934 932 """
935 933 try:
936 934 func = item.__xiter__
937 935 except AttributeError:
938 936 if _isdict(item):
939 937 def items(item):
940 938 fields = ("key", "value")
941 939 for (key, value) in item.iteritems():
942 940 yield Fields(fields, key=key, value=value)
943 941 return items(item)
944 942 elif isinstance(item, new.module):
945 943 def items(item):
946 944 fields = ("key", "value")
947 945 for key in sorted(item.__dict__):
948 946 yield Fields(fields, key=key, value=getattr(item, key))
949 947 return items(item)
950 948 elif _isstr(item):
951 949 if not item:
952 950 raise ValueError("can't enter empty string")
953 951 lines = item.splitlines()
954 952 if len(lines) == 1:
955 953 def iterone(item):
956 954 yield item
957 955 return iterone(item)
958 956 else:
959 957 return iter(lines)
960 958 return iter(item)
961 959 else:
962 960 return iter(func()) # iter() just to be safe
963 961 xiter = simplegeneric.generic(xiter)
964 962
965 963
966 964 class ichain(Pipe):
967 965 """
968 966 Chains multiple ``Table``s into one.
969 967 """
970 968
971 969 def __init__(self, *iters):
972 970 self.iters = iters
973 971
974 972 def __iter__(self):
975 973 return itertools.chain(*self.iters)
976 974
977 975 def __xrepr__(self, mode="default"):
978 976 if mode == "header" or mode == "footer":
979 977 for (i, item) in enumerate(self.iters):
980 978 if i:
981 979 yield (astyle.style_default, "+")
982 980 if isinstance(item, Pipe):
983 981 yield (astyle.style_default, "(")
984 982 for part in xrepr(item, mode):
985 983 yield part
986 984 if isinstance(item, Pipe):
987 985 yield (astyle.style_default, ")")
988 986 else:
989 987 yield (astyle.style_default, repr(self))
990 988
991 989 def __repr__(self):
992 990 args = ", ".join([repr(it) for it in self.iters])
993 991 return "%s.%s(%s)" % \
994 992 (self.__class__.__module__, self.__class__.__name__, args)
995 993
996 994
997 995 class ifile(path.path):
998 996 """
999 997 file (or directory) object.
1000 998 """
1001 999
1002 1000 def getmode(self):
1003 1001 return self.stat().st_mode
1004 1002 mode = property(getmode, None, None, "Access mode")
1005 1003
1006 1004 def gettype(self):
1007 1005 data = [
1008 1006 (stat.S_ISREG, "file"),
1009 1007 (stat.S_ISDIR, "dir"),
1010 1008 (stat.S_ISCHR, "chardev"),
1011 1009 (stat.S_ISBLK, "blockdev"),
1012 1010 (stat.S_ISFIFO, "fifo"),
1013 1011 (stat.S_ISLNK, "symlink"),
1014 1012 (stat.S_ISSOCK,"socket"),
1015 1013 ]
1016 1014 lstat = self.lstat()
1017 1015 if lstat is not None:
1018 1016 types = set([text for (func, text) in data if func(lstat.st_mode)])
1019 1017 else:
1020 1018 types = set()
1021 1019 m = self.mode
1022 1020 types.update([text for (func, text) in data if func(m)])
1023 1021 return ", ".join(types)
1024 1022 type = property(gettype, None, None, "file type (file, directory, link, etc.)")
1025 1023
1026 1024 def getmodestr(self):
1027 1025 m = self.mode
1028 1026 data = [
1029 1027 (stat.S_IRUSR, "-r"),
1030 1028 (stat.S_IWUSR, "-w"),
1031 1029 (stat.S_IXUSR, "-x"),
1032 1030 (stat.S_IRGRP, "-r"),
1033 1031 (stat.S_IWGRP, "-w"),
1034 1032 (stat.S_IXGRP, "-x"),
1035 1033 (stat.S_IROTH, "-r"),
1036 1034 (stat.S_IWOTH, "-w"),
1037 1035 (stat.S_IXOTH, "-x"),
1038 1036 ]
1039 1037 return "".join([text[bool(m&bit)] for (bit, text) in data])
1040 1038
1041 1039 modestr = property(getmodestr, None, None, "Access mode as string")
1042 1040
1043 1041 def getblocks(self):
1044 1042 return self.stat().st_blocks
1045 1043 blocks = property(getblocks, None, None, "File size in blocks")
1046 1044
1047 1045 def getblksize(self):
1048 1046 return self.stat().st_blksize
1049 1047 blksize = property(getblksize, None, None, "Filesystem block size")
1050 1048
1051 1049 def getdev(self):
1052 1050 return self.stat().st_dev
1053 1051 dev = property(getdev)
1054 1052
1055 1053 def getnlink(self):
1056 1054 return self.stat().st_nlink
1057 1055 nlink = property(getnlink, None, None, "Number of links")
1058 1056
1059 1057 def getuid(self):
1060 1058 return self.stat().st_uid
1061 1059 uid = property(getuid, None, None, "User id of file owner")
1062 1060
1063 1061 def getgid(self):
1064 1062 return self.stat().st_gid
1065 1063 gid = property(getgid, None, None, "Group id of file owner")
1066 1064
1067 1065 def getowner(self):
1068 1066 stat = self.stat()
1069 1067 try:
1070 1068 return pwd.getpwuid(stat.st_uid).pw_name
1071 1069 except KeyError:
1072 1070 return stat.st_uid
1073 1071 owner = property(getowner, None, None, "Owner name (or id)")
1074 1072
1075 1073 def getgroup(self):
1076 1074 stat = self.stat()
1077 1075 try:
1078 1076 return grp.getgrgid(stat.st_gid).gr_name
1079 1077 except KeyError:
1080 1078 return stat.st_gid
1081 1079 group = property(getgroup, None, None, "Group name (or id)")
1082 1080
1083 1081 def getadate(self):
1084 1082 return datetime.datetime.utcfromtimestamp(self.atime)
1085 1083 adate = property(getadate, None, None, "Access date")
1086 1084
1087 1085 def getcdate(self):
1088 1086 return datetime.datetime.utcfromtimestamp(self.ctime)
1089 1087 cdate = property(getcdate, None, None, "Creation date")
1090 1088
1091 1089 def getmdate(self):
1092 1090 return datetime.datetime.utcfromtimestamp(self.mtime)
1093 1091 mdate = property(getmdate, None, None, "Modification date")
1094 1092
1095 1093 def mimetype(self):
1096 1094 """
1097 1095 Return MIME type guessed from the extension.
1098 1096 """
1099 1097 return mimetypes.guess_type(self.basename())[0]
1100 1098
1101 1099 def encoding(self):
1102 1100 """
1103 1101 Return guessed compression (like "compress" or "gzip").
1104 1102 """
1105 1103 return mimetypes.guess_type(self.basename())[1]
1106 1104
1107 1105 def __repr__(self):
1108 1106 return "ifile(%s)" % path._base.__repr__(self)
1109 1107
1110 1108 if sys.platform == "win32":
1111 1109 defaultattrs = (None, "type", "size", "modestr", "mdate")
1112 1110 else:
1113 1111 defaultattrs = (None, "type", "size", "modestr", "owner", "group", "mdate")
1114 1112
1115 1113 def __xattrs__(self, mode="default"):
1116 1114 if mode == "detail":
1117 1115 return (
1118 1116 "name",
1119 1117 "basename()",
1120 1118 "abspath()",
1121 1119 "realpath()",
1122 1120 "type",
1123 1121 "mode",
1124 1122 "modestr",
1125 1123 "stat()",
1126 1124 "lstat()",
1127 1125 "uid",
1128 1126 "gid",
1129 1127 "owner",
1130 1128 "group",
1131 1129 "dev",
1132 1130 "nlink",
1133 1131 "ctime",
1134 1132 "mtime",
1135 1133 "atime",
1136 1134 "cdate",
1137 1135 "mdate",
1138 1136 "adate",
1139 1137 "size",
1140 1138 "blocks",
1141 1139 "blksize",
1142 1140 "isdir()",
1143 1141 "islink()",
1144 1142 "mimetype()",
1145 1143 "encoding()",
1146 1144 "-listdir()",
1147 1145 "-dirs()",
1148 1146 "-files()",
1149 1147 "-walk()",
1150 1148 "-walkdirs()",
1151 1149 "-walkfiles()",
1152 1150 )
1153 1151 else:
1154 1152 return self.defaultattrs
1155 1153
1156 1154
1157 1155 def xiter_ifile(self):
1158 1156 if self.isdir():
1159 1157 yield (self / os.pardir).abspath()
1160 1158 for child in sorted(self.listdir()):
1161 1159 yield child
1162 1160 else:
1163 1161 f = self.open("rb")
1164 1162 for line in f:
1165 1163 yield line
1166 1164 f.close()
1167 1165 xiter.when_type(ifile)(xiter_ifile)
1168 1166
1169 1167
1170 1168 # We need to implement ``xrepr`` for ``ifile`` as a generic function, because
1171 1169 # otherwise ``xrepr_str`` would kick in.
1172 1170 def xrepr_ifile(self, mode="default"):
1173 1171 try:
1174 1172 if self.isdir():
1175 1173 name = "idir"
1176 1174 style = astyle.style_dir
1177 1175 else:
1178 1176 name = "ifile"
1179 1177 style = astyle.style_file
1180 1178 except IOError:
1181 1179 name = "ifile"
1182 1180 style = astyle.style_default
1183 1181 if mode in ("cell", "header", "footer"):
1184 1182 abspath = repr(path._base(self.normpath()))
1185 1183 if abspath.startswith("u"):
1186 1184 abspath = abspath[2:-1]
1187 1185 else:
1188 1186 abspath = abspath[1:-1]
1189 1187 if mode == "cell":
1190 1188 yield (style, abspath)
1191 1189 else:
1192 1190 yield (style, "%s(%s)" % (name, abspath))
1193 1191 else:
1194 1192 yield (style, repr(self))
1195 1193 xrepr.when_type(ifile)(xrepr_ifile)
1196 1194
1197 1195
1198 1196 class ils(Table):
1199 1197 """
1200 1198 List the current (or a specified) directory.
1201 1199
1202 1200 Examples:
1203 1201
1204 1202 >>> ils
1205 1203 >>> ils("/usr/local/lib/python2.4")
1206 1204 >>> ils("~")
1207 1205 """
1208 1206 def __init__(self, base=os.curdir, dirs=True, files=True):
1209 1207 self.base = os.path.expanduser(base)
1210 1208 self.dirs = dirs
1211 1209 self.files = files
1212 1210
1213 1211 def __iter__(self):
1214 1212 base = ifile(self.base)
1215 1213 yield (base / os.pardir).abspath()
1216 1214 for child in sorted(base.listdir()):
1217 1215 if self.dirs:
1218 1216 if self.files:
1219 1217 yield child
1220 1218 else:
1221 1219 if child.isdir():
1222 1220 yield child
1223 1221 elif self.files:
1224 1222 if not child.isdir():
1225 1223 yield child
1226 1224
1227 1225 def __xrepr__(self, mode="default"):
1228 1226 return xrepr(ifile(self.base), mode)
1229 1227
1230 1228 def __repr__(self):
1231 1229 return "%s.%s(%r)" % \
1232 1230 (self.__class__.__module__, self.__class__.__name__, self.base)
1233 1231
1234 1232
1235 1233 class iglob(Table):
1236 1234 """
1237 1235 List all files and directories matching a specified pattern.
1238 1236 (See ``glob.glob()`` for more info.).
1239 1237
1240 1238 Examples:
1241 1239
1242 1240 >>> iglob("*.py")
1243 1241 """
1244 1242 def __init__(self, glob):
1245 1243 self.glob = glob
1246 1244
1247 1245 def __iter__(self):
1248 1246 for name in glob.glob(self.glob):
1249 1247 yield ifile(name)
1250 1248
1251 1249 def __xrepr__(self, mode="default"):
1252 1250 if mode == "header" or mode == "footer" or mode == "cell":
1253 1251 yield (astyle.style_default,
1254 1252 "%s(%r)" % (self.__class__.__name__, self.glob))
1255 1253 else:
1256 1254 yield (astyle.style_default, repr(self))
1257 1255
1258 1256 def __repr__(self):
1259 1257 return "%s.%s(%r)" % \
1260 1258 (self.__class__.__module__, self.__class__.__name__, self.glob)
1261 1259
1262 1260
1263 1261 class iwalk(Table):
1264 1262 """
1265 1263 List all files and directories in a directory and it's subdirectory.
1266 1264
1267 1265 >>> iwalk
1268 1266 >>> iwalk("/usr/local/lib/python2.4")
1269 1267 >>> iwalk("~")
1270 1268 """
1271 1269 def __init__(self, base=os.curdir, dirs=True, files=True):
1272 1270 self.base = os.path.expanduser(base)
1273 1271 self.dirs = dirs
1274 1272 self.files = files
1275 1273
1276 1274 def __iter__(self):
1277 1275 for (dirpath, dirnames, filenames) in os.walk(self.base):
1278 1276 if self.dirs:
1279 1277 for name in sorted(dirnames):
1280 1278 yield ifile(os.path.join(dirpath, name))
1281 1279 if self.files:
1282 1280 for name in sorted(filenames):
1283 1281 yield ifile(os.path.join(dirpath, name))
1284 1282
1285 1283 def __xrepr__(self, mode="default"):
1286 1284 if mode == "header" or mode == "footer" or mode == "cell":
1287 1285 yield (astyle.style_default,
1288 1286 "%s(%r)" % (self.__class__.__name__, self.base))
1289 1287 else:
1290 1288 yield (astyle.style_default, repr(self))
1291 1289
1292 1290 def __repr__(self):
1293 1291 return "%s.%s(%r)" % \
1294 1292 (self.__class__.__module__, self.__class__.__name__, self.base)
1295 1293
1296 1294
1297 1295 class ipwdentry(object):
1298 1296 """
1299 1297 ``ipwdentry`` objects encapsulate entries in the Unix user account and
1300 1298 password database.
1301 1299 """
1302 1300 def __init__(self, id):
1303 1301 self._id = id
1304 1302 self._entry = None
1305 1303
1306 1304 def __eq__(self, other):
1307 1305 return self.__class__ is other.__class__ and self._id == other._id
1308 1306
1309 1307 def __ne__(self, other):
1310 1308 return self.__class__ is not other.__class__ or self._id != other._id
1311 1309
1312 1310 def _getentry(self):
1313 1311 if self._entry is None:
1314 1312 if isinstance(self._id, basestring):
1315 1313 self._entry = pwd.getpwnam(self._id)
1316 1314 else:
1317 1315 self._entry = pwd.getpwuid(self._id)
1318 1316 return self._entry
1319 1317
1320 1318 def getname(self):
1321 1319 if isinstance(self._id, basestring):
1322 1320 return self._id
1323 1321 else:
1324 1322 return self._getentry().pw_name
1325 1323 name = property(getname, None, None, "User name")
1326 1324
1327 1325 def getpasswd(self):
1328 1326 return self._getentry().pw_passwd
1329 1327 passwd = property(getpasswd, None, None, "Password")
1330 1328
1331 1329 def getuid(self):
1332 1330 if isinstance(self._id, basestring):
1333 1331 return self._getentry().pw_uid
1334 1332 else:
1335 1333 return self._id
1336 1334 uid = property(getuid, None, None, "User id")
1337 1335
1338 1336 def getgid(self):
1339 1337 return self._getentry().pw_gid
1340 1338 gid = property(getgid, None, None, "Primary group id")
1341 1339
1342 1340 def getgroup(self):
1343 1341 return igrpentry(self.gid)
1344 1342 group = property(getgroup, None, None, "Group")
1345 1343
1346 1344 def getgecos(self):
1347 1345 return self._getentry().pw_gecos
1348 1346 gecos = property(getgecos, None, None, "Information (e.g. full user name)")
1349 1347
1350 1348 def getdir(self):
1351 1349 return self._getentry().pw_dir
1352 1350 dir = property(getdir, None, None, "$HOME directory")
1353 1351
1354 1352 def getshell(self):
1355 1353 return self._getentry().pw_shell
1356 1354 shell = property(getshell, None, None, "Login shell")
1357 1355
1358 1356 def __xattrs__(self, mode="default"):
1359 1357 return ("name", "passwd", "uid", "gid", "gecos", "dir", "shell")
1360 1358
1361 1359 def __repr__(self):
1362 1360 return "%s.%s(%r)" % \
1363 1361 (self.__class__.__module__, self.__class__.__name__, self._id)
1364 1362
1365 1363
1366 1364 class ipwd(Table):
1367 1365 """
1368 1366 List all entries in the Unix user account and password database.
1369 1367
1370 1368 Example:
1371 1369
1372 1370 >>> ipwd | isort("uid")
1373 1371 """
1374 1372 def __iter__(self):
1375 1373 for entry in pwd.getpwall():
1376 1374 yield ipwdentry(entry.pw_name)
1377 1375
1378 1376 def __xrepr__(self, mode="default"):
1379 1377 if mode == "header" or mode == "footer" or mode == "cell":
1380 1378 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1381 1379 else:
1382 1380 yield (astyle.style_default, repr(self))
1383 1381
1384 1382
1385 1383 class igrpentry(object):
1386 1384 """
1387 1385 ``igrpentry`` objects encapsulate entries in the Unix group database.
1388 1386 """
1389 1387 def __init__(self, id):
1390 1388 self._id = id
1391 1389 self._entry = None
1392 1390
1393 1391 def __eq__(self, other):
1394 1392 return self.__class__ is other.__class__ and self._id == other._id
1395 1393
1396 1394 def __ne__(self, other):
1397 1395 return self.__class__ is not other.__class__ or self._id != other._id
1398 1396
1399 1397 def _getentry(self):
1400 1398 if self._entry is None:
1401 1399 if isinstance(self._id, basestring):
1402 1400 self._entry = grp.getgrnam(self._id)
1403 1401 else:
1404 1402 self._entry = grp.getgrgid(self._id)
1405 1403 return self._entry
1406 1404
1407 1405 def getname(self):
1408 1406 if isinstance(self._id, basestring):
1409 1407 return self._id
1410 1408 else:
1411 1409 return self._getentry().gr_name
1412 1410 name = property(getname, None, None, "Group name")
1413 1411
1414 1412 def getpasswd(self):
1415 1413 return self._getentry().gr_passwd
1416 1414 passwd = property(getpasswd, None, None, "Password")
1417 1415
1418 1416 def getgid(self):
1419 1417 if isinstance(self._id, basestring):
1420 1418 return self._getentry().gr_gid
1421 1419 else:
1422 1420 return self._id
1423 1421 gid = property(getgid, None, None, "Group id")
1424 1422
1425 1423 def getmem(self):
1426 1424 return self._getentry().gr_mem
1427 1425 mem = property(getmem, None, None, "Members")
1428 1426
1429 1427 def __xattrs__(self, mode="default"):
1430 1428 return ("name", "passwd", "gid", "mem")
1431 1429
1432 1430 def __xrepr__(self, mode="default"):
1433 1431 if mode == "header" or mode == "footer" or mode == "cell":
1434 1432 yield (astyle.style_default, "group ")
1435 1433 try:
1436 1434 yield (astyle.style_default, self.name)
1437 1435 except KeyError:
1438 1436 if isinstance(self._id, basestring):
1439 1437 yield (astyle.style_default, self.name_id)
1440 1438 else:
1441 1439 yield (astyle.style_type_number, str(self._id))
1442 1440 else:
1443 1441 yield (astyle.style_default, repr(self))
1444 1442
1445 1443 def __iter__(self):
1446 1444 for member in self.mem:
1447 1445 yield ipwdentry(member)
1448 1446
1449 1447 def __repr__(self):
1450 1448 return "%s.%s(%r)" % \
1451 1449 (self.__class__.__module__, self.__class__.__name__, self._id)
1452 1450
1453 1451
1454 1452 class igrp(Table):
1455 1453 """
1456 1454 This ``Table`` lists all entries in the Unix group database.
1457 1455 """
1458 1456 def __iter__(self):
1459 1457 for entry in grp.getgrall():
1460 1458 yield igrpentry(entry.gr_name)
1461 1459
1462 1460 def __xrepr__(self, mode="default"):
1463 1461 if mode == "header" or mode == "footer":
1464 1462 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1465 1463 else:
1466 1464 yield (astyle.style_default, repr(self))
1467 1465
1468 1466
1469 1467 class Fields(object):
1470 1468 def __init__(self, fieldnames, **fields):
1471 1469 self.__fieldnames = [upgradexattr(fieldname) for fieldname in fieldnames]
1472 1470 for (key, value) in fields.iteritems():
1473 1471 setattr(self, key, value)
1474 1472
1475 1473 def __xattrs__(self, mode="default"):
1476 1474 return self.__fieldnames
1477 1475
1478 1476 def __xrepr__(self, mode="default"):
1479 1477 yield (-1, False)
1480 1478 if mode == "header" or mode == "cell":
1481 1479 yield (astyle.style_default, self.__class__.__name__)
1482 1480 yield (astyle.style_default, "(")
1483 1481 for (i, f) in enumerate(self.__fieldnames):
1484 1482 if i:
1485 1483 yield (astyle.style_default, ", ")
1486 1484 yield (astyle.style_default, f.name())
1487 1485 yield (astyle.style_default, "=")
1488 1486 for part in xrepr(getattr(self, f), "default"):
1489 1487 yield part
1490 1488 yield (astyle.style_default, ")")
1491 1489 elif mode == "footer":
1492 1490 yield (astyle.style_default, self.__class__.__name__)
1493 1491 yield (astyle.style_default, "(")
1494 1492 for (i, f) in enumerate(self.__fieldnames):
1495 1493 if i:
1496 1494 yield (astyle.style_default, ", ")
1497 1495 yield (astyle.style_default, f.name())
1498 1496 yield (astyle.style_default, ")")
1499 1497 else:
1500 1498 yield (astyle.style_default, repr(self))
1501 1499
1502 1500
1503 1501 class FieldTable(Table, list):
1504 1502 def __init__(self, *fields):
1505 1503 Table.__init__(self)
1506 1504 list.__init__(self)
1507 1505 self.fields = fields
1508 1506
1509 1507 def add(self, **fields):
1510 1508 self.append(Fields(self.fields, **fields))
1511 1509
1512 1510 def __xrepr__(self, mode="default"):
1513 1511 yield (-1, False)
1514 1512 if mode == "header" or mode == "footer":
1515 1513 yield (astyle.style_default, self.__class__.__name__)
1516 1514 yield (astyle.style_default, "(")
1517 1515 for (i, f) in enumerate(self.__fieldnames):
1518 1516 if i:
1519 1517 yield (astyle.style_default, ", ")
1520 1518 yield (astyle.style_default, f)
1521 1519 yield (astyle.style_default, ")")
1522 1520 else:
1523 1521 yield (astyle.style_default, repr(self))
1524 1522
1525 1523 def __repr__(self):
1526 1524 return "<%s.%s object with fields=%r at 0x%x>" % \
1527 1525 (self.__class__.__module__, self.__class__.__name__,
1528 1526 ", ".join(map(repr, self.fields)), id(self))
1529 1527
1530 1528
1531 1529 class List(list):
1532 1530 def __xattrs__(self, mode="default"):
1533 1531 return xrange(len(self))
1534 1532
1535 1533 def __xrepr__(self, mode="default"):
1536 1534 yield (-1, False)
1537 1535 if mode == "header" or mode == "cell" or mode == "footer" or mode == "default":
1538 1536 yield (astyle.style_default, self.__class__.__name__)
1539 1537 yield (astyle.style_default, "(")
1540 1538 for (i, item) in enumerate(self):
1541 1539 if i:
1542 1540 yield (astyle.style_default, ", ")
1543 1541 for part in xrepr(item, "default"):
1544 1542 yield part
1545 1543 yield (astyle.style_default, ")")
1546 1544 else:
1547 1545 yield (astyle.style_default, repr(self))
1548 1546
1549 1547
1550 1548 class ienv(Table):
1551 1549 """
1552 1550 List environment variables.
1553 1551
1554 1552 Example:
1555 1553
1556 1554 >>> ienv
1557 1555 """
1558 1556
1559 1557 def __iter__(self):
1560 1558 fields = ("key", "value")
1561 1559 for (key, value) in os.environ.iteritems():
1562 1560 yield Fields(fields, key=key, value=value)
1563 1561
1564 1562 def __xrepr__(self, mode="default"):
1565 1563 if mode == "header" or mode == "cell":
1566 1564 yield (astyle.style_default, "%s()" % self.__class__.__name__)
1567 1565 else:
1568 1566 yield (astyle.style_default, repr(self))
1569 1567
1570 1568
1571 1569 class ihist(Table):
1572 1570 """
1573 1571 IPython input history
1574 1572
1575 1573 Example:
1576 1574
1577 1575 >>> ihist
1578 1576 >>> ihist(True) (raw mode)
1579 1577 """
1580 1578 def __init__(self, raw=True):
1581 1579 self.raw = raw
1582 1580
1583 1581 def __iter__(self):
1584 1582 api = ipapi.get()
1585 1583 if self.raw:
1586 1584 for line in api.IP.input_hist_raw:
1587 1585 yield line.rstrip("\n")
1588 1586 else:
1589 1587 for line in api.IP.input_hist:
1590 1588 yield line.rstrip("\n")
1591 1589
1592 1590
1593 1591 class icsv(Pipe):
1594 1592 """
1595 1593 This ``Pipe`` lists turn the input (with must be a pipe outputting lines
1596 1594 or an ``ifile``) into lines of CVS columns.
1597 1595 """
1598 1596 def __init__(self, **csvargs):
1599 1597 """
1600 1598 Create an ``icsv`` object. ``cvsargs`` will be passed through as
1601 1599 keyword arguments to ``cvs.reader()``.
1602 1600 """
1603 1601 self.csvargs = csvargs
1604 1602
1605 1603 def __iter__(self):
1606 1604 input = self.input
1607 1605 if isinstance(input, ifile):
1608 1606 input = input.open("rb")
1609 1607 reader = csv.reader(input, **self.csvargs)
1610 1608 for line in reader:
1611 1609 yield List(line)
1612 1610
1613 1611 def __xrepr__(self, mode="default"):
1614 1612 yield (-1, False)
1615 1613 if mode == "header" or mode == "footer":
1616 1614 input = getattr(self, "input", None)
1617 1615 if input is not None:
1618 1616 for part in xrepr(input, mode):
1619 1617 yield part
1620 1618 yield (astyle.style_default, " | ")
1621 1619 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1622 1620 for (i, (name, value)) in enumerate(self.csvargs.iteritems()):
1623 1621 if i:
1624 1622 yield (astyle.style_default, ", ")
1625 1623 yield (astyle.style_default, name)
1626 1624 yield (astyle.style_default, "=")
1627 1625 for part in xrepr(value, "default"):
1628 1626 yield part
1629 1627 yield (astyle.style_default, ")")
1630 1628 else:
1631 1629 yield (astyle.style_default, repr(self))
1632 1630
1633 1631 def __repr__(self):
1634 1632 args = ", ".join(["%s=%r" % item for item in self.csvargs.iteritems()])
1635 1633 return "<%s.%s %s at 0x%x>" % \
1636 1634 (self.__class__.__module__, self.__class__.__name__, args, id(self))
1637 1635
1638 1636
1639 1637 class ix(Table):
1640 1638 """
1641 1639 Execute a system command and list its output as lines
1642 1640 (similar to ``os.popen()``).
1643 1641
1644 1642 Examples:
1645 1643
1646 1644 >>> ix("ps x")
1647 1645 >>> ix("find .") | ifile
1648 1646 """
1649 1647 def __init__(self, cmd):
1650 1648 self.cmd = cmd
1651 1649 self._pipeout = None
1652 1650
1653 1651 def __iter__(self):
1654 1652 (_pipein, self._pipeout) = os.popen4(self.cmd)
1655 1653 _pipein.close()
1656 1654 for l in self._pipeout:
1657 1655 yield l.rstrip("\r\n")
1658 1656 self._pipeout.close()
1659 1657 self._pipeout = None
1660 1658
1661 1659 def __del__(self):
1662 1660 if self._pipeout is not None and not self._pipeout.closed:
1663 1661 self._pipeout.close()
1664 1662 self._pipeout = None
1665 1663
1666 1664 def __xrepr__(self, mode="default"):
1667 1665 if mode == "header" or mode == "footer":
1668 1666 yield (astyle.style_default,
1669 1667 "%s(%r)" % (self.__class__.__name__, self.cmd))
1670 1668 else:
1671 1669 yield (astyle.style_default, repr(self))
1672 1670
1673 1671 def __repr__(self):
1674 1672 return "%s.%s(%r)" % \
1675 1673 (self.__class__.__module__, self.__class__.__name__, self.cmd)
1676 1674
1677 1675
1678 1676 class ifilter(Pipe):
1679 1677 """
1680 1678 Filter an input pipe. Only objects where an expression evaluates to true
1681 1679 (and doesn't raise an exception) are listed.
1682 1680
1683 1681 Examples:
1684 1682
1685 1683 >>> ils | ifilter("_.isfile() and size>1000")
1686 1684 >>> igrp | ifilter("len(mem)")
1687 1685 >>> sys.modules | ifilter(lambda _:_.value is not None)
1688 1686 """
1689 1687
1690 1688 def __init__(self, expr, globals=None, errors="raiseifallfail"):
1691 1689 """
1692 1690 Create an ``ifilter`` object. ``expr`` can be a callable or a string
1693 1691 containing an expression. ``globals`` will be used as the global
1694 1692 namespace for calling string expressions (defaulting to IPython's
1695 1693 user namespace). ``errors`` specifies how exception during evaluation
1696 1694 of ``expr`` are handled:
1697 1695
1698 1696 * ``drop``: drop all items that have errors;
1699 1697
1700 1698 * ``keep``: keep all items that have errors;
1701 1699
1702 1700 * ``keeperror``: keep the exception of all items that have errors;
1703 1701
1704 1702 * ``raise``: raise the exception;
1705 1703
1706 1704 * ``raiseifallfail``: raise the first exception if all items have errors;
1707 1705 otherwise drop those with errors (this is the default).
1708 1706 """
1709 1707 self.expr = expr
1710 1708 self.globals = globals
1711 1709 self.errors = errors
1712 1710
1713 1711 def __iter__(self):
1714 1712 if callable(self.expr):
1715 1713 test = self.expr
1716 1714 else:
1717 1715 g = getglobals(self.globals)
1718 1716 expr = compile(self.expr, "ipipe-expression", "eval")
1719 1717 def test(item):
1720 1718 return eval(expr, g, AttrNamespace(item))
1721 1719
1722 1720 ok = 0
1723 1721 exc_info = None
1724 1722 for item in xiter(self.input):
1725 1723 try:
1726 1724 if test(item):
1727 1725 yield item
1728 1726 ok += 1
1729 1727 except (KeyboardInterrupt, SystemExit):
1730 1728 raise
1731 1729 except Exception, exc:
1732 1730 if self.errors == "drop":
1733 1731 pass # Ignore errors
1734 1732 elif self.errors == "keep":
1735 1733 yield item
1736 1734 elif self.errors == "keeperror":
1737 1735 yield exc
1738 1736 elif self.errors == "raise":
1739 1737 raise
1740 1738 elif self.errors == "raiseifallfail":
1741 1739 if exc_info is None:
1742 1740 exc_info = sys.exc_info()
1743 1741 if not ok and exc_info is not None:
1744 1742 raise exc_info[0], exc_info[1], exc_info[2]
1745 1743
1746 1744 def __xrepr__(self, mode="default"):
1747 1745 if mode == "header" or mode == "footer":
1748 1746 input = getattr(self, "input", None)
1749 1747 if input is not None:
1750 1748 for part in xrepr(input, mode):
1751 1749 yield part
1752 1750 yield (astyle.style_default, " | ")
1753 1751 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1754 1752 for part in xrepr(self.expr, "default"):
1755 1753 yield part
1756 1754 yield (astyle.style_default, ")")
1757 1755 else:
1758 1756 yield (astyle.style_default, repr(self))
1759 1757
1760 1758 def __repr__(self):
1761 1759 return "<%s.%s expr=%r at 0x%x>" % \
1762 1760 (self.__class__.__module__, self.__class__.__name__,
1763 1761 self.expr, id(self))
1764 1762
1765 1763
1766 1764 class ieval(Pipe):
1767 1765 """
1768 1766 Evaluate an expression for each object in the input pipe.
1769 1767
1770 1768 Examples:
1771 1769
1772 1770 >>> ils | ieval("_.abspath()")
1773 1771 >>> sys.path | ieval(ifile)
1774 1772 """
1775 1773
1776 1774 def __init__(self, expr, globals=None, errors="raiseifallfail"):
1777 1775 """
1778 1776 Create an ``ieval`` object. ``expr`` can be a callable or a string
1779 1777 containing an expression. For the meaning of ``globals`` and
1780 1778 ``errors`` see ``ifilter``.
1781 1779 """
1782 1780 self.expr = expr
1783 1781 self.globals = globals
1784 1782 self.errors = errors
1785 1783
1786 1784 def __iter__(self):
1787 1785 if callable(self.expr):
1788 1786 do = self.expr
1789 1787 else:
1790 1788 g = getglobals(self.globals)
1791 1789 expr = compile(self.expr, "ipipe-expression", "eval")
1792 1790 def do(item):
1793 1791 return eval(expr, g, AttrNamespace(item))
1794 1792
1795 1793 ok = 0
1796 1794 exc_info = None
1797 1795 for item in xiter(self.input):
1798 1796 try:
1799 1797 yield do(item)
1800 1798 except (KeyboardInterrupt, SystemExit):
1801 1799 raise
1802 1800 except Exception, exc:
1803 1801 if self.errors == "drop":
1804 1802 pass # Ignore errors
1805 1803 elif self.errors == "keep":
1806 1804 yield item
1807 1805 elif self.errors == "keeperror":
1808 1806 yield exc
1809 1807 elif self.errors == "raise":
1810 1808 raise
1811 1809 elif self.errors == "raiseifallfail":
1812 1810 if exc_info is None:
1813 1811 exc_info = sys.exc_info()
1814 1812 if not ok and exc_info is not None:
1815 1813 raise exc_info[0], exc_info[1], exc_info[2]
1816 1814
1817 1815 def __xrepr__(self, mode="default"):
1818 1816 if mode == "header" or mode == "footer":
1819 1817 input = getattr(self, "input", None)
1820 1818 if input is not None:
1821 1819 for part in xrepr(input, mode):
1822 1820 yield part
1823 1821 yield (astyle.style_default, " | ")
1824 1822 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1825 1823 for part in xrepr(self.expr, "default"):
1826 1824 yield part
1827 1825 yield (astyle.style_default, ")")
1828 1826 else:
1829 1827 yield (astyle.style_default, repr(self))
1830 1828
1831 1829 def __repr__(self):
1832 1830 return "<%s.%s expr=%r at 0x%x>" % \
1833 1831 (self.__class__.__module__, self.__class__.__name__,
1834 1832 self.expr, id(self))
1835 1833
1836 1834
1837 1835 class ienum(Pipe):
1838 1836 """
1839 1837 Enumerate the input pipe (i.e. wrap each input object in an object
1840 1838 with ``index`` and ``object`` attributes).
1841 1839
1842 1840 Examples:
1843 1841
1844 1842 >>> xrange(20) | ieval("_,_*_") | ienum | ifilter("index % 2 == 0") | ieval("object")
1845 1843 """
1846 1844 def __iter__(self):
1847 1845 fields = ("index", "object")
1848 1846 for (index, object) in enumerate(xiter(self.input)):
1849 1847 yield Fields(fields, index=index, object=object)
1850 1848
1851 1849
1852 1850 class isort(Pipe):
1853 1851 """
1854 1852 Sorts the input pipe.
1855 1853
1856 1854 Examples:
1857 1855
1858 1856 >>> ils | isort("size")
1859 1857 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
1860 1858 """
1861 1859
1862 1860 def __init__(self, key=None, globals=None, reverse=False):
1863 1861 """
1864 1862 Create an ``isort`` object. ``key`` can be a callable or a string
1865 1863 containing an expression (or ``None`` in which case the items
1866 1864 themselves will be sorted). If ``reverse`` is true the sort order
1867 1865 will be reversed. For the meaning of ``globals`` see ``ifilter``.
1868 1866 """
1869 1867 self.key = key
1870 1868 self.globals = globals
1871 1869 self.reverse = reverse
1872 1870
1873 1871 def __iter__(self):
1874 1872 if self.key is None:
1875 1873 items = sorted(xiter(self.input), reverse=self.reverse)
1876 1874 elif callable(self.key):
1877 1875 items = sorted(xiter(self.input), key=self.key, reverse=self.reverse)
1878 1876 else:
1879 1877 g = getglobals(self.globals)
1880 1878 key = compile(self.key, "ipipe-expression", "eval")
1881 1879 def realkey(item):
1882 1880 return eval(key, g, AttrNamespace(item))
1883 1881 items = sorted(xiter(self.input), key=realkey, reverse=self.reverse)
1884 1882 for item in items:
1885 1883 yield item
1886 1884
1887 1885 def __xrepr__(self, mode="default"):
1888 1886 if mode == "header" or mode == "footer":
1889 1887 input = getattr(self, "input", None)
1890 1888 if input is not None:
1891 1889 for part in xrepr(input, mode):
1892 1890 yield part
1893 1891 yield (astyle.style_default, " | ")
1894 1892 yield (astyle.style_default, "%s(" % self.__class__.__name__)
1895 1893 for part in xrepr(self.key, "default"):
1896 1894 yield part
1897 1895 if self.reverse:
1898 1896 yield (astyle.style_default, ", ")
1899 1897 for part in xrepr(True, "default"):
1900 1898 yield part
1901 1899 yield (astyle.style_default, ")")
1902 1900 else:
1903 1901 yield (astyle.style_default, repr(self))
1904 1902
1905 1903 def __repr__(self):
1906 1904 return "<%s.%s key=%r reverse=%r at 0x%x>" % \
1907 1905 (self.__class__.__module__, self.__class__.__name__,
1908 1906 self.key, self.reverse, id(self))
1909 1907
1910 1908
1911 1909 tab = 3 # for expandtabs()
1912 1910
1913 1911 def _format(field):
1914 1912 if isinstance(field, str):
1915 1913 text = repr(field.expandtabs(tab))[1:-1]
1916 1914 elif isinstance(field, unicode):
1917 1915 text = repr(field.expandtabs(tab))[2:-1]
1918 1916 elif isinstance(field, datetime.datetime):
1919 1917 # Don't use strftime() here, as this requires year >= 1900
1920 1918 text = "%04d-%02d-%02d %02d:%02d:%02d.%06d" % \
1921 1919 (field.year, field.month, field.day,
1922 1920 field.hour, field.minute, field.second, field.microsecond)
1923 1921 elif isinstance(field, datetime.date):
1924 1922 text = "%04d-%02d-%02d" % (field.year, field.month, field.day)
1925 1923 else:
1926 1924 text = repr(field)
1927 1925 return text
1928 1926
1929 1927
1930 1928 class Display(object):
1931 1929 class __metaclass__(type):
1932 1930 def __ror__(self, input):
1933 1931 return input | self()
1934 1932
1933 def __init__(self, input=None):
1934 self.input = input
1935
1935 1936 def __ror__(self, input):
1936 1937 self.input = input
1937 1938 return self
1938 1939
1939 1940 def display(self):
1940 1941 pass
1941 1942
1942 1943
1943 1944 class iless(Display):
1944 1945 cmd = "less --quit-if-one-screen --LONG-PROMPT --LINE-NUMBERS --chop-long-lines --shift=8 --RAW-CONTROL-CHARS"
1945 1946
1946 1947 def display(self):
1947 1948 try:
1948 1949 pager = os.popen(self.cmd, "w")
1949 1950 try:
1950 1951 for item in xiter(self.input):
1951 1952 first = False
1952 1953 for attr in xattrs(item, "default"):
1953 1954 if first:
1954 1955 first = False
1955 1956 else:
1956 1957 pager.write(" ")
1957 1958 attr = upgradexattr(attr)
1958 1959 if not isinstance(attr, SelfDescriptor):
1959 1960 pager.write(attr.name())
1960 1961 pager.write("=")
1961 1962 pager.write(str(attr.value(item)))
1962 1963 pager.write("\n")
1963 1964 finally:
1964 1965 pager.close()
1965 1966 except Exception, exc:
1966 1967 print "%s: %s" % (exc.__class__.__name__, str(exc))
1967 1968
1968 1969
1969 1970 class _RedirectIO(object):
1970 1971 def __init__(self,*args,**kwargs):
1971 1972 """
1972 1973 Map the system output streams to self.
1973 1974 """
1974 1975 self.stream = StringIO.StringIO()
1975 1976 self.stdout = sys.stdout
1976 1977 sys.stdout = self
1977 1978 self.stderr = sys.stderr
1978 1979 sys.stderr = self
1979 1980
1980 1981 def write(self, text):
1981 1982 """
1982 1983 Write both to screen and to self.
1983 1984 """
1984 1985 self.stream.write(text)
1985 1986 self.stdout.write(text)
1986 1987 if "\n" in text:
1987 1988 self.stdout.flush()
1988 1989
1989 1990 def writelines(self, lines):
1990 1991 """
1991 1992 Write lines both to screen and to self.
1992 1993 """
1993 1994 self.stream.writelines(lines)
1994 1995 self.stdout.writelines(lines)
1995 1996 self.stdout.flush()
1996 1997
1997 1998 def restore(self):
1998 1999 """
1999 2000 Restore the default system streams.
2000 2001 """
2001 2002 self.stdout.flush()
2002 2003 self.stderr.flush()
2003 2004 sys.stdout = self.stdout
2004 2005 sys.stderr = self.stderr
2005 2006
2006 2007
2007 2008 class icap(Table):
2008 2009 """
2009 2010 Execute a python string and capture any output to stderr/stdout.
2010 2011
2011 2012 Examples:
2012 2013
2013 2014 >>> import time
2014 2015 >>> icap("for i in range(10): print i, time.sleep(0.1)")
2015 2016
2016 2017 """
2017 2018 def __init__(self, expr, globals=None):
2018 2019 self.expr = expr
2019 2020 self.globals = globals
2020 2021 log = _RedirectIO()
2021 2022 try:
2022 2023 exec(expr, getglobals(globals))
2023 2024 finally:
2024 2025 log.restore()
2025 2026 self.stream = log.stream
2026 2027
2027 2028 def __iter__(self):
2028 2029 self.stream.seek(0)
2029 2030 for line in self.stream:
2030 2031 yield line.rstrip("\r\n")
2031 2032
2032 2033 def __xrepr__(self, mode="default"):
2033 2034 if mode == "header" or mode == "footer":
2034 2035 yield (astyle.style_default,
2035 2036 "%s(%r)" % (self.__class__.__name__, self.expr))
2036 2037 else:
2037 2038 yield (astyle.style_default, repr(self))
2038 2039
2039 2040 def __repr__(self):
2040 2041 return "%s.%s(%r)" % \
2041 2042 (self.__class__.__module__, self.__class__.__name__, self.expr)
2042 2043
2043 2044
2044 2045 def xformat(value, mode, maxlength):
2045 2046 align = None
2046 2047 full = True
2047 2048 width = 0
2048 2049 text = astyle.Text()
2049 2050 for (style, part) in xrepr(value, mode):
2050 2051 # only consider the first result
2051 2052 if align is None:
2052 2053 if isinstance(style, int):
2053 2054 # (style, text) really is (alignment, stop)
2054 2055 align = style
2055 2056 full = part
2056 2057 continue
2057 2058 else:
2058 2059 align = -1
2059 2060 full = True
2060 2061 if not isinstance(style, int):
2061 2062 text.append((style, part))
2062 2063 width += len(part)
2063 2064 if width >= maxlength and not full:
2064 2065 text.append((astyle.style_ellisis, "..."))
2065 2066 width += 3
2066 2067 break
2067 2068 if align is None: # default to left alignment
2068 2069 align = -1
2069 2070 return (align, width, text)
2070 2071
2071 2072
2073
2074 import astyle
2075
2072 2076 class idump(Display):
2073 2077 # The approximate maximum length of a column entry
2074 2078 maxattrlength = 200
2075 2079
2076 2080 # Style for column names
2077 2081 style_header = astyle.Style.fromstr("white:black:bold")
2078 2082
2079 def __init__(self, *attrs):
2083 def __init__(self, input=None, *attrs):
2084 Display.__init__(self, input)
2080 2085 self.attrs = [upgradexattr(attr) for attr in attrs]
2081 2086 self.headerpadchar = " "
2082 2087 self.headersepchar = "|"
2083 2088 self.datapadchar = " "
2084 2089 self.datasepchar = "|"
2085 2090
2086 2091 def display(self):
2087 2092 stream = genutils.Term.cout
2088 2093 allattrs = []
2089 2094 attrset = set()
2090 2095 colwidths = {}
2091 2096 rows = []
2092 2097 for item in xiter(self.input):
2093 2098 row = {}
2094 2099 attrs = self.attrs
2095 2100 if not attrs:
2096 2101 attrs = xattrs(item, "default")
2097 2102 for attr in attrs:
2098 2103 if attr not in attrset:
2099 2104 allattrs.append(attr)
2100 2105 attrset.add(attr)
2101 2106 colwidths[attr] = len(attr.name())
2102 2107 try:
2103 2108 value = attr.value(item)
2104 2109 except (KeyboardInterrupt, SystemExit):
2105 2110 raise
2106 2111 except Exception, exc:
2107 2112 value = exc
2108 2113 (align, width, text) = xformat(value, "cell", self.maxattrlength)
2109 2114 colwidths[attr] = max(colwidths[attr], width)
2110 2115 # remember alignment, length and colored parts
2111 2116 row[attr] = (align, width, text)
2112 2117 rows.append(row)
2113 2118
2114 2119 stream.write("\n")
2115 2120 for (i, attr) in enumerate(allattrs):
2116 2121 attrname = attr.name()
2117 2122 self.style_header(attrname).write(stream)
2118 2123 spc = colwidths[attr] - len(attrname)
2119 2124 if i < len(colwidths)-1:
2120 2125 stream.write(self.headerpadchar*spc)
2121 2126 stream.write(self.headersepchar)
2122 2127 stream.write("\n")
2123 2128
2124 2129 for row in rows:
2125 2130 for (i, attr) in enumerate(allattrs):
2126 2131 (align, width, text) = row[attr]
2127 2132 spc = colwidths[attr] - width
2128 2133 if align == -1:
2129 2134 text.write(stream)
2130 2135 if i < len(colwidths)-1:
2131 2136 stream.write(self.datapadchar*spc)
2132 2137 elif align == 0:
2133 2138 spc = colwidths[attr] - width
2134 2139 spc1 = spc//2
2135 2140 spc2 = spc-spc1
2136 2141 stream.write(self.datapadchar*spc1)
2137 2142 text.write(stream)
2138 2143 if i < len(colwidths)-1:
2139 2144 stream.write(self.datapadchar*spc2)
2140 2145 else:
2141 2146 stream.write(self.datapadchar*spc)
2142 2147 text.write(stream)
2143 2148 if i < len(colwidths)-1:
2144 2149 stream.write(self.datasepchar)
2145 2150 stream.write("\n")
2146 2151
2147 2152
2148 2153 class AttributeDetail(Table):
2149 2154 """
2150 2155 ``AttributeDetail`` objects are use for displaying a detailed list of object
2151 2156 attributes.
2152 2157 """
2153 2158 def __init__(self, object, descriptor):
2154 2159 self.object = object
2155 2160 self.descriptor = descriptor
2156 2161
2157 2162 def __iter__(self):
2158 2163 return self.descriptor.iter(self.object)
2159 2164
2160 2165 def name(self):
2161 2166 return self.descriptor.name()
2162 2167
2163 2168 def attrtype(self):
2164 2169 return self.descriptor.attrtype(self.object)
2165 2170
2166 2171 def valuetype(self):
2167 2172 return self.descriptor.valuetype(self.object)
2168 2173
2169 2174 def doc(self):
2170 2175 return self.descriptor.doc(self.object)
2171 2176
2172 2177 def shortdoc(self):
2173 2178 return self.descriptor.shortdoc(self.object)
2174 2179
2175 2180 def value(self):
2176 2181 return self.descriptor.value(self.object)
2177 2182
2178 2183 def __xattrs__(self, mode="default"):
2179 2184 attrs = ("name()", "attrtype()", "valuetype()", "value()", "shortdoc()")
2180 2185 if mode == "detail":
2181 2186 attrs += ("doc()",)
2182 2187 return attrs
2183 2188
2184 2189 def __xrepr__(self, mode="default"):
2185 2190 yield (-1, True)
2186 2191 valuetype = self.valuetype()
2187 2192 if valuetype is not noitem:
2188 2193 for part in xrepr(valuetype):
2189 2194 yield part
2190 2195 yield (astyle.style_default, " ")
2191 2196 yield (astyle.style_default, self.attrtype())
2192 2197 yield (astyle.style_default, " ")
2193 2198 yield (astyle.style_default, self.name())
2194 2199 yield (astyle.style_default, " of ")
2195 2200 for part in xrepr(self.object):
2196 2201 yield part
2197 2202
2198 2203
2199 2204 try:
2200 2205 from ibrowse import ibrowse
2201 2206 except ImportError:
2202 2207 # No curses (probably Windows)
2203 2208 try:
2204 2209 from igrid import igrid
2205 2210 except ImportError:
2206 2211 # no wx eithevn do => use ``idump`` as the default display.
2207 2212 defaultdisplay = idump
2208 2213 else:
2209 2214 defaultdisplay = igrid
2210 2215 __all__.append("igrid")
2211 2216 else:
2212 2217 defaultdisplay = ibrowse
2213 2218 __all__.append("ibrowse")
2214 2219
2215 2220
2216 2221 # If we're running under IPython, install an IPython displayhook that
2217 2222 # returns the object from Display.display(), else install a displayhook
2218 2223 # directly as sys.displayhook
2219 2224 api = None
2220 2225 if ipapi is not None:
2221 2226 try:
2222 2227 api = ipapi.get()
2223 2228 except AttributeError:
2224 2229 pass
2225 2230
2226 2231 if api is not None:
2227 2232 def displayhook(self, obj):
2228 2233 if isinstance(obj, type) and issubclass(obj, Table):
2229 2234 obj = obj()
2230 2235 if isinstance(obj, Table):
2231 2236 obj = obj | defaultdisplay
2232 2237 if isinstance(obj, Display):
2233 2238 return obj.display()
2234 2239 else:
2235 2240 raise ipapi.TryNext
2236 2241 api.set_hook("result_display", displayhook)
2237 2242 else:
2238 2243 def installdisplayhook():
2239 2244 _originalhook = sys.displayhook
2240 2245 def displayhook(obj):
2241 2246 if isinstance(obj, type) and issubclass(obj, Table):
2242 2247 obj = obj()
2243 2248 if isinstance(obj, Table):
2244 2249 obj = obj | defaultdisplay
2245 2250 if isinstance(obj, Display):
2246 2251 return obj.display()
2247 2252 else:
2248 2253 _originalhook(obj)
2249 2254 sys.displayhook = displayhook
2250 2255 installdisplayhook()
@@ -1,7390 +1,7392 b''
1 1 2008-01-19 Walter Doerwald <walter@livinglogic.de>
2 2
3 * IPython/Extensions/ibrowse.py, IPython/Extensions/igrid.py:
4 The input object can now be passed to the constructor of ibrowse/igrid.
3 * ibrowse.py, igrid.py, ipipe.py:
4 The input object can now be passed to the constructor of the display classes.
5 5 This makes it possible to use them with objects that implement __or__.
6
6 * ipipe.py: Importing astyle.py is done as late as possible to
7 avoid problems with circular imports.
8
7 9 2008-01-19 Ville Vainio <vivainio@gmail.com>
8 10
9 11 * hooks.py, iplib.py: Added 'shell_hook' to customize how
10 12 IPython calls shell.
11 13
12 14 * hooks.py, iplib.py: Added 'show_in_pager' hook to specify
13 15 how IPython pages text (%page, %pycat, %pdoc etc.)
14 16
15 17 * Extensions/jobctrl.py: Use shell_hook. New magics: '%tasks'
16 18 and '%kill' to kill hanging processes that won't obey ctrl+C.
17 19
18 20 2008-01-16 Ville Vainio <vivainio@gmail.com>
19 21
20 22 * ipy_completers.py: pyw extension support for %run completer.
21 23
22 24 2008-01-11 Ville Vainio <vivainio@gmail.com>
23 25
24 26 * iplib.py, ipmaker.py: new rc option - autoexec. It's a list
25 27 of ipython commands to be run when IPython has started up
26 28 (just before running the scripts and -c arg on command line).
27 29
28 30 * ipy_user_conf.py: Added an example on how to change term
29 31 colors in config file (through using autoexec).
30 32
31 33 * completer.py, test_completer.py: Ability to specify custom
32 34 get_endidx to replace readline.get_endidx. For emacs users.
33 35
34 36 2008-01-10 Ville Vainio <vivainio@gmail.com>
35 37
36 38 * Prompts.py (set_p_str): do not crash on illegal prompt strings
37 39
38 40 2008-01-08 Ville Vainio <vivainio@gmail.com>
39 41
40 42 * '%macro -r' (raw mode) is now default in sh profile.
41 43
42 44 2007-12-31 Ville Vainio <vivainio@gmail.com>
43 45
44 46 * completer.py: custom completer matching is now case sensitive
45 47 (#207).
46 48
47 49 * ultraTB.py, iplib.py: Add some KeyboardInterrupt catching in
48 50 an attempt to prevent occasional crashes.
49 51
50 52 * CrashHandler.py: Crash log dump now asks user to press enter
51 53 before exiting.
52 54
53 55 * Store _ip in user_ns instead of __builtin__, enabling safer
54 56 coexistence of multiple IPython instances in the same python
55 57 interpreter (#197).
56 58
57 59 * Debugger.py, ipmaker.py: Need to add '-pydb' command line
58 60 switch to enable pydb in post-mortem debugging and %run -d.
59 61
60 62 2007-12-28 Ville Vainio <vivainio@gmail.com>
61 63
62 64 * ipy_server.py: TCP socket server for "remote control" of an IPython
63 65 instance.
64 66
65 67 * Debugger.py: Change to PSF license
66 68
67 69 * simplegeneric.py: Add license & author notes.
68 70
69 71 * ipy_fsops.py: Added PathObj and FileObj, an object-oriented way
70 72 to navigate file system with a custom completer. Run
71 73 ipy_fsops.test_pathobj() to play with it.
72 74
73 75 2007-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
74 76
75 77 * IPython/dtutils.py: Add utilities for interactively running
76 78 doctests. Still needs work to more easily handle the namespace of
77 79 the package one may be working on, but the basics are in place.
78 80
79 81 2007-12-27 Ville Vainio <vivainio@gmail.com>
80 82
81 83 * ipy_completers.py: Applied arno's patch to get proper list of
82 84 packages in import completer. Closes #196.
83 85
84 86 2007-12-20 Ville Vainio <vivainio@gmail.com>
85 87
86 88 * completer.py, generics.py(complete_object): Allow
87 89 custom complers based on python objects via simplegeneric.
88 90 See generics.py / my_demo_complete_object
89 91
90 92 2007-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
91 93
92 94 * IPython/Prompts.py (BasePrompt.__nonzero__): add proper boolean
93 95 behavior to prompt objects, useful for display hooks to adjust
94 96 themselves depending on whether prompts will be there or not.
95 97
96 98 2007-12-13 Ville Vainio <vivainio@gmail.com>
97 99
98 100 * iplib.py(raw_input): unix readline does not allow unicode in
99 101 history, encode to normal string. After patch by Tiago.
100 102 Close #201
101 103
102 104 2007-12-12 Ville Vainio <vivainio@gmail.com>
103 105
104 106 * genutils.py (abbrev_cwd): Terminal title now shows 2 levels of
105 107 current directory.
106 108
107 109 2007-12-12 Fernando Perez <Fernando.Perez@colorado.edu>
108 110
109 111 * IPython/Shell.py (_select_shell): add support for controlling
110 112 the pylab threading mode directly at the command line, without
111 113 having to modify MPL config files. Added unit tests for this
112 114 feature, though manual/docs update is still pending, will do later.
113 115
114 116 2007-12-11 Ville Vainio <vivainio@gmail.com>
115 117
116 118 * ext_rescapture.py: var = !cmd is no longer verbose (to facilitate
117 119 use in scripts)
118 120
119 121 2007-12-07 Ville Vainio <vivainio@gmail.com>
120 122
121 123 * iplib.py, ipy_profile_sh.py: Do not escape # on command lines
122 124 anymore (to \#) - even if it is a comment char that is implicitly
123 125 escaped in some unix shells in interactive mode, it is ok to leave
124 126 it in IPython as such.
125 127
126 128
127 129 2007-12-01 Robert Kern <robert.kern@gmail.com>
128 130
129 131 * IPython/ultraTB.py (findsource): Improve the monkeypatch to
130 132 inspect.findsource(). It can now find source lines inside zipped
131 133 packages.
132 134
133 135 * IPython/ultraTB.py: When constructing tracebacks, try to use __file__
134 136 in the frame's namespace before trusting the filename in the code object
135 137 which created the frame.
136 138
137 139 2007-11-29 *** Released version 0.8.2
138 140
139 141 2007-11-25 Fernando Perez <Fernando.Perez@colorado.edu>
140 142
141 143 * IPython/Logger.py (Logger.logstop): add a proper logstop()
142 144 method to fully stop the logger, along with a corresponding
143 145 %logstop magic for interactive use.
144 146
145 147 * IPython/Extensions/ipy_host_completers.py: added new host
146 148 completers functionality, contributed by Gael Pasgrimaud
147 149 <gawel-AT-afpy.org>.
148 150
149 151 2007-11-24 Fernando Perez <Fernando.Perez@colorado.edu>
150 152
151 153 * IPython/DPyGetOpt.py (ArgumentError): Apply patch by Paul Mueller
152 154 <gakusei-AT-dakotacom.net>, to fix deprecated string exceptions in
153 155 options handling. Unicode fix in %whos (committed a while ago)
154 156 was also contributed by Paul.
155 157
156 158 2007-11-23 Darren Dale <darren.dale@cornell.edu>
157 159 * ipy_traits_completer.py: let traits_completer respect the user's
158 160 readline_omit__names setting.
159 161
160 162 2007-11-08 Ville Vainio <vivainio@gmail.com>
161 163
162 164 * ipy_completers.py (import completer): assume 'xml' module exists.
163 165 Do not add every module twice anymore. Closes #196.
164 166
165 167 * ipy_completers.py, ipy_app_completers.py: Add proper apt-get
166 168 completer that uses apt-cache to search for existing packages.
167 169
168 170 2007-11-06 Ville Vainio <vivainio@gmail.com>
169 171
170 172 * Prompts.py: Do not update _oh and _123 when do_full_cache is not
171 173 true. Closes #194.
172 174
173 175 2007-11-01 Brian Granger <ellisonbg@gmail.com>
174 176
175 177 * iplib.py, rlineimpl.py: Applied Body Water's patches to get IPython
176 178 working with OS X 10.5 libedit implementation of readline.
177 179
178 180 2007-10-24 Ville Vainio <vivainio@gmail.com>
179 181
180 182 * iplib.py(user_setup): To route around buggy installations where
181 183 UserConfig is not available, create a minimal _ipython.
182 184
183 185 * iplib.py: Unicode fixes from Jorgen.
184 186
185 187 * genutils.py: Slist now has new method 'fields()' for extraction of
186 188 whitespace-separated fields from line-oriented data.
187 189
188 190 2007-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
189 191
190 192 * IPython/OInspect.py (Inspector.pinfo): fix bug that could arise
191 193 when querying objects with no __class__ attribute (such as
192 194 f2py-generated modules).
193 195
194 196 2007-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
195 197
196 198 * IPython/Magic.py (magic_time): track compilation time and report
197 199 it if longer than 0.1s (fix done to %time and %timeit). After a
198 200 SAGE bug report: http://trac.sagemath.org/sage_trac/ticket/632.
199 201
200 202 2007-09-18 Ville Vainio <vivainio@gmail.com>
201 203
202 204 * genutils.py(make_quoted_expr): Do not use Itpl, it does
203 205 not support unicode at the moment. Fixes (many) magic calls with
204 206 special characters.
205 207
206 208 2007-09-14 Fernando Perez <Fernando.Perez@colorado.edu>
207 209
208 210 * IPython/genutils.py (doctest_reload): expose the doctest
209 211 reloader to the user so that people can easily reset doctest while
210 212 using it interactively. Fixes a problem reported by Jorgen.
211 213
212 214 * IPython/iplib.py (InteractiveShell.__init__): protect the
213 215 FakeModule instances used for __main__ in %run calls from
214 216 deletion, so that user code defined in them isn't left with
215 217 dangling references due to the Python module deletion machinery.
216 218 This should fix the problems reported by Darren.
217 219
218 220 2007-09-10 Darren Dale <dd55@cornell.edu>
219 221
220 222 * Cleanup of IPShellQt and IPShellQt4
221 223
222 224 2007-09-09 Fernando Perez <Fernando.Perez@colorado.edu>
223 225
224 226 * IPython/FakeModule.py (FakeModule.__init__): further fixes for
225 227 doctest support.
226 228
227 229 * IPython/iplib.py (safe_execfile): minor docstring improvements.
228 230
229 231 2007-09-08 Ville Vainio <vivainio@gmail.com>
230 232
231 233 * Magic.py (%pushd, %popd, %dirs): Fix dir stack - push *current*
232 234 directory, not the target directory.
233 235
234 236 * ipapi.py, Magic.py, iplib.py: Add ipapi.UsageError, a lighter weight
235 237 exception that won't print the tracebacks. Switched many magics to
236 238 raise them on error situations, also GetoptError is not printed
237 239 anymore.
238 240
239 241 2007-09-07 Ville Vainio <vivainio@gmail.com>
240 242
241 243 * iplib.py: do not auto-alias "dir", it screws up other dir auto
242 244 aliases.
243 245
244 246 * genutils.py: SList.grep() implemented.
245 247
246 248 * ipy_editors.py, UserConfig/ipy_user_conf.py: Add some editors
247 249 for easy "out of the box" setup of several common editors, so that
248 250 e.g. '%edit os.path.isfile' will jump to the correct line
249 251 automatically. Contributions for command lines of your favourite
250 252 editors welcome.
251 253
252 254 2007-09-07 Fernando Perez <Fernando.Perez@colorado.edu>
253 255
254 256 * IPython/OInspect.py (Inspector.pinfo): fixed bug that was
255 257 preventing source display in certain cases. In reality I think
256 258 the problem is with Ubuntu's Python build, but this change works
257 259 around the issue in some cases (not in all, unfortunately). I'd
258 260 filed a Python bug on this with more details, but in the change of
259 261 bug trackers it seems to have been lost.
260 262
261 263 * IPython/Magic.py (magic_dhist): restore %dhist. No, cd -TAB is
262 264 not the same, it's not self-documenting, doesn't allow range
263 265 selection, and sorts alphabetically instead of numerically.
264 266 (magic_r): restore %r. No, "up + enter. One char magic" is not
265 267 the same thing, since %r takes parameters to allow fast retrieval
266 268 of old commands. I've received emails from users who use this a
267 269 LOT, so it stays.
268 270 (magic_automagic): restore %automagic. "use _ip.option.automagic"
269 271 is not a valid replacement b/c it doesn't provide an complete
270 272 explanation (which the automagic docstring does).
271 273 (magic_autocall): restore %autocall, with improved docstring.
272 274 Same argument as for others, "use _ip.options.autocall" is not a
273 275 valid replacement.
274 276 (magic_pdef): restore %pdef & friends. Used widely, mentioned in
275 277 tutorials and online docs.
276 278
277 279 2007-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
278 280
279 281 * IPython/usage.py (quick_reference): mention magics in quickref,
280 282 modified main banner to mention %quickref.
281 283
282 284 * IPython/FakeModule.py (FakeModule): fixes for doctest compatibility.
283 285
284 286 2007-09-06 Ville Vainio <vivainio@gmail.com>
285 287
286 288 * ipy_rehashdir.py, ipy_workdir.py, ipy_fsops.py, iplib.py:
287 289 Callable aliases now pass the _ip as first arg. This breaks
288 290 compatibility with earlier 0.8.2.svn series! (though they should
289 291 not have been in use yet outside these few extensions)
290 292
291 293 2007-09-05 Ville Vainio <vivainio@gmail.com>
292 294
293 295 * external/mglob.py: expand('dirname') => ['dirname'], instead
294 296 of ['dirname/foo','dirname/bar', ...].
295 297
296 298 * Extensions/ipy_fsops.py: added, has usefull shell utils for plain
297 299 win32 installations: icp, imv, imkdir, igrep, irm, collect (collect
298 300 is useful for others as well).
299 301
300 302 * iplib.py: on callable aliases (as opposed to old style aliases),
301 303 do var_expand() immediately, and use make_quoted_expr instead
302 304 of hardcoded r"""
303 305
304 306 * Extensions/ipy_profile_sh.py: Try to detect cygwin on win32,
305 307 if not available load ipy_fsops.py for cp, mv, etc. replacements
306 308
307 309 * OInspect.py, ipy_which.py: improve %which and obj? for callable
308 310 aliases
309 311
310 312 2007-09-04 Ville Vainio <vivainio@gmail.com>
311 313
312 314 * ipy_profile_zope.py: add zope profile, by Stefan Eletzhofer.
313 315 Relicensed under BSD with the authors approval.
314 316
315 317 * ipmaker.py, usage.py: Remove %magic from default banner, improve
316 318 %quickref
317 319
318 320 2007-09-03 Ville Vainio <vivainio@gmail.com>
319 321
320 322 * Magic.py: %time now passes expression through prefilter,
321 323 allowing IPython syntax.
322 324
323 325 2007-09-01 Ville Vainio <vivainio@gmail.com>
324 326
325 327 * ipmaker.py: Always show full traceback when newstyle config fails
326 328
327 329 2007-08-27 Ville Vainio <vivainio@gmail.com>
328 330
329 331 * Magic.py: fix %cd for nonexistent dir when dhist is empty, close #180
330 332
331 333 2007-08-26 Ville Vainio <vivainio@gmail.com>
332 334
333 335 * ipmaker.py: Command line args have the highest priority again
334 336
335 337 * iplib.py, ipmaker.py: -i command line argument now behaves as in
336 338 normal python, i.e. leaves the IPython session running after -c
337 339 command or running a batch file from command line.
338 340
339 341 2007-08-22 Ville Vainio <vivainio@gmail.com>
340 342
341 343 * iplib.py: no extra empty (last) line in raw hist w/ multiline
342 344 statements
343 345
344 346 * logger.py: Fix bug where blank lines in history were not
345 347 added until AFTER adding the current line; translated and raw
346 348 history should finally be in sync with prompt now.
347 349
348 350 * ipy_completers.py: quick_completer now makes it easy to create
349 351 trivial custom completers
350 352
351 353 * clearcmd.py: shadow history compression & erasing, fixed input hist
352 354 clearing.
353 355
354 356 * envpersist.py, history.py: %env (sh profile only), %hist completers
355 357
356 358 * genutils.py, Prompts.py, Magic.py: win32 - prompt (with \yDEPTH) and
357 359 term title now include the drive letter, and always use / instead of
358 360 os.sep (as per recommended approach for win32 ipython in general).
359 361
360 362 * ipykit.py, ipy_kitcfg.py: special launcher for ipykit. Allows running
361 363 plain python scripts from ipykit command line by running
362 364 "py myscript.py", even w/o installed python.
363 365
364 366 2007-08-21 Ville Vainio <vivainio@gmail.com>
365 367
366 368 * ipmaker.py: finding ipythonrc-PROF now skips ipy_profile_PROF.
367 369 (for backwards compatibility)
368 370
369 371 * history.py: switch back to %hist -t from %hist -r as default.
370 372 At least until raw history is fixed for good.
371 373
372 374 2007-08-20 Ville Vainio <vivainio@gmail.com>
373 375
374 376 * ipapi.py, iplib.py: DebugTools accessible via _ip.dbg, to catch &
375 377 locate alias redeclarations etc. Also, avoid handling
376 378 _ip.IP.alias_table directly, prefer using _ip.defalias.
377 379
378 380
379 381 2007-08-15 Ville Vainio <vivainio@gmail.com>
380 382
381 383 * prefilter.py: ! is now always served first
382 384
383 385 2007-08-15 Fernando Perez <Fernando.Perez@colorado.edu>
384 386
385 387 * IPython/iplib.py (safe_execfile): fix the SystemExit
386 388 auto-suppression code to work in Python2.4 (the internal structure
387 389 of that exception changed and I'd only tested the code with 2.5).
388 390 Bug reported by a SciPy attendee.
389 391
390 392 2007-08-13 Ville Vainio <vivainio@gmail.com>
391 393
392 394 * prefilter.py: reverted !c:/bin/foo fix, made % in
393 395 multiline specials work again
394 396
395 397 2007-08-13 Ville Vainio <vivainio@gmail.com>
396 398
397 399 * prefilter.py: Take more care to special-case !, so that
398 400 !c:/bin/foo.exe works.
399 401
400 402 * setup.py: if we are building eggs, strip all docs and
401 403 examples (it doesn't make sense to bytecompile examples,
402 404 and docs would be in an awkward place anyway).
403 405
404 406 * Ryan Krauss' patch fixes start menu shortcuts when IPython
405 407 is installed into a directory that has spaces in the name.
406 408
407 409 2007-08-13 Fernando Perez <Fernando.Perez@colorado.edu>
408 410
409 411 * IPython/Magic.py (magic_doctest_mode): fix prompt separators in
410 412 doctest profile and %doctest_mode, so they actually generate the
411 413 blank lines needed by doctest to separate individual tests.
412 414
413 415 * IPython/iplib.py (safe_execfile): modify so that running code
414 416 which calls sys.exit(0) (or equivalently, raise SystemExit(0))
415 417 doesn't get a printed traceback. Any other value in sys.exit(),
416 418 including the empty call, still generates a traceback. This
417 419 enables use of %run without having to pass '-e' for codes that
418 420 correctly set the exit status flag.
419 421
420 422 2007-08-12 Fernando Perez <Fernando.Perez@colorado.edu>
421 423
422 424 * IPython/iplib.py (InteractiveShell.post_config_initialization):
423 425 fix problems with doctests failing when run inside IPython due to
424 426 IPython's modifications of sys.displayhook.
425 427
426 428 2007-8-9 Fernando Perez <fperez@planck.colorado.edu>
427 429
428 430 * IPython/ipapi.py (to_user_ns): update to accept a dict as well as
429 431 a string with names.
430 432
431 433 2007-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
432 434
433 435 * IPython/Magic.py (magic_doctest_mode): added new %doctest_mode
434 436 magic to toggle on/off the doctest pasting support without having
435 437 to leave a session to switch to a separate profile.
436 438
437 439 2007-08-08 Fernando Perez <Fernando.Perez@colorado.edu>
438 440
439 441 * IPython/Extensions/ipy_profile_doctest.py (main): fix prompt to
440 442 introduce a blank line between inputs, to conform to doctest
441 443 requirements.
442 444
443 445 * IPython/OInspect.py (Inspector.pinfo): fix another part where
444 446 auto-generated docstrings for new-style classes were showing up.
445 447
446 448 2007-08-07 Fernando Perez <Fernando.Perez@colorado.edu>
447 449
448 450 * api_changes: Add new file to track backward-incompatible
449 451 user-visible changes.
450 452
451 453 2007-08-06 Ville Vainio <vivainio@gmail.com>
452 454
453 455 * ipmaker.py: fix bug where user_config_ns didn't exist at all
454 456 before all the config files were handled.
455 457
456 458 2007-08-04 Fernando Perez <Fernando.Perez@colorado.edu>
457 459
458 460 * IPython/irunner.py (RunnerFactory): Add new factory class for
459 461 creating reusable runners based on filenames.
460 462
461 463 * IPython/Extensions/ipy_profile_doctest.py: New profile for
462 464 doctest support. It sets prompts/exceptions as similar to
463 465 standard Python as possible, so that ipython sessions in this
464 466 profile can be easily pasted as doctests with minimal
465 467 modifications. It also enables pasting of doctests from external
466 468 sources (even if they have leading whitespace), so that you can
467 469 rerun doctests from existing sources.
468 470
469 471 * IPython/iplib.py (_prefilter): fix a buglet where after entering
470 472 some whitespace, the prompt would become a continuation prompt
471 473 with no way of exiting it other than Ctrl-C. This fix brings us
472 474 into conformity with how the default python prompt works.
473 475
474 476 * IPython/Extensions/InterpreterPasteInput.py (prefilter_paste):
475 477 Add support for pasting not only lines that start with '>>>', but
476 478 also with ' >>>'. That is, arbitrary whitespace can now precede
477 479 the prompts. This makes the system useful for pasting doctests
478 480 from docstrings back into a normal session.
479 481
480 482 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu>
481 483
482 484 * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in
483 485 r1357, which had killed multiple invocations of an embedded
484 486 ipython (this means that example-embed has been broken for over 1
485 487 year!!!). Rather than possibly breaking the batch stuff for which
486 488 the code in iplib.py/interact was introduced, I worked around the
487 489 problem in the embedding class in Shell.py. We really need a
488 490 bloody test suite for this code, I'm sick of finding stuff that
489 491 used to work breaking left and right every time I use an old
490 492 feature I hadn't touched in a few months.
491 493 (kill_embedded): Add a new magic that only shows up in embedded
492 494 mode, to allow users to permanently deactivate an embedded instance.
493 495
494 496 2007-08-01 Ville Vainio <vivainio@gmail.com>
495 497
496 498 * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw
497 499 history gets out of sync on runlines (e.g. when running macros).
498 500
499 501 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu>
500 502
501 503 * IPython/Magic.py (magic_colors): fix win32-related error message
502 504 that could appear under *nix when readline was missing. Patch by
503 505 Scott Jackson, closes #175.
504 506
505 507 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
506 508
507 509 * IPython/Extensions/ipy_traits_completer.py: Add a new custom
508 510 completer that it traits-aware, so that traits objects don't show
509 511 all of their internal attributes all the time.
510 512
511 513 * IPython/genutils.py (dir2): moved this code from inside
512 514 completer.py to expose it publicly, so I could use it in the
513 515 wildcards bugfix.
514 516
515 517 * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by
516 518 Stefan with Traits.
517 519
518 520 * IPython/completer.py (Completer.attr_matches): change internal
519 521 var name from 'object' to 'obj', since 'object' is now a builtin
520 522 and this can lead to weird bugs if reusing this code elsewhere.
521 523
522 524 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu>
523 525
524 526 * IPython/OInspect.py (Inspector.pinfo): fix small glitches in
525 527 'foo?' and update the code to prevent printing of default
526 528 docstrings that started appearing after I added support for
527 529 new-style classes. The approach I'm using isn't ideal (I just
528 530 special-case those strings) but I'm not sure how to more robustly
529 531 differentiate between truly user-written strings and Python's
530 532 automatic ones.
531 533
532 534 2007-07-09 Ville Vainio <vivainio@gmail.com>
533 535
534 536 * completer.py: Applied Matthew Neeley's patch:
535 537 Dynamic attributes from trait_names and _getAttributeNames are added
536 538 to the list of tab completions, but when this happens, the attribute
537 539 list is turned into a set, so the attributes are unordered when
538 540 printed, which makes it hard to find the right completion. This patch
539 541 turns this set back into a list and sort it.
540 542
541 543 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu>
542 544
543 545 * IPython/OInspect.py (Inspector.pinfo): Add support for new-style
544 546 classes in various inspector functions.
545 547
546 548 2007-06-28 Ville Vainio <vivainio@gmail.com>
547 549
548 550 * shadowns.py, iplib.py, ipapi.py, OInspect.py:
549 551 Implement "shadow" namespace, and callable aliases that reside there.
550 552 Use them by:
551 553
552 554 _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc
553 555
554 556 foo hello world
555 557 (gets translated to:)
556 558 _sh.foo(r"""hello world""")
557 559
558 560 In practice, this kind of alias can take the role of a magic function
559 561
560 562 * New generic inspect_object, called on obj? and obj??
561 563
562 564 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu>
563 565
564 566 * IPython/ultraTB.py (findsource): fix a problem with
565 567 inspect.getfile that can cause crashes during traceback construction.
566 568
567 569 2007-06-14 Ville Vainio <vivainio@gmail.com>
568 570
569 571 * iplib.py (handle_auto): Try to use ascii for printing "--->"
570 572 autocall rewrite indication, becausesometimes unicode fails to print
571 573 properly (and you get ' - - - '). Use plain uncoloured ---> for
572 574 unicode.
573 575
574 576 * shadow history. Usable through "%hist -g <pat>" and "%rep 0123".
575 577
576 578 . pickleshare 'hash' commands (hget, hset, hcompress,
577 579 hdict) for efficient shadow history storage.
578 580
579 581 2007-06-13 Ville Vainio <vivainio@gmail.com>
580 582
581 583 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
582 584 Added kw arg 'interactive', tell whether vars should be visible
583 585 with %whos.
584 586
585 587 2007-06-11 Ville Vainio <vivainio@gmail.com>
586 588
587 589 * pspersistence.py, Magic.py, iplib.py: directory history now saved
588 590 to db
589 591
590 592 * iplib.py: "ipython -c <cmd>" now passes the command through prefilter.
591 593 Also, it exits IPython immediately after evaluating the command (just like
592 594 std python)
593 595
594 596 2007-06-05 Walter Doerwald <walter@livinglogic.de>
595 597
596 598 * IPython/Extensions/ipipe.py: Added a new table icap, which executes a
597 599 Python string and captures the output. (Idea and original patch by
598 600 Stefan van der Walt)
599 601
600 602 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu>
601 603
602 604 * IPython/ultraTB.py (VerboseTB.text): update printing of
603 605 exception types for Python 2.5 (now all exceptions in the stdlib
604 606 are new-style classes).
605 607
606 608 2007-05-31 Walter Doerwald <walter@livinglogic.de>
607 609
608 610 * IPython/Extensions/igrid.py: Add new commands refresh and
609 611 refresh_timer (mapped to "R"/"F5" and to the menu) which restarts
610 612 the iterator once (refresh) or after every x seconds (refresh_timer).
611 613 Add a working implementation of "searchexpression", where the text
612 614 entered is not the text to search for, but an expression that must
613 615 be true. Added display of shortcuts to the menu. Added commands "pickinput"
614 616 and "pickinputattr" that put the object or attribute under the cursor
615 617 in the input line. Split the statusbar to be able to display the currently
616 618 active refresh interval. (Patch by Nik Tautenhahn)
617 619
618 620 2007-05-29 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
619 621
620 622 * fixing set_term_title to use ctypes as default
621 623
622 624 * fixing set_term_title fallback to work when curent dir
623 625 is on a windows network share
624 626
625 627 2007-05-28 Ville Vainio <vivainio@gmail.com>
626 628
627 629 * %cpaste: strip + with > from left (diffs).
628 630
629 631 * iplib.py: Fix crash when readline not installed
630 632
631 633 2007-05-26 Ville Vainio <vivainio@gmail.com>
632 634
633 635 * generics.py: intruduce easy to extend result_display generic
634 636 function (using simplegeneric.py).
635 637
636 638 * Fixed the append functionality of %set.
637 639
638 640 2007-05-25 Ville Vainio <vivainio@gmail.com>
639 641
640 642 * New magic: %rep (fetch / run old commands from history)
641 643
642 644 * New extension: mglob (%mglob magic), for powerful glob / find /filter
643 645 like functionality
644 646
645 647 % maghistory.py: %hist -g PATTERM greps the history for pattern
646 648
647 649 2007-05-24 Walter Doerwald <walter@livinglogic.de>
648 650
649 651 * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to
650 652 browse the IPython input history
651 653
652 654 * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput
653 655 (mapped to "i") can be used to put the object under the curser in the input
654 656 line. pickinputattr (mapped to "I") does the same for the attribute under
655 657 the cursor.
656 658
657 659 2007-05-24 Ville Vainio <vivainio@gmail.com>
658 660
659 661 * Grand magic cleansing (changeset [2380]):
660 662
661 663 * Introduce ipy_legacy.py where the following magics were
662 664 moved:
663 665
664 666 pdef pdoc psource pfile rehash dhist Quit p r automagic autocall
665 667
666 668 If you need them, either use default profile or "import ipy_legacy"
667 669 in your ipy_user_conf.py
668 670
669 671 * Move sh and scipy profile to Extensions from UserConfig. this implies
670 672 you should not edit them, but you don't need to run %upgrade when
671 673 upgrading IPython anymore.
672 674
673 675 * %hist/%history now operates in "raw" mode by default. To get the old
674 676 behaviour, run '%hist -n' (native mode).
675 677
676 678 * split ipy_stock_completers.py to ipy_stock_completers.py and
677 679 ipy_app_completers.py. Stock completers (%cd, import, %run) are now
678 680 installed as default.
679 681
680 682 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
681 683 handling.
682 684
683 685 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
684 686 input if readline is available.
685 687
686 688 2007-05-23 Ville Vainio <vivainio@gmail.com>
687 689
688 690 * macro.py: %store uses __getstate__ properly
689 691
690 692 * exesetup.py: added new setup script for creating
691 693 standalone IPython executables with py2exe (i.e.
692 694 no python installation required).
693 695
694 696 * Removed ipythonrc-scipy, ipy_profile_scipy.py takes
695 697 its place.
696 698
697 699 * rlineimpl.py, genutils.py (get_home_dir): py2exe support
698 700
699 701 2007-05-21 Ville Vainio <vivainio@gmail.com>
700 702
701 703 * platutil_win32.py (set_term_title): handle
702 704 failure of 'title' system call properly.
703 705
704 706 2007-05-17 Walter Doerwald <walter@livinglogic.de>
705 707
706 708 * IPython/Extensions/ipipe.py: Fix xrepr for ifiles.
707 709 (Bug detected by Paul Mueller).
708 710
709 711 2007-05-16 Ville Vainio <vivainio@gmail.com>
710 712
711 713 * ipy_profile_sci.py, ipython_win_post_install.py: Create
712 714 new "sci" profile, effectively a modern version of the old
713 715 "scipy" profile (which is now slated for deprecation).
714 716
715 717 2007-05-15 Ville Vainio <vivainio@gmail.com>
716 718
717 719 * pycolorize.py, pycolor.1: Paul Mueller's patches that
718 720 make pycolorize read input from stdin when run without arguments.
719 721
720 722 * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155
721 723
722 724 * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import
723 725 it in sh profile (instead of ipy_system_conf.py).
724 726
725 727 * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command
726 728 aliases are now lower case on windows (MyCommand.exe => mycommand).
727 729
728 730 * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul.
729 731 Macros are now callable objects that inherit from ipapi.IPyAutocall,
730 732 i.e. get autocalled regardless of system autocall setting.
731 733
732 734 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
733 735
734 736 * IPython/rlineimpl.py: check for clear_history in readline and
735 737 make it a dummy no-op if not available. This function isn't
736 738 guaranteed to be in the API and appeared in Python 2.4, so we need
737 739 to check it ourselves. Also, clean up this file quite a bit.
738 740
739 741 * ipython.1: update man page and full manual with information
740 742 about threads (remove outdated warning). Closes #151.
741 743
742 744 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu>
743 745
744 746 * IPython/Extensions/ipy_constants.py: Add Gael's constants module
745 747 in trunk (note that this made it into the 0.8.1 release already,
746 748 but the changelogs didn't get coordinated). Many thanks to Gael
747 749 Varoquaux <gael.varoquaux-AT-normalesup.org>
748 750
749 751 2007-05-09 *** Released version 0.8.1
750 752
751 753 2007-05-10 Walter Doerwald <walter@livinglogic.de>
752 754
753 755 * IPython/Extensions/igrid.py: Incorporate html help into
754 756 the module, so we don't have to search for the file.
755 757
756 758 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu>
757 759
758 760 * test/test_irunner.py (RunnerTestCase._test_runner): Close #147.
759 761
760 762 2007-04-30 Ville Vainio <vivainio@gmail.com>
761 763
762 764 * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the
763 765 user has illegal (non-ascii) home directory name
764 766
765 767 2007-04-27 Ville Vainio <vivainio@gmail.com>
766 768
767 769 * platutils_win32.py: implement set_term_title for windows
768 770
769 771 * Update version number
770 772
771 773 * ipy_profile_sh.py: more informative prompt (2 dir levels)
772 774
773 775 2007-04-26 Walter Doerwald <walter@livinglogic.de>
774 776
775 777 * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced
776 778 when the igrid input raised an exception. (Patch by Nik Tautenhahn,
777 779 bug discovered by Ville).
778 780
779 781 2007-04-26 Ville Vainio <vivainio@gmail.com>
780 782
781 783 * Extensions/ipy_completers.py: Olivier's module completer now
782 784 saves the list of root modules if it takes > 4 secs on the first run.
783 785
784 786 * Magic.py (%rehashx): %rehashx now clears the completer cache
785 787
786 788
787 789 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu>
788 790
789 791 * ipython.el: fix incorrect color scheme, reported by Stefan.
790 792 Closes #149.
791 793
792 794 * IPython/PyColorize.py (Parser.format2): fix state-handling
793 795 logic. I still don't like how that code handles state, but at
794 796 least now it should be correct, if inelegant. Closes #146.
795 797
796 798 2007-04-25 Ville Vainio <vivainio@gmail.com>
797 799
798 800 * Extensions/ipy_which.py: added extension for %which magic, works
799 801 a lot like unix 'which' but also finds and expands aliases, and
800 802 allows wildcards.
801 803
802 804 * ipapi.py (expand_alias): Now actually *return* the expanded alias,
803 805 as opposed to returning nothing.
804 806
805 807 * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import
806 808 ipy_stock_completers on default profile, do import on sh profile.
807 809
808 810 2007-04-22 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
809 811
810 812 * Fix bug in iplib.py/safe_execfile when launching ipython with a script
811 813 like ipython.py foo.py which raised a IndexError.
812 814
813 815 2007-04-21 Ville Vainio <vivainio@gmail.com>
814 816
815 817 * Extensions/ipy_extutil.py: added extension to manage other ipython
816 818 extensions. Now only supports 'ls' == list extensions.
817 819
818 820 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
819 821
820 822 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
821 823 would prevent use of the exception system outside of a running
822 824 IPython instance.
823 825
824 826 2007-04-20 Ville Vainio <vivainio@gmail.com>
825 827
826 828 * Extensions/ipy_render.py: added extension for easy
827 829 interactive text template rendering (to clipboard). Uses Ka-Ping Yee's
828 830 'Iptl' template notation,
829 831
830 832 * Extensions/ipy_completers.py: introduced Olivier Lauzanne's
831 833 safer & faster 'import' completer.
832 834
833 835 * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value)
834 836 and _ip.defalias(name, command).
835 837
836 838 * Extensions/ipy_exportdb.py: New extension for exporting all the
837 839 %store'd data in a portable format (normal ipapi calls like
838 840 defmacro() etc.)
839 841
840 842 2007-04-19 Ville Vainio <vivainio@gmail.com>
841 843
842 844 * upgrade_dir.py: skip junk files like *.pyc
843 845
844 846 * Release.py: version number to 0.8.1
845 847
846 848 2007-04-18 Ville Vainio <vivainio@gmail.com>
847 849
848 850 * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1
849 851 and later on win32.
850 852
851 853 2007-04-16 Ville Vainio <vivainio@gmail.com>
852 854
853 855 * iplib.py (showtraceback): Do not crash when running w/o readline.
854 856
855 857 2007-04-12 Walter Doerwald <walter@livinglogic.de>
856 858
857 859 * IPython/Extensions/ipipe.py: (ils) Directoy listings are now
858 860 sorted (case sensitive with files and dirs mixed).
859 861
860 862 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu>
861 863
862 864 * IPython/Release.py (version): Open trunk for 0.8.1 development.
863 865
864 866 2007-04-10 *** Released version 0.8.0
865 867
866 868 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
867 869
868 870 * Tag 0.8.0 for release.
869 871
870 872 * IPython/iplib.py (reloadhist): add API function to cleanly
871 873 reload the readline history, which was growing inappropriately on
872 874 every %run call.
873 875
874 876 * win32_manual_post_install.py (run): apply last part of Nicolas
875 877 Pernetty's patch (I'd accidentally applied it in a different
876 878 directory and this particular file didn't get patched).
877 879
878 880 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
879 881
880 882 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
881 883 find the main thread id and use the proper API call. Thanks to
882 884 Stefan for the fix.
883 885
884 886 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
885 887 unit tests to reflect fixed ticket #52, and add more tests sent by
886 888 him.
887 889
888 890 * IPython/iplib.py (raw_input): restore the readline completer
889 891 state on every input, in case third-party code messed it up.
890 892 (_prefilter): revert recent addition of early-escape checks which
891 893 prevent many valid alias calls from working.
892 894
893 895 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
894 896 flag for sigint handler so we don't run a full signal() call on
895 897 each runcode access.
896 898
897 899 * IPython/Magic.py (magic_whos): small improvement to diagnostic
898 900 message.
899 901
900 902 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
901 903
902 904 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
903 905 asynchronous exceptions working, i.e., Ctrl-C can actually
904 906 interrupt long-running code in the multithreaded shells.
905 907
906 908 This is using Tomer Filiba's great ctypes-based trick:
907 909 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
908 910 this in the past, but hadn't been able to make it work before. So
909 911 far it looks like it's actually running, but this needs more
910 912 testing. If it really works, I'll be *very* happy, and we'll owe
911 913 a huge thank you to Tomer. My current implementation is ugly,
912 914 hackish and uses nasty globals, but I don't want to try and clean
913 915 anything up until we know if it actually works.
914 916
915 917 NOTE: this feature needs ctypes to work. ctypes is included in
916 918 Python2.5, but 2.4 users will need to manually install it. This
917 919 feature makes multi-threaded shells so much more usable that it's
918 920 a minor price to pay (ctypes is very easy to install, already a
919 921 requirement for win32 and available in major linux distros).
920 922
921 923 2007-04-04 Ville Vainio <vivainio@gmail.com>
922 924
923 925 * Extensions/ipy_completers.py, ipy_stock_completers.py:
924 926 Moved implementations of 'bundled' completers to ipy_completers.py,
925 927 they are only enabled in ipy_stock_completers.py.
926 928
927 929 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
928 930
929 931 * IPython/PyColorize.py (Parser.format2): Fix identation of
930 932 colorzied output and return early if color scheme is NoColor, to
931 933 avoid unnecessary and expensive tokenization. Closes #131.
932 934
933 935 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
934 936
935 937 * IPython/Debugger.py: disable the use of pydb version 1.17. It
936 938 has a critical bug (a missing import that makes post-mortem not
937 939 work at all). Unfortunately as of this time, this is the version
938 940 shipped with Ubuntu Edgy, so quite a few people have this one. I
939 941 hope Edgy will update to a more recent package.
940 942
941 943 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
942 944
943 945 * IPython/iplib.py (_prefilter): close #52, second part of a patch
944 946 set by Stefan (only the first part had been applied before).
945 947
946 948 * IPython/Extensions/ipy_stock_completers.py (module_completer):
947 949 remove usage of the dangerous pkgutil.walk_packages(). See
948 950 details in comments left in the code.
949 951
950 952 * IPython/Magic.py (magic_whos): add support for numpy arrays
951 953 similar to what we had for Numeric.
952 954
953 955 * IPython/completer.py (IPCompleter.complete): extend the
954 956 complete() call API to support completions by other mechanisms
955 957 than readline. Closes #109.
956 958
957 959 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
958 960 protect against a bug in Python's execfile(). Closes #123.
959 961
960 962 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
961 963
962 964 * IPython/iplib.py (split_user_input): ensure that when splitting
963 965 user input, the part that can be treated as a python name is pure
964 966 ascii (Python identifiers MUST be pure ascii). Part of the
965 967 ongoing Unicode support work.
966 968
967 969 * IPython/Prompts.py (prompt_specials_color): Add \N for the
968 970 actual prompt number, without any coloring. This allows users to
969 971 produce numbered prompts with their own colors. Added after a
970 972 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
971 973
972 974 2007-03-31 Walter Doerwald <walter@livinglogic.de>
973 975
974 976 * IPython/Extensions/igrid.py: Map the return key
975 977 to enter() and shift-return to enterattr().
976 978
977 979 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
978 980
979 981 * IPython/Magic.py (magic_psearch): add unicode support by
980 982 encoding to ascii the input, since this routine also only deals
981 983 with valid Python names. Fixes a bug reported by Stefan.
982 984
983 985 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
984 986
985 987 * IPython/Magic.py (_inspect): convert unicode input into ascii
986 988 before trying to evaluate it as a Python identifier. This fixes a
987 989 problem that the new unicode support had introduced when analyzing
988 990 long definition lines for functions.
989 991
990 992 2007-03-24 Walter Doerwald <walter@livinglogic.de>
991 993
992 994 * IPython/Extensions/igrid.py: Fix picking. Using
993 995 igrid with wxPython 2.6 and -wthread should work now.
994 996 igrid.display() simply tries to create a frame without
995 997 an application. Only if this fails an application is created.
996 998
997 999 2007-03-23 Walter Doerwald <walter@livinglogic.de>
998 1000
999 1001 * IPython/Extensions/path.py: Updated to version 2.2.
1000 1002
1001 1003 2007-03-23 Ville Vainio <vivainio@gmail.com>
1002 1004
1003 1005 * iplib.py: recursive alias expansion now works better, so that
1004 1006 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
1005 1007 doesn't trip up the process, if 'd' has been aliased to 'ls'.
1006 1008
1007 1009 * Extensions/ipy_gnuglobal.py added, provides %global magic
1008 1010 for users of http://www.gnu.org/software/global
1009 1011
1010 1012 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
1011 1013 Closes #52. Patch by Stefan van der Walt.
1012 1014
1013 1015 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
1014 1016
1015 1017 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
1016 1018 respect the __file__ attribute when using %run. Thanks to a bug
1017 1019 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
1018 1020
1019 1021 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
1020 1022
1021 1023 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
1022 1024 input. Patch sent by Stefan.
1023 1025
1024 1026 2007-03-20 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
1025 1027 * IPython/Extensions/ipy_stock_completer.py
1026 1028 shlex_split, fix bug in shlex_split. len function
1027 1029 call was missing an if statement. Caused shlex_split to
1028 1030 sometimes return "" as last element.
1029 1031
1030 1032 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
1031 1033
1032 1034 * IPython/completer.py
1033 1035 (IPCompleter.file_matches.single_dir_expand): fix a problem
1034 1036 reported by Stefan, where directories containign a single subdir
1035 1037 would be completed too early.
1036 1038
1037 1039 * IPython/Shell.py (_load_pylab): Make the execution of 'from
1038 1040 pylab import *' when -pylab is given be optional. A new flag,
1039 1041 pylab_import_all controls this behavior, the default is True for
1040 1042 backwards compatibility.
1041 1043
1042 1044 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
1043 1045 modified) R. Bernstein's patch for fully syntax highlighted
1044 1046 tracebacks. The functionality is also available under ultraTB for
1045 1047 non-ipython users (someone using ultraTB but outside an ipython
1046 1048 session). They can select the color scheme by setting the
1047 1049 module-level global DEFAULT_SCHEME. The highlight functionality
1048 1050 also works when debugging.
1049 1051
1050 1052 * IPython/genutils.py (IOStream.close): small patch by
1051 1053 R. Bernstein for improved pydb support.
1052 1054
1053 1055 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
1054 1056 DaveS <davls@telus.net> to improve support of debugging under
1055 1057 NTEmacs, including improved pydb behavior.
1056 1058
1057 1059 * IPython/Magic.py (magic_prun): Fix saving of profile info for
1058 1060 Python 2.5, where the stats object API changed a little. Thanks
1059 1061 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
1060 1062
1061 1063 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
1062 1064 Pernetty's patch to improve support for (X)Emacs under Win32.
1063 1065
1064 1066 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
1065 1067
1066 1068 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
1067 1069 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
1068 1070 a report by Nik Tautenhahn.
1069 1071
1070 1072 2007-03-16 Walter Doerwald <walter@livinglogic.de>
1071 1073
1072 1074 * setup.py: Add the igrid help files to the list of data files
1073 1075 to be installed alongside igrid.
1074 1076 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
1075 1077 Show the input object of the igrid browser as the window tile.
1076 1078 Show the object the cursor is on in the statusbar.
1077 1079
1078 1080 2007-03-15 Ville Vainio <vivainio@gmail.com>
1079 1081
1080 1082 * Extensions/ipy_stock_completers.py: Fixed exception
1081 1083 on mismatching quotes in %run completer. Patch by
1082 1084 Jorgen Stenarson. Closes #127.
1083 1085
1084 1086 2007-03-14 Ville Vainio <vivainio@gmail.com>
1085 1087
1086 1088 * Extensions/ext_rehashdir.py: Do not do auto_alias
1087 1089 in %rehashdir, it clobbers %store'd aliases.
1088 1090
1089 1091 * UserConfig/ipy_profile_sh.py: envpersist.py extension
1090 1092 (beefed up %env) imported for sh profile.
1091 1093
1092 1094 2007-03-10 Walter Doerwald <walter@livinglogic.de>
1093 1095
1094 1096 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
1095 1097 as the default browser.
1096 1098 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
1097 1099 As igrid displays all attributes it ever encounters, fetch() (which has
1098 1100 been renamed to _fetch()) doesn't have to recalculate the display attributes
1099 1101 every time a new item is fetched. This should speed up scrolling.
1100 1102
1101 1103 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
1102 1104
1103 1105 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
1104 1106 Schmolck's recently reported tab-completion bug (my previous one
1105 1107 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
1106 1108
1107 1109 2007-03-09 Walter Doerwald <walter@livinglogic.de>
1108 1110
1109 1111 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
1110 1112 Close help window if exiting igrid.
1111 1113
1112 1114 2007-03-02 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
1113 1115
1114 1116 * IPython/Extensions/ipy_defaults.py: Check if readline is available
1115 1117 before calling functions from readline.
1116 1118
1117 1119 2007-03-02 Walter Doerwald <walter@livinglogic.de>
1118 1120
1119 1121 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
1120 1122 igrid is a wxPython-based display object for ipipe. If your system has
1121 1123 wx installed igrid will be the default display. Without wx ipipe falls
1122 1124 back to ibrowse (which needs curses). If no curses is installed ipipe
1123 1125 falls back to idump.
1124 1126
1125 1127 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
1126 1128
1127 1129 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
1128 1130 my changes from yesterday, they introduced bugs. Will reactivate
1129 1131 once I get a correct solution, which will be much easier thanks to
1130 1132 Dan Milstein's new prefilter test suite.
1131 1133
1132 1134 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
1133 1135
1134 1136 * IPython/iplib.py (split_user_input): fix input splitting so we
1135 1137 don't attempt attribute accesses on things that can't possibly be
1136 1138 valid Python attributes. After a bug report by Alex Schmolck.
1137 1139 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
1138 1140 %magic with explicit % prefix.
1139 1141
1140 1142 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
1141 1143
1142 1144 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
1143 1145 avoid a DeprecationWarning from GTK.
1144 1146
1145 1147 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
1146 1148
1147 1149 * IPython/genutils.py (clock): I modified clock() to return total
1148 1150 time, user+system. This is a more commonly needed metric. I also
1149 1151 introduced the new clocku/clocks to get only user/system time if
1150 1152 one wants those instead.
1151 1153
1152 1154 ***WARNING: API CHANGE*** clock() used to return only user time,
1153 1155 so if you want exactly the same results as before, use clocku
1154 1156 instead.
1155 1157
1156 1158 2007-02-22 Ville Vainio <vivainio@gmail.com>
1157 1159
1158 1160 * IPython/Extensions/ipy_p4.py: Extension for improved
1159 1161 p4 (perforce version control system) experience.
1160 1162 Adds %p4 magic with p4 command completion and
1161 1163 automatic -G argument (marshall output as python dict)
1162 1164
1163 1165 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
1164 1166
1165 1167 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
1166 1168 stop marks.
1167 1169 (ClearingMixin): a simple mixin to easily make a Demo class clear
1168 1170 the screen in between blocks and have empty marquees. The
1169 1171 ClearDemo and ClearIPDemo classes that use it are included.
1170 1172
1171 1173 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
1172 1174
1173 1175 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
1174 1176 protect against exceptions at Python shutdown time. Patch
1175 1177 sumbmitted to upstream.
1176 1178
1177 1179 2007-02-14 Walter Doerwald <walter@livinglogic.de>
1178 1180
1179 1181 * IPython/Extensions/ibrowse.py: If entering the first object level
1180 1182 (i.e. the object for which the browser has been started) fails,
1181 1183 now the error is raised directly (aborting the browser) instead of
1182 1184 running into an empty levels list later.
1183 1185
1184 1186 2007-02-03 Walter Doerwald <walter@livinglogic.de>
1185 1187
1186 1188 * IPython/Extensions/ipipe.py: Add an xrepr implementation
1187 1189 for the noitem object.
1188 1190
1189 1191 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
1190 1192
1191 1193 * IPython/completer.py (Completer.attr_matches): Fix small
1192 1194 tab-completion bug with Enthought Traits objects with units.
1193 1195 Thanks to a bug report by Tom Denniston
1194 1196 <tom.denniston-AT-alum.dartmouth.org>.
1195 1197
1196 1198 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
1197 1199
1198 1200 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
1199 1201 bug where only .ipy or .py would be completed. Once the first
1200 1202 argument to %run has been given, all completions are valid because
1201 1203 they are the arguments to the script, which may well be non-python
1202 1204 filenames.
1203 1205
1204 1206 * IPython/irunner.py (InteractiveRunner.run_source): major updates
1205 1207 to irunner to allow it to correctly support real doctesting of
1206 1208 out-of-process ipython code.
1207 1209
1208 1210 * IPython/Magic.py (magic_cd): Make the setting of the terminal
1209 1211 title an option (-noterm_title) because it completely breaks
1210 1212 doctesting.
1211 1213
1212 1214 * IPython/demo.py: fix IPythonDemo class that was not actually working.
1213 1215
1214 1216 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
1215 1217
1216 1218 * IPython/irunner.py (main): fix small bug where extensions were
1217 1219 not being correctly recognized.
1218 1220
1219 1221 2007-01-23 Walter Doerwald <walter@livinglogic.de>
1220 1222
1221 1223 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
1222 1224 a string containing a single line yields the string itself as the
1223 1225 only item.
1224 1226
1225 1227 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
1226 1228 object if it's the same as the one on the last level (This avoids
1227 1229 infinite recursion for one line strings).
1228 1230
1229 1231 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1230 1232
1231 1233 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
1232 1234 all output streams before printing tracebacks. This ensures that
1233 1235 user output doesn't end up interleaved with traceback output.
1234 1236
1235 1237 2007-01-10 Ville Vainio <vivainio@gmail.com>
1236 1238
1237 1239 * Extensions/envpersist.py: Turbocharged %env that remembers
1238 1240 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
1239 1241 "%env VISUAL=jed".
1240 1242
1241 1243 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
1242 1244
1243 1245 * IPython/iplib.py (showtraceback): ensure that we correctly call
1244 1246 custom handlers in all cases (some with pdb were slipping through,
1245 1247 but I'm not exactly sure why).
1246 1248
1247 1249 * IPython/Debugger.py (Tracer.__init__): added new class to
1248 1250 support set_trace-like usage of IPython's enhanced debugger.
1249 1251
1250 1252 2006-12-24 Ville Vainio <vivainio@gmail.com>
1251 1253
1252 1254 * ipmaker.py: more informative message when ipy_user_conf
1253 1255 import fails (suggest running %upgrade).
1254 1256
1255 1257 * tools/run_ipy_in_profiler.py: Utility to see where
1256 1258 the time during IPython startup is spent.
1257 1259
1258 1260 2006-12-20 Ville Vainio <vivainio@gmail.com>
1259 1261
1260 1262 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
1261 1263
1262 1264 * ipapi.py: Add new ipapi method, expand_alias.
1263 1265
1264 1266 * Release.py: Bump up version to 0.7.4.svn
1265 1267
1266 1268 2006-12-17 Ville Vainio <vivainio@gmail.com>
1267 1269
1268 1270 * Extensions/jobctrl.py: Fixed &cmd arg arg...
1269 1271 to work properly on posix too
1270 1272
1271 1273 * Release.py: Update revnum (version is still just 0.7.3).
1272 1274
1273 1275 2006-12-15 Ville Vainio <vivainio@gmail.com>
1274 1276
1275 1277 * scripts/ipython_win_post_install: create ipython.py in
1276 1278 prefix + "/scripts".
1277 1279
1278 1280 * Release.py: Update version to 0.7.3.
1279 1281
1280 1282 2006-12-14 Ville Vainio <vivainio@gmail.com>
1281 1283
1282 1284 * scripts/ipython_win_post_install: Overwrite old shortcuts
1283 1285 if they already exist
1284 1286
1285 1287 * Release.py: release 0.7.3rc2
1286 1288
1287 1289 2006-12-13 Ville Vainio <vivainio@gmail.com>
1288 1290
1289 1291 * Branch and update Release.py for 0.7.3rc1
1290 1292
1291 1293 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
1292 1294
1293 1295 * IPython/Shell.py (IPShellWX): update for current WX naming
1294 1296 conventions, to avoid a deprecation warning with current WX
1295 1297 versions. Thanks to a report by Danny Shevitz.
1296 1298
1297 1299 2006-12-12 Ville Vainio <vivainio@gmail.com>
1298 1300
1299 1301 * ipmaker.py: apply david cournapeau's patch to make
1300 1302 import_some work properly even when ipythonrc does
1301 1303 import_some on empty list (it was an old bug!).
1302 1304
1303 1305 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
1304 1306 Add deprecation note to ipythonrc and a url to wiki
1305 1307 in ipy_user_conf.py
1306 1308
1307 1309
1308 1310 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
1309 1311 as if it was typed on IPython command prompt, i.e.
1310 1312 as IPython script.
1311 1313
1312 1314 * example-magic.py, magic_grepl.py: remove outdated examples
1313 1315
1314 1316 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
1315 1317
1316 1318 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
1317 1319 is called before any exception has occurred.
1318 1320
1319 1321 2006-12-08 Ville Vainio <vivainio@gmail.com>
1320 1322
1321 1323 * Extensions/ipy_stock_completers.py: fix cd completer
1322 1324 to translate /'s to \'s again.
1323 1325
1324 1326 * completer.py: prevent traceback on file completions w/
1325 1327 backslash.
1326 1328
1327 1329 * Release.py: Update release number to 0.7.3b3 for release
1328 1330
1329 1331 2006-12-07 Ville Vainio <vivainio@gmail.com>
1330 1332
1331 1333 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
1332 1334 while executing external code. Provides more shell-like behaviour
1333 1335 and overall better response to ctrl + C / ctrl + break.
1334 1336
1335 1337 * tools/make_tarball.py: new script to create tarball straight from svn
1336 1338 (setup.py sdist doesn't work on win32).
1337 1339
1338 1340 * Extensions/ipy_stock_completers.py: fix cd completer to give up
1339 1341 on dirnames with spaces and use the default completer instead.
1340 1342
1341 1343 * Revision.py: Change version to 0.7.3b2 for release.
1342 1344
1343 1345 2006-12-05 Ville Vainio <vivainio@gmail.com>
1344 1346
1345 1347 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
1346 1348 pydb patch 4 (rm debug printing, py 2.5 checking)
1347 1349
1348 1350 2006-11-30 Walter Doerwald <walter@livinglogic.de>
1349 1351 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
1350 1352 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
1351 1353 "refreshfind" (mapped to "R") does the same but tries to go back to the same
1352 1354 object the cursor was on before the refresh. The command "markrange" is
1353 1355 mapped to "%" now.
1354 1356 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
1355 1357
1356 1358 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
1357 1359
1358 1360 * IPython/Magic.py (magic_debug): new %debug magic to activate the
1359 1361 interactive debugger on the last traceback, without having to call
1360 1362 %pdb and rerun your code. Made minor changes in various modules,
1361 1363 should automatically recognize pydb if available.
1362 1364
1363 1365 2006-11-28 Ville Vainio <vivainio@gmail.com>
1364 1366
1365 1367 * completer.py: If the text start with !, show file completions
1366 1368 properly. This helps when trying to complete command name
1367 1369 for shell escapes.
1368 1370
1369 1371 2006-11-27 Ville Vainio <vivainio@gmail.com>
1370 1372
1371 1373 * ipy_stock_completers.py: bzr completer submitted by Stefan van
1372 1374 der Walt. Clean up svn and hg completers by using a common
1373 1375 vcs_completer.
1374 1376
1375 1377 2006-11-26 Ville Vainio <vivainio@gmail.com>
1376 1378
1377 1379 * Remove ipconfig and %config; you should use _ip.options structure
1378 1380 directly instead!
1379 1381
1380 1382 * genutils.py: add wrap_deprecated function for deprecating callables
1381 1383
1382 1384 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
1383 1385 _ip.system instead. ipalias is redundant.
1384 1386
1385 1387 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
1386 1388 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
1387 1389 explicit.
1388 1390
1389 1391 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
1390 1392 completer. Try it by entering 'hg ' and pressing tab.
1391 1393
1392 1394 * macro.py: Give Macro a useful __repr__ method
1393 1395
1394 1396 * Magic.py: %whos abbreviates the typename of Macro for brevity.
1395 1397
1396 1398 2006-11-24 Walter Doerwald <walter@livinglogic.de>
1397 1399 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
1398 1400 we don't get a duplicate ipipe module, where registration of the xrepr
1399 1401 implementation for Text is useless.
1400 1402
1401 1403 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
1402 1404
1403 1405 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
1404 1406
1405 1407 2006-11-24 Ville Vainio <vivainio@gmail.com>
1406 1408
1407 1409 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
1408 1410 try to use "cProfile" instead of the slower pure python
1409 1411 "profile"
1410 1412
1411 1413 2006-11-23 Ville Vainio <vivainio@gmail.com>
1412 1414
1413 1415 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
1414 1416 Qt+IPython+Designer link in documentation.
1415 1417
1416 1418 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
1417 1419 correct Pdb object to %pydb.
1418 1420
1419 1421
1420 1422 2006-11-22 Walter Doerwald <walter@livinglogic.de>
1421 1423 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
1422 1424 generic xrepr(), otherwise the list implementation would kick in.
1423 1425
1424 1426 2006-11-21 Ville Vainio <vivainio@gmail.com>
1425 1427
1426 1428 * upgrade_dir.py: Now actually overwrites a nonmodified user file
1427 1429 with one from UserConfig.
1428 1430
1429 1431 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
1430 1432 it was missing which broke the sh profile.
1431 1433
1432 1434 * completer.py: file completer now uses explicit '/' instead
1433 1435 of os.path.join, expansion of 'foo' was broken on win32
1434 1436 if there was one directory with name 'foobar'.
1435 1437
1436 1438 * A bunch of patches from Kirill Smelkov:
1437 1439
1438 1440 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
1439 1441
1440 1442 * [patch 7/9] Implement %page -r (page in raw mode) -
1441 1443
1442 1444 * [patch 5/9] ScientificPython webpage has moved
1443 1445
1444 1446 * [patch 4/9] The manual mentions %ds, should be %dhist
1445 1447
1446 1448 * [patch 3/9] Kill old bits from %prun doc.
1447 1449
1448 1450 * [patch 1/9] Fix typos here and there.
1449 1451
1450 1452 2006-11-08 Ville Vainio <vivainio@gmail.com>
1451 1453
1452 1454 * completer.py (attr_matches): catch all exceptions raised
1453 1455 by eval of expr with dots.
1454 1456
1455 1457 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
1456 1458
1457 1459 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
1458 1460 input if it starts with whitespace. This allows you to paste
1459 1461 indented input from any editor without manually having to type in
1460 1462 the 'if 1:', which is convenient when working interactively.
1461 1463 Slightly modifed version of a patch by Bo Peng
1462 1464 <bpeng-AT-rice.edu>.
1463 1465
1464 1466 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1465 1467
1466 1468 * IPython/irunner.py (main): modified irunner so it automatically
1467 1469 recognizes the right runner to use based on the extension (.py for
1468 1470 python, .ipy for ipython and .sage for sage).
1469 1471
1470 1472 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
1471 1473 visible in ipapi as ip.config(), to programatically control the
1472 1474 internal rc object. There's an accompanying %config magic for
1473 1475 interactive use, which has been enhanced to match the
1474 1476 funtionality in ipconfig.
1475 1477
1476 1478 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
1477 1479 so it's not just a toggle, it now takes an argument. Add support
1478 1480 for a customizable header when making system calls, as the new
1479 1481 system_header variable in the ipythonrc file.
1480 1482
1481 1483 2006-11-03 Walter Doerwald <walter@livinglogic.de>
1482 1484
1483 1485 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
1484 1486 generic functions (using Philip J. Eby's simplegeneric package).
1485 1487 This makes it possible to customize the display of third-party classes
1486 1488 without having to monkeypatch them. xiter() no longer supports a mode
1487 1489 argument and the XMode class has been removed. The same functionality can
1488 1490 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
1489 1491 One consequence of the switch to generic functions is that xrepr() and
1490 1492 xattrs() implementation must define the default value for the mode
1491 1493 argument themselves and xattrs() implementations must return real
1492 1494 descriptors.
1493 1495
1494 1496 * IPython/external: This new subpackage will contain all third-party
1495 1497 packages that are bundled with IPython. (The first one is simplegeneric).
1496 1498
1497 1499 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
1498 1500 directory which as been dropped in r1703.
1499 1501
1500 1502 * IPython/Extensions/ipipe.py (iless): Fixed.
1501 1503
1502 1504 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
1503 1505
1504 1506 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1505 1507
1506 1508 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
1507 1509 handling in variable expansion so that shells and magics recognize
1508 1510 function local scopes correctly. Bug reported by Brian.
1509 1511
1510 1512 * scripts/ipython: remove the very first entry in sys.path which
1511 1513 Python auto-inserts for scripts, so that sys.path under IPython is
1512 1514 as similar as possible to that under plain Python.
1513 1515
1514 1516 * IPython/completer.py (IPCompleter.file_matches): Fix
1515 1517 tab-completion so that quotes are not closed unless the completion
1516 1518 is unambiguous. After a request by Stefan. Minor cleanups in
1517 1519 ipy_stock_completers.
1518 1520
1519 1521 2006-11-02 Ville Vainio <vivainio@gmail.com>
1520 1522
1521 1523 * ipy_stock_completers.py: Add %run and %cd completers.
1522 1524
1523 1525 * completer.py: Try running custom completer for both
1524 1526 "foo" and "%foo" if the command is just "foo". Ignore case
1525 1527 when filtering possible completions.
1526 1528
1527 1529 * UserConfig/ipy_user_conf.py: install stock completers as default
1528 1530
1529 1531 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
1530 1532 simplified readline history save / restore through a wrapper
1531 1533 function
1532 1534
1533 1535
1534 1536 2006-10-31 Ville Vainio <vivainio@gmail.com>
1535 1537
1536 1538 * strdispatch.py, completer.py, ipy_stock_completers.py:
1537 1539 Allow str_key ("command") in completer hooks. Implement
1538 1540 trivial completer for 'import' (stdlib modules only). Rename
1539 1541 ipy_linux_package_managers.py to ipy_stock_completers.py.
1540 1542 SVN completer.
1541 1543
1542 1544 * Extensions/ledit.py: %magic line editor for easily and
1543 1545 incrementally manipulating lists of strings. The magic command
1544 1546 name is %led.
1545 1547
1546 1548 2006-10-30 Ville Vainio <vivainio@gmail.com>
1547 1549
1548 1550 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
1549 1551 Bernsteins's patches for pydb integration.
1550 1552 http://bashdb.sourceforge.net/pydb/
1551 1553
1552 1554 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
1553 1555 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
1554 1556 custom completer hook to allow the users to implement their own
1555 1557 completers. See ipy_linux_package_managers.py for example. The
1556 1558 hook name is 'complete_command'.
1557 1559
1558 1560 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
1559 1561
1560 1562 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
1561 1563 Numeric leftovers.
1562 1564
1563 1565 * ipython.el (py-execute-region): apply Stefan's patch to fix
1564 1566 garbled results if the python shell hasn't been previously started.
1565 1567
1566 1568 * IPython/genutils.py (arg_split): moved to genutils, since it's a
1567 1569 pretty generic function and useful for other things.
1568 1570
1569 1571 * IPython/OInspect.py (getsource): Add customizable source
1570 1572 extractor. After a request/patch form W. Stein (SAGE).
1571 1573
1572 1574 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
1573 1575 window size to a more reasonable value from what pexpect does,
1574 1576 since their choice causes wrapping bugs with long input lines.
1575 1577
1576 1578 2006-10-28 Ville Vainio <vivainio@gmail.com>
1577 1579
1578 1580 * Magic.py (%run): Save and restore the readline history from
1579 1581 file around %run commands to prevent side effects from
1580 1582 %runned programs that might use readline (e.g. pydb).
1581 1583
1582 1584 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
1583 1585 invoking the pydb enhanced debugger.
1584 1586
1585 1587 2006-10-23 Walter Doerwald <walter@livinglogic.de>
1586 1588
1587 1589 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
1588 1590 call the base class method and propagate the return value to
1589 1591 ifile. This is now done by path itself.
1590 1592
1591 1593 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1592 1594
1593 1595 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
1594 1596 api: set_crash_handler(), to expose the ability to change the
1595 1597 internal crash handler.
1596 1598
1597 1599 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
1598 1600 the various parameters of the crash handler so that apps using
1599 1601 IPython as their engine can customize crash handling. Ipmlemented
1600 1602 at the request of SAGE.
1601 1603
1602 1604 2006-10-14 Ville Vainio <vivainio@gmail.com>
1603 1605
1604 1606 * Magic.py, ipython.el: applied first "safe" part of Rocky
1605 1607 Bernstein's patch set for pydb integration.
1606 1608
1607 1609 * Magic.py (%unalias, %alias): %store'd aliases can now be
1608 1610 removed with '%unalias'. %alias w/o args now shows most
1609 1611 interesting (stored / manually defined) aliases last
1610 1612 where they catch the eye w/o scrolling.
1611 1613
1612 1614 * Magic.py (%rehashx), ext_rehashdir.py: files with
1613 1615 'py' extension are always considered executable, even
1614 1616 when not in PATHEXT environment variable.
1615 1617
1616 1618 2006-10-12 Ville Vainio <vivainio@gmail.com>
1617 1619
1618 1620 * jobctrl.py: Add new "jobctrl" extension for spawning background
1619 1621 processes with "&find /". 'import jobctrl' to try it out. Requires
1620 1622 'subprocess' module, standard in python 2.4+.
1621 1623
1622 1624 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
1623 1625 so if foo -> bar and bar -> baz, then foo -> baz.
1624 1626
1625 1627 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
1626 1628
1627 1629 * IPython/Magic.py (Magic.parse_options): add a new posix option
1628 1630 to allow parsing of input args in magics that doesn't strip quotes
1629 1631 (if posix=False). This also closes %timeit bug reported by
1630 1632 Stefan.
1631 1633
1632 1634 2006-10-03 Ville Vainio <vivainio@gmail.com>
1633 1635
1634 1636 * iplib.py (raw_input, interact): Return ValueError catching for
1635 1637 raw_input. Fixes infinite loop for sys.stdin.close() or
1636 1638 sys.stdout.close().
1637 1639
1638 1640 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1639 1641
1640 1642 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
1641 1643 to help in handling doctests. irunner is now pretty useful for
1642 1644 running standalone scripts and simulate a full interactive session
1643 1645 in a format that can be then pasted as a doctest.
1644 1646
1645 1647 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
1646 1648 on top of the default (useless) ones. This also fixes the nasty
1647 1649 way in which 2.5's Quitter() exits (reverted [1785]).
1648 1650
1649 1651 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
1650 1652 2.5.
1651 1653
1652 1654 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
1653 1655 color scheme is updated as well when color scheme is changed
1654 1656 interactively.
1655 1657
1656 1658 2006-09-27 Ville Vainio <vivainio@gmail.com>
1657 1659
1658 1660 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
1659 1661 infinite loop and just exit. It's a hack, but will do for a while.
1660 1662
1661 1663 2006-08-25 Walter Doerwald <walter@livinglogic.de>
1662 1664
1663 1665 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
1664 1666 the constructor, this makes it possible to get a list of only directories
1665 1667 or only files.
1666 1668
1667 1669 2006-08-12 Ville Vainio <vivainio@gmail.com>
1668 1670
1669 1671 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
1670 1672 they broke unittest
1671 1673
1672 1674 2006-08-11 Ville Vainio <vivainio@gmail.com>
1673 1675
1674 1676 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
1675 1677 by resolving issue properly, i.e. by inheriting FakeModule
1676 1678 from types.ModuleType. Pickling ipython interactive data
1677 1679 should still work as usual (testing appreciated).
1678 1680
1679 1681 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
1680 1682
1681 1683 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
1682 1684 running under python 2.3 with code from 2.4 to fix a bug with
1683 1685 help(). Reported by the Debian maintainers, Norbert Tretkowski
1684 1686 <norbert-AT-tretkowski.de> and Alexandre Fayolle
1685 1687 <afayolle-AT-debian.org>.
1686 1688
1687 1689 2006-08-04 Walter Doerwald <walter@livinglogic.de>
1688 1690
1689 1691 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
1690 1692 (which was displaying "quit" twice).
1691 1693
1692 1694 2006-07-28 Walter Doerwald <walter@livinglogic.de>
1693 1695
1694 1696 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
1695 1697 the mode argument).
1696 1698
1697 1699 2006-07-27 Walter Doerwald <walter@livinglogic.de>
1698 1700
1699 1701 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
1700 1702 not running under IPython.
1701 1703
1702 1704 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
1703 1705 and make it iterable (iterating over the attribute itself). Add two new
1704 1706 magic strings for __xattrs__(): If the string starts with "-", the attribute
1705 1707 will not be displayed in ibrowse's detail view (but it can still be
1706 1708 iterated over). This makes it possible to add attributes that are large
1707 1709 lists or generator methods to the detail view. Replace magic attribute names
1708 1710 and _attrname() and _getattr() with "descriptors": For each type of magic
1709 1711 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
1710 1712 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
1711 1713 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
1712 1714 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
1713 1715 are still supported.
1714 1716
1715 1717 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
1716 1718 fails in ibrowse.fetch(), the exception object is added as the last item
1717 1719 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
1718 1720 a generator throws an exception midway through execution.
1719 1721
1720 1722 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
1721 1723 encoding into methods.
1722 1724
1723 1725 2006-07-26 Ville Vainio <vivainio@gmail.com>
1724 1726
1725 1727 * iplib.py: history now stores multiline input as single
1726 1728 history entries. Patch by Jorgen Cederlof.
1727 1729
1728 1730 2006-07-18 Walter Doerwald <walter@livinglogic.de>
1729 1731
1730 1732 * IPython/Extensions/ibrowse.py: Make cursor visible over
1731 1733 non existing attributes.
1732 1734
1733 1735 2006-07-14 Walter Doerwald <walter@livinglogic.de>
1734 1736
1735 1737 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
1736 1738 error output of the running command doesn't mess up the screen.
1737 1739
1738 1740 2006-07-13 Walter Doerwald <walter@livinglogic.de>
1739 1741
1740 1742 * IPython/Extensions/ipipe.py (isort): Make isort usable without
1741 1743 argument. This sorts the items themselves.
1742 1744
1743 1745 2006-07-12 Walter Doerwald <walter@livinglogic.de>
1744 1746
1745 1747 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
1746 1748 Compile expression strings into code objects. This should speed
1747 1749 up ifilter and friends somewhat.
1748 1750
1749 1751 2006-07-08 Ville Vainio <vivainio@gmail.com>
1750 1752
1751 1753 * Magic.py: %cpaste now strips > from the beginning of lines
1752 1754 to ease pasting quoted code from emails. Contributed by
1753 1755 Stefan van der Walt.
1754 1756
1755 1757 2006-06-29 Ville Vainio <vivainio@gmail.com>
1756 1758
1757 1759 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
1758 1760 mode, patch contributed by Darren Dale. NEEDS TESTING!
1759 1761
1760 1762 2006-06-28 Walter Doerwald <walter@livinglogic.de>
1761 1763
1762 1764 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
1763 1765 a blue background. Fix fetching new display rows when the browser
1764 1766 scrolls more than a screenful (e.g. by using the goto command).
1765 1767
1766 1768 2006-06-27 Ville Vainio <vivainio@gmail.com>
1767 1769
1768 1770 * Magic.py (_inspect, _ofind) Apply David Huard's
1769 1771 patch for displaying the correct docstring for 'property'
1770 1772 attributes.
1771 1773
1772 1774 2006-06-23 Walter Doerwald <walter@livinglogic.de>
1773 1775
1774 1776 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
1775 1777 commands into the methods implementing them.
1776 1778
1777 1779 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
1778 1780
1779 1781 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
1780 1782 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
1781 1783 autoindent support was authored by Jin Liu.
1782 1784
1783 1785 2006-06-22 Walter Doerwald <walter@livinglogic.de>
1784 1786
1785 1787 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
1786 1788 for keymaps with a custom class that simplifies handling.
1787 1789
1788 1790 2006-06-19 Walter Doerwald <walter@livinglogic.de>
1789 1791
1790 1792 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
1791 1793 resizing. This requires Python 2.5 to work.
1792 1794
1793 1795 2006-06-16 Walter Doerwald <walter@livinglogic.de>
1794 1796
1795 1797 * IPython/Extensions/ibrowse.py: Add two new commands to
1796 1798 ibrowse: "hideattr" (mapped to "h") hides the attribute under
1797 1799 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
1798 1800 attributes again. Remapped the help command to "?". Display
1799 1801 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
1800 1802 as keys for the "home" and "end" commands. Add three new commands
1801 1803 to the input mode for "find" and friends: "delend" (CTRL-K)
1802 1804 deletes to the end of line. "incsearchup" searches upwards in the
1803 1805 command history for an input that starts with the text before the cursor.
1804 1806 "incsearchdown" does the same downwards. Removed a bogus mapping of
1805 1807 the x key to "delete".
1806 1808
1807 1809 2006-06-15 Ville Vainio <vivainio@gmail.com>
1808 1810
1809 1811 * iplib.py, hooks.py: Added new generate_prompt hook that can be
1810 1812 used to create prompts dynamically, instead of the "old" way of
1811 1813 assigning "magic" strings to prompt_in1 and prompt_in2. The old
1812 1814 way still works (it's invoked by the default hook), of course.
1813 1815
1814 1816 * Prompts.py: added generate_output_prompt hook for altering output
1815 1817 prompt
1816 1818
1817 1819 * Release.py: Changed version string to 0.7.3.svn.
1818 1820
1819 1821 2006-06-15 Walter Doerwald <walter@livinglogic.de>
1820 1822
1821 1823 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
1822 1824 the call to fetch() always tries to fetch enough data for at least one
1823 1825 full screen. This makes it possible to simply call moveto(0,0,True) in
1824 1826 the constructor. Fix typos and removed the obsolete goto attribute.
1825 1827
1826 1828 2006-06-12 Ville Vainio <vivainio@gmail.com>
1827 1829
1828 1830 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
1829 1831 allowing $variable interpolation within multiline statements,
1830 1832 though so far only with "sh" profile for a testing period.
1831 1833 The patch also enables splitting long commands with \ but it
1832 1834 doesn't work properly yet.
1833 1835
1834 1836 2006-06-12 Walter Doerwald <walter@livinglogic.de>
1835 1837
1836 1838 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
1837 1839 input history and the position of the cursor in the input history for
1838 1840 the find, findbackwards and goto command.
1839 1841
1840 1842 2006-06-10 Walter Doerwald <walter@livinglogic.de>
1841 1843
1842 1844 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
1843 1845 implements the basic functionality of browser commands that require
1844 1846 input. Reimplement the goto, find and findbackwards commands as
1845 1847 subclasses of _CommandInput. Add an input history and keymaps to those
1846 1848 commands. Add "\r" as a keyboard shortcut for the enterdefault and
1847 1849 execute commands.
1848 1850
1849 1851 2006-06-07 Ville Vainio <vivainio@gmail.com>
1850 1852
1851 1853 * iplib.py: ipython mybatch.ipy exits ipython immediately after
1852 1854 running the batch files instead of leaving the session open.
1853 1855
1854 1856 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
1855 1857
1856 1858 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
1857 1859 the original fix was incomplete. Patch submitted by W. Maier.
1858 1860
1859 1861 2006-06-07 Ville Vainio <vivainio@gmail.com>
1860 1862
1861 1863 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
1862 1864 Confirmation prompts can be supressed by 'quiet' option.
1863 1865 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
1864 1866
1865 1867 2006-06-06 *** Released version 0.7.2
1866 1868
1867 1869 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1868 1870
1869 1871 * IPython/Release.py (version): Made 0.7.2 final for release.
1870 1872 Repo tagged and release cut.
1871 1873
1872 1874 2006-06-05 Ville Vainio <vivainio@gmail.com>
1873 1875
1874 1876 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1875 1877 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1876 1878
1877 1879 * upgrade_dir.py: try import 'path' module a bit harder
1878 1880 (for %upgrade)
1879 1881
1880 1882 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1881 1883
1882 1884 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1883 1885 instead of looping 20 times.
1884 1886
1885 1887 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1886 1888 correctly at initialization time. Bug reported by Krishna Mohan
1887 1889 Gundu <gkmohan-AT-gmail.com> on the user list.
1888 1890
1889 1891 * IPython/Release.py (version): Mark 0.7.2 version to start
1890 1892 testing for release on 06/06.
1891 1893
1892 1894 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1893 1895
1894 1896 * scripts/irunner: thin script interface so users don't have to
1895 1897 find the module and call it as an executable, since modules rarely
1896 1898 live in people's PATH.
1897 1899
1898 1900 * IPython/irunner.py (InteractiveRunner.__init__): added
1899 1901 delaybeforesend attribute to control delays with newer versions of
1900 1902 pexpect. Thanks to detailed help from pexpect's author, Noah
1901 1903 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1902 1904 correctly (it works in NoColor mode).
1903 1905
1904 1906 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1905 1907 SAGE list, from improper log() calls.
1906 1908
1907 1909 2006-05-31 Ville Vainio <vivainio@gmail.com>
1908 1910
1909 1911 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1910 1912 with args in parens to work correctly with dirs that have spaces.
1911 1913
1912 1914 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1913 1915
1914 1916 * IPython/Logger.py (Logger.logstart): add option to log raw input
1915 1917 instead of the processed one. A -r flag was added to the
1916 1918 %logstart magic used for controlling logging.
1917 1919
1918 1920 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1919 1921
1920 1922 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1921 1923 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1922 1924 recognize the option. After a bug report by Will Maier. This
1923 1925 closes #64 (will do it after confirmation from W. Maier).
1924 1926
1925 1927 * IPython/irunner.py: New module to run scripts as if manually
1926 1928 typed into an interactive environment, based on pexpect. After a
1927 1929 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1928 1930 ipython-user list. Simple unittests in the tests/ directory.
1929 1931
1930 1932 * tools/release: add Will Maier, OpenBSD port maintainer, to
1931 1933 recepients list. We are now officially part of the OpenBSD ports:
1932 1934 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1933 1935 work.
1934 1936
1935 1937 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1936 1938
1937 1939 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1938 1940 so that it doesn't break tkinter apps.
1939 1941
1940 1942 * IPython/iplib.py (_prefilter): fix bug where aliases would
1941 1943 shadow variables when autocall was fully off. Reported by SAGE
1942 1944 author William Stein.
1943 1945
1944 1946 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1945 1947 at what detail level strings are computed when foo? is requested.
1946 1948 This allows users to ask for example that the string form of an
1947 1949 object is only computed when foo?? is called, or even never, by
1948 1950 setting the object_info_string_level >= 2 in the configuration
1949 1951 file. This new option has been added and documented. After a
1950 1952 request by SAGE to be able to control the printing of very large
1951 1953 objects more easily.
1952 1954
1953 1955 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1954 1956
1955 1957 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1956 1958 from sys.argv, to be 100% consistent with how Python itself works
1957 1959 (as seen for example with python -i file.py). After a bug report
1958 1960 by Jeffrey Collins.
1959 1961
1960 1962 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1961 1963 nasty bug which was preventing custom namespaces with -pylab,
1962 1964 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1963 1965 compatibility (long gone from mpl).
1964 1966
1965 1967 * IPython/ipapi.py (make_session): name change: create->make. We
1966 1968 use make in other places (ipmaker,...), it's shorter and easier to
1967 1969 type and say, etc. I'm trying to clean things before 0.7.2 so
1968 1970 that I can keep things stable wrt to ipapi in the chainsaw branch.
1969 1971
1970 1972 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1971 1973 python-mode recognizes our debugger mode. Add support for
1972 1974 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1973 1975 <m.liu.jin-AT-gmail.com> originally written by
1974 1976 doxgen-AT-newsmth.net (with minor modifications for xemacs
1975 1977 compatibility)
1976 1978
1977 1979 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1978 1980 tracebacks when walking the stack so that the stack tracking system
1979 1981 in emacs' python-mode can identify the frames correctly.
1980 1982
1981 1983 * IPython/ipmaker.py (make_IPython): make the internal (and
1982 1984 default config) autoedit_syntax value false by default. Too many
1983 1985 users have complained to me (both on and off-list) about problems
1984 1986 with this option being on by default, so I'm making it default to
1985 1987 off. It can still be enabled by anyone via the usual mechanisms.
1986 1988
1987 1989 * IPython/completer.py (Completer.attr_matches): add support for
1988 1990 PyCrust-style _getAttributeNames magic method. Patch contributed
1989 1991 by <mscott-AT-goldenspud.com>. Closes #50.
1990 1992
1991 1993 * IPython/iplib.py (InteractiveShell.__init__): remove the
1992 1994 deletion of exit/quit from __builtin__, which can break
1993 1995 third-party tools like the Zope debugging console. The
1994 1996 %exit/%quit magics remain. In general, it's probably a good idea
1995 1997 not to delete anything from __builtin__, since we never know what
1996 1998 that will break. In any case, python now (for 2.5) will support
1997 1999 'real' exit/quit, so this issue is moot. Closes #55.
1998 2000
1999 2001 * IPython/genutils.py (with_obj): rename the 'with' function to
2000 2002 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
2001 2003 becomes a language keyword. Closes #53.
2002 2004
2003 2005 * IPython/FakeModule.py (FakeModule.__init__): add a proper
2004 2006 __file__ attribute to this so it fools more things into thinking
2005 2007 it is a real module. Closes #59.
2006 2008
2007 2009 * IPython/Magic.py (magic_edit): add -n option to open the editor
2008 2010 at a specific line number. After a patch by Stefan van der Walt.
2009 2011
2010 2012 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
2011 2013
2012 2014 * IPython/iplib.py (edit_syntax_error): fix crash when for some
2013 2015 reason the file could not be opened. After automatic crash
2014 2016 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
2015 2017 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
2016 2018 (_should_recompile): Don't fire editor if using %bg, since there
2017 2019 is no file in the first place. From the same report as above.
2018 2020 (raw_input): protect against faulty third-party prefilters. After
2019 2021 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
2020 2022 while running under SAGE.
2021 2023
2022 2024 2006-05-23 Ville Vainio <vivainio@gmail.com>
2023 2025
2024 2026 * ipapi.py: Stripped down ip.to_user_ns() to work only as
2025 2027 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
2026 2028 now returns None (again), unless dummy is specifically allowed by
2027 2029 ipapi.get(allow_dummy=True).
2028 2030
2029 2031 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
2030 2032
2031 2033 * IPython: remove all 2.2-compatibility objects and hacks from
2032 2034 everywhere, since we only support 2.3 at this point. Docs
2033 2035 updated.
2034 2036
2035 2037 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
2036 2038 Anything requiring extra validation can be turned into a Python
2037 2039 property in the future. I used a property for the db one b/c
2038 2040 there was a nasty circularity problem with the initialization
2039 2041 order, which right now I don't have time to clean up.
2040 2042
2041 2043 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
2042 2044 another locking bug reported by Jorgen. I'm not 100% sure though,
2043 2045 so more testing is needed...
2044 2046
2045 2047 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
2046 2048
2047 2049 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
2048 2050 local variables from any routine in user code (typically executed
2049 2051 with %run) directly into the interactive namespace. Very useful
2050 2052 when doing complex debugging.
2051 2053 (IPythonNotRunning): Changed the default None object to a dummy
2052 2054 whose attributes can be queried as well as called without
2053 2055 exploding, to ease writing code which works transparently both in
2054 2056 and out of ipython and uses some of this API.
2055 2057
2056 2058 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
2057 2059
2058 2060 * IPython/hooks.py (result_display): Fix the fact that our display
2059 2061 hook was using str() instead of repr(), as the default python
2060 2062 console does. This had gone unnoticed b/c it only happened if
2061 2063 %Pprint was off, but the inconsistency was there.
2062 2064
2063 2065 2006-05-15 Ville Vainio <vivainio@gmail.com>
2064 2066
2065 2067 * Oinspect.py: Only show docstring for nonexisting/binary files
2066 2068 when doing object??, closing ticket #62
2067 2069
2068 2070 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
2069 2071
2070 2072 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
2071 2073 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
2072 2074 was being released in a routine which hadn't checked if it had
2073 2075 been the one to acquire it.
2074 2076
2075 2077 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
2076 2078
2077 2079 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
2078 2080
2079 2081 2006-04-11 Ville Vainio <vivainio@gmail.com>
2080 2082
2081 2083 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
2082 2084 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
2083 2085 prefilters, allowing stuff like magics and aliases in the file.
2084 2086
2085 2087 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
2086 2088 added. Supported now are "%clear in" and "%clear out" (clear input and
2087 2089 output history, respectively). Also fixed CachedOutput.flush to
2088 2090 properly flush the output cache.
2089 2091
2090 2092 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
2091 2093 half-success (and fail explicitly).
2092 2094
2093 2095 2006-03-28 Ville Vainio <vivainio@gmail.com>
2094 2096
2095 2097 * iplib.py: Fix quoting of aliases so that only argless ones
2096 2098 are quoted
2097 2099
2098 2100 2006-03-28 Ville Vainio <vivainio@gmail.com>
2099 2101
2100 2102 * iplib.py: Quote aliases with spaces in the name.
2101 2103 "c:\program files\blah\bin" is now legal alias target.
2102 2104
2103 2105 * ext_rehashdir.py: Space no longer allowed as arg
2104 2106 separator, since space is legal in path names.
2105 2107
2106 2108 2006-03-16 Ville Vainio <vivainio@gmail.com>
2107 2109
2108 2110 * upgrade_dir.py: Take path.py from Extensions, correcting
2109 2111 %upgrade magic
2110 2112
2111 2113 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
2112 2114
2113 2115 * hooks.py: Only enclose editor binary in quotes if legal and
2114 2116 necessary (space in the name, and is an existing file). Fixes a bug
2115 2117 reported by Zachary Pincus.
2116 2118
2117 2119 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
2118 2120
2119 2121 * Manual: thanks to a tip on proper color handling for Emacs, by
2120 2122 Eric J Haywiser <ejh1-AT-MIT.EDU>.
2121 2123
2122 2124 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
2123 2125 by applying the provided patch. Thanks to Liu Jin
2124 2126 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
2125 2127 XEmacs/Linux, I'm trusting the submitter that it actually helps
2126 2128 under win32/GNU Emacs. Will revisit if any problems are reported.
2127 2129
2128 2130 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
2129 2131
2130 2132 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
2131 2133 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
2132 2134
2133 2135 2006-03-12 Ville Vainio <vivainio@gmail.com>
2134 2136
2135 2137 * Magic.py (magic_timeit): Added %timeit magic, contributed by
2136 2138 Torsten Marek.
2137 2139
2138 2140 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
2139 2141
2140 2142 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
2141 2143 line ranges works again.
2142 2144
2143 2145 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
2144 2146
2145 2147 * IPython/iplib.py (showtraceback): add back sys.last_traceback
2146 2148 and friends, after a discussion with Zach Pincus on ipython-user.
2147 2149 I'm not 100% sure, but after thinking about it quite a bit, it may
2148 2150 be OK. Testing with the multithreaded shells didn't reveal any
2149 2151 problems, but let's keep an eye out.
2150 2152
2151 2153 In the process, I fixed a few things which were calling
2152 2154 self.InteractiveTB() directly (like safe_execfile), which is a
2153 2155 mistake: ALL exception reporting should be done by calling
2154 2156 self.showtraceback(), which handles state and tab-completion and
2155 2157 more.
2156 2158
2157 2159 2006-03-01 Ville Vainio <vivainio@gmail.com>
2158 2160
2159 2161 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
2160 2162 To use, do "from ipipe import *".
2161 2163
2162 2164 2006-02-24 Ville Vainio <vivainio@gmail.com>
2163 2165
2164 2166 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
2165 2167 "cleanly" and safely than the older upgrade mechanism.
2166 2168
2167 2169 2006-02-21 Ville Vainio <vivainio@gmail.com>
2168 2170
2169 2171 * Magic.py: %save works again.
2170 2172
2171 2173 2006-02-15 Ville Vainio <vivainio@gmail.com>
2172 2174
2173 2175 * Magic.py: %Pprint works again
2174 2176
2175 2177 * Extensions/ipy_sane_defaults.py: Provide everything provided
2176 2178 in default ipythonrc, to make it possible to have a completely empty
2177 2179 ipythonrc (and thus completely rc-file free configuration)
2178 2180
2179 2181 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
2180 2182
2181 2183 * IPython/hooks.py (editor): quote the call to the editor command,
2182 2184 to allow commands with spaces in them. Problem noted by watching
2183 2185 Ian Oswald's video about textpad under win32 at
2184 2186 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
2185 2187
2186 2188 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
2187 2189 describing magics (we haven't used @ for a loong time).
2188 2190
2189 2191 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
2190 2192 contributed by marienz to close
2191 2193 http://www.scipy.net/roundup/ipython/issue53.
2192 2194
2193 2195 2006-02-10 Ville Vainio <vivainio@gmail.com>
2194 2196
2195 2197 * genutils.py: getoutput now works in win32 too
2196 2198
2197 2199 * completer.py: alias and magic completion only invoked
2198 2200 at the first "item" in the line, to avoid "cd %store"
2199 2201 nonsense.
2200 2202
2201 2203 2006-02-09 Ville Vainio <vivainio@gmail.com>
2202 2204
2203 2205 * test/*: Added a unit testing framework (finally).
2204 2206 '%run runtests.py' to run test_*.
2205 2207
2206 2208 * ipapi.py: Exposed runlines and set_custom_exc
2207 2209
2208 2210 2006-02-07 Ville Vainio <vivainio@gmail.com>
2209 2211
2210 2212 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
2211 2213 instead use "f(1 2)" as before.
2212 2214
2213 2215 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
2214 2216
2215 2217 * IPython/demo.py (IPythonDemo): Add new classes to the demo
2216 2218 facilities, for demos processed by the IPython input filter
2217 2219 (IPythonDemo), and for running a script one-line-at-a-time as a
2218 2220 demo, both for pure Python (LineDemo) and for IPython-processed
2219 2221 input (IPythonLineDemo). After a request by Dave Kohel, from the
2220 2222 SAGE team.
2221 2223 (Demo.edit): added an edit() method to the demo objects, to edit
2222 2224 the in-memory copy of the last executed block.
2223 2225
2224 2226 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
2225 2227 processing to %edit, %macro and %save. These commands can now be
2226 2228 invoked on the unprocessed input as it was typed by the user
2227 2229 (without any prefilters applied). After requests by the SAGE team
2228 2230 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
2229 2231
2230 2232 2006-02-01 Ville Vainio <vivainio@gmail.com>
2231 2233
2232 2234 * setup.py, eggsetup.py: easy_install ipython==dev works
2233 2235 correctly now (on Linux)
2234 2236
2235 2237 * ipy_user_conf,ipmaker: user config changes, removed spurious
2236 2238 warnings
2237 2239
2238 2240 * iplib: if rc.banner is string, use it as is.
2239 2241
2240 2242 * Magic: %pycat accepts a string argument and pages it's contents.
2241 2243
2242 2244
2243 2245 2006-01-30 Ville Vainio <vivainio@gmail.com>
2244 2246
2245 2247 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
2246 2248 Now %store and bookmarks work through PickleShare, meaning that
2247 2249 concurrent access is possible and all ipython sessions see the
2248 2250 same database situation all the time, instead of snapshot of
2249 2251 the situation when the session was started. Hence, %bookmark
2250 2252 results are immediately accessible from othes sessions. The database
2251 2253 is also available for use by user extensions. See:
2252 2254 http://www.python.org/pypi/pickleshare
2253 2255
2254 2256 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
2255 2257
2256 2258 * aliases can now be %store'd
2257 2259
2258 2260 * path.py moved to Extensions so that pickleshare does not need
2259 2261 IPython-specific import. Extensions added to pythonpath right
2260 2262 at __init__.
2261 2263
2262 2264 * iplib.py: ipalias deprecated/redundant; aliases are converted and
2263 2265 called with _ip.system and the pre-transformed command string.
2264 2266
2265 2267 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
2266 2268
2267 2269 * IPython/iplib.py (interact): Fix that we were not catching
2268 2270 KeyboardInterrupt exceptions properly. I'm not quite sure why the
2269 2271 logic here had to change, but it's fixed now.
2270 2272
2271 2273 2006-01-29 Ville Vainio <vivainio@gmail.com>
2272 2274
2273 2275 * iplib.py: Try to import pyreadline on Windows.
2274 2276
2275 2277 2006-01-27 Ville Vainio <vivainio@gmail.com>
2276 2278
2277 2279 * iplib.py: Expose ipapi as _ip in builtin namespace.
2278 2280 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
2279 2281 and ip_set_hook (-> _ip.set_hook) redundant. % and !
2280 2282 syntax now produce _ip.* variant of the commands.
2281 2283
2282 2284 * "_ip.options().autoedit_syntax = 2" automatically throws
2283 2285 user to editor for syntax error correction without prompting.
2284 2286
2285 2287 2006-01-27 Ville Vainio <vivainio@gmail.com>
2286 2288
2287 2289 * ipmaker.py: Give "realistic" sys.argv for scripts (without
2288 2290 'ipython' at argv[0]) executed through command line.
2289 2291 NOTE: this DEPRECATES calling ipython with multiple scripts
2290 2292 ("ipython a.py b.py c.py")
2291 2293
2292 2294 * iplib.py, hooks.py: Added configurable input prefilter,
2293 2295 named 'input_prefilter'. See ext_rescapture.py for example
2294 2296 usage.
2295 2297
2296 2298 * ext_rescapture.py, Magic.py: Better system command output capture
2297 2299 through 'var = !ls' (deprecates user-visible %sc). Same notation
2298 2300 applies for magics, 'var = %alias' assigns alias list to var.
2299 2301
2300 2302 * ipapi.py: added meta() for accessing extension-usable data store.
2301 2303
2302 2304 * iplib.py: added InteractiveShell.getapi(). New magics should be
2303 2305 written doing self.getapi() instead of using the shell directly.
2304 2306
2305 2307 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
2306 2308 %store foo >> ~/myfoo.txt to store variables to files (in clean
2307 2309 textual form, not a restorable pickle).
2308 2310
2309 2311 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
2310 2312
2311 2313 * usage.py, Magic.py: added %quickref
2312 2314
2313 2315 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
2314 2316
2315 2317 * GetoptErrors when invoking magics etc. with wrong args
2316 2318 are now more helpful:
2317 2319 GetoptError: option -l not recognized (allowed: "qb" )
2318 2320
2319 2321 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
2320 2322
2321 2323 * IPython/demo.py (Demo.show): Flush stdout after each block, so
2322 2324 computationally intensive blocks don't appear to stall the demo.
2323 2325
2324 2326 2006-01-24 Ville Vainio <vivainio@gmail.com>
2325 2327
2326 2328 * iplib.py, hooks.py: 'result_display' hook can return a non-None
2327 2329 value to manipulate resulting history entry.
2328 2330
2329 2331 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
2330 2332 to instance methods of IPApi class, to make extending an embedded
2331 2333 IPython feasible. See ext_rehashdir.py for example usage.
2332 2334
2333 2335 * Merged 1071-1076 from branches/0.7.1
2334 2336
2335 2337
2336 2338 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
2337 2339
2338 2340 * tools/release (daystamp): Fix build tools to use the new
2339 2341 eggsetup.py script to build lightweight eggs.
2340 2342
2341 2343 * Applied changesets 1062 and 1064 before 0.7.1 release.
2342 2344
2343 2345 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
2344 2346 see the raw input history (without conversions like %ls ->
2345 2347 ipmagic("ls")). After a request from W. Stein, SAGE
2346 2348 (http://modular.ucsd.edu/sage) developer. This information is
2347 2349 stored in the input_hist_raw attribute of the IPython instance, so
2348 2350 developers can access it if needed (it's an InputList instance).
2349 2351
2350 2352 * Versionstring = 0.7.2.svn
2351 2353
2352 2354 * eggsetup.py: A separate script for constructing eggs, creates
2353 2355 proper launch scripts even on Windows (an .exe file in
2354 2356 \python24\scripts).
2355 2357
2356 2358 * ipapi.py: launch_new_instance, launch entry point needed for the
2357 2359 egg.
2358 2360
2359 2361 2006-01-23 Ville Vainio <vivainio@gmail.com>
2360 2362
2361 2363 * Added %cpaste magic for pasting python code
2362 2364
2363 2365 2006-01-22 Ville Vainio <vivainio@gmail.com>
2364 2366
2365 2367 * Merge from branches/0.7.1 into trunk, revs 1052-1057
2366 2368
2367 2369 * Versionstring = 0.7.2.svn
2368 2370
2369 2371 * eggsetup.py: A separate script for constructing eggs, creates
2370 2372 proper launch scripts even on Windows (an .exe file in
2371 2373 \python24\scripts).
2372 2374
2373 2375 * ipapi.py: launch_new_instance, launch entry point needed for the
2374 2376 egg.
2375 2377
2376 2378 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
2377 2379
2378 2380 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
2379 2381 %pfile foo would print the file for foo even if it was a binary.
2380 2382 Now, extensions '.so' and '.dll' are skipped.
2381 2383
2382 2384 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
2383 2385 bug, where macros would fail in all threaded modes. I'm not 100%
2384 2386 sure, so I'm going to put out an rc instead of making a release
2385 2387 today, and wait for feedback for at least a few days.
2386 2388
2387 2389 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
2388 2390 it...) the handling of pasting external code with autoindent on.
2389 2391 To get out of a multiline input, the rule will appear for most
2390 2392 users unchanged: two blank lines or change the indent level
2391 2393 proposed by IPython. But there is a twist now: you can
2392 2394 add/subtract only *one or two spaces*. If you add/subtract three
2393 2395 or more (unless you completely delete the line), IPython will
2394 2396 accept that line, and you'll need to enter a second one of pure
2395 2397 whitespace. I know it sounds complicated, but I can't find a
2396 2398 different solution that covers all the cases, with the right
2397 2399 heuristics. Hopefully in actual use, nobody will really notice
2398 2400 all these strange rules and things will 'just work'.
2399 2401
2400 2402 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
2401 2403
2402 2404 * IPython/iplib.py (interact): catch exceptions which can be
2403 2405 triggered asynchronously by signal handlers. Thanks to an
2404 2406 automatic crash report, submitted by Colin Kingsley
2405 2407 <tercel-AT-gentoo.org>.
2406 2408
2407 2409 2006-01-20 Ville Vainio <vivainio@gmail.com>
2408 2410
2409 2411 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
2410 2412 (%rehashdir, very useful, try it out) of how to extend ipython
2411 2413 with new magics. Also added Extensions dir to pythonpath to make
2412 2414 importing extensions easy.
2413 2415
2414 2416 * %store now complains when trying to store interactively declared
2415 2417 classes / instances of those classes.
2416 2418
2417 2419 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
2418 2420 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
2419 2421 if they exist, and ipy_user_conf.py with some defaults is created for
2420 2422 the user.
2421 2423
2422 2424 * Startup rehashing done by the config file, not InterpreterExec.
2423 2425 This means system commands are available even without selecting the
2424 2426 pysh profile. It's the sensible default after all.
2425 2427
2426 2428 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
2427 2429
2428 2430 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
2429 2431 multiline code with autoindent on working. But I am really not
2430 2432 sure, so this needs more testing. Will commit a debug-enabled
2431 2433 version for now, while I test it some more, so that Ville and
2432 2434 others may also catch any problems. Also made
2433 2435 self.indent_current_str() a method, to ensure that there's no
2434 2436 chance of the indent space count and the corresponding string
2435 2437 falling out of sync. All code needing the string should just call
2436 2438 the method.
2437 2439
2438 2440 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2439 2441
2440 2442 * IPython/Magic.py (magic_edit): fix check for when users don't
2441 2443 save their output files, the try/except was in the wrong section.
2442 2444
2443 2445 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2444 2446
2445 2447 * IPython/Magic.py (magic_run): fix __file__ global missing from
2446 2448 script's namespace when executed via %run. After a report by
2447 2449 Vivian.
2448 2450
2449 2451 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
2450 2452 when using python 2.4. The parent constructor changed in 2.4, and
2451 2453 we need to track it directly (we can't call it, as it messes up
2452 2454 readline and tab-completion inside our pdb would stop working).
2453 2455 After a bug report by R. Bernstein <rocky-AT-panix.com>.
2454 2456
2455 2457 2006-01-16 Ville Vainio <vivainio@gmail.com>
2456 2458
2457 2459 * Ipython/magic.py: Reverted back to old %edit functionality
2458 2460 that returns file contents on exit.
2459 2461
2460 2462 * IPython/path.py: Added Jason Orendorff's "path" module to
2461 2463 IPython tree, http://www.jorendorff.com/articles/python/path/.
2462 2464 You can get path objects conveniently through %sc, and !!, e.g.:
2463 2465 sc files=ls
2464 2466 for p in files.paths: # or files.p
2465 2467 print p,p.mtime
2466 2468
2467 2469 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
2468 2470 now work again without considering the exclusion regexp -
2469 2471 hence, things like ',foo my/path' turn to 'foo("my/path")'
2470 2472 instead of syntax error.
2471 2473
2472 2474
2473 2475 2006-01-14 Ville Vainio <vivainio@gmail.com>
2474 2476
2475 2477 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
2476 2478 ipapi decorators for python 2.4 users, options() provides access to rc
2477 2479 data.
2478 2480
2479 2481 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
2480 2482 as path separators (even on Linux ;-). Space character after
2481 2483 backslash (as yielded by tab completer) is still space;
2482 2484 "%cd long\ name" works as expected.
2483 2485
2484 2486 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
2485 2487 as "chain of command", with priority. API stays the same,
2486 2488 TryNext exception raised by a hook function signals that
2487 2489 current hook failed and next hook should try handling it, as
2488 2490 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
2489 2491 requested configurable display hook, which is now implemented.
2490 2492
2491 2493 2006-01-13 Ville Vainio <vivainio@gmail.com>
2492 2494
2493 2495 * IPython/platutils*.py: platform specific utility functions,
2494 2496 so far only set_term_title is implemented (change terminal
2495 2497 label in windowing systems). %cd now changes the title to
2496 2498 current dir.
2497 2499
2498 2500 * IPython/Release.py: Added myself to "authors" list,
2499 2501 had to create new files.
2500 2502
2501 2503 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
2502 2504 shell escape; not a known bug but had potential to be one in the
2503 2505 future.
2504 2506
2505 2507 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
2506 2508 extension API for IPython! See the module for usage example. Fix
2507 2509 OInspect for docstring-less magic functions.
2508 2510
2509 2511
2510 2512 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2511 2513
2512 2514 * IPython/iplib.py (raw_input): temporarily deactivate all
2513 2515 attempts at allowing pasting of code with autoindent on. It
2514 2516 introduced bugs (reported by Prabhu) and I can't seem to find a
2515 2517 robust combination which works in all cases. Will have to revisit
2516 2518 later.
2517 2519
2518 2520 * IPython/genutils.py: remove isspace() function. We've dropped
2519 2521 2.2 compatibility, so it's OK to use the string method.
2520 2522
2521 2523 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2522 2524
2523 2525 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
2524 2526 matching what NOT to autocall on, to include all python binary
2525 2527 operators (including things like 'and', 'or', 'is' and 'in').
2526 2528 Prompted by a bug report on 'foo & bar', but I realized we had
2527 2529 many more potential bug cases with other operators. The regexp is
2528 2530 self.re_exclude_auto, it's fairly commented.
2529 2531
2530 2532 2006-01-12 Ville Vainio <vivainio@gmail.com>
2531 2533
2532 2534 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
2533 2535 Prettified and hardened string/backslash quoting with ipsystem(),
2534 2536 ipalias() and ipmagic(). Now even \ characters are passed to
2535 2537 %magics, !shell escapes and aliases exactly as they are in the
2536 2538 ipython command line. Should improve backslash experience,
2537 2539 particularly in Windows (path delimiter for some commands that
2538 2540 won't understand '/'), but Unix benefits as well (regexps). %cd
2539 2541 magic still doesn't support backslash path delimiters, though. Also
2540 2542 deleted all pretense of supporting multiline command strings in
2541 2543 !system or %magic commands. Thanks to Jerry McRae for suggestions.
2542 2544
2543 2545 * doc/build_doc_instructions.txt added. Documentation on how to
2544 2546 use doc/update_manual.py, added yesterday. Both files contributed
2545 2547 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
2546 2548 doc/*.sh for deprecation at a later date.
2547 2549
2548 2550 * /ipython.py Added ipython.py to root directory for
2549 2551 zero-installation (tar xzvf ipython.tgz; cd ipython; python
2550 2552 ipython.py) and development convenience (no need to keep doing
2551 2553 "setup.py install" between changes).
2552 2554
2553 2555 * Made ! and !! shell escapes work (again) in multiline expressions:
2554 2556 if 1:
2555 2557 !ls
2556 2558 !!ls
2557 2559
2558 2560 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2559 2561
2560 2562 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
2561 2563 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
2562 2564 module in case-insensitive installation. Was causing crashes
2563 2565 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
2564 2566
2565 2567 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
2566 2568 <marienz-AT-gentoo.org>, closes
2567 2569 http://www.scipy.net/roundup/ipython/issue51.
2568 2570
2569 2571 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2570 2572
2571 2573 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
2572 2574 problem of excessive CPU usage under *nix and keyboard lag under
2573 2575 win32.
2574 2576
2575 2577 2006-01-10 *** Released version 0.7.0
2576 2578
2577 2579 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2578 2580
2579 2581 * IPython/Release.py (revision): tag version number to 0.7.0,
2580 2582 ready for release.
2581 2583
2582 2584 * IPython/Magic.py (magic_edit): Add print statement to %edit so
2583 2585 it informs the user of the name of the temp. file used. This can
2584 2586 help if you decide later to reuse that same file, so you know
2585 2587 where to copy the info from.
2586 2588
2587 2589 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2588 2590
2589 2591 * setup_bdist_egg.py: little script to build an egg. Added
2590 2592 support in the release tools as well.
2591 2593
2592 2594 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
2593 2595
2594 2596 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
2595 2597 version selection (new -wxversion command line and ipythonrc
2596 2598 parameter). Patch contributed by Arnd Baecker
2597 2599 <arnd.baecker-AT-web.de>.
2598 2600
2599 2601 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2600 2602 embedded instances, for variables defined at the interactive
2601 2603 prompt of the embedded ipython. Reported by Arnd.
2602 2604
2603 2605 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
2604 2606 it can be used as a (stateful) toggle, or with a direct parameter.
2605 2607
2606 2608 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
2607 2609 could be triggered in certain cases and cause the traceback
2608 2610 printer not to work.
2609 2611
2610 2612 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
2611 2613
2612 2614 * IPython/iplib.py (_should_recompile): Small fix, closes
2613 2615 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
2614 2616
2615 2617 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
2616 2618
2617 2619 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
2618 2620 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
2619 2621 Moad for help with tracking it down.
2620 2622
2621 2623 * IPython/iplib.py (handle_auto): fix autocall handling for
2622 2624 objects which support BOTH __getitem__ and __call__ (so that f [x]
2623 2625 is left alone, instead of becoming f([x]) automatically).
2624 2626
2625 2627 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
2626 2628 Ville's patch.
2627 2629
2628 2630 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
2629 2631
2630 2632 * IPython/iplib.py (handle_auto): changed autocall semantics to
2631 2633 include 'smart' mode, where the autocall transformation is NOT
2632 2634 applied if there are no arguments on the line. This allows you to
2633 2635 just type 'foo' if foo is a callable to see its internal form,
2634 2636 instead of having it called with no arguments (typically a
2635 2637 mistake). The old 'full' autocall still exists: for that, you
2636 2638 need to set the 'autocall' parameter to 2 in your ipythonrc file.
2637 2639
2638 2640 * IPython/completer.py (Completer.attr_matches): add
2639 2641 tab-completion support for Enthoughts' traits. After a report by
2640 2642 Arnd and a patch by Prabhu.
2641 2643
2642 2644 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
2643 2645
2644 2646 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
2645 2647 Schmolck's patch to fix inspect.getinnerframes().
2646 2648
2647 2649 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
2648 2650 for embedded instances, regarding handling of namespaces and items
2649 2651 added to the __builtin__ one. Multiple embedded instances and
2650 2652 recursive embeddings should work better now (though I'm not sure
2651 2653 I've got all the corner cases fixed, that code is a bit of a brain
2652 2654 twister).
2653 2655
2654 2656 * IPython/Magic.py (magic_edit): added support to edit in-memory
2655 2657 macros (automatically creates the necessary temp files). %edit
2656 2658 also doesn't return the file contents anymore, it's just noise.
2657 2659
2658 2660 * IPython/completer.py (Completer.attr_matches): revert change to
2659 2661 complete only on attributes listed in __all__. I realized it
2660 2662 cripples the tab-completion system as a tool for exploring the
2661 2663 internals of unknown libraries (it renders any non-__all__
2662 2664 attribute off-limits). I got bit by this when trying to see
2663 2665 something inside the dis module.
2664 2666
2665 2667 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2666 2668
2667 2669 * IPython/iplib.py (InteractiveShell.__init__): add .meta
2668 2670 namespace for users and extension writers to hold data in. This
2669 2671 follows the discussion in
2670 2672 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
2671 2673
2672 2674 * IPython/completer.py (IPCompleter.complete): small patch to help
2673 2675 tab-completion under Emacs, after a suggestion by John Barnard
2674 2676 <barnarj-AT-ccf.org>.
2675 2677
2676 2678 * IPython/Magic.py (Magic.extract_input_slices): added support for
2677 2679 the slice notation in magics to use N-M to represent numbers N...M
2678 2680 (closed endpoints). This is used by %macro and %save.
2679 2681
2680 2682 * IPython/completer.py (Completer.attr_matches): for modules which
2681 2683 define __all__, complete only on those. After a patch by Jeffrey
2682 2684 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
2683 2685 speed up this routine.
2684 2686
2685 2687 * IPython/Logger.py (Logger.log): fix a history handling bug. I
2686 2688 don't know if this is the end of it, but the behavior now is
2687 2689 certainly much more correct. Note that coupled with macros,
2688 2690 slightly surprising (at first) behavior may occur: a macro will in
2689 2691 general expand to multiple lines of input, so upon exiting, the
2690 2692 in/out counters will both be bumped by the corresponding amount
2691 2693 (as if the macro's contents had been typed interactively). Typing
2692 2694 %hist will reveal the intermediate (silently processed) lines.
2693 2695
2694 2696 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
2695 2697 pickle to fail (%run was overwriting __main__ and not restoring
2696 2698 it, but pickle relies on __main__ to operate).
2697 2699
2698 2700 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
2699 2701 using properties, but forgot to make the main InteractiveShell
2700 2702 class a new-style class. Properties fail silently, and
2701 2703 mysteriously, with old-style class (getters work, but
2702 2704 setters don't do anything).
2703 2705
2704 2706 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
2705 2707
2706 2708 * IPython/Magic.py (magic_history): fix history reporting bug (I
2707 2709 know some nasties are still there, I just can't seem to find a
2708 2710 reproducible test case to track them down; the input history is
2709 2711 falling out of sync...)
2710 2712
2711 2713 * IPython/iplib.py (handle_shell_escape): fix bug where both
2712 2714 aliases and system accesses where broken for indented code (such
2713 2715 as loops).
2714 2716
2715 2717 * IPython/genutils.py (shell): fix small but critical bug for
2716 2718 win32 system access.
2717 2719
2718 2720 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2719 2721
2720 2722 * IPython/iplib.py (showtraceback): remove use of the
2721 2723 sys.last_{type/value/traceback} structures, which are non
2722 2724 thread-safe.
2723 2725 (_prefilter): change control flow to ensure that we NEVER
2724 2726 introspect objects when autocall is off. This will guarantee that
2725 2727 having an input line of the form 'x.y', where access to attribute
2726 2728 'y' has side effects, doesn't trigger the side effect TWICE. It
2727 2729 is important to note that, with autocall on, these side effects
2728 2730 can still happen.
2729 2731 (ipsystem): new builtin, to complete the ip{magic/alias/system}
2730 2732 trio. IPython offers these three kinds of special calls which are
2731 2733 not python code, and it's a good thing to have their call method
2732 2734 be accessible as pure python functions (not just special syntax at
2733 2735 the command line). It gives us a better internal implementation
2734 2736 structure, as well as exposing these for user scripting more
2735 2737 cleanly.
2736 2738
2737 2739 * IPython/macro.py (Macro.__init__): moved macros to a standalone
2738 2740 file. Now that they'll be more likely to be used with the
2739 2741 persistance system (%store), I want to make sure their module path
2740 2742 doesn't change in the future, so that we don't break things for
2741 2743 users' persisted data.
2742 2744
2743 2745 * IPython/iplib.py (autoindent_update): move indentation
2744 2746 management into the _text_ processing loop, not the keyboard
2745 2747 interactive one. This is necessary to correctly process non-typed
2746 2748 multiline input (such as macros).
2747 2749
2748 2750 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
2749 2751 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
2750 2752 which was producing problems in the resulting manual.
2751 2753 (magic_whos): improve reporting of instances (show their class,
2752 2754 instead of simply printing 'instance' which isn't terribly
2753 2755 informative).
2754 2756
2755 2757 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
2756 2758 (minor mods) to support network shares under win32.
2757 2759
2758 2760 * IPython/winconsole.py (get_console_size): add new winconsole
2759 2761 module and fixes to page_dumb() to improve its behavior under
2760 2762 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
2761 2763
2762 2764 * IPython/Magic.py (Macro): simplified Macro class to just
2763 2765 subclass list. We've had only 2.2 compatibility for a very long
2764 2766 time, yet I was still avoiding subclassing the builtin types. No
2765 2767 more (I'm also starting to use properties, though I won't shift to
2766 2768 2.3-specific features quite yet).
2767 2769 (magic_store): added Ville's patch for lightweight variable
2768 2770 persistence, after a request on the user list by Matt Wilkie
2769 2771 <maphew-AT-gmail.com>. The new %store magic's docstring has full
2770 2772 details.
2771 2773
2772 2774 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2773 2775 changed the default logfile name from 'ipython.log' to
2774 2776 'ipython_log.py'. These logs are real python files, and now that
2775 2777 we have much better multiline support, people are more likely to
2776 2778 want to use them as such. Might as well name them correctly.
2777 2779
2778 2780 * IPython/Magic.py: substantial cleanup. While we can't stop
2779 2781 using magics as mixins, due to the existing customizations 'out
2780 2782 there' which rely on the mixin naming conventions, at least I
2781 2783 cleaned out all cross-class name usage. So once we are OK with
2782 2784 breaking compatibility, the two systems can be separated.
2783 2785
2784 2786 * IPython/Logger.py: major cleanup. This one is NOT a mixin
2785 2787 anymore, and the class is a fair bit less hideous as well. New
2786 2788 features were also introduced: timestamping of input, and logging
2787 2789 of output results. These are user-visible with the -t and -o
2788 2790 options to %logstart. Closes
2789 2791 http://www.scipy.net/roundup/ipython/issue11 and a request by
2790 2792 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
2791 2793
2792 2794 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2793 2795
2794 2796 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
2795 2797 better handle backslashes in paths. See the thread 'More Windows
2796 2798 questions part 2 - \/ characters revisited' on the iypthon user
2797 2799 list:
2798 2800 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
2799 2801
2800 2802 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
2801 2803
2802 2804 (InteractiveShell.__init__): change threaded shells to not use the
2803 2805 ipython crash handler. This was causing more problems than not,
2804 2806 as exceptions in the main thread (GUI code, typically) would
2805 2807 always show up as a 'crash', when they really weren't.
2806 2808
2807 2809 The colors and exception mode commands (%colors/%xmode) have been
2808 2810 synchronized to also take this into account, so users can get
2809 2811 verbose exceptions for their threaded code as well. I also added
2810 2812 support for activating pdb inside this exception handler as well,
2811 2813 so now GUI authors can use IPython's enhanced pdb at runtime.
2812 2814
2813 2815 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
2814 2816 true by default, and add it to the shipped ipythonrc file. Since
2815 2817 this asks the user before proceeding, I think it's OK to make it
2816 2818 true by default.
2817 2819
2818 2820 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
2819 2821 of the previous special-casing of input in the eval loop. I think
2820 2822 this is cleaner, as they really are commands and shouldn't have
2821 2823 a special role in the middle of the core code.
2822 2824
2823 2825 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2824 2826
2825 2827 * IPython/iplib.py (edit_syntax_error): added support for
2826 2828 automatically reopening the editor if the file had a syntax error
2827 2829 in it. Thanks to scottt who provided the patch at:
2828 2830 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
2829 2831 version committed).
2830 2832
2831 2833 * IPython/iplib.py (handle_normal): add suport for multi-line
2832 2834 input with emtpy lines. This fixes
2833 2835 http://www.scipy.net/roundup/ipython/issue43 and a similar
2834 2836 discussion on the user list.
2835 2837
2836 2838 WARNING: a behavior change is necessarily introduced to support
2837 2839 blank lines: now a single blank line with whitespace does NOT
2838 2840 break the input loop, which means that when autoindent is on, by
2839 2841 default hitting return on the next (indented) line does NOT exit.
2840 2842
2841 2843 Instead, to exit a multiline input you can either have:
2842 2844
2843 2845 - TWO whitespace lines (just hit return again), or
2844 2846 - a single whitespace line of a different length than provided
2845 2847 by the autoindent (add or remove a space).
2846 2848
2847 2849 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
2848 2850 module to better organize all readline-related functionality.
2849 2851 I've deleted FlexCompleter and put all completion clases here.
2850 2852
2851 2853 * IPython/iplib.py (raw_input): improve indentation management.
2852 2854 It is now possible to paste indented code with autoindent on, and
2853 2855 the code is interpreted correctly (though it still looks bad on
2854 2856 screen, due to the line-oriented nature of ipython).
2855 2857 (MagicCompleter.complete): change behavior so that a TAB key on an
2856 2858 otherwise empty line actually inserts a tab, instead of completing
2857 2859 on the entire global namespace. This makes it easier to use the
2858 2860 TAB key for indentation. After a request by Hans Meine
2859 2861 <hans_meine-AT-gmx.net>
2860 2862 (_prefilter): add support so that typing plain 'exit' or 'quit'
2861 2863 does a sensible thing. Originally I tried to deviate as little as
2862 2864 possible from the default python behavior, but even that one may
2863 2865 change in this direction (thread on python-dev to that effect).
2864 2866 Regardless, ipython should do the right thing even if CPython's
2865 2867 '>>>' prompt doesn't.
2866 2868 (InteractiveShell): removed subclassing code.InteractiveConsole
2867 2869 class. By now we'd overridden just about all of its methods: I've
2868 2870 copied the remaining two over, and now ipython is a standalone
2869 2871 class. This will provide a clearer picture for the chainsaw
2870 2872 branch refactoring.
2871 2873
2872 2874 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2873 2875
2874 2876 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2875 2877 failures for objects which break when dir() is called on them.
2876 2878
2877 2879 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2878 2880 distinct local and global namespaces in the completer API. This
2879 2881 change allows us to properly handle completion with distinct
2880 2882 scopes, including in embedded instances (this had never really
2881 2883 worked correctly).
2882 2884
2883 2885 Note: this introduces a change in the constructor for
2884 2886 MagicCompleter, as a new global_namespace parameter is now the
2885 2887 second argument (the others were bumped one position).
2886 2888
2887 2889 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2888 2890
2889 2891 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2890 2892 embedded instances (which can be done now thanks to Vivian's
2891 2893 frame-handling fixes for pdb).
2892 2894 (InteractiveShell.__init__): Fix namespace handling problem in
2893 2895 embedded instances. We were overwriting __main__ unconditionally,
2894 2896 and this should only be done for 'full' (non-embedded) IPython;
2895 2897 embedded instances must respect the caller's __main__. Thanks to
2896 2898 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2897 2899
2898 2900 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2899 2901
2900 2902 * setup.py: added download_url to setup(). This registers the
2901 2903 download address at PyPI, which is not only useful to humans
2902 2904 browsing the site, but is also picked up by setuptools (the Eggs
2903 2905 machinery). Thanks to Ville and R. Kern for the info/discussion
2904 2906 on this.
2905 2907
2906 2908 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2907 2909
2908 2910 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2909 2911 This brings a lot of nice functionality to the pdb mode, which now
2910 2912 has tab-completion, syntax highlighting, and better stack handling
2911 2913 than before. Many thanks to Vivian De Smedt
2912 2914 <vivian-AT-vdesmedt.com> for the original patches.
2913 2915
2914 2916 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2915 2917
2916 2918 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2917 2919 sequence to consistently accept the banner argument. The
2918 2920 inconsistency was tripping SAGE, thanks to Gary Zablackis
2919 2921 <gzabl-AT-yahoo.com> for the report.
2920 2922
2921 2923 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2922 2924
2923 2925 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2924 2926 Fix bug where a naked 'alias' call in the ipythonrc file would
2925 2927 cause a crash. Bug reported by Jorgen Stenarson.
2926 2928
2927 2929 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2928 2930
2929 2931 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2930 2932 startup time.
2931 2933
2932 2934 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2933 2935 instances had introduced a bug with globals in normal code. Now
2934 2936 it's working in all cases.
2935 2937
2936 2938 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2937 2939 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2938 2940 has been introduced to set the default case sensitivity of the
2939 2941 searches. Users can still select either mode at runtime on a
2940 2942 per-search basis.
2941 2943
2942 2944 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2943 2945
2944 2946 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2945 2947 attributes in wildcard searches for subclasses. Modified version
2946 2948 of a patch by Jorgen.
2947 2949
2948 2950 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2949 2951
2950 2952 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2951 2953 embedded instances. I added a user_global_ns attribute to the
2952 2954 InteractiveShell class to handle this.
2953 2955
2954 2956 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2955 2957
2956 2958 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2957 2959 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2958 2960 (reported under win32, but may happen also in other platforms).
2959 2961 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2960 2962
2961 2963 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2962 2964
2963 2965 * IPython/Magic.py (magic_psearch): new support for wildcard
2964 2966 patterns. Now, typing ?a*b will list all names which begin with a
2965 2967 and end in b, for example. The %psearch magic has full
2966 2968 docstrings. Many thanks to JΓΆrgen Stenarson
2967 2969 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2968 2970 implementing this functionality.
2969 2971
2970 2972 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2971 2973
2972 2974 * Manual: fixed long-standing annoyance of double-dashes (as in
2973 2975 --prefix=~, for example) being stripped in the HTML version. This
2974 2976 is a latex2html bug, but a workaround was provided. Many thanks
2975 2977 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2976 2978 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2977 2979 rolling. This seemingly small issue had tripped a number of users
2978 2980 when first installing, so I'm glad to see it gone.
2979 2981
2980 2982 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2981 2983
2982 2984 * IPython/Extensions/numeric_formats.py: fix missing import,
2983 2985 reported by Stephen Walton.
2984 2986
2985 2987 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2986 2988
2987 2989 * IPython/demo.py: finish demo module, fully documented now.
2988 2990
2989 2991 * IPython/genutils.py (file_read): simple little utility to read a
2990 2992 file and ensure it's closed afterwards.
2991 2993
2992 2994 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2993 2995
2994 2996 * IPython/demo.py (Demo.__init__): added support for individually
2995 2997 tagging blocks for automatic execution.
2996 2998
2997 2999 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2998 3000 syntax-highlighted python sources, requested by John.
2999 3001
3000 3002 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
3001 3003
3002 3004 * IPython/demo.py (Demo.again): fix bug where again() blocks after
3003 3005 finishing.
3004 3006
3005 3007 * IPython/genutils.py (shlex_split): moved from Magic to here,
3006 3008 where all 2.2 compatibility stuff lives. I needed it for demo.py.
3007 3009
3008 3010 * IPython/demo.py (Demo.__init__): added support for silent
3009 3011 blocks, improved marks as regexps, docstrings written.
3010 3012 (Demo.__init__): better docstring, added support for sys.argv.
3011 3013
3012 3014 * IPython/genutils.py (marquee): little utility used by the demo
3013 3015 code, handy in general.
3014 3016
3015 3017 * IPython/demo.py (Demo.__init__): new class for interactive
3016 3018 demos. Not documented yet, I just wrote it in a hurry for
3017 3019 scipy'05. Will docstring later.
3018 3020
3019 3021 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
3020 3022
3021 3023 * IPython/Shell.py (sigint_handler): Drastic simplification which
3022 3024 also seems to make Ctrl-C work correctly across threads! This is
3023 3025 so simple, that I can't beleive I'd missed it before. Needs more
3024 3026 testing, though.
3025 3027 (KBINT): Never mind, revert changes. I'm sure I'd tried something
3026 3028 like this before...
3027 3029
3028 3030 * IPython/genutils.py (get_home_dir): add protection against
3029 3031 non-dirs in win32 registry.
3030 3032
3031 3033 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
3032 3034 bug where dict was mutated while iterating (pysh crash).
3033 3035
3034 3036 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
3035 3037
3036 3038 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
3037 3039 spurious newlines added by this routine. After a report by
3038 3040 F. Mantegazza.
3039 3041
3040 3042 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
3041 3043
3042 3044 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
3043 3045 calls. These were a leftover from the GTK 1.x days, and can cause
3044 3046 problems in certain cases (after a report by John Hunter).
3045 3047
3046 3048 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
3047 3049 os.getcwd() fails at init time. Thanks to patch from David Remahl
3048 3050 <chmod007-AT-mac.com>.
3049 3051 (InteractiveShell.__init__): prevent certain special magics from
3050 3052 being shadowed by aliases. Closes
3051 3053 http://www.scipy.net/roundup/ipython/issue41.
3052 3054
3053 3055 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
3054 3056
3055 3057 * IPython/iplib.py (InteractiveShell.complete): Added new
3056 3058 top-level completion method to expose the completion mechanism
3057 3059 beyond readline-based environments.
3058 3060
3059 3061 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
3060 3062
3061 3063 * tools/ipsvnc (svnversion): fix svnversion capture.
3062 3064
3063 3065 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
3064 3066 attribute to self, which was missing. Before, it was set by a
3065 3067 routine which in certain cases wasn't being called, so the
3066 3068 instance could end up missing the attribute. This caused a crash.
3067 3069 Closes http://www.scipy.net/roundup/ipython/issue40.
3068 3070
3069 3071 2005-08-16 Fernando Perez <fperez@colorado.edu>
3070 3072
3071 3073 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
3072 3074 contains non-string attribute. Closes
3073 3075 http://www.scipy.net/roundup/ipython/issue38.
3074 3076
3075 3077 2005-08-14 Fernando Perez <fperez@colorado.edu>
3076 3078
3077 3079 * tools/ipsvnc: Minor improvements, to add changeset info.
3078 3080
3079 3081 2005-08-12 Fernando Perez <fperez@colorado.edu>
3080 3082
3081 3083 * IPython/iplib.py (runsource): remove self.code_to_run_src
3082 3084 attribute. I realized this is nothing more than
3083 3085 '\n'.join(self.buffer), and having the same data in two different
3084 3086 places is just asking for synchronization bugs. This may impact
3085 3087 people who have custom exception handlers, so I need to warn
3086 3088 ipython-dev about it (F. Mantegazza may use them).
3087 3089
3088 3090 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
3089 3091
3090 3092 * IPython/genutils.py: fix 2.2 compatibility (generators)
3091 3093
3092 3094 2005-07-18 Fernando Perez <fperez@colorado.edu>
3093 3095
3094 3096 * IPython/genutils.py (get_home_dir): fix to help users with
3095 3097 invalid $HOME under win32.
3096 3098
3097 3099 2005-07-17 Fernando Perez <fperez@colorado.edu>
3098 3100
3099 3101 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
3100 3102 some old hacks and clean up a bit other routines; code should be
3101 3103 simpler and a bit faster.
3102 3104
3103 3105 * IPython/iplib.py (interact): removed some last-resort attempts
3104 3106 to survive broken stdout/stderr. That code was only making it
3105 3107 harder to abstract out the i/o (necessary for gui integration),
3106 3108 and the crashes it could prevent were extremely rare in practice
3107 3109 (besides being fully user-induced in a pretty violent manner).
3108 3110
3109 3111 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
3110 3112 Nothing major yet, but the code is simpler to read; this should
3111 3113 make it easier to do more serious modifications in the future.
3112 3114
3113 3115 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
3114 3116 which broke in .15 (thanks to a report by Ville).
3115 3117
3116 3118 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
3117 3119 be quite correct, I know next to nothing about unicode). This
3118 3120 will allow unicode strings to be used in prompts, amongst other
3119 3121 cases. It also will prevent ipython from crashing when unicode
3120 3122 shows up unexpectedly in many places. If ascii encoding fails, we
3121 3123 assume utf_8. Currently the encoding is not a user-visible
3122 3124 setting, though it could be made so if there is demand for it.
3123 3125
3124 3126 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
3125 3127
3126 3128 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
3127 3129
3128 3130 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
3129 3131
3130 3132 * IPython/genutils.py: Add 2.2 compatibility here, so all other
3131 3133 code can work transparently for 2.2/2.3.
3132 3134
3133 3135 2005-07-16 Fernando Perez <fperez@colorado.edu>
3134 3136
3135 3137 * IPython/ultraTB.py (ExceptionColors): Make a global variable
3136 3138 out of the color scheme table used for coloring exception
3137 3139 tracebacks. This allows user code to add new schemes at runtime.
3138 3140 This is a minimally modified version of the patch at
3139 3141 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
3140 3142 for the contribution.
3141 3143
3142 3144 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
3143 3145 slightly modified version of the patch in
3144 3146 http://www.scipy.net/roundup/ipython/issue34, which also allows me
3145 3147 to remove the previous try/except solution (which was costlier).
3146 3148 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
3147 3149
3148 3150 2005-06-08 Fernando Perez <fperez@colorado.edu>
3149 3151
3150 3152 * IPython/iplib.py (write/write_err): Add methods to abstract all
3151 3153 I/O a bit more.
3152 3154
3153 3155 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
3154 3156 warning, reported by Aric Hagberg, fix by JD Hunter.
3155 3157
3156 3158 2005-06-02 *** Released version 0.6.15
3157 3159
3158 3160 2005-06-01 Fernando Perez <fperez@colorado.edu>
3159 3161
3160 3162 * IPython/iplib.py (MagicCompleter.file_matches): Fix
3161 3163 tab-completion of filenames within open-quoted strings. Note that
3162 3164 this requires that in ~/.ipython/ipythonrc, users change the
3163 3165 readline delimiters configuration to read:
3164 3166
3165 3167 readline_remove_delims -/~
3166 3168
3167 3169
3168 3170 2005-05-31 *** Released version 0.6.14
3169 3171
3170 3172 2005-05-29 Fernando Perez <fperez@colorado.edu>
3171 3173
3172 3174 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
3173 3175 with files not on the filesystem. Reported by Eliyahu Sandler
3174 3176 <eli@gondolin.net>
3175 3177
3176 3178 2005-05-22 Fernando Perez <fperez@colorado.edu>
3177 3179
3178 3180 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
3179 3181 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
3180 3182
3181 3183 2005-05-19 Fernando Perez <fperez@colorado.edu>
3182 3184
3183 3185 * IPython/iplib.py (safe_execfile): close a file which could be
3184 3186 left open (causing problems in win32, which locks open files).
3185 3187 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
3186 3188
3187 3189 2005-05-18 Fernando Perez <fperez@colorado.edu>
3188 3190
3189 3191 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
3190 3192 keyword arguments correctly to safe_execfile().
3191 3193
3192 3194 2005-05-13 Fernando Perez <fperez@colorado.edu>
3193 3195
3194 3196 * ipython.1: Added info about Qt to manpage, and threads warning
3195 3197 to usage page (invoked with --help).
3196 3198
3197 3199 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
3198 3200 new matcher (it goes at the end of the priority list) to do
3199 3201 tab-completion on named function arguments. Submitted by George
3200 3202 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
3201 3203 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
3202 3204 for more details.
3203 3205
3204 3206 * IPython/Magic.py (magic_run): Added new -e flag to ignore
3205 3207 SystemExit exceptions in the script being run. Thanks to a report
3206 3208 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
3207 3209 producing very annoying behavior when running unit tests.
3208 3210
3209 3211 2005-05-12 Fernando Perez <fperez@colorado.edu>
3210 3212
3211 3213 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
3212 3214 which I'd broken (again) due to a changed regexp. In the process,
3213 3215 added ';' as an escape to auto-quote the whole line without
3214 3216 splitting its arguments. Thanks to a report by Jerry McRae
3215 3217 <qrs0xyc02-AT-sneakemail.com>.
3216 3218
3217 3219 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
3218 3220 possible crashes caused by a TokenError. Reported by Ed Schofield
3219 3221 <schofield-AT-ftw.at>.
3220 3222
3221 3223 2005-05-06 Fernando Perez <fperez@colorado.edu>
3222 3224
3223 3225 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
3224 3226
3225 3227 2005-04-29 Fernando Perez <fperez@colorado.edu>
3226 3228
3227 3229 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
3228 3230 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
3229 3231 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
3230 3232 which provides support for Qt interactive usage (similar to the
3231 3233 existing one for WX and GTK). This had been often requested.
3232 3234
3233 3235 2005-04-14 *** Released version 0.6.13
3234 3236
3235 3237 2005-04-08 Fernando Perez <fperez@colorado.edu>
3236 3238
3237 3239 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
3238 3240 from _ofind, which gets called on almost every input line. Now,
3239 3241 we only try to get docstrings if they are actually going to be
3240 3242 used (the overhead of fetching unnecessary docstrings can be
3241 3243 noticeable for certain objects, such as Pyro proxies).
3242 3244
3243 3245 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
3244 3246 for completers. For some reason I had been passing them the state
3245 3247 variable, which completers never actually need, and was in
3246 3248 conflict with the rlcompleter API. Custom completers ONLY need to
3247 3249 take the text parameter.
3248 3250
3249 3251 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
3250 3252 work correctly in pysh. I've also moved all the logic which used
3251 3253 to be in pysh.py here, which will prevent problems with future
3252 3254 upgrades. However, this time I must warn users to update their
3253 3255 pysh profile to include the line
3254 3256
3255 3257 import_all IPython.Extensions.InterpreterExec
3256 3258
3257 3259 because otherwise things won't work for them. They MUST also
3258 3260 delete pysh.py and the line
3259 3261
3260 3262 execfile pysh.py
3261 3263
3262 3264 from their ipythonrc-pysh.
3263 3265
3264 3266 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
3265 3267 robust in the face of objects whose dir() returns non-strings
3266 3268 (which it shouldn't, but some broken libs like ITK do). Thanks to
3267 3269 a patch by John Hunter (implemented differently, though). Also
3268 3270 minor improvements by using .extend instead of + on lists.
3269 3271
3270 3272 * pysh.py:
3271 3273
3272 3274 2005-04-06 Fernando Perez <fperez@colorado.edu>
3273 3275
3274 3276 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
3275 3277 by default, so that all users benefit from it. Those who don't
3276 3278 want it can still turn it off.
3277 3279
3278 3280 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
3279 3281 config file, I'd forgotten about this, so users were getting it
3280 3282 off by default.
3281 3283
3282 3284 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
3283 3285 consistency. Now magics can be called in multiline statements,
3284 3286 and python variables can be expanded in magic calls via $var.
3285 3287 This makes the magic system behave just like aliases or !system
3286 3288 calls.
3287 3289
3288 3290 2005-03-28 Fernando Perez <fperez@colorado.edu>
3289 3291
3290 3292 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
3291 3293 expensive string additions for building command. Add support for
3292 3294 trailing ';' when autocall is used.
3293 3295
3294 3296 2005-03-26 Fernando Perez <fperez@colorado.edu>
3295 3297
3296 3298 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
3297 3299 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
3298 3300 ipython.el robust against prompts with any number of spaces
3299 3301 (including 0) after the ':' character.
3300 3302
3301 3303 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
3302 3304 continuation prompt, which misled users to think the line was
3303 3305 already indented. Closes debian Bug#300847, reported to me by
3304 3306 Norbert Tretkowski <tretkowski-AT-inittab.de>.
3305 3307
3306 3308 2005-03-23 Fernando Perez <fperez@colorado.edu>
3307 3309
3308 3310 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
3309 3311 properly aligned if they have embedded newlines.
3310 3312
3311 3313 * IPython/iplib.py (runlines): Add a public method to expose
3312 3314 IPython's code execution machinery, so that users can run strings
3313 3315 as if they had been typed at the prompt interactively.
3314 3316 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
3315 3317 methods which can call the system shell, but with python variable
3316 3318 expansion. The three such methods are: __IPYTHON__.system,
3317 3319 .getoutput and .getoutputerror. These need to be documented in a
3318 3320 'public API' section (to be written) of the manual.
3319 3321
3320 3322 2005-03-20 Fernando Perez <fperez@colorado.edu>
3321 3323
3322 3324 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
3323 3325 for custom exception handling. This is quite powerful, and it
3324 3326 allows for user-installable exception handlers which can trap
3325 3327 custom exceptions at runtime and treat them separately from
3326 3328 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
3327 3329 Mantegazza <mantegazza-AT-ill.fr>.
3328 3330 (InteractiveShell.set_custom_completer): public API function to
3329 3331 add new completers at runtime.
3330 3332
3331 3333 2005-03-19 Fernando Perez <fperez@colorado.edu>
3332 3334
3333 3335 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
3334 3336 allow objects which provide their docstrings via non-standard
3335 3337 mechanisms (like Pyro proxies) to still be inspected by ipython's
3336 3338 ? system.
3337 3339
3338 3340 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
3339 3341 automatic capture system. I tried quite hard to make it work
3340 3342 reliably, and simply failed. I tried many combinations with the
3341 3343 subprocess module, but eventually nothing worked in all needed
3342 3344 cases (not blocking stdin for the child, duplicating stdout
3343 3345 without blocking, etc). The new %sc/%sx still do capture to these
3344 3346 magical list/string objects which make shell use much more
3345 3347 conveninent, so not all is lost.
3346 3348
3347 3349 XXX - FIX MANUAL for the change above!
3348 3350
3349 3351 (runsource): I copied code.py's runsource() into ipython to modify
3350 3352 it a bit. Now the code object and source to be executed are
3351 3353 stored in ipython. This makes this info accessible to third-party
3352 3354 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
3353 3355 Mantegazza <mantegazza-AT-ill.fr>.
3354 3356
3355 3357 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
3356 3358 history-search via readline (like C-p/C-n). I'd wanted this for a
3357 3359 long time, but only recently found out how to do it. For users
3358 3360 who already have their ipythonrc files made and want this, just
3359 3361 add:
3360 3362
3361 3363 readline_parse_and_bind "\e[A": history-search-backward
3362 3364 readline_parse_and_bind "\e[B": history-search-forward
3363 3365
3364 3366 2005-03-18 Fernando Perez <fperez@colorado.edu>
3365 3367
3366 3368 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
3367 3369 LSString and SList classes which allow transparent conversions
3368 3370 between list mode and whitespace-separated string.
3369 3371 (magic_r): Fix recursion problem in %r.
3370 3372
3371 3373 * IPython/genutils.py (LSString): New class to be used for
3372 3374 automatic storage of the results of all alias/system calls in _o
3373 3375 and _e (stdout/err). These provide a .l/.list attribute which
3374 3376 does automatic splitting on newlines. This means that for most
3375 3377 uses, you'll never need to do capturing of output with %sc/%sx
3376 3378 anymore, since ipython keeps this always done for you. Note that
3377 3379 only the LAST results are stored, the _o/e variables are
3378 3380 overwritten on each call. If you need to save their contents
3379 3381 further, simply bind them to any other name.
3380 3382
3381 3383 2005-03-17 Fernando Perez <fperez@colorado.edu>
3382 3384
3383 3385 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
3384 3386 prompt namespace handling.
3385 3387
3386 3388 2005-03-16 Fernando Perez <fperez@colorado.edu>
3387 3389
3388 3390 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
3389 3391 classic prompts to be '>>> ' (final space was missing, and it
3390 3392 trips the emacs python mode).
3391 3393 (BasePrompt.__str__): Added safe support for dynamic prompt
3392 3394 strings. Now you can set your prompt string to be '$x', and the
3393 3395 value of x will be printed from your interactive namespace. The
3394 3396 interpolation syntax includes the full Itpl support, so
3395 3397 ${foo()+x+bar()} is a valid prompt string now, and the function
3396 3398 calls will be made at runtime.
3397 3399
3398 3400 2005-03-15 Fernando Perez <fperez@colorado.edu>
3399 3401
3400 3402 * IPython/Magic.py (magic_history): renamed %hist to %history, to
3401 3403 avoid name clashes in pylab. %hist still works, it just forwards
3402 3404 the call to %history.
3403 3405
3404 3406 2005-03-02 *** Released version 0.6.12
3405 3407
3406 3408 2005-03-02 Fernando Perez <fperez@colorado.edu>
3407 3409
3408 3410 * IPython/iplib.py (handle_magic): log magic calls properly as
3409 3411 ipmagic() function calls.
3410 3412
3411 3413 * IPython/Magic.py (magic_time): Improved %time to support
3412 3414 statements and provide wall-clock as well as CPU time.
3413 3415
3414 3416 2005-02-27 Fernando Perez <fperez@colorado.edu>
3415 3417
3416 3418 * IPython/hooks.py: New hooks module, to expose user-modifiable
3417 3419 IPython functionality in a clean manner. For now only the editor
3418 3420 hook is actually written, and other thigns which I intend to turn
3419 3421 into proper hooks aren't yet there. The display and prefilter
3420 3422 stuff, for example, should be hooks. But at least now the
3421 3423 framework is in place, and the rest can be moved here with more
3422 3424 time later. IPython had had a .hooks variable for a long time for
3423 3425 this purpose, but I'd never actually used it for anything.
3424 3426
3425 3427 2005-02-26 Fernando Perez <fperez@colorado.edu>
3426 3428
3427 3429 * IPython/ipmaker.py (make_IPython): make the default ipython
3428 3430 directory be called _ipython under win32, to follow more the
3429 3431 naming peculiarities of that platform (where buggy software like
3430 3432 Visual Sourcesafe breaks with .named directories). Reported by
3431 3433 Ville Vainio.
3432 3434
3433 3435 2005-02-23 Fernando Perez <fperez@colorado.edu>
3434 3436
3435 3437 * IPython/iplib.py (InteractiveShell.__init__): removed a few
3436 3438 auto_aliases for win32 which were causing problems. Users can
3437 3439 define the ones they personally like.
3438 3440
3439 3441 2005-02-21 Fernando Perez <fperez@colorado.edu>
3440 3442
3441 3443 * IPython/Magic.py (magic_time): new magic to time execution of
3442 3444 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
3443 3445
3444 3446 2005-02-19 Fernando Perez <fperez@colorado.edu>
3445 3447
3446 3448 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
3447 3449 into keys (for prompts, for example).
3448 3450
3449 3451 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
3450 3452 prompts in case users want them. This introduces a small behavior
3451 3453 change: ipython does not automatically add a space to all prompts
3452 3454 anymore. To get the old prompts with a space, users should add it
3453 3455 manually to their ipythonrc file, so for example prompt_in1 should
3454 3456 now read 'In [\#]: ' instead of 'In [\#]:'.
3455 3457 (BasePrompt.__init__): New option prompts_pad_left (only in rc
3456 3458 file) to control left-padding of secondary prompts.
3457 3459
3458 3460 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
3459 3461 the profiler can't be imported. Fix for Debian, which removed
3460 3462 profile.py because of License issues. I applied a slightly
3461 3463 modified version of the original Debian patch at
3462 3464 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
3463 3465
3464 3466 2005-02-17 Fernando Perez <fperez@colorado.edu>
3465 3467
3466 3468 * IPython/genutils.py (native_line_ends): Fix bug which would
3467 3469 cause improper line-ends under win32 b/c I was not opening files
3468 3470 in binary mode. Bug report and fix thanks to Ville.
3469 3471
3470 3472 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
3471 3473 trying to catch spurious foo[1] autocalls. My fix actually broke
3472 3474 ',/' autoquote/call with explicit escape (bad regexp).
3473 3475
3474 3476 2005-02-15 *** Released version 0.6.11
3475 3477
3476 3478 2005-02-14 Fernando Perez <fperez@colorado.edu>
3477 3479
3478 3480 * IPython/background_jobs.py: New background job management
3479 3481 subsystem. This is implemented via a new set of classes, and
3480 3482 IPython now provides a builtin 'jobs' object for background job
3481 3483 execution. A convenience %bg magic serves as a lightweight
3482 3484 frontend for starting the more common type of calls. This was
3483 3485 inspired by discussions with B. Granger and the BackgroundCommand
3484 3486 class described in the book Python Scripting for Computational
3485 3487 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
3486 3488 (although ultimately no code from this text was used, as IPython's
3487 3489 system is a separate implementation).
3488 3490
3489 3491 * IPython/iplib.py (MagicCompleter.python_matches): add new option
3490 3492 to control the completion of single/double underscore names
3491 3493 separately. As documented in the example ipytonrc file, the
3492 3494 readline_omit__names variable can now be set to 2, to omit even
3493 3495 single underscore names. Thanks to a patch by Brian Wong
3494 3496 <BrianWong-AT-AirgoNetworks.Com>.
3495 3497 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
3496 3498 be autocalled as foo([1]) if foo were callable. A problem for
3497 3499 things which are both callable and implement __getitem__.
3498 3500 (init_readline): Fix autoindentation for win32. Thanks to a patch
3499 3501 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
3500 3502
3501 3503 2005-02-12 Fernando Perez <fperez@colorado.edu>
3502 3504
3503 3505 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
3504 3506 which I had written long ago to sort out user error messages which
3505 3507 may occur during startup. This seemed like a good idea initially,
3506 3508 but it has proven a disaster in retrospect. I don't want to
3507 3509 change much code for now, so my fix is to set the internal 'debug'
3508 3510 flag to true everywhere, whose only job was precisely to control
3509 3511 this subsystem. This closes issue 28 (as well as avoiding all
3510 3512 sorts of strange hangups which occur from time to time).
3511 3513
3512 3514 2005-02-07 Fernando Perez <fperez@colorado.edu>
3513 3515
3514 3516 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
3515 3517 previous call produced a syntax error.
3516 3518
3517 3519 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3518 3520 classes without constructor.
3519 3521
3520 3522 2005-02-06 Fernando Perez <fperez@colorado.edu>
3521 3523
3522 3524 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
3523 3525 completions with the results of each matcher, so we return results
3524 3526 to the user from all namespaces. This breaks with ipython
3525 3527 tradition, but I think it's a nicer behavior. Now you get all
3526 3528 possible completions listed, from all possible namespaces (python,
3527 3529 filesystem, magics...) After a request by John Hunter
3528 3530 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3529 3531
3530 3532 2005-02-05 Fernando Perez <fperez@colorado.edu>
3531 3533
3532 3534 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
3533 3535 the call had quote characters in it (the quotes were stripped).
3534 3536
3535 3537 2005-01-31 Fernando Perez <fperez@colorado.edu>
3536 3538
3537 3539 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
3538 3540 Itpl.itpl() to make the code more robust against psyco
3539 3541 optimizations.
3540 3542
3541 3543 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
3542 3544 of causing an exception. Quicker, cleaner.
3543 3545
3544 3546 2005-01-28 Fernando Perez <fperez@colorado.edu>
3545 3547
3546 3548 * scripts/ipython_win_post_install.py (install): hardcode
3547 3549 sys.prefix+'python.exe' as the executable path. It turns out that
3548 3550 during the post-installation run, sys.executable resolves to the
3549 3551 name of the binary installer! I should report this as a distutils
3550 3552 bug, I think. I updated the .10 release with this tiny fix, to
3551 3553 avoid annoying the lists further.
3552 3554
3553 3555 2005-01-27 *** Released version 0.6.10
3554 3556
3555 3557 2005-01-27 Fernando Perez <fperez@colorado.edu>
3556 3558
3557 3559 * IPython/numutils.py (norm): Added 'inf' as optional name for
3558 3560 L-infinity norm, included references to mathworld.com for vector
3559 3561 norm definitions.
3560 3562 (amin/amax): added amin/amax for array min/max. Similar to what
3561 3563 pylab ships with after the recent reorganization of names.
3562 3564 (spike/spike_odd): removed deprecated spike/spike_odd functions.
3563 3565
3564 3566 * ipython.el: committed Alex's recent fixes and improvements.
3565 3567 Tested with python-mode from CVS, and it looks excellent. Since
3566 3568 python-mode hasn't released anything in a while, I'm temporarily
3567 3569 putting a copy of today's CVS (v 4.70) of python-mode in:
3568 3570 http://ipython.scipy.org/tmp/python-mode.el
3569 3571
3570 3572 * scripts/ipython_win_post_install.py (install): Win32 fix to use
3571 3573 sys.executable for the executable name, instead of assuming it's
3572 3574 called 'python.exe' (the post-installer would have produced broken
3573 3575 setups on systems with a differently named python binary).
3574 3576
3575 3577 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
3576 3578 references to os.linesep, to make the code more
3577 3579 platform-independent. This is also part of the win32 coloring
3578 3580 fixes.
3579 3581
3580 3582 * IPython/genutils.py (page_dumb): Remove attempts to chop long
3581 3583 lines, which actually cause coloring bugs because the length of
3582 3584 the line is very difficult to correctly compute with embedded
3583 3585 escapes. This was the source of all the coloring problems under
3584 3586 Win32. I think that _finally_, Win32 users have a properly
3585 3587 working ipython in all respects. This would never have happened
3586 3588 if not for Gary Bishop and Viktor Ransmayr's great help and work.
3587 3589
3588 3590 2005-01-26 *** Released version 0.6.9
3589 3591
3590 3592 2005-01-25 Fernando Perez <fperez@colorado.edu>
3591 3593
3592 3594 * setup.py: finally, we have a true Windows installer, thanks to
3593 3595 the excellent work of Viktor Ransmayr
3594 3596 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
3595 3597 Windows users. The setup routine is quite a bit cleaner thanks to
3596 3598 this, and the post-install script uses the proper functions to
3597 3599 allow a clean de-installation using the standard Windows Control
3598 3600 Panel.
3599 3601
3600 3602 * IPython/genutils.py (get_home_dir): changed to use the $HOME
3601 3603 environment variable under all OSes (including win32) if
3602 3604 available. This will give consistency to win32 users who have set
3603 3605 this variable for any reason. If os.environ['HOME'] fails, the
3604 3606 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
3605 3607
3606 3608 2005-01-24 Fernando Perez <fperez@colorado.edu>
3607 3609
3608 3610 * IPython/numutils.py (empty_like): add empty_like(), similar to
3609 3611 zeros_like() but taking advantage of the new empty() Numeric routine.
3610 3612
3611 3613 2005-01-23 *** Released version 0.6.8
3612 3614
3613 3615 2005-01-22 Fernando Perez <fperez@colorado.edu>
3614 3616
3615 3617 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
3616 3618 automatic show() calls. After discussing things with JDH, it
3617 3619 turns out there are too many corner cases where this can go wrong.
3618 3620 It's best not to try to be 'too smart', and simply have ipython
3619 3621 reproduce as much as possible the default behavior of a normal
3620 3622 python shell.
3621 3623
3622 3624 * IPython/iplib.py (InteractiveShell.__init__): Modified the
3623 3625 line-splitting regexp and _prefilter() to avoid calling getattr()
3624 3626 on assignments. This closes
3625 3627 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
3626 3628 readline uses getattr(), so a simple <TAB> keypress is still
3627 3629 enough to trigger getattr() calls on an object.
3628 3630
3629 3631 2005-01-21 Fernando Perez <fperez@colorado.edu>
3630 3632
3631 3633 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
3632 3634 docstring under pylab so it doesn't mask the original.
3633 3635
3634 3636 2005-01-21 *** Released version 0.6.7
3635 3637
3636 3638 2005-01-21 Fernando Perez <fperez@colorado.edu>
3637 3639
3638 3640 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
3639 3641 signal handling for win32 users in multithreaded mode.
3640 3642
3641 3643 2005-01-17 Fernando Perez <fperez@colorado.edu>
3642 3644
3643 3645 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3644 3646 instances with no __init__. After a crash report by Norbert Nemec
3645 3647 <Norbert-AT-nemec-online.de>.
3646 3648
3647 3649 2005-01-14 Fernando Perez <fperez@colorado.edu>
3648 3650
3649 3651 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
3650 3652 names for verbose exceptions, when multiple dotted names and the
3651 3653 'parent' object were present on the same line.
3652 3654
3653 3655 2005-01-11 Fernando Perez <fperez@colorado.edu>
3654 3656
3655 3657 * IPython/genutils.py (flag_calls): new utility to trap and flag
3656 3658 calls in functions. I need it to clean up matplotlib support.
3657 3659 Also removed some deprecated code in genutils.
3658 3660
3659 3661 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
3660 3662 that matplotlib scripts called with %run, which don't call show()
3661 3663 themselves, still have their plotting windows open.
3662 3664
3663 3665 2005-01-05 Fernando Perez <fperez@colorado.edu>
3664 3666
3665 3667 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
3666 3668 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
3667 3669
3668 3670 2004-12-19 Fernando Perez <fperez@colorado.edu>
3669 3671
3670 3672 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
3671 3673 parent_runcode, which was an eyesore. The same result can be
3672 3674 obtained with Python's regular superclass mechanisms.
3673 3675
3674 3676 2004-12-17 Fernando Perez <fperez@colorado.edu>
3675 3677
3676 3678 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
3677 3679 reported by Prabhu.
3678 3680 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
3679 3681 sys.stderr) instead of explicitly calling sys.stderr. This helps
3680 3682 maintain our I/O abstractions clean, for future GUI embeddings.
3681 3683
3682 3684 * IPython/genutils.py (info): added new utility for sys.stderr
3683 3685 unified info message handling (thin wrapper around warn()).
3684 3686
3685 3687 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
3686 3688 composite (dotted) names on verbose exceptions.
3687 3689 (VerboseTB.nullrepr): harden against another kind of errors which
3688 3690 Python's inspect module can trigger, and which were crashing
3689 3691 IPython. Thanks to a report by Marco Lombardi
3690 3692 <mlombard-AT-ma010192.hq.eso.org>.
3691 3693
3692 3694 2004-12-13 *** Released version 0.6.6
3693 3695
3694 3696 2004-12-12 Fernando Perez <fperez@colorado.edu>
3695 3697
3696 3698 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
3697 3699 generated by pygtk upon initialization if it was built without
3698 3700 threads (for matplotlib users). After a crash reported by
3699 3701 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
3700 3702
3701 3703 * IPython/ipmaker.py (make_IPython): fix small bug in the
3702 3704 import_some parameter for multiple imports.
3703 3705
3704 3706 * IPython/iplib.py (ipmagic): simplified the interface of
3705 3707 ipmagic() to take a single string argument, just as it would be
3706 3708 typed at the IPython cmd line.
3707 3709 (ipalias): Added new ipalias() with an interface identical to
3708 3710 ipmagic(). This completes exposing a pure python interface to the
3709 3711 alias and magic system, which can be used in loops or more complex
3710 3712 code where IPython's automatic line mangling is not active.
3711 3713
3712 3714 * IPython/genutils.py (timing): changed interface of timing to
3713 3715 simply run code once, which is the most common case. timings()
3714 3716 remains unchanged, for the cases where you want multiple runs.
3715 3717
3716 3718 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
3717 3719 bug where Python2.2 crashes with exec'ing code which does not end
3718 3720 in a single newline. Python 2.3 is OK, so I hadn't noticed this
3719 3721 before.
3720 3722
3721 3723 2004-12-10 Fernando Perez <fperez@colorado.edu>
3722 3724
3723 3725 * IPython/Magic.py (Magic.magic_prun): changed name of option from
3724 3726 -t to -T, to accomodate the new -t flag in %run (the %run and
3725 3727 %prun options are kind of intermixed, and it's not easy to change
3726 3728 this with the limitations of python's getopt).
3727 3729
3728 3730 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
3729 3731 the execution of scripts. It's not as fine-tuned as timeit.py,
3730 3732 but it works from inside ipython (and under 2.2, which lacks
3731 3733 timeit.py). Optionally a number of runs > 1 can be given for
3732 3734 timing very short-running code.
3733 3735
3734 3736 * IPython/genutils.py (uniq_stable): new routine which returns a
3735 3737 list of unique elements in any iterable, but in stable order of
3736 3738 appearance. I needed this for the ultraTB fixes, and it's a handy
3737 3739 utility.
3738 3740
3739 3741 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
3740 3742 dotted names in Verbose exceptions. This had been broken since
3741 3743 the very start, now x.y will properly be printed in a Verbose
3742 3744 traceback, instead of x being shown and y appearing always as an
3743 3745 'undefined global'. Getting this to work was a bit tricky,
3744 3746 because by default python tokenizers are stateless. Saved by
3745 3747 python's ability to easily add a bit of state to an arbitrary
3746 3748 function (without needing to build a full-blown callable object).
3747 3749
3748 3750 Also big cleanup of this code, which had horrendous runtime
3749 3751 lookups of zillions of attributes for colorization. Moved all
3750 3752 this code into a few templates, which make it cleaner and quicker.
3751 3753
3752 3754 Printout quality was also improved for Verbose exceptions: one
3753 3755 variable per line, and memory addresses are printed (this can be
3754 3756 quite handy in nasty debugging situations, which is what Verbose
3755 3757 is for).
3756 3758
3757 3759 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
3758 3760 the command line as scripts to be loaded by embedded instances.
3759 3761 Doing so has the potential for an infinite recursion if there are
3760 3762 exceptions thrown in the process. This fixes a strange crash
3761 3763 reported by Philippe MULLER <muller-AT-irit.fr>.
3762 3764
3763 3765 2004-12-09 Fernando Perez <fperez@colorado.edu>
3764 3766
3765 3767 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
3766 3768 to reflect new names in matplotlib, which now expose the
3767 3769 matlab-compatible interface via a pylab module instead of the
3768 3770 'matlab' name. The new code is backwards compatible, so users of
3769 3771 all matplotlib versions are OK. Patch by J. Hunter.
3770 3772
3771 3773 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
3772 3774 of __init__ docstrings for instances (class docstrings are already
3773 3775 automatically printed). Instances with customized docstrings
3774 3776 (indep. of the class) are also recognized and all 3 separate
3775 3777 docstrings are printed (instance, class, constructor). After some
3776 3778 comments/suggestions by J. Hunter.
3777 3779
3778 3780 2004-12-05 Fernando Perez <fperez@colorado.edu>
3779 3781
3780 3782 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
3781 3783 warnings when tab-completion fails and triggers an exception.
3782 3784
3783 3785 2004-12-03 Fernando Perez <fperez@colorado.edu>
3784 3786
3785 3787 * IPython/Magic.py (magic_prun): Fix bug where an exception would
3786 3788 be triggered when using 'run -p'. An incorrect option flag was
3787 3789 being set ('d' instead of 'D').
3788 3790 (manpage): fix missing escaped \- sign.
3789 3791
3790 3792 2004-11-30 *** Released version 0.6.5
3791 3793
3792 3794 2004-11-30 Fernando Perez <fperez@colorado.edu>
3793 3795
3794 3796 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
3795 3797 setting with -d option.
3796 3798
3797 3799 * setup.py (docfiles): Fix problem where the doc glob I was using
3798 3800 was COMPLETELY BROKEN. It was giving the right files by pure
3799 3801 accident, but failed once I tried to include ipython.el. Note:
3800 3802 glob() does NOT allow you to do exclusion on multiple endings!
3801 3803
3802 3804 2004-11-29 Fernando Perez <fperez@colorado.edu>
3803 3805
3804 3806 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
3805 3807 the manpage as the source. Better formatting & consistency.
3806 3808
3807 3809 * IPython/Magic.py (magic_run): Added new -d option, to run
3808 3810 scripts under the control of the python pdb debugger. Note that
3809 3811 this required changing the %prun option -d to -D, to avoid a clash
3810 3812 (since %run must pass options to %prun, and getopt is too dumb to
3811 3813 handle options with string values with embedded spaces). Thanks
3812 3814 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
3813 3815 (magic_who_ls): added type matching to %who and %whos, so that one
3814 3816 can filter their output to only include variables of certain
3815 3817 types. Another suggestion by Matthew.
3816 3818 (magic_whos): Added memory summaries in kb and Mb for arrays.
3817 3819 (magic_who): Improve formatting (break lines every 9 vars).
3818 3820
3819 3821 2004-11-28 Fernando Perez <fperez@colorado.edu>
3820 3822
3821 3823 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
3822 3824 cache when empty lines were present.
3823 3825
3824 3826 2004-11-24 Fernando Perez <fperez@colorado.edu>
3825 3827
3826 3828 * IPython/usage.py (__doc__): document the re-activated threading
3827 3829 options for WX and GTK.
3828 3830
3829 3831 2004-11-23 Fernando Perez <fperez@colorado.edu>
3830 3832
3831 3833 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
3832 3834 the -wthread and -gthread options, along with a new -tk one to try
3833 3835 and coordinate Tk threading with wx/gtk. The tk support is very
3834 3836 platform dependent, since it seems to require Tcl and Tk to be
3835 3837 built with threads (Fedora1/2 appears NOT to have it, but in
3836 3838 Prabhu's Debian boxes it works OK). But even with some Tk
3837 3839 limitations, this is a great improvement.
3838 3840
3839 3841 * IPython/Prompts.py (prompt_specials_color): Added \t for time
3840 3842 info in user prompts. Patch by Prabhu.
3841 3843
3842 3844 2004-11-18 Fernando Perez <fperez@colorado.edu>
3843 3845
3844 3846 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
3845 3847 EOFErrors and bail, to avoid infinite loops if a non-terminating
3846 3848 file is fed into ipython. Patch submitted in issue 19 by user,
3847 3849 many thanks.
3848 3850
3849 3851 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
3850 3852 autoquote/parens in continuation prompts, which can cause lots of
3851 3853 problems. Closes roundup issue 20.
3852 3854
3853 3855 2004-11-17 Fernando Perez <fperez@colorado.edu>
3854 3856
3855 3857 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
3856 3858 reported as debian bug #280505. I'm not sure my local changelog
3857 3859 entry has the proper debian format (Jack?).
3858 3860
3859 3861 2004-11-08 *** Released version 0.6.4
3860 3862
3861 3863 2004-11-08 Fernando Perez <fperez@colorado.edu>
3862 3864
3863 3865 * IPython/iplib.py (init_readline): Fix exit message for Windows
3864 3866 when readline is active. Thanks to a report by Eric Jones
3865 3867 <eric-AT-enthought.com>.
3866 3868
3867 3869 2004-11-07 Fernando Perez <fperez@colorado.edu>
3868 3870
3869 3871 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3870 3872 sometimes seen by win2k/cygwin users.
3871 3873
3872 3874 2004-11-06 Fernando Perez <fperez@colorado.edu>
3873 3875
3874 3876 * IPython/iplib.py (interact): Change the handling of %Exit from
3875 3877 trying to propagate a SystemExit to an internal ipython flag.
3876 3878 This is less elegant than using Python's exception mechanism, but
3877 3879 I can't get that to work reliably with threads, so under -pylab
3878 3880 %Exit was hanging IPython. Cross-thread exception handling is
3879 3881 really a bitch. Thaks to a bug report by Stephen Walton
3880 3882 <stephen.walton-AT-csun.edu>.
3881 3883
3882 3884 2004-11-04 Fernando Perez <fperez@colorado.edu>
3883 3885
3884 3886 * IPython/iplib.py (raw_input_original): store a pointer to the
3885 3887 true raw_input to harden against code which can modify it
3886 3888 (wx.py.PyShell does this and would otherwise crash ipython).
3887 3889 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3888 3890
3889 3891 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3890 3892 Ctrl-C problem, which does not mess up the input line.
3891 3893
3892 3894 2004-11-03 Fernando Perez <fperez@colorado.edu>
3893 3895
3894 3896 * IPython/Release.py: Changed licensing to BSD, in all files.
3895 3897 (name): lowercase name for tarball/RPM release.
3896 3898
3897 3899 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3898 3900 use throughout ipython.
3899 3901
3900 3902 * IPython/Magic.py (Magic._ofind): Switch to using the new
3901 3903 OInspect.getdoc() function.
3902 3904
3903 3905 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3904 3906 of the line currently being canceled via Ctrl-C. It's extremely
3905 3907 ugly, but I don't know how to do it better (the problem is one of
3906 3908 handling cross-thread exceptions).
3907 3909
3908 3910 2004-10-28 Fernando Perez <fperez@colorado.edu>
3909 3911
3910 3912 * IPython/Shell.py (signal_handler): add signal handlers to trap
3911 3913 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3912 3914 report by Francesc Alted.
3913 3915
3914 3916 2004-10-21 Fernando Perez <fperez@colorado.edu>
3915 3917
3916 3918 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3917 3919 to % for pysh syntax extensions.
3918 3920
3919 3921 2004-10-09 Fernando Perez <fperez@colorado.edu>
3920 3922
3921 3923 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3922 3924 arrays to print a more useful summary, without calling str(arr).
3923 3925 This avoids the problem of extremely lengthy computations which
3924 3926 occur if arr is large, and appear to the user as a system lockup
3925 3927 with 100% cpu activity. After a suggestion by Kristian Sandberg
3926 3928 <Kristian.Sandberg@colorado.edu>.
3927 3929 (Magic.__init__): fix bug in global magic escapes not being
3928 3930 correctly set.
3929 3931
3930 3932 2004-10-08 Fernando Perez <fperez@colorado.edu>
3931 3933
3932 3934 * IPython/Magic.py (__license__): change to absolute imports of
3933 3935 ipython's own internal packages, to start adapting to the absolute
3934 3936 import requirement of PEP-328.
3935 3937
3936 3938 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3937 3939 files, and standardize author/license marks through the Release
3938 3940 module instead of having per/file stuff (except for files with
3939 3941 particular licenses, like the MIT/PSF-licensed codes).
3940 3942
3941 3943 * IPython/Debugger.py: remove dead code for python 2.1
3942 3944
3943 3945 2004-10-04 Fernando Perez <fperez@colorado.edu>
3944 3946
3945 3947 * IPython/iplib.py (ipmagic): New function for accessing magics
3946 3948 via a normal python function call.
3947 3949
3948 3950 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3949 3951 from '@' to '%', to accomodate the new @decorator syntax of python
3950 3952 2.4.
3951 3953
3952 3954 2004-09-29 Fernando Perez <fperez@colorado.edu>
3953 3955
3954 3956 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3955 3957 matplotlib.use to prevent running scripts which try to switch
3956 3958 interactive backends from within ipython. This will just crash
3957 3959 the python interpreter, so we can't allow it (but a detailed error
3958 3960 is given to the user).
3959 3961
3960 3962 2004-09-28 Fernando Perez <fperez@colorado.edu>
3961 3963
3962 3964 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3963 3965 matplotlib-related fixes so that using @run with non-matplotlib
3964 3966 scripts doesn't pop up spurious plot windows. This requires
3965 3967 matplotlib >= 0.63, where I had to make some changes as well.
3966 3968
3967 3969 * IPython/ipmaker.py (make_IPython): update version requirement to
3968 3970 python 2.2.
3969 3971
3970 3972 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3971 3973 banner arg for embedded customization.
3972 3974
3973 3975 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3974 3976 explicit uses of __IP as the IPython's instance name. Now things
3975 3977 are properly handled via the shell.name value. The actual code
3976 3978 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3977 3979 is much better than before. I'll clean things completely when the
3978 3980 magic stuff gets a real overhaul.
3979 3981
3980 3982 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3981 3983 minor changes to debian dir.
3982 3984
3983 3985 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3984 3986 pointer to the shell itself in the interactive namespace even when
3985 3987 a user-supplied dict is provided. This is needed for embedding
3986 3988 purposes (found by tests with Michel Sanner).
3987 3989
3988 3990 2004-09-27 Fernando Perez <fperez@colorado.edu>
3989 3991
3990 3992 * IPython/UserConfig/ipythonrc: remove []{} from
3991 3993 readline_remove_delims, so that things like [modname.<TAB> do
3992 3994 proper completion. This disables [].TAB, but that's a less common
3993 3995 case than module names in list comprehensions, for example.
3994 3996 Thanks to a report by Andrea Riciputi.
3995 3997
3996 3998 2004-09-09 Fernando Perez <fperez@colorado.edu>
3997 3999
3998 4000 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3999 4001 blocking problems in win32 and osx. Fix by John.
4000 4002
4001 4003 2004-09-08 Fernando Perez <fperez@colorado.edu>
4002 4004
4003 4005 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
4004 4006 for Win32 and OSX. Fix by John Hunter.
4005 4007
4006 4008 2004-08-30 *** Released version 0.6.3
4007 4009
4008 4010 2004-08-30 Fernando Perez <fperez@colorado.edu>
4009 4011
4010 4012 * setup.py (isfile): Add manpages to list of dependent files to be
4011 4013 updated.
4012 4014
4013 4015 2004-08-27 Fernando Perez <fperez@colorado.edu>
4014 4016
4015 4017 * IPython/Shell.py (start): I've disabled -wthread and -gthread
4016 4018 for now. They don't really work with standalone WX/GTK code
4017 4019 (though matplotlib IS working fine with both of those backends).
4018 4020 This will neeed much more testing. I disabled most things with
4019 4021 comments, so turning it back on later should be pretty easy.
4020 4022
4021 4023 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
4022 4024 autocalling of expressions like r'foo', by modifying the line
4023 4025 split regexp. Closes
4024 4026 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
4025 4027 Riley <ipythonbugs-AT-sabi.net>.
4026 4028 (InteractiveShell.mainloop): honor --nobanner with banner
4027 4029 extensions.
4028 4030
4029 4031 * IPython/Shell.py: Significant refactoring of all classes, so
4030 4032 that we can really support ALL matplotlib backends and threading
4031 4033 models (John spotted a bug with Tk which required this). Now we
4032 4034 should support single-threaded, WX-threads and GTK-threads, both
4033 4035 for generic code and for matplotlib.
4034 4036
4035 4037 * IPython/ipmaker.py (__call__): Changed -mpthread option to
4036 4038 -pylab, to simplify things for users. Will also remove the pylab
4037 4039 profile, since now all of matplotlib configuration is directly
4038 4040 handled here. This also reduces startup time.
4039 4041
4040 4042 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
4041 4043 shell wasn't being correctly called. Also in IPShellWX.
4042 4044
4043 4045 * IPython/iplib.py (InteractiveShell.__init__): Added option to
4044 4046 fine-tune banner.
4045 4047
4046 4048 * IPython/numutils.py (spike): Deprecate these spike functions,
4047 4049 delete (long deprecated) gnuplot_exec handler.
4048 4050
4049 4051 2004-08-26 Fernando Perez <fperez@colorado.edu>
4050 4052
4051 4053 * ipython.1: Update for threading options, plus some others which
4052 4054 were missing.
4053 4055
4054 4056 * IPython/ipmaker.py (__call__): Added -wthread option for
4055 4057 wxpython thread handling. Make sure threading options are only
4056 4058 valid at the command line.
4057 4059
4058 4060 * scripts/ipython: moved shell selection into a factory function
4059 4061 in Shell.py, to keep the starter script to a minimum.
4060 4062
4061 4063 2004-08-25 Fernando Perez <fperez@colorado.edu>
4062 4064
4063 4065 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
4064 4066 John. Along with some recent changes he made to matplotlib, the
4065 4067 next versions of both systems should work very well together.
4066 4068
4067 4069 2004-08-24 Fernando Perez <fperez@colorado.edu>
4068 4070
4069 4071 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
4070 4072 tried to switch the profiling to using hotshot, but I'm getting
4071 4073 strange errors from prof.runctx() there. I may be misreading the
4072 4074 docs, but it looks weird. For now the profiling code will
4073 4075 continue to use the standard profiler.
4074 4076
4075 4077 2004-08-23 Fernando Perez <fperez@colorado.edu>
4076 4078
4077 4079 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
4078 4080 threaded shell, by John Hunter. It's not quite ready yet, but
4079 4081 close.
4080 4082
4081 4083 2004-08-22 Fernando Perez <fperez@colorado.edu>
4082 4084
4083 4085 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
4084 4086 in Magic and ultraTB.
4085 4087
4086 4088 * ipython.1: document threading options in manpage.
4087 4089
4088 4090 * scripts/ipython: Changed name of -thread option to -gthread,
4089 4091 since this is GTK specific. I want to leave the door open for a
4090 4092 -wthread option for WX, which will most likely be necessary. This
4091 4093 change affects usage and ipmaker as well.
4092 4094
4093 4095 * IPython/Shell.py (matplotlib_shell): Add a factory function to
4094 4096 handle the matplotlib shell issues. Code by John Hunter
4095 4097 <jdhunter-AT-nitace.bsd.uchicago.edu>.
4096 4098 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
4097 4099 broken (and disabled for end users) for now, but it puts the
4098 4100 infrastructure in place.
4099 4101
4100 4102 2004-08-21 Fernando Perez <fperez@colorado.edu>
4101 4103
4102 4104 * ipythonrc-pylab: Add matplotlib support.
4103 4105
4104 4106 * matplotlib_config.py: new files for matplotlib support, part of
4105 4107 the pylab profile.
4106 4108
4107 4109 * IPython/usage.py (__doc__): documented the threading options.
4108 4110
4109 4111 2004-08-20 Fernando Perez <fperez@colorado.edu>
4110 4112
4111 4113 * ipython: Modified the main calling routine to handle the -thread
4112 4114 and -mpthread options. This needs to be done as a top-level hack,
4113 4115 because it determines which class to instantiate for IPython
4114 4116 itself.
4115 4117
4116 4118 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
4117 4119 classes to support multithreaded GTK operation without blocking,
4118 4120 and matplotlib with all backends. This is a lot of still very
4119 4121 experimental code, and threads are tricky. So it may still have a
4120 4122 few rough edges... This code owes a lot to
4121 4123 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
4122 4124 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
4123 4125 to John Hunter for all the matplotlib work.
4124 4126
4125 4127 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
4126 4128 options for gtk thread and matplotlib support.
4127 4129
4128 4130 2004-08-16 Fernando Perez <fperez@colorado.edu>
4129 4131
4130 4132 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
4131 4133 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
4132 4134 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
4133 4135
4134 4136 2004-08-11 Fernando Perez <fperez@colorado.edu>
4135 4137
4136 4138 * setup.py (isfile): Fix build so documentation gets updated for
4137 4139 rpms (it was only done for .tgz builds).
4138 4140
4139 4141 2004-08-10 Fernando Perez <fperez@colorado.edu>
4140 4142
4141 4143 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
4142 4144
4143 4145 * iplib.py : Silence syntax error exceptions in tab-completion.
4144 4146
4145 4147 2004-08-05 Fernando Perez <fperez@colorado.edu>
4146 4148
4147 4149 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
4148 4150 'color off' mark for continuation prompts. This was causing long
4149 4151 continuation lines to mis-wrap.
4150 4152
4151 4153 2004-08-01 Fernando Perez <fperez@colorado.edu>
4152 4154
4153 4155 * IPython/ipmaker.py (make_IPython): Allow the shell class used
4154 4156 for building ipython to be a parameter. All this is necessary
4155 4157 right now to have a multithreaded version, but this insane
4156 4158 non-design will be cleaned up soon. For now, it's a hack that
4157 4159 works.
4158 4160
4159 4161 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
4160 4162 args in various places. No bugs so far, but it's a dangerous
4161 4163 practice.
4162 4164
4163 4165 2004-07-31 Fernando Perez <fperez@colorado.edu>
4164 4166
4165 4167 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
4166 4168 fix completion of files with dots in their names under most
4167 4169 profiles (pysh was OK because the completion order is different).
4168 4170
4169 4171 2004-07-27 Fernando Perez <fperez@colorado.edu>
4170 4172
4171 4173 * IPython/iplib.py (InteractiveShell.__init__): build dict of
4172 4174 keywords manually, b/c the one in keyword.py was removed in python
4173 4175 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
4174 4176 This is NOT a bug under python 2.3 and earlier.
4175 4177
4176 4178 2004-07-26 Fernando Perez <fperez@colorado.edu>
4177 4179
4178 4180 * IPython/ultraTB.py (VerboseTB.text): Add another
4179 4181 linecache.checkcache() call to try to prevent inspect.py from
4180 4182 crashing under python 2.3. I think this fixes
4181 4183 http://www.scipy.net/roundup/ipython/issue17.
4182 4184
4183 4185 2004-07-26 *** Released version 0.6.2
4184 4186
4185 4187 2004-07-26 Fernando Perez <fperez@colorado.edu>
4186 4188
4187 4189 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
4188 4190 fail for any number.
4189 4191 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
4190 4192 empty bookmarks.
4191 4193
4192 4194 2004-07-26 *** Released version 0.6.1
4193 4195
4194 4196 2004-07-26 Fernando Perez <fperez@colorado.edu>
4195 4197
4196 4198 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
4197 4199
4198 4200 * IPython/iplib.py (protect_filename): Applied Ville's patch for
4199 4201 escaping '()[]{}' in filenames.
4200 4202
4201 4203 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
4202 4204 Python 2.2 users who lack a proper shlex.split.
4203 4205
4204 4206 2004-07-19 Fernando Perez <fperez@colorado.edu>
4205 4207
4206 4208 * IPython/iplib.py (InteractiveShell.init_readline): Add support
4207 4209 for reading readline's init file. I follow the normal chain:
4208 4210 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
4209 4211 report by Mike Heeter. This closes
4210 4212 http://www.scipy.net/roundup/ipython/issue16.
4211 4213
4212 4214 2004-07-18 Fernando Perez <fperez@colorado.edu>
4213 4215
4214 4216 * IPython/iplib.py (__init__): Add better handling of '\' under
4215 4217 Win32 for filenames. After a patch by Ville.
4216 4218
4217 4219 2004-07-17 Fernando Perez <fperez@colorado.edu>
4218 4220
4219 4221 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4220 4222 autocalling would be triggered for 'foo is bar' if foo is
4221 4223 callable. I also cleaned up the autocall detection code to use a
4222 4224 regexp, which is faster. Bug reported by Alexander Schmolck.
4223 4225
4224 4226 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
4225 4227 '?' in them would confuse the help system. Reported by Alex
4226 4228 Schmolck.
4227 4229
4228 4230 2004-07-16 Fernando Perez <fperez@colorado.edu>
4229 4231
4230 4232 * IPython/GnuplotInteractive.py (__all__): added plot2.
4231 4233
4232 4234 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
4233 4235 plotting dictionaries, lists or tuples of 1d arrays.
4234 4236
4235 4237 * IPython/Magic.py (Magic.magic_hist): small clenaups and
4236 4238 optimizations.
4237 4239
4238 4240 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
4239 4241 the information which was there from Janko's original IPP code:
4240 4242
4241 4243 03.05.99 20:53 porto.ifm.uni-kiel.de
4242 4244 --Started changelog.
4243 4245 --make clear do what it say it does
4244 4246 --added pretty output of lines from inputcache
4245 4247 --Made Logger a mixin class, simplifies handling of switches
4246 4248 --Added own completer class. .string<TAB> expands to last history
4247 4249 line which starts with string. The new expansion is also present
4248 4250 with Ctrl-r from the readline library. But this shows, who this
4249 4251 can be done for other cases.
4250 4252 --Added convention that all shell functions should accept a
4251 4253 parameter_string This opens the door for different behaviour for
4252 4254 each function. @cd is a good example of this.
4253 4255
4254 4256 04.05.99 12:12 porto.ifm.uni-kiel.de
4255 4257 --added logfile rotation
4256 4258 --added new mainloop method which freezes first the namespace
4257 4259
4258 4260 07.05.99 21:24 porto.ifm.uni-kiel.de
4259 4261 --added the docreader classes. Now there is a help system.
4260 4262 -This is only a first try. Currently it's not easy to put new
4261 4263 stuff in the indices. But this is the way to go. Info would be
4262 4264 better, but HTML is every where and not everybody has an info
4263 4265 system installed and it's not so easy to change html-docs to info.
4264 4266 --added global logfile option
4265 4267 --there is now a hook for object inspection method pinfo needs to
4266 4268 be provided for this. Can be reached by two '??'.
4267 4269
4268 4270 08.05.99 20:51 porto.ifm.uni-kiel.de
4269 4271 --added a README
4270 4272 --bug in rc file. Something has changed so functions in the rc
4271 4273 file need to reference the shell and not self. Not clear if it's a
4272 4274 bug or feature.
4273 4275 --changed rc file for new behavior
4274 4276
4275 4277 2004-07-15 Fernando Perez <fperez@colorado.edu>
4276 4278
4277 4279 * IPython/Logger.py (Logger.log): fixed recent bug where the input
4278 4280 cache was falling out of sync in bizarre manners when multi-line
4279 4281 input was present. Minor optimizations and cleanup.
4280 4282
4281 4283 (Logger): Remove old Changelog info for cleanup. This is the
4282 4284 information which was there from Janko's original code:
4283 4285
4284 4286 Changes to Logger: - made the default log filename a parameter
4285 4287
4286 4288 - put a check for lines beginning with !@? in log(). Needed
4287 4289 (even if the handlers properly log their lines) for mid-session
4288 4290 logging activation to work properly. Without this, lines logged
4289 4291 in mid session, which get read from the cache, would end up
4290 4292 'bare' (with !@? in the open) in the log. Now they are caught
4291 4293 and prepended with a #.
4292 4294
4293 4295 * IPython/iplib.py (InteractiveShell.init_readline): added check
4294 4296 in case MagicCompleter fails to be defined, so we don't crash.
4295 4297
4296 4298 2004-07-13 Fernando Perez <fperez@colorado.edu>
4297 4299
4298 4300 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
4299 4301 of EPS if the requested filename ends in '.eps'.
4300 4302
4301 4303 2004-07-04 Fernando Perez <fperez@colorado.edu>
4302 4304
4303 4305 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
4304 4306 escaping of quotes when calling the shell.
4305 4307
4306 4308 2004-07-02 Fernando Perez <fperez@colorado.edu>
4307 4309
4308 4310 * IPython/Prompts.py (CachedOutput.update): Fix problem with
4309 4311 gettext not working because we were clobbering '_'. Fixes
4310 4312 http://www.scipy.net/roundup/ipython/issue6.
4311 4313
4312 4314 2004-07-01 Fernando Perez <fperez@colorado.edu>
4313 4315
4314 4316 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
4315 4317 into @cd. Patch by Ville.
4316 4318
4317 4319 * IPython/iplib.py (InteractiveShell.post_config_initialization):
4318 4320 new function to store things after ipmaker runs. Patch by Ville.
4319 4321 Eventually this will go away once ipmaker is removed and the class
4320 4322 gets cleaned up, but for now it's ok. Key functionality here is
4321 4323 the addition of the persistent storage mechanism, a dict for
4322 4324 keeping data across sessions (for now just bookmarks, but more can
4323 4325 be implemented later).
4324 4326
4325 4327 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
4326 4328 persistent across sections. Patch by Ville, I modified it
4327 4329 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
4328 4330 added a '-l' option to list all bookmarks.
4329 4331
4330 4332 * IPython/iplib.py (InteractiveShell.atexit_operations): new
4331 4333 center for cleanup. Registered with atexit.register(). I moved
4332 4334 here the old exit_cleanup(). After a patch by Ville.
4333 4335
4334 4336 * IPython/Magic.py (get_py_filename): added '~' to the accepted
4335 4337 characters in the hacked shlex_split for python 2.2.
4336 4338
4337 4339 * IPython/iplib.py (file_matches): more fixes to filenames with
4338 4340 whitespace in them. It's not perfect, but limitations in python's
4339 4341 readline make it impossible to go further.
4340 4342
4341 4343 2004-06-29 Fernando Perez <fperez@colorado.edu>
4342 4344
4343 4345 * IPython/iplib.py (file_matches): escape whitespace correctly in
4344 4346 filename completions. Bug reported by Ville.
4345 4347
4346 4348 2004-06-28 Fernando Perez <fperez@colorado.edu>
4347 4349
4348 4350 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
4349 4351 the history file will be called 'history-PROFNAME' (or just
4350 4352 'history' if no profile is loaded). I was getting annoyed at
4351 4353 getting my Numerical work history clobbered by pysh sessions.
4352 4354
4353 4355 * IPython/iplib.py (InteractiveShell.__init__): Internal
4354 4356 getoutputerror() function so that we can honor the system_verbose
4355 4357 flag for _all_ system calls. I also added escaping of #
4356 4358 characters here to avoid confusing Itpl.
4357 4359
4358 4360 * IPython/Magic.py (shlex_split): removed call to shell in
4359 4361 parse_options and replaced it with shlex.split(). The annoying
4360 4362 part was that in Python 2.2, shlex.split() doesn't exist, so I had
4361 4363 to backport it from 2.3, with several frail hacks (the shlex
4362 4364 module is rather limited in 2.2). Thanks to a suggestion by Ville
4363 4365 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
4364 4366 problem.
4365 4367
4366 4368 (Magic.magic_system_verbose): new toggle to print the actual
4367 4369 system calls made by ipython. Mainly for debugging purposes.
4368 4370
4369 4371 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
4370 4372 doesn't support persistence. Reported (and fix suggested) by
4371 4373 Travis Caldwell <travis_caldwell2000@yahoo.com>.
4372 4374
4373 4375 2004-06-26 Fernando Perez <fperez@colorado.edu>
4374 4376
4375 4377 * IPython/Logger.py (Logger.log): fix to handle correctly empty
4376 4378 continue prompts.
4377 4379
4378 4380 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
4379 4381 function (basically a big docstring) and a few more things here to
4380 4382 speedup startup. pysh.py is now very lightweight. We want because
4381 4383 it gets execfile'd, while InterpreterExec gets imported, so
4382 4384 byte-compilation saves time.
4383 4385
4384 4386 2004-06-25 Fernando Perez <fperez@colorado.edu>
4385 4387
4386 4388 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
4387 4389 -NUM', which was recently broken.
4388 4390
4389 4391 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
4390 4392 in multi-line input (but not !!, which doesn't make sense there).
4391 4393
4392 4394 * IPython/UserConfig/ipythonrc: made autoindent on by default.
4393 4395 It's just too useful, and people can turn it off in the less
4394 4396 common cases where it's a problem.
4395 4397
4396 4398 2004-06-24 Fernando Perez <fperez@colorado.edu>
4397 4399
4398 4400 * IPython/iplib.py (InteractiveShell._prefilter): big change -
4399 4401 special syntaxes (like alias calling) is now allied in multi-line
4400 4402 input. This is still _very_ experimental, but it's necessary for
4401 4403 efficient shell usage combining python looping syntax with system
4402 4404 calls. For now it's restricted to aliases, I don't think it
4403 4405 really even makes sense to have this for magics.
4404 4406
4405 4407 2004-06-23 Fernando Perez <fperez@colorado.edu>
4406 4408
4407 4409 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
4408 4410 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
4409 4411
4410 4412 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
4411 4413 extensions under Windows (after code sent by Gary Bishop). The
4412 4414 extensions considered 'executable' are stored in IPython's rc
4413 4415 structure as win_exec_ext.
4414 4416
4415 4417 * IPython/genutils.py (shell): new function, like system() but
4416 4418 without return value. Very useful for interactive shell work.
4417 4419
4418 4420 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
4419 4421 delete aliases.
4420 4422
4421 4423 * IPython/iplib.py (InteractiveShell.alias_table_update): make
4422 4424 sure that the alias table doesn't contain python keywords.
4423 4425
4424 4426 2004-06-21 Fernando Perez <fperez@colorado.edu>
4425 4427
4426 4428 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
4427 4429 non-existent items are found in $PATH. Reported by Thorsten.
4428 4430
4429 4431 2004-06-20 Fernando Perez <fperez@colorado.edu>
4430 4432
4431 4433 * IPython/iplib.py (complete): modified the completer so that the
4432 4434 order of priorities can be easily changed at runtime.
4433 4435
4434 4436 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
4435 4437 Modified to auto-execute all lines beginning with '~', '/' or '.'.
4436 4438
4437 4439 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
4438 4440 expand Python variables prepended with $ in all system calls. The
4439 4441 same was done to InteractiveShell.handle_shell_escape. Now all
4440 4442 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
4441 4443 expansion of python variables and expressions according to the
4442 4444 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
4443 4445
4444 4446 Though PEP-215 has been rejected, a similar (but simpler) one
4445 4447 seems like it will go into Python 2.4, PEP-292 -
4446 4448 http://www.python.org/peps/pep-0292.html.
4447 4449
4448 4450 I'll keep the full syntax of PEP-215, since IPython has since the
4449 4451 start used Ka-Ping Yee's reference implementation discussed there
4450 4452 (Itpl), and I actually like the powerful semantics it offers.
4451 4453
4452 4454 In order to access normal shell variables, the $ has to be escaped
4453 4455 via an extra $. For example:
4454 4456
4455 4457 In [7]: PATH='a python variable'
4456 4458
4457 4459 In [8]: !echo $PATH
4458 4460 a python variable
4459 4461
4460 4462 In [9]: !echo $$PATH
4461 4463 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
4462 4464
4463 4465 (Magic.parse_options): escape $ so the shell doesn't evaluate
4464 4466 things prematurely.
4465 4467
4466 4468 * IPython/iplib.py (InteractiveShell.call_alias): added the
4467 4469 ability for aliases to expand python variables via $.
4468 4470
4469 4471 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
4470 4472 system, now there's a @rehash/@rehashx pair of magics. These work
4471 4473 like the csh rehash command, and can be invoked at any time. They
4472 4474 build a table of aliases to everything in the user's $PATH
4473 4475 (@rehash uses everything, @rehashx is slower but only adds
4474 4476 executable files). With this, the pysh.py-based shell profile can
4475 4477 now simply call rehash upon startup, and full access to all
4476 4478 programs in the user's path is obtained.
4477 4479
4478 4480 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
4479 4481 functionality is now fully in place. I removed the old dynamic
4480 4482 code generation based approach, in favor of a much lighter one
4481 4483 based on a simple dict. The advantage is that this allows me to
4482 4484 now have thousands of aliases with negligible cost (unthinkable
4483 4485 with the old system).
4484 4486
4485 4487 2004-06-19 Fernando Perez <fperez@colorado.edu>
4486 4488
4487 4489 * IPython/iplib.py (__init__): extended MagicCompleter class to
4488 4490 also complete (last in priority) on user aliases.
4489 4491
4490 4492 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
4491 4493 call to eval.
4492 4494 (ItplNS.__init__): Added a new class which functions like Itpl,
4493 4495 but allows configuring the namespace for the evaluation to occur
4494 4496 in.
4495 4497
4496 4498 2004-06-18 Fernando Perez <fperez@colorado.edu>
4497 4499
4498 4500 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
4499 4501 better message when 'exit' or 'quit' are typed (a common newbie
4500 4502 confusion).
4501 4503
4502 4504 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
4503 4505 check for Windows users.
4504 4506
4505 4507 * IPython/iplib.py (InteractiveShell.user_setup): removed
4506 4508 disabling of colors for Windows. I'll test at runtime and issue a
4507 4509 warning if Gary's readline isn't found, as to nudge users to
4508 4510 download it.
4509 4511
4510 4512 2004-06-16 Fernando Perez <fperez@colorado.edu>
4511 4513
4512 4514 * IPython/genutils.py (Stream.__init__): changed to print errors
4513 4515 to sys.stderr. I had a circular dependency here. Now it's
4514 4516 possible to run ipython as IDLE's shell (consider this pre-alpha,
4515 4517 since true stdout things end up in the starting terminal instead
4516 4518 of IDLE's out).
4517 4519
4518 4520 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
4519 4521 users who haven't # updated their prompt_in2 definitions. Remove
4520 4522 eventually.
4521 4523 (multiple_replace): added credit to original ASPN recipe.
4522 4524
4523 4525 2004-06-15 Fernando Perez <fperez@colorado.edu>
4524 4526
4525 4527 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
4526 4528 list of auto-defined aliases.
4527 4529
4528 4530 2004-06-13 Fernando Perez <fperez@colorado.edu>
4529 4531
4530 4532 * setup.py (scriptfiles): Don't trigger win_post_install unless an
4531 4533 install was really requested (so setup.py can be used for other
4532 4534 things under Windows).
4533 4535
4534 4536 2004-06-10 Fernando Perez <fperez@colorado.edu>
4535 4537
4536 4538 * IPython/Logger.py (Logger.create_log): Manually remove any old
4537 4539 backup, since os.remove may fail under Windows. Fixes bug
4538 4540 reported by Thorsten.
4539 4541
4540 4542 2004-06-09 Fernando Perez <fperez@colorado.edu>
4541 4543
4542 4544 * examples/example-embed.py: fixed all references to %n (replaced
4543 4545 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
4544 4546 for all examples and the manual as well.
4545 4547
4546 4548 2004-06-08 Fernando Perez <fperez@colorado.edu>
4547 4549
4548 4550 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
4549 4551 alignment and color management. All 3 prompt subsystems now
4550 4552 inherit from BasePrompt.
4551 4553
4552 4554 * tools/release: updates for windows installer build and tag rpms
4553 4555 with python version (since paths are fixed).
4554 4556
4555 4557 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
4556 4558 which will become eventually obsolete. Also fixed the default
4557 4559 prompt_in2 to use \D, so at least new users start with the correct
4558 4560 defaults.
4559 4561 WARNING: Users with existing ipythonrc files will need to apply
4560 4562 this fix manually!
4561 4563
4562 4564 * setup.py: make windows installer (.exe). This is finally the
4563 4565 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
4564 4566 which I hadn't included because it required Python 2.3 (or recent
4565 4567 distutils).
4566 4568
4567 4569 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
4568 4570 usage of new '\D' escape.
4569 4571
4570 4572 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
4571 4573 lacks os.getuid())
4572 4574 (CachedOutput.set_colors): Added the ability to turn coloring
4573 4575 on/off with @colors even for manually defined prompt colors. It
4574 4576 uses a nasty global, but it works safely and via the generic color
4575 4577 handling mechanism.
4576 4578 (Prompt2.__init__): Introduced new escape '\D' for continuation
4577 4579 prompts. It represents the counter ('\#') as dots.
4578 4580 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
4579 4581 need to update their ipythonrc files and replace '%n' with '\D' in
4580 4582 their prompt_in2 settings everywhere. Sorry, but there's
4581 4583 otherwise no clean way to get all prompts to properly align. The
4582 4584 ipythonrc shipped with IPython has been updated.
4583 4585
4584 4586 2004-06-07 Fernando Perez <fperez@colorado.edu>
4585 4587
4586 4588 * setup.py (isfile): Pass local_icons option to latex2html, so the
4587 4589 resulting HTML file is self-contained. Thanks to
4588 4590 dryice-AT-liu.com.cn for the tip.
4589 4591
4590 4592 * pysh.py: I created a new profile 'shell', which implements a
4591 4593 _rudimentary_ IPython-based shell. This is in NO WAY a realy
4592 4594 system shell, nor will it become one anytime soon. It's mainly
4593 4595 meant to illustrate the use of the new flexible bash-like prompts.
4594 4596 I guess it could be used by hardy souls for true shell management,
4595 4597 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
4596 4598 profile. This uses the InterpreterExec extension provided by
4597 4599 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
4598 4600
4599 4601 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
4600 4602 auto-align itself with the length of the previous input prompt
4601 4603 (taking into account the invisible color escapes).
4602 4604 (CachedOutput.__init__): Large restructuring of this class. Now
4603 4605 all three prompts (primary1, primary2, output) are proper objects,
4604 4606 managed by the 'parent' CachedOutput class. The code is still a
4605 4607 bit hackish (all prompts share state via a pointer to the cache),
4606 4608 but it's overall far cleaner than before.
4607 4609
4608 4610 * IPython/genutils.py (getoutputerror): modified to add verbose,
4609 4611 debug and header options. This makes the interface of all getout*
4610 4612 functions uniform.
4611 4613 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
4612 4614
4613 4615 * IPython/Magic.py (Magic.default_option): added a function to
4614 4616 allow registering default options for any magic command. This
4615 4617 makes it easy to have profiles which customize the magics globally
4616 4618 for a certain use. The values set through this function are
4617 4619 picked up by the parse_options() method, which all magics should
4618 4620 use to parse their options.
4619 4621
4620 4622 * IPython/genutils.py (warn): modified the warnings framework to
4621 4623 use the Term I/O class. I'm trying to slowly unify all of
4622 4624 IPython's I/O operations to pass through Term.
4623 4625
4624 4626 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
4625 4627 the secondary prompt to correctly match the length of the primary
4626 4628 one for any prompt. Now multi-line code will properly line up
4627 4629 even for path dependent prompts, such as the new ones available
4628 4630 via the prompt_specials.
4629 4631
4630 4632 2004-06-06 Fernando Perez <fperez@colorado.edu>
4631 4633
4632 4634 * IPython/Prompts.py (prompt_specials): Added the ability to have
4633 4635 bash-like special sequences in the prompts, which get
4634 4636 automatically expanded. Things like hostname, current working
4635 4637 directory and username are implemented already, but it's easy to
4636 4638 add more in the future. Thanks to a patch by W.J. van der Laan
4637 4639 <gnufnork-AT-hetdigitalegat.nl>
4638 4640 (prompt_specials): Added color support for prompt strings, so
4639 4641 users can define arbitrary color setups for their prompts.
4640 4642
4641 4643 2004-06-05 Fernando Perez <fperez@colorado.edu>
4642 4644
4643 4645 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
4644 4646 code to load Gary Bishop's readline and configure it
4645 4647 automatically. Thanks to Gary for help on this.
4646 4648
4647 4649 2004-06-01 Fernando Perez <fperez@colorado.edu>
4648 4650
4649 4651 * IPython/Logger.py (Logger.create_log): fix bug for logging
4650 4652 with no filename (previous fix was incomplete).
4651 4653
4652 4654 2004-05-25 Fernando Perez <fperez@colorado.edu>
4653 4655
4654 4656 * IPython/Magic.py (Magic.parse_options): fix bug where naked
4655 4657 parens would get passed to the shell.
4656 4658
4657 4659 2004-05-20 Fernando Perez <fperez@colorado.edu>
4658 4660
4659 4661 * IPython/Magic.py (Magic.magic_prun): changed default profile
4660 4662 sort order to 'time' (the more common profiling need).
4661 4663
4662 4664 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
4663 4665 so that source code shown is guaranteed in sync with the file on
4664 4666 disk (also changed in psource). Similar fix to the one for
4665 4667 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
4666 4668 <yann.ledu-AT-noos.fr>.
4667 4669
4668 4670 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
4669 4671 with a single option would not be correctly parsed. Closes
4670 4672 http://www.scipy.net/roundup/ipython/issue14. This bug had been
4671 4673 introduced in 0.6.0 (on 2004-05-06).
4672 4674
4673 4675 2004-05-13 *** Released version 0.6.0
4674 4676
4675 4677 2004-05-13 Fernando Perez <fperez@colorado.edu>
4676 4678
4677 4679 * debian/: Added debian/ directory to CVS, so that debian support
4678 4680 is publicly accessible. The debian package is maintained by Jack
4679 4681 Moffit <jack-AT-xiph.org>.
4680 4682
4681 4683 * Documentation: included the notes about an ipython-based system
4682 4684 shell (the hypothetical 'pysh') into the new_design.pdf document,
4683 4685 so that these ideas get distributed to users along with the
4684 4686 official documentation.
4685 4687
4686 4688 2004-05-10 Fernando Perez <fperez@colorado.edu>
4687 4689
4688 4690 * IPython/Logger.py (Logger.create_log): fix recently introduced
4689 4691 bug (misindented line) where logstart would fail when not given an
4690 4692 explicit filename.
4691 4693
4692 4694 2004-05-09 Fernando Perez <fperez@colorado.edu>
4693 4695
4694 4696 * IPython/Magic.py (Magic.parse_options): skip system call when
4695 4697 there are no options to look for. Faster, cleaner for the common
4696 4698 case.
4697 4699
4698 4700 * Documentation: many updates to the manual: describing Windows
4699 4701 support better, Gnuplot updates, credits, misc small stuff. Also
4700 4702 updated the new_design doc a bit.
4701 4703
4702 4704 2004-05-06 *** Released version 0.6.0.rc1
4703 4705
4704 4706 2004-05-06 Fernando Perez <fperez@colorado.edu>
4705 4707
4706 4708 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
4707 4709 operations to use the vastly more efficient list/''.join() method.
4708 4710 (FormattedTB.text): Fix
4709 4711 http://www.scipy.net/roundup/ipython/issue12 - exception source
4710 4712 extract not updated after reload. Thanks to Mike Salib
4711 4713 <msalib-AT-mit.edu> for pinning the source of the problem.
4712 4714 Fortunately, the solution works inside ipython and doesn't require
4713 4715 any changes to python proper.
4714 4716
4715 4717 * IPython/Magic.py (Magic.parse_options): Improved to process the
4716 4718 argument list as a true shell would (by actually using the
4717 4719 underlying system shell). This way, all @magics automatically get
4718 4720 shell expansion for variables. Thanks to a comment by Alex
4719 4721 Schmolck.
4720 4722
4721 4723 2004-04-04 Fernando Perez <fperez@colorado.edu>
4722 4724
4723 4725 * IPython/iplib.py (InteractiveShell.interact): Added a special
4724 4726 trap for a debugger quit exception, which is basically impossible
4725 4727 to handle by normal mechanisms, given what pdb does to the stack.
4726 4728 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
4727 4729
4728 4730 2004-04-03 Fernando Perez <fperez@colorado.edu>
4729 4731
4730 4732 * IPython/genutils.py (Term): Standardized the names of the Term
4731 4733 class streams to cin/cout/cerr, following C++ naming conventions
4732 4734 (I can't use in/out/err because 'in' is not a valid attribute
4733 4735 name).
4734 4736
4735 4737 * IPython/iplib.py (InteractiveShell.interact): don't increment
4736 4738 the prompt if there's no user input. By Daniel 'Dang' Griffith
4737 4739 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
4738 4740 Francois Pinard.
4739 4741
4740 4742 2004-04-02 Fernando Perez <fperez@colorado.edu>
4741 4743
4742 4744 * IPython/genutils.py (Stream.__init__): Modified to survive at
4743 4745 least importing in contexts where stdin/out/err aren't true file
4744 4746 objects, such as PyCrust (they lack fileno() and mode). However,
4745 4747 the recovery facilities which rely on these things existing will
4746 4748 not work.
4747 4749
4748 4750 2004-04-01 Fernando Perez <fperez@colorado.edu>
4749 4751
4750 4752 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
4751 4753 use the new getoutputerror() function, so it properly
4752 4754 distinguishes stdout/err.
4753 4755
4754 4756 * IPython/genutils.py (getoutputerror): added a function to
4755 4757 capture separately the standard output and error of a command.
4756 4758 After a comment from dang on the mailing lists. This code is
4757 4759 basically a modified version of commands.getstatusoutput(), from
4758 4760 the standard library.
4759 4761
4760 4762 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
4761 4763 '!!' as a special syntax (shorthand) to access @sx.
4762 4764
4763 4765 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
4764 4766 command and return its output as a list split on '\n'.
4765 4767
4766 4768 2004-03-31 Fernando Perez <fperez@colorado.edu>
4767 4769
4768 4770 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
4769 4771 method to dictionaries used as FakeModule instances if they lack
4770 4772 it. At least pydoc in python2.3 breaks for runtime-defined
4771 4773 functions without this hack. At some point I need to _really_
4772 4774 understand what FakeModule is doing, because it's a gross hack.
4773 4775 But it solves Arnd's problem for now...
4774 4776
4775 4777 2004-02-27 Fernando Perez <fperez@colorado.edu>
4776 4778
4777 4779 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
4778 4780 mode would behave erratically. Also increased the number of
4779 4781 possible logs in rotate mod to 999. Thanks to Rod Holland
4780 4782 <rhh@StructureLABS.com> for the report and fixes.
4781 4783
4782 4784 2004-02-26 Fernando Perez <fperez@colorado.edu>
4783 4785
4784 4786 * IPython/genutils.py (page): Check that the curses module really
4785 4787 has the initscr attribute before trying to use it. For some
4786 4788 reason, the Solaris curses module is missing this. I think this
4787 4789 should be considered a Solaris python bug, but I'm not sure.
4788 4790
4789 4791 2004-01-17 Fernando Perez <fperez@colorado.edu>
4790 4792
4791 4793 * IPython/genutils.py (Stream.__init__): Changes to try to make
4792 4794 ipython robust against stdin/out/err being closed by the user.
4793 4795 This is 'user error' (and blocks a normal python session, at least
4794 4796 the stdout case). However, Ipython should be able to survive such
4795 4797 instances of abuse as gracefully as possible. To simplify the
4796 4798 coding and maintain compatibility with Gary Bishop's Term
4797 4799 contributions, I've made use of classmethods for this. I think
4798 4800 this introduces a dependency on python 2.2.
4799 4801
4800 4802 2004-01-13 Fernando Perez <fperez@colorado.edu>
4801 4803
4802 4804 * IPython/numutils.py (exp_safe): simplified the code a bit and
4803 4805 removed the need for importing the kinds module altogether.
4804 4806
4805 4807 2004-01-06 Fernando Perez <fperez@colorado.edu>
4806 4808
4807 4809 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
4808 4810 a magic function instead, after some community feedback. No
4809 4811 special syntax will exist for it, but its name is deliberately
4810 4812 very short.
4811 4813
4812 4814 2003-12-20 Fernando Perez <fperez@colorado.edu>
4813 4815
4814 4816 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
4815 4817 new functionality, to automagically assign the result of a shell
4816 4818 command to a variable. I'll solicit some community feedback on
4817 4819 this before making it permanent.
4818 4820
4819 4821 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
4820 4822 requested about callables for which inspect couldn't obtain a
4821 4823 proper argspec. Thanks to a crash report sent by Etienne
4822 4824 Posthumus <etienne-AT-apple01.cs.vu.nl>.
4823 4825
4824 4826 2003-12-09 Fernando Perez <fperez@colorado.edu>
4825 4827
4826 4828 * IPython/genutils.py (page): patch for the pager to work across
4827 4829 various versions of Windows. By Gary Bishop.
4828 4830
4829 4831 2003-12-04 Fernando Perez <fperez@colorado.edu>
4830 4832
4831 4833 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
4832 4834 Gnuplot.py version 1.7, whose internal names changed quite a bit.
4833 4835 While I tested this and it looks ok, there may still be corner
4834 4836 cases I've missed.
4835 4837
4836 4838 2003-12-01 Fernando Perez <fperez@colorado.edu>
4837 4839
4838 4840 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
4839 4841 where a line like 'p,q=1,2' would fail because the automagic
4840 4842 system would be triggered for @p.
4841 4843
4842 4844 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
4843 4845 cleanups, code unmodified.
4844 4846
4845 4847 * IPython/genutils.py (Term): added a class for IPython to handle
4846 4848 output. In most cases it will just be a proxy for stdout/err, but
4847 4849 having this allows modifications to be made for some platforms,
4848 4850 such as handling color escapes under Windows. All of this code
4849 4851 was contributed by Gary Bishop, with minor modifications by me.
4850 4852 The actual changes affect many files.
4851 4853
4852 4854 2003-11-30 Fernando Perez <fperez@colorado.edu>
4853 4855
4854 4856 * IPython/iplib.py (file_matches): new completion code, courtesy
4855 4857 of Jeff Collins. This enables filename completion again under
4856 4858 python 2.3, which disabled it at the C level.
4857 4859
4858 4860 2003-11-11 Fernando Perez <fperez@colorado.edu>
4859 4861
4860 4862 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
4861 4863 for Numeric.array(map(...)), but often convenient.
4862 4864
4863 4865 2003-11-05 Fernando Perez <fperez@colorado.edu>
4864 4866
4865 4867 * IPython/numutils.py (frange): Changed a call from int() to
4866 4868 int(round()) to prevent a problem reported with arange() in the
4867 4869 numpy list.
4868 4870
4869 4871 2003-10-06 Fernando Perez <fperez@colorado.edu>
4870 4872
4871 4873 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4872 4874 prevent crashes if sys lacks an argv attribute (it happens with
4873 4875 embedded interpreters which build a bare-bones sys module).
4874 4876 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4875 4877
4876 4878 2003-09-24 Fernando Perez <fperez@colorado.edu>
4877 4879
4878 4880 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4879 4881 to protect against poorly written user objects where __getattr__
4880 4882 raises exceptions other than AttributeError. Thanks to a bug
4881 4883 report by Oliver Sander <osander-AT-gmx.de>.
4882 4884
4883 4885 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4884 4886 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4885 4887
4886 4888 2003-09-09 Fernando Perez <fperez@colorado.edu>
4887 4889
4888 4890 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4889 4891 unpacking a list whith a callable as first element would
4890 4892 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4891 4893 Collins.
4892 4894
4893 4895 2003-08-25 *** Released version 0.5.0
4894 4896
4895 4897 2003-08-22 Fernando Perez <fperez@colorado.edu>
4896 4898
4897 4899 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4898 4900 improperly defined user exceptions. Thanks to feedback from Mark
4899 4901 Russell <mrussell-AT-verio.net>.
4900 4902
4901 4903 2003-08-20 Fernando Perez <fperez@colorado.edu>
4902 4904
4903 4905 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4904 4906 printing so that it would print multi-line string forms starting
4905 4907 with a new line. This way the formatting is better respected for
4906 4908 objects which work hard to make nice string forms.
4907 4909
4908 4910 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4909 4911 autocall would overtake data access for objects with both
4910 4912 __getitem__ and __call__.
4911 4913
4912 4914 2003-08-19 *** Released version 0.5.0-rc1
4913 4915
4914 4916 2003-08-19 Fernando Perez <fperez@colorado.edu>
4915 4917
4916 4918 * IPython/deep_reload.py (load_tail): single tiny change here
4917 4919 seems to fix the long-standing bug of dreload() failing to work
4918 4920 for dotted names. But this module is pretty tricky, so I may have
4919 4921 missed some subtlety. Needs more testing!.
4920 4922
4921 4923 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4922 4924 exceptions which have badly implemented __str__ methods.
4923 4925 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4924 4926 which I've been getting reports about from Python 2.3 users. I
4925 4927 wish I had a simple test case to reproduce the problem, so I could
4926 4928 either write a cleaner workaround or file a bug report if
4927 4929 necessary.
4928 4930
4929 4931 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4930 4932 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4931 4933 a bug report by Tjabo Kloppenburg.
4932 4934
4933 4935 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4934 4936 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4935 4937 seems rather unstable. Thanks to a bug report by Tjabo
4936 4938 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4937 4939
4938 4940 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4939 4941 this out soon because of the critical fixes in the inner loop for
4940 4942 generators.
4941 4943
4942 4944 * IPython/Magic.py (Magic.getargspec): removed. This (and
4943 4945 _get_def) have been obsoleted by OInspect for a long time, I
4944 4946 hadn't noticed that they were dead code.
4945 4947 (Magic._ofind): restored _ofind functionality for a few literals
4946 4948 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4947 4949 for things like "hello".capitalize?, since that would require a
4948 4950 potentially dangerous eval() again.
4949 4951
4950 4952 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4951 4953 logic a bit more to clean up the escapes handling and minimize the
4952 4954 use of _ofind to only necessary cases. The interactive 'feel' of
4953 4955 IPython should have improved quite a bit with the changes in
4954 4956 _prefilter and _ofind (besides being far safer than before).
4955 4957
4956 4958 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4957 4959 obscure, never reported). Edit would fail to find the object to
4958 4960 edit under some circumstances.
4959 4961 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4960 4962 which were causing double-calling of generators. Those eval calls
4961 4963 were _very_ dangerous, since code with side effects could be
4962 4964 triggered. As they say, 'eval is evil'... These were the
4963 4965 nastiest evals in IPython. Besides, _ofind is now far simpler,
4964 4966 and it should also be quite a bit faster. Its use of inspect is
4965 4967 also safer, so perhaps some of the inspect-related crashes I've
4966 4968 seen lately with Python 2.3 might be taken care of. That will
4967 4969 need more testing.
4968 4970
4969 4971 2003-08-17 Fernando Perez <fperez@colorado.edu>
4970 4972
4971 4973 * IPython/iplib.py (InteractiveShell._prefilter): significant
4972 4974 simplifications to the logic for handling user escapes. Faster
4973 4975 and simpler code.
4974 4976
4975 4977 2003-08-14 Fernando Perez <fperez@colorado.edu>
4976 4978
4977 4979 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4978 4980 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4979 4981 but it should be quite a bit faster. And the recursive version
4980 4982 generated O(log N) intermediate storage for all rank>1 arrays,
4981 4983 even if they were contiguous.
4982 4984 (l1norm): Added this function.
4983 4985 (norm): Added this function for arbitrary norms (including
4984 4986 l-infinity). l1 and l2 are still special cases for convenience
4985 4987 and speed.
4986 4988
4987 4989 2003-08-03 Fernando Perez <fperez@colorado.edu>
4988 4990
4989 4991 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4990 4992 exceptions, which now raise PendingDeprecationWarnings in Python
4991 4993 2.3. There were some in Magic and some in Gnuplot2.
4992 4994
4993 4995 2003-06-30 Fernando Perez <fperez@colorado.edu>
4994 4996
4995 4997 * IPython/genutils.py (page): modified to call curses only for
4996 4998 terminals where TERM=='xterm'. After problems under many other
4997 4999 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4998 5000
4999 5001 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
5000 5002 would be triggered when readline was absent. This was just an old
5001 5003 debugging statement I'd forgotten to take out.
5002 5004
5003 5005 2003-06-20 Fernando Perez <fperez@colorado.edu>
5004 5006
5005 5007 * IPython/genutils.py (clock): modified to return only user time
5006 5008 (not counting system time), after a discussion on scipy. While
5007 5009 system time may be a useful quantity occasionally, it may much
5008 5010 more easily be skewed by occasional swapping or other similar
5009 5011 activity.
5010 5012
5011 5013 2003-06-05 Fernando Perez <fperez@colorado.edu>
5012 5014
5013 5015 * IPython/numutils.py (identity): new function, for building
5014 5016 arbitrary rank Kronecker deltas (mostly backwards compatible with
5015 5017 Numeric.identity)
5016 5018
5017 5019 2003-06-03 Fernando Perez <fperez@colorado.edu>
5018 5020
5019 5021 * IPython/iplib.py (InteractiveShell.handle_magic): protect
5020 5022 arguments passed to magics with spaces, to allow trailing '\' to
5021 5023 work normally (mainly for Windows users).
5022 5024
5023 5025 2003-05-29 Fernando Perez <fperez@colorado.edu>
5024 5026
5025 5027 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
5026 5028 instead of pydoc.help. This fixes a bizarre behavior where
5027 5029 printing '%s' % locals() would trigger the help system. Now
5028 5030 ipython behaves like normal python does.
5029 5031
5030 5032 Note that if one does 'from pydoc import help', the bizarre
5031 5033 behavior returns, but this will also happen in normal python, so
5032 5034 it's not an ipython bug anymore (it has to do with how pydoc.help
5033 5035 is implemented).
5034 5036
5035 5037 2003-05-22 Fernando Perez <fperez@colorado.edu>
5036 5038
5037 5039 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
5038 5040 return [] instead of None when nothing matches, also match to end
5039 5041 of line. Patch by Gary Bishop.
5040 5042
5041 5043 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
5042 5044 protection as before, for files passed on the command line. This
5043 5045 prevents the CrashHandler from kicking in if user files call into
5044 5046 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
5045 5047 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
5046 5048
5047 5049 2003-05-20 *** Released version 0.4.0
5048 5050
5049 5051 2003-05-20 Fernando Perez <fperez@colorado.edu>
5050 5052
5051 5053 * setup.py: added support for manpages. It's a bit hackish b/c of
5052 5054 a bug in the way the bdist_rpm distutils target handles gzipped
5053 5055 manpages, but it works. After a patch by Jack.
5054 5056
5055 5057 2003-05-19 Fernando Perez <fperez@colorado.edu>
5056 5058
5057 5059 * IPython/numutils.py: added a mockup of the kinds module, since
5058 5060 it was recently removed from Numeric. This way, numutils will
5059 5061 work for all users even if they are missing kinds.
5060 5062
5061 5063 * IPython/Magic.py (Magic._ofind): Harden against an inspect
5062 5064 failure, which can occur with SWIG-wrapped extensions. After a
5063 5065 crash report from Prabhu.
5064 5066
5065 5067 2003-05-16 Fernando Perez <fperez@colorado.edu>
5066 5068
5067 5069 * IPython/iplib.py (InteractiveShell.excepthook): New method to
5068 5070 protect ipython from user code which may call directly
5069 5071 sys.excepthook (this looks like an ipython crash to the user, even
5070 5072 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
5071 5073 This is especially important to help users of WxWindows, but may
5072 5074 also be useful in other cases.
5073 5075
5074 5076 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
5075 5077 an optional tb_offset to be specified, and to preserve exception
5076 5078 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
5077 5079
5078 5080 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
5079 5081
5080 5082 2003-05-15 Fernando Perez <fperez@colorado.edu>
5081 5083
5082 5084 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
5083 5085 installing for a new user under Windows.
5084 5086
5085 5087 2003-05-12 Fernando Perez <fperez@colorado.edu>
5086 5088
5087 5089 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
5088 5090 handler for Emacs comint-based lines. Currently it doesn't do
5089 5091 much (but importantly, it doesn't update the history cache). In
5090 5092 the future it may be expanded if Alex needs more functionality
5091 5093 there.
5092 5094
5093 5095 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
5094 5096 info to crash reports.
5095 5097
5096 5098 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
5097 5099 just like Python's -c. Also fixed crash with invalid -color
5098 5100 option value at startup. Thanks to Will French
5099 5101 <wfrench-AT-bestweb.net> for the bug report.
5100 5102
5101 5103 2003-05-09 Fernando Perez <fperez@colorado.edu>
5102 5104
5103 5105 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
5104 5106 to EvalDict (it's a mapping, after all) and simplified its code
5105 5107 quite a bit, after a nice discussion on c.l.py where Gustavo
5106 5108 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
5107 5109
5108 5110 2003-04-30 Fernando Perez <fperez@colorado.edu>
5109 5111
5110 5112 * IPython/genutils.py (timings_out): modified it to reduce its
5111 5113 overhead in the common reps==1 case.
5112 5114
5113 5115 2003-04-29 Fernando Perez <fperez@colorado.edu>
5114 5116
5115 5117 * IPython/genutils.py (timings_out): Modified to use the resource
5116 5118 module, which avoids the wraparound problems of time.clock().
5117 5119
5118 5120 2003-04-17 *** Released version 0.2.15pre4
5119 5121
5120 5122 2003-04-17 Fernando Perez <fperez@colorado.edu>
5121 5123
5122 5124 * setup.py (scriptfiles): Split windows-specific stuff over to a
5123 5125 separate file, in an attempt to have a Windows GUI installer.
5124 5126 That didn't work, but part of the groundwork is done.
5125 5127
5126 5128 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
5127 5129 indent/unindent with 4 spaces. Particularly useful in combination
5128 5130 with the new auto-indent option.
5129 5131
5130 5132 2003-04-16 Fernando Perez <fperez@colorado.edu>
5131 5133
5132 5134 * IPython/Magic.py: various replacements of self.rc for
5133 5135 self.shell.rc. A lot more remains to be done to fully disentangle
5134 5136 this class from the main Shell class.
5135 5137
5136 5138 * IPython/GnuplotRuntime.py: added checks for mouse support so
5137 5139 that we don't try to enable it if the current gnuplot doesn't
5138 5140 really support it. Also added checks so that we don't try to
5139 5141 enable persist under Windows (where Gnuplot doesn't recognize the
5140 5142 option).
5141 5143
5142 5144 * IPython/iplib.py (InteractiveShell.interact): Added optional
5143 5145 auto-indenting code, after a patch by King C. Shu
5144 5146 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
5145 5147 get along well with pasting indented code. If I ever figure out
5146 5148 how to make that part go well, it will become on by default.
5147 5149
5148 5150 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
5149 5151 crash ipython if there was an unmatched '%' in the user's prompt
5150 5152 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5151 5153
5152 5154 * IPython/iplib.py (InteractiveShell.interact): removed the
5153 5155 ability to ask the user whether he wants to crash or not at the
5154 5156 'last line' exception handler. Calling functions at that point
5155 5157 changes the stack, and the error reports would have incorrect
5156 5158 tracebacks.
5157 5159
5158 5160 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
5159 5161 pass through a peger a pretty-printed form of any object. After a
5160 5162 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
5161 5163
5162 5164 2003-04-14 Fernando Perez <fperez@colorado.edu>
5163 5165
5164 5166 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
5165 5167 all files in ~ would be modified at first install (instead of
5166 5168 ~/.ipython). This could be potentially disastrous, as the
5167 5169 modification (make line-endings native) could damage binary files.
5168 5170
5169 5171 2003-04-10 Fernando Perez <fperez@colorado.edu>
5170 5172
5171 5173 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
5172 5174 handle only lines which are invalid python. This now means that
5173 5175 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
5174 5176 for the bug report.
5175 5177
5176 5178 2003-04-01 Fernando Perez <fperez@colorado.edu>
5177 5179
5178 5180 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
5179 5181 where failing to set sys.last_traceback would crash pdb.pm().
5180 5182 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
5181 5183 report.
5182 5184
5183 5185 2003-03-25 Fernando Perez <fperez@colorado.edu>
5184 5186
5185 5187 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
5186 5188 before printing it (it had a lot of spurious blank lines at the
5187 5189 end).
5188 5190
5189 5191 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
5190 5192 output would be sent 21 times! Obviously people don't use this
5191 5193 too often, or I would have heard about it.
5192 5194
5193 5195 2003-03-24 Fernando Perez <fperez@colorado.edu>
5194 5196
5195 5197 * setup.py (scriptfiles): renamed the data_files parameter from
5196 5198 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
5197 5199 for the patch.
5198 5200
5199 5201 2003-03-20 Fernando Perez <fperez@colorado.edu>
5200 5202
5201 5203 * IPython/genutils.py (error): added error() and fatal()
5202 5204 functions.
5203 5205
5204 5206 2003-03-18 *** Released version 0.2.15pre3
5205 5207
5206 5208 2003-03-18 Fernando Perez <fperez@colorado.edu>
5207 5209
5208 5210 * setupext/install_data_ext.py
5209 5211 (install_data_ext.initialize_options): Class contributed by Jack
5210 5212 Moffit for fixing the old distutils hack. He is sending this to
5211 5213 the distutils folks so in the future we may not need it as a
5212 5214 private fix.
5213 5215
5214 5216 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
5215 5217 changes for Debian packaging. See his patch for full details.
5216 5218 The old distutils hack of making the ipythonrc* files carry a
5217 5219 bogus .py extension is gone, at last. Examples were moved to a
5218 5220 separate subdir under doc/, and the separate executable scripts
5219 5221 now live in their own directory. Overall a great cleanup. The
5220 5222 manual was updated to use the new files, and setup.py has been
5221 5223 fixed for this setup.
5222 5224
5223 5225 * IPython/PyColorize.py (Parser.usage): made non-executable and
5224 5226 created a pycolor wrapper around it to be included as a script.
5225 5227
5226 5228 2003-03-12 *** Released version 0.2.15pre2
5227 5229
5228 5230 2003-03-12 Fernando Perez <fperez@colorado.edu>
5229 5231
5230 5232 * IPython/ColorANSI.py (make_color_table): Finally fixed the
5231 5233 long-standing problem with garbage characters in some terminals.
5232 5234 The issue was really that the \001 and \002 escapes must _only_ be
5233 5235 passed to input prompts (which call readline), but _never_ to
5234 5236 normal text to be printed on screen. I changed ColorANSI to have
5235 5237 two classes: TermColors and InputTermColors, each with the
5236 5238 appropriate escapes for input prompts or normal text. The code in
5237 5239 Prompts.py got slightly more complicated, but this very old and
5238 5240 annoying bug is finally fixed.
5239 5241
5240 5242 All the credit for nailing down the real origin of this problem
5241 5243 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
5242 5244 *Many* thanks to him for spending quite a bit of effort on this.
5243 5245
5244 5246 2003-03-05 *** Released version 0.2.15pre1
5245 5247
5246 5248 2003-03-03 Fernando Perez <fperez@colorado.edu>
5247 5249
5248 5250 * IPython/FakeModule.py: Moved the former _FakeModule to a
5249 5251 separate file, because it's also needed by Magic (to fix a similar
5250 5252 pickle-related issue in @run).
5251 5253
5252 5254 2003-03-02 Fernando Perez <fperez@colorado.edu>
5253 5255
5254 5256 * IPython/Magic.py (Magic.magic_autocall): new magic to control
5255 5257 the autocall option at runtime.
5256 5258 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
5257 5259 across Magic.py to start separating Magic from InteractiveShell.
5258 5260 (Magic._ofind): Fixed to return proper namespace for dotted
5259 5261 names. Before, a dotted name would always return 'not currently
5260 5262 defined', because it would find the 'parent'. s.x would be found,
5261 5263 but since 'x' isn't defined by itself, it would get confused.
5262 5264 (Magic.magic_run): Fixed pickling problems reported by Ralf
5263 5265 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
5264 5266 that I'd used when Mike Heeter reported similar issues at the
5265 5267 top-level, but now for @run. It boils down to injecting the
5266 5268 namespace where code is being executed with something that looks
5267 5269 enough like a module to fool pickle.dump(). Since a pickle stores
5268 5270 a named reference to the importing module, we need this for
5269 5271 pickles to save something sensible.
5270 5272
5271 5273 * IPython/ipmaker.py (make_IPython): added an autocall option.
5272 5274
5273 5275 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
5274 5276 the auto-eval code. Now autocalling is an option, and the code is
5275 5277 also vastly safer. There is no more eval() involved at all.
5276 5278
5277 5279 2003-03-01 Fernando Perez <fperez@colorado.edu>
5278 5280
5279 5281 * IPython/Magic.py (Magic._ofind): Changed interface to return a
5280 5282 dict with named keys instead of a tuple.
5281 5283
5282 5284 * IPython: Started using CVS for IPython as of 0.2.15pre1.
5283 5285
5284 5286 * setup.py (make_shortcut): Fixed message about directories
5285 5287 created during Windows installation (the directories were ok, just
5286 5288 the printed message was misleading). Thanks to Chris Liechti
5287 5289 <cliechti-AT-gmx.net> for the heads up.
5288 5290
5289 5291 2003-02-21 Fernando Perez <fperez@colorado.edu>
5290 5292
5291 5293 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
5292 5294 of ValueError exception when checking for auto-execution. This
5293 5295 one is raised by things like Numeric arrays arr.flat when the
5294 5296 array is non-contiguous.
5295 5297
5296 5298 2003-01-31 Fernando Perez <fperez@colorado.edu>
5297 5299
5298 5300 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
5299 5301 not return any value at all (even though the command would get
5300 5302 executed).
5301 5303 (xsys): Flush stdout right after printing the command to ensure
5302 5304 proper ordering of commands and command output in the total
5303 5305 output.
5304 5306 (SystemExec/xsys/bq): Switched the names of xsys/bq and
5305 5307 system/getoutput as defaults. The old ones are kept for
5306 5308 compatibility reasons, so no code which uses this library needs
5307 5309 changing.
5308 5310
5309 5311 2003-01-27 *** Released version 0.2.14
5310 5312
5311 5313 2003-01-25 Fernando Perez <fperez@colorado.edu>
5312 5314
5313 5315 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
5314 5316 functions defined in previous edit sessions could not be re-edited
5315 5317 (because the temp files were immediately removed). Now temp files
5316 5318 are removed only at IPython's exit.
5317 5319 (Magic.magic_run): Improved @run to perform shell-like expansions
5318 5320 on its arguments (~users and $VARS). With this, @run becomes more
5319 5321 like a normal command-line.
5320 5322
5321 5323 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
5322 5324 bugs related to embedding and cleaned up that code. A fairly
5323 5325 important one was the impossibility to access the global namespace
5324 5326 through the embedded IPython (only local variables were visible).
5325 5327
5326 5328 2003-01-14 Fernando Perez <fperez@colorado.edu>
5327 5329
5328 5330 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
5329 5331 auto-calling to be a bit more conservative. Now it doesn't get
5330 5332 triggered if any of '!=()<>' are in the rest of the input line, to
5331 5333 allow comparing callables. Thanks to Alex for the heads up.
5332 5334
5333 5335 2003-01-07 Fernando Perez <fperez@colorado.edu>
5334 5336
5335 5337 * IPython/genutils.py (page): fixed estimation of the number of
5336 5338 lines in a string to be paged to simply count newlines. This
5337 5339 prevents over-guessing due to embedded escape sequences. A better
5338 5340 long-term solution would involve stripping out the control chars
5339 5341 for the count, but it's potentially so expensive I just don't
5340 5342 think it's worth doing.
5341 5343
5342 5344 2002-12-19 *** Released version 0.2.14pre50
5343 5345
5344 5346 2002-12-19 Fernando Perez <fperez@colorado.edu>
5345 5347
5346 5348 * tools/release (version): Changed release scripts to inform
5347 5349 Andrea and build a NEWS file with a list of recent changes.
5348 5350
5349 5351 * IPython/ColorANSI.py (__all__): changed terminal detection
5350 5352 code. Seems to work better for xterms without breaking
5351 5353 konsole. Will need more testing to determine if WinXP and Mac OSX
5352 5354 also work ok.
5353 5355
5354 5356 2002-12-18 *** Released version 0.2.14pre49
5355 5357
5356 5358 2002-12-18 Fernando Perez <fperez@colorado.edu>
5357 5359
5358 5360 * Docs: added new info about Mac OSX, from Andrea.
5359 5361
5360 5362 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
5361 5363 allow direct plotting of python strings whose format is the same
5362 5364 of gnuplot data files.
5363 5365
5364 5366 2002-12-16 Fernando Perez <fperez@colorado.edu>
5365 5367
5366 5368 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
5367 5369 value of exit question to be acknowledged.
5368 5370
5369 5371 2002-12-03 Fernando Perez <fperez@colorado.edu>
5370 5372
5371 5373 * IPython/ipmaker.py: removed generators, which had been added
5372 5374 by mistake in an earlier debugging run. This was causing trouble
5373 5375 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
5374 5376 for pointing this out.
5375 5377
5376 5378 2002-11-17 Fernando Perez <fperez@colorado.edu>
5377 5379
5378 5380 * Manual: updated the Gnuplot section.
5379 5381
5380 5382 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
5381 5383 a much better split of what goes in Runtime and what goes in
5382 5384 Interactive.
5383 5385
5384 5386 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
5385 5387 being imported from iplib.
5386 5388
5387 5389 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
5388 5390 for command-passing. Now the global Gnuplot instance is called
5389 5391 'gp' instead of 'g', which was really a far too fragile and
5390 5392 common name.
5391 5393
5392 5394 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
5393 5395 bounding boxes generated by Gnuplot for square plots.
5394 5396
5395 5397 * IPython/genutils.py (popkey): new function added. I should
5396 5398 suggest this on c.l.py as a dict method, it seems useful.
5397 5399
5398 5400 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
5399 5401 to transparently handle PostScript generation. MUCH better than
5400 5402 the previous plot_eps/replot_eps (which I removed now). The code
5401 5403 is also fairly clean and well documented now (including
5402 5404 docstrings).
5403 5405
5404 5406 2002-11-13 Fernando Perez <fperez@colorado.edu>
5405 5407
5406 5408 * IPython/Magic.py (Magic.magic_edit): fixed docstring
5407 5409 (inconsistent with options).
5408 5410
5409 5411 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
5410 5412 manually disabled, I don't know why. Fixed it.
5411 5413 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
5412 5414 eps output.
5413 5415
5414 5416 2002-11-12 Fernando Perez <fperez@colorado.edu>
5415 5417
5416 5418 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
5417 5419 don't propagate up to caller. Fixes crash reported by François
5418 5420 Pinard.
5419 5421
5420 5422 2002-11-09 Fernando Perez <fperez@colorado.edu>
5421 5423
5422 5424 * IPython/ipmaker.py (make_IPython): fixed problem with writing
5423 5425 history file for new users.
5424 5426 (make_IPython): fixed bug where initial install would leave the
5425 5427 user running in the .ipython dir.
5426 5428 (make_IPython): fixed bug where config dir .ipython would be
5427 5429 created regardless of the given -ipythondir option. Thanks to Cory
5428 5430 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
5429 5431
5430 5432 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
5431 5433 type confirmations. Will need to use it in all of IPython's code
5432 5434 consistently.
5433 5435
5434 5436 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
5435 5437 context to print 31 lines instead of the default 5. This will make
5436 5438 the crash reports extremely detailed in case the problem is in
5437 5439 libraries I don't have access to.
5438 5440
5439 5441 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
5440 5442 line of defense' code to still crash, but giving users fair
5441 5443 warning. I don't want internal errors to go unreported: if there's
5442 5444 an internal problem, IPython should crash and generate a full
5443 5445 report.
5444 5446
5445 5447 2002-11-08 Fernando Perez <fperez@colorado.edu>
5446 5448
5447 5449 * IPython/iplib.py (InteractiveShell.interact): added code to trap
5448 5450 otherwise uncaught exceptions which can appear if people set
5449 5451 sys.stdout to something badly broken. Thanks to a crash report
5450 5452 from henni-AT-mail.brainbot.com.
5451 5453
5452 5454 2002-11-04 Fernando Perez <fperez@colorado.edu>
5453 5455
5454 5456 * IPython/iplib.py (InteractiveShell.interact): added
5455 5457 __IPYTHON__active to the builtins. It's a flag which goes on when
5456 5458 the interaction starts and goes off again when it stops. This
5457 5459 allows embedding code to detect being inside IPython. Before this
5458 5460 was done via __IPYTHON__, but that only shows that an IPython
5459 5461 instance has been created.
5460 5462
5461 5463 * IPython/Magic.py (Magic.magic_env): I realized that in a
5462 5464 UserDict, instance.data holds the data as a normal dict. So I
5463 5465 modified @env to return os.environ.data instead of rebuilding a
5464 5466 dict by hand.
5465 5467
5466 5468 2002-11-02 Fernando Perez <fperez@colorado.edu>
5467 5469
5468 5470 * IPython/genutils.py (warn): changed so that level 1 prints no
5469 5471 header. Level 2 is now the default (with 'WARNING' header, as
5470 5472 before). I think I tracked all places where changes were needed in
5471 5473 IPython, but outside code using the old level numbering may have
5472 5474 broken.
5473 5475
5474 5476 * IPython/iplib.py (InteractiveShell.runcode): added this to
5475 5477 handle the tracebacks in SystemExit traps correctly. The previous
5476 5478 code (through interact) was printing more of the stack than
5477 5479 necessary, showing IPython internal code to the user.
5478 5480
5479 5481 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
5480 5482 default. Now that the default at the confirmation prompt is yes,
5481 5483 it's not so intrusive. François' argument that ipython sessions
5482 5484 tend to be complex enough not to lose them from an accidental C-d,
5483 5485 is a valid one.
5484 5486
5485 5487 * IPython/iplib.py (InteractiveShell.interact): added a
5486 5488 showtraceback() call to the SystemExit trap, and modified the exit
5487 5489 confirmation to have yes as the default.
5488 5490
5489 5491 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
5490 5492 this file. It's been gone from the code for a long time, this was
5491 5493 simply leftover junk.
5492 5494
5493 5495 2002-11-01 Fernando Perez <fperez@colorado.edu>
5494 5496
5495 5497 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
5496 5498 added. If set, IPython now traps EOF and asks for
5497 5499 confirmation. After a request by François Pinard.
5498 5500
5499 5501 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
5500 5502 of @abort, and with a new (better) mechanism for handling the
5501 5503 exceptions.
5502 5504
5503 5505 2002-10-27 Fernando Perez <fperez@colorado.edu>
5504 5506
5505 5507 * IPython/usage.py (__doc__): updated the --help information and
5506 5508 the ipythonrc file to indicate that -log generates
5507 5509 ./ipython.log. Also fixed the corresponding info in @logstart.
5508 5510 This and several other fixes in the manuals thanks to reports by
5509 5511 François Pinard <pinard-AT-iro.umontreal.ca>.
5510 5512
5511 5513 * IPython/Logger.py (Logger.switch_log): Fixed error message to
5512 5514 refer to @logstart (instead of @log, which doesn't exist).
5513 5515
5514 5516 * IPython/iplib.py (InteractiveShell._prefilter): fixed
5515 5517 AttributeError crash. Thanks to Christopher Armstrong
5516 5518 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
5517 5519 introduced recently (in 0.2.14pre37) with the fix to the eval
5518 5520 problem mentioned below.
5519 5521
5520 5522 2002-10-17 Fernando Perez <fperez@colorado.edu>
5521 5523
5522 5524 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
5523 5525 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
5524 5526
5525 5527 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
5526 5528 this function to fix a problem reported by Alex Schmolck. He saw
5527 5529 it with list comprehensions and generators, which were getting
5528 5530 called twice. The real problem was an 'eval' call in testing for
5529 5531 automagic which was evaluating the input line silently.
5530 5532
5531 5533 This is a potentially very nasty bug, if the input has side
5532 5534 effects which must not be repeated. The code is much cleaner now,
5533 5535 without any blanket 'except' left and with a regexp test for
5534 5536 actual function names.
5535 5537
5536 5538 But an eval remains, which I'm not fully comfortable with. I just
5537 5539 don't know how to find out if an expression could be a callable in
5538 5540 the user's namespace without doing an eval on the string. However
5539 5541 that string is now much more strictly checked so that no code
5540 5542 slips by, so the eval should only happen for things that can
5541 5543 really be only function/method names.
5542 5544
5543 5545 2002-10-15 Fernando Perez <fperez@colorado.edu>
5544 5546
5545 5547 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
5546 5548 OSX information to main manual, removed README_Mac_OSX file from
5547 5549 distribution. Also updated credits for recent additions.
5548 5550
5549 5551 2002-10-10 Fernando Perez <fperez@colorado.edu>
5550 5552
5551 5553 * README_Mac_OSX: Added a README for Mac OSX users for fixing
5552 5554 terminal-related issues. Many thanks to Andrea Riciputi
5553 5555 <andrea.riciputi-AT-libero.it> for writing it.
5554 5556
5555 5557 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
5556 5558 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5557 5559
5558 5560 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
5559 5561 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
5560 5562 <syver-en-AT-online.no> who both submitted patches for this problem.
5561 5563
5562 5564 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
5563 5565 global embedding to make sure that things don't overwrite user
5564 5566 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
5565 5567
5566 5568 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
5567 5569 compatibility. Thanks to Hayden Callow
5568 5570 <h.callow-AT-elec.canterbury.ac.nz>
5569 5571
5570 5572 2002-10-04 Fernando Perez <fperez@colorado.edu>
5571 5573
5572 5574 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
5573 5575 Gnuplot.File objects.
5574 5576
5575 5577 2002-07-23 Fernando Perez <fperez@colorado.edu>
5576 5578
5577 5579 * IPython/genutils.py (timing): Added timings() and timing() for
5578 5580 quick access to the most commonly needed data, the execution
5579 5581 times. Old timing() renamed to timings_out().
5580 5582
5581 5583 2002-07-18 Fernando Perez <fperez@colorado.edu>
5582 5584
5583 5585 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
5584 5586 bug with nested instances disrupting the parent's tab completion.
5585 5587
5586 5588 * IPython/iplib.py (all_completions): Added Alex Schmolck's
5587 5589 all_completions code to begin the emacs integration.
5588 5590
5589 5591 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
5590 5592 argument to allow titling individual arrays when plotting.
5591 5593
5592 5594 2002-07-15 Fernando Perez <fperez@colorado.edu>
5593 5595
5594 5596 * setup.py (make_shortcut): changed to retrieve the value of
5595 5597 'Program Files' directory from the registry (this value changes in
5596 5598 non-english versions of Windows). Thanks to Thomas Fanslau
5597 5599 <tfanslau-AT-gmx.de> for the report.
5598 5600
5599 5601 2002-07-10 Fernando Perez <fperez@colorado.edu>
5600 5602
5601 5603 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
5602 5604 a bug in pdb, which crashes if a line with only whitespace is
5603 5605 entered. Bug report submitted to sourceforge.
5604 5606
5605 5607 2002-07-09 Fernando Perez <fperez@colorado.edu>
5606 5608
5607 5609 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
5608 5610 reporting exceptions (it's a bug in inspect.py, I just set a
5609 5611 workaround).
5610 5612
5611 5613 2002-07-08 Fernando Perez <fperez@colorado.edu>
5612 5614
5613 5615 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
5614 5616 __IPYTHON__ in __builtins__ to show up in user_ns.
5615 5617
5616 5618 2002-07-03 Fernando Perez <fperez@colorado.edu>
5617 5619
5618 5620 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
5619 5621 name from @gp_set_instance to @gp_set_default.
5620 5622
5621 5623 * IPython/ipmaker.py (make_IPython): default editor value set to
5622 5624 '0' (a string), to match the rc file. Otherwise will crash when
5623 5625 .strip() is called on it.
5624 5626
5625 5627
5626 5628 2002-06-28 Fernando Perez <fperez@colorado.edu>
5627 5629
5628 5630 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
5629 5631 of files in current directory when a file is executed via
5630 5632 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
5631 5633
5632 5634 * setup.py (manfiles): fix for rpm builds, submitted by RA
5633 5635 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
5634 5636
5635 5637 * IPython/ipmaker.py (make_IPython): fixed lookup of default
5636 5638 editor when set to '0'. Problem was, '0' evaluates to True (it's a
5637 5639 string!). A. Schmolck caught this one.
5638 5640
5639 5641 2002-06-27 Fernando Perez <fperez@colorado.edu>
5640 5642
5641 5643 * IPython/ipmaker.py (make_IPython): fixed bug when running user
5642 5644 defined files at the cmd line. __name__ wasn't being set to
5643 5645 __main__.
5644 5646
5645 5647 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
5646 5648 regular lists and tuples besides Numeric arrays.
5647 5649
5648 5650 * IPython/Prompts.py (CachedOutput.__call__): Added output
5649 5651 supression for input ending with ';'. Similar to Mathematica and
5650 5652 Matlab. The _* vars and Out[] list are still updated, just like
5651 5653 Mathematica behaves.
5652 5654
5653 5655 2002-06-25 Fernando Perez <fperez@colorado.edu>
5654 5656
5655 5657 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
5656 5658 .ini extensions for profiels under Windows.
5657 5659
5658 5660 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
5659 5661 string form. Fix contributed by Alexander Schmolck
5660 5662 <a.schmolck-AT-gmx.net>
5661 5663
5662 5664 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
5663 5665 pre-configured Gnuplot instance.
5664 5666
5665 5667 2002-06-21 Fernando Perez <fperez@colorado.edu>
5666 5668
5667 5669 * IPython/numutils.py (exp_safe): new function, works around the
5668 5670 underflow problems in Numeric.
5669 5671 (log2): New fn. Safe log in base 2: returns exact integer answer
5670 5672 for exact integer powers of 2.
5671 5673
5672 5674 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
5673 5675 properly.
5674 5676
5675 5677 2002-06-20 Fernando Perez <fperez@colorado.edu>
5676 5678
5677 5679 * IPython/genutils.py (timing): new function like
5678 5680 Mathematica's. Similar to time_test, but returns more info.
5679 5681
5680 5682 2002-06-18 Fernando Perez <fperez@colorado.edu>
5681 5683
5682 5684 * IPython/Magic.py (Magic.magic_save): modified @save and @r
5683 5685 according to Mike Heeter's suggestions.
5684 5686
5685 5687 2002-06-16 Fernando Perez <fperez@colorado.edu>
5686 5688
5687 5689 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
5688 5690 system. GnuplotMagic is gone as a user-directory option. New files
5689 5691 make it easier to use all the gnuplot stuff both from external
5690 5692 programs as well as from IPython. Had to rewrite part of
5691 5693 hardcopy() b/c of a strange bug: often the ps files simply don't
5692 5694 get created, and require a repeat of the command (often several
5693 5695 times).
5694 5696
5695 5697 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
5696 5698 resolve output channel at call time, so that if sys.stderr has
5697 5699 been redirected by user this gets honored.
5698 5700
5699 5701 2002-06-13 Fernando Perez <fperez@colorado.edu>
5700 5702
5701 5703 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
5702 5704 IPShell. Kept a copy with the old names to avoid breaking people's
5703 5705 embedded code.
5704 5706
5705 5707 * IPython/ipython: simplified it to the bare minimum after
5706 5708 Holger's suggestions. Added info about how to use it in
5707 5709 PYTHONSTARTUP.
5708 5710
5709 5711 * IPython/Shell.py (IPythonShell): changed the options passing
5710 5712 from a string with funky %s replacements to a straight list. Maybe
5711 5713 a bit more typing, but it follows sys.argv conventions, so there's
5712 5714 less special-casing to remember.
5713 5715
5714 5716 2002-06-12 Fernando Perez <fperez@colorado.edu>
5715 5717
5716 5718 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
5717 5719 command. Thanks to a suggestion by Mike Heeter.
5718 5720 (Magic.magic_pfile): added behavior to look at filenames if given
5719 5721 arg is not a defined object.
5720 5722 (Magic.magic_save): New @save function to save code snippets. Also
5721 5723 a Mike Heeter idea.
5722 5724
5723 5725 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
5724 5726 plot() and replot(). Much more convenient now, especially for
5725 5727 interactive use.
5726 5728
5727 5729 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
5728 5730 filenames.
5729 5731
5730 5732 2002-06-02 Fernando Perez <fperez@colorado.edu>
5731 5733
5732 5734 * IPython/Struct.py (Struct.__init__): modified to admit
5733 5735 initialization via another struct.
5734 5736
5735 5737 * IPython/genutils.py (SystemExec.__init__): New stateful
5736 5738 interface to xsys and bq. Useful for writing system scripts.
5737 5739
5738 5740 2002-05-30 Fernando Perez <fperez@colorado.edu>
5739 5741
5740 5742 * MANIFEST.in: Changed docfile selection to exclude all the lyx
5741 5743 documents. This will make the user download smaller (it's getting
5742 5744 too big).
5743 5745
5744 5746 2002-05-29 Fernando Perez <fperez@colorado.edu>
5745 5747
5746 5748 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
5747 5749 fix problems with shelve and pickle. Seems to work, but I don't
5748 5750 know if corner cases break it. Thanks to Mike Heeter
5749 5751 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
5750 5752
5751 5753 2002-05-24 Fernando Perez <fperez@colorado.edu>
5752 5754
5753 5755 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
5754 5756 macros having broken.
5755 5757
5756 5758 2002-05-21 Fernando Perez <fperez@colorado.edu>
5757 5759
5758 5760 * IPython/Magic.py (Magic.magic_logstart): fixed recently
5759 5761 introduced logging bug: all history before logging started was
5760 5762 being written one character per line! This came from the redesign
5761 5763 of the input history as a special list which slices to strings,
5762 5764 not to lists.
5763 5765
5764 5766 2002-05-20 Fernando Perez <fperez@colorado.edu>
5765 5767
5766 5768 * IPython/Prompts.py (CachedOutput.__init__): made the color table
5767 5769 be an attribute of all classes in this module. The design of these
5768 5770 classes needs some serious overhauling.
5769 5771
5770 5772 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
5771 5773 which was ignoring '_' in option names.
5772 5774
5773 5775 * IPython/ultraTB.py (FormattedTB.__init__): Changed
5774 5776 'Verbose_novars' to 'Context' and made it the new default. It's a
5775 5777 bit more readable and also safer than verbose.
5776 5778
5777 5779 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
5778 5780 triple-quoted strings.
5779 5781
5780 5782 * IPython/OInspect.py (__all__): new module exposing the object
5781 5783 introspection facilities. Now the corresponding magics are dummy
5782 5784 wrappers around this. Having this module will make it much easier
5783 5785 to put these functions into our modified pdb.
5784 5786 This new object inspector system uses the new colorizing module,
5785 5787 so source code and other things are nicely syntax highlighted.
5786 5788
5787 5789 2002-05-18 Fernando Perez <fperez@colorado.edu>
5788 5790
5789 5791 * IPython/ColorANSI.py: Split the coloring tools into a separate
5790 5792 module so I can use them in other code easier (they were part of
5791 5793 ultraTB).
5792 5794
5793 5795 2002-05-17 Fernando Perez <fperez@colorado.edu>
5794 5796
5795 5797 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5796 5798 fixed it to set the global 'g' also to the called instance, as
5797 5799 long as 'g' was still a gnuplot instance (so it doesn't overwrite
5798 5800 user's 'g' variables).
5799 5801
5800 5802 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
5801 5803 global variables (aliases to _ih,_oh) so that users which expect
5802 5804 In[5] or Out[7] to work aren't unpleasantly surprised.
5803 5805 (InputList.__getslice__): new class to allow executing slices of
5804 5806 input history directly. Very simple class, complements the use of
5805 5807 macros.
5806 5808
5807 5809 2002-05-16 Fernando Perez <fperez@colorado.edu>
5808 5810
5809 5811 * setup.py (docdirbase): make doc directory be just doc/IPython
5810 5812 without version numbers, it will reduce clutter for users.
5811 5813
5812 5814 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
5813 5815 execfile call to prevent possible memory leak. See for details:
5814 5816 http://mail.python.org/pipermail/python-list/2002-February/088476.html
5815 5817
5816 5818 2002-05-15 Fernando Perez <fperez@colorado.edu>
5817 5819
5818 5820 * IPython/Magic.py (Magic.magic_psource): made the object
5819 5821 introspection names be more standard: pdoc, pdef, pfile and
5820 5822 psource. They all print/page their output, and it makes
5821 5823 remembering them easier. Kept old names for compatibility as
5822 5824 aliases.
5823 5825
5824 5826 2002-05-14 Fernando Perez <fperez@colorado.edu>
5825 5827
5826 5828 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
5827 5829 what the mouse problem was. The trick is to use gnuplot with temp
5828 5830 files and NOT with pipes (for data communication), because having
5829 5831 both pipes and the mouse on is bad news.
5830 5832
5831 5833 2002-05-13 Fernando Perez <fperez@colorado.edu>
5832 5834
5833 5835 * IPython/Magic.py (Magic._ofind): fixed namespace order search
5834 5836 bug. Information would be reported about builtins even when
5835 5837 user-defined functions overrode them.
5836 5838
5837 5839 2002-05-11 Fernando Perez <fperez@colorado.edu>
5838 5840
5839 5841 * IPython/__init__.py (__all__): removed FlexCompleter from
5840 5842 __all__ so that things don't fail in platforms without readline.
5841 5843
5842 5844 2002-05-10 Fernando Perez <fperez@colorado.edu>
5843 5845
5844 5846 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
5845 5847 it requires Numeric, effectively making Numeric a dependency for
5846 5848 IPython.
5847 5849
5848 5850 * Released 0.2.13
5849 5851
5850 5852 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
5851 5853 profiler interface. Now all the major options from the profiler
5852 5854 module are directly supported in IPython, both for single
5853 5855 expressions (@prun) and for full programs (@run -p).
5854 5856
5855 5857 2002-05-09 Fernando Perez <fperez@colorado.edu>
5856 5858
5857 5859 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
5858 5860 magic properly formatted for screen.
5859 5861
5860 5862 * setup.py (make_shortcut): Changed things to put pdf version in
5861 5863 doc/ instead of doc/manual (had to change lyxport a bit).
5862 5864
5863 5865 * IPython/Magic.py (Profile.string_stats): made profile runs go
5864 5866 through pager (they are long and a pager allows searching, saving,
5865 5867 etc.)
5866 5868
5867 5869 2002-05-08 Fernando Perez <fperez@colorado.edu>
5868 5870
5869 5871 * Released 0.2.12
5870 5872
5871 5873 2002-05-06 Fernando Perez <fperez@colorado.edu>
5872 5874
5873 5875 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5874 5876 introduced); 'hist n1 n2' was broken.
5875 5877 (Magic.magic_pdb): added optional on/off arguments to @pdb
5876 5878 (Magic.magic_run): added option -i to @run, which executes code in
5877 5879 the IPython namespace instead of a clean one. Also added @irun as
5878 5880 an alias to @run -i.
5879 5881
5880 5882 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5881 5883 fixed (it didn't really do anything, the namespaces were wrong).
5882 5884
5883 5885 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5884 5886
5885 5887 * IPython/__init__.py (__all__): Fixed package namespace, now
5886 5888 'import IPython' does give access to IPython.<all> as
5887 5889 expected. Also renamed __release__ to Release.
5888 5890
5889 5891 * IPython/Debugger.py (__license__): created new Pdb class which
5890 5892 functions like a drop-in for the normal pdb.Pdb but does NOT
5891 5893 import readline by default. This way it doesn't muck up IPython's
5892 5894 readline handling, and now tab-completion finally works in the
5893 5895 debugger -- sort of. It completes things globally visible, but the
5894 5896 completer doesn't track the stack as pdb walks it. That's a bit
5895 5897 tricky, and I'll have to implement it later.
5896 5898
5897 5899 2002-05-05 Fernando Perez <fperez@colorado.edu>
5898 5900
5899 5901 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5900 5902 magic docstrings when printed via ? (explicit \'s were being
5901 5903 printed).
5902 5904
5903 5905 * IPython/ipmaker.py (make_IPython): fixed namespace
5904 5906 identification bug. Now variables loaded via logs or command-line
5905 5907 files are recognized in the interactive namespace by @who.
5906 5908
5907 5909 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5908 5910 log replay system stemming from the string form of Structs.
5909 5911
5910 5912 * IPython/Magic.py (Macro.__init__): improved macros to properly
5911 5913 handle magic commands in them.
5912 5914 (Magic.magic_logstart): usernames are now expanded so 'logstart
5913 5915 ~/mylog' now works.
5914 5916
5915 5917 * IPython/iplib.py (complete): fixed bug where paths starting with
5916 5918 '/' would be completed as magic names.
5917 5919
5918 5920 2002-05-04 Fernando Perez <fperez@colorado.edu>
5919 5921
5920 5922 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5921 5923 allow running full programs under the profiler's control.
5922 5924
5923 5925 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5924 5926 mode to report exceptions verbosely but without formatting
5925 5927 variables. This addresses the issue of ipython 'freezing' (it's
5926 5928 not frozen, but caught in an expensive formatting loop) when huge
5927 5929 variables are in the context of an exception.
5928 5930 (VerboseTB.text): Added '--->' markers at line where exception was
5929 5931 triggered. Much clearer to read, especially in NoColor modes.
5930 5932
5931 5933 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5932 5934 implemented in reverse when changing to the new parse_options().
5933 5935
5934 5936 2002-05-03 Fernando Perez <fperez@colorado.edu>
5935 5937
5936 5938 * IPython/Magic.py (Magic.parse_options): new function so that
5937 5939 magics can parse options easier.
5938 5940 (Magic.magic_prun): new function similar to profile.run(),
5939 5941 suggested by Chris Hart.
5940 5942 (Magic.magic_cd): fixed behavior so that it only changes if
5941 5943 directory actually is in history.
5942 5944
5943 5945 * IPython/usage.py (__doc__): added information about potential
5944 5946 slowness of Verbose exception mode when there are huge data
5945 5947 structures to be formatted (thanks to Archie Paulson).
5946 5948
5947 5949 * IPython/ipmaker.py (make_IPython): Changed default logging
5948 5950 (when simply called with -log) to use curr_dir/ipython.log in
5949 5951 rotate mode. Fixed crash which was occuring with -log before
5950 5952 (thanks to Jim Boyle).
5951 5953
5952 5954 2002-05-01 Fernando Perez <fperez@colorado.edu>
5953 5955
5954 5956 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5955 5957 was nasty -- though somewhat of a corner case).
5956 5958
5957 5959 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5958 5960 text (was a bug).
5959 5961
5960 5962 2002-04-30 Fernando Perez <fperez@colorado.edu>
5961 5963
5962 5964 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5963 5965 a print after ^D or ^C from the user so that the In[] prompt
5964 5966 doesn't over-run the gnuplot one.
5965 5967
5966 5968 2002-04-29 Fernando Perez <fperez@colorado.edu>
5967 5969
5968 5970 * Released 0.2.10
5969 5971
5970 5972 * IPython/__release__.py (version): get date dynamically.
5971 5973
5972 5974 * Misc. documentation updates thanks to Arnd's comments. Also ran
5973 5975 a full spellcheck on the manual (hadn't been done in a while).
5974 5976
5975 5977 2002-04-27 Fernando Perez <fperez@colorado.edu>
5976 5978
5977 5979 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5978 5980 starting a log in mid-session would reset the input history list.
5979 5981
5980 5982 2002-04-26 Fernando Perez <fperez@colorado.edu>
5981 5983
5982 5984 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5983 5985 all files were being included in an update. Now anything in
5984 5986 UserConfig that matches [A-Za-z]*.py will go (this excludes
5985 5987 __init__.py)
5986 5988
5987 5989 2002-04-25 Fernando Perez <fperez@colorado.edu>
5988 5990
5989 5991 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5990 5992 to __builtins__ so that any form of embedded or imported code can
5991 5993 test for being inside IPython.
5992 5994
5993 5995 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5994 5996 changed to GnuplotMagic because it's now an importable module,
5995 5997 this makes the name follow that of the standard Gnuplot module.
5996 5998 GnuplotMagic can now be loaded at any time in mid-session.
5997 5999
5998 6000 2002-04-24 Fernando Perez <fperez@colorado.edu>
5999 6001
6000 6002 * IPython/numutils.py: removed SIUnits. It doesn't properly set
6001 6003 the globals (IPython has its own namespace) and the
6002 6004 PhysicalQuantity stuff is much better anyway.
6003 6005
6004 6006 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
6005 6007 embedding example to standard user directory for
6006 6008 distribution. Also put it in the manual.
6007 6009
6008 6010 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
6009 6011 instance as first argument (so it doesn't rely on some obscure
6010 6012 hidden global).
6011 6013
6012 6014 * IPython/UserConfig/ipythonrc.py: put () back in accepted
6013 6015 delimiters. While it prevents ().TAB from working, it allows
6014 6016 completions in open (... expressions. This is by far a more common
6015 6017 case.
6016 6018
6017 6019 2002-04-23 Fernando Perez <fperez@colorado.edu>
6018 6020
6019 6021 * IPython/Extensions/InterpreterPasteInput.py: new
6020 6022 syntax-processing module for pasting lines with >>> or ... at the
6021 6023 start.
6022 6024
6023 6025 * IPython/Extensions/PhysicalQ_Interactive.py
6024 6026 (PhysicalQuantityInteractive.__int__): fixed to work with either
6025 6027 Numeric or math.
6026 6028
6027 6029 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
6028 6030 provided profiles. Now we have:
6029 6031 -math -> math module as * and cmath with its own namespace.
6030 6032 -numeric -> Numeric as *, plus gnuplot & grace
6031 6033 -physics -> same as before
6032 6034
6033 6035 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
6034 6036 user-defined magics wouldn't be found by @magic if they were
6035 6037 defined as class methods. Also cleaned up the namespace search
6036 6038 logic and the string building (to use %s instead of many repeated
6037 6039 string adds).
6038 6040
6039 6041 * IPython/UserConfig/example-magic.py (magic_foo): updated example
6040 6042 of user-defined magics to operate with class methods (cleaner, in
6041 6043 line with the gnuplot code).
6042 6044
6043 6045 2002-04-22 Fernando Perez <fperez@colorado.edu>
6044 6046
6045 6047 * setup.py: updated dependency list so that manual is updated when
6046 6048 all included files change.
6047 6049
6048 6050 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
6049 6051 the delimiter removal option (the fix is ugly right now).
6050 6052
6051 6053 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
6052 6054 all of the math profile (quicker loading, no conflict between
6053 6055 g-9.8 and g-gnuplot).
6054 6056
6055 6057 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
6056 6058 name of post-mortem files to IPython_crash_report.txt.
6057 6059
6058 6060 * Cleanup/update of the docs. Added all the new readline info and
6059 6061 formatted all lists as 'real lists'.
6060 6062
6061 6063 * IPython/ipmaker.py (make_IPython): removed now-obsolete
6062 6064 tab-completion options, since the full readline parse_and_bind is
6063 6065 now accessible.
6064 6066
6065 6067 * IPython/iplib.py (InteractiveShell.init_readline): Changed
6066 6068 handling of readline options. Now users can specify any string to
6067 6069 be passed to parse_and_bind(), as well as the delimiters to be
6068 6070 removed.
6069 6071 (InteractiveShell.__init__): Added __name__ to the global
6070 6072 namespace so that things like Itpl which rely on its existence
6071 6073 don't crash.
6072 6074 (InteractiveShell._prefilter): Defined the default with a _ so
6073 6075 that prefilter() is easier to override, while the default one
6074 6076 remains available.
6075 6077
6076 6078 2002-04-18 Fernando Perez <fperez@colorado.edu>
6077 6079
6078 6080 * Added information about pdb in the docs.
6079 6081
6080 6082 2002-04-17 Fernando Perez <fperez@colorado.edu>
6081 6083
6082 6084 * IPython/ipmaker.py (make_IPython): added rc_override option to
6083 6085 allow passing config options at creation time which may override
6084 6086 anything set in the config files or command line. This is
6085 6087 particularly useful for configuring embedded instances.
6086 6088
6087 6089 2002-04-15 Fernando Perez <fperez@colorado.edu>
6088 6090
6089 6091 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
6090 6092 crash embedded instances because of the input cache falling out of
6091 6093 sync with the output counter.
6092 6094
6093 6095 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
6094 6096 mode which calls pdb after an uncaught exception in IPython itself.
6095 6097
6096 6098 2002-04-14 Fernando Perez <fperez@colorado.edu>
6097 6099
6098 6100 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
6099 6101 readline, fix it back after each call.
6100 6102
6101 6103 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
6102 6104 method to force all access via __call__(), which guarantees that
6103 6105 traceback references are properly deleted.
6104 6106
6105 6107 * IPython/Prompts.py (CachedOutput._display): minor fixes to
6106 6108 improve printing when pprint is in use.
6107 6109
6108 6110 2002-04-13 Fernando Perez <fperez@colorado.edu>
6109 6111
6110 6112 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
6111 6113 exceptions aren't caught anymore. If the user triggers one, he
6112 6114 should know why he's doing it and it should go all the way up,
6113 6115 just like any other exception. So now @abort will fully kill the
6114 6116 embedded interpreter and the embedding code (unless that happens
6115 6117 to catch SystemExit).
6116 6118
6117 6119 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
6118 6120 and a debugger() method to invoke the interactive pdb debugger
6119 6121 after printing exception information. Also added the corresponding
6120 6122 -pdb option and @pdb magic to control this feature, and updated
6121 6123 the docs. After a suggestion from Christopher Hart
6122 6124 (hart-AT-caltech.edu).
6123 6125
6124 6126 2002-04-12 Fernando Perez <fperez@colorado.edu>
6125 6127
6126 6128 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
6127 6129 the exception handlers defined by the user (not the CrashHandler)
6128 6130 so that user exceptions don't trigger an ipython bug report.
6129 6131
6130 6132 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
6131 6133 configurable (it should have always been so).
6132 6134
6133 6135 2002-03-26 Fernando Perez <fperez@colorado.edu>
6134 6136
6135 6137 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
6136 6138 and there to fix embedding namespace issues. This should all be
6137 6139 done in a more elegant way.
6138 6140
6139 6141 2002-03-25 Fernando Perez <fperez@colorado.edu>
6140 6142
6141 6143 * IPython/genutils.py (get_home_dir): Try to make it work under
6142 6144 win9x also.
6143 6145
6144 6146 2002-03-20 Fernando Perez <fperez@colorado.edu>
6145 6147
6146 6148 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
6147 6149 sys.displayhook untouched upon __init__.
6148 6150
6149 6151 2002-03-19 Fernando Perez <fperez@colorado.edu>
6150 6152
6151 6153 * Released 0.2.9 (for embedding bug, basically).
6152 6154
6153 6155 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
6154 6156 exceptions so that enclosing shell's state can be restored.
6155 6157
6156 6158 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
6157 6159 naming conventions in the .ipython/ dir.
6158 6160
6159 6161 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
6160 6162 from delimiters list so filenames with - in them get expanded.
6161 6163
6162 6164 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
6163 6165 sys.displayhook not being properly restored after an embedded call.
6164 6166
6165 6167 2002-03-18 Fernando Perez <fperez@colorado.edu>
6166 6168
6167 6169 * Released 0.2.8
6168 6170
6169 6171 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
6170 6172 some files weren't being included in a -upgrade.
6171 6173 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
6172 6174 on' so that the first tab completes.
6173 6175 (InteractiveShell.handle_magic): fixed bug with spaces around
6174 6176 quotes breaking many magic commands.
6175 6177
6176 6178 * setup.py: added note about ignoring the syntax error messages at
6177 6179 installation.
6178 6180
6179 6181 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
6180 6182 streamlining the gnuplot interface, now there's only one magic @gp.
6181 6183
6182 6184 2002-03-17 Fernando Perez <fperez@colorado.edu>
6183 6185
6184 6186 * IPython/UserConfig/magic_gnuplot.py: new name for the
6185 6187 example-magic_pm.py file. Much enhanced system, now with a shell
6186 6188 for communicating directly with gnuplot, one command at a time.
6187 6189
6188 6190 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
6189 6191 setting __name__=='__main__'.
6190 6192
6191 6193 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
6192 6194 mini-shell for accessing gnuplot from inside ipython. Should
6193 6195 extend it later for grace access too. Inspired by Arnd's
6194 6196 suggestion.
6195 6197
6196 6198 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
6197 6199 calling magic functions with () in their arguments. Thanks to Arnd
6198 6200 Baecker for pointing this to me.
6199 6201
6200 6202 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
6201 6203 infinitely for integer or complex arrays (only worked with floats).
6202 6204
6203 6205 2002-03-16 Fernando Perez <fperez@colorado.edu>
6204 6206
6205 6207 * setup.py: Merged setup and setup_windows into a single script
6206 6208 which properly handles things for windows users.
6207 6209
6208 6210 2002-03-15 Fernando Perez <fperez@colorado.edu>
6209 6211
6210 6212 * Big change to the manual: now the magics are all automatically
6211 6213 documented. This information is generated from their docstrings
6212 6214 and put in a latex file included by the manual lyx file. This way
6213 6215 we get always up to date information for the magics. The manual
6214 6216 now also has proper version information, also auto-synced.
6215 6217
6216 6218 For this to work, an undocumented --magic_docstrings option was added.
6217 6219
6218 6220 2002-03-13 Fernando Perez <fperez@colorado.edu>
6219 6221
6220 6222 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
6221 6223 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
6222 6224
6223 6225 2002-03-12 Fernando Perez <fperez@colorado.edu>
6224 6226
6225 6227 * IPython/ultraTB.py (TermColors): changed color escapes again to
6226 6228 fix the (old, reintroduced) line-wrapping bug. Basically, if
6227 6229 \001..\002 aren't given in the color escapes, lines get wrapped
6228 6230 weirdly. But giving those screws up old xterms and emacs terms. So
6229 6231 I added some logic for emacs terms to be ok, but I can't identify old
6230 6232 xterms separately ($TERM=='xterm' for many terminals, like konsole).
6231 6233
6232 6234 2002-03-10 Fernando Perez <fperez@colorado.edu>
6233 6235
6234 6236 * IPython/usage.py (__doc__): Various documentation cleanups and
6235 6237 updates, both in usage docstrings and in the manual.
6236 6238
6237 6239 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
6238 6240 handling of caching. Set minimum acceptabe value for having a
6239 6241 cache at 20 values.
6240 6242
6241 6243 * IPython/iplib.py (InteractiveShell.user_setup): moved the
6242 6244 install_first_time function to a method, renamed it and added an
6243 6245 'upgrade' mode. Now people can update their config directory with
6244 6246 a simple command line switch (-upgrade, also new).
6245 6247
6246 6248 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
6247 6249 @file (convenient for automagic users under Python >= 2.2).
6248 6250 Removed @files (it seemed more like a plural than an abbrev. of
6249 6251 'file show').
6250 6252
6251 6253 * IPython/iplib.py (install_first_time): Fixed crash if there were
6252 6254 backup files ('~') in .ipython/ install directory.
6253 6255
6254 6256 * IPython/ipmaker.py (make_IPython): fixes for new prompt
6255 6257 system. Things look fine, but these changes are fairly
6256 6258 intrusive. Test them for a few days.
6257 6259
6258 6260 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
6259 6261 the prompts system. Now all in/out prompt strings are user
6260 6262 controllable. This is particularly useful for embedding, as one
6261 6263 can tag embedded instances with particular prompts.
6262 6264
6263 6265 Also removed global use of sys.ps1/2, which now allows nested
6264 6266 embeddings without any problems. Added command-line options for
6265 6267 the prompt strings.
6266 6268
6267 6269 2002-03-08 Fernando Perez <fperez@colorado.edu>
6268 6270
6269 6271 * IPython/UserConfig/example-embed-short.py (ipshell): added
6270 6272 example file with the bare minimum code for embedding.
6271 6273
6272 6274 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
6273 6275 functionality for the embeddable shell to be activated/deactivated
6274 6276 either globally or at each call.
6275 6277
6276 6278 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
6277 6279 rewriting the prompt with '--->' for auto-inputs with proper
6278 6280 coloring. Now the previous UGLY hack in handle_auto() is gone, and
6279 6281 this is handled by the prompts class itself, as it should.
6280 6282
6281 6283 2002-03-05 Fernando Perez <fperez@colorado.edu>
6282 6284
6283 6285 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
6284 6286 @logstart to avoid name clashes with the math log function.
6285 6287
6286 6288 * Big updates to X/Emacs section of the manual.
6287 6289
6288 6290 * Removed ipython_emacs. Milan explained to me how to pass
6289 6291 arguments to ipython through Emacs. Some day I'm going to end up
6290 6292 learning some lisp...
6291 6293
6292 6294 2002-03-04 Fernando Perez <fperez@colorado.edu>
6293 6295
6294 6296 * IPython/ipython_emacs: Created script to be used as the
6295 6297 py-python-command Emacs variable so we can pass IPython
6296 6298 parameters. I can't figure out how to tell Emacs directly to pass
6297 6299 parameters to IPython, so a dummy shell script will do it.
6298 6300
6299 6301 Other enhancements made for things to work better under Emacs'
6300 6302 various types of terminals. Many thanks to Milan Zamazal
6301 6303 <pdm-AT-zamazal.org> for all the suggestions and pointers.
6302 6304
6303 6305 2002-03-01 Fernando Perez <fperez@colorado.edu>
6304 6306
6305 6307 * IPython/ipmaker.py (make_IPython): added a --readline! option so
6306 6308 that loading of readline is now optional. This gives better
6307 6309 control to emacs users.
6308 6310
6309 6311 * IPython/ultraTB.py (__date__): Modified color escape sequences
6310 6312 and now things work fine under xterm and in Emacs' term buffers
6311 6313 (though not shell ones). Well, in emacs you get colors, but all
6312 6314 seem to be 'light' colors (no difference between dark and light
6313 6315 ones). But the garbage chars are gone, and also in xterms. It
6314 6316 seems that now I'm using 'cleaner' ansi sequences.
6315 6317
6316 6318 2002-02-21 Fernando Perez <fperez@colorado.edu>
6317 6319
6318 6320 * Released 0.2.7 (mainly to publish the scoping fix).
6319 6321
6320 6322 * IPython/Logger.py (Logger.logstate): added. A corresponding
6321 6323 @logstate magic was created.
6322 6324
6323 6325 * IPython/Magic.py: fixed nested scoping problem under Python
6324 6326 2.1.x (automagic wasn't working).
6325 6327
6326 6328 2002-02-20 Fernando Perez <fperez@colorado.edu>
6327 6329
6328 6330 * Released 0.2.6.
6329 6331
6330 6332 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
6331 6333 option so that logs can come out without any headers at all.
6332 6334
6333 6335 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
6334 6336 SciPy.
6335 6337
6336 6338 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
6337 6339 that embedded IPython calls don't require vars() to be explicitly
6338 6340 passed. Now they are extracted from the caller's frame (code
6339 6341 snatched from Eric Jones' weave). Added better documentation to
6340 6342 the section on embedding and the example file.
6341 6343
6342 6344 * IPython/genutils.py (page): Changed so that under emacs, it just
6343 6345 prints the string. You can then page up and down in the emacs
6344 6346 buffer itself. This is how the builtin help() works.
6345 6347
6346 6348 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
6347 6349 macro scoping: macros need to be executed in the user's namespace
6348 6350 to work as if they had been typed by the user.
6349 6351
6350 6352 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
6351 6353 execute automatically (no need to type 'exec...'). They then
6352 6354 behave like 'true macros'. The printing system was also modified
6353 6355 for this to work.
6354 6356
6355 6357 2002-02-19 Fernando Perez <fperez@colorado.edu>
6356 6358
6357 6359 * IPython/genutils.py (page_file): new function for paging files
6358 6360 in an OS-independent way. Also necessary for file viewing to work
6359 6361 well inside Emacs buffers.
6360 6362 (page): Added checks for being in an emacs buffer.
6361 6363 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
6362 6364 same bug in iplib.
6363 6365
6364 6366 2002-02-18 Fernando Perez <fperez@colorado.edu>
6365 6367
6366 6368 * IPython/iplib.py (InteractiveShell.init_readline): modified use
6367 6369 of readline so that IPython can work inside an Emacs buffer.
6368 6370
6369 6371 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
6370 6372 method signatures (they weren't really bugs, but it looks cleaner
6371 6373 and keeps PyChecker happy).
6372 6374
6373 6375 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
6374 6376 for implementing various user-defined hooks. Currently only
6375 6377 display is done.
6376 6378
6377 6379 * IPython/Prompts.py (CachedOutput._display): changed display
6378 6380 functions so that they can be dynamically changed by users easily.
6379 6381
6380 6382 * IPython/Extensions/numeric_formats.py (num_display): added an
6381 6383 extension for printing NumPy arrays in flexible manners. It
6382 6384 doesn't do anything yet, but all the structure is in
6383 6385 place. Ultimately the plan is to implement output format control
6384 6386 like in Octave.
6385 6387
6386 6388 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
6387 6389 methods are found at run-time by all the automatic machinery.
6388 6390
6389 6391 2002-02-17 Fernando Perez <fperez@colorado.edu>
6390 6392
6391 6393 * setup_Windows.py (make_shortcut): documented. Cleaned up the
6392 6394 whole file a little.
6393 6395
6394 6396 * ToDo: closed this document. Now there's a new_design.lyx
6395 6397 document for all new ideas. Added making a pdf of it for the
6396 6398 end-user distro.
6397 6399
6398 6400 * IPython/Logger.py (Logger.switch_log): Created this to replace
6399 6401 logon() and logoff(). It also fixes a nasty crash reported by
6400 6402 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
6401 6403
6402 6404 * IPython/iplib.py (complete): got auto-completion to work with
6403 6405 automagic (I had wanted this for a long time).
6404 6406
6405 6407 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
6406 6408 to @file, since file() is now a builtin and clashes with automagic
6407 6409 for @file.
6408 6410
6409 6411 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
6410 6412 of this was previously in iplib, which had grown to more than 2000
6411 6413 lines, way too long. No new functionality, but it makes managing
6412 6414 the code a bit easier.
6413 6415
6414 6416 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
6415 6417 information to crash reports.
6416 6418
6417 6419 2002-02-12 Fernando Perez <fperez@colorado.edu>
6418 6420
6419 6421 * Released 0.2.5.
6420 6422
6421 6423 2002-02-11 Fernando Perez <fperez@colorado.edu>
6422 6424
6423 6425 * Wrote a relatively complete Windows installer. It puts
6424 6426 everything in place, creates Start Menu entries and fixes the
6425 6427 color issues. Nothing fancy, but it works.
6426 6428
6427 6429 2002-02-10 Fernando Perez <fperez@colorado.edu>
6428 6430
6429 6431 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
6430 6432 os.path.expanduser() call so that we can type @run ~/myfile.py and
6431 6433 have thigs work as expected.
6432 6434
6433 6435 * IPython/genutils.py (page): fixed exception handling so things
6434 6436 work both in Unix and Windows correctly. Quitting a pager triggers
6435 6437 an IOError/broken pipe in Unix, and in windows not finding a pager
6436 6438 is also an IOError, so I had to actually look at the return value
6437 6439 of the exception, not just the exception itself. Should be ok now.
6438 6440
6439 6441 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
6440 6442 modified to allow case-insensitive color scheme changes.
6441 6443
6442 6444 2002-02-09 Fernando Perez <fperez@colorado.edu>
6443 6445
6444 6446 * IPython/genutils.py (native_line_ends): new function to leave
6445 6447 user config files with os-native line-endings.
6446 6448
6447 6449 * README and manual updates.
6448 6450
6449 6451 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
6450 6452 instead of StringType to catch Unicode strings.
6451 6453
6452 6454 * IPython/genutils.py (filefind): fixed bug for paths with
6453 6455 embedded spaces (very common in Windows).
6454 6456
6455 6457 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
6456 6458 files under Windows, so that they get automatically associated
6457 6459 with a text editor. Windows makes it a pain to handle
6458 6460 extension-less files.
6459 6461
6460 6462 * IPython/iplib.py (InteractiveShell.init_readline): Made the
6461 6463 warning about readline only occur for Posix. In Windows there's no
6462 6464 way to get readline, so why bother with the warning.
6463 6465
6464 6466 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
6465 6467 for __str__ instead of dir(self), since dir() changed in 2.2.
6466 6468
6467 6469 * Ported to Windows! Tested on XP, I suspect it should work fine
6468 6470 on NT/2000, but I don't think it will work on 98 et al. That
6469 6471 series of Windows is such a piece of junk anyway that I won't try
6470 6472 porting it there. The XP port was straightforward, showed a few
6471 6473 bugs here and there (fixed all), in particular some string
6472 6474 handling stuff which required considering Unicode strings (which
6473 6475 Windows uses). This is good, but hasn't been too tested :) No
6474 6476 fancy installer yet, I'll put a note in the manual so people at
6475 6477 least make manually a shortcut.
6476 6478
6477 6479 * IPython/iplib.py (Magic.magic_colors): Unified the color options
6478 6480 into a single one, "colors". This now controls both prompt and
6479 6481 exception color schemes, and can be changed both at startup
6480 6482 (either via command-line switches or via ipythonrc files) and at
6481 6483 runtime, with @colors.
6482 6484 (Magic.magic_run): renamed @prun to @run and removed the old
6483 6485 @run. The two were too similar to warrant keeping both.
6484 6486
6485 6487 2002-02-03 Fernando Perez <fperez@colorado.edu>
6486 6488
6487 6489 * IPython/iplib.py (install_first_time): Added comment on how to
6488 6490 configure the color options for first-time users. Put a <return>
6489 6491 request at the end so that small-terminal users get a chance to
6490 6492 read the startup info.
6491 6493
6492 6494 2002-01-23 Fernando Perez <fperez@colorado.edu>
6493 6495
6494 6496 * IPython/iplib.py (CachedOutput.update): Changed output memory
6495 6497 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
6496 6498 input history we still use _i. Did this b/c these variable are
6497 6499 very commonly used in interactive work, so the less we need to
6498 6500 type the better off we are.
6499 6501 (Magic.magic_prun): updated @prun to better handle the namespaces
6500 6502 the file will run in, including a fix for __name__ not being set
6501 6503 before.
6502 6504
6503 6505 2002-01-20 Fernando Perez <fperez@colorado.edu>
6504 6506
6505 6507 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
6506 6508 extra garbage for Python 2.2. Need to look more carefully into
6507 6509 this later.
6508 6510
6509 6511 2002-01-19 Fernando Perez <fperez@colorado.edu>
6510 6512
6511 6513 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
6512 6514 display SyntaxError exceptions properly formatted when they occur
6513 6515 (they can be triggered by imported code).
6514 6516
6515 6517 2002-01-18 Fernando Perez <fperez@colorado.edu>
6516 6518
6517 6519 * IPython/iplib.py (InteractiveShell.safe_execfile): now
6518 6520 SyntaxError exceptions are reported nicely formatted, instead of
6519 6521 spitting out only offset information as before.
6520 6522 (Magic.magic_prun): Added the @prun function for executing
6521 6523 programs with command line args inside IPython.
6522 6524
6523 6525 2002-01-16 Fernando Perez <fperez@colorado.edu>
6524 6526
6525 6527 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
6526 6528 to *not* include the last item given in a range. This brings their
6527 6529 behavior in line with Python's slicing:
6528 6530 a[n1:n2] -> a[n1]...a[n2-1]
6529 6531 It may be a bit less convenient, but I prefer to stick to Python's
6530 6532 conventions *everywhere*, so users never have to wonder.
6531 6533 (Magic.magic_macro): Added @macro function to ease the creation of
6532 6534 macros.
6533 6535
6534 6536 2002-01-05 Fernando Perez <fperez@colorado.edu>
6535 6537
6536 6538 * Released 0.2.4.
6537 6539
6538 6540 * IPython/iplib.py (Magic.magic_pdef):
6539 6541 (InteractiveShell.safe_execfile): report magic lines and error
6540 6542 lines without line numbers so one can easily copy/paste them for
6541 6543 re-execution.
6542 6544
6543 6545 * Updated manual with recent changes.
6544 6546
6545 6547 * IPython/iplib.py (Magic.magic_oinfo): added constructor
6546 6548 docstring printing when class? is called. Very handy for knowing
6547 6549 how to create class instances (as long as __init__ is well
6548 6550 documented, of course :)
6549 6551 (Magic.magic_doc): print both class and constructor docstrings.
6550 6552 (Magic.magic_pdef): give constructor info if passed a class and
6551 6553 __call__ info for callable object instances.
6552 6554
6553 6555 2002-01-04 Fernando Perez <fperez@colorado.edu>
6554 6556
6555 6557 * Made deep_reload() off by default. It doesn't always work
6556 6558 exactly as intended, so it's probably safer to have it off. It's
6557 6559 still available as dreload() anyway, so nothing is lost.
6558 6560
6559 6561 2002-01-02 Fernando Perez <fperez@colorado.edu>
6560 6562
6561 6563 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
6562 6564 so I wanted an updated release).
6563 6565
6564 6566 2001-12-27 Fernando Perez <fperez@colorado.edu>
6565 6567
6566 6568 * IPython/iplib.py (InteractiveShell.interact): Added the original
6567 6569 code from 'code.py' for this module in order to change the
6568 6570 handling of a KeyboardInterrupt. This was necessary b/c otherwise
6569 6571 the history cache would break when the user hit Ctrl-C, and
6570 6572 interact() offers no way to add any hooks to it.
6571 6573
6572 6574 2001-12-23 Fernando Perez <fperez@colorado.edu>
6573 6575
6574 6576 * setup.py: added check for 'MANIFEST' before trying to remove
6575 6577 it. Thanks to Sean Reifschneider.
6576 6578
6577 6579 2001-12-22 Fernando Perez <fperez@colorado.edu>
6578 6580
6579 6581 * Released 0.2.2.
6580 6582
6581 6583 * Finished (reasonably) writing the manual. Later will add the
6582 6584 python-standard navigation stylesheets, but for the time being
6583 6585 it's fairly complete. Distribution will include html and pdf
6584 6586 versions.
6585 6587
6586 6588 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
6587 6589 (MayaVi author).
6588 6590
6589 6591 2001-12-21 Fernando Perez <fperez@colorado.edu>
6590 6592
6591 6593 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
6592 6594 good public release, I think (with the manual and the distutils
6593 6595 installer). The manual can use some work, but that can go
6594 6596 slowly. Otherwise I think it's quite nice for end users. Next
6595 6597 summer, rewrite the guts of it...
6596 6598
6597 6599 * Changed format of ipythonrc files to use whitespace as the
6598 6600 separator instead of an explicit '='. Cleaner.
6599 6601
6600 6602 2001-12-20 Fernando Perez <fperez@colorado.edu>
6601 6603
6602 6604 * Started a manual in LyX. For now it's just a quick merge of the
6603 6605 various internal docstrings and READMEs. Later it may grow into a
6604 6606 nice, full-blown manual.
6605 6607
6606 6608 * Set up a distutils based installer. Installation should now be
6607 6609 trivially simple for end-users.
6608 6610
6609 6611 2001-12-11 Fernando Perez <fperez@colorado.edu>
6610 6612
6611 6613 * Released 0.2.0. First public release, announced it at
6612 6614 comp.lang.python. From now on, just bugfixes...
6613 6615
6614 6616 * Went through all the files, set copyright/license notices and
6615 6617 cleaned up things. Ready for release.
6616 6618
6617 6619 2001-12-10 Fernando Perez <fperez@colorado.edu>
6618 6620
6619 6621 * Changed the first-time installer not to use tarfiles. It's more
6620 6622 robust now and less unix-dependent. Also makes it easier for
6621 6623 people to later upgrade versions.
6622 6624
6623 6625 * Changed @exit to @abort to reflect the fact that it's pretty
6624 6626 brutal (a sys.exit()). The difference between @abort and Ctrl-D
6625 6627 becomes significant only when IPyhton is embedded: in that case,
6626 6628 C-D closes IPython only, but @abort kills the enclosing program
6627 6629 too (unless it had called IPython inside a try catching
6628 6630 SystemExit).
6629 6631
6630 6632 * Created Shell module which exposes the actuall IPython Shell
6631 6633 classes, currently the normal and the embeddable one. This at
6632 6634 least offers a stable interface we won't need to change when
6633 6635 (later) the internals are rewritten. That rewrite will be confined
6634 6636 to iplib and ipmaker, but the Shell interface should remain as is.
6635 6637
6636 6638 * Added embed module which offers an embeddable IPShell object,
6637 6639 useful to fire up IPython *inside* a running program. Great for
6638 6640 debugging or dynamical data analysis.
6639 6641
6640 6642 2001-12-08 Fernando Perez <fperez@colorado.edu>
6641 6643
6642 6644 * Fixed small bug preventing seeing info from methods of defined
6643 6645 objects (incorrect namespace in _ofind()).
6644 6646
6645 6647 * Documentation cleanup. Moved the main usage docstrings to a
6646 6648 separate file, usage.py (cleaner to maintain, and hopefully in the
6647 6649 future some perlpod-like way of producing interactive, man and
6648 6650 html docs out of it will be found).
6649 6651
6650 6652 * Added @profile to see your profile at any time.
6651 6653
6652 6654 * Added @p as an alias for 'print'. It's especially convenient if
6653 6655 using automagic ('p x' prints x).
6654 6656
6655 6657 * Small cleanups and fixes after a pychecker run.
6656 6658
6657 6659 * Changed the @cd command to handle @cd - and @cd -<n> for
6658 6660 visiting any directory in _dh.
6659 6661
6660 6662 * Introduced _dh, a history of visited directories. @dhist prints
6661 6663 it out with numbers.
6662 6664
6663 6665 2001-12-07 Fernando Perez <fperez@colorado.edu>
6664 6666
6665 6667 * Released 0.1.22
6666 6668
6667 6669 * Made initialization a bit more robust against invalid color
6668 6670 options in user input (exit, not traceback-crash).
6669 6671
6670 6672 * Changed the bug crash reporter to write the report only in the
6671 6673 user's .ipython directory. That way IPython won't litter people's
6672 6674 hard disks with crash files all over the place. Also print on
6673 6675 screen the necessary mail command.
6674 6676
6675 6677 * With the new ultraTB, implemented LightBG color scheme for light
6676 6678 background terminals. A lot of people like white backgrounds, so I
6677 6679 guess we should at least give them something readable.
6678 6680
6679 6681 2001-12-06 Fernando Perez <fperez@colorado.edu>
6680 6682
6681 6683 * Modified the structure of ultraTB. Now there's a proper class
6682 6684 for tables of color schemes which allow adding schemes easily and
6683 6685 switching the active scheme without creating a new instance every
6684 6686 time (which was ridiculous). The syntax for creating new schemes
6685 6687 is also cleaner. I think ultraTB is finally done, with a clean
6686 6688 class structure. Names are also much cleaner (now there's proper
6687 6689 color tables, no need for every variable to also have 'color' in
6688 6690 its name).
6689 6691
6690 6692 * Broke down genutils into separate files. Now genutils only
6691 6693 contains utility functions, and classes have been moved to their
6692 6694 own files (they had enough independent functionality to warrant
6693 6695 it): ConfigLoader, OutputTrap, Struct.
6694 6696
6695 6697 2001-12-05 Fernando Perez <fperez@colorado.edu>
6696 6698
6697 6699 * IPython turns 21! Released version 0.1.21, as a candidate for
6698 6700 public consumption. If all goes well, release in a few days.
6699 6701
6700 6702 * Fixed path bug (files in Extensions/ directory wouldn't be found
6701 6703 unless IPython/ was explicitly in sys.path).
6702 6704
6703 6705 * Extended the FlexCompleter class as MagicCompleter to allow
6704 6706 completion of @-starting lines.
6705 6707
6706 6708 * Created __release__.py file as a central repository for release
6707 6709 info that other files can read from.
6708 6710
6709 6711 * Fixed small bug in logging: when logging was turned on in
6710 6712 mid-session, old lines with special meanings (!@?) were being
6711 6713 logged without the prepended comment, which is necessary since
6712 6714 they are not truly valid python syntax. This should make session
6713 6715 restores produce less errors.
6714 6716
6715 6717 * The namespace cleanup forced me to make a FlexCompleter class
6716 6718 which is nothing but a ripoff of rlcompleter, but with selectable
6717 6719 namespace (rlcompleter only works in __main__.__dict__). I'll try
6718 6720 to submit a note to the authors to see if this change can be
6719 6721 incorporated in future rlcompleter releases (Dec.6: done)
6720 6722
6721 6723 * More fixes to namespace handling. It was a mess! Now all
6722 6724 explicit references to __main__.__dict__ are gone (except when
6723 6725 really needed) and everything is handled through the namespace
6724 6726 dicts in the IPython instance. We seem to be getting somewhere
6725 6727 with this, finally...
6726 6728
6727 6729 * Small documentation updates.
6728 6730
6729 6731 * Created the Extensions directory under IPython (with an
6730 6732 __init__.py). Put the PhysicalQ stuff there. This directory should
6731 6733 be used for all special-purpose extensions.
6732 6734
6733 6735 * File renaming:
6734 6736 ipythonlib --> ipmaker
6735 6737 ipplib --> iplib
6736 6738 This makes a bit more sense in terms of what these files actually do.
6737 6739
6738 6740 * Moved all the classes and functions in ipythonlib to ipplib, so
6739 6741 now ipythonlib only has make_IPython(). This will ease up its
6740 6742 splitting in smaller functional chunks later.
6741 6743
6742 6744 * Cleaned up (done, I think) output of @whos. Better column
6743 6745 formatting, and now shows str(var) for as much as it can, which is
6744 6746 typically what one gets with a 'print var'.
6745 6747
6746 6748 2001-12-04 Fernando Perez <fperez@colorado.edu>
6747 6749
6748 6750 * Fixed namespace problems. Now builtin/IPyhton/user names get
6749 6751 properly reported in their namespace. Internal namespace handling
6750 6752 is finally getting decent (not perfect yet, but much better than
6751 6753 the ad-hoc mess we had).
6752 6754
6753 6755 * Removed -exit option. If people just want to run a python
6754 6756 script, that's what the normal interpreter is for. Less
6755 6757 unnecessary options, less chances for bugs.
6756 6758
6757 6759 * Added a crash handler which generates a complete post-mortem if
6758 6760 IPython crashes. This will help a lot in tracking bugs down the
6759 6761 road.
6760 6762
6761 6763 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
6762 6764 which were boud to functions being reassigned would bypass the
6763 6765 logger, breaking the sync of _il with the prompt counter. This
6764 6766 would then crash IPython later when a new line was logged.
6765 6767
6766 6768 2001-12-02 Fernando Perez <fperez@colorado.edu>
6767 6769
6768 6770 * Made IPython a package. This means people don't have to clutter
6769 6771 their sys.path with yet another directory. Changed the INSTALL
6770 6772 file accordingly.
6771 6773
6772 6774 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
6773 6775 sorts its output (so @who shows it sorted) and @whos formats the
6774 6776 table according to the width of the first column. Nicer, easier to
6775 6777 read. Todo: write a generic table_format() which takes a list of
6776 6778 lists and prints it nicely formatted, with optional row/column
6777 6779 separators and proper padding and justification.
6778 6780
6779 6781 * Released 0.1.20
6780 6782
6781 6783 * Fixed bug in @log which would reverse the inputcache list (a
6782 6784 copy operation was missing).
6783 6785
6784 6786 * Code cleanup. @config was changed to use page(). Better, since
6785 6787 its output is always quite long.
6786 6788
6787 6789 * Itpl is back as a dependency. I was having too many problems
6788 6790 getting the parametric aliases to work reliably, and it's just
6789 6791 easier to code weird string operations with it than playing %()s
6790 6792 games. It's only ~6k, so I don't think it's too big a deal.
6791 6793
6792 6794 * Found (and fixed) a very nasty bug with history. !lines weren't
6793 6795 getting cached, and the out of sync caches would crash
6794 6796 IPython. Fixed it by reorganizing the prefilter/handlers/logger
6795 6797 division of labor a bit better. Bug fixed, cleaner structure.
6796 6798
6797 6799 2001-12-01 Fernando Perez <fperez@colorado.edu>
6798 6800
6799 6801 * Released 0.1.19
6800 6802
6801 6803 * Added option -n to @hist to prevent line number printing. Much
6802 6804 easier to copy/paste code this way.
6803 6805
6804 6806 * Created global _il to hold the input list. Allows easy
6805 6807 re-execution of blocks of code by slicing it (inspired by Janko's
6806 6808 comment on 'macros').
6807 6809
6808 6810 * Small fixes and doc updates.
6809 6811
6810 6812 * Rewrote @history function (was @h). Renamed it to @hist, @h is
6811 6813 much too fragile with automagic. Handles properly multi-line
6812 6814 statements and takes parameters.
6813 6815
6814 6816 2001-11-30 Fernando Perez <fperez@colorado.edu>
6815 6817
6816 6818 * Version 0.1.18 released.
6817 6819
6818 6820 * Fixed nasty namespace bug in initial module imports.
6819 6821
6820 6822 * Added copyright/license notes to all code files (except
6821 6823 DPyGetOpt). For the time being, LGPL. That could change.
6822 6824
6823 6825 * Rewrote a much nicer README, updated INSTALL, cleaned up
6824 6826 ipythonrc-* samples.
6825 6827
6826 6828 * Overall code/documentation cleanup. Basically ready for
6827 6829 release. Only remaining thing: licence decision (LGPL?).
6828 6830
6829 6831 * Converted load_config to a class, ConfigLoader. Now recursion
6830 6832 control is better organized. Doesn't include the same file twice.
6831 6833
6832 6834 2001-11-29 Fernando Perez <fperez@colorado.edu>
6833 6835
6834 6836 * Got input history working. Changed output history variables from
6835 6837 _p to _o so that _i is for input and _o for output. Just cleaner
6836 6838 convention.
6837 6839
6838 6840 * Implemented parametric aliases. This pretty much allows the
6839 6841 alias system to offer full-blown shell convenience, I think.
6840 6842
6841 6843 * Version 0.1.17 released, 0.1.18 opened.
6842 6844
6843 6845 * dot_ipython/ipythonrc (alias): added documentation.
6844 6846 (xcolor): Fixed small bug (xcolors -> xcolor)
6845 6847
6846 6848 * Changed the alias system. Now alias is a magic command to define
6847 6849 aliases just like the shell. Rationale: the builtin magics should
6848 6850 be there for things deeply connected to IPython's
6849 6851 architecture. And this is a much lighter system for what I think
6850 6852 is the really important feature: allowing users to define quickly
6851 6853 magics that will do shell things for them, so they can customize
6852 6854 IPython easily to match their work habits. If someone is really
6853 6855 desperate to have another name for a builtin alias, they can
6854 6856 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
6855 6857 works.
6856 6858
6857 6859 2001-11-28 Fernando Perez <fperez@colorado.edu>
6858 6860
6859 6861 * Changed @file so that it opens the source file at the proper
6860 6862 line. Since it uses less, if your EDITOR environment is
6861 6863 configured, typing v will immediately open your editor of choice
6862 6864 right at the line where the object is defined. Not as quick as
6863 6865 having a direct @edit command, but for all intents and purposes it
6864 6866 works. And I don't have to worry about writing @edit to deal with
6865 6867 all the editors, less does that.
6866 6868
6867 6869 * Version 0.1.16 released, 0.1.17 opened.
6868 6870
6869 6871 * Fixed some nasty bugs in the page/page_dumb combo that could
6870 6872 crash IPython.
6871 6873
6872 6874 2001-11-27 Fernando Perez <fperez@colorado.edu>
6873 6875
6874 6876 * Version 0.1.15 released, 0.1.16 opened.
6875 6877
6876 6878 * Finally got ? and ?? to work for undefined things: now it's
6877 6879 possible to type {}.get? and get information about the get method
6878 6880 of dicts, or os.path? even if only os is defined (so technically
6879 6881 os.path isn't). Works at any level. For example, after import os,
6880 6882 os?, os.path?, os.path.abspath? all work. This is great, took some
6881 6883 work in _ofind.
6882 6884
6883 6885 * Fixed more bugs with logging. The sanest way to do it was to add
6884 6886 to @log a 'mode' parameter. Killed two in one shot (this mode
6885 6887 option was a request of Janko's). I think it's finally clean
6886 6888 (famous last words).
6887 6889
6888 6890 * Added a page_dumb() pager which does a decent job of paging on
6889 6891 screen, if better things (like less) aren't available. One less
6890 6892 unix dependency (someday maybe somebody will port this to
6891 6893 windows).
6892 6894
6893 6895 * Fixed problem in magic_log: would lock of logging out if log
6894 6896 creation failed (because it would still think it had succeeded).
6895 6897
6896 6898 * Improved the page() function using curses to auto-detect screen
6897 6899 size. Now it can make a much better decision on whether to print
6898 6900 or page a string. Option screen_length was modified: a value 0
6899 6901 means auto-detect, and that's the default now.
6900 6902
6901 6903 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6902 6904 go out. I'll test it for a few days, then talk to Janko about
6903 6905 licences and announce it.
6904 6906
6905 6907 * Fixed the length of the auto-generated ---> prompt which appears
6906 6908 for auto-parens and auto-quotes. Getting this right isn't trivial,
6907 6909 with all the color escapes, different prompt types and optional
6908 6910 separators. But it seems to be working in all the combinations.
6909 6911
6910 6912 2001-11-26 Fernando Perez <fperez@colorado.edu>
6911 6913
6912 6914 * Wrote a regexp filter to get option types from the option names
6913 6915 string. This eliminates the need to manually keep two duplicate
6914 6916 lists.
6915 6917
6916 6918 * Removed the unneeded check_option_names. Now options are handled
6917 6919 in a much saner manner and it's easy to visually check that things
6918 6920 are ok.
6919 6921
6920 6922 * Updated version numbers on all files I modified to carry a
6921 6923 notice so Janko and Nathan have clear version markers.
6922 6924
6923 6925 * Updated docstring for ultraTB with my changes. I should send
6924 6926 this to Nathan.
6925 6927
6926 6928 * Lots of small fixes. Ran everything through pychecker again.
6927 6929
6928 6930 * Made loading of deep_reload an cmd line option. If it's not too
6929 6931 kosher, now people can just disable it. With -nodeep_reload it's
6930 6932 still available as dreload(), it just won't overwrite reload().
6931 6933
6932 6934 * Moved many options to the no| form (-opt and -noopt
6933 6935 accepted). Cleaner.
6934 6936
6935 6937 * Changed magic_log so that if called with no parameters, it uses
6936 6938 'rotate' mode. That way auto-generated logs aren't automatically
6937 6939 over-written. For normal logs, now a backup is made if it exists
6938 6940 (only 1 level of backups). A new 'backup' mode was added to the
6939 6941 Logger class to support this. This was a request by Janko.
6940 6942
6941 6943 * Added @logoff/@logon to stop/restart an active log.
6942 6944
6943 6945 * Fixed a lot of bugs in log saving/replay. It was pretty
6944 6946 broken. Now special lines (!@,/) appear properly in the command
6945 6947 history after a log replay.
6946 6948
6947 6949 * Tried and failed to implement full session saving via pickle. My
6948 6950 idea was to pickle __main__.__dict__, but modules can't be
6949 6951 pickled. This would be a better alternative to replaying logs, but
6950 6952 seems quite tricky to get to work. Changed -session to be called
6951 6953 -logplay, which more accurately reflects what it does. And if we
6952 6954 ever get real session saving working, -session is now available.
6953 6955
6954 6956 * Implemented color schemes for prompts also. As for tracebacks,
6955 6957 currently only NoColor and Linux are supported. But now the
6956 6958 infrastructure is in place, based on a generic ColorScheme
6957 6959 class. So writing and activating new schemes both for the prompts
6958 6960 and the tracebacks should be straightforward.
6959 6961
6960 6962 * Version 0.1.13 released, 0.1.14 opened.
6961 6963
6962 6964 * Changed handling of options for output cache. Now counter is
6963 6965 hardwired starting at 1 and one specifies the maximum number of
6964 6966 entries *in the outcache* (not the max prompt counter). This is
6965 6967 much better, since many statements won't increase the cache
6966 6968 count. It also eliminated some confusing options, now there's only
6967 6969 one: cache_size.
6968 6970
6969 6971 * Added 'alias' magic function and magic_alias option in the
6970 6972 ipythonrc file. Now the user can easily define whatever names he
6971 6973 wants for the magic functions without having to play weird
6972 6974 namespace games. This gives IPython a real shell-like feel.
6973 6975
6974 6976 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6975 6977 @ or not).
6976 6978
6977 6979 This was one of the last remaining 'visible' bugs (that I know
6978 6980 of). I think if I can clean up the session loading so it works
6979 6981 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6980 6982 about licensing).
6981 6983
6982 6984 2001-11-25 Fernando Perez <fperez@colorado.edu>
6983 6985
6984 6986 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6985 6987 there's a cleaner distinction between what ? and ?? show.
6986 6988
6987 6989 * Added screen_length option. Now the user can define his own
6988 6990 screen size for page() operations.
6989 6991
6990 6992 * Implemented magic shell-like functions with automatic code
6991 6993 generation. Now adding another function is just a matter of adding
6992 6994 an entry to a dict, and the function is dynamically generated at
6993 6995 run-time. Python has some really cool features!
6994 6996
6995 6997 * Renamed many options to cleanup conventions a little. Now all
6996 6998 are lowercase, and only underscores where needed. Also in the code
6997 6999 option name tables are clearer.
6998 7000
6999 7001 * Changed prompts a little. Now input is 'In [n]:' instead of
7000 7002 'In[n]:='. This allows it the numbers to be aligned with the
7001 7003 Out[n] numbers, and removes usage of ':=' which doesn't exist in
7002 7004 Python (it was a Mathematica thing). The '...' continuation prompt
7003 7005 was also changed a little to align better.
7004 7006
7005 7007 * Fixed bug when flushing output cache. Not all _p<n> variables
7006 7008 exist, so their deletion needs to be wrapped in a try:
7007 7009
7008 7010 * Figured out how to properly use inspect.formatargspec() (it
7009 7011 requires the args preceded by *). So I removed all the code from
7010 7012 _get_pdef in Magic, which was just replicating that.
7011 7013
7012 7014 * Added test to prefilter to allow redefining magic function names
7013 7015 as variables. This is ok, since the @ form is always available,
7014 7016 but whe should allow the user to define a variable called 'ls' if
7015 7017 he needs it.
7016 7018
7017 7019 * Moved the ToDo information from README into a separate ToDo.
7018 7020
7019 7021 * General code cleanup and small bugfixes. I think it's close to a
7020 7022 state where it can be released, obviously with a big 'beta'
7021 7023 warning on it.
7022 7024
7023 7025 * Got the magic function split to work. Now all magics are defined
7024 7026 in a separate class. It just organizes things a bit, and now
7025 7027 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
7026 7028 was too long).
7027 7029
7028 7030 * Changed @clear to @reset to avoid potential confusions with
7029 7031 the shell command clear. Also renamed @cl to @clear, which does
7030 7032 exactly what people expect it to from their shell experience.
7031 7033
7032 7034 Added a check to the @reset command (since it's so
7033 7035 destructive, it's probably a good idea to ask for confirmation).
7034 7036 But now reset only works for full namespace resetting. Since the
7035 7037 del keyword is already there for deleting a few specific
7036 7038 variables, I don't see the point of having a redundant magic
7037 7039 function for the same task.
7038 7040
7039 7041 2001-11-24 Fernando Perez <fperez@colorado.edu>
7040 7042
7041 7043 * Updated the builtin docs (esp. the ? ones).
7042 7044
7043 7045 * Ran all the code through pychecker. Not terribly impressed with
7044 7046 it: lots of spurious warnings and didn't really find anything of
7045 7047 substance (just a few modules being imported and not used).
7046 7048
7047 7049 * Implemented the new ultraTB functionality into IPython. New
7048 7050 option: xcolors. This chooses color scheme. xmode now only selects
7049 7051 between Plain and Verbose. Better orthogonality.
7050 7052
7051 7053 * Large rewrite of ultraTB. Much cleaner now, with a separation of
7052 7054 mode and color scheme for the exception handlers. Now it's
7053 7055 possible to have the verbose traceback with no coloring.
7054 7056
7055 7057 2001-11-23 Fernando Perez <fperez@colorado.edu>
7056 7058
7057 7059 * Version 0.1.12 released, 0.1.13 opened.
7058 7060
7059 7061 * Removed option to set auto-quote and auto-paren escapes by
7060 7062 user. The chances of breaking valid syntax are just too high. If
7061 7063 someone *really* wants, they can always dig into the code.
7062 7064
7063 7065 * Made prompt separators configurable.
7064 7066
7065 7067 2001-11-22 Fernando Perez <fperez@colorado.edu>
7066 7068
7067 7069 * Small bugfixes in many places.
7068 7070
7069 7071 * Removed the MyCompleter class from ipplib. It seemed redundant
7070 7072 with the C-p,C-n history search functionality. Less code to
7071 7073 maintain.
7072 7074
7073 7075 * Moved all the original ipython.py code into ipythonlib.py. Right
7074 7076 now it's just one big dump into a function called make_IPython, so
7075 7077 no real modularity has been gained. But at least it makes the
7076 7078 wrapper script tiny, and since ipythonlib is a module, it gets
7077 7079 compiled and startup is much faster.
7078 7080
7079 7081 This is a reasobably 'deep' change, so we should test it for a
7080 7082 while without messing too much more with the code.
7081 7083
7082 7084 2001-11-21 Fernando Perez <fperez@colorado.edu>
7083 7085
7084 7086 * Version 0.1.11 released, 0.1.12 opened for further work.
7085 7087
7086 7088 * Removed dependency on Itpl. It was only needed in one place. It
7087 7089 would be nice if this became part of python, though. It makes life
7088 7090 *a lot* easier in some cases.
7089 7091
7090 7092 * Simplified the prefilter code a bit. Now all handlers are
7091 7093 expected to explicitly return a value (at least a blank string).
7092 7094
7093 7095 * Heavy edits in ipplib. Removed the help system altogether. Now
7094 7096 obj?/?? is used for inspecting objects, a magic @doc prints
7095 7097 docstrings, and full-blown Python help is accessed via the 'help'
7096 7098 keyword. This cleans up a lot of code (less to maintain) and does
7097 7099 the job. Since 'help' is now a standard Python component, might as
7098 7100 well use it and remove duplicate functionality.
7099 7101
7100 7102 Also removed the option to use ipplib as a standalone program. By
7101 7103 now it's too dependent on other parts of IPython to function alone.
7102 7104
7103 7105 * Fixed bug in genutils.pager. It would crash if the pager was
7104 7106 exited immediately after opening (broken pipe).
7105 7107
7106 7108 * Trimmed down the VerboseTB reporting a little. The header is
7107 7109 much shorter now and the repeated exception arguments at the end
7108 7110 have been removed. For interactive use the old header seemed a bit
7109 7111 excessive.
7110 7112
7111 7113 * Fixed small bug in output of @whos for variables with multi-word
7112 7114 types (only first word was displayed).
7113 7115
7114 7116 2001-11-17 Fernando Perez <fperez@colorado.edu>
7115 7117
7116 7118 * Version 0.1.10 released, 0.1.11 opened for further work.
7117 7119
7118 7120 * Modified dirs and friends. dirs now *returns* the stack (not
7119 7121 prints), so one can manipulate it as a variable. Convenient to
7120 7122 travel along many directories.
7121 7123
7122 7124 * Fixed bug in magic_pdef: would only work with functions with
7123 7125 arguments with default values.
7124 7126
7125 7127 2001-11-14 Fernando Perez <fperez@colorado.edu>
7126 7128
7127 7129 * Added the PhysicsInput stuff to dot_ipython so it ships as an
7128 7130 example with IPython. Various other minor fixes and cleanups.
7129 7131
7130 7132 * Version 0.1.9 released, 0.1.10 opened for further work.
7131 7133
7132 7134 * Added sys.path to the list of directories searched in the
7133 7135 execfile= option. It used to be the current directory and the
7134 7136 user's IPYTHONDIR only.
7135 7137
7136 7138 2001-11-13 Fernando Perez <fperez@colorado.edu>
7137 7139
7138 7140 * Reinstated the raw_input/prefilter separation that Janko had
7139 7141 initially. This gives a more convenient setup for extending the
7140 7142 pre-processor from the outside: raw_input always gets a string,
7141 7143 and prefilter has to process it. We can then redefine prefilter
7142 7144 from the outside and implement extensions for special
7143 7145 purposes.
7144 7146
7145 7147 Today I got one for inputting PhysicalQuantity objects
7146 7148 (from Scientific) without needing any function calls at
7147 7149 all. Extremely convenient, and it's all done as a user-level
7148 7150 extension (no IPython code was touched). Now instead of:
7149 7151 a = PhysicalQuantity(4.2,'m/s**2')
7150 7152 one can simply say
7151 7153 a = 4.2 m/s**2
7152 7154 or even
7153 7155 a = 4.2 m/s^2
7154 7156
7155 7157 I use this, but it's also a proof of concept: IPython really is
7156 7158 fully user-extensible, even at the level of the parsing of the
7157 7159 command line. It's not trivial, but it's perfectly doable.
7158 7160
7159 7161 * Added 'add_flip' method to inclusion conflict resolver. Fixes
7160 7162 the problem of modules being loaded in the inverse order in which
7161 7163 they were defined in
7162 7164
7163 7165 * Version 0.1.8 released, 0.1.9 opened for further work.
7164 7166
7165 7167 * Added magics pdef, source and file. They respectively show the
7166 7168 definition line ('prototype' in C), source code and full python
7167 7169 file for any callable object. The object inspector oinfo uses
7168 7170 these to show the same information.
7169 7171
7170 7172 * Version 0.1.7 released, 0.1.8 opened for further work.
7171 7173
7172 7174 * Separated all the magic functions into a class called Magic. The
7173 7175 InteractiveShell class was becoming too big for Xemacs to handle
7174 7176 (de-indenting a line would lock it up for 10 seconds while it
7175 7177 backtracked on the whole class!)
7176 7178
7177 7179 FIXME: didn't work. It can be done, but right now namespaces are
7178 7180 all messed up. Do it later (reverted it for now, so at least
7179 7181 everything works as before).
7180 7182
7181 7183 * Got the object introspection system (magic_oinfo) working! I
7182 7184 think this is pretty much ready for release to Janko, so he can
7183 7185 test it for a while and then announce it. Pretty much 100% of what
7184 7186 I wanted for the 'phase 1' release is ready. Happy, tired.
7185 7187
7186 7188 2001-11-12 Fernando Perez <fperez@colorado.edu>
7187 7189
7188 7190 * Version 0.1.6 released, 0.1.7 opened for further work.
7189 7191
7190 7192 * Fixed bug in printing: it used to test for truth before
7191 7193 printing, so 0 wouldn't print. Now checks for None.
7192 7194
7193 7195 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
7194 7196 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
7195 7197 reaches by hand into the outputcache. Think of a better way to do
7196 7198 this later.
7197 7199
7198 7200 * Various small fixes thanks to Nathan's comments.
7199 7201
7200 7202 * Changed magic_pprint to magic_Pprint. This way it doesn't
7201 7203 collide with pprint() and the name is consistent with the command
7202 7204 line option.
7203 7205
7204 7206 * Changed prompt counter behavior to be fully like
7205 7207 Mathematica's. That is, even input that doesn't return a result
7206 7208 raises the prompt counter. The old behavior was kind of confusing
7207 7209 (getting the same prompt number several times if the operation
7208 7210 didn't return a result).
7209 7211
7210 7212 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
7211 7213
7212 7214 * Fixed -Classic mode (wasn't working anymore).
7213 7215
7214 7216 * Added colored prompts using Nathan's new code. Colors are
7215 7217 currently hardwired, they can be user-configurable. For
7216 7218 developers, they can be chosen in file ipythonlib.py, at the
7217 7219 beginning of the CachedOutput class def.
7218 7220
7219 7221 2001-11-11 Fernando Perez <fperez@colorado.edu>
7220 7222
7221 7223 * Version 0.1.5 released, 0.1.6 opened for further work.
7222 7224
7223 7225 * Changed magic_env to *return* the environment as a dict (not to
7224 7226 print it). This way it prints, but it can also be processed.
7225 7227
7226 7228 * Added Verbose exception reporting to interactive
7227 7229 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
7228 7230 traceback. Had to make some changes to the ultraTB file. This is
7229 7231 probably the last 'big' thing in my mental todo list. This ties
7230 7232 in with the next entry:
7231 7233
7232 7234 * Changed -Xi and -Xf to a single -xmode option. Now all the user
7233 7235 has to specify is Plain, Color or Verbose for all exception
7234 7236 handling.
7235 7237
7236 7238 * Removed ShellServices option. All this can really be done via
7237 7239 the magic system. It's easier to extend, cleaner and has automatic
7238 7240 namespace protection and documentation.
7239 7241
7240 7242 2001-11-09 Fernando Perez <fperez@colorado.edu>
7241 7243
7242 7244 * Fixed bug in output cache flushing (missing parameter to
7243 7245 __init__). Other small bugs fixed (found using pychecker).
7244 7246
7245 7247 * Version 0.1.4 opened for bugfixing.
7246 7248
7247 7249 2001-11-07 Fernando Perez <fperez@colorado.edu>
7248 7250
7249 7251 * Version 0.1.3 released, mainly because of the raw_input bug.
7250 7252
7251 7253 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
7252 7254 and when testing for whether things were callable, a call could
7253 7255 actually be made to certain functions. They would get called again
7254 7256 once 'really' executed, with a resulting double call. A disaster
7255 7257 in many cases (list.reverse() would never work!).
7256 7258
7257 7259 * Removed prefilter() function, moved its code to raw_input (which
7258 7260 after all was just a near-empty caller for prefilter). This saves
7259 7261 a function call on every prompt, and simplifies the class a tiny bit.
7260 7262
7261 7263 * Fix _ip to __ip name in magic example file.
7262 7264
7263 7265 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
7264 7266 work with non-gnu versions of tar.
7265 7267
7266 7268 2001-11-06 Fernando Perez <fperez@colorado.edu>
7267 7269
7268 7270 * Version 0.1.2. Just to keep track of the recent changes.
7269 7271
7270 7272 * Fixed nasty bug in output prompt routine. It used to check 'if
7271 7273 arg != None...'. Problem is, this fails if arg implements a
7272 7274 special comparison (__cmp__) which disallows comparing to
7273 7275 None. Found it when trying to use the PhysicalQuantity module from
7274 7276 ScientificPython.
7275 7277
7276 7278 2001-11-05 Fernando Perez <fperez@colorado.edu>
7277 7279
7278 7280 * Also added dirs. Now the pushd/popd/dirs family functions
7279 7281 basically like the shell, with the added convenience of going home
7280 7282 when called with no args.
7281 7283
7282 7284 * pushd/popd slightly modified to mimic shell behavior more
7283 7285 closely.
7284 7286
7285 7287 * Added env,pushd,popd from ShellServices as magic functions. I
7286 7288 think the cleanest will be to port all desired functions from
7287 7289 ShellServices as magics and remove ShellServices altogether. This
7288 7290 will provide a single, clean way of adding functionality
7289 7291 (shell-type or otherwise) to IP.
7290 7292
7291 7293 2001-11-04 Fernando Perez <fperez@colorado.edu>
7292 7294
7293 7295 * Added .ipython/ directory to sys.path. This way users can keep
7294 7296 customizations there and access them via import.
7295 7297
7296 7298 2001-11-03 Fernando Perez <fperez@colorado.edu>
7297 7299
7298 7300 * Opened version 0.1.1 for new changes.
7299 7301
7300 7302 * Changed version number to 0.1.0: first 'public' release, sent to
7301 7303 Nathan and Janko.
7302 7304
7303 7305 * Lots of small fixes and tweaks.
7304 7306
7305 7307 * Minor changes to whos format. Now strings are shown, snipped if
7306 7308 too long.
7307 7309
7308 7310 * Changed ShellServices to work on __main__ so they show up in @who
7309 7311
7310 7312 * Help also works with ? at the end of a line:
7311 7313 ?sin and sin?
7312 7314 both produce the same effect. This is nice, as often I use the
7313 7315 tab-complete to find the name of a method, but I used to then have
7314 7316 to go to the beginning of the line to put a ? if I wanted more
7315 7317 info. Now I can just add the ? and hit return. Convenient.
7316 7318
7317 7319 2001-11-02 Fernando Perez <fperez@colorado.edu>
7318 7320
7319 7321 * Python version check (>=2.1) added.
7320 7322
7321 7323 * Added LazyPython documentation. At this point the docs are quite
7322 7324 a mess. A cleanup is in order.
7323 7325
7324 7326 * Auto-installer created. For some bizarre reason, the zipfiles
7325 7327 module isn't working on my system. So I made a tar version
7326 7328 (hopefully the command line options in various systems won't kill
7327 7329 me).
7328 7330
7329 7331 * Fixes to Struct in genutils. Now all dictionary-like methods are
7330 7332 protected (reasonably).
7331 7333
7332 7334 * Added pager function to genutils and changed ? to print usage
7333 7335 note through it (it was too long).
7334 7336
7335 7337 * Added the LazyPython functionality. Works great! I changed the
7336 7338 auto-quote escape to ';', it's on home row and next to '. But
7337 7339 both auto-quote and auto-paren (still /) escapes are command-line
7338 7340 parameters.
7339 7341
7340 7342
7341 7343 2001-11-01 Fernando Perez <fperez@colorado.edu>
7342 7344
7343 7345 * Version changed to 0.0.7. Fairly large change: configuration now
7344 7346 is all stored in a directory, by default .ipython. There, all
7345 7347 config files have normal looking names (not .names)
7346 7348
7347 7349 * Version 0.0.6 Released first to Lucas and Archie as a test
7348 7350 run. Since it's the first 'semi-public' release, change version to
7349 7351 > 0.0.6 for any changes now.
7350 7352
7351 7353 * Stuff I had put in the ipplib.py changelog:
7352 7354
7353 7355 Changes to InteractiveShell:
7354 7356
7355 7357 - Made the usage message a parameter.
7356 7358
7357 7359 - Require the name of the shell variable to be given. It's a bit
7358 7360 of a hack, but allows the name 'shell' not to be hardwired in the
7359 7361 magic (@) handler, which is problematic b/c it requires
7360 7362 polluting the global namespace with 'shell'. This in turn is
7361 7363 fragile: if a user redefines a variable called shell, things
7362 7364 break.
7363 7365
7364 7366 - magic @: all functions available through @ need to be defined
7365 7367 as magic_<name>, even though they can be called simply as
7366 7368 @<name>. This allows the special command @magic to gather
7367 7369 information automatically about all existing magic functions,
7368 7370 even if they are run-time user extensions, by parsing the shell
7369 7371 instance __dict__ looking for special magic_ names.
7370 7372
7371 7373 - mainloop: added *two* local namespace parameters. This allows
7372 7374 the class to differentiate between parameters which were there
7373 7375 before and after command line initialization was processed. This
7374 7376 way, later @who can show things loaded at startup by the
7375 7377 user. This trick was necessary to make session saving/reloading
7376 7378 really work: ideally after saving/exiting/reloading a session,
7377 7379 *everything* should look the same, including the output of @who. I
7378 7380 was only able to make this work with this double namespace
7379 7381 trick.
7380 7382
7381 7383 - added a header to the logfile which allows (almost) full
7382 7384 session restoring.
7383 7385
7384 7386 - prepend lines beginning with @ or !, with a and log
7385 7387 them. Why? !lines: may be useful to know what you did @lines:
7386 7388 they may affect session state. So when restoring a session, at
7387 7389 least inform the user of their presence. I couldn't quite get
7388 7390 them to properly re-execute, but at least the user is warned.
7389 7391
7390 7392 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now