##// END OF EJS Templates
prompt and set_term_title now include drive letter and / characters on win32
vivainio -
Show More
@@ -1,3012 +1,3010 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 2649 2007-08-21 18:19:20Z vivainio $"""
4 $Id: Magic.py 2659 2007-08-22 20:21:07Z vivainio $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import bdb
24 import bdb
25 import inspect
25 import inspect
26 import os
26 import os
27 import pdb
27 import pdb
28 import pydoc
28 import pydoc
29 import sys
29 import sys
30 import re
30 import re
31 import tempfile
31 import tempfile
32 import time
32 import time
33 import cPickle as pickle
33 import cPickle as pickle
34 import textwrap
34 import textwrap
35 from cStringIO import StringIO
35 from cStringIO import StringIO
36 from getopt import getopt,GetoptError
36 from getopt import getopt,GetoptError
37 from pprint import pprint, pformat
37 from pprint import pprint, pformat
38 from sets import Set
38 from sets import Set
39
39
40 # cProfile was added in Python2.5
40 # cProfile was added in Python2.5
41 try:
41 try:
42 import cProfile as profile
42 import cProfile as profile
43 import pstats
43 import pstats
44 except ImportError:
44 except ImportError:
45 # profile isn't bundled by default in Debian for license reasons
45 # profile isn't bundled by default in Debian for license reasons
46 try:
46 try:
47 import profile,pstats
47 import profile,pstats
48 except ImportError:
48 except ImportError:
49 profile = pstats = None
49 profile = pstats = None
50
50
51 # Homebrewed
51 # Homebrewed
52 import IPython
52 import IPython
53 from IPython import Debugger, OInspect, wildcard
53 from IPython import Debugger, OInspect, wildcard
54 from IPython.FakeModule import FakeModule
54 from IPython.FakeModule import FakeModule
55 from IPython.Itpl import Itpl, itpl, printpl,itplns
55 from IPython.Itpl import Itpl, itpl, printpl,itplns
56 from IPython.PyColorize import Parser
56 from IPython.PyColorize import Parser
57 from IPython.ipstruct import Struct
57 from IPython.ipstruct import Struct
58 from IPython.macro import Macro
58 from IPython.macro import Macro
59 from IPython.genutils import *
59 from IPython.genutils import *
60 from IPython import platutils
60 from IPython import platutils
61 import IPython.generics
61 import IPython.generics
62 import IPython.ipapi
62 import IPython.ipapi
63
63
64 #***************************************************************************
64 #***************************************************************************
65 # Utility functions
65 # Utility functions
66 def on_off(tag):
66 def on_off(tag):
67 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
67 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
68 return ['OFF','ON'][tag]
68 return ['OFF','ON'][tag]
69
69
70 class Bunch: pass
70 class Bunch: pass
71
71
72 def compress_dhist(dh):
72 def compress_dhist(dh):
73 head, tail = dh[:-10], dh[-10:]
73 head, tail = dh[:-10], dh[-10:]
74
74
75 newhead = []
75 newhead = []
76 done = Set()
76 done = Set()
77 for h in head:
77 for h in head:
78 if h in done:
78 if h in done:
79 continue
79 continue
80 newhead.append(h)
80 newhead.append(h)
81 done.add(h)
81 done.add(h)
82
82
83 return newhead + tail
83 return newhead + tail
84
84
85
85
86 #***************************************************************************
86 #***************************************************************************
87 # Main class implementing Magic functionality
87 # Main class implementing Magic functionality
88 class Magic:
88 class Magic:
89 """Magic functions for InteractiveShell.
89 """Magic functions for InteractiveShell.
90
90
91 Shell functions which can be reached as %function_name. All magic
91 Shell functions which can be reached as %function_name. All magic
92 functions should accept a string, which they can parse for their own
92 functions should accept a string, which they can parse for their own
93 needs. This can make some functions easier to type, eg `%cd ../`
93 needs. This can make some functions easier to type, eg `%cd ../`
94 vs. `%cd("../")`
94 vs. `%cd("../")`
95
95
96 ALL definitions MUST begin with the prefix magic_. The user won't need it
96 ALL definitions MUST begin with the prefix magic_. The user won't need it
97 at the command line, but it is is needed in the definition. """
97 at the command line, but it is is needed in the definition. """
98
98
99 # class globals
99 # class globals
100 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
100 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
101 'Automagic is ON, % prefix NOT needed for magic functions.']
101 'Automagic is ON, % prefix NOT needed for magic functions.']
102
102
103 #......................................................................
103 #......................................................................
104 # some utility functions
104 # some utility functions
105
105
106 def __init__(self,shell):
106 def __init__(self,shell):
107
107
108 self.options_table = {}
108 self.options_table = {}
109 if profile is None:
109 if profile is None:
110 self.magic_prun = self.profile_missing_notice
110 self.magic_prun = self.profile_missing_notice
111 self.shell = shell
111 self.shell = shell
112
112
113 # namespace for holding state we may need
113 # namespace for holding state we may need
114 self._magic_state = Bunch()
114 self._magic_state = Bunch()
115
115
116 def profile_missing_notice(self, *args, **kwargs):
116 def profile_missing_notice(self, *args, **kwargs):
117 error("""\
117 error("""\
118 The profile module could not be found. If you are a Debian user,
118 The profile module could not be found. If you are a Debian user,
119 it has been removed from the standard Debian package because of its non-free
119 it has been removed from the standard Debian package because of its non-free
120 license. To use profiling, please install"python2.3-profiler" from non-free.""")
120 license. To use profiling, please install"python2.3-profiler" from non-free.""")
121
121
122 def default_option(self,fn,optstr):
122 def default_option(self,fn,optstr):
123 """Make an entry in the options_table for fn, with value optstr"""
123 """Make an entry in the options_table for fn, with value optstr"""
124
124
125 if fn not in self.lsmagic():
125 if fn not in self.lsmagic():
126 error("%s is not a magic function" % fn)
126 error("%s is not a magic function" % fn)
127 self.options_table[fn] = optstr
127 self.options_table[fn] = optstr
128
128
129 def lsmagic(self):
129 def lsmagic(self):
130 """Return a list of currently available magic functions.
130 """Return a list of currently available magic functions.
131
131
132 Gives a list of the bare names after mangling (['ls','cd', ...], not
132 Gives a list of the bare names after mangling (['ls','cd', ...], not
133 ['magic_ls','magic_cd',...]"""
133 ['magic_ls','magic_cd',...]"""
134
134
135 # FIXME. This needs a cleanup, in the way the magics list is built.
135 # FIXME. This needs a cleanup, in the way the magics list is built.
136
136
137 # magics in class definition
137 # magics in class definition
138 class_magic = lambda fn: fn.startswith('magic_') and \
138 class_magic = lambda fn: fn.startswith('magic_') and \
139 callable(Magic.__dict__[fn])
139 callable(Magic.__dict__[fn])
140 # in instance namespace (run-time user additions)
140 # in instance namespace (run-time user additions)
141 inst_magic = lambda fn: fn.startswith('magic_') and \
141 inst_magic = lambda fn: fn.startswith('magic_') and \
142 callable(self.__dict__[fn])
142 callable(self.__dict__[fn])
143 # and bound magics by user (so they can access self):
143 # and bound magics by user (so they can access self):
144 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
144 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
145 callable(self.__class__.__dict__[fn])
145 callable(self.__class__.__dict__[fn])
146 magics = filter(class_magic,Magic.__dict__.keys()) + \
146 magics = filter(class_magic,Magic.__dict__.keys()) + \
147 filter(inst_magic,self.__dict__.keys()) + \
147 filter(inst_magic,self.__dict__.keys()) + \
148 filter(inst_bound_magic,self.__class__.__dict__.keys())
148 filter(inst_bound_magic,self.__class__.__dict__.keys())
149 out = []
149 out = []
150 for fn in magics:
150 for fn in magics:
151 out.append(fn.replace('magic_','',1))
151 out.append(fn.replace('magic_','',1))
152 out.sort()
152 out.sort()
153 return out
153 return out
154
154
155 def extract_input_slices(self,slices,raw=False):
155 def extract_input_slices(self,slices,raw=False):
156 """Return as a string a set of input history slices.
156 """Return as a string a set of input history slices.
157
157
158 Inputs:
158 Inputs:
159
159
160 - slices: the set of slices is given as a list of strings (like
160 - slices: the set of slices is given as a list of strings (like
161 ['1','4:8','9'], since this function is for use by magic functions
161 ['1','4:8','9'], since this function is for use by magic functions
162 which get their arguments as strings.
162 which get their arguments as strings.
163
163
164 Optional inputs:
164 Optional inputs:
165
165
166 - raw(False): by default, the processed input is used. If this is
166 - raw(False): by default, the processed input is used. If this is
167 true, the raw input history is used instead.
167 true, the raw input history is used instead.
168
168
169 Note that slices can be called with two notations:
169 Note that slices can be called with two notations:
170
170
171 N:M -> standard python form, means including items N...(M-1).
171 N:M -> standard python form, means including items N...(M-1).
172
172
173 N-M -> include items N..M (closed endpoint)."""
173 N-M -> include items N..M (closed endpoint)."""
174
174
175 if raw:
175 if raw:
176 hist = self.shell.input_hist_raw
176 hist = self.shell.input_hist_raw
177 else:
177 else:
178 hist = self.shell.input_hist
178 hist = self.shell.input_hist
179
179
180 cmds = []
180 cmds = []
181 for chunk in slices:
181 for chunk in slices:
182 if ':' in chunk:
182 if ':' in chunk:
183 ini,fin = map(int,chunk.split(':'))
183 ini,fin = map(int,chunk.split(':'))
184 elif '-' in chunk:
184 elif '-' in chunk:
185 ini,fin = map(int,chunk.split('-'))
185 ini,fin = map(int,chunk.split('-'))
186 fin += 1
186 fin += 1
187 else:
187 else:
188 ini = int(chunk)
188 ini = int(chunk)
189 fin = ini+1
189 fin = ini+1
190 cmds.append(hist[ini:fin])
190 cmds.append(hist[ini:fin])
191 return cmds
191 return cmds
192
192
193 def _ofind(self, oname, namespaces=None):
193 def _ofind(self, oname, namespaces=None):
194 """Find an object in the available namespaces.
194 """Find an object in the available namespaces.
195
195
196 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
196 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
197
197
198 Has special code to detect magic functions.
198 Has special code to detect magic functions.
199 """
199 """
200
200
201 oname = oname.strip()
201 oname = oname.strip()
202
202
203 alias_ns = None
203 alias_ns = None
204 if namespaces is None:
204 if namespaces is None:
205 # Namespaces to search in:
205 # Namespaces to search in:
206 # Put them in a list. The order is important so that we
206 # Put them in a list. The order is important so that we
207 # find things in the same order that Python finds them.
207 # find things in the same order that Python finds them.
208 namespaces = [ ('Interactive', self.shell.user_ns),
208 namespaces = [ ('Interactive', self.shell.user_ns),
209 ('IPython internal', self.shell.internal_ns),
209 ('IPython internal', self.shell.internal_ns),
210 ('Python builtin', __builtin__.__dict__),
210 ('Python builtin', __builtin__.__dict__),
211 ('Alias', self.shell.alias_table),
211 ('Alias', self.shell.alias_table),
212 ]
212 ]
213 alias_ns = self.shell.alias_table
213 alias_ns = self.shell.alias_table
214
214
215 # initialize results to 'null'
215 # initialize results to 'null'
216 found = 0; obj = None; ospace = None; ds = None;
216 found = 0; obj = None; ospace = None; ds = None;
217 ismagic = 0; isalias = 0; parent = None
217 ismagic = 0; isalias = 0; parent = None
218
218
219 # Look for the given name by splitting it in parts. If the head is
219 # Look for the given name by splitting it in parts. If the head is
220 # found, then we look for all the remaining parts as members, and only
220 # found, then we look for all the remaining parts as members, and only
221 # declare success if we can find them all.
221 # declare success if we can find them all.
222 oname_parts = oname.split('.')
222 oname_parts = oname.split('.')
223 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
223 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
224 for nsname,ns in namespaces:
224 for nsname,ns in namespaces:
225 try:
225 try:
226 obj = ns[oname_head]
226 obj = ns[oname_head]
227 except KeyError:
227 except KeyError:
228 continue
228 continue
229 else:
229 else:
230 #print 'oname_rest:', oname_rest # dbg
230 #print 'oname_rest:', oname_rest # dbg
231 for part in oname_rest:
231 for part in oname_rest:
232 try:
232 try:
233 parent = obj
233 parent = obj
234 obj = getattr(obj,part)
234 obj = getattr(obj,part)
235 except:
235 except:
236 # Blanket except b/c some badly implemented objects
236 # Blanket except b/c some badly implemented objects
237 # allow __getattr__ to raise exceptions other than
237 # allow __getattr__ to raise exceptions other than
238 # AttributeError, which then crashes IPython.
238 # AttributeError, which then crashes IPython.
239 break
239 break
240 else:
240 else:
241 # If we finish the for loop (no break), we got all members
241 # If we finish the for loop (no break), we got all members
242 found = 1
242 found = 1
243 ospace = nsname
243 ospace = nsname
244 if ns == alias_ns:
244 if ns == alias_ns:
245 isalias = 1
245 isalias = 1
246 break # namespace loop
246 break # namespace loop
247
247
248 # Try to see if it's magic
248 # Try to see if it's magic
249 if not found:
249 if not found:
250 if oname.startswith(self.shell.ESC_MAGIC):
250 if oname.startswith(self.shell.ESC_MAGIC):
251 oname = oname[1:]
251 oname = oname[1:]
252 obj = getattr(self,'magic_'+oname,None)
252 obj = getattr(self,'magic_'+oname,None)
253 if obj is not None:
253 if obj is not None:
254 found = 1
254 found = 1
255 ospace = 'IPython internal'
255 ospace = 'IPython internal'
256 ismagic = 1
256 ismagic = 1
257
257
258 # Last try: special-case some literals like '', [], {}, etc:
258 # Last try: special-case some literals like '', [], {}, etc:
259 if not found and oname_head in ["''",'""','[]','{}','()']:
259 if not found and oname_head in ["''",'""','[]','{}','()']:
260 obj = eval(oname_head)
260 obj = eval(oname_head)
261 found = 1
261 found = 1
262 ospace = 'Interactive'
262 ospace = 'Interactive'
263
263
264 return {'found':found, 'obj':obj, 'namespace':ospace,
264 return {'found':found, 'obj':obj, 'namespace':ospace,
265 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
265 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
266
266
267 def arg_err(self,func):
267 def arg_err(self,func):
268 """Print docstring if incorrect arguments were passed"""
268 """Print docstring if incorrect arguments were passed"""
269 print 'Error in arguments:'
269 print 'Error in arguments:'
270 print OInspect.getdoc(func)
270 print OInspect.getdoc(func)
271
271
272 def format_latex(self,strng):
272 def format_latex(self,strng):
273 """Format a string for latex inclusion."""
273 """Format a string for latex inclusion."""
274
274
275 # Characters that need to be escaped for latex:
275 # Characters that need to be escaped for latex:
276 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
276 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
277 # Magic command names as headers:
277 # Magic command names as headers:
278 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
278 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
279 re.MULTILINE)
279 re.MULTILINE)
280 # Magic commands
280 # Magic commands
281 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
281 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
282 re.MULTILINE)
282 re.MULTILINE)
283 # Paragraph continue
283 # Paragraph continue
284 par_re = re.compile(r'\\$',re.MULTILINE)
284 par_re = re.compile(r'\\$',re.MULTILINE)
285
285
286 # The "\n" symbol
286 # The "\n" symbol
287 newline_re = re.compile(r'\\n')
287 newline_re = re.compile(r'\\n')
288
288
289 # Now build the string for output:
289 # Now build the string for output:
290 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
290 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
291 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
291 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
292 strng)
292 strng)
293 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
293 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
294 strng = par_re.sub(r'\\\\',strng)
294 strng = par_re.sub(r'\\\\',strng)
295 strng = escape_re.sub(r'\\\1',strng)
295 strng = escape_re.sub(r'\\\1',strng)
296 strng = newline_re.sub(r'\\textbackslash{}n',strng)
296 strng = newline_re.sub(r'\\textbackslash{}n',strng)
297 return strng
297 return strng
298
298
299 def format_screen(self,strng):
299 def format_screen(self,strng):
300 """Format a string for screen printing.
300 """Format a string for screen printing.
301
301
302 This removes some latex-type format codes."""
302 This removes some latex-type format codes."""
303 # Paragraph continue
303 # Paragraph continue
304 par_re = re.compile(r'\\$',re.MULTILINE)
304 par_re = re.compile(r'\\$',re.MULTILINE)
305 strng = par_re.sub('',strng)
305 strng = par_re.sub('',strng)
306 return strng
306 return strng
307
307
308 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
308 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
309 """Parse options passed to an argument string.
309 """Parse options passed to an argument string.
310
310
311 The interface is similar to that of getopt(), but it returns back a
311 The interface is similar to that of getopt(), but it returns back a
312 Struct with the options as keys and the stripped argument string still
312 Struct with the options as keys and the stripped argument string still
313 as a string.
313 as a string.
314
314
315 arg_str is quoted as a true sys.argv vector by using shlex.split.
315 arg_str is quoted as a true sys.argv vector by using shlex.split.
316 This allows us to easily expand variables, glob files, quote
316 This allows us to easily expand variables, glob files, quote
317 arguments, etc.
317 arguments, etc.
318
318
319 Options:
319 Options:
320 -mode: default 'string'. If given as 'list', the argument string is
320 -mode: default 'string'. If given as 'list', the argument string is
321 returned as a list (split on whitespace) instead of a string.
321 returned as a list (split on whitespace) instead of a string.
322
322
323 -list_all: put all option values in lists. Normally only options
323 -list_all: put all option values in lists. Normally only options
324 appearing more than once are put in a list.
324 appearing more than once are put in a list.
325
325
326 -posix (True): whether to split the input line in POSIX mode or not,
326 -posix (True): whether to split the input line in POSIX mode or not,
327 as per the conventions outlined in the shlex module from the
327 as per the conventions outlined in the shlex module from the
328 standard library."""
328 standard library."""
329
329
330 # inject default options at the beginning of the input line
330 # inject default options at the beginning of the input line
331 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
331 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
332 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
332 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
333
333
334 mode = kw.get('mode','string')
334 mode = kw.get('mode','string')
335 if mode not in ['string','list']:
335 if mode not in ['string','list']:
336 raise ValueError,'incorrect mode given: %s' % mode
336 raise ValueError,'incorrect mode given: %s' % mode
337 # Get options
337 # Get options
338 list_all = kw.get('list_all',0)
338 list_all = kw.get('list_all',0)
339 posix = kw.get('posix',True)
339 posix = kw.get('posix',True)
340
340
341 # Check if we have more than one argument to warrant extra processing:
341 # Check if we have more than one argument to warrant extra processing:
342 odict = {} # Dictionary with options
342 odict = {} # Dictionary with options
343 args = arg_str.split()
343 args = arg_str.split()
344 if len(args) >= 1:
344 if len(args) >= 1:
345 # If the list of inputs only has 0 or 1 thing in it, there's no
345 # If the list of inputs only has 0 or 1 thing in it, there's no
346 # need to look for options
346 # need to look for options
347 argv = arg_split(arg_str,posix)
347 argv = arg_split(arg_str,posix)
348 # Do regular option processing
348 # Do regular option processing
349 try:
349 try:
350 opts,args = getopt(argv,opt_str,*long_opts)
350 opts,args = getopt(argv,opt_str,*long_opts)
351 except GetoptError,e:
351 except GetoptError,e:
352 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
352 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
353 " ".join(long_opts)))
353 " ".join(long_opts)))
354 for o,a in opts:
354 for o,a in opts:
355 if o.startswith('--'):
355 if o.startswith('--'):
356 o = o[2:]
356 o = o[2:]
357 else:
357 else:
358 o = o[1:]
358 o = o[1:]
359 try:
359 try:
360 odict[o].append(a)
360 odict[o].append(a)
361 except AttributeError:
361 except AttributeError:
362 odict[o] = [odict[o],a]
362 odict[o] = [odict[o],a]
363 except KeyError:
363 except KeyError:
364 if list_all:
364 if list_all:
365 odict[o] = [a]
365 odict[o] = [a]
366 else:
366 else:
367 odict[o] = a
367 odict[o] = a
368
368
369 # Prepare opts,args for return
369 # Prepare opts,args for return
370 opts = Struct(odict)
370 opts = Struct(odict)
371 if mode == 'string':
371 if mode == 'string':
372 args = ' '.join(args)
372 args = ' '.join(args)
373
373
374 return opts,args
374 return opts,args
375
375
376 #......................................................................
376 #......................................................................
377 # And now the actual magic functions
377 # And now the actual magic functions
378
378
379 # Functions for IPython shell work (vars,funcs, config, etc)
379 # Functions for IPython shell work (vars,funcs, config, etc)
380 def magic_lsmagic(self, parameter_s = ''):
380 def magic_lsmagic(self, parameter_s = ''):
381 """List currently available magic functions."""
381 """List currently available magic functions."""
382 mesc = self.shell.ESC_MAGIC
382 mesc = self.shell.ESC_MAGIC
383 print 'Available magic functions:\n'+mesc+\
383 print 'Available magic functions:\n'+mesc+\
384 (' '+mesc).join(self.lsmagic())
384 (' '+mesc).join(self.lsmagic())
385 print '\n' + Magic.auto_status[self.shell.rc.automagic]
385 print '\n' + Magic.auto_status[self.shell.rc.automagic]
386 return None
386 return None
387
387
388 def magic_magic(self, parameter_s = ''):
388 def magic_magic(self, parameter_s = ''):
389 """Print information about the magic function system."""
389 """Print information about the magic function system."""
390
390
391 mode = ''
391 mode = ''
392 try:
392 try:
393 if parameter_s.split()[0] == '-latex':
393 if parameter_s.split()[0] == '-latex':
394 mode = 'latex'
394 mode = 'latex'
395 if parameter_s.split()[0] == '-brief':
395 if parameter_s.split()[0] == '-brief':
396 mode = 'brief'
396 mode = 'brief'
397 except:
397 except:
398 pass
398 pass
399
399
400 magic_docs = []
400 magic_docs = []
401 for fname in self.lsmagic():
401 for fname in self.lsmagic():
402 mname = 'magic_' + fname
402 mname = 'magic_' + fname
403 for space in (Magic,self,self.__class__):
403 for space in (Magic,self,self.__class__):
404 try:
404 try:
405 fn = space.__dict__[mname]
405 fn = space.__dict__[mname]
406 except KeyError:
406 except KeyError:
407 pass
407 pass
408 else:
408 else:
409 break
409 break
410 if mode == 'brief':
410 if mode == 'brief':
411 # only first line
411 # only first line
412 fndoc = fn.__doc__.split('\n',1)[0]
412 fndoc = fn.__doc__.split('\n',1)[0]
413 else:
413 else:
414 fndoc = fn.__doc__
414 fndoc = fn.__doc__
415
415
416 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
416 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
417 fname,fndoc))
417 fname,fndoc))
418 magic_docs = ''.join(magic_docs)
418 magic_docs = ''.join(magic_docs)
419
419
420 if mode == 'latex':
420 if mode == 'latex':
421 print self.format_latex(magic_docs)
421 print self.format_latex(magic_docs)
422 return
422 return
423 else:
423 else:
424 magic_docs = self.format_screen(magic_docs)
424 magic_docs = self.format_screen(magic_docs)
425 if mode == 'brief':
425 if mode == 'brief':
426 return magic_docs
426 return magic_docs
427
427
428 outmsg = """
428 outmsg = """
429 IPython's 'magic' functions
429 IPython's 'magic' functions
430 ===========================
430 ===========================
431
431
432 The magic function system provides a series of functions which allow you to
432 The magic function system provides a series of functions which allow you to
433 control the behavior of IPython itself, plus a lot of system-type
433 control the behavior of IPython itself, plus a lot of system-type
434 features. All these functions are prefixed with a % character, but parameters
434 features. All these functions are prefixed with a % character, but parameters
435 are given without parentheses or quotes.
435 are given without parentheses or quotes.
436
436
437 NOTE: If you have 'automagic' enabled (via the command line option or with the
437 NOTE: If you have 'automagic' enabled (via the command line option or with the
438 %automagic function), you don't need to type in the % explicitly. By default,
438 %automagic function), you don't need to type in the % explicitly. By default,
439 IPython ships with automagic on, so you should only rarely need the % escape.
439 IPython ships with automagic on, so you should only rarely need the % escape.
440
440
441 Example: typing '%cd mydir' (without the quotes) changes you working directory
441 Example: typing '%cd mydir' (without the quotes) changes you working directory
442 to 'mydir', if it exists.
442 to 'mydir', if it exists.
443
443
444 You can define your own magic functions to extend the system. See the supplied
444 You can define your own magic functions to extend the system. See the supplied
445 ipythonrc and example-magic.py files for details (in your ipython
445 ipythonrc and example-magic.py files for details (in your ipython
446 configuration directory, typically $HOME/.ipython/).
446 configuration directory, typically $HOME/.ipython/).
447
447
448 You can also define your own aliased names for magic functions. In your
448 You can also define your own aliased names for magic functions. In your
449 ipythonrc file, placing a line like:
449 ipythonrc file, placing a line like:
450
450
451 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
451 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
452
452
453 will define %pf as a new name for %profile.
453 will define %pf as a new name for %profile.
454
454
455 You can also call magics in code using the ipmagic() function, which IPython
455 You can also call magics in code using the ipmagic() function, which IPython
456 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
456 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
457
457
458 For a list of the available magic functions, use %lsmagic. For a description
458 For a list of the available magic functions, use %lsmagic. For a description
459 of any of them, type %magic_name?, e.g. '%cd?'.
459 of any of them, type %magic_name?, e.g. '%cd?'.
460
460
461 Currently the magic system has the following functions:\n"""
461 Currently the magic system has the following functions:\n"""
462
462
463 mesc = self.shell.ESC_MAGIC
463 mesc = self.shell.ESC_MAGIC
464 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
464 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
465 "\n\n%s%s\n\n%s" % (outmsg,
465 "\n\n%s%s\n\n%s" % (outmsg,
466 magic_docs,mesc,mesc,
466 magic_docs,mesc,mesc,
467 (' '+mesc).join(self.lsmagic()),
467 (' '+mesc).join(self.lsmagic()),
468 Magic.auto_status[self.shell.rc.automagic] ) )
468 Magic.auto_status[self.shell.rc.automagic] ) )
469
469
470 page(outmsg,screen_lines=self.shell.rc.screen_length)
470 page(outmsg,screen_lines=self.shell.rc.screen_length)
471
471
472
472
473 def magic_autoindent(self, parameter_s = ''):
473 def magic_autoindent(self, parameter_s = ''):
474 """Toggle autoindent on/off (if available)."""
474 """Toggle autoindent on/off (if available)."""
475
475
476 self.shell.set_autoindent()
476 self.shell.set_autoindent()
477 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
477 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
478
478
479 def magic_system_verbose(self, parameter_s = ''):
479 def magic_system_verbose(self, parameter_s = ''):
480 """Set verbose printing of system calls.
480 """Set verbose printing of system calls.
481
481
482 If called without an argument, act as a toggle"""
482 If called without an argument, act as a toggle"""
483
483
484 if parameter_s:
484 if parameter_s:
485 val = bool(eval(parameter_s))
485 val = bool(eval(parameter_s))
486 else:
486 else:
487 val = None
487 val = None
488
488
489 self.shell.rc_set_toggle('system_verbose',val)
489 self.shell.rc_set_toggle('system_verbose',val)
490 print "System verbose printing is:",\
490 print "System verbose printing is:",\
491 ['OFF','ON'][self.shell.rc.system_verbose]
491 ['OFF','ON'][self.shell.rc.system_verbose]
492
492
493
493
494 def magic_page(self, parameter_s=''):
494 def magic_page(self, parameter_s=''):
495 """Pretty print the object and display it through a pager.
495 """Pretty print the object and display it through a pager.
496
496
497 %page [options] OBJECT
497 %page [options] OBJECT
498
498
499 If no object is given, use _ (last output).
499 If no object is given, use _ (last output).
500
500
501 Options:
501 Options:
502
502
503 -r: page str(object), don't pretty-print it."""
503 -r: page str(object), don't pretty-print it."""
504
504
505 # After a function contributed by Olivier Aubert, slightly modified.
505 # After a function contributed by Olivier Aubert, slightly modified.
506
506
507 # Process options/args
507 # Process options/args
508 opts,args = self.parse_options(parameter_s,'r')
508 opts,args = self.parse_options(parameter_s,'r')
509 raw = 'r' in opts
509 raw = 'r' in opts
510
510
511 oname = args and args or '_'
511 oname = args and args or '_'
512 info = self._ofind(oname)
512 info = self._ofind(oname)
513 if info['found']:
513 if info['found']:
514 txt = (raw and str or pformat)( info['obj'] )
514 txt = (raw and str or pformat)( info['obj'] )
515 page(txt)
515 page(txt)
516 else:
516 else:
517 print 'Object `%s` not found' % oname
517 print 'Object `%s` not found' % oname
518
518
519 def magic_profile(self, parameter_s=''):
519 def magic_profile(self, parameter_s=''):
520 """Print your currently active IPyhton profile."""
520 """Print your currently active IPyhton profile."""
521 if self.shell.rc.profile:
521 if self.shell.rc.profile:
522 printpl('Current IPython profile: $self.shell.rc.profile.')
522 printpl('Current IPython profile: $self.shell.rc.profile.')
523 else:
523 else:
524 print 'No profile active.'
524 print 'No profile active.'
525
525
526 def magic_pinfo(self, parameter_s='', namespaces=None):
526 def magic_pinfo(self, parameter_s='', namespaces=None):
527 """Provide detailed information about an object.
527 """Provide detailed information about an object.
528
528
529 '%pinfo object' is just a synonym for object? or ?object."""
529 '%pinfo object' is just a synonym for object? or ?object."""
530
530
531 #print 'pinfo par: <%s>' % parameter_s # dbg
531 #print 'pinfo par: <%s>' % parameter_s # dbg
532
532
533
533
534 # detail_level: 0 -> obj? , 1 -> obj??
534 # detail_level: 0 -> obj? , 1 -> obj??
535 detail_level = 0
535 detail_level = 0
536 # We need to detect if we got called as 'pinfo pinfo foo', which can
536 # We need to detect if we got called as 'pinfo pinfo foo', which can
537 # happen if the user types 'pinfo foo?' at the cmd line.
537 # happen if the user types 'pinfo foo?' at the cmd line.
538 pinfo,qmark1,oname,qmark2 = \
538 pinfo,qmark1,oname,qmark2 = \
539 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
539 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
540 if pinfo or qmark1 or qmark2:
540 if pinfo or qmark1 or qmark2:
541 detail_level = 1
541 detail_level = 1
542 if "*" in oname:
542 if "*" in oname:
543 self.magic_psearch(oname)
543 self.magic_psearch(oname)
544 else:
544 else:
545 self._inspect('pinfo', oname, detail_level=detail_level,
545 self._inspect('pinfo', oname, detail_level=detail_level,
546 namespaces=namespaces)
546 namespaces=namespaces)
547
547
548 def _inspect(self,meth,oname,namespaces=None,**kw):
548 def _inspect(self,meth,oname,namespaces=None,**kw):
549 """Generic interface to the inspector system.
549 """Generic interface to the inspector system.
550
550
551 This function is meant to be called by pdef, pdoc & friends."""
551 This function is meant to be called by pdef, pdoc & friends."""
552
552
553 #oname = oname.strip()
553 #oname = oname.strip()
554 #print '1- oname: <%r>' % oname # dbg
554 #print '1- oname: <%r>' % oname # dbg
555 try:
555 try:
556 oname = oname.strip().encode('ascii')
556 oname = oname.strip().encode('ascii')
557 #print '2- oname: <%r>' % oname # dbg
557 #print '2- oname: <%r>' % oname # dbg
558 except UnicodeEncodeError:
558 except UnicodeEncodeError:
559 print 'Python identifiers can only contain ascii characters.'
559 print 'Python identifiers can only contain ascii characters.'
560 return 'not found'
560 return 'not found'
561
561
562 info = Struct(self._ofind(oname, namespaces))
562 info = Struct(self._ofind(oname, namespaces))
563
563
564 if info.found:
564 if info.found:
565 try:
565 try:
566 IPython.generics.inspect_object(info.obj)
566 IPython.generics.inspect_object(info.obj)
567 return
567 return
568 except IPython.ipapi.TryNext:
568 except IPython.ipapi.TryNext:
569 pass
569 pass
570 # Get the docstring of the class property if it exists.
570 # Get the docstring of the class property if it exists.
571 path = oname.split('.')
571 path = oname.split('.')
572 root = '.'.join(path[:-1])
572 root = '.'.join(path[:-1])
573 if info.parent is not None:
573 if info.parent is not None:
574 try:
574 try:
575 target = getattr(info.parent, '__class__')
575 target = getattr(info.parent, '__class__')
576 # The object belongs to a class instance.
576 # The object belongs to a class instance.
577 try:
577 try:
578 target = getattr(target, path[-1])
578 target = getattr(target, path[-1])
579 # The class defines the object.
579 # The class defines the object.
580 if isinstance(target, property):
580 if isinstance(target, property):
581 oname = root + '.__class__.' + path[-1]
581 oname = root + '.__class__.' + path[-1]
582 info = Struct(self._ofind(oname))
582 info = Struct(self._ofind(oname))
583 except AttributeError: pass
583 except AttributeError: pass
584 except AttributeError: pass
584 except AttributeError: pass
585
585
586 pmethod = getattr(self.shell.inspector,meth)
586 pmethod = getattr(self.shell.inspector,meth)
587 formatter = info.ismagic and self.format_screen or None
587 formatter = info.ismagic and self.format_screen or None
588 if meth == 'pdoc':
588 if meth == 'pdoc':
589 pmethod(info.obj,oname,formatter)
589 pmethod(info.obj,oname,formatter)
590 elif meth == 'pinfo':
590 elif meth == 'pinfo':
591 pmethod(info.obj,oname,formatter,info,**kw)
591 pmethod(info.obj,oname,formatter,info,**kw)
592 else:
592 else:
593 pmethod(info.obj,oname)
593 pmethod(info.obj,oname)
594 else:
594 else:
595 print 'Object `%s` not found.' % oname
595 print 'Object `%s` not found.' % oname
596 return 'not found' # so callers can take other action
596 return 'not found' # so callers can take other action
597
597
598 def magic_psearch(self, parameter_s=''):
598 def magic_psearch(self, parameter_s=''):
599 """Search for object in namespaces by wildcard.
599 """Search for object in namespaces by wildcard.
600
600
601 %psearch [options] PATTERN [OBJECT TYPE]
601 %psearch [options] PATTERN [OBJECT TYPE]
602
602
603 Note: ? can be used as a synonym for %psearch, at the beginning or at
603 Note: ? can be used as a synonym for %psearch, at the beginning or at
604 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
604 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
605 rest of the command line must be unchanged (options come first), so
605 rest of the command line must be unchanged (options come first), so
606 for example the following forms are equivalent
606 for example the following forms are equivalent
607
607
608 %psearch -i a* function
608 %psearch -i a* function
609 -i a* function?
609 -i a* function?
610 ?-i a* function
610 ?-i a* function
611
611
612 Arguments:
612 Arguments:
613
613
614 PATTERN
614 PATTERN
615
615
616 where PATTERN is a string containing * as a wildcard similar to its
616 where PATTERN is a string containing * as a wildcard similar to its
617 use in a shell. The pattern is matched in all namespaces on the
617 use in a shell. The pattern is matched in all namespaces on the
618 search path. By default objects starting with a single _ are not
618 search path. By default objects starting with a single _ are not
619 matched, many IPython generated objects have a single
619 matched, many IPython generated objects have a single
620 underscore. The default is case insensitive matching. Matching is
620 underscore. The default is case insensitive matching. Matching is
621 also done on the attributes of objects and not only on the objects
621 also done on the attributes of objects and not only on the objects
622 in a module.
622 in a module.
623
623
624 [OBJECT TYPE]
624 [OBJECT TYPE]
625
625
626 Is the name of a python type from the types module. The name is
626 Is the name of a python type from the types module. The name is
627 given in lowercase without the ending type, ex. StringType is
627 given in lowercase without the ending type, ex. StringType is
628 written string. By adding a type here only objects matching the
628 written string. By adding a type here only objects matching the
629 given type are matched. Using all here makes the pattern match all
629 given type are matched. Using all here makes the pattern match all
630 types (this is the default).
630 types (this is the default).
631
631
632 Options:
632 Options:
633
633
634 -a: makes the pattern match even objects whose names start with a
634 -a: makes the pattern match even objects whose names start with a
635 single underscore. These names are normally ommitted from the
635 single underscore. These names are normally ommitted from the
636 search.
636 search.
637
637
638 -i/-c: make the pattern case insensitive/sensitive. If neither of
638 -i/-c: make the pattern case insensitive/sensitive. If neither of
639 these options is given, the default is read from your ipythonrc
639 these options is given, the default is read from your ipythonrc
640 file. The option name which sets this value is
640 file. The option name which sets this value is
641 'wildcards_case_sensitive'. If this option is not specified in your
641 'wildcards_case_sensitive'. If this option is not specified in your
642 ipythonrc file, IPython's internal default is to do a case sensitive
642 ipythonrc file, IPython's internal default is to do a case sensitive
643 search.
643 search.
644
644
645 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
645 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
646 specifiy can be searched in any of the following namespaces:
646 specifiy can be searched in any of the following namespaces:
647 'builtin', 'user', 'user_global','internal', 'alias', where
647 'builtin', 'user', 'user_global','internal', 'alias', where
648 'builtin' and 'user' are the search defaults. Note that you should
648 'builtin' and 'user' are the search defaults. Note that you should
649 not use quotes when specifying namespaces.
649 not use quotes when specifying namespaces.
650
650
651 'Builtin' contains the python module builtin, 'user' contains all
651 'Builtin' contains the python module builtin, 'user' contains all
652 user data, 'alias' only contain the shell aliases and no python
652 user data, 'alias' only contain the shell aliases and no python
653 objects, 'internal' contains objects used by IPython. The
653 objects, 'internal' contains objects used by IPython. The
654 'user_global' namespace is only used by embedded IPython instances,
654 'user_global' namespace is only used by embedded IPython instances,
655 and it contains module-level globals. You can add namespaces to the
655 and it contains module-level globals. You can add namespaces to the
656 search with -s or exclude them with -e (these options can be given
656 search with -s or exclude them with -e (these options can be given
657 more than once).
657 more than once).
658
658
659 Examples:
659 Examples:
660
660
661 %psearch a* -> objects beginning with an a
661 %psearch a* -> objects beginning with an a
662 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
662 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
663 %psearch a* function -> all functions beginning with an a
663 %psearch a* function -> all functions beginning with an a
664 %psearch re.e* -> objects beginning with an e in module re
664 %psearch re.e* -> objects beginning with an e in module re
665 %psearch r*.e* -> objects that start with e in modules starting in r
665 %psearch r*.e* -> objects that start with e in modules starting in r
666 %psearch r*.* string -> all strings in modules beginning with r
666 %psearch r*.* string -> all strings in modules beginning with r
667
667
668 Case sensitve search:
668 Case sensitve search:
669
669
670 %psearch -c a* list all object beginning with lower case a
670 %psearch -c a* list all object beginning with lower case a
671
671
672 Show objects beginning with a single _:
672 Show objects beginning with a single _:
673
673
674 %psearch -a _* list objects beginning with a single underscore"""
674 %psearch -a _* list objects beginning with a single underscore"""
675 try:
675 try:
676 parameter_s = parameter_s.encode('ascii')
676 parameter_s = parameter_s.encode('ascii')
677 except UnicodeEncodeError:
677 except UnicodeEncodeError:
678 print 'Python identifiers can only contain ascii characters.'
678 print 'Python identifiers can only contain ascii characters.'
679 return
679 return
680
680
681 # default namespaces to be searched
681 # default namespaces to be searched
682 def_search = ['user','builtin']
682 def_search = ['user','builtin']
683
683
684 # Process options/args
684 # Process options/args
685 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
685 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
686 opt = opts.get
686 opt = opts.get
687 shell = self.shell
687 shell = self.shell
688 psearch = shell.inspector.psearch
688 psearch = shell.inspector.psearch
689
689
690 # select case options
690 # select case options
691 if opts.has_key('i'):
691 if opts.has_key('i'):
692 ignore_case = True
692 ignore_case = True
693 elif opts.has_key('c'):
693 elif opts.has_key('c'):
694 ignore_case = False
694 ignore_case = False
695 else:
695 else:
696 ignore_case = not shell.rc.wildcards_case_sensitive
696 ignore_case = not shell.rc.wildcards_case_sensitive
697
697
698 # Build list of namespaces to search from user options
698 # Build list of namespaces to search from user options
699 def_search.extend(opt('s',[]))
699 def_search.extend(opt('s',[]))
700 ns_exclude = ns_exclude=opt('e',[])
700 ns_exclude = ns_exclude=opt('e',[])
701 ns_search = [nm for nm in def_search if nm not in ns_exclude]
701 ns_search = [nm for nm in def_search if nm not in ns_exclude]
702
702
703 # Call the actual search
703 # Call the actual search
704 try:
704 try:
705 psearch(args,shell.ns_table,ns_search,
705 psearch(args,shell.ns_table,ns_search,
706 show_all=opt('a'),ignore_case=ignore_case)
706 show_all=opt('a'),ignore_case=ignore_case)
707 except:
707 except:
708 shell.showtraceback()
708 shell.showtraceback()
709
709
710 def magic_who_ls(self, parameter_s=''):
710 def magic_who_ls(self, parameter_s=''):
711 """Return a sorted list of all interactive variables.
711 """Return a sorted list of all interactive variables.
712
712
713 If arguments are given, only variables of types matching these
713 If arguments are given, only variables of types matching these
714 arguments are returned."""
714 arguments are returned."""
715
715
716 user_ns = self.shell.user_ns
716 user_ns = self.shell.user_ns
717 internal_ns = self.shell.internal_ns
717 internal_ns = self.shell.internal_ns
718 user_config_ns = self.shell.user_config_ns
718 user_config_ns = self.shell.user_config_ns
719 out = []
719 out = []
720 typelist = parameter_s.split()
720 typelist = parameter_s.split()
721
721
722 for i in user_ns:
722 for i in user_ns:
723 if not (i.startswith('_') or i.startswith('_i')) \
723 if not (i.startswith('_') or i.startswith('_i')) \
724 and not (i in internal_ns or i in user_config_ns):
724 and not (i in internal_ns or i in user_config_ns):
725 if typelist:
725 if typelist:
726 if type(user_ns[i]).__name__ in typelist:
726 if type(user_ns[i]).__name__ in typelist:
727 out.append(i)
727 out.append(i)
728 else:
728 else:
729 out.append(i)
729 out.append(i)
730 out.sort()
730 out.sort()
731 return out
731 return out
732
732
733 def magic_who(self, parameter_s=''):
733 def magic_who(self, parameter_s=''):
734 """Print all interactive variables, with some minimal formatting.
734 """Print all interactive variables, with some minimal formatting.
735
735
736 If any arguments are given, only variables whose type matches one of
736 If any arguments are given, only variables whose type matches one of
737 these are printed. For example:
737 these are printed. For example:
738
738
739 %who function str
739 %who function str
740
740
741 will only list functions and strings, excluding all other types of
741 will only list functions and strings, excluding all other types of
742 variables. To find the proper type names, simply use type(var) at a
742 variables. To find the proper type names, simply use type(var) at a
743 command line to see how python prints type names. For example:
743 command line to see how python prints type names. For example:
744
744
745 In [1]: type('hello')\\
745 In [1]: type('hello')\\
746 Out[1]: <type 'str'>
746 Out[1]: <type 'str'>
747
747
748 indicates that the type name for strings is 'str'.
748 indicates that the type name for strings is 'str'.
749
749
750 %who always excludes executed names loaded through your configuration
750 %who always excludes executed names loaded through your configuration
751 file and things which are internal to IPython.
751 file and things which are internal to IPython.
752
752
753 This is deliberate, as typically you may load many modules and the
753 This is deliberate, as typically you may load many modules and the
754 purpose of %who is to show you only what you've manually defined."""
754 purpose of %who is to show you only what you've manually defined."""
755
755
756 varlist = self.magic_who_ls(parameter_s)
756 varlist = self.magic_who_ls(parameter_s)
757 if not varlist:
757 if not varlist:
758 if parameter_s:
758 if parameter_s:
759 print 'No variables match your requested type.'
759 print 'No variables match your requested type.'
760 else:
760 else:
761 print 'Interactive namespace is empty.'
761 print 'Interactive namespace is empty.'
762 return
762 return
763
763
764 # if we have variables, move on...
764 # if we have variables, move on...
765 count = 0
765 count = 0
766 for i in varlist:
766 for i in varlist:
767 print i+'\t',
767 print i+'\t',
768 count += 1
768 count += 1
769 if count > 8:
769 if count > 8:
770 count = 0
770 count = 0
771 print
771 print
772 print
772 print
773
773
774 def magic_whos(self, parameter_s=''):
774 def magic_whos(self, parameter_s=''):
775 """Like %who, but gives some extra information about each variable.
775 """Like %who, but gives some extra information about each variable.
776
776
777 The same type filtering of %who can be applied here.
777 The same type filtering of %who can be applied here.
778
778
779 For all variables, the type is printed. Additionally it prints:
779 For all variables, the type is printed. Additionally it prints:
780
780
781 - For {},[],(): their length.
781 - For {},[],(): their length.
782
782
783 - For numpy and Numeric arrays, a summary with shape, number of
783 - For numpy and Numeric arrays, a summary with shape, number of
784 elements, typecode and size in memory.
784 elements, typecode and size in memory.
785
785
786 - Everything else: a string representation, snipping their middle if
786 - Everything else: a string representation, snipping their middle if
787 too long."""
787 too long."""
788
788
789 varnames = self.magic_who_ls(parameter_s)
789 varnames = self.magic_who_ls(parameter_s)
790 if not varnames:
790 if not varnames:
791 if parameter_s:
791 if parameter_s:
792 print 'No variables match your requested type.'
792 print 'No variables match your requested type.'
793 else:
793 else:
794 print 'Interactive namespace is empty.'
794 print 'Interactive namespace is empty.'
795 return
795 return
796
796
797 # if we have variables, move on...
797 # if we have variables, move on...
798
798
799 # for these types, show len() instead of data:
799 # for these types, show len() instead of data:
800 seq_types = [types.DictType,types.ListType,types.TupleType]
800 seq_types = [types.DictType,types.ListType,types.TupleType]
801
801
802 # for numpy/Numeric arrays, display summary info
802 # for numpy/Numeric arrays, display summary info
803 try:
803 try:
804 import numpy
804 import numpy
805 except ImportError:
805 except ImportError:
806 ndarray_type = None
806 ndarray_type = None
807 else:
807 else:
808 ndarray_type = numpy.ndarray.__name__
808 ndarray_type = numpy.ndarray.__name__
809 try:
809 try:
810 import Numeric
810 import Numeric
811 except ImportError:
811 except ImportError:
812 array_type = None
812 array_type = None
813 else:
813 else:
814 array_type = Numeric.ArrayType.__name__
814 array_type = Numeric.ArrayType.__name__
815
815
816 # Find all variable names and types so we can figure out column sizes
816 # Find all variable names and types so we can figure out column sizes
817 def get_vars(i):
817 def get_vars(i):
818 return self.shell.user_ns[i]
818 return self.shell.user_ns[i]
819
819
820 # some types are well known and can be shorter
820 # some types are well known and can be shorter
821 abbrevs = {'IPython.macro.Macro' : 'Macro'}
821 abbrevs = {'IPython.macro.Macro' : 'Macro'}
822 def type_name(v):
822 def type_name(v):
823 tn = type(v).__name__
823 tn = type(v).__name__
824 return abbrevs.get(tn,tn)
824 return abbrevs.get(tn,tn)
825
825
826 varlist = map(get_vars,varnames)
826 varlist = map(get_vars,varnames)
827
827
828 typelist = []
828 typelist = []
829 for vv in varlist:
829 for vv in varlist:
830 tt = type_name(vv)
830 tt = type_name(vv)
831
831
832 if tt=='instance':
832 if tt=='instance':
833 typelist.append( abbrevs.get(str(vv.__class__),
833 typelist.append( abbrevs.get(str(vv.__class__),
834 str(vv.__class__)))
834 str(vv.__class__)))
835 else:
835 else:
836 typelist.append(tt)
836 typelist.append(tt)
837
837
838 # column labels and # of spaces as separator
838 # column labels and # of spaces as separator
839 varlabel = 'Variable'
839 varlabel = 'Variable'
840 typelabel = 'Type'
840 typelabel = 'Type'
841 datalabel = 'Data/Info'
841 datalabel = 'Data/Info'
842 colsep = 3
842 colsep = 3
843 # variable format strings
843 # variable format strings
844 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
844 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
845 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
845 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
846 aformat = "%s: %s elems, type `%s`, %s bytes"
846 aformat = "%s: %s elems, type `%s`, %s bytes"
847 # find the size of the columns to format the output nicely
847 # find the size of the columns to format the output nicely
848 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
848 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
849 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
849 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
850 # table header
850 # table header
851 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
851 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
852 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
852 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
853 # and the table itself
853 # and the table itself
854 kb = 1024
854 kb = 1024
855 Mb = 1048576 # kb**2
855 Mb = 1048576 # kb**2
856 for vname,var,vtype in zip(varnames,varlist,typelist):
856 for vname,var,vtype in zip(varnames,varlist,typelist):
857 print itpl(vformat),
857 print itpl(vformat),
858 if vtype in seq_types:
858 if vtype in seq_types:
859 print len(var)
859 print len(var)
860 elif vtype in [array_type,ndarray_type]:
860 elif vtype in [array_type,ndarray_type]:
861 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
861 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
862 if vtype==ndarray_type:
862 if vtype==ndarray_type:
863 # numpy
863 # numpy
864 vsize = var.size
864 vsize = var.size
865 vbytes = vsize*var.itemsize
865 vbytes = vsize*var.itemsize
866 vdtype = var.dtype
866 vdtype = var.dtype
867 else:
867 else:
868 # Numeric
868 # Numeric
869 vsize = Numeric.size(var)
869 vsize = Numeric.size(var)
870 vbytes = vsize*var.itemsize()
870 vbytes = vsize*var.itemsize()
871 vdtype = var.typecode()
871 vdtype = var.typecode()
872
872
873 if vbytes < 100000:
873 if vbytes < 100000:
874 print aformat % (vshape,vsize,vdtype,vbytes)
874 print aformat % (vshape,vsize,vdtype,vbytes)
875 else:
875 else:
876 print aformat % (vshape,vsize,vdtype,vbytes),
876 print aformat % (vshape,vsize,vdtype,vbytes),
877 if vbytes < Mb:
877 if vbytes < Mb:
878 print '(%s kb)' % (vbytes/kb,)
878 print '(%s kb)' % (vbytes/kb,)
879 else:
879 else:
880 print '(%s Mb)' % (vbytes/Mb,)
880 print '(%s Mb)' % (vbytes/Mb,)
881 else:
881 else:
882 try:
882 try:
883 vstr = str(var)
883 vstr = str(var)
884 except UnicodeEncodeError:
884 except UnicodeEncodeError:
885 vstr = unicode(var).encode(sys.getdefaultencoding(),
885 vstr = unicode(var).encode(sys.getdefaultencoding(),
886 'backslashreplace')
886 'backslashreplace')
887 vstr = vstr.replace('\n','\\n')
887 vstr = vstr.replace('\n','\\n')
888 if len(vstr) < 50:
888 if len(vstr) < 50:
889 print vstr
889 print vstr
890 else:
890 else:
891 printpl(vfmt_short)
891 printpl(vfmt_short)
892
892
893 def magic_reset(self, parameter_s=''):
893 def magic_reset(self, parameter_s=''):
894 """Resets the namespace by removing all names defined by the user.
894 """Resets the namespace by removing all names defined by the user.
895
895
896 Input/Output history are left around in case you need them."""
896 Input/Output history are left around in case you need them."""
897
897
898 ans = self.shell.ask_yes_no(
898 ans = self.shell.ask_yes_no(
899 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
899 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
900 if not ans:
900 if not ans:
901 print 'Nothing done.'
901 print 'Nothing done.'
902 return
902 return
903 user_ns = self.shell.user_ns
903 user_ns = self.shell.user_ns
904 for i in self.magic_who_ls():
904 for i in self.magic_who_ls():
905 del(user_ns[i])
905 del(user_ns[i])
906
906
907 def magic_logstart(self,parameter_s=''):
907 def magic_logstart(self,parameter_s=''):
908 """Start logging anywhere in a session.
908 """Start logging anywhere in a session.
909
909
910 %logstart [-o|-r|-t] [log_name [log_mode]]
910 %logstart [-o|-r|-t] [log_name [log_mode]]
911
911
912 If no name is given, it defaults to a file named 'ipython_log.py' in your
912 If no name is given, it defaults to a file named 'ipython_log.py' in your
913 current directory, in 'rotate' mode (see below).
913 current directory, in 'rotate' mode (see below).
914
914
915 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
915 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
916 history up to that point and then continues logging.
916 history up to that point and then continues logging.
917
917
918 %logstart takes a second optional parameter: logging mode. This can be one
918 %logstart takes a second optional parameter: logging mode. This can be one
919 of (note that the modes are given unquoted):\\
919 of (note that the modes are given unquoted):\\
920 append: well, that says it.\\
920 append: well, that says it.\\
921 backup: rename (if exists) to name~ and start name.\\
921 backup: rename (if exists) to name~ and start name.\\
922 global: single logfile in your home dir, appended to.\\
922 global: single logfile in your home dir, appended to.\\
923 over : overwrite existing log.\\
923 over : overwrite existing log.\\
924 rotate: create rotating logs name.1~, name.2~, etc.
924 rotate: create rotating logs name.1~, name.2~, etc.
925
925
926 Options:
926 Options:
927
927
928 -o: log also IPython's output. In this mode, all commands which
928 -o: log also IPython's output. In this mode, all commands which
929 generate an Out[NN] prompt are recorded to the logfile, right after
929 generate an Out[NN] prompt are recorded to the logfile, right after
930 their corresponding input line. The output lines are always
930 their corresponding input line. The output lines are always
931 prepended with a '#[Out]# ' marker, so that the log remains valid
931 prepended with a '#[Out]# ' marker, so that the log remains valid
932 Python code.
932 Python code.
933
933
934 Since this marker is always the same, filtering only the output from
934 Since this marker is always the same, filtering only the output from
935 a log is very easy, using for example a simple awk call:
935 a log is very easy, using for example a simple awk call:
936
936
937 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
937 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
938
938
939 -r: log 'raw' input. Normally, IPython's logs contain the processed
939 -r: log 'raw' input. Normally, IPython's logs contain the processed
940 input, so that user lines are logged in their final form, converted
940 input, so that user lines are logged in their final form, converted
941 into valid Python. For example, %Exit is logged as
941 into valid Python. For example, %Exit is logged as
942 '_ip.magic("Exit"). If the -r flag is given, all input is logged
942 '_ip.magic("Exit"). If the -r flag is given, all input is logged
943 exactly as typed, with no transformations applied.
943 exactly as typed, with no transformations applied.
944
944
945 -t: put timestamps before each input line logged (these are put in
945 -t: put timestamps before each input line logged (these are put in
946 comments)."""
946 comments)."""
947
947
948 opts,par = self.parse_options(parameter_s,'ort')
948 opts,par = self.parse_options(parameter_s,'ort')
949 log_output = 'o' in opts
949 log_output = 'o' in opts
950 log_raw_input = 'r' in opts
950 log_raw_input = 'r' in opts
951 timestamp = 't' in opts
951 timestamp = 't' in opts
952
952
953 rc = self.shell.rc
953 rc = self.shell.rc
954 logger = self.shell.logger
954 logger = self.shell.logger
955
955
956 # if no args are given, the defaults set in the logger constructor by
956 # if no args are given, the defaults set in the logger constructor by
957 # ipytohn remain valid
957 # ipytohn remain valid
958 if par:
958 if par:
959 try:
959 try:
960 logfname,logmode = par.split()
960 logfname,logmode = par.split()
961 except:
961 except:
962 logfname = par
962 logfname = par
963 logmode = 'backup'
963 logmode = 'backup'
964 else:
964 else:
965 logfname = logger.logfname
965 logfname = logger.logfname
966 logmode = logger.logmode
966 logmode = logger.logmode
967 # put logfname into rc struct as if it had been called on the command
967 # put logfname into rc struct as if it had been called on the command
968 # line, so it ends up saved in the log header Save it in case we need
968 # line, so it ends up saved in the log header Save it in case we need
969 # to restore it...
969 # to restore it...
970 old_logfile = rc.opts.get('logfile','')
970 old_logfile = rc.opts.get('logfile','')
971 if logfname:
971 if logfname:
972 logfname = os.path.expanduser(logfname)
972 logfname = os.path.expanduser(logfname)
973 rc.opts.logfile = logfname
973 rc.opts.logfile = logfname
974 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
974 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
975 try:
975 try:
976 started = logger.logstart(logfname,loghead,logmode,
976 started = logger.logstart(logfname,loghead,logmode,
977 log_output,timestamp,log_raw_input)
977 log_output,timestamp,log_raw_input)
978 except:
978 except:
979 rc.opts.logfile = old_logfile
979 rc.opts.logfile = old_logfile
980 warn("Couldn't start log: %s" % sys.exc_info()[1])
980 warn("Couldn't start log: %s" % sys.exc_info()[1])
981 else:
981 else:
982 # log input history up to this point, optionally interleaving
982 # log input history up to this point, optionally interleaving
983 # output if requested
983 # output if requested
984
984
985 if timestamp:
985 if timestamp:
986 # disable timestamping for the previous history, since we've
986 # disable timestamping for the previous history, since we've
987 # lost those already (no time machine here).
987 # lost those already (no time machine here).
988 logger.timestamp = False
988 logger.timestamp = False
989
989
990 if log_raw_input:
990 if log_raw_input:
991 input_hist = self.shell.input_hist_raw
991 input_hist = self.shell.input_hist_raw
992 else:
992 else:
993 input_hist = self.shell.input_hist
993 input_hist = self.shell.input_hist
994
994
995 if log_output:
995 if log_output:
996 log_write = logger.log_write
996 log_write = logger.log_write
997 output_hist = self.shell.output_hist
997 output_hist = self.shell.output_hist
998 for n in range(1,len(input_hist)-1):
998 for n in range(1,len(input_hist)-1):
999 log_write(input_hist[n].rstrip())
999 log_write(input_hist[n].rstrip())
1000 if n in output_hist:
1000 if n in output_hist:
1001 log_write(repr(output_hist[n]),'output')
1001 log_write(repr(output_hist[n]),'output')
1002 else:
1002 else:
1003 logger.log_write(input_hist[1:])
1003 logger.log_write(input_hist[1:])
1004 if timestamp:
1004 if timestamp:
1005 # re-enable timestamping
1005 # re-enable timestamping
1006 logger.timestamp = True
1006 logger.timestamp = True
1007
1007
1008 print ('Activating auto-logging. '
1008 print ('Activating auto-logging. '
1009 'Current session state plus future input saved.')
1009 'Current session state plus future input saved.')
1010 logger.logstate()
1010 logger.logstate()
1011
1011
1012 def magic_logoff(self,parameter_s=''):
1012 def magic_logoff(self,parameter_s=''):
1013 """Temporarily stop logging.
1013 """Temporarily stop logging.
1014
1014
1015 You must have previously started logging."""
1015 You must have previously started logging."""
1016 self.shell.logger.switch_log(0)
1016 self.shell.logger.switch_log(0)
1017
1017
1018 def magic_logon(self,parameter_s=''):
1018 def magic_logon(self,parameter_s=''):
1019 """Restart logging.
1019 """Restart logging.
1020
1020
1021 This function is for restarting logging which you've temporarily
1021 This function is for restarting logging which you've temporarily
1022 stopped with %logoff. For starting logging for the first time, you
1022 stopped with %logoff. For starting logging for the first time, you
1023 must use the %logstart function, which allows you to specify an
1023 must use the %logstart function, which allows you to specify an
1024 optional log filename."""
1024 optional log filename."""
1025
1025
1026 self.shell.logger.switch_log(1)
1026 self.shell.logger.switch_log(1)
1027
1027
1028 def magic_logstate(self,parameter_s=''):
1028 def magic_logstate(self,parameter_s=''):
1029 """Print the status of the logging system."""
1029 """Print the status of the logging system."""
1030
1030
1031 self.shell.logger.logstate()
1031 self.shell.logger.logstate()
1032
1032
1033 def magic_pdb(self, parameter_s=''):
1033 def magic_pdb(self, parameter_s=''):
1034 """Control the automatic calling of the pdb interactive debugger.
1034 """Control the automatic calling of the pdb interactive debugger.
1035
1035
1036 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1036 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1037 argument it works as a toggle.
1037 argument it works as a toggle.
1038
1038
1039 When an exception is triggered, IPython can optionally call the
1039 When an exception is triggered, IPython can optionally call the
1040 interactive pdb debugger after the traceback printout. %pdb toggles
1040 interactive pdb debugger after the traceback printout. %pdb toggles
1041 this feature on and off.
1041 this feature on and off.
1042
1042
1043 The initial state of this feature is set in your ipythonrc
1043 The initial state of this feature is set in your ipythonrc
1044 configuration file (the variable is called 'pdb').
1044 configuration file (the variable is called 'pdb').
1045
1045
1046 If you want to just activate the debugger AFTER an exception has fired,
1046 If you want to just activate the debugger AFTER an exception has fired,
1047 without having to type '%pdb on' and rerunning your code, you can use
1047 without having to type '%pdb on' and rerunning your code, you can use
1048 the %debug magic."""
1048 the %debug magic."""
1049
1049
1050 par = parameter_s.strip().lower()
1050 par = parameter_s.strip().lower()
1051
1051
1052 if par:
1052 if par:
1053 try:
1053 try:
1054 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1054 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1055 except KeyError:
1055 except KeyError:
1056 print ('Incorrect argument. Use on/1, off/0, '
1056 print ('Incorrect argument. Use on/1, off/0, '
1057 'or nothing for a toggle.')
1057 'or nothing for a toggle.')
1058 return
1058 return
1059 else:
1059 else:
1060 # toggle
1060 # toggle
1061 new_pdb = not self.shell.call_pdb
1061 new_pdb = not self.shell.call_pdb
1062
1062
1063 # set on the shell
1063 # set on the shell
1064 self.shell.call_pdb = new_pdb
1064 self.shell.call_pdb = new_pdb
1065 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1065 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1066
1066
1067 def magic_debug(self, parameter_s=''):
1067 def magic_debug(self, parameter_s=''):
1068 """Activate the interactive debugger in post-mortem mode.
1068 """Activate the interactive debugger in post-mortem mode.
1069
1069
1070 If an exception has just occurred, this lets you inspect its stack
1070 If an exception has just occurred, this lets you inspect its stack
1071 frames interactively. Note that this will always work only on the last
1071 frames interactively. Note that this will always work only on the last
1072 traceback that occurred, so you must call this quickly after an
1072 traceback that occurred, so you must call this quickly after an
1073 exception that you wish to inspect has fired, because if another one
1073 exception that you wish to inspect has fired, because if another one
1074 occurs, it clobbers the previous one.
1074 occurs, it clobbers the previous one.
1075
1075
1076 If you want IPython to automatically do this on every exception, see
1076 If you want IPython to automatically do this on every exception, see
1077 the %pdb magic for more details.
1077 the %pdb magic for more details.
1078 """
1078 """
1079
1079
1080 self.shell.debugger(force=True)
1080 self.shell.debugger(force=True)
1081
1081
1082 def magic_prun(self, parameter_s ='',user_mode=1,
1082 def magic_prun(self, parameter_s ='',user_mode=1,
1083 opts=None,arg_lst=None,prog_ns=None):
1083 opts=None,arg_lst=None,prog_ns=None):
1084
1084
1085 """Run a statement through the python code profiler.
1085 """Run a statement through the python code profiler.
1086
1086
1087 Usage:\\
1087 Usage:\\
1088 %prun [options] statement
1088 %prun [options] statement
1089
1089
1090 The given statement (which doesn't require quote marks) is run via the
1090 The given statement (which doesn't require quote marks) is run via the
1091 python profiler in a manner similar to the profile.run() function.
1091 python profiler in a manner similar to the profile.run() function.
1092 Namespaces are internally managed to work correctly; profile.run
1092 Namespaces are internally managed to work correctly; profile.run
1093 cannot be used in IPython because it makes certain assumptions about
1093 cannot be used in IPython because it makes certain assumptions about
1094 namespaces which do not hold under IPython.
1094 namespaces which do not hold under IPython.
1095
1095
1096 Options:
1096 Options:
1097
1097
1098 -l <limit>: you can place restrictions on what or how much of the
1098 -l <limit>: you can place restrictions on what or how much of the
1099 profile gets printed. The limit value can be:
1099 profile gets printed. The limit value can be:
1100
1100
1101 * A string: only information for function names containing this string
1101 * A string: only information for function names containing this string
1102 is printed.
1102 is printed.
1103
1103
1104 * An integer: only these many lines are printed.
1104 * An integer: only these many lines are printed.
1105
1105
1106 * A float (between 0 and 1): this fraction of the report is printed
1106 * A float (between 0 and 1): this fraction of the report is printed
1107 (for example, use a limit of 0.4 to see the topmost 40% only).
1107 (for example, use a limit of 0.4 to see the topmost 40% only).
1108
1108
1109 You can combine several limits with repeated use of the option. For
1109 You can combine several limits with repeated use of the option. For
1110 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1110 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1111 information about class constructors.
1111 information about class constructors.
1112
1112
1113 -r: return the pstats.Stats object generated by the profiling. This
1113 -r: return the pstats.Stats object generated by the profiling. This
1114 object has all the information about the profile in it, and you can
1114 object has all the information about the profile in it, and you can
1115 later use it for further analysis or in other functions.
1115 later use it for further analysis or in other functions.
1116
1116
1117 -s <key>: sort profile by given key. You can provide more than one key
1117 -s <key>: sort profile by given key. You can provide more than one key
1118 by using the option several times: '-s key1 -s key2 -s key3...'. The
1118 by using the option several times: '-s key1 -s key2 -s key3...'. The
1119 default sorting key is 'time'.
1119 default sorting key is 'time'.
1120
1120
1121 The following is copied verbatim from the profile documentation
1121 The following is copied verbatim from the profile documentation
1122 referenced below:
1122 referenced below:
1123
1123
1124 When more than one key is provided, additional keys are used as
1124 When more than one key is provided, additional keys are used as
1125 secondary criteria when the there is equality in all keys selected
1125 secondary criteria when the there is equality in all keys selected
1126 before them.
1126 before them.
1127
1127
1128 Abbreviations can be used for any key names, as long as the
1128 Abbreviations can be used for any key names, as long as the
1129 abbreviation is unambiguous. The following are the keys currently
1129 abbreviation is unambiguous. The following are the keys currently
1130 defined:
1130 defined:
1131
1131
1132 Valid Arg Meaning\\
1132 Valid Arg Meaning\\
1133 "calls" call count\\
1133 "calls" call count\\
1134 "cumulative" cumulative time\\
1134 "cumulative" cumulative time\\
1135 "file" file name\\
1135 "file" file name\\
1136 "module" file name\\
1136 "module" file name\\
1137 "pcalls" primitive call count\\
1137 "pcalls" primitive call count\\
1138 "line" line number\\
1138 "line" line number\\
1139 "name" function name\\
1139 "name" function name\\
1140 "nfl" name/file/line\\
1140 "nfl" name/file/line\\
1141 "stdname" standard name\\
1141 "stdname" standard name\\
1142 "time" internal time
1142 "time" internal time
1143
1143
1144 Note that all sorts on statistics are in descending order (placing
1144 Note that all sorts on statistics are in descending order (placing
1145 most time consuming items first), where as name, file, and line number
1145 most time consuming items first), where as name, file, and line number
1146 searches are in ascending order (i.e., alphabetical). The subtle
1146 searches are in ascending order (i.e., alphabetical). The subtle
1147 distinction between "nfl" and "stdname" is that the standard name is a
1147 distinction between "nfl" and "stdname" is that the standard name is a
1148 sort of the name as printed, which means that the embedded line
1148 sort of the name as printed, which means that the embedded line
1149 numbers get compared in an odd way. For example, lines 3, 20, and 40
1149 numbers get compared in an odd way. For example, lines 3, 20, and 40
1150 would (if the file names were the same) appear in the string order
1150 would (if the file names were the same) appear in the string order
1151 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1151 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1152 line numbers. In fact, sort_stats("nfl") is the same as
1152 line numbers. In fact, sort_stats("nfl") is the same as
1153 sort_stats("name", "file", "line").
1153 sort_stats("name", "file", "line").
1154
1154
1155 -T <filename>: save profile results as shown on screen to a text
1155 -T <filename>: save profile results as shown on screen to a text
1156 file. The profile is still shown on screen.
1156 file. The profile is still shown on screen.
1157
1157
1158 -D <filename>: save (via dump_stats) profile statistics to given
1158 -D <filename>: save (via dump_stats) profile statistics to given
1159 filename. This data is in a format understod by the pstats module, and
1159 filename. This data is in a format understod by the pstats module, and
1160 is generated by a call to the dump_stats() method of profile
1160 is generated by a call to the dump_stats() method of profile
1161 objects. The profile is still shown on screen.
1161 objects. The profile is still shown on screen.
1162
1162
1163 If you want to run complete programs under the profiler's control, use
1163 If you want to run complete programs under the profiler's control, use
1164 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1164 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1165 contains profiler specific options as described here.
1165 contains profiler specific options as described here.
1166
1166
1167 You can read the complete documentation for the profile module with:\\
1167 You can read the complete documentation for the profile module with:\\
1168 In [1]: import profile; profile.help() """
1168 In [1]: import profile; profile.help() """
1169
1169
1170 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1170 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1171 # protect user quote marks
1171 # protect user quote marks
1172 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1172 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1173
1173
1174 if user_mode: # regular user call
1174 if user_mode: # regular user call
1175 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1175 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1176 list_all=1)
1176 list_all=1)
1177 namespace = self.shell.user_ns
1177 namespace = self.shell.user_ns
1178 else: # called to run a program by %run -p
1178 else: # called to run a program by %run -p
1179 try:
1179 try:
1180 filename = get_py_filename(arg_lst[0])
1180 filename = get_py_filename(arg_lst[0])
1181 except IOError,msg:
1181 except IOError,msg:
1182 error(msg)
1182 error(msg)
1183 return
1183 return
1184
1184
1185 arg_str = 'execfile(filename,prog_ns)'
1185 arg_str = 'execfile(filename,prog_ns)'
1186 namespace = locals()
1186 namespace = locals()
1187
1187
1188 opts.merge(opts_def)
1188 opts.merge(opts_def)
1189
1189
1190 prof = profile.Profile()
1190 prof = profile.Profile()
1191 try:
1191 try:
1192 prof = prof.runctx(arg_str,namespace,namespace)
1192 prof = prof.runctx(arg_str,namespace,namespace)
1193 sys_exit = ''
1193 sys_exit = ''
1194 except SystemExit:
1194 except SystemExit:
1195 sys_exit = """*** SystemExit exception caught in code being profiled."""
1195 sys_exit = """*** SystemExit exception caught in code being profiled."""
1196
1196
1197 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1197 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1198
1198
1199 lims = opts.l
1199 lims = opts.l
1200 if lims:
1200 if lims:
1201 lims = [] # rebuild lims with ints/floats/strings
1201 lims = [] # rebuild lims with ints/floats/strings
1202 for lim in opts.l:
1202 for lim in opts.l:
1203 try:
1203 try:
1204 lims.append(int(lim))
1204 lims.append(int(lim))
1205 except ValueError:
1205 except ValueError:
1206 try:
1206 try:
1207 lims.append(float(lim))
1207 lims.append(float(lim))
1208 except ValueError:
1208 except ValueError:
1209 lims.append(lim)
1209 lims.append(lim)
1210
1210
1211 # Trap output.
1211 # Trap output.
1212 stdout_trap = StringIO()
1212 stdout_trap = StringIO()
1213
1213
1214 if hasattr(stats,'stream'):
1214 if hasattr(stats,'stream'):
1215 # In newer versions of python, the stats object has a 'stream'
1215 # In newer versions of python, the stats object has a 'stream'
1216 # attribute to write into.
1216 # attribute to write into.
1217 stats.stream = stdout_trap
1217 stats.stream = stdout_trap
1218 stats.print_stats(*lims)
1218 stats.print_stats(*lims)
1219 else:
1219 else:
1220 # For older versions, we manually redirect stdout during printing
1220 # For older versions, we manually redirect stdout during printing
1221 sys_stdout = sys.stdout
1221 sys_stdout = sys.stdout
1222 try:
1222 try:
1223 sys.stdout = stdout_trap
1223 sys.stdout = stdout_trap
1224 stats.print_stats(*lims)
1224 stats.print_stats(*lims)
1225 finally:
1225 finally:
1226 sys.stdout = sys_stdout
1226 sys.stdout = sys_stdout
1227
1227
1228 output = stdout_trap.getvalue()
1228 output = stdout_trap.getvalue()
1229 output = output.rstrip()
1229 output = output.rstrip()
1230
1230
1231 page(output,screen_lines=self.shell.rc.screen_length)
1231 page(output,screen_lines=self.shell.rc.screen_length)
1232 print sys_exit,
1232 print sys_exit,
1233
1233
1234 dump_file = opts.D[0]
1234 dump_file = opts.D[0]
1235 text_file = opts.T[0]
1235 text_file = opts.T[0]
1236 if dump_file:
1236 if dump_file:
1237 prof.dump_stats(dump_file)
1237 prof.dump_stats(dump_file)
1238 print '\n*** Profile stats marshalled to file',\
1238 print '\n*** Profile stats marshalled to file',\
1239 `dump_file`+'.',sys_exit
1239 `dump_file`+'.',sys_exit
1240 if text_file:
1240 if text_file:
1241 pfile = file(text_file,'w')
1241 pfile = file(text_file,'w')
1242 pfile.write(output)
1242 pfile.write(output)
1243 pfile.close()
1243 pfile.close()
1244 print '\n*** Profile printout saved to text file',\
1244 print '\n*** Profile printout saved to text file',\
1245 `text_file`+'.',sys_exit
1245 `text_file`+'.',sys_exit
1246
1246
1247 if opts.has_key('r'):
1247 if opts.has_key('r'):
1248 return stats
1248 return stats
1249 else:
1249 else:
1250 return None
1250 return None
1251
1251
1252 def magic_run(self, parameter_s ='',runner=None):
1252 def magic_run(self, parameter_s ='',runner=None):
1253 """Run the named file inside IPython as a program.
1253 """Run the named file inside IPython as a program.
1254
1254
1255 Usage:\\
1255 Usage:\\
1256 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1256 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1257
1257
1258 Parameters after the filename are passed as command-line arguments to
1258 Parameters after the filename are passed as command-line arguments to
1259 the program (put in sys.argv). Then, control returns to IPython's
1259 the program (put in sys.argv). Then, control returns to IPython's
1260 prompt.
1260 prompt.
1261
1261
1262 This is similar to running at a system prompt:\\
1262 This is similar to running at a system prompt:\\
1263 $ python file args\\
1263 $ python file args\\
1264 but with the advantage of giving you IPython's tracebacks, and of
1264 but with the advantage of giving you IPython's tracebacks, and of
1265 loading all variables into your interactive namespace for further use
1265 loading all variables into your interactive namespace for further use
1266 (unless -p is used, see below).
1266 (unless -p is used, see below).
1267
1267
1268 The file is executed in a namespace initially consisting only of
1268 The file is executed in a namespace initially consisting only of
1269 __name__=='__main__' and sys.argv constructed as indicated. It thus
1269 __name__=='__main__' and sys.argv constructed as indicated. It thus
1270 sees its environment as if it were being run as a stand-alone
1270 sees its environment as if it were being run as a stand-alone
1271 program. But after execution, the IPython interactive namespace gets
1271 program. But after execution, the IPython interactive namespace gets
1272 updated with all variables defined in the program (except for __name__
1272 updated with all variables defined in the program (except for __name__
1273 and sys.argv). This allows for very convenient loading of code for
1273 and sys.argv). This allows for very convenient loading of code for
1274 interactive work, while giving each program a 'clean sheet' to run in.
1274 interactive work, while giving each program a 'clean sheet' to run in.
1275
1275
1276 Options:
1276 Options:
1277
1277
1278 -n: __name__ is NOT set to '__main__', but to the running file's name
1278 -n: __name__ is NOT set to '__main__', but to the running file's name
1279 without extension (as python does under import). This allows running
1279 without extension (as python does under import). This allows running
1280 scripts and reloading the definitions in them without calling code
1280 scripts and reloading the definitions in them without calling code
1281 protected by an ' if __name__ == "__main__" ' clause.
1281 protected by an ' if __name__ == "__main__" ' clause.
1282
1282
1283 -i: run the file in IPython's namespace instead of an empty one. This
1283 -i: run the file in IPython's namespace instead of an empty one. This
1284 is useful if you are experimenting with code written in a text editor
1284 is useful if you are experimenting with code written in a text editor
1285 which depends on variables defined interactively.
1285 which depends on variables defined interactively.
1286
1286
1287 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1287 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1288 being run. This is particularly useful if IPython is being used to
1288 being run. This is particularly useful if IPython is being used to
1289 run unittests, which always exit with a sys.exit() call. In such
1289 run unittests, which always exit with a sys.exit() call. In such
1290 cases you are interested in the output of the test results, not in
1290 cases you are interested in the output of the test results, not in
1291 seeing a traceback of the unittest module.
1291 seeing a traceback of the unittest module.
1292
1292
1293 -t: print timing information at the end of the run. IPython will give
1293 -t: print timing information at the end of the run. IPython will give
1294 you an estimated CPU time consumption for your script, which under
1294 you an estimated CPU time consumption for your script, which under
1295 Unix uses the resource module to avoid the wraparound problems of
1295 Unix uses the resource module to avoid the wraparound problems of
1296 time.clock(). Under Unix, an estimate of time spent on system tasks
1296 time.clock(). Under Unix, an estimate of time spent on system tasks
1297 is also given (for Windows platforms this is reported as 0.0).
1297 is also given (for Windows platforms this is reported as 0.0).
1298
1298
1299 If -t is given, an additional -N<N> option can be given, where <N>
1299 If -t is given, an additional -N<N> option can be given, where <N>
1300 must be an integer indicating how many times you want the script to
1300 must be an integer indicating how many times you want the script to
1301 run. The final timing report will include total and per run results.
1301 run. The final timing report will include total and per run results.
1302
1302
1303 For example (testing the script uniq_stable.py):
1303 For example (testing the script uniq_stable.py):
1304
1304
1305 In [1]: run -t uniq_stable
1305 In [1]: run -t uniq_stable
1306
1306
1307 IPython CPU timings (estimated):\\
1307 IPython CPU timings (estimated):\\
1308 User : 0.19597 s.\\
1308 User : 0.19597 s.\\
1309 System: 0.0 s.\\
1309 System: 0.0 s.\\
1310
1310
1311 In [2]: run -t -N5 uniq_stable
1311 In [2]: run -t -N5 uniq_stable
1312
1312
1313 IPython CPU timings (estimated):\\
1313 IPython CPU timings (estimated):\\
1314 Total runs performed: 5\\
1314 Total runs performed: 5\\
1315 Times : Total Per run\\
1315 Times : Total Per run\\
1316 User : 0.910862 s, 0.1821724 s.\\
1316 User : 0.910862 s, 0.1821724 s.\\
1317 System: 0.0 s, 0.0 s.
1317 System: 0.0 s, 0.0 s.
1318
1318
1319 -d: run your program under the control of pdb, the Python debugger.
1319 -d: run your program under the control of pdb, the Python debugger.
1320 This allows you to execute your program step by step, watch variables,
1320 This allows you to execute your program step by step, watch variables,
1321 etc. Internally, what IPython does is similar to calling:
1321 etc. Internally, what IPython does is similar to calling:
1322
1322
1323 pdb.run('execfile("YOURFILENAME")')
1323 pdb.run('execfile("YOURFILENAME")')
1324
1324
1325 with a breakpoint set on line 1 of your file. You can change the line
1325 with a breakpoint set on line 1 of your file. You can change the line
1326 number for this automatic breakpoint to be <N> by using the -bN option
1326 number for this automatic breakpoint to be <N> by using the -bN option
1327 (where N must be an integer). For example:
1327 (where N must be an integer). For example:
1328
1328
1329 %run -d -b40 myscript
1329 %run -d -b40 myscript
1330
1330
1331 will set the first breakpoint at line 40 in myscript.py. Note that
1331 will set the first breakpoint at line 40 in myscript.py. Note that
1332 the first breakpoint must be set on a line which actually does
1332 the first breakpoint must be set on a line which actually does
1333 something (not a comment or docstring) for it to stop execution.
1333 something (not a comment or docstring) for it to stop execution.
1334
1334
1335 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1335 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1336 first enter 'c' (without qoutes) to start execution up to the first
1336 first enter 'c' (without qoutes) to start execution up to the first
1337 breakpoint.
1337 breakpoint.
1338
1338
1339 Entering 'help' gives information about the use of the debugger. You
1339 Entering 'help' gives information about the use of the debugger. You
1340 can easily see pdb's full documentation with "import pdb;pdb.help()"
1340 can easily see pdb's full documentation with "import pdb;pdb.help()"
1341 at a prompt.
1341 at a prompt.
1342
1342
1343 -p: run program under the control of the Python profiler module (which
1343 -p: run program under the control of the Python profiler module (which
1344 prints a detailed report of execution times, function calls, etc).
1344 prints a detailed report of execution times, function calls, etc).
1345
1345
1346 You can pass other options after -p which affect the behavior of the
1346 You can pass other options after -p which affect the behavior of the
1347 profiler itself. See the docs for %prun for details.
1347 profiler itself. See the docs for %prun for details.
1348
1348
1349 In this mode, the program's variables do NOT propagate back to the
1349 In this mode, the program's variables do NOT propagate back to the
1350 IPython interactive namespace (because they remain in the namespace
1350 IPython interactive namespace (because they remain in the namespace
1351 where the profiler executes them).
1351 where the profiler executes them).
1352
1352
1353 Internally this triggers a call to %prun, see its documentation for
1353 Internally this triggers a call to %prun, see its documentation for
1354 details on the options available specifically for profiling.
1354 details on the options available specifically for profiling.
1355
1355
1356 There is one special usage for which the text above doesn't apply:
1356 There is one special usage for which the text above doesn't apply:
1357 if the filename ends with .ipy, the file is run as ipython script,
1357 if the filename ends with .ipy, the file is run as ipython script,
1358 just as if the commands were written on IPython prompt.
1358 just as if the commands were written on IPython prompt.
1359 """
1359 """
1360
1360
1361 # get arguments and set sys.argv for program to be run.
1361 # get arguments and set sys.argv for program to be run.
1362 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1362 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1363 mode='list',list_all=1)
1363 mode='list',list_all=1)
1364
1364
1365 try:
1365 try:
1366 filename = get_py_filename(arg_lst[0])
1366 filename = get_py_filename(arg_lst[0])
1367 except IndexError:
1367 except IndexError:
1368 warn('you must provide at least a filename.')
1368 warn('you must provide at least a filename.')
1369 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1369 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1370 return
1370 return
1371 except IOError,msg:
1371 except IOError,msg:
1372 error(msg)
1372 error(msg)
1373 return
1373 return
1374
1374
1375 if filename.lower().endswith('.ipy'):
1375 if filename.lower().endswith('.ipy'):
1376 self.api.runlines(open(filename).read())
1376 self.api.runlines(open(filename).read())
1377 return
1377 return
1378
1378
1379 # Control the response to exit() calls made by the script being run
1379 # Control the response to exit() calls made by the script being run
1380 exit_ignore = opts.has_key('e')
1380 exit_ignore = opts.has_key('e')
1381
1381
1382 # Make sure that the running script gets a proper sys.argv as if it
1382 # Make sure that the running script gets a proper sys.argv as if it
1383 # were run from a system shell.
1383 # were run from a system shell.
1384 save_argv = sys.argv # save it for later restoring
1384 save_argv = sys.argv # save it for later restoring
1385 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1385 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1386
1386
1387 if opts.has_key('i'):
1387 if opts.has_key('i'):
1388 prog_ns = self.shell.user_ns
1388 prog_ns = self.shell.user_ns
1389 __name__save = self.shell.user_ns['__name__']
1389 __name__save = self.shell.user_ns['__name__']
1390 prog_ns['__name__'] = '__main__'
1390 prog_ns['__name__'] = '__main__'
1391 else:
1391 else:
1392 if opts.has_key('n'):
1392 if opts.has_key('n'):
1393 name = os.path.splitext(os.path.basename(filename))[0]
1393 name = os.path.splitext(os.path.basename(filename))[0]
1394 else:
1394 else:
1395 name = '__main__'
1395 name = '__main__'
1396 prog_ns = {'__name__':name}
1396 prog_ns = {'__name__':name}
1397
1397
1398 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1398 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1399 # set the __file__ global in the script's namespace
1399 # set the __file__ global in the script's namespace
1400 prog_ns['__file__'] = filename
1400 prog_ns['__file__'] = filename
1401
1401
1402 # pickle fix. See iplib for an explanation. But we need to make sure
1402 # pickle fix. See iplib for an explanation. But we need to make sure
1403 # that, if we overwrite __main__, we replace it at the end
1403 # that, if we overwrite __main__, we replace it at the end
1404 if prog_ns['__name__'] == '__main__':
1404 if prog_ns['__name__'] == '__main__':
1405 restore_main = sys.modules['__main__']
1405 restore_main = sys.modules['__main__']
1406 else:
1406 else:
1407 restore_main = False
1407 restore_main = False
1408
1408
1409 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1409 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1410
1410
1411 stats = None
1411 stats = None
1412 try:
1412 try:
1413 if self.shell.has_readline:
1413 if self.shell.has_readline:
1414 self.shell.savehist()
1414 self.shell.savehist()
1415
1415
1416 if opts.has_key('p'):
1416 if opts.has_key('p'):
1417 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1417 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1418 else:
1418 else:
1419 if opts.has_key('d'):
1419 if opts.has_key('d'):
1420 deb = Debugger.Pdb(self.shell.rc.colors)
1420 deb = Debugger.Pdb(self.shell.rc.colors)
1421 # reset Breakpoint state, which is moronically kept
1421 # reset Breakpoint state, which is moronically kept
1422 # in a class
1422 # in a class
1423 bdb.Breakpoint.next = 1
1423 bdb.Breakpoint.next = 1
1424 bdb.Breakpoint.bplist = {}
1424 bdb.Breakpoint.bplist = {}
1425 bdb.Breakpoint.bpbynumber = [None]
1425 bdb.Breakpoint.bpbynumber = [None]
1426 # Set an initial breakpoint to stop execution
1426 # Set an initial breakpoint to stop execution
1427 maxtries = 10
1427 maxtries = 10
1428 bp = int(opts.get('b',[1])[0])
1428 bp = int(opts.get('b',[1])[0])
1429 checkline = deb.checkline(filename,bp)
1429 checkline = deb.checkline(filename,bp)
1430 if not checkline:
1430 if not checkline:
1431 for bp in range(bp+1,bp+maxtries+1):
1431 for bp in range(bp+1,bp+maxtries+1):
1432 if deb.checkline(filename,bp):
1432 if deb.checkline(filename,bp):
1433 break
1433 break
1434 else:
1434 else:
1435 msg = ("\nI failed to find a valid line to set "
1435 msg = ("\nI failed to find a valid line to set "
1436 "a breakpoint\n"
1436 "a breakpoint\n"
1437 "after trying up to line: %s.\n"
1437 "after trying up to line: %s.\n"
1438 "Please set a valid breakpoint manually "
1438 "Please set a valid breakpoint manually "
1439 "with the -b option." % bp)
1439 "with the -b option." % bp)
1440 error(msg)
1440 error(msg)
1441 return
1441 return
1442 # if we find a good linenumber, set the breakpoint
1442 # if we find a good linenumber, set the breakpoint
1443 deb.do_break('%s:%s' % (filename,bp))
1443 deb.do_break('%s:%s' % (filename,bp))
1444 # Start file run
1444 # Start file run
1445 print "NOTE: Enter 'c' at the",
1445 print "NOTE: Enter 'c' at the",
1446 print "%s prompt to start your script." % deb.prompt
1446 print "%s prompt to start your script." % deb.prompt
1447 try:
1447 try:
1448 deb.run('execfile("%s")' % filename,prog_ns)
1448 deb.run('execfile("%s")' % filename,prog_ns)
1449
1449
1450 except:
1450 except:
1451 etype, value, tb = sys.exc_info()
1451 etype, value, tb = sys.exc_info()
1452 # Skip three frames in the traceback: the %run one,
1452 # Skip three frames in the traceback: the %run one,
1453 # one inside bdb.py, and the command-line typed by the
1453 # one inside bdb.py, and the command-line typed by the
1454 # user (run by exec in pdb itself).
1454 # user (run by exec in pdb itself).
1455 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1455 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1456 else:
1456 else:
1457 if runner is None:
1457 if runner is None:
1458 runner = self.shell.safe_execfile
1458 runner = self.shell.safe_execfile
1459 if opts.has_key('t'):
1459 if opts.has_key('t'):
1460 try:
1460 try:
1461 nruns = int(opts['N'][0])
1461 nruns = int(opts['N'][0])
1462 if nruns < 1:
1462 if nruns < 1:
1463 error('Number of runs must be >=1')
1463 error('Number of runs must be >=1')
1464 return
1464 return
1465 except (KeyError):
1465 except (KeyError):
1466 nruns = 1
1466 nruns = 1
1467 if nruns == 1:
1467 if nruns == 1:
1468 t0 = clock2()
1468 t0 = clock2()
1469 runner(filename,prog_ns,prog_ns,
1469 runner(filename,prog_ns,prog_ns,
1470 exit_ignore=exit_ignore)
1470 exit_ignore=exit_ignore)
1471 t1 = clock2()
1471 t1 = clock2()
1472 t_usr = t1[0]-t0[0]
1472 t_usr = t1[0]-t0[0]
1473 t_sys = t1[1]-t1[1]
1473 t_sys = t1[1]-t1[1]
1474 print "\nIPython CPU timings (estimated):"
1474 print "\nIPython CPU timings (estimated):"
1475 print " User : %10s s." % t_usr
1475 print " User : %10s s." % t_usr
1476 print " System: %10s s." % t_sys
1476 print " System: %10s s." % t_sys
1477 else:
1477 else:
1478 runs = range(nruns)
1478 runs = range(nruns)
1479 t0 = clock2()
1479 t0 = clock2()
1480 for nr in runs:
1480 for nr in runs:
1481 runner(filename,prog_ns,prog_ns,
1481 runner(filename,prog_ns,prog_ns,
1482 exit_ignore=exit_ignore)
1482 exit_ignore=exit_ignore)
1483 t1 = clock2()
1483 t1 = clock2()
1484 t_usr = t1[0]-t0[0]
1484 t_usr = t1[0]-t0[0]
1485 t_sys = t1[1]-t1[1]
1485 t_sys = t1[1]-t1[1]
1486 print "\nIPython CPU timings (estimated):"
1486 print "\nIPython CPU timings (estimated):"
1487 print "Total runs performed:",nruns
1487 print "Total runs performed:",nruns
1488 print " Times : %10s %10s" % ('Total','Per run')
1488 print " Times : %10s %10s" % ('Total','Per run')
1489 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1489 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1490 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1490 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1491
1491
1492 else:
1492 else:
1493 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1493 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1494 if opts.has_key('i'):
1494 if opts.has_key('i'):
1495 self.shell.user_ns['__name__'] = __name__save
1495 self.shell.user_ns['__name__'] = __name__save
1496 else:
1496 else:
1497 # update IPython interactive namespace
1497 # update IPython interactive namespace
1498 del prog_ns['__name__']
1498 del prog_ns['__name__']
1499 self.shell.user_ns.update(prog_ns)
1499 self.shell.user_ns.update(prog_ns)
1500 finally:
1500 finally:
1501 sys.argv = save_argv
1501 sys.argv = save_argv
1502 if restore_main:
1502 if restore_main:
1503 sys.modules['__main__'] = restore_main
1503 sys.modules['__main__'] = restore_main
1504 self.shell.reloadhist()
1504 self.shell.reloadhist()
1505
1505
1506 return stats
1506 return stats
1507
1507
1508 def magic_runlog(self, parameter_s =''):
1508 def magic_runlog(self, parameter_s =''):
1509 """Run files as logs.
1509 """Run files as logs.
1510
1510
1511 Usage:\\
1511 Usage:\\
1512 %runlog file1 file2 ...
1512 %runlog file1 file2 ...
1513
1513
1514 Run the named files (treating them as log files) in sequence inside
1514 Run the named files (treating them as log files) in sequence inside
1515 the interpreter, and return to the prompt. This is much slower than
1515 the interpreter, and return to the prompt. This is much slower than
1516 %run because each line is executed in a try/except block, but it
1516 %run because each line is executed in a try/except block, but it
1517 allows running files with syntax errors in them.
1517 allows running files with syntax errors in them.
1518
1518
1519 Normally IPython will guess when a file is one of its own logfiles, so
1519 Normally IPython will guess when a file is one of its own logfiles, so
1520 you can typically use %run even for logs. This shorthand allows you to
1520 you can typically use %run even for logs. This shorthand allows you to
1521 force any file to be treated as a log file."""
1521 force any file to be treated as a log file."""
1522
1522
1523 for f in parameter_s.split():
1523 for f in parameter_s.split():
1524 self.shell.safe_execfile(f,self.shell.user_ns,
1524 self.shell.safe_execfile(f,self.shell.user_ns,
1525 self.shell.user_ns,islog=1)
1525 self.shell.user_ns,islog=1)
1526
1526
1527 def magic_timeit(self, parameter_s =''):
1527 def magic_timeit(self, parameter_s =''):
1528 """Time execution of a Python statement or expression
1528 """Time execution of a Python statement or expression
1529
1529
1530 Usage:\\
1530 Usage:\\
1531 %timeit [-n<N> -r<R> [-t|-c]] statement
1531 %timeit [-n<N> -r<R> [-t|-c]] statement
1532
1532
1533 Time execution of a Python statement or expression using the timeit
1533 Time execution of a Python statement or expression using the timeit
1534 module.
1534 module.
1535
1535
1536 Options:
1536 Options:
1537 -n<N>: execute the given statement <N> times in a loop. If this value
1537 -n<N>: execute the given statement <N> times in a loop. If this value
1538 is not given, a fitting value is chosen.
1538 is not given, a fitting value is chosen.
1539
1539
1540 -r<R>: repeat the loop iteration <R> times and take the best result.
1540 -r<R>: repeat the loop iteration <R> times and take the best result.
1541 Default: 3
1541 Default: 3
1542
1542
1543 -t: use time.time to measure the time, which is the default on Unix.
1543 -t: use time.time to measure the time, which is the default on Unix.
1544 This function measures wall time.
1544 This function measures wall time.
1545
1545
1546 -c: use time.clock to measure the time, which is the default on
1546 -c: use time.clock to measure the time, which is the default on
1547 Windows and measures wall time. On Unix, resource.getrusage is used
1547 Windows and measures wall time. On Unix, resource.getrusage is used
1548 instead and returns the CPU user time.
1548 instead and returns the CPU user time.
1549
1549
1550 -p<P>: use a precision of <P> digits to display the timing result.
1550 -p<P>: use a precision of <P> digits to display the timing result.
1551 Default: 3
1551 Default: 3
1552
1552
1553
1553
1554 Examples:\\
1554 Examples:\\
1555 In [1]: %timeit pass
1555 In [1]: %timeit pass
1556 10000000 loops, best of 3: 53.3 ns per loop
1556 10000000 loops, best of 3: 53.3 ns per loop
1557
1557
1558 In [2]: u = None
1558 In [2]: u = None
1559
1559
1560 In [3]: %timeit u is None
1560 In [3]: %timeit u is None
1561 10000000 loops, best of 3: 184 ns per loop
1561 10000000 loops, best of 3: 184 ns per loop
1562
1562
1563 In [4]: %timeit -r 4 u == None
1563 In [4]: %timeit -r 4 u == None
1564 1000000 loops, best of 4: 242 ns per loop
1564 1000000 loops, best of 4: 242 ns per loop
1565
1565
1566 In [5]: import time
1566 In [5]: import time
1567
1567
1568 In [6]: %timeit -n1 time.sleep(2)
1568 In [6]: %timeit -n1 time.sleep(2)
1569 1 loops, best of 3: 2 s per loop
1569 1 loops, best of 3: 2 s per loop
1570
1570
1571
1571
1572 The times reported by %timeit will be slightly higher than those
1572 The times reported by %timeit will be slightly higher than those
1573 reported by the timeit.py script when variables are accessed. This is
1573 reported by the timeit.py script when variables are accessed. This is
1574 due to the fact that %timeit executes the statement in the namespace
1574 due to the fact that %timeit executes the statement in the namespace
1575 of the shell, compared with timeit.py, which uses a single setup
1575 of the shell, compared with timeit.py, which uses a single setup
1576 statement to import function or create variables. Generally, the bias
1576 statement to import function or create variables. Generally, the bias
1577 does not matter as long as results from timeit.py are not mixed with
1577 does not matter as long as results from timeit.py are not mixed with
1578 those from %timeit."""
1578 those from %timeit."""
1579
1579
1580 import timeit
1580 import timeit
1581 import math
1581 import math
1582
1582
1583 units = ["s", "ms", "\xc2\xb5s", "ns"]
1583 units = ["s", "ms", "\xc2\xb5s", "ns"]
1584 scaling = [1, 1e3, 1e6, 1e9]
1584 scaling = [1, 1e3, 1e6, 1e9]
1585
1585
1586 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1586 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1587 posix=False)
1587 posix=False)
1588 if stmt == "":
1588 if stmt == "":
1589 return
1589 return
1590 timefunc = timeit.default_timer
1590 timefunc = timeit.default_timer
1591 number = int(getattr(opts, "n", 0))
1591 number = int(getattr(opts, "n", 0))
1592 repeat = int(getattr(opts, "r", timeit.default_repeat))
1592 repeat = int(getattr(opts, "r", timeit.default_repeat))
1593 precision = int(getattr(opts, "p", 3))
1593 precision = int(getattr(opts, "p", 3))
1594 if hasattr(opts, "t"):
1594 if hasattr(opts, "t"):
1595 timefunc = time.time
1595 timefunc = time.time
1596 if hasattr(opts, "c"):
1596 if hasattr(opts, "c"):
1597 timefunc = clock
1597 timefunc = clock
1598
1598
1599 timer = timeit.Timer(timer=timefunc)
1599 timer = timeit.Timer(timer=timefunc)
1600 # this code has tight coupling to the inner workings of timeit.Timer,
1600 # this code has tight coupling to the inner workings of timeit.Timer,
1601 # but is there a better way to achieve that the code stmt has access
1601 # but is there a better way to achieve that the code stmt has access
1602 # to the shell namespace?
1602 # to the shell namespace?
1603
1603
1604 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1604 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1605 'setup': "pass"}
1605 'setup': "pass"}
1606 code = compile(src, "<magic-timeit>", "exec")
1606 code = compile(src, "<magic-timeit>", "exec")
1607 ns = {}
1607 ns = {}
1608 exec code in self.shell.user_ns, ns
1608 exec code in self.shell.user_ns, ns
1609 timer.inner = ns["inner"]
1609 timer.inner = ns["inner"]
1610
1610
1611 if number == 0:
1611 if number == 0:
1612 # determine number so that 0.2 <= total time < 2.0
1612 # determine number so that 0.2 <= total time < 2.0
1613 number = 1
1613 number = 1
1614 for i in range(1, 10):
1614 for i in range(1, 10):
1615 number *= 10
1615 number *= 10
1616 if timer.timeit(number) >= 0.2:
1616 if timer.timeit(number) >= 0.2:
1617 break
1617 break
1618
1618
1619 best = min(timer.repeat(repeat, number)) / number
1619 best = min(timer.repeat(repeat, number)) / number
1620
1620
1621 if best > 0.0:
1621 if best > 0.0:
1622 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1622 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1623 else:
1623 else:
1624 order = 3
1624 order = 3
1625 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1625 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1626 precision,
1626 precision,
1627 best * scaling[order],
1627 best * scaling[order],
1628 units[order])
1628 units[order])
1629
1629
1630 def magic_time(self,parameter_s = ''):
1630 def magic_time(self,parameter_s = ''):
1631 """Time execution of a Python statement or expression.
1631 """Time execution of a Python statement or expression.
1632
1632
1633 The CPU and wall clock times are printed, and the value of the
1633 The CPU and wall clock times are printed, and the value of the
1634 expression (if any) is returned. Note that under Win32, system time
1634 expression (if any) is returned. Note that under Win32, system time
1635 is always reported as 0, since it can not be measured.
1635 is always reported as 0, since it can not be measured.
1636
1636
1637 This function provides very basic timing functionality. In Python
1637 This function provides very basic timing functionality. In Python
1638 2.3, the timeit module offers more control and sophistication, so this
1638 2.3, the timeit module offers more control and sophistication, so this
1639 could be rewritten to use it (patches welcome).
1639 could be rewritten to use it (patches welcome).
1640
1640
1641 Some examples:
1641 Some examples:
1642
1642
1643 In [1]: time 2**128
1643 In [1]: time 2**128
1644 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1644 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1645 Wall time: 0.00
1645 Wall time: 0.00
1646 Out[1]: 340282366920938463463374607431768211456L
1646 Out[1]: 340282366920938463463374607431768211456L
1647
1647
1648 In [2]: n = 1000000
1648 In [2]: n = 1000000
1649
1649
1650 In [3]: time sum(range(n))
1650 In [3]: time sum(range(n))
1651 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1651 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1652 Wall time: 1.37
1652 Wall time: 1.37
1653 Out[3]: 499999500000L
1653 Out[3]: 499999500000L
1654
1654
1655 In [4]: time print 'hello world'
1655 In [4]: time print 'hello world'
1656 hello world
1656 hello world
1657 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1657 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1658 Wall time: 0.00
1658 Wall time: 0.00
1659 """
1659 """
1660
1660
1661 # fail immediately if the given expression can't be compiled
1661 # fail immediately if the given expression can't be compiled
1662 try:
1662 try:
1663 mode = 'eval'
1663 mode = 'eval'
1664 code = compile(parameter_s,'<timed eval>',mode)
1664 code = compile(parameter_s,'<timed eval>',mode)
1665 except SyntaxError:
1665 except SyntaxError:
1666 mode = 'exec'
1666 mode = 'exec'
1667 code = compile(parameter_s,'<timed exec>',mode)
1667 code = compile(parameter_s,'<timed exec>',mode)
1668 # skew measurement as little as possible
1668 # skew measurement as little as possible
1669 glob = self.shell.user_ns
1669 glob = self.shell.user_ns
1670 clk = clock2
1670 clk = clock2
1671 wtime = time.time
1671 wtime = time.time
1672 # time execution
1672 # time execution
1673 wall_st = wtime()
1673 wall_st = wtime()
1674 if mode=='eval':
1674 if mode=='eval':
1675 st = clk()
1675 st = clk()
1676 out = eval(code,glob)
1676 out = eval(code,glob)
1677 end = clk()
1677 end = clk()
1678 else:
1678 else:
1679 st = clk()
1679 st = clk()
1680 exec code in glob
1680 exec code in glob
1681 end = clk()
1681 end = clk()
1682 out = None
1682 out = None
1683 wall_end = wtime()
1683 wall_end = wtime()
1684 # Compute actual times and report
1684 # Compute actual times and report
1685 wall_time = wall_end-wall_st
1685 wall_time = wall_end-wall_st
1686 cpu_user = end[0]-st[0]
1686 cpu_user = end[0]-st[0]
1687 cpu_sys = end[1]-st[1]
1687 cpu_sys = end[1]-st[1]
1688 cpu_tot = cpu_user+cpu_sys
1688 cpu_tot = cpu_user+cpu_sys
1689 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1689 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1690 (cpu_user,cpu_sys,cpu_tot)
1690 (cpu_user,cpu_sys,cpu_tot)
1691 print "Wall time: %.2f" % wall_time
1691 print "Wall time: %.2f" % wall_time
1692 return out
1692 return out
1693
1693
1694 def magic_macro(self,parameter_s = ''):
1694 def magic_macro(self,parameter_s = ''):
1695 """Define a set of input lines as a macro for future re-execution.
1695 """Define a set of input lines as a macro for future re-execution.
1696
1696
1697 Usage:\\
1697 Usage:\\
1698 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1698 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1699
1699
1700 Options:
1700 Options:
1701
1701
1702 -r: use 'raw' input. By default, the 'processed' history is used,
1702 -r: use 'raw' input. By default, the 'processed' history is used,
1703 so that magics are loaded in their transformed version to valid
1703 so that magics are loaded in their transformed version to valid
1704 Python. If this option is given, the raw input as typed as the
1704 Python. If this option is given, the raw input as typed as the
1705 command line is used instead.
1705 command line is used instead.
1706
1706
1707 This will define a global variable called `name` which is a string
1707 This will define a global variable called `name` which is a string
1708 made of joining the slices and lines you specify (n1,n2,... numbers
1708 made of joining the slices and lines you specify (n1,n2,... numbers
1709 above) from your input history into a single string. This variable
1709 above) from your input history into a single string. This variable
1710 acts like an automatic function which re-executes those lines as if
1710 acts like an automatic function which re-executes those lines as if
1711 you had typed them. You just type 'name' at the prompt and the code
1711 you had typed them. You just type 'name' at the prompt and the code
1712 executes.
1712 executes.
1713
1713
1714 The notation for indicating number ranges is: n1-n2 means 'use line
1714 The notation for indicating number ranges is: n1-n2 means 'use line
1715 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1715 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1716 using the lines numbered 5,6 and 7.
1716 using the lines numbered 5,6 and 7.
1717
1717
1718 Note: as a 'hidden' feature, you can also use traditional python slice
1718 Note: as a 'hidden' feature, you can also use traditional python slice
1719 notation, where N:M means numbers N through M-1.
1719 notation, where N:M means numbers N through M-1.
1720
1720
1721 For example, if your history contains (%hist prints it):
1721 For example, if your history contains (%hist prints it):
1722
1722
1723 44: x=1\\
1723 44: x=1\\
1724 45: y=3\\
1724 45: y=3\\
1725 46: z=x+y\\
1725 46: z=x+y\\
1726 47: print x\\
1726 47: print x\\
1727 48: a=5\\
1727 48: a=5\\
1728 49: print 'x',x,'y',y\\
1728 49: print 'x',x,'y',y\\
1729
1729
1730 you can create a macro with lines 44 through 47 (included) and line 49
1730 you can create a macro with lines 44 through 47 (included) and line 49
1731 called my_macro with:
1731 called my_macro with:
1732
1732
1733 In [51]: %macro my_macro 44-47 49
1733 In [51]: %macro my_macro 44-47 49
1734
1734
1735 Now, typing `my_macro` (without quotes) will re-execute all this code
1735 Now, typing `my_macro` (without quotes) will re-execute all this code
1736 in one pass.
1736 in one pass.
1737
1737
1738 You don't need to give the line-numbers in order, and any given line
1738 You don't need to give the line-numbers in order, and any given line
1739 number can appear multiple times. You can assemble macros with any
1739 number can appear multiple times. You can assemble macros with any
1740 lines from your input history in any order.
1740 lines from your input history in any order.
1741
1741
1742 The macro is a simple object which holds its value in an attribute,
1742 The macro is a simple object which holds its value in an attribute,
1743 but IPython's display system checks for macros and executes them as
1743 but IPython's display system checks for macros and executes them as
1744 code instead of printing them when you type their name.
1744 code instead of printing them when you type their name.
1745
1745
1746 You can view a macro's contents by explicitly printing it with:
1746 You can view a macro's contents by explicitly printing it with:
1747
1747
1748 'print macro_name'.
1748 'print macro_name'.
1749
1749
1750 For one-off cases which DON'T contain magic function calls in them you
1750 For one-off cases which DON'T contain magic function calls in them you
1751 can obtain similar results by explicitly executing slices from your
1751 can obtain similar results by explicitly executing slices from your
1752 input history with:
1752 input history with:
1753
1753
1754 In [60]: exec In[44:48]+In[49]"""
1754 In [60]: exec In[44:48]+In[49]"""
1755
1755
1756 opts,args = self.parse_options(parameter_s,'r',mode='list')
1756 opts,args = self.parse_options(parameter_s,'r',mode='list')
1757 if not args:
1757 if not args:
1758 macs = [k for k,v in self.shell.user_ns.items() if isinstance(v, Macro)]
1758 macs = [k for k,v in self.shell.user_ns.items() if isinstance(v, Macro)]
1759 macs.sort()
1759 macs.sort()
1760 return macs
1760 return macs
1761 name,ranges = args[0], args[1:]
1761 name,ranges = args[0], args[1:]
1762 #print 'rng',ranges # dbg
1762 #print 'rng',ranges # dbg
1763 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1763 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1764 macro = Macro(lines)
1764 macro = Macro(lines)
1765 self.shell.user_ns.update({name:macro})
1765 self.shell.user_ns.update({name:macro})
1766 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1766 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1767 print 'Macro contents:'
1767 print 'Macro contents:'
1768 print macro,
1768 print macro,
1769
1769
1770 def magic_save(self,parameter_s = ''):
1770 def magic_save(self,parameter_s = ''):
1771 """Save a set of lines to a given filename.
1771 """Save a set of lines to a given filename.
1772
1772
1773 Usage:\\
1773 Usage:\\
1774 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1774 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1775
1775
1776 Options:
1776 Options:
1777
1777
1778 -r: use 'raw' input. By default, the 'processed' history is used,
1778 -r: use 'raw' input. By default, the 'processed' history is used,
1779 so that magics are loaded in their transformed version to valid
1779 so that magics are loaded in their transformed version to valid
1780 Python. If this option is given, the raw input as typed as the
1780 Python. If this option is given, the raw input as typed as the
1781 command line is used instead.
1781 command line is used instead.
1782
1782
1783 This function uses the same syntax as %macro for line extraction, but
1783 This function uses the same syntax as %macro for line extraction, but
1784 instead of creating a macro it saves the resulting string to the
1784 instead of creating a macro it saves the resulting string to the
1785 filename you specify.
1785 filename you specify.
1786
1786
1787 It adds a '.py' extension to the file if you don't do so yourself, and
1787 It adds a '.py' extension to the file if you don't do so yourself, and
1788 it asks for confirmation before overwriting existing files."""
1788 it asks for confirmation before overwriting existing files."""
1789
1789
1790 opts,args = self.parse_options(parameter_s,'r',mode='list')
1790 opts,args = self.parse_options(parameter_s,'r',mode='list')
1791 fname,ranges = args[0], args[1:]
1791 fname,ranges = args[0], args[1:]
1792 if not fname.endswith('.py'):
1792 if not fname.endswith('.py'):
1793 fname += '.py'
1793 fname += '.py'
1794 if os.path.isfile(fname):
1794 if os.path.isfile(fname):
1795 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1795 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1796 if ans.lower() not in ['y','yes']:
1796 if ans.lower() not in ['y','yes']:
1797 print 'Operation cancelled.'
1797 print 'Operation cancelled.'
1798 return
1798 return
1799 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1799 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1800 f = file(fname,'w')
1800 f = file(fname,'w')
1801 f.write(cmds)
1801 f.write(cmds)
1802 f.close()
1802 f.close()
1803 print 'The following commands were written to file `%s`:' % fname
1803 print 'The following commands were written to file `%s`:' % fname
1804 print cmds
1804 print cmds
1805
1805
1806 def _edit_macro(self,mname,macro):
1806 def _edit_macro(self,mname,macro):
1807 """open an editor with the macro data in a file"""
1807 """open an editor with the macro data in a file"""
1808 filename = self.shell.mktempfile(macro.value)
1808 filename = self.shell.mktempfile(macro.value)
1809 self.shell.hooks.editor(filename)
1809 self.shell.hooks.editor(filename)
1810
1810
1811 # and make a new macro object, to replace the old one
1811 # and make a new macro object, to replace the old one
1812 mfile = open(filename)
1812 mfile = open(filename)
1813 mvalue = mfile.read()
1813 mvalue = mfile.read()
1814 mfile.close()
1814 mfile.close()
1815 self.shell.user_ns[mname] = Macro(mvalue)
1815 self.shell.user_ns[mname] = Macro(mvalue)
1816
1816
1817 def magic_ed(self,parameter_s=''):
1817 def magic_ed(self,parameter_s=''):
1818 """Alias to %edit."""
1818 """Alias to %edit."""
1819 return self.magic_edit(parameter_s)
1819 return self.magic_edit(parameter_s)
1820
1820
1821 def magic_edit(self,parameter_s='',last_call=['','']):
1821 def magic_edit(self,parameter_s='',last_call=['','']):
1822 """Bring up an editor and execute the resulting code.
1822 """Bring up an editor and execute the resulting code.
1823
1823
1824 Usage:
1824 Usage:
1825 %edit [options] [args]
1825 %edit [options] [args]
1826
1826
1827 %edit runs IPython's editor hook. The default version of this hook is
1827 %edit runs IPython's editor hook. The default version of this hook is
1828 set to call the __IPYTHON__.rc.editor command. This is read from your
1828 set to call the __IPYTHON__.rc.editor command. This is read from your
1829 environment variable $EDITOR. If this isn't found, it will default to
1829 environment variable $EDITOR. If this isn't found, it will default to
1830 vi under Linux/Unix and to notepad under Windows. See the end of this
1830 vi under Linux/Unix and to notepad under Windows. See the end of this
1831 docstring for how to change the editor hook.
1831 docstring for how to change the editor hook.
1832
1832
1833 You can also set the value of this editor via the command line option
1833 You can also set the value of this editor via the command line option
1834 '-editor' or in your ipythonrc file. This is useful if you wish to use
1834 '-editor' or in your ipythonrc file. This is useful if you wish to use
1835 specifically for IPython an editor different from your typical default
1835 specifically for IPython an editor different from your typical default
1836 (and for Windows users who typically don't set environment variables).
1836 (and for Windows users who typically don't set environment variables).
1837
1837
1838 This command allows you to conveniently edit multi-line code right in
1838 This command allows you to conveniently edit multi-line code right in
1839 your IPython session.
1839 your IPython session.
1840
1840
1841 If called without arguments, %edit opens up an empty editor with a
1841 If called without arguments, %edit opens up an empty editor with a
1842 temporary file and will execute the contents of this file when you
1842 temporary file and will execute the contents of this file when you
1843 close it (don't forget to save it!).
1843 close it (don't forget to save it!).
1844
1844
1845
1845
1846 Options:
1846 Options:
1847
1847
1848 -n <number>: open the editor at a specified line number. By default,
1848 -n <number>: open the editor at a specified line number. By default,
1849 the IPython editor hook uses the unix syntax 'editor +N filename', but
1849 the IPython editor hook uses the unix syntax 'editor +N filename', but
1850 you can configure this by providing your own modified hook if your
1850 you can configure this by providing your own modified hook if your
1851 favorite editor supports line-number specifications with a different
1851 favorite editor supports line-number specifications with a different
1852 syntax.
1852 syntax.
1853
1853
1854 -p: this will call the editor with the same data as the previous time
1854 -p: this will call the editor with the same data as the previous time
1855 it was used, regardless of how long ago (in your current session) it
1855 it was used, regardless of how long ago (in your current session) it
1856 was.
1856 was.
1857
1857
1858 -r: use 'raw' input. This option only applies to input taken from the
1858 -r: use 'raw' input. This option only applies to input taken from the
1859 user's history. By default, the 'processed' history is used, so that
1859 user's history. By default, the 'processed' history is used, so that
1860 magics are loaded in their transformed version to valid Python. If
1860 magics are loaded in their transformed version to valid Python. If
1861 this option is given, the raw input as typed as the command line is
1861 this option is given, the raw input as typed as the command line is
1862 used instead. When you exit the editor, it will be executed by
1862 used instead. When you exit the editor, it will be executed by
1863 IPython's own processor.
1863 IPython's own processor.
1864
1864
1865 -x: do not execute the edited code immediately upon exit. This is
1865 -x: do not execute the edited code immediately upon exit. This is
1866 mainly useful if you are editing programs which need to be called with
1866 mainly useful if you are editing programs which need to be called with
1867 command line arguments, which you can then do using %run.
1867 command line arguments, which you can then do using %run.
1868
1868
1869
1869
1870 Arguments:
1870 Arguments:
1871
1871
1872 If arguments are given, the following possibilites exist:
1872 If arguments are given, the following possibilites exist:
1873
1873
1874 - The arguments are numbers or pairs of colon-separated numbers (like
1874 - The arguments are numbers or pairs of colon-separated numbers (like
1875 1 4:8 9). These are interpreted as lines of previous input to be
1875 1 4:8 9). These are interpreted as lines of previous input to be
1876 loaded into the editor. The syntax is the same of the %macro command.
1876 loaded into the editor. The syntax is the same of the %macro command.
1877
1877
1878 - If the argument doesn't start with a number, it is evaluated as a
1878 - If the argument doesn't start with a number, it is evaluated as a
1879 variable and its contents loaded into the editor. You can thus edit
1879 variable and its contents loaded into the editor. You can thus edit
1880 any string which contains python code (including the result of
1880 any string which contains python code (including the result of
1881 previous edits).
1881 previous edits).
1882
1882
1883 - If the argument is the name of an object (other than a string),
1883 - If the argument is the name of an object (other than a string),
1884 IPython will try to locate the file where it was defined and open the
1884 IPython will try to locate the file where it was defined and open the
1885 editor at the point where it is defined. You can use `%edit function`
1885 editor at the point where it is defined. You can use `%edit function`
1886 to load an editor exactly at the point where 'function' is defined,
1886 to load an editor exactly at the point where 'function' is defined,
1887 edit it and have the file be executed automatically.
1887 edit it and have the file be executed automatically.
1888
1888
1889 If the object is a macro (see %macro for details), this opens up your
1889 If the object is a macro (see %macro for details), this opens up your
1890 specified editor with a temporary file containing the macro's data.
1890 specified editor with a temporary file containing the macro's data.
1891 Upon exit, the macro is reloaded with the contents of the file.
1891 Upon exit, the macro is reloaded with the contents of the file.
1892
1892
1893 Note: opening at an exact line is only supported under Unix, and some
1893 Note: opening at an exact line is only supported under Unix, and some
1894 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1894 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1895 '+NUMBER' parameter necessary for this feature. Good editors like
1895 '+NUMBER' parameter necessary for this feature. Good editors like
1896 (X)Emacs, vi, jed, pico and joe all do.
1896 (X)Emacs, vi, jed, pico and joe all do.
1897
1897
1898 - If the argument is not found as a variable, IPython will look for a
1898 - If the argument is not found as a variable, IPython will look for a
1899 file with that name (adding .py if necessary) and load it into the
1899 file with that name (adding .py if necessary) and load it into the
1900 editor. It will execute its contents with execfile() when you exit,
1900 editor. It will execute its contents with execfile() when you exit,
1901 loading any code in the file into your interactive namespace.
1901 loading any code in the file into your interactive namespace.
1902
1902
1903 After executing your code, %edit will return as output the code you
1903 After executing your code, %edit will return as output the code you
1904 typed in the editor (except when it was an existing file). This way
1904 typed in the editor (except when it was an existing file). This way
1905 you can reload the code in further invocations of %edit as a variable,
1905 you can reload the code in further invocations of %edit as a variable,
1906 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1906 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1907 the output.
1907 the output.
1908
1908
1909 Note that %edit is also available through the alias %ed.
1909 Note that %edit is also available through the alias %ed.
1910
1910
1911 This is an example of creating a simple function inside the editor and
1911 This is an example of creating a simple function inside the editor and
1912 then modifying it. First, start up the editor:
1912 then modifying it. First, start up the editor:
1913
1913
1914 In [1]: ed\\
1914 In [1]: ed\\
1915 Editing... done. Executing edited code...\\
1915 Editing... done. Executing edited code...\\
1916 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1916 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1917
1917
1918 We can then call the function foo():
1918 We can then call the function foo():
1919
1919
1920 In [2]: foo()\\
1920 In [2]: foo()\\
1921 foo() was defined in an editing session
1921 foo() was defined in an editing session
1922
1922
1923 Now we edit foo. IPython automatically loads the editor with the
1923 Now we edit foo. IPython automatically loads the editor with the
1924 (temporary) file where foo() was previously defined:
1924 (temporary) file where foo() was previously defined:
1925
1925
1926 In [3]: ed foo\\
1926 In [3]: ed foo\\
1927 Editing... done. Executing edited code...
1927 Editing... done. Executing edited code...
1928
1928
1929 And if we call foo() again we get the modified version:
1929 And if we call foo() again we get the modified version:
1930
1930
1931 In [4]: foo()\\
1931 In [4]: foo()\\
1932 foo() has now been changed!
1932 foo() has now been changed!
1933
1933
1934 Here is an example of how to edit a code snippet successive
1934 Here is an example of how to edit a code snippet successive
1935 times. First we call the editor:
1935 times. First we call the editor:
1936
1936
1937 In [8]: ed\\
1937 In [8]: ed\\
1938 Editing... done. Executing edited code...\\
1938 Editing... done. Executing edited code...\\
1939 hello\\
1939 hello\\
1940 Out[8]: "print 'hello'\\n"
1940 Out[8]: "print 'hello'\\n"
1941
1941
1942 Now we call it again with the previous output (stored in _):
1942 Now we call it again with the previous output (stored in _):
1943
1943
1944 In [9]: ed _\\
1944 In [9]: ed _\\
1945 Editing... done. Executing edited code...\\
1945 Editing... done. Executing edited code...\\
1946 hello world\\
1946 hello world\\
1947 Out[9]: "print 'hello world'\\n"
1947 Out[9]: "print 'hello world'\\n"
1948
1948
1949 Now we call it with the output #8 (stored in _8, also as Out[8]):
1949 Now we call it with the output #8 (stored in _8, also as Out[8]):
1950
1950
1951 In [10]: ed _8\\
1951 In [10]: ed _8\\
1952 Editing... done. Executing edited code...\\
1952 Editing... done. Executing edited code...\\
1953 hello again\\
1953 hello again\\
1954 Out[10]: "print 'hello again'\\n"
1954 Out[10]: "print 'hello again'\\n"
1955
1955
1956
1956
1957 Changing the default editor hook:
1957 Changing the default editor hook:
1958
1958
1959 If you wish to write your own editor hook, you can put it in a
1959 If you wish to write your own editor hook, you can put it in a
1960 configuration file which you load at startup time. The default hook
1960 configuration file which you load at startup time. The default hook
1961 is defined in the IPython.hooks module, and you can use that as a
1961 is defined in the IPython.hooks module, and you can use that as a
1962 starting example for further modifications. That file also has
1962 starting example for further modifications. That file also has
1963 general instructions on how to set a new hook for use once you've
1963 general instructions on how to set a new hook for use once you've
1964 defined it."""
1964 defined it."""
1965
1965
1966 # FIXME: This function has become a convoluted mess. It needs a
1966 # FIXME: This function has become a convoluted mess. It needs a
1967 # ground-up rewrite with clean, simple logic.
1967 # ground-up rewrite with clean, simple logic.
1968
1968
1969 def make_filename(arg):
1969 def make_filename(arg):
1970 "Make a filename from the given args"
1970 "Make a filename from the given args"
1971 try:
1971 try:
1972 filename = get_py_filename(arg)
1972 filename = get_py_filename(arg)
1973 except IOError:
1973 except IOError:
1974 if args.endswith('.py'):
1974 if args.endswith('.py'):
1975 filename = arg
1975 filename = arg
1976 else:
1976 else:
1977 filename = None
1977 filename = None
1978 return filename
1978 return filename
1979
1979
1980 # custom exceptions
1980 # custom exceptions
1981 class DataIsObject(Exception): pass
1981 class DataIsObject(Exception): pass
1982
1982
1983 opts,args = self.parse_options(parameter_s,'prxn:')
1983 opts,args = self.parse_options(parameter_s,'prxn:')
1984 # Set a few locals from the options for convenience:
1984 # Set a few locals from the options for convenience:
1985 opts_p = opts.has_key('p')
1985 opts_p = opts.has_key('p')
1986 opts_r = opts.has_key('r')
1986 opts_r = opts.has_key('r')
1987
1987
1988 # Default line number value
1988 # Default line number value
1989 lineno = opts.get('n',None)
1989 lineno = opts.get('n',None)
1990
1990
1991 if opts_p:
1991 if opts_p:
1992 args = '_%s' % last_call[0]
1992 args = '_%s' % last_call[0]
1993 if not self.shell.user_ns.has_key(args):
1993 if not self.shell.user_ns.has_key(args):
1994 args = last_call[1]
1994 args = last_call[1]
1995
1995
1996 # use last_call to remember the state of the previous call, but don't
1996 # use last_call to remember the state of the previous call, but don't
1997 # let it be clobbered by successive '-p' calls.
1997 # let it be clobbered by successive '-p' calls.
1998 try:
1998 try:
1999 last_call[0] = self.shell.outputcache.prompt_count
1999 last_call[0] = self.shell.outputcache.prompt_count
2000 if not opts_p:
2000 if not opts_p:
2001 last_call[1] = parameter_s
2001 last_call[1] = parameter_s
2002 except:
2002 except:
2003 pass
2003 pass
2004
2004
2005 # by default this is done with temp files, except when the given
2005 # by default this is done with temp files, except when the given
2006 # arg is a filename
2006 # arg is a filename
2007 use_temp = 1
2007 use_temp = 1
2008
2008
2009 if re.match(r'\d',args):
2009 if re.match(r'\d',args):
2010 # Mode where user specifies ranges of lines, like in %macro.
2010 # Mode where user specifies ranges of lines, like in %macro.
2011 # This means that you can't edit files whose names begin with
2011 # This means that you can't edit files whose names begin with
2012 # numbers this way. Tough.
2012 # numbers this way. Tough.
2013 ranges = args.split()
2013 ranges = args.split()
2014 data = ''.join(self.extract_input_slices(ranges,opts_r))
2014 data = ''.join(self.extract_input_slices(ranges,opts_r))
2015 elif args.endswith('.py'):
2015 elif args.endswith('.py'):
2016 filename = make_filename(args)
2016 filename = make_filename(args)
2017 data = ''
2017 data = ''
2018 use_temp = 0
2018 use_temp = 0
2019 elif args:
2019 elif args:
2020 try:
2020 try:
2021 # Load the parameter given as a variable. If not a string,
2021 # Load the parameter given as a variable. If not a string,
2022 # process it as an object instead (below)
2022 # process it as an object instead (below)
2023
2023
2024 #print '*** args',args,'type',type(args) # dbg
2024 #print '*** args',args,'type',type(args) # dbg
2025 data = eval(args,self.shell.user_ns)
2025 data = eval(args,self.shell.user_ns)
2026 if not type(data) in StringTypes:
2026 if not type(data) in StringTypes:
2027 raise DataIsObject
2027 raise DataIsObject
2028
2028
2029 except (NameError,SyntaxError):
2029 except (NameError,SyntaxError):
2030 # given argument is not a variable, try as a filename
2030 # given argument is not a variable, try as a filename
2031 filename = make_filename(args)
2031 filename = make_filename(args)
2032 if filename is None:
2032 if filename is None:
2033 warn("Argument given (%s) can't be found as a variable "
2033 warn("Argument given (%s) can't be found as a variable "
2034 "or as a filename." % args)
2034 "or as a filename." % args)
2035 return
2035 return
2036
2036
2037 data = ''
2037 data = ''
2038 use_temp = 0
2038 use_temp = 0
2039 except DataIsObject:
2039 except DataIsObject:
2040
2040
2041 # macros have a special edit function
2041 # macros have a special edit function
2042 if isinstance(data,Macro):
2042 if isinstance(data,Macro):
2043 self._edit_macro(args,data)
2043 self._edit_macro(args,data)
2044 return
2044 return
2045
2045
2046 # For objects, try to edit the file where they are defined
2046 # For objects, try to edit the file where they are defined
2047 try:
2047 try:
2048 filename = inspect.getabsfile(data)
2048 filename = inspect.getabsfile(data)
2049 datafile = 1
2049 datafile = 1
2050 except TypeError:
2050 except TypeError:
2051 filename = make_filename(args)
2051 filename = make_filename(args)
2052 datafile = 1
2052 datafile = 1
2053 warn('Could not find file where `%s` is defined.\n'
2053 warn('Could not find file where `%s` is defined.\n'
2054 'Opening a file named `%s`' % (args,filename))
2054 'Opening a file named `%s`' % (args,filename))
2055 # Now, make sure we can actually read the source (if it was in
2055 # Now, make sure we can actually read the source (if it was in
2056 # a temp file it's gone by now).
2056 # a temp file it's gone by now).
2057 if datafile:
2057 if datafile:
2058 try:
2058 try:
2059 if lineno is None:
2059 if lineno is None:
2060 lineno = inspect.getsourcelines(data)[1]
2060 lineno = inspect.getsourcelines(data)[1]
2061 except IOError:
2061 except IOError:
2062 filename = make_filename(args)
2062 filename = make_filename(args)
2063 if filename is None:
2063 if filename is None:
2064 warn('The file `%s` where `%s` was defined cannot '
2064 warn('The file `%s` where `%s` was defined cannot '
2065 'be read.' % (filename,data))
2065 'be read.' % (filename,data))
2066 return
2066 return
2067 use_temp = 0
2067 use_temp = 0
2068 else:
2068 else:
2069 data = ''
2069 data = ''
2070
2070
2071 if use_temp:
2071 if use_temp:
2072 filename = self.shell.mktempfile(data)
2072 filename = self.shell.mktempfile(data)
2073 print 'IPython will make a temporary file named:',filename
2073 print 'IPython will make a temporary file named:',filename
2074
2074
2075 # do actual editing here
2075 # do actual editing here
2076 print 'Editing...',
2076 print 'Editing...',
2077 sys.stdout.flush()
2077 sys.stdout.flush()
2078 self.shell.hooks.editor(filename,lineno)
2078 self.shell.hooks.editor(filename,lineno)
2079 if opts.has_key('x'): # -x prevents actual execution
2079 if opts.has_key('x'): # -x prevents actual execution
2080 print
2080 print
2081 else:
2081 else:
2082 print 'done. Executing edited code...'
2082 print 'done. Executing edited code...'
2083 if opts_r:
2083 if opts_r:
2084 self.shell.runlines(file_read(filename))
2084 self.shell.runlines(file_read(filename))
2085 else:
2085 else:
2086 self.shell.safe_execfile(filename,self.shell.user_ns,
2086 self.shell.safe_execfile(filename,self.shell.user_ns,
2087 self.shell.user_ns)
2087 self.shell.user_ns)
2088 if use_temp:
2088 if use_temp:
2089 try:
2089 try:
2090 return open(filename).read()
2090 return open(filename).read()
2091 except IOError,msg:
2091 except IOError,msg:
2092 if msg.filename == filename:
2092 if msg.filename == filename:
2093 warn('File not found. Did you forget to save?')
2093 warn('File not found. Did you forget to save?')
2094 return
2094 return
2095 else:
2095 else:
2096 self.shell.showtraceback()
2096 self.shell.showtraceback()
2097
2097
2098 def magic_xmode(self,parameter_s = ''):
2098 def magic_xmode(self,parameter_s = ''):
2099 """Switch modes for the exception handlers.
2099 """Switch modes for the exception handlers.
2100
2100
2101 Valid modes: Plain, Context and Verbose.
2101 Valid modes: Plain, Context and Verbose.
2102
2102
2103 If called without arguments, acts as a toggle."""
2103 If called without arguments, acts as a toggle."""
2104
2104
2105 def xmode_switch_err(name):
2105 def xmode_switch_err(name):
2106 warn('Error changing %s exception modes.\n%s' %
2106 warn('Error changing %s exception modes.\n%s' %
2107 (name,sys.exc_info()[1]))
2107 (name,sys.exc_info()[1]))
2108
2108
2109 shell = self.shell
2109 shell = self.shell
2110 new_mode = parameter_s.strip().capitalize()
2110 new_mode = parameter_s.strip().capitalize()
2111 try:
2111 try:
2112 shell.InteractiveTB.set_mode(mode=new_mode)
2112 shell.InteractiveTB.set_mode(mode=new_mode)
2113 print 'Exception reporting mode:',shell.InteractiveTB.mode
2113 print 'Exception reporting mode:',shell.InteractiveTB.mode
2114 except:
2114 except:
2115 xmode_switch_err('user')
2115 xmode_switch_err('user')
2116
2116
2117 # threaded shells use a special handler in sys.excepthook
2117 # threaded shells use a special handler in sys.excepthook
2118 if shell.isthreaded:
2118 if shell.isthreaded:
2119 try:
2119 try:
2120 shell.sys_excepthook.set_mode(mode=new_mode)
2120 shell.sys_excepthook.set_mode(mode=new_mode)
2121 except:
2121 except:
2122 xmode_switch_err('threaded')
2122 xmode_switch_err('threaded')
2123
2123
2124 def magic_colors(self,parameter_s = ''):
2124 def magic_colors(self,parameter_s = ''):
2125 """Switch color scheme for prompts, info system and exception handlers.
2125 """Switch color scheme for prompts, info system and exception handlers.
2126
2126
2127 Currently implemented schemes: NoColor, Linux, LightBG.
2127 Currently implemented schemes: NoColor, Linux, LightBG.
2128
2128
2129 Color scheme names are not case-sensitive."""
2129 Color scheme names are not case-sensitive."""
2130
2130
2131 def color_switch_err(name):
2131 def color_switch_err(name):
2132 warn('Error changing %s color schemes.\n%s' %
2132 warn('Error changing %s color schemes.\n%s' %
2133 (name,sys.exc_info()[1]))
2133 (name,sys.exc_info()[1]))
2134
2134
2135
2135
2136 new_scheme = parameter_s.strip()
2136 new_scheme = parameter_s.strip()
2137 if not new_scheme:
2137 if not new_scheme:
2138 print 'You must specify a color scheme.'
2138 print 'You must specify a color scheme.'
2139 return
2139 return
2140 # local shortcut
2140 # local shortcut
2141 shell = self.shell
2141 shell = self.shell
2142
2142
2143 import IPython.rlineimpl as readline
2143 import IPython.rlineimpl as readline
2144
2144
2145 if not readline.have_readline and sys.platform == "win32":
2145 if not readline.have_readline and sys.platform == "win32":
2146 msg = """\
2146 msg = """\
2147 Proper color support under MS Windows requires the pyreadline library.
2147 Proper color support under MS Windows requires the pyreadline library.
2148 You can find it at:
2148 You can find it at:
2149 http://ipython.scipy.org/moin/PyReadline/Intro
2149 http://ipython.scipy.org/moin/PyReadline/Intro
2150 Gary's readline needs the ctypes module, from:
2150 Gary's readline needs the ctypes module, from:
2151 http://starship.python.net/crew/theller/ctypes
2151 http://starship.python.net/crew/theller/ctypes
2152 (Note that ctypes is already part of Python versions 2.5 and newer).
2152 (Note that ctypes is already part of Python versions 2.5 and newer).
2153
2153
2154 Defaulting color scheme to 'NoColor'"""
2154 Defaulting color scheme to 'NoColor'"""
2155 new_scheme = 'NoColor'
2155 new_scheme = 'NoColor'
2156 warn(msg)
2156 warn(msg)
2157
2157
2158 # readline option is 0
2158 # readline option is 0
2159 if not shell.has_readline:
2159 if not shell.has_readline:
2160 new_scheme = 'NoColor'
2160 new_scheme = 'NoColor'
2161
2161
2162 # Set prompt colors
2162 # Set prompt colors
2163 try:
2163 try:
2164 shell.outputcache.set_colors(new_scheme)
2164 shell.outputcache.set_colors(new_scheme)
2165 except:
2165 except:
2166 color_switch_err('prompt')
2166 color_switch_err('prompt')
2167 else:
2167 else:
2168 shell.rc.colors = \
2168 shell.rc.colors = \
2169 shell.outputcache.color_table.active_scheme_name
2169 shell.outputcache.color_table.active_scheme_name
2170 # Set exception colors
2170 # Set exception colors
2171 try:
2171 try:
2172 shell.InteractiveTB.set_colors(scheme = new_scheme)
2172 shell.InteractiveTB.set_colors(scheme = new_scheme)
2173 shell.SyntaxTB.set_colors(scheme = new_scheme)
2173 shell.SyntaxTB.set_colors(scheme = new_scheme)
2174 except:
2174 except:
2175 color_switch_err('exception')
2175 color_switch_err('exception')
2176
2176
2177 # threaded shells use a verbose traceback in sys.excepthook
2177 # threaded shells use a verbose traceback in sys.excepthook
2178 if shell.isthreaded:
2178 if shell.isthreaded:
2179 try:
2179 try:
2180 shell.sys_excepthook.set_colors(scheme=new_scheme)
2180 shell.sys_excepthook.set_colors(scheme=new_scheme)
2181 except:
2181 except:
2182 color_switch_err('system exception handler')
2182 color_switch_err('system exception handler')
2183
2183
2184 # Set info (for 'object?') colors
2184 # Set info (for 'object?') colors
2185 if shell.rc.color_info:
2185 if shell.rc.color_info:
2186 try:
2186 try:
2187 shell.inspector.set_active_scheme(new_scheme)
2187 shell.inspector.set_active_scheme(new_scheme)
2188 except:
2188 except:
2189 color_switch_err('object inspector')
2189 color_switch_err('object inspector')
2190 else:
2190 else:
2191 shell.inspector.set_active_scheme('NoColor')
2191 shell.inspector.set_active_scheme('NoColor')
2192
2192
2193 def magic_color_info(self,parameter_s = ''):
2193 def magic_color_info(self,parameter_s = ''):
2194 """Toggle color_info.
2194 """Toggle color_info.
2195
2195
2196 The color_info configuration parameter controls whether colors are
2196 The color_info configuration parameter controls whether colors are
2197 used for displaying object details (by things like %psource, %pfile or
2197 used for displaying object details (by things like %psource, %pfile or
2198 the '?' system). This function toggles this value with each call.
2198 the '?' system). This function toggles this value with each call.
2199
2199
2200 Note that unless you have a fairly recent pager (less works better
2200 Note that unless you have a fairly recent pager (less works better
2201 than more) in your system, using colored object information displays
2201 than more) in your system, using colored object information displays
2202 will not work properly. Test it and see."""
2202 will not work properly. Test it and see."""
2203
2203
2204 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2204 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2205 self.magic_colors(self.shell.rc.colors)
2205 self.magic_colors(self.shell.rc.colors)
2206 print 'Object introspection functions have now coloring:',
2206 print 'Object introspection functions have now coloring:',
2207 print ['OFF','ON'][self.shell.rc.color_info]
2207 print ['OFF','ON'][self.shell.rc.color_info]
2208
2208
2209 def magic_Pprint(self, parameter_s=''):
2209 def magic_Pprint(self, parameter_s=''):
2210 """Toggle pretty printing on/off."""
2210 """Toggle pretty printing on/off."""
2211
2211
2212 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2212 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2213 print 'Pretty printing has been turned', \
2213 print 'Pretty printing has been turned', \
2214 ['OFF','ON'][self.shell.rc.pprint]
2214 ['OFF','ON'][self.shell.rc.pprint]
2215
2215
2216 def magic_exit(self, parameter_s=''):
2216 def magic_exit(self, parameter_s=''):
2217 """Exit IPython, confirming if configured to do so.
2217 """Exit IPython, confirming if configured to do so.
2218
2218
2219 You can configure whether IPython asks for confirmation upon exit by
2219 You can configure whether IPython asks for confirmation upon exit by
2220 setting the confirm_exit flag in the ipythonrc file."""
2220 setting the confirm_exit flag in the ipythonrc file."""
2221
2221
2222 self.shell.exit()
2222 self.shell.exit()
2223
2223
2224 def magic_quit(self, parameter_s=''):
2224 def magic_quit(self, parameter_s=''):
2225 """Exit IPython, confirming if configured to do so (like %exit)"""
2225 """Exit IPython, confirming if configured to do so (like %exit)"""
2226
2226
2227 self.shell.exit()
2227 self.shell.exit()
2228
2228
2229 def magic_Exit(self, parameter_s=''):
2229 def magic_Exit(self, parameter_s=''):
2230 """Exit IPython without confirmation."""
2230 """Exit IPython without confirmation."""
2231
2231
2232 self.shell.exit_now = True
2232 self.shell.exit_now = True
2233
2233
2234 #......................................................................
2234 #......................................................................
2235 # Functions to implement unix shell-type things
2235 # Functions to implement unix shell-type things
2236
2236
2237 def magic_alias(self, parameter_s = ''):
2237 def magic_alias(self, parameter_s = ''):
2238 """Define an alias for a system command.
2238 """Define an alias for a system command.
2239
2239
2240 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2240 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2241
2241
2242 Then, typing 'alias_name params' will execute the system command 'cmd
2242 Then, typing 'alias_name params' will execute the system command 'cmd
2243 params' (from your underlying operating system).
2243 params' (from your underlying operating system).
2244
2244
2245 Aliases have lower precedence than magic functions and Python normal
2245 Aliases have lower precedence than magic functions and Python normal
2246 variables, so if 'foo' is both a Python variable and an alias, the
2246 variables, so if 'foo' is both a Python variable and an alias, the
2247 alias can not be executed until 'del foo' removes the Python variable.
2247 alias can not be executed until 'del foo' removes the Python variable.
2248
2248
2249 You can use the %l specifier in an alias definition to represent the
2249 You can use the %l specifier in an alias definition to represent the
2250 whole line when the alias is called. For example:
2250 whole line when the alias is called. For example:
2251
2251
2252 In [2]: alias all echo "Input in brackets: <%l>"\\
2252 In [2]: alias all echo "Input in brackets: <%l>"\\
2253 In [3]: all hello world\\
2253 In [3]: all hello world\\
2254 Input in brackets: <hello world>
2254 Input in brackets: <hello world>
2255
2255
2256 You can also define aliases with parameters using %s specifiers (one
2256 You can also define aliases with parameters using %s specifiers (one
2257 per parameter):
2257 per parameter):
2258
2258
2259 In [1]: alias parts echo first %s second %s\\
2259 In [1]: alias parts echo first %s second %s\\
2260 In [2]: %parts A B\\
2260 In [2]: %parts A B\\
2261 first A second B\\
2261 first A second B\\
2262 In [3]: %parts A\\
2262 In [3]: %parts A\\
2263 Incorrect number of arguments: 2 expected.\\
2263 Incorrect number of arguments: 2 expected.\\
2264 parts is an alias to: 'echo first %s second %s'
2264 parts is an alias to: 'echo first %s second %s'
2265
2265
2266 Note that %l and %s are mutually exclusive. You can only use one or
2266 Note that %l and %s are mutually exclusive. You can only use one or
2267 the other in your aliases.
2267 the other in your aliases.
2268
2268
2269 Aliases expand Python variables just like system calls using ! or !!
2269 Aliases expand Python variables just like system calls using ! or !!
2270 do: all expressions prefixed with '$' get expanded. For details of
2270 do: all expressions prefixed with '$' get expanded. For details of
2271 the semantic rules, see PEP-215:
2271 the semantic rules, see PEP-215:
2272 http://www.python.org/peps/pep-0215.html. This is the library used by
2272 http://www.python.org/peps/pep-0215.html. This is the library used by
2273 IPython for variable expansion. If you want to access a true shell
2273 IPython for variable expansion. If you want to access a true shell
2274 variable, an extra $ is necessary to prevent its expansion by IPython:
2274 variable, an extra $ is necessary to prevent its expansion by IPython:
2275
2275
2276 In [6]: alias show echo\\
2276 In [6]: alias show echo\\
2277 In [7]: PATH='A Python string'\\
2277 In [7]: PATH='A Python string'\\
2278 In [8]: show $PATH\\
2278 In [8]: show $PATH\\
2279 A Python string\\
2279 A Python string\\
2280 In [9]: show $$PATH\\
2280 In [9]: show $$PATH\\
2281 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2281 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2282
2282
2283 You can use the alias facility to acess all of $PATH. See the %rehash
2283 You can use the alias facility to acess all of $PATH. See the %rehash
2284 and %rehashx functions, which automatically create aliases for the
2284 and %rehashx functions, which automatically create aliases for the
2285 contents of your $PATH.
2285 contents of your $PATH.
2286
2286
2287 If called with no parameters, %alias prints the current alias table."""
2287 If called with no parameters, %alias prints the current alias table."""
2288
2288
2289 par = parameter_s.strip()
2289 par = parameter_s.strip()
2290 if not par:
2290 if not par:
2291 stored = self.db.get('stored_aliases', {} )
2291 stored = self.db.get('stored_aliases', {} )
2292 atab = self.shell.alias_table
2292 atab = self.shell.alias_table
2293 aliases = atab.keys()
2293 aliases = atab.keys()
2294 aliases.sort()
2294 aliases.sort()
2295 res = []
2295 res = []
2296 showlast = []
2296 showlast = []
2297 for alias in aliases:
2297 for alias in aliases:
2298 try:
2298 try:
2299 tgt = atab[alias][1]
2299 tgt = atab[alias][1]
2300 except TypeError:
2300 except TypeError:
2301 # unsubscriptable? probably a callable
2301 # unsubscriptable? probably a callable
2302 tgt = atab[alias]
2302 tgt = atab[alias]
2303 # 'interesting' aliases
2303 # 'interesting' aliases
2304 if (alias in stored or
2304 if (alias in stored or
2305 alias.lower() != os.path.splitext(tgt)[0].lower() or
2305 alias.lower() != os.path.splitext(tgt)[0].lower() or
2306 ' ' in tgt):
2306 ' ' in tgt):
2307 showlast.append((alias, tgt))
2307 showlast.append((alias, tgt))
2308 else:
2308 else:
2309 res.append((alias, tgt ))
2309 res.append((alias, tgt ))
2310
2310
2311 # show most interesting aliases last
2311 # show most interesting aliases last
2312 res.extend(showlast)
2312 res.extend(showlast)
2313 print "Total number of aliases:",len(aliases)
2313 print "Total number of aliases:",len(aliases)
2314 return res
2314 return res
2315 try:
2315 try:
2316 alias,cmd = par.split(None,1)
2316 alias,cmd = par.split(None,1)
2317 except:
2317 except:
2318 print OInspect.getdoc(self.magic_alias)
2318 print OInspect.getdoc(self.magic_alias)
2319 else:
2319 else:
2320 nargs = cmd.count('%s')
2320 nargs = cmd.count('%s')
2321 if nargs>0 and cmd.find('%l')>=0:
2321 if nargs>0 and cmd.find('%l')>=0:
2322 error('The %s and %l specifiers are mutually exclusive '
2322 error('The %s and %l specifiers are mutually exclusive '
2323 'in alias definitions.')
2323 'in alias definitions.')
2324 else: # all looks OK
2324 else: # all looks OK
2325 self.shell.alias_table[alias] = (nargs,cmd)
2325 self.shell.alias_table[alias] = (nargs,cmd)
2326 self.shell.alias_table_validate(verbose=0)
2326 self.shell.alias_table_validate(verbose=0)
2327 # end magic_alias
2327 # end magic_alias
2328
2328
2329 def magic_unalias(self, parameter_s = ''):
2329 def magic_unalias(self, parameter_s = ''):
2330 """Remove an alias"""
2330 """Remove an alias"""
2331
2331
2332 aname = parameter_s.strip()
2332 aname = parameter_s.strip()
2333 if aname in self.shell.alias_table:
2333 if aname in self.shell.alias_table:
2334 del self.shell.alias_table[aname]
2334 del self.shell.alias_table[aname]
2335 stored = self.db.get('stored_aliases', {} )
2335 stored = self.db.get('stored_aliases', {} )
2336 if aname in stored:
2336 if aname in stored:
2337 print "Removing %stored alias",aname
2337 print "Removing %stored alias",aname
2338 del stored[aname]
2338 del stored[aname]
2339 self.db['stored_aliases'] = stored
2339 self.db['stored_aliases'] = stored
2340
2340
2341
2341
2342 def magic_rehashx(self, parameter_s = ''):
2342 def magic_rehashx(self, parameter_s = ''):
2343 """Update the alias table with all executable files in $PATH.
2343 """Update the alias table with all executable files in $PATH.
2344
2344
2345 This version explicitly checks that every entry in $PATH is a file
2345 This version explicitly checks that every entry in $PATH is a file
2346 with execute access (os.X_OK), so it is much slower than %rehash.
2346 with execute access (os.X_OK), so it is much slower than %rehash.
2347
2347
2348 Under Windows, it checks executability as a match agains a
2348 Under Windows, it checks executability as a match agains a
2349 '|'-separated string of extensions, stored in the IPython config
2349 '|'-separated string of extensions, stored in the IPython config
2350 variable win_exec_ext. This defaults to 'exe|com|bat'.
2350 variable win_exec_ext. This defaults to 'exe|com|bat'.
2351
2351
2352 This function also resets the root module cache of module completer,
2352 This function also resets the root module cache of module completer,
2353 used on slow filesystems.
2353 used on slow filesystems.
2354 """
2354 """
2355
2355
2356
2356
2357 ip = self.api
2357 ip = self.api
2358
2358
2359 # for the benefit of module completer in ipy_completers.py
2359 # for the benefit of module completer in ipy_completers.py
2360 del ip.db['rootmodules']
2360 del ip.db['rootmodules']
2361
2361
2362 path = [os.path.abspath(os.path.expanduser(p)) for p in
2362 path = [os.path.abspath(os.path.expanduser(p)) for p in
2363 os.environ.get('PATH','').split(os.pathsep)]
2363 os.environ.get('PATH','').split(os.pathsep)]
2364 path = filter(os.path.isdir,path)
2364 path = filter(os.path.isdir,path)
2365
2365
2366 alias_table = self.shell.alias_table
2366 alias_table = self.shell.alias_table
2367 syscmdlist = []
2367 syscmdlist = []
2368 if os.name == 'posix':
2368 if os.name == 'posix':
2369 isexec = lambda fname:os.path.isfile(fname) and \
2369 isexec = lambda fname:os.path.isfile(fname) and \
2370 os.access(fname,os.X_OK)
2370 os.access(fname,os.X_OK)
2371 else:
2371 else:
2372
2372
2373 try:
2373 try:
2374 winext = os.environ['pathext'].replace(';','|').replace('.','')
2374 winext = os.environ['pathext'].replace(';','|').replace('.','')
2375 except KeyError:
2375 except KeyError:
2376 winext = 'exe|com|bat|py'
2376 winext = 'exe|com|bat|py'
2377 if 'py' not in winext:
2377 if 'py' not in winext:
2378 winext += '|py'
2378 winext += '|py'
2379 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2379 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2380 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2380 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2381 savedir = os.getcwd()
2381 savedir = os.getcwd()
2382 try:
2382 try:
2383 # write the whole loop for posix/Windows so we don't have an if in
2383 # write the whole loop for posix/Windows so we don't have an if in
2384 # the innermost part
2384 # the innermost part
2385 if os.name == 'posix':
2385 if os.name == 'posix':
2386 for pdir in path:
2386 for pdir in path:
2387 os.chdir(pdir)
2387 os.chdir(pdir)
2388 for ff in os.listdir(pdir):
2388 for ff in os.listdir(pdir):
2389 if isexec(ff) and ff not in self.shell.no_alias:
2389 if isexec(ff) and ff not in self.shell.no_alias:
2390 # each entry in the alias table must be (N,name),
2390 # each entry in the alias table must be (N,name),
2391 # where N is the number of positional arguments of the
2391 # where N is the number of positional arguments of the
2392 # alias.
2392 # alias.
2393 alias_table[ff] = (0,ff)
2393 alias_table[ff] = (0,ff)
2394 syscmdlist.append(ff)
2394 syscmdlist.append(ff)
2395 else:
2395 else:
2396 for pdir in path:
2396 for pdir in path:
2397 os.chdir(pdir)
2397 os.chdir(pdir)
2398 for ff in os.listdir(pdir):
2398 for ff in os.listdir(pdir):
2399 base, ext = os.path.splitext(ff)
2399 base, ext = os.path.splitext(ff)
2400 if isexec(ff) and base not in self.shell.no_alias:
2400 if isexec(ff) and base not in self.shell.no_alias:
2401 if ext.lower() == '.exe':
2401 if ext.lower() == '.exe':
2402 ff = base
2402 ff = base
2403 alias_table[base.lower()] = (0,ff)
2403 alias_table[base.lower()] = (0,ff)
2404 syscmdlist.append(ff)
2404 syscmdlist.append(ff)
2405 # Make sure the alias table doesn't contain keywords or builtins
2405 # Make sure the alias table doesn't contain keywords or builtins
2406 self.shell.alias_table_validate()
2406 self.shell.alias_table_validate()
2407 # Call again init_auto_alias() so we get 'rm -i' and other
2407 # Call again init_auto_alias() so we get 'rm -i' and other
2408 # modified aliases since %rehashx will probably clobber them
2408 # modified aliases since %rehashx will probably clobber them
2409
2409
2410 # no, we don't want them. if %rehashx clobbers them, good,
2410 # no, we don't want them. if %rehashx clobbers them, good,
2411 # we'll probably get better versions
2411 # we'll probably get better versions
2412 # self.shell.init_auto_alias()
2412 # self.shell.init_auto_alias()
2413 db = ip.db
2413 db = ip.db
2414 db['syscmdlist'] = syscmdlist
2414 db['syscmdlist'] = syscmdlist
2415 finally:
2415 finally:
2416 os.chdir(savedir)
2416 os.chdir(savedir)
2417
2417
2418 def magic_pwd(self, parameter_s = ''):
2418 def magic_pwd(self, parameter_s = ''):
2419 """Return the current working directory path."""
2419 """Return the current working directory path."""
2420 return os.getcwd()
2420 return os.getcwd()
2421
2421
2422 def magic_cd(self, parameter_s=''):
2422 def magic_cd(self, parameter_s=''):
2423 """Change the current working directory.
2423 """Change the current working directory.
2424
2424
2425 This command automatically maintains an internal list of directories
2425 This command automatically maintains an internal list of directories
2426 you visit during your IPython session, in the variable _dh. The
2426 you visit during your IPython session, in the variable _dh. The
2427 command %dhist shows this history nicely formatted. You can also
2427 command %dhist shows this history nicely formatted. You can also
2428 do 'cd -<tab>' to see directory history conveniently.
2428 do 'cd -<tab>' to see directory history conveniently.
2429
2429
2430 Usage:
2430 Usage:
2431
2431
2432 cd 'dir': changes to directory 'dir'.
2432 cd 'dir': changes to directory 'dir'.
2433
2433
2434 cd -: changes to the last visited directory.
2434 cd -: changes to the last visited directory.
2435
2435
2436 cd -<n>: changes to the n-th directory in the directory history.
2436 cd -<n>: changes to the n-th directory in the directory history.
2437
2437
2438 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2438 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2439 (note: cd <bookmark_name> is enough if there is no
2439 (note: cd <bookmark_name> is enough if there is no
2440 directory <bookmark_name>, but a bookmark with the name exists.)
2440 directory <bookmark_name>, but a bookmark with the name exists.)
2441 'cd -b <tab>' allows you to tab-complete bookmark names.
2441 'cd -b <tab>' allows you to tab-complete bookmark names.
2442
2442
2443 Options:
2443 Options:
2444
2444
2445 -q: quiet. Do not print the working directory after the cd command is
2445 -q: quiet. Do not print the working directory after the cd command is
2446 executed. By default IPython's cd command does print this directory,
2446 executed. By default IPython's cd command does print this directory,
2447 since the default prompts do not display path information.
2447 since the default prompts do not display path information.
2448
2448
2449 Note that !cd doesn't work for this purpose because the shell where
2449 Note that !cd doesn't work for this purpose because the shell where
2450 !command runs is immediately discarded after executing 'command'."""
2450 !command runs is immediately discarded after executing 'command'."""
2451
2451
2452 parameter_s = parameter_s.strip()
2452 parameter_s = parameter_s.strip()
2453 #bkms = self.shell.persist.get("bookmarks",{})
2453 #bkms = self.shell.persist.get("bookmarks",{})
2454
2454
2455 numcd = re.match(r'(-)(\d+)$',parameter_s)
2455 numcd = re.match(r'(-)(\d+)$',parameter_s)
2456 # jump in directory history by number
2456 # jump in directory history by number
2457 if numcd:
2457 if numcd:
2458 nn = int(numcd.group(2))
2458 nn = int(numcd.group(2))
2459 try:
2459 try:
2460 ps = self.shell.user_ns['_dh'][nn]
2460 ps = self.shell.user_ns['_dh'][nn]
2461 except IndexError:
2461 except IndexError:
2462 print 'The requested directory does not exist in history.'
2462 print 'The requested directory does not exist in history.'
2463 return
2463 return
2464 else:
2464 else:
2465 opts = {}
2465 opts = {}
2466 else:
2466 else:
2467 #turn all non-space-escaping backslashes to slashes,
2467 #turn all non-space-escaping backslashes to slashes,
2468 # for c:\windows\directory\names\
2468 # for c:\windows\directory\names\
2469 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2469 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2470 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2470 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2471 # jump to previous
2471 # jump to previous
2472 if ps == '-':
2472 if ps == '-':
2473 try:
2473 try:
2474 ps = self.shell.user_ns['_dh'][-2]
2474 ps = self.shell.user_ns['_dh'][-2]
2475 except IndexError:
2475 except IndexError:
2476 print 'No previous directory to change to.'
2476 print 'No previous directory to change to.'
2477 return
2477 return
2478 # jump to bookmark if needed
2478 # jump to bookmark if needed
2479 else:
2479 else:
2480 if not os.path.isdir(ps) or opts.has_key('b'):
2480 if not os.path.isdir(ps) or opts.has_key('b'):
2481 bkms = self.db.get('bookmarks', {})
2481 bkms = self.db.get('bookmarks', {})
2482
2482
2483 if bkms.has_key(ps):
2483 if bkms.has_key(ps):
2484 target = bkms[ps]
2484 target = bkms[ps]
2485 print '(bookmark:%s) -> %s' % (ps,target)
2485 print '(bookmark:%s) -> %s' % (ps,target)
2486 ps = target
2486 ps = target
2487 else:
2487 else:
2488 if opts.has_key('b'):
2488 if opts.has_key('b'):
2489 error("Bookmark '%s' not found. "
2489 error("Bookmark '%s' not found. "
2490 "Use '%%bookmark -l' to see your bookmarks." % ps)
2490 "Use '%%bookmark -l' to see your bookmarks." % ps)
2491 return
2491 return
2492
2492
2493 # at this point ps should point to the target dir
2493 # at this point ps should point to the target dir
2494 if ps:
2494 if ps:
2495 try:
2495 try:
2496 os.chdir(os.path.expanduser(ps))
2496 os.chdir(os.path.expanduser(ps))
2497 if self.shell.rc.term_title:
2497 if self.shell.rc.term_title:
2498 #print 'set term title:',self.shell.rc.term_title # dbg
2498 #print 'set term title:',self.shell.rc.term_title # dbg
2499 ttitle = ("IPy:" + (
2499 ttitle = 'IPy ' + abbrev_cwd()
2500 os.getcwd() == '/' and '/' or \
2501 os.path.basename(os.getcwd())))
2502 platutils.set_term_title(ttitle)
2500 platutils.set_term_title(ttitle)
2503 except OSError:
2501 except OSError:
2504 print sys.exc_info()[1]
2502 print sys.exc_info()[1]
2505 else:
2503 else:
2506 cwd = os.getcwd()
2504 cwd = os.getcwd()
2507 dhist = self.shell.user_ns['_dh']
2505 dhist = self.shell.user_ns['_dh']
2508 dhist.append(cwd)
2506 dhist.append(cwd)
2509 self.db['dhist'] = compress_dhist(dhist)[-100:]
2507 self.db['dhist'] = compress_dhist(dhist)[-100:]
2510
2508
2511 else:
2509 else:
2512 os.chdir(self.shell.home_dir)
2510 os.chdir(self.shell.home_dir)
2513 if self.shell.rc.term_title:
2511 if self.shell.rc.term_title:
2514 platutils.set_term_title("IPy:~")
2512 platutils.set_term_title("IPy ~")
2515 cwd = os.getcwd()
2513 cwd = os.getcwd()
2516 dhist = self.shell.user_ns['_dh']
2514 dhist = self.shell.user_ns['_dh']
2517 dhist.append(cwd)
2515 dhist.append(cwd)
2518 self.db['dhist'] = compress_dhist(dhist)[-100:]
2516 self.db['dhist'] = compress_dhist(dhist)[-100:]
2519 if not 'q' in opts:
2517 if not 'q' in opts:
2520 print self.shell.user_ns['_dh'][-1]
2518 print self.shell.user_ns['_dh'][-1]
2521
2519
2522
2520
2523 def magic_env(self, parameter_s=''):
2521 def magic_env(self, parameter_s=''):
2524 """List environment variables."""
2522 """List environment variables."""
2525
2523
2526 return os.environ.data
2524 return os.environ.data
2527
2525
2528 def magic_pushd(self, parameter_s=''):
2526 def magic_pushd(self, parameter_s=''):
2529 """Place the current dir on stack and change directory.
2527 """Place the current dir on stack and change directory.
2530
2528
2531 Usage:\\
2529 Usage:\\
2532 %pushd ['dirname']
2530 %pushd ['dirname']
2533
2531
2534 %pushd with no arguments does a %pushd to your home directory.
2532 %pushd with no arguments does a %pushd to your home directory.
2535 """
2533 """
2536 if parameter_s == '': parameter_s = '~'
2534 if parameter_s == '': parameter_s = '~'
2537 dir_s = self.shell.dir_stack
2535 dir_s = self.shell.dir_stack
2538 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2536 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2539 os.path.expanduser(self.shell.dir_stack[0]):
2537 os.path.expanduser(self.shell.dir_stack[0]):
2540 try:
2538 try:
2541 self.magic_cd(parameter_s)
2539 self.magic_cd(parameter_s)
2542 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2540 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2543 self.magic_dirs()
2541 self.magic_dirs()
2544 except:
2542 except:
2545 print 'Invalid directory'
2543 print 'Invalid directory'
2546 else:
2544 else:
2547 print 'You are already there!'
2545 print 'You are already there!'
2548
2546
2549 def magic_popd(self, parameter_s=''):
2547 def magic_popd(self, parameter_s=''):
2550 """Change to directory popped off the top of the stack.
2548 """Change to directory popped off the top of the stack.
2551 """
2549 """
2552 if len (self.shell.dir_stack) > 1:
2550 if len (self.shell.dir_stack) > 1:
2553 self.shell.dir_stack.pop(0)
2551 self.shell.dir_stack.pop(0)
2554 self.magic_cd(self.shell.dir_stack[0])
2552 self.magic_cd(self.shell.dir_stack[0])
2555 print self.shell.dir_stack[0]
2553 print self.shell.dir_stack[0]
2556 else:
2554 else:
2557 print "You can't remove the starting directory from the stack:",\
2555 print "You can't remove the starting directory from the stack:",\
2558 self.shell.dir_stack
2556 self.shell.dir_stack
2559
2557
2560 def magic_dirs(self, parameter_s=''):
2558 def magic_dirs(self, parameter_s=''):
2561 """Return the current directory stack."""
2559 """Return the current directory stack."""
2562
2560
2563 return self.shell.dir_stack[:]
2561 return self.shell.dir_stack[:]
2564
2562
2565 def magic_sc(self, parameter_s=''):
2563 def magic_sc(self, parameter_s=''):
2566 """Shell capture - execute a shell command and capture its output.
2564 """Shell capture - execute a shell command and capture its output.
2567
2565
2568 DEPRECATED. Suboptimal, retained for backwards compatibility.
2566 DEPRECATED. Suboptimal, retained for backwards compatibility.
2569
2567
2570 You should use the form 'var = !command' instead. Example:
2568 You should use the form 'var = !command' instead. Example:
2571
2569
2572 "%sc -l myfiles = ls ~" should now be written as
2570 "%sc -l myfiles = ls ~" should now be written as
2573
2571
2574 "myfiles = !ls ~"
2572 "myfiles = !ls ~"
2575
2573
2576 myfiles.s, myfiles.l and myfiles.n still apply as documented
2574 myfiles.s, myfiles.l and myfiles.n still apply as documented
2577 below.
2575 below.
2578
2576
2579 --
2577 --
2580 %sc [options] varname=command
2578 %sc [options] varname=command
2581
2579
2582 IPython will run the given command using commands.getoutput(), and
2580 IPython will run the given command using commands.getoutput(), and
2583 will then update the user's interactive namespace with a variable
2581 will then update the user's interactive namespace with a variable
2584 called varname, containing the value of the call. Your command can
2582 called varname, containing the value of the call. Your command can
2585 contain shell wildcards, pipes, etc.
2583 contain shell wildcards, pipes, etc.
2586
2584
2587 The '=' sign in the syntax is mandatory, and the variable name you
2585 The '=' sign in the syntax is mandatory, and the variable name you
2588 supply must follow Python's standard conventions for valid names.
2586 supply must follow Python's standard conventions for valid names.
2589
2587
2590 (A special format without variable name exists for internal use)
2588 (A special format without variable name exists for internal use)
2591
2589
2592 Options:
2590 Options:
2593
2591
2594 -l: list output. Split the output on newlines into a list before
2592 -l: list output. Split the output on newlines into a list before
2595 assigning it to the given variable. By default the output is stored
2593 assigning it to the given variable. By default the output is stored
2596 as a single string.
2594 as a single string.
2597
2595
2598 -v: verbose. Print the contents of the variable.
2596 -v: verbose. Print the contents of the variable.
2599
2597
2600 In most cases you should not need to split as a list, because the
2598 In most cases you should not need to split as a list, because the
2601 returned value is a special type of string which can automatically
2599 returned value is a special type of string which can automatically
2602 provide its contents either as a list (split on newlines) or as a
2600 provide its contents either as a list (split on newlines) or as a
2603 space-separated string. These are convenient, respectively, either
2601 space-separated string. These are convenient, respectively, either
2604 for sequential processing or to be passed to a shell command.
2602 for sequential processing or to be passed to a shell command.
2605
2603
2606 For example:
2604 For example:
2607
2605
2608 # Capture into variable a
2606 # Capture into variable a
2609 In [9]: sc a=ls *py
2607 In [9]: sc a=ls *py
2610
2608
2611 # a is a string with embedded newlines
2609 # a is a string with embedded newlines
2612 In [10]: a
2610 In [10]: a
2613 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2611 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2614
2612
2615 # which can be seen as a list:
2613 # which can be seen as a list:
2616 In [11]: a.l
2614 In [11]: a.l
2617 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2615 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2618
2616
2619 # or as a whitespace-separated string:
2617 # or as a whitespace-separated string:
2620 In [12]: a.s
2618 In [12]: a.s
2621 Out[12]: 'setup.py win32_manual_post_install.py'
2619 Out[12]: 'setup.py win32_manual_post_install.py'
2622
2620
2623 # a.s is useful to pass as a single command line:
2621 # a.s is useful to pass as a single command line:
2624 In [13]: !wc -l $a.s
2622 In [13]: !wc -l $a.s
2625 146 setup.py
2623 146 setup.py
2626 130 win32_manual_post_install.py
2624 130 win32_manual_post_install.py
2627 276 total
2625 276 total
2628
2626
2629 # while the list form is useful to loop over:
2627 # while the list form is useful to loop over:
2630 In [14]: for f in a.l:
2628 In [14]: for f in a.l:
2631 ....: !wc -l $f
2629 ....: !wc -l $f
2632 ....:
2630 ....:
2633 146 setup.py
2631 146 setup.py
2634 130 win32_manual_post_install.py
2632 130 win32_manual_post_install.py
2635
2633
2636 Similiarly, the lists returned by the -l option are also special, in
2634 Similiarly, the lists returned by the -l option are also special, in
2637 the sense that you can equally invoke the .s attribute on them to
2635 the sense that you can equally invoke the .s attribute on them to
2638 automatically get a whitespace-separated string from their contents:
2636 automatically get a whitespace-separated string from their contents:
2639
2637
2640 In [1]: sc -l b=ls *py
2638 In [1]: sc -l b=ls *py
2641
2639
2642 In [2]: b
2640 In [2]: b
2643 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2641 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2644
2642
2645 In [3]: b.s
2643 In [3]: b.s
2646 Out[3]: 'setup.py win32_manual_post_install.py'
2644 Out[3]: 'setup.py win32_manual_post_install.py'
2647
2645
2648 In summary, both the lists and strings used for ouptut capture have
2646 In summary, both the lists and strings used for ouptut capture have
2649 the following special attributes:
2647 the following special attributes:
2650
2648
2651 .l (or .list) : value as list.
2649 .l (or .list) : value as list.
2652 .n (or .nlstr): value as newline-separated string.
2650 .n (or .nlstr): value as newline-separated string.
2653 .s (or .spstr): value as space-separated string.
2651 .s (or .spstr): value as space-separated string.
2654 """
2652 """
2655
2653
2656 opts,args = self.parse_options(parameter_s,'lv')
2654 opts,args = self.parse_options(parameter_s,'lv')
2657 # Try to get a variable name and command to run
2655 # Try to get a variable name and command to run
2658 try:
2656 try:
2659 # the variable name must be obtained from the parse_options
2657 # the variable name must be obtained from the parse_options
2660 # output, which uses shlex.split to strip options out.
2658 # output, which uses shlex.split to strip options out.
2661 var,_ = args.split('=',1)
2659 var,_ = args.split('=',1)
2662 var = var.strip()
2660 var = var.strip()
2663 # But the the command has to be extracted from the original input
2661 # But the the command has to be extracted from the original input
2664 # parameter_s, not on what parse_options returns, to avoid the
2662 # parameter_s, not on what parse_options returns, to avoid the
2665 # quote stripping which shlex.split performs on it.
2663 # quote stripping which shlex.split performs on it.
2666 _,cmd = parameter_s.split('=',1)
2664 _,cmd = parameter_s.split('=',1)
2667 except ValueError:
2665 except ValueError:
2668 var,cmd = '',''
2666 var,cmd = '',''
2669 # If all looks ok, proceed
2667 # If all looks ok, proceed
2670 out,err = self.shell.getoutputerror(cmd)
2668 out,err = self.shell.getoutputerror(cmd)
2671 if err:
2669 if err:
2672 print >> Term.cerr,err
2670 print >> Term.cerr,err
2673 if opts.has_key('l'):
2671 if opts.has_key('l'):
2674 out = SList(out.split('\n'))
2672 out = SList(out.split('\n'))
2675 else:
2673 else:
2676 out = LSString(out)
2674 out = LSString(out)
2677 if opts.has_key('v'):
2675 if opts.has_key('v'):
2678 print '%s ==\n%s' % (var,pformat(out))
2676 print '%s ==\n%s' % (var,pformat(out))
2679 if var:
2677 if var:
2680 self.shell.user_ns.update({var:out})
2678 self.shell.user_ns.update({var:out})
2681 else:
2679 else:
2682 return out
2680 return out
2683
2681
2684 def magic_sx(self, parameter_s=''):
2682 def magic_sx(self, parameter_s=''):
2685 """Shell execute - run a shell command and capture its output.
2683 """Shell execute - run a shell command and capture its output.
2686
2684
2687 %sx command
2685 %sx command
2688
2686
2689 IPython will run the given command using commands.getoutput(), and
2687 IPython will run the given command using commands.getoutput(), and
2690 return the result formatted as a list (split on '\\n'). Since the
2688 return the result formatted as a list (split on '\\n'). Since the
2691 output is _returned_, it will be stored in ipython's regular output
2689 output is _returned_, it will be stored in ipython's regular output
2692 cache Out[N] and in the '_N' automatic variables.
2690 cache Out[N] and in the '_N' automatic variables.
2693
2691
2694 Notes:
2692 Notes:
2695
2693
2696 1) If an input line begins with '!!', then %sx is automatically
2694 1) If an input line begins with '!!', then %sx is automatically
2697 invoked. That is, while:
2695 invoked. That is, while:
2698 !ls
2696 !ls
2699 causes ipython to simply issue system('ls'), typing
2697 causes ipython to simply issue system('ls'), typing
2700 !!ls
2698 !!ls
2701 is a shorthand equivalent to:
2699 is a shorthand equivalent to:
2702 %sx ls
2700 %sx ls
2703
2701
2704 2) %sx differs from %sc in that %sx automatically splits into a list,
2702 2) %sx differs from %sc in that %sx automatically splits into a list,
2705 like '%sc -l'. The reason for this is to make it as easy as possible
2703 like '%sc -l'. The reason for this is to make it as easy as possible
2706 to process line-oriented shell output via further python commands.
2704 to process line-oriented shell output via further python commands.
2707 %sc is meant to provide much finer control, but requires more
2705 %sc is meant to provide much finer control, but requires more
2708 typing.
2706 typing.
2709
2707
2710 3) Just like %sc -l, this is a list with special attributes:
2708 3) Just like %sc -l, this is a list with special attributes:
2711
2709
2712 .l (or .list) : value as list.
2710 .l (or .list) : value as list.
2713 .n (or .nlstr): value as newline-separated string.
2711 .n (or .nlstr): value as newline-separated string.
2714 .s (or .spstr): value as whitespace-separated string.
2712 .s (or .spstr): value as whitespace-separated string.
2715
2713
2716 This is very useful when trying to use such lists as arguments to
2714 This is very useful when trying to use such lists as arguments to
2717 system commands."""
2715 system commands."""
2718
2716
2719 if parameter_s:
2717 if parameter_s:
2720 out,err = self.shell.getoutputerror(parameter_s)
2718 out,err = self.shell.getoutputerror(parameter_s)
2721 if err:
2719 if err:
2722 print >> Term.cerr,err
2720 print >> Term.cerr,err
2723 return SList(out.split('\n'))
2721 return SList(out.split('\n'))
2724
2722
2725 def magic_bg(self, parameter_s=''):
2723 def magic_bg(self, parameter_s=''):
2726 """Run a job in the background, in a separate thread.
2724 """Run a job in the background, in a separate thread.
2727
2725
2728 For example,
2726 For example,
2729
2727
2730 %bg myfunc(x,y,z=1)
2728 %bg myfunc(x,y,z=1)
2731
2729
2732 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2730 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2733 execution starts, a message will be printed indicating the job
2731 execution starts, a message will be printed indicating the job
2734 number. If your job number is 5, you can use
2732 number. If your job number is 5, you can use
2735
2733
2736 myvar = jobs.result(5) or myvar = jobs[5].result
2734 myvar = jobs.result(5) or myvar = jobs[5].result
2737
2735
2738 to assign this result to variable 'myvar'.
2736 to assign this result to variable 'myvar'.
2739
2737
2740 IPython has a job manager, accessible via the 'jobs' object. You can
2738 IPython has a job manager, accessible via the 'jobs' object. You can
2741 type jobs? to get more information about it, and use jobs.<TAB> to see
2739 type jobs? to get more information about it, and use jobs.<TAB> to see
2742 its attributes. All attributes not starting with an underscore are
2740 its attributes. All attributes not starting with an underscore are
2743 meant for public use.
2741 meant for public use.
2744
2742
2745 In particular, look at the jobs.new() method, which is used to create
2743 In particular, look at the jobs.new() method, which is used to create
2746 new jobs. This magic %bg function is just a convenience wrapper
2744 new jobs. This magic %bg function is just a convenience wrapper
2747 around jobs.new(), for expression-based jobs. If you want to create a
2745 around jobs.new(), for expression-based jobs. If you want to create a
2748 new job with an explicit function object and arguments, you must call
2746 new job with an explicit function object and arguments, you must call
2749 jobs.new() directly.
2747 jobs.new() directly.
2750
2748
2751 The jobs.new docstring also describes in detail several important
2749 The jobs.new docstring also describes in detail several important
2752 caveats associated with a thread-based model for background job
2750 caveats associated with a thread-based model for background job
2753 execution. Type jobs.new? for details.
2751 execution. Type jobs.new? for details.
2754
2752
2755 You can check the status of all jobs with jobs.status().
2753 You can check the status of all jobs with jobs.status().
2756
2754
2757 The jobs variable is set by IPython into the Python builtin namespace.
2755 The jobs variable is set by IPython into the Python builtin namespace.
2758 If you ever declare a variable named 'jobs', you will shadow this
2756 If you ever declare a variable named 'jobs', you will shadow this
2759 name. You can either delete your global jobs variable to regain
2757 name. You can either delete your global jobs variable to regain
2760 access to the job manager, or make a new name and assign it manually
2758 access to the job manager, or make a new name and assign it manually
2761 to the manager (stored in IPython's namespace). For example, to
2759 to the manager (stored in IPython's namespace). For example, to
2762 assign the job manager to the Jobs name, use:
2760 assign the job manager to the Jobs name, use:
2763
2761
2764 Jobs = __builtins__.jobs"""
2762 Jobs = __builtins__.jobs"""
2765
2763
2766 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2764 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2767
2765
2768
2766
2769 def magic_bookmark(self, parameter_s=''):
2767 def magic_bookmark(self, parameter_s=''):
2770 """Manage IPython's bookmark system.
2768 """Manage IPython's bookmark system.
2771
2769
2772 %bookmark <name> - set bookmark to current dir
2770 %bookmark <name> - set bookmark to current dir
2773 %bookmark <name> <dir> - set bookmark to <dir>
2771 %bookmark <name> <dir> - set bookmark to <dir>
2774 %bookmark -l - list all bookmarks
2772 %bookmark -l - list all bookmarks
2775 %bookmark -d <name> - remove bookmark
2773 %bookmark -d <name> - remove bookmark
2776 %bookmark -r - remove all bookmarks
2774 %bookmark -r - remove all bookmarks
2777
2775
2778 You can later on access a bookmarked folder with:
2776 You can later on access a bookmarked folder with:
2779 %cd -b <name>
2777 %cd -b <name>
2780 or simply '%cd <name>' if there is no directory called <name> AND
2778 or simply '%cd <name>' if there is no directory called <name> AND
2781 there is such a bookmark defined.
2779 there is such a bookmark defined.
2782
2780
2783 Your bookmarks persist through IPython sessions, but they are
2781 Your bookmarks persist through IPython sessions, but they are
2784 associated with each profile."""
2782 associated with each profile."""
2785
2783
2786 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2784 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2787 if len(args) > 2:
2785 if len(args) > 2:
2788 error('You can only give at most two arguments')
2786 error('You can only give at most two arguments')
2789 return
2787 return
2790
2788
2791 bkms = self.db.get('bookmarks',{})
2789 bkms = self.db.get('bookmarks',{})
2792
2790
2793 if opts.has_key('d'):
2791 if opts.has_key('d'):
2794 try:
2792 try:
2795 todel = args[0]
2793 todel = args[0]
2796 except IndexError:
2794 except IndexError:
2797 error('You must provide a bookmark to delete')
2795 error('You must provide a bookmark to delete')
2798 else:
2796 else:
2799 try:
2797 try:
2800 del bkms[todel]
2798 del bkms[todel]
2801 except:
2799 except:
2802 error("Can't delete bookmark '%s'" % todel)
2800 error("Can't delete bookmark '%s'" % todel)
2803 elif opts.has_key('r'):
2801 elif opts.has_key('r'):
2804 bkms = {}
2802 bkms = {}
2805 elif opts.has_key('l'):
2803 elif opts.has_key('l'):
2806 bks = bkms.keys()
2804 bks = bkms.keys()
2807 bks.sort()
2805 bks.sort()
2808 if bks:
2806 if bks:
2809 size = max(map(len,bks))
2807 size = max(map(len,bks))
2810 else:
2808 else:
2811 size = 0
2809 size = 0
2812 fmt = '%-'+str(size)+'s -> %s'
2810 fmt = '%-'+str(size)+'s -> %s'
2813 print 'Current bookmarks:'
2811 print 'Current bookmarks:'
2814 for bk in bks:
2812 for bk in bks:
2815 print fmt % (bk,bkms[bk])
2813 print fmt % (bk,bkms[bk])
2816 else:
2814 else:
2817 if not args:
2815 if not args:
2818 error("You must specify the bookmark name")
2816 error("You must specify the bookmark name")
2819 elif len(args)==1:
2817 elif len(args)==1:
2820 bkms[args[0]] = os.getcwd()
2818 bkms[args[0]] = os.getcwd()
2821 elif len(args)==2:
2819 elif len(args)==2:
2822 bkms[args[0]] = args[1]
2820 bkms[args[0]] = args[1]
2823 self.db['bookmarks'] = bkms
2821 self.db['bookmarks'] = bkms
2824
2822
2825 def magic_pycat(self, parameter_s=''):
2823 def magic_pycat(self, parameter_s=''):
2826 """Show a syntax-highlighted file through a pager.
2824 """Show a syntax-highlighted file through a pager.
2827
2825
2828 This magic is similar to the cat utility, but it will assume the file
2826 This magic is similar to the cat utility, but it will assume the file
2829 to be Python source and will show it with syntax highlighting. """
2827 to be Python source and will show it with syntax highlighting. """
2830
2828
2831 try:
2829 try:
2832 filename = get_py_filename(parameter_s)
2830 filename = get_py_filename(parameter_s)
2833 cont = file_read(filename)
2831 cont = file_read(filename)
2834 except IOError:
2832 except IOError:
2835 try:
2833 try:
2836 cont = eval(parameter_s,self.user_ns)
2834 cont = eval(parameter_s,self.user_ns)
2837 except NameError:
2835 except NameError:
2838 cont = None
2836 cont = None
2839 if cont is None:
2837 if cont is None:
2840 print "Error: no such file or variable"
2838 print "Error: no such file or variable"
2841 return
2839 return
2842
2840
2843 page(self.shell.pycolorize(cont),
2841 page(self.shell.pycolorize(cont),
2844 screen_lines=self.shell.rc.screen_length)
2842 screen_lines=self.shell.rc.screen_length)
2845
2843
2846 def magic_cpaste(self, parameter_s=''):
2844 def magic_cpaste(self, parameter_s=''):
2847 """Allows you to paste & execute a pre-formatted code block from clipboard
2845 """Allows you to paste & execute a pre-formatted code block from clipboard
2848
2846
2849 You must terminate the block with '--' (two minus-signs) alone on the
2847 You must terminate the block with '--' (two minus-signs) alone on the
2850 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2848 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2851 is the new sentinel for this operation)
2849 is the new sentinel for this operation)
2852
2850
2853 The block is dedented prior to execution to enable execution of method
2851 The block is dedented prior to execution to enable execution of method
2854 definitions. '>' and '+' characters at the beginning of a line are
2852 definitions. '>' and '+' characters at the beginning of a line are
2855 ignored, to allow pasting directly from e-mails or diff files. The
2853 ignored, to allow pasting directly from e-mails or diff files. The
2856 executed block is also assigned to variable named 'pasted_block' for
2854 executed block is also assigned to variable named 'pasted_block' for
2857 later editing with '%edit pasted_block'.
2855 later editing with '%edit pasted_block'.
2858
2856
2859 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2857 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2860 This assigns the pasted block to variable 'foo' as string, without
2858 This assigns the pasted block to variable 'foo' as string, without
2861 dedenting or executing it.
2859 dedenting or executing it.
2862
2860
2863 Do not be alarmed by garbled output on Windows (it's a readline bug).
2861 Do not be alarmed by garbled output on Windows (it's a readline bug).
2864 Just press enter and type -- (and press enter again) and the block
2862 Just press enter and type -- (and press enter again) and the block
2865 will be what was just pasted.
2863 will be what was just pasted.
2866
2864
2867 IPython statements (magics, shell escapes) are not supported (yet).
2865 IPython statements (magics, shell escapes) are not supported (yet).
2868 """
2866 """
2869 opts,args = self.parse_options(parameter_s,'s:',mode='string')
2867 opts,args = self.parse_options(parameter_s,'s:',mode='string')
2870 par = args.strip()
2868 par = args.strip()
2871 sentinel = opts.get('s','--')
2869 sentinel = opts.get('s','--')
2872
2870
2873 from IPython import iplib
2871 from IPython import iplib
2874 lines = []
2872 lines = []
2875 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
2873 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
2876 while 1:
2874 while 1:
2877 l = iplib.raw_input_original(':')
2875 l = iplib.raw_input_original(':')
2878 if l ==sentinel:
2876 if l ==sentinel:
2879 break
2877 break
2880 lines.append(l.lstrip('>').lstrip('+'))
2878 lines.append(l.lstrip('>').lstrip('+'))
2881 block = "\n".join(lines) + '\n'
2879 block = "\n".join(lines) + '\n'
2882 #print "block:\n",block
2880 #print "block:\n",block
2883 if not par:
2881 if not par:
2884 b = textwrap.dedent(block)
2882 b = textwrap.dedent(block)
2885 exec b in self.user_ns
2883 exec b in self.user_ns
2886 self.user_ns['pasted_block'] = b
2884 self.user_ns['pasted_block'] = b
2887 else:
2885 else:
2888 self.user_ns[par] = block
2886 self.user_ns[par] = block
2889 print "Block assigned to '%s'" % par
2887 print "Block assigned to '%s'" % par
2890
2888
2891 def magic_quickref(self,arg):
2889 def magic_quickref(self,arg):
2892 """ Show a quick reference sheet """
2890 """ Show a quick reference sheet """
2893 import IPython.usage
2891 import IPython.usage
2894 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
2892 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
2895
2893
2896 page(qr)
2894 page(qr)
2897
2895
2898 def magic_upgrade(self,arg):
2896 def magic_upgrade(self,arg):
2899 """ Upgrade your IPython installation
2897 """ Upgrade your IPython installation
2900
2898
2901 This will copy the config files that don't yet exist in your
2899 This will copy the config files that don't yet exist in your
2902 ipython dir from the system config dir. Use this after upgrading
2900 ipython dir from the system config dir. Use this after upgrading
2903 IPython if you don't wish to delete your .ipython dir.
2901 IPython if you don't wish to delete your .ipython dir.
2904
2902
2905 Call with -nolegacy to get rid of ipythonrc* files (recommended for
2903 Call with -nolegacy to get rid of ipythonrc* files (recommended for
2906 new users)
2904 new users)
2907
2905
2908 """
2906 """
2909 ip = self.getapi()
2907 ip = self.getapi()
2910 ipinstallation = path(IPython.__file__).dirname()
2908 ipinstallation = path(IPython.__file__).dirname()
2911 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
2909 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
2912 src_config = ipinstallation / 'UserConfig'
2910 src_config = ipinstallation / 'UserConfig'
2913 userdir = path(ip.options.ipythondir)
2911 userdir = path(ip.options.ipythondir)
2914 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
2912 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
2915 print ">",cmd
2913 print ">",cmd
2916 shell(cmd)
2914 shell(cmd)
2917 if arg == '-nolegacy':
2915 if arg == '-nolegacy':
2918 legacy = userdir.files('ipythonrc*')
2916 legacy = userdir.files('ipythonrc*')
2919 print "Nuking legacy files:",legacy
2917 print "Nuking legacy files:",legacy
2920
2918
2921 [p.remove() for p in legacy]
2919 [p.remove() for p in legacy]
2922 suffix = (sys.platform == 'win32' and '.ini' or '')
2920 suffix = (sys.platform == 'win32' and '.ini' or '')
2923 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
2921 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
2924
2922
2925
2923
2926 def magic_doctest_mode(self,parameter_s=''):
2924 def magic_doctest_mode(self,parameter_s=''):
2927 """Toggle doctest mode on and off.
2925 """Toggle doctest mode on and off.
2928
2926
2929 This mode allows you to toggle the prompt behavior between normal
2927 This mode allows you to toggle the prompt behavior between normal
2930 IPython prompts and ones that are as similar to the default IPython
2928 IPython prompts and ones that are as similar to the default IPython
2931 interpreter as possible.
2929 interpreter as possible.
2932
2930
2933 It also supports the pasting of code snippets that have leading '>>>'
2931 It also supports the pasting of code snippets that have leading '>>>'
2934 and '...' prompts in them. This means that you can paste doctests from
2932 and '...' prompts in them. This means that you can paste doctests from
2935 files or docstrings (even if they have leading whitespace), and the
2933 files or docstrings (even if they have leading whitespace), and the
2936 code will execute correctly. You can then use '%history -tn' to see
2934 code will execute correctly. You can then use '%history -tn' to see
2937 the translated history without line numbers; this will give you the
2935 the translated history without line numbers; this will give you the
2938 input after removal of all the leading prompts and whitespace, which
2936 input after removal of all the leading prompts and whitespace, which
2939 can be pasted back into an editor.
2937 can be pasted back into an editor.
2940
2938
2941 With these features, you can switch into this mode easily whenever you
2939 With these features, you can switch into this mode easily whenever you
2942 need to do testing and changes to doctests, without having to leave
2940 need to do testing and changes to doctests, without having to leave
2943 your existing IPython session.
2941 your existing IPython session.
2944 """
2942 """
2945
2943
2946 # XXX - Fix this to have cleaner activate/deactivate calls.
2944 # XXX - Fix this to have cleaner activate/deactivate calls.
2947 from IPython.Extensions import InterpreterPasteInput as ipaste
2945 from IPython.Extensions import InterpreterPasteInput as ipaste
2948 from IPython.ipstruct import Struct
2946 from IPython.ipstruct import Struct
2949
2947
2950 # Shorthands
2948 # Shorthands
2951 shell = self.shell
2949 shell = self.shell
2952 oc = shell.outputcache
2950 oc = shell.outputcache
2953 rc = shell.rc
2951 rc = shell.rc
2954 meta = shell.meta
2952 meta = shell.meta
2955 # dstore is a data store kept in the instance metadata bag to track any
2953 # dstore is a data store kept in the instance metadata bag to track any
2956 # changes we make, so we can undo them later.
2954 # changes we make, so we can undo them later.
2957 dstore = meta.setdefault('doctest_mode',Struct())
2955 dstore = meta.setdefault('doctest_mode',Struct())
2958 save_dstore = dstore.setdefault
2956 save_dstore = dstore.setdefault
2959
2957
2960 # save a few values we'll need to recover later
2958 # save a few values we'll need to recover later
2961 mode = save_dstore('mode',False)
2959 mode = save_dstore('mode',False)
2962 save_dstore('rc_pprint',rc.pprint)
2960 save_dstore('rc_pprint',rc.pprint)
2963 save_dstore('xmode',shell.InteractiveTB.mode)
2961 save_dstore('xmode',shell.InteractiveTB.mode)
2964 save_dstore('rc_separate_in',rc.separate_in)
2962 save_dstore('rc_separate_in',rc.separate_in)
2965 save_dstore('rc_separate_out',rc.separate_out)
2963 save_dstore('rc_separate_out',rc.separate_out)
2966 save_dstore('rc_separate_out2',rc.separate_out2)
2964 save_dstore('rc_separate_out2',rc.separate_out2)
2967 save_dstore('rc_prompts_pad_left',rc.prompts_pad_left)
2965 save_dstore('rc_prompts_pad_left',rc.prompts_pad_left)
2968
2966
2969 if mode == False:
2967 if mode == False:
2970 # turn on
2968 # turn on
2971 ipaste.activate_prefilter()
2969 ipaste.activate_prefilter()
2972
2970
2973 oc.prompt1.p_template = '>>> '
2971 oc.prompt1.p_template = '>>> '
2974 oc.prompt2.p_template = '... '
2972 oc.prompt2.p_template = '... '
2975 oc.prompt_out.p_template = ''
2973 oc.prompt_out.p_template = ''
2976
2974
2977 oc.prompt1.sep = '\n'
2975 oc.prompt1.sep = '\n'
2978 oc.output_sep = ''
2976 oc.output_sep = ''
2979 oc.output_sep2 = ''
2977 oc.output_sep2 = ''
2980
2978
2981 oc.prompt1.pad_left = oc.prompt2.pad_left = \
2979 oc.prompt1.pad_left = oc.prompt2.pad_left = \
2982 oc.prompt_out.pad_left = False
2980 oc.prompt_out.pad_left = False
2983
2981
2984 rc.pprint = False
2982 rc.pprint = False
2985
2983
2986 shell.magic_xmode('Plain')
2984 shell.magic_xmode('Plain')
2987
2985
2988 else:
2986 else:
2989 # turn off
2987 # turn off
2990 ipaste.deactivate_prefilter()
2988 ipaste.deactivate_prefilter()
2991
2989
2992 oc.prompt1.p_template = rc.prompt_in1
2990 oc.prompt1.p_template = rc.prompt_in1
2993 oc.prompt2.p_template = rc.prompt_in2
2991 oc.prompt2.p_template = rc.prompt_in2
2994 oc.prompt_out.p_template = rc.prompt_out
2992 oc.prompt_out.p_template = rc.prompt_out
2995
2993
2996 oc.prompt1.sep = dstore.rc_separate_in
2994 oc.prompt1.sep = dstore.rc_separate_in
2997 oc.output_sep = dstore.rc_separate_out
2995 oc.output_sep = dstore.rc_separate_out
2998 oc.output_sep2 = dstore.rc_separate_out2
2996 oc.output_sep2 = dstore.rc_separate_out2
2999
2997
3000 oc.prompt1.pad_left = oc.prompt2.pad_left = \
2998 oc.prompt1.pad_left = oc.prompt2.pad_left = \
3001 oc.prompt_out.pad_left = dstore.rc_prompts_pad_left
2999 oc.prompt_out.pad_left = dstore.rc_prompts_pad_left
3002
3000
3003 rc.pprint = dstore.rc_pprint
3001 rc.pprint = dstore.rc_pprint
3004
3002
3005 shell.magic_xmode(dstore.xmode)
3003 shell.magic_xmode(dstore.xmode)
3006
3004
3007 # Store new mode and inform
3005 # Store new mode and inform
3008 dstore.mode = bool(1-int(mode))
3006 dstore.mode = bool(1-int(mode))
3009 print 'Doctest mode is:',
3007 print 'Doctest mode is:',
3010 print ['OFF','ON'][dstore.mode]
3008 print ['OFF','ON'][dstore.mode]
3011
3009
3012 # end Magic
3010 # end Magic
@@ -1,604 +1,609 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Classes for handling input/output prompts.
3 Classes for handling input/output prompts.
4
4
5 $Id: Prompts.py 2601 2007-08-10 07:01:29Z fperez $"""
5 $Id: Prompts.py 2659 2007-08-22 20:21:07Z vivainio $"""
6
6
7 #*****************************************************************************
7 #*****************************************************************************
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 from IPython import Release
14 from IPython import Release
15 __author__ = '%s <%s>' % Release.authors['Fernando']
15 __author__ = '%s <%s>' % Release.authors['Fernando']
16 __license__ = Release.license
16 __license__ = Release.license
17 __version__ = Release.version
17 __version__ = Release.version
18
18
19 #****************************************************************************
19 #****************************************************************************
20 # Required modules
20 # Required modules
21 import __builtin__
21 import __builtin__
22 import os
22 import os
23 import socket
23 import socket
24 import sys
24 import sys
25 import time
25 import time
26
26
27 # IPython's own
27 # IPython's own
28 from IPython import ColorANSI
28 from IPython import ColorANSI
29 from IPython.Itpl import ItplNS
29 from IPython.Itpl import ItplNS
30 from IPython.ipstruct import Struct
30 from IPython.ipstruct import Struct
31 from IPython.macro import Macro
31 from IPython.macro import Macro
32 from IPython.genutils import *
32 from IPython.genutils import *
33 from IPython.ipapi import TryNext
33 from IPython.ipapi import TryNext
34
34
35 #****************************************************************************
35 #****************************************************************************
36 #Color schemes for Prompts.
36 #Color schemes for Prompts.
37
37
38 PromptColors = ColorANSI.ColorSchemeTable()
38 PromptColors = ColorANSI.ColorSchemeTable()
39 InputColors = ColorANSI.InputTermColors # just a shorthand
39 InputColors = ColorANSI.InputTermColors # just a shorthand
40 Colors = ColorANSI.TermColors # just a shorthand
40 Colors = ColorANSI.TermColors # just a shorthand
41
41
42 PromptColors.add_scheme(ColorANSI.ColorScheme(
42 PromptColors.add_scheme(ColorANSI.ColorScheme(
43 'NoColor',
43 'NoColor',
44 in_prompt = InputColors.NoColor, # Input prompt
44 in_prompt = InputColors.NoColor, # Input prompt
45 in_number = InputColors.NoColor, # Input prompt number
45 in_number = InputColors.NoColor, # Input prompt number
46 in_prompt2 = InputColors.NoColor, # Continuation prompt
46 in_prompt2 = InputColors.NoColor, # Continuation prompt
47 in_normal = InputColors.NoColor, # color off (usu. Colors.Normal)
47 in_normal = InputColors.NoColor, # color off (usu. Colors.Normal)
48
48
49 out_prompt = Colors.NoColor, # Output prompt
49 out_prompt = Colors.NoColor, # Output prompt
50 out_number = Colors.NoColor, # Output prompt number
50 out_number = Colors.NoColor, # Output prompt number
51
51
52 normal = Colors.NoColor # color off (usu. Colors.Normal)
52 normal = Colors.NoColor # color off (usu. Colors.Normal)
53 ))
53 ))
54
54
55 # make some schemes as instances so we can copy them for modification easily:
55 # make some schemes as instances so we can copy them for modification easily:
56 __PColLinux = ColorANSI.ColorScheme(
56 __PColLinux = ColorANSI.ColorScheme(
57 'Linux',
57 'Linux',
58 in_prompt = InputColors.Green,
58 in_prompt = InputColors.Green,
59 in_number = InputColors.LightGreen,
59 in_number = InputColors.LightGreen,
60 in_prompt2 = InputColors.Green,
60 in_prompt2 = InputColors.Green,
61 in_normal = InputColors.Normal, # color off (usu. Colors.Normal)
61 in_normal = InputColors.Normal, # color off (usu. Colors.Normal)
62
62
63 out_prompt = Colors.Red,
63 out_prompt = Colors.Red,
64 out_number = Colors.LightRed,
64 out_number = Colors.LightRed,
65
65
66 normal = Colors.Normal
66 normal = Colors.Normal
67 )
67 )
68 # Don't forget to enter it into the table!
68 # Don't forget to enter it into the table!
69 PromptColors.add_scheme(__PColLinux)
69 PromptColors.add_scheme(__PColLinux)
70
70
71 # Slightly modified Linux for light backgrounds
71 # Slightly modified Linux for light backgrounds
72 __PColLightBG = __PColLinux.copy('LightBG')
72 __PColLightBG = __PColLinux.copy('LightBG')
73
73
74 __PColLightBG.colors.update(
74 __PColLightBG.colors.update(
75 in_prompt = InputColors.Blue,
75 in_prompt = InputColors.Blue,
76 in_number = InputColors.LightBlue,
76 in_number = InputColors.LightBlue,
77 in_prompt2 = InputColors.Blue
77 in_prompt2 = InputColors.Blue
78 )
78 )
79 PromptColors.add_scheme(__PColLightBG)
79 PromptColors.add_scheme(__PColLightBG)
80
80
81 del Colors,InputColors
81 del Colors,InputColors
82
82
83 #-----------------------------------------------------------------------------
83 #-----------------------------------------------------------------------------
84 def multiple_replace(dict, text):
84 def multiple_replace(dict, text):
85 """ Replace in 'text' all occurences of any key in the given
85 """ Replace in 'text' all occurences of any key in the given
86 dictionary by its corresponding value. Returns the new string."""
86 dictionary by its corresponding value. Returns the new string."""
87
87
88 # Function by Xavier Defrang, originally found at:
88 # Function by Xavier Defrang, originally found at:
89 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
89 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
90
90
91 # Create a regular expression from the dictionary keys
91 # Create a regular expression from the dictionary keys
92 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
92 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
93 # For each match, look-up corresponding value in dictionary
93 # For each match, look-up corresponding value in dictionary
94 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
94 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
95
95
96 #-----------------------------------------------------------------------------
96 #-----------------------------------------------------------------------------
97 # Special characters that can be used in prompt templates, mainly bash-like
97 # Special characters that can be used in prompt templates, mainly bash-like
98
98
99 # If $HOME isn't defined (Windows), make it an absurd string so that it can
99 # If $HOME isn't defined (Windows), make it an absurd string so that it can
100 # never be expanded out into '~'. Basically anything which can never be a
100 # never be expanded out into '~'. Basically anything which can never be a
101 # reasonable directory name will do, we just want the $HOME -> '~' operation
101 # reasonable directory name will do, we just want the $HOME -> '~' operation
102 # to become a no-op. We pre-compute $HOME here so it's not done on every
102 # to become a no-op. We pre-compute $HOME here so it's not done on every
103 # prompt call.
103 # prompt call.
104
104
105 # FIXME:
105 # FIXME:
106
106
107 # - This should be turned into a class which does proper namespace management,
107 # - This should be turned into a class which does proper namespace management,
108 # since the prompt specials need to be evaluated in a certain namespace.
108 # since the prompt specials need to be evaluated in a certain namespace.
109 # Currently it's just globals, which need to be managed manually by code
109 # Currently it's just globals, which need to be managed manually by code
110 # below.
110 # below.
111
111
112 # - I also need to split up the color schemes from the prompt specials
112 # - I also need to split up the color schemes from the prompt specials
113 # somehow. I don't have a clean design for that quite yet.
113 # somehow. I don't have a clean design for that quite yet.
114
114
115 HOME = os.environ.get("HOME","//////:::::ZZZZZ,,,~~~")
115 HOME = os.environ.get("HOME","//////:::::ZZZZZ,,,~~~")
116
116
117 # We precompute a few more strings here for the prompt_specials, which are
117 # We precompute a few more strings here for the prompt_specials, which are
118 # fixed once ipython starts. This reduces the runtime overhead of computing
118 # fixed once ipython starts. This reduces the runtime overhead of computing
119 # prompt strings.
119 # prompt strings.
120 USER = os.environ.get("USER")
120 USER = os.environ.get("USER")
121 HOSTNAME = socket.gethostname()
121 HOSTNAME = socket.gethostname()
122 HOSTNAME_SHORT = HOSTNAME.split(".")[0]
122 HOSTNAME_SHORT = HOSTNAME.split(".")[0]
123 ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0]
123 ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0]
124
124
125 prompt_specials_color = {
125 prompt_specials_color = {
126 # Prompt/history count
126 # Prompt/history count
127 '%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
127 '%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
128 r'\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
128 r'\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
129 # Just the prompt counter number, WITHOUT any coloring wrappers, so users
129 # Just the prompt counter number, WITHOUT any coloring wrappers, so users
130 # can get numbers displayed in whatever color they want.
130 # can get numbers displayed in whatever color they want.
131 r'\N': '${self.cache.prompt_count}',
131 r'\N': '${self.cache.prompt_count}',
132 # Prompt/history count, with the actual digits replaced by dots. Used
132 # Prompt/history count, with the actual digits replaced by dots. Used
133 # mainly in continuation prompts (prompt_in2)
133 # mainly in continuation prompts (prompt_in2)
134 r'\D': '${"."*len(str(self.cache.prompt_count))}',
134 r'\D': '${"."*len(str(self.cache.prompt_count))}',
135 # Current working directory
135 # Current working directory
136 r'\w': '${os.getcwd()}',
136 r'\w': '${os.getcwd()}',
137 # Current time
137 # Current time
138 r'\t' : '${time.strftime("%H:%M:%S")}',
138 r'\t' : '${time.strftime("%H:%M:%S")}',
139 # Basename of current working directory.
139 # Basename of current working directory.
140 # (use os.sep to make this portable across OSes)
140 # (use os.sep to make this portable across OSes)
141 r'\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
141 r'\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
142 # These X<N> are an extension to the normal bash prompts. They return
142 # These X<N> are an extension to the normal bash prompts. They return
143 # N terms of the path, after replacing $HOME with '~'
143 # N terms of the path, after replacing $HOME with '~'
144 r'\X0': '${os.getcwd().replace("%s","~")}' % HOME,
144 r'\X0': '${os.getcwd().replace("%s","~")}' % HOME,
145 r'\X1': '${self.cwd_filt(1)}',
145 r'\X1': '${self.cwd_filt(1)}',
146 r'\X2': '${self.cwd_filt(2)}',
146 r'\X2': '${self.cwd_filt(2)}',
147 r'\X3': '${self.cwd_filt(3)}',
147 r'\X3': '${self.cwd_filt(3)}',
148 r'\X4': '${self.cwd_filt(4)}',
148 r'\X4': '${self.cwd_filt(4)}',
149 r'\X5': '${self.cwd_filt(5)}',
149 r'\X5': '${self.cwd_filt(5)}',
150 # Y<N> are similar to X<N>, but they show '~' if it's the directory
150 # Y<N> are similar to X<N>, but they show '~' if it's the directory
151 # N+1 in the list. Somewhat like %cN in tcsh.
151 # N+1 in the list. Somewhat like %cN in tcsh.
152 r'\Y0': '${self.cwd_filt2(0)}',
152 r'\Y0': '${self.cwd_filt2(0)}',
153 r'\Y1': '${self.cwd_filt2(1)}',
153 r'\Y1': '${self.cwd_filt2(1)}',
154 r'\Y2': '${self.cwd_filt2(2)}',
154 r'\Y2': '${self.cwd_filt2(2)}',
155 r'\Y3': '${self.cwd_filt2(3)}',
155 r'\Y3': '${self.cwd_filt2(3)}',
156 r'\Y4': '${self.cwd_filt2(4)}',
156 r'\Y4': '${self.cwd_filt2(4)}',
157 r'\Y5': '${self.cwd_filt2(5)}',
157 r'\Y5': '${self.cwd_filt2(5)}',
158 # Hostname up to first .
158 # Hostname up to first .
159 r'\h': HOSTNAME_SHORT,
159 r'\h': HOSTNAME_SHORT,
160 # Full hostname
160 # Full hostname
161 r'\H': HOSTNAME,
161 r'\H': HOSTNAME,
162 # Username of current user
162 # Username of current user
163 r'\u': USER,
163 r'\u': USER,
164 # Escaped '\'
164 # Escaped '\'
165 '\\\\': '\\',
165 '\\\\': '\\',
166 # Newline
166 # Newline
167 r'\n': '\n',
167 r'\n': '\n',
168 # Carriage return
168 # Carriage return
169 r'\r': '\r',
169 r'\r': '\r',
170 # Release version
170 # Release version
171 r'\v': __version__,
171 r'\v': __version__,
172 # Root symbol ($ or #)
172 # Root symbol ($ or #)
173 r'\$': ROOT_SYMBOL,
173 r'\$': ROOT_SYMBOL,
174 }
174 }
175
175
176 # A copy of the prompt_specials dictionary but with all color escapes removed,
176 # A copy of the prompt_specials dictionary but with all color escapes removed,
177 # so we can correctly compute the prompt length for the auto_rewrite method.
177 # so we can correctly compute the prompt length for the auto_rewrite method.
178 prompt_specials_nocolor = prompt_specials_color.copy()
178 prompt_specials_nocolor = prompt_specials_color.copy()
179 prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
179 prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
180 prompt_specials_nocolor[r'\#'] = '${self.cache.prompt_count}'
180 prompt_specials_nocolor[r'\#'] = '${self.cache.prompt_count}'
181
181
182 # Add in all the InputTermColors color escapes as valid prompt characters.
182 # Add in all the InputTermColors color escapes as valid prompt characters.
183 # They all get added as \\C_COLORNAME, so that we don't have any conflicts
183 # They all get added as \\C_COLORNAME, so that we don't have any conflicts
184 # with a color name which may begin with a letter used by any other of the
184 # with a color name which may begin with a letter used by any other of the
185 # allowed specials. This of course means that \\C will never be allowed for
185 # allowed specials. This of course means that \\C will never be allowed for
186 # anything else.
186 # anything else.
187 input_colors = ColorANSI.InputTermColors
187 input_colors = ColorANSI.InputTermColors
188 for _color in dir(input_colors):
188 for _color in dir(input_colors):
189 if _color[0] != '_':
189 if _color[0] != '_':
190 c_name = r'\C_'+_color
190 c_name = r'\C_'+_color
191 prompt_specials_color[c_name] = getattr(input_colors,_color)
191 prompt_specials_color[c_name] = getattr(input_colors,_color)
192 prompt_specials_nocolor[c_name] = ''
192 prompt_specials_nocolor[c_name] = ''
193
193
194 # we default to no color for safety. Note that prompt_specials is a global
194 # we default to no color for safety. Note that prompt_specials is a global
195 # variable used by all prompt objects.
195 # variable used by all prompt objects.
196 prompt_specials = prompt_specials_nocolor
196 prompt_specials = prompt_specials_nocolor
197
197
198 #-----------------------------------------------------------------------------
198 #-----------------------------------------------------------------------------
199 def str_safe(arg):
199 def str_safe(arg):
200 """Convert to a string, without ever raising an exception.
200 """Convert to a string, without ever raising an exception.
201
201
202 If str(arg) fails, <ERROR: ... > is returned, where ... is the exception
202 If str(arg) fails, <ERROR: ... > is returned, where ... is the exception
203 error message."""
203 error message."""
204
204
205 try:
205 try:
206 out = str(arg)
206 out = str(arg)
207 except UnicodeError:
207 except UnicodeError:
208 try:
208 try:
209 out = arg.encode('utf_8','replace')
209 out = arg.encode('utf_8','replace')
210 except Exception,msg:
210 except Exception,msg:
211 # let's keep this little duplication here, so that the most common
211 # let's keep this little duplication here, so that the most common
212 # case doesn't suffer from a double try wrapping.
212 # case doesn't suffer from a double try wrapping.
213 out = '<ERROR: %s>' % msg
213 out = '<ERROR: %s>' % msg
214 except Exception,msg:
214 except Exception,msg:
215 out = '<ERROR: %s>' % msg
215 out = '<ERROR: %s>' % msg
216 return out
216 return out
217
217
218 class BasePrompt(object):
218 class BasePrompt(object):
219 """Interactive prompt similar to Mathematica's."""
219 """Interactive prompt similar to Mathematica's."""
220
220
221 def _get_p_template(self):
221 def _get_p_template(self):
222 return self._p_template
222 return self._p_template
223
223
224 def _set_p_template(self,val):
224 def _set_p_template(self,val):
225 self._p_template = val
225 self._p_template = val
226 self.set_p_str()
226 self.set_p_str()
227
227
228 p_template = property(_get_p_template,_set_p_template,
228 p_template = property(_get_p_template,_set_p_template,
229 doc='Template for prompt string creation')
229 doc='Template for prompt string creation')
230
230
231 def __init__(self,cache,sep,prompt,pad_left=False):
231 def __init__(self,cache,sep,prompt,pad_left=False):
232
232
233 # Hack: we access information about the primary prompt through the
233 # Hack: we access information about the primary prompt through the
234 # cache argument. We need this, because we want the secondary prompt
234 # cache argument. We need this, because we want the secondary prompt
235 # to be aligned with the primary one. Color table info is also shared
235 # to be aligned with the primary one. Color table info is also shared
236 # by all prompt classes through the cache. Nice OO spaghetti code!
236 # by all prompt classes through the cache. Nice OO spaghetti code!
237 self.cache = cache
237 self.cache = cache
238 self.sep = sep
238 self.sep = sep
239
239
240 # regexp to count the number of spaces at the end of a prompt
240 # regexp to count the number of spaces at the end of a prompt
241 # expression, useful for prompt auto-rewriting
241 # expression, useful for prompt auto-rewriting
242 self.rspace = re.compile(r'(\s*)$')
242 self.rspace = re.compile(r'(\s*)$')
243 # Flag to left-pad prompt strings to match the length of the primary
243 # Flag to left-pad prompt strings to match the length of the primary
244 # prompt
244 # prompt
245 self.pad_left = pad_left
245 self.pad_left = pad_left
246
246
247 # Set template to create each actual prompt (where numbers change).
247 # Set template to create each actual prompt (where numbers change).
248 # Use a property
248 # Use a property
249 self.p_template = prompt
249 self.p_template = prompt
250 self.set_p_str()
250 self.set_p_str()
251
251
252 def set_p_str(self):
252 def set_p_str(self):
253 """ Set the interpolating prompt strings.
253 """ Set the interpolating prompt strings.
254
254
255 This must be called every time the color settings change, because the
255 This must be called every time the color settings change, because the
256 prompt_specials global may have changed."""
256 prompt_specials global may have changed."""
257
257
258 import os,time # needed in locals for prompt string handling
258 import os,time # needed in locals for prompt string handling
259 loc = locals()
259 loc = locals()
260 self.p_str = ItplNS('%s%s%s' %
260 self.p_str = ItplNS('%s%s%s' %
261 ('${self.sep}${self.col_p}',
261 ('${self.sep}${self.col_p}',
262 multiple_replace(prompt_specials, self.p_template),
262 multiple_replace(prompt_specials, self.p_template),
263 '${self.col_norm}'),self.cache.user_ns,loc)
263 '${self.col_norm}'),self.cache.user_ns,loc)
264
264
265 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
265 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
266 self.p_template),
266 self.p_template),
267 self.cache.user_ns,loc)
267 self.cache.user_ns,loc)
268
268
269 def write(self,msg): # dbg
269 def write(self,msg): # dbg
270 sys.stdout.write(msg)
270 sys.stdout.write(msg)
271 return ''
271 return ''
272
272
273 def __str__(self):
273 def __str__(self):
274 """Return a string form of the prompt.
274 """Return a string form of the prompt.
275
275
276 This for is useful for continuation and output prompts, since it is
276 This for is useful for continuation and output prompts, since it is
277 left-padded to match lengths with the primary one (if the
277 left-padded to match lengths with the primary one (if the
278 self.pad_left attribute is set)."""
278 self.pad_left attribute is set)."""
279
279
280 out_str = str_safe(self.p_str)
280 out_str = str_safe(self.p_str)
281 if self.pad_left:
281 if self.pad_left:
282 # We must find the amount of padding required to match lengths,
282 # We must find the amount of padding required to match lengths,
283 # taking the color escapes (which are invisible on-screen) into
283 # taking the color escapes (which are invisible on-screen) into
284 # account.
284 # account.
285 esc_pad = len(out_str) - len(str_safe(self.p_str_nocolor))
285 esc_pad = len(out_str) - len(str_safe(self.p_str_nocolor))
286 format = '%%%ss' % (len(str(self.cache.last_prompt))+esc_pad)
286 format = '%%%ss' % (len(str(self.cache.last_prompt))+esc_pad)
287 return format % out_str
287 return format % out_str
288 else:
288 else:
289 return out_str
289 return out_str
290
290
291 # these path filters are put in as methods so that we can control the
291 # these path filters are put in as methods so that we can control the
292 # namespace where the prompt strings get evaluated
292 # namespace where the prompt strings get evaluated
293 def cwd_filt(self,depth):
293 def cwd_filt(self,depth):
294 """Return the last depth elements of the current working directory.
294 """Return the last depth elements of the current working directory.
295
295
296 $HOME is always replaced with '~'.
296 $HOME is always replaced with '~'.
297 If depth==0, the full path is returned."""
297 If depth==0, the full path is returned."""
298
298
299 cwd = os.getcwd().replace(HOME,"~")
299 cwd = os.getcwd().replace(HOME,"~")
300 out = os.sep.join(cwd.split(os.sep)[-depth:])
300 out = os.sep.join(cwd.split(os.sep)[-depth:])
301 if out:
301 if out:
302 return out
302 return out
303 else:
303 else:
304 return os.sep
304 return os.sep
305
305
306 def cwd_filt2(self,depth):
306 def cwd_filt2(self,depth):
307 """Return the last depth elements of the current working directory.
307 """Return the last depth elements of the current working directory.
308
308
309 $HOME is always replaced with '~'.
309 $HOME is always replaced with '~'.
310 If depth==0, the full path is returned."""
310 If depth==0, the full path is returned."""
311
311
312 cwd = os.getcwd().replace(HOME,"~").split(os.sep)
312 full_cwd = os.getcwd()
313 cwd = full_cwd.replace(HOME,"~").split(os.sep)
313 if '~' in cwd and len(cwd) == depth+1:
314 if '~' in cwd and len(cwd) == depth+1:
314 depth += 1
315 depth += 1
315 out = os.sep.join(cwd[-depth:])
316 drivepart = ''
317 if sys.platform == 'win32' and len(cwd) > depth:
318 drivepart = os.path.splitdrive(full_cwd)[0]
319 out = drivepart + '/'.join(cwd[-depth:])
320
316 if out:
321 if out:
317 return out
322 return out
318 else:
323 else:
319 return os.sep
324 return os.sep
320
325
321 class Prompt1(BasePrompt):
326 class Prompt1(BasePrompt):
322 """Input interactive prompt similar to Mathematica's."""
327 """Input interactive prompt similar to Mathematica's."""
323
328
324 def __init__(self,cache,sep='\n',prompt='In [\\#]: ',pad_left=True):
329 def __init__(self,cache,sep='\n',prompt='In [\\#]: ',pad_left=True):
325 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
330 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
326
331
327 def set_colors(self):
332 def set_colors(self):
328 self.set_p_str()
333 self.set_p_str()
329 Colors = self.cache.color_table.active_colors # shorthand
334 Colors = self.cache.color_table.active_colors # shorthand
330 self.col_p = Colors.in_prompt
335 self.col_p = Colors.in_prompt
331 self.col_num = Colors.in_number
336 self.col_num = Colors.in_number
332 self.col_norm = Colors.in_normal
337 self.col_norm = Colors.in_normal
333 # We need a non-input version of these escapes for the '--->'
338 # We need a non-input version of these escapes for the '--->'
334 # auto-call prompts used in the auto_rewrite() method.
339 # auto-call prompts used in the auto_rewrite() method.
335 self.col_p_ni = self.col_p.replace('\001','').replace('\002','')
340 self.col_p_ni = self.col_p.replace('\001','').replace('\002','')
336 self.col_norm_ni = Colors.normal
341 self.col_norm_ni = Colors.normal
337
342
338 def __str__(self):
343 def __str__(self):
339 self.cache.prompt_count += 1
344 self.cache.prompt_count += 1
340 self.cache.last_prompt = str_safe(self.p_str_nocolor).split('\n')[-1]
345 self.cache.last_prompt = str_safe(self.p_str_nocolor).split('\n')[-1]
341 return str_safe(self.p_str)
346 return str_safe(self.p_str)
342
347
343 def auto_rewrite(self):
348 def auto_rewrite(self):
344 """Print a string of the form '--->' which lines up with the previous
349 """Print a string of the form '--->' which lines up with the previous
345 input string. Useful for systems which re-write the user input when
350 input string. Useful for systems which re-write the user input when
346 handling automatically special syntaxes."""
351 handling automatically special syntaxes."""
347
352
348 curr = str(self.cache.last_prompt)
353 curr = str(self.cache.last_prompt)
349 nrspaces = len(self.rspace.search(curr).group())
354 nrspaces = len(self.rspace.search(curr).group())
350 return '%s%s>%s%s' % (self.col_p_ni,'-'*(len(curr)-nrspaces-1),
355 return '%s%s>%s%s' % (self.col_p_ni,'-'*(len(curr)-nrspaces-1),
351 ' '*nrspaces,self.col_norm_ni)
356 ' '*nrspaces,self.col_norm_ni)
352
357
353 class PromptOut(BasePrompt):
358 class PromptOut(BasePrompt):
354 """Output interactive prompt similar to Mathematica's."""
359 """Output interactive prompt similar to Mathematica's."""
355
360
356 def __init__(self,cache,sep='',prompt='Out[\\#]: ',pad_left=True):
361 def __init__(self,cache,sep='',prompt='Out[\\#]: ',pad_left=True):
357 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
362 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
358 if not self.p_template:
363 if not self.p_template:
359 self.__str__ = lambda: ''
364 self.__str__ = lambda: ''
360
365
361 def set_colors(self):
366 def set_colors(self):
362 self.set_p_str()
367 self.set_p_str()
363 Colors = self.cache.color_table.active_colors # shorthand
368 Colors = self.cache.color_table.active_colors # shorthand
364 self.col_p = Colors.out_prompt
369 self.col_p = Colors.out_prompt
365 self.col_num = Colors.out_number
370 self.col_num = Colors.out_number
366 self.col_norm = Colors.normal
371 self.col_norm = Colors.normal
367
372
368 class Prompt2(BasePrompt):
373 class Prompt2(BasePrompt):
369 """Interactive continuation prompt."""
374 """Interactive continuation prompt."""
370
375
371 def __init__(self,cache,prompt=' .\\D.: ',pad_left=True):
376 def __init__(self,cache,prompt=' .\\D.: ',pad_left=True):
372 self.cache = cache
377 self.cache = cache
373 self.p_template = prompt
378 self.p_template = prompt
374 self.pad_left = pad_left
379 self.pad_left = pad_left
375 self.set_p_str()
380 self.set_p_str()
376
381
377 def set_p_str(self):
382 def set_p_str(self):
378 import os,time # needed in locals for prompt string handling
383 import os,time # needed in locals for prompt string handling
379 loc = locals()
384 loc = locals()
380 self.p_str = ItplNS('%s%s%s' %
385 self.p_str = ItplNS('%s%s%s' %
381 ('${self.col_p2}',
386 ('${self.col_p2}',
382 multiple_replace(prompt_specials, self.p_template),
387 multiple_replace(prompt_specials, self.p_template),
383 '$self.col_norm'),
388 '$self.col_norm'),
384 self.cache.user_ns,loc)
389 self.cache.user_ns,loc)
385 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
390 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
386 self.p_template),
391 self.p_template),
387 self.cache.user_ns,loc)
392 self.cache.user_ns,loc)
388
393
389 def set_colors(self):
394 def set_colors(self):
390 self.set_p_str()
395 self.set_p_str()
391 Colors = self.cache.color_table.active_colors
396 Colors = self.cache.color_table.active_colors
392 self.col_p2 = Colors.in_prompt2
397 self.col_p2 = Colors.in_prompt2
393 self.col_norm = Colors.in_normal
398 self.col_norm = Colors.in_normal
394 # FIXME (2004-06-16) HACK: prevent crashes for users who haven't
399 # FIXME (2004-06-16) HACK: prevent crashes for users who haven't
395 # updated their prompt_in2 definitions. Remove eventually.
400 # updated their prompt_in2 definitions. Remove eventually.
396 self.col_p = Colors.out_prompt
401 self.col_p = Colors.out_prompt
397 self.col_num = Colors.out_number
402 self.col_num = Colors.out_number
398
403
399
404
400 #-----------------------------------------------------------------------------
405 #-----------------------------------------------------------------------------
401 class CachedOutput:
406 class CachedOutput:
402 """Class for printing output from calculations while keeping a cache of
407 """Class for printing output from calculations while keeping a cache of
403 reults. It dynamically creates global variables prefixed with _ which
408 reults. It dynamically creates global variables prefixed with _ which
404 contain these results.
409 contain these results.
405
410
406 Meant to be used as a sys.displayhook replacement, providing numbered
411 Meant to be used as a sys.displayhook replacement, providing numbered
407 prompts and cache services.
412 prompts and cache services.
408
413
409 Initialize with initial and final values for cache counter (this defines
414 Initialize with initial and final values for cache counter (this defines
410 the maximum size of the cache."""
415 the maximum size of the cache."""
411
416
412 def __init__(self,shell,cache_size,Pprint,
417 def __init__(self,shell,cache_size,Pprint,
413 colors='NoColor',input_sep='\n',
418 colors='NoColor',input_sep='\n',
414 output_sep='\n',output_sep2='',
419 output_sep='\n',output_sep2='',
415 ps1 = None, ps2 = None,ps_out = None,pad_left=True):
420 ps1 = None, ps2 = None,ps_out = None,pad_left=True):
416
421
417 cache_size_min = 3
422 cache_size_min = 3
418 if cache_size <= 0:
423 if cache_size <= 0:
419 self.do_full_cache = 0
424 self.do_full_cache = 0
420 cache_size = 0
425 cache_size = 0
421 elif cache_size < cache_size_min:
426 elif cache_size < cache_size_min:
422 self.do_full_cache = 0
427 self.do_full_cache = 0
423 cache_size = 0
428 cache_size = 0
424 warn('caching was disabled (min value for cache size is %s).' %
429 warn('caching was disabled (min value for cache size is %s).' %
425 cache_size_min,level=3)
430 cache_size_min,level=3)
426 else:
431 else:
427 self.do_full_cache = 1
432 self.do_full_cache = 1
428
433
429 self.cache_size = cache_size
434 self.cache_size = cache_size
430 self.input_sep = input_sep
435 self.input_sep = input_sep
431
436
432 # we need a reference to the user-level namespace
437 # we need a reference to the user-level namespace
433 self.shell = shell
438 self.shell = shell
434 self.user_ns = shell.user_ns
439 self.user_ns = shell.user_ns
435 # and to the user's input
440 # and to the user's input
436 self.input_hist = shell.input_hist
441 self.input_hist = shell.input_hist
437 # and to the user's logger, for logging output
442 # and to the user's logger, for logging output
438 self.logger = shell.logger
443 self.logger = shell.logger
439
444
440 # Set input prompt strings and colors
445 # Set input prompt strings and colors
441 if cache_size == 0:
446 if cache_size == 0:
442 if ps1.find('%n') > -1 or ps1.find(r'\#') > -1 \
447 if ps1.find('%n') > -1 or ps1.find(r'\#') > -1 \
443 or ps1.find(r'\N') > -1:
448 or ps1.find(r'\N') > -1:
444 ps1 = '>>> '
449 ps1 = '>>> '
445 if ps2.find('%n') > -1 or ps2.find(r'\#') > -1 \
450 if ps2.find('%n') > -1 or ps2.find(r'\#') > -1 \
446 or ps2.find(r'\N') > -1:
451 or ps2.find(r'\N') > -1:
447 ps2 = '... '
452 ps2 = '... '
448 self.ps1_str = self._set_prompt_str(ps1,'In [\\#]: ','>>> ')
453 self.ps1_str = self._set_prompt_str(ps1,'In [\\#]: ','>>> ')
449 self.ps2_str = self._set_prompt_str(ps2,' .\\D.: ','... ')
454 self.ps2_str = self._set_prompt_str(ps2,' .\\D.: ','... ')
450 self.ps_out_str = self._set_prompt_str(ps_out,'Out[\\#]: ','')
455 self.ps_out_str = self._set_prompt_str(ps_out,'Out[\\#]: ','')
451
456
452 self.color_table = PromptColors
457 self.color_table = PromptColors
453 self.prompt1 = Prompt1(self,sep=input_sep,prompt=self.ps1_str,
458 self.prompt1 = Prompt1(self,sep=input_sep,prompt=self.ps1_str,
454 pad_left=pad_left)
459 pad_left=pad_left)
455 self.prompt2 = Prompt2(self,prompt=self.ps2_str,pad_left=pad_left)
460 self.prompt2 = Prompt2(self,prompt=self.ps2_str,pad_left=pad_left)
456 self.prompt_out = PromptOut(self,sep='',prompt=self.ps_out_str,
461 self.prompt_out = PromptOut(self,sep='',prompt=self.ps_out_str,
457 pad_left=pad_left)
462 pad_left=pad_left)
458 self.set_colors(colors)
463 self.set_colors(colors)
459
464
460 # other more normal stuff
465 # other more normal stuff
461 # b/c each call to the In[] prompt raises it by 1, even the first.
466 # b/c each call to the In[] prompt raises it by 1, even the first.
462 self.prompt_count = 0
467 self.prompt_count = 0
463 # Store the last prompt string each time, we need it for aligning
468 # Store the last prompt string each time, we need it for aligning
464 # continuation and auto-rewrite prompts
469 # continuation and auto-rewrite prompts
465 self.last_prompt = ''
470 self.last_prompt = ''
466 self.Pprint = Pprint
471 self.Pprint = Pprint
467 self.output_sep = output_sep
472 self.output_sep = output_sep
468 self.output_sep2 = output_sep2
473 self.output_sep2 = output_sep2
469 self._,self.__,self.___ = '','',''
474 self._,self.__,self.___ = '','',''
470 self.pprint_types = map(type,[(),[],{}])
475 self.pprint_types = map(type,[(),[],{}])
471
476
472 # these are deliberately global:
477 # these are deliberately global:
473 to_user_ns = {'_':self._,'__':self.__,'___':self.___}
478 to_user_ns = {'_':self._,'__':self.__,'___':self.___}
474 self.user_ns.update(to_user_ns)
479 self.user_ns.update(to_user_ns)
475
480
476 def _set_prompt_str(self,p_str,cache_def,no_cache_def):
481 def _set_prompt_str(self,p_str,cache_def,no_cache_def):
477 if p_str is None:
482 if p_str is None:
478 if self.do_full_cache:
483 if self.do_full_cache:
479 return cache_def
484 return cache_def
480 else:
485 else:
481 return no_cache_def
486 return no_cache_def
482 else:
487 else:
483 return p_str
488 return p_str
484
489
485 def set_colors(self,colors):
490 def set_colors(self,colors):
486 """Set the active color scheme and configure colors for the three
491 """Set the active color scheme and configure colors for the three
487 prompt subsystems."""
492 prompt subsystems."""
488
493
489 # FIXME: the prompt_specials global should be gobbled inside this
494 # FIXME: the prompt_specials global should be gobbled inside this
490 # class instead. Do it when cleaning up the whole 3-prompt system.
495 # class instead. Do it when cleaning up the whole 3-prompt system.
491 global prompt_specials
496 global prompt_specials
492 if colors.lower()=='nocolor':
497 if colors.lower()=='nocolor':
493 prompt_specials = prompt_specials_nocolor
498 prompt_specials = prompt_specials_nocolor
494 else:
499 else:
495 prompt_specials = prompt_specials_color
500 prompt_specials = prompt_specials_color
496
501
497 self.color_table.set_active_scheme(colors)
502 self.color_table.set_active_scheme(colors)
498 self.prompt1.set_colors()
503 self.prompt1.set_colors()
499 self.prompt2.set_colors()
504 self.prompt2.set_colors()
500 self.prompt_out.set_colors()
505 self.prompt_out.set_colors()
501
506
502 def __call__(self,arg=None):
507 def __call__(self,arg=None):
503 """Printing with history cache management.
508 """Printing with history cache management.
504
509
505 This is invoked everytime the interpreter needs to print, and is
510 This is invoked everytime the interpreter needs to print, and is
506 activated by setting the variable sys.displayhook to it."""
511 activated by setting the variable sys.displayhook to it."""
507
512
508 # If something injected a '_' variable in __builtin__, delete
513 # If something injected a '_' variable in __builtin__, delete
509 # ipython's automatic one so we don't clobber that. gettext() in
514 # ipython's automatic one so we don't clobber that. gettext() in
510 # particular uses _, so we need to stay away from it.
515 # particular uses _, so we need to stay away from it.
511 if '_' in __builtin__.__dict__:
516 if '_' in __builtin__.__dict__:
512 try:
517 try:
513 del self.user_ns['_']
518 del self.user_ns['_']
514 except KeyError:
519 except KeyError:
515 pass
520 pass
516 if arg is not None:
521 if arg is not None:
517 cout_write = Term.cout.write # fast lookup
522 cout_write = Term.cout.write # fast lookup
518 # first handle the cache and counters
523 # first handle the cache and counters
519
524
520 # do not print output if input ends in ';'
525 # do not print output if input ends in ';'
521 if self.input_hist[self.prompt_count].endswith(';\n'):
526 if self.input_hist[self.prompt_count].endswith(';\n'):
522 return
527 return
523 # don't use print, puts an extra space
528 # don't use print, puts an extra space
524 cout_write(self.output_sep)
529 cout_write(self.output_sep)
525 outprompt = self.shell.hooks.generate_output_prompt()
530 outprompt = self.shell.hooks.generate_output_prompt()
526 if self.do_full_cache:
531 if self.do_full_cache:
527 cout_write(outprompt)
532 cout_write(outprompt)
528
533
529 # and now call a possibly user-defined print mechanism
534 # and now call a possibly user-defined print mechanism
530 manipulated_val = self.display(arg)
535 manipulated_val = self.display(arg)
531
536
532 # user display hooks can change the variable to be stored in
537 # user display hooks can change the variable to be stored in
533 # output history
538 # output history
534
539
535 if manipulated_val is not None:
540 if manipulated_val is not None:
536 arg = manipulated_val
541 arg = manipulated_val
537
542
538 # avoid recursive reference when displaying _oh/Out
543 # avoid recursive reference when displaying _oh/Out
539 if arg is not self.user_ns['_oh']:
544 if arg is not self.user_ns['_oh']:
540 self.update(arg)
545 self.update(arg)
541
546
542 if self.logger.log_output:
547 if self.logger.log_output:
543 self.logger.log_write(repr(arg),'output')
548 self.logger.log_write(repr(arg),'output')
544 cout_write(self.output_sep2)
549 cout_write(self.output_sep2)
545 Term.cout.flush()
550 Term.cout.flush()
546
551
547 def _display(self,arg):
552 def _display(self,arg):
548 """Default printer method, uses pprint.
553 """Default printer method, uses pprint.
549
554
550 Do ip.set_hook("result_display", my_displayhook) for custom result
555 Do ip.set_hook("result_display", my_displayhook) for custom result
551 display, e.g. when your own objects need special formatting.
556 display, e.g. when your own objects need special formatting.
552 """
557 """
553 try:
558 try:
554 return IPython.generics.result_display(arg)
559 return IPython.generics.result_display(arg)
555 except TryNext:
560 except TryNext:
556 return self.shell.hooks.result_display(arg)
561 return self.shell.hooks.result_display(arg)
557
562
558 # Assign the default display method:
563 # Assign the default display method:
559 display = _display
564 display = _display
560
565
561 def update(self,arg):
566 def update(self,arg):
562 #print '***cache_count', self.cache_count # dbg
567 #print '***cache_count', self.cache_count # dbg
563 if len(self.user_ns['_oh']) >= self.cache_size and self.do_full_cache:
568 if len(self.user_ns['_oh']) >= self.cache_size and self.do_full_cache:
564 warn('Output cache limit (currently '+
569 warn('Output cache limit (currently '+
565 `self.cache_size`+' entries) hit.\n'
570 `self.cache_size`+' entries) hit.\n'
566 'Flushing cache and resetting history counter...\n'
571 'Flushing cache and resetting history counter...\n'
567 'The only history variables available will be _,__,___ and _1\n'
572 'The only history variables available will be _,__,___ and _1\n'
568 'with the current result.')
573 'with the current result.')
569
574
570 self.flush()
575 self.flush()
571 # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise
576 # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise
572 # we cause buggy behavior for things like gettext).
577 # we cause buggy behavior for things like gettext).
573 if '_' not in __builtin__.__dict__:
578 if '_' not in __builtin__.__dict__:
574 self.___ = self.__
579 self.___ = self.__
575 self.__ = self._
580 self.__ = self._
576 self._ = arg
581 self._ = arg
577 self.user_ns.update({'_':self._,'__':self.__,'___':self.___})
582 self.user_ns.update({'_':self._,'__':self.__,'___':self.___})
578
583
579 # hackish access to top-level namespace to create _1,_2... dynamically
584 # hackish access to top-level namespace to create _1,_2... dynamically
580 to_main = {}
585 to_main = {}
581 if self.do_full_cache:
586 if self.do_full_cache:
582 new_result = '_'+`self.prompt_count`
587 new_result = '_'+`self.prompt_count`
583 to_main[new_result] = arg
588 to_main[new_result] = arg
584 self.user_ns.update(to_main)
589 self.user_ns.update(to_main)
585 self.user_ns['_oh'][self.prompt_count] = arg
590 self.user_ns['_oh'][self.prompt_count] = arg
586
591
587 def flush(self):
592 def flush(self):
588 if not self.do_full_cache:
593 if not self.do_full_cache:
589 raise ValueError,"You shouldn't have reached the cache flush "\
594 raise ValueError,"You shouldn't have reached the cache flush "\
590 "if full caching is not enabled!"
595 "if full caching is not enabled!"
591 # delete auto-generated vars from global namespace
596 # delete auto-generated vars from global namespace
592
597
593 for n in range(1,self.prompt_count + 1):
598 for n in range(1,self.prompt_count + 1):
594 key = '_'+`n`
599 key = '_'+`n`
595 try:
600 try:
596 del self.user_ns[key]
601 del self.user_ns[key]
597 except: pass
602 except: pass
598 self.user_ns['_oh'].clear()
603 self.user_ns['_oh'].clear()
599
604
600 if '_' not in __builtin__.__dict__:
605 if '_' not in __builtin__.__dict__:
601 self.user_ns.update({'_':None,'__':None, '___':None})
606 self.user_ns.update({'_':None,'__':None, '___':None})
602 import gc
607 import gc
603 gc.collect() # xxx needed?
608 gc.collect() # xxx needed?
604
609
@@ -1,1874 +1,1887 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 General purpose utilities.
3 General purpose utilities.
4
4
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 2602 2007-08-12 22:45:38Z fperez $"""
8 $Id: genutils.py 2659 2007-08-22 20:21:07Z vivainio $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
12 #
12 #
13 # Distributed under the terms of the BSD License. The full license is in
13 # Distributed under the terms of the BSD License. The full license is in
14 # the file COPYING, distributed as part of this software.
14 # the file COPYING, distributed as part of this software.
15 #*****************************************************************************
15 #*****************************************************************************
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>' % Release.authors['Fernando']
18 __author__ = '%s <%s>' % Release.authors['Fernando']
19 __license__ = Release.license
19 __license__ = Release.license
20
20
21 #****************************************************************************
21 #****************************************************************************
22 # required modules from the Python standard library
22 # required modules from the Python standard library
23 import __main__
23 import __main__
24 import commands
24 import commands
25 import os
25 import os
26 import re
26 import re
27 import shlex
27 import shlex
28 import shutil
28 import shutil
29 import sys
29 import sys
30 import tempfile
30 import tempfile
31 import time
31 import time
32 import types
32 import types
33 import warnings
33 import warnings
34
34
35 # Other IPython utilities
35 # Other IPython utilities
36 import IPython
36 import IPython
37 from IPython.Itpl import Itpl,itpl,printpl
37 from IPython.Itpl import Itpl,itpl,printpl
38 from IPython import DPyGetOpt, platutils
38 from IPython import DPyGetOpt, platutils
39 from IPython.generics import result_display
39 from IPython.generics import result_display
40 from path import path
40 from path import path
41 if os.name == "nt":
41 if os.name == "nt":
42 from IPython.winconsole import get_console_size
42 from IPython.winconsole import get_console_size
43
43
44 #****************************************************************************
44 #****************************************************************************
45 # Exceptions
45 # Exceptions
46 class Error(Exception):
46 class Error(Exception):
47 """Base class for exceptions in this module."""
47 """Base class for exceptions in this module."""
48 pass
48 pass
49
49
50 #----------------------------------------------------------------------------
50 #----------------------------------------------------------------------------
51 class IOStream:
51 class IOStream:
52 def __init__(self,stream,fallback):
52 def __init__(self,stream,fallback):
53 if not hasattr(stream,'write') or not hasattr(stream,'flush'):
53 if not hasattr(stream,'write') or not hasattr(stream,'flush'):
54 stream = fallback
54 stream = fallback
55 self.stream = stream
55 self.stream = stream
56 self._swrite = stream.write
56 self._swrite = stream.write
57 self.flush = stream.flush
57 self.flush = stream.flush
58
58
59 def write(self,data):
59 def write(self,data):
60 try:
60 try:
61 self._swrite(data)
61 self._swrite(data)
62 except:
62 except:
63 try:
63 try:
64 # print handles some unicode issues which may trip a plain
64 # print handles some unicode issues which may trip a plain
65 # write() call. Attempt to emulate write() by using a
65 # write() call. Attempt to emulate write() by using a
66 # trailing comma
66 # trailing comma
67 print >> self.stream, data,
67 print >> self.stream, data,
68 except:
68 except:
69 # if we get here, something is seriously broken.
69 # if we get here, something is seriously broken.
70 print >> sys.stderr, \
70 print >> sys.stderr, \
71 'ERROR - failed to write data to stream:', self.stream
71 'ERROR - failed to write data to stream:', self.stream
72
72
73 def close(self):
73 def close(self):
74 pass
74 pass
75
75
76
76
77 class IOTerm:
77 class IOTerm:
78 """ Term holds the file or file-like objects for handling I/O operations.
78 """ Term holds the file or file-like objects for handling I/O operations.
79
79
80 These are normally just sys.stdin, sys.stdout and sys.stderr but for
80 These are normally just sys.stdin, sys.stdout and sys.stderr but for
81 Windows they can can replaced to allow editing the strings before they are
81 Windows they can can replaced to allow editing the strings before they are
82 displayed."""
82 displayed."""
83
83
84 # In the future, having IPython channel all its I/O operations through
84 # In the future, having IPython channel all its I/O operations through
85 # this class will make it easier to embed it into other environments which
85 # this class will make it easier to embed it into other environments which
86 # are not a normal terminal (such as a GUI-based shell)
86 # are not a normal terminal (such as a GUI-based shell)
87 def __init__(self,cin=None,cout=None,cerr=None):
87 def __init__(self,cin=None,cout=None,cerr=None):
88 self.cin = IOStream(cin,sys.stdin)
88 self.cin = IOStream(cin,sys.stdin)
89 self.cout = IOStream(cout,sys.stdout)
89 self.cout = IOStream(cout,sys.stdout)
90 self.cerr = IOStream(cerr,sys.stderr)
90 self.cerr = IOStream(cerr,sys.stderr)
91
91
92 # Global variable to be used for all I/O
92 # Global variable to be used for all I/O
93 Term = IOTerm()
93 Term = IOTerm()
94
94
95 import IPython.rlineimpl as readline
95 import IPython.rlineimpl as readline
96 # Remake Term to use the readline i/o facilities
96 # Remake Term to use the readline i/o facilities
97 if sys.platform == 'win32' and readline.have_readline:
97 if sys.platform == 'win32' and readline.have_readline:
98
98
99 Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile)
99 Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile)
100
100
101
101
102 #****************************************************************************
102 #****************************************************************************
103 # Generic warning/error printer, used by everything else
103 # Generic warning/error printer, used by everything else
104 def warn(msg,level=2,exit_val=1):
104 def warn(msg,level=2,exit_val=1):
105 """Standard warning printer. Gives formatting consistency.
105 """Standard warning printer. Gives formatting consistency.
106
106
107 Output is sent to Term.cerr (sys.stderr by default).
107 Output is sent to Term.cerr (sys.stderr by default).
108
108
109 Options:
109 Options:
110
110
111 -level(2): allows finer control:
111 -level(2): allows finer control:
112 0 -> Do nothing, dummy function.
112 0 -> Do nothing, dummy function.
113 1 -> Print message.
113 1 -> Print message.
114 2 -> Print 'WARNING:' + message. (Default level).
114 2 -> Print 'WARNING:' + message. (Default level).
115 3 -> Print 'ERROR:' + message.
115 3 -> Print 'ERROR:' + message.
116 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
116 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
117
117
118 -exit_val (1): exit value returned by sys.exit() for a level 4
118 -exit_val (1): exit value returned by sys.exit() for a level 4
119 warning. Ignored for all other levels."""
119 warning. Ignored for all other levels."""
120
120
121 if level>0:
121 if level>0:
122 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
122 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
123 print >> Term.cerr, '%s%s' % (header[level],msg)
123 print >> Term.cerr, '%s%s' % (header[level],msg)
124 if level == 4:
124 if level == 4:
125 print >> Term.cerr,'Exiting.\n'
125 print >> Term.cerr,'Exiting.\n'
126 sys.exit(exit_val)
126 sys.exit(exit_val)
127
127
128 def info(msg):
128 def info(msg):
129 """Equivalent to warn(msg,level=1)."""
129 """Equivalent to warn(msg,level=1)."""
130
130
131 warn(msg,level=1)
131 warn(msg,level=1)
132
132
133 def error(msg):
133 def error(msg):
134 """Equivalent to warn(msg,level=3)."""
134 """Equivalent to warn(msg,level=3)."""
135
135
136 warn(msg,level=3)
136 warn(msg,level=3)
137
137
138 def fatal(msg,exit_val=1):
138 def fatal(msg,exit_val=1):
139 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
139 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
140
140
141 warn(msg,exit_val=exit_val,level=4)
141 warn(msg,exit_val=exit_val,level=4)
142
142
143 #---------------------------------------------------------------------------
143 #---------------------------------------------------------------------------
144 # Debugging routines
144 # Debugging routines
145 #
145 #
146 def debugx(expr,pre_msg=''):
146 def debugx(expr,pre_msg=''):
147 """Print the value of an expression from the caller's frame.
147 """Print the value of an expression from the caller's frame.
148
148
149 Takes an expression, evaluates it in the caller's frame and prints both
149 Takes an expression, evaluates it in the caller's frame and prints both
150 the given expression and the resulting value (as well as a debug mark
150 the given expression and the resulting value (as well as a debug mark
151 indicating the name of the calling function. The input must be of a form
151 indicating the name of the calling function. The input must be of a form
152 suitable for eval().
152 suitable for eval().
153
153
154 An optional message can be passed, which will be prepended to the printed
154 An optional message can be passed, which will be prepended to the printed
155 expr->value pair."""
155 expr->value pair."""
156
156
157 cf = sys._getframe(1)
157 cf = sys._getframe(1)
158 print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr,
158 print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr,
159 eval(expr,cf.f_globals,cf.f_locals))
159 eval(expr,cf.f_globals,cf.f_locals))
160
160
161 # deactivate it by uncommenting the following line, which makes it a no-op
161 # deactivate it by uncommenting the following line, which makes it a no-op
162 #def debugx(expr,pre_msg=''): pass
162 #def debugx(expr,pre_msg=''): pass
163
163
164 #----------------------------------------------------------------------------
164 #----------------------------------------------------------------------------
165 StringTypes = types.StringTypes
165 StringTypes = types.StringTypes
166
166
167 # Basic timing functionality
167 # Basic timing functionality
168
168
169 # If possible (Unix), use the resource module instead of time.clock()
169 # If possible (Unix), use the resource module instead of time.clock()
170 try:
170 try:
171 import resource
171 import resource
172 def clocku():
172 def clocku():
173 """clocku() -> floating point number
173 """clocku() -> floating point number
174
174
175 Return the *USER* CPU time in seconds since the start of the process.
175 Return the *USER* CPU time in seconds since the start of the process.
176 This is done via a call to resource.getrusage, so it avoids the
176 This is done via a call to resource.getrusage, so it avoids the
177 wraparound problems in time.clock()."""
177 wraparound problems in time.clock()."""
178
178
179 return resource.getrusage(resource.RUSAGE_SELF)[0]
179 return resource.getrusage(resource.RUSAGE_SELF)[0]
180
180
181 def clocks():
181 def clocks():
182 """clocks() -> floating point number
182 """clocks() -> floating point number
183
183
184 Return the *SYSTEM* CPU time in seconds since the start of the process.
184 Return the *SYSTEM* CPU time in seconds since the start of the process.
185 This is done via a call to resource.getrusage, so it avoids the
185 This is done via a call to resource.getrusage, so it avoids the
186 wraparound problems in time.clock()."""
186 wraparound problems in time.clock()."""
187
187
188 return resource.getrusage(resource.RUSAGE_SELF)[1]
188 return resource.getrusage(resource.RUSAGE_SELF)[1]
189
189
190 def clock():
190 def clock():
191 """clock() -> floating point number
191 """clock() -> floating point number
192
192
193 Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of
193 Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of
194 the process. This is done via a call to resource.getrusage, so it
194 the process. This is done via a call to resource.getrusage, so it
195 avoids the wraparound problems in time.clock()."""
195 avoids the wraparound problems in time.clock()."""
196
196
197 u,s = resource.getrusage(resource.RUSAGE_SELF)[:2]
197 u,s = resource.getrusage(resource.RUSAGE_SELF)[:2]
198 return u+s
198 return u+s
199
199
200 def clock2():
200 def clock2():
201 """clock2() -> (t_user,t_system)
201 """clock2() -> (t_user,t_system)
202
202
203 Similar to clock(), but return a tuple of user/system times."""
203 Similar to clock(), but return a tuple of user/system times."""
204 return resource.getrusage(resource.RUSAGE_SELF)[:2]
204 return resource.getrusage(resource.RUSAGE_SELF)[:2]
205
205
206 except ImportError:
206 except ImportError:
207 # There is no distinction of user/system time under windows, so we just use
207 # There is no distinction of user/system time under windows, so we just use
208 # time.clock() for everything...
208 # time.clock() for everything...
209 clocku = clocks = clock = time.clock
209 clocku = clocks = clock = time.clock
210 def clock2():
210 def clock2():
211 """Under windows, system CPU time can't be measured.
211 """Under windows, system CPU time can't be measured.
212
212
213 This just returns clock() and zero."""
213 This just returns clock() and zero."""
214 return time.clock(),0.0
214 return time.clock(),0.0
215
215
216 def timings_out(reps,func,*args,**kw):
216 def timings_out(reps,func,*args,**kw):
217 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
217 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
218
218
219 Execute a function reps times, return a tuple with the elapsed total
219 Execute a function reps times, return a tuple with the elapsed total
220 CPU time in seconds, the time per call and the function's output.
220 CPU time in seconds, the time per call and the function's output.
221
221
222 Under Unix, the return value is the sum of user+system time consumed by
222 Under Unix, the return value is the sum of user+system time consumed by
223 the process, computed via the resource module. This prevents problems
223 the process, computed via the resource module. This prevents problems
224 related to the wraparound effect which the time.clock() function has.
224 related to the wraparound effect which the time.clock() function has.
225
225
226 Under Windows the return value is in wall clock seconds. See the
226 Under Windows the return value is in wall clock seconds. See the
227 documentation for the time module for more details."""
227 documentation for the time module for more details."""
228
228
229 reps = int(reps)
229 reps = int(reps)
230 assert reps >=1, 'reps must be >= 1'
230 assert reps >=1, 'reps must be >= 1'
231 if reps==1:
231 if reps==1:
232 start = clock()
232 start = clock()
233 out = func(*args,**kw)
233 out = func(*args,**kw)
234 tot_time = clock()-start
234 tot_time = clock()-start
235 else:
235 else:
236 rng = xrange(reps-1) # the last time is executed separately to store output
236 rng = xrange(reps-1) # the last time is executed separately to store output
237 start = clock()
237 start = clock()
238 for dummy in rng: func(*args,**kw)
238 for dummy in rng: func(*args,**kw)
239 out = func(*args,**kw) # one last time
239 out = func(*args,**kw) # one last time
240 tot_time = clock()-start
240 tot_time = clock()-start
241 av_time = tot_time / reps
241 av_time = tot_time / reps
242 return tot_time,av_time,out
242 return tot_time,av_time,out
243
243
244 def timings(reps,func,*args,**kw):
244 def timings(reps,func,*args,**kw):
245 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
245 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
246
246
247 Execute a function reps times, return a tuple with the elapsed total CPU
247 Execute a function reps times, return a tuple with the elapsed total CPU
248 time in seconds and the time per call. These are just the first two values
248 time in seconds and the time per call. These are just the first two values
249 in timings_out()."""
249 in timings_out()."""
250
250
251 return timings_out(reps,func,*args,**kw)[0:2]
251 return timings_out(reps,func,*args,**kw)[0:2]
252
252
253 def timing(func,*args,**kw):
253 def timing(func,*args,**kw):
254 """timing(func,*args,**kw) -> t_total
254 """timing(func,*args,**kw) -> t_total
255
255
256 Execute a function once, return the elapsed total CPU time in
256 Execute a function once, return the elapsed total CPU time in
257 seconds. This is just the first value in timings_out()."""
257 seconds. This is just the first value in timings_out()."""
258
258
259 return timings_out(1,func,*args,**kw)[0]
259 return timings_out(1,func,*args,**kw)[0]
260
260
261 #****************************************************************************
261 #****************************************************************************
262 # file and system
262 # file and system
263
263
264 def arg_split(s,posix=False):
264 def arg_split(s,posix=False):
265 """Split a command line's arguments in a shell-like manner.
265 """Split a command line's arguments in a shell-like manner.
266
266
267 This is a modified version of the standard library's shlex.split()
267 This is a modified version of the standard library's shlex.split()
268 function, but with a default of posix=False for splitting, so that quotes
268 function, but with a default of posix=False for splitting, so that quotes
269 in inputs are respected."""
269 in inputs are respected."""
270
270
271 # XXX - there may be unicode-related problems here!!! I'm not sure that
271 # XXX - there may be unicode-related problems here!!! I'm not sure that
272 # shlex is truly unicode-safe, so it might be necessary to do
272 # shlex is truly unicode-safe, so it might be necessary to do
273 #
273 #
274 # s = s.encode(sys.stdin.encoding)
274 # s = s.encode(sys.stdin.encoding)
275 #
275 #
276 # first, to ensure that shlex gets a normal string. Input from anyone who
276 # first, to ensure that shlex gets a normal string. Input from anyone who
277 # knows more about unicode and shlex than I would be good to have here...
277 # knows more about unicode and shlex than I would be good to have here...
278 lex = shlex.shlex(s, posix=posix)
278 lex = shlex.shlex(s, posix=posix)
279 lex.whitespace_split = True
279 lex.whitespace_split = True
280 return list(lex)
280 return list(lex)
281
281
282 def system(cmd,verbose=0,debug=0,header=''):
282 def system(cmd,verbose=0,debug=0,header=''):
283 """Execute a system command, return its exit status.
283 """Execute a system command, return its exit status.
284
284
285 Options:
285 Options:
286
286
287 - verbose (0): print the command to be executed.
287 - verbose (0): print the command to be executed.
288
288
289 - debug (0): only print, do not actually execute.
289 - debug (0): only print, do not actually execute.
290
290
291 - header (''): Header to print on screen prior to the executed command (it
291 - header (''): Header to print on screen prior to the executed command (it
292 is only prepended to the command, no newlines are added).
292 is only prepended to the command, no newlines are added).
293
293
294 Note: a stateful version of this function is available through the
294 Note: a stateful version of this function is available through the
295 SystemExec class."""
295 SystemExec class."""
296
296
297 stat = 0
297 stat = 0
298 if verbose or debug: print header+cmd
298 if verbose or debug: print header+cmd
299 sys.stdout.flush()
299 sys.stdout.flush()
300 if not debug: stat = os.system(cmd)
300 if not debug: stat = os.system(cmd)
301 return stat
301 return stat
302
302
303 def abbrev_cwd():
304 """ Return abbreviated version of cwd, e.g. d:mydir """
305 cwd = os.getcwd()
306 drivepart = ''
307 if sys.platform == 'win32':
308 if len(cwd) < 4:
309 return cwd
310 drivepart = os.path.splitdrive(cwd)[0]
311 return (drivepart + (
312 cwd == '/' and '/' or \
313 os.path.basename(cwd)))
314
315
303 # This function is used by ipython in a lot of places to make system calls.
316 # This function is used by ipython in a lot of places to make system calls.
304 # We need it to be slightly different under win32, due to the vagaries of
317 # We need it to be slightly different under win32, due to the vagaries of
305 # 'network shares'. A win32 override is below.
318 # 'network shares'. A win32 override is below.
306
319
307 def shell(cmd,verbose=0,debug=0,header=''):
320 def shell(cmd,verbose=0,debug=0,header=''):
308 """Execute a command in the system shell, always return None.
321 """Execute a command in the system shell, always return None.
309
322
310 Options:
323 Options:
311
324
312 - verbose (0): print the command to be executed.
325 - verbose (0): print the command to be executed.
313
326
314 - debug (0): only print, do not actually execute.
327 - debug (0): only print, do not actually execute.
315
328
316 - header (''): Header to print on screen prior to the executed command (it
329 - header (''): Header to print on screen prior to the executed command (it
317 is only prepended to the command, no newlines are added).
330 is only prepended to the command, no newlines are added).
318
331
319 Note: this is similar to genutils.system(), but it returns None so it can
332 Note: this is similar to genutils.system(), but it returns None so it can
320 be conveniently used in interactive loops without getting the return value
333 be conveniently used in interactive loops without getting the return value
321 (typically 0) printed many times."""
334 (typically 0) printed many times."""
322
335
323 stat = 0
336 stat = 0
324 if verbose or debug: print header+cmd
337 if verbose or debug: print header+cmd
325 # flush stdout so we don't mangle python's buffering
338 # flush stdout so we don't mangle python's buffering
326 sys.stdout.flush()
339 sys.stdout.flush()
327
340
328 if not debug:
341 if not debug:
329 platutils.set_term_title("IPy:" + cmd)
342 platutils.set_term_title("IPy " + cmd)
330 os.system(cmd)
343 os.system(cmd)
331 platutils.set_term_title("IPy:" + os.path.basename(os.getcwd()))
344 platutils.set_term_title("IPy " + abbrev_cwd())
332
345
333 # override shell() for win32 to deal with network shares
346 # override shell() for win32 to deal with network shares
334 if os.name in ('nt','dos'):
347 if os.name in ('nt','dos'):
335
348
336 shell_ori = shell
349 shell_ori = shell
337
350
338 def shell(cmd,verbose=0,debug=0,header=''):
351 def shell(cmd,verbose=0,debug=0,header=''):
339 if os.getcwd().startswith(r"\\"):
352 if os.getcwd().startswith(r"\\"):
340 path = os.getcwd()
353 path = os.getcwd()
341 # change to c drive (cannot be on UNC-share when issuing os.system,
354 # change to c drive (cannot be on UNC-share when issuing os.system,
342 # as cmd.exe cannot handle UNC addresses)
355 # as cmd.exe cannot handle UNC addresses)
343 os.chdir("c:")
356 os.chdir("c:")
344 # issue pushd to the UNC-share and then run the command
357 # issue pushd to the UNC-share and then run the command
345 try:
358 try:
346 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
359 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
347 finally:
360 finally:
348 os.chdir(path)
361 os.chdir(path)
349 else:
362 else:
350 shell_ori(cmd,verbose,debug,header)
363 shell_ori(cmd,verbose,debug,header)
351
364
352 shell.__doc__ = shell_ori.__doc__
365 shell.__doc__ = shell_ori.__doc__
353
366
354 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
367 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
355 """Dummy substitute for perl's backquotes.
368 """Dummy substitute for perl's backquotes.
356
369
357 Executes a command and returns the output.
370 Executes a command and returns the output.
358
371
359 Accepts the same arguments as system(), plus:
372 Accepts the same arguments as system(), plus:
360
373
361 - split(0): if true, the output is returned as a list split on newlines.
374 - split(0): if true, the output is returned as a list split on newlines.
362
375
363 Note: a stateful version of this function is available through the
376 Note: a stateful version of this function is available through the
364 SystemExec class.
377 SystemExec class.
365
378
366 This is pretty much deprecated and rarely used,
379 This is pretty much deprecated and rarely used,
367 genutils.getoutputerror may be what you need.
380 genutils.getoutputerror may be what you need.
368
381
369 """
382 """
370
383
371 if verbose or debug: print header+cmd
384 if verbose or debug: print header+cmd
372 if not debug:
385 if not debug:
373 output = os.popen(cmd).read()
386 output = os.popen(cmd).read()
374 # stipping last \n is here for backwards compat.
387 # stipping last \n is here for backwards compat.
375 if output.endswith('\n'):
388 if output.endswith('\n'):
376 output = output[:-1]
389 output = output[:-1]
377 if split:
390 if split:
378 return output.split('\n')
391 return output.split('\n')
379 else:
392 else:
380 return output
393 return output
381
394
382 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
395 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
383 """Return (standard output,standard error) of executing cmd in a shell.
396 """Return (standard output,standard error) of executing cmd in a shell.
384
397
385 Accepts the same arguments as system(), plus:
398 Accepts the same arguments as system(), plus:
386
399
387 - split(0): if true, each of stdout/err is returned as a list split on
400 - split(0): if true, each of stdout/err is returned as a list split on
388 newlines.
401 newlines.
389
402
390 Note: a stateful version of this function is available through the
403 Note: a stateful version of this function is available through the
391 SystemExec class."""
404 SystemExec class."""
392
405
393 if verbose or debug: print header+cmd
406 if verbose or debug: print header+cmd
394 if not cmd:
407 if not cmd:
395 if split:
408 if split:
396 return [],[]
409 return [],[]
397 else:
410 else:
398 return '',''
411 return '',''
399 if not debug:
412 if not debug:
400 pin,pout,perr = os.popen3(cmd)
413 pin,pout,perr = os.popen3(cmd)
401 tout = pout.read().rstrip()
414 tout = pout.read().rstrip()
402 terr = perr.read().rstrip()
415 terr = perr.read().rstrip()
403 pin.close()
416 pin.close()
404 pout.close()
417 pout.close()
405 perr.close()
418 perr.close()
406 if split:
419 if split:
407 return tout.split('\n'),terr.split('\n')
420 return tout.split('\n'),terr.split('\n')
408 else:
421 else:
409 return tout,terr
422 return tout,terr
410
423
411 # for compatibility with older naming conventions
424 # for compatibility with older naming conventions
412 xsys = system
425 xsys = system
413 bq = getoutput
426 bq = getoutput
414
427
415 class SystemExec:
428 class SystemExec:
416 """Access the system and getoutput functions through a stateful interface.
429 """Access the system and getoutput functions through a stateful interface.
417
430
418 Note: here we refer to the system and getoutput functions from this
431 Note: here we refer to the system and getoutput functions from this
419 library, not the ones from the standard python library.
432 library, not the ones from the standard python library.
420
433
421 This class offers the system and getoutput functions as methods, but the
434 This class offers the system and getoutput functions as methods, but the
422 verbose, debug and header parameters can be set for the instance (at
435 verbose, debug and header parameters can be set for the instance (at
423 creation time or later) so that they don't need to be specified on each
436 creation time or later) so that they don't need to be specified on each
424 call.
437 call.
425
438
426 For efficiency reasons, there's no way to override the parameters on a
439 For efficiency reasons, there's no way to override the parameters on a
427 per-call basis other than by setting instance attributes. If you need
440 per-call basis other than by setting instance attributes. If you need
428 local overrides, it's best to directly call system() or getoutput().
441 local overrides, it's best to directly call system() or getoutput().
429
442
430 The following names are provided as alternate options:
443 The following names are provided as alternate options:
431 - xsys: alias to system
444 - xsys: alias to system
432 - bq: alias to getoutput
445 - bq: alias to getoutput
433
446
434 An instance can then be created as:
447 An instance can then be created as:
435 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
448 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
436
449
437 And used as:
450 And used as:
438 >>> sysexec.xsys('pwd')
451 >>> sysexec.xsys('pwd')
439 >>> dirlist = sysexec.bq('ls -l')
452 >>> dirlist = sysexec.bq('ls -l')
440 """
453 """
441
454
442 def __init__(self,verbose=0,debug=0,header='',split=0):
455 def __init__(self,verbose=0,debug=0,header='',split=0):
443 """Specify the instance's values for verbose, debug and header."""
456 """Specify the instance's values for verbose, debug and header."""
444 setattr_list(self,'verbose debug header split')
457 setattr_list(self,'verbose debug header split')
445
458
446 def system(self,cmd):
459 def system(self,cmd):
447 """Stateful interface to system(), with the same keyword parameters."""
460 """Stateful interface to system(), with the same keyword parameters."""
448
461
449 system(cmd,self.verbose,self.debug,self.header)
462 system(cmd,self.verbose,self.debug,self.header)
450
463
451 def shell(self,cmd):
464 def shell(self,cmd):
452 """Stateful interface to shell(), with the same keyword parameters."""
465 """Stateful interface to shell(), with the same keyword parameters."""
453
466
454 shell(cmd,self.verbose,self.debug,self.header)
467 shell(cmd,self.verbose,self.debug,self.header)
455
468
456 xsys = system # alias
469 xsys = system # alias
457
470
458 def getoutput(self,cmd):
471 def getoutput(self,cmd):
459 """Stateful interface to getoutput()."""
472 """Stateful interface to getoutput()."""
460
473
461 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
474 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
462
475
463 def getoutputerror(self,cmd):
476 def getoutputerror(self,cmd):
464 """Stateful interface to getoutputerror()."""
477 """Stateful interface to getoutputerror()."""
465
478
466 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
479 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
467
480
468 bq = getoutput # alias
481 bq = getoutput # alias
469
482
470 #-----------------------------------------------------------------------------
483 #-----------------------------------------------------------------------------
471 def mutex_opts(dict,ex_op):
484 def mutex_opts(dict,ex_op):
472 """Check for presence of mutually exclusive keys in a dict.
485 """Check for presence of mutually exclusive keys in a dict.
473
486
474 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
487 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
475 for op1,op2 in ex_op:
488 for op1,op2 in ex_op:
476 if op1 in dict and op2 in dict:
489 if op1 in dict and op2 in dict:
477 raise ValueError,'\n*** ERROR in Arguments *** '\
490 raise ValueError,'\n*** ERROR in Arguments *** '\
478 'Options '+op1+' and '+op2+' are mutually exclusive.'
491 'Options '+op1+' and '+op2+' are mutually exclusive.'
479
492
480 #-----------------------------------------------------------------------------
493 #-----------------------------------------------------------------------------
481 def get_py_filename(name):
494 def get_py_filename(name):
482 """Return a valid python filename in the current directory.
495 """Return a valid python filename in the current directory.
483
496
484 If the given name is not a file, it adds '.py' and searches again.
497 If the given name is not a file, it adds '.py' and searches again.
485 Raises IOError with an informative message if the file isn't found."""
498 Raises IOError with an informative message if the file isn't found."""
486
499
487 name = os.path.expanduser(name)
500 name = os.path.expanduser(name)
488 if not os.path.isfile(name) and not name.endswith('.py'):
501 if not os.path.isfile(name) and not name.endswith('.py'):
489 name += '.py'
502 name += '.py'
490 if os.path.isfile(name):
503 if os.path.isfile(name):
491 return name
504 return name
492 else:
505 else:
493 raise IOError,'File `%s` not found.' % name
506 raise IOError,'File `%s` not found.' % name
494
507
495 #-----------------------------------------------------------------------------
508 #-----------------------------------------------------------------------------
496 def filefind(fname,alt_dirs = None):
509 def filefind(fname,alt_dirs = None):
497 """Return the given filename either in the current directory, if it
510 """Return the given filename either in the current directory, if it
498 exists, or in a specified list of directories.
511 exists, or in a specified list of directories.
499
512
500 ~ expansion is done on all file and directory names.
513 ~ expansion is done on all file and directory names.
501
514
502 Upon an unsuccessful search, raise an IOError exception."""
515 Upon an unsuccessful search, raise an IOError exception."""
503
516
504 if alt_dirs is None:
517 if alt_dirs is None:
505 try:
518 try:
506 alt_dirs = get_home_dir()
519 alt_dirs = get_home_dir()
507 except HomeDirError:
520 except HomeDirError:
508 alt_dirs = os.getcwd()
521 alt_dirs = os.getcwd()
509 search = [fname] + list_strings(alt_dirs)
522 search = [fname] + list_strings(alt_dirs)
510 search = map(os.path.expanduser,search)
523 search = map(os.path.expanduser,search)
511 #print 'search list for',fname,'list:',search # dbg
524 #print 'search list for',fname,'list:',search # dbg
512 fname = search[0]
525 fname = search[0]
513 if os.path.isfile(fname):
526 if os.path.isfile(fname):
514 return fname
527 return fname
515 for direc in search[1:]:
528 for direc in search[1:]:
516 testname = os.path.join(direc,fname)
529 testname = os.path.join(direc,fname)
517 #print 'testname',testname # dbg
530 #print 'testname',testname # dbg
518 if os.path.isfile(testname):
531 if os.path.isfile(testname):
519 return testname
532 return testname
520 raise IOError,'File' + `fname` + \
533 raise IOError,'File' + `fname` + \
521 ' not found in current or supplied directories:' + `alt_dirs`
534 ' not found in current or supplied directories:' + `alt_dirs`
522
535
523 #----------------------------------------------------------------------------
536 #----------------------------------------------------------------------------
524 def file_read(filename):
537 def file_read(filename):
525 """Read a file and close it. Returns the file source."""
538 """Read a file and close it. Returns the file source."""
526 fobj = open(filename,'r');
539 fobj = open(filename,'r');
527 source = fobj.read();
540 source = fobj.read();
528 fobj.close()
541 fobj.close()
529 return source
542 return source
530
543
531 def file_readlines(filename):
544 def file_readlines(filename):
532 """Read a file and close it. Returns the file source using readlines()."""
545 """Read a file and close it. Returns the file source using readlines()."""
533 fobj = open(filename,'r');
546 fobj = open(filename,'r');
534 lines = fobj.readlines();
547 lines = fobj.readlines();
535 fobj.close()
548 fobj.close()
536 return lines
549 return lines
537
550
538 #----------------------------------------------------------------------------
551 #----------------------------------------------------------------------------
539 def target_outdated(target,deps):
552 def target_outdated(target,deps):
540 """Determine whether a target is out of date.
553 """Determine whether a target is out of date.
541
554
542 target_outdated(target,deps) -> 1/0
555 target_outdated(target,deps) -> 1/0
543
556
544 deps: list of filenames which MUST exist.
557 deps: list of filenames which MUST exist.
545 target: single filename which may or may not exist.
558 target: single filename which may or may not exist.
546
559
547 If target doesn't exist or is older than any file listed in deps, return
560 If target doesn't exist or is older than any file listed in deps, return
548 true, otherwise return false.
561 true, otherwise return false.
549 """
562 """
550 try:
563 try:
551 target_time = os.path.getmtime(target)
564 target_time = os.path.getmtime(target)
552 except os.error:
565 except os.error:
553 return 1
566 return 1
554 for dep in deps:
567 for dep in deps:
555 dep_time = os.path.getmtime(dep)
568 dep_time = os.path.getmtime(dep)
556 if dep_time > target_time:
569 if dep_time > target_time:
557 #print "For target",target,"Dep failed:",dep # dbg
570 #print "For target",target,"Dep failed:",dep # dbg
558 #print "times (dep,tar):",dep_time,target_time # dbg
571 #print "times (dep,tar):",dep_time,target_time # dbg
559 return 1
572 return 1
560 return 0
573 return 0
561
574
562 #-----------------------------------------------------------------------------
575 #-----------------------------------------------------------------------------
563 def target_update(target,deps,cmd):
576 def target_update(target,deps,cmd):
564 """Update a target with a given command given a list of dependencies.
577 """Update a target with a given command given a list of dependencies.
565
578
566 target_update(target,deps,cmd) -> runs cmd if target is outdated.
579 target_update(target,deps,cmd) -> runs cmd if target is outdated.
567
580
568 This is just a wrapper around target_outdated() which calls the given
581 This is just a wrapper around target_outdated() which calls the given
569 command if target is outdated."""
582 command if target is outdated."""
570
583
571 if target_outdated(target,deps):
584 if target_outdated(target,deps):
572 xsys(cmd)
585 xsys(cmd)
573
586
574 #----------------------------------------------------------------------------
587 #----------------------------------------------------------------------------
575 def unquote_ends(istr):
588 def unquote_ends(istr):
576 """Remove a single pair of quotes from the endpoints of a string."""
589 """Remove a single pair of quotes from the endpoints of a string."""
577
590
578 if not istr:
591 if not istr:
579 return istr
592 return istr
580 if (istr[0]=="'" and istr[-1]=="'") or \
593 if (istr[0]=="'" and istr[-1]=="'") or \
581 (istr[0]=='"' and istr[-1]=='"'):
594 (istr[0]=='"' and istr[-1]=='"'):
582 return istr[1:-1]
595 return istr[1:-1]
583 else:
596 else:
584 return istr
597 return istr
585
598
586 #----------------------------------------------------------------------------
599 #----------------------------------------------------------------------------
587 def process_cmdline(argv,names=[],defaults={},usage=''):
600 def process_cmdline(argv,names=[],defaults={},usage=''):
588 """ Process command-line options and arguments.
601 """ Process command-line options and arguments.
589
602
590 Arguments:
603 Arguments:
591
604
592 - argv: list of arguments, typically sys.argv.
605 - argv: list of arguments, typically sys.argv.
593
606
594 - names: list of option names. See DPyGetOpt docs for details on options
607 - names: list of option names. See DPyGetOpt docs for details on options
595 syntax.
608 syntax.
596
609
597 - defaults: dict of default values.
610 - defaults: dict of default values.
598
611
599 - usage: optional usage notice to print if a wrong argument is passed.
612 - usage: optional usage notice to print if a wrong argument is passed.
600
613
601 Return a dict of options and a list of free arguments."""
614 Return a dict of options and a list of free arguments."""
602
615
603 getopt = DPyGetOpt.DPyGetOpt()
616 getopt = DPyGetOpt.DPyGetOpt()
604 getopt.setIgnoreCase(0)
617 getopt.setIgnoreCase(0)
605 getopt.parseConfiguration(names)
618 getopt.parseConfiguration(names)
606
619
607 try:
620 try:
608 getopt.processArguments(argv)
621 getopt.processArguments(argv)
609 except:
622 except:
610 print usage
623 print usage
611 warn(`sys.exc_value`,level=4)
624 warn(`sys.exc_value`,level=4)
612
625
613 defaults.update(getopt.optionValues)
626 defaults.update(getopt.optionValues)
614 args = getopt.freeValues
627 args = getopt.freeValues
615
628
616 return defaults,args
629 return defaults,args
617
630
618 #----------------------------------------------------------------------------
631 #----------------------------------------------------------------------------
619 def optstr2types(ostr):
632 def optstr2types(ostr):
620 """Convert a string of option names to a dict of type mappings.
633 """Convert a string of option names to a dict of type mappings.
621
634
622 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
635 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
623
636
624 This is used to get the types of all the options in a string formatted
637 This is used to get the types of all the options in a string formatted
625 with the conventions of DPyGetOpt. The 'type' None is used for options
638 with the conventions of DPyGetOpt. The 'type' None is used for options
626 which are strings (they need no further conversion). This function's main
639 which are strings (they need no further conversion). This function's main
627 use is to get a typemap for use with read_dict().
640 use is to get a typemap for use with read_dict().
628 """
641 """
629
642
630 typeconv = {None:'',int:'',float:''}
643 typeconv = {None:'',int:'',float:''}
631 typemap = {'s':None,'i':int,'f':float}
644 typemap = {'s':None,'i':int,'f':float}
632 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
645 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
633
646
634 for w in ostr.split():
647 for w in ostr.split():
635 oname,alias,otype = opt_re.match(w).groups()
648 oname,alias,otype = opt_re.match(w).groups()
636 if otype == '' or alias == '!': # simple switches are integers too
649 if otype == '' or alias == '!': # simple switches are integers too
637 otype = 'i'
650 otype = 'i'
638 typeconv[typemap[otype]] += oname + ' '
651 typeconv[typemap[otype]] += oname + ' '
639 return typeconv
652 return typeconv
640
653
641 #----------------------------------------------------------------------------
654 #----------------------------------------------------------------------------
642 def read_dict(filename,type_conv=None,**opt):
655 def read_dict(filename,type_conv=None,**opt):
643
656
644 """Read a dictionary of key=value pairs from an input file, optionally
657 """Read a dictionary of key=value pairs from an input file, optionally
645 performing conversions on the resulting values.
658 performing conversions on the resulting values.
646
659
647 read_dict(filename,type_conv,**opt) -> dict
660 read_dict(filename,type_conv,**opt) -> dict
648
661
649 Only one value per line is accepted, the format should be
662 Only one value per line is accepted, the format should be
650 # optional comments are ignored
663 # optional comments are ignored
651 key value\n
664 key value\n
652
665
653 Args:
666 Args:
654
667
655 - type_conv: A dictionary specifying which keys need to be converted to
668 - type_conv: A dictionary specifying which keys need to be converted to
656 which types. By default all keys are read as strings. This dictionary
669 which types. By default all keys are read as strings. This dictionary
657 should have as its keys valid conversion functions for strings
670 should have as its keys valid conversion functions for strings
658 (int,long,float,complex, or your own). The value for each key
671 (int,long,float,complex, or your own). The value for each key
659 (converter) should be a whitespace separated string containing the names
672 (converter) should be a whitespace separated string containing the names
660 of all the entries in the file to be converted using that function. For
673 of all the entries in the file to be converted using that function. For
661 keys to be left alone, use None as the conversion function (only needed
674 keys to be left alone, use None as the conversion function (only needed
662 with purge=1, see below).
675 with purge=1, see below).
663
676
664 - opt: dictionary with extra options as below (default in parens)
677 - opt: dictionary with extra options as below (default in parens)
665
678
666 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
679 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
667 of the dictionary to be returned. If purge is going to be used, the
680 of the dictionary to be returned. If purge is going to be used, the
668 set of keys to be left as strings also has to be explicitly specified
681 set of keys to be left as strings also has to be explicitly specified
669 using the (non-existent) conversion function None.
682 using the (non-existent) conversion function None.
670
683
671 fs(None): field separator. This is the key/value separator to be used
684 fs(None): field separator. This is the key/value separator to be used
672 when parsing the file. The None default means any whitespace [behavior
685 when parsing the file. The None default means any whitespace [behavior
673 of string.split()].
686 of string.split()].
674
687
675 strip(0): if 1, strip string values of leading/trailinig whitespace.
688 strip(0): if 1, strip string values of leading/trailinig whitespace.
676
689
677 warn(1): warning level if requested keys are not found in file.
690 warn(1): warning level if requested keys are not found in file.
678 - 0: silently ignore.
691 - 0: silently ignore.
679 - 1: inform but proceed.
692 - 1: inform but proceed.
680 - 2: raise KeyError exception.
693 - 2: raise KeyError exception.
681
694
682 no_empty(0): if 1, remove keys with whitespace strings as a value.
695 no_empty(0): if 1, remove keys with whitespace strings as a value.
683
696
684 unique([]): list of keys (or space separated string) which can't be
697 unique([]): list of keys (or space separated string) which can't be
685 repeated. If one such key is found in the file, each new instance
698 repeated. If one such key is found in the file, each new instance
686 overwrites the previous one. For keys not listed here, the behavior is
699 overwrites the previous one. For keys not listed here, the behavior is
687 to make a list of all appearances.
700 to make a list of all appearances.
688
701
689 Example:
702 Example:
690 If the input file test.ini has:
703 If the input file test.ini has:
691 i 3
704 i 3
692 x 4.5
705 x 4.5
693 y 5.5
706 y 5.5
694 s hi ho
707 s hi ho
695 Then:
708 Then:
696
709
697 >>> type_conv={int:'i',float:'x',None:'s'}
710 >>> type_conv={int:'i',float:'x',None:'s'}
698 >>> read_dict('test.ini')
711 >>> read_dict('test.ini')
699 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
712 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
700 >>> read_dict('test.ini',type_conv)
713 >>> read_dict('test.ini',type_conv)
701 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
714 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
702 >>> read_dict('test.ini',type_conv,purge=1)
715 >>> read_dict('test.ini',type_conv,purge=1)
703 {'i': 3, 's': 'hi ho', 'x': 4.5}
716 {'i': 3, 's': 'hi ho', 'x': 4.5}
704 """
717 """
705
718
706 # starting config
719 # starting config
707 opt.setdefault('purge',0)
720 opt.setdefault('purge',0)
708 opt.setdefault('fs',None) # field sep defaults to any whitespace
721 opt.setdefault('fs',None) # field sep defaults to any whitespace
709 opt.setdefault('strip',0)
722 opt.setdefault('strip',0)
710 opt.setdefault('warn',1)
723 opt.setdefault('warn',1)
711 opt.setdefault('no_empty',0)
724 opt.setdefault('no_empty',0)
712 opt.setdefault('unique','')
725 opt.setdefault('unique','')
713 if type(opt['unique']) in StringTypes:
726 if type(opt['unique']) in StringTypes:
714 unique_keys = qw(opt['unique'])
727 unique_keys = qw(opt['unique'])
715 elif type(opt['unique']) in (types.TupleType,types.ListType):
728 elif type(opt['unique']) in (types.TupleType,types.ListType):
716 unique_keys = opt['unique']
729 unique_keys = opt['unique']
717 else:
730 else:
718 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
731 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
719
732
720 dict = {}
733 dict = {}
721 # first read in table of values as strings
734 # first read in table of values as strings
722 file = open(filename,'r')
735 file = open(filename,'r')
723 for line in file.readlines():
736 for line in file.readlines():
724 line = line.strip()
737 line = line.strip()
725 if len(line) and line[0]=='#': continue
738 if len(line) and line[0]=='#': continue
726 if len(line)>0:
739 if len(line)>0:
727 lsplit = line.split(opt['fs'],1)
740 lsplit = line.split(opt['fs'],1)
728 try:
741 try:
729 key,val = lsplit
742 key,val = lsplit
730 except ValueError:
743 except ValueError:
731 key,val = lsplit[0],''
744 key,val = lsplit[0],''
732 key = key.strip()
745 key = key.strip()
733 if opt['strip']: val = val.strip()
746 if opt['strip']: val = val.strip()
734 if val == "''" or val == '""': val = ''
747 if val == "''" or val == '""': val = ''
735 if opt['no_empty'] and (val=='' or val.isspace()):
748 if opt['no_empty'] and (val=='' or val.isspace()):
736 continue
749 continue
737 # if a key is found more than once in the file, build a list
750 # if a key is found more than once in the file, build a list
738 # unless it's in the 'unique' list. In that case, last found in file
751 # unless it's in the 'unique' list. In that case, last found in file
739 # takes precedence. User beware.
752 # takes precedence. User beware.
740 try:
753 try:
741 if dict[key] and key in unique_keys:
754 if dict[key] and key in unique_keys:
742 dict[key] = val
755 dict[key] = val
743 elif type(dict[key]) is types.ListType:
756 elif type(dict[key]) is types.ListType:
744 dict[key].append(val)
757 dict[key].append(val)
745 else:
758 else:
746 dict[key] = [dict[key],val]
759 dict[key] = [dict[key],val]
747 except KeyError:
760 except KeyError:
748 dict[key] = val
761 dict[key] = val
749 # purge if requested
762 # purge if requested
750 if opt['purge']:
763 if opt['purge']:
751 accepted_keys = qwflat(type_conv.values())
764 accepted_keys = qwflat(type_conv.values())
752 for key in dict.keys():
765 for key in dict.keys():
753 if key in accepted_keys: continue
766 if key in accepted_keys: continue
754 del(dict[key])
767 del(dict[key])
755 # now convert if requested
768 # now convert if requested
756 if type_conv==None: return dict
769 if type_conv==None: return dict
757 conversions = type_conv.keys()
770 conversions = type_conv.keys()
758 try: conversions.remove(None)
771 try: conversions.remove(None)
759 except: pass
772 except: pass
760 for convert in conversions:
773 for convert in conversions:
761 for val in qw(type_conv[convert]):
774 for val in qw(type_conv[convert]):
762 try:
775 try:
763 dict[val] = convert(dict[val])
776 dict[val] = convert(dict[val])
764 except KeyError,e:
777 except KeyError,e:
765 if opt['warn'] == 0:
778 if opt['warn'] == 0:
766 pass
779 pass
767 elif opt['warn'] == 1:
780 elif opt['warn'] == 1:
768 print >>sys.stderr, 'Warning: key',val,\
781 print >>sys.stderr, 'Warning: key',val,\
769 'not found in file',filename
782 'not found in file',filename
770 elif opt['warn'] == 2:
783 elif opt['warn'] == 2:
771 raise KeyError,e
784 raise KeyError,e
772 else:
785 else:
773 raise ValueError,'Warning level must be 0,1 or 2'
786 raise ValueError,'Warning level must be 0,1 or 2'
774
787
775 return dict
788 return dict
776
789
777 #----------------------------------------------------------------------------
790 #----------------------------------------------------------------------------
778 def flag_calls(func):
791 def flag_calls(func):
779 """Wrap a function to detect and flag when it gets called.
792 """Wrap a function to detect and flag when it gets called.
780
793
781 This is a decorator which takes a function and wraps it in a function with
794 This is a decorator which takes a function and wraps it in a function with
782 a 'called' attribute. wrapper.called is initialized to False.
795 a 'called' attribute. wrapper.called is initialized to False.
783
796
784 The wrapper.called attribute is set to False right before each call to the
797 The wrapper.called attribute is set to False right before each call to the
785 wrapped function, so if the call fails it remains False. After the call
798 wrapped function, so if the call fails it remains False. After the call
786 completes, wrapper.called is set to True and the output is returned.
799 completes, wrapper.called is set to True and the output is returned.
787
800
788 Testing for truth in wrapper.called allows you to determine if a call to
801 Testing for truth in wrapper.called allows you to determine if a call to
789 func() was attempted and succeeded."""
802 func() was attempted and succeeded."""
790
803
791 def wrapper(*args,**kw):
804 def wrapper(*args,**kw):
792 wrapper.called = False
805 wrapper.called = False
793 out = func(*args,**kw)
806 out = func(*args,**kw)
794 wrapper.called = True
807 wrapper.called = True
795 return out
808 return out
796
809
797 wrapper.called = False
810 wrapper.called = False
798 wrapper.__doc__ = func.__doc__
811 wrapper.__doc__ = func.__doc__
799 return wrapper
812 return wrapper
800
813
801 #----------------------------------------------------------------------------
814 #----------------------------------------------------------------------------
802 def dhook_wrap(func,*a,**k):
815 def dhook_wrap(func,*a,**k):
803 """Wrap a function call in a sys.displayhook controller.
816 """Wrap a function call in a sys.displayhook controller.
804
817
805 Returns a wrapper around func which calls func, with all its arguments and
818 Returns a wrapper around func which calls func, with all its arguments and
806 keywords unmodified, using the default sys.displayhook. Since IPython
819 keywords unmodified, using the default sys.displayhook. Since IPython
807 modifies sys.displayhook, it breaks the behavior of certain systems that
820 modifies sys.displayhook, it breaks the behavior of certain systems that
808 rely on the default behavior, notably doctest.
821 rely on the default behavior, notably doctest.
809 """
822 """
810
823
811 def f(*a,**k):
824 def f(*a,**k):
812
825
813 dhook_s = sys.displayhook
826 dhook_s = sys.displayhook
814 sys.displayhook = sys.__displayhook__
827 sys.displayhook = sys.__displayhook__
815 try:
828 try:
816 out = func(*a,**k)
829 out = func(*a,**k)
817 finally:
830 finally:
818 sys.displayhook = dhook_s
831 sys.displayhook = dhook_s
819
832
820 return out
833 return out
821
834
822 f.__doc__ = func.__doc__
835 f.__doc__ = func.__doc__
823 return f
836 return f
824
837
825 #----------------------------------------------------------------------------
838 #----------------------------------------------------------------------------
826 class HomeDirError(Error):
839 class HomeDirError(Error):
827 pass
840 pass
828
841
829 def get_home_dir():
842 def get_home_dir():
830 """Return the closest possible equivalent to a 'home' directory.
843 """Return the closest possible equivalent to a 'home' directory.
831
844
832 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
845 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
833
846
834 Currently only Posix and NT are implemented, a HomeDirError exception is
847 Currently only Posix and NT are implemented, a HomeDirError exception is
835 raised for all other OSes. """
848 raised for all other OSes. """
836
849
837 isdir = os.path.isdir
850 isdir = os.path.isdir
838 env = os.environ
851 env = os.environ
839
852
840 # first, check py2exe distribution root directory for _ipython.
853 # first, check py2exe distribution root directory for _ipython.
841 # This overrides all. Normally does not exist.
854 # This overrides all. Normally does not exist.
842
855
843 if '\\library.zip\\' in IPython.__file__.lower():
856 if '\\library.zip\\' in IPython.__file__.lower():
844 root, rest = IPython.__file__.lower().split('library.zip')
857 root, rest = IPython.__file__.lower().split('library.zip')
845 if isdir(root + '_ipython'):
858 if isdir(root + '_ipython'):
846 os.environ["IPYKITROOT"] = root.rstrip('\\')
859 os.environ["IPYKITROOT"] = root.rstrip('\\')
847 return root
860 return root
848
861
849 try:
862 try:
850 homedir = env['HOME']
863 homedir = env['HOME']
851 if not isdir(homedir):
864 if not isdir(homedir):
852 # in case a user stuck some string which does NOT resolve to a
865 # in case a user stuck some string which does NOT resolve to a
853 # valid path, it's as good as if we hadn't foud it
866 # valid path, it's as good as if we hadn't foud it
854 raise KeyError
867 raise KeyError
855 return homedir
868 return homedir
856 except KeyError:
869 except KeyError:
857 if os.name == 'posix':
870 if os.name == 'posix':
858 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
871 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
859 elif os.name == 'nt':
872 elif os.name == 'nt':
860 # For some strange reason, win9x returns 'nt' for os.name.
873 # For some strange reason, win9x returns 'nt' for os.name.
861 try:
874 try:
862 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
875 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
863 if not isdir(homedir):
876 if not isdir(homedir):
864 homedir = os.path.join(env['USERPROFILE'])
877 homedir = os.path.join(env['USERPROFILE'])
865 if not isdir(homedir):
878 if not isdir(homedir):
866 raise HomeDirError
879 raise HomeDirError
867 return homedir
880 return homedir
868 except:
881 except:
869 try:
882 try:
870 # Use the registry to get the 'My Documents' folder.
883 # Use the registry to get the 'My Documents' folder.
871 import _winreg as wreg
884 import _winreg as wreg
872 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
885 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
873 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
886 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
874 homedir = wreg.QueryValueEx(key,'Personal')[0]
887 homedir = wreg.QueryValueEx(key,'Personal')[0]
875 key.Close()
888 key.Close()
876 if not isdir(homedir):
889 if not isdir(homedir):
877 e = ('Invalid "Personal" folder registry key '
890 e = ('Invalid "Personal" folder registry key '
878 'typically "My Documents".\n'
891 'typically "My Documents".\n'
879 'Value: %s\n'
892 'Value: %s\n'
880 'This is not a valid directory on your system.' %
893 'This is not a valid directory on your system.' %
881 homedir)
894 homedir)
882 raise HomeDirError(e)
895 raise HomeDirError(e)
883 return homedir
896 return homedir
884 except HomeDirError:
897 except HomeDirError:
885 raise
898 raise
886 except:
899 except:
887 return 'C:\\'
900 return 'C:\\'
888 elif os.name == 'dos':
901 elif os.name == 'dos':
889 # Desperate, may do absurd things in classic MacOS. May work under DOS.
902 # Desperate, may do absurd things in classic MacOS. May work under DOS.
890 return 'C:\\'
903 return 'C:\\'
891 else:
904 else:
892 raise HomeDirError,'support for your operating system not implemented.'
905 raise HomeDirError,'support for your operating system not implemented.'
893
906
894 #****************************************************************************
907 #****************************************************************************
895 # strings and text
908 # strings and text
896
909
897 class LSString(str):
910 class LSString(str):
898 """String derivative with a special access attributes.
911 """String derivative with a special access attributes.
899
912
900 These are normal strings, but with the special attributes:
913 These are normal strings, but with the special attributes:
901
914
902 .l (or .list) : value as list (split on newlines).
915 .l (or .list) : value as list (split on newlines).
903 .n (or .nlstr): original value (the string itself).
916 .n (or .nlstr): original value (the string itself).
904 .s (or .spstr): value as whitespace-separated string.
917 .s (or .spstr): value as whitespace-separated string.
905 .p (or .paths): list of path objects
918 .p (or .paths): list of path objects
906
919
907 Any values which require transformations are computed only once and
920 Any values which require transformations are computed only once and
908 cached.
921 cached.
909
922
910 Such strings are very useful to efficiently interact with the shell, which
923 Such strings are very useful to efficiently interact with the shell, which
911 typically only understands whitespace-separated options for commands."""
924 typically only understands whitespace-separated options for commands."""
912
925
913 def get_list(self):
926 def get_list(self):
914 try:
927 try:
915 return self.__list
928 return self.__list
916 except AttributeError:
929 except AttributeError:
917 self.__list = self.split('\n')
930 self.__list = self.split('\n')
918 return self.__list
931 return self.__list
919
932
920 l = list = property(get_list)
933 l = list = property(get_list)
921
934
922 def get_spstr(self):
935 def get_spstr(self):
923 try:
936 try:
924 return self.__spstr
937 return self.__spstr
925 except AttributeError:
938 except AttributeError:
926 self.__spstr = self.replace('\n',' ')
939 self.__spstr = self.replace('\n',' ')
927 return self.__spstr
940 return self.__spstr
928
941
929 s = spstr = property(get_spstr)
942 s = spstr = property(get_spstr)
930
943
931 def get_nlstr(self):
944 def get_nlstr(self):
932 return self
945 return self
933
946
934 n = nlstr = property(get_nlstr)
947 n = nlstr = property(get_nlstr)
935
948
936 def get_paths(self):
949 def get_paths(self):
937 try:
950 try:
938 return self.__paths
951 return self.__paths
939 except AttributeError:
952 except AttributeError:
940 self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)]
953 self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)]
941 return self.__paths
954 return self.__paths
942
955
943 p = paths = property(get_paths)
956 p = paths = property(get_paths)
944
957
945 def print_lsstring(arg):
958 def print_lsstring(arg):
946 """ Prettier (non-repr-like) and more informative printer for LSString """
959 """ Prettier (non-repr-like) and more informative printer for LSString """
947 print "LSString (.p, .n, .l, .s available). Value:"
960 print "LSString (.p, .n, .l, .s available). Value:"
948 print arg
961 print arg
949
962
950 print_lsstring = result_display.when_type(LSString)(print_lsstring)
963 print_lsstring = result_display.when_type(LSString)(print_lsstring)
951
964
952 #----------------------------------------------------------------------------
965 #----------------------------------------------------------------------------
953 class SList(list):
966 class SList(list):
954 """List derivative with a special access attributes.
967 """List derivative with a special access attributes.
955
968
956 These are normal lists, but with the special attributes:
969 These are normal lists, but with the special attributes:
957
970
958 .l (or .list) : value as list (the list itself).
971 .l (or .list) : value as list (the list itself).
959 .n (or .nlstr): value as a string, joined on newlines.
972 .n (or .nlstr): value as a string, joined on newlines.
960 .s (or .spstr): value as a string, joined on spaces.
973 .s (or .spstr): value as a string, joined on spaces.
961 .p (or .paths): list of path objects
974 .p (or .paths): list of path objects
962
975
963 Any values which require transformations are computed only once and
976 Any values which require transformations are computed only once and
964 cached."""
977 cached."""
965
978
966 def get_list(self):
979 def get_list(self):
967 return self
980 return self
968
981
969 l = list = property(get_list)
982 l = list = property(get_list)
970
983
971 def get_spstr(self):
984 def get_spstr(self):
972 try:
985 try:
973 return self.__spstr
986 return self.__spstr
974 except AttributeError:
987 except AttributeError:
975 self.__spstr = ' '.join(self)
988 self.__spstr = ' '.join(self)
976 return self.__spstr
989 return self.__spstr
977
990
978 s = spstr = property(get_spstr)
991 s = spstr = property(get_spstr)
979
992
980 def get_nlstr(self):
993 def get_nlstr(self):
981 try:
994 try:
982 return self.__nlstr
995 return self.__nlstr
983 except AttributeError:
996 except AttributeError:
984 self.__nlstr = '\n'.join(self)
997 self.__nlstr = '\n'.join(self)
985 return self.__nlstr
998 return self.__nlstr
986
999
987 n = nlstr = property(get_nlstr)
1000 n = nlstr = property(get_nlstr)
988
1001
989 def get_paths(self):
1002 def get_paths(self):
990 try:
1003 try:
991 return self.__paths
1004 return self.__paths
992 except AttributeError:
1005 except AttributeError:
993 self.__paths = [path(p) for p in self if os.path.exists(p)]
1006 self.__paths = [path(p) for p in self if os.path.exists(p)]
994 return self.__paths
1007 return self.__paths
995
1008
996 p = paths = property(get_paths)
1009 p = paths = property(get_paths)
997
1010
998 #----------------------------------------------------------------------------
1011 #----------------------------------------------------------------------------
999 def esc_quotes(strng):
1012 def esc_quotes(strng):
1000 """Return the input string with single and double quotes escaped out"""
1013 """Return the input string with single and double quotes escaped out"""
1001
1014
1002 return strng.replace('"','\\"').replace("'","\\'")
1015 return strng.replace('"','\\"').replace("'","\\'")
1003
1016
1004 #----------------------------------------------------------------------------
1017 #----------------------------------------------------------------------------
1005 def make_quoted_expr(s):
1018 def make_quoted_expr(s):
1006 """Return string s in appropriate quotes, using raw string if possible.
1019 """Return string s in appropriate quotes, using raw string if possible.
1007
1020
1008 Effectively this turns string: cd \ao\ao\
1021 Effectively this turns string: cd \ao\ao\
1009 to: r"cd \ao\ao\_"[:-1]
1022 to: r"cd \ao\ao\_"[:-1]
1010
1023
1011 Note the use of raw string and padding at the end to allow trailing backslash.
1024 Note the use of raw string and padding at the end to allow trailing backslash.
1012
1025
1013 """
1026 """
1014
1027
1015 tail = ''
1028 tail = ''
1016 tailpadding = ''
1029 tailpadding = ''
1017 raw = ''
1030 raw = ''
1018 if "\\" in s:
1031 if "\\" in s:
1019 raw = 'r'
1032 raw = 'r'
1020 if s.endswith('\\'):
1033 if s.endswith('\\'):
1021 tail = '[:-1]'
1034 tail = '[:-1]'
1022 tailpadding = '_'
1035 tailpadding = '_'
1023 if '"' not in s:
1036 if '"' not in s:
1024 quote = '"'
1037 quote = '"'
1025 elif "'" not in s:
1038 elif "'" not in s:
1026 quote = "'"
1039 quote = "'"
1027 elif '"""' not in s and not s.endswith('"'):
1040 elif '"""' not in s and not s.endswith('"'):
1028 quote = '"""'
1041 quote = '"""'
1029 elif "'''" not in s and not s.endswith("'"):
1042 elif "'''" not in s and not s.endswith("'"):
1030 quote = "'''"
1043 quote = "'''"
1031 else:
1044 else:
1032 # give up, backslash-escaped string will do
1045 # give up, backslash-escaped string will do
1033 return '"%s"' % esc_quotes(s)
1046 return '"%s"' % esc_quotes(s)
1034 res = itpl("$raw$quote$s$tailpadding$quote$tail")
1047 res = itpl("$raw$quote$s$tailpadding$quote$tail")
1035 return res
1048 return res
1036
1049
1037
1050
1038 #----------------------------------------------------------------------------
1051 #----------------------------------------------------------------------------
1039 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
1052 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
1040 """Take multiple lines of input.
1053 """Take multiple lines of input.
1041
1054
1042 A list with each line of input as a separate element is returned when a
1055 A list with each line of input as a separate element is returned when a
1043 termination string is entered (defaults to a single '.'). Input can also
1056 termination string is entered (defaults to a single '.'). Input can also
1044 terminate via EOF (^D in Unix, ^Z-RET in Windows).
1057 terminate via EOF (^D in Unix, ^Z-RET in Windows).
1045
1058
1046 Lines of input which end in \\ are joined into single entries (and a
1059 Lines of input which end in \\ are joined into single entries (and a
1047 secondary continuation prompt is issued as long as the user terminates
1060 secondary continuation prompt is issued as long as the user terminates
1048 lines with \\). This allows entering very long strings which are still
1061 lines with \\). This allows entering very long strings which are still
1049 meant to be treated as single entities.
1062 meant to be treated as single entities.
1050 """
1063 """
1051
1064
1052 try:
1065 try:
1053 if header:
1066 if header:
1054 header += '\n'
1067 header += '\n'
1055 lines = [raw_input(header + ps1)]
1068 lines = [raw_input(header + ps1)]
1056 except EOFError:
1069 except EOFError:
1057 return []
1070 return []
1058 terminate = [terminate_str]
1071 terminate = [terminate_str]
1059 try:
1072 try:
1060 while lines[-1:] != terminate:
1073 while lines[-1:] != terminate:
1061 new_line = raw_input(ps1)
1074 new_line = raw_input(ps1)
1062 while new_line.endswith('\\'):
1075 while new_line.endswith('\\'):
1063 new_line = new_line[:-1] + raw_input(ps2)
1076 new_line = new_line[:-1] + raw_input(ps2)
1064 lines.append(new_line)
1077 lines.append(new_line)
1065
1078
1066 return lines[:-1] # don't return the termination command
1079 return lines[:-1] # don't return the termination command
1067 except EOFError:
1080 except EOFError:
1068 print
1081 print
1069 return lines
1082 return lines
1070
1083
1071 #----------------------------------------------------------------------------
1084 #----------------------------------------------------------------------------
1072 def raw_input_ext(prompt='', ps2='... '):
1085 def raw_input_ext(prompt='', ps2='... '):
1073 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1086 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1074
1087
1075 line = raw_input(prompt)
1088 line = raw_input(prompt)
1076 while line.endswith('\\'):
1089 while line.endswith('\\'):
1077 line = line[:-1] + raw_input(ps2)
1090 line = line[:-1] + raw_input(ps2)
1078 return line
1091 return line
1079
1092
1080 #----------------------------------------------------------------------------
1093 #----------------------------------------------------------------------------
1081 def ask_yes_no(prompt,default=None):
1094 def ask_yes_no(prompt,default=None):
1082 """Asks a question and returns a boolean (y/n) answer.
1095 """Asks a question and returns a boolean (y/n) answer.
1083
1096
1084 If default is given (one of 'y','n'), it is used if the user input is
1097 If default is given (one of 'y','n'), it is used if the user input is
1085 empty. Otherwise the question is repeated until an answer is given.
1098 empty. Otherwise the question is repeated until an answer is given.
1086
1099
1087 An EOF is treated as the default answer. If there is no default, an
1100 An EOF is treated as the default answer. If there is no default, an
1088 exception is raised to prevent infinite loops.
1101 exception is raised to prevent infinite loops.
1089
1102
1090 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1103 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1091
1104
1092 answers = {'y':True,'n':False,'yes':True,'no':False}
1105 answers = {'y':True,'n':False,'yes':True,'no':False}
1093 ans = None
1106 ans = None
1094 while ans not in answers.keys():
1107 while ans not in answers.keys():
1095 try:
1108 try:
1096 ans = raw_input(prompt+' ').lower()
1109 ans = raw_input(prompt+' ').lower()
1097 if not ans: # response was an empty string
1110 if not ans: # response was an empty string
1098 ans = default
1111 ans = default
1099 except KeyboardInterrupt:
1112 except KeyboardInterrupt:
1100 pass
1113 pass
1101 except EOFError:
1114 except EOFError:
1102 if default in answers.keys():
1115 if default in answers.keys():
1103 ans = default
1116 ans = default
1104 print
1117 print
1105 else:
1118 else:
1106 raise
1119 raise
1107
1120
1108 return answers[ans]
1121 return answers[ans]
1109
1122
1110 #----------------------------------------------------------------------------
1123 #----------------------------------------------------------------------------
1111 def marquee(txt='',width=78,mark='*'):
1124 def marquee(txt='',width=78,mark='*'):
1112 """Return the input string centered in a 'marquee'."""
1125 """Return the input string centered in a 'marquee'."""
1113 if not txt:
1126 if not txt:
1114 return (mark*width)[:width]
1127 return (mark*width)[:width]
1115 nmark = (width-len(txt)-2)/len(mark)/2
1128 nmark = (width-len(txt)-2)/len(mark)/2
1116 if nmark < 0: nmark =0
1129 if nmark < 0: nmark =0
1117 marks = mark*nmark
1130 marks = mark*nmark
1118 return '%s %s %s' % (marks,txt,marks)
1131 return '%s %s %s' % (marks,txt,marks)
1119
1132
1120 #----------------------------------------------------------------------------
1133 #----------------------------------------------------------------------------
1121 class EvalDict:
1134 class EvalDict:
1122 """
1135 """
1123 Emulate a dict which evaluates its contents in the caller's frame.
1136 Emulate a dict which evaluates its contents in the caller's frame.
1124
1137
1125 Usage:
1138 Usage:
1126 >>>number = 19
1139 >>>number = 19
1127 >>>text = "python"
1140 >>>text = "python"
1128 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1141 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1129 """
1142 """
1130
1143
1131 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1144 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1132 # modified (shorter) version of:
1145 # modified (shorter) version of:
1133 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1146 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1134 # Skip Montanaro (skip@pobox.com).
1147 # Skip Montanaro (skip@pobox.com).
1135
1148
1136 def __getitem__(self, name):
1149 def __getitem__(self, name):
1137 frame = sys._getframe(1)
1150 frame = sys._getframe(1)
1138 return eval(name, frame.f_globals, frame.f_locals)
1151 return eval(name, frame.f_globals, frame.f_locals)
1139
1152
1140 EvalString = EvalDict # for backwards compatibility
1153 EvalString = EvalDict # for backwards compatibility
1141 #----------------------------------------------------------------------------
1154 #----------------------------------------------------------------------------
1142 def qw(words,flat=0,sep=None,maxsplit=-1):
1155 def qw(words,flat=0,sep=None,maxsplit=-1):
1143 """Similar to Perl's qw() operator, but with some more options.
1156 """Similar to Perl's qw() operator, but with some more options.
1144
1157
1145 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1158 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1146
1159
1147 words can also be a list itself, and with flat=1, the output will be
1160 words can also be a list itself, and with flat=1, the output will be
1148 recursively flattened. Examples:
1161 recursively flattened. Examples:
1149
1162
1150 >>> qw('1 2')
1163 >>> qw('1 2')
1151 ['1', '2']
1164 ['1', '2']
1152 >>> qw(['a b','1 2',['m n','p q']])
1165 >>> qw(['a b','1 2',['m n','p q']])
1153 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1166 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1154 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1167 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1155 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1168 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1156
1169
1157 if type(words) in StringTypes:
1170 if type(words) in StringTypes:
1158 return [word.strip() for word in words.split(sep,maxsplit)
1171 return [word.strip() for word in words.split(sep,maxsplit)
1159 if word and not word.isspace() ]
1172 if word and not word.isspace() ]
1160 if flat:
1173 if flat:
1161 return flatten(map(qw,words,[1]*len(words)))
1174 return flatten(map(qw,words,[1]*len(words)))
1162 return map(qw,words)
1175 return map(qw,words)
1163
1176
1164 #----------------------------------------------------------------------------
1177 #----------------------------------------------------------------------------
1165 def qwflat(words,sep=None,maxsplit=-1):
1178 def qwflat(words,sep=None,maxsplit=-1):
1166 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1179 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1167 return qw(words,1,sep,maxsplit)
1180 return qw(words,1,sep,maxsplit)
1168
1181
1169 #----------------------------------------------------------------------------
1182 #----------------------------------------------------------------------------
1170 def qw_lol(indata):
1183 def qw_lol(indata):
1171 """qw_lol('a b') -> [['a','b']],
1184 """qw_lol('a b') -> [['a','b']],
1172 otherwise it's just a call to qw().
1185 otherwise it's just a call to qw().
1173
1186
1174 We need this to make sure the modules_some keys *always* end up as a
1187 We need this to make sure the modules_some keys *always* end up as a
1175 list of lists."""
1188 list of lists."""
1176
1189
1177 if type(indata) in StringTypes:
1190 if type(indata) in StringTypes:
1178 return [qw(indata)]
1191 return [qw(indata)]
1179 else:
1192 else:
1180 return qw(indata)
1193 return qw(indata)
1181
1194
1182 #-----------------------------------------------------------------------------
1195 #-----------------------------------------------------------------------------
1183 def list_strings(arg):
1196 def list_strings(arg):
1184 """Always return a list of strings, given a string or list of strings
1197 """Always return a list of strings, given a string or list of strings
1185 as input."""
1198 as input."""
1186
1199
1187 if type(arg) in StringTypes: return [arg]
1200 if type(arg) in StringTypes: return [arg]
1188 else: return arg
1201 else: return arg
1189
1202
1190 #----------------------------------------------------------------------------
1203 #----------------------------------------------------------------------------
1191 def grep(pat,list,case=1):
1204 def grep(pat,list,case=1):
1192 """Simple minded grep-like function.
1205 """Simple minded grep-like function.
1193 grep(pat,list) returns occurrences of pat in list, None on failure.
1206 grep(pat,list) returns occurrences of pat in list, None on failure.
1194
1207
1195 It only does simple string matching, with no support for regexps. Use the
1208 It only does simple string matching, with no support for regexps. Use the
1196 option case=0 for case-insensitive matching."""
1209 option case=0 for case-insensitive matching."""
1197
1210
1198 # This is pretty crude. At least it should implement copying only references
1211 # This is pretty crude. At least it should implement copying only references
1199 # to the original data in case it's big. Now it copies the data for output.
1212 # to the original data in case it's big. Now it copies the data for output.
1200 out=[]
1213 out=[]
1201 if case:
1214 if case:
1202 for term in list:
1215 for term in list:
1203 if term.find(pat)>-1: out.append(term)
1216 if term.find(pat)>-1: out.append(term)
1204 else:
1217 else:
1205 lpat=pat.lower()
1218 lpat=pat.lower()
1206 for term in list:
1219 for term in list:
1207 if term.lower().find(lpat)>-1: out.append(term)
1220 if term.lower().find(lpat)>-1: out.append(term)
1208
1221
1209 if len(out): return out
1222 if len(out): return out
1210 else: return None
1223 else: return None
1211
1224
1212 #----------------------------------------------------------------------------
1225 #----------------------------------------------------------------------------
1213 def dgrep(pat,*opts):
1226 def dgrep(pat,*opts):
1214 """Return grep() on dir()+dir(__builtins__).
1227 """Return grep() on dir()+dir(__builtins__).
1215
1228
1216 A very common use of grep() when working interactively."""
1229 A very common use of grep() when working interactively."""
1217
1230
1218 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1231 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1219
1232
1220 #----------------------------------------------------------------------------
1233 #----------------------------------------------------------------------------
1221 def idgrep(pat):
1234 def idgrep(pat):
1222 """Case-insensitive dgrep()"""
1235 """Case-insensitive dgrep()"""
1223
1236
1224 return dgrep(pat,0)
1237 return dgrep(pat,0)
1225
1238
1226 #----------------------------------------------------------------------------
1239 #----------------------------------------------------------------------------
1227 def igrep(pat,list):
1240 def igrep(pat,list):
1228 """Synonym for case-insensitive grep."""
1241 """Synonym for case-insensitive grep."""
1229
1242
1230 return grep(pat,list,case=0)
1243 return grep(pat,list,case=0)
1231
1244
1232 #----------------------------------------------------------------------------
1245 #----------------------------------------------------------------------------
1233 def indent(str,nspaces=4,ntabs=0):
1246 def indent(str,nspaces=4,ntabs=0):
1234 """Indent a string a given number of spaces or tabstops.
1247 """Indent a string a given number of spaces or tabstops.
1235
1248
1236 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1249 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1237 """
1250 """
1238 if str is None:
1251 if str is None:
1239 return
1252 return
1240 ind = '\t'*ntabs+' '*nspaces
1253 ind = '\t'*ntabs+' '*nspaces
1241 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1254 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1242 if outstr.endswith(os.linesep+ind):
1255 if outstr.endswith(os.linesep+ind):
1243 return outstr[:-len(ind)]
1256 return outstr[:-len(ind)]
1244 else:
1257 else:
1245 return outstr
1258 return outstr
1246
1259
1247 #-----------------------------------------------------------------------------
1260 #-----------------------------------------------------------------------------
1248 def native_line_ends(filename,backup=1):
1261 def native_line_ends(filename,backup=1):
1249 """Convert (in-place) a file to line-ends native to the current OS.
1262 """Convert (in-place) a file to line-ends native to the current OS.
1250
1263
1251 If the optional backup argument is given as false, no backup of the
1264 If the optional backup argument is given as false, no backup of the
1252 original file is left. """
1265 original file is left. """
1253
1266
1254 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1267 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1255
1268
1256 bak_filename = filename + backup_suffixes[os.name]
1269 bak_filename = filename + backup_suffixes[os.name]
1257
1270
1258 original = open(filename).read()
1271 original = open(filename).read()
1259 shutil.copy2(filename,bak_filename)
1272 shutil.copy2(filename,bak_filename)
1260 try:
1273 try:
1261 new = open(filename,'wb')
1274 new = open(filename,'wb')
1262 new.write(os.linesep.join(original.splitlines()))
1275 new.write(os.linesep.join(original.splitlines()))
1263 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1276 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1264 new.close()
1277 new.close()
1265 except:
1278 except:
1266 os.rename(bak_filename,filename)
1279 os.rename(bak_filename,filename)
1267 if not backup:
1280 if not backup:
1268 try:
1281 try:
1269 os.remove(bak_filename)
1282 os.remove(bak_filename)
1270 except:
1283 except:
1271 pass
1284 pass
1272
1285
1273 #----------------------------------------------------------------------------
1286 #----------------------------------------------------------------------------
1274 def get_pager_cmd(pager_cmd = None):
1287 def get_pager_cmd(pager_cmd = None):
1275 """Return a pager command.
1288 """Return a pager command.
1276
1289
1277 Makes some attempts at finding an OS-correct one."""
1290 Makes some attempts at finding an OS-correct one."""
1278
1291
1279 if os.name == 'posix':
1292 if os.name == 'posix':
1280 default_pager_cmd = 'less -r' # -r for color control sequences
1293 default_pager_cmd = 'less -r' # -r for color control sequences
1281 elif os.name in ['nt','dos']:
1294 elif os.name in ['nt','dos']:
1282 default_pager_cmd = 'type'
1295 default_pager_cmd = 'type'
1283
1296
1284 if pager_cmd is None:
1297 if pager_cmd is None:
1285 try:
1298 try:
1286 pager_cmd = os.environ['PAGER']
1299 pager_cmd = os.environ['PAGER']
1287 except:
1300 except:
1288 pager_cmd = default_pager_cmd
1301 pager_cmd = default_pager_cmd
1289 return pager_cmd
1302 return pager_cmd
1290
1303
1291 #-----------------------------------------------------------------------------
1304 #-----------------------------------------------------------------------------
1292 def get_pager_start(pager,start):
1305 def get_pager_start(pager,start):
1293 """Return the string for paging files with an offset.
1306 """Return the string for paging files with an offset.
1294
1307
1295 This is the '+N' argument which less and more (under Unix) accept.
1308 This is the '+N' argument which less and more (under Unix) accept.
1296 """
1309 """
1297
1310
1298 if pager in ['less','more']:
1311 if pager in ['less','more']:
1299 if start:
1312 if start:
1300 start_string = '+' + str(start)
1313 start_string = '+' + str(start)
1301 else:
1314 else:
1302 start_string = ''
1315 start_string = ''
1303 else:
1316 else:
1304 start_string = ''
1317 start_string = ''
1305 return start_string
1318 return start_string
1306
1319
1307 #----------------------------------------------------------------------------
1320 #----------------------------------------------------------------------------
1308 # (X)emacs on W32 doesn't like to be bypassed with msvcrt.getch()
1321 # (X)emacs on W32 doesn't like to be bypassed with msvcrt.getch()
1309 if os.name == 'nt' and os.environ.get('TERM','dumb') != 'emacs':
1322 if os.name == 'nt' and os.environ.get('TERM','dumb') != 'emacs':
1310 import msvcrt
1323 import msvcrt
1311 def page_more():
1324 def page_more():
1312 """ Smart pausing between pages
1325 """ Smart pausing between pages
1313
1326
1314 @return: True if need print more lines, False if quit
1327 @return: True if need print more lines, False if quit
1315 """
1328 """
1316 Term.cout.write('---Return to continue, q to quit--- ')
1329 Term.cout.write('---Return to continue, q to quit--- ')
1317 ans = msvcrt.getch()
1330 ans = msvcrt.getch()
1318 if ans in ("q", "Q"):
1331 if ans in ("q", "Q"):
1319 result = False
1332 result = False
1320 else:
1333 else:
1321 result = True
1334 result = True
1322 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1335 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1323 return result
1336 return result
1324 else:
1337 else:
1325 def page_more():
1338 def page_more():
1326 ans = raw_input('---Return to continue, q to quit--- ')
1339 ans = raw_input('---Return to continue, q to quit--- ')
1327 if ans.lower().startswith('q'):
1340 if ans.lower().startswith('q'):
1328 return False
1341 return False
1329 else:
1342 else:
1330 return True
1343 return True
1331
1344
1332 esc_re = re.compile(r"(\x1b[^m]+m)")
1345 esc_re = re.compile(r"(\x1b[^m]+m)")
1333
1346
1334 def page_dumb(strng,start=0,screen_lines=25):
1347 def page_dumb(strng,start=0,screen_lines=25):
1335 """Very dumb 'pager' in Python, for when nothing else works.
1348 """Very dumb 'pager' in Python, for when nothing else works.
1336
1349
1337 Only moves forward, same interface as page(), except for pager_cmd and
1350 Only moves forward, same interface as page(), except for pager_cmd and
1338 mode."""
1351 mode."""
1339
1352
1340 out_ln = strng.splitlines()[start:]
1353 out_ln = strng.splitlines()[start:]
1341 screens = chop(out_ln,screen_lines-1)
1354 screens = chop(out_ln,screen_lines-1)
1342 if len(screens) == 1:
1355 if len(screens) == 1:
1343 print >>Term.cout, os.linesep.join(screens[0])
1356 print >>Term.cout, os.linesep.join(screens[0])
1344 else:
1357 else:
1345 last_escape = ""
1358 last_escape = ""
1346 for scr in screens[0:-1]:
1359 for scr in screens[0:-1]:
1347 hunk = os.linesep.join(scr)
1360 hunk = os.linesep.join(scr)
1348 print >>Term.cout, last_escape + hunk
1361 print >>Term.cout, last_escape + hunk
1349 if not page_more():
1362 if not page_more():
1350 return
1363 return
1351 esc_list = esc_re.findall(hunk)
1364 esc_list = esc_re.findall(hunk)
1352 if len(esc_list) > 0:
1365 if len(esc_list) > 0:
1353 last_escape = esc_list[-1]
1366 last_escape = esc_list[-1]
1354 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1367 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1355
1368
1356 #----------------------------------------------------------------------------
1369 #----------------------------------------------------------------------------
1357 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1370 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1358 """Print a string, piping through a pager after a certain length.
1371 """Print a string, piping through a pager after a certain length.
1359
1372
1360 The screen_lines parameter specifies the number of *usable* lines of your
1373 The screen_lines parameter specifies the number of *usable* lines of your
1361 terminal screen (total lines minus lines you need to reserve to show other
1374 terminal screen (total lines minus lines you need to reserve to show other
1362 information).
1375 information).
1363
1376
1364 If you set screen_lines to a number <=0, page() will try to auto-determine
1377 If you set screen_lines to a number <=0, page() will try to auto-determine
1365 your screen size and will only use up to (screen_size+screen_lines) for
1378 your screen size and will only use up to (screen_size+screen_lines) for
1366 printing, paging after that. That is, if you want auto-detection but need
1379 printing, paging after that. That is, if you want auto-detection but need
1367 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1380 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1368 auto-detection without any lines reserved simply use screen_lines = 0.
1381 auto-detection without any lines reserved simply use screen_lines = 0.
1369
1382
1370 If a string won't fit in the allowed lines, it is sent through the
1383 If a string won't fit in the allowed lines, it is sent through the
1371 specified pager command. If none given, look for PAGER in the environment,
1384 specified pager command. If none given, look for PAGER in the environment,
1372 and ultimately default to less.
1385 and ultimately default to less.
1373
1386
1374 If no system pager works, the string is sent through a 'dumb pager'
1387 If no system pager works, the string is sent through a 'dumb pager'
1375 written in python, very simplistic.
1388 written in python, very simplistic.
1376 """
1389 """
1377
1390
1378 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1391 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1379 TERM = os.environ.get('TERM','dumb')
1392 TERM = os.environ.get('TERM','dumb')
1380 if TERM in ['dumb','emacs'] and os.name != 'nt':
1393 if TERM in ['dumb','emacs'] and os.name != 'nt':
1381 print strng
1394 print strng
1382 return
1395 return
1383 # chop off the topmost part of the string we don't want to see
1396 # chop off the topmost part of the string we don't want to see
1384 str_lines = strng.split(os.linesep)[start:]
1397 str_lines = strng.split(os.linesep)[start:]
1385 str_toprint = os.linesep.join(str_lines)
1398 str_toprint = os.linesep.join(str_lines)
1386 num_newlines = len(str_lines)
1399 num_newlines = len(str_lines)
1387 len_str = len(str_toprint)
1400 len_str = len(str_toprint)
1388
1401
1389 # Dumb heuristics to guesstimate number of on-screen lines the string
1402 # Dumb heuristics to guesstimate number of on-screen lines the string
1390 # takes. Very basic, but good enough for docstrings in reasonable
1403 # takes. Very basic, but good enough for docstrings in reasonable
1391 # terminals. If someone later feels like refining it, it's not hard.
1404 # terminals. If someone later feels like refining it, it's not hard.
1392 numlines = max(num_newlines,int(len_str/80)+1)
1405 numlines = max(num_newlines,int(len_str/80)+1)
1393
1406
1394 if os.name == "nt":
1407 if os.name == "nt":
1395 screen_lines_def = get_console_size(defaulty=25)[1]
1408 screen_lines_def = get_console_size(defaulty=25)[1]
1396 else:
1409 else:
1397 screen_lines_def = 25 # default value if we can't auto-determine
1410 screen_lines_def = 25 # default value if we can't auto-determine
1398
1411
1399 # auto-determine screen size
1412 # auto-determine screen size
1400 if screen_lines <= 0:
1413 if screen_lines <= 0:
1401 if TERM=='xterm':
1414 if TERM=='xterm':
1402 try:
1415 try:
1403 import curses
1416 import curses
1404 if hasattr(curses,'initscr'):
1417 if hasattr(curses,'initscr'):
1405 use_curses = 1
1418 use_curses = 1
1406 else:
1419 else:
1407 use_curses = 0
1420 use_curses = 0
1408 except ImportError:
1421 except ImportError:
1409 use_curses = 0
1422 use_curses = 0
1410 else:
1423 else:
1411 # curses causes problems on many terminals other than xterm.
1424 # curses causes problems on many terminals other than xterm.
1412 use_curses = 0
1425 use_curses = 0
1413 if use_curses:
1426 if use_curses:
1414 scr = curses.initscr()
1427 scr = curses.initscr()
1415 screen_lines_real,screen_cols = scr.getmaxyx()
1428 screen_lines_real,screen_cols = scr.getmaxyx()
1416 curses.endwin()
1429 curses.endwin()
1417 screen_lines += screen_lines_real
1430 screen_lines += screen_lines_real
1418 #print '***Screen size:',screen_lines_real,'lines x',\
1431 #print '***Screen size:',screen_lines_real,'lines x',\
1419 #screen_cols,'columns.' # dbg
1432 #screen_cols,'columns.' # dbg
1420 else:
1433 else:
1421 screen_lines += screen_lines_def
1434 screen_lines += screen_lines_def
1422
1435
1423 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1436 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1424 if numlines <= screen_lines :
1437 if numlines <= screen_lines :
1425 #print '*** normal print' # dbg
1438 #print '*** normal print' # dbg
1426 print >>Term.cout, str_toprint
1439 print >>Term.cout, str_toprint
1427 else:
1440 else:
1428 # Try to open pager and default to internal one if that fails.
1441 # Try to open pager and default to internal one if that fails.
1429 # All failure modes are tagged as 'retval=1', to match the return
1442 # All failure modes are tagged as 'retval=1', to match the return
1430 # value of a failed system command. If any intermediate attempt
1443 # value of a failed system command. If any intermediate attempt
1431 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1444 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1432 pager_cmd = get_pager_cmd(pager_cmd)
1445 pager_cmd = get_pager_cmd(pager_cmd)
1433 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1446 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1434 if os.name == 'nt':
1447 if os.name == 'nt':
1435 if pager_cmd.startswith('type'):
1448 if pager_cmd.startswith('type'):
1436 # The default WinXP 'type' command is failing on complex strings.
1449 # The default WinXP 'type' command is failing on complex strings.
1437 retval = 1
1450 retval = 1
1438 else:
1451 else:
1439 tmpname = tempfile.mktemp('.txt')
1452 tmpname = tempfile.mktemp('.txt')
1440 tmpfile = file(tmpname,'wt')
1453 tmpfile = file(tmpname,'wt')
1441 tmpfile.write(strng)
1454 tmpfile.write(strng)
1442 tmpfile.close()
1455 tmpfile.close()
1443 cmd = "%s < %s" % (pager_cmd,tmpname)
1456 cmd = "%s < %s" % (pager_cmd,tmpname)
1444 if os.system(cmd):
1457 if os.system(cmd):
1445 retval = 1
1458 retval = 1
1446 else:
1459 else:
1447 retval = None
1460 retval = None
1448 os.remove(tmpname)
1461 os.remove(tmpname)
1449 else:
1462 else:
1450 try:
1463 try:
1451 retval = None
1464 retval = None
1452 # if I use popen4, things hang. No idea why.
1465 # if I use popen4, things hang. No idea why.
1453 #pager,shell_out = os.popen4(pager_cmd)
1466 #pager,shell_out = os.popen4(pager_cmd)
1454 pager = os.popen(pager_cmd,'w')
1467 pager = os.popen(pager_cmd,'w')
1455 pager.write(strng)
1468 pager.write(strng)
1456 pager.close()
1469 pager.close()
1457 retval = pager.close() # success returns None
1470 retval = pager.close() # success returns None
1458 except IOError,msg: # broken pipe when user quits
1471 except IOError,msg: # broken pipe when user quits
1459 if msg.args == (32,'Broken pipe'):
1472 if msg.args == (32,'Broken pipe'):
1460 retval = None
1473 retval = None
1461 else:
1474 else:
1462 retval = 1
1475 retval = 1
1463 except OSError:
1476 except OSError:
1464 # Other strange problems, sometimes seen in Win2k/cygwin
1477 # Other strange problems, sometimes seen in Win2k/cygwin
1465 retval = 1
1478 retval = 1
1466 if retval is not None:
1479 if retval is not None:
1467 page_dumb(strng,screen_lines=screen_lines)
1480 page_dumb(strng,screen_lines=screen_lines)
1468
1481
1469 #----------------------------------------------------------------------------
1482 #----------------------------------------------------------------------------
1470 def page_file(fname,start = 0, pager_cmd = None):
1483 def page_file(fname,start = 0, pager_cmd = None):
1471 """Page a file, using an optional pager command and starting line.
1484 """Page a file, using an optional pager command and starting line.
1472 """
1485 """
1473
1486
1474 pager_cmd = get_pager_cmd(pager_cmd)
1487 pager_cmd = get_pager_cmd(pager_cmd)
1475 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1488 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1476
1489
1477 try:
1490 try:
1478 if os.environ['TERM'] in ['emacs','dumb']:
1491 if os.environ['TERM'] in ['emacs','dumb']:
1479 raise EnvironmentError
1492 raise EnvironmentError
1480 xsys(pager_cmd + ' ' + fname)
1493 xsys(pager_cmd + ' ' + fname)
1481 except:
1494 except:
1482 try:
1495 try:
1483 if start > 0:
1496 if start > 0:
1484 start -= 1
1497 start -= 1
1485 page(open(fname).read(),start)
1498 page(open(fname).read(),start)
1486 except:
1499 except:
1487 print 'Unable to show file',`fname`
1500 print 'Unable to show file',`fname`
1488
1501
1489 #----------------------------------------------------------------------------
1502 #----------------------------------------------------------------------------
1490 def snip_print(str,width = 75,print_full = 0,header = ''):
1503 def snip_print(str,width = 75,print_full = 0,header = ''):
1491 """Print a string snipping the midsection to fit in width.
1504 """Print a string snipping the midsection to fit in width.
1492
1505
1493 print_full: mode control:
1506 print_full: mode control:
1494 - 0: only snip long strings
1507 - 0: only snip long strings
1495 - 1: send to page() directly.
1508 - 1: send to page() directly.
1496 - 2: snip long strings and ask for full length viewing with page()
1509 - 2: snip long strings and ask for full length viewing with page()
1497 Return 1 if snipping was necessary, 0 otherwise."""
1510 Return 1 if snipping was necessary, 0 otherwise."""
1498
1511
1499 if print_full == 1:
1512 if print_full == 1:
1500 page(header+str)
1513 page(header+str)
1501 return 0
1514 return 0
1502
1515
1503 print header,
1516 print header,
1504 if len(str) < width:
1517 if len(str) < width:
1505 print str
1518 print str
1506 snip = 0
1519 snip = 0
1507 else:
1520 else:
1508 whalf = int((width -5)/2)
1521 whalf = int((width -5)/2)
1509 print str[:whalf] + ' <...> ' + str[-whalf:]
1522 print str[:whalf] + ' <...> ' + str[-whalf:]
1510 snip = 1
1523 snip = 1
1511 if snip and print_full == 2:
1524 if snip and print_full == 2:
1512 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1525 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1513 page(str)
1526 page(str)
1514 return snip
1527 return snip
1515
1528
1516 #****************************************************************************
1529 #****************************************************************************
1517 # lists, dicts and structures
1530 # lists, dicts and structures
1518
1531
1519 def belong(candidates,checklist):
1532 def belong(candidates,checklist):
1520 """Check whether a list of items appear in a given list of options.
1533 """Check whether a list of items appear in a given list of options.
1521
1534
1522 Returns a list of 1 and 0, one for each candidate given."""
1535 Returns a list of 1 and 0, one for each candidate given."""
1523
1536
1524 return [x in checklist for x in candidates]
1537 return [x in checklist for x in candidates]
1525
1538
1526 #----------------------------------------------------------------------------
1539 #----------------------------------------------------------------------------
1527 def uniq_stable(elems):
1540 def uniq_stable(elems):
1528 """uniq_stable(elems) -> list
1541 """uniq_stable(elems) -> list
1529
1542
1530 Return from an iterable, a list of all the unique elements in the input,
1543 Return from an iterable, a list of all the unique elements in the input,
1531 but maintaining the order in which they first appear.
1544 but maintaining the order in which they first appear.
1532
1545
1533 A naive solution to this problem which just makes a dictionary with the
1546 A naive solution to this problem which just makes a dictionary with the
1534 elements as keys fails to respect the stability condition, since
1547 elements as keys fails to respect the stability condition, since
1535 dictionaries are unsorted by nature.
1548 dictionaries are unsorted by nature.
1536
1549
1537 Note: All elements in the input must be valid dictionary keys for this
1550 Note: All elements in the input must be valid dictionary keys for this
1538 routine to work, as it internally uses a dictionary for efficiency
1551 routine to work, as it internally uses a dictionary for efficiency
1539 reasons."""
1552 reasons."""
1540
1553
1541 unique = []
1554 unique = []
1542 unique_dict = {}
1555 unique_dict = {}
1543 for nn in elems:
1556 for nn in elems:
1544 if nn not in unique_dict:
1557 if nn not in unique_dict:
1545 unique.append(nn)
1558 unique.append(nn)
1546 unique_dict[nn] = None
1559 unique_dict[nn] = None
1547 return unique
1560 return unique
1548
1561
1549 #----------------------------------------------------------------------------
1562 #----------------------------------------------------------------------------
1550 class NLprinter:
1563 class NLprinter:
1551 """Print an arbitrarily nested list, indicating index numbers.
1564 """Print an arbitrarily nested list, indicating index numbers.
1552
1565
1553 An instance of this class called nlprint is available and callable as a
1566 An instance of this class called nlprint is available and callable as a
1554 function.
1567 function.
1555
1568
1556 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1569 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1557 and using 'sep' to separate the index from the value. """
1570 and using 'sep' to separate the index from the value. """
1558
1571
1559 def __init__(self):
1572 def __init__(self):
1560 self.depth = 0
1573 self.depth = 0
1561
1574
1562 def __call__(self,lst,pos='',**kw):
1575 def __call__(self,lst,pos='',**kw):
1563 """Prints the nested list numbering levels."""
1576 """Prints the nested list numbering levels."""
1564 kw.setdefault('indent',' ')
1577 kw.setdefault('indent',' ')
1565 kw.setdefault('sep',': ')
1578 kw.setdefault('sep',': ')
1566 kw.setdefault('start',0)
1579 kw.setdefault('start',0)
1567 kw.setdefault('stop',len(lst))
1580 kw.setdefault('stop',len(lst))
1568 # we need to remove start and stop from kw so they don't propagate
1581 # we need to remove start and stop from kw so they don't propagate
1569 # into a recursive call for a nested list.
1582 # into a recursive call for a nested list.
1570 start = kw['start']; del kw['start']
1583 start = kw['start']; del kw['start']
1571 stop = kw['stop']; del kw['stop']
1584 stop = kw['stop']; del kw['stop']
1572 if self.depth == 0 and 'header' in kw.keys():
1585 if self.depth == 0 and 'header' in kw.keys():
1573 print kw['header']
1586 print kw['header']
1574
1587
1575 for idx in range(start,stop):
1588 for idx in range(start,stop):
1576 elem = lst[idx]
1589 elem = lst[idx]
1577 if type(elem)==type([]):
1590 if type(elem)==type([]):
1578 self.depth += 1
1591 self.depth += 1
1579 self.__call__(elem,itpl('$pos$idx,'),**kw)
1592 self.__call__(elem,itpl('$pos$idx,'),**kw)
1580 self.depth -= 1
1593 self.depth -= 1
1581 else:
1594 else:
1582 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1595 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1583
1596
1584 nlprint = NLprinter()
1597 nlprint = NLprinter()
1585 #----------------------------------------------------------------------------
1598 #----------------------------------------------------------------------------
1586 def all_belong(candidates,checklist):
1599 def all_belong(candidates,checklist):
1587 """Check whether a list of items ALL appear in a given list of options.
1600 """Check whether a list of items ALL appear in a given list of options.
1588
1601
1589 Returns a single 1 or 0 value."""
1602 Returns a single 1 or 0 value."""
1590
1603
1591 return 1-(0 in [x in checklist for x in candidates])
1604 return 1-(0 in [x in checklist for x in candidates])
1592
1605
1593 #----------------------------------------------------------------------------
1606 #----------------------------------------------------------------------------
1594 def sort_compare(lst1,lst2,inplace = 1):
1607 def sort_compare(lst1,lst2,inplace = 1):
1595 """Sort and compare two lists.
1608 """Sort and compare two lists.
1596
1609
1597 By default it does it in place, thus modifying the lists. Use inplace = 0
1610 By default it does it in place, thus modifying the lists. Use inplace = 0
1598 to avoid that (at the cost of temporary copy creation)."""
1611 to avoid that (at the cost of temporary copy creation)."""
1599 if not inplace:
1612 if not inplace:
1600 lst1 = lst1[:]
1613 lst1 = lst1[:]
1601 lst2 = lst2[:]
1614 lst2 = lst2[:]
1602 lst1.sort(); lst2.sort()
1615 lst1.sort(); lst2.sort()
1603 return lst1 == lst2
1616 return lst1 == lst2
1604
1617
1605 #----------------------------------------------------------------------------
1618 #----------------------------------------------------------------------------
1606 def mkdict(**kwargs):
1619 def mkdict(**kwargs):
1607 """Return a dict from a keyword list.
1620 """Return a dict from a keyword list.
1608
1621
1609 It's just syntactic sugar for making ditcionary creation more convenient:
1622 It's just syntactic sugar for making ditcionary creation more convenient:
1610 # the standard way
1623 # the standard way
1611 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1624 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1612 # a cleaner way
1625 # a cleaner way
1613 >>>data = dict(red=1, green=2, blue=3)
1626 >>>data = dict(red=1, green=2, blue=3)
1614
1627
1615 If you need more than this, look at the Struct() class."""
1628 If you need more than this, look at the Struct() class."""
1616
1629
1617 return kwargs
1630 return kwargs
1618
1631
1619 #----------------------------------------------------------------------------
1632 #----------------------------------------------------------------------------
1620 def list2dict(lst):
1633 def list2dict(lst):
1621 """Takes a list of (key,value) pairs and turns it into a dict."""
1634 """Takes a list of (key,value) pairs and turns it into a dict."""
1622
1635
1623 dic = {}
1636 dic = {}
1624 for k,v in lst: dic[k] = v
1637 for k,v in lst: dic[k] = v
1625 return dic
1638 return dic
1626
1639
1627 #----------------------------------------------------------------------------
1640 #----------------------------------------------------------------------------
1628 def list2dict2(lst,default=''):
1641 def list2dict2(lst,default=''):
1629 """Takes a list and turns it into a dict.
1642 """Takes a list and turns it into a dict.
1630 Much slower than list2dict, but more versatile. This version can take
1643 Much slower than list2dict, but more versatile. This version can take
1631 lists with sublists of arbitrary length (including sclars)."""
1644 lists with sublists of arbitrary length (including sclars)."""
1632
1645
1633 dic = {}
1646 dic = {}
1634 for elem in lst:
1647 for elem in lst:
1635 if type(elem) in (types.ListType,types.TupleType):
1648 if type(elem) in (types.ListType,types.TupleType):
1636 size = len(elem)
1649 size = len(elem)
1637 if size == 0:
1650 if size == 0:
1638 pass
1651 pass
1639 elif size == 1:
1652 elif size == 1:
1640 dic[elem] = default
1653 dic[elem] = default
1641 else:
1654 else:
1642 k,v = elem[0], elem[1:]
1655 k,v = elem[0], elem[1:]
1643 if len(v) == 1: v = v[0]
1656 if len(v) == 1: v = v[0]
1644 dic[k] = v
1657 dic[k] = v
1645 else:
1658 else:
1646 dic[elem] = default
1659 dic[elem] = default
1647 return dic
1660 return dic
1648
1661
1649 #----------------------------------------------------------------------------
1662 #----------------------------------------------------------------------------
1650 def flatten(seq):
1663 def flatten(seq):
1651 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1664 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1652
1665
1653 return [x for subseq in seq for x in subseq]
1666 return [x for subseq in seq for x in subseq]
1654
1667
1655 #----------------------------------------------------------------------------
1668 #----------------------------------------------------------------------------
1656 def get_slice(seq,start=0,stop=None,step=1):
1669 def get_slice(seq,start=0,stop=None,step=1):
1657 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1670 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1658 if stop == None:
1671 if stop == None:
1659 stop = len(seq)
1672 stop = len(seq)
1660 item = lambda i: seq[i]
1673 item = lambda i: seq[i]
1661 return map(item,xrange(start,stop,step))
1674 return map(item,xrange(start,stop,step))
1662
1675
1663 #----------------------------------------------------------------------------
1676 #----------------------------------------------------------------------------
1664 def chop(seq,size):
1677 def chop(seq,size):
1665 """Chop a sequence into chunks of the given size."""
1678 """Chop a sequence into chunks of the given size."""
1666 chunk = lambda i: seq[i:i+size]
1679 chunk = lambda i: seq[i:i+size]
1667 return map(chunk,xrange(0,len(seq),size))
1680 return map(chunk,xrange(0,len(seq),size))
1668
1681
1669 #----------------------------------------------------------------------------
1682 #----------------------------------------------------------------------------
1670 # with is a keyword as of python 2.5, so this function is renamed to withobj
1683 # with is a keyword as of python 2.5, so this function is renamed to withobj
1671 # from its old 'with' name.
1684 # from its old 'with' name.
1672 def with_obj(object, **args):
1685 def with_obj(object, **args):
1673 """Set multiple attributes for an object, similar to Pascal's with.
1686 """Set multiple attributes for an object, similar to Pascal's with.
1674
1687
1675 Example:
1688 Example:
1676 with_obj(jim,
1689 with_obj(jim,
1677 born = 1960,
1690 born = 1960,
1678 haircolour = 'Brown',
1691 haircolour = 'Brown',
1679 eyecolour = 'Green')
1692 eyecolour = 'Green')
1680
1693
1681 Credit: Greg Ewing, in
1694 Credit: Greg Ewing, in
1682 http://mail.python.org/pipermail/python-list/2001-May/040703.html.
1695 http://mail.python.org/pipermail/python-list/2001-May/040703.html.
1683
1696
1684 NOTE: up until IPython 0.7.2, this was called simply 'with', but 'with'
1697 NOTE: up until IPython 0.7.2, this was called simply 'with', but 'with'
1685 has become a keyword for Python 2.5, so we had to rename it."""
1698 has become a keyword for Python 2.5, so we had to rename it."""
1686
1699
1687 object.__dict__.update(args)
1700 object.__dict__.update(args)
1688
1701
1689 #----------------------------------------------------------------------------
1702 #----------------------------------------------------------------------------
1690 def setattr_list(obj,alist,nspace = None):
1703 def setattr_list(obj,alist,nspace = None):
1691 """Set a list of attributes for an object taken from a namespace.
1704 """Set a list of attributes for an object taken from a namespace.
1692
1705
1693 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1706 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1694 alist with their values taken from nspace, which must be a dict (something
1707 alist with their values taken from nspace, which must be a dict (something
1695 like locals() will often do) If nspace isn't given, locals() of the
1708 like locals() will often do) If nspace isn't given, locals() of the
1696 *caller* is used, so in most cases you can omit it.
1709 *caller* is used, so in most cases you can omit it.
1697
1710
1698 Note that alist can be given as a string, which will be automatically
1711 Note that alist can be given as a string, which will be automatically
1699 split into a list on whitespace. If given as a list, it must be a list of
1712 split into a list on whitespace. If given as a list, it must be a list of
1700 *strings* (the variable names themselves), not of variables."""
1713 *strings* (the variable names themselves), not of variables."""
1701
1714
1702 # this grabs the local variables from the *previous* call frame -- that is
1715 # this grabs the local variables from the *previous* call frame -- that is
1703 # the locals from the function that called setattr_list().
1716 # the locals from the function that called setattr_list().
1704 # - snipped from weave.inline()
1717 # - snipped from weave.inline()
1705 if nspace is None:
1718 if nspace is None:
1706 call_frame = sys._getframe().f_back
1719 call_frame = sys._getframe().f_back
1707 nspace = call_frame.f_locals
1720 nspace = call_frame.f_locals
1708
1721
1709 if type(alist) in StringTypes:
1722 if type(alist) in StringTypes:
1710 alist = alist.split()
1723 alist = alist.split()
1711 for attr in alist:
1724 for attr in alist:
1712 val = eval(attr,nspace)
1725 val = eval(attr,nspace)
1713 setattr(obj,attr,val)
1726 setattr(obj,attr,val)
1714
1727
1715 #----------------------------------------------------------------------------
1728 #----------------------------------------------------------------------------
1716 def getattr_list(obj,alist,*args):
1729 def getattr_list(obj,alist,*args):
1717 """getattr_list(obj,alist[, default]) -> attribute list.
1730 """getattr_list(obj,alist[, default]) -> attribute list.
1718
1731
1719 Get a list of named attributes for an object. When a default argument is
1732 Get a list of named attributes for an object. When a default argument is
1720 given, it is returned when the attribute doesn't exist; without it, an
1733 given, it is returned when the attribute doesn't exist; without it, an
1721 exception is raised in that case.
1734 exception is raised in that case.
1722
1735
1723 Note that alist can be given as a string, which will be automatically
1736 Note that alist can be given as a string, which will be automatically
1724 split into a list on whitespace. If given as a list, it must be a list of
1737 split into a list on whitespace. If given as a list, it must be a list of
1725 *strings* (the variable names themselves), not of variables."""
1738 *strings* (the variable names themselves), not of variables."""
1726
1739
1727 if type(alist) in StringTypes:
1740 if type(alist) in StringTypes:
1728 alist = alist.split()
1741 alist = alist.split()
1729 if args:
1742 if args:
1730 if len(args)==1:
1743 if len(args)==1:
1731 default = args[0]
1744 default = args[0]
1732 return map(lambda attr: getattr(obj,attr,default),alist)
1745 return map(lambda attr: getattr(obj,attr,default),alist)
1733 else:
1746 else:
1734 raise ValueError,'getattr_list() takes only one optional argument'
1747 raise ValueError,'getattr_list() takes only one optional argument'
1735 else:
1748 else:
1736 return map(lambda attr: getattr(obj,attr),alist)
1749 return map(lambda attr: getattr(obj,attr),alist)
1737
1750
1738 #----------------------------------------------------------------------------
1751 #----------------------------------------------------------------------------
1739 def map_method(method,object_list,*argseq,**kw):
1752 def map_method(method,object_list,*argseq,**kw):
1740 """map_method(method,object_list,*args,**kw) -> list
1753 """map_method(method,object_list,*args,**kw) -> list
1741
1754
1742 Return a list of the results of applying the methods to the items of the
1755 Return a list of the results of applying the methods to the items of the
1743 argument sequence(s). If more than one sequence is given, the method is
1756 argument sequence(s). If more than one sequence is given, the method is
1744 called with an argument list consisting of the corresponding item of each
1757 called with an argument list consisting of the corresponding item of each
1745 sequence. All sequences must be of the same length.
1758 sequence. All sequences must be of the same length.
1746
1759
1747 Keyword arguments are passed verbatim to all objects called.
1760 Keyword arguments are passed verbatim to all objects called.
1748
1761
1749 This is Python code, so it's not nearly as fast as the builtin map()."""
1762 This is Python code, so it's not nearly as fast as the builtin map()."""
1750
1763
1751 out_list = []
1764 out_list = []
1752 idx = 0
1765 idx = 0
1753 for object in object_list:
1766 for object in object_list:
1754 try:
1767 try:
1755 handler = getattr(object, method)
1768 handler = getattr(object, method)
1756 except AttributeError:
1769 except AttributeError:
1757 out_list.append(None)
1770 out_list.append(None)
1758 else:
1771 else:
1759 if argseq:
1772 if argseq:
1760 args = map(lambda lst:lst[idx],argseq)
1773 args = map(lambda lst:lst[idx],argseq)
1761 #print 'ob',object,'hand',handler,'ar',args # dbg
1774 #print 'ob',object,'hand',handler,'ar',args # dbg
1762 out_list.append(handler(args,**kw))
1775 out_list.append(handler(args,**kw))
1763 else:
1776 else:
1764 out_list.append(handler(**kw))
1777 out_list.append(handler(**kw))
1765 idx += 1
1778 idx += 1
1766 return out_list
1779 return out_list
1767
1780
1768 #----------------------------------------------------------------------------
1781 #----------------------------------------------------------------------------
1769 def get_class_members(cls):
1782 def get_class_members(cls):
1770 ret = dir(cls)
1783 ret = dir(cls)
1771 if hasattr(cls,'__bases__'):
1784 if hasattr(cls,'__bases__'):
1772 for base in cls.__bases__:
1785 for base in cls.__bases__:
1773 ret.extend(get_class_members(base))
1786 ret.extend(get_class_members(base))
1774 return ret
1787 return ret
1775
1788
1776 #----------------------------------------------------------------------------
1789 #----------------------------------------------------------------------------
1777 def dir2(obj):
1790 def dir2(obj):
1778 """dir2(obj) -> list of strings
1791 """dir2(obj) -> list of strings
1779
1792
1780 Extended version of the Python builtin dir(), which does a few extra
1793 Extended version of the Python builtin dir(), which does a few extra
1781 checks, and supports common objects with unusual internals that confuse
1794 checks, and supports common objects with unusual internals that confuse
1782 dir(), such as Traits and PyCrust.
1795 dir(), such as Traits and PyCrust.
1783
1796
1784 This version is guaranteed to return only a list of true strings, whereas
1797 This version is guaranteed to return only a list of true strings, whereas
1785 dir() returns anything that objects inject into themselves, even if they
1798 dir() returns anything that objects inject into themselves, even if they
1786 are later not really valid for attribute access (many extension libraries
1799 are later not really valid for attribute access (many extension libraries
1787 have such bugs).
1800 have such bugs).
1788 """
1801 """
1789
1802
1790 # Start building the attribute list via dir(), and then complete it
1803 # Start building the attribute list via dir(), and then complete it
1791 # with a few extra special-purpose calls.
1804 # with a few extra special-purpose calls.
1792 words = dir(obj)
1805 words = dir(obj)
1793
1806
1794 if hasattr(obj,'__class__'):
1807 if hasattr(obj,'__class__'):
1795 words.append('__class__')
1808 words.append('__class__')
1796 words.extend(get_class_members(obj.__class__))
1809 words.extend(get_class_members(obj.__class__))
1797 #if '__base__' in words: 1/0
1810 #if '__base__' in words: 1/0
1798
1811
1799 # Some libraries (such as traits) may introduce duplicates, we want to
1812 # Some libraries (such as traits) may introduce duplicates, we want to
1800 # track and clean this up if it happens
1813 # track and clean this up if it happens
1801 may_have_dupes = False
1814 may_have_dupes = False
1802
1815
1803 # this is the 'dir' function for objects with Enthought's traits
1816 # this is the 'dir' function for objects with Enthought's traits
1804 if hasattr(obj, 'trait_names'):
1817 if hasattr(obj, 'trait_names'):
1805 try:
1818 try:
1806 words.extend(obj.trait_names())
1819 words.extend(obj.trait_names())
1807 may_have_dupes = True
1820 may_have_dupes = True
1808 except TypeError:
1821 except TypeError:
1809 # This will happen if `obj` is a class and not an instance.
1822 # This will happen if `obj` is a class and not an instance.
1810 pass
1823 pass
1811
1824
1812 # Support for PyCrust-style _getAttributeNames magic method.
1825 # Support for PyCrust-style _getAttributeNames magic method.
1813 if hasattr(obj, '_getAttributeNames'):
1826 if hasattr(obj, '_getAttributeNames'):
1814 try:
1827 try:
1815 words.extend(obj._getAttributeNames())
1828 words.extend(obj._getAttributeNames())
1816 may_have_dupes = True
1829 may_have_dupes = True
1817 except TypeError:
1830 except TypeError:
1818 # `obj` is a class and not an instance. Ignore
1831 # `obj` is a class and not an instance. Ignore
1819 # this error.
1832 # this error.
1820 pass
1833 pass
1821
1834
1822 if may_have_dupes:
1835 if may_have_dupes:
1823 # eliminate possible duplicates, as some traits may also
1836 # eliminate possible duplicates, as some traits may also
1824 # appear as normal attributes in the dir() call.
1837 # appear as normal attributes in the dir() call.
1825 words = list(set(words))
1838 words = list(set(words))
1826 words.sort()
1839 words.sort()
1827
1840
1828 # filter out non-string attributes which may be stuffed by dir() calls
1841 # filter out non-string attributes which may be stuffed by dir() calls
1829 # and poor coding in third-party modules
1842 # and poor coding in third-party modules
1830 return [w for w in words if isinstance(w, basestring)]
1843 return [w for w in words if isinstance(w, basestring)]
1831
1844
1832 #----------------------------------------------------------------------------
1845 #----------------------------------------------------------------------------
1833 def import_fail_info(mod_name,fns=None):
1846 def import_fail_info(mod_name,fns=None):
1834 """Inform load failure for a module."""
1847 """Inform load failure for a module."""
1835
1848
1836 if fns == None:
1849 if fns == None:
1837 warn("Loading of %s failed.\n" % (mod_name,))
1850 warn("Loading of %s failed.\n" % (mod_name,))
1838 else:
1851 else:
1839 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1852 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1840
1853
1841 #----------------------------------------------------------------------------
1854 #----------------------------------------------------------------------------
1842 # Proposed popitem() extension, written as a method
1855 # Proposed popitem() extension, written as a method
1843
1856
1844
1857
1845 class NotGiven: pass
1858 class NotGiven: pass
1846
1859
1847 def popkey(dct,key,default=NotGiven):
1860 def popkey(dct,key,default=NotGiven):
1848 """Return dct[key] and delete dct[key].
1861 """Return dct[key] and delete dct[key].
1849
1862
1850 If default is given, return it if dct[key] doesn't exist, otherwise raise
1863 If default is given, return it if dct[key] doesn't exist, otherwise raise
1851 KeyError. """
1864 KeyError. """
1852
1865
1853 try:
1866 try:
1854 val = dct[key]
1867 val = dct[key]
1855 except KeyError:
1868 except KeyError:
1856 if default is NotGiven:
1869 if default is NotGiven:
1857 raise
1870 raise
1858 else:
1871 else:
1859 return default
1872 return default
1860 else:
1873 else:
1861 del dct[key]
1874 del dct[key]
1862 return val
1875 return val
1863
1876
1864 def wrap_deprecated(func, suggest = '<nothing>'):
1877 def wrap_deprecated(func, suggest = '<nothing>'):
1865 def newFunc(*args, **kwargs):
1878 def newFunc(*args, **kwargs):
1866 warnings.warn("Call to deprecated function %s, use %s instead" %
1879 warnings.warn("Call to deprecated function %s, use %s instead" %
1867 ( func.__name__, suggest),
1880 ( func.__name__, suggest),
1868 category=DeprecationWarning,
1881 category=DeprecationWarning,
1869 stacklevel = 2)
1882 stacklevel = 2)
1870 return func(*args, **kwargs)
1883 return func(*args, **kwargs)
1871 return newFunc
1884 return newFunc
1872
1885
1873 #*************************** end of file <genutils.py> **********************
1886 #*************************** end of file <genutils.py> **********************
1874
1887
@@ -1,7043 +1,7047 b''
1 2007-08-22 Ville Vainio <vivainio@gmail.com>
1 2007-08-22 Ville Vainio <vivainio@gmail.com>
2
2
3 * iplib.py: no extra empty (last) line in raw hist w/ multiline
3 * iplib.py: no extra empty (last) line in raw hist w/ multiline
4 statements
4 statements
5
5
6 * logger.py: Fix bug where blank lines in history were not
6 * logger.py: Fix bug where blank lines in history were not
7 added until AFTER adding the current line; translated and raw
7 added until AFTER adding the current line; translated and raw
8 history should finally be in sync with prompt now.
8 history should finally be in sync with prompt now.
9
9
10 * ipy_completers.py: quick_completer now makes it easy to create
10 * ipy_completers.py: quick_completer now makes it easy to create
11 trivial custom completers
11 trivial custom completers
12
12
13 * clearcmd.py: shadow history compression & erasing
13 * clearcmd.py: shadow history compression & erasing
14
14
15 * envpersist.py, history.py: %env (sh profile only), %hist completers
15 * envpersist.py, history.py: %env (sh profile only), %hist completers
16
16
17 * genutils.py, Prompts.py, Magic.py: win32 - prompt (with \yDEPTH) and
18 term title now include the drive letter, and always use / instead of
19 os.sep (as per recommended approach for win32 ipython in general).
20
17 2007-08-21 Ville Vainio <vivainio@gmail.com>
21 2007-08-21 Ville Vainio <vivainio@gmail.com>
18
22
19 * ipmaker.py: finding ipythonrc-PROF now skips ipy_profile_PROF.
23 * ipmaker.py: finding ipythonrc-PROF now skips ipy_profile_PROF.
20 (for backwards compatibility)
24 (for backwards compatibility)
21
25
22 * history.py: switch back to %hist -t from %hist -r as default.
26 * history.py: switch back to %hist -t from %hist -r as default.
23 At least until raw history is fixed for good.
27 At least until raw history is fixed for good.
24
28
25 2007-08-20 Ville Vainio <vivainio@gmail.com>
29 2007-08-20 Ville Vainio <vivainio@gmail.com>
26
30
27 * ipapi.py, iplib.py: DebugTools accessible via _ip.dbg, to catch &
31 * ipapi.py, iplib.py: DebugTools accessible via _ip.dbg, to catch &
28 locate alias redeclarations etc. Also, avoid handling
32 locate alias redeclarations etc. Also, avoid handling
29 _ip.IP.alias_table directly, prefer using _ip.defalias.
33 _ip.IP.alias_table directly, prefer using _ip.defalias.
30
34
31
35
32 2007-08-15 Ville Vainio <vivainio@gmail.com>
36 2007-08-15 Ville Vainio <vivainio@gmail.com>
33
37
34 * prefilter.py: ! is now always served first
38 * prefilter.py: ! is now always served first
35
39
36 2007-08-15 Fernando Perez <Fernando.Perez@colorado.edu>
40 2007-08-15 Fernando Perez <Fernando.Perez@colorado.edu>
37
41
38 * IPython/iplib.py (safe_execfile): fix the SystemExit
42 * IPython/iplib.py (safe_execfile): fix the SystemExit
39 auto-suppression code to work in Python2.4 (the internal structure
43 auto-suppression code to work in Python2.4 (the internal structure
40 of that exception changed and I'd only tested the code with 2.5).
44 of that exception changed and I'd only tested the code with 2.5).
41 Bug reported by a SciPy attendee.
45 Bug reported by a SciPy attendee.
42
46
43 2007-08-13 Ville Vainio <vivainio@gmail.com>
47 2007-08-13 Ville Vainio <vivainio@gmail.com>
44
48
45 * prefilter.py: reverted !c:/bin/foo fix, made % in
49 * prefilter.py: reverted !c:/bin/foo fix, made % in
46 multiline specials work again
50 multiline specials work again
47
51
48 2007-08-13 Ville Vainio <vivainio@gmail.com>
52 2007-08-13 Ville Vainio <vivainio@gmail.com>
49
53
50 * prefilter.py: Take more care to special-case !, so that
54 * prefilter.py: Take more care to special-case !, so that
51 !c:/bin/foo.exe works.
55 !c:/bin/foo.exe works.
52
56
53 * setup.py: if we are building eggs, strip all docs and
57 * setup.py: if we are building eggs, strip all docs and
54 examples (it doesn't make sense to bytecompile examples,
58 examples (it doesn't make sense to bytecompile examples,
55 and docs would be in an awkward place anyway).
59 and docs would be in an awkward place anyway).
56
60
57 * Ryan Krauss' patch fixes start menu shortcuts when IPython
61 * Ryan Krauss' patch fixes start menu shortcuts when IPython
58 is installed into a directory that has spaces in the name.
62 is installed into a directory that has spaces in the name.
59
63
60 2007-08-13 Fernando Perez <Fernando.Perez@colorado.edu>
64 2007-08-13 Fernando Perez <Fernando.Perez@colorado.edu>
61
65
62 * IPython/Magic.py (magic_doctest_mode): fix prompt separators in
66 * IPython/Magic.py (magic_doctest_mode): fix prompt separators in
63 doctest profile and %doctest_mode, so they actually generate the
67 doctest profile and %doctest_mode, so they actually generate the
64 blank lines needed by doctest to separate individual tests.
68 blank lines needed by doctest to separate individual tests.
65
69
66 * IPython/iplib.py (safe_execfile): modify so that running code
70 * IPython/iplib.py (safe_execfile): modify so that running code
67 which calls sys.exit(0) (or equivalently, raise SystemExit(0))
71 which calls sys.exit(0) (or equivalently, raise SystemExit(0))
68 doesn't get a printed traceback. Any other value in sys.exit(),
72 doesn't get a printed traceback. Any other value in sys.exit(),
69 including the empty call, still generates a traceback. This
73 including the empty call, still generates a traceback. This
70 enables use of %run without having to pass '-e' for codes that
74 enables use of %run without having to pass '-e' for codes that
71 correctly set the exit status flag.
75 correctly set the exit status flag.
72
76
73 2007-08-12 Fernando Perez <Fernando.Perez@colorado.edu>
77 2007-08-12 Fernando Perez <Fernando.Perez@colorado.edu>
74
78
75 * IPython/iplib.py (InteractiveShell.post_config_initialization):
79 * IPython/iplib.py (InteractiveShell.post_config_initialization):
76 fix problems with doctests failing when run inside IPython due to
80 fix problems with doctests failing when run inside IPython due to
77 IPython's modifications of sys.displayhook.
81 IPython's modifications of sys.displayhook.
78
82
79 2007-8-9 Fernando Perez <fperez@planck.colorado.edu>
83 2007-8-9 Fernando Perez <fperez@planck.colorado.edu>
80
84
81 * IPython/ipapi.py (to_user_ns): update to accept a dict as well as
85 * IPython/ipapi.py (to_user_ns): update to accept a dict as well as
82 a string with names.
86 a string with names.
83
87
84 2007-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
88 2007-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
85
89
86 * IPython/Magic.py (magic_doctest_mode): added new %doctest_mode
90 * IPython/Magic.py (magic_doctest_mode): added new %doctest_mode
87 magic to toggle on/off the doctest pasting support without having
91 magic to toggle on/off the doctest pasting support without having
88 to leave a session to switch to a separate profile.
92 to leave a session to switch to a separate profile.
89
93
90 2007-08-08 Fernando Perez <Fernando.Perez@colorado.edu>
94 2007-08-08 Fernando Perez <Fernando.Perez@colorado.edu>
91
95
92 * IPython/Extensions/ipy_profile_doctest.py (main): fix prompt to
96 * IPython/Extensions/ipy_profile_doctest.py (main): fix prompt to
93 introduce a blank line between inputs, to conform to doctest
97 introduce a blank line between inputs, to conform to doctest
94 requirements.
98 requirements.
95
99
96 * IPython/OInspect.py (Inspector.pinfo): fix another part where
100 * IPython/OInspect.py (Inspector.pinfo): fix another part where
97 auto-generated docstrings for new-style classes were showing up.
101 auto-generated docstrings for new-style classes were showing up.
98
102
99 2007-08-07 Fernando Perez <Fernando.Perez@colorado.edu>
103 2007-08-07 Fernando Perez <Fernando.Perez@colorado.edu>
100
104
101 * api_changes: Add new file to track backward-incompatible
105 * api_changes: Add new file to track backward-incompatible
102 user-visible changes.
106 user-visible changes.
103
107
104 2007-08-06 Ville Vainio <vivainio@gmail.com>
108 2007-08-06 Ville Vainio <vivainio@gmail.com>
105
109
106 * ipmaker.py: fix bug where user_config_ns didn't exist at all
110 * ipmaker.py: fix bug where user_config_ns didn't exist at all
107 before all the config files were handled.
111 before all the config files were handled.
108
112
109 2007-08-04 Fernando Perez <Fernando.Perez@colorado.edu>
113 2007-08-04 Fernando Perez <Fernando.Perez@colorado.edu>
110
114
111 * IPython/irunner.py (RunnerFactory): Add new factory class for
115 * IPython/irunner.py (RunnerFactory): Add new factory class for
112 creating reusable runners based on filenames.
116 creating reusable runners based on filenames.
113
117
114 * IPython/Extensions/ipy_profile_doctest.py: New profile for
118 * IPython/Extensions/ipy_profile_doctest.py: New profile for
115 doctest support. It sets prompts/exceptions as similar to
119 doctest support. It sets prompts/exceptions as similar to
116 standard Python as possible, so that ipython sessions in this
120 standard Python as possible, so that ipython sessions in this
117 profile can be easily pasted as doctests with minimal
121 profile can be easily pasted as doctests with minimal
118 modifications. It also enables pasting of doctests from external
122 modifications. It also enables pasting of doctests from external
119 sources (even if they have leading whitespace), so that you can
123 sources (even if they have leading whitespace), so that you can
120 rerun doctests from existing sources.
124 rerun doctests from existing sources.
121
125
122 * IPython/iplib.py (_prefilter): fix a buglet where after entering
126 * IPython/iplib.py (_prefilter): fix a buglet where after entering
123 some whitespace, the prompt would become a continuation prompt
127 some whitespace, the prompt would become a continuation prompt
124 with no way of exiting it other than Ctrl-C. This fix brings us
128 with no way of exiting it other than Ctrl-C. This fix brings us
125 into conformity with how the default python prompt works.
129 into conformity with how the default python prompt works.
126
130
127 * IPython/Extensions/InterpreterPasteInput.py (prefilter_paste):
131 * IPython/Extensions/InterpreterPasteInput.py (prefilter_paste):
128 Add support for pasting not only lines that start with '>>>', but
132 Add support for pasting not only lines that start with '>>>', but
129 also with ' >>>'. That is, arbitrary whitespace can now precede
133 also with ' >>>'. That is, arbitrary whitespace can now precede
130 the prompts. This makes the system useful for pasting doctests
134 the prompts. This makes the system useful for pasting doctests
131 from docstrings back into a normal session.
135 from docstrings back into a normal session.
132
136
133 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu>
137 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu>
134
138
135 * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in
139 * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in
136 r1357, which had killed multiple invocations of an embedded
140 r1357, which had killed multiple invocations of an embedded
137 ipython (this means that example-embed has been broken for over 1
141 ipython (this means that example-embed has been broken for over 1
138 year!!!). Rather than possibly breaking the batch stuff for which
142 year!!!). Rather than possibly breaking the batch stuff for which
139 the code in iplib.py/interact was introduced, I worked around the
143 the code in iplib.py/interact was introduced, I worked around the
140 problem in the embedding class in Shell.py. We really need a
144 problem in the embedding class in Shell.py. We really need a
141 bloody test suite for this code, I'm sick of finding stuff that
145 bloody test suite for this code, I'm sick of finding stuff that
142 used to work breaking left and right every time I use an old
146 used to work breaking left and right every time I use an old
143 feature I hadn't touched in a few months.
147 feature I hadn't touched in a few months.
144 (kill_embedded): Add a new magic that only shows up in embedded
148 (kill_embedded): Add a new magic that only shows up in embedded
145 mode, to allow users to permanently deactivate an embedded instance.
149 mode, to allow users to permanently deactivate an embedded instance.
146
150
147 2007-08-01 Ville Vainio <vivainio@gmail.com>
151 2007-08-01 Ville Vainio <vivainio@gmail.com>
148
152
149 * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw
153 * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw
150 history gets out of sync on runlines (e.g. when running macros).
154 history gets out of sync on runlines (e.g. when running macros).
151
155
152 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu>
156 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu>
153
157
154 * IPython/Magic.py (magic_colors): fix win32-related error message
158 * IPython/Magic.py (magic_colors): fix win32-related error message
155 that could appear under *nix when readline was missing. Patch by
159 that could appear under *nix when readline was missing. Patch by
156 Scott Jackson, closes #175.
160 Scott Jackson, closes #175.
157
161
158 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
162 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
159
163
160 * IPython/Extensions/ipy_traits_completer.py: Add a new custom
164 * IPython/Extensions/ipy_traits_completer.py: Add a new custom
161 completer that it traits-aware, so that traits objects don't show
165 completer that it traits-aware, so that traits objects don't show
162 all of their internal attributes all the time.
166 all of their internal attributes all the time.
163
167
164 * IPython/genutils.py (dir2): moved this code from inside
168 * IPython/genutils.py (dir2): moved this code from inside
165 completer.py to expose it publicly, so I could use it in the
169 completer.py to expose it publicly, so I could use it in the
166 wildcards bugfix.
170 wildcards bugfix.
167
171
168 * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by
172 * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by
169 Stefan with Traits.
173 Stefan with Traits.
170
174
171 * IPython/completer.py (Completer.attr_matches): change internal
175 * IPython/completer.py (Completer.attr_matches): change internal
172 var name from 'object' to 'obj', since 'object' is now a builtin
176 var name from 'object' to 'obj', since 'object' is now a builtin
173 and this can lead to weird bugs if reusing this code elsewhere.
177 and this can lead to weird bugs if reusing this code elsewhere.
174
178
175 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu>
179 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu>
176
180
177 * IPython/OInspect.py (Inspector.pinfo): fix small glitches in
181 * IPython/OInspect.py (Inspector.pinfo): fix small glitches in
178 'foo?' and update the code to prevent printing of default
182 'foo?' and update the code to prevent printing of default
179 docstrings that started appearing after I added support for
183 docstrings that started appearing after I added support for
180 new-style classes. The approach I'm using isn't ideal (I just
184 new-style classes. The approach I'm using isn't ideal (I just
181 special-case those strings) but I'm not sure how to more robustly
185 special-case those strings) but I'm not sure how to more robustly
182 differentiate between truly user-written strings and Python's
186 differentiate between truly user-written strings and Python's
183 automatic ones.
187 automatic ones.
184
188
185 2007-07-09 Ville Vainio <vivainio@gmail.com>
189 2007-07-09 Ville Vainio <vivainio@gmail.com>
186
190
187 * completer.py: Applied Matthew Neeley's patch:
191 * completer.py: Applied Matthew Neeley's patch:
188 Dynamic attributes from trait_names and _getAttributeNames are added
192 Dynamic attributes from trait_names and _getAttributeNames are added
189 to the list of tab completions, but when this happens, the attribute
193 to the list of tab completions, but when this happens, the attribute
190 list is turned into a set, so the attributes are unordered when
194 list is turned into a set, so the attributes are unordered when
191 printed, which makes it hard to find the right completion. This patch
195 printed, which makes it hard to find the right completion. This patch
192 turns this set back into a list and sort it.
196 turns this set back into a list and sort it.
193
197
194 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu>
198 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu>
195
199
196 * IPython/OInspect.py (Inspector.pinfo): Add support for new-style
200 * IPython/OInspect.py (Inspector.pinfo): Add support for new-style
197 classes in various inspector functions.
201 classes in various inspector functions.
198
202
199 2007-06-28 Ville Vainio <vivainio@gmail.com>
203 2007-06-28 Ville Vainio <vivainio@gmail.com>
200
204
201 * shadowns.py, iplib.py, ipapi.py, OInspect.py:
205 * shadowns.py, iplib.py, ipapi.py, OInspect.py:
202 Implement "shadow" namespace, and callable aliases that reside there.
206 Implement "shadow" namespace, and callable aliases that reside there.
203 Use them by:
207 Use them by:
204
208
205 _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc
209 _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc
206
210
207 foo hello world
211 foo hello world
208 (gets translated to:)
212 (gets translated to:)
209 _sh.foo(r"""hello world""")
213 _sh.foo(r"""hello world""")
210
214
211 In practice, this kind of alias can take the role of a magic function
215 In practice, this kind of alias can take the role of a magic function
212
216
213 * New generic inspect_object, called on obj? and obj??
217 * New generic inspect_object, called on obj? and obj??
214
218
215 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu>
219 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu>
216
220
217 * IPython/ultraTB.py (findsource): fix a problem with
221 * IPython/ultraTB.py (findsource): fix a problem with
218 inspect.getfile that can cause crashes during traceback construction.
222 inspect.getfile that can cause crashes during traceback construction.
219
223
220 2007-06-14 Ville Vainio <vivainio@gmail.com>
224 2007-06-14 Ville Vainio <vivainio@gmail.com>
221
225
222 * iplib.py (handle_auto): Try to use ascii for printing "--->"
226 * iplib.py (handle_auto): Try to use ascii for printing "--->"
223 autocall rewrite indication, becausesometimes unicode fails to print
227 autocall rewrite indication, becausesometimes unicode fails to print
224 properly (and you get ' - - - '). Use plain uncoloured ---> for
228 properly (and you get ' - - - '). Use plain uncoloured ---> for
225 unicode.
229 unicode.
226
230
227 * shadow history. Usable through "%hist -g <pat>" and "%rep 0123".
231 * shadow history. Usable through "%hist -g <pat>" and "%rep 0123".
228
232
229 . pickleshare 'hash' commands (hget, hset, hcompress,
233 . pickleshare 'hash' commands (hget, hset, hcompress,
230 hdict) for efficient shadow history storage.
234 hdict) for efficient shadow history storage.
231
235
232 2007-06-13 Ville Vainio <vivainio@gmail.com>
236 2007-06-13 Ville Vainio <vivainio@gmail.com>
233
237
234 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
238 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
235 Added kw arg 'interactive', tell whether vars should be visible
239 Added kw arg 'interactive', tell whether vars should be visible
236 with %whos.
240 with %whos.
237
241
238 2007-06-11 Ville Vainio <vivainio@gmail.com>
242 2007-06-11 Ville Vainio <vivainio@gmail.com>
239
243
240 * pspersistence.py, Magic.py, iplib.py: directory history now saved
244 * pspersistence.py, Magic.py, iplib.py: directory history now saved
241 to db
245 to db
242
246
243 * iplib.py: "ipython -c <cmd>" now passes the command through prefilter.
247 * iplib.py: "ipython -c <cmd>" now passes the command through prefilter.
244 Also, it exits IPython immediately after evaluating the command (just like
248 Also, it exits IPython immediately after evaluating the command (just like
245 std python)
249 std python)
246
250
247 2007-06-05 Walter Doerwald <walter@livinglogic.de>
251 2007-06-05 Walter Doerwald <walter@livinglogic.de>
248
252
249 * IPython/Extensions/ipipe.py: Added a new table icap, which executes a
253 * IPython/Extensions/ipipe.py: Added a new table icap, which executes a
250 Python string and captures the output. (Idea and original patch by
254 Python string and captures the output. (Idea and original patch by
251 StοΏ½fan van der Walt)
255 StοΏ½fan van der Walt)
252
256
253 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu>
257 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu>
254
258
255 * IPython/ultraTB.py (VerboseTB.text): update printing of
259 * IPython/ultraTB.py (VerboseTB.text): update printing of
256 exception types for Python 2.5 (now all exceptions in the stdlib
260 exception types for Python 2.5 (now all exceptions in the stdlib
257 are new-style classes).
261 are new-style classes).
258
262
259 2007-05-31 Walter Doerwald <walter@livinglogic.de>
263 2007-05-31 Walter Doerwald <walter@livinglogic.de>
260
264
261 * IPython/Extensions/igrid.py: Add new commands refresh and
265 * IPython/Extensions/igrid.py: Add new commands refresh and
262 refresh_timer (mapped to "R"/"F5" and to the menu) which restarts
266 refresh_timer (mapped to "R"/"F5" and to the menu) which restarts
263 the iterator once (refresh) or after every x seconds (refresh_timer).
267 the iterator once (refresh) or after every x seconds (refresh_timer).
264 Add a working implementation of "searchexpression", where the text
268 Add a working implementation of "searchexpression", where the text
265 entered is not the text to search for, but an expression that must
269 entered is not the text to search for, but an expression that must
266 be true. Added display of shortcuts to the menu. Added commands "pickinput"
270 be true. Added display of shortcuts to the menu. Added commands "pickinput"
267 and "pickinputattr" that put the object or attribute under the cursor
271 and "pickinputattr" that put the object or attribute under the cursor
268 in the input line. Split the statusbar to be able to display the currently
272 in the input line. Split the statusbar to be able to display the currently
269 active refresh interval. (Patch by Nik Tautenhahn)
273 active refresh interval. (Patch by Nik Tautenhahn)
270
274
271 2007-05-29 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
275 2007-05-29 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
272
276
273 * fixing set_term_title to use ctypes as default
277 * fixing set_term_title to use ctypes as default
274
278
275 * fixing set_term_title fallback to work when curent dir
279 * fixing set_term_title fallback to work when curent dir
276 is on a windows network share
280 is on a windows network share
277
281
278 2007-05-28 Ville Vainio <vivainio@gmail.com>
282 2007-05-28 Ville Vainio <vivainio@gmail.com>
279
283
280 * %cpaste: strip + with > from left (diffs).
284 * %cpaste: strip + with > from left (diffs).
281
285
282 * iplib.py: Fix crash when readline not installed
286 * iplib.py: Fix crash when readline not installed
283
287
284 2007-05-26 Ville Vainio <vivainio@gmail.com>
288 2007-05-26 Ville Vainio <vivainio@gmail.com>
285
289
286 * generics.py: intruduce easy to extend result_display generic
290 * generics.py: intruduce easy to extend result_display generic
287 function (using simplegeneric.py).
291 function (using simplegeneric.py).
288
292
289 * Fixed the append functionality of %set.
293 * Fixed the append functionality of %set.
290
294
291 2007-05-25 Ville Vainio <vivainio@gmail.com>
295 2007-05-25 Ville Vainio <vivainio@gmail.com>
292
296
293 * New magic: %rep (fetch / run old commands from history)
297 * New magic: %rep (fetch / run old commands from history)
294
298
295 * New extension: mglob (%mglob magic), for powerful glob / find /filter
299 * New extension: mglob (%mglob magic), for powerful glob / find /filter
296 like functionality
300 like functionality
297
301
298 % maghistory.py: %hist -g PATTERM greps the history for pattern
302 % maghistory.py: %hist -g PATTERM greps the history for pattern
299
303
300 2007-05-24 Walter Doerwald <walter@livinglogic.de>
304 2007-05-24 Walter Doerwald <walter@livinglogic.de>
301
305
302 * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to
306 * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to
303 browse the IPython input history
307 browse the IPython input history
304
308
305 * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput
309 * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput
306 (mapped to "i") can be used to put the object under the curser in the input
310 (mapped to "i") can be used to put the object under the curser in the input
307 line. pickinputattr (mapped to "I") does the same for the attribute under
311 line. pickinputattr (mapped to "I") does the same for the attribute under
308 the cursor.
312 the cursor.
309
313
310 2007-05-24 Ville Vainio <vivainio@gmail.com>
314 2007-05-24 Ville Vainio <vivainio@gmail.com>
311
315
312 * Grand magic cleansing (changeset [2380]):
316 * Grand magic cleansing (changeset [2380]):
313
317
314 * Introduce ipy_legacy.py where the following magics were
318 * Introduce ipy_legacy.py where the following magics were
315 moved:
319 moved:
316
320
317 pdef pdoc psource pfile rehash dhist Quit p r automagic autocall
321 pdef pdoc psource pfile rehash dhist Quit p r automagic autocall
318
322
319 If you need them, either use default profile or "import ipy_legacy"
323 If you need them, either use default profile or "import ipy_legacy"
320 in your ipy_user_conf.py
324 in your ipy_user_conf.py
321
325
322 * Move sh and scipy profile to Extensions from UserConfig. this implies
326 * Move sh and scipy profile to Extensions from UserConfig. this implies
323 you should not edit them, but you don't need to run %upgrade when
327 you should not edit them, but you don't need to run %upgrade when
324 upgrading IPython anymore.
328 upgrading IPython anymore.
325
329
326 * %hist/%history now operates in "raw" mode by default. To get the old
330 * %hist/%history now operates in "raw" mode by default. To get the old
327 behaviour, run '%hist -n' (native mode).
331 behaviour, run '%hist -n' (native mode).
328
332
329 * split ipy_stock_completers.py to ipy_stock_completers.py and
333 * split ipy_stock_completers.py to ipy_stock_completers.py and
330 ipy_app_completers.py. Stock completers (%cd, import, %run) are now
334 ipy_app_completers.py. Stock completers (%cd, import, %run) are now
331 installed as default.
335 installed as default.
332
336
333 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
337 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
334 handling.
338 handling.
335
339
336 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
340 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
337 input if readline is available.
341 input if readline is available.
338
342
339 2007-05-23 Ville Vainio <vivainio@gmail.com>
343 2007-05-23 Ville Vainio <vivainio@gmail.com>
340
344
341 * macro.py: %store uses __getstate__ properly
345 * macro.py: %store uses __getstate__ properly
342
346
343 * exesetup.py: added new setup script for creating
347 * exesetup.py: added new setup script for creating
344 standalone IPython executables with py2exe (i.e.
348 standalone IPython executables with py2exe (i.e.
345 no python installation required).
349 no python installation required).
346
350
347 * Removed ipythonrc-scipy, ipy_profile_scipy.py takes
351 * Removed ipythonrc-scipy, ipy_profile_scipy.py takes
348 its place.
352 its place.
349
353
350 * rlineimpl.py, genutils.py (get_home_dir): py2exe support
354 * rlineimpl.py, genutils.py (get_home_dir): py2exe support
351
355
352 2007-05-21 Ville Vainio <vivainio@gmail.com>
356 2007-05-21 Ville Vainio <vivainio@gmail.com>
353
357
354 * platutil_win32.py (set_term_title): handle
358 * platutil_win32.py (set_term_title): handle
355 failure of 'title' system call properly.
359 failure of 'title' system call properly.
356
360
357 2007-05-17 Walter Doerwald <walter@livinglogic.de>
361 2007-05-17 Walter Doerwald <walter@livinglogic.de>
358
362
359 * IPython/Extensions/ipipe.py: Fix xrepr for ifiles.
363 * IPython/Extensions/ipipe.py: Fix xrepr for ifiles.
360 (Bug detected by Paul Mueller).
364 (Bug detected by Paul Mueller).
361
365
362 2007-05-16 Ville Vainio <vivainio@gmail.com>
366 2007-05-16 Ville Vainio <vivainio@gmail.com>
363
367
364 * ipy_profile_sci.py, ipython_win_post_install.py: Create
368 * ipy_profile_sci.py, ipython_win_post_install.py: Create
365 new "sci" profile, effectively a modern version of the old
369 new "sci" profile, effectively a modern version of the old
366 "scipy" profile (which is now slated for deprecation).
370 "scipy" profile (which is now slated for deprecation).
367
371
368 2007-05-15 Ville Vainio <vivainio@gmail.com>
372 2007-05-15 Ville Vainio <vivainio@gmail.com>
369
373
370 * pycolorize.py, pycolor.1: Paul Mueller's patches that
374 * pycolorize.py, pycolor.1: Paul Mueller's patches that
371 make pycolorize read input from stdin when run without arguments.
375 make pycolorize read input from stdin when run without arguments.
372
376
373 * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155
377 * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155
374
378
375 * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import
379 * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import
376 it in sh profile (instead of ipy_system_conf.py).
380 it in sh profile (instead of ipy_system_conf.py).
377
381
378 * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command
382 * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command
379 aliases are now lower case on windows (MyCommand.exe => mycommand).
383 aliases are now lower case on windows (MyCommand.exe => mycommand).
380
384
381 * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul.
385 * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul.
382 Macros are now callable objects that inherit from ipapi.IPyAutocall,
386 Macros are now callable objects that inherit from ipapi.IPyAutocall,
383 i.e. get autocalled regardless of system autocall setting.
387 i.e. get autocalled regardless of system autocall setting.
384
388
385 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
389 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
386
390
387 * IPython/rlineimpl.py: check for clear_history in readline and
391 * IPython/rlineimpl.py: check for clear_history in readline and
388 make it a dummy no-op if not available. This function isn't
392 make it a dummy no-op if not available. This function isn't
389 guaranteed to be in the API and appeared in Python 2.4, so we need
393 guaranteed to be in the API and appeared in Python 2.4, so we need
390 to check it ourselves. Also, clean up this file quite a bit.
394 to check it ourselves. Also, clean up this file quite a bit.
391
395
392 * ipython.1: update man page and full manual with information
396 * ipython.1: update man page and full manual with information
393 about threads (remove outdated warning). Closes #151.
397 about threads (remove outdated warning). Closes #151.
394
398
395 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu>
399 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu>
396
400
397 * IPython/Extensions/ipy_constants.py: Add Gael's constants module
401 * IPython/Extensions/ipy_constants.py: Add Gael's constants module
398 in trunk (note that this made it into the 0.8.1 release already,
402 in trunk (note that this made it into the 0.8.1 release already,
399 but the changelogs didn't get coordinated). Many thanks to Gael
403 but the changelogs didn't get coordinated). Many thanks to Gael
400 Varoquaux <gael.varoquaux-AT-normalesup.org>
404 Varoquaux <gael.varoquaux-AT-normalesup.org>
401
405
402 2007-05-09 *** Released version 0.8.1
406 2007-05-09 *** Released version 0.8.1
403
407
404 2007-05-10 Walter Doerwald <walter@livinglogic.de>
408 2007-05-10 Walter Doerwald <walter@livinglogic.de>
405
409
406 * IPython/Extensions/igrid.py: Incorporate html help into
410 * IPython/Extensions/igrid.py: Incorporate html help into
407 the module, so we don't have to search for the file.
411 the module, so we don't have to search for the file.
408
412
409 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu>
413 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu>
410
414
411 * test/test_irunner.py (RunnerTestCase._test_runner): Close #147.
415 * test/test_irunner.py (RunnerTestCase._test_runner): Close #147.
412
416
413 2007-04-30 Ville Vainio <vivainio@gmail.com>
417 2007-04-30 Ville Vainio <vivainio@gmail.com>
414
418
415 * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the
419 * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the
416 user has illegal (non-ascii) home directory name
420 user has illegal (non-ascii) home directory name
417
421
418 2007-04-27 Ville Vainio <vivainio@gmail.com>
422 2007-04-27 Ville Vainio <vivainio@gmail.com>
419
423
420 * platutils_win32.py: implement set_term_title for windows
424 * platutils_win32.py: implement set_term_title for windows
421
425
422 * Update version number
426 * Update version number
423
427
424 * ipy_profile_sh.py: more informative prompt (2 dir levels)
428 * ipy_profile_sh.py: more informative prompt (2 dir levels)
425
429
426 2007-04-26 Walter Doerwald <walter@livinglogic.de>
430 2007-04-26 Walter Doerwald <walter@livinglogic.de>
427
431
428 * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced
432 * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced
429 when the igrid input raised an exception. (Patch by Nik Tautenhahn,
433 when the igrid input raised an exception. (Patch by Nik Tautenhahn,
430 bug discovered by Ville).
434 bug discovered by Ville).
431
435
432 2007-04-26 Ville Vainio <vivainio@gmail.com>
436 2007-04-26 Ville Vainio <vivainio@gmail.com>
433
437
434 * Extensions/ipy_completers.py: Olivier's module completer now
438 * Extensions/ipy_completers.py: Olivier's module completer now
435 saves the list of root modules if it takes > 4 secs on the first run.
439 saves the list of root modules if it takes > 4 secs on the first run.
436
440
437 * Magic.py (%rehashx): %rehashx now clears the completer cache
441 * Magic.py (%rehashx): %rehashx now clears the completer cache
438
442
439
443
440 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu>
444 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu>
441
445
442 * ipython.el: fix incorrect color scheme, reported by Stefan.
446 * ipython.el: fix incorrect color scheme, reported by Stefan.
443 Closes #149.
447 Closes #149.
444
448
445 * IPython/PyColorize.py (Parser.format2): fix state-handling
449 * IPython/PyColorize.py (Parser.format2): fix state-handling
446 logic. I still don't like how that code handles state, but at
450 logic. I still don't like how that code handles state, but at
447 least now it should be correct, if inelegant. Closes #146.
451 least now it should be correct, if inelegant. Closes #146.
448
452
449 2007-04-25 Ville Vainio <vivainio@gmail.com>
453 2007-04-25 Ville Vainio <vivainio@gmail.com>
450
454
451 * Extensions/ipy_which.py: added extension for %which magic, works
455 * Extensions/ipy_which.py: added extension for %which magic, works
452 a lot like unix 'which' but also finds and expands aliases, and
456 a lot like unix 'which' but also finds and expands aliases, and
453 allows wildcards.
457 allows wildcards.
454
458
455 * ipapi.py (expand_alias): Now actually *return* the expanded alias,
459 * ipapi.py (expand_alias): Now actually *return* the expanded alias,
456 as opposed to returning nothing.
460 as opposed to returning nothing.
457
461
458 * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import
462 * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import
459 ipy_stock_completers on default profile, do import on sh profile.
463 ipy_stock_completers on default profile, do import on sh profile.
460
464
461 2007-04-22 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
465 2007-04-22 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
462
466
463 * Fix bug in iplib.py/safe_execfile when launching ipython with a script
467 * Fix bug in iplib.py/safe_execfile when launching ipython with a script
464 like ipython.py foo.py which raised a IndexError.
468 like ipython.py foo.py which raised a IndexError.
465
469
466 2007-04-21 Ville Vainio <vivainio@gmail.com>
470 2007-04-21 Ville Vainio <vivainio@gmail.com>
467
471
468 * Extensions/ipy_extutil.py: added extension to manage other ipython
472 * Extensions/ipy_extutil.py: added extension to manage other ipython
469 extensions. Now only supports 'ls' == list extensions.
473 extensions. Now only supports 'ls' == list extensions.
470
474
471 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
475 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
472
476
473 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
477 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
474 would prevent use of the exception system outside of a running
478 would prevent use of the exception system outside of a running
475 IPython instance.
479 IPython instance.
476
480
477 2007-04-20 Ville Vainio <vivainio@gmail.com>
481 2007-04-20 Ville Vainio <vivainio@gmail.com>
478
482
479 * Extensions/ipy_render.py: added extension for easy
483 * Extensions/ipy_render.py: added extension for easy
480 interactive text template rendering (to clipboard). Uses Ka-Ping Yee's
484 interactive text template rendering (to clipboard). Uses Ka-Ping Yee's
481 'Iptl' template notation,
485 'Iptl' template notation,
482
486
483 * Extensions/ipy_completers.py: introduced Olivier Lauzanne's
487 * Extensions/ipy_completers.py: introduced Olivier Lauzanne's
484 safer & faster 'import' completer.
488 safer & faster 'import' completer.
485
489
486 * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value)
490 * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value)
487 and _ip.defalias(name, command).
491 and _ip.defalias(name, command).
488
492
489 * Extensions/ipy_exportdb.py: New extension for exporting all the
493 * Extensions/ipy_exportdb.py: New extension for exporting all the
490 %store'd data in a portable format (normal ipapi calls like
494 %store'd data in a portable format (normal ipapi calls like
491 defmacro() etc.)
495 defmacro() etc.)
492
496
493 2007-04-19 Ville Vainio <vivainio@gmail.com>
497 2007-04-19 Ville Vainio <vivainio@gmail.com>
494
498
495 * upgrade_dir.py: skip junk files like *.pyc
499 * upgrade_dir.py: skip junk files like *.pyc
496
500
497 * Release.py: version number to 0.8.1
501 * Release.py: version number to 0.8.1
498
502
499 2007-04-18 Ville Vainio <vivainio@gmail.com>
503 2007-04-18 Ville Vainio <vivainio@gmail.com>
500
504
501 * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1
505 * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1
502 and later on win32.
506 and later on win32.
503
507
504 2007-04-16 Ville Vainio <vivainio@gmail.com>
508 2007-04-16 Ville Vainio <vivainio@gmail.com>
505
509
506 * iplib.py (showtraceback): Do not crash when running w/o readline.
510 * iplib.py (showtraceback): Do not crash when running w/o readline.
507
511
508 2007-04-12 Walter Doerwald <walter@livinglogic.de>
512 2007-04-12 Walter Doerwald <walter@livinglogic.de>
509
513
510 * IPython/Extensions/ipipe.py: (ils) Directoy listings are now
514 * IPython/Extensions/ipipe.py: (ils) Directoy listings are now
511 sorted (case sensitive with files and dirs mixed).
515 sorted (case sensitive with files and dirs mixed).
512
516
513 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu>
517 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu>
514
518
515 * IPython/Release.py (version): Open trunk for 0.8.1 development.
519 * IPython/Release.py (version): Open trunk for 0.8.1 development.
516
520
517 2007-04-10 *** Released version 0.8.0
521 2007-04-10 *** Released version 0.8.0
518
522
519 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
523 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
520
524
521 * Tag 0.8.0 for release.
525 * Tag 0.8.0 for release.
522
526
523 * IPython/iplib.py (reloadhist): add API function to cleanly
527 * IPython/iplib.py (reloadhist): add API function to cleanly
524 reload the readline history, which was growing inappropriately on
528 reload the readline history, which was growing inappropriately on
525 every %run call.
529 every %run call.
526
530
527 * win32_manual_post_install.py (run): apply last part of Nicolas
531 * win32_manual_post_install.py (run): apply last part of Nicolas
528 Pernetty's patch (I'd accidentally applied it in a different
532 Pernetty's patch (I'd accidentally applied it in a different
529 directory and this particular file didn't get patched).
533 directory and this particular file didn't get patched).
530
534
531 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
535 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
532
536
533 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
537 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
534 find the main thread id and use the proper API call. Thanks to
538 find the main thread id and use the proper API call. Thanks to
535 Stefan for the fix.
539 Stefan for the fix.
536
540
537 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
541 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
538 unit tests to reflect fixed ticket #52, and add more tests sent by
542 unit tests to reflect fixed ticket #52, and add more tests sent by
539 him.
543 him.
540
544
541 * IPython/iplib.py (raw_input): restore the readline completer
545 * IPython/iplib.py (raw_input): restore the readline completer
542 state on every input, in case third-party code messed it up.
546 state on every input, in case third-party code messed it up.
543 (_prefilter): revert recent addition of early-escape checks which
547 (_prefilter): revert recent addition of early-escape checks which
544 prevent many valid alias calls from working.
548 prevent many valid alias calls from working.
545
549
546 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
550 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
547 flag for sigint handler so we don't run a full signal() call on
551 flag for sigint handler so we don't run a full signal() call on
548 each runcode access.
552 each runcode access.
549
553
550 * IPython/Magic.py (magic_whos): small improvement to diagnostic
554 * IPython/Magic.py (magic_whos): small improvement to diagnostic
551 message.
555 message.
552
556
553 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
557 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
554
558
555 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
559 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
556 asynchronous exceptions working, i.e., Ctrl-C can actually
560 asynchronous exceptions working, i.e., Ctrl-C can actually
557 interrupt long-running code in the multithreaded shells.
561 interrupt long-running code in the multithreaded shells.
558
562
559 This is using Tomer Filiba's great ctypes-based trick:
563 This is using Tomer Filiba's great ctypes-based trick:
560 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
564 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
561 this in the past, but hadn't been able to make it work before. So
565 this in the past, but hadn't been able to make it work before. So
562 far it looks like it's actually running, but this needs more
566 far it looks like it's actually running, but this needs more
563 testing. If it really works, I'll be *very* happy, and we'll owe
567 testing. If it really works, I'll be *very* happy, and we'll owe
564 a huge thank you to Tomer. My current implementation is ugly,
568 a huge thank you to Tomer. My current implementation is ugly,
565 hackish and uses nasty globals, but I don't want to try and clean
569 hackish and uses nasty globals, but I don't want to try and clean
566 anything up until we know if it actually works.
570 anything up until we know if it actually works.
567
571
568 NOTE: this feature needs ctypes to work. ctypes is included in
572 NOTE: this feature needs ctypes to work. ctypes is included in
569 Python2.5, but 2.4 users will need to manually install it. This
573 Python2.5, but 2.4 users will need to manually install it. This
570 feature makes multi-threaded shells so much more usable that it's
574 feature makes multi-threaded shells so much more usable that it's
571 a minor price to pay (ctypes is very easy to install, already a
575 a minor price to pay (ctypes is very easy to install, already a
572 requirement for win32 and available in major linux distros).
576 requirement for win32 and available in major linux distros).
573
577
574 2007-04-04 Ville Vainio <vivainio@gmail.com>
578 2007-04-04 Ville Vainio <vivainio@gmail.com>
575
579
576 * Extensions/ipy_completers.py, ipy_stock_completers.py:
580 * Extensions/ipy_completers.py, ipy_stock_completers.py:
577 Moved implementations of 'bundled' completers to ipy_completers.py,
581 Moved implementations of 'bundled' completers to ipy_completers.py,
578 they are only enabled in ipy_stock_completers.py.
582 they are only enabled in ipy_stock_completers.py.
579
583
580 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
584 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
581
585
582 * IPython/PyColorize.py (Parser.format2): Fix identation of
586 * IPython/PyColorize.py (Parser.format2): Fix identation of
583 colorzied output and return early if color scheme is NoColor, to
587 colorzied output and return early if color scheme is NoColor, to
584 avoid unnecessary and expensive tokenization. Closes #131.
588 avoid unnecessary and expensive tokenization. Closes #131.
585
589
586 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
590 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
587
591
588 * IPython/Debugger.py: disable the use of pydb version 1.17. It
592 * IPython/Debugger.py: disable the use of pydb version 1.17. It
589 has a critical bug (a missing import that makes post-mortem not
593 has a critical bug (a missing import that makes post-mortem not
590 work at all). Unfortunately as of this time, this is the version
594 work at all). Unfortunately as of this time, this is the version
591 shipped with Ubuntu Edgy, so quite a few people have this one. I
595 shipped with Ubuntu Edgy, so quite a few people have this one. I
592 hope Edgy will update to a more recent package.
596 hope Edgy will update to a more recent package.
593
597
594 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
598 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
595
599
596 * IPython/iplib.py (_prefilter): close #52, second part of a patch
600 * IPython/iplib.py (_prefilter): close #52, second part of a patch
597 set by Stefan (only the first part had been applied before).
601 set by Stefan (only the first part had been applied before).
598
602
599 * IPython/Extensions/ipy_stock_completers.py (module_completer):
603 * IPython/Extensions/ipy_stock_completers.py (module_completer):
600 remove usage of the dangerous pkgutil.walk_packages(). See
604 remove usage of the dangerous pkgutil.walk_packages(). See
601 details in comments left in the code.
605 details in comments left in the code.
602
606
603 * IPython/Magic.py (magic_whos): add support for numpy arrays
607 * IPython/Magic.py (magic_whos): add support for numpy arrays
604 similar to what we had for Numeric.
608 similar to what we had for Numeric.
605
609
606 * IPython/completer.py (IPCompleter.complete): extend the
610 * IPython/completer.py (IPCompleter.complete): extend the
607 complete() call API to support completions by other mechanisms
611 complete() call API to support completions by other mechanisms
608 than readline. Closes #109.
612 than readline. Closes #109.
609
613
610 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
614 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
611 protect against a bug in Python's execfile(). Closes #123.
615 protect against a bug in Python's execfile(). Closes #123.
612
616
613 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
617 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
614
618
615 * IPython/iplib.py (split_user_input): ensure that when splitting
619 * IPython/iplib.py (split_user_input): ensure that when splitting
616 user input, the part that can be treated as a python name is pure
620 user input, the part that can be treated as a python name is pure
617 ascii (Python identifiers MUST be pure ascii). Part of the
621 ascii (Python identifiers MUST be pure ascii). Part of the
618 ongoing Unicode support work.
622 ongoing Unicode support work.
619
623
620 * IPython/Prompts.py (prompt_specials_color): Add \N for the
624 * IPython/Prompts.py (prompt_specials_color): Add \N for the
621 actual prompt number, without any coloring. This allows users to
625 actual prompt number, without any coloring. This allows users to
622 produce numbered prompts with their own colors. Added after a
626 produce numbered prompts with their own colors. Added after a
623 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
627 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
624
628
625 2007-03-31 Walter Doerwald <walter@livinglogic.de>
629 2007-03-31 Walter Doerwald <walter@livinglogic.de>
626
630
627 * IPython/Extensions/igrid.py: Map the return key
631 * IPython/Extensions/igrid.py: Map the return key
628 to enter() and shift-return to enterattr().
632 to enter() and shift-return to enterattr().
629
633
630 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
634 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
631
635
632 * IPython/Magic.py (magic_psearch): add unicode support by
636 * IPython/Magic.py (magic_psearch): add unicode support by
633 encoding to ascii the input, since this routine also only deals
637 encoding to ascii the input, since this routine also only deals
634 with valid Python names. Fixes a bug reported by Stefan.
638 with valid Python names. Fixes a bug reported by Stefan.
635
639
636 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
640 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
637
641
638 * IPython/Magic.py (_inspect): convert unicode input into ascii
642 * IPython/Magic.py (_inspect): convert unicode input into ascii
639 before trying to evaluate it as a Python identifier. This fixes a
643 before trying to evaluate it as a Python identifier. This fixes a
640 problem that the new unicode support had introduced when analyzing
644 problem that the new unicode support had introduced when analyzing
641 long definition lines for functions.
645 long definition lines for functions.
642
646
643 2007-03-24 Walter Doerwald <walter@livinglogic.de>
647 2007-03-24 Walter Doerwald <walter@livinglogic.de>
644
648
645 * IPython/Extensions/igrid.py: Fix picking. Using
649 * IPython/Extensions/igrid.py: Fix picking. Using
646 igrid with wxPython 2.6 and -wthread should work now.
650 igrid with wxPython 2.6 and -wthread should work now.
647 igrid.display() simply tries to create a frame without
651 igrid.display() simply tries to create a frame without
648 an application. Only if this fails an application is created.
652 an application. Only if this fails an application is created.
649
653
650 2007-03-23 Walter Doerwald <walter@livinglogic.de>
654 2007-03-23 Walter Doerwald <walter@livinglogic.de>
651
655
652 * IPython/Extensions/path.py: Updated to version 2.2.
656 * IPython/Extensions/path.py: Updated to version 2.2.
653
657
654 2007-03-23 Ville Vainio <vivainio@gmail.com>
658 2007-03-23 Ville Vainio <vivainio@gmail.com>
655
659
656 * iplib.py: recursive alias expansion now works better, so that
660 * iplib.py: recursive alias expansion now works better, so that
657 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
661 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
658 doesn't trip up the process, if 'd' has been aliased to 'ls'.
662 doesn't trip up the process, if 'd' has been aliased to 'ls'.
659
663
660 * Extensions/ipy_gnuglobal.py added, provides %global magic
664 * Extensions/ipy_gnuglobal.py added, provides %global magic
661 for users of http://www.gnu.org/software/global
665 for users of http://www.gnu.org/software/global
662
666
663 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
667 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
664 Closes #52. Patch by Stefan van der Walt.
668 Closes #52. Patch by Stefan van der Walt.
665
669
666 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
670 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
667
671
668 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
672 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
669 respect the __file__ attribute when using %run. Thanks to a bug
673 respect the __file__ attribute when using %run. Thanks to a bug
670 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
674 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
671
675
672 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
676 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
673
677
674 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
678 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
675 input. Patch sent by Stefan.
679 input. Patch sent by Stefan.
676
680
677 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
681 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
678 * IPython/Extensions/ipy_stock_completer.py
682 * IPython/Extensions/ipy_stock_completer.py
679 shlex_split, fix bug in shlex_split. len function
683 shlex_split, fix bug in shlex_split. len function
680 call was missing an if statement. Caused shlex_split to
684 call was missing an if statement. Caused shlex_split to
681 sometimes return "" as last element.
685 sometimes return "" as last element.
682
686
683 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
687 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
684
688
685 * IPython/completer.py
689 * IPython/completer.py
686 (IPCompleter.file_matches.single_dir_expand): fix a problem
690 (IPCompleter.file_matches.single_dir_expand): fix a problem
687 reported by Stefan, where directories containign a single subdir
691 reported by Stefan, where directories containign a single subdir
688 would be completed too early.
692 would be completed too early.
689
693
690 * IPython/Shell.py (_load_pylab): Make the execution of 'from
694 * IPython/Shell.py (_load_pylab): Make the execution of 'from
691 pylab import *' when -pylab is given be optional. A new flag,
695 pylab import *' when -pylab is given be optional. A new flag,
692 pylab_import_all controls this behavior, the default is True for
696 pylab_import_all controls this behavior, the default is True for
693 backwards compatibility.
697 backwards compatibility.
694
698
695 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
699 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
696 modified) R. Bernstein's patch for fully syntax highlighted
700 modified) R. Bernstein's patch for fully syntax highlighted
697 tracebacks. The functionality is also available under ultraTB for
701 tracebacks. The functionality is also available under ultraTB for
698 non-ipython users (someone using ultraTB but outside an ipython
702 non-ipython users (someone using ultraTB but outside an ipython
699 session). They can select the color scheme by setting the
703 session). They can select the color scheme by setting the
700 module-level global DEFAULT_SCHEME. The highlight functionality
704 module-level global DEFAULT_SCHEME. The highlight functionality
701 also works when debugging.
705 also works when debugging.
702
706
703 * IPython/genutils.py (IOStream.close): small patch by
707 * IPython/genutils.py (IOStream.close): small patch by
704 R. Bernstein for improved pydb support.
708 R. Bernstein for improved pydb support.
705
709
706 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
710 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
707 DaveS <davls@telus.net> to improve support of debugging under
711 DaveS <davls@telus.net> to improve support of debugging under
708 NTEmacs, including improved pydb behavior.
712 NTEmacs, including improved pydb behavior.
709
713
710 * IPython/Magic.py (magic_prun): Fix saving of profile info for
714 * IPython/Magic.py (magic_prun): Fix saving of profile info for
711 Python 2.5, where the stats object API changed a little. Thanks
715 Python 2.5, where the stats object API changed a little. Thanks
712 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
716 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
713
717
714 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
718 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
715 Pernetty's patch to improve support for (X)Emacs under Win32.
719 Pernetty's patch to improve support for (X)Emacs under Win32.
716
720
717 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
721 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
718
722
719 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
723 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
720 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
724 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
721 a report by Nik Tautenhahn.
725 a report by Nik Tautenhahn.
722
726
723 2007-03-16 Walter Doerwald <walter@livinglogic.de>
727 2007-03-16 Walter Doerwald <walter@livinglogic.de>
724
728
725 * setup.py: Add the igrid help files to the list of data files
729 * setup.py: Add the igrid help files to the list of data files
726 to be installed alongside igrid.
730 to be installed alongside igrid.
727 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
731 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
728 Show the input object of the igrid browser as the window tile.
732 Show the input object of the igrid browser as the window tile.
729 Show the object the cursor is on in the statusbar.
733 Show the object the cursor is on in the statusbar.
730
734
731 2007-03-15 Ville Vainio <vivainio@gmail.com>
735 2007-03-15 Ville Vainio <vivainio@gmail.com>
732
736
733 * Extensions/ipy_stock_completers.py: Fixed exception
737 * Extensions/ipy_stock_completers.py: Fixed exception
734 on mismatching quotes in %run completer. Patch by
738 on mismatching quotes in %run completer. Patch by
735 JοΏ½rgen Stenarson. Closes #127.
739 JοΏ½rgen Stenarson. Closes #127.
736
740
737 2007-03-14 Ville Vainio <vivainio@gmail.com>
741 2007-03-14 Ville Vainio <vivainio@gmail.com>
738
742
739 * Extensions/ext_rehashdir.py: Do not do auto_alias
743 * Extensions/ext_rehashdir.py: Do not do auto_alias
740 in %rehashdir, it clobbers %store'd aliases.
744 in %rehashdir, it clobbers %store'd aliases.
741
745
742 * UserConfig/ipy_profile_sh.py: envpersist.py extension
746 * UserConfig/ipy_profile_sh.py: envpersist.py extension
743 (beefed up %env) imported for sh profile.
747 (beefed up %env) imported for sh profile.
744
748
745 2007-03-10 Walter Doerwald <walter@livinglogic.de>
749 2007-03-10 Walter Doerwald <walter@livinglogic.de>
746
750
747 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
751 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
748 as the default browser.
752 as the default browser.
749 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
753 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
750 As igrid displays all attributes it ever encounters, fetch() (which has
754 As igrid displays all attributes it ever encounters, fetch() (which has
751 been renamed to _fetch()) doesn't have to recalculate the display attributes
755 been renamed to _fetch()) doesn't have to recalculate the display attributes
752 every time a new item is fetched. This should speed up scrolling.
756 every time a new item is fetched. This should speed up scrolling.
753
757
754 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
758 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
755
759
756 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
760 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
757 Schmolck's recently reported tab-completion bug (my previous one
761 Schmolck's recently reported tab-completion bug (my previous one
758 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
762 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
759
763
760 2007-03-09 Walter Doerwald <walter@livinglogic.de>
764 2007-03-09 Walter Doerwald <walter@livinglogic.de>
761
765
762 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
766 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
763 Close help window if exiting igrid.
767 Close help window if exiting igrid.
764
768
765 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
769 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
766
770
767 * IPython/Extensions/ipy_defaults.py: Check if readline is available
771 * IPython/Extensions/ipy_defaults.py: Check if readline is available
768 before calling functions from readline.
772 before calling functions from readline.
769
773
770 2007-03-02 Walter Doerwald <walter@livinglogic.de>
774 2007-03-02 Walter Doerwald <walter@livinglogic.de>
771
775
772 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
776 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
773 igrid is a wxPython-based display object for ipipe. If your system has
777 igrid is a wxPython-based display object for ipipe. If your system has
774 wx installed igrid will be the default display. Without wx ipipe falls
778 wx installed igrid will be the default display. Without wx ipipe falls
775 back to ibrowse (which needs curses). If no curses is installed ipipe
779 back to ibrowse (which needs curses). If no curses is installed ipipe
776 falls back to idump.
780 falls back to idump.
777
781
778 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
782 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
779
783
780 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
784 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
781 my changes from yesterday, they introduced bugs. Will reactivate
785 my changes from yesterday, they introduced bugs. Will reactivate
782 once I get a correct solution, which will be much easier thanks to
786 once I get a correct solution, which will be much easier thanks to
783 Dan Milstein's new prefilter test suite.
787 Dan Milstein's new prefilter test suite.
784
788
785 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
789 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
786
790
787 * IPython/iplib.py (split_user_input): fix input splitting so we
791 * IPython/iplib.py (split_user_input): fix input splitting so we
788 don't attempt attribute accesses on things that can't possibly be
792 don't attempt attribute accesses on things that can't possibly be
789 valid Python attributes. After a bug report by Alex Schmolck.
793 valid Python attributes. After a bug report by Alex Schmolck.
790 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
794 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
791 %magic with explicit % prefix.
795 %magic with explicit % prefix.
792
796
793 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
797 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
794
798
795 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
799 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
796 avoid a DeprecationWarning from GTK.
800 avoid a DeprecationWarning from GTK.
797
801
798 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
802 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
799
803
800 * IPython/genutils.py (clock): I modified clock() to return total
804 * IPython/genutils.py (clock): I modified clock() to return total
801 time, user+system. This is a more commonly needed metric. I also
805 time, user+system. This is a more commonly needed metric. I also
802 introduced the new clocku/clocks to get only user/system time if
806 introduced the new clocku/clocks to get only user/system time if
803 one wants those instead.
807 one wants those instead.
804
808
805 ***WARNING: API CHANGE*** clock() used to return only user time,
809 ***WARNING: API CHANGE*** clock() used to return only user time,
806 so if you want exactly the same results as before, use clocku
810 so if you want exactly the same results as before, use clocku
807 instead.
811 instead.
808
812
809 2007-02-22 Ville Vainio <vivainio@gmail.com>
813 2007-02-22 Ville Vainio <vivainio@gmail.com>
810
814
811 * IPython/Extensions/ipy_p4.py: Extension for improved
815 * IPython/Extensions/ipy_p4.py: Extension for improved
812 p4 (perforce version control system) experience.
816 p4 (perforce version control system) experience.
813 Adds %p4 magic with p4 command completion and
817 Adds %p4 magic with p4 command completion and
814 automatic -G argument (marshall output as python dict)
818 automatic -G argument (marshall output as python dict)
815
819
816 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
820 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
817
821
818 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
822 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
819 stop marks.
823 stop marks.
820 (ClearingMixin): a simple mixin to easily make a Demo class clear
824 (ClearingMixin): a simple mixin to easily make a Demo class clear
821 the screen in between blocks and have empty marquees. The
825 the screen in between blocks and have empty marquees. The
822 ClearDemo and ClearIPDemo classes that use it are included.
826 ClearDemo and ClearIPDemo classes that use it are included.
823
827
824 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
828 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
825
829
826 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
830 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
827 protect against exceptions at Python shutdown time. Patch
831 protect against exceptions at Python shutdown time. Patch
828 sumbmitted to upstream.
832 sumbmitted to upstream.
829
833
830 2007-02-14 Walter Doerwald <walter@livinglogic.de>
834 2007-02-14 Walter Doerwald <walter@livinglogic.de>
831
835
832 * IPython/Extensions/ibrowse.py: If entering the first object level
836 * IPython/Extensions/ibrowse.py: If entering the first object level
833 (i.e. the object for which the browser has been started) fails,
837 (i.e. the object for which the browser has been started) fails,
834 now the error is raised directly (aborting the browser) instead of
838 now the error is raised directly (aborting the browser) instead of
835 running into an empty levels list later.
839 running into an empty levels list later.
836
840
837 2007-02-03 Walter Doerwald <walter@livinglogic.de>
841 2007-02-03 Walter Doerwald <walter@livinglogic.de>
838
842
839 * IPython/Extensions/ipipe.py: Add an xrepr implementation
843 * IPython/Extensions/ipipe.py: Add an xrepr implementation
840 for the noitem object.
844 for the noitem object.
841
845
842 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
846 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
843
847
844 * IPython/completer.py (Completer.attr_matches): Fix small
848 * IPython/completer.py (Completer.attr_matches): Fix small
845 tab-completion bug with Enthought Traits objects with units.
849 tab-completion bug with Enthought Traits objects with units.
846 Thanks to a bug report by Tom Denniston
850 Thanks to a bug report by Tom Denniston
847 <tom.denniston-AT-alum.dartmouth.org>.
851 <tom.denniston-AT-alum.dartmouth.org>.
848
852
849 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
853 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
850
854
851 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
855 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
852 bug where only .ipy or .py would be completed. Once the first
856 bug where only .ipy or .py would be completed. Once the first
853 argument to %run has been given, all completions are valid because
857 argument to %run has been given, all completions are valid because
854 they are the arguments to the script, which may well be non-python
858 they are the arguments to the script, which may well be non-python
855 filenames.
859 filenames.
856
860
857 * IPython/irunner.py (InteractiveRunner.run_source): major updates
861 * IPython/irunner.py (InteractiveRunner.run_source): major updates
858 to irunner to allow it to correctly support real doctesting of
862 to irunner to allow it to correctly support real doctesting of
859 out-of-process ipython code.
863 out-of-process ipython code.
860
864
861 * IPython/Magic.py (magic_cd): Make the setting of the terminal
865 * IPython/Magic.py (magic_cd): Make the setting of the terminal
862 title an option (-noterm_title) because it completely breaks
866 title an option (-noterm_title) because it completely breaks
863 doctesting.
867 doctesting.
864
868
865 * IPython/demo.py: fix IPythonDemo class that was not actually working.
869 * IPython/demo.py: fix IPythonDemo class that was not actually working.
866
870
867 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
871 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
868
872
869 * IPython/irunner.py (main): fix small bug where extensions were
873 * IPython/irunner.py (main): fix small bug where extensions were
870 not being correctly recognized.
874 not being correctly recognized.
871
875
872 2007-01-23 Walter Doerwald <walter@livinglogic.de>
876 2007-01-23 Walter Doerwald <walter@livinglogic.de>
873
877
874 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
878 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
875 a string containing a single line yields the string itself as the
879 a string containing a single line yields the string itself as the
876 only item.
880 only item.
877
881
878 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
882 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
879 object if it's the same as the one on the last level (This avoids
883 object if it's the same as the one on the last level (This avoids
880 infinite recursion for one line strings).
884 infinite recursion for one line strings).
881
885
882 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
886 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
883
887
884 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
888 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
885 all output streams before printing tracebacks. This ensures that
889 all output streams before printing tracebacks. This ensures that
886 user output doesn't end up interleaved with traceback output.
890 user output doesn't end up interleaved with traceback output.
887
891
888 2007-01-10 Ville Vainio <vivainio@gmail.com>
892 2007-01-10 Ville Vainio <vivainio@gmail.com>
889
893
890 * Extensions/envpersist.py: Turbocharged %env that remembers
894 * Extensions/envpersist.py: Turbocharged %env that remembers
891 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
895 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
892 "%env VISUAL=jed".
896 "%env VISUAL=jed".
893
897
894 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
898 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
895
899
896 * IPython/iplib.py (showtraceback): ensure that we correctly call
900 * IPython/iplib.py (showtraceback): ensure that we correctly call
897 custom handlers in all cases (some with pdb were slipping through,
901 custom handlers in all cases (some with pdb were slipping through,
898 but I'm not exactly sure why).
902 but I'm not exactly sure why).
899
903
900 * IPython/Debugger.py (Tracer.__init__): added new class to
904 * IPython/Debugger.py (Tracer.__init__): added new class to
901 support set_trace-like usage of IPython's enhanced debugger.
905 support set_trace-like usage of IPython's enhanced debugger.
902
906
903 2006-12-24 Ville Vainio <vivainio@gmail.com>
907 2006-12-24 Ville Vainio <vivainio@gmail.com>
904
908
905 * ipmaker.py: more informative message when ipy_user_conf
909 * ipmaker.py: more informative message when ipy_user_conf
906 import fails (suggest running %upgrade).
910 import fails (suggest running %upgrade).
907
911
908 * tools/run_ipy_in_profiler.py: Utility to see where
912 * tools/run_ipy_in_profiler.py: Utility to see where
909 the time during IPython startup is spent.
913 the time during IPython startup is spent.
910
914
911 2006-12-20 Ville Vainio <vivainio@gmail.com>
915 2006-12-20 Ville Vainio <vivainio@gmail.com>
912
916
913 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
917 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
914
918
915 * ipapi.py: Add new ipapi method, expand_alias.
919 * ipapi.py: Add new ipapi method, expand_alias.
916
920
917 * Release.py: Bump up version to 0.7.4.svn
921 * Release.py: Bump up version to 0.7.4.svn
918
922
919 2006-12-17 Ville Vainio <vivainio@gmail.com>
923 2006-12-17 Ville Vainio <vivainio@gmail.com>
920
924
921 * Extensions/jobctrl.py: Fixed &cmd arg arg...
925 * Extensions/jobctrl.py: Fixed &cmd arg arg...
922 to work properly on posix too
926 to work properly on posix too
923
927
924 * Release.py: Update revnum (version is still just 0.7.3).
928 * Release.py: Update revnum (version is still just 0.7.3).
925
929
926 2006-12-15 Ville Vainio <vivainio@gmail.com>
930 2006-12-15 Ville Vainio <vivainio@gmail.com>
927
931
928 * scripts/ipython_win_post_install: create ipython.py in
932 * scripts/ipython_win_post_install: create ipython.py in
929 prefix + "/scripts".
933 prefix + "/scripts".
930
934
931 * Release.py: Update version to 0.7.3.
935 * Release.py: Update version to 0.7.3.
932
936
933 2006-12-14 Ville Vainio <vivainio@gmail.com>
937 2006-12-14 Ville Vainio <vivainio@gmail.com>
934
938
935 * scripts/ipython_win_post_install: Overwrite old shortcuts
939 * scripts/ipython_win_post_install: Overwrite old shortcuts
936 if they already exist
940 if they already exist
937
941
938 * Release.py: release 0.7.3rc2
942 * Release.py: release 0.7.3rc2
939
943
940 2006-12-13 Ville Vainio <vivainio@gmail.com>
944 2006-12-13 Ville Vainio <vivainio@gmail.com>
941
945
942 * Branch and update Release.py for 0.7.3rc1
946 * Branch and update Release.py for 0.7.3rc1
943
947
944 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
948 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
945
949
946 * IPython/Shell.py (IPShellWX): update for current WX naming
950 * IPython/Shell.py (IPShellWX): update for current WX naming
947 conventions, to avoid a deprecation warning with current WX
951 conventions, to avoid a deprecation warning with current WX
948 versions. Thanks to a report by Danny Shevitz.
952 versions. Thanks to a report by Danny Shevitz.
949
953
950 2006-12-12 Ville Vainio <vivainio@gmail.com>
954 2006-12-12 Ville Vainio <vivainio@gmail.com>
951
955
952 * ipmaker.py: apply david cournapeau's patch to make
956 * ipmaker.py: apply david cournapeau's patch to make
953 import_some work properly even when ipythonrc does
957 import_some work properly even when ipythonrc does
954 import_some on empty list (it was an old bug!).
958 import_some on empty list (it was an old bug!).
955
959
956 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
960 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
957 Add deprecation note to ipythonrc and a url to wiki
961 Add deprecation note to ipythonrc and a url to wiki
958 in ipy_user_conf.py
962 in ipy_user_conf.py
959
963
960
964
961 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
965 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
962 as if it was typed on IPython command prompt, i.e.
966 as if it was typed on IPython command prompt, i.e.
963 as IPython script.
967 as IPython script.
964
968
965 * example-magic.py, magic_grepl.py: remove outdated examples
969 * example-magic.py, magic_grepl.py: remove outdated examples
966
970
967 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
971 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
968
972
969 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
973 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
970 is called before any exception has occurred.
974 is called before any exception has occurred.
971
975
972 2006-12-08 Ville Vainio <vivainio@gmail.com>
976 2006-12-08 Ville Vainio <vivainio@gmail.com>
973
977
974 * Extensions/ipy_stock_completers.py: fix cd completer
978 * Extensions/ipy_stock_completers.py: fix cd completer
975 to translate /'s to \'s again.
979 to translate /'s to \'s again.
976
980
977 * completer.py: prevent traceback on file completions w/
981 * completer.py: prevent traceback on file completions w/
978 backslash.
982 backslash.
979
983
980 * Release.py: Update release number to 0.7.3b3 for release
984 * Release.py: Update release number to 0.7.3b3 for release
981
985
982 2006-12-07 Ville Vainio <vivainio@gmail.com>
986 2006-12-07 Ville Vainio <vivainio@gmail.com>
983
987
984 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
988 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
985 while executing external code. Provides more shell-like behaviour
989 while executing external code. Provides more shell-like behaviour
986 and overall better response to ctrl + C / ctrl + break.
990 and overall better response to ctrl + C / ctrl + break.
987
991
988 * tools/make_tarball.py: new script to create tarball straight from svn
992 * tools/make_tarball.py: new script to create tarball straight from svn
989 (setup.py sdist doesn't work on win32).
993 (setup.py sdist doesn't work on win32).
990
994
991 * Extensions/ipy_stock_completers.py: fix cd completer to give up
995 * Extensions/ipy_stock_completers.py: fix cd completer to give up
992 on dirnames with spaces and use the default completer instead.
996 on dirnames with spaces and use the default completer instead.
993
997
994 * Revision.py: Change version to 0.7.3b2 for release.
998 * Revision.py: Change version to 0.7.3b2 for release.
995
999
996 2006-12-05 Ville Vainio <vivainio@gmail.com>
1000 2006-12-05 Ville Vainio <vivainio@gmail.com>
997
1001
998 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
1002 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
999 pydb patch 4 (rm debug printing, py 2.5 checking)
1003 pydb patch 4 (rm debug printing, py 2.5 checking)
1000
1004
1001 2006-11-30 Walter Doerwald <walter@livinglogic.de>
1005 2006-11-30 Walter Doerwald <walter@livinglogic.de>
1002 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
1006 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
1003 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
1007 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
1004 "refreshfind" (mapped to "R") does the same but tries to go back to the same
1008 "refreshfind" (mapped to "R") does the same but tries to go back to the same
1005 object the cursor was on before the refresh. The command "markrange" is
1009 object the cursor was on before the refresh. The command "markrange" is
1006 mapped to "%" now.
1010 mapped to "%" now.
1007 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
1011 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
1008
1012
1009 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
1013 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
1010
1014
1011 * IPython/Magic.py (magic_debug): new %debug magic to activate the
1015 * IPython/Magic.py (magic_debug): new %debug magic to activate the
1012 interactive debugger on the last traceback, without having to call
1016 interactive debugger on the last traceback, without having to call
1013 %pdb and rerun your code. Made minor changes in various modules,
1017 %pdb and rerun your code. Made minor changes in various modules,
1014 should automatically recognize pydb if available.
1018 should automatically recognize pydb if available.
1015
1019
1016 2006-11-28 Ville Vainio <vivainio@gmail.com>
1020 2006-11-28 Ville Vainio <vivainio@gmail.com>
1017
1021
1018 * completer.py: If the text start with !, show file completions
1022 * completer.py: If the text start with !, show file completions
1019 properly. This helps when trying to complete command name
1023 properly. This helps when trying to complete command name
1020 for shell escapes.
1024 for shell escapes.
1021
1025
1022 2006-11-27 Ville Vainio <vivainio@gmail.com>
1026 2006-11-27 Ville Vainio <vivainio@gmail.com>
1023
1027
1024 * ipy_stock_completers.py: bzr completer submitted by Stefan van
1028 * ipy_stock_completers.py: bzr completer submitted by Stefan van
1025 der Walt. Clean up svn and hg completers by using a common
1029 der Walt. Clean up svn and hg completers by using a common
1026 vcs_completer.
1030 vcs_completer.
1027
1031
1028 2006-11-26 Ville Vainio <vivainio@gmail.com>
1032 2006-11-26 Ville Vainio <vivainio@gmail.com>
1029
1033
1030 * Remove ipconfig and %config; you should use _ip.options structure
1034 * Remove ipconfig and %config; you should use _ip.options structure
1031 directly instead!
1035 directly instead!
1032
1036
1033 * genutils.py: add wrap_deprecated function for deprecating callables
1037 * genutils.py: add wrap_deprecated function for deprecating callables
1034
1038
1035 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
1039 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
1036 _ip.system instead. ipalias is redundant.
1040 _ip.system instead. ipalias is redundant.
1037
1041
1038 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
1042 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
1039 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
1043 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
1040 explicit.
1044 explicit.
1041
1045
1042 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
1046 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
1043 completer. Try it by entering 'hg ' and pressing tab.
1047 completer. Try it by entering 'hg ' and pressing tab.
1044
1048
1045 * macro.py: Give Macro a useful __repr__ method
1049 * macro.py: Give Macro a useful __repr__ method
1046
1050
1047 * Magic.py: %whos abbreviates the typename of Macro for brevity.
1051 * Magic.py: %whos abbreviates the typename of Macro for brevity.
1048
1052
1049 2006-11-24 Walter Doerwald <walter@livinglogic.de>
1053 2006-11-24 Walter Doerwald <walter@livinglogic.de>
1050 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
1054 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
1051 we don't get a duplicate ipipe module, where registration of the xrepr
1055 we don't get a duplicate ipipe module, where registration of the xrepr
1052 implementation for Text is useless.
1056 implementation for Text is useless.
1053
1057
1054 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
1058 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
1055
1059
1056 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
1060 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
1057
1061
1058 2006-11-24 Ville Vainio <vivainio@gmail.com>
1062 2006-11-24 Ville Vainio <vivainio@gmail.com>
1059
1063
1060 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
1064 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
1061 try to use "cProfile" instead of the slower pure python
1065 try to use "cProfile" instead of the slower pure python
1062 "profile"
1066 "profile"
1063
1067
1064 2006-11-23 Ville Vainio <vivainio@gmail.com>
1068 2006-11-23 Ville Vainio <vivainio@gmail.com>
1065
1069
1066 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
1070 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
1067 Qt+IPython+Designer link in documentation.
1071 Qt+IPython+Designer link in documentation.
1068
1072
1069 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
1073 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
1070 correct Pdb object to %pydb.
1074 correct Pdb object to %pydb.
1071
1075
1072
1076
1073 2006-11-22 Walter Doerwald <walter@livinglogic.de>
1077 2006-11-22 Walter Doerwald <walter@livinglogic.de>
1074 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
1078 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
1075 generic xrepr(), otherwise the list implementation would kick in.
1079 generic xrepr(), otherwise the list implementation would kick in.
1076
1080
1077 2006-11-21 Ville Vainio <vivainio@gmail.com>
1081 2006-11-21 Ville Vainio <vivainio@gmail.com>
1078
1082
1079 * upgrade_dir.py: Now actually overwrites a nonmodified user file
1083 * upgrade_dir.py: Now actually overwrites a nonmodified user file
1080 with one from UserConfig.
1084 with one from UserConfig.
1081
1085
1082 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
1086 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
1083 it was missing which broke the sh profile.
1087 it was missing which broke the sh profile.
1084
1088
1085 * completer.py: file completer now uses explicit '/' instead
1089 * completer.py: file completer now uses explicit '/' instead
1086 of os.path.join, expansion of 'foo' was broken on win32
1090 of os.path.join, expansion of 'foo' was broken on win32
1087 if there was one directory with name 'foobar'.
1091 if there was one directory with name 'foobar'.
1088
1092
1089 * A bunch of patches from Kirill Smelkov:
1093 * A bunch of patches from Kirill Smelkov:
1090
1094
1091 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
1095 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
1092
1096
1093 * [patch 7/9] Implement %page -r (page in raw mode) -
1097 * [patch 7/9] Implement %page -r (page in raw mode) -
1094
1098
1095 * [patch 5/9] ScientificPython webpage has moved
1099 * [patch 5/9] ScientificPython webpage has moved
1096
1100
1097 * [patch 4/9] The manual mentions %ds, should be %dhist
1101 * [patch 4/9] The manual mentions %ds, should be %dhist
1098
1102
1099 * [patch 3/9] Kill old bits from %prun doc.
1103 * [patch 3/9] Kill old bits from %prun doc.
1100
1104
1101 * [patch 1/9] Fix typos here and there.
1105 * [patch 1/9] Fix typos here and there.
1102
1106
1103 2006-11-08 Ville Vainio <vivainio@gmail.com>
1107 2006-11-08 Ville Vainio <vivainio@gmail.com>
1104
1108
1105 * completer.py (attr_matches): catch all exceptions raised
1109 * completer.py (attr_matches): catch all exceptions raised
1106 by eval of expr with dots.
1110 by eval of expr with dots.
1107
1111
1108 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
1112 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
1109
1113
1110 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
1114 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
1111 input if it starts with whitespace. This allows you to paste
1115 input if it starts with whitespace. This allows you to paste
1112 indented input from any editor without manually having to type in
1116 indented input from any editor without manually having to type in
1113 the 'if 1:', which is convenient when working interactively.
1117 the 'if 1:', which is convenient when working interactively.
1114 Slightly modifed version of a patch by Bo Peng
1118 Slightly modifed version of a patch by Bo Peng
1115 <bpeng-AT-rice.edu>.
1119 <bpeng-AT-rice.edu>.
1116
1120
1117 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1121 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1118
1122
1119 * IPython/irunner.py (main): modified irunner so it automatically
1123 * IPython/irunner.py (main): modified irunner so it automatically
1120 recognizes the right runner to use based on the extension (.py for
1124 recognizes the right runner to use based on the extension (.py for
1121 python, .ipy for ipython and .sage for sage).
1125 python, .ipy for ipython and .sage for sage).
1122
1126
1123 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
1127 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
1124 visible in ipapi as ip.config(), to programatically control the
1128 visible in ipapi as ip.config(), to programatically control the
1125 internal rc object. There's an accompanying %config magic for
1129 internal rc object. There's an accompanying %config magic for
1126 interactive use, which has been enhanced to match the
1130 interactive use, which has been enhanced to match the
1127 funtionality in ipconfig.
1131 funtionality in ipconfig.
1128
1132
1129 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
1133 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
1130 so it's not just a toggle, it now takes an argument. Add support
1134 so it's not just a toggle, it now takes an argument. Add support
1131 for a customizable header when making system calls, as the new
1135 for a customizable header when making system calls, as the new
1132 system_header variable in the ipythonrc file.
1136 system_header variable in the ipythonrc file.
1133
1137
1134 2006-11-03 Walter Doerwald <walter@livinglogic.de>
1138 2006-11-03 Walter Doerwald <walter@livinglogic.de>
1135
1139
1136 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
1140 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
1137 generic functions (using Philip J. Eby's simplegeneric package).
1141 generic functions (using Philip J. Eby's simplegeneric package).
1138 This makes it possible to customize the display of third-party classes
1142 This makes it possible to customize the display of third-party classes
1139 without having to monkeypatch them. xiter() no longer supports a mode
1143 without having to monkeypatch them. xiter() no longer supports a mode
1140 argument and the XMode class has been removed. The same functionality can
1144 argument and the XMode class has been removed. The same functionality can
1141 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
1145 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
1142 One consequence of the switch to generic functions is that xrepr() and
1146 One consequence of the switch to generic functions is that xrepr() and
1143 xattrs() implementation must define the default value for the mode
1147 xattrs() implementation must define the default value for the mode
1144 argument themselves and xattrs() implementations must return real
1148 argument themselves and xattrs() implementations must return real
1145 descriptors.
1149 descriptors.
1146
1150
1147 * IPython/external: This new subpackage will contain all third-party
1151 * IPython/external: This new subpackage will contain all third-party
1148 packages that are bundled with IPython. (The first one is simplegeneric).
1152 packages that are bundled with IPython. (The first one is simplegeneric).
1149
1153
1150 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
1154 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
1151 directory which as been dropped in r1703.
1155 directory which as been dropped in r1703.
1152
1156
1153 * IPython/Extensions/ipipe.py (iless): Fixed.
1157 * IPython/Extensions/ipipe.py (iless): Fixed.
1154
1158
1155 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
1159 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
1156
1160
1157 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1161 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1158
1162
1159 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
1163 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
1160 handling in variable expansion so that shells and magics recognize
1164 handling in variable expansion so that shells and magics recognize
1161 function local scopes correctly. Bug reported by Brian.
1165 function local scopes correctly. Bug reported by Brian.
1162
1166
1163 * scripts/ipython: remove the very first entry in sys.path which
1167 * scripts/ipython: remove the very first entry in sys.path which
1164 Python auto-inserts for scripts, so that sys.path under IPython is
1168 Python auto-inserts for scripts, so that sys.path under IPython is
1165 as similar as possible to that under plain Python.
1169 as similar as possible to that under plain Python.
1166
1170
1167 * IPython/completer.py (IPCompleter.file_matches): Fix
1171 * IPython/completer.py (IPCompleter.file_matches): Fix
1168 tab-completion so that quotes are not closed unless the completion
1172 tab-completion so that quotes are not closed unless the completion
1169 is unambiguous. After a request by Stefan. Minor cleanups in
1173 is unambiguous. After a request by Stefan. Minor cleanups in
1170 ipy_stock_completers.
1174 ipy_stock_completers.
1171
1175
1172 2006-11-02 Ville Vainio <vivainio@gmail.com>
1176 2006-11-02 Ville Vainio <vivainio@gmail.com>
1173
1177
1174 * ipy_stock_completers.py: Add %run and %cd completers.
1178 * ipy_stock_completers.py: Add %run and %cd completers.
1175
1179
1176 * completer.py: Try running custom completer for both
1180 * completer.py: Try running custom completer for both
1177 "foo" and "%foo" if the command is just "foo". Ignore case
1181 "foo" and "%foo" if the command is just "foo". Ignore case
1178 when filtering possible completions.
1182 when filtering possible completions.
1179
1183
1180 * UserConfig/ipy_user_conf.py: install stock completers as default
1184 * UserConfig/ipy_user_conf.py: install stock completers as default
1181
1185
1182 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
1186 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
1183 simplified readline history save / restore through a wrapper
1187 simplified readline history save / restore through a wrapper
1184 function
1188 function
1185
1189
1186
1190
1187 2006-10-31 Ville Vainio <vivainio@gmail.com>
1191 2006-10-31 Ville Vainio <vivainio@gmail.com>
1188
1192
1189 * strdispatch.py, completer.py, ipy_stock_completers.py:
1193 * strdispatch.py, completer.py, ipy_stock_completers.py:
1190 Allow str_key ("command") in completer hooks. Implement
1194 Allow str_key ("command") in completer hooks. Implement
1191 trivial completer for 'import' (stdlib modules only). Rename
1195 trivial completer for 'import' (stdlib modules only). Rename
1192 ipy_linux_package_managers.py to ipy_stock_completers.py.
1196 ipy_linux_package_managers.py to ipy_stock_completers.py.
1193 SVN completer.
1197 SVN completer.
1194
1198
1195 * Extensions/ledit.py: %magic line editor for easily and
1199 * Extensions/ledit.py: %magic line editor for easily and
1196 incrementally manipulating lists of strings. The magic command
1200 incrementally manipulating lists of strings. The magic command
1197 name is %led.
1201 name is %led.
1198
1202
1199 2006-10-30 Ville Vainio <vivainio@gmail.com>
1203 2006-10-30 Ville Vainio <vivainio@gmail.com>
1200
1204
1201 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
1205 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
1202 Bernsteins's patches for pydb integration.
1206 Bernsteins's patches for pydb integration.
1203 http://bashdb.sourceforge.net/pydb/
1207 http://bashdb.sourceforge.net/pydb/
1204
1208
1205 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
1209 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
1206 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
1210 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
1207 custom completer hook to allow the users to implement their own
1211 custom completer hook to allow the users to implement their own
1208 completers. See ipy_linux_package_managers.py for example. The
1212 completers. See ipy_linux_package_managers.py for example. The
1209 hook name is 'complete_command'.
1213 hook name is 'complete_command'.
1210
1214
1211 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
1215 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
1212
1216
1213 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
1217 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
1214 Numeric leftovers.
1218 Numeric leftovers.
1215
1219
1216 * ipython.el (py-execute-region): apply Stefan's patch to fix
1220 * ipython.el (py-execute-region): apply Stefan's patch to fix
1217 garbled results if the python shell hasn't been previously started.
1221 garbled results if the python shell hasn't been previously started.
1218
1222
1219 * IPython/genutils.py (arg_split): moved to genutils, since it's a
1223 * IPython/genutils.py (arg_split): moved to genutils, since it's a
1220 pretty generic function and useful for other things.
1224 pretty generic function and useful for other things.
1221
1225
1222 * IPython/OInspect.py (getsource): Add customizable source
1226 * IPython/OInspect.py (getsource): Add customizable source
1223 extractor. After a request/patch form W. Stein (SAGE).
1227 extractor. After a request/patch form W. Stein (SAGE).
1224
1228
1225 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
1229 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
1226 window size to a more reasonable value from what pexpect does,
1230 window size to a more reasonable value from what pexpect does,
1227 since their choice causes wrapping bugs with long input lines.
1231 since their choice causes wrapping bugs with long input lines.
1228
1232
1229 2006-10-28 Ville Vainio <vivainio@gmail.com>
1233 2006-10-28 Ville Vainio <vivainio@gmail.com>
1230
1234
1231 * Magic.py (%run): Save and restore the readline history from
1235 * Magic.py (%run): Save and restore the readline history from
1232 file around %run commands to prevent side effects from
1236 file around %run commands to prevent side effects from
1233 %runned programs that might use readline (e.g. pydb).
1237 %runned programs that might use readline (e.g. pydb).
1234
1238
1235 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
1239 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
1236 invoking the pydb enhanced debugger.
1240 invoking the pydb enhanced debugger.
1237
1241
1238 2006-10-23 Walter Doerwald <walter@livinglogic.de>
1242 2006-10-23 Walter Doerwald <walter@livinglogic.de>
1239
1243
1240 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
1244 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
1241 call the base class method and propagate the return value to
1245 call the base class method and propagate the return value to
1242 ifile. This is now done by path itself.
1246 ifile. This is now done by path itself.
1243
1247
1244 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1248 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1245
1249
1246 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
1250 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
1247 api: set_crash_handler(), to expose the ability to change the
1251 api: set_crash_handler(), to expose the ability to change the
1248 internal crash handler.
1252 internal crash handler.
1249
1253
1250 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
1254 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
1251 the various parameters of the crash handler so that apps using
1255 the various parameters of the crash handler so that apps using
1252 IPython as their engine can customize crash handling. Ipmlemented
1256 IPython as their engine can customize crash handling. Ipmlemented
1253 at the request of SAGE.
1257 at the request of SAGE.
1254
1258
1255 2006-10-14 Ville Vainio <vivainio@gmail.com>
1259 2006-10-14 Ville Vainio <vivainio@gmail.com>
1256
1260
1257 * Magic.py, ipython.el: applied first "safe" part of Rocky
1261 * Magic.py, ipython.el: applied first "safe" part of Rocky
1258 Bernstein's patch set for pydb integration.
1262 Bernstein's patch set for pydb integration.
1259
1263
1260 * Magic.py (%unalias, %alias): %store'd aliases can now be
1264 * Magic.py (%unalias, %alias): %store'd aliases can now be
1261 removed with '%unalias'. %alias w/o args now shows most
1265 removed with '%unalias'. %alias w/o args now shows most
1262 interesting (stored / manually defined) aliases last
1266 interesting (stored / manually defined) aliases last
1263 where they catch the eye w/o scrolling.
1267 where they catch the eye w/o scrolling.
1264
1268
1265 * Magic.py (%rehashx), ext_rehashdir.py: files with
1269 * Magic.py (%rehashx), ext_rehashdir.py: files with
1266 'py' extension are always considered executable, even
1270 'py' extension are always considered executable, even
1267 when not in PATHEXT environment variable.
1271 when not in PATHEXT environment variable.
1268
1272
1269 2006-10-12 Ville Vainio <vivainio@gmail.com>
1273 2006-10-12 Ville Vainio <vivainio@gmail.com>
1270
1274
1271 * jobctrl.py: Add new "jobctrl" extension for spawning background
1275 * jobctrl.py: Add new "jobctrl" extension for spawning background
1272 processes with "&find /". 'import jobctrl' to try it out. Requires
1276 processes with "&find /". 'import jobctrl' to try it out. Requires
1273 'subprocess' module, standard in python 2.4+.
1277 'subprocess' module, standard in python 2.4+.
1274
1278
1275 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
1279 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
1276 so if foo -> bar and bar -> baz, then foo -> baz.
1280 so if foo -> bar and bar -> baz, then foo -> baz.
1277
1281
1278 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
1282 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
1279
1283
1280 * IPython/Magic.py (Magic.parse_options): add a new posix option
1284 * IPython/Magic.py (Magic.parse_options): add a new posix option
1281 to allow parsing of input args in magics that doesn't strip quotes
1285 to allow parsing of input args in magics that doesn't strip quotes
1282 (if posix=False). This also closes %timeit bug reported by
1286 (if posix=False). This also closes %timeit bug reported by
1283 Stefan.
1287 Stefan.
1284
1288
1285 2006-10-03 Ville Vainio <vivainio@gmail.com>
1289 2006-10-03 Ville Vainio <vivainio@gmail.com>
1286
1290
1287 * iplib.py (raw_input, interact): Return ValueError catching for
1291 * iplib.py (raw_input, interact): Return ValueError catching for
1288 raw_input. Fixes infinite loop for sys.stdin.close() or
1292 raw_input. Fixes infinite loop for sys.stdin.close() or
1289 sys.stdout.close().
1293 sys.stdout.close().
1290
1294
1291 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1295 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1292
1296
1293 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
1297 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
1294 to help in handling doctests. irunner is now pretty useful for
1298 to help in handling doctests. irunner is now pretty useful for
1295 running standalone scripts and simulate a full interactive session
1299 running standalone scripts and simulate a full interactive session
1296 in a format that can be then pasted as a doctest.
1300 in a format that can be then pasted as a doctest.
1297
1301
1298 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
1302 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
1299 on top of the default (useless) ones. This also fixes the nasty
1303 on top of the default (useless) ones. This also fixes the nasty
1300 way in which 2.5's Quitter() exits (reverted [1785]).
1304 way in which 2.5's Quitter() exits (reverted [1785]).
1301
1305
1302 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
1306 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
1303 2.5.
1307 2.5.
1304
1308
1305 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
1309 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
1306 color scheme is updated as well when color scheme is changed
1310 color scheme is updated as well when color scheme is changed
1307 interactively.
1311 interactively.
1308
1312
1309 2006-09-27 Ville Vainio <vivainio@gmail.com>
1313 2006-09-27 Ville Vainio <vivainio@gmail.com>
1310
1314
1311 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
1315 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
1312 infinite loop and just exit. It's a hack, but will do for a while.
1316 infinite loop and just exit. It's a hack, but will do for a while.
1313
1317
1314 2006-08-25 Walter Doerwald <walter@livinglogic.de>
1318 2006-08-25 Walter Doerwald <walter@livinglogic.de>
1315
1319
1316 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
1320 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
1317 the constructor, this makes it possible to get a list of only directories
1321 the constructor, this makes it possible to get a list of only directories
1318 or only files.
1322 or only files.
1319
1323
1320 2006-08-12 Ville Vainio <vivainio@gmail.com>
1324 2006-08-12 Ville Vainio <vivainio@gmail.com>
1321
1325
1322 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
1326 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
1323 they broke unittest
1327 they broke unittest
1324
1328
1325 2006-08-11 Ville Vainio <vivainio@gmail.com>
1329 2006-08-11 Ville Vainio <vivainio@gmail.com>
1326
1330
1327 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
1331 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
1328 by resolving issue properly, i.e. by inheriting FakeModule
1332 by resolving issue properly, i.e. by inheriting FakeModule
1329 from types.ModuleType. Pickling ipython interactive data
1333 from types.ModuleType. Pickling ipython interactive data
1330 should still work as usual (testing appreciated).
1334 should still work as usual (testing appreciated).
1331
1335
1332 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
1336 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
1333
1337
1334 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
1338 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
1335 running under python 2.3 with code from 2.4 to fix a bug with
1339 running under python 2.3 with code from 2.4 to fix a bug with
1336 help(). Reported by the Debian maintainers, Norbert Tretkowski
1340 help(). Reported by the Debian maintainers, Norbert Tretkowski
1337 <norbert-AT-tretkowski.de> and Alexandre Fayolle
1341 <norbert-AT-tretkowski.de> and Alexandre Fayolle
1338 <afayolle-AT-debian.org>.
1342 <afayolle-AT-debian.org>.
1339
1343
1340 2006-08-04 Walter Doerwald <walter@livinglogic.de>
1344 2006-08-04 Walter Doerwald <walter@livinglogic.de>
1341
1345
1342 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
1346 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
1343 (which was displaying "quit" twice).
1347 (which was displaying "quit" twice).
1344
1348
1345 2006-07-28 Walter Doerwald <walter@livinglogic.de>
1349 2006-07-28 Walter Doerwald <walter@livinglogic.de>
1346
1350
1347 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
1351 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
1348 the mode argument).
1352 the mode argument).
1349
1353
1350 2006-07-27 Walter Doerwald <walter@livinglogic.de>
1354 2006-07-27 Walter Doerwald <walter@livinglogic.de>
1351
1355
1352 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
1356 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
1353 not running under IPython.
1357 not running under IPython.
1354
1358
1355 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
1359 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
1356 and make it iterable (iterating over the attribute itself). Add two new
1360 and make it iterable (iterating over the attribute itself). Add two new
1357 magic strings for __xattrs__(): If the string starts with "-", the attribute
1361 magic strings for __xattrs__(): If the string starts with "-", the attribute
1358 will not be displayed in ibrowse's detail view (but it can still be
1362 will not be displayed in ibrowse's detail view (but it can still be
1359 iterated over). This makes it possible to add attributes that are large
1363 iterated over). This makes it possible to add attributes that are large
1360 lists or generator methods to the detail view. Replace magic attribute names
1364 lists or generator methods to the detail view. Replace magic attribute names
1361 and _attrname() and _getattr() with "descriptors": For each type of magic
1365 and _attrname() and _getattr() with "descriptors": For each type of magic
1362 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
1366 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
1363 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
1367 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
1364 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
1368 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
1365 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
1369 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
1366 are still supported.
1370 are still supported.
1367
1371
1368 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
1372 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
1369 fails in ibrowse.fetch(), the exception object is added as the last item
1373 fails in ibrowse.fetch(), the exception object is added as the last item
1370 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
1374 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
1371 a generator throws an exception midway through execution.
1375 a generator throws an exception midway through execution.
1372
1376
1373 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
1377 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
1374 encoding into methods.
1378 encoding into methods.
1375
1379
1376 2006-07-26 Ville Vainio <vivainio@gmail.com>
1380 2006-07-26 Ville Vainio <vivainio@gmail.com>
1377
1381
1378 * iplib.py: history now stores multiline input as single
1382 * iplib.py: history now stores multiline input as single
1379 history entries. Patch by Jorgen Cederlof.
1383 history entries. Patch by Jorgen Cederlof.
1380
1384
1381 2006-07-18 Walter Doerwald <walter@livinglogic.de>
1385 2006-07-18 Walter Doerwald <walter@livinglogic.de>
1382
1386
1383 * IPython/Extensions/ibrowse.py: Make cursor visible over
1387 * IPython/Extensions/ibrowse.py: Make cursor visible over
1384 non existing attributes.
1388 non existing attributes.
1385
1389
1386 2006-07-14 Walter Doerwald <walter@livinglogic.de>
1390 2006-07-14 Walter Doerwald <walter@livinglogic.de>
1387
1391
1388 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
1392 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
1389 error output of the running command doesn't mess up the screen.
1393 error output of the running command doesn't mess up the screen.
1390
1394
1391 2006-07-13 Walter Doerwald <walter@livinglogic.de>
1395 2006-07-13 Walter Doerwald <walter@livinglogic.de>
1392
1396
1393 * IPython/Extensions/ipipe.py (isort): Make isort usable without
1397 * IPython/Extensions/ipipe.py (isort): Make isort usable without
1394 argument. This sorts the items themselves.
1398 argument. This sorts the items themselves.
1395
1399
1396 2006-07-12 Walter Doerwald <walter@livinglogic.de>
1400 2006-07-12 Walter Doerwald <walter@livinglogic.de>
1397
1401
1398 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
1402 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
1399 Compile expression strings into code objects. This should speed
1403 Compile expression strings into code objects. This should speed
1400 up ifilter and friends somewhat.
1404 up ifilter and friends somewhat.
1401
1405
1402 2006-07-08 Ville Vainio <vivainio@gmail.com>
1406 2006-07-08 Ville Vainio <vivainio@gmail.com>
1403
1407
1404 * Magic.py: %cpaste now strips > from the beginning of lines
1408 * Magic.py: %cpaste now strips > from the beginning of lines
1405 to ease pasting quoted code from emails. Contributed by
1409 to ease pasting quoted code from emails. Contributed by
1406 Stefan van der Walt.
1410 Stefan van der Walt.
1407
1411
1408 2006-06-29 Ville Vainio <vivainio@gmail.com>
1412 2006-06-29 Ville Vainio <vivainio@gmail.com>
1409
1413
1410 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
1414 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
1411 mode, patch contributed by Darren Dale. NEEDS TESTING!
1415 mode, patch contributed by Darren Dale. NEEDS TESTING!
1412
1416
1413 2006-06-28 Walter Doerwald <walter@livinglogic.de>
1417 2006-06-28 Walter Doerwald <walter@livinglogic.de>
1414
1418
1415 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
1419 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
1416 a blue background. Fix fetching new display rows when the browser
1420 a blue background. Fix fetching new display rows when the browser
1417 scrolls more than a screenful (e.g. by using the goto command).
1421 scrolls more than a screenful (e.g. by using the goto command).
1418
1422
1419 2006-06-27 Ville Vainio <vivainio@gmail.com>
1423 2006-06-27 Ville Vainio <vivainio@gmail.com>
1420
1424
1421 * Magic.py (_inspect, _ofind) Apply David Huard's
1425 * Magic.py (_inspect, _ofind) Apply David Huard's
1422 patch for displaying the correct docstring for 'property'
1426 patch for displaying the correct docstring for 'property'
1423 attributes.
1427 attributes.
1424
1428
1425 2006-06-23 Walter Doerwald <walter@livinglogic.de>
1429 2006-06-23 Walter Doerwald <walter@livinglogic.de>
1426
1430
1427 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
1431 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
1428 commands into the methods implementing them.
1432 commands into the methods implementing them.
1429
1433
1430 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
1434 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
1431
1435
1432 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
1436 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
1433 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
1437 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
1434 autoindent support was authored by Jin Liu.
1438 autoindent support was authored by Jin Liu.
1435
1439
1436 2006-06-22 Walter Doerwald <walter@livinglogic.de>
1440 2006-06-22 Walter Doerwald <walter@livinglogic.de>
1437
1441
1438 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
1442 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
1439 for keymaps with a custom class that simplifies handling.
1443 for keymaps with a custom class that simplifies handling.
1440
1444
1441 2006-06-19 Walter Doerwald <walter@livinglogic.de>
1445 2006-06-19 Walter Doerwald <walter@livinglogic.de>
1442
1446
1443 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
1447 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
1444 resizing. This requires Python 2.5 to work.
1448 resizing. This requires Python 2.5 to work.
1445
1449
1446 2006-06-16 Walter Doerwald <walter@livinglogic.de>
1450 2006-06-16 Walter Doerwald <walter@livinglogic.de>
1447
1451
1448 * IPython/Extensions/ibrowse.py: Add two new commands to
1452 * IPython/Extensions/ibrowse.py: Add two new commands to
1449 ibrowse: "hideattr" (mapped to "h") hides the attribute under
1453 ibrowse: "hideattr" (mapped to "h") hides the attribute under
1450 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
1454 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
1451 attributes again. Remapped the help command to "?". Display
1455 attributes again. Remapped the help command to "?". Display
1452 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
1456 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
1453 as keys for the "home" and "end" commands. Add three new commands
1457 as keys for the "home" and "end" commands. Add three new commands
1454 to the input mode for "find" and friends: "delend" (CTRL-K)
1458 to the input mode for "find" and friends: "delend" (CTRL-K)
1455 deletes to the end of line. "incsearchup" searches upwards in the
1459 deletes to the end of line. "incsearchup" searches upwards in the
1456 command history for an input that starts with the text before the cursor.
1460 command history for an input that starts with the text before the cursor.
1457 "incsearchdown" does the same downwards. Removed a bogus mapping of
1461 "incsearchdown" does the same downwards. Removed a bogus mapping of
1458 the x key to "delete".
1462 the x key to "delete".
1459
1463
1460 2006-06-15 Ville Vainio <vivainio@gmail.com>
1464 2006-06-15 Ville Vainio <vivainio@gmail.com>
1461
1465
1462 * iplib.py, hooks.py: Added new generate_prompt hook that can be
1466 * iplib.py, hooks.py: Added new generate_prompt hook that can be
1463 used to create prompts dynamically, instead of the "old" way of
1467 used to create prompts dynamically, instead of the "old" way of
1464 assigning "magic" strings to prompt_in1 and prompt_in2. The old
1468 assigning "magic" strings to prompt_in1 and prompt_in2. The old
1465 way still works (it's invoked by the default hook), of course.
1469 way still works (it's invoked by the default hook), of course.
1466
1470
1467 * Prompts.py: added generate_output_prompt hook for altering output
1471 * Prompts.py: added generate_output_prompt hook for altering output
1468 prompt
1472 prompt
1469
1473
1470 * Release.py: Changed version string to 0.7.3.svn.
1474 * Release.py: Changed version string to 0.7.3.svn.
1471
1475
1472 2006-06-15 Walter Doerwald <walter@livinglogic.de>
1476 2006-06-15 Walter Doerwald <walter@livinglogic.de>
1473
1477
1474 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
1478 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
1475 the call to fetch() always tries to fetch enough data for at least one
1479 the call to fetch() always tries to fetch enough data for at least one
1476 full screen. This makes it possible to simply call moveto(0,0,True) in
1480 full screen. This makes it possible to simply call moveto(0,0,True) in
1477 the constructor. Fix typos and removed the obsolete goto attribute.
1481 the constructor. Fix typos and removed the obsolete goto attribute.
1478
1482
1479 2006-06-12 Ville Vainio <vivainio@gmail.com>
1483 2006-06-12 Ville Vainio <vivainio@gmail.com>
1480
1484
1481 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
1485 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
1482 allowing $variable interpolation within multiline statements,
1486 allowing $variable interpolation within multiline statements,
1483 though so far only with "sh" profile for a testing period.
1487 though so far only with "sh" profile for a testing period.
1484 The patch also enables splitting long commands with \ but it
1488 The patch also enables splitting long commands with \ but it
1485 doesn't work properly yet.
1489 doesn't work properly yet.
1486
1490
1487 2006-06-12 Walter Doerwald <walter@livinglogic.de>
1491 2006-06-12 Walter Doerwald <walter@livinglogic.de>
1488
1492
1489 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
1493 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
1490 input history and the position of the cursor in the input history for
1494 input history and the position of the cursor in the input history for
1491 the find, findbackwards and goto command.
1495 the find, findbackwards and goto command.
1492
1496
1493 2006-06-10 Walter Doerwald <walter@livinglogic.de>
1497 2006-06-10 Walter Doerwald <walter@livinglogic.de>
1494
1498
1495 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
1499 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
1496 implements the basic functionality of browser commands that require
1500 implements the basic functionality of browser commands that require
1497 input. Reimplement the goto, find and findbackwards commands as
1501 input. Reimplement the goto, find and findbackwards commands as
1498 subclasses of _CommandInput. Add an input history and keymaps to those
1502 subclasses of _CommandInput. Add an input history and keymaps to those
1499 commands. Add "\r" as a keyboard shortcut for the enterdefault and
1503 commands. Add "\r" as a keyboard shortcut for the enterdefault and
1500 execute commands.
1504 execute commands.
1501
1505
1502 2006-06-07 Ville Vainio <vivainio@gmail.com>
1506 2006-06-07 Ville Vainio <vivainio@gmail.com>
1503
1507
1504 * iplib.py: ipython mybatch.ipy exits ipython immediately after
1508 * iplib.py: ipython mybatch.ipy exits ipython immediately after
1505 running the batch files instead of leaving the session open.
1509 running the batch files instead of leaving the session open.
1506
1510
1507 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
1511 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
1508
1512
1509 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
1513 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
1510 the original fix was incomplete. Patch submitted by W. Maier.
1514 the original fix was incomplete. Patch submitted by W. Maier.
1511
1515
1512 2006-06-07 Ville Vainio <vivainio@gmail.com>
1516 2006-06-07 Ville Vainio <vivainio@gmail.com>
1513
1517
1514 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
1518 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
1515 Confirmation prompts can be supressed by 'quiet' option.
1519 Confirmation prompts can be supressed by 'quiet' option.
1516 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
1520 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
1517
1521
1518 2006-06-06 *** Released version 0.7.2
1522 2006-06-06 *** Released version 0.7.2
1519
1523
1520 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1524 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1521
1525
1522 * IPython/Release.py (version): Made 0.7.2 final for release.
1526 * IPython/Release.py (version): Made 0.7.2 final for release.
1523 Repo tagged and release cut.
1527 Repo tagged and release cut.
1524
1528
1525 2006-06-05 Ville Vainio <vivainio@gmail.com>
1529 2006-06-05 Ville Vainio <vivainio@gmail.com>
1526
1530
1527 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1531 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1528 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1532 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1529
1533
1530 * upgrade_dir.py: try import 'path' module a bit harder
1534 * upgrade_dir.py: try import 'path' module a bit harder
1531 (for %upgrade)
1535 (for %upgrade)
1532
1536
1533 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1537 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1534
1538
1535 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1539 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1536 instead of looping 20 times.
1540 instead of looping 20 times.
1537
1541
1538 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1542 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1539 correctly at initialization time. Bug reported by Krishna Mohan
1543 correctly at initialization time. Bug reported by Krishna Mohan
1540 Gundu <gkmohan-AT-gmail.com> on the user list.
1544 Gundu <gkmohan-AT-gmail.com> on the user list.
1541
1545
1542 * IPython/Release.py (version): Mark 0.7.2 version to start
1546 * IPython/Release.py (version): Mark 0.7.2 version to start
1543 testing for release on 06/06.
1547 testing for release on 06/06.
1544
1548
1545 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1549 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1546
1550
1547 * scripts/irunner: thin script interface so users don't have to
1551 * scripts/irunner: thin script interface so users don't have to
1548 find the module and call it as an executable, since modules rarely
1552 find the module and call it as an executable, since modules rarely
1549 live in people's PATH.
1553 live in people's PATH.
1550
1554
1551 * IPython/irunner.py (InteractiveRunner.__init__): added
1555 * IPython/irunner.py (InteractiveRunner.__init__): added
1552 delaybeforesend attribute to control delays with newer versions of
1556 delaybeforesend attribute to control delays with newer versions of
1553 pexpect. Thanks to detailed help from pexpect's author, Noah
1557 pexpect. Thanks to detailed help from pexpect's author, Noah
1554 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1558 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1555 correctly (it works in NoColor mode).
1559 correctly (it works in NoColor mode).
1556
1560
1557 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1561 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1558 SAGE list, from improper log() calls.
1562 SAGE list, from improper log() calls.
1559
1563
1560 2006-05-31 Ville Vainio <vivainio@gmail.com>
1564 2006-05-31 Ville Vainio <vivainio@gmail.com>
1561
1565
1562 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1566 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1563 with args in parens to work correctly with dirs that have spaces.
1567 with args in parens to work correctly with dirs that have spaces.
1564
1568
1565 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1569 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1566
1570
1567 * IPython/Logger.py (Logger.logstart): add option to log raw input
1571 * IPython/Logger.py (Logger.logstart): add option to log raw input
1568 instead of the processed one. A -r flag was added to the
1572 instead of the processed one. A -r flag was added to the
1569 %logstart magic used for controlling logging.
1573 %logstart magic used for controlling logging.
1570
1574
1571 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1575 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1572
1576
1573 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1577 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1574 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1578 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1575 recognize the option. After a bug report by Will Maier. This
1579 recognize the option. After a bug report by Will Maier. This
1576 closes #64 (will do it after confirmation from W. Maier).
1580 closes #64 (will do it after confirmation from W. Maier).
1577
1581
1578 * IPython/irunner.py: New module to run scripts as if manually
1582 * IPython/irunner.py: New module to run scripts as if manually
1579 typed into an interactive environment, based on pexpect. After a
1583 typed into an interactive environment, based on pexpect. After a
1580 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1584 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1581 ipython-user list. Simple unittests in the tests/ directory.
1585 ipython-user list. Simple unittests in the tests/ directory.
1582
1586
1583 * tools/release: add Will Maier, OpenBSD port maintainer, to
1587 * tools/release: add Will Maier, OpenBSD port maintainer, to
1584 recepients list. We are now officially part of the OpenBSD ports:
1588 recepients list. We are now officially part of the OpenBSD ports:
1585 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1589 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1586 work.
1590 work.
1587
1591
1588 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1592 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1589
1593
1590 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1594 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1591 so that it doesn't break tkinter apps.
1595 so that it doesn't break tkinter apps.
1592
1596
1593 * IPython/iplib.py (_prefilter): fix bug where aliases would
1597 * IPython/iplib.py (_prefilter): fix bug where aliases would
1594 shadow variables when autocall was fully off. Reported by SAGE
1598 shadow variables when autocall was fully off. Reported by SAGE
1595 author William Stein.
1599 author William Stein.
1596
1600
1597 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1601 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1598 at what detail level strings are computed when foo? is requested.
1602 at what detail level strings are computed when foo? is requested.
1599 This allows users to ask for example that the string form of an
1603 This allows users to ask for example that the string form of an
1600 object is only computed when foo?? is called, or even never, by
1604 object is only computed when foo?? is called, or even never, by
1601 setting the object_info_string_level >= 2 in the configuration
1605 setting the object_info_string_level >= 2 in the configuration
1602 file. This new option has been added and documented. After a
1606 file. This new option has been added and documented. After a
1603 request by SAGE to be able to control the printing of very large
1607 request by SAGE to be able to control the printing of very large
1604 objects more easily.
1608 objects more easily.
1605
1609
1606 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1610 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1607
1611
1608 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1612 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1609 from sys.argv, to be 100% consistent with how Python itself works
1613 from sys.argv, to be 100% consistent with how Python itself works
1610 (as seen for example with python -i file.py). After a bug report
1614 (as seen for example with python -i file.py). After a bug report
1611 by Jeffrey Collins.
1615 by Jeffrey Collins.
1612
1616
1613 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1617 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1614 nasty bug which was preventing custom namespaces with -pylab,
1618 nasty bug which was preventing custom namespaces with -pylab,
1615 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1619 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1616 compatibility (long gone from mpl).
1620 compatibility (long gone from mpl).
1617
1621
1618 * IPython/ipapi.py (make_session): name change: create->make. We
1622 * IPython/ipapi.py (make_session): name change: create->make. We
1619 use make in other places (ipmaker,...), it's shorter and easier to
1623 use make in other places (ipmaker,...), it's shorter and easier to
1620 type and say, etc. I'm trying to clean things before 0.7.2 so
1624 type and say, etc. I'm trying to clean things before 0.7.2 so
1621 that I can keep things stable wrt to ipapi in the chainsaw branch.
1625 that I can keep things stable wrt to ipapi in the chainsaw branch.
1622
1626
1623 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1627 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1624 python-mode recognizes our debugger mode. Add support for
1628 python-mode recognizes our debugger mode. Add support for
1625 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1629 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1626 <m.liu.jin-AT-gmail.com> originally written by
1630 <m.liu.jin-AT-gmail.com> originally written by
1627 doxgen-AT-newsmth.net (with minor modifications for xemacs
1631 doxgen-AT-newsmth.net (with minor modifications for xemacs
1628 compatibility)
1632 compatibility)
1629
1633
1630 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1634 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1631 tracebacks when walking the stack so that the stack tracking system
1635 tracebacks when walking the stack so that the stack tracking system
1632 in emacs' python-mode can identify the frames correctly.
1636 in emacs' python-mode can identify the frames correctly.
1633
1637
1634 * IPython/ipmaker.py (make_IPython): make the internal (and
1638 * IPython/ipmaker.py (make_IPython): make the internal (and
1635 default config) autoedit_syntax value false by default. Too many
1639 default config) autoedit_syntax value false by default. Too many
1636 users have complained to me (both on and off-list) about problems
1640 users have complained to me (both on and off-list) about problems
1637 with this option being on by default, so I'm making it default to
1641 with this option being on by default, so I'm making it default to
1638 off. It can still be enabled by anyone via the usual mechanisms.
1642 off. It can still be enabled by anyone via the usual mechanisms.
1639
1643
1640 * IPython/completer.py (Completer.attr_matches): add support for
1644 * IPython/completer.py (Completer.attr_matches): add support for
1641 PyCrust-style _getAttributeNames magic method. Patch contributed
1645 PyCrust-style _getAttributeNames magic method. Patch contributed
1642 by <mscott-AT-goldenspud.com>. Closes #50.
1646 by <mscott-AT-goldenspud.com>. Closes #50.
1643
1647
1644 * IPython/iplib.py (InteractiveShell.__init__): remove the
1648 * IPython/iplib.py (InteractiveShell.__init__): remove the
1645 deletion of exit/quit from __builtin__, which can break
1649 deletion of exit/quit from __builtin__, which can break
1646 third-party tools like the Zope debugging console. The
1650 third-party tools like the Zope debugging console. The
1647 %exit/%quit magics remain. In general, it's probably a good idea
1651 %exit/%quit magics remain. In general, it's probably a good idea
1648 not to delete anything from __builtin__, since we never know what
1652 not to delete anything from __builtin__, since we never know what
1649 that will break. In any case, python now (for 2.5) will support
1653 that will break. In any case, python now (for 2.5) will support
1650 'real' exit/quit, so this issue is moot. Closes #55.
1654 'real' exit/quit, so this issue is moot. Closes #55.
1651
1655
1652 * IPython/genutils.py (with_obj): rename the 'with' function to
1656 * IPython/genutils.py (with_obj): rename the 'with' function to
1653 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1657 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1654 becomes a language keyword. Closes #53.
1658 becomes a language keyword. Closes #53.
1655
1659
1656 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1660 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1657 __file__ attribute to this so it fools more things into thinking
1661 __file__ attribute to this so it fools more things into thinking
1658 it is a real module. Closes #59.
1662 it is a real module. Closes #59.
1659
1663
1660 * IPython/Magic.py (magic_edit): add -n option to open the editor
1664 * IPython/Magic.py (magic_edit): add -n option to open the editor
1661 at a specific line number. After a patch by Stefan van der Walt.
1665 at a specific line number. After a patch by Stefan van der Walt.
1662
1666
1663 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1667 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1664
1668
1665 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1669 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1666 reason the file could not be opened. After automatic crash
1670 reason the file could not be opened. After automatic crash
1667 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1671 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1668 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1672 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1669 (_should_recompile): Don't fire editor if using %bg, since there
1673 (_should_recompile): Don't fire editor if using %bg, since there
1670 is no file in the first place. From the same report as above.
1674 is no file in the first place. From the same report as above.
1671 (raw_input): protect against faulty third-party prefilters. After
1675 (raw_input): protect against faulty third-party prefilters. After
1672 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1676 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1673 while running under SAGE.
1677 while running under SAGE.
1674
1678
1675 2006-05-23 Ville Vainio <vivainio@gmail.com>
1679 2006-05-23 Ville Vainio <vivainio@gmail.com>
1676
1680
1677 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1681 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1678 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1682 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1679 now returns None (again), unless dummy is specifically allowed by
1683 now returns None (again), unless dummy is specifically allowed by
1680 ipapi.get(allow_dummy=True).
1684 ipapi.get(allow_dummy=True).
1681
1685
1682 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1686 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1683
1687
1684 * IPython: remove all 2.2-compatibility objects and hacks from
1688 * IPython: remove all 2.2-compatibility objects and hacks from
1685 everywhere, since we only support 2.3 at this point. Docs
1689 everywhere, since we only support 2.3 at this point. Docs
1686 updated.
1690 updated.
1687
1691
1688 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1692 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1689 Anything requiring extra validation can be turned into a Python
1693 Anything requiring extra validation can be turned into a Python
1690 property in the future. I used a property for the db one b/c
1694 property in the future. I used a property for the db one b/c
1691 there was a nasty circularity problem with the initialization
1695 there was a nasty circularity problem with the initialization
1692 order, which right now I don't have time to clean up.
1696 order, which right now I don't have time to clean up.
1693
1697
1694 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1698 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1695 another locking bug reported by Jorgen. I'm not 100% sure though,
1699 another locking bug reported by Jorgen. I'm not 100% sure though,
1696 so more testing is needed...
1700 so more testing is needed...
1697
1701
1698 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1702 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1699
1703
1700 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1704 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1701 local variables from any routine in user code (typically executed
1705 local variables from any routine in user code (typically executed
1702 with %run) directly into the interactive namespace. Very useful
1706 with %run) directly into the interactive namespace. Very useful
1703 when doing complex debugging.
1707 when doing complex debugging.
1704 (IPythonNotRunning): Changed the default None object to a dummy
1708 (IPythonNotRunning): Changed the default None object to a dummy
1705 whose attributes can be queried as well as called without
1709 whose attributes can be queried as well as called without
1706 exploding, to ease writing code which works transparently both in
1710 exploding, to ease writing code which works transparently both in
1707 and out of ipython and uses some of this API.
1711 and out of ipython and uses some of this API.
1708
1712
1709 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1713 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1710
1714
1711 * IPython/hooks.py (result_display): Fix the fact that our display
1715 * IPython/hooks.py (result_display): Fix the fact that our display
1712 hook was using str() instead of repr(), as the default python
1716 hook was using str() instead of repr(), as the default python
1713 console does. This had gone unnoticed b/c it only happened if
1717 console does. This had gone unnoticed b/c it only happened if
1714 %Pprint was off, but the inconsistency was there.
1718 %Pprint was off, but the inconsistency was there.
1715
1719
1716 2006-05-15 Ville Vainio <vivainio@gmail.com>
1720 2006-05-15 Ville Vainio <vivainio@gmail.com>
1717
1721
1718 * Oinspect.py: Only show docstring for nonexisting/binary files
1722 * Oinspect.py: Only show docstring for nonexisting/binary files
1719 when doing object??, closing ticket #62
1723 when doing object??, closing ticket #62
1720
1724
1721 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1725 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1722
1726
1723 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1727 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1724 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1728 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1725 was being released in a routine which hadn't checked if it had
1729 was being released in a routine which hadn't checked if it had
1726 been the one to acquire it.
1730 been the one to acquire it.
1727
1731
1728 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1732 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1729
1733
1730 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1734 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1731
1735
1732 2006-04-11 Ville Vainio <vivainio@gmail.com>
1736 2006-04-11 Ville Vainio <vivainio@gmail.com>
1733
1737
1734 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1738 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1735 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1739 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1736 prefilters, allowing stuff like magics and aliases in the file.
1740 prefilters, allowing stuff like magics and aliases in the file.
1737
1741
1738 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1742 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1739 added. Supported now are "%clear in" and "%clear out" (clear input and
1743 added. Supported now are "%clear in" and "%clear out" (clear input and
1740 output history, respectively). Also fixed CachedOutput.flush to
1744 output history, respectively). Also fixed CachedOutput.flush to
1741 properly flush the output cache.
1745 properly flush the output cache.
1742
1746
1743 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1747 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1744 half-success (and fail explicitly).
1748 half-success (and fail explicitly).
1745
1749
1746 2006-03-28 Ville Vainio <vivainio@gmail.com>
1750 2006-03-28 Ville Vainio <vivainio@gmail.com>
1747
1751
1748 * iplib.py: Fix quoting of aliases so that only argless ones
1752 * iplib.py: Fix quoting of aliases so that only argless ones
1749 are quoted
1753 are quoted
1750
1754
1751 2006-03-28 Ville Vainio <vivainio@gmail.com>
1755 2006-03-28 Ville Vainio <vivainio@gmail.com>
1752
1756
1753 * iplib.py: Quote aliases with spaces in the name.
1757 * iplib.py: Quote aliases with spaces in the name.
1754 "c:\program files\blah\bin" is now legal alias target.
1758 "c:\program files\blah\bin" is now legal alias target.
1755
1759
1756 * ext_rehashdir.py: Space no longer allowed as arg
1760 * ext_rehashdir.py: Space no longer allowed as arg
1757 separator, since space is legal in path names.
1761 separator, since space is legal in path names.
1758
1762
1759 2006-03-16 Ville Vainio <vivainio@gmail.com>
1763 2006-03-16 Ville Vainio <vivainio@gmail.com>
1760
1764
1761 * upgrade_dir.py: Take path.py from Extensions, correcting
1765 * upgrade_dir.py: Take path.py from Extensions, correcting
1762 %upgrade magic
1766 %upgrade magic
1763
1767
1764 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1768 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1765
1769
1766 * hooks.py: Only enclose editor binary in quotes if legal and
1770 * hooks.py: Only enclose editor binary in quotes if legal and
1767 necessary (space in the name, and is an existing file). Fixes a bug
1771 necessary (space in the name, and is an existing file). Fixes a bug
1768 reported by Zachary Pincus.
1772 reported by Zachary Pincus.
1769
1773
1770 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1774 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1771
1775
1772 * Manual: thanks to a tip on proper color handling for Emacs, by
1776 * Manual: thanks to a tip on proper color handling for Emacs, by
1773 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1777 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1774
1778
1775 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1779 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1776 by applying the provided patch. Thanks to Liu Jin
1780 by applying the provided patch. Thanks to Liu Jin
1777 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1781 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1778 XEmacs/Linux, I'm trusting the submitter that it actually helps
1782 XEmacs/Linux, I'm trusting the submitter that it actually helps
1779 under win32/GNU Emacs. Will revisit if any problems are reported.
1783 under win32/GNU Emacs. Will revisit if any problems are reported.
1780
1784
1781 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1785 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1782
1786
1783 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1787 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1784 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1788 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1785
1789
1786 2006-03-12 Ville Vainio <vivainio@gmail.com>
1790 2006-03-12 Ville Vainio <vivainio@gmail.com>
1787
1791
1788 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1792 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1789 Torsten Marek.
1793 Torsten Marek.
1790
1794
1791 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1795 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1792
1796
1793 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1797 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1794 line ranges works again.
1798 line ranges works again.
1795
1799
1796 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1800 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1797
1801
1798 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1802 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1799 and friends, after a discussion with Zach Pincus on ipython-user.
1803 and friends, after a discussion with Zach Pincus on ipython-user.
1800 I'm not 100% sure, but after thinking about it quite a bit, it may
1804 I'm not 100% sure, but after thinking about it quite a bit, it may
1801 be OK. Testing with the multithreaded shells didn't reveal any
1805 be OK. Testing with the multithreaded shells didn't reveal any
1802 problems, but let's keep an eye out.
1806 problems, but let's keep an eye out.
1803
1807
1804 In the process, I fixed a few things which were calling
1808 In the process, I fixed a few things which were calling
1805 self.InteractiveTB() directly (like safe_execfile), which is a
1809 self.InteractiveTB() directly (like safe_execfile), which is a
1806 mistake: ALL exception reporting should be done by calling
1810 mistake: ALL exception reporting should be done by calling
1807 self.showtraceback(), which handles state and tab-completion and
1811 self.showtraceback(), which handles state and tab-completion and
1808 more.
1812 more.
1809
1813
1810 2006-03-01 Ville Vainio <vivainio@gmail.com>
1814 2006-03-01 Ville Vainio <vivainio@gmail.com>
1811
1815
1812 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1816 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1813 To use, do "from ipipe import *".
1817 To use, do "from ipipe import *".
1814
1818
1815 2006-02-24 Ville Vainio <vivainio@gmail.com>
1819 2006-02-24 Ville Vainio <vivainio@gmail.com>
1816
1820
1817 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1821 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1818 "cleanly" and safely than the older upgrade mechanism.
1822 "cleanly" and safely than the older upgrade mechanism.
1819
1823
1820 2006-02-21 Ville Vainio <vivainio@gmail.com>
1824 2006-02-21 Ville Vainio <vivainio@gmail.com>
1821
1825
1822 * Magic.py: %save works again.
1826 * Magic.py: %save works again.
1823
1827
1824 2006-02-15 Ville Vainio <vivainio@gmail.com>
1828 2006-02-15 Ville Vainio <vivainio@gmail.com>
1825
1829
1826 * Magic.py: %Pprint works again
1830 * Magic.py: %Pprint works again
1827
1831
1828 * Extensions/ipy_sane_defaults.py: Provide everything provided
1832 * Extensions/ipy_sane_defaults.py: Provide everything provided
1829 in default ipythonrc, to make it possible to have a completely empty
1833 in default ipythonrc, to make it possible to have a completely empty
1830 ipythonrc (and thus completely rc-file free configuration)
1834 ipythonrc (and thus completely rc-file free configuration)
1831
1835
1832 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1836 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1833
1837
1834 * IPython/hooks.py (editor): quote the call to the editor command,
1838 * IPython/hooks.py (editor): quote the call to the editor command,
1835 to allow commands with spaces in them. Problem noted by watching
1839 to allow commands with spaces in them. Problem noted by watching
1836 Ian Oswald's video about textpad under win32 at
1840 Ian Oswald's video about textpad under win32 at
1837 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1841 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1838
1842
1839 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1843 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1840 describing magics (we haven't used @ for a loong time).
1844 describing magics (we haven't used @ for a loong time).
1841
1845
1842 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1846 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1843 contributed by marienz to close
1847 contributed by marienz to close
1844 http://www.scipy.net/roundup/ipython/issue53.
1848 http://www.scipy.net/roundup/ipython/issue53.
1845
1849
1846 2006-02-10 Ville Vainio <vivainio@gmail.com>
1850 2006-02-10 Ville Vainio <vivainio@gmail.com>
1847
1851
1848 * genutils.py: getoutput now works in win32 too
1852 * genutils.py: getoutput now works in win32 too
1849
1853
1850 * completer.py: alias and magic completion only invoked
1854 * completer.py: alias and magic completion only invoked
1851 at the first "item" in the line, to avoid "cd %store"
1855 at the first "item" in the line, to avoid "cd %store"
1852 nonsense.
1856 nonsense.
1853
1857
1854 2006-02-09 Ville Vainio <vivainio@gmail.com>
1858 2006-02-09 Ville Vainio <vivainio@gmail.com>
1855
1859
1856 * test/*: Added a unit testing framework (finally).
1860 * test/*: Added a unit testing framework (finally).
1857 '%run runtests.py' to run test_*.
1861 '%run runtests.py' to run test_*.
1858
1862
1859 * ipapi.py: Exposed runlines and set_custom_exc
1863 * ipapi.py: Exposed runlines and set_custom_exc
1860
1864
1861 2006-02-07 Ville Vainio <vivainio@gmail.com>
1865 2006-02-07 Ville Vainio <vivainio@gmail.com>
1862
1866
1863 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1867 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1864 instead use "f(1 2)" as before.
1868 instead use "f(1 2)" as before.
1865
1869
1866 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1870 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1867
1871
1868 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1872 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1869 facilities, for demos processed by the IPython input filter
1873 facilities, for demos processed by the IPython input filter
1870 (IPythonDemo), and for running a script one-line-at-a-time as a
1874 (IPythonDemo), and for running a script one-line-at-a-time as a
1871 demo, both for pure Python (LineDemo) and for IPython-processed
1875 demo, both for pure Python (LineDemo) and for IPython-processed
1872 input (IPythonLineDemo). After a request by Dave Kohel, from the
1876 input (IPythonLineDemo). After a request by Dave Kohel, from the
1873 SAGE team.
1877 SAGE team.
1874 (Demo.edit): added an edit() method to the demo objects, to edit
1878 (Demo.edit): added an edit() method to the demo objects, to edit
1875 the in-memory copy of the last executed block.
1879 the in-memory copy of the last executed block.
1876
1880
1877 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1881 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1878 processing to %edit, %macro and %save. These commands can now be
1882 processing to %edit, %macro and %save. These commands can now be
1879 invoked on the unprocessed input as it was typed by the user
1883 invoked on the unprocessed input as it was typed by the user
1880 (without any prefilters applied). After requests by the SAGE team
1884 (without any prefilters applied). After requests by the SAGE team
1881 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1885 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1882
1886
1883 2006-02-01 Ville Vainio <vivainio@gmail.com>
1887 2006-02-01 Ville Vainio <vivainio@gmail.com>
1884
1888
1885 * setup.py, eggsetup.py: easy_install ipython==dev works
1889 * setup.py, eggsetup.py: easy_install ipython==dev works
1886 correctly now (on Linux)
1890 correctly now (on Linux)
1887
1891
1888 * ipy_user_conf,ipmaker: user config changes, removed spurious
1892 * ipy_user_conf,ipmaker: user config changes, removed spurious
1889 warnings
1893 warnings
1890
1894
1891 * iplib: if rc.banner is string, use it as is.
1895 * iplib: if rc.banner is string, use it as is.
1892
1896
1893 * Magic: %pycat accepts a string argument and pages it's contents.
1897 * Magic: %pycat accepts a string argument and pages it's contents.
1894
1898
1895
1899
1896 2006-01-30 Ville Vainio <vivainio@gmail.com>
1900 2006-01-30 Ville Vainio <vivainio@gmail.com>
1897
1901
1898 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1902 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1899 Now %store and bookmarks work through PickleShare, meaning that
1903 Now %store and bookmarks work through PickleShare, meaning that
1900 concurrent access is possible and all ipython sessions see the
1904 concurrent access is possible and all ipython sessions see the
1901 same database situation all the time, instead of snapshot of
1905 same database situation all the time, instead of snapshot of
1902 the situation when the session was started. Hence, %bookmark
1906 the situation when the session was started. Hence, %bookmark
1903 results are immediately accessible from othes sessions. The database
1907 results are immediately accessible from othes sessions. The database
1904 is also available for use by user extensions. See:
1908 is also available for use by user extensions. See:
1905 http://www.python.org/pypi/pickleshare
1909 http://www.python.org/pypi/pickleshare
1906
1910
1907 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1911 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1908
1912
1909 * aliases can now be %store'd
1913 * aliases can now be %store'd
1910
1914
1911 * path.py moved to Extensions so that pickleshare does not need
1915 * path.py moved to Extensions so that pickleshare does not need
1912 IPython-specific import. Extensions added to pythonpath right
1916 IPython-specific import. Extensions added to pythonpath right
1913 at __init__.
1917 at __init__.
1914
1918
1915 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1919 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1916 called with _ip.system and the pre-transformed command string.
1920 called with _ip.system and the pre-transformed command string.
1917
1921
1918 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1922 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1919
1923
1920 * IPython/iplib.py (interact): Fix that we were not catching
1924 * IPython/iplib.py (interact): Fix that we were not catching
1921 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1925 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1922 logic here had to change, but it's fixed now.
1926 logic here had to change, but it's fixed now.
1923
1927
1924 2006-01-29 Ville Vainio <vivainio@gmail.com>
1928 2006-01-29 Ville Vainio <vivainio@gmail.com>
1925
1929
1926 * iplib.py: Try to import pyreadline on Windows.
1930 * iplib.py: Try to import pyreadline on Windows.
1927
1931
1928 2006-01-27 Ville Vainio <vivainio@gmail.com>
1932 2006-01-27 Ville Vainio <vivainio@gmail.com>
1929
1933
1930 * iplib.py: Expose ipapi as _ip in builtin namespace.
1934 * iplib.py: Expose ipapi as _ip in builtin namespace.
1931 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1935 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1932 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1936 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1933 syntax now produce _ip.* variant of the commands.
1937 syntax now produce _ip.* variant of the commands.
1934
1938
1935 * "_ip.options().autoedit_syntax = 2" automatically throws
1939 * "_ip.options().autoedit_syntax = 2" automatically throws
1936 user to editor for syntax error correction without prompting.
1940 user to editor for syntax error correction without prompting.
1937
1941
1938 2006-01-27 Ville Vainio <vivainio@gmail.com>
1942 2006-01-27 Ville Vainio <vivainio@gmail.com>
1939
1943
1940 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1944 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1941 'ipython' at argv[0]) executed through command line.
1945 'ipython' at argv[0]) executed through command line.
1942 NOTE: this DEPRECATES calling ipython with multiple scripts
1946 NOTE: this DEPRECATES calling ipython with multiple scripts
1943 ("ipython a.py b.py c.py")
1947 ("ipython a.py b.py c.py")
1944
1948
1945 * iplib.py, hooks.py: Added configurable input prefilter,
1949 * iplib.py, hooks.py: Added configurable input prefilter,
1946 named 'input_prefilter'. See ext_rescapture.py for example
1950 named 'input_prefilter'. See ext_rescapture.py for example
1947 usage.
1951 usage.
1948
1952
1949 * ext_rescapture.py, Magic.py: Better system command output capture
1953 * ext_rescapture.py, Magic.py: Better system command output capture
1950 through 'var = !ls' (deprecates user-visible %sc). Same notation
1954 through 'var = !ls' (deprecates user-visible %sc). Same notation
1951 applies for magics, 'var = %alias' assigns alias list to var.
1955 applies for magics, 'var = %alias' assigns alias list to var.
1952
1956
1953 * ipapi.py: added meta() for accessing extension-usable data store.
1957 * ipapi.py: added meta() for accessing extension-usable data store.
1954
1958
1955 * iplib.py: added InteractiveShell.getapi(). New magics should be
1959 * iplib.py: added InteractiveShell.getapi(). New magics should be
1956 written doing self.getapi() instead of using the shell directly.
1960 written doing self.getapi() instead of using the shell directly.
1957
1961
1958 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1962 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1959 %store foo >> ~/myfoo.txt to store variables to files (in clean
1963 %store foo >> ~/myfoo.txt to store variables to files (in clean
1960 textual form, not a restorable pickle).
1964 textual form, not a restorable pickle).
1961
1965
1962 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1966 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1963
1967
1964 * usage.py, Magic.py: added %quickref
1968 * usage.py, Magic.py: added %quickref
1965
1969
1966 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1970 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1967
1971
1968 * GetoptErrors when invoking magics etc. with wrong args
1972 * GetoptErrors when invoking magics etc. with wrong args
1969 are now more helpful:
1973 are now more helpful:
1970 GetoptError: option -l not recognized (allowed: "qb" )
1974 GetoptError: option -l not recognized (allowed: "qb" )
1971
1975
1972 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1976 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1973
1977
1974 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1978 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1975 computationally intensive blocks don't appear to stall the demo.
1979 computationally intensive blocks don't appear to stall the demo.
1976
1980
1977 2006-01-24 Ville Vainio <vivainio@gmail.com>
1981 2006-01-24 Ville Vainio <vivainio@gmail.com>
1978
1982
1979 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1983 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1980 value to manipulate resulting history entry.
1984 value to manipulate resulting history entry.
1981
1985
1982 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1986 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1983 to instance methods of IPApi class, to make extending an embedded
1987 to instance methods of IPApi class, to make extending an embedded
1984 IPython feasible. See ext_rehashdir.py for example usage.
1988 IPython feasible. See ext_rehashdir.py for example usage.
1985
1989
1986 * Merged 1071-1076 from branches/0.7.1
1990 * Merged 1071-1076 from branches/0.7.1
1987
1991
1988
1992
1989 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1993 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1990
1994
1991 * tools/release (daystamp): Fix build tools to use the new
1995 * tools/release (daystamp): Fix build tools to use the new
1992 eggsetup.py script to build lightweight eggs.
1996 eggsetup.py script to build lightweight eggs.
1993
1997
1994 * Applied changesets 1062 and 1064 before 0.7.1 release.
1998 * Applied changesets 1062 and 1064 before 0.7.1 release.
1995
1999
1996 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
2000 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1997 see the raw input history (without conversions like %ls ->
2001 see the raw input history (without conversions like %ls ->
1998 ipmagic("ls")). After a request from W. Stein, SAGE
2002 ipmagic("ls")). After a request from W. Stein, SAGE
1999 (http://modular.ucsd.edu/sage) developer. This information is
2003 (http://modular.ucsd.edu/sage) developer. This information is
2000 stored in the input_hist_raw attribute of the IPython instance, so
2004 stored in the input_hist_raw attribute of the IPython instance, so
2001 developers can access it if needed (it's an InputList instance).
2005 developers can access it if needed (it's an InputList instance).
2002
2006
2003 * Versionstring = 0.7.2.svn
2007 * Versionstring = 0.7.2.svn
2004
2008
2005 * eggsetup.py: A separate script for constructing eggs, creates
2009 * eggsetup.py: A separate script for constructing eggs, creates
2006 proper launch scripts even on Windows (an .exe file in
2010 proper launch scripts even on Windows (an .exe file in
2007 \python24\scripts).
2011 \python24\scripts).
2008
2012
2009 * ipapi.py: launch_new_instance, launch entry point needed for the
2013 * ipapi.py: launch_new_instance, launch entry point needed for the
2010 egg.
2014 egg.
2011
2015
2012 2006-01-23 Ville Vainio <vivainio@gmail.com>
2016 2006-01-23 Ville Vainio <vivainio@gmail.com>
2013
2017
2014 * Added %cpaste magic for pasting python code
2018 * Added %cpaste magic for pasting python code
2015
2019
2016 2006-01-22 Ville Vainio <vivainio@gmail.com>
2020 2006-01-22 Ville Vainio <vivainio@gmail.com>
2017
2021
2018 * Merge from branches/0.7.1 into trunk, revs 1052-1057
2022 * Merge from branches/0.7.1 into trunk, revs 1052-1057
2019
2023
2020 * Versionstring = 0.7.2.svn
2024 * Versionstring = 0.7.2.svn
2021
2025
2022 * eggsetup.py: A separate script for constructing eggs, creates
2026 * eggsetup.py: A separate script for constructing eggs, creates
2023 proper launch scripts even on Windows (an .exe file in
2027 proper launch scripts even on Windows (an .exe file in
2024 \python24\scripts).
2028 \python24\scripts).
2025
2029
2026 * ipapi.py: launch_new_instance, launch entry point needed for the
2030 * ipapi.py: launch_new_instance, launch entry point needed for the
2027 egg.
2031 egg.
2028
2032
2029 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
2033 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
2030
2034
2031 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
2035 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
2032 %pfile foo would print the file for foo even if it was a binary.
2036 %pfile foo would print the file for foo even if it was a binary.
2033 Now, extensions '.so' and '.dll' are skipped.
2037 Now, extensions '.so' and '.dll' are skipped.
2034
2038
2035 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
2039 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
2036 bug, where macros would fail in all threaded modes. I'm not 100%
2040 bug, where macros would fail in all threaded modes. I'm not 100%
2037 sure, so I'm going to put out an rc instead of making a release
2041 sure, so I'm going to put out an rc instead of making a release
2038 today, and wait for feedback for at least a few days.
2042 today, and wait for feedback for at least a few days.
2039
2043
2040 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
2044 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
2041 it...) the handling of pasting external code with autoindent on.
2045 it...) the handling of pasting external code with autoindent on.
2042 To get out of a multiline input, the rule will appear for most
2046 To get out of a multiline input, the rule will appear for most
2043 users unchanged: two blank lines or change the indent level
2047 users unchanged: two blank lines or change the indent level
2044 proposed by IPython. But there is a twist now: you can
2048 proposed by IPython. But there is a twist now: you can
2045 add/subtract only *one or two spaces*. If you add/subtract three
2049 add/subtract only *one or two spaces*. If you add/subtract three
2046 or more (unless you completely delete the line), IPython will
2050 or more (unless you completely delete the line), IPython will
2047 accept that line, and you'll need to enter a second one of pure
2051 accept that line, and you'll need to enter a second one of pure
2048 whitespace. I know it sounds complicated, but I can't find a
2052 whitespace. I know it sounds complicated, but I can't find a
2049 different solution that covers all the cases, with the right
2053 different solution that covers all the cases, with the right
2050 heuristics. Hopefully in actual use, nobody will really notice
2054 heuristics. Hopefully in actual use, nobody will really notice
2051 all these strange rules and things will 'just work'.
2055 all these strange rules and things will 'just work'.
2052
2056
2053 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
2057 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
2054
2058
2055 * IPython/iplib.py (interact): catch exceptions which can be
2059 * IPython/iplib.py (interact): catch exceptions which can be
2056 triggered asynchronously by signal handlers. Thanks to an
2060 triggered asynchronously by signal handlers. Thanks to an
2057 automatic crash report, submitted by Colin Kingsley
2061 automatic crash report, submitted by Colin Kingsley
2058 <tercel-AT-gentoo.org>.
2062 <tercel-AT-gentoo.org>.
2059
2063
2060 2006-01-20 Ville Vainio <vivainio@gmail.com>
2064 2006-01-20 Ville Vainio <vivainio@gmail.com>
2061
2065
2062 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
2066 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
2063 (%rehashdir, very useful, try it out) of how to extend ipython
2067 (%rehashdir, very useful, try it out) of how to extend ipython
2064 with new magics. Also added Extensions dir to pythonpath to make
2068 with new magics. Also added Extensions dir to pythonpath to make
2065 importing extensions easy.
2069 importing extensions easy.
2066
2070
2067 * %store now complains when trying to store interactively declared
2071 * %store now complains when trying to store interactively declared
2068 classes / instances of those classes.
2072 classes / instances of those classes.
2069
2073
2070 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
2074 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
2071 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
2075 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
2072 if they exist, and ipy_user_conf.py with some defaults is created for
2076 if they exist, and ipy_user_conf.py with some defaults is created for
2073 the user.
2077 the user.
2074
2078
2075 * Startup rehashing done by the config file, not InterpreterExec.
2079 * Startup rehashing done by the config file, not InterpreterExec.
2076 This means system commands are available even without selecting the
2080 This means system commands are available even without selecting the
2077 pysh profile. It's the sensible default after all.
2081 pysh profile. It's the sensible default after all.
2078
2082
2079 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
2083 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
2080
2084
2081 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
2085 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
2082 multiline code with autoindent on working. But I am really not
2086 multiline code with autoindent on working. But I am really not
2083 sure, so this needs more testing. Will commit a debug-enabled
2087 sure, so this needs more testing. Will commit a debug-enabled
2084 version for now, while I test it some more, so that Ville and
2088 version for now, while I test it some more, so that Ville and
2085 others may also catch any problems. Also made
2089 others may also catch any problems. Also made
2086 self.indent_current_str() a method, to ensure that there's no
2090 self.indent_current_str() a method, to ensure that there's no
2087 chance of the indent space count and the corresponding string
2091 chance of the indent space count and the corresponding string
2088 falling out of sync. All code needing the string should just call
2092 falling out of sync. All code needing the string should just call
2089 the method.
2093 the method.
2090
2094
2091 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2095 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2092
2096
2093 * IPython/Magic.py (magic_edit): fix check for when users don't
2097 * IPython/Magic.py (magic_edit): fix check for when users don't
2094 save their output files, the try/except was in the wrong section.
2098 save their output files, the try/except was in the wrong section.
2095
2099
2096 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2100 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2097
2101
2098 * IPython/Magic.py (magic_run): fix __file__ global missing from
2102 * IPython/Magic.py (magic_run): fix __file__ global missing from
2099 script's namespace when executed via %run. After a report by
2103 script's namespace when executed via %run. After a report by
2100 Vivian.
2104 Vivian.
2101
2105
2102 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
2106 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
2103 when using python 2.4. The parent constructor changed in 2.4, and
2107 when using python 2.4. The parent constructor changed in 2.4, and
2104 we need to track it directly (we can't call it, as it messes up
2108 we need to track it directly (we can't call it, as it messes up
2105 readline and tab-completion inside our pdb would stop working).
2109 readline and tab-completion inside our pdb would stop working).
2106 After a bug report by R. Bernstein <rocky-AT-panix.com>.
2110 After a bug report by R. Bernstein <rocky-AT-panix.com>.
2107
2111
2108 2006-01-16 Ville Vainio <vivainio@gmail.com>
2112 2006-01-16 Ville Vainio <vivainio@gmail.com>
2109
2113
2110 * Ipython/magic.py: Reverted back to old %edit functionality
2114 * Ipython/magic.py: Reverted back to old %edit functionality
2111 that returns file contents on exit.
2115 that returns file contents on exit.
2112
2116
2113 * IPython/path.py: Added Jason Orendorff's "path" module to
2117 * IPython/path.py: Added Jason Orendorff's "path" module to
2114 IPython tree, http://www.jorendorff.com/articles/python/path/.
2118 IPython tree, http://www.jorendorff.com/articles/python/path/.
2115 You can get path objects conveniently through %sc, and !!, e.g.:
2119 You can get path objects conveniently through %sc, and !!, e.g.:
2116 sc files=ls
2120 sc files=ls
2117 for p in files.paths: # or files.p
2121 for p in files.paths: # or files.p
2118 print p,p.mtime
2122 print p,p.mtime
2119
2123
2120 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
2124 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
2121 now work again without considering the exclusion regexp -
2125 now work again without considering the exclusion regexp -
2122 hence, things like ',foo my/path' turn to 'foo("my/path")'
2126 hence, things like ',foo my/path' turn to 'foo("my/path")'
2123 instead of syntax error.
2127 instead of syntax error.
2124
2128
2125
2129
2126 2006-01-14 Ville Vainio <vivainio@gmail.com>
2130 2006-01-14 Ville Vainio <vivainio@gmail.com>
2127
2131
2128 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
2132 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
2129 ipapi decorators for python 2.4 users, options() provides access to rc
2133 ipapi decorators for python 2.4 users, options() provides access to rc
2130 data.
2134 data.
2131
2135
2132 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
2136 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
2133 as path separators (even on Linux ;-). Space character after
2137 as path separators (even on Linux ;-). Space character after
2134 backslash (as yielded by tab completer) is still space;
2138 backslash (as yielded by tab completer) is still space;
2135 "%cd long\ name" works as expected.
2139 "%cd long\ name" works as expected.
2136
2140
2137 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
2141 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
2138 as "chain of command", with priority. API stays the same,
2142 as "chain of command", with priority. API stays the same,
2139 TryNext exception raised by a hook function signals that
2143 TryNext exception raised by a hook function signals that
2140 current hook failed and next hook should try handling it, as
2144 current hook failed and next hook should try handling it, as
2141 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
2145 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
2142 requested configurable display hook, which is now implemented.
2146 requested configurable display hook, which is now implemented.
2143
2147
2144 2006-01-13 Ville Vainio <vivainio@gmail.com>
2148 2006-01-13 Ville Vainio <vivainio@gmail.com>
2145
2149
2146 * IPython/platutils*.py: platform specific utility functions,
2150 * IPython/platutils*.py: platform specific utility functions,
2147 so far only set_term_title is implemented (change terminal
2151 so far only set_term_title is implemented (change terminal
2148 label in windowing systems). %cd now changes the title to
2152 label in windowing systems). %cd now changes the title to
2149 current dir.
2153 current dir.
2150
2154
2151 * IPython/Release.py: Added myself to "authors" list,
2155 * IPython/Release.py: Added myself to "authors" list,
2152 had to create new files.
2156 had to create new files.
2153
2157
2154 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
2158 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
2155 shell escape; not a known bug but had potential to be one in the
2159 shell escape; not a known bug but had potential to be one in the
2156 future.
2160 future.
2157
2161
2158 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
2162 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
2159 extension API for IPython! See the module for usage example. Fix
2163 extension API for IPython! See the module for usage example. Fix
2160 OInspect for docstring-less magic functions.
2164 OInspect for docstring-less magic functions.
2161
2165
2162
2166
2163 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2167 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2164
2168
2165 * IPython/iplib.py (raw_input): temporarily deactivate all
2169 * IPython/iplib.py (raw_input): temporarily deactivate all
2166 attempts at allowing pasting of code with autoindent on. It
2170 attempts at allowing pasting of code with autoindent on. It
2167 introduced bugs (reported by Prabhu) and I can't seem to find a
2171 introduced bugs (reported by Prabhu) and I can't seem to find a
2168 robust combination which works in all cases. Will have to revisit
2172 robust combination which works in all cases. Will have to revisit
2169 later.
2173 later.
2170
2174
2171 * IPython/genutils.py: remove isspace() function. We've dropped
2175 * IPython/genutils.py: remove isspace() function. We've dropped
2172 2.2 compatibility, so it's OK to use the string method.
2176 2.2 compatibility, so it's OK to use the string method.
2173
2177
2174 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2178 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2175
2179
2176 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
2180 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
2177 matching what NOT to autocall on, to include all python binary
2181 matching what NOT to autocall on, to include all python binary
2178 operators (including things like 'and', 'or', 'is' and 'in').
2182 operators (including things like 'and', 'or', 'is' and 'in').
2179 Prompted by a bug report on 'foo & bar', but I realized we had
2183 Prompted by a bug report on 'foo & bar', but I realized we had
2180 many more potential bug cases with other operators. The regexp is
2184 many more potential bug cases with other operators. The regexp is
2181 self.re_exclude_auto, it's fairly commented.
2185 self.re_exclude_auto, it's fairly commented.
2182
2186
2183 2006-01-12 Ville Vainio <vivainio@gmail.com>
2187 2006-01-12 Ville Vainio <vivainio@gmail.com>
2184
2188
2185 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
2189 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
2186 Prettified and hardened string/backslash quoting with ipsystem(),
2190 Prettified and hardened string/backslash quoting with ipsystem(),
2187 ipalias() and ipmagic(). Now even \ characters are passed to
2191 ipalias() and ipmagic(). Now even \ characters are passed to
2188 %magics, !shell escapes and aliases exactly as they are in the
2192 %magics, !shell escapes and aliases exactly as they are in the
2189 ipython command line. Should improve backslash experience,
2193 ipython command line. Should improve backslash experience,
2190 particularly in Windows (path delimiter for some commands that
2194 particularly in Windows (path delimiter for some commands that
2191 won't understand '/'), but Unix benefits as well (regexps). %cd
2195 won't understand '/'), but Unix benefits as well (regexps). %cd
2192 magic still doesn't support backslash path delimiters, though. Also
2196 magic still doesn't support backslash path delimiters, though. Also
2193 deleted all pretense of supporting multiline command strings in
2197 deleted all pretense of supporting multiline command strings in
2194 !system or %magic commands. Thanks to Jerry McRae for suggestions.
2198 !system or %magic commands. Thanks to Jerry McRae for suggestions.
2195
2199
2196 * doc/build_doc_instructions.txt added. Documentation on how to
2200 * doc/build_doc_instructions.txt added. Documentation on how to
2197 use doc/update_manual.py, added yesterday. Both files contributed
2201 use doc/update_manual.py, added yesterday. Both files contributed
2198 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
2202 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
2199 doc/*.sh for deprecation at a later date.
2203 doc/*.sh for deprecation at a later date.
2200
2204
2201 * /ipython.py Added ipython.py to root directory for
2205 * /ipython.py Added ipython.py to root directory for
2202 zero-installation (tar xzvf ipython.tgz; cd ipython; python
2206 zero-installation (tar xzvf ipython.tgz; cd ipython; python
2203 ipython.py) and development convenience (no need to keep doing
2207 ipython.py) and development convenience (no need to keep doing
2204 "setup.py install" between changes).
2208 "setup.py install" between changes).
2205
2209
2206 * Made ! and !! shell escapes work (again) in multiline expressions:
2210 * Made ! and !! shell escapes work (again) in multiline expressions:
2207 if 1:
2211 if 1:
2208 !ls
2212 !ls
2209 !!ls
2213 !!ls
2210
2214
2211 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2215 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2212
2216
2213 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
2217 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
2214 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
2218 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
2215 module in case-insensitive installation. Was causing crashes
2219 module in case-insensitive installation. Was causing crashes
2216 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
2220 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
2217
2221
2218 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
2222 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
2219 <marienz-AT-gentoo.org>, closes
2223 <marienz-AT-gentoo.org>, closes
2220 http://www.scipy.net/roundup/ipython/issue51.
2224 http://www.scipy.net/roundup/ipython/issue51.
2221
2225
2222 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2226 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2223
2227
2224 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
2228 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
2225 problem of excessive CPU usage under *nix and keyboard lag under
2229 problem of excessive CPU usage under *nix and keyboard lag under
2226 win32.
2230 win32.
2227
2231
2228 2006-01-10 *** Released version 0.7.0
2232 2006-01-10 *** Released version 0.7.0
2229
2233
2230 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2234 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2231
2235
2232 * IPython/Release.py (revision): tag version number to 0.7.0,
2236 * IPython/Release.py (revision): tag version number to 0.7.0,
2233 ready for release.
2237 ready for release.
2234
2238
2235 * IPython/Magic.py (magic_edit): Add print statement to %edit so
2239 * IPython/Magic.py (magic_edit): Add print statement to %edit so
2236 it informs the user of the name of the temp. file used. This can
2240 it informs the user of the name of the temp. file used. This can
2237 help if you decide later to reuse that same file, so you know
2241 help if you decide later to reuse that same file, so you know
2238 where to copy the info from.
2242 where to copy the info from.
2239
2243
2240 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2244 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2241
2245
2242 * setup_bdist_egg.py: little script to build an egg. Added
2246 * setup_bdist_egg.py: little script to build an egg. Added
2243 support in the release tools as well.
2247 support in the release tools as well.
2244
2248
2245 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
2249 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
2246
2250
2247 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
2251 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
2248 version selection (new -wxversion command line and ipythonrc
2252 version selection (new -wxversion command line and ipythonrc
2249 parameter). Patch contributed by Arnd Baecker
2253 parameter). Patch contributed by Arnd Baecker
2250 <arnd.baecker-AT-web.de>.
2254 <arnd.baecker-AT-web.de>.
2251
2255
2252 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2256 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2253 embedded instances, for variables defined at the interactive
2257 embedded instances, for variables defined at the interactive
2254 prompt of the embedded ipython. Reported by Arnd.
2258 prompt of the embedded ipython. Reported by Arnd.
2255
2259
2256 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
2260 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
2257 it can be used as a (stateful) toggle, or with a direct parameter.
2261 it can be used as a (stateful) toggle, or with a direct parameter.
2258
2262
2259 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
2263 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
2260 could be triggered in certain cases and cause the traceback
2264 could be triggered in certain cases and cause the traceback
2261 printer not to work.
2265 printer not to work.
2262
2266
2263 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
2267 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
2264
2268
2265 * IPython/iplib.py (_should_recompile): Small fix, closes
2269 * IPython/iplib.py (_should_recompile): Small fix, closes
2266 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
2270 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
2267
2271
2268 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
2272 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
2269
2273
2270 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
2274 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
2271 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
2275 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
2272 Moad for help with tracking it down.
2276 Moad for help with tracking it down.
2273
2277
2274 * IPython/iplib.py (handle_auto): fix autocall handling for
2278 * IPython/iplib.py (handle_auto): fix autocall handling for
2275 objects which support BOTH __getitem__ and __call__ (so that f [x]
2279 objects which support BOTH __getitem__ and __call__ (so that f [x]
2276 is left alone, instead of becoming f([x]) automatically).
2280 is left alone, instead of becoming f([x]) automatically).
2277
2281
2278 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
2282 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
2279 Ville's patch.
2283 Ville's patch.
2280
2284
2281 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
2285 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
2282
2286
2283 * IPython/iplib.py (handle_auto): changed autocall semantics to
2287 * IPython/iplib.py (handle_auto): changed autocall semantics to
2284 include 'smart' mode, where the autocall transformation is NOT
2288 include 'smart' mode, where the autocall transformation is NOT
2285 applied if there are no arguments on the line. This allows you to
2289 applied if there are no arguments on the line. This allows you to
2286 just type 'foo' if foo is a callable to see its internal form,
2290 just type 'foo' if foo is a callable to see its internal form,
2287 instead of having it called with no arguments (typically a
2291 instead of having it called with no arguments (typically a
2288 mistake). The old 'full' autocall still exists: for that, you
2292 mistake). The old 'full' autocall still exists: for that, you
2289 need to set the 'autocall' parameter to 2 in your ipythonrc file.
2293 need to set the 'autocall' parameter to 2 in your ipythonrc file.
2290
2294
2291 * IPython/completer.py (Completer.attr_matches): add
2295 * IPython/completer.py (Completer.attr_matches): add
2292 tab-completion support for Enthoughts' traits. After a report by
2296 tab-completion support for Enthoughts' traits. After a report by
2293 Arnd and a patch by Prabhu.
2297 Arnd and a patch by Prabhu.
2294
2298
2295 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
2299 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
2296
2300
2297 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
2301 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
2298 Schmolck's patch to fix inspect.getinnerframes().
2302 Schmolck's patch to fix inspect.getinnerframes().
2299
2303
2300 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
2304 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
2301 for embedded instances, regarding handling of namespaces and items
2305 for embedded instances, regarding handling of namespaces and items
2302 added to the __builtin__ one. Multiple embedded instances and
2306 added to the __builtin__ one. Multiple embedded instances and
2303 recursive embeddings should work better now (though I'm not sure
2307 recursive embeddings should work better now (though I'm not sure
2304 I've got all the corner cases fixed, that code is a bit of a brain
2308 I've got all the corner cases fixed, that code is a bit of a brain
2305 twister).
2309 twister).
2306
2310
2307 * IPython/Magic.py (magic_edit): added support to edit in-memory
2311 * IPython/Magic.py (magic_edit): added support to edit in-memory
2308 macros (automatically creates the necessary temp files). %edit
2312 macros (automatically creates the necessary temp files). %edit
2309 also doesn't return the file contents anymore, it's just noise.
2313 also doesn't return the file contents anymore, it's just noise.
2310
2314
2311 * IPython/completer.py (Completer.attr_matches): revert change to
2315 * IPython/completer.py (Completer.attr_matches): revert change to
2312 complete only on attributes listed in __all__. I realized it
2316 complete only on attributes listed in __all__. I realized it
2313 cripples the tab-completion system as a tool for exploring the
2317 cripples the tab-completion system as a tool for exploring the
2314 internals of unknown libraries (it renders any non-__all__
2318 internals of unknown libraries (it renders any non-__all__
2315 attribute off-limits). I got bit by this when trying to see
2319 attribute off-limits). I got bit by this when trying to see
2316 something inside the dis module.
2320 something inside the dis module.
2317
2321
2318 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2322 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2319
2323
2320 * IPython/iplib.py (InteractiveShell.__init__): add .meta
2324 * IPython/iplib.py (InteractiveShell.__init__): add .meta
2321 namespace for users and extension writers to hold data in. This
2325 namespace for users and extension writers to hold data in. This
2322 follows the discussion in
2326 follows the discussion in
2323 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
2327 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
2324
2328
2325 * IPython/completer.py (IPCompleter.complete): small patch to help
2329 * IPython/completer.py (IPCompleter.complete): small patch to help
2326 tab-completion under Emacs, after a suggestion by John Barnard
2330 tab-completion under Emacs, after a suggestion by John Barnard
2327 <barnarj-AT-ccf.org>.
2331 <barnarj-AT-ccf.org>.
2328
2332
2329 * IPython/Magic.py (Magic.extract_input_slices): added support for
2333 * IPython/Magic.py (Magic.extract_input_slices): added support for
2330 the slice notation in magics to use N-M to represent numbers N...M
2334 the slice notation in magics to use N-M to represent numbers N...M
2331 (closed endpoints). This is used by %macro and %save.
2335 (closed endpoints). This is used by %macro and %save.
2332
2336
2333 * IPython/completer.py (Completer.attr_matches): for modules which
2337 * IPython/completer.py (Completer.attr_matches): for modules which
2334 define __all__, complete only on those. After a patch by Jeffrey
2338 define __all__, complete only on those. After a patch by Jeffrey
2335 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
2339 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
2336 speed up this routine.
2340 speed up this routine.
2337
2341
2338 * IPython/Logger.py (Logger.log): fix a history handling bug. I
2342 * IPython/Logger.py (Logger.log): fix a history handling bug. I
2339 don't know if this is the end of it, but the behavior now is
2343 don't know if this is the end of it, but the behavior now is
2340 certainly much more correct. Note that coupled with macros,
2344 certainly much more correct. Note that coupled with macros,
2341 slightly surprising (at first) behavior may occur: a macro will in
2345 slightly surprising (at first) behavior may occur: a macro will in
2342 general expand to multiple lines of input, so upon exiting, the
2346 general expand to multiple lines of input, so upon exiting, the
2343 in/out counters will both be bumped by the corresponding amount
2347 in/out counters will both be bumped by the corresponding amount
2344 (as if the macro's contents had been typed interactively). Typing
2348 (as if the macro's contents had been typed interactively). Typing
2345 %hist will reveal the intermediate (silently processed) lines.
2349 %hist will reveal the intermediate (silently processed) lines.
2346
2350
2347 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
2351 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
2348 pickle to fail (%run was overwriting __main__ and not restoring
2352 pickle to fail (%run was overwriting __main__ and not restoring
2349 it, but pickle relies on __main__ to operate).
2353 it, but pickle relies on __main__ to operate).
2350
2354
2351 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
2355 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
2352 using properties, but forgot to make the main InteractiveShell
2356 using properties, but forgot to make the main InteractiveShell
2353 class a new-style class. Properties fail silently, and
2357 class a new-style class. Properties fail silently, and
2354 mysteriously, with old-style class (getters work, but
2358 mysteriously, with old-style class (getters work, but
2355 setters don't do anything).
2359 setters don't do anything).
2356
2360
2357 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
2361 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
2358
2362
2359 * IPython/Magic.py (magic_history): fix history reporting bug (I
2363 * IPython/Magic.py (magic_history): fix history reporting bug (I
2360 know some nasties are still there, I just can't seem to find a
2364 know some nasties are still there, I just can't seem to find a
2361 reproducible test case to track them down; the input history is
2365 reproducible test case to track them down; the input history is
2362 falling out of sync...)
2366 falling out of sync...)
2363
2367
2364 * IPython/iplib.py (handle_shell_escape): fix bug where both
2368 * IPython/iplib.py (handle_shell_escape): fix bug where both
2365 aliases and system accesses where broken for indented code (such
2369 aliases and system accesses where broken for indented code (such
2366 as loops).
2370 as loops).
2367
2371
2368 * IPython/genutils.py (shell): fix small but critical bug for
2372 * IPython/genutils.py (shell): fix small but critical bug for
2369 win32 system access.
2373 win32 system access.
2370
2374
2371 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2375 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2372
2376
2373 * IPython/iplib.py (showtraceback): remove use of the
2377 * IPython/iplib.py (showtraceback): remove use of the
2374 sys.last_{type/value/traceback} structures, which are non
2378 sys.last_{type/value/traceback} structures, which are non
2375 thread-safe.
2379 thread-safe.
2376 (_prefilter): change control flow to ensure that we NEVER
2380 (_prefilter): change control flow to ensure that we NEVER
2377 introspect objects when autocall is off. This will guarantee that
2381 introspect objects when autocall is off. This will guarantee that
2378 having an input line of the form 'x.y', where access to attribute
2382 having an input line of the form 'x.y', where access to attribute
2379 'y' has side effects, doesn't trigger the side effect TWICE. It
2383 'y' has side effects, doesn't trigger the side effect TWICE. It
2380 is important to note that, with autocall on, these side effects
2384 is important to note that, with autocall on, these side effects
2381 can still happen.
2385 can still happen.
2382 (ipsystem): new builtin, to complete the ip{magic/alias/system}
2386 (ipsystem): new builtin, to complete the ip{magic/alias/system}
2383 trio. IPython offers these three kinds of special calls which are
2387 trio. IPython offers these three kinds of special calls which are
2384 not python code, and it's a good thing to have their call method
2388 not python code, and it's a good thing to have their call method
2385 be accessible as pure python functions (not just special syntax at
2389 be accessible as pure python functions (not just special syntax at
2386 the command line). It gives us a better internal implementation
2390 the command line). It gives us a better internal implementation
2387 structure, as well as exposing these for user scripting more
2391 structure, as well as exposing these for user scripting more
2388 cleanly.
2392 cleanly.
2389
2393
2390 * IPython/macro.py (Macro.__init__): moved macros to a standalone
2394 * IPython/macro.py (Macro.__init__): moved macros to a standalone
2391 file. Now that they'll be more likely to be used with the
2395 file. Now that they'll be more likely to be used with the
2392 persistance system (%store), I want to make sure their module path
2396 persistance system (%store), I want to make sure their module path
2393 doesn't change in the future, so that we don't break things for
2397 doesn't change in the future, so that we don't break things for
2394 users' persisted data.
2398 users' persisted data.
2395
2399
2396 * IPython/iplib.py (autoindent_update): move indentation
2400 * IPython/iplib.py (autoindent_update): move indentation
2397 management into the _text_ processing loop, not the keyboard
2401 management into the _text_ processing loop, not the keyboard
2398 interactive one. This is necessary to correctly process non-typed
2402 interactive one. This is necessary to correctly process non-typed
2399 multiline input (such as macros).
2403 multiline input (such as macros).
2400
2404
2401 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
2405 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
2402 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
2406 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
2403 which was producing problems in the resulting manual.
2407 which was producing problems in the resulting manual.
2404 (magic_whos): improve reporting of instances (show their class,
2408 (magic_whos): improve reporting of instances (show their class,
2405 instead of simply printing 'instance' which isn't terribly
2409 instead of simply printing 'instance' which isn't terribly
2406 informative).
2410 informative).
2407
2411
2408 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
2412 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
2409 (minor mods) to support network shares under win32.
2413 (minor mods) to support network shares under win32.
2410
2414
2411 * IPython/winconsole.py (get_console_size): add new winconsole
2415 * IPython/winconsole.py (get_console_size): add new winconsole
2412 module and fixes to page_dumb() to improve its behavior under
2416 module and fixes to page_dumb() to improve its behavior under
2413 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
2417 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
2414
2418
2415 * IPython/Magic.py (Macro): simplified Macro class to just
2419 * IPython/Magic.py (Macro): simplified Macro class to just
2416 subclass list. We've had only 2.2 compatibility for a very long
2420 subclass list. We've had only 2.2 compatibility for a very long
2417 time, yet I was still avoiding subclassing the builtin types. No
2421 time, yet I was still avoiding subclassing the builtin types. No
2418 more (I'm also starting to use properties, though I won't shift to
2422 more (I'm also starting to use properties, though I won't shift to
2419 2.3-specific features quite yet).
2423 2.3-specific features quite yet).
2420 (magic_store): added Ville's patch for lightweight variable
2424 (magic_store): added Ville's patch for lightweight variable
2421 persistence, after a request on the user list by Matt Wilkie
2425 persistence, after a request on the user list by Matt Wilkie
2422 <maphew-AT-gmail.com>. The new %store magic's docstring has full
2426 <maphew-AT-gmail.com>. The new %store magic's docstring has full
2423 details.
2427 details.
2424
2428
2425 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2429 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2426 changed the default logfile name from 'ipython.log' to
2430 changed the default logfile name from 'ipython.log' to
2427 'ipython_log.py'. These logs are real python files, and now that
2431 'ipython_log.py'. These logs are real python files, and now that
2428 we have much better multiline support, people are more likely to
2432 we have much better multiline support, people are more likely to
2429 want to use them as such. Might as well name them correctly.
2433 want to use them as such. Might as well name them correctly.
2430
2434
2431 * IPython/Magic.py: substantial cleanup. While we can't stop
2435 * IPython/Magic.py: substantial cleanup. While we can't stop
2432 using magics as mixins, due to the existing customizations 'out
2436 using magics as mixins, due to the existing customizations 'out
2433 there' which rely on the mixin naming conventions, at least I
2437 there' which rely on the mixin naming conventions, at least I
2434 cleaned out all cross-class name usage. So once we are OK with
2438 cleaned out all cross-class name usage. So once we are OK with
2435 breaking compatibility, the two systems can be separated.
2439 breaking compatibility, the two systems can be separated.
2436
2440
2437 * IPython/Logger.py: major cleanup. This one is NOT a mixin
2441 * IPython/Logger.py: major cleanup. This one is NOT a mixin
2438 anymore, and the class is a fair bit less hideous as well. New
2442 anymore, and the class is a fair bit less hideous as well. New
2439 features were also introduced: timestamping of input, and logging
2443 features were also introduced: timestamping of input, and logging
2440 of output results. These are user-visible with the -t and -o
2444 of output results. These are user-visible with the -t and -o
2441 options to %logstart. Closes
2445 options to %logstart. Closes
2442 http://www.scipy.net/roundup/ipython/issue11 and a request by
2446 http://www.scipy.net/roundup/ipython/issue11 and a request by
2443 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
2447 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
2444
2448
2445 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2449 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2446
2450
2447 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
2451 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
2448 better handle backslashes in paths. See the thread 'More Windows
2452 better handle backslashes in paths. See the thread 'More Windows
2449 questions part 2 - \/ characters revisited' on the iypthon user
2453 questions part 2 - \/ characters revisited' on the iypthon user
2450 list:
2454 list:
2451 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
2455 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
2452
2456
2453 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
2457 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
2454
2458
2455 (InteractiveShell.__init__): change threaded shells to not use the
2459 (InteractiveShell.__init__): change threaded shells to not use the
2456 ipython crash handler. This was causing more problems than not,
2460 ipython crash handler. This was causing more problems than not,
2457 as exceptions in the main thread (GUI code, typically) would
2461 as exceptions in the main thread (GUI code, typically) would
2458 always show up as a 'crash', when they really weren't.
2462 always show up as a 'crash', when they really weren't.
2459
2463
2460 The colors and exception mode commands (%colors/%xmode) have been
2464 The colors and exception mode commands (%colors/%xmode) have been
2461 synchronized to also take this into account, so users can get
2465 synchronized to also take this into account, so users can get
2462 verbose exceptions for their threaded code as well. I also added
2466 verbose exceptions for their threaded code as well. I also added
2463 support for activating pdb inside this exception handler as well,
2467 support for activating pdb inside this exception handler as well,
2464 so now GUI authors can use IPython's enhanced pdb at runtime.
2468 so now GUI authors can use IPython's enhanced pdb at runtime.
2465
2469
2466 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
2470 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
2467 true by default, and add it to the shipped ipythonrc file. Since
2471 true by default, and add it to the shipped ipythonrc file. Since
2468 this asks the user before proceeding, I think it's OK to make it
2472 this asks the user before proceeding, I think it's OK to make it
2469 true by default.
2473 true by default.
2470
2474
2471 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
2475 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
2472 of the previous special-casing of input in the eval loop. I think
2476 of the previous special-casing of input in the eval loop. I think
2473 this is cleaner, as they really are commands and shouldn't have
2477 this is cleaner, as they really are commands and shouldn't have
2474 a special role in the middle of the core code.
2478 a special role in the middle of the core code.
2475
2479
2476 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2480 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2477
2481
2478 * IPython/iplib.py (edit_syntax_error): added support for
2482 * IPython/iplib.py (edit_syntax_error): added support for
2479 automatically reopening the editor if the file had a syntax error
2483 automatically reopening the editor if the file had a syntax error
2480 in it. Thanks to scottt who provided the patch at:
2484 in it. Thanks to scottt who provided the patch at:
2481 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
2485 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
2482 version committed).
2486 version committed).
2483
2487
2484 * IPython/iplib.py (handle_normal): add suport for multi-line
2488 * IPython/iplib.py (handle_normal): add suport for multi-line
2485 input with emtpy lines. This fixes
2489 input with emtpy lines. This fixes
2486 http://www.scipy.net/roundup/ipython/issue43 and a similar
2490 http://www.scipy.net/roundup/ipython/issue43 and a similar
2487 discussion on the user list.
2491 discussion on the user list.
2488
2492
2489 WARNING: a behavior change is necessarily introduced to support
2493 WARNING: a behavior change is necessarily introduced to support
2490 blank lines: now a single blank line with whitespace does NOT
2494 blank lines: now a single blank line with whitespace does NOT
2491 break the input loop, which means that when autoindent is on, by
2495 break the input loop, which means that when autoindent is on, by
2492 default hitting return on the next (indented) line does NOT exit.
2496 default hitting return on the next (indented) line does NOT exit.
2493
2497
2494 Instead, to exit a multiline input you can either have:
2498 Instead, to exit a multiline input you can either have:
2495
2499
2496 - TWO whitespace lines (just hit return again), or
2500 - TWO whitespace lines (just hit return again), or
2497 - a single whitespace line of a different length than provided
2501 - a single whitespace line of a different length than provided
2498 by the autoindent (add or remove a space).
2502 by the autoindent (add or remove a space).
2499
2503
2500 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
2504 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
2501 module to better organize all readline-related functionality.
2505 module to better organize all readline-related functionality.
2502 I've deleted FlexCompleter and put all completion clases here.
2506 I've deleted FlexCompleter and put all completion clases here.
2503
2507
2504 * IPython/iplib.py (raw_input): improve indentation management.
2508 * IPython/iplib.py (raw_input): improve indentation management.
2505 It is now possible to paste indented code with autoindent on, and
2509 It is now possible to paste indented code with autoindent on, and
2506 the code is interpreted correctly (though it still looks bad on
2510 the code is interpreted correctly (though it still looks bad on
2507 screen, due to the line-oriented nature of ipython).
2511 screen, due to the line-oriented nature of ipython).
2508 (MagicCompleter.complete): change behavior so that a TAB key on an
2512 (MagicCompleter.complete): change behavior so that a TAB key on an
2509 otherwise empty line actually inserts a tab, instead of completing
2513 otherwise empty line actually inserts a tab, instead of completing
2510 on the entire global namespace. This makes it easier to use the
2514 on the entire global namespace. This makes it easier to use the
2511 TAB key for indentation. After a request by Hans Meine
2515 TAB key for indentation. After a request by Hans Meine
2512 <hans_meine-AT-gmx.net>
2516 <hans_meine-AT-gmx.net>
2513 (_prefilter): add support so that typing plain 'exit' or 'quit'
2517 (_prefilter): add support so that typing plain 'exit' or 'quit'
2514 does a sensible thing. Originally I tried to deviate as little as
2518 does a sensible thing. Originally I tried to deviate as little as
2515 possible from the default python behavior, but even that one may
2519 possible from the default python behavior, but even that one may
2516 change in this direction (thread on python-dev to that effect).
2520 change in this direction (thread on python-dev to that effect).
2517 Regardless, ipython should do the right thing even if CPython's
2521 Regardless, ipython should do the right thing even if CPython's
2518 '>>>' prompt doesn't.
2522 '>>>' prompt doesn't.
2519 (InteractiveShell): removed subclassing code.InteractiveConsole
2523 (InteractiveShell): removed subclassing code.InteractiveConsole
2520 class. By now we'd overridden just about all of its methods: I've
2524 class. By now we'd overridden just about all of its methods: I've
2521 copied the remaining two over, and now ipython is a standalone
2525 copied the remaining two over, and now ipython is a standalone
2522 class. This will provide a clearer picture for the chainsaw
2526 class. This will provide a clearer picture for the chainsaw
2523 branch refactoring.
2527 branch refactoring.
2524
2528
2525 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2529 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2526
2530
2527 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2531 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2528 failures for objects which break when dir() is called on them.
2532 failures for objects which break when dir() is called on them.
2529
2533
2530 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2534 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2531 distinct local and global namespaces in the completer API. This
2535 distinct local and global namespaces in the completer API. This
2532 change allows us to properly handle completion with distinct
2536 change allows us to properly handle completion with distinct
2533 scopes, including in embedded instances (this had never really
2537 scopes, including in embedded instances (this had never really
2534 worked correctly).
2538 worked correctly).
2535
2539
2536 Note: this introduces a change in the constructor for
2540 Note: this introduces a change in the constructor for
2537 MagicCompleter, as a new global_namespace parameter is now the
2541 MagicCompleter, as a new global_namespace parameter is now the
2538 second argument (the others were bumped one position).
2542 second argument (the others were bumped one position).
2539
2543
2540 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2544 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2541
2545
2542 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2546 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2543 embedded instances (which can be done now thanks to Vivian's
2547 embedded instances (which can be done now thanks to Vivian's
2544 frame-handling fixes for pdb).
2548 frame-handling fixes for pdb).
2545 (InteractiveShell.__init__): Fix namespace handling problem in
2549 (InteractiveShell.__init__): Fix namespace handling problem in
2546 embedded instances. We were overwriting __main__ unconditionally,
2550 embedded instances. We were overwriting __main__ unconditionally,
2547 and this should only be done for 'full' (non-embedded) IPython;
2551 and this should only be done for 'full' (non-embedded) IPython;
2548 embedded instances must respect the caller's __main__. Thanks to
2552 embedded instances must respect the caller's __main__. Thanks to
2549 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2553 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2550
2554
2551 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2555 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2552
2556
2553 * setup.py: added download_url to setup(). This registers the
2557 * setup.py: added download_url to setup(). This registers the
2554 download address at PyPI, which is not only useful to humans
2558 download address at PyPI, which is not only useful to humans
2555 browsing the site, but is also picked up by setuptools (the Eggs
2559 browsing the site, but is also picked up by setuptools (the Eggs
2556 machinery). Thanks to Ville and R. Kern for the info/discussion
2560 machinery). Thanks to Ville and R. Kern for the info/discussion
2557 on this.
2561 on this.
2558
2562
2559 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2563 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2560
2564
2561 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2565 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2562 This brings a lot of nice functionality to the pdb mode, which now
2566 This brings a lot of nice functionality to the pdb mode, which now
2563 has tab-completion, syntax highlighting, and better stack handling
2567 has tab-completion, syntax highlighting, and better stack handling
2564 than before. Many thanks to Vivian De Smedt
2568 than before. Many thanks to Vivian De Smedt
2565 <vivian-AT-vdesmedt.com> for the original patches.
2569 <vivian-AT-vdesmedt.com> for the original patches.
2566
2570
2567 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2571 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2568
2572
2569 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2573 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2570 sequence to consistently accept the banner argument. The
2574 sequence to consistently accept the banner argument. The
2571 inconsistency was tripping SAGE, thanks to Gary Zablackis
2575 inconsistency was tripping SAGE, thanks to Gary Zablackis
2572 <gzabl-AT-yahoo.com> for the report.
2576 <gzabl-AT-yahoo.com> for the report.
2573
2577
2574 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2578 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2575
2579
2576 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2580 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2577 Fix bug where a naked 'alias' call in the ipythonrc file would
2581 Fix bug where a naked 'alias' call in the ipythonrc file would
2578 cause a crash. Bug reported by Jorgen Stenarson.
2582 cause a crash. Bug reported by Jorgen Stenarson.
2579
2583
2580 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2584 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2581
2585
2582 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2586 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2583 startup time.
2587 startup time.
2584
2588
2585 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2589 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2586 instances had introduced a bug with globals in normal code. Now
2590 instances had introduced a bug with globals in normal code. Now
2587 it's working in all cases.
2591 it's working in all cases.
2588
2592
2589 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2593 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2590 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2594 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2591 has been introduced to set the default case sensitivity of the
2595 has been introduced to set the default case sensitivity of the
2592 searches. Users can still select either mode at runtime on a
2596 searches. Users can still select either mode at runtime on a
2593 per-search basis.
2597 per-search basis.
2594
2598
2595 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2599 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2596
2600
2597 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2601 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2598 attributes in wildcard searches for subclasses. Modified version
2602 attributes in wildcard searches for subclasses. Modified version
2599 of a patch by Jorgen.
2603 of a patch by Jorgen.
2600
2604
2601 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2605 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2602
2606
2603 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2607 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2604 embedded instances. I added a user_global_ns attribute to the
2608 embedded instances. I added a user_global_ns attribute to the
2605 InteractiveShell class to handle this.
2609 InteractiveShell class to handle this.
2606
2610
2607 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2611 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2608
2612
2609 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2613 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2610 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2614 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2611 (reported under win32, but may happen also in other platforms).
2615 (reported under win32, but may happen also in other platforms).
2612 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2616 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2613
2617
2614 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2618 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2615
2619
2616 * IPython/Magic.py (magic_psearch): new support for wildcard
2620 * IPython/Magic.py (magic_psearch): new support for wildcard
2617 patterns. Now, typing ?a*b will list all names which begin with a
2621 patterns. Now, typing ?a*b will list all names which begin with a
2618 and end in b, for example. The %psearch magic has full
2622 and end in b, for example. The %psearch magic has full
2619 docstrings. Many thanks to JΓΆrgen Stenarson
2623 docstrings. Many thanks to JΓΆrgen Stenarson
2620 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2624 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2621 implementing this functionality.
2625 implementing this functionality.
2622
2626
2623 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2627 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2624
2628
2625 * Manual: fixed long-standing annoyance of double-dashes (as in
2629 * Manual: fixed long-standing annoyance of double-dashes (as in
2626 --prefix=~, for example) being stripped in the HTML version. This
2630 --prefix=~, for example) being stripped in the HTML version. This
2627 is a latex2html bug, but a workaround was provided. Many thanks
2631 is a latex2html bug, but a workaround was provided. Many thanks
2628 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2632 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2629 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2633 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2630 rolling. This seemingly small issue had tripped a number of users
2634 rolling. This seemingly small issue had tripped a number of users
2631 when first installing, so I'm glad to see it gone.
2635 when first installing, so I'm glad to see it gone.
2632
2636
2633 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2637 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2634
2638
2635 * IPython/Extensions/numeric_formats.py: fix missing import,
2639 * IPython/Extensions/numeric_formats.py: fix missing import,
2636 reported by Stephen Walton.
2640 reported by Stephen Walton.
2637
2641
2638 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2642 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2639
2643
2640 * IPython/demo.py: finish demo module, fully documented now.
2644 * IPython/demo.py: finish demo module, fully documented now.
2641
2645
2642 * IPython/genutils.py (file_read): simple little utility to read a
2646 * IPython/genutils.py (file_read): simple little utility to read a
2643 file and ensure it's closed afterwards.
2647 file and ensure it's closed afterwards.
2644
2648
2645 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2649 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2646
2650
2647 * IPython/demo.py (Demo.__init__): added support for individually
2651 * IPython/demo.py (Demo.__init__): added support for individually
2648 tagging blocks for automatic execution.
2652 tagging blocks for automatic execution.
2649
2653
2650 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2654 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2651 syntax-highlighted python sources, requested by John.
2655 syntax-highlighted python sources, requested by John.
2652
2656
2653 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2657 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2654
2658
2655 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2659 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2656 finishing.
2660 finishing.
2657
2661
2658 * IPython/genutils.py (shlex_split): moved from Magic to here,
2662 * IPython/genutils.py (shlex_split): moved from Magic to here,
2659 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2663 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2660
2664
2661 * IPython/demo.py (Demo.__init__): added support for silent
2665 * IPython/demo.py (Demo.__init__): added support for silent
2662 blocks, improved marks as regexps, docstrings written.
2666 blocks, improved marks as regexps, docstrings written.
2663 (Demo.__init__): better docstring, added support for sys.argv.
2667 (Demo.__init__): better docstring, added support for sys.argv.
2664
2668
2665 * IPython/genutils.py (marquee): little utility used by the demo
2669 * IPython/genutils.py (marquee): little utility used by the demo
2666 code, handy in general.
2670 code, handy in general.
2667
2671
2668 * IPython/demo.py (Demo.__init__): new class for interactive
2672 * IPython/demo.py (Demo.__init__): new class for interactive
2669 demos. Not documented yet, I just wrote it in a hurry for
2673 demos. Not documented yet, I just wrote it in a hurry for
2670 scipy'05. Will docstring later.
2674 scipy'05. Will docstring later.
2671
2675
2672 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2676 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2673
2677
2674 * IPython/Shell.py (sigint_handler): Drastic simplification which
2678 * IPython/Shell.py (sigint_handler): Drastic simplification which
2675 also seems to make Ctrl-C work correctly across threads! This is
2679 also seems to make Ctrl-C work correctly across threads! This is
2676 so simple, that I can't beleive I'd missed it before. Needs more
2680 so simple, that I can't beleive I'd missed it before. Needs more
2677 testing, though.
2681 testing, though.
2678 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2682 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2679 like this before...
2683 like this before...
2680
2684
2681 * IPython/genutils.py (get_home_dir): add protection against
2685 * IPython/genutils.py (get_home_dir): add protection against
2682 non-dirs in win32 registry.
2686 non-dirs in win32 registry.
2683
2687
2684 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2688 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2685 bug where dict was mutated while iterating (pysh crash).
2689 bug where dict was mutated while iterating (pysh crash).
2686
2690
2687 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2691 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2688
2692
2689 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2693 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2690 spurious newlines added by this routine. After a report by
2694 spurious newlines added by this routine. After a report by
2691 F. Mantegazza.
2695 F. Mantegazza.
2692
2696
2693 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2697 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2694
2698
2695 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2699 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2696 calls. These were a leftover from the GTK 1.x days, and can cause
2700 calls. These were a leftover from the GTK 1.x days, and can cause
2697 problems in certain cases (after a report by John Hunter).
2701 problems in certain cases (after a report by John Hunter).
2698
2702
2699 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2703 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2700 os.getcwd() fails at init time. Thanks to patch from David Remahl
2704 os.getcwd() fails at init time. Thanks to patch from David Remahl
2701 <chmod007-AT-mac.com>.
2705 <chmod007-AT-mac.com>.
2702 (InteractiveShell.__init__): prevent certain special magics from
2706 (InteractiveShell.__init__): prevent certain special magics from
2703 being shadowed by aliases. Closes
2707 being shadowed by aliases. Closes
2704 http://www.scipy.net/roundup/ipython/issue41.
2708 http://www.scipy.net/roundup/ipython/issue41.
2705
2709
2706 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2710 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2707
2711
2708 * IPython/iplib.py (InteractiveShell.complete): Added new
2712 * IPython/iplib.py (InteractiveShell.complete): Added new
2709 top-level completion method to expose the completion mechanism
2713 top-level completion method to expose the completion mechanism
2710 beyond readline-based environments.
2714 beyond readline-based environments.
2711
2715
2712 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2716 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2713
2717
2714 * tools/ipsvnc (svnversion): fix svnversion capture.
2718 * tools/ipsvnc (svnversion): fix svnversion capture.
2715
2719
2716 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2720 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2717 attribute to self, which was missing. Before, it was set by a
2721 attribute to self, which was missing. Before, it was set by a
2718 routine which in certain cases wasn't being called, so the
2722 routine which in certain cases wasn't being called, so the
2719 instance could end up missing the attribute. This caused a crash.
2723 instance could end up missing the attribute. This caused a crash.
2720 Closes http://www.scipy.net/roundup/ipython/issue40.
2724 Closes http://www.scipy.net/roundup/ipython/issue40.
2721
2725
2722 2005-08-16 Fernando Perez <fperez@colorado.edu>
2726 2005-08-16 Fernando Perez <fperez@colorado.edu>
2723
2727
2724 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2728 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2725 contains non-string attribute. Closes
2729 contains non-string attribute. Closes
2726 http://www.scipy.net/roundup/ipython/issue38.
2730 http://www.scipy.net/roundup/ipython/issue38.
2727
2731
2728 2005-08-14 Fernando Perez <fperez@colorado.edu>
2732 2005-08-14 Fernando Perez <fperez@colorado.edu>
2729
2733
2730 * tools/ipsvnc: Minor improvements, to add changeset info.
2734 * tools/ipsvnc: Minor improvements, to add changeset info.
2731
2735
2732 2005-08-12 Fernando Perez <fperez@colorado.edu>
2736 2005-08-12 Fernando Perez <fperez@colorado.edu>
2733
2737
2734 * IPython/iplib.py (runsource): remove self.code_to_run_src
2738 * IPython/iplib.py (runsource): remove self.code_to_run_src
2735 attribute. I realized this is nothing more than
2739 attribute. I realized this is nothing more than
2736 '\n'.join(self.buffer), and having the same data in two different
2740 '\n'.join(self.buffer), and having the same data in two different
2737 places is just asking for synchronization bugs. This may impact
2741 places is just asking for synchronization bugs. This may impact
2738 people who have custom exception handlers, so I need to warn
2742 people who have custom exception handlers, so I need to warn
2739 ipython-dev about it (F. Mantegazza may use them).
2743 ipython-dev about it (F. Mantegazza may use them).
2740
2744
2741 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2745 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2742
2746
2743 * IPython/genutils.py: fix 2.2 compatibility (generators)
2747 * IPython/genutils.py: fix 2.2 compatibility (generators)
2744
2748
2745 2005-07-18 Fernando Perez <fperez@colorado.edu>
2749 2005-07-18 Fernando Perez <fperez@colorado.edu>
2746
2750
2747 * IPython/genutils.py (get_home_dir): fix to help users with
2751 * IPython/genutils.py (get_home_dir): fix to help users with
2748 invalid $HOME under win32.
2752 invalid $HOME under win32.
2749
2753
2750 2005-07-17 Fernando Perez <fperez@colorado.edu>
2754 2005-07-17 Fernando Perez <fperez@colorado.edu>
2751
2755
2752 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2756 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2753 some old hacks and clean up a bit other routines; code should be
2757 some old hacks and clean up a bit other routines; code should be
2754 simpler and a bit faster.
2758 simpler and a bit faster.
2755
2759
2756 * IPython/iplib.py (interact): removed some last-resort attempts
2760 * IPython/iplib.py (interact): removed some last-resort attempts
2757 to survive broken stdout/stderr. That code was only making it
2761 to survive broken stdout/stderr. That code was only making it
2758 harder to abstract out the i/o (necessary for gui integration),
2762 harder to abstract out the i/o (necessary for gui integration),
2759 and the crashes it could prevent were extremely rare in practice
2763 and the crashes it could prevent were extremely rare in practice
2760 (besides being fully user-induced in a pretty violent manner).
2764 (besides being fully user-induced in a pretty violent manner).
2761
2765
2762 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2766 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2763 Nothing major yet, but the code is simpler to read; this should
2767 Nothing major yet, but the code is simpler to read; this should
2764 make it easier to do more serious modifications in the future.
2768 make it easier to do more serious modifications in the future.
2765
2769
2766 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2770 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2767 which broke in .15 (thanks to a report by Ville).
2771 which broke in .15 (thanks to a report by Ville).
2768
2772
2769 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2773 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2770 be quite correct, I know next to nothing about unicode). This
2774 be quite correct, I know next to nothing about unicode). This
2771 will allow unicode strings to be used in prompts, amongst other
2775 will allow unicode strings to be used in prompts, amongst other
2772 cases. It also will prevent ipython from crashing when unicode
2776 cases. It also will prevent ipython from crashing when unicode
2773 shows up unexpectedly in many places. If ascii encoding fails, we
2777 shows up unexpectedly in many places. If ascii encoding fails, we
2774 assume utf_8. Currently the encoding is not a user-visible
2778 assume utf_8. Currently the encoding is not a user-visible
2775 setting, though it could be made so if there is demand for it.
2779 setting, though it could be made so if there is demand for it.
2776
2780
2777 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2781 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2778
2782
2779 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2783 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2780
2784
2781 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2785 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2782
2786
2783 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2787 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2784 code can work transparently for 2.2/2.3.
2788 code can work transparently for 2.2/2.3.
2785
2789
2786 2005-07-16 Fernando Perez <fperez@colorado.edu>
2790 2005-07-16 Fernando Perez <fperez@colorado.edu>
2787
2791
2788 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2792 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2789 out of the color scheme table used for coloring exception
2793 out of the color scheme table used for coloring exception
2790 tracebacks. This allows user code to add new schemes at runtime.
2794 tracebacks. This allows user code to add new schemes at runtime.
2791 This is a minimally modified version of the patch at
2795 This is a minimally modified version of the patch at
2792 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2796 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2793 for the contribution.
2797 for the contribution.
2794
2798
2795 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2799 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2796 slightly modified version of the patch in
2800 slightly modified version of the patch in
2797 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2801 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2798 to remove the previous try/except solution (which was costlier).
2802 to remove the previous try/except solution (which was costlier).
2799 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2803 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2800
2804
2801 2005-06-08 Fernando Perez <fperez@colorado.edu>
2805 2005-06-08 Fernando Perez <fperez@colorado.edu>
2802
2806
2803 * IPython/iplib.py (write/write_err): Add methods to abstract all
2807 * IPython/iplib.py (write/write_err): Add methods to abstract all
2804 I/O a bit more.
2808 I/O a bit more.
2805
2809
2806 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2810 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2807 warning, reported by Aric Hagberg, fix by JD Hunter.
2811 warning, reported by Aric Hagberg, fix by JD Hunter.
2808
2812
2809 2005-06-02 *** Released version 0.6.15
2813 2005-06-02 *** Released version 0.6.15
2810
2814
2811 2005-06-01 Fernando Perez <fperez@colorado.edu>
2815 2005-06-01 Fernando Perez <fperez@colorado.edu>
2812
2816
2813 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2817 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2814 tab-completion of filenames within open-quoted strings. Note that
2818 tab-completion of filenames within open-quoted strings. Note that
2815 this requires that in ~/.ipython/ipythonrc, users change the
2819 this requires that in ~/.ipython/ipythonrc, users change the
2816 readline delimiters configuration to read:
2820 readline delimiters configuration to read:
2817
2821
2818 readline_remove_delims -/~
2822 readline_remove_delims -/~
2819
2823
2820
2824
2821 2005-05-31 *** Released version 0.6.14
2825 2005-05-31 *** Released version 0.6.14
2822
2826
2823 2005-05-29 Fernando Perez <fperez@colorado.edu>
2827 2005-05-29 Fernando Perez <fperez@colorado.edu>
2824
2828
2825 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2829 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2826 with files not on the filesystem. Reported by Eliyahu Sandler
2830 with files not on the filesystem. Reported by Eliyahu Sandler
2827 <eli@gondolin.net>
2831 <eli@gondolin.net>
2828
2832
2829 2005-05-22 Fernando Perez <fperez@colorado.edu>
2833 2005-05-22 Fernando Perez <fperez@colorado.edu>
2830
2834
2831 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2835 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2832 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2836 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2833
2837
2834 2005-05-19 Fernando Perez <fperez@colorado.edu>
2838 2005-05-19 Fernando Perez <fperez@colorado.edu>
2835
2839
2836 * IPython/iplib.py (safe_execfile): close a file which could be
2840 * IPython/iplib.py (safe_execfile): close a file which could be
2837 left open (causing problems in win32, which locks open files).
2841 left open (causing problems in win32, which locks open files).
2838 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2842 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2839
2843
2840 2005-05-18 Fernando Perez <fperez@colorado.edu>
2844 2005-05-18 Fernando Perez <fperez@colorado.edu>
2841
2845
2842 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2846 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2843 keyword arguments correctly to safe_execfile().
2847 keyword arguments correctly to safe_execfile().
2844
2848
2845 2005-05-13 Fernando Perez <fperez@colorado.edu>
2849 2005-05-13 Fernando Perez <fperez@colorado.edu>
2846
2850
2847 * ipython.1: Added info about Qt to manpage, and threads warning
2851 * ipython.1: Added info about Qt to manpage, and threads warning
2848 to usage page (invoked with --help).
2852 to usage page (invoked with --help).
2849
2853
2850 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2854 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2851 new matcher (it goes at the end of the priority list) to do
2855 new matcher (it goes at the end of the priority list) to do
2852 tab-completion on named function arguments. Submitted by George
2856 tab-completion on named function arguments. Submitted by George
2853 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2857 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2854 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2858 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2855 for more details.
2859 for more details.
2856
2860
2857 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2861 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2858 SystemExit exceptions in the script being run. Thanks to a report
2862 SystemExit exceptions in the script being run. Thanks to a report
2859 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2863 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2860 producing very annoying behavior when running unit tests.
2864 producing very annoying behavior when running unit tests.
2861
2865
2862 2005-05-12 Fernando Perez <fperez@colorado.edu>
2866 2005-05-12 Fernando Perez <fperez@colorado.edu>
2863
2867
2864 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2868 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2865 which I'd broken (again) due to a changed regexp. In the process,
2869 which I'd broken (again) due to a changed regexp. In the process,
2866 added ';' as an escape to auto-quote the whole line without
2870 added ';' as an escape to auto-quote the whole line without
2867 splitting its arguments. Thanks to a report by Jerry McRae
2871 splitting its arguments. Thanks to a report by Jerry McRae
2868 <qrs0xyc02-AT-sneakemail.com>.
2872 <qrs0xyc02-AT-sneakemail.com>.
2869
2873
2870 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2874 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2871 possible crashes caused by a TokenError. Reported by Ed Schofield
2875 possible crashes caused by a TokenError. Reported by Ed Schofield
2872 <schofield-AT-ftw.at>.
2876 <schofield-AT-ftw.at>.
2873
2877
2874 2005-05-06 Fernando Perez <fperez@colorado.edu>
2878 2005-05-06 Fernando Perez <fperez@colorado.edu>
2875
2879
2876 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2880 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2877
2881
2878 2005-04-29 Fernando Perez <fperez@colorado.edu>
2882 2005-04-29 Fernando Perez <fperez@colorado.edu>
2879
2883
2880 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2884 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2881 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2885 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2882 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2886 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2883 which provides support for Qt interactive usage (similar to the
2887 which provides support for Qt interactive usage (similar to the
2884 existing one for WX and GTK). This had been often requested.
2888 existing one for WX and GTK). This had been often requested.
2885
2889
2886 2005-04-14 *** Released version 0.6.13
2890 2005-04-14 *** Released version 0.6.13
2887
2891
2888 2005-04-08 Fernando Perez <fperez@colorado.edu>
2892 2005-04-08 Fernando Perez <fperez@colorado.edu>
2889
2893
2890 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2894 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2891 from _ofind, which gets called on almost every input line. Now,
2895 from _ofind, which gets called on almost every input line. Now,
2892 we only try to get docstrings if they are actually going to be
2896 we only try to get docstrings if they are actually going to be
2893 used (the overhead of fetching unnecessary docstrings can be
2897 used (the overhead of fetching unnecessary docstrings can be
2894 noticeable for certain objects, such as Pyro proxies).
2898 noticeable for certain objects, such as Pyro proxies).
2895
2899
2896 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2900 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2897 for completers. For some reason I had been passing them the state
2901 for completers. For some reason I had been passing them the state
2898 variable, which completers never actually need, and was in
2902 variable, which completers never actually need, and was in
2899 conflict with the rlcompleter API. Custom completers ONLY need to
2903 conflict with the rlcompleter API. Custom completers ONLY need to
2900 take the text parameter.
2904 take the text parameter.
2901
2905
2902 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2906 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2903 work correctly in pysh. I've also moved all the logic which used
2907 work correctly in pysh. I've also moved all the logic which used
2904 to be in pysh.py here, which will prevent problems with future
2908 to be in pysh.py here, which will prevent problems with future
2905 upgrades. However, this time I must warn users to update their
2909 upgrades. However, this time I must warn users to update their
2906 pysh profile to include the line
2910 pysh profile to include the line
2907
2911
2908 import_all IPython.Extensions.InterpreterExec
2912 import_all IPython.Extensions.InterpreterExec
2909
2913
2910 because otherwise things won't work for them. They MUST also
2914 because otherwise things won't work for them. They MUST also
2911 delete pysh.py and the line
2915 delete pysh.py and the line
2912
2916
2913 execfile pysh.py
2917 execfile pysh.py
2914
2918
2915 from their ipythonrc-pysh.
2919 from their ipythonrc-pysh.
2916
2920
2917 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2921 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2918 robust in the face of objects whose dir() returns non-strings
2922 robust in the face of objects whose dir() returns non-strings
2919 (which it shouldn't, but some broken libs like ITK do). Thanks to
2923 (which it shouldn't, but some broken libs like ITK do). Thanks to
2920 a patch by John Hunter (implemented differently, though). Also
2924 a patch by John Hunter (implemented differently, though). Also
2921 minor improvements by using .extend instead of + on lists.
2925 minor improvements by using .extend instead of + on lists.
2922
2926
2923 * pysh.py:
2927 * pysh.py:
2924
2928
2925 2005-04-06 Fernando Perez <fperez@colorado.edu>
2929 2005-04-06 Fernando Perez <fperez@colorado.edu>
2926
2930
2927 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2931 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2928 by default, so that all users benefit from it. Those who don't
2932 by default, so that all users benefit from it. Those who don't
2929 want it can still turn it off.
2933 want it can still turn it off.
2930
2934
2931 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2935 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2932 config file, I'd forgotten about this, so users were getting it
2936 config file, I'd forgotten about this, so users were getting it
2933 off by default.
2937 off by default.
2934
2938
2935 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2939 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2936 consistency. Now magics can be called in multiline statements,
2940 consistency. Now magics can be called in multiline statements,
2937 and python variables can be expanded in magic calls via $var.
2941 and python variables can be expanded in magic calls via $var.
2938 This makes the magic system behave just like aliases or !system
2942 This makes the magic system behave just like aliases or !system
2939 calls.
2943 calls.
2940
2944
2941 2005-03-28 Fernando Perez <fperez@colorado.edu>
2945 2005-03-28 Fernando Perez <fperez@colorado.edu>
2942
2946
2943 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2947 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2944 expensive string additions for building command. Add support for
2948 expensive string additions for building command. Add support for
2945 trailing ';' when autocall is used.
2949 trailing ';' when autocall is used.
2946
2950
2947 2005-03-26 Fernando Perez <fperez@colorado.edu>
2951 2005-03-26 Fernando Perez <fperez@colorado.edu>
2948
2952
2949 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2953 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2950 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2954 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2951 ipython.el robust against prompts with any number of spaces
2955 ipython.el robust against prompts with any number of spaces
2952 (including 0) after the ':' character.
2956 (including 0) after the ':' character.
2953
2957
2954 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2958 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2955 continuation prompt, which misled users to think the line was
2959 continuation prompt, which misled users to think the line was
2956 already indented. Closes debian Bug#300847, reported to me by
2960 already indented. Closes debian Bug#300847, reported to me by
2957 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2961 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2958
2962
2959 2005-03-23 Fernando Perez <fperez@colorado.edu>
2963 2005-03-23 Fernando Perez <fperez@colorado.edu>
2960
2964
2961 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2965 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2962 properly aligned if they have embedded newlines.
2966 properly aligned if they have embedded newlines.
2963
2967
2964 * IPython/iplib.py (runlines): Add a public method to expose
2968 * IPython/iplib.py (runlines): Add a public method to expose
2965 IPython's code execution machinery, so that users can run strings
2969 IPython's code execution machinery, so that users can run strings
2966 as if they had been typed at the prompt interactively.
2970 as if they had been typed at the prompt interactively.
2967 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2971 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2968 methods which can call the system shell, but with python variable
2972 methods which can call the system shell, but with python variable
2969 expansion. The three such methods are: __IPYTHON__.system,
2973 expansion. The three such methods are: __IPYTHON__.system,
2970 .getoutput and .getoutputerror. These need to be documented in a
2974 .getoutput and .getoutputerror. These need to be documented in a
2971 'public API' section (to be written) of the manual.
2975 'public API' section (to be written) of the manual.
2972
2976
2973 2005-03-20 Fernando Perez <fperez@colorado.edu>
2977 2005-03-20 Fernando Perez <fperez@colorado.edu>
2974
2978
2975 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2979 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2976 for custom exception handling. This is quite powerful, and it
2980 for custom exception handling. This is quite powerful, and it
2977 allows for user-installable exception handlers which can trap
2981 allows for user-installable exception handlers which can trap
2978 custom exceptions at runtime and treat them separately from
2982 custom exceptions at runtime and treat them separately from
2979 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2983 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2980 Mantegazza <mantegazza-AT-ill.fr>.
2984 Mantegazza <mantegazza-AT-ill.fr>.
2981 (InteractiveShell.set_custom_completer): public API function to
2985 (InteractiveShell.set_custom_completer): public API function to
2982 add new completers at runtime.
2986 add new completers at runtime.
2983
2987
2984 2005-03-19 Fernando Perez <fperez@colorado.edu>
2988 2005-03-19 Fernando Perez <fperez@colorado.edu>
2985
2989
2986 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2990 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2987 allow objects which provide their docstrings via non-standard
2991 allow objects which provide their docstrings via non-standard
2988 mechanisms (like Pyro proxies) to still be inspected by ipython's
2992 mechanisms (like Pyro proxies) to still be inspected by ipython's
2989 ? system.
2993 ? system.
2990
2994
2991 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2995 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2992 automatic capture system. I tried quite hard to make it work
2996 automatic capture system. I tried quite hard to make it work
2993 reliably, and simply failed. I tried many combinations with the
2997 reliably, and simply failed. I tried many combinations with the
2994 subprocess module, but eventually nothing worked in all needed
2998 subprocess module, but eventually nothing worked in all needed
2995 cases (not blocking stdin for the child, duplicating stdout
2999 cases (not blocking stdin for the child, duplicating stdout
2996 without blocking, etc). The new %sc/%sx still do capture to these
3000 without blocking, etc). The new %sc/%sx still do capture to these
2997 magical list/string objects which make shell use much more
3001 magical list/string objects which make shell use much more
2998 conveninent, so not all is lost.
3002 conveninent, so not all is lost.
2999
3003
3000 XXX - FIX MANUAL for the change above!
3004 XXX - FIX MANUAL for the change above!
3001
3005
3002 (runsource): I copied code.py's runsource() into ipython to modify
3006 (runsource): I copied code.py's runsource() into ipython to modify
3003 it a bit. Now the code object and source to be executed are
3007 it a bit. Now the code object and source to be executed are
3004 stored in ipython. This makes this info accessible to third-party
3008 stored in ipython. This makes this info accessible to third-party
3005 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
3009 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
3006 Mantegazza <mantegazza-AT-ill.fr>.
3010 Mantegazza <mantegazza-AT-ill.fr>.
3007
3011
3008 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
3012 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
3009 history-search via readline (like C-p/C-n). I'd wanted this for a
3013 history-search via readline (like C-p/C-n). I'd wanted this for a
3010 long time, but only recently found out how to do it. For users
3014 long time, but only recently found out how to do it. For users
3011 who already have their ipythonrc files made and want this, just
3015 who already have their ipythonrc files made and want this, just
3012 add:
3016 add:
3013
3017
3014 readline_parse_and_bind "\e[A": history-search-backward
3018 readline_parse_and_bind "\e[A": history-search-backward
3015 readline_parse_and_bind "\e[B": history-search-forward
3019 readline_parse_and_bind "\e[B": history-search-forward
3016
3020
3017 2005-03-18 Fernando Perez <fperez@colorado.edu>
3021 2005-03-18 Fernando Perez <fperez@colorado.edu>
3018
3022
3019 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
3023 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
3020 LSString and SList classes which allow transparent conversions
3024 LSString and SList classes which allow transparent conversions
3021 between list mode and whitespace-separated string.
3025 between list mode and whitespace-separated string.
3022 (magic_r): Fix recursion problem in %r.
3026 (magic_r): Fix recursion problem in %r.
3023
3027
3024 * IPython/genutils.py (LSString): New class to be used for
3028 * IPython/genutils.py (LSString): New class to be used for
3025 automatic storage of the results of all alias/system calls in _o
3029 automatic storage of the results of all alias/system calls in _o
3026 and _e (stdout/err). These provide a .l/.list attribute which
3030 and _e (stdout/err). These provide a .l/.list attribute which
3027 does automatic splitting on newlines. This means that for most
3031 does automatic splitting on newlines. This means that for most
3028 uses, you'll never need to do capturing of output with %sc/%sx
3032 uses, you'll never need to do capturing of output with %sc/%sx
3029 anymore, since ipython keeps this always done for you. Note that
3033 anymore, since ipython keeps this always done for you. Note that
3030 only the LAST results are stored, the _o/e variables are
3034 only the LAST results are stored, the _o/e variables are
3031 overwritten on each call. If you need to save their contents
3035 overwritten on each call. If you need to save their contents
3032 further, simply bind them to any other name.
3036 further, simply bind them to any other name.
3033
3037
3034 2005-03-17 Fernando Perez <fperez@colorado.edu>
3038 2005-03-17 Fernando Perez <fperez@colorado.edu>
3035
3039
3036 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
3040 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
3037 prompt namespace handling.
3041 prompt namespace handling.
3038
3042
3039 2005-03-16 Fernando Perez <fperez@colorado.edu>
3043 2005-03-16 Fernando Perez <fperez@colorado.edu>
3040
3044
3041 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
3045 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
3042 classic prompts to be '>>> ' (final space was missing, and it
3046 classic prompts to be '>>> ' (final space was missing, and it
3043 trips the emacs python mode).
3047 trips the emacs python mode).
3044 (BasePrompt.__str__): Added safe support for dynamic prompt
3048 (BasePrompt.__str__): Added safe support for dynamic prompt
3045 strings. Now you can set your prompt string to be '$x', and the
3049 strings. Now you can set your prompt string to be '$x', and the
3046 value of x will be printed from your interactive namespace. The
3050 value of x will be printed from your interactive namespace. The
3047 interpolation syntax includes the full Itpl support, so
3051 interpolation syntax includes the full Itpl support, so
3048 ${foo()+x+bar()} is a valid prompt string now, and the function
3052 ${foo()+x+bar()} is a valid prompt string now, and the function
3049 calls will be made at runtime.
3053 calls will be made at runtime.
3050
3054
3051 2005-03-15 Fernando Perez <fperez@colorado.edu>
3055 2005-03-15 Fernando Perez <fperez@colorado.edu>
3052
3056
3053 * IPython/Magic.py (magic_history): renamed %hist to %history, to
3057 * IPython/Magic.py (magic_history): renamed %hist to %history, to
3054 avoid name clashes in pylab. %hist still works, it just forwards
3058 avoid name clashes in pylab. %hist still works, it just forwards
3055 the call to %history.
3059 the call to %history.
3056
3060
3057 2005-03-02 *** Released version 0.6.12
3061 2005-03-02 *** Released version 0.6.12
3058
3062
3059 2005-03-02 Fernando Perez <fperez@colorado.edu>
3063 2005-03-02 Fernando Perez <fperez@colorado.edu>
3060
3064
3061 * IPython/iplib.py (handle_magic): log magic calls properly as
3065 * IPython/iplib.py (handle_magic): log magic calls properly as
3062 ipmagic() function calls.
3066 ipmagic() function calls.
3063
3067
3064 * IPython/Magic.py (magic_time): Improved %time to support
3068 * IPython/Magic.py (magic_time): Improved %time to support
3065 statements and provide wall-clock as well as CPU time.
3069 statements and provide wall-clock as well as CPU time.
3066
3070
3067 2005-02-27 Fernando Perez <fperez@colorado.edu>
3071 2005-02-27 Fernando Perez <fperez@colorado.edu>
3068
3072
3069 * IPython/hooks.py: New hooks module, to expose user-modifiable
3073 * IPython/hooks.py: New hooks module, to expose user-modifiable
3070 IPython functionality in a clean manner. For now only the editor
3074 IPython functionality in a clean manner. For now only the editor
3071 hook is actually written, and other thigns which I intend to turn
3075 hook is actually written, and other thigns which I intend to turn
3072 into proper hooks aren't yet there. The display and prefilter
3076 into proper hooks aren't yet there. The display and prefilter
3073 stuff, for example, should be hooks. But at least now the
3077 stuff, for example, should be hooks. But at least now the
3074 framework is in place, and the rest can be moved here with more
3078 framework is in place, and the rest can be moved here with more
3075 time later. IPython had had a .hooks variable for a long time for
3079 time later. IPython had had a .hooks variable for a long time for
3076 this purpose, but I'd never actually used it for anything.
3080 this purpose, but I'd never actually used it for anything.
3077
3081
3078 2005-02-26 Fernando Perez <fperez@colorado.edu>
3082 2005-02-26 Fernando Perez <fperez@colorado.edu>
3079
3083
3080 * IPython/ipmaker.py (make_IPython): make the default ipython
3084 * IPython/ipmaker.py (make_IPython): make the default ipython
3081 directory be called _ipython under win32, to follow more the
3085 directory be called _ipython under win32, to follow more the
3082 naming peculiarities of that platform (where buggy software like
3086 naming peculiarities of that platform (where buggy software like
3083 Visual Sourcesafe breaks with .named directories). Reported by
3087 Visual Sourcesafe breaks with .named directories). Reported by
3084 Ville Vainio.
3088 Ville Vainio.
3085
3089
3086 2005-02-23 Fernando Perez <fperez@colorado.edu>
3090 2005-02-23 Fernando Perez <fperez@colorado.edu>
3087
3091
3088 * IPython/iplib.py (InteractiveShell.__init__): removed a few
3092 * IPython/iplib.py (InteractiveShell.__init__): removed a few
3089 auto_aliases for win32 which were causing problems. Users can
3093 auto_aliases for win32 which were causing problems. Users can
3090 define the ones they personally like.
3094 define the ones they personally like.
3091
3095
3092 2005-02-21 Fernando Perez <fperez@colorado.edu>
3096 2005-02-21 Fernando Perez <fperez@colorado.edu>
3093
3097
3094 * IPython/Magic.py (magic_time): new magic to time execution of
3098 * IPython/Magic.py (magic_time): new magic to time execution of
3095 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
3099 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
3096
3100
3097 2005-02-19 Fernando Perez <fperez@colorado.edu>
3101 2005-02-19 Fernando Perez <fperez@colorado.edu>
3098
3102
3099 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
3103 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
3100 into keys (for prompts, for example).
3104 into keys (for prompts, for example).
3101
3105
3102 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
3106 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
3103 prompts in case users want them. This introduces a small behavior
3107 prompts in case users want them. This introduces a small behavior
3104 change: ipython does not automatically add a space to all prompts
3108 change: ipython does not automatically add a space to all prompts
3105 anymore. To get the old prompts with a space, users should add it
3109 anymore. To get the old prompts with a space, users should add it
3106 manually to their ipythonrc file, so for example prompt_in1 should
3110 manually to their ipythonrc file, so for example prompt_in1 should
3107 now read 'In [\#]: ' instead of 'In [\#]:'.
3111 now read 'In [\#]: ' instead of 'In [\#]:'.
3108 (BasePrompt.__init__): New option prompts_pad_left (only in rc
3112 (BasePrompt.__init__): New option prompts_pad_left (only in rc
3109 file) to control left-padding of secondary prompts.
3113 file) to control left-padding of secondary prompts.
3110
3114
3111 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
3115 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
3112 the profiler can't be imported. Fix for Debian, which removed
3116 the profiler can't be imported. Fix for Debian, which removed
3113 profile.py because of License issues. I applied a slightly
3117 profile.py because of License issues. I applied a slightly
3114 modified version of the original Debian patch at
3118 modified version of the original Debian patch at
3115 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
3119 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
3116
3120
3117 2005-02-17 Fernando Perez <fperez@colorado.edu>
3121 2005-02-17 Fernando Perez <fperez@colorado.edu>
3118
3122
3119 * IPython/genutils.py (native_line_ends): Fix bug which would
3123 * IPython/genutils.py (native_line_ends): Fix bug which would
3120 cause improper line-ends under win32 b/c I was not opening files
3124 cause improper line-ends under win32 b/c I was not opening files
3121 in binary mode. Bug report and fix thanks to Ville.
3125 in binary mode. Bug report and fix thanks to Ville.
3122
3126
3123 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
3127 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
3124 trying to catch spurious foo[1] autocalls. My fix actually broke
3128 trying to catch spurious foo[1] autocalls. My fix actually broke
3125 ',/' autoquote/call with explicit escape (bad regexp).
3129 ',/' autoquote/call with explicit escape (bad regexp).
3126
3130
3127 2005-02-15 *** Released version 0.6.11
3131 2005-02-15 *** Released version 0.6.11
3128
3132
3129 2005-02-14 Fernando Perez <fperez@colorado.edu>
3133 2005-02-14 Fernando Perez <fperez@colorado.edu>
3130
3134
3131 * IPython/background_jobs.py: New background job management
3135 * IPython/background_jobs.py: New background job management
3132 subsystem. This is implemented via a new set of classes, and
3136 subsystem. This is implemented via a new set of classes, and
3133 IPython now provides a builtin 'jobs' object for background job
3137 IPython now provides a builtin 'jobs' object for background job
3134 execution. A convenience %bg magic serves as a lightweight
3138 execution. A convenience %bg magic serves as a lightweight
3135 frontend for starting the more common type of calls. This was
3139 frontend for starting the more common type of calls. This was
3136 inspired by discussions with B. Granger and the BackgroundCommand
3140 inspired by discussions with B. Granger and the BackgroundCommand
3137 class described in the book Python Scripting for Computational
3141 class described in the book Python Scripting for Computational
3138 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
3142 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
3139 (although ultimately no code from this text was used, as IPython's
3143 (although ultimately no code from this text was used, as IPython's
3140 system is a separate implementation).
3144 system is a separate implementation).
3141
3145
3142 * IPython/iplib.py (MagicCompleter.python_matches): add new option
3146 * IPython/iplib.py (MagicCompleter.python_matches): add new option
3143 to control the completion of single/double underscore names
3147 to control the completion of single/double underscore names
3144 separately. As documented in the example ipytonrc file, the
3148 separately. As documented in the example ipytonrc file, the
3145 readline_omit__names variable can now be set to 2, to omit even
3149 readline_omit__names variable can now be set to 2, to omit even
3146 single underscore names. Thanks to a patch by Brian Wong
3150 single underscore names. Thanks to a patch by Brian Wong
3147 <BrianWong-AT-AirgoNetworks.Com>.
3151 <BrianWong-AT-AirgoNetworks.Com>.
3148 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
3152 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
3149 be autocalled as foo([1]) if foo were callable. A problem for
3153 be autocalled as foo([1]) if foo were callable. A problem for
3150 things which are both callable and implement __getitem__.
3154 things which are both callable and implement __getitem__.
3151 (init_readline): Fix autoindentation for win32. Thanks to a patch
3155 (init_readline): Fix autoindentation for win32. Thanks to a patch
3152 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
3156 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
3153
3157
3154 2005-02-12 Fernando Perez <fperez@colorado.edu>
3158 2005-02-12 Fernando Perez <fperez@colorado.edu>
3155
3159
3156 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
3160 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
3157 which I had written long ago to sort out user error messages which
3161 which I had written long ago to sort out user error messages which
3158 may occur during startup. This seemed like a good idea initially,
3162 may occur during startup. This seemed like a good idea initially,
3159 but it has proven a disaster in retrospect. I don't want to
3163 but it has proven a disaster in retrospect. I don't want to
3160 change much code for now, so my fix is to set the internal 'debug'
3164 change much code for now, so my fix is to set the internal 'debug'
3161 flag to true everywhere, whose only job was precisely to control
3165 flag to true everywhere, whose only job was precisely to control
3162 this subsystem. This closes issue 28 (as well as avoiding all
3166 this subsystem. This closes issue 28 (as well as avoiding all
3163 sorts of strange hangups which occur from time to time).
3167 sorts of strange hangups which occur from time to time).
3164
3168
3165 2005-02-07 Fernando Perez <fperez@colorado.edu>
3169 2005-02-07 Fernando Perez <fperez@colorado.edu>
3166
3170
3167 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
3171 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
3168 previous call produced a syntax error.
3172 previous call produced a syntax error.
3169
3173
3170 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3174 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3171 classes without constructor.
3175 classes without constructor.
3172
3176
3173 2005-02-06 Fernando Perez <fperez@colorado.edu>
3177 2005-02-06 Fernando Perez <fperez@colorado.edu>
3174
3178
3175 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
3179 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
3176 completions with the results of each matcher, so we return results
3180 completions with the results of each matcher, so we return results
3177 to the user from all namespaces. This breaks with ipython
3181 to the user from all namespaces. This breaks with ipython
3178 tradition, but I think it's a nicer behavior. Now you get all
3182 tradition, but I think it's a nicer behavior. Now you get all
3179 possible completions listed, from all possible namespaces (python,
3183 possible completions listed, from all possible namespaces (python,
3180 filesystem, magics...) After a request by John Hunter
3184 filesystem, magics...) After a request by John Hunter
3181 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3185 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3182
3186
3183 2005-02-05 Fernando Perez <fperez@colorado.edu>
3187 2005-02-05 Fernando Perez <fperez@colorado.edu>
3184
3188
3185 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
3189 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
3186 the call had quote characters in it (the quotes were stripped).
3190 the call had quote characters in it (the quotes were stripped).
3187
3191
3188 2005-01-31 Fernando Perez <fperez@colorado.edu>
3192 2005-01-31 Fernando Perez <fperez@colorado.edu>
3189
3193
3190 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
3194 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
3191 Itpl.itpl() to make the code more robust against psyco
3195 Itpl.itpl() to make the code more robust against psyco
3192 optimizations.
3196 optimizations.
3193
3197
3194 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
3198 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
3195 of causing an exception. Quicker, cleaner.
3199 of causing an exception. Quicker, cleaner.
3196
3200
3197 2005-01-28 Fernando Perez <fperez@colorado.edu>
3201 2005-01-28 Fernando Perez <fperez@colorado.edu>
3198
3202
3199 * scripts/ipython_win_post_install.py (install): hardcode
3203 * scripts/ipython_win_post_install.py (install): hardcode
3200 sys.prefix+'python.exe' as the executable path. It turns out that
3204 sys.prefix+'python.exe' as the executable path. It turns out that
3201 during the post-installation run, sys.executable resolves to the
3205 during the post-installation run, sys.executable resolves to the
3202 name of the binary installer! I should report this as a distutils
3206 name of the binary installer! I should report this as a distutils
3203 bug, I think. I updated the .10 release with this tiny fix, to
3207 bug, I think. I updated the .10 release with this tiny fix, to
3204 avoid annoying the lists further.
3208 avoid annoying the lists further.
3205
3209
3206 2005-01-27 *** Released version 0.6.10
3210 2005-01-27 *** Released version 0.6.10
3207
3211
3208 2005-01-27 Fernando Perez <fperez@colorado.edu>
3212 2005-01-27 Fernando Perez <fperez@colorado.edu>
3209
3213
3210 * IPython/numutils.py (norm): Added 'inf' as optional name for
3214 * IPython/numutils.py (norm): Added 'inf' as optional name for
3211 L-infinity norm, included references to mathworld.com for vector
3215 L-infinity norm, included references to mathworld.com for vector
3212 norm definitions.
3216 norm definitions.
3213 (amin/amax): added amin/amax for array min/max. Similar to what
3217 (amin/amax): added amin/amax for array min/max. Similar to what
3214 pylab ships with after the recent reorganization of names.
3218 pylab ships with after the recent reorganization of names.
3215 (spike/spike_odd): removed deprecated spike/spike_odd functions.
3219 (spike/spike_odd): removed deprecated spike/spike_odd functions.
3216
3220
3217 * ipython.el: committed Alex's recent fixes and improvements.
3221 * ipython.el: committed Alex's recent fixes and improvements.
3218 Tested with python-mode from CVS, and it looks excellent. Since
3222 Tested with python-mode from CVS, and it looks excellent. Since
3219 python-mode hasn't released anything in a while, I'm temporarily
3223 python-mode hasn't released anything in a while, I'm temporarily
3220 putting a copy of today's CVS (v 4.70) of python-mode in:
3224 putting a copy of today's CVS (v 4.70) of python-mode in:
3221 http://ipython.scipy.org/tmp/python-mode.el
3225 http://ipython.scipy.org/tmp/python-mode.el
3222
3226
3223 * scripts/ipython_win_post_install.py (install): Win32 fix to use
3227 * scripts/ipython_win_post_install.py (install): Win32 fix to use
3224 sys.executable for the executable name, instead of assuming it's
3228 sys.executable for the executable name, instead of assuming it's
3225 called 'python.exe' (the post-installer would have produced broken
3229 called 'python.exe' (the post-installer would have produced broken
3226 setups on systems with a differently named python binary).
3230 setups on systems with a differently named python binary).
3227
3231
3228 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
3232 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
3229 references to os.linesep, to make the code more
3233 references to os.linesep, to make the code more
3230 platform-independent. This is also part of the win32 coloring
3234 platform-independent. This is also part of the win32 coloring
3231 fixes.
3235 fixes.
3232
3236
3233 * IPython/genutils.py (page_dumb): Remove attempts to chop long
3237 * IPython/genutils.py (page_dumb): Remove attempts to chop long
3234 lines, which actually cause coloring bugs because the length of
3238 lines, which actually cause coloring bugs because the length of
3235 the line is very difficult to correctly compute with embedded
3239 the line is very difficult to correctly compute with embedded
3236 escapes. This was the source of all the coloring problems under
3240 escapes. This was the source of all the coloring problems under
3237 Win32. I think that _finally_, Win32 users have a properly
3241 Win32. I think that _finally_, Win32 users have a properly
3238 working ipython in all respects. This would never have happened
3242 working ipython in all respects. This would never have happened
3239 if not for Gary Bishop and Viktor Ransmayr's great help and work.
3243 if not for Gary Bishop and Viktor Ransmayr's great help and work.
3240
3244
3241 2005-01-26 *** Released version 0.6.9
3245 2005-01-26 *** Released version 0.6.9
3242
3246
3243 2005-01-25 Fernando Perez <fperez@colorado.edu>
3247 2005-01-25 Fernando Perez <fperez@colorado.edu>
3244
3248
3245 * setup.py: finally, we have a true Windows installer, thanks to
3249 * setup.py: finally, we have a true Windows installer, thanks to
3246 the excellent work of Viktor Ransmayr
3250 the excellent work of Viktor Ransmayr
3247 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
3251 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
3248 Windows users. The setup routine is quite a bit cleaner thanks to
3252 Windows users. The setup routine is quite a bit cleaner thanks to
3249 this, and the post-install script uses the proper functions to
3253 this, and the post-install script uses the proper functions to
3250 allow a clean de-installation using the standard Windows Control
3254 allow a clean de-installation using the standard Windows Control
3251 Panel.
3255 Panel.
3252
3256
3253 * IPython/genutils.py (get_home_dir): changed to use the $HOME
3257 * IPython/genutils.py (get_home_dir): changed to use the $HOME
3254 environment variable under all OSes (including win32) if
3258 environment variable under all OSes (including win32) if
3255 available. This will give consistency to win32 users who have set
3259 available. This will give consistency to win32 users who have set
3256 this variable for any reason. If os.environ['HOME'] fails, the
3260 this variable for any reason. If os.environ['HOME'] fails, the
3257 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
3261 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
3258
3262
3259 2005-01-24 Fernando Perez <fperez@colorado.edu>
3263 2005-01-24 Fernando Perez <fperez@colorado.edu>
3260
3264
3261 * IPython/numutils.py (empty_like): add empty_like(), similar to
3265 * IPython/numutils.py (empty_like): add empty_like(), similar to
3262 zeros_like() but taking advantage of the new empty() Numeric routine.
3266 zeros_like() but taking advantage of the new empty() Numeric routine.
3263
3267
3264 2005-01-23 *** Released version 0.6.8
3268 2005-01-23 *** Released version 0.6.8
3265
3269
3266 2005-01-22 Fernando Perez <fperez@colorado.edu>
3270 2005-01-22 Fernando Perez <fperez@colorado.edu>
3267
3271
3268 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
3272 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
3269 automatic show() calls. After discussing things with JDH, it
3273 automatic show() calls. After discussing things with JDH, it
3270 turns out there are too many corner cases where this can go wrong.
3274 turns out there are too many corner cases where this can go wrong.
3271 It's best not to try to be 'too smart', and simply have ipython
3275 It's best not to try to be 'too smart', and simply have ipython
3272 reproduce as much as possible the default behavior of a normal
3276 reproduce as much as possible the default behavior of a normal
3273 python shell.
3277 python shell.
3274
3278
3275 * IPython/iplib.py (InteractiveShell.__init__): Modified the
3279 * IPython/iplib.py (InteractiveShell.__init__): Modified the
3276 line-splitting regexp and _prefilter() to avoid calling getattr()
3280 line-splitting regexp and _prefilter() to avoid calling getattr()
3277 on assignments. This closes
3281 on assignments. This closes
3278 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
3282 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
3279 readline uses getattr(), so a simple <TAB> keypress is still
3283 readline uses getattr(), so a simple <TAB> keypress is still
3280 enough to trigger getattr() calls on an object.
3284 enough to trigger getattr() calls on an object.
3281
3285
3282 2005-01-21 Fernando Perez <fperez@colorado.edu>
3286 2005-01-21 Fernando Perez <fperez@colorado.edu>
3283
3287
3284 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
3288 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
3285 docstring under pylab so it doesn't mask the original.
3289 docstring under pylab so it doesn't mask the original.
3286
3290
3287 2005-01-21 *** Released version 0.6.7
3291 2005-01-21 *** Released version 0.6.7
3288
3292
3289 2005-01-21 Fernando Perez <fperez@colorado.edu>
3293 2005-01-21 Fernando Perez <fperez@colorado.edu>
3290
3294
3291 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
3295 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
3292 signal handling for win32 users in multithreaded mode.
3296 signal handling for win32 users in multithreaded mode.
3293
3297
3294 2005-01-17 Fernando Perez <fperez@colorado.edu>
3298 2005-01-17 Fernando Perez <fperez@colorado.edu>
3295
3299
3296 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3300 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3297 instances with no __init__. After a crash report by Norbert Nemec
3301 instances with no __init__. After a crash report by Norbert Nemec
3298 <Norbert-AT-nemec-online.de>.
3302 <Norbert-AT-nemec-online.de>.
3299
3303
3300 2005-01-14 Fernando Perez <fperez@colorado.edu>
3304 2005-01-14 Fernando Perez <fperez@colorado.edu>
3301
3305
3302 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
3306 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
3303 names for verbose exceptions, when multiple dotted names and the
3307 names for verbose exceptions, when multiple dotted names and the
3304 'parent' object were present on the same line.
3308 'parent' object were present on the same line.
3305
3309
3306 2005-01-11 Fernando Perez <fperez@colorado.edu>
3310 2005-01-11 Fernando Perez <fperez@colorado.edu>
3307
3311
3308 * IPython/genutils.py (flag_calls): new utility to trap and flag
3312 * IPython/genutils.py (flag_calls): new utility to trap and flag
3309 calls in functions. I need it to clean up matplotlib support.
3313 calls in functions. I need it to clean up matplotlib support.
3310 Also removed some deprecated code in genutils.
3314 Also removed some deprecated code in genutils.
3311
3315
3312 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
3316 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
3313 that matplotlib scripts called with %run, which don't call show()
3317 that matplotlib scripts called with %run, which don't call show()
3314 themselves, still have their plotting windows open.
3318 themselves, still have their plotting windows open.
3315
3319
3316 2005-01-05 Fernando Perez <fperez@colorado.edu>
3320 2005-01-05 Fernando Perez <fperez@colorado.edu>
3317
3321
3318 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
3322 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
3319 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
3323 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
3320
3324
3321 2004-12-19 Fernando Perez <fperez@colorado.edu>
3325 2004-12-19 Fernando Perez <fperez@colorado.edu>
3322
3326
3323 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
3327 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
3324 parent_runcode, which was an eyesore. The same result can be
3328 parent_runcode, which was an eyesore. The same result can be
3325 obtained with Python's regular superclass mechanisms.
3329 obtained with Python's regular superclass mechanisms.
3326
3330
3327 2004-12-17 Fernando Perez <fperez@colorado.edu>
3331 2004-12-17 Fernando Perez <fperez@colorado.edu>
3328
3332
3329 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
3333 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
3330 reported by Prabhu.
3334 reported by Prabhu.
3331 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
3335 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
3332 sys.stderr) instead of explicitly calling sys.stderr. This helps
3336 sys.stderr) instead of explicitly calling sys.stderr. This helps
3333 maintain our I/O abstractions clean, for future GUI embeddings.
3337 maintain our I/O abstractions clean, for future GUI embeddings.
3334
3338
3335 * IPython/genutils.py (info): added new utility for sys.stderr
3339 * IPython/genutils.py (info): added new utility for sys.stderr
3336 unified info message handling (thin wrapper around warn()).
3340 unified info message handling (thin wrapper around warn()).
3337
3341
3338 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
3342 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
3339 composite (dotted) names on verbose exceptions.
3343 composite (dotted) names on verbose exceptions.
3340 (VerboseTB.nullrepr): harden against another kind of errors which
3344 (VerboseTB.nullrepr): harden against another kind of errors which
3341 Python's inspect module can trigger, and which were crashing
3345 Python's inspect module can trigger, and which were crashing
3342 IPython. Thanks to a report by Marco Lombardi
3346 IPython. Thanks to a report by Marco Lombardi
3343 <mlombard-AT-ma010192.hq.eso.org>.
3347 <mlombard-AT-ma010192.hq.eso.org>.
3344
3348
3345 2004-12-13 *** Released version 0.6.6
3349 2004-12-13 *** Released version 0.6.6
3346
3350
3347 2004-12-12 Fernando Perez <fperez@colorado.edu>
3351 2004-12-12 Fernando Perez <fperez@colorado.edu>
3348
3352
3349 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
3353 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
3350 generated by pygtk upon initialization if it was built without
3354 generated by pygtk upon initialization if it was built without
3351 threads (for matplotlib users). After a crash reported by
3355 threads (for matplotlib users). After a crash reported by
3352 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
3356 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
3353
3357
3354 * IPython/ipmaker.py (make_IPython): fix small bug in the
3358 * IPython/ipmaker.py (make_IPython): fix small bug in the
3355 import_some parameter for multiple imports.
3359 import_some parameter for multiple imports.
3356
3360
3357 * IPython/iplib.py (ipmagic): simplified the interface of
3361 * IPython/iplib.py (ipmagic): simplified the interface of
3358 ipmagic() to take a single string argument, just as it would be
3362 ipmagic() to take a single string argument, just as it would be
3359 typed at the IPython cmd line.
3363 typed at the IPython cmd line.
3360 (ipalias): Added new ipalias() with an interface identical to
3364 (ipalias): Added new ipalias() with an interface identical to
3361 ipmagic(). This completes exposing a pure python interface to the
3365 ipmagic(). This completes exposing a pure python interface to the
3362 alias and magic system, which can be used in loops or more complex
3366 alias and magic system, which can be used in loops or more complex
3363 code where IPython's automatic line mangling is not active.
3367 code where IPython's automatic line mangling is not active.
3364
3368
3365 * IPython/genutils.py (timing): changed interface of timing to
3369 * IPython/genutils.py (timing): changed interface of timing to
3366 simply run code once, which is the most common case. timings()
3370 simply run code once, which is the most common case. timings()
3367 remains unchanged, for the cases where you want multiple runs.
3371 remains unchanged, for the cases where you want multiple runs.
3368
3372
3369 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
3373 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
3370 bug where Python2.2 crashes with exec'ing code which does not end
3374 bug where Python2.2 crashes with exec'ing code which does not end
3371 in a single newline. Python 2.3 is OK, so I hadn't noticed this
3375 in a single newline. Python 2.3 is OK, so I hadn't noticed this
3372 before.
3376 before.
3373
3377
3374 2004-12-10 Fernando Perez <fperez@colorado.edu>
3378 2004-12-10 Fernando Perez <fperez@colorado.edu>
3375
3379
3376 * IPython/Magic.py (Magic.magic_prun): changed name of option from
3380 * IPython/Magic.py (Magic.magic_prun): changed name of option from
3377 -t to -T, to accomodate the new -t flag in %run (the %run and
3381 -t to -T, to accomodate the new -t flag in %run (the %run and
3378 %prun options are kind of intermixed, and it's not easy to change
3382 %prun options are kind of intermixed, and it's not easy to change
3379 this with the limitations of python's getopt).
3383 this with the limitations of python's getopt).
3380
3384
3381 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
3385 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
3382 the execution of scripts. It's not as fine-tuned as timeit.py,
3386 the execution of scripts. It's not as fine-tuned as timeit.py,
3383 but it works from inside ipython (and under 2.2, which lacks
3387 but it works from inside ipython (and under 2.2, which lacks
3384 timeit.py). Optionally a number of runs > 1 can be given for
3388 timeit.py). Optionally a number of runs > 1 can be given for
3385 timing very short-running code.
3389 timing very short-running code.
3386
3390
3387 * IPython/genutils.py (uniq_stable): new routine which returns a
3391 * IPython/genutils.py (uniq_stable): new routine which returns a
3388 list of unique elements in any iterable, but in stable order of
3392 list of unique elements in any iterable, but in stable order of
3389 appearance. I needed this for the ultraTB fixes, and it's a handy
3393 appearance. I needed this for the ultraTB fixes, and it's a handy
3390 utility.
3394 utility.
3391
3395
3392 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
3396 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
3393 dotted names in Verbose exceptions. This had been broken since
3397 dotted names in Verbose exceptions. This had been broken since
3394 the very start, now x.y will properly be printed in a Verbose
3398 the very start, now x.y will properly be printed in a Verbose
3395 traceback, instead of x being shown and y appearing always as an
3399 traceback, instead of x being shown and y appearing always as an
3396 'undefined global'. Getting this to work was a bit tricky,
3400 'undefined global'. Getting this to work was a bit tricky,
3397 because by default python tokenizers are stateless. Saved by
3401 because by default python tokenizers are stateless. Saved by
3398 python's ability to easily add a bit of state to an arbitrary
3402 python's ability to easily add a bit of state to an arbitrary
3399 function (without needing to build a full-blown callable object).
3403 function (without needing to build a full-blown callable object).
3400
3404
3401 Also big cleanup of this code, which had horrendous runtime
3405 Also big cleanup of this code, which had horrendous runtime
3402 lookups of zillions of attributes for colorization. Moved all
3406 lookups of zillions of attributes for colorization. Moved all
3403 this code into a few templates, which make it cleaner and quicker.
3407 this code into a few templates, which make it cleaner and quicker.
3404
3408
3405 Printout quality was also improved for Verbose exceptions: one
3409 Printout quality was also improved for Verbose exceptions: one
3406 variable per line, and memory addresses are printed (this can be
3410 variable per line, and memory addresses are printed (this can be
3407 quite handy in nasty debugging situations, which is what Verbose
3411 quite handy in nasty debugging situations, which is what Verbose
3408 is for).
3412 is for).
3409
3413
3410 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
3414 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
3411 the command line as scripts to be loaded by embedded instances.
3415 the command line as scripts to be loaded by embedded instances.
3412 Doing so has the potential for an infinite recursion if there are
3416 Doing so has the potential for an infinite recursion if there are
3413 exceptions thrown in the process. This fixes a strange crash
3417 exceptions thrown in the process. This fixes a strange crash
3414 reported by Philippe MULLER <muller-AT-irit.fr>.
3418 reported by Philippe MULLER <muller-AT-irit.fr>.
3415
3419
3416 2004-12-09 Fernando Perez <fperez@colorado.edu>
3420 2004-12-09 Fernando Perez <fperez@colorado.edu>
3417
3421
3418 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
3422 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
3419 to reflect new names in matplotlib, which now expose the
3423 to reflect new names in matplotlib, which now expose the
3420 matlab-compatible interface via a pylab module instead of the
3424 matlab-compatible interface via a pylab module instead of the
3421 'matlab' name. The new code is backwards compatible, so users of
3425 'matlab' name. The new code is backwards compatible, so users of
3422 all matplotlib versions are OK. Patch by J. Hunter.
3426 all matplotlib versions are OK. Patch by J. Hunter.
3423
3427
3424 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
3428 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
3425 of __init__ docstrings for instances (class docstrings are already
3429 of __init__ docstrings for instances (class docstrings are already
3426 automatically printed). Instances with customized docstrings
3430 automatically printed). Instances with customized docstrings
3427 (indep. of the class) are also recognized and all 3 separate
3431 (indep. of the class) are also recognized and all 3 separate
3428 docstrings are printed (instance, class, constructor). After some
3432 docstrings are printed (instance, class, constructor). After some
3429 comments/suggestions by J. Hunter.
3433 comments/suggestions by J. Hunter.
3430
3434
3431 2004-12-05 Fernando Perez <fperez@colorado.edu>
3435 2004-12-05 Fernando Perez <fperez@colorado.edu>
3432
3436
3433 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
3437 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
3434 warnings when tab-completion fails and triggers an exception.
3438 warnings when tab-completion fails and triggers an exception.
3435
3439
3436 2004-12-03 Fernando Perez <fperez@colorado.edu>
3440 2004-12-03 Fernando Perez <fperez@colorado.edu>
3437
3441
3438 * IPython/Magic.py (magic_prun): Fix bug where an exception would
3442 * IPython/Magic.py (magic_prun): Fix bug where an exception would
3439 be triggered when using 'run -p'. An incorrect option flag was
3443 be triggered when using 'run -p'. An incorrect option flag was
3440 being set ('d' instead of 'D').
3444 being set ('d' instead of 'D').
3441 (manpage): fix missing escaped \- sign.
3445 (manpage): fix missing escaped \- sign.
3442
3446
3443 2004-11-30 *** Released version 0.6.5
3447 2004-11-30 *** Released version 0.6.5
3444
3448
3445 2004-11-30 Fernando Perez <fperez@colorado.edu>
3449 2004-11-30 Fernando Perez <fperez@colorado.edu>
3446
3450
3447 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
3451 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
3448 setting with -d option.
3452 setting with -d option.
3449
3453
3450 * setup.py (docfiles): Fix problem where the doc glob I was using
3454 * setup.py (docfiles): Fix problem where the doc glob I was using
3451 was COMPLETELY BROKEN. It was giving the right files by pure
3455 was COMPLETELY BROKEN. It was giving the right files by pure
3452 accident, but failed once I tried to include ipython.el. Note:
3456 accident, but failed once I tried to include ipython.el. Note:
3453 glob() does NOT allow you to do exclusion on multiple endings!
3457 glob() does NOT allow you to do exclusion on multiple endings!
3454
3458
3455 2004-11-29 Fernando Perez <fperez@colorado.edu>
3459 2004-11-29 Fernando Perez <fperez@colorado.edu>
3456
3460
3457 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
3461 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
3458 the manpage as the source. Better formatting & consistency.
3462 the manpage as the source. Better formatting & consistency.
3459
3463
3460 * IPython/Magic.py (magic_run): Added new -d option, to run
3464 * IPython/Magic.py (magic_run): Added new -d option, to run
3461 scripts under the control of the python pdb debugger. Note that
3465 scripts under the control of the python pdb debugger. Note that
3462 this required changing the %prun option -d to -D, to avoid a clash
3466 this required changing the %prun option -d to -D, to avoid a clash
3463 (since %run must pass options to %prun, and getopt is too dumb to
3467 (since %run must pass options to %prun, and getopt is too dumb to
3464 handle options with string values with embedded spaces). Thanks
3468 handle options with string values with embedded spaces). Thanks
3465 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
3469 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
3466 (magic_who_ls): added type matching to %who and %whos, so that one
3470 (magic_who_ls): added type matching to %who and %whos, so that one
3467 can filter their output to only include variables of certain
3471 can filter their output to only include variables of certain
3468 types. Another suggestion by Matthew.
3472 types. Another suggestion by Matthew.
3469 (magic_whos): Added memory summaries in kb and Mb for arrays.
3473 (magic_whos): Added memory summaries in kb and Mb for arrays.
3470 (magic_who): Improve formatting (break lines every 9 vars).
3474 (magic_who): Improve formatting (break lines every 9 vars).
3471
3475
3472 2004-11-28 Fernando Perez <fperez@colorado.edu>
3476 2004-11-28 Fernando Perez <fperez@colorado.edu>
3473
3477
3474 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
3478 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
3475 cache when empty lines were present.
3479 cache when empty lines were present.
3476
3480
3477 2004-11-24 Fernando Perez <fperez@colorado.edu>
3481 2004-11-24 Fernando Perez <fperez@colorado.edu>
3478
3482
3479 * IPython/usage.py (__doc__): document the re-activated threading
3483 * IPython/usage.py (__doc__): document the re-activated threading
3480 options for WX and GTK.
3484 options for WX and GTK.
3481
3485
3482 2004-11-23 Fernando Perez <fperez@colorado.edu>
3486 2004-11-23 Fernando Perez <fperez@colorado.edu>
3483
3487
3484 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
3488 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
3485 the -wthread and -gthread options, along with a new -tk one to try
3489 the -wthread and -gthread options, along with a new -tk one to try
3486 and coordinate Tk threading with wx/gtk. The tk support is very
3490 and coordinate Tk threading with wx/gtk. The tk support is very
3487 platform dependent, since it seems to require Tcl and Tk to be
3491 platform dependent, since it seems to require Tcl and Tk to be
3488 built with threads (Fedora1/2 appears NOT to have it, but in
3492 built with threads (Fedora1/2 appears NOT to have it, but in
3489 Prabhu's Debian boxes it works OK). But even with some Tk
3493 Prabhu's Debian boxes it works OK). But even with some Tk
3490 limitations, this is a great improvement.
3494 limitations, this is a great improvement.
3491
3495
3492 * IPython/Prompts.py (prompt_specials_color): Added \t for time
3496 * IPython/Prompts.py (prompt_specials_color): Added \t for time
3493 info in user prompts. Patch by Prabhu.
3497 info in user prompts. Patch by Prabhu.
3494
3498
3495 2004-11-18 Fernando Perez <fperez@colorado.edu>
3499 2004-11-18 Fernando Perez <fperez@colorado.edu>
3496
3500
3497 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
3501 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
3498 EOFErrors and bail, to avoid infinite loops if a non-terminating
3502 EOFErrors and bail, to avoid infinite loops if a non-terminating
3499 file is fed into ipython. Patch submitted in issue 19 by user,
3503 file is fed into ipython. Patch submitted in issue 19 by user,
3500 many thanks.
3504 many thanks.
3501
3505
3502 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
3506 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
3503 autoquote/parens in continuation prompts, which can cause lots of
3507 autoquote/parens in continuation prompts, which can cause lots of
3504 problems. Closes roundup issue 20.
3508 problems. Closes roundup issue 20.
3505
3509
3506 2004-11-17 Fernando Perez <fperez@colorado.edu>
3510 2004-11-17 Fernando Perez <fperez@colorado.edu>
3507
3511
3508 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
3512 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
3509 reported as debian bug #280505. I'm not sure my local changelog
3513 reported as debian bug #280505. I'm not sure my local changelog
3510 entry has the proper debian format (Jack?).
3514 entry has the proper debian format (Jack?).
3511
3515
3512 2004-11-08 *** Released version 0.6.4
3516 2004-11-08 *** Released version 0.6.4
3513
3517
3514 2004-11-08 Fernando Perez <fperez@colorado.edu>
3518 2004-11-08 Fernando Perez <fperez@colorado.edu>
3515
3519
3516 * IPython/iplib.py (init_readline): Fix exit message for Windows
3520 * IPython/iplib.py (init_readline): Fix exit message for Windows
3517 when readline is active. Thanks to a report by Eric Jones
3521 when readline is active. Thanks to a report by Eric Jones
3518 <eric-AT-enthought.com>.
3522 <eric-AT-enthought.com>.
3519
3523
3520 2004-11-07 Fernando Perez <fperez@colorado.edu>
3524 2004-11-07 Fernando Perez <fperez@colorado.edu>
3521
3525
3522 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3526 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3523 sometimes seen by win2k/cygwin users.
3527 sometimes seen by win2k/cygwin users.
3524
3528
3525 2004-11-06 Fernando Perez <fperez@colorado.edu>
3529 2004-11-06 Fernando Perez <fperez@colorado.edu>
3526
3530
3527 * IPython/iplib.py (interact): Change the handling of %Exit from
3531 * IPython/iplib.py (interact): Change the handling of %Exit from
3528 trying to propagate a SystemExit to an internal ipython flag.
3532 trying to propagate a SystemExit to an internal ipython flag.
3529 This is less elegant than using Python's exception mechanism, but
3533 This is less elegant than using Python's exception mechanism, but
3530 I can't get that to work reliably with threads, so under -pylab
3534 I can't get that to work reliably with threads, so under -pylab
3531 %Exit was hanging IPython. Cross-thread exception handling is
3535 %Exit was hanging IPython. Cross-thread exception handling is
3532 really a bitch. Thaks to a bug report by Stephen Walton
3536 really a bitch. Thaks to a bug report by Stephen Walton
3533 <stephen.walton-AT-csun.edu>.
3537 <stephen.walton-AT-csun.edu>.
3534
3538
3535 2004-11-04 Fernando Perez <fperez@colorado.edu>
3539 2004-11-04 Fernando Perez <fperez@colorado.edu>
3536
3540
3537 * IPython/iplib.py (raw_input_original): store a pointer to the
3541 * IPython/iplib.py (raw_input_original): store a pointer to the
3538 true raw_input to harden against code which can modify it
3542 true raw_input to harden against code which can modify it
3539 (wx.py.PyShell does this and would otherwise crash ipython).
3543 (wx.py.PyShell does this and would otherwise crash ipython).
3540 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3544 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3541
3545
3542 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3546 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3543 Ctrl-C problem, which does not mess up the input line.
3547 Ctrl-C problem, which does not mess up the input line.
3544
3548
3545 2004-11-03 Fernando Perez <fperez@colorado.edu>
3549 2004-11-03 Fernando Perez <fperez@colorado.edu>
3546
3550
3547 * IPython/Release.py: Changed licensing to BSD, in all files.
3551 * IPython/Release.py: Changed licensing to BSD, in all files.
3548 (name): lowercase name for tarball/RPM release.
3552 (name): lowercase name for tarball/RPM release.
3549
3553
3550 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3554 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3551 use throughout ipython.
3555 use throughout ipython.
3552
3556
3553 * IPython/Magic.py (Magic._ofind): Switch to using the new
3557 * IPython/Magic.py (Magic._ofind): Switch to using the new
3554 OInspect.getdoc() function.
3558 OInspect.getdoc() function.
3555
3559
3556 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3560 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3557 of the line currently being canceled via Ctrl-C. It's extremely
3561 of the line currently being canceled via Ctrl-C. It's extremely
3558 ugly, but I don't know how to do it better (the problem is one of
3562 ugly, but I don't know how to do it better (the problem is one of
3559 handling cross-thread exceptions).
3563 handling cross-thread exceptions).
3560
3564
3561 2004-10-28 Fernando Perez <fperez@colorado.edu>
3565 2004-10-28 Fernando Perez <fperez@colorado.edu>
3562
3566
3563 * IPython/Shell.py (signal_handler): add signal handlers to trap
3567 * IPython/Shell.py (signal_handler): add signal handlers to trap
3564 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3568 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3565 report by Francesc Alted.
3569 report by Francesc Alted.
3566
3570
3567 2004-10-21 Fernando Perez <fperez@colorado.edu>
3571 2004-10-21 Fernando Perez <fperez@colorado.edu>
3568
3572
3569 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3573 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3570 to % for pysh syntax extensions.
3574 to % for pysh syntax extensions.
3571
3575
3572 2004-10-09 Fernando Perez <fperez@colorado.edu>
3576 2004-10-09 Fernando Perez <fperez@colorado.edu>
3573
3577
3574 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3578 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3575 arrays to print a more useful summary, without calling str(arr).
3579 arrays to print a more useful summary, without calling str(arr).
3576 This avoids the problem of extremely lengthy computations which
3580 This avoids the problem of extremely lengthy computations which
3577 occur if arr is large, and appear to the user as a system lockup
3581 occur if arr is large, and appear to the user as a system lockup
3578 with 100% cpu activity. After a suggestion by Kristian Sandberg
3582 with 100% cpu activity. After a suggestion by Kristian Sandberg
3579 <Kristian.Sandberg@colorado.edu>.
3583 <Kristian.Sandberg@colorado.edu>.
3580 (Magic.__init__): fix bug in global magic escapes not being
3584 (Magic.__init__): fix bug in global magic escapes not being
3581 correctly set.
3585 correctly set.
3582
3586
3583 2004-10-08 Fernando Perez <fperez@colorado.edu>
3587 2004-10-08 Fernando Perez <fperez@colorado.edu>
3584
3588
3585 * IPython/Magic.py (__license__): change to absolute imports of
3589 * IPython/Magic.py (__license__): change to absolute imports of
3586 ipython's own internal packages, to start adapting to the absolute
3590 ipython's own internal packages, to start adapting to the absolute
3587 import requirement of PEP-328.
3591 import requirement of PEP-328.
3588
3592
3589 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3593 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3590 files, and standardize author/license marks through the Release
3594 files, and standardize author/license marks through the Release
3591 module instead of having per/file stuff (except for files with
3595 module instead of having per/file stuff (except for files with
3592 particular licenses, like the MIT/PSF-licensed codes).
3596 particular licenses, like the MIT/PSF-licensed codes).
3593
3597
3594 * IPython/Debugger.py: remove dead code for python 2.1
3598 * IPython/Debugger.py: remove dead code for python 2.1
3595
3599
3596 2004-10-04 Fernando Perez <fperez@colorado.edu>
3600 2004-10-04 Fernando Perez <fperez@colorado.edu>
3597
3601
3598 * IPython/iplib.py (ipmagic): New function for accessing magics
3602 * IPython/iplib.py (ipmagic): New function for accessing magics
3599 via a normal python function call.
3603 via a normal python function call.
3600
3604
3601 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3605 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3602 from '@' to '%', to accomodate the new @decorator syntax of python
3606 from '@' to '%', to accomodate the new @decorator syntax of python
3603 2.4.
3607 2.4.
3604
3608
3605 2004-09-29 Fernando Perez <fperez@colorado.edu>
3609 2004-09-29 Fernando Perez <fperez@colorado.edu>
3606
3610
3607 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3611 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3608 matplotlib.use to prevent running scripts which try to switch
3612 matplotlib.use to prevent running scripts which try to switch
3609 interactive backends from within ipython. This will just crash
3613 interactive backends from within ipython. This will just crash
3610 the python interpreter, so we can't allow it (but a detailed error
3614 the python interpreter, so we can't allow it (but a detailed error
3611 is given to the user).
3615 is given to the user).
3612
3616
3613 2004-09-28 Fernando Perez <fperez@colorado.edu>
3617 2004-09-28 Fernando Perez <fperez@colorado.edu>
3614
3618
3615 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3619 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3616 matplotlib-related fixes so that using @run with non-matplotlib
3620 matplotlib-related fixes so that using @run with non-matplotlib
3617 scripts doesn't pop up spurious plot windows. This requires
3621 scripts doesn't pop up spurious plot windows. This requires
3618 matplotlib >= 0.63, where I had to make some changes as well.
3622 matplotlib >= 0.63, where I had to make some changes as well.
3619
3623
3620 * IPython/ipmaker.py (make_IPython): update version requirement to
3624 * IPython/ipmaker.py (make_IPython): update version requirement to
3621 python 2.2.
3625 python 2.2.
3622
3626
3623 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3627 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3624 banner arg for embedded customization.
3628 banner arg for embedded customization.
3625
3629
3626 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3630 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3627 explicit uses of __IP as the IPython's instance name. Now things
3631 explicit uses of __IP as the IPython's instance name. Now things
3628 are properly handled via the shell.name value. The actual code
3632 are properly handled via the shell.name value. The actual code
3629 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3633 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3630 is much better than before. I'll clean things completely when the
3634 is much better than before. I'll clean things completely when the
3631 magic stuff gets a real overhaul.
3635 magic stuff gets a real overhaul.
3632
3636
3633 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3637 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3634 minor changes to debian dir.
3638 minor changes to debian dir.
3635
3639
3636 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3640 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3637 pointer to the shell itself in the interactive namespace even when
3641 pointer to the shell itself in the interactive namespace even when
3638 a user-supplied dict is provided. This is needed for embedding
3642 a user-supplied dict is provided. This is needed for embedding
3639 purposes (found by tests with Michel Sanner).
3643 purposes (found by tests with Michel Sanner).
3640
3644
3641 2004-09-27 Fernando Perez <fperez@colorado.edu>
3645 2004-09-27 Fernando Perez <fperez@colorado.edu>
3642
3646
3643 * IPython/UserConfig/ipythonrc: remove []{} from
3647 * IPython/UserConfig/ipythonrc: remove []{} from
3644 readline_remove_delims, so that things like [modname.<TAB> do
3648 readline_remove_delims, so that things like [modname.<TAB> do
3645 proper completion. This disables [].TAB, but that's a less common
3649 proper completion. This disables [].TAB, but that's a less common
3646 case than module names in list comprehensions, for example.
3650 case than module names in list comprehensions, for example.
3647 Thanks to a report by Andrea Riciputi.
3651 Thanks to a report by Andrea Riciputi.
3648
3652
3649 2004-09-09 Fernando Perez <fperez@colorado.edu>
3653 2004-09-09 Fernando Perez <fperez@colorado.edu>
3650
3654
3651 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3655 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3652 blocking problems in win32 and osx. Fix by John.
3656 blocking problems in win32 and osx. Fix by John.
3653
3657
3654 2004-09-08 Fernando Perez <fperez@colorado.edu>
3658 2004-09-08 Fernando Perez <fperez@colorado.edu>
3655
3659
3656 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3660 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3657 for Win32 and OSX. Fix by John Hunter.
3661 for Win32 and OSX. Fix by John Hunter.
3658
3662
3659 2004-08-30 *** Released version 0.6.3
3663 2004-08-30 *** Released version 0.6.3
3660
3664
3661 2004-08-30 Fernando Perez <fperez@colorado.edu>
3665 2004-08-30 Fernando Perez <fperez@colorado.edu>
3662
3666
3663 * setup.py (isfile): Add manpages to list of dependent files to be
3667 * setup.py (isfile): Add manpages to list of dependent files to be
3664 updated.
3668 updated.
3665
3669
3666 2004-08-27 Fernando Perez <fperez@colorado.edu>
3670 2004-08-27 Fernando Perez <fperez@colorado.edu>
3667
3671
3668 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3672 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3669 for now. They don't really work with standalone WX/GTK code
3673 for now. They don't really work with standalone WX/GTK code
3670 (though matplotlib IS working fine with both of those backends).
3674 (though matplotlib IS working fine with both of those backends).
3671 This will neeed much more testing. I disabled most things with
3675 This will neeed much more testing. I disabled most things with
3672 comments, so turning it back on later should be pretty easy.
3676 comments, so turning it back on later should be pretty easy.
3673
3677
3674 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3678 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3675 autocalling of expressions like r'foo', by modifying the line
3679 autocalling of expressions like r'foo', by modifying the line
3676 split regexp. Closes
3680 split regexp. Closes
3677 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3681 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3678 Riley <ipythonbugs-AT-sabi.net>.
3682 Riley <ipythonbugs-AT-sabi.net>.
3679 (InteractiveShell.mainloop): honor --nobanner with banner
3683 (InteractiveShell.mainloop): honor --nobanner with banner
3680 extensions.
3684 extensions.
3681
3685
3682 * IPython/Shell.py: Significant refactoring of all classes, so
3686 * IPython/Shell.py: Significant refactoring of all classes, so
3683 that we can really support ALL matplotlib backends and threading
3687 that we can really support ALL matplotlib backends and threading
3684 models (John spotted a bug with Tk which required this). Now we
3688 models (John spotted a bug with Tk which required this). Now we
3685 should support single-threaded, WX-threads and GTK-threads, both
3689 should support single-threaded, WX-threads and GTK-threads, both
3686 for generic code and for matplotlib.
3690 for generic code and for matplotlib.
3687
3691
3688 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3692 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3689 -pylab, to simplify things for users. Will also remove the pylab
3693 -pylab, to simplify things for users. Will also remove the pylab
3690 profile, since now all of matplotlib configuration is directly
3694 profile, since now all of matplotlib configuration is directly
3691 handled here. This also reduces startup time.
3695 handled here. This also reduces startup time.
3692
3696
3693 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3697 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3694 shell wasn't being correctly called. Also in IPShellWX.
3698 shell wasn't being correctly called. Also in IPShellWX.
3695
3699
3696 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3700 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3697 fine-tune banner.
3701 fine-tune banner.
3698
3702
3699 * IPython/numutils.py (spike): Deprecate these spike functions,
3703 * IPython/numutils.py (spike): Deprecate these spike functions,
3700 delete (long deprecated) gnuplot_exec handler.
3704 delete (long deprecated) gnuplot_exec handler.
3701
3705
3702 2004-08-26 Fernando Perez <fperez@colorado.edu>
3706 2004-08-26 Fernando Perez <fperez@colorado.edu>
3703
3707
3704 * ipython.1: Update for threading options, plus some others which
3708 * ipython.1: Update for threading options, plus some others which
3705 were missing.
3709 were missing.
3706
3710
3707 * IPython/ipmaker.py (__call__): Added -wthread option for
3711 * IPython/ipmaker.py (__call__): Added -wthread option for
3708 wxpython thread handling. Make sure threading options are only
3712 wxpython thread handling. Make sure threading options are only
3709 valid at the command line.
3713 valid at the command line.
3710
3714
3711 * scripts/ipython: moved shell selection into a factory function
3715 * scripts/ipython: moved shell selection into a factory function
3712 in Shell.py, to keep the starter script to a minimum.
3716 in Shell.py, to keep the starter script to a minimum.
3713
3717
3714 2004-08-25 Fernando Perez <fperez@colorado.edu>
3718 2004-08-25 Fernando Perez <fperez@colorado.edu>
3715
3719
3716 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3720 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3717 John. Along with some recent changes he made to matplotlib, the
3721 John. Along with some recent changes he made to matplotlib, the
3718 next versions of both systems should work very well together.
3722 next versions of both systems should work very well together.
3719
3723
3720 2004-08-24 Fernando Perez <fperez@colorado.edu>
3724 2004-08-24 Fernando Perez <fperez@colorado.edu>
3721
3725
3722 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3726 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3723 tried to switch the profiling to using hotshot, but I'm getting
3727 tried to switch the profiling to using hotshot, but I'm getting
3724 strange errors from prof.runctx() there. I may be misreading the
3728 strange errors from prof.runctx() there. I may be misreading the
3725 docs, but it looks weird. For now the profiling code will
3729 docs, but it looks weird. For now the profiling code will
3726 continue to use the standard profiler.
3730 continue to use the standard profiler.
3727
3731
3728 2004-08-23 Fernando Perez <fperez@colorado.edu>
3732 2004-08-23 Fernando Perez <fperez@colorado.edu>
3729
3733
3730 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3734 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3731 threaded shell, by John Hunter. It's not quite ready yet, but
3735 threaded shell, by John Hunter. It's not quite ready yet, but
3732 close.
3736 close.
3733
3737
3734 2004-08-22 Fernando Perez <fperez@colorado.edu>
3738 2004-08-22 Fernando Perez <fperez@colorado.edu>
3735
3739
3736 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3740 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3737 in Magic and ultraTB.
3741 in Magic and ultraTB.
3738
3742
3739 * ipython.1: document threading options in manpage.
3743 * ipython.1: document threading options in manpage.
3740
3744
3741 * scripts/ipython: Changed name of -thread option to -gthread,
3745 * scripts/ipython: Changed name of -thread option to -gthread,
3742 since this is GTK specific. I want to leave the door open for a
3746 since this is GTK specific. I want to leave the door open for a
3743 -wthread option for WX, which will most likely be necessary. This
3747 -wthread option for WX, which will most likely be necessary. This
3744 change affects usage and ipmaker as well.
3748 change affects usage and ipmaker as well.
3745
3749
3746 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3750 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3747 handle the matplotlib shell issues. Code by John Hunter
3751 handle the matplotlib shell issues. Code by John Hunter
3748 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3752 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3749 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3753 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3750 broken (and disabled for end users) for now, but it puts the
3754 broken (and disabled for end users) for now, but it puts the
3751 infrastructure in place.
3755 infrastructure in place.
3752
3756
3753 2004-08-21 Fernando Perez <fperez@colorado.edu>
3757 2004-08-21 Fernando Perez <fperez@colorado.edu>
3754
3758
3755 * ipythonrc-pylab: Add matplotlib support.
3759 * ipythonrc-pylab: Add matplotlib support.
3756
3760
3757 * matplotlib_config.py: new files for matplotlib support, part of
3761 * matplotlib_config.py: new files for matplotlib support, part of
3758 the pylab profile.
3762 the pylab profile.
3759
3763
3760 * IPython/usage.py (__doc__): documented the threading options.
3764 * IPython/usage.py (__doc__): documented the threading options.
3761
3765
3762 2004-08-20 Fernando Perez <fperez@colorado.edu>
3766 2004-08-20 Fernando Perez <fperez@colorado.edu>
3763
3767
3764 * ipython: Modified the main calling routine to handle the -thread
3768 * ipython: Modified the main calling routine to handle the -thread
3765 and -mpthread options. This needs to be done as a top-level hack,
3769 and -mpthread options. This needs to be done as a top-level hack,
3766 because it determines which class to instantiate for IPython
3770 because it determines which class to instantiate for IPython
3767 itself.
3771 itself.
3768
3772
3769 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3773 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3770 classes to support multithreaded GTK operation without blocking,
3774 classes to support multithreaded GTK operation without blocking,
3771 and matplotlib with all backends. This is a lot of still very
3775 and matplotlib with all backends. This is a lot of still very
3772 experimental code, and threads are tricky. So it may still have a
3776 experimental code, and threads are tricky. So it may still have a
3773 few rough edges... This code owes a lot to
3777 few rough edges... This code owes a lot to
3774 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3778 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3775 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3779 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3776 to John Hunter for all the matplotlib work.
3780 to John Hunter for all the matplotlib work.
3777
3781
3778 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3782 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3779 options for gtk thread and matplotlib support.
3783 options for gtk thread and matplotlib support.
3780
3784
3781 2004-08-16 Fernando Perez <fperez@colorado.edu>
3785 2004-08-16 Fernando Perez <fperez@colorado.edu>
3782
3786
3783 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3787 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3784 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3788 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3785 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3789 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3786
3790
3787 2004-08-11 Fernando Perez <fperez@colorado.edu>
3791 2004-08-11 Fernando Perez <fperez@colorado.edu>
3788
3792
3789 * setup.py (isfile): Fix build so documentation gets updated for
3793 * setup.py (isfile): Fix build so documentation gets updated for
3790 rpms (it was only done for .tgz builds).
3794 rpms (it was only done for .tgz builds).
3791
3795
3792 2004-08-10 Fernando Perez <fperez@colorado.edu>
3796 2004-08-10 Fernando Perez <fperez@colorado.edu>
3793
3797
3794 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3798 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3795
3799
3796 * iplib.py : Silence syntax error exceptions in tab-completion.
3800 * iplib.py : Silence syntax error exceptions in tab-completion.
3797
3801
3798 2004-08-05 Fernando Perez <fperez@colorado.edu>
3802 2004-08-05 Fernando Perez <fperez@colorado.edu>
3799
3803
3800 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3804 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3801 'color off' mark for continuation prompts. This was causing long
3805 'color off' mark for continuation prompts. This was causing long
3802 continuation lines to mis-wrap.
3806 continuation lines to mis-wrap.
3803
3807
3804 2004-08-01 Fernando Perez <fperez@colorado.edu>
3808 2004-08-01 Fernando Perez <fperez@colorado.edu>
3805
3809
3806 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3810 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3807 for building ipython to be a parameter. All this is necessary
3811 for building ipython to be a parameter. All this is necessary
3808 right now to have a multithreaded version, but this insane
3812 right now to have a multithreaded version, but this insane
3809 non-design will be cleaned up soon. For now, it's a hack that
3813 non-design will be cleaned up soon. For now, it's a hack that
3810 works.
3814 works.
3811
3815
3812 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3816 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3813 args in various places. No bugs so far, but it's a dangerous
3817 args in various places. No bugs so far, but it's a dangerous
3814 practice.
3818 practice.
3815
3819
3816 2004-07-31 Fernando Perez <fperez@colorado.edu>
3820 2004-07-31 Fernando Perez <fperez@colorado.edu>
3817
3821
3818 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3822 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3819 fix completion of files with dots in their names under most
3823 fix completion of files with dots in their names under most
3820 profiles (pysh was OK because the completion order is different).
3824 profiles (pysh was OK because the completion order is different).
3821
3825
3822 2004-07-27 Fernando Perez <fperez@colorado.edu>
3826 2004-07-27 Fernando Perez <fperez@colorado.edu>
3823
3827
3824 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3828 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3825 keywords manually, b/c the one in keyword.py was removed in python
3829 keywords manually, b/c the one in keyword.py was removed in python
3826 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3830 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3827 This is NOT a bug under python 2.3 and earlier.
3831 This is NOT a bug under python 2.3 and earlier.
3828
3832
3829 2004-07-26 Fernando Perez <fperez@colorado.edu>
3833 2004-07-26 Fernando Perez <fperez@colorado.edu>
3830
3834
3831 * IPython/ultraTB.py (VerboseTB.text): Add another
3835 * IPython/ultraTB.py (VerboseTB.text): Add another
3832 linecache.checkcache() call to try to prevent inspect.py from
3836 linecache.checkcache() call to try to prevent inspect.py from
3833 crashing under python 2.3. I think this fixes
3837 crashing under python 2.3. I think this fixes
3834 http://www.scipy.net/roundup/ipython/issue17.
3838 http://www.scipy.net/roundup/ipython/issue17.
3835
3839
3836 2004-07-26 *** Released version 0.6.2
3840 2004-07-26 *** Released version 0.6.2
3837
3841
3838 2004-07-26 Fernando Perez <fperez@colorado.edu>
3842 2004-07-26 Fernando Perez <fperez@colorado.edu>
3839
3843
3840 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3844 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3841 fail for any number.
3845 fail for any number.
3842 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3846 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3843 empty bookmarks.
3847 empty bookmarks.
3844
3848
3845 2004-07-26 *** Released version 0.6.1
3849 2004-07-26 *** Released version 0.6.1
3846
3850
3847 2004-07-26 Fernando Perez <fperez@colorado.edu>
3851 2004-07-26 Fernando Perez <fperez@colorado.edu>
3848
3852
3849 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3853 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3850
3854
3851 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3855 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3852 escaping '()[]{}' in filenames.
3856 escaping '()[]{}' in filenames.
3853
3857
3854 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3858 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3855 Python 2.2 users who lack a proper shlex.split.
3859 Python 2.2 users who lack a proper shlex.split.
3856
3860
3857 2004-07-19 Fernando Perez <fperez@colorado.edu>
3861 2004-07-19 Fernando Perez <fperez@colorado.edu>
3858
3862
3859 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3863 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3860 for reading readline's init file. I follow the normal chain:
3864 for reading readline's init file. I follow the normal chain:
3861 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3865 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3862 report by Mike Heeter. This closes
3866 report by Mike Heeter. This closes
3863 http://www.scipy.net/roundup/ipython/issue16.
3867 http://www.scipy.net/roundup/ipython/issue16.
3864
3868
3865 2004-07-18 Fernando Perez <fperez@colorado.edu>
3869 2004-07-18 Fernando Perez <fperez@colorado.edu>
3866
3870
3867 * IPython/iplib.py (__init__): Add better handling of '\' under
3871 * IPython/iplib.py (__init__): Add better handling of '\' under
3868 Win32 for filenames. After a patch by Ville.
3872 Win32 for filenames. After a patch by Ville.
3869
3873
3870 2004-07-17 Fernando Perez <fperez@colorado.edu>
3874 2004-07-17 Fernando Perez <fperez@colorado.edu>
3871
3875
3872 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3876 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3873 autocalling would be triggered for 'foo is bar' if foo is
3877 autocalling would be triggered for 'foo is bar' if foo is
3874 callable. I also cleaned up the autocall detection code to use a
3878 callable. I also cleaned up the autocall detection code to use a
3875 regexp, which is faster. Bug reported by Alexander Schmolck.
3879 regexp, which is faster. Bug reported by Alexander Schmolck.
3876
3880
3877 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3881 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3878 '?' in them would confuse the help system. Reported by Alex
3882 '?' in them would confuse the help system. Reported by Alex
3879 Schmolck.
3883 Schmolck.
3880
3884
3881 2004-07-16 Fernando Perez <fperez@colorado.edu>
3885 2004-07-16 Fernando Perez <fperez@colorado.edu>
3882
3886
3883 * IPython/GnuplotInteractive.py (__all__): added plot2.
3887 * IPython/GnuplotInteractive.py (__all__): added plot2.
3884
3888
3885 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3889 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3886 plotting dictionaries, lists or tuples of 1d arrays.
3890 plotting dictionaries, lists or tuples of 1d arrays.
3887
3891
3888 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3892 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3889 optimizations.
3893 optimizations.
3890
3894
3891 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3895 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3892 the information which was there from Janko's original IPP code:
3896 the information which was there from Janko's original IPP code:
3893
3897
3894 03.05.99 20:53 porto.ifm.uni-kiel.de
3898 03.05.99 20:53 porto.ifm.uni-kiel.de
3895 --Started changelog.
3899 --Started changelog.
3896 --make clear do what it say it does
3900 --make clear do what it say it does
3897 --added pretty output of lines from inputcache
3901 --added pretty output of lines from inputcache
3898 --Made Logger a mixin class, simplifies handling of switches
3902 --Made Logger a mixin class, simplifies handling of switches
3899 --Added own completer class. .string<TAB> expands to last history
3903 --Added own completer class. .string<TAB> expands to last history
3900 line which starts with string. The new expansion is also present
3904 line which starts with string. The new expansion is also present
3901 with Ctrl-r from the readline library. But this shows, who this
3905 with Ctrl-r from the readline library. But this shows, who this
3902 can be done for other cases.
3906 can be done for other cases.
3903 --Added convention that all shell functions should accept a
3907 --Added convention that all shell functions should accept a
3904 parameter_string This opens the door for different behaviour for
3908 parameter_string This opens the door for different behaviour for
3905 each function. @cd is a good example of this.
3909 each function. @cd is a good example of this.
3906
3910
3907 04.05.99 12:12 porto.ifm.uni-kiel.de
3911 04.05.99 12:12 porto.ifm.uni-kiel.de
3908 --added logfile rotation
3912 --added logfile rotation
3909 --added new mainloop method which freezes first the namespace
3913 --added new mainloop method which freezes first the namespace
3910
3914
3911 07.05.99 21:24 porto.ifm.uni-kiel.de
3915 07.05.99 21:24 porto.ifm.uni-kiel.de
3912 --added the docreader classes. Now there is a help system.
3916 --added the docreader classes. Now there is a help system.
3913 -This is only a first try. Currently it's not easy to put new
3917 -This is only a first try. Currently it's not easy to put new
3914 stuff in the indices. But this is the way to go. Info would be
3918 stuff in the indices. But this is the way to go. Info would be
3915 better, but HTML is every where and not everybody has an info
3919 better, but HTML is every where and not everybody has an info
3916 system installed and it's not so easy to change html-docs to info.
3920 system installed and it's not so easy to change html-docs to info.
3917 --added global logfile option
3921 --added global logfile option
3918 --there is now a hook for object inspection method pinfo needs to
3922 --there is now a hook for object inspection method pinfo needs to
3919 be provided for this. Can be reached by two '??'.
3923 be provided for this. Can be reached by two '??'.
3920
3924
3921 08.05.99 20:51 porto.ifm.uni-kiel.de
3925 08.05.99 20:51 porto.ifm.uni-kiel.de
3922 --added a README
3926 --added a README
3923 --bug in rc file. Something has changed so functions in the rc
3927 --bug in rc file. Something has changed so functions in the rc
3924 file need to reference the shell and not self. Not clear if it's a
3928 file need to reference the shell and not self. Not clear if it's a
3925 bug or feature.
3929 bug or feature.
3926 --changed rc file for new behavior
3930 --changed rc file for new behavior
3927
3931
3928 2004-07-15 Fernando Perez <fperez@colorado.edu>
3932 2004-07-15 Fernando Perez <fperez@colorado.edu>
3929
3933
3930 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3934 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3931 cache was falling out of sync in bizarre manners when multi-line
3935 cache was falling out of sync in bizarre manners when multi-line
3932 input was present. Minor optimizations and cleanup.
3936 input was present. Minor optimizations and cleanup.
3933
3937
3934 (Logger): Remove old Changelog info for cleanup. This is the
3938 (Logger): Remove old Changelog info for cleanup. This is the
3935 information which was there from Janko's original code:
3939 information which was there from Janko's original code:
3936
3940
3937 Changes to Logger: - made the default log filename a parameter
3941 Changes to Logger: - made the default log filename a parameter
3938
3942
3939 - put a check for lines beginning with !@? in log(). Needed
3943 - put a check for lines beginning with !@? in log(). Needed
3940 (even if the handlers properly log their lines) for mid-session
3944 (even if the handlers properly log their lines) for mid-session
3941 logging activation to work properly. Without this, lines logged
3945 logging activation to work properly. Without this, lines logged
3942 in mid session, which get read from the cache, would end up
3946 in mid session, which get read from the cache, would end up
3943 'bare' (with !@? in the open) in the log. Now they are caught
3947 'bare' (with !@? in the open) in the log. Now they are caught
3944 and prepended with a #.
3948 and prepended with a #.
3945
3949
3946 * IPython/iplib.py (InteractiveShell.init_readline): added check
3950 * IPython/iplib.py (InteractiveShell.init_readline): added check
3947 in case MagicCompleter fails to be defined, so we don't crash.
3951 in case MagicCompleter fails to be defined, so we don't crash.
3948
3952
3949 2004-07-13 Fernando Perez <fperez@colorado.edu>
3953 2004-07-13 Fernando Perez <fperez@colorado.edu>
3950
3954
3951 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3955 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3952 of EPS if the requested filename ends in '.eps'.
3956 of EPS if the requested filename ends in '.eps'.
3953
3957
3954 2004-07-04 Fernando Perez <fperez@colorado.edu>
3958 2004-07-04 Fernando Perez <fperez@colorado.edu>
3955
3959
3956 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3960 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3957 escaping of quotes when calling the shell.
3961 escaping of quotes when calling the shell.
3958
3962
3959 2004-07-02 Fernando Perez <fperez@colorado.edu>
3963 2004-07-02 Fernando Perez <fperez@colorado.edu>
3960
3964
3961 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3965 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3962 gettext not working because we were clobbering '_'. Fixes
3966 gettext not working because we were clobbering '_'. Fixes
3963 http://www.scipy.net/roundup/ipython/issue6.
3967 http://www.scipy.net/roundup/ipython/issue6.
3964
3968
3965 2004-07-01 Fernando Perez <fperez@colorado.edu>
3969 2004-07-01 Fernando Perez <fperez@colorado.edu>
3966
3970
3967 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3971 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3968 into @cd. Patch by Ville.
3972 into @cd. Patch by Ville.
3969
3973
3970 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3974 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3971 new function to store things after ipmaker runs. Patch by Ville.
3975 new function to store things after ipmaker runs. Patch by Ville.
3972 Eventually this will go away once ipmaker is removed and the class
3976 Eventually this will go away once ipmaker is removed and the class
3973 gets cleaned up, but for now it's ok. Key functionality here is
3977 gets cleaned up, but for now it's ok. Key functionality here is
3974 the addition of the persistent storage mechanism, a dict for
3978 the addition of the persistent storage mechanism, a dict for
3975 keeping data across sessions (for now just bookmarks, but more can
3979 keeping data across sessions (for now just bookmarks, but more can
3976 be implemented later).
3980 be implemented later).
3977
3981
3978 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3982 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3979 persistent across sections. Patch by Ville, I modified it
3983 persistent across sections. Patch by Ville, I modified it
3980 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3984 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3981 added a '-l' option to list all bookmarks.
3985 added a '-l' option to list all bookmarks.
3982
3986
3983 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3987 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3984 center for cleanup. Registered with atexit.register(). I moved
3988 center for cleanup. Registered with atexit.register(). I moved
3985 here the old exit_cleanup(). After a patch by Ville.
3989 here the old exit_cleanup(). After a patch by Ville.
3986
3990
3987 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3991 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3988 characters in the hacked shlex_split for python 2.2.
3992 characters in the hacked shlex_split for python 2.2.
3989
3993
3990 * IPython/iplib.py (file_matches): more fixes to filenames with
3994 * IPython/iplib.py (file_matches): more fixes to filenames with
3991 whitespace in them. It's not perfect, but limitations in python's
3995 whitespace in them. It's not perfect, but limitations in python's
3992 readline make it impossible to go further.
3996 readline make it impossible to go further.
3993
3997
3994 2004-06-29 Fernando Perez <fperez@colorado.edu>
3998 2004-06-29 Fernando Perez <fperez@colorado.edu>
3995
3999
3996 * IPython/iplib.py (file_matches): escape whitespace correctly in
4000 * IPython/iplib.py (file_matches): escape whitespace correctly in
3997 filename completions. Bug reported by Ville.
4001 filename completions. Bug reported by Ville.
3998
4002
3999 2004-06-28 Fernando Perez <fperez@colorado.edu>
4003 2004-06-28 Fernando Perez <fperez@colorado.edu>
4000
4004
4001 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
4005 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
4002 the history file will be called 'history-PROFNAME' (or just
4006 the history file will be called 'history-PROFNAME' (or just
4003 'history' if no profile is loaded). I was getting annoyed at
4007 'history' if no profile is loaded). I was getting annoyed at
4004 getting my Numerical work history clobbered by pysh sessions.
4008 getting my Numerical work history clobbered by pysh sessions.
4005
4009
4006 * IPython/iplib.py (InteractiveShell.__init__): Internal
4010 * IPython/iplib.py (InteractiveShell.__init__): Internal
4007 getoutputerror() function so that we can honor the system_verbose
4011 getoutputerror() function so that we can honor the system_verbose
4008 flag for _all_ system calls. I also added escaping of #
4012 flag for _all_ system calls. I also added escaping of #
4009 characters here to avoid confusing Itpl.
4013 characters here to avoid confusing Itpl.
4010
4014
4011 * IPython/Magic.py (shlex_split): removed call to shell in
4015 * IPython/Magic.py (shlex_split): removed call to shell in
4012 parse_options and replaced it with shlex.split(). The annoying
4016 parse_options and replaced it with shlex.split(). The annoying
4013 part was that in Python 2.2, shlex.split() doesn't exist, so I had
4017 part was that in Python 2.2, shlex.split() doesn't exist, so I had
4014 to backport it from 2.3, with several frail hacks (the shlex
4018 to backport it from 2.3, with several frail hacks (the shlex
4015 module is rather limited in 2.2). Thanks to a suggestion by Ville
4019 module is rather limited in 2.2). Thanks to a suggestion by Ville
4016 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
4020 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
4017 problem.
4021 problem.
4018
4022
4019 (Magic.magic_system_verbose): new toggle to print the actual
4023 (Magic.magic_system_verbose): new toggle to print the actual
4020 system calls made by ipython. Mainly for debugging purposes.
4024 system calls made by ipython. Mainly for debugging purposes.
4021
4025
4022 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
4026 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
4023 doesn't support persistence. Reported (and fix suggested) by
4027 doesn't support persistence. Reported (and fix suggested) by
4024 Travis Caldwell <travis_caldwell2000@yahoo.com>.
4028 Travis Caldwell <travis_caldwell2000@yahoo.com>.
4025
4029
4026 2004-06-26 Fernando Perez <fperez@colorado.edu>
4030 2004-06-26 Fernando Perez <fperez@colorado.edu>
4027
4031
4028 * IPython/Logger.py (Logger.log): fix to handle correctly empty
4032 * IPython/Logger.py (Logger.log): fix to handle correctly empty
4029 continue prompts.
4033 continue prompts.
4030
4034
4031 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
4035 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
4032 function (basically a big docstring) and a few more things here to
4036 function (basically a big docstring) and a few more things here to
4033 speedup startup. pysh.py is now very lightweight. We want because
4037 speedup startup. pysh.py is now very lightweight. We want because
4034 it gets execfile'd, while InterpreterExec gets imported, so
4038 it gets execfile'd, while InterpreterExec gets imported, so
4035 byte-compilation saves time.
4039 byte-compilation saves time.
4036
4040
4037 2004-06-25 Fernando Perez <fperez@colorado.edu>
4041 2004-06-25 Fernando Perez <fperez@colorado.edu>
4038
4042
4039 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
4043 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
4040 -NUM', which was recently broken.
4044 -NUM', which was recently broken.
4041
4045
4042 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
4046 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
4043 in multi-line input (but not !!, which doesn't make sense there).
4047 in multi-line input (but not !!, which doesn't make sense there).
4044
4048
4045 * IPython/UserConfig/ipythonrc: made autoindent on by default.
4049 * IPython/UserConfig/ipythonrc: made autoindent on by default.
4046 It's just too useful, and people can turn it off in the less
4050 It's just too useful, and people can turn it off in the less
4047 common cases where it's a problem.
4051 common cases where it's a problem.
4048
4052
4049 2004-06-24 Fernando Perez <fperez@colorado.edu>
4053 2004-06-24 Fernando Perez <fperez@colorado.edu>
4050
4054
4051 * IPython/iplib.py (InteractiveShell._prefilter): big change -
4055 * IPython/iplib.py (InteractiveShell._prefilter): big change -
4052 special syntaxes (like alias calling) is now allied in multi-line
4056 special syntaxes (like alias calling) is now allied in multi-line
4053 input. This is still _very_ experimental, but it's necessary for
4057 input. This is still _very_ experimental, but it's necessary for
4054 efficient shell usage combining python looping syntax with system
4058 efficient shell usage combining python looping syntax with system
4055 calls. For now it's restricted to aliases, I don't think it
4059 calls. For now it's restricted to aliases, I don't think it
4056 really even makes sense to have this for magics.
4060 really even makes sense to have this for magics.
4057
4061
4058 2004-06-23 Fernando Perez <fperez@colorado.edu>
4062 2004-06-23 Fernando Perez <fperez@colorado.edu>
4059
4063
4060 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
4064 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
4061 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
4065 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
4062
4066
4063 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
4067 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
4064 extensions under Windows (after code sent by Gary Bishop). The
4068 extensions under Windows (after code sent by Gary Bishop). The
4065 extensions considered 'executable' are stored in IPython's rc
4069 extensions considered 'executable' are stored in IPython's rc
4066 structure as win_exec_ext.
4070 structure as win_exec_ext.
4067
4071
4068 * IPython/genutils.py (shell): new function, like system() but
4072 * IPython/genutils.py (shell): new function, like system() but
4069 without return value. Very useful for interactive shell work.
4073 without return value. Very useful for interactive shell work.
4070
4074
4071 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
4075 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
4072 delete aliases.
4076 delete aliases.
4073
4077
4074 * IPython/iplib.py (InteractiveShell.alias_table_update): make
4078 * IPython/iplib.py (InteractiveShell.alias_table_update): make
4075 sure that the alias table doesn't contain python keywords.
4079 sure that the alias table doesn't contain python keywords.
4076
4080
4077 2004-06-21 Fernando Perez <fperez@colorado.edu>
4081 2004-06-21 Fernando Perez <fperez@colorado.edu>
4078
4082
4079 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
4083 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
4080 non-existent items are found in $PATH. Reported by Thorsten.
4084 non-existent items are found in $PATH. Reported by Thorsten.
4081
4085
4082 2004-06-20 Fernando Perez <fperez@colorado.edu>
4086 2004-06-20 Fernando Perez <fperez@colorado.edu>
4083
4087
4084 * IPython/iplib.py (complete): modified the completer so that the
4088 * IPython/iplib.py (complete): modified the completer so that the
4085 order of priorities can be easily changed at runtime.
4089 order of priorities can be easily changed at runtime.
4086
4090
4087 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
4091 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
4088 Modified to auto-execute all lines beginning with '~', '/' or '.'.
4092 Modified to auto-execute all lines beginning with '~', '/' or '.'.
4089
4093
4090 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
4094 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
4091 expand Python variables prepended with $ in all system calls. The
4095 expand Python variables prepended with $ in all system calls. The
4092 same was done to InteractiveShell.handle_shell_escape. Now all
4096 same was done to InteractiveShell.handle_shell_escape. Now all
4093 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
4097 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
4094 expansion of python variables and expressions according to the
4098 expansion of python variables and expressions according to the
4095 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
4099 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
4096
4100
4097 Though PEP-215 has been rejected, a similar (but simpler) one
4101 Though PEP-215 has been rejected, a similar (but simpler) one
4098 seems like it will go into Python 2.4, PEP-292 -
4102 seems like it will go into Python 2.4, PEP-292 -
4099 http://www.python.org/peps/pep-0292.html.
4103 http://www.python.org/peps/pep-0292.html.
4100
4104
4101 I'll keep the full syntax of PEP-215, since IPython has since the
4105 I'll keep the full syntax of PEP-215, since IPython has since the
4102 start used Ka-Ping Yee's reference implementation discussed there
4106 start used Ka-Ping Yee's reference implementation discussed there
4103 (Itpl), and I actually like the powerful semantics it offers.
4107 (Itpl), and I actually like the powerful semantics it offers.
4104
4108
4105 In order to access normal shell variables, the $ has to be escaped
4109 In order to access normal shell variables, the $ has to be escaped
4106 via an extra $. For example:
4110 via an extra $. For example:
4107
4111
4108 In [7]: PATH='a python variable'
4112 In [7]: PATH='a python variable'
4109
4113
4110 In [8]: !echo $PATH
4114 In [8]: !echo $PATH
4111 a python variable
4115 a python variable
4112
4116
4113 In [9]: !echo $$PATH
4117 In [9]: !echo $$PATH
4114 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
4118 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
4115
4119
4116 (Magic.parse_options): escape $ so the shell doesn't evaluate
4120 (Magic.parse_options): escape $ so the shell doesn't evaluate
4117 things prematurely.
4121 things prematurely.
4118
4122
4119 * IPython/iplib.py (InteractiveShell.call_alias): added the
4123 * IPython/iplib.py (InteractiveShell.call_alias): added the
4120 ability for aliases to expand python variables via $.
4124 ability for aliases to expand python variables via $.
4121
4125
4122 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
4126 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
4123 system, now there's a @rehash/@rehashx pair of magics. These work
4127 system, now there's a @rehash/@rehashx pair of magics. These work
4124 like the csh rehash command, and can be invoked at any time. They
4128 like the csh rehash command, and can be invoked at any time. They
4125 build a table of aliases to everything in the user's $PATH
4129 build a table of aliases to everything in the user's $PATH
4126 (@rehash uses everything, @rehashx is slower but only adds
4130 (@rehash uses everything, @rehashx is slower but only adds
4127 executable files). With this, the pysh.py-based shell profile can
4131 executable files). With this, the pysh.py-based shell profile can
4128 now simply call rehash upon startup, and full access to all
4132 now simply call rehash upon startup, and full access to all
4129 programs in the user's path is obtained.
4133 programs in the user's path is obtained.
4130
4134
4131 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
4135 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
4132 functionality is now fully in place. I removed the old dynamic
4136 functionality is now fully in place. I removed the old dynamic
4133 code generation based approach, in favor of a much lighter one
4137 code generation based approach, in favor of a much lighter one
4134 based on a simple dict. The advantage is that this allows me to
4138 based on a simple dict. The advantage is that this allows me to
4135 now have thousands of aliases with negligible cost (unthinkable
4139 now have thousands of aliases with negligible cost (unthinkable
4136 with the old system).
4140 with the old system).
4137
4141
4138 2004-06-19 Fernando Perez <fperez@colorado.edu>
4142 2004-06-19 Fernando Perez <fperez@colorado.edu>
4139
4143
4140 * IPython/iplib.py (__init__): extended MagicCompleter class to
4144 * IPython/iplib.py (__init__): extended MagicCompleter class to
4141 also complete (last in priority) on user aliases.
4145 also complete (last in priority) on user aliases.
4142
4146
4143 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
4147 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
4144 call to eval.
4148 call to eval.
4145 (ItplNS.__init__): Added a new class which functions like Itpl,
4149 (ItplNS.__init__): Added a new class which functions like Itpl,
4146 but allows configuring the namespace for the evaluation to occur
4150 but allows configuring the namespace for the evaluation to occur
4147 in.
4151 in.
4148
4152
4149 2004-06-18 Fernando Perez <fperez@colorado.edu>
4153 2004-06-18 Fernando Perez <fperez@colorado.edu>
4150
4154
4151 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
4155 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
4152 better message when 'exit' or 'quit' are typed (a common newbie
4156 better message when 'exit' or 'quit' are typed (a common newbie
4153 confusion).
4157 confusion).
4154
4158
4155 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
4159 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
4156 check for Windows users.
4160 check for Windows users.
4157
4161
4158 * IPython/iplib.py (InteractiveShell.user_setup): removed
4162 * IPython/iplib.py (InteractiveShell.user_setup): removed
4159 disabling of colors for Windows. I'll test at runtime and issue a
4163 disabling of colors for Windows. I'll test at runtime and issue a
4160 warning if Gary's readline isn't found, as to nudge users to
4164 warning if Gary's readline isn't found, as to nudge users to
4161 download it.
4165 download it.
4162
4166
4163 2004-06-16 Fernando Perez <fperez@colorado.edu>
4167 2004-06-16 Fernando Perez <fperez@colorado.edu>
4164
4168
4165 * IPython/genutils.py (Stream.__init__): changed to print errors
4169 * IPython/genutils.py (Stream.__init__): changed to print errors
4166 to sys.stderr. I had a circular dependency here. Now it's
4170 to sys.stderr. I had a circular dependency here. Now it's
4167 possible to run ipython as IDLE's shell (consider this pre-alpha,
4171 possible to run ipython as IDLE's shell (consider this pre-alpha,
4168 since true stdout things end up in the starting terminal instead
4172 since true stdout things end up in the starting terminal instead
4169 of IDLE's out).
4173 of IDLE's out).
4170
4174
4171 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
4175 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
4172 users who haven't # updated their prompt_in2 definitions. Remove
4176 users who haven't # updated their prompt_in2 definitions. Remove
4173 eventually.
4177 eventually.
4174 (multiple_replace): added credit to original ASPN recipe.
4178 (multiple_replace): added credit to original ASPN recipe.
4175
4179
4176 2004-06-15 Fernando Perez <fperez@colorado.edu>
4180 2004-06-15 Fernando Perez <fperez@colorado.edu>
4177
4181
4178 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
4182 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
4179 list of auto-defined aliases.
4183 list of auto-defined aliases.
4180
4184
4181 2004-06-13 Fernando Perez <fperez@colorado.edu>
4185 2004-06-13 Fernando Perez <fperez@colorado.edu>
4182
4186
4183 * setup.py (scriptfiles): Don't trigger win_post_install unless an
4187 * setup.py (scriptfiles): Don't trigger win_post_install unless an
4184 install was really requested (so setup.py can be used for other
4188 install was really requested (so setup.py can be used for other
4185 things under Windows).
4189 things under Windows).
4186
4190
4187 2004-06-10 Fernando Perez <fperez@colorado.edu>
4191 2004-06-10 Fernando Perez <fperez@colorado.edu>
4188
4192
4189 * IPython/Logger.py (Logger.create_log): Manually remove any old
4193 * IPython/Logger.py (Logger.create_log): Manually remove any old
4190 backup, since os.remove may fail under Windows. Fixes bug
4194 backup, since os.remove may fail under Windows. Fixes bug
4191 reported by Thorsten.
4195 reported by Thorsten.
4192
4196
4193 2004-06-09 Fernando Perez <fperez@colorado.edu>
4197 2004-06-09 Fernando Perez <fperez@colorado.edu>
4194
4198
4195 * examples/example-embed.py: fixed all references to %n (replaced
4199 * examples/example-embed.py: fixed all references to %n (replaced
4196 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
4200 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
4197 for all examples and the manual as well.
4201 for all examples and the manual as well.
4198
4202
4199 2004-06-08 Fernando Perez <fperez@colorado.edu>
4203 2004-06-08 Fernando Perez <fperez@colorado.edu>
4200
4204
4201 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
4205 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
4202 alignment and color management. All 3 prompt subsystems now
4206 alignment and color management. All 3 prompt subsystems now
4203 inherit from BasePrompt.
4207 inherit from BasePrompt.
4204
4208
4205 * tools/release: updates for windows installer build and tag rpms
4209 * tools/release: updates for windows installer build and tag rpms
4206 with python version (since paths are fixed).
4210 with python version (since paths are fixed).
4207
4211
4208 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
4212 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
4209 which will become eventually obsolete. Also fixed the default
4213 which will become eventually obsolete. Also fixed the default
4210 prompt_in2 to use \D, so at least new users start with the correct
4214 prompt_in2 to use \D, so at least new users start with the correct
4211 defaults.
4215 defaults.
4212 WARNING: Users with existing ipythonrc files will need to apply
4216 WARNING: Users with existing ipythonrc files will need to apply
4213 this fix manually!
4217 this fix manually!
4214
4218
4215 * setup.py: make windows installer (.exe). This is finally the
4219 * setup.py: make windows installer (.exe). This is finally the
4216 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
4220 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
4217 which I hadn't included because it required Python 2.3 (or recent
4221 which I hadn't included because it required Python 2.3 (or recent
4218 distutils).
4222 distutils).
4219
4223
4220 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
4224 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
4221 usage of new '\D' escape.
4225 usage of new '\D' escape.
4222
4226
4223 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
4227 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
4224 lacks os.getuid())
4228 lacks os.getuid())
4225 (CachedOutput.set_colors): Added the ability to turn coloring
4229 (CachedOutput.set_colors): Added the ability to turn coloring
4226 on/off with @colors even for manually defined prompt colors. It
4230 on/off with @colors even for manually defined prompt colors. It
4227 uses a nasty global, but it works safely and via the generic color
4231 uses a nasty global, but it works safely and via the generic color
4228 handling mechanism.
4232 handling mechanism.
4229 (Prompt2.__init__): Introduced new escape '\D' for continuation
4233 (Prompt2.__init__): Introduced new escape '\D' for continuation
4230 prompts. It represents the counter ('\#') as dots.
4234 prompts. It represents the counter ('\#') as dots.
4231 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
4235 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
4232 need to update their ipythonrc files and replace '%n' with '\D' in
4236 need to update their ipythonrc files and replace '%n' with '\D' in
4233 their prompt_in2 settings everywhere. Sorry, but there's
4237 their prompt_in2 settings everywhere. Sorry, but there's
4234 otherwise no clean way to get all prompts to properly align. The
4238 otherwise no clean way to get all prompts to properly align. The
4235 ipythonrc shipped with IPython has been updated.
4239 ipythonrc shipped with IPython has been updated.
4236
4240
4237 2004-06-07 Fernando Perez <fperez@colorado.edu>
4241 2004-06-07 Fernando Perez <fperez@colorado.edu>
4238
4242
4239 * setup.py (isfile): Pass local_icons option to latex2html, so the
4243 * setup.py (isfile): Pass local_icons option to latex2html, so the
4240 resulting HTML file is self-contained. Thanks to
4244 resulting HTML file is self-contained. Thanks to
4241 dryice-AT-liu.com.cn for the tip.
4245 dryice-AT-liu.com.cn for the tip.
4242
4246
4243 * pysh.py: I created a new profile 'shell', which implements a
4247 * pysh.py: I created a new profile 'shell', which implements a
4244 _rudimentary_ IPython-based shell. This is in NO WAY a realy
4248 _rudimentary_ IPython-based shell. This is in NO WAY a realy
4245 system shell, nor will it become one anytime soon. It's mainly
4249 system shell, nor will it become one anytime soon. It's mainly
4246 meant to illustrate the use of the new flexible bash-like prompts.
4250 meant to illustrate the use of the new flexible bash-like prompts.
4247 I guess it could be used by hardy souls for true shell management,
4251 I guess it could be used by hardy souls for true shell management,
4248 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
4252 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
4249 profile. This uses the InterpreterExec extension provided by
4253 profile. This uses the InterpreterExec extension provided by
4250 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
4254 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
4251
4255
4252 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
4256 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
4253 auto-align itself with the length of the previous input prompt
4257 auto-align itself with the length of the previous input prompt
4254 (taking into account the invisible color escapes).
4258 (taking into account the invisible color escapes).
4255 (CachedOutput.__init__): Large restructuring of this class. Now
4259 (CachedOutput.__init__): Large restructuring of this class. Now
4256 all three prompts (primary1, primary2, output) are proper objects,
4260 all three prompts (primary1, primary2, output) are proper objects,
4257 managed by the 'parent' CachedOutput class. The code is still a
4261 managed by the 'parent' CachedOutput class. The code is still a
4258 bit hackish (all prompts share state via a pointer to the cache),
4262 bit hackish (all prompts share state via a pointer to the cache),
4259 but it's overall far cleaner than before.
4263 but it's overall far cleaner than before.
4260
4264
4261 * IPython/genutils.py (getoutputerror): modified to add verbose,
4265 * IPython/genutils.py (getoutputerror): modified to add verbose,
4262 debug and header options. This makes the interface of all getout*
4266 debug and header options. This makes the interface of all getout*
4263 functions uniform.
4267 functions uniform.
4264 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
4268 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
4265
4269
4266 * IPython/Magic.py (Magic.default_option): added a function to
4270 * IPython/Magic.py (Magic.default_option): added a function to
4267 allow registering default options for any magic command. This
4271 allow registering default options for any magic command. This
4268 makes it easy to have profiles which customize the magics globally
4272 makes it easy to have profiles which customize the magics globally
4269 for a certain use. The values set through this function are
4273 for a certain use. The values set through this function are
4270 picked up by the parse_options() method, which all magics should
4274 picked up by the parse_options() method, which all magics should
4271 use to parse their options.
4275 use to parse their options.
4272
4276
4273 * IPython/genutils.py (warn): modified the warnings framework to
4277 * IPython/genutils.py (warn): modified the warnings framework to
4274 use the Term I/O class. I'm trying to slowly unify all of
4278 use the Term I/O class. I'm trying to slowly unify all of
4275 IPython's I/O operations to pass through Term.
4279 IPython's I/O operations to pass through Term.
4276
4280
4277 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
4281 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
4278 the secondary prompt to correctly match the length of the primary
4282 the secondary prompt to correctly match the length of the primary
4279 one for any prompt. Now multi-line code will properly line up
4283 one for any prompt. Now multi-line code will properly line up
4280 even for path dependent prompts, such as the new ones available
4284 even for path dependent prompts, such as the new ones available
4281 via the prompt_specials.
4285 via the prompt_specials.
4282
4286
4283 2004-06-06 Fernando Perez <fperez@colorado.edu>
4287 2004-06-06 Fernando Perez <fperez@colorado.edu>
4284
4288
4285 * IPython/Prompts.py (prompt_specials): Added the ability to have
4289 * IPython/Prompts.py (prompt_specials): Added the ability to have
4286 bash-like special sequences in the prompts, which get
4290 bash-like special sequences in the prompts, which get
4287 automatically expanded. Things like hostname, current working
4291 automatically expanded. Things like hostname, current working
4288 directory and username are implemented already, but it's easy to
4292 directory and username are implemented already, but it's easy to
4289 add more in the future. Thanks to a patch by W.J. van der Laan
4293 add more in the future. Thanks to a patch by W.J. van der Laan
4290 <gnufnork-AT-hetdigitalegat.nl>
4294 <gnufnork-AT-hetdigitalegat.nl>
4291 (prompt_specials): Added color support for prompt strings, so
4295 (prompt_specials): Added color support for prompt strings, so
4292 users can define arbitrary color setups for their prompts.
4296 users can define arbitrary color setups for their prompts.
4293
4297
4294 2004-06-05 Fernando Perez <fperez@colorado.edu>
4298 2004-06-05 Fernando Perez <fperez@colorado.edu>
4295
4299
4296 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
4300 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
4297 code to load Gary Bishop's readline and configure it
4301 code to load Gary Bishop's readline and configure it
4298 automatically. Thanks to Gary for help on this.
4302 automatically. Thanks to Gary for help on this.
4299
4303
4300 2004-06-01 Fernando Perez <fperez@colorado.edu>
4304 2004-06-01 Fernando Perez <fperez@colorado.edu>
4301
4305
4302 * IPython/Logger.py (Logger.create_log): fix bug for logging
4306 * IPython/Logger.py (Logger.create_log): fix bug for logging
4303 with no filename (previous fix was incomplete).
4307 with no filename (previous fix was incomplete).
4304
4308
4305 2004-05-25 Fernando Perez <fperez@colorado.edu>
4309 2004-05-25 Fernando Perez <fperez@colorado.edu>
4306
4310
4307 * IPython/Magic.py (Magic.parse_options): fix bug where naked
4311 * IPython/Magic.py (Magic.parse_options): fix bug where naked
4308 parens would get passed to the shell.
4312 parens would get passed to the shell.
4309
4313
4310 2004-05-20 Fernando Perez <fperez@colorado.edu>
4314 2004-05-20 Fernando Perez <fperez@colorado.edu>
4311
4315
4312 * IPython/Magic.py (Magic.magic_prun): changed default profile
4316 * IPython/Magic.py (Magic.magic_prun): changed default profile
4313 sort order to 'time' (the more common profiling need).
4317 sort order to 'time' (the more common profiling need).
4314
4318
4315 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
4319 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
4316 so that source code shown is guaranteed in sync with the file on
4320 so that source code shown is guaranteed in sync with the file on
4317 disk (also changed in psource). Similar fix to the one for
4321 disk (also changed in psource). Similar fix to the one for
4318 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
4322 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
4319 <yann.ledu-AT-noos.fr>.
4323 <yann.ledu-AT-noos.fr>.
4320
4324
4321 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
4325 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
4322 with a single option would not be correctly parsed. Closes
4326 with a single option would not be correctly parsed. Closes
4323 http://www.scipy.net/roundup/ipython/issue14. This bug had been
4327 http://www.scipy.net/roundup/ipython/issue14. This bug had been
4324 introduced in 0.6.0 (on 2004-05-06).
4328 introduced in 0.6.0 (on 2004-05-06).
4325
4329
4326 2004-05-13 *** Released version 0.6.0
4330 2004-05-13 *** Released version 0.6.0
4327
4331
4328 2004-05-13 Fernando Perez <fperez@colorado.edu>
4332 2004-05-13 Fernando Perez <fperez@colorado.edu>
4329
4333
4330 * debian/: Added debian/ directory to CVS, so that debian support
4334 * debian/: Added debian/ directory to CVS, so that debian support
4331 is publicly accessible. The debian package is maintained by Jack
4335 is publicly accessible. The debian package is maintained by Jack
4332 Moffit <jack-AT-xiph.org>.
4336 Moffit <jack-AT-xiph.org>.
4333
4337
4334 * Documentation: included the notes about an ipython-based system
4338 * Documentation: included the notes about an ipython-based system
4335 shell (the hypothetical 'pysh') into the new_design.pdf document,
4339 shell (the hypothetical 'pysh') into the new_design.pdf document,
4336 so that these ideas get distributed to users along with the
4340 so that these ideas get distributed to users along with the
4337 official documentation.
4341 official documentation.
4338
4342
4339 2004-05-10 Fernando Perez <fperez@colorado.edu>
4343 2004-05-10 Fernando Perez <fperez@colorado.edu>
4340
4344
4341 * IPython/Logger.py (Logger.create_log): fix recently introduced
4345 * IPython/Logger.py (Logger.create_log): fix recently introduced
4342 bug (misindented line) where logstart would fail when not given an
4346 bug (misindented line) where logstart would fail when not given an
4343 explicit filename.
4347 explicit filename.
4344
4348
4345 2004-05-09 Fernando Perez <fperez@colorado.edu>
4349 2004-05-09 Fernando Perez <fperez@colorado.edu>
4346
4350
4347 * IPython/Magic.py (Magic.parse_options): skip system call when
4351 * IPython/Magic.py (Magic.parse_options): skip system call when
4348 there are no options to look for. Faster, cleaner for the common
4352 there are no options to look for. Faster, cleaner for the common
4349 case.
4353 case.
4350
4354
4351 * Documentation: many updates to the manual: describing Windows
4355 * Documentation: many updates to the manual: describing Windows
4352 support better, Gnuplot updates, credits, misc small stuff. Also
4356 support better, Gnuplot updates, credits, misc small stuff. Also
4353 updated the new_design doc a bit.
4357 updated the new_design doc a bit.
4354
4358
4355 2004-05-06 *** Released version 0.6.0.rc1
4359 2004-05-06 *** Released version 0.6.0.rc1
4356
4360
4357 2004-05-06 Fernando Perez <fperez@colorado.edu>
4361 2004-05-06 Fernando Perez <fperez@colorado.edu>
4358
4362
4359 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
4363 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
4360 operations to use the vastly more efficient list/''.join() method.
4364 operations to use the vastly more efficient list/''.join() method.
4361 (FormattedTB.text): Fix
4365 (FormattedTB.text): Fix
4362 http://www.scipy.net/roundup/ipython/issue12 - exception source
4366 http://www.scipy.net/roundup/ipython/issue12 - exception source
4363 extract not updated after reload. Thanks to Mike Salib
4367 extract not updated after reload. Thanks to Mike Salib
4364 <msalib-AT-mit.edu> for pinning the source of the problem.
4368 <msalib-AT-mit.edu> for pinning the source of the problem.
4365 Fortunately, the solution works inside ipython and doesn't require
4369 Fortunately, the solution works inside ipython and doesn't require
4366 any changes to python proper.
4370 any changes to python proper.
4367
4371
4368 * IPython/Magic.py (Magic.parse_options): Improved to process the
4372 * IPython/Magic.py (Magic.parse_options): Improved to process the
4369 argument list as a true shell would (by actually using the
4373 argument list as a true shell would (by actually using the
4370 underlying system shell). This way, all @magics automatically get
4374 underlying system shell). This way, all @magics automatically get
4371 shell expansion for variables. Thanks to a comment by Alex
4375 shell expansion for variables. Thanks to a comment by Alex
4372 Schmolck.
4376 Schmolck.
4373
4377
4374 2004-04-04 Fernando Perez <fperez@colorado.edu>
4378 2004-04-04 Fernando Perez <fperez@colorado.edu>
4375
4379
4376 * IPython/iplib.py (InteractiveShell.interact): Added a special
4380 * IPython/iplib.py (InteractiveShell.interact): Added a special
4377 trap for a debugger quit exception, which is basically impossible
4381 trap for a debugger quit exception, which is basically impossible
4378 to handle by normal mechanisms, given what pdb does to the stack.
4382 to handle by normal mechanisms, given what pdb does to the stack.
4379 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
4383 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
4380
4384
4381 2004-04-03 Fernando Perez <fperez@colorado.edu>
4385 2004-04-03 Fernando Perez <fperez@colorado.edu>
4382
4386
4383 * IPython/genutils.py (Term): Standardized the names of the Term
4387 * IPython/genutils.py (Term): Standardized the names of the Term
4384 class streams to cin/cout/cerr, following C++ naming conventions
4388 class streams to cin/cout/cerr, following C++ naming conventions
4385 (I can't use in/out/err because 'in' is not a valid attribute
4389 (I can't use in/out/err because 'in' is not a valid attribute
4386 name).
4390 name).
4387
4391
4388 * IPython/iplib.py (InteractiveShell.interact): don't increment
4392 * IPython/iplib.py (InteractiveShell.interact): don't increment
4389 the prompt if there's no user input. By Daniel 'Dang' Griffith
4393 the prompt if there's no user input. By Daniel 'Dang' Griffith
4390 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
4394 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
4391 Francois Pinard.
4395 Francois Pinard.
4392
4396
4393 2004-04-02 Fernando Perez <fperez@colorado.edu>
4397 2004-04-02 Fernando Perez <fperez@colorado.edu>
4394
4398
4395 * IPython/genutils.py (Stream.__init__): Modified to survive at
4399 * IPython/genutils.py (Stream.__init__): Modified to survive at
4396 least importing in contexts where stdin/out/err aren't true file
4400 least importing in contexts where stdin/out/err aren't true file
4397 objects, such as PyCrust (they lack fileno() and mode). However,
4401 objects, such as PyCrust (they lack fileno() and mode). However,
4398 the recovery facilities which rely on these things existing will
4402 the recovery facilities which rely on these things existing will
4399 not work.
4403 not work.
4400
4404
4401 2004-04-01 Fernando Perez <fperez@colorado.edu>
4405 2004-04-01 Fernando Perez <fperez@colorado.edu>
4402
4406
4403 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
4407 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
4404 use the new getoutputerror() function, so it properly
4408 use the new getoutputerror() function, so it properly
4405 distinguishes stdout/err.
4409 distinguishes stdout/err.
4406
4410
4407 * IPython/genutils.py (getoutputerror): added a function to
4411 * IPython/genutils.py (getoutputerror): added a function to
4408 capture separately the standard output and error of a command.
4412 capture separately the standard output and error of a command.
4409 After a comment from dang on the mailing lists. This code is
4413 After a comment from dang on the mailing lists. This code is
4410 basically a modified version of commands.getstatusoutput(), from
4414 basically a modified version of commands.getstatusoutput(), from
4411 the standard library.
4415 the standard library.
4412
4416
4413 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
4417 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
4414 '!!' as a special syntax (shorthand) to access @sx.
4418 '!!' as a special syntax (shorthand) to access @sx.
4415
4419
4416 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
4420 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
4417 command and return its output as a list split on '\n'.
4421 command and return its output as a list split on '\n'.
4418
4422
4419 2004-03-31 Fernando Perez <fperez@colorado.edu>
4423 2004-03-31 Fernando Perez <fperez@colorado.edu>
4420
4424
4421 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
4425 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
4422 method to dictionaries used as FakeModule instances if they lack
4426 method to dictionaries used as FakeModule instances if they lack
4423 it. At least pydoc in python2.3 breaks for runtime-defined
4427 it. At least pydoc in python2.3 breaks for runtime-defined
4424 functions without this hack. At some point I need to _really_
4428 functions without this hack. At some point I need to _really_
4425 understand what FakeModule is doing, because it's a gross hack.
4429 understand what FakeModule is doing, because it's a gross hack.
4426 But it solves Arnd's problem for now...
4430 But it solves Arnd's problem for now...
4427
4431
4428 2004-02-27 Fernando Perez <fperez@colorado.edu>
4432 2004-02-27 Fernando Perez <fperez@colorado.edu>
4429
4433
4430 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
4434 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
4431 mode would behave erratically. Also increased the number of
4435 mode would behave erratically. Also increased the number of
4432 possible logs in rotate mod to 999. Thanks to Rod Holland
4436 possible logs in rotate mod to 999. Thanks to Rod Holland
4433 <rhh@StructureLABS.com> for the report and fixes.
4437 <rhh@StructureLABS.com> for the report and fixes.
4434
4438
4435 2004-02-26 Fernando Perez <fperez@colorado.edu>
4439 2004-02-26 Fernando Perez <fperez@colorado.edu>
4436
4440
4437 * IPython/genutils.py (page): Check that the curses module really
4441 * IPython/genutils.py (page): Check that the curses module really
4438 has the initscr attribute before trying to use it. For some
4442 has the initscr attribute before trying to use it. For some
4439 reason, the Solaris curses module is missing this. I think this
4443 reason, the Solaris curses module is missing this. I think this
4440 should be considered a Solaris python bug, but I'm not sure.
4444 should be considered a Solaris python bug, but I'm not sure.
4441
4445
4442 2004-01-17 Fernando Perez <fperez@colorado.edu>
4446 2004-01-17 Fernando Perez <fperez@colorado.edu>
4443
4447
4444 * IPython/genutils.py (Stream.__init__): Changes to try to make
4448 * IPython/genutils.py (Stream.__init__): Changes to try to make
4445 ipython robust against stdin/out/err being closed by the user.
4449 ipython robust against stdin/out/err being closed by the user.
4446 This is 'user error' (and blocks a normal python session, at least
4450 This is 'user error' (and blocks a normal python session, at least
4447 the stdout case). However, Ipython should be able to survive such
4451 the stdout case). However, Ipython should be able to survive such
4448 instances of abuse as gracefully as possible. To simplify the
4452 instances of abuse as gracefully as possible. To simplify the
4449 coding and maintain compatibility with Gary Bishop's Term
4453 coding and maintain compatibility with Gary Bishop's Term
4450 contributions, I've made use of classmethods for this. I think
4454 contributions, I've made use of classmethods for this. I think
4451 this introduces a dependency on python 2.2.
4455 this introduces a dependency on python 2.2.
4452
4456
4453 2004-01-13 Fernando Perez <fperez@colorado.edu>
4457 2004-01-13 Fernando Perez <fperez@colorado.edu>
4454
4458
4455 * IPython/numutils.py (exp_safe): simplified the code a bit and
4459 * IPython/numutils.py (exp_safe): simplified the code a bit and
4456 removed the need for importing the kinds module altogether.
4460 removed the need for importing the kinds module altogether.
4457
4461
4458 2004-01-06 Fernando Perez <fperez@colorado.edu>
4462 2004-01-06 Fernando Perez <fperez@colorado.edu>
4459
4463
4460 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
4464 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
4461 a magic function instead, after some community feedback. No
4465 a magic function instead, after some community feedback. No
4462 special syntax will exist for it, but its name is deliberately
4466 special syntax will exist for it, but its name is deliberately
4463 very short.
4467 very short.
4464
4468
4465 2003-12-20 Fernando Perez <fperez@colorado.edu>
4469 2003-12-20 Fernando Perez <fperez@colorado.edu>
4466
4470
4467 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
4471 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
4468 new functionality, to automagically assign the result of a shell
4472 new functionality, to automagically assign the result of a shell
4469 command to a variable. I'll solicit some community feedback on
4473 command to a variable. I'll solicit some community feedback on
4470 this before making it permanent.
4474 this before making it permanent.
4471
4475
4472 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
4476 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
4473 requested about callables for which inspect couldn't obtain a
4477 requested about callables for which inspect couldn't obtain a
4474 proper argspec. Thanks to a crash report sent by Etienne
4478 proper argspec. Thanks to a crash report sent by Etienne
4475 Posthumus <etienne-AT-apple01.cs.vu.nl>.
4479 Posthumus <etienne-AT-apple01.cs.vu.nl>.
4476
4480
4477 2003-12-09 Fernando Perez <fperez@colorado.edu>
4481 2003-12-09 Fernando Perez <fperez@colorado.edu>
4478
4482
4479 * IPython/genutils.py (page): patch for the pager to work across
4483 * IPython/genutils.py (page): patch for the pager to work across
4480 various versions of Windows. By Gary Bishop.
4484 various versions of Windows. By Gary Bishop.
4481
4485
4482 2003-12-04 Fernando Perez <fperez@colorado.edu>
4486 2003-12-04 Fernando Perez <fperez@colorado.edu>
4483
4487
4484 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
4488 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
4485 Gnuplot.py version 1.7, whose internal names changed quite a bit.
4489 Gnuplot.py version 1.7, whose internal names changed quite a bit.
4486 While I tested this and it looks ok, there may still be corner
4490 While I tested this and it looks ok, there may still be corner
4487 cases I've missed.
4491 cases I've missed.
4488
4492
4489 2003-12-01 Fernando Perez <fperez@colorado.edu>
4493 2003-12-01 Fernando Perez <fperez@colorado.edu>
4490
4494
4491 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
4495 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
4492 where a line like 'p,q=1,2' would fail because the automagic
4496 where a line like 'p,q=1,2' would fail because the automagic
4493 system would be triggered for @p.
4497 system would be triggered for @p.
4494
4498
4495 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
4499 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
4496 cleanups, code unmodified.
4500 cleanups, code unmodified.
4497
4501
4498 * IPython/genutils.py (Term): added a class for IPython to handle
4502 * IPython/genutils.py (Term): added a class for IPython to handle
4499 output. In most cases it will just be a proxy for stdout/err, but
4503 output. In most cases it will just be a proxy for stdout/err, but
4500 having this allows modifications to be made for some platforms,
4504 having this allows modifications to be made for some platforms,
4501 such as handling color escapes under Windows. All of this code
4505 such as handling color escapes under Windows. All of this code
4502 was contributed by Gary Bishop, with minor modifications by me.
4506 was contributed by Gary Bishop, with minor modifications by me.
4503 The actual changes affect many files.
4507 The actual changes affect many files.
4504
4508
4505 2003-11-30 Fernando Perez <fperez@colorado.edu>
4509 2003-11-30 Fernando Perez <fperez@colorado.edu>
4506
4510
4507 * IPython/iplib.py (file_matches): new completion code, courtesy
4511 * IPython/iplib.py (file_matches): new completion code, courtesy
4508 of Jeff Collins. This enables filename completion again under
4512 of Jeff Collins. This enables filename completion again under
4509 python 2.3, which disabled it at the C level.
4513 python 2.3, which disabled it at the C level.
4510
4514
4511 2003-11-11 Fernando Perez <fperez@colorado.edu>
4515 2003-11-11 Fernando Perez <fperez@colorado.edu>
4512
4516
4513 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
4517 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
4514 for Numeric.array(map(...)), but often convenient.
4518 for Numeric.array(map(...)), but often convenient.
4515
4519
4516 2003-11-05 Fernando Perez <fperez@colorado.edu>
4520 2003-11-05 Fernando Perez <fperez@colorado.edu>
4517
4521
4518 * IPython/numutils.py (frange): Changed a call from int() to
4522 * IPython/numutils.py (frange): Changed a call from int() to
4519 int(round()) to prevent a problem reported with arange() in the
4523 int(round()) to prevent a problem reported with arange() in the
4520 numpy list.
4524 numpy list.
4521
4525
4522 2003-10-06 Fernando Perez <fperez@colorado.edu>
4526 2003-10-06 Fernando Perez <fperez@colorado.edu>
4523
4527
4524 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4528 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4525 prevent crashes if sys lacks an argv attribute (it happens with
4529 prevent crashes if sys lacks an argv attribute (it happens with
4526 embedded interpreters which build a bare-bones sys module).
4530 embedded interpreters which build a bare-bones sys module).
4527 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4531 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4528
4532
4529 2003-09-24 Fernando Perez <fperez@colorado.edu>
4533 2003-09-24 Fernando Perez <fperez@colorado.edu>
4530
4534
4531 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4535 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4532 to protect against poorly written user objects where __getattr__
4536 to protect against poorly written user objects where __getattr__
4533 raises exceptions other than AttributeError. Thanks to a bug
4537 raises exceptions other than AttributeError. Thanks to a bug
4534 report by Oliver Sander <osander-AT-gmx.de>.
4538 report by Oliver Sander <osander-AT-gmx.de>.
4535
4539
4536 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4540 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4537 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4541 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4538
4542
4539 2003-09-09 Fernando Perez <fperez@colorado.edu>
4543 2003-09-09 Fernando Perez <fperez@colorado.edu>
4540
4544
4541 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4545 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4542 unpacking a list whith a callable as first element would
4546 unpacking a list whith a callable as first element would
4543 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4547 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4544 Collins.
4548 Collins.
4545
4549
4546 2003-08-25 *** Released version 0.5.0
4550 2003-08-25 *** Released version 0.5.0
4547
4551
4548 2003-08-22 Fernando Perez <fperez@colorado.edu>
4552 2003-08-22 Fernando Perez <fperez@colorado.edu>
4549
4553
4550 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4554 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4551 improperly defined user exceptions. Thanks to feedback from Mark
4555 improperly defined user exceptions. Thanks to feedback from Mark
4552 Russell <mrussell-AT-verio.net>.
4556 Russell <mrussell-AT-verio.net>.
4553
4557
4554 2003-08-20 Fernando Perez <fperez@colorado.edu>
4558 2003-08-20 Fernando Perez <fperez@colorado.edu>
4555
4559
4556 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4560 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4557 printing so that it would print multi-line string forms starting
4561 printing so that it would print multi-line string forms starting
4558 with a new line. This way the formatting is better respected for
4562 with a new line. This way the formatting is better respected for
4559 objects which work hard to make nice string forms.
4563 objects which work hard to make nice string forms.
4560
4564
4561 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4565 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4562 autocall would overtake data access for objects with both
4566 autocall would overtake data access for objects with both
4563 __getitem__ and __call__.
4567 __getitem__ and __call__.
4564
4568
4565 2003-08-19 *** Released version 0.5.0-rc1
4569 2003-08-19 *** Released version 0.5.0-rc1
4566
4570
4567 2003-08-19 Fernando Perez <fperez@colorado.edu>
4571 2003-08-19 Fernando Perez <fperez@colorado.edu>
4568
4572
4569 * IPython/deep_reload.py (load_tail): single tiny change here
4573 * IPython/deep_reload.py (load_tail): single tiny change here
4570 seems to fix the long-standing bug of dreload() failing to work
4574 seems to fix the long-standing bug of dreload() failing to work
4571 for dotted names. But this module is pretty tricky, so I may have
4575 for dotted names. But this module is pretty tricky, so I may have
4572 missed some subtlety. Needs more testing!.
4576 missed some subtlety. Needs more testing!.
4573
4577
4574 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4578 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4575 exceptions which have badly implemented __str__ methods.
4579 exceptions which have badly implemented __str__ methods.
4576 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4580 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4577 which I've been getting reports about from Python 2.3 users. I
4581 which I've been getting reports about from Python 2.3 users. I
4578 wish I had a simple test case to reproduce the problem, so I could
4582 wish I had a simple test case to reproduce the problem, so I could
4579 either write a cleaner workaround or file a bug report if
4583 either write a cleaner workaround or file a bug report if
4580 necessary.
4584 necessary.
4581
4585
4582 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4586 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4583 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4587 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4584 a bug report by Tjabo Kloppenburg.
4588 a bug report by Tjabo Kloppenburg.
4585
4589
4586 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4590 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4587 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4591 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4588 seems rather unstable. Thanks to a bug report by Tjabo
4592 seems rather unstable. Thanks to a bug report by Tjabo
4589 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4593 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4590
4594
4591 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4595 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4592 this out soon because of the critical fixes in the inner loop for
4596 this out soon because of the critical fixes in the inner loop for
4593 generators.
4597 generators.
4594
4598
4595 * IPython/Magic.py (Magic.getargspec): removed. This (and
4599 * IPython/Magic.py (Magic.getargspec): removed. This (and
4596 _get_def) have been obsoleted by OInspect for a long time, I
4600 _get_def) have been obsoleted by OInspect for a long time, I
4597 hadn't noticed that they were dead code.
4601 hadn't noticed that they were dead code.
4598 (Magic._ofind): restored _ofind functionality for a few literals
4602 (Magic._ofind): restored _ofind functionality for a few literals
4599 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4603 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4600 for things like "hello".capitalize?, since that would require a
4604 for things like "hello".capitalize?, since that would require a
4601 potentially dangerous eval() again.
4605 potentially dangerous eval() again.
4602
4606
4603 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4607 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4604 logic a bit more to clean up the escapes handling and minimize the
4608 logic a bit more to clean up the escapes handling and minimize the
4605 use of _ofind to only necessary cases. The interactive 'feel' of
4609 use of _ofind to only necessary cases. The interactive 'feel' of
4606 IPython should have improved quite a bit with the changes in
4610 IPython should have improved quite a bit with the changes in
4607 _prefilter and _ofind (besides being far safer than before).
4611 _prefilter and _ofind (besides being far safer than before).
4608
4612
4609 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4613 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4610 obscure, never reported). Edit would fail to find the object to
4614 obscure, never reported). Edit would fail to find the object to
4611 edit under some circumstances.
4615 edit under some circumstances.
4612 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4616 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4613 which were causing double-calling of generators. Those eval calls
4617 which were causing double-calling of generators. Those eval calls
4614 were _very_ dangerous, since code with side effects could be
4618 were _very_ dangerous, since code with side effects could be
4615 triggered. As they say, 'eval is evil'... These were the
4619 triggered. As they say, 'eval is evil'... These were the
4616 nastiest evals in IPython. Besides, _ofind is now far simpler,
4620 nastiest evals in IPython. Besides, _ofind is now far simpler,
4617 and it should also be quite a bit faster. Its use of inspect is
4621 and it should also be quite a bit faster. Its use of inspect is
4618 also safer, so perhaps some of the inspect-related crashes I've
4622 also safer, so perhaps some of the inspect-related crashes I've
4619 seen lately with Python 2.3 might be taken care of. That will
4623 seen lately with Python 2.3 might be taken care of. That will
4620 need more testing.
4624 need more testing.
4621
4625
4622 2003-08-17 Fernando Perez <fperez@colorado.edu>
4626 2003-08-17 Fernando Perez <fperez@colorado.edu>
4623
4627
4624 * IPython/iplib.py (InteractiveShell._prefilter): significant
4628 * IPython/iplib.py (InteractiveShell._prefilter): significant
4625 simplifications to the logic for handling user escapes. Faster
4629 simplifications to the logic for handling user escapes. Faster
4626 and simpler code.
4630 and simpler code.
4627
4631
4628 2003-08-14 Fernando Perez <fperez@colorado.edu>
4632 2003-08-14 Fernando Perez <fperez@colorado.edu>
4629
4633
4630 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4634 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4631 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4635 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4632 but it should be quite a bit faster. And the recursive version
4636 but it should be quite a bit faster. And the recursive version
4633 generated O(log N) intermediate storage for all rank>1 arrays,
4637 generated O(log N) intermediate storage for all rank>1 arrays,
4634 even if they were contiguous.
4638 even if they were contiguous.
4635 (l1norm): Added this function.
4639 (l1norm): Added this function.
4636 (norm): Added this function for arbitrary norms (including
4640 (norm): Added this function for arbitrary norms (including
4637 l-infinity). l1 and l2 are still special cases for convenience
4641 l-infinity). l1 and l2 are still special cases for convenience
4638 and speed.
4642 and speed.
4639
4643
4640 2003-08-03 Fernando Perez <fperez@colorado.edu>
4644 2003-08-03 Fernando Perez <fperez@colorado.edu>
4641
4645
4642 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4646 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4643 exceptions, which now raise PendingDeprecationWarnings in Python
4647 exceptions, which now raise PendingDeprecationWarnings in Python
4644 2.3. There were some in Magic and some in Gnuplot2.
4648 2.3. There were some in Magic and some in Gnuplot2.
4645
4649
4646 2003-06-30 Fernando Perez <fperez@colorado.edu>
4650 2003-06-30 Fernando Perez <fperez@colorado.edu>
4647
4651
4648 * IPython/genutils.py (page): modified to call curses only for
4652 * IPython/genutils.py (page): modified to call curses only for
4649 terminals where TERM=='xterm'. After problems under many other
4653 terminals where TERM=='xterm'. After problems under many other
4650 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4654 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4651
4655
4652 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4656 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4653 would be triggered when readline was absent. This was just an old
4657 would be triggered when readline was absent. This was just an old
4654 debugging statement I'd forgotten to take out.
4658 debugging statement I'd forgotten to take out.
4655
4659
4656 2003-06-20 Fernando Perez <fperez@colorado.edu>
4660 2003-06-20 Fernando Perez <fperez@colorado.edu>
4657
4661
4658 * IPython/genutils.py (clock): modified to return only user time
4662 * IPython/genutils.py (clock): modified to return only user time
4659 (not counting system time), after a discussion on scipy. While
4663 (not counting system time), after a discussion on scipy. While
4660 system time may be a useful quantity occasionally, it may much
4664 system time may be a useful quantity occasionally, it may much
4661 more easily be skewed by occasional swapping or other similar
4665 more easily be skewed by occasional swapping or other similar
4662 activity.
4666 activity.
4663
4667
4664 2003-06-05 Fernando Perez <fperez@colorado.edu>
4668 2003-06-05 Fernando Perez <fperez@colorado.edu>
4665
4669
4666 * IPython/numutils.py (identity): new function, for building
4670 * IPython/numutils.py (identity): new function, for building
4667 arbitrary rank Kronecker deltas (mostly backwards compatible with
4671 arbitrary rank Kronecker deltas (mostly backwards compatible with
4668 Numeric.identity)
4672 Numeric.identity)
4669
4673
4670 2003-06-03 Fernando Perez <fperez@colorado.edu>
4674 2003-06-03 Fernando Perez <fperez@colorado.edu>
4671
4675
4672 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4676 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4673 arguments passed to magics with spaces, to allow trailing '\' to
4677 arguments passed to magics with spaces, to allow trailing '\' to
4674 work normally (mainly for Windows users).
4678 work normally (mainly for Windows users).
4675
4679
4676 2003-05-29 Fernando Perez <fperez@colorado.edu>
4680 2003-05-29 Fernando Perez <fperez@colorado.edu>
4677
4681
4678 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4682 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4679 instead of pydoc.help. This fixes a bizarre behavior where
4683 instead of pydoc.help. This fixes a bizarre behavior where
4680 printing '%s' % locals() would trigger the help system. Now
4684 printing '%s' % locals() would trigger the help system. Now
4681 ipython behaves like normal python does.
4685 ipython behaves like normal python does.
4682
4686
4683 Note that if one does 'from pydoc import help', the bizarre
4687 Note that if one does 'from pydoc import help', the bizarre
4684 behavior returns, but this will also happen in normal python, so
4688 behavior returns, but this will also happen in normal python, so
4685 it's not an ipython bug anymore (it has to do with how pydoc.help
4689 it's not an ipython bug anymore (it has to do with how pydoc.help
4686 is implemented).
4690 is implemented).
4687
4691
4688 2003-05-22 Fernando Perez <fperez@colorado.edu>
4692 2003-05-22 Fernando Perez <fperez@colorado.edu>
4689
4693
4690 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4694 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4691 return [] instead of None when nothing matches, also match to end
4695 return [] instead of None when nothing matches, also match to end
4692 of line. Patch by Gary Bishop.
4696 of line. Patch by Gary Bishop.
4693
4697
4694 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4698 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4695 protection as before, for files passed on the command line. This
4699 protection as before, for files passed on the command line. This
4696 prevents the CrashHandler from kicking in if user files call into
4700 prevents the CrashHandler from kicking in if user files call into
4697 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4701 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4698 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4702 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4699
4703
4700 2003-05-20 *** Released version 0.4.0
4704 2003-05-20 *** Released version 0.4.0
4701
4705
4702 2003-05-20 Fernando Perez <fperez@colorado.edu>
4706 2003-05-20 Fernando Perez <fperez@colorado.edu>
4703
4707
4704 * setup.py: added support for manpages. It's a bit hackish b/c of
4708 * setup.py: added support for manpages. It's a bit hackish b/c of
4705 a bug in the way the bdist_rpm distutils target handles gzipped
4709 a bug in the way the bdist_rpm distutils target handles gzipped
4706 manpages, but it works. After a patch by Jack.
4710 manpages, but it works. After a patch by Jack.
4707
4711
4708 2003-05-19 Fernando Perez <fperez@colorado.edu>
4712 2003-05-19 Fernando Perez <fperez@colorado.edu>
4709
4713
4710 * IPython/numutils.py: added a mockup of the kinds module, since
4714 * IPython/numutils.py: added a mockup of the kinds module, since
4711 it was recently removed from Numeric. This way, numutils will
4715 it was recently removed from Numeric. This way, numutils will
4712 work for all users even if they are missing kinds.
4716 work for all users even if they are missing kinds.
4713
4717
4714 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4718 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4715 failure, which can occur with SWIG-wrapped extensions. After a
4719 failure, which can occur with SWIG-wrapped extensions. After a
4716 crash report from Prabhu.
4720 crash report from Prabhu.
4717
4721
4718 2003-05-16 Fernando Perez <fperez@colorado.edu>
4722 2003-05-16 Fernando Perez <fperez@colorado.edu>
4719
4723
4720 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4724 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4721 protect ipython from user code which may call directly
4725 protect ipython from user code which may call directly
4722 sys.excepthook (this looks like an ipython crash to the user, even
4726 sys.excepthook (this looks like an ipython crash to the user, even
4723 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4727 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4724 This is especially important to help users of WxWindows, but may
4728 This is especially important to help users of WxWindows, but may
4725 also be useful in other cases.
4729 also be useful in other cases.
4726
4730
4727 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4731 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4728 an optional tb_offset to be specified, and to preserve exception
4732 an optional tb_offset to be specified, and to preserve exception
4729 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4733 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4730
4734
4731 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4735 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4732
4736
4733 2003-05-15 Fernando Perez <fperez@colorado.edu>
4737 2003-05-15 Fernando Perez <fperez@colorado.edu>
4734
4738
4735 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4739 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4736 installing for a new user under Windows.
4740 installing for a new user under Windows.
4737
4741
4738 2003-05-12 Fernando Perez <fperez@colorado.edu>
4742 2003-05-12 Fernando Perez <fperez@colorado.edu>
4739
4743
4740 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4744 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4741 handler for Emacs comint-based lines. Currently it doesn't do
4745 handler for Emacs comint-based lines. Currently it doesn't do
4742 much (but importantly, it doesn't update the history cache). In
4746 much (but importantly, it doesn't update the history cache). In
4743 the future it may be expanded if Alex needs more functionality
4747 the future it may be expanded if Alex needs more functionality
4744 there.
4748 there.
4745
4749
4746 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4750 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4747 info to crash reports.
4751 info to crash reports.
4748
4752
4749 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4753 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4750 just like Python's -c. Also fixed crash with invalid -color
4754 just like Python's -c. Also fixed crash with invalid -color
4751 option value at startup. Thanks to Will French
4755 option value at startup. Thanks to Will French
4752 <wfrench-AT-bestweb.net> for the bug report.
4756 <wfrench-AT-bestweb.net> for the bug report.
4753
4757
4754 2003-05-09 Fernando Perez <fperez@colorado.edu>
4758 2003-05-09 Fernando Perez <fperez@colorado.edu>
4755
4759
4756 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4760 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4757 to EvalDict (it's a mapping, after all) and simplified its code
4761 to EvalDict (it's a mapping, after all) and simplified its code
4758 quite a bit, after a nice discussion on c.l.py where Gustavo
4762 quite a bit, after a nice discussion on c.l.py where Gustavo
4759 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4763 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4760
4764
4761 2003-04-30 Fernando Perez <fperez@colorado.edu>
4765 2003-04-30 Fernando Perez <fperez@colorado.edu>
4762
4766
4763 * IPython/genutils.py (timings_out): modified it to reduce its
4767 * IPython/genutils.py (timings_out): modified it to reduce its
4764 overhead in the common reps==1 case.
4768 overhead in the common reps==1 case.
4765
4769
4766 2003-04-29 Fernando Perez <fperez@colorado.edu>
4770 2003-04-29 Fernando Perez <fperez@colorado.edu>
4767
4771
4768 * IPython/genutils.py (timings_out): Modified to use the resource
4772 * IPython/genutils.py (timings_out): Modified to use the resource
4769 module, which avoids the wraparound problems of time.clock().
4773 module, which avoids the wraparound problems of time.clock().
4770
4774
4771 2003-04-17 *** Released version 0.2.15pre4
4775 2003-04-17 *** Released version 0.2.15pre4
4772
4776
4773 2003-04-17 Fernando Perez <fperez@colorado.edu>
4777 2003-04-17 Fernando Perez <fperez@colorado.edu>
4774
4778
4775 * setup.py (scriptfiles): Split windows-specific stuff over to a
4779 * setup.py (scriptfiles): Split windows-specific stuff over to a
4776 separate file, in an attempt to have a Windows GUI installer.
4780 separate file, in an attempt to have a Windows GUI installer.
4777 That didn't work, but part of the groundwork is done.
4781 That didn't work, but part of the groundwork is done.
4778
4782
4779 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4783 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4780 indent/unindent with 4 spaces. Particularly useful in combination
4784 indent/unindent with 4 spaces. Particularly useful in combination
4781 with the new auto-indent option.
4785 with the new auto-indent option.
4782
4786
4783 2003-04-16 Fernando Perez <fperez@colorado.edu>
4787 2003-04-16 Fernando Perez <fperez@colorado.edu>
4784
4788
4785 * IPython/Magic.py: various replacements of self.rc for
4789 * IPython/Magic.py: various replacements of self.rc for
4786 self.shell.rc. A lot more remains to be done to fully disentangle
4790 self.shell.rc. A lot more remains to be done to fully disentangle
4787 this class from the main Shell class.
4791 this class from the main Shell class.
4788
4792
4789 * IPython/GnuplotRuntime.py: added checks for mouse support so
4793 * IPython/GnuplotRuntime.py: added checks for mouse support so
4790 that we don't try to enable it if the current gnuplot doesn't
4794 that we don't try to enable it if the current gnuplot doesn't
4791 really support it. Also added checks so that we don't try to
4795 really support it. Also added checks so that we don't try to
4792 enable persist under Windows (where Gnuplot doesn't recognize the
4796 enable persist under Windows (where Gnuplot doesn't recognize the
4793 option).
4797 option).
4794
4798
4795 * IPython/iplib.py (InteractiveShell.interact): Added optional
4799 * IPython/iplib.py (InteractiveShell.interact): Added optional
4796 auto-indenting code, after a patch by King C. Shu
4800 auto-indenting code, after a patch by King C. Shu
4797 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4801 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4798 get along well with pasting indented code. If I ever figure out
4802 get along well with pasting indented code. If I ever figure out
4799 how to make that part go well, it will become on by default.
4803 how to make that part go well, it will become on by default.
4800
4804
4801 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4805 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4802 crash ipython if there was an unmatched '%' in the user's prompt
4806 crash ipython if there was an unmatched '%' in the user's prompt
4803 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4807 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4804
4808
4805 * IPython/iplib.py (InteractiveShell.interact): removed the
4809 * IPython/iplib.py (InteractiveShell.interact): removed the
4806 ability to ask the user whether he wants to crash or not at the
4810 ability to ask the user whether he wants to crash or not at the
4807 'last line' exception handler. Calling functions at that point
4811 'last line' exception handler. Calling functions at that point
4808 changes the stack, and the error reports would have incorrect
4812 changes the stack, and the error reports would have incorrect
4809 tracebacks.
4813 tracebacks.
4810
4814
4811 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4815 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4812 pass through a peger a pretty-printed form of any object. After a
4816 pass through a peger a pretty-printed form of any object. After a
4813 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4817 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4814
4818
4815 2003-04-14 Fernando Perez <fperez@colorado.edu>
4819 2003-04-14 Fernando Perez <fperez@colorado.edu>
4816
4820
4817 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4821 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4818 all files in ~ would be modified at first install (instead of
4822 all files in ~ would be modified at first install (instead of
4819 ~/.ipython). This could be potentially disastrous, as the
4823 ~/.ipython). This could be potentially disastrous, as the
4820 modification (make line-endings native) could damage binary files.
4824 modification (make line-endings native) could damage binary files.
4821
4825
4822 2003-04-10 Fernando Perez <fperez@colorado.edu>
4826 2003-04-10 Fernando Perez <fperez@colorado.edu>
4823
4827
4824 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4828 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4825 handle only lines which are invalid python. This now means that
4829 handle only lines which are invalid python. This now means that
4826 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4830 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4827 for the bug report.
4831 for the bug report.
4828
4832
4829 2003-04-01 Fernando Perez <fperez@colorado.edu>
4833 2003-04-01 Fernando Perez <fperez@colorado.edu>
4830
4834
4831 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4835 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4832 where failing to set sys.last_traceback would crash pdb.pm().
4836 where failing to set sys.last_traceback would crash pdb.pm().
4833 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4837 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4834 report.
4838 report.
4835
4839
4836 2003-03-25 Fernando Perez <fperez@colorado.edu>
4840 2003-03-25 Fernando Perez <fperez@colorado.edu>
4837
4841
4838 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4842 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4839 before printing it (it had a lot of spurious blank lines at the
4843 before printing it (it had a lot of spurious blank lines at the
4840 end).
4844 end).
4841
4845
4842 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4846 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4843 output would be sent 21 times! Obviously people don't use this
4847 output would be sent 21 times! Obviously people don't use this
4844 too often, or I would have heard about it.
4848 too often, or I would have heard about it.
4845
4849
4846 2003-03-24 Fernando Perez <fperez@colorado.edu>
4850 2003-03-24 Fernando Perez <fperez@colorado.edu>
4847
4851
4848 * setup.py (scriptfiles): renamed the data_files parameter from
4852 * setup.py (scriptfiles): renamed the data_files parameter from
4849 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4853 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4850 for the patch.
4854 for the patch.
4851
4855
4852 2003-03-20 Fernando Perez <fperez@colorado.edu>
4856 2003-03-20 Fernando Perez <fperez@colorado.edu>
4853
4857
4854 * IPython/genutils.py (error): added error() and fatal()
4858 * IPython/genutils.py (error): added error() and fatal()
4855 functions.
4859 functions.
4856
4860
4857 2003-03-18 *** Released version 0.2.15pre3
4861 2003-03-18 *** Released version 0.2.15pre3
4858
4862
4859 2003-03-18 Fernando Perez <fperez@colorado.edu>
4863 2003-03-18 Fernando Perez <fperez@colorado.edu>
4860
4864
4861 * setupext/install_data_ext.py
4865 * setupext/install_data_ext.py
4862 (install_data_ext.initialize_options): Class contributed by Jack
4866 (install_data_ext.initialize_options): Class contributed by Jack
4863 Moffit for fixing the old distutils hack. He is sending this to
4867 Moffit for fixing the old distutils hack. He is sending this to
4864 the distutils folks so in the future we may not need it as a
4868 the distutils folks so in the future we may not need it as a
4865 private fix.
4869 private fix.
4866
4870
4867 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4871 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4868 changes for Debian packaging. See his patch for full details.
4872 changes for Debian packaging. See his patch for full details.
4869 The old distutils hack of making the ipythonrc* files carry a
4873 The old distutils hack of making the ipythonrc* files carry a
4870 bogus .py extension is gone, at last. Examples were moved to a
4874 bogus .py extension is gone, at last. Examples were moved to a
4871 separate subdir under doc/, and the separate executable scripts
4875 separate subdir under doc/, and the separate executable scripts
4872 now live in their own directory. Overall a great cleanup. The
4876 now live in their own directory. Overall a great cleanup. The
4873 manual was updated to use the new files, and setup.py has been
4877 manual was updated to use the new files, and setup.py has been
4874 fixed for this setup.
4878 fixed for this setup.
4875
4879
4876 * IPython/PyColorize.py (Parser.usage): made non-executable and
4880 * IPython/PyColorize.py (Parser.usage): made non-executable and
4877 created a pycolor wrapper around it to be included as a script.
4881 created a pycolor wrapper around it to be included as a script.
4878
4882
4879 2003-03-12 *** Released version 0.2.15pre2
4883 2003-03-12 *** Released version 0.2.15pre2
4880
4884
4881 2003-03-12 Fernando Perez <fperez@colorado.edu>
4885 2003-03-12 Fernando Perez <fperez@colorado.edu>
4882
4886
4883 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4887 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4884 long-standing problem with garbage characters in some terminals.
4888 long-standing problem with garbage characters in some terminals.
4885 The issue was really that the \001 and \002 escapes must _only_ be
4889 The issue was really that the \001 and \002 escapes must _only_ be
4886 passed to input prompts (which call readline), but _never_ to
4890 passed to input prompts (which call readline), but _never_ to
4887 normal text to be printed on screen. I changed ColorANSI to have
4891 normal text to be printed on screen. I changed ColorANSI to have
4888 two classes: TermColors and InputTermColors, each with the
4892 two classes: TermColors and InputTermColors, each with the
4889 appropriate escapes for input prompts or normal text. The code in
4893 appropriate escapes for input prompts or normal text. The code in
4890 Prompts.py got slightly more complicated, but this very old and
4894 Prompts.py got slightly more complicated, but this very old and
4891 annoying bug is finally fixed.
4895 annoying bug is finally fixed.
4892
4896
4893 All the credit for nailing down the real origin of this problem
4897 All the credit for nailing down the real origin of this problem
4894 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4898 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4895 *Many* thanks to him for spending quite a bit of effort on this.
4899 *Many* thanks to him for spending quite a bit of effort on this.
4896
4900
4897 2003-03-05 *** Released version 0.2.15pre1
4901 2003-03-05 *** Released version 0.2.15pre1
4898
4902
4899 2003-03-03 Fernando Perez <fperez@colorado.edu>
4903 2003-03-03 Fernando Perez <fperez@colorado.edu>
4900
4904
4901 * IPython/FakeModule.py: Moved the former _FakeModule to a
4905 * IPython/FakeModule.py: Moved the former _FakeModule to a
4902 separate file, because it's also needed by Magic (to fix a similar
4906 separate file, because it's also needed by Magic (to fix a similar
4903 pickle-related issue in @run).
4907 pickle-related issue in @run).
4904
4908
4905 2003-03-02 Fernando Perez <fperez@colorado.edu>
4909 2003-03-02 Fernando Perez <fperez@colorado.edu>
4906
4910
4907 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4911 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4908 the autocall option at runtime.
4912 the autocall option at runtime.
4909 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4913 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4910 across Magic.py to start separating Magic from InteractiveShell.
4914 across Magic.py to start separating Magic from InteractiveShell.
4911 (Magic._ofind): Fixed to return proper namespace for dotted
4915 (Magic._ofind): Fixed to return proper namespace for dotted
4912 names. Before, a dotted name would always return 'not currently
4916 names. Before, a dotted name would always return 'not currently
4913 defined', because it would find the 'parent'. s.x would be found,
4917 defined', because it would find the 'parent'. s.x would be found,
4914 but since 'x' isn't defined by itself, it would get confused.
4918 but since 'x' isn't defined by itself, it would get confused.
4915 (Magic.magic_run): Fixed pickling problems reported by Ralf
4919 (Magic.magic_run): Fixed pickling problems reported by Ralf
4916 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4920 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4917 that I'd used when Mike Heeter reported similar issues at the
4921 that I'd used when Mike Heeter reported similar issues at the
4918 top-level, but now for @run. It boils down to injecting the
4922 top-level, but now for @run. It boils down to injecting the
4919 namespace where code is being executed with something that looks
4923 namespace where code is being executed with something that looks
4920 enough like a module to fool pickle.dump(). Since a pickle stores
4924 enough like a module to fool pickle.dump(). Since a pickle stores
4921 a named reference to the importing module, we need this for
4925 a named reference to the importing module, we need this for
4922 pickles to save something sensible.
4926 pickles to save something sensible.
4923
4927
4924 * IPython/ipmaker.py (make_IPython): added an autocall option.
4928 * IPython/ipmaker.py (make_IPython): added an autocall option.
4925
4929
4926 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4930 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4927 the auto-eval code. Now autocalling is an option, and the code is
4931 the auto-eval code. Now autocalling is an option, and the code is
4928 also vastly safer. There is no more eval() involved at all.
4932 also vastly safer. There is no more eval() involved at all.
4929
4933
4930 2003-03-01 Fernando Perez <fperez@colorado.edu>
4934 2003-03-01 Fernando Perez <fperez@colorado.edu>
4931
4935
4932 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4936 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4933 dict with named keys instead of a tuple.
4937 dict with named keys instead of a tuple.
4934
4938
4935 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4939 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4936
4940
4937 * setup.py (make_shortcut): Fixed message about directories
4941 * setup.py (make_shortcut): Fixed message about directories
4938 created during Windows installation (the directories were ok, just
4942 created during Windows installation (the directories were ok, just
4939 the printed message was misleading). Thanks to Chris Liechti
4943 the printed message was misleading). Thanks to Chris Liechti
4940 <cliechti-AT-gmx.net> for the heads up.
4944 <cliechti-AT-gmx.net> for the heads up.
4941
4945
4942 2003-02-21 Fernando Perez <fperez@colorado.edu>
4946 2003-02-21 Fernando Perez <fperez@colorado.edu>
4943
4947
4944 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4948 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4945 of ValueError exception when checking for auto-execution. This
4949 of ValueError exception when checking for auto-execution. This
4946 one is raised by things like Numeric arrays arr.flat when the
4950 one is raised by things like Numeric arrays arr.flat when the
4947 array is non-contiguous.
4951 array is non-contiguous.
4948
4952
4949 2003-01-31 Fernando Perez <fperez@colorado.edu>
4953 2003-01-31 Fernando Perez <fperez@colorado.edu>
4950
4954
4951 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4955 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4952 not return any value at all (even though the command would get
4956 not return any value at all (even though the command would get
4953 executed).
4957 executed).
4954 (xsys): Flush stdout right after printing the command to ensure
4958 (xsys): Flush stdout right after printing the command to ensure
4955 proper ordering of commands and command output in the total
4959 proper ordering of commands and command output in the total
4956 output.
4960 output.
4957 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4961 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4958 system/getoutput as defaults. The old ones are kept for
4962 system/getoutput as defaults. The old ones are kept for
4959 compatibility reasons, so no code which uses this library needs
4963 compatibility reasons, so no code which uses this library needs
4960 changing.
4964 changing.
4961
4965
4962 2003-01-27 *** Released version 0.2.14
4966 2003-01-27 *** Released version 0.2.14
4963
4967
4964 2003-01-25 Fernando Perez <fperez@colorado.edu>
4968 2003-01-25 Fernando Perez <fperez@colorado.edu>
4965
4969
4966 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4970 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4967 functions defined in previous edit sessions could not be re-edited
4971 functions defined in previous edit sessions could not be re-edited
4968 (because the temp files were immediately removed). Now temp files
4972 (because the temp files were immediately removed). Now temp files
4969 are removed only at IPython's exit.
4973 are removed only at IPython's exit.
4970 (Magic.magic_run): Improved @run to perform shell-like expansions
4974 (Magic.magic_run): Improved @run to perform shell-like expansions
4971 on its arguments (~users and $VARS). With this, @run becomes more
4975 on its arguments (~users and $VARS). With this, @run becomes more
4972 like a normal command-line.
4976 like a normal command-line.
4973
4977
4974 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4978 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4975 bugs related to embedding and cleaned up that code. A fairly
4979 bugs related to embedding and cleaned up that code. A fairly
4976 important one was the impossibility to access the global namespace
4980 important one was the impossibility to access the global namespace
4977 through the embedded IPython (only local variables were visible).
4981 through the embedded IPython (only local variables were visible).
4978
4982
4979 2003-01-14 Fernando Perez <fperez@colorado.edu>
4983 2003-01-14 Fernando Perez <fperez@colorado.edu>
4980
4984
4981 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4985 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4982 auto-calling to be a bit more conservative. Now it doesn't get
4986 auto-calling to be a bit more conservative. Now it doesn't get
4983 triggered if any of '!=()<>' are in the rest of the input line, to
4987 triggered if any of '!=()<>' are in the rest of the input line, to
4984 allow comparing callables. Thanks to Alex for the heads up.
4988 allow comparing callables. Thanks to Alex for the heads up.
4985
4989
4986 2003-01-07 Fernando Perez <fperez@colorado.edu>
4990 2003-01-07 Fernando Perez <fperez@colorado.edu>
4987
4991
4988 * IPython/genutils.py (page): fixed estimation of the number of
4992 * IPython/genutils.py (page): fixed estimation of the number of
4989 lines in a string to be paged to simply count newlines. This
4993 lines in a string to be paged to simply count newlines. This
4990 prevents over-guessing due to embedded escape sequences. A better
4994 prevents over-guessing due to embedded escape sequences. A better
4991 long-term solution would involve stripping out the control chars
4995 long-term solution would involve stripping out the control chars
4992 for the count, but it's potentially so expensive I just don't
4996 for the count, but it's potentially so expensive I just don't
4993 think it's worth doing.
4997 think it's worth doing.
4994
4998
4995 2002-12-19 *** Released version 0.2.14pre50
4999 2002-12-19 *** Released version 0.2.14pre50
4996
5000
4997 2002-12-19 Fernando Perez <fperez@colorado.edu>
5001 2002-12-19 Fernando Perez <fperez@colorado.edu>
4998
5002
4999 * tools/release (version): Changed release scripts to inform
5003 * tools/release (version): Changed release scripts to inform
5000 Andrea and build a NEWS file with a list of recent changes.
5004 Andrea and build a NEWS file with a list of recent changes.
5001
5005
5002 * IPython/ColorANSI.py (__all__): changed terminal detection
5006 * IPython/ColorANSI.py (__all__): changed terminal detection
5003 code. Seems to work better for xterms without breaking
5007 code. Seems to work better for xterms without breaking
5004 konsole. Will need more testing to determine if WinXP and Mac OSX
5008 konsole. Will need more testing to determine if WinXP and Mac OSX
5005 also work ok.
5009 also work ok.
5006
5010
5007 2002-12-18 *** Released version 0.2.14pre49
5011 2002-12-18 *** Released version 0.2.14pre49
5008
5012
5009 2002-12-18 Fernando Perez <fperez@colorado.edu>
5013 2002-12-18 Fernando Perez <fperez@colorado.edu>
5010
5014
5011 * Docs: added new info about Mac OSX, from Andrea.
5015 * Docs: added new info about Mac OSX, from Andrea.
5012
5016
5013 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
5017 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
5014 allow direct plotting of python strings whose format is the same
5018 allow direct plotting of python strings whose format is the same
5015 of gnuplot data files.
5019 of gnuplot data files.
5016
5020
5017 2002-12-16 Fernando Perez <fperez@colorado.edu>
5021 2002-12-16 Fernando Perez <fperez@colorado.edu>
5018
5022
5019 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
5023 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
5020 value of exit question to be acknowledged.
5024 value of exit question to be acknowledged.
5021
5025
5022 2002-12-03 Fernando Perez <fperez@colorado.edu>
5026 2002-12-03 Fernando Perez <fperez@colorado.edu>
5023
5027
5024 * IPython/ipmaker.py: removed generators, which had been added
5028 * IPython/ipmaker.py: removed generators, which had been added
5025 by mistake in an earlier debugging run. This was causing trouble
5029 by mistake in an earlier debugging run. This was causing trouble
5026 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
5030 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
5027 for pointing this out.
5031 for pointing this out.
5028
5032
5029 2002-11-17 Fernando Perez <fperez@colorado.edu>
5033 2002-11-17 Fernando Perez <fperez@colorado.edu>
5030
5034
5031 * Manual: updated the Gnuplot section.
5035 * Manual: updated the Gnuplot section.
5032
5036
5033 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
5037 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
5034 a much better split of what goes in Runtime and what goes in
5038 a much better split of what goes in Runtime and what goes in
5035 Interactive.
5039 Interactive.
5036
5040
5037 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
5041 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
5038 being imported from iplib.
5042 being imported from iplib.
5039
5043
5040 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
5044 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
5041 for command-passing. Now the global Gnuplot instance is called
5045 for command-passing. Now the global Gnuplot instance is called
5042 'gp' instead of 'g', which was really a far too fragile and
5046 'gp' instead of 'g', which was really a far too fragile and
5043 common name.
5047 common name.
5044
5048
5045 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
5049 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
5046 bounding boxes generated by Gnuplot for square plots.
5050 bounding boxes generated by Gnuplot for square plots.
5047
5051
5048 * IPython/genutils.py (popkey): new function added. I should
5052 * IPython/genutils.py (popkey): new function added. I should
5049 suggest this on c.l.py as a dict method, it seems useful.
5053 suggest this on c.l.py as a dict method, it seems useful.
5050
5054
5051 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
5055 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
5052 to transparently handle PostScript generation. MUCH better than
5056 to transparently handle PostScript generation. MUCH better than
5053 the previous plot_eps/replot_eps (which I removed now). The code
5057 the previous plot_eps/replot_eps (which I removed now). The code
5054 is also fairly clean and well documented now (including
5058 is also fairly clean and well documented now (including
5055 docstrings).
5059 docstrings).
5056
5060
5057 2002-11-13 Fernando Perez <fperez@colorado.edu>
5061 2002-11-13 Fernando Perez <fperez@colorado.edu>
5058
5062
5059 * IPython/Magic.py (Magic.magic_edit): fixed docstring
5063 * IPython/Magic.py (Magic.magic_edit): fixed docstring
5060 (inconsistent with options).
5064 (inconsistent with options).
5061
5065
5062 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
5066 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
5063 manually disabled, I don't know why. Fixed it.
5067 manually disabled, I don't know why. Fixed it.
5064 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
5068 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
5065 eps output.
5069 eps output.
5066
5070
5067 2002-11-12 Fernando Perez <fperez@colorado.edu>
5071 2002-11-12 Fernando Perez <fperez@colorado.edu>
5068
5072
5069 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
5073 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
5070 don't propagate up to caller. Fixes crash reported by François
5074 don't propagate up to caller. Fixes crash reported by François
5071 Pinard.
5075 Pinard.
5072
5076
5073 2002-11-09 Fernando Perez <fperez@colorado.edu>
5077 2002-11-09 Fernando Perez <fperez@colorado.edu>
5074
5078
5075 * IPython/ipmaker.py (make_IPython): fixed problem with writing
5079 * IPython/ipmaker.py (make_IPython): fixed problem with writing
5076 history file for new users.
5080 history file for new users.
5077 (make_IPython): fixed bug where initial install would leave the
5081 (make_IPython): fixed bug where initial install would leave the
5078 user running in the .ipython dir.
5082 user running in the .ipython dir.
5079 (make_IPython): fixed bug where config dir .ipython would be
5083 (make_IPython): fixed bug where config dir .ipython would be
5080 created regardless of the given -ipythondir option. Thanks to Cory
5084 created regardless of the given -ipythondir option. Thanks to Cory
5081 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
5085 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
5082
5086
5083 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
5087 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
5084 type confirmations. Will need to use it in all of IPython's code
5088 type confirmations. Will need to use it in all of IPython's code
5085 consistently.
5089 consistently.
5086
5090
5087 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
5091 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
5088 context to print 31 lines instead of the default 5. This will make
5092 context to print 31 lines instead of the default 5. This will make
5089 the crash reports extremely detailed in case the problem is in
5093 the crash reports extremely detailed in case the problem is in
5090 libraries I don't have access to.
5094 libraries I don't have access to.
5091
5095
5092 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
5096 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
5093 line of defense' code to still crash, but giving users fair
5097 line of defense' code to still crash, but giving users fair
5094 warning. I don't want internal errors to go unreported: if there's
5098 warning. I don't want internal errors to go unreported: if there's
5095 an internal problem, IPython should crash and generate a full
5099 an internal problem, IPython should crash and generate a full
5096 report.
5100 report.
5097
5101
5098 2002-11-08 Fernando Perez <fperez@colorado.edu>
5102 2002-11-08 Fernando Perez <fperez@colorado.edu>
5099
5103
5100 * IPython/iplib.py (InteractiveShell.interact): added code to trap
5104 * IPython/iplib.py (InteractiveShell.interact): added code to trap
5101 otherwise uncaught exceptions which can appear if people set
5105 otherwise uncaught exceptions which can appear if people set
5102 sys.stdout to something badly broken. Thanks to a crash report
5106 sys.stdout to something badly broken. Thanks to a crash report
5103 from henni-AT-mail.brainbot.com.
5107 from henni-AT-mail.brainbot.com.
5104
5108
5105 2002-11-04 Fernando Perez <fperez@colorado.edu>
5109 2002-11-04 Fernando Perez <fperez@colorado.edu>
5106
5110
5107 * IPython/iplib.py (InteractiveShell.interact): added
5111 * IPython/iplib.py (InteractiveShell.interact): added
5108 __IPYTHON__active to the builtins. It's a flag which goes on when
5112 __IPYTHON__active to the builtins. It's a flag which goes on when
5109 the interaction starts and goes off again when it stops. This
5113 the interaction starts and goes off again when it stops. This
5110 allows embedding code to detect being inside IPython. Before this
5114 allows embedding code to detect being inside IPython. Before this
5111 was done via __IPYTHON__, but that only shows that an IPython
5115 was done via __IPYTHON__, but that only shows that an IPython
5112 instance has been created.
5116 instance has been created.
5113
5117
5114 * IPython/Magic.py (Magic.magic_env): I realized that in a
5118 * IPython/Magic.py (Magic.magic_env): I realized that in a
5115 UserDict, instance.data holds the data as a normal dict. So I
5119 UserDict, instance.data holds the data as a normal dict. So I
5116 modified @env to return os.environ.data instead of rebuilding a
5120 modified @env to return os.environ.data instead of rebuilding a
5117 dict by hand.
5121 dict by hand.
5118
5122
5119 2002-11-02 Fernando Perez <fperez@colorado.edu>
5123 2002-11-02 Fernando Perez <fperez@colorado.edu>
5120
5124
5121 * IPython/genutils.py (warn): changed so that level 1 prints no
5125 * IPython/genutils.py (warn): changed so that level 1 prints no
5122 header. Level 2 is now the default (with 'WARNING' header, as
5126 header. Level 2 is now the default (with 'WARNING' header, as
5123 before). I think I tracked all places where changes were needed in
5127 before). I think I tracked all places where changes were needed in
5124 IPython, but outside code using the old level numbering may have
5128 IPython, but outside code using the old level numbering may have
5125 broken.
5129 broken.
5126
5130
5127 * IPython/iplib.py (InteractiveShell.runcode): added this to
5131 * IPython/iplib.py (InteractiveShell.runcode): added this to
5128 handle the tracebacks in SystemExit traps correctly. The previous
5132 handle the tracebacks in SystemExit traps correctly. The previous
5129 code (through interact) was printing more of the stack than
5133 code (through interact) was printing more of the stack than
5130 necessary, showing IPython internal code to the user.
5134 necessary, showing IPython internal code to the user.
5131
5135
5132 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
5136 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
5133 default. Now that the default at the confirmation prompt is yes,
5137 default. Now that the default at the confirmation prompt is yes,
5134 it's not so intrusive. François' argument that ipython sessions
5138 it's not so intrusive. François' argument that ipython sessions
5135 tend to be complex enough not to lose them from an accidental C-d,
5139 tend to be complex enough not to lose them from an accidental C-d,
5136 is a valid one.
5140 is a valid one.
5137
5141
5138 * IPython/iplib.py (InteractiveShell.interact): added a
5142 * IPython/iplib.py (InteractiveShell.interact): added a
5139 showtraceback() call to the SystemExit trap, and modified the exit
5143 showtraceback() call to the SystemExit trap, and modified the exit
5140 confirmation to have yes as the default.
5144 confirmation to have yes as the default.
5141
5145
5142 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
5146 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
5143 this file. It's been gone from the code for a long time, this was
5147 this file. It's been gone from the code for a long time, this was
5144 simply leftover junk.
5148 simply leftover junk.
5145
5149
5146 2002-11-01 Fernando Perez <fperez@colorado.edu>
5150 2002-11-01 Fernando Perez <fperez@colorado.edu>
5147
5151
5148 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
5152 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
5149 added. If set, IPython now traps EOF and asks for
5153 added. If set, IPython now traps EOF and asks for
5150 confirmation. After a request by François Pinard.
5154 confirmation. After a request by François Pinard.
5151
5155
5152 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
5156 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
5153 of @abort, and with a new (better) mechanism for handling the
5157 of @abort, and with a new (better) mechanism for handling the
5154 exceptions.
5158 exceptions.
5155
5159
5156 2002-10-27 Fernando Perez <fperez@colorado.edu>
5160 2002-10-27 Fernando Perez <fperez@colorado.edu>
5157
5161
5158 * IPython/usage.py (__doc__): updated the --help information and
5162 * IPython/usage.py (__doc__): updated the --help information and
5159 the ipythonrc file to indicate that -log generates
5163 the ipythonrc file to indicate that -log generates
5160 ./ipython.log. Also fixed the corresponding info in @logstart.
5164 ./ipython.log. Also fixed the corresponding info in @logstart.
5161 This and several other fixes in the manuals thanks to reports by
5165 This and several other fixes in the manuals thanks to reports by
5162 François Pinard <pinard-AT-iro.umontreal.ca>.
5166 François Pinard <pinard-AT-iro.umontreal.ca>.
5163
5167
5164 * IPython/Logger.py (Logger.switch_log): Fixed error message to
5168 * IPython/Logger.py (Logger.switch_log): Fixed error message to
5165 refer to @logstart (instead of @log, which doesn't exist).
5169 refer to @logstart (instead of @log, which doesn't exist).
5166
5170
5167 * IPython/iplib.py (InteractiveShell._prefilter): fixed
5171 * IPython/iplib.py (InteractiveShell._prefilter): fixed
5168 AttributeError crash. Thanks to Christopher Armstrong
5172 AttributeError crash. Thanks to Christopher Armstrong
5169 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
5173 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
5170 introduced recently (in 0.2.14pre37) with the fix to the eval
5174 introduced recently (in 0.2.14pre37) with the fix to the eval
5171 problem mentioned below.
5175 problem mentioned below.
5172
5176
5173 2002-10-17 Fernando Perez <fperez@colorado.edu>
5177 2002-10-17 Fernando Perez <fperez@colorado.edu>
5174
5178
5175 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
5179 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
5176 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
5180 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
5177
5181
5178 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
5182 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
5179 this function to fix a problem reported by Alex Schmolck. He saw
5183 this function to fix a problem reported by Alex Schmolck. He saw
5180 it with list comprehensions and generators, which were getting
5184 it with list comprehensions and generators, which were getting
5181 called twice. The real problem was an 'eval' call in testing for
5185 called twice. The real problem was an 'eval' call in testing for
5182 automagic which was evaluating the input line silently.
5186 automagic which was evaluating the input line silently.
5183
5187
5184 This is a potentially very nasty bug, if the input has side
5188 This is a potentially very nasty bug, if the input has side
5185 effects which must not be repeated. The code is much cleaner now,
5189 effects which must not be repeated. The code is much cleaner now,
5186 without any blanket 'except' left and with a regexp test for
5190 without any blanket 'except' left and with a regexp test for
5187 actual function names.
5191 actual function names.
5188
5192
5189 But an eval remains, which I'm not fully comfortable with. I just
5193 But an eval remains, which I'm not fully comfortable with. I just
5190 don't know how to find out if an expression could be a callable in
5194 don't know how to find out if an expression could be a callable in
5191 the user's namespace without doing an eval on the string. However
5195 the user's namespace without doing an eval on the string. However
5192 that string is now much more strictly checked so that no code
5196 that string is now much more strictly checked so that no code
5193 slips by, so the eval should only happen for things that can
5197 slips by, so the eval should only happen for things that can
5194 really be only function/method names.
5198 really be only function/method names.
5195
5199
5196 2002-10-15 Fernando Perez <fperez@colorado.edu>
5200 2002-10-15 Fernando Perez <fperez@colorado.edu>
5197
5201
5198 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
5202 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
5199 OSX information to main manual, removed README_Mac_OSX file from
5203 OSX information to main manual, removed README_Mac_OSX file from
5200 distribution. Also updated credits for recent additions.
5204 distribution. Also updated credits for recent additions.
5201
5205
5202 2002-10-10 Fernando Perez <fperez@colorado.edu>
5206 2002-10-10 Fernando Perez <fperez@colorado.edu>
5203
5207
5204 * README_Mac_OSX: Added a README for Mac OSX users for fixing
5208 * README_Mac_OSX: Added a README for Mac OSX users for fixing
5205 terminal-related issues. Many thanks to Andrea Riciputi
5209 terminal-related issues. Many thanks to Andrea Riciputi
5206 <andrea.riciputi-AT-libero.it> for writing it.
5210 <andrea.riciputi-AT-libero.it> for writing it.
5207
5211
5208 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
5212 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
5209 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5213 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5210
5214
5211 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
5215 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
5212 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
5216 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
5213 <syver-en-AT-online.no> who both submitted patches for this problem.
5217 <syver-en-AT-online.no> who both submitted patches for this problem.
5214
5218
5215 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
5219 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
5216 global embedding to make sure that things don't overwrite user
5220 global embedding to make sure that things don't overwrite user
5217 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
5221 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
5218
5222
5219 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
5223 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
5220 compatibility. Thanks to Hayden Callow
5224 compatibility. Thanks to Hayden Callow
5221 <h.callow-AT-elec.canterbury.ac.nz>
5225 <h.callow-AT-elec.canterbury.ac.nz>
5222
5226
5223 2002-10-04 Fernando Perez <fperez@colorado.edu>
5227 2002-10-04 Fernando Perez <fperez@colorado.edu>
5224
5228
5225 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
5229 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
5226 Gnuplot.File objects.
5230 Gnuplot.File objects.
5227
5231
5228 2002-07-23 Fernando Perez <fperez@colorado.edu>
5232 2002-07-23 Fernando Perez <fperez@colorado.edu>
5229
5233
5230 * IPython/genutils.py (timing): Added timings() and timing() for
5234 * IPython/genutils.py (timing): Added timings() and timing() for
5231 quick access to the most commonly needed data, the execution
5235 quick access to the most commonly needed data, the execution
5232 times. Old timing() renamed to timings_out().
5236 times. Old timing() renamed to timings_out().
5233
5237
5234 2002-07-18 Fernando Perez <fperez@colorado.edu>
5238 2002-07-18 Fernando Perez <fperez@colorado.edu>
5235
5239
5236 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
5240 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
5237 bug with nested instances disrupting the parent's tab completion.
5241 bug with nested instances disrupting the parent's tab completion.
5238
5242
5239 * IPython/iplib.py (all_completions): Added Alex Schmolck's
5243 * IPython/iplib.py (all_completions): Added Alex Schmolck's
5240 all_completions code to begin the emacs integration.
5244 all_completions code to begin the emacs integration.
5241
5245
5242 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
5246 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
5243 argument to allow titling individual arrays when plotting.
5247 argument to allow titling individual arrays when plotting.
5244
5248
5245 2002-07-15 Fernando Perez <fperez@colorado.edu>
5249 2002-07-15 Fernando Perez <fperez@colorado.edu>
5246
5250
5247 * setup.py (make_shortcut): changed to retrieve the value of
5251 * setup.py (make_shortcut): changed to retrieve the value of
5248 'Program Files' directory from the registry (this value changes in
5252 'Program Files' directory from the registry (this value changes in
5249 non-english versions of Windows). Thanks to Thomas Fanslau
5253 non-english versions of Windows). Thanks to Thomas Fanslau
5250 <tfanslau-AT-gmx.de> for the report.
5254 <tfanslau-AT-gmx.de> for the report.
5251
5255
5252 2002-07-10 Fernando Perez <fperez@colorado.edu>
5256 2002-07-10 Fernando Perez <fperez@colorado.edu>
5253
5257
5254 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
5258 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
5255 a bug in pdb, which crashes if a line with only whitespace is
5259 a bug in pdb, which crashes if a line with only whitespace is
5256 entered. Bug report submitted to sourceforge.
5260 entered. Bug report submitted to sourceforge.
5257
5261
5258 2002-07-09 Fernando Perez <fperez@colorado.edu>
5262 2002-07-09 Fernando Perez <fperez@colorado.edu>
5259
5263
5260 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
5264 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
5261 reporting exceptions (it's a bug in inspect.py, I just set a
5265 reporting exceptions (it's a bug in inspect.py, I just set a
5262 workaround).
5266 workaround).
5263
5267
5264 2002-07-08 Fernando Perez <fperez@colorado.edu>
5268 2002-07-08 Fernando Perez <fperez@colorado.edu>
5265
5269
5266 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
5270 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
5267 __IPYTHON__ in __builtins__ to show up in user_ns.
5271 __IPYTHON__ in __builtins__ to show up in user_ns.
5268
5272
5269 2002-07-03 Fernando Perez <fperez@colorado.edu>
5273 2002-07-03 Fernando Perez <fperez@colorado.edu>
5270
5274
5271 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
5275 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
5272 name from @gp_set_instance to @gp_set_default.
5276 name from @gp_set_instance to @gp_set_default.
5273
5277
5274 * IPython/ipmaker.py (make_IPython): default editor value set to
5278 * IPython/ipmaker.py (make_IPython): default editor value set to
5275 '0' (a string), to match the rc file. Otherwise will crash when
5279 '0' (a string), to match the rc file. Otherwise will crash when
5276 .strip() is called on it.
5280 .strip() is called on it.
5277
5281
5278
5282
5279 2002-06-28 Fernando Perez <fperez@colorado.edu>
5283 2002-06-28 Fernando Perez <fperez@colorado.edu>
5280
5284
5281 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
5285 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
5282 of files in current directory when a file is executed via
5286 of files in current directory when a file is executed via
5283 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
5287 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
5284
5288
5285 * setup.py (manfiles): fix for rpm builds, submitted by RA
5289 * setup.py (manfiles): fix for rpm builds, submitted by RA
5286 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
5290 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
5287
5291
5288 * IPython/ipmaker.py (make_IPython): fixed lookup of default
5292 * IPython/ipmaker.py (make_IPython): fixed lookup of default
5289 editor when set to '0'. Problem was, '0' evaluates to True (it's a
5293 editor when set to '0'. Problem was, '0' evaluates to True (it's a
5290 string!). A. Schmolck caught this one.
5294 string!). A. Schmolck caught this one.
5291
5295
5292 2002-06-27 Fernando Perez <fperez@colorado.edu>
5296 2002-06-27 Fernando Perez <fperez@colorado.edu>
5293
5297
5294 * IPython/ipmaker.py (make_IPython): fixed bug when running user
5298 * IPython/ipmaker.py (make_IPython): fixed bug when running user
5295 defined files at the cmd line. __name__ wasn't being set to
5299 defined files at the cmd line. __name__ wasn't being set to
5296 __main__.
5300 __main__.
5297
5301
5298 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
5302 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
5299 regular lists and tuples besides Numeric arrays.
5303 regular lists and tuples besides Numeric arrays.
5300
5304
5301 * IPython/Prompts.py (CachedOutput.__call__): Added output
5305 * IPython/Prompts.py (CachedOutput.__call__): Added output
5302 supression for input ending with ';'. Similar to Mathematica and
5306 supression for input ending with ';'. Similar to Mathematica and
5303 Matlab. The _* vars and Out[] list are still updated, just like
5307 Matlab. The _* vars and Out[] list are still updated, just like
5304 Mathematica behaves.
5308 Mathematica behaves.
5305
5309
5306 2002-06-25 Fernando Perez <fperez@colorado.edu>
5310 2002-06-25 Fernando Perez <fperez@colorado.edu>
5307
5311
5308 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
5312 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
5309 .ini extensions for profiels under Windows.
5313 .ini extensions for profiels under Windows.
5310
5314
5311 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
5315 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
5312 string form. Fix contributed by Alexander Schmolck
5316 string form. Fix contributed by Alexander Schmolck
5313 <a.schmolck-AT-gmx.net>
5317 <a.schmolck-AT-gmx.net>
5314
5318
5315 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
5319 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
5316 pre-configured Gnuplot instance.
5320 pre-configured Gnuplot instance.
5317
5321
5318 2002-06-21 Fernando Perez <fperez@colorado.edu>
5322 2002-06-21 Fernando Perez <fperez@colorado.edu>
5319
5323
5320 * IPython/numutils.py (exp_safe): new function, works around the
5324 * IPython/numutils.py (exp_safe): new function, works around the
5321 underflow problems in Numeric.
5325 underflow problems in Numeric.
5322 (log2): New fn. Safe log in base 2: returns exact integer answer
5326 (log2): New fn. Safe log in base 2: returns exact integer answer
5323 for exact integer powers of 2.
5327 for exact integer powers of 2.
5324
5328
5325 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
5329 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
5326 properly.
5330 properly.
5327
5331
5328 2002-06-20 Fernando Perez <fperez@colorado.edu>
5332 2002-06-20 Fernando Perez <fperez@colorado.edu>
5329
5333
5330 * IPython/genutils.py (timing): new function like
5334 * IPython/genutils.py (timing): new function like
5331 Mathematica's. Similar to time_test, but returns more info.
5335 Mathematica's. Similar to time_test, but returns more info.
5332
5336
5333 2002-06-18 Fernando Perez <fperez@colorado.edu>
5337 2002-06-18 Fernando Perez <fperez@colorado.edu>
5334
5338
5335 * IPython/Magic.py (Magic.magic_save): modified @save and @r
5339 * IPython/Magic.py (Magic.magic_save): modified @save and @r
5336 according to Mike Heeter's suggestions.
5340 according to Mike Heeter's suggestions.
5337
5341
5338 2002-06-16 Fernando Perez <fperez@colorado.edu>
5342 2002-06-16 Fernando Perez <fperez@colorado.edu>
5339
5343
5340 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
5344 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
5341 system. GnuplotMagic is gone as a user-directory option. New files
5345 system. GnuplotMagic is gone as a user-directory option. New files
5342 make it easier to use all the gnuplot stuff both from external
5346 make it easier to use all the gnuplot stuff both from external
5343 programs as well as from IPython. Had to rewrite part of
5347 programs as well as from IPython. Had to rewrite part of
5344 hardcopy() b/c of a strange bug: often the ps files simply don't
5348 hardcopy() b/c of a strange bug: often the ps files simply don't
5345 get created, and require a repeat of the command (often several
5349 get created, and require a repeat of the command (often several
5346 times).
5350 times).
5347
5351
5348 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
5352 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
5349 resolve output channel at call time, so that if sys.stderr has
5353 resolve output channel at call time, so that if sys.stderr has
5350 been redirected by user this gets honored.
5354 been redirected by user this gets honored.
5351
5355
5352 2002-06-13 Fernando Perez <fperez@colorado.edu>
5356 2002-06-13 Fernando Perez <fperez@colorado.edu>
5353
5357
5354 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
5358 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
5355 IPShell. Kept a copy with the old names to avoid breaking people's
5359 IPShell. Kept a copy with the old names to avoid breaking people's
5356 embedded code.
5360 embedded code.
5357
5361
5358 * IPython/ipython: simplified it to the bare minimum after
5362 * IPython/ipython: simplified it to the bare minimum after
5359 Holger's suggestions. Added info about how to use it in
5363 Holger's suggestions. Added info about how to use it in
5360 PYTHONSTARTUP.
5364 PYTHONSTARTUP.
5361
5365
5362 * IPython/Shell.py (IPythonShell): changed the options passing
5366 * IPython/Shell.py (IPythonShell): changed the options passing
5363 from a string with funky %s replacements to a straight list. Maybe
5367 from a string with funky %s replacements to a straight list. Maybe
5364 a bit more typing, but it follows sys.argv conventions, so there's
5368 a bit more typing, but it follows sys.argv conventions, so there's
5365 less special-casing to remember.
5369 less special-casing to remember.
5366
5370
5367 2002-06-12 Fernando Perez <fperez@colorado.edu>
5371 2002-06-12 Fernando Perez <fperez@colorado.edu>
5368
5372
5369 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
5373 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
5370 command. Thanks to a suggestion by Mike Heeter.
5374 command. Thanks to a suggestion by Mike Heeter.
5371 (Magic.magic_pfile): added behavior to look at filenames if given
5375 (Magic.magic_pfile): added behavior to look at filenames if given
5372 arg is not a defined object.
5376 arg is not a defined object.
5373 (Magic.magic_save): New @save function to save code snippets. Also
5377 (Magic.magic_save): New @save function to save code snippets. Also
5374 a Mike Heeter idea.
5378 a Mike Heeter idea.
5375
5379
5376 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
5380 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
5377 plot() and replot(). Much more convenient now, especially for
5381 plot() and replot(). Much more convenient now, especially for
5378 interactive use.
5382 interactive use.
5379
5383
5380 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
5384 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
5381 filenames.
5385 filenames.
5382
5386
5383 2002-06-02 Fernando Perez <fperez@colorado.edu>
5387 2002-06-02 Fernando Perez <fperez@colorado.edu>
5384
5388
5385 * IPython/Struct.py (Struct.__init__): modified to admit
5389 * IPython/Struct.py (Struct.__init__): modified to admit
5386 initialization via another struct.
5390 initialization via another struct.
5387
5391
5388 * IPython/genutils.py (SystemExec.__init__): New stateful
5392 * IPython/genutils.py (SystemExec.__init__): New stateful
5389 interface to xsys and bq. Useful for writing system scripts.
5393 interface to xsys and bq. Useful for writing system scripts.
5390
5394
5391 2002-05-30 Fernando Perez <fperez@colorado.edu>
5395 2002-05-30 Fernando Perez <fperez@colorado.edu>
5392
5396
5393 * MANIFEST.in: Changed docfile selection to exclude all the lyx
5397 * MANIFEST.in: Changed docfile selection to exclude all the lyx
5394 documents. This will make the user download smaller (it's getting
5398 documents. This will make the user download smaller (it's getting
5395 too big).
5399 too big).
5396
5400
5397 2002-05-29 Fernando Perez <fperez@colorado.edu>
5401 2002-05-29 Fernando Perez <fperez@colorado.edu>
5398
5402
5399 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
5403 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
5400 fix problems with shelve and pickle. Seems to work, but I don't
5404 fix problems with shelve and pickle. Seems to work, but I don't
5401 know if corner cases break it. Thanks to Mike Heeter
5405 know if corner cases break it. Thanks to Mike Heeter
5402 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
5406 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
5403
5407
5404 2002-05-24 Fernando Perez <fperez@colorado.edu>
5408 2002-05-24 Fernando Perez <fperez@colorado.edu>
5405
5409
5406 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
5410 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
5407 macros having broken.
5411 macros having broken.
5408
5412
5409 2002-05-21 Fernando Perez <fperez@colorado.edu>
5413 2002-05-21 Fernando Perez <fperez@colorado.edu>
5410
5414
5411 * IPython/Magic.py (Magic.magic_logstart): fixed recently
5415 * IPython/Magic.py (Magic.magic_logstart): fixed recently
5412 introduced logging bug: all history before logging started was
5416 introduced logging bug: all history before logging started was
5413 being written one character per line! This came from the redesign
5417 being written one character per line! This came from the redesign
5414 of the input history as a special list which slices to strings,
5418 of the input history as a special list which slices to strings,
5415 not to lists.
5419 not to lists.
5416
5420
5417 2002-05-20 Fernando Perez <fperez@colorado.edu>
5421 2002-05-20 Fernando Perez <fperez@colorado.edu>
5418
5422
5419 * IPython/Prompts.py (CachedOutput.__init__): made the color table
5423 * IPython/Prompts.py (CachedOutput.__init__): made the color table
5420 be an attribute of all classes in this module. The design of these
5424 be an attribute of all classes in this module. The design of these
5421 classes needs some serious overhauling.
5425 classes needs some serious overhauling.
5422
5426
5423 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
5427 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
5424 which was ignoring '_' in option names.
5428 which was ignoring '_' in option names.
5425
5429
5426 * IPython/ultraTB.py (FormattedTB.__init__): Changed
5430 * IPython/ultraTB.py (FormattedTB.__init__): Changed
5427 'Verbose_novars' to 'Context' and made it the new default. It's a
5431 'Verbose_novars' to 'Context' and made it the new default. It's a
5428 bit more readable and also safer than verbose.
5432 bit more readable and also safer than verbose.
5429
5433
5430 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
5434 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
5431 triple-quoted strings.
5435 triple-quoted strings.
5432
5436
5433 * IPython/OInspect.py (__all__): new module exposing the object
5437 * IPython/OInspect.py (__all__): new module exposing the object
5434 introspection facilities. Now the corresponding magics are dummy
5438 introspection facilities. Now the corresponding magics are dummy
5435 wrappers around this. Having this module will make it much easier
5439 wrappers around this. Having this module will make it much easier
5436 to put these functions into our modified pdb.
5440 to put these functions into our modified pdb.
5437 This new object inspector system uses the new colorizing module,
5441 This new object inspector system uses the new colorizing module,
5438 so source code and other things are nicely syntax highlighted.
5442 so source code and other things are nicely syntax highlighted.
5439
5443
5440 2002-05-18 Fernando Perez <fperez@colorado.edu>
5444 2002-05-18 Fernando Perez <fperez@colorado.edu>
5441
5445
5442 * IPython/ColorANSI.py: Split the coloring tools into a separate
5446 * IPython/ColorANSI.py: Split the coloring tools into a separate
5443 module so I can use them in other code easier (they were part of
5447 module so I can use them in other code easier (they were part of
5444 ultraTB).
5448 ultraTB).
5445
5449
5446 2002-05-17 Fernando Perez <fperez@colorado.edu>
5450 2002-05-17 Fernando Perez <fperez@colorado.edu>
5447
5451
5448 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5452 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5449 fixed it to set the global 'g' also to the called instance, as
5453 fixed it to set the global 'g' also to the called instance, as
5450 long as 'g' was still a gnuplot instance (so it doesn't overwrite
5454 long as 'g' was still a gnuplot instance (so it doesn't overwrite
5451 user's 'g' variables).
5455 user's 'g' variables).
5452
5456
5453 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
5457 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
5454 global variables (aliases to _ih,_oh) so that users which expect
5458 global variables (aliases to _ih,_oh) so that users which expect
5455 In[5] or Out[7] to work aren't unpleasantly surprised.
5459 In[5] or Out[7] to work aren't unpleasantly surprised.
5456 (InputList.__getslice__): new class to allow executing slices of
5460 (InputList.__getslice__): new class to allow executing slices of
5457 input history directly. Very simple class, complements the use of
5461 input history directly. Very simple class, complements the use of
5458 macros.
5462 macros.
5459
5463
5460 2002-05-16 Fernando Perez <fperez@colorado.edu>
5464 2002-05-16 Fernando Perez <fperez@colorado.edu>
5461
5465
5462 * setup.py (docdirbase): make doc directory be just doc/IPython
5466 * setup.py (docdirbase): make doc directory be just doc/IPython
5463 without version numbers, it will reduce clutter for users.
5467 without version numbers, it will reduce clutter for users.
5464
5468
5465 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
5469 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
5466 execfile call to prevent possible memory leak. See for details:
5470 execfile call to prevent possible memory leak. See for details:
5467 http://mail.python.org/pipermail/python-list/2002-February/088476.html
5471 http://mail.python.org/pipermail/python-list/2002-February/088476.html
5468
5472
5469 2002-05-15 Fernando Perez <fperez@colorado.edu>
5473 2002-05-15 Fernando Perez <fperez@colorado.edu>
5470
5474
5471 * IPython/Magic.py (Magic.magic_psource): made the object
5475 * IPython/Magic.py (Magic.magic_psource): made the object
5472 introspection names be more standard: pdoc, pdef, pfile and
5476 introspection names be more standard: pdoc, pdef, pfile and
5473 psource. They all print/page their output, and it makes
5477 psource. They all print/page their output, and it makes
5474 remembering them easier. Kept old names for compatibility as
5478 remembering them easier. Kept old names for compatibility as
5475 aliases.
5479 aliases.
5476
5480
5477 2002-05-14 Fernando Perez <fperez@colorado.edu>
5481 2002-05-14 Fernando Perez <fperez@colorado.edu>
5478
5482
5479 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
5483 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
5480 what the mouse problem was. The trick is to use gnuplot with temp
5484 what the mouse problem was. The trick is to use gnuplot with temp
5481 files and NOT with pipes (for data communication), because having
5485 files and NOT with pipes (for data communication), because having
5482 both pipes and the mouse on is bad news.
5486 both pipes and the mouse on is bad news.
5483
5487
5484 2002-05-13 Fernando Perez <fperez@colorado.edu>
5488 2002-05-13 Fernando Perez <fperez@colorado.edu>
5485
5489
5486 * IPython/Magic.py (Magic._ofind): fixed namespace order search
5490 * IPython/Magic.py (Magic._ofind): fixed namespace order search
5487 bug. Information would be reported about builtins even when
5491 bug. Information would be reported about builtins even when
5488 user-defined functions overrode them.
5492 user-defined functions overrode them.
5489
5493
5490 2002-05-11 Fernando Perez <fperez@colorado.edu>
5494 2002-05-11 Fernando Perez <fperez@colorado.edu>
5491
5495
5492 * IPython/__init__.py (__all__): removed FlexCompleter from
5496 * IPython/__init__.py (__all__): removed FlexCompleter from
5493 __all__ so that things don't fail in platforms without readline.
5497 __all__ so that things don't fail in platforms without readline.
5494
5498
5495 2002-05-10 Fernando Perez <fperez@colorado.edu>
5499 2002-05-10 Fernando Perez <fperez@colorado.edu>
5496
5500
5497 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
5501 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
5498 it requires Numeric, effectively making Numeric a dependency for
5502 it requires Numeric, effectively making Numeric a dependency for
5499 IPython.
5503 IPython.
5500
5504
5501 * Released 0.2.13
5505 * Released 0.2.13
5502
5506
5503 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
5507 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
5504 profiler interface. Now all the major options from the profiler
5508 profiler interface. Now all the major options from the profiler
5505 module are directly supported in IPython, both for single
5509 module are directly supported in IPython, both for single
5506 expressions (@prun) and for full programs (@run -p).
5510 expressions (@prun) and for full programs (@run -p).
5507
5511
5508 2002-05-09 Fernando Perez <fperez@colorado.edu>
5512 2002-05-09 Fernando Perez <fperez@colorado.edu>
5509
5513
5510 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
5514 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
5511 magic properly formatted for screen.
5515 magic properly formatted for screen.
5512
5516
5513 * setup.py (make_shortcut): Changed things to put pdf version in
5517 * setup.py (make_shortcut): Changed things to put pdf version in
5514 doc/ instead of doc/manual (had to change lyxport a bit).
5518 doc/ instead of doc/manual (had to change lyxport a bit).
5515
5519
5516 * IPython/Magic.py (Profile.string_stats): made profile runs go
5520 * IPython/Magic.py (Profile.string_stats): made profile runs go
5517 through pager (they are long and a pager allows searching, saving,
5521 through pager (they are long and a pager allows searching, saving,
5518 etc.)
5522 etc.)
5519
5523
5520 2002-05-08 Fernando Perez <fperez@colorado.edu>
5524 2002-05-08 Fernando Perez <fperez@colorado.edu>
5521
5525
5522 * Released 0.2.12
5526 * Released 0.2.12
5523
5527
5524 2002-05-06 Fernando Perez <fperez@colorado.edu>
5528 2002-05-06 Fernando Perez <fperez@colorado.edu>
5525
5529
5526 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5530 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5527 introduced); 'hist n1 n2' was broken.
5531 introduced); 'hist n1 n2' was broken.
5528 (Magic.magic_pdb): added optional on/off arguments to @pdb
5532 (Magic.magic_pdb): added optional on/off arguments to @pdb
5529 (Magic.magic_run): added option -i to @run, which executes code in
5533 (Magic.magic_run): added option -i to @run, which executes code in
5530 the IPython namespace instead of a clean one. Also added @irun as
5534 the IPython namespace instead of a clean one. Also added @irun as
5531 an alias to @run -i.
5535 an alias to @run -i.
5532
5536
5533 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5537 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5534 fixed (it didn't really do anything, the namespaces were wrong).
5538 fixed (it didn't really do anything, the namespaces were wrong).
5535
5539
5536 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5540 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5537
5541
5538 * IPython/__init__.py (__all__): Fixed package namespace, now
5542 * IPython/__init__.py (__all__): Fixed package namespace, now
5539 'import IPython' does give access to IPython.<all> as
5543 'import IPython' does give access to IPython.<all> as
5540 expected. Also renamed __release__ to Release.
5544 expected. Also renamed __release__ to Release.
5541
5545
5542 * IPython/Debugger.py (__license__): created new Pdb class which
5546 * IPython/Debugger.py (__license__): created new Pdb class which
5543 functions like a drop-in for the normal pdb.Pdb but does NOT
5547 functions like a drop-in for the normal pdb.Pdb but does NOT
5544 import readline by default. This way it doesn't muck up IPython's
5548 import readline by default. This way it doesn't muck up IPython's
5545 readline handling, and now tab-completion finally works in the
5549 readline handling, and now tab-completion finally works in the
5546 debugger -- sort of. It completes things globally visible, but the
5550 debugger -- sort of. It completes things globally visible, but the
5547 completer doesn't track the stack as pdb walks it. That's a bit
5551 completer doesn't track the stack as pdb walks it. That's a bit
5548 tricky, and I'll have to implement it later.
5552 tricky, and I'll have to implement it later.
5549
5553
5550 2002-05-05 Fernando Perez <fperez@colorado.edu>
5554 2002-05-05 Fernando Perez <fperez@colorado.edu>
5551
5555
5552 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5556 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5553 magic docstrings when printed via ? (explicit \'s were being
5557 magic docstrings when printed via ? (explicit \'s were being
5554 printed).
5558 printed).
5555
5559
5556 * IPython/ipmaker.py (make_IPython): fixed namespace
5560 * IPython/ipmaker.py (make_IPython): fixed namespace
5557 identification bug. Now variables loaded via logs or command-line
5561 identification bug. Now variables loaded via logs or command-line
5558 files are recognized in the interactive namespace by @who.
5562 files are recognized in the interactive namespace by @who.
5559
5563
5560 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5564 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5561 log replay system stemming from the string form of Structs.
5565 log replay system stemming from the string form of Structs.
5562
5566
5563 * IPython/Magic.py (Macro.__init__): improved macros to properly
5567 * IPython/Magic.py (Macro.__init__): improved macros to properly
5564 handle magic commands in them.
5568 handle magic commands in them.
5565 (Magic.magic_logstart): usernames are now expanded so 'logstart
5569 (Magic.magic_logstart): usernames are now expanded so 'logstart
5566 ~/mylog' now works.
5570 ~/mylog' now works.
5567
5571
5568 * IPython/iplib.py (complete): fixed bug where paths starting with
5572 * IPython/iplib.py (complete): fixed bug where paths starting with
5569 '/' would be completed as magic names.
5573 '/' would be completed as magic names.
5570
5574
5571 2002-05-04 Fernando Perez <fperez@colorado.edu>
5575 2002-05-04 Fernando Perez <fperez@colorado.edu>
5572
5576
5573 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5577 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5574 allow running full programs under the profiler's control.
5578 allow running full programs under the profiler's control.
5575
5579
5576 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5580 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5577 mode to report exceptions verbosely but without formatting
5581 mode to report exceptions verbosely but without formatting
5578 variables. This addresses the issue of ipython 'freezing' (it's
5582 variables. This addresses the issue of ipython 'freezing' (it's
5579 not frozen, but caught in an expensive formatting loop) when huge
5583 not frozen, but caught in an expensive formatting loop) when huge
5580 variables are in the context of an exception.
5584 variables are in the context of an exception.
5581 (VerboseTB.text): Added '--->' markers at line where exception was
5585 (VerboseTB.text): Added '--->' markers at line where exception was
5582 triggered. Much clearer to read, especially in NoColor modes.
5586 triggered. Much clearer to read, especially in NoColor modes.
5583
5587
5584 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5588 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5585 implemented in reverse when changing to the new parse_options().
5589 implemented in reverse when changing to the new parse_options().
5586
5590
5587 2002-05-03 Fernando Perez <fperez@colorado.edu>
5591 2002-05-03 Fernando Perez <fperez@colorado.edu>
5588
5592
5589 * IPython/Magic.py (Magic.parse_options): new function so that
5593 * IPython/Magic.py (Magic.parse_options): new function so that
5590 magics can parse options easier.
5594 magics can parse options easier.
5591 (Magic.magic_prun): new function similar to profile.run(),
5595 (Magic.magic_prun): new function similar to profile.run(),
5592 suggested by Chris Hart.
5596 suggested by Chris Hart.
5593 (Magic.magic_cd): fixed behavior so that it only changes if
5597 (Magic.magic_cd): fixed behavior so that it only changes if
5594 directory actually is in history.
5598 directory actually is in history.
5595
5599
5596 * IPython/usage.py (__doc__): added information about potential
5600 * IPython/usage.py (__doc__): added information about potential
5597 slowness of Verbose exception mode when there are huge data
5601 slowness of Verbose exception mode when there are huge data
5598 structures to be formatted (thanks to Archie Paulson).
5602 structures to be formatted (thanks to Archie Paulson).
5599
5603
5600 * IPython/ipmaker.py (make_IPython): Changed default logging
5604 * IPython/ipmaker.py (make_IPython): Changed default logging
5601 (when simply called with -log) to use curr_dir/ipython.log in
5605 (when simply called with -log) to use curr_dir/ipython.log in
5602 rotate mode. Fixed crash which was occuring with -log before
5606 rotate mode. Fixed crash which was occuring with -log before
5603 (thanks to Jim Boyle).
5607 (thanks to Jim Boyle).
5604
5608
5605 2002-05-01 Fernando Perez <fperez@colorado.edu>
5609 2002-05-01 Fernando Perez <fperez@colorado.edu>
5606
5610
5607 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5611 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5608 was nasty -- though somewhat of a corner case).
5612 was nasty -- though somewhat of a corner case).
5609
5613
5610 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5614 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5611 text (was a bug).
5615 text (was a bug).
5612
5616
5613 2002-04-30 Fernando Perez <fperez@colorado.edu>
5617 2002-04-30 Fernando Perez <fperez@colorado.edu>
5614
5618
5615 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5619 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5616 a print after ^D or ^C from the user so that the In[] prompt
5620 a print after ^D or ^C from the user so that the In[] prompt
5617 doesn't over-run the gnuplot one.
5621 doesn't over-run the gnuplot one.
5618
5622
5619 2002-04-29 Fernando Perez <fperez@colorado.edu>
5623 2002-04-29 Fernando Perez <fperez@colorado.edu>
5620
5624
5621 * Released 0.2.10
5625 * Released 0.2.10
5622
5626
5623 * IPython/__release__.py (version): get date dynamically.
5627 * IPython/__release__.py (version): get date dynamically.
5624
5628
5625 * Misc. documentation updates thanks to Arnd's comments. Also ran
5629 * Misc. documentation updates thanks to Arnd's comments. Also ran
5626 a full spellcheck on the manual (hadn't been done in a while).
5630 a full spellcheck on the manual (hadn't been done in a while).
5627
5631
5628 2002-04-27 Fernando Perez <fperez@colorado.edu>
5632 2002-04-27 Fernando Perez <fperez@colorado.edu>
5629
5633
5630 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5634 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5631 starting a log in mid-session would reset the input history list.
5635 starting a log in mid-session would reset the input history list.
5632
5636
5633 2002-04-26 Fernando Perez <fperez@colorado.edu>
5637 2002-04-26 Fernando Perez <fperez@colorado.edu>
5634
5638
5635 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5639 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5636 all files were being included in an update. Now anything in
5640 all files were being included in an update. Now anything in
5637 UserConfig that matches [A-Za-z]*.py will go (this excludes
5641 UserConfig that matches [A-Za-z]*.py will go (this excludes
5638 __init__.py)
5642 __init__.py)
5639
5643
5640 2002-04-25 Fernando Perez <fperez@colorado.edu>
5644 2002-04-25 Fernando Perez <fperez@colorado.edu>
5641
5645
5642 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5646 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5643 to __builtins__ so that any form of embedded or imported code can
5647 to __builtins__ so that any form of embedded or imported code can
5644 test for being inside IPython.
5648 test for being inside IPython.
5645
5649
5646 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5650 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5647 changed to GnuplotMagic because it's now an importable module,
5651 changed to GnuplotMagic because it's now an importable module,
5648 this makes the name follow that of the standard Gnuplot module.
5652 this makes the name follow that of the standard Gnuplot module.
5649 GnuplotMagic can now be loaded at any time in mid-session.
5653 GnuplotMagic can now be loaded at any time in mid-session.
5650
5654
5651 2002-04-24 Fernando Perez <fperez@colorado.edu>
5655 2002-04-24 Fernando Perez <fperez@colorado.edu>
5652
5656
5653 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5657 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5654 the globals (IPython has its own namespace) and the
5658 the globals (IPython has its own namespace) and the
5655 PhysicalQuantity stuff is much better anyway.
5659 PhysicalQuantity stuff is much better anyway.
5656
5660
5657 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5661 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5658 embedding example to standard user directory for
5662 embedding example to standard user directory for
5659 distribution. Also put it in the manual.
5663 distribution. Also put it in the manual.
5660
5664
5661 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5665 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5662 instance as first argument (so it doesn't rely on some obscure
5666 instance as first argument (so it doesn't rely on some obscure
5663 hidden global).
5667 hidden global).
5664
5668
5665 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5669 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5666 delimiters. While it prevents ().TAB from working, it allows
5670 delimiters. While it prevents ().TAB from working, it allows
5667 completions in open (... expressions. This is by far a more common
5671 completions in open (... expressions. This is by far a more common
5668 case.
5672 case.
5669
5673
5670 2002-04-23 Fernando Perez <fperez@colorado.edu>
5674 2002-04-23 Fernando Perez <fperez@colorado.edu>
5671
5675
5672 * IPython/Extensions/InterpreterPasteInput.py: new
5676 * IPython/Extensions/InterpreterPasteInput.py: new
5673 syntax-processing module for pasting lines with >>> or ... at the
5677 syntax-processing module for pasting lines with >>> or ... at the
5674 start.
5678 start.
5675
5679
5676 * IPython/Extensions/PhysicalQ_Interactive.py
5680 * IPython/Extensions/PhysicalQ_Interactive.py
5677 (PhysicalQuantityInteractive.__int__): fixed to work with either
5681 (PhysicalQuantityInteractive.__int__): fixed to work with either
5678 Numeric or math.
5682 Numeric or math.
5679
5683
5680 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5684 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5681 provided profiles. Now we have:
5685 provided profiles. Now we have:
5682 -math -> math module as * and cmath with its own namespace.
5686 -math -> math module as * and cmath with its own namespace.
5683 -numeric -> Numeric as *, plus gnuplot & grace
5687 -numeric -> Numeric as *, plus gnuplot & grace
5684 -physics -> same as before
5688 -physics -> same as before
5685
5689
5686 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5690 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5687 user-defined magics wouldn't be found by @magic if they were
5691 user-defined magics wouldn't be found by @magic if they were
5688 defined as class methods. Also cleaned up the namespace search
5692 defined as class methods. Also cleaned up the namespace search
5689 logic and the string building (to use %s instead of many repeated
5693 logic and the string building (to use %s instead of many repeated
5690 string adds).
5694 string adds).
5691
5695
5692 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5696 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5693 of user-defined magics to operate with class methods (cleaner, in
5697 of user-defined magics to operate with class methods (cleaner, in
5694 line with the gnuplot code).
5698 line with the gnuplot code).
5695
5699
5696 2002-04-22 Fernando Perez <fperez@colorado.edu>
5700 2002-04-22 Fernando Perez <fperez@colorado.edu>
5697
5701
5698 * setup.py: updated dependency list so that manual is updated when
5702 * setup.py: updated dependency list so that manual is updated when
5699 all included files change.
5703 all included files change.
5700
5704
5701 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5705 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5702 the delimiter removal option (the fix is ugly right now).
5706 the delimiter removal option (the fix is ugly right now).
5703
5707
5704 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5708 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5705 all of the math profile (quicker loading, no conflict between
5709 all of the math profile (quicker loading, no conflict between
5706 g-9.8 and g-gnuplot).
5710 g-9.8 and g-gnuplot).
5707
5711
5708 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5712 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5709 name of post-mortem files to IPython_crash_report.txt.
5713 name of post-mortem files to IPython_crash_report.txt.
5710
5714
5711 * Cleanup/update of the docs. Added all the new readline info and
5715 * Cleanup/update of the docs. Added all the new readline info and
5712 formatted all lists as 'real lists'.
5716 formatted all lists as 'real lists'.
5713
5717
5714 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5718 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5715 tab-completion options, since the full readline parse_and_bind is
5719 tab-completion options, since the full readline parse_and_bind is
5716 now accessible.
5720 now accessible.
5717
5721
5718 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5722 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5719 handling of readline options. Now users can specify any string to
5723 handling of readline options. Now users can specify any string to
5720 be passed to parse_and_bind(), as well as the delimiters to be
5724 be passed to parse_and_bind(), as well as the delimiters to be
5721 removed.
5725 removed.
5722 (InteractiveShell.__init__): Added __name__ to the global
5726 (InteractiveShell.__init__): Added __name__ to the global
5723 namespace so that things like Itpl which rely on its existence
5727 namespace so that things like Itpl which rely on its existence
5724 don't crash.
5728 don't crash.
5725 (InteractiveShell._prefilter): Defined the default with a _ so
5729 (InteractiveShell._prefilter): Defined the default with a _ so
5726 that prefilter() is easier to override, while the default one
5730 that prefilter() is easier to override, while the default one
5727 remains available.
5731 remains available.
5728
5732
5729 2002-04-18 Fernando Perez <fperez@colorado.edu>
5733 2002-04-18 Fernando Perez <fperez@colorado.edu>
5730
5734
5731 * Added information about pdb in the docs.
5735 * Added information about pdb in the docs.
5732
5736
5733 2002-04-17 Fernando Perez <fperez@colorado.edu>
5737 2002-04-17 Fernando Perez <fperez@colorado.edu>
5734
5738
5735 * IPython/ipmaker.py (make_IPython): added rc_override option to
5739 * IPython/ipmaker.py (make_IPython): added rc_override option to
5736 allow passing config options at creation time which may override
5740 allow passing config options at creation time which may override
5737 anything set in the config files or command line. This is
5741 anything set in the config files or command line. This is
5738 particularly useful for configuring embedded instances.
5742 particularly useful for configuring embedded instances.
5739
5743
5740 2002-04-15 Fernando Perez <fperez@colorado.edu>
5744 2002-04-15 Fernando Perez <fperez@colorado.edu>
5741
5745
5742 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5746 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5743 crash embedded instances because of the input cache falling out of
5747 crash embedded instances because of the input cache falling out of
5744 sync with the output counter.
5748 sync with the output counter.
5745
5749
5746 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5750 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5747 mode which calls pdb after an uncaught exception in IPython itself.
5751 mode which calls pdb after an uncaught exception in IPython itself.
5748
5752
5749 2002-04-14 Fernando Perez <fperez@colorado.edu>
5753 2002-04-14 Fernando Perez <fperez@colorado.edu>
5750
5754
5751 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5755 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5752 readline, fix it back after each call.
5756 readline, fix it back after each call.
5753
5757
5754 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5758 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5755 method to force all access via __call__(), which guarantees that
5759 method to force all access via __call__(), which guarantees that
5756 traceback references are properly deleted.
5760 traceback references are properly deleted.
5757
5761
5758 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5762 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5759 improve printing when pprint is in use.
5763 improve printing when pprint is in use.
5760
5764
5761 2002-04-13 Fernando Perez <fperez@colorado.edu>
5765 2002-04-13 Fernando Perez <fperez@colorado.edu>
5762
5766
5763 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5767 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5764 exceptions aren't caught anymore. If the user triggers one, he
5768 exceptions aren't caught anymore. If the user triggers one, he
5765 should know why he's doing it and it should go all the way up,
5769 should know why he's doing it and it should go all the way up,
5766 just like any other exception. So now @abort will fully kill the
5770 just like any other exception. So now @abort will fully kill the
5767 embedded interpreter and the embedding code (unless that happens
5771 embedded interpreter and the embedding code (unless that happens
5768 to catch SystemExit).
5772 to catch SystemExit).
5769
5773
5770 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5774 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5771 and a debugger() method to invoke the interactive pdb debugger
5775 and a debugger() method to invoke the interactive pdb debugger
5772 after printing exception information. Also added the corresponding
5776 after printing exception information. Also added the corresponding
5773 -pdb option and @pdb magic to control this feature, and updated
5777 -pdb option and @pdb magic to control this feature, and updated
5774 the docs. After a suggestion from Christopher Hart
5778 the docs. After a suggestion from Christopher Hart
5775 (hart-AT-caltech.edu).
5779 (hart-AT-caltech.edu).
5776
5780
5777 2002-04-12 Fernando Perez <fperez@colorado.edu>
5781 2002-04-12 Fernando Perez <fperez@colorado.edu>
5778
5782
5779 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5783 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5780 the exception handlers defined by the user (not the CrashHandler)
5784 the exception handlers defined by the user (not the CrashHandler)
5781 so that user exceptions don't trigger an ipython bug report.
5785 so that user exceptions don't trigger an ipython bug report.
5782
5786
5783 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5787 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5784 configurable (it should have always been so).
5788 configurable (it should have always been so).
5785
5789
5786 2002-03-26 Fernando Perez <fperez@colorado.edu>
5790 2002-03-26 Fernando Perez <fperez@colorado.edu>
5787
5791
5788 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5792 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5789 and there to fix embedding namespace issues. This should all be
5793 and there to fix embedding namespace issues. This should all be
5790 done in a more elegant way.
5794 done in a more elegant way.
5791
5795
5792 2002-03-25 Fernando Perez <fperez@colorado.edu>
5796 2002-03-25 Fernando Perez <fperez@colorado.edu>
5793
5797
5794 * IPython/genutils.py (get_home_dir): Try to make it work under
5798 * IPython/genutils.py (get_home_dir): Try to make it work under
5795 win9x also.
5799 win9x also.
5796
5800
5797 2002-03-20 Fernando Perez <fperez@colorado.edu>
5801 2002-03-20 Fernando Perez <fperez@colorado.edu>
5798
5802
5799 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5803 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5800 sys.displayhook untouched upon __init__.
5804 sys.displayhook untouched upon __init__.
5801
5805
5802 2002-03-19 Fernando Perez <fperez@colorado.edu>
5806 2002-03-19 Fernando Perez <fperez@colorado.edu>
5803
5807
5804 * Released 0.2.9 (for embedding bug, basically).
5808 * Released 0.2.9 (for embedding bug, basically).
5805
5809
5806 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5810 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5807 exceptions so that enclosing shell's state can be restored.
5811 exceptions so that enclosing shell's state can be restored.
5808
5812
5809 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5813 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5810 naming conventions in the .ipython/ dir.
5814 naming conventions in the .ipython/ dir.
5811
5815
5812 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5816 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5813 from delimiters list so filenames with - in them get expanded.
5817 from delimiters list so filenames with - in them get expanded.
5814
5818
5815 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5819 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5816 sys.displayhook not being properly restored after an embedded call.
5820 sys.displayhook not being properly restored after an embedded call.
5817
5821
5818 2002-03-18 Fernando Perez <fperez@colorado.edu>
5822 2002-03-18 Fernando Perez <fperez@colorado.edu>
5819
5823
5820 * Released 0.2.8
5824 * Released 0.2.8
5821
5825
5822 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5826 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5823 some files weren't being included in a -upgrade.
5827 some files weren't being included in a -upgrade.
5824 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5828 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5825 on' so that the first tab completes.
5829 on' so that the first tab completes.
5826 (InteractiveShell.handle_magic): fixed bug with spaces around
5830 (InteractiveShell.handle_magic): fixed bug with spaces around
5827 quotes breaking many magic commands.
5831 quotes breaking many magic commands.
5828
5832
5829 * setup.py: added note about ignoring the syntax error messages at
5833 * setup.py: added note about ignoring the syntax error messages at
5830 installation.
5834 installation.
5831
5835
5832 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5836 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5833 streamlining the gnuplot interface, now there's only one magic @gp.
5837 streamlining the gnuplot interface, now there's only one magic @gp.
5834
5838
5835 2002-03-17 Fernando Perez <fperez@colorado.edu>
5839 2002-03-17 Fernando Perez <fperez@colorado.edu>
5836
5840
5837 * IPython/UserConfig/magic_gnuplot.py: new name for the
5841 * IPython/UserConfig/magic_gnuplot.py: new name for the
5838 example-magic_pm.py file. Much enhanced system, now with a shell
5842 example-magic_pm.py file. Much enhanced system, now with a shell
5839 for communicating directly with gnuplot, one command at a time.
5843 for communicating directly with gnuplot, one command at a time.
5840
5844
5841 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5845 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5842 setting __name__=='__main__'.
5846 setting __name__=='__main__'.
5843
5847
5844 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5848 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5845 mini-shell for accessing gnuplot from inside ipython. Should
5849 mini-shell for accessing gnuplot from inside ipython. Should
5846 extend it later for grace access too. Inspired by Arnd's
5850 extend it later for grace access too. Inspired by Arnd's
5847 suggestion.
5851 suggestion.
5848
5852
5849 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5853 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5850 calling magic functions with () in their arguments. Thanks to Arnd
5854 calling magic functions with () in their arguments. Thanks to Arnd
5851 Baecker for pointing this to me.
5855 Baecker for pointing this to me.
5852
5856
5853 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5857 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5854 infinitely for integer or complex arrays (only worked with floats).
5858 infinitely for integer or complex arrays (only worked with floats).
5855
5859
5856 2002-03-16 Fernando Perez <fperez@colorado.edu>
5860 2002-03-16 Fernando Perez <fperez@colorado.edu>
5857
5861
5858 * setup.py: Merged setup and setup_windows into a single script
5862 * setup.py: Merged setup and setup_windows into a single script
5859 which properly handles things for windows users.
5863 which properly handles things for windows users.
5860
5864
5861 2002-03-15 Fernando Perez <fperez@colorado.edu>
5865 2002-03-15 Fernando Perez <fperez@colorado.edu>
5862
5866
5863 * Big change to the manual: now the magics are all automatically
5867 * Big change to the manual: now the magics are all automatically
5864 documented. This information is generated from their docstrings
5868 documented. This information is generated from their docstrings
5865 and put in a latex file included by the manual lyx file. This way
5869 and put in a latex file included by the manual lyx file. This way
5866 we get always up to date information for the magics. The manual
5870 we get always up to date information for the magics. The manual
5867 now also has proper version information, also auto-synced.
5871 now also has proper version information, also auto-synced.
5868
5872
5869 For this to work, an undocumented --magic_docstrings option was added.
5873 For this to work, an undocumented --magic_docstrings option was added.
5870
5874
5871 2002-03-13 Fernando Perez <fperez@colorado.edu>
5875 2002-03-13 Fernando Perez <fperez@colorado.edu>
5872
5876
5873 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5877 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5874 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5878 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5875
5879
5876 2002-03-12 Fernando Perez <fperez@colorado.edu>
5880 2002-03-12 Fernando Perez <fperez@colorado.edu>
5877
5881
5878 * IPython/ultraTB.py (TermColors): changed color escapes again to
5882 * IPython/ultraTB.py (TermColors): changed color escapes again to
5879 fix the (old, reintroduced) line-wrapping bug. Basically, if
5883 fix the (old, reintroduced) line-wrapping bug. Basically, if
5880 \001..\002 aren't given in the color escapes, lines get wrapped
5884 \001..\002 aren't given in the color escapes, lines get wrapped
5881 weirdly. But giving those screws up old xterms and emacs terms. So
5885 weirdly. But giving those screws up old xterms and emacs terms. So
5882 I added some logic for emacs terms to be ok, but I can't identify old
5886 I added some logic for emacs terms to be ok, but I can't identify old
5883 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5887 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5884
5888
5885 2002-03-10 Fernando Perez <fperez@colorado.edu>
5889 2002-03-10 Fernando Perez <fperez@colorado.edu>
5886
5890
5887 * IPython/usage.py (__doc__): Various documentation cleanups and
5891 * IPython/usage.py (__doc__): Various documentation cleanups and
5888 updates, both in usage docstrings and in the manual.
5892 updates, both in usage docstrings and in the manual.
5889
5893
5890 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5894 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5891 handling of caching. Set minimum acceptabe value for having a
5895 handling of caching. Set minimum acceptabe value for having a
5892 cache at 20 values.
5896 cache at 20 values.
5893
5897
5894 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5898 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5895 install_first_time function to a method, renamed it and added an
5899 install_first_time function to a method, renamed it and added an
5896 'upgrade' mode. Now people can update their config directory with
5900 'upgrade' mode. Now people can update their config directory with
5897 a simple command line switch (-upgrade, also new).
5901 a simple command line switch (-upgrade, also new).
5898
5902
5899 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5903 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5900 @file (convenient for automagic users under Python >= 2.2).
5904 @file (convenient for automagic users under Python >= 2.2).
5901 Removed @files (it seemed more like a plural than an abbrev. of
5905 Removed @files (it seemed more like a plural than an abbrev. of
5902 'file show').
5906 'file show').
5903
5907
5904 * IPython/iplib.py (install_first_time): Fixed crash if there were
5908 * IPython/iplib.py (install_first_time): Fixed crash if there were
5905 backup files ('~') in .ipython/ install directory.
5909 backup files ('~') in .ipython/ install directory.
5906
5910
5907 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5911 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5908 system. Things look fine, but these changes are fairly
5912 system. Things look fine, but these changes are fairly
5909 intrusive. Test them for a few days.
5913 intrusive. Test them for a few days.
5910
5914
5911 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5915 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5912 the prompts system. Now all in/out prompt strings are user
5916 the prompts system. Now all in/out prompt strings are user
5913 controllable. This is particularly useful for embedding, as one
5917 controllable. This is particularly useful for embedding, as one
5914 can tag embedded instances with particular prompts.
5918 can tag embedded instances with particular prompts.
5915
5919
5916 Also removed global use of sys.ps1/2, which now allows nested
5920 Also removed global use of sys.ps1/2, which now allows nested
5917 embeddings without any problems. Added command-line options for
5921 embeddings without any problems. Added command-line options for
5918 the prompt strings.
5922 the prompt strings.
5919
5923
5920 2002-03-08 Fernando Perez <fperez@colorado.edu>
5924 2002-03-08 Fernando Perez <fperez@colorado.edu>
5921
5925
5922 * IPython/UserConfig/example-embed-short.py (ipshell): added
5926 * IPython/UserConfig/example-embed-short.py (ipshell): added
5923 example file with the bare minimum code for embedding.
5927 example file with the bare minimum code for embedding.
5924
5928
5925 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5929 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5926 functionality for the embeddable shell to be activated/deactivated
5930 functionality for the embeddable shell to be activated/deactivated
5927 either globally or at each call.
5931 either globally or at each call.
5928
5932
5929 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5933 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5930 rewriting the prompt with '--->' for auto-inputs with proper
5934 rewriting the prompt with '--->' for auto-inputs with proper
5931 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5935 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5932 this is handled by the prompts class itself, as it should.
5936 this is handled by the prompts class itself, as it should.
5933
5937
5934 2002-03-05 Fernando Perez <fperez@colorado.edu>
5938 2002-03-05 Fernando Perez <fperez@colorado.edu>
5935
5939
5936 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5940 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5937 @logstart to avoid name clashes with the math log function.
5941 @logstart to avoid name clashes with the math log function.
5938
5942
5939 * Big updates to X/Emacs section of the manual.
5943 * Big updates to X/Emacs section of the manual.
5940
5944
5941 * Removed ipython_emacs. Milan explained to me how to pass
5945 * Removed ipython_emacs. Milan explained to me how to pass
5942 arguments to ipython through Emacs. Some day I'm going to end up
5946 arguments to ipython through Emacs. Some day I'm going to end up
5943 learning some lisp...
5947 learning some lisp...
5944
5948
5945 2002-03-04 Fernando Perez <fperez@colorado.edu>
5949 2002-03-04 Fernando Perez <fperez@colorado.edu>
5946
5950
5947 * IPython/ipython_emacs: Created script to be used as the
5951 * IPython/ipython_emacs: Created script to be used as the
5948 py-python-command Emacs variable so we can pass IPython
5952 py-python-command Emacs variable so we can pass IPython
5949 parameters. I can't figure out how to tell Emacs directly to pass
5953 parameters. I can't figure out how to tell Emacs directly to pass
5950 parameters to IPython, so a dummy shell script will do it.
5954 parameters to IPython, so a dummy shell script will do it.
5951
5955
5952 Other enhancements made for things to work better under Emacs'
5956 Other enhancements made for things to work better under Emacs'
5953 various types of terminals. Many thanks to Milan Zamazal
5957 various types of terminals. Many thanks to Milan Zamazal
5954 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5958 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5955
5959
5956 2002-03-01 Fernando Perez <fperez@colorado.edu>
5960 2002-03-01 Fernando Perez <fperez@colorado.edu>
5957
5961
5958 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5962 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5959 that loading of readline is now optional. This gives better
5963 that loading of readline is now optional. This gives better
5960 control to emacs users.
5964 control to emacs users.
5961
5965
5962 * IPython/ultraTB.py (__date__): Modified color escape sequences
5966 * IPython/ultraTB.py (__date__): Modified color escape sequences
5963 and now things work fine under xterm and in Emacs' term buffers
5967 and now things work fine under xterm and in Emacs' term buffers
5964 (though not shell ones). Well, in emacs you get colors, but all
5968 (though not shell ones). Well, in emacs you get colors, but all
5965 seem to be 'light' colors (no difference between dark and light
5969 seem to be 'light' colors (no difference between dark and light
5966 ones). But the garbage chars are gone, and also in xterms. It
5970 ones). But the garbage chars are gone, and also in xterms. It
5967 seems that now I'm using 'cleaner' ansi sequences.
5971 seems that now I'm using 'cleaner' ansi sequences.
5968
5972
5969 2002-02-21 Fernando Perez <fperez@colorado.edu>
5973 2002-02-21 Fernando Perez <fperez@colorado.edu>
5970
5974
5971 * Released 0.2.7 (mainly to publish the scoping fix).
5975 * Released 0.2.7 (mainly to publish the scoping fix).
5972
5976
5973 * IPython/Logger.py (Logger.logstate): added. A corresponding
5977 * IPython/Logger.py (Logger.logstate): added. A corresponding
5974 @logstate magic was created.
5978 @logstate magic was created.
5975
5979
5976 * IPython/Magic.py: fixed nested scoping problem under Python
5980 * IPython/Magic.py: fixed nested scoping problem under Python
5977 2.1.x (automagic wasn't working).
5981 2.1.x (automagic wasn't working).
5978
5982
5979 2002-02-20 Fernando Perez <fperez@colorado.edu>
5983 2002-02-20 Fernando Perez <fperez@colorado.edu>
5980
5984
5981 * Released 0.2.6.
5985 * Released 0.2.6.
5982
5986
5983 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5987 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5984 option so that logs can come out without any headers at all.
5988 option so that logs can come out without any headers at all.
5985
5989
5986 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5990 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5987 SciPy.
5991 SciPy.
5988
5992
5989 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5993 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5990 that embedded IPython calls don't require vars() to be explicitly
5994 that embedded IPython calls don't require vars() to be explicitly
5991 passed. Now they are extracted from the caller's frame (code
5995 passed. Now they are extracted from the caller's frame (code
5992 snatched from Eric Jones' weave). Added better documentation to
5996 snatched from Eric Jones' weave). Added better documentation to
5993 the section on embedding and the example file.
5997 the section on embedding and the example file.
5994
5998
5995 * IPython/genutils.py (page): Changed so that under emacs, it just
5999 * IPython/genutils.py (page): Changed so that under emacs, it just
5996 prints the string. You can then page up and down in the emacs
6000 prints the string. You can then page up and down in the emacs
5997 buffer itself. This is how the builtin help() works.
6001 buffer itself. This is how the builtin help() works.
5998
6002
5999 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
6003 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
6000 macro scoping: macros need to be executed in the user's namespace
6004 macro scoping: macros need to be executed in the user's namespace
6001 to work as if they had been typed by the user.
6005 to work as if they had been typed by the user.
6002
6006
6003 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
6007 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
6004 execute automatically (no need to type 'exec...'). They then
6008 execute automatically (no need to type 'exec...'). They then
6005 behave like 'true macros'. The printing system was also modified
6009 behave like 'true macros'. The printing system was also modified
6006 for this to work.
6010 for this to work.
6007
6011
6008 2002-02-19 Fernando Perez <fperez@colorado.edu>
6012 2002-02-19 Fernando Perez <fperez@colorado.edu>
6009
6013
6010 * IPython/genutils.py (page_file): new function for paging files
6014 * IPython/genutils.py (page_file): new function for paging files
6011 in an OS-independent way. Also necessary for file viewing to work
6015 in an OS-independent way. Also necessary for file viewing to work
6012 well inside Emacs buffers.
6016 well inside Emacs buffers.
6013 (page): Added checks for being in an emacs buffer.
6017 (page): Added checks for being in an emacs buffer.
6014 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
6018 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
6015 same bug in iplib.
6019 same bug in iplib.
6016
6020
6017 2002-02-18 Fernando Perez <fperez@colorado.edu>
6021 2002-02-18 Fernando Perez <fperez@colorado.edu>
6018
6022
6019 * IPython/iplib.py (InteractiveShell.init_readline): modified use
6023 * IPython/iplib.py (InteractiveShell.init_readline): modified use
6020 of readline so that IPython can work inside an Emacs buffer.
6024 of readline so that IPython can work inside an Emacs buffer.
6021
6025
6022 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
6026 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
6023 method signatures (they weren't really bugs, but it looks cleaner
6027 method signatures (they weren't really bugs, but it looks cleaner
6024 and keeps PyChecker happy).
6028 and keeps PyChecker happy).
6025
6029
6026 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
6030 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
6027 for implementing various user-defined hooks. Currently only
6031 for implementing various user-defined hooks. Currently only
6028 display is done.
6032 display is done.
6029
6033
6030 * IPython/Prompts.py (CachedOutput._display): changed display
6034 * IPython/Prompts.py (CachedOutput._display): changed display
6031 functions so that they can be dynamically changed by users easily.
6035 functions so that they can be dynamically changed by users easily.
6032
6036
6033 * IPython/Extensions/numeric_formats.py (num_display): added an
6037 * IPython/Extensions/numeric_formats.py (num_display): added an
6034 extension for printing NumPy arrays in flexible manners. It
6038 extension for printing NumPy arrays in flexible manners. It
6035 doesn't do anything yet, but all the structure is in
6039 doesn't do anything yet, but all the structure is in
6036 place. Ultimately the plan is to implement output format control
6040 place. Ultimately the plan is to implement output format control
6037 like in Octave.
6041 like in Octave.
6038
6042
6039 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
6043 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
6040 methods are found at run-time by all the automatic machinery.
6044 methods are found at run-time by all the automatic machinery.
6041
6045
6042 2002-02-17 Fernando Perez <fperez@colorado.edu>
6046 2002-02-17 Fernando Perez <fperez@colorado.edu>
6043
6047
6044 * setup_Windows.py (make_shortcut): documented. Cleaned up the
6048 * setup_Windows.py (make_shortcut): documented. Cleaned up the
6045 whole file a little.
6049 whole file a little.
6046
6050
6047 * ToDo: closed this document. Now there's a new_design.lyx
6051 * ToDo: closed this document. Now there's a new_design.lyx
6048 document for all new ideas. Added making a pdf of it for the
6052 document for all new ideas. Added making a pdf of it for the
6049 end-user distro.
6053 end-user distro.
6050
6054
6051 * IPython/Logger.py (Logger.switch_log): Created this to replace
6055 * IPython/Logger.py (Logger.switch_log): Created this to replace
6052 logon() and logoff(). It also fixes a nasty crash reported by
6056 logon() and logoff(). It also fixes a nasty crash reported by
6053 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
6057 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
6054
6058
6055 * IPython/iplib.py (complete): got auto-completion to work with
6059 * IPython/iplib.py (complete): got auto-completion to work with
6056 automagic (I had wanted this for a long time).
6060 automagic (I had wanted this for a long time).
6057
6061
6058 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
6062 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
6059 to @file, since file() is now a builtin and clashes with automagic
6063 to @file, since file() is now a builtin and clashes with automagic
6060 for @file.
6064 for @file.
6061
6065
6062 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
6066 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
6063 of this was previously in iplib, which had grown to more than 2000
6067 of this was previously in iplib, which had grown to more than 2000
6064 lines, way too long. No new functionality, but it makes managing
6068 lines, way too long. No new functionality, but it makes managing
6065 the code a bit easier.
6069 the code a bit easier.
6066
6070
6067 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
6071 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
6068 information to crash reports.
6072 information to crash reports.
6069
6073
6070 2002-02-12 Fernando Perez <fperez@colorado.edu>
6074 2002-02-12 Fernando Perez <fperez@colorado.edu>
6071
6075
6072 * Released 0.2.5.
6076 * Released 0.2.5.
6073
6077
6074 2002-02-11 Fernando Perez <fperez@colorado.edu>
6078 2002-02-11 Fernando Perez <fperez@colorado.edu>
6075
6079
6076 * Wrote a relatively complete Windows installer. It puts
6080 * Wrote a relatively complete Windows installer. It puts
6077 everything in place, creates Start Menu entries and fixes the
6081 everything in place, creates Start Menu entries and fixes the
6078 color issues. Nothing fancy, but it works.
6082 color issues. Nothing fancy, but it works.
6079
6083
6080 2002-02-10 Fernando Perez <fperez@colorado.edu>
6084 2002-02-10 Fernando Perez <fperez@colorado.edu>
6081
6085
6082 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
6086 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
6083 os.path.expanduser() call so that we can type @run ~/myfile.py and
6087 os.path.expanduser() call so that we can type @run ~/myfile.py and
6084 have thigs work as expected.
6088 have thigs work as expected.
6085
6089
6086 * IPython/genutils.py (page): fixed exception handling so things
6090 * IPython/genutils.py (page): fixed exception handling so things
6087 work both in Unix and Windows correctly. Quitting a pager triggers
6091 work both in Unix and Windows correctly. Quitting a pager triggers
6088 an IOError/broken pipe in Unix, and in windows not finding a pager
6092 an IOError/broken pipe in Unix, and in windows not finding a pager
6089 is also an IOError, so I had to actually look at the return value
6093 is also an IOError, so I had to actually look at the return value
6090 of the exception, not just the exception itself. Should be ok now.
6094 of the exception, not just the exception itself. Should be ok now.
6091
6095
6092 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
6096 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
6093 modified to allow case-insensitive color scheme changes.
6097 modified to allow case-insensitive color scheme changes.
6094
6098
6095 2002-02-09 Fernando Perez <fperez@colorado.edu>
6099 2002-02-09 Fernando Perez <fperez@colorado.edu>
6096
6100
6097 * IPython/genutils.py (native_line_ends): new function to leave
6101 * IPython/genutils.py (native_line_ends): new function to leave
6098 user config files with os-native line-endings.
6102 user config files with os-native line-endings.
6099
6103
6100 * README and manual updates.
6104 * README and manual updates.
6101
6105
6102 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
6106 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
6103 instead of StringType to catch Unicode strings.
6107 instead of StringType to catch Unicode strings.
6104
6108
6105 * IPython/genutils.py (filefind): fixed bug for paths with
6109 * IPython/genutils.py (filefind): fixed bug for paths with
6106 embedded spaces (very common in Windows).
6110 embedded spaces (very common in Windows).
6107
6111
6108 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
6112 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
6109 files under Windows, so that they get automatically associated
6113 files under Windows, so that they get automatically associated
6110 with a text editor. Windows makes it a pain to handle
6114 with a text editor. Windows makes it a pain to handle
6111 extension-less files.
6115 extension-less files.
6112
6116
6113 * IPython/iplib.py (InteractiveShell.init_readline): Made the
6117 * IPython/iplib.py (InteractiveShell.init_readline): Made the
6114 warning about readline only occur for Posix. In Windows there's no
6118 warning about readline only occur for Posix. In Windows there's no
6115 way to get readline, so why bother with the warning.
6119 way to get readline, so why bother with the warning.
6116
6120
6117 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
6121 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
6118 for __str__ instead of dir(self), since dir() changed in 2.2.
6122 for __str__ instead of dir(self), since dir() changed in 2.2.
6119
6123
6120 * Ported to Windows! Tested on XP, I suspect it should work fine
6124 * Ported to Windows! Tested on XP, I suspect it should work fine
6121 on NT/2000, but I don't think it will work on 98 et al. That
6125 on NT/2000, but I don't think it will work on 98 et al. That
6122 series of Windows is such a piece of junk anyway that I won't try
6126 series of Windows is such a piece of junk anyway that I won't try
6123 porting it there. The XP port was straightforward, showed a few
6127 porting it there. The XP port was straightforward, showed a few
6124 bugs here and there (fixed all), in particular some string
6128 bugs here and there (fixed all), in particular some string
6125 handling stuff which required considering Unicode strings (which
6129 handling stuff which required considering Unicode strings (which
6126 Windows uses). This is good, but hasn't been too tested :) No
6130 Windows uses). This is good, but hasn't been too tested :) No
6127 fancy installer yet, I'll put a note in the manual so people at
6131 fancy installer yet, I'll put a note in the manual so people at
6128 least make manually a shortcut.
6132 least make manually a shortcut.
6129
6133
6130 * IPython/iplib.py (Magic.magic_colors): Unified the color options
6134 * IPython/iplib.py (Magic.magic_colors): Unified the color options
6131 into a single one, "colors". This now controls both prompt and
6135 into a single one, "colors". This now controls both prompt and
6132 exception color schemes, and can be changed both at startup
6136 exception color schemes, and can be changed both at startup
6133 (either via command-line switches or via ipythonrc files) and at
6137 (either via command-line switches or via ipythonrc files) and at
6134 runtime, with @colors.
6138 runtime, with @colors.
6135 (Magic.magic_run): renamed @prun to @run and removed the old
6139 (Magic.magic_run): renamed @prun to @run and removed the old
6136 @run. The two were too similar to warrant keeping both.
6140 @run. The two were too similar to warrant keeping both.
6137
6141
6138 2002-02-03 Fernando Perez <fperez@colorado.edu>
6142 2002-02-03 Fernando Perez <fperez@colorado.edu>
6139
6143
6140 * IPython/iplib.py (install_first_time): Added comment on how to
6144 * IPython/iplib.py (install_first_time): Added comment on how to
6141 configure the color options for first-time users. Put a <return>
6145 configure the color options for first-time users. Put a <return>
6142 request at the end so that small-terminal users get a chance to
6146 request at the end so that small-terminal users get a chance to
6143 read the startup info.
6147 read the startup info.
6144
6148
6145 2002-01-23 Fernando Perez <fperez@colorado.edu>
6149 2002-01-23 Fernando Perez <fperez@colorado.edu>
6146
6150
6147 * IPython/iplib.py (CachedOutput.update): Changed output memory
6151 * IPython/iplib.py (CachedOutput.update): Changed output memory
6148 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
6152 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
6149 input history we still use _i. Did this b/c these variable are
6153 input history we still use _i. Did this b/c these variable are
6150 very commonly used in interactive work, so the less we need to
6154 very commonly used in interactive work, so the less we need to
6151 type the better off we are.
6155 type the better off we are.
6152 (Magic.magic_prun): updated @prun to better handle the namespaces
6156 (Magic.magic_prun): updated @prun to better handle the namespaces
6153 the file will run in, including a fix for __name__ not being set
6157 the file will run in, including a fix for __name__ not being set
6154 before.
6158 before.
6155
6159
6156 2002-01-20 Fernando Perez <fperez@colorado.edu>
6160 2002-01-20 Fernando Perez <fperez@colorado.edu>
6157
6161
6158 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
6162 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
6159 extra garbage for Python 2.2. Need to look more carefully into
6163 extra garbage for Python 2.2. Need to look more carefully into
6160 this later.
6164 this later.
6161
6165
6162 2002-01-19 Fernando Perez <fperez@colorado.edu>
6166 2002-01-19 Fernando Perez <fperez@colorado.edu>
6163
6167
6164 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
6168 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
6165 display SyntaxError exceptions properly formatted when they occur
6169 display SyntaxError exceptions properly formatted when they occur
6166 (they can be triggered by imported code).
6170 (they can be triggered by imported code).
6167
6171
6168 2002-01-18 Fernando Perez <fperez@colorado.edu>
6172 2002-01-18 Fernando Perez <fperez@colorado.edu>
6169
6173
6170 * IPython/iplib.py (InteractiveShell.safe_execfile): now
6174 * IPython/iplib.py (InteractiveShell.safe_execfile): now
6171 SyntaxError exceptions are reported nicely formatted, instead of
6175 SyntaxError exceptions are reported nicely formatted, instead of
6172 spitting out only offset information as before.
6176 spitting out only offset information as before.
6173 (Magic.magic_prun): Added the @prun function for executing
6177 (Magic.magic_prun): Added the @prun function for executing
6174 programs with command line args inside IPython.
6178 programs with command line args inside IPython.
6175
6179
6176 2002-01-16 Fernando Perez <fperez@colorado.edu>
6180 2002-01-16 Fernando Perez <fperez@colorado.edu>
6177
6181
6178 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
6182 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
6179 to *not* include the last item given in a range. This brings their
6183 to *not* include the last item given in a range. This brings their
6180 behavior in line with Python's slicing:
6184 behavior in line with Python's slicing:
6181 a[n1:n2] -> a[n1]...a[n2-1]
6185 a[n1:n2] -> a[n1]...a[n2-1]
6182 It may be a bit less convenient, but I prefer to stick to Python's
6186 It may be a bit less convenient, but I prefer to stick to Python's
6183 conventions *everywhere*, so users never have to wonder.
6187 conventions *everywhere*, so users never have to wonder.
6184 (Magic.magic_macro): Added @macro function to ease the creation of
6188 (Magic.magic_macro): Added @macro function to ease the creation of
6185 macros.
6189 macros.
6186
6190
6187 2002-01-05 Fernando Perez <fperez@colorado.edu>
6191 2002-01-05 Fernando Perez <fperez@colorado.edu>
6188
6192
6189 * Released 0.2.4.
6193 * Released 0.2.4.
6190
6194
6191 * IPython/iplib.py (Magic.magic_pdef):
6195 * IPython/iplib.py (Magic.magic_pdef):
6192 (InteractiveShell.safe_execfile): report magic lines and error
6196 (InteractiveShell.safe_execfile): report magic lines and error
6193 lines without line numbers so one can easily copy/paste them for
6197 lines without line numbers so one can easily copy/paste them for
6194 re-execution.
6198 re-execution.
6195
6199
6196 * Updated manual with recent changes.
6200 * Updated manual with recent changes.
6197
6201
6198 * IPython/iplib.py (Magic.magic_oinfo): added constructor
6202 * IPython/iplib.py (Magic.magic_oinfo): added constructor
6199 docstring printing when class? is called. Very handy for knowing
6203 docstring printing when class? is called. Very handy for knowing
6200 how to create class instances (as long as __init__ is well
6204 how to create class instances (as long as __init__ is well
6201 documented, of course :)
6205 documented, of course :)
6202 (Magic.magic_doc): print both class and constructor docstrings.
6206 (Magic.magic_doc): print both class and constructor docstrings.
6203 (Magic.magic_pdef): give constructor info if passed a class and
6207 (Magic.magic_pdef): give constructor info if passed a class and
6204 __call__ info for callable object instances.
6208 __call__ info for callable object instances.
6205
6209
6206 2002-01-04 Fernando Perez <fperez@colorado.edu>
6210 2002-01-04 Fernando Perez <fperez@colorado.edu>
6207
6211
6208 * Made deep_reload() off by default. It doesn't always work
6212 * Made deep_reload() off by default. It doesn't always work
6209 exactly as intended, so it's probably safer to have it off. It's
6213 exactly as intended, so it's probably safer to have it off. It's
6210 still available as dreload() anyway, so nothing is lost.
6214 still available as dreload() anyway, so nothing is lost.
6211
6215
6212 2002-01-02 Fernando Perez <fperez@colorado.edu>
6216 2002-01-02 Fernando Perez <fperez@colorado.edu>
6213
6217
6214 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
6218 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
6215 so I wanted an updated release).
6219 so I wanted an updated release).
6216
6220
6217 2001-12-27 Fernando Perez <fperez@colorado.edu>
6221 2001-12-27 Fernando Perez <fperez@colorado.edu>
6218
6222
6219 * IPython/iplib.py (InteractiveShell.interact): Added the original
6223 * IPython/iplib.py (InteractiveShell.interact): Added the original
6220 code from 'code.py' for this module in order to change the
6224 code from 'code.py' for this module in order to change the
6221 handling of a KeyboardInterrupt. This was necessary b/c otherwise
6225 handling of a KeyboardInterrupt. This was necessary b/c otherwise
6222 the history cache would break when the user hit Ctrl-C, and
6226 the history cache would break when the user hit Ctrl-C, and
6223 interact() offers no way to add any hooks to it.
6227 interact() offers no way to add any hooks to it.
6224
6228
6225 2001-12-23 Fernando Perez <fperez@colorado.edu>
6229 2001-12-23 Fernando Perez <fperez@colorado.edu>
6226
6230
6227 * setup.py: added check for 'MANIFEST' before trying to remove
6231 * setup.py: added check for 'MANIFEST' before trying to remove
6228 it. Thanks to Sean Reifschneider.
6232 it. Thanks to Sean Reifschneider.
6229
6233
6230 2001-12-22 Fernando Perez <fperez@colorado.edu>
6234 2001-12-22 Fernando Perez <fperez@colorado.edu>
6231
6235
6232 * Released 0.2.2.
6236 * Released 0.2.2.
6233
6237
6234 * Finished (reasonably) writing the manual. Later will add the
6238 * Finished (reasonably) writing the manual. Later will add the
6235 python-standard navigation stylesheets, but for the time being
6239 python-standard navigation stylesheets, but for the time being
6236 it's fairly complete. Distribution will include html and pdf
6240 it's fairly complete. Distribution will include html and pdf
6237 versions.
6241 versions.
6238
6242
6239 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
6243 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
6240 (MayaVi author).
6244 (MayaVi author).
6241
6245
6242 2001-12-21 Fernando Perez <fperez@colorado.edu>
6246 2001-12-21 Fernando Perez <fperez@colorado.edu>
6243
6247
6244 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
6248 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
6245 good public release, I think (with the manual and the distutils
6249 good public release, I think (with the manual and the distutils
6246 installer). The manual can use some work, but that can go
6250 installer). The manual can use some work, but that can go
6247 slowly. Otherwise I think it's quite nice for end users. Next
6251 slowly. Otherwise I think it's quite nice for end users. Next
6248 summer, rewrite the guts of it...
6252 summer, rewrite the guts of it...
6249
6253
6250 * Changed format of ipythonrc files to use whitespace as the
6254 * Changed format of ipythonrc files to use whitespace as the
6251 separator instead of an explicit '='. Cleaner.
6255 separator instead of an explicit '='. Cleaner.
6252
6256
6253 2001-12-20 Fernando Perez <fperez@colorado.edu>
6257 2001-12-20 Fernando Perez <fperez@colorado.edu>
6254
6258
6255 * Started a manual in LyX. For now it's just a quick merge of the
6259 * Started a manual in LyX. For now it's just a quick merge of the
6256 various internal docstrings and READMEs. Later it may grow into a
6260 various internal docstrings and READMEs. Later it may grow into a
6257 nice, full-blown manual.
6261 nice, full-blown manual.
6258
6262
6259 * Set up a distutils based installer. Installation should now be
6263 * Set up a distutils based installer. Installation should now be
6260 trivially simple for end-users.
6264 trivially simple for end-users.
6261
6265
6262 2001-12-11 Fernando Perez <fperez@colorado.edu>
6266 2001-12-11 Fernando Perez <fperez@colorado.edu>
6263
6267
6264 * Released 0.2.0. First public release, announced it at
6268 * Released 0.2.0. First public release, announced it at
6265 comp.lang.python. From now on, just bugfixes...
6269 comp.lang.python. From now on, just bugfixes...
6266
6270
6267 * Went through all the files, set copyright/license notices and
6271 * Went through all the files, set copyright/license notices and
6268 cleaned up things. Ready for release.
6272 cleaned up things. Ready for release.
6269
6273
6270 2001-12-10 Fernando Perez <fperez@colorado.edu>
6274 2001-12-10 Fernando Perez <fperez@colorado.edu>
6271
6275
6272 * Changed the first-time installer not to use tarfiles. It's more
6276 * Changed the first-time installer not to use tarfiles. It's more
6273 robust now and less unix-dependent. Also makes it easier for
6277 robust now and less unix-dependent. Also makes it easier for
6274 people to later upgrade versions.
6278 people to later upgrade versions.
6275
6279
6276 * Changed @exit to @abort to reflect the fact that it's pretty
6280 * Changed @exit to @abort to reflect the fact that it's pretty
6277 brutal (a sys.exit()). The difference between @abort and Ctrl-D
6281 brutal (a sys.exit()). The difference between @abort and Ctrl-D
6278 becomes significant only when IPyhton is embedded: in that case,
6282 becomes significant only when IPyhton is embedded: in that case,
6279 C-D closes IPython only, but @abort kills the enclosing program
6283 C-D closes IPython only, but @abort kills the enclosing program
6280 too (unless it had called IPython inside a try catching
6284 too (unless it had called IPython inside a try catching
6281 SystemExit).
6285 SystemExit).
6282
6286
6283 * Created Shell module which exposes the actuall IPython Shell
6287 * Created Shell module which exposes the actuall IPython Shell
6284 classes, currently the normal and the embeddable one. This at
6288 classes, currently the normal and the embeddable one. This at
6285 least offers a stable interface we won't need to change when
6289 least offers a stable interface we won't need to change when
6286 (later) the internals are rewritten. That rewrite will be confined
6290 (later) the internals are rewritten. That rewrite will be confined
6287 to iplib and ipmaker, but the Shell interface should remain as is.
6291 to iplib and ipmaker, but the Shell interface should remain as is.
6288
6292
6289 * Added embed module which offers an embeddable IPShell object,
6293 * Added embed module which offers an embeddable IPShell object,
6290 useful to fire up IPython *inside* a running program. Great for
6294 useful to fire up IPython *inside* a running program. Great for
6291 debugging or dynamical data analysis.
6295 debugging or dynamical data analysis.
6292
6296
6293 2001-12-08 Fernando Perez <fperez@colorado.edu>
6297 2001-12-08 Fernando Perez <fperez@colorado.edu>
6294
6298
6295 * Fixed small bug preventing seeing info from methods of defined
6299 * Fixed small bug preventing seeing info from methods of defined
6296 objects (incorrect namespace in _ofind()).
6300 objects (incorrect namespace in _ofind()).
6297
6301
6298 * Documentation cleanup. Moved the main usage docstrings to a
6302 * Documentation cleanup. Moved the main usage docstrings to a
6299 separate file, usage.py (cleaner to maintain, and hopefully in the
6303 separate file, usage.py (cleaner to maintain, and hopefully in the
6300 future some perlpod-like way of producing interactive, man and
6304 future some perlpod-like way of producing interactive, man and
6301 html docs out of it will be found).
6305 html docs out of it will be found).
6302
6306
6303 * Added @profile to see your profile at any time.
6307 * Added @profile to see your profile at any time.
6304
6308
6305 * Added @p as an alias for 'print'. It's especially convenient if
6309 * Added @p as an alias for 'print'. It's especially convenient if
6306 using automagic ('p x' prints x).
6310 using automagic ('p x' prints x).
6307
6311
6308 * Small cleanups and fixes after a pychecker run.
6312 * Small cleanups and fixes after a pychecker run.
6309
6313
6310 * Changed the @cd command to handle @cd - and @cd -<n> for
6314 * Changed the @cd command to handle @cd - and @cd -<n> for
6311 visiting any directory in _dh.
6315 visiting any directory in _dh.
6312
6316
6313 * Introduced _dh, a history of visited directories. @dhist prints
6317 * Introduced _dh, a history of visited directories. @dhist prints
6314 it out with numbers.
6318 it out with numbers.
6315
6319
6316 2001-12-07 Fernando Perez <fperez@colorado.edu>
6320 2001-12-07 Fernando Perez <fperez@colorado.edu>
6317
6321
6318 * Released 0.1.22
6322 * Released 0.1.22
6319
6323
6320 * Made initialization a bit more robust against invalid color
6324 * Made initialization a bit more robust against invalid color
6321 options in user input (exit, not traceback-crash).
6325 options in user input (exit, not traceback-crash).
6322
6326
6323 * Changed the bug crash reporter to write the report only in the
6327 * Changed the bug crash reporter to write the report only in the
6324 user's .ipython directory. That way IPython won't litter people's
6328 user's .ipython directory. That way IPython won't litter people's
6325 hard disks with crash files all over the place. Also print on
6329 hard disks with crash files all over the place. Also print on
6326 screen the necessary mail command.
6330 screen the necessary mail command.
6327
6331
6328 * With the new ultraTB, implemented LightBG color scheme for light
6332 * With the new ultraTB, implemented LightBG color scheme for light
6329 background terminals. A lot of people like white backgrounds, so I
6333 background terminals. A lot of people like white backgrounds, so I
6330 guess we should at least give them something readable.
6334 guess we should at least give them something readable.
6331
6335
6332 2001-12-06 Fernando Perez <fperez@colorado.edu>
6336 2001-12-06 Fernando Perez <fperez@colorado.edu>
6333
6337
6334 * Modified the structure of ultraTB. Now there's a proper class
6338 * Modified the structure of ultraTB. Now there's a proper class
6335 for tables of color schemes which allow adding schemes easily and
6339 for tables of color schemes which allow adding schemes easily and
6336 switching the active scheme without creating a new instance every
6340 switching the active scheme without creating a new instance every
6337 time (which was ridiculous). The syntax for creating new schemes
6341 time (which was ridiculous). The syntax for creating new schemes
6338 is also cleaner. I think ultraTB is finally done, with a clean
6342 is also cleaner. I think ultraTB is finally done, with a clean
6339 class structure. Names are also much cleaner (now there's proper
6343 class structure. Names are also much cleaner (now there's proper
6340 color tables, no need for every variable to also have 'color' in
6344 color tables, no need for every variable to also have 'color' in
6341 its name).
6345 its name).
6342
6346
6343 * Broke down genutils into separate files. Now genutils only
6347 * Broke down genutils into separate files. Now genutils only
6344 contains utility functions, and classes have been moved to their
6348 contains utility functions, and classes have been moved to their
6345 own files (they had enough independent functionality to warrant
6349 own files (they had enough independent functionality to warrant
6346 it): ConfigLoader, OutputTrap, Struct.
6350 it): ConfigLoader, OutputTrap, Struct.
6347
6351
6348 2001-12-05 Fernando Perez <fperez@colorado.edu>
6352 2001-12-05 Fernando Perez <fperez@colorado.edu>
6349
6353
6350 * IPython turns 21! Released version 0.1.21, as a candidate for
6354 * IPython turns 21! Released version 0.1.21, as a candidate for
6351 public consumption. If all goes well, release in a few days.
6355 public consumption. If all goes well, release in a few days.
6352
6356
6353 * Fixed path bug (files in Extensions/ directory wouldn't be found
6357 * Fixed path bug (files in Extensions/ directory wouldn't be found
6354 unless IPython/ was explicitly in sys.path).
6358 unless IPython/ was explicitly in sys.path).
6355
6359
6356 * Extended the FlexCompleter class as MagicCompleter to allow
6360 * Extended the FlexCompleter class as MagicCompleter to allow
6357 completion of @-starting lines.
6361 completion of @-starting lines.
6358
6362
6359 * Created __release__.py file as a central repository for release
6363 * Created __release__.py file as a central repository for release
6360 info that other files can read from.
6364 info that other files can read from.
6361
6365
6362 * Fixed small bug in logging: when logging was turned on in
6366 * Fixed small bug in logging: when logging was turned on in
6363 mid-session, old lines with special meanings (!@?) were being
6367 mid-session, old lines with special meanings (!@?) were being
6364 logged without the prepended comment, which is necessary since
6368 logged without the prepended comment, which is necessary since
6365 they are not truly valid python syntax. This should make session
6369 they are not truly valid python syntax. This should make session
6366 restores produce less errors.
6370 restores produce less errors.
6367
6371
6368 * The namespace cleanup forced me to make a FlexCompleter class
6372 * The namespace cleanup forced me to make a FlexCompleter class
6369 which is nothing but a ripoff of rlcompleter, but with selectable
6373 which is nothing but a ripoff of rlcompleter, but with selectable
6370 namespace (rlcompleter only works in __main__.__dict__). I'll try
6374 namespace (rlcompleter only works in __main__.__dict__). I'll try
6371 to submit a note to the authors to see if this change can be
6375 to submit a note to the authors to see if this change can be
6372 incorporated in future rlcompleter releases (Dec.6: done)
6376 incorporated in future rlcompleter releases (Dec.6: done)
6373
6377
6374 * More fixes to namespace handling. It was a mess! Now all
6378 * More fixes to namespace handling. It was a mess! Now all
6375 explicit references to __main__.__dict__ are gone (except when
6379 explicit references to __main__.__dict__ are gone (except when
6376 really needed) and everything is handled through the namespace
6380 really needed) and everything is handled through the namespace
6377 dicts in the IPython instance. We seem to be getting somewhere
6381 dicts in the IPython instance. We seem to be getting somewhere
6378 with this, finally...
6382 with this, finally...
6379
6383
6380 * Small documentation updates.
6384 * Small documentation updates.
6381
6385
6382 * Created the Extensions directory under IPython (with an
6386 * Created the Extensions directory under IPython (with an
6383 __init__.py). Put the PhysicalQ stuff there. This directory should
6387 __init__.py). Put the PhysicalQ stuff there. This directory should
6384 be used for all special-purpose extensions.
6388 be used for all special-purpose extensions.
6385
6389
6386 * File renaming:
6390 * File renaming:
6387 ipythonlib --> ipmaker
6391 ipythonlib --> ipmaker
6388 ipplib --> iplib
6392 ipplib --> iplib
6389 This makes a bit more sense in terms of what these files actually do.
6393 This makes a bit more sense in terms of what these files actually do.
6390
6394
6391 * Moved all the classes and functions in ipythonlib to ipplib, so
6395 * Moved all the classes and functions in ipythonlib to ipplib, so
6392 now ipythonlib only has make_IPython(). This will ease up its
6396 now ipythonlib only has make_IPython(). This will ease up its
6393 splitting in smaller functional chunks later.
6397 splitting in smaller functional chunks later.
6394
6398
6395 * Cleaned up (done, I think) output of @whos. Better column
6399 * Cleaned up (done, I think) output of @whos. Better column
6396 formatting, and now shows str(var) for as much as it can, which is
6400 formatting, and now shows str(var) for as much as it can, which is
6397 typically what one gets with a 'print var'.
6401 typically what one gets with a 'print var'.
6398
6402
6399 2001-12-04 Fernando Perez <fperez@colorado.edu>
6403 2001-12-04 Fernando Perez <fperez@colorado.edu>
6400
6404
6401 * Fixed namespace problems. Now builtin/IPyhton/user names get
6405 * Fixed namespace problems. Now builtin/IPyhton/user names get
6402 properly reported in their namespace. Internal namespace handling
6406 properly reported in their namespace. Internal namespace handling
6403 is finally getting decent (not perfect yet, but much better than
6407 is finally getting decent (not perfect yet, but much better than
6404 the ad-hoc mess we had).
6408 the ad-hoc mess we had).
6405
6409
6406 * Removed -exit option. If people just want to run a python
6410 * Removed -exit option. If people just want to run a python
6407 script, that's what the normal interpreter is for. Less
6411 script, that's what the normal interpreter is for. Less
6408 unnecessary options, less chances for bugs.
6412 unnecessary options, less chances for bugs.
6409
6413
6410 * Added a crash handler which generates a complete post-mortem if
6414 * Added a crash handler which generates a complete post-mortem if
6411 IPython crashes. This will help a lot in tracking bugs down the
6415 IPython crashes. This will help a lot in tracking bugs down the
6412 road.
6416 road.
6413
6417
6414 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
6418 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
6415 which were boud to functions being reassigned would bypass the
6419 which were boud to functions being reassigned would bypass the
6416 logger, breaking the sync of _il with the prompt counter. This
6420 logger, breaking the sync of _il with the prompt counter. This
6417 would then crash IPython later when a new line was logged.
6421 would then crash IPython later when a new line was logged.
6418
6422
6419 2001-12-02 Fernando Perez <fperez@colorado.edu>
6423 2001-12-02 Fernando Perez <fperez@colorado.edu>
6420
6424
6421 * Made IPython a package. This means people don't have to clutter
6425 * Made IPython a package. This means people don't have to clutter
6422 their sys.path with yet another directory. Changed the INSTALL
6426 their sys.path with yet another directory. Changed the INSTALL
6423 file accordingly.
6427 file accordingly.
6424
6428
6425 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
6429 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
6426 sorts its output (so @who shows it sorted) and @whos formats the
6430 sorts its output (so @who shows it sorted) and @whos formats the
6427 table according to the width of the first column. Nicer, easier to
6431 table according to the width of the first column. Nicer, easier to
6428 read. Todo: write a generic table_format() which takes a list of
6432 read. Todo: write a generic table_format() which takes a list of
6429 lists and prints it nicely formatted, with optional row/column
6433 lists and prints it nicely formatted, with optional row/column
6430 separators and proper padding and justification.
6434 separators and proper padding and justification.
6431
6435
6432 * Released 0.1.20
6436 * Released 0.1.20
6433
6437
6434 * Fixed bug in @log which would reverse the inputcache list (a
6438 * Fixed bug in @log which would reverse the inputcache list (a
6435 copy operation was missing).
6439 copy operation was missing).
6436
6440
6437 * Code cleanup. @config was changed to use page(). Better, since
6441 * Code cleanup. @config was changed to use page(). Better, since
6438 its output is always quite long.
6442 its output is always quite long.
6439
6443
6440 * Itpl is back as a dependency. I was having too many problems
6444 * Itpl is back as a dependency. I was having too many problems
6441 getting the parametric aliases to work reliably, and it's just
6445 getting the parametric aliases to work reliably, and it's just
6442 easier to code weird string operations with it than playing %()s
6446 easier to code weird string operations with it than playing %()s
6443 games. It's only ~6k, so I don't think it's too big a deal.
6447 games. It's only ~6k, so I don't think it's too big a deal.
6444
6448
6445 * Found (and fixed) a very nasty bug with history. !lines weren't
6449 * Found (and fixed) a very nasty bug with history. !lines weren't
6446 getting cached, and the out of sync caches would crash
6450 getting cached, and the out of sync caches would crash
6447 IPython. Fixed it by reorganizing the prefilter/handlers/logger
6451 IPython. Fixed it by reorganizing the prefilter/handlers/logger
6448 division of labor a bit better. Bug fixed, cleaner structure.
6452 division of labor a bit better. Bug fixed, cleaner structure.
6449
6453
6450 2001-12-01 Fernando Perez <fperez@colorado.edu>
6454 2001-12-01 Fernando Perez <fperez@colorado.edu>
6451
6455
6452 * Released 0.1.19
6456 * Released 0.1.19
6453
6457
6454 * Added option -n to @hist to prevent line number printing. Much
6458 * Added option -n to @hist to prevent line number printing. Much
6455 easier to copy/paste code this way.
6459 easier to copy/paste code this way.
6456
6460
6457 * Created global _il to hold the input list. Allows easy
6461 * Created global _il to hold the input list. Allows easy
6458 re-execution of blocks of code by slicing it (inspired by Janko's
6462 re-execution of blocks of code by slicing it (inspired by Janko's
6459 comment on 'macros').
6463 comment on 'macros').
6460
6464
6461 * Small fixes and doc updates.
6465 * Small fixes and doc updates.
6462
6466
6463 * Rewrote @history function (was @h). Renamed it to @hist, @h is
6467 * Rewrote @history function (was @h). Renamed it to @hist, @h is
6464 much too fragile with automagic. Handles properly multi-line
6468 much too fragile with automagic. Handles properly multi-line
6465 statements and takes parameters.
6469 statements and takes parameters.
6466
6470
6467 2001-11-30 Fernando Perez <fperez@colorado.edu>
6471 2001-11-30 Fernando Perez <fperez@colorado.edu>
6468
6472
6469 * Version 0.1.18 released.
6473 * Version 0.1.18 released.
6470
6474
6471 * Fixed nasty namespace bug in initial module imports.
6475 * Fixed nasty namespace bug in initial module imports.
6472
6476
6473 * Added copyright/license notes to all code files (except
6477 * Added copyright/license notes to all code files (except
6474 DPyGetOpt). For the time being, LGPL. That could change.
6478 DPyGetOpt). For the time being, LGPL. That could change.
6475
6479
6476 * Rewrote a much nicer README, updated INSTALL, cleaned up
6480 * Rewrote a much nicer README, updated INSTALL, cleaned up
6477 ipythonrc-* samples.
6481 ipythonrc-* samples.
6478
6482
6479 * Overall code/documentation cleanup. Basically ready for
6483 * Overall code/documentation cleanup. Basically ready for
6480 release. Only remaining thing: licence decision (LGPL?).
6484 release. Only remaining thing: licence decision (LGPL?).
6481
6485
6482 * Converted load_config to a class, ConfigLoader. Now recursion
6486 * Converted load_config to a class, ConfigLoader. Now recursion
6483 control is better organized. Doesn't include the same file twice.
6487 control is better organized. Doesn't include the same file twice.
6484
6488
6485 2001-11-29 Fernando Perez <fperez@colorado.edu>
6489 2001-11-29 Fernando Perez <fperez@colorado.edu>
6486
6490
6487 * Got input history working. Changed output history variables from
6491 * Got input history working. Changed output history variables from
6488 _p to _o so that _i is for input and _o for output. Just cleaner
6492 _p to _o so that _i is for input and _o for output. Just cleaner
6489 convention.
6493 convention.
6490
6494
6491 * Implemented parametric aliases. This pretty much allows the
6495 * Implemented parametric aliases. This pretty much allows the
6492 alias system to offer full-blown shell convenience, I think.
6496 alias system to offer full-blown shell convenience, I think.
6493
6497
6494 * Version 0.1.17 released, 0.1.18 opened.
6498 * Version 0.1.17 released, 0.1.18 opened.
6495
6499
6496 * dot_ipython/ipythonrc (alias): added documentation.
6500 * dot_ipython/ipythonrc (alias): added documentation.
6497 (xcolor): Fixed small bug (xcolors -> xcolor)
6501 (xcolor): Fixed small bug (xcolors -> xcolor)
6498
6502
6499 * Changed the alias system. Now alias is a magic command to define
6503 * Changed the alias system. Now alias is a magic command to define
6500 aliases just like the shell. Rationale: the builtin magics should
6504 aliases just like the shell. Rationale: the builtin magics should
6501 be there for things deeply connected to IPython's
6505 be there for things deeply connected to IPython's
6502 architecture. And this is a much lighter system for what I think
6506 architecture. And this is a much lighter system for what I think
6503 is the really important feature: allowing users to define quickly
6507 is the really important feature: allowing users to define quickly
6504 magics that will do shell things for them, so they can customize
6508 magics that will do shell things for them, so they can customize
6505 IPython easily to match their work habits. If someone is really
6509 IPython easily to match their work habits. If someone is really
6506 desperate to have another name for a builtin alias, they can
6510 desperate to have another name for a builtin alias, they can
6507 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
6511 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
6508 works.
6512 works.
6509
6513
6510 2001-11-28 Fernando Perez <fperez@colorado.edu>
6514 2001-11-28 Fernando Perez <fperez@colorado.edu>
6511
6515
6512 * Changed @file so that it opens the source file at the proper
6516 * Changed @file so that it opens the source file at the proper
6513 line. Since it uses less, if your EDITOR environment is
6517 line. Since it uses less, if your EDITOR environment is
6514 configured, typing v will immediately open your editor of choice
6518 configured, typing v will immediately open your editor of choice
6515 right at the line where the object is defined. Not as quick as
6519 right at the line where the object is defined. Not as quick as
6516 having a direct @edit command, but for all intents and purposes it
6520 having a direct @edit command, but for all intents and purposes it
6517 works. And I don't have to worry about writing @edit to deal with
6521 works. And I don't have to worry about writing @edit to deal with
6518 all the editors, less does that.
6522 all the editors, less does that.
6519
6523
6520 * Version 0.1.16 released, 0.1.17 opened.
6524 * Version 0.1.16 released, 0.1.17 opened.
6521
6525
6522 * Fixed some nasty bugs in the page/page_dumb combo that could
6526 * Fixed some nasty bugs in the page/page_dumb combo that could
6523 crash IPython.
6527 crash IPython.
6524
6528
6525 2001-11-27 Fernando Perez <fperez@colorado.edu>
6529 2001-11-27 Fernando Perez <fperez@colorado.edu>
6526
6530
6527 * Version 0.1.15 released, 0.1.16 opened.
6531 * Version 0.1.15 released, 0.1.16 opened.
6528
6532
6529 * Finally got ? and ?? to work for undefined things: now it's
6533 * Finally got ? and ?? to work for undefined things: now it's
6530 possible to type {}.get? and get information about the get method
6534 possible to type {}.get? and get information about the get method
6531 of dicts, or os.path? even if only os is defined (so technically
6535 of dicts, or os.path? even if only os is defined (so technically
6532 os.path isn't). Works at any level. For example, after import os,
6536 os.path isn't). Works at any level. For example, after import os,
6533 os?, os.path?, os.path.abspath? all work. This is great, took some
6537 os?, os.path?, os.path.abspath? all work. This is great, took some
6534 work in _ofind.
6538 work in _ofind.
6535
6539
6536 * Fixed more bugs with logging. The sanest way to do it was to add
6540 * Fixed more bugs with logging. The sanest way to do it was to add
6537 to @log a 'mode' parameter. Killed two in one shot (this mode
6541 to @log a 'mode' parameter. Killed two in one shot (this mode
6538 option was a request of Janko's). I think it's finally clean
6542 option was a request of Janko's). I think it's finally clean
6539 (famous last words).
6543 (famous last words).
6540
6544
6541 * Added a page_dumb() pager which does a decent job of paging on
6545 * Added a page_dumb() pager which does a decent job of paging on
6542 screen, if better things (like less) aren't available. One less
6546 screen, if better things (like less) aren't available. One less
6543 unix dependency (someday maybe somebody will port this to
6547 unix dependency (someday maybe somebody will port this to
6544 windows).
6548 windows).
6545
6549
6546 * Fixed problem in magic_log: would lock of logging out if log
6550 * Fixed problem in magic_log: would lock of logging out if log
6547 creation failed (because it would still think it had succeeded).
6551 creation failed (because it would still think it had succeeded).
6548
6552
6549 * Improved the page() function using curses to auto-detect screen
6553 * Improved the page() function using curses to auto-detect screen
6550 size. Now it can make a much better decision on whether to print
6554 size. Now it can make a much better decision on whether to print
6551 or page a string. Option screen_length was modified: a value 0
6555 or page a string. Option screen_length was modified: a value 0
6552 means auto-detect, and that's the default now.
6556 means auto-detect, and that's the default now.
6553
6557
6554 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6558 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6555 go out. I'll test it for a few days, then talk to Janko about
6559 go out. I'll test it for a few days, then talk to Janko about
6556 licences and announce it.
6560 licences and announce it.
6557
6561
6558 * Fixed the length of the auto-generated ---> prompt which appears
6562 * Fixed the length of the auto-generated ---> prompt which appears
6559 for auto-parens and auto-quotes. Getting this right isn't trivial,
6563 for auto-parens and auto-quotes. Getting this right isn't trivial,
6560 with all the color escapes, different prompt types and optional
6564 with all the color escapes, different prompt types and optional
6561 separators. But it seems to be working in all the combinations.
6565 separators. But it seems to be working in all the combinations.
6562
6566
6563 2001-11-26 Fernando Perez <fperez@colorado.edu>
6567 2001-11-26 Fernando Perez <fperez@colorado.edu>
6564
6568
6565 * Wrote a regexp filter to get option types from the option names
6569 * Wrote a regexp filter to get option types from the option names
6566 string. This eliminates the need to manually keep two duplicate
6570 string. This eliminates the need to manually keep two duplicate
6567 lists.
6571 lists.
6568
6572
6569 * Removed the unneeded check_option_names. Now options are handled
6573 * Removed the unneeded check_option_names. Now options are handled
6570 in a much saner manner and it's easy to visually check that things
6574 in a much saner manner and it's easy to visually check that things
6571 are ok.
6575 are ok.
6572
6576
6573 * Updated version numbers on all files I modified to carry a
6577 * Updated version numbers on all files I modified to carry a
6574 notice so Janko and Nathan have clear version markers.
6578 notice so Janko and Nathan have clear version markers.
6575
6579
6576 * Updated docstring for ultraTB with my changes. I should send
6580 * Updated docstring for ultraTB with my changes. I should send
6577 this to Nathan.
6581 this to Nathan.
6578
6582
6579 * Lots of small fixes. Ran everything through pychecker again.
6583 * Lots of small fixes. Ran everything through pychecker again.
6580
6584
6581 * Made loading of deep_reload an cmd line option. If it's not too
6585 * Made loading of deep_reload an cmd line option. If it's not too
6582 kosher, now people can just disable it. With -nodeep_reload it's
6586 kosher, now people can just disable it. With -nodeep_reload it's
6583 still available as dreload(), it just won't overwrite reload().
6587 still available as dreload(), it just won't overwrite reload().
6584
6588
6585 * Moved many options to the no| form (-opt and -noopt
6589 * Moved many options to the no| form (-opt and -noopt
6586 accepted). Cleaner.
6590 accepted). Cleaner.
6587
6591
6588 * Changed magic_log so that if called with no parameters, it uses
6592 * Changed magic_log so that if called with no parameters, it uses
6589 'rotate' mode. That way auto-generated logs aren't automatically
6593 'rotate' mode. That way auto-generated logs aren't automatically
6590 over-written. For normal logs, now a backup is made if it exists
6594 over-written. For normal logs, now a backup is made if it exists
6591 (only 1 level of backups). A new 'backup' mode was added to the
6595 (only 1 level of backups). A new 'backup' mode was added to the
6592 Logger class to support this. This was a request by Janko.
6596 Logger class to support this. This was a request by Janko.
6593
6597
6594 * Added @logoff/@logon to stop/restart an active log.
6598 * Added @logoff/@logon to stop/restart an active log.
6595
6599
6596 * Fixed a lot of bugs in log saving/replay. It was pretty
6600 * Fixed a lot of bugs in log saving/replay. It was pretty
6597 broken. Now special lines (!@,/) appear properly in the command
6601 broken. Now special lines (!@,/) appear properly in the command
6598 history after a log replay.
6602 history after a log replay.
6599
6603
6600 * Tried and failed to implement full session saving via pickle. My
6604 * Tried and failed to implement full session saving via pickle. My
6601 idea was to pickle __main__.__dict__, but modules can't be
6605 idea was to pickle __main__.__dict__, but modules can't be
6602 pickled. This would be a better alternative to replaying logs, but
6606 pickled. This would be a better alternative to replaying logs, but
6603 seems quite tricky to get to work. Changed -session to be called
6607 seems quite tricky to get to work. Changed -session to be called
6604 -logplay, which more accurately reflects what it does. And if we
6608 -logplay, which more accurately reflects what it does. And if we
6605 ever get real session saving working, -session is now available.
6609 ever get real session saving working, -session is now available.
6606
6610
6607 * Implemented color schemes for prompts also. As for tracebacks,
6611 * Implemented color schemes for prompts also. As for tracebacks,
6608 currently only NoColor and Linux are supported. But now the
6612 currently only NoColor and Linux are supported. But now the
6609 infrastructure is in place, based on a generic ColorScheme
6613 infrastructure is in place, based on a generic ColorScheme
6610 class. So writing and activating new schemes both for the prompts
6614 class. So writing and activating new schemes both for the prompts
6611 and the tracebacks should be straightforward.
6615 and the tracebacks should be straightforward.
6612
6616
6613 * Version 0.1.13 released, 0.1.14 opened.
6617 * Version 0.1.13 released, 0.1.14 opened.
6614
6618
6615 * Changed handling of options for output cache. Now counter is
6619 * Changed handling of options for output cache. Now counter is
6616 hardwired starting at 1 and one specifies the maximum number of
6620 hardwired starting at 1 and one specifies the maximum number of
6617 entries *in the outcache* (not the max prompt counter). This is
6621 entries *in the outcache* (not the max prompt counter). This is
6618 much better, since many statements won't increase the cache
6622 much better, since many statements won't increase the cache
6619 count. It also eliminated some confusing options, now there's only
6623 count. It also eliminated some confusing options, now there's only
6620 one: cache_size.
6624 one: cache_size.
6621
6625
6622 * Added 'alias' magic function and magic_alias option in the
6626 * Added 'alias' magic function and magic_alias option in the
6623 ipythonrc file. Now the user can easily define whatever names he
6627 ipythonrc file. Now the user can easily define whatever names he
6624 wants for the magic functions without having to play weird
6628 wants for the magic functions without having to play weird
6625 namespace games. This gives IPython a real shell-like feel.
6629 namespace games. This gives IPython a real shell-like feel.
6626
6630
6627 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6631 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6628 @ or not).
6632 @ or not).
6629
6633
6630 This was one of the last remaining 'visible' bugs (that I know
6634 This was one of the last remaining 'visible' bugs (that I know
6631 of). I think if I can clean up the session loading so it works
6635 of). I think if I can clean up the session loading so it works
6632 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6636 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6633 about licensing).
6637 about licensing).
6634
6638
6635 2001-11-25 Fernando Perez <fperez@colorado.edu>
6639 2001-11-25 Fernando Perez <fperez@colorado.edu>
6636
6640
6637 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6641 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6638 there's a cleaner distinction between what ? and ?? show.
6642 there's a cleaner distinction between what ? and ?? show.
6639
6643
6640 * Added screen_length option. Now the user can define his own
6644 * Added screen_length option. Now the user can define his own
6641 screen size for page() operations.
6645 screen size for page() operations.
6642
6646
6643 * Implemented magic shell-like functions with automatic code
6647 * Implemented magic shell-like functions with automatic code
6644 generation. Now adding another function is just a matter of adding
6648 generation. Now adding another function is just a matter of adding
6645 an entry to a dict, and the function is dynamically generated at
6649 an entry to a dict, and the function is dynamically generated at
6646 run-time. Python has some really cool features!
6650 run-time. Python has some really cool features!
6647
6651
6648 * Renamed many options to cleanup conventions a little. Now all
6652 * Renamed many options to cleanup conventions a little. Now all
6649 are lowercase, and only underscores where needed. Also in the code
6653 are lowercase, and only underscores where needed. Also in the code
6650 option name tables are clearer.
6654 option name tables are clearer.
6651
6655
6652 * Changed prompts a little. Now input is 'In [n]:' instead of
6656 * Changed prompts a little. Now input is 'In [n]:' instead of
6653 'In[n]:='. This allows it the numbers to be aligned with the
6657 'In[n]:='. This allows it the numbers to be aligned with the
6654 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6658 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6655 Python (it was a Mathematica thing). The '...' continuation prompt
6659 Python (it was a Mathematica thing). The '...' continuation prompt
6656 was also changed a little to align better.
6660 was also changed a little to align better.
6657
6661
6658 * Fixed bug when flushing output cache. Not all _p<n> variables
6662 * Fixed bug when flushing output cache. Not all _p<n> variables
6659 exist, so their deletion needs to be wrapped in a try:
6663 exist, so their deletion needs to be wrapped in a try:
6660
6664
6661 * Figured out how to properly use inspect.formatargspec() (it
6665 * Figured out how to properly use inspect.formatargspec() (it
6662 requires the args preceded by *). So I removed all the code from
6666 requires the args preceded by *). So I removed all the code from
6663 _get_pdef in Magic, which was just replicating that.
6667 _get_pdef in Magic, which was just replicating that.
6664
6668
6665 * Added test to prefilter to allow redefining magic function names
6669 * Added test to prefilter to allow redefining magic function names
6666 as variables. This is ok, since the @ form is always available,
6670 as variables. This is ok, since the @ form is always available,
6667 but whe should allow the user to define a variable called 'ls' if
6671 but whe should allow the user to define a variable called 'ls' if
6668 he needs it.
6672 he needs it.
6669
6673
6670 * Moved the ToDo information from README into a separate ToDo.
6674 * Moved the ToDo information from README into a separate ToDo.
6671
6675
6672 * General code cleanup and small bugfixes. I think it's close to a
6676 * General code cleanup and small bugfixes. I think it's close to a
6673 state where it can be released, obviously with a big 'beta'
6677 state where it can be released, obviously with a big 'beta'
6674 warning on it.
6678 warning on it.
6675
6679
6676 * Got the magic function split to work. Now all magics are defined
6680 * Got the magic function split to work. Now all magics are defined
6677 in a separate class. It just organizes things a bit, and now
6681 in a separate class. It just organizes things a bit, and now
6678 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6682 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6679 was too long).
6683 was too long).
6680
6684
6681 * Changed @clear to @reset to avoid potential confusions with
6685 * Changed @clear to @reset to avoid potential confusions with
6682 the shell command clear. Also renamed @cl to @clear, which does
6686 the shell command clear. Also renamed @cl to @clear, which does
6683 exactly what people expect it to from their shell experience.
6687 exactly what people expect it to from their shell experience.
6684
6688
6685 Added a check to the @reset command (since it's so
6689 Added a check to the @reset command (since it's so
6686 destructive, it's probably a good idea to ask for confirmation).
6690 destructive, it's probably a good idea to ask for confirmation).
6687 But now reset only works for full namespace resetting. Since the
6691 But now reset only works for full namespace resetting. Since the
6688 del keyword is already there for deleting a few specific
6692 del keyword is already there for deleting a few specific
6689 variables, I don't see the point of having a redundant magic
6693 variables, I don't see the point of having a redundant magic
6690 function for the same task.
6694 function for the same task.
6691
6695
6692 2001-11-24 Fernando Perez <fperez@colorado.edu>
6696 2001-11-24 Fernando Perez <fperez@colorado.edu>
6693
6697
6694 * Updated the builtin docs (esp. the ? ones).
6698 * Updated the builtin docs (esp. the ? ones).
6695
6699
6696 * Ran all the code through pychecker. Not terribly impressed with
6700 * Ran all the code through pychecker. Not terribly impressed with
6697 it: lots of spurious warnings and didn't really find anything of
6701 it: lots of spurious warnings and didn't really find anything of
6698 substance (just a few modules being imported and not used).
6702 substance (just a few modules being imported and not used).
6699
6703
6700 * Implemented the new ultraTB functionality into IPython. New
6704 * Implemented the new ultraTB functionality into IPython. New
6701 option: xcolors. This chooses color scheme. xmode now only selects
6705 option: xcolors. This chooses color scheme. xmode now only selects
6702 between Plain and Verbose. Better orthogonality.
6706 between Plain and Verbose. Better orthogonality.
6703
6707
6704 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6708 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6705 mode and color scheme for the exception handlers. Now it's
6709 mode and color scheme for the exception handlers. Now it's
6706 possible to have the verbose traceback with no coloring.
6710 possible to have the verbose traceback with no coloring.
6707
6711
6708 2001-11-23 Fernando Perez <fperez@colorado.edu>
6712 2001-11-23 Fernando Perez <fperez@colorado.edu>
6709
6713
6710 * Version 0.1.12 released, 0.1.13 opened.
6714 * Version 0.1.12 released, 0.1.13 opened.
6711
6715
6712 * Removed option to set auto-quote and auto-paren escapes by
6716 * Removed option to set auto-quote and auto-paren escapes by
6713 user. The chances of breaking valid syntax are just too high. If
6717 user. The chances of breaking valid syntax are just too high. If
6714 someone *really* wants, they can always dig into the code.
6718 someone *really* wants, they can always dig into the code.
6715
6719
6716 * Made prompt separators configurable.
6720 * Made prompt separators configurable.
6717
6721
6718 2001-11-22 Fernando Perez <fperez@colorado.edu>
6722 2001-11-22 Fernando Perez <fperez@colorado.edu>
6719
6723
6720 * Small bugfixes in many places.
6724 * Small bugfixes in many places.
6721
6725
6722 * Removed the MyCompleter class from ipplib. It seemed redundant
6726 * Removed the MyCompleter class from ipplib. It seemed redundant
6723 with the C-p,C-n history search functionality. Less code to
6727 with the C-p,C-n history search functionality. Less code to
6724 maintain.
6728 maintain.
6725
6729
6726 * Moved all the original ipython.py code into ipythonlib.py. Right
6730 * Moved all the original ipython.py code into ipythonlib.py. Right
6727 now it's just one big dump into a function called make_IPython, so
6731 now it's just one big dump into a function called make_IPython, so
6728 no real modularity has been gained. But at least it makes the
6732 no real modularity has been gained. But at least it makes the
6729 wrapper script tiny, and since ipythonlib is a module, it gets
6733 wrapper script tiny, and since ipythonlib is a module, it gets
6730 compiled and startup is much faster.
6734 compiled and startup is much faster.
6731
6735
6732 This is a reasobably 'deep' change, so we should test it for a
6736 This is a reasobably 'deep' change, so we should test it for a
6733 while without messing too much more with the code.
6737 while without messing too much more with the code.
6734
6738
6735 2001-11-21 Fernando Perez <fperez@colorado.edu>
6739 2001-11-21 Fernando Perez <fperez@colorado.edu>
6736
6740
6737 * Version 0.1.11 released, 0.1.12 opened for further work.
6741 * Version 0.1.11 released, 0.1.12 opened for further work.
6738
6742
6739 * Removed dependency on Itpl. It was only needed in one place. It
6743 * Removed dependency on Itpl. It was only needed in one place. It
6740 would be nice if this became part of python, though. It makes life
6744 would be nice if this became part of python, though. It makes life
6741 *a lot* easier in some cases.
6745 *a lot* easier in some cases.
6742
6746
6743 * Simplified the prefilter code a bit. Now all handlers are
6747 * Simplified the prefilter code a bit. Now all handlers are
6744 expected to explicitly return a value (at least a blank string).
6748 expected to explicitly return a value (at least a blank string).
6745
6749
6746 * Heavy edits in ipplib. Removed the help system altogether. Now
6750 * Heavy edits in ipplib. Removed the help system altogether. Now
6747 obj?/?? is used for inspecting objects, a magic @doc prints
6751 obj?/?? is used for inspecting objects, a magic @doc prints
6748 docstrings, and full-blown Python help is accessed via the 'help'
6752 docstrings, and full-blown Python help is accessed via the 'help'
6749 keyword. This cleans up a lot of code (less to maintain) and does
6753 keyword. This cleans up a lot of code (less to maintain) and does
6750 the job. Since 'help' is now a standard Python component, might as
6754 the job. Since 'help' is now a standard Python component, might as
6751 well use it and remove duplicate functionality.
6755 well use it and remove duplicate functionality.
6752
6756
6753 Also removed the option to use ipplib as a standalone program. By
6757 Also removed the option to use ipplib as a standalone program. By
6754 now it's too dependent on other parts of IPython to function alone.
6758 now it's too dependent on other parts of IPython to function alone.
6755
6759
6756 * Fixed bug in genutils.pager. It would crash if the pager was
6760 * Fixed bug in genutils.pager. It would crash if the pager was
6757 exited immediately after opening (broken pipe).
6761 exited immediately after opening (broken pipe).
6758
6762
6759 * Trimmed down the VerboseTB reporting a little. The header is
6763 * Trimmed down the VerboseTB reporting a little. The header is
6760 much shorter now and the repeated exception arguments at the end
6764 much shorter now and the repeated exception arguments at the end
6761 have been removed. For interactive use the old header seemed a bit
6765 have been removed. For interactive use the old header seemed a bit
6762 excessive.
6766 excessive.
6763
6767
6764 * Fixed small bug in output of @whos for variables with multi-word
6768 * Fixed small bug in output of @whos for variables with multi-word
6765 types (only first word was displayed).
6769 types (only first word was displayed).
6766
6770
6767 2001-11-17 Fernando Perez <fperez@colorado.edu>
6771 2001-11-17 Fernando Perez <fperez@colorado.edu>
6768
6772
6769 * Version 0.1.10 released, 0.1.11 opened for further work.
6773 * Version 0.1.10 released, 0.1.11 opened for further work.
6770
6774
6771 * Modified dirs and friends. dirs now *returns* the stack (not
6775 * Modified dirs and friends. dirs now *returns* the stack (not
6772 prints), so one can manipulate it as a variable. Convenient to
6776 prints), so one can manipulate it as a variable. Convenient to
6773 travel along many directories.
6777 travel along many directories.
6774
6778
6775 * Fixed bug in magic_pdef: would only work with functions with
6779 * Fixed bug in magic_pdef: would only work with functions with
6776 arguments with default values.
6780 arguments with default values.
6777
6781
6778 2001-11-14 Fernando Perez <fperez@colorado.edu>
6782 2001-11-14 Fernando Perez <fperez@colorado.edu>
6779
6783
6780 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6784 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6781 example with IPython. Various other minor fixes and cleanups.
6785 example with IPython. Various other minor fixes and cleanups.
6782
6786
6783 * Version 0.1.9 released, 0.1.10 opened for further work.
6787 * Version 0.1.9 released, 0.1.10 opened for further work.
6784
6788
6785 * Added sys.path to the list of directories searched in the
6789 * Added sys.path to the list of directories searched in the
6786 execfile= option. It used to be the current directory and the
6790 execfile= option. It used to be the current directory and the
6787 user's IPYTHONDIR only.
6791 user's IPYTHONDIR only.
6788
6792
6789 2001-11-13 Fernando Perez <fperez@colorado.edu>
6793 2001-11-13 Fernando Perez <fperez@colorado.edu>
6790
6794
6791 * Reinstated the raw_input/prefilter separation that Janko had
6795 * Reinstated the raw_input/prefilter separation that Janko had
6792 initially. This gives a more convenient setup for extending the
6796 initially. This gives a more convenient setup for extending the
6793 pre-processor from the outside: raw_input always gets a string,
6797 pre-processor from the outside: raw_input always gets a string,
6794 and prefilter has to process it. We can then redefine prefilter
6798 and prefilter has to process it. We can then redefine prefilter
6795 from the outside and implement extensions for special
6799 from the outside and implement extensions for special
6796 purposes.
6800 purposes.
6797
6801
6798 Today I got one for inputting PhysicalQuantity objects
6802 Today I got one for inputting PhysicalQuantity objects
6799 (from Scientific) without needing any function calls at
6803 (from Scientific) without needing any function calls at
6800 all. Extremely convenient, and it's all done as a user-level
6804 all. Extremely convenient, and it's all done as a user-level
6801 extension (no IPython code was touched). Now instead of:
6805 extension (no IPython code was touched). Now instead of:
6802 a = PhysicalQuantity(4.2,'m/s**2')
6806 a = PhysicalQuantity(4.2,'m/s**2')
6803 one can simply say
6807 one can simply say
6804 a = 4.2 m/s**2
6808 a = 4.2 m/s**2
6805 or even
6809 or even
6806 a = 4.2 m/s^2
6810 a = 4.2 m/s^2
6807
6811
6808 I use this, but it's also a proof of concept: IPython really is
6812 I use this, but it's also a proof of concept: IPython really is
6809 fully user-extensible, even at the level of the parsing of the
6813 fully user-extensible, even at the level of the parsing of the
6810 command line. It's not trivial, but it's perfectly doable.
6814 command line. It's not trivial, but it's perfectly doable.
6811
6815
6812 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6816 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6813 the problem of modules being loaded in the inverse order in which
6817 the problem of modules being loaded in the inverse order in which
6814 they were defined in
6818 they were defined in
6815
6819
6816 * Version 0.1.8 released, 0.1.9 opened for further work.
6820 * Version 0.1.8 released, 0.1.9 opened for further work.
6817
6821
6818 * Added magics pdef, source and file. They respectively show the
6822 * Added magics pdef, source and file. They respectively show the
6819 definition line ('prototype' in C), source code and full python
6823 definition line ('prototype' in C), source code and full python
6820 file for any callable object. The object inspector oinfo uses
6824 file for any callable object. The object inspector oinfo uses
6821 these to show the same information.
6825 these to show the same information.
6822
6826
6823 * Version 0.1.7 released, 0.1.8 opened for further work.
6827 * Version 0.1.7 released, 0.1.8 opened for further work.
6824
6828
6825 * Separated all the magic functions into a class called Magic. The
6829 * Separated all the magic functions into a class called Magic. The
6826 InteractiveShell class was becoming too big for Xemacs to handle
6830 InteractiveShell class was becoming too big for Xemacs to handle
6827 (de-indenting a line would lock it up for 10 seconds while it
6831 (de-indenting a line would lock it up for 10 seconds while it
6828 backtracked on the whole class!)
6832 backtracked on the whole class!)
6829
6833
6830 FIXME: didn't work. It can be done, but right now namespaces are
6834 FIXME: didn't work. It can be done, but right now namespaces are
6831 all messed up. Do it later (reverted it for now, so at least
6835 all messed up. Do it later (reverted it for now, so at least
6832 everything works as before).
6836 everything works as before).
6833
6837
6834 * Got the object introspection system (magic_oinfo) working! I
6838 * Got the object introspection system (magic_oinfo) working! I
6835 think this is pretty much ready for release to Janko, so he can
6839 think this is pretty much ready for release to Janko, so he can
6836 test it for a while and then announce it. Pretty much 100% of what
6840 test it for a while and then announce it. Pretty much 100% of what
6837 I wanted for the 'phase 1' release is ready. Happy, tired.
6841 I wanted for the 'phase 1' release is ready. Happy, tired.
6838
6842
6839 2001-11-12 Fernando Perez <fperez@colorado.edu>
6843 2001-11-12 Fernando Perez <fperez@colorado.edu>
6840
6844
6841 * Version 0.1.6 released, 0.1.7 opened for further work.
6845 * Version 0.1.6 released, 0.1.7 opened for further work.
6842
6846
6843 * Fixed bug in printing: it used to test for truth before
6847 * Fixed bug in printing: it used to test for truth before
6844 printing, so 0 wouldn't print. Now checks for None.
6848 printing, so 0 wouldn't print. Now checks for None.
6845
6849
6846 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6850 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6847 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6851 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6848 reaches by hand into the outputcache. Think of a better way to do
6852 reaches by hand into the outputcache. Think of a better way to do
6849 this later.
6853 this later.
6850
6854
6851 * Various small fixes thanks to Nathan's comments.
6855 * Various small fixes thanks to Nathan's comments.
6852
6856
6853 * Changed magic_pprint to magic_Pprint. This way it doesn't
6857 * Changed magic_pprint to magic_Pprint. This way it doesn't
6854 collide with pprint() and the name is consistent with the command
6858 collide with pprint() and the name is consistent with the command
6855 line option.
6859 line option.
6856
6860
6857 * Changed prompt counter behavior to be fully like
6861 * Changed prompt counter behavior to be fully like
6858 Mathematica's. That is, even input that doesn't return a result
6862 Mathematica's. That is, even input that doesn't return a result
6859 raises the prompt counter. The old behavior was kind of confusing
6863 raises the prompt counter. The old behavior was kind of confusing
6860 (getting the same prompt number several times if the operation
6864 (getting the same prompt number several times if the operation
6861 didn't return a result).
6865 didn't return a result).
6862
6866
6863 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6867 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6864
6868
6865 * Fixed -Classic mode (wasn't working anymore).
6869 * Fixed -Classic mode (wasn't working anymore).
6866
6870
6867 * Added colored prompts using Nathan's new code. Colors are
6871 * Added colored prompts using Nathan's new code. Colors are
6868 currently hardwired, they can be user-configurable. For
6872 currently hardwired, they can be user-configurable. For
6869 developers, they can be chosen in file ipythonlib.py, at the
6873 developers, they can be chosen in file ipythonlib.py, at the
6870 beginning of the CachedOutput class def.
6874 beginning of the CachedOutput class def.
6871
6875
6872 2001-11-11 Fernando Perez <fperez@colorado.edu>
6876 2001-11-11 Fernando Perez <fperez@colorado.edu>
6873
6877
6874 * Version 0.1.5 released, 0.1.6 opened for further work.
6878 * Version 0.1.5 released, 0.1.6 opened for further work.
6875
6879
6876 * Changed magic_env to *return* the environment as a dict (not to
6880 * Changed magic_env to *return* the environment as a dict (not to
6877 print it). This way it prints, but it can also be processed.
6881 print it). This way it prints, but it can also be processed.
6878
6882
6879 * Added Verbose exception reporting to interactive
6883 * Added Verbose exception reporting to interactive
6880 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6884 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6881 traceback. Had to make some changes to the ultraTB file. This is
6885 traceback. Had to make some changes to the ultraTB file. This is
6882 probably the last 'big' thing in my mental todo list. This ties
6886 probably the last 'big' thing in my mental todo list. This ties
6883 in with the next entry:
6887 in with the next entry:
6884
6888
6885 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6889 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6886 has to specify is Plain, Color or Verbose for all exception
6890 has to specify is Plain, Color or Verbose for all exception
6887 handling.
6891 handling.
6888
6892
6889 * Removed ShellServices option. All this can really be done via
6893 * Removed ShellServices option. All this can really be done via
6890 the magic system. It's easier to extend, cleaner and has automatic
6894 the magic system. It's easier to extend, cleaner and has automatic
6891 namespace protection and documentation.
6895 namespace protection and documentation.
6892
6896
6893 2001-11-09 Fernando Perez <fperez@colorado.edu>
6897 2001-11-09 Fernando Perez <fperez@colorado.edu>
6894
6898
6895 * Fixed bug in output cache flushing (missing parameter to
6899 * Fixed bug in output cache flushing (missing parameter to
6896 __init__). Other small bugs fixed (found using pychecker).
6900 __init__). Other small bugs fixed (found using pychecker).
6897
6901
6898 * Version 0.1.4 opened for bugfixing.
6902 * Version 0.1.4 opened for bugfixing.
6899
6903
6900 2001-11-07 Fernando Perez <fperez@colorado.edu>
6904 2001-11-07 Fernando Perez <fperez@colorado.edu>
6901
6905
6902 * Version 0.1.3 released, mainly because of the raw_input bug.
6906 * Version 0.1.3 released, mainly because of the raw_input bug.
6903
6907
6904 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6908 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6905 and when testing for whether things were callable, a call could
6909 and when testing for whether things were callable, a call could
6906 actually be made to certain functions. They would get called again
6910 actually be made to certain functions. They would get called again
6907 once 'really' executed, with a resulting double call. A disaster
6911 once 'really' executed, with a resulting double call. A disaster
6908 in many cases (list.reverse() would never work!).
6912 in many cases (list.reverse() would never work!).
6909
6913
6910 * Removed prefilter() function, moved its code to raw_input (which
6914 * Removed prefilter() function, moved its code to raw_input (which
6911 after all was just a near-empty caller for prefilter). This saves
6915 after all was just a near-empty caller for prefilter). This saves
6912 a function call on every prompt, and simplifies the class a tiny bit.
6916 a function call on every prompt, and simplifies the class a tiny bit.
6913
6917
6914 * Fix _ip to __ip name in magic example file.
6918 * Fix _ip to __ip name in magic example file.
6915
6919
6916 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6920 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6917 work with non-gnu versions of tar.
6921 work with non-gnu versions of tar.
6918
6922
6919 2001-11-06 Fernando Perez <fperez@colorado.edu>
6923 2001-11-06 Fernando Perez <fperez@colorado.edu>
6920
6924
6921 * Version 0.1.2. Just to keep track of the recent changes.
6925 * Version 0.1.2. Just to keep track of the recent changes.
6922
6926
6923 * Fixed nasty bug in output prompt routine. It used to check 'if
6927 * Fixed nasty bug in output prompt routine. It used to check 'if
6924 arg != None...'. Problem is, this fails if arg implements a
6928 arg != None...'. Problem is, this fails if arg implements a
6925 special comparison (__cmp__) which disallows comparing to
6929 special comparison (__cmp__) which disallows comparing to
6926 None. Found it when trying to use the PhysicalQuantity module from
6930 None. Found it when trying to use the PhysicalQuantity module from
6927 ScientificPython.
6931 ScientificPython.
6928
6932
6929 2001-11-05 Fernando Perez <fperez@colorado.edu>
6933 2001-11-05 Fernando Perez <fperez@colorado.edu>
6930
6934
6931 * Also added dirs. Now the pushd/popd/dirs family functions
6935 * Also added dirs. Now the pushd/popd/dirs family functions
6932 basically like the shell, with the added convenience of going home
6936 basically like the shell, with the added convenience of going home
6933 when called with no args.
6937 when called with no args.
6934
6938
6935 * pushd/popd slightly modified to mimic shell behavior more
6939 * pushd/popd slightly modified to mimic shell behavior more
6936 closely.
6940 closely.
6937
6941
6938 * Added env,pushd,popd from ShellServices as magic functions. I
6942 * Added env,pushd,popd from ShellServices as magic functions. I
6939 think the cleanest will be to port all desired functions from
6943 think the cleanest will be to port all desired functions from
6940 ShellServices as magics and remove ShellServices altogether. This
6944 ShellServices as magics and remove ShellServices altogether. This
6941 will provide a single, clean way of adding functionality
6945 will provide a single, clean way of adding functionality
6942 (shell-type or otherwise) to IP.
6946 (shell-type or otherwise) to IP.
6943
6947
6944 2001-11-04 Fernando Perez <fperez@colorado.edu>
6948 2001-11-04 Fernando Perez <fperez@colorado.edu>
6945
6949
6946 * Added .ipython/ directory to sys.path. This way users can keep
6950 * Added .ipython/ directory to sys.path. This way users can keep
6947 customizations there and access them via import.
6951 customizations there and access them via import.
6948
6952
6949 2001-11-03 Fernando Perez <fperez@colorado.edu>
6953 2001-11-03 Fernando Perez <fperez@colorado.edu>
6950
6954
6951 * Opened version 0.1.1 for new changes.
6955 * Opened version 0.1.1 for new changes.
6952
6956
6953 * Changed version number to 0.1.0: first 'public' release, sent to
6957 * Changed version number to 0.1.0: first 'public' release, sent to
6954 Nathan and Janko.
6958 Nathan and Janko.
6955
6959
6956 * Lots of small fixes and tweaks.
6960 * Lots of small fixes and tweaks.
6957
6961
6958 * Minor changes to whos format. Now strings are shown, snipped if
6962 * Minor changes to whos format. Now strings are shown, snipped if
6959 too long.
6963 too long.
6960
6964
6961 * Changed ShellServices to work on __main__ so they show up in @who
6965 * Changed ShellServices to work on __main__ so they show up in @who
6962
6966
6963 * Help also works with ? at the end of a line:
6967 * Help also works with ? at the end of a line:
6964 ?sin and sin?
6968 ?sin and sin?
6965 both produce the same effect. This is nice, as often I use the
6969 both produce the same effect. This is nice, as often I use the
6966 tab-complete to find the name of a method, but I used to then have
6970 tab-complete to find the name of a method, but I used to then have
6967 to go to the beginning of the line to put a ? if I wanted more
6971 to go to the beginning of the line to put a ? if I wanted more
6968 info. Now I can just add the ? and hit return. Convenient.
6972 info. Now I can just add the ? and hit return. Convenient.
6969
6973
6970 2001-11-02 Fernando Perez <fperez@colorado.edu>
6974 2001-11-02 Fernando Perez <fperez@colorado.edu>
6971
6975
6972 * Python version check (>=2.1) added.
6976 * Python version check (>=2.1) added.
6973
6977
6974 * Added LazyPython documentation. At this point the docs are quite
6978 * Added LazyPython documentation. At this point the docs are quite
6975 a mess. A cleanup is in order.
6979 a mess. A cleanup is in order.
6976
6980
6977 * Auto-installer created. For some bizarre reason, the zipfiles
6981 * Auto-installer created. For some bizarre reason, the zipfiles
6978 module isn't working on my system. So I made a tar version
6982 module isn't working on my system. So I made a tar version
6979 (hopefully the command line options in various systems won't kill
6983 (hopefully the command line options in various systems won't kill
6980 me).
6984 me).
6981
6985
6982 * Fixes to Struct in genutils. Now all dictionary-like methods are
6986 * Fixes to Struct in genutils. Now all dictionary-like methods are
6983 protected (reasonably).
6987 protected (reasonably).
6984
6988
6985 * Added pager function to genutils and changed ? to print usage
6989 * Added pager function to genutils and changed ? to print usage
6986 note through it (it was too long).
6990 note through it (it was too long).
6987
6991
6988 * Added the LazyPython functionality. Works great! I changed the
6992 * Added the LazyPython functionality. Works great! I changed the
6989 auto-quote escape to ';', it's on home row and next to '. But
6993 auto-quote escape to ';', it's on home row and next to '. But
6990 both auto-quote and auto-paren (still /) escapes are command-line
6994 both auto-quote and auto-paren (still /) escapes are command-line
6991 parameters.
6995 parameters.
6992
6996
6993
6997
6994 2001-11-01 Fernando Perez <fperez@colorado.edu>
6998 2001-11-01 Fernando Perez <fperez@colorado.edu>
6995
6999
6996 * Version changed to 0.0.7. Fairly large change: configuration now
7000 * Version changed to 0.0.7. Fairly large change: configuration now
6997 is all stored in a directory, by default .ipython. There, all
7001 is all stored in a directory, by default .ipython. There, all
6998 config files have normal looking names (not .names)
7002 config files have normal looking names (not .names)
6999
7003
7000 * Version 0.0.6 Released first to Lucas and Archie as a test
7004 * Version 0.0.6 Released first to Lucas and Archie as a test
7001 run. Since it's the first 'semi-public' release, change version to
7005 run. Since it's the first 'semi-public' release, change version to
7002 > 0.0.6 for any changes now.
7006 > 0.0.6 for any changes now.
7003
7007
7004 * Stuff I had put in the ipplib.py changelog:
7008 * Stuff I had put in the ipplib.py changelog:
7005
7009
7006 Changes to InteractiveShell:
7010 Changes to InteractiveShell:
7007
7011
7008 - Made the usage message a parameter.
7012 - Made the usage message a parameter.
7009
7013
7010 - Require the name of the shell variable to be given. It's a bit
7014 - Require the name of the shell variable to be given. It's a bit
7011 of a hack, but allows the name 'shell' not to be hardwired in the
7015 of a hack, but allows the name 'shell' not to be hardwired in the
7012 magic (@) handler, which is problematic b/c it requires
7016 magic (@) handler, which is problematic b/c it requires
7013 polluting the global namespace with 'shell'. This in turn is
7017 polluting the global namespace with 'shell'. This in turn is
7014 fragile: if a user redefines a variable called shell, things
7018 fragile: if a user redefines a variable called shell, things
7015 break.
7019 break.
7016
7020
7017 - magic @: all functions available through @ need to be defined
7021 - magic @: all functions available through @ need to be defined
7018 as magic_<name>, even though they can be called simply as
7022 as magic_<name>, even though they can be called simply as
7019 @<name>. This allows the special command @magic to gather
7023 @<name>. This allows the special command @magic to gather
7020 information automatically about all existing magic functions,
7024 information automatically about all existing magic functions,
7021 even if they are run-time user extensions, by parsing the shell
7025 even if they are run-time user extensions, by parsing the shell
7022 instance __dict__ looking for special magic_ names.
7026 instance __dict__ looking for special magic_ names.
7023
7027
7024 - mainloop: added *two* local namespace parameters. This allows
7028 - mainloop: added *two* local namespace parameters. This allows
7025 the class to differentiate between parameters which were there
7029 the class to differentiate between parameters which were there
7026 before and after command line initialization was processed. This
7030 before and after command line initialization was processed. This
7027 way, later @who can show things loaded at startup by the
7031 way, later @who can show things loaded at startup by the
7028 user. This trick was necessary to make session saving/reloading
7032 user. This trick was necessary to make session saving/reloading
7029 really work: ideally after saving/exiting/reloading a session,
7033 really work: ideally after saving/exiting/reloading a session,
7030 *everything* should look the same, including the output of @who. I
7034 *everything* should look the same, including the output of @who. I
7031 was only able to make this work with this double namespace
7035 was only able to make this work with this double namespace
7032 trick.
7036 trick.
7033
7037
7034 - added a header to the logfile which allows (almost) full
7038 - added a header to the logfile which allows (almost) full
7035 session restoring.
7039 session restoring.
7036
7040
7037 - prepend lines beginning with @ or !, with a and log
7041 - prepend lines beginning with @ or !, with a and log
7038 them. Why? !lines: may be useful to know what you did @lines:
7042 them. Why? !lines: may be useful to know what you did @lines:
7039 they may affect session state. So when restoring a session, at
7043 they may affect session state. So when restoring a session, at
7040 least inform the user of their presence. I couldn't quite get
7044 least inform the user of their presence. I couldn't quite get
7041 them to properly re-execute, but at least the user is warned.
7045 them to properly re-execute, but at least the user is warned.
7042
7046
7043 * Started ChangeLog.
7047 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now