##// END OF EJS Templates
Apply patch by Paul Mueller <gakusei-AT-dakotacom.net>, to fix deprecated...
fperez -
Show More
@@ -1,671 +1,693 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """DPyGetOpt -- Demiurge Python GetOptions Module
2 """DPyGetOpt -- Demiurge Python GetOptions Module
3
3
4 $Id: DPyGetOpt.py 1980 2006-12-12 21:48:46Z vivainio $
4 $Id: DPyGetOpt.py 2872 2007-11-25 17:58:05Z fperez $
5
5
6 This module is modeled after perl's Getopt::Long module-- which
6 This module is modeled after perl's Getopt::Long module-- which
7 is, in turn, modeled after GNU's extended getopt() function.
7 is, in turn, modeled after GNU's extended getopt() function.
8
8
9 Upon instantiation, the option specification should be a sequence
9 Upon instantiation, the option specification should be a sequence
10 (list) of option definitions.
10 (list) of option definitions.
11
11
12 Options that take no arguments should simply contain the name of
12 Options that take no arguments should simply contain the name of
13 the option. If a ! is post-pended, the option can be negated by
13 the option. If a ! is post-pended, the option can be negated by
14 prepending 'no'; ie 'debug!' specifies that -debug and -nodebug
14 prepending 'no'; ie 'debug!' specifies that -debug and -nodebug
15 should be accepted.
15 should be accepted.
16
16
17 Mandatory arguments to options are specified using a postpended
17 Mandatory arguments to options are specified using a postpended
18 '=' + a type specifier. '=s' specifies a mandatory string
18 '=' + a type specifier. '=s' specifies a mandatory string
19 argument, '=i' specifies a mandatory integer argument, and '=f'
19 argument, '=i' specifies a mandatory integer argument, and '=f'
20 specifies a mandatory real number. In all cases, the '=' can be
20 specifies a mandatory real number. In all cases, the '=' can be
21 substituted with ':' to specify that the argument is optional.
21 substituted with ':' to specify that the argument is optional.
22
22
23 Dashes '-' in option names are allowed.
23 Dashes '-' in option names are allowed.
24
24
25 If an option has the character '@' postpended (after the
25 If an option has the character '@' postpended (after the
26 argumentation specification), it can appear multiple times within
26 argumentation specification), it can appear multiple times within
27 each argument list that is processed. The results will be stored
27 each argument list that is processed. The results will be stored
28 in a list.
28 in a list.
29
29
30 The option name can actually be a list of names separated by '|'
30 The option name can actually be a list of names separated by '|'
31 characters; ie-- 'foo|bar|baz=f@' specifies that all -foo, -bar,
31 characters; ie-- 'foo|bar|baz=f@' specifies that all -foo, -bar,
32 and -baz options that appear on within the parsed argument list
32 and -baz options that appear on within the parsed argument list
33 must have a real number argument and that the accumulated list
33 must have a real number argument and that the accumulated list
34 of values will be available under the name 'foo'
34 of values will be available under the name 'foo'
35
35
36 $Id: DPyGetOpt.py 1980 2006-12-12 21:48:46Z vivainio $"""
36 $Id: DPyGetOpt.py 2872 2007-11-25 17:58:05Z fperez $"""
37
37
38 #*****************************************************************************
38 #*****************************************************************************
39 #
39 #
40 # Copyright (c) 2001 Bill Bumgarner <bbum@friday.com>
40 # Copyright (c) 2001 Bill Bumgarner <bbum@friday.com>
41 #
41 #
42 #
42 #
43 # Published under the terms of the MIT license, hereby reproduced:
43 # Published under the terms of the MIT license, hereby reproduced:
44 #
44 #
45 # Permission is hereby granted, free of charge, to any person obtaining a copy
45 # Permission is hereby granted, free of charge, to any person obtaining a copy
46 # of this software and associated documentation files (the "Software"), to
46 # of this software and associated documentation files (the "Software"), to
47 # deal in the Software without restriction, including without limitation the
47 # deal in the Software without restriction, including without limitation the
48 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
48 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
49 # sell copies of the Software, and to permit persons to whom the Software is
49 # sell copies of the Software, and to permit persons to whom the Software is
50 # furnished to do so, subject to the following conditions:
50 # furnished to do so, subject to the following conditions:
51 #
51 #
52 # The above copyright notice and this permission notice shall be included in
52 # The above copyright notice and this permission notice shall be included in
53 # all copies or substantial portions of the Software.
53 # all copies or substantial portions of the Software.
54 #
54 #
55 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
59 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
60 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
60 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
61 # IN THE SOFTWARE.
61 # IN THE SOFTWARE.
62 #
62 #
63 #*****************************************************************************
63 #*****************************************************************************
64
64
65 __author__ = 'Bill Bumgarner <bbum@friday.com>'
65 __author__ = 'Bill Bumgarner <bbum@friday.com>'
66 __license__ = 'MIT'
66 __license__ = 'MIT'
67 __version__ = '1.2'
67 __version__ = '1.2'
68
68
69 # Modified to use re instead of regex and regsub modules.
69 # Modified to use re instead of regex and regsub modules.
70 # 2001/5/7, Jonathan Hogg <jonathan@onegoodidea.com>
70 # 2001/5/7, Jonathan Hogg <jonathan@onegoodidea.com>
71
71
72 import re
72 import re
73 import string
73 import string
74 import sys
74 import sys
75 import types
75 import types
76
76
77 arg_error = 'DPyGetOpt Argument Error'
77 class Error(Exception):
78 spec_error = 'DPyGetOpt Specification Error'
78 """Base class for exceptions in the DPyGetOpt module."""
79 term_error = 'DPyGetOpt Termination Error'
79
80 class ArgumentError(Error):
81 """Exception indicating an error in the arguments passed to
82 DPyGetOpt.processArguments."""
83
84 class SpecificationError(Error):
85 """Exception indicating an error with an option specification."""
86
87 class TerminationError(Error):
88 """Exception indicating an error with an option processing terminator."""
80
89
81 specificationExpr = re.compile('(?P<required>.)(?P<type>.)(?P<multi>@?)')
90 specificationExpr = re.compile('(?P<required>.)(?P<type>.)(?P<multi>@?)')
82
91
83 ArgRequired = 'Requires an Argument'
92 ArgRequired = 'Requires an Argument'
84 ArgOptional = 'Argument Optional'
93 ArgOptional = 'Argument Optional'
85
94
86 # The types modules is not used for these identifiers because there
95 # The types modules is not used for these identifiers because there
87 # is no identifier for 'boolean' or 'generic'
96 # is no identifier for 'boolean' or 'generic'
88 StringArgType = 'String Argument Type'
97 StringArgType = 'String Argument Type'
89 IntegerArgType = 'Integer Argument Type'
98 IntegerArgType = 'Integer Argument Type'
90 RealArgType = 'Real Argument Type'
99 RealArgType = 'Real Argument Type'
91 BooleanArgType = 'Boolean Argument Type'
100 BooleanArgType = 'Boolean Argument Type'
92 GenericArgType = 'Generic Argument Type'
101 GenericArgType = 'Generic Argument Type'
93
102
94 # dictionary of conversion functions-- boolean and generic options
103 # dictionary of conversion functions-- boolean and generic options
95 # do not accept arguments and do not need conversion functions;
104 # do not accept arguments and do not need conversion functions;
96 # the identity function is used purely for convenience.
105 # the identity function is used purely for convenience.
97 ConversionFunctions = {
106 ConversionFunctions = {
98 StringArgType : lambda x: x,
107 StringArgType : lambda x: x,
99 IntegerArgType : string.atoi,
108 IntegerArgType : string.atoi,
100 RealArgType : string.atof,
109 RealArgType : string.atof,
101 BooleanArgType : lambda x: x,
110 BooleanArgType : lambda x: x,
102 GenericArgType : lambda x: x,
111 GenericArgType : lambda x: x,
103 }
112 }
104
113
105 class DPyGetOpt:
114 class DPyGetOpt:
106
115
107 def __init__(self, spec = None, terminators = ['--']):
116 def __init__(self, spec = None, terminators = ['--']):
108 """
117 """
109 Declare and intialize instance variables
118 Declare and intialize instance variables
110
119
111 Yes, declaration is not necessary... but one of the things
120 Yes, declaration is not necessary... but one of the things
112 I sorely miss from C/Obj-C is the concept of having an
121 I sorely miss from C/Obj-C is the concept of having an
113 interface definition that clearly declares all instance
122 interface definition that clearly declares all instance
114 variables and methods without providing any implementation
123 variables and methods without providing any implementation
115 details. it is a useful reference!
124 details. it is a useful reference!
116
125
117 all instance variables are initialized to 0/Null/None of
126 all instance variables are initialized to 0/Null/None of
118 the appropriate type-- not even the default value...
127 the appropriate type-- not even the default value...
119 """
128 """
120
129
121 # sys.stderr.write(string.join(spec) + "\n")
130 # sys.stderr.write(string.join(spec) + "\n")
122
131
123 self.allowAbbreviations = 1 # boolean, 1 if abbreviations will
132 self.allowAbbreviations = 1 # boolean, 1 if abbreviations will
124 # be expanded
133 # be expanded
125 self.freeValues = [] # list, contains free values
134 self.freeValues = [] # list, contains free values
126 self.ignoreCase = 0 # boolean, YES if ignoring case
135 self.ignoreCase = 0 # boolean, YES if ignoring case
127 self.needsParse = 0 # boolean, YES if need to reparse parameter spec
136 self.needsParse = 0 # boolean, YES if need to reparse parameter spec
128 self.optionNames = {} # dict, all option names-- value is index of tuple
137 self.optionNames = {} # dict, all option names-- value is index of tuple
129 self.optionStartExpr = None # regexp defining the start of an option (ie; '-', '--')
138 self.optionStartExpr = None # regexp defining the start of an option (ie; '-', '--')
130 self.optionTuples = [] # list o' tuples containing defn of options AND aliases
139 self.optionTuples = [] # list o' tuples containing defn of options AND aliases
131 self.optionValues = {} # dict, option names (after alias expansion) -> option value(s)
140 self.optionValues = {} # dict, option names (after alias expansion) -> option value(s)
132 self.orderMixed = 0 # boolean, YES if options can be mixed with args
141 self.orderMixed = 0 # boolean, YES if options can be mixed with args
133 self.posixCompliance = 0 # boolean, YES indicates posix like behaviour
142 self.posixCompliance = 0 # boolean, YES indicates posix like behaviour
134 self.spec = [] # list, raw specs (in case it must be reparsed)
143 self.spec = [] # list, raw specs (in case it must be reparsed)
135 self.terminators = terminators # list, strings that terminate argument processing
144 self.terminators = terminators # list, strings that terminate argument processing
136 self.termValues = [] # list, values after terminator
145 self.termValues = [] # list, values after terminator
137 self.terminator = None # full name of terminator that ended
146 self.terminator = None # full name of terminator that ended
138 # option processing
147 # option processing
139
148
140 # set up defaults
149 # set up defaults
141 self.setPosixCompliance()
150 self.setPosixCompliance()
142 self.setIgnoreCase()
151 self.setIgnoreCase()
143 self.setAllowAbbreviations()
152 self.setAllowAbbreviations()
144
153
145 # parse spec-- if present
154 # parse spec-- if present
146 if spec:
155 if spec:
147 self.parseConfiguration(spec)
156 self.parseConfiguration(spec)
148
157
149 def setPosixCompliance(self, aFlag = 0):
158 def setPosixCompliance(self, aFlag = 0):
150 """
159 """
151 Enables and disables posix compliance.
160 Enables and disables posix compliance.
152
161
153 When enabled, '+' can be used as an option prefix and free
162 When enabled, '+' can be used as an option prefix and free
154 values can be mixed with options.
163 values can be mixed with options.
155 """
164 """
156 self.posixCompliance = aFlag
165 self.posixCompliance = aFlag
157 self.needsParse = 1
166 self.needsParse = 1
158
167
159 if self.posixCompliance:
168 if self.posixCompliance:
160 self.optionStartExpr = re.compile('(--|-)(?P<option>[A-Za-z0-9_-]+)(?P<arg>=.*)?')
169 self.optionStartExpr = re.compile('(--|-)(?P<option>[A-Za-z0-9_-]+)(?P<arg>=.*)?')
161 self.orderMixed = 0
170 self.orderMixed = 0
162 else:
171 else:
163 self.optionStartExpr = re.compile('(--|-|\+)(?P<option>[A-Za-z0-9_-]+)(?P<arg>=.*)?')
172 self.optionStartExpr = re.compile('(--|-|\+)(?P<option>[A-Za-z0-9_-]+)(?P<arg>=.*)?')
164 self.orderMixed = 1
173 self.orderMixed = 1
165
174
166 def isPosixCompliant(self):
175 def isPosixCompliant(self):
167 """
176 """
168 Returns the value of the posix compliance flag.
177 Returns the value of the posix compliance flag.
169 """
178 """
170 return self.posixCompliance
179 return self.posixCompliance
171
180
172 def setIgnoreCase(self, aFlag = 1):
181 def setIgnoreCase(self, aFlag = 1):
173 """
182 """
174 Enables and disables ignoring case during option processing.
183 Enables and disables ignoring case during option processing.
175 """
184 """
176 self.needsParse = 1
185 self.needsParse = 1
177 self.ignoreCase = aFlag
186 self.ignoreCase = aFlag
178
187
179 def ignoreCase(self):
188 def ignoreCase(self):
180 """
189 """
181 Returns 1 if the option processor will ignore case when
190 Returns 1 if the option processor will ignore case when
182 processing options.
191 processing options.
183 """
192 """
184 return self.ignoreCase
193 return self.ignoreCase
185
194
186 def setAllowAbbreviations(self, aFlag = 1):
195 def setAllowAbbreviations(self, aFlag = 1):
187 """
196 """
188 Enables and disables the expansion of abbreviations during
197 Enables and disables the expansion of abbreviations during
189 option processing.
198 option processing.
190 """
199 """
191 self.allowAbbreviations = aFlag
200 self.allowAbbreviations = aFlag
192
201
193 def willAllowAbbreviations(self):
202 def willAllowAbbreviations(self):
194 """
203 """
195 Returns 1 if abbreviated options will be automatically
204 Returns 1 if abbreviated options will be automatically
196 expanded to the non-abbreviated form (instead of causing an
205 expanded to the non-abbreviated form (instead of causing an
197 unrecognized option error).
206 unrecognized option error).
198 """
207 """
199 return self.allowAbbreviations
208 return self.allowAbbreviations
200
209
201 def addTerminator(self, newTerm):
210 def addTerminator(self, newTerm):
202 """
211 """
203 Adds newTerm as terminator of option processing.
212 Adds newTerm as terminator of option processing.
204
213
205 Whenever the option processor encounters one of the terminators
214 Whenever the option processor encounters one of the terminators
206 during option processing, the processing of options terminates
215 during option processing, the processing of options terminates
207 immediately, all remaining options are stored in the termValues
216 immediately, all remaining options are stored in the termValues
208 instance variable and the full name of the terminator is stored
217 instance variable and the full name of the terminator is stored
209 in the terminator instance variable.
218 in the terminator instance variable.
210 """
219 """
211 self.terminators = self.terminators + [newTerm]
220 self.terminators = self.terminators + [newTerm]
212
221
213 def _addOption(self, oTuple):
222 def _addOption(self, oTuple):
214 """
223 """
215 Adds the option described by oTuple (name, (type, mode,
224 Adds the option described by oTuple (name, (type, mode,
216 default), alias) to optionTuples. Adds index keyed under name
225 default), alias) to optionTuples. Adds index keyed under name
217 to optionNames. Raises spec_error if name already in
226 to optionNames. Raises SpecificationError if name already in
218 optionNames
227 optionNames
219 """
228 """
220 (name, (type, mode, default, multi), realName) = oTuple
229 (name, (type, mode, default, multi), realName) = oTuple
221
230
222 # verify name and add to option names dictionary
231 # verify name and add to option names dictionary
223 if self.optionNames.has_key(name):
232 if self.optionNames.has_key(name):
224 if realName:
233 if realName:
225 raise spec_error, 'Alias \'' + name + '\' for \'' + realName + \
234 raise SpecificationError('Alias \'' + name + '\' for \'' +
226 '\' already used for another option or alias.'
235 realName +
236 '\' already used for another option or alias.')
227 else:
237 else:
228 raise spec_error, 'Option named \'' + name + \
238 raise SpecificationError('Option named \'' + name +
229 '\' specified more than once. Specification: ' + option
239 '\' specified more than once. Specification: '
240 + option)
230
241
231 # validated. add to optionNames
242 # validated. add to optionNames
232 self.optionNames[name] = self.tupleIndex
243 self.optionNames[name] = self.tupleIndex
233 self.tupleIndex = self.tupleIndex + 1
244 self.tupleIndex = self.tupleIndex + 1
234
245
235 # add to optionTuples
246 # add to optionTuples
236 self.optionTuples = self.optionTuples + [oTuple]
247 self.optionTuples = self.optionTuples + [oTuple]
237
248
238 # if type is boolean, add negation
249 # if type is boolean, add negation
239 if type == BooleanArgType:
250 if type == BooleanArgType:
240 alias = 'no' + name
251 alias = 'no' + name
241 specTuple = (type, mode, 0, multi)
252 specTuple = (type, mode, 0, multi)
242 oTuple = (alias, specTuple, name)
253 oTuple = (alias, specTuple, name)
243
254
244 # verify name and add to option names dictionary
255 # verify name and add to option names dictionary
245 if self.optionNames.has_key(alias):
256 if self.optionNames.has_key(alias):
246 if realName:
257 if realName:
247 raise spec_error, 'Negated alias \'' + name + '\' for \'' + realName + \
258 raise SpecificationError('Negated alias \'' + name +
248 '\' already used for another option or alias.'
259 '\' for \'' + realName +
260 '\' already used for another option or alias.')
249 else:
261 else:
250 raise spec_error, 'Negated option named \'' + name + \
262 raise SpecificationError('Negated option named \'' + name +
251 '\' specified more than once. Specification: ' + option
263 '\' specified more than once. Specification: '
264 + option)
252
265
253 # validated. add to optionNames
266 # validated. add to optionNames
254 self.optionNames[alias] = self.tupleIndex
267 self.optionNames[alias] = self.tupleIndex
255 self.tupleIndex = self.tupleIndex + 1
268 self.tupleIndex = self.tupleIndex + 1
256
269
257 # add to optionTuples
270 # add to optionTuples
258 self.optionTuples = self.optionTuples + [oTuple]
271 self.optionTuples = self.optionTuples + [oTuple]
259
272
260 def addOptionConfigurationTuple(self, oTuple):
273 def addOptionConfigurationTuple(self, oTuple):
261 (name, argSpec, realName) = oTuple
274 (name, argSpec, realName) = oTuple
262 if self.ignoreCase:
275 if self.ignoreCase:
263 name = string.lower(name)
276 name = string.lower(name)
264 if realName:
277 if realName:
265 realName = string.lower(realName)
278 realName = string.lower(realName)
266 else:
279 else:
267 realName = name
280 realName = name
268
281
269 oTuple = (name, argSpec, realName)
282 oTuple = (name, argSpec, realName)
270
283
271 # add option
284 # add option
272 self._addOption(oTuple)
285 self._addOption(oTuple)
273
286
274 def addOptionConfigurationTuples(self, oTuple):
287 def addOptionConfigurationTuples(self, oTuple):
275 if type(oTuple) is ListType:
288 if type(oTuple) is ListType:
276 for t in oTuple:
289 for t in oTuple:
277 self.addOptionConfigurationTuple(t)
290 self.addOptionConfigurationTuple(t)
278 else:
291 else:
279 self.addOptionConfigurationTuple(oTuple)
292 self.addOptionConfigurationTuple(oTuple)
280
293
281 def parseConfiguration(self, spec):
294 def parseConfiguration(self, spec):
282 # destroy previous stored information + store raw spec
295 # destroy previous stored information + store raw spec
283 self.spec = spec
296 self.spec = spec
284 self.optionTuples = []
297 self.optionTuples = []
285 self.optionNames = {}
298 self.optionNames = {}
286 self.tupleIndex = 0
299 self.tupleIndex = 0
287
300
288 tupleIndex = 0
301 tupleIndex = 0
289
302
290 # create some regex's for parsing each spec
303 # create some regex's for parsing each spec
291 splitExpr = \
304 splitExpr = \
292 re.compile('(?P<names>\w+[-A-Za-z0-9|]*)?(?P<spec>!|[=:][infs]@?)?')
305 re.compile('(?P<names>\w+[-A-Za-z0-9|]*)?(?P<spec>!|[=:][infs]@?)?')
293 for option in spec:
306 for option in spec:
294 # push to lower case (does not negatively affect
307 # push to lower case (does not negatively affect
295 # specification)
308 # specification)
296 if self.ignoreCase:
309 if self.ignoreCase:
297 option = string.lower(option)
310 option = string.lower(option)
298
311
299 # break into names, specification
312 # break into names, specification
300 match = splitExpr.match(option)
313 match = splitExpr.match(option)
301 if match is None:
314 if match is None:
302 raise spec_error, 'Invalid specification {' + option + '}'
315 raise SpecificationError('Invalid specification {' + option +
316 '}')
303
317
304 names = match.group('names')
318 names = match.group('names')
305 specification = match.group('spec')
319 specification = match.group('spec')
306
320
307 # break name into name, aliases
321 # break name into name, aliases
308 nlist = string.split(names, '|')
322 nlist = string.split(names, '|')
309
323
310 # get name
324 # get name
311 name = nlist[0]
325 name = nlist[0]
312 aliases = nlist[1:]
326 aliases = nlist[1:]
313
327
314 # specificationExpr = regex.symcomp('\(<required>.\)\(<type>.\)\(<multi>@?\)')
328 # specificationExpr = regex.symcomp('\(<required>.\)\(<type>.\)\(<multi>@?\)')
315 if not specification:
329 if not specification:
316 #spec tuple is ('type', 'arg mode', 'default value', 'multiple')
330 #spec tuple is ('type', 'arg mode', 'default value', 'multiple')
317 argType = GenericArgType
331 argType = GenericArgType
318 argMode = None
332 argMode = None
319 argDefault = 1
333 argDefault = 1
320 argMultiple = 0
334 argMultiple = 0
321 elif specification == '!':
335 elif specification == '!':
322 argType = BooleanArgType
336 argType = BooleanArgType
323 argMode = None
337 argMode = None
324 argDefault = 1
338 argDefault = 1
325 argMultiple = 0
339 argMultiple = 0
326 else:
340 else:
327 # parse
341 # parse
328 match = specificationExpr.match(specification)
342 match = specificationExpr.match(specification)
329 if match is None:
343 if match is None:
330 # failed to parse, die
344 # failed to parse, die
331 raise spec_error, 'Invalid configuration for option \'' + option + '\''
345 raise SpecificationError('Invalid configuration for option \''
346 + option + '\'')
332
347
333 # determine mode
348 # determine mode
334 required = match.group('required')
349 required = match.group('required')
335 if required == '=':
350 if required == '=':
336 argMode = ArgRequired
351 argMode = ArgRequired
337 elif required == ':':
352 elif required == ':':
338 argMode = ArgOptional
353 argMode = ArgOptional
339 else:
354 else:
340 raise spec_error, 'Unknown requirement configuration \'' + required + '\''
355 raise SpecificationError('Unknown requirement configuration \''
356 + required + '\'')
341
357
342 # determine type
358 # determine type
343 type = match.group('type')
359 type = match.group('type')
344 if type == 's':
360 if type == 's':
345 argType = StringArgType
361 argType = StringArgType
346 argDefault = ''
362 argDefault = ''
347 elif type == 'i':
363 elif type == 'i':
348 argType = IntegerArgType
364 argType = IntegerArgType
349 argDefault = 1
365 argDefault = 1
350 elif type == 'f' or type == 'n':
366 elif type == 'f' or type == 'n':
351 argType = RealArgType
367 argType = RealArgType
352 argDefault = 1
368 argDefault = 1
353 else:
369 else:
354 raise spec_error, 'Unknown type specifier \'' + type + '\''
370 raise SpecificationError('Unknown type specifier \'' +
371 type + '\'')
355
372
356 # determine quantity
373 # determine quantity
357 if match.group('multi') == '@':
374 if match.group('multi') == '@':
358 argMultiple = 1
375 argMultiple = 1
359 else:
376 else:
360 argMultiple = 0
377 argMultiple = 0
361 ## end else (of not specification)
378 ## end else (of not specification)
362
379
363 # construct specification tuple
380 # construct specification tuple
364 specTuple = (argType, argMode, argDefault, argMultiple)
381 specTuple = (argType, argMode, argDefault, argMultiple)
365
382
366 # add the option-- option tuple is (name, specTuple, real name)
383 # add the option-- option tuple is (name, specTuple, real name)
367 oTuple = (name, specTuple, name)
384 oTuple = (name, specTuple, name)
368 self._addOption(oTuple)
385 self._addOption(oTuple)
369
386
370 for alias in aliases:
387 for alias in aliases:
371 # drop to all lower (if configured to do so)
388 # drop to all lower (if configured to do so)
372 if self.ignoreCase:
389 if self.ignoreCase:
373 alias = string.lower(alias)
390 alias = string.lower(alias)
374 # create configuration tuple
391 # create configuration tuple
375 oTuple = (alias, specTuple, name)
392 oTuple = (alias, specTuple, name)
376 # add
393 # add
377 self._addOption(oTuple)
394 self._addOption(oTuple)
378
395
379 # successfully parsed....
396 # successfully parsed....
380 self.needsParse = 0
397 self.needsParse = 0
381
398
382 def _getArgTuple(self, argName):
399 def _getArgTuple(self, argName):
383 """
400 """
384 Returns a list containing all the specification tuples that
401 Returns a list containing all the specification tuples that
385 match argName. If none match, None is returned. If one
402 match argName. If none match, None is returned. If one
386 matches, a list with one tuple is returned. If more than one
403 matches, a list with one tuple is returned. If more than one
387 match, a list containing all the tuples that matched is
404 match, a list containing all the tuples that matched is
388 returned.
405 returned.
389
406
390 In other words, this function does not pass judgement upon the
407 In other words, this function does not pass judgement upon the
391 validity of multiple matches.
408 validity of multiple matches.
392 """
409 """
393 # is it in the optionNames dict?
410 # is it in the optionNames dict?
394
411
395 try:
412 try:
396 # sys.stderr.write(argName + string.join(self.optionNames.keys()) + "\n")
413 # sys.stderr.write(argName + string.join(self.optionNames.keys()) + "\n")
397
414
398 # yes, get index
415 # yes, get index
399 tupleIndex = self.optionNames[argName]
416 tupleIndex = self.optionNames[argName]
400 # and return tuple as element of list
417 # and return tuple as element of list
401 return [self.optionTuples[tupleIndex]]
418 return [self.optionTuples[tupleIndex]]
402 except KeyError:
419 except KeyError:
403 # are abbreviations allowed?
420 # are abbreviations allowed?
404 if not self.allowAbbreviations:
421 if not self.allowAbbreviations:
405 # No! terefore, this cannot be valid argument-- nothing found
422 # No! terefore, this cannot be valid argument-- nothing found
406 return None
423 return None
407
424
408 # argName might be an abbreviation (and, abbreviations must
425 # argName might be an abbreviation (and, abbreviations must
409 # be allowed... or this would not have been reached!)
426 # be allowed... or this would not have been reached!)
410
427
411 # create regex for argName
428 # create regex for argName
412 argExpr = re.compile('^' + argName)
429 argExpr = re.compile('^' + argName)
413
430
414 tuples = filter(lambda x, argExpr=argExpr: argExpr.search(x[0]) is not None,
431 tuples = filter(lambda x, argExpr=argExpr: argExpr.search(x[0]) is not None,
415 self.optionTuples)
432 self.optionTuples)
416
433
417 if not len(tuples):
434 if not len(tuples):
418 return None
435 return None
419 else:
436 else:
420 return tuples
437 return tuples
421
438
422 def _isTerminator(self, optionName):
439 def _isTerminator(self, optionName):
423 """
440 """
424 Returns the full name of the terminator if optionName is a valid
441 Returns the full name of the terminator if optionName is a valid
425 terminator. If it is, sets self.terminator to the full name of
442 terminator. If it is, sets self.terminator to the full name of
426 the terminator.
443 the terminator.
427
444
428 If more than one terminator matched, raises a term_error with a
445 If more than one terminator matched, raises a TerminationError with a
429 string describing the ambiguity.
446 string describing the ambiguity.
430 """
447 """
431
448
432 # sys.stderr.write(optionName + "\n")
449 # sys.stderr.write(optionName + "\n")
433 # sys.stderr.write(repr(self.terminators))
450 # sys.stderr.write(repr(self.terminators))
434
451
435 if optionName in self.terminators:
452 if optionName in self.terminators:
436 self.terminator = optionName
453 self.terminator = optionName
437 elif not self.allowAbbreviations:
454 elif not self.allowAbbreviations:
438 return None
455 return None
439
456
440 # regex thing in bogus
457 # regex thing in bogus
441 # termExpr = regex.compile('^' + optionName)
458 # termExpr = regex.compile('^' + optionName)
442
459
443 terms = filter(lambda x, on=optionName: string.find(x,on) == 0, self.terminators)
460 terms = filter(lambda x, on=optionName: string.find(x,on) == 0, self.terminators)
444
461
445 if not len(terms):
462 if not len(terms):
446 return None
463 return None
447 elif len(terms) > 1:
464 elif len(terms) > 1:
448 raise term_error, 'Ambiguous terminator \'' + optionName + \
465 raise TerminationError('Ambiguous terminator \'' + optionName +
449 '\' matches ' + repr(terms)
466 '\' matches ' + repr(terms))
450
467
451 self.terminator = terms[0]
468 self.terminator = terms[0]
452 return self.terminator
469 return self.terminator
453
470
454 def processArguments(self, args = None):
471 def processArguments(self, args = None):
455 """
472 """
456 Processes args, a list of arguments (including options).
473 Processes args, a list of arguments (including options).
457
474
458 If args is the same as sys.argv, automatically trims the first
475 If args is the same as sys.argv, automatically trims the first
459 argument (the executable name/path).
476 argument (the executable name/path).
460
477
461 If an exception is not raised, the argument list was parsed
478 If an exception is not raised, the argument list was parsed
462 correctly.
479 correctly.
463
480
464 Upon successful completion, the freeValues instance variable
481 Upon successful completion, the freeValues instance variable
465 will contain all the arguments that were not associated with an
482 will contain all the arguments that were not associated with an
466 option in the order they were encountered. optionValues is a
483 option in the order they were encountered. optionValues is a
467 dictionary containing the value of each option-- the method
484 dictionary containing the value of each option-- the method
468 valueForOption() can be used to query this dictionary.
485 valueForOption() can be used to query this dictionary.
469 terminator will contain the argument encountered that terminated
486 terminator will contain the argument encountered that terminated
470 option processing (or None, if a terminator was never
487 option processing (or None, if a terminator was never
471 encountered) and termValues will contain all of the options that
488 encountered) and termValues will contain all of the options that
472 appeared after the Terminator (or an empty list).
489 appeared after the Terminator (or an empty list).
473 """
490 """
474
491
475 if hasattr(sys, "argv") and args == sys.argv:
492 if hasattr(sys, "argv") and args == sys.argv:
476 args = sys.argv[1:]
493 args = sys.argv[1:]
477
494
478 max = len(args) # maximum index + 1
495 max = len(args) # maximum index + 1
479 self.freeValues = [] # array to hold return values
496 self.freeValues = [] # array to hold return values
480 self.optionValues= {}
497 self.optionValues= {}
481 index = 0 # initial index
498 index = 0 # initial index
482 self.terminator = None
499 self.terminator = None
483 self.termValues = []
500 self.termValues = []
484
501
485 while index < max:
502 while index < max:
486 # obtain argument
503 # obtain argument
487 arg = args[index]
504 arg = args[index]
488 # increment index -- REMEMBER; it is NOW incremented
505 # increment index -- REMEMBER; it is NOW incremented
489 index = index + 1
506 index = index + 1
490
507
491 # terminate immediately if option terminator encountered
508 # terminate immediately if option terminator encountered
492 if self._isTerminator(arg):
509 if self._isTerminator(arg):
493 self.freeValues = self.freeValues + args[index:]
510 self.freeValues = self.freeValues + args[index:]
494 self.termValues = args[index:]
511 self.termValues = args[index:]
495 return
512 return
496
513
497 # is this possibly an option?
514 # is this possibly an option?
498 match = self.optionStartExpr.match(arg)
515 match = self.optionStartExpr.match(arg)
499 if match is None:
516 if match is None:
500 # not an option-- add to freeValues
517 # not an option-- add to freeValues
501 self.freeValues = self.freeValues + [arg]
518 self.freeValues = self.freeValues + [arg]
502 if not self.orderMixed:
519 if not self.orderMixed:
503 # mixing not allowed; add rest of args as freeValues
520 # mixing not allowed; add rest of args as freeValues
504 self.freeValues = self.freeValues + args[index:]
521 self.freeValues = self.freeValues + args[index:]
505 # return to caller
522 # return to caller
506 return
523 return
507 else:
524 else:
508 continue
525 continue
509
526
510 # grab name
527 # grab name
511 optName = match.group('option')
528 optName = match.group('option')
512
529
513 # obtain next argument-- index has already been incremented
530 # obtain next argument-- index has already been incremented
514 nextArg = match.group('arg')
531 nextArg = match.group('arg')
515 if nextArg:
532 if nextArg:
516 nextArg = nextArg[1:]
533 nextArg = nextArg[1:]
517 index = index - 1 # put it back
534 index = index - 1 # put it back
518 else:
535 else:
519 try:
536 try:
520 nextArg = args[index]
537 nextArg = args[index]
521 except:
538 except:
522 nextArg = None
539 nextArg = None
523
540
524 # transpose to lower case, if necessary
541 # transpose to lower case, if necessary
525 if self.ignoreCase:
542 if self.ignoreCase:
526 optName = string.lower(optName)
543 optName = string.lower(optName)
527
544
528 # obtain defining tuple
545 # obtain defining tuple
529 tuples = self._getArgTuple(optName)
546 tuples = self._getArgTuple(optName)
530
547
531 if tuples == None:
548 if tuples == None:
532 raise arg_error, 'Illegal option \'' + arg + '\''
549 raise ArgumentError('Illegal option \'' + arg + '\'')
533 elif len(tuples) > 1:
550 elif len(tuples) > 1:
534 raise arg_error, 'Ambiguous option \'' + arg + '\'; matches ' + \
551 raise ArgumentError('Ambiguous option \'' + arg +
535 repr(map(lambda x: x[0], tuples))
552 '\'; matches ' +
553 repr(map(lambda x: x[0], tuples)))
536 else:
554 else:
537 config = tuples[0]
555 config = tuples[0]
538
556
539 # config is now set to the configuration tuple for the
557 # config is now set to the configuration tuple for the
540 # argument
558 # argument
541 (fullName, spec, realName) = config
559 (fullName, spec, realName) = config
542 (optType, optMode, optDefault, optMultiple) = spec
560 (optType, optMode, optDefault, optMultiple) = spec
543
561
544 # if opt mode required, but nextArg is none, raise an error
562 # if opt mode required, but nextArg is none, raise an error
545 if (optMode == ArgRequired):
563 if (optMode == ArgRequired):
546 if (not nextArg) or self._isTerminator(nextArg):
564 if (not nextArg) or self._isTerminator(nextArg):
547 # print nextArg
565 # print nextArg
548 raise arg_error, 'Option \'' + arg + \
566 raise ArgumentError('Option \'' + arg +
549 '\' requires an argument of type ' + optType
567 '\' requires an argument of type ' +
568 optType)
550
569
551 if (not optMode == None) and nextArg and (not self._isTerminator(nextArg)):
570 if (not optMode == None) and nextArg and (not self._isTerminator(nextArg)):
552 # nextArg defined, option configured to possibly consume arg
571 # nextArg defined, option configured to possibly consume arg
553 try:
572 try:
554 # grab conversion function-- the try is more for internal diagnostics
573 # grab conversion function-- the try is more for internal diagnostics
555 func = ConversionFunctions[optType]
574 func = ConversionFunctions[optType]
556 try:
575 try:
557 optionValue = func(nextArg)
576 optionValue = func(nextArg)
558 index = index + 1
577 index = index + 1
559 except:
578 except:
560 # only raise conversion error if REQUIRED to consume argument
579 # only raise conversion error if REQUIRED to consume argument
561 if optMode == ArgRequired:
580 if optMode == ArgRequired:
562 raise arg_error, 'Invalid argument to option \'' + arg + \
581 raise ArgumentError('Invalid argument to option \''
563 '\'; should be \'' + optType + '\''
582 + arg + '\'; should be \'' +
583 optType + '\'')
564 else:
584 else:
565 optionValue = optDefault
585 optionValue = optDefault
566 except arg_error:
586 except ArgumentError:
567 raise arg_error, sys.exc_value
587 raise
568 except:
588 except:
569 raise arg_error, '(' + arg + \
589 raise ArgumentError('(' + arg +
570 ') Conversion function for \'' + optType + '\' not found.'
590 ') Conversion function for \'' +
591 optType + '\' not found.')
571 else:
592 else:
572 optionValue = optDefault
593 optionValue = optDefault
573
594
574 # add value to options dictionary
595 # add value to options dictionary
575 if optMultiple:
596 if optMultiple:
576 # can be multiple values
597 # can be multiple values
577 try:
598 try:
578 # try to append element
599 # try to append element
579 self.optionValues[realName] = self.optionValues[realName] + [optionValue]
600 self.optionValues[realName] = self.optionValues[realName] + [optionValue]
580 except:
601 except:
581 # failed-- must not exist; add it
602 # failed-- must not exist; add it
582 self.optionValues[realName] = [optionValue]
603 self.optionValues[realName] = [optionValue]
583 else:
604 else:
584 # only one value per
605 # only one value per
585 if self.isPosixCompliant and self.optionValues.has_key(realName):
606 if self.isPosixCompliant and self.optionValues.has_key(realName):
586 raise arg_error, 'Argument \'' + arg + '\' occurs multiple times.'
607 raise ArgumentError('Argument \'' + arg +
608 '\' occurs multiple times.')
587
609
588 self.optionValues[realName] = optionValue
610 self.optionValues[realName] = optionValue
589
611
590 def valueForOption(self, optionName, defaultValue = None):
612 def valueForOption(self, optionName, defaultValue = None):
591 """
613 """
592 Return the value associated with optionName. If optionName was
614 Return the value associated with optionName. If optionName was
593 not encountered during parsing of the arguments, returns the
615 not encountered during parsing of the arguments, returns the
594 defaultValue (which defaults to None).
616 defaultValue (which defaults to None).
595 """
617 """
596 try:
618 try:
597 optionValue = self.optionValues[optionName]
619 optionValue = self.optionValues[optionName]
598 except:
620 except:
599 optionValue = defaultValue
621 optionValue = defaultValue
600
622
601 return optionValue
623 return optionValue
602
624
603 ##
625 ##
604 ## test/example section
626 ## test/example section
605 ##
627 ##
606 test_error = 'Test Run Amok!'
628 test_error = 'Test Run Amok!'
607 def _test():
629 def _test():
608 """
630 """
609 A relatively complete test suite.
631 A relatively complete test suite.
610 """
632 """
611 try:
633 try:
612 DPyGetOpt(['foo', 'bar=s', 'foo'])
634 DPyGetOpt(['foo', 'bar=s', 'foo'])
613 except:
635 except Error, exc:
614 print 'EXCEPTION (should be \'foo\' already used..): ' + sys.exc_value
636 print 'EXCEPTION (should be \'foo\' already used..): %s' % exc
615
637
616 try:
638 try:
617 DPyGetOpt(['foo|bar|apple=s@', 'baz|apple!'])
639 DPyGetOpt(['foo|bar|apple=s@', 'baz|apple!'])
618 except:
640 except Error, exc:
619 print 'EXCEPTION (should be duplicate alias/name error): ' + sys.exc_value
641 print 'EXCEPTION (should be duplicate alias/name error): %s' % exc
620
642
621 x = DPyGetOpt(['apple|atlas=i@', 'application|executable=f@'])
643 x = DPyGetOpt(['apple|atlas=i@', 'application|executable=f@'])
622 try:
644 try:
623 x.processArguments(['-app', '29.3'])
645 x.processArguments(['-app', '29.3'])
624 except:
646 except Error, exc:
625 print 'EXCEPTION (should be ambiguous argument): ' + sys.exc_value
647 print 'EXCEPTION (should be ambiguous argument): %s' % exc
626
648
627 x = DPyGetOpt(['foo'], ['antigravity', 'antithesis'])
649 x = DPyGetOpt(['foo'], ['antigravity', 'antithesis'])
628 try:
650 try:
629 x.processArguments(['-foo', 'anti'])
651 x.processArguments(['-foo', 'anti'])
630 except:
652 except Error, exc:
631 print 'EXCEPTION (should be ambiguous terminator): ' + sys.exc_value
653 print 'EXCEPTION (should be ambiguous terminator): %s' % exc
632
654
633 profile = ['plain-option',
655 profile = ['plain-option',
634 'boolean-option!',
656 'boolean-option!',
635 'list-of-integers=i@',
657 'list-of-integers=i@',
636 'list-real-option|list-real-alias|list-real-pseudonym=f@',
658 'list-real-option|list-real-alias|list-real-pseudonym=f@',
637 'optional-string-option:s',
659 'optional-string-option:s',
638 'abbreviated-string-list=s@']
660 'abbreviated-string-list=s@']
639
661
640 terminators = ['terminator']
662 terminators = ['terminator']
641
663
642 args = ['-plain-option',
664 args = ['-plain-option',
643 '+noboolean-option',
665 '+noboolean-option',
644 '--list-of-integers', '1',
666 '--list-of-integers', '1',
645 '+list-of-integers', '2',
667 '+list-of-integers', '2',
646 '-list-of-integers', '3',
668 '-list-of-integers', '3',
647 'freeargone',
669 'freeargone',
648 '-list-real-option', '1.1',
670 '-list-real-option', '1.1',
649 '+list-real-alias', '1.2',
671 '+list-real-alias', '1.2',
650 '--list-real-pseudonym', '1.3',
672 '--list-real-pseudonym', '1.3',
651 'freeargtwo',
673 'freeargtwo',
652 '-abbreviated-string-list', 'String1',
674 '-abbreviated-string-list', 'String1',
653 '--abbreviated-s', 'String2',
675 '--abbreviated-s', 'String2',
654 '-abbrev', 'String3',
676 '-abbrev', 'String3',
655 '-a', 'String4',
677 '-a', 'String4',
656 '-optional-string-option',
678 '-optional-string-option',
657 'term',
679 'term',
658 'next option should look like an invalid arg',
680 'next option should look like an invalid arg',
659 '-a']
681 '-a']
660
682
661
683
662 print 'Using profile: ' + repr(profile)
684 print 'Using profile: ' + repr(profile)
663 print 'With terminator: ' + repr(terminators)
685 print 'With terminator: ' + repr(terminators)
664 print 'Processing arguments: ' + repr(args)
686 print 'Processing arguments: ' + repr(args)
665
687
666 go = DPyGetOpt(profile, terminators)
688 go = DPyGetOpt(profile, terminators)
667 go.processArguments(args)
689 go.processArguments(args)
668
690
669 print 'Options (and values): ' + repr(go.optionValues)
691 print 'Options (and values): ' + repr(go.optionValues)
670 print 'free args: ' + repr(go.freeValues)
692 print 'free args: ' + repr(go.freeValues)
671 print 'term args: ' + repr(go.termValues)
693 print 'term args: ' + repr(go.termValues)
@@ -1,3264 +1,3265 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 2841 2007-10-10 00:17:26Z fperez $"""
4 $Id: Magic.py 2872 2007-11-25 17:58:05Z fperez $"""
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 from IPython.ipapi import UsageError
63 from IPython.ipapi import UsageError
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 UsageError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
352 raise UsageError('%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
479
480 def magic_automagic(self, parameter_s = ''):
480 def magic_automagic(self, parameter_s = ''):
481 """Make magic functions callable without having to type the initial %.
481 """Make magic functions callable without having to type the initial %.
482
482
483 Without argumentsl toggles on/off (when off, you must call it as
483 Without argumentsl toggles on/off (when off, you must call it as
484 %automagic, of course). With arguments it sets the value, and you can
484 %automagic, of course). With arguments it sets the value, and you can
485 use any of (case insensitive):
485 use any of (case insensitive):
486
486
487 - on,1,True: to activate
487 - on,1,True: to activate
488
488
489 - off,0,False: to deactivate.
489 - off,0,False: to deactivate.
490
490
491 Note that magic functions have lowest priority, so if there's a
491 Note that magic functions have lowest priority, so if there's a
492 variable whose name collides with that of a magic fn, automagic won't
492 variable whose name collides with that of a magic fn, automagic won't
493 work for that function (you get the variable instead). However, if you
493 work for that function (you get the variable instead). However, if you
494 delete the variable (del var), the previously shadowed magic function
494 delete the variable (del var), the previously shadowed magic function
495 becomes visible to automagic again."""
495 becomes visible to automagic again."""
496
496
497 rc = self.shell.rc
497 rc = self.shell.rc
498 arg = parameter_s.lower()
498 arg = parameter_s.lower()
499 if parameter_s in ('on','1','true'):
499 if parameter_s in ('on','1','true'):
500 rc.automagic = True
500 rc.automagic = True
501 elif parameter_s in ('off','0','false'):
501 elif parameter_s in ('off','0','false'):
502 rc.automagic = False
502 rc.automagic = False
503 else:
503 else:
504 rc.automagic = not rc.automagic
504 rc.automagic = not rc.automagic
505 print '\n' + Magic.auto_status[rc.automagic]
505 print '\n' + Magic.auto_status[rc.automagic]
506
506
507
507
508 def magic_autocall(self, parameter_s = ''):
508 def magic_autocall(self, parameter_s = ''):
509 """Make functions callable without having to type parentheses.
509 """Make functions callable without having to type parentheses.
510
510
511 Usage:
511 Usage:
512
512
513 %autocall [mode]
513 %autocall [mode]
514
514
515 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
515 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
516 value is toggled on and off (remembering the previous state).
516 value is toggled on and off (remembering the previous state).
517
517
518 In more detail, these values mean:
518 In more detail, these values mean:
519
519
520 0 -> fully disabled
520 0 -> fully disabled
521
521
522 1 -> active, but do not apply if there are no arguments on the line.
522 1 -> active, but do not apply if there are no arguments on the line.
523
523
524 In this mode, you get:
524 In this mode, you get:
525
525
526 In [1]: callable
526 In [1]: callable
527 Out[1]: <built-in function callable>
527 Out[1]: <built-in function callable>
528
528
529 In [2]: callable 'hello'
529 In [2]: callable 'hello'
530 ------> callable('hello')
530 ------> callable('hello')
531 Out[2]: False
531 Out[2]: False
532
532
533 2 -> Active always. Even if no arguments are present, the callable
533 2 -> Active always. Even if no arguments are present, the callable
534 object is called:
534 object is called:
535
535
536 In [4]: callable
536 In [4]: callable
537 ------> callable()
537 ------> callable()
538
538
539 Note that even with autocall off, you can still use '/' at the start of
539 Note that even with autocall off, you can still use '/' at the start of
540 a line to treat the first argument on the command line as a function
540 a line to treat the first argument on the command line as a function
541 and add parentheses to it:
541 and add parentheses to it:
542
542
543 In [8]: /str 43
543 In [8]: /str 43
544 ------> str(43)
544 ------> str(43)
545 Out[8]: '43'
545 Out[8]: '43'
546 """
546 """
547
547
548 rc = self.shell.rc
548 rc = self.shell.rc
549
549
550 if parameter_s:
550 if parameter_s:
551 arg = int(parameter_s)
551 arg = int(parameter_s)
552 else:
552 else:
553 arg = 'toggle'
553 arg = 'toggle'
554
554
555 if not arg in (0,1,2,'toggle'):
555 if not arg in (0,1,2,'toggle'):
556 error('Valid modes: (0->Off, 1->Smart, 2->Full')
556 error('Valid modes: (0->Off, 1->Smart, 2->Full')
557 return
557 return
558
558
559 if arg in (0,1,2):
559 if arg in (0,1,2):
560 rc.autocall = arg
560 rc.autocall = arg
561 else: # toggle
561 else: # toggle
562 if rc.autocall:
562 if rc.autocall:
563 self._magic_state.autocall_save = rc.autocall
563 self._magic_state.autocall_save = rc.autocall
564 rc.autocall = 0
564 rc.autocall = 0
565 else:
565 else:
566 try:
566 try:
567 rc.autocall = self._magic_state.autocall_save
567 rc.autocall = self._magic_state.autocall_save
568 except AttributeError:
568 except AttributeError:
569 rc.autocall = self._magic_state.autocall_save = 1
569 rc.autocall = self._magic_state.autocall_save = 1
570
570
571 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
571 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
572
572
573 def magic_system_verbose(self, parameter_s = ''):
573 def magic_system_verbose(self, parameter_s = ''):
574 """Set verbose printing of system calls.
574 """Set verbose printing of system calls.
575
575
576 If called without an argument, act as a toggle"""
576 If called without an argument, act as a toggle"""
577
577
578 if parameter_s:
578 if parameter_s:
579 val = bool(eval(parameter_s))
579 val = bool(eval(parameter_s))
580 else:
580 else:
581 val = None
581 val = None
582
582
583 self.shell.rc_set_toggle('system_verbose',val)
583 self.shell.rc_set_toggle('system_verbose',val)
584 print "System verbose printing is:",\
584 print "System verbose printing is:",\
585 ['OFF','ON'][self.shell.rc.system_verbose]
585 ['OFF','ON'][self.shell.rc.system_verbose]
586
586
587
587
588 def magic_page(self, parameter_s=''):
588 def magic_page(self, parameter_s=''):
589 """Pretty print the object and display it through a pager.
589 """Pretty print the object and display it through a pager.
590
590
591 %page [options] OBJECT
591 %page [options] OBJECT
592
592
593 If no object is given, use _ (last output).
593 If no object is given, use _ (last output).
594
594
595 Options:
595 Options:
596
596
597 -r: page str(object), don't pretty-print it."""
597 -r: page str(object), don't pretty-print it."""
598
598
599 # After a function contributed by Olivier Aubert, slightly modified.
599 # After a function contributed by Olivier Aubert, slightly modified.
600
600
601 # Process options/args
601 # Process options/args
602 opts,args = self.parse_options(parameter_s,'r')
602 opts,args = self.parse_options(parameter_s,'r')
603 raw = 'r' in opts
603 raw = 'r' in opts
604
604
605 oname = args and args or '_'
605 oname = args and args or '_'
606 info = self._ofind(oname)
606 info = self._ofind(oname)
607 if info['found']:
607 if info['found']:
608 txt = (raw and str or pformat)( info['obj'] )
608 txt = (raw and str or pformat)( info['obj'] )
609 page(txt)
609 page(txt)
610 else:
610 else:
611 print 'Object `%s` not found' % oname
611 print 'Object `%s` not found' % oname
612
612
613 def magic_profile(self, parameter_s=''):
613 def magic_profile(self, parameter_s=''):
614 """Print your currently active IPyhton profile."""
614 """Print your currently active IPyhton profile."""
615 if self.shell.rc.profile:
615 if self.shell.rc.profile:
616 printpl('Current IPython profile: $self.shell.rc.profile.')
616 printpl('Current IPython profile: $self.shell.rc.profile.')
617 else:
617 else:
618 print 'No profile active.'
618 print 'No profile active.'
619
619
620 def magic_pinfo(self, parameter_s='', namespaces=None):
620 def magic_pinfo(self, parameter_s='', namespaces=None):
621 """Provide detailed information about an object.
621 """Provide detailed information about an object.
622
622
623 '%pinfo object' is just a synonym for object? or ?object."""
623 '%pinfo object' is just a synonym for object? or ?object."""
624
624
625 #print 'pinfo par: <%s>' % parameter_s # dbg
625 #print 'pinfo par: <%s>' % parameter_s # dbg
626
626
627
627
628 # detail_level: 0 -> obj? , 1 -> obj??
628 # detail_level: 0 -> obj? , 1 -> obj??
629 detail_level = 0
629 detail_level = 0
630 # We need to detect if we got called as 'pinfo pinfo foo', which can
630 # We need to detect if we got called as 'pinfo pinfo foo', which can
631 # happen if the user types 'pinfo foo?' at the cmd line.
631 # happen if the user types 'pinfo foo?' at the cmd line.
632 pinfo,qmark1,oname,qmark2 = \
632 pinfo,qmark1,oname,qmark2 = \
633 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
633 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
634 if pinfo or qmark1 or qmark2:
634 if pinfo or qmark1 or qmark2:
635 detail_level = 1
635 detail_level = 1
636 if "*" in oname:
636 if "*" in oname:
637 self.magic_psearch(oname)
637 self.magic_psearch(oname)
638 else:
638 else:
639 self._inspect('pinfo', oname, detail_level=detail_level,
639 self._inspect('pinfo', oname, detail_level=detail_level,
640 namespaces=namespaces)
640 namespaces=namespaces)
641
641
642 def magic_pdef(self, parameter_s='', namespaces=None):
642 def magic_pdef(self, parameter_s='', namespaces=None):
643 """Print the definition header for any callable object.
643 """Print the definition header for any callable object.
644
644
645 If the object is a class, print the constructor information."""
645 If the object is a class, print the constructor information."""
646 self._inspect('pdef',parameter_s, namespaces)
646 self._inspect('pdef',parameter_s, namespaces)
647
647
648 def magic_pdoc(self, parameter_s='', namespaces=None):
648 def magic_pdoc(self, parameter_s='', namespaces=None):
649 """Print the docstring for an object.
649 """Print the docstring for an object.
650
650
651 If the given object is a class, it will print both the class and the
651 If the given object is a class, it will print both the class and the
652 constructor docstrings."""
652 constructor docstrings."""
653 self._inspect('pdoc',parameter_s, namespaces)
653 self._inspect('pdoc',parameter_s, namespaces)
654
654
655 def magic_psource(self, parameter_s='', namespaces=None):
655 def magic_psource(self, parameter_s='', namespaces=None):
656 """Print (or run through pager) the source code for an object."""
656 """Print (or run through pager) the source code for an object."""
657 self._inspect('psource',parameter_s, namespaces)
657 self._inspect('psource',parameter_s, namespaces)
658
658
659 def magic_pfile(self, parameter_s=''):
659 def magic_pfile(self, parameter_s=''):
660 """Print (or run through pager) the file where an object is defined.
660 """Print (or run through pager) the file where an object is defined.
661
661
662 The file opens at the line where the object definition begins. IPython
662 The file opens at the line where the object definition begins. IPython
663 will honor the environment variable PAGER if set, and otherwise will
663 will honor the environment variable PAGER if set, and otherwise will
664 do its best to print the file in a convenient form.
664 do its best to print the file in a convenient form.
665
665
666 If the given argument is not an object currently defined, IPython will
666 If the given argument is not an object currently defined, IPython will
667 try to interpret it as a filename (automatically adding a .py extension
667 try to interpret it as a filename (automatically adding a .py extension
668 if needed). You can thus use %pfile as a syntax highlighting code
668 if needed). You can thus use %pfile as a syntax highlighting code
669 viewer."""
669 viewer."""
670
670
671 # first interpret argument as an object name
671 # first interpret argument as an object name
672 out = self._inspect('pfile',parameter_s)
672 out = self._inspect('pfile',parameter_s)
673 # if not, try the input as a filename
673 # if not, try the input as a filename
674 if out == 'not found':
674 if out == 'not found':
675 try:
675 try:
676 filename = get_py_filename(parameter_s)
676 filename = get_py_filename(parameter_s)
677 except IOError,msg:
677 except IOError,msg:
678 print msg
678 print msg
679 return
679 return
680 page(self.shell.inspector.format(file(filename).read()))
680 page(self.shell.inspector.format(file(filename).read()))
681
681
682 def _inspect(self,meth,oname,namespaces=None,**kw):
682 def _inspect(self,meth,oname,namespaces=None,**kw):
683 """Generic interface to the inspector system.
683 """Generic interface to the inspector system.
684
684
685 This function is meant to be called by pdef, pdoc & friends."""
685 This function is meant to be called by pdef, pdoc & friends."""
686
686
687 #oname = oname.strip()
687 #oname = oname.strip()
688 #print '1- oname: <%r>' % oname # dbg
688 #print '1- oname: <%r>' % oname # dbg
689 try:
689 try:
690 oname = oname.strip().encode('ascii')
690 oname = oname.strip().encode('ascii')
691 #print '2- oname: <%r>' % oname # dbg
691 #print '2- oname: <%r>' % oname # dbg
692 except UnicodeEncodeError:
692 except UnicodeEncodeError:
693 print 'Python identifiers can only contain ascii characters.'
693 print 'Python identifiers can only contain ascii characters.'
694 return 'not found'
694 return 'not found'
695
695
696 info = Struct(self._ofind(oname, namespaces))
696 info = Struct(self._ofind(oname, namespaces))
697
697
698 if info.found:
698 if info.found:
699 try:
699 try:
700 IPython.generics.inspect_object(info.obj)
700 IPython.generics.inspect_object(info.obj)
701 return
701 return
702 except IPython.ipapi.TryNext:
702 except IPython.ipapi.TryNext:
703 pass
703 pass
704 # Get the docstring of the class property if it exists.
704 # Get the docstring of the class property if it exists.
705 path = oname.split('.')
705 path = oname.split('.')
706 root = '.'.join(path[:-1])
706 root = '.'.join(path[:-1])
707 if info.parent is not None:
707 if info.parent is not None:
708 try:
708 try:
709 target = getattr(info.parent, '__class__')
709 target = getattr(info.parent, '__class__')
710 # The object belongs to a class instance.
710 # The object belongs to a class instance.
711 try:
711 try:
712 target = getattr(target, path[-1])
712 target = getattr(target, path[-1])
713 # The class defines the object.
713 # The class defines the object.
714 if isinstance(target, property):
714 if isinstance(target, property):
715 oname = root + '.__class__.' + path[-1]
715 oname = root + '.__class__.' + path[-1]
716 info = Struct(self._ofind(oname))
716 info = Struct(self._ofind(oname))
717 except AttributeError: pass
717 except AttributeError: pass
718 except AttributeError: pass
718 except AttributeError: pass
719
719
720 pmethod = getattr(self.shell.inspector,meth)
720 pmethod = getattr(self.shell.inspector,meth)
721 formatter = info.ismagic and self.format_screen or None
721 formatter = info.ismagic and self.format_screen or None
722 if meth == 'pdoc':
722 if meth == 'pdoc':
723 pmethod(info.obj,oname,formatter)
723 pmethod(info.obj,oname,formatter)
724 elif meth == 'pinfo':
724 elif meth == 'pinfo':
725 pmethod(info.obj,oname,formatter,info,**kw)
725 pmethod(info.obj,oname,formatter,info,**kw)
726 else:
726 else:
727 pmethod(info.obj,oname)
727 pmethod(info.obj,oname)
728 else:
728 else:
729 print 'Object `%s` not found.' % oname
729 print 'Object `%s` not found.' % oname
730 return 'not found' # so callers can take other action
730 return 'not found' # so callers can take other action
731
731
732 def magic_psearch(self, parameter_s=''):
732 def magic_psearch(self, parameter_s=''):
733 """Search for object in namespaces by wildcard.
733 """Search for object in namespaces by wildcard.
734
734
735 %psearch [options] PATTERN [OBJECT TYPE]
735 %psearch [options] PATTERN [OBJECT TYPE]
736
736
737 Note: ? can be used as a synonym for %psearch, at the beginning or at
737 Note: ? can be used as a synonym for %psearch, at the beginning or at
738 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
738 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
739 rest of the command line must be unchanged (options come first), so
739 rest of the command line must be unchanged (options come first), so
740 for example the following forms are equivalent
740 for example the following forms are equivalent
741
741
742 %psearch -i a* function
742 %psearch -i a* function
743 -i a* function?
743 -i a* function?
744 ?-i a* function
744 ?-i a* function
745
745
746 Arguments:
746 Arguments:
747
747
748 PATTERN
748 PATTERN
749
749
750 where PATTERN is a string containing * as a wildcard similar to its
750 where PATTERN is a string containing * as a wildcard similar to its
751 use in a shell. The pattern is matched in all namespaces on the
751 use in a shell. The pattern is matched in all namespaces on the
752 search path. By default objects starting with a single _ are not
752 search path. By default objects starting with a single _ are not
753 matched, many IPython generated objects have a single
753 matched, many IPython generated objects have a single
754 underscore. The default is case insensitive matching. Matching is
754 underscore. The default is case insensitive matching. Matching is
755 also done on the attributes of objects and not only on the objects
755 also done on the attributes of objects and not only on the objects
756 in a module.
756 in a module.
757
757
758 [OBJECT TYPE]
758 [OBJECT TYPE]
759
759
760 Is the name of a python type from the types module. The name is
760 Is the name of a python type from the types module. The name is
761 given in lowercase without the ending type, ex. StringType is
761 given in lowercase without the ending type, ex. StringType is
762 written string. By adding a type here only objects matching the
762 written string. By adding a type here only objects matching the
763 given type are matched. Using all here makes the pattern match all
763 given type are matched. Using all here makes the pattern match all
764 types (this is the default).
764 types (this is the default).
765
765
766 Options:
766 Options:
767
767
768 -a: makes the pattern match even objects whose names start with a
768 -a: makes the pattern match even objects whose names start with a
769 single underscore. These names are normally ommitted from the
769 single underscore. These names are normally ommitted from the
770 search.
770 search.
771
771
772 -i/-c: make the pattern case insensitive/sensitive. If neither of
772 -i/-c: make the pattern case insensitive/sensitive. If neither of
773 these options is given, the default is read from your ipythonrc
773 these options is given, the default is read from your ipythonrc
774 file. The option name which sets this value is
774 file. The option name which sets this value is
775 'wildcards_case_sensitive'. If this option is not specified in your
775 'wildcards_case_sensitive'. If this option is not specified in your
776 ipythonrc file, IPython's internal default is to do a case sensitive
776 ipythonrc file, IPython's internal default is to do a case sensitive
777 search.
777 search.
778
778
779 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
779 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
780 specifiy can be searched in any of the following namespaces:
780 specifiy can be searched in any of the following namespaces:
781 'builtin', 'user', 'user_global','internal', 'alias', where
781 'builtin', 'user', 'user_global','internal', 'alias', where
782 'builtin' and 'user' are the search defaults. Note that you should
782 'builtin' and 'user' are the search defaults. Note that you should
783 not use quotes when specifying namespaces.
783 not use quotes when specifying namespaces.
784
784
785 'Builtin' contains the python module builtin, 'user' contains all
785 'Builtin' contains the python module builtin, 'user' contains all
786 user data, 'alias' only contain the shell aliases and no python
786 user data, 'alias' only contain the shell aliases and no python
787 objects, 'internal' contains objects used by IPython. The
787 objects, 'internal' contains objects used by IPython. The
788 'user_global' namespace is only used by embedded IPython instances,
788 'user_global' namespace is only used by embedded IPython instances,
789 and it contains module-level globals. You can add namespaces to the
789 and it contains module-level globals. You can add namespaces to the
790 search with -s or exclude them with -e (these options can be given
790 search with -s or exclude them with -e (these options can be given
791 more than once).
791 more than once).
792
792
793 Examples:
793 Examples:
794
794
795 %psearch a* -> objects beginning with an a
795 %psearch a* -> objects beginning with an a
796 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
796 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
797 %psearch a* function -> all functions beginning with an a
797 %psearch a* function -> all functions beginning with an a
798 %psearch re.e* -> objects beginning with an e in module re
798 %psearch re.e* -> objects beginning with an e in module re
799 %psearch r*.e* -> objects that start with e in modules starting in r
799 %psearch r*.e* -> objects that start with e in modules starting in r
800 %psearch r*.* string -> all strings in modules beginning with r
800 %psearch r*.* string -> all strings in modules beginning with r
801
801
802 Case sensitve search:
802 Case sensitve search:
803
803
804 %psearch -c a* list all object beginning with lower case a
804 %psearch -c a* list all object beginning with lower case a
805
805
806 Show objects beginning with a single _:
806 Show objects beginning with a single _:
807
807
808 %psearch -a _* list objects beginning with a single underscore"""
808 %psearch -a _* list objects beginning with a single underscore"""
809 try:
809 try:
810 parameter_s = parameter_s.encode('ascii')
810 parameter_s = parameter_s.encode('ascii')
811 except UnicodeEncodeError:
811 except UnicodeEncodeError:
812 print 'Python identifiers can only contain ascii characters.'
812 print 'Python identifiers can only contain ascii characters.'
813 return
813 return
814
814
815 # default namespaces to be searched
815 # default namespaces to be searched
816 def_search = ['user','builtin']
816 def_search = ['user','builtin']
817
817
818 # Process options/args
818 # Process options/args
819 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
819 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
820 opt = opts.get
820 opt = opts.get
821 shell = self.shell
821 shell = self.shell
822 psearch = shell.inspector.psearch
822 psearch = shell.inspector.psearch
823
823
824 # select case options
824 # select case options
825 if opts.has_key('i'):
825 if opts.has_key('i'):
826 ignore_case = True
826 ignore_case = True
827 elif opts.has_key('c'):
827 elif opts.has_key('c'):
828 ignore_case = False
828 ignore_case = False
829 else:
829 else:
830 ignore_case = not shell.rc.wildcards_case_sensitive
830 ignore_case = not shell.rc.wildcards_case_sensitive
831
831
832 # Build list of namespaces to search from user options
832 # Build list of namespaces to search from user options
833 def_search.extend(opt('s',[]))
833 def_search.extend(opt('s',[]))
834 ns_exclude = ns_exclude=opt('e',[])
834 ns_exclude = ns_exclude=opt('e',[])
835 ns_search = [nm for nm in def_search if nm not in ns_exclude]
835 ns_search = [nm for nm in def_search if nm not in ns_exclude]
836
836
837 # Call the actual search
837 # Call the actual search
838 try:
838 try:
839 psearch(args,shell.ns_table,ns_search,
839 psearch(args,shell.ns_table,ns_search,
840 show_all=opt('a'),ignore_case=ignore_case)
840 show_all=opt('a'),ignore_case=ignore_case)
841 except:
841 except:
842 shell.showtraceback()
842 shell.showtraceback()
843
843
844 def magic_who_ls(self, parameter_s=''):
844 def magic_who_ls(self, parameter_s=''):
845 """Return a sorted list of all interactive variables.
845 """Return a sorted list of all interactive variables.
846
846
847 If arguments are given, only variables of types matching these
847 If arguments are given, only variables of types matching these
848 arguments are returned."""
848 arguments are returned."""
849
849
850 user_ns = self.shell.user_ns
850 user_ns = self.shell.user_ns
851 internal_ns = self.shell.internal_ns
851 internal_ns = self.shell.internal_ns
852 user_config_ns = self.shell.user_config_ns
852 user_config_ns = self.shell.user_config_ns
853 out = []
853 out = []
854 typelist = parameter_s.split()
854 typelist = parameter_s.split()
855
855
856 for i in user_ns:
856 for i in user_ns:
857 if not (i.startswith('_') or i.startswith('_i')) \
857 if not (i.startswith('_') or i.startswith('_i')) \
858 and not (i in internal_ns or i in user_config_ns):
858 and not (i in internal_ns or i in user_config_ns):
859 if typelist:
859 if typelist:
860 if type(user_ns[i]).__name__ in typelist:
860 if type(user_ns[i]).__name__ in typelist:
861 out.append(i)
861 out.append(i)
862 else:
862 else:
863 out.append(i)
863 out.append(i)
864 out.sort()
864 out.sort()
865 return out
865 return out
866
866
867 def magic_who(self, parameter_s=''):
867 def magic_who(self, parameter_s=''):
868 """Print all interactive variables, with some minimal formatting.
868 """Print all interactive variables, with some minimal formatting.
869
869
870 If any arguments are given, only variables whose type matches one of
870 If any arguments are given, only variables whose type matches one of
871 these are printed. For example:
871 these are printed. For example:
872
872
873 %who function str
873 %who function str
874
874
875 will only list functions and strings, excluding all other types of
875 will only list functions and strings, excluding all other types of
876 variables. To find the proper type names, simply use type(var) at a
876 variables. To find the proper type names, simply use type(var) at a
877 command line to see how python prints type names. For example:
877 command line to see how python prints type names. For example:
878
878
879 In [1]: type('hello')\\
879 In [1]: type('hello')\\
880 Out[1]: <type 'str'>
880 Out[1]: <type 'str'>
881
881
882 indicates that the type name for strings is 'str'.
882 indicates that the type name for strings is 'str'.
883
883
884 %who always excludes executed names loaded through your configuration
884 %who always excludes executed names loaded through your configuration
885 file and things which are internal to IPython.
885 file and things which are internal to IPython.
886
886
887 This is deliberate, as typically you may load many modules and the
887 This is deliberate, as typically you may load many modules and the
888 purpose of %who is to show you only what you've manually defined."""
888 purpose of %who is to show you only what you've manually defined."""
889
889
890 varlist = self.magic_who_ls(parameter_s)
890 varlist = self.magic_who_ls(parameter_s)
891 if not varlist:
891 if not varlist:
892 if parameter_s:
892 if parameter_s:
893 print 'No variables match your requested type.'
893 print 'No variables match your requested type.'
894 else:
894 else:
895 print 'Interactive namespace is empty.'
895 print 'Interactive namespace is empty.'
896 return
896 return
897
897
898 # if we have variables, move on...
898 # if we have variables, move on...
899 count = 0
899 count = 0
900 for i in varlist:
900 for i in varlist:
901 print i+'\t',
901 print i+'\t',
902 count += 1
902 count += 1
903 if count > 8:
903 if count > 8:
904 count = 0
904 count = 0
905 print
905 print
906 print
906 print
907
907
908 def magic_whos(self, parameter_s=''):
908 def magic_whos(self, parameter_s=''):
909 """Like %who, but gives some extra information about each variable.
909 """Like %who, but gives some extra information about each variable.
910
910
911 The same type filtering of %who can be applied here.
911 The same type filtering of %who can be applied here.
912
912
913 For all variables, the type is printed. Additionally it prints:
913 For all variables, the type is printed. Additionally it prints:
914
914
915 - For {},[],(): their length.
915 - For {},[],(): their length.
916
916
917 - For numpy and Numeric arrays, a summary with shape, number of
917 - For numpy and Numeric arrays, a summary with shape, number of
918 elements, typecode and size in memory.
918 elements, typecode and size in memory.
919
919
920 - Everything else: a string representation, snipping their middle if
920 - Everything else: a string representation, snipping their middle if
921 too long."""
921 too long."""
922
922
923 varnames = self.magic_who_ls(parameter_s)
923 varnames = self.magic_who_ls(parameter_s)
924 if not varnames:
924 if not varnames:
925 if parameter_s:
925 if parameter_s:
926 print 'No variables match your requested type.'
926 print 'No variables match your requested type.'
927 else:
927 else:
928 print 'Interactive namespace is empty.'
928 print 'Interactive namespace is empty.'
929 return
929 return
930
930
931 # if we have variables, move on...
931 # if we have variables, move on...
932
932
933 # for these types, show len() instead of data:
933 # for these types, show len() instead of data:
934 seq_types = [types.DictType,types.ListType,types.TupleType]
934 seq_types = [types.DictType,types.ListType,types.TupleType]
935
935
936 # for numpy/Numeric arrays, display summary info
936 # for numpy/Numeric arrays, display summary info
937 try:
937 try:
938 import numpy
938 import numpy
939 except ImportError:
939 except ImportError:
940 ndarray_type = None
940 ndarray_type = None
941 else:
941 else:
942 ndarray_type = numpy.ndarray.__name__
942 ndarray_type = numpy.ndarray.__name__
943 try:
943 try:
944 import Numeric
944 import Numeric
945 except ImportError:
945 except ImportError:
946 array_type = None
946 array_type = None
947 else:
947 else:
948 array_type = Numeric.ArrayType.__name__
948 array_type = Numeric.ArrayType.__name__
949
949
950 # Find all variable names and types so we can figure out column sizes
950 # Find all variable names and types so we can figure out column sizes
951 def get_vars(i):
951 def get_vars(i):
952 return self.shell.user_ns[i]
952 return self.shell.user_ns[i]
953
953
954 # some types are well known and can be shorter
954 # some types are well known and can be shorter
955 abbrevs = {'IPython.macro.Macro' : 'Macro'}
955 abbrevs = {'IPython.macro.Macro' : 'Macro'}
956 def type_name(v):
956 def type_name(v):
957 tn = type(v).__name__
957 tn = type(v).__name__
958 return abbrevs.get(tn,tn)
958 return abbrevs.get(tn,tn)
959
959
960 varlist = map(get_vars,varnames)
960 varlist = map(get_vars,varnames)
961
961
962 typelist = []
962 typelist = []
963 for vv in varlist:
963 for vv in varlist:
964 tt = type_name(vv)
964 tt = type_name(vv)
965
965
966 if tt=='instance':
966 if tt=='instance':
967 typelist.append( abbrevs.get(str(vv.__class__),
967 typelist.append( abbrevs.get(str(vv.__class__),
968 str(vv.__class__)))
968 str(vv.__class__)))
969 else:
969 else:
970 typelist.append(tt)
970 typelist.append(tt)
971
971
972 # column labels and # of spaces as separator
972 # column labels and # of spaces as separator
973 varlabel = 'Variable'
973 varlabel = 'Variable'
974 typelabel = 'Type'
974 typelabel = 'Type'
975 datalabel = 'Data/Info'
975 datalabel = 'Data/Info'
976 colsep = 3
976 colsep = 3
977 # variable format strings
977 # variable format strings
978 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
978 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
979 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
979 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
980 aformat = "%s: %s elems, type `%s`, %s bytes"
980 aformat = "%s: %s elems, type `%s`, %s bytes"
981 # find the size of the columns to format the output nicely
981 # find the size of the columns to format the output nicely
982 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
982 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
983 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
983 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
984 # table header
984 # table header
985 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
985 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
986 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
986 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
987 # and the table itself
987 # and the table itself
988 kb = 1024
988 kb = 1024
989 Mb = 1048576 # kb**2
989 Mb = 1048576 # kb**2
990 for vname,var,vtype in zip(varnames,varlist,typelist):
990 for vname,var,vtype in zip(varnames,varlist,typelist):
991 print itpl(vformat),
991 print itpl(vformat),
992 if vtype in seq_types:
992 if vtype in seq_types:
993 print len(var)
993 print len(var)
994 elif vtype in [array_type,ndarray_type]:
994 elif vtype in [array_type,ndarray_type]:
995 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
995 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
996 if vtype==ndarray_type:
996 if vtype==ndarray_type:
997 # numpy
997 # numpy
998 vsize = var.size
998 vsize = var.size
999 vbytes = vsize*var.itemsize
999 vbytes = vsize*var.itemsize
1000 vdtype = var.dtype
1000 vdtype = var.dtype
1001 else:
1001 else:
1002 # Numeric
1002 # Numeric
1003 vsize = Numeric.size(var)
1003 vsize = Numeric.size(var)
1004 vbytes = vsize*var.itemsize()
1004 vbytes = vsize*var.itemsize()
1005 vdtype = var.typecode()
1005 vdtype = var.typecode()
1006
1006
1007 if vbytes < 100000:
1007 if vbytes < 100000:
1008 print aformat % (vshape,vsize,vdtype,vbytes)
1008 print aformat % (vshape,vsize,vdtype,vbytes)
1009 else:
1009 else:
1010 print aformat % (vshape,vsize,vdtype,vbytes),
1010 print aformat % (vshape,vsize,vdtype,vbytes),
1011 if vbytes < Mb:
1011 if vbytes < Mb:
1012 print '(%s kb)' % (vbytes/kb,)
1012 print '(%s kb)' % (vbytes/kb,)
1013 else:
1013 else:
1014 print '(%s Mb)' % (vbytes/Mb,)
1014 print '(%s Mb)' % (vbytes/Mb,)
1015 else:
1015 else:
1016 try:
1016 try:
1017 vstr = str(var)
1017 vstr = str(var)
1018 except UnicodeEncodeError:
1018 except UnicodeEncodeError:
1019 vstr = unicode(var).encode(sys.getdefaultencoding(),
1019 vstr = unicode(var).encode(sys.getdefaultencoding(),
1020 'backslashreplace')
1020 'backslashreplace')
1021 vstr = vstr.replace('\n','\\n')
1021 vstr = vstr.replace('\n','\\n')
1022 if len(vstr) < 50:
1022 if len(vstr) < 50:
1023 print vstr
1023 print vstr
1024 else:
1024 else:
1025 printpl(vfmt_short)
1025 printpl(vfmt_short)
1026
1026
1027 def magic_reset(self, parameter_s=''):
1027 def magic_reset(self, parameter_s=''):
1028 """Resets the namespace by removing all names defined by the user.
1028 """Resets the namespace by removing all names defined by the user.
1029
1029
1030 Input/Output history are left around in case you need them."""
1030 Input/Output history are left around in case you need them."""
1031
1031
1032 ans = self.shell.ask_yes_no(
1032 ans = self.shell.ask_yes_no(
1033 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1033 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1034 if not ans:
1034 if not ans:
1035 print 'Nothing done.'
1035 print 'Nothing done.'
1036 return
1036 return
1037 user_ns = self.shell.user_ns
1037 user_ns = self.shell.user_ns
1038 for i in self.magic_who_ls():
1038 for i in self.magic_who_ls():
1039 del(user_ns[i])
1039 del(user_ns[i])
1040
1040
1041 # Also flush the private list of module references kept for script
1041 # Also flush the private list of module references kept for script
1042 # execution protection
1042 # execution protection
1043 self.shell._user_main_modules[:] = []
1043 self.shell._user_main_modules[:] = []
1044
1044
1045 def magic_logstart(self,parameter_s=''):
1045 def magic_logstart(self,parameter_s=''):
1046 """Start logging anywhere in a session.
1046 """Start logging anywhere in a session.
1047
1047
1048 %logstart [-o|-r|-t] [log_name [log_mode]]
1048 %logstart [-o|-r|-t] [log_name [log_mode]]
1049
1049
1050 If no name is given, it defaults to a file named 'ipython_log.py' in your
1050 If no name is given, it defaults to a file named 'ipython_log.py' in your
1051 current directory, in 'rotate' mode (see below).
1051 current directory, in 'rotate' mode (see below).
1052
1052
1053 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1053 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1054 history up to that point and then continues logging.
1054 history up to that point and then continues logging.
1055
1055
1056 %logstart takes a second optional parameter: logging mode. This can be one
1056 %logstart takes a second optional parameter: logging mode. This can be one
1057 of (note that the modes are given unquoted):\\
1057 of (note that the modes are given unquoted):\\
1058 append: well, that says it.\\
1058 append: well, that says it.\\
1059 backup: rename (if exists) to name~ and start name.\\
1059 backup: rename (if exists) to name~ and start name.\\
1060 global: single logfile in your home dir, appended to.\\
1060 global: single logfile in your home dir, appended to.\\
1061 over : overwrite existing log.\\
1061 over : overwrite existing log.\\
1062 rotate: create rotating logs name.1~, name.2~, etc.
1062 rotate: create rotating logs name.1~, name.2~, etc.
1063
1063
1064 Options:
1064 Options:
1065
1065
1066 -o: log also IPython's output. In this mode, all commands which
1066 -o: log also IPython's output. In this mode, all commands which
1067 generate an Out[NN] prompt are recorded to the logfile, right after
1067 generate an Out[NN] prompt are recorded to the logfile, right after
1068 their corresponding input line. The output lines are always
1068 their corresponding input line. The output lines are always
1069 prepended with a '#[Out]# ' marker, so that the log remains valid
1069 prepended with a '#[Out]# ' marker, so that the log remains valid
1070 Python code.
1070 Python code.
1071
1071
1072 Since this marker is always the same, filtering only the output from
1072 Since this marker is always the same, filtering only the output from
1073 a log is very easy, using for example a simple awk call:
1073 a log is very easy, using for example a simple awk call:
1074
1074
1075 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1075 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1076
1076
1077 -r: log 'raw' input. Normally, IPython's logs contain the processed
1077 -r: log 'raw' input. Normally, IPython's logs contain the processed
1078 input, so that user lines are logged in their final form, converted
1078 input, so that user lines are logged in their final form, converted
1079 into valid Python. For example, %Exit is logged as
1079 into valid Python. For example, %Exit is logged as
1080 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1080 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1081 exactly as typed, with no transformations applied.
1081 exactly as typed, with no transformations applied.
1082
1082
1083 -t: put timestamps before each input line logged (these are put in
1083 -t: put timestamps before each input line logged (these are put in
1084 comments)."""
1084 comments)."""
1085
1085
1086 opts,par = self.parse_options(parameter_s,'ort')
1086 opts,par = self.parse_options(parameter_s,'ort')
1087 log_output = 'o' in opts
1087 log_output = 'o' in opts
1088 log_raw_input = 'r' in opts
1088 log_raw_input = 'r' in opts
1089 timestamp = 't' in opts
1089 timestamp = 't' in opts
1090
1090
1091 rc = self.shell.rc
1091 rc = self.shell.rc
1092 logger = self.shell.logger
1092 logger = self.shell.logger
1093
1093
1094 # if no args are given, the defaults set in the logger constructor by
1094 # if no args are given, the defaults set in the logger constructor by
1095 # ipytohn remain valid
1095 # ipytohn remain valid
1096 if par:
1096 if par:
1097 try:
1097 try:
1098 logfname,logmode = par.split()
1098 logfname,logmode = par.split()
1099 except:
1099 except:
1100 logfname = par
1100 logfname = par
1101 logmode = 'backup'
1101 logmode = 'backup'
1102 else:
1102 else:
1103 logfname = logger.logfname
1103 logfname = logger.logfname
1104 logmode = logger.logmode
1104 logmode = logger.logmode
1105 # put logfname into rc struct as if it had been called on the command
1105 # put logfname into rc struct as if it had been called on the command
1106 # line, so it ends up saved in the log header Save it in case we need
1106 # line, so it ends up saved in the log header Save it in case we need
1107 # to restore it...
1107 # to restore it...
1108 old_logfile = rc.opts.get('logfile','')
1108 old_logfile = rc.opts.get('logfile','')
1109 if logfname:
1109 if logfname:
1110 logfname = os.path.expanduser(logfname)
1110 logfname = os.path.expanduser(logfname)
1111 rc.opts.logfile = logfname
1111 rc.opts.logfile = logfname
1112 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1112 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1113 try:
1113 try:
1114 started = logger.logstart(logfname,loghead,logmode,
1114 started = logger.logstart(logfname,loghead,logmode,
1115 log_output,timestamp,log_raw_input)
1115 log_output,timestamp,log_raw_input)
1116 except:
1116 except:
1117 rc.opts.logfile = old_logfile
1117 rc.opts.logfile = old_logfile
1118 warn("Couldn't start log: %s" % sys.exc_info()[1])
1118 warn("Couldn't start log: %s" % sys.exc_info()[1])
1119 else:
1119 else:
1120 # log input history up to this point, optionally interleaving
1120 # log input history up to this point, optionally interleaving
1121 # output if requested
1121 # output if requested
1122
1122
1123 if timestamp:
1123 if timestamp:
1124 # disable timestamping for the previous history, since we've
1124 # disable timestamping for the previous history, since we've
1125 # lost those already (no time machine here).
1125 # lost those already (no time machine here).
1126 logger.timestamp = False
1126 logger.timestamp = False
1127
1127
1128 if log_raw_input:
1128 if log_raw_input:
1129 input_hist = self.shell.input_hist_raw
1129 input_hist = self.shell.input_hist_raw
1130 else:
1130 else:
1131 input_hist = self.shell.input_hist
1131 input_hist = self.shell.input_hist
1132
1132
1133 if log_output:
1133 if log_output:
1134 log_write = logger.log_write
1134 log_write = logger.log_write
1135 output_hist = self.shell.output_hist
1135 output_hist = self.shell.output_hist
1136 for n in range(1,len(input_hist)-1):
1136 for n in range(1,len(input_hist)-1):
1137 log_write(input_hist[n].rstrip())
1137 log_write(input_hist[n].rstrip())
1138 if n in output_hist:
1138 if n in output_hist:
1139 log_write(repr(output_hist[n]),'output')
1139 log_write(repr(output_hist[n]),'output')
1140 else:
1140 else:
1141 logger.log_write(input_hist[1:])
1141 logger.log_write(input_hist[1:])
1142 if timestamp:
1142 if timestamp:
1143 # re-enable timestamping
1143 # re-enable timestamping
1144 logger.timestamp = True
1144 logger.timestamp = True
1145
1145
1146 print ('Activating auto-logging. '
1146 print ('Activating auto-logging. '
1147 'Current session state plus future input saved.')
1147 'Current session state plus future input saved.')
1148 logger.logstate()
1148 logger.logstate()
1149
1149
1150 def magic_logoff(self,parameter_s=''):
1150 def magic_logoff(self,parameter_s=''):
1151 """Temporarily stop logging.
1151 """Temporarily stop logging.
1152
1152
1153 You must have previously started logging."""
1153 You must have previously started logging."""
1154 self.shell.logger.switch_log(0)
1154 self.shell.logger.switch_log(0)
1155
1155
1156 def magic_logon(self,parameter_s=''):
1156 def magic_logon(self,parameter_s=''):
1157 """Restart logging.
1157 """Restart logging.
1158
1158
1159 This function is for restarting logging which you've temporarily
1159 This function is for restarting logging which you've temporarily
1160 stopped with %logoff. For starting logging for the first time, you
1160 stopped with %logoff. For starting logging for the first time, you
1161 must use the %logstart function, which allows you to specify an
1161 must use the %logstart function, which allows you to specify an
1162 optional log filename."""
1162 optional log filename."""
1163
1163
1164 self.shell.logger.switch_log(1)
1164 self.shell.logger.switch_log(1)
1165
1165
1166 def magic_logstate(self,parameter_s=''):
1166 def magic_logstate(self,parameter_s=''):
1167 """Print the status of the logging system."""
1167 """Print the status of the logging system."""
1168
1168
1169 self.shell.logger.logstate()
1169 self.shell.logger.logstate()
1170
1170
1171 def magic_pdb(self, parameter_s=''):
1171 def magic_pdb(self, parameter_s=''):
1172 """Control the automatic calling of the pdb interactive debugger.
1172 """Control the automatic calling of the pdb interactive debugger.
1173
1173
1174 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1174 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1175 argument it works as a toggle.
1175 argument it works as a toggle.
1176
1176
1177 When an exception is triggered, IPython can optionally call the
1177 When an exception is triggered, IPython can optionally call the
1178 interactive pdb debugger after the traceback printout. %pdb toggles
1178 interactive pdb debugger after the traceback printout. %pdb toggles
1179 this feature on and off.
1179 this feature on and off.
1180
1180
1181 The initial state of this feature is set in your ipythonrc
1181 The initial state of this feature is set in your ipythonrc
1182 configuration file (the variable is called 'pdb').
1182 configuration file (the variable is called 'pdb').
1183
1183
1184 If you want to just activate the debugger AFTER an exception has fired,
1184 If you want to just activate the debugger AFTER an exception has fired,
1185 without having to type '%pdb on' and rerunning your code, you can use
1185 without having to type '%pdb on' and rerunning your code, you can use
1186 the %debug magic."""
1186 the %debug magic."""
1187
1187
1188 par = parameter_s.strip().lower()
1188 par = parameter_s.strip().lower()
1189
1189
1190 if par:
1190 if par:
1191 try:
1191 try:
1192 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1192 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1193 except KeyError:
1193 except KeyError:
1194 print ('Incorrect argument. Use on/1, off/0, '
1194 print ('Incorrect argument. Use on/1, off/0, '
1195 'or nothing for a toggle.')
1195 'or nothing for a toggle.')
1196 return
1196 return
1197 else:
1197 else:
1198 # toggle
1198 # toggle
1199 new_pdb = not self.shell.call_pdb
1199 new_pdb = not self.shell.call_pdb
1200
1200
1201 # set on the shell
1201 # set on the shell
1202 self.shell.call_pdb = new_pdb
1202 self.shell.call_pdb = new_pdb
1203 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1203 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1204
1204
1205 def magic_debug(self, parameter_s=''):
1205 def magic_debug(self, parameter_s=''):
1206 """Activate the interactive debugger in post-mortem mode.
1206 """Activate the interactive debugger in post-mortem mode.
1207
1207
1208 If an exception has just occurred, this lets you inspect its stack
1208 If an exception has just occurred, this lets you inspect its stack
1209 frames interactively. Note that this will always work only on the last
1209 frames interactively. Note that this will always work only on the last
1210 traceback that occurred, so you must call this quickly after an
1210 traceback that occurred, so you must call this quickly after an
1211 exception that you wish to inspect has fired, because if another one
1211 exception that you wish to inspect has fired, because if another one
1212 occurs, it clobbers the previous one.
1212 occurs, it clobbers the previous one.
1213
1213
1214 If you want IPython to automatically do this on every exception, see
1214 If you want IPython to automatically do this on every exception, see
1215 the %pdb magic for more details.
1215 the %pdb magic for more details.
1216 """
1216 """
1217
1217
1218 self.shell.debugger(force=True)
1218 self.shell.debugger(force=True)
1219
1219
1220 def magic_prun(self, parameter_s ='',user_mode=1,
1220 def magic_prun(self, parameter_s ='',user_mode=1,
1221 opts=None,arg_lst=None,prog_ns=None):
1221 opts=None,arg_lst=None,prog_ns=None):
1222
1222
1223 """Run a statement through the python code profiler.
1223 """Run a statement through the python code profiler.
1224
1224
1225 Usage:\\
1225 Usage:\\
1226 %prun [options] statement
1226 %prun [options] statement
1227
1227
1228 The given statement (which doesn't require quote marks) is run via the
1228 The given statement (which doesn't require quote marks) is run via the
1229 python profiler in a manner similar to the profile.run() function.
1229 python profiler in a manner similar to the profile.run() function.
1230 Namespaces are internally managed to work correctly; profile.run
1230 Namespaces are internally managed to work correctly; profile.run
1231 cannot be used in IPython because it makes certain assumptions about
1231 cannot be used in IPython because it makes certain assumptions about
1232 namespaces which do not hold under IPython.
1232 namespaces which do not hold under IPython.
1233
1233
1234 Options:
1234 Options:
1235
1235
1236 -l <limit>: you can place restrictions on what or how much of the
1236 -l <limit>: you can place restrictions on what or how much of the
1237 profile gets printed. The limit value can be:
1237 profile gets printed. The limit value can be:
1238
1238
1239 * A string: only information for function names containing this string
1239 * A string: only information for function names containing this string
1240 is printed.
1240 is printed.
1241
1241
1242 * An integer: only these many lines are printed.
1242 * An integer: only these many lines are printed.
1243
1243
1244 * A float (between 0 and 1): this fraction of the report is printed
1244 * A float (between 0 and 1): this fraction of the report is printed
1245 (for example, use a limit of 0.4 to see the topmost 40% only).
1245 (for example, use a limit of 0.4 to see the topmost 40% only).
1246
1246
1247 You can combine several limits with repeated use of the option. For
1247 You can combine several limits with repeated use of the option. For
1248 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1248 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1249 information about class constructors.
1249 information about class constructors.
1250
1250
1251 -r: return the pstats.Stats object generated by the profiling. This
1251 -r: return the pstats.Stats object generated by the profiling. This
1252 object has all the information about the profile in it, and you can
1252 object has all the information about the profile in it, and you can
1253 later use it for further analysis or in other functions.
1253 later use it for further analysis or in other functions.
1254
1254
1255 -s <key>: sort profile by given key. You can provide more than one key
1255 -s <key>: sort profile by given key. You can provide more than one key
1256 by using the option several times: '-s key1 -s key2 -s key3...'. The
1256 by using the option several times: '-s key1 -s key2 -s key3...'. The
1257 default sorting key is 'time'.
1257 default sorting key is 'time'.
1258
1258
1259 The following is copied verbatim from the profile documentation
1259 The following is copied verbatim from the profile documentation
1260 referenced below:
1260 referenced below:
1261
1261
1262 When more than one key is provided, additional keys are used as
1262 When more than one key is provided, additional keys are used as
1263 secondary criteria when the there is equality in all keys selected
1263 secondary criteria when the there is equality in all keys selected
1264 before them.
1264 before them.
1265
1265
1266 Abbreviations can be used for any key names, as long as the
1266 Abbreviations can be used for any key names, as long as the
1267 abbreviation is unambiguous. The following are the keys currently
1267 abbreviation is unambiguous. The following are the keys currently
1268 defined:
1268 defined:
1269
1269
1270 Valid Arg Meaning\\
1270 Valid Arg Meaning\\
1271 "calls" call count\\
1271 "calls" call count\\
1272 "cumulative" cumulative time\\
1272 "cumulative" cumulative time\\
1273 "file" file name\\
1273 "file" file name\\
1274 "module" file name\\
1274 "module" file name\\
1275 "pcalls" primitive call count\\
1275 "pcalls" primitive call count\\
1276 "line" line number\\
1276 "line" line number\\
1277 "name" function name\\
1277 "name" function name\\
1278 "nfl" name/file/line\\
1278 "nfl" name/file/line\\
1279 "stdname" standard name\\
1279 "stdname" standard name\\
1280 "time" internal time
1280 "time" internal time
1281
1281
1282 Note that all sorts on statistics are in descending order (placing
1282 Note that all sorts on statistics are in descending order (placing
1283 most time consuming items first), where as name, file, and line number
1283 most time consuming items first), where as name, file, and line number
1284 searches are in ascending order (i.e., alphabetical). The subtle
1284 searches are in ascending order (i.e., alphabetical). The subtle
1285 distinction between "nfl" and "stdname" is that the standard name is a
1285 distinction between "nfl" and "stdname" is that the standard name is a
1286 sort of the name as printed, which means that the embedded line
1286 sort of the name as printed, which means that the embedded line
1287 numbers get compared in an odd way. For example, lines 3, 20, and 40
1287 numbers get compared in an odd way. For example, lines 3, 20, and 40
1288 would (if the file names were the same) appear in the string order
1288 would (if the file names were the same) appear in the string order
1289 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1289 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1290 line numbers. In fact, sort_stats("nfl") is the same as
1290 line numbers. In fact, sort_stats("nfl") is the same as
1291 sort_stats("name", "file", "line").
1291 sort_stats("name", "file", "line").
1292
1292
1293 -T <filename>: save profile results as shown on screen to a text
1293 -T <filename>: save profile results as shown on screen to a text
1294 file. The profile is still shown on screen.
1294 file. The profile is still shown on screen.
1295
1295
1296 -D <filename>: save (via dump_stats) profile statistics to given
1296 -D <filename>: save (via dump_stats) profile statistics to given
1297 filename. This data is in a format understod by the pstats module, and
1297 filename. This data is in a format understod by the pstats module, and
1298 is generated by a call to the dump_stats() method of profile
1298 is generated by a call to the dump_stats() method of profile
1299 objects. The profile is still shown on screen.
1299 objects. The profile is still shown on screen.
1300
1300
1301 If you want to run complete programs under the profiler's control, use
1301 If you want to run complete programs under the profiler's control, use
1302 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1302 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1303 contains profiler specific options as described here.
1303 contains profiler specific options as described here.
1304
1304
1305 You can read the complete documentation for the profile module with:\\
1305 You can read the complete documentation for the profile module with:\\
1306 In [1]: import profile; profile.help() """
1306 In [1]: import profile; profile.help() """
1307
1307
1308 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1308 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1309 # protect user quote marks
1309 # protect user quote marks
1310 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1310 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1311
1311
1312 if user_mode: # regular user call
1312 if user_mode: # regular user call
1313 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1313 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1314 list_all=1)
1314 list_all=1)
1315 namespace = self.shell.user_ns
1315 namespace = self.shell.user_ns
1316 else: # called to run a program by %run -p
1316 else: # called to run a program by %run -p
1317 try:
1317 try:
1318 filename = get_py_filename(arg_lst[0])
1318 filename = get_py_filename(arg_lst[0])
1319 except IOError,msg:
1319 except IOError,msg:
1320 error(msg)
1320 error(msg)
1321 return
1321 return
1322
1322
1323 arg_str = 'execfile(filename,prog_ns)'
1323 arg_str = 'execfile(filename,prog_ns)'
1324 namespace = locals()
1324 namespace = locals()
1325
1325
1326 opts.merge(opts_def)
1326 opts.merge(opts_def)
1327
1327
1328 prof = profile.Profile()
1328 prof = profile.Profile()
1329 try:
1329 try:
1330 prof = prof.runctx(arg_str,namespace,namespace)
1330 prof = prof.runctx(arg_str,namespace,namespace)
1331 sys_exit = ''
1331 sys_exit = ''
1332 except SystemExit:
1332 except SystemExit:
1333 sys_exit = """*** SystemExit exception caught in code being profiled."""
1333 sys_exit = """*** SystemExit exception caught in code being profiled."""
1334
1334
1335 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1335 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1336
1336
1337 lims = opts.l
1337 lims = opts.l
1338 if lims:
1338 if lims:
1339 lims = [] # rebuild lims with ints/floats/strings
1339 lims = [] # rebuild lims with ints/floats/strings
1340 for lim in opts.l:
1340 for lim in opts.l:
1341 try:
1341 try:
1342 lims.append(int(lim))
1342 lims.append(int(lim))
1343 except ValueError:
1343 except ValueError:
1344 try:
1344 try:
1345 lims.append(float(lim))
1345 lims.append(float(lim))
1346 except ValueError:
1346 except ValueError:
1347 lims.append(lim)
1347 lims.append(lim)
1348
1348
1349 # Trap output.
1349 # Trap output.
1350 stdout_trap = StringIO()
1350 stdout_trap = StringIO()
1351
1351
1352 if hasattr(stats,'stream'):
1352 if hasattr(stats,'stream'):
1353 # In newer versions of python, the stats object has a 'stream'
1353 # In newer versions of python, the stats object has a 'stream'
1354 # attribute to write into.
1354 # attribute to write into.
1355 stats.stream = stdout_trap
1355 stats.stream = stdout_trap
1356 stats.print_stats(*lims)
1356 stats.print_stats(*lims)
1357 else:
1357 else:
1358 # For older versions, we manually redirect stdout during printing
1358 # For older versions, we manually redirect stdout during printing
1359 sys_stdout = sys.stdout
1359 sys_stdout = sys.stdout
1360 try:
1360 try:
1361 sys.stdout = stdout_trap
1361 sys.stdout = stdout_trap
1362 stats.print_stats(*lims)
1362 stats.print_stats(*lims)
1363 finally:
1363 finally:
1364 sys.stdout = sys_stdout
1364 sys.stdout = sys_stdout
1365
1365
1366 output = stdout_trap.getvalue()
1366 output = stdout_trap.getvalue()
1367 output = output.rstrip()
1367 output = output.rstrip()
1368
1368
1369 page(output,screen_lines=self.shell.rc.screen_length)
1369 page(output,screen_lines=self.shell.rc.screen_length)
1370 print sys_exit,
1370 print sys_exit,
1371
1371
1372 dump_file = opts.D[0]
1372 dump_file = opts.D[0]
1373 text_file = opts.T[0]
1373 text_file = opts.T[0]
1374 if dump_file:
1374 if dump_file:
1375 prof.dump_stats(dump_file)
1375 prof.dump_stats(dump_file)
1376 print '\n*** Profile stats marshalled to file',\
1376 print '\n*** Profile stats marshalled to file',\
1377 `dump_file`+'.',sys_exit
1377 `dump_file`+'.',sys_exit
1378 if text_file:
1378 if text_file:
1379 pfile = file(text_file,'w')
1379 pfile = file(text_file,'w')
1380 pfile.write(output)
1380 pfile.write(output)
1381 pfile.close()
1381 pfile.close()
1382 print '\n*** Profile printout saved to text file',\
1382 print '\n*** Profile printout saved to text file',\
1383 `text_file`+'.',sys_exit
1383 `text_file`+'.',sys_exit
1384
1384
1385 if opts.has_key('r'):
1385 if opts.has_key('r'):
1386 return stats
1386 return stats
1387 else:
1387 else:
1388 return None
1388 return None
1389
1389
1390 def magic_run(self, parameter_s ='',runner=None):
1390 def magic_run(self, parameter_s ='',runner=None):
1391 """Run the named file inside IPython as a program.
1391 """Run the named file inside IPython as a program.
1392
1392
1393 Usage:\\
1393 Usage:\\
1394 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1394 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1395
1395
1396 Parameters after the filename are passed as command-line arguments to
1396 Parameters after the filename are passed as command-line arguments to
1397 the program (put in sys.argv). Then, control returns to IPython's
1397 the program (put in sys.argv). Then, control returns to IPython's
1398 prompt.
1398 prompt.
1399
1399
1400 This is similar to running at a system prompt:\\
1400 This is similar to running at a system prompt:\\
1401 $ python file args\\
1401 $ python file args\\
1402 but with the advantage of giving you IPython's tracebacks, and of
1402 but with the advantage of giving you IPython's tracebacks, and of
1403 loading all variables into your interactive namespace for further use
1403 loading all variables into your interactive namespace for further use
1404 (unless -p is used, see below).
1404 (unless -p is used, see below).
1405
1405
1406 The file is executed in a namespace initially consisting only of
1406 The file is executed in a namespace initially consisting only of
1407 __name__=='__main__' and sys.argv constructed as indicated. It thus
1407 __name__=='__main__' and sys.argv constructed as indicated. It thus
1408 sees its environment as if it were being run as a stand-alone
1408 sees its environment as if it were being run as a stand-alone program
1409 program. But after execution, the IPython interactive namespace gets
1409 (except for sharing global objects such as previously imported
1410 modules). But after execution, the IPython interactive namespace gets
1410 updated with all variables defined in the program (except for __name__
1411 updated with all variables defined in the program (except for __name__
1411 and sys.argv). This allows for very convenient loading of code for
1412 and sys.argv). This allows for very convenient loading of code for
1412 interactive work, while giving each program a 'clean sheet' to run in.
1413 interactive work, while giving each program a 'clean sheet' to run in.
1413
1414
1414 Options:
1415 Options:
1415
1416
1416 -n: __name__ is NOT set to '__main__', but to the running file's name
1417 -n: __name__ is NOT set to '__main__', but to the running file's name
1417 without extension (as python does under import). This allows running
1418 without extension (as python does under import). This allows running
1418 scripts and reloading the definitions in them without calling code
1419 scripts and reloading the definitions in them without calling code
1419 protected by an ' if __name__ == "__main__" ' clause.
1420 protected by an ' if __name__ == "__main__" ' clause.
1420
1421
1421 -i: run the file in IPython's namespace instead of an empty one. This
1422 -i: run the file in IPython's namespace instead of an empty one. This
1422 is useful if you are experimenting with code written in a text editor
1423 is useful if you are experimenting with code written in a text editor
1423 which depends on variables defined interactively.
1424 which depends on variables defined interactively.
1424
1425
1425 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1426 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1426 being run. This is particularly useful if IPython is being used to
1427 being run. This is particularly useful if IPython is being used to
1427 run unittests, which always exit with a sys.exit() call. In such
1428 run unittests, which always exit with a sys.exit() call. In such
1428 cases you are interested in the output of the test results, not in
1429 cases you are interested in the output of the test results, not in
1429 seeing a traceback of the unittest module.
1430 seeing a traceback of the unittest module.
1430
1431
1431 -t: print timing information at the end of the run. IPython will give
1432 -t: print timing information at the end of the run. IPython will give
1432 you an estimated CPU time consumption for your script, which under
1433 you an estimated CPU time consumption for your script, which under
1433 Unix uses the resource module to avoid the wraparound problems of
1434 Unix uses the resource module to avoid the wraparound problems of
1434 time.clock(). Under Unix, an estimate of time spent on system tasks
1435 time.clock(). Under Unix, an estimate of time spent on system tasks
1435 is also given (for Windows platforms this is reported as 0.0).
1436 is also given (for Windows platforms this is reported as 0.0).
1436
1437
1437 If -t is given, an additional -N<N> option can be given, where <N>
1438 If -t is given, an additional -N<N> option can be given, where <N>
1438 must be an integer indicating how many times you want the script to
1439 must be an integer indicating how many times you want the script to
1439 run. The final timing report will include total and per run results.
1440 run. The final timing report will include total and per run results.
1440
1441
1441 For example (testing the script uniq_stable.py):
1442 For example (testing the script uniq_stable.py):
1442
1443
1443 In [1]: run -t uniq_stable
1444 In [1]: run -t uniq_stable
1444
1445
1445 IPython CPU timings (estimated):\\
1446 IPython CPU timings (estimated):\\
1446 User : 0.19597 s.\\
1447 User : 0.19597 s.\\
1447 System: 0.0 s.\\
1448 System: 0.0 s.\\
1448
1449
1449 In [2]: run -t -N5 uniq_stable
1450 In [2]: run -t -N5 uniq_stable
1450
1451
1451 IPython CPU timings (estimated):\\
1452 IPython CPU timings (estimated):\\
1452 Total runs performed: 5\\
1453 Total runs performed: 5\\
1453 Times : Total Per run\\
1454 Times : Total Per run\\
1454 User : 0.910862 s, 0.1821724 s.\\
1455 User : 0.910862 s, 0.1821724 s.\\
1455 System: 0.0 s, 0.0 s.
1456 System: 0.0 s, 0.0 s.
1456
1457
1457 -d: run your program under the control of pdb, the Python debugger.
1458 -d: run your program under the control of pdb, the Python debugger.
1458 This allows you to execute your program step by step, watch variables,
1459 This allows you to execute your program step by step, watch variables,
1459 etc. Internally, what IPython does is similar to calling:
1460 etc. Internally, what IPython does is similar to calling:
1460
1461
1461 pdb.run('execfile("YOURFILENAME")')
1462 pdb.run('execfile("YOURFILENAME")')
1462
1463
1463 with a breakpoint set on line 1 of your file. You can change the line
1464 with a breakpoint set on line 1 of your file. You can change the line
1464 number for this automatic breakpoint to be <N> by using the -bN option
1465 number for this automatic breakpoint to be <N> by using the -bN option
1465 (where N must be an integer). For example:
1466 (where N must be an integer). For example:
1466
1467
1467 %run -d -b40 myscript
1468 %run -d -b40 myscript
1468
1469
1469 will set the first breakpoint at line 40 in myscript.py. Note that
1470 will set the first breakpoint at line 40 in myscript.py. Note that
1470 the first breakpoint must be set on a line which actually does
1471 the first breakpoint must be set on a line which actually does
1471 something (not a comment or docstring) for it to stop execution.
1472 something (not a comment or docstring) for it to stop execution.
1472
1473
1473 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1474 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1474 first enter 'c' (without qoutes) to start execution up to the first
1475 first enter 'c' (without qoutes) to start execution up to the first
1475 breakpoint.
1476 breakpoint.
1476
1477
1477 Entering 'help' gives information about the use of the debugger. You
1478 Entering 'help' gives information about the use of the debugger. You
1478 can easily see pdb's full documentation with "import pdb;pdb.help()"
1479 can easily see pdb's full documentation with "import pdb;pdb.help()"
1479 at a prompt.
1480 at a prompt.
1480
1481
1481 -p: run program under the control of the Python profiler module (which
1482 -p: run program under the control of the Python profiler module (which
1482 prints a detailed report of execution times, function calls, etc).
1483 prints a detailed report of execution times, function calls, etc).
1483
1484
1484 You can pass other options after -p which affect the behavior of the
1485 You can pass other options after -p which affect the behavior of the
1485 profiler itself. See the docs for %prun for details.
1486 profiler itself. See the docs for %prun for details.
1486
1487
1487 In this mode, the program's variables do NOT propagate back to the
1488 In this mode, the program's variables do NOT propagate back to the
1488 IPython interactive namespace (because they remain in the namespace
1489 IPython interactive namespace (because they remain in the namespace
1489 where the profiler executes them).
1490 where the profiler executes them).
1490
1491
1491 Internally this triggers a call to %prun, see its documentation for
1492 Internally this triggers a call to %prun, see its documentation for
1492 details on the options available specifically for profiling.
1493 details on the options available specifically for profiling.
1493
1494
1494 There is one special usage for which the text above doesn't apply:
1495 There is one special usage for which the text above doesn't apply:
1495 if the filename ends with .ipy, the file is run as ipython script,
1496 if the filename ends with .ipy, the file is run as ipython script,
1496 just as if the commands were written on IPython prompt.
1497 just as if the commands were written on IPython prompt.
1497 """
1498 """
1498
1499
1499 # get arguments and set sys.argv for program to be run.
1500 # get arguments and set sys.argv for program to be run.
1500 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1501 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1501 mode='list',list_all=1)
1502 mode='list',list_all=1)
1502
1503
1503 try:
1504 try:
1504 filename = get_py_filename(arg_lst[0])
1505 filename = get_py_filename(arg_lst[0])
1505 except IndexError:
1506 except IndexError:
1506 warn('you must provide at least a filename.')
1507 warn('you must provide at least a filename.')
1507 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1508 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1508 return
1509 return
1509 except IOError,msg:
1510 except IOError,msg:
1510 error(msg)
1511 error(msg)
1511 return
1512 return
1512
1513
1513 if filename.lower().endswith('.ipy'):
1514 if filename.lower().endswith('.ipy'):
1514 self.api.runlines(open(filename).read())
1515 self.api.runlines(open(filename).read())
1515 return
1516 return
1516
1517
1517 # Control the response to exit() calls made by the script being run
1518 # Control the response to exit() calls made by the script being run
1518 exit_ignore = opts.has_key('e')
1519 exit_ignore = opts.has_key('e')
1519
1520
1520 # Make sure that the running script gets a proper sys.argv as if it
1521 # Make sure that the running script gets a proper sys.argv as if it
1521 # were run from a system shell.
1522 # were run from a system shell.
1522 save_argv = sys.argv # save it for later restoring
1523 save_argv = sys.argv # save it for later restoring
1523 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1524 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1524
1525
1525 if opts.has_key('i'):
1526 if opts.has_key('i'):
1526 # Run in user's interactive namespace
1527 # Run in user's interactive namespace
1527 prog_ns = self.shell.user_ns
1528 prog_ns = self.shell.user_ns
1528 __name__save = self.shell.user_ns['__name__']
1529 __name__save = self.shell.user_ns['__name__']
1529 prog_ns['__name__'] = '__main__'
1530 prog_ns['__name__'] = '__main__'
1530 main_mod = FakeModule(prog_ns)
1531 main_mod = FakeModule(prog_ns)
1531 else:
1532 else:
1532 # Run in a fresh, empty namespace
1533 # Run in a fresh, empty namespace
1533 if opts.has_key('n'):
1534 if opts.has_key('n'):
1534 name = os.path.splitext(os.path.basename(filename))[0]
1535 name = os.path.splitext(os.path.basename(filename))[0]
1535 else:
1536 else:
1536 name = '__main__'
1537 name = '__main__'
1537 main_mod = FakeModule()
1538 main_mod = FakeModule()
1538 prog_ns = main_mod.__dict__
1539 prog_ns = main_mod.__dict__
1539 prog_ns['__name__'] = name
1540 prog_ns['__name__'] = name
1540 # The shell MUST hold a reference to main_mod so after %run exits,
1541 # The shell MUST hold a reference to main_mod so after %run exits,
1541 # the python deletion mechanism doesn't zero it out (leaving
1542 # the python deletion mechanism doesn't zero it out (leaving
1542 # dangling references)
1543 # dangling references)
1543 self.shell._user_main_modules.append(main_mod)
1544 self.shell._user_main_modules.append(main_mod)
1544
1545
1545 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1546 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1546 # set the __file__ global in the script's namespace
1547 # set the __file__ global in the script's namespace
1547 prog_ns['__file__'] = filename
1548 prog_ns['__file__'] = filename
1548
1549
1549 # pickle fix. See iplib for an explanation. But we need to make sure
1550 # pickle fix. See iplib for an explanation. But we need to make sure
1550 # that, if we overwrite __main__, we replace it at the end
1551 # that, if we overwrite __main__, we replace it at the end
1551 if prog_ns['__name__'] == '__main__':
1552 if prog_ns['__name__'] == '__main__':
1552 restore_main = sys.modules['__main__']
1553 restore_main = sys.modules['__main__']
1553 else:
1554 else:
1554 restore_main = False
1555 restore_main = False
1555
1556
1556 sys.modules[prog_ns['__name__']] = main_mod
1557 sys.modules[prog_ns['__name__']] = main_mod
1557
1558
1558 stats = None
1559 stats = None
1559 try:
1560 try:
1560 if self.shell.has_readline:
1561 if self.shell.has_readline:
1561 self.shell.savehist()
1562 self.shell.savehist()
1562
1563
1563 if opts.has_key('p'):
1564 if opts.has_key('p'):
1564 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1565 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1565 else:
1566 else:
1566 if opts.has_key('d'):
1567 if opts.has_key('d'):
1567 deb = Debugger.Pdb(self.shell.rc.colors)
1568 deb = Debugger.Pdb(self.shell.rc.colors)
1568 # reset Breakpoint state, which is moronically kept
1569 # reset Breakpoint state, which is moronically kept
1569 # in a class
1570 # in a class
1570 bdb.Breakpoint.next = 1
1571 bdb.Breakpoint.next = 1
1571 bdb.Breakpoint.bplist = {}
1572 bdb.Breakpoint.bplist = {}
1572 bdb.Breakpoint.bpbynumber = [None]
1573 bdb.Breakpoint.bpbynumber = [None]
1573 # Set an initial breakpoint to stop execution
1574 # Set an initial breakpoint to stop execution
1574 maxtries = 10
1575 maxtries = 10
1575 bp = int(opts.get('b',[1])[0])
1576 bp = int(opts.get('b',[1])[0])
1576 checkline = deb.checkline(filename,bp)
1577 checkline = deb.checkline(filename,bp)
1577 if not checkline:
1578 if not checkline:
1578 for bp in range(bp+1,bp+maxtries+1):
1579 for bp in range(bp+1,bp+maxtries+1):
1579 if deb.checkline(filename,bp):
1580 if deb.checkline(filename,bp):
1580 break
1581 break
1581 else:
1582 else:
1582 msg = ("\nI failed to find a valid line to set "
1583 msg = ("\nI failed to find a valid line to set "
1583 "a breakpoint\n"
1584 "a breakpoint\n"
1584 "after trying up to line: %s.\n"
1585 "after trying up to line: %s.\n"
1585 "Please set a valid breakpoint manually "
1586 "Please set a valid breakpoint manually "
1586 "with the -b option." % bp)
1587 "with the -b option." % bp)
1587 error(msg)
1588 error(msg)
1588 return
1589 return
1589 # if we find a good linenumber, set the breakpoint
1590 # if we find a good linenumber, set the breakpoint
1590 deb.do_break('%s:%s' % (filename,bp))
1591 deb.do_break('%s:%s' % (filename,bp))
1591 # Start file run
1592 # Start file run
1592 print "NOTE: Enter 'c' at the",
1593 print "NOTE: Enter 'c' at the",
1593 print "%s prompt to start your script." % deb.prompt
1594 print "%s prompt to start your script." % deb.prompt
1594 try:
1595 try:
1595 deb.run('execfile("%s")' % filename,prog_ns)
1596 deb.run('execfile("%s")' % filename,prog_ns)
1596
1597
1597 except:
1598 except:
1598 etype, value, tb = sys.exc_info()
1599 etype, value, tb = sys.exc_info()
1599 # Skip three frames in the traceback: the %run one,
1600 # Skip three frames in the traceback: the %run one,
1600 # one inside bdb.py, and the command-line typed by the
1601 # one inside bdb.py, and the command-line typed by the
1601 # user (run by exec in pdb itself).
1602 # user (run by exec in pdb itself).
1602 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1603 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1603 else:
1604 else:
1604 if runner is None:
1605 if runner is None:
1605 runner = self.shell.safe_execfile
1606 runner = self.shell.safe_execfile
1606 if opts.has_key('t'):
1607 if opts.has_key('t'):
1607 # timed execution
1608 # timed execution
1608 try:
1609 try:
1609 nruns = int(opts['N'][0])
1610 nruns = int(opts['N'][0])
1610 if nruns < 1:
1611 if nruns < 1:
1611 error('Number of runs must be >=1')
1612 error('Number of runs must be >=1')
1612 return
1613 return
1613 except (KeyError):
1614 except (KeyError):
1614 nruns = 1
1615 nruns = 1
1615 if nruns == 1:
1616 if nruns == 1:
1616 t0 = clock2()
1617 t0 = clock2()
1617 runner(filename,prog_ns,prog_ns,
1618 runner(filename,prog_ns,prog_ns,
1618 exit_ignore=exit_ignore)
1619 exit_ignore=exit_ignore)
1619 t1 = clock2()
1620 t1 = clock2()
1620 t_usr = t1[0]-t0[0]
1621 t_usr = t1[0]-t0[0]
1621 t_sys = t1[1]-t1[1]
1622 t_sys = t1[1]-t1[1]
1622 print "\nIPython CPU timings (estimated):"
1623 print "\nIPython CPU timings (estimated):"
1623 print " User : %10s s." % t_usr
1624 print " User : %10s s." % t_usr
1624 print " System: %10s s." % t_sys
1625 print " System: %10s s." % t_sys
1625 else:
1626 else:
1626 runs = range(nruns)
1627 runs = range(nruns)
1627 t0 = clock2()
1628 t0 = clock2()
1628 for nr in runs:
1629 for nr in runs:
1629 runner(filename,prog_ns,prog_ns,
1630 runner(filename,prog_ns,prog_ns,
1630 exit_ignore=exit_ignore)
1631 exit_ignore=exit_ignore)
1631 t1 = clock2()
1632 t1 = clock2()
1632 t_usr = t1[0]-t0[0]
1633 t_usr = t1[0]-t0[0]
1633 t_sys = t1[1]-t1[1]
1634 t_sys = t1[1]-t1[1]
1634 print "\nIPython CPU timings (estimated):"
1635 print "\nIPython CPU timings (estimated):"
1635 print "Total runs performed:",nruns
1636 print "Total runs performed:",nruns
1636 print " Times : %10s %10s" % ('Total','Per run')
1637 print " Times : %10s %10s" % ('Total','Per run')
1637 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1638 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1638 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1639 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1639
1640
1640 else:
1641 else:
1641 # regular execution
1642 # regular execution
1642 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1643 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1643 if opts.has_key('i'):
1644 if opts.has_key('i'):
1644 self.shell.user_ns['__name__'] = __name__save
1645 self.shell.user_ns['__name__'] = __name__save
1645 else:
1646 else:
1646 # update IPython interactive namespace
1647 # update IPython interactive namespace
1647 del prog_ns['__name__']
1648 del prog_ns['__name__']
1648 self.shell.user_ns.update(prog_ns)
1649 self.shell.user_ns.update(prog_ns)
1649 finally:
1650 finally:
1650 sys.argv = save_argv
1651 sys.argv = save_argv
1651 if restore_main:
1652 if restore_main:
1652 sys.modules['__main__'] = restore_main
1653 sys.modules['__main__'] = restore_main
1653 self.shell.reloadhist()
1654 self.shell.reloadhist()
1654
1655
1655 return stats
1656 return stats
1656
1657
1657 def magic_runlog(self, parameter_s =''):
1658 def magic_runlog(self, parameter_s =''):
1658 """Run files as logs.
1659 """Run files as logs.
1659
1660
1660 Usage:\\
1661 Usage:\\
1661 %runlog file1 file2 ...
1662 %runlog file1 file2 ...
1662
1663
1663 Run the named files (treating them as log files) in sequence inside
1664 Run the named files (treating them as log files) in sequence inside
1664 the interpreter, and return to the prompt. This is much slower than
1665 the interpreter, and return to the prompt. This is much slower than
1665 %run because each line is executed in a try/except block, but it
1666 %run because each line is executed in a try/except block, but it
1666 allows running files with syntax errors in them.
1667 allows running files with syntax errors in them.
1667
1668
1668 Normally IPython will guess when a file is one of its own logfiles, so
1669 Normally IPython will guess when a file is one of its own logfiles, so
1669 you can typically use %run even for logs. This shorthand allows you to
1670 you can typically use %run even for logs. This shorthand allows you to
1670 force any file to be treated as a log file."""
1671 force any file to be treated as a log file."""
1671
1672
1672 for f in parameter_s.split():
1673 for f in parameter_s.split():
1673 self.shell.safe_execfile(f,self.shell.user_ns,
1674 self.shell.safe_execfile(f,self.shell.user_ns,
1674 self.shell.user_ns,islog=1)
1675 self.shell.user_ns,islog=1)
1675
1676
1676 def magic_timeit(self, parameter_s =''):
1677 def magic_timeit(self, parameter_s =''):
1677 """Time execution of a Python statement or expression
1678 """Time execution of a Python statement or expression
1678
1679
1679 Usage:\\
1680 Usage:\\
1680 %timeit [-n<N> -r<R> [-t|-c]] statement
1681 %timeit [-n<N> -r<R> [-t|-c]] statement
1681
1682
1682 Time execution of a Python statement or expression using the timeit
1683 Time execution of a Python statement or expression using the timeit
1683 module.
1684 module.
1684
1685
1685 Options:
1686 Options:
1686 -n<N>: execute the given statement <N> times in a loop. If this value
1687 -n<N>: execute the given statement <N> times in a loop. If this value
1687 is not given, a fitting value is chosen.
1688 is not given, a fitting value is chosen.
1688
1689
1689 -r<R>: repeat the loop iteration <R> times and take the best result.
1690 -r<R>: repeat the loop iteration <R> times and take the best result.
1690 Default: 3
1691 Default: 3
1691
1692
1692 -t: use time.time to measure the time, which is the default on Unix.
1693 -t: use time.time to measure the time, which is the default on Unix.
1693 This function measures wall time.
1694 This function measures wall time.
1694
1695
1695 -c: use time.clock to measure the time, which is the default on
1696 -c: use time.clock to measure the time, which is the default on
1696 Windows and measures wall time. On Unix, resource.getrusage is used
1697 Windows and measures wall time. On Unix, resource.getrusage is used
1697 instead and returns the CPU user time.
1698 instead and returns the CPU user time.
1698
1699
1699 -p<P>: use a precision of <P> digits to display the timing result.
1700 -p<P>: use a precision of <P> digits to display the timing result.
1700 Default: 3
1701 Default: 3
1701
1702
1702
1703
1703 Examples:\\
1704 Examples:\\
1704 In [1]: %timeit pass
1705 In [1]: %timeit pass
1705 10000000 loops, best of 3: 53.3 ns per loop
1706 10000000 loops, best of 3: 53.3 ns per loop
1706
1707
1707 In [2]: u = None
1708 In [2]: u = None
1708
1709
1709 In [3]: %timeit u is None
1710 In [3]: %timeit u is None
1710 10000000 loops, best of 3: 184 ns per loop
1711 10000000 loops, best of 3: 184 ns per loop
1711
1712
1712 In [4]: %timeit -r 4 u == None
1713 In [4]: %timeit -r 4 u == None
1713 1000000 loops, best of 4: 242 ns per loop
1714 1000000 loops, best of 4: 242 ns per loop
1714
1715
1715 In [5]: import time
1716 In [5]: import time
1716
1717
1717 In [6]: %timeit -n1 time.sleep(2)
1718 In [6]: %timeit -n1 time.sleep(2)
1718 1 loops, best of 3: 2 s per loop
1719 1 loops, best of 3: 2 s per loop
1719
1720
1720
1721
1721 The times reported by %timeit will be slightly higher than those
1722 The times reported by %timeit will be slightly higher than those
1722 reported by the timeit.py script when variables are accessed. This is
1723 reported by the timeit.py script when variables are accessed. This is
1723 due to the fact that %timeit executes the statement in the namespace
1724 due to the fact that %timeit executes the statement in the namespace
1724 of the shell, compared with timeit.py, which uses a single setup
1725 of the shell, compared with timeit.py, which uses a single setup
1725 statement to import function or create variables. Generally, the bias
1726 statement to import function or create variables. Generally, the bias
1726 does not matter as long as results from timeit.py are not mixed with
1727 does not matter as long as results from timeit.py are not mixed with
1727 those from %timeit."""
1728 those from %timeit."""
1728
1729
1729 import timeit
1730 import timeit
1730 import math
1731 import math
1731
1732
1732 units = ["s", "ms", "\xc2\xb5s", "ns"]
1733 units = ["s", "ms", "\xc2\xb5s", "ns"]
1733 scaling = [1, 1e3, 1e6, 1e9]
1734 scaling = [1, 1e3, 1e6, 1e9]
1734
1735
1735 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1736 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1736 posix=False)
1737 posix=False)
1737 if stmt == "":
1738 if stmt == "":
1738 return
1739 return
1739 timefunc = timeit.default_timer
1740 timefunc = timeit.default_timer
1740 number = int(getattr(opts, "n", 0))
1741 number = int(getattr(opts, "n", 0))
1741 repeat = int(getattr(opts, "r", timeit.default_repeat))
1742 repeat = int(getattr(opts, "r", timeit.default_repeat))
1742 precision = int(getattr(opts, "p", 3))
1743 precision = int(getattr(opts, "p", 3))
1743 if hasattr(opts, "t"):
1744 if hasattr(opts, "t"):
1744 timefunc = time.time
1745 timefunc = time.time
1745 if hasattr(opts, "c"):
1746 if hasattr(opts, "c"):
1746 timefunc = clock
1747 timefunc = clock
1747
1748
1748 timer = timeit.Timer(timer=timefunc)
1749 timer = timeit.Timer(timer=timefunc)
1749 # this code has tight coupling to the inner workings of timeit.Timer,
1750 # this code has tight coupling to the inner workings of timeit.Timer,
1750 # but is there a better way to achieve that the code stmt has access
1751 # but is there a better way to achieve that the code stmt has access
1751 # to the shell namespace?
1752 # to the shell namespace?
1752
1753
1753 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1754 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1754 'setup': "pass"}
1755 'setup': "pass"}
1755 # Track compilation time so it can be reported if too long
1756 # Track compilation time so it can be reported if too long
1756 # Minimum time above which compilation time will be reported
1757 # Minimum time above which compilation time will be reported
1757 tc_min = 0.1
1758 tc_min = 0.1
1758
1759
1759 t0 = clock()
1760 t0 = clock()
1760 code = compile(src, "<magic-timeit>", "exec")
1761 code = compile(src, "<magic-timeit>", "exec")
1761 tc = clock()-t0
1762 tc = clock()-t0
1762
1763
1763 ns = {}
1764 ns = {}
1764 exec code in self.shell.user_ns, ns
1765 exec code in self.shell.user_ns, ns
1765 timer.inner = ns["inner"]
1766 timer.inner = ns["inner"]
1766
1767
1767 if number == 0:
1768 if number == 0:
1768 # determine number so that 0.2 <= total time < 2.0
1769 # determine number so that 0.2 <= total time < 2.0
1769 number = 1
1770 number = 1
1770 for i in range(1, 10):
1771 for i in range(1, 10):
1771 number *= 10
1772 number *= 10
1772 if timer.timeit(number) >= 0.2:
1773 if timer.timeit(number) >= 0.2:
1773 break
1774 break
1774
1775
1775 best = min(timer.repeat(repeat, number)) / number
1776 best = min(timer.repeat(repeat, number)) / number
1776
1777
1777 if best > 0.0:
1778 if best > 0.0:
1778 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1779 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1779 else:
1780 else:
1780 order = 3
1781 order = 3
1781 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1782 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1782 precision,
1783 precision,
1783 best * scaling[order],
1784 best * scaling[order],
1784 units[order])
1785 units[order])
1785 if tc > tc_min:
1786 if tc > tc_min:
1786 print "Compiler time: %.2f s" % tc
1787 print "Compiler time: %.2f s" % tc
1787
1788
1788 def magic_time(self,parameter_s = ''):
1789 def magic_time(self,parameter_s = ''):
1789 """Time execution of a Python statement or expression.
1790 """Time execution of a Python statement or expression.
1790
1791
1791 The CPU and wall clock times are printed, and the value of the
1792 The CPU and wall clock times are printed, and the value of the
1792 expression (if any) is returned. Note that under Win32, system time
1793 expression (if any) is returned. Note that under Win32, system time
1793 is always reported as 0, since it can not be measured.
1794 is always reported as 0, since it can not be measured.
1794
1795
1795 This function provides very basic timing functionality. In Python
1796 This function provides very basic timing functionality. In Python
1796 2.3, the timeit module offers more control and sophistication, so this
1797 2.3, the timeit module offers more control and sophistication, so this
1797 could be rewritten to use it (patches welcome).
1798 could be rewritten to use it (patches welcome).
1798
1799
1799 Some examples:
1800 Some examples:
1800
1801
1801 In [1]: time 2**128
1802 In [1]: time 2**128
1802 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1803 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1803 Wall time: 0.00
1804 Wall time: 0.00
1804 Out[1]: 340282366920938463463374607431768211456L
1805 Out[1]: 340282366920938463463374607431768211456L
1805
1806
1806 In [2]: n = 1000000
1807 In [2]: n = 1000000
1807
1808
1808 In [3]: time sum(range(n))
1809 In [3]: time sum(range(n))
1809 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1810 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1810 Wall time: 1.37
1811 Wall time: 1.37
1811 Out[3]: 499999500000L
1812 Out[3]: 499999500000L
1812
1813
1813 In [4]: time print 'hello world'
1814 In [4]: time print 'hello world'
1814 hello world
1815 hello world
1815 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1816 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1816 Wall time: 0.00
1817 Wall time: 0.00
1817
1818
1818 Note that the time needed by Python to compile the given expression
1819 Note that the time needed by Python to compile the given expression
1819 will be reported if it is more than 0.1s. In this example, the
1820 will be reported if it is more than 0.1s. In this example, the
1820 actual exponentiation is done by Python at compilation time, so while
1821 actual exponentiation is done by Python at compilation time, so while
1821 the expression can take a noticeable amount of time to compute, that
1822 the expression can take a noticeable amount of time to compute, that
1822 time is purely due to the compilation:
1823 time is purely due to the compilation:
1823
1824
1824 In [5]: time 3**9999;
1825 In [5]: time 3**9999;
1825 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1826 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1826 Wall time: 0.00 s
1827 Wall time: 0.00 s
1827
1828
1828 In [6]: time 3**999999;
1829 In [6]: time 3**999999;
1829 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1830 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1830 Wall time: 0.00 s
1831 Wall time: 0.00 s
1831 Compiler : 0.78 s
1832 Compiler : 0.78 s
1832 """
1833 """
1833
1834
1834 # fail immediately if the given expression can't be compiled
1835 # fail immediately if the given expression can't be compiled
1835
1836
1836 expr = self.shell.prefilter(parameter_s,False)
1837 expr = self.shell.prefilter(parameter_s,False)
1837
1838
1838 # Minimum time above which compilation time will be reported
1839 # Minimum time above which compilation time will be reported
1839 tc_min = 0.1
1840 tc_min = 0.1
1840
1841
1841 try:
1842 try:
1842 mode = 'eval'
1843 mode = 'eval'
1843 t0 = clock()
1844 t0 = clock()
1844 code = compile(expr,'<timed eval>',mode)
1845 code = compile(expr,'<timed eval>',mode)
1845 tc = clock()-t0
1846 tc = clock()-t0
1846 except SyntaxError:
1847 except SyntaxError:
1847 mode = 'exec'
1848 mode = 'exec'
1848 t0 = clock()
1849 t0 = clock()
1849 code = compile(expr,'<timed exec>',mode)
1850 code = compile(expr,'<timed exec>',mode)
1850 tc = clock()-t0
1851 tc = clock()-t0
1851 # skew measurement as little as possible
1852 # skew measurement as little as possible
1852 glob = self.shell.user_ns
1853 glob = self.shell.user_ns
1853 clk = clock2
1854 clk = clock2
1854 wtime = time.time
1855 wtime = time.time
1855 # time execution
1856 # time execution
1856 wall_st = wtime()
1857 wall_st = wtime()
1857 if mode=='eval':
1858 if mode=='eval':
1858 st = clk()
1859 st = clk()
1859 out = eval(code,glob)
1860 out = eval(code,glob)
1860 end = clk()
1861 end = clk()
1861 else:
1862 else:
1862 st = clk()
1863 st = clk()
1863 exec code in glob
1864 exec code in glob
1864 end = clk()
1865 end = clk()
1865 out = None
1866 out = None
1866 wall_end = wtime()
1867 wall_end = wtime()
1867 # Compute actual times and report
1868 # Compute actual times and report
1868 wall_time = wall_end-wall_st
1869 wall_time = wall_end-wall_st
1869 cpu_user = end[0]-st[0]
1870 cpu_user = end[0]-st[0]
1870 cpu_sys = end[1]-st[1]
1871 cpu_sys = end[1]-st[1]
1871 cpu_tot = cpu_user+cpu_sys
1872 cpu_tot = cpu_user+cpu_sys
1872 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1873 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1873 (cpu_user,cpu_sys,cpu_tot)
1874 (cpu_user,cpu_sys,cpu_tot)
1874 print "Wall time: %.2f s" % wall_time
1875 print "Wall time: %.2f s" % wall_time
1875 if tc > tc_min:
1876 if tc > tc_min:
1876 print "Compiler : %.2f s" % tc
1877 print "Compiler : %.2f s" % tc
1877 return out
1878 return out
1878
1879
1879 def magic_macro(self,parameter_s = ''):
1880 def magic_macro(self,parameter_s = ''):
1880 """Define a set of input lines as a macro for future re-execution.
1881 """Define a set of input lines as a macro for future re-execution.
1881
1882
1882 Usage:\\
1883 Usage:\\
1883 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1884 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1884
1885
1885 Options:
1886 Options:
1886
1887
1887 -r: use 'raw' input. By default, the 'processed' history is used,
1888 -r: use 'raw' input. By default, the 'processed' history is used,
1888 so that magics are loaded in their transformed version to valid
1889 so that magics are loaded in their transformed version to valid
1889 Python. If this option is given, the raw input as typed as the
1890 Python. If this option is given, the raw input as typed as the
1890 command line is used instead.
1891 command line is used instead.
1891
1892
1892 This will define a global variable called `name` which is a string
1893 This will define a global variable called `name` which is a string
1893 made of joining the slices and lines you specify (n1,n2,... numbers
1894 made of joining the slices and lines you specify (n1,n2,... numbers
1894 above) from your input history into a single string. This variable
1895 above) from your input history into a single string. This variable
1895 acts like an automatic function which re-executes those lines as if
1896 acts like an automatic function which re-executes those lines as if
1896 you had typed them. You just type 'name' at the prompt and the code
1897 you had typed them. You just type 'name' at the prompt and the code
1897 executes.
1898 executes.
1898
1899
1899 The notation for indicating number ranges is: n1-n2 means 'use line
1900 The notation for indicating number ranges is: n1-n2 means 'use line
1900 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1901 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1901 using the lines numbered 5,6 and 7.
1902 using the lines numbered 5,6 and 7.
1902
1903
1903 Note: as a 'hidden' feature, you can also use traditional python slice
1904 Note: as a 'hidden' feature, you can also use traditional python slice
1904 notation, where N:M means numbers N through M-1.
1905 notation, where N:M means numbers N through M-1.
1905
1906
1906 For example, if your history contains (%hist prints it):
1907 For example, if your history contains (%hist prints it):
1907
1908
1908 44: x=1\\
1909 44: x=1\\
1909 45: y=3\\
1910 45: y=3\\
1910 46: z=x+y\\
1911 46: z=x+y\\
1911 47: print x\\
1912 47: print x\\
1912 48: a=5\\
1913 48: a=5\\
1913 49: print 'x',x,'y',y\\
1914 49: print 'x',x,'y',y\\
1914
1915
1915 you can create a macro with lines 44 through 47 (included) and line 49
1916 you can create a macro with lines 44 through 47 (included) and line 49
1916 called my_macro with:
1917 called my_macro with:
1917
1918
1918 In [51]: %macro my_macro 44-47 49
1919 In [51]: %macro my_macro 44-47 49
1919
1920
1920 Now, typing `my_macro` (without quotes) will re-execute all this code
1921 Now, typing `my_macro` (without quotes) will re-execute all this code
1921 in one pass.
1922 in one pass.
1922
1923
1923 You don't need to give the line-numbers in order, and any given line
1924 You don't need to give the line-numbers in order, and any given line
1924 number can appear multiple times. You can assemble macros with any
1925 number can appear multiple times. You can assemble macros with any
1925 lines from your input history in any order.
1926 lines from your input history in any order.
1926
1927
1927 The macro is a simple object which holds its value in an attribute,
1928 The macro is a simple object which holds its value in an attribute,
1928 but IPython's display system checks for macros and executes them as
1929 but IPython's display system checks for macros and executes them as
1929 code instead of printing them when you type their name.
1930 code instead of printing them when you type their name.
1930
1931
1931 You can view a macro's contents by explicitly printing it with:
1932 You can view a macro's contents by explicitly printing it with:
1932
1933
1933 'print macro_name'.
1934 'print macro_name'.
1934
1935
1935 For one-off cases which DON'T contain magic function calls in them you
1936 For one-off cases which DON'T contain magic function calls in them you
1936 can obtain similar results by explicitly executing slices from your
1937 can obtain similar results by explicitly executing slices from your
1937 input history with:
1938 input history with:
1938
1939
1939 In [60]: exec In[44:48]+In[49]"""
1940 In [60]: exec In[44:48]+In[49]"""
1940
1941
1941 opts,args = self.parse_options(parameter_s,'r',mode='list')
1942 opts,args = self.parse_options(parameter_s,'r',mode='list')
1942 if not args:
1943 if not args:
1943 macs = [k for k,v in self.shell.user_ns.items() if isinstance(v, Macro)]
1944 macs = [k for k,v in self.shell.user_ns.items() if isinstance(v, Macro)]
1944 macs.sort()
1945 macs.sort()
1945 return macs
1946 return macs
1946 if len(args) == 1:
1947 if len(args) == 1:
1947 raise UsageError(
1948 raise UsageError(
1948 "%macro insufficient args; usage '%macro name n1-n2 n3-4...")
1949 "%macro insufficient args; usage '%macro name n1-n2 n3-4...")
1949 name,ranges = args[0], args[1:]
1950 name,ranges = args[0], args[1:]
1950
1951
1951 #print 'rng',ranges # dbg
1952 #print 'rng',ranges # dbg
1952 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1953 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1953 macro = Macro(lines)
1954 macro = Macro(lines)
1954 self.shell.user_ns.update({name:macro})
1955 self.shell.user_ns.update({name:macro})
1955 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1956 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1956 print 'Macro contents:'
1957 print 'Macro contents:'
1957 print macro,
1958 print macro,
1958
1959
1959 def magic_save(self,parameter_s = ''):
1960 def magic_save(self,parameter_s = ''):
1960 """Save a set of lines to a given filename.
1961 """Save a set of lines to a given filename.
1961
1962
1962 Usage:\\
1963 Usage:\\
1963 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1964 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1964
1965
1965 Options:
1966 Options:
1966
1967
1967 -r: use 'raw' input. By default, the 'processed' history is used,
1968 -r: use 'raw' input. By default, the 'processed' history is used,
1968 so that magics are loaded in their transformed version to valid
1969 so that magics are loaded in their transformed version to valid
1969 Python. If this option is given, the raw input as typed as the
1970 Python. If this option is given, the raw input as typed as the
1970 command line is used instead.
1971 command line is used instead.
1971
1972
1972 This function uses the same syntax as %macro for line extraction, but
1973 This function uses the same syntax as %macro for line extraction, but
1973 instead of creating a macro it saves the resulting string to the
1974 instead of creating a macro it saves the resulting string to the
1974 filename you specify.
1975 filename you specify.
1975
1976
1976 It adds a '.py' extension to the file if you don't do so yourself, and
1977 It adds a '.py' extension to the file if you don't do so yourself, and
1977 it asks for confirmation before overwriting existing files."""
1978 it asks for confirmation before overwriting existing files."""
1978
1979
1979 opts,args = self.parse_options(parameter_s,'r',mode='list')
1980 opts,args = self.parse_options(parameter_s,'r',mode='list')
1980 fname,ranges = args[0], args[1:]
1981 fname,ranges = args[0], args[1:]
1981 if not fname.endswith('.py'):
1982 if not fname.endswith('.py'):
1982 fname += '.py'
1983 fname += '.py'
1983 if os.path.isfile(fname):
1984 if os.path.isfile(fname):
1984 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1985 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1985 if ans.lower() not in ['y','yes']:
1986 if ans.lower() not in ['y','yes']:
1986 print 'Operation cancelled.'
1987 print 'Operation cancelled.'
1987 return
1988 return
1988 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1989 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1989 f = file(fname,'w')
1990 f = file(fname,'w')
1990 f.write(cmds)
1991 f.write(cmds)
1991 f.close()
1992 f.close()
1992 print 'The following commands were written to file `%s`:' % fname
1993 print 'The following commands were written to file `%s`:' % fname
1993 print cmds
1994 print cmds
1994
1995
1995 def _edit_macro(self,mname,macro):
1996 def _edit_macro(self,mname,macro):
1996 """open an editor with the macro data in a file"""
1997 """open an editor with the macro data in a file"""
1997 filename = self.shell.mktempfile(macro.value)
1998 filename = self.shell.mktempfile(macro.value)
1998 self.shell.hooks.editor(filename)
1999 self.shell.hooks.editor(filename)
1999
2000
2000 # and make a new macro object, to replace the old one
2001 # and make a new macro object, to replace the old one
2001 mfile = open(filename)
2002 mfile = open(filename)
2002 mvalue = mfile.read()
2003 mvalue = mfile.read()
2003 mfile.close()
2004 mfile.close()
2004 self.shell.user_ns[mname] = Macro(mvalue)
2005 self.shell.user_ns[mname] = Macro(mvalue)
2005
2006
2006 def magic_ed(self,parameter_s=''):
2007 def magic_ed(self,parameter_s=''):
2007 """Alias to %edit."""
2008 """Alias to %edit."""
2008 return self.magic_edit(parameter_s)
2009 return self.magic_edit(parameter_s)
2009
2010
2010 def magic_edit(self,parameter_s='',last_call=['','']):
2011 def magic_edit(self,parameter_s='',last_call=['','']):
2011 """Bring up an editor and execute the resulting code.
2012 """Bring up an editor and execute the resulting code.
2012
2013
2013 Usage:
2014 Usage:
2014 %edit [options] [args]
2015 %edit [options] [args]
2015
2016
2016 %edit runs IPython's editor hook. The default version of this hook is
2017 %edit runs IPython's editor hook. The default version of this hook is
2017 set to call the __IPYTHON__.rc.editor command. This is read from your
2018 set to call the __IPYTHON__.rc.editor command. This is read from your
2018 environment variable $EDITOR. If this isn't found, it will default to
2019 environment variable $EDITOR. If this isn't found, it will default to
2019 vi under Linux/Unix and to notepad under Windows. See the end of this
2020 vi under Linux/Unix and to notepad under Windows. See the end of this
2020 docstring for how to change the editor hook.
2021 docstring for how to change the editor hook.
2021
2022
2022 You can also set the value of this editor via the command line option
2023 You can also set the value of this editor via the command line option
2023 '-editor' or in your ipythonrc file. This is useful if you wish to use
2024 '-editor' or in your ipythonrc file. This is useful if you wish to use
2024 specifically for IPython an editor different from your typical default
2025 specifically for IPython an editor different from your typical default
2025 (and for Windows users who typically don't set environment variables).
2026 (and for Windows users who typically don't set environment variables).
2026
2027
2027 This command allows you to conveniently edit multi-line code right in
2028 This command allows you to conveniently edit multi-line code right in
2028 your IPython session.
2029 your IPython session.
2029
2030
2030 If called without arguments, %edit opens up an empty editor with a
2031 If called without arguments, %edit opens up an empty editor with a
2031 temporary file and will execute the contents of this file when you
2032 temporary file and will execute the contents of this file when you
2032 close it (don't forget to save it!).
2033 close it (don't forget to save it!).
2033
2034
2034
2035
2035 Options:
2036 Options:
2036
2037
2037 -n <number>: open the editor at a specified line number. By default,
2038 -n <number>: open the editor at a specified line number. By default,
2038 the IPython editor hook uses the unix syntax 'editor +N filename', but
2039 the IPython editor hook uses the unix syntax 'editor +N filename', but
2039 you can configure this by providing your own modified hook if your
2040 you can configure this by providing your own modified hook if your
2040 favorite editor supports line-number specifications with a different
2041 favorite editor supports line-number specifications with a different
2041 syntax.
2042 syntax.
2042
2043
2043 -p: this will call the editor with the same data as the previous time
2044 -p: this will call the editor with the same data as the previous time
2044 it was used, regardless of how long ago (in your current session) it
2045 it was used, regardless of how long ago (in your current session) it
2045 was.
2046 was.
2046
2047
2047 -r: use 'raw' input. This option only applies to input taken from the
2048 -r: use 'raw' input. This option only applies to input taken from the
2048 user's history. By default, the 'processed' history is used, so that
2049 user's history. By default, the 'processed' history is used, so that
2049 magics are loaded in their transformed version to valid Python. If
2050 magics are loaded in their transformed version to valid Python. If
2050 this option is given, the raw input as typed as the command line is
2051 this option is given, the raw input as typed as the command line is
2051 used instead. When you exit the editor, it will be executed by
2052 used instead. When you exit the editor, it will be executed by
2052 IPython's own processor.
2053 IPython's own processor.
2053
2054
2054 -x: do not execute the edited code immediately upon exit. This is
2055 -x: do not execute the edited code immediately upon exit. This is
2055 mainly useful if you are editing programs which need to be called with
2056 mainly useful if you are editing programs which need to be called with
2056 command line arguments, which you can then do using %run.
2057 command line arguments, which you can then do using %run.
2057
2058
2058
2059
2059 Arguments:
2060 Arguments:
2060
2061
2061 If arguments are given, the following possibilites exist:
2062 If arguments are given, the following possibilites exist:
2062
2063
2063 - The arguments are numbers or pairs of colon-separated numbers (like
2064 - The arguments are numbers or pairs of colon-separated numbers (like
2064 1 4:8 9). These are interpreted as lines of previous input to be
2065 1 4:8 9). These are interpreted as lines of previous input to be
2065 loaded into the editor. The syntax is the same of the %macro command.
2066 loaded into the editor. The syntax is the same of the %macro command.
2066
2067
2067 - If the argument doesn't start with a number, it is evaluated as a
2068 - If the argument doesn't start with a number, it is evaluated as a
2068 variable and its contents loaded into the editor. You can thus edit
2069 variable and its contents loaded into the editor. You can thus edit
2069 any string which contains python code (including the result of
2070 any string which contains python code (including the result of
2070 previous edits).
2071 previous edits).
2071
2072
2072 - If the argument is the name of an object (other than a string),
2073 - If the argument is the name of an object (other than a string),
2073 IPython will try to locate the file where it was defined and open the
2074 IPython will try to locate the file where it was defined and open the
2074 editor at the point where it is defined. You can use `%edit function`
2075 editor at the point where it is defined. You can use `%edit function`
2075 to load an editor exactly at the point where 'function' is defined,
2076 to load an editor exactly at the point where 'function' is defined,
2076 edit it and have the file be executed automatically.
2077 edit it and have the file be executed automatically.
2077
2078
2078 If the object is a macro (see %macro for details), this opens up your
2079 If the object is a macro (see %macro for details), this opens up your
2079 specified editor with a temporary file containing the macro's data.
2080 specified editor with a temporary file containing the macro's data.
2080 Upon exit, the macro is reloaded with the contents of the file.
2081 Upon exit, the macro is reloaded with the contents of the file.
2081
2082
2082 Note: opening at an exact line is only supported under Unix, and some
2083 Note: opening at an exact line is only supported under Unix, and some
2083 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2084 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2084 '+NUMBER' parameter necessary for this feature. Good editors like
2085 '+NUMBER' parameter necessary for this feature. Good editors like
2085 (X)Emacs, vi, jed, pico and joe all do.
2086 (X)Emacs, vi, jed, pico and joe all do.
2086
2087
2087 - If the argument is not found as a variable, IPython will look for a
2088 - If the argument is not found as a variable, IPython will look for a
2088 file with that name (adding .py if necessary) and load it into the
2089 file with that name (adding .py if necessary) and load it into the
2089 editor. It will execute its contents with execfile() when you exit,
2090 editor. It will execute its contents with execfile() when you exit,
2090 loading any code in the file into your interactive namespace.
2091 loading any code in the file into your interactive namespace.
2091
2092
2092 After executing your code, %edit will return as output the code you
2093 After executing your code, %edit will return as output the code you
2093 typed in the editor (except when it was an existing file). This way
2094 typed in the editor (except when it was an existing file). This way
2094 you can reload the code in further invocations of %edit as a variable,
2095 you can reload the code in further invocations of %edit as a variable,
2095 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2096 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2096 the output.
2097 the output.
2097
2098
2098 Note that %edit is also available through the alias %ed.
2099 Note that %edit is also available through the alias %ed.
2099
2100
2100 This is an example of creating a simple function inside the editor and
2101 This is an example of creating a simple function inside the editor and
2101 then modifying it. First, start up the editor:
2102 then modifying it. First, start up the editor:
2102
2103
2103 In [1]: ed\\
2104 In [1]: ed\\
2104 Editing... done. Executing edited code...\\
2105 Editing... done. Executing edited code...\\
2105 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2106 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2106
2107
2107 We can then call the function foo():
2108 We can then call the function foo():
2108
2109
2109 In [2]: foo()\\
2110 In [2]: foo()\\
2110 foo() was defined in an editing session
2111 foo() was defined in an editing session
2111
2112
2112 Now we edit foo. IPython automatically loads the editor with the
2113 Now we edit foo. IPython automatically loads the editor with the
2113 (temporary) file where foo() was previously defined:
2114 (temporary) file where foo() was previously defined:
2114
2115
2115 In [3]: ed foo\\
2116 In [3]: ed foo\\
2116 Editing... done. Executing edited code...
2117 Editing... done. Executing edited code...
2117
2118
2118 And if we call foo() again we get the modified version:
2119 And if we call foo() again we get the modified version:
2119
2120
2120 In [4]: foo()\\
2121 In [4]: foo()\\
2121 foo() has now been changed!
2122 foo() has now been changed!
2122
2123
2123 Here is an example of how to edit a code snippet successive
2124 Here is an example of how to edit a code snippet successive
2124 times. First we call the editor:
2125 times. First we call the editor:
2125
2126
2126 In [8]: ed\\
2127 In [8]: ed\\
2127 Editing... done. Executing edited code...\\
2128 Editing... done. Executing edited code...\\
2128 hello\\
2129 hello\\
2129 Out[8]: "print 'hello'\\n"
2130 Out[8]: "print 'hello'\\n"
2130
2131
2131 Now we call it again with the previous output (stored in _):
2132 Now we call it again with the previous output (stored in _):
2132
2133
2133 In [9]: ed _\\
2134 In [9]: ed _\\
2134 Editing... done. Executing edited code...\\
2135 Editing... done. Executing edited code...\\
2135 hello world\\
2136 hello world\\
2136 Out[9]: "print 'hello world'\\n"
2137 Out[9]: "print 'hello world'\\n"
2137
2138
2138 Now we call it with the output #8 (stored in _8, also as Out[8]):
2139 Now we call it with the output #8 (stored in _8, also as Out[8]):
2139
2140
2140 In [10]: ed _8\\
2141 In [10]: ed _8\\
2141 Editing... done. Executing edited code...\\
2142 Editing... done. Executing edited code...\\
2142 hello again\\
2143 hello again\\
2143 Out[10]: "print 'hello again'\\n"
2144 Out[10]: "print 'hello again'\\n"
2144
2145
2145
2146
2146 Changing the default editor hook:
2147 Changing the default editor hook:
2147
2148
2148 If you wish to write your own editor hook, you can put it in a
2149 If you wish to write your own editor hook, you can put it in a
2149 configuration file which you load at startup time. The default hook
2150 configuration file which you load at startup time. The default hook
2150 is defined in the IPython.hooks module, and you can use that as a
2151 is defined in the IPython.hooks module, and you can use that as a
2151 starting example for further modifications. That file also has
2152 starting example for further modifications. That file also has
2152 general instructions on how to set a new hook for use once you've
2153 general instructions on how to set a new hook for use once you've
2153 defined it."""
2154 defined it."""
2154
2155
2155 # FIXME: This function has become a convoluted mess. It needs a
2156 # FIXME: This function has become a convoluted mess. It needs a
2156 # ground-up rewrite with clean, simple logic.
2157 # ground-up rewrite with clean, simple logic.
2157
2158
2158 def make_filename(arg):
2159 def make_filename(arg):
2159 "Make a filename from the given args"
2160 "Make a filename from the given args"
2160 try:
2161 try:
2161 filename = get_py_filename(arg)
2162 filename = get_py_filename(arg)
2162 except IOError:
2163 except IOError:
2163 if args.endswith('.py'):
2164 if args.endswith('.py'):
2164 filename = arg
2165 filename = arg
2165 else:
2166 else:
2166 filename = None
2167 filename = None
2167 return filename
2168 return filename
2168
2169
2169 # custom exceptions
2170 # custom exceptions
2170 class DataIsObject(Exception): pass
2171 class DataIsObject(Exception): pass
2171
2172
2172 opts,args = self.parse_options(parameter_s,'prxn:')
2173 opts,args = self.parse_options(parameter_s,'prxn:')
2173 # Set a few locals from the options for convenience:
2174 # Set a few locals from the options for convenience:
2174 opts_p = opts.has_key('p')
2175 opts_p = opts.has_key('p')
2175 opts_r = opts.has_key('r')
2176 opts_r = opts.has_key('r')
2176
2177
2177 # Default line number value
2178 # Default line number value
2178 lineno = opts.get('n',None)
2179 lineno = opts.get('n',None)
2179
2180
2180 if opts_p:
2181 if opts_p:
2181 args = '_%s' % last_call[0]
2182 args = '_%s' % last_call[0]
2182 if not self.shell.user_ns.has_key(args):
2183 if not self.shell.user_ns.has_key(args):
2183 args = last_call[1]
2184 args = last_call[1]
2184
2185
2185 # use last_call to remember the state of the previous call, but don't
2186 # use last_call to remember the state of the previous call, but don't
2186 # let it be clobbered by successive '-p' calls.
2187 # let it be clobbered by successive '-p' calls.
2187 try:
2188 try:
2188 last_call[0] = self.shell.outputcache.prompt_count
2189 last_call[0] = self.shell.outputcache.prompt_count
2189 if not opts_p:
2190 if not opts_p:
2190 last_call[1] = parameter_s
2191 last_call[1] = parameter_s
2191 except:
2192 except:
2192 pass
2193 pass
2193
2194
2194 # by default this is done with temp files, except when the given
2195 # by default this is done with temp files, except when the given
2195 # arg is a filename
2196 # arg is a filename
2196 use_temp = 1
2197 use_temp = 1
2197
2198
2198 if re.match(r'\d',args):
2199 if re.match(r'\d',args):
2199 # Mode where user specifies ranges of lines, like in %macro.
2200 # Mode where user specifies ranges of lines, like in %macro.
2200 # This means that you can't edit files whose names begin with
2201 # This means that you can't edit files whose names begin with
2201 # numbers this way. Tough.
2202 # numbers this way. Tough.
2202 ranges = args.split()
2203 ranges = args.split()
2203 data = ''.join(self.extract_input_slices(ranges,opts_r))
2204 data = ''.join(self.extract_input_slices(ranges,opts_r))
2204 elif args.endswith('.py'):
2205 elif args.endswith('.py'):
2205 filename = make_filename(args)
2206 filename = make_filename(args)
2206 data = ''
2207 data = ''
2207 use_temp = 0
2208 use_temp = 0
2208 elif args:
2209 elif args:
2209 try:
2210 try:
2210 # Load the parameter given as a variable. If not a string,
2211 # Load the parameter given as a variable. If not a string,
2211 # process it as an object instead (below)
2212 # process it as an object instead (below)
2212
2213
2213 #print '*** args',args,'type',type(args) # dbg
2214 #print '*** args',args,'type',type(args) # dbg
2214 data = eval(args,self.shell.user_ns)
2215 data = eval(args,self.shell.user_ns)
2215 if not type(data) in StringTypes:
2216 if not type(data) in StringTypes:
2216 raise DataIsObject
2217 raise DataIsObject
2217
2218
2218 except (NameError,SyntaxError):
2219 except (NameError,SyntaxError):
2219 # given argument is not a variable, try as a filename
2220 # given argument is not a variable, try as a filename
2220 filename = make_filename(args)
2221 filename = make_filename(args)
2221 if filename is None:
2222 if filename is None:
2222 warn("Argument given (%s) can't be found as a variable "
2223 warn("Argument given (%s) can't be found as a variable "
2223 "or as a filename." % args)
2224 "or as a filename." % args)
2224 return
2225 return
2225
2226
2226 data = ''
2227 data = ''
2227 use_temp = 0
2228 use_temp = 0
2228 except DataIsObject:
2229 except DataIsObject:
2229
2230
2230 # macros have a special edit function
2231 # macros have a special edit function
2231 if isinstance(data,Macro):
2232 if isinstance(data,Macro):
2232 self._edit_macro(args,data)
2233 self._edit_macro(args,data)
2233 return
2234 return
2234
2235
2235 # For objects, try to edit the file where they are defined
2236 # For objects, try to edit the file where they are defined
2236 try:
2237 try:
2237 filename = inspect.getabsfile(data)
2238 filename = inspect.getabsfile(data)
2238 datafile = 1
2239 datafile = 1
2239 except TypeError:
2240 except TypeError:
2240 filename = make_filename(args)
2241 filename = make_filename(args)
2241 datafile = 1
2242 datafile = 1
2242 warn('Could not find file where `%s` is defined.\n'
2243 warn('Could not find file where `%s` is defined.\n'
2243 'Opening a file named `%s`' % (args,filename))
2244 'Opening a file named `%s`' % (args,filename))
2244 # Now, make sure we can actually read the source (if it was in
2245 # Now, make sure we can actually read the source (if it was in
2245 # a temp file it's gone by now).
2246 # a temp file it's gone by now).
2246 if datafile:
2247 if datafile:
2247 try:
2248 try:
2248 if lineno is None:
2249 if lineno is None:
2249 lineno = inspect.getsourcelines(data)[1]
2250 lineno = inspect.getsourcelines(data)[1]
2250 except IOError:
2251 except IOError:
2251 filename = make_filename(args)
2252 filename = make_filename(args)
2252 if filename is None:
2253 if filename is None:
2253 warn('The file `%s` where `%s` was defined cannot '
2254 warn('The file `%s` where `%s` was defined cannot '
2254 'be read.' % (filename,data))
2255 'be read.' % (filename,data))
2255 return
2256 return
2256 use_temp = 0
2257 use_temp = 0
2257 else:
2258 else:
2258 data = ''
2259 data = ''
2259
2260
2260 if use_temp:
2261 if use_temp:
2261 filename = self.shell.mktempfile(data)
2262 filename = self.shell.mktempfile(data)
2262 print 'IPython will make a temporary file named:',filename
2263 print 'IPython will make a temporary file named:',filename
2263
2264
2264 # do actual editing here
2265 # do actual editing here
2265 print 'Editing...',
2266 print 'Editing...',
2266 sys.stdout.flush()
2267 sys.stdout.flush()
2267 self.shell.hooks.editor(filename,lineno)
2268 self.shell.hooks.editor(filename,lineno)
2268 if opts.has_key('x'): # -x prevents actual execution
2269 if opts.has_key('x'): # -x prevents actual execution
2269 print
2270 print
2270 else:
2271 else:
2271 print 'done. Executing edited code...'
2272 print 'done. Executing edited code...'
2272 if opts_r:
2273 if opts_r:
2273 self.shell.runlines(file_read(filename))
2274 self.shell.runlines(file_read(filename))
2274 else:
2275 else:
2275 self.shell.safe_execfile(filename,self.shell.user_ns,
2276 self.shell.safe_execfile(filename,self.shell.user_ns,
2276 self.shell.user_ns)
2277 self.shell.user_ns)
2277 if use_temp:
2278 if use_temp:
2278 try:
2279 try:
2279 return open(filename).read()
2280 return open(filename).read()
2280 except IOError,msg:
2281 except IOError,msg:
2281 if msg.filename == filename:
2282 if msg.filename == filename:
2282 warn('File not found. Did you forget to save?')
2283 warn('File not found. Did you forget to save?')
2283 return
2284 return
2284 else:
2285 else:
2285 self.shell.showtraceback()
2286 self.shell.showtraceback()
2286
2287
2287 def magic_xmode(self,parameter_s = ''):
2288 def magic_xmode(self,parameter_s = ''):
2288 """Switch modes for the exception handlers.
2289 """Switch modes for the exception handlers.
2289
2290
2290 Valid modes: Plain, Context and Verbose.
2291 Valid modes: Plain, Context and Verbose.
2291
2292
2292 If called without arguments, acts as a toggle."""
2293 If called without arguments, acts as a toggle."""
2293
2294
2294 def xmode_switch_err(name):
2295 def xmode_switch_err(name):
2295 warn('Error changing %s exception modes.\n%s' %
2296 warn('Error changing %s exception modes.\n%s' %
2296 (name,sys.exc_info()[1]))
2297 (name,sys.exc_info()[1]))
2297
2298
2298 shell = self.shell
2299 shell = self.shell
2299 new_mode = parameter_s.strip().capitalize()
2300 new_mode = parameter_s.strip().capitalize()
2300 try:
2301 try:
2301 shell.InteractiveTB.set_mode(mode=new_mode)
2302 shell.InteractiveTB.set_mode(mode=new_mode)
2302 print 'Exception reporting mode:',shell.InteractiveTB.mode
2303 print 'Exception reporting mode:',shell.InteractiveTB.mode
2303 except:
2304 except:
2304 xmode_switch_err('user')
2305 xmode_switch_err('user')
2305
2306
2306 # threaded shells use a special handler in sys.excepthook
2307 # threaded shells use a special handler in sys.excepthook
2307 if shell.isthreaded:
2308 if shell.isthreaded:
2308 try:
2309 try:
2309 shell.sys_excepthook.set_mode(mode=new_mode)
2310 shell.sys_excepthook.set_mode(mode=new_mode)
2310 except:
2311 except:
2311 xmode_switch_err('threaded')
2312 xmode_switch_err('threaded')
2312
2313
2313 def magic_colors(self,parameter_s = ''):
2314 def magic_colors(self,parameter_s = ''):
2314 """Switch color scheme for prompts, info system and exception handlers.
2315 """Switch color scheme for prompts, info system and exception handlers.
2315
2316
2316 Currently implemented schemes: NoColor, Linux, LightBG.
2317 Currently implemented schemes: NoColor, Linux, LightBG.
2317
2318
2318 Color scheme names are not case-sensitive."""
2319 Color scheme names are not case-sensitive."""
2319
2320
2320 def color_switch_err(name):
2321 def color_switch_err(name):
2321 warn('Error changing %s color schemes.\n%s' %
2322 warn('Error changing %s color schemes.\n%s' %
2322 (name,sys.exc_info()[1]))
2323 (name,sys.exc_info()[1]))
2323
2324
2324
2325
2325 new_scheme = parameter_s.strip()
2326 new_scheme = parameter_s.strip()
2326 if not new_scheme:
2327 if not new_scheme:
2327 raise UsageError(
2328 raise UsageError(
2328 "%colors: you must specify a color scheme. See '%colors?'")
2329 "%colors: you must specify a color scheme. See '%colors?'")
2329 return
2330 return
2330 # local shortcut
2331 # local shortcut
2331 shell = self.shell
2332 shell = self.shell
2332
2333
2333 import IPython.rlineimpl as readline
2334 import IPython.rlineimpl as readline
2334
2335
2335 if not readline.have_readline and sys.platform == "win32":
2336 if not readline.have_readline and sys.platform == "win32":
2336 msg = """\
2337 msg = """\
2337 Proper color support under MS Windows requires the pyreadline library.
2338 Proper color support under MS Windows requires the pyreadline library.
2338 You can find it at:
2339 You can find it at:
2339 http://ipython.scipy.org/moin/PyReadline/Intro
2340 http://ipython.scipy.org/moin/PyReadline/Intro
2340 Gary's readline needs the ctypes module, from:
2341 Gary's readline needs the ctypes module, from:
2341 http://starship.python.net/crew/theller/ctypes
2342 http://starship.python.net/crew/theller/ctypes
2342 (Note that ctypes is already part of Python versions 2.5 and newer).
2343 (Note that ctypes is already part of Python versions 2.5 and newer).
2343
2344
2344 Defaulting color scheme to 'NoColor'"""
2345 Defaulting color scheme to 'NoColor'"""
2345 new_scheme = 'NoColor'
2346 new_scheme = 'NoColor'
2346 warn(msg)
2347 warn(msg)
2347
2348
2348 # readline option is 0
2349 # readline option is 0
2349 if not shell.has_readline:
2350 if not shell.has_readline:
2350 new_scheme = 'NoColor'
2351 new_scheme = 'NoColor'
2351
2352
2352 # Set prompt colors
2353 # Set prompt colors
2353 try:
2354 try:
2354 shell.outputcache.set_colors(new_scheme)
2355 shell.outputcache.set_colors(new_scheme)
2355 except:
2356 except:
2356 color_switch_err('prompt')
2357 color_switch_err('prompt')
2357 else:
2358 else:
2358 shell.rc.colors = \
2359 shell.rc.colors = \
2359 shell.outputcache.color_table.active_scheme_name
2360 shell.outputcache.color_table.active_scheme_name
2360 # Set exception colors
2361 # Set exception colors
2361 try:
2362 try:
2362 shell.InteractiveTB.set_colors(scheme = new_scheme)
2363 shell.InteractiveTB.set_colors(scheme = new_scheme)
2363 shell.SyntaxTB.set_colors(scheme = new_scheme)
2364 shell.SyntaxTB.set_colors(scheme = new_scheme)
2364 except:
2365 except:
2365 color_switch_err('exception')
2366 color_switch_err('exception')
2366
2367
2367 # threaded shells use a verbose traceback in sys.excepthook
2368 # threaded shells use a verbose traceback in sys.excepthook
2368 if shell.isthreaded:
2369 if shell.isthreaded:
2369 try:
2370 try:
2370 shell.sys_excepthook.set_colors(scheme=new_scheme)
2371 shell.sys_excepthook.set_colors(scheme=new_scheme)
2371 except:
2372 except:
2372 color_switch_err('system exception handler')
2373 color_switch_err('system exception handler')
2373
2374
2374 # Set info (for 'object?') colors
2375 # Set info (for 'object?') colors
2375 if shell.rc.color_info:
2376 if shell.rc.color_info:
2376 try:
2377 try:
2377 shell.inspector.set_active_scheme(new_scheme)
2378 shell.inspector.set_active_scheme(new_scheme)
2378 except:
2379 except:
2379 color_switch_err('object inspector')
2380 color_switch_err('object inspector')
2380 else:
2381 else:
2381 shell.inspector.set_active_scheme('NoColor')
2382 shell.inspector.set_active_scheme('NoColor')
2382
2383
2383 def magic_color_info(self,parameter_s = ''):
2384 def magic_color_info(self,parameter_s = ''):
2384 """Toggle color_info.
2385 """Toggle color_info.
2385
2386
2386 The color_info configuration parameter controls whether colors are
2387 The color_info configuration parameter controls whether colors are
2387 used for displaying object details (by things like %psource, %pfile or
2388 used for displaying object details (by things like %psource, %pfile or
2388 the '?' system). This function toggles this value with each call.
2389 the '?' system). This function toggles this value with each call.
2389
2390
2390 Note that unless you have a fairly recent pager (less works better
2391 Note that unless you have a fairly recent pager (less works better
2391 than more) in your system, using colored object information displays
2392 than more) in your system, using colored object information displays
2392 will not work properly. Test it and see."""
2393 will not work properly. Test it and see."""
2393
2394
2394 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2395 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2395 self.magic_colors(self.shell.rc.colors)
2396 self.magic_colors(self.shell.rc.colors)
2396 print 'Object introspection functions have now coloring:',
2397 print 'Object introspection functions have now coloring:',
2397 print ['OFF','ON'][self.shell.rc.color_info]
2398 print ['OFF','ON'][self.shell.rc.color_info]
2398
2399
2399 def magic_Pprint(self, parameter_s=''):
2400 def magic_Pprint(self, parameter_s=''):
2400 """Toggle pretty printing on/off."""
2401 """Toggle pretty printing on/off."""
2401
2402
2402 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2403 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2403 print 'Pretty printing has been turned', \
2404 print 'Pretty printing has been turned', \
2404 ['OFF','ON'][self.shell.rc.pprint]
2405 ['OFF','ON'][self.shell.rc.pprint]
2405
2406
2406 def magic_exit(self, parameter_s=''):
2407 def magic_exit(self, parameter_s=''):
2407 """Exit IPython, confirming if configured to do so.
2408 """Exit IPython, confirming if configured to do so.
2408
2409
2409 You can configure whether IPython asks for confirmation upon exit by
2410 You can configure whether IPython asks for confirmation upon exit by
2410 setting the confirm_exit flag in the ipythonrc file."""
2411 setting the confirm_exit flag in the ipythonrc file."""
2411
2412
2412 self.shell.exit()
2413 self.shell.exit()
2413
2414
2414 def magic_quit(self, parameter_s=''):
2415 def magic_quit(self, parameter_s=''):
2415 """Exit IPython, confirming if configured to do so (like %exit)"""
2416 """Exit IPython, confirming if configured to do so (like %exit)"""
2416
2417
2417 self.shell.exit()
2418 self.shell.exit()
2418
2419
2419 def magic_Exit(self, parameter_s=''):
2420 def magic_Exit(self, parameter_s=''):
2420 """Exit IPython without confirmation."""
2421 """Exit IPython without confirmation."""
2421
2422
2422 self.shell.exit_now = True
2423 self.shell.exit_now = True
2423
2424
2424 #......................................................................
2425 #......................................................................
2425 # Functions to implement unix shell-type things
2426 # Functions to implement unix shell-type things
2426
2427
2427 def magic_alias(self, parameter_s = ''):
2428 def magic_alias(self, parameter_s = ''):
2428 """Define an alias for a system command.
2429 """Define an alias for a system command.
2429
2430
2430 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2431 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2431
2432
2432 Then, typing 'alias_name params' will execute the system command 'cmd
2433 Then, typing 'alias_name params' will execute the system command 'cmd
2433 params' (from your underlying operating system).
2434 params' (from your underlying operating system).
2434
2435
2435 Aliases have lower precedence than magic functions and Python normal
2436 Aliases have lower precedence than magic functions and Python normal
2436 variables, so if 'foo' is both a Python variable and an alias, the
2437 variables, so if 'foo' is both a Python variable and an alias, the
2437 alias can not be executed until 'del foo' removes the Python variable.
2438 alias can not be executed until 'del foo' removes the Python variable.
2438
2439
2439 You can use the %l specifier in an alias definition to represent the
2440 You can use the %l specifier in an alias definition to represent the
2440 whole line when the alias is called. For example:
2441 whole line when the alias is called. For example:
2441
2442
2442 In [2]: alias all echo "Input in brackets: <%l>"\\
2443 In [2]: alias all echo "Input in brackets: <%l>"\\
2443 In [3]: all hello world\\
2444 In [3]: all hello world\\
2444 Input in brackets: <hello world>
2445 Input in brackets: <hello world>
2445
2446
2446 You can also define aliases with parameters using %s specifiers (one
2447 You can also define aliases with parameters using %s specifiers (one
2447 per parameter):
2448 per parameter):
2448
2449
2449 In [1]: alias parts echo first %s second %s\\
2450 In [1]: alias parts echo first %s second %s\\
2450 In [2]: %parts A B\\
2451 In [2]: %parts A B\\
2451 first A second B\\
2452 first A second B\\
2452 In [3]: %parts A\\
2453 In [3]: %parts A\\
2453 Incorrect number of arguments: 2 expected.\\
2454 Incorrect number of arguments: 2 expected.\\
2454 parts is an alias to: 'echo first %s second %s'
2455 parts is an alias to: 'echo first %s second %s'
2455
2456
2456 Note that %l and %s are mutually exclusive. You can only use one or
2457 Note that %l and %s are mutually exclusive. You can only use one or
2457 the other in your aliases.
2458 the other in your aliases.
2458
2459
2459 Aliases expand Python variables just like system calls using ! or !!
2460 Aliases expand Python variables just like system calls using ! or !!
2460 do: all expressions prefixed with '$' get expanded. For details of
2461 do: all expressions prefixed with '$' get expanded. For details of
2461 the semantic rules, see PEP-215:
2462 the semantic rules, see PEP-215:
2462 http://www.python.org/peps/pep-0215.html. This is the library used by
2463 http://www.python.org/peps/pep-0215.html. This is the library used by
2463 IPython for variable expansion. If you want to access a true shell
2464 IPython for variable expansion. If you want to access a true shell
2464 variable, an extra $ is necessary to prevent its expansion by IPython:
2465 variable, an extra $ is necessary to prevent its expansion by IPython:
2465
2466
2466 In [6]: alias show echo\\
2467 In [6]: alias show echo\\
2467 In [7]: PATH='A Python string'\\
2468 In [7]: PATH='A Python string'\\
2468 In [8]: show $PATH\\
2469 In [8]: show $PATH\\
2469 A Python string\\
2470 A Python string\\
2470 In [9]: show $$PATH\\
2471 In [9]: show $$PATH\\
2471 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2472 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2472
2473
2473 You can use the alias facility to acess all of $PATH. See the %rehash
2474 You can use the alias facility to acess all of $PATH. See the %rehash
2474 and %rehashx functions, which automatically create aliases for the
2475 and %rehashx functions, which automatically create aliases for the
2475 contents of your $PATH.
2476 contents of your $PATH.
2476
2477
2477 If called with no parameters, %alias prints the current alias table."""
2478 If called with no parameters, %alias prints the current alias table."""
2478
2479
2479 par = parameter_s.strip()
2480 par = parameter_s.strip()
2480 if not par:
2481 if not par:
2481 stored = self.db.get('stored_aliases', {} )
2482 stored = self.db.get('stored_aliases', {} )
2482 atab = self.shell.alias_table
2483 atab = self.shell.alias_table
2483 aliases = atab.keys()
2484 aliases = atab.keys()
2484 aliases.sort()
2485 aliases.sort()
2485 res = []
2486 res = []
2486 showlast = []
2487 showlast = []
2487 for alias in aliases:
2488 for alias in aliases:
2488 special = False
2489 special = False
2489 try:
2490 try:
2490 tgt = atab[alias][1]
2491 tgt = atab[alias][1]
2491 except (TypeError, AttributeError):
2492 except (TypeError, AttributeError):
2492 # unsubscriptable? probably a callable
2493 # unsubscriptable? probably a callable
2493 tgt = atab[alias]
2494 tgt = atab[alias]
2494 special = True
2495 special = True
2495 # 'interesting' aliases
2496 # 'interesting' aliases
2496 if (alias in stored or
2497 if (alias in stored or
2497 special or
2498 special or
2498 alias.lower() != os.path.splitext(tgt)[0].lower() or
2499 alias.lower() != os.path.splitext(tgt)[0].lower() or
2499 ' ' in tgt):
2500 ' ' in tgt):
2500 showlast.append((alias, tgt))
2501 showlast.append((alias, tgt))
2501 else:
2502 else:
2502 res.append((alias, tgt ))
2503 res.append((alias, tgt ))
2503
2504
2504 # show most interesting aliases last
2505 # show most interesting aliases last
2505 res.extend(showlast)
2506 res.extend(showlast)
2506 print "Total number of aliases:",len(aliases)
2507 print "Total number of aliases:",len(aliases)
2507 return res
2508 return res
2508 try:
2509 try:
2509 alias,cmd = par.split(None,1)
2510 alias,cmd = par.split(None,1)
2510 except:
2511 except:
2511 print OInspect.getdoc(self.magic_alias)
2512 print OInspect.getdoc(self.magic_alias)
2512 else:
2513 else:
2513 nargs = cmd.count('%s')
2514 nargs = cmd.count('%s')
2514 if nargs>0 and cmd.find('%l')>=0:
2515 if nargs>0 and cmd.find('%l')>=0:
2515 error('The %s and %l specifiers are mutually exclusive '
2516 error('The %s and %l specifiers are mutually exclusive '
2516 'in alias definitions.')
2517 'in alias definitions.')
2517 else: # all looks OK
2518 else: # all looks OK
2518 self.shell.alias_table[alias] = (nargs,cmd)
2519 self.shell.alias_table[alias] = (nargs,cmd)
2519 self.shell.alias_table_validate(verbose=0)
2520 self.shell.alias_table_validate(verbose=0)
2520 # end magic_alias
2521 # end magic_alias
2521
2522
2522 def magic_unalias(self, parameter_s = ''):
2523 def magic_unalias(self, parameter_s = ''):
2523 """Remove an alias"""
2524 """Remove an alias"""
2524
2525
2525 aname = parameter_s.strip()
2526 aname = parameter_s.strip()
2526 if aname in self.shell.alias_table:
2527 if aname in self.shell.alias_table:
2527 del self.shell.alias_table[aname]
2528 del self.shell.alias_table[aname]
2528 stored = self.db.get('stored_aliases', {} )
2529 stored = self.db.get('stored_aliases', {} )
2529 if aname in stored:
2530 if aname in stored:
2530 print "Removing %stored alias",aname
2531 print "Removing %stored alias",aname
2531 del stored[aname]
2532 del stored[aname]
2532 self.db['stored_aliases'] = stored
2533 self.db['stored_aliases'] = stored
2533
2534
2534
2535
2535 def magic_rehashx(self, parameter_s = ''):
2536 def magic_rehashx(self, parameter_s = ''):
2536 """Update the alias table with all executable files in $PATH.
2537 """Update the alias table with all executable files in $PATH.
2537
2538
2538 This version explicitly checks that every entry in $PATH is a file
2539 This version explicitly checks that every entry in $PATH is a file
2539 with execute access (os.X_OK), so it is much slower than %rehash.
2540 with execute access (os.X_OK), so it is much slower than %rehash.
2540
2541
2541 Under Windows, it checks executability as a match agains a
2542 Under Windows, it checks executability as a match agains a
2542 '|'-separated string of extensions, stored in the IPython config
2543 '|'-separated string of extensions, stored in the IPython config
2543 variable win_exec_ext. This defaults to 'exe|com|bat'.
2544 variable win_exec_ext. This defaults to 'exe|com|bat'.
2544
2545
2545 This function also resets the root module cache of module completer,
2546 This function also resets the root module cache of module completer,
2546 used on slow filesystems.
2547 used on slow filesystems.
2547 """
2548 """
2548
2549
2549
2550
2550 ip = self.api
2551 ip = self.api
2551
2552
2552 # for the benefit of module completer in ipy_completers.py
2553 # for the benefit of module completer in ipy_completers.py
2553 del ip.db['rootmodules']
2554 del ip.db['rootmodules']
2554
2555
2555 path = [os.path.abspath(os.path.expanduser(p)) for p in
2556 path = [os.path.abspath(os.path.expanduser(p)) for p in
2556 os.environ.get('PATH','').split(os.pathsep)]
2557 os.environ.get('PATH','').split(os.pathsep)]
2557 path = filter(os.path.isdir,path)
2558 path = filter(os.path.isdir,path)
2558
2559
2559 alias_table = self.shell.alias_table
2560 alias_table = self.shell.alias_table
2560 syscmdlist = []
2561 syscmdlist = []
2561 if os.name == 'posix':
2562 if os.name == 'posix':
2562 isexec = lambda fname:os.path.isfile(fname) and \
2563 isexec = lambda fname:os.path.isfile(fname) and \
2563 os.access(fname,os.X_OK)
2564 os.access(fname,os.X_OK)
2564 else:
2565 else:
2565
2566
2566 try:
2567 try:
2567 winext = os.environ['pathext'].replace(';','|').replace('.','')
2568 winext = os.environ['pathext'].replace(';','|').replace('.','')
2568 except KeyError:
2569 except KeyError:
2569 winext = 'exe|com|bat|py'
2570 winext = 'exe|com|bat|py'
2570 if 'py' not in winext:
2571 if 'py' not in winext:
2571 winext += '|py'
2572 winext += '|py'
2572 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2573 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2573 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2574 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2574 savedir = os.getcwd()
2575 savedir = os.getcwd()
2575 try:
2576 try:
2576 # write the whole loop for posix/Windows so we don't have an if in
2577 # write the whole loop for posix/Windows so we don't have an if in
2577 # the innermost part
2578 # the innermost part
2578 if os.name == 'posix':
2579 if os.name == 'posix':
2579 for pdir in path:
2580 for pdir in path:
2580 os.chdir(pdir)
2581 os.chdir(pdir)
2581 for ff in os.listdir(pdir):
2582 for ff in os.listdir(pdir):
2582 if isexec(ff) and ff not in self.shell.no_alias:
2583 if isexec(ff) and ff not in self.shell.no_alias:
2583 # each entry in the alias table must be (N,name),
2584 # each entry in the alias table must be (N,name),
2584 # where N is the number of positional arguments of the
2585 # where N is the number of positional arguments of the
2585 # alias.
2586 # alias.
2586 alias_table[ff] = (0,ff)
2587 alias_table[ff] = (0,ff)
2587 syscmdlist.append(ff)
2588 syscmdlist.append(ff)
2588 else:
2589 else:
2589 for pdir in path:
2590 for pdir in path:
2590 os.chdir(pdir)
2591 os.chdir(pdir)
2591 for ff in os.listdir(pdir):
2592 for ff in os.listdir(pdir):
2592 base, ext = os.path.splitext(ff)
2593 base, ext = os.path.splitext(ff)
2593 if isexec(ff) and base not in self.shell.no_alias:
2594 if isexec(ff) and base not in self.shell.no_alias:
2594 if ext.lower() == '.exe':
2595 if ext.lower() == '.exe':
2595 ff = base
2596 ff = base
2596 alias_table[base.lower()] = (0,ff)
2597 alias_table[base.lower()] = (0,ff)
2597 syscmdlist.append(ff)
2598 syscmdlist.append(ff)
2598 # Make sure the alias table doesn't contain keywords or builtins
2599 # Make sure the alias table doesn't contain keywords or builtins
2599 self.shell.alias_table_validate()
2600 self.shell.alias_table_validate()
2600 # Call again init_auto_alias() so we get 'rm -i' and other
2601 # Call again init_auto_alias() so we get 'rm -i' and other
2601 # modified aliases since %rehashx will probably clobber them
2602 # modified aliases since %rehashx will probably clobber them
2602
2603
2603 # no, we don't want them. if %rehashx clobbers them, good,
2604 # no, we don't want them. if %rehashx clobbers them, good,
2604 # we'll probably get better versions
2605 # we'll probably get better versions
2605 # self.shell.init_auto_alias()
2606 # self.shell.init_auto_alias()
2606 db = ip.db
2607 db = ip.db
2607 db['syscmdlist'] = syscmdlist
2608 db['syscmdlist'] = syscmdlist
2608 finally:
2609 finally:
2609 os.chdir(savedir)
2610 os.chdir(savedir)
2610
2611
2611 def magic_pwd(self, parameter_s = ''):
2612 def magic_pwd(self, parameter_s = ''):
2612 """Return the current working directory path."""
2613 """Return the current working directory path."""
2613 return os.getcwd()
2614 return os.getcwd()
2614
2615
2615 def magic_cd(self, parameter_s=''):
2616 def magic_cd(self, parameter_s=''):
2616 """Change the current working directory.
2617 """Change the current working directory.
2617
2618
2618 This command automatically maintains an internal list of directories
2619 This command automatically maintains an internal list of directories
2619 you visit during your IPython session, in the variable _dh. The
2620 you visit during your IPython session, in the variable _dh. The
2620 command %dhist shows this history nicely formatted. You can also
2621 command %dhist shows this history nicely formatted. You can also
2621 do 'cd -<tab>' to see directory history conveniently.
2622 do 'cd -<tab>' to see directory history conveniently.
2622
2623
2623 Usage:
2624 Usage:
2624
2625
2625 cd 'dir': changes to directory 'dir'.
2626 cd 'dir': changes to directory 'dir'.
2626
2627
2627 cd -: changes to the last visited directory.
2628 cd -: changes to the last visited directory.
2628
2629
2629 cd -<n>: changes to the n-th directory in the directory history.
2630 cd -<n>: changes to the n-th directory in the directory history.
2630
2631
2631 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2632 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2632 (note: cd <bookmark_name> is enough if there is no
2633 (note: cd <bookmark_name> is enough if there is no
2633 directory <bookmark_name>, but a bookmark with the name exists.)
2634 directory <bookmark_name>, but a bookmark with the name exists.)
2634 'cd -b <tab>' allows you to tab-complete bookmark names.
2635 'cd -b <tab>' allows you to tab-complete bookmark names.
2635
2636
2636 Options:
2637 Options:
2637
2638
2638 -q: quiet. Do not print the working directory after the cd command is
2639 -q: quiet. Do not print the working directory after the cd command is
2639 executed. By default IPython's cd command does print this directory,
2640 executed. By default IPython's cd command does print this directory,
2640 since the default prompts do not display path information.
2641 since the default prompts do not display path information.
2641
2642
2642 Note that !cd doesn't work for this purpose because the shell where
2643 Note that !cd doesn't work for this purpose because the shell where
2643 !command runs is immediately discarded after executing 'command'."""
2644 !command runs is immediately discarded after executing 'command'."""
2644
2645
2645 parameter_s = parameter_s.strip()
2646 parameter_s = parameter_s.strip()
2646 #bkms = self.shell.persist.get("bookmarks",{})
2647 #bkms = self.shell.persist.get("bookmarks",{})
2647
2648
2648 numcd = re.match(r'(-)(\d+)$',parameter_s)
2649 numcd = re.match(r'(-)(\d+)$',parameter_s)
2649 # jump in directory history by number
2650 # jump in directory history by number
2650 if numcd:
2651 if numcd:
2651 nn = int(numcd.group(2))
2652 nn = int(numcd.group(2))
2652 try:
2653 try:
2653 ps = self.shell.user_ns['_dh'][nn]
2654 ps = self.shell.user_ns['_dh'][nn]
2654 except IndexError:
2655 except IndexError:
2655 print 'The requested directory does not exist in history.'
2656 print 'The requested directory does not exist in history.'
2656 return
2657 return
2657 else:
2658 else:
2658 opts = {}
2659 opts = {}
2659 else:
2660 else:
2660 #turn all non-space-escaping backslashes to slashes,
2661 #turn all non-space-escaping backslashes to slashes,
2661 # for c:\windows\directory\names\
2662 # for c:\windows\directory\names\
2662 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2663 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2663 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2664 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2664 # jump to previous
2665 # jump to previous
2665 if ps == '-':
2666 if ps == '-':
2666 try:
2667 try:
2667 ps = self.shell.user_ns['_dh'][-2]
2668 ps = self.shell.user_ns['_dh'][-2]
2668 except IndexError:
2669 except IndexError:
2669 raise UsageError('%cd -: No previous directory to change to.')
2670 raise UsageError('%cd -: No previous directory to change to.')
2670 # jump to bookmark if needed
2671 # jump to bookmark if needed
2671 else:
2672 else:
2672 if not os.path.isdir(ps) or opts.has_key('b'):
2673 if not os.path.isdir(ps) or opts.has_key('b'):
2673 bkms = self.db.get('bookmarks', {})
2674 bkms = self.db.get('bookmarks', {})
2674
2675
2675 if bkms.has_key(ps):
2676 if bkms.has_key(ps):
2676 target = bkms[ps]
2677 target = bkms[ps]
2677 print '(bookmark:%s) -> %s' % (ps,target)
2678 print '(bookmark:%s) -> %s' % (ps,target)
2678 ps = target
2679 ps = target
2679 else:
2680 else:
2680 if opts.has_key('b'):
2681 if opts.has_key('b'):
2681 raise UsageError("Bookmark '%s' not found. "
2682 raise UsageError("Bookmark '%s' not found. "
2682 "Use '%%bookmark -l' to see your bookmarks." % ps)
2683 "Use '%%bookmark -l' to see your bookmarks." % ps)
2683
2684
2684 # at this point ps should point to the target dir
2685 # at this point ps should point to the target dir
2685 if ps:
2686 if ps:
2686 try:
2687 try:
2687 os.chdir(os.path.expanduser(ps))
2688 os.chdir(os.path.expanduser(ps))
2688 if self.shell.rc.term_title:
2689 if self.shell.rc.term_title:
2689 #print 'set term title:',self.shell.rc.term_title # dbg
2690 #print 'set term title:',self.shell.rc.term_title # dbg
2690 ttitle = 'IPy ' + abbrev_cwd()
2691 ttitle = 'IPy ' + abbrev_cwd()
2691 platutils.set_term_title(ttitle)
2692 platutils.set_term_title(ttitle)
2692 except OSError:
2693 except OSError:
2693 print sys.exc_info()[1]
2694 print sys.exc_info()[1]
2694 else:
2695 else:
2695 cwd = os.getcwd()
2696 cwd = os.getcwd()
2696 dhist = self.shell.user_ns['_dh']
2697 dhist = self.shell.user_ns['_dh']
2697 dhist.append(cwd)
2698 dhist.append(cwd)
2698 self.db['dhist'] = compress_dhist(dhist)[-100:]
2699 self.db['dhist'] = compress_dhist(dhist)[-100:]
2699
2700
2700 else:
2701 else:
2701 os.chdir(self.shell.home_dir)
2702 os.chdir(self.shell.home_dir)
2702 if self.shell.rc.term_title:
2703 if self.shell.rc.term_title:
2703 platutils.set_term_title("IPy ~")
2704 platutils.set_term_title("IPy ~")
2704 cwd = os.getcwd()
2705 cwd = os.getcwd()
2705 dhist = self.shell.user_ns['_dh']
2706 dhist = self.shell.user_ns['_dh']
2706 dhist.append(cwd)
2707 dhist.append(cwd)
2707 self.db['dhist'] = compress_dhist(dhist)[-100:]
2708 self.db['dhist'] = compress_dhist(dhist)[-100:]
2708 if not 'q' in opts and self.shell.user_ns['_dh']:
2709 if not 'q' in opts and self.shell.user_ns['_dh']:
2709 print self.shell.user_ns['_dh'][-1]
2710 print self.shell.user_ns['_dh'][-1]
2710
2711
2711
2712
2712 def magic_env(self, parameter_s=''):
2713 def magic_env(self, parameter_s=''):
2713 """List environment variables."""
2714 """List environment variables."""
2714
2715
2715 return os.environ.data
2716 return os.environ.data
2716
2717
2717 def magic_pushd(self, parameter_s=''):
2718 def magic_pushd(self, parameter_s=''):
2718 """Place the current dir on stack and change directory.
2719 """Place the current dir on stack and change directory.
2719
2720
2720 Usage:\\
2721 Usage:\\
2721 %pushd ['dirname']
2722 %pushd ['dirname']
2722 """
2723 """
2723
2724
2724 dir_s = self.shell.dir_stack
2725 dir_s = self.shell.dir_stack
2725 tgt = os.path.expanduser(parameter_s)
2726 tgt = os.path.expanduser(parameter_s)
2726 cwd = os.getcwd().replace(self.home_dir,'~')
2727 cwd = os.getcwd().replace(self.home_dir,'~')
2727 if tgt:
2728 if tgt:
2728 self.magic_cd(parameter_s)
2729 self.magic_cd(parameter_s)
2729 dir_s.insert(0,cwd)
2730 dir_s.insert(0,cwd)
2730 return self.magic_dirs()
2731 return self.magic_dirs()
2731
2732
2732 def magic_popd(self, parameter_s=''):
2733 def magic_popd(self, parameter_s=''):
2733 """Change to directory popped off the top of the stack.
2734 """Change to directory popped off the top of the stack.
2734 """
2735 """
2735 if not self.shell.dir_stack:
2736 if not self.shell.dir_stack:
2736 raise UsageError("%popd on empty stack")
2737 raise UsageError("%popd on empty stack")
2737 top = self.shell.dir_stack.pop(0)
2738 top = self.shell.dir_stack.pop(0)
2738 self.magic_cd(top)
2739 self.magic_cd(top)
2739 print "popd ->",top
2740 print "popd ->",top
2740
2741
2741 def magic_dirs(self, parameter_s=''):
2742 def magic_dirs(self, parameter_s=''):
2742 """Return the current directory stack."""
2743 """Return the current directory stack."""
2743
2744
2744 return self.shell.dir_stack
2745 return self.shell.dir_stack
2745
2746
2746 def magic_dhist(self, parameter_s=''):
2747 def magic_dhist(self, parameter_s=''):
2747 """Print your history of visited directories.
2748 """Print your history of visited directories.
2748
2749
2749 %dhist -> print full history\\
2750 %dhist -> print full history\\
2750 %dhist n -> print last n entries only\\
2751 %dhist n -> print last n entries only\\
2751 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2752 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2752
2753
2753 This history is automatically maintained by the %cd command, and
2754 This history is automatically maintained by the %cd command, and
2754 always available as the global list variable _dh. You can use %cd -<n>
2755 always available as the global list variable _dh. You can use %cd -<n>
2755 to go to directory number <n>.
2756 to go to directory number <n>.
2756
2757
2757 Note that most of time, you should view directory history by entering
2758 Note that most of time, you should view directory history by entering
2758 cd -<TAB>.
2759 cd -<TAB>.
2759
2760
2760 """
2761 """
2761
2762
2762 dh = self.shell.user_ns['_dh']
2763 dh = self.shell.user_ns['_dh']
2763 if parameter_s:
2764 if parameter_s:
2764 try:
2765 try:
2765 args = map(int,parameter_s.split())
2766 args = map(int,parameter_s.split())
2766 except:
2767 except:
2767 self.arg_err(Magic.magic_dhist)
2768 self.arg_err(Magic.magic_dhist)
2768 return
2769 return
2769 if len(args) == 1:
2770 if len(args) == 1:
2770 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2771 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2771 elif len(args) == 2:
2772 elif len(args) == 2:
2772 ini,fin = args
2773 ini,fin = args
2773 else:
2774 else:
2774 self.arg_err(Magic.magic_dhist)
2775 self.arg_err(Magic.magic_dhist)
2775 return
2776 return
2776 else:
2777 else:
2777 ini,fin = 0,len(dh)
2778 ini,fin = 0,len(dh)
2778 nlprint(dh,
2779 nlprint(dh,
2779 header = 'Directory history (kept in _dh)',
2780 header = 'Directory history (kept in _dh)',
2780 start=ini,stop=fin)
2781 start=ini,stop=fin)
2781
2782
2782
2783
2783 def magic_sc(self, parameter_s=''):
2784 def magic_sc(self, parameter_s=''):
2784 """Shell capture - execute a shell command and capture its output.
2785 """Shell capture - execute a shell command and capture its output.
2785
2786
2786 DEPRECATED. Suboptimal, retained for backwards compatibility.
2787 DEPRECATED. Suboptimal, retained for backwards compatibility.
2787
2788
2788 You should use the form 'var = !command' instead. Example:
2789 You should use the form 'var = !command' instead. Example:
2789
2790
2790 "%sc -l myfiles = ls ~" should now be written as
2791 "%sc -l myfiles = ls ~" should now be written as
2791
2792
2792 "myfiles = !ls ~"
2793 "myfiles = !ls ~"
2793
2794
2794 myfiles.s, myfiles.l and myfiles.n still apply as documented
2795 myfiles.s, myfiles.l and myfiles.n still apply as documented
2795 below.
2796 below.
2796
2797
2797 --
2798 --
2798 %sc [options] varname=command
2799 %sc [options] varname=command
2799
2800
2800 IPython will run the given command using commands.getoutput(), and
2801 IPython will run the given command using commands.getoutput(), and
2801 will then update the user's interactive namespace with a variable
2802 will then update the user's interactive namespace with a variable
2802 called varname, containing the value of the call. Your command can
2803 called varname, containing the value of the call. Your command can
2803 contain shell wildcards, pipes, etc.
2804 contain shell wildcards, pipes, etc.
2804
2805
2805 The '=' sign in the syntax is mandatory, and the variable name you
2806 The '=' sign in the syntax is mandatory, and the variable name you
2806 supply must follow Python's standard conventions for valid names.
2807 supply must follow Python's standard conventions for valid names.
2807
2808
2808 (A special format without variable name exists for internal use)
2809 (A special format without variable name exists for internal use)
2809
2810
2810 Options:
2811 Options:
2811
2812
2812 -l: list output. Split the output on newlines into a list before
2813 -l: list output. Split the output on newlines into a list before
2813 assigning it to the given variable. By default the output is stored
2814 assigning it to the given variable. By default the output is stored
2814 as a single string.
2815 as a single string.
2815
2816
2816 -v: verbose. Print the contents of the variable.
2817 -v: verbose. Print the contents of the variable.
2817
2818
2818 In most cases you should not need to split as a list, because the
2819 In most cases you should not need to split as a list, because the
2819 returned value is a special type of string which can automatically
2820 returned value is a special type of string which can automatically
2820 provide its contents either as a list (split on newlines) or as a
2821 provide its contents either as a list (split on newlines) or as a
2821 space-separated string. These are convenient, respectively, either
2822 space-separated string. These are convenient, respectively, either
2822 for sequential processing or to be passed to a shell command.
2823 for sequential processing or to be passed to a shell command.
2823
2824
2824 For example:
2825 For example:
2825
2826
2826 # Capture into variable a
2827 # Capture into variable a
2827 In [9]: sc a=ls *py
2828 In [9]: sc a=ls *py
2828
2829
2829 # a is a string with embedded newlines
2830 # a is a string with embedded newlines
2830 In [10]: a
2831 In [10]: a
2831 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2832 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2832
2833
2833 # which can be seen as a list:
2834 # which can be seen as a list:
2834 In [11]: a.l
2835 In [11]: a.l
2835 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2836 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2836
2837
2837 # or as a whitespace-separated string:
2838 # or as a whitespace-separated string:
2838 In [12]: a.s
2839 In [12]: a.s
2839 Out[12]: 'setup.py win32_manual_post_install.py'
2840 Out[12]: 'setup.py win32_manual_post_install.py'
2840
2841
2841 # a.s is useful to pass as a single command line:
2842 # a.s is useful to pass as a single command line:
2842 In [13]: !wc -l $a.s
2843 In [13]: !wc -l $a.s
2843 146 setup.py
2844 146 setup.py
2844 130 win32_manual_post_install.py
2845 130 win32_manual_post_install.py
2845 276 total
2846 276 total
2846
2847
2847 # while the list form is useful to loop over:
2848 # while the list form is useful to loop over:
2848 In [14]: for f in a.l:
2849 In [14]: for f in a.l:
2849 ....: !wc -l $f
2850 ....: !wc -l $f
2850 ....:
2851 ....:
2851 146 setup.py
2852 146 setup.py
2852 130 win32_manual_post_install.py
2853 130 win32_manual_post_install.py
2853
2854
2854 Similiarly, the lists returned by the -l option are also special, in
2855 Similiarly, the lists returned by the -l option are also special, in
2855 the sense that you can equally invoke the .s attribute on them to
2856 the sense that you can equally invoke the .s attribute on them to
2856 automatically get a whitespace-separated string from their contents:
2857 automatically get a whitespace-separated string from their contents:
2857
2858
2858 In [1]: sc -l b=ls *py
2859 In [1]: sc -l b=ls *py
2859
2860
2860 In [2]: b
2861 In [2]: b
2861 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2862 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2862
2863
2863 In [3]: b.s
2864 In [3]: b.s
2864 Out[3]: 'setup.py win32_manual_post_install.py'
2865 Out[3]: 'setup.py win32_manual_post_install.py'
2865
2866
2866 In summary, both the lists and strings used for ouptut capture have
2867 In summary, both the lists and strings used for ouptut capture have
2867 the following special attributes:
2868 the following special attributes:
2868
2869
2869 .l (or .list) : value as list.
2870 .l (or .list) : value as list.
2870 .n (or .nlstr): value as newline-separated string.
2871 .n (or .nlstr): value as newline-separated string.
2871 .s (or .spstr): value as space-separated string.
2872 .s (or .spstr): value as space-separated string.
2872 """
2873 """
2873
2874
2874 opts,args = self.parse_options(parameter_s,'lv')
2875 opts,args = self.parse_options(parameter_s,'lv')
2875 # Try to get a variable name and command to run
2876 # Try to get a variable name and command to run
2876 try:
2877 try:
2877 # the variable name must be obtained from the parse_options
2878 # the variable name must be obtained from the parse_options
2878 # output, which uses shlex.split to strip options out.
2879 # output, which uses shlex.split to strip options out.
2879 var,_ = args.split('=',1)
2880 var,_ = args.split('=',1)
2880 var = var.strip()
2881 var = var.strip()
2881 # But the the command has to be extracted from the original input
2882 # But the the command has to be extracted from the original input
2882 # parameter_s, not on what parse_options returns, to avoid the
2883 # parameter_s, not on what parse_options returns, to avoid the
2883 # quote stripping which shlex.split performs on it.
2884 # quote stripping which shlex.split performs on it.
2884 _,cmd = parameter_s.split('=',1)
2885 _,cmd = parameter_s.split('=',1)
2885 except ValueError:
2886 except ValueError:
2886 var,cmd = '',''
2887 var,cmd = '',''
2887 # If all looks ok, proceed
2888 # If all looks ok, proceed
2888 out,err = self.shell.getoutputerror(cmd)
2889 out,err = self.shell.getoutputerror(cmd)
2889 if err:
2890 if err:
2890 print >> Term.cerr,err
2891 print >> Term.cerr,err
2891 if opts.has_key('l'):
2892 if opts.has_key('l'):
2892 out = SList(out.split('\n'))
2893 out = SList(out.split('\n'))
2893 else:
2894 else:
2894 out = LSString(out)
2895 out = LSString(out)
2895 if opts.has_key('v'):
2896 if opts.has_key('v'):
2896 print '%s ==\n%s' % (var,pformat(out))
2897 print '%s ==\n%s' % (var,pformat(out))
2897 if var:
2898 if var:
2898 self.shell.user_ns.update({var:out})
2899 self.shell.user_ns.update({var:out})
2899 else:
2900 else:
2900 return out
2901 return out
2901
2902
2902 def magic_sx(self, parameter_s=''):
2903 def magic_sx(self, parameter_s=''):
2903 """Shell execute - run a shell command and capture its output.
2904 """Shell execute - run a shell command and capture its output.
2904
2905
2905 %sx command
2906 %sx command
2906
2907
2907 IPython will run the given command using commands.getoutput(), and
2908 IPython will run the given command using commands.getoutput(), and
2908 return the result formatted as a list (split on '\\n'). Since the
2909 return the result formatted as a list (split on '\\n'). Since the
2909 output is _returned_, it will be stored in ipython's regular output
2910 output is _returned_, it will be stored in ipython's regular output
2910 cache Out[N] and in the '_N' automatic variables.
2911 cache Out[N] and in the '_N' automatic variables.
2911
2912
2912 Notes:
2913 Notes:
2913
2914
2914 1) If an input line begins with '!!', then %sx is automatically
2915 1) If an input line begins with '!!', then %sx is automatically
2915 invoked. That is, while:
2916 invoked. That is, while:
2916 !ls
2917 !ls
2917 causes ipython to simply issue system('ls'), typing
2918 causes ipython to simply issue system('ls'), typing
2918 !!ls
2919 !!ls
2919 is a shorthand equivalent to:
2920 is a shorthand equivalent to:
2920 %sx ls
2921 %sx ls
2921
2922
2922 2) %sx differs from %sc in that %sx automatically splits into a list,
2923 2) %sx differs from %sc in that %sx automatically splits into a list,
2923 like '%sc -l'. The reason for this is to make it as easy as possible
2924 like '%sc -l'. The reason for this is to make it as easy as possible
2924 to process line-oriented shell output via further python commands.
2925 to process line-oriented shell output via further python commands.
2925 %sc is meant to provide much finer control, but requires more
2926 %sc is meant to provide much finer control, but requires more
2926 typing.
2927 typing.
2927
2928
2928 3) Just like %sc -l, this is a list with special attributes:
2929 3) Just like %sc -l, this is a list with special attributes:
2929
2930
2930 .l (or .list) : value as list.
2931 .l (or .list) : value as list.
2931 .n (or .nlstr): value as newline-separated string.
2932 .n (or .nlstr): value as newline-separated string.
2932 .s (or .spstr): value as whitespace-separated string.
2933 .s (or .spstr): value as whitespace-separated string.
2933
2934
2934 This is very useful when trying to use such lists as arguments to
2935 This is very useful when trying to use such lists as arguments to
2935 system commands."""
2936 system commands."""
2936
2937
2937 if parameter_s:
2938 if parameter_s:
2938 out,err = self.shell.getoutputerror(parameter_s)
2939 out,err = self.shell.getoutputerror(parameter_s)
2939 if err:
2940 if err:
2940 print >> Term.cerr,err
2941 print >> Term.cerr,err
2941 return SList(out.split('\n'))
2942 return SList(out.split('\n'))
2942
2943
2943 def magic_bg(self, parameter_s=''):
2944 def magic_bg(self, parameter_s=''):
2944 """Run a job in the background, in a separate thread.
2945 """Run a job in the background, in a separate thread.
2945
2946
2946 For example,
2947 For example,
2947
2948
2948 %bg myfunc(x,y,z=1)
2949 %bg myfunc(x,y,z=1)
2949
2950
2950 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2951 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2951 execution starts, a message will be printed indicating the job
2952 execution starts, a message will be printed indicating the job
2952 number. If your job number is 5, you can use
2953 number. If your job number is 5, you can use
2953
2954
2954 myvar = jobs.result(5) or myvar = jobs[5].result
2955 myvar = jobs.result(5) or myvar = jobs[5].result
2955
2956
2956 to assign this result to variable 'myvar'.
2957 to assign this result to variable 'myvar'.
2957
2958
2958 IPython has a job manager, accessible via the 'jobs' object. You can
2959 IPython has a job manager, accessible via the 'jobs' object. You can
2959 type jobs? to get more information about it, and use jobs.<TAB> to see
2960 type jobs? to get more information about it, and use jobs.<TAB> to see
2960 its attributes. All attributes not starting with an underscore are
2961 its attributes. All attributes not starting with an underscore are
2961 meant for public use.
2962 meant for public use.
2962
2963
2963 In particular, look at the jobs.new() method, which is used to create
2964 In particular, look at the jobs.new() method, which is used to create
2964 new jobs. This magic %bg function is just a convenience wrapper
2965 new jobs. This magic %bg function is just a convenience wrapper
2965 around jobs.new(), for expression-based jobs. If you want to create a
2966 around jobs.new(), for expression-based jobs. If you want to create a
2966 new job with an explicit function object and arguments, you must call
2967 new job with an explicit function object and arguments, you must call
2967 jobs.new() directly.
2968 jobs.new() directly.
2968
2969
2969 The jobs.new docstring also describes in detail several important
2970 The jobs.new docstring also describes in detail several important
2970 caveats associated with a thread-based model for background job
2971 caveats associated with a thread-based model for background job
2971 execution. Type jobs.new? for details.
2972 execution. Type jobs.new? for details.
2972
2973
2973 You can check the status of all jobs with jobs.status().
2974 You can check the status of all jobs with jobs.status().
2974
2975
2975 The jobs variable is set by IPython into the Python builtin namespace.
2976 The jobs variable is set by IPython into the Python builtin namespace.
2976 If you ever declare a variable named 'jobs', you will shadow this
2977 If you ever declare a variable named 'jobs', you will shadow this
2977 name. You can either delete your global jobs variable to regain
2978 name. You can either delete your global jobs variable to regain
2978 access to the job manager, or make a new name and assign it manually
2979 access to the job manager, or make a new name and assign it manually
2979 to the manager (stored in IPython's namespace). For example, to
2980 to the manager (stored in IPython's namespace). For example, to
2980 assign the job manager to the Jobs name, use:
2981 assign the job manager to the Jobs name, use:
2981
2982
2982 Jobs = __builtins__.jobs"""
2983 Jobs = __builtins__.jobs"""
2983
2984
2984 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2985 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2985
2986
2986 def magic_r(self, parameter_s=''):
2987 def magic_r(self, parameter_s=''):
2987 """Repeat previous input.
2988 """Repeat previous input.
2988
2989
2989 Note: Consider using the more powerfull %rep instead!
2990 Note: Consider using the more powerfull %rep instead!
2990
2991
2991 If given an argument, repeats the previous command which starts with
2992 If given an argument, repeats the previous command which starts with
2992 the same string, otherwise it just repeats the previous input.
2993 the same string, otherwise it just repeats the previous input.
2993
2994
2994 Shell escaped commands (with ! as first character) are not recognized
2995 Shell escaped commands (with ! as first character) are not recognized
2995 by this system, only pure python code and magic commands.
2996 by this system, only pure python code and magic commands.
2996 """
2997 """
2997
2998
2998 start = parameter_s.strip()
2999 start = parameter_s.strip()
2999 esc_magic = self.shell.ESC_MAGIC
3000 esc_magic = self.shell.ESC_MAGIC
3000 # Identify magic commands even if automagic is on (which means
3001 # Identify magic commands even if automagic is on (which means
3001 # the in-memory version is different from that typed by the user).
3002 # the in-memory version is different from that typed by the user).
3002 if self.shell.rc.automagic:
3003 if self.shell.rc.automagic:
3003 start_magic = esc_magic+start
3004 start_magic = esc_magic+start
3004 else:
3005 else:
3005 start_magic = start
3006 start_magic = start
3006 # Look through the input history in reverse
3007 # Look through the input history in reverse
3007 for n in range(len(self.shell.input_hist)-2,0,-1):
3008 for n in range(len(self.shell.input_hist)-2,0,-1):
3008 input = self.shell.input_hist[n]
3009 input = self.shell.input_hist[n]
3009 # skip plain 'r' lines so we don't recurse to infinity
3010 # skip plain 'r' lines so we don't recurse to infinity
3010 if input != '_ip.magic("r")\n' and \
3011 if input != '_ip.magic("r")\n' and \
3011 (input.startswith(start) or input.startswith(start_magic)):
3012 (input.startswith(start) or input.startswith(start_magic)):
3012 #print 'match',`input` # dbg
3013 #print 'match',`input` # dbg
3013 print 'Executing:',input,
3014 print 'Executing:',input,
3014 self.shell.runlines(input)
3015 self.shell.runlines(input)
3015 return
3016 return
3016 print 'No previous input matching `%s` found.' % start
3017 print 'No previous input matching `%s` found.' % start
3017
3018
3018
3019
3019 def magic_bookmark(self, parameter_s=''):
3020 def magic_bookmark(self, parameter_s=''):
3020 """Manage IPython's bookmark system.
3021 """Manage IPython's bookmark system.
3021
3022
3022 %bookmark <name> - set bookmark to current dir
3023 %bookmark <name> - set bookmark to current dir
3023 %bookmark <name> <dir> - set bookmark to <dir>
3024 %bookmark <name> <dir> - set bookmark to <dir>
3024 %bookmark -l - list all bookmarks
3025 %bookmark -l - list all bookmarks
3025 %bookmark -d <name> - remove bookmark
3026 %bookmark -d <name> - remove bookmark
3026 %bookmark -r - remove all bookmarks
3027 %bookmark -r - remove all bookmarks
3027
3028
3028 You can later on access a bookmarked folder with:
3029 You can later on access a bookmarked folder with:
3029 %cd -b <name>
3030 %cd -b <name>
3030 or simply '%cd <name>' if there is no directory called <name> AND
3031 or simply '%cd <name>' if there is no directory called <name> AND
3031 there is such a bookmark defined.
3032 there is such a bookmark defined.
3032
3033
3033 Your bookmarks persist through IPython sessions, but they are
3034 Your bookmarks persist through IPython sessions, but they are
3034 associated with each profile."""
3035 associated with each profile."""
3035
3036
3036 opts,args = self.parse_options(parameter_s,'drl',mode='list')
3037 opts,args = self.parse_options(parameter_s,'drl',mode='list')
3037 if len(args) > 2:
3038 if len(args) > 2:
3038 raise UsageError("%bookmark: too many arguments")
3039 raise UsageError("%bookmark: too many arguments")
3039
3040
3040 bkms = self.db.get('bookmarks',{})
3041 bkms = self.db.get('bookmarks',{})
3041
3042
3042 if opts.has_key('d'):
3043 if opts.has_key('d'):
3043 try:
3044 try:
3044 todel = args[0]
3045 todel = args[0]
3045 except IndexError:
3046 except IndexError:
3046 raise UsageError(
3047 raise UsageError(
3047 "%bookmark -d: must provide a bookmark to delete")
3048 "%bookmark -d: must provide a bookmark to delete")
3048 else:
3049 else:
3049 try:
3050 try:
3050 del bkms[todel]
3051 del bkms[todel]
3051 except KeyError:
3052 except KeyError:
3052 raise UsageError(
3053 raise UsageError(
3053 "%%bookmark -d: Can't delete bookmark '%s'" % todel)
3054 "%%bookmark -d: Can't delete bookmark '%s'" % todel)
3054
3055
3055 elif opts.has_key('r'):
3056 elif opts.has_key('r'):
3056 bkms = {}
3057 bkms = {}
3057 elif opts.has_key('l'):
3058 elif opts.has_key('l'):
3058 bks = bkms.keys()
3059 bks = bkms.keys()
3059 bks.sort()
3060 bks.sort()
3060 if bks:
3061 if bks:
3061 size = max(map(len,bks))
3062 size = max(map(len,bks))
3062 else:
3063 else:
3063 size = 0
3064 size = 0
3064 fmt = '%-'+str(size)+'s -> %s'
3065 fmt = '%-'+str(size)+'s -> %s'
3065 print 'Current bookmarks:'
3066 print 'Current bookmarks:'
3066 for bk in bks:
3067 for bk in bks:
3067 print fmt % (bk,bkms[bk])
3068 print fmt % (bk,bkms[bk])
3068 else:
3069 else:
3069 if not args:
3070 if not args:
3070 raise UsageError("%bookmark: You must specify the bookmark name")
3071 raise UsageError("%bookmark: You must specify the bookmark name")
3071 elif len(args)==1:
3072 elif len(args)==1:
3072 bkms[args[0]] = os.getcwd()
3073 bkms[args[0]] = os.getcwd()
3073 elif len(args)==2:
3074 elif len(args)==2:
3074 bkms[args[0]] = args[1]
3075 bkms[args[0]] = args[1]
3075 self.db['bookmarks'] = bkms
3076 self.db['bookmarks'] = bkms
3076
3077
3077 def magic_pycat(self, parameter_s=''):
3078 def magic_pycat(self, parameter_s=''):
3078 """Show a syntax-highlighted file through a pager.
3079 """Show a syntax-highlighted file through a pager.
3079
3080
3080 This magic is similar to the cat utility, but it will assume the file
3081 This magic is similar to the cat utility, but it will assume the file
3081 to be Python source and will show it with syntax highlighting. """
3082 to be Python source and will show it with syntax highlighting. """
3082
3083
3083 try:
3084 try:
3084 filename = get_py_filename(parameter_s)
3085 filename = get_py_filename(parameter_s)
3085 cont = file_read(filename)
3086 cont = file_read(filename)
3086 except IOError:
3087 except IOError:
3087 try:
3088 try:
3088 cont = eval(parameter_s,self.user_ns)
3089 cont = eval(parameter_s,self.user_ns)
3089 except NameError:
3090 except NameError:
3090 cont = None
3091 cont = None
3091 if cont is None:
3092 if cont is None:
3092 print "Error: no such file or variable"
3093 print "Error: no such file or variable"
3093 return
3094 return
3094
3095
3095 page(self.shell.pycolorize(cont),
3096 page(self.shell.pycolorize(cont),
3096 screen_lines=self.shell.rc.screen_length)
3097 screen_lines=self.shell.rc.screen_length)
3097
3098
3098 def magic_cpaste(self, parameter_s=''):
3099 def magic_cpaste(self, parameter_s=''):
3099 """Allows you to paste & execute a pre-formatted code block from clipboard
3100 """Allows you to paste & execute a pre-formatted code block from clipboard
3100
3101
3101 You must terminate the block with '--' (two minus-signs) alone on the
3102 You must terminate the block with '--' (two minus-signs) alone on the
3102 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3103 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3103 is the new sentinel for this operation)
3104 is the new sentinel for this operation)
3104
3105
3105 The block is dedented prior to execution to enable execution of method
3106 The block is dedented prior to execution to enable execution of method
3106 definitions. '>' and '+' characters at the beginning of a line are
3107 definitions. '>' and '+' characters at the beginning of a line are
3107 ignored, to allow pasting directly from e-mails or diff files. The
3108 ignored, to allow pasting directly from e-mails or diff files. The
3108 executed block is also assigned to variable named 'pasted_block' for
3109 executed block is also assigned to variable named 'pasted_block' for
3109 later editing with '%edit pasted_block'.
3110 later editing with '%edit pasted_block'.
3110
3111
3111 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3112 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3112 This assigns the pasted block to variable 'foo' as string, without
3113 This assigns the pasted block to variable 'foo' as string, without
3113 dedenting or executing it.
3114 dedenting or executing it.
3114
3115
3115 Do not be alarmed by garbled output on Windows (it's a readline bug).
3116 Do not be alarmed by garbled output on Windows (it's a readline bug).
3116 Just press enter and type -- (and press enter again) and the block
3117 Just press enter and type -- (and press enter again) and the block
3117 will be what was just pasted.
3118 will be what was just pasted.
3118
3119
3119 IPython statements (magics, shell escapes) are not supported (yet).
3120 IPython statements (magics, shell escapes) are not supported (yet).
3120 """
3121 """
3121 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3122 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3122 par = args.strip()
3123 par = args.strip()
3123 sentinel = opts.get('s','--')
3124 sentinel = opts.get('s','--')
3124
3125
3125 from IPython import iplib
3126 from IPython import iplib
3126 lines = []
3127 lines = []
3127 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3128 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3128 while 1:
3129 while 1:
3129 l = iplib.raw_input_original(':')
3130 l = iplib.raw_input_original(':')
3130 if l ==sentinel:
3131 if l ==sentinel:
3131 break
3132 break
3132 lines.append(l.lstrip('>').lstrip('+'))
3133 lines.append(l.lstrip('>').lstrip('+'))
3133 block = "\n".join(lines) + '\n'
3134 block = "\n".join(lines) + '\n'
3134 #print "block:\n",block
3135 #print "block:\n",block
3135 if not par:
3136 if not par:
3136 b = textwrap.dedent(block)
3137 b = textwrap.dedent(block)
3137 exec b in self.user_ns
3138 exec b in self.user_ns
3138 self.user_ns['pasted_block'] = b
3139 self.user_ns['pasted_block'] = b
3139 else:
3140 else:
3140 self.user_ns[par] = block
3141 self.user_ns[par] = block
3141 print "Block assigned to '%s'" % par
3142 print "Block assigned to '%s'" % par
3142
3143
3143 def magic_quickref(self,arg):
3144 def magic_quickref(self,arg):
3144 """ Show a quick reference sheet """
3145 """ Show a quick reference sheet """
3145 import IPython.usage
3146 import IPython.usage
3146 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3147 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3147
3148
3148 page(qr)
3149 page(qr)
3149
3150
3150 def magic_upgrade(self,arg):
3151 def magic_upgrade(self,arg):
3151 """ Upgrade your IPython installation
3152 """ Upgrade your IPython installation
3152
3153
3153 This will copy the config files that don't yet exist in your
3154 This will copy the config files that don't yet exist in your
3154 ipython dir from the system config dir. Use this after upgrading
3155 ipython dir from the system config dir. Use this after upgrading
3155 IPython if you don't wish to delete your .ipython dir.
3156 IPython if you don't wish to delete your .ipython dir.
3156
3157
3157 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3158 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3158 new users)
3159 new users)
3159
3160
3160 """
3161 """
3161 ip = self.getapi()
3162 ip = self.getapi()
3162 ipinstallation = path(IPython.__file__).dirname()
3163 ipinstallation = path(IPython.__file__).dirname()
3163 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3164 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3164 src_config = ipinstallation / 'UserConfig'
3165 src_config = ipinstallation / 'UserConfig'
3165 userdir = path(ip.options.ipythondir)
3166 userdir = path(ip.options.ipythondir)
3166 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3167 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3167 print ">",cmd
3168 print ">",cmd
3168 shell(cmd)
3169 shell(cmd)
3169 if arg == '-nolegacy':
3170 if arg == '-nolegacy':
3170 legacy = userdir.files('ipythonrc*')
3171 legacy = userdir.files('ipythonrc*')
3171 print "Nuking legacy files:",legacy
3172 print "Nuking legacy files:",legacy
3172
3173
3173 [p.remove() for p in legacy]
3174 [p.remove() for p in legacy]
3174 suffix = (sys.platform == 'win32' and '.ini' or '')
3175 suffix = (sys.platform == 'win32' and '.ini' or '')
3175 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3176 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3176
3177
3177
3178
3178 def magic_doctest_mode(self,parameter_s=''):
3179 def magic_doctest_mode(self,parameter_s=''):
3179 """Toggle doctest mode on and off.
3180 """Toggle doctest mode on and off.
3180
3181
3181 This mode allows you to toggle the prompt behavior between normal
3182 This mode allows you to toggle the prompt behavior between normal
3182 IPython prompts and ones that are as similar to the default IPython
3183 IPython prompts and ones that are as similar to the default IPython
3183 interpreter as possible.
3184 interpreter as possible.
3184
3185
3185 It also supports the pasting of code snippets that have leading '>>>'
3186 It also supports the pasting of code snippets that have leading '>>>'
3186 and '...' prompts in them. This means that you can paste doctests from
3187 and '...' prompts in them. This means that you can paste doctests from
3187 files or docstrings (even if they have leading whitespace), and the
3188 files or docstrings (even if they have leading whitespace), and the
3188 code will execute correctly. You can then use '%history -tn' to see
3189 code will execute correctly. You can then use '%history -tn' to see
3189 the translated history without line numbers; this will give you the
3190 the translated history without line numbers; this will give you the
3190 input after removal of all the leading prompts and whitespace, which
3191 input after removal of all the leading prompts and whitespace, which
3191 can be pasted back into an editor.
3192 can be pasted back into an editor.
3192
3193
3193 With these features, you can switch into this mode easily whenever you
3194 With these features, you can switch into this mode easily whenever you
3194 need to do testing and changes to doctests, without having to leave
3195 need to do testing and changes to doctests, without having to leave
3195 your existing IPython session.
3196 your existing IPython session.
3196 """
3197 """
3197
3198
3198 # XXX - Fix this to have cleaner activate/deactivate calls.
3199 # XXX - Fix this to have cleaner activate/deactivate calls.
3199 from IPython.Extensions import InterpreterPasteInput as ipaste
3200 from IPython.Extensions import InterpreterPasteInput as ipaste
3200 from IPython.ipstruct import Struct
3201 from IPython.ipstruct import Struct
3201
3202
3202 # Shorthands
3203 # Shorthands
3203 shell = self.shell
3204 shell = self.shell
3204 oc = shell.outputcache
3205 oc = shell.outputcache
3205 rc = shell.rc
3206 rc = shell.rc
3206 meta = shell.meta
3207 meta = shell.meta
3207 # dstore is a data store kept in the instance metadata bag to track any
3208 # dstore is a data store kept in the instance metadata bag to track any
3208 # changes we make, so we can undo them later.
3209 # changes we make, so we can undo them later.
3209 dstore = meta.setdefault('doctest_mode',Struct())
3210 dstore = meta.setdefault('doctest_mode',Struct())
3210 save_dstore = dstore.setdefault
3211 save_dstore = dstore.setdefault
3211
3212
3212 # save a few values we'll need to recover later
3213 # save a few values we'll need to recover later
3213 mode = save_dstore('mode',False)
3214 mode = save_dstore('mode',False)
3214 save_dstore('rc_pprint',rc.pprint)
3215 save_dstore('rc_pprint',rc.pprint)
3215 save_dstore('xmode',shell.InteractiveTB.mode)
3216 save_dstore('xmode',shell.InteractiveTB.mode)
3216 save_dstore('rc_separate_in',rc.separate_in)
3217 save_dstore('rc_separate_in',rc.separate_in)
3217 save_dstore('rc_separate_out',rc.separate_out)
3218 save_dstore('rc_separate_out',rc.separate_out)
3218 save_dstore('rc_separate_out2',rc.separate_out2)
3219 save_dstore('rc_separate_out2',rc.separate_out2)
3219 save_dstore('rc_prompts_pad_left',rc.prompts_pad_left)
3220 save_dstore('rc_prompts_pad_left',rc.prompts_pad_left)
3220
3221
3221 if mode == False:
3222 if mode == False:
3222 # turn on
3223 # turn on
3223 ipaste.activate_prefilter()
3224 ipaste.activate_prefilter()
3224
3225
3225 oc.prompt1.p_template = '>>> '
3226 oc.prompt1.p_template = '>>> '
3226 oc.prompt2.p_template = '... '
3227 oc.prompt2.p_template = '... '
3227 oc.prompt_out.p_template = ''
3228 oc.prompt_out.p_template = ''
3228
3229
3229 oc.prompt1.sep = '\n'
3230 oc.prompt1.sep = '\n'
3230 oc.output_sep = ''
3231 oc.output_sep = ''
3231 oc.output_sep2 = ''
3232 oc.output_sep2 = ''
3232
3233
3233 oc.prompt1.pad_left = oc.prompt2.pad_left = \
3234 oc.prompt1.pad_left = oc.prompt2.pad_left = \
3234 oc.prompt_out.pad_left = False
3235 oc.prompt_out.pad_left = False
3235
3236
3236 rc.pprint = False
3237 rc.pprint = False
3237
3238
3238 shell.magic_xmode('Plain')
3239 shell.magic_xmode('Plain')
3239
3240
3240 else:
3241 else:
3241 # turn off
3242 # turn off
3242 ipaste.deactivate_prefilter()
3243 ipaste.deactivate_prefilter()
3243
3244
3244 oc.prompt1.p_template = rc.prompt_in1
3245 oc.prompt1.p_template = rc.prompt_in1
3245 oc.prompt2.p_template = rc.prompt_in2
3246 oc.prompt2.p_template = rc.prompt_in2
3246 oc.prompt_out.p_template = rc.prompt_out
3247 oc.prompt_out.p_template = rc.prompt_out
3247
3248
3248 oc.prompt1.sep = dstore.rc_separate_in
3249 oc.prompt1.sep = dstore.rc_separate_in
3249 oc.output_sep = dstore.rc_separate_out
3250 oc.output_sep = dstore.rc_separate_out
3250 oc.output_sep2 = dstore.rc_separate_out2
3251 oc.output_sep2 = dstore.rc_separate_out2
3251
3252
3252 oc.prompt1.pad_left = oc.prompt2.pad_left = \
3253 oc.prompt1.pad_left = oc.prompt2.pad_left = \
3253 oc.prompt_out.pad_left = dstore.rc_prompts_pad_left
3254 oc.prompt_out.pad_left = dstore.rc_prompts_pad_left
3254
3255
3255 rc.pprint = dstore.rc_pprint
3256 rc.pprint = dstore.rc_pprint
3256
3257
3257 shell.magic_xmode(dstore.xmode)
3258 shell.magic_xmode(dstore.xmode)
3258
3259
3259 # Store new mode and inform
3260 # Store new mode and inform
3260 dstore.mode = bool(1-int(mode))
3261 dstore.mode = bool(1-int(mode))
3261 print 'Doctest mode is:',
3262 print 'Doctest mode is:',
3262 print ['OFF','ON'][dstore.mode]
3263 print ['OFF','ON'][dstore.mode]
3263
3264
3264 # end Magic
3265 # end Magic
@@ -1,1984 +1,1984 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 2847 2007-10-24 15:16:24Z vivainio $"""
8 $Id: genutils.py 2872 2007-11-25 17:58:05Z fperez $"""
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 doctest
25 import doctest
26 import os
26 import os
27 import re
27 import re
28 import shlex
28 import shlex
29 import shutil
29 import shutil
30 import sys
30 import sys
31 import tempfile
31 import tempfile
32 import time
32 import time
33 import types
33 import types
34 import warnings
34 import warnings
35
35
36 # Other IPython utilities
36 # Other IPython utilities
37 import IPython
37 import IPython
38 from IPython.Itpl import Itpl,itpl,printpl
38 from IPython.Itpl import Itpl,itpl,printpl
39 from IPython import DPyGetOpt, platutils
39 from IPython import DPyGetOpt, platutils
40 from IPython.generics import result_display
40 from IPython.generics import result_display
41 from path import path
41 from path import path
42 if os.name == "nt":
42 if os.name == "nt":
43 from IPython.winconsole import get_console_size
43 from IPython.winconsole import get_console_size
44
44
45 #****************************************************************************
45 #****************************************************************************
46 # Exceptions
46 # Exceptions
47 class Error(Exception):
47 class Error(Exception):
48 """Base class for exceptions in this module."""
48 """Base class for exceptions in this module."""
49 pass
49 pass
50
50
51 #----------------------------------------------------------------------------
51 #----------------------------------------------------------------------------
52 class IOStream:
52 class IOStream:
53 def __init__(self,stream,fallback):
53 def __init__(self,stream,fallback):
54 if not hasattr(stream,'write') or not hasattr(stream,'flush'):
54 if not hasattr(stream,'write') or not hasattr(stream,'flush'):
55 stream = fallback
55 stream = fallback
56 self.stream = stream
56 self.stream = stream
57 self._swrite = stream.write
57 self._swrite = stream.write
58 self.flush = stream.flush
58 self.flush = stream.flush
59
59
60 def write(self,data):
60 def write(self,data):
61 try:
61 try:
62 self._swrite(data)
62 self._swrite(data)
63 except:
63 except:
64 try:
64 try:
65 # print handles some unicode issues which may trip a plain
65 # print handles some unicode issues which may trip a plain
66 # write() call. Attempt to emulate write() by using a
66 # write() call. Attempt to emulate write() by using a
67 # trailing comma
67 # trailing comma
68 print >> self.stream, data,
68 print >> self.stream, data,
69 except:
69 except:
70 # if we get here, something is seriously broken.
70 # if we get here, something is seriously broken.
71 print >> sys.stderr, \
71 print >> sys.stderr, \
72 'ERROR - failed to write data to stream:', self.stream
72 'ERROR - failed to write data to stream:', self.stream
73
73
74 def close(self):
74 def close(self):
75 pass
75 pass
76
76
77
77
78 class IOTerm:
78 class IOTerm:
79 """ Term holds the file or file-like objects for handling I/O operations.
79 """ Term holds the file or file-like objects for handling I/O operations.
80
80
81 These are normally just sys.stdin, sys.stdout and sys.stderr but for
81 These are normally just sys.stdin, sys.stdout and sys.stderr but for
82 Windows they can can replaced to allow editing the strings before they are
82 Windows they can can replaced to allow editing the strings before they are
83 displayed."""
83 displayed."""
84
84
85 # In the future, having IPython channel all its I/O operations through
85 # In the future, having IPython channel all its I/O operations through
86 # this class will make it easier to embed it into other environments which
86 # this class will make it easier to embed it into other environments which
87 # are not a normal terminal (such as a GUI-based shell)
87 # are not a normal terminal (such as a GUI-based shell)
88 def __init__(self,cin=None,cout=None,cerr=None):
88 def __init__(self,cin=None,cout=None,cerr=None):
89 self.cin = IOStream(cin,sys.stdin)
89 self.cin = IOStream(cin,sys.stdin)
90 self.cout = IOStream(cout,sys.stdout)
90 self.cout = IOStream(cout,sys.stdout)
91 self.cerr = IOStream(cerr,sys.stderr)
91 self.cerr = IOStream(cerr,sys.stderr)
92
92
93 # Global variable to be used for all I/O
93 # Global variable to be used for all I/O
94 Term = IOTerm()
94 Term = IOTerm()
95
95
96 import IPython.rlineimpl as readline
96 import IPython.rlineimpl as readline
97 # Remake Term to use the readline i/o facilities
97 # Remake Term to use the readline i/o facilities
98 if sys.platform == 'win32' and readline.have_readline:
98 if sys.platform == 'win32' and readline.have_readline:
99
99
100 Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile)
100 Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile)
101
101
102
102
103 #****************************************************************************
103 #****************************************************************************
104 # Generic warning/error printer, used by everything else
104 # Generic warning/error printer, used by everything else
105 def warn(msg,level=2,exit_val=1):
105 def warn(msg,level=2,exit_val=1):
106 """Standard warning printer. Gives formatting consistency.
106 """Standard warning printer. Gives formatting consistency.
107
107
108 Output is sent to Term.cerr (sys.stderr by default).
108 Output is sent to Term.cerr (sys.stderr by default).
109
109
110 Options:
110 Options:
111
111
112 -level(2): allows finer control:
112 -level(2): allows finer control:
113 0 -> Do nothing, dummy function.
113 0 -> Do nothing, dummy function.
114 1 -> Print message.
114 1 -> Print message.
115 2 -> Print 'WARNING:' + message. (Default level).
115 2 -> Print 'WARNING:' + message. (Default level).
116 3 -> Print 'ERROR:' + message.
116 3 -> Print 'ERROR:' + message.
117 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
117 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
118
118
119 -exit_val (1): exit value returned by sys.exit() for a level 4
119 -exit_val (1): exit value returned by sys.exit() for a level 4
120 warning. Ignored for all other levels."""
120 warning. Ignored for all other levels."""
121
121
122 if level>0:
122 if level>0:
123 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
123 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
124 print >> Term.cerr, '%s%s' % (header[level],msg)
124 print >> Term.cerr, '%s%s' % (header[level],msg)
125 if level == 4:
125 if level == 4:
126 print >> Term.cerr,'Exiting.\n'
126 print >> Term.cerr,'Exiting.\n'
127 sys.exit(exit_val)
127 sys.exit(exit_val)
128
128
129 def info(msg):
129 def info(msg):
130 """Equivalent to warn(msg,level=1)."""
130 """Equivalent to warn(msg,level=1)."""
131
131
132 warn(msg,level=1)
132 warn(msg,level=1)
133
133
134 def error(msg):
134 def error(msg):
135 """Equivalent to warn(msg,level=3)."""
135 """Equivalent to warn(msg,level=3)."""
136
136
137 warn(msg,level=3)
137 warn(msg,level=3)
138
138
139 def fatal(msg,exit_val=1):
139 def fatal(msg,exit_val=1):
140 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
140 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
141
141
142 warn(msg,exit_val=exit_val,level=4)
142 warn(msg,exit_val=exit_val,level=4)
143
143
144 #---------------------------------------------------------------------------
144 #---------------------------------------------------------------------------
145 # Debugging routines
145 # Debugging routines
146 #
146 #
147 def debugx(expr,pre_msg=''):
147 def debugx(expr,pre_msg=''):
148 """Print the value of an expression from the caller's frame.
148 """Print the value of an expression from the caller's frame.
149
149
150 Takes an expression, evaluates it in the caller's frame and prints both
150 Takes an expression, evaluates it in the caller's frame and prints both
151 the given expression and the resulting value (as well as a debug mark
151 the given expression and the resulting value (as well as a debug mark
152 indicating the name of the calling function. The input must be of a form
152 indicating the name of the calling function. The input must be of a form
153 suitable for eval().
153 suitable for eval().
154
154
155 An optional message can be passed, which will be prepended to the printed
155 An optional message can be passed, which will be prepended to the printed
156 expr->value pair."""
156 expr->value pair."""
157
157
158 cf = sys._getframe(1)
158 cf = sys._getframe(1)
159 print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr,
159 print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr,
160 eval(expr,cf.f_globals,cf.f_locals))
160 eval(expr,cf.f_globals,cf.f_locals))
161
161
162 # deactivate it by uncommenting the following line, which makes it a no-op
162 # deactivate it by uncommenting the following line, which makes it a no-op
163 #def debugx(expr,pre_msg=''): pass
163 #def debugx(expr,pre_msg=''): pass
164
164
165 #----------------------------------------------------------------------------
165 #----------------------------------------------------------------------------
166 StringTypes = types.StringTypes
166 StringTypes = types.StringTypes
167
167
168 # Basic timing functionality
168 # Basic timing functionality
169
169
170 # If possible (Unix), use the resource module instead of time.clock()
170 # If possible (Unix), use the resource module instead of time.clock()
171 try:
171 try:
172 import resource
172 import resource
173 def clocku():
173 def clocku():
174 """clocku() -> floating point number
174 """clocku() -> floating point number
175
175
176 Return the *USER* CPU time in seconds since the start of the process.
176 Return the *USER* CPU time in seconds since the start of the process.
177 This is done via a call to resource.getrusage, so it avoids the
177 This is done via a call to resource.getrusage, so it avoids the
178 wraparound problems in time.clock()."""
178 wraparound problems in time.clock()."""
179
179
180 return resource.getrusage(resource.RUSAGE_SELF)[0]
180 return resource.getrusage(resource.RUSAGE_SELF)[0]
181
181
182 def clocks():
182 def clocks():
183 """clocks() -> floating point number
183 """clocks() -> floating point number
184
184
185 Return the *SYSTEM* CPU time in seconds since the start of the process.
185 Return the *SYSTEM* CPU time in seconds since the start of the process.
186 This is done via a call to resource.getrusage, so it avoids the
186 This is done via a call to resource.getrusage, so it avoids the
187 wraparound problems in time.clock()."""
187 wraparound problems in time.clock()."""
188
188
189 return resource.getrusage(resource.RUSAGE_SELF)[1]
189 return resource.getrusage(resource.RUSAGE_SELF)[1]
190
190
191 def clock():
191 def clock():
192 """clock() -> floating point number
192 """clock() -> floating point number
193
193
194 Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of
194 Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of
195 the process. This is done via a call to resource.getrusage, so it
195 the process. This is done via a call to resource.getrusage, so it
196 avoids the wraparound problems in time.clock()."""
196 avoids the wraparound problems in time.clock()."""
197
197
198 u,s = resource.getrusage(resource.RUSAGE_SELF)[:2]
198 u,s = resource.getrusage(resource.RUSAGE_SELF)[:2]
199 return u+s
199 return u+s
200
200
201 def clock2():
201 def clock2():
202 """clock2() -> (t_user,t_system)
202 """clock2() -> (t_user,t_system)
203
203
204 Similar to clock(), but return a tuple of user/system times."""
204 Similar to clock(), but return a tuple of user/system times."""
205 return resource.getrusage(resource.RUSAGE_SELF)[:2]
205 return resource.getrusage(resource.RUSAGE_SELF)[:2]
206
206
207 except ImportError:
207 except ImportError:
208 # There is no distinction of user/system time under windows, so we just use
208 # There is no distinction of user/system time under windows, so we just use
209 # time.clock() for everything...
209 # time.clock() for everything...
210 clocku = clocks = clock = time.clock
210 clocku = clocks = clock = time.clock
211 def clock2():
211 def clock2():
212 """Under windows, system CPU time can't be measured.
212 """Under windows, system CPU time can't be measured.
213
213
214 This just returns clock() and zero."""
214 This just returns clock() and zero."""
215 return time.clock(),0.0
215 return time.clock(),0.0
216
216
217 def timings_out(reps,func,*args,**kw):
217 def timings_out(reps,func,*args,**kw):
218 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
218 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
219
219
220 Execute a function reps times, return a tuple with the elapsed total
220 Execute a function reps times, return a tuple with the elapsed total
221 CPU time in seconds, the time per call and the function's output.
221 CPU time in seconds, the time per call and the function's output.
222
222
223 Under Unix, the return value is the sum of user+system time consumed by
223 Under Unix, the return value is the sum of user+system time consumed by
224 the process, computed via the resource module. This prevents problems
224 the process, computed via the resource module. This prevents problems
225 related to the wraparound effect which the time.clock() function has.
225 related to the wraparound effect which the time.clock() function has.
226
226
227 Under Windows the return value is in wall clock seconds. See the
227 Under Windows the return value is in wall clock seconds. See the
228 documentation for the time module for more details."""
228 documentation for the time module for more details."""
229
229
230 reps = int(reps)
230 reps = int(reps)
231 assert reps >=1, 'reps must be >= 1'
231 assert reps >=1, 'reps must be >= 1'
232 if reps==1:
232 if reps==1:
233 start = clock()
233 start = clock()
234 out = func(*args,**kw)
234 out = func(*args,**kw)
235 tot_time = clock()-start
235 tot_time = clock()-start
236 else:
236 else:
237 rng = xrange(reps-1) # the last time is executed separately to store output
237 rng = xrange(reps-1) # the last time is executed separately to store output
238 start = clock()
238 start = clock()
239 for dummy in rng: func(*args,**kw)
239 for dummy in rng: func(*args,**kw)
240 out = func(*args,**kw) # one last time
240 out = func(*args,**kw) # one last time
241 tot_time = clock()-start
241 tot_time = clock()-start
242 av_time = tot_time / reps
242 av_time = tot_time / reps
243 return tot_time,av_time,out
243 return tot_time,av_time,out
244
244
245 def timings(reps,func,*args,**kw):
245 def timings(reps,func,*args,**kw):
246 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
246 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
247
247
248 Execute a function reps times, return a tuple with the elapsed total CPU
248 Execute a function reps times, return a tuple with the elapsed total CPU
249 time in seconds and the time per call. These are just the first two values
249 time in seconds and the time per call. These are just the first two values
250 in timings_out()."""
250 in timings_out()."""
251
251
252 return timings_out(reps,func,*args,**kw)[0:2]
252 return timings_out(reps,func,*args,**kw)[0:2]
253
253
254 def timing(func,*args,**kw):
254 def timing(func,*args,**kw):
255 """timing(func,*args,**kw) -> t_total
255 """timing(func,*args,**kw) -> t_total
256
256
257 Execute a function once, return the elapsed total CPU time in
257 Execute a function once, return the elapsed total CPU time in
258 seconds. This is just the first value in timings_out()."""
258 seconds. This is just the first value in timings_out()."""
259
259
260 return timings_out(1,func,*args,**kw)[0]
260 return timings_out(1,func,*args,**kw)[0]
261
261
262 #****************************************************************************
262 #****************************************************************************
263 # file and system
263 # file and system
264
264
265 def arg_split(s,posix=False):
265 def arg_split(s,posix=False):
266 """Split a command line's arguments in a shell-like manner.
266 """Split a command line's arguments in a shell-like manner.
267
267
268 This is a modified version of the standard library's shlex.split()
268 This is a modified version of the standard library's shlex.split()
269 function, but with a default of posix=False for splitting, so that quotes
269 function, but with a default of posix=False for splitting, so that quotes
270 in inputs are respected."""
270 in inputs are respected."""
271
271
272 # XXX - there may be unicode-related problems here!!! I'm not sure that
272 # XXX - there may be unicode-related problems here!!! I'm not sure that
273 # shlex is truly unicode-safe, so it might be necessary to do
273 # shlex is truly unicode-safe, so it might be necessary to do
274 #
274 #
275 # s = s.encode(sys.stdin.encoding)
275 # s = s.encode(sys.stdin.encoding)
276 #
276 #
277 # first, to ensure that shlex gets a normal string. Input from anyone who
277 # first, to ensure that shlex gets a normal string. Input from anyone who
278 # knows more about unicode and shlex than I would be good to have here...
278 # knows more about unicode and shlex than I would be good to have here...
279 lex = shlex.shlex(s, posix=posix)
279 lex = shlex.shlex(s, posix=posix)
280 lex.whitespace_split = True
280 lex.whitespace_split = True
281 return list(lex)
281 return list(lex)
282
282
283 def system(cmd,verbose=0,debug=0,header=''):
283 def system(cmd,verbose=0,debug=0,header=''):
284 """Execute a system command, return its exit status.
284 """Execute a system command, return its exit status.
285
285
286 Options:
286 Options:
287
287
288 - verbose (0): print the command to be executed.
288 - verbose (0): print the command to be executed.
289
289
290 - debug (0): only print, do not actually execute.
290 - debug (0): only print, do not actually execute.
291
291
292 - header (''): Header to print on screen prior to the executed command (it
292 - header (''): Header to print on screen prior to the executed command (it
293 is only prepended to the command, no newlines are added).
293 is only prepended to the command, no newlines are added).
294
294
295 Note: a stateful version of this function is available through the
295 Note: a stateful version of this function is available through the
296 SystemExec class."""
296 SystemExec class."""
297
297
298 stat = 0
298 stat = 0
299 if verbose or debug: print header+cmd
299 if verbose or debug: print header+cmd
300 sys.stdout.flush()
300 sys.stdout.flush()
301 if not debug: stat = os.system(cmd)
301 if not debug: stat = os.system(cmd)
302 return stat
302 return stat
303
303
304 def abbrev_cwd():
304 def abbrev_cwd():
305 """ Return abbreviated version of cwd, e.g. d:mydir """
305 """ Return abbreviated version of cwd, e.g. d:mydir """
306 cwd = os.getcwd()
306 cwd = os.getcwd()
307 drivepart = ''
307 drivepart = ''
308 if sys.platform == 'win32':
308 if sys.platform == 'win32':
309 if len(cwd) < 4:
309 if len(cwd) < 4:
310 return cwd
310 return cwd
311 drivepart = os.path.splitdrive(cwd)[0]
311 drivepart = os.path.splitdrive(cwd)[0]
312 return (drivepart + (
312 return (drivepart + (
313 cwd == '/' and '/' or \
313 cwd == '/' and '/' or \
314 os.path.basename(cwd)))
314 os.path.basename(cwd)))
315
315
316
316
317 # This function is used by ipython in a lot of places to make system calls.
317 # This function is used by ipython in a lot of places to make system calls.
318 # We need it to be slightly different under win32, due to the vagaries of
318 # We need it to be slightly different under win32, due to the vagaries of
319 # 'network shares'. A win32 override is below.
319 # 'network shares'. A win32 override is below.
320
320
321 def shell(cmd,verbose=0,debug=0,header=''):
321 def shell(cmd,verbose=0,debug=0,header=''):
322 """Execute a command in the system shell, always return None.
322 """Execute a command in the system shell, always return None.
323
323
324 Options:
324 Options:
325
325
326 - verbose (0): print the command to be executed.
326 - verbose (0): print the command to be executed.
327
327
328 - debug (0): only print, do not actually execute.
328 - debug (0): only print, do not actually execute.
329
329
330 - header (''): Header to print on screen prior to the executed command (it
330 - header (''): Header to print on screen prior to the executed command (it
331 is only prepended to the command, no newlines are added).
331 is only prepended to the command, no newlines are added).
332
332
333 Note: this is similar to genutils.system(), but it returns None so it can
333 Note: this is similar to genutils.system(), but it returns None so it can
334 be conveniently used in interactive loops without getting the return value
334 be conveniently used in interactive loops without getting the return value
335 (typically 0) printed many times."""
335 (typically 0) printed many times."""
336
336
337 stat = 0
337 stat = 0
338 if verbose or debug: print header+cmd
338 if verbose or debug: print header+cmd
339 # flush stdout so we don't mangle python's buffering
339 # flush stdout so we don't mangle python's buffering
340 sys.stdout.flush()
340 sys.stdout.flush()
341
341
342 if not debug:
342 if not debug:
343 platutils.set_term_title("IPy " + cmd)
343 platutils.set_term_title("IPy " + cmd)
344 os.system(cmd)
344 os.system(cmd)
345 platutils.set_term_title("IPy " + abbrev_cwd())
345 platutils.set_term_title("IPy " + abbrev_cwd())
346
346
347 # override shell() for win32 to deal with network shares
347 # override shell() for win32 to deal with network shares
348 if os.name in ('nt','dos'):
348 if os.name in ('nt','dos'):
349
349
350 shell_ori = shell
350 shell_ori = shell
351
351
352 def shell(cmd,verbose=0,debug=0,header=''):
352 def shell(cmd,verbose=0,debug=0,header=''):
353 if os.getcwd().startswith(r"\\"):
353 if os.getcwd().startswith(r"\\"):
354 path = os.getcwd()
354 path = os.getcwd()
355 # change to c drive (cannot be on UNC-share when issuing os.system,
355 # change to c drive (cannot be on UNC-share when issuing os.system,
356 # as cmd.exe cannot handle UNC addresses)
356 # as cmd.exe cannot handle UNC addresses)
357 os.chdir("c:")
357 os.chdir("c:")
358 # issue pushd to the UNC-share and then run the command
358 # issue pushd to the UNC-share and then run the command
359 try:
359 try:
360 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
360 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
361 finally:
361 finally:
362 os.chdir(path)
362 os.chdir(path)
363 else:
363 else:
364 shell_ori(cmd,verbose,debug,header)
364 shell_ori(cmd,verbose,debug,header)
365
365
366 shell.__doc__ = shell_ori.__doc__
366 shell.__doc__ = shell_ori.__doc__
367
367
368 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
368 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
369 """Dummy substitute for perl's backquotes.
369 """Dummy substitute for perl's backquotes.
370
370
371 Executes a command and returns the output.
371 Executes a command and returns the output.
372
372
373 Accepts the same arguments as system(), plus:
373 Accepts the same arguments as system(), plus:
374
374
375 - split(0): if true, the output is returned as a list split on newlines.
375 - split(0): if true, the output is returned as a list split on newlines.
376
376
377 Note: a stateful version of this function is available through the
377 Note: a stateful version of this function is available through the
378 SystemExec class.
378 SystemExec class.
379
379
380 This is pretty much deprecated and rarely used,
380 This is pretty much deprecated and rarely used,
381 genutils.getoutputerror may be what you need.
381 genutils.getoutputerror may be what you need.
382
382
383 """
383 """
384
384
385 if verbose or debug: print header+cmd
385 if verbose or debug: print header+cmd
386 if not debug:
386 if not debug:
387 output = os.popen(cmd).read()
387 output = os.popen(cmd).read()
388 # stipping last \n is here for backwards compat.
388 # stipping last \n is here for backwards compat.
389 if output.endswith('\n'):
389 if output.endswith('\n'):
390 output = output[:-1]
390 output = output[:-1]
391 if split:
391 if split:
392 return output.split('\n')
392 return output.split('\n')
393 else:
393 else:
394 return output
394 return output
395
395
396 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
396 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
397 """Return (standard output,standard error) of executing cmd in a shell.
397 """Return (standard output,standard error) of executing cmd in a shell.
398
398
399 Accepts the same arguments as system(), plus:
399 Accepts the same arguments as system(), plus:
400
400
401 - split(0): if true, each of stdout/err is returned as a list split on
401 - split(0): if true, each of stdout/err is returned as a list split on
402 newlines.
402 newlines.
403
403
404 Note: a stateful version of this function is available through the
404 Note: a stateful version of this function is available through the
405 SystemExec class."""
405 SystemExec class."""
406
406
407 if verbose or debug: print header+cmd
407 if verbose or debug: print header+cmd
408 if not cmd:
408 if not cmd:
409 if split:
409 if split:
410 return [],[]
410 return [],[]
411 else:
411 else:
412 return '',''
412 return '',''
413 if not debug:
413 if not debug:
414 pin,pout,perr = os.popen3(cmd)
414 pin,pout,perr = os.popen3(cmd)
415 tout = pout.read().rstrip()
415 tout = pout.read().rstrip()
416 terr = perr.read().rstrip()
416 terr = perr.read().rstrip()
417 pin.close()
417 pin.close()
418 pout.close()
418 pout.close()
419 perr.close()
419 perr.close()
420 if split:
420 if split:
421 return tout.split('\n'),terr.split('\n')
421 return tout.split('\n'),terr.split('\n')
422 else:
422 else:
423 return tout,terr
423 return tout,terr
424
424
425 # for compatibility with older naming conventions
425 # for compatibility with older naming conventions
426 xsys = system
426 xsys = system
427 bq = getoutput
427 bq = getoutput
428
428
429 class SystemExec:
429 class SystemExec:
430 """Access the system and getoutput functions through a stateful interface.
430 """Access the system and getoutput functions through a stateful interface.
431
431
432 Note: here we refer to the system and getoutput functions from this
432 Note: here we refer to the system and getoutput functions from this
433 library, not the ones from the standard python library.
433 library, not the ones from the standard python library.
434
434
435 This class offers the system and getoutput functions as methods, but the
435 This class offers the system and getoutput functions as methods, but the
436 verbose, debug and header parameters can be set for the instance (at
436 verbose, debug and header parameters can be set for the instance (at
437 creation time or later) so that they don't need to be specified on each
437 creation time or later) so that they don't need to be specified on each
438 call.
438 call.
439
439
440 For efficiency reasons, there's no way to override the parameters on a
440 For efficiency reasons, there's no way to override the parameters on a
441 per-call basis other than by setting instance attributes. If you need
441 per-call basis other than by setting instance attributes. If you need
442 local overrides, it's best to directly call system() or getoutput().
442 local overrides, it's best to directly call system() or getoutput().
443
443
444 The following names are provided as alternate options:
444 The following names are provided as alternate options:
445 - xsys: alias to system
445 - xsys: alias to system
446 - bq: alias to getoutput
446 - bq: alias to getoutput
447
447
448 An instance can then be created as:
448 An instance can then be created as:
449 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
449 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
450
450
451 And used as:
451 And used as:
452 >>> sysexec.xsys('pwd')
452 >>> sysexec.xsys('pwd')
453 >>> dirlist = sysexec.bq('ls -l')
453 >>> dirlist = sysexec.bq('ls -l')
454 """
454 """
455
455
456 def __init__(self,verbose=0,debug=0,header='',split=0):
456 def __init__(self,verbose=0,debug=0,header='',split=0):
457 """Specify the instance's values for verbose, debug and header."""
457 """Specify the instance's values for verbose, debug and header."""
458 setattr_list(self,'verbose debug header split')
458 setattr_list(self,'verbose debug header split')
459
459
460 def system(self,cmd):
460 def system(self,cmd):
461 """Stateful interface to system(), with the same keyword parameters."""
461 """Stateful interface to system(), with the same keyword parameters."""
462
462
463 system(cmd,self.verbose,self.debug,self.header)
463 system(cmd,self.verbose,self.debug,self.header)
464
464
465 def shell(self,cmd):
465 def shell(self,cmd):
466 """Stateful interface to shell(), with the same keyword parameters."""
466 """Stateful interface to shell(), with the same keyword parameters."""
467
467
468 shell(cmd,self.verbose,self.debug,self.header)
468 shell(cmd,self.verbose,self.debug,self.header)
469
469
470 xsys = system # alias
470 xsys = system # alias
471
471
472 def getoutput(self,cmd):
472 def getoutput(self,cmd):
473 """Stateful interface to getoutput()."""
473 """Stateful interface to getoutput()."""
474
474
475 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
475 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
476
476
477 def getoutputerror(self,cmd):
477 def getoutputerror(self,cmd):
478 """Stateful interface to getoutputerror()."""
478 """Stateful interface to getoutputerror()."""
479
479
480 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
480 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
481
481
482 bq = getoutput # alias
482 bq = getoutput # alias
483
483
484 #-----------------------------------------------------------------------------
484 #-----------------------------------------------------------------------------
485 def mutex_opts(dict,ex_op):
485 def mutex_opts(dict,ex_op):
486 """Check for presence of mutually exclusive keys in a dict.
486 """Check for presence of mutually exclusive keys in a dict.
487
487
488 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
488 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
489 for op1,op2 in ex_op:
489 for op1,op2 in ex_op:
490 if op1 in dict and op2 in dict:
490 if op1 in dict and op2 in dict:
491 raise ValueError,'\n*** ERROR in Arguments *** '\
491 raise ValueError,'\n*** ERROR in Arguments *** '\
492 'Options '+op1+' and '+op2+' are mutually exclusive.'
492 'Options '+op1+' and '+op2+' are mutually exclusive.'
493
493
494 #-----------------------------------------------------------------------------
494 #-----------------------------------------------------------------------------
495 def get_py_filename(name):
495 def get_py_filename(name):
496 """Return a valid python filename in the current directory.
496 """Return a valid python filename in the current directory.
497
497
498 If the given name is not a file, it adds '.py' and searches again.
498 If the given name is not a file, it adds '.py' and searches again.
499 Raises IOError with an informative message if the file isn't found."""
499 Raises IOError with an informative message if the file isn't found."""
500
500
501 name = os.path.expanduser(name)
501 name = os.path.expanduser(name)
502 if not os.path.isfile(name) and not name.endswith('.py'):
502 if not os.path.isfile(name) and not name.endswith('.py'):
503 name += '.py'
503 name += '.py'
504 if os.path.isfile(name):
504 if os.path.isfile(name):
505 return name
505 return name
506 else:
506 else:
507 raise IOError,'File `%s` not found.' % name
507 raise IOError,'File `%s` not found.' % name
508
508
509 #-----------------------------------------------------------------------------
509 #-----------------------------------------------------------------------------
510 def filefind(fname,alt_dirs = None):
510 def filefind(fname,alt_dirs = None):
511 """Return the given filename either in the current directory, if it
511 """Return the given filename either in the current directory, if it
512 exists, or in a specified list of directories.
512 exists, or in a specified list of directories.
513
513
514 ~ expansion is done on all file and directory names.
514 ~ expansion is done on all file and directory names.
515
515
516 Upon an unsuccessful search, raise an IOError exception."""
516 Upon an unsuccessful search, raise an IOError exception."""
517
517
518 if alt_dirs is None:
518 if alt_dirs is None:
519 try:
519 try:
520 alt_dirs = get_home_dir()
520 alt_dirs = get_home_dir()
521 except HomeDirError:
521 except HomeDirError:
522 alt_dirs = os.getcwd()
522 alt_dirs = os.getcwd()
523 search = [fname] + list_strings(alt_dirs)
523 search = [fname] + list_strings(alt_dirs)
524 search = map(os.path.expanduser,search)
524 search = map(os.path.expanduser,search)
525 #print 'search list for',fname,'list:',search # dbg
525 #print 'search list for',fname,'list:',search # dbg
526 fname = search[0]
526 fname = search[0]
527 if os.path.isfile(fname):
527 if os.path.isfile(fname):
528 return fname
528 return fname
529 for direc in search[1:]:
529 for direc in search[1:]:
530 testname = os.path.join(direc,fname)
530 testname = os.path.join(direc,fname)
531 #print 'testname',testname # dbg
531 #print 'testname',testname # dbg
532 if os.path.isfile(testname):
532 if os.path.isfile(testname):
533 return testname
533 return testname
534 raise IOError,'File' + `fname` + \
534 raise IOError,'File' + `fname` + \
535 ' not found in current or supplied directories:' + `alt_dirs`
535 ' not found in current or supplied directories:' + `alt_dirs`
536
536
537 #----------------------------------------------------------------------------
537 #----------------------------------------------------------------------------
538 def file_read(filename):
538 def file_read(filename):
539 """Read a file and close it. Returns the file source."""
539 """Read a file and close it. Returns the file source."""
540 fobj = open(filename,'r');
540 fobj = open(filename,'r');
541 source = fobj.read();
541 source = fobj.read();
542 fobj.close()
542 fobj.close()
543 return source
543 return source
544
544
545 def file_readlines(filename):
545 def file_readlines(filename):
546 """Read a file and close it. Returns the file source using readlines()."""
546 """Read a file and close it. Returns the file source using readlines()."""
547 fobj = open(filename,'r');
547 fobj = open(filename,'r');
548 lines = fobj.readlines();
548 lines = fobj.readlines();
549 fobj.close()
549 fobj.close()
550 return lines
550 return lines
551
551
552 #----------------------------------------------------------------------------
552 #----------------------------------------------------------------------------
553 def target_outdated(target,deps):
553 def target_outdated(target,deps):
554 """Determine whether a target is out of date.
554 """Determine whether a target is out of date.
555
555
556 target_outdated(target,deps) -> 1/0
556 target_outdated(target,deps) -> 1/0
557
557
558 deps: list of filenames which MUST exist.
558 deps: list of filenames which MUST exist.
559 target: single filename which may or may not exist.
559 target: single filename which may or may not exist.
560
560
561 If target doesn't exist or is older than any file listed in deps, return
561 If target doesn't exist or is older than any file listed in deps, return
562 true, otherwise return false.
562 true, otherwise return false.
563 """
563 """
564 try:
564 try:
565 target_time = os.path.getmtime(target)
565 target_time = os.path.getmtime(target)
566 except os.error:
566 except os.error:
567 return 1
567 return 1
568 for dep in deps:
568 for dep in deps:
569 dep_time = os.path.getmtime(dep)
569 dep_time = os.path.getmtime(dep)
570 if dep_time > target_time:
570 if dep_time > target_time:
571 #print "For target",target,"Dep failed:",dep # dbg
571 #print "For target",target,"Dep failed:",dep # dbg
572 #print "times (dep,tar):",dep_time,target_time # dbg
572 #print "times (dep,tar):",dep_time,target_time # dbg
573 return 1
573 return 1
574 return 0
574 return 0
575
575
576 #-----------------------------------------------------------------------------
576 #-----------------------------------------------------------------------------
577 def target_update(target,deps,cmd):
577 def target_update(target,deps,cmd):
578 """Update a target with a given command given a list of dependencies.
578 """Update a target with a given command given a list of dependencies.
579
579
580 target_update(target,deps,cmd) -> runs cmd if target is outdated.
580 target_update(target,deps,cmd) -> runs cmd if target is outdated.
581
581
582 This is just a wrapper around target_outdated() which calls the given
582 This is just a wrapper around target_outdated() which calls the given
583 command if target is outdated."""
583 command if target is outdated."""
584
584
585 if target_outdated(target,deps):
585 if target_outdated(target,deps):
586 xsys(cmd)
586 xsys(cmd)
587
587
588 #----------------------------------------------------------------------------
588 #----------------------------------------------------------------------------
589 def unquote_ends(istr):
589 def unquote_ends(istr):
590 """Remove a single pair of quotes from the endpoints of a string."""
590 """Remove a single pair of quotes from the endpoints of a string."""
591
591
592 if not istr:
592 if not istr:
593 return istr
593 return istr
594 if (istr[0]=="'" and istr[-1]=="'") or \
594 if (istr[0]=="'" and istr[-1]=="'") or \
595 (istr[0]=='"' and istr[-1]=='"'):
595 (istr[0]=='"' and istr[-1]=='"'):
596 return istr[1:-1]
596 return istr[1:-1]
597 else:
597 else:
598 return istr
598 return istr
599
599
600 #----------------------------------------------------------------------------
600 #----------------------------------------------------------------------------
601 def process_cmdline(argv,names=[],defaults={},usage=''):
601 def process_cmdline(argv,names=[],defaults={},usage=''):
602 """ Process command-line options and arguments.
602 """ Process command-line options and arguments.
603
603
604 Arguments:
604 Arguments:
605
605
606 - argv: list of arguments, typically sys.argv.
606 - argv: list of arguments, typically sys.argv.
607
607
608 - names: list of option names. See DPyGetOpt docs for details on options
608 - names: list of option names. See DPyGetOpt docs for details on options
609 syntax.
609 syntax.
610
610
611 - defaults: dict of default values.
611 - defaults: dict of default values.
612
612
613 - usage: optional usage notice to print if a wrong argument is passed.
613 - usage: optional usage notice to print if a wrong argument is passed.
614
614
615 Return a dict of options and a list of free arguments."""
615 Return a dict of options and a list of free arguments."""
616
616
617 getopt = DPyGetOpt.DPyGetOpt()
617 getopt = DPyGetOpt.DPyGetOpt()
618 getopt.setIgnoreCase(0)
618 getopt.setIgnoreCase(0)
619 getopt.parseConfiguration(names)
619 getopt.parseConfiguration(names)
620
620
621 try:
621 try:
622 getopt.processArguments(argv)
622 getopt.processArguments(argv)
623 except:
623 except DPyGetOpt.ArgumentError, exc:
624 print usage
624 print usage
625 warn(`sys.exc_value`,level=4)
625 warn('"%s"' % exc,level=4)
626
626
627 defaults.update(getopt.optionValues)
627 defaults.update(getopt.optionValues)
628 args = getopt.freeValues
628 args = getopt.freeValues
629
629
630 return defaults,args
630 return defaults,args
631
631
632 #----------------------------------------------------------------------------
632 #----------------------------------------------------------------------------
633 def optstr2types(ostr):
633 def optstr2types(ostr):
634 """Convert a string of option names to a dict of type mappings.
634 """Convert a string of option names to a dict of type mappings.
635
635
636 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
636 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
637
637
638 This is used to get the types of all the options in a string formatted
638 This is used to get the types of all the options in a string formatted
639 with the conventions of DPyGetOpt. The 'type' None is used for options
639 with the conventions of DPyGetOpt. The 'type' None is used for options
640 which are strings (they need no further conversion). This function's main
640 which are strings (they need no further conversion). This function's main
641 use is to get a typemap for use with read_dict().
641 use is to get a typemap for use with read_dict().
642 """
642 """
643
643
644 typeconv = {None:'',int:'',float:''}
644 typeconv = {None:'',int:'',float:''}
645 typemap = {'s':None,'i':int,'f':float}
645 typemap = {'s':None,'i':int,'f':float}
646 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
646 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
647
647
648 for w in ostr.split():
648 for w in ostr.split():
649 oname,alias,otype = opt_re.match(w).groups()
649 oname,alias,otype = opt_re.match(w).groups()
650 if otype == '' or alias == '!': # simple switches are integers too
650 if otype == '' or alias == '!': # simple switches are integers too
651 otype = 'i'
651 otype = 'i'
652 typeconv[typemap[otype]] += oname + ' '
652 typeconv[typemap[otype]] += oname + ' '
653 return typeconv
653 return typeconv
654
654
655 #----------------------------------------------------------------------------
655 #----------------------------------------------------------------------------
656 def read_dict(filename,type_conv=None,**opt):
656 def read_dict(filename,type_conv=None,**opt):
657
657
658 """Read a dictionary of key=value pairs from an input file, optionally
658 """Read a dictionary of key=value pairs from an input file, optionally
659 performing conversions on the resulting values.
659 performing conversions on the resulting values.
660
660
661 read_dict(filename,type_conv,**opt) -> dict
661 read_dict(filename,type_conv,**opt) -> dict
662
662
663 Only one value per line is accepted, the format should be
663 Only one value per line is accepted, the format should be
664 # optional comments are ignored
664 # optional comments are ignored
665 key value\n
665 key value\n
666
666
667 Args:
667 Args:
668
668
669 - type_conv: A dictionary specifying which keys need to be converted to
669 - type_conv: A dictionary specifying which keys need to be converted to
670 which types. By default all keys are read as strings. This dictionary
670 which types. By default all keys are read as strings. This dictionary
671 should have as its keys valid conversion functions for strings
671 should have as its keys valid conversion functions for strings
672 (int,long,float,complex, or your own). The value for each key
672 (int,long,float,complex, or your own). The value for each key
673 (converter) should be a whitespace separated string containing the names
673 (converter) should be a whitespace separated string containing the names
674 of all the entries in the file to be converted using that function. For
674 of all the entries in the file to be converted using that function. For
675 keys to be left alone, use None as the conversion function (only needed
675 keys to be left alone, use None as the conversion function (only needed
676 with purge=1, see below).
676 with purge=1, see below).
677
677
678 - opt: dictionary with extra options as below (default in parens)
678 - opt: dictionary with extra options as below (default in parens)
679
679
680 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
680 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
681 of the dictionary to be returned. If purge is going to be used, the
681 of the dictionary to be returned. If purge is going to be used, the
682 set of keys to be left as strings also has to be explicitly specified
682 set of keys to be left as strings also has to be explicitly specified
683 using the (non-existent) conversion function None.
683 using the (non-existent) conversion function None.
684
684
685 fs(None): field separator. This is the key/value separator to be used
685 fs(None): field separator. This is the key/value separator to be used
686 when parsing the file. The None default means any whitespace [behavior
686 when parsing the file. The None default means any whitespace [behavior
687 of string.split()].
687 of string.split()].
688
688
689 strip(0): if 1, strip string values of leading/trailinig whitespace.
689 strip(0): if 1, strip string values of leading/trailinig whitespace.
690
690
691 warn(1): warning level if requested keys are not found in file.
691 warn(1): warning level if requested keys are not found in file.
692 - 0: silently ignore.
692 - 0: silently ignore.
693 - 1: inform but proceed.
693 - 1: inform but proceed.
694 - 2: raise KeyError exception.
694 - 2: raise KeyError exception.
695
695
696 no_empty(0): if 1, remove keys with whitespace strings as a value.
696 no_empty(0): if 1, remove keys with whitespace strings as a value.
697
697
698 unique([]): list of keys (or space separated string) which can't be
698 unique([]): list of keys (or space separated string) which can't be
699 repeated. If one such key is found in the file, each new instance
699 repeated. If one such key is found in the file, each new instance
700 overwrites the previous one. For keys not listed here, the behavior is
700 overwrites the previous one. For keys not listed here, the behavior is
701 to make a list of all appearances.
701 to make a list of all appearances.
702
702
703 Example:
703 Example:
704 If the input file test.ini has:
704 If the input file test.ini has:
705 i 3
705 i 3
706 x 4.5
706 x 4.5
707 y 5.5
707 y 5.5
708 s hi ho
708 s hi ho
709 Then:
709 Then:
710
710
711 >>> type_conv={int:'i',float:'x',None:'s'}
711 >>> type_conv={int:'i',float:'x',None:'s'}
712 >>> read_dict('test.ini')
712 >>> read_dict('test.ini')
713 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
713 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
714 >>> read_dict('test.ini',type_conv)
714 >>> read_dict('test.ini',type_conv)
715 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
715 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
716 >>> read_dict('test.ini',type_conv,purge=1)
716 >>> read_dict('test.ini',type_conv,purge=1)
717 {'i': 3, 's': 'hi ho', 'x': 4.5}
717 {'i': 3, 's': 'hi ho', 'x': 4.5}
718 """
718 """
719
719
720 # starting config
720 # starting config
721 opt.setdefault('purge',0)
721 opt.setdefault('purge',0)
722 opt.setdefault('fs',None) # field sep defaults to any whitespace
722 opt.setdefault('fs',None) # field sep defaults to any whitespace
723 opt.setdefault('strip',0)
723 opt.setdefault('strip',0)
724 opt.setdefault('warn',1)
724 opt.setdefault('warn',1)
725 opt.setdefault('no_empty',0)
725 opt.setdefault('no_empty',0)
726 opt.setdefault('unique','')
726 opt.setdefault('unique','')
727 if type(opt['unique']) in StringTypes:
727 if type(opt['unique']) in StringTypes:
728 unique_keys = qw(opt['unique'])
728 unique_keys = qw(opt['unique'])
729 elif type(opt['unique']) in (types.TupleType,types.ListType):
729 elif type(opt['unique']) in (types.TupleType,types.ListType):
730 unique_keys = opt['unique']
730 unique_keys = opt['unique']
731 else:
731 else:
732 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
732 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
733
733
734 dict = {}
734 dict = {}
735 # first read in table of values as strings
735 # first read in table of values as strings
736 file = open(filename,'r')
736 file = open(filename,'r')
737 for line in file.readlines():
737 for line in file.readlines():
738 line = line.strip()
738 line = line.strip()
739 if len(line) and line[0]=='#': continue
739 if len(line) and line[0]=='#': continue
740 if len(line)>0:
740 if len(line)>0:
741 lsplit = line.split(opt['fs'],1)
741 lsplit = line.split(opt['fs'],1)
742 try:
742 try:
743 key,val = lsplit
743 key,val = lsplit
744 except ValueError:
744 except ValueError:
745 key,val = lsplit[0],''
745 key,val = lsplit[0],''
746 key = key.strip()
746 key = key.strip()
747 if opt['strip']: val = val.strip()
747 if opt['strip']: val = val.strip()
748 if val == "''" or val == '""': val = ''
748 if val == "''" or val == '""': val = ''
749 if opt['no_empty'] and (val=='' or val.isspace()):
749 if opt['no_empty'] and (val=='' or val.isspace()):
750 continue
750 continue
751 # if a key is found more than once in the file, build a list
751 # if a key is found more than once in the file, build a list
752 # unless it's in the 'unique' list. In that case, last found in file
752 # unless it's in the 'unique' list. In that case, last found in file
753 # takes precedence. User beware.
753 # takes precedence. User beware.
754 try:
754 try:
755 if dict[key] and key in unique_keys:
755 if dict[key] and key in unique_keys:
756 dict[key] = val
756 dict[key] = val
757 elif type(dict[key]) is types.ListType:
757 elif type(dict[key]) is types.ListType:
758 dict[key].append(val)
758 dict[key].append(val)
759 else:
759 else:
760 dict[key] = [dict[key],val]
760 dict[key] = [dict[key],val]
761 except KeyError:
761 except KeyError:
762 dict[key] = val
762 dict[key] = val
763 # purge if requested
763 # purge if requested
764 if opt['purge']:
764 if opt['purge']:
765 accepted_keys = qwflat(type_conv.values())
765 accepted_keys = qwflat(type_conv.values())
766 for key in dict.keys():
766 for key in dict.keys():
767 if key in accepted_keys: continue
767 if key in accepted_keys: continue
768 del(dict[key])
768 del(dict[key])
769 # now convert if requested
769 # now convert if requested
770 if type_conv==None: return dict
770 if type_conv==None: return dict
771 conversions = type_conv.keys()
771 conversions = type_conv.keys()
772 try: conversions.remove(None)
772 try: conversions.remove(None)
773 except: pass
773 except: pass
774 for convert in conversions:
774 for convert in conversions:
775 for val in qw(type_conv[convert]):
775 for val in qw(type_conv[convert]):
776 try:
776 try:
777 dict[val] = convert(dict[val])
777 dict[val] = convert(dict[val])
778 except KeyError,e:
778 except KeyError,e:
779 if opt['warn'] == 0:
779 if opt['warn'] == 0:
780 pass
780 pass
781 elif opt['warn'] == 1:
781 elif opt['warn'] == 1:
782 print >>sys.stderr, 'Warning: key',val,\
782 print >>sys.stderr, 'Warning: key',val,\
783 'not found in file',filename
783 'not found in file',filename
784 elif opt['warn'] == 2:
784 elif opt['warn'] == 2:
785 raise KeyError,e
785 raise KeyError,e
786 else:
786 else:
787 raise ValueError,'Warning level must be 0,1 or 2'
787 raise ValueError,'Warning level must be 0,1 or 2'
788
788
789 return dict
789 return dict
790
790
791 #----------------------------------------------------------------------------
791 #----------------------------------------------------------------------------
792 def flag_calls(func):
792 def flag_calls(func):
793 """Wrap a function to detect and flag when it gets called.
793 """Wrap a function to detect and flag when it gets called.
794
794
795 This is a decorator which takes a function and wraps it in a function with
795 This is a decorator which takes a function and wraps it in a function with
796 a 'called' attribute. wrapper.called is initialized to False.
796 a 'called' attribute. wrapper.called is initialized to False.
797
797
798 The wrapper.called attribute is set to False right before each call to the
798 The wrapper.called attribute is set to False right before each call to the
799 wrapped function, so if the call fails it remains False. After the call
799 wrapped function, so if the call fails it remains False. After the call
800 completes, wrapper.called is set to True and the output is returned.
800 completes, wrapper.called is set to True and the output is returned.
801
801
802 Testing for truth in wrapper.called allows you to determine if a call to
802 Testing for truth in wrapper.called allows you to determine if a call to
803 func() was attempted and succeeded."""
803 func() was attempted and succeeded."""
804
804
805 def wrapper(*args,**kw):
805 def wrapper(*args,**kw):
806 wrapper.called = False
806 wrapper.called = False
807 out = func(*args,**kw)
807 out = func(*args,**kw)
808 wrapper.called = True
808 wrapper.called = True
809 return out
809 return out
810
810
811 wrapper.called = False
811 wrapper.called = False
812 wrapper.__doc__ = func.__doc__
812 wrapper.__doc__ = func.__doc__
813 return wrapper
813 return wrapper
814
814
815 #----------------------------------------------------------------------------
815 #----------------------------------------------------------------------------
816 def dhook_wrap(func,*a,**k):
816 def dhook_wrap(func,*a,**k):
817 """Wrap a function call in a sys.displayhook controller.
817 """Wrap a function call in a sys.displayhook controller.
818
818
819 Returns a wrapper around func which calls func, with all its arguments and
819 Returns a wrapper around func which calls func, with all its arguments and
820 keywords unmodified, using the default sys.displayhook. Since IPython
820 keywords unmodified, using the default sys.displayhook. Since IPython
821 modifies sys.displayhook, it breaks the behavior of certain systems that
821 modifies sys.displayhook, it breaks the behavior of certain systems that
822 rely on the default behavior, notably doctest.
822 rely on the default behavior, notably doctest.
823 """
823 """
824
824
825 def f(*a,**k):
825 def f(*a,**k):
826
826
827 dhook_s = sys.displayhook
827 dhook_s = sys.displayhook
828 sys.displayhook = sys.__displayhook__
828 sys.displayhook = sys.__displayhook__
829 try:
829 try:
830 out = func(*a,**k)
830 out = func(*a,**k)
831 finally:
831 finally:
832 sys.displayhook = dhook_s
832 sys.displayhook = dhook_s
833
833
834 return out
834 return out
835
835
836 f.__doc__ = func.__doc__
836 f.__doc__ = func.__doc__
837 return f
837 return f
838
838
839 #----------------------------------------------------------------------------
839 #----------------------------------------------------------------------------
840 def doctest_reload():
840 def doctest_reload():
841 """Properly reload doctest to reuse it interactively.
841 """Properly reload doctest to reuse it interactively.
842
842
843 This routine:
843 This routine:
844
844
845 - reloads doctest
845 - reloads doctest
846
846
847 - resets its global 'master' attribute to None, so that multiple uses of
847 - resets its global 'master' attribute to None, so that multiple uses of
848 the module interactively don't produce cumulative reports.
848 the module interactively don't produce cumulative reports.
849
849
850 - Monkeypatches its core test runner method to protect it from IPython's
850 - Monkeypatches its core test runner method to protect it from IPython's
851 modified displayhook. Doctest expects the default displayhook behavior
851 modified displayhook. Doctest expects the default displayhook behavior
852 deep down, so our modification breaks it completely. For this reason, a
852 deep down, so our modification breaks it completely. For this reason, a
853 hard monkeypatch seems like a reasonable solution rather than asking
853 hard monkeypatch seems like a reasonable solution rather than asking
854 users to manually use a different doctest runner when under IPython."""
854 users to manually use a different doctest runner when under IPython."""
855
855
856 import doctest
856 import doctest
857 reload(doctest)
857 reload(doctest)
858 doctest.master=None
858 doctest.master=None
859
859
860 try:
860 try:
861 doctest.DocTestRunner
861 doctest.DocTestRunner
862 except AttributeError:
862 except AttributeError:
863 # This is only for python 2.3 compatibility, remove once we move to
863 # This is only for python 2.3 compatibility, remove once we move to
864 # 2.4 only.
864 # 2.4 only.
865 pass
865 pass
866 else:
866 else:
867 doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run)
867 doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run)
868
868
869 #----------------------------------------------------------------------------
869 #----------------------------------------------------------------------------
870 class HomeDirError(Error):
870 class HomeDirError(Error):
871 pass
871 pass
872
872
873 def get_home_dir():
873 def get_home_dir():
874 """Return the closest possible equivalent to a 'home' directory.
874 """Return the closest possible equivalent to a 'home' directory.
875
875
876 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
876 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
877
877
878 Currently only Posix and NT are implemented, a HomeDirError exception is
878 Currently only Posix and NT are implemented, a HomeDirError exception is
879 raised for all other OSes. """
879 raised for all other OSes. """
880
880
881 isdir = os.path.isdir
881 isdir = os.path.isdir
882 env = os.environ
882 env = os.environ
883
883
884 # first, check py2exe distribution root directory for _ipython.
884 # first, check py2exe distribution root directory for _ipython.
885 # This overrides all. Normally does not exist.
885 # This overrides all. Normally does not exist.
886
886
887 if '\\library.zip\\' in IPython.__file__.lower():
887 if '\\library.zip\\' in IPython.__file__.lower():
888 root, rest = IPython.__file__.lower().split('library.zip')
888 root, rest = IPython.__file__.lower().split('library.zip')
889 if isdir(root + '_ipython'):
889 if isdir(root + '_ipython'):
890 os.environ["IPYKITROOT"] = root.rstrip('\\')
890 os.environ["IPYKITROOT"] = root.rstrip('\\')
891 return root
891 return root
892
892
893 try:
893 try:
894 homedir = env['HOME']
894 homedir = env['HOME']
895 if not isdir(homedir):
895 if not isdir(homedir):
896 # in case a user stuck some string which does NOT resolve to a
896 # in case a user stuck some string which does NOT resolve to a
897 # valid path, it's as good as if we hadn't foud it
897 # valid path, it's as good as if we hadn't foud it
898 raise KeyError
898 raise KeyError
899 return homedir
899 return homedir
900 except KeyError:
900 except KeyError:
901 if os.name == 'posix':
901 if os.name == 'posix':
902 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
902 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
903 elif os.name == 'nt':
903 elif os.name == 'nt':
904 # For some strange reason, win9x returns 'nt' for os.name.
904 # For some strange reason, win9x returns 'nt' for os.name.
905 try:
905 try:
906 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
906 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
907 if not isdir(homedir):
907 if not isdir(homedir):
908 homedir = os.path.join(env['USERPROFILE'])
908 homedir = os.path.join(env['USERPROFILE'])
909 if not isdir(homedir):
909 if not isdir(homedir):
910 raise HomeDirError
910 raise HomeDirError
911 return homedir
911 return homedir
912 except:
912 except:
913 try:
913 try:
914 # Use the registry to get the 'My Documents' folder.
914 # Use the registry to get the 'My Documents' folder.
915 import _winreg as wreg
915 import _winreg as wreg
916 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
916 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
917 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
917 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
918 homedir = wreg.QueryValueEx(key,'Personal')[0]
918 homedir = wreg.QueryValueEx(key,'Personal')[0]
919 key.Close()
919 key.Close()
920 if not isdir(homedir):
920 if not isdir(homedir):
921 e = ('Invalid "Personal" folder registry key '
921 e = ('Invalid "Personal" folder registry key '
922 'typically "My Documents".\n'
922 'typically "My Documents".\n'
923 'Value: %s\n'
923 'Value: %s\n'
924 'This is not a valid directory on your system.' %
924 'This is not a valid directory on your system.' %
925 homedir)
925 homedir)
926 raise HomeDirError(e)
926 raise HomeDirError(e)
927 return homedir
927 return homedir
928 except HomeDirError:
928 except HomeDirError:
929 raise
929 raise
930 except:
930 except:
931 return 'C:\\'
931 return 'C:\\'
932 elif os.name == 'dos':
932 elif os.name == 'dos':
933 # Desperate, may do absurd things in classic MacOS. May work under DOS.
933 # Desperate, may do absurd things in classic MacOS. May work under DOS.
934 return 'C:\\'
934 return 'C:\\'
935 else:
935 else:
936 raise HomeDirError,'support for your operating system not implemented.'
936 raise HomeDirError,'support for your operating system not implemented.'
937
937
938 #****************************************************************************
938 #****************************************************************************
939 # strings and text
939 # strings and text
940
940
941 class LSString(str):
941 class LSString(str):
942 """String derivative with a special access attributes.
942 """String derivative with a special access attributes.
943
943
944 These are normal strings, but with the special attributes:
944 These are normal strings, but with the special attributes:
945
945
946 .l (or .list) : value as list (split on newlines).
946 .l (or .list) : value as list (split on newlines).
947 .n (or .nlstr): original value (the string itself).
947 .n (or .nlstr): original value (the string itself).
948 .s (or .spstr): value as whitespace-separated string.
948 .s (or .spstr): value as whitespace-separated string.
949 .p (or .paths): list of path objects
949 .p (or .paths): list of path objects
950
950
951 Any values which require transformations are computed only once and
951 Any values which require transformations are computed only once and
952 cached.
952 cached.
953
953
954 Such strings are very useful to efficiently interact with the shell, which
954 Such strings are very useful to efficiently interact with the shell, which
955 typically only understands whitespace-separated options for commands."""
955 typically only understands whitespace-separated options for commands."""
956
956
957 def get_list(self):
957 def get_list(self):
958 try:
958 try:
959 return self.__list
959 return self.__list
960 except AttributeError:
960 except AttributeError:
961 self.__list = self.split('\n')
961 self.__list = self.split('\n')
962 return self.__list
962 return self.__list
963
963
964 l = list = property(get_list)
964 l = list = property(get_list)
965
965
966 def get_spstr(self):
966 def get_spstr(self):
967 try:
967 try:
968 return self.__spstr
968 return self.__spstr
969 except AttributeError:
969 except AttributeError:
970 self.__spstr = self.replace('\n',' ')
970 self.__spstr = self.replace('\n',' ')
971 return self.__spstr
971 return self.__spstr
972
972
973 s = spstr = property(get_spstr)
973 s = spstr = property(get_spstr)
974
974
975 def get_nlstr(self):
975 def get_nlstr(self):
976 return self
976 return self
977
977
978 n = nlstr = property(get_nlstr)
978 n = nlstr = property(get_nlstr)
979
979
980 def get_paths(self):
980 def get_paths(self):
981 try:
981 try:
982 return self.__paths
982 return self.__paths
983 except AttributeError:
983 except AttributeError:
984 self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)]
984 self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)]
985 return self.__paths
985 return self.__paths
986
986
987 p = paths = property(get_paths)
987 p = paths = property(get_paths)
988
988
989 def print_lsstring(arg):
989 def print_lsstring(arg):
990 """ Prettier (non-repr-like) and more informative printer for LSString """
990 """ Prettier (non-repr-like) and more informative printer for LSString """
991 print "LSString (.p, .n, .l, .s available). Value:"
991 print "LSString (.p, .n, .l, .s available). Value:"
992 print arg
992 print arg
993
993
994 print_lsstring = result_display.when_type(LSString)(print_lsstring)
994 print_lsstring = result_display.when_type(LSString)(print_lsstring)
995
995
996 #----------------------------------------------------------------------------
996 #----------------------------------------------------------------------------
997 class SList(list):
997 class SList(list):
998 """List derivative with a special access attributes.
998 """List derivative with a special access attributes.
999
999
1000 These are normal lists, but with the special attributes:
1000 These are normal lists, but with the special attributes:
1001
1001
1002 .l (or .list) : value as list (the list itself).
1002 .l (or .list) : value as list (the list itself).
1003 .n (or .nlstr): value as a string, joined on newlines.
1003 .n (or .nlstr): value as a string, joined on newlines.
1004 .s (or .spstr): value as a string, joined on spaces.
1004 .s (or .spstr): value as a string, joined on spaces.
1005 .p (or .paths): list of path objects
1005 .p (or .paths): list of path objects
1006
1006
1007 Any values which require transformations are computed only once and
1007 Any values which require transformations are computed only once and
1008 cached."""
1008 cached."""
1009
1009
1010 def get_list(self):
1010 def get_list(self):
1011 return self
1011 return self
1012
1012
1013 l = list = property(get_list)
1013 l = list = property(get_list)
1014
1014
1015 def get_spstr(self):
1015 def get_spstr(self):
1016 try:
1016 try:
1017 return self.__spstr
1017 return self.__spstr
1018 except AttributeError:
1018 except AttributeError:
1019 self.__spstr = ' '.join(self)
1019 self.__spstr = ' '.join(self)
1020 return self.__spstr
1020 return self.__spstr
1021
1021
1022 s = spstr = property(get_spstr)
1022 s = spstr = property(get_spstr)
1023
1023
1024 def get_nlstr(self):
1024 def get_nlstr(self):
1025 try:
1025 try:
1026 return self.__nlstr
1026 return self.__nlstr
1027 except AttributeError:
1027 except AttributeError:
1028 self.__nlstr = '\n'.join(self)
1028 self.__nlstr = '\n'.join(self)
1029 return self.__nlstr
1029 return self.__nlstr
1030
1030
1031 n = nlstr = property(get_nlstr)
1031 n = nlstr = property(get_nlstr)
1032
1032
1033 def get_paths(self):
1033 def get_paths(self):
1034 try:
1034 try:
1035 return self.__paths
1035 return self.__paths
1036 except AttributeError:
1036 except AttributeError:
1037 self.__paths = [path(p) for p in self if os.path.exists(p)]
1037 self.__paths = [path(p) for p in self if os.path.exists(p)]
1038 return self.__paths
1038 return self.__paths
1039
1039
1040 p = paths = property(get_paths)
1040 p = paths = property(get_paths)
1041
1041
1042 def grep(self, pattern, prune = False):
1042 def grep(self, pattern, prune = False):
1043 """ Return all strings matching 'pattern' (a regex or callable)
1043 """ Return all strings matching 'pattern' (a regex or callable)
1044
1044
1045 This is case-insensitive. If prune is true, return all items
1045 This is case-insensitive. If prune is true, return all items
1046 NOT matching the pattern.
1046 NOT matching the pattern.
1047
1047
1048 Examples::
1048 Examples::
1049
1049
1050 a.grep( lambda x: x.startswith('C') )
1050 a.grep( lambda x: x.startswith('C') )
1051 a.grep('Cha.*log', prune=1)
1051 a.grep('Cha.*log', prune=1)
1052 """
1052 """
1053 if isinstance(pattern, basestring):
1053 if isinstance(pattern, basestring):
1054 pred = lambda x : re.search(pattern, x, re.IGNORECASE)
1054 pred = lambda x : re.search(pattern, x, re.IGNORECASE)
1055 else:
1055 else:
1056 pred = pattern
1056 pred = pattern
1057 if not prune:
1057 if not prune:
1058 return SList([el for el in self if pred(el)])
1058 return SList([el for el in self if pred(el)])
1059 else:
1059 else:
1060 return SList([el for el in self if not pred(el)])
1060 return SList([el for el in self if not pred(el)])
1061 def fields(self, *fields):
1061 def fields(self, *fields):
1062 """ Collect whitespace-separated fields from string list
1062 """ Collect whitespace-separated fields from string list
1063
1063
1064 Allows quick awk-like usage of string lists.
1064 Allows quick awk-like usage of string lists.
1065
1065
1066 Example data (in var a, created by 'a = !ls -l')::
1066 Example data (in var a, created by 'a = !ls -l')::
1067 -rwxrwxrwx 1 ville None 18 Dec 14 2006 ChangeLog
1067 -rwxrwxrwx 1 ville None 18 Dec 14 2006 ChangeLog
1068 drwxrwxrwx+ 6 ville None 0 Oct 24 18:05 IPython
1068 drwxrwxrwx+ 6 ville None 0 Oct 24 18:05 IPython
1069
1069
1070 a.fields(0) is ['-rwxrwxrwx', 'drwxrwxrwx+']
1070 a.fields(0) is ['-rwxrwxrwx', 'drwxrwxrwx+']
1071 a.fields(1,0) is ['1 -rwxrwxrwx', '6 drwxrwxrwx+']
1071 a.fields(1,0) is ['1 -rwxrwxrwx', '6 drwxrwxrwx+']
1072 (note the joining by space).
1072 (note the joining by space).
1073
1073
1074 IndexErrors are ignored.
1074 IndexErrors are ignored.
1075
1075
1076 Without args, fields() just split()'s the strings.
1076 Without args, fields() just split()'s the strings.
1077 """
1077 """
1078 if len(fields) == 0:
1078 if len(fields) == 0:
1079 return [el.split() for el in self]
1079 return [el.split() for el in self]
1080
1080
1081 res = SList()
1081 res = SList()
1082 for el in [f.split() for f in self]:
1082 for el in [f.split() for f in self]:
1083 lineparts = []
1083 lineparts = []
1084
1084
1085 for fd in fields:
1085 for fd in fields:
1086 try:
1086 try:
1087 lineparts.append(el[fd])
1087 lineparts.append(el[fd])
1088 except IndexError:
1088 except IndexError:
1089 pass
1089 pass
1090 if lineparts:
1090 if lineparts:
1091 res.append(" ".join(lineparts))
1091 res.append(" ".join(lineparts))
1092
1092
1093 return res
1093 return res
1094
1094
1095
1095
1096
1096
1097
1097
1098
1098
1099 def print_slist(arg):
1099 def print_slist(arg):
1100 """ Prettier (non-repr-like) and more informative printer for SList """
1100 """ Prettier (non-repr-like) and more informative printer for SList """
1101 print "SList (.p, .n, .l, .s, .grep(), .fields() available). Value:"
1101 print "SList (.p, .n, .l, .s, .grep(), .fields() available). Value:"
1102 nlprint(arg)
1102 nlprint(arg)
1103
1103
1104 print_slist = result_display.when_type(SList)(print_slist)
1104 print_slist = result_display.when_type(SList)(print_slist)
1105
1105
1106
1106
1107
1107
1108 #----------------------------------------------------------------------------
1108 #----------------------------------------------------------------------------
1109 def esc_quotes(strng):
1109 def esc_quotes(strng):
1110 """Return the input string with single and double quotes escaped out"""
1110 """Return the input string with single and double quotes escaped out"""
1111
1111
1112 return strng.replace('"','\\"').replace("'","\\'")
1112 return strng.replace('"','\\"').replace("'","\\'")
1113
1113
1114 #----------------------------------------------------------------------------
1114 #----------------------------------------------------------------------------
1115 def make_quoted_expr(s):
1115 def make_quoted_expr(s):
1116 """Return string s in appropriate quotes, using raw string if possible.
1116 """Return string s in appropriate quotes, using raw string if possible.
1117
1117
1118 Effectively this turns string: cd \ao\ao\
1118 Effectively this turns string: cd \ao\ao\
1119 to: r"cd \ao\ao\_"[:-1]
1119 to: r"cd \ao\ao\_"[:-1]
1120
1120
1121 Note the use of raw string and padding at the end to allow trailing backslash.
1121 Note the use of raw string and padding at the end to allow trailing backslash.
1122
1122
1123 """
1123 """
1124
1124
1125 tail = ''
1125 tail = ''
1126 tailpadding = ''
1126 tailpadding = ''
1127 raw = ''
1127 raw = ''
1128 if "\\" in s:
1128 if "\\" in s:
1129 raw = 'r'
1129 raw = 'r'
1130 if s.endswith('\\'):
1130 if s.endswith('\\'):
1131 tail = '[:-1]'
1131 tail = '[:-1]'
1132 tailpadding = '_'
1132 tailpadding = '_'
1133 if '"' not in s:
1133 if '"' not in s:
1134 quote = '"'
1134 quote = '"'
1135 elif "'" not in s:
1135 elif "'" not in s:
1136 quote = "'"
1136 quote = "'"
1137 elif '"""' not in s and not s.endswith('"'):
1137 elif '"""' not in s and not s.endswith('"'):
1138 quote = '"""'
1138 quote = '"""'
1139 elif "'''" not in s and not s.endswith("'"):
1139 elif "'''" not in s and not s.endswith("'"):
1140 quote = "'''"
1140 quote = "'''"
1141 else:
1141 else:
1142 # give up, backslash-escaped string will do
1142 # give up, backslash-escaped string will do
1143 return '"%s"' % esc_quotes(s)
1143 return '"%s"' % esc_quotes(s)
1144 res = raw + quote + s + tailpadding + quote + tail
1144 res = raw + quote + s + tailpadding + quote + tail
1145 return res
1145 return res
1146
1146
1147
1147
1148 #----------------------------------------------------------------------------
1148 #----------------------------------------------------------------------------
1149 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
1149 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
1150 """Take multiple lines of input.
1150 """Take multiple lines of input.
1151
1151
1152 A list with each line of input as a separate element is returned when a
1152 A list with each line of input as a separate element is returned when a
1153 termination string is entered (defaults to a single '.'). Input can also
1153 termination string is entered (defaults to a single '.'). Input can also
1154 terminate via EOF (^D in Unix, ^Z-RET in Windows).
1154 terminate via EOF (^D in Unix, ^Z-RET in Windows).
1155
1155
1156 Lines of input which end in \\ are joined into single entries (and a
1156 Lines of input which end in \\ are joined into single entries (and a
1157 secondary continuation prompt is issued as long as the user terminates
1157 secondary continuation prompt is issued as long as the user terminates
1158 lines with \\). This allows entering very long strings which are still
1158 lines with \\). This allows entering very long strings which are still
1159 meant to be treated as single entities.
1159 meant to be treated as single entities.
1160 """
1160 """
1161
1161
1162 try:
1162 try:
1163 if header:
1163 if header:
1164 header += '\n'
1164 header += '\n'
1165 lines = [raw_input(header + ps1)]
1165 lines = [raw_input(header + ps1)]
1166 except EOFError:
1166 except EOFError:
1167 return []
1167 return []
1168 terminate = [terminate_str]
1168 terminate = [terminate_str]
1169 try:
1169 try:
1170 while lines[-1:] != terminate:
1170 while lines[-1:] != terminate:
1171 new_line = raw_input(ps1)
1171 new_line = raw_input(ps1)
1172 while new_line.endswith('\\'):
1172 while new_line.endswith('\\'):
1173 new_line = new_line[:-1] + raw_input(ps2)
1173 new_line = new_line[:-1] + raw_input(ps2)
1174 lines.append(new_line)
1174 lines.append(new_line)
1175
1175
1176 return lines[:-1] # don't return the termination command
1176 return lines[:-1] # don't return the termination command
1177 except EOFError:
1177 except EOFError:
1178 print
1178 print
1179 return lines
1179 return lines
1180
1180
1181 #----------------------------------------------------------------------------
1181 #----------------------------------------------------------------------------
1182 def raw_input_ext(prompt='', ps2='... '):
1182 def raw_input_ext(prompt='', ps2='... '):
1183 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1183 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1184
1184
1185 line = raw_input(prompt)
1185 line = raw_input(prompt)
1186 while line.endswith('\\'):
1186 while line.endswith('\\'):
1187 line = line[:-1] + raw_input(ps2)
1187 line = line[:-1] + raw_input(ps2)
1188 return line
1188 return line
1189
1189
1190 #----------------------------------------------------------------------------
1190 #----------------------------------------------------------------------------
1191 def ask_yes_no(prompt,default=None):
1191 def ask_yes_no(prompt,default=None):
1192 """Asks a question and returns a boolean (y/n) answer.
1192 """Asks a question and returns a boolean (y/n) answer.
1193
1193
1194 If default is given (one of 'y','n'), it is used if the user input is
1194 If default is given (one of 'y','n'), it is used if the user input is
1195 empty. Otherwise the question is repeated until an answer is given.
1195 empty. Otherwise the question is repeated until an answer is given.
1196
1196
1197 An EOF is treated as the default answer. If there is no default, an
1197 An EOF is treated as the default answer. If there is no default, an
1198 exception is raised to prevent infinite loops.
1198 exception is raised to prevent infinite loops.
1199
1199
1200 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1200 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1201
1201
1202 answers = {'y':True,'n':False,'yes':True,'no':False}
1202 answers = {'y':True,'n':False,'yes':True,'no':False}
1203 ans = None
1203 ans = None
1204 while ans not in answers.keys():
1204 while ans not in answers.keys():
1205 try:
1205 try:
1206 ans = raw_input(prompt+' ').lower()
1206 ans = raw_input(prompt+' ').lower()
1207 if not ans: # response was an empty string
1207 if not ans: # response was an empty string
1208 ans = default
1208 ans = default
1209 except KeyboardInterrupt:
1209 except KeyboardInterrupt:
1210 pass
1210 pass
1211 except EOFError:
1211 except EOFError:
1212 if default in answers.keys():
1212 if default in answers.keys():
1213 ans = default
1213 ans = default
1214 print
1214 print
1215 else:
1215 else:
1216 raise
1216 raise
1217
1217
1218 return answers[ans]
1218 return answers[ans]
1219
1219
1220 #----------------------------------------------------------------------------
1220 #----------------------------------------------------------------------------
1221 def marquee(txt='',width=78,mark='*'):
1221 def marquee(txt='',width=78,mark='*'):
1222 """Return the input string centered in a 'marquee'."""
1222 """Return the input string centered in a 'marquee'."""
1223 if not txt:
1223 if not txt:
1224 return (mark*width)[:width]
1224 return (mark*width)[:width]
1225 nmark = (width-len(txt)-2)/len(mark)/2
1225 nmark = (width-len(txt)-2)/len(mark)/2
1226 if nmark < 0: nmark =0
1226 if nmark < 0: nmark =0
1227 marks = mark*nmark
1227 marks = mark*nmark
1228 return '%s %s %s' % (marks,txt,marks)
1228 return '%s %s %s' % (marks,txt,marks)
1229
1229
1230 #----------------------------------------------------------------------------
1230 #----------------------------------------------------------------------------
1231 class EvalDict:
1231 class EvalDict:
1232 """
1232 """
1233 Emulate a dict which evaluates its contents in the caller's frame.
1233 Emulate a dict which evaluates its contents in the caller's frame.
1234
1234
1235 Usage:
1235 Usage:
1236 >>>number = 19
1236 >>>number = 19
1237 >>>text = "python"
1237 >>>text = "python"
1238 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1238 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1239 """
1239 """
1240
1240
1241 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1241 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1242 # modified (shorter) version of:
1242 # modified (shorter) version of:
1243 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1243 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1244 # Skip Montanaro (skip@pobox.com).
1244 # Skip Montanaro (skip@pobox.com).
1245
1245
1246 def __getitem__(self, name):
1246 def __getitem__(self, name):
1247 frame = sys._getframe(1)
1247 frame = sys._getframe(1)
1248 return eval(name, frame.f_globals, frame.f_locals)
1248 return eval(name, frame.f_globals, frame.f_locals)
1249
1249
1250 EvalString = EvalDict # for backwards compatibility
1250 EvalString = EvalDict # for backwards compatibility
1251 #----------------------------------------------------------------------------
1251 #----------------------------------------------------------------------------
1252 def qw(words,flat=0,sep=None,maxsplit=-1):
1252 def qw(words,flat=0,sep=None,maxsplit=-1):
1253 """Similar to Perl's qw() operator, but with some more options.
1253 """Similar to Perl's qw() operator, but with some more options.
1254
1254
1255 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1255 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1256
1256
1257 words can also be a list itself, and with flat=1, the output will be
1257 words can also be a list itself, and with flat=1, the output will be
1258 recursively flattened. Examples:
1258 recursively flattened. Examples:
1259
1259
1260 >>> qw('1 2')
1260 >>> qw('1 2')
1261 ['1', '2']
1261 ['1', '2']
1262 >>> qw(['a b','1 2',['m n','p q']])
1262 >>> qw(['a b','1 2',['m n','p q']])
1263 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1263 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1264 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1264 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1265 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1265 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1266
1266
1267 if type(words) in StringTypes:
1267 if type(words) in StringTypes:
1268 return [word.strip() for word in words.split(sep,maxsplit)
1268 return [word.strip() for word in words.split(sep,maxsplit)
1269 if word and not word.isspace() ]
1269 if word and not word.isspace() ]
1270 if flat:
1270 if flat:
1271 return flatten(map(qw,words,[1]*len(words)))
1271 return flatten(map(qw,words,[1]*len(words)))
1272 return map(qw,words)
1272 return map(qw,words)
1273
1273
1274 #----------------------------------------------------------------------------
1274 #----------------------------------------------------------------------------
1275 def qwflat(words,sep=None,maxsplit=-1):
1275 def qwflat(words,sep=None,maxsplit=-1):
1276 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1276 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1277 return qw(words,1,sep,maxsplit)
1277 return qw(words,1,sep,maxsplit)
1278
1278
1279 #----------------------------------------------------------------------------
1279 #----------------------------------------------------------------------------
1280 def qw_lol(indata):
1280 def qw_lol(indata):
1281 """qw_lol('a b') -> [['a','b']],
1281 """qw_lol('a b') -> [['a','b']],
1282 otherwise it's just a call to qw().
1282 otherwise it's just a call to qw().
1283
1283
1284 We need this to make sure the modules_some keys *always* end up as a
1284 We need this to make sure the modules_some keys *always* end up as a
1285 list of lists."""
1285 list of lists."""
1286
1286
1287 if type(indata) in StringTypes:
1287 if type(indata) in StringTypes:
1288 return [qw(indata)]
1288 return [qw(indata)]
1289 else:
1289 else:
1290 return qw(indata)
1290 return qw(indata)
1291
1291
1292 #-----------------------------------------------------------------------------
1292 #-----------------------------------------------------------------------------
1293 def list_strings(arg):
1293 def list_strings(arg):
1294 """Always return a list of strings, given a string or list of strings
1294 """Always return a list of strings, given a string or list of strings
1295 as input."""
1295 as input."""
1296
1296
1297 if type(arg) in StringTypes: return [arg]
1297 if type(arg) in StringTypes: return [arg]
1298 else: return arg
1298 else: return arg
1299
1299
1300 #----------------------------------------------------------------------------
1300 #----------------------------------------------------------------------------
1301 def grep(pat,list,case=1):
1301 def grep(pat,list,case=1):
1302 """Simple minded grep-like function.
1302 """Simple minded grep-like function.
1303 grep(pat,list) returns occurrences of pat in list, None on failure.
1303 grep(pat,list) returns occurrences of pat in list, None on failure.
1304
1304
1305 It only does simple string matching, with no support for regexps. Use the
1305 It only does simple string matching, with no support for regexps. Use the
1306 option case=0 for case-insensitive matching."""
1306 option case=0 for case-insensitive matching."""
1307
1307
1308 # This is pretty crude. At least it should implement copying only references
1308 # This is pretty crude. At least it should implement copying only references
1309 # to the original data in case it's big. Now it copies the data for output.
1309 # to the original data in case it's big. Now it copies the data for output.
1310 out=[]
1310 out=[]
1311 if case:
1311 if case:
1312 for term in list:
1312 for term in list:
1313 if term.find(pat)>-1: out.append(term)
1313 if term.find(pat)>-1: out.append(term)
1314 else:
1314 else:
1315 lpat=pat.lower()
1315 lpat=pat.lower()
1316 for term in list:
1316 for term in list:
1317 if term.lower().find(lpat)>-1: out.append(term)
1317 if term.lower().find(lpat)>-1: out.append(term)
1318
1318
1319 if len(out): return out
1319 if len(out): return out
1320 else: return None
1320 else: return None
1321
1321
1322 #----------------------------------------------------------------------------
1322 #----------------------------------------------------------------------------
1323 def dgrep(pat,*opts):
1323 def dgrep(pat,*opts):
1324 """Return grep() on dir()+dir(__builtins__).
1324 """Return grep() on dir()+dir(__builtins__).
1325
1325
1326 A very common use of grep() when working interactively."""
1326 A very common use of grep() when working interactively."""
1327
1327
1328 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1328 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1329
1329
1330 #----------------------------------------------------------------------------
1330 #----------------------------------------------------------------------------
1331 def idgrep(pat):
1331 def idgrep(pat):
1332 """Case-insensitive dgrep()"""
1332 """Case-insensitive dgrep()"""
1333
1333
1334 return dgrep(pat,0)
1334 return dgrep(pat,0)
1335
1335
1336 #----------------------------------------------------------------------------
1336 #----------------------------------------------------------------------------
1337 def igrep(pat,list):
1337 def igrep(pat,list):
1338 """Synonym for case-insensitive grep."""
1338 """Synonym for case-insensitive grep."""
1339
1339
1340 return grep(pat,list,case=0)
1340 return grep(pat,list,case=0)
1341
1341
1342 #----------------------------------------------------------------------------
1342 #----------------------------------------------------------------------------
1343 def indent(str,nspaces=4,ntabs=0):
1343 def indent(str,nspaces=4,ntabs=0):
1344 """Indent a string a given number of spaces or tabstops.
1344 """Indent a string a given number of spaces or tabstops.
1345
1345
1346 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1346 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1347 """
1347 """
1348 if str is None:
1348 if str is None:
1349 return
1349 return
1350 ind = '\t'*ntabs+' '*nspaces
1350 ind = '\t'*ntabs+' '*nspaces
1351 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1351 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1352 if outstr.endswith(os.linesep+ind):
1352 if outstr.endswith(os.linesep+ind):
1353 return outstr[:-len(ind)]
1353 return outstr[:-len(ind)]
1354 else:
1354 else:
1355 return outstr
1355 return outstr
1356
1356
1357 #-----------------------------------------------------------------------------
1357 #-----------------------------------------------------------------------------
1358 def native_line_ends(filename,backup=1):
1358 def native_line_ends(filename,backup=1):
1359 """Convert (in-place) a file to line-ends native to the current OS.
1359 """Convert (in-place) a file to line-ends native to the current OS.
1360
1360
1361 If the optional backup argument is given as false, no backup of the
1361 If the optional backup argument is given as false, no backup of the
1362 original file is left. """
1362 original file is left. """
1363
1363
1364 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1364 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1365
1365
1366 bak_filename = filename + backup_suffixes[os.name]
1366 bak_filename = filename + backup_suffixes[os.name]
1367
1367
1368 original = open(filename).read()
1368 original = open(filename).read()
1369 shutil.copy2(filename,bak_filename)
1369 shutil.copy2(filename,bak_filename)
1370 try:
1370 try:
1371 new = open(filename,'wb')
1371 new = open(filename,'wb')
1372 new.write(os.linesep.join(original.splitlines()))
1372 new.write(os.linesep.join(original.splitlines()))
1373 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1373 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1374 new.close()
1374 new.close()
1375 except:
1375 except:
1376 os.rename(bak_filename,filename)
1376 os.rename(bak_filename,filename)
1377 if not backup:
1377 if not backup:
1378 try:
1378 try:
1379 os.remove(bak_filename)
1379 os.remove(bak_filename)
1380 except:
1380 except:
1381 pass
1381 pass
1382
1382
1383 #----------------------------------------------------------------------------
1383 #----------------------------------------------------------------------------
1384 def get_pager_cmd(pager_cmd = None):
1384 def get_pager_cmd(pager_cmd = None):
1385 """Return a pager command.
1385 """Return a pager command.
1386
1386
1387 Makes some attempts at finding an OS-correct one."""
1387 Makes some attempts at finding an OS-correct one."""
1388
1388
1389 if os.name == 'posix':
1389 if os.name == 'posix':
1390 default_pager_cmd = 'less -r' # -r for color control sequences
1390 default_pager_cmd = 'less -r' # -r for color control sequences
1391 elif os.name in ['nt','dos']:
1391 elif os.name in ['nt','dos']:
1392 default_pager_cmd = 'type'
1392 default_pager_cmd = 'type'
1393
1393
1394 if pager_cmd is None:
1394 if pager_cmd is None:
1395 try:
1395 try:
1396 pager_cmd = os.environ['PAGER']
1396 pager_cmd = os.environ['PAGER']
1397 except:
1397 except:
1398 pager_cmd = default_pager_cmd
1398 pager_cmd = default_pager_cmd
1399 return pager_cmd
1399 return pager_cmd
1400
1400
1401 #-----------------------------------------------------------------------------
1401 #-----------------------------------------------------------------------------
1402 def get_pager_start(pager,start):
1402 def get_pager_start(pager,start):
1403 """Return the string for paging files with an offset.
1403 """Return the string for paging files with an offset.
1404
1404
1405 This is the '+N' argument which less and more (under Unix) accept.
1405 This is the '+N' argument which less and more (under Unix) accept.
1406 """
1406 """
1407
1407
1408 if pager in ['less','more']:
1408 if pager in ['less','more']:
1409 if start:
1409 if start:
1410 start_string = '+' + str(start)
1410 start_string = '+' + str(start)
1411 else:
1411 else:
1412 start_string = ''
1412 start_string = ''
1413 else:
1413 else:
1414 start_string = ''
1414 start_string = ''
1415 return start_string
1415 return start_string
1416
1416
1417 #----------------------------------------------------------------------------
1417 #----------------------------------------------------------------------------
1418 # (X)emacs on W32 doesn't like to be bypassed with msvcrt.getch()
1418 # (X)emacs on W32 doesn't like to be bypassed with msvcrt.getch()
1419 if os.name == 'nt' and os.environ.get('TERM','dumb') != 'emacs':
1419 if os.name == 'nt' and os.environ.get('TERM','dumb') != 'emacs':
1420 import msvcrt
1420 import msvcrt
1421 def page_more():
1421 def page_more():
1422 """ Smart pausing between pages
1422 """ Smart pausing between pages
1423
1423
1424 @return: True if need print more lines, False if quit
1424 @return: True if need print more lines, False if quit
1425 """
1425 """
1426 Term.cout.write('---Return to continue, q to quit--- ')
1426 Term.cout.write('---Return to continue, q to quit--- ')
1427 ans = msvcrt.getch()
1427 ans = msvcrt.getch()
1428 if ans in ("q", "Q"):
1428 if ans in ("q", "Q"):
1429 result = False
1429 result = False
1430 else:
1430 else:
1431 result = True
1431 result = True
1432 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1432 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1433 return result
1433 return result
1434 else:
1434 else:
1435 def page_more():
1435 def page_more():
1436 ans = raw_input('---Return to continue, q to quit--- ')
1436 ans = raw_input('---Return to continue, q to quit--- ')
1437 if ans.lower().startswith('q'):
1437 if ans.lower().startswith('q'):
1438 return False
1438 return False
1439 else:
1439 else:
1440 return True
1440 return True
1441
1441
1442 esc_re = re.compile(r"(\x1b[^m]+m)")
1442 esc_re = re.compile(r"(\x1b[^m]+m)")
1443
1443
1444 def page_dumb(strng,start=0,screen_lines=25):
1444 def page_dumb(strng,start=0,screen_lines=25):
1445 """Very dumb 'pager' in Python, for when nothing else works.
1445 """Very dumb 'pager' in Python, for when nothing else works.
1446
1446
1447 Only moves forward, same interface as page(), except for pager_cmd and
1447 Only moves forward, same interface as page(), except for pager_cmd and
1448 mode."""
1448 mode."""
1449
1449
1450 out_ln = strng.splitlines()[start:]
1450 out_ln = strng.splitlines()[start:]
1451 screens = chop(out_ln,screen_lines-1)
1451 screens = chop(out_ln,screen_lines-1)
1452 if len(screens) == 1:
1452 if len(screens) == 1:
1453 print >>Term.cout, os.linesep.join(screens[0])
1453 print >>Term.cout, os.linesep.join(screens[0])
1454 else:
1454 else:
1455 last_escape = ""
1455 last_escape = ""
1456 for scr in screens[0:-1]:
1456 for scr in screens[0:-1]:
1457 hunk = os.linesep.join(scr)
1457 hunk = os.linesep.join(scr)
1458 print >>Term.cout, last_escape + hunk
1458 print >>Term.cout, last_escape + hunk
1459 if not page_more():
1459 if not page_more():
1460 return
1460 return
1461 esc_list = esc_re.findall(hunk)
1461 esc_list = esc_re.findall(hunk)
1462 if len(esc_list) > 0:
1462 if len(esc_list) > 0:
1463 last_escape = esc_list[-1]
1463 last_escape = esc_list[-1]
1464 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1464 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1465
1465
1466 #----------------------------------------------------------------------------
1466 #----------------------------------------------------------------------------
1467 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1467 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1468 """Print a string, piping through a pager after a certain length.
1468 """Print a string, piping through a pager after a certain length.
1469
1469
1470 The screen_lines parameter specifies the number of *usable* lines of your
1470 The screen_lines parameter specifies the number of *usable* lines of your
1471 terminal screen (total lines minus lines you need to reserve to show other
1471 terminal screen (total lines minus lines you need to reserve to show other
1472 information).
1472 information).
1473
1473
1474 If you set screen_lines to a number <=0, page() will try to auto-determine
1474 If you set screen_lines to a number <=0, page() will try to auto-determine
1475 your screen size and will only use up to (screen_size+screen_lines) for
1475 your screen size and will only use up to (screen_size+screen_lines) for
1476 printing, paging after that. That is, if you want auto-detection but need
1476 printing, paging after that. That is, if you want auto-detection but need
1477 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1477 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1478 auto-detection without any lines reserved simply use screen_lines = 0.
1478 auto-detection without any lines reserved simply use screen_lines = 0.
1479
1479
1480 If a string won't fit in the allowed lines, it is sent through the
1480 If a string won't fit in the allowed lines, it is sent through the
1481 specified pager command. If none given, look for PAGER in the environment,
1481 specified pager command. If none given, look for PAGER in the environment,
1482 and ultimately default to less.
1482 and ultimately default to less.
1483
1483
1484 If no system pager works, the string is sent through a 'dumb pager'
1484 If no system pager works, the string is sent through a 'dumb pager'
1485 written in python, very simplistic.
1485 written in python, very simplistic.
1486 """
1486 """
1487
1487
1488 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1488 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1489 TERM = os.environ.get('TERM','dumb')
1489 TERM = os.environ.get('TERM','dumb')
1490 if TERM in ['dumb','emacs'] and os.name != 'nt':
1490 if TERM in ['dumb','emacs'] and os.name != 'nt':
1491 print strng
1491 print strng
1492 return
1492 return
1493 # chop off the topmost part of the string we don't want to see
1493 # chop off the topmost part of the string we don't want to see
1494 str_lines = strng.split(os.linesep)[start:]
1494 str_lines = strng.split(os.linesep)[start:]
1495 str_toprint = os.linesep.join(str_lines)
1495 str_toprint = os.linesep.join(str_lines)
1496 num_newlines = len(str_lines)
1496 num_newlines = len(str_lines)
1497 len_str = len(str_toprint)
1497 len_str = len(str_toprint)
1498
1498
1499 # Dumb heuristics to guesstimate number of on-screen lines the string
1499 # Dumb heuristics to guesstimate number of on-screen lines the string
1500 # takes. Very basic, but good enough for docstrings in reasonable
1500 # takes. Very basic, but good enough for docstrings in reasonable
1501 # terminals. If someone later feels like refining it, it's not hard.
1501 # terminals. If someone later feels like refining it, it's not hard.
1502 numlines = max(num_newlines,int(len_str/80)+1)
1502 numlines = max(num_newlines,int(len_str/80)+1)
1503
1503
1504 if os.name == "nt":
1504 if os.name == "nt":
1505 screen_lines_def = get_console_size(defaulty=25)[1]
1505 screen_lines_def = get_console_size(defaulty=25)[1]
1506 else:
1506 else:
1507 screen_lines_def = 25 # default value if we can't auto-determine
1507 screen_lines_def = 25 # default value if we can't auto-determine
1508
1508
1509 # auto-determine screen size
1509 # auto-determine screen size
1510 if screen_lines <= 0:
1510 if screen_lines <= 0:
1511 if TERM=='xterm':
1511 if TERM=='xterm':
1512 try:
1512 try:
1513 import curses
1513 import curses
1514 if hasattr(curses,'initscr'):
1514 if hasattr(curses,'initscr'):
1515 use_curses = 1
1515 use_curses = 1
1516 else:
1516 else:
1517 use_curses = 0
1517 use_curses = 0
1518 except ImportError:
1518 except ImportError:
1519 use_curses = 0
1519 use_curses = 0
1520 else:
1520 else:
1521 # curses causes problems on many terminals other than xterm.
1521 # curses causes problems on many terminals other than xterm.
1522 use_curses = 0
1522 use_curses = 0
1523 if use_curses:
1523 if use_curses:
1524 scr = curses.initscr()
1524 scr = curses.initscr()
1525 screen_lines_real,screen_cols = scr.getmaxyx()
1525 screen_lines_real,screen_cols = scr.getmaxyx()
1526 curses.endwin()
1526 curses.endwin()
1527 screen_lines += screen_lines_real
1527 screen_lines += screen_lines_real
1528 #print '***Screen size:',screen_lines_real,'lines x',\
1528 #print '***Screen size:',screen_lines_real,'lines x',\
1529 #screen_cols,'columns.' # dbg
1529 #screen_cols,'columns.' # dbg
1530 else:
1530 else:
1531 screen_lines += screen_lines_def
1531 screen_lines += screen_lines_def
1532
1532
1533 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1533 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1534 if numlines <= screen_lines :
1534 if numlines <= screen_lines :
1535 #print '*** normal print' # dbg
1535 #print '*** normal print' # dbg
1536 print >>Term.cout, str_toprint
1536 print >>Term.cout, str_toprint
1537 else:
1537 else:
1538 # Try to open pager and default to internal one if that fails.
1538 # Try to open pager and default to internal one if that fails.
1539 # All failure modes are tagged as 'retval=1', to match the return
1539 # All failure modes are tagged as 'retval=1', to match the return
1540 # value of a failed system command. If any intermediate attempt
1540 # value of a failed system command. If any intermediate attempt
1541 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1541 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1542 pager_cmd = get_pager_cmd(pager_cmd)
1542 pager_cmd = get_pager_cmd(pager_cmd)
1543 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1543 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1544 if os.name == 'nt':
1544 if os.name == 'nt':
1545 if pager_cmd.startswith('type'):
1545 if pager_cmd.startswith('type'):
1546 # The default WinXP 'type' command is failing on complex strings.
1546 # The default WinXP 'type' command is failing on complex strings.
1547 retval = 1
1547 retval = 1
1548 else:
1548 else:
1549 tmpname = tempfile.mktemp('.txt')
1549 tmpname = tempfile.mktemp('.txt')
1550 tmpfile = file(tmpname,'wt')
1550 tmpfile = file(tmpname,'wt')
1551 tmpfile.write(strng)
1551 tmpfile.write(strng)
1552 tmpfile.close()
1552 tmpfile.close()
1553 cmd = "%s < %s" % (pager_cmd,tmpname)
1553 cmd = "%s < %s" % (pager_cmd,tmpname)
1554 if os.system(cmd):
1554 if os.system(cmd):
1555 retval = 1
1555 retval = 1
1556 else:
1556 else:
1557 retval = None
1557 retval = None
1558 os.remove(tmpname)
1558 os.remove(tmpname)
1559 else:
1559 else:
1560 try:
1560 try:
1561 retval = None
1561 retval = None
1562 # if I use popen4, things hang. No idea why.
1562 # if I use popen4, things hang. No idea why.
1563 #pager,shell_out = os.popen4(pager_cmd)
1563 #pager,shell_out = os.popen4(pager_cmd)
1564 pager = os.popen(pager_cmd,'w')
1564 pager = os.popen(pager_cmd,'w')
1565 pager.write(strng)
1565 pager.write(strng)
1566 pager.close()
1566 pager.close()
1567 retval = pager.close() # success returns None
1567 retval = pager.close() # success returns None
1568 except IOError,msg: # broken pipe when user quits
1568 except IOError,msg: # broken pipe when user quits
1569 if msg.args == (32,'Broken pipe'):
1569 if msg.args == (32,'Broken pipe'):
1570 retval = None
1570 retval = None
1571 else:
1571 else:
1572 retval = 1
1572 retval = 1
1573 except OSError:
1573 except OSError:
1574 # Other strange problems, sometimes seen in Win2k/cygwin
1574 # Other strange problems, sometimes seen in Win2k/cygwin
1575 retval = 1
1575 retval = 1
1576 if retval is not None:
1576 if retval is not None:
1577 page_dumb(strng,screen_lines=screen_lines)
1577 page_dumb(strng,screen_lines=screen_lines)
1578
1578
1579 #----------------------------------------------------------------------------
1579 #----------------------------------------------------------------------------
1580 def page_file(fname,start = 0, pager_cmd = None):
1580 def page_file(fname,start = 0, pager_cmd = None):
1581 """Page a file, using an optional pager command and starting line.
1581 """Page a file, using an optional pager command and starting line.
1582 """
1582 """
1583
1583
1584 pager_cmd = get_pager_cmd(pager_cmd)
1584 pager_cmd = get_pager_cmd(pager_cmd)
1585 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1585 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1586
1586
1587 try:
1587 try:
1588 if os.environ['TERM'] in ['emacs','dumb']:
1588 if os.environ['TERM'] in ['emacs','dumb']:
1589 raise EnvironmentError
1589 raise EnvironmentError
1590 xsys(pager_cmd + ' ' + fname)
1590 xsys(pager_cmd + ' ' + fname)
1591 except:
1591 except:
1592 try:
1592 try:
1593 if start > 0:
1593 if start > 0:
1594 start -= 1
1594 start -= 1
1595 page(open(fname).read(),start)
1595 page(open(fname).read(),start)
1596 except:
1596 except:
1597 print 'Unable to show file',`fname`
1597 print 'Unable to show file',`fname`
1598
1598
1599 #----------------------------------------------------------------------------
1599 #----------------------------------------------------------------------------
1600 def snip_print(str,width = 75,print_full = 0,header = ''):
1600 def snip_print(str,width = 75,print_full = 0,header = ''):
1601 """Print a string snipping the midsection to fit in width.
1601 """Print a string snipping the midsection to fit in width.
1602
1602
1603 print_full: mode control:
1603 print_full: mode control:
1604 - 0: only snip long strings
1604 - 0: only snip long strings
1605 - 1: send to page() directly.
1605 - 1: send to page() directly.
1606 - 2: snip long strings and ask for full length viewing with page()
1606 - 2: snip long strings and ask for full length viewing with page()
1607 Return 1 if snipping was necessary, 0 otherwise."""
1607 Return 1 if snipping was necessary, 0 otherwise."""
1608
1608
1609 if print_full == 1:
1609 if print_full == 1:
1610 page(header+str)
1610 page(header+str)
1611 return 0
1611 return 0
1612
1612
1613 print header,
1613 print header,
1614 if len(str) < width:
1614 if len(str) < width:
1615 print str
1615 print str
1616 snip = 0
1616 snip = 0
1617 else:
1617 else:
1618 whalf = int((width -5)/2)
1618 whalf = int((width -5)/2)
1619 print str[:whalf] + ' <...> ' + str[-whalf:]
1619 print str[:whalf] + ' <...> ' + str[-whalf:]
1620 snip = 1
1620 snip = 1
1621 if snip and print_full == 2:
1621 if snip and print_full == 2:
1622 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1622 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1623 page(str)
1623 page(str)
1624 return snip
1624 return snip
1625
1625
1626 #****************************************************************************
1626 #****************************************************************************
1627 # lists, dicts and structures
1627 # lists, dicts and structures
1628
1628
1629 def belong(candidates,checklist):
1629 def belong(candidates,checklist):
1630 """Check whether a list of items appear in a given list of options.
1630 """Check whether a list of items appear in a given list of options.
1631
1631
1632 Returns a list of 1 and 0, one for each candidate given."""
1632 Returns a list of 1 and 0, one for each candidate given."""
1633
1633
1634 return [x in checklist for x in candidates]
1634 return [x in checklist for x in candidates]
1635
1635
1636 #----------------------------------------------------------------------------
1636 #----------------------------------------------------------------------------
1637 def uniq_stable(elems):
1637 def uniq_stable(elems):
1638 """uniq_stable(elems) -> list
1638 """uniq_stable(elems) -> list
1639
1639
1640 Return from an iterable, a list of all the unique elements in the input,
1640 Return from an iterable, a list of all the unique elements in the input,
1641 but maintaining the order in which they first appear.
1641 but maintaining the order in which they first appear.
1642
1642
1643 A naive solution to this problem which just makes a dictionary with the
1643 A naive solution to this problem which just makes a dictionary with the
1644 elements as keys fails to respect the stability condition, since
1644 elements as keys fails to respect the stability condition, since
1645 dictionaries are unsorted by nature.
1645 dictionaries are unsorted by nature.
1646
1646
1647 Note: All elements in the input must be valid dictionary keys for this
1647 Note: All elements in the input must be valid dictionary keys for this
1648 routine to work, as it internally uses a dictionary for efficiency
1648 routine to work, as it internally uses a dictionary for efficiency
1649 reasons."""
1649 reasons."""
1650
1650
1651 unique = []
1651 unique = []
1652 unique_dict = {}
1652 unique_dict = {}
1653 for nn in elems:
1653 for nn in elems:
1654 if nn not in unique_dict:
1654 if nn not in unique_dict:
1655 unique.append(nn)
1655 unique.append(nn)
1656 unique_dict[nn] = None
1656 unique_dict[nn] = None
1657 return unique
1657 return unique
1658
1658
1659 #----------------------------------------------------------------------------
1659 #----------------------------------------------------------------------------
1660 class NLprinter:
1660 class NLprinter:
1661 """Print an arbitrarily nested list, indicating index numbers.
1661 """Print an arbitrarily nested list, indicating index numbers.
1662
1662
1663 An instance of this class called nlprint is available and callable as a
1663 An instance of this class called nlprint is available and callable as a
1664 function.
1664 function.
1665
1665
1666 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1666 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1667 and using 'sep' to separate the index from the value. """
1667 and using 'sep' to separate the index from the value. """
1668
1668
1669 def __init__(self):
1669 def __init__(self):
1670 self.depth = 0
1670 self.depth = 0
1671
1671
1672 def __call__(self,lst,pos='',**kw):
1672 def __call__(self,lst,pos='',**kw):
1673 """Prints the nested list numbering levels."""
1673 """Prints the nested list numbering levels."""
1674 kw.setdefault('indent',' ')
1674 kw.setdefault('indent',' ')
1675 kw.setdefault('sep',': ')
1675 kw.setdefault('sep',': ')
1676 kw.setdefault('start',0)
1676 kw.setdefault('start',0)
1677 kw.setdefault('stop',len(lst))
1677 kw.setdefault('stop',len(lst))
1678 # we need to remove start and stop from kw so they don't propagate
1678 # we need to remove start and stop from kw so they don't propagate
1679 # into a recursive call for a nested list.
1679 # into a recursive call for a nested list.
1680 start = kw['start']; del kw['start']
1680 start = kw['start']; del kw['start']
1681 stop = kw['stop']; del kw['stop']
1681 stop = kw['stop']; del kw['stop']
1682 if self.depth == 0 and 'header' in kw.keys():
1682 if self.depth == 0 and 'header' in kw.keys():
1683 print kw['header']
1683 print kw['header']
1684
1684
1685 for idx in range(start,stop):
1685 for idx in range(start,stop):
1686 elem = lst[idx]
1686 elem = lst[idx]
1687 if type(elem)==type([]):
1687 if type(elem)==type([]):
1688 self.depth += 1
1688 self.depth += 1
1689 self.__call__(elem,itpl('$pos$idx,'),**kw)
1689 self.__call__(elem,itpl('$pos$idx,'),**kw)
1690 self.depth -= 1
1690 self.depth -= 1
1691 else:
1691 else:
1692 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1692 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1693
1693
1694 nlprint = NLprinter()
1694 nlprint = NLprinter()
1695 #----------------------------------------------------------------------------
1695 #----------------------------------------------------------------------------
1696 def all_belong(candidates,checklist):
1696 def all_belong(candidates,checklist):
1697 """Check whether a list of items ALL appear in a given list of options.
1697 """Check whether a list of items ALL appear in a given list of options.
1698
1698
1699 Returns a single 1 or 0 value."""
1699 Returns a single 1 or 0 value."""
1700
1700
1701 return 1-(0 in [x in checklist for x in candidates])
1701 return 1-(0 in [x in checklist for x in candidates])
1702
1702
1703 #----------------------------------------------------------------------------
1703 #----------------------------------------------------------------------------
1704 def sort_compare(lst1,lst2,inplace = 1):
1704 def sort_compare(lst1,lst2,inplace = 1):
1705 """Sort and compare two lists.
1705 """Sort and compare two lists.
1706
1706
1707 By default it does it in place, thus modifying the lists. Use inplace = 0
1707 By default it does it in place, thus modifying the lists. Use inplace = 0
1708 to avoid that (at the cost of temporary copy creation)."""
1708 to avoid that (at the cost of temporary copy creation)."""
1709 if not inplace:
1709 if not inplace:
1710 lst1 = lst1[:]
1710 lst1 = lst1[:]
1711 lst2 = lst2[:]
1711 lst2 = lst2[:]
1712 lst1.sort(); lst2.sort()
1712 lst1.sort(); lst2.sort()
1713 return lst1 == lst2
1713 return lst1 == lst2
1714
1714
1715 #----------------------------------------------------------------------------
1715 #----------------------------------------------------------------------------
1716 def mkdict(**kwargs):
1716 def mkdict(**kwargs):
1717 """Return a dict from a keyword list.
1717 """Return a dict from a keyword list.
1718
1718
1719 It's just syntactic sugar for making ditcionary creation more convenient:
1719 It's just syntactic sugar for making ditcionary creation more convenient:
1720 # the standard way
1720 # the standard way
1721 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1721 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1722 # a cleaner way
1722 # a cleaner way
1723 >>>data = dict(red=1, green=2, blue=3)
1723 >>>data = dict(red=1, green=2, blue=3)
1724
1724
1725 If you need more than this, look at the Struct() class."""
1725 If you need more than this, look at the Struct() class."""
1726
1726
1727 return kwargs
1727 return kwargs
1728
1728
1729 #----------------------------------------------------------------------------
1729 #----------------------------------------------------------------------------
1730 def list2dict(lst):
1730 def list2dict(lst):
1731 """Takes a list of (key,value) pairs and turns it into a dict."""
1731 """Takes a list of (key,value) pairs and turns it into a dict."""
1732
1732
1733 dic = {}
1733 dic = {}
1734 for k,v in lst: dic[k] = v
1734 for k,v in lst: dic[k] = v
1735 return dic
1735 return dic
1736
1736
1737 #----------------------------------------------------------------------------
1737 #----------------------------------------------------------------------------
1738 def list2dict2(lst,default=''):
1738 def list2dict2(lst,default=''):
1739 """Takes a list and turns it into a dict.
1739 """Takes a list and turns it into a dict.
1740 Much slower than list2dict, but more versatile. This version can take
1740 Much slower than list2dict, but more versatile. This version can take
1741 lists with sublists of arbitrary length (including sclars)."""
1741 lists with sublists of arbitrary length (including sclars)."""
1742
1742
1743 dic = {}
1743 dic = {}
1744 for elem in lst:
1744 for elem in lst:
1745 if type(elem) in (types.ListType,types.TupleType):
1745 if type(elem) in (types.ListType,types.TupleType):
1746 size = len(elem)
1746 size = len(elem)
1747 if size == 0:
1747 if size == 0:
1748 pass
1748 pass
1749 elif size == 1:
1749 elif size == 1:
1750 dic[elem] = default
1750 dic[elem] = default
1751 else:
1751 else:
1752 k,v = elem[0], elem[1:]
1752 k,v = elem[0], elem[1:]
1753 if len(v) == 1: v = v[0]
1753 if len(v) == 1: v = v[0]
1754 dic[k] = v
1754 dic[k] = v
1755 else:
1755 else:
1756 dic[elem] = default
1756 dic[elem] = default
1757 return dic
1757 return dic
1758
1758
1759 #----------------------------------------------------------------------------
1759 #----------------------------------------------------------------------------
1760 def flatten(seq):
1760 def flatten(seq):
1761 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1761 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1762
1762
1763 return [x for subseq in seq for x in subseq]
1763 return [x for subseq in seq for x in subseq]
1764
1764
1765 #----------------------------------------------------------------------------
1765 #----------------------------------------------------------------------------
1766 def get_slice(seq,start=0,stop=None,step=1):
1766 def get_slice(seq,start=0,stop=None,step=1):
1767 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1767 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1768 if stop == None:
1768 if stop == None:
1769 stop = len(seq)
1769 stop = len(seq)
1770 item = lambda i: seq[i]
1770 item = lambda i: seq[i]
1771 return map(item,xrange(start,stop,step))
1771 return map(item,xrange(start,stop,step))
1772
1772
1773 #----------------------------------------------------------------------------
1773 #----------------------------------------------------------------------------
1774 def chop(seq,size):
1774 def chop(seq,size):
1775 """Chop a sequence into chunks of the given size."""
1775 """Chop a sequence into chunks of the given size."""
1776 chunk = lambda i: seq[i:i+size]
1776 chunk = lambda i: seq[i:i+size]
1777 return map(chunk,xrange(0,len(seq),size))
1777 return map(chunk,xrange(0,len(seq),size))
1778
1778
1779 #----------------------------------------------------------------------------
1779 #----------------------------------------------------------------------------
1780 # with is a keyword as of python 2.5, so this function is renamed to withobj
1780 # with is a keyword as of python 2.5, so this function is renamed to withobj
1781 # from its old 'with' name.
1781 # from its old 'with' name.
1782 def with_obj(object, **args):
1782 def with_obj(object, **args):
1783 """Set multiple attributes for an object, similar to Pascal's with.
1783 """Set multiple attributes for an object, similar to Pascal's with.
1784
1784
1785 Example:
1785 Example:
1786 with_obj(jim,
1786 with_obj(jim,
1787 born = 1960,
1787 born = 1960,
1788 haircolour = 'Brown',
1788 haircolour = 'Brown',
1789 eyecolour = 'Green')
1789 eyecolour = 'Green')
1790
1790
1791 Credit: Greg Ewing, in
1791 Credit: Greg Ewing, in
1792 http://mail.python.org/pipermail/python-list/2001-May/040703.html.
1792 http://mail.python.org/pipermail/python-list/2001-May/040703.html.
1793
1793
1794 NOTE: up until IPython 0.7.2, this was called simply 'with', but 'with'
1794 NOTE: up until IPython 0.7.2, this was called simply 'with', but 'with'
1795 has become a keyword for Python 2.5, so we had to rename it."""
1795 has become a keyword for Python 2.5, so we had to rename it."""
1796
1796
1797 object.__dict__.update(args)
1797 object.__dict__.update(args)
1798
1798
1799 #----------------------------------------------------------------------------
1799 #----------------------------------------------------------------------------
1800 def setattr_list(obj,alist,nspace = None):
1800 def setattr_list(obj,alist,nspace = None):
1801 """Set a list of attributes for an object taken from a namespace.
1801 """Set a list of attributes for an object taken from a namespace.
1802
1802
1803 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1803 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1804 alist with their values taken from nspace, which must be a dict (something
1804 alist with their values taken from nspace, which must be a dict (something
1805 like locals() will often do) If nspace isn't given, locals() of the
1805 like locals() will often do) If nspace isn't given, locals() of the
1806 *caller* is used, so in most cases you can omit it.
1806 *caller* is used, so in most cases you can omit it.
1807
1807
1808 Note that alist can be given as a string, which will be automatically
1808 Note that alist can be given as a string, which will be automatically
1809 split into a list on whitespace. If given as a list, it must be a list of
1809 split into a list on whitespace. If given as a list, it must be a list of
1810 *strings* (the variable names themselves), not of variables."""
1810 *strings* (the variable names themselves), not of variables."""
1811
1811
1812 # this grabs the local variables from the *previous* call frame -- that is
1812 # this grabs the local variables from the *previous* call frame -- that is
1813 # the locals from the function that called setattr_list().
1813 # the locals from the function that called setattr_list().
1814 # - snipped from weave.inline()
1814 # - snipped from weave.inline()
1815 if nspace is None:
1815 if nspace is None:
1816 call_frame = sys._getframe().f_back
1816 call_frame = sys._getframe().f_back
1817 nspace = call_frame.f_locals
1817 nspace = call_frame.f_locals
1818
1818
1819 if type(alist) in StringTypes:
1819 if type(alist) in StringTypes:
1820 alist = alist.split()
1820 alist = alist.split()
1821 for attr in alist:
1821 for attr in alist:
1822 val = eval(attr,nspace)
1822 val = eval(attr,nspace)
1823 setattr(obj,attr,val)
1823 setattr(obj,attr,val)
1824
1824
1825 #----------------------------------------------------------------------------
1825 #----------------------------------------------------------------------------
1826 def getattr_list(obj,alist,*args):
1826 def getattr_list(obj,alist,*args):
1827 """getattr_list(obj,alist[, default]) -> attribute list.
1827 """getattr_list(obj,alist[, default]) -> attribute list.
1828
1828
1829 Get a list of named attributes for an object. When a default argument is
1829 Get a list of named attributes for an object. When a default argument is
1830 given, it is returned when the attribute doesn't exist; without it, an
1830 given, it is returned when the attribute doesn't exist; without it, an
1831 exception is raised in that case.
1831 exception is raised in that case.
1832
1832
1833 Note that alist can be given as a string, which will be automatically
1833 Note that alist can be given as a string, which will be automatically
1834 split into a list on whitespace. If given as a list, it must be a list of
1834 split into a list on whitespace. If given as a list, it must be a list of
1835 *strings* (the variable names themselves), not of variables."""
1835 *strings* (the variable names themselves), not of variables."""
1836
1836
1837 if type(alist) in StringTypes:
1837 if type(alist) in StringTypes:
1838 alist = alist.split()
1838 alist = alist.split()
1839 if args:
1839 if args:
1840 if len(args)==1:
1840 if len(args)==1:
1841 default = args[0]
1841 default = args[0]
1842 return map(lambda attr: getattr(obj,attr,default),alist)
1842 return map(lambda attr: getattr(obj,attr,default),alist)
1843 else:
1843 else:
1844 raise ValueError,'getattr_list() takes only one optional argument'
1844 raise ValueError,'getattr_list() takes only one optional argument'
1845 else:
1845 else:
1846 return map(lambda attr: getattr(obj,attr),alist)
1846 return map(lambda attr: getattr(obj,attr),alist)
1847
1847
1848 #----------------------------------------------------------------------------
1848 #----------------------------------------------------------------------------
1849 def map_method(method,object_list,*argseq,**kw):
1849 def map_method(method,object_list,*argseq,**kw):
1850 """map_method(method,object_list,*args,**kw) -> list
1850 """map_method(method,object_list,*args,**kw) -> list
1851
1851
1852 Return a list of the results of applying the methods to the items of the
1852 Return a list of the results of applying the methods to the items of the
1853 argument sequence(s). If more than one sequence is given, the method is
1853 argument sequence(s). If more than one sequence is given, the method is
1854 called with an argument list consisting of the corresponding item of each
1854 called with an argument list consisting of the corresponding item of each
1855 sequence. All sequences must be of the same length.
1855 sequence. All sequences must be of the same length.
1856
1856
1857 Keyword arguments are passed verbatim to all objects called.
1857 Keyword arguments are passed verbatim to all objects called.
1858
1858
1859 This is Python code, so it's not nearly as fast as the builtin map()."""
1859 This is Python code, so it's not nearly as fast as the builtin map()."""
1860
1860
1861 out_list = []
1861 out_list = []
1862 idx = 0
1862 idx = 0
1863 for object in object_list:
1863 for object in object_list:
1864 try:
1864 try:
1865 handler = getattr(object, method)
1865 handler = getattr(object, method)
1866 except AttributeError:
1866 except AttributeError:
1867 out_list.append(None)
1867 out_list.append(None)
1868 else:
1868 else:
1869 if argseq:
1869 if argseq:
1870 args = map(lambda lst:lst[idx],argseq)
1870 args = map(lambda lst:lst[idx],argseq)
1871 #print 'ob',object,'hand',handler,'ar',args # dbg
1871 #print 'ob',object,'hand',handler,'ar',args # dbg
1872 out_list.append(handler(args,**kw))
1872 out_list.append(handler(args,**kw))
1873 else:
1873 else:
1874 out_list.append(handler(**kw))
1874 out_list.append(handler(**kw))
1875 idx += 1
1875 idx += 1
1876 return out_list
1876 return out_list
1877
1877
1878 #----------------------------------------------------------------------------
1878 #----------------------------------------------------------------------------
1879 def get_class_members(cls):
1879 def get_class_members(cls):
1880 ret = dir(cls)
1880 ret = dir(cls)
1881 if hasattr(cls,'__bases__'):
1881 if hasattr(cls,'__bases__'):
1882 for base in cls.__bases__:
1882 for base in cls.__bases__:
1883 ret.extend(get_class_members(base))
1883 ret.extend(get_class_members(base))
1884 return ret
1884 return ret
1885
1885
1886 #----------------------------------------------------------------------------
1886 #----------------------------------------------------------------------------
1887 def dir2(obj):
1887 def dir2(obj):
1888 """dir2(obj) -> list of strings
1888 """dir2(obj) -> list of strings
1889
1889
1890 Extended version of the Python builtin dir(), which does a few extra
1890 Extended version of the Python builtin dir(), which does a few extra
1891 checks, and supports common objects with unusual internals that confuse
1891 checks, and supports common objects with unusual internals that confuse
1892 dir(), such as Traits and PyCrust.
1892 dir(), such as Traits and PyCrust.
1893
1893
1894 This version is guaranteed to return only a list of true strings, whereas
1894 This version is guaranteed to return only a list of true strings, whereas
1895 dir() returns anything that objects inject into themselves, even if they
1895 dir() returns anything that objects inject into themselves, even if they
1896 are later not really valid for attribute access (many extension libraries
1896 are later not really valid for attribute access (many extension libraries
1897 have such bugs).
1897 have such bugs).
1898 """
1898 """
1899
1899
1900 # Start building the attribute list via dir(), and then complete it
1900 # Start building the attribute list via dir(), and then complete it
1901 # with a few extra special-purpose calls.
1901 # with a few extra special-purpose calls.
1902 words = dir(obj)
1902 words = dir(obj)
1903
1903
1904 if hasattr(obj,'__class__'):
1904 if hasattr(obj,'__class__'):
1905 words.append('__class__')
1905 words.append('__class__')
1906 words.extend(get_class_members(obj.__class__))
1906 words.extend(get_class_members(obj.__class__))
1907 #if '__base__' in words: 1/0
1907 #if '__base__' in words: 1/0
1908
1908
1909 # Some libraries (such as traits) may introduce duplicates, we want to
1909 # Some libraries (such as traits) may introduce duplicates, we want to
1910 # track and clean this up if it happens
1910 # track and clean this up if it happens
1911 may_have_dupes = False
1911 may_have_dupes = False
1912
1912
1913 # this is the 'dir' function for objects with Enthought's traits
1913 # this is the 'dir' function for objects with Enthought's traits
1914 if hasattr(obj, 'trait_names'):
1914 if hasattr(obj, 'trait_names'):
1915 try:
1915 try:
1916 words.extend(obj.trait_names())
1916 words.extend(obj.trait_names())
1917 may_have_dupes = True
1917 may_have_dupes = True
1918 except TypeError:
1918 except TypeError:
1919 # This will happen if `obj` is a class and not an instance.
1919 # This will happen if `obj` is a class and not an instance.
1920 pass
1920 pass
1921
1921
1922 # Support for PyCrust-style _getAttributeNames magic method.
1922 # Support for PyCrust-style _getAttributeNames magic method.
1923 if hasattr(obj, '_getAttributeNames'):
1923 if hasattr(obj, '_getAttributeNames'):
1924 try:
1924 try:
1925 words.extend(obj._getAttributeNames())
1925 words.extend(obj._getAttributeNames())
1926 may_have_dupes = True
1926 may_have_dupes = True
1927 except TypeError:
1927 except TypeError:
1928 # `obj` is a class and not an instance. Ignore
1928 # `obj` is a class and not an instance. Ignore
1929 # this error.
1929 # this error.
1930 pass
1930 pass
1931
1931
1932 if may_have_dupes:
1932 if may_have_dupes:
1933 # eliminate possible duplicates, as some traits may also
1933 # eliminate possible duplicates, as some traits may also
1934 # appear as normal attributes in the dir() call.
1934 # appear as normal attributes in the dir() call.
1935 words = list(set(words))
1935 words = list(set(words))
1936 words.sort()
1936 words.sort()
1937
1937
1938 # filter out non-string attributes which may be stuffed by dir() calls
1938 # filter out non-string attributes which may be stuffed by dir() calls
1939 # and poor coding in third-party modules
1939 # and poor coding in third-party modules
1940 return [w for w in words if isinstance(w, basestring)]
1940 return [w for w in words if isinstance(w, basestring)]
1941
1941
1942 #----------------------------------------------------------------------------
1942 #----------------------------------------------------------------------------
1943 def import_fail_info(mod_name,fns=None):
1943 def import_fail_info(mod_name,fns=None):
1944 """Inform load failure for a module."""
1944 """Inform load failure for a module."""
1945
1945
1946 if fns == None:
1946 if fns == None:
1947 warn("Loading of %s failed.\n" % (mod_name,))
1947 warn("Loading of %s failed.\n" % (mod_name,))
1948 else:
1948 else:
1949 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1949 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1950
1950
1951 #----------------------------------------------------------------------------
1951 #----------------------------------------------------------------------------
1952 # Proposed popitem() extension, written as a method
1952 # Proposed popitem() extension, written as a method
1953
1953
1954
1954
1955 class NotGiven: pass
1955 class NotGiven: pass
1956
1956
1957 def popkey(dct,key,default=NotGiven):
1957 def popkey(dct,key,default=NotGiven):
1958 """Return dct[key] and delete dct[key].
1958 """Return dct[key] and delete dct[key].
1959
1959
1960 If default is given, return it if dct[key] doesn't exist, otherwise raise
1960 If default is given, return it if dct[key] doesn't exist, otherwise raise
1961 KeyError. """
1961 KeyError. """
1962
1962
1963 try:
1963 try:
1964 val = dct[key]
1964 val = dct[key]
1965 except KeyError:
1965 except KeyError:
1966 if default is NotGiven:
1966 if default is NotGiven:
1967 raise
1967 raise
1968 else:
1968 else:
1969 return default
1969 return default
1970 else:
1970 else:
1971 del dct[key]
1971 del dct[key]
1972 return val
1972 return val
1973
1973
1974 def wrap_deprecated(func, suggest = '<nothing>'):
1974 def wrap_deprecated(func, suggest = '<nothing>'):
1975 def newFunc(*args, **kwargs):
1975 def newFunc(*args, **kwargs):
1976 warnings.warn("Call to deprecated function %s, use %s instead" %
1976 warnings.warn("Call to deprecated function %s, use %s instead" %
1977 ( func.__name__, suggest),
1977 ( func.__name__, suggest),
1978 category=DeprecationWarning,
1978 category=DeprecationWarning,
1979 stacklevel = 2)
1979 stacklevel = 2)
1980 return func(*args, **kwargs)
1980 return func(*args, **kwargs)
1981 return newFunc
1981 return newFunc
1982
1982
1983 #*************************** end of file <genutils.py> **********************
1983 #*************************** end of file <genutils.py> **********************
1984
1984
@@ -1,763 +1,763 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or better.
5 Requires Python 2.1 or better.
6
6
7 This file contains the main make_IPython() starter function.
7 This file contains the main make_IPython() starter function.
8
8
9 $Id: ipmaker.py 2723 2007-09-07 07:44:16Z fperez $"""
9 $Id: ipmaker.py 2872 2007-11-25 17:58:05Z fperez $"""
10
10
11 #*****************************************************************************
11 #*****************************************************************************
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
13 #
13 #
14 # Distributed under the terms of the BSD License. The full license is in
14 # Distributed under the terms of the BSD License. The full license is in
15 # the file COPYING, distributed as part of this software.
15 # the file COPYING, distributed as part of this software.
16 #*****************************************************************************
16 #*****************************************************************************
17
17
18 from IPython import Release
18 from IPython import Release
19 __author__ = '%s <%s>' % Release.authors['Fernando']
19 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __license__ = Release.license
20 __license__ = Release.license
21 __version__ = Release.version
21 __version__ = Release.version
22
22
23 try:
23 try:
24 credits._Printer__data = """
24 credits._Printer__data = """
25 Python: %s
25 Python: %s
26
26
27 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
27 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
28 See http://ipython.scipy.org for more information.""" \
28 See http://ipython.scipy.org for more information.""" \
29 % credits._Printer__data
29 % credits._Printer__data
30
30
31 copyright._Printer__data += """
31 copyright._Printer__data += """
32
32
33 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
33 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
34 All Rights Reserved."""
34 All Rights Reserved."""
35 except NameError:
35 except NameError:
36 # Can happen if ipython was started with 'python -S', so that site.py is
36 # Can happen if ipython was started with 'python -S', so that site.py is
37 # not loaded
37 # not loaded
38 pass
38 pass
39
39
40 #****************************************************************************
40 #****************************************************************************
41 # Required modules
41 # Required modules
42
42
43 # From the standard library
43 # From the standard library
44 import __main__
44 import __main__
45 import __builtin__
45 import __builtin__
46 import os
46 import os
47 import re
47 import re
48 import sys
48 import sys
49 import types
49 import types
50 from pprint import pprint,pformat
50 from pprint import pprint,pformat
51
51
52 # Our own
52 # Our own
53 from IPython import DPyGetOpt
53 from IPython import DPyGetOpt
54 from IPython.ipstruct import Struct
54 from IPython.ipstruct import Struct
55 from IPython.OutputTrap import OutputTrap
55 from IPython.OutputTrap import OutputTrap
56 from IPython.ConfigLoader import ConfigLoader
56 from IPython.ConfigLoader import ConfigLoader
57 from IPython.iplib import InteractiveShell
57 from IPython.iplib import InteractiveShell
58 from IPython.usage import cmd_line_usage,interactive_usage
58 from IPython.usage import cmd_line_usage,interactive_usage
59 from IPython.genutils import *
59 from IPython.genutils import *
60
60
61 #-----------------------------------------------------------------------------
61 #-----------------------------------------------------------------------------
62 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
62 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
63 rc_override=None,shell_class=InteractiveShell,
63 rc_override=None,shell_class=InteractiveShell,
64 embedded=False,**kw):
64 embedded=False,**kw):
65 """This is a dump of IPython into a single function.
65 """This is a dump of IPython into a single function.
66
66
67 Later it will have to be broken up in a sensible manner.
67 Later it will have to be broken up in a sensible manner.
68
68
69 Arguments:
69 Arguments:
70
70
71 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
71 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
72 script name, b/c DPyGetOpt strips the first argument only for the real
72 script name, b/c DPyGetOpt strips the first argument only for the real
73 sys.argv.
73 sys.argv.
74
74
75 - user_ns: a dict to be used as the user's namespace."""
75 - user_ns: a dict to be used as the user's namespace."""
76
76
77 #----------------------------------------------------------------------
77 #----------------------------------------------------------------------
78 # Defaults and initialization
78 # Defaults and initialization
79
79
80 # For developer debugging, deactivates crash handler and uses pdb.
80 # For developer debugging, deactivates crash handler and uses pdb.
81 DEVDEBUG = False
81 DEVDEBUG = False
82
82
83 if argv is None:
83 if argv is None:
84 argv = sys.argv
84 argv = sys.argv
85
85
86 # __IP is the main global that lives throughout and represents the whole
86 # __IP is the main global that lives throughout and represents the whole
87 # application. If the user redefines it, all bets are off as to what
87 # application. If the user redefines it, all bets are off as to what
88 # happens.
88 # happens.
89
89
90 # __IP is the name of he global which the caller will have accessible as
90 # __IP is the name of he global which the caller will have accessible as
91 # __IP.name. We set its name via the first parameter passed to
91 # __IP.name. We set its name via the first parameter passed to
92 # InteractiveShell:
92 # InteractiveShell:
93
93
94 IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns,
94 IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns,
95 embedded=embedded,**kw)
95 embedded=embedded,**kw)
96
96
97 # Put 'help' in the user namespace
97 # Put 'help' in the user namespace
98 from site import _Helper
98 from site import _Helper
99 IP.user_config_ns = {}
99 IP.user_config_ns = {}
100 IP.user_ns['help'] = _Helper()
100 IP.user_ns['help'] = _Helper()
101
101
102
102
103 if DEVDEBUG:
103 if DEVDEBUG:
104 # For developer debugging only (global flag)
104 # For developer debugging only (global flag)
105 from IPython import ultraTB
105 from IPython import ultraTB
106 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
106 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
107
107
108 IP.BANNER_PARTS = ['Python %s\n'
108 IP.BANNER_PARTS = ['Python %s\n'
109 'Type "copyright", "credits" or "license" '
109 'Type "copyright", "credits" or "license" '
110 'for more information.\n'
110 'for more information.\n'
111 % (sys.version.split('\n')[0],),
111 % (sys.version.split('\n')[0],),
112 "IPython %s -- An enhanced Interactive Python."
112 "IPython %s -- An enhanced Interactive Python."
113 % (__version__,),
113 % (__version__,),
114 """\
114 """\
115 ? -> Introduction and overview of IPython's features.
115 ? -> Introduction and overview of IPython's features.
116 %quickref -> Quick reference.
116 %quickref -> Quick reference.
117 help -> Python's own help system.
117 help -> Python's own help system.
118 object? -> Details about 'object'. ?object also works, ?? prints more.
118 object? -> Details about 'object'. ?object also works, ?? prints more.
119 """ ]
119 """ ]
120
120
121 IP.usage = interactive_usage
121 IP.usage = interactive_usage
122
122
123 # Platform-dependent suffix and directory names. We use _ipython instead
123 # Platform-dependent suffix and directory names. We use _ipython instead
124 # of .ipython under win32 b/c there's software that breaks with .named
124 # of .ipython under win32 b/c there's software that breaks with .named
125 # directories on that platform.
125 # directories on that platform.
126 if os.name == 'posix':
126 if os.name == 'posix':
127 rc_suffix = ''
127 rc_suffix = ''
128 ipdir_def = '.ipython'
128 ipdir_def = '.ipython'
129 else:
129 else:
130 rc_suffix = '.ini'
130 rc_suffix = '.ini'
131 ipdir_def = '_ipython'
131 ipdir_def = '_ipython'
132
132
133 # default directory for configuration
133 # default directory for configuration
134 ipythondir_def = os.path.abspath(os.environ.get('IPYTHONDIR',
134 ipythondir_def = os.path.abspath(os.environ.get('IPYTHONDIR',
135 os.path.join(IP.home_dir,ipdir_def)))
135 os.path.join(IP.home_dir,ipdir_def)))
136
136
137 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
137 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
138
138
139 # we need the directory where IPython itself is installed
139 # we need the directory where IPython itself is installed
140 import IPython
140 import IPython
141 IPython_dir = os.path.dirname(IPython.__file__)
141 IPython_dir = os.path.dirname(IPython.__file__)
142 del IPython
142 del IPython
143
143
144 #-------------------------------------------------------------------------
144 #-------------------------------------------------------------------------
145 # Command line handling
145 # Command line handling
146
146
147 # Valid command line options (uses DPyGetOpt syntax, like Perl's
147 # Valid command line options (uses DPyGetOpt syntax, like Perl's
148 # GetOpt::Long)
148 # GetOpt::Long)
149
149
150 # Any key not listed here gets deleted even if in the file (like session
150 # Any key not listed here gets deleted even if in the file (like session
151 # or profile). That's deliberate, to maintain the rc namespace clean.
151 # or profile). That's deliberate, to maintain the rc namespace clean.
152
152
153 # Each set of options appears twice: under _conv only the names are
153 # Each set of options appears twice: under _conv only the names are
154 # listed, indicating which type they must be converted to when reading the
154 # listed, indicating which type they must be converted to when reading the
155 # ipythonrc file. And under DPyGetOpt they are listed with the regular
155 # ipythonrc file. And under DPyGetOpt they are listed with the regular
156 # DPyGetOpt syntax (=s,=i,:f,etc).
156 # DPyGetOpt syntax (=s,=i,:f,etc).
157
157
158 # Make sure there's a space before each end of line (they get auto-joined!)
158 # Make sure there's a space before each end of line (they get auto-joined!)
159 cmdline_opts = ('autocall=i autoindent! automagic! banner! cache_size|cs=i '
159 cmdline_opts = ('autocall=i autoindent! automagic! banner! cache_size|cs=i '
160 'c=s classic|cl color_info! colors=s confirm_exit! '
160 'c=s classic|cl color_info! colors=s confirm_exit! '
161 'debug! deep_reload! editor=s log|l messages! nosep '
161 'debug! deep_reload! editor=s log|l messages! nosep '
162 'object_info_string_level=i pdb! '
162 'object_info_string_level=i pdb! '
163 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
163 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
164 'pylab_import_all! '
164 'pylab_import_all! '
165 'quick screen_length|sl=i prompts_pad_left=i '
165 'quick screen_length|sl=i prompts_pad_left=i '
166 'logfile|lf=s logplay|lp=s profile|p=s '
166 'logfile|lf=s logplay|lp=s profile|p=s '
167 'readline! readline_merge_completions! '
167 'readline! readline_merge_completions! '
168 'readline_omit__names! '
168 'readline_omit__names! '
169 'rcfile=s separate_in|si=s separate_out|so=s '
169 'rcfile=s separate_in|si=s separate_out|so=s '
170 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
170 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
171 'magic_docstrings system_verbose! '
171 'magic_docstrings system_verbose! '
172 'multi_line_specials! '
172 'multi_line_specials! '
173 'term_title! wxversion=s '
173 'term_title! wxversion=s '
174 'autoedit_syntax!')
174 'autoedit_syntax!')
175
175
176 # Options that can *only* appear at the cmd line (not in rcfiles).
176 # Options that can *only* appear at the cmd line (not in rcfiles).
177
177
178 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
178 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
179 # the 'C-c !' command in emacs automatically appends a -i option at the end.
179 # the 'C-c !' command in emacs automatically appends a -i option at the end.
180 cmdline_only = ('help interact|i ipythondir=s Version upgrade '
180 cmdline_only = ('help interact|i ipythondir=s Version upgrade '
181 'gthread! qthread! q4thread! wthread! pylab! tk!')
181 'gthread! qthread! q4thread! wthread! pylab! tk!')
182
182
183 # Build the actual name list to be used by DPyGetOpt
183 # Build the actual name list to be used by DPyGetOpt
184 opts_names = qw(cmdline_opts) + qw(cmdline_only)
184 opts_names = qw(cmdline_opts) + qw(cmdline_only)
185
185
186 # Set sensible command line defaults.
186 # Set sensible command line defaults.
187 # This should have everything from cmdline_opts and cmdline_only
187 # This should have everything from cmdline_opts and cmdline_only
188 opts_def = Struct(autocall = 1,
188 opts_def = Struct(autocall = 1,
189 autoedit_syntax = 0,
189 autoedit_syntax = 0,
190 autoindent = 0,
190 autoindent = 0,
191 automagic = 1,
191 automagic = 1,
192 banner = 1,
192 banner = 1,
193 cache_size = 1000,
193 cache_size = 1000,
194 c = '',
194 c = '',
195 classic = 0,
195 classic = 0,
196 colors = 'NoColor',
196 colors = 'NoColor',
197 color_info = 0,
197 color_info = 0,
198 confirm_exit = 1,
198 confirm_exit = 1,
199 debug = 0,
199 debug = 0,
200 deep_reload = 0,
200 deep_reload = 0,
201 editor = '0',
201 editor = '0',
202 help = 0,
202 help = 0,
203 interact = 0,
203 interact = 0,
204 ipythondir = ipythondir_def,
204 ipythondir = ipythondir_def,
205 log = 0,
205 log = 0,
206 logfile = '',
206 logfile = '',
207 logplay = '',
207 logplay = '',
208 multi_line_specials = 1,
208 multi_line_specials = 1,
209 messages = 1,
209 messages = 1,
210 object_info_string_level = 0,
210 object_info_string_level = 0,
211 nosep = 0,
211 nosep = 0,
212 pdb = 0,
212 pdb = 0,
213 pprint = 0,
213 pprint = 0,
214 profile = '',
214 profile = '',
215 prompt_in1 = 'In [\\#]: ',
215 prompt_in1 = 'In [\\#]: ',
216 prompt_in2 = ' .\\D.: ',
216 prompt_in2 = ' .\\D.: ',
217 prompt_out = 'Out[\\#]: ',
217 prompt_out = 'Out[\\#]: ',
218 prompts_pad_left = 1,
218 prompts_pad_left = 1,
219 pylab_import_all = 1,
219 pylab_import_all = 1,
220 quiet = 0,
220 quiet = 0,
221 quick = 0,
221 quick = 0,
222 readline = 1,
222 readline = 1,
223 readline_merge_completions = 1,
223 readline_merge_completions = 1,
224 readline_omit__names = 0,
224 readline_omit__names = 0,
225 rcfile = 'ipythonrc' + rc_suffix,
225 rcfile = 'ipythonrc' + rc_suffix,
226 screen_length = 0,
226 screen_length = 0,
227 separate_in = '\n',
227 separate_in = '\n',
228 separate_out = '\n',
228 separate_out = '\n',
229 separate_out2 = '',
229 separate_out2 = '',
230 system_header = 'IPython system call: ',
230 system_header = 'IPython system call: ',
231 system_verbose = 0,
231 system_verbose = 0,
232 gthread = 0,
232 gthread = 0,
233 qthread = 0,
233 qthread = 0,
234 q4thread = 0,
234 q4thread = 0,
235 wthread = 0,
235 wthread = 0,
236 pylab = 0,
236 pylab = 0,
237 term_title = 1,
237 term_title = 1,
238 tk = 0,
238 tk = 0,
239 upgrade = 0,
239 upgrade = 0,
240 Version = 0,
240 Version = 0,
241 xmode = 'Verbose',
241 xmode = 'Verbose',
242 wildcards_case_sensitive = 1,
242 wildcards_case_sensitive = 1,
243 wxversion = '0',
243 wxversion = '0',
244 magic_docstrings = 0, # undocumented, for doc generation
244 magic_docstrings = 0, # undocumented, for doc generation
245 )
245 )
246
246
247 # Things that will *only* appear in rcfiles (not at the command line).
247 # Things that will *only* appear in rcfiles (not at the command line).
248 # Make sure there's a space before each end of line (they get auto-joined!)
248 # Make sure there's a space before each end of line (they get auto-joined!)
249 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
249 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
250 qw_lol: 'import_some ',
250 qw_lol: 'import_some ',
251 # for things with embedded whitespace:
251 # for things with embedded whitespace:
252 list_strings:'execute alias readline_parse_and_bind ',
252 list_strings:'execute alias readline_parse_and_bind ',
253 # Regular strings need no conversion:
253 # Regular strings need no conversion:
254 None:'readline_remove_delims ',
254 None:'readline_remove_delims ',
255 }
255 }
256 # Default values for these
256 # Default values for these
257 rc_def = Struct(include = [],
257 rc_def = Struct(include = [],
258 import_mod = [],
258 import_mod = [],
259 import_all = [],
259 import_all = [],
260 import_some = [[]],
260 import_some = [[]],
261 execute = [],
261 execute = [],
262 execfile = [],
262 execfile = [],
263 alias = [],
263 alias = [],
264 readline_parse_and_bind = [],
264 readline_parse_and_bind = [],
265 readline_remove_delims = '',
265 readline_remove_delims = '',
266 )
266 )
267
267
268 # Build the type conversion dictionary from the above tables:
268 # Build the type conversion dictionary from the above tables:
269 typeconv = rcfile_opts.copy()
269 typeconv = rcfile_opts.copy()
270 typeconv.update(optstr2types(cmdline_opts))
270 typeconv.update(optstr2types(cmdline_opts))
271
271
272 # FIXME: the None key appears in both, put that back together by hand. Ugly!
272 # FIXME: the None key appears in both, put that back together by hand. Ugly!
273 typeconv[None] += ' ' + rcfile_opts[None]
273 typeconv[None] += ' ' + rcfile_opts[None]
274
274
275 # Remove quotes at ends of all strings (used to protect spaces)
275 # Remove quotes at ends of all strings (used to protect spaces)
276 typeconv[unquote_ends] = typeconv[None]
276 typeconv[unquote_ends] = typeconv[None]
277 del typeconv[None]
277 del typeconv[None]
278
278
279 # Build the list we'll use to make all config decisions with defaults:
279 # Build the list we'll use to make all config decisions with defaults:
280 opts_all = opts_def.copy()
280 opts_all = opts_def.copy()
281 opts_all.update(rc_def)
281 opts_all.update(rc_def)
282
282
283 # Build conflict resolver for recursive loading of config files:
283 # Build conflict resolver for recursive loading of config files:
284 # - preserve means the outermost file maintains the value, it is not
284 # - preserve means the outermost file maintains the value, it is not
285 # overwritten if an included file has the same key.
285 # overwritten if an included file has the same key.
286 # - add_flip applies + to the two values, so it better make sense to add
286 # - add_flip applies + to the two values, so it better make sense to add
287 # those types of keys. But it flips them first so that things loaded
287 # those types of keys. But it flips them first so that things loaded
288 # deeper in the inclusion chain have lower precedence.
288 # deeper in the inclusion chain have lower precedence.
289 conflict = {'preserve': ' '.join([ typeconv[int],
289 conflict = {'preserve': ' '.join([ typeconv[int],
290 typeconv[unquote_ends] ]),
290 typeconv[unquote_ends] ]),
291 'add_flip': ' '.join([ typeconv[qwflat],
291 'add_flip': ' '.join([ typeconv[qwflat],
292 typeconv[qw_lol],
292 typeconv[qw_lol],
293 typeconv[list_strings] ])
293 typeconv[list_strings] ])
294 }
294 }
295
295
296 # Now actually process the command line
296 # Now actually process the command line
297 getopt = DPyGetOpt.DPyGetOpt()
297 getopt = DPyGetOpt.DPyGetOpt()
298 getopt.setIgnoreCase(0)
298 getopt.setIgnoreCase(0)
299
299
300 getopt.parseConfiguration(opts_names)
300 getopt.parseConfiguration(opts_names)
301
301
302 try:
302 try:
303 getopt.processArguments(argv)
303 getopt.processArguments(argv)
304 except:
304 except DPyGetOpt.ArgumentError, exc:
305 print cmd_line_usage
305 print cmd_line_usage
306 warn('\nError in Arguments: ' + `sys.exc_value`)
306 warn('\nError in Arguments: "%s"' % exc)
307 sys.exit(1)
307 sys.exit(1)
308
308
309 # convert the options dict to a struct for much lighter syntax later
309 # convert the options dict to a struct for much lighter syntax later
310 opts = Struct(getopt.optionValues)
310 opts = Struct(getopt.optionValues)
311 args = getopt.freeValues
311 args = getopt.freeValues
312
312
313 # this is the struct (which has default values at this point) with which
313 # this is the struct (which has default values at this point) with which
314 # we make all decisions:
314 # we make all decisions:
315 opts_all.update(opts)
315 opts_all.update(opts)
316
316
317 # Options that force an immediate exit
317 # Options that force an immediate exit
318 if opts_all.help:
318 if opts_all.help:
319 page(cmd_line_usage)
319 page(cmd_line_usage)
320 sys.exit()
320 sys.exit()
321
321
322 if opts_all.Version:
322 if opts_all.Version:
323 print __version__
323 print __version__
324 sys.exit()
324 sys.exit()
325
325
326 if opts_all.magic_docstrings:
326 if opts_all.magic_docstrings:
327 IP.magic_magic('-latex')
327 IP.magic_magic('-latex')
328 sys.exit()
328 sys.exit()
329
329
330 # add personal ipythondir to sys.path so that users can put things in
330 # add personal ipythondir to sys.path so that users can put things in
331 # there for customization
331 # there for customization
332 sys.path.append(os.path.abspath(opts_all.ipythondir))
332 sys.path.append(os.path.abspath(opts_all.ipythondir))
333
333
334 # Create user config directory if it doesn't exist. This must be done
334 # Create user config directory if it doesn't exist. This must be done
335 # *after* getting the cmd line options.
335 # *after* getting the cmd line options.
336 if not os.path.isdir(opts_all.ipythondir):
336 if not os.path.isdir(opts_all.ipythondir):
337 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
337 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
338
338
339 # upgrade user config files while preserving a copy of the originals
339 # upgrade user config files while preserving a copy of the originals
340 if opts_all.upgrade:
340 if opts_all.upgrade:
341 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
341 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
342
342
343 # check mutually exclusive options in the *original* command line
343 # check mutually exclusive options in the *original* command line
344 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
344 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
345 qw('classic profile'),qw('classic rcfile')])
345 qw('classic profile'),qw('classic rcfile')])
346
346
347 #---------------------------------------------------------------------------
347 #---------------------------------------------------------------------------
348 # Log replay
348 # Log replay
349
349
350 # if -logplay, we need to 'become' the other session. That basically means
350 # if -logplay, we need to 'become' the other session. That basically means
351 # replacing the current command line environment with that of the old
351 # replacing the current command line environment with that of the old
352 # session and moving on.
352 # session and moving on.
353
353
354 # this is needed so that later we know we're in session reload mode, as
354 # this is needed so that later we know we're in session reload mode, as
355 # opts_all will get overwritten:
355 # opts_all will get overwritten:
356 load_logplay = 0
356 load_logplay = 0
357
357
358 if opts_all.logplay:
358 if opts_all.logplay:
359 load_logplay = opts_all.logplay
359 load_logplay = opts_all.logplay
360 opts_debug_save = opts_all.debug
360 opts_debug_save = opts_all.debug
361 try:
361 try:
362 logplay = open(opts_all.logplay)
362 logplay = open(opts_all.logplay)
363 except IOError:
363 except IOError:
364 if opts_all.debug: IP.InteractiveTB()
364 if opts_all.debug: IP.InteractiveTB()
365 warn('Could not open logplay file '+`opts_all.logplay`)
365 warn('Could not open logplay file '+`opts_all.logplay`)
366 # restore state as if nothing had happened and move on, but make
366 # restore state as if nothing had happened and move on, but make
367 # sure that later we don't try to actually load the session file
367 # sure that later we don't try to actually load the session file
368 logplay = None
368 logplay = None
369 load_logplay = 0
369 load_logplay = 0
370 del opts_all.logplay
370 del opts_all.logplay
371 else:
371 else:
372 try:
372 try:
373 logplay.readline()
373 logplay.readline()
374 logplay.readline();
374 logplay.readline();
375 # this reloads that session's command line
375 # this reloads that session's command line
376 cmd = logplay.readline()[6:]
376 cmd = logplay.readline()[6:]
377 exec cmd
377 exec cmd
378 # restore the true debug flag given so that the process of
378 # restore the true debug flag given so that the process of
379 # session loading itself can be monitored.
379 # session loading itself can be monitored.
380 opts.debug = opts_debug_save
380 opts.debug = opts_debug_save
381 # save the logplay flag so later we don't overwrite the log
381 # save the logplay flag so later we don't overwrite the log
382 opts.logplay = load_logplay
382 opts.logplay = load_logplay
383 # now we must update our own structure with defaults
383 # now we must update our own structure with defaults
384 opts_all.update(opts)
384 opts_all.update(opts)
385 # now load args
385 # now load args
386 cmd = logplay.readline()[6:]
386 cmd = logplay.readline()[6:]
387 exec cmd
387 exec cmd
388 logplay.close()
388 logplay.close()
389 except:
389 except:
390 logplay.close()
390 logplay.close()
391 if opts_all.debug: IP.InteractiveTB()
391 if opts_all.debug: IP.InteractiveTB()
392 warn("Logplay file lacking full configuration information.\n"
392 warn("Logplay file lacking full configuration information.\n"
393 "I'll try to read it, but some things may not work.")
393 "I'll try to read it, but some things may not work.")
394
394
395 #-------------------------------------------------------------------------
395 #-------------------------------------------------------------------------
396 # set up output traps: catch all output from files, being run, modules
396 # set up output traps: catch all output from files, being run, modules
397 # loaded, etc. Then give it to the user in a clean form at the end.
397 # loaded, etc. Then give it to the user in a clean form at the end.
398
398
399 msg_out = 'Output messages. '
399 msg_out = 'Output messages. '
400 msg_err = 'Error messages. '
400 msg_err = 'Error messages. '
401 msg_sep = '\n'
401 msg_sep = '\n'
402 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
402 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
403 msg_err,msg_sep,debug,
403 msg_err,msg_sep,debug,
404 quiet_out=1),
404 quiet_out=1),
405 user_exec = OutputTrap('User File Execution',msg_out,
405 user_exec = OutputTrap('User File Execution',msg_out,
406 msg_err,msg_sep,debug),
406 msg_err,msg_sep,debug),
407 logplay = OutputTrap('Log Loader',msg_out,
407 logplay = OutputTrap('Log Loader',msg_out,
408 msg_err,msg_sep,debug),
408 msg_err,msg_sep,debug),
409 summary = ''
409 summary = ''
410 )
410 )
411
411
412 #-------------------------------------------------------------------------
412 #-------------------------------------------------------------------------
413 # Process user ipythonrc-type configuration files
413 # Process user ipythonrc-type configuration files
414
414
415 # turn on output trapping and log to msg.config
415 # turn on output trapping and log to msg.config
416 # remember that with debug on, trapping is actually disabled
416 # remember that with debug on, trapping is actually disabled
417 msg.config.trap_all()
417 msg.config.trap_all()
418
418
419 # look for rcfile in current or default directory
419 # look for rcfile in current or default directory
420 try:
420 try:
421 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
421 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
422 except IOError:
422 except IOError:
423 if opts_all.debug: IP.InteractiveTB()
423 if opts_all.debug: IP.InteractiveTB()
424 warn('Configuration file %s not found. Ignoring request.'
424 warn('Configuration file %s not found. Ignoring request.'
425 % (opts_all.rcfile) )
425 % (opts_all.rcfile) )
426
426
427 # 'profiles' are a shorthand notation for config filenames
427 # 'profiles' are a shorthand notation for config filenames
428 profile_handled_by_legacy = False
428 profile_handled_by_legacy = False
429 if opts_all.profile:
429 if opts_all.profile:
430
430
431 try:
431 try:
432 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
432 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
433 + rc_suffix,
433 + rc_suffix,
434 opts_all.ipythondir)
434 opts_all.ipythondir)
435 profile_handled_by_legacy = True
435 profile_handled_by_legacy = True
436 except IOError:
436 except IOError:
437 if opts_all.debug: IP.InteractiveTB()
437 if opts_all.debug: IP.InteractiveTB()
438 opts.profile = '' # remove profile from options if invalid
438 opts.profile = '' # remove profile from options if invalid
439 # We won't warn anymore, primary method is ipy_profile_PROFNAME
439 # We won't warn anymore, primary method is ipy_profile_PROFNAME
440 # which does trigger a warning.
440 # which does trigger a warning.
441
441
442 # load the config file
442 # load the config file
443 rcfiledata = None
443 rcfiledata = None
444 if opts_all.quick:
444 if opts_all.quick:
445 print 'Launching IPython in quick mode. No config file read.'
445 print 'Launching IPython in quick mode. No config file read.'
446 elif opts_all.rcfile:
446 elif opts_all.rcfile:
447 try:
447 try:
448 cfg_loader = ConfigLoader(conflict)
448 cfg_loader = ConfigLoader(conflict)
449 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
449 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
450 'include',opts_all.ipythondir,
450 'include',opts_all.ipythondir,
451 purge = 1,
451 purge = 1,
452 unique = conflict['preserve'])
452 unique = conflict['preserve'])
453 except:
453 except:
454 IP.InteractiveTB()
454 IP.InteractiveTB()
455 warn('Problems loading configuration file '+
455 warn('Problems loading configuration file '+
456 `opts_all.rcfile`+
456 `opts_all.rcfile`+
457 '\nStarting with default -bare bones- configuration.')
457 '\nStarting with default -bare bones- configuration.')
458 else:
458 else:
459 warn('No valid configuration file found in either currrent directory\n'+
459 warn('No valid configuration file found in either currrent directory\n'+
460 'or in the IPython config. directory: '+`opts_all.ipythondir`+
460 'or in the IPython config. directory: '+`opts_all.ipythondir`+
461 '\nProceeding with internal defaults.')
461 '\nProceeding with internal defaults.')
462
462
463 #------------------------------------------------------------------------
463 #------------------------------------------------------------------------
464 # Set exception handlers in mode requested by user.
464 # Set exception handlers in mode requested by user.
465 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
465 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
466 IP.magic_xmode(opts_all.xmode)
466 IP.magic_xmode(opts_all.xmode)
467 otrap.release_out()
467 otrap.release_out()
468
468
469 #------------------------------------------------------------------------
469 #------------------------------------------------------------------------
470 # Execute user config
470 # Execute user config
471
471
472 # Create a valid config structure with the right precedence order:
472 # Create a valid config structure with the right precedence order:
473 # defaults < rcfile < command line. This needs to be in the instance, so
473 # defaults < rcfile < command line. This needs to be in the instance, so
474 # that method calls below that rely on it find it.
474 # that method calls below that rely on it find it.
475 IP.rc = rc_def.copy()
475 IP.rc = rc_def.copy()
476
476
477 # Work with a local alias inside this routine to avoid unnecessary
477 # Work with a local alias inside this routine to avoid unnecessary
478 # attribute lookups.
478 # attribute lookups.
479 IP_rc = IP.rc
479 IP_rc = IP.rc
480
480
481 IP_rc.update(opts_def)
481 IP_rc.update(opts_def)
482 if rcfiledata:
482 if rcfiledata:
483 # now we can update
483 # now we can update
484 IP_rc.update(rcfiledata)
484 IP_rc.update(rcfiledata)
485 IP_rc.update(opts)
485 IP_rc.update(opts)
486 IP_rc.update(rc_override)
486 IP_rc.update(rc_override)
487
487
488 # Store the original cmd line for reference:
488 # Store the original cmd line for reference:
489 IP_rc.opts = opts
489 IP_rc.opts = opts
490 IP_rc.args = args
490 IP_rc.args = args
491
491
492 # create a *runtime* Struct like rc for holding parameters which may be
492 # create a *runtime* Struct like rc for holding parameters which may be
493 # created and/or modified by runtime user extensions.
493 # created and/or modified by runtime user extensions.
494 IP.runtime_rc = Struct()
494 IP.runtime_rc = Struct()
495
495
496 # from this point on, all config should be handled through IP_rc,
496 # from this point on, all config should be handled through IP_rc,
497 # opts* shouldn't be used anymore.
497 # opts* shouldn't be used anymore.
498
498
499
499
500 # update IP_rc with some special things that need manual
500 # update IP_rc with some special things that need manual
501 # tweaks. Basically options which affect other options. I guess this
501 # tweaks. Basically options which affect other options. I guess this
502 # should just be written so that options are fully orthogonal and we
502 # should just be written so that options are fully orthogonal and we
503 # wouldn't worry about this stuff!
503 # wouldn't worry about this stuff!
504
504
505 if IP_rc.classic:
505 if IP_rc.classic:
506 IP_rc.quick = 1
506 IP_rc.quick = 1
507 IP_rc.cache_size = 0
507 IP_rc.cache_size = 0
508 IP_rc.pprint = 0
508 IP_rc.pprint = 0
509 IP_rc.prompt_in1 = '>>> '
509 IP_rc.prompt_in1 = '>>> '
510 IP_rc.prompt_in2 = '... '
510 IP_rc.prompt_in2 = '... '
511 IP_rc.prompt_out = ''
511 IP_rc.prompt_out = ''
512 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
512 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
513 IP_rc.colors = 'NoColor'
513 IP_rc.colors = 'NoColor'
514 IP_rc.xmode = 'Plain'
514 IP_rc.xmode = 'Plain'
515
515
516 IP.pre_config_initialization()
516 IP.pre_config_initialization()
517 # configure readline
517 # configure readline
518 # Define the history file for saving commands in between sessions
518 # Define the history file for saving commands in between sessions
519 if IP_rc.profile:
519 if IP_rc.profile:
520 histfname = 'history-%s' % IP_rc.profile
520 histfname = 'history-%s' % IP_rc.profile
521 else:
521 else:
522 histfname = 'history'
522 histfname = 'history'
523 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
523 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
524
524
525 # update exception handlers with rc file status
525 # update exception handlers with rc file status
526 otrap.trap_out() # I don't want these messages ever.
526 otrap.trap_out() # I don't want these messages ever.
527 IP.magic_xmode(IP_rc.xmode)
527 IP.magic_xmode(IP_rc.xmode)
528 otrap.release_out()
528 otrap.release_out()
529
529
530 # activate logging if requested and not reloading a log
530 # activate logging if requested and not reloading a log
531 if IP_rc.logplay:
531 if IP_rc.logplay:
532 IP.magic_logstart(IP_rc.logplay + ' append')
532 IP.magic_logstart(IP_rc.logplay + ' append')
533 elif IP_rc.logfile:
533 elif IP_rc.logfile:
534 IP.magic_logstart(IP_rc.logfile)
534 IP.magic_logstart(IP_rc.logfile)
535 elif IP_rc.log:
535 elif IP_rc.log:
536 IP.magic_logstart()
536 IP.magic_logstart()
537
537
538 # find user editor so that it we don't have to look it up constantly
538 # find user editor so that it we don't have to look it up constantly
539 if IP_rc.editor.strip()=='0':
539 if IP_rc.editor.strip()=='0':
540 try:
540 try:
541 ed = os.environ['EDITOR']
541 ed = os.environ['EDITOR']
542 except KeyError:
542 except KeyError:
543 if os.name == 'posix':
543 if os.name == 'posix':
544 ed = 'vi' # the only one guaranteed to be there!
544 ed = 'vi' # the only one guaranteed to be there!
545 else:
545 else:
546 ed = 'notepad' # same in Windows!
546 ed = 'notepad' # same in Windows!
547 IP_rc.editor = ed
547 IP_rc.editor = ed
548
548
549 # Keep track of whether this is an embedded instance or not (useful for
549 # Keep track of whether this is an embedded instance or not (useful for
550 # post-mortems).
550 # post-mortems).
551 IP_rc.embedded = IP.embedded
551 IP_rc.embedded = IP.embedded
552
552
553 # Recursive reload
553 # Recursive reload
554 try:
554 try:
555 from IPython import deep_reload
555 from IPython import deep_reload
556 if IP_rc.deep_reload:
556 if IP_rc.deep_reload:
557 __builtin__.reload = deep_reload.reload
557 __builtin__.reload = deep_reload.reload
558 else:
558 else:
559 __builtin__.dreload = deep_reload.reload
559 __builtin__.dreload = deep_reload.reload
560 del deep_reload
560 del deep_reload
561 except ImportError:
561 except ImportError:
562 pass
562 pass
563
563
564 # Save the current state of our namespace so that the interactive shell
564 # Save the current state of our namespace so that the interactive shell
565 # can later know which variables have been created by us from config files
565 # can later know which variables have been created by us from config files
566 # and loading. This way, loading a file (in any way) is treated just like
566 # and loading. This way, loading a file (in any way) is treated just like
567 # defining things on the command line, and %who works as expected.
567 # defining things on the command line, and %who works as expected.
568
568
569 # DON'T do anything that affects the namespace beyond this point!
569 # DON'T do anything that affects the namespace beyond this point!
570 IP.internal_ns.update(__main__.__dict__)
570 IP.internal_ns.update(__main__.__dict__)
571
571
572 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
572 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
573
573
574 # Now run through the different sections of the users's config
574 # Now run through the different sections of the users's config
575 if IP_rc.debug:
575 if IP_rc.debug:
576 print 'Trying to execute the following configuration structure:'
576 print 'Trying to execute the following configuration structure:'
577 print '(Things listed first are deeper in the inclusion tree and get'
577 print '(Things listed first are deeper in the inclusion tree and get'
578 print 'loaded first).\n'
578 print 'loaded first).\n'
579 pprint(IP_rc.__dict__)
579 pprint(IP_rc.__dict__)
580
580
581 for mod in IP_rc.import_mod:
581 for mod in IP_rc.import_mod:
582 try:
582 try:
583 exec 'import '+mod in IP.user_ns
583 exec 'import '+mod in IP.user_ns
584 except :
584 except :
585 IP.InteractiveTB()
585 IP.InteractiveTB()
586 import_fail_info(mod)
586 import_fail_info(mod)
587
587
588 for mod_fn in IP_rc.import_some:
588 for mod_fn in IP_rc.import_some:
589 if not mod_fn == []:
589 if not mod_fn == []:
590 mod,fn = mod_fn[0],','.join(mod_fn[1:])
590 mod,fn = mod_fn[0],','.join(mod_fn[1:])
591 try:
591 try:
592 exec 'from '+mod+' import '+fn in IP.user_ns
592 exec 'from '+mod+' import '+fn in IP.user_ns
593 except :
593 except :
594 IP.InteractiveTB()
594 IP.InteractiveTB()
595 import_fail_info(mod,fn)
595 import_fail_info(mod,fn)
596
596
597 for mod in IP_rc.import_all:
597 for mod in IP_rc.import_all:
598 try:
598 try:
599 exec 'from '+mod+' import *' in IP.user_ns
599 exec 'from '+mod+' import *' in IP.user_ns
600 except :
600 except :
601 IP.InteractiveTB()
601 IP.InteractiveTB()
602 import_fail_info(mod)
602 import_fail_info(mod)
603
603
604 for code in IP_rc.execute:
604 for code in IP_rc.execute:
605 try:
605 try:
606 exec code in IP.user_ns
606 exec code in IP.user_ns
607 except:
607 except:
608 IP.InteractiveTB()
608 IP.InteractiveTB()
609 warn('Failure executing code: ' + `code`)
609 warn('Failure executing code: ' + `code`)
610
610
611 # Execute the files the user wants in ipythonrc
611 # Execute the files the user wants in ipythonrc
612 for file in IP_rc.execfile:
612 for file in IP_rc.execfile:
613 try:
613 try:
614 file = filefind(file,sys.path+[IPython_dir])
614 file = filefind(file,sys.path+[IPython_dir])
615 except IOError:
615 except IOError:
616 warn(itpl('File $file not found. Skipping it.'))
616 warn(itpl('File $file not found. Skipping it.'))
617 else:
617 else:
618 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
618 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
619
619
620 # finally, try importing ipy_*_conf for final configuration
620 # finally, try importing ipy_*_conf for final configuration
621 try:
621 try:
622 import ipy_system_conf
622 import ipy_system_conf
623 except ImportError:
623 except ImportError:
624 if opts_all.debug: IP.InteractiveTB()
624 if opts_all.debug: IP.InteractiveTB()
625 warn("Could not import 'ipy_system_conf'")
625 warn("Could not import 'ipy_system_conf'")
626 except:
626 except:
627 IP.InteractiveTB()
627 IP.InteractiveTB()
628 import_fail_info('ipy_system_conf')
628 import_fail_info('ipy_system_conf')
629
629
630 # only import prof module if ipythonrc-PROF was not found
630 # only import prof module if ipythonrc-PROF was not found
631 if opts_all.profile and not profile_handled_by_legacy:
631 if opts_all.profile and not profile_handled_by_legacy:
632 profmodname = 'ipy_profile_' + opts_all.profile
632 profmodname = 'ipy_profile_' + opts_all.profile
633 try:
633 try:
634 __import__(profmodname)
634 __import__(profmodname)
635 except:
635 except:
636 IP.InteractiveTB()
636 IP.InteractiveTB()
637 print "Error importing",profmodname,"- perhaps you should run %upgrade?"
637 print "Error importing",profmodname,"- perhaps you should run %upgrade?"
638 import_fail_info(profmodname)
638 import_fail_info(profmodname)
639 else:
639 else:
640 import ipy_profile_none
640 import ipy_profile_none
641 try:
641 try:
642 import ipy_user_conf
642 import ipy_user_conf
643
643
644 except:
644 except:
645 conf = opts_all.ipythondir + "/ipy_user_conf.py"
645 conf = opts_all.ipythondir + "/ipy_user_conf.py"
646 IP.InteractiveTB()
646 IP.InteractiveTB()
647 if not os.path.isfile(conf):
647 if not os.path.isfile(conf):
648 warn(conf + ' does not exist, please run %upgrade!')
648 warn(conf + ' does not exist, please run %upgrade!')
649
649
650 import_fail_info("ipy_user_conf")
650 import_fail_info("ipy_user_conf")
651
651
652 # finally, push the argv to options again to ensure highest priority
652 # finally, push the argv to options again to ensure highest priority
653 IP_rc.update(opts)
653 IP_rc.update(opts)
654
654
655 # release stdout and stderr and save config log into a global summary
655 # release stdout and stderr and save config log into a global summary
656 msg.config.release_all()
656 msg.config.release_all()
657 if IP_rc.messages:
657 if IP_rc.messages:
658 msg.summary += msg.config.summary_all()
658 msg.summary += msg.config.summary_all()
659
659
660 #------------------------------------------------------------------------
660 #------------------------------------------------------------------------
661 # Setup interactive session
661 # Setup interactive session
662
662
663 # Now we should be fully configured. We can then execute files or load
663 # Now we should be fully configured. We can then execute files or load
664 # things only needed for interactive use. Then we'll open the shell.
664 # things only needed for interactive use. Then we'll open the shell.
665
665
666 # Take a snapshot of the user namespace before opening the shell. That way
666 # Take a snapshot of the user namespace before opening the shell. That way
667 # we'll be able to identify which things were interactively defined and
667 # we'll be able to identify which things were interactively defined and
668 # which were defined through config files.
668 # which were defined through config files.
669 IP.user_config_ns.update(IP.user_ns)
669 IP.user_config_ns.update(IP.user_ns)
670
670
671 # Force reading a file as if it were a session log. Slower but safer.
671 # Force reading a file as if it were a session log. Slower but safer.
672 if load_logplay:
672 if load_logplay:
673 print 'Replaying log...'
673 print 'Replaying log...'
674 try:
674 try:
675 if IP_rc.debug:
675 if IP_rc.debug:
676 logplay_quiet = 0
676 logplay_quiet = 0
677 else:
677 else:
678 logplay_quiet = 1
678 logplay_quiet = 1
679
679
680 msg.logplay.trap_all()
680 msg.logplay.trap_all()
681 IP.safe_execfile(load_logplay,IP.user_ns,
681 IP.safe_execfile(load_logplay,IP.user_ns,
682 islog = 1, quiet = logplay_quiet)
682 islog = 1, quiet = logplay_quiet)
683 msg.logplay.release_all()
683 msg.logplay.release_all()
684 if IP_rc.messages:
684 if IP_rc.messages:
685 msg.summary += msg.logplay.summary_all()
685 msg.summary += msg.logplay.summary_all()
686 except:
686 except:
687 warn('Problems replaying logfile %s.' % load_logplay)
687 warn('Problems replaying logfile %s.' % load_logplay)
688 IP.InteractiveTB()
688 IP.InteractiveTB()
689
689
690 # Load remaining files in command line
690 # Load remaining files in command line
691 msg.user_exec.trap_all()
691 msg.user_exec.trap_all()
692
692
693 # Do NOT execute files named in the command line as scripts to be loaded
693 # Do NOT execute files named in the command line as scripts to be loaded
694 # by embedded instances. Doing so has the potential for an infinite
694 # by embedded instances. Doing so has the potential for an infinite
695 # recursion if there are exceptions thrown in the process.
695 # recursion if there are exceptions thrown in the process.
696
696
697 # XXX FIXME: the execution of user files should be moved out to after
697 # XXX FIXME: the execution of user files should be moved out to after
698 # ipython is fully initialized, just as if they were run via %run at the
698 # ipython is fully initialized, just as if they were run via %run at the
699 # ipython prompt. This would also give them the benefit of ipython's
699 # ipython prompt. This would also give them the benefit of ipython's
700 # nice tracebacks.
700 # nice tracebacks.
701
701
702 if (not embedded and IP_rc.args and
702 if (not embedded and IP_rc.args and
703 not IP_rc.args[0].lower().endswith('.ipy')):
703 not IP_rc.args[0].lower().endswith('.ipy')):
704 name_save = IP.user_ns['__name__']
704 name_save = IP.user_ns['__name__']
705 IP.user_ns['__name__'] = '__main__'
705 IP.user_ns['__name__'] = '__main__'
706 # Set our own excepthook in case the user code tries to call it
706 # Set our own excepthook in case the user code tries to call it
707 # directly. This prevents triggering the IPython crash handler.
707 # directly. This prevents triggering the IPython crash handler.
708 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
708 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
709
709
710 save_argv = sys.argv[1:] # save it for later restoring
710 save_argv = sys.argv[1:] # save it for later restoring
711
711
712 sys.argv = args
712 sys.argv = args
713
713
714 try:
714 try:
715 IP.safe_execfile(args[0], IP.user_ns)
715 IP.safe_execfile(args[0], IP.user_ns)
716 finally:
716 finally:
717 # Reset our crash handler in place
717 # Reset our crash handler in place
718 sys.excepthook = old_excepthook
718 sys.excepthook = old_excepthook
719 sys.argv[:] = save_argv
719 sys.argv[:] = save_argv
720 IP.user_ns['__name__'] = name_save
720 IP.user_ns['__name__'] = name_save
721
721
722 msg.user_exec.release_all()
722 msg.user_exec.release_all()
723
723
724 if IP_rc.messages:
724 if IP_rc.messages:
725 msg.summary += msg.user_exec.summary_all()
725 msg.summary += msg.user_exec.summary_all()
726
726
727 # since we can't specify a null string on the cmd line, 0 is the equivalent:
727 # since we can't specify a null string on the cmd line, 0 is the equivalent:
728 if IP_rc.nosep:
728 if IP_rc.nosep:
729 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
729 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
730 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
730 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
731 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
731 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
732 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
732 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
733 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
733 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
734 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
734 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
735 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
735 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
736
736
737 # Determine how many lines at the bottom of the screen are needed for
737 # Determine how many lines at the bottom of the screen are needed for
738 # showing prompts, so we can know wheter long strings are to be printed or
738 # showing prompts, so we can know wheter long strings are to be printed or
739 # paged:
739 # paged:
740 num_lines_bot = IP_rc.separate_in.count('\n')+1
740 num_lines_bot = IP_rc.separate_in.count('\n')+1
741 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
741 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
742
742
743 # configure startup banner
743 # configure startup banner
744 if IP_rc.c: # regular python doesn't print the banner with -c
744 if IP_rc.c: # regular python doesn't print the banner with -c
745 IP_rc.banner = 0
745 IP_rc.banner = 0
746 if IP_rc.banner:
746 if IP_rc.banner:
747 BANN_P = IP.BANNER_PARTS
747 BANN_P = IP.BANNER_PARTS
748 else:
748 else:
749 BANN_P = []
749 BANN_P = []
750
750
751 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
751 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
752
752
753 # add message log (possibly empty)
753 # add message log (possibly empty)
754 if msg.summary: BANN_P.append(msg.summary)
754 if msg.summary: BANN_P.append(msg.summary)
755 # Final banner is a string
755 # Final banner is a string
756 IP.BANNER = '\n'.join(BANN_P)
756 IP.BANNER = '\n'.join(BANN_P)
757
757
758 # Finalize the IPython instance. This assumes the rc structure is fully
758 # Finalize the IPython instance. This assumes the rc structure is fully
759 # in place.
759 # in place.
760 IP.post_config_initialization()
760 IP.post_config_initialization()
761
761
762 return IP
762 return IP
763 #************************ end of file <ipmaker.py> **************************
763 #************************ end of file <ipmaker.py> **************************
@@ -1,7234 +1,7241 b''
1 2007-11-24 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/DPyGetOpt.py (ArgumentError): Apply patch by Paul Mueller
4 <gakusei-AT-dakotacom.net>, to fix deprecated string exceptions in
5 options handling. Unicode fix in %whos (committed a while ago)
6 was also contributed by Paul.
7
1 2007-11-23 Darren Dale <darren.dale@cornell.edu>
8 2007-11-23 Darren Dale <darren.dale@cornell.edu>
2 * ipy_traits_completer.py: let traits_completer respect the user's
9 * ipy_traits_completer.py: let traits_completer respect the user's
3 readline_omit__names setting.
10 readline_omit__names setting.
4
11
5 2007-11-08 Ville Vainio <vivainio@gmail.com>
12 2007-11-08 Ville Vainio <vivainio@gmail.com>
6 * ipy_completers.py (import completer): assume 'xml' module exists.
13 * ipy_completers.py (import completer): assume 'xml' module exists.
7 Do not add every module twice anymore. Closes #196.
14 Do not add every module twice anymore. Closes #196.
8
15
9 * ipy_completers.py, ipy_app_completers.py: Add proper apt-get
16 * ipy_completers.py, ipy_app_completers.py: Add proper apt-get
10 completer that uses apt-cache to search for existing packages.
17 completer that uses apt-cache to search for existing packages.
11
18
12 2007-11-06 Ville Vainio <vivainio@gmail.com>
19 2007-11-06 Ville Vainio <vivainio@gmail.com>
13
20
14 * Prompts.py: Do not update _oh and _123 when do_full_cache is not
21 * Prompts.py: Do not update _oh and _123 when do_full_cache is not
15 true. Closes #194.
22 true. Closes #194.
16
23
17 2007-11-01 Brian Granger <ellisonbg@gmail.com>
24 2007-11-01 Brian Granger <ellisonbg@gmail.com>
18
25
19 * iplib.py, rlineimpl.py: Applied Body Water's patches to get IPython
26 * iplib.py, rlineimpl.py: Applied Body Water's patches to get IPython
20 working with OS X 10.5 libedit implementation of readline.
27 working with OS X 10.5 libedit implementation of readline.
21
28
22 2007-10-24 Ville Vainio <vivainio@gmail.com>
29 2007-10-24 Ville Vainio <vivainio@gmail.com>
23
30
24 * iplib.py(user_setup): To route around buggy installations where
31 * iplib.py(user_setup): To route around buggy installations where
25 UserConfig is not available, create a minimal _ipython.
32 UserConfig is not available, create a minimal _ipython.
26
33
27 * iplib.py: Unicode fixes from Jorgen.
34 * iplib.py: Unicode fixes from Jorgen.
28
35
29 * genutils.py: Slist now has new method 'fields()' for extraction of
36 * genutils.py: Slist now has new method 'fields()' for extraction of
30 whitespace-separated fields from line-oriented data.
37 whitespace-separated fields from line-oriented data.
31
38
32 2007-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
39 2007-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
33
40
34 * IPython/OInspect.py (Inspector.pinfo): fix bug that could arise
41 * IPython/OInspect.py (Inspector.pinfo): fix bug that could arise
35 when querying objects with no __class__ attribute (such as
42 when querying objects with no __class__ attribute (such as
36 f2py-generated modules).
43 f2py-generated modules).
37
44
38 2007-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
45 2007-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
39
46
40 * IPython/Magic.py (magic_time): track compilation time and report
47 * IPython/Magic.py (magic_time): track compilation time and report
41 it if longer than 0.1s (fix done to %time and %timeit). After a
48 it if longer than 0.1s (fix done to %time and %timeit). After a
42 SAGE bug report: http://trac.sagemath.org/sage_trac/ticket/632.
49 SAGE bug report: http://trac.sagemath.org/sage_trac/ticket/632.
43
50
44 2007-09-18 Ville Vainio <vivainio@gmail.com>
51 2007-09-18 Ville Vainio <vivainio@gmail.com>
45
52
46 * genutils.py(make_quoted_expr): Do not use Itpl, it does
53 * genutils.py(make_quoted_expr): Do not use Itpl, it does
47 not support unicode at the moment. Fixes (many) magic calls with
54 not support unicode at the moment. Fixes (many) magic calls with
48 special characters.
55 special characters.
49
56
50 2007-09-14 Fernando Perez <Fernando.Perez@colorado.edu>
57 2007-09-14 Fernando Perez <Fernando.Perez@colorado.edu>
51
58
52 * IPython/genutils.py (doctest_reload): expose the doctest
59 * IPython/genutils.py (doctest_reload): expose the doctest
53 reloader to the user so that people can easily reset doctest while
60 reloader to the user so that people can easily reset doctest while
54 using it interactively. Fixes a problem reported by Jorgen.
61 using it interactively. Fixes a problem reported by Jorgen.
55
62
56 * IPython/iplib.py (InteractiveShell.__init__): protect the
63 * IPython/iplib.py (InteractiveShell.__init__): protect the
57 FakeModule instances used for __main__ in %run calls from
64 FakeModule instances used for __main__ in %run calls from
58 deletion, so that user code defined in them isn't left with
65 deletion, so that user code defined in them isn't left with
59 dangling references due to the Python module deletion machinery.
66 dangling references due to the Python module deletion machinery.
60 This should fix the problems reported by Darren.
67 This should fix the problems reported by Darren.
61
68
62 2007-09-10 Darren Dale <dd55@cornell.edu>
69 2007-09-10 Darren Dale <dd55@cornell.edu>
63
70
64 * Cleanup of IPShellQt and IPShellQt4
71 * Cleanup of IPShellQt and IPShellQt4
65
72
66 2007-09-09 Fernando Perez <Fernando.Perez@colorado.edu>
73 2007-09-09 Fernando Perez <Fernando.Perez@colorado.edu>
67
74
68 * IPython/FakeModule.py (FakeModule.__init__): further fixes for
75 * IPython/FakeModule.py (FakeModule.__init__): further fixes for
69 doctest support.
76 doctest support.
70
77
71 * IPython/iplib.py (safe_execfile): minor docstring improvements.
78 * IPython/iplib.py (safe_execfile): minor docstring improvements.
72
79
73 2007-09-08 Ville Vainio <vivainio@gmail.com>
80 2007-09-08 Ville Vainio <vivainio@gmail.com>
74
81
75 * Magic.py (%pushd, %popd, %dirs): Fix dir stack - push *current*
82 * Magic.py (%pushd, %popd, %dirs): Fix dir stack - push *current*
76 directory, not the target directory.
83 directory, not the target directory.
77
84
78 * ipapi.py, Magic.py, iplib.py: Add ipapi.UsageError, a lighter weight
85 * ipapi.py, Magic.py, iplib.py: Add ipapi.UsageError, a lighter weight
79 exception that won't print the tracebacks. Switched many magics to
86 exception that won't print the tracebacks. Switched many magics to
80 raise them on error situations, also GetoptError is not printed
87 raise them on error situations, also GetoptError is not printed
81 anymore.
88 anymore.
82
89
83 2007-09-07 Ville Vainio <vivainio@gmail.com>
90 2007-09-07 Ville Vainio <vivainio@gmail.com>
84
91
85 * iplib.py: do not auto-alias "dir", it screws up other dir auto
92 * iplib.py: do not auto-alias "dir", it screws up other dir auto
86 aliases.
93 aliases.
87
94
88 * genutils.py: SList.grep() implemented.
95 * genutils.py: SList.grep() implemented.
89
96
90 * ipy_editors.py, UserConfig/ipy_user_conf.py: Add some editors
97 * ipy_editors.py, UserConfig/ipy_user_conf.py: Add some editors
91 for easy "out of the box" setup of several common editors, so that
98 for easy "out of the box" setup of several common editors, so that
92 e.g. '%edit os.path.isfile' will jump to the correct line
99 e.g. '%edit os.path.isfile' will jump to the correct line
93 automatically. Contributions for command lines of your favourite
100 automatically. Contributions for command lines of your favourite
94 editors welcome.
101 editors welcome.
95
102
96 2007-09-07 Fernando Perez <Fernando.Perez@colorado.edu>
103 2007-09-07 Fernando Perez <Fernando.Perez@colorado.edu>
97
104
98 * IPython/OInspect.py (Inspector.pinfo): fixed bug that was
105 * IPython/OInspect.py (Inspector.pinfo): fixed bug that was
99 preventing source display in certain cases. In reality I think
106 preventing source display in certain cases. In reality I think
100 the problem is with Ubuntu's Python build, but this change works
107 the problem is with Ubuntu's Python build, but this change works
101 around the issue in some cases (not in all, unfortunately). I'd
108 around the issue in some cases (not in all, unfortunately). I'd
102 filed a Python bug on this with more details, but in the change of
109 filed a Python bug on this with more details, but in the change of
103 bug trackers it seems to have been lost.
110 bug trackers it seems to have been lost.
104
111
105 * IPython/Magic.py (magic_dhist): restore %dhist. No, cd -TAB is
112 * IPython/Magic.py (magic_dhist): restore %dhist. No, cd -TAB is
106 not the same, it's not self-documenting, doesn't allow range
113 not the same, it's not self-documenting, doesn't allow range
107 selection, and sorts alphabetically instead of numerically.
114 selection, and sorts alphabetically instead of numerically.
108 (magic_r): restore %r. No, "up + enter. One char magic" is not
115 (magic_r): restore %r. No, "up + enter. One char magic" is not
109 the same thing, since %r takes parameters to allow fast retrieval
116 the same thing, since %r takes parameters to allow fast retrieval
110 of old commands. I've received emails from users who use this a
117 of old commands. I've received emails from users who use this a
111 LOT, so it stays.
118 LOT, so it stays.
112 (magic_automagic): restore %automagic. "use _ip.option.automagic"
119 (magic_automagic): restore %automagic. "use _ip.option.automagic"
113 is not a valid replacement b/c it doesn't provide an complete
120 is not a valid replacement b/c it doesn't provide an complete
114 explanation (which the automagic docstring does).
121 explanation (which the automagic docstring does).
115 (magic_autocall): restore %autocall, with improved docstring.
122 (magic_autocall): restore %autocall, with improved docstring.
116 Same argument as for others, "use _ip.options.autocall" is not a
123 Same argument as for others, "use _ip.options.autocall" is not a
117 valid replacement.
124 valid replacement.
118 (magic_pdef): restore %pdef & friends. Used widely, mentioned in
125 (magic_pdef): restore %pdef & friends. Used widely, mentioned in
119 tutorials and online docs.
126 tutorials and online docs.
120
127
121 2007-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
128 2007-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
122
129
123 * IPython/usage.py (quick_reference): mention magics in quickref,
130 * IPython/usage.py (quick_reference): mention magics in quickref,
124 modified main banner to mention %quickref.
131 modified main banner to mention %quickref.
125
132
126 * IPython/FakeModule.py (FakeModule): fixes for doctest compatibility.
133 * IPython/FakeModule.py (FakeModule): fixes for doctest compatibility.
127
134
128 2007-09-06 Ville Vainio <vivainio@gmail.com>
135 2007-09-06 Ville Vainio <vivainio@gmail.com>
129
136
130 * ipy_rehashdir.py, ipy_workdir.py, ipy_fsops.py, iplib.py:
137 * ipy_rehashdir.py, ipy_workdir.py, ipy_fsops.py, iplib.py:
131 Callable aliases now pass the _ip as first arg. This breaks
138 Callable aliases now pass the _ip as first arg. This breaks
132 compatibility with earlier 0.8.2.svn series! (though they should
139 compatibility with earlier 0.8.2.svn series! (though they should
133 not have been in use yet outside these few extensions)
140 not have been in use yet outside these few extensions)
134
141
135 2007-09-05 Ville Vainio <vivainio@gmail.com>
142 2007-09-05 Ville Vainio <vivainio@gmail.com>
136
143
137 * external/mglob.py: expand('dirname') => ['dirname'], instead
144 * external/mglob.py: expand('dirname') => ['dirname'], instead
138 of ['dirname/foo','dirname/bar', ...].
145 of ['dirname/foo','dirname/bar', ...].
139
146
140 * Extensions/ipy_fsops.py: added, has usefull shell utils for plain
147 * Extensions/ipy_fsops.py: added, has usefull shell utils for plain
141 win32 installations: icp, imv, imkdir, igrep, irm, collect (collect
148 win32 installations: icp, imv, imkdir, igrep, irm, collect (collect
142 is useful for others as well).
149 is useful for others as well).
143
150
144 * iplib.py: on callable aliases (as opposed to old style aliases),
151 * iplib.py: on callable aliases (as opposed to old style aliases),
145 do var_expand() immediately, and use make_quoted_expr instead
152 do var_expand() immediately, and use make_quoted_expr instead
146 of hardcoded r"""
153 of hardcoded r"""
147
154
148 * Extensions/ipy_profile_sh.py: Try to detect cygwin on win32,
155 * Extensions/ipy_profile_sh.py: Try to detect cygwin on win32,
149 if not available load ipy_fsops.py for cp, mv, etc. replacements
156 if not available load ipy_fsops.py for cp, mv, etc. replacements
150
157
151 * OInspect.py, ipy_which.py: improve %which and obj? for callable
158 * OInspect.py, ipy_which.py: improve %which and obj? for callable
152 aliases
159 aliases
153
160
154 2007-09-04 Ville Vainio <vivainio@gmail.com>
161 2007-09-04 Ville Vainio <vivainio@gmail.com>
155
162
156 * ipy_profile_zope.py: add zope profile, by Stefan Eletzhofer.
163 * ipy_profile_zope.py: add zope profile, by Stefan Eletzhofer.
157 Relicensed under BSD with the authors approval.
164 Relicensed under BSD with the authors approval.
158
165
159 * ipmaker.py, usage.py: Remove %magic from default banner, improve
166 * ipmaker.py, usage.py: Remove %magic from default banner, improve
160 %quickref
167 %quickref
161
168
162 2007-09-03 Ville Vainio <vivainio@gmail.com>
169 2007-09-03 Ville Vainio <vivainio@gmail.com>
163
170
164 * Magic.py: %time now passes expression through prefilter,
171 * Magic.py: %time now passes expression through prefilter,
165 allowing IPython syntax.
172 allowing IPython syntax.
166
173
167 2007-09-01 Ville Vainio <vivainio@gmail.com>
174 2007-09-01 Ville Vainio <vivainio@gmail.com>
168
175
169 * ipmaker.py: Always show full traceback when newstyle config fails
176 * ipmaker.py: Always show full traceback when newstyle config fails
170
177
171 2007-08-27 Ville Vainio <vivainio@gmail.com>
178 2007-08-27 Ville Vainio <vivainio@gmail.com>
172
179
173 * Magic.py: fix %cd for nonexistent dir when dhist is empty, close #180
180 * Magic.py: fix %cd for nonexistent dir when dhist is empty, close #180
174
181
175 2007-08-26 Ville Vainio <vivainio@gmail.com>
182 2007-08-26 Ville Vainio <vivainio@gmail.com>
176
183
177 * ipmaker.py: Command line args have the highest priority again
184 * ipmaker.py: Command line args have the highest priority again
178
185
179 * iplib.py, ipmaker.py: -i command line argument now behaves as in
186 * iplib.py, ipmaker.py: -i command line argument now behaves as in
180 normal python, i.e. leaves the IPython session running after -c
187 normal python, i.e. leaves the IPython session running after -c
181 command or running a batch file from command line.
188 command or running a batch file from command line.
182
189
183 2007-08-22 Ville Vainio <vivainio@gmail.com>
190 2007-08-22 Ville Vainio <vivainio@gmail.com>
184
191
185 * iplib.py: no extra empty (last) line in raw hist w/ multiline
192 * iplib.py: no extra empty (last) line in raw hist w/ multiline
186 statements
193 statements
187
194
188 * logger.py: Fix bug where blank lines in history were not
195 * logger.py: Fix bug where blank lines in history were not
189 added until AFTER adding the current line; translated and raw
196 added until AFTER adding the current line; translated and raw
190 history should finally be in sync with prompt now.
197 history should finally be in sync with prompt now.
191
198
192 * ipy_completers.py: quick_completer now makes it easy to create
199 * ipy_completers.py: quick_completer now makes it easy to create
193 trivial custom completers
200 trivial custom completers
194
201
195 * clearcmd.py: shadow history compression & erasing, fixed input hist
202 * clearcmd.py: shadow history compression & erasing, fixed input hist
196 clearing.
203 clearing.
197
204
198 * envpersist.py, history.py: %env (sh profile only), %hist completers
205 * envpersist.py, history.py: %env (sh profile only), %hist completers
199
206
200 * genutils.py, Prompts.py, Magic.py: win32 - prompt (with \yDEPTH) and
207 * genutils.py, Prompts.py, Magic.py: win32 - prompt (with \yDEPTH) and
201 term title now include the drive letter, and always use / instead of
208 term title now include the drive letter, and always use / instead of
202 os.sep (as per recommended approach for win32 ipython in general).
209 os.sep (as per recommended approach for win32 ipython in general).
203
210
204 * ipykit.py, ipy_kitcfg.py: special launcher for ipykit. Allows running
211 * ipykit.py, ipy_kitcfg.py: special launcher for ipykit. Allows running
205 plain python scripts from ipykit command line by running
212 plain python scripts from ipykit command line by running
206 "py myscript.py", even w/o installed python.
213 "py myscript.py", even w/o installed python.
207
214
208 2007-08-21 Ville Vainio <vivainio@gmail.com>
215 2007-08-21 Ville Vainio <vivainio@gmail.com>
209
216
210 * ipmaker.py: finding ipythonrc-PROF now skips ipy_profile_PROF.
217 * ipmaker.py: finding ipythonrc-PROF now skips ipy_profile_PROF.
211 (for backwards compatibility)
218 (for backwards compatibility)
212
219
213 * history.py: switch back to %hist -t from %hist -r as default.
220 * history.py: switch back to %hist -t from %hist -r as default.
214 At least until raw history is fixed for good.
221 At least until raw history is fixed for good.
215
222
216 2007-08-20 Ville Vainio <vivainio@gmail.com>
223 2007-08-20 Ville Vainio <vivainio@gmail.com>
217
224
218 * ipapi.py, iplib.py: DebugTools accessible via _ip.dbg, to catch &
225 * ipapi.py, iplib.py: DebugTools accessible via _ip.dbg, to catch &
219 locate alias redeclarations etc. Also, avoid handling
226 locate alias redeclarations etc. Also, avoid handling
220 _ip.IP.alias_table directly, prefer using _ip.defalias.
227 _ip.IP.alias_table directly, prefer using _ip.defalias.
221
228
222
229
223 2007-08-15 Ville Vainio <vivainio@gmail.com>
230 2007-08-15 Ville Vainio <vivainio@gmail.com>
224
231
225 * prefilter.py: ! is now always served first
232 * prefilter.py: ! is now always served first
226
233
227 2007-08-15 Fernando Perez <Fernando.Perez@colorado.edu>
234 2007-08-15 Fernando Perez <Fernando.Perez@colorado.edu>
228
235
229 * IPython/iplib.py (safe_execfile): fix the SystemExit
236 * IPython/iplib.py (safe_execfile): fix the SystemExit
230 auto-suppression code to work in Python2.4 (the internal structure
237 auto-suppression code to work in Python2.4 (the internal structure
231 of that exception changed and I'd only tested the code with 2.5).
238 of that exception changed and I'd only tested the code with 2.5).
232 Bug reported by a SciPy attendee.
239 Bug reported by a SciPy attendee.
233
240
234 2007-08-13 Ville Vainio <vivainio@gmail.com>
241 2007-08-13 Ville Vainio <vivainio@gmail.com>
235
242
236 * prefilter.py: reverted !c:/bin/foo fix, made % in
243 * prefilter.py: reverted !c:/bin/foo fix, made % in
237 multiline specials work again
244 multiline specials work again
238
245
239 2007-08-13 Ville Vainio <vivainio@gmail.com>
246 2007-08-13 Ville Vainio <vivainio@gmail.com>
240
247
241 * prefilter.py: Take more care to special-case !, so that
248 * prefilter.py: Take more care to special-case !, so that
242 !c:/bin/foo.exe works.
249 !c:/bin/foo.exe works.
243
250
244 * setup.py: if we are building eggs, strip all docs and
251 * setup.py: if we are building eggs, strip all docs and
245 examples (it doesn't make sense to bytecompile examples,
252 examples (it doesn't make sense to bytecompile examples,
246 and docs would be in an awkward place anyway).
253 and docs would be in an awkward place anyway).
247
254
248 * Ryan Krauss' patch fixes start menu shortcuts when IPython
255 * Ryan Krauss' patch fixes start menu shortcuts when IPython
249 is installed into a directory that has spaces in the name.
256 is installed into a directory that has spaces in the name.
250
257
251 2007-08-13 Fernando Perez <Fernando.Perez@colorado.edu>
258 2007-08-13 Fernando Perez <Fernando.Perez@colorado.edu>
252
259
253 * IPython/Magic.py (magic_doctest_mode): fix prompt separators in
260 * IPython/Magic.py (magic_doctest_mode): fix prompt separators in
254 doctest profile and %doctest_mode, so they actually generate the
261 doctest profile and %doctest_mode, so they actually generate the
255 blank lines needed by doctest to separate individual tests.
262 blank lines needed by doctest to separate individual tests.
256
263
257 * IPython/iplib.py (safe_execfile): modify so that running code
264 * IPython/iplib.py (safe_execfile): modify so that running code
258 which calls sys.exit(0) (or equivalently, raise SystemExit(0))
265 which calls sys.exit(0) (or equivalently, raise SystemExit(0))
259 doesn't get a printed traceback. Any other value in sys.exit(),
266 doesn't get a printed traceback. Any other value in sys.exit(),
260 including the empty call, still generates a traceback. This
267 including the empty call, still generates a traceback. This
261 enables use of %run without having to pass '-e' for codes that
268 enables use of %run without having to pass '-e' for codes that
262 correctly set the exit status flag.
269 correctly set the exit status flag.
263
270
264 2007-08-12 Fernando Perez <Fernando.Perez@colorado.edu>
271 2007-08-12 Fernando Perez <Fernando.Perez@colorado.edu>
265
272
266 * IPython/iplib.py (InteractiveShell.post_config_initialization):
273 * IPython/iplib.py (InteractiveShell.post_config_initialization):
267 fix problems with doctests failing when run inside IPython due to
274 fix problems with doctests failing when run inside IPython due to
268 IPython's modifications of sys.displayhook.
275 IPython's modifications of sys.displayhook.
269
276
270 2007-8-9 Fernando Perez <fperez@planck.colorado.edu>
277 2007-8-9 Fernando Perez <fperez@planck.colorado.edu>
271
278
272 * IPython/ipapi.py (to_user_ns): update to accept a dict as well as
279 * IPython/ipapi.py (to_user_ns): update to accept a dict as well as
273 a string with names.
280 a string with names.
274
281
275 2007-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
282 2007-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
276
283
277 * IPython/Magic.py (magic_doctest_mode): added new %doctest_mode
284 * IPython/Magic.py (magic_doctest_mode): added new %doctest_mode
278 magic to toggle on/off the doctest pasting support without having
285 magic to toggle on/off the doctest pasting support without having
279 to leave a session to switch to a separate profile.
286 to leave a session to switch to a separate profile.
280
287
281 2007-08-08 Fernando Perez <Fernando.Perez@colorado.edu>
288 2007-08-08 Fernando Perez <Fernando.Perez@colorado.edu>
282
289
283 * IPython/Extensions/ipy_profile_doctest.py (main): fix prompt to
290 * IPython/Extensions/ipy_profile_doctest.py (main): fix prompt to
284 introduce a blank line between inputs, to conform to doctest
291 introduce a blank line between inputs, to conform to doctest
285 requirements.
292 requirements.
286
293
287 * IPython/OInspect.py (Inspector.pinfo): fix another part where
294 * IPython/OInspect.py (Inspector.pinfo): fix another part where
288 auto-generated docstrings for new-style classes were showing up.
295 auto-generated docstrings for new-style classes were showing up.
289
296
290 2007-08-07 Fernando Perez <Fernando.Perez@colorado.edu>
297 2007-08-07 Fernando Perez <Fernando.Perez@colorado.edu>
291
298
292 * api_changes: Add new file to track backward-incompatible
299 * api_changes: Add new file to track backward-incompatible
293 user-visible changes.
300 user-visible changes.
294
301
295 2007-08-06 Ville Vainio <vivainio@gmail.com>
302 2007-08-06 Ville Vainio <vivainio@gmail.com>
296
303
297 * ipmaker.py: fix bug where user_config_ns didn't exist at all
304 * ipmaker.py: fix bug where user_config_ns didn't exist at all
298 before all the config files were handled.
305 before all the config files were handled.
299
306
300 2007-08-04 Fernando Perez <Fernando.Perez@colorado.edu>
307 2007-08-04 Fernando Perez <Fernando.Perez@colorado.edu>
301
308
302 * IPython/irunner.py (RunnerFactory): Add new factory class for
309 * IPython/irunner.py (RunnerFactory): Add new factory class for
303 creating reusable runners based on filenames.
310 creating reusable runners based on filenames.
304
311
305 * IPython/Extensions/ipy_profile_doctest.py: New profile for
312 * IPython/Extensions/ipy_profile_doctest.py: New profile for
306 doctest support. It sets prompts/exceptions as similar to
313 doctest support. It sets prompts/exceptions as similar to
307 standard Python as possible, so that ipython sessions in this
314 standard Python as possible, so that ipython sessions in this
308 profile can be easily pasted as doctests with minimal
315 profile can be easily pasted as doctests with minimal
309 modifications. It also enables pasting of doctests from external
316 modifications. It also enables pasting of doctests from external
310 sources (even if they have leading whitespace), so that you can
317 sources (even if they have leading whitespace), so that you can
311 rerun doctests from existing sources.
318 rerun doctests from existing sources.
312
319
313 * IPython/iplib.py (_prefilter): fix a buglet where after entering
320 * IPython/iplib.py (_prefilter): fix a buglet where after entering
314 some whitespace, the prompt would become a continuation prompt
321 some whitespace, the prompt would become a continuation prompt
315 with no way of exiting it other than Ctrl-C. This fix brings us
322 with no way of exiting it other than Ctrl-C. This fix brings us
316 into conformity with how the default python prompt works.
323 into conformity with how the default python prompt works.
317
324
318 * IPython/Extensions/InterpreterPasteInput.py (prefilter_paste):
325 * IPython/Extensions/InterpreterPasteInput.py (prefilter_paste):
319 Add support for pasting not only lines that start with '>>>', but
326 Add support for pasting not only lines that start with '>>>', but
320 also with ' >>>'. That is, arbitrary whitespace can now precede
327 also with ' >>>'. That is, arbitrary whitespace can now precede
321 the prompts. This makes the system useful for pasting doctests
328 the prompts. This makes the system useful for pasting doctests
322 from docstrings back into a normal session.
329 from docstrings back into a normal session.
323
330
324 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu>
331 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu>
325
332
326 * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in
333 * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in
327 r1357, which had killed multiple invocations of an embedded
334 r1357, which had killed multiple invocations of an embedded
328 ipython (this means that example-embed has been broken for over 1
335 ipython (this means that example-embed has been broken for over 1
329 year!!!). Rather than possibly breaking the batch stuff for which
336 year!!!). Rather than possibly breaking the batch stuff for which
330 the code in iplib.py/interact was introduced, I worked around the
337 the code in iplib.py/interact was introduced, I worked around the
331 problem in the embedding class in Shell.py. We really need a
338 problem in the embedding class in Shell.py. We really need a
332 bloody test suite for this code, I'm sick of finding stuff that
339 bloody test suite for this code, I'm sick of finding stuff that
333 used to work breaking left and right every time I use an old
340 used to work breaking left and right every time I use an old
334 feature I hadn't touched in a few months.
341 feature I hadn't touched in a few months.
335 (kill_embedded): Add a new magic that only shows up in embedded
342 (kill_embedded): Add a new magic that only shows up in embedded
336 mode, to allow users to permanently deactivate an embedded instance.
343 mode, to allow users to permanently deactivate an embedded instance.
337
344
338 2007-08-01 Ville Vainio <vivainio@gmail.com>
345 2007-08-01 Ville Vainio <vivainio@gmail.com>
339
346
340 * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw
347 * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw
341 history gets out of sync on runlines (e.g. when running macros).
348 history gets out of sync on runlines (e.g. when running macros).
342
349
343 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu>
350 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu>
344
351
345 * IPython/Magic.py (magic_colors): fix win32-related error message
352 * IPython/Magic.py (magic_colors): fix win32-related error message
346 that could appear under *nix when readline was missing. Patch by
353 that could appear under *nix when readline was missing. Patch by
347 Scott Jackson, closes #175.
354 Scott Jackson, closes #175.
348
355
349 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
356 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
350
357
351 * IPython/Extensions/ipy_traits_completer.py: Add a new custom
358 * IPython/Extensions/ipy_traits_completer.py: Add a new custom
352 completer that it traits-aware, so that traits objects don't show
359 completer that it traits-aware, so that traits objects don't show
353 all of their internal attributes all the time.
360 all of their internal attributes all the time.
354
361
355 * IPython/genutils.py (dir2): moved this code from inside
362 * IPython/genutils.py (dir2): moved this code from inside
356 completer.py to expose it publicly, so I could use it in the
363 completer.py to expose it publicly, so I could use it in the
357 wildcards bugfix.
364 wildcards bugfix.
358
365
359 * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by
366 * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by
360 Stefan with Traits.
367 Stefan with Traits.
361
368
362 * IPython/completer.py (Completer.attr_matches): change internal
369 * IPython/completer.py (Completer.attr_matches): change internal
363 var name from 'object' to 'obj', since 'object' is now a builtin
370 var name from 'object' to 'obj', since 'object' is now a builtin
364 and this can lead to weird bugs if reusing this code elsewhere.
371 and this can lead to weird bugs if reusing this code elsewhere.
365
372
366 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu>
373 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu>
367
374
368 * IPython/OInspect.py (Inspector.pinfo): fix small glitches in
375 * IPython/OInspect.py (Inspector.pinfo): fix small glitches in
369 'foo?' and update the code to prevent printing of default
376 'foo?' and update the code to prevent printing of default
370 docstrings that started appearing after I added support for
377 docstrings that started appearing after I added support for
371 new-style classes. The approach I'm using isn't ideal (I just
378 new-style classes. The approach I'm using isn't ideal (I just
372 special-case those strings) but I'm not sure how to more robustly
379 special-case those strings) but I'm not sure how to more robustly
373 differentiate between truly user-written strings and Python's
380 differentiate between truly user-written strings and Python's
374 automatic ones.
381 automatic ones.
375
382
376 2007-07-09 Ville Vainio <vivainio@gmail.com>
383 2007-07-09 Ville Vainio <vivainio@gmail.com>
377
384
378 * completer.py: Applied Matthew Neeley's patch:
385 * completer.py: Applied Matthew Neeley's patch:
379 Dynamic attributes from trait_names and _getAttributeNames are added
386 Dynamic attributes from trait_names and _getAttributeNames are added
380 to the list of tab completions, but when this happens, the attribute
387 to the list of tab completions, but when this happens, the attribute
381 list is turned into a set, so the attributes are unordered when
388 list is turned into a set, so the attributes are unordered when
382 printed, which makes it hard to find the right completion. This patch
389 printed, which makes it hard to find the right completion. This patch
383 turns this set back into a list and sort it.
390 turns this set back into a list and sort it.
384
391
385 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu>
392 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu>
386
393
387 * IPython/OInspect.py (Inspector.pinfo): Add support for new-style
394 * IPython/OInspect.py (Inspector.pinfo): Add support for new-style
388 classes in various inspector functions.
395 classes in various inspector functions.
389
396
390 2007-06-28 Ville Vainio <vivainio@gmail.com>
397 2007-06-28 Ville Vainio <vivainio@gmail.com>
391
398
392 * shadowns.py, iplib.py, ipapi.py, OInspect.py:
399 * shadowns.py, iplib.py, ipapi.py, OInspect.py:
393 Implement "shadow" namespace, and callable aliases that reside there.
400 Implement "shadow" namespace, and callable aliases that reside there.
394 Use them by:
401 Use them by:
395
402
396 _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc
403 _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc
397
404
398 foo hello world
405 foo hello world
399 (gets translated to:)
406 (gets translated to:)
400 _sh.foo(r"""hello world""")
407 _sh.foo(r"""hello world""")
401
408
402 In practice, this kind of alias can take the role of a magic function
409 In practice, this kind of alias can take the role of a magic function
403
410
404 * New generic inspect_object, called on obj? and obj??
411 * New generic inspect_object, called on obj? and obj??
405
412
406 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu>
413 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu>
407
414
408 * IPython/ultraTB.py (findsource): fix a problem with
415 * IPython/ultraTB.py (findsource): fix a problem with
409 inspect.getfile that can cause crashes during traceback construction.
416 inspect.getfile that can cause crashes during traceback construction.
410
417
411 2007-06-14 Ville Vainio <vivainio@gmail.com>
418 2007-06-14 Ville Vainio <vivainio@gmail.com>
412
419
413 * iplib.py (handle_auto): Try to use ascii for printing "--->"
420 * iplib.py (handle_auto): Try to use ascii for printing "--->"
414 autocall rewrite indication, becausesometimes unicode fails to print
421 autocall rewrite indication, becausesometimes unicode fails to print
415 properly (and you get ' - - - '). Use plain uncoloured ---> for
422 properly (and you get ' - - - '). Use plain uncoloured ---> for
416 unicode.
423 unicode.
417
424
418 * shadow history. Usable through "%hist -g <pat>" and "%rep 0123".
425 * shadow history. Usable through "%hist -g <pat>" and "%rep 0123".
419
426
420 . pickleshare 'hash' commands (hget, hset, hcompress,
427 . pickleshare 'hash' commands (hget, hset, hcompress,
421 hdict) for efficient shadow history storage.
428 hdict) for efficient shadow history storage.
422
429
423 2007-06-13 Ville Vainio <vivainio@gmail.com>
430 2007-06-13 Ville Vainio <vivainio@gmail.com>
424
431
425 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
432 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
426 Added kw arg 'interactive', tell whether vars should be visible
433 Added kw arg 'interactive', tell whether vars should be visible
427 with %whos.
434 with %whos.
428
435
429 2007-06-11 Ville Vainio <vivainio@gmail.com>
436 2007-06-11 Ville Vainio <vivainio@gmail.com>
430
437
431 * pspersistence.py, Magic.py, iplib.py: directory history now saved
438 * pspersistence.py, Magic.py, iplib.py: directory history now saved
432 to db
439 to db
433
440
434 * iplib.py: "ipython -c <cmd>" now passes the command through prefilter.
441 * iplib.py: "ipython -c <cmd>" now passes the command through prefilter.
435 Also, it exits IPython immediately after evaluating the command (just like
442 Also, it exits IPython immediately after evaluating the command (just like
436 std python)
443 std python)
437
444
438 2007-06-05 Walter Doerwald <walter@livinglogic.de>
445 2007-06-05 Walter Doerwald <walter@livinglogic.de>
439
446
440 * IPython/Extensions/ipipe.py: Added a new table icap, which executes a
447 * IPython/Extensions/ipipe.py: Added a new table icap, which executes a
441 Python string and captures the output. (Idea and original patch by
448 Python string and captures the output. (Idea and original patch by
442 Stefan van der Walt)
449 Stefan van der Walt)
443
450
444 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu>
451 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu>
445
452
446 * IPython/ultraTB.py (VerboseTB.text): update printing of
453 * IPython/ultraTB.py (VerboseTB.text): update printing of
447 exception types for Python 2.5 (now all exceptions in the stdlib
454 exception types for Python 2.5 (now all exceptions in the stdlib
448 are new-style classes).
455 are new-style classes).
449
456
450 2007-05-31 Walter Doerwald <walter@livinglogic.de>
457 2007-05-31 Walter Doerwald <walter@livinglogic.de>
451
458
452 * IPython/Extensions/igrid.py: Add new commands refresh and
459 * IPython/Extensions/igrid.py: Add new commands refresh and
453 refresh_timer (mapped to "R"/"F5" and to the menu) which restarts
460 refresh_timer (mapped to "R"/"F5" and to the menu) which restarts
454 the iterator once (refresh) or after every x seconds (refresh_timer).
461 the iterator once (refresh) or after every x seconds (refresh_timer).
455 Add a working implementation of "searchexpression", where the text
462 Add a working implementation of "searchexpression", where the text
456 entered is not the text to search for, but an expression that must
463 entered is not the text to search for, but an expression that must
457 be true. Added display of shortcuts to the menu. Added commands "pickinput"
464 be true. Added display of shortcuts to the menu. Added commands "pickinput"
458 and "pickinputattr" that put the object or attribute under the cursor
465 and "pickinputattr" that put the object or attribute under the cursor
459 in the input line. Split the statusbar to be able to display the currently
466 in the input line. Split the statusbar to be able to display the currently
460 active refresh interval. (Patch by Nik Tautenhahn)
467 active refresh interval. (Patch by Nik Tautenhahn)
461
468
462 2007-05-29 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
469 2007-05-29 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
463
470
464 * fixing set_term_title to use ctypes as default
471 * fixing set_term_title to use ctypes as default
465
472
466 * fixing set_term_title fallback to work when curent dir
473 * fixing set_term_title fallback to work when curent dir
467 is on a windows network share
474 is on a windows network share
468
475
469 2007-05-28 Ville Vainio <vivainio@gmail.com>
476 2007-05-28 Ville Vainio <vivainio@gmail.com>
470
477
471 * %cpaste: strip + with > from left (diffs).
478 * %cpaste: strip + with > from left (diffs).
472
479
473 * iplib.py: Fix crash when readline not installed
480 * iplib.py: Fix crash when readline not installed
474
481
475 2007-05-26 Ville Vainio <vivainio@gmail.com>
482 2007-05-26 Ville Vainio <vivainio@gmail.com>
476
483
477 * generics.py: intruduce easy to extend result_display generic
484 * generics.py: intruduce easy to extend result_display generic
478 function (using simplegeneric.py).
485 function (using simplegeneric.py).
479
486
480 * Fixed the append functionality of %set.
487 * Fixed the append functionality of %set.
481
488
482 2007-05-25 Ville Vainio <vivainio@gmail.com>
489 2007-05-25 Ville Vainio <vivainio@gmail.com>
483
490
484 * New magic: %rep (fetch / run old commands from history)
491 * New magic: %rep (fetch / run old commands from history)
485
492
486 * New extension: mglob (%mglob magic), for powerful glob / find /filter
493 * New extension: mglob (%mglob magic), for powerful glob / find /filter
487 like functionality
494 like functionality
488
495
489 % maghistory.py: %hist -g PATTERM greps the history for pattern
496 % maghistory.py: %hist -g PATTERM greps the history for pattern
490
497
491 2007-05-24 Walter Doerwald <walter@livinglogic.de>
498 2007-05-24 Walter Doerwald <walter@livinglogic.de>
492
499
493 * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to
500 * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to
494 browse the IPython input history
501 browse the IPython input history
495
502
496 * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput
503 * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput
497 (mapped to "i") can be used to put the object under the curser in the input
504 (mapped to "i") can be used to put the object under the curser in the input
498 line. pickinputattr (mapped to "I") does the same for the attribute under
505 line. pickinputattr (mapped to "I") does the same for the attribute under
499 the cursor.
506 the cursor.
500
507
501 2007-05-24 Ville Vainio <vivainio@gmail.com>
508 2007-05-24 Ville Vainio <vivainio@gmail.com>
502
509
503 * Grand magic cleansing (changeset [2380]):
510 * Grand magic cleansing (changeset [2380]):
504
511
505 * Introduce ipy_legacy.py where the following magics were
512 * Introduce ipy_legacy.py where the following magics were
506 moved:
513 moved:
507
514
508 pdef pdoc psource pfile rehash dhist Quit p r automagic autocall
515 pdef pdoc psource pfile rehash dhist Quit p r automagic autocall
509
516
510 If you need them, either use default profile or "import ipy_legacy"
517 If you need them, either use default profile or "import ipy_legacy"
511 in your ipy_user_conf.py
518 in your ipy_user_conf.py
512
519
513 * Move sh and scipy profile to Extensions from UserConfig. this implies
520 * Move sh and scipy profile to Extensions from UserConfig. this implies
514 you should not edit them, but you don't need to run %upgrade when
521 you should not edit them, but you don't need to run %upgrade when
515 upgrading IPython anymore.
522 upgrading IPython anymore.
516
523
517 * %hist/%history now operates in "raw" mode by default. To get the old
524 * %hist/%history now operates in "raw" mode by default. To get the old
518 behaviour, run '%hist -n' (native mode).
525 behaviour, run '%hist -n' (native mode).
519
526
520 * split ipy_stock_completers.py to ipy_stock_completers.py and
527 * split ipy_stock_completers.py to ipy_stock_completers.py and
521 ipy_app_completers.py. Stock completers (%cd, import, %run) are now
528 ipy_app_completers.py. Stock completers (%cd, import, %run) are now
522 installed as default.
529 installed as default.
523
530
524 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
531 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
525 handling.
532 handling.
526
533
527 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
534 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
528 input if readline is available.
535 input if readline is available.
529
536
530 2007-05-23 Ville Vainio <vivainio@gmail.com>
537 2007-05-23 Ville Vainio <vivainio@gmail.com>
531
538
532 * macro.py: %store uses __getstate__ properly
539 * macro.py: %store uses __getstate__ properly
533
540
534 * exesetup.py: added new setup script for creating
541 * exesetup.py: added new setup script for creating
535 standalone IPython executables with py2exe (i.e.
542 standalone IPython executables with py2exe (i.e.
536 no python installation required).
543 no python installation required).
537
544
538 * Removed ipythonrc-scipy, ipy_profile_scipy.py takes
545 * Removed ipythonrc-scipy, ipy_profile_scipy.py takes
539 its place.
546 its place.
540
547
541 * rlineimpl.py, genutils.py (get_home_dir): py2exe support
548 * rlineimpl.py, genutils.py (get_home_dir): py2exe support
542
549
543 2007-05-21 Ville Vainio <vivainio@gmail.com>
550 2007-05-21 Ville Vainio <vivainio@gmail.com>
544
551
545 * platutil_win32.py (set_term_title): handle
552 * platutil_win32.py (set_term_title): handle
546 failure of 'title' system call properly.
553 failure of 'title' system call properly.
547
554
548 2007-05-17 Walter Doerwald <walter@livinglogic.de>
555 2007-05-17 Walter Doerwald <walter@livinglogic.de>
549
556
550 * IPython/Extensions/ipipe.py: Fix xrepr for ifiles.
557 * IPython/Extensions/ipipe.py: Fix xrepr for ifiles.
551 (Bug detected by Paul Mueller).
558 (Bug detected by Paul Mueller).
552
559
553 2007-05-16 Ville Vainio <vivainio@gmail.com>
560 2007-05-16 Ville Vainio <vivainio@gmail.com>
554
561
555 * ipy_profile_sci.py, ipython_win_post_install.py: Create
562 * ipy_profile_sci.py, ipython_win_post_install.py: Create
556 new "sci" profile, effectively a modern version of the old
563 new "sci" profile, effectively a modern version of the old
557 "scipy" profile (which is now slated for deprecation).
564 "scipy" profile (which is now slated for deprecation).
558
565
559 2007-05-15 Ville Vainio <vivainio@gmail.com>
566 2007-05-15 Ville Vainio <vivainio@gmail.com>
560
567
561 * pycolorize.py, pycolor.1: Paul Mueller's patches that
568 * pycolorize.py, pycolor.1: Paul Mueller's patches that
562 make pycolorize read input from stdin when run without arguments.
569 make pycolorize read input from stdin when run without arguments.
563
570
564 * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155
571 * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155
565
572
566 * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import
573 * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import
567 it in sh profile (instead of ipy_system_conf.py).
574 it in sh profile (instead of ipy_system_conf.py).
568
575
569 * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command
576 * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command
570 aliases are now lower case on windows (MyCommand.exe => mycommand).
577 aliases are now lower case on windows (MyCommand.exe => mycommand).
571
578
572 * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul.
579 * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul.
573 Macros are now callable objects that inherit from ipapi.IPyAutocall,
580 Macros are now callable objects that inherit from ipapi.IPyAutocall,
574 i.e. get autocalled regardless of system autocall setting.
581 i.e. get autocalled regardless of system autocall setting.
575
582
576 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
583 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
577
584
578 * IPython/rlineimpl.py: check for clear_history in readline and
585 * IPython/rlineimpl.py: check for clear_history in readline and
579 make it a dummy no-op if not available. This function isn't
586 make it a dummy no-op if not available. This function isn't
580 guaranteed to be in the API and appeared in Python 2.4, so we need
587 guaranteed to be in the API and appeared in Python 2.4, so we need
581 to check it ourselves. Also, clean up this file quite a bit.
588 to check it ourselves. Also, clean up this file quite a bit.
582
589
583 * ipython.1: update man page and full manual with information
590 * ipython.1: update man page and full manual with information
584 about threads (remove outdated warning). Closes #151.
591 about threads (remove outdated warning). Closes #151.
585
592
586 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu>
593 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu>
587
594
588 * IPython/Extensions/ipy_constants.py: Add Gael's constants module
595 * IPython/Extensions/ipy_constants.py: Add Gael's constants module
589 in trunk (note that this made it into the 0.8.1 release already,
596 in trunk (note that this made it into the 0.8.1 release already,
590 but the changelogs didn't get coordinated). Many thanks to Gael
597 but the changelogs didn't get coordinated). Many thanks to Gael
591 Varoquaux <gael.varoquaux-AT-normalesup.org>
598 Varoquaux <gael.varoquaux-AT-normalesup.org>
592
599
593 2007-05-09 *** Released version 0.8.1
600 2007-05-09 *** Released version 0.8.1
594
601
595 2007-05-10 Walter Doerwald <walter@livinglogic.de>
602 2007-05-10 Walter Doerwald <walter@livinglogic.de>
596
603
597 * IPython/Extensions/igrid.py: Incorporate html help into
604 * IPython/Extensions/igrid.py: Incorporate html help into
598 the module, so we don't have to search for the file.
605 the module, so we don't have to search for the file.
599
606
600 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu>
607 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu>
601
608
602 * test/test_irunner.py (RunnerTestCase._test_runner): Close #147.
609 * test/test_irunner.py (RunnerTestCase._test_runner): Close #147.
603
610
604 2007-04-30 Ville Vainio <vivainio@gmail.com>
611 2007-04-30 Ville Vainio <vivainio@gmail.com>
605
612
606 * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the
613 * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the
607 user has illegal (non-ascii) home directory name
614 user has illegal (non-ascii) home directory name
608
615
609 2007-04-27 Ville Vainio <vivainio@gmail.com>
616 2007-04-27 Ville Vainio <vivainio@gmail.com>
610
617
611 * platutils_win32.py: implement set_term_title for windows
618 * platutils_win32.py: implement set_term_title for windows
612
619
613 * Update version number
620 * Update version number
614
621
615 * ipy_profile_sh.py: more informative prompt (2 dir levels)
622 * ipy_profile_sh.py: more informative prompt (2 dir levels)
616
623
617 2007-04-26 Walter Doerwald <walter@livinglogic.de>
624 2007-04-26 Walter Doerwald <walter@livinglogic.de>
618
625
619 * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced
626 * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced
620 when the igrid input raised an exception. (Patch by Nik Tautenhahn,
627 when the igrid input raised an exception. (Patch by Nik Tautenhahn,
621 bug discovered by Ville).
628 bug discovered by Ville).
622
629
623 2007-04-26 Ville Vainio <vivainio@gmail.com>
630 2007-04-26 Ville Vainio <vivainio@gmail.com>
624
631
625 * Extensions/ipy_completers.py: Olivier's module completer now
632 * Extensions/ipy_completers.py: Olivier's module completer now
626 saves the list of root modules if it takes > 4 secs on the first run.
633 saves the list of root modules if it takes > 4 secs on the first run.
627
634
628 * Magic.py (%rehashx): %rehashx now clears the completer cache
635 * Magic.py (%rehashx): %rehashx now clears the completer cache
629
636
630
637
631 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu>
638 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu>
632
639
633 * ipython.el: fix incorrect color scheme, reported by Stefan.
640 * ipython.el: fix incorrect color scheme, reported by Stefan.
634 Closes #149.
641 Closes #149.
635
642
636 * IPython/PyColorize.py (Parser.format2): fix state-handling
643 * IPython/PyColorize.py (Parser.format2): fix state-handling
637 logic. I still don't like how that code handles state, but at
644 logic. I still don't like how that code handles state, but at
638 least now it should be correct, if inelegant. Closes #146.
645 least now it should be correct, if inelegant. Closes #146.
639
646
640 2007-04-25 Ville Vainio <vivainio@gmail.com>
647 2007-04-25 Ville Vainio <vivainio@gmail.com>
641
648
642 * Extensions/ipy_which.py: added extension for %which magic, works
649 * Extensions/ipy_which.py: added extension for %which magic, works
643 a lot like unix 'which' but also finds and expands aliases, and
650 a lot like unix 'which' but also finds and expands aliases, and
644 allows wildcards.
651 allows wildcards.
645
652
646 * ipapi.py (expand_alias): Now actually *return* the expanded alias,
653 * ipapi.py (expand_alias): Now actually *return* the expanded alias,
647 as opposed to returning nothing.
654 as opposed to returning nothing.
648
655
649 * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import
656 * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import
650 ipy_stock_completers on default profile, do import on sh profile.
657 ipy_stock_completers on default profile, do import on sh profile.
651
658
652 2007-04-22 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
659 2007-04-22 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
653
660
654 * Fix bug in iplib.py/safe_execfile when launching ipython with a script
661 * Fix bug in iplib.py/safe_execfile when launching ipython with a script
655 like ipython.py foo.py which raised a IndexError.
662 like ipython.py foo.py which raised a IndexError.
656
663
657 2007-04-21 Ville Vainio <vivainio@gmail.com>
664 2007-04-21 Ville Vainio <vivainio@gmail.com>
658
665
659 * Extensions/ipy_extutil.py: added extension to manage other ipython
666 * Extensions/ipy_extutil.py: added extension to manage other ipython
660 extensions. Now only supports 'ls' == list extensions.
667 extensions. Now only supports 'ls' == list extensions.
661
668
662 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
669 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
663
670
664 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
671 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
665 would prevent use of the exception system outside of a running
672 would prevent use of the exception system outside of a running
666 IPython instance.
673 IPython instance.
667
674
668 2007-04-20 Ville Vainio <vivainio@gmail.com>
675 2007-04-20 Ville Vainio <vivainio@gmail.com>
669
676
670 * Extensions/ipy_render.py: added extension for easy
677 * Extensions/ipy_render.py: added extension for easy
671 interactive text template rendering (to clipboard). Uses Ka-Ping Yee's
678 interactive text template rendering (to clipboard). Uses Ka-Ping Yee's
672 'Iptl' template notation,
679 'Iptl' template notation,
673
680
674 * Extensions/ipy_completers.py: introduced Olivier Lauzanne's
681 * Extensions/ipy_completers.py: introduced Olivier Lauzanne's
675 safer & faster 'import' completer.
682 safer & faster 'import' completer.
676
683
677 * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value)
684 * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value)
678 and _ip.defalias(name, command).
685 and _ip.defalias(name, command).
679
686
680 * Extensions/ipy_exportdb.py: New extension for exporting all the
687 * Extensions/ipy_exportdb.py: New extension for exporting all the
681 %store'd data in a portable format (normal ipapi calls like
688 %store'd data in a portable format (normal ipapi calls like
682 defmacro() etc.)
689 defmacro() etc.)
683
690
684 2007-04-19 Ville Vainio <vivainio@gmail.com>
691 2007-04-19 Ville Vainio <vivainio@gmail.com>
685
692
686 * upgrade_dir.py: skip junk files like *.pyc
693 * upgrade_dir.py: skip junk files like *.pyc
687
694
688 * Release.py: version number to 0.8.1
695 * Release.py: version number to 0.8.1
689
696
690 2007-04-18 Ville Vainio <vivainio@gmail.com>
697 2007-04-18 Ville Vainio <vivainio@gmail.com>
691
698
692 * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1
699 * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1
693 and later on win32.
700 and later on win32.
694
701
695 2007-04-16 Ville Vainio <vivainio@gmail.com>
702 2007-04-16 Ville Vainio <vivainio@gmail.com>
696
703
697 * iplib.py (showtraceback): Do not crash when running w/o readline.
704 * iplib.py (showtraceback): Do not crash when running w/o readline.
698
705
699 2007-04-12 Walter Doerwald <walter@livinglogic.de>
706 2007-04-12 Walter Doerwald <walter@livinglogic.de>
700
707
701 * IPython/Extensions/ipipe.py: (ils) Directoy listings are now
708 * IPython/Extensions/ipipe.py: (ils) Directoy listings are now
702 sorted (case sensitive with files and dirs mixed).
709 sorted (case sensitive with files and dirs mixed).
703
710
704 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu>
711 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu>
705
712
706 * IPython/Release.py (version): Open trunk for 0.8.1 development.
713 * IPython/Release.py (version): Open trunk for 0.8.1 development.
707
714
708 2007-04-10 *** Released version 0.8.0
715 2007-04-10 *** Released version 0.8.0
709
716
710 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
717 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
711
718
712 * Tag 0.8.0 for release.
719 * Tag 0.8.0 for release.
713
720
714 * IPython/iplib.py (reloadhist): add API function to cleanly
721 * IPython/iplib.py (reloadhist): add API function to cleanly
715 reload the readline history, which was growing inappropriately on
722 reload the readline history, which was growing inappropriately on
716 every %run call.
723 every %run call.
717
724
718 * win32_manual_post_install.py (run): apply last part of Nicolas
725 * win32_manual_post_install.py (run): apply last part of Nicolas
719 Pernetty's patch (I'd accidentally applied it in a different
726 Pernetty's patch (I'd accidentally applied it in a different
720 directory and this particular file didn't get patched).
727 directory and this particular file didn't get patched).
721
728
722 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
729 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
723
730
724 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
731 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
725 find the main thread id and use the proper API call. Thanks to
732 find the main thread id and use the proper API call. Thanks to
726 Stefan for the fix.
733 Stefan for the fix.
727
734
728 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
735 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
729 unit tests to reflect fixed ticket #52, and add more tests sent by
736 unit tests to reflect fixed ticket #52, and add more tests sent by
730 him.
737 him.
731
738
732 * IPython/iplib.py (raw_input): restore the readline completer
739 * IPython/iplib.py (raw_input): restore the readline completer
733 state on every input, in case third-party code messed it up.
740 state on every input, in case third-party code messed it up.
734 (_prefilter): revert recent addition of early-escape checks which
741 (_prefilter): revert recent addition of early-escape checks which
735 prevent many valid alias calls from working.
742 prevent many valid alias calls from working.
736
743
737 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
744 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
738 flag for sigint handler so we don't run a full signal() call on
745 flag for sigint handler so we don't run a full signal() call on
739 each runcode access.
746 each runcode access.
740
747
741 * IPython/Magic.py (magic_whos): small improvement to diagnostic
748 * IPython/Magic.py (magic_whos): small improvement to diagnostic
742 message.
749 message.
743
750
744 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
751 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
745
752
746 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
753 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
747 asynchronous exceptions working, i.e., Ctrl-C can actually
754 asynchronous exceptions working, i.e., Ctrl-C can actually
748 interrupt long-running code in the multithreaded shells.
755 interrupt long-running code in the multithreaded shells.
749
756
750 This is using Tomer Filiba's great ctypes-based trick:
757 This is using Tomer Filiba's great ctypes-based trick:
751 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
758 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
752 this in the past, but hadn't been able to make it work before. So
759 this in the past, but hadn't been able to make it work before. So
753 far it looks like it's actually running, but this needs more
760 far it looks like it's actually running, but this needs more
754 testing. If it really works, I'll be *very* happy, and we'll owe
761 testing. If it really works, I'll be *very* happy, and we'll owe
755 a huge thank you to Tomer. My current implementation is ugly,
762 a huge thank you to Tomer. My current implementation is ugly,
756 hackish and uses nasty globals, but I don't want to try and clean
763 hackish and uses nasty globals, but I don't want to try and clean
757 anything up until we know if it actually works.
764 anything up until we know if it actually works.
758
765
759 NOTE: this feature needs ctypes to work. ctypes is included in
766 NOTE: this feature needs ctypes to work. ctypes is included in
760 Python2.5, but 2.4 users will need to manually install it. This
767 Python2.5, but 2.4 users will need to manually install it. This
761 feature makes multi-threaded shells so much more usable that it's
768 feature makes multi-threaded shells so much more usable that it's
762 a minor price to pay (ctypes is very easy to install, already a
769 a minor price to pay (ctypes is very easy to install, already a
763 requirement for win32 and available in major linux distros).
770 requirement for win32 and available in major linux distros).
764
771
765 2007-04-04 Ville Vainio <vivainio@gmail.com>
772 2007-04-04 Ville Vainio <vivainio@gmail.com>
766
773
767 * Extensions/ipy_completers.py, ipy_stock_completers.py:
774 * Extensions/ipy_completers.py, ipy_stock_completers.py:
768 Moved implementations of 'bundled' completers to ipy_completers.py,
775 Moved implementations of 'bundled' completers to ipy_completers.py,
769 they are only enabled in ipy_stock_completers.py.
776 they are only enabled in ipy_stock_completers.py.
770
777
771 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
778 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
772
779
773 * IPython/PyColorize.py (Parser.format2): Fix identation of
780 * IPython/PyColorize.py (Parser.format2): Fix identation of
774 colorzied output and return early if color scheme is NoColor, to
781 colorzied output and return early if color scheme is NoColor, to
775 avoid unnecessary and expensive tokenization. Closes #131.
782 avoid unnecessary and expensive tokenization. Closes #131.
776
783
777 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
784 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
778
785
779 * IPython/Debugger.py: disable the use of pydb version 1.17. It
786 * IPython/Debugger.py: disable the use of pydb version 1.17. It
780 has a critical bug (a missing import that makes post-mortem not
787 has a critical bug (a missing import that makes post-mortem not
781 work at all). Unfortunately as of this time, this is the version
788 work at all). Unfortunately as of this time, this is the version
782 shipped with Ubuntu Edgy, so quite a few people have this one. I
789 shipped with Ubuntu Edgy, so quite a few people have this one. I
783 hope Edgy will update to a more recent package.
790 hope Edgy will update to a more recent package.
784
791
785 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
792 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
786
793
787 * IPython/iplib.py (_prefilter): close #52, second part of a patch
794 * IPython/iplib.py (_prefilter): close #52, second part of a patch
788 set by Stefan (only the first part had been applied before).
795 set by Stefan (only the first part had been applied before).
789
796
790 * IPython/Extensions/ipy_stock_completers.py (module_completer):
797 * IPython/Extensions/ipy_stock_completers.py (module_completer):
791 remove usage of the dangerous pkgutil.walk_packages(). See
798 remove usage of the dangerous pkgutil.walk_packages(). See
792 details in comments left in the code.
799 details in comments left in the code.
793
800
794 * IPython/Magic.py (magic_whos): add support for numpy arrays
801 * IPython/Magic.py (magic_whos): add support for numpy arrays
795 similar to what we had for Numeric.
802 similar to what we had for Numeric.
796
803
797 * IPython/completer.py (IPCompleter.complete): extend the
804 * IPython/completer.py (IPCompleter.complete): extend the
798 complete() call API to support completions by other mechanisms
805 complete() call API to support completions by other mechanisms
799 than readline. Closes #109.
806 than readline. Closes #109.
800
807
801 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
808 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
802 protect against a bug in Python's execfile(). Closes #123.
809 protect against a bug in Python's execfile(). Closes #123.
803
810
804 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
811 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
805
812
806 * IPython/iplib.py (split_user_input): ensure that when splitting
813 * IPython/iplib.py (split_user_input): ensure that when splitting
807 user input, the part that can be treated as a python name is pure
814 user input, the part that can be treated as a python name is pure
808 ascii (Python identifiers MUST be pure ascii). Part of the
815 ascii (Python identifiers MUST be pure ascii). Part of the
809 ongoing Unicode support work.
816 ongoing Unicode support work.
810
817
811 * IPython/Prompts.py (prompt_specials_color): Add \N for the
818 * IPython/Prompts.py (prompt_specials_color): Add \N for the
812 actual prompt number, without any coloring. This allows users to
819 actual prompt number, without any coloring. This allows users to
813 produce numbered prompts with their own colors. Added after a
820 produce numbered prompts with their own colors. Added after a
814 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
821 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
815
822
816 2007-03-31 Walter Doerwald <walter@livinglogic.de>
823 2007-03-31 Walter Doerwald <walter@livinglogic.de>
817
824
818 * IPython/Extensions/igrid.py: Map the return key
825 * IPython/Extensions/igrid.py: Map the return key
819 to enter() and shift-return to enterattr().
826 to enter() and shift-return to enterattr().
820
827
821 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
828 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
822
829
823 * IPython/Magic.py (magic_psearch): add unicode support by
830 * IPython/Magic.py (magic_psearch): add unicode support by
824 encoding to ascii the input, since this routine also only deals
831 encoding to ascii the input, since this routine also only deals
825 with valid Python names. Fixes a bug reported by Stefan.
832 with valid Python names. Fixes a bug reported by Stefan.
826
833
827 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
834 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
828
835
829 * IPython/Magic.py (_inspect): convert unicode input into ascii
836 * IPython/Magic.py (_inspect): convert unicode input into ascii
830 before trying to evaluate it as a Python identifier. This fixes a
837 before trying to evaluate it as a Python identifier. This fixes a
831 problem that the new unicode support had introduced when analyzing
838 problem that the new unicode support had introduced when analyzing
832 long definition lines for functions.
839 long definition lines for functions.
833
840
834 2007-03-24 Walter Doerwald <walter@livinglogic.de>
841 2007-03-24 Walter Doerwald <walter@livinglogic.de>
835
842
836 * IPython/Extensions/igrid.py: Fix picking. Using
843 * IPython/Extensions/igrid.py: Fix picking. Using
837 igrid with wxPython 2.6 and -wthread should work now.
844 igrid with wxPython 2.6 and -wthread should work now.
838 igrid.display() simply tries to create a frame without
845 igrid.display() simply tries to create a frame without
839 an application. Only if this fails an application is created.
846 an application. Only if this fails an application is created.
840
847
841 2007-03-23 Walter Doerwald <walter@livinglogic.de>
848 2007-03-23 Walter Doerwald <walter@livinglogic.de>
842
849
843 * IPython/Extensions/path.py: Updated to version 2.2.
850 * IPython/Extensions/path.py: Updated to version 2.2.
844
851
845 2007-03-23 Ville Vainio <vivainio@gmail.com>
852 2007-03-23 Ville Vainio <vivainio@gmail.com>
846
853
847 * iplib.py: recursive alias expansion now works better, so that
854 * iplib.py: recursive alias expansion now works better, so that
848 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
855 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
849 doesn't trip up the process, if 'd' has been aliased to 'ls'.
856 doesn't trip up the process, if 'd' has been aliased to 'ls'.
850
857
851 * Extensions/ipy_gnuglobal.py added, provides %global magic
858 * Extensions/ipy_gnuglobal.py added, provides %global magic
852 for users of http://www.gnu.org/software/global
859 for users of http://www.gnu.org/software/global
853
860
854 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
861 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
855 Closes #52. Patch by Stefan van der Walt.
862 Closes #52. Patch by Stefan van der Walt.
856
863
857 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
864 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
858
865
859 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
866 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
860 respect the __file__ attribute when using %run. Thanks to a bug
867 respect the __file__ attribute when using %run. Thanks to a bug
861 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
868 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
862
869
863 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
870 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
864
871
865 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
872 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
866 input. Patch sent by Stefan.
873 input. Patch sent by Stefan.
867
874
868 2007-03-20 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
875 2007-03-20 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
869 * IPython/Extensions/ipy_stock_completer.py
876 * IPython/Extensions/ipy_stock_completer.py
870 shlex_split, fix bug in shlex_split. len function
877 shlex_split, fix bug in shlex_split. len function
871 call was missing an if statement. Caused shlex_split to
878 call was missing an if statement. Caused shlex_split to
872 sometimes return "" as last element.
879 sometimes return "" as last element.
873
880
874 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
881 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
875
882
876 * IPython/completer.py
883 * IPython/completer.py
877 (IPCompleter.file_matches.single_dir_expand): fix a problem
884 (IPCompleter.file_matches.single_dir_expand): fix a problem
878 reported by Stefan, where directories containign a single subdir
885 reported by Stefan, where directories containign a single subdir
879 would be completed too early.
886 would be completed too early.
880
887
881 * IPython/Shell.py (_load_pylab): Make the execution of 'from
888 * IPython/Shell.py (_load_pylab): Make the execution of 'from
882 pylab import *' when -pylab is given be optional. A new flag,
889 pylab import *' when -pylab is given be optional. A new flag,
883 pylab_import_all controls this behavior, the default is True for
890 pylab_import_all controls this behavior, the default is True for
884 backwards compatibility.
891 backwards compatibility.
885
892
886 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
893 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
887 modified) R. Bernstein's patch for fully syntax highlighted
894 modified) R. Bernstein's patch for fully syntax highlighted
888 tracebacks. The functionality is also available under ultraTB for
895 tracebacks. The functionality is also available under ultraTB for
889 non-ipython users (someone using ultraTB but outside an ipython
896 non-ipython users (someone using ultraTB but outside an ipython
890 session). They can select the color scheme by setting the
897 session). They can select the color scheme by setting the
891 module-level global DEFAULT_SCHEME. The highlight functionality
898 module-level global DEFAULT_SCHEME. The highlight functionality
892 also works when debugging.
899 also works when debugging.
893
900
894 * IPython/genutils.py (IOStream.close): small patch by
901 * IPython/genutils.py (IOStream.close): small patch by
895 R. Bernstein for improved pydb support.
902 R. Bernstein for improved pydb support.
896
903
897 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
904 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
898 DaveS <davls@telus.net> to improve support of debugging under
905 DaveS <davls@telus.net> to improve support of debugging under
899 NTEmacs, including improved pydb behavior.
906 NTEmacs, including improved pydb behavior.
900
907
901 * IPython/Magic.py (magic_prun): Fix saving of profile info for
908 * IPython/Magic.py (magic_prun): Fix saving of profile info for
902 Python 2.5, where the stats object API changed a little. Thanks
909 Python 2.5, where the stats object API changed a little. Thanks
903 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
910 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
904
911
905 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
912 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
906 Pernetty's patch to improve support for (X)Emacs under Win32.
913 Pernetty's patch to improve support for (X)Emacs under Win32.
907
914
908 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
915 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
909
916
910 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
917 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
911 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
918 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
912 a report by Nik Tautenhahn.
919 a report by Nik Tautenhahn.
913
920
914 2007-03-16 Walter Doerwald <walter@livinglogic.de>
921 2007-03-16 Walter Doerwald <walter@livinglogic.de>
915
922
916 * setup.py: Add the igrid help files to the list of data files
923 * setup.py: Add the igrid help files to the list of data files
917 to be installed alongside igrid.
924 to be installed alongside igrid.
918 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
925 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
919 Show the input object of the igrid browser as the window tile.
926 Show the input object of the igrid browser as the window tile.
920 Show the object the cursor is on in the statusbar.
927 Show the object the cursor is on in the statusbar.
921
928
922 2007-03-15 Ville Vainio <vivainio@gmail.com>
929 2007-03-15 Ville Vainio <vivainio@gmail.com>
923
930
924 * Extensions/ipy_stock_completers.py: Fixed exception
931 * Extensions/ipy_stock_completers.py: Fixed exception
925 on mismatching quotes in %run completer. Patch by
932 on mismatching quotes in %run completer. Patch by
926 Jorgen Stenarson. Closes #127.
933 Jorgen Stenarson. Closes #127.
927
934
928 2007-03-14 Ville Vainio <vivainio@gmail.com>
935 2007-03-14 Ville Vainio <vivainio@gmail.com>
929
936
930 * Extensions/ext_rehashdir.py: Do not do auto_alias
937 * Extensions/ext_rehashdir.py: Do not do auto_alias
931 in %rehashdir, it clobbers %store'd aliases.
938 in %rehashdir, it clobbers %store'd aliases.
932
939
933 * UserConfig/ipy_profile_sh.py: envpersist.py extension
940 * UserConfig/ipy_profile_sh.py: envpersist.py extension
934 (beefed up %env) imported for sh profile.
941 (beefed up %env) imported for sh profile.
935
942
936 2007-03-10 Walter Doerwald <walter@livinglogic.de>
943 2007-03-10 Walter Doerwald <walter@livinglogic.de>
937
944
938 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
945 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
939 as the default browser.
946 as the default browser.
940 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
947 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
941 As igrid displays all attributes it ever encounters, fetch() (which has
948 As igrid displays all attributes it ever encounters, fetch() (which has
942 been renamed to _fetch()) doesn't have to recalculate the display attributes
949 been renamed to _fetch()) doesn't have to recalculate the display attributes
943 every time a new item is fetched. This should speed up scrolling.
950 every time a new item is fetched. This should speed up scrolling.
944
951
945 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
952 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
946
953
947 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
954 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
948 Schmolck's recently reported tab-completion bug (my previous one
955 Schmolck's recently reported tab-completion bug (my previous one
949 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
956 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
950
957
951 2007-03-09 Walter Doerwald <walter@livinglogic.de>
958 2007-03-09 Walter Doerwald <walter@livinglogic.de>
952
959
953 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
960 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
954 Close help window if exiting igrid.
961 Close help window if exiting igrid.
955
962
956 2007-03-02 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
963 2007-03-02 Jorgen Stenarson <jorgen.stenarson@bostream.nu>
957
964
958 * IPython/Extensions/ipy_defaults.py: Check if readline is available
965 * IPython/Extensions/ipy_defaults.py: Check if readline is available
959 before calling functions from readline.
966 before calling functions from readline.
960
967
961 2007-03-02 Walter Doerwald <walter@livinglogic.de>
968 2007-03-02 Walter Doerwald <walter@livinglogic.de>
962
969
963 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
970 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
964 igrid is a wxPython-based display object for ipipe. If your system has
971 igrid is a wxPython-based display object for ipipe. If your system has
965 wx installed igrid will be the default display. Without wx ipipe falls
972 wx installed igrid will be the default display. Without wx ipipe falls
966 back to ibrowse (which needs curses). If no curses is installed ipipe
973 back to ibrowse (which needs curses). If no curses is installed ipipe
967 falls back to idump.
974 falls back to idump.
968
975
969 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
976 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
970
977
971 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
978 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
972 my changes from yesterday, they introduced bugs. Will reactivate
979 my changes from yesterday, they introduced bugs. Will reactivate
973 once I get a correct solution, which will be much easier thanks to
980 once I get a correct solution, which will be much easier thanks to
974 Dan Milstein's new prefilter test suite.
981 Dan Milstein's new prefilter test suite.
975
982
976 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
983 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
977
984
978 * IPython/iplib.py (split_user_input): fix input splitting so we
985 * IPython/iplib.py (split_user_input): fix input splitting so we
979 don't attempt attribute accesses on things that can't possibly be
986 don't attempt attribute accesses on things that can't possibly be
980 valid Python attributes. After a bug report by Alex Schmolck.
987 valid Python attributes. After a bug report by Alex Schmolck.
981 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
988 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
982 %magic with explicit % prefix.
989 %magic with explicit % prefix.
983
990
984 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
991 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
985
992
986 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
993 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
987 avoid a DeprecationWarning from GTK.
994 avoid a DeprecationWarning from GTK.
988
995
989 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
996 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
990
997
991 * IPython/genutils.py (clock): I modified clock() to return total
998 * IPython/genutils.py (clock): I modified clock() to return total
992 time, user+system. This is a more commonly needed metric. I also
999 time, user+system. This is a more commonly needed metric. I also
993 introduced the new clocku/clocks to get only user/system time if
1000 introduced the new clocku/clocks to get only user/system time if
994 one wants those instead.
1001 one wants those instead.
995
1002
996 ***WARNING: API CHANGE*** clock() used to return only user time,
1003 ***WARNING: API CHANGE*** clock() used to return only user time,
997 so if you want exactly the same results as before, use clocku
1004 so if you want exactly the same results as before, use clocku
998 instead.
1005 instead.
999
1006
1000 2007-02-22 Ville Vainio <vivainio@gmail.com>
1007 2007-02-22 Ville Vainio <vivainio@gmail.com>
1001
1008
1002 * IPython/Extensions/ipy_p4.py: Extension for improved
1009 * IPython/Extensions/ipy_p4.py: Extension for improved
1003 p4 (perforce version control system) experience.
1010 p4 (perforce version control system) experience.
1004 Adds %p4 magic with p4 command completion and
1011 Adds %p4 magic with p4 command completion and
1005 automatic -G argument (marshall output as python dict)
1012 automatic -G argument (marshall output as python dict)
1006
1013
1007 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
1014 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
1008
1015
1009 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
1016 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
1010 stop marks.
1017 stop marks.
1011 (ClearingMixin): a simple mixin to easily make a Demo class clear
1018 (ClearingMixin): a simple mixin to easily make a Demo class clear
1012 the screen in between blocks and have empty marquees. The
1019 the screen in between blocks and have empty marquees. The
1013 ClearDemo and ClearIPDemo classes that use it are included.
1020 ClearDemo and ClearIPDemo classes that use it are included.
1014
1021
1015 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
1022 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
1016
1023
1017 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
1024 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
1018 protect against exceptions at Python shutdown time. Patch
1025 protect against exceptions at Python shutdown time. Patch
1019 sumbmitted to upstream.
1026 sumbmitted to upstream.
1020
1027
1021 2007-02-14 Walter Doerwald <walter@livinglogic.de>
1028 2007-02-14 Walter Doerwald <walter@livinglogic.de>
1022
1029
1023 * IPython/Extensions/ibrowse.py: If entering the first object level
1030 * IPython/Extensions/ibrowse.py: If entering the first object level
1024 (i.e. the object for which the browser has been started) fails,
1031 (i.e. the object for which the browser has been started) fails,
1025 now the error is raised directly (aborting the browser) instead of
1032 now the error is raised directly (aborting the browser) instead of
1026 running into an empty levels list later.
1033 running into an empty levels list later.
1027
1034
1028 2007-02-03 Walter Doerwald <walter@livinglogic.de>
1035 2007-02-03 Walter Doerwald <walter@livinglogic.de>
1029
1036
1030 * IPython/Extensions/ipipe.py: Add an xrepr implementation
1037 * IPython/Extensions/ipipe.py: Add an xrepr implementation
1031 for the noitem object.
1038 for the noitem object.
1032
1039
1033 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
1040 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
1034
1041
1035 * IPython/completer.py (Completer.attr_matches): Fix small
1042 * IPython/completer.py (Completer.attr_matches): Fix small
1036 tab-completion bug with Enthought Traits objects with units.
1043 tab-completion bug with Enthought Traits objects with units.
1037 Thanks to a bug report by Tom Denniston
1044 Thanks to a bug report by Tom Denniston
1038 <tom.denniston-AT-alum.dartmouth.org>.
1045 <tom.denniston-AT-alum.dartmouth.org>.
1039
1046
1040 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
1047 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
1041
1048
1042 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
1049 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
1043 bug where only .ipy or .py would be completed. Once the first
1050 bug where only .ipy or .py would be completed. Once the first
1044 argument to %run has been given, all completions are valid because
1051 argument to %run has been given, all completions are valid because
1045 they are the arguments to the script, which may well be non-python
1052 they are the arguments to the script, which may well be non-python
1046 filenames.
1053 filenames.
1047
1054
1048 * IPython/irunner.py (InteractiveRunner.run_source): major updates
1055 * IPython/irunner.py (InteractiveRunner.run_source): major updates
1049 to irunner to allow it to correctly support real doctesting of
1056 to irunner to allow it to correctly support real doctesting of
1050 out-of-process ipython code.
1057 out-of-process ipython code.
1051
1058
1052 * IPython/Magic.py (magic_cd): Make the setting of the terminal
1059 * IPython/Magic.py (magic_cd): Make the setting of the terminal
1053 title an option (-noterm_title) because it completely breaks
1060 title an option (-noterm_title) because it completely breaks
1054 doctesting.
1061 doctesting.
1055
1062
1056 * IPython/demo.py: fix IPythonDemo class that was not actually working.
1063 * IPython/demo.py: fix IPythonDemo class that was not actually working.
1057
1064
1058 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
1065 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
1059
1066
1060 * IPython/irunner.py (main): fix small bug where extensions were
1067 * IPython/irunner.py (main): fix small bug where extensions were
1061 not being correctly recognized.
1068 not being correctly recognized.
1062
1069
1063 2007-01-23 Walter Doerwald <walter@livinglogic.de>
1070 2007-01-23 Walter Doerwald <walter@livinglogic.de>
1064
1071
1065 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
1072 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
1066 a string containing a single line yields the string itself as the
1073 a string containing a single line yields the string itself as the
1067 only item.
1074 only item.
1068
1075
1069 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
1076 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
1070 object if it's the same as the one on the last level (This avoids
1077 object if it's the same as the one on the last level (This avoids
1071 infinite recursion for one line strings).
1078 infinite recursion for one line strings).
1072
1079
1073 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1080 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1074
1081
1075 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
1082 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
1076 all output streams before printing tracebacks. This ensures that
1083 all output streams before printing tracebacks. This ensures that
1077 user output doesn't end up interleaved with traceback output.
1084 user output doesn't end up interleaved with traceback output.
1078
1085
1079 2007-01-10 Ville Vainio <vivainio@gmail.com>
1086 2007-01-10 Ville Vainio <vivainio@gmail.com>
1080
1087
1081 * Extensions/envpersist.py: Turbocharged %env that remembers
1088 * Extensions/envpersist.py: Turbocharged %env that remembers
1082 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
1089 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
1083 "%env VISUAL=jed".
1090 "%env VISUAL=jed".
1084
1091
1085 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
1092 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
1086
1093
1087 * IPython/iplib.py (showtraceback): ensure that we correctly call
1094 * IPython/iplib.py (showtraceback): ensure that we correctly call
1088 custom handlers in all cases (some with pdb were slipping through,
1095 custom handlers in all cases (some with pdb were slipping through,
1089 but I'm not exactly sure why).
1096 but I'm not exactly sure why).
1090
1097
1091 * IPython/Debugger.py (Tracer.__init__): added new class to
1098 * IPython/Debugger.py (Tracer.__init__): added new class to
1092 support set_trace-like usage of IPython's enhanced debugger.
1099 support set_trace-like usage of IPython's enhanced debugger.
1093
1100
1094 2006-12-24 Ville Vainio <vivainio@gmail.com>
1101 2006-12-24 Ville Vainio <vivainio@gmail.com>
1095
1102
1096 * ipmaker.py: more informative message when ipy_user_conf
1103 * ipmaker.py: more informative message when ipy_user_conf
1097 import fails (suggest running %upgrade).
1104 import fails (suggest running %upgrade).
1098
1105
1099 * tools/run_ipy_in_profiler.py: Utility to see where
1106 * tools/run_ipy_in_profiler.py: Utility to see where
1100 the time during IPython startup is spent.
1107 the time during IPython startup is spent.
1101
1108
1102 2006-12-20 Ville Vainio <vivainio@gmail.com>
1109 2006-12-20 Ville Vainio <vivainio@gmail.com>
1103
1110
1104 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
1111 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
1105
1112
1106 * ipapi.py: Add new ipapi method, expand_alias.
1113 * ipapi.py: Add new ipapi method, expand_alias.
1107
1114
1108 * Release.py: Bump up version to 0.7.4.svn
1115 * Release.py: Bump up version to 0.7.4.svn
1109
1116
1110 2006-12-17 Ville Vainio <vivainio@gmail.com>
1117 2006-12-17 Ville Vainio <vivainio@gmail.com>
1111
1118
1112 * Extensions/jobctrl.py: Fixed &cmd arg arg...
1119 * Extensions/jobctrl.py: Fixed &cmd arg arg...
1113 to work properly on posix too
1120 to work properly on posix too
1114
1121
1115 * Release.py: Update revnum (version is still just 0.7.3).
1122 * Release.py: Update revnum (version is still just 0.7.3).
1116
1123
1117 2006-12-15 Ville Vainio <vivainio@gmail.com>
1124 2006-12-15 Ville Vainio <vivainio@gmail.com>
1118
1125
1119 * scripts/ipython_win_post_install: create ipython.py in
1126 * scripts/ipython_win_post_install: create ipython.py in
1120 prefix + "/scripts".
1127 prefix + "/scripts".
1121
1128
1122 * Release.py: Update version to 0.7.3.
1129 * Release.py: Update version to 0.7.3.
1123
1130
1124 2006-12-14 Ville Vainio <vivainio@gmail.com>
1131 2006-12-14 Ville Vainio <vivainio@gmail.com>
1125
1132
1126 * scripts/ipython_win_post_install: Overwrite old shortcuts
1133 * scripts/ipython_win_post_install: Overwrite old shortcuts
1127 if they already exist
1134 if they already exist
1128
1135
1129 * Release.py: release 0.7.3rc2
1136 * Release.py: release 0.7.3rc2
1130
1137
1131 2006-12-13 Ville Vainio <vivainio@gmail.com>
1138 2006-12-13 Ville Vainio <vivainio@gmail.com>
1132
1139
1133 * Branch and update Release.py for 0.7.3rc1
1140 * Branch and update Release.py for 0.7.3rc1
1134
1141
1135 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
1142 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
1136
1143
1137 * IPython/Shell.py (IPShellWX): update for current WX naming
1144 * IPython/Shell.py (IPShellWX): update for current WX naming
1138 conventions, to avoid a deprecation warning with current WX
1145 conventions, to avoid a deprecation warning with current WX
1139 versions. Thanks to a report by Danny Shevitz.
1146 versions. Thanks to a report by Danny Shevitz.
1140
1147
1141 2006-12-12 Ville Vainio <vivainio@gmail.com>
1148 2006-12-12 Ville Vainio <vivainio@gmail.com>
1142
1149
1143 * ipmaker.py: apply david cournapeau's patch to make
1150 * ipmaker.py: apply david cournapeau's patch to make
1144 import_some work properly even when ipythonrc does
1151 import_some work properly even when ipythonrc does
1145 import_some on empty list (it was an old bug!).
1152 import_some on empty list (it was an old bug!).
1146
1153
1147 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
1154 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
1148 Add deprecation note to ipythonrc and a url to wiki
1155 Add deprecation note to ipythonrc and a url to wiki
1149 in ipy_user_conf.py
1156 in ipy_user_conf.py
1150
1157
1151
1158
1152 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
1159 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
1153 as if it was typed on IPython command prompt, i.e.
1160 as if it was typed on IPython command prompt, i.e.
1154 as IPython script.
1161 as IPython script.
1155
1162
1156 * example-magic.py, magic_grepl.py: remove outdated examples
1163 * example-magic.py, magic_grepl.py: remove outdated examples
1157
1164
1158 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
1165 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
1159
1166
1160 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
1167 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
1161 is called before any exception has occurred.
1168 is called before any exception has occurred.
1162
1169
1163 2006-12-08 Ville Vainio <vivainio@gmail.com>
1170 2006-12-08 Ville Vainio <vivainio@gmail.com>
1164
1171
1165 * Extensions/ipy_stock_completers.py: fix cd completer
1172 * Extensions/ipy_stock_completers.py: fix cd completer
1166 to translate /'s to \'s again.
1173 to translate /'s to \'s again.
1167
1174
1168 * completer.py: prevent traceback on file completions w/
1175 * completer.py: prevent traceback on file completions w/
1169 backslash.
1176 backslash.
1170
1177
1171 * Release.py: Update release number to 0.7.3b3 for release
1178 * Release.py: Update release number to 0.7.3b3 for release
1172
1179
1173 2006-12-07 Ville Vainio <vivainio@gmail.com>
1180 2006-12-07 Ville Vainio <vivainio@gmail.com>
1174
1181
1175 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
1182 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
1176 while executing external code. Provides more shell-like behaviour
1183 while executing external code. Provides more shell-like behaviour
1177 and overall better response to ctrl + C / ctrl + break.
1184 and overall better response to ctrl + C / ctrl + break.
1178
1185
1179 * tools/make_tarball.py: new script to create tarball straight from svn
1186 * tools/make_tarball.py: new script to create tarball straight from svn
1180 (setup.py sdist doesn't work on win32).
1187 (setup.py sdist doesn't work on win32).
1181
1188
1182 * Extensions/ipy_stock_completers.py: fix cd completer to give up
1189 * Extensions/ipy_stock_completers.py: fix cd completer to give up
1183 on dirnames with spaces and use the default completer instead.
1190 on dirnames with spaces and use the default completer instead.
1184
1191
1185 * Revision.py: Change version to 0.7.3b2 for release.
1192 * Revision.py: Change version to 0.7.3b2 for release.
1186
1193
1187 2006-12-05 Ville Vainio <vivainio@gmail.com>
1194 2006-12-05 Ville Vainio <vivainio@gmail.com>
1188
1195
1189 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
1196 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
1190 pydb patch 4 (rm debug printing, py 2.5 checking)
1197 pydb patch 4 (rm debug printing, py 2.5 checking)
1191
1198
1192 2006-11-30 Walter Doerwald <walter@livinglogic.de>
1199 2006-11-30 Walter Doerwald <walter@livinglogic.de>
1193 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
1200 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
1194 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
1201 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
1195 "refreshfind" (mapped to "R") does the same but tries to go back to the same
1202 "refreshfind" (mapped to "R") does the same but tries to go back to the same
1196 object the cursor was on before the refresh. The command "markrange" is
1203 object the cursor was on before the refresh. The command "markrange" is
1197 mapped to "%" now.
1204 mapped to "%" now.
1198 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
1205 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
1199
1206
1200 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
1207 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
1201
1208
1202 * IPython/Magic.py (magic_debug): new %debug magic to activate the
1209 * IPython/Magic.py (magic_debug): new %debug magic to activate the
1203 interactive debugger on the last traceback, without having to call
1210 interactive debugger on the last traceback, without having to call
1204 %pdb and rerun your code. Made minor changes in various modules,
1211 %pdb and rerun your code. Made minor changes in various modules,
1205 should automatically recognize pydb if available.
1212 should automatically recognize pydb if available.
1206
1213
1207 2006-11-28 Ville Vainio <vivainio@gmail.com>
1214 2006-11-28 Ville Vainio <vivainio@gmail.com>
1208
1215
1209 * completer.py: If the text start with !, show file completions
1216 * completer.py: If the text start with !, show file completions
1210 properly. This helps when trying to complete command name
1217 properly. This helps when trying to complete command name
1211 for shell escapes.
1218 for shell escapes.
1212
1219
1213 2006-11-27 Ville Vainio <vivainio@gmail.com>
1220 2006-11-27 Ville Vainio <vivainio@gmail.com>
1214
1221
1215 * ipy_stock_completers.py: bzr completer submitted by Stefan van
1222 * ipy_stock_completers.py: bzr completer submitted by Stefan van
1216 der Walt. Clean up svn and hg completers by using a common
1223 der Walt. Clean up svn and hg completers by using a common
1217 vcs_completer.
1224 vcs_completer.
1218
1225
1219 2006-11-26 Ville Vainio <vivainio@gmail.com>
1226 2006-11-26 Ville Vainio <vivainio@gmail.com>
1220
1227
1221 * Remove ipconfig and %config; you should use _ip.options structure
1228 * Remove ipconfig and %config; you should use _ip.options structure
1222 directly instead!
1229 directly instead!
1223
1230
1224 * genutils.py: add wrap_deprecated function for deprecating callables
1231 * genutils.py: add wrap_deprecated function for deprecating callables
1225
1232
1226 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
1233 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
1227 _ip.system instead. ipalias is redundant.
1234 _ip.system instead. ipalias is redundant.
1228
1235
1229 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
1236 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
1230 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
1237 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
1231 explicit.
1238 explicit.
1232
1239
1233 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
1240 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
1234 completer. Try it by entering 'hg ' and pressing tab.
1241 completer. Try it by entering 'hg ' and pressing tab.
1235
1242
1236 * macro.py: Give Macro a useful __repr__ method
1243 * macro.py: Give Macro a useful __repr__ method
1237
1244
1238 * Magic.py: %whos abbreviates the typename of Macro for brevity.
1245 * Magic.py: %whos abbreviates the typename of Macro for brevity.
1239
1246
1240 2006-11-24 Walter Doerwald <walter@livinglogic.de>
1247 2006-11-24 Walter Doerwald <walter@livinglogic.de>
1241 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
1248 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
1242 we don't get a duplicate ipipe module, where registration of the xrepr
1249 we don't get a duplicate ipipe module, where registration of the xrepr
1243 implementation for Text is useless.
1250 implementation for Text is useless.
1244
1251
1245 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
1252 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
1246
1253
1247 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
1254 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
1248
1255
1249 2006-11-24 Ville Vainio <vivainio@gmail.com>
1256 2006-11-24 Ville Vainio <vivainio@gmail.com>
1250
1257
1251 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
1258 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
1252 try to use "cProfile" instead of the slower pure python
1259 try to use "cProfile" instead of the slower pure python
1253 "profile"
1260 "profile"
1254
1261
1255 2006-11-23 Ville Vainio <vivainio@gmail.com>
1262 2006-11-23 Ville Vainio <vivainio@gmail.com>
1256
1263
1257 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
1264 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
1258 Qt+IPython+Designer link in documentation.
1265 Qt+IPython+Designer link in documentation.
1259
1266
1260 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
1267 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
1261 correct Pdb object to %pydb.
1268 correct Pdb object to %pydb.
1262
1269
1263
1270
1264 2006-11-22 Walter Doerwald <walter@livinglogic.de>
1271 2006-11-22 Walter Doerwald <walter@livinglogic.de>
1265 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
1272 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
1266 generic xrepr(), otherwise the list implementation would kick in.
1273 generic xrepr(), otherwise the list implementation would kick in.
1267
1274
1268 2006-11-21 Ville Vainio <vivainio@gmail.com>
1275 2006-11-21 Ville Vainio <vivainio@gmail.com>
1269
1276
1270 * upgrade_dir.py: Now actually overwrites a nonmodified user file
1277 * upgrade_dir.py: Now actually overwrites a nonmodified user file
1271 with one from UserConfig.
1278 with one from UserConfig.
1272
1279
1273 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
1280 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
1274 it was missing which broke the sh profile.
1281 it was missing which broke the sh profile.
1275
1282
1276 * completer.py: file completer now uses explicit '/' instead
1283 * completer.py: file completer now uses explicit '/' instead
1277 of os.path.join, expansion of 'foo' was broken on win32
1284 of os.path.join, expansion of 'foo' was broken on win32
1278 if there was one directory with name 'foobar'.
1285 if there was one directory with name 'foobar'.
1279
1286
1280 * A bunch of patches from Kirill Smelkov:
1287 * A bunch of patches from Kirill Smelkov:
1281
1288
1282 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
1289 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
1283
1290
1284 * [patch 7/9] Implement %page -r (page in raw mode) -
1291 * [patch 7/9] Implement %page -r (page in raw mode) -
1285
1292
1286 * [patch 5/9] ScientificPython webpage has moved
1293 * [patch 5/9] ScientificPython webpage has moved
1287
1294
1288 * [patch 4/9] The manual mentions %ds, should be %dhist
1295 * [patch 4/9] The manual mentions %ds, should be %dhist
1289
1296
1290 * [patch 3/9] Kill old bits from %prun doc.
1297 * [patch 3/9] Kill old bits from %prun doc.
1291
1298
1292 * [patch 1/9] Fix typos here and there.
1299 * [patch 1/9] Fix typos here and there.
1293
1300
1294 2006-11-08 Ville Vainio <vivainio@gmail.com>
1301 2006-11-08 Ville Vainio <vivainio@gmail.com>
1295
1302
1296 * completer.py (attr_matches): catch all exceptions raised
1303 * completer.py (attr_matches): catch all exceptions raised
1297 by eval of expr with dots.
1304 by eval of expr with dots.
1298
1305
1299 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
1306 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
1300
1307
1301 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
1308 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
1302 input if it starts with whitespace. This allows you to paste
1309 input if it starts with whitespace. This allows you to paste
1303 indented input from any editor without manually having to type in
1310 indented input from any editor without manually having to type in
1304 the 'if 1:', which is convenient when working interactively.
1311 the 'if 1:', which is convenient when working interactively.
1305 Slightly modifed version of a patch by Bo Peng
1312 Slightly modifed version of a patch by Bo Peng
1306 <bpeng-AT-rice.edu>.
1313 <bpeng-AT-rice.edu>.
1307
1314
1308 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1315 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1309
1316
1310 * IPython/irunner.py (main): modified irunner so it automatically
1317 * IPython/irunner.py (main): modified irunner so it automatically
1311 recognizes the right runner to use based on the extension (.py for
1318 recognizes the right runner to use based on the extension (.py for
1312 python, .ipy for ipython and .sage for sage).
1319 python, .ipy for ipython and .sage for sage).
1313
1320
1314 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
1321 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
1315 visible in ipapi as ip.config(), to programatically control the
1322 visible in ipapi as ip.config(), to programatically control the
1316 internal rc object. There's an accompanying %config magic for
1323 internal rc object. There's an accompanying %config magic for
1317 interactive use, which has been enhanced to match the
1324 interactive use, which has been enhanced to match the
1318 funtionality in ipconfig.
1325 funtionality in ipconfig.
1319
1326
1320 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
1327 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
1321 so it's not just a toggle, it now takes an argument. Add support
1328 so it's not just a toggle, it now takes an argument. Add support
1322 for a customizable header when making system calls, as the new
1329 for a customizable header when making system calls, as the new
1323 system_header variable in the ipythonrc file.
1330 system_header variable in the ipythonrc file.
1324
1331
1325 2006-11-03 Walter Doerwald <walter@livinglogic.de>
1332 2006-11-03 Walter Doerwald <walter@livinglogic.de>
1326
1333
1327 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
1334 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
1328 generic functions (using Philip J. Eby's simplegeneric package).
1335 generic functions (using Philip J. Eby's simplegeneric package).
1329 This makes it possible to customize the display of third-party classes
1336 This makes it possible to customize the display of third-party classes
1330 without having to monkeypatch them. xiter() no longer supports a mode
1337 without having to monkeypatch them. xiter() no longer supports a mode
1331 argument and the XMode class has been removed. The same functionality can
1338 argument and the XMode class has been removed. The same functionality can
1332 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
1339 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
1333 One consequence of the switch to generic functions is that xrepr() and
1340 One consequence of the switch to generic functions is that xrepr() and
1334 xattrs() implementation must define the default value for the mode
1341 xattrs() implementation must define the default value for the mode
1335 argument themselves and xattrs() implementations must return real
1342 argument themselves and xattrs() implementations must return real
1336 descriptors.
1343 descriptors.
1337
1344
1338 * IPython/external: This new subpackage will contain all third-party
1345 * IPython/external: This new subpackage will contain all third-party
1339 packages that are bundled with IPython. (The first one is simplegeneric).
1346 packages that are bundled with IPython. (The first one is simplegeneric).
1340
1347
1341 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
1348 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
1342 directory which as been dropped in r1703.
1349 directory which as been dropped in r1703.
1343
1350
1344 * IPython/Extensions/ipipe.py (iless): Fixed.
1351 * IPython/Extensions/ipipe.py (iless): Fixed.
1345
1352
1346 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
1353 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
1347
1354
1348 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1355 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1349
1356
1350 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
1357 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
1351 handling in variable expansion so that shells and magics recognize
1358 handling in variable expansion so that shells and magics recognize
1352 function local scopes correctly. Bug reported by Brian.
1359 function local scopes correctly. Bug reported by Brian.
1353
1360
1354 * scripts/ipython: remove the very first entry in sys.path which
1361 * scripts/ipython: remove the very first entry in sys.path which
1355 Python auto-inserts for scripts, so that sys.path under IPython is
1362 Python auto-inserts for scripts, so that sys.path under IPython is
1356 as similar as possible to that under plain Python.
1363 as similar as possible to that under plain Python.
1357
1364
1358 * IPython/completer.py (IPCompleter.file_matches): Fix
1365 * IPython/completer.py (IPCompleter.file_matches): Fix
1359 tab-completion so that quotes are not closed unless the completion
1366 tab-completion so that quotes are not closed unless the completion
1360 is unambiguous. After a request by Stefan. Minor cleanups in
1367 is unambiguous. After a request by Stefan. Minor cleanups in
1361 ipy_stock_completers.
1368 ipy_stock_completers.
1362
1369
1363 2006-11-02 Ville Vainio <vivainio@gmail.com>
1370 2006-11-02 Ville Vainio <vivainio@gmail.com>
1364
1371
1365 * ipy_stock_completers.py: Add %run and %cd completers.
1372 * ipy_stock_completers.py: Add %run and %cd completers.
1366
1373
1367 * completer.py: Try running custom completer for both
1374 * completer.py: Try running custom completer for both
1368 "foo" and "%foo" if the command is just "foo". Ignore case
1375 "foo" and "%foo" if the command is just "foo". Ignore case
1369 when filtering possible completions.
1376 when filtering possible completions.
1370
1377
1371 * UserConfig/ipy_user_conf.py: install stock completers as default
1378 * UserConfig/ipy_user_conf.py: install stock completers as default
1372
1379
1373 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
1380 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
1374 simplified readline history save / restore through a wrapper
1381 simplified readline history save / restore through a wrapper
1375 function
1382 function
1376
1383
1377
1384
1378 2006-10-31 Ville Vainio <vivainio@gmail.com>
1385 2006-10-31 Ville Vainio <vivainio@gmail.com>
1379
1386
1380 * strdispatch.py, completer.py, ipy_stock_completers.py:
1387 * strdispatch.py, completer.py, ipy_stock_completers.py:
1381 Allow str_key ("command") in completer hooks. Implement
1388 Allow str_key ("command") in completer hooks. Implement
1382 trivial completer for 'import' (stdlib modules only). Rename
1389 trivial completer for 'import' (stdlib modules only). Rename
1383 ipy_linux_package_managers.py to ipy_stock_completers.py.
1390 ipy_linux_package_managers.py to ipy_stock_completers.py.
1384 SVN completer.
1391 SVN completer.
1385
1392
1386 * Extensions/ledit.py: %magic line editor for easily and
1393 * Extensions/ledit.py: %magic line editor for easily and
1387 incrementally manipulating lists of strings. The magic command
1394 incrementally manipulating lists of strings. The magic command
1388 name is %led.
1395 name is %led.
1389
1396
1390 2006-10-30 Ville Vainio <vivainio@gmail.com>
1397 2006-10-30 Ville Vainio <vivainio@gmail.com>
1391
1398
1392 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
1399 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
1393 Bernsteins's patches for pydb integration.
1400 Bernsteins's patches for pydb integration.
1394 http://bashdb.sourceforge.net/pydb/
1401 http://bashdb.sourceforge.net/pydb/
1395
1402
1396 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
1403 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
1397 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
1404 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
1398 custom completer hook to allow the users to implement their own
1405 custom completer hook to allow the users to implement their own
1399 completers. See ipy_linux_package_managers.py for example. The
1406 completers. See ipy_linux_package_managers.py for example. The
1400 hook name is 'complete_command'.
1407 hook name is 'complete_command'.
1401
1408
1402 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
1409 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
1403
1410
1404 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
1411 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
1405 Numeric leftovers.
1412 Numeric leftovers.
1406
1413
1407 * ipython.el (py-execute-region): apply Stefan's patch to fix
1414 * ipython.el (py-execute-region): apply Stefan's patch to fix
1408 garbled results if the python shell hasn't been previously started.
1415 garbled results if the python shell hasn't been previously started.
1409
1416
1410 * IPython/genutils.py (arg_split): moved to genutils, since it's a
1417 * IPython/genutils.py (arg_split): moved to genutils, since it's a
1411 pretty generic function and useful for other things.
1418 pretty generic function and useful for other things.
1412
1419
1413 * IPython/OInspect.py (getsource): Add customizable source
1420 * IPython/OInspect.py (getsource): Add customizable source
1414 extractor. After a request/patch form W. Stein (SAGE).
1421 extractor. After a request/patch form W. Stein (SAGE).
1415
1422
1416 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
1423 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
1417 window size to a more reasonable value from what pexpect does,
1424 window size to a more reasonable value from what pexpect does,
1418 since their choice causes wrapping bugs with long input lines.
1425 since their choice causes wrapping bugs with long input lines.
1419
1426
1420 2006-10-28 Ville Vainio <vivainio@gmail.com>
1427 2006-10-28 Ville Vainio <vivainio@gmail.com>
1421
1428
1422 * Magic.py (%run): Save and restore the readline history from
1429 * Magic.py (%run): Save and restore the readline history from
1423 file around %run commands to prevent side effects from
1430 file around %run commands to prevent side effects from
1424 %runned programs that might use readline (e.g. pydb).
1431 %runned programs that might use readline (e.g. pydb).
1425
1432
1426 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
1433 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
1427 invoking the pydb enhanced debugger.
1434 invoking the pydb enhanced debugger.
1428
1435
1429 2006-10-23 Walter Doerwald <walter@livinglogic.de>
1436 2006-10-23 Walter Doerwald <walter@livinglogic.de>
1430
1437
1431 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
1438 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
1432 call the base class method and propagate the return value to
1439 call the base class method and propagate the return value to
1433 ifile. This is now done by path itself.
1440 ifile. This is now done by path itself.
1434
1441
1435 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1442 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1436
1443
1437 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
1444 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
1438 api: set_crash_handler(), to expose the ability to change the
1445 api: set_crash_handler(), to expose the ability to change the
1439 internal crash handler.
1446 internal crash handler.
1440
1447
1441 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
1448 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
1442 the various parameters of the crash handler so that apps using
1449 the various parameters of the crash handler so that apps using
1443 IPython as their engine can customize crash handling. Ipmlemented
1450 IPython as their engine can customize crash handling. Ipmlemented
1444 at the request of SAGE.
1451 at the request of SAGE.
1445
1452
1446 2006-10-14 Ville Vainio <vivainio@gmail.com>
1453 2006-10-14 Ville Vainio <vivainio@gmail.com>
1447
1454
1448 * Magic.py, ipython.el: applied first "safe" part of Rocky
1455 * Magic.py, ipython.el: applied first "safe" part of Rocky
1449 Bernstein's patch set for pydb integration.
1456 Bernstein's patch set for pydb integration.
1450
1457
1451 * Magic.py (%unalias, %alias): %store'd aliases can now be
1458 * Magic.py (%unalias, %alias): %store'd aliases can now be
1452 removed with '%unalias'. %alias w/o args now shows most
1459 removed with '%unalias'. %alias w/o args now shows most
1453 interesting (stored / manually defined) aliases last
1460 interesting (stored / manually defined) aliases last
1454 where they catch the eye w/o scrolling.
1461 where they catch the eye w/o scrolling.
1455
1462
1456 * Magic.py (%rehashx), ext_rehashdir.py: files with
1463 * Magic.py (%rehashx), ext_rehashdir.py: files with
1457 'py' extension are always considered executable, even
1464 'py' extension are always considered executable, even
1458 when not in PATHEXT environment variable.
1465 when not in PATHEXT environment variable.
1459
1466
1460 2006-10-12 Ville Vainio <vivainio@gmail.com>
1467 2006-10-12 Ville Vainio <vivainio@gmail.com>
1461
1468
1462 * jobctrl.py: Add new "jobctrl" extension for spawning background
1469 * jobctrl.py: Add new "jobctrl" extension for spawning background
1463 processes with "&find /". 'import jobctrl' to try it out. Requires
1470 processes with "&find /". 'import jobctrl' to try it out. Requires
1464 'subprocess' module, standard in python 2.4+.
1471 'subprocess' module, standard in python 2.4+.
1465
1472
1466 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
1473 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
1467 so if foo -> bar and bar -> baz, then foo -> baz.
1474 so if foo -> bar and bar -> baz, then foo -> baz.
1468
1475
1469 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
1476 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
1470
1477
1471 * IPython/Magic.py (Magic.parse_options): add a new posix option
1478 * IPython/Magic.py (Magic.parse_options): add a new posix option
1472 to allow parsing of input args in magics that doesn't strip quotes
1479 to allow parsing of input args in magics that doesn't strip quotes
1473 (if posix=False). This also closes %timeit bug reported by
1480 (if posix=False). This also closes %timeit bug reported by
1474 Stefan.
1481 Stefan.
1475
1482
1476 2006-10-03 Ville Vainio <vivainio@gmail.com>
1483 2006-10-03 Ville Vainio <vivainio@gmail.com>
1477
1484
1478 * iplib.py (raw_input, interact): Return ValueError catching for
1485 * iplib.py (raw_input, interact): Return ValueError catching for
1479 raw_input. Fixes infinite loop for sys.stdin.close() or
1486 raw_input. Fixes infinite loop for sys.stdin.close() or
1480 sys.stdout.close().
1487 sys.stdout.close().
1481
1488
1482 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1489 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1483
1490
1484 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
1491 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
1485 to help in handling doctests. irunner is now pretty useful for
1492 to help in handling doctests. irunner is now pretty useful for
1486 running standalone scripts and simulate a full interactive session
1493 running standalone scripts and simulate a full interactive session
1487 in a format that can be then pasted as a doctest.
1494 in a format that can be then pasted as a doctest.
1488
1495
1489 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
1496 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
1490 on top of the default (useless) ones. This also fixes the nasty
1497 on top of the default (useless) ones. This also fixes the nasty
1491 way in which 2.5's Quitter() exits (reverted [1785]).
1498 way in which 2.5's Quitter() exits (reverted [1785]).
1492
1499
1493 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
1500 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
1494 2.5.
1501 2.5.
1495
1502
1496 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
1503 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
1497 color scheme is updated as well when color scheme is changed
1504 color scheme is updated as well when color scheme is changed
1498 interactively.
1505 interactively.
1499
1506
1500 2006-09-27 Ville Vainio <vivainio@gmail.com>
1507 2006-09-27 Ville Vainio <vivainio@gmail.com>
1501
1508
1502 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
1509 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
1503 infinite loop and just exit. It's a hack, but will do for a while.
1510 infinite loop and just exit. It's a hack, but will do for a while.
1504
1511
1505 2006-08-25 Walter Doerwald <walter@livinglogic.de>
1512 2006-08-25 Walter Doerwald <walter@livinglogic.de>
1506
1513
1507 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
1514 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
1508 the constructor, this makes it possible to get a list of only directories
1515 the constructor, this makes it possible to get a list of only directories
1509 or only files.
1516 or only files.
1510
1517
1511 2006-08-12 Ville Vainio <vivainio@gmail.com>
1518 2006-08-12 Ville Vainio <vivainio@gmail.com>
1512
1519
1513 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
1520 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
1514 they broke unittest
1521 they broke unittest
1515
1522
1516 2006-08-11 Ville Vainio <vivainio@gmail.com>
1523 2006-08-11 Ville Vainio <vivainio@gmail.com>
1517
1524
1518 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
1525 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
1519 by resolving issue properly, i.e. by inheriting FakeModule
1526 by resolving issue properly, i.e. by inheriting FakeModule
1520 from types.ModuleType. Pickling ipython interactive data
1527 from types.ModuleType. Pickling ipython interactive data
1521 should still work as usual (testing appreciated).
1528 should still work as usual (testing appreciated).
1522
1529
1523 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
1530 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
1524
1531
1525 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
1532 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
1526 running under python 2.3 with code from 2.4 to fix a bug with
1533 running under python 2.3 with code from 2.4 to fix a bug with
1527 help(). Reported by the Debian maintainers, Norbert Tretkowski
1534 help(). Reported by the Debian maintainers, Norbert Tretkowski
1528 <norbert-AT-tretkowski.de> and Alexandre Fayolle
1535 <norbert-AT-tretkowski.de> and Alexandre Fayolle
1529 <afayolle-AT-debian.org>.
1536 <afayolle-AT-debian.org>.
1530
1537
1531 2006-08-04 Walter Doerwald <walter@livinglogic.de>
1538 2006-08-04 Walter Doerwald <walter@livinglogic.de>
1532
1539
1533 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
1540 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
1534 (which was displaying "quit" twice).
1541 (which was displaying "quit" twice).
1535
1542
1536 2006-07-28 Walter Doerwald <walter@livinglogic.de>
1543 2006-07-28 Walter Doerwald <walter@livinglogic.de>
1537
1544
1538 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
1545 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
1539 the mode argument).
1546 the mode argument).
1540
1547
1541 2006-07-27 Walter Doerwald <walter@livinglogic.de>
1548 2006-07-27 Walter Doerwald <walter@livinglogic.de>
1542
1549
1543 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
1550 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
1544 not running under IPython.
1551 not running under IPython.
1545
1552
1546 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
1553 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
1547 and make it iterable (iterating over the attribute itself). Add two new
1554 and make it iterable (iterating over the attribute itself). Add two new
1548 magic strings for __xattrs__(): If the string starts with "-", the attribute
1555 magic strings for __xattrs__(): If the string starts with "-", the attribute
1549 will not be displayed in ibrowse's detail view (but it can still be
1556 will not be displayed in ibrowse's detail view (but it can still be
1550 iterated over). This makes it possible to add attributes that are large
1557 iterated over). This makes it possible to add attributes that are large
1551 lists or generator methods to the detail view. Replace magic attribute names
1558 lists or generator methods to the detail view. Replace magic attribute names
1552 and _attrname() and _getattr() with "descriptors": For each type of magic
1559 and _attrname() and _getattr() with "descriptors": For each type of magic
1553 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
1560 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
1554 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
1561 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
1555 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
1562 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
1556 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
1563 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
1557 are still supported.
1564 are still supported.
1558
1565
1559 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
1566 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
1560 fails in ibrowse.fetch(), the exception object is added as the last item
1567 fails in ibrowse.fetch(), the exception object is added as the last item
1561 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
1568 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
1562 a generator throws an exception midway through execution.
1569 a generator throws an exception midway through execution.
1563
1570
1564 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
1571 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
1565 encoding into methods.
1572 encoding into methods.
1566
1573
1567 2006-07-26 Ville Vainio <vivainio@gmail.com>
1574 2006-07-26 Ville Vainio <vivainio@gmail.com>
1568
1575
1569 * iplib.py: history now stores multiline input as single
1576 * iplib.py: history now stores multiline input as single
1570 history entries. Patch by Jorgen Cederlof.
1577 history entries. Patch by Jorgen Cederlof.
1571
1578
1572 2006-07-18 Walter Doerwald <walter@livinglogic.de>
1579 2006-07-18 Walter Doerwald <walter@livinglogic.de>
1573
1580
1574 * IPython/Extensions/ibrowse.py: Make cursor visible over
1581 * IPython/Extensions/ibrowse.py: Make cursor visible over
1575 non existing attributes.
1582 non existing attributes.
1576
1583
1577 2006-07-14 Walter Doerwald <walter@livinglogic.de>
1584 2006-07-14 Walter Doerwald <walter@livinglogic.de>
1578
1585
1579 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
1586 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
1580 error output of the running command doesn't mess up the screen.
1587 error output of the running command doesn't mess up the screen.
1581
1588
1582 2006-07-13 Walter Doerwald <walter@livinglogic.de>
1589 2006-07-13 Walter Doerwald <walter@livinglogic.de>
1583
1590
1584 * IPython/Extensions/ipipe.py (isort): Make isort usable without
1591 * IPython/Extensions/ipipe.py (isort): Make isort usable without
1585 argument. This sorts the items themselves.
1592 argument. This sorts the items themselves.
1586
1593
1587 2006-07-12 Walter Doerwald <walter@livinglogic.de>
1594 2006-07-12 Walter Doerwald <walter@livinglogic.de>
1588
1595
1589 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
1596 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
1590 Compile expression strings into code objects. This should speed
1597 Compile expression strings into code objects. This should speed
1591 up ifilter and friends somewhat.
1598 up ifilter and friends somewhat.
1592
1599
1593 2006-07-08 Ville Vainio <vivainio@gmail.com>
1600 2006-07-08 Ville Vainio <vivainio@gmail.com>
1594
1601
1595 * Magic.py: %cpaste now strips > from the beginning of lines
1602 * Magic.py: %cpaste now strips > from the beginning of lines
1596 to ease pasting quoted code from emails. Contributed by
1603 to ease pasting quoted code from emails. Contributed by
1597 Stefan van der Walt.
1604 Stefan van der Walt.
1598
1605
1599 2006-06-29 Ville Vainio <vivainio@gmail.com>
1606 2006-06-29 Ville Vainio <vivainio@gmail.com>
1600
1607
1601 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
1608 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
1602 mode, patch contributed by Darren Dale. NEEDS TESTING!
1609 mode, patch contributed by Darren Dale. NEEDS TESTING!
1603
1610
1604 2006-06-28 Walter Doerwald <walter@livinglogic.de>
1611 2006-06-28 Walter Doerwald <walter@livinglogic.de>
1605
1612
1606 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
1613 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
1607 a blue background. Fix fetching new display rows when the browser
1614 a blue background. Fix fetching new display rows when the browser
1608 scrolls more than a screenful (e.g. by using the goto command).
1615 scrolls more than a screenful (e.g. by using the goto command).
1609
1616
1610 2006-06-27 Ville Vainio <vivainio@gmail.com>
1617 2006-06-27 Ville Vainio <vivainio@gmail.com>
1611
1618
1612 * Magic.py (_inspect, _ofind) Apply David Huard's
1619 * Magic.py (_inspect, _ofind) Apply David Huard's
1613 patch for displaying the correct docstring for 'property'
1620 patch for displaying the correct docstring for 'property'
1614 attributes.
1621 attributes.
1615
1622
1616 2006-06-23 Walter Doerwald <walter@livinglogic.de>
1623 2006-06-23 Walter Doerwald <walter@livinglogic.de>
1617
1624
1618 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
1625 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
1619 commands into the methods implementing them.
1626 commands into the methods implementing them.
1620
1627
1621 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
1628 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
1622
1629
1623 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
1630 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
1624 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
1631 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
1625 autoindent support was authored by Jin Liu.
1632 autoindent support was authored by Jin Liu.
1626
1633
1627 2006-06-22 Walter Doerwald <walter@livinglogic.de>
1634 2006-06-22 Walter Doerwald <walter@livinglogic.de>
1628
1635
1629 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
1636 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
1630 for keymaps with a custom class that simplifies handling.
1637 for keymaps with a custom class that simplifies handling.
1631
1638
1632 2006-06-19 Walter Doerwald <walter@livinglogic.de>
1639 2006-06-19 Walter Doerwald <walter@livinglogic.de>
1633
1640
1634 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
1641 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
1635 resizing. This requires Python 2.5 to work.
1642 resizing. This requires Python 2.5 to work.
1636
1643
1637 2006-06-16 Walter Doerwald <walter@livinglogic.de>
1644 2006-06-16 Walter Doerwald <walter@livinglogic.de>
1638
1645
1639 * IPython/Extensions/ibrowse.py: Add two new commands to
1646 * IPython/Extensions/ibrowse.py: Add two new commands to
1640 ibrowse: "hideattr" (mapped to "h") hides the attribute under
1647 ibrowse: "hideattr" (mapped to "h") hides the attribute under
1641 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
1648 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
1642 attributes again. Remapped the help command to "?". Display
1649 attributes again. Remapped the help command to "?". Display
1643 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
1650 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
1644 as keys for the "home" and "end" commands. Add three new commands
1651 as keys for the "home" and "end" commands. Add three new commands
1645 to the input mode for "find" and friends: "delend" (CTRL-K)
1652 to the input mode for "find" and friends: "delend" (CTRL-K)
1646 deletes to the end of line. "incsearchup" searches upwards in the
1653 deletes to the end of line. "incsearchup" searches upwards in the
1647 command history for an input that starts with the text before the cursor.
1654 command history for an input that starts with the text before the cursor.
1648 "incsearchdown" does the same downwards. Removed a bogus mapping of
1655 "incsearchdown" does the same downwards. Removed a bogus mapping of
1649 the x key to "delete".
1656 the x key to "delete".
1650
1657
1651 2006-06-15 Ville Vainio <vivainio@gmail.com>
1658 2006-06-15 Ville Vainio <vivainio@gmail.com>
1652
1659
1653 * iplib.py, hooks.py: Added new generate_prompt hook that can be
1660 * iplib.py, hooks.py: Added new generate_prompt hook that can be
1654 used to create prompts dynamically, instead of the "old" way of
1661 used to create prompts dynamically, instead of the "old" way of
1655 assigning "magic" strings to prompt_in1 and prompt_in2. The old
1662 assigning "magic" strings to prompt_in1 and prompt_in2. The old
1656 way still works (it's invoked by the default hook), of course.
1663 way still works (it's invoked by the default hook), of course.
1657
1664
1658 * Prompts.py: added generate_output_prompt hook for altering output
1665 * Prompts.py: added generate_output_prompt hook for altering output
1659 prompt
1666 prompt
1660
1667
1661 * Release.py: Changed version string to 0.7.3.svn.
1668 * Release.py: Changed version string to 0.7.3.svn.
1662
1669
1663 2006-06-15 Walter Doerwald <walter@livinglogic.de>
1670 2006-06-15 Walter Doerwald <walter@livinglogic.de>
1664
1671
1665 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
1672 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
1666 the call to fetch() always tries to fetch enough data for at least one
1673 the call to fetch() always tries to fetch enough data for at least one
1667 full screen. This makes it possible to simply call moveto(0,0,True) in
1674 full screen. This makes it possible to simply call moveto(0,0,True) in
1668 the constructor. Fix typos and removed the obsolete goto attribute.
1675 the constructor. Fix typos and removed the obsolete goto attribute.
1669
1676
1670 2006-06-12 Ville Vainio <vivainio@gmail.com>
1677 2006-06-12 Ville Vainio <vivainio@gmail.com>
1671
1678
1672 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
1679 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
1673 allowing $variable interpolation within multiline statements,
1680 allowing $variable interpolation within multiline statements,
1674 though so far only with "sh" profile for a testing period.
1681 though so far only with "sh" profile for a testing period.
1675 The patch also enables splitting long commands with \ but it
1682 The patch also enables splitting long commands with \ but it
1676 doesn't work properly yet.
1683 doesn't work properly yet.
1677
1684
1678 2006-06-12 Walter Doerwald <walter@livinglogic.de>
1685 2006-06-12 Walter Doerwald <walter@livinglogic.de>
1679
1686
1680 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
1687 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
1681 input history and the position of the cursor in the input history for
1688 input history and the position of the cursor in the input history for
1682 the find, findbackwards and goto command.
1689 the find, findbackwards and goto command.
1683
1690
1684 2006-06-10 Walter Doerwald <walter@livinglogic.de>
1691 2006-06-10 Walter Doerwald <walter@livinglogic.de>
1685
1692
1686 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
1693 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
1687 implements the basic functionality of browser commands that require
1694 implements the basic functionality of browser commands that require
1688 input. Reimplement the goto, find and findbackwards commands as
1695 input. Reimplement the goto, find and findbackwards commands as
1689 subclasses of _CommandInput. Add an input history and keymaps to those
1696 subclasses of _CommandInput. Add an input history and keymaps to those
1690 commands. Add "\r" as a keyboard shortcut for the enterdefault and
1697 commands. Add "\r" as a keyboard shortcut for the enterdefault and
1691 execute commands.
1698 execute commands.
1692
1699
1693 2006-06-07 Ville Vainio <vivainio@gmail.com>
1700 2006-06-07 Ville Vainio <vivainio@gmail.com>
1694
1701
1695 * iplib.py: ipython mybatch.ipy exits ipython immediately after
1702 * iplib.py: ipython mybatch.ipy exits ipython immediately after
1696 running the batch files instead of leaving the session open.
1703 running the batch files instead of leaving the session open.
1697
1704
1698 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
1705 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
1699
1706
1700 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
1707 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
1701 the original fix was incomplete. Patch submitted by W. Maier.
1708 the original fix was incomplete. Patch submitted by W. Maier.
1702
1709
1703 2006-06-07 Ville Vainio <vivainio@gmail.com>
1710 2006-06-07 Ville Vainio <vivainio@gmail.com>
1704
1711
1705 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
1712 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
1706 Confirmation prompts can be supressed by 'quiet' option.
1713 Confirmation prompts can be supressed by 'quiet' option.
1707 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
1714 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
1708
1715
1709 2006-06-06 *** Released version 0.7.2
1716 2006-06-06 *** Released version 0.7.2
1710
1717
1711 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1718 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1712
1719
1713 * IPython/Release.py (version): Made 0.7.2 final for release.
1720 * IPython/Release.py (version): Made 0.7.2 final for release.
1714 Repo tagged and release cut.
1721 Repo tagged and release cut.
1715
1722
1716 2006-06-05 Ville Vainio <vivainio@gmail.com>
1723 2006-06-05 Ville Vainio <vivainio@gmail.com>
1717
1724
1718 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1725 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1719 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1726 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1720
1727
1721 * upgrade_dir.py: try import 'path' module a bit harder
1728 * upgrade_dir.py: try import 'path' module a bit harder
1722 (for %upgrade)
1729 (for %upgrade)
1723
1730
1724 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1731 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1725
1732
1726 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1733 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1727 instead of looping 20 times.
1734 instead of looping 20 times.
1728
1735
1729 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1736 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1730 correctly at initialization time. Bug reported by Krishna Mohan
1737 correctly at initialization time. Bug reported by Krishna Mohan
1731 Gundu <gkmohan-AT-gmail.com> on the user list.
1738 Gundu <gkmohan-AT-gmail.com> on the user list.
1732
1739
1733 * IPython/Release.py (version): Mark 0.7.2 version to start
1740 * IPython/Release.py (version): Mark 0.7.2 version to start
1734 testing for release on 06/06.
1741 testing for release on 06/06.
1735
1742
1736 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1743 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1737
1744
1738 * scripts/irunner: thin script interface so users don't have to
1745 * scripts/irunner: thin script interface so users don't have to
1739 find the module and call it as an executable, since modules rarely
1746 find the module and call it as an executable, since modules rarely
1740 live in people's PATH.
1747 live in people's PATH.
1741
1748
1742 * IPython/irunner.py (InteractiveRunner.__init__): added
1749 * IPython/irunner.py (InteractiveRunner.__init__): added
1743 delaybeforesend attribute to control delays with newer versions of
1750 delaybeforesend attribute to control delays with newer versions of
1744 pexpect. Thanks to detailed help from pexpect's author, Noah
1751 pexpect. Thanks to detailed help from pexpect's author, Noah
1745 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1752 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1746 correctly (it works in NoColor mode).
1753 correctly (it works in NoColor mode).
1747
1754
1748 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1755 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1749 SAGE list, from improper log() calls.
1756 SAGE list, from improper log() calls.
1750
1757
1751 2006-05-31 Ville Vainio <vivainio@gmail.com>
1758 2006-05-31 Ville Vainio <vivainio@gmail.com>
1752
1759
1753 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1760 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1754 with args in parens to work correctly with dirs that have spaces.
1761 with args in parens to work correctly with dirs that have spaces.
1755
1762
1756 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1763 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1757
1764
1758 * IPython/Logger.py (Logger.logstart): add option to log raw input
1765 * IPython/Logger.py (Logger.logstart): add option to log raw input
1759 instead of the processed one. A -r flag was added to the
1766 instead of the processed one. A -r flag was added to the
1760 %logstart magic used for controlling logging.
1767 %logstart magic used for controlling logging.
1761
1768
1762 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1769 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1763
1770
1764 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1771 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1765 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1772 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1766 recognize the option. After a bug report by Will Maier. This
1773 recognize the option. After a bug report by Will Maier. This
1767 closes #64 (will do it after confirmation from W. Maier).
1774 closes #64 (will do it after confirmation from W. Maier).
1768
1775
1769 * IPython/irunner.py: New module to run scripts as if manually
1776 * IPython/irunner.py: New module to run scripts as if manually
1770 typed into an interactive environment, based on pexpect. After a
1777 typed into an interactive environment, based on pexpect. After a
1771 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1778 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1772 ipython-user list. Simple unittests in the tests/ directory.
1779 ipython-user list. Simple unittests in the tests/ directory.
1773
1780
1774 * tools/release: add Will Maier, OpenBSD port maintainer, to
1781 * tools/release: add Will Maier, OpenBSD port maintainer, to
1775 recepients list. We are now officially part of the OpenBSD ports:
1782 recepients list. We are now officially part of the OpenBSD ports:
1776 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1783 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1777 work.
1784 work.
1778
1785
1779 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1786 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1780
1787
1781 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1788 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1782 so that it doesn't break tkinter apps.
1789 so that it doesn't break tkinter apps.
1783
1790
1784 * IPython/iplib.py (_prefilter): fix bug where aliases would
1791 * IPython/iplib.py (_prefilter): fix bug where aliases would
1785 shadow variables when autocall was fully off. Reported by SAGE
1792 shadow variables when autocall was fully off. Reported by SAGE
1786 author William Stein.
1793 author William Stein.
1787
1794
1788 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1795 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1789 at what detail level strings are computed when foo? is requested.
1796 at what detail level strings are computed when foo? is requested.
1790 This allows users to ask for example that the string form of an
1797 This allows users to ask for example that the string form of an
1791 object is only computed when foo?? is called, or even never, by
1798 object is only computed when foo?? is called, or even never, by
1792 setting the object_info_string_level >= 2 in the configuration
1799 setting the object_info_string_level >= 2 in the configuration
1793 file. This new option has been added and documented. After a
1800 file. This new option has been added and documented. After a
1794 request by SAGE to be able to control the printing of very large
1801 request by SAGE to be able to control the printing of very large
1795 objects more easily.
1802 objects more easily.
1796
1803
1797 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1804 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1798
1805
1799 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1806 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1800 from sys.argv, to be 100% consistent with how Python itself works
1807 from sys.argv, to be 100% consistent with how Python itself works
1801 (as seen for example with python -i file.py). After a bug report
1808 (as seen for example with python -i file.py). After a bug report
1802 by Jeffrey Collins.
1809 by Jeffrey Collins.
1803
1810
1804 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1811 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1805 nasty bug which was preventing custom namespaces with -pylab,
1812 nasty bug which was preventing custom namespaces with -pylab,
1806 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1813 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1807 compatibility (long gone from mpl).
1814 compatibility (long gone from mpl).
1808
1815
1809 * IPython/ipapi.py (make_session): name change: create->make. We
1816 * IPython/ipapi.py (make_session): name change: create->make. We
1810 use make in other places (ipmaker,...), it's shorter and easier to
1817 use make in other places (ipmaker,...), it's shorter and easier to
1811 type and say, etc. I'm trying to clean things before 0.7.2 so
1818 type and say, etc. I'm trying to clean things before 0.7.2 so
1812 that I can keep things stable wrt to ipapi in the chainsaw branch.
1819 that I can keep things stable wrt to ipapi in the chainsaw branch.
1813
1820
1814 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1821 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1815 python-mode recognizes our debugger mode. Add support for
1822 python-mode recognizes our debugger mode. Add support for
1816 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1823 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1817 <m.liu.jin-AT-gmail.com> originally written by
1824 <m.liu.jin-AT-gmail.com> originally written by
1818 doxgen-AT-newsmth.net (with minor modifications for xemacs
1825 doxgen-AT-newsmth.net (with minor modifications for xemacs
1819 compatibility)
1826 compatibility)
1820
1827
1821 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1828 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1822 tracebacks when walking the stack so that the stack tracking system
1829 tracebacks when walking the stack so that the stack tracking system
1823 in emacs' python-mode can identify the frames correctly.
1830 in emacs' python-mode can identify the frames correctly.
1824
1831
1825 * IPython/ipmaker.py (make_IPython): make the internal (and
1832 * IPython/ipmaker.py (make_IPython): make the internal (and
1826 default config) autoedit_syntax value false by default. Too many
1833 default config) autoedit_syntax value false by default. Too many
1827 users have complained to me (both on and off-list) about problems
1834 users have complained to me (both on and off-list) about problems
1828 with this option being on by default, so I'm making it default to
1835 with this option being on by default, so I'm making it default to
1829 off. It can still be enabled by anyone via the usual mechanisms.
1836 off. It can still be enabled by anyone via the usual mechanisms.
1830
1837
1831 * IPython/completer.py (Completer.attr_matches): add support for
1838 * IPython/completer.py (Completer.attr_matches): add support for
1832 PyCrust-style _getAttributeNames magic method. Patch contributed
1839 PyCrust-style _getAttributeNames magic method. Patch contributed
1833 by <mscott-AT-goldenspud.com>. Closes #50.
1840 by <mscott-AT-goldenspud.com>. Closes #50.
1834
1841
1835 * IPython/iplib.py (InteractiveShell.__init__): remove the
1842 * IPython/iplib.py (InteractiveShell.__init__): remove the
1836 deletion of exit/quit from __builtin__, which can break
1843 deletion of exit/quit from __builtin__, which can break
1837 third-party tools like the Zope debugging console. The
1844 third-party tools like the Zope debugging console. The
1838 %exit/%quit magics remain. In general, it's probably a good idea
1845 %exit/%quit magics remain. In general, it's probably a good idea
1839 not to delete anything from __builtin__, since we never know what
1846 not to delete anything from __builtin__, since we never know what
1840 that will break. In any case, python now (for 2.5) will support
1847 that will break. In any case, python now (for 2.5) will support
1841 'real' exit/quit, so this issue is moot. Closes #55.
1848 'real' exit/quit, so this issue is moot. Closes #55.
1842
1849
1843 * IPython/genutils.py (with_obj): rename the 'with' function to
1850 * IPython/genutils.py (with_obj): rename the 'with' function to
1844 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1851 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1845 becomes a language keyword. Closes #53.
1852 becomes a language keyword. Closes #53.
1846
1853
1847 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1854 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1848 __file__ attribute to this so it fools more things into thinking
1855 __file__ attribute to this so it fools more things into thinking
1849 it is a real module. Closes #59.
1856 it is a real module. Closes #59.
1850
1857
1851 * IPython/Magic.py (magic_edit): add -n option to open the editor
1858 * IPython/Magic.py (magic_edit): add -n option to open the editor
1852 at a specific line number. After a patch by Stefan van der Walt.
1859 at a specific line number. After a patch by Stefan van der Walt.
1853
1860
1854 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1861 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1855
1862
1856 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1863 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1857 reason the file could not be opened. After automatic crash
1864 reason the file could not be opened. After automatic crash
1858 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1865 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1859 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1866 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1860 (_should_recompile): Don't fire editor if using %bg, since there
1867 (_should_recompile): Don't fire editor if using %bg, since there
1861 is no file in the first place. From the same report as above.
1868 is no file in the first place. From the same report as above.
1862 (raw_input): protect against faulty third-party prefilters. After
1869 (raw_input): protect against faulty third-party prefilters. After
1863 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1870 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1864 while running under SAGE.
1871 while running under SAGE.
1865
1872
1866 2006-05-23 Ville Vainio <vivainio@gmail.com>
1873 2006-05-23 Ville Vainio <vivainio@gmail.com>
1867
1874
1868 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1875 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1869 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1876 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1870 now returns None (again), unless dummy is specifically allowed by
1877 now returns None (again), unless dummy is specifically allowed by
1871 ipapi.get(allow_dummy=True).
1878 ipapi.get(allow_dummy=True).
1872
1879
1873 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1880 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1874
1881
1875 * IPython: remove all 2.2-compatibility objects and hacks from
1882 * IPython: remove all 2.2-compatibility objects and hacks from
1876 everywhere, since we only support 2.3 at this point. Docs
1883 everywhere, since we only support 2.3 at this point. Docs
1877 updated.
1884 updated.
1878
1885
1879 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1886 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1880 Anything requiring extra validation can be turned into a Python
1887 Anything requiring extra validation can be turned into a Python
1881 property in the future. I used a property for the db one b/c
1888 property in the future. I used a property for the db one b/c
1882 there was a nasty circularity problem with the initialization
1889 there was a nasty circularity problem with the initialization
1883 order, which right now I don't have time to clean up.
1890 order, which right now I don't have time to clean up.
1884
1891
1885 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1892 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1886 another locking bug reported by Jorgen. I'm not 100% sure though,
1893 another locking bug reported by Jorgen. I'm not 100% sure though,
1887 so more testing is needed...
1894 so more testing is needed...
1888
1895
1889 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1896 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1890
1897
1891 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1898 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1892 local variables from any routine in user code (typically executed
1899 local variables from any routine in user code (typically executed
1893 with %run) directly into the interactive namespace. Very useful
1900 with %run) directly into the interactive namespace. Very useful
1894 when doing complex debugging.
1901 when doing complex debugging.
1895 (IPythonNotRunning): Changed the default None object to a dummy
1902 (IPythonNotRunning): Changed the default None object to a dummy
1896 whose attributes can be queried as well as called without
1903 whose attributes can be queried as well as called without
1897 exploding, to ease writing code which works transparently both in
1904 exploding, to ease writing code which works transparently both in
1898 and out of ipython and uses some of this API.
1905 and out of ipython and uses some of this API.
1899
1906
1900 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1907 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1901
1908
1902 * IPython/hooks.py (result_display): Fix the fact that our display
1909 * IPython/hooks.py (result_display): Fix the fact that our display
1903 hook was using str() instead of repr(), as the default python
1910 hook was using str() instead of repr(), as the default python
1904 console does. This had gone unnoticed b/c it only happened if
1911 console does. This had gone unnoticed b/c it only happened if
1905 %Pprint was off, but the inconsistency was there.
1912 %Pprint was off, but the inconsistency was there.
1906
1913
1907 2006-05-15 Ville Vainio <vivainio@gmail.com>
1914 2006-05-15 Ville Vainio <vivainio@gmail.com>
1908
1915
1909 * Oinspect.py: Only show docstring for nonexisting/binary files
1916 * Oinspect.py: Only show docstring for nonexisting/binary files
1910 when doing object??, closing ticket #62
1917 when doing object??, closing ticket #62
1911
1918
1912 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1919 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1913
1920
1914 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1921 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1915 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1922 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1916 was being released in a routine which hadn't checked if it had
1923 was being released in a routine which hadn't checked if it had
1917 been the one to acquire it.
1924 been the one to acquire it.
1918
1925
1919 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1926 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1920
1927
1921 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1928 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1922
1929
1923 2006-04-11 Ville Vainio <vivainio@gmail.com>
1930 2006-04-11 Ville Vainio <vivainio@gmail.com>
1924
1931
1925 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1932 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1926 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1933 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1927 prefilters, allowing stuff like magics and aliases in the file.
1934 prefilters, allowing stuff like magics and aliases in the file.
1928
1935
1929 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1936 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1930 added. Supported now are "%clear in" and "%clear out" (clear input and
1937 added. Supported now are "%clear in" and "%clear out" (clear input and
1931 output history, respectively). Also fixed CachedOutput.flush to
1938 output history, respectively). Also fixed CachedOutput.flush to
1932 properly flush the output cache.
1939 properly flush the output cache.
1933
1940
1934 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1941 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1935 half-success (and fail explicitly).
1942 half-success (and fail explicitly).
1936
1943
1937 2006-03-28 Ville Vainio <vivainio@gmail.com>
1944 2006-03-28 Ville Vainio <vivainio@gmail.com>
1938
1945
1939 * iplib.py: Fix quoting of aliases so that only argless ones
1946 * iplib.py: Fix quoting of aliases so that only argless ones
1940 are quoted
1947 are quoted
1941
1948
1942 2006-03-28 Ville Vainio <vivainio@gmail.com>
1949 2006-03-28 Ville Vainio <vivainio@gmail.com>
1943
1950
1944 * iplib.py: Quote aliases with spaces in the name.
1951 * iplib.py: Quote aliases with spaces in the name.
1945 "c:\program files\blah\bin" is now legal alias target.
1952 "c:\program files\blah\bin" is now legal alias target.
1946
1953
1947 * ext_rehashdir.py: Space no longer allowed as arg
1954 * ext_rehashdir.py: Space no longer allowed as arg
1948 separator, since space is legal in path names.
1955 separator, since space is legal in path names.
1949
1956
1950 2006-03-16 Ville Vainio <vivainio@gmail.com>
1957 2006-03-16 Ville Vainio <vivainio@gmail.com>
1951
1958
1952 * upgrade_dir.py: Take path.py from Extensions, correcting
1959 * upgrade_dir.py: Take path.py from Extensions, correcting
1953 %upgrade magic
1960 %upgrade magic
1954
1961
1955 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1962 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1956
1963
1957 * hooks.py: Only enclose editor binary in quotes if legal and
1964 * hooks.py: Only enclose editor binary in quotes if legal and
1958 necessary (space in the name, and is an existing file). Fixes a bug
1965 necessary (space in the name, and is an existing file). Fixes a bug
1959 reported by Zachary Pincus.
1966 reported by Zachary Pincus.
1960
1967
1961 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1968 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1962
1969
1963 * Manual: thanks to a tip on proper color handling for Emacs, by
1970 * Manual: thanks to a tip on proper color handling for Emacs, by
1964 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1971 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1965
1972
1966 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1973 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1967 by applying the provided patch. Thanks to Liu Jin
1974 by applying the provided patch. Thanks to Liu Jin
1968 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1975 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1969 XEmacs/Linux, I'm trusting the submitter that it actually helps
1976 XEmacs/Linux, I'm trusting the submitter that it actually helps
1970 under win32/GNU Emacs. Will revisit if any problems are reported.
1977 under win32/GNU Emacs. Will revisit if any problems are reported.
1971
1978
1972 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1979 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1973
1980
1974 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1981 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1975 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1982 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1976
1983
1977 2006-03-12 Ville Vainio <vivainio@gmail.com>
1984 2006-03-12 Ville Vainio <vivainio@gmail.com>
1978
1985
1979 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1986 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1980 Torsten Marek.
1987 Torsten Marek.
1981
1988
1982 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1989 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1983
1990
1984 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1991 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1985 line ranges works again.
1992 line ranges works again.
1986
1993
1987 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1994 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1988
1995
1989 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1996 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1990 and friends, after a discussion with Zach Pincus on ipython-user.
1997 and friends, after a discussion with Zach Pincus on ipython-user.
1991 I'm not 100% sure, but after thinking about it quite a bit, it may
1998 I'm not 100% sure, but after thinking about it quite a bit, it may
1992 be OK. Testing with the multithreaded shells didn't reveal any
1999 be OK. Testing with the multithreaded shells didn't reveal any
1993 problems, but let's keep an eye out.
2000 problems, but let's keep an eye out.
1994
2001
1995 In the process, I fixed a few things which were calling
2002 In the process, I fixed a few things which were calling
1996 self.InteractiveTB() directly (like safe_execfile), which is a
2003 self.InteractiveTB() directly (like safe_execfile), which is a
1997 mistake: ALL exception reporting should be done by calling
2004 mistake: ALL exception reporting should be done by calling
1998 self.showtraceback(), which handles state and tab-completion and
2005 self.showtraceback(), which handles state and tab-completion and
1999 more.
2006 more.
2000
2007
2001 2006-03-01 Ville Vainio <vivainio@gmail.com>
2008 2006-03-01 Ville Vainio <vivainio@gmail.com>
2002
2009
2003 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
2010 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
2004 To use, do "from ipipe import *".
2011 To use, do "from ipipe import *".
2005
2012
2006 2006-02-24 Ville Vainio <vivainio@gmail.com>
2013 2006-02-24 Ville Vainio <vivainio@gmail.com>
2007
2014
2008 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
2015 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
2009 "cleanly" and safely than the older upgrade mechanism.
2016 "cleanly" and safely than the older upgrade mechanism.
2010
2017
2011 2006-02-21 Ville Vainio <vivainio@gmail.com>
2018 2006-02-21 Ville Vainio <vivainio@gmail.com>
2012
2019
2013 * Magic.py: %save works again.
2020 * Magic.py: %save works again.
2014
2021
2015 2006-02-15 Ville Vainio <vivainio@gmail.com>
2022 2006-02-15 Ville Vainio <vivainio@gmail.com>
2016
2023
2017 * Magic.py: %Pprint works again
2024 * Magic.py: %Pprint works again
2018
2025
2019 * Extensions/ipy_sane_defaults.py: Provide everything provided
2026 * Extensions/ipy_sane_defaults.py: Provide everything provided
2020 in default ipythonrc, to make it possible to have a completely empty
2027 in default ipythonrc, to make it possible to have a completely empty
2021 ipythonrc (and thus completely rc-file free configuration)
2028 ipythonrc (and thus completely rc-file free configuration)
2022
2029
2023 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
2030 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
2024
2031
2025 * IPython/hooks.py (editor): quote the call to the editor command,
2032 * IPython/hooks.py (editor): quote the call to the editor command,
2026 to allow commands with spaces in them. Problem noted by watching
2033 to allow commands with spaces in them. Problem noted by watching
2027 Ian Oswald's video about textpad under win32 at
2034 Ian Oswald's video about textpad under win32 at
2028 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
2035 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
2029
2036
2030 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
2037 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
2031 describing magics (we haven't used @ for a loong time).
2038 describing magics (we haven't used @ for a loong time).
2032
2039
2033 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
2040 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
2034 contributed by marienz to close
2041 contributed by marienz to close
2035 http://www.scipy.net/roundup/ipython/issue53.
2042 http://www.scipy.net/roundup/ipython/issue53.
2036
2043
2037 2006-02-10 Ville Vainio <vivainio@gmail.com>
2044 2006-02-10 Ville Vainio <vivainio@gmail.com>
2038
2045
2039 * genutils.py: getoutput now works in win32 too
2046 * genutils.py: getoutput now works in win32 too
2040
2047
2041 * completer.py: alias and magic completion only invoked
2048 * completer.py: alias and magic completion only invoked
2042 at the first "item" in the line, to avoid "cd %store"
2049 at the first "item" in the line, to avoid "cd %store"
2043 nonsense.
2050 nonsense.
2044
2051
2045 2006-02-09 Ville Vainio <vivainio@gmail.com>
2052 2006-02-09 Ville Vainio <vivainio@gmail.com>
2046
2053
2047 * test/*: Added a unit testing framework (finally).
2054 * test/*: Added a unit testing framework (finally).
2048 '%run runtests.py' to run test_*.
2055 '%run runtests.py' to run test_*.
2049
2056
2050 * ipapi.py: Exposed runlines and set_custom_exc
2057 * ipapi.py: Exposed runlines and set_custom_exc
2051
2058
2052 2006-02-07 Ville Vainio <vivainio@gmail.com>
2059 2006-02-07 Ville Vainio <vivainio@gmail.com>
2053
2060
2054 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
2061 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
2055 instead use "f(1 2)" as before.
2062 instead use "f(1 2)" as before.
2056
2063
2057 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
2064 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
2058
2065
2059 * IPython/demo.py (IPythonDemo): Add new classes to the demo
2066 * IPython/demo.py (IPythonDemo): Add new classes to the demo
2060 facilities, for demos processed by the IPython input filter
2067 facilities, for demos processed by the IPython input filter
2061 (IPythonDemo), and for running a script one-line-at-a-time as a
2068 (IPythonDemo), and for running a script one-line-at-a-time as a
2062 demo, both for pure Python (LineDemo) and for IPython-processed
2069 demo, both for pure Python (LineDemo) and for IPython-processed
2063 input (IPythonLineDemo). After a request by Dave Kohel, from the
2070 input (IPythonLineDemo). After a request by Dave Kohel, from the
2064 SAGE team.
2071 SAGE team.
2065 (Demo.edit): added an edit() method to the demo objects, to edit
2072 (Demo.edit): added an edit() method to the demo objects, to edit
2066 the in-memory copy of the last executed block.
2073 the in-memory copy of the last executed block.
2067
2074
2068 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
2075 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
2069 processing to %edit, %macro and %save. These commands can now be
2076 processing to %edit, %macro and %save. These commands can now be
2070 invoked on the unprocessed input as it was typed by the user
2077 invoked on the unprocessed input as it was typed by the user
2071 (without any prefilters applied). After requests by the SAGE team
2078 (without any prefilters applied). After requests by the SAGE team
2072 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
2079 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
2073
2080
2074 2006-02-01 Ville Vainio <vivainio@gmail.com>
2081 2006-02-01 Ville Vainio <vivainio@gmail.com>
2075
2082
2076 * setup.py, eggsetup.py: easy_install ipython==dev works
2083 * setup.py, eggsetup.py: easy_install ipython==dev works
2077 correctly now (on Linux)
2084 correctly now (on Linux)
2078
2085
2079 * ipy_user_conf,ipmaker: user config changes, removed spurious
2086 * ipy_user_conf,ipmaker: user config changes, removed spurious
2080 warnings
2087 warnings
2081
2088
2082 * iplib: if rc.banner is string, use it as is.
2089 * iplib: if rc.banner is string, use it as is.
2083
2090
2084 * Magic: %pycat accepts a string argument and pages it's contents.
2091 * Magic: %pycat accepts a string argument and pages it's contents.
2085
2092
2086
2093
2087 2006-01-30 Ville Vainio <vivainio@gmail.com>
2094 2006-01-30 Ville Vainio <vivainio@gmail.com>
2088
2095
2089 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
2096 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
2090 Now %store and bookmarks work through PickleShare, meaning that
2097 Now %store and bookmarks work through PickleShare, meaning that
2091 concurrent access is possible and all ipython sessions see the
2098 concurrent access is possible and all ipython sessions see the
2092 same database situation all the time, instead of snapshot of
2099 same database situation all the time, instead of snapshot of
2093 the situation when the session was started. Hence, %bookmark
2100 the situation when the session was started. Hence, %bookmark
2094 results are immediately accessible from othes sessions. The database
2101 results are immediately accessible from othes sessions. The database
2095 is also available for use by user extensions. See:
2102 is also available for use by user extensions. See:
2096 http://www.python.org/pypi/pickleshare
2103 http://www.python.org/pypi/pickleshare
2097
2104
2098 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
2105 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
2099
2106
2100 * aliases can now be %store'd
2107 * aliases can now be %store'd
2101
2108
2102 * path.py moved to Extensions so that pickleshare does not need
2109 * path.py moved to Extensions so that pickleshare does not need
2103 IPython-specific import. Extensions added to pythonpath right
2110 IPython-specific import. Extensions added to pythonpath right
2104 at __init__.
2111 at __init__.
2105
2112
2106 * iplib.py: ipalias deprecated/redundant; aliases are converted and
2113 * iplib.py: ipalias deprecated/redundant; aliases are converted and
2107 called with _ip.system and the pre-transformed command string.
2114 called with _ip.system and the pre-transformed command string.
2108
2115
2109 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
2116 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
2110
2117
2111 * IPython/iplib.py (interact): Fix that we were not catching
2118 * IPython/iplib.py (interact): Fix that we were not catching
2112 KeyboardInterrupt exceptions properly. I'm not quite sure why the
2119 KeyboardInterrupt exceptions properly. I'm not quite sure why the
2113 logic here had to change, but it's fixed now.
2120 logic here had to change, but it's fixed now.
2114
2121
2115 2006-01-29 Ville Vainio <vivainio@gmail.com>
2122 2006-01-29 Ville Vainio <vivainio@gmail.com>
2116
2123
2117 * iplib.py: Try to import pyreadline on Windows.
2124 * iplib.py: Try to import pyreadline on Windows.
2118
2125
2119 2006-01-27 Ville Vainio <vivainio@gmail.com>
2126 2006-01-27 Ville Vainio <vivainio@gmail.com>
2120
2127
2121 * iplib.py: Expose ipapi as _ip in builtin namespace.
2128 * iplib.py: Expose ipapi as _ip in builtin namespace.
2122 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
2129 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
2123 and ip_set_hook (-> _ip.set_hook) redundant. % and !
2130 and ip_set_hook (-> _ip.set_hook) redundant. % and !
2124 syntax now produce _ip.* variant of the commands.
2131 syntax now produce _ip.* variant of the commands.
2125
2132
2126 * "_ip.options().autoedit_syntax = 2" automatically throws
2133 * "_ip.options().autoedit_syntax = 2" automatically throws
2127 user to editor for syntax error correction without prompting.
2134 user to editor for syntax error correction without prompting.
2128
2135
2129 2006-01-27 Ville Vainio <vivainio@gmail.com>
2136 2006-01-27 Ville Vainio <vivainio@gmail.com>
2130
2137
2131 * ipmaker.py: Give "realistic" sys.argv for scripts (without
2138 * ipmaker.py: Give "realistic" sys.argv for scripts (without
2132 'ipython' at argv[0]) executed through command line.
2139 'ipython' at argv[0]) executed through command line.
2133 NOTE: this DEPRECATES calling ipython with multiple scripts
2140 NOTE: this DEPRECATES calling ipython with multiple scripts
2134 ("ipython a.py b.py c.py")
2141 ("ipython a.py b.py c.py")
2135
2142
2136 * iplib.py, hooks.py: Added configurable input prefilter,
2143 * iplib.py, hooks.py: Added configurable input prefilter,
2137 named 'input_prefilter'. See ext_rescapture.py for example
2144 named 'input_prefilter'. See ext_rescapture.py for example
2138 usage.
2145 usage.
2139
2146
2140 * ext_rescapture.py, Magic.py: Better system command output capture
2147 * ext_rescapture.py, Magic.py: Better system command output capture
2141 through 'var = !ls' (deprecates user-visible %sc). Same notation
2148 through 'var = !ls' (deprecates user-visible %sc). Same notation
2142 applies for magics, 'var = %alias' assigns alias list to var.
2149 applies for magics, 'var = %alias' assigns alias list to var.
2143
2150
2144 * ipapi.py: added meta() for accessing extension-usable data store.
2151 * ipapi.py: added meta() for accessing extension-usable data store.
2145
2152
2146 * iplib.py: added InteractiveShell.getapi(). New magics should be
2153 * iplib.py: added InteractiveShell.getapi(). New magics should be
2147 written doing self.getapi() instead of using the shell directly.
2154 written doing self.getapi() instead of using the shell directly.
2148
2155
2149 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
2156 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
2150 %store foo >> ~/myfoo.txt to store variables to files (in clean
2157 %store foo >> ~/myfoo.txt to store variables to files (in clean
2151 textual form, not a restorable pickle).
2158 textual form, not a restorable pickle).
2152
2159
2153 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
2160 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
2154
2161
2155 * usage.py, Magic.py: added %quickref
2162 * usage.py, Magic.py: added %quickref
2156
2163
2157 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
2164 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
2158
2165
2159 * GetoptErrors when invoking magics etc. with wrong args
2166 * GetoptErrors when invoking magics etc. with wrong args
2160 are now more helpful:
2167 are now more helpful:
2161 GetoptError: option -l not recognized (allowed: "qb" )
2168 GetoptError: option -l not recognized (allowed: "qb" )
2162
2169
2163 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
2170 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
2164
2171
2165 * IPython/demo.py (Demo.show): Flush stdout after each block, so
2172 * IPython/demo.py (Demo.show): Flush stdout after each block, so
2166 computationally intensive blocks don't appear to stall the demo.
2173 computationally intensive blocks don't appear to stall the demo.
2167
2174
2168 2006-01-24 Ville Vainio <vivainio@gmail.com>
2175 2006-01-24 Ville Vainio <vivainio@gmail.com>
2169
2176
2170 * iplib.py, hooks.py: 'result_display' hook can return a non-None
2177 * iplib.py, hooks.py: 'result_display' hook can return a non-None
2171 value to manipulate resulting history entry.
2178 value to manipulate resulting history entry.
2172
2179
2173 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
2180 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
2174 to instance methods of IPApi class, to make extending an embedded
2181 to instance methods of IPApi class, to make extending an embedded
2175 IPython feasible. See ext_rehashdir.py for example usage.
2182 IPython feasible. See ext_rehashdir.py for example usage.
2176
2183
2177 * Merged 1071-1076 from branches/0.7.1
2184 * Merged 1071-1076 from branches/0.7.1
2178
2185
2179
2186
2180 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
2187 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
2181
2188
2182 * tools/release (daystamp): Fix build tools to use the new
2189 * tools/release (daystamp): Fix build tools to use the new
2183 eggsetup.py script to build lightweight eggs.
2190 eggsetup.py script to build lightweight eggs.
2184
2191
2185 * Applied changesets 1062 and 1064 before 0.7.1 release.
2192 * Applied changesets 1062 and 1064 before 0.7.1 release.
2186
2193
2187 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
2194 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
2188 see the raw input history (without conversions like %ls ->
2195 see the raw input history (without conversions like %ls ->
2189 ipmagic("ls")). After a request from W. Stein, SAGE
2196 ipmagic("ls")). After a request from W. Stein, SAGE
2190 (http://modular.ucsd.edu/sage) developer. This information is
2197 (http://modular.ucsd.edu/sage) developer. This information is
2191 stored in the input_hist_raw attribute of the IPython instance, so
2198 stored in the input_hist_raw attribute of the IPython instance, so
2192 developers can access it if needed (it's an InputList instance).
2199 developers can access it if needed (it's an InputList instance).
2193
2200
2194 * Versionstring = 0.7.2.svn
2201 * Versionstring = 0.7.2.svn
2195
2202
2196 * eggsetup.py: A separate script for constructing eggs, creates
2203 * eggsetup.py: A separate script for constructing eggs, creates
2197 proper launch scripts even on Windows (an .exe file in
2204 proper launch scripts even on Windows (an .exe file in
2198 \python24\scripts).
2205 \python24\scripts).
2199
2206
2200 * ipapi.py: launch_new_instance, launch entry point needed for the
2207 * ipapi.py: launch_new_instance, launch entry point needed for the
2201 egg.
2208 egg.
2202
2209
2203 2006-01-23 Ville Vainio <vivainio@gmail.com>
2210 2006-01-23 Ville Vainio <vivainio@gmail.com>
2204
2211
2205 * Added %cpaste magic for pasting python code
2212 * Added %cpaste magic for pasting python code
2206
2213
2207 2006-01-22 Ville Vainio <vivainio@gmail.com>
2214 2006-01-22 Ville Vainio <vivainio@gmail.com>
2208
2215
2209 * Merge from branches/0.7.1 into trunk, revs 1052-1057
2216 * Merge from branches/0.7.1 into trunk, revs 1052-1057
2210
2217
2211 * Versionstring = 0.7.2.svn
2218 * Versionstring = 0.7.2.svn
2212
2219
2213 * eggsetup.py: A separate script for constructing eggs, creates
2220 * eggsetup.py: A separate script for constructing eggs, creates
2214 proper launch scripts even on Windows (an .exe file in
2221 proper launch scripts even on Windows (an .exe file in
2215 \python24\scripts).
2222 \python24\scripts).
2216
2223
2217 * ipapi.py: launch_new_instance, launch entry point needed for the
2224 * ipapi.py: launch_new_instance, launch entry point needed for the
2218 egg.
2225 egg.
2219
2226
2220 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
2227 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
2221
2228
2222 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
2229 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
2223 %pfile foo would print the file for foo even if it was a binary.
2230 %pfile foo would print the file for foo even if it was a binary.
2224 Now, extensions '.so' and '.dll' are skipped.
2231 Now, extensions '.so' and '.dll' are skipped.
2225
2232
2226 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
2233 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
2227 bug, where macros would fail in all threaded modes. I'm not 100%
2234 bug, where macros would fail in all threaded modes. I'm not 100%
2228 sure, so I'm going to put out an rc instead of making a release
2235 sure, so I'm going to put out an rc instead of making a release
2229 today, and wait for feedback for at least a few days.
2236 today, and wait for feedback for at least a few days.
2230
2237
2231 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
2238 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
2232 it...) the handling of pasting external code with autoindent on.
2239 it...) the handling of pasting external code with autoindent on.
2233 To get out of a multiline input, the rule will appear for most
2240 To get out of a multiline input, the rule will appear for most
2234 users unchanged: two blank lines or change the indent level
2241 users unchanged: two blank lines or change the indent level
2235 proposed by IPython. But there is a twist now: you can
2242 proposed by IPython. But there is a twist now: you can
2236 add/subtract only *one or two spaces*. If you add/subtract three
2243 add/subtract only *one or two spaces*. If you add/subtract three
2237 or more (unless you completely delete the line), IPython will
2244 or more (unless you completely delete the line), IPython will
2238 accept that line, and you'll need to enter a second one of pure
2245 accept that line, and you'll need to enter a second one of pure
2239 whitespace. I know it sounds complicated, but I can't find a
2246 whitespace. I know it sounds complicated, but I can't find a
2240 different solution that covers all the cases, with the right
2247 different solution that covers all the cases, with the right
2241 heuristics. Hopefully in actual use, nobody will really notice
2248 heuristics. Hopefully in actual use, nobody will really notice
2242 all these strange rules and things will 'just work'.
2249 all these strange rules and things will 'just work'.
2243
2250
2244 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
2251 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
2245
2252
2246 * IPython/iplib.py (interact): catch exceptions which can be
2253 * IPython/iplib.py (interact): catch exceptions which can be
2247 triggered asynchronously by signal handlers. Thanks to an
2254 triggered asynchronously by signal handlers. Thanks to an
2248 automatic crash report, submitted by Colin Kingsley
2255 automatic crash report, submitted by Colin Kingsley
2249 <tercel-AT-gentoo.org>.
2256 <tercel-AT-gentoo.org>.
2250
2257
2251 2006-01-20 Ville Vainio <vivainio@gmail.com>
2258 2006-01-20 Ville Vainio <vivainio@gmail.com>
2252
2259
2253 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
2260 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
2254 (%rehashdir, very useful, try it out) of how to extend ipython
2261 (%rehashdir, very useful, try it out) of how to extend ipython
2255 with new magics. Also added Extensions dir to pythonpath to make
2262 with new magics. Also added Extensions dir to pythonpath to make
2256 importing extensions easy.
2263 importing extensions easy.
2257
2264
2258 * %store now complains when trying to store interactively declared
2265 * %store now complains when trying to store interactively declared
2259 classes / instances of those classes.
2266 classes / instances of those classes.
2260
2267
2261 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
2268 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
2262 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
2269 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
2263 if they exist, and ipy_user_conf.py with some defaults is created for
2270 if they exist, and ipy_user_conf.py with some defaults is created for
2264 the user.
2271 the user.
2265
2272
2266 * Startup rehashing done by the config file, not InterpreterExec.
2273 * Startup rehashing done by the config file, not InterpreterExec.
2267 This means system commands are available even without selecting the
2274 This means system commands are available even without selecting the
2268 pysh profile. It's the sensible default after all.
2275 pysh profile. It's the sensible default after all.
2269
2276
2270 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
2277 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
2271
2278
2272 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
2279 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
2273 multiline code with autoindent on working. But I am really not
2280 multiline code with autoindent on working. But I am really not
2274 sure, so this needs more testing. Will commit a debug-enabled
2281 sure, so this needs more testing. Will commit a debug-enabled
2275 version for now, while I test it some more, so that Ville and
2282 version for now, while I test it some more, so that Ville and
2276 others may also catch any problems. Also made
2283 others may also catch any problems. Also made
2277 self.indent_current_str() a method, to ensure that there's no
2284 self.indent_current_str() a method, to ensure that there's no
2278 chance of the indent space count and the corresponding string
2285 chance of the indent space count and the corresponding string
2279 falling out of sync. All code needing the string should just call
2286 falling out of sync. All code needing the string should just call
2280 the method.
2287 the method.
2281
2288
2282 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2289 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2283
2290
2284 * IPython/Magic.py (magic_edit): fix check for when users don't
2291 * IPython/Magic.py (magic_edit): fix check for when users don't
2285 save their output files, the try/except was in the wrong section.
2292 save their output files, the try/except was in the wrong section.
2286
2293
2287 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2294 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2288
2295
2289 * IPython/Magic.py (magic_run): fix __file__ global missing from
2296 * IPython/Magic.py (magic_run): fix __file__ global missing from
2290 script's namespace when executed via %run. After a report by
2297 script's namespace when executed via %run. After a report by
2291 Vivian.
2298 Vivian.
2292
2299
2293 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
2300 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
2294 when using python 2.4. The parent constructor changed in 2.4, and
2301 when using python 2.4. The parent constructor changed in 2.4, and
2295 we need to track it directly (we can't call it, as it messes up
2302 we need to track it directly (we can't call it, as it messes up
2296 readline and tab-completion inside our pdb would stop working).
2303 readline and tab-completion inside our pdb would stop working).
2297 After a bug report by R. Bernstein <rocky-AT-panix.com>.
2304 After a bug report by R. Bernstein <rocky-AT-panix.com>.
2298
2305
2299 2006-01-16 Ville Vainio <vivainio@gmail.com>
2306 2006-01-16 Ville Vainio <vivainio@gmail.com>
2300
2307
2301 * Ipython/magic.py: Reverted back to old %edit functionality
2308 * Ipython/magic.py: Reverted back to old %edit functionality
2302 that returns file contents on exit.
2309 that returns file contents on exit.
2303
2310
2304 * IPython/path.py: Added Jason Orendorff's "path" module to
2311 * IPython/path.py: Added Jason Orendorff's "path" module to
2305 IPython tree, http://www.jorendorff.com/articles/python/path/.
2312 IPython tree, http://www.jorendorff.com/articles/python/path/.
2306 You can get path objects conveniently through %sc, and !!, e.g.:
2313 You can get path objects conveniently through %sc, and !!, e.g.:
2307 sc files=ls
2314 sc files=ls
2308 for p in files.paths: # or files.p
2315 for p in files.paths: # or files.p
2309 print p,p.mtime
2316 print p,p.mtime
2310
2317
2311 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
2318 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
2312 now work again without considering the exclusion regexp -
2319 now work again without considering the exclusion regexp -
2313 hence, things like ',foo my/path' turn to 'foo("my/path")'
2320 hence, things like ',foo my/path' turn to 'foo("my/path")'
2314 instead of syntax error.
2321 instead of syntax error.
2315
2322
2316
2323
2317 2006-01-14 Ville Vainio <vivainio@gmail.com>
2324 2006-01-14 Ville Vainio <vivainio@gmail.com>
2318
2325
2319 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
2326 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
2320 ipapi decorators for python 2.4 users, options() provides access to rc
2327 ipapi decorators for python 2.4 users, options() provides access to rc
2321 data.
2328 data.
2322
2329
2323 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
2330 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
2324 as path separators (even on Linux ;-). Space character after
2331 as path separators (even on Linux ;-). Space character after
2325 backslash (as yielded by tab completer) is still space;
2332 backslash (as yielded by tab completer) is still space;
2326 "%cd long\ name" works as expected.
2333 "%cd long\ name" works as expected.
2327
2334
2328 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
2335 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
2329 as "chain of command", with priority. API stays the same,
2336 as "chain of command", with priority. API stays the same,
2330 TryNext exception raised by a hook function signals that
2337 TryNext exception raised by a hook function signals that
2331 current hook failed and next hook should try handling it, as
2338 current hook failed and next hook should try handling it, as
2332 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
2339 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
2333 requested configurable display hook, which is now implemented.
2340 requested configurable display hook, which is now implemented.
2334
2341
2335 2006-01-13 Ville Vainio <vivainio@gmail.com>
2342 2006-01-13 Ville Vainio <vivainio@gmail.com>
2336
2343
2337 * IPython/platutils*.py: platform specific utility functions,
2344 * IPython/platutils*.py: platform specific utility functions,
2338 so far only set_term_title is implemented (change terminal
2345 so far only set_term_title is implemented (change terminal
2339 label in windowing systems). %cd now changes the title to
2346 label in windowing systems). %cd now changes the title to
2340 current dir.
2347 current dir.
2341
2348
2342 * IPython/Release.py: Added myself to "authors" list,
2349 * IPython/Release.py: Added myself to "authors" list,
2343 had to create new files.
2350 had to create new files.
2344
2351
2345 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
2352 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
2346 shell escape; not a known bug but had potential to be one in the
2353 shell escape; not a known bug but had potential to be one in the
2347 future.
2354 future.
2348
2355
2349 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
2356 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
2350 extension API for IPython! See the module for usage example. Fix
2357 extension API for IPython! See the module for usage example. Fix
2351 OInspect for docstring-less magic functions.
2358 OInspect for docstring-less magic functions.
2352
2359
2353
2360
2354 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2361 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2355
2362
2356 * IPython/iplib.py (raw_input): temporarily deactivate all
2363 * IPython/iplib.py (raw_input): temporarily deactivate all
2357 attempts at allowing pasting of code with autoindent on. It
2364 attempts at allowing pasting of code with autoindent on. It
2358 introduced bugs (reported by Prabhu) and I can't seem to find a
2365 introduced bugs (reported by Prabhu) and I can't seem to find a
2359 robust combination which works in all cases. Will have to revisit
2366 robust combination which works in all cases. Will have to revisit
2360 later.
2367 later.
2361
2368
2362 * IPython/genutils.py: remove isspace() function. We've dropped
2369 * IPython/genutils.py: remove isspace() function. We've dropped
2363 2.2 compatibility, so it's OK to use the string method.
2370 2.2 compatibility, so it's OK to use the string method.
2364
2371
2365 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2372 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2366
2373
2367 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
2374 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
2368 matching what NOT to autocall on, to include all python binary
2375 matching what NOT to autocall on, to include all python binary
2369 operators (including things like 'and', 'or', 'is' and 'in').
2376 operators (including things like 'and', 'or', 'is' and 'in').
2370 Prompted by a bug report on 'foo & bar', but I realized we had
2377 Prompted by a bug report on 'foo & bar', but I realized we had
2371 many more potential bug cases with other operators. The regexp is
2378 many more potential bug cases with other operators. The regexp is
2372 self.re_exclude_auto, it's fairly commented.
2379 self.re_exclude_auto, it's fairly commented.
2373
2380
2374 2006-01-12 Ville Vainio <vivainio@gmail.com>
2381 2006-01-12 Ville Vainio <vivainio@gmail.com>
2375
2382
2376 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
2383 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
2377 Prettified and hardened string/backslash quoting with ipsystem(),
2384 Prettified and hardened string/backslash quoting with ipsystem(),
2378 ipalias() and ipmagic(). Now even \ characters are passed to
2385 ipalias() and ipmagic(). Now even \ characters are passed to
2379 %magics, !shell escapes and aliases exactly as they are in the
2386 %magics, !shell escapes and aliases exactly as they are in the
2380 ipython command line. Should improve backslash experience,
2387 ipython command line. Should improve backslash experience,
2381 particularly in Windows (path delimiter for some commands that
2388 particularly in Windows (path delimiter for some commands that
2382 won't understand '/'), but Unix benefits as well (regexps). %cd
2389 won't understand '/'), but Unix benefits as well (regexps). %cd
2383 magic still doesn't support backslash path delimiters, though. Also
2390 magic still doesn't support backslash path delimiters, though. Also
2384 deleted all pretense of supporting multiline command strings in
2391 deleted all pretense of supporting multiline command strings in
2385 !system or %magic commands. Thanks to Jerry McRae for suggestions.
2392 !system or %magic commands. Thanks to Jerry McRae for suggestions.
2386
2393
2387 * doc/build_doc_instructions.txt added. Documentation on how to
2394 * doc/build_doc_instructions.txt added. Documentation on how to
2388 use doc/update_manual.py, added yesterday. Both files contributed
2395 use doc/update_manual.py, added yesterday. Both files contributed
2389 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
2396 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
2390 doc/*.sh for deprecation at a later date.
2397 doc/*.sh for deprecation at a later date.
2391
2398
2392 * /ipython.py Added ipython.py to root directory for
2399 * /ipython.py Added ipython.py to root directory for
2393 zero-installation (tar xzvf ipython.tgz; cd ipython; python
2400 zero-installation (tar xzvf ipython.tgz; cd ipython; python
2394 ipython.py) and development convenience (no need to keep doing
2401 ipython.py) and development convenience (no need to keep doing
2395 "setup.py install" between changes).
2402 "setup.py install" between changes).
2396
2403
2397 * Made ! and !! shell escapes work (again) in multiline expressions:
2404 * Made ! and !! shell escapes work (again) in multiline expressions:
2398 if 1:
2405 if 1:
2399 !ls
2406 !ls
2400 !!ls
2407 !!ls
2401
2408
2402 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2409 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2403
2410
2404 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
2411 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
2405 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
2412 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
2406 module in case-insensitive installation. Was causing crashes
2413 module in case-insensitive installation. Was causing crashes
2407 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
2414 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
2408
2415
2409 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
2416 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
2410 <marienz-AT-gentoo.org>, closes
2417 <marienz-AT-gentoo.org>, closes
2411 http://www.scipy.net/roundup/ipython/issue51.
2418 http://www.scipy.net/roundup/ipython/issue51.
2412
2419
2413 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2420 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2414
2421
2415 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
2422 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
2416 problem of excessive CPU usage under *nix and keyboard lag under
2423 problem of excessive CPU usage under *nix and keyboard lag under
2417 win32.
2424 win32.
2418
2425
2419 2006-01-10 *** Released version 0.7.0
2426 2006-01-10 *** Released version 0.7.0
2420
2427
2421 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2428 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2422
2429
2423 * IPython/Release.py (revision): tag version number to 0.7.0,
2430 * IPython/Release.py (revision): tag version number to 0.7.0,
2424 ready for release.
2431 ready for release.
2425
2432
2426 * IPython/Magic.py (magic_edit): Add print statement to %edit so
2433 * IPython/Magic.py (magic_edit): Add print statement to %edit so
2427 it informs the user of the name of the temp. file used. This can
2434 it informs the user of the name of the temp. file used. This can
2428 help if you decide later to reuse that same file, so you know
2435 help if you decide later to reuse that same file, so you know
2429 where to copy the info from.
2436 where to copy the info from.
2430
2437
2431 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2438 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2432
2439
2433 * setup_bdist_egg.py: little script to build an egg. Added
2440 * setup_bdist_egg.py: little script to build an egg. Added
2434 support in the release tools as well.
2441 support in the release tools as well.
2435
2442
2436 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
2443 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
2437
2444
2438 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
2445 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
2439 version selection (new -wxversion command line and ipythonrc
2446 version selection (new -wxversion command line and ipythonrc
2440 parameter). Patch contributed by Arnd Baecker
2447 parameter). Patch contributed by Arnd Baecker
2441 <arnd.baecker-AT-web.de>.
2448 <arnd.baecker-AT-web.de>.
2442
2449
2443 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2450 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2444 embedded instances, for variables defined at the interactive
2451 embedded instances, for variables defined at the interactive
2445 prompt of the embedded ipython. Reported by Arnd.
2452 prompt of the embedded ipython. Reported by Arnd.
2446
2453
2447 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
2454 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
2448 it can be used as a (stateful) toggle, or with a direct parameter.
2455 it can be used as a (stateful) toggle, or with a direct parameter.
2449
2456
2450 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
2457 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
2451 could be triggered in certain cases and cause the traceback
2458 could be triggered in certain cases and cause the traceback
2452 printer not to work.
2459 printer not to work.
2453
2460
2454 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
2461 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
2455
2462
2456 * IPython/iplib.py (_should_recompile): Small fix, closes
2463 * IPython/iplib.py (_should_recompile): Small fix, closes
2457 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
2464 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
2458
2465
2459 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
2466 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
2460
2467
2461 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
2468 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
2462 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
2469 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
2463 Moad for help with tracking it down.
2470 Moad for help with tracking it down.
2464
2471
2465 * IPython/iplib.py (handle_auto): fix autocall handling for
2472 * IPython/iplib.py (handle_auto): fix autocall handling for
2466 objects which support BOTH __getitem__ and __call__ (so that f [x]
2473 objects which support BOTH __getitem__ and __call__ (so that f [x]
2467 is left alone, instead of becoming f([x]) automatically).
2474 is left alone, instead of becoming f([x]) automatically).
2468
2475
2469 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
2476 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
2470 Ville's patch.
2477 Ville's patch.
2471
2478
2472 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
2479 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
2473
2480
2474 * IPython/iplib.py (handle_auto): changed autocall semantics to
2481 * IPython/iplib.py (handle_auto): changed autocall semantics to
2475 include 'smart' mode, where the autocall transformation is NOT
2482 include 'smart' mode, where the autocall transformation is NOT
2476 applied if there are no arguments on the line. This allows you to
2483 applied if there are no arguments on the line. This allows you to
2477 just type 'foo' if foo is a callable to see its internal form,
2484 just type 'foo' if foo is a callable to see its internal form,
2478 instead of having it called with no arguments (typically a
2485 instead of having it called with no arguments (typically a
2479 mistake). The old 'full' autocall still exists: for that, you
2486 mistake). The old 'full' autocall still exists: for that, you
2480 need to set the 'autocall' parameter to 2 in your ipythonrc file.
2487 need to set the 'autocall' parameter to 2 in your ipythonrc file.
2481
2488
2482 * IPython/completer.py (Completer.attr_matches): add
2489 * IPython/completer.py (Completer.attr_matches): add
2483 tab-completion support for Enthoughts' traits. After a report by
2490 tab-completion support for Enthoughts' traits. After a report by
2484 Arnd and a patch by Prabhu.
2491 Arnd and a patch by Prabhu.
2485
2492
2486 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
2493 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
2487
2494
2488 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
2495 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
2489 Schmolck's patch to fix inspect.getinnerframes().
2496 Schmolck's patch to fix inspect.getinnerframes().
2490
2497
2491 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
2498 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
2492 for embedded instances, regarding handling of namespaces and items
2499 for embedded instances, regarding handling of namespaces and items
2493 added to the __builtin__ one. Multiple embedded instances and
2500 added to the __builtin__ one. Multiple embedded instances and
2494 recursive embeddings should work better now (though I'm not sure
2501 recursive embeddings should work better now (though I'm not sure
2495 I've got all the corner cases fixed, that code is a bit of a brain
2502 I've got all the corner cases fixed, that code is a bit of a brain
2496 twister).
2503 twister).
2497
2504
2498 * IPython/Magic.py (magic_edit): added support to edit in-memory
2505 * IPython/Magic.py (magic_edit): added support to edit in-memory
2499 macros (automatically creates the necessary temp files). %edit
2506 macros (automatically creates the necessary temp files). %edit
2500 also doesn't return the file contents anymore, it's just noise.
2507 also doesn't return the file contents anymore, it's just noise.
2501
2508
2502 * IPython/completer.py (Completer.attr_matches): revert change to
2509 * IPython/completer.py (Completer.attr_matches): revert change to
2503 complete only on attributes listed in __all__. I realized it
2510 complete only on attributes listed in __all__. I realized it
2504 cripples the tab-completion system as a tool for exploring the
2511 cripples the tab-completion system as a tool for exploring the
2505 internals of unknown libraries (it renders any non-__all__
2512 internals of unknown libraries (it renders any non-__all__
2506 attribute off-limits). I got bit by this when trying to see
2513 attribute off-limits). I got bit by this when trying to see
2507 something inside the dis module.
2514 something inside the dis module.
2508
2515
2509 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2516 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2510
2517
2511 * IPython/iplib.py (InteractiveShell.__init__): add .meta
2518 * IPython/iplib.py (InteractiveShell.__init__): add .meta
2512 namespace for users and extension writers to hold data in. This
2519 namespace for users and extension writers to hold data in. This
2513 follows the discussion in
2520 follows the discussion in
2514 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
2521 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
2515
2522
2516 * IPython/completer.py (IPCompleter.complete): small patch to help
2523 * IPython/completer.py (IPCompleter.complete): small patch to help
2517 tab-completion under Emacs, after a suggestion by John Barnard
2524 tab-completion under Emacs, after a suggestion by John Barnard
2518 <barnarj-AT-ccf.org>.
2525 <barnarj-AT-ccf.org>.
2519
2526
2520 * IPython/Magic.py (Magic.extract_input_slices): added support for
2527 * IPython/Magic.py (Magic.extract_input_slices): added support for
2521 the slice notation in magics to use N-M to represent numbers N...M
2528 the slice notation in magics to use N-M to represent numbers N...M
2522 (closed endpoints). This is used by %macro and %save.
2529 (closed endpoints). This is used by %macro and %save.
2523
2530
2524 * IPython/completer.py (Completer.attr_matches): for modules which
2531 * IPython/completer.py (Completer.attr_matches): for modules which
2525 define __all__, complete only on those. After a patch by Jeffrey
2532 define __all__, complete only on those. After a patch by Jeffrey
2526 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
2533 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
2527 speed up this routine.
2534 speed up this routine.
2528
2535
2529 * IPython/Logger.py (Logger.log): fix a history handling bug. I
2536 * IPython/Logger.py (Logger.log): fix a history handling bug. I
2530 don't know if this is the end of it, but the behavior now is
2537 don't know if this is the end of it, but the behavior now is
2531 certainly much more correct. Note that coupled with macros,
2538 certainly much more correct. Note that coupled with macros,
2532 slightly surprising (at first) behavior may occur: a macro will in
2539 slightly surprising (at first) behavior may occur: a macro will in
2533 general expand to multiple lines of input, so upon exiting, the
2540 general expand to multiple lines of input, so upon exiting, the
2534 in/out counters will both be bumped by the corresponding amount
2541 in/out counters will both be bumped by the corresponding amount
2535 (as if the macro's contents had been typed interactively). Typing
2542 (as if the macro's contents had been typed interactively). Typing
2536 %hist will reveal the intermediate (silently processed) lines.
2543 %hist will reveal the intermediate (silently processed) lines.
2537
2544
2538 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
2545 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
2539 pickle to fail (%run was overwriting __main__ and not restoring
2546 pickle to fail (%run was overwriting __main__ and not restoring
2540 it, but pickle relies on __main__ to operate).
2547 it, but pickle relies on __main__ to operate).
2541
2548
2542 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
2549 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
2543 using properties, but forgot to make the main InteractiveShell
2550 using properties, but forgot to make the main InteractiveShell
2544 class a new-style class. Properties fail silently, and
2551 class a new-style class. Properties fail silently, and
2545 mysteriously, with old-style class (getters work, but
2552 mysteriously, with old-style class (getters work, but
2546 setters don't do anything).
2553 setters don't do anything).
2547
2554
2548 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
2555 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
2549
2556
2550 * IPython/Magic.py (magic_history): fix history reporting bug (I
2557 * IPython/Magic.py (magic_history): fix history reporting bug (I
2551 know some nasties are still there, I just can't seem to find a
2558 know some nasties are still there, I just can't seem to find a
2552 reproducible test case to track them down; the input history is
2559 reproducible test case to track them down; the input history is
2553 falling out of sync...)
2560 falling out of sync...)
2554
2561
2555 * IPython/iplib.py (handle_shell_escape): fix bug where both
2562 * IPython/iplib.py (handle_shell_escape): fix bug where both
2556 aliases and system accesses where broken for indented code (such
2563 aliases and system accesses where broken for indented code (such
2557 as loops).
2564 as loops).
2558
2565
2559 * IPython/genutils.py (shell): fix small but critical bug for
2566 * IPython/genutils.py (shell): fix small but critical bug for
2560 win32 system access.
2567 win32 system access.
2561
2568
2562 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2569 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2563
2570
2564 * IPython/iplib.py (showtraceback): remove use of the
2571 * IPython/iplib.py (showtraceback): remove use of the
2565 sys.last_{type/value/traceback} structures, which are non
2572 sys.last_{type/value/traceback} structures, which are non
2566 thread-safe.
2573 thread-safe.
2567 (_prefilter): change control flow to ensure that we NEVER
2574 (_prefilter): change control flow to ensure that we NEVER
2568 introspect objects when autocall is off. This will guarantee that
2575 introspect objects when autocall is off. This will guarantee that
2569 having an input line of the form 'x.y', where access to attribute
2576 having an input line of the form 'x.y', where access to attribute
2570 'y' has side effects, doesn't trigger the side effect TWICE. It
2577 'y' has side effects, doesn't trigger the side effect TWICE. It
2571 is important to note that, with autocall on, these side effects
2578 is important to note that, with autocall on, these side effects
2572 can still happen.
2579 can still happen.
2573 (ipsystem): new builtin, to complete the ip{magic/alias/system}
2580 (ipsystem): new builtin, to complete the ip{magic/alias/system}
2574 trio. IPython offers these three kinds of special calls which are
2581 trio. IPython offers these three kinds of special calls which are
2575 not python code, and it's a good thing to have their call method
2582 not python code, and it's a good thing to have their call method
2576 be accessible as pure python functions (not just special syntax at
2583 be accessible as pure python functions (not just special syntax at
2577 the command line). It gives us a better internal implementation
2584 the command line). It gives us a better internal implementation
2578 structure, as well as exposing these for user scripting more
2585 structure, as well as exposing these for user scripting more
2579 cleanly.
2586 cleanly.
2580
2587
2581 * IPython/macro.py (Macro.__init__): moved macros to a standalone
2588 * IPython/macro.py (Macro.__init__): moved macros to a standalone
2582 file. Now that they'll be more likely to be used with the
2589 file. Now that they'll be more likely to be used with the
2583 persistance system (%store), I want to make sure their module path
2590 persistance system (%store), I want to make sure their module path
2584 doesn't change in the future, so that we don't break things for
2591 doesn't change in the future, so that we don't break things for
2585 users' persisted data.
2592 users' persisted data.
2586
2593
2587 * IPython/iplib.py (autoindent_update): move indentation
2594 * IPython/iplib.py (autoindent_update): move indentation
2588 management into the _text_ processing loop, not the keyboard
2595 management into the _text_ processing loop, not the keyboard
2589 interactive one. This is necessary to correctly process non-typed
2596 interactive one. This is necessary to correctly process non-typed
2590 multiline input (such as macros).
2597 multiline input (such as macros).
2591
2598
2592 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
2599 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
2593 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
2600 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
2594 which was producing problems in the resulting manual.
2601 which was producing problems in the resulting manual.
2595 (magic_whos): improve reporting of instances (show their class,
2602 (magic_whos): improve reporting of instances (show their class,
2596 instead of simply printing 'instance' which isn't terribly
2603 instead of simply printing 'instance' which isn't terribly
2597 informative).
2604 informative).
2598
2605
2599 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
2606 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
2600 (minor mods) to support network shares under win32.
2607 (minor mods) to support network shares under win32.
2601
2608
2602 * IPython/winconsole.py (get_console_size): add new winconsole
2609 * IPython/winconsole.py (get_console_size): add new winconsole
2603 module and fixes to page_dumb() to improve its behavior under
2610 module and fixes to page_dumb() to improve its behavior under
2604 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
2611 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
2605
2612
2606 * IPython/Magic.py (Macro): simplified Macro class to just
2613 * IPython/Magic.py (Macro): simplified Macro class to just
2607 subclass list. We've had only 2.2 compatibility for a very long
2614 subclass list. We've had only 2.2 compatibility for a very long
2608 time, yet I was still avoiding subclassing the builtin types. No
2615 time, yet I was still avoiding subclassing the builtin types. No
2609 more (I'm also starting to use properties, though I won't shift to
2616 more (I'm also starting to use properties, though I won't shift to
2610 2.3-specific features quite yet).
2617 2.3-specific features quite yet).
2611 (magic_store): added Ville's patch for lightweight variable
2618 (magic_store): added Ville's patch for lightweight variable
2612 persistence, after a request on the user list by Matt Wilkie
2619 persistence, after a request on the user list by Matt Wilkie
2613 <maphew-AT-gmail.com>. The new %store magic's docstring has full
2620 <maphew-AT-gmail.com>. The new %store magic's docstring has full
2614 details.
2621 details.
2615
2622
2616 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2623 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2617 changed the default logfile name from 'ipython.log' to
2624 changed the default logfile name from 'ipython.log' to
2618 'ipython_log.py'. These logs are real python files, and now that
2625 'ipython_log.py'. These logs are real python files, and now that
2619 we have much better multiline support, people are more likely to
2626 we have much better multiline support, people are more likely to
2620 want to use them as such. Might as well name them correctly.
2627 want to use them as such. Might as well name them correctly.
2621
2628
2622 * IPython/Magic.py: substantial cleanup. While we can't stop
2629 * IPython/Magic.py: substantial cleanup. While we can't stop
2623 using magics as mixins, due to the existing customizations 'out
2630 using magics as mixins, due to the existing customizations 'out
2624 there' which rely on the mixin naming conventions, at least I
2631 there' which rely on the mixin naming conventions, at least I
2625 cleaned out all cross-class name usage. So once we are OK with
2632 cleaned out all cross-class name usage. So once we are OK with
2626 breaking compatibility, the two systems can be separated.
2633 breaking compatibility, the two systems can be separated.
2627
2634
2628 * IPython/Logger.py: major cleanup. This one is NOT a mixin
2635 * IPython/Logger.py: major cleanup. This one is NOT a mixin
2629 anymore, and the class is a fair bit less hideous as well. New
2636 anymore, and the class is a fair bit less hideous as well. New
2630 features were also introduced: timestamping of input, and logging
2637 features were also introduced: timestamping of input, and logging
2631 of output results. These are user-visible with the -t and -o
2638 of output results. These are user-visible with the -t and -o
2632 options to %logstart. Closes
2639 options to %logstart. Closes
2633 http://www.scipy.net/roundup/ipython/issue11 and a request by
2640 http://www.scipy.net/roundup/ipython/issue11 and a request by
2634 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
2641 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
2635
2642
2636 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2643 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2637
2644
2638 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
2645 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
2639 better handle backslashes in paths. See the thread 'More Windows
2646 better handle backslashes in paths. See the thread 'More Windows
2640 questions part 2 - \/ characters revisited' on the iypthon user
2647 questions part 2 - \/ characters revisited' on the iypthon user
2641 list:
2648 list:
2642 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
2649 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
2643
2650
2644 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
2651 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
2645
2652
2646 (InteractiveShell.__init__): change threaded shells to not use the
2653 (InteractiveShell.__init__): change threaded shells to not use the
2647 ipython crash handler. This was causing more problems than not,
2654 ipython crash handler. This was causing more problems than not,
2648 as exceptions in the main thread (GUI code, typically) would
2655 as exceptions in the main thread (GUI code, typically) would
2649 always show up as a 'crash', when they really weren't.
2656 always show up as a 'crash', when they really weren't.
2650
2657
2651 The colors and exception mode commands (%colors/%xmode) have been
2658 The colors and exception mode commands (%colors/%xmode) have been
2652 synchronized to also take this into account, so users can get
2659 synchronized to also take this into account, so users can get
2653 verbose exceptions for their threaded code as well. I also added
2660 verbose exceptions for their threaded code as well. I also added
2654 support for activating pdb inside this exception handler as well,
2661 support for activating pdb inside this exception handler as well,
2655 so now GUI authors can use IPython's enhanced pdb at runtime.
2662 so now GUI authors can use IPython's enhanced pdb at runtime.
2656
2663
2657 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
2664 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
2658 true by default, and add it to the shipped ipythonrc file. Since
2665 true by default, and add it to the shipped ipythonrc file. Since
2659 this asks the user before proceeding, I think it's OK to make it
2666 this asks the user before proceeding, I think it's OK to make it
2660 true by default.
2667 true by default.
2661
2668
2662 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
2669 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
2663 of the previous special-casing of input in the eval loop. I think
2670 of the previous special-casing of input in the eval loop. I think
2664 this is cleaner, as they really are commands and shouldn't have
2671 this is cleaner, as they really are commands and shouldn't have
2665 a special role in the middle of the core code.
2672 a special role in the middle of the core code.
2666
2673
2667 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2674 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2668
2675
2669 * IPython/iplib.py (edit_syntax_error): added support for
2676 * IPython/iplib.py (edit_syntax_error): added support for
2670 automatically reopening the editor if the file had a syntax error
2677 automatically reopening the editor if the file had a syntax error
2671 in it. Thanks to scottt who provided the patch at:
2678 in it. Thanks to scottt who provided the patch at:
2672 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
2679 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
2673 version committed).
2680 version committed).
2674
2681
2675 * IPython/iplib.py (handle_normal): add suport for multi-line
2682 * IPython/iplib.py (handle_normal): add suport for multi-line
2676 input with emtpy lines. This fixes
2683 input with emtpy lines. This fixes
2677 http://www.scipy.net/roundup/ipython/issue43 and a similar
2684 http://www.scipy.net/roundup/ipython/issue43 and a similar
2678 discussion on the user list.
2685 discussion on the user list.
2679
2686
2680 WARNING: a behavior change is necessarily introduced to support
2687 WARNING: a behavior change is necessarily introduced to support
2681 blank lines: now a single blank line with whitespace does NOT
2688 blank lines: now a single blank line with whitespace does NOT
2682 break the input loop, which means that when autoindent is on, by
2689 break the input loop, which means that when autoindent is on, by
2683 default hitting return on the next (indented) line does NOT exit.
2690 default hitting return on the next (indented) line does NOT exit.
2684
2691
2685 Instead, to exit a multiline input you can either have:
2692 Instead, to exit a multiline input you can either have:
2686
2693
2687 - TWO whitespace lines (just hit return again), or
2694 - TWO whitespace lines (just hit return again), or
2688 - a single whitespace line of a different length than provided
2695 - a single whitespace line of a different length than provided
2689 by the autoindent (add or remove a space).
2696 by the autoindent (add or remove a space).
2690
2697
2691 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
2698 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
2692 module to better organize all readline-related functionality.
2699 module to better organize all readline-related functionality.
2693 I've deleted FlexCompleter and put all completion clases here.
2700 I've deleted FlexCompleter and put all completion clases here.
2694
2701
2695 * IPython/iplib.py (raw_input): improve indentation management.
2702 * IPython/iplib.py (raw_input): improve indentation management.
2696 It is now possible to paste indented code with autoindent on, and
2703 It is now possible to paste indented code with autoindent on, and
2697 the code is interpreted correctly (though it still looks bad on
2704 the code is interpreted correctly (though it still looks bad on
2698 screen, due to the line-oriented nature of ipython).
2705 screen, due to the line-oriented nature of ipython).
2699 (MagicCompleter.complete): change behavior so that a TAB key on an
2706 (MagicCompleter.complete): change behavior so that a TAB key on an
2700 otherwise empty line actually inserts a tab, instead of completing
2707 otherwise empty line actually inserts a tab, instead of completing
2701 on the entire global namespace. This makes it easier to use the
2708 on the entire global namespace. This makes it easier to use the
2702 TAB key for indentation. After a request by Hans Meine
2709 TAB key for indentation. After a request by Hans Meine
2703 <hans_meine-AT-gmx.net>
2710 <hans_meine-AT-gmx.net>
2704 (_prefilter): add support so that typing plain 'exit' or 'quit'
2711 (_prefilter): add support so that typing plain 'exit' or 'quit'
2705 does a sensible thing. Originally I tried to deviate as little as
2712 does a sensible thing. Originally I tried to deviate as little as
2706 possible from the default python behavior, but even that one may
2713 possible from the default python behavior, but even that one may
2707 change in this direction (thread on python-dev to that effect).
2714 change in this direction (thread on python-dev to that effect).
2708 Regardless, ipython should do the right thing even if CPython's
2715 Regardless, ipython should do the right thing even if CPython's
2709 '>>>' prompt doesn't.
2716 '>>>' prompt doesn't.
2710 (InteractiveShell): removed subclassing code.InteractiveConsole
2717 (InteractiveShell): removed subclassing code.InteractiveConsole
2711 class. By now we'd overridden just about all of its methods: I've
2718 class. By now we'd overridden just about all of its methods: I've
2712 copied the remaining two over, and now ipython is a standalone
2719 copied the remaining two over, and now ipython is a standalone
2713 class. This will provide a clearer picture for the chainsaw
2720 class. This will provide a clearer picture for the chainsaw
2714 branch refactoring.
2721 branch refactoring.
2715
2722
2716 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2723 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2717
2724
2718 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2725 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2719 failures for objects which break when dir() is called on them.
2726 failures for objects which break when dir() is called on them.
2720
2727
2721 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2728 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2722 distinct local and global namespaces in the completer API. This
2729 distinct local and global namespaces in the completer API. This
2723 change allows us to properly handle completion with distinct
2730 change allows us to properly handle completion with distinct
2724 scopes, including in embedded instances (this had never really
2731 scopes, including in embedded instances (this had never really
2725 worked correctly).
2732 worked correctly).
2726
2733
2727 Note: this introduces a change in the constructor for
2734 Note: this introduces a change in the constructor for
2728 MagicCompleter, as a new global_namespace parameter is now the
2735 MagicCompleter, as a new global_namespace parameter is now the
2729 second argument (the others were bumped one position).
2736 second argument (the others were bumped one position).
2730
2737
2731 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2738 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2732
2739
2733 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2740 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2734 embedded instances (which can be done now thanks to Vivian's
2741 embedded instances (which can be done now thanks to Vivian's
2735 frame-handling fixes for pdb).
2742 frame-handling fixes for pdb).
2736 (InteractiveShell.__init__): Fix namespace handling problem in
2743 (InteractiveShell.__init__): Fix namespace handling problem in
2737 embedded instances. We were overwriting __main__ unconditionally,
2744 embedded instances. We were overwriting __main__ unconditionally,
2738 and this should only be done for 'full' (non-embedded) IPython;
2745 and this should only be done for 'full' (non-embedded) IPython;
2739 embedded instances must respect the caller's __main__. Thanks to
2746 embedded instances must respect the caller's __main__. Thanks to
2740 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2747 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2741
2748
2742 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2749 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2743
2750
2744 * setup.py: added download_url to setup(). This registers the
2751 * setup.py: added download_url to setup(). This registers the
2745 download address at PyPI, which is not only useful to humans
2752 download address at PyPI, which is not only useful to humans
2746 browsing the site, but is also picked up by setuptools (the Eggs
2753 browsing the site, but is also picked up by setuptools (the Eggs
2747 machinery). Thanks to Ville and R. Kern for the info/discussion
2754 machinery). Thanks to Ville and R. Kern for the info/discussion
2748 on this.
2755 on this.
2749
2756
2750 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2757 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2751
2758
2752 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2759 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2753 This brings a lot of nice functionality to the pdb mode, which now
2760 This brings a lot of nice functionality to the pdb mode, which now
2754 has tab-completion, syntax highlighting, and better stack handling
2761 has tab-completion, syntax highlighting, and better stack handling
2755 than before. Many thanks to Vivian De Smedt
2762 than before. Many thanks to Vivian De Smedt
2756 <vivian-AT-vdesmedt.com> for the original patches.
2763 <vivian-AT-vdesmedt.com> for the original patches.
2757
2764
2758 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2765 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2759
2766
2760 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2767 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2761 sequence to consistently accept the banner argument. The
2768 sequence to consistently accept the banner argument. The
2762 inconsistency was tripping SAGE, thanks to Gary Zablackis
2769 inconsistency was tripping SAGE, thanks to Gary Zablackis
2763 <gzabl-AT-yahoo.com> for the report.
2770 <gzabl-AT-yahoo.com> for the report.
2764
2771
2765 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2772 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2766
2773
2767 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2774 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2768 Fix bug where a naked 'alias' call in the ipythonrc file would
2775 Fix bug where a naked 'alias' call in the ipythonrc file would
2769 cause a crash. Bug reported by Jorgen Stenarson.
2776 cause a crash. Bug reported by Jorgen Stenarson.
2770
2777
2771 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2778 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2772
2779
2773 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2780 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2774 startup time.
2781 startup time.
2775
2782
2776 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2783 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2777 instances had introduced a bug with globals in normal code. Now
2784 instances had introduced a bug with globals in normal code. Now
2778 it's working in all cases.
2785 it's working in all cases.
2779
2786
2780 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2787 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2781 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2788 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2782 has been introduced to set the default case sensitivity of the
2789 has been introduced to set the default case sensitivity of the
2783 searches. Users can still select either mode at runtime on a
2790 searches. Users can still select either mode at runtime on a
2784 per-search basis.
2791 per-search basis.
2785
2792
2786 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2793 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2787
2794
2788 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2795 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2789 attributes in wildcard searches for subclasses. Modified version
2796 attributes in wildcard searches for subclasses. Modified version
2790 of a patch by Jorgen.
2797 of a patch by Jorgen.
2791
2798
2792 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2799 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2793
2800
2794 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2801 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2795 embedded instances. I added a user_global_ns attribute to the
2802 embedded instances. I added a user_global_ns attribute to the
2796 InteractiveShell class to handle this.
2803 InteractiveShell class to handle this.
2797
2804
2798 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2805 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2799
2806
2800 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2807 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2801 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2808 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2802 (reported under win32, but may happen also in other platforms).
2809 (reported under win32, but may happen also in other platforms).
2803 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2810 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2804
2811
2805 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2812 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2806
2813
2807 * IPython/Magic.py (magic_psearch): new support for wildcard
2814 * IPython/Magic.py (magic_psearch): new support for wildcard
2808 patterns. Now, typing ?a*b will list all names which begin with a
2815 patterns. Now, typing ?a*b will list all names which begin with a
2809 and end in b, for example. The %psearch magic has full
2816 and end in b, for example. The %psearch magic has full
2810 docstrings. Many thanks to JΓΆrgen Stenarson
2817 docstrings. Many thanks to JΓΆrgen Stenarson
2811 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2818 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2812 implementing this functionality.
2819 implementing this functionality.
2813
2820
2814 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2821 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2815
2822
2816 * Manual: fixed long-standing annoyance of double-dashes (as in
2823 * Manual: fixed long-standing annoyance of double-dashes (as in
2817 --prefix=~, for example) being stripped in the HTML version. This
2824 --prefix=~, for example) being stripped in the HTML version. This
2818 is a latex2html bug, but a workaround was provided. Many thanks
2825 is a latex2html bug, but a workaround was provided. Many thanks
2819 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2826 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2820 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2827 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2821 rolling. This seemingly small issue had tripped a number of users
2828 rolling. This seemingly small issue had tripped a number of users
2822 when first installing, so I'm glad to see it gone.
2829 when first installing, so I'm glad to see it gone.
2823
2830
2824 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2831 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2825
2832
2826 * IPython/Extensions/numeric_formats.py: fix missing import,
2833 * IPython/Extensions/numeric_formats.py: fix missing import,
2827 reported by Stephen Walton.
2834 reported by Stephen Walton.
2828
2835
2829 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2836 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2830
2837
2831 * IPython/demo.py: finish demo module, fully documented now.
2838 * IPython/demo.py: finish demo module, fully documented now.
2832
2839
2833 * IPython/genutils.py (file_read): simple little utility to read a
2840 * IPython/genutils.py (file_read): simple little utility to read a
2834 file and ensure it's closed afterwards.
2841 file and ensure it's closed afterwards.
2835
2842
2836 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2843 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2837
2844
2838 * IPython/demo.py (Demo.__init__): added support for individually
2845 * IPython/demo.py (Demo.__init__): added support for individually
2839 tagging blocks for automatic execution.
2846 tagging blocks for automatic execution.
2840
2847
2841 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2848 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2842 syntax-highlighted python sources, requested by John.
2849 syntax-highlighted python sources, requested by John.
2843
2850
2844 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2851 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2845
2852
2846 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2853 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2847 finishing.
2854 finishing.
2848
2855
2849 * IPython/genutils.py (shlex_split): moved from Magic to here,
2856 * IPython/genutils.py (shlex_split): moved from Magic to here,
2850 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2857 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2851
2858
2852 * IPython/demo.py (Demo.__init__): added support for silent
2859 * IPython/demo.py (Demo.__init__): added support for silent
2853 blocks, improved marks as regexps, docstrings written.
2860 blocks, improved marks as regexps, docstrings written.
2854 (Demo.__init__): better docstring, added support for sys.argv.
2861 (Demo.__init__): better docstring, added support for sys.argv.
2855
2862
2856 * IPython/genutils.py (marquee): little utility used by the demo
2863 * IPython/genutils.py (marquee): little utility used by the demo
2857 code, handy in general.
2864 code, handy in general.
2858
2865
2859 * IPython/demo.py (Demo.__init__): new class for interactive
2866 * IPython/demo.py (Demo.__init__): new class for interactive
2860 demos. Not documented yet, I just wrote it in a hurry for
2867 demos. Not documented yet, I just wrote it in a hurry for
2861 scipy'05. Will docstring later.
2868 scipy'05. Will docstring later.
2862
2869
2863 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2870 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2864
2871
2865 * IPython/Shell.py (sigint_handler): Drastic simplification which
2872 * IPython/Shell.py (sigint_handler): Drastic simplification which
2866 also seems to make Ctrl-C work correctly across threads! This is
2873 also seems to make Ctrl-C work correctly across threads! This is
2867 so simple, that I can't beleive I'd missed it before. Needs more
2874 so simple, that I can't beleive I'd missed it before. Needs more
2868 testing, though.
2875 testing, though.
2869 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2876 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2870 like this before...
2877 like this before...
2871
2878
2872 * IPython/genutils.py (get_home_dir): add protection against
2879 * IPython/genutils.py (get_home_dir): add protection against
2873 non-dirs in win32 registry.
2880 non-dirs in win32 registry.
2874
2881
2875 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2882 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2876 bug where dict was mutated while iterating (pysh crash).
2883 bug where dict was mutated while iterating (pysh crash).
2877
2884
2878 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2885 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2879
2886
2880 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2887 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2881 spurious newlines added by this routine. After a report by
2888 spurious newlines added by this routine. After a report by
2882 F. Mantegazza.
2889 F. Mantegazza.
2883
2890
2884 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2891 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2885
2892
2886 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2893 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2887 calls. These were a leftover from the GTK 1.x days, and can cause
2894 calls. These were a leftover from the GTK 1.x days, and can cause
2888 problems in certain cases (after a report by John Hunter).
2895 problems in certain cases (after a report by John Hunter).
2889
2896
2890 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2897 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2891 os.getcwd() fails at init time. Thanks to patch from David Remahl
2898 os.getcwd() fails at init time. Thanks to patch from David Remahl
2892 <chmod007-AT-mac.com>.
2899 <chmod007-AT-mac.com>.
2893 (InteractiveShell.__init__): prevent certain special magics from
2900 (InteractiveShell.__init__): prevent certain special magics from
2894 being shadowed by aliases. Closes
2901 being shadowed by aliases. Closes
2895 http://www.scipy.net/roundup/ipython/issue41.
2902 http://www.scipy.net/roundup/ipython/issue41.
2896
2903
2897 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2904 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2898
2905
2899 * IPython/iplib.py (InteractiveShell.complete): Added new
2906 * IPython/iplib.py (InteractiveShell.complete): Added new
2900 top-level completion method to expose the completion mechanism
2907 top-level completion method to expose the completion mechanism
2901 beyond readline-based environments.
2908 beyond readline-based environments.
2902
2909
2903 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2910 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2904
2911
2905 * tools/ipsvnc (svnversion): fix svnversion capture.
2912 * tools/ipsvnc (svnversion): fix svnversion capture.
2906
2913
2907 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2914 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2908 attribute to self, which was missing. Before, it was set by a
2915 attribute to self, which was missing. Before, it was set by a
2909 routine which in certain cases wasn't being called, so the
2916 routine which in certain cases wasn't being called, so the
2910 instance could end up missing the attribute. This caused a crash.
2917 instance could end up missing the attribute. This caused a crash.
2911 Closes http://www.scipy.net/roundup/ipython/issue40.
2918 Closes http://www.scipy.net/roundup/ipython/issue40.
2912
2919
2913 2005-08-16 Fernando Perez <fperez@colorado.edu>
2920 2005-08-16 Fernando Perez <fperez@colorado.edu>
2914
2921
2915 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2922 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2916 contains non-string attribute. Closes
2923 contains non-string attribute. Closes
2917 http://www.scipy.net/roundup/ipython/issue38.
2924 http://www.scipy.net/roundup/ipython/issue38.
2918
2925
2919 2005-08-14 Fernando Perez <fperez@colorado.edu>
2926 2005-08-14 Fernando Perez <fperez@colorado.edu>
2920
2927
2921 * tools/ipsvnc: Minor improvements, to add changeset info.
2928 * tools/ipsvnc: Minor improvements, to add changeset info.
2922
2929
2923 2005-08-12 Fernando Perez <fperez@colorado.edu>
2930 2005-08-12 Fernando Perez <fperez@colorado.edu>
2924
2931
2925 * IPython/iplib.py (runsource): remove self.code_to_run_src
2932 * IPython/iplib.py (runsource): remove self.code_to_run_src
2926 attribute. I realized this is nothing more than
2933 attribute. I realized this is nothing more than
2927 '\n'.join(self.buffer), and having the same data in two different
2934 '\n'.join(self.buffer), and having the same data in two different
2928 places is just asking for synchronization bugs. This may impact
2935 places is just asking for synchronization bugs. This may impact
2929 people who have custom exception handlers, so I need to warn
2936 people who have custom exception handlers, so I need to warn
2930 ipython-dev about it (F. Mantegazza may use them).
2937 ipython-dev about it (F. Mantegazza may use them).
2931
2938
2932 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2939 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2933
2940
2934 * IPython/genutils.py: fix 2.2 compatibility (generators)
2941 * IPython/genutils.py: fix 2.2 compatibility (generators)
2935
2942
2936 2005-07-18 Fernando Perez <fperez@colorado.edu>
2943 2005-07-18 Fernando Perez <fperez@colorado.edu>
2937
2944
2938 * IPython/genutils.py (get_home_dir): fix to help users with
2945 * IPython/genutils.py (get_home_dir): fix to help users with
2939 invalid $HOME under win32.
2946 invalid $HOME under win32.
2940
2947
2941 2005-07-17 Fernando Perez <fperez@colorado.edu>
2948 2005-07-17 Fernando Perez <fperez@colorado.edu>
2942
2949
2943 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2950 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2944 some old hacks and clean up a bit other routines; code should be
2951 some old hacks and clean up a bit other routines; code should be
2945 simpler and a bit faster.
2952 simpler and a bit faster.
2946
2953
2947 * IPython/iplib.py (interact): removed some last-resort attempts
2954 * IPython/iplib.py (interact): removed some last-resort attempts
2948 to survive broken stdout/stderr. That code was only making it
2955 to survive broken stdout/stderr. That code was only making it
2949 harder to abstract out the i/o (necessary for gui integration),
2956 harder to abstract out the i/o (necessary for gui integration),
2950 and the crashes it could prevent were extremely rare in practice
2957 and the crashes it could prevent were extremely rare in practice
2951 (besides being fully user-induced in a pretty violent manner).
2958 (besides being fully user-induced in a pretty violent manner).
2952
2959
2953 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2960 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2954 Nothing major yet, but the code is simpler to read; this should
2961 Nothing major yet, but the code is simpler to read; this should
2955 make it easier to do more serious modifications in the future.
2962 make it easier to do more serious modifications in the future.
2956
2963
2957 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2964 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2958 which broke in .15 (thanks to a report by Ville).
2965 which broke in .15 (thanks to a report by Ville).
2959
2966
2960 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2967 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2961 be quite correct, I know next to nothing about unicode). This
2968 be quite correct, I know next to nothing about unicode). This
2962 will allow unicode strings to be used in prompts, amongst other
2969 will allow unicode strings to be used in prompts, amongst other
2963 cases. It also will prevent ipython from crashing when unicode
2970 cases. It also will prevent ipython from crashing when unicode
2964 shows up unexpectedly in many places. If ascii encoding fails, we
2971 shows up unexpectedly in many places. If ascii encoding fails, we
2965 assume utf_8. Currently the encoding is not a user-visible
2972 assume utf_8. Currently the encoding is not a user-visible
2966 setting, though it could be made so if there is demand for it.
2973 setting, though it could be made so if there is demand for it.
2967
2974
2968 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2975 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2969
2976
2970 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2977 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2971
2978
2972 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2979 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2973
2980
2974 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2981 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2975 code can work transparently for 2.2/2.3.
2982 code can work transparently for 2.2/2.3.
2976
2983
2977 2005-07-16 Fernando Perez <fperez@colorado.edu>
2984 2005-07-16 Fernando Perez <fperez@colorado.edu>
2978
2985
2979 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2986 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2980 out of the color scheme table used for coloring exception
2987 out of the color scheme table used for coloring exception
2981 tracebacks. This allows user code to add new schemes at runtime.
2988 tracebacks. This allows user code to add new schemes at runtime.
2982 This is a minimally modified version of the patch at
2989 This is a minimally modified version of the patch at
2983 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2990 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2984 for the contribution.
2991 for the contribution.
2985
2992
2986 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2993 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2987 slightly modified version of the patch in
2994 slightly modified version of the patch in
2988 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2995 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2989 to remove the previous try/except solution (which was costlier).
2996 to remove the previous try/except solution (which was costlier).
2990 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2997 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2991
2998
2992 2005-06-08 Fernando Perez <fperez@colorado.edu>
2999 2005-06-08 Fernando Perez <fperez@colorado.edu>
2993
3000
2994 * IPython/iplib.py (write/write_err): Add methods to abstract all
3001 * IPython/iplib.py (write/write_err): Add methods to abstract all
2995 I/O a bit more.
3002 I/O a bit more.
2996
3003
2997 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
3004 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2998 warning, reported by Aric Hagberg, fix by JD Hunter.
3005 warning, reported by Aric Hagberg, fix by JD Hunter.
2999
3006
3000 2005-06-02 *** Released version 0.6.15
3007 2005-06-02 *** Released version 0.6.15
3001
3008
3002 2005-06-01 Fernando Perez <fperez@colorado.edu>
3009 2005-06-01 Fernando Perez <fperez@colorado.edu>
3003
3010
3004 * IPython/iplib.py (MagicCompleter.file_matches): Fix
3011 * IPython/iplib.py (MagicCompleter.file_matches): Fix
3005 tab-completion of filenames within open-quoted strings. Note that
3012 tab-completion of filenames within open-quoted strings. Note that
3006 this requires that in ~/.ipython/ipythonrc, users change the
3013 this requires that in ~/.ipython/ipythonrc, users change the
3007 readline delimiters configuration to read:
3014 readline delimiters configuration to read:
3008
3015
3009 readline_remove_delims -/~
3016 readline_remove_delims -/~
3010
3017
3011
3018
3012 2005-05-31 *** Released version 0.6.14
3019 2005-05-31 *** Released version 0.6.14
3013
3020
3014 2005-05-29 Fernando Perez <fperez@colorado.edu>
3021 2005-05-29 Fernando Perez <fperez@colorado.edu>
3015
3022
3016 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
3023 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
3017 with files not on the filesystem. Reported by Eliyahu Sandler
3024 with files not on the filesystem. Reported by Eliyahu Sandler
3018 <eli@gondolin.net>
3025 <eli@gondolin.net>
3019
3026
3020 2005-05-22 Fernando Perez <fperez@colorado.edu>
3027 2005-05-22 Fernando Perez <fperez@colorado.edu>
3021
3028
3022 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
3029 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
3023 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
3030 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
3024
3031
3025 2005-05-19 Fernando Perez <fperez@colorado.edu>
3032 2005-05-19 Fernando Perez <fperez@colorado.edu>
3026
3033
3027 * IPython/iplib.py (safe_execfile): close a file which could be
3034 * IPython/iplib.py (safe_execfile): close a file which could be
3028 left open (causing problems in win32, which locks open files).
3035 left open (causing problems in win32, which locks open files).
3029 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
3036 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
3030
3037
3031 2005-05-18 Fernando Perez <fperez@colorado.edu>
3038 2005-05-18 Fernando Perez <fperez@colorado.edu>
3032
3039
3033 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
3040 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
3034 keyword arguments correctly to safe_execfile().
3041 keyword arguments correctly to safe_execfile().
3035
3042
3036 2005-05-13 Fernando Perez <fperez@colorado.edu>
3043 2005-05-13 Fernando Perez <fperez@colorado.edu>
3037
3044
3038 * ipython.1: Added info about Qt to manpage, and threads warning
3045 * ipython.1: Added info about Qt to manpage, and threads warning
3039 to usage page (invoked with --help).
3046 to usage page (invoked with --help).
3040
3047
3041 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
3048 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
3042 new matcher (it goes at the end of the priority list) to do
3049 new matcher (it goes at the end of the priority list) to do
3043 tab-completion on named function arguments. Submitted by George
3050 tab-completion on named function arguments. Submitted by George
3044 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
3051 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
3045 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
3052 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
3046 for more details.
3053 for more details.
3047
3054
3048 * IPython/Magic.py (magic_run): Added new -e flag to ignore
3055 * IPython/Magic.py (magic_run): Added new -e flag to ignore
3049 SystemExit exceptions in the script being run. Thanks to a report
3056 SystemExit exceptions in the script being run. Thanks to a report
3050 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
3057 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
3051 producing very annoying behavior when running unit tests.
3058 producing very annoying behavior when running unit tests.
3052
3059
3053 2005-05-12 Fernando Perez <fperez@colorado.edu>
3060 2005-05-12 Fernando Perez <fperez@colorado.edu>
3054
3061
3055 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
3062 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
3056 which I'd broken (again) due to a changed regexp. In the process,
3063 which I'd broken (again) due to a changed regexp. In the process,
3057 added ';' as an escape to auto-quote the whole line without
3064 added ';' as an escape to auto-quote the whole line without
3058 splitting its arguments. Thanks to a report by Jerry McRae
3065 splitting its arguments. Thanks to a report by Jerry McRae
3059 <qrs0xyc02-AT-sneakemail.com>.
3066 <qrs0xyc02-AT-sneakemail.com>.
3060
3067
3061 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
3068 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
3062 possible crashes caused by a TokenError. Reported by Ed Schofield
3069 possible crashes caused by a TokenError. Reported by Ed Schofield
3063 <schofield-AT-ftw.at>.
3070 <schofield-AT-ftw.at>.
3064
3071
3065 2005-05-06 Fernando Perez <fperez@colorado.edu>
3072 2005-05-06 Fernando Perez <fperez@colorado.edu>
3066
3073
3067 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
3074 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
3068
3075
3069 2005-04-29 Fernando Perez <fperez@colorado.edu>
3076 2005-04-29 Fernando Perez <fperez@colorado.edu>
3070
3077
3071 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
3078 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
3072 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
3079 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
3073 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
3080 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
3074 which provides support for Qt interactive usage (similar to the
3081 which provides support for Qt interactive usage (similar to the
3075 existing one for WX and GTK). This had been often requested.
3082 existing one for WX and GTK). This had been often requested.
3076
3083
3077 2005-04-14 *** Released version 0.6.13
3084 2005-04-14 *** Released version 0.6.13
3078
3085
3079 2005-04-08 Fernando Perez <fperez@colorado.edu>
3086 2005-04-08 Fernando Perez <fperez@colorado.edu>
3080
3087
3081 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
3088 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
3082 from _ofind, which gets called on almost every input line. Now,
3089 from _ofind, which gets called on almost every input line. Now,
3083 we only try to get docstrings if they are actually going to be
3090 we only try to get docstrings if they are actually going to be
3084 used (the overhead of fetching unnecessary docstrings can be
3091 used (the overhead of fetching unnecessary docstrings can be
3085 noticeable for certain objects, such as Pyro proxies).
3092 noticeable for certain objects, such as Pyro proxies).
3086
3093
3087 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
3094 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
3088 for completers. For some reason I had been passing them the state
3095 for completers. For some reason I had been passing them the state
3089 variable, which completers never actually need, and was in
3096 variable, which completers never actually need, and was in
3090 conflict with the rlcompleter API. Custom completers ONLY need to
3097 conflict with the rlcompleter API. Custom completers ONLY need to
3091 take the text parameter.
3098 take the text parameter.
3092
3099
3093 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
3100 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
3094 work correctly in pysh. I've also moved all the logic which used
3101 work correctly in pysh. I've also moved all the logic which used
3095 to be in pysh.py here, which will prevent problems with future
3102 to be in pysh.py here, which will prevent problems with future
3096 upgrades. However, this time I must warn users to update their
3103 upgrades. However, this time I must warn users to update their
3097 pysh profile to include the line
3104 pysh profile to include the line
3098
3105
3099 import_all IPython.Extensions.InterpreterExec
3106 import_all IPython.Extensions.InterpreterExec
3100
3107
3101 because otherwise things won't work for them. They MUST also
3108 because otherwise things won't work for them. They MUST also
3102 delete pysh.py and the line
3109 delete pysh.py and the line
3103
3110
3104 execfile pysh.py
3111 execfile pysh.py
3105
3112
3106 from their ipythonrc-pysh.
3113 from their ipythonrc-pysh.
3107
3114
3108 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
3115 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
3109 robust in the face of objects whose dir() returns non-strings
3116 robust in the face of objects whose dir() returns non-strings
3110 (which it shouldn't, but some broken libs like ITK do). Thanks to
3117 (which it shouldn't, but some broken libs like ITK do). Thanks to
3111 a patch by John Hunter (implemented differently, though). Also
3118 a patch by John Hunter (implemented differently, though). Also
3112 minor improvements by using .extend instead of + on lists.
3119 minor improvements by using .extend instead of + on lists.
3113
3120
3114 * pysh.py:
3121 * pysh.py:
3115
3122
3116 2005-04-06 Fernando Perez <fperez@colorado.edu>
3123 2005-04-06 Fernando Perez <fperez@colorado.edu>
3117
3124
3118 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
3125 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
3119 by default, so that all users benefit from it. Those who don't
3126 by default, so that all users benefit from it. Those who don't
3120 want it can still turn it off.
3127 want it can still turn it off.
3121
3128
3122 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
3129 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
3123 config file, I'd forgotten about this, so users were getting it
3130 config file, I'd forgotten about this, so users were getting it
3124 off by default.
3131 off by default.
3125
3132
3126 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
3133 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
3127 consistency. Now magics can be called in multiline statements,
3134 consistency. Now magics can be called in multiline statements,
3128 and python variables can be expanded in magic calls via $var.
3135 and python variables can be expanded in magic calls via $var.
3129 This makes the magic system behave just like aliases or !system
3136 This makes the magic system behave just like aliases or !system
3130 calls.
3137 calls.
3131
3138
3132 2005-03-28 Fernando Perez <fperez@colorado.edu>
3139 2005-03-28 Fernando Perez <fperez@colorado.edu>
3133
3140
3134 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
3141 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
3135 expensive string additions for building command. Add support for
3142 expensive string additions for building command. Add support for
3136 trailing ';' when autocall is used.
3143 trailing ';' when autocall is used.
3137
3144
3138 2005-03-26 Fernando Perez <fperez@colorado.edu>
3145 2005-03-26 Fernando Perez <fperez@colorado.edu>
3139
3146
3140 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
3147 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
3141 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
3148 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
3142 ipython.el robust against prompts with any number of spaces
3149 ipython.el robust against prompts with any number of spaces
3143 (including 0) after the ':' character.
3150 (including 0) after the ':' character.
3144
3151
3145 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
3152 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
3146 continuation prompt, which misled users to think the line was
3153 continuation prompt, which misled users to think the line was
3147 already indented. Closes debian Bug#300847, reported to me by
3154 already indented. Closes debian Bug#300847, reported to me by
3148 Norbert Tretkowski <tretkowski-AT-inittab.de>.
3155 Norbert Tretkowski <tretkowski-AT-inittab.de>.
3149
3156
3150 2005-03-23 Fernando Perez <fperez@colorado.edu>
3157 2005-03-23 Fernando Perez <fperez@colorado.edu>
3151
3158
3152 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
3159 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
3153 properly aligned if they have embedded newlines.
3160 properly aligned if they have embedded newlines.
3154
3161
3155 * IPython/iplib.py (runlines): Add a public method to expose
3162 * IPython/iplib.py (runlines): Add a public method to expose
3156 IPython's code execution machinery, so that users can run strings
3163 IPython's code execution machinery, so that users can run strings
3157 as if they had been typed at the prompt interactively.
3164 as if they had been typed at the prompt interactively.
3158 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
3165 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
3159 methods which can call the system shell, but with python variable
3166 methods which can call the system shell, but with python variable
3160 expansion. The three such methods are: __IPYTHON__.system,
3167 expansion. The three such methods are: __IPYTHON__.system,
3161 .getoutput and .getoutputerror. These need to be documented in a
3168 .getoutput and .getoutputerror. These need to be documented in a
3162 'public API' section (to be written) of the manual.
3169 'public API' section (to be written) of the manual.
3163
3170
3164 2005-03-20 Fernando Perez <fperez@colorado.edu>
3171 2005-03-20 Fernando Perez <fperez@colorado.edu>
3165
3172
3166 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
3173 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
3167 for custom exception handling. This is quite powerful, and it
3174 for custom exception handling. This is quite powerful, and it
3168 allows for user-installable exception handlers which can trap
3175 allows for user-installable exception handlers which can trap
3169 custom exceptions at runtime and treat them separately from
3176 custom exceptions at runtime and treat them separately from
3170 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
3177 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
3171 Mantegazza <mantegazza-AT-ill.fr>.
3178 Mantegazza <mantegazza-AT-ill.fr>.
3172 (InteractiveShell.set_custom_completer): public API function to
3179 (InteractiveShell.set_custom_completer): public API function to
3173 add new completers at runtime.
3180 add new completers at runtime.
3174
3181
3175 2005-03-19 Fernando Perez <fperez@colorado.edu>
3182 2005-03-19 Fernando Perez <fperez@colorado.edu>
3176
3183
3177 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
3184 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
3178 allow objects which provide their docstrings via non-standard
3185 allow objects which provide their docstrings via non-standard
3179 mechanisms (like Pyro proxies) to still be inspected by ipython's
3186 mechanisms (like Pyro proxies) to still be inspected by ipython's
3180 ? system.
3187 ? system.
3181
3188
3182 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
3189 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
3183 automatic capture system. I tried quite hard to make it work
3190 automatic capture system. I tried quite hard to make it work
3184 reliably, and simply failed. I tried many combinations with the
3191 reliably, and simply failed. I tried many combinations with the
3185 subprocess module, but eventually nothing worked in all needed
3192 subprocess module, but eventually nothing worked in all needed
3186 cases (not blocking stdin for the child, duplicating stdout
3193 cases (not blocking stdin for the child, duplicating stdout
3187 without blocking, etc). The new %sc/%sx still do capture to these
3194 without blocking, etc). The new %sc/%sx still do capture to these
3188 magical list/string objects which make shell use much more
3195 magical list/string objects which make shell use much more
3189 conveninent, so not all is lost.
3196 conveninent, so not all is lost.
3190
3197
3191 XXX - FIX MANUAL for the change above!
3198 XXX - FIX MANUAL for the change above!
3192
3199
3193 (runsource): I copied code.py's runsource() into ipython to modify
3200 (runsource): I copied code.py's runsource() into ipython to modify
3194 it a bit. Now the code object and source to be executed are
3201 it a bit. Now the code object and source to be executed are
3195 stored in ipython. This makes this info accessible to third-party
3202 stored in ipython. This makes this info accessible to third-party
3196 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
3203 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
3197 Mantegazza <mantegazza-AT-ill.fr>.
3204 Mantegazza <mantegazza-AT-ill.fr>.
3198
3205
3199 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
3206 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
3200 history-search via readline (like C-p/C-n). I'd wanted this for a
3207 history-search via readline (like C-p/C-n). I'd wanted this for a
3201 long time, but only recently found out how to do it. For users
3208 long time, but only recently found out how to do it. For users
3202 who already have their ipythonrc files made and want this, just
3209 who already have their ipythonrc files made and want this, just
3203 add:
3210 add:
3204
3211
3205 readline_parse_and_bind "\e[A": history-search-backward
3212 readline_parse_and_bind "\e[A": history-search-backward
3206 readline_parse_and_bind "\e[B": history-search-forward
3213 readline_parse_and_bind "\e[B": history-search-forward
3207
3214
3208 2005-03-18 Fernando Perez <fperez@colorado.edu>
3215 2005-03-18 Fernando Perez <fperez@colorado.edu>
3209
3216
3210 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
3217 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
3211 LSString and SList classes which allow transparent conversions
3218 LSString and SList classes which allow transparent conversions
3212 between list mode and whitespace-separated string.
3219 between list mode and whitespace-separated string.
3213 (magic_r): Fix recursion problem in %r.
3220 (magic_r): Fix recursion problem in %r.
3214
3221
3215 * IPython/genutils.py (LSString): New class to be used for
3222 * IPython/genutils.py (LSString): New class to be used for
3216 automatic storage of the results of all alias/system calls in _o
3223 automatic storage of the results of all alias/system calls in _o
3217 and _e (stdout/err). These provide a .l/.list attribute which
3224 and _e (stdout/err). These provide a .l/.list attribute which
3218 does automatic splitting on newlines. This means that for most
3225 does automatic splitting on newlines. This means that for most
3219 uses, you'll never need to do capturing of output with %sc/%sx
3226 uses, you'll never need to do capturing of output with %sc/%sx
3220 anymore, since ipython keeps this always done for you. Note that
3227 anymore, since ipython keeps this always done for you. Note that
3221 only the LAST results are stored, the _o/e variables are
3228 only the LAST results are stored, the _o/e variables are
3222 overwritten on each call. If you need to save their contents
3229 overwritten on each call. If you need to save their contents
3223 further, simply bind them to any other name.
3230 further, simply bind them to any other name.
3224
3231
3225 2005-03-17 Fernando Perez <fperez@colorado.edu>
3232 2005-03-17 Fernando Perez <fperez@colorado.edu>
3226
3233
3227 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
3234 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
3228 prompt namespace handling.
3235 prompt namespace handling.
3229
3236
3230 2005-03-16 Fernando Perez <fperez@colorado.edu>
3237 2005-03-16 Fernando Perez <fperez@colorado.edu>
3231
3238
3232 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
3239 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
3233 classic prompts to be '>>> ' (final space was missing, and it
3240 classic prompts to be '>>> ' (final space was missing, and it
3234 trips the emacs python mode).
3241 trips the emacs python mode).
3235 (BasePrompt.__str__): Added safe support for dynamic prompt
3242 (BasePrompt.__str__): Added safe support for dynamic prompt
3236 strings. Now you can set your prompt string to be '$x', and the
3243 strings. Now you can set your prompt string to be '$x', and the
3237 value of x will be printed from your interactive namespace. The
3244 value of x will be printed from your interactive namespace. The
3238 interpolation syntax includes the full Itpl support, so
3245 interpolation syntax includes the full Itpl support, so
3239 ${foo()+x+bar()} is a valid prompt string now, and the function
3246 ${foo()+x+bar()} is a valid prompt string now, and the function
3240 calls will be made at runtime.
3247 calls will be made at runtime.
3241
3248
3242 2005-03-15 Fernando Perez <fperez@colorado.edu>
3249 2005-03-15 Fernando Perez <fperez@colorado.edu>
3243
3250
3244 * IPython/Magic.py (magic_history): renamed %hist to %history, to
3251 * IPython/Magic.py (magic_history): renamed %hist to %history, to
3245 avoid name clashes in pylab. %hist still works, it just forwards
3252 avoid name clashes in pylab. %hist still works, it just forwards
3246 the call to %history.
3253 the call to %history.
3247
3254
3248 2005-03-02 *** Released version 0.6.12
3255 2005-03-02 *** Released version 0.6.12
3249
3256
3250 2005-03-02 Fernando Perez <fperez@colorado.edu>
3257 2005-03-02 Fernando Perez <fperez@colorado.edu>
3251
3258
3252 * IPython/iplib.py (handle_magic): log magic calls properly as
3259 * IPython/iplib.py (handle_magic): log magic calls properly as
3253 ipmagic() function calls.
3260 ipmagic() function calls.
3254
3261
3255 * IPython/Magic.py (magic_time): Improved %time to support
3262 * IPython/Magic.py (magic_time): Improved %time to support
3256 statements and provide wall-clock as well as CPU time.
3263 statements and provide wall-clock as well as CPU time.
3257
3264
3258 2005-02-27 Fernando Perez <fperez@colorado.edu>
3265 2005-02-27 Fernando Perez <fperez@colorado.edu>
3259
3266
3260 * IPython/hooks.py: New hooks module, to expose user-modifiable
3267 * IPython/hooks.py: New hooks module, to expose user-modifiable
3261 IPython functionality in a clean manner. For now only the editor
3268 IPython functionality in a clean manner. For now only the editor
3262 hook is actually written, and other thigns which I intend to turn
3269 hook is actually written, and other thigns which I intend to turn
3263 into proper hooks aren't yet there. The display and prefilter
3270 into proper hooks aren't yet there. The display and prefilter
3264 stuff, for example, should be hooks. But at least now the
3271 stuff, for example, should be hooks. But at least now the
3265 framework is in place, and the rest can be moved here with more
3272 framework is in place, and the rest can be moved here with more
3266 time later. IPython had had a .hooks variable for a long time for
3273 time later. IPython had had a .hooks variable for a long time for
3267 this purpose, but I'd never actually used it for anything.
3274 this purpose, but I'd never actually used it for anything.
3268
3275
3269 2005-02-26 Fernando Perez <fperez@colorado.edu>
3276 2005-02-26 Fernando Perez <fperez@colorado.edu>
3270
3277
3271 * IPython/ipmaker.py (make_IPython): make the default ipython
3278 * IPython/ipmaker.py (make_IPython): make the default ipython
3272 directory be called _ipython under win32, to follow more the
3279 directory be called _ipython under win32, to follow more the
3273 naming peculiarities of that platform (where buggy software like
3280 naming peculiarities of that platform (where buggy software like
3274 Visual Sourcesafe breaks with .named directories). Reported by
3281 Visual Sourcesafe breaks with .named directories). Reported by
3275 Ville Vainio.
3282 Ville Vainio.
3276
3283
3277 2005-02-23 Fernando Perez <fperez@colorado.edu>
3284 2005-02-23 Fernando Perez <fperez@colorado.edu>
3278
3285
3279 * IPython/iplib.py (InteractiveShell.__init__): removed a few
3286 * IPython/iplib.py (InteractiveShell.__init__): removed a few
3280 auto_aliases for win32 which were causing problems. Users can
3287 auto_aliases for win32 which were causing problems. Users can
3281 define the ones they personally like.
3288 define the ones they personally like.
3282
3289
3283 2005-02-21 Fernando Perez <fperez@colorado.edu>
3290 2005-02-21 Fernando Perez <fperez@colorado.edu>
3284
3291
3285 * IPython/Magic.py (magic_time): new magic to time execution of
3292 * IPython/Magic.py (magic_time): new magic to time execution of
3286 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
3293 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
3287
3294
3288 2005-02-19 Fernando Perez <fperez@colorado.edu>
3295 2005-02-19 Fernando Perez <fperez@colorado.edu>
3289
3296
3290 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
3297 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
3291 into keys (for prompts, for example).
3298 into keys (for prompts, for example).
3292
3299
3293 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
3300 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
3294 prompts in case users want them. This introduces a small behavior
3301 prompts in case users want them. This introduces a small behavior
3295 change: ipython does not automatically add a space to all prompts
3302 change: ipython does not automatically add a space to all prompts
3296 anymore. To get the old prompts with a space, users should add it
3303 anymore. To get the old prompts with a space, users should add it
3297 manually to their ipythonrc file, so for example prompt_in1 should
3304 manually to their ipythonrc file, so for example prompt_in1 should
3298 now read 'In [\#]: ' instead of 'In [\#]:'.
3305 now read 'In [\#]: ' instead of 'In [\#]:'.
3299 (BasePrompt.__init__): New option prompts_pad_left (only in rc
3306 (BasePrompt.__init__): New option prompts_pad_left (only in rc
3300 file) to control left-padding of secondary prompts.
3307 file) to control left-padding of secondary prompts.
3301
3308
3302 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
3309 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
3303 the profiler can't be imported. Fix for Debian, which removed
3310 the profiler can't be imported. Fix for Debian, which removed
3304 profile.py because of License issues. I applied a slightly
3311 profile.py because of License issues. I applied a slightly
3305 modified version of the original Debian patch at
3312 modified version of the original Debian patch at
3306 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
3313 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
3307
3314
3308 2005-02-17 Fernando Perez <fperez@colorado.edu>
3315 2005-02-17 Fernando Perez <fperez@colorado.edu>
3309
3316
3310 * IPython/genutils.py (native_line_ends): Fix bug which would
3317 * IPython/genutils.py (native_line_ends): Fix bug which would
3311 cause improper line-ends under win32 b/c I was not opening files
3318 cause improper line-ends under win32 b/c I was not opening files
3312 in binary mode. Bug report and fix thanks to Ville.
3319 in binary mode. Bug report and fix thanks to Ville.
3313
3320
3314 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
3321 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
3315 trying to catch spurious foo[1] autocalls. My fix actually broke
3322 trying to catch spurious foo[1] autocalls. My fix actually broke
3316 ',/' autoquote/call with explicit escape (bad regexp).
3323 ',/' autoquote/call with explicit escape (bad regexp).
3317
3324
3318 2005-02-15 *** Released version 0.6.11
3325 2005-02-15 *** Released version 0.6.11
3319
3326
3320 2005-02-14 Fernando Perez <fperez@colorado.edu>
3327 2005-02-14 Fernando Perez <fperez@colorado.edu>
3321
3328
3322 * IPython/background_jobs.py: New background job management
3329 * IPython/background_jobs.py: New background job management
3323 subsystem. This is implemented via a new set of classes, and
3330 subsystem. This is implemented via a new set of classes, and
3324 IPython now provides a builtin 'jobs' object for background job
3331 IPython now provides a builtin 'jobs' object for background job
3325 execution. A convenience %bg magic serves as a lightweight
3332 execution. A convenience %bg magic serves as a lightweight
3326 frontend for starting the more common type of calls. This was
3333 frontend for starting the more common type of calls. This was
3327 inspired by discussions with B. Granger and the BackgroundCommand
3334 inspired by discussions with B. Granger and the BackgroundCommand
3328 class described in the book Python Scripting for Computational
3335 class described in the book Python Scripting for Computational
3329 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
3336 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
3330 (although ultimately no code from this text was used, as IPython's
3337 (although ultimately no code from this text was used, as IPython's
3331 system is a separate implementation).
3338 system is a separate implementation).
3332
3339
3333 * IPython/iplib.py (MagicCompleter.python_matches): add new option
3340 * IPython/iplib.py (MagicCompleter.python_matches): add new option
3334 to control the completion of single/double underscore names
3341 to control the completion of single/double underscore names
3335 separately. As documented in the example ipytonrc file, the
3342 separately. As documented in the example ipytonrc file, the
3336 readline_omit__names variable can now be set to 2, to omit even
3343 readline_omit__names variable can now be set to 2, to omit even
3337 single underscore names. Thanks to a patch by Brian Wong
3344 single underscore names. Thanks to a patch by Brian Wong
3338 <BrianWong-AT-AirgoNetworks.Com>.
3345 <BrianWong-AT-AirgoNetworks.Com>.
3339 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
3346 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
3340 be autocalled as foo([1]) if foo were callable. A problem for
3347 be autocalled as foo([1]) if foo were callable. A problem for
3341 things which are both callable and implement __getitem__.
3348 things which are both callable and implement __getitem__.
3342 (init_readline): Fix autoindentation for win32. Thanks to a patch
3349 (init_readline): Fix autoindentation for win32. Thanks to a patch
3343 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
3350 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
3344
3351
3345 2005-02-12 Fernando Perez <fperez@colorado.edu>
3352 2005-02-12 Fernando Perez <fperez@colorado.edu>
3346
3353
3347 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
3354 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
3348 which I had written long ago to sort out user error messages which
3355 which I had written long ago to sort out user error messages which
3349 may occur during startup. This seemed like a good idea initially,
3356 may occur during startup. This seemed like a good idea initially,
3350 but it has proven a disaster in retrospect. I don't want to
3357 but it has proven a disaster in retrospect. I don't want to
3351 change much code for now, so my fix is to set the internal 'debug'
3358 change much code for now, so my fix is to set the internal 'debug'
3352 flag to true everywhere, whose only job was precisely to control
3359 flag to true everywhere, whose only job was precisely to control
3353 this subsystem. This closes issue 28 (as well as avoiding all
3360 this subsystem. This closes issue 28 (as well as avoiding all
3354 sorts of strange hangups which occur from time to time).
3361 sorts of strange hangups which occur from time to time).
3355
3362
3356 2005-02-07 Fernando Perez <fperez@colorado.edu>
3363 2005-02-07 Fernando Perez <fperez@colorado.edu>
3357
3364
3358 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
3365 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
3359 previous call produced a syntax error.
3366 previous call produced a syntax error.
3360
3367
3361 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3368 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3362 classes without constructor.
3369 classes without constructor.
3363
3370
3364 2005-02-06 Fernando Perez <fperez@colorado.edu>
3371 2005-02-06 Fernando Perez <fperez@colorado.edu>
3365
3372
3366 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
3373 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
3367 completions with the results of each matcher, so we return results
3374 completions with the results of each matcher, so we return results
3368 to the user from all namespaces. This breaks with ipython
3375 to the user from all namespaces. This breaks with ipython
3369 tradition, but I think it's a nicer behavior. Now you get all
3376 tradition, but I think it's a nicer behavior. Now you get all
3370 possible completions listed, from all possible namespaces (python,
3377 possible completions listed, from all possible namespaces (python,
3371 filesystem, magics...) After a request by John Hunter
3378 filesystem, magics...) After a request by John Hunter
3372 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3379 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3373
3380
3374 2005-02-05 Fernando Perez <fperez@colorado.edu>
3381 2005-02-05 Fernando Perez <fperez@colorado.edu>
3375
3382
3376 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
3383 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
3377 the call had quote characters in it (the quotes were stripped).
3384 the call had quote characters in it (the quotes were stripped).
3378
3385
3379 2005-01-31 Fernando Perez <fperez@colorado.edu>
3386 2005-01-31 Fernando Perez <fperez@colorado.edu>
3380
3387
3381 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
3388 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
3382 Itpl.itpl() to make the code more robust against psyco
3389 Itpl.itpl() to make the code more robust against psyco
3383 optimizations.
3390 optimizations.
3384
3391
3385 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
3392 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
3386 of causing an exception. Quicker, cleaner.
3393 of causing an exception. Quicker, cleaner.
3387
3394
3388 2005-01-28 Fernando Perez <fperez@colorado.edu>
3395 2005-01-28 Fernando Perez <fperez@colorado.edu>
3389
3396
3390 * scripts/ipython_win_post_install.py (install): hardcode
3397 * scripts/ipython_win_post_install.py (install): hardcode
3391 sys.prefix+'python.exe' as the executable path. It turns out that
3398 sys.prefix+'python.exe' as the executable path. It turns out that
3392 during the post-installation run, sys.executable resolves to the
3399 during the post-installation run, sys.executable resolves to the
3393 name of the binary installer! I should report this as a distutils
3400 name of the binary installer! I should report this as a distutils
3394 bug, I think. I updated the .10 release with this tiny fix, to
3401 bug, I think. I updated the .10 release with this tiny fix, to
3395 avoid annoying the lists further.
3402 avoid annoying the lists further.
3396
3403
3397 2005-01-27 *** Released version 0.6.10
3404 2005-01-27 *** Released version 0.6.10
3398
3405
3399 2005-01-27 Fernando Perez <fperez@colorado.edu>
3406 2005-01-27 Fernando Perez <fperez@colorado.edu>
3400
3407
3401 * IPython/numutils.py (norm): Added 'inf' as optional name for
3408 * IPython/numutils.py (norm): Added 'inf' as optional name for
3402 L-infinity norm, included references to mathworld.com for vector
3409 L-infinity norm, included references to mathworld.com for vector
3403 norm definitions.
3410 norm definitions.
3404 (amin/amax): added amin/amax for array min/max. Similar to what
3411 (amin/amax): added amin/amax for array min/max. Similar to what
3405 pylab ships with after the recent reorganization of names.
3412 pylab ships with after the recent reorganization of names.
3406 (spike/spike_odd): removed deprecated spike/spike_odd functions.
3413 (spike/spike_odd): removed deprecated spike/spike_odd functions.
3407
3414
3408 * ipython.el: committed Alex's recent fixes and improvements.
3415 * ipython.el: committed Alex's recent fixes and improvements.
3409 Tested with python-mode from CVS, and it looks excellent. Since
3416 Tested with python-mode from CVS, and it looks excellent. Since
3410 python-mode hasn't released anything in a while, I'm temporarily
3417 python-mode hasn't released anything in a while, I'm temporarily
3411 putting a copy of today's CVS (v 4.70) of python-mode in:
3418 putting a copy of today's CVS (v 4.70) of python-mode in:
3412 http://ipython.scipy.org/tmp/python-mode.el
3419 http://ipython.scipy.org/tmp/python-mode.el
3413
3420
3414 * scripts/ipython_win_post_install.py (install): Win32 fix to use
3421 * scripts/ipython_win_post_install.py (install): Win32 fix to use
3415 sys.executable for the executable name, instead of assuming it's
3422 sys.executable for the executable name, instead of assuming it's
3416 called 'python.exe' (the post-installer would have produced broken
3423 called 'python.exe' (the post-installer would have produced broken
3417 setups on systems with a differently named python binary).
3424 setups on systems with a differently named python binary).
3418
3425
3419 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
3426 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
3420 references to os.linesep, to make the code more
3427 references to os.linesep, to make the code more
3421 platform-independent. This is also part of the win32 coloring
3428 platform-independent. This is also part of the win32 coloring
3422 fixes.
3429 fixes.
3423
3430
3424 * IPython/genutils.py (page_dumb): Remove attempts to chop long
3431 * IPython/genutils.py (page_dumb): Remove attempts to chop long
3425 lines, which actually cause coloring bugs because the length of
3432 lines, which actually cause coloring bugs because the length of
3426 the line is very difficult to correctly compute with embedded
3433 the line is very difficult to correctly compute with embedded
3427 escapes. This was the source of all the coloring problems under
3434 escapes. This was the source of all the coloring problems under
3428 Win32. I think that _finally_, Win32 users have a properly
3435 Win32. I think that _finally_, Win32 users have a properly
3429 working ipython in all respects. This would never have happened
3436 working ipython in all respects. This would never have happened
3430 if not for Gary Bishop and Viktor Ransmayr's great help and work.
3437 if not for Gary Bishop and Viktor Ransmayr's great help and work.
3431
3438
3432 2005-01-26 *** Released version 0.6.9
3439 2005-01-26 *** Released version 0.6.9
3433
3440
3434 2005-01-25 Fernando Perez <fperez@colorado.edu>
3441 2005-01-25 Fernando Perez <fperez@colorado.edu>
3435
3442
3436 * setup.py: finally, we have a true Windows installer, thanks to
3443 * setup.py: finally, we have a true Windows installer, thanks to
3437 the excellent work of Viktor Ransmayr
3444 the excellent work of Viktor Ransmayr
3438 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
3445 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
3439 Windows users. The setup routine is quite a bit cleaner thanks to
3446 Windows users. The setup routine is quite a bit cleaner thanks to
3440 this, and the post-install script uses the proper functions to
3447 this, and the post-install script uses the proper functions to
3441 allow a clean de-installation using the standard Windows Control
3448 allow a clean de-installation using the standard Windows Control
3442 Panel.
3449 Panel.
3443
3450
3444 * IPython/genutils.py (get_home_dir): changed to use the $HOME
3451 * IPython/genutils.py (get_home_dir): changed to use the $HOME
3445 environment variable under all OSes (including win32) if
3452 environment variable under all OSes (including win32) if
3446 available. This will give consistency to win32 users who have set
3453 available. This will give consistency to win32 users who have set
3447 this variable for any reason. If os.environ['HOME'] fails, the
3454 this variable for any reason. If os.environ['HOME'] fails, the
3448 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
3455 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
3449
3456
3450 2005-01-24 Fernando Perez <fperez@colorado.edu>
3457 2005-01-24 Fernando Perez <fperez@colorado.edu>
3451
3458
3452 * IPython/numutils.py (empty_like): add empty_like(), similar to
3459 * IPython/numutils.py (empty_like): add empty_like(), similar to
3453 zeros_like() but taking advantage of the new empty() Numeric routine.
3460 zeros_like() but taking advantage of the new empty() Numeric routine.
3454
3461
3455 2005-01-23 *** Released version 0.6.8
3462 2005-01-23 *** Released version 0.6.8
3456
3463
3457 2005-01-22 Fernando Perez <fperez@colorado.edu>
3464 2005-01-22 Fernando Perez <fperez@colorado.edu>
3458
3465
3459 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
3466 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
3460 automatic show() calls. After discussing things with JDH, it
3467 automatic show() calls. After discussing things with JDH, it
3461 turns out there are too many corner cases where this can go wrong.
3468 turns out there are too many corner cases where this can go wrong.
3462 It's best not to try to be 'too smart', and simply have ipython
3469 It's best not to try to be 'too smart', and simply have ipython
3463 reproduce as much as possible the default behavior of a normal
3470 reproduce as much as possible the default behavior of a normal
3464 python shell.
3471 python shell.
3465
3472
3466 * IPython/iplib.py (InteractiveShell.__init__): Modified the
3473 * IPython/iplib.py (InteractiveShell.__init__): Modified the
3467 line-splitting regexp and _prefilter() to avoid calling getattr()
3474 line-splitting regexp and _prefilter() to avoid calling getattr()
3468 on assignments. This closes
3475 on assignments. This closes
3469 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
3476 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
3470 readline uses getattr(), so a simple <TAB> keypress is still
3477 readline uses getattr(), so a simple <TAB> keypress is still
3471 enough to trigger getattr() calls on an object.
3478 enough to trigger getattr() calls on an object.
3472
3479
3473 2005-01-21 Fernando Perez <fperez@colorado.edu>
3480 2005-01-21 Fernando Perez <fperez@colorado.edu>
3474
3481
3475 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
3482 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
3476 docstring under pylab so it doesn't mask the original.
3483 docstring under pylab so it doesn't mask the original.
3477
3484
3478 2005-01-21 *** Released version 0.6.7
3485 2005-01-21 *** Released version 0.6.7
3479
3486
3480 2005-01-21 Fernando Perez <fperez@colorado.edu>
3487 2005-01-21 Fernando Perez <fperez@colorado.edu>
3481
3488
3482 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
3489 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
3483 signal handling for win32 users in multithreaded mode.
3490 signal handling for win32 users in multithreaded mode.
3484
3491
3485 2005-01-17 Fernando Perez <fperez@colorado.edu>
3492 2005-01-17 Fernando Perez <fperez@colorado.edu>
3486
3493
3487 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3494 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3488 instances with no __init__. After a crash report by Norbert Nemec
3495 instances with no __init__. After a crash report by Norbert Nemec
3489 <Norbert-AT-nemec-online.de>.
3496 <Norbert-AT-nemec-online.de>.
3490
3497
3491 2005-01-14 Fernando Perez <fperez@colorado.edu>
3498 2005-01-14 Fernando Perez <fperez@colorado.edu>
3492
3499
3493 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
3500 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
3494 names for verbose exceptions, when multiple dotted names and the
3501 names for verbose exceptions, when multiple dotted names and the
3495 'parent' object were present on the same line.
3502 'parent' object were present on the same line.
3496
3503
3497 2005-01-11 Fernando Perez <fperez@colorado.edu>
3504 2005-01-11 Fernando Perez <fperez@colorado.edu>
3498
3505
3499 * IPython/genutils.py (flag_calls): new utility to trap and flag
3506 * IPython/genutils.py (flag_calls): new utility to trap and flag
3500 calls in functions. I need it to clean up matplotlib support.
3507 calls in functions. I need it to clean up matplotlib support.
3501 Also removed some deprecated code in genutils.
3508 Also removed some deprecated code in genutils.
3502
3509
3503 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
3510 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
3504 that matplotlib scripts called with %run, which don't call show()
3511 that matplotlib scripts called with %run, which don't call show()
3505 themselves, still have their plotting windows open.
3512 themselves, still have their plotting windows open.
3506
3513
3507 2005-01-05 Fernando Perez <fperez@colorado.edu>
3514 2005-01-05 Fernando Perez <fperez@colorado.edu>
3508
3515
3509 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
3516 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
3510 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
3517 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
3511
3518
3512 2004-12-19 Fernando Perez <fperez@colorado.edu>
3519 2004-12-19 Fernando Perez <fperez@colorado.edu>
3513
3520
3514 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
3521 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
3515 parent_runcode, which was an eyesore. The same result can be
3522 parent_runcode, which was an eyesore. The same result can be
3516 obtained with Python's regular superclass mechanisms.
3523 obtained with Python's regular superclass mechanisms.
3517
3524
3518 2004-12-17 Fernando Perez <fperez@colorado.edu>
3525 2004-12-17 Fernando Perez <fperez@colorado.edu>
3519
3526
3520 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
3527 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
3521 reported by Prabhu.
3528 reported by Prabhu.
3522 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
3529 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
3523 sys.stderr) instead of explicitly calling sys.stderr. This helps
3530 sys.stderr) instead of explicitly calling sys.stderr. This helps
3524 maintain our I/O abstractions clean, for future GUI embeddings.
3531 maintain our I/O abstractions clean, for future GUI embeddings.
3525
3532
3526 * IPython/genutils.py (info): added new utility for sys.stderr
3533 * IPython/genutils.py (info): added new utility for sys.stderr
3527 unified info message handling (thin wrapper around warn()).
3534 unified info message handling (thin wrapper around warn()).
3528
3535
3529 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
3536 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
3530 composite (dotted) names on verbose exceptions.
3537 composite (dotted) names on verbose exceptions.
3531 (VerboseTB.nullrepr): harden against another kind of errors which
3538 (VerboseTB.nullrepr): harden against another kind of errors which
3532 Python's inspect module can trigger, and which were crashing
3539 Python's inspect module can trigger, and which were crashing
3533 IPython. Thanks to a report by Marco Lombardi
3540 IPython. Thanks to a report by Marco Lombardi
3534 <mlombard-AT-ma010192.hq.eso.org>.
3541 <mlombard-AT-ma010192.hq.eso.org>.
3535
3542
3536 2004-12-13 *** Released version 0.6.6
3543 2004-12-13 *** Released version 0.6.6
3537
3544
3538 2004-12-12 Fernando Perez <fperez@colorado.edu>
3545 2004-12-12 Fernando Perez <fperez@colorado.edu>
3539
3546
3540 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
3547 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
3541 generated by pygtk upon initialization if it was built without
3548 generated by pygtk upon initialization if it was built without
3542 threads (for matplotlib users). After a crash reported by
3549 threads (for matplotlib users). After a crash reported by
3543 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
3550 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
3544
3551
3545 * IPython/ipmaker.py (make_IPython): fix small bug in the
3552 * IPython/ipmaker.py (make_IPython): fix small bug in the
3546 import_some parameter for multiple imports.
3553 import_some parameter for multiple imports.
3547
3554
3548 * IPython/iplib.py (ipmagic): simplified the interface of
3555 * IPython/iplib.py (ipmagic): simplified the interface of
3549 ipmagic() to take a single string argument, just as it would be
3556 ipmagic() to take a single string argument, just as it would be
3550 typed at the IPython cmd line.
3557 typed at the IPython cmd line.
3551 (ipalias): Added new ipalias() with an interface identical to
3558 (ipalias): Added new ipalias() with an interface identical to
3552 ipmagic(). This completes exposing a pure python interface to the
3559 ipmagic(). This completes exposing a pure python interface to the
3553 alias and magic system, which can be used in loops or more complex
3560 alias and magic system, which can be used in loops or more complex
3554 code where IPython's automatic line mangling is not active.
3561 code where IPython's automatic line mangling is not active.
3555
3562
3556 * IPython/genutils.py (timing): changed interface of timing to
3563 * IPython/genutils.py (timing): changed interface of timing to
3557 simply run code once, which is the most common case. timings()
3564 simply run code once, which is the most common case. timings()
3558 remains unchanged, for the cases where you want multiple runs.
3565 remains unchanged, for the cases where you want multiple runs.
3559
3566
3560 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
3567 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
3561 bug where Python2.2 crashes with exec'ing code which does not end
3568 bug where Python2.2 crashes with exec'ing code which does not end
3562 in a single newline. Python 2.3 is OK, so I hadn't noticed this
3569 in a single newline. Python 2.3 is OK, so I hadn't noticed this
3563 before.
3570 before.
3564
3571
3565 2004-12-10 Fernando Perez <fperez@colorado.edu>
3572 2004-12-10 Fernando Perez <fperez@colorado.edu>
3566
3573
3567 * IPython/Magic.py (Magic.magic_prun): changed name of option from
3574 * IPython/Magic.py (Magic.magic_prun): changed name of option from
3568 -t to -T, to accomodate the new -t flag in %run (the %run and
3575 -t to -T, to accomodate the new -t flag in %run (the %run and
3569 %prun options are kind of intermixed, and it's not easy to change
3576 %prun options are kind of intermixed, and it's not easy to change
3570 this with the limitations of python's getopt).
3577 this with the limitations of python's getopt).
3571
3578
3572 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
3579 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
3573 the execution of scripts. It's not as fine-tuned as timeit.py,
3580 the execution of scripts. It's not as fine-tuned as timeit.py,
3574 but it works from inside ipython (and under 2.2, which lacks
3581 but it works from inside ipython (and under 2.2, which lacks
3575 timeit.py). Optionally a number of runs > 1 can be given for
3582 timeit.py). Optionally a number of runs > 1 can be given for
3576 timing very short-running code.
3583 timing very short-running code.
3577
3584
3578 * IPython/genutils.py (uniq_stable): new routine which returns a
3585 * IPython/genutils.py (uniq_stable): new routine which returns a
3579 list of unique elements in any iterable, but in stable order of
3586 list of unique elements in any iterable, but in stable order of
3580 appearance. I needed this for the ultraTB fixes, and it's a handy
3587 appearance. I needed this for the ultraTB fixes, and it's a handy
3581 utility.
3588 utility.
3582
3589
3583 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
3590 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
3584 dotted names in Verbose exceptions. This had been broken since
3591 dotted names in Verbose exceptions. This had been broken since
3585 the very start, now x.y will properly be printed in a Verbose
3592 the very start, now x.y will properly be printed in a Verbose
3586 traceback, instead of x being shown and y appearing always as an
3593 traceback, instead of x being shown and y appearing always as an
3587 'undefined global'. Getting this to work was a bit tricky,
3594 'undefined global'. Getting this to work was a bit tricky,
3588 because by default python tokenizers are stateless. Saved by
3595 because by default python tokenizers are stateless. Saved by
3589 python's ability to easily add a bit of state to an arbitrary
3596 python's ability to easily add a bit of state to an arbitrary
3590 function (without needing to build a full-blown callable object).
3597 function (without needing to build a full-blown callable object).
3591
3598
3592 Also big cleanup of this code, which had horrendous runtime
3599 Also big cleanup of this code, which had horrendous runtime
3593 lookups of zillions of attributes for colorization. Moved all
3600 lookups of zillions of attributes for colorization. Moved all
3594 this code into a few templates, which make it cleaner and quicker.
3601 this code into a few templates, which make it cleaner and quicker.
3595
3602
3596 Printout quality was also improved for Verbose exceptions: one
3603 Printout quality was also improved for Verbose exceptions: one
3597 variable per line, and memory addresses are printed (this can be
3604 variable per line, and memory addresses are printed (this can be
3598 quite handy in nasty debugging situations, which is what Verbose
3605 quite handy in nasty debugging situations, which is what Verbose
3599 is for).
3606 is for).
3600
3607
3601 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
3608 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
3602 the command line as scripts to be loaded by embedded instances.
3609 the command line as scripts to be loaded by embedded instances.
3603 Doing so has the potential for an infinite recursion if there are
3610 Doing so has the potential for an infinite recursion if there are
3604 exceptions thrown in the process. This fixes a strange crash
3611 exceptions thrown in the process. This fixes a strange crash
3605 reported by Philippe MULLER <muller-AT-irit.fr>.
3612 reported by Philippe MULLER <muller-AT-irit.fr>.
3606
3613
3607 2004-12-09 Fernando Perez <fperez@colorado.edu>
3614 2004-12-09 Fernando Perez <fperez@colorado.edu>
3608
3615
3609 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
3616 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
3610 to reflect new names in matplotlib, which now expose the
3617 to reflect new names in matplotlib, which now expose the
3611 matlab-compatible interface via a pylab module instead of the
3618 matlab-compatible interface via a pylab module instead of the
3612 'matlab' name. The new code is backwards compatible, so users of
3619 'matlab' name. The new code is backwards compatible, so users of
3613 all matplotlib versions are OK. Patch by J. Hunter.
3620 all matplotlib versions are OK. Patch by J. Hunter.
3614
3621
3615 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
3622 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
3616 of __init__ docstrings for instances (class docstrings are already
3623 of __init__ docstrings for instances (class docstrings are already
3617 automatically printed). Instances with customized docstrings
3624 automatically printed). Instances with customized docstrings
3618 (indep. of the class) are also recognized and all 3 separate
3625 (indep. of the class) are also recognized and all 3 separate
3619 docstrings are printed (instance, class, constructor). After some
3626 docstrings are printed (instance, class, constructor). After some
3620 comments/suggestions by J. Hunter.
3627 comments/suggestions by J. Hunter.
3621
3628
3622 2004-12-05 Fernando Perez <fperez@colorado.edu>
3629 2004-12-05 Fernando Perez <fperez@colorado.edu>
3623
3630
3624 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
3631 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
3625 warnings when tab-completion fails and triggers an exception.
3632 warnings when tab-completion fails and triggers an exception.
3626
3633
3627 2004-12-03 Fernando Perez <fperez@colorado.edu>
3634 2004-12-03 Fernando Perez <fperez@colorado.edu>
3628
3635
3629 * IPython/Magic.py (magic_prun): Fix bug where an exception would
3636 * IPython/Magic.py (magic_prun): Fix bug where an exception would
3630 be triggered when using 'run -p'. An incorrect option flag was
3637 be triggered when using 'run -p'. An incorrect option flag was
3631 being set ('d' instead of 'D').
3638 being set ('d' instead of 'D').
3632 (manpage): fix missing escaped \- sign.
3639 (manpage): fix missing escaped \- sign.
3633
3640
3634 2004-11-30 *** Released version 0.6.5
3641 2004-11-30 *** Released version 0.6.5
3635
3642
3636 2004-11-30 Fernando Perez <fperez@colorado.edu>
3643 2004-11-30 Fernando Perez <fperez@colorado.edu>
3637
3644
3638 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
3645 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
3639 setting with -d option.
3646 setting with -d option.
3640
3647
3641 * setup.py (docfiles): Fix problem where the doc glob I was using
3648 * setup.py (docfiles): Fix problem where the doc glob I was using
3642 was COMPLETELY BROKEN. It was giving the right files by pure
3649 was COMPLETELY BROKEN. It was giving the right files by pure
3643 accident, but failed once I tried to include ipython.el. Note:
3650 accident, but failed once I tried to include ipython.el. Note:
3644 glob() does NOT allow you to do exclusion on multiple endings!
3651 glob() does NOT allow you to do exclusion on multiple endings!
3645
3652
3646 2004-11-29 Fernando Perez <fperez@colorado.edu>
3653 2004-11-29 Fernando Perez <fperez@colorado.edu>
3647
3654
3648 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
3655 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
3649 the manpage as the source. Better formatting & consistency.
3656 the manpage as the source. Better formatting & consistency.
3650
3657
3651 * IPython/Magic.py (magic_run): Added new -d option, to run
3658 * IPython/Magic.py (magic_run): Added new -d option, to run
3652 scripts under the control of the python pdb debugger. Note that
3659 scripts under the control of the python pdb debugger. Note that
3653 this required changing the %prun option -d to -D, to avoid a clash
3660 this required changing the %prun option -d to -D, to avoid a clash
3654 (since %run must pass options to %prun, and getopt is too dumb to
3661 (since %run must pass options to %prun, and getopt is too dumb to
3655 handle options with string values with embedded spaces). Thanks
3662 handle options with string values with embedded spaces). Thanks
3656 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
3663 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
3657 (magic_who_ls): added type matching to %who and %whos, so that one
3664 (magic_who_ls): added type matching to %who and %whos, so that one
3658 can filter their output to only include variables of certain
3665 can filter their output to only include variables of certain
3659 types. Another suggestion by Matthew.
3666 types. Another suggestion by Matthew.
3660 (magic_whos): Added memory summaries in kb and Mb for arrays.
3667 (magic_whos): Added memory summaries in kb and Mb for arrays.
3661 (magic_who): Improve formatting (break lines every 9 vars).
3668 (magic_who): Improve formatting (break lines every 9 vars).
3662
3669
3663 2004-11-28 Fernando Perez <fperez@colorado.edu>
3670 2004-11-28 Fernando Perez <fperez@colorado.edu>
3664
3671
3665 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
3672 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
3666 cache when empty lines were present.
3673 cache when empty lines were present.
3667
3674
3668 2004-11-24 Fernando Perez <fperez@colorado.edu>
3675 2004-11-24 Fernando Perez <fperez@colorado.edu>
3669
3676
3670 * IPython/usage.py (__doc__): document the re-activated threading
3677 * IPython/usage.py (__doc__): document the re-activated threading
3671 options for WX and GTK.
3678 options for WX and GTK.
3672
3679
3673 2004-11-23 Fernando Perez <fperez@colorado.edu>
3680 2004-11-23 Fernando Perez <fperez@colorado.edu>
3674
3681
3675 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
3682 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
3676 the -wthread and -gthread options, along with a new -tk one to try
3683 the -wthread and -gthread options, along with a new -tk one to try
3677 and coordinate Tk threading with wx/gtk. The tk support is very
3684 and coordinate Tk threading with wx/gtk. The tk support is very
3678 platform dependent, since it seems to require Tcl and Tk to be
3685 platform dependent, since it seems to require Tcl and Tk to be
3679 built with threads (Fedora1/2 appears NOT to have it, but in
3686 built with threads (Fedora1/2 appears NOT to have it, but in
3680 Prabhu's Debian boxes it works OK). But even with some Tk
3687 Prabhu's Debian boxes it works OK). But even with some Tk
3681 limitations, this is a great improvement.
3688 limitations, this is a great improvement.
3682
3689
3683 * IPython/Prompts.py (prompt_specials_color): Added \t for time
3690 * IPython/Prompts.py (prompt_specials_color): Added \t for time
3684 info in user prompts. Patch by Prabhu.
3691 info in user prompts. Patch by Prabhu.
3685
3692
3686 2004-11-18 Fernando Perez <fperez@colorado.edu>
3693 2004-11-18 Fernando Perez <fperez@colorado.edu>
3687
3694
3688 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
3695 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
3689 EOFErrors and bail, to avoid infinite loops if a non-terminating
3696 EOFErrors and bail, to avoid infinite loops if a non-terminating
3690 file is fed into ipython. Patch submitted in issue 19 by user,
3697 file is fed into ipython. Patch submitted in issue 19 by user,
3691 many thanks.
3698 many thanks.
3692
3699
3693 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
3700 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
3694 autoquote/parens in continuation prompts, which can cause lots of
3701 autoquote/parens in continuation prompts, which can cause lots of
3695 problems. Closes roundup issue 20.
3702 problems. Closes roundup issue 20.
3696
3703
3697 2004-11-17 Fernando Perez <fperez@colorado.edu>
3704 2004-11-17 Fernando Perez <fperez@colorado.edu>
3698
3705
3699 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
3706 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
3700 reported as debian bug #280505. I'm not sure my local changelog
3707 reported as debian bug #280505. I'm not sure my local changelog
3701 entry has the proper debian format (Jack?).
3708 entry has the proper debian format (Jack?).
3702
3709
3703 2004-11-08 *** Released version 0.6.4
3710 2004-11-08 *** Released version 0.6.4
3704
3711
3705 2004-11-08 Fernando Perez <fperez@colorado.edu>
3712 2004-11-08 Fernando Perez <fperez@colorado.edu>
3706
3713
3707 * IPython/iplib.py (init_readline): Fix exit message for Windows
3714 * IPython/iplib.py (init_readline): Fix exit message for Windows
3708 when readline is active. Thanks to a report by Eric Jones
3715 when readline is active. Thanks to a report by Eric Jones
3709 <eric-AT-enthought.com>.
3716 <eric-AT-enthought.com>.
3710
3717
3711 2004-11-07 Fernando Perez <fperez@colorado.edu>
3718 2004-11-07 Fernando Perez <fperez@colorado.edu>
3712
3719
3713 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3720 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3714 sometimes seen by win2k/cygwin users.
3721 sometimes seen by win2k/cygwin users.
3715
3722
3716 2004-11-06 Fernando Perez <fperez@colorado.edu>
3723 2004-11-06 Fernando Perez <fperez@colorado.edu>
3717
3724
3718 * IPython/iplib.py (interact): Change the handling of %Exit from
3725 * IPython/iplib.py (interact): Change the handling of %Exit from
3719 trying to propagate a SystemExit to an internal ipython flag.
3726 trying to propagate a SystemExit to an internal ipython flag.
3720 This is less elegant than using Python's exception mechanism, but
3727 This is less elegant than using Python's exception mechanism, but
3721 I can't get that to work reliably with threads, so under -pylab
3728 I can't get that to work reliably with threads, so under -pylab
3722 %Exit was hanging IPython. Cross-thread exception handling is
3729 %Exit was hanging IPython. Cross-thread exception handling is
3723 really a bitch. Thaks to a bug report by Stephen Walton
3730 really a bitch. Thaks to a bug report by Stephen Walton
3724 <stephen.walton-AT-csun.edu>.
3731 <stephen.walton-AT-csun.edu>.
3725
3732
3726 2004-11-04 Fernando Perez <fperez@colorado.edu>
3733 2004-11-04 Fernando Perez <fperez@colorado.edu>
3727
3734
3728 * IPython/iplib.py (raw_input_original): store a pointer to the
3735 * IPython/iplib.py (raw_input_original): store a pointer to the
3729 true raw_input to harden against code which can modify it
3736 true raw_input to harden against code which can modify it
3730 (wx.py.PyShell does this and would otherwise crash ipython).
3737 (wx.py.PyShell does this and would otherwise crash ipython).
3731 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3738 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3732
3739
3733 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3740 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3734 Ctrl-C problem, which does not mess up the input line.
3741 Ctrl-C problem, which does not mess up the input line.
3735
3742
3736 2004-11-03 Fernando Perez <fperez@colorado.edu>
3743 2004-11-03 Fernando Perez <fperez@colorado.edu>
3737
3744
3738 * IPython/Release.py: Changed licensing to BSD, in all files.
3745 * IPython/Release.py: Changed licensing to BSD, in all files.
3739 (name): lowercase name for tarball/RPM release.
3746 (name): lowercase name for tarball/RPM release.
3740
3747
3741 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3748 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3742 use throughout ipython.
3749 use throughout ipython.
3743
3750
3744 * IPython/Magic.py (Magic._ofind): Switch to using the new
3751 * IPython/Magic.py (Magic._ofind): Switch to using the new
3745 OInspect.getdoc() function.
3752 OInspect.getdoc() function.
3746
3753
3747 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3754 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3748 of the line currently being canceled via Ctrl-C. It's extremely
3755 of the line currently being canceled via Ctrl-C. It's extremely
3749 ugly, but I don't know how to do it better (the problem is one of
3756 ugly, but I don't know how to do it better (the problem is one of
3750 handling cross-thread exceptions).
3757 handling cross-thread exceptions).
3751
3758
3752 2004-10-28 Fernando Perez <fperez@colorado.edu>
3759 2004-10-28 Fernando Perez <fperez@colorado.edu>
3753
3760
3754 * IPython/Shell.py (signal_handler): add signal handlers to trap
3761 * IPython/Shell.py (signal_handler): add signal handlers to trap
3755 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3762 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3756 report by Francesc Alted.
3763 report by Francesc Alted.
3757
3764
3758 2004-10-21 Fernando Perez <fperez@colorado.edu>
3765 2004-10-21 Fernando Perez <fperez@colorado.edu>
3759
3766
3760 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3767 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3761 to % for pysh syntax extensions.
3768 to % for pysh syntax extensions.
3762
3769
3763 2004-10-09 Fernando Perez <fperez@colorado.edu>
3770 2004-10-09 Fernando Perez <fperez@colorado.edu>
3764
3771
3765 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3772 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3766 arrays to print a more useful summary, without calling str(arr).
3773 arrays to print a more useful summary, without calling str(arr).
3767 This avoids the problem of extremely lengthy computations which
3774 This avoids the problem of extremely lengthy computations which
3768 occur if arr is large, and appear to the user as a system lockup
3775 occur if arr is large, and appear to the user as a system lockup
3769 with 100% cpu activity. After a suggestion by Kristian Sandberg
3776 with 100% cpu activity. After a suggestion by Kristian Sandberg
3770 <Kristian.Sandberg@colorado.edu>.
3777 <Kristian.Sandberg@colorado.edu>.
3771 (Magic.__init__): fix bug in global magic escapes not being
3778 (Magic.__init__): fix bug in global magic escapes not being
3772 correctly set.
3779 correctly set.
3773
3780
3774 2004-10-08 Fernando Perez <fperez@colorado.edu>
3781 2004-10-08 Fernando Perez <fperez@colorado.edu>
3775
3782
3776 * IPython/Magic.py (__license__): change to absolute imports of
3783 * IPython/Magic.py (__license__): change to absolute imports of
3777 ipython's own internal packages, to start adapting to the absolute
3784 ipython's own internal packages, to start adapting to the absolute
3778 import requirement of PEP-328.
3785 import requirement of PEP-328.
3779
3786
3780 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3787 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3781 files, and standardize author/license marks through the Release
3788 files, and standardize author/license marks through the Release
3782 module instead of having per/file stuff (except for files with
3789 module instead of having per/file stuff (except for files with
3783 particular licenses, like the MIT/PSF-licensed codes).
3790 particular licenses, like the MIT/PSF-licensed codes).
3784
3791
3785 * IPython/Debugger.py: remove dead code for python 2.1
3792 * IPython/Debugger.py: remove dead code for python 2.1
3786
3793
3787 2004-10-04 Fernando Perez <fperez@colorado.edu>
3794 2004-10-04 Fernando Perez <fperez@colorado.edu>
3788
3795
3789 * IPython/iplib.py (ipmagic): New function for accessing magics
3796 * IPython/iplib.py (ipmagic): New function for accessing magics
3790 via a normal python function call.
3797 via a normal python function call.
3791
3798
3792 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3799 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3793 from '@' to '%', to accomodate the new @decorator syntax of python
3800 from '@' to '%', to accomodate the new @decorator syntax of python
3794 2.4.
3801 2.4.
3795
3802
3796 2004-09-29 Fernando Perez <fperez@colorado.edu>
3803 2004-09-29 Fernando Perez <fperez@colorado.edu>
3797
3804
3798 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3805 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3799 matplotlib.use to prevent running scripts which try to switch
3806 matplotlib.use to prevent running scripts which try to switch
3800 interactive backends from within ipython. This will just crash
3807 interactive backends from within ipython. This will just crash
3801 the python interpreter, so we can't allow it (but a detailed error
3808 the python interpreter, so we can't allow it (but a detailed error
3802 is given to the user).
3809 is given to the user).
3803
3810
3804 2004-09-28 Fernando Perez <fperez@colorado.edu>
3811 2004-09-28 Fernando Perez <fperez@colorado.edu>
3805
3812
3806 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3813 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3807 matplotlib-related fixes so that using @run with non-matplotlib
3814 matplotlib-related fixes so that using @run with non-matplotlib
3808 scripts doesn't pop up spurious plot windows. This requires
3815 scripts doesn't pop up spurious plot windows. This requires
3809 matplotlib >= 0.63, where I had to make some changes as well.
3816 matplotlib >= 0.63, where I had to make some changes as well.
3810
3817
3811 * IPython/ipmaker.py (make_IPython): update version requirement to
3818 * IPython/ipmaker.py (make_IPython): update version requirement to
3812 python 2.2.
3819 python 2.2.
3813
3820
3814 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3821 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3815 banner arg for embedded customization.
3822 banner arg for embedded customization.
3816
3823
3817 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3824 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3818 explicit uses of __IP as the IPython's instance name. Now things
3825 explicit uses of __IP as the IPython's instance name. Now things
3819 are properly handled via the shell.name value. The actual code
3826 are properly handled via the shell.name value. The actual code
3820 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3827 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3821 is much better than before. I'll clean things completely when the
3828 is much better than before. I'll clean things completely when the
3822 magic stuff gets a real overhaul.
3829 magic stuff gets a real overhaul.
3823
3830
3824 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3831 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3825 minor changes to debian dir.
3832 minor changes to debian dir.
3826
3833
3827 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3834 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3828 pointer to the shell itself in the interactive namespace even when
3835 pointer to the shell itself in the interactive namespace even when
3829 a user-supplied dict is provided. This is needed for embedding
3836 a user-supplied dict is provided. This is needed for embedding
3830 purposes (found by tests with Michel Sanner).
3837 purposes (found by tests with Michel Sanner).
3831
3838
3832 2004-09-27 Fernando Perez <fperez@colorado.edu>
3839 2004-09-27 Fernando Perez <fperez@colorado.edu>
3833
3840
3834 * IPython/UserConfig/ipythonrc: remove []{} from
3841 * IPython/UserConfig/ipythonrc: remove []{} from
3835 readline_remove_delims, so that things like [modname.<TAB> do
3842 readline_remove_delims, so that things like [modname.<TAB> do
3836 proper completion. This disables [].TAB, but that's a less common
3843 proper completion. This disables [].TAB, but that's a less common
3837 case than module names in list comprehensions, for example.
3844 case than module names in list comprehensions, for example.
3838 Thanks to a report by Andrea Riciputi.
3845 Thanks to a report by Andrea Riciputi.
3839
3846
3840 2004-09-09 Fernando Perez <fperez@colorado.edu>
3847 2004-09-09 Fernando Perez <fperez@colorado.edu>
3841
3848
3842 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3849 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3843 blocking problems in win32 and osx. Fix by John.
3850 blocking problems in win32 and osx. Fix by John.
3844
3851
3845 2004-09-08 Fernando Perez <fperez@colorado.edu>
3852 2004-09-08 Fernando Perez <fperez@colorado.edu>
3846
3853
3847 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3854 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3848 for Win32 and OSX. Fix by John Hunter.
3855 for Win32 and OSX. Fix by John Hunter.
3849
3856
3850 2004-08-30 *** Released version 0.6.3
3857 2004-08-30 *** Released version 0.6.3
3851
3858
3852 2004-08-30 Fernando Perez <fperez@colorado.edu>
3859 2004-08-30 Fernando Perez <fperez@colorado.edu>
3853
3860
3854 * setup.py (isfile): Add manpages to list of dependent files to be
3861 * setup.py (isfile): Add manpages to list of dependent files to be
3855 updated.
3862 updated.
3856
3863
3857 2004-08-27 Fernando Perez <fperez@colorado.edu>
3864 2004-08-27 Fernando Perez <fperez@colorado.edu>
3858
3865
3859 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3866 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3860 for now. They don't really work with standalone WX/GTK code
3867 for now. They don't really work with standalone WX/GTK code
3861 (though matplotlib IS working fine with both of those backends).
3868 (though matplotlib IS working fine with both of those backends).
3862 This will neeed much more testing. I disabled most things with
3869 This will neeed much more testing. I disabled most things with
3863 comments, so turning it back on later should be pretty easy.
3870 comments, so turning it back on later should be pretty easy.
3864
3871
3865 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3872 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3866 autocalling of expressions like r'foo', by modifying the line
3873 autocalling of expressions like r'foo', by modifying the line
3867 split regexp. Closes
3874 split regexp. Closes
3868 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3875 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3869 Riley <ipythonbugs-AT-sabi.net>.
3876 Riley <ipythonbugs-AT-sabi.net>.
3870 (InteractiveShell.mainloop): honor --nobanner with banner
3877 (InteractiveShell.mainloop): honor --nobanner with banner
3871 extensions.
3878 extensions.
3872
3879
3873 * IPython/Shell.py: Significant refactoring of all classes, so
3880 * IPython/Shell.py: Significant refactoring of all classes, so
3874 that we can really support ALL matplotlib backends and threading
3881 that we can really support ALL matplotlib backends and threading
3875 models (John spotted a bug with Tk which required this). Now we
3882 models (John spotted a bug with Tk which required this). Now we
3876 should support single-threaded, WX-threads and GTK-threads, both
3883 should support single-threaded, WX-threads and GTK-threads, both
3877 for generic code and for matplotlib.
3884 for generic code and for matplotlib.
3878
3885
3879 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3886 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3880 -pylab, to simplify things for users. Will also remove the pylab
3887 -pylab, to simplify things for users. Will also remove the pylab
3881 profile, since now all of matplotlib configuration is directly
3888 profile, since now all of matplotlib configuration is directly
3882 handled here. This also reduces startup time.
3889 handled here. This also reduces startup time.
3883
3890
3884 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3891 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3885 shell wasn't being correctly called. Also in IPShellWX.
3892 shell wasn't being correctly called. Also in IPShellWX.
3886
3893
3887 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3894 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3888 fine-tune banner.
3895 fine-tune banner.
3889
3896
3890 * IPython/numutils.py (spike): Deprecate these spike functions,
3897 * IPython/numutils.py (spike): Deprecate these spike functions,
3891 delete (long deprecated) gnuplot_exec handler.
3898 delete (long deprecated) gnuplot_exec handler.
3892
3899
3893 2004-08-26 Fernando Perez <fperez@colorado.edu>
3900 2004-08-26 Fernando Perez <fperez@colorado.edu>
3894
3901
3895 * ipython.1: Update for threading options, plus some others which
3902 * ipython.1: Update for threading options, plus some others which
3896 were missing.
3903 were missing.
3897
3904
3898 * IPython/ipmaker.py (__call__): Added -wthread option for
3905 * IPython/ipmaker.py (__call__): Added -wthread option for
3899 wxpython thread handling. Make sure threading options are only
3906 wxpython thread handling. Make sure threading options are only
3900 valid at the command line.
3907 valid at the command line.
3901
3908
3902 * scripts/ipython: moved shell selection into a factory function
3909 * scripts/ipython: moved shell selection into a factory function
3903 in Shell.py, to keep the starter script to a minimum.
3910 in Shell.py, to keep the starter script to a minimum.
3904
3911
3905 2004-08-25 Fernando Perez <fperez@colorado.edu>
3912 2004-08-25 Fernando Perez <fperez@colorado.edu>
3906
3913
3907 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3914 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3908 John. Along with some recent changes he made to matplotlib, the
3915 John. Along with some recent changes he made to matplotlib, the
3909 next versions of both systems should work very well together.
3916 next versions of both systems should work very well together.
3910
3917
3911 2004-08-24 Fernando Perez <fperez@colorado.edu>
3918 2004-08-24 Fernando Perez <fperez@colorado.edu>
3912
3919
3913 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3920 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3914 tried to switch the profiling to using hotshot, but I'm getting
3921 tried to switch the profiling to using hotshot, but I'm getting
3915 strange errors from prof.runctx() there. I may be misreading the
3922 strange errors from prof.runctx() there. I may be misreading the
3916 docs, but it looks weird. For now the profiling code will
3923 docs, but it looks weird. For now the profiling code will
3917 continue to use the standard profiler.
3924 continue to use the standard profiler.
3918
3925
3919 2004-08-23 Fernando Perez <fperez@colorado.edu>
3926 2004-08-23 Fernando Perez <fperez@colorado.edu>
3920
3927
3921 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3928 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3922 threaded shell, by John Hunter. It's not quite ready yet, but
3929 threaded shell, by John Hunter. It's not quite ready yet, but
3923 close.
3930 close.
3924
3931
3925 2004-08-22 Fernando Perez <fperez@colorado.edu>
3932 2004-08-22 Fernando Perez <fperez@colorado.edu>
3926
3933
3927 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3934 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3928 in Magic and ultraTB.
3935 in Magic and ultraTB.
3929
3936
3930 * ipython.1: document threading options in manpage.
3937 * ipython.1: document threading options in manpage.
3931
3938
3932 * scripts/ipython: Changed name of -thread option to -gthread,
3939 * scripts/ipython: Changed name of -thread option to -gthread,
3933 since this is GTK specific. I want to leave the door open for a
3940 since this is GTK specific. I want to leave the door open for a
3934 -wthread option for WX, which will most likely be necessary. This
3941 -wthread option for WX, which will most likely be necessary. This
3935 change affects usage and ipmaker as well.
3942 change affects usage and ipmaker as well.
3936
3943
3937 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3944 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3938 handle the matplotlib shell issues. Code by John Hunter
3945 handle the matplotlib shell issues. Code by John Hunter
3939 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3946 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3940 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3947 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3941 broken (and disabled for end users) for now, but it puts the
3948 broken (and disabled for end users) for now, but it puts the
3942 infrastructure in place.
3949 infrastructure in place.
3943
3950
3944 2004-08-21 Fernando Perez <fperez@colorado.edu>
3951 2004-08-21 Fernando Perez <fperez@colorado.edu>
3945
3952
3946 * ipythonrc-pylab: Add matplotlib support.
3953 * ipythonrc-pylab: Add matplotlib support.
3947
3954
3948 * matplotlib_config.py: new files for matplotlib support, part of
3955 * matplotlib_config.py: new files for matplotlib support, part of
3949 the pylab profile.
3956 the pylab profile.
3950
3957
3951 * IPython/usage.py (__doc__): documented the threading options.
3958 * IPython/usage.py (__doc__): documented the threading options.
3952
3959
3953 2004-08-20 Fernando Perez <fperez@colorado.edu>
3960 2004-08-20 Fernando Perez <fperez@colorado.edu>
3954
3961
3955 * ipython: Modified the main calling routine to handle the -thread
3962 * ipython: Modified the main calling routine to handle the -thread
3956 and -mpthread options. This needs to be done as a top-level hack,
3963 and -mpthread options. This needs to be done as a top-level hack,
3957 because it determines which class to instantiate for IPython
3964 because it determines which class to instantiate for IPython
3958 itself.
3965 itself.
3959
3966
3960 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3967 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3961 classes to support multithreaded GTK operation without blocking,
3968 classes to support multithreaded GTK operation without blocking,
3962 and matplotlib with all backends. This is a lot of still very
3969 and matplotlib with all backends. This is a lot of still very
3963 experimental code, and threads are tricky. So it may still have a
3970 experimental code, and threads are tricky. So it may still have a
3964 few rough edges... This code owes a lot to
3971 few rough edges... This code owes a lot to
3965 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3972 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3966 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3973 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3967 to John Hunter for all the matplotlib work.
3974 to John Hunter for all the matplotlib work.
3968
3975
3969 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3976 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3970 options for gtk thread and matplotlib support.
3977 options for gtk thread and matplotlib support.
3971
3978
3972 2004-08-16 Fernando Perez <fperez@colorado.edu>
3979 2004-08-16 Fernando Perez <fperez@colorado.edu>
3973
3980
3974 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3981 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3975 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3982 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3976 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3983 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3977
3984
3978 2004-08-11 Fernando Perez <fperez@colorado.edu>
3985 2004-08-11 Fernando Perez <fperez@colorado.edu>
3979
3986
3980 * setup.py (isfile): Fix build so documentation gets updated for
3987 * setup.py (isfile): Fix build so documentation gets updated for
3981 rpms (it was only done for .tgz builds).
3988 rpms (it was only done for .tgz builds).
3982
3989
3983 2004-08-10 Fernando Perez <fperez@colorado.edu>
3990 2004-08-10 Fernando Perez <fperez@colorado.edu>
3984
3991
3985 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3992 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3986
3993
3987 * iplib.py : Silence syntax error exceptions in tab-completion.
3994 * iplib.py : Silence syntax error exceptions in tab-completion.
3988
3995
3989 2004-08-05 Fernando Perez <fperez@colorado.edu>
3996 2004-08-05 Fernando Perez <fperez@colorado.edu>
3990
3997
3991 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3998 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3992 'color off' mark for continuation prompts. This was causing long
3999 'color off' mark for continuation prompts. This was causing long
3993 continuation lines to mis-wrap.
4000 continuation lines to mis-wrap.
3994
4001
3995 2004-08-01 Fernando Perez <fperez@colorado.edu>
4002 2004-08-01 Fernando Perez <fperez@colorado.edu>
3996
4003
3997 * IPython/ipmaker.py (make_IPython): Allow the shell class used
4004 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3998 for building ipython to be a parameter. All this is necessary
4005 for building ipython to be a parameter. All this is necessary
3999 right now to have a multithreaded version, but this insane
4006 right now to have a multithreaded version, but this insane
4000 non-design will be cleaned up soon. For now, it's a hack that
4007 non-design will be cleaned up soon. For now, it's a hack that
4001 works.
4008 works.
4002
4009
4003 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
4010 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
4004 args in various places. No bugs so far, but it's a dangerous
4011 args in various places. No bugs so far, but it's a dangerous
4005 practice.
4012 practice.
4006
4013
4007 2004-07-31 Fernando Perez <fperez@colorado.edu>
4014 2004-07-31 Fernando Perez <fperez@colorado.edu>
4008
4015
4009 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
4016 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
4010 fix completion of files with dots in their names under most
4017 fix completion of files with dots in their names under most
4011 profiles (pysh was OK because the completion order is different).
4018 profiles (pysh was OK because the completion order is different).
4012
4019
4013 2004-07-27 Fernando Perez <fperez@colorado.edu>
4020 2004-07-27 Fernando Perez <fperez@colorado.edu>
4014
4021
4015 * IPython/iplib.py (InteractiveShell.__init__): build dict of
4022 * IPython/iplib.py (InteractiveShell.__init__): build dict of
4016 keywords manually, b/c the one in keyword.py was removed in python
4023 keywords manually, b/c the one in keyword.py was removed in python
4017 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
4024 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
4018 This is NOT a bug under python 2.3 and earlier.
4025 This is NOT a bug under python 2.3 and earlier.
4019
4026
4020 2004-07-26 Fernando Perez <fperez@colorado.edu>
4027 2004-07-26 Fernando Perez <fperez@colorado.edu>
4021
4028
4022 * IPython/ultraTB.py (VerboseTB.text): Add another
4029 * IPython/ultraTB.py (VerboseTB.text): Add another
4023 linecache.checkcache() call to try to prevent inspect.py from
4030 linecache.checkcache() call to try to prevent inspect.py from
4024 crashing under python 2.3. I think this fixes
4031 crashing under python 2.3. I think this fixes
4025 http://www.scipy.net/roundup/ipython/issue17.
4032 http://www.scipy.net/roundup/ipython/issue17.
4026
4033
4027 2004-07-26 *** Released version 0.6.2
4034 2004-07-26 *** Released version 0.6.2
4028
4035
4029 2004-07-26 Fernando Perez <fperez@colorado.edu>
4036 2004-07-26 Fernando Perez <fperez@colorado.edu>
4030
4037
4031 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
4038 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
4032 fail for any number.
4039 fail for any number.
4033 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
4040 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
4034 empty bookmarks.
4041 empty bookmarks.
4035
4042
4036 2004-07-26 *** Released version 0.6.1
4043 2004-07-26 *** Released version 0.6.1
4037
4044
4038 2004-07-26 Fernando Perez <fperez@colorado.edu>
4045 2004-07-26 Fernando Perez <fperez@colorado.edu>
4039
4046
4040 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
4047 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
4041
4048
4042 * IPython/iplib.py (protect_filename): Applied Ville's patch for
4049 * IPython/iplib.py (protect_filename): Applied Ville's patch for
4043 escaping '()[]{}' in filenames.
4050 escaping '()[]{}' in filenames.
4044
4051
4045 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
4052 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
4046 Python 2.2 users who lack a proper shlex.split.
4053 Python 2.2 users who lack a proper shlex.split.
4047
4054
4048 2004-07-19 Fernando Perez <fperez@colorado.edu>
4055 2004-07-19 Fernando Perez <fperez@colorado.edu>
4049
4056
4050 * IPython/iplib.py (InteractiveShell.init_readline): Add support
4057 * IPython/iplib.py (InteractiveShell.init_readline): Add support
4051 for reading readline's init file. I follow the normal chain:
4058 for reading readline's init file. I follow the normal chain:
4052 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
4059 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
4053 report by Mike Heeter. This closes
4060 report by Mike Heeter. This closes
4054 http://www.scipy.net/roundup/ipython/issue16.
4061 http://www.scipy.net/roundup/ipython/issue16.
4055
4062
4056 2004-07-18 Fernando Perez <fperez@colorado.edu>
4063 2004-07-18 Fernando Perez <fperez@colorado.edu>
4057
4064
4058 * IPython/iplib.py (__init__): Add better handling of '\' under
4065 * IPython/iplib.py (__init__): Add better handling of '\' under
4059 Win32 for filenames. After a patch by Ville.
4066 Win32 for filenames. After a patch by Ville.
4060
4067
4061 2004-07-17 Fernando Perez <fperez@colorado.edu>
4068 2004-07-17 Fernando Perez <fperez@colorado.edu>
4062
4069
4063 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4070 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4064 autocalling would be triggered for 'foo is bar' if foo is
4071 autocalling would be triggered for 'foo is bar' if foo is
4065 callable. I also cleaned up the autocall detection code to use a
4072 callable. I also cleaned up the autocall detection code to use a
4066 regexp, which is faster. Bug reported by Alexander Schmolck.
4073 regexp, which is faster. Bug reported by Alexander Schmolck.
4067
4074
4068 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
4075 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
4069 '?' in them would confuse the help system. Reported by Alex
4076 '?' in them would confuse the help system. Reported by Alex
4070 Schmolck.
4077 Schmolck.
4071
4078
4072 2004-07-16 Fernando Perez <fperez@colorado.edu>
4079 2004-07-16 Fernando Perez <fperez@colorado.edu>
4073
4080
4074 * IPython/GnuplotInteractive.py (__all__): added plot2.
4081 * IPython/GnuplotInteractive.py (__all__): added plot2.
4075
4082
4076 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
4083 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
4077 plotting dictionaries, lists or tuples of 1d arrays.
4084 plotting dictionaries, lists or tuples of 1d arrays.
4078
4085
4079 * IPython/Magic.py (Magic.magic_hist): small clenaups and
4086 * IPython/Magic.py (Magic.magic_hist): small clenaups and
4080 optimizations.
4087 optimizations.
4081
4088
4082 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
4089 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
4083 the information which was there from Janko's original IPP code:
4090 the information which was there from Janko's original IPP code:
4084
4091
4085 03.05.99 20:53 porto.ifm.uni-kiel.de
4092 03.05.99 20:53 porto.ifm.uni-kiel.de
4086 --Started changelog.
4093 --Started changelog.
4087 --make clear do what it say it does
4094 --make clear do what it say it does
4088 --added pretty output of lines from inputcache
4095 --added pretty output of lines from inputcache
4089 --Made Logger a mixin class, simplifies handling of switches
4096 --Made Logger a mixin class, simplifies handling of switches
4090 --Added own completer class. .string<TAB> expands to last history
4097 --Added own completer class. .string<TAB> expands to last history
4091 line which starts with string. The new expansion is also present
4098 line which starts with string. The new expansion is also present
4092 with Ctrl-r from the readline library. But this shows, who this
4099 with Ctrl-r from the readline library. But this shows, who this
4093 can be done for other cases.
4100 can be done for other cases.
4094 --Added convention that all shell functions should accept a
4101 --Added convention that all shell functions should accept a
4095 parameter_string This opens the door for different behaviour for
4102 parameter_string This opens the door for different behaviour for
4096 each function. @cd is a good example of this.
4103 each function. @cd is a good example of this.
4097
4104
4098 04.05.99 12:12 porto.ifm.uni-kiel.de
4105 04.05.99 12:12 porto.ifm.uni-kiel.de
4099 --added logfile rotation
4106 --added logfile rotation
4100 --added new mainloop method which freezes first the namespace
4107 --added new mainloop method which freezes first the namespace
4101
4108
4102 07.05.99 21:24 porto.ifm.uni-kiel.de
4109 07.05.99 21:24 porto.ifm.uni-kiel.de
4103 --added the docreader classes. Now there is a help system.
4110 --added the docreader classes. Now there is a help system.
4104 -This is only a first try. Currently it's not easy to put new
4111 -This is only a first try. Currently it's not easy to put new
4105 stuff in the indices. But this is the way to go. Info would be
4112 stuff in the indices. But this is the way to go. Info would be
4106 better, but HTML is every where and not everybody has an info
4113 better, but HTML is every where and not everybody has an info
4107 system installed and it's not so easy to change html-docs to info.
4114 system installed and it's not so easy to change html-docs to info.
4108 --added global logfile option
4115 --added global logfile option
4109 --there is now a hook for object inspection method pinfo needs to
4116 --there is now a hook for object inspection method pinfo needs to
4110 be provided for this. Can be reached by two '??'.
4117 be provided for this. Can be reached by two '??'.
4111
4118
4112 08.05.99 20:51 porto.ifm.uni-kiel.de
4119 08.05.99 20:51 porto.ifm.uni-kiel.de
4113 --added a README
4120 --added a README
4114 --bug in rc file. Something has changed so functions in the rc
4121 --bug in rc file. Something has changed so functions in the rc
4115 file need to reference the shell and not self. Not clear if it's a
4122 file need to reference the shell and not self. Not clear if it's a
4116 bug or feature.
4123 bug or feature.
4117 --changed rc file for new behavior
4124 --changed rc file for new behavior
4118
4125
4119 2004-07-15 Fernando Perez <fperez@colorado.edu>
4126 2004-07-15 Fernando Perez <fperez@colorado.edu>
4120
4127
4121 * IPython/Logger.py (Logger.log): fixed recent bug where the input
4128 * IPython/Logger.py (Logger.log): fixed recent bug where the input
4122 cache was falling out of sync in bizarre manners when multi-line
4129 cache was falling out of sync in bizarre manners when multi-line
4123 input was present. Minor optimizations and cleanup.
4130 input was present. Minor optimizations and cleanup.
4124
4131
4125 (Logger): Remove old Changelog info for cleanup. This is the
4132 (Logger): Remove old Changelog info for cleanup. This is the
4126 information which was there from Janko's original code:
4133 information which was there from Janko's original code:
4127
4134
4128 Changes to Logger: - made the default log filename a parameter
4135 Changes to Logger: - made the default log filename a parameter
4129
4136
4130 - put a check for lines beginning with !@? in log(). Needed
4137 - put a check for lines beginning with !@? in log(). Needed
4131 (even if the handlers properly log their lines) for mid-session
4138 (even if the handlers properly log their lines) for mid-session
4132 logging activation to work properly. Without this, lines logged
4139 logging activation to work properly. Without this, lines logged
4133 in mid session, which get read from the cache, would end up
4140 in mid session, which get read from the cache, would end up
4134 'bare' (with !@? in the open) in the log. Now they are caught
4141 'bare' (with !@? in the open) in the log. Now they are caught
4135 and prepended with a #.
4142 and prepended with a #.
4136
4143
4137 * IPython/iplib.py (InteractiveShell.init_readline): added check
4144 * IPython/iplib.py (InteractiveShell.init_readline): added check
4138 in case MagicCompleter fails to be defined, so we don't crash.
4145 in case MagicCompleter fails to be defined, so we don't crash.
4139
4146
4140 2004-07-13 Fernando Perez <fperez@colorado.edu>
4147 2004-07-13 Fernando Perez <fperez@colorado.edu>
4141
4148
4142 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
4149 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
4143 of EPS if the requested filename ends in '.eps'.
4150 of EPS if the requested filename ends in '.eps'.
4144
4151
4145 2004-07-04 Fernando Perez <fperez@colorado.edu>
4152 2004-07-04 Fernando Perez <fperez@colorado.edu>
4146
4153
4147 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
4154 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
4148 escaping of quotes when calling the shell.
4155 escaping of quotes when calling the shell.
4149
4156
4150 2004-07-02 Fernando Perez <fperez@colorado.edu>
4157 2004-07-02 Fernando Perez <fperez@colorado.edu>
4151
4158
4152 * IPython/Prompts.py (CachedOutput.update): Fix problem with
4159 * IPython/Prompts.py (CachedOutput.update): Fix problem with
4153 gettext not working because we were clobbering '_'. Fixes
4160 gettext not working because we were clobbering '_'. Fixes
4154 http://www.scipy.net/roundup/ipython/issue6.
4161 http://www.scipy.net/roundup/ipython/issue6.
4155
4162
4156 2004-07-01 Fernando Perez <fperez@colorado.edu>
4163 2004-07-01 Fernando Perez <fperez@colorado.edu>
4157
4164
4158 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
4165 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
4159 into @cd. Patch by Ville.
4166 into @cd. Patch by Ville.
4160
4167
4161 * IPython/iplib.py (InteractiveShell.post_config_initialization):
4168 * IPython/iplib.py (InteractiveShell.post_config_initialization):
4162 new function to store things after ipmaker runs. Patch by Ville.
4169 new function to store things after ipmaker runs. Patch by Ville.
4163 Eventually this will go away once ipmaker is removed and the class
4170 Eventually this will go away once ipmaker is removed and the class
4164 gets cleaned up, but for now it's ok. Key functionality here is
4171 gets cleaned up, but for now it's ok. Key functionality here is
4165 the addition of the persistent storage mechanism, a dict for
4172 the addition of the persistent storage mechanism, a dict for
4166 keeping data across sessions (for now just bookmarks, but more can
4173 keeping data across sessions (for now just bookmarks, but more can
4167 be implemented later).
4174 be implemented later).
4168
4175
4169 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
4176 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
4170 persistent across sections. Patch by Ville, I modified it
4177 persistent across sections. Patch by Ville, I modified it
4171 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
4178 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
4172 added a '-l' option to list all bookmarks.
4179 added a '-l' option to list all bookmarks.
4173
4180
4174 * IPython/iplib.py (InteractiveShell.atexit_operations): new
4181 * IPython/iplib.py (InteractiveShell.atexit_operations): new
4175 center for cleanup. Registered with atexit.register(). I moved
4182 center for cleanup. Registered with atexit.register(). I moved
4176 here the old exit_cleanup(). After a patch by Ville.
4183 here the old exit_cleanup(). After a patch by Ville.
4177
4184
4178 * IPython/Magic.py (get_py_filename): added '~' to the accepted
4185 * IPython/Magic.py (get_py_filename): added '~' to the accepted
4179 characters in the hacked shlex_split for python 2.2.
4186 characters in the hacked shlex_split for python 2.2.
4180
4187
4181 * IPython/iplib.py (file_matches): more fixes to filenames with
4188 * IPython/iplib.py (file_matches): more fixes to filenames with
4182 whitespace in them. It's not perfect, but limitations in python's
4189 whitespace in them. It's not perfect, but limitations in python's
4183 readline make it impossible to go further.
4190 readline make it impossible to go further.
4184
4191
4185 2004-06-29 Fernando Perez <fperez@colorado.edu>
4192 2004-06-29 Fernando Perez <fperez@colorado.edu>
4186
4193
4187 * IPython/iplib.py (file_matches): escape whitespace correctly in
4194 * IPython/iplib.py (file_matches): escape whitespace correctly in
4188 filename completions. Bug reported by Ville.
4195 filename completions. Bug reported by Ville.
4189
4196
4190 2004-06-28 Fernando Perez <fperez@colorado.edu>
4197 2004-06-28 Fernando Perez <fperez@colorado.edu>
4191
4198
4192 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
4199 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
4193 the history file will be called 'history-PROFNAME' (or just
4200 the history file will be called 'history-PROFNAME' (or just
4194 'history' if no profile is loaded). I was getting annoyed at
4201 'history' if no profile is loaded). I was getting annoyed at
4195 getting my Numerical work history clobbered by pysh sessions.
4202 getting my Numerical work history clobbered by pysh sessions.
4196
4203
4197 * IPython/iplib.py (InteractiveShell.__init__): Internal
4204 * IPython/iplib.py (InteractiveShell.__init__): Internal
4198 getoutputerror() function so that we can honor the system_verbose
4205 getoutputerror() function so that we can honor the system_verbose
4199 flag for _all_ system calls. I also added escaping of #
4206 flag for _all_ system calls. I also added escaping of #
4200 characters here to avoid confusing Itpl.
4207 characters here to avoid confusing Itpl.
4201
4208
4202 * IPython/Magic.py (shlex_split): removed call to shell in
4209 * IPython/Magic.py (shlex_split): removed call to shell in
4203 parse_options and replaced it with shlex.split(). The annoying
4210 parse_options and replaced it with shlex.split(). The annoying
4204 part was that in Python 2.2, shlex.split() doesn't exist, so I had
4211 part was that in Python 2.2, shlex.split() doesn't exist, so I had
4205 to backport it from 2.3, with several frail hacks (the shlex
4212 to backport it from 2.3, with several frail hacks (the shlex
4206 module is rather limited in 2.2). Thanks to a suggestion by Ville
4213 module is rather limited in 2.2). Thanks to a suggestion by Ville
4207 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
4214 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
4208 problem.
4215 problem.
4209
4216
4210 (Magic.magic_system_verbose): new toggle to print the actual
4217 (Magic.magic_system_verbose): new toggle to print the actual
4211 system calls made by ipython. Mainly for debugging purposes.
4218 system calls made by ipython. Mainly for debugging purposes.
4212
4219
4213 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
4220 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
4214 doesn't support persistence. Reported (and fix suggested) by
4221 doesn't support persistence. Reported (and fix suggested) by
4215 Travis Caldwell <travis_caldwell2000@yahoo.com>.
4222 Travis Caldwell <travis_caldwell2000@yahoo.com>.
4216
4223
4217 2004-06-26 Fernando Perez <fperez@colorado.edu>
4224 2004-06-26 Fernando Perez <fperez@colorado.edu>
4218
4225
4219 * IPython/Logger.py (Logger.log): fix to handle correctly empty
4226 * IPython/Logger.py (Logger.log): fix to handle correctly empty
4220 continue prompts.
4227 continue prompts.
4221
4228
4222 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
4229 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
4223 function (basically a big docstring) and a few more things here to
4230 function (basically a big docstring) and a few more things here to
4224 speedup startup. pysh.py is now very lightweight. We want because
4231 speedup startup. pysh.py is now very lightweight. We want because
4225 it gets execfile'd, while InterpreterExec gets imported, so
4232 it gets execfile'd, while InterpreterExec gets imported, so
4226 byte-compilation saves time.
4233 byte-compilation saves time.
4227
4234
4228 2004-06-25 Fernando Perez <fperez@colorado.edu>
4235 2004-06-25 Fernando Perez <fperez@colorado.edu>
4229
4236
4230 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
4237 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
4231 -NUM', which was recently broken.
4238 -NUM', which was recently broken.
4232
4239
4233 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
4240 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
4234 in multi-line input (but not !!, which doesn't make sense there).
4241 in multi-line input (but not !!, which doesn't make sense there).
4235
4242
4236 * IPython/UserConfig/ipythonrc: made autoindent on by default.
4243 * IPython/UserConfig/ipythonrc: made autoindent on by default.
4237 It's just too useful, and people can turn it off in the less
4244 It's just too useful, and people can turn it off in the less
4238 common cases where it's a problem.
4245 common cases where it's a problem.
4239
4246
4240 2004-06-24 Fernando Perez <fperez@colorado.edu>
4247 2004-06-24 Fernando Perez <fperez@colorado.edu>
4241
4248
4242 * IPython/iplib.py (InteractiveShell._prefilter): big change -
4249 * IPython/iplib.py (InteractiveShell._prefilter): big change -
4243 special syntaxes (like alias calling) is now allied in multi-line
4250 special syntaxes (like alias calling) is now allied in multi-line
4244 input. This is still _very_ experimental, but it's necessary for
4251 input. This is still _very_ experimental, but it's necessary for
4245 efficient shell usage combining python looping syntax with system
4252 efficient shell usage combining python looping syntax with system
4246 calls. For now it's restricted to aliases, I don't think it
4253 calls. For now it's restricted to aliases, I don't think it
4247 really even makes sense to have this for magics.
4254 really even makes sense to have this for magics.
4248
4255
4249 2004-06-23 Fernando Perez <fperez@colorado.edu>
4256 2004-06-23 Fernando Perez <fperez@colorado.edu>
4250
4257
4251 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
4258 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
4252 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
4259 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
4253
4260
4254 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
4261 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
4255 extensions under Windows (after code sent by Gary Bishop). The
4262 extensions under Windows (after code sent by Gary Bishop). The
4256 extensions considered 'executable' are stored in IPython's rc
4263 extensions considered 'executable' are stored in IPython's rc
4257 structure as win_exec_ext.
4264 structure as win_exec_ext.
4258
4265
4259 * IPython/genutils.py (shell): new function, like system() but
4266 * IPython/genutils.py (shell): new function, like system() but
4260 without return value. Very useful for interactive shell work.
4267 without return value. Very useful for interactive shell work.
4261
4268
4262 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
4269 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
4263 delete aliases.
4270 delete aliases.
4264
4271
4265 * IPython/iplib.py (InteractiveShell.alias_table_update): make
4272 * IPython/iplib.py (InteractiveShell.alias_table_update): make
4266 sure that the alias table doesn't contain python keywords.
4273 sure that the alias table doesn't contain python keywords.
4267
4274
4268 2004-06-21 Fernando Perez <fperez@colorado.edu>
4275 2004-06-21 Fernando Perez <fperez@colorado.edu>
4269
4276
4270 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
4277 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
4271 non-existent items are found in $PATH. Reported by Thorsten.
4278 non-existent items are found in $PATH. Reported by Thorsten.
4272
4279
4273 2004-06-20 Fernando Perez <fperez@colorado.edu>
4280 2004-06-20 Fernando Perez <fperez@colorado.edu>
4274
4281
4275 * IPython/iplib.py (complete): modified the completer so that the
4282 * IPython/iplib.py (complete): modified the completer so that the
4276 order of priorities can be easily changed at runtime.
4283 order of priorities can be easily changed at runtime.
4277
4284
4278 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
4285 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
4279 Modified to auto-execute all lines beginning with '~', '/' or '.'.
4286 Modified to auto-execute all lines beginning with '~', '/' or '.'.
4280
4287
4281 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
4288 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
4282 expand Python variables prepended with $ in all system calls. The
4289 expand Python variables prepended with $ in all system calls. The
4283 same was done to InteractiveShell.handle_shell_escape. Now all
4290 same was done to InteractiveShell.handle_shell_escape. Now all
4284 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
4291 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
4285 expansion of python variables and expressions according to the
4292 expansion of python variables and expressions according to the
4286 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
4293 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
4287
4294
4288 Though PEP-215 has been rejected, a similar (but simpler) one
4295 Though PEP-215 has been rejected, a similar (but simpler) one
4289 seems like it will go into Python 2.4, PEP-292 -
4296 seems like it will go into Python 2.4, PEP-292 -
4290 http://www.python.org/peps/pep-0292.html.
4297 http://www.python.org/peps/pep-0292.html.
4291
4298
4292 I'll keep the full syntax of PEP-215, since IPython has since the
4299 I'll keep the full syntax of PEP-215, since IPython has since the
4293 start used Ka-Ping Yee's reference implementation discussed there
4300 start used Ka-Ping Yee's reference implementation discussed there
4294 (Itpl), and I actually like the powerful semantics it offers.
4301 (Itpl), and I actually like the powerful semantics it offers.
4295
4302
4296 In order to access normal shell variables, the $ has to be escaped
4303 In order to access normal shell variables, the $ has to be escaped
4297 via an extra $. For example:
4304 via an extra $. For example:
4298
4305
4299 In [7]: PATH='a python variable'
4306 In [7]: PATH='a python variable'
4300
4307
4301 In [8]: !echo $PATH
4308 In [8]: !echo $PATH
4302 a python variable
4309 a python variable
4303
4310
4304 In [9]: !echo $$PATH
4311 In [9]: !echo $$PATH
4305 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
4312 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
4306
4313
4307 (Magic.parse_options): escape $ so the shell doesn't evaluate
4314 (Magic.parse_options): escape $ so the shell doesn't evaluate
4308 things prematurely.
4315 things prematurely.
4309
4316
4310 * IPython/iplib.py (InteractiveShell.call_alias): added the
4317 * IPython/iplib.py (InteractiveShell.call_alias): added the
4311 ability for aliases to expand python variables via $.
4318 ability for aliases to expand python variables via $.
4312
4319
4313 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
4320 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
4314 system, now there's a @rehash/@rehashx pair of magics. These work
4321 system, now there's a @rehash/@rehashx pair of magics. These work
4315 like the csh rehash command, and can be invoked at any time. They
4322 like the csh rehash command, and can be invoked at any time. They
4316 build a table of aliases to everything in the user's $PATH
4323 build a table of aliases to everything in the user's $PATH
4317 (@rehash uses everything, @rehashx is slower but only adds
4324 (@rehash uses everything, @rehashx is slower but only adds
4318 executable files). With this, the pysh.py-based shell profile can
4325 executable files). With this, the pysh.py-based shell profile can
4319 now simply call rehash upon startup, and full access to all
4326 now simply call rehash upon startup, and full access to all
4320 programs in the user's path is obtained.
4327 programs in the user's path is obtained.
4321
4328
4322 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
4329 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
4323 functionality is now fully in place. I removed the old dynamic
4330 functionality is now fully in place. I removed the old dynamic
4324 code generation based approach, in favor of a much lighter one
4331 code generation based approach, in favor of a much lighter one
4325 based on a simple dict. The advantage is that this allows me to
4332 based on a simple dict. The advantage is that this allows me to
4326 now have thousands of aliases with negligible cost (unthinkable
4333 now have thousands of aliases with negligible cost (unthinkable
4327 with the old system).
4334 with the old system).
4328
4335
4329 2004-06-19 Fernando Perez <fperez@colorado.edu>
4336 2004-06-19 Fernando Perez <fperez@colorado.edu>
4330
4337
4331 * IPython/iplib.py (__init__): extended MagicCompleter class to
4338 * IPython/iplib.py (__init__): extended MagicCompleter class to
4332 also complete (last in priority) on user aliases.
4339 also complete (last in priority) on user aliases.
4333
4340
4334 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
4341 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
4335 call to eval.
4342 call to eval.
4336 (ItplNS.__init__): Added a new class which functions like Itpl,
4343 (ItplNS.__init__): Added a new class which functions like Itpl,
4337 but allows configuring the namespace for the evaluation to occur
4344 but allows configuring the namespace for the evaluation to occur
4338 in.
4345 in.
4339
4346
4340 2004-06-18 Fernando Perez <fperez@colorado.edu>
4347 2004-06-18 Fernando Perez <fperez@colorado.edu>
4341
4348
4342 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
4349 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
4343 better message when 'exit' or 'quit' are typed (a common newbie
4350 better message when 'exit' or 'quit' are typed (a common newbie
4344 confusion).
4351 confusion).
4345
4352
4346 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
4353 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
4347 check for Windows users.
4354 check for Windows users.
4348
4355
4349 * IPython/iplib.py (InteractiveShell.user_setup): removed
4356 * IPython/iplib.py (InteractiveShell.user_setup): removed
4350 disabling of colors for Windows. I'll test at runtime and issue a
4357 disabling of colors for Windows. I'll test at runtime and issue a
4351 warning if Gary's readline isn't found, as to nudge users to
4358 warning if Gary's readline isn't found, as to nudge users to
4352 download it.
4359 download it.
4353
4360
4354 2004-06-16 Fernando Perez <fperez@colorado.edu>
4361 2004-06-16 Fernando Perez <fperez@colorado.edu>
4355
4362
4356 * IPython/genutils.py (Stream.__init__): changed to print errors
4363 * IPython/genutils.py (Stream.__init__): changed to print errors
4357 to sys.stderr. I had a circular dependency here. Now it's
4364 to sys.stderr. I had a circular dependency here. Now it's
4358 possible to run ipython as IDLE's shell (consider this pre-alpha,
4365 possible to run ipython as IDLE's shell (consider this pre-alpha,
4359 since true stdout things end up in the starting terminal instead
4366 since true stdout things end up in the starting terminal instead
4360 of IDLE's out).
4367 of IDLE's out).
4361
4368
4362 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
4369 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
4363 users who haven't # updated their prompt_in2 definitions. Remove
4370 users who haven't # updated their prompt_in2 definitions. Remove
4364 eventually.
4371 eventually.
4365 (multiple_replace): added credit to original ASPN recipe.
4372 (multiple_replace): added credit to original ASPN recipe.
4366
4373
4367 2004-06-15 Fernando Perez <fperez@colorado.edu>
4374 2004-06-15 Fernando Perez <fperez@colorado.edu>
4368
4375
4369 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
4376 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
4370 list of auto-defined aliases.
4377 list of auto-defined aliases.
4371
4378
4372 2004-06-13 Fernando Perez <fperez@colorado.edu>
4379 2004-06-13 Fernando Perez <fperez@colorado.edu>
4373
4380
4374 * setup.py (scriptfiles): Don't trigger win_post_install unless an
4381 * setup.py (scriptfiles): Don't trigger win_post_install unless an
4375 install was really requested (so setup.py can be used for other
4382 install was really requested (so setup.py can be used for other
4376 things under Windows).
4383 things under Windows).
4377
4384
4378 2004-06-10 Fernando Perez <fperez@colorado.edu>
4385 2004-06-10 Fernando Perez <fperez@colorado.edu>
4379
4386
4380 * IPython/Logger.py (Logger.create_log): Manually remove any old
4387 * IPython/Logger.py (Logger.create_log): Manually remove any old
4381 backup, since os.remove may fail under Windows. Fixes bug
4388 backup, since os.remove may fail under Windows. Fixes bug
4382 reported by Thorsten.
4389 reported by Thorsten.
4383
4390
4384 2004-06-09 Fernando Perez <fperez@colorado.edu>
4391 2004-06-09 Fernando Perez <fperez@colorado.edu>
4385
4392
4386 * examples/example-embed.py: fixed all references to %n (replaced
4393 * examples/example-embed.py: fixed all references to %n (replaced
4387 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
4394 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
4388 for all examples and the manual as well.
4395 for all examples and the manual as well.
4389
4396
4390 2004-06-08 Fernando Perez <fperez@colorado.edu>
4397 2004-06-08 Fernando Perez <fperez@colorado.edu>
4391
4398
4392 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
4399 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
4393 alignment and color management. All 3 prompt subsystems now
4400 alignment and color management. All 3 prompt subsystems now
4394 inherit from BasePrompt.
4401 inherit from BasePrompt.
4395
4402
4396 * tools/release: updates for windows installer build and tag rpms
4403 * tools/release: updates for windows installer build and tag rpms
4397 with python version (since paths are fixed).
4404 with python version (since paths are fixed).
4398
4405
4399 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
4406 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
4400 which will become eventually obsolete. Also fixed the default
4407 which will become eventually obsolete. Also fixed the default
4401 prompt_in2 to use \D, so at least new users start with the correct
4408 prompt_in2 to use \D, so at least new users start with the correct
4402 defaults.
4409 defaults.
4403 WARNING: Users with existing ipythonrc files will need to apply
4410 WARNING: Users with existing ipythonrc files will need to apply
4404 this fix manually!
4411 this fix manually!
4405
4412
4406 * setup.py: make windows installer (.exe). This is finally the
4413 * setup.py: make windows installer (.exe). This is finally the
4407 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
4414 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
4408 which I hadn't included because it required Python 2.3 (or recent
4415 which I hadn't included because it required Python 2.3 (or recent
4409 distutils).
4416 distutils).
4410
4417
4411 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
4418 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
4412 usage of new '\D' escape.
4419 usage of new '\D' escape.
4413
4420
4414 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
4421 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
4415 lacks os.getuid())
4422 lacks os.getuid())
4416 (CachedOutput.set_colors): Added the ability to turn coloring
4423 (CachedOutput.set_colors): Added the ability to turn coloring
4417 on/off with @colors even for manually defined prompt colors. It
4424 on/off with @colors even for manually defined prompt colors. It
4418 uses a nasty global, but it works safely and via the generic color
4425 uses a nasty global, but it works safely and via the generic color
4419 handling mechanism.
4426 handling mechanism.
4420 (Prompt2.__init__): Introduced new escape '\D' for continuation
4427 (Prompt2.__init__): Introduced new escape '\D' for continuation
4421 prompts. It represents the counter ('\#') as dots.
4428 prompts. It represents the counter ('\#') as dots.
4422 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
4429 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
4423 need to update their ipythonrc files and replace '%n' with '\D' in
4430 need to update their ipythonrc files and replace '%n' with '\D' in
4424 their prompt_in2 settings everywhere. Sorry, but there's
4431 their prompt_in2 settings everywhere. Sorry, but there's
4425 otherwise no clean way to get all prompts to properly align. The
4432 otherwise no clean way to get all prompts to properly align. The
4426 ipythonrc shipped with IPython has been updated.
4433 ipythonrc shipped with IPython has been updated.
4427
4434
4428 2004-06-07 Fernando Perez <fperez@colorado.edu>
4435 2004-06-07 Fernando Perez <fperez@colorado.edu>
4429
4436
4430 * setup.py (isfile): Pass local_icons option to latex2html, so the
4437 * setup.py (isfile): Pass local_icons option to latex2html, so the
4431 resulting HTML file is self-contained. Thanks to
4438 resulting HTML file is self-contained. Thanks to
4432 dryice-AT-liu.com.cn for the tip.
4439 dryice-AT-liu.com.cn for the tip.
4433
4440
4434 * pysh.py: I created a new profile 'shell', which implements a
4441 * pysh.py: I created a new profile 'shell', which implements a
4435 _rudimentary_ IPython-based shell. This is in NO WAY a realy
4442 _rudimentary_ IPython-based shell. This is in NO WAY a realy
4436 system shell, nor will it become one anytime soon. It's mainly
4443 system shell, nor will it become one anytime soon. It's mainly
4437 meant to illustrate the use of the new flexible bash-like prompts.
4444 meant to illustrate the use of the new flexible bash-like prompts.
4438 I guess it could be used by hardy souls for true shell management,
4445 I guess it could be used by hardy souls for true shell management,
4439 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
4446 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
4440 profile. This uses the InterpreterExec extension provided by
4447 profile. This uses the InterpreterExec extension provided by
4441 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
4448 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
4442
4449
4443 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
4450 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
4444 auto-align itself with the length of the previous input prompt
4451 auto-align itself with the length of the previous input prompt
4445 (taking into account the invisible color escapes).
4452 (taking into account the invisible color escapes).
4446 (CachedOutput.__init__): Large restructuring of this class. Now
4453 (CachedOutput.__init__): Large restructuring of this class. Now
4447 all three prompts (primary1, primary2, output) are proper objects,
4454 all three prompts (primary1, primary2, output) are proper objects,
4448 managed by the 'parent' CachedOutput class. The code is still a
4455 managed by the 'parent' CachedOutput class. The code is still a
4449 bit hackish (all prompts share state via a pointer to the cache),
4456 bit hackish (all prompts share state via a pointer to the cache),
4450 but it's overall far cleaner than before.
4457 but it's overall far cleaner than before.
4451
4458
4452 * IPython/genutils.py (getoutputerror): modified to add verbose,
4459 * IPython/genutils.py (getoutputerror): modified to add verbose,
4453 debug and header options. This makes the interface of all getout*
4460 debug and header options. This makes the interface of all getout*
4454 functions uniform.
4461 functions uniform.
4455 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
4462 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
4456
4463
4457 * IPython/Magic.py (Magic.default_option): added a function to
4464 * IPython/Magic.py (Magic.default_option): added a function to
4458 allow registering default options for any magic command. This
4465 allow registering default options for any magic command. This
4459 makes it easy to have profiles which customize the magics globally
4466 makes it easy to have profiles which customize the magics globally
4460 for a certain use. The values set through this function are
4467 for a certain use. The values set through this function are
4461 picked up by the parse_options() method, which all magics should
4468 picked up by the parse_options() method, which all magics should
4462 use to parse their options.
4469 use to parse their options.
4463
4470
4464 * IPython/genutils.py (warn): modified the warnings framework to
4471 * IPython/genutils.py (warn): modified the warnings framework to
4465 use the Term I/O class. I'm trying to slowly unify all of
4472 use the Term I/O class. I'm trying to slowly unify all of
4466 IPython's I/O operations to pass through Term.
4473 IPython's I/O operations to pass through Term.
4467
4474
4468 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
4475 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
4469 the secondary prompt to correctly match the length of the primary
4476 the secondary prompt to correctly match the length of the primary
4470 one for any prompt. Now multi-line code will properly line up
4477 one for any prompt. Now multi-line code will properly line up
4471 even for path dependent prompts, such as the new ones available
4478 even for path dependent prompts, such as the new ones available
4472 via the prompt_specials.
4479 via the prompt_specials.
4473
4480
4474 2004-06-06 Fernando Perez <fperez@colorado.edu>
4481 2004-06-06 Fernando Perez <fperez@colorado.edu>
4475
4482
4476 * IPython/Prompts.py (prompt_specials): Added the ability to have
4483 * IPython/Prompts.py (prompt_specials): Added the ability to have
4477 bash-like special sequences in the prompts, which get
4484 bash-like special sequences in the prompts, which get
4478 automatically expanded. Things like hostname, current working
4485 automatically expanded. Things like hostname, current working
4479 directory and username are implemented already, but it's easy to
4486 directory and username are implemented already, but it's easy to
4480 add more in the future. Thanks to a patch by W.J. van der Laan
4487 add more in the future. Thanks to a patch by W.J. van der Laan
4481 <gnufnork-AT-hetdigitalegat.nl>
4488 <gnufnork-AT-hetdigitalegat.nl>
4482 (prompt_specials): Added color support for prompt strings, so
4489 (prompt_specials): Added color support for prompt strings, so
4483 users can define arbitrary color setups for their prompts.
4490 users can define arbitrary color setups for their prompts.
4484
4491
4485 2004-06-05 Fernando Perez <fperez@colorado.edu>
4492 2004-06-05 Fernando Perez <fperez@colorado.edu>
4486
4493
4487 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
4494 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
4488 code to load Gary Bishop's readline and configure it
4495 code to load Gary Bishop's readline and configure it
4489 automatically. Thanks to Gary for help on this.
4496 automatically. Thanks to Gary for help on this.
4490
4497
4491 2004-06-01 Fernando Perez <fperez@colorado.edu>
4498 2004-06-01 Fernando Perez <fperez@colorado.edu>
4492
4499
4493 * IPython/Logger.py (Logger.create_log): fix bug for logging
4500 * IPython/Logger.py (Logger.create_log): fix bug for logging
4494 with no filename (previous fix was incomplete).
4501 with no filename (previous fix was incomplete).
4495
4502
4496 2004-05-25 Fernando Perez <fperez@colorado.edu>
4503 2004-05-25 Fernando Perez <fperez@colorado.edu>
4497
4504
4498 * IPython/Magic.py (Magic.parse_options): fix bug where naked
4505 * IPython/Magic.py (Magic.parse_options): fix bug where naked
4499 parens would get passed to the shell.
4506 parens would get passed to the shell.
4500
4507
4501 2004-05-20 Fernando Perez <fperez@colorado.edu>
4508 2004-05-20 Fernando Perez <fperez@colorado.edu>
4502
4509
4503 * IPython/Magic.py (Magic.magic_prun): changed default profile
4510 * IPython/Magic.py (Magic.magic_prun): changed default profile
4504 sort order to 'time' (the more common profiling need).
4511 sort order to 'time' (the more common profiling need).
4505
4512
4506 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
4513 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
4507 so that source code shown is guaranteed in sync with the file on
4514 so that source code shown is guaranteed in sync with the file on
4508 disk (also changed in psource). Similar fix to the one for
4515 disk (also changed in psource). Similar fix to the one for
4509 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
4516 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
4510 <yann.ledu-AT-noos.fr>.
4517 <yann.ledu-AT-noos.fr>.
4511
4518
4512 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
4519 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
4513 with a single option would not be correctly parsed. Closes
4520 with a single option would not be correctly parsed. Closes
4514 http://www.scipy.net/roundup/ipython/issue14. This bug had been
4521 http://www.scipy.net/roundup/ipython/issue14. This bug had been
4515 introduced in 0.6.0 (on 2004-05-06).
4522 introduced in 0.6.0 (on 2004-05-06).
4516
4523
4517 2004-05-13 *** Released version 0.6.0
4524 2004-05-13 *** Released version 0.6.0
4518
4525
4519 2004-05-13 Fernando Perez <fperez@colorado.edu>
4526 2004-05-13 Fernando Perez <fperez@colorado.edu>
4520
4527
4521 * debian/: Added debian/ directory to CVS, so that debian support
4528 * debian/: Added debian/ directory to CVS, so that debian support
4522 is publicly accessible. The debian package is maintained by Jack
4529 is publicly accessible. The debian package is maintained by Jack
4523 Moffit <jack-AT-xiph.org>.
4530 Moffit <jack-AT-xiph.org>.
4524
4531
4525 * Documentation: included the notes about an ipython-based system
4532 * Documentation: included the notes about an ipython-based system
4526 shell (the hypothetical 'pysh') into the new_design.pdf document,
4533 shell (the hypothetical 'pysh') into the new_design.pdf document,
4527 so that these ideas get distributed to users along with the
4534 so that these ideas get distributed to users along with the
4528 official documentation.
4535 official documentation.
4529
4536
4530 2004-05-10 Fernando Perez <fperez@colorado.edu>
4537 2004-05-10 Fernando Perez <fperez@colorado.edu>
4531
4538
4532 * IPython/Logger.py (Logger.create_log): fix recently introduced
4539 * IPython/Logger.py (Logger.create_log): fix recently introduced
4533 bug (misindented line) where logstart would fail when not given an
4540 bug (misindented line) where logstart would fail when not given an
4534 explicit filename.
4541 explicit filename.
4535
4542
4536 2004-05-09 Fernando Perez <fperez@colorado.edu>
4543 2004-05-09 Fernando Perez <fperez@colorado.edu>
4537
4544
4538 * IPython/Magic.py (Magic.parse_options): skip system call when
4545 * IPython/Magic.py (Magic.parse_options): skip system call when
4539 there are no options to look for. Faster, cleaner for the common
4546 there are no options to look for. Faster, cleaner for the common
4540 case.
4547 case.
4541
4548
4542 * Documentation: many updates to the manual: describing Windows
4549 * Documentation: many updates to the manual: describing Windows
4543 support better, Gnuplot updates, credits, misc small stuff. Also
4550 support better, Gnuplot updates, credits, misc small stuff. Also
4544 updated the new_design doc a bit.
4551 updated the new_design doc a bit.
4545
4552
4546 2004-05-06 *** Released version 0.6.0.rc1
4553 2004-05-06 *** Released version 0.6.0.rc1
4547
4554
4548 2004-05-06 Fernando Perez <fperez@colorado.edu>
4555 2004-05-06 Fernando Perez <fperez@colorado.edu>
4549
4556
4550 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
4557 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
4551 operations to use the vastly more efficient list/''.join() method.
4558 operations to use the vastly more efficient list/''.join() method.
4552 (FormattedTB.text): Fix
4559 (FormattedTB.text): Fix
4553 http://www.scipy.net/roundup/ipython/issue12 - exception source
4560 http://www.scipy.net/roundup/ipython/issue12 - exception source
4554 extract not updated after reload. Thanks to Mike Salib
4561 extract not updated after reload. Thanks to Mike Salib
4555 <msalib-AT-mit.edu> for pinning the source of the problem.
4562 <msalib-AT-mit.edu> for pinning the source of the problem.
4556 Fortunately, the solution works inside ipython and doesn't require
4563 Fortunately, the solution works inside ipython and doesn't require
4557 any changes to python proper.
4564 any changes to python proper.
4558
4565
4559 * IPython/Magic.py (Magic.parse_options): Improved to process the
4566 * IPython/Magic.py (Magic.parse_options): Improved to process the
4560 argument list as a true shell would (by actually using the
4567 argument list as a true shell would (by actually using the
4561 underlying system shell). This way, all @magics automatically get
4568 underlying system shell). This way, all @magics automatically get
4562 shell expansion for variables. Thanks to a comment by Alex
4569 shell expansion for variables. Thanks to a comment by Alex
4563 Schmolck.
4570 Schmolck.
4564
4571
4565 2004-04-04 Fernando Perez <fperez@colorado.edu>
4572 2004-04-04 Fernando Perez <fperez@colorado.edu>
4566
4573
4567 * IPython/iplib.py (InteractiveShell.interact): Added a special
4574 * IPython/iplib.py (InteractiveShell.interact): Added a special
4568 trap for a debugger quit exception, which is basically impossible
4575 trap for a debugger quit exception, which is basically impossible
4569 to handle by normal mechanisms, given what pdb does to the stack.
4576 to handle by normal mechanisms, given what pdb does to the stack.
4570 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
4577 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
4571
4578
4572 2004-04-03 Fernando Perez <fperez@colorado.edu>
4579 2004-04-03 Fernando Perez <fperez@colorado.edu>
4573
4580
4574 * IPython/genutils.py (Term): Standardized the names of the Term
4581 * IPython/genutils.py (Term): Standardized the names of the Term
4575 class streams to cin/cout/cerr, following C++ naming conventions
4582 class streams to cin/cout/cerr, following C++ naming conventions
4576 (I can't use in/out/err because 'in' is not a valid attribute
4583 (I can't use in/out/err because 'in' is not a valid attribute
4577 name).
4584 name).
4578
4585
4579 * IPython/iplib.py (InteractiveShell.interact): don't increment
4586 * IPython/iplib.py (InteractiveShell.interact): don't increment
4580 the prompt if there's no user input. By Daniel 'Dang' Griffith
4587 the prompt if there's no user input. By Daniel 'Dang' Griffith
4581 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
4588 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
4582 Francois Pinard.
4589 Francois Pinard.
4583
4590
4584 2004-04-02 Fernando Perez <fperez@colorado.edu>
4591 2004-04-02 Fernando Perez <fperez@colorado.edu>
4585
4592
4586 * IPython/genutils.py (Stream.__init__): Modified to survive at
4593 * IPython/genutils.py (Stream.__init__): Modified to survive at
4587 least importing in contexts where stdin/out/err aren't true file
4594 least importing in contexts where stdin/out/err aren't true file
4588 objects, such as PyCrust (they lack fileno() and mode). However,
4595 objects, such as PyCrust (they lack fileno() and mode). However,
4589 the recovery facilities which rely on these things existing will
4596 the recovery facilities which rely on these things existing will
4590 not work.
4597 not work.
4591
4598
4592 2004-04-01 Fernando Perez <fperez@colorado.edu>
4599 2004-04-01 Fernando Perez <fperez@colorado.edu>
4593
4600
4594 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
4601 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
4595 use the new getoutputerror() function, so it properly
4602 use the new getoutputerror() function, so it properly
4596 distinguishes stdout/err.
4603 distinguishes stdout/err.
4597
4604
4598 * IPython/genutils.py (getoutputerror): added a function to
4605 * IPython/genutils.py (getoutputerror): added a function to
4599 capture separately the standard output and error of a command.
4606 capture separately the standard output and error of a command.
4600 After a comment from dang on the mailing lists. This code is
4607 After a comment from dang on the mailing lists. This code is
4601 basically a modified version of commands.getstatusoutput(), from
4608 basically a modified version of commands.getstatusoutput(), from
4602 the standard library.
4609 the standard library.
4603
4610
4604 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
4611 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
4605 '!!' as a special syntax (shorthand) to access @sx.
4612 '!!' as a special syntax (shorthand) to access @sx.
4606
4613
4607 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
4614 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
4608 command and return its output as a list split on '\n'.
4615 command and return its output as a list split on '\n'.
4609
4616
4610 2004-03-31 Fernando Perez <fperez@colorado.edu>
4617 2004-03-31 Fernando Perez <fperez@colorado.edu>
4611
4618
4612 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
4619 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
4613 method to dictionaries used as FakeModule instances if they lack
4620 method to dictionaries used as FakeModule instances if they lack
4614 it. At least pydoc in python2.3 breaks for runtime-defined
4621 it. At least pydoc in python2.3 breaks for runtime-defined
4615 functions without this hack. At some point I need to _really_
4622 functions without this hack. At some point I need to _really_
4616 understand what FakeModule is doing, because it's a gross hack.
4623 understand what FakeModule is doing, because it's a gross hack.
4617 But it solves Arnd's problem for now...
4624 But it solves Arnd's problem for now...
4618
4625
4619 2004-02-27 Fernando Perez <fperez@colorado.edu>
4626 2004-02-27 Fernando Perez <fperez@colorado.edu>
4620
4627
4621 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
4628 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
4622 mode would behave erratically. Also increased the number of
4629 mode would behave erratically. Also increased the number of
4623 possible logs in rotate mod to 999. Thanks to Rod Holland
4630 possible logs in rotate mod to 999. Thanks to Rod Holland
4624 <rhh@StructureLABS.com> for the report and fixes.
4631 <rhh@StructureLABS.com> for the report and fixes.
4625
4632
4626 2004-02-26 Fernando Perez <fperez@colorado.edu>
4633 2004-02-26 Fernando Perez <fperez@colorado.edu>
4627
4634
4628 * IPython/genutils.py (page): Check that the curses module really
4635 * IPython/genutils.py (page): Check that the curses module really
4629 has the initscr attribute before trying to use it. For some
4636 has the initscr attribute before trying to use it. For some
4630 reason, the Solaris curses module is missing this. I think this
4637 reason, the Solaris curses module is missing this. I think this
4631 should be considered a Solaris python bug, but I'm not sure.
4638 should be considered a Solaris python bug, but I'm not sure.
4632
4639
4633 2004-01-17 Fernando Perez <fperez@colorado.edu>
4640 2004-01-17 Fernando Perez <fperez@colorado.edu>
4634
4641
4635 * IPython/genutils.py (Stream.__init__): Changes to try to make
4642 * IPython/genutils.py (Stream.__init__): Changes to try to make
4636 ipython robust against stdin/out/err being closed by the user.
4643 ipython robust against stdin/out/err being closed by the user.
4637 This is 'user error' (and blocks a normal python session, at least
4644 This is 'user error' (and blocks a normal python session, at least
4638 the stdout case). However, Ipython should be able to survive such
4645 the stdout case). However, Ipython should be able to survive such
4639 instances of abuse as gracefully as possible. To simplify the
4646 instances of abuse as gracefully as possible. To simplify the
4640 coding and maintain compatibility with Gary Bishop's Term
4647 coding and maintain compatibility with Gary Bishop's Term
4641 contributions, I've made use of classmethods for this. I think
4648 contributions, I've made use of classmethods for this. I think
4642 this introduces a dependency on python 2.2.
4649 this introduces a dependency on python 2.2.
4643
4650
4644 2004-01-13 Fernando Perez <fperez@colorado.edu>
4651 2004-01-13 Fernando Perez <fperez@colorado.edu>
4645
4652
4646 * IPython/numutils.py (exp_safe): simplified the code a bit and
4653 * IPython/numutils.py (exp_safe): simplified the code a bit and
4647 removed the need for importing the kinds module altogether.
4654 removed the need for importing the kinds module altogether.
4648
4655
4649 2004-01-06 Fernando Perez <fperez@colorado.edu>
4656 2004-01-06 Fernando Perez <fperez@colorado.edu>
4650
4657
4651 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
4658 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
4652 a magic function instead, after some community feedback. No
4659 a magic function instead, after some community feedback. No
4653 special syntax will exist for it, but its name is deliberately
4660 special syntax will exist for it, but its name is deliberately
4654 very short.
4661 very short.
4655
4662
4656 2003-12-20 Fernando Perez <fperez@colorado.edu>
4663 2003-12-20 Fernando Perez <fperez@colorado.edu>
4657
4664
4658 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
4665 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
4659 new functionality, to automagically assign the result of a shell
4666 new functionality, to automagically assign the result of a shell
4660 command to a variable. I'll solicit some community feedback on
4667 command to a variable. I'll solicit some community feedback on
4661 this before making it permanent.
4668 this before making it permanent.
4662
4669
4663 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
4670 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
4664 requested about callables for which inspect couldn't obtain a
4671 requested about callables for which inspect couldn't obtain a
4665 proper argspec. Thanks to a crash report sent by Etienne
4672 proper argspec. Thanks to a crash report sent by Etienne
4666 Posthumus <etienne-AT-apple01.cs.vu.nl>.
4673 Posthumus <etienne-AT-apple01.cs.vu.nl>.
4667
4674
4668 2003-12-09 Fernando Perez <fperez@colorado.edu>
4675 2003-12-09 Fernando Perez <fperez@colorado.edu>
4669
4676
4670 * IPython/genutils.py (page): patch for the pager to work across
4677 * IPython/genutils.py (page): patch for the pager to work across
4671 various versions of Windows. By Gary Bishop.
4678 various versions of Windows. By Gary Bishop.
4672
4679
4673 2003-12-04 Fernando Perez <fperez@colorado.edu>
4680 2003-12-04 Fernando Perez <fperez@colorado.edu>
4674
4681
4675 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
4682 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
4676 Gnuplot.py version 1.7, whose internal names changed quite a bit.
4683 Gnuplot.py version 1.7, whose internal names changed quite a bit.
4677 While I tested this and it looks ok, there may still be corner
4684 While I tested this and it looks ok, there may still be corner
4678 cases I've missed.
4685 cases I've missed.
4679
4686
4680 2003-12-01 Fernando Perez <fperez@colorado.edu>
4687 2003-12-01 Fernando Perez <fperez@colorado.edu>
4681
4688
4682 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
4689 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
4683 where a line like 'p,q=1,2' would fail because the automagic
4690 where a line like 'p,q=1,2' would fail because the automagic
4684 system would be triggered for @p.
4691 system would be triggered for @p.
4685
4692
4686 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
4693 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
4687 cleanups, code unmodified.
4694 cleanups, code unmodified.
4688
4695
4689 * IPython/genutils.py (Term): added a class for IPython to handle
4696 * IPython/genutils.py (Term): added a class for IPython to handle
4690 output. In most cases it will just be a proxy for stdout/err, but
4697 output. In most cases it will just be a proxy for stdout/err, but
4691 having this allows modifications to be made for some platforms,
4698 having this allows modifications to be made for some platforms,
4692 such as handling color escapes under Windows. All of this code
4699 such as handling color escapes under Windows. All of this code
4693 was contributed by Gary Bishop, with minor modifications by me.
4700 was contributed by Gary Bishop, with minor modifications by me.
4694 The actual changes affect many files.
4701 The actual changes affect many files.
4695
4702
4696 2003-11-30 Fernando Perez <fperez@colorado.edu>
4703 2003-11-30 Fernando Perez <fperez@colorado.edu>
4697
4704
4698 * IPython/iplib.py (file_matches): new completion code, courtesy
4705 * IPython/iplib.py (file_matches): new completion code, courtesy
4699 of Jeff Collins. This enables filename completion again under
4706 of Jeff Collins. This enables filename completion again under
4700 python 2.3, which disabled it at the C level.
4707 python 2.3, which disabled it at the C level.
4701
4708
4702 2003-11-11 Fernando Perez <fperez@colorado.edu>
4709 2003-11-11 Fernando Perez <fperez@colorado.edu>
4703
4710
4704 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
4711 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
4705 for Numeric.array(map(...)), but often convenient.
4712 for Numeric.array(map(...)), but often convenient.
4706
4713
4707 2003-11-05 Fernando Perez <fperez@colorado.edu>
4714 2003-11-05 Fernando Perez <fperez@colorado.edu>
4708
4715
4709 * IPython/numutils.py (frange): Changed a call from int() to
4716 * IPython/numutils.py (frange): Changed a call from int() to
4710 int(round()) to prevent a problem reported with arange() in the
4717 int(round()) to prevent a problem reported with arange() in the
4711 numpy list.
4718 numpy list.
4712
4719
4713 2003-10-06 Fernando Perez <fperez@colorado.edu>
4720 2003-10-06 Fernando Perez <fperez@colorado.edu>
4714
4721
4715 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4722 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4716 prevent crashes if sys lacks an argv attribute (it happens with
4723 prevent crashes if sys lacks an argv attribute (it happens with
4717 embedded interpreters which build a bare-bones sys module).
4724 embedded interpreters which build a bare-bones sys module).
4718 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4725 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4719
4726
4720 2003-09-24 Fernando Perez <fperez@colorado.edu>
4727 2003-09-24 Fernando Perez <fperez@colorado.edu>
4721
4728
4722 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4729 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4723 to protect against poorly written user objects where __getattr__
4730 to protect against poorly written user objects where __getattr__
4724 raises exceptions other than AttributeError. Thanks to a bug
4731 raises exceptions other than AttributeError. Thanks to a bug
4725 report by Oliver Sander <osander-AT-gmx.de>.
4732 report by Oliver Sander <osander-AT-gmx.de>.
4726
4733
4727 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4734 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4728 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4735 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4729
4736
4730 2003-09-09 Fernando Perez <fperez@colorado.edu>
4737 2003-09-09 Fernando Perez <fperez@colorado.edu>
4731
4738
4732 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4739 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4733 unpacking a list whith a callable as first element would
4740 unpacking a list whith a callable as first element would
4734 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4741 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4735 Collins.
4742 Collins.
4736
4743
4737 2003-08-25 *** Released version 0.5.0
4744 2003-08-25 *** Released version 0.5.0
4738
4745
4739 2003-08-22 Fernando Perez <fperez@colorado.edu>
4746 2003-08-22 Fernando Perez <fperez@colorado.edu>
4740
4747
4741 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4748 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4742 improperly defined user exceptions. Thanks to feedback from Mark
4749 improperly defined user exceptions. Thanks to feedback from Mark
4743 Russell <mrussell-AT-verio.net>.
4750 Russell <mrussell-AT-verio.net>.
4744
4751
4745 2003-08-20 Fernando Perez <fperez@colorado.edu>
4752 2003-08-20 Fernando Perez <fperez@colorado.edu>
4746
4753
4747 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4754 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4748 printing so that it would print multi-line string forms starting
4755 printing so that it would print multi-line string forms starting
4749 with a new line. This way the formatting is better respected for
4756 with a new line. This way the formatting is better respected for
4750 objects which work hard to make nice string forms.
4757 objects which work hard to make nice string forms.
4751
4758
4752 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4759 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4753 autocall would overtake data access for objects with both
4760 autocall would overtake data access for objects with both
4754 __getitem__ and __call__.
4761 __getitem__ and __call__.
4755
4762
4756 2003-08-19 *** Released version 0.5.0-rc1
4763 2003-08-19 *** Released version 0.5.0-rc1
4757
4764
4758 2003-08-19 Fernando Perez <fperez@colorado.edu>
4765 2003-08-19 Fernando Perez <fperez@colorado.edu>
4759
4766
4760 * IPython/deep_reload.py (load_tail): single tiny change here
4767 * IPython/deep_reload.py (load_tail): single tiny change here
4761 seems to fix the long-standing bug of dreload() failing to work
4768 seems to fix the long-standing bug of dreload() failing to work
4762 for dotted names. But this module is pretty tricky, so I may have
4769 for dotted names. But this module is pretty tricky, so I may have
4763 missed some subtlety. Needs more testing!.
4770 missed some subtlety. Needs more testing!.
4764
4771
4765 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4772 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4766 exceptions which have badly implemented __str__ methods.
4773 exceptions which have badly implemented __str__ methods.
4767 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4774 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4768 which I've been getting reports about from Python 2.3 users. I
4775 which I've been getting reports about from Python 2.3 users. I
4769 wish I had a simple test case to reproduce the problem, so I could
4776 wish I had a simple test case to reproduce the problem, so I could
4770 either write a cleaner workaround or file a bug report if
4777 either write a cleaner workaround or file a bug report if
4771 necessary.
4778 necessary.
4772
4779
4773 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4780 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4774 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4781 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4775 a bug report by Tjabo Kloppenburg.
4782 a bug report by Tjabo Kloppenburg.
4776
4783
4777 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4784 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4778 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4785 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4779 seems rather unstable. Thanks to a bug report by Tjabo
4786 seems rather unstable. Thanks to a bug report by Tjabo
4780 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4787 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4781
4788
4782 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4789 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4783 this out soon because of the critical fixes in the inner loop for
4790 this out soon because of the critical fixes in the inner loop for
4784 generators.
4791 generators.
4785
4792
4786 * IPython/Magic.py (Magic.getargspec): removed. This (and
4793 * IPython/Magic.py (Magic.getargspec): removed. This (and
4787 _get_def) have been obsoleted by OInspect for a long time, I
4794 _get_def) have been obsoleted by OInspect for a long time, I
4788 hadn't noticed that they were dead code.
4795 hadn't noticed that they were dead code.
4789 (Magic._ofind): restored _ofind functionality for a few literals
4796 (Magic._ofind): restored _ofind functionality for a few literals
4790 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4797 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4791 for things like "hello".capitalize?, since that would require a
4798 for things like "hello".capitalize?, since that would require a
4792 potentially dangerous eval() again.
4799 potentially dangerous eval() again.
4793
4800
4794 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4801 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4795 logic a bit more to clean up the escapes handling and minimize the
4802 logic a bit more to clean up the escapes handling and minimize the
4796 use of _ofind to only necessary cases. The interactive 'feel' of
4803 use of _ofind to only necessary cases. The interactive 'feel' of
4797 IPython should have improved quite a bit with the changes in
4804 IPython should have improved quite a bit with the changes in
4798 _prefilter and _ofind (besides being far safer than before).
4805 _prefilter and _ofind (besides being far safer than before).
4799
4806
4800 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4807 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4801 obscure, never reported). Edit would fail to find the object to
4808 obscure, never reported). Edit would fail to find the object to
4802 edit under some circumstances.
4809 edit under some circumstances.
4803 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4810 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4804 which were causing double-calling of generators. Those eval calls
4811 which were causing double-calling of generators. Those eval calls
4805 were _very_ dangerous, since code with side effects could be
4812 were _very_ dangerous, since code with side effects could be
4806 triggered. As they say, 'eval is evil'... These were the
4813 triggered. As they say, 'eval is evil'... These were the
4807 nastiest evals in IPython. Besides, _ofind is now far simpler,
4814 nastiest evals in IPython. Besides, _ofind is now far simpler,
4808 and it should also be quite a bit faster. Its use of inspect is
4815 and it should also be quite a bit faster. Its use of inspect is
4809 also safer, so perhaps some of the inspect-related crashes I've
4816 also safer, so perhaps some of the inspect-related crashes I've
4810 seen lately with Python 2.3 might be taken care of. That will
4817 seen lately with Python 2.3 might be taken care of. That will
4811 need more testing.
4818 need more testing.
4812
4819
4813 2003-08-17 Fernando Perez <fperez@colorado.edu>
4820 2003-08-17 Fernando Perez <fperez@colorado.edu>
4814
4821
4815 * IPython/iplib.py (InteractiveShell._prefilter): significant
4822 * IPython/iplib.py (InteractiveShell._prefilter): significant
4816 simplifications to the logic for handling user escapes. Faster
4823 simplifications to the logic for handling user escapes. Faster
4817 and simpler code.
4824 and simpler code.
4818
4825
4819 2003-08-14 Fernando Perez <fperez@colorado.edu>
4826 2003-08-14 Fernando Perez <fperez@colorado.edu>
4820
4827
4821 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4828 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4822 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4829 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4823 but it should be quite a bit faster. And the recursive version
4830 but it should be quite a bit faster. And the recursive version
4824 generated O(log N) intermediate storage for all rank>1 arrays,
4831 generated O(log N) intermediate storage for all rank>1 arrays,
4825 even if they were contiguous.
4832 even if they were contiguous.
4826 (l1norm): Added this function.
4833 (l1norm): Added this function.
4827 (norm): Added this function for arbitrary norms (including
4834 (norm): Added this function for arbitrary norms (including
4828 l-infinity). l1 and l2 are still special cases for convenience
4835 l-infinity). l1 and l2 are still special cases for convenience
4829 and speed.
4836 and speed.
4830
4837
4831 2003-08-03 Fernando Perez <fperez@colorado.edu>
4838 2003-08-03 Fernando Perez <fperez@colorado.edu>
4832
4839
4833 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4840 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4834 exceptions, which now raise PendingDeprecationWarnings in Python
4841 exceptions, which now raise PendingDeprecationWarnings in Python
4835 2.3. There were some in Magic and some in Gnuplot2.
4842 2.3. There were some in Magic and some in Gnuplot2.
4836
4843
4837 2003-06-30 Fernando Perez <fperez@colorado.edu>
4844 2003-06-30 Fernando Perez <fperez@colorado.edu>
4838
4845
4839 * IPython/genutils.py (page): modified to call curses only for
4846 * IPython/genutils.py (page): modified to call curses only for
4840 terminals where TERM=='xterm'. After problems under many other
4847 terminals where TERM=='xterm'. After problems under many other
4841 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4848 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4842
4849
4843 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4850 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4844 would be triggered when readline was absent. This was just an old
4851 would be triggered when readline was absent. This was just an old
4845 debugging statement I'd forgotten to take out.
4852 debugging statement I'd forgotten to take out.
4846
4853
4847 2003-06-20 Fernando Perez <fperez@colorado.edu>
4854 2003-06-20 Fernando Perez <fperez@colorado.edu>
4848
4855
4849 * IPython/genutils.py (clock): modified to return only user time
4856 * IPython/genutils.py (clock): modified to return only user time
4850 (not counting system time), after a discussion on scipy. While
4857 (not counting system time), after a discussion on scipy. While
4851 system time may be a useful quantity occasionally, it may much
4858 system time may be a useful quantity occasionally, it may much
4852 more easily be skewed by occasional swapping or other similar
4859 more easily be skewed by occasional swapping or other similar
4853 activity.
4860 activity.
4854
4861
4855 2003-06-05 Fernando Perez <fperez@colorado.edu>
4862 2003-06-05 Fernando Perez <fperez@colorado.edu>
4856
4863
4857 * IPython/numutils.py (identity): new function, for building
4864 * IPython/numutils.py (identity): new function, for building
4858 arbitrary rank Kronecker deltas (mostly backwards compatible with
4865 arbitrary rank Kronecker deltas (mostly backwards compatible with
4859 Numeric.identity)
4866 Numeric.identity)
4860
4867
4861 2003-06-03 Fernando Perez <fperez@colorado.edu>
4868 2003-06-03 Fernando Perez <fperez@colorado.edu>
4862
4869
4863 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4870 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4864 arguments passed to magics with spaces, to allow trailing '\' to
4871 arguments passed to magics with spaces, to allow trailing '\' to
4865 work normally (mainly for Windows users).
4872 work normally (mainly for Windows users).
4866
4873
4867 2003-05-29 Fernando Perez <fperez@colorado.edu>
4874 2003-05-29 Fernando Perez <fperez@colorado.edu>
4868
4875
4869 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4876 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4870 instead of pydoc.help. This fixes a bizarre behavior where
4877 instead of pydoc.help. This fixes a bizarre behavior where
4871 printing '%s' % locals() would trigger the help system. Now
4878 printing '%s' % locals() would trigger the help system. Now
4872 ipython behaves like normal python does.
4879 ipython behaves like normal python does.
4873
4880
4874 Note that if one does 'from pydoc import help', the bizarre
4881 Note that if one does 'from pydoc import help', the bizarre
4875 behavior returns, but this will also happen in normal python, so
4882 behavior returns, but this will also happen in normal python, so
4876 it's not an ipython bug anymore (it has to do with how pydoc.help
4883 it's not an ipython bug anymore (it has to do with how pydoc.help
4877 is implemented).
4884 is implemented).
4878
4885
4879 2003-05-22 Fernando Perez <fperez@colorado.edu>
4886 2003-05-22 Fernando Perez <fperez@colorado.edu>
4880
4887
4881 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4888 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4882 return [] instead of None when nothing matches, also match to end
4889 return [] instead of None when nothing matches, also match to end
4883 of line. Patch by Gary Bishop.
4890 of line. Patch by Gary Bishop.
4884
4891
4885 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4892 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4886 protection as before, for files passed on the command line. This
4893 protection as before, for files passed on the command line. This
4887 prevents the CrashHandler from kicking in if user files call into
4894 prevents the CrashHandler from kicking in if user files call into
4888 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4895 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4889 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4896 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4890
4897
4891 2003-05-20 *** Released version 0.4.0
4898 2003-05-20 *** Released version 0.4.0
4892
4899
4893 2003-05-20 Fernando Perez <fperez@colorado.edu>
4900 2003-05-20 Fernando Perez <fperez@colorado.edu>
4894
4901
4895 * setup.py: added support for manpages. It's a bit hackish b/c of
4902 * setup.py: added support for manpages. It's a bit hackish b/c of
4896 a bug in the way the bdist_rpm distutils target handles gzipped
4903 a bug in the way the bdist_rpm distutils target handles gzipped
4897 manpages, but it works. After a patch by Jack.
4904 manpages, but it works. After a patch by Jack.
4898
4905
4899 2003-05-19 Fernando Perez <fperez@colorado.edu>
4906 2003-05-19 Fernando Perez <fperez@colorado.edu>
4900
4907
4901 * IPython/numutils.py: added a mockup of the kinds module, since
4908 * IPython/numutils.py: added a mockup of the kinds module, since
4902 it was recently removed from Numeric. This way, numutils will
4909 it was recently removed from Numeric. This way, numutils will
4903 work for all users even if they are missing kinds.
4910 work for all users even if they are missing kinds.
4904
4911
4905 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4912 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4906 failure, which can occur with SWIG-wrapped extensions. After a
4913 failure, which can occur with SWIG-wrapped extensions. After a
4907 crash report from Prabhu.
4914 crash report from Prabhu.
4908
4915
4909 2003-05-16 Fernando Perez <fperez@colorado.edu>
4916 2003-05-16 Fernando Perez <fperez@colorado.edu>
4910
4917
4911 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4918 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4912 protect ipython from user code which may call directly
4919 protect ipython from user code which may call directly
4913 sys.excepthook (this looks like an ipython crash to the user, even
4920 sys.excepthook (this looks like an ipython crash to the user, even
4914 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4921 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4915 This is especially important to help users of WxWindows, but may
4922 This is especially important to help users of WxWindows, but may
4916 also be useful in other cases.
4923 also be useful in other cases.
4917
4924
4918 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4925 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4919 an optional tb_offset to be specified, and to preserve exception
4926 an optional tb_offset to be specified, and to preserve exception
4920 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4927 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4921
4928
4922 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4929 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4923
4930
4924 2003-05-15 Fernando Perez <fperez@colorado.edu>
4931 2003-05-15 Fernando Perez <fperez@colorado.edu>
4925
4932
4926 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4933 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4927 installing for a new user under Windows.
4934 installing for a new user under Windows.
4928
4935
4929 2003-05-12 Fernando Perez <fperez@colorado.edu>
4936 2003-05-12 Fernando Perez <fperez@colorado.edu>
4930
4937
4931 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4938 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4932 handler for Emacs comint-based lines. Currently it doesn't do
4939 handler for Emacs comint-based lines. Currently it doesn't do
4933 much (but importantly, it doesn't update the history cache). In
4940 much (but importantly, it doesn't update the history cache). In
4934 the future it may be expanded if Alex needs more functionality
4941 the future it may be expanded if Alex needs more functionality
4935 there.
4942 there.
4936
4943
4937 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4944 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4938 info to crash reports.
4945 info to crash reports.
4939
4946
4940 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4947 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4941 just like Python's -c. Also fixed crash with invalid -color
4948 just like Python's -c. Also fixed crash with invalid -color
4942 option value at startup. Thanks to Will French
4949 option value at startup. Thanks to Will French
4943 <wfrench-AT-bestweb.net> for the bug report.
4950 <wfrench-AT-bestweb.net> for the bug report.
4944
4951
4945 2003-05-09 Fernando Perez <fperez@colorado.edu>
4952 2003-05-09 Fernando Perez <fperez@colorado.edu>
4946
4953
4947 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4954 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4948 to EvalDict (it's a mapping, after all) and simplified its code
4955 to EvalDict (it's a mapping, after all) and simplified its code
4949 quite a bit, after a nice discussion on c.l.py where Gustavo
4956 quite a bit, after a nice discussion on c.l.py where Gustavo
4950 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4957 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4951
4958
4952 2003-04-30 Fernando Perez <fperez@colorado.edu>
4959 2003-04-30 Fernando Perez <fperez@colorado.edu>
4953
4960
4954 * IPython/genutils.py (timings_out): modified it to reduce its
4961 * IPython/genutils.py (timings_out): modified it to reduce its
4955 overhead in the common reps==1 case.
4962 overhead in the common reps==1 case.
4956
4963
4957 2003-04-29 Fernando Perez <fperez@colorado.edu>
4964 2003-04-29 Fernando Perez <fperez@colorado.edu>
4958
4965
4959 * IPython/genutils.py (timings_out): Modified to use the resource
4966 * IPython/genutils.py (timings_out): Modified to use the resource
4960 module, which avoids the wraparound problems of time.clock().
4967 module, which avoids the wraparound problems of time.clock().
4961
4968
4962 2003-04-17 *** Released version 0.2.15pre4
4969 2003-04-17 *** Released version 0.2.15pre4
4963
4970
4964 2003-04-17 Fernando Perez <fperez@colorado.edu>
4971 2003-04-17 Fernando Perez <fperez@colorado.edu>
4965
4972
4966 * setup.py (scriptfiles): Split windows-specific stuff over to a
4973 * setup.py (scriptfiles): Split windows-specific stuff over to a
4967 separate file, in an attempt to have a Windows GUI installer.
4974 separate file, in an attempt to have a Windows GUI installer.
4968 That didn't work, but part of the groundwork is done.
4975 That didn't work, but part of the groundwork is done.
4969
4976
4970 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4977 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4971 indent/unindent with 4 spaces. Particularly useful in combination
4978 indent/unindent with 4 spaces. Particularly useful in combination
4972 with the new auto-indent option.
4979 with the new auto-indent option.
4973
4980
4974 2003-04-16 Fernando Perez <fperez@colorado.edu>
4981 2003-04-16 Fernando Perez <fperez@colorado.edu>
4975
4982
4976 * IPython/Magic.py: various replacements of self.rc for
4983 * IPython/Magic.py: various replacements of self.rc for
4977 self.shell.rc. A lot more remains to be done to fully disentangle
4984 self.shell.rc. A lot more remains to be done to fully disentangle
4978 this class from the main Shell class.
4985 this class from the main Shell class.
4979
4986
4980 * IPython/GnuplotRuntime.py: added checks for mouse support so
4987 * IPython/GnuplotRuntime.py: added checks for mouse support so
4981 that we don't try to enable it if the current gnuplot doesn't
4988 that we don't try to enable it if the current gnuplot doesn't
4982 really support it. Also added checks so that we don't try to
4989 really support it. Also added checks so that we don't try to
4983 enable persist under Windows (where Gnuplot doesn't recognize the
4990 enable persist under Windows (where Gnuplot doesn't recognize the
4984 option).
4991 option).
4985
4992
4986 * IPython/iplib.py (InteractiveShell.interact): Added optional
4993 * IPython/iplib.py (InteractiveShell.interact): Added optional
4987 auto-indenting code, after a patch by King C. Shu
4994 auto-indenting code, after a patch by King C. Shu
4988 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4995 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4989 get along well with pasting indented code. If I ever figure out
4996 get along well with pasting indented code. If I ever figure out
4990 how to make that part go well, it will become on by default.
4997 how to make that part go well, it will become on by default.
4991
4998
4992 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4999 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4993 crash ipython if there was an unmatched '%' in the user's prompt
5000 crash ipython if there was an unmatched '%' in the user's prompt
4994 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5001 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4995
5002
4996 * IPython/iplib.py (InteractiveShell.interact): removed the
5003 * IPython/iplib.py (InteractiveShell.interact): removed the
4997 ability to ask the user whether he wants to crash or not at the
5004 ability to ask the user whether he wants to crash or not at the
4998 'last line' exception handler. Calling functions at that point
5005 'last line' exception handler. Calling functions at that point
4999 changes the stack, and the error reports would have incorrect
5006 changes the stack, and the error reports would have incorrect
5000 tracebacks.
5007 tracebacks.
5001
5008
5002 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
5009 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
5003 pass through a peger a pretty-printed form of any object. After a
5010 pass through a peger a pretty-printed form of any object. After a
5004 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
5011 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
5005
5012
5006 2003-04-14 Fernando Perez <fperez@colorado.edu>
5013 2003-04-14 Fernando Perez <fperez@colorado.edu>
5007
5014
5008 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
5015 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
5009 all files in ~ would be modified at first install (instead of
5016 all files in ~ would be modified at first install (instead of
5010 ~/.ipython). This could be potentially disastrous, as the
5017 ~/.ipython). This could be potentially disastrous, as the
5011 modification (make line-endings native) could damage binary files.
5018 modification (make line-endings native) could damage binary files.
5012
5019
5013 2003-04-10 Fernando Perez <fperez@colorado.edu>
5020 2003-04-10 Fernando Perez <fperez@colorado.edu>
5014
5021
5015 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
5022 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
5016 handle only lines which are invalid python. This now means that
5023 handle only lines which are invalid python. This now means that
5017 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
5024 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
5018 for the bug report.
5025 for the bug report.
5019
5026
5020 2003-04-01 Fernando Perez <fperez@colorado.edu>
5027 2003-04-01 Fernando Perez <fperez@colorado.edu>
5021
5028
5022 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
5029 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
5023 where failing to set sys.last_traceback would crash pdb.pm().
5030 where failing to set sys.last_traceback would crash pdb.pm().
5024 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
5031 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
5025 report.
5032 report.
5026
5033
5027 2003-03-25 Fernando Perez <fperez@colorado.edu>
5034 2003-03-25 Fernando Perez <fperez@colorado.edu>
5028
5035
5029 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
5036 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
5030 before printing it (it had a lot of spurious blank lines at the
5037 before printing it (it had a lot of spurious blank lines at the
5031 end).
5038 end).
5032
5039
5033 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
5040 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
5034 output would be sent 21 times! Obviously people don't use this
5041 output would be sent 21 times! Obviously people don't use this
5035 too often, or I would have heard about it.
5042 too often, or I would have heard about it.
5036
5043
5037 2003-03-24 Fernando Perez <fperez@colorado.edu>
5044 2003-03-24 Fernando Perez <fperez@colorado.edu>
5038
5045
5039 * setup.py (scriptfiles): renamed the data_files parameter from
5046 * setup.py (scriptfiles): renamed the data_files parameter from
5040 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
5047 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
5041 for the patch.
5048 for the patch.
5042
5049
5043 2003-03-20 Fernando Perez <fperez@colorado.edu>
5050 2003-03-20 Fernando Perez <fperez@colorado.edu>
5044
5051
5045 * IPython/genutils.py (error): added error() and fatal()
5052 * IPython/genutils.py (error): added error() and fatal()
5046 functions.
5053 functions.
5047
5054
5048 2003-03-18 *** Released version 0.2.15pre3
5055 2003-03-18 *** Released version 0.2.15pre3
5049
5056
5050 2003-03-18 Fernando Perez <fperez@colorado.edu>
5057 2003-03-18 Fernando Perez <fperez@colorado.edu>
5051
5058
5052 * setupext/install_data_ext.py
5059 * setupext/install_data_ext.py
5053 (install_data_ext.initialize_options): Class contributed by Jack
5060 (install_data_ext.initialize_options): Class contributed by Jack
5054 Moffit for fixing the old distutils hack. He is sending this to
5061 Moffit for fixing the old distutils hack. He is sending this to
5055 the distutils folks so in the future we may not need it as a
5062 the distutils folks so in the future we may not need it as a
5056 private fix.
5063 private fix.
5057
5064
5058 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
5065 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
5059 changes for Debian packaging. See his patch for full details.
5066 changes for Debian packaging. See his patch for full details.
5060 The old distutils hack of making the ipythonrc* files carry a
5067 The old distutils hack of making the ipythonrc* files carry a
5061 bogus .py extension is gone, at last. Examples were moved to a
5068 bogus .py extension is gone, at last. Examples were moved to a
5062 separate subdir under doc/, and the separate executable scripts
5069 separate subdir under doc/, and the separate executable scripts
5063 now live in their own directory. Overall a great cleanup. The
5070 now live in their own directory. Overall a great cleanup. The
5064 manual was updated to use the new files, and setup.py has been
5071 manual was updated to use the new files, and setup.py has been
5065 fixed for this setup.
5072 fixed for this setup.
5066
5073
5067 * IPython/PyColorize.py (Parser.usage): made non-executable and
5074 * IPython/PyColorize.py (Parser.usage): made non-executable and
5068 created a pycolor wrapper around it to be included as a script.
5075 created a pycolor wrapper around it to be included as a script.
5069
5076
5070 2003-03-12 *** Released version 0.2.15pre2
5077 2003-03-12 *** Released version 0.2.15pre2
5071
5078
5072 2003-03-12 Fernando Perez <fperez@colorado.edu>
5079 2003-03-12 Fernando Perez <fperez@colorado.edu>
5073
5080
5074 * IPython/ColorANSI.py (make_color_table): Finally fixed the
5081 * IPython/ColorANSI.py (make_color_table): Finally fixed the
5075 long-standing problem with garbage characters in some terminals.
5082 long-standing problem with garbage characters in some terminals.
5076 The issue was really that the \001 and \002 escapes must _only_ be
5083 The issue was really that the \001 and \002 escapes must _only_ be
5077 passed to input prompts (which call readline), but _never_ to
5084 passed to input prompts (which call readline), but _never_ to
5078 normal text to be printed on screen. I changed ColorANSI to have
5085 normal text to be printed on screen. I changed ColorANSI to have
5079 two classes: TermColors and InputTermColors, each with the
5086 two classes: TermColors and InputTermColors, each with the
5080 appropriate escapes for input prompts or normal text. The code in
5087 appropriate escapes for input prompts or normal text. The code in
5081 Prompts.py got slightly more complicated, but this very old and
5088 Prompts.py got slightly more complicated, but this very old and
5082 annoying bug is finally fixed.
5089 annoying bug is finally fixed.
5083
5090
5084 All the credit for nailing down the real origin of this problem
5091 All the credit for nailing down the real origin of this problem
5085 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
5092 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
5086 *Many* thanks to him for spending quite a bit of effort on this.
5093 *Many* thanks to him for spending quite a bit of effort on this.
5087
5094
5088 2003-03-05 *** Released version 0.2.15pre1
5095 2003-03-05 *** Released version 0.2.15pre1
5089
5096
5090 2003-03-03 Fernando Perez <fperez@colorado.edu>
5097 2003-03-03 Fernando Perez <fperez@colorado.edu>
5091
5098
5092 * IPython/FakeModule.py: Moved the former _FakeModule to a
5099 * IPython/FakeModule.py: Moved the former _FakeModule to a
5093 separate file, because it's also needed by Magic (to fix a similar
5100 separate file, because it's also needed by Magic (to fix a similar
5094 pickle-related issue in @run).
5101 pickle-related issue in @run).
5095
5102
5096 2003-03-02 Fernando Perez <fperez@colorado.edu>
5103 2003-03-02 Fernando Perez <fperez@colorado.edu>
5097
5104
5098 * IPython/Magic.py (Magic.magic_autocall): new magic to control
5105 * IPython/Magic.py (Magic.magic_autocall): new magic to control
5099 the autocall option at runtime.
5106 the autocall option at runtime.
5100 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
5107 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
5101 across Magic.py to start separating Magic from InteractiveShell.
5108 across Magic.py to start separating Magic from InteractiveShell.
5102 (Magic._ofind): Fixed to return proper namespace for dotted
5109 (Magic._ofind): Fixed to return proper namespace for dotted
5103 names. Before, a dotted name would always return 'not currently
5110 names. Before, a dotted name would always return 'not currently
5104 defined', because it would find the 'parent'. s.x would be found,
5111 defined', because it would find the 'parent'. s.x would be found,
5105 but since 'x' isn't defined by itself, it would get confused.
5112 but since 'x' isn't defined by itself, it would get confused.
5106 (Magic.magic_run): Fixed pickling problems reported by Ralf
5113 (Magic.magic_run): Fixed pickling problems reported by Ralf
5107 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
5114 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
5108 that I'd used when Mike Heeter reported similar issues at the
5115 that I'd used when Mike Heeter reported similar issues at the
5109 top-level, but now for @run. It boils down to injecting the
5116 top-level, but now for @run. It boils down to injecting the
5110 namespace where code is being executed with something that looks
5117 namespace where code is being executed with something that looks
5111 enough like a module to fool pickle.dump(). Since a pickle stores
5118 enough like a module to fool pickle.dump(). Since a pickle stores
5112 a named reference to the importing module, we need this for
5119 a named reference to the importing module, we need this for
5113 pickles to save something sensible.
5120 pickles to save something sensible.
5114
5121
5115 * IPython/ipmaker.py (make_IPython): added an autocall option.
5122 * IPython/ipmaker.py (make_IPython): added an autocall option.
5116
5123
5117 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
5124 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
5118 the auto-eval code. Now autocalling is an option, and the code is
5125 the auto-eval code. Now autocalling is an option, and the code is
5119 also vastly safer. There is no more eval() involved at all.
5126 also vastly safer. There is no more eval() involved at all.
5120
5127
5121 2003-03-01 Fernando Perez <fperez@colorado.edu>
5128 2003-03-01 Fernando Perez <fperez@colorado.edu>
5122
5129
5123 * IPython/Magic.py (Magic._ofind): Changed interface to return a
5130 * IPython/Magic.py (Magic._ofind): Changed interface to return a
5124 dict with named keys instead of a tuple.
5131 dict with named keys instead of a tuple.
5125
5132
5126 * IPython: Started using CVS for IPython as of 0.2.15pre1.
5133 * IPython: Started using CVS for IPython as of 0.2.15pre1.
5127
5134
5128 * setup.py (make_shortcut): Fixed message about directories
5135 * setup.py (make_shortcut): Fixed message about directories
5129 created during Windows installation (the directories were ok, just
5136 created during Windows installation (the directories were ok, just
5130 the printed message was misleading). Thanks to Chris Liechti
5137 the printed message was misleading). Thanks to Chris Liechti
5131 <cliechti-AT-gmx.net> for the heads up.
5138 <cliechti-AT-gmx.net> for the heads up.
5132
5139
5133 2003-02-21 Fernando Perez <fperez@colorado.edu>
5140 2003-02-21 Fernando Perez <fperez@colorado.edu>
5134
5141
5135 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
5142 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
5136 of ValueError exception when checking for auto-execution. This
5143 of ValueError exception when checking for auto-execution. This
5137 one is raised by things like Numeric arrays arr.flat when the
5144 one is raised by things like Numeric arrays arr.flat when the
5138 array is non-contiguous.
5145 array is non-contiguous.
5139
5146
5140 2003-01-31 Fernando Perez <fperez@colorado.edu>
5147 2003-01-31 Fernando Perez <fperez@colorado.edu>
5141
5148
5142 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
5149 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
5143 not return any value at all (even though the command would get
5150 not return any value at all (even though the command would get
5144 executed).
5151 executed).
5145 (xsys): Flush stdout right after printing the command to ensure
5152 (xsys): Flush stdout right after printing the command to ensure
5146 proper ordering of commands and command output in the total
5153 proper ordering of commands and command output in the total
5147 output.
5154 output.
5148 (SystemExec/xsys/bq): Switched the names of xsys/bq and
5155 (SystemExec/xsys/bq): Switched the names of xsys/bq and
5149 system/getoutput as defaults. The old ones are kept for
5156 system/getoutput as defaults. The old ones are kept for
5150 compatibility reasons, so no code which uses this library needs
5157 compatibility reasons, so no code which uses this library needs
5151 changing.
5158 changing.
5152
5159
5153 2003-01-27 *** Released version 0.2.14
5160 2003-01-27 *** Released version 0.2.14
5154
5161
5155 2003-01-25 Fernando Perez <fperez@colorado.edu>
5162 2003-01-25 Fernando Perez <fperez@colorado.edu>
5156
5163
5157 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
5164 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
5158 functions defined in previous edit sessions could not be re-edited
5165 functions defined in previous edit sessions could not be re-edited
5159 (because the temp files were immediately removed). Now temp files
5166 (because the temp files were immediately removed). Now temp files
5160 are removed only at IPython's exit.
5167 are removed only at IPython's exit.
5161 (Magic.magic_run): Improved @run to perform shell-like expansions
5168 (Magic.magic_run): Improved @run to perform shell-like expansions
5162 on its arguments (~users and $VARS). With this, @run becomes more
5169 on its arguments (~users and $VARS). With this, @run becomes more
5163 like a normal command-line.
5170 like a normal command-line.
5164
5171
5165 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
5172 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
5166 bugs related to embedding and cleaned up that code. A fairly
5173 bugs related to embedding and cleaned up that code. A fairly
5167 important one was the impossibility to access the global namespace
5174 important one was the impossibility to access the global namespace
5168 through the embedded IPython (only local variables were visible).
5175 through the embedded IPython (only local variables were visible).
5169
5176
5170 2003-01-14 Fernando Perez <fperez@colorado.edu>
5177 2003-01-14 Fernando Perez <fperez@colorado.edu>
5171
5178
5172 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
5179 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
5173 auto-calling to be a bit more conservative. Now it doesn't get
5180 auto-calling to be a bit more conservative. Now it doesn't get
5174 triggered if any of '!=()<>' are in the rest of the input line, to
5181 triggered if any of '!=()<>' are in the rest of the input line, to
5175 allow comparing callables. Thanks to Alex for the heads up.
5182 allow comparing callables. Thanks to Alex for the heads up.
5176
5183
5177 2003-01-07 Fernando Perez <fperez@colorado.edu>
5184 2003-01-07 Fernando Perez <fperez@colorado.edu>
5178
5185
5179 * IPython/genutils.py (page): fixed estimation of the number of
5186 * IPython/genutils.py (page): fixed estimation of the number of
5180 lines in a string to be paged to simply count newlines. This
5187 lines in a string to be paged to simply count newlines. This
5181 prevents over-guessing due to embedded escape sequences. A better
5188 prevents over-guessing due to embedded escape sequences. A better
5182 long-term solution would involve stripping out the control chars
5189 long-term solution would involve stripping out the control chars
5183 for the count, but it's potentially so expensive I just don't
5190 for the count, but it's potentially so expensive I just don't
5184 think it's worth doing.
5191 think it's worth doing.
5185
5192
5186 2002-12-19 *** Released version 0.2.14pre50
5193 2002-12-19 *** Released version 0.2.14pre50
5187
5194
5188 2002-12-19 Fernando Perez <fperez@colorado.edu>
5195 2002-12-19 Fernando Perez <fperez@colorado.edu>
5189
5196
5190 * tools/release (version): Changed release scripts to inform
5197 * tools/release (version): Changed release scripts to inform
5191 Andrea and build a NEWS file with a list of recent changes.
5198 Andrea and build a NEWS file with a list of recent changes.
5192
5199
5193 * IPython/ColorANSI.py (__all__): changed terminal detection
5200 * IPython/ColorANSI.py (__all__): changed terminal detection
5194 code. Seems to work better for xterms without breaking
5201 code. Seems to work better for xterms without breaking
5195 konsole. Will need more testing to determine if WinXP and Mac OSX
5202 konsole. Will need more testing to determine if WinXP and Mac OSX
5196 also work ok.
5203 also work ok.
5197
5204
5198 2002-12-18 *** Released version 0.2.14pre49
5205 2002-12-18 *** Released version 0.2.14pre49
5199
5206
5200 2002-12-18 Fernando Perez <fperez@colorado.edu>
5207 2002-12-18 Fernando Perez <fperez@colorado.edu>
5201
5208
5202 * Docs: added new info about Mac OSX, from Andrea.
5209 * Docs: added new info about Mac OSX, from Andrea.
5203
5210
5204 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
5211 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
5205 allow direct plotting of python strings whose format is the same
5212 allow direct plotting of python strings whose format is the same
5206 of gnuplot data files.
5213 of gnuplot data files.
5207
5214
5208 2002-12-16 Fernando Perez <fperez@colorado.edu>
5215 2002-12-16 Fernando Perez <fperez@colorado.edu>
5209
5216
5210 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
5217 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
5211 value of exit question to be acknowledged.
5218 value of exit question to be acknowledged.
5212
5219
5213 2002-12-03 Fernando Perez <fperez@colorado.edu>
5220 2002-12-03 Fernando Perez <fperez@colorado.edu>
5214
5221
5215 * IPython/ipmaker.py: removed generators, which had been added
5222 * IPython/ipmaker.py: removed generators, which had been added
5216 by mistake in an earlier debugging run. This was causing trouble
5223 by mistake in an earlier debugging run. This was causing trouble
5217 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
5224 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
5218 for pointing this out.
5225 for pointing this out.
5219
5226
5220 2002-11-17 Fernando Perez <fperez@colorado.edu>
5227 2002-11-17 Fernando Perez <fperez@colorado.edu>
5221
5228
5222 * Manual: updated the Gnuplot section.
5229 * Manual: updated the Gnuplot section.
5223
5230
5224 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
5231 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
5225 a much better split of what goes in Runtime and what goes in
5232 a much better split of what goes in Runtime and what goes in
5226 Interactive.
5233 Interactive.
5227
5234
5228 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
5235 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
5229 being imported from iplib.
5236 being imported from iplib.
5230
5237
5231 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
5238 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
5232 for command-passing. Now the global Gnuplot instance is called
5239 for command-passing. Now the global Gnuplot instance is called
5233 'gp' instead of 'g', which was really a far too fragile and
5240 'gp' instead of 'g', which was really a far too fragile and
5234 common name.
5241 common name.
5235
5242
5236 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
5243 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
5237 bounding boxes generated by Gnuplot for square plots.
5244 bounding boxes generated by Gnuplot for square plots.
5238
5245
5239 * IPython/genutils.py (popkey): new function added. I should
5246 * IPython/genutils.py (popkey): new function added. I should
5240 suggest this on c.l.py as a dict method, it seems useful.
5247 suggest this on c.l.py as a dict method, it seems useful.
5241
5248
5242 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
5249 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
5243 to transparently handle PostScript generation. MUCH better than
5250 to transparently handle PostScript generation. MUCH better than
5244 the previous plot_eps/replot_eps (which I removed now). The code
5251 the previous plot_eps/replot_eps (which I removed now). The code
5245 is also fairly clean and well documented now (including
5252 is also fairly clean and well documented now (including
5246 docstrings).
5253 docstrings).
5247
5254
5248 2002-11-13 Fernando Perez <fperez@colorado.edu>
5255 2002-11-13 Fernando Perez <fperez@colorado.edu>
5249
5256
5250 * IPython/Magic.py (Magic.magic_edit): fixed docstring
5257 * IPython/Magic.py (Magic.magic_edit): fixed docstring
5251 (inconsistent with options).
5258 (inconsistent with options).
5252
5259
5253 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
5260 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
5254 manually disabled, I don't know why. Fixed it.
5261 manually disabled, I don't know why. Fixed it.
5255 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
5262 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
5256 eps output.
5263 eps output.
5257
5264
5258 2002-11-12 Fernando Perez <fperez@colorado.edu>
5265 2002-11-12 Fernando Perez <fperez@colorado.edu>
5259
5266
5260 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
5267 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
5261 don't propagate up to caller. Fixes crash reported by François
5268 don't propagate up to caller. Fixes crash reported by François
5262 Pinard.
5269 Pinard.
5263
5270
5264 2002-11-09 Fernando Perez <fperez@colorado.edu>
5271 2002-11-09 Fernando Perez <fperez@colorado.edu>
5265
5272
5266 * IPython/ipmaker.py (make_IPython): fixed problem with writing
5273 * IPython/ipmaker.py (make_IPython): fixed problem with writing
5267 history file for new users.
5274 history file for new users.
5268 (make_IPython): fixed bug where initial install would leave the
5275 (make_IPython): fixed bug where initial install would leave the
5269 user running in the .ipython dir.
5276 user running in the .ipython dir.
5270 (make_IPython): fixed bug where config dir .ipython would be
5277 (make_IPython): fixed bug where config dir .ipython would be
5271 created regardless of the given -ipythondir option. Thanks to Cory
5278 created regardless of the given -ipythondir option. Thanks to Cory
5272 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
5279 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
5273
5280
5274 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
5281 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
5275 type confirmations. Will need to use it in all of IPython's code
5282 type confirmations. Will need to use it in all of IPython's code
5276 consistently.
5283 consistently.
5277
5284
5278 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
5285 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
5279 context to print 31 lines instead of the default 5. This will make
5286 context to print 31 lines instead of the default 5. This will make
5280 the crash reports extremely detailed in case the problem is in
5287 the crash reports extremely detailed in case the problem is in
5281 libraries I don't have access to.
5288 libraries I don't have access to.
5282
5289
5283 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
5290 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
5284 line of defense' code to still crash, but giving users fair
5291 line of defense' code to still crash, but giving users fair
5285 warning. I don't want internal errors to go unreported: if there's
5292 warning. I don't want internal errors to go unreported: if there's
5286 an internal problem, IPython should crash and generate a full
5293 an internal problem, IPython should crash and generate a full
5287 report.
5294 report.
5288
5295
5289 2002-11-08 Fernando Perez <fperez@colorado.edu>
5296 2002-11-08 Fernando Perez <fperez@colorado.edu>
5290
5297
5291 * IPython/iplib.py (InteractiveShell.interact): added code to trap
5298 * IPython/iplib.py (InteractiveShell.interact): added code to trap
5292 otherwise uncaught exceptions which can appear if people set
5299 otherwise uncaught exceptions which can appear if people set
5293 sys.stdout to something badly broken. Thanks to a crash report
5300 sys.stdout to something badly broken. Thanks to a crash report
5294 from henni-AT-mail.brainbot.com.
5301 from henni-AT-mail.brainbot.com.
5295
5302
5296 2002-11-04 Fernando Perez <fperez@colorado.edu>
5303 2002-11-04 Fernando Perez <fperez@colorado.edu>
5297
5304
5298 * IPython/iplib.py (InteractiveShell.interact): added
5305 * IPython/iplib.py (InteractiveShell.interact): added
5299 __IPYTHON__active to the builtins. It's a flag which goes on when
5306 __IPYTHON__active to the builtins. It's a flag which goes on when
5300 the interaction starts and goes off again when it stops. This
5307 the interaction starts and goes off again when it stops. This
5301 allows embedding code to detect being inside IPython. Before this
5308 allows embedding code to detect being inside IPython. Before this
5302 was done via __IPYTHON__, but that only shows that an IPython
5309 was done via __IPYTHON__, but that only shows that an IPython
5303 instance has been created.
5310 instance has been created.
5304
5311
5305 * IPython/Magic.py (Magic.magic_env): I realized that in a
5312 * IPython/Magic.py (Magic.magic_env): I realized that in a
5306 UserDict, instance.data holds the data as a normal dict. So I
5313 UserDict, instance.data holds the data as a normal dict. So I
5307 modified @env to return os.environ.data instead of rebuilding a
5314 modified @env to return os.environ.data instead of rebuilding a
5308 dict by hand.
5315 dict by hand.
5309
5316
5310 2002-11-02 Fernando Perez <fperez@colorado.edu>
5317 2002-11-02 Fernando Perez <fperez@colorado.edu>
5311
5318
5312 * IPython/genutils.py (warn): changed so that level 1 prints no
5319 * IPython/genutils.py (warn): changed so that level 1 prints no
5313 header. Level 2 is now the default (with 'WARNING' header, as
5320 header. Level 2 is now the default (with 'WARNING' header, as
5314 before). I think I tracked all places where changes were needed in
5321 before). I think I tracked all places where changes were needed in
5315 IPython, but outside code using the old level numbering may have
5322 IPython, but outside code using the old level numbering may have
5316 broken.
5323 broken.
5317
5324
5318 * IPython/iplib.py (InteractiveShell.runcode): added this to
5325 * IPython/iplib.py (InteractiveShell.runcode): added this to
5319 handle the tracebacks in SystemExit traps correctly. The previous
5326 handle the tracebacks in SystemExit traps correctly. The previous
5320 code (through interact) was printing more of the stack than
5327 code (through interact) was printing more of the stack than
5321 necessary, showing IPython internal code to the user.
5328 necessary, showing IPython internal code to the user.
5322
5329
5323 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
5330 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
5324 default. Now that the default at the confirmation prompt is yes,
5331 default. Now that the default at the confirmation prompt is yes,
5325 it's not so intrusive. François' argument that ipython sessions
5332 it's not so intrusive. François' argument that ipython sessions
5326 tend to be complex enough not to lose them from an accidental C-d,
5333 tend to be complex enough not to lose them from an accidental C-d,
5327 is a valid one.
5334 is a valid one.
5328
5335
5329 * IPython/iplib.py (InteractiveShell.interact): added a
5336 * IPython/iplib.py (InteractiveShell.interact): added a
5330 showtraceback() call to the SystemExit trap, and modified the exit
5337 showtraceback() call to the SystemExit trap, and modified the exit
5331 confirmation to have yes as the default.
5338 confirmation to have yes as the default.
5332
5339
5333 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
5340 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
5334 this file. It's been gone from the code for a long time, this was
5341 this file. It's been gone from the code for a long time, this was
5335 simply leftover junk.
5342 simply leftover junk.
5336
5343
5337 2002-11-01 Fernando Perez <fperez@colorado.edu>
5344 2002-11-01 Fernando Perez <fperez@colorado.edu>
5338
5345
5339 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
5346 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
5340 added. If set, IPython now traps EOF and asks for
5347 added. If set, IPython now traps EOF and asks for
5341 confirmation. After a request by François Pinard.
5348 confirmation. After a request by François Pinard.
5342
5349
5343 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
5350 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
5344 of @abort, and with a new (better) mechanism for handling the
5351 of @abort, and with a new (better) mechanism for handling the
5345 exceptions.
5352 exceptions.
5346
5353
5347 2002-10-27 Fernando Perez <fperez@colorado.edu>
5354 2002-10-27 Fernando Perez <fperez@colorado.edu>
5348
5355
5349 * IPython/usage.py (__doc__): updated the --help information and
5356 * IPython/usage.py (__doc__): updated the --help information and
5350 the ipythonrc file to indicate that -log generates
5357 the ipythonrc file to indicate that -log generates
5351 ./ipython.log. Also fixed the corresponding info in @logstart.
5358 ./ipython.log. Also fixed the corresponding info in @logstart.
5352 This and several other fixes in the manuals thanks to reports by
5359 This and several other fixes in the manuals thanks to reports by
5353 François Pinard <pinard-AT-iro.umontreal.ca>.
5360 François Pinard <pinard-AT-iro.umontreal.ca>.
5354
5361
5355 * IPython/Logger.py (Logger.switch_log): Fixed error message to
5362 * IPython/Logger.py (Logger.switch_log): Fixed error message to
5356 refer to @logstart (instead of @log, which doesn't exist).
5363 refer to @logstart (instead of @log, which doesn't exist).
5357
5364
5358 * IPython/iplib.py (InteractiveShell._prefilter): fixed
5365 * IPython/iplib.py (InteractiveShell._prefilter): fixed
5359 AttributeError crash. Thanks to Christopher Armstrong
5366 AttributeError crash. Thanks to Christopher Armstrong
5360 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
5367 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
5361 introduced recently (in 0.2.14pre37) with the fix to the eval
5368 introduced recently (in 0.2.14pre37) with the fix to the eval
5362 problem mentioned below.
5369 problem mentioned below.
5363
5370
5364 2002-10-17 Fernando Perez <fperez@colorado.edu>
5371 2002-10-17 Fernando Perez <fperez@colorado.edu>
5365
5372
5366 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
5373 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
5367 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
5374 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
5368
5375
5369 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
5376 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
5370 this function to fix a problem reported by Alex Schmolck. He saw
5377 this function to fix a problem reported by Alex Schmolck. He saw
5371 it with list comprehensions and generators, which were getting
5378 it with list comprehensions and generators, which were getting
5372 called twice. The real problem was an 'eval' call in testing for
5379 called twice. The real problem was an 'eval' call in testing for
5373 automagic which was evaluating the input line silently.
5380 automagic which was evaluating the input line silently.
5374
5381
5375 This is a potentially very nasty bug, if the input has side
5382 This is a potentially very nasty bug, if the input has side
5376 effects which must not be repeated. The code is much cleaner now,
5383 effects which must not be repeated. The code is much cleaner now,
5377 without any blanket 'except' left and with a regexp test for
5384 without any blanket 'except' left and with a regexp test for
5378 actual function names.
5385 actual function names.
5379
5386
5380 But an eval remains, which I'm not fully comfortable with. I just
5387 But an eval remains, which I'm not fully comfortable with. I just
5381 don't know how to find out if an expression could be a callable in
5388 don't know how to find out if an expression could be a callable in
5382 the user's namespace without doing an eval on the string. However
5389 the user's namespace without doing an eval on the string. However
5383 that string is now much more strictly checked so that no code
5390 that string is now much more strictly checked so that no code
5384 slips by, so the eval should only happen for things that can
5391 slips by, so the eval should only happen for things that can
5385 really be only function/method names.
5392 really be only function/method names.
5386
5393
5387 2002-10-15 Fernando Perez <fperez@colorado.edu>
5394 2002-10-15 Fernando Perez <fperez@colorado.edu>
5388
5395
5389 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
5396 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
5390 OSX information to main manual, removed README_Mac_OSX file from
5397 OSX information to main manual, removed README_Mac_OSX file from
5391 distribution. Also updated credits for recent additions.
5398 distribution. Also updated credits for recent additions.
5392
5399
5393 2002-10-10 Fernando Perez <fperez@colorado.edu>
5400 2002-10-10 Fernando Perez <fperez@colorado.edu>
5394
5401
5395 * README_Mac_OSX: Added a README for Mac OSX users for fixing
5402 * README_Mac_OSX: Added a README for Mac OSX users for fixing
5396 terminal-related issues. Many thanks to Andrea Riciputi
5403 terminal-related issues. Many thanks to Andrea Riciputi
5397 <andrea.riciputi-AT-libero.it> for writing it.
5404 <andrea.riciputi-AT-libero.it> for writing it.
5398
5405
5399 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
5406 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
5400 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5407 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5401
5408
5402 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
5409 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
5403 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
5410 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
5404 <syver-en-AT-online.no> who both submitted patches for this problem.
5411 <syver-en-AT-online.no> who both submitted patches for this problem.
5405
5412
5406 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
5413 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
5407 global embedding to make sure that things don't overwrite user
5414 global embedding to make sure that things don't overwrite user
5408 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
5415 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
5409
5416
5410 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
5417 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
5411 compatibility. Thanks to Hayden Callow
5418 compatibility. Thanks to Hayden Callow
5412 <h.callow-AT-elec.canterbury.ac.nz>
5419 <h.callow-AT-elec.canterbury.ac.nz>
5413
5420
5414 2002-10-04 Fernando Perez <fperez@colorado.edu>
5421 2002-10-04 Fernando Perez <fperez@colorado.edu>
5415
5422
5416 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
5423 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
5417 Gnuplot.File objects.
5424 Gnuplot.File objects.
5418
5425
5419 2002-07-23 Fernando Perez <fperez@colorado.edu>
5426 2002-07-23 Fernando Perez <fperez@colorado.edu>
5420
5427
5421 * IPython/genutils.py (timing): Added timings() and timing() for
5428 * IPython/genutils.py (timing): Added timings() and timing() for
5422 quick access to the most commonly needed data, the execution
5429 quick access to the most commonly needed data, the execution
5423 times. Old timing() renamed to timings_out().
5430 times. Old timing() renamed to timings_out().
5424
5431
5425 2002-07-18 Fernando Perez <fperez@colorado.edu>
5432 2002-07-18 Fernando Perez <fperez@colorado.edu>
5426
5433
5427 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
5434 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
5428 bug with nested instances disrupting the parent's tab completion.
5435 bug with nested instances disrupting the parent's tab completion.
5429
5436
5430 * IPython/iplib.py (all_completions): Added Alex Schmolck's
5437 * IPython/iplib.py (all_completions): Added Alex Schmolck's
5431 all_completions code to begin the emacs integration.
5438 all_completions code to begin the emacs integration.
5432
5439
5433 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
5440 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
5434 argument to allow titling individual arrays when plotting.
5441 argument to allow titling individual arrays when plotting.
5435
5442
5436 2002-07-15 Fernando Perez <fperez@colorado.edu>
5443 2002-07-15 Fernando Perez <fperez@colorado.edu>
5437
5444
5438 * setup.py (make_shortcut): changed to retrieve the value of
5445 * setup.py (make_shortcut): changed to retrieve the value of
5439 'Program Files' directory from the registry (this value changes in
5446 'Program Files' directory from the registry (this value changes in
5440 non-english versions of Windows). Thanks to Thomas Fanslau
5447 non-english versions of Windows). Thanks to Thomas Fanslau
5441 <tfanslau-AT-gmx.de> for the report.
5448 <tfanslau-AT-gmx.de> for the report.
5442
5449
5443 2002-07-10 Fernando Perez <fperez@colorado.edu>
5450 2002-07-10 Fernando Perez <fperez@colorado.edu>
5444
5451
5445 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
5452 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
5446 a bug in pdb, which crashes if a line with only whitespace is
5453 a bug in pdb, which crashes if a line with only whitespace is
5447 entered. Bug report submitted to sourceforge.
5454 entered. Bug report submitted to sourceforge.
5448
5455
5449 2002-07-09 Fernando Perez <fperez@colorado.edu>
5456 2002-07-09 Fernando Perez <fperez@colorado.edu>
5450
5457
5451 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
5458 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
5452 reporting exceptions (it's a bug in inspect.py, I just set a
5459 reporting exceptions (it's a bug in inspect.py, I just set a
5453 workaround).
5460 workaround).
5454
5461
5455 2002-07-08 Fernando Perez <fperez@colorado.edu>
5462 2002-07-08 Fernando Perez <fperez@colorado.edu>
5456
5463
5457 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
5464 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
5458 __IPYTHON__ in __builtins__ to show up in user_ns.
5465 __IPYTHON__ in __builtins__ to show up in user_ns.
5459
5466
5460 2002-07-03 Fernando Perez <fperez@colorado.edu>
5467 2002-07-03 Fernando Perez <fperez@colorado.edu>
5461
5468
5462 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
5469 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
5463 name from @gp_set_instance to @gp_set_default.
5470 name from @gp_set_instance to @gp_set_default.
5464
5471
5465 * IPython/ipmaker.py (make_IPython): default editor value set to
5472 * IPython/ipmaker.py (make_IPython): default editor value set to
5466 '0' (a string), to match the rc file. Otherwise will crash when
5473 '0' (a string), to match the rc file. Otherwise will crash when
5467 .strip() is called on it.
5474 .strip() is called on it.
5468
5475
5469
5476
5470 2002-06-28 Fernando Perez <fperez@colorado.edu>
5477 2002-06-28 Fernando Perez <fperez@colorado.edu>
5471
5478
5472 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
5479 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
5473 of files in current directory when a file is executed via
5480 of files in current directory when a file is executed via
5474 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
5481 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
5475
5482
5476 * setup.py (manfiles): fix for rpm builds, submitted by RA
5483 * setup.py (manfiles): fix for rpm builds, submitted by RA
5477 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
5484 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
5478
5485
5479 * IPython/ipmaker.py (make_IPython): fixed lookup of default
5486 * IPython/ipmaker.py (make_IPython): fixed lookup of default
5480 editor when set to '0'. Problem was, '0' evaluates to True (it's a
5487 editor when set to '0'. Problem was, '0' evaluates to True (it's a
5481 string!). A. Schmolck caught this one.
5488 string!). A. Schmolck caught this one.
5482
5489
5483 2002-06-27 Fernando Perez <fperez@colorado.edu>
5490 2002-06-27 Fernando Perez <fperez@colorado.edu>
5484
5491
5485 * IPython/ipmaker.py (make_IPython): fixed bug when running user
5492 * IPython/ipmaker.py (make_IPython): fixed bug when running user
5486 defined files at the cmd line. __name__ wasn't being set to
5493 defined files at the cmd line. __name__ wasn't being set to
5487 __main__.
5494 __main__.
5488
5495
5489 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
5496 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
5490 regular lists and tuples besides Numeric arrays.
5497 regular lists and tuples besides Numeric arrays.
5491
5498
5492 * IPython/Prompts.py (CachedOutput.__call__): Added output
5499 * IPython/Prompts.py (CachedOutput.__call__): Added output
5493 supression for input ending with ';'. Similar to Mathematica and
5500 supression for input ending with ';'. Similar to Mathematica and
5494 Matlab. The _* vars and Out[] list are still updated, just like
5501 Matlab. The _* vars and Out[] list are still updated, just like
5495 Mathematica behaves.
5502 Mathematica behaves.
5496
5503
5497 2002-06-25 Fernando Perez <fperez@colorado.edu>
5504 2002-06-25 Fernando Perez <fperez@colorado.edu>
5498
5505
5499 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
5506 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
5500 .ini extensions for profiels under Windows.
5507 .ini extensions for profiels under Windows.
5501
5508
5502 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
5509 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
5503 string form. Fix contributed by Alexander Schmolck
5510 string form. Fix contributed by Alexander Schmolck
5504 <a.schmolck-AT-gmx.net>
5511 <a.schmolck-AT-gmx.net>
5505
5512
5506 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
5513 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
5507 pre-configured Gnuplot instance.
5514 pre-configured Gnuplot instance.
5508
5515
5509 2002-06-21 Fernando Perez <fperez@colorado.edu>
5516 2002-06-21 Fernando Perez <fperez@colorado.edu>
5510
5517
5511 * IPython/numutils.py (exp_safe): new function, works around the
5518 * IPython/numutils.py (exp_safe): new function, works around the
5512 underflow problems in Numeric.
5519 underflow problems in Numeric.
5513 (log2): New fn. Safe log in base 2: returns exact integer answer
5520 (log2): New fn. Safe log in base 2: returns exact integer answer
5514 for exact integer powers of 2.
5521 for exact integer powers of 2.
5515
5522
5516 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
5523 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
5517 properly.
5524 properly.
5518
5525
5519 2002-06-20 Fernando Perez <fperez@colorado.edu>
5526 2002-06-20 Fernando Perez <fperez@colorado.edu>
5520
5527
5521 * IPython/genutils.py (timing): new function like
5528 * IPython/genutils.py (timing): new function like
5522 Mathematica's. Similar to time_test, but returns more info.
5529 Mathematica's. Similar to time_test, but returns more info.
5523
5530
5524 2002-06-18 Fernando Perez <fperez@colorado.edu>
5531 2002-06-18 Fernando Perez <fperez@colorado.edu>
5525
5532
5526 * IPython/Magic.py (Magic.magic_save): modified @save and @r
5533 * IPython/Magic.py (Magic.magic_save): modified @save and @r
5527 according to Mike Heeter's suggestions.
5534 according to Mike Heeter's suggestions.
5528
5535
5529 2002-06-16 Fernando Perez <fperez@colorado.edu>
5536 2002-06-16 Fernando Perez <fperez@colorado.edu>
5530
5537
5531 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
5538 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
5532 system. GnuplotMagic is gone as a user-directory option. New files
5539 system. GnuplotMagic is gone as a user-directory option. New files
5533 make it easier to use all the gnuplot stuff both from external
5540 make it easier to use all the gnuplot stuff both from external
5534 programs as well as from IPython. Had to rewrite part of
5541 programs as well as from IPython. Had to rewrite part of
5535 hardcopy() b/c of a strange bug: often the ps files simply don't
5542 hardcopy() b/c of a strange bug: often the ps files simply don't
5536 get created, and require a repeat of the command (often several
5543 get created, and require a repeat of the command (often several
5537 times).
5544 times).
5538
5545
5539 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
5546 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
5540 resolve output channel at call time, so that if sys.stderr has
5547 resolve output channel at call time, so that if sys.stderr has
5541 been redirected by user this gets honored.
5548 been redirected by user this gets honored.
5542
5549
5543 2002-06-13 Fernando Perez <fperez@colorado.edu>
5550 2002-06-13 Fernando Perez <fperez@colorado.edu>
5544
5551
5545 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
5552 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
5546 IPShell. Kept a copy with the old names to avoid breaking people's
5553 IPShell. Kept a copy with the old names to avoid breaking people's
5547 embedded code.
5554 embedded code.
5548
5555
5549 * IPython/ipython: simplified it to the bare minimum after
5556 * IPython/ipython: simplified it to the bare minimum after
5550 Holger's suggestions. Added info about how to use it in
5557 Holger's suggestions. Added info about how to use it in
5551 PYTHONSTARTUP.
5558 PYTHONSTARTUP.
5552
5559
5553 * IPython/Shell.py (IPythonShell): changed the options passing
5560 * IPython/Shell.py (IPythonShell): changed the options passing
5554 from a string with funky %s replacements to a straight list. Maybe
5561 from a string with funky %s replacements to a straight list. Maybe
5555 a bit more typing, but it follows sys.argv conventions, so there's
5562 a bit more typing, but it follows sys.argv conventions, so there's
5556 less special-casing to remember.
5563 less special-casing to remember.
5557
5564
5558 2002-06-12 Fernando Perez <fperez@colorado.edu>
5565 2002-06-12 Fernando Perez <fperez@colorado.edu>
5559
5566
5560 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
5567 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
5561 command. Thanks to a suggestion by Mike Heeter.
5568 command. Thanks to a suggestion by Mike Heeter.
5562 (Magic.magic_pfile): added behavior to look at filenames if given
5569 (Magic.magic_pfile): added behavior to look at filenames if given
5563 arg is not a defined object.
5570 arg is not a defined object.
5564 (Magic.magic_save): New @save function to save code snippets. Also
5571 (Magic.magic_save): New @save function to save code snippets. Also
5565 a Mike Heeter idea.
5572 a Mike Heeter idea.
5566
5573
5567 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
5574 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
5568 plot() and replot(). Much more convenient now, especially for
5575 plot() and replot(). Much more convenient now, especially for
5569 interactive use.
5576 interactive use.
5570
5577
5571 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
5578 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
5572 filenames.
5579 filenames.
5573
5580
5574 2002-06-02 Fernando Perez <fperez@colorado.edu>
5581 2002-06-02 Fernando Perez <fperez@colorado.edu>
5575
5582
5576 * IPython/Struct.py (Struct.__init__): modified to admit
5583 * IPython/Struct.py (Struct.__init__): modified to admit
5577 initialization via another struct.
5584 initialization via another struct.
5578
5585
5579 * IPython/genutils.py (SystemExec.__init__): New stateful
5586 * IPython/genutils.py (SystemExec.__init__): New stateful
5580 interface to xsys and bq. Useful for writing system scripts.
5587 interface to xsys and bq. Useful for writing system scripts.
5581
5588
5582 2002-05-30 Fernando Perez <fperez@colorado.edu>
5589 2002-05-30 Fernando Perez <fperez@colorado.edu>
5583
5590
5584 * MANIFEST.in: Changed docfile selection to exclude all the lyx
5591 * MANIFEST.in: Changed docfile selection to exclude all the lyx
5585 documents. This will make the user download smaller (it's getting
5592 documents. This will make the user download smaller (it's getting
5586 too big).
5593 too big).
5587
5594
5588 2002-05-29 Fernando Perez <fperez@colorado.edu>
5595 2002-05-29 Fernando Perez <fperez@colorado.edu>
5589
5596
5590 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
5597 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
5591 fix problems with shelve and pickle. Seems to work, but I don't
5598 fix problems with shelve and pickle. Seems to work, but I don't
5592 know if corner cases break it. Thanks to Mike Heeter
5599 know if corner cases break it. Thanks to Mike Heeter
5593 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
5600 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
5594
5601
5595 2002-05-24 Fernando Perez <fperez@colorado.edu>
5602 2002-05-24 Fernando Perez <fperez@colorado.edu>
5596
5603
5597 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
5604 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
5598 macros having broken.
5605 macros having broken.
5599
5606
5600 2002-05-21 Fernando Perez <fperez@colorado.edu>
5607 2002-05-21 Fernando Perez <fperez@colorado.edu>
5601
5608
5602 * IPython/Magic.py (Magic.magic_logstart): fixed recently
5609 * IPython/Magic.py (Magic.magic_logstart): fixed recently
5603 introduced logging bug: all history before logging started was
5610 introduced logging bug: all history before logging started was
5604 being written one character per line! This came from the redesign
5611 being written one character per line! This came from the redesign
5605 of the input history as a special list which slices to strings,
5612 of the input history as a special list which slices to strings,
5606 not to lists.
5613 not to lists.
5607
5614
5608 2002-05-20 Fernando Perez <fperez@colorado.edu>
5615 2002-05-20 Fernando Perez <fperez@colorado.edu>
5609
5616
5610 * IPython/Prompts.py (CachedOutput.__init__): made the color table
5617 * IPython/Prompts.py (CachedOutput.__init__): made the color table
5611 be an attribute of all classes in this module. The design of these
5618 be an attribute of all classes in this module. The design of these
5612 classes needs some serious overhauling.
5619 classes needs some serious overhauling.
5613
5620
5614 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
5621 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
5615 which was ignoring '_' in option names.
5622 which was ignoring '_' in option names.
5616
5623
5617 * IPython/ultraTB.py (FormattedTB.__init__): Changed
5624 * IPython/ultraTB.py (FormattedTB.__init__): Changed
5618 'Verbose_novars' to 'Context' and made it the new default. It's a
5625 'Verbose_novars' to 'Context' and made it the new default. It's a
5619 bit more readable and also safer than verbose.
5626 bit more readable and also safer than verbose.
5620
5627
5621 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
5628 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
5622 triple-quoted strings.
5629 triple-quoted strings.
5623
5630
5624 * IPython/OInspect.py (__all__): new module exposing the object
5631 * IPython/OInspect.py (__all__): new module exposing the object
5625 introspection facilities. Now the corresponding magics are dummy
5632 introspection facilities. Now the corresponding magics are dummy
5626 wrappers around this. Having this module will make it much easier
5633 wrappers around this. Having this module will make it much easier
5627 to put these functions into our modified pdb.
5634 to put these functions into our modified pdb.
5628 This new object inspector system uses the new colorizing module,
5635 This new object inspector system uses the new colorizing module,
5629 so source code and other things are nicely syntax highlighted.
5636 so source code and other things are nicely syntax highlighted.
5630
5637
5631 2002-05-18 Fernando Perez <fperez@colorado.edu>
5638 2002-05-18 Fernando Perez <fperez@colorado.edu>
5632
5639
5633 * IPython/ColorANSI.py: Split the coloring tools into a separate
5640 * IPython/ColorANSI.py: Split the coloring tools into a separate
5634 module so I can use them in other code easier (they were part of
5641 module so I can use them in other code easier (they were part of
5635 ultraTB).
5642 ultraTB).
5636
5643
5637 2002-05-17 Fernando Perez <fperez@colorado.edu>
5644 2002-05-17 Fernando Perez <fperez@colorado.edu>
5638
5645
5639 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5646 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5640 fixed it to set the global 'g' also to the called instance, as
5647 fixed it to set the global 'g' also to the called instance, as
5641 long as 'g' was still a gnuplot instance (so it doesn't overwrite
5648 long as 'g' was still a gnuplot instance (so it doesn't overwrite
5642 user's 'g' variables).
5649 user's 'g' variables).
5643
5650
5644 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
5651 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
5645 global variables (aliases to _ih,_oh) so that users which expect
5652 global variables (aliases to _ih,_oh) so that users which expect
5646 In[5] or Out[7] to work aren't unpleasantly surprised.
5653 In[5] or Out[7] to work aren't unpleasantly surprised.
5647 (InputList.__getslice__): new class to allow executing slices of
5654 (InputList.__getslice__): new class to allow executing slices of
5648 input history directly. Very simple class, complements the use of
5655 input history directly. Very simple class, complements the use of
5649 macros.
5656 macros.
5650
5657
5651 2002-05-16 Fernando Perez <fperez@colorado.edu>
5658 2002-05-16 Fernando Perez <fperez@colorado.edu>
5652
5659
5653 * setup.py (docdirbase): make doc directory be just doc/IPython
5660 * setup.py (docdirbase): make doc directory be just doc/IPython
5654 without version numbers, it will reduce clutter for users.
5661 without version numbers, it will reduce clutter for users.
5655
5662
5656 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
5663 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
5657 execfile call to prevent possible memory leak. See for details:
5664 execfile call to prevent possible memory leak. See for details:
5658 http://mail.python.org/pipermail/python-list/2002-February/088476.html
5665 http://mail.python.org/pipermail/python-list/2002-February/088476.html
5659
5666
5660 2002-05-15 Fernando Perez <fperez@colorado.edu>
5667 2002-05-15 Fernando Perez <fperez@colorado.edu>
5661
5668
5662 * IPython/Magic.py (Magic.magic_psource): made the object
5669 * IPython/Magic.py (Magic.magic_psource): made the object
5663 introspection names be more standard: pdoc, pdef, pfile and
5670 introspection names be more standard: pdoc, pdef, pfile and
5664 psource. They all print/page their output, and it makes
5671 psource. They all print/page their output, and it makes
5665 remembering them easier. Kept old names for compatibility as
5672 remembering them easier. Kept old names for compatibility as
5666 aliases.
5673 aliases.
5667
5674
5668 2002-05-14 Fernando Perez <fperez@colorado.edu>
5675 2002-05-14 Fernando Perez <fperez@colorado.edu>
5669
5676
5670 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
5677 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
5671 what the mouse problem was. The trick is to use gnuplot with temp
5678 what the mouse problem was. The trick is to use gnuplot with temp
5672 files and NOT with pipes (for data communication), because having
5679 files and NOT with pipes (for data communication), because having
5673 both pipes and the mouse on is bad news.
5680 both pipes and the mouse on is bad news.
5674
5681
5675 2002-05-13 Fernando Perez <fperez@colorado.edu>
5682 2002-05-13 Fernando Perez <fperez@colorado.edu>
5676
5683
5677 * IPython/Magic.py (Magic._ofind): fixed namespace order search
5684 * IPython/Magic.py (Magic._ofind): fixed namespace order search
5678 bug. Information would be reported about builtins even when
5685 bug. Information would be reported about builtins even when
5679 user-defined functions overrode them.
5686 user-defined functions overrode them.
5680
5687
5681 2002-05-11 Fernando Perez <fperez@colorado.edu>
5688 2002-05-11 Fernando Perez <fperez@colorado.edu>
5682
5689
5683 * IPython/__init__.py (__all__): removed FlexCompleter from
5690 * IPython/__init__.py (__all__): removed FlexCompleter from
5684 __all__ so that things don't fail in platforms without readline.
5691 __all__ so that things don't fail in platforms without readline.
5685
5692
5686 2002-05-10 Fernando Perez <fperez@colorado.edu>
5693 2002-05-10 Fernando Perez <fperez@colorado.edu>
5687
5694
5688 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
5695 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
5689 it requires Numeric, effectively making Numeric a dependency for
5696 it requires Numeric, effectively making Numeric a dependency for
5690 IPython.
5697 IPython.
5691
5698
5692 * Released 0.2.13
5699 * Released 0.2.13
5693
5700
5694 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
5701 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
5695 profiler interface. Now all the major options from the profiler
5702 profiler interface. Now all the major options from the profiler
5696 module are directly supported in IPython, both for single
5703 module are directly supported in IPython, both for single
5697 expressions (@prun) and for full programs (@run -p).
5704 expressions (@prun) and for full programs (@run -p).
5698
5705
5699 2002-05-09 Fernando Perez <fperez@colorado.edu>
5706 2002-05-09 Fernando Perez <fperez@colorado.edu>
5700
5707
5701 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
5708 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
5702 magic properly formatted for screen.
5709 magic properly formatted for screen.
5703
5710
5704 * setup.py (make_shortcut): Changed things to put pdf version in
5711 * setup.py (make_shortcut): Changed things to put pdf version in
5705 doc/ instead of doc/manual (had to change lyxport a bit).
5712 doc/ instead of doc/manual (had to change lyxport a bit).
5706
5713
5707 * IPython/Magic.py (Profile.string_stats): made profile runs go
5714 * IPython/Magic.py (Profile.string_stats): made profile runs go
5708 through pager (they are long and a pager allows searching, saving,
5715 through pager (they are long and a pager allows searching, saving,
5709 etc.)
5716 etc.)
5710
5717
5711 2002-05-08 Fernando Perez <fperez@colorado.edu>
5718 2002-05-08 Fernando Perez <fperez@colorado.edu>
5712
5719
5713 * Released 0.2.12
5720 * Released 0.2.12
5714
5721
5715 2002-05-06 Fernando Perez <fperez@colorado.edu>
5722 2002-05-06 Fernando Perez <fperez@colorado.edu>
5716
5723
5717 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5724 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5718 introduced); 'hist n1 n2' was broken.
5725 introduced); 'hist n1 n2' was broken.
5719 (Magic.magic_pdb): added optional on/off arguments to @pdb
5726 (Magic.magic_pdb): added optional on/off arguments to @pdb
5720 (Magic.magic_run): added option -i to @run, which executes code in
5727 (Magic.magic_run): added option -i to @run, which executes code in
5721 the IPython namespace instead of a clean one. Also added @irun as
5728 the IPython namespace instead of a clean one. Also added @irun as
5722 an alias to @run -i.
5729 an alias to @run -i.
5723
5730
5724 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5731 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5725 fixed (it didn't really do anything, the namespaces were wrong).
5732 fixed (it didn't really do anything, the namespaces were wrong).
5726
5733
5727 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5734 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5728
5735
5729 * IPython/__init__.py (__all__): Fixed package namespace, now
5736 * IPython/__init__.py (__all__): Fixed package namespace, now
5730 'import IPython' does give access to IPython.<all> as
5737 'import IPython' does give access to IPython.<all> as
5731 expected. Also renamed __release__ to Release.
5738 expected. Also renamed __release__ to Release.
5732
5739
5733 * IPython/Debugger.py (__license__): created new Pdb class which
5740 * IPython/Debugger.py (__license__): created new Pdb class which
5734 functions like a drop-in for the normal pdb.Pdb but does NOT
5741 functions like a drop-in for the normal pdb.Pdb but does NOT
5735 import readline by default. This way it doesn't muck up IPython's
5742 import readline by default. This way it doesn't muck up IPython's
5736 readline handling, and now tab-completion finally works in the
5743 readline handling, and now tab-completion finally works in the
5737 debugger -- sort of. It completes things globally visible, but the
5744 debugger -- sort of. It completes things globally visible, but the
5738 completer doesn't track the stack as pdb walks it. That's a bit
5745 completer doesn't track the stack as pdb walks it. That's a bit
5739 tricky, and I'll have to implement it later.
5746 tricky, and I'll have to implement it later.
5740
5747
5741 2002-05-05 Fernando Perez <fperez@colorado.edu>
5748 2002-05-05 Fernando Perez <fperez@colorado.edu>
5742
5749
5743 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5750 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5744 magic docstrings when printed via ? (explicit \'s were being
5751 magic docstrings when printed via ? (explicit \'s were being
5745 printed).
5752 printed).
5746
5753
5747 * IPython/ipmaker.py (make_IPython): fixed namespace
5754 * IPython/ipmaker.py (make_IPython): fixed namespace
5748 identification bug. Now variables loaded via logs or command-line
5755 identification bug. Now variables loaded via logs or command-line
5749 files are recognized in the interactive namespace by @who.
5756 files are recognized in the interactive namespace by @who.
5750
5757
5751 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5758 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5752 log replay system stemming from the string form of Structs.
5759 log replay system stemming from the string form of Structs.
5753
5760
5754 * IPython/Magic.py (Macro.__init__): improved macros to properly
5761 * IPython/Magic.py (Macro.__init__): improved macros to properly
5755 handle magic commands in them.
5762 handle magic commands in them.
5756 (Magic.magic_logstart): usernames are now expanded so 'logstart
5763 (Magic.magic_logstart): usernames are now expanded so 'logstart
5757 ~/mylog' now works.
5764 ~/mylog' now works.
5758
5765
5759 * IPython/iplib.py (complete): fixed bug where paths starting with
5766 * IPython/iplib.py (complete): fixed bug where paths starting with
5760 '/' would be completed as magic names.
5767 '/' would be completed as magic names.
5761
5768
5762 2002-05-04 Fernando Perez <fperez@colorado.edu>
5769 2002-05-04 Fernando Perez <fperez@colorado.edu>
5763
5770
5764 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5771 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5765 allow running full programs under the profiler's control.
5772 allow running full programs under the profiler's control.
5766
5773
5767 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5774 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5768 mode to report exceptions verbosely but without formatting
5775 mode to report exceptions verbosely but without formatting
5769 variables. This addresses the issue of ipython 'freezing' (it's
5776 variables. This addresses the issue of ipython 'freezing' (it's
5770 not frozen, but caught in an expensive formatting loop) when huge
5777 not frozen, but caught in an expensive formatting loop) when huge
5771 variables are in the context of an exception.
5778 variables are in the context of an exception.
5772 (VerboseTB.text): Added '--->' markers at line where exception was
5779 (VerboseTB.text): Added '--->' markers at line where exception was
5773 triggered. Much clearer to read, especially in NoColor modes.
5780 triggered. Much clearer to read, especially in NoColor modes.
5774
5781
5775 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5782 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5776 implemented in reverse when changing to the new parse_options().
5783 implemented in reverse when changing to the new parse_options().
5777
5784
5778 2002-05-03 Fernando Perez <fperez@colorado.edu>
5785 2002-05-03 Fernando Perez <fperez@colorado.edu>
5779
5786
5780 * IPython/Magic.py (Magic.parse_options): new function so that
5787 * IPython/Magic.py (Magic.parse_options): new function so that
5781 magics can parse options easier.
5788 magics can parse options easier.
5782 (Magic.magic_prun): new function similar to profile.run(),
5789 (Magic.magic_prun): new function similar to profile.run(),
5783 suggested by Chris Hart.
5790 suggested by Chris Hart.
5784 (Magic.magic_cd): fixed behavior so that it only changes if
5791 (Magic.magic_cd): fixed behavior so that it only changes if
5785 directory actually is in history.
5792 directory actually is in history.
5786
5793
5787 * IPython/usage.py (__doc__): added information about potential
5794 * IPython/usage.py (__doc__): added information about potential
5788 slowness of Verbose exception mode when there are huge data
5795 slowness of Verbose exception mode when there are huge data
5789 structures to be formatted (thanks to Archie Paulson).
5796 structures to be formatted (thanks to Archie Paulson).
5790
5797
5791 * IPython/ipmaker.py (make_IPython): Changed default logging
5798 * IPython/ipmaker.py (make_IPython): Changed default logging
5792 (when simply called with -log) to use curr_dir/ipython.log in
5799 (when simply called with -log) to use curr_dir/ipython.log in
5793 rotate mode. Fixed crash which was occuring with -log before
5800 rotate mode. Fixed crash which was occuring with -log before
5794 (thanks to Jim Boyle).
5801 (thanks to Jim Boyle).
5795
5802
5796 2002-05-01 Fernando Perez <fperez@colorado.edu>
5803 2002-05-01 Fernando Perez <fperez@colorado.edu>
5797
5804
5798 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5805 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5799 was nasty -- though somewhat of a corner case).
5806 was nasty -- though somewhat of a corner case).
5800
5807
5801 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5808 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5802 text (was a bug).
5809 text (was a bug).
5803
5810
5804 2002-04-30 Fernando Perez <fperez@colorado.edu>
5811 2002-04-30 Fernando Perez <fperez@colorado.edu>
5805
5812
5806 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5813 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5807 a print after ^D or ^C from the user so that the In[] prompt
5814 a print after ^D or ^C from the user so that the In[] prompt
5808 doesn't over-run the gnuplot one.
5815 doesn't over-run the gnuplot one.
5809
5816
5810 2002-04-29 Fernando Perez <fperez@colorado.edu>
5817 2002-04-29 Fernando Perez <fperez@colorado.edu>
5811
5818
5812 * Released 0.2.10
5819 * Released 0.2.10
5813
5820
5814 * IPython/__release__.py (version): get date dynamically.
5821 * IPython/__release__.py (version): get date dynamically.
5815
5822
5816 * Misc. documentation updates thanks to Arnd's comments. Also ran
5823 * Misc. documentation updates thanks to Arnd's comments. Also ran
5817 a full spellcheck on the manual (hadn't been done in a while).
5824 a full spellcheck on the manual (hadn't been done in a while).
5818
5825
5819 2002-04-27 Fernando Perez <fperez@colorado.edu>
5826 2002-04-27 Fernando Perez <fperez@colorado.edu>
5820
5827
5821 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5828 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5822 starting a log in mid-session would reset the input history list.
5829 starting a log in mid-session would reset the input history list.
5823
5830
5824 2002-04-26 Fernando Perez <fperez@colorado.edu>
5831 2002-04-26 Fernando Perez <fperez@colorado.edu>
5825
5832
5826 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5833 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5827 all files were being included in an update. Now anything in
5834 all files were being included in an update. Now anything in
5828 UserConfig that matches [A-Za-z]*.py will go (this excludes
5835 UserConfig that matches [A-Za-z]*.py will go (this excludes
5829 __init__.py)
5836 __init__.py)
5830
5837
5831 2002-04-25 Fernando Perez <fperez@colorado.edu>
5838 2002-04-25 Fernando Perez <fperez@colorado.edu>
5832
5839
5833 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5840 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5834 to __builtins__ so that any form of embedded or imported code can
5841 to __builtins__ so that any form of embedded or imported code can
5835 test for being inside IPython.
5842 test for being inside IPython.
5836
5843
5837 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5844 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5838 changed to GnuplotMagic because it's now an importable module,
5845 changed to GnuplotMagic because it's now an importable module,
5839 this makes the name follow that of the standard Gnuplot module.
5846 this makes the name follow that of the standard Gnuplot module.
5840 GnuplotMagic can now be loaded at any time in mid-session.
5847 GnuplotMagic can now be loaded at any time in mid-session.
5841
5848
5842 2002-04-24 Fernando Perez <fperez@colorado.edu>
5849 2002-04-24 Fernando Perez <fperez@colorado.edu>
5843
5850
5844 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5851 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5845 the globals (IPython has its own namespace) and the
5852 the globals (IPython has its own namespace) and the
5846 PhysicalQuantity stuff is much better anyway.
5853 PhysicalQuantity stuff is much better anyway.
5847
5854
5848 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5855 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5849 embedding example to standard user directory for
5856 embedding example to standard user directory for
5850 distribution. Also put it in the manual.
5857 distribution. Also put it in the manual.
5851
5858
5852 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5859 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5853 instance as first argument (so it doesn't rely on some obscure
5860 instance as first argument (so it doesn't rely on some obscure
5854 hidden global).
5861 hidden global).
5855
5862
5856 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5863 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5857 delimiters. While it prevents ().TAB from working, it allows
5864 delimiters. While it prevents ().TAB from working, it allows
5858 completions in open (... expressions. This is by far a more common
5865 completions in open (... expressions. This is by far a more common
5859 case.
5866 case.
5860
5867
5861 2002-04-23 Fernando Perez <fperez@colorado.edu>
5868 2002-04-23 Fernando Perez <fperez@colorado.edu>
5862
5869
5863 * IPython/Extensions/InterpreterPasteInput.py: new
5870 * IPython/Extensions/InterpreterPasteInput.py: new
5864 syntax-processing module for pasting lines with >>> or ... at the
5871 syntax-processing module for pasting lines with >>> or ... at the
5865 start.
5872 start.
5866
5873
5867 * IPython/Extensions/PhysicalQ_Interactive.py
5874 * IPython/Extensions/PhysicalQ_Interactive.py
5868 (PhysicalQuantityInteractive.__int__): fixed to work with either
5875 (PhysicalQuantityInteractive.__int__): fixed to work with either
5869 Numeric or math.
5876 Numeric or math.
5870
5877
5871 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5878 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5872 provided profiles. Now we have:
5879 provided profiles. Now we have:
5873 -math -> math module as * and cmath with its own namespace.
5880 -math -> math module as * and cmath with its own namespace.
5874 -numeric -> Numeric as *, plus gnuplot & grace
5881 -numeric -> Numeric as *, plus gnuplot & grace
5875 -physics -> same as before
5882 -physics -> same as before
5876
5883
5877 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5884 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5878 user-defined magics wouldn't be found by @magic if they were
5885 user-defined magics wouldn't be found by @magic if they were
5879 defined as class methods. Also cleaned up the namespace search
5886 defined as class methods. Also cleaned up the namespace search
5880 logic and the string building (to use %s instead of many repeated
5887 logic and the string building (to use %s instead of many repeated
5881 string adds).
5888 string adds).
5882
5889
5883 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5890 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5884 of user-defined magics to operate with class methods (cleaner, in
5891 of user-defined magics to operate with class methods (cleaner, in
5885 line with the gnuplot code).
5892 line with the gnuplot code).
5886
5893
5887 2002-04-22 Fernando Perez <fperez@colorado.edu>
5894 2002-04-22 Fernando Perez <fperez@colorado.edu>
5888
5895
5889 * setup.py: updated dependency list so that manual is updated when
5896 * setup.py: updated dependency list so that manual is updated when
5890 all included files change.
5897 all included files change.
5891
5898
5892 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5899 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5893 the delimiter removal option (the fix is ugly right now).
5900 the delimiter removal option (the fix is ugly right now).
5894
5901
5895 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5902 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5896 all of the math profile (quicker loading, no conflict between
5903 all of the math profile (quicker loading, no conflict between
5897 g-9.8 and g-gnuplot).
5904 g-9.8 and g-gnuplot).
5898
5905
5899 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5906 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5900 name of post-mortem files to IPython_crash_report.txt.
5907 name of post-mortem files to IPython_crash_report.txt.
5901
5908
5902 * Cleanup/update of the docs. Added all the new readline info and
5909 * Cleanup/update of the docs. Added all the new readline info and
5903 formatted all lists as 'real lists'.
5910 formatted all lists as 'real lists'.
5904
5911
5905 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5912 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5906 tab-completion options, since the full readline parse_and_bind is
5913 tab-completion options, since the full readline parse_and_bind is
5907 now accessible.
5914 now accessible.
5908
5915
5909 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5916 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5910 handling of readline options. Now users can specify any string to
5917 handling of readline options. Now users can specify any string to
5911 be passed to parse_and_bind(), as well as the delimiters to be
5918 be passed to parse_and_bind(), as well as the delimiters to be
5912 removed.
5919 removed.
5913 (InteractiveShell.__init__): Added __name__ to the global
5920 (InteractiveShell.__init__): Added __name__ to the global
5914 namespace so that things like Itpl which rely on its existence
5921 namespace so that things like Itpl which rely on its existence
5915 don't crash.
5922 don't crash.
5916 (InteractiveShell._prefilter): Defined the default with a _ so
5923 (InteractiveShell._prefilter): Defined the default with a _ so
5917 that prefilter() is easier to override, while the default one
5924 that prefilter() is easier to override, while the default one
5918 remains available.
5925 remains available.
5919
5926
5920 2002-04-18 Fernando Perez <fperez@colorado.edu>
5927 2002-04-18 Fernando Perez <fperez@colorado.edu>
5921
5928
5922 * Added information about pdb in the docs.
5929 * Added information about pdb in the docs.
5923
5930
5924 2002-04-17 Fernando Perez <fperez@colorado.edu>
5931 2002-04-17 Fernando Perez <fperez@colorado.edu>
5925
5932
5926 * IPython/ipmaker.py (make_IPython): added rc_override option to
5933 * IPython/ipmaker.py (make_IPython): added rc_override option to
5927 allow passing config options at creation time which may override
5934 allow passing config options at creation time which may override
5928 anything set in the config files or command line. This is
5935 anything set in the config files or command line. This is
5929 particularly useful for configuring embedded instances.
5936 particularly useful for configuring embedded instances.
5930
5937
5931 2002-04-15 Fernando Perez <fperez@colorado.edu>
5938 2002-04-15 Fernando Perez <fperez@colorado.edu>
5932
5939
5933 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5940 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5934 crash embedded instances because of the input cache falling out of
5941 crash embedded instances because of the input cache falling out of
5935 sync with the output counter.
5942 sync with the output counter.
5936
5943
5937 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5944 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5938 mode which calls pdb after an uncaught exception in IPython itself.
5945 mode which calls pdb after an uncaught exception in IPython itself.
5939
5946
5940 2002-04-14 Fernando Perez <fperez@colorado.edu>
5947 2002-04-14 Fernando Perez <fperez@colorado.edu>
5941
5948
5942 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5949 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5943 readline, fix it back after each call.
5950 readline, fix it back after each call.
5944
5951
5945 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5952 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5946 method to force all access via __call__(), which guarantees that
5953 method to force all access via __call__(), which guarantees that
5947 traceback references are properly deleted.
5954 traceback references are properly deleted.
5948
5955
5949 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5956 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5950 improve printing when pprint is in use.
5957 improve printing when pprint is in use.
5951
5958
5952 2002-04-13 Fernando Perez <fperez@colorado.edu>
5959 2002-04-13 Fernando Perez <fperez@colorado.edu>
5953
5960
5954 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5961 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5955 exceptions aren't caught anymore. If the user triggers one, he
5962 exceptions aren't caught anymore. If the user triggers one, he
5956 should know why he's doing it and it should go all the way up,
5963 should know why he's doing it and it should go all the way up,
5957 just like any other exception. So now @abort will fully kill the
5964 just like any other exception. So now @abort will fully kill the
5958 embedded interpreter and the embedding code (unless that happens
5965 embedded interpreter and the embedding code (unless that happens
5959 to catch SystemExit).
5966 to catch SystemExit).
5960
5967
5961 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5968 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5962 and a debugger() method to invoke the interactive pdb debugger
5969 and a debugger() method to invoke the interactive pdb debugger
5963 after printing exception information. Also added the corresponding
5970 after printing exception information. Also added the corresponding
5964 -pdb option and @pdb magic to control this feature, and updated
5971 -pdb option and @pdb magic to control this feature, and updated
5965 the docs. After a suggestion from Christopher Hart
5972 the docs. After a suggestion from Christopher Hart
5966 (hart-AT-caltech.edu).
5973 (hart-AT-caltech.edu).
5967
5974
5968 2002-04-12 Fernando Perez <fperez@colorado.edu>
5975 2002-04-12 Fernando Perez <fperez@colorado.edu>
5969
5976
5970 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5977 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5971 the exception handlers defined by the user (not the CrashHandler)
5978 the exception handlers defined by the user (not the CrashHandler)
5972 so that user exceptions don't trigger an ipython bug report.
5979 so that user exceptions don't trigger an ipython bug report.
5973
5980
5974 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5981 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5975 configurable (it should have always been so).
5982 configurable (it should have always been so).
5976
5983
5977 2002-03-26 Fernando Perez <fperez@colorado.edu>
5984 2002-03-26 Fernando Perez <fperez@colorado.edu>
5978
5985
5979 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5986 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5980 and there to fix embedding namespace issues. This should all be
5987 and there to fix embedding namespace issues. This should all be
5981 done in a more elegant way.
5988 done in a more elegant way.
5982
5989
5983 2002-03-25 Fernando Perez <fperez@colorado.edu>
5990 2002-03-25 Fernando Perez <fperez@colorado.edu>
5984
5991
5985 * IPython/genutils.py (get_home_dir): Try to make it work under
5992 * IPython/genutils.py (get_home_dir): Try to make it work under
5986 win9x also.
5993 win9x also.
5987
5994
5988 2002-03-20 Fernando Perez <fperez@colorado.edu>
5995 2002-03-20 Fernando Perez <fperez@colorado.edu>
5989
5996
5990 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5997 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5991 sys.displayhook untouched upon __init__.
5998 sys.displayhook untouched upon __init__.
5992
5999
5993 2002-03-19 Fernando Perez <fperez@colorado.edu>
6000 2002-03-19 Fernando Perez <fperez@colorado.edu>
5994
6001
5995 * Released 0.2.9 (for embedding bug, basically).
6002 * Released 0.2.9 (for embedding bug, basically).
5996
6003
5997 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
6004 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5998 exceptions so that enclosing shell's state can be restored.
6005 exceptions so that enclosing shell's state can be restored.
5999
6006
6000 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
6007 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
6001 naming conventions in the .ipython/ dir.
6008 naming conventions in the .ipython/ dir.
6002
6009
6003 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
6010 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
6004 from delimiters list so filenames with - in them get expanded.
6011 from delimiters list so filenames with - in them get expanded.
6005
6012
6006 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
6013 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
6007 sys.displayhook not being properly restored after an embedded call.
6014 sys.displayhook not being properly restored after an embedded call.
6008
6015
6009 2002-03-18 Fernando Perez <fperez@colorado.edu>
6016 2002-03-18 Fernando Perez <fperez@colorado.edu>
6010
6017
6011 * Released 0.2.8
6018 * Released 0.2.8
6012
6019
6013 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
6020 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
6014 some files weren't being included in a -upgrade.
6021 some files weren't being included in a -upgrade.
6015 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
6022 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
6016 on' so that the first tab completes.
6023 on' so that the first tab completes.
6017 (InteractiveShell.handle_magic): fixed bug with spaces around
6024 (InteractiveShell.handle_magic): fixed bug with spaces around
6018 quotes breaking many magic commands.
6025 quotes breaking many magic commands.
6019
6026
6020 * setup.py: added note about ignoring the syntax error messages at
6027 * setup.py: added note about ignoring the syntax error messages at
6021 installation.
6028 installation.
6022
6029
6023 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
6030 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
6024 streamlining the gnuplot interface, now there's only one magic @gp.
6031 streamlining the gnuplot interface, now there's only one magic @gp.
6025
6032
6026 2002-03-17 Fernando Perez <fperez@colorado.edu>
6033 2002-03-17 Fernando Perez <fperez@colorado.edu>
6027
6034
6028 * IPython/UserConfig/magic_gnuplot.py: new name for the
6035 * IPython/UserConfig/magic_gnuplot.py: new name for the
6029 example-magic_pm.py file. Much enhanced system, now with a shell
6036 example-magic_pm.py file. Much enhanced system, now with a shell
6030 for communicating directly with gnuplot, one command at a time.
6037 for communicating directly with gnuplot, one command at a time.
6031
6038
6032 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
6039 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
6033 setting __name__=='__main__'.
6040 setting __name__=='__main__'.
6034
6041
6035 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
6042 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
6036 mini-shell for accessing gnuplot from inside ipython. Should
6043 mini-shell for accessing gnuplot from inside ipython. Should
6037 extend it later for grace access too. Inspired by Arnd's
6044 extend it later for grace access too. Inspired by Arnd's
6038 suggestion.
6045 suggestion.
6039
6046
6040 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
6047 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
6041 calling magic functions with () in their arguments. Thanks to Arnd
6048 calling magic functions with () in their arguments. Thanks to Arnd
6042 Baecker for pointing this to me.
6049 Baecker for pointing this to me.
6043
6050
6044 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
6051 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
6045 infinitely for integer or complex arrays (only worked with floats).
6052 infinitely for integer or complex arrays (only worked with floats).
6046
6053
6047 2002-03-16 Fernando Perez <fperez@colorado.edu>
6054 2002-03-16 Fernando Perez <fperez@colorado.edu>
6048
6055
6049 * setup.py: Merged setup and setup_windows into a single script
6056 * setup.py: Merged setup and setup_windows into a single script
6050 which properly handles things for windows users.
6057 which properly handles things for windows users.
6051
6058
6052 2002-03-15 Fernando Perez <fperez@colorado.edu>
6059 2002-03-15 Fernando Perez <fperez@colorado.edu>
6053
6060
6054 * Big change to the manual: now the magics are all automatically
6061 * Big change to the manual: now the magics are all automatically
6055 documented. This information is generated from their docstrings
6062 documented. This information is generated from their docstrings
6056 and put in a latex file included by the manual lyx file. This way
6063 and put in a latex file included by the manual lyx file. This way
6057 we get always up to date information for the magics. The manual
6064 we get always up to date information for the magics. The manual
6058 now also has proper version information, also auto-synced.
6065 now also has proper version information, also auto-synced.
6059
6066
6060 For this to work, an undocumented --magic_docstrings option was added.
6067 For this to work, an undocumented --magic_docstrings option was added.
6061
6068
6062 2002-03-13 Fernando Perez <fperez@colorado.edu>
6069 2002-03-13 Fernando Perez <fperez@colorado.edu>
6063
6070
6064 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
6071 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
6065 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
6072 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
6066
6073
6067 2002-03-12 Fernando Perez <fperez@colorado.edu>
6074 2002-03-12 Fernando Perez <fperez@colorado.edu>
6068
6075
6069 * IPython/ultraTB.py (TermColors): changed color escapes again to
6076 * IPython/ultraTB.py (TermColors): changed color escapes again to
6070 fix the (old, reintroduced) line-wrapping bug. Basically, if
6077 fix the (old, reintroduced) line-wrapping bug. Basically, if
6071 \001..\002 aren't given in the color escapes, lines get wrapped
6078 \001..\002 aren't given in the color escapes, lines get wrapped
6072 weirdly. But giving those screws up old xterms and emacs terms. So
6079 weirdly. But giving those screws up old xterms and emacs terms. So
6073 I added some logic for emacs terms to be ok, but I can't identify old
6080 I added some logic for emacs terms to be ok, but I can't identify old
6074 xterms separately ($TERM=='xterm' for many terminals, like konsole).
6081 xterms separately ($TERM=='xterm' for many terminals, like konsole).
6075
6082
6076 2002-03-10 Fernando Perez <fperez@colorado.edu>
6083 2002-03-10 Fernando Perez <fperez@colorado.edu>
6077
6084
6078 * IPython/usage.py (__doc__): Various documentation cleanups and
6085 * IPython/usage.py (__doc__): Various documentation cleanups and
6079 updates, both in usage docstrings and in the manual.
6086 updates, both in usage docstrings and in the manual.
6080
6087
6081 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
6088 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
6082 handling of caching. Set minimum acceptabe value for having a
6089 handling of caching. Set minimum acceptabe value for having a
6083 cache at 20 values.
6090 cache at 20 values.
6084
6091
6085 * IPython/iplib.py (InteractiveShell.user_setup): moved the
6092 * IPython/iplib.py (InteractiveShell.user_setup): moved the
6086 install_first_time function to a method, renamed it and added an
6093 install_first_time function to a method, renamed it and added an
6087 'upgrade' mode. Now people can update their config directory with
6094 'upgrade' mode. Now people can update their config directory with
6088 a simple command line switch (-upgrade, also new).
6095 a simple command line switch (-upgrade, also new).
6089
6096
6090 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
6097 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
6091 @file (convenient for automagic users under Python >= 2.2).
6098 @file (convenient for automagic users under Python >= 2.2).
6092 Removed @files (it seemed more like a plural than an abbrev. of
6099 Removed @files (it seemed more like a plural than an abbrev. of
6093 'file show').
6100 'file show').
6094
6101
6095 * IPython/iplib.py (install_first_time): Fixed crash if there were
6102 * IPython/iplib.py (install_first_time): Fixed crash if there were
6096 backup files ('~') in .ipython/ install directory.
6103 backup files ('~') in .ipython/ install directory.
6097
6104
6098 * IPython/ipmaker.py (make_IPython): fixes for new prompt
6105 * IPython/ipmaker.py (make_IPython): fixes for new prompt
6099 system. Things look fine, but these changes are fairly
6106 system. Things look fine, but these changes are fairly
6100 intrusive. Test them for a few days.
6107 intrusive. Test them for a few days.
6101
6108
6102 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
6109 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
6103 the prompts system. Now all in/out prompt strings are user
6110 the prompts system. Now all in/out prompt strings are user
6104 controllable. This is particularly useful for embedding, as one
6111 controllable. This is particularly useful for embedding, as one
6105 can tag embedded instances with particular prompts.
6112 can tag embedded instances with particular prompts.
6106
6113
6107 Also removed global use of sys.ps1/2, which now allows nested
6114 Also removed global use of sys.ps1/2, which now allows nested
6108 embeddings without any problems. Added command-line options for
6115 embeddings without any problems. Added command-line options for
6109 the prompt strings.
6116 the prompt strings.
6110
6117
6111 2002-03-08 Fernando Perez <fperez@colorado.edu>
6118 2002-03-08 Fernando Perez <fperez@colorado.edu>
6112
6119
6113 * IPython/UserConfig/example-embed-short.py (ipshell): added
6120 * IPython/UserConfig/example-embed-short.py (ipshell): added
6114 example file with the bare minimum code for embedding.
6121 example file with the bare minimum code for embedding.
6115
6122
6116 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
6123 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
6117 functionality for the embeddable shell to be activated/deactivated
6124 functionality for the embeddable shell to be activated/deactivated
6118 either globally or at each call.
6125 either globally or at each call.
6119
6126
6120 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
6127 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
6121 rewriting the prompt with '--->' for auto-inputs with proper
6128 rewriting the prompt with '--->' for auto-inputs with proper
6122 coloring. Now the previous UGLY hack in handle_auto() is gone, and
6129 coloring. Now the previous UGLY hack in handle_auto() is gone, and
6123 this is handled by the prompts class itself, as it should.
6130 this is handled by the prompts class itself, as it should.
6124
6131
6125 2002-03-05 Fernando Perez <fperez@colorado.edu>
6132 2002-03-05 Fernando Perez <fperez@colorado.edu>
6126
6133
6127 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
6134 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
6128 @logstart to avoid name clashes with the math log function.
6135 @logstart to avoid name clashes with the math log function.
6129
6136
6130 * Big updates to X/Emacs section of the manual.
6137 * Big updates to X/Emacs section of the manual.
6131
6138
6132 * Removed ipython_emacs. Milan explained to me how to pass
6139 * Removed ipython_emacs. Milan explained to me how to pass
6133 arguments to ipython through Emacs. Some day I'm going to end up
6140 arguments to ipython through Emacs. Some day I'm going to end up
6134 learning some lisp...
6141 learning some lisp...
6135
6142
6136 2002-03-04 Fernando Perez <fperez@colorado.edu>
6143 2002-03-04 Fernando Perez <fperez@colorado.edu>
6137
6144
6138 * IPython/ipython_emacs: Created script to be used as the
6145 * IPython/ipython_emacs: Created script to be used as the
6139 py-python-command Emacs variable so we can pass IPython
6146 py-python-command Emacs variable so we can pass IPython
6140 parameters. I can't figure out how to tell Emacs directly to pass
6147 parameters. I can't figure out how to tell Emacs directly to pass
6141 parameters to IPython, so a dummy shell script will do it.
6148 parameters to IPython, so a dummy shell script will do it.
6142
6149
6143 Other enhancements made for things to work better under Emacs'
6150 Other enhancements made for things to work better under Emacs'
6144 various types of terminals. Many thanks to Milan Zamazal
6151 various types of terminals. Many thanks to Milan Zamazal
6145 <pdm-AT-zamazal.org> for all the suggestions and pointers.
6152 <pdm-AT-zamazal.org> for all the suggestions and pointers.
6146
6153
6147 2002-03-01 Fernando Perez <fperez@colorado.edu>
6154 2002-03-01 Fernando Perez <fperez@colorado.edu>
6148
6155
6149 * IPython/ipmaker.py (make_IPython): added a --readline! option so
6156 * IPython/ipmaker.py (make_IPython): added a --readline! option so
6150 that loading of readline is now optional. This gives better
6157 that loading of readline is now optional. This gives better
6151 control to emacs users.
6158 control to emacs users.
6152
6159
6153 * IPython/ultraTB.py (__date__): Modified color escape sequences
6160 * IPython/ultraTB.py (__date__): Modified color escape sequences
6154 and now things work fine under xterm and in Emacs' term buffers
6161 and now things work fine under xterm and in Emacs' term buffers
6155 (though not shell ones). Well, in emacs you get colors, but all
6162 (though not shell ones). Well, in emacs you get colors, but all
6156 seem to be 'light' colors (no difference between dark and light
6163 seem to be 'light' colors (no difference between dark and light
6157 ones). But the garbage chars are gone, and also in xterms. It
6164 ones). But the garbage chars are gone, and also in xterms. It
6158 seems that now I'm using 'cleaner' ansi sequences.
6165 seems that now I'm using 'cleaner' ansi sequences.
6159
6166
6160 2002-02-21 Fernando Perez <fperez@colorado.edu>
6167 2002-02-21 Fernando Perez <fperez@colorado.edu>
6161
6168
6162 * Released 0.2.7 (mainly to publish the scoping fix).
6169 * Released 0.2.7 (mainly to publish the scoping fix).
6163
6170
6164 * IPython/Logger.py (Logger.logstate): added. A corresponding
6171 * IPython/Logger.py (Logger.logstate): added. A corresponding
6165 @logstate magic was created.
6172 @logstate magic was created.
6166
6173
6167 * IPython/Magic.py: fixed nested scoping problem under Python
6174 * IPython/Magic.py: fixed nested scoping problem under Python
6168 2.1.x (automagic wasn't working).
6175 2.1.x (automagic wasn't working).
6169
6176
6170 2002-02-20 Fernando Perez <fperez@colorado.edu>
6177 2002-02-20 Fernando Perez <fperez@colorado.edu>
6171
6178
6172 * Released 0.2.6.
6179 * Released 0.2.6.
6173
6180
6174 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
6181 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
6175 option so that logs can come out without any headers at all.
6182 option so that logs can come out without any headers at all.
6176
6183
6177 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
6184 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
6178 SciPy.
6185 SciPy.
6179
6186
6180 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
6187 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
6181 that embedded IPython calls don't require vars() to be explicitly
6188 that embedded IPython calls don't require vars() to be explicitly
6182 passed. Now they are extracted from the caller's frame (code
6189 passed. Now they are extracted from the caller's frame (code
6183 snatched from Eric Jones' weave). Added better documentation to
6190 snatched from Eric Jones' weave). Added better documentation to
6184 the section on embedding and the example file.
6191 the section on embedding and the example file.
6185
6192
6186 * IPython/genutils.py (page): Changed so that under emacs, it just
6193 * IPython/genutils.py (page): Changed so that under emacs, it just
6187 prints the string. You can then page up and down in the emacs
6194 prints the string. You can then page up and down in the emacs
6188 buffer itself. This is how the builtin help() works.
6195 buffer itself. This is how the builtin help() works.
6189
6196
6190 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
6197 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
6191 macro scoping: macros need to be executed in the user's namespace
6198 macro scoping: macros need to be executed in the user's namespace
6192 to work as if they had been typed by the user.
6199 to work as if they had been typed by the user.
6193
6200
6194 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
6201 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
6195 execute automatically (no need to type 'exec...'). They then
6202 execute automatically (no need to type 'exec...'). They then
6196 behave like 'true macros'. The printing system was also modified
6203 behave like 'true macros'. The printing system was also modified
6197 for this to work.
6204 for this to work.
6198
6205
6199 2002-02-19 Fernando Perez <fperez@colorado.edu>
6206 2002-02-19 Fernando Perez <fperez@colorado.edu>
6200
6207
6201 * IPython/genutils.py (page_file): new function for paging files
6208 * IPython/genutils.py (page_file): new function for paging files
6202 in an OS-independent way. Also necessary for file viewing to work
6209 in an OS-independent way. Also necessary for file viewing to work
6203 well inside Emacs buffers.
6210 well inside Emacs buffers.
6204 (page): Added checks for being in an emacs buffer.
6211 (page): Added checks for being in an emacs buffer.
6205 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
6212 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
6206 same bug in iplib.
6213 same bug in iplib.
6207
6214
6208 2002-02-18 Fernando Perez <fperez@colorado.edu>
6215 2002-02-18 Fernando Perez <fperez@colorado.edu>
6209
6216
6210 * IPython/iplib.py (InteractiveShell.init_readline): modified use
6217 * IPython/iplib.py (InteractiveShell.init_readline): modified use
6211 of readline so that IPython can work inside an Emacs buffer.
6218 of readline so that IPython can work inside an Emacs buffer.
6212
6219
6213 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
6220 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
6214 method signatures (they weren't really bugs, but it looks cleaner
6221 method signatures (they weren't really bugs, but it looks cleaner
6215 and keeps PyChecker happy).
6222 and keeps PyChecker happy).
6216
6223
6217 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
6224 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
6218 for implementing various user-defined hooks. Currently only
6225 for implementing various user-defined hooks. Currently only
6219 display is done.
6226 display is done.
6220
6227
6221 * IPython/Prompts.py (CachedOutput._display): changed display
6228 * IPython/Prompts.py (CachedOutput._display): changed display
6222 functions so that they can be dynamically changed by users easily.
6229 functions so that they can be dynamically changed by users easily.
6223
6230
6224 * IPython/Extensions/numeric_formats.py (num_display): added an
6231 * IPython/Extensions/numeric_formats.py (num_display): added an
6225 extension for printing NumPy arrays in flexible manners. It
6232 extension for printing NumPy arrays in flexible manners. It
6226 doesn't do anything yet, but all the structure is in
6233 doesn't do anything yet, but all the structure is in
6227 place. Ultimately the plan is to implement output format control
6234 place. Ultimately the plan is to implement output format control
6228 like in Octave.
6235 like in Octave.
6229
6236
6230 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
6237 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
6231 methods are found at run-time by all the automatic machinery.
6238 methods are found at run-time by all the automatic machinery.
6232
6239
6233 2002-02-17 Fernando Perez <fperez@colorado.edu>
6240 2002-02-17 Fernando Perez <fperez@colorado.edu>
6234
6241
6235 * setup_Windows.py (make_shortcut): documented. Cleaned up the
6242 * setup_Windows.py (make_shortcut): documented. Cleaned up the
6236 whole file a little.
6243 whole file a little.
6237
6244
6238 * ToDo: closed this document. Now there's a new_design.lyx
6245 * ToDo: closed this document. Now there's a new_design.lyx
6239 document for all new ideas. Added making a pdf of it for the
6246 document for all new ideas. Added making a pdf of it for the
6240 end-user distro.
6247 end-user distro.
6241
6248
6242 * IPython/Logger.py (Logger.switch_log): Created this to replace
6249 * IPython/Logger.py (Logger.switch_log): Created this to replace
6243 logon() and logoff(). It also fixes a nasty crash reported by
6250 logon() and logoff(). It also fixes a nasty crash reported by
6244 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
6251 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
6245
6252
6246 * IPython/iplib.py (complete): got auto-completion to work with
6253 * IPython/iplib.py (complete): got auto-completion to work with
6247 automagic (I had wanted this for a long time).
6254 automagic (I had wanted this for a long time).
6248
6255
6249 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
6256 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
6250 to @file, since file() is now a builtin and clashes with automagic
6257 to @file, since file() is now a builtin and clashes with automagic
6251 for @file.
6258 for @file.
6252
6259
6253 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
6260 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
6254 of this was previously in iplib, which had grown to more than 2000
6261 of this was previously in iplib, which had grown to more than 2000
6255 lines, way too long. No new functionality, but it makes managing
6262 lines, way too long. No new functionality, but it makes managing
6256 the code a bit easier.
6263 the code a bit easier.
6257
6264
6258 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
6265 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
6259 information to crash reports.
6266 information to crash reports.
6260
6267
6261 2002-02-12 Fernando Perez <fperez@colorado.edu>
6268 2002-02-12 Fernando Perez <fperez@colorado.edu>
6262
6269
6263 * Released 0.2.5.
6270 * Released 0.2.5.
6264
6271
6265 2002-02-11 Fernando Perez <fperez@colorado.edu>
6272 2002-02-11 Fernando Perez <fperez@colorado.edu>
6266
6273
6267 * Wrote a relatively complete Windows installer. It puts
6274 * Wrote a relatively complete Windows installer. It puts
6268 everything in place, creates Start Menu entries and fixes the
6275 everything in place, creates Start Menu entries and fixes the
6269 color issues. Nothing fancy, but it works.
6276 color issues. Nothing fancy, but it works.
6270
6277
6271 2002-02-10 Fernando Perez <fperez@colorado.edu>
6278 2002-02-10 Fernando Perez <fperez@colorado.edu>
6272
6279
6273 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
6280 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
6274 os.path.expanduser() call so that we can type @run ~/myfile.py and
6281 os.path.expanduser() call so that we can type @run ~/myfile.py and
6275 have thigs work as expected.
6282 have thigs work as expected.
6276
6283
6277 * IPython/genutils.py (page): fixed exception handling so things
6284 * IPython/genutils.py (page): fixed exception handling so things
6278 work both in Unix and Windows correctly. Quitting a pager triggers
6285 work both in Unix and Windows correctly. Quitting a pager triggers
6279 an IOError/broken pipe in Unix, and in windows not finding a pager
6286 an IOError/broken pipe in Unix, and in windows not finding a pager
6280 is also an IOError, so I had to actually look at the return value
6287 is also an IOError, so I had to actually look at the return value
6281 of the exception, not just the exception itself. Should be ok now.
6288 of the exception, not just the exception itself. Should be ok now.
6282
6289
6283 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
6290 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
6284 modified to allow case-insensitive color scheme changes.
6291 modified to allow case-insensitive color scheme changes.
6285
6292
6286 2002-02-09 Fernando Perez <fperez@colorado.edu>
6293 2002-02-09 Fernando Perez <fperez@colorado.edu>
6287
6294
6288 * IPython/genutils.py (native_line_ends): new function to leave
6295 * IPython/genutils.py (native_line_ends): new function to leave
6289 user config files with os-native line-endings.
6296 user config files with os-native line-endings.
6290
6297
6291 * README and manual updates.
6298 * README and manual updates.
6292
6299
6293 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
6300 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
6294 instead of StringType to catch Unicode strings.
6301 instead of StringType to catch Unicode strings.
6295
6302
6296 * IPython/genutils.py (filefind): fixed bug for paths with
6303 * IPython/genutils.py (filefind): fixed bug for paths with
6297 embedded spaces (very common in Windows).
6304 embedded spaces (very common in Windows).
6298
6305
6299 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
6306 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
6300 files under Windows, so that they get automatically associated
6307 files under Windows, so that they get automatically associated
6301 with a text editor. Windows makes it a pain to handle
6308 with a text editor. Windows makes it a pain to handle
6302 extension-less files.
6309 extension-less files.
6303
6310
6304 * IPython/iplib.py (InteractiveShell.init_readline): Made the
6311 * IPython/iplib.py (InteractiveShell.init_readline): Made the
6305 warning about readline only occur for Posix. In Windows there's no
6312 warning about readline only occur for Posix. In Windows there's no
6306 way to get readline, so why bother with the warning.
6313 way to get readline, so why bother with the warning.
6307
6314
6308 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
6315 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
6309 for __str__ instead of dir(self), since dir() changed in 2.2.
6316 for __str__ instead of dir(self), since dir() changed in 2.2.
6310
6317
6311 * Ported to Windows! Tested on XP, I suspect it should work fine
6318 * Ported to Windows! Tested on XP, I suspect it should work fine
6312 on NT/2000, but I don't think it will work on 98 et al. That
6319 on NT/2000, but I don't think it will work on 98 et al. That
6313 series of Windows is such a piece of junk anyway that I won't try
6320 series of Windows is such a piece of junk anyway that I won't try
6314 porting it there. The XP port was straightforward, showed a few
6321 porting it there. The XP port was straightforward, showed a few
6315 bugs here and there (fixed all), in particular some string
6322 bugs here and there (fixed all), in particular some string
6316 handling stuff which required considering Unicode strings (which
6323 handling stuff which required considering Unicode strings (which
6317 Windows uses). This is good, but hasn't been too tested :) No
6324 Windows uses). This is good, but hasn't been too tested :) No
6318 fancy installer yet, I'll put a note in the manual so people at
6325 fancy installer yet, I'll put a note in the manual so people at
6319 least make manually a shortcut.
6326 least make manually a shortcut.
6320
6327
6321 * IPython/iplib.py (Magic.magic_colors): Unified the color options
6328 * IPython/iplib.py (Magic.magic_colors): Unified the color options
6322 into a single one, "colors". This now controls both prompt and
6329 into a single one, "colors". This now controls both prompt and
6323 exception color schemes, and can be changed both at startup
6330 exception color schemes, and can be changed both at startup
6324 (either via command-line switches or via ipythonrc files) and at
6331 (either via command-line switches or via ipythonrc files) and at
6325 runtime, with @colors.
6332 runtime, with @colors.
6326 (Magic.magic_run): renamed @prun to @run and removed the old
6333 (Magic.magic_run): renamed @prun to @run and removed the old
6327 @run. The two were too similar to warrant keeping both.
6334 @run. The two were too similar to warrant keeping both.
6328
6335
6329 2002-02-03 Fernando Perez <fperez@colorado.edu>
6336 2002-02-03 Fernando Perez <fperez@colorado.edu>
6330
6337
6331 * IPython/iplib.py (install_first_time): Added comment on how to
6338 * IPython/iplib.py (install_first_time): Added comment on how to
6332 configure the color options for first-time users. Put a <return>
6339 configure the color options for first-time users. Put a <return>
6333 request at the end so that small-terminal users get a chance to
6340 request at the end so that small-terminal users get a chance to
6334 read the startup info.
6341 read the startup info.
6335
6342
6336 2002-01-23 Fernando Perez <fperez@colorado.edu>
6343 2002-01-23 Fernando Perez <fperez@colorado.edu>
6337
6344
6338 * IPython/iplib.py (CachedOutput.update): Changed output memory
6345 * IPython/iplib.py (CachedOutput.update): Changed output memory
6339 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
6346 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
6340 input history we still use _i. Did this b/c these variable are
6347 input history we still use _i. Did this b/c these variable are
6341 very commonly used in interactive work, so the less we need to
6348 very commonly used in interactive work, so the less we need to
6342 type the better off we are.
6349 type the better off we are.
6343 (Magic.magic_prun): updated @prun to better handle the namespaces
6350 (Magic.magic_prun): updated @prun to better handle the namespaces
6344 the file will run in, including a fix for __name__ not being set
6351 the file will run in, including a fix for __name__ not being set
6345 before.
6352 before.
6346
6353
6347 2002-01-20 Fernando Perez <fperez@colorado.edu>
6354 2002-01-20 Fernando Perez <fperez@colorado.edu>
6348
6355
6349 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
6356 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
6350 extra garbage for Python 2.2. Need to look more carefully into
6357 extra garbage for Python 2.2. Need to look more carefully into
6351 this later.
6358 this later.
6352
6359
6353 2002-01-19 Fernando Perez <fperez@colorado.edu>
6360 2002-01-19 Fernando Perez <fperez@colorado.edu>
6354
6361
6355 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
6362 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
6356 display SyntaxError exceptions properly formatted when they occur
6363 display SyntaxError exceptions properly formatted when they occur
6357 (they can be triggered by imported code).
6364 (they can be triggered by imported code).
6358
6365
6359 2002-01-18 Fernando Perez <fperez@colorado.edu>
6366 2002-01-18 Fernando Perez <fperez@colorado.edu>
6360
6367
6361 * IPython/iplib.py (InteractiveShell.safe_execfile): now
6368 * IPython/iplib.py (InteractiveShell.safe_execfile): now
6362 SyntaxError exceptions are reported nicely formatted, instead of
6369 SyntaxError exceptions are reported nicely formatted, instead of
6363 spitting out only offset information as before.
6370 spitting out only offset information as before.
6364 (Magic.magic_prun): Added the @prun function for executing
6371 (Magic.magic_prun): Added the @prun function for executing
6365 programs with command line args inside IPython.
6372 programs with command line args inside IPython.
6366
6373
6367 2002-01-16 Fernando Perez <fperez@colorado.edu>
6374 2002-01-16 Fernando Perez <fperez@colorado.edu>
6368
6375
6369 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
6376 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
6370 to *not* include the last item given in a range. This brings their
6377 to *not* include the last item given in a range. This brings their
6371 behavior in line with Python's slicing:
6378 behavior in line with Python's slicing:
6372 a[n1:n2] -> a[n1]...a[n2-1]
6379 a[n1:n2] -> a[n1]...a[n2-1]
6373 It may be a bit less convenient, but I prefer to stick to Python's
6380 It may be a bit less convenient, but I prefer to stick to Python's
6374 conventions *everywhere*, so users never have to wonder.
6381 conventions *everywhere*, so users never have to wonder.
6375 (Magic.magic_macro): Added @macro function to ease the creation of
6382 (Magic.magic_macro): Added @macro function to ease the creation of
6376 macros.
6383 macros.
6377
6384
6378 2002-01-05 Fernando Perez <fperez@colorado.edu>
6385 2002-01-05 Fernando Perez <fperez@colorado.edu>
6379
6386
6380 * Released 0.2.4.
6387 * Released 0.2.4.
6381
6388
6382 * IPython/iplib.py (Magic.magic_pdef):
6389 * IPython/iplib.py (Magic.magic_pdef):
6383 (InteractiveShell.safe_execfile): report magic lines and error
6390 (InteractiveShell.safe_execfile): report magic lines and error
6384 lines without line numbers so one can easily copy/paste them for
6391 lines without line numbers so one can easily copy/paste them for
6385 re-execution.
6392 re-execution.
6386
6393
6387 * Updated manual with recent changes.
6394 * Updated manual with recent changes.
6388
6395
6389 * IPython/iplib.py (Magic.magic_oinfo): added constructor
6396 * IPython/iplib.py (Magic.magic_oinfo): added constructor
6390 docstring printing when class? is called. Very handy for knowing
6397 docstring printing when class? is called. Very handy for knowing
6391 how to create class instances (as long as __init__ is well
6398 how to create class instances (as long as __init__ is well
6392 documented, of course :)
6399 documented, of course :)
6393 (Magic.magic_doc): print both class and constructor docstrings.
6400 (Magic.magic_doc): print both class and constructor docstrings.
6394 (Magic.magic_pdef): give constructor info if passed a class and
6401 (Magic.magic_pdef): give constructor info if passed a class and
6395 __call__ info for callable object instances.
6402 __call__ info for callable object instances.
6396
6403
6397 2002-01-04 Fernando Perez <fperez@colorado.edu>
6404 2002-01-04 Fernando Perez <fperez@colorado.edu>
6398
6405
6399 * Made deep_reload() off by default. It doesn't always work
6406 * Made deep_reload() off by default. It doesn't always work
6400 exactly as intended, so it's probably safer to have it off. It's
6407 exactly as intended, so it's probably safer to have it off. It's
6401 still available as dreload() anyway, so nothing is lost.
6408 still available as dreload() anyway, so nothing is lost.
6402
6409
6403 2002-01-02 Fernando Perez <fperez@colorado.edu>
6410 2002-01-02 Fernando Perez <fperez@colorado.edu>
6404
6411
6405 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
6412 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
6406 so I wanted an updated release).
6413 so I wanted an updated release).
6407
6414
6408 2001-12-27 Fernando Perez <fperez@colorado.edu>
6415 2001-12-27 Fernando Perez <fperez@colorado.edu>
6409
6416
6410 * IPython/iplib.py (InteractiveShell.interact): Added the original
6417 * IPython/iplib.py (InteractiveShell.interact): Added the original
6411 code from 'code.py' for this module in order to change the
6418 code from 'code.py' for this module in order to change the
6412 handling of a KeyboardInterrupt. This was necessary b/c otherwise
6419 handling of a KeyboardInterrupt. This was necessary b/c otherwise
6413 the history cache would break when the user hit Ctrl-C, and
6420 the history cache would break when the user hit Ctrl-C, and
6414 interact() offers no way to add any hooks to it.
6421 interact() offers no way to add any hooks to it.
6415
6422
6416 2001-12-23 Fernando Perez <fperez@colorado.edu>
6423 2001-12-23 Fernando Perez <fperez@colorado.edu>
6417
6424
6418 * setup.py: added check for 'MANIFEST' before trying to remove
6425 * setup.py: added check for 'MANIFEST' before trying to remove
6419 it. Thanks to Sean Reifschneider.
6426 it. Thanks to Sean Reifschneider.
6420
6427
6421 2001-12-22 Fernando Perez <fperez@colorado.edu>
6428 2001-12-22 Fernando Perez <fperez@colorado.edu>
6422
6429
6423 * Released 0.2.2.
6430 * Released 0.2.2.
6424
6431
6425 * Finished (reasonably) writing the manual. Later will add the
6432 * Finished (reasonably) writing the manual. Later will add the
6426 python-standard navigation stylesheets, but for the time being
6433 python-standard navigation stylesheets, but for the time being
6427 it's fairly complete. Distribution will include html and pdf
6434 it's fairly complete. Distribution will include html and pdf
6428 versions.
6435 versions.
6429
6436
6430 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
6437 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
6431 (MayaVi author).
6438 (MayaVi author).
6432
6439
6433 2001-12-21 Fernando Perez <fperez@colorado.edu>
6440 2001-12-21 Fernando Perez <fperez@colorado.edu>
6434
6441
6435 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
6442 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
6436 good public release, I think (with the manual and the distutils
6443 good public release, I think (with the manual and the distutils
6437 installer). The manual can use some work, but that can go
6444 installer). The manual can use some work, but that can go
6438 slowly. Otherwise I think it's quite nice for end users. Next
6445 slowly. Otherwise I think it's quite nice for end users. Next
6439 summer, rewrite the guts of it...
6446 summer, rewrite the guts of it...
6440
6447
6441 * Changed format of ipythonrc files to use whitespace as the
6448 * Changed format of ipythonrc files to use whitespace as the
6442 separator instead of an explicit '='. Cleaner.
6449 separator instead of an explicit '='. Cleaner.
6443
6450
6444 2001-12-20 Fernando Perez <fperez@colorado.edu>
6451 2001-12-20 Fernando Perez <fperez@colorado.edu>
6445
6452
6446 * Started a manual in LyX. For now it's just a quick merge of the
6453 * Started a manual in LyX. For now it's just a quick merge of the
6447 various internal docstrings and READMEs. Later it may grow into a
6454 various internal docstrings and READMEs. Later it may grow into a
6448 nice, full-blown manual.
6455 nice, full-blown manual.
6449
6456
6450 * Set up a distutils based installer. Installation should now be
6457 * Set up a distutils based installer. Installation should now be
6451 trivially simple for end-users.
6458 trivially simple for end-users.
6452
6459
6453 2001-12-11 Fernando Perez <fperez@colorado.edu>
6460 2001-12-11 Fernando Perez <fperez@colorado.edu>
6454
6461
6455 * Released 0.2.0. First public release, announced it at
6462 * Released 0.2.0. First public release, announced it at
6456 comp.lang.python. From now on, just bugfixes...
6463 comp.lang.python. From now on, just bugfixes...
6457
6464
6458 * Went through all the files, set copyright/license notices and
6465 * Went through all the files, set copyright/license notices and
6459 cleaned up things. Ready for release.
6466 cleaned up things. Ready for release.
6460
6467
6461 2001-12-10 Fernando Perez <fperez@colorado.edu>
6468 2001-12-10 Fernando Perez <fperez@colorado.edu>
6462
6469
6463 * Changed the first-time installer not to use tarfiles. It's more
6470 * Changed the first-time installer not to use tarfiles. It's more
6464 robust now and less unix-dependent. Also makes it easier for
6471 robust now and less unix-dependent. Also makes it easier for
6465 people to later upgrade versions.
6472 people to later upgrade versions.
6466
6473
6467 * Changed @exit to @abort to reflect the fact that it's pretty
6474 * Changed @exit to @abort to reflect the fact that it's pretty
6468 brutal (a sys.exit()). The difference between @abort and Ctrl-D
6475 brutal (a sys.exit()). The difference between @abort and Ctrl-D
6469 becomes significant only when IPyhton is embedded: in that case,
6476 becomes significant only when IPyhton is embedded: in that case,
6470 C-D closes IPython only, but @abort kills the enclosing program
6477 C-D closes IPython only, but @abort kills the enclosing program
6471 too (unless it had called IPython inside a try catching
6478 too (unless it had called IPython inside a try catching
6472 SystemExit).
6479 SystemExit).
6473
6480
6474 * Created Shell module which exposes the actuall IPython Shell
6481 * Created Shell module which exposes the actuall IPython Shell
6475 classes, currently the normal and the embeddable one. This at
6482 classes, currently the normal and the embeddable one. This at
6476 least offers a stable interface we won't need to change when
6483 least offers a stable interface we won't need to change when
6477 (later) the internals are rewritten. That rewrite will be confined
6484 (later) the internals are rewritten. That rewrite will be confined
6478 to iplib and ipmaker, but the Shell interface should remain as is.
6485 to iplib and ipmaker, but the Shell interface should remain as is.
6479
6486
6480 * Added embed module which offers an embeddable IPShell object,
6487 * Added embed module which offers an embeddable IPShell object,
6481 useful to fire up IPython *inside* a running program. Great for
6488 useful to fire up IPython *inside* a running program. Great for
6482 debugging or dynamical data analysis.
6489 debugging or dynamical data analysis.
6483
6490
6484 2001-12-08 Fernando Perez <fperez@colorado.edu>
6491 2001-12-08 Fernando Perez <fperez@colorado.edu>
6485
6492
6486 * Fixed small bug preventing seeing info from methods of defined
6493 * Fixed small bug preventing seeing info from methods of defined
6487 objects (incorrect namespace in _ofind()).
6494 objects (incorrect namespace in _ofind()).
6488
6495
6489 * Documentation cleanup. Moved the main usage docstrings to a
6496 * Documentation cleanup. Moved the main usage docstrings to a
6490 separate file, usage.py (cleaner to maintain, and hopefully in the
6497 separate file, usage.py (cleaner to maintain, and hopefully in the
6491 future some perlpod-like way of producing interactive, man and
6498 future some perlpod-like way of producing interactive, man and
6492 html docs out of it will be found).
6499 html docs out of it will be found).
6493
6500
6494 * Added @profile to see your profile at any time.
6501 * Added @profile to see your profile at any time.
6495
6502
6496 * Added @p as an alias for 'print'. It's especially convenient if
6503 * Added @p as an alias for 'print'. It's especially convenient if
6497 using automagic ('p x' prints x).
6504 using automagic ('p x' prints x).
6498
6505
6499 * Small cleanups and fixes after a pychecker run.
6506 * Small cleanups and fixes after a pychecker run.
6500
6507
6501 * Changed the @cd command to handle @cd - and @cd -<n> for
6508 * Changed the @cd command to handle @cd - and @cd -<n> for
6502 visiting any directory in _dh.
6509 visiting any directory in _dh.
6503
6510
6504 * Introduced _dh, a history of visited directories. @dhist prints
6511 * Introduced _dh, a history of visited directories. @dhist prints
6505 it out with numbers.
6512 it out with numbers.
6506
6513
6507 2001-12-07 Fernando Perez <fperez@colorado.edu>
6514 2001-12-07 Fernando Perez <fperez@colorado.edu>
6508
6515
6509 * Released 0.1.22
6516 * Released 0.1.22
6510
6517
6511 * Made initialization a bit more robust against invalid color
6518 * Made initialization a bit more robust against invalid color
6512 options in user input (exit, not traceback-crash).
6519 options in user input (exit, not traceback-crash).
6513
6520
6514 * Changed the bug crash reporter to write the report only in the
6521 * Changed the bug crash reporter to write the report only in the
6515 user's .ipython directory. That way IPython won't litter people's
6522 user's .ipython directory. That way IPython won't litter people's
6516 hard disks with crash files all over the place. Also print on
6523 hard disks with crash files all over the place. Also print on
6517 screen the necessary mail command.
6524 screen the necessary mail command.
6518
6525
6519 * With the new ultraTB, implemented LightBG color scheme for light
6526 * With the new ultraTB, implemented LightBG color scheme for light
6520 background terminals. A lot of people like white backgrounds, so I
6527 background terminals. A lot of people like white backgrounds, so I
6521 guess we should at least give them something readable.
6528 guess we should at least give them something readable.
6522
6529
6523 2001-12-06 Fernando Perez <fperez@colorado.edu>
6530 2001-12-06 Fernando Perez <fperez@colorado.edu>
6524
6531
6525 * Modified the structure of ultraTB. Now there's a proper class
6532 * Modified the structure of ultraTB. Now there's a proper class
6526 for tables of color schemes which allow adding schemes easily and
6533 for tables of color schemes which allow adding schemes easily and
6527 switching the active scheme without creating a new instance every
6534 switching the active scheme without creating a new instance every
6528 time (which was ridiculous). The syntax for creating new schemes
6535 time (which was ridiculous). The syntax for creating new schemes
6529 is also cleaner. I think ultraTB is finally done, with a clean
6536 is also cleaner. I think ultraTB is finally done, with a clean
6530 class structure. Names are also much cleaner (now there's proper
6537 class structure. Names are also much cleaner (now there's proper
6531 color tables, no need for every variable to also have 'color' in
6538 color tables, no need for every variable to also have 'color' in
6532 its name).
6539 its name).
6533
6540
6534 * Broke down genutils into separate files. Now genutils only
6541 * Broke down genutils into separate files. Now genutils only
6535 contains utility functions, and classes have been moved to their
6542 contains utility functions, and classes have been moved to their
6536 own files (they had enough independent functionality to warrant
6543 own files (they had enough independent functionality to warrant
6537 it): ConfigLoader, OutputTrap, Struct.
6544 it): ConfigLoader, OutputTrap, Struct.
6538
6545
6539 2001-12-05 Fernando Perez <fperez@colorado.edu>
6546 2001-12-05 Fernando Perez <fperez@colorado.edu>
6540
6547
6541 * IPython turns 21! Released version 0.1.21, as a candidate for
6548 * IPython turns 21! Released version 0.1.21, as a candidate for
6542 public consumption. If all goes well, release in a few days.
6549 public consumption. If all goes well, release in a few days.
6543
6550
6544 * Fixed path bug (files in Extensions/ directory wouldn't be found
6551 * Fixed path bug (files in Extensions/ directory wouldn't be found
6545 unless IPython/ was explicitly in sys.path).
6552 unless IPython/ was explicitly in sys.path).
6546
6553
6547 * Extended the FlexCompleter class as MagicCompleter to allow
6554 * Extended the FlexCompleter class as MagicCompleter to allow
6548 completion of @-starting lines.
6555 completion of @-starting lines.
6549
6556
6550 * Created __release__.py file as a central repository for release
6557 * Created __release__.py file as a central repository for release
6551 info that other files can read from.
6558 info that other files can read from.
6552
6559
6553 * Fixed small bug in logging: when logging was turned on in
6560 * Fixed small bug in logging: when logging was turned on in
6554 mid-session, old lines with special meanings (!@?) were being
6561 mid-session, old lines with special meanings (!@?) were being
6555 logged without the prepended comment, which is necessary since
6562 logged without the prepended comment, which is necessary since
6556 they are not truly valid python syntax. This should make session
6563 they are not truly valid python syntax. This should make session
6557 restores produce less errors.
6564 restores produce less errors.
6558
6565
6559 * The namespace cleanup forced me to make a FlexCompleter class
6566 * The namespace cleanup forced me to make a FlexCompleter class
6560 which is nothing but a ripoff of rlcompleter, but with selectable
6567 which is nothing but a ripoff of rlcompleter, but with selectable
6561 namespace (rlcompleter only works in __main__.__dict__). I'll try
6568 namespace (rlcompleter only works in __main__.__dict__). I'll try
6562 to submit a note to the authors to see if this change can be
6569 to submit a note to the authors to see if this change can be
6563 incorporated in future rlcompleter releases (Dec.6: done)
6570 incorporated in future rlcompleter releases (Dec.6: done)
6564
6571
6565 * More fixes to namespace handling. It was a mess! Now all
6572 * More fixes to namespace handling. It was a mess! Now all
6566 explicit references to __main__.__dict__ are gone (except when
6573 explicit references to __main__.__dict__ are gone (except when
6567 really needed) and everything is handled through the namespace
6574 really needed) and everything is handled through the namespace
6568 dicts in the IPython instance. We seem to be getting somewhere
6575 dicts in the IPython instance. We seem to be getting somewhere
6569 with this, finally...
6576 with this, finally...
6570
6577
6571 * Small documentation updates.
6578 * Small documentation updates.
6572
6579
6573 * Created the Extensions directory under IPython (with an
6580 * Created the Extensions directory under IPython (with an
6574 __init__.py). Put the PhysicalQ stuff there. This directory should
6581 __init__.py). Put the PhysicalQ stuff there. This directory should
6575 be used for all special-purpose extensions.
6582 be used for all special-purpose extensions.
6576
6583
6577 * File renaming:
6584 * File renaming:
6578 ipythonlib --> ipmaker
6585 ipythonlib --> ipmaker
6579 ipplib --> iplib
6586 ipplib --> iplib
6580 This makes a bit more sense in terms of what these files actually do.
6587 This makes a bit more sense in terms of what these files actually do.
6581
6588
6582 * Moved all the classes and functions in ipythonlib to ipplib, so
6589 * Moved all the classes and functions in ipythonlib to ipplib, so
6583 now ipythonlib only has make_IPython(). This will ease up its
6590 now ipythonlib only has make_IPython(). This will ease up its
6584 splitting in smaller functional chunks later.
6591 splitting in smaller functional chunks later.
6585
6592
6586 * Cleaned up (done, I think) output of @whos. Better column
6593 * Cleaned up (done, I think) output of @whos. Better column
6587 formatting, and now shows str(var) for as much as it can, which is
6594 formatting, and now shows str(var) for as much as it can, which is
6588 typically what one gets with a 'print var'.
6595 typically what one gets with a 'print var'.
6589
6596
6590 2001-12-04 Fernando Perez <fperez@colorado.edu>
6597 2001-12-04 Fernando Perez <fperez@colorado.edu>
6591
6598
6592 * Fixed namespace problems. Now builtin/IPyhton/user names get
6599 * Fixed namespace problems. Now builtin/IPyhton/user names get
6593 properly reported in their namespace. Internal namespace handling
6600 properly reported in their namespace. Internal namespace handling
6594 is finally getting decent (not perfect yet, but much better than
6601 is finally getting decent (not perfect yet, but much better than
6595 the ad-hoc mess we had).
6602 the ad-hoc mess we had).
6596
6603
6597 * Removed -exit option. If people just want to run a python
6604 * Removed -exit option. If people just want to run a python
6598 script, that's what the normal interpreter is for. Less
6605 script, that's what the normal interpreter is for. Less
6599 unnecessary options, less chances for bugs.
6606 unnecessary options, less chances for bugs.
6600
6607
6601 * Added a crash handler which generates a complete post-mortem if
6608 * Added a crash handler which generates a complete post-mortem if
6602 IPython crashes. This will help a lot in tracking bugs down the
6609 IPython crashes. This will help a lot in tracking bugs down the
6603 road.
6610 road.
6604
6611
6605 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
6612 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
6606 which were boud to functions being reassigned would bypass the
6613 which were boud to functions being reassigned would bypass the
6607 logger, breaking the sync of _il with the prompt counter. This
6614 logger, breaking the sync of _il with the prompt counter. This
6608 would then crash IPython later when a new line was logged.
6615 would then crash IPython later when a new line was logged.
6609
6616
6610 2001-12-02 Fernando Perez <fperez@colorado.edu>
6617 2001-12-02 Fernando Perez <fperez@colorado.edu>
6611
6618
6612 * Made IPython a package. This means people don't have to clutter
6619 * Made IPython a package. This means people don't have to clutter
6613 their sys.path with yet another directory. Changed the INSTALL
6620 their sys.path with yet another directory. Changed the INSTALL
6614 file accordingly.
6621 file accordingly.
6615
6622
6616 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
6623 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
6617 sorts its output (so @who shows it sorted) and @whos formats the
6624 sorts its output (so @who shows it sorted) and @whos formats the
6618 table according to the width of the first column. Nicer, easier to
6625 table according to the width of the first column. Nicer, easier to
6619 read. Todo: write a generic table_format() which takes a list of
6626 read. Todo: write a generic table_format() which takes a list of
6620 lists and prints it nicely formatted, with optional row/column
6627 lists and prints it nicely formatted, with optional row/column
6621 separators and proper padding and justification.
6628 separators and proper padding and justification.
6622
6629
6623 * Released 0.1.20
6630 * Released 0.1.20
6624
6631
6625 * Fixed bug in @log which would reverse the inputcache list (a
6632 * Fixed bug in @log which would reverse the inputcache list (a
6626 copy operation was missing).
6633 copy operation was missing).
6627
6634
6628 * Code cleanup. @config was changed to use page(). Better, since
6635 * Code cleanup. @config was changed to use page(). Better, since
6629 its output is always quite long.
6636 its output is always quite long.
6630
6637
6631 * Itpl is back as a dependency. I was having too many problems
6638 * Itpl is back as a dependency. I was having too many problems
6632 getting the parametric aliases to work reliably, and it's just
6639 getting the parametric aliases to work reliably, and it's just
6633 easier to code weird string operations with it than playing %()s
6640 easier to code weird string operations with it than playing %()s
6634 games. It's only ~6k, so I don't think it's too big a deal.
6641 games. It's only ~6k, so I don't think it's too big a deal.
6635
6642
6636 * Found (and fixed) a very nasty bug with history. !lines weren't
6643 * Found (and fixed) a very nasty bug with history. !lines weren't
6637 getting cached, and the out of sync caches would crash
6644 getting cached, and the out of sync caches would crash
6638 IPython. Fixed it by reorganizing the prefilter/handlers/logger
6645 IPython. Fixed it by reorganizing the prefilter/handlers/logger
6639 division of labor a bit better. Bug fixed, cleaner structure.
6646 division of labor a bit better. Bug fixed, cleaner structure.
6640
6647
6641 2001-12-01 Fernando Perez <fperez@colorado.edu>
6648 2001-12-01 Fernando Perez <fperez@colorado.edu>
6642
6649
6643 * Released 0.1.19
6650 * Released 0.1.19
6644
6651
6645 * Added option -n to @hist to prevent line number printing. Much
6652 * Added option -n to @hist to prevent line number printing. Much
6646 easier to copy/paste code this way.
6653 easier to copy/paste code this way.
6647
6654
6648 * Created global _il to hold the input list. Allows easy
6655 * Created global _il to hold the input list. Allows easy
6649 re-execution of blocks of code by slicing it (inspired by Janko's
6656 re-execution of blocks of code by slicing it (inspired by Janko's
6650 comment on 'macros').
6657 comment on 'macros').
6651
6658
6652 * Small fixes and doc updates.
6659 * Small fixes and doc updates.
6653
6660
6654 * Rewrote @history function (was @h). Renamed it to @hist, @h is
6661 * Rewrote @history function (was @h). Renamed it to @hist, @h is
6655 much too fragile with automagic. Handles properly multi-line
6662 much too fragile with automagic. Handles properly multi-line
6656 statements and takes parameters.
6663 statements and takes parameters.
6657
6664
6658 2001-11-30 Fernando Perez <fperez@colorado.edu>
6665 2001-11-30 Fernando Perez <fperez@colorado.edu>
6659
6666
6660 * Version 0.1.18 released.
6667 * Version 0.1.18 released.
6661
6668
6662 * Fixed nasty namespace bug in initial module imports.
6669 * Fixed nasty namespace bug in initial module imports.
6663
6670
6664 * Added copyright/license notes to all code files (except
6671 * Added copyright/license notes to all code files (except
6665 DPyGetOpt). For the time being, LGPL. That could change.
6672 DPyGetOpt). For the time being, LGPL. That could change.
6666
6673
6667 * Rewrote a much nicer README, updated INSTALL, cleaned up
6674 * Rewrote a much nicer README, updated INSTALL, cleaned up
6668 ipythonrc-* samples.
6675 ipythonrc-* samples.
6669
6676
6670 * Overall code/documentation cleanup. Basically ready for
6677 * Overall code/documentation cleanup. Basically ready for
6671 release. Only remaining thing: licence decision (LGPL?).
6678 release. Only remaining thing: licence decision (LGPL?).
6672
6679
6673 * Converted load_config to a class, ConfigLoader. Now recursion
6680 * Converted load_config to a class, ConfigLoader. Now recursion
6674 control is better organized. Doesn't include the same file twice.
6681 control is better organized. Doesn't include the same file twice.
6675
6682
6676 2001-11-29 Fernando Perez <fperez@colorado.edu>
6683 2001-11-29 Fernando Perez <fperez@colorado.edu>
6677
6684
6678 * Got input history working. Changed output history variables from
6685 * Got input history working. Changed output history variables from
6679 _p to _o so that _i is for input and _o for output. Just cleaner
6686 _p to _o so that _i is for input and _o for output. Just cleaner
6680 convention.
6687 convention.
6681
6688
6682 * Implemented parametric aliases. This pretty much allows the
6689 * Implemented parametric aliases. This pretty much allows the
6683 alias system to offer full-blown shell convenience, I think.
6690 alias system to offer full-blown shell convenience, I think.
6684
6691
6685 * Version 0.1.17 released, 0.1.18 opened.
6692 * Version 0.1.17 released, 0.1.18 opened.
6686
6693
6687 * dot_ipython/ipythonrc (alias): added documentation.
6694 * dot_ipython/ipythonrc (alias): added documentation.
6688 (xcolor): Fixed small bug (xcolors -> xcolor)
6695 (xcolor): Fixed small bug (xcolors -> xcolor)
6689
6696
6690 * Changed the alias system. Now alias is a magic command to define
6697 * Changed the alias system. Now alias is a magic command to define
6691 aliases just like the shell. Rationale: the builtin magics should
6698 aliases just like the shell. Rationale: the builtin magics should
6692 be there for things deeply connected to IPython's
6699 be there for things deeply connected to IPython's
6693 architecture. And this is a much lighter system for what I think
6700 architecture. And this is a much lighter system for what I think
6694 is the really important feature: allowing users to define quickly
6701 is the really important feature: allowing users to define quickly
6695 magics that will do shell things for them, so they can customize
6702 magics that will do shell things for them, so they can customize
6696 IPython easily to match their work habits. If someone is really
6703 IPython easily to match their work habits. If someone is really
6697 desperate to have another name for a builtin alias, they can
6704 desperate to have another name for a builtin alias, they can
6698 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
6705 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
6699 works.
6706 works.
6700
6707
6701 2001-11-28 Fernando Perez <fperez@colorado.edu>
6708 2001-11-28 Fernando Perez <fperez@colorado.edu>
6702
6709
6703 * Changed @file so that it opens the source file at the proper
6710 * Changed @file so that it opens the source file at the proper
6704 line. Since it uses less, if your EDITOR environment is
6711 line. Since it uses less, if your EDITOR environment is
6705 configured, typing v will immediately open your editor of choice
6712 configured, typing v will immediately open your editor of choice
6706 right at the line where the object is defined. Not as quick as
6713 right at the line where the object is defined. Not as quick as
6707 having a direct @edit command, but for all intents and purposes it
6714 having a direct @edit command, but for all intents and purposes it
6708 works. And I don't have to worry about writing @edit to deal with
6715 works. And I don't have to worry about writing @edit to deal with
6709 all the editors, less does that.
6716 all the editors, less does that.
6710
6717
6711 * Version 0.1.16 released, 0.1.17 opened.
6718 * Version 0.1.16 released, 0.1.17 opened.
6712
6719
6713 * Fixed some nasty bugs in the page/page_dumb combo that could
6720 * Fixed some nasty bugs in the page/page_dumb combo that could
6714 crash IPython.
6721 crash IPython.
6715
6722
6716 2001-11-27 Fernando Perez <fperez@colorado.edu>
6723 2001-11-27 Fernando Perez <fperez@colorado.edu>
6717
6724
6718 * Version 0.1.15 released, 0.1.16 opened.
6725 * Version 0.1.15 released, 0.1.16 opened.
6719
6726
6720 * Finally got ? and ?? to work for undefined things: now it's
6727 * Finally got ? and ?? to work for undefined things: now it's
6721 possible to type {}.get? and get information about the get method
6728 possible to type {}.get? and get information about the get method
6722 of dicts, or os.path? even if only os is defined (so technically
6729 of dicts, or os.path? even if only os is defined (so technically
6723 os.path isn't). Works at any level. For example, after import os,
6730 os.path isn't). Works at any level. For example, after import os,
6724 os?, os.path?, os.path.abspath? all work. This is great, took some
6731 os?, os.path?, os.path.abspath? all work. This is great, took some
6725 work in _ofind.
6732 work in _ofind.
6726
6733
6727 * Fixed more bugs with logging. The sanest way to do it was to add
6734 * Fixed more bugs with logging. The sanest way to do it was to add
6728 to @log a 'mode' parameter. Killed two in one shot (this mode
6735 to @log a 'mode' parameter. Killed two in one shot (this mode
6729 option was a request of Janko's). I think it's finally clean
6736 option was a request of Janko's). I think it's finally clean
6730 (famous last words).
6737 (famous last words).
6731
6738
6732 * Added a page_dumb() pager which does a decent job of paging on
6739 * Added a page_dumb() pager which does a decent job of paging on
6733 screen, if better things (like less) aren't available. One less
6740 screen, if better things (like less) aren't available. One less
6734 unix dependency (someday maybe somebody will port this to
6741 unix dependency (someday maybe somebody will port this to
6735 windows).
6742 windows).
6736
6743
6737 * Fixed problem in magic_log: would lock of logging out if log
6744 * Fixed problem in magic_log: would lock of logging out if log
6738 creation failed (because it would still think it had succeeded).
6745 creation failed (because it would still think it had succeeded).
6739
6746
6740 * Improved the page() function using curses to auto-detect screen
6747 * Improved the page() function using curses to auto-detect screen
6741 size. Now it can make a much better decision on whether to print
6748 size. Now it can make a much better decision on whether to print
6742 or page a string. Option screen_length was modified: a value 0
6749 or page a string. Option screen_length was modified: a value 0
6743 means auto-detect, and that's the default now.
6750 means auto-detect, and that's the default now.
6744
6751
6745 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6752 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6746 go out. I'll test it for a few days, then talk to Janko about
6753 go out. I'll test it for a few days, then talk to Janko about
6747 licences and announce it.
6754 licences and announce it.
6748
6755
6749 * Fixed the length of the auto-generated ---> prompt which appears
6756 * Fixed the length of the auto-generated ---> prompt which appears
6750 for auto-parens and auto-quotes. Getting this right isn't trivial,
6757 for auto-parens and auto-quotes. Getting this right isn't trivial,
6751 with all the color escapes, different prompt types and optional
6758 with all the color escapes, different prompt types and optional
6752 separators. But it seems to be working in all the combinations.
6759 separators. But it seems to be working in all the combinations.
6753
6760
6754 2001-11-26 Fernando Perez <fperez@colorado.edu>
6761 2001-11-26 Fernando Perez <fperez@colorado.edu>
6755
6762
6756 * Wrote a regexp filter to get option types from the option names
6763 * Wrote a regexp filter to get option types from the option names
6757 string. This eliminates the need to manually keep two duplicate
6764 string. This eliminates the need to manually keep two duplicate
6758 lists.
6765 lists.
6759
6766
6760 * Removed the unneeded check_option_names. Now options are handled
6767 * Removed the unneeded check_option_names. Now options are handled
6761 in a much saner manner and it's easy to visually check that things
6768 in a much saner manner and it's easy to visually check that things
6762 are ok.
6769 are ok.
6763
6770
6764 * Updated version numbers on all files I modified to carry a
6771 * Updated version numbers on all files I modified to carry a
6765 notice so Janko and Nathan have clear version markers.
6772 notice so Janko and Nathan have clear version markers.
6766
6773
6767 * Updated docstring for ultraTB with my changes. I should send
6774 * Updated docstring for ultraTB with my changes. I should send
6768 this to Nathan.
6775 this to Nathan.
6769
6776
6770 * Lots of small fixes. Ran everything through pychecker again.
6777 * Lots of small fixes. Ran everything through pychecker again.
6771
6778
6772 * Made loading of deep_reload an cmd line option. If it's not too
6779 * Made loading of deep_reload an cmd line option. If it's not too
6773 kosher, now people can just disable it. With -nodeep_reload it's
6780 kosher, now people can just disable it. With -nodeep_reload it's
6774 still available as dreload(), it just won't overwrite reload().
6781 still available as dreload(), it just won't overwrite reload().
6775
6782
6776 * Moved many options to the no| form (-opt and -noopt
6783 * Moved many options to the no| form (-opt and -noopt
6777 accepted). Cleaner.
6784 accepted). Cleaner.
6778
6785
6779 * Changed magic_log so that if called with no parameters, it uses
6786 * Changed magic_log so that if called with no parameters, it uses
6780 'rotate' mode. That way auto-generated logs aren't automatically
6787 'rotate' mode. That way auto-generated logs aren't automatically
6781 over-written. For normal logs, now a backup is made if it exists
6788 over-written. For normal logs, now a backup is made if it exists
6782 (only 1 level of backups). A new 'backup' mode was added to the
6789 (only 1 level of backups). A new 'backup' mode was added to the
6783 Logger class to support this. This was a request by Janko.
6790 Logger class to support this. This was a request by Janko.
6784
6791
6785 * Added @logoff/@logon to stop/restart an active log.
6792 * Added @logoff/@logon to stop/restart an active log.
6786
6793
6787 * Fixed a lot of bugs in log saving/replay. It was pretty
6794 * Fixed a lot of bugs in log saving/replay. It was pretty
6788 broken. Now special lines (!@,/) appear properly in the command
6795 broken. Now special lines (!@,/) appear properly in the command
6789 history after a log replay.
6796 history after a log replay.
6790
6797
6791 * Tried and failed to implement full session saving via pickle. My
6798 * Tried and failed to implement full session saving via pickle. My
6792 idea was to pickle __main__.__dict__, but modules can't be
6799 idea was to pickle __main__.__dict__, but modules can't be
6793 pickled. This would be a better alternative to replaying logs, but
6800 pickled. This would be a better alternative to replaying logs, but
6794 seems quite tricky to get to work. Changed -session to be called
6801 seems quite tricky to get to work. Changed -session to be called
6795 -logplay, which more accurately reflects what it does. And if we
6802 -logplay, which more accurately reflects what it does. And if we
6796 ever get real session saving working, -session is now available.
6803 ever get real session saving working, -session is now available.
6797
6804
6798 * Implemented color schemes for prompts also. As for tracebacks,
6805 * Implemented color schemes for prompts also. As for tracebacks,
6799 currently only NoColor and Linux are supported. But now the
6806 currently only NoColor and Linux are supported. But now the
6800 infrastructure is in place, based on a generic ColorScheme
6807 infrastructure is in place, based on a generic ColorScheme
6801 class. So writing and activating new schemes both for the prompts
6808 class. So writing and activating new schemes both for the prompts
6802 and the tracebacks should be straightforward.
6809 and the tracebacks should be straightforward.
6803
6810
6804 * Version 0.1.13 released, 0.1.14 opened.
6811 * Version 0.1.13 released, 0.1.14 opened.
6805
6812
6806 * Changed handling of options for output cache. Now counter is
6813 * Changed handling of options for output cache. Now counter is
6807 hardwired starting at 1 and one specifies the maximum number of
6814 hardwired starting at 1 and one specifies the maximum number of
6808 entries *in the outcache* (not the max prompt counter). This is
6815 entries *in the outcache* (not the max prompt counter). This is
6809 much better, since many statements won't increase the cache
6816 much better, since many statements won't increase the cache
6810 count. It also eliminated some confusing options, now there's only
6817 count. It also eliminated some confusing options, now there's only
6811 one: cache_size.
6818 one: cache_size.
6812
6819
6813 * Added 'alias' magic function and magic_alias option in the
6820 * Added 'alias' magic function and magic_alias option in the
6814 ipythonrc file. Now the user can easily define whatever names he
6821 ipythonrc file. Now the user can easily define whatever names he
6815 wants for the magic functions without having to play weird
6822 wants for the magic functions without having to play weird
6816 namespace games. This gives IPython a real shell-like feel.
6823 namespace games. This gives IPython a real shell-like feel.
6817
6824
6818 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6825 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6819 @ or not).
6826 @ or not).
6820
6827
6821 This was one of the last remaining 'visible' bugs (that I know
6828 This was one of the last remaining 'visible' bugs (that I know
6822 of). I think if I can clean up the session loading so it works
6829 of). I think if I can clean up the session loading so it works
6823 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6830 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6824 about licensing).
6831 about licensing).
6825
6832
6826 2001-11-25 Fernando Perez <fperez@colorado.edu>
6833 2001-11-25 Fernando Perez <fperez@colorado.edu>
6827
6834
6828 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6835 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6829 there's a cleaner distinction between what ? and ?? show.
6836 there's a cleaner distinction between what ? and ?? show.
6830
6837
6831 * Added screen_length option. Now the user can define his own
6838 * Added screen_length option. Now the user can define his own
6832 screen size for page() operations.
6839 screen size for page() operations.
6833
6840
6834 * Implemented magic shell-like functions with automatic code
6841 * Implemented magic shell-like functions with automatic code
6835 generation. Now adding another function is just a matter of adding
6842 generation. Now adding another function is just a matter of adding
6836 an entry to a dict, and the function is dynamically generated at
6843 an entry to a dict, and the function is dynamically generated at
6837 run-time. Python has some really cool features!
6844 run-time. Python has some really cool features!
6838
6845
6839 * Renamed many options to cleanup conventions a little. Now all
6846 * Renamed many options to cleanup conventions a little. Now all
6840 are lowercase, and only underscores where needed. Also in the code
6847 are lowercase, and only underscores where needed. Also in the code
6841 option name tables are clearer.
6848 option name tables are clearer.
6842
6849
6843 * Changed prompts a little. Now input is 'In [n]:' instead of
6850 * Changed prompts a little. Now input is 'In [n]:' instead of
6844 'In[n]:='. This allows it the numbers to be aligned with the
6851 'In[n]:='. This allows it the numbers to be aligned with the
6845 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6852 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6846 Python (it was a Mathematica thing). The '...' continuation prompt
6853 Python (it was a Mathematica thing). The '...' continuation prompt
6847 was also changed a little to align better.
6854 was also changed a little to align better.
6848
6855
6849 * Fixed bug when flushing output cache. Not all _p<n> variables
6856 * Fixed bug when flushing output cache. Not all _p<n> variables
6850 exist, so their deletion needs to be wrapped in a try:
6857 exist, so their deletion needs to be wrapped in a try:
6851
6858
6852 * Figured out how to properly use inspect.formatargspec() (it
6859 * Figured out how to properly use inspect.formatargspec() (it
6853 requires the args preceded by *). So I removed all the code from
6860 requires the args preceded by *). So I removed all the code from
6854 _get_pdef in Magic, which was just replicating that.
6861 _get_pdef in Magic, which was just replicating that.
6855
6862
6856 * Added test to prefilter to allow redefining magic function names
6863 * Added test to prefilter to allow redefining magic function names
6857 as variables. This is ok, since the @ form is always available,
6864 as variables. This is ok, since the @ form is always available,
6858 but whe should allow the user to define a variable called 'ls' if
6865 but whe should allow the user to define a variable called 'ls' if
6859 he needs it.
6866 he needs it.
6860
6867
6861 * Moved the ToDo information from README into a separate ToDo.
6868 * Moved the ToDo information from README into a separate ToDo.
6862
6869
6863 * General code cleanup and small bugfixes. I think it's close to a
6870 * General code cleanup and small bugfixes. I think it's close to a
6864 state where it can be released, obviously with a big 'beta'
6871 state where it can be released, obviously with a big 'beta'
6865 warning on it.
6872 warning on it.
6866
6873
6867 * Got the magic function split to work. Now all magics are defined
6874 * Got the magic function split to work. Now all magics are defined
6868 in a separate class. It just organizes things a bit, and now
6875 in a separate class. It just organizes things a bit, and now
6869 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6876 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6870 was too long).
6877 was too long).
6871
6878
6872 * Changed @clear to @reset to avoid potential confusions with
6879 * Changed @clear to @reset to avoid potential confusions with
6873 the shell command clear. Also renamed @cl to @clear, which does
6880 the shell command clear. Also renamed @cl to @clear, which does
6874 exactly what people expect it to from their shell experience.
6881 exactly what people expect it to from their shell experience.
6875
6882
6876 Added a check to the @reset command (since it's so
6883 Added a check to the @reset command (since it's so
6877 destructive, it's probably a good idea to ask for confirmation).
6884 destructive, it's probably a good idea to ask for confirmation).
6878 But now reset only works for full namespace resetting. Since the
6885 But now reset only works for full namespace resetting. Since the
6879 del keyword is already there for deleting a few specific
6886 del keyword is already there for deleting a few specific
6880 variables, I don't see the point of having a redundant magic
6887 variables, I don't see the point of having a redundant magic
6881 function for the same task.
6888 function for the same task.
6882
6889
6883 2001-11-24 Fernando Perez <fperez@colorado.edu>
6890 2001-11-24 Fernando Perez <fperez@colorado.edu>
6884
6891
6885 * Updated the builtin docs (esp. the ? ones).
6892 * Updated the builtin docs (esp. the ? ones).
6886
6893
6887 * Ran all the code through pychecker. Not terribly impressed with
6894 * Ran all the code through pychecker. Not terribly impressed with
6888 it: lots of spurious warnings and didn't really find anything of
6895 it: lots of spurious warnings and didn't really find anything of
6889 substance (just a few modules being imported and not used).
6896 substance (just a few modules being imported and not used).
6890
6897
6891 * Implemented the new ultraTB functionality into IPython. New
6898 * Implemented the new ultraTB functionality into IPython. New
6892 option: xcolors. This chooses color scheme. xmode now only selects
6899 option: xcolors. This chooses color scheme. xmode now only selects
6893 between Plain and Verbose. Better orthogonality.
6900 between Plain and Verbose. Better orthogonality.
6894
6901
6895 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6902 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6896 mode and color scheme for the exception handlers. Now it's
6903 mode and color scheme for the exception handlers. Now it's
6897 possible to have the verbose traceback with no coloring.
6904 possible to have the verbose traceback with no coloring.
6898
6905
6899 2001-11-23 Fernando Perez <fperez@colorado.edu>
6906 2001-11-23 Fernando Perez <fperez@colorado.edu>
6900
6907
6901 * Version 0.1.12 released, 0.1.13 opened.
6908 * Version 0.1.12 released, 0.1.13 opened.
6902
6909
6903 * Removed option to set auto-quote and auto-paren escapes by
6910 * Removed option to set auto-quote and auto-paren escapes by
6904 user. The chances of breaking valid syntax are just too high. If
6911 user. The chances of breaking valid syntax are just too high. If
6905 someone *really* wants, they can always dig into the code.
6912 someone *really* wants, they can always dig into the code.
6906
6913
6907 * Made prompt separators configurable.
6914 * Made prompt separators configurable.
6908
6915
6909 2001-11-22 Fernando Perez <fperez@colorado.edu>
6916 2001-11-22 Fernando Perez <fperez@colorado.edu>
6910
6917
6911 * Small bugfixes in many places.
6918 * Small bugfixes in many places.
6912
6919
6913 * Removed the MyCompleter class from ipplib. It seemed redundant
6920 * Removed the MyCompleter class from ipplib. It seemed redundant
6914 with the C-p,C-n history search functionality. Less code to
6921 with the C-p,C-n history search functionality. Less code to
6915 maintain.
6922 maintain.
6916
6923
6917 * Moved all the original ipython.py code into ipythonlib.py. Right
6924 * Moved all the original ipython.py code into ipythonlib.py. Right
6918 now it's just one big dump into a function called make_IPython, so
6925 now it's just one big dump into a function called make_IPython, so
6919 no real modularity has been gained. But at least it makes the
6926 no real modularity has been gained. But at least it makes the
6920 wrapper script tiny, and since ipythonlib is a module, it gets
6927 wrapper script tiny, and since ipythonlib is a module, it gets
6921 compiled and startup is much faster.
6928 compiled and startup is much faster.
6922
6929
6923 This is a reasobably 'deep' change, so we should test it for a
6930 This is a reasobably 'deep' change, so we should test it for a
6924 while without messing too much more with the code.
6931 while without messing too much more with the code.
6925
6932
6926 2001-11-21 Fernando Perez <fperez@colorado.edu>
6933 2001-11-21 Fernando Perez <fperez@colorado.edu>
6927
6934
6928 * Version 0.1.11 released, 0.1.12 opened for further work.
6935 * Version 0.1.11 released, 0.1.12 opened for further work.
6929
6936
6930 * Removed dependency on Itpl. It was only needed in one place. It
6937 * Removed dependency on Itpl. It was only needed in one place. It
6931 would be nice if this became part of python, though. It makes life
6938 would be nice if this became part of python, though. It makes life
6932 *a lot* easier in some cases.
6939 *a lot* easier in some cases.
6933
6940
6934 * Simplified the prefilter code a bit. Now all handlers are
6941 * Simplified the prefilter code a bit. Now all handlers are
6935 expected to explicitly return a value (at least a blank string).
6942 expected to explicitly return a value (at least a blank string).
6936
6943
6937 * Heavy edits in ipplib. Removed the help system altogether. Now
6944 * Heavy edits in ipplib. Removed the help system altogether. Now
6938 obj?/?? is used for inspecting objects, a magic @doc prints
6945 obj?/?? is used for inspecting objects, a magic @doc prints
6939 docstrings, and full-blown Python help is accessed via the 'help'
6946 docstrings, and full-blown Python help is accessed via the 'help'
6940 keyword. This cleans up a lot of code (less to maintain) and does
6947 keyword. This cleans up a lot of code (less to maintain) and does
6941 the job. Since 'help' is now a standard Python component, might as
6948 the job. Since 'help' is now a standard Python component, might as
6942 well use it and remove duplicate functionality.
6949 well use it and remove duplicate functionality.
6943
6950
6944 Also removed the option to use ipplib as a standalone program. By
6951 Also removed the option to use ipplib as a standalone program. By
6945 now it's too dependent on other parts of IPython to function alone.
6952 now it's too dependent on other parts of IPython to function alone.
6946
6953
6947 * Fixed bug in genutils.pager. It would crash if the pager was
6954 * Fixed bug in genutils.pager. It would crash if the pager was
6948 exited immediately after opening (broken pipe).
6955 exited immediately after opening (broken pipe).
6949
6956
6950 * Trimmed down the VerboseTB reporting a little. The header is
6957 * Trimmed down the VerboseTB reporting a little. The header is
6951 much shorter now and the repeated exception arguments at the end
6958 much shorter now and the repeated exception arguments at the end
6952 have been removed. For interactive use the old header seemed a bit
6959 have been removed. For interactive use the old header seemed a bit
6953 excessive.
6960 excessive.
6954
6961
6955 * Fixed small bug in output of @whos for variables with multi-word
6962 * Fixed small bug in output of @whos for variables with multi-word
6956 types (only first word was displayed).
6963 types (only first word was displayed).
6957
6964
6958 2001-11-17 Fernando Perez <fperez@colorado.edu>
6965 2001-11-17 Fernando Perez <fperez@colorado.edu>
6959
6966
6960 * Version 0.1.10 released, 0.1.11 opened for further work.
6967 * Version 0.1.10 released, 0.1.11 opened for further work.
6961
6968
6962 * Modified dirs and friends. dirs now *returns* the stack (not
6969 * Modified dirs and friends. dirs now *returns* the stack (not
6963 prints), so one can manipulate it as a variable. Convenient to
6970 prints), so one can manipulate it as a variable. Convenient to
6964 travel along many directories.
6971 travel along many directories.
6965
6972
6966 * Fixed bug in magic_pdef: would only work with functions with
6973 * Fixed bug in magic_pdef: would only work with functions with
6967 arguments with default values.
6974 arguments with default values.
6968
6975
6969 2001-11-14 Fernando Perez <fperez@colorado.edu>
6976 2001-11-14 Fernando Perez <fperez@colorado.edu>
6970
6977
6971 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6978 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6972 example with IPython. Various other minor fixes and cleanups.
6979 example with IPython. Various other minor fixes and cleanups.
6973
6980
6974 * Version 0.1.9 released, 0.1.10 opened for further work.
6981 * Version 0.1.9 released, 0.1.10 opened for further work.
6975
6982
6976 * Added sys.path to the list of directories searched in the
6983 * Added sys.path to the list of directories searched in the
6977 execfile= option. It used to be the current directory and the
6984 execfile= option. It used to be the current directory and the
6978 user's IPYTHONDIR only.
6985 user's IPYTHONDIR only.
6979
6986
6980 2001-11-13 Fernando Perez <fperez@colorado.edu>
6987 2001-11-13 Fernando Perez <fperez@colorado.edu>
6981
6988
6982 * Reinstated the raw_input/prefilter separation that Janko had
6989 * Reinstated the raw_input/prefilter separation that Janko had
6983 initially. This gives a more convenient setup for extending the
6990 initially. This gives a more convenient setup for extending the
6984 pre-processor from the outside: raw_input always gets a string,
6991 pre-processor from the outside: raw_input always gets a string,
6985 and prefilter has to process it. We can then redefine prefilter
6992 and prefilter has to process it. We can then redefine prefilter
6986 from the outside and implement extensions for special
6993 from the outside and implement extensions for special
6987 purposes.
6994 purposes.
6988
6995
6989 Today I got one for inputting PhysicalQuantity objects
6996 Today I got one for inputting PhysicalQuantity objects
6990 (from Scientific) without needing any function calls at
6997 (from Scientific) without needing any function calls at
6991 all. Extremely convenient, and it's all done as a user-level
6998 all. Extremely convenient, and it's all done as a user-level
6992 extension (no IPython code was touched). Now instead of:
6999 extension (no IPython code was touched). Now instead of:
6993 a = PhysicalQuantity(4.2,'m/s**2')
7000 a = PhysicalQuantity(4.2,'m/s**2')
6994 one can simply say
7001 one can simply say
6995 a = 4.2 m/s**2
7002 a = 4.2 m/s**2
6996 or even
7003 or even
6997 a = 4.2 m/s^2
7004 a = 4.2 m/s^2
6998
7005
6999 I use this, but it's also a proof of concept: IPython really is
7006 I use this, but it's also a proof of concept: IPython really is
7000 fully user-extensible, even at the level of the parsing of the
7007 fully user-extensible, even at the level of the parsing of the
7001 command line. It's not trivial, but it's perfectly doable.
7008 command line. It's not trivial, but it's perfectly doable.
7002
7009
7003 * Added 'add_flip' method to inclusion conflict resolver. Fixes
7010 * Added 'add_flip' method to inclusion conflict resolver. Fixes
7004 the problem of modules being loaded in the inverse order in which
7011 the problem of modules being loaded in the inverse order in which
7005 they were defined in
7012 they were defined in
7006
7013
7007 * Version 0.1.8 released, 0.1.9 opened for further work.
7014 * Version 0.1.8 released, 0.1.9 opened for further work.
7008
7015
7009 * Added magics pdef, source and file. They respectively show the
7016 * Added magics pdef, source and file. They respectively show the
7010 definition line ('prototype' in C), source code and full python
7017 definition line ('prototype' in C), source code and full python
7011 file for any callable object. The object inspector oinfo uses
7018 file for any callable object. The object inspector oinfo uses
7012 these to show the same information.
7019 these to show the same information.
7013
7020
7014 * Version 0.1.7 released, 0.1.8 opened for further work.
7021 * Version 0.1.7 released, 0.1.8 opened for further work.
7015
7022
7016 * Separated all the magic functions into a class called Magic. The
7023 * Separated all the magic functions into a class called Magic. The
7017 InteractiveShell class was becoming too big for Xemacs to handle
7024 InteractiveShell class was becoming too big for Xemacs to handle
7018 (de-indenting a line would lock it up for 10 seconds while it
7025 (de-indenting a line would lock it up for 10 seconds while it
7019 backtracked on the whole class!)
7026 backtracked on the whole class!)
7020
7027
7021 FIXME: didn't work. It can be done, but right now namespaces are
7028 FIXME: didn't work. It can be done, but right now namespaces are
7022 all messed up. Do it later (reverted it for now, so at least
7029 all messed up. Do it later (reverted it for now, so at least
7023 everything works as before).
7030 everything works as before).
7024
7031
7025 * Got the object introspection system (magic_oinfo) working! I
7032 * Got the object introspection system (magic_oinfo) working! I
7026 think this is pretty much ready for release to Janko, so he can
7033 think this is pretty much ready for release to Janko, so he can
7027 test it for a while and then announce it. Pretty much 100% of what
7034 test it for a while and then announce it. Pretty much 100% of what
7028 I wanted for the 'phase 1' release is ready. Happy, tired.
7035 I wanted for the 'phase 1' release is ready. Happy, tired.
7029
7036
7030 2001-11-12 Fernando Perez <fperez@colorado.edu>
7037 2001-11-12 Fernando Perez <fperez@colorado.edu>
7031
7038
7032 * Version 0.1.6 released, 0.1.7 opened for further work.
7039 * Version 0.1.6 released, 0.1.7 opened for further work.
7033
7040
7034 * Fixed bug in printing: it used to test for truth before
7041 * Fixed bug in printing: it used to test for truth before
7035 printing, so 0 wouldn't print. Now checks for None.
7042 printing, so 0 wouldn't print. Now checks for None.
7036
7043
7037 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
7044 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
7038 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
7045 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
7039 reaches by hand into the outputcache. Think of a better way to do
7046 reaches by hand into the outputcache. Think of a better way to do
7040 this later.
7047 this later.
7041
7048
7042 * Various small fixes thanks to Nathan's comments.
7049 * Various small fixes thanks to Nathan's comments.
7043
7050
7044 * Changed magic_pprint to magic_Pprint. This way it doesn't
7051 * Changed magic_pprint to magic_Pprint. This way it doesn't
7045 collide with pprint() and the name is consistent with the command
7052 collide with pprint() and the name is consistent with the command
7046 line option.
7053 line option.
7047
7054
7048 * Changed prompt counter behavior to be fully like
7055 * Changed prompt counter behavior to be fully like
7049 Mathematica's. That is, even input that doesn't return a result
7056 Mathematica's. That is, even input that doesn't return a result
7050 raises the prompt counter. The old behavior was kind of confusing
7057 raises the prompt counter. The old behavior was kind of confusing
7051 (getting the same prompt number several times if the operation
7058 (getting the same prompt number several times if the operation
7052 didn't return a result).
7059 didn't return a result).
7053
7060
7054 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
7061 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
7055
7062
7056 * Fixed -Classic mode (wasn't working anymore).
7063 * Fixed -Classic mode (wasn't working anymore).
7057
7064
7058 * Added colored prompts using Nathan's new code. Colors are
7065 * Added colored prompts using Nathan's new code. Colors are
7059 currently hardwired, they can be user-configurable. For
7066 currently hardwired, they can be user-configurable. For
7060 developers, they can be chosen in file ipythonlib.py, at the
7067 developers, they can be chosen in file ipythonlib.py, at the
7061 beginning of the CachedOutput class def.
7068 beginning of the CachedOutput class def.
7062
7069
7063 2001-11-11 Fernando Perez <fperez@colorado.edu>
7070 2001-11-11 Fernando Perez <fperez@colorado.edu>
7064
7071
7065 * Version 0.1.5 released, 0.1.6 opened for further work.
7072 * Version 0.1.5 released, 0.1.6 opened for further work.
7066
7073
7067 * Changed magic_env to *return* the environment as a dict (not to
7074 * Changed magic_env to *return* the environment as a dict (not to
7068 print it). This way it prints, but it can also be processed.
7075 print it). This way it prints, but it can also be processed.
7069
7076
7070 * Added Verbose exception reporting to interactive
7077 * Added Verbose exception reporting to interactive
7071 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
7078 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
7072 traceback. Had to make some changes to the ultraTB file. This is
7079 traceback. Had to make some changes to the ultraTB file. This is
7073 probably the last 'big' thing in my mental todo list. This ties
7080 probably the last 'big' thing in my mental todo list. This ties
7074 in with the next entry:
7081 in with the next entry:
7075
7082
7076 * Changed -Xi and -Xf to a single -xmode option. Now all the user
7083 * Changed -Xi and -Xf to a single -xmode option. Now all the user
7077 has to specify is Plain, Color or Verbose for all exception
7084 has to specify is Plain, Color or Verbose for all exception
7078 handling.
7085 handling.
7079
7086
7080 * Removed ShellServices option. All this can really be done via
7087 * Removed ShellServices option. All this can really be done via
7081 the magic system. It's easier to extend, cleaner and has automatic
7088 the magic system. It's easier to extend, cleaner and has automatic
7082 namespace protection and documentation.
7089 namespace protection and documentation.
7083
7090
7084 2001-11-09 Fernando Perez <fperez@colorado.edu>
7091 2001-11-09 Fernando Perez <fperez@colorado.edu>
7085
7092
7086 * Fixed bug in output cache flushing (missing parameter to
7093 * Fixed bug in output cache flushing (missing parameter to
7087 __init__). Other small bugs fixed (found using pychecker).
7094 __init__). Other small bugs fixed (found using pychecker).
7088
7095
7089 * Version 0.1.4 opened for bugfixing.
7096 * Version 0.1.4 opened for bugfixing.
7090
7097
7091 2001-11-07 Fernando Perez <fperez@colorado.edu>
7098 2001-11-07 Fernando Perez <fperez@colorado.edu>
7092
7099
7093 * Version 0.1.3 released, mainly because of the raw_input bug.
7100 * Version 0.1.3 released, mainly because of the raw_input bug.
7094
7101
7095 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
7102 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
7096 and when testing for whether things were callable, a call could
7103 and when testing for whether things were callable, a call could
7097 actually be made to certain functions. They would get called again
7104 actually be made to certain functions. They would get called again
7098 once 'really' executed, with a resulting double call. A disaster
7105 once 'really' executed, with a resulting double call. A disaster
7099 in many cases (list.reverse() would never work!).
7106 in many cases (list.reverse() would never work!).
7100
7107
7101 * Removed prefilter() function, moved its code to raw_input (which
7108 * Removed prefilter() function, moved its code to raw_input (which
7102 after all was just a near-empty caller for prefilter). This saves
7109 after all was just a near-empty caller for prefilter). This saves
7103 a function call on every prompt, and simplifies the class a tiny bit.
7110 a function call on every prompt, and simplifies the class a tiny bit.
7104
7111
7105 * Fix _ip to __ip name in magic example file.
7112 * Fix _ip to __ip name in magic example file.
7106
7113
7107 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
7114 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
7108 work with non-gnu versions of tar.
7115 work with non-gnu versions of tar.
7109
7116
7110 2001-11-06 Fernando Perez <fperez@colorado.edu>
7117 2001-11-06 Fernando Perez <fperez@colorado.edu>
7111
7118
7112 * Version 0.1.2. Just to keep track of the recent changes.
7119 * Version 0.1.2. Just to keep track of the recent changes.
7113
7120
7114 * Fixed nasty bug in output prompt routine. It used to check 'if
7121 * Fixed nasty bug in output prompt routine. It used to check 'if
7115 arg != None...'. Problem is, this fails if arg implements a
7122 arg != None...'. Problem is, this fails if arg implements a
7116 special comparison (__cmp__) which disallows comparing to
7123 special comparison (__cmp__) which disallows comparing to
7117 None. Found it when trying to use the PhysicalQuantity module from
7124 None. Found it when trying to use the PhysicalQuantity module from
7118 ScientificPython.
7125 ScientificPython.
7119
7126
7120 2001-11-05 Fernando Perez <fperez@colorado.edu>
7127 2001-11-05 Fernando Perez <fperez@colorado.edu>
7121
7128
7122 * Also added dirs. Now the pushd/popd/dirs family functions
7129 * Also added dirs. Now the pushd/popd/dirs family functions
7123 basically like the shell, with the added convenience of going home
7130 basically like the shell, with the added convenience of going home
7124 when called with no args.
7131 when called with no args.
7125
7132
7126 * pushd/popd slightly modified to mimic shell behavior more
7133 * pushd/popd slightly modified to mimic shell behavior more
7127 closely.
7134 closely.
7128
7135
7129 * Added env,pushd,popd from ShellServices as magic functions. I
7136 * Added env,pushd,popd from ShellServices as magic functions. I
7130 think the cleanest will be to port all desired functions from
7137 think the cleanest will be to port all desired functions from
7131 ShellServices as magics and remove ShellServices altogether. This
7138 ShellServices as magics and remove ShellServices altogether. This
7132 will provide a single, clean way of adding functionality
7139 will provide a single, clean way of adding functionality
7133 (shell-type or otherwise) to IP.
7140 (shell-type or otherwise) to IP.
7134
7141
7135 2001-11-04 Fernando Perez <fperez@colorado.edu>
7142 2001-11-04 Fernando Perez <fperez@colorado.edu>
7136
7143
7137 * Added .ipython/ directory to sys.path. This way users can keep
7144 * Added .ipython/ directory to sys.path. This way users can keep
7138 customizations there and access them via import.
7145 customizations there and access them via import.
7139
7146
7140 2001-11-03 Fernando Perez <fperez@colorado.edu>
7147 2001-11-03 Fernando Perez <fperez@colorado.edu>
7141
7148
7142 * Opened version 0.1.1 for new changes.
7149 * Opened version 0.1.1 for new changes.
7143
7150
7144 * Changed version number to 0.1.0: first 'public' release, sent to
7151 * Changed version number to 0.1.0: first 'public' release, sent to
7145 Nathan and Janko.
7152 Nathan and Janko.
7146
7153
7147 * Lots of small fixes and tweaks.
7154 * Lots of small fixes and tweaks.
7148
7155
7149 * Minor changes to whos format. Now strings are shown, snipped if
7156 * Minor changes to whos format. Now strings are shown, snipped if
7150 too long.
7157 too long.
7151
7158
7152 * Changed ShellServices to work on __main__ so they show up in @who
7159 * Changed ShellServices to work on __main__ so they show up in @who
7153
7160
7154 * Help also works with ? at the end of a line:
7161 * Help also works with ? at the end of a line:
7155 ?sin and sin?
7162 ?sin and sin?
7156 both produce the same effect. This is nice, as often I use the
7163 both produce the same effect. This is nice, as often I use the
7157 tab-complete to find the name of a method, but I used to then have
7164 tab-complete to find the name of a method, but I used to then have
7158 to go to the beginning of the line to put a ? if I wanted more
7165 to go to the beginning of the line to put a ? if I wanted more
7159 info. Now I can just add the ? and hit return. Convenient.
7166 info. Now I can just add the ? and hit return. Convenient.
7160
7167
7161 2001-11-02 Fernando Perez <fperez@colorado.edu>
7168 2001-11-02 Fernando Perez <fperez@colorado.edu>
7162
7169
7163 * Python version check (>=2.1) added.
7170 * Python version check (>=2.1) added.
7164
7171
7165 * Added LazyPython documentation. At this point the docs are quite
7172 * Added LazyPython documentation. At this point the docs are quite
7166 a mess. A cleanup is in order.
7173 a mess. A cleanup is in order.
7167
7174
7168 * Auto-installer created. For some bizarre reason, the zipfiles
7175 * Auto-installer created. For some bizarre reason, the zipfiles
7169 module isn't working on my system. So I made a tar version
7176 module isn't working on my system. So I made a tar version
7170 (hopefully the command line options in various systems won't kill
7177 (hopefully the command line options in various systems won't kill
7171 me).
7178 me).
7172
7179
7173 * Fixes to Struct in genutils. Now all dictionary-like methods are
7180 * Fixes to Struct in genutils. Now all dictionary-like methods are
7174 protected (reasonably).
7181 protected (reasonably).
7175
7182
7176 * Added pager function to genutils and changed ? to print usage
7183 * Added pager function to genutils and changed ? to print usage
7177 note through it (it was too long).
7184 note through it (it was too long).
7178
7185
7179 * Added the LazyPython functionality. Works great! I changed the
7186 * Added the LazyPython functionality. Works great! I changed the
7180 auto-quote escape to ';', it's on home row and next to '. But
7187 auto-quote escape to ';', it's on home row and next to '. But
7181 both auto-quote and auto-paren (still /) escapes are command-line
7188 both auto-quote and auto-paren (still /) escapes are command-line
7182 parameters.
7189 parameters.
7183
7190
7184
7191
7185 2001-11-01 Fernando Perez <fperez@colorado.edu>
7192 2001-11-01 Fernando Perez <fperez@colorado.edu>
7186
7193
7187 * Version changed to 0.0.7. Fairly large change: configuration now
7194 * Version changed to 0.0.7. Fairly large change: configuration now
7188 is all stored in a directory, by default .ipython. There, all
7195 is all stored in a directory, by default .ipython. There, all
7189 config files have normal looking names (not .names)
7196 config files have normal looking names (not .names)
7190
7197
7191 * Version 0.0.6 Released first to Lucas and Archie as a test
7198 * Version 0.0.6 Released first to Lucas and Archie as a test
7192 run. Since it's the first 'semi-public' release, change version to
7199 run. Since it's the first 'semi-public' release, change version to
7193 > 0.0.6 for any changes now.
7200 > 0.0.6 for any changes now.
7194
7201
7195 * Stuff I had put in the ipplib.py changelog:
7202 * Stuff I had put in the ipplib.py changelog:
7196
7203
7197 Changes to InteractiveShell:
7204 Changes to InteractiveShell:
7198
7205
7199 - Made the usage message a parameter.
7206 - Made the usage message a parameter.
7200
7207
7201 - Require the name of the shell variable to be given. It's a bit
7208 - Require the name of the shell variable to be given. It's a bit
7202 of a hack, but allows the name 'shell' not to be hardwired in the
7209 of a hack, but allows the name 'shell' not to be hardwired in the
7203 magic (@) handler, which is problematic b/c it requires
7210 magic (@) handler, which is problematic b/c it requires
7204 polluting the global namespace with 'shell'. This in turn is
7211 polluting the global namespace with 'shell'. This in turn is
7205 fragile: if a user redefines a variable called shell, things
7212 fragile: if a user redefines a variable called shell, things
7206 break.
7213 break.
7207
7214
7208 - magic @: all functions available through @ need to be defined
7215 - magic @: all functions available through @ need to be defined
7209 as magic_<name>, even though they can be called simply as
7216 as magic_<name>, even though they can be called simply as
7210 @<name>. This allows the special command @magic to gather
7217 @<name>. This allows the special command @magic to gather
7211 information automatically about all existing magic functions,
7218 information automatically about all existing magic functions,
7212 even if they are run-time user extensions, by parsing the shell
7219 even if they are run-time user extensions, by parsing the shell
7213 instance __dict__ looking for special magic_ names.
7220 instance __dict__ looking for special magic_ names.
7214
7221
7215 - mainloop: added *two* local namespace parameters. This allows
7222 - mainloop: added *two* local namespace parameters. This allows
7216 the class to differentiate between parameters which were there
7223 the class to differentiate between parameters which were there
7217 before and after command line initialization was processed. This
7224 before and after command line initialization was processed. This
7218 way, later @who can show things loaded at startup by the
7225 way, later @who can show things loaded at startup by the
7219 user. This trick was necessary to make session saving/reloading
7226 user. This trick was necessary to make session saving/reloading
7220 really work: ideally after saving/exiting/reloading a session,
7227 really work: ideally after saving/exiting/reloading a session,
7221 *everything* should look the same, including the output of @who. I
7228 *everything* should look the same, including the output of @who. I
7222 was only able to make this work with this double namespace
7229 was only able to make this work with this double namespace
7223 trick.
7230 trick.
7224
7231
7225 - added a header to the logfile which allows (almost) full
7232 - added a header to the logfile which allows (almost) full
7226 session restoring.
7233 session restoring.
7227
7234
7228 - prepend lines beginning with @ or !, with a and log
7235 - prepend lines beginning with @ or !, with a and log
7229 them. Why? !lines: may be useful to know what you did @lines:
7236 them. Why? !lines: may be useful to know what you did @lines:
7230 they may affect session state. So when restoring a session, at
7237 they may affect session state. So when restoring a session, at
7231 least inform the user of their presence. I couldn't quite get
7238 least inform the user of their presence. I couldn't quite get
7232 them to properly re-execute, but at least the user is warned.
7239 them to properly re-execute, but at least the user is warned.
7233
7240
7234 * Started ChangeLog.
7241 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now