Show More
@@ -1,2765 +1,2804 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 112 |
|
4 | $Id: Magic.py 1126 2006-02-06 02:31:40Z 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 |
|
38 | |||
39 | # profile isn't bundled by default in Debian for license reasons |
|
39 | # profile isn't bundled by default in Debian for license reasons | |
40 | try: |
|
40 | try: | |
41 | import profile,pstats |
|
41 | import profile,pstats | |
42 | except ImportError: |
|
42 | except ImportError: | |
43 | profile = pstats = None |
|
43 | profile = pstats = None | |
44 |
|
44 | |||
45 | # Homebrewed |
|
45 | # Homebrewed | |
46 | from IPython import Debugger, OInspect, wildcard |
|
46 | from IPython import Debugger, OInspect, wildcard | |
47 | from IPython.FakeModule import FakeModule |
|
47 | from IPython.FakeModule import FakeModule | |
48 | from IPython.Itpl import Itpl, itpl, printpl,itplns |
|
48 | from IPython.Itpl import Itpl, itpl, printpl,itplns | |
49 | from IPython.PyColorize import Parser |
|
49 | from IPython.PyColorize import Parser | |
50 | from IPython.ipstruct import Struct |
|
50 | from IPython.ipstruct import Struct | |
51 | from IPython.macro import Macro |
|
51 | from IPython.macro import Macro | |
52 | from IPython.genutils import * |
|
52 | from IPython.genutils import * | |
53 | from IPython import platutils |
|
53 | from IPython import platutils | |
54 |
|
54 | |||
55 | #*************************************************************************** |
|
55 | #*************************************************************************** | |
56 | # Utility functions |
|
56 | # Utility functions | |
57 | def on_off(tag): |
|
57 | def on_off(tag): | |
58 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" |
|
58 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" | |
59 | return ['OFF','ON'][tag] |
|
59 | return ['OFF','ON'][tag] | |
60 |
|
60 | |||
61 | class Bunch: pass |
|
61 | class Bunch: pass | |
62 |
|
62 | |||
63 | #*************************************************************************** |
|
63 | #*************************************************************************** | |
64 | # Main class implementing Magic functionality |
|
64 | # Main class implementing Magic functionality | |
65 | class Magic: |
|
65 | class Magic: | |
66 | """Magic functions for InteractiveShell. |
|
66 | """Magic functions for InteractiveShell. | |
67 |
|
67 | |||
68 | Shell functions which can be reached as %function_name. All magic |
|
68 | Shell functions which can be reached as %function_name. All magic | |
69 | functions should accept a string, which they can parse for their own |
|
69 | functions should accept a string, which they can parse for their own | |
70 | needs. This can make some functions easier to type, eg `%cd ../` |
|
70 | needs. This can make some functions easier to type, eg `%cd ../` | |
71 | vs. `%cd("../")` |
|
71 | vs. `%cd("../")` | |
72 |
|
72 | |||
73 | ALL definitions MUST begin with the prefix magic_. The user won't need it |
|
73 | ALL definitions MUST begin with the prefix magic_. The user won't need it | |
74 | at the command line, but it is is needed in the definition. """ |
|
74 | at the command line, but it is is needed in the definition. """ | |
75 |
|
75 | |||
76 | # class globals |
|
76 | # class globals | |
77 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', |
|
77 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', | |
78 | 'Automagic is ON, % prefix NOT needed for magic functions.'] |
|
78 | 'Automagic is ON, % prefix NOT needed for magic functions.'] | |
79 |
|
79 | |||
80 | #...................................................................... |
|
80 | #...................................................................... | |
81 | # some utility functions |
|
81 | # some utility functions | |
82 |
|
82 | |||
83 | def __init__(self,shell): |
|
83 | def __init__(self,shell): | |
84 |
|
84 | |||
85 | self.options_table = {} |
|
85 | self.options_table = {} | |
86 | if profile is None: |
|
86 | if profile is None: | |
87 | self.magic_prun = self.profile_missing_notice |
|
87 | self.magic_prun = self.profile_missing_notice | |
88 | self.shell = shell |
|
88 | self.shell = shell | |
89 |
|
89 | |||
90 | # namespace for holding state we may need |
|
90 | # namespace for holding state we may need | |
91 | self._magic_state = Bunch() |
|
91 | self._magic_state = Bunch() | |
92 |
|
92 | |||
93 | def profile_missing_notice(self, *args, **kwargs): |
|
93 | def profile_missing_notice(self, *args, **kwargs): | |
94 | error("""\ |
|
94 | error("""\ | |
95 | The profile module could not be found. If you are a Debian user, |
|
95 | The profile module could not be found. If you are a Debian user, | |
96 | it has been removed from the standard Debian package because of its non-free |
|
96 | it has been removed from the standard Debian package because of its non-free | |
97 | license. To use profiling, please install"python2.3-profiler" from non-free.""") |
|
97 | license. To use profiling, please install"python2.3-profiler" from non-free.""") | |
98 |
|
98 | |||
99 | def default_option(self,fn,optstr): |
|
99 | def default_option(self,fn,optstr): | |
100 | """Make an entry in the options_table for fn, with value optstr""" |
|
100 | """Make an entry in the options_table for fn, with value optstr""" | |
101 |
|
101 | |||
102 | if fn not in self.lsmagic(): |
|
102 | if fn not in self.lsmagic(): | |
103 | error("%s is not a magic function" % fn) |
|
103 | error("%s is not a magic function" % fn) | |
104 | self.options_table[fn] = optstr |
|
104 | self.options_table[fn] = optstr | |
105 |
|
105 | |||
106 | def lsmagic(self): |
|
106 | def lsmagic(self): | |
107 | """Return a list of currently available magic functions. |
|
107 | """Return a list of currently available magic functions. | |
108 |
|
108 | |||
109 | Gives a list of the bare names after mangling (['ls','cd', ...], not |
|
109 | Gives a list of the bare names after mangling (['ls','cd', ...], not | |
110 | ['magic_ls','magic_cd',...]""" |
|
110 | ['magic_ls','magic_cd',...]""" | |
111 |
|
111 | |||
112 | # FIXME. This needs a cleanup, in the way the magics list is built. |
|
112 | # FIXME. This needs a cleanup, in the way the magics list is built. | |
113 |
|
113 | |||
114 | # magics in class definition |
|
114 | # magics in class definition | |
115 | class_magic = lambda fn: fn.startswith('magic_') and \ |
|
115 | class_magic = lambda fn: fn.startswith('magic_') and \ | |
116 | callable(Magic.__dict__[fn]) |
|
116 | callable(Magic.__dict__[fn]) | |
117 | # in instance namespace (run-time user additions) |
|
117 | # in instance namespace (run-time user additions) | |
118 | inst_magic = lambda fn: fn.startswith('magic_') and \ |
|
118 | inst_magic = lambda fn: fn.startswith('magic_') and \ | |
119 | callable(self.__dict__[fn]) |
|
119 | callable(self.__dict__[fn]) | |
120 | # and bound magics by user (so they can access self): |
|
120 | # and bound magics by user (so they can access self): | |
121 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ |
|
121 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ | |
122 | callable(self.__class__.__dict__[fn]) |
|
122 | callable(self.__class__.__dict__[fn]) | |
123 | magics = filter(class_magic,Magic.__dict__.keys()) + \ |
|
123 | magics = filter(class_magic,Magic.__dict__.keys()) + \ | |
124 | filter(inst_magic,self.__dict__.keys()) + \ |
|
124 | filter(inst_magic,self.__dict__.keys()) + \ | |
125 | filter(inst_bound_magic,self.__class__.__dict__.keys()) |
|
125 | filter(inst_bound_magic,self.__class__.__dict__.keys()) | |
126 | out = [] |
|
126 | out = [] | |
127 | for fn in magics: |
|
127 | for fn in magics: | |
128 | out.append(fn.replace('magic_','',1)) |
|
128 | out.append(fn.replace('magic_','',1)) | |
129 | out.sort() |
|
129 | out.sort() | |
130 | return out |
|
130 | return out | |
131 |
|
131 | |||
132 | def extract_input_slices(self,slices): |
|
132 | def extract_input_slices(self,slices,raw=False): | |
133 | """Return as a string a set of input history slices. |
|
133 | """Return as a string a set of input history slices. | |
134 |
|
134 | |||
135 | The set of slices is given as a list of strings (like ['1','4:8','9'], |
|
135 | Inputs: | |
136 | since this function is for use by magic functions which get their |
|
136 | ||
137 | arguments as strings. |
|
137 | - slices: the set of slices is given as a list of strings (like | |
|
138 | ['1','4:8','9'], since this function is for use by magic functions | |||
|
139 | which get their arguments as strings. | |||
|
140 | ||||
|
141 | Optional inputs: | |||
|
142 | ||||
|
143 | - raw(False): by default, the processed input is used. If this is | |||
|
144 | true, the raw input history is used instead. | |||
138 |
|
145 | |||
139 | Note that slices can be called with two notations: |
|
146 | Note that slices can be called with two notations: | |
140 |
|
147 | |||
141 | N:M -> standard python form, means including items N...(M-1). |
|
148 | N:M -> standard python form, means including items N...(M-1). | |
142 |
|
149 | |||
143 | N-M -> include items N..M (closed endpoint).""" |
|
150 | N-M -> include items N..M (closed endpoint).""" | |
144 |
|
151 | |||
|
152 | if raw: | |||
|
153 | hist = self.shell.input_hist_raw | |||
|
154 | else: | |||
|
155 | hist = self.shell.input_hist | |||
|
156 | ||||
145 | cmds = [] |
|
157 | cmds = [] | |
146 | for chunk in slices: |
|
158 | for chunk in slices: | |
147 | if ':' in chunk: |
|
159 | if ':' in chunk: | |
148 | ini,fin = map(int,chunk.split(':')) |
|
160 | ini,fin = map(int,chunk.split(':')) | |
149 | elif '-' in chunk: |
|
161 | elif '-' in chunk: | |
150 | ini,fin = map(int,chunk.split('-')) |
|
162 | ini,fin = map(int,chunk.split('-')) | |
151 | fin += 1 |
|
163 | fin += 1 | |
152 | else: |
|
164 | else: | |
153 | ini = int(chunk) |
|
165 | ini = int(chunk) | |
154 | fin = ini+1 |
|
166 | fin = ini+1 | |
155 |
cmds.append( |
|
167 | cmds.append(hist[ini:fin]) | |
156 | return cmds |
|
168 | return cmds | |
157 |
|
169 | |||
158 | def _ofind(self,oname): |
|
170 | def _ofind(self,oname): | |
159 | """Find an object in the available namespaces. |
|
171 | """Find an object in the available namespaces. | |
160 |
|
172 | |||
161 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic |
|
173 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic | |
162 |
|
174 | |||
163 | Has special code to detect magic functions. |
|
175 | Has special code to detect magic functions. | |
164 | """ |
|
176 | """ | |
165 |
|
177 | |||
166 | oname = oname.strip() |
|
178 | oname = oname.strip() | |
167 |
|
179 | |||
168 | # Namespaces to search in: |
|
180 | # Namespaces to search in: | |
169 | user_ns = self.shell.user_ns |
|
181 | user_ns = self.shell.user_ns | |
170 | internal_ns = self.shell.internal_ns |
|
182 | internal_ns = self.shell.internal_ns | |
171 | builtin_ns = __builtin__.__dict__ |
|
183 | builtin_ns = __builtin__.__dict__ | |
172 | alias_ns = self.shell.alias_table |
|
184 | alias_ns = self.shell.alias_table | |
173 |
|
185 | |||
174 | # Put them in a list. The order is important so that we find things in |
|
186 | # Put them in a list. The order is important so that we find things in | |
175 | # the same order that Python finds them. |
|
187 | # the same order that Python finds them. | |
176 | namespaces = [ ('Interactive',user_ns), |
|
188 | namespaces = [ ('Interactive',user_ns), | |
177 | ('IPython internal',internal_ns), |
|
189 | ('IPython internal',internal_ns), | |
178 | ('Python builtin',builtin_ns), |
|
190 | ('Python builtin',builtin_ns), | |
179 | ('Alias',alias_ns), |
|
191 | ('Alias',alias_ns), | |
180 | ] |
|
192 | ] | |
181 |
|
193 | |||
182 | # initialize results to 'null' |
|
194 | # initialize results to 'null' | |
183 | found = 0; obj = None; ospace = None; ds = None; |
|
195 | found = 0; obj = None; ospace = None; ds = None; | |
184 | ismagic = 0; isalias = 0 |
|
196 | ismagic = 0; isalias = 0 | |
185 |
|
197 | |||
186 | # Look for the given name by splitting it in parts. If the head is |
|
198 | # Look for the given name by splitting it in parts. If the head is | |
187 | # found, then we look for all the remaining parts as members, and only |
|
199 | # found, then we look for all the remaining parts as members, and only | |
188 | # declare success if we can find them all. |
|
200 | # declare success if we can find them all. | |
189 | oname_parts = oname.split('.') |
|
201 | oname_parts = oname.split('.') | |
190 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] |
|
202 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] | |
191 | for nsname,ns in namespaces: |
|
203 | for nsname,ns in namespaces: | |
192 | try: |
|
204 | try: | |
193 | obj = ns[oname_head] |
|
205 | obj = ns[oname_head] | |
194 | except KeyError: |
|
206 | except KeyError: | |
195 | continue |
|
207 | continue | |
196 | else: |
|
208 | else: | |
197 | for part in oname_rest: |
|
209 | for part in oname_rest: | |
198 | try: |
|
210 | try: | |
199 | obj = getattr(obj,part) |
|
211 | obj = getattr(obj,part) | |
200 | except: |
|
212 | except: | |
201 | # Blanket except b/c some badly implemented objects |
|
213 | # Blanket except b/c some badly implemented objects | |
202 | # allow __getattr__ to raise exceptions other than |
|
214 | # allow __getattr__ to raise exceptions other than | |
203 | # AttributeError, which then crashes IPython. |
|
215 | # AttributeError, which then crashes IPython. | |
204 | break |
|
216 | break | |
205 | else: |
|
217 | else: | |
206 | # If we finish the for loop (no break), we got all members |
|
218 | # If we finish the for loop (no break), we got all members | |
207 | found = 1 |
|
219 | found = 1 | |
208 | ospace = nsname |
|
220 | ospace = nsname | |
209 | if ns == alias_ns: |
|
221 | if ns == alias_ns: | |
210 | isalias = 1 |
|
222 | isalias = 1 | |
211 | break # namespace loop |
|
223 | break # namespace loop | |
212 |
|
224 | |||
213 | # Try to see if it's magic |
|
225 | # Try to see if it's magic | |
214 | if not found: |
|
226 | if not found: | |
215 | if oname.startswith(self.shell.ESC_MAGIC): |
|
227 | if oname.startswith(self.shell.ESC_MAGIC): | |
216 | oname = oname[1:] |
|
228 | oname = oname[1:] | |
217 | obj = getattr(self,'magic_'+oname,None) |
|
229 | obj = getattr(self,'magic_'+oname,None) | |
218 | if obj is not None: |
|
230 | if obj is not None: | |
219 | found = 1 |
|
231 | found = 1 | |
220 | ospace = 'IPython internal' |
|
232 | ospace = 'IPython internal' | |
221 | ismagic = 1 |
|
233 | ismagic = 1 | |
222 |
|
234 | |||
223 | # Last try: special-case some literals like '', [], {}, etc: |
|
235 | # Last try: special-case some literals like '', [], {}, etc: | |
224 | if not found and oname_head in ["''",'""','[]','{}','()']: |
|
236 | if not found and oname_head in ["''",'""','[]','{}','()']: | |
225 | obj = eval(oname_head) |
|
237 | obj = eval(oname_head) | |
226 | found = 1 |
|
238 | found = 1 | |
227 | ospace = 'Interactive' |
|
239 | ospace = 'Interactive' | |
228 |
|
240 | |||
229 | return {'found':found, 'obj':obj, 'namespace':ospace, |
|
241 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
230 | 'ismagic':ismagic, 'isalias':isalias} |
|
242 | 'ismagic':ismagic, 'isalias':isalias} | |
231 |
|
243 | |||
232 | def arg_err(self,func): |
|
244 | def arg_err(self,func): | |
233 | """Print docstring if incorrect arguments were passed""" |
|
245 | """Print docstring if incorrect arguments were passed""" | |
234 | print 'Error in arguments:' |
|
246 | print 'Error in arguments:' | |
235 | print OInspect.getdoc(func) |
|
247 | print OInspect.getdoc(func) | |
236 |
|
248 | |||
237 | def format_latex(self,strng): |
|
249 | def format_latex(self,strng): | |
238 | """Format a string for latex inclusion.""" |
|
250 | """Format a string for latex inclusion.""" | |
239 |
|
251 | |||
240 | # Characters that need to be escaped for latex: |
|
252 | # Characters that need to be escaped for latex: | |
241 | escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE) |
|
253 | escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE) | |
242 | # Magic command names as headers: |
|
254 | # Magic command names as headers: | |
243 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, |
|
255 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, | |
244 | re.MULTILINE) |
|
256 | re.MULTILINE) | |
245 | # Magic commands |
|
257 | # Magic commands | |
246 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, |
|
258 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, | |
247 | re.MULTILINE) |
|
259 | re.MULTILINE) | |
248 | # Paragraph continue |
|
260 | # Paragraph continue | |
249 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
261 | par_re = re.compile(r'\\$',re.MULTILINE) | |
250 |
|
262 | |||
251 | # The "\n" symbol |
|
263 | # The "\n" symbol | |
252 | newline_re = re.compile(r'\\n') |
|
264 | newline_re = re.compile(r'\\n') | |
253 |
|
265 | |||
254 | # Now build the string for output: |
|
266 | # Now build the string for output: | |
255 | #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng) |
|
267 | #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng) | |
256 | strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:', |
|
268 | strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:', | |
257 | strng) |
|
269 | strng) | |
258 | strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng) |
|
270 | strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng) | |
259 | strng = par_re.sub(r'\\\\',strng) |
|
271 | strng = par_re.sub(r'\\\\',strng) | |
260 | strng = escape_re.sub(r'\\\1',strng) |
|
272 | strng = escape_re.sub(r'\\\1',strng) | |
261 | strng = newline_re.sub(r'\\textbackslash{}n',strng) |
|
273 | strng = newline_re.sub(r'\\textbackslash{}n',strng) | |
262 | return strng |
|
274 | return strng | |
263 |
|
275 | |||
264 | def format_screen(self,strng): |
|
276 | def format_screen(self,strng): | |
265 | """Format a string for screen printing. |
|
277 | """Format a string for screen printing. | |
266 |
|
278 | |||
267 | This removes some latex-type format codes.""" |
|
279 | This removes some latex-type format codes.""" | |
268 | # Paragraph continue |
|
280 | # Paragraph continue | |
269 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
281 | par_re = re.compile(r'\\$',re.MULTILINE) | |
270 | strng = par_re.sub('',strng) |
|
282 | strng = par_re.sub('',strng) | |
271 | return strng |
|
283 | return strng | |
272 |
|
284 | |||
273 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): |
|
285 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): | |
274 | """Parse options passed to an argument string. |
|
286 | """Parse options passed to an argument string. | |
275 |
|
287 | |||
276 | The interface is similar to that of getopt(), but it returns back a |
|
288 | The interface is similar to that of getopt(), but it returns back a | |
277 | Struct with the options as keys and the stripped argument string still |
|
289 | Struct with the options as keys and the stripped argument string still | |
278 | as a string. |
|
290 | as a string. | |
279 |
|
291 | |||
280 | arg_str is quoted as a true sys.argv vector by using shlex.split. |
|
292 | arg_str is quoted as a true sys.argv vector by using shlex.split. | |
281 | This allows us to easily expand variables, glob files, quote |
|
293 | This allows us to easily expand variables, glob files, quote | |
282 | arguments, etc. |
|
294 | arguments, etc. | |
283 |
|
295 | |||
284 | Options: |
|
296 | Options: | |
285 | -mode: default 'string'. If given as 'list', the argument string is |
|
297 | -mode: default 'string'. If given as 'list', the argument string is | |
286 | returned as a list (split on whitespace) instead of a string. |
|
298 | returned as a list (split on whitespace) instead of a string. | |
287 |
|
299 | |||
288 | -list_all: put all option values in lists. Normally only options |
|
300 | -list_all: put all option values in lists. Normally only options | |
289 | appearing more than once are put in a list.""" |
|
301 | appearing more than once are put in a list.""" | |
290 |
|
302 | |||
291 | # inject default options at the beginning of the input line |
|
303 | # inject default options at the beginning of the input line | |
292 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') |
|
304 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') | |
293 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) |
|
305 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) | |
294 |
|
306 | |||
295 | mode = kw.get('mode','string') |
|
307 | mode = kw.get('mode','string') | |
296 | if mode not in ['string','list']: |
|
308 | if mode not in ['string','list']: | |
297 | raise ValueError,'incorrect mode given: %s' % mode |
|
309 | raise ValueError,'incorrect mode given: %s' % mode | |
298 | # Get options |
|
310 | # Get options | |
299 | list_all = kw.get('list_all',0) |
|
311 | list_all = kw.get('list_all',0) | |
300 |
|
312 | |||
301 | # Check if we have more than one argument to warrant extra processing: |
|
313 | # Check if we have more than one argument to warrant extra processing: | |
302 | odict = {} # Dictionary with options |
|
314 | odict = {} # Dictionary with options | |
303 | args = arg_str.split() |
|
315 | args = arg_str.split() | |
304 | if len(args) >= 1: |
|
316 | if len(args) >= 1: | |
305 | # If the list of inputs only has 0 or 1 thing in it, there's no |
|
317 | # If the list of inputs only has 0 or 1 thing in it, there's no | |
306 | # need to look for options |
|
318 | # need to look for options | |
307 | argv = shlex_split(arg_str) |
|
319 | argv = shlex_split(arg_str) | |
308 | # Do regular option processing |
|
320 | # Do regular option processing | |
309 | try: |
|
321 | try: | |
310 | opts,args = getopt(argv,opt_str,*long_opts) |
|
322 | opts,args = getopt(argv,opt_str,*long_opts) | |
311 | except GetoptError,e: |
|
323 | except GetoptError,e: | |
312 | raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str, |
|
324 | raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str, | |
313 | " ".join(long_opts))) |
|
325 | " ".join(long_opts))) | |
314 | for o,a in opts: |
|
326 | for o,a in opts: | |
315 | if o.startswith('--'): |
|
327 | if o.startswith('--'): | |
316 | o = o[2:] |
|
328 | o = o[2:] | |
317 | else: |
|
329 | else: | |
318 | o = o[1:] |
|
330 | o = o[1:] | |
319 | try: |
|
331 | try: | |
320 | odict[o].append(a) |
|
332 | odict[o].append(a) | |
321 | except AttributeError: |
|
333 | except AttributeError: | |
322 | odict[o] = [odict[o],a] |
|
334 | odict[o] = [odict[o],a] | |
323 | except KeyError: |
|
335 | except KeyError: | |
324 | if list_all: |
|
336 | if list_all: | |
325 | odict[o] = [a] |
|
337 | odict[o] = [a] | |
326 | else: |
|
338 | else: | |
327 | odict[o] = a |
|
339 | odict[o] = a | |
328 |
|
340 | |||
329 | # Prepare opts,args for return |
|
341 | # Prepare opts,args for return | |
330 | opts = Struct(odict) |
|
342 | opts = Struct(odict) | |
331 | if mode == 'string': |
|
343 | if mode == 'string': | |
332 | args = ' '.join(args) |
|
344 | args = ' '.join(args) | |
333 |
|
345 | |||
334 | return opts,args |
|
346 | return opts,args | |
335 |
|
347 | |||
336 | #...................................................................... |
|
348 | #...................................................................... | |
337 | # And now the actual magic functions |
|
349 | # And now the actual magic functions | |
338 |
|
350 | |||
339 | # Functions for IPython shell work (vars,funcs, config, etc) |
|
351 | # Functions for IPython shell work (vars,funcs, config, etc) | |
340 | def magic_lsmagic(self, parameter_s = ''): |
|
352 | def magic_lsmagic(self, parameter_s = ''): | |
341 | """List currently available magic functions.""" |
|
353 | """List currently available magic functions.""" | |
342 | mesc = self.shell.ESC_MAGIC |
|
354 | mesc = self.shell.ESC_MAGIC | |
343 | print 'Available magic functions:\n'+mesc+\ |
|
355 | print 'Available magic functions:\n'+mesc+\ | |
344 | (' '+mesc).join(self.lsmagic()) |
|
356 | (' '+mesc).join(self.lsmagic()) | |
345 | print '\n' + Magic.auto_status[self.shell.rc.automagic] |
|
357 | print '\n' + Magic.auto_status[self.shell.rc.automagic] | |
346 | return None |
|
358 | return None | |
347 |
|
359 | |||
348 | def magic_magic(self, parameter_s = ''): |
|
360 | def magic_magic(self, parameter_s = ''): | |
349 | """Print information about the magic function system.""" |
|
361 | """Print information about the magic function system.""" | |
350 |
|
362 | |||
351 | mode = '' |
|
363 | mode = '' | |
352 | try: |
|
364 | try: | |
353 | if parameter_s.split()[0] == '-latex': |
|
365 | if parameter_s.split()[0] == '-latex': | |
354 | mode = 'latex' |
|
366 | mode = 'latex' | |
355 | except: |
|
367 | except: | |
356 | pass |
|
368 | pass | |
357 |
|
369 | |||
358 | magic_docs = [] |
|
370 | magic_docs = [] | |
359 | for fname in self.lsmagic(): |
|
371 | for fname in self.lsmagic(): | |
360 | mname = 'magic_' + fname |
|
372 | mname = 'magic_' + fname | |
361 | for space in (Magic,self,self.__class__): |
|
373 | for space in (Magic,self,self.__class__): | |
362 | try: |
|
374 | try: | |
363 | fn = space.__dict__[mname] |
|
375 | fn = space.__dict__[mname] | |
364 | except KeyError: |
|
376 | except KeyError: | |
365 | pass |
|
377 | pass | |
366 | else: |
|
378 | else: | |
367 | break |
|
379 | break | |
368 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, |
|
380 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, | |
369 | fname,fn.__doc__)) |
|
381 | fname,fn.__doc__)) | |
370 | magic_docs = ''.join(magic_docs) |
|
382 | magic_docs = ''.join(magic_docs) | |
371 |
|
383 | |||
372 | if mode == 'latex': |
|
384 | if mode == 'latex': | |
373 | print self.format_latex(magic_docs) |
|
385 | print self.format_latex(magic_docs) | |
374 | return |
|
386 | return | |
375 | else: |
|
387 | else: | |
376 | magic_docs = self.format_screen(magic_docs) |
|
388 | magic_docs = self.format_screen(magic_docs) | |
377 |
|
389 | |||
378 | outmsg = """ |
|
390 | outmsg = """ | |
379 | IPython's 'magic' functions |
|
391 | IPython's 'magic' functions | |
380 | =========================== |
|
392 | =========================== | |
381 |
|
393 | |||
382 | The magic function system provides a series of functions which allow you to |
|
394 | The magic function system provides a series of functions which allow you to | |
383 | control the behavior of IPython itself, plus a lot of system-type |
|
395 | control the behavior of IPython itself, plus a lot of system-type | |
384 | features. All these functions are prefixed with a % character, but parameters |
|
396 | features. All these functions are prefixed with a % character, but parameters | |
385 | are given without parentheses or quotes. |
|
397 | are given without parentheses or quotes. | |
386 |
|
398 | |||
387 | NOTE: If you have 'automagic' enabled (via the command line option or with the |
|
399 | NOTE: If you have 'automagic' enabled (via the command line option or with the | |
388 | %automagic function), you don't need to type in the % explicitly. By default, |
|
400 | %automagic function), you don't need to type in the % explicitly. By default, | |
389 | IPython ships with automagic on, so you should only rarely need the % escape. |
|
401 | IPython ships with automagic on, so you should only rarely need the % escape. | |
390 |
|
402 | |||
391 | Example: typing '%cd mydir' (without the quotes) changes you working directory |
|
403 | Example: typing '%cd mydir' (without the quotes) changes you working directory | |
392 | to 'mydir', if it exists. |
|
404 | to 'mydir', if it exists. | |
393 |
|
405 | |||
394 | You can define your own magic functions to extend the system. See the supplied |
|
406 | You can define your own magic functions to extend the system. See the supplied | |
395 | ipythonrc and example-magic.py files for details (in your ipython |
|
407 | ipythonrc and example-magic.py files for details (in your ipython | |
396 | configuration directory, typically $HOME/.ipython/). |
|
408 | configuration directory, typically $HOME/.ipython/). | |
397 |
|
409 | |||
398 | You can also define your own aliased names for magic functions. In your |
|
410 | You can also define your own aliased names for magic functions. In your | |
399 | ipythonrc file, placing a line like: |
|
411 | ipythonrc file, placing a line like: | |
400 |
|
412 | |||
401 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile |
|
413 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile | |
402 |
|
414 | |||
403 | will define %pf as a new name for %profile. |
|
415 | will define %pf as a new name for %profile. | |
404 |
|
416 | |||
405 | You can also call magics in code using the ipmagic() function, which IPython |
|
417 | You can also call magics in code using the ipmagic() function, which IPython | |
406 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. |
|
418 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. | |
407 |
|
419 | |||
408 | For a list of the available magic functions, use %lsmagic. For a description |
|
420 | For a list of the available magic functions, use %lsmagic. For a description | |
409 | of any of them, type %magic_name?, e.g. '%cd?'. |
|
421 | of any of them, type %magic_name?, e.g. '%cd?'. | |
410 |
|
422 | |||
411 | Currently the magic system has the following functions:\n""" |
|
423 | Currently the magic system has the following functions:\n""" | |
412 |
|
424 | |||
413 | mesc = self.shell.ESC_MAGIC |
|
425 | mesc = self.shell.ESC_MAGIC | |
414 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" |
|
426 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" | |
415 | "\n\n%s%s\n\n%s" % (outmsg, |
|
427 | "\n\n%s%s\n\n%s" % (outmsg, | |
416 | magic_docs,mesc,mesc, |
|
428 | magic_docs,mesc,mesc, | |
417 | (' '+mesc).join(self.lsmagic()), |
|
429 | (' '+mesc).join(self.lsmagic()), | |
418 | Magic.auto_status[self.shell.rc.automagic] ) ) |
|
430 | Magic.auto_status[self.shell.rc.automagic] ) ) | |
419 |
|
431 | |||
420 | page(outmsg,screen_lines=self.shell.rc.screen_length) |
|
432 | page(outmsg,screen_lines=self.shell.rc.screen_length) | |
421 |
|
433 | |||
422 | def magic_automagic(self, parameter_s = ''): |
|
434 | def magic_automagic(self, parameter_s = ''): | |
423 | """Make magic functions callable without having to type the initial %. |
|
435 | """Make magic functions callable without having to type the initial %. | |
424 |
|
436 | |||
425 | Toggles on/off (when off, you must call it as %automagic, of |
|
437 | Toggles on/off (when off, you must call it as %automagic, of | |
426 | course). Note that magic functions have lowest priority, so if there's |
|
438 | course). Note that magic functions have lowest priority, so if there's | |
427 | a variable whose name collides with that of a magic fn, automagic |
|
439 | a variable whose name collides with that of a magic fn, automagic | |
428 | won't work for that function (you get the variable instead). However, |
|
440 | won't work for that function (you get the variable instead). However, | |
429 | if you delete the variable (del var), the previously shadowed magic |
|
441 | if you delete the variable (del var), the previously shadowed magic | |
430 | function becomes visible to automagic again.""" |
|
442 | function becomes visible to automagic again.""" | |
431 |
|
443 | |||
432 | rc = self.shell.rc |
|
444 | rc = self.shell.rc | |
433 | rc.automagic = not rc.automagic |
|
445 | rc.automagic = not rc.automagic | |
434 | print '\n' + Magic.auto_status[rc.automagic] |
|
446 | print '\n' + Magic.auto_status[rc.automagic] | |
435 |
|
447 | |||
436 | def magic_autocall(self, parameter_s = ''): |
|
448 | def magic_autocall(self, parameter_s = ''): | |
437 | """Make functions callable without having to type parentheses. |
|
449 | """Make functions callable without having to type parentheses. | |
438 |
|
450 | |||
439 | Usage: |
|
451 | Usage: | |
440 |
|
452 | |||
441 | %autocall [mode] |
|
453 | %autocall [mode] | |
442 |
|
454 | |||
443 | The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the |
|
455 | The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the | |
444 | value is toggled on and off (remembering the previous state).""" |
|
456 | value is toggled on and off (remembering the previous state).""" | |
445 |
|
457 | |||
446 | rc = self.shell.rc |
|
458 | rc = self.shell.rc | |
447 |
|
459 | |||
448 | if parameter_s: |
|
460 | if parameter_s: | |
449 | arg = int(parameter_s) |
|
461 | arg = int(parameter_s) | |
450 | else: |
|
462 | else: | |
451 | arg = 'toggle' |
|
463 | arg = 'toggle' | |
452 |
|
464 | |||
453 | if not arg in (0,1,2,'toggle'): |
|
465 | if not arg in (0,1,2,'toggle'): | |
454 | error('Valid modes: (0->Off, 1->Smart, 2->Full') |
|
466 | error('Valid modes: (0->Off, 1->Smart, 2->Full') | |
455 | return |
|
467 | return | |
456 |
|
468 | |||
457 | if arg in (0,1,2): |
|
469 | if arg in (0,1,2): | |
458 | rc.autocall = arg |
|
470 | rc.autocall = arg | |
459 | else: # toggle |
|
471 | else: # toggle | |
460 | if rc.autocall: |
|
472 | if rc.autocall: | |
461 | self._magic_state.autocall_save = rc.autocall |
|
473 | self._magic_state.autocall_save = rc.autocall | |
462 | rc.autocall = 0 |
|
474 | rc.autocall = 0 | |
463 | else: |
|
475 | else: | |
464 | try: |
|
476 | try: | |
465 | rc.autocall = self._magic_state.autocall_save |
|
477 | rc.autocall = self._magic_state.autocall_save | |
466 | except AttributeError: |
|
478 | except AttributeError: | |
467 | rc.autocall = self._magic_state.autocall_save = 1 |
|
479 | rc.autocall = self._magic_state.autocall_save = 1 | |
468 |
|
480 | |||
469 | print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall] |
|
481 | print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall] | |
470 |
|
482 | |||
471 | def magic_autoindent(self, parameter_s = ''): |
|
483 | def magic_autoindent(self, parameter_s = ''): | |
472 | """Toggle autoindent on/off (if available).""" |
|
484 | """Toggle autoindent on/off (if available).""" | |
473 |
|
485 | |||
474 | self.shell.set_autoindent() |
|
486 | self.shell.set_autoindent() | |
475 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] |
|
487 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] | |
476 |
|
488 | |||
477 | def magic_system_verbose(self, parameter_s = ''): |
|
489 | def magic_system_verbose(self, parameter_s = ''): | |
478 | """Toggle verbose printing of system calls on/off.""" |
|
490 | """Toggle verbose printing of system calls on/off.""" | |
479 |
|
491 | |||
480 | self.shell.rc_set_toggle('system_verbose') |
|
492 | self.shell.rc_set_toggle('system_verbose') | |
481 | print "System verbose printing is:",\ |
|
493 | print "System verbose printing is:",\ | |
482 | ['OFF','ON'][self.shell.rc.system_verbose] |
|
494 | ['OFF','ON'][self.shell.rc.system_verbose] | |
483 |
|
495 | |||
484 | def magic_history(self, parameter_s = ''): |
|
496 | def magic_history(self, parameter_s = ''): | |
485 | """Print input history (_i<n> variables), with most recent last. |
|
497 | """Print input history (_i<n> variables), with most recent last. | |
486 |
|
498 | |||
487 | %history -> print at most 40 inputs (some may be multi-line)\\ |
|
499 | %history -> print at most 40 inputs (some may be multi-line)\\ | |
488 | %history n -> print at most n inputs\\ |
|
500 | %history n -> print at most n inputs\\ | |
489 | %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ |
|
501 | %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ | |
490 |
|
502 | |||
491 | Each input's number <n> is shown, and is accessible as the |
|
503 | Each input's number <n> is shown, and is accessible as the | |
492 | automatically generated variable _i<n>. Multi-line statements are |
|
504 | automatically generated variable _i<n>. Multi-line statements are | |
493 | printed starting at a new line for easy copy/paste. |
|
505 | printed starting at a new line for easy copy/paste. | |
494 |
|
506 | |||
495 |
|
507 | |||
496 | Options: |
|
508 | Options: | |
497 |
|
509 | |||
498 | -n: do NOT print line numbers. This is useful if you want to get a |
|
510 | -n: do NOT print line numbers. This is useful if you want to get a | |
499 | printout of many lines which can be directly pasted into a text |
|
511 | printout of many lines which can be directly pasted into a text | |
500 | editor. |
|
512 | editor. | |
501 |
|
513 | |||
502 | This feature is only available if numbered prompts are in use. |
|
514 | This feature is only available if numbered prompts are in use. | |
503 |
|
515 | |||
504 | -r: print the 'raw' history. IPython filters your input and |
|
516 | -r: print the 'raw' history. IPython filters your input and | |
505 | converts it all into valid Python source before executing it (things |
|
517 | converts it all into valid Python source before executing it (things | |
506 | like magics or aliases are turned into function calls, for |
|
518 | like magics or aliases are turned into function calls, for | |
507 | example). With this option, you'll see the unfiltered history |
|
519 | example). With this option, you'll see the unfiltered history | |
508 | instead of the filtered version: '%cd /' will be seen as '%cd /' |
|
520 | instead of the filtered version: '%cd /' will be seen as '%cd /' | |
509 | instead of '_ip.magic("%cd /")'. |
|
521 | instead of '_ip.magic("%cd /")'. | |
510 | """ |
|
522 | """ | |
511 |
|
523 | |||
512 | shell = self.shell |
|
524 | shell = self.shell | |
513 | if not shell.outputcache.do_full_cache: |
|
525 | if not shell.outputcache.do_full_cache: | |
514 | print 'This feature is only available if numbered prompts are in use.' |
|
526 | print 'This feature is only available if numbered prompts are in use.' | |
515 | return |
|
527 | return | |
516 | opts,args = self.parse_options(parameter_s,'nr',mode='list') |
|
528 | opts,args = self.parse_options(parameter_s,'nr',mode='list') | |
517 |
|
529 | |||
518 | if opts.has_key('r'): |
|
530 | if opts.has_key('r'): | |
519 | input_hist = shell.input_hist_raw |
|
531 | input_hist = shell.input_hist_raw | |
520 | else: |
|
532 | else: | |
521 | input_hist = shell.input_hist |
|
533 | input_hist = shell.input_hist | |
522 |
|
534 | |||
523 | default_length = 40 |
|
535 | default_length = 40 | |
524 | if len(args) == 0: |
|
536 | if len(args) == 0: | |
525 | final = len(input_hist) |
|
537 | final = len(input_hist) | |
526 | init = max(1,final-default_length) |
|
538 | init = max(1,final-default_length) | |
527 | elif len(args) == 1: |
|
539 | elif len(args) == 1: | |
528 | final = len(input_hist) |
|
540 | final = len(input_hist) | |
529 | init = max(1,final-int(args[0])) |
|
541 | init = max(1,final-int(args[0])) | |
530 | elif len(args) == 2: |
|
542 | elif len(args) == 2: | |
531 | init,final = map(int,args) |
|
543 | init,final = map(int,args) | |
532 | else: |
|
544 | else: | |
533 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') |
|
545 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') | |
534 | print self.magic_hist.__doc__ |
|
546 | print self.magic_hist.__doc__ | |
535 | return |
|
547 | return | |
536 | width = len(str(final)) |
|
548 | width = len(str(final)) | |
537 | line_sep = ['','\n'] |
|
549 | line_sep = ['','\n'] | |
538 | print_nums = not opts.has_key('n') |
|
550 | print_nums = not opts.has_key('n') | |
539 | for in_num in range(init,final): |
|
551 | for in_num in range(init,final): | |
540 | inline = input_hist[in_num] |
|
552 | inline = input_hist[in_num] | |
541 | multiline = int(inline.count('\n') > 1) |
|
553 | multiline = int(inline.count('\n') > 1) | |
542 | if print_nums: |
|
554 | if print_nums: | |
543 | print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), |
|
555 | print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), | |
544 | print inline, |
|
556 | print inline, | |
545 |
|
557 | |||
546 | def magic_hist(self, parameter_s=''): |
|
558 | def magic_hist(self, parameter_s=''): | |
547 | """Alternate name for %history.""" |
|
559 | """Alternate name for %history.""" | |
548 | return self.magic_history(parameter_s) |
|
560 | return self.magic_history(parameter_s) | |
549 |
|
561 | |||
550 | def magic_p(self, parameter_s=''): |
|
562 | def magic_p(self, parameter_s=''): | |
551 | """Just a short alias for Python's 'print'.""" |
|
563 | """Just a short alias for Python's 'print'.""" | |
552 | exec 'print ' + parameter_s in self.shell.user_ns |
|
564 | exec 'print ' + parameter_s in self.shell.user_ns | |
553 |
|
565 | |||
554 | def magic_r(self, parameter_s=''): |
|
566 | def magic_r(self, parameter_s=''): | |
555 | """Repeat previous input. |
|
567 | """Repeat previous input. | |
556 |
|
568 | |||
557 | If given an argument, repeats the previous command which starts with |
|
569 | If given an argument, repeats the previous command which starts with | |
558 | the same string, otherwise it just repeats the previous input. |
|
570 | the same string, otherwise it just repeats the previous input. | |
559 |
|
571 | |||
560 | Shell escaped commands (with ! as first character) are not recognized |
|
572 | Shell escaped commands (with ! as first character) are not recognized | |
561 | by this system, only pure python code and magic commands. |
|
573 | by this system, only pure python code and magic commands. | |
562 | """ |
|
574 | """ | |
563 |
|
575 | |||
564 | start = parameter_s.strip() |
|
576 | start = parameter_s.strip() | |
565 | esc_magic = self.shell.ESC_MAGIC |
|
577 | esc_magic = self.shell.ESC_MAGIC | |
566 | # Identify magic commands even if automagic is on (which means |
|
578 | # Identify magic commands even if automagic is on (which means | |
567 | # the in-memory version is different from that typed by the user). |
|
579 | # the in-memory version is different from that typed by the user). | |
568 | if self.shell.rc.automagic: |
|
580 | if self.shell.rc.automagic: | |
569 | start_magic = esc_magic+start |
|
581 | start_magic = esc_magic+start | |
570 | else: |
|
582 | else: | |
571 | start_magic = start |
|
583 | start_magic = start | |
572 | # Look through the input history in reverse |
|
584 | # Look through the input history in reverse | |
573 | for n in range(len(self.shell.input_hist)-2,0,-1): |
|
585 | for n in range(len(self.shell.input_hist)-2,0,-1): | |
574 | input = self.shell.input_hist[n] |
|
586 | input = self.shell.input_hist[n] | |
575 | # skip plain 'r' lines so we don't recurse to infinity |
|
587 | # skip plain 'r' lines so we don't recurse to infinity | |
576 | if input != '_ip.magic("r")\n' and \ |
|
588 | if input != '_ip.magic("r")\n' and \ | |
577 | (input.startswith(start) or input.startswith(start_magic)): |
|
589 | (input.startswith(start) or input.startswith(start_magic)): | |
578 | #print 'match',`input` # dbg |
|
590 | #print 'match',`input` # dbg | |
579 | print 'Executing:',input, |
|
591 | print 'Executing:',input, | |
580 | self.shell.runlines(input) |
|
592 | self.shell.runlines(input) | |
581 | return |
|
593 | return | |
582 | print 'No previous input matching `%s` found.' % start |
|
594 | print 'No previous input matching `%s` found.' % start | |
583 |
|
595 | |||
584 | def magic_page(self, parameter_s=''): |
|
596 | def magic_page(self, parameter_s=''): | |
585 | """Pretty print the object and display it through a pager. |
|
597 | """Pretty print the object and display it through a pager. | |
586 |
|
598 | |||
587 | If no parameter is given, use _ (last output).""" |
|
599 | If no parameter is given, use _ (last output).""" | |
588 | # After a function contributed by Olivier Aubert, slightly modified. |
|
600 | # After a function contributed by Olivier Aubert, slightly modified. | |
589 |
|
601 | |||
590 | oname = parameter_s and parameter_s or '_' |
|
602 | oname = parameter_s and parameter_s or '_' | |
591 | info = self._ofind(oname) |
|
603 | info = self._ofind(oname) | |
592 | if info['found']: |
|
604 | if info['found']: | |
593 | page(pformat(info['obj'])) |
|
605 | page(pformat(info['obj'])) | |
594 | else: |
|
606 | else: | |
595 | print 'Object `%s` not found' % oname |
|
607 | print 'Object `%s` not found' % oname | |
596 |
|
608 | |||
597 | def magic_profile(self, parameter_s=''): |
|
609 | def magic_profile(self, parameter_s=''): | |
598 | """Print your currently active IPyhton profile.""" |
|
610 | """Print your currently active IPyhton profile.""" | |
599 | if self.shell.rc.profile: |
|
611 | if self.shell.rc.profile: | |
600 | printpl('Current IPython profile: $self.shell.rc.profile.') |
|
612 | printpl('Current IPython profile: $self.shell.rc.profile.') | |
601 | else: |
|
613 | else: | |
602 | print 'No profile active.' |
|
614 | print 'No profile active.' | |
603 |
|
615 | |||
604 | def _inspect(self,meth,oname,**kw): |
|
616 | def _inspect(self,meth,oname,**kw): | |
605 | """Generic interface to the inspector system. |
|
617 | """Generic interface to the inspector system. | |
606 |
|
618 | |||
607 | This function is meant to be called by pdef, pdoc & friends.""" |
|
619 | This function is meant to be called by pdef, pdoc & friends.""" | |
608 |
|
620 | |||
609 | oname = oname.strip() |
|
621 | oname = oname.strip() | |
610 | info = Struct(self._ofind(oname)) |
|
622 | info = Struct(self._ofind(oname)) | |
611 | if info.found: |
|
623 | if info.found: | |
612 | pmethod = getattr(self.shell.inspector,meth) |
|
624 | pmethod = getattr(self.shell.inspector,meth) | |
613 | formatter = info.ismagic and self.format_screen or None |
|
625 | formatter = info.ismagic and self.format_screen or None | |
614 | if meth == 'pdoc': |
|
626 | if meth == 'pdoc': | |
615 | pmethod(info.obj,oname,formatter) |
|
627 | pmethod(info.obj,oname,formatter) | |
616 | elif meth == 'pinfo': |
|
628 | elif meth == 'pinfo': | |
617 | pmethod(info.obj,oname,formatter,info,**kw) |
|
629 | pmethod(info.obj,oname,formatter,info,**kw) | |
618 | else: |
|
630 | else: | |
619 | pmethod(info.obj,oname) |
|
631 | pmethod(info.obj,oname) | |
620 | else: |
|
632 | else: | |
621 | print 'Object `%s` not found.' % oname |
|
633 | print 'Object `%s` not found.' % oname | |
622 | return 'not found' # so callers can take other action |
|
634 | return 'not found' # so callers can take other action | |
623 |
|
635 | |||
624 | def magic_pdef(self, parameter_s=''): |
|
636 | def magic_pdef(self, parameter_s=''): | |
625 | """Print the definition header for any callable object. |
|
637 | """Print the definition header for any callable object. | |
626 |
|
638 | |||
627 | If the object is a class, print the constructor information.""" |
|
639 | If the object is a class, print the constructor information.""" | |
628 | self._inspect('pdef',parameter_s) |
|
640 | self._inspect('pdef',parameter_s) | |
629 |
|
641 | |||
630 | def magic_pdoc(self, parameter_s=''): |
|
642 | def magic_pdoc(self, parameter_s=''): | |
631 | """Print the docstring for an object. |
|
643 | """Print the docstring for an object. | |
632 |
|
644 | |||
633 | If the given object is a class, it will print both the class and the |
|
645 | If the given object is a class, it will print both the class and the | |
634 | constructor docstrings.""" |
|
646 | constructor docstrings.""" | |
635 | self._inspect('pdoc',parameter_s) |
|
647 | self._inspect('pdoc',parameter_s) | |
636 |
|
648 | |||
637 | def magic_psource(self, parameter_s=''): |
|
649 | def magic_psource(self, parameter_s=''): | |
638 | """Print (or run through pager) the source code for an object.""" |
|
650 | """Print (or run through pager) the source code for an object.""" | |
639 | self._inspect('psource',parameter_s) |
|
651 | self._inspect('psource',parameter_s) | |
640 |
|
652 | |||
641 | def magic_pfile(self, parameter_s=''): |
|
653 | def magic_pfile(self, parameter_s=''): | |
642 | """Print (or run through pager) the file where an object is defined. |
|
654 | """Print (or run through pager) the file where an object is defined. | |
643 |
|
655 | |||
644 | The file opens at the line where the object definition begins. IPython |
|
656 | The file opens at the line where the object definition begins. IPython | |
645 | will honor the environment variable PAGER if set, and otherwise will |
|
657 | will honor the environment variable PAGER if set, and otherwise will | |
646 | do its best to print the file in a convenient form. |
|
658 | do its best to print the file in a convenient form. | |
647 |
|
659 | |||
648 | If the given argument is not an object currently defined, IPython will |
|
660 | If the given argument is not an object currently defined, IPython will | |
649 | try to interpret it as a filename (automatically adding a .py extension |
|
661 | try to interpret it as a filename (automatically adding a .py extension | |
650 | if needed). You can thus use %pfile as a syntax highlighting code |
|
662 | if needed). You can thus use %pfile as a syntax highlighting code | |
651 | viewer.""" |
|
663 | viewer.""" | |
652 |
|
664 | |||
653 | # first interpret argument as an object name |
|
665 | # first interpret argument as an object name | |
654 | out = self._inspect('pfile',parameter_s) |
|
666 | out = self._inspect('pfile',parameter_s) | |
655 | # if not, try the input as a filename |
|
667 | # if not, try the input as a filename | |
656 | if out == 'not found': |
|
668 | if out == 'not found': | |
657 | try: |
|
669 | try: | |
658 | filename = get_py_filename(parameter_s) |
|
670 | filename = get_py_filename(parameter_s) | |
659 | except IOError,msg: |
|
671 | except IOError,msg: | |
660 | print msg |
|
672 | print msg | |
661 | return |
|
673 | return | |
662 | page(self.shell.inspector.format(file(filename).read())) |
|
674 | page(self.shell.inspector.format(file(filename).read())) | |
663 |
|
675 | |||
664 | def magic_pinfo(self, parameter_s=''): |
|
676 | def magic_pinfo(self, parameter_s=''): | |
665 | """Provide detailed information about an object. |
|
677 | """Provide detailed information about an object. | |
666 |
|
678 | |||
667 | '%pinfo object' is just a synonym for object? or ?object.""" |
|
679 | '%pinfo object' is just a synonym for object? or ?object.""" | |
668 |
|
680 | |||
669 | #print 'pinfo par: <%s>' % parameter_s # dbg |
|
681 | #print 'pinfo par: <%s>' % parameter_s # dbg | |
670 |
|
682 | |||
671 | # detail_level: 0 -> obj? , 1 -> obj?? |
|
683 | # detail_level: 0 -> obj? , 1 -> obj?? | |
672 | detail_level = 0 |
|
684 | detail_level = 0 | |
673 | # We need to detect if we got called as 'pinfo pinfo foo', which can |
|
685 | # We need to detect if we got called as 'pinfo pinfo foo', which can | |
674 | # happen if the user types 'pinfo foo?' at the cmd line. |
|
686 | # happen if the user types 'pinfo foo?' at the cmd line. | |
675 | pinfo,qmark1,oname,qmark2 = \ |
|
687 | pinfo,qmark1,oname,qmark2 = \ | |
676 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() |
|
688 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() | |
677 | if pinfo or qmark1 or qmark2: |
|
689 | if pinfo or qmark1 or qmark2: | |
678 | detail_level = 1 |
|
690 | detail_level = 1 | |
679 | if "*" in oname: |
|
691 | if "*" in oname: | |
680 | self.magic_psearch(oname) |
|
692 | self.magic_psearch(oname) | |
681 | else: |
|
693 | else: | |
682 | self._inspect('pinfo',oname,detail_level=detail_level) |
|
694 | self._inspect('pinfo',oname,detail_level=detail_level) | |
683 |
|
695 | |||
684 | def magic_psearch(self, parameter_s=''): |
|
696 | def magic_psearch(self, parameter_s=''): | |
685 | """Search for object in namespaces by wildcard. |
|
697 | """Search for object in namespaces by wildcard. | |
686 |
|
698 | |||
687 | %psearch [options] PATTERN [OBJECT TYPE] |
|
699 | %psearch [options] PATTERN [OBJECT TYPE] | |
688 |
|
700 | |||
689 | Note: ? can be used as a synonym for %psearch, at the beginning or at |
|
701 | Note: ? can be used as a synonym for %psearch, at the beginning or at | |
690 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the |
|
702 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the | |
691 | rest of the command line must be unchanged (options come first), so |
|
703 | rest of the command line must be unchanged (options come first), so | |
692 | for example the following forms are equivalent |
|
704 | for example the following forms are equivalent | |
693 |
|
705 | |||
694 | %psearch -i a* function |
|
706 | %psearch -i a* function | |
695 | -i a* function? |
|
707 | -i a* function? | |
696 | ?-i a* function |
|
708 | ?-i a* function | |
697 |
|
709 | |||
698 | Arguments: |
|
710 | Arguments: | |
699 |
|
711 | |||
700 | PATTERN |
|
712 | PATTERN | |
701 |
|
713 | |||
702 | where PATTERN is a string containing * as a wildcard similar to its |
|
714 | where PATTERN is a string containing * as a wildcard similar to its | |
703 | use in a shell. The pattern is matched in all namespaces on the |
|
715 | use in a shell. The pattern is matched in all namespaces on the | |
704 | search path. By default objects starting with a single _ are not |
|
716 | search path. By default objects starting with a single _ are not | |
705 | matched, many IPython generated objects have a single |
|
717 | matched, many IPython generated objects have a single | |
706 | underscore. The default is case insensitive matching. Matching is |
|
718 | underscore. The default is case insensitive matching. Matching is | |
707 | also done on the attributes of objects and not only on the objects |
|
719 | also done on the attributes of objects and not only on the objects | |
708 | in a module. |
|
720 | in a module. | |
709 |
|
721 | |||
710 | [OBJECT TYPE] |
|
722 | [OBJECT TYPE] | |
711 |
|
723 | |||
712 | Is the name of a python type from the types module. The name is |
|
724 | Is the name of a python type from the types module. The name is | |
713 | given in lowercase without the ending type, ex. StringType is |
|
725 | given in lowercase without the ending type, ex. StringType is | |
714 | written string. By adding a type here only objects matching the |
|
726 | written string. By adding a type here only objects matching the | |
715 | given type are matched. Using all here makes the pattern match all |
|
727 | given type are matched. Using all here makes the pattern match all | |
716 | types (this is the default). |
|
728 | types (this is the default). | |
717 |
|
729 | |||
718 | Options: |
|
730 | Options: | |
719 |
|
731 | |||
720 | -a: makes the pattern match even objects whose names start with a |
|
732 | -a: makes the pattern match even objects whose names start with a | |
721 | single underscore. These names are normally ommitted from the |
|
733 | single underscore. These names are normally ommitted from the | |
722 | search. |
|
734 | search. | |
723 |
|
735 | |||
724 | -i/-c: make the pattern case insensitive/sensitive. If neither of |
|
736 | -i/-c: make the pattern case insensitive/sensitive. If neither of | |
725 | these options is given, the default is read from your ipythonrc |
|
737 | these options is given, the default is read from your ipythonrc | |
726 | file. The option name which sets this value is |
|
738 | file. The option name which sets this value is | |
727 | 'wildcards_case_sensitive'. If this option is not specified in your |
|
739 | 'wildcards_case_sensitive'. If this option is not specified in your | |
728 | ipythonrc file, IPython's internal default is to do a case sensitive |
|
740 | ipythonrc file, IPython's internal default is to do a case sensitive | |
729 | search. |
|
741 | search. | |
730 |
|
742 | |||
731 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you |
|
743 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you | |
732 | specifiy can be searched in any of the following namespaces: |
|
744 | specifiy can be searched in any of the following namespaces: | |
733 | 'builtin', 'user', 'user_global','internal', 'alias', where |
|
745 | 'builtin', 'user', 'user_global','internal', 'alias', where | |
734 | 'builtin' and 'user' are the search defaults. Note that you should |
|
746 | 'builtin' and 'user' are the search defaults. Note that you should | |
735 | not use quotes when specifying namespaces. |
|
747 | not use quotes when specifying namespaces. | |
736 |
|
748 | |||
737 | 'Builtin' contains the python module builtin, 'user' contains all |
|
749 | 'Builtin' contains the python module builtin, 'user' contains all | |
738 | user data, 'alias' only contain the shell aliases and no python |
|
750 | user data, 'alias' only contain the shell aliases and no python | |
739 | objects, 'internal' contains objects used by IPython. The |
|
751 | objects, 'internal' contains objects used by IPython. The | |
740 | 'user_global' namespace is only used by embedded IPython instances, |
|
752 | 'user_global' namespace is only used by embedded IPython instances, | |
741 | and it contains module-level globals. You can add namespaces to the |
|
753 | and it contains module-level globals. You can add namespaces to the | |
742 | search with -s or exclude them with -e (these options can be given |
|
754 | search with -s or exclude them with -e (these options can be given | |
743 | more than once). |
|
755 | more than once). | |
744 |
|
756 | |||
745 | Examples: |
|
757 | Examples: | |
746 |
|
758 | |||
747 | %psearch a* -> objects beginning with an a |
|
759 | %psearch a* -> objects beginning with an a | |
748 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a |
|
760 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a | |
749 | %psearch a* function -> all functions beginning with an a |
|
761 | %psearch a* function -> all functions beginning with an a | |
750 | %psearch re.e* -> objects beginning with an e in module re |
|
762 | %psearch re.e* -> objects beginning with an e in module re | |
751 | %psearch r*.e* -> objects that start with e in modules starting in r |
|
763 | %psearch r*.e* -> objects that start with e in modules starting in r | |
752 | %psearch r*.* string -> all strings in modules beginning with r |
|
764 | %psearch r*.* string -> all strings in modules beginning with r | |
753 |
|
765 | |||
754 | Case sensitve search: |
|
766 | Case sensitve search: | |
755 |
|
767 | |||
756 | %psearch -c a* list all object beginning with lower case a |
|
768 | %psearch -c a* list all object beginning with lower case a | |
757 |
|
769 | |||
758 | Show objects beginning with a single _: |
|
770 | Show objects beginning with a single _: | |
759 |
|
771 | |||
760 | %psearch -a _* list objects beginning with a single underscore""" |
|
772 | %psearch -a _* list objects beginning with a single underscore""" | |
761 |
|
773 | |||
762 | # default namespaces to be searched |
|
774 | # default namespaces to be searched | |
763 | def_search = ['user','builtin'] |
|
775 | def_search = ['user','builtin'] | |
764 |
|
776 | |||
765 | # Process options/args |
|
777 | # Process options/args | |
766 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) |
|
778 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) | |
767 | opt = opts.get |
|
779 | opt = opts.get | |
768 | shell = self.shell |
|
780 | shell = self.shell | |
769 | psearch = shell.inspector.psearch |
|
781 | psearch = shell.inspector.psearch | |
770 |
|
782 | |||
771 | # select case options |
|
783 | # select case options | |
772 | if opts.has_key('i'): |
|
784 | if opts.has_key('i'): | |
773 | ignore_case = True |
|
785 | ignore_case = True | |
774 | elif opts.has_key('c'): |
|
786 | elif opts.has_key('c'): | |
775 | ignore_case = False |
|
787 | ignore_case = False | |
776 | else: |
|
788 | else: | |
777 | ignore_case = not shell.rc.wildcards_case_sensitive |
|
789 | ignore_case = not shell.rc.wildcards_case_sensitive | |
778 |
|
790 | |||
779 | # Build list of namespaces to search from user options |
|
791 | # Build list of namespaces to search from user options | |
780 | def_search.extend(opt('s',[])) |
|
792 | def_search.extend(opt('s',[])) | |
781 | ns_exclude = ns_exclude=opt('e',[]) |
|
793 | ns_exclude = ns_exclude=opt('e',[]) | |
782 | ns_search = [nm for nm in def_search if nm not in ns_exclude] |
|
794 | ns_search = [nm for nm in def_search if nm not in ns_exclude] | |
783 |
|
795 | |||
784 | # Call the actual search |
|
796 | # Call the actual search | |
785 | try: |
|
797 | try: | |
786 | psearch(args,shell.ns_table,ns_search, |
|
798 | psearch(args,shell.ns_table,ns_search, | |
787 | show_all=opt('a'),ignore_case=ignore_case) |
|
799 | show_all=opt('a'),ignore_case=ignore_case) | |
788 | except: |
|
800 | except: | |
789 | shell.showtraceback() |
|
801 | shell.showtraceback() | |
790 |
|
802 | |||
791 | def magic_who_ls(self, parameter_s=''): |
|
803 | def magic_who_ls(self, parameter_s=''): | |
792 | """Return a sorted list of all interactive variables. |
|
804 | """Return a sorted list of all interactive variables. | |
793 |
|
805 | |||
794 | If arguments are given, only variables of types matching these |
|
806 | If arguments are given, only variables of types matching these | |
795 | arguments are returned.""" |
|
807 | arguments are returned.""" | |
796 |
|
808 | |||
797 | user_ns = self.shell.user_ns |
|
809 | user_ns = self.shell.user_ns | |
798 | internal_ns = self.shell.internal_ns |
|
810 | internal_ns = self.shell.internal_ns | |
799 | user_config_ns = self.shell.user_config_ns |
|
811 | user_config_ns = self.shell.user_config_ns | |
800 | out = [] |
|
812 | out = [] | |
801 | typelist = parameter_s.split() |
|
813 | typelist = parameter_s.split() | |
802 |
|
814 | |||
803 | for i in user_ns: |
|
815 | for i in user_ns: | |
804 | if not (i.startswith('_') or i.startswith('_i')) \ |
|
816 | if not (i.startswith('_') or i.startswith('_i')) \ | |
805 | and not (i in internal_ns or i in user_config_ns): |
|
817 | and not (i in internal_ns or i in user_config_ns): | |
806 | if typelist: |
|
818 | if typelist: | |
807 | if type(user_ns[i]).__name__ in typelist: |
|
819 | if type(user_ns[i]).__name__ in typelist: | |
808 | out.append(i) |
|
820 | out.append(i) | |
809 | else: |
|
821 | else: | |
810 | out.append(i) |
|
822 | out.append(i) | |
811 | out.sort() |
|
823 | out.sort() | |
812 | return out |
|
824 | return out | |
813 |
|
825 | |||
814 | def magic_who(self, parameter_s=''): |
|
826 | def magic_who(self, parameter_s=''): | |
815 | """Print all interactive variables, with some minimal formatting. |
|
827 | """Print all interactive variables, with some minimal formatting. | |
816 |
|
828 | |||
817 | If any arguments are given, only variables whose type matches one of |
|
829 | If any arguments are given, only variables whose type matches one of | |
818 | these are printed. For example: |
|
830 | these are printed. For example: | |
819 |
|
831 | |||
820 | %who function str |
|
832 | %who function str | |
821 |
|
833 | |||
822 | will only list functions and strings, excluding all other types of |
|
834 | will only list functions and strings, excluding all other types of | |
823 | variables. To find the proper type names, simply use type(var) at a |
|
835 | variables. To find the proper type names, simply use type(var) at a | |
824 | command line to see how python prints type names. For example: |
|
836 | command line to see how python prints type names. For example: | |
825 |
|
837 | |||
826 | In [1]: type('hello')\\ |
|
838 | In [1]: type('hello')\\ | |
827 | Out[1]: <type 'str'> |
|
839 | Out[1]: <type 'str'> | |
828 |
|
840 | |||
829 | indicates that the type name for strings is 'str'. |
|
841 | indicates that the type name for strings is 'str'. | |
830 |
|
842 | |||
831 | %who always excludes executed names loaded through your configuration |
|
843 | %who always excludes executed names loaded through your configuration | |
832 | file and things which are internal to IPython. |
|
844 | file and things which are internal to IPython. | |
833 |
|
845 | |||
834 | This is deliberate, as typically you may load many modules and the |
|
846 | This is deliberate, as typically you may load many modules and the | |
835 | purpose of %who is to show you only what you've manually defined.""" |
|
847 | purpose of %who is to show you only what you've manually defined.""" | |
836 |
|
848 | |||
837 | varlist = self.magic_who_ls(parameter_s) |
|
849 | varlist = self.magic_who_ls(parameter_s) | |
838 | if not varlist: |
|
850 | if not varlist: | |
839 | print 'Interactive namespace is empty.' |
|
851 | print 'Interactive namespace is empty.' | |
840 | return |
|
852 | return | |
841 |
|
853 | |||
842 | # if we have variables, move on... |
|
854 | # if we have variables, move on... | |
843 |
|
855 | |||
844 | # stupid flushing problem: when prompts have no separators, stdout is |
|
856 | # stupid flushing problem: when prompts have no separators, stdout is | |
845 | # getting lost. I'm starting to think this is a python bug. I'm having |
|
857 | # getting lost. I'm starting to think this is a python bug. I'm having | |
846 | # to force a flush with a print because even a sys.stdout.flush |
|
858 | # to force a flush with a print because even a sys.stdout.flush | |
847 | # doesn't seem to do anything! |
|
859 | # doesn't seem to do anything! | |
848 |
|
860 | |||
849 | count = 0 |
|
861 | count = 0 | |
850 | for i in varlist: |
|
862 | for i in varlist: | |
851 | print i+'\t', |
|
863 | print i+'\t', | |
852 | count += 1 |
|
864 | count += 1 | |
853 | if count > 8: |
|
865 | if count > 8: | |
854 | count = 0 |
|
866 | count = 0 | |
855 |
|
867 | |||
856 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? |
|
868 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? | |
857 |
|
869 | |||
858 | print # well, this does force a flush at the expense of an extra \n |
|
870 | print # well, this does force a flush at the expense of an extra \n | |
859 |
|
871 | |||
860 | def magic_whos(self, parameter_s=''): |
|
872 | def magic_whos(self, parameter_s=''): | |
861 | """Like %who, but gives some extra information about each variable. |
|
873 | """Like %who, but gives some extra information about each variable. | |
862 |
|
874 | |||
863 | The same type filtering of %who can be applied here. |
|
875 | The same type filtering of %who can be applied here. | |
864 |
|
876 | |||
865 | For all variables, the type is printed. Additionally it prints: |
|
877 | For all variables, the type is printed. Additionally it prints: | |
866 |
|
878 | |||
867 | - For {},[],(): their length. |
|
879 | - For {},[],(): their length. | |
868 |
|
880 | |||
869 | - For Numeric arrays, a summary with shape, number of elements, |
|
881 | - For Numeric arrays, a summary with shape, number of elements, | |
870 | typecode and size in memory. |
|
882 | typecode and size in memory. | |
871 |
|
883 | |||
872 | - Everything else: a string representation, snipping their middle if |
|
884 | - Everything else: a string representation, snipping their middle if | |
873 | too long.""" |
|
885 | too long.""" | |
874 |
|
886 | |||
875 | varnames = self.magic_who_ls(parameter_s) |
|
887 | varnames = self.magic_who_ls(parameter_s) | |
876 | if not varnames: |
|
888 | if not varnames: | |
877 | print 'Interactive namespace is empty.' |
|
889 | print 'Interactive namespace is empty.' | |
878 | return |
|
890 | return | |
879 |
|
891 | |||
880 | # if we have variables, move on... |
|
892 | # if we have variables, move on... | |
881 |
|
893 | |||
882 | # for these types, show len() instead of data: |
|
894 | # for these types, show len() instead of data: | |
883 | seq_types = [types.DictType,types.ListType,types.TupleType] |
|
895 | seq_types = [types.DictType,types.ListType,types.TupleType] | |
884 |
|
896 | |||
885 | # for Numeric arrays, display summary info |
|
897 | # for Numeric arrays, display summary info | |
886 | try: |
|
898 | try: | |
887 | import Numeric |
|
899 | import Numeric | |
888 | except ImportError: |
|
900 | except ImportError: | |
889 | array_type = None |
|
901 | array_type = None | |
890 | else: |
|
902 | else: | |
891 | array_type = Numeric.ArrayType.__name__ |
|
903 | array_type = Numeric.ArrayType.__name__ | |
892 |
|
904 | |||
893 | # Find all variable names and types so we can figure out column sizes |
|
905 | # Find all variable names and types so we can figure out column sizes | |
894 | get_vars = lambda i: self.shell.user_ns[i] |
|
906 | get_vars = lambda i: self.shell.user_ns[i] | |
895 | type_name = lambda v: type(v).__name__ |
|
907 | type_name = lambda v: type(v).__name__ | |
896 | varlist = map(get_vars,varnames) |
|
908 | varlist = map(get_vars,varnames) | |
897 |
|
909 | |||
898 | typelist = [] |
|
910 | typelist = [] | |
899 | for vv in varlist: |
|
911 | for vv in varlist: | |
900 | tt = type_name(vv) |
|
912 | tt = type_name(vv) | |
901 | if tt=='instance': |
|
913 | if tt=='instance': | |
902 | typelist.append(str(vv.__class__)) |
|
914 | typelist.append(str(vv.__class__)) | |
903 | else: |
|
915 | else: | |
904 | typelist.append(tt) |
|
916 | typelist.append(tt) | |
905 |
|
917 | |||
906 | # column labels and # of spaces as separator |
|
918 | # column labels and # of spaces as separator | |
907 | varlabel = 'Variable' |
|
919 | varlabel = 'Variable' | |
908 | typelabel = 'Type' |
|
920 | typelabel = 'Type' | |
909 | datalabel = 'Data/Info' |
|
921 | datalabel = 'Data/Info' | |
910 | colsep = 3 |
|
922 | colsep = 3 | |
911 | # variable format strings |
|
923 | # variable format strings | |
912 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" |
|
924 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" | |
913 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' |
|
925 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' | |
914 | aformat = "%s: %s elems, type `%s`, %s bytes" |
|
926 | aformat = "%s: %s elems, type `%s`, %s bytes" | |
915 | # find the size of the columns to format the output nicely |
|
927 | # find the size of the columns to format the output nicely | |
916 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep |
|
928 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep | |
917 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep |
|
929 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep | |
918 | # table header |
|
930 | # table header | |
919 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ |
|
931 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ | |
920 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) |
|
932 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) | |
921 | # and the table itself |
|
933 | # and the table itself | |
922 | kb = 1024 |
|
934 | kb = 1024 | |
923 | Mb = 1048576 # kb**2 |
|
935 | Mb = 1048576 # kb**2 | |
924 | for vname,var,vtype in zip(varnames,varlist,typelist): |
|
936 | for vname,var,vtype in zip(varnames,varlist,typelist): | |
925 | print itpl(vformat), |
|
937 | print itpl(vformat), | |
926 | if vtype in seq_types: |
|
938 | if vtype in seq_types: | |
927 | print len(var) |
|
939 | print len(var) | |
928 | elif vtype==array_type: |
|
940 | elif vtype==array_type: | |
929 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] |
|
941 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] | |
930 | vsize = Numeric.size(var) |
|
942 | vsize = Numeric.size(var) | |
931 | vbytes = vsize*var.itemsize() |
|
943 | vbytes = vsize*var.itemsize() | |
932 | if vbytes < 100000: |
|
944 | if vbytes < 100000: | |
933 | print aformat % (vshape,vsize,var.typecode(),vbytes) |
|
945 | print aformat % (vshape,vsize,var.typecode(),vbytes) | |
934 | else: |
|
946 | else: | |
935 | print aformat % (vshape,vsize,var.typecode(),vbytes), |
|
947 | print aformat % (vshape,vsize,var.typecode(),vbytes), | |
936 | if vbytes < Mb: |
|
948 | if vbytes < Mb: | |
937 | print '(%s kb)' % (vbytes/kb,) |
|
949 | print '(%s kb)' % (vbytes/kb,) | |
938 | else: |
|
950 | else: | |
939 | print '(%s Mb)' % (vbytes/Mb,) |
|
951 | print '(%s Mb)' % (vbytes/Mb,) | |
940 | else: |
|
952 | else: | |
941 | vstr = str(var).replace('\n','\\n') |
|
953 | vstr = str(var).replace('\n','\\n') | |
942 | if len(vstr) < 50: |
|
954 | if len(vstr) < 50: | |
943 | print vstr |
|
955 | print vstr | |
944 | else: |
|
956 | else: | |
945 | printpl(vfmt_short) |
|
957 | printpl(vfmt_short) | |
946 |
|
958 | |||
947 | def magic_reset(self, parameter_s=''): |
|
959 | def magic_reset(self, parameter_s=''): | |
948 | """Resets the namespace by removing all names defined by the user. |
|
960 | """Resets the namespace by removing all names defined by the user. | |
949 |
|
961 | |||
950 | Input/Output history are left around in case you need them.""" |
|
962 | Input/Output history are left around in case you need them.""" | |
951 |
|
963 | |||
952 | ans = raw_input( |
|
964 | ans = raw_input( | |
953 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") |
|
965 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") | |
954 | if not ans.lower() == 'y': |
|
966 | if not ans.lower() == 'y': | |
955 | print 'Nothing done.' |
|
967 | print 'Nothing done.' | |
956 | return |
|
968 | return | |
957 | user_ns = self.shell.user_ns |
|
969 | user_ns = self.shell.user_ns | |
958 | for i in self.magic_who_ls(): |
|
970 | for i in self.magic_who_ls(): | |
959 | del(user_ns[i]) |
|
971 | del(user_ns[i]) | |
960 |
|
972 | |||
961 | def magic_config(self,parameter_s=''): |
|
973 | def magic_config(self,parameter_s=''): | |
962 | """Show IPython's internal configuration.""" |
|
974 | """Show IPython's internal configuration.""" | |
963 |
|
975 | |||
964 | page('Current configuration structure:\n'+ |
|
976 | page('Current configuration structure:\n'+ | |
965 | pformat(self.shell.rc.dict())) |
|
977 | pformat(self.shell.rc.dict())) | |
966 |
|
978 | |||
967 | def magic_logstart(self,parameter_s=''): |
|
979 | def magic_logstart(self,parameter_s=''): | |
968 | """Start logging anywhere in a session. |
|
980 | """Start logging anywhere in a session. | |
969 |
|
981 | |||
970 | %logstart [-o|-t] [log_name [log_mode]] |
|
982 | %logstart [-o|-t] [log_name [log_mode]] | |
971 |
|
983 | |||
972 | If no name is given, it defaults to a file named 'ipython_log.py' in your |
|
984 | If no name is given, it defaults to a file named 'ipython_log.py' in your | |
973 | current directory, in 'rotate' mode (see below). |
|
985 | current directory, in 'rotate' mode (see below). | |
974 |
|
986 | |||
975 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your |
|
987 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your | |
976 | history up to that point and then continues logging. |
|
988 | history up to that point and then continues logging. | |
977 |
|
989 | |||
978 | %logstart takes a second optional parameter: logging mode. This can be one |
|
990 | %logstart takes a second optional parameter: logging mode. This can be one | |
979 | of (note that the modes are given unquoted):\\ |
|
991 | of (note that the modes are given unquoted):\\ | |
980 | append: well, that says it.\\ |
|
992 | append: well, that says it.\\ | |
981 | backup: rename (if exists) to name~ and start name.\\ |
|
993 | backup: rename (if exists) to name~ and start name.\\ | |
982 | global: single logfile in your home dir, appended to.\\ |
|
994 | global: single logfile in your home dir, appended to.\\ | |
983 | over : overwrite existing log.\\ |
|
995 | over : overwrite existing log.\\ | |
984 | rotate: create rotating logs name.1~, name.2~, etc. |
|
996 | rotate: create rotating logs name.1~, name.2~, etc. | |
985 |
|
997 | |||
986 | Options: |
|
998 | Options: | |
987 |
|
999 | |||
988 | -o: log also IPython's output. In this mode, all commands which |
|
1000 | -o: log also IPython's output. In this mode, all commands which | |
989 | generate an Out[NN] prompt are recorded to the logfile, right after |
|
1001 | generate an Out[NN] prompt are recorded to the logfile, right after | |
990 | their corresponding input line. The output lines are always |
|
1002 | their corresponding input line. The output lines are always | |
991 | prepended with a '#[Out]# ' marker, so that the log remains valid |
|
1003 | prepended with a '#[Out]# ' marker, so that the log remains valid | |
992 | Python code. |
|
1004 | Python code. | |
993 |
|
1005 | |||
994 | Since this marker is always the same, filtering only the output from |
|
1006 | Since this marker is always the same, filtering only the output from | |
995 | a log is very easy, using for example a simple awk call: |
|
1007 | a log is very easy, using for example a simple awk call: | |
996 |
|
1008 | |||
997 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py |
|
1009 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py | |
998 |
|
1010 | |||
999 | -t: put timestamps before each input line logged (these are put in |
|
1011 | -t: put timestamps before each input line logged (these are put in | |
1000 | comments).""" |
|
1012 | comments).""" | |
1001 |
|
1013 | |||
1002 | opts,par = self.parse_options(parameter_s,'ot') |
|
1014 | opts,par = self.parse_options(parameter_s,'ot') | |
1003 | log_output = 'o' in opts |
|
1015 | log_output = 'o' in opts | |
1004 | timestamp = 't' in opts |
|
1016 | timestamp = 't' in opts | |
1005 |
|
1017 | |||
1006 | rc = self.shell.rc |
|
1018 | rc = self.shell.rc | |
1007 | logger = self.shell.logger |
|
1019 | logger = self.shell.logger | |
1008 |
|
1020 | |||
1009 | # if no args are given, the defaults set in the logger constructor by |
|
1021 | # if no args are given, the defaults set in the logger constructor by | |
1010 | # ipytohn remain valid |
|
1022 | # ipytohn remain valid | |
1011 | if par: |
|
1023 | if par: | |
1012 | try: |
|
1024 | try: | |
1013 | logfname,logmode = par.split() |
|
1025 | logfname,logmode = par.split() | |
1014 | except: |
|
1026 | except: | |
1015 | logfname = par |
|
1027 | logfname = par | |
1016 | logmode = 'backup' |
|
1028 | logmode = 'backup' | |
1017 | else: |
|
1029 | else: | |
1018 | logfname = logger.logfname |
|
1030 | logfname = logger.logfname | |
1019 | logmode = logger.logmode |
|
1031 | logmode = logger.logmode | |
1020 | # put logfname into rc struct as if it had been called on the command |
|
1032 | # put logfname into rc struct as if it had been called on the command | |
1021 | # line, so it ends up saved in the log header Save it in case we need |
|
1033 | # line, so it ends up saved in the log header Save it in case we need | |
1022 | # to restore it... |
|
1034 | # to restore it... | |
1023 | old_logfile = rc.opts.get('logfile','') |
|
1035 | old_logfile = rc.opts.get('logfile','') | |
1024 | if logfname: |
|
1036 | if logfname: | |
1025 | logfname = os.path.expanduser(logfname) |
|
1037 | logfname = os.path.expanduser(logfname) | |
1026 | rc.opts.logfile = logfname |
|
1038 | rc.opts.logfile = logfname | |
1027 | loghead = self.shell.loghead_tpl % (rc.opts,rc.args) |
|
1039 | loghead = self.shell.loghead_tpl % (rc.opts,rc.args) | |
1028 | try: |
|
1040 | try: | |
1029 | started = logger.logstart(logfname,loghead,logmode, |
|
1041 | started = logger.logstart(logfname,loghead,logmode, | |
1030 | log_output,timestamp) |
|
1042 | log_output,timestamp) | |
1031 | except: |
|
1043 | except: | |
1032 | rc.opts.logfile = old_logfile |
|
1044 | rc.opts.logfile = old_logfile | |
1033 | warn("Couldn't start log: %s" % sys.exc_info()[1]) |
|
1045 | warn("Couldn't start log: %s" % sys.exc_info()[1]) | |
1034 | else: |
|
1046 | else: | |
1035 | # log input history up to this point, optionally interleaving |
|
1047 | # log input history up to this point, optionally interleaving | |
1036 | # output if requested |
|
1048 | # output if requested | |
1037 |
|
1049 | |||
1038 | if timestamp: |
|
1050 | if timestamp: | |
1039 | # disable timestamping for the previous history, since we've |
|
1051 | # disable timestamping for the previous history, since we've | |
1040 | # lost those already (no time machine here). |
|
1052 | # lost those already (no time machine here). | |
1041 | logger.timestamp = False |
|
1053 | logger.timestamp = False | |
1042 | if log_output: |
|
1054 | if log_output: | |
1043 | log_write = logger.log_write |
|
1055 | log_write = logger.log_write | |
1044 | input_hist = self.shell.input_hist |
|
1056 | input_hist = self.shell.input_hist | |
1045 | output_hist = self.shell.output_hist |
|
1057 | output_hist = self.shell.output_hist | |
1046 | for n in range(1,len(input_hist)-1): |
|
1058 | for n in range(1,len(input_hist)-1): | |
1047 | log_write(input_hist[n].rstrip()) |
|
1059 | log_write(input_hist[n].rstrip()) | |
1048 | if n in output_hist: |
|
1060 | if n in output_hist: | |
1049 | log_write(repr(output_hist[n]),'output') |
|
1061 | log_write(repr(output_hist[n]),'output') | |
1050 | else: |
|
1062 | else: | |
1051 | logger.log_write(self.shell.input_hist[1:]) |
|
1063 | logger.log_write(self.shell.input_hist[1:]) | |
1052 | if timestamp: |
|
1064 | if timestamp: | |
1053 | # re-enable timestamping |
|
1065 | # re-enable timestamping | |
1054 | logger.timestamp = True |
|
1066 | logger.timestamp = True | |
1055 |
|
1067 | |||
1056 | print ('Activating auto-logging. ' |
|
1068 | print ('Activating auto-logging. ' | |
1057 | 'Current session state plus future input saved.') |
|
1069 | 'Current session state plus future input saved.') | |
1058 | logger.logstate() |
|
1070 | logger.logstate() | |
1059 |
|
1071 | |||
1060 | def magic_logoff(self,parameter_s=''): |
|
1072 | def magic_logoff(self,parameter_s=''): | |
1061 | """Temporarily stop logging. |
|
1073 | """Temporarily stop logging. | |
1062 |
|
1074 | |||
1063 | You must have previously started logging.""" |
|
1075 | You must have previously started logging.""" | |
1064 | self.shell.logger.switch_log(0) |
|
1076 | self.shell.logger.switch_log(0) | |
1065 |
|
1077 | |||
1066 | def magic_logon(self,parameter_s=''): |
|
1078 | def magic_logon(self,parameter_s=''): | |
1067 | """Restart logging. |
|
1079 | """Restart logging. | |
1068 |
|
1080 | |||
1069 | This function is for restarting logging which you've temporarily |
|
1081 | This function is for restarting logging which you've temporarily | |
1070 | stopped with %logoff. For starting logging for the first time, you |
|
1082 | stopped with %logoff. For starting logging for the first time, you | |
1071 | must use the %logstart function, which allows you to specify an |
|
1083 | must use the %logstart function, which allows you to specify an | |
1072 | optional log filename.""" |
|
1084 | optional log filename.""" | |
1073 |
|
1085 | |||
1074 | self.shell.logger.switch_log(1) |
|
1086 | self.shell.logger.switch_log(1) | |
1075 |
|
1087 | |||
1076 | def magic_logstate(self,parameter_s=''): |
|
1088 | def magic_logstate(self,parameter_s=''): | |
1077 | """Print the status of the logging system.""" |
|
1089 | """Print the status of the logging system.""" | |
1078 |
|
1090 | |||
1079 | self.shell.logger.logstate() |
|
1091 | self.shell.logger.logstate() | |
1080 |
|
1092 | |||
1081 | def magic_pdb(self, parameter_s=''): |
|
1093 | def magic_pdb(self, parameter_s=''): | |
1082 | """Control the calling of the pdb interactive debugger. |
|
1094 | """Control the calling of the pdb interactive debugger. | |
1083 |
|
1095 | |||
1084 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without |
|
1096 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without | |
1085 | argument it works as a toggle. |
|
1097 | argument it works as a toggle. | |
1086 |
|
1098 | |||
1087 | When an exception is triggered, IPython can optionally call the |
|
1099 | When an exception is triggered, IPython can optionally call the | |
1088 | interactive pdb debugger after the traceback printout. %pdb toggles |
|
1100 | interactive pdb debugger after the traceback printout. %pdb toggles | |
1089 | this feature on and off.""" |
|
1101 | this feature on and off.""" | |
1090 |
|
1102 | |||
1091 | par = parameter_s.strip().lower() |
|
1103 | par = parameter_s.strip().lower() | |
1092 |
|
1104 | |||
1093 | if par: |
|
1105 | if par: | |
1094 | try: |
|
1106 | try: | |
1095 | new_pdb = {'off':0,'0':0,'on':1,'1':1}[par] |
|
1107 | new_pdb = {'off':0,'0':0,'on':1,'1':1}[par] | |
1096 | except KeyError: |
|
1108 | except KeyError: | |
1097 | print ('Incorrect argument. Use on/1, off/0, ' |
|
1109 | print ('Incorrect argument. Use on/1, off/0, ' | |
1098 | 'or nothing for a toggle.') |
|
1110 | 'or nothing for a toggle.') | |
1099 | return |
|
1111 | return | |
1100 | else: |
|
1112 | else: | |
1101 | # toggle |
|
1113 | # toggle | |
1102 | new_pdb = not self.shell.InteractiveTB.call_pdb |
|
1114 | new_pdb = not self.shell.InteractiveTB.call_pdb | |
1103 |
|
1115 | |||
1104 | # set on the shell |
|
1116 | # set on the shell | |
1105 | self.shell.call_pdb = new_pdb |
|
1117 | self.shell.call_pdb = new_pdb | |
1106 | print 'Automatic pdb calling has been turned',on_off(new_pdb) |
|
1118 | print 'Automatic pdb calling has been turned',on_off(new_pdb) | |
1107 |
|
1119 | |||
1108 | def magic_prun(self, parameter_s ='',user_mode=1, |
|
1120 | def magic_prun(self, parameter_s ='',user_mode=1, | |
1109 | opts=None,arg_lst=None,prog_ns=None): |
|
1121 | opts=None,arg_lst=None,prog_ns=None): | |
1110 |
|
1122 | |||
1111 | """Run a statement through the python code profiler. |
|
1123 | """Run a statement through the python code profiler. | |
1112 |
|
1124 | |||
1113 | Usage:\\ |
|
1125 | Usage:\\ | |
1114 | %prun [options] statement |
|
1126 | %prun [options] statement | |
1115 |
|
1127 | |||
1116 | The given statement (which doesn't require quote marks) is run via the |
|
1128 | The given statement (which doesn't require quote marks) is run via the | |
1117 | python profiler in a manner similar to the profile.run() function. |
|
1129 | python profiler in a manner similar to the profile.run() function. | |
1118 | Namespaces are internally managed to work correctly; profile.run |
|
1130 | Namespaces are internally managed to work correctly; profile.run | |
1119 | cannot be used in IPython because it makes certain assumptions about |
|
1131 | cannot be used in IPython because it makes certain assumptions about | |
1120 | namespaces which do not hold under IPython. |
|
1132 | namespaces which do not hold under IPython. | |
1121 |
|
1133 | |||
1122 | Options: |
|
1134 | Options: | |
1123 |
|
1135 | |||
1124 | -l <limit>: you can place restrictions on what or how much of the |
|
1136 | -l <limit>: you can place restrictions on what or how much of the | |
1125 | profile gets printed. The limit value can be: |
|
1137 | profile gets printed. The limit value can be: | |
1126 |
|
1138 | |||
1127 | * A string: only information for function names containing this string |
|
1139 | * A string: only information for function names containing this string | |
1128 | is printed. |
|
1140 | is printed. | |
1129 |
|
1141 | |||
1130 | * An integer: only these many lines are printed. |
|
1142 | * An integer: only these many lines are printed. | |
1131 |
|
1143 | |||
1132 | * A float (between 0 and 1): this fraction of the report is printed |
|
1144 | * A float (between 0 and 1): this fraction of the report is printed | |
1133 | (for example, use a limit of 0.4 to see the topmost 40% only). |
|
1145 | (for example, use a limit of 0.4 to see the topmost 40% only). | |
1134 |
|
1146 | |||
1135 | You can combine several limits with repeated use of the option. For |
|
1147 | You can combine several limits with repeated use of the option. For | |
1136 | example, '-l __init__ -l 5' will print only the topmost 5 lines of |
|
1148 | example, '-l __init__ -l 5' will print only the topmost 5 lines of | |
1137 | information about class constructors. |
|
1149 | information about class constructors. | |
1138 |
|
1150 | |||
1139 | -r: return the pstats.Stats object generated by the profiling. This |
|
1151 | -r: return the pstats.Stats object generated by the profiling. This | |
1140 | object has all the information about the profile in it, and you can |
|
1152 | object has all the information about the profile in it, and you can | |
1141 | later use it for further analysis or in other functions. |
|
1153 | later use it for further analysis or in other functions. | |
1142 |
|
1154 | |||
1143 | Since magic functions have a particular form of calling which prevents |
|
1155 | Since magic functions have a particular form of calling which prevents | |
1144 | you from writing something like:\\ |
|
1156 | you from writing something like:\\ | |
1145 | In [1]: p = %prun -r print 4 # invalid!\\ |
|
1157 | In [1]: p = %prun -r print 4 # invalid!\\ | |
1146 | you must instead use IPython's automatic variables to assign this:\\ |
|
1158 | you must instead use IPython's automatic variables to assign this:\\ | |
1147 | In [1]: %prun -r print 4 \\ |
|
1159 | In [1]: %prun -r print 4 \\ | |
1148 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ |
|
1160 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ | |
1149 | In [2]: stats = _ |
|
1161 | In [2]: stats = _ | |
1150 |
|
1162 | |||
1151 | If you really need to assign this value via an explicit function call, |
|
1163 | If you really need to assign this value via an explicit function call, | |
1152 | you can always tap directly into the true name of the magic function |
|
1164 | you can always tap directly into the true name of the magic function | |
1153 | by using the _ip.magic function:\\ |
|
1165 | by using the _ip.magic function:\\ | |
1154 | In [3]: stats = _ip.magic('prun','-r print 4') |
|
1166 | In [3]: stats = _ip.magic('prun','-r print 4') | |
1155 |
|
1167 | |||
1156 | You can type _ip.magic? for more details. |
|
1168 | You can type _ip.magic? for more details. | |
1157 |
|
1169 | |||
1158 | -s <key>: sort profile by given key. You can provide more than one key |
|
1170 | -s <key>: sort profile by given key. You can provide more than one key | |
1159 | by using the option several times: '-s key1 -s key2 -s key3...'. The |
|
1171 | by using the option several times: '-s key1 -s key2 -s key3...'. The | |
1160 | default sorting key is 'time'. |
|
1172 | default sorting key is 'time'. | |
1161 |
|
1173 | |||
1162 | The following is copied verbatim from the profile documentation |
|
1174 | The following is copied verbatim from the profile documentation | |
1163 | referenced below: |
|
1175 | referenced below: | |
1164 |
|
1176 | |||
1165 | When more than one key is provided, additional keys are used as |
|
1177 | When more than one key is provided, additional keys are used as | |
1166 | secondary criteria when the there is equality in all keys selected |
|
1178 | secondary criteria when the there is equality in all keys selected | |
1167 | before them. |
|
1179 | before them. | |
1168 |
|
1180 | |||
1169 | Abbreviations can be used for any key names, as long as the |
|
1181 | Abbreviations can be used for any key names, as long as the | |
1170 | abbreviation is unambiguous. The following are the keys currently |
|
1182 | abbreviation is unambiguous. The following are the keys currently | |
1171 | defined: |
|
1183 | defined: | |
1172 |
|
1184 | |||
1173 | Valid Arg Meaning\\ |
|
1185 | Valid Arg Meaning\\ | |
1174 | "calls" call count\\ |
|
1186 | "calls" call count\\ | |
1175 | "cumulative" cumulative time\\ |
|
1187 | "cumulative" cumulative time\\ | |
1176 | "file" file name\\ |
|
1188 | "file" file name\\ | |
1177 | "module" file name\\ |
|
1189 | "module" file name\\ | |
1178 | "pcalls" primitive call count\\ |
|
1190 | "pcalls" primitive call count\\ | |
1179 | "line" line number\\ |
|
1191 | "line" line number\\ | |
1180 | "name" function name\\ |
|
1192 | "name" function name\\ | |
1181 | "nfl" name/file/line\\ |
|
1193 | "nfl" name/file/line\\ | |
1182 | "stdname" standard name\\ |
|
1194 | "stdname" standard name\\ | |
1183 | "time" internal time |
|
1195 | "time" internal time | |
1184 |
|
1196 | |||
1185 | Note that all sorts on statistics are in descending order (placing |
|
1197 | Note that all sorts on statistics are in descending order (placing | |
1186 | most time consuming items first), where as name, file, and line number |
|
1198 | most time consuming items first), where as name, file, and line number | |
1187 | searches are in ascending order (i.e., alphabetical). The subtle |
|
1199 | searches are in ascending order (i.e., alphabetical). The subtle | |
1188 | distinction between "nfl" and "stdname" is that the standard name is a |
|
1200 | distinction between "nfl" and "stdname" is that the standard name is a | |
1189 | sort of the name as printed, which means that the embedded line |
|
1201 | sort of the name as printed, which means that the embedded line | |
1190 | numbers get compared in an odd way. For example, lines 3, 20, and 40 |
|
1202 | numbers get compared in an odd way. For example, lines 3, 20, and 40 | |
1191 | would (if the file names were the same) appear in the string order |
|
1203 | would (if the file names were the same) appear in the string order | |
1192 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the |
|
1204 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the | |
1193 | line numbers. In fact, sort_stats("nfl") is the same as |
|
1205 | line numbers. In fact, sort_stats("nfl") is the same as | |
1194 | sort_stats("name", "file", "line"). |
|
1206 | sort_stats("name", "file", "line"). | |
1195 |
|
1207 | |||
1196 | -T <filename>: save profile results as shown on screen to a text |
|
1208 | -T <filename>: save profile results as shown on screen to a text | |
1197 | file. The profile is still shown on screen. |
|
1209 | file. The profile is still shown on screen. | |
1198 |
|
1210 | |||
1199 | -D <filename>: save (via dump_stats) profile statistics to given |
|
1211 | -D <filename>: save (via dump_stats) profile statistics to given | |
1200 | filename. This data is in a format understod by the pstats module, and |
|
1212 | filename. This data is in a format understod by the pstats module, and | |
1201 | is generated by a call to the dump_stats() method of profile |
|
1213 | is generated by a call to the dump_stats() method of profile | |
1202 | objects. The profile is still shown on screen. |
|
1214 | objects. The profile is still shown on screen. | |
1203 |
|
1215 | |||
1204 | If you want to run complete programs under the profiler's control, use |
|
1216 | If you want to run complete programs under the profiler's control, use | |
1205 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts |
|
1217 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts | |
1206 | contains profiler specific options as described here. |
|
1218 | contains profiler specific options as described here. | |
1207 |
|
1219 | |||
1208 | You can read the complete documentation for the profile module with:\\ |
|
1220 | You can read the complete documentation for the profile module with:\\ | |
1209 | In [1]: import profile; profile.help() """ |
|
1221 | In [1]: import profile; profile.help() """ | |
1210 |
|
1222 | |||
1211 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) |
|
1223 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) | |
1212 | # protect user quote marks |
|
1224 | # protect user quote marks | |
1213 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") |
|
1225 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") | |
1214 |
|
1226 | |||
1215 | if user_mode: # regular user call |
|
1227 | if user_mode: # regular user call | |
1216 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', |
|
1228 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', | |
1217 | list_all=1) |
|
1229 | list_all=1) | |
1218 | namespace = self.shell.user_ns |
|
1230 | namespace = self.shell.user_ns | |
1219 | else: # called to run a program by %run -p |
|
1231 | else: # called to run a program by %run -p | |
1220 | try: |
|
1232 | try: | |
1221 | filename = get_py_filename(arg_lst[0]) |
|
1233 | filename = get_py_filename(arg_lst[0]) | |
1222 | except IOError,msg: |
|
1234 | except IOError,msg: | |
1223 | error(msg) |
|
1235 | error(msg) | |
1224 | return |
|
1236 | return | |
1225 |
|
1237 | |||
1226 | arg_str = 'execfile(filename,prog_ns)' |
|
1238 | arg_str = 'execfile(filename,prog_ns)' | |
1227 | namespace = locals() |
|
1239 | namespace = locals() | |
1228 |
|
1240 | |||
1229 | opts.merge(opts_def) |
|
1241 | opts.merge(opts_def) | |
1230 |
|
1242 | |||
1231 | prof = profile.Profile() |
|
1243 | prof = profile.Profile() | |
1232 | try: |
|
1244 | try: | |
1233 | prof = prof.runctx(arg_str,namespace,namespace) |
|
1245 | prof = prof.runctx(arg_str,namespace,namespace) | |
1234 | sys_exit = '' |
|
1246 | sys_exit = '' | |
1235 | except SystemExit: |
|
1247 | except SystemExit: | |
1236 | sys_exit = """*** SystemExit exception caught in code being profiled.""" |
|
1248 | sys_exit = """*** SystemExit exception caught in code being profiled.""" | |
1237 |
|
1249 | |||
1238 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) |
|
1250 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) | |
1239 |
|
1251 | |||
1240 | lims = opts.l |
|
1252 | lims = opts.l | |
1241 | if lims: |
|
1253 | if lims: | |
1242 | lims = [] # rebuild lims with ints/floats/strings |
|
1254 | lims = [] # rebuild lims with ints/floats/strings | |
1243 | for lim in opts.l: |
|
1255 | for lim in opts.l: | |
1244 | try: |
|
1256 | try: | |
1245 | lims.append(int(lim)) |
|
1257 | lims.append(int(lim)) | |
1246 | except ValueError: |
|
1258 | except ValueError: | |
1247 | try: |
|
1259 | try: | |
1248 | lims.append(float(lim)) |
|
1260 | lims.append(float(lim)) | |
1249 | except ValueError: |
|
1261 | except ValueError: | |
1250 | lims.append(lim) |
|
1262 | lims.append(lim) | |
1251 |
|
1263 | |||
1252 | # trap output |
|
1264 | # trap output | |
1253 | sys_stdout = sys.stdout |
|
1265 | sys_stdout = sys.stdout | |
1254 | stdout_trap = StringIO() |
|
1266 | stdout_trap = StringIO() | |
1255 | try: |
|
1267 | try: | |
1256 | sys.stdout = stdout_trap |
|
1268 | sys.stdout = stdout_trap | |
1257 | stats.print_stats(*lims) |
|
1269 | stats.print_stats(*lims) | |
1258 | finally: |
|
1270 | finally: | |
1259 | sys.stdout = sys_stdout |
|
1271 | sys.stdout = sys_stdout | |
1260 | output = stdout_trap.getvalue() |
|
1272 | output = stdout_trap.getvalue() | |
1261 | output = output.rstrip() |
|
1273 | output = output.rstrip() | |
1262 |
|
1274 | |||
1263 | page(output,screen_lines=self.shell.rc.screen_length) |
|
1275 | page(output,screen_lines=self.shell.rc.screen_length) | |
1264 | print sys_exit, |
|
1276 | print sys_exit, | |
1265 |
|
1277 | |||
1266 | dump_file = opts.D[0] |
|
1278 | dump_file = opts.D[0] | |
1267 | text_file = opts.T[0] |
|
1279 | text_file = opts.T[0] | |
1268 | if dump_file: |
|
1280 | if dump_file: | |
1269 | prof.dump_stats(dump_file) |
|
1281 | prof.dump_stats(dump_file) | |
1270 | print '\n*** Profile stats marshalled to file',\ |
|
1282 | print '\n*** Profile stats marshalled to file',\ | |
1271 | `dump_file`+'.',sys_exit |
|
1283 | `dump_file`+'.',sys_exit | |
1272 | if text_file: |
|
1284 | if text_file: | |
1273 | file(text_file,'w').write(output) |
|
1285 | file(text_file,'w').write(output) | |
1274 | print '\n*** Profile printout saved to text file',\ |
|
1286 | print '\n*** Profile printout saved to text file',\ | |
1275 | `text_file`+'.',sys_exit |
|
1287 | `text_file`+'.',sys_exit | |
1276 |
|
1288 | |||
1277 | if opts.has_key('r'): |
|
1289 | if opts.has_key('r'): | |
1278 | return stats |
|
1290 | return stats | |
1279 | else: |
|
1291 | else: | |
1280 | return None |
|
1292 | return None | |
1281 |
|
1293 | |||
1282 | def magic_run(self, parameter_s ='',runner=None): |
|
1294 | def magic_run(self, parameter_s ='',runner=None): | |
1283 | """Run the named file inside IPython as a program. |
|
1295 | """Run the named file inside IPython as a program. | |
1284 |
|
1296 | |||
1285 | Usage:\\ |
|
1297 | Usage:\\ | |
1286 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] |
|
1298 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] | |
1287 |
|
1299 | |||
1288 | Parameters after the filename are passed as command-line arguments to |
|
1300 | Parameters after the filename are passed as command-line arguments to | |
1289 | the program (put in sys.argv). Then, control returns to IPython's |
|
1301 | the program (put in sys.argv). Then, control returns to IPython's | |
1290 | prompt. |
|
1302 | prompt. | |
1291 |
|
1303 | |||
1292 | This is similar to running at a system prompt:\\ |
|
1304 | This is similar to running at a system prompt:\\ | |
1293 | $ python file args\\ |
|
1305 | $ python file args\\ | |
1294 | but with the advantage of giving you IPython's tracebacks, and of |
|
1306 | but with the advantage of giving you IPython's tracebacks, and of | |
1295 | loading all variables into your interactive namespace for further use |
|
1307 | loading all variables into your interactive namespace for further use | |
1296 | (unless -p is used, see below). |
|
1308 | (unless -p is used, see below). | |
1297 |
|
1309 | |||
1298 | The file is executed in a namespace initially consisting only of |
|
1310 | The file is executed in a namespace initially consisting only of | |
1299 | __name__=='__main__' and sys.argv constructed as indicated. It thus |
|
1311 | __name__=='__main__' and sys.argv constructed as indicated. It thus | |
1300 | sees its environment as if it were being run as a stand-alone |
|
1312 | sees its environment as if it were being run as a stand-alone | |
1301 | program. But after execution, the IPython interactive namespace gets |
|
1313 | program. But after execution, the IPython interactive namespace gets | |
1302 | updated with all variables defined in the program (except for __name__ |
|
1314 | updated with all variables defined in the program (except for __name__ | |
1303 | and sys.argv). This allows for very convenient loading of code for |
|
1315 | and sys.argv). This allows for very convenient loading of code for | |
1304 | interactive work, while giving each program a 'clean sheet' to run in. |
|
1316 | interactive work, while giving each program a 'clean sheet' to run in. | |
1305 |
|
1317 | |||
1306 | Options: |
|
1318 | Options: | |
1307 |
|
1319 | |||
1308 | -n: __name__ is NOT set to '__main__', but to the running file's name |
|
1320 | -n: __name__ is NOT set to '__main__', but to the running file's name | |
1309 | without extension (as python does under import). This allows running |
|
1321 | without extension (as python does under import). This allows running | |
1310 | scripts and reloading the definitions in them without calling code |
|
1322 | scripts and reloading the definitions in them without calling code | |
1311 | protected by an ' if __name__ == "__main__" ' clause. |
|
1323 | protected by an ' if __name__ == "__main__" ' clause. | |
1312 |
|
1324 | |||
1313 | -i: run the file in IPython's namespace instead of an empty one. This |
|
1325 | -i: run the file in IPython's namespace instead of an empty one. This | |
1314 | is useful if you are experimenting with code written in a text editor |
|
1326 | is useful if you are experimenting with code written in a text editor | |
1315 | which depends on variables defined interactively. |
|
1327 | which depends on variables defined interactively. | |
1316 |
|
1328 | |||
1317 | -e: ignore sys.exit() calls or SystemExit exceptions in the script |
|
1329 | -e: ignore sys.exit() calls or SystemExit exceptions in the script | |
1318 | being run. This is particularly useful if IPython is being used to |
|
1330 | being run. This is particularly useful if IPython is being used to | |
1319 | run unittests, which always exit with a sys.exit() call. In such |
|
1331 | run unittests, which always exit with a sys.exit() call. In such | |
1320 | cases you are interested in the output of the test results, not in |
|
1332 | cases you are interested in the output of the test results, not in | |
1321 | seeing a traceback of the unittest module. |
|
1333 | seeing a traceback of the unittest module. | |
1322 |
|
1334 | |||
1323 | -t: print timing information at the end of the run. IPython will give |
|
1335 | -t: print timing information at the end of the run. IPython will give | |
1324 | you an estimated CPU time consumption for your script, which under |
|
1336 | you an estimated CPU time consumption for your script, which under | |
1325 | Unix uses the resource module to avoid the wraparound problems of |
|
1337 | Unix uses the resource module to avoid the wraparound problems of | |
1326 | time.clock(). Under Unix, an estimate of time spent on system tasks |
|
1338 | time.clock(). Under Unix, an estimate of time spent on system tasks | |
1327 | is also given (for Windows platforms this is reported as 0.0). |
|
1339 | is also given (for Windows platforms this is reported as 0.0). | |
1328 |
|
1340 | |||
1329 | If -t is given, an additional -N<N> option can be given, where <N> |
|
1341 | If -t is given, an additional -N<N> option can be given, where <N> | |
1330 | must be an integer indicating how many times you want the script to |
|
1342 | must be an integer indicating how many times you want the script to | |
1331 | run. The final timing report will include total and per run results. |
|
1343 | run. The final timing report will include total and per run results. | |
1332 |
|
1344 | |||
1333 | For example (testing the script uniq_stable.py): |
|
1345 | For example (testing the script uniq_stable.py): | |
1334 |
|
1346 | |||
1335 | In [1]: run -t uniq_stable |
|
1347 | In [1]: run -t uniq_stable | |
1336 |
|
1348 | |||
1337 | IPython CPU timings (estimated):\\ |
|
1349 | IPython CPU timings (estimated):\\ | |
1338 | User : 0.19597 s.\\ |
|
1350 | User : 0.19597 s.\\ | |
1339 | System: 0.0 s.\\ |
|
1351 | System: 0.0 s.\\ | |
1340 |
|
1352 | |||
1341 | In [2]: run -t -N5 uniq_stable |
|
1353 | In [2]: run -t -N5 uniq_stable | |
1342 |
|
1354 | |||
1343 | IPython CPU timings (estimated):\\ |
|
1355 | IPython CPU timings (estimated):\\ | |
1344 | Total runs performed: 5\\ |
|
1356 | Total runs performed: 5\\ | |
1345 | Times : Total Per run\\ |
|
1357 | Times : Total Per run\\ | |
1346 | User : 0.910862 s, 0.1821724 s.\\ |
|
1358 | User : 0.910862 s, 0.1821724 s.\\ | |
1347 | System: 0.0 s, 0.0 s. |
|
1359 | System: 0.0 s, 0.0 s. | |
1348 |
|
1360 | |||
1349 | -d: run your program under the control of pdb, the Python debugger. |
|
1361 | -d: run your program under the control of pdb, the Python debugger. | |
1350 | This allows you to execute your program step by step, watch variables, |
|
1362 | This allows you to execute your program step by step, watch variables, | |
1351 | etc. Internally, what IPython does is similar to calling: |
|
1363 | etc. Internally, what IPython does is similar to calling: | |
1352 |
|
1364 | |||
1353 | pdb.run('execfile("YOURFILENAME")') |
|
1365 | pdb.run('execfile("YOURFILENAME")') | |
1354 |
|
1366 | |||
1355 | with a breakpoint set on line 1 of your file. You can change the line |
|
1367 | with a breakpoint set on line 1 of your file. You can change the line | |
1356 | number for this automatic breakpoint to be <N> by using the -bN option |
|
1368 | number for this automatic breakpoint to be <N> by using the -bN option | |
1357 | (where N must be an integer). For example: |
|
1369 | (where N must be an integer). For example: | |
1358 |
|
1370 | |||
1359 | %run -d -b40 myscript |
|
1371 | %run -d -b40 myscript | |
1360 |
|
1372 | |||
1361 | will set the first breakpoint at line 40 in myscript.py. Note that |
|
1373 | will set the first breakpoint at line 40 in myscript.py. Note that | |
1362 | the first breakpoint must be set on a line which actually does |
|
1374 | the first breakpoint must be set on a line which actually does | |
1363 | something (not a comment or docstring) for it to stop execution. |
|
1375 | something (not a comment or docstring) for it to stop execution. | |
1364 |
|
1376 | |||
1365 | When the pdb debugger starts, you will see a (Pdb) prompt. You must |
|
1377 | When the pdb debugger starts, you will see a (Pdb) prompt. You must | |
1366 | first enter 'c' (without qoutes) to start execution up to the first |
|
1378 | first enter 'c' (without qoutes) to start execution up to the first | |
1367 | breakpoint. |
|
1379 | breakpoint. | |
1368 |
|
1380 | |||
1369 | Entering 'help' gives information about the use of the debugger. You |
|
1381 | Entering 'help' gives information about the use of the debugger. You | |
1370 | can easily see pdb's full documentation with "import pdb;pdb.help()" |
|
1382 | can easily see pdb's full documentation with "import pdb;pdb.help()" | |
1371 | at a prompt. |
|
1383 | at a prompt. | |
1372 |
|
1384 | |||
1373 | -p: run program under the control of the Python profiler module (which |
|
1385 | -p: run program under the control of the Python profiler module (which | |
1374 | prints a detailed report of execution times, function calls, etc). |
|
1386 | prints a detailed report of execution times, function calls, etc). | |
1375 |
|
1387 | |||
1376 | You can pass other options after -p which affect the behavior of the |
|
1388 | You can pass other options after -p which affect the behavior of the | |
1377 | profiler itself. See the docs for %prun for details. |
|
1389 | profiler itself. See the docs for %prun for details. | |
1378 |
|
1390 | |||
1379 | In this mode, the program's variables do NOT propagate back to the |
|
1391 | In this mode, the program's variables do NOT propagate back to the | |
1380 | IPython interactive namespace (because they remain in the namespace |
|
1392 | IPython interactive namespace (because they remain in the namespace | |
1381 | where the profiler executes them). |
|
1393 | where the profiler executes them). | |
1382 |
|
1394 | |||
1383 | Internally this triggers a call to %prun, see its documentation for |
|
1395 | Internally this triggers a call to %prun, see its documentation for | |
1384 | details on the options available specifically for profiling.""" |
|
1396 | details on the options available specifically for profiling.""" | |
1385 |
|
1397 | |||
1386 | # get arguments and set sys.argv for program to be run. |
|
1398 | # get arguments and set sys.argv for program to be run. | |
1387 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', |
|
1399 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', | |
1388 | mode='list',list_all=1) |
|
1400 | mode='list',list_all=1) | |
1389 |
|
1401 | |||
1390 | try: |
|
1402 | try: | |
1391 | filename = get_py_filename(arg_lst[0]) |
|
1403 | filename = get_py_filename(arg_lst[0]) | |
1392 | except IndexError: |
|
1404 | except IndexError: | |
1393 | warn('you must provide at least a filename.') |
|
1405 | warn('you must provide at least a filename.') | |
1394 | print '\n%run:\n',OInspect.getdoc(self.magic_run) |
|
1406 | print '\n%run:\n',OInspect.getdoc(self.magic_run) | |
1395 | return |
|
1407 | return | |
1396 | except IOError,msg: |
|
1408 | except IOError,msg: | |
1397 | error(msg) |
|
1409 | error(msg) | |
1398 | return |
|
1410 | return | |
1399 |
|
1411 | |||
1400 | # Control the response to exit() calls made by the script being run |
|
1412 | # Control the response to exit() calls made by the script being run | |
1401 | exit_ignore = opts.has_key('e') |
|
1413 | exit_ignore = opts.has_key('e') | |
1402 |
|
1414 | |||
1403 | # Make sure that the running script gets a proper sys.argv as if it |
|
1415 | # Make sure that the running script gets a proper sys.argv as if it | |
1404 | # were run from a system shell. |
|
1416 | # were run from a system shell. | |
1405 | save_argv = sys.argv # save it for later restoring |
|
1417 | save_argv = sys.argv # save it for later restoring | |
1406 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename |
|
1418 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename | |
1407 |
|
1419 | |||
1408 | if opts.has_key('i'): |
|
1420 | if opts.has_key('i'): | |
1409 | prog_ns = self.shell.user_ns |
|
1421 | prog_ns = self.shell.user_ns | |
1410 | __name__save = self.shell.user_ns['__name__'] |
|
1422 | __name__save = self.shell.user_ns['__name__'] | |
1411 | prog_ns['__name__'] = '__main__' |
|
1423 | prog_ns['__name__'] = '__main__' | |
1412 | else: |
|
1424 | else: | |
1413 | if opts.has_key('n'): |
|
1425 | if opts.has_key('n'): | |
1414 | name = os.path.splitext(os.path.basename(filename))[0] |
|
1426 | name = os.path.splitext(os.path.basename(filename))[0] | |
1415 | else: |
|
1427 | else: | |
1416 | name = '__main__' |
|
1428 | name = '__main__' | |
1417 | prog_ns = {'__name__':name} |
|
1429 | prog_ns = {'__name__':name} | |
1418 |
|
1430 | |||
1419 | # Since '%run foo' emulates 'python foo.py' at the cmd line, we must |
|
1431 | # Since '%run foo' emulates 'python foo.py' at the cmd line, we must | |
1420 | # set the __file__ global in the script's namespace |
|
1432 | # set the __file__ global in the script's namespace | |
1421 | prog_ns['__file__'] = filename |
|
1433 | prog_ns['__file__'] = filename | |
1422 |
|
1434 | |||
1423 | # pickle fix. See iplib for an explanation. But we need to make sure |
|
1435 | # pickle fix. See iplib for an explanation. But we need to make sure | |
1424 | # that, if we overwrite __main__, we replace it at the end |
|
1436 | # that, if we overwrite __main__, we replace it at the end | |
1425 | if prog_ns['__name__'] == '__main__': |
|
1437 | if prog_ns['__name__'] == '__main__': | |
1426 | restore_main = sys.modules['__main__'] |
|
1438 | restore_main = sys.modules['__main__'] | |
1427 | else: |
|
1439 | else: | |
1428 | restore_main = False |
|
1440 | restore_main = False | |
1429 |
|
1441 | |||
1430 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) |
|
1442 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) | |
1431 |
|
1443 | |||
1432 | stats = None |
|
1444 | stats = None | |
1433 | try: |
|
1445 | try: | |
1434 | if opts.has_key('p'): |
|
1446 | if opts.has_key('p'): | |
1435 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) |
|
1447 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) | |
1436 | else: |
|
1448 | else: | |
1437 | if opts.has_key('d'): |
|
1449 | if opts.has_key('d'): | |
1438 | deb = Debugger.Pdb(self.shell.rc.colors) |
|
1450 | deb = Debugger.Pdb(self.shell.rc.colors) | |
1439 | # reset Breakpoint state, which is moronically kept |
|
1451 | # reset Breakpoint state, which is moronically kept | |
1440 | # in a class |
|
1452 | # in a class | |
1441 | bdb.Breakpoint.next = 1 |
|
1453 | bdb.Breakpoint.next = 1 | |
1442 | bdb.Breakpoint.bplist = {} |
|
1454 | bdb.Breakpoint.bplist = {} | |
1443 | bdb.Breakpoint.bpbynumber = [None] |
|
1455 | bdb.Breakpoint.bpbynumber = [None] | |
1444 | # Set an initial breakpoint to stop execution |
|
1456 | # Set an initial breakpoint to stop execution | |
1445 | maxtries = 10 |
|
1457 | maxtries = 10 | |
1446 | bp = int(opts.get('b',[1])[0]) |
|
1458 | bp = int(opts.get('b',[1])[0]) | |
1447 | checkline = deb.checkline(filename,bp) |
|
1459 | checkline = deb.checkline(filename,bp) | |
1448 | if not checkline: |
|
1460 | if not checkline: | |
1449 | for bp in range(bp+1,bp+maxtries+1): |
|
1461 | for bp in range(bp+1,bp+maxtries+1): | |
1450 | if deb.checkline(filename,bp): |
|
1462 | if deb.checkline(filename,bp): | |
1451 | break |
|
1463 | break | |
1452 | else: |
|
1464 | else: | |
1453 | msg = ("\nI failed to find a valid line to set " |
|
1465 | msg = ("\nI failed to find a valid line to set " | |
1454 | "a breakpoint\n" |
|
1466 | "a breakpoint\n" | |
1455 | "after trying up to line: %s.\n" |
|
1467 | "after trying up to line: %s.\n" | |
1456 | "Please set a valid breakpoint manually " |
|
1468 | "Please set a valid breakpoint manually " | |
1457 | "with the -b option." % bp) |
|
1469 | "with the -b option." % bp) | |
1458 | error(msg) |
|
1470 | error(msg) | |
1459 | return |
|
1471 | return | |
1460 | # if we find a good linenumber, set the breakpoint |
|
1472 | # if we find a good linenumber, set the breakpoint | |
1461 | deb.do_break('%s:%s' % (filename,bp)) |
|
1473 | deb.do_break('%s:%s' % (filename,bp)) | |
1462 | # Start file run |
|
1474 | # Start file run | |
1463 | print "NOTE: Enter 'c' at the", |
|
1475 | print "NOTE: Enter 'c' at the", | |
1464 | print "ipdb> prompt to start your script." |
|
1476 | print "ipdb> prompt to start your script." | |
1465 | try: |
|
1477 | try: | |
1466 | deb.run('execfile("%s")' % filename,prog_ns) |
|
1478 | deb.run('execfile("%s")' % filename,prog_ns) | |
1467 | except: |
|
1479 | except: | |
1468 | etype, value, tb = sys.exc_info() |
|
1480 | etype, value, tb = sys.exc_info() | |
1469 | # Skip three frames in the traceback: the %run one, |
|
1481 | # Skip three frames in the traceback: the %run one, | |
1470 | # one inside bdb.py, and the command-line typed by the |
|
1482 | # one inside bdb.py, and the command-line typed by the | |
1471 | # user (run by exec in pdb itself). |
|
1483 | # user (run by exec in pdb itself). | |
1472 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) |
|
1484 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) | |
1473 | else: |
|
1485 | else: | |
1474 | if runner is None: |
|
1486 | if runner is None: | |
1475 | runner = self.shell.safe_execfile |
|
1487 | runner = self.shell.safe_execfile | |
1476 | if opts.has_key('t'): |
|
1488 | if opts.has_key('t'): | |
1477 | try: |
|
1489 | try: | |
1478 | nruns = int(opts['N'][0]) |
|
1490 | nruns = int(opts['N'][0]) | |
1479 | if nruns < 1: |
|
1491 | if nruns < 1: | |
1480 | error('Number of runs must be >=1') |
|
1492 | error('Number of runs must be >=1') | |
1481 | return |
|
1493 | return | |
1482 | except (KeyError): |
|
1494 | except (KeyError): | |
1483 | nruns = 1 |
|
1495 | nruns = 1 | |
1484 | if nruns == 1: |
|
1496 | if nruns == 1: | |
1485 | t0 = clock2() |
|
1497 | t0 = clock2() | |
1486 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1498 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1487 | t1 = clock2() |
|
1499 | t1 = clock2() | |
1488 | t_usr = t1[0]-t0[0] |
|
1500 | t_usr = t1[0]-t0[0] | |
1489 | t_sys = t1[1]-t1[1] |
|
1501 | t_sys = t1[1]-t1[1] | |
1490 | print "\nIPython CPU timings (estimated):" |
|
1502 | print "\nIPython CPU timings (estimated):" | |
1491 | print " User : %10s s." % t_usr |
|
1503 | print " User : %10s s." % t_usr | |
1492 | print " System: %10s s." % t_sys |
|
1504 | print " System: %10s s." % t_sys | |
1493 | else: |
|
1505 | else: | |
1494 | runs = range(nruns) |
|
1506 | runs = range(nruns) | |
1495 | t0 = clock2() |
|
1507 | t0 = clock2() | |
1496 | for nr in runs: |
|
1508 | for nr in runs: | |
1497 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1509 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1498 | t1 = clock2() |
|
1510 | t1 = clock2() | |
1499 | t_usr = t1[0]-t0[0] |
|
1511 | t_usr = t1[0]-t0[0] | |
1500 | t_sys = t1[1]-t1[1] |
|
1512 | t_sys = t1[1]-t1[1] | |
1501 | print "\nIPython CPU timings (estimated):" |
|
1513 | print "\nIPython CPU timings (estimated):" | |
1502 | print "Total runs performed:",nruns |
|
1514 | print "Total runs performed:",nruns | |
1503 | print " Times : %10s %10s" % ('Total','Per run') |
|
1515 | print " Times : %10s %10s" % ('Total','Per run') | |
1504 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) |
|
1516 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) | |
1505 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) |
|
1517 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) | |
1506 |
|
1518 | |||
1507 | else: |
|
1519 | else: | |
1508 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1520 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1509 | if opts.has_key('i'): |
|
1521 | if opts.has_key('i'): | |
1510 | self.shell.user_ns['__name__'] = __name__save |
|
1522 | self.shell.user_ns['__name__'] = __name__save | |
1511 | else: |
|
1523 | else: | |
1512 | # update IPython interactive namespace |
|
1524 | # update IPython interactive namespace | |
1513 | del prog_ns['__name__'] |
|
1525 | del prog_ns['__name__'] | |
1514 | self.shell.user_ns.update(prog_ns) |
|
1526 | self.shell.user_ns.update(prog_ns) | |
1515 | finally: |
|
1527 | finally: | |
1516 | sys.argv = save_argv |
|
1528 | sys.argv = save_argv | |
1517 | if restore_main: |
|
1529 | if restore_main: | |
1518 | sys.modules['__main__'] = restore_main |
|
1530 | sys.modules['__main__'] = restore_main | |
1519 | return stats |
|
1531 | return stats | |
1520 |
|
1532 | |||
1521 | def magic_runlog(self, parameter_s =''): |
|
1533 | def magic_runlog(self, parameter_s =''): | |
1522 | """Run files as logs. |
|
1534 | """Run files as logs. | |
1523 |
|
1535 | |||
1524 | Usage:\\ |
|
1536 | Usage:\\ | |
1525 | %runlog file1 file2 ... |
|
1537 | %runlog file1 file2 ... | |
1526 |
|
1538 | |||
1527 | Run the named files (treating them as log files) in sequence inside |
|
1539 | Run the named files (treating them as log files) in sequence inside | |
1528 | the interpreter, and return to the prompt. This is much slower than |
|
1540 | the interpreter, and return to the prompt. This is much slower than | |
1529 | %run because each line is executed in a try/except block, but it |
|
1541 | %run because each line is executed in a try/except block, but it | |
1530 | allows running files with syntax errors in them. |
|
1542 | allows running files with syntax errors in them. | |
1531 |
|
1543 | |||
1532 | Normally IPython will guess when a file is one of its own logfiles, so |
|
1544 | Normally IPython will guess when a file is one of its own logfiles, so | |
1533 | you can typically use %run even for logs. This shorthand allows you to |
|
1545 | you can typically use %run even for logs. This shorthand allows you to | |
1534 | force any file to be treated as a log file.""" |
|
1546 | force any file to be treated as a log file.""" | |
1535 |
|
1547 | |||
1536 | for f in parameter_s.split(): |
|
1548 | for f in parameter_s.split(): | |
1537 | self.shell.safe_execfile(f,self.shell.user_ns, |
|
1549 | self.shell.safe_execfile(f,self.shell.user_ns, | |
1538 | self.shell.user_ns,islog=1) |
|
1550 | self.shell.user_ns,islog=1) | |
1539 |
|
1551 | |||
1540 | def magic_time(self,parameter_s = ''): |
|
1552 | def magic_time(self,parameter_s = ''): | |
1541 | """Time execution of a Python statement or expression. |
|
1553 | """Time execution of a Python statement or expression. | |
1542 |
|
1554 | |||
1543 | The CPU and wall clock times are printed, and the value of the |
|
1555 | The CPU and wall clock times are printed, and the value of the | |
1544 | expression (if any) is returned. Note that under Win32, system time |
|
1556 | expression (if any) is returned. Note that under Win32, system time | |
1545 | is always reported as 0, since it can not be measured. |
|
1557 | is always reported as 0, since it can not be measured. | |
1546 |
|
1558 | |||
1547 | This function provides very basic timing functionality. In Python |
|
1559 | This function provides very basic timing functionality. In Python | |
1548 | 2.3, the timeit module offers more control and sophistication, but for |
|
1560 | 2.3, the timeit module offers more control and sophistication, but for | |
1549 | now IPython supports Python 2.2, so we can not rely on timeit being |
|
1561 | now IPython supports Python 2.2, so we can not rely on timeit being | |
1550 | present. |
|
1562 | present. | |
1551 |
|
1563 | |||
1552 | Some examples: |
|
1564 | Some examples: | |
1553 |
|
1565 | |||
1554 | In [1]: time 2**128 |
|
1566 | In [1]: time 2**128 | |
1555 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1567 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1556 | Wall time: 0.00 |
|
1568 | Wall time: 0.00 | |
1557 | Out[1]: 340282366920938463463374607431768211456L |
|
1569 | Out[1]: 340282366920938463463374607431768211456L | |
1558 |
|
1570 | |||
1559 | In [2]: n = 1000000 |
|
1571 | In [2]: n = 1000000 | |
1560 |
|
1572 | |||
1561 | In [3]: time sum(range(n)) |
|
1573 | In [3]: time sum(range(n)) | |
1562 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s |
|
1574 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s | |
1563 | Wall time: 1.37 |
|
1575 | Wall time: 1.37 | |
1564 | Out[3]: 499999500000L |
|
1576 | Out[3]: 499999500000L | |
1565 |
|
1577 | |||
1566 | In [4]: time print 'hello world' |
|
1578 | In [4]: time print 'hello world' | |
1567 | hello world |
|
1579 | hello world | |
1568 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1580 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1569 | Wall time: 0.00 |
|
1581 | Wall time: 0.00 | |
1570 | """ |
|
1582 | """ | |
1571 |
|
1583 | |||
1572 | # fail immediately if the given expression can't be compiled |
|
1584 | # fail immediately if the given expression can't be compiled | |
1573 | try: |
|
1585 | try: | |
1574 | mode = 'eval' |
|
1586 | mode = 'eval' | |
1575 | code = compile(parameter_s,'<timed eval>',mode) |
|
1587 | code = compile(parameter_s,'<timed eval>',mode) | |
1576 | except SyntaxError: |
|
1588 | except SyntaxError: | |
1577 | mode = 'exec' |
|
1589 | mode = 'exec' | |
1578 | code = compile(parameter_s,'<timed exec>',mode) |
|
1590 | code = compile(parameter_s,'<timed exec>',mode) | |
1579 | # skew measurement as little as possible |
|
1591 | # skew measurement as little as possible | |
1580 | glob = self.shell.user_ns |
|
1592 | glob = self.shell.user_ns | |
1581 | clk = clock2 |
|
1593 | clk = clock2 | |
1582 | wtime = time.time |
|
1594 | wtime = time.time | |
1583 | # time execution |
|
1595 | # time execution | |
1584 | wall_st = wtime() |
|
1596 | wall_st = wtime() | |
1585 | if mode=='eval': |
|
1597 | if mode=='eval': | |
1586 | st = clk() |
|
1598 | st = clk() | |
1587 | out = eval(code,glob) |
|
1599 | out = eval(code,glob) | |
1588 | end = clk() |
|
1600 | end = clk() | |
1589 | else: |
|
1601 | else: | |
1590 | st = clk() |
|
1602 | st = clk() | |
1591 | exec code in glob |
|
1603 | exec code in glob | |
1592 | end = clk() |
|
1604 | end = clk() | |
1593 | out = None |
|
1605 | out = None | |
1594 | wall_end = wtime() |
|
1606 | wall_end = wtime() | |
1595 | # Compute actual times and report |
|
1607 | # Compute actual times and report | |
1596 | wall_time = wall_end-wall_st |
|
1608 | wall_time = wall_end-wall_st | |
1597 | cpu_user = end[0]-st[0] |
|
1609 | cpu_user = end[0]-st[0] | |
1598 | cpu_sys = end[1]-st[1] |
|
1610 | cpu_sys = end[1]-st[1] | |
1599 | cpu_tot = cpu_user+cpu_sys |
|
1611 | cpu_tot = cpu_user+cpu_sys | |
1600 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ |
|
1612 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ | |
1601 | (cpu_user,cpu_sys,cpu_tot) |
|
1613 | (cpu_user,cpu_sys,cpu_tot) | |
1602 | print "Wall time: %.2f" % wall_time |
|
1614 | print "Wall time: %.2f" % wall_time | |
1603 | return out |
|
1615 | return out | |
1604 |
|
1616 | |||
1605 | def magic_macro(self,parameter_s = ''): |
|
1617 | def magic_macro(self,parameter_s = ''): | |
1606 | """Define a set of input lines as a macro for future re-execution. |
|
1618 | """Define a set of input lines as a macro for future re-execution. | |
1607 |
|
1619 | |||
1608 | Usage:\\ |
|
1620 | Usage:\\ | |
1609 | %macro name n1-n2 n3-n4 ... n5 .. n6 ... |
|
1621 | %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ... | |
|
1622 | ||||
|
1623 | Options: | |||
|
1624 | ||||
|
1625 | -r: use 'raw' input. By default, the 'processed' history is used, | |||
|
1626 | so that magics are loaded in their transformed version to valid | |||
|
1627 | Python. If this option is given, the raw input as typed as the | |||
|
1628 | command line is used instead. | |||
1610 |
|
1629 | |||
1611 | This will define a global variable called `name` which is a string |
|
1630 | This will define a global variable called `name` which is a string | |
1612 | made of joining the slices and lines you specify (n1,n2,... numbers |
|
1631 | made of joining the slices and lines you specify (n1,n2,... numbers | |
1613 | above) from your input history into a single string. This variable |
|
1632 | above) from your input history into a single string. This variable | |
1614 | acts like an automatic function which re-executes those lines as if |
|
1633 | acts like an automatic function which re-executes those lines as if | |
1615 | you had typed them. You just type 'name' at the prompt and the code |
|
1634 | you had typed them. You just type 'name' at the prompt and the code | |
1616 | executes. |
|
1635 | executes. | |
1617 |
|
1636 | |||
1618 | The notation for indicating number ranges is: n1-n2 means 'use line |
|
1637 | The notation for indicating number ranges is: n1-n2 means 'use line | |
1619 | numbers n1,...n2' (the endpoint is included). That is, '5-7' means |
|
1638 | numbers n1,...n2' (the endpoint is included). That is, '5-7' means | |
1620 | using the lines numbered 5,6 and 7. |
|
1639 | using the lines numbered 5,6 and 7. | |
1621 |
|
1640 | |||
1622 | Note: as a 'hidden' feature, you can also use traditional python slice |
|
1641 | Note: as a 'hidden' feature, you can also use traditional python slice | |
1623 | notation, where N:M means numbers N through M-1. |
|
1642 | notation, where N:M means numbers N through M-1. | |
1624 |
|
1643 | |||
1625 | For example, if your history contains (%hist prints it): |
|
1644 | For example, if your history contains (%hist prints it): | |
1626 |
|
1645 | |||
1627 | 44: x=1\\ |
|
1646 | 44: x=1\\ | |
1628 | 45: y=3\\ |
|
1647 | 45: y=3\\ | |
1629 | 46: z=x+y\\ |
|
1648 | 46: z=x+y\\ | |
1630 | 47: print x\\ |
|
1649 | 47: print x\\ | |
1631 | 48: a=5\\ |
|
1650 | 48: a=5\\ | |
1632 | 49: print 'x',x,'y',y\\ |
|
1651 | 49: print 'x',x,'y',y\\ | |
1633 |
|
1652 | |||
1634 | you can create a macro with lines 44 through 47 (included) and line 49 |
|
1653 | you can create a macro with lines 44 through 47 (included) and line 49 | |
1635 | called my_macro with: |
|
1654 | called my_macro with: | |
1636 |
|
1655 | |||
1637 | In [51]: %macro my_macro 44-47 49 |
|
1656 | In [51]: %macro my_macro 44-47 49 | |
1638 |
|
1657 | |||
1639 | Now, typing `my_macro` (without quotes) will re-execute all this code |
|
1658 | Now, typing `my_macro` (without quotes) will re-execute all this code | |
1640 | in one pass. |
|
1659 | in one pass. | |
1641 |
|
1660 | |||
1642 | You don't need to give the line-numbers in order, and any given line |
|
1661 | You don't need to give the line-numbers in order, and any given line | |
1643 | number can appear multiple times. You can assemble macros with any |
|
1662 | number can appear multiple times. You can assemble macros with any | |
1644 | lines from your input history in any order. |
|
1663 | lines from your input history in any order. | |
1645 |
|
1664 | |||
1646 | The macro is a simple object which holds its value in an attribute, |
|
1665 | The macro is a simple object which holds its value in an attribute, | |
1647 | but IPython's display system checks for macros and executes them as |
|
1666 | but IPython's display system checks for macros and executes them as | |
1648 | code instead of printing them when you type their name. |
|
1667 | code instead of printing them when you type their name. | |
1649 |
|
1668 | |||
1650 | You can view a macro's contents by explicitly printing it with: |
|
1669 | You can view a macro's contents by explicitly printing it with: | |
1651 |
|
1670 | |||
1652 | 'print macro_name'. |
|
1671 | 'print macro_name'. | |
1653 |
|
1672 | |||
1654 | For one-off cases which DON'T contain magic function calls in them you |
|
1673 | For one-off cases which DON'T contain magic function calls in them you | |
1655 | can obtain similar results by explicitly executing slices from your |
|
1674 | can obtain similar results by explicitly executing slices from your | |
1656 | input history with: |
|
1675 | input history with: | |
1657 |
|
1676 | |||
1658 | In [60]: exec In[44:48]+In[49]""" |
|
1677 | In [60]: exec In[44:48]+In[49]""" | |
1659 |
|
1678 | |||
1660 |
args = parameter_s |
|
1679 | opts,args = self.parse_options(parameter_s,'r') | |
1661 | name,ranges = args[0], args[1:] |
|
1680 | name,ranges = args[0], args[1:] | |
1662 | #print 'rng',ranges # dbg |
|
1681 | #print 'rng',ranges # dbg | |
1663 | lines = self.extract_input_slices(ranges) |
|
1682 | lines = self.extract_input_slices(ranges,opts.has_key('r')) | |
1664 | macro = Macro(lines) |
|
1683 | macro = Macro(lines) | |
1665 | self.shell.user_ns.update({name:macro}) |
|
1684 | self.shell.user_ns.update({name:macro}) | |
1666 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name |
|
1685 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name | |
1667 | print 'Macro contents:' |
|
1686 | print 'Macro contents:' | |
1668 | print macro, |
|
1687 | print macro, | |
1669 |
|
1688 | |||
1670 | def magic_save(self,parameter_s = ''): |
|
1689 | def magic_save(self,parameter_s = ''): | |
1671 | """Save a set of lines to a given filename. |
|
1690 | """Save a set of lines to a given filename. | |
1672 |
|
1691 | |||
1673 | Usage:\\ |
|
1692 | Usage:\\ | |
1674 | %save filename n1-n2 n3-n4 ... n5 .. n6 ... |
|
1693 | %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ... | |
|
1694 | ||||
|
1695 | Options: | |||
|
1696 | ||||
|
1697 | -r: use 'raw' input. By default, the 'processed' history is used, | |||
|
1698 | so that magics are loaded in their transformed version to valid | |||
|
1699 | Python. If this option is given, the raw input as typed as the | |||
|
1700 | command line is used instead. | |||
1675 |
|
1701 | |||
1676 | This function uses the same syntax as %macro for line extraction, but |
|
1702 | This function uses the same syntax as %macro for line extraction, but | |
1677 | instead of creating a macro it saves the resulting string to the |
|
1703 | instead of creating a macro it saves the resulting string to the | |
1678 | filename you specify. |
|
1704 | filename you specify. | |
1679 |
|
1705 | |||
1680 | It adds a '.py' extension to the file if you don't do so yourself, and |
|
1706 | It adds a '.py' extension to the file if you don't do so yourself, and | |
1681 | it asks for confirmation before overwriting existing files.""" |
|
1707 | it asks for confirmation before overwriting existing files.""" | |
1682 |
|
1708 | |||
1683 |
args = parameter_s |
|
1709 | opts,args = self.parse_options(parameter_s,'r') | |
1684 | fname,ranges = args[0], args[1:] |
|
1710 | fname,ranges = args[0], args[1:] | |
1685 | if not fname.endswith('.py'): |
|
1711 | if not fname.endswith('.py'): | |
1686 | fname += '.py' |
|
1712 | fname += '.py' | |
1687 | if os.path.isfile(fname): |
|
1713 | if os.path.isfile(fname): | |
1688 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) |
|
1714 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) | |
1689 | if ans.lower() not in ['y','yes']: |
|
1715 | if ans.lower() not in ['y','yes']: | |
1690 | print 'Operation cancelled.' |
|
1716 | print 'Operation cancelled.' | |
1691 | return |
|
1717 | return | |
1692 | cmds = ''.join(self.extract_input_slices(ranges)) |
|
1718 | cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r'))) | |
1693 | f = file(fname,'w') |
|
1719 | f = file(fname,'w') | |
1694 | f.write(cmds) |
|
1720 | f.write(cmds) | |
1695 | f.close() |
|
1721 | f.close() | |
1696 | print 'The following commands were written to file `%s`:' % fname |
|
1722 | print 'The following commands were written to file `%s`:' % fname | |
1697 | print cmds |
|
1723 | print cmds | |
1698 |
|
1724 | |||
1699 | def _edit_macro(self,mname,macro): |
|
1725 | def _edit_macro(self,mname,macro): | |
1700 | """open an editor with the macro data in a file""" |
|
1726 | """open an editor with the macro data in a file""" | |
1701 | filename = self.shell.mktempfile(macro.value) |
|
1727 | filename = self.shell.mktempfile(macro.value) | |
1702 | self.shell.hooks.editor(filename) |
|
1728 | self.shell.hooks.editor(filename) | |
1703 |
|
1729 | |||
1704 | # and make a new macro object, to replace the old one |
|
1730 | # and make a new macro object, to replace the old one | |
1705 | mfile = open(filename) |
|
1731 | mfile = open(filename) | |
1706 | mvalue = mfile.read() |
|
1732 | mvalue = mfile.read() | |
1707 | mfile.close() |
|
1733 | mfile.close() | |
1708 | self.shell.user_ns[mname] = Macro(mvalue) |
|
1734 | self.shell.user_ns[mname] = Macro(mvalue) | |
1709 |
|
1735 | |||
1710 | def magic_ed(self,parameter_s=''): |
|
1736 | def magic_ed(self,parameter_s=''): | |
1711 | """Alias to %edit.""" |
|
1737 | """Alias to %edit.""" | |
1712 | return self.magic_edit(parameter_s) |
|
1738 | return self.magic_edit(parameter_s) | |
1713 |
|
1739 | |||
1714 | def magic_edit(self,parameter_s='',last_call=['','']): |
|
1740 | def magic_edit(self,parameter_s='',last_call=['','']): | |
1715 | """Bring up an editor and execute the resulting code. |
|
1741 | """Bring up an editor and execute the resulting code. | |
1716 |
|
1742 | |||
1717 | Usage: |
|
1743 | Usage: | |
1718 | %edit [options] [args] |
|
1744 | %edit [options] [args] | |
1719 |
|
1745 | |||
1720 | %edit runs IPython's editor hook. The default version of this hook is |
|
1746 | %edit runs IPython's editor hook. The default version of this hook is | |
1721 | set to call the __IPYTHON__.rc.editor command. This is read from your |
|
1747 | set to call the __IPYTHON__.rc.editor command. This is read from your | |
1722 | environment variable $EDITOR. If this isn't found, it will default to |
|
1748 | environment variable $EDITOR. If this isn't found, it will default to | |
1723 | vi under Linux/Unix and to notepad under Windows. See the end of this |
|
1749 | vi under Linux/Unix and to notepad under Windows. See the end of this | |
1724 | docstring for how to change the editor hook. |
|
1750 | docstring for how to change the editor hook. | |
1725 |
|
1751 | |||
1726 | You can also set the value of this editor via the command line option |
|
1752 | You can also set the value of this editor via the command line option | |
1727 | '-editor' or in your ipythonrc file. This is useful if you wish to use |
|
1753 | '-editor' or in your ipythonrc file. This is useful if you wish to use | |
1728 | specifically for IPython an editor different from your typical default |
|
1754 | specifically for IPython an editor different from your typical default | |
1729 | (and for Windows users who typically don't set environment variables). |
|
1755 | (and for Windows users who typically don't set environment variables). | |
1730 |
|
1756 | |||
1731 | This command allows you to conveniently edit multi-line code right in |
|
1757 | This command allows you to conveniently edit multi-line code right in | |
1732 | your IPython session. |
|
1758 | your IPython session. | |
1733 |
|
1759 | |||
1734 | If called without arguments, %edit opens up an empty editor with a |
|
1760 | If called without arguments, %edit opens up an empty editor with a | |
1735 | temporary file and will execute the contents of this file when you |
|
1761 | temporary file and will execute the contents of this file when you | |
1736 | close it (don't forget to save it!). |
|
1762 | close it (don't forget to save it!). | |
1737 |
|
1763 | |||
1738 |
|
1764 | |||
1739 | Options: |
|
1765 | Options: | |
1740 |
|
1766 | |||
1741 | -p: this will call the editor with the same data as the previous time |
|
1767 | -p: this will call the editor with the same data as the previous time | |
1742 | it was used, regardless of how long ago (in your current session) it |
|
1768 | it was used, regardless of how long ago (in your current session) it | |
1743 | was. |
|
1769 | was. | |
1744 |
|
1770 | |||
|
1771 | -r: use 'raw' input. This option only applies to input taken from the | |||
|
1772 | user's history. By default, the 'processed' history is used, so that | |||
|
1773 | magics are loaded in their transformed version to valid Python. If | |||
|
1774 | this option is given, the raw input as typed as the command line is | |||
|
1775 | used instead. When you exit the editor, it will be executed by | |||
|
1776 | IPython's own processor. | |||
|
1777 | ||||
1745 | -x: do not execute the edited code immediately upon exit. This is |
|
1778 | -x: do not execute the edited code immediately upon exit. This is | |
1746 | mainly useful if you are editing programs which need to be called with |
|
1779 | mainly useful if you are editing programs which need to be called with | |
1747 | command line arguments, which you can then do using %run. |
|
1780 | command line arguments, which you can then do using %run. | |
1748 |
|
1781 | |||
1749 |
|
1782 | |||
1750 | Arguments: |
|
1783 | Arguments: | |
1751 |
|
1784 | |||
1752 | If arguments are given, the following possibilites exist: |
|
1785 | If arguments are given, the following possibilites exist: | |
1753 |
|
1786 | |||
1754 | - The arguments are numbers or pairs of colon-separated numbers (like |
|
1787 | - The arguments are numbers or pairs of colon-separated numbers (like | |
1755 | 1 4:8 9). These are interpreted as lines of previous input to be |
|
1788 | 1 4:8 9). These are interpreted as lines of previous input to be | |
1756 | loaded into the editor. The syntax is the same of the %macro command. |
|
1789 | loaded into the editor. The syntax is the same of the %macro command. | |
1757 |
|
1790 | |||
1758 | - If the argument doesn't start with a number, it is evaluated as a |
|
1791 | - If the argument doesn't start with a number, it is evaluated as a | |
1759 | variable and its contents loaded into the editor. You can thus edit |
|
1792 | variable and its contents loaded into the editor. You can thus edit | |
1760 | any string which contains python code (including the result of |
|
1793 | any string which contains python code (including the result of | |
1761 | previous edits). |
|
1794 | previous edits). | |
1762 |
|
1795 | |||
1763 | - If the argument is the name of an object (other than a string), |
|
1796 | - If the argument is the name of an object (other than a string), | |
1764 | IPython will try to locate the file where it was defined and open the |
|
1797 | IPython will try to locate the file where it was defined and open the | |
1765 | editor at the point where it is defined. You can use `%edit function` |
|
1798 | editor at the point where it is defined. You can use `%edit function` | |
1766 | to load an editor exactly at the point where 'function' is defined, |
|
1799 | to load an editor exactly at the point where 'function' is defined, | |
1767 | edit it and have the file be executed automatically. |
|
1800 | edit it and have the file be executed automatically. | |
1768 |
|
1801 | |||
1769 | If the object is a macro (see %macro for details), this opens up your |
|
1802 | If the object is a macro (see %macro for details), this opens up your | |
1770 | specified editor with a temporary file containing the macro's data. |
|
1803 | specified editor with a temporary file containing the macro's data. | |
1771 | Upon exit, the macro is reloaded with the contents of the file. |
|
1804 | Upon exit, the macro is reloaded with the contents of the file. | |
1772 |
|
1805 | |||
1773 | Note: opening at an exact line is only supported under Unix, and some |
|
1806 | Note: opening at an exact line is only supported under Unix, and some | |
1774 | editors (like kedit and gedit up to Gnome 2.8) do not understand the |
|
1807 | editors (like kedit and gedit up to Gnome 2.8) do not understand the | |
1775 | '+NUMBER' parameter necessary for this feature. Good editors like |
|
1808 | '+NUMBER' parameter necessary for this feature. Good editors like | |
1776 | (X)Emacs, vi, jed, pico and joe all do. |
|
1809 | (X)Emacs, vi, jed, pico and joe all do. | |
1777 |
|
1810 | |||
1778 | - If the argument is not found as a variable, IPython will look for a |
|
1811 | - If the argument is not found as a variable, IPython will look for a | |
1779 | file with that name (adding .py if necessary) and load it into the |
|
1812 | file with that name (adding .py if necessary) and load it into the | |
1780 | editor. It will execute its contents with execfile() when you exit, |
|
1813 | editor. It will execute its contents with execfile() when you exit, | |
1781 | loading any code in the file into your interactive namespace. |
|
1814 | loading any code in the file into your interactive namespace. | |
1782 |
|
1815 | |||
1783 | After executing your code, %edit will return as output the code you |
|
1816 | After executing your code, %edit will return as output the code you | |
1784 | typed in the editor (except when it was an existing file). This way |
|
1817 | typed in the editor (except when it was an existing file). This way | |
1785 | you can reload the code in further invocations of %edit as a variable, |
|
1818 | you can reload the code in further invocations of %edit as a variable, | |
1786 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of |
|
1819 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of | |
1787 | the output. |
|
1820 | the output. | |
1788 |
|
1821 | |||
1789 | Note that %edit is also available through the alias %ed. |
|
1822 | Note that %edit is also available through the alias %ed. | |
1790 |
|
1823 | |||
1791 | This is an example of creating a simple function inside the editor and |
|
1824 | This is an example of creating a simple function inside the editor and | |
1792 | then modifying it. First, start up the editor: |
|
1825 | then modifying it. First, start up the editor: | |
1793 |
|
1826 | |||
1794 | In [1]: ed\\ |
|
1827 | In [1]: ed\\ | |
1795 | Editing... done. Executing edited code...\\ |
|
1828 | Editing... done. Executing edited code...\\ | |
1796 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' |
|
1829 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' | |
1797 |
|
1830 | |||
1798 | We can then call the function foo(): |
|
1831 | We can then call the function foo(): | |
1799 |
|
1832 | |||
1800 | In [2]: foo()\\ |
|
1833 | In [2]: foo()\\ | |
1801 | foo() was defined in an editing session |
|
1834 | foo() was defined in an editing session | |
1802 |
|
1835 | |||
1803 | Now we edit foo. IPython automatically loads the editor with the |
|
1836 | Now we edit foo. IPython automatically loads the editor with the | |
1804 | (temporary) file where foo() was previously defined: |
|
1837 | (temporary) file where foo() was previously defined: | |
1805 |
|
1838 | |||
1806 | In [3]: ed foo\\ |
|
1839 | In [3]: ed foo\\ | |
1807 | Editing... done. Executing edited code... |
|
1840 | Editing... done. Executing edited code... | |
1808 |
|
1841 | |||
1809 | And if we call foo() again we get the modified version: |
|
1842 | And if we call foo() again we get the modified version: | |
1810 |
|
1843 | |||
1811 | In [4]: foo()\\ |
|
1844 | In [4]: foo()\\ | |
1812 | foo() has now been changed! |
|
1845 | foo() has now been changed! | |
1813 |
|
1846 | |||
1814 | Here is an example of how to edit a code snippet successive |
|
1847 | Here is an example of how to edit a code snippet successive | |
1815 | times. First we call the editor: |
|
1848 | times. First we call the editor: | |
1816 |
|
1849 | |||
1817 | In [8]: ed\\ |
|
1850 | In [8]: ed\\ | |
1818 | Editing... done. Executing edited code...\\ |
|
1851 | Editing... done. Executing edited code...\\ | |
1819 | hello\\ |
|
1852 | hello\\ | |
1820 | Out[8]: "print 'hello'\\n" |
|
1853 | Out[8]: "print 'hello'\\n" | |
1821 |
|
1854 | |||
1822 | Now we call it again with the previous output (stored in _): |
|
1855 | Now we call it again with the previous output (stored in _): | |
1823 |
|
1856 | |||
1824 | In [9]: ed _\\ |
|
1857 | In [9]: ed _\\ | |
1825 | Editing... done. Executing edited code...\\ |
|
1858 | Editing... done. Executing edited code...\\ | |
1826 | hello world\\ |
|
1859 | hello world\\ | |
1827 | Out[9]: "print 'hello world'\\n" |
|
1860 | Out[9]: "print 'hello world'\\n" | |
1828 |
|
1861 | |||
1829 | Now we call it with the output #8 (stored in _8, also as Out[8]): |
|
1862 | Now we call it with the output #8 (stored in _8, also as Out[8]): | |
1830 |
|
1863 | |||
1831 | In [10]: ed _8\\ |
|
1864 | In [10]: ed _8\\ | |
1832 | Editing... done. Executing edited code...\\ |
|
1865 | Editing... done. Executing edited code...\\ | |
1833 | hello again\\ |
|
1866 | hello again\\ | |
1834 | Out[10]: "print 'hello again'\\n" |
|
1867 | Out[10]: "print 'hello again'\\n" | |
1835 |
|
1868 | |||
1836 |
|
1869 | |||
1837 | Changing the default editor hook: |
|
1870 | Changing the default editor hook: | |
1838 |
|
1871 | |||
1839 | If you wish to write your own editor hook, you can put it in a |
|
1872 | If you wish to write your own editor hook, you can put it in a | |
1840 | configuration file which you load at startup time. The default hook |
|
1873 | configuration file which you load at startup time. The default hook | |
1841 | is defined in the IPython.hooks module, and you can use that as a |
|
1874 | is defined in the IPython.hooks module, and you can use that as a | |
1842 | starting example for further modifications. That file also has |
|
1875 | starting example for further modifications. That file also has | |
1843 | general instructions on how to set a new hook for use once you've |
|
1876 | general instructions on how to set a new hook for use once you've | |
1844 | defined it.""" |
|
1877 | defined it.""" | |
1845 |
|
1878 | |||
1846 | # FIXME: This function has become a convoluted mess. It needs a |
|
1879 | # FIXME: This function has become a convoluted mess. It needs a | |
1847 | # ground-up rewrite with clean, simple logic. |
|
1880 | # ground-up rewrite with clean, simple logic. | |
1848 |
|
1881 | |||
1849 | def make_filename(arg): |
|
1882 | def make_filename(arg): | |
1850 | "Make a filename from the given args" |
|
1883 | "Make a filename from the given args" | |
1851 | try: |
|
1884 | try: | |
1852 | filename = get_py_filename(arg) |
|
1885 | filename = get_py_filename(arg) | |
1853 | except IOError: |
|
1886 | except IOError: | |
1854 | if args.endswith('.py'): |
|
1887 | if args.endswith('.py'): | |
1855 | filename = arg |
|
1888 | filename = arg | |
1856 | else: |
|
1889 | else: | |
1857 | filename = None |
|
1890 | filename = None | |
1858 | return filename |
|
1891 | return filename | |
1859 |
|
1892 | |||
1860 | # custom exceptions |
|
1893 | # custom exceptions | |
1861 | class DataIsObject(Exception): pass |
|
1894 | class DataIsObject(Exception): pass | |
1862 |
|
1895 | |||
1863 | opts,args = self.parse_options(parameter_s,'px') |
|
1896 | opts,args = self.parse_options(parameter_s,'prx') | |
|
1897 | # Set a few locals from the options for convenience: | |||
|
1898 | opts_p = opts.has_key('p') | |||
|
1899 | opts_r = opts.has_key('r') | |||
1864 |
|
1900 | |||
1865 | # Default line number value |
|
1901 | # Default line number value | |
1866 | lineno = None |
|
1902 | lineno = None | |
1867 |
if opts |
|
1903 | if opts_p: | |
1868 | args = '_%s' % last_call[0] |
|
1904 | args = '_%s' % last_call[0] | |
1869 | if not self.shell.user_ns.has_key(args): |
|
1905 | if not self.shell.user_ns.has_key(args): | |
1870 | args = last_call[1] |
|
1906 | args = last_call[1] | |
1871 |
|
1907 | |||
1872 | # use last_call to remember the state of the previous call, but don't |
|
1908 | # use last_call to remember the state of the previous call, but don't | |
1873 | # let it be clobbered by successive '-p' calls. |
|
1909 | # let it be clobbered by successive '-p' calls. | |
1874 | try: |
|
1910 | try: | |
1875 | last_call[0] = self.shell.outputcache.prompt_count |
|
1911 | last_call[0] = self.shell.outputcache.prompt_count | |
1876 |
if not opts |
|
1912 | if not opts_p: | |
1877 | last_call[1] = parameter_s |
|
1913 | last_call[1] = parameter_s | |
1878 | except: |
|
1914 | except: | |
1879 | pass |
|
1915 | pass | |
1880 |
|
1916 | |||
1881 | # by default this is done with temp files, except when the given |
|
1917 | # by default this is done with temp files, except when the given | |
1882 | # arg is a filename |
|
1918 | # arg is a filename | |
1883 | use_temp = 1 |
|
1919 | use_temp = 1 | |
1884 |
|
1920 | |||
1885 | if re.match(r'\d',args): |
|
1921 | if re.match(r'\d',args): | |
1886 | # Mode where user specifies ranges of lines, like in %macro. |
|
1922 | # Mode where user specifies ranges of lines, like in %macro. | |
1887 | # This means that you can't edit files whose names begin with |
|
1923 | # This means that you can't edit files whose names begin with | |
1888 | # numbers this way. Tough. |
|
1924 | # numbers this way. Tough. | |
1889 | ranges = args.split() |
|
1925 | ranges = args.split() | |
1890 | data = ''.join(self.extract_input_slices(ranges)) |
|
1926 | data = ''.join(self.extract_input_slices(ranges,opts_r)) | |
1891 | elif args.endswith('.py'): |
|
1927 | elif args.endswith('.py'): | |
1892 | filename = make_filename(args) |
|
1928 | filename = make_filename(args) | |
1893 | data = '' |
|
1929 | data = '' | |
1894 | use_temp = 0 |
|
1930 | use_temp = 0 | |
1895 | elif args: |
|
1931 | elif args: | |
1896 | try: |
|
1932 | try: | |
1897 | # Load the parameter given as a variable. If not a string, |
|
1933 | # Load the parameter given as a variable. If not a string, | |
1898 | # process it as an object instead (below) |
|
1934 | # process it as an object instead (below) | |
1899 |
|
1935 | |||
1900 | #print '*** args',args,'type',type(args) # dbg |
|
1936 | #print '*** args',args,'type',type(args) # dbg | |
1901 | data = eval(args,self.shell.user_ns) |
|
1937 | data = eval(args,self.shell.user_ns) | |
1902 | if not type(data) in StringTypes: |
|
1938 | if not type(data) in StringTypes: | |
1903 | raise DataIsObject |
|
1939 | raise DataIsObject | |
1904 |
|
1940 | |||
1905 | except (NameError,SyntaxError): |
|
1941 | except (NameError,SyntaxError): | |
1906 | # given argument is not a variable, try as a filename |
|
1942 | # given argument is not a variable, try as a filename | |
1907 | filename = make_filename(args) |
|
1943 | filename = make_filename(args) | |
1908 | if filename is None: |
|
1944 | if filename is None: | |
1909 | warn("Argument given (%s) can't be found as a variable " |
|
1945 | warn("Argument given (%s) can't be found as a variable " | |
1910 | "or as a filename." % args) |
|
1946 | "or as a filename." % args) | |
1911 | return |
|
1947 | return | |
1912 |
|
1948 | |||
1913 | data = '' |
|
1949 | data = '' | |
1914 | use_temp = 0 |
|
1950 | use_temp = 0 | |
1915 | except DataIsObject: |
|
1951 | except DataIsObject: | |
1916 |
|
1952 | |||
1917 | # macros have a special edit function |
|
1953 | # macros have a special edit function | |
1918 | if isinstance(data,Macro): |
|
1954 | if isinstance(data,Macro): | |
1919 | self._edit_macro(args,data) |
|
1955 | self._edit_macro(args,data) | |
1920 | return |
|
1956 | return | |
1921 |
|
1957 | |||
1922 | # For objects, try to edit the file where they are defined |
|
1958 | # For objects, try to edit the file where they are defined | |
1923 | try: |
|
1959 | try: | |
1924 | filename = inspect.getabsfile(data) |
|
1960 | filename = inspect.getabsfile(data) | |
1925 | datafile = 1 |
|
1961 | datafile = 1 | |
1926 | except TypeError: |
|
1962 | except TypeError: | |
1927 | filename = make_filename(args) |
|
1963 | filename = make_filename(args) | |
1928 | datafile = 1 |
|
1964 | datafile = 1 | |
1929 | warn('Could not find file where `%s` is defined.\n' |
|
1965 | warn('Could not find file where `%s` is defined.\n' | |
1930 | 'Opening a file named `%s`' % (args,filename)) |
|
1966 | 'Opening a file named `%s`' % (args,filename)) | |
1931 | # Now, make sure we can actually read the source (if it was in |
|
1967 | # Now, make sure we can actually read the source (if it was in | |
1932 | # a temp file it's gone by now). |
|
1968 | # a temp file it's gone by now). | |
1933 | if datafile: |
|
1969 | if datafile: | |
1934 | try: |
|
1970 | try: | |
1935 | lineno = inspect.getsourcelines(data)[1] |
|
1971 | lineno = inspect.getsourcelines(data)[1] | |
1936 | except IOError: |
|
1972 | except IOError: | |
1937 | filename = make_filename(args) |
|
1973 | filename = make_filename(args) | |
1938 | if filename is None: |
|
1974 | if filename is None: | |
1939 | warn('The file `%s` where `%s` was defined cannot ' |
|
1975 | warn('The file `%s` where `%s` was defined cannot ' | |
1940 | 'be read.' % (filename,data)) |
|
1976 | 'be read.' % (filename,data)) | |
1941 | return |
|
1977 | return | |
1942 | use_temp = 0 |
|
1978 | use_temp = 0 | |
1943 | else: |
|
1979 | else: | |
1944 | data = '' |
|
1980 | data = '' | |
1945 |
|
1981 | |||
1946 | if use_temp: |
|
1982 | if use_temp: | |
1947 | filename = self.shell.mktempfile(data) |
|
1983 | filename = self.shell.mktempfile(data) | |
1948 | print 'IPython will make a temporary file named:',filename |
|
1984 | print 'IPython will make a temporary file named:',filename | |
1949 |
|
1985 | |||
1950 | # do actual editing here |
|
1986 | # do actual editing here | |
1951 | print 'Editing...', |
|
1987 | print 'Editing...', | |
1952 | sys.stdout.flush() |
|
1988 | sys.stdout.flush() | |
1953 | self.shell.hooks.editor(filename,lineno) |
|
1989 | self.shell.hooks.editor(filename,lineno) | |
1954 | if opts.has_key('x'): # -x prevents actual execution |
|
1990 | if opts.has_key('x'): # -x prevents actual execution | |
1955 |
|
1991 | |||
1956 | else: |
|
1992 | else: | |
1957 | print 'done. Executing edited code...' |
|
1993 | print 'done. Executing edited code...' | |
|
1994 | if opts_r: | |||
|
1995 | self.shell.runlines(file_read(filename)) | |||
|
1996 | else: | |||
1958 | self.shell.safe_execfile(filename,self.shell.user_ns) |
|
1997 | self.shell.safe_execfile(filename,self.shell.user_ns) | |
1959 | if use_temp: |
|
1998 | if use_temp: | |
1960 | try: |
|
1999 | try: | |
1961 | return open(filename).read() |
|
2000 | return open(filename).read() | |
1962 | except IOError,msg: |
|
2001 | except IOError,msg: | |
1963 | if msg.filename == filename: |
|
2002 | if msg.filename == filename: | |
1964 | warn('File not found. Did you forget to save?') |
|
2003 | warn('File not found. Did you forget to save?') | |
1965 | return |
|
2004 | return | |
1966 | else: |
|
2005 | else: | |
1967 | self.shell.showtraceback() |
|
2006 | self.shell.showtraceback() | |
1968 |
|
2007 | |||
1969 | def magic_xmode(self,parameter_s = ''): |
|
2008 | def magic_xmode(self,parameter_s = ''): | |
1970 | """Switch modes for the exception handlers. |
|
2009 | """Switch modes for the exception handlers. | |
1971 |
|
2010 | |||
1972 | Valid modes: Plain, Context and Verbose. |
|
2011 | Valid modes: Plain, Context and Verbose. | |
1973 |
|
2012 | |||
1974 | If called without arguments, acts as a toggle.""" |
|
2013 | If called without arguments, acts as a toggle.""" | |
1975 |
|
2014 | |||
1976 | def xmode_switch_err(name): |
|
2015 | def xmode_switch_err(name): | |
1977 | warn('Error changing %s exception modes.\n%s' % |
|
2016 | warn('Error changing %s exception modes.\n%s' % | |
1978 | (name,sys.exc_info()[1])) |
|
2017 | (name,sys.exc_info()[1])) | |
1979 |
|
2018 | |||
1980 | shell = self.shell |
|
2019 | shell = self.shell | |
1981 | new_mode = parameter_s.strip().capitalize() |
|
2020 | new_mode = parameter_s.strip().capitalize() | |
1982 | try: |
|
2021 | try: | |
1983 | shell.InteractiveTB.set_mode(mode=new_mode) |
|
2022 | shell.InteractiveTB.set_mode(mode=new_mode) | |
1984 | print 'Exception reporting mode:',shell.InteractiveTB.mode |
|
2023 | print 'Exception reporting mode:',shell.InteractiveTB.mode | |
1985 | except: |
|
2024 | except: | |
1986 | xmode_switch_err('user') |
|
2025 | xmode_switch_err('user') | |
1987 |
|
2026 | |||
1988 | # threaded shells use a special handler in sys.excepthook |
|
2027 | # threaded shells use a special handler in sys.excepthook | |
1989 | if shell.isthreaded: |
|
2028 | if shell.isthreaded: | |
1990 | try: |
|
2029 | try: | |
1991 | shell.sys_excepthook.set_mode(mode=new_mode) |
|
2030 | shell.sys_excepthook.set_mode(mode=new_mode) | |
1992 | except: |
|
2031 | except: | |
1993 | xmode_switch_err('threaded') |
|
2032 | xmode_switch_err('threaded') | |
1994 |
|
2033 | |||
1995 | def magic_colors(self,parameter_s = ''): |
|
2034 | def magic_colors(self,parameter_s = ''): | |
1996 | """Switch color scheme for prompts, info system and exception handlers. |
|
2035 | """Switch color scheme for prompts, info system and exception handlers. | |
1997 |
|
2036 | |||
1998 | Currently implemented schemes: NoColor, Linux, LightBG. |
|
2037 | Currently implemented schemes: NoColor, Linux, LightBG. | |
1999 |
|
2038 | |||
2000 | Color scheme names are not case-sensitive.""" |
|
2039 | Color scheme names are not case-sensitive.""" | |
2001 |
|
2040 | |||
2002 | def color_switch_err(name): |
|
2041 | def color_switch_err(name): | |
2003 | warn('Error changing %s color schemes.\n%s' % |
|
2042 | warn('Error changing %s color schemes.\n%s' % | |
2004 | (name,sys.exc_info()[1])) |
|
2043 | (name,sys.exc_info()[1])) | |
2005 |
|
2044 | |||
2006 |
|
2045 | |||
2007 | new_scheme = parameter_s.strip() |
|
2046 | new_scheme = parameter_s.strip() | |
2008 | if not new_scheme: |
|
2047 | if not new_scheme: | |
2009 | print 'You must specify a color scheme.' |
|
2048 | print 'You must specify a color scheme.' | |
2010 | return |
|
2049 | return | |
2011 | import IPython.rlineimpl as readline |
|
2050 | import IPython.rlineimpl as readline | |
2012 | if not readline.have_readline: |
|
2051 | if not readline.have_readline: | |
2013 | msg = """\ |
|
2052 | msg = """\ | |
2014 | Proper color support under MS Windows requires Gary Bishop's readline library. |
|
2053 | Proper color support under MS Windows requires Gary Bishop's readline library. | |
2015 | You can find it at: |
|
2054 | You can find it at: | |
2016 | http://sourceforge.net/projects/uncpythontools |
|
2055 | http://sourceforge.net/projects/uncpythontools | |
2017 | Gary's readline needs the ctypes module, from: |
|
2056 | Gary's readline needs the ctypes module, from: | |
2018 | http://starship.python.net/crew/theller/ctypes |
|
2057 | http://starship.python.net/crew/theller/ctypes | |
2019 |
|
2058 | |||
2020 | Defaulting color scheme to 'NoColor'""" |
|
2059 | Defaulting color scheme to 'NoColor'""" | |
2021 | new_scheme = 'NoColor' |
|
2060 | new_scheme = 'NoColor' | |
2022 | warn(msg) |
|
2061 | warn(msg) | |
2023 | # local shortcut |
|
2062 | # local shortcut | |
2024 | shell = self.shell |
|
2063 | shell = self.shell | |
2025 |
|
2064 | |||
2026 | # Set prompt colors |
|
2065 | # Set prompt colors | |
2027 | try: |
|
2066 | try: | |
2028 | shell.outputcache.set_colors(new_scheme) |
|
2067 | shell.outputcache.set_colors(new_scheme) | |
2029 | except: |
|
2068 | except: | |
2030 | color_switch_err('prompt') |
|
2069 | color_switch_err('prompt') | |
2031 | else: |
|
2070 | else: | |
2032 | shell.rc.colors = \ |
|
2071 | shell.rc.colors = \ | |
2033 | shell.outputcache.color_table.active_scheme_name |
|
2072 | shell.outputcache.color_table.active_scheme_name | |
2034 | # Set exception colors |
|
2073 | # Set exception colors | |
2035 | try: |
|
2074 | try: | |
2036 | shell.InteractiveTB.set_colors(scheme = new_scheme) |
|
2075 | shell.InteractiveTB.set_colors(scheme = new_scheme) | |
2037 | shell.SyntaxTB.set_colors(scheme = new_scheme) |
|
2076 | shell.SyntaxTB.set_colors(scheme = new_scheme) | |
2038 | except: |
|
2077 | except: | |
2039 | color_switch_err('exception') |
|
2078 | color_switch_err('exception') | |
2040 |
|
2079 | |||
2041 | # threaded shells use a verbose traceback in sys.excepthook |
|
2080 | # threaded shells use a verbose traceback in sys.excepthook | |
2042 | if shell.isthreaded: |
|
2081 | if shell.isthreaded: | |
2043 | try: |
|
2082 | try: | |
2044 | shell.sys_excepthook.set_colors(scheme=new_scheme) |
|
2083 | shell.sys_excepthook.set_colors(scheme=new_scheme) | |
2045 | except: |
|
2084 | except: | |
2046 | color_switch_err('system exception handler') |
|
2085 | color_switch_err('system exception handler') | |
2047 |
|
2086 | |||
2048 | # Set info (for 'object?') colors |
|
2087 | # Set info (for 'object?') colors | |
2049 | if shell.rc.color_info: |
|
2088 | if shell.rc.color_info: | |
2050 | try: |
|
2089 | try: | |
2051 | shell.inspector.set_active_scheme(new_scheme) |
|
2090 | shell.inspector.set_active_scheme(new_scheme) | |
2052 | except: |
|
2091 | except: | |
2053 | color_switch_err('object inspector') |
|
2092 | color_switch_err('object inspector') | |
2054 | else: |
|
2093 | else: | |
2055 | shell.inspector.set_active_scheme('NoColor') |
|
2094 | shell.inspector.set_active_scheme('NoColor') | |
2056 |
|
2095 | |||
2057 | def magic_color_info(self,parameter_s = ''): |
|
2096 | def magic_color_info(self,parameter_s = ''): | |
2058 | """Toggle color_info. |
|
2097 | """Toggle color_info. | |
2059 |
|
2098 | |||
2060 | The color_info configuration parameter controls whether colors are |
|
2099 | The color_info configuration parameter controls whether colors are | |
2061 | used for displaying object details (by things like %psource, %pfile or |
|
2100 | used for displaying object details (by things like %psource, %pfile or | |
2062 | the '?' system). This function toggles this value with each call. |
|
2101 | the '?' system). This function toggles this value with each call. | |
2063 |
|
2102 | |||
2064 | Note that unless you have a fairly recent pager (less works better |
|
2103 | Note that unless you have a fairly recent pager (less works better | |
2065 | than more) in your system, using colored object information displays |
|
2104 | than more) in your system, using colored object information displays | |
2066 | will not work properly. Test it and see.""" |
|
2105 | will not work properly. Test it and see.""" | |
2067 |
|
2106 | |||
2068 | self.shell.rc.color_info = 1 - self.shell.rc.color_info |
|
2107 | self.shell.rc.color_info = 1 - self.shell.rc.color_info | |
2069 | self.magic_colors(self.shell.rc.colors) |
|
2108 | self.magic_colors(self.shell.rc.colors) | |
2070 | print 'Object introspection functions have now coloring:', |
|
2109 | print 'Object introspection functions have now coloring:', | |
2071 | print ['OFF','ON'][self.shell.rc.color_info] |
|
2110 | print ['OFF','ON'][self.shell.rc.color_info] | |
2072 |
|
2111 | |||
2073 | def magic_Pprint(self, parameter_s=''): |
|
2112 | def magic_Pprint(self, parameter_s=''): | |
2074 | """Toggle pretty printing on/off.""" |
|
2113 | """Toggle pretty printing on/off.""" | |
2075 |
|
2114 | |||
2076 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint |
|
2115 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint | |
2077 | print 'Pretty printing has been turned', \ |
|
2116 | print 'Pretty printing has been turned', \ | |
2078 | ['OFF','ON'][self.shell.outputcache.Pprint] |
|
2117 | ['OFF','ON'][self.shell.outputcache.Pprint] | |
2079 |
|
2118 | |||
2080 | def magic_exit(self, parameter_s=''): |
|
2119 | def magic_exit(self, parameter_s=''): | |
2081 | """Exit IPython, confirming if configured to do so. |
|
2120 | """Exit IPython, confirming if configured to do so. | |
2082 |
|
2121 | |||
2083 | You can configure whether IPython asks for confirmation upon exit by |
|
2122 | You can configure whether IPython asks for confirmation upon exit by | |
2084 | setting the confirm_exit flag in the ipythonrc file.""" |
|
2123 | setting the confirm_exit flag in the ipythonrc file.""" | |
2085 |
|
2124 | |||
2086 | self.shell.exit() |
|
2125 | self.shell.exit() | |
2087 |
|
2126 | |||
2088 | def magic_quit(self, parameter_s=''): |
|
2127 | def magic_quit(self, parameter_s=''): | |
2089 | """Exit IPython, confirming if configured to do so (like %exit)""" |
|
2128 | """Exit IPython, confirming if configured to do so (like %exit)""" | |
2090 |
|
2129 | |||
2091 | self.shell.exit() |
|
2130 | self.shell.exit() | |
2092 |
|
2131 | |||
2093 | def magic_Exit(self, parameter_s=''): |
|
2132 | def magic_Exit(self, parameter_s=''): | |
2094 | """Exit IPython without confirmation.""" |
|
2133 | """Exit IPython without confirmation.""" | |
2095 |
|
2134 | |||
2096 | self.shell.exit_now = True |
|
2135 | self.shell.exit_now = True | |
2097 |
|
2136 | |||
2098 | def magic_Quit(self, parameter_s=''): |
|
2137 | def magic_Quit(self, parameter_s=''): | |
2099 | """Exit IPython without confirmation (like %Exit).""" |
|
2138 | """Exit IPython without confirmation (like %Exit).""" | |
2100 |
|
2139 | |||
2101 | self.shell.exit_now = True |
|
2140 | self.shell.exit_now = True | |
2102 |
|
2141 | |||
2103 | #...................................................................... |
|
2142 | #...................................................................... | |
2104 | # Functions to implement unix shell-type things |
|
2143 | # Functions to implement unix shell-type things | |
2105 |
|
2144 | |||
2106 | def magic_alias(self, parameter_s = ''): |
|
2145 | def magic_alias(self, parameter_s = ''): | |
2107 | """Define an alias for a system command. |
|
2146 | """Define an alias for a system command. | |
2108 |
|
2147 | |||
2109 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' |
|
2148 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' | |
2110 |
|
2149 | |||
2111 | Then, typing 'alias_name params' will execute the system command 'cmd |
|
2150 | Then, typing 'alias_name params' will execute the system command 'cmd | |
2112 | params' (from your underlying operating system). |
|
2151 | params' (from your underlying operating system). | |
2113 |
|
2152 | |||
2114 | Aliases have lower precedence than magic functions and Python normal |
|
2153 | Aliases have lower precedence than magic functions and Python normal | |
2115 | variables, so if 'foo' is both a Python variable and an alias, the |
|
2154 | variables, so if 'foo' is both a Python variable and an alias, the | |
2116 | alias can not be executed until 'del foo' removes the Python variable. |
|
2155 | alias can not be executed until 'del foo' removes the Python variable. | |
2117 |
|
2156 | |||
2118 | You can use the %l specifier in an alias definition to represent the |
|
2157 | You can use the %l specifier in an alias definition to represent the | |
2119 | whole line when the alias is called. For example: |
|
2158 | whole line when the alias is called. For example: | |
2120 |
|
2159 | |||
2121 | In [2]: alias all echo "Input in brackets: <%l>"\\ |
|
2160 | In [2]: alias all echo "Input in brackets: <%l>"\\ | |
2122 | In [3]: all hello world\\ |
|
2161 | In [3]: all hello world\\ | |
2123 | Input in brackets: <hello world> |
|
2162 | Input in brackets: <hello world> | |
2124 |
|
2163 | |||
2125 | You can also define aliases with parameters using %s specifiers (one |
|
2164 | You can also define aliases with parameters using %s specifiers (one | |
2126 | per parameter): |
|
2165 | per parameter): | |
2127 |
|
2166 | |||
2128 | In [1]: alias parts echo first %s second %s\\ |
|
2167 | In [1]: alias parts echo first %s second %s\\ | |
2129 | In [2]: %parts A B\\ |
|
2168 | In [2]: %parts A B\\ | |
2130 | first A second B\\ |
|
2169 | first A second B\\ | |
2131 | In [3]: %parts A\\ |
|
2170 | In [3]: %parts A\\ | |
2132 | Incorrect number of arguments: 2 expected.\\ |
|
2171 | Incorrect number of arguments: 2 expected.\\ | |
2133 | parts is an alias to: 'echo first %s second %s' |
|
2172 | parts is an alias to: 'echo first %s second %s' | |
2134 |
|
2173 | |||
2135 | Note that %l and %s are mutually exclusive. You can only use one or |
|
2174 | Note that %l and %s are mutually exclusive. You can only use one or | |
2136 | the other in your aliases. |
|
2175 | the other in your aliases. | |
2137 |
|
2176 | |||
2138 | Aliases expand Python variables just like system calls using ! or !! |
|
2177 | Aliases expand Python variables just like system calls using ! or !! | |
2139 | do: all expressions prefixed with '$' get expanded. For details of |
|
2178 | do: all expressions prefixed with '$' get expanded. For details of | |
2140 | the semantic rules, see PEP-215: |
|
2179 | the semantic rules, see PEP-215: | |
2141 | http://www.python.org/peps/pep-0215.html. This is the library used by |
|
2180 | http://www.python.org/peps/pep-0215.html. This is the library used by | |
2142 | IPython for variable expansion. If you want to access a true shell |
|
2181 | IPython for variable expansion. If you want to access a true shell | |
2143 | variable, an extra $ is necessary to prevent its expansion by IPython: |
|
2182 | variable, an extra $ is necessary to prevent its expansion by IPython: | |
2144 |
|
2183 | |||
2145 | In [6]: alias show echo\\ |
|
2184 | In [6]: alias show echo\\ | |
2146 | In [7]: PATH='A Python string'\\ |
|
2185 | In [7]: PATH='A Python string'\\ | |
2147 | In [8]: show $PATH\\ |
|
2186 | In [8]: show $PATH\\ | |
2148 | A Python string\\ |
|
2187 | A Python string\\ | |
2149 | In [9]: show $$PATH\\ |
|
2188 | In [9]: show $$PATH\\ | |
2150 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2189 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2151 |
|
2190 | |||
2152 | You can use the alias facility to acess all of $PATH. See the %rehash |
|
2191 | You can use the alias facility to acess all of $PATH. See the %rehash | |
2153 | and %rehashx functions, which automatically create aliases for the |
|
2192 | and %rehashx functions, which automatically create aliases for the | |
2154 | contents of your $PATH. |
|
2193 | contents of your $PATH. | |
2155 |
|
2194 | |||
2156 | If called with no parameters, %alias prints the current alias table.""" |
|
2195 | If called with no parameters, %alias prints the current alias table.""" | |
2157 |
|
2196 | |||
2158 | par = parameter_s.strip() |
|
2197 | par = parameter_s.strip() | |
2159 | if not par: |
|
2198 | if not par: | |
2160 | if self.shell.rc.automagic: |
|
2199 | if self.shell.rc.automagic: | |
2161 | prechar = '' |
|
2200 | prechar = '' | |
2162 | else: |
|
2201 | else: | |
2163 | prechar = self.shell.ESC_MAGIC |
|
2202 | prechar = self.shell.ESC_MAGIC | |
2164 | #print 'Alias\t\tSystem Command\n'+'-'*30 |
|
2203 | #print 'Alias\t\tSystem Command\n'+'-'*30 | |
2165 | atab = self.shell.alias_table |
|
2204 | atab = self.shell.alias_table | |
2166 | aliases = atab.keys() |
|
2205 | aliases = atab.keys() | |
2167 | aliases.sort() |
|
2206 | aliases.sort() | |
2168 | res = [] |
|
2207 | res = [] | |
2169 | for alias in aliases: |
|
2208 | for alias in aliases: | |
2170 | res.append((alias, atab[alias][1])) |
|
2209 | res.append((alias, atab[alias][1])) | |
2171 | print "Total number of aliases:",len(aliases) |
|
2210 | print "Total number of aliases:",len(aliases) | |
2172 | return res |
|
2211 | return res | |
2173 | try: |
|
2212 | try: | |
2174 | alias,cmd = par.split(None,1) |
|
2213 | alias,cmd = par.split(None,1) | |
2175 | except: |
|
2214 | except: | |
2176 | print OInspect.getdoc(self.magic_alias) |
|
2215 | print OInspect.getdoc(self.magic_alias) | |
2177 | else: |
|
2216 | else: | |
2178 | nargs = cmd.count('%s') |
|
2217 | nargs = cmd.count('%s') | |
2179 | if nargs>0 and cmd.find('%l')>=0: |
|
2218 | if nargs>0 and cmd.find('%l')>=0: | |
2180 | error('The %s and %l specifiers are mutually exclusive ' |
|
2219 | error('The %s and %l specifiers are mutually exclusive ' | |
2181 | 'in alias definitions.') |
|
2220 | 'in alias definitions.') | |
2182 | else: # all looks OK |
|
2221 | else: # all looks OK | |
2183 | self.shell.alias_table[alias] = (nargs,cmd) |
|
2222 | self.shell.alias_table[alias] = (nargs,cmd) | |
2184 | self.shell.alias_table_validate(verbose=1) |
|
2223 | self.shell.alias_table_validate(verbose=1) | |
2185 | # end magic_alias |
|
2224 | # end magic_alias | |
2186 |
|
2225 | |||
2187 | def magic_unalias(self, parameter_s = ''): |
|
2226 | def magic_unalias(self, parameter_s = ''): | |
2188 | """Remove an alias""" |
|
2227 | """Remove an alias""" | |
2189 |
|
2228 | |||
2190 | aname = parameter_s.strip() |
|
2229 | aname = parameter_s.strip() | |
2191 | if aname in self.shell.alias_table: |
|
2230 | if aname in self.shell.alias_table: | |
2192 | del self.shell.alias_table[aname] |
|
2231 | del self.shell.alias_table[aname] | |
2193 |
|
2232 | |||
2194 | def magic_rehash(self, parameter_s = ''): |
|
2233 | def magic_rehash(self, parameter_s = ''): | |
2195 | """Update the alias table with all entries in $PATH. |
|
2234 | """Update the alias table with all entries in $PATH. | |
2196 |
|
2235 | |||
2197 | This version does no checks on execute permissions or whether the |
|
2236 | This version does no checks on execute permissions or whether the | |
2198 | contents of $PATH are truly files (instead of directories or something |
|
2237 | contents of $PATH are truly files (instead of directories or something | |
2199 | else). For such a safer (but slower) version, use %rehashx.""" |
|
2238 | else). For such a safer (but slower) version, use %rehashx.""" | |
2200 |
|
2239 | |||
2201 | # This function (and rehashx) manipulate the alias_table directly |
|
2240 | # This function (and rehashx) manipulate the alias_table directly | |
2202 | # rather than calling magic_alias, for speed reasons. A rehash on a |
|
2241 | # rather than calling magic_alias, for speed reasons. A rehash on a | |
2203 | # typical Linux box involves several thousand entries, so efficiency |
|
2242 | # typical Linux box involves several thousand entries, so efficiency | |
2204 | # here is a top concern. |
|
2243 | # here is a top concern. | |
2205 |
|
2244 | |||
2206 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2245 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2207 | alias_table = self.shell.alias_table |
|
2246 | alias_table = self.shell.alias_table | |
2208 | for pdir in path: |
|
2247 | for pdir in path: | |
2209 | for ff in os.listdir(pdir): |
|
2248 | for ff in os.listdir(pdir): | |
2210 | # each entry in the alias table must be (N,name), where |
|
2249 | # each entry in the alias table must be (N,name), where | |
2211 | # N is the number of positional arguments of the alias. |
|
2250 | # N is the number of positional arguments of the alias. | |
2212 | alias_table[ff] = (0,ff) |
|
2251 | alias_table[ff] = (0,ff) | |
2213 | # Make sure the alias table doesn't contain keywords or builtins |
|
2252 | # Make sure the alias table doesn't contain keywords or builtins | |
2214 | self.shell.alias_table_validate() |
|
2253 | self.shell.alias_table_validate() | |
2215 | # Call again init_auto_alias() so we get 'rm -i' and other modified |
|
2254 | # Call again init_auto_alias() so we get 'rm -i' and other modified | |
2216 | # aliases since %rehash will probably clobber them |
|
2255 | # aliases since %rehash will probably clobber them | |
2217 | self.shell.init_auto_alias() |
|
2256 | self.shell.init_auto_alias() | |
2218 |
|
2257 | |||
2219 | def magic_rehashx(self, parameter_s = ''): |
|
2258 | def magic_rehashx(self, parameter_s = ''): | |
2220 | """Update the alias table with all executable files in $PATH. |
|
2259 | """Update the alias table with all executable files in $PATH. | |
2221 |
|
2260 | |||
2222 | This version explicitly checks that every entry in $PATH is a file |
|
2261 | This version explicitly checks that every entry in $PATH is a file | |
2223 | with execute access (os.X_OK), so it is much slower than %rehash. |
|
2262 | with execute access (os.X_OK), so it is much slower than %rehash. | |
2224 |
|
2263 | |||
2225 | Under Windows, it checks executability as a match agains a |
|
2264 | Under Windows, it checks executability as a match agains a | |
2226 | '|'-separated string of extensions, stored in the IPython config |
|
2265 | '|'-separated string of extensions, stored in the IPython config | |
2227 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ |
|
2266 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ | |
2228 |
|
2267 | |||
2229 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2268 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2230 | alias_table = self.shell.alias_table |
|
2269 | alias_table = self.shell.alias_table | |
2231 |
|
2270 | |||
2232 | if os.name == 'posix': |
|
2271 | if os.name == 'posix': | |
2233 | isexec = lambda fname:os.path.isfile(fname) and \ |
|
2272 | isexec = lambda fname:os.path.isfile(fname) and \ | |
2234 | os.access(fname,os.X_OK) |
|
2273 | os.access(fname,os.X_OK) | |
2235 | else: |
|
2274 | else: | |
2236 |
|
2275 | |||
2237 | try: |
|
2276 | try: | |
2238 | winext = os.environ['pathext'].replace(';','|').replace('.','') |
|
2277 | winext = os.environ['pathext'].replace(';','|').replace('.','') | |
2239 | except KeyError: |
|
2278 | except KeyError: | |
2240 | winext = 'exe|com|bat' |
|
2279 | winext = 'exe|com|bat' | |
2241 |
|
2280 | |||
2242 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) |
|
2281 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) | |
2243 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) |
|
2282 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) | |
2244 | savedir = os.getcwd() |
|
2283 | savedir = os.getcwd() | |
2245 | try: |
|
2284 | try: | |
2246 | # write the whole loop for posix/Windows so we don't have an if in |
|
2285 | # write the whole loop for posix/Windows so we don't have an if in | |
2247 | # the innermost part |
|
2286 | # the innermost part | |
2248 | if os.name == 'posix': |
|
2287 | if os.name == 'posix': | |
2249 | for pdir in path: |
|
2288 | for pdir in path: | |
2250 | os.chdir(pdir) |
|
2289 | os.chdir(pdir) | |
2251 | for ff in os.listdir(pdir): |
|
2290 | for ff in os.listdir(pdir): | |
2252 | if isexec(ff): |
|
2291 | if isexec(ff): | |
2253 | # each entry in the alias table must be (N,name), |
|
2292 | # each entry in the alias table must be (N,name), | |
2254 | # where N is the number of positional arguments of the |
|
2293 | # where N is the number of positional arguments of the | |
2255 | # alias. |
|
2294 | # alias. | |
2256 | alias_table[ff] = (0,ff) |
|
2295 | alias_table[ff] = (0,ff) | |
2257 | else: |
|
2296 | else: | |
2258 | for pdir in path: |
|
2297 | for pdir in path: | |
2259 | os.chdir(pdir) |
|
2298 | os.chdir(pdir) | |
2260 | for ff in os.listdir(pdir): |
|
2299 | for ff in os.listdir(pdir): | |
2261 | if isexec(ff): |
|
2300 | if isexec(ff): | |
2262 | alias_table[execre.sub(r'\1',ff)] = (0,ff) |
|
2301 | alias_table[execre.sub(r'\1',ff)] = (0,ff) | |
2263 | # Make sure the alias table doesn't contain keywords or builtins |
|
2302 | # Make sure the alias table doesn't contain keywords or builtins | |
2264 | self.shell.alias_table_validate() |
|
2303 | self.shell.alias_table_validate() | |
2265 | # Call again init_auto_alias() so we get 'rm -i' and other |
|
2304 | # Call again init_auto_alias() so we get 'rm -i' and other | |
2266 | # modified aliases since %rehashx will probably clobber them |
|
2305 | # modified aliases since %rehashx will probably clobber them | |
2267 | self.shell.init_auto_alias() |
|
2306 | self.shell.init_auto_alias() | |
2268 | finally: |
|
2307 | finally: | |
2269 | os.chdir(savedir) |
|
2308 | os.chdir(savedir) | |
2270 |
|
2309 | |||
2271 | def magic_pwd(self, parameter_s = ''): |
|
2310 | def magic_pwd(self, parameter_s = ''): | |
2272 | """Return the current working directory path.""" |
|
2311 | """Return the current working directory path.""" | |
2273 | return os.getcwd() |
|
2312 | return os.getcwd() | |
2274 |
|
2313 | |||
2275 | def magic_cd(self, parameter_s=''): |
|
2314 | def magic_cd(self, parameter_s=''): | |
2276 | """Change the current working directory. |
|
2315 | """Change the current working directory. | |
2277 |
|
2316 | |||
2278 | This command automatically maintains an internal list of directories |
|
2317 | This command automatically maintains an internal list of directories | |
2279 | you visit during your IPython session, in the variable _dh. The |
|
2318 | you visit during your IPython session, in the variable _dh. The | |
2280 | command %dhist shows this history nicely formatted. |
|
2319 | command %dhist shows this history nicely formatted. | |
2281 |
|
2320 | |||
2282 | Usage: |
|
2321 | Usage: | |
2283 |
|
2322 | |||
2284 | cd 'dir': changes to directory 'dir'. |
|
2323 | cd 'dir': changes to directory 'dir'. | |
2285 |
|
2324 | |||
2286 | cd -: changes to the last visited directory. |
|
2325 | cd -: changes to the last visited directory. | |
2287 |
|
2326 | |||
2288 | cd -<n>: changes to the n-th directory in the directory history. |
|
2327 | cd -<n>: changes to the n-th directory in the directory history. | |
2289 |
|
2328 | |||
2290 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark |
|
2329 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark | |
2291 | (note: cd <bookmark_name> is enough if there is no |
|
2330 | (note: cd <bookmark_name> is enough if there is no | |
2292 | directory <bookmark_name>, but a bookmark with the name exists.) |
|
2331 | directory <bookmark_name>, but a bookmark with the name exists.) | |
2293 |
|
2332 | |||
2294 | Options: |
|
2333 | Options: | |
2295 |
|
2334 | |||
2296 | -q: quiet. Do not print the working directory after the cd command is |
|
2335 | -q: quiet. Do not print the working directory after the cd command is | |
2297 | executed. By default IPython's cd command does print this directory, |
|
2336 | executed. By default IPython's cd command does print this directory, | |
2298 | since the default prompts do not display path information. |
|
2337 | since the default prompts do not display path information. | |
2299 |
|
2338 | |||
2300 | Note that !cd doesn't work for this purpose because the shell where |
|
2339 | Note that !cd doesn't work for this purpose because the shell where | |
2301 | !command runs is immediately discarded after executing 'command'.""" |
|
2340 | !command runs is immediately discarded after executing 'command'.""" | |
2302 |
|
2341 | |||
2303 | parameter_s = parameter_s.strip() |
|
2342 | parameter_s = parameter_s.strip() | |
2304 | #bkms = self.shell.persist.get("bookmarks",{}) |
|
2343 | #bkms = self.shell.persist.get("bookmarks",{}) | |
2305 |
|
2344 | |||
2306 | numcd = re.match(r'(-)(\d+)$',parameter_s) |
|
2345 | numcd = re.match(r'(-)(\d+)$',parameter_s) | |
2307 | # jump in directory history by number |
|
2346 | # jump in directory history by number | |
2308 | if numcd: |
|
2347 | if numcd: | |
2309 | nn = int(numcd.group(2)) |
|
2348 | nn = int(numcd.group(2)) | |
2310 | try: |
|
2349 | try: | |
2311 | ps = self.shell.user_ns['_dh'][nn] |
|
2350 | ps = self.shell.user_ns['_dh'][nn] | |
2312 | except IndexError: |
|
2351 | except IndexError: | |
2313 | print 'The requested directory does not exist in history.' |
|
2352 | print 'The requested directory does not exist in history.' | |
2314 | return |
|
2353 | return | |
2315 | else: |
|
2354 | else: | |
2316 | opts = {} |
|
2355 | opts = {} | |
2317 | else: |
|
2356 | else: | |
2318 | #turn all non-space-escaping backslashes to slashes, |
|
2357 | #turn all non-space-escaping backslashes to slashes, | |
2319 | # for c:\windows\directory\names\ |
|
2358 | # for c:\windows\directory\names\ | |
2320 | parameter_s = re.sub(r'\\(?! )','/', parameter_s) |
|
2359 | parameter_s = re.sub(r'\\(?! )','/', parameter_s) | |
2321 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') |
|
2360 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') | |
2322 | # jump to previous |
|
2361 | # jump to previous | |
2323 | if ps == '-': |
|
2362 | if ps == '-': | |
2324 | try: |
|
2363 | try: | |
2325 | ps = self.shell.user_ns['_dh'][-2] |
|
2364 | ps = self.shell.user_ns['_dh'][-2] | |
2326 | except IndexError: |
|
2365 | except IndexError: | |
2327 | print 'No previous directory to change to.' |
|
2366 | print 'No previous directory to change to.' | |
2328 | return |
|
2367 | return | |
2329 | # jump to bookmark if needed |
|
2368 | # jump to bookmark if needed | |
2330 | else: |
|
2369 | else: | |
2331 | if not os.path.isdir(ps) or opts.has_key('b'): |
|
2370 | if not os.path.isdir(ps) or opts.has_key('b'): | |
2332 | bkms = self.db.get('bookmarks', {}) |
|
2371 | bkms = self.db.get('bookmarks', {}) | |
2333 |
|
2372 | |||
2334 | if bkms.has_key(ps): |
|
2373 | if bkms.has_key(ps): | |
2335 | target = bkms[ps] |
|
2374 | target = bkms[ps] | |
2336 | print '(bookmark:%s) -> %s' % (ps,target) |
|
2375 | print '(bookmark:%s) -> %s' % (ps,target) | |
2337 | ps = target |
|
2376 | ps = target | |
2338 | else: |
|
2377 | else: | |
2339 | if opts.has_key('b'): |
|
2378 | if opts.has_key('b'): | |
2340 | error("Bookmark '%s' not found. " |
|
2379 | error("Bookmark '%s' not found. " | |
2341 | "Use '%%bookmark -l' to see your bookmarks." % ps) |
|
2380 | "Use '%%bookmark -l' to see your bookmarks." % ps) | |
2342 | return |
|
2381 | return | |
2343 |
|
2382 | |||
2344 | # at this point ps should point to the target dir |
|
2383 | # at this point ps should point to the target dir | |
2345 | if ps: |
|
2384 | if ps: | |
2346 | try: |
|
2385 | try: | |
2347 | os.chdir(os.path.expanduser(ps)) |
|
2386 | os.chdir(os.path.expanduser(ps)) | |
2348 | ttitle = ("IPy:" + ( |
|
2387 | ttitle = ("IPy:" + ( | |
2349 | os.getcwd() == '/' and '/' or os.path.basename(os.getcwd()))) |
|
2388 | os.getcwd() == '/' and '/' or os.path.basename(os.getcwd()))) | |
2350 | platutils.set_term_title(ttitle) |
|
2389 | platutils.set_term_title(ttitle) | |
2351 | except OSError: |
|
2390 | except OSError: | |
2352 | print sys.exc_info()[1] |
|
2391 | print sys.exc_info()[1] | |
2353 | else: |
|
2392 | else: | |
2354 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2393 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2355 | else: |
|
2394 | else: | |
2356 | os.chdir(self.shell.home_dir) |
|
2395 | os.chdir(self.shell.home_dir) | |
2357 | platutils.set_term_title("IPy:~") |
|
2396 | platutils.set_term_title("IPy:~") | |
2358 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2397 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2359 | if not 'q' in opts: |
|
2398 | if not 'q' in opts: | |
2360 | print self.shell.user_ns['_dh'][-1] |
|
2399 | print self.shell.user_ns['_dh'][-1] | |
2361 |
|
2400 | |||
2362 | def magic_dhist(self, parameter_s=''): |
|
2401 | def magic_dhist(self, parameter_s=''): | |
2363 | """Print your history of visited directories. |
|
2402 | """Print your history of visited directories. | |
2364 |
|
2403 | |||
2365 | %dhist -> print full history\\ |
|
2404 | %dhist -> print full history\\ | |
2366 | %dhist n -> print last n entries only\\ |
|
2405 | %dhist n -> print last n entries only\\ | |
2367 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ |
|
2406 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ | |
2368 |
|
2407 | |||
2369 | This history is automatically maintained by the %cd command, and |
|
2408 | This history is automatically maintained by the %cd command, and | |
2370 | always available as the global list variable _dh. You can use %cd -<n> |
|
2409 | always available as the global list variable _dh. You can use %cd -<n> | |
2371 | to go to directory number <n>.""" |
|
2410 | to go to directory number <n>.""" | |
2372 |
|
2411 | |||
2373 | dh = self.shell.user_ns['_dh'] |
|
2412 | dh = self.shell.user_ns['_dh'] | |
2374 | if parameter_s: |
|
2413 | if parameter_s: | |
2375 | try: |
|
2414 | try: | |
2376 | args = map(int,parameter_s.split()) |
|
2415 | args = map(int,parameter_s.split()) | |
2377 | except: |
|
2416 | except: | |
2378 | self.arg_err(Magic.magic_dhist) |
|
2417 | self.arg_err(Magic.magic_dhist) | |
2379 | return |
|
2418 | return | |
2380 | if len(args) == 1: |
|
2419 | if len(args) == 1: | |
2381 | ini,fin = max(len(dh)-(args[0]),0),len(dh) |
|
2420 | ini,fin = max(len(dh)-(args[0]),0),len(dh) | |
2382 | elif len(args) == 2: |
|
2421 | elif len(args) == 2: | |
2383 | ini,fin = args |
|
2422 | ini,fin = args | |
2384 | else: |
|
2423 | else: | |
2385 | self.arg_err(Magic.magic_dhist) |
|
2424 | self.arg_err(Magic.magic_dhist) | |
2386 | return |
|
2425 | return | |
2387 | else: |
|
2426 | else: | |
2388 | ini,fin = 0,len(dh) |
|
2427 | ini,fin = 0,len(dh) | |
2389 | nlprint(dh, |
|
2428 | nlprint(dh, | |
2390 | header = 'Directory history (kept in _dh)', |
|
2429 | header = 'Directory history (kept in _dh)', | |
2391 | start=ini,stop=fin) |
|
2430 | start=ini,stop=fin) | |
2392 |
|
2431 | |||
2393 | def magic_env(self, parameter_s=''): |
|
2432 | def magic_env(self, parameter_s=''): | |
2394 | """List environment variables.""" |
|
2433 | """List environment variables.""" | |
2395 |
|
2434 | |||
2396 | return os.environ.data |
|
2435 | return os.environ.data | |
2397 |
|
2436 | |||
2398 | def magic_pushd(self, parameter_s=''): |
|
2437 | def magic_pushd(self, parameter_s=''): | |
2399 | """Place the current dir on stack and change directory. |
|
2438 | """Place the current dir on stack and change directory. | |
2400 |
|
2439 | |||
2401 | Usage:\\ |
|
2440 | Usage:\\ | |
2402 | %pushd ['dirname'] |
|
2441 | %pushd ['dirname'] | |
2403 |
|
2442 | |||
2404 | %pushd with no arguments does a %pushd to your home directory. |
|
2443 | %pushd with no arguments does a %pushd to your home directory. | |
2405 | """ |
|
2444 | """ | |
2406 | if parameter_s == '': parameter_s = '~' |
|
2445 | if parameter_s == '': parameter_s = '~' | |
2407 | dir_s = self.shell.dir_stack |
|
2446 | dir_s = self.shell.dir_stack | |
2408 | if len(dir_s)>0 and os.path.expanduser(parameter_s) != \ |
|
2447 | if len(dir_s)>0 and os.path.expanduser(parameter_s) != \ | |
2409 | os.path.expanduser(self.shell.dir_stack[0]): |
|
2448 | os.path.expanduser(self.shell.dir_stack[0]): | |
2410 | try: |
|
2449 | try: | |
2411 | self.magic_cd(parameter_s) |
|
2450 | self.magic_cd(parameter_s) | |
2412 | dir_s.insert(0,os.getcwd().replace(self.home_dir,'~')) |
|
2451 | dir_s.insert(0,os.getcwd().replace(self.home_dir,'~')) | |
2413 | self.magic_dirs() |
|
2452 | self.magic_dirs() | |
2414 | except: |
|
2453 | except: | |
2415 | print 'Invalid directory' |
|
2454 | print 'Invalid directory' | |
2416 | else: |
|
2455 | else: | |
2417 | print 'You are already there!' |
|
2456 | print 'You are already there!' | |
2418 |
|
2457 | |||
2419 | def magic_popd(self, parameter_s=''): |
|
2458 | def magic_popd(self, parameter_s=''): | |
2420 | """Change to directory popped off the top of the stack. |
|
2459 | """Change to directory popped off the top of the stack. | |
2421 | """ |
|
2460 | """ | |
2422 | if len (self.shell.dir_stack) > 1: |
|
2461 | if len (self.shell.dir_stack) > 1: | |
2423 | self.shell.dir_stack.pop(0) |
|
2462 | self.shell.dir_stack.pop(0) | |
2424 | self.magic_cd(self.shell.dir_stack[0]) |
|
2463 | self.magic_cd(self.shell.dir_stack[0]) | |
2425 | print self.shell.dir_stack[0] |
|
2464 | print self.shell.dir_stack[0] | |
2426 | else: |
|
2465 | else: | |
2427 | print "You can't remove the starting directory from the stack:",\ |
|
2466 | print "You can't remove the starting directory from the stack:",\ | |
2428 | self.shell.dir_stack |
|
2467 | self.shell.dir_stack | |
2429 |
|
2468 | |||
2430 | def magic_dirs(self, parameter_s=''): |
|
2469 | def magic_dirs(self, parameter_s=''): | |
2431 | """Return the current directory stack.""" |
|
2470 | """Return the current directory stack.""" | |
2432 |
|
2471 | |||
2433 | return self.shell.dir_stack[:] |
|
2472 | return self.shell.dir_stack[:] | |
2434 |
|
2473 | |||
2435 | def magic_sc(self, parameter_s=''): |
|
2474 | def magic_sc(self, parameter_s=''): | |
2436 | """Shell capture - execute a shell command and capture its output. |
|
2475 | """Shell capture - execute a shell command and capture its output. | |
2437 |
|
2476 | |||
2438 | DEPRECATED. Suboptimal, retained for backwards compatibility. |
|
2477 | DEPRECATED. Suboptimal, retained for backwards compatibility. | |
2439 |
|
2478 | |||
2440 | You should use the form 'var = !command' instead. Example: |
|
2479 | You should use the form 'var = !command' instead. Example: | |
2441 |
|
2480 | |||
2442 | "%sc -l myfiles = ls ~" should now be written as |
|
2481 | "%sc -l myfiles = ls ~" should now be written as | |
2443 |
|
2482 | |||
2444 | "myfiles = !ls ~" |
|
2483 | "myfiles = !ls ~" | |
2445 |
|
2484 | |||
2446 | myfiles.s, myfiles.l and myfiles.n still apply as documented |
|
2485 | myfiles.s, myfiles.l and myfiles.n still apply as documented | |
2447 | below. |
|
2486 | below. | |
2448 |
|
2487 | |||
2449 | -- |
|
2488 | -- | |
2450 | %sc [options] varname=command |
|
2489 | %sc [options] varname=command | |
2451 |
|
2490 | |||
2452 | IPython will run the given command using commands.getoutput(), and |
|
2491 | IPython will run the given command using commands.getoutput(), and | |
2453 | will then update the user's interactive namespace with a variable |
|
2492 | will then update the user's interactive namespace with a variable | |
2454 | called varname, containing the value of the call. Your command can |
|
2493 | called varname, containing the value of the call. Your command can | |
2455 | contain shell wildcards, pipes, etc. |
|
2494 | contain shell wildcards, pipes, etc. | |
2456 |
|
2495 | |||
2457 | The '=' sign in the syntax is mandatory, and the variable name you |
|
2496 | The '=' sign in the syntax is mandatory, and the variable name you | |
2458 | supply must follow Python's standard conventions for valid names. |
|
2497 | supply must follow Python's standard conventions for valid names. | |
2459 |
|
2498 | |||
2460 | (A special format without variable name exists for internal use) |
|
2499 | (A special format without variable name exists for internal use) | |
2461 |
|
2500 | |||
2462 | Options: |
|
2501 | Options: | |
2463 |
|
2502 | |||
2464 | -l: list output. Split the output on newlines into a list before |
|
2503 | -l: list output. Split the output on newlines into a list before | |
2465 | assigning it to the given variable. By default the output is stored |
|
2504 | assigning it to the given variable. By default the output is stored | |
2466 | as a single string. |
|
2505 | as a single string. | |
2467 |
|
2506 | |||
2468 | -v: verbose. Print the contents of the variable. |
|
2507 | -v: verbose. Print the contents of the variable. | |
2469 |
|
2508 | |||
2470 | In most cases you should not need to split as a list, because the |
|
2509 | In most cases you should not need to split as a list, because the | |
2471 | returned value is a special type of string which can automatically |
|
2510 | returned value is a special type of string which can automatically | |
2472 | provide its contents either as a list (split on newlines) or as a |
|
2511 | provide its contents either as a list (split on newlines) or as a | |
2473 | space-separated string. These are convenient, respectively, either |
|
2512 | space-separated string. These are convenient, respectively, either | |
2474 | for sequential processing or to be passed to a shell command. |
|
2513 | for sequential processing or to be passed to a shell command. | |
2475 |
|
2514 | |||
2476 | For example: |
|
2515 | For example: | |
2477 |
|
2516 | |||
2478 | # Capture into variable a |
|
2517 | # Capture into variable a | |
2479 | In [9]: sc a=ls *py |
|
2518 | In [9]: sc a=ls *py | |
2480 |
|
2519 | |||
2481 | # a is a string with embedded newlines |
|
2520 | # a is a string with embedded newlines | |
2482 | In [10]: a |
|
2521 | In [10]: a | |
2483 | Out[10]: 'setup.py\nwin32_manual_post_install.py' |
|
2522 | Out[10]: 'setup.py\nwin32_manual_post_install.py' | |
2484 |
|
2523 | |||
2485 | # which can be seen as a list: |
|
2524 | # which can be seen as a list: | |
2486 | In [11]: a.l |
|
2525 | In [11]: a.l | |
2487 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] |
|
2526 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] | |
2488 |
|
2527 | |||
2489 | # or as a whitespace-separated string: |
|
2528 | # or as a whitespace-separated string: | |
2490 | In [12]: a.s |
|
2529 | In [12]: a.s | |
2491 | Out[12]: 'setup.py win32_manual_post_install.py' |
|
2530 | Out[12]: 'setup.py win32_manual_post_install.py' | |
2492 |
|
2531 | |||
2493 | # a.s is useful to pass as a single command line: |
|
2532 | # a.s is useful to pass as a single command line: | |
2494 | In [13]: !wc -l $a.s |
|
2533 | In [13]: !wc -l $a.s | |
2495 | 146 setup.py |
|
2534 | 146 setup.py | |
2496 | 130 win32_manual_post_install.py |
|
2535 | 130 win32_manual_post_install.py | |
2497 | 276 total |
|
2536 | 276 total | |
2498 |
|
2537 | |||
2499 | # while the list form is useful to loop over: |
|
2538 | # while the list form is useful to loop over: | |
2500 | In [14]: for f in a.l: |
|
2539 | In [14]: for f in a.l: | |
2501 | ....: !wc -l $f |
|
2540 | ....: !wc -l $f | |
2502 | ....: |
|
2541 | ....: | |
2503 | 146 setup.py |
|
2542 | 146 setup.py | |
2504 | 130 win32_manual_post_install.py |
|
2543 | 130 win32_manual_post_install.py | |
2505 |
|
2544 | |||
2506 | Similiarly, the lists returned by the -l option are also special, in |
|
2545 | Similiarly, the lists returned by the -l option are also special, in | |
2507 | the sense that you can equally invoke the .s attribute on them to |
|
2546 | the sense that you can equally invoke the .s attribute on them to | |
2508 | automatically get a whitespace-separated string from their contents: |
|
2547 | automatically get a whitespace-separated string from their contents: | |
2509 |
|
2548 | |||
2510 | In [1]: sc -l b=ls *py |
|
2549 | In [1]: sc -l b=ls *py | |
2511 |
|
2550 | |||
2512 | In [2]: b |
|
2551 | In [2]: b | |
2513 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] |
|
2552 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] | |
2514 |
|
2553 | |||
2515 | In [3]: b.s |
|
2554 | In [3]: b.s | |
2516 | Out[3]: 'setup.py win32_manual_post_install.py' |
|
2555 | Out[3]: 'setup.py win32_manual_post_install.py' | |
2517 |
|
2556 | |||
2518 | In summary, both the lists and strings used for ouptut capture have |
|
2557 | In summary, both the lists and strings used for ouptut capture have | |
2519 | the following special attributes: |
|
2558 | the following special attributes: | |
2520 |
|
2559 | |||
2521 | .l (or .list) : value as list. |
|
2560 | .l (or .list) : value as list. | |
2522 | .n (or .nlstr): value as newline-separated string. |
|
2561 | .n (or .nlstr): value as newline-separated string. | |
2523 | .s (or .spstr): value as space-separated string. |
|
2562 | .s (or .spstr): value as space-separated string. | |
2524 | """ |
|
2563 | """ | |
2525 |
|
2564 | |||
2526 | opts,args = self.parse_options(parameter_s,'lv') |
|
2565 | opts,args = self.parse_options(parameter_s,'lv') | |
2527 | # Try to get a variable name and command to run |
|
2566 | # Try to get a variable name and command to run | |
2528 | try: |
|
2567 | try: | |
2529 | # the variable name must be obtained from the parse_options |
|
2568 | # the variable name must be obtained from the parse_options | |
2530 | # output, which uses shlex.split to strip options out. |
|
2569 | # output, which uses shlex.split to strip options out. | |
2531 | var,_ = args.split('=',1) |
|
2570 | var,_ = args.split('=',1) | |
2532 | var = var.strip() |
|
2571 | var = var.strip() | |
2533 | # But the the command has to be extracted from the original input |
|
2572 | # But the the command has to be extracted from the original input | |
2534 | # parameter_s, not on what parse_options returns, to avoid the |
|
2573 | # parameter_s, not on what parse_options returns, to avoid the | |
2535 | # quote stripping which shlex.split performs on it. |
|
2574 | # quote stripping which shlex.split performs on it. | |
2536 | _,cmd = parameter_s.split('=',1) |
|
2575 | _,cmd = parameter_s.split('=',1) | |
2537 | except ValueError: |
|
2576 | except ValueError: | |
2538 | var,cmd = '','' |
|
2577 | var,cmd = '','' | |
2539 | # If all looks ok, proceed |
|
2578 | # If all looks ok, proceed | |
2540 | out,err = self.shell.getoutputerror(cmd) |
|
2579 | out,err = self.shell.getoutputerror(cmd) | |
2541 | if err: |
|
2580 | if err: | |
2542 | print >> Term.cerr,err |
|
2581 | print >> Term.cerr,err | |
2543 | if opts.has_key('l'): |
|
2582 | if opts.has_key('l'): | |
2544 | out = SList(out.split('\n')) |
|
2583 | out = SList(out.split('\n')) | |
2545 | else: |
|
2584 | else: | |
2546 | out = LSString(out) |
|
2585 | out = LSString(out) | |
2547 | if opts.has_key('v'): |
|
2586 | if opts.has_key('v'): | |
2548 | print '%s ==\n%s' % (var,pformat(out)) |
|
2587 | print '%s ==\n%s' % (var,pformat(out)) | |
2549 | if var: |
|
2588 | if var: | |
2550 | self.shell.user_ns.update({var:out}) |
|
2589 | self.shell.user_ns.update({var:out}) | |
2551 | else: |
|
2590 | else: | |
2552 | return out |
|
2591 | return out | |
2553 |
|
2592 | |||
2554 | def magic_sx(self, parameter_s=''): |
|
2593 | def magic_sx(self, parameter_s=''): | |
2555 | """Shell execute - run a shell command and capture its output. |
|
2594 | """Shell execute - run a shell command and capture its output. | |
2556 |
|
2595 | |||
2557 | %sx command |
|
2596 | %sx command | |
2558 |
|
2597 | |||
2559 | IPython will run the given command using commands.getoutput(), and |
|
2598 | IPython will run the given command using commands.getoutput(), and | |
2560 | return the result formatted as a list (split on '\\n'). Since the |
|
2599 | return the result formatted as a list (split on '\\n'). Since the | |
2561 | output is _returned_, it will be stored in ipython's regular output |
|
2600 | output is _returned_, it will be stored in ipython's regular output | |
2562 | cache Out[N] and in the '_N' automatic variables. |
|
2601 | cache Out[N] and in the '_N' automatic variables. | |
2563 |
|
2602 | |||
2564 | Notes: |
|
2603 | Notes: | |
2565 |
|
2604 | |||
2566 | 1) If an input line begins with '!!', then %sx is automatically |
|
2605 | 1) If an input line begins with '!!', then %sx is automatically | |
2567 | invoked. That is, while: |
|
2606 | invoked. That is, while: | |
2568 | !ls |
|
2607 | !ls | |
2569 | causes ipython to simply issue system('ls'), typing |
|
2608 | causes ipython to simply issue system('ls'), typing | |
2570 | !!ls |
|
2609 | !!ls | |
2571 | is a shorthand equivalent to: |
|
2610 | is a shorthand equivalent to: | |
2572 | %sx ls |
|
2611 | %sx ls | |
2573 |
|
2612 | |||
2574 | 2) %sx differs from %sc in that %sx automatically splits into a list, |
|
2613 | 2) %sx differs from %sc in that %sx automatically splits into a list, | |
2575 | like '%sc -l'. The reason for this is to make it as easy as possible |
|
2614 | like '%sc -l'. The reason for this is to make it as easy as possible | |
2576 | to process line-oriented shell output via further python commands. |
|
2615 | to process line-oriented shell output via further python commands. | |
2577 | %sc is meant to provide much finer control, but requires more |
|
2616 | %sc is meant to provide much finer control, but requires more | |
2578 | typing. |
|
2617 | typing. | |
2579 |
|
2618 | |||
2580 | 3) Just like %sc -l, this is a list with special attributes: |
|
2619 | 3) Just like %sc -l, this is a list with special attributes: | |
2581 |
|
2620 | |||
2582 | .l (or .list) : value as list. |
|
2621 | .l (or .list) : value as list. | |
2583 | .n (or .nlstr): value as newline-separated string. |
|
2622 | .n (or .nlstr): value as newline-separated string. | |
2584 | .s (or .spstr): value as whitespace-separated string. |
|
2623 | .s (or .spstr): value as whitespace-separated string. | |
2585 |
|
2624 | |||
2586 | This is very useful when trying to use such lists as arguments to |
|
2625 | This is very useful when trying to use such lists as arguments to | |
2587 | system commands.""" |
|
2626 | system commands.""" | |
2588 |
|
2627 | |||
2589 | if parameter_s: |
|
2628 | if parameter_s: | |
2590 | out,err = self.shell.getoutputerror(parameter_s) |
|
2629 | out,err = self.shell.getoutputerror(parameter_s) | |
2591 | if err: |
|
2630 | if err: | |
2592 | print >> Term.cerr,err |
|
2631 | print >> Term.cerr,err | |
2593 | return SList(out.split('\n')) |
|
2632 | return SList(out.split('\n')) | |
2594 |
|
2633 | |||
2595 | def magic_bg(self, parameter_s=''): |
|
2634 | def magic_bg(self, parameter_s=''): | |
2596 | """Run a job in the background, in a separate thread. |
|
2635 | """Run a job in the background, in a separate thread. | |
2597 |
|
2636 | |||
2598 | For example, |
|
2637 | For example, | |
2599 |
|
2638 | |||
2600 | %bg myfunc(x,y,z=1) |
|
2639 | %bg myfunc(x,y,z=1) | |
2601 |
|
2640 | |||
2602 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the |
|
2641 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the | |
2603 | execution starts, a message will be printed indicating the job |
|
2642 | execution starts, a message will be printed indicating the job | |
2604 | number. If your job number is 5, you can use |
|
2643 | number. If your job number is 5, you can use | |
2605 |
|
2644 | |||
2606 | myvar = jobs.result(5) or myvar = jobs[5].result |
|
2645 | myvar = jobs.result(5) or myvar = jobs[5].result | |
2607 |
|
2646 | |||
2608 | to assign this result to variable 'myvar'. |
|
2647 | to assign this result to variable 'myvar'. | |
2609 |
|
2648 | |||
2610 | IPython has a job manager, accessible via the 'jobs' object. You can |
|
2649 | IPython has a job manager, accessible via the 'jobs' object. You can | |
2611 | type jobs? to get more information about it, and use jobs.<TAB> to see |
|
2650 | type jobs? to get more information about it, and use jobs.<TAB> to see | |
2612 | its attributes. All attributes not starting with an underscore are |
|
2651 | its attributes. All attributes not starting with an underscore are | |
2613 | meant for public use. |
|
2652 | meant for public use. | |
2614 |
|
2653 | |||
2615 | In particular, look at the jobs.new() method, which is used to create |
|
2654 | In particular, look at the jobs.new() method, which is used to create | |
2616 | new jobs. This magic %bg function is just a convenience wrapper |
|
2655 | new jobs. This magic %bg function is just a convenience wrapper | |
2617 | around jobs.new(), for expression-based jobs. If you want to create a |
|
2656 | around jobs.new(), for expression-based jobs. If you want to create a | |
2618 | new job with an explicit function object and arguments, you must call |
|
2657 | new job with an explicit function object and arguments, you must call | |
2619 | jobs.new() directly. |
|
2658 | jobs.new() directly. | |
2620 |
|
2659 | |||
2621 | The jobs.new docstring also describes in detail several important |
|
2660 | The jobs.new docstring also describes in detail several important | |
2622 | caveats associated with a thread-based model for background job |
|
2661 | caveats associated with a thread-based model for background job | |
2623 | execution. Type jobs.new? for details. |
|
2662 | execution. Type jobs.new? for details. | |
2624 |
|
2663 | |||
2625 | You can check the status of all jobs with jobs.status(). |
|
2664 | You can check the status of all jobs with jobs.status(). | |
2626 |
|
2665 | |||
2627 | The jobs variable is set by IPython into the Python builtin namespace. |
|
2666 | The jobs variable is set by IPython into the Python builtin namespace. | |
2628 | If you ever declare a variable named 'jobs', you will shadow this |
|
2667 | If you ever declare a variable named 'jobs', you will shadow this | |
2629 | name. You can either delete your global jobs variable to regain |
|
2668 | name. You can either delete your global jobs variable to regain | |
2630 | access to the job manager, or make a new name and assign it manually |
|
2669 | access to the job manager, or make a new name and assign it manually | |
2631 | to the manager (stored in IPython's namespace). For example, to |
|
2670 | to the manager (stored in IPython's namespace). For example, to | |
2632 | assign the job manager to the Jobs name, use: |
|
2671 | assign the job manager to the Jobs name, use: | |
2633 |
|
2672 | |||
2634 | Jobs = __builtins__.jobs""" |
|
2673 | Jobs = __builtins__.jobs""" | |
2635 |
|
2674 | |||
2636 | self.shell.jobs.new(parameter_s,self.shell.user_ns) |
|
2675 | self.shell.jobs.new(parameter_s,self.shell.user_ns) | |
2637 |
|
2676 | |||
2638 |
|
2677 | |||
2639 | def magic_bookmark(self, parameter_s=''): |
|
2678 | def magic_bookmark(self, parameter_s=''): | |
2640 | """Manage IPython's bookmark system. |
|
2679 | """Manage IPython's bookmark system. | |
2641 |
|
2680 | |||
2642 | %bookmark <name> - set bookmark to current dir |
|
2681 | %bookmark <name> - set bookmark to current dir | |
2643 | %bookmark <name> <dir> - set bookmark to <dir> |
|
2682 | %bookmark <name> <dir> - set bookmark to <dir> | |
2644 | %bookmark -l - list all bookmarks |
|
2683 | %bookmark -l - list all bookmarks | |
2645 | %bookmark -d <name> - remove bookmark |
|
2684 | %bookmark -d <name> - remove bookmark | |
2646 | %bookmark -r - remove all bookmarks |
|
2685 | %bookmark -r - remove all bookmarks | |
2647 |
|
2686 | |||
2648 | You can later on access a bookmarked folder with: |
|
2687 | You can later on access a bookmarked folder with: | |
2649 | %cd -b <name> |
|
2688 | %cd -b <name> | |
2650 | or simply '%cd <name>' if there is no directory called <name> AND |
|
2689 | or simply '%cd <name>' if there is no directory called <name> AND | |
2651 | there is such a bookmark defined. |
|
2690 | there is such a bookmark defined. | |
2652 |
|
2691 | |||
2653 | Your bookmarks persist through IPython sessions, but they are |
|
2692 | Your bookmarks persist through IPython sessions, but they are | |
2654 | associated with each profile.""" |
|
2693 | associated with each profile.""" | |
2655 |
|
2694 | |||
2656 | opts,args = self.parse_options(parameter_s,'drl',mode='list') |
|
2695 | opts,args = self.parse_options(parameter_s,'drl',mode='list') | |
2657 | if len(args) > 2: |
|
2696 | if len(args) > 2: | |
2658 | error('You can only give at most two arguments') |
|
2697 | error('You can only give at most two arguments') | |
2659 | return |
|
2698 | return | |
2660 |
|
2699 | |||
2661 | bkms = self.db.get('bookmarks',{}) |
|
2700 | bkms = self.db.get('bookmarks',{}) | |
2662 |
|
2701 | |||
2663 | if opts.has_key('d'): |
|
2702 | if opts.has_key('d'): | |
2664 | try: |
|
2703 | try: | |
2665 | todel = args[0] |
|
2704 | todel = args[0] | |
2666 | except IndexError: |
|
2705 | except IndexError: | |
2667 | error('You must provide a bookmark to delete') |
|
2706 | error('You must provide a bookmark to delete') | |
2668 | else: |
|
2707 | else: | |
2669 | try: |
|
2708 | try: | |
2670 | del bkms[todel] |
|
2709 | del bkms[todel] | |
2671 | except: |
|
2710 | except: | |
2672 | error("Can't delete bookmark '%s'" % todel) |
|
2711 | error("Can't delete bookmark '%s'" % todel) | |
2673 | elif opts.has_key('r'): |
|
2712 | elif opts.has_key('r'): | |
2674 | bkms = {} |
|
2713 | bkms = {} | |
2675 | elif opts.has_key('l'): |
|
2714 | elif opts.has_key('l'): | |
2676 | bks = bkms.keys() |
|
2715 | bks = bkms.keys() | |
2677 | bks.sort() |
|
2716 | bks.sort() | |
2678 | if bks: |
|
2717 | if bks: | |
2679 | size = max(map(len,bks)) |
|
2718 | size = max(map(len,bks)) | |
2680 | else: |
|
2719 | else: | |
2681 | size = 0 |
|
2720 | size = 0 | |
2682 | fmt = '%-'+str(size)+'s -> %s' |
|
2721 | fmt = '%-'+str(size)+'s -> %s' | |
2683 | print 'Current bookmarks:' |
|
2722 | print 'Current bookmarks:' | |
2684 | for bk in bks: |
|
2723 | for bk in bks: | |
2685 | print fmt % (bk,bkms[bk]) |
|
2724 | print fmt % (bk,bkms[bk]) | |
2686 | else: |
|
2725 | else: | |
2687 | if not args: |
|
2726 | if not args: | |
2688 | error("You must specify the bookmark name") |
|
2727 | error("You must specify the bookmark name") | |
2689 | elif len(args)==1: |
|
2728 | elif len(args)==1: | |
2690 | bkms[args[0]] = os.getcwd() |
|
2729 | bkms[args[0]] = os.getcwd() | |
2691 | elif len(args)==2: |
|
2730 | elif len(args)==2: | |
2692 | bkms[args[0]] = args[1] |
|
2731 | bkms[args[0]] = args[1] | |
2693 | self.db['bookmarks'] = bkms |
|
2732 | self.db['bookmarks'] = bkms | |
2694 |
|
2733 | |||
2695 | def magic_pycat(self, parameter_s=''): |
|
2734 | def magic_pycat(self, parameter_s=''): | |
2696 | """Show a syntax-highlighted file through a pager. |
|
2735 | """Show a syntax-highlighted file through a pager. | |
2697 |
|
2736 | |||
2698 | This magic is similar to the cat utility, but it will assume the file |
|
2737 | This magic is similar to the cat utility, but it will assume the file | |
2699 | to be Python source and will show it with syntax highlighting. """ |
|
2738 | to be Python source and will show it with syntax highlighting. """ | |
2700 |
|
2739 | |||
2701 | try: |
|
2740 | try: | |
2702 | filename = get_py_filename(parameter_s) |
|
2741 | filename = get_py_filename(parameter_s) | |
2703 | cont = file_read(filename) |
|
2742 | cont = file_read(filename) | |
2704 | except IOError: |
|
2743 | except IOError: | |
2705 | try: |
|
2744 | try: | |
2706 | cont = eval(parameter_s,self.user_ns) |
|
2745 | cont = eval(parameter_s,self.user_ns) | |
2707 | except NameError: |
|
2746 | except NameError: | |
2708 | cont = None |
|
2747 | cont = None | |
2709 | if cont is None: |
|
2748 | if cont is None: | |
2710 | print "Error: no such file or variable" |
|
2749 | print "Error: no such file or variable" | |
2711 | return |
|
2750 | return | |
2712 |
|
2751 | |||
2713 | page(self.shell.pycolorize(cont), |
|
2752 | page(self.shell.pycolorize(cont), | |
2714 | screen_lines=self.shell.rc.screen_length) |
|
2753 | screen_lines=self.shell.rc.screen_length) | |
2715 |
|
2754 | |||
2716 | def magic_cpaste(self, parameter_s=''): |
|
2755 | def magic_cpaste(self, parameter_s=''): | |
2717 | """Allows you to paste & execute a pre-formatted code block from |
|
2756 | """Allows you to paste & execute a pre-formatted code block from | |
2718 | clipboard. |
|
2757 | clipboard. | |
2719 |
|
2758 | |||
2720 | You must terminate the block with '--' (two minus-signs) alone on the |
|
2759 | You must terminate the block with '--' (two minus-signs) alone on the | |
2721 | line. You can also provide your own sentinel with '%paste -s %%' ('%%' |
|
2760 | line. You can also provide your own sentinel with '%paste -s %%' ('%%' | |
2722 | is the new sentinel for this operation) |
|
2761 | is the new sentinel for this operation) | |
2723 |
|
2762 | |||
2724 | The block is dedented prior to execution to enable execution of |
|
2763 | The block is dedented prior to execution to enable execution of | |
2725 | method definitions. The executed block is also assigned to variable |
|
2764 | method definitions. The executed block is also assigned to variable | |
2726 | named 'pasted_block' for later editing with '%edit pasted_block'. |
|
2765 | named 'pasted_block' for later editing with '%edit pasted_block'. | |
2727 |
|
2766 | |||
2728 | You can also pass a variable name as an argument, e.g. '%cpaste foo'. |
|
2767 | You can also pass a variable name as an argument, e.g. '%cpaste foo'. | |
2729 | This assigns the pasted block to variable 'foo' as string, without |
|
2768 | This assigns the pasted block to variable 'foo' as string, without | |
2730 | dedenting or executing it. |
|
2769 | dedenting or executing it. | |
2731 |
|
2770 | |||
2732 | Do not be alarmed by garbled output on Windows (it's a readline bug). |
|
2771 | Do not be alarmed by garbled output on Windows (it's a readline bug). | |
2733 | Just press enter and type -- (and press enter again) and the block |
|
2772 | Just press enter and type -- (and press enter again) and the block | |
2734 | will be what was just pasted. |
|
2773 | will be what was just pasted. | |
2735 |
|
2774 | |||
2736 | IPython statements (magics, shell escapes) are not supported (yet). |
|
2775 | IPython statements (magics, shell escapes) are not supported (yet). | |
2737 | """ |
|
2776 | """ | |
2738 | opts,args = self.parse_options(parameter_s,'s:',mode='string') |
|
2777 | opts,args = self.parse_options(parameter_s,'s:',mode='string') | |
2739 | par = args.strip() |
|
2778 | par = args.strip() | |
2740 | sentinel = opts.get('s','--') |
|
2779 | sentinel = opts.get('s','--') | |
2741 |
|
2780 | |||
2742 | from IPython import iplib |
|
2781 | from IPython import iplib | |
2743 | lines = [] |
|
2782 | lines = [] | |
2744 | print "Pasting code; enter '%s' alone on the line to stop." % sentinel |
|
2783 | print "Pasting code; enter '%s' alone on the line to stop." % sentinel | |
2745 | while 1: |
|
2784 | while 1: | |
2746 | l = iplib.raw_input_original(':') |
|
2785 | l = iplib.raw_input_original(':') | |
2747 | if l ==sentinel: |
|
2786 | if l ==sentinel: | |
2748 | break |
|
2787 | break | |
2749 | lines.append(l) |
|
2788 | lines.append(l) | |
2750 | block = "\n".join(lines) + '\n' |
|
2789 | block = "\n".join(lines) + '\n' | |
2751 | #print "block:\n",block |
|
2790 | #print "block:\n",block | |
2752 | if not par: |
|
2791 | if not par: | |
2753 | b = textwrap.dedent(block) |
|
2792 | b = textwrap.dedent(block) | |
2754 | exec b in self.user_ns |
|
2793 | exec b in self.user_ns | |
2755 | self.user_ns['pasted_block'] = b |
|
2794 | self.user_ns['pasted_block'] = b | |
2756 | else: |
|
2795 | else: | |
2757 | self.user_ns[par] = block |
|
2796 | self.user_ns[par] = block | |
2758 | print "Block assigned to '%s'" % par |
|
2797 | print "Block assigned to '%s'" % par | |
2759 | def magic_quickref(self,arg): |
|
2798 | def magic_quickref(self,arg): | |
2760 | import IPython.usage |
|
2799 | import IPython.usage | |
2761 | page(IPython.usage.quick_reference) |
|
2800 | page(IPython.usage.quick_reference) | |
2762 | del IPython.usage |
|
2801 | del IPython.usage | |
2763 |
|
2802 | |||
2764 |
|
2803 | |||
2765 | # end Magic |
|
2804 | # end Magic |
@@ -1,311 +1,418 b'' | |||||
1 | """Module for interactive demos using IPython. |
|
1 | """Module for interactive demos using IPython. | |
2 |
|
2 | |||
3 |
This module implements a |
|
3 | This module implements a few classes for running Python scripts interactively | |
4 |
|
|
4 | in IPython for demonstrations. With very simple markup (a few tags in | |
5 |
|
|
5 | comments), you can control points where the script stops executing and returns | |
6 |
|
|
6 | control to IPython. | |
|
7 | ||||
|
8 | The classes are (see their docstrings for further details): | |||
|
9 | ||||
|
10 | - Demo: pure python demos | |||
|
11 | ||||
|
12 | - IPythonDemo: demos with input to be processed by IPython as if it had been | |||
|
13 | typed interactively (so magics work, as well as any other special syntax you | |||
|
14 | may have added via input prefilters). | |||
|
15 | ||||
|
16 | - LineDemo: single-line version of the Demo class. These demos are executed | |||
|
17 | one line at a time, and require no markup. | |||
|
18 | ||||
|
19 | - IPythonLineDemo: IPython version of the LineDemo class (the demo is | |||
|
20 | executed a line at a time, but processed via IPython). | |||
|
21 | ||||
7 |
|
22 | |||
8 | The file is run in its own empty namespace (though you can pass it a string of |
|
23 | The file is run in its own empty namespace (though you can pass it a string of | |
9 | arguments as if in a command line environment, and it will see those as |
|
24 | arguments as if in a command line environment, and it will see those as | |
10 | sys.argv). But at each stop, the global IPython namespace is updated with the |
|
25 | sys.argv). But at each stop, the global IPython namespace is updated with the | |
11 | current internal demo namespace, so you can work interactively with the data |
|
26 | current internal demo namespace, so you can work interactively with the data | |
12 | accumulated so far. |
|
27 | accumulated so far. | |
13 |
|
28 | |||
14 | By default, each block of code is printed (with syntax highlighting) before |
|
29 | By default, each block of code is printed (with syntax highlighting) before | |
15 | executing it and you have to confirm execution. This is intended to show the |
|
30 | executing it and you have to confirm execution. This is intended to show the | |
16 | code to an audience first so you can discuss it, and only proceed with |
|
31 | code to an audience first so you can discuss it, and only proceed with | |
17 | execution once you agree. There are a few tags which allow you to modify this |
|
32 | execution once you agree. There are a few tags which allow you to modify this | |
18 | behavior. |
|
33 | behavior. | |
19 |
|
34 | |||
20 | The supported tags are: |
|
35 | The supported tags are: | |
21 |
|
36 | |||
22 | # <demo> --- stop --- |
|
37 | # <demo> --- stop --- | |
23 |
|
38 | |||
24 | Defines block boundaries, the points where IPython stops execution of the |
|
39 | Defines block boundaries, the points where IPython stops execution of the | |
25 | file and returns to the interactive prompt. |
|
40 | file and returns to the interactive prompt. | |
26 |
|
41 | |||
27 | # <demo> silent |
|
42 | # <demo> silent | |
28 |
|
43 | |||
29 | Make a block execute silently (and hence automatically). Typically used in |
|
44 | Make a block execute silently (and hence automatically). Typically used in | |
30 | cases where you have some boilerplate or initialization code which you need |
|
45 | cases where you have some boilerplate or initialization code which you need | |
31 | executed but do not want to be seen in the demo. |
|
46 | executed but do not want to be seen in the demo. | |
32 |
|
47 | |||
33 | # <demo> auto |
|
48 | # <demo> auto | |
34 |
|
49 | |||
35 | Make a block execute automatically, but still being printed. Useful for |
|
50 | Make a block execute automatically, but still being printed. Useful for | |
36 | simple code which does not warrant discussion, since it avoids the extra |
|
51 | simple code which does not warrant discussion, since it avoids the extra | |
37 | manual confirmation. |
|
52 | manual confirmation. | |
38 |
|
53 | |||
39 | # <demo> auto_all |
|
54 | # <demo> auto_all | |
40 |
|
55 | |||
41 | This tag can _only_ be in the first block, and if given it overrides the |
|
56 | This tag can _only_ be in the first block, and if given it overrides the | |
42 | individual auto tags to make the whole demo fully automatic (no block asks |
|
57 | individual auto tags to make the whole demo fully automatic (no block asks | |
43 | for confirmation). It can also be given at creation time (or the attribute |
|
58 | for confirmation). It can also be given at creation time (or the attribute | |
44 | set later) to override what's in the file. |
|
59 | set later) to override what's in the file. | |
45 |
|
60 | |||
46 | While _any_ python file can be run as a Demo instance, if there are no stop |
|
61 | While _any_ python file can be run as a Demo instance, if there are no stop | |
47 | tags the whole file will run in a single block (no different that calling |
|
62 | tags the whole file will run in a single block (no different that calling | |
48 | first %pycat and then %run). The minimal markup to make this useful is to |
|
63 | first %pycat and then %run). The minimal markup to make this useful is to | |
49 | place a set of stop tags; the other tags are only there to let you fine-tune |
|
64 | place a set of stop tags; the other tags are only there to let you fine-tune | |
50 | the execution. |
|
65 | the execution. | |
51 |
|
66 | |||
52 | This is probably best explained with the simple example file below. You can |
|
67 | This is probably best explained with the simple example file below. You can | |
53 | copy this into a file named ex_demo.py, and try running it via: |
|
68 | copy this into a file named ex_demo.py, and try running it via: | |
54 |
|
69 | |||
55 | from IPython.demo import Demo |
|
70 | from IPython.demo import Demo | |
56 | d = Demo('ex_demo.py') |
|
71 | d = Demo('ex_demo.py') | |
57 |
d() <--- Call the d object (omit the parens if you have autocall |
|
72 | d() <--- Call the d object (omit the parens if you have autocall set to 2). | |
58 |
|
73 | |||
59 | Each time you call the demo object, it runs the next block. The demo object |
|
74 | Each time you call the demo object, it runs the next block. The demo object | |
60 |
has a few useful methods for navigation, like again(), jump(), seek() |
|
75 | has a few useful methods for navigation, like again(), edit(), jump(), seek() | |
61 |
back(). It can be reset for a new run via reset() or reloaded from disk |
|
76 | and back(). It can be reset for a new run via reset() or reloaded from disk | |
62 | case you've edited the source) via reload(). See their docstrings below. |
|
77 | (in case you've edited the source) via reload(). See their docstrings below. | |
63 |
|
78 | |||
64 | #################### EXAMPLE DEMO <ex_demo.py> ############################### |
|
79 | #################### EXAMPLE DEMO <ex_demo.py> ############################### | |
65 | '''A simple interactive demo to illustrate the use of IPython's Demo class.''' |
|
80 | '''A simple interactive demo to illustrate the use of IPython's Demo class.''' | |
66 |
|
81 | |||
67 | print 'Hello, welcome to an interactive IPython demo.' |
|
82 | print 'Hello, welcome to an interactive IPython demo.' | |
68 |
|
83 | |||
69 | # The mark below defines a block boundary, which is a point where IPython will |
|
84 | # The mark below defines a block boundary, which is a point where IPython will | |
70 | # stop execution and return to the interactive prompt. |
|
85 | # stop execution and return to the interactive prompt. | |
71 | # Note that in actual interactive execution, |
|
86 | # Note that in actual interactive execution, | |
72 | # <demo> --- stop --- |
|
87 | # <demo> --- stop --- | |
73 |
|
88 | |||
74 | x = 1 |
|
89 | x = 1 | |
75 | y = 2 |
|
90 | y = 2 | |
76 |
|
91 | |||
77 | # <demo> --- stop --- |
|
92 | # <demo> --- stop --- | |
78 |
|
93 | |||
79 | # the mark below makes this block as silent |
|
94 | # the mark below makes this block as silent | |
80 | # <demo> silent |
|
95 | # <demo> silent | |
81 |
|
96 | |||
82 | print 'This is a silent block, which gets executed but not printed.' |
|
97 | print 'This is a silent block, which gets executed but not printed.' | |
83 |
|
98 | |||
84 | # <demo> --- stop --- |
|
99 | # <demo> --- stop --- | |
85 | # <demo> auto |
|
100 | # <demo> auto | |
86 | print 'This is an automatic block.' |
|
101 | print 'This is an automatic block.' | |
87 | print 'It is executed without asking for confirmation, but printed.' |
|
102 | print 'It is executed without asking for confirmation, but printed.' | |
88 | z = x+y |
|
103 | z = x+y | |
89 |
|
104 | |||
90 | print 'z=',x |
|
105 | print 'z=',x | |
91 |
|
106 | |||
92 | # <demo> --- stop --- |
|
107 | # <demo> --- stop --- | |
93 | # This is just another normal block. |
|
108 | # This is just another normal block. | |
94 | print 'z is now:', z |
|
109 | print 'z is now:', z | |
95 |
|
110 | |||
96 | print 'bye!' |
|
111 | print 'bye!' | |
97 | ################### END EXAMPLE DEMO <ex_demo.py> ############################ |
|
112 | ################### END EXAMPLE DEMO <ex_demo.py> ############################ | |
98 |
|
||||
99 | WARNING: this module uses Python 2.3 features, so it won't work in 2.2 |
|
|||
100 | environments. |
|
|||
101 | """ |
|
113 | """ | |
102 | #***************************************************************************** |
|
114 | #***************************************************************************** | |
103 | # Copyright (C) 2005-2006 Fernando Perez. <Fernando.Perez@colorado.edu> |
|
115 | # Copyright (C) 2005-2006 Fernando Perez. <Fernando.Perez@colorado.edu> | |
104 | # |
|
116 | # | |
105 | # Distributed under the terms of the BSD License. The full license is in |
|
117 | # Distributed under the terms of the BSD License. The full license is in | |
106 | # the file COPYING, distributed as part of this software. |
|
118 | # the file COPYING, distributed as part of this software. | |
107 | # |
|
119 | # | |
108 | #***************************************************************************** |
|
120 | #***************************************************************************** | |
109 |
|
121 | |||
110 | import exceptions |
|
122 | import exceptions | |
|
123 | import os | |||
111 | import re |
|
124 | import re | |
112 | import sys |
|
125 | import sys | |
113 |
|
126 | |||
114 | from IPython.PyColorize import Parser |
|
127 | from IPython.PyColorize import Parser | |
115 | from IPython.genutils import marquee, shlex_split, file_read |
|
128 | from IPython.genutils import marquee, shlex_split, file_read, file_readlines | |
116 |
|
129 | |||
117 | __all__ = ['Demo','DemoError'] |
|
130 | __all__ = ['Demo','IPythonDemo','LineDemo','IPythonLineDemo','DemoError'] | |
118 |
|
131 | |||
119 | class DemoError(exceptions.Exception): pass |
|
132 | class DemoError(exceptions.Exception): pass | |
120 |
|
133 | |||
121 | def re_mark(mark): |
|
134 | def re_mark(mark): | |
122 | return re.compile(r'^\s*#\s+<demo>\s+%s\s*$' % mark,re.MULTILINE) |
|
135 | return re.compile(r'^\s*#\s+<demo>\s+%s\s*$' % mark,re.MULTILINE) | |
123 |
|
136 | |||
124 | class Demo: |
|
137 | class Demo: | |
125 |
|
138 | |||
126 | re_stop = re_mark('---\s?stop\s?---') |
|
139 | re_stop = re_mark('---\s?stop\s?---') | |
127 | re_silent = re_mark('silent') |
|
140 | re_silent = re_mark('silent') | |
128 | re_auto = re_mark('auto') |
|
141 | re_auto = re_mark('auto') | |
129 | re_auto_all = re_mark('auto_all') |
|
142 | re_auto_all = re_mark('auto_all') | |
130 |
|
143 | |||
131 | def __init__(self,fname,arg_str='',auto_all=None): |
|
144 | def __init__(self,fname,arg_str='',auto_all=None): | |
132 | """Make a new demo object. To run the demo, simply call the object. |
|
145 | """Make a new demo object. To run the demo, simply call the object. | |
133 |
|
146 | |||
134 | See the module docstring for full details and an example (you can use |
|
147 | See the module docstring for full details and an example (you can use | |
135 | IPython.Demo? in IPython to see it). |
|
148 | IPython.Demo? in IPython to see it). | |
136 |
|
149 | |||
137 | Inputs: |
|
150 | Inputs: | |
138 |
|
151 | |||
139 | - fname = filename. |
|
152 | - fname = filename. | |
140 |
|
153 | |||
141 | Optional inputs: |
|
154 | Optional inputs: | |
142 |
|
155 | |||
143 | - arg_str(''): a string of arguments, internally converted to a list |
|
156 | - arg_str(''): a string of arguments, internally converted to a list | |
144 | just like sys.argv, so the demo script can see a similar |
|
157 | just like sys.argv, so the demo script can see a similar | |
145 | environment. |
|
158 | environment. | |
146 |
|
159 | |||
147 | - auto_all(None): global flag to run all blocks automatically without |
|
160 | - auto_all(None): global flag to run all blocks automatically without | |
148 | confirmation. This attribute overrides the block-level tags and |
|
161 | confirmation. This attribute overrides the block-level tags and | |
149 | applies to the whole demo. It is an attribute of the object, and |
|
162 | applies to the whole demo. It is an attribute of the object, and | |
150 | can be changed at runtime simply by reassigning it to a boolean |
|
163 | can be changed at runtime simply by reassigning it to a boolean | |
151 | value. |
|
164 | value. | |
152 | """ |
|
165 | """ | |
153 |
|
166 | |||
154 | self.fname = fname |
|
167 | self.fname = fname | |
155 | self.sys_argv = [fname] + shlex_split(arg_str) |
|
168 | self.sys_argv = [fname] + shlex_split(arg_str) | |
156 | self.auto_all = auto_all |
|
169 | self.auto_all = auto_all | |
157 |
|
170 | |||
158 | # get a few things from ipython. While it's a bit ugly design-wise, |
|
171 | # get a few things from ipython. While it's a bit ugly design-wise, | |
159 | # it ensures that things like color scheme and the like are always in |
|
172 | # it ensures that things like color scheme and the like are always in | |
160 | # sync with the ipython mode being used. This class is only meant to |
|
173 | # sync with the ipython mode being used. This class is only meant to | |
161 | # be used inside ipython anyways, so it's OK. |
|
174 | # be used inside ipython anyways, so it's OK. | |
162 | self.ip_showtb = __IPYTHON__.showtraceback |
|
|||
163 | self.ip_ns = __IPYTHON__.user_ns |
|
175 | self.ip_ns = __IPYTHON__.user_ns | |
164 | self.ip_colorize = __IPYTHON__.pycolorize |
|
176 | self.ip_colorize = __IPYTHON__.pycolorize | |
|
177 | self.ip_showtb = __IPYTHON__.showtraceback | |||
|
178 | self.ip_runlines = __IPYTHON__.runlines | |||
|
179 | self.shell = __IPYTHON__ | |||
165 |
|
180 | |||
166 | # load user data and initialize data structures |
|
181 | # load user data and initialize data structures | |
167 | self.reload() |
|
182 | self.reload() | |
168 |
|
183 | |||
169 | def reload(self): |
|
184 | def reload(self): | |
170 | """Reload source from disk and initialize state.""" |
|
185 | """Reload source from disk and initialize state.""" | |
171 | # read data and parse into blocks |
|
186 | # read data and parse into blocks | |
172 | self.src = file_read(self.fname) |
|
187 | self.src = file_read(self.fname) | |
173 | src_b = [b.strip() for b in self.re_stop.split(self.src) if b] |
|
188 | src_b = [b.strip() for b in self.re_stop.split(self.src) if b] | |
174 | self._silent = [bool(self.re_silent.findall(b)) for b in src_b] |
|
189 | self._silent = [bool(self.re_silent.findall(b)) for b in src_b] | |
175 | self._auto = [bool(self.re_auto.findall(b)) for b in src_b] |
|
190 | self._auto = [bool(self.re_auto.findall(b)) for b in src_b] | |
176 |
|
191 | |||
177 | # if auto_all is not given (def. None), we read it from the file |
|
192 | # if auto_all is not given (def. None), we read it from the file | |
178 | if self.auto_all is None: |
|
193 | if self.auto_all is None: | |
179 | self.auto_all = bool(self.re_auto_all.findall(src_b[0])) |
|
194 | self.auto_all = bool(self.re_auto_all.findall(src_b[0])) | |
180 | else: |
|
195 | else: | |
181 | self.auto_all = bool(self.auto_all) |
|
196 | self.auto_all = bool(self.auto_all) | |
182 |
|
197 | |||
183 | # Clean the sources from all markup so it doesn't get displayed when |
|
198 | # Clean the sources from all markup so it doesn't get displayed when | |
184 | # running the demo |
|
199 | # running the demo | |
185 | src_blocks = [] |
|
200 | src_blocks = [] | |
186 | auto_strip = lambda s: self.re_auto.sub('',s) |
|
201 | auto_strip = lambda s: self.re_auto.sub('',s) | |
187 | for i,b in enumerate(src_b): |
|
202 | for i,b in enumerate(src_b): | |
188 | if self._auto[i]: |
|
203 | if self._auto[i]: | |
189 | src_blocks.append(auto_strip(b)) |
|
204 | src_blocks.append(auto_strip(b)) | |
190 | else: |
|
205 | else: | |
191 | src_blocks.append(b) |
|
206 | src_blocks.append(b) | |
192 | # remove the auto_all marker |
|
207 | # remove the auto_all marker | |
193 | src_blocks[0] = self.re_auto_all.sub('',src_blocks[0]) |
|
208 | src_blocks[0] = self.re_auto_all.sub('',src_blocks[0]) | |
194 |
|
209 | |||
195 | self.nblocks = len(src_blocks) |
|
210 | self.nblocks = len(src_blocks) | |
196 | self.src_blocks = src_blocks |
|
211 | self.src_blocks = src_blocks | |
197 |
|
212 | |||
198 | # also build syntax-highlighted source |
|
213 | # also build syntax-highlighted source | |
199 | self.src_blocks_colored = map(self.ip_colorize,self.src_blocks) |
|
214 | self.src_blocks_colored = map(self.ip_colorize,self.src_blocks) | |
200 |
|
215 | |||
201 | # ensure clean namespace and seek offset |
|
216 | # ensure clean namespace and seek offset | |
202 | self.reset() |
|
217 | self.reset() | |
203 |
|
218 | |||
204 | def reset(self): |
|
219 | def reset(self): | |
205 | """Reset the namespace and seek pointer to restart the demo""" |
|
220 | """Reset the namespace and seek pointer to restart the demo""" | |
206 | self.user_ns = {} |
|
221 | self.user_ns = {} | |
207 | self.finished = False |
|
222 | self.finished = False | |
208 | self.block_index = 0 |
|
223 | self.block_index = 0 | |
209 |
|
224 | |||
210 | def _validate_index(self,index): |
|
225 | def _validate_index(self,index): | |
211 | if index<0 or index>=self.nblocks: |
|
226 | if index<0 or index>=self.nblocks: | |
212 | raise ValueError('invalid block index %s' % index) |
|
227 | raise ValueError('invalid block index %s' % index) | |
213 |
|
228 | |||
|
229 | def _get_index(self,index): | |||
|
230 | """Get the current block index, validating and checking status. | |||
|
231 | ||||
|
232 | Returns None if the demo is finished""" | |||
|
233 | ||||
|
234 | if index is None: | |||
|
235 | if self.finished: | |||
|
236 | print 'Demo finished. Use reset() if you want to rerun it.' | |||
|
237 | return None | |||
|
238 | index = self.block_index | |||
|
239 | else: | |||
|
240 | self._validate_index(index) | |||
|
241 | return index | |||
|
242 | ||||
214 | def seek(self,index): |
|
243 | def seek(self,index): | |
215 | """Move the current seek pointer to the given block""" |
|
244 | """Move the current seek pointer to the given block""" | |
216 | self._validate_index(index) |
|
245 | self._validate_index(index) | |
217 | self.block_index = index |
|
246 | self.block_index = index | |
218 | self.finished = False |
|
247 | self.finished = False | |
219 |
|
248 | |||
220 | def back(self,num=1): |
|
249 | def back(self,num=1): | |
221 | """Move the seek pointer back num blocks (default is 1).""" |
|
250 | """Move the seek pointer back num blocks (default is 1).""" | |
222 | self.seek(self.block_index-num) |
|
251 | self.seek(self.block_index-num) | |
223 |
|
252 | |||
224 | def jump(self,num): |
|
253 | def jump(self,num): | |
225 | """Jump a given number of blocks relative to the current one.""" |
|
254 | """Jump a given number of blocks relative to the current one.""" | |
226 | self.seek(self.block_index+num) |
|
255 | self.seek(self.block_index+num) | |
227 |
|
256 | |||
228 | def again(self): |
|
257 | def again(self): | |
229 | """Move the seek pointer back one block and re-execute.""" |
|
258 | """Move the seek pointer back one block and re-execute.""" | |
230 | self.back(1) |
|
259 | self.back(1) | |
231 | self() |
|
260 | self() | |
232 |
|
261 | |||
|
262 | def edit(self,index=None): | |||
|
263 | """Edit a block. | |||
|
264 | ||||
|
265 | If no number is given, use the last block executed. | |||
|
266 | ||||
|
267 | This edits the in-memory copy of the demo, it does NOT modify the | |||
|
268 | original source file. If you want to do that, simply open the file in | |||
|
269 | an editor and use reload() when you make changes to the file. This | |||
|
270 | method is meant to let you change a block during a demonstration for | |||
|
271 | explanatory purposes, without damaging your original script.""" | |||
|
272 | ||||
|
273 | index = self._get_index(index) | |||
|
274 | if index is None: | |||
|
275 | return | |||
|
276 | # decrease the index by one (unless we're at the very beginning), so | |||
|
277 | # that the default demo.edit() call opens up the sblock we've last run | |||
|
278 | if index>0: | |||
|
279 | index -= 1 | |||
|
280 | ||||
|
281 | filename = self.shell.mktempfile(self.src_blocks[index]) | |||
|
282 | self.shell.hooks.editor(filename,1) | |||
|
283 | new_block = file_read(filename) | |||
|
284 | # update the source and colored block | |||
|
285 | self.src_blocks[index] = new_block | |||
|
286 | self.src_blocks_colored[index] = self.ip_colorize(new_block) | |||
|
287 | self.block_index = index | |||
|
288 | # call to run with the newly edited index | |||
|
289 | self() | |||
|
290 | ||||
233 | def show(self,index=None): |
|
291 | def show(self,index=None): | |
234 | """Show a single block on screen""" |
|
292 | """Show a single block on screen""" | |
|
293 | ||||
|
294 | index = self._get_index(index) | |||
235 | if index is None: |
|
295 | if index is None: | |
236 | if self.finished: |
|
|||
237 | print 'Demo finished. Use reset() if you want to rerun it.' |
|
|||
238 |
|
|
296 | return | |
239 | index = self.block_index |
|
297 | ||
240 | else: |
|
|||
241 | self._validate_index(index) |
|
|||
242 | print marquee('<%s> block # %s (%s remaining)' % |
|
298 | print marquee('<%s> block # %s (%s remaining)' % | |
243 | (self.fname,index,self.nblocks-index-1)) |
|
299 | (self.fname,index,self.nblocks-index-1)) | |
244 | print self.src_blocks_colored[index], |
|
300 | print self.src_blocks_colored[index], | |
245 | sys.stdout.flush() |
|
301 | sys.stdout.flush() | |
246 |
|
302 | |||
247 | def show_all(self): |
|
303 | def show_all(self): | |
248 | """Show entire demo on screen, block by block""" |
|
304 | """Show entire demo on screen, block by block""" | |
249 |
|
305 | |||
250 | fname = self.fname |
|
306 | fname = self.fname | |
251 | nblocks = self.nblocks |
|
307 | nblocks = self.nblocks | |
252 | silent = self._silent |
|
308 | silent = self._silent | |
253 | for index,block in enumerate(self.src_blocks_colored): |
|
309 | for index,block in enumerate(self.src_blocks_colored): | |
254 | if silent[index]: |
|
310 | if silent[index]: | |
255 | print marquee('<%s> SILENT block # %s (%s remaining)' % |
|
311 | print marquee('<%s> SILENT block # %s (%s remaining)' % | |
256 | (fname,index,nblocks-index-1)) |
|
312 | (fname,index,nblocks-index-1)) | |
257 | else: |
|
313 | else: | |
258 | print marquee('<%s> block # %s (%s remaining)' % |
|
314 | print marquee('<%s> block # %s (%s remaining)' % | |
259 | (fname,index,nblocks-index-1)) |
|
315 | (fname,index,nblocks-index-1)) | |
260 | print block, |
|
316 | print block, | |
261 | sys.stdout.flush() |
|
317 | sys.stdout.flush() | |
262 |
|
318 | |||
|
319 | def runlines(self,source): | |||
|
320 | """Execute a string with one or more lines of code""" | |||
|
321 | ||||
|
322 | exec source in self.user_ns | |||
|
323 | ||||
263 | def __call__(self,index=None): |
|
324 | def __call__(self,index=None): | |
264 | """run a block of the demo. |
|
325 | """run a block of the demo. | |
265 |
|
326 | |||
266 | If index is given, it should be an integer >=1 and <= nblocks. This |
|
327 | If index is given, it should be an integer >=1 and <= nblocks. This | |
267 | means that the calling convention is one off from typical Python |
|
328 | means that the calling convention is one off from typical Python | |
268 | lists. The reason for the inconsistency is that the demo always |
|
329 | lists. The reason for the inconsistency is that the demo always | |
269 | prints 'Block n/N, and N is the total, so it would be very odd to use |
|
330 | prints 'Block n/N, and N is the total, so it would be very odd to use | |
270 | zero-indexing here.""" |
|
331 | zero-indexing here.""" | |
271 |
|
332 | |||
272 | if index is None and self.finished: |
|
333 | index = self._get_index(index) | |
273 | print 'Demo finished. Use reset() if you want to rerun it.' |
|
|||
274 | return |
|
|||
275 | if index is None: |
|
334 | if index is None: | |
276 | index = self.block_index |
|
335 | return | |
277 | self._validate_index(index) |
|
|||
278 | try: |
|
336 | try: | |
279 | next_block = self.src_blocks[index] |
|
337 | next_block = self.src_blocks[index] | |
280 | self.block_index += 1 |
|
338 | self.block_index += 1 | |
281 | if self._silent[index]: |
|
339 | if self._silent[index]: | |
282 | print marquee('Executing silent block # %s (%s remaining)' % |
|
340 | print marquee('Executing silent block # %s (%s remaining)' % | |
283 | (index,self.nblocks-index-1)) |
|
341 | (index,self.nblocks-index-1)) | |
284 | else: |
|
342 | else: | |
285 | self.show(index) |
|
343 | self.show(index) | |
286 | if self.auto_all or self._auto[index]: |
|
344 | if self.auto_all or self._auto[index]: | |
287 | print marquee('output') |
|
345 | print marquee('output') | |
288 | else: |
|
346 | else: | |
289 | print marquee('Press <q> to quit, <Enter> to execute...'), |
|
347 | print marquee('Press <q> to quit, <Enter> to execute...'), | |
290 | ans = raw_input().strip() |
|
348 | ans = raw_input().strip() | |
291 | if ans: |
|
349 | if ans: | |
292 | print marquee('Block NOT executed') |
|
350 | print marquee('Block NOT executed') | |
293 | return |
|
351 | return | |
294 | try: |
|
352 | try: | |
295 | save_argv = sys.argv |
|
353 | save_argv = sys.argv | |
296 | sys.argv = self.sys_argv |
|
354 | sys.argv = self.sys_argv | |
297 |
|
|
355 | self.runlines(next_block) | |
298 | finally: |
|
356 | finally: | |
299 | sys.argv = save_argv |
|
357 | sys.argv = save_argv | |
300 |
|
358 | |||
301 | except: |
|
359 | except: | |
302 | self.ip_showtb(filename=self.fname) |
|
360 | self.ip_showtb(filename=self.fname) | |
303 | else: |
|
361 | else: | |
304 | self.ip_ns.update(self.user_ns) |
|
362 | self.ip_ns.update(self.user_ns) | |
305 |
|
363 | |||
306 | if self.block_index == self.nblocks: |
|
364 | if self.block_index == self.nblocks: | |
307 |
|
365 | |||
308 | print marquee(' END OF DEMO ') |
|
366 | print marquee(' END OF DEMO ') | |
309 | print marquee('Use reset() if you want to rerun it.') |
|
367 | print marquee('Use reset() if you want to rerun it.') | |
310 | self.finished = True |
|
368 | self.finished = True | |
311 |
|
369 | |||
|
370 | class IPythonDemo(Demo): | |||
|
371 | """Class for interactive demos with IPython's input processing applied. | |||
|
372 | ||||
|
373 | This subclasses Demo, but instead of executing each block by the Python | |||
|
374 | interpreter (via exec), it actually calls IPython on it, so that any input | |||
|
375 | filters which may be in place are applied to the input block. | |||
|
376 | ||||
|
377 | If you have an interactive environment which exposes special input | |||
|
378 | processing, you can use this class instead to write demo scripts which | |||
|
379 | operate exactly as if you had typed them interactively. The default Demo | |||
|
380 | class requires the input to be valid, pure Python code. | |||
|
381 | """ | |||
|
382 | ||||
|
383 | def runlines(self,source): | |||
|
384 | """Execute a string with one or more lines of code""" | |||
|
385 | ||||
|
386 | self.runlines(source) | |||
|
387 | ||||
|
388 | class LineDemo(Demo): | |||
|
389 | """Demo where each line is executed as a separate block. | |||
|
390 | ||||
|
391 | The input script should be valid Python code. | |||
|
392 | ||||
|
393 | This class doesn't require any markup at all, and it's meant for simple | |||
|
394 | scripts (with no nesting or any kind of indentation) which consist of | |||
|
395 | multiple lines of input to be executed, one at a time, as if they had been | |||
|
396 | typed in the interactive prompt.""" | |||
|
397 | ||||
|
398 | def reload(self): | |||
|
399 | """Reload source from disk and initialize state.""" | |||
|
400 | # read data and parse into blocks | |||
|
401 | src_b = [l for l in file_readlines(self.fname) if l.strip()] | |||
|
402 | nblocks = len(src_b) | |||
|
403 | self.src = os.linesep.join(file_readlines(self.fname)) | |||
|
404 | self._silent = [False]*nblocks | |||
|
405 | self._auto = [True]*nblocks | |||
|
406 | self.auto_all = True | |||
|
407 | self.nblocks = nblocks | |||
|
408 | self.src_blocks = src_b | |||
|
409 | ||||
|
410 | # also build syntax-highlighted source | |||
|
411 | self.src_blocks_colored = map(self.ip_colorize,self.src_blocks) | |||
|
412 | ||||
|
413 | # ensure clean namespace and seek offset | |||
|
414 | self.reset() | |||
|
415 | ||||
|
416 | class IPythonLineDemo(IPythonDemo,LineDemo): | |||
|
417 | """Variant of the LineDemo class whose input is processed by IPython.""" | |||
|
418 | pass |
@@ -1,1761 +1,1768 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 11 |
|
8 | $Id: genutils.py 1126 2006-02-06 02:31:40Z 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 __future__ import generators # 2.2 compatibility |
|
17 | from __future__ import generators # 2.2 compatibility | |
18 |
|
18 | |||
19 | from IPython import Release |
|
19 | from IPython import Release | |
20 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
20 | __author__ = '%s <%s>' % Release.authors['Fernando'] | |
21 | __license__ = Release.license |
|
21 | __license__ = Release.license | |
22 |
|
22 | |||
23 | #**************************************************************************** |
|
23 | #**************************************************************************** | |
24 | # required modules from the Python standard library |
|
24 | # required modules from the Python standard library | |
25 | import __main__ |
|
25 | import __main__ | |
26 | import commands |
|
26 | import commands | |
27 | import os |
|
27 | import os | |
28 | import re |
|
28 | import re | |
29 | import shlex |
|
29 | import shlex | |
30 | import shutil |
|
30 | import shutil | |
31 | import sys |
|
31 | import sys | |
32 | import tempfile |
|
32 | import tempfile | |
33 | import time |
|
33 | import time | |
34 | import types |
|
34 | import types | |
35 |
|
35 | |||
36 | # Other IPython utilities |
|
36 | # Other IPython utilities | |
37 | from IPython.Itpl import Itpl,itpl,printpl |
|
37 | from IPython.Itpl import Itpl,itpl,printpl | |
38 | from IPython import DPyGetOpt |
|
38 | from IPython import DPyGetOpt | |
39 | from path import path |
|
39 | from path import path | |
40 | if os.name == "nt": |
|
40 | if os.name == "nt": | |
41 | from IPython.winconsole import get_console_size |
|
41 | from IPython.winconsole import get_console_size | |
42 |
|
42 | |||
43 | # Build objects which appeared in Python 2.3 for 2.2, to make ipython |
|
43 | # Build objects which appeared in Python 2.3 for 2.2, to make ipython | |
44 | # 2.2-friendly |
|
44 | # 2.2-friendly | |
45 | try: |
|
45 | try: | |
46 | basestring |
|
46 | basestring | |
47 | except NameError: |
|
47 | except NameError: | |
48 | import types |
|
48 | import types | |
49 | basestring = (types.StringType, types.UnicodeType) |
|
49 | basestring = (types.StringType, types.UnicodeType) | |
50 | True = 1==1 |
|
50 | True = 1==1 | |
51 | False = 1==0 |
|
51 | False = 1==0 | |
52 |
|
52 | |||
53 | def enumerate(obj): |
|
53 | def enumerate(obj): | |
54 | i = -1 |
|
54 | i = -1 | |
55 | for item in obj: |
|
55 | for item in obj: | |
56 | i += 1 |
|
56 | i += 1 | |
57 | yield i, item |
|
57 | yield i, item | |
58 |
|
58 | |||
59 | # add these to the builtin namespace, so that all modules find them |
|
59 | # add these to the builtin namespace, so that all modules find them | |
60 | import __builtin__ |
|
60 | import __builtin__ | |
61 | __builtin__.basestring = basestring |
|
61 | __builtin__.basestring = basestring | |
62 | __builtin__.True = True |
|
62 | __builtin__.True = True | |
63 | __builtin__.False = False |
|
63 | __builtin__.False = False | |
64 | __builtin__.enumerate = enumerate |
|
64 | __builtin__.enumerate = enumerate | |
65 |
|
65 | |||
66 | # Try to use shlex.split for converting an input string into a sys.argv-type |
|
66 | # Try to use shlex.split for converting an input string into a sys.argv-type | |
67 | # list. This appeared in Python 2.3, so here's a quick backport for 2.2. |
|
67 | # list. This appeared in Python 2.3, so here's a quick backport for 2.2. | |
68 | try: |
|
68 | try: | |
69 | shlex_split = shlex.split |
|
69 | shlex_split = shlex.split | |
70 | except AttributeError: |
|
70 | except AttributeError: | |
71 | _quotesre = re.compile(r'[\'"](.*)[\'"]') |
|
71 | _quotesre = re.compile(r'[\'"](.*)[\'"]') | |
72 | _wordchars = ('abcdfeghijklmnopqrstuvwxyz' |
|
72 | _wordchars = ('abcdfeghijklmnopqrstuvwxyz' | |
73 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~*?' |
|
73 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~*?' | |
74 | 'ßà áâãäåæçèéêëìÃîïðñòóôõöøùúûüýþÿ' |
|
74 | 'ßà áâãäåæçèéêëìÃîïðñòóôõöøùúûüýþÿ' | |
75 | 'À�ÂÃÄÅÆÇÈÉÊËÌ�Î��ÑÒÓÔÕÖØÙÚÛÜ�Þ%s' |
|
75 | 'À�ÂÃÄÅÆÇÈÉÊËÌ�Î��ÑÒÓÔÕÖØÙÚÛÜ�Þ%s' | |
76 | % os.sep) |
|
76 | % os.sep) | |
77 |
|
77 | |||
78 | def shlex_split(s): |
|
78 | def shlex_split(s): | |
79 | """Simplified backport to Python 2.2 of shlex.split(). |
|
79 | """Simplified backport to Python 2.2 of shlex.split(). | |
80 |
|
80 | |||
81 | This is a quick and dirty hack, since the shlex module under 2.2 lacks |
|
81 | This is a quick and dirty hack, since the shlex module under 2.2 lacks | |
82 | several of the features needed to really match the functionality of |
|
82 | several of the features needed to really match the functionality of | |
83 | shlex.split() in 2.3.""" |
|
83 | shlex.split() in 2.3.""" | |
84 |
|
84 | |||
85 | lex = shlex.shlex(StringIO(s)) |
|
85 | lex = shlex.shlex(StringIO(s)) | |
86 | # Try to get options, extensions and path separators as characters |
|
86 | # Try to get options, extensions and path separators as characters | |
87 | lex.wordchars = _wordchars |
|
87 | lex.wordchars = _wordchars | |
88 | lex.commenters = '' |
|
88 | lex.commenters = '' | |
89 | # Make a list out of the lexer by hand, since in 2.2 it's not an |
|
89 | # Make a list out of the lexer by hand, since in 2.2 it's not an | |
90 | # iterator. |
|
90 | # iterator. | |
91 | lout = [] |
|
91 | lout = [] | |
92 | while 1: |
|
92 | while 1: | |
93 | token = lex.get_token() |
|
93 | token = lex.get_token() | |
94 | if token == '': |
|
94 | if token == '': | |
95 | break |
|
95 | break | |
96 | # Try to handle quoted tokens correctly |
|
96 | # Try to handle quoted tokens correctly | |
97 | quotes = _quotesre.match(token) |
|
97 | quotes = _quotesre.match(token) | |
98 | if quotes: |
|
98 | if quotes: | |
99 | token = quotes.group(1) |
|
99 | token = quotes.group(1) | |
100 | lout.append(token) |
|
100 | lout.append(token) | |
101 | return lout |
|
101 | return lout | |
102 |
|
102 | |||
103 | #**************************************************************************** |
|
103 | #**************************************************************************** | |
104 | # Exceptions |
|
104 | # Exceptions | |
105 | class Error(Exception): |
|
105 | class Error(Exception): | |
106 | """Base class for exceptions in this module.""" |
|
106 | """Base class for exceptions in this module.""" | |
107 | pass |
|
107 | pass | |
108 |
|
108 | |||
109 | #---------------------------------------------------------------------------- |
|
109 | #---------------------------------------------------------------------------- | |
110 | class IOStream: |
|
110 | class IOStream: | |
111 | def __init__(self,stream,fallback): |
|
111 | def __init__(self,stream,fallback): | |
112 | if not hasattr(stream,'write') or not hasattr(stream,'flush'): |
|
112 | if not hasattr(stream,'write') or not hasattr(stream,'flush'): | |
113 | stream = fallback |
|
113 | stream = fallback | |
114 | self.stream = stream |
|
114 | self.stream = stream | |
115 | self._swrite = stream.write |
|
115 | self._swrite = stream.write | |
116 | self.flush = stream.flush |
|
116 | self.flush = stream.flush | |
117 |
|
117 | |||
118 | def write(self,data): |
|
118 | def write(self,data): | |
119 | try: |
|
119 | try: | |
120 | self._swrite(data) |
|
120 | self._swrite(data) | |
121 | except: |
|
121 | except: | |
122 | try: |
|
122 | try: | |
123 | # print handles some unicode issues which may trip a plain |
|
123 | # print handles some unicode issues which may trip a plain | |
124 | # write() call. Attempt to emulate write() by using a |
|
124 | # write() call. Attempt to emulate write() by using a | |
125 | # trailing comma |
|
125 | # trailing comma | |
126 | print >> self.stream, data, |
|
126 | print >> self.stream, data, | |
127 | except: |
|
127 | except: | |
128 | # if we get here, something is seriously broken. |
|
128 | # if we get here, something is seriously broken. | |
129 | print >> sys.stderr, \ |
|
129 | print >> sys.stderr, \ | |
130 | 'ERROR - failed to write data to stream:', stream |
|
130 | 'ERROR - failed to write data to stream:', stream | |
131 |
|
131 | |||
132 | class IOTerm: |
|
132 | class IOTerm: | |
133 | """ Term holds the file or file-like objects for handling I/O operations. |
|
133 | """ Term holds the file or file-like objects for handling I/O operations. | |
134 |
|
134 | |||
135 | These are normally just sys.stdin, sys.stdout and sys.stderr but for |
|
135 | These are normally just sys.stdin, sys.stdout and sys.stderr but for | |
136 | Windows they can can replaced to allow editing the strings before they are |
|
136 | Windows they can can replaced to allow editing the strings before they are | |
137 | displayed.""" |
|
137 | displayed.""" | |
138 |
|
138 | |||
139 | # In the future, having IPython channel all its I/O operations through |
|
139 | # In the future, having IPython channel all its I/O operations through | |
140 | # this class will make it easier to embed it into other environments which |
|
140 | # this class will make it easier to embed it into other environments which | |
141 | # are not a normal terminal (such as a GUI-based shell) |
|
141 | # are not a normal terminal (such as a GUI-based shell) | |
142 | def __init__(self,cin=None,cout=None,cerr=None): |
|
142 | def __init__(self,cin=None,cout=None,cerr=None): | |
143 | self.cin = IOStream(cin,sys.stdin) |
|
143 | self.cin = IOStream(cin,sys.stdin) | |
144 | self.cout = IOStream(cout,sys.stdout) |
|
144 | self.cout = IOStream(cout,sys.stdout) | |
145 | self.cerr = IOStream(cerr,sys.stderr) |
|
145 | self.cerr = IOStream(cerr,sys.stderr) | |
146 |
|
146 | |||
147 | # Global variable to be used for all I/O |
|
147 | # Global variable to be used for all I/O | |
148 | Term = IOTerm() |
|
148 | Term = IOTerm() | |
149 |
|
149 | |||
150 | import IPython.rlineimpl as readline |
|
150 | import IPython.rlineimpl as readline | |
151 | # Remake Term to use the readline i/o facilities |
|
151 | # Remake Term to use the readline i/o facilities | |
152 | if sys.platform == 'win32' and readline.have_readline: |
|
152 | if sys.platform == 'win32' and readline.have_readline: | |
153 |
|
153 | |||
154 | Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile) |
|
154 | Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile) | |
155 |
|
155 | |||
156 |
|
156 | |||
157 | #**************************************************************************** |
|
157 | #**************************************************************************** | |
158 | # Generic warning/error printer, used by everything else |
|
158 | # Generic warning/error printer, used by everything else | |
159 | def warn(msg,level=2,exit_val=1): |
|
159 | def warn(msg,level=2,exit_val=1): | |
160 | """Standard warning printer. Gives formatting consistency. |
|
160 | """Standard warning printer. Gives formatting consistency. | |
161 |
|
161 | |||
162 | Output is sent to Term.cerr (sys.stderr by default). |
|
162 | Output is sent to Term.cerr (sys.stderr by default). | |
163 |
|
163 | |||
164 | Options: |
|
164 | Options: | |
165 |
|
165 | |||
166 | -level(2): allows finer control: |
|
166 | -level(2): allows finer control: | |
167 | 0 -> Do nothing, dummy function. |
|
167 | 0 -> Do nothing, dummy function. | |
168 | 1 -> Print message. |
|
168 | 1 -> Print message. | |
169 | 2 -> Print 'WARNING:' + message. (Default level). |
|
169 | 2 -> Print 'WARNING:' + message. (Default level). | |
170 | 3 -> Print 'ERROR:' + message. |
|
170 | 3 -> Print 'ERROR:' + message. | |
171 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). |
|
171 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). | |
172 |
|
172 | |||
173 | -exit_val (1): exit value returned by sys.exit() for a level 4 |
|
173 | -exit_val (1): exit value returned by sys.exit() for a level 4 | |
174 | warning. Ignored for all other levels.""" |
|
174 | warning. Ignored for all other levels.""" | |
175 |
|
175 | |||
176 | if level>0: |
|
176 | if level>0: | |
177 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] |
|
177 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] | |
178 | print >> Term.cerr, '%s%s' % (header[level],msg) |
|
178 | print >> Term.cerr, '%s%s' % (header[level],msg) | |
179 | if level == 4: |
|
179 | if level == 4: | |
180 | print >> Term.cerr,'Exiting.\n' |
|
180 | print >> Term.cerr,'Exiting.\n' | |
181 | sys.exit(exit_val) |
|
181 | sys.exit(exit_val) | |
182 |
|
182 | |||
183 | def info(msg): |
|
183 | def info(msg): | |
184 | """Equivalent to warn(msg,level=1).""" |
|
184 | """Equivalent to warn(msg,level=1).""" | |
185 |
|
185 | |||
186 | warn(msg,level=1) |
|
186 | warn(msg,level=1) | |
187 |
|
187 | |||
188 | def error(msg): |
|
188 | def error(msg): | |
189 | """Equivalent to warn(msg,level=3).""" |
|
189 | """Equivalent to warn(msg,level=3).""" | |
190 |
|
190 | |||
191 | warn(msg,level=3) |
|
191 | warn(msg,level=3) | |
192 |
|
192 | |||
193 | def fatal(msg,exit_val=1): |
|
193 | def fatal(msg,exit_val=1): | |
194 | """Equivalent to warn(msg,exit_val=exit_val,level=4).""" |
|
194 | """Equivalent to warn(msg,exit_val=exit_val,level=4).""" | |
195 |
|
195 | |||
196 | warn(msg,exit_val=exit_val,level=4) |
|
196 | warn(msg,exit_val=exit_val,level=4) | |
197 |
|
197 | |||
198 | #--------------------------------------------------------------------------- |
|
198 | #--------------------------------------------------------------------------- | |
199 | # Debugging routines |
|
199 | # Debugging routines | |
200 | # |
|
200 | # | |
201 | def debugx(expr,pre_msg=''): |
|
201 | def debugx(expr,pre_msg=''): | |
202 | """Print the value of an expression from the caller's frame. |
|
202 | """Print the value of an expression from the caller's frame. | |
203 |
|
203 | |||
204 | Takes an expression, evaluates it in the caller's frame and prints both |
|
204 | Takes an expression, evaluates it in the caller's frame and prints both | |
205 | the given expression and the resulting value (as well as a debug mark |
|
205 | the given expression and the resulting value (as well as a debug mark | |
206 | indicating the name of the calling function. The input must be of a form |
|
206 | indicating the name of the calling function. The input must be of a form | |
207 | suitable for eval(). |
|
207 | suitable for eval(). | |
208 |
|
208 | |||
209 | An optional message can be passed, which will be prepended to the printed |
|
209 | An optional message can be passed, which will be prepended to the printed | |
210 | expr->value pair.""" |
|
210 | expr->value pair.""" | |
211 |
|
211 | |||
212 | cf = sys._getframe(1) |
|
212 | cf = sys._getframe(1) | |
213 | print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr, |
|
213 | print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr, | |
214 | eval(expr,cf.f_globals,cf.f_locals)) |
|
214 | eval(expr,cf.f_globals,cf.f_locals)) | |
215 |
|
215 | |||
216 | # deactivate it by uncommenting the following line, which makes it a no-op |
|
216 | # deactivate it by uncommenting the following line, which makes it a no-op | |
217 | #def debugx(expr,pre_msg=''): pass |
|
217 | #def debugx(expr,pre_msg=''): pass | |
218 |
|
218 | |||
219 | #---------------------------------------------------------------------------- |
|
219 | #---------------------------------------------------------------------------- | |
220 | StringTypes = types.StringTypes |
|
220 | StringTypes = types.StringTypes | |
221 |
|
221 | |||
222 | # Basic timing functionality |
|
222 | # Basic timing functionality | |
223 |
|
223 | |||
224 | # If possible (Unix), use the resource module instead of time.clock() |
|
224 | # If possible (Unix), use the resource module instead of time.clock() | |
225 | try: |
|
225 | try: | |
226 | import resource |
|
226 | import resource | |
227 | def clock(): |
|
227 | def clock(): | |
228 | """clock() -> floating point number |
|
228 | """clock() -> floating point number | |
229 |
|
229 | |||
230 | Return the CPU time in seconds (user time only, system time is |
|
230 | Return the CPU time in seconds (user time only, system time is | |
231 | ignored) since the start of the process. This is done via a call to |
|
231 | ignored) since the start of the process. This is done via a call to | |
232 | resource.getrusage, so it avoids the wraparound problems in |
|
232 | resource.getrusage, so it avoids the wraparound problems in | |
233 | time.clock().""" |
|
233 | time.clock().""" | |
234 |
|
234 | |||
235 | return resource.getrusage(resource.RUSAGE_SELF)[0] |
|
235 | return resource.getrusage(resource.RUSAGE_SELF)[0] | |
236 |
|
236 | |||
237 | def clock2(): |
|
237 | def clock2(): | |
238 | """clock2() -> (t_user,t_system) |
|
238 | """clock2() -> (t_user,t_system) | |
239 |
|
239 | |||
240 | Similar to clock(), but return a tuple of user/system times.""" |
|
240 | Similar to clock(), but return a tuple of user/system times.""" | |
241 | return resource.getrusage(resource.RUSAGE_SELF)[:2] |
|
241 | return resource.getrusage(resource.RUSAGE_SELF)[:2] | |
242 |
|
242 | |||
243 | except ImportError: |
|
243 | except ImportError: | |
244 | clock = time.clock |
|
244 | clock = time.clock | |
245 | def clock2(): |
|
245 | def clock2(): | |
246 | """Under windows, system CPU time can't be measured. |
|
246 | """Under windows, system CPU time can't be measured. | |
247 |
|
247 | |||
248 | This just returns clock() and zero.""" |
|
248 | This just returns clock() and zero.""" | |
249 | return time.clock(),0.0 |
|
249 | return time.clock(),0.0 | |
250 |
|
250 | |||
251 | def timings_out(reps,func,*args,**kw): |
|
251 | def timings_out(reps,func,*args,**kw): | |
252 | """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output) |
|
252 | """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output) | |
253 |
|
253 | |||
254 | Execute a function reps times, return a tuple with the elapsed total |
|
254 | Execute a function reps times, return a tuple with the elapsed total | |
255 | CPU time in seconds, the time per call and the function's output. |
|
255 | CPU time in seconds, the time per call and the function's output. | |
256 |
|
256 | |||
257 | Under Unix, the return value is the sum of user+system time consumed by |
|
257 | Under Unix, the return value is the sum of user+system time consumed by | |
258 | the process, computed via the resource module. This prevents problems |
|
258 | the process, computed via the resource module. This prevents problems | |
259 | related to the wraparound effect which the time.clock() function has. |
|
259 | related to the wraparound effect which the time.clock() function has. | |
260 |
|
260 | |||
261 | Under Windows the return value is in wall clock seconds. See the |
|
261 | Under Windows the return value is in wall clock seconds. See the | |
262 | documentation for the time module for more details.""" |
|
262 | documentation for the time module for more details.""" | |
263 |
|
263 | |||
264 | reps = int(reps) |
|
264 | reps = int(reps) | |
265 | assert reps >=1, 'reps must be >= 1' |
|
265 | assert reps >=1, 'reps must be >= 1' | |
266 | if reps==1: |
|
266 | if reps==1: | |
267 | start = clock() |
|
267 | start = clock() | |
268 | out = func(*args,**kw) |
|
268 | out = func(*args,**kw) | |
269 | tot_time = clock()-start |
|
269 | tot_time = clock()-start | |
270 | else: |
|
270 | else: | |
271 | rng = xrange(reps-1) # the last time is executed separately to store output |
|
271 | rng = xrange(reps-1) # the last time is executed separately to store output | |
272 | start = clock() |
|
272 | start = clock() | |
273 | for dummy in rng: func(*args,**kw) |
|
273 | for dummy in rng: func(*args,**kw) | |
274 | out = func(*args,**kw) # one last time |
|
274 | out = func(*args,**kw) # one last time | |
275 | tot_time = clock()-start |
|
275 | tot_time = clock()-start | |
276 | av_time = tot_time / reps |
|
276 | av_time = tot_time / reps | |
277 | return tot_time,av_time,out |
|
277 | return tot_time,av_time,out | |
278 |
|
278 | |||
279 | def timings(reps,func,*args,**kw): |
|
279 | def timings(reps,func,*args,**kw): | |
280 | """timings(reps,func,*args,**kw) -> (t_total,t_per_call) |
|
280 | """timings(reps,func,*args,**kw) -> (t_total,t_per_call) | |
281 |
|
281 | |||
282 | Execute a function reps times, return a tuple with the elapsed total CPU |
|
282 | Execute a function reps times, return a tuple with the elapsed total CPU | |
283 | time in seconds and the time per call. These are just the first two values |
|
283 | time in seconds and the time per call. These are just the first two values | |
284 | in timings_out().""" |
|
284 | in timings_out().""" | |
285 |
|
285 | |||
286 | return timings_out(reps,func,*args,**kw)[0:2] |
|
286 | return timings_out(reps,func,*args,**kw)[0:2] | |
287 |
|
287 | |||
288 | def timing(func,*args,**kw): |
|
288 | def timing(func,*args,**kw): | |
289 | """timing(func,*args,**kw) -> t_total |
|
289 | """timing(func,*args,**kw) -> t_total | |
290 |
|
290 | |||
291 | Execute a function once, return the elapsed total CPU time in |
|
291 | Execute a function once, return the elapsed total CPU time in | |
292 | seconds. This is just the first value in timings_out().""" |
|
292 | seconds. This is just the first value in timings_out().""" | |
293 |
|
293 | |||
294 | return timings_out(1,func,*args,**kw)[0] |
|
294 | return timings_out(1,func,*args,**kw)[0] | |
295 |
|
295 | |||
296 | #**************************************************************************** |
|
296 | #**************************************************************************** | |
297 | # file and system |
|
297 | # file and system | |
298 |
|
298 | |||
299 | def system(cmd,verbose=0,debug=0,header=''): |
|
299 | def system(cmd,verbose=0,debug=0,header=''): | |
300 | """Execute a system command, return its exit status. |
|
300 | """Execute a system command, return its exit status. | |
301 |
|
301 | |||
302 | Options: |
|
302 | Options: | |
303 |
|
303 | |||
304 | - verbose (0): print the command to be executed. |
|
304 | - verbose (0): print the command to be executed. | |
305 |
|
305 | |||
306 | - debug (0): only print, do not actually execute. |
|
306 | - debug (0): only print, do not actually execute. | |
307 |
|
307 | |||
308 | - header (''): Header to print on screen prior to the executed command (it |
|
308 | - header (''): Header to print on screen prior to the executed command (it | |
309 | is only prepended to the command, no newlines are added). |
|
309 | is only prepended to the command, no newlines are added). | |
310 |
|
310 | |||
311 | Note: a stateful version of this function is available through the |
|
311 | Note: a stateful version of this function is available through the | |
312 | SystemExec class.""" |
|
312 | SystemExec class.""" | |
313 |
|
313 | |||
314 | stat = 0 |
|
314 | stat = 0 | |
315 | if verbose or debug: print header+cmd |
|
315 | if verbose or debug: print header+cmd | |
316 | sys.stdout.flush() |
|
316 | sys.stdout.flush() | |
317 | if not debug: stat = os.system(cmd) |
|
317 | if not debug: stat = os.system(cmd) | |
318 | return stat |
|
318 | return stat | |
319 |
|
319 | |||
320 | # This function is used by ipython in a lot of places to make system calls. |
|
320 | # This function is used by ipython in a lot of places to make system calls. | |
321 | # We need it to be slightly different under win32, due to the vagaries of |
|
321 | # We need it to be slightly different under win32, due to the vagaries of | |
322 | # 'network shares'. A win32 override is below. |
|
322 | # 'network shares'. A win32 override is below. | |
323 |
|
323 | |||
324 | def shell(cmd,verbose=0,debug=0,header=''): |
|
324 | def shell(cmd,verbose=0,debug=0,header=''): | |
325 | """Execute a command in the system shell, always return None. |
|
325 | """Execute a command in the system shell, always return None. | |
326 |
|
326 | |||
327 | Options: |
|
327 | Options: | |
328 |
|
328 | |||
329 | - verbose (0): print the command to be executed. |
|
329 | - verbose (0): print the command to be executed. | |
330 |
|
330 | |||
331 | - debug (0): only print, do not actually execute. |
|
331 | - debug (0): only print, do not actually execute. | |
332 |
|
332 | |||
333 | - header (''): Header to print on screen prior to the executed command (it |
|
333 | - header (''): Header to print on screen prior to the executed command (it | |
334 | is only prepended to the command, no newlines are added). |
|
334 | is only prepended to the command, no newlines are added). | |
335 |
|
335 | |||
336 | Note: this is similar to genutils.system(), but it returns None so it can |
|
336 | Note: this is similar to genutils.system(), but it returns None so it can | |
337 | be conveniently used in interactive loops without getting the return value |
|
337 | be conveniently used in interactive loops without getting the return value | |
338 | (typically 0) printed many times.""" |
|
338 | (typically 0) printed many times.""" | |
339 |
|
339 | |||
340 | stat = 0 |
|
340 | stat = 0 | |
341 | if verbose or debug: print header+cmd |
|
341 | if verbose or debug: print header+cmd | |
342 | # flush stdout so we don't mangle python's buffering |
|
342 | # flush stdout so we don't mangle python's buffering | |
343 | sys.stdout.flush() |
|
343 | sys.stdout.flush() | |
344 | if not debug: |
|
344 | if not debug: | |
345 | os.system(cmd) |
|
345 | os.system(cmd) | |
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 | if verbose or debug: print header+cmd |
|
380 | if verbose or debug: print header+cmd | |
381 | if not debug: |
|
381 | if not debug: | |
382 | output = commands.getoutput(cmd) |
|
382 | output = commands.getoutput(cmd) | |
383 | if split: |
|
383 | if split: | |
384 | return output.split('\n') |
|
384 | return output.split('\n') | |
385 | else: |
|
385 | else: | |
386 | return output |
|
386 | return output | |
387 |
|
387 | |||
388 | def getoutputerror(cmd,verbose=0,debug=0,header='',split=0): |
|
388 | def getoutputerror(cmd,verbose=0,debug=0,header='',split=0): | |
389 | """Return (standard output,standard error) of executing cmd in a shell. |
|
389 | """Return (standard output,standard error) of executing cmd in a shell. | |
390 |
|
390 | |||
391 | Accepts the same arguments as system(), plus: |
|
391 | Accepts the same arguments as system(), plus: | |
392 |
|
392 | |||
393 | - split(0): if true, each of stdout/err is returned as a list split on |
|
393 | - split(0): if true, each of stdout/err is returned as a list split on | |
394 | newlines. |
|
394 | newlines. | |
395 |
|
395 | |||
396 | Note: a stateful version of this function is available through the |
|
396 | Note: a stateful version of this function is available through the | |
397 | SystemExec class.""" |
|
397 | SystemExec class.""" | |
398 |
|
398 | |||
399 | if verbose or debug: print header+cmd |
|
399 | if verbose or debug: print header+cmd | |
400 | if not cmd: |
|
400 | if not cmd: | |
401 | if split: |
|
401 | if split: | |
402 | return [],[] |
|
402 | return [],[] | |
403 | else: |
|
403 | else: | |
404 | return '','' |
|
404 | return '','' | |
405 | if not debug: |
|
405 | if not debug: | |
406 | pin,pout,perr = os.popen3(cmd) |
|
406 | pin,pout,perr = os.popen3(cmd) | |
407 | tout = pout.read().rstrip() |
|
407 | tout = pout.read().rstrip() | |
408 | terr = perr.read().rstrip() |
|
408 | terr = perr.read().rstrip() | |
409 | pin.close() |
|
409 | pin.close() | |
410 | pout.close() |
|
410 | pout.close() | |
411 | perr.close() |
|
411 | perr.close() | |
412 | if split: |
|
412 | if split: | |
413 | return tout.split('\n'),terr.split('\n') |
|
413 | return tout.split('\n'),terr.split('\n') | |
414 | else: |
|
414 | else: | |
415 | return tout,terr |
|
415 | return tout,terr | |
416 |
|
416 | |||
417 | # for compatibility with older naming conventions |
|
417 | # for compatibility with older naming conventions | |
418 | xsys = system |
|
418 | xsys = system | |
419 | bq = getoutput |
|
419 | bq = getoutput | |
420 |
|
420 | |||
421 | class SystemExec: |
|
421 | class SystemExec: | |
422 | """Access the system and getoutput functions through a stateful interface. |
|
422 | """Access the system and getoutput functions through a stateful interface. | |
423 |
|
423 | |||
424 | Note: here we refer to the system and getoutput functions from this |
|
424 | Note: here we refer to the system and getoutput functions from this | |
425 | library, not the ones from the standard python library. |
|
425 | library, not the ones from the standard python library. | |
426 |
|
426 | |||
427 | This class offers the system and getoutput functions as methods, but the |
|
427 | This class offers the system and getoutput functions as methods, but the | |
428 | verbose, debug and header parameters can be set for the instance (at |
|
428 | verbose, debug and header parameters can be set for the instance (at | |
429 | creation time or later) so that they don't need to be specified on each |
|
429 | creation time or later) so that they don't need to be specified on each | |
430 | call. |
|
430 | call. | |
431 |
|
431 | |||
432 | For efficiency reasons, there's no way to override the parameters on a |
|
432 | For efficiency reasons, there's no way to override the parameters on a | |
433 | per-call basis other than by setting instance attributes. If you need |
|
433 | per-call basis other than by setting instance attributes. If you need | |
434 | local overrides, it's best to directly call system() or getoutput(). |
|
434 | local overrides, it's best to directly call system() or getoutput(). | |
435 |
|
435 | |||
436 | The following names are provided as alternate options: |
|
436 | The following names are provided as alternate options: | |
437 | - xsys: alias to system |
|
437 | - xsys: alias to system | |
438 | - bq: alias to getoutput |
|
438 | - bq: alias to getoutput | |
439 |
|
439 | |||
440 | An instance can then be created as: |
|
440 | An instance can then be created as: | |
441 | >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ') |
|
441 | >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ') | |
442 |
|
442 | |||
443 | And used as: |
|
443 | And used as: | |
444 | >>> sysexec.xsys('pwd') |
|
444 | >>> sysexec.xsys('pwd') | |
445 | >>> dirlist = sysexec.bq('ls -l') |
|
445 | >>> dirlist = sysexec.bq('ls -l') | |
446 | """ |
|
446 | """ | |
447 |
|
447 | |||
448 | def __init__(self,verbose=0,debug=0,header='',split=0): |
|
448 | def __init__(self,verbose=0,debug=0,header='',split=0): | |
449 | """Specify the instance's values for verbose, debug and header.""" |
|
449 | """Specify the instance's values for verbose, debug and header.""" | |
450 | setattr_list(self,'verbose debug header split') |
|
450 | setattr_list(self,'verbose debug header split') | |
451 |
|
451 | |||
452 | def system(self,cmd): |
|
452 | def system(self,cmd): | |
453 | """Stateful interface to system(), with the same keyword parameters.""" |
|
453 | """Stateful interface to system(), with the same keyword parameters.""" | |
454 |
|
454 | |||
455 | system(cmd,self.verbose,self.debug,self.header) |
|
455 | system(cmd,self.verbose,self.debug,self.header) | |
456 |
|
456 | |||
457 | def shell(self,cmd): |
|
457 | def shell(self,cmd): | |
458 | """Stateful interface to shell(), with the same keyword parameters.""" |
|
458 | """Stateful interface to shell(), with the same keyword parameters.""" | |
459 |
|
459 | |||
460 | shell(cmd,self.verbose,self.debug,self.header) |
|
460 | shell(cmd,self.verbose,self.debug,self.header) | |
461 |
|
461 | |||
462 | xsys = system # alias |
|
462 | xsys = system # alias | |
463 |
|
463 | |||
464 | def getoutput(self,cmd): |
|
464 | def getoutput(self,cmd): | |
465 | """Stateful interface to getoutput().""" |
|
465 | """Stateful interface to getoutput().""" | |
466 |
|
466 | |||
467 | return getoutput(cmd,self.verbose,self.debug,self.header,self.split) |
|
467 | return getoutput(cmd,self.verbose,self.debug,self.header,self.split) | |
468 |
|
468 | |||
469 | def getoutputerror(self,cmd): |
|
469 | def getoutputerror(self,cmd): | |
470 | """Stateful interface to getoutputerror().""" |
|
470 | """Stateful interface to getoutputerror().""" | |
471 |
|
471 | |||
472 | return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split) |
|
472 | return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split) | |
473 |
|
473 | |||
474 | bq = getoutput # alias |
|
474 | bq = getoutput # alias | |
475 |
|
475 | |||
476 | #----------------------------------------------------------------------------- |
|
476 | #----------------------------------------------------------------------------- | |
477 | def mutex_opts(dict,ex_op): |
|
477 | def mutex_opts(dict,ex_op): | |
478 | """Check for presence of mutually exclusive keys in a dict. |
|
478 | """Check for presence of mutually exclusive keys in a dict. | |
479 |
|
479 | |||
480 | Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" |
|
480 | Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" | |
481 | for op1,op2 in ex_op: |
|
481 | for op1,op2 in ex_op: | |
482 | if op1 in dict and op2 in dict: |
|
482 | if op1 in dict and op2 in dict: | |
483 | raise ValueError,'\n*** ERROR in Arguments *** '\ |
|
483 | raise ValueError,'\n*** ERROR in Arguments *** '\ | |
484 | 'Options '+op1+' and '+op2+' are mutually exclusive.' |
|
484 | 'Options '+op1+' and '+op2+' are mutually exclusive.' | |
485 |
|
485 | |||
486 | #----------------------------------------------------------------------------- |
|
486 | #----------------------------------------------------------------------------- | |
487 | def get_py_filename(name): |
|
487 | def get_py_filename(name): | |
488 | """Return a valid python filename in the current directory. |
|
488 | """Return a valid python filename in the current directory. | |
489 |
|
489 | |||
490 | If the given name is not a file, it adds '.py' and searches again. |
|
490 | If the given name is not a file, it adds '.py' and searches again. | |
491 | Raises IOError with an informative message if the file isn't found.""" |
|
491 | Raises IOError with an informative message if the file isn't found.""" | |
492 |
|
492 | |||
493 | name = os.path.expanduser(name) |
|
493 | name = os.path.expanduser(name) | |
494 | if not os.path.isfile(name) and not name.endswith('.py'): |
|
494 | if not os.path.isfile(name) and not name.endswith('.py'): | |
495 | name += '.py' |
|
495 | name += '.py' | |
496 | if os.path.isfile(name): |
|
496 | if os.path.isfile(name): | |
497 | return name |
|
497 | return name | |
498 | else: |
|
498 | else: | |
499 | raise IOError,'File `%s` not found.' % name |
|
499 | raise IOError,'File `%s` not found.' % name | |
500 |
|
500 | |||
501 | #----------------------------------------------------------------------------- |
|
501 | #----------------------------------------------------------------------------- | |
502 | def filefind(fname,alt_dirs = None): |
|
502 | def filefind(fname,alt_dirs = None): | |
503 | """Return the given filename either in the current directory, if it |
|
503 | """Return the given filename either in the current directory, if it | |
504 | exists, or in a specified list of directories. |
|
504 | exists, or in a specified list of directories. | |
505 |
|
505 | |||
506 | ~ expansion is done on all file and directory names. |
|
506 | ~ expansion is done on all file and directory names. | |
507 |
|
507 | |||
508 | Upon an unsuccessful search, raise an IOError exception.""" |
|
508 | Upon an unsuccessful search, raise an IOError exception.""" | |
509 |
|
509 | |||
510 | if alt_dirs is None: |
|
510 | if alt_dirs is None: | |
511 | try: |
|
511 | try: | |
512 | alt_dirs = get_home_dir() |
|
512 | alt_dirs = get_home_dir() | |
513 | except HomeDirError: |
|
513 | except HomeDirError: | |
514 | alt_dirs = os.getcwd() |
|
514 | alt_dirs = os.getcwd() | |
515 | search = [fname] + list_strings(alt_dirs) |
|
515 | search = [fname] + list_strings(alt_dirs) | |
516 | search = map(os.path.expanduser,search) |
|
516 | search = map(os.path.expanduser,search) | |
517 | #print 'search list for',fname,'list:',search # dbg |
|
517 | #print 'search list for',fname,'list:',search # dbg | |
518 | fname = search[0] |
|
518 | fname = search[0] | |
519 | if os.path.isfile(fname): |
|
519 | if os.path.isfile(fname): | |
520 | return fname |
|
520 | return fname | |
521 | for direc in search[1:]: |
|
521 | for direc in search[1:]: | |
522 | testname = os.path.join(direc,fname) |
|
522 | testname = os.path.join(direc,fname) | |
523 | #print 'testname',testname # dbg |
|
523 | #print 'testname',testname # dbg | |
524 | if os.path.isfile(testname): |
|
524 | if os.path.isfile(testname): | |
525 | return testname |
|
525 | return testname | |
526 | raise IOError,'File' + `fname` + \ |
|
526 | raise IOError,'File' + `fname` + \ | |
527 | ' not found in current or supplied directories:' + `alt_dirs` |
|
527 | ' not found in current or supplied directories:' + `alt_dirs` | |
528 |
|
528 | |||
529 | #---------------------------------------------------------------------------- |
|
529 | #---------------------------------------------------------------------------- | |
530 | def file_read(filename): |
|
530 | def file_read(filename): | |
531 | """Read a file and close it. Returns the file source.""" |
|
531 | """Read a file and close it. Returns the file source.""" | |
532 | fobj=open(filename,'r'); |
|
532 | fobj = open(filename,'r'); | |
533 | source = fobj.read(); |
|
533 | source = fobj.read(); | |
534 | fobj.close() |
|
534 | fobj.close() | |
535 | return source |
|
535 | return source | |
536 |
|
536 | |||
|
537 | def file_readlines(filename): | |||
|
538 | """Read a file and close it. Returns the file source using readlines().""" | |||
|
539 | fobj = open(filename,'r'); | |||
|
540 | lines = fobj.readlines(); | |||
|
541 | fobj.close() | |||
|
542 | return lines | |||
|
543 | ||||
537 | #---------------------------------------------------------------------------- |
|
544 | #---------------------------------------------------------------------------- | |
538 | def target_outdated(target,deps): |
|
545 | def target_outdated(target,deps): | |
539 | """Determine whether a target is out of date. |
|
546 | """Determine whether a target is out of date. | |
540 |
|
547 | |||
541 | target_outdated(target,deps) -> 1/0 |
|
548 | target_outdated(target,deps) -> 1/0 | |
542 |
|
549 | |||
543 | deps: list of filenames which MUST exist. |
|
550 | deps: list of filenames which MUST exist. | |
544 | target: single filename which may or may not exist. |
|
551 | target: single filename which may or may not exist. | |
545 |
|
552 | |||
546 | If target doesn't exist or is older than any file listed in deps, return |
|
553 | If target doesn't exist or is older than any file listed in deps, return | |
547 | true, otherwise return false. |
|
554 | true, otherwise return false. | |
548 | """ |
|
555 | """ | |
549 | try: |
|
556 | try: | |
550 | target_time = os.path.getmtime(target) |
|
557 | target_time = os.path.getmtime(target) | |
551 | except os.error: |
|
558 | except os.error: | |
552 | return 1 |
|
559 | return 1 | |
553 | for dep in deps: |
|
560 | for dep in deps: | |
554 | dep_time = os.path.getmtime(dep) |
|
561 | dep_time = os.path.getmtime(dep) | |
555 | if dep_time > target_time: |
|
562 | if dep_time > target_time: | |
556 | #print "For target",target,"Dep failed:",dep # dbg |
|
563 | #print "For target",target,"Dep failed:",dep # dbg | |
557 | #print "times (dep,tar):",dep_time,target_time # dbg |
|
564 | #print "times (dep,tar):",dep_time,target_time # dbg | |
558 | return 1 |
|
565 | return 1 | |
559 | return 0 |
|
566 | return 0 | |
560 |
|
567 | |||
561 | #----------------------------------------------------------------------------- |
|
568 | #----------------------------------------------------------------------------- | |
562 | def target_update(target,deps,cmd): |
|
569 | def target_update(target,deps,cmd): | |
563 | """Update a target with a given command given a list of dependencies. |
|
570 | """Update a target with a given command given a list of dependencies. | |
564 |
|
571 | |||
565 | target_update(target,deps,cmd) -> runs cmd if target is outdated. |
|
572 | target_update(target,deps,cmd) -> runs cmd if target is outdated. | |
566 |
|
573 | |||
567 | This is just a wrapper around target_outdated() which calls the given |
|
574 | This is just a wrapper around target_outdated() which calls the given | |
568 | command if target is outdated.""" |
|
575 | command if target is outdated.""" | |
569 |
|
576 | |||
570 | if target_outdated(target,deps): |
|
577 | if target_outdated(target,deps): | |
571 | xsys(cmd) |
|
578 | xsys(cmd) | |
572 |
|
579 | |||
573 | #---------------------------------------------------------------------------- |
|
580 | #---------------------------------------------------------------------------- | |
574 | def unquote_ends(istr): |
|
581 | def unquote_ends(istr): | |
575 | """Remove a single pair of quotes from the endpoints of a string.""" |
|
582 | """Remove a single pair of quotes from the endpoints of a string.""" | |
576 |
|
583 | |||
577 | if not istr: |
|
584 | if not istr: | |
578 | return istr |
|
585 | return istr | |
579 | if (istr[0]=="'" and istr[-1]=="'") or \ |
|
586 | if (istr[0]=="'" and istr[-1]=="'") or \ | |
580 | (istr[0]=='"' and istr[-1]=='"'): |
|
587 | (istr[0]=='"' and istr[-1]=='"'): | |
581 | return istr[1:-1] |
|
588 | return istr[1:-1] | |
582 | else: |
|
589 | else: | |
583 | return istr |
|
590 | return istr | |
584 |
|
591 | |||
585 | #---------------------------------------------------------------------------- |
|
592 | #---------------------------------------------------------------------------- | |
586 | def process_cmdline(argv,names=[],defaults={},usage=''): |
|
593 | def process_cmdline(argv,names=[],defaults={},usage=''): | |
587 | """ Process command-line options and arguments. |
|
594 | """ Process command-line options and arguments. | |
588 |
|
595 | |||
589 | Arguments: |
|
596 | Arguments: | |
590 |
|
597 | |||
591 | - argv: list of arguments, typically sys.argv. |
|
598 | - argv: list of arguments, typically sys.argv. | |
592 |
|
599 | |||
593 | - names: list of option names. See DPyGetOpt docs for details on options |
|
600 | - names: list of option names. See DPyGetOpt docs for details on options | |
594 | syntax. |
|
601 | syntax. | |
595 |
|
602 | |||
596 | - defaults: dict of default values. |
|
603 | - defaults: dict of default values. | |
597 |
|
604 | |||
598 | - usage: optional usage notice to print if a wrong argument is passed. |
|
605 | - usage: optional usage notice to print if a wrong argument is passed. | |
599 |
|
606 | |||
600 | Return a dict of options and a list of free arguments.""" |
|
607 | Return a dict of options and a list of free arguments.""" | |
601 |
|
608 | |||
602 | getopt = DPyGetOpt.DPyGetOpt() |
|
609 | getopt = DPyGetOpt.DPyGetOpt() | |
603 | getopt.setIgnoreCase(0) |
|
610 | getopt.setIgnoreCase(0) | |
604 | getopt.parseConfiguration(names) |
|
611 | getopt.parseConfiguration(names) | |
605 |
|
612 | |||
606 | try: |
|
613 | try: | |
607 | getopt.processArguments(argv) |
|
614 | getopt.processArguments(argv) | |
608 | except: |
|
615 | except: | |
609 | print usage |
|
616 | print usage | |
610 | warn(`sys.exc_value`,level=4) |
|
617 | warn(`sys.exc_value`,level=4) | |
611 |
|
618 | |||
612 | defaults.update(getopt.optionValues) |
|
619 | defaults.update(getopt.optionValues) | |
613 | args = getopt.freeValues |
|
620 | args = getopt.freeValues | |
614 |
|
621 | |||
615 | return defaults,args |
|
622 | return defaults,args | |
616 |
|
623 | |||
617 | #---------------------------------------------------------------------------- |
|
624 | #---------------------------------------------------------------------------- | |
618 | def optstr2types(ostr): |
|
625 | def optstr2types(ostr): | |
619 | """Convert a string of option names to a dict of type mappings. |
|
626 | """Convert a string of option names to a dict of type mappings. | |
620 |
|
627 | |||
621 | optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'} |
|
628 | optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'} | |
622 |
|
629 | |||
623 | This is used to get the types of all the options in a string formatted |
|
630 | This is used to get the types of all the options in a string formatted | |
624 | with the conventions of DPyGetOpt. The 'type' None is used for options |
|
631 | with the conventions of DPyGetOpt. The 'type' None is used for options | |
625 | which are strings (they need no further conversion). This function's main |
|
632 | which are strings (they need no further conversion). This function's main | |
626 | use is to get a typemap for use with read_dict(). |
|
633 | use is to get a typemap for use with read_dict(). | |
627 | """ |
|
634 | """ | |
628 |
|
635 | |||
629 | typeconv = {None:'',int:'',float:''} |
|
636 | typeconv = {None:'',int:'',float:''} | |
630 | typemap = {'s':None,'i':int,'f':float} |
|
637 | typemap = {'s':None,'i':int,'f':float} | |
631 | opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)') |
|
638 | opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)') | |
632 |
|
639 | |||
633 | for w in ostr.split(): |
|
640 | for w in ostr.split(): | |
634 | oname,alias,otype = opt_re.match(w).groups() |
|
641 | oname,alias,otype = opt_re.match(w).groups() | |
635 | if otype == '' or alias == '!': # simple switches are integers too |
|
642 | if otype == '' or alias == '!': # simple switches are integers too | |
636 | otype = 'i' |
|
643 | otype = 'i' | |
637 | typeconv[typemap[otype]] += oname + ' ' |
|
644 | typeconv[typemap[otype]] += oname + ' ' | |
638 | return typeconv |
|
645 | return typeconv | |
639 |
|
646 | |||
640 | #---------------------------------------------------------------------------- |
|
647 | #---------------------------------------------------------------------------- | |
641 | def read_dict(filename,type_conv=None,**opt): |
|
648 | def read_dict(filename,type_conv=None,**opt): | |
642 |
|
649 | |||
643 | """Read a dictionary of key=value pairs from an input file, optionally |
|
650 | """Read a dictionary of key=value pairs from an input file, optionally | |
644 | performing conversions on the resulting values. |
|
651 | performing conversions on the resulting values. | |
645 |
|
652 | |||
646 | read_dict(filename,type_conv,**opt) -> dict |
|
653 | read_dict(filename,type_conv,**opt) -> dict | |
647 |
|
654 | |||
648 | Only one value per line is accepted, the format should be |
|
655 | Only one value per line is accepted, the format should be | |
649 | # optional comments are ignored |
|
656 | # optional comments are ignored | |
650 | key value\n |
|
657 | key value\n | |
651 |
|
658 | |||
652 | Args: |
|
659 | Args: | |
653 |
|
660 | |||
654 | - type_conv: A dictionary specifying which keys need to be converted to |
|
661 | - type_conv: A dictionary specifying which keys need to be converted to | |
655 | which types. By default all keys are read as strings. This dictionary |
|
662 | which types. By default all keys are read as strings. This dictionary | |
656 | should have as its keys valid conversion functions for strings |
|
663 | should have as its keys valid conversion functions for strings | |
657 | (int,long,float,complex, or your own). The value for each key |
|
664 | (int,long,float,complex, or your own). The value for each key | |
658 | (converter) should be a whitespace separated string containing the names |
|
665 | (converter) should be a whitespace separated string containing the names | |
659 | of all the entries in the file to be converted using that function. For |
|
666 | of all the entries in the file to be converted using that function. For | |
660 | keys to be left alone, use None as the conversion function (only needed |
|
667 | keys to be left alone, use None as the conversion function (only needed | |
661 | with purge=1, see below). |
|
668 | with purge=1, see below). | |
662 |
|
669 | |||
663 | - opt: dictionary with extra options as below (default in parens) |
|
670 | - opt: dictionary with extra options as below (default in parens) | |
664 |
|
671 | |||
665 | purge(0): if set to 1, all keys *not* listed in type_conv are purged out |
|
672 | purge(0): if set to 1, all keys *not* listed in type_conv are purged out | |
666 | of the dictionary to be returned. If purge is going to be used, the |
|
673 | of the dictionary to be returned. If purge is going to be used, the | |
667 | set of keys to be left as strings also has to be explicitly specified |
|
674 | set of keys to be left as strings also has to be explicitly specified | |
668 | using the (non-existent) conversion function None. |
|
675 | using the (non-existent) conversion function None. | |
669 |
|
676 | |||
670 | fs(None): field separator. This is the key/value separator to be used |
|
677 | fs(None): field separator. This is the key/value separator to be used | |
671 | when parsing the file. The None default means any whitespace [behavior |
|
678 | when parsing the file. The None default means any whitespace [behavior | |
672 | of string.split()]. |
|
679 | of string.split()]. | |
673 |
|
680 | |||
674 | strip(0): if 1, strip string values of leading/trailinig whitespace. |
|
681 | strip(0): if 1, strip string values of leading/trailinig whitespace. | |
675 |
|
682 | |||
676 | warn(1): warning level if requested keys are not found in file. |
|
683 | warn(1): warning level if requested keys are not found in file. | |
677 | - 0: silently ignore. |
|
684 | - 0: silently ignore. | |
678 | - 1: inform but proceed. |
|
685 | - 1: inform but proceed. | |
679 | - 2: raise KeyError exception. |
|
686 | - 2: raise KeyError exception. | |
680 |
|
687 | |||
681 | no_empty(0): if 1, remove keys with whitespace strings as a value. |
|
688 | no_empty(0): if 1, remove keys with whitespace strings as a value. | |
682 |
|
689 | |||
683 | unique([]): list of keys (or space separated string) which can't be |
|
690 | unique([]): list of keys (or space separated string) which can't be | |
684 | repeated. If one such key is found in the file, each new instance |
|
691 | repeated. If one such key is found in the file, each new instance | |
685 | overwrites the previous one. For keys not listed here, the behavior is |
|
692 | overwrites the previous one. For keys not listed here, the behavior is | |
686 | to make a list of all appearances. |
|
693 | to make a list of all appearances. | |
687 |
|
694 | |||
688 | Example: |
|
695 | Example: | |
689 | If the input file test.ini has: |
|
696 | If the input file test.ini has: | |
690 | i 3 |
|
697 | i 3 | |
691 | x 4.5 |
|
698 | x 4.5 | |
692 | y 5.5 |
|
699 | y 5.5 | |
693 | s hi ho |
|
700 | s hi ho | |
694 | Then: |
|
701 | Then: | |
695 |
|
702 | |||
696 | >>> type_conv={int:'i',float:'x',None:'s'} |
|
703 | >>> type_conv={int:'i',float:'x',None:'s'} | |
697 | >>> read_dict('test.ini') |
|
704 | >>> read_dict('test.ini') | |
698 | {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'} |
|
705 | {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'} | |
699 | >>> read_dict('test.ini',type_conv) |
|
706 | >>> read_dict('test.ini',type_conv) | |
700 | {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'} |
|
707 | {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'} | |
701 | >>> read_dict('test.ini',type_conv,purge=1) |
|
708 | >>> read_dict('test.ini',type_conv,purge=1) | |
702 | {'i': 3, 's': 'hi ho', 'x': 4.5} |
|
709 | {'i': 3, 's': 'hi ho', 'x': 4.5} | |
703 | """ |
|
710 | """ | |
704 |
|
711 | |||
705 | # starting config |
|
712 | # starting config | |
706 | opt.setdefault('purge',0) |
|
713 | opt.setdefault('purge',0) | |
707 | opt.setdefault('fs',None) # field sep defaults to any whitespace |
|
714 | opt.setdefault('fs',None) # field sep defaults to any whitespace | |
708 | opt.setdefault('strip',0) |
|
715 | opt.setdefault('strip',0) | |
709 | opt.setdefault('warn',1) |
|
716 | opt.setdefault('warn',1) | |
710 | opt.setdefault('no_empty',0) |
|
717 | opt.setdefault('no_empty',0) | |
711 | opt.setdefault('unique','') |
|
718 | opt.setdefault('unique','') | |
712 | if type(opt['unique']) in StringTypes: |
|
719 | if type(opt['unique']) in StringTypes: | |
713 | unique_keys = qw(opt['unique']) |
|
720 | unique_keys = qw(opt['unique']) | |
714 | elif type(opt['unique']) in (types.TupleType,types.ListType): |
|
721 | elif type(opt['unique']) in (types.TupleType,types.ListType): | |
715 | unique_keys = opt['unique'] |
|
722 | unique_keys = opt['unique'] | |
716 | else: |
|
723 | else: | |
717 | raise ValueError, 'Unique keys must be given as a string, List or Tuple' |
|
724 | raise ValueError, 'Unique keys must be given as a string, List or Tuple' | |
718 |
|
725 | |||
719 | dict = {} |
|
726 | dict = {} | |
720 | # first read in table of values as strings |
|
727 | # first read in table of values as strings | |
721 | file = open(filename,'r') |
|
728 | file = open(filename,'r') | |
722 | for line in file.readlines(): |
|
729 | for line in file.readlines(): | |
723 | line = line.strip() |
|
730 | line = line.strip() | |
724 | if len(line) and line[0]=='#': continue |
|
731 | if len(line) and line[0]=='#': continue | |
725 | if len(line)>0: |
|
732 | if len(line)>0: | |
726 | lsplit = line.split(opt['fs'],1) |
|
733 | lsplit = line.split(opt['fs'],1) | |
727 | try: |
|
734 | try: | |
728 | key,val = lsplit |
|
735 | key,val = lsplit | |
729 | except ValueError: |
|
736 | except ValueError: | |
730 | key,val = lsplit[0],'' |
|
737 | key,val = lsplit[0],'' | |
731 | key = key.strip() |
|
738 | key = key.strip() | |
732 | if opt['strip']: val = val.strip() |
|
739 | if opt['strip']: val = val.strip() | |
733 | if val == "''" or val == '""': val = '' |
|
740 | if val == "''" or val == '""': val = '' | |
734 | if opt['no_empty'] and (val=='' or val.isspace()): |
|
741 | if opt['no_empty'] and (val=='' or val.isspace()): | |
735 | continue |
|
742 | continue | |
736 | # if a key is found more than once in the file, build a list |
|
743 | # if a key is found more than once in the file, build a list | |
737 | # unless it's in the 'unique' list. In that case, last found in file |
|
744 | # unless it's in the 'unique' list. In that case, last found in file | |
738 | # takes precedence. User beware. |
|
745 | # takes precedence. User beware. | |
739 | try: |
|
746 | try: | |
740 | if dict[key] and key in unique_keys: |
|
747 | if dict[key] and key in unique_keys: | |
741 | dict[key] = val |
|
748 | dict[key] = val | |
742 | elif type(dict[key]) is types.ListType: |
|
749 | elif type(dict[key]) is types.ListType: | |
743 | dict[key].append(val) |
|
750 | dict[key].append(val) | |
744 | else: |
|
751 | else: | |
745 | dict[key] = [dict[key],val] |
|
752 | dict[key] = [dict[key],val] | |
746 | except KeyError: |
|
753 | except KeyError: | |
747 | dict[key] = val |
|
754 | dict[key] = val | |
748 | # purge if requested |
|
755 | # purge if requested | |
749 | if opt['purge']: |
|
756 | if opt['purge']: | |
750 | accepted_keys = qwflat(type_conv.values()) |
|
757 | accepted_keys = qwflat(type_conv.values()) | |
751 | for key in dict.keys(): |
|
758 | for key in dict.keys(): | |
752 | if key in accepted_keys: continue |
|
759 | if key in accepted_keys: continue | |
753 | del(dict[key]) |
|
760 | del(dict[key]) | |
754 | # now convert if requested |
|
761 | # now convert if requested | |
755 | if type_conv==None: return dict |
|
762 | if type_conv==None: return dict | |
756 | conversions = type_conv.keys() |
|
763 | conversions = type_conv.keys() | |
757 | try: conversions.remove(None) |
|
764 | try: conversions.remove(None) | |
758 | except: pass |
|
765 | except: pass | |
759 | for convert in conversions: |
|
766 | for convert in conversions: | |
760 | for val in qw(type_conv[convert]): |
|
767 | for val in qw(type_conv[convert]): | |
761 | try: |
|
768 | try: | |
762 | dict[val] = convert(dict[val]) |
|
769 | dict[val] = convert(dict[val]) | |
763 | except KeyError,e: |
|
770 | except KeyError,e: | |
764 | if opt['warn'] == 0: |
|
771 | if opt['warn'] == 0: | |
765 | pass |
|
772 | pass | |
766 | elif opt['warn'] == 1: |
|
773 | elif opt['warn'] == 1: | |
767 | print >>sys.stderr, 'Warning: key',val,\ |
|
774 | print >>sys.stderr, 'Warning: key',val,\ | |
768 | 'not found in file',filename |
|
775 | 'not found in file',filename | |
769 | elif opt['warn'] == 2: |
|
776 | elif opt['warn'] == 2: | |
770 | raise KeyError,e |
|
777 | raise KeyError,e | |
771 | else: |
|
778 | else: | |
772 | raise ValueError,'Warning level must be 0,1 or 2' |
|
779 | raise ValueError,'Warning level must be 0,1 or 2' | |
773 |
|
780 | |||
774 | return dict |
|
781 | return dict | |
775 |
|
782 | |||
776 | #---------------------------------------------------------------------------- |
|
783 | #---------------------------------------------------------------------------- | |
777 | def flag_calls(func): |
|
784 | def flag_calls(func): | |
778 | """Wrap a function to detect and flag when it gets called. |
|
785 | """Wrap a function to detect and flag when it gets called. | |
779 |
|
786 | |||
780 | This is a decorator which takes a function and wraps it in a function with |
|
787 | This is a decorator which takes a function and wraps it in a function with | |
781 | a 'called' attribute. wrapper.called is initialized to False. |
|
788 | a 'called' attribute. wrapper.called is initialized to False. | |
782 |
|
789 | |||
783 | The wrapper.called attribute is set to False right before each call to the |
|
790 | The wrapper.called attribute is set to False right before each call to the | |
784 | wrapped function, so if the call fails it remains False. After the call |
|
791 | wrapped function, so if the call fails it remains False. After the call | |
785 | completes, wrapper.called is set to True and the output is returned. |
|
792 | completes, wrapper.called is set to True and the output is returned. | |
786 |
|
793 | |||
787 | Testing for truth in wrapper.called allows you to determine if a call to |
|
794 | Testing for truth in wrapper.called allows you to determine if a call to | |
788 | func() was attempted and succeeded.""" |
|
795 | func() was attempted and succeeded.""" | |
789 |
|
796 | |||
790 | def wrapper(*args,**kw): |
|
797 | def wrapper(*args,**kw): | |
791 | wrapper.called = False |
|
798 | wrapper.called = False | |
792 | out = func(*args,**kw) |
|
799 | out = func(*args,**kw) | |
793 | wrapper.called = True |
|
800 | wrapper.called = True | |
794 | return out |
|
801 | return out | |
795 |
|
802 | |||
796 | wrapper.called = False |
|
803 | wrapper.called = False | |
797 | wrapper.__doc__ = func.__doc__ |
|
804 | wrapper.__doc__ = func.__doc__ | |
798 | return wrapper |
|
805 | return wrapper | |
799 |
|
806 | |||
800 | #---------------------------------------------------------------------------- |
|
807 | #---------------------------------------------------------------------------- | |
801 | class HomeDirError(Error): |
|
808 | class HomeDirError(Error): | |
802 | pass |
|
809 | pass | |
803 |
|
810 | |||
804 | def get_home_dir(): |
|
811 | def get_home_dir(): | |
805 | """Return the closest possible equivalent to a 'home' directory. |
|
812 | """Return the closest possible equivalent to a 'home' directory. | |
806 |
|
813 | |||
807 | We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH. |
|
814 | We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH. | |
808 |
|
815 | |||
809 | Currently only Posix and NT are implemented, a HomeDirError exception is |
|
816 | Currently only Posix and NT are implemented, a HomeDirError exception is | |
810 | raised for all other OSes. """ |
|
817 | raised for all other OSes. """ | |
811 |
|
818 | |||
812 | isdir = os.path.isdir |
|
819 | isdir = os.path.isdir | |
813 | env = os.environ |
|
820 | env = os.environ | |
814 | try: |
|
821 | try: | |
815 | homedir = env['HOME'] |
|
822 | homedir = env['HOME'] | |
816 | if not isdir(homedir): |
|
823 | if not isdir(homedir): | |
817 | # in case a user stuck some string which does NOT resolve to a |
|
824 | # in case a user stuck some string which does NOT resolve to a | |
818 | # valid path, it's as good as if we hadn't foud it |
|
825 | # valid path, it's as good as if we hadn't foud it | |
819 | raise KeyError |
|
826 | raise KeyError | |
820 | return homedir |
|
827 | return homedir | |
821 | except KeyError: |
|
828 | except KeyError: | |
822 | if os.name == 'posix': |
|
829 | if os.name == 'posix': | |
823 | raise HomeDirError,'undefined $HOME, IPython can not proceed.' |
|
830 | raise HomeDirError,'undefined $HOME, IPython can not proceed.' | |
824 | elif os.name == 'nt': |
|
831 | elif os.name == 'nt': | |
825 | # For some strange reason, win9x returns 'nt' for os.name. |
|
832 | # For some strange reason, win9x returns 'nt' for os.name. | |
826 | try: |
|
833 | try: | |
827 | homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) |
|
834 | homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) | |
828 | if not isdir(homedir): |
|
835 | if not isdir(homedir): | |
829 | homedir = os.path.join(env['USERPROFILE']) |
|
836 | homedir = os.path.join(env['USERPROFILE']) | |
830 | if not isdir(homedir): |
|
837 | if not isdir(homedir): | |
831 | raise HomeDirError |
|
838 | raise HomeDirError | |
832 | return homedir |
|
839 | return homedir | |
833 | except: |
|
840 | except: | |
834 | try: |
|
841 | try: | |
835 | # Use the registry to get the 'My Documents' folder. |
|
842 | # Use the registry to get the 'My Documents' folder. | |
836 | import _winreg as wreg |
|
843 | import _winreg as wreg | |
837 | key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, |
|
844 | key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, | |
838 | "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") |
|
845 | "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") | |
839 | homedir = wreg.QueryValueEx(key,'Personal')[0] |
|
846 | homedir = wreg.QueryValueEx(key,'Personal')[0] | |
840 | key.Close() |
|
847 | key.Close() | |
841 | if not isdir(homedir): |
|
848 | if not isdir(homedir): | |
842 | e = ('Invalid "Personal" folder registry key ' |
|
849 | e = ('Invalid "Personal" folder registry key ' | |
843 | 'typically "My Documents".\n' |
|
850 | 'typically "My Documents".\n' | |
844 | 'Value: %s\n' |
|
851 | 'Value: %s\n' | |
845 | 'This is not a valid directory on your system.' % |
|
852 | 'This is not a valid directory on your system.' % | |
846 | homedir) |
|
853 | homedir) | |
847 | raise HomeDirError(e) |
|
854 | raise HomeDirError(e) | |
848 | return homedir |
|
855 | return homedir | |
849 | except HomeDirError: |
|
856 | except HomeDirError: | |
850 | raise |
|
857 | raise | |
851 | except: |
|
858 | except: | |
852 | return 'C:\\' |
|
859 | return 'C:\\' | |
853 | elif os.name == 'dos': |
|
860 | elif os.name == 'dos': | |
854 | # Desperate, may do absurd things in classic MacOS. May work under DOS. |
|
861 | # Desperate, may do absurd things in classic MacOS. May work under DOS. | |
855 | return 'C:\\' |
|
862 | return 'C:\\' | |
856 | else: |
|
863 | else: | |
857 | raise HomeDirError,'support for your operating system not implemented.' |
|
864 | raise HomeDirError,'support for your operating system not implemented.' | |
858 |
|
865 | |||
859 | #**************************************************************************** |
|
866 | #**************************************************************************** | |
860 | # strings and text |
|
867 | # strings and text | |
861 |
|
868 | |||
862 | class LSString(str): |
|
869 | class LSString(str): | |
863 | """String derivative with a special access attributes. |
|
870 | """String derivative with a special access attributes. | |
864 |
|
871 | |||
865 | These are normal strings, but with the special attributes: |
|
872 | These are normal strings, but with the special attributes: | |
866 |
|
873 | |||
867 | .l (or .list) : value as list (split on newlines). |
|
874 | .l (or .list) : value as list (split on newlines). | |
868 | .n (or .nlstr): original value (the string itself). |
|
875 | .n (or .nlstr): original value (the string itself). | |
869 | .s (or .spstr): value as whitespace-separated string. |
|
876 | .s (or .spstr): value as whitespace-separated string. | |
870 |
|
877 | |||
871 | Any values which require transformations are computed only once and |
|
878 | Any values which require transformations are computed only once and | |
872 | cached. |
|
879 | cached. | |
873 |
|
880 | |||
874 | Such strings are very useful to efficiently interact with the shell, which |
|
881 | Such strings are very useful to efficiently interact with the shell, which | |
875 | typically only understands whitespace-separated options for commands.""" |
|
882 | typically only understands whitespace-separated options for commands.""" | |
876 |
|
883 | |||
877 | def get_list(self): |
|
884 | def get_list(self): | |
878 | try: |
|
885 | try: | |
879 | return self.__list |
|
886 | return self.__list | |
880 | except AttributeError: |
|
887 | except AttributeError: | |
881 | self.__list = self.split('\n') |
|
888 | self.__list = self.split('\n') | |
882 | return self.__list |
|
889 | return self.__list | |
883 |
|
890 | |||
884 | l = list = property(get_list) |
|
891 | l = list = property(get_list) | |
885 |
|
892 | |||
886 | def get_spstr(self): |
|
893 | def get_spstr(self): | |
887 | try: |
|
894 | try: | |
888 | return self.__spstr |
|
895 | return self.__spstr | |
889 | except AttributeError: |
|
896 | except AttributeError: | |
890 | self.__spstr = self.replace('\n',' ') |
|
897 | self.__spstr = self.replace('\n',' ') | |
891 | return self.__spstr |
|
898 | return self.__spstr | |
892 |
|
899 | |||
893 | s = spstr = property(get_spstr) |
|
900 | s = spstr = property(get_spstr) | |
894 |
|
901 | |||
895 | def get_nlstr(self): |
|
902 | def get_nlstr(self): | |
896 | return self |
|
903 | return self | |
897 |
|
904 | |||
898 | n = nlstr = property(get_nlstr) |
|
905 | n = nlstr = property(get_nlstr) | |
899 |
|
906 | |||
900 | def get_paths(self): |
|
907 | def get_paths(self): | |
901 | try: |
|
908 | try: | |
902 | return self.__paths |
|
909 | return self.__paths | |
903 | except AttributeError: |
|
910 | except AttributeError: | |
904 | self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)] |
|
911 | self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)] | |
905 | return self.__paths |
|
912 | return self.__paths | |
906 |
|
913 | |||
907 | p = paths = property(get_paths) |
|
914 | p = paths = property(get_paths) | |
908 |
|
915 | |||
909 |
|
916 | |||
910 | #---------------------------------------------------------------------------- |
|
917 | #---------------------------------------------------------------------------- | |
911 | class SList(list): |
|
918 | class SList(list): | |
912 | """List derivative with a special access attributes. |
|
919 | """List derivative with a special access attributes. | |
913 |
|
920 | |||
914 | These are normal lists, but with the special attributes: |
|
921 | These are normal lists, but with the special attributes: | |
915 |
|
922 | |||
916 | .l (or .list) : value as list (the list itself). |
|
923 | .l (or .list) : value as list (the list itself). | |
917 | .n (or .nlstr): value as a string, joined on newlines. |
|
924 | .n (or .nlstr): value as a string, joined on newlines. | |
918 | .s (or .spstr): value as a string, joined on spaces. |
|
925 | .s (or .spstr): value as a string, joined on spaces. | |
919 |
|
926 | |||
920 | Any values which require transformations are computed only once and |
|
927 | Any values which require transformations are computed only once and | |
921 | cached.""" |
|
928 | cached.""" | |
922 |
|
929 | |||
923 | def get_list(self): |
|
930 | def get_list(self): | |
924 | return self |
|
931 | return self | |
925 |
|
932 | |||
926 | l = list = property(get_list) |
|
933 | l = list = property(get_list) | |
927 |
|
934 | |||
928 | def get_spstr(self): |
|
935 | def get_spstr(self): | |
929 | try: |
|
936 | try: | |
930 | return self.__spstr |
|
937 | return self.__spstr | |
931 | except AttributeError: |
|
938 | except AttributeError: | |
932 | self.__spstr = ' '.join(self) |
|
939 | self.__spstr = ' '.join(self) | |
933 | return self.__spstr |
|
940 | return self.__spstr | |
934 |
|
941 | |||
935 | s = spstr = property(get_spstr) |
|
942 | s = spstr = property(get_spstr) | |
936 |
|
943 | |||
937 | def get_nlstr(self): |
|
944 | def get_nlstr(self): | |
938 | try: |
|
945 | try: | |
939 | return self.__nlstr |
|
946 | return self.__nlstr | |
940 | except AttributeError: |
|
947 | except AttributeError: | |
941 | self.__nlstr = '\n'.join(self) |
|
948 | self.__nlstr = '\n'.join(self) | |
942 | return self.__nlstr |
|
949 | return self.__nlstr | |
943 |
|
950 | |||
944 | n = nlstr = property(get_nlstr) |
|
951 | n = nlstr = property(get_nlstr) | |
945 |
|
952 | |||
946 | def get_paths(self): |
|
953 | def get_paths(self): | |
947 | try: |
|
954 | try: | |
948 | return self.__paths |
|
955 | return self.__paths | |
949 | except AttributeError: |
|
956 | except AttributeError: | |
950 | self.__paths = [path(p) for p in self if os.path.exists(p)] |
|
957 | self.__paths = [path(p) for p in self if os.path.exists(p)] | |
951 | return self.__paths |
|
958 | return self.__paths | |
952 |
|
959 | |||
953 | p = paths = property(get_paths) |
|
960 | p = paths = property(get_paths) | |
954 |
|
961 | |||
955 | #---------------------------------------------------------------------------- |
|
962 | #---------------------------------------------------------------------------- | |
956 | def esc_quotes(strng): |
|
963 | def esc_quotes(strng): | |
957 | """Return the input string with single and double quotes escaped out""" |
|
964 | """Return the input string with single and double quotes escaped out""" | |
958 |
|
965 | |||
959 | return strng.replace('"','\\"').replace("'","\\'") |
|
966 | return strng.replace('"','\\"').replace("'","\\'") | |
960 |
|
967 | |||
961 | #---------------------------------------------------------------------------- |
|
968 | #---------------------------------------------------------------------------- | |
962 | def make_quoted_expr(s): |
|
969 | def make_quoted_expr(s): | |
963 | """Return string s in appropriate quotes, using raw string if possible. |
|
970 | """Return string s in appropriate quotes, using raw string if possible. | |
964 |
|
971 | |||
965 | Effectively this turns string: cd \ao\ao\ |
|
972 | Effectively this turns string: cd \ao\ao\ | |
966 | to: r"cd \ao\ao\_"[:-1] |
|
973 | to: r"cd \ao\ao\_"[:-1] | |
967 |
|
974 | |||
968 | Note the use of raw string and padding at the end to allow trailing backslash. |
|
975 | Note the use of raw string and padding at the end to allow trailing backslash. | |
969 |
|
976 | |||
970 | """ |
|
977 | """ | |
971 |
|
978 | |||
972 | tail = '' |
|
979 | tail = '' | |
973 | tailpadding = '' |
|
980 | tailpadding = '' | |
974 | raw = '' |
|
981 | raw = '' | |
975 | if "\\" in s: |
|
982 | if "\\" in s: | |
976 | raw = 'r' |
|
983 | raw = 'r' | |
977 | if s.endswith('\\'): |
|
984 | if s.endswith('\\'): | |
978 | tail = '[:-1]' |
|
985 | tail = '[:-1]' | |
979 | tailpadding = '_' |
|
986 | tailpadding = '_' | |
980 | if '"' not in s: |
|
987 | if '"' not in s: | |
981 | quote = '"' |
|
988 | quote = '"' | |
982 | elif "'" not in s: |
|
989 | elif "'" not in s: | |
983 | quote = "'" |
|
990 | quote = "'" | |
984 | elif '"""' not in s and not s.endswith('"'): |
|
991 | elif '"""' not in s and not s.endswith('"'): | |
985 | quote = '"""' |
|
992 | quote = '"""' | |
986 | elif "'''" not in s and not s.endswith("'"): |
|
993 | elif "'''" not in s and not s.endswith("'"): | |
987 | quote = "'''" |
|
994 | quote = "'''" | |
988 | else: |
|
995 | else: | |
989 | # give up, backslash-escaped string will do |
|
996 | # give up, backslash-escaped string will do | |
990 | return '"%s"' % esc_quotes(s) |
|
997 | return '"%s"' % esc_quotes(s) | |
991 | res = itpl("$raw$quote$s$tailpadding$quote$tail") |
|
998 | res = itpl("$raw$quote$s$tailpadding$quote$tail") | |
992 | return res |
|
999 | return res | |
993 |
|
1000 | |||
994 |
|
1001 | |||
995 | #---------------------------------------------------------------------------- |
|
1002 | #---------------------------------------------------------------------------- | |
996 | def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'): |
|
1003 | def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'): | |
997 | """Take multiple lines of input. |
|
1004 | """Take multiple lines of input. | |
998 |
|
1005 | |||
999 | A list with each line of input as a separate element is returned when a |
|
1006 | A list with each line of input as a separate element is returned when a | |
1000 | termination string is entered (defaults to a single '.'). Input can also |
|
1007 | termination string is entered (defaults to a single '.'). Input can also | |
1001 | terminate via EOF (^D in Unix, ^Z-RET in Windows). |
|
1008 | terminate via EOF (^D in Unix, ^Z-RET in Windows). | |
1002 |
|
1009 | |||
1003 | Lines of input which end in \\ are joined into single entries (and a |
|
1010 | Lines of input which end in \\ are joined into single entries (and a | |
1004 | secondary continuation prompt is issued as long as the user terminates |
|
1011 | secondary continuation prompt is issued as long as the user terminates | |
1005 | lines with \\). This allows entering very long strings which are still |
|
1012 | lines with \\). This allows entering very long strings which are still | |
1006 | meant to be treated as single entities. |
|
1013 | meant to be treated as single entities. | |
1007 | """ |
|
1014 | """ | |
1008 |
|
1015 | |||
1009 | try: |
|
1016 | try: | |
1010 | if header: |
|
1017 | if header: | |
1011 | header += '\n' |
|
1018 | header += '\n' | |
1012 | lines = [raw_input(header + ps1)] |
|
1019 | lines = [raw_input(header + ps1)] | |
1013 | except EOFError: |
|
1020 | except EOFError: | |
1014 | return [] |
|
1021 | return [] | |
1015 | terminate = [terminate_str] |
|
1022 | terminate = [terminate_str] | |
1016 | try: |
|
1023 | try: | |
1017 | while lines[-1:] != terminate: |
|
1024 | while lines[-1:] != terminate: | |
1018 | new_line = raw_input(ps1) |
|
1025 | new_line = raw_input(ps1) | |
1019 | while new_line.endswith('\\'): |
|
1026 | while new_line.endswith('\\'): | |
1020 | new_line = new_line[:-1] + raw_input(ps2) |
|
1027 | new_line = new_line[:-1] + raw_input(ps2) | |
1021 | lines.append(new_line) |
|
1028 | lines.append(new_line) | |
1022 |
|
1029 | |||
1023 | return lines[:-1] # don't return the termination command |
|
1030 | return lines[:-1] # don't return the termination command | |
1024 | except EOFError: |
|
1031 | except EOFError: | |
1025 |
|
1032 | |||
1026 | return lines |
|
1033 | return lines | |
1027 |
|
1034 | |||
1028 | #---------------------------------------------------------------------------- |
|
1035 | #---------------------------------------------------------------------------- | |
1029 | def raw_input_ext(prompt='', ps2='... '): |
|
1036 | def raw_input_ext(prompt='', ps2='... '): | |
1030 | """Similar to raw_input(), but accepts extended lines if input ends with \\.""" |
|
1037 | """Similar to raw_input(), but accepts extended lines if input ends with \\.""" | |
1031 |
|
1038 | |||
1032 | line = raw_input(prompt) |
|
1039 | line = raw_input(prompt) | |
1033 | while line.endswith('\\'): |
|
1040 | while line.endswith('\\'): | |
1034 | line = line[:-1] + raw_input(ps2) |
|
1041 | line = line[:-1] + raw_input(ps2) | |
1035 | return line |
|
1042 | return line | |
1036 |
|
1043 | |||
1037 | #---------------------------------------------------------------------------- |
|
1044 | #---------------------------------------------------------------------------- | |
1038 | def ask_yes_no(prompt,default=None): |
|
1045 | def ask_yes_no(prompt,default=None): | |
1039 | """Asks a question and returns an integer 1/0 (y/n) answer. |
|
1046 | """Asks a question and returns an integer 1/0 (y/n) answer. | |
1040 |
|
1047 | |||
1041 | If default is given (one of 'y','n'), it is used if the user input is |
|
1048 | If default is given (one of 'y','n'), it is used if the user input is | |
1042 | empty. Otherwise the question is repeated until an answer is given. |
|
1049 | empty. Otherwise the question is repeated until an answer is given. | |
1043 | If EOF occurs 20 times consecutively, the default answer is assumed, |
|
1050 | If EOF occurs 20 times consecutively, the default answer is assumed, | |
1044 | or if there is no default, an exception is raised to prevent infinite |
|
1051 | or if there is no default, an exception is raised to prevent infinite | |
1045 | loops. |
|
1052 | loops. | |
1046 |
|
1053 | |||
1047 | Valid answers are: y/yes/n/no (match is not case sensitive).""" |
|
1054 | Valid answers are: y/yes/n/no (match is not case sensitive).""" | |
1048 |
|
1055 | |||
1049 | answers = {'y':True,'n':False,'yes':True,'no':False} |
|
1056 | answers = {'y':True,'n':False,'yes':True,'no':False} | |
1050 | ans = None |
|
1057 | ans = None | |
1051 | eofs, max_eofs = 0, 20 |
|
1058 | eofs, max_eofs = 0, 20 | |
1052 | while ans not in answers.keys(): |
|
1059 | while ans not in answers.keys(): | |
1053 | try: |
|
1060 | try: | |
1054 | ans = raw_input(prompt+' ').lower() |
|
1061 | ans = raw_input(prompt+' ').lower() | |
1055 | if not ans: # response was an empty string |
|
1062 | if not ans: # response was an empty string | |
1056 | ans = default |
|
1063 | ans = default | |
1057 | eofs = 0 |
|
1064 | eofs = 0 | |
1058 | except (EOFError,KeyboardInterrupt): |
|
1065 | except (EOFError,KeyboardInterrupt): | |
1059 | eofs = eofs + 1 |
|
1066 | eofs = eofs + 1 | |
1060 | if eofs >= max_eofs: |
|
1067 | if eofs >= max_eofs: | |
1061 | if default in answers.keys(): |
|
1068 | if default in answers.keys(): | |
1062 | ans = default |
|
1069 | ans = default | |
1063 | else: |
|
1070 | else: | |
1064 | raise |
|
1071 | raise | |
1065 |
|
1072 | |||
1066 | return answers[ans] |
|
1073 | return answers[ans] | |
1067 |
|
1074 | |||
1068 | #---------------------------------------------------------------------------- |
|
1075 | #---------------------------------------------------------------------------- | |
1069 | def marquee(txt='',width=78,mark='*'): |
|
1076 | def marquee(txt='',width=78,mark='*'): | |
1070 | """Return the input string centered in a 'marquee'.""" |
|
1077 | """Return the input string centered in a 'marquee'.""" | |
1071 | if not txt: |
|
1078 | if not txt: | |
1072 | return (mark*width)[:width] |
|
1079 | return (mark*width)[:width] | |
1073 | nmark = (width-len(txt)-2)/len(mark)/2 |
|
1080 | nmark = (width-len(txt)-2)/len(mark)/2 | |
1074 | if nmark < 0: nmark =0 |
|
1081 | if nmark < 0: nmark =0 | |
1075 | marks = mark*nmark |
|
1082 | marks = mark*nmark | |
1076 | return '%s %s %s' % (marks,txt,marks) |
|
1083 | return '%s %s %s' % (marks,txt,marks) | |
1077 |
|
1084 | |||
1078 | #---------------------------------------------------------------------------- |
|
1085 | #---------------------------------------------------------------------------- | |
1079 | class EvalDict: |
|
1086 | class EvalDict: | |
1080 | """ |
|
1087 | """ | |
1081 | Emulate a dict which evaluates its contents in the caller's frame. |
|
1088 | Emulate a dict which evaluates its contents in the caller's frame. | |
1082 |
|
1089 | |||
1083 | Usage: |
|
1090 | Usage: | |
1084 | >>>number = 19 |
|
1091 | >>>number = 19 | |
1085 | >>>text = "python" |
|
1092 | >>>text = "python" | |
1086 | >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict() |
|
1093 | >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict() | |
1087 | """ |
|
1094 | """ | |
1088 |
|
1095 | |||
1089 | # This version is due to sismex01@hebmex.com on c.l.py, and is basically a |
|
1096 | # This version is due to sismex01@hebmex.com on c.l.py, and is basically a | |
1090 | # modified (shorter) version of: |
|
1097 | # modified (shorter) version of: | |
1091 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by |
|
1098 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by | |
1092 | # Skip Montanaro (skip@pobox.com). |
|
1099 | # Skip Montanaro (skip@pobox.com). | |
1093 |
|
1100 | |||
1094 | def __getitem__(self, name): |
|
1101 | def __getitem__(self, name): | |
1095 | frame = sys._getframe(1) |
|
1102 | frame = sys._getframe(1) | |
1096 | return eval(name, frame.f_globals, frame.f_locals) |
|
1103 | return eval(name, frame.f_globals, frame.f_locals) | |
1097 |
|
1104 | |||
1098 | EvalString = EvalDict # for backwards compatibility |
|
1105 | EvalString = EvalDict # for backwards compatibility | |
1099 | #---------------------------------------------------------------------------- |
|
1106 | #---------------------------------------------------------------------------- | |
1100 | def qw(words,flat=0,sep=None,maxsplit=-1): |
|
1107 | def qw(words,flat=0,sep=None,maxsplit=-1): | |
1101 | """Similar to Perl's qw() operator, but with some more options. |
|
1108 | """Similar to Perl's qw() operator, but with some more options. | |
1102 |
|
1109 | |||
1103 | qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) |
|
1110 | qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) | |
1104 |
|
1111 | |||
1105 | words can also be a list itself, and with flat=1, the output will be |
|
1112 | words can also be a list itself, and with flat=1, the output will be | |
1106 | recursively flattened. Examples: |
|
1113 | recursively flattened. Examples: | |
1107 |
|
1114 | |||
1108 | >>> qw('1 2') |
|
1115 | >>> qw('1 2') | |
1109 | ['1', '2'] |
|
1116 | ['1', '2'] | |
1110 | >>> qw(['a b','1 2',['m n','p q']]) |
|
1117 | >>> qw(['a b','1 2',['m n','p q']]) | |
1111 | [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]] |
|
1118 | [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]] | |
1112 | >>> qw(['a b','1 2',['m n','p q']],flat=1) |
|
1119 | >>> qw(['a b','1 2',['m n','p q']],flat=1) | |
1113 | ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """ |
|
1120 | ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """ | |
1114 |
|
1121 | |||
1115 | if type(words) in StringTypes: |
|
1122 | if type(words) in StringTypes: | |
1116 | return [word.strip() for word in words.split(sep,maxsplit) |
|
1123 | return [word.strip() for word in words.split(sep,maxsplit) | |
1117 | if word and not word.isspace() ] |
|
1124 | if word and not word.isspace() ] | |
1118 | if flat: |
|
1125 | if flat: | |
1119 | return flatten(map(qw,words,[1]*len(words))) |
|
1126 | return flatten(map(qw,words,[1]*len(words))) | |
1120 | return map(qw,words) |
|
1127 | return map(qw,words) | |
1121 |
|
1128 | |||
1122 | #---------------------------------------------------------------------------- |
|
1129 | #---------------------------------------------------------------------------- | |
1123 | def qwflat(words,sep=None,maxsplit=-1): |
|
1130 | def qwflat(words,sep=None,maxsplit=-1): | |
1124 | """Calls qw(words) in flat mode. It's just a convenient shorthand.""" |
|
1131 | """Calls qw(words) in flat mode. It's just a convenient shorthand.""" | |
1125 | return qw(words,1,sep,maxsplit) |
|
1132 | return qw(words,1,sep,maxsplit) | |
1126 |
|
1133 | |||
1127 | #---------------------------------------------------------------------------- |
|
1134 | #---------------------------------------------------------------------------- | |
1128 | def qw_lol(indata): |
|
1135 | def qw_lol(indata): | |
1129 | """qw_lol('a b') -> [['a','b']], |
|
1136 | """qw_lol('a b') -> [['a','b']], | |
1130 | otherwise it's just a call to qw(). |
|
1137 | otherwise it's just a call to qw(). | |
1131 |
|
1138 | |||
1132 | We need this to make sure the modules_some keys *always* end up as a |
|
1139 | We need this to make sure the modules_some keys *always* end up as a | |
1133 | list of lists.""" |
|
1140 | list of lists.""" | |
1134 |
|
1141 | |||
1135 | if type(indata) in StringTypes: |
|
1142 | if type(indata) in StringTypes: | |
1136 | return [qw(indata)] |
|
1143 | return [qw(indata)] | |
1137 | else: |
|
1144 | else: | |
1138 | return qw(indata) |
|
1145 | return qw(indata) | |
1139 |
|
1146 | |||
1140 | #----------------------------------------------------------------------------- |
|
1147 | #----------------------------------------------------------------------------- | |
1141 | def list_strings(arg): |
|
1148 | def list_strings(arg): | |
1142 | """Always return a list of strings, given a string or list of strings |
|
1149 | """Always return a list of strings, given a string or list of strings | |
1143 | as input.""" |
|
1150 | as input.""" | |
1144 |
|
1151 | |||
1145 | if type(arg) in StringTypes: return [arg] |
|
1152 | if type(arg) in StringTypes: return [arg] | |
1146 | else: return arg |
|
1153 | else: return arg | |
1147 |
|
1154 | |||
1148 | #---------------------------------------------------------------------------- |
|
1155 | #---------------------------------------------------------------------------- | |
1149 | def grep(pat,list,case=1): |
|
1156 | def grep(pat,list,case=1): | |
1150 | """Simple minded grep-like function. |
|
1157 | """Simple minded grep-like function. | |
1151 | grep(pat,list) returns occurrences of pat in list, None on failure. |
|
1158 | grep(pat,list) returns occurrences of pat in list, None on failure. | |
1152 |
|
1159 | |||
1153 | It only does simple string matching, with no support for regexps. Use the |
|
1160 | It only does simple string matching, with no support for regexps. Use the | |
1154 | option case=0 for case-insensitive matching.""" |
|
1161 | option case=0 for case-insensitive matching.""" | |
1155 |
|
1162 | |||
1156 | # This is pretty crude. At least it should implement copying only references |
|
1163 | # This is pretty crude. At least it should implement copying only references | |
1157 | # to the original data in case it's big. Now it copies the data for output. |
|
1164 | # to the original data in case it's big. Now it copies the data for output. | |
1158 | out=[] |
|
1165 | out=[] | |
1159 | if case: |
|
1166 | if case: | |
1160 | for term in list: |
|
1167 | for term in list: | |
1161 | if term.find(pat)>-1: out.append(term) |
|
1168 | if term.find(pat)>-1: out.append(term) | |
1162 | else: |
|
1169 | else: | |
1163 | lpat=pat.lower() |
|
1170 | lpat=pat.lower() | |
1164 | for term in list: |
|
1171 | for term in list: | |
1165 | if term.lower().find(lpat)>-1: out.append(term) |
|
1172 | if term.lower().find(lpat)>-1: out.append(term) | |
1166 |
|
1173 | |||
1167 | if len(out): return out |
|
1174 | if len(out): return out | |
1168 | else: return None |
|
1175 | else: return None | |
1169 |
|
1176 | |||
1170 | #---------------------------------------------------------------------------- |
|
1177 | #---------------------------------------------------------------------------- | |
1171 | def dgrep(pat,*opts): |
|
1178 | def dgrep(pat,*opts): | |
1172 | """Return grep() on dir()+dir(__builtins__). |
|
1179 | """Return grep() on dir()+dir(__builtins__). | |
1173 |
|
1180 | |||
1174 | A very common use of grep() when working interactively.""" |
|
1181 | A very common use of grep() when working interactively.""" | |
1175 |
|
1182 | |||
1176 | return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts) |
|
1183 | return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts) | |
1177 |
|
1184 | |||
1178 | #---------------------------------------------------------------------------- |
|
1185 | #---------------------------------------------------------------------------- | |
1179 | def idgrep(pat): |
|
1186 | def idgrep(pat): | |
1180 | """Case-insensitive dgrep()""" |
|
1187 | """Case-insensitive dgrep()""" | |
1181 |
|
1188 | |||
1182 | return dgrep(pat,0) |
|
1189 | return dgrep(pat,0) | |
1183 |
|
1190 | |||
1184 | #---------------------------------------------------------------------------- |
|
1191 | #---------------------------------------------------------------------------- | |
1185 | def igrep(pat,list): |
|
1192 | def igrep(pat,list): | |
1186 | """Synonym for case-insensitive grep.""" |
|
1193 | """Synonym for case-insensitive grep.""" | |
1187 |
|
1194 | |||
1188 | return grep(pat,list,case=0) |
|
1195 | return grep(pat,list,case=0) | |
1189 |
|
1196 | |||
1190 | #---------------------------------------------------------------------------- |
|
1197 | #---------------------------------------------------------------------------- | |
1191 | def indent(str,nspaces=4,ntabs=0): |
|
1198 | def indent(str,nspaces=4,ntabs=0): | |
1192 | """Indent a string a given number of spaces or tabstops. |
|
1199 | """Indent a string a given number of spaces or tabstops. | |
1193 |
|
1200 | |||
1194 | indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces. |
|
1201 | indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces. | |
1195 | """ |
|
1202 | """ | |
1196 | if str is None: |
|
1203 | if str is None: | |
1197 | return |
|
1204 | return | |
1198 | ind = '\t'*ntabs+' '*nspaces |
|
1205 | ind = '\t'*ntabs+' '*nspaces | |
1199 | outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind)) |
|
1206 | outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind)) | |
1200 | if outstr.endswith(os.linesep+ind): |
|
1207 | if outstr.endswith(os.linesep+ind): | |
1201 | return outstr[:-len(ind)] |
|
1208 | return outstr[:-len(ind)] | |
1202 | else: |
|
1209 | else: | |
1203 | return outstr |
|
1210 | return outstr | |
1204 |
|
1211 | |||
1205 | #----------------------------------------------------------------------------- |
|
1212 | #----------------------------------------------------------------------------- | |
1206 | def native_line_ends(filename,backup=1): |
|
1213 | def native_line_ends(filename,backup=1): | |
1207 | """Convert (in-place) a file to line-ends native to the current OS. |
|
1214 | """Convert (in-place) a file to line-ends native to the current OS. | |
1208 |
|
1215 | |||
1209 | If the optional backup argument is given as false, no backup of the |
|
1216 | If the optional backup argument is given as false, no backup of the | |
1210 | original file is left. """ |
|
1217 | original file is left. """ | |
1211 |
|
1218 | |||
1212 | backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'} |
|
1219 | backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'} | |
1213 |
|
1220 | |||
1214 | bak_filename = filename + backup_suffixes[os.name] |
|
1221 | bak_filename = filename + backup_suffixes[os.name] | |
1215 |
|
1222 | |||
1216 | original = open(filename).read() |
|
1223 | original = open(filename).read() | |
1217 | shutil.copy2(filename,bak_filename) |
|
1224 | shutil.copy2(filename,bak_filename) | |
1218 | try: |
|
1225 | try: | |
1219 | new = open(filename,'wb') |
|
1226 | new = open(filename,'wb') | |
1220 | new.write(os.linesep.join(original.splitlines())) |
|
1227 | new.write(os.linesep.join(original.splitlines())) | |
1221 | new.write(os.linesep) # ALWAYS put an eol at the end of the file |
|
1228 | new.write(os.linesep) # ALWAYS put an eol at the end of the file | |
1222 | new.close() |
|
1229 | new.close() | |
1223 | except: |
|
1230 | except: | |
1224 | os.rename(bak_filename,filename) |
|
1231 | os.rename(bak_filename,filename) | |
1225 | if not backup: |
|
1232 | if not backup: | |
1226 | try: |
|
1233 | try: | |
1227 | os.remove(bak_filename) |
|
1234 | os.remove(bak_filename) | |
1228 | except: |
|
1235 | except: | |
1229 | pass |
|
1236 | pass | |
1230 |
|
1237 | |||
1231 | #---------------------------------------------------------------------------- |
|
1238 | #---------------------------------------------------------------------------- | |
1232 | def get_pager_cmd(pager_cmd = None): |
|
1239 | def get_pager_cmd(pager_cmd = None): | |
1233 | """Return a pager command. |
|
1240 | """Return a pager command. | |
1234 |
|
1241 | |||
1235 | Makes some attempts at finding an OS-correct one.""" |
|
1242 | Makes some attempts at finding an OS-correct one.""" | |
1236 |
|
1243 | |||
1237 | if os.name == 'posix': |
|
1244 | if os.name == 'posix': | |
1238 | default_pager_cmd = 'less -r' # -r for color control sequences |
|
1245 | default_pager_cmd = 'less -r' # -r for color control sequences | |
1239 | elif os.name in ['nt','dos']: |
|
1246 | elif os.name in ['nt','dos']: | |
1240 | default_pager_cmd = 'type' |
|
1247 | default_pager_cmd = 'type' | |
1241 |
|
1248 | |||
1242 | if pager_cmd is None: |
|
1249 | if pager_cmd is None: | |
1243 | try: |
|
1250 | try: | |
1244 | pager_cmd = os.environ['PAGER'] |
|
1251 | pager_cmd = os.environ['PAGER'] | |
1245 | except: |
|
1252 | except: | |
1246 | pager_cmd = default_pager_cmd |
|
1253 | pager_cmd = default_pager_cmd | |
1247 | return pager_cmd |
|
1254 | return pager_cmd | |
1248 |
|
1255 | |||
1249 | #----------------------------------------------------------------------------- |
|
1256 | #----------------------------------------------------------------------------- | |
1250 | def get_pager_start(pager,start): |
|
1257 | def get_pager_start(pager,start): | |
1251 | """Return the string for paging files with an offset. |
|
1258 | """Return the string for paging files with an offset. | |
1252 |
|
1259 | |||
1253 | This is the '+N' argument which less and more (under Unix) accept. |
|
1260 | This is the '+N' argument which less and more (under Unix) accept. | |
1254 | """ |
|
1261 | """ | |
1255 |
|
1262 | |||
1256 | if pager in ['less','more']: |
|
1263 | if pager in ['less','more']: | |
1257 | if start: |
|
1264 | if start: | |
1258 | start_string = '+' + str(start) |
|
1265 | start_string = '+' + str(start) | |
1259 | else: |
|
1266 | else: | |
1260 | start_string = '' |
|
1267 | start_string = '' | |
1261 | else: |
|
1268 | else: | |
1262 | start_string = '' |
|
1269 | start_string = '' | |
1263 | return start_string |
|
1270 | return start_string | |
1264 |
|
1271 | |||
1265 | #---------------------------------------------------------------------------- |
|
1272 | #---------------------------------------------------------------------------- | |
1266 | if os.name == "nt": |
|
1273 | if os.name == "nt": | |
1267 | import msvcrt |
|
1274 | import msvcrt | |
1268 | def page_more(): |
|
1275 | def page_more(): | |
1269 | """ Smart pausing between pages |
|
1276 | """ Smart pausing between pages | |
1270 |
|
1277 | |||
1271 | @return: True if need print more lines, False if quit |
|
1278 | @return: True if need print more lines, False if quit | |
1272 | """ |
|
1279 | """ | |
1273 | Term.cout.write('---Return to continue, q to quit--- ') |
|
1280 | Term.cout.write('---Return to continue, q to quit--- ') | |
1274 | ans = msvcrt.getch() |
|
1281 | ans = msvcrt.getch() | |
1275 | if ans in ("q", "Q"): |
|
1282 | if ans in ("q", "Q"): | |
1276 | result = False |
|
1283 | result = False | |
1277 | else: |
|
1284 | else: | |
1278 | result = True |
|
1285 | result = True | |
1279 | Term.cout.write("\b"*37 + " "*37 + "\b"*37) |
|
1286 | Term.cout.write("\b"*37 + " "*37 + "\b"*37) | |
1280 | return result |
|
1287 | return result | |
1281 | else: |
|
1288 | else: | |
1282 | def page_more(): |
|
1289 | def page_more(): | |
1283 | ans = raw_input('---Return to continue, q to quit--- ') |
|
1290 | ans = raw_input('---Return to continue, q to quit--- ') | |
1284 | if ans.lower().startswith('q'): |
|
1291 | if ans.lower().startswith('q'): | |
1285 | return False |
|
1292 | return False | |
1286 | else: |
|
1293 | else: | |
1287 | return True |
|
1294 | return True | |
1288 |
|
1295 | |||
1289 | esc_re = re.compile(r"(\x1b[^m]+m)") |
|
1296 | esc_re = re.compile(r"(\x1b[^m]+m)") | |
1290 |
|
1297 | |||
1291 | def page_dumb(strng,start=0,screen_lines=25): |
|
1298 | def page_dumb(strng,start=0,screen_lines=25): | |
1292 | """Very dumb 'pager' in Python, for when nothing else works. |
|
1299 | """Very dumb 'pager' in Python, for when nothing else works. | |
1293 |
|
1300 | |||
1294 | Only moves forward, same interface as page(), except for pager_cmd and |
|
1301 | Only moves forward, same interface as page(), except for pager_cmd and | |
1295 | mode.""" |
|
1302 | mode.""" | |
1296 |
|
1303 | |||
1297 | out_ln = strng.splitlines()[start:] |
|
1304 | out_ln = strng.splitlines()[start:] | |
1298 | screens = chop(out_ln,screen_lines-1) |
|
1305 | screens = chop(out_ln,screen_lines-1) | |
1299 | if len(screens) == 1: |
|
1306 | if len(screens) == 1: | |
1300 | print >>Term.cout, os.linesep.join(screens[0]) |
|
1307 | print >>Term.cout, os.linesep.join(screens[0]) | |
1301 | else: |
|
1308 | else: | |
1302 | last_escape = "" |
|
1309 | last_escape = "" | |
1303 | for scr in screens[0:-1]: |
|
1310 | for scr in screens[0:-1]: | |
1304 | hunk = os.linesep.join(scr) |
|
1311 | hunk = os.linesep.join(scr) | |
1305 | print >>Term.cout, last_escape + hunk |
|
1312 | print >>Term.cout, last_escape + hunk | |
1306 | if not page_more(): |
|
1313 | if not page_more(): | |
1307 | return |
|
1314 | return | |
1308 | esc_list = esc_re.findall(hunk) |
|
1315 | esc_list = esc_re.findall(hunk) | |
1309 | if len(esc_list) > 0: |
|
1316 | if len(esc_list) > 0: | |
1310 | last_escape = esc_list[-1] |
|
1317 | last_escape = esc_list[-1] | |
1311 | print >>Term.cout, last_escape + os.linesep.join(screens[-1]) |
|
1318 | print >>Term.cout, last_escape + os.linesep.join(screens[-1]) | |
1312 |
|
1319 | |||
1313 | #---------------------------------------------------------------------------- |
|
1320 | #---------------------------------------------------------------------------- | |
1314 | def page(strng,start=0,screen_lines=0,pager_cmd = None): |
|
1321 | def page(strng,start=0,screen_lines=0,pager_cmd = None): | |
1315 | """Print a string, piping through a pager after a certain length. |
|
1322 | """Print a string, piping through a pager after a certain length. | |
1316 |
|
1323 | |||
1317 | The screen_lines parameter specifies the number of *usable* lines of your |
|
1324 | The screen_lines parameter specifies the number of *usable* lines of your | |
1318 | terminal screen (total lines minus lines you need to reserve to show other |
|
1325 | terminal screen (total lines minus lines you need to reserve to show other | |
1319 | information). |
|
1326 | information). | |
1320 |
|
1327 | |||
1321 | If you set screen_lines to a number <=0, page() will try to auto-determine |
|
1328 | If you set screen_lines to a number <=0, page() will try to auto-determine | |
1322 | your screen size and will only use up to (screen_size+screen_lines) for |
|
1329 | your screen size and will only use up to (screen_size+screen_lines) for | |
1323 | printing, paging after that. That is, if you want auto-detection but need |
|
1330 | printing, paging after that. That is, if you want auto-detection but need | |
1324 | to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for |
|
1331 | to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for | |
1325 | auto-detection without any lines reserved simply use screen_lines = 0. |
|
1332 | auto-detection without any lines reserved simply use screen_lines = 0. | |
1326 |
|
1333 | |||
1327 | If a string won't fit in the allowed lines, it is sent through the |
|
1334 | If a string won't fit in the allowed lines, it is sent through the | |
1328 | specified pager command. If none given, look for PAGER in the environment, |
|
1335 | specified pager command. If none given, look for PAGER in the environment, | |
1329 | and ultimately default to less. |
|
1336 | and ultimately default to less. | |
1330 |
|
1337 | |||
1331 | If no system pager works, the string is sent through a 'dumb pager' |
|
1338 | If no system pager works, the string is sent through a 'dumb pager' | |
1332 | written in python, very simplistic. |
|
1339 | written in python, very simplistic. | |
1333 | """ |
|
1340 | """ | |
1334 |
|
1341 | |||
1335 | # Ugly kludge, but calling curses.initscr() flat out crashes in emacs |
|
1342 | # Ugly kludge, but calling curses.initscr() flat out crashes in emacs | |
1336 | TERM = os.environ.get('TERM','dumb') |
|
1343 | TERM = os.environ.get('TERM','dumb') | |
1337 | if TERM in ['dumb','emacs'] and os.name != 'nt': |
|
1344 | if TERM in ['dumb','emacs'] and os.name != 'nt': | |
1338 | print strng |
|
1345 | print strng | |
1339 | return |
|
1346 | return | |
1340 | # chop off the topmost part of the string we don't want to see |
|
1347 | # chop off the topmost part of the string we don't want to see | |
1341 | str_lines = strng.split(os.linesep)[start:] |
|
1348 | str_lines = strng.split(os.linesep)[start:] | |
1342 | str_toprint = os.linesep.join(str_lines) |
|
1349 | str_toprint = os.linesep.join(str_lines) | |
1343 | num_newlines = len(str_lines) |
|
1350 | num_newlines = len(str_lines) | |
1344 | len_str = len(str_toprint) |
|
1351 | len_str = len(str_toprint) | |
1345 |
|
1352 | |||
1346 | # Dumb heuristics to guesstimate number of on-screen lines the string |
|
1353 | # Dumb heuristics to guesstimate number of on-screen lines the string | |
1347 | # takes. Very basic, but good enough for docstrings in reasonable |
|
1354 | # takes. Very basic, but good enough for docstrings in reasonable | |
1348 | # terminals. If someone later feels like refining it, it's not hard. |
|
1355 | # terminals. If someone later feels like refining it, it's not hard. | |
1349 | numlines = max(num_newlines,int(len_str/80)+1) |
|
1356 | numlines = max(num_newlines,int(len_str/80)+1) | |
1350 |
|
1357 | |||
1351 | if os.name == "nt": |
|
1358 | if os.name == "nt": | |
1352 | screen_lines_def = get_console_size(defaulty=25)[1] |
|
1359 | screen_lines_def = get_console_size(defaulty=25)[1] | |
1353 | else: |
|
1360 | else: | |
1354 | screen_lines_def = 25 # default value if we can't auto-determine |
|
1361 | screen_lines_def = 25 # default value if we can't auto-determine | |
1355 |
|
1362 | |||
1356 | # auto-determine screen size |
|
1363 | # auto-determine screen size | |
1357 | if screen_lines <= 0: |
|
1364 | if screen_lines <= 0: | |
1358 | if TERM=='xterm': |
|
1365 | if TERM=='xterm': | |
1359 | try: |
|
1366 | try: | |
1360 | import curses |
|
1367 | import curses | |
1361 | if hasattr(curses,'initscr'): |
|
1368 | if hasattr(curses,'initscr'): | |
1362 | use_curses = 1 |
|
1369 | use_curses = 1 | |
1363 | else: |
|
1370 | else: | |
1364 | use_curses = 0 |
|
1371 | use_curses = 0 | |
1365 | except ImportError: |
|
1372 | except ImportError: | |
1366 | use_curses = 0 |
|
1373 | use_curses = 0 | |
1367 | else: |
|
1374 | else: | |
1368 | # curses causes problems on many terminals other than xterm. |
|
1375 | # curses causes problems on many terminals other than xterm. | |
1369 | use_curses = 0 |
|
1376 | use_curses = 0 | |
1370 | if use_curses: |
|
1377 | if use_curses: | |
1371 | scr = curses.initscr() |
|
1378 | scr = curses.initscr() | |
1372 | screen_lines_real,screen_cols = scr.getmaxyx() |
|
1379 | screen_lines_real,screen_cols = scr.getmaxyx() | |
1373 | curses.endwin() |
|
1380 | curses.endwin() | |
1374 | screen_lines += screen_lines_real |
|
1381 | screen_lines += screen_lines_real | |
1375 | #print '***Screen size:',screen_lines_real,'lines x',\ |
|
1382 | #print '***Screen size:',screen_lines_real,'lines x',\ | |
1376 | #screen_cols,'columns.' # dbg |
|
1383 | #screen_cols,'columns.' # dbg | |
1377 | else: |
|
1384 | else: | |
1378 | screen_lines += screen_lines_def |
|
1385 | screen_lines += screen_lines_def | |
1379 |
|
1386 | |||
1380 | #print 'numlines',numlines,'screenlines',screen_lines # dbg |
|
1387 | #print 'numlines',numlines,'screenlines',screen_lines # dbg | |
1381 | if numlines <= screen_lines : |
|
1388 | if numlines <= screen_lines : | |
1382 | #print '*** normal print' # dbg |
|
1389 | #print '*** normal print' # dbg | |
1383 | print >>Term.cout, str_toprint |
|
1390 | print >>Term.cout, str_toprint | |
1384 | else: |
|
1391 | else: | |
1385 | # Try to open pager and default to internal one if that fails. |
|
1392 | # Try to open pager and default to internal one if that fails. | |
1386 | # All failure modes are tagged as 'retval=1', to match the return |
|
1393 | # All failure modes are tagged as 'retval=1', to match the return | |
1387 | # value of a failed system command. If any intermediate attempt |
|
1394 | # value of a failed system command. If any intermediate attempt | |
1388 | # sets retval to 1, at the end we resort to our own page_dumb() pager. |
|
1395 | # sets retval to 1, at the end we resort to our own page_dumb() pager. | |
1389 | pager_cmd = get_pager_cmd(pager_cmd) |
|
1396 | pager_cmd = get_pager_cmd(pager_cmd) | |
1390 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) |
|
1397 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) | |
1391 | if os.name == 'nt': |
|
1398 | if os.name == 'nt': | |
1392 | if pager_cmd.startswith('type'): |
|
1399 | if pager_cmd.startswith('type'): | |
1393 | # The default WinXP 'type' command is failing on complex strings. |
|
1400 | # The default WinXP 'type' command is failing on complex strings. | |
1394 | retval = 1 |
|
1401 | retval = 1 | |
1395 | else: |
|
1402 | else: | |
1396 | tmpname = tempfile.mktemp('.txt') |
|
1403 | tmpname = tempfile.mktemp('.txt') | |
1397 | tmpfile = file(tmpname,'wt') |
|
1404 | tmpfile = file(tmpname,'wt') | |
1398 | tmpfile.write(strng) |
|
1405 | tmpfile.write(strng) | |
1399 | tmpfile.close() |
|
1406 | tmpfile.close() | |
1400 | cmd = "%s < %s" % (pager_cmd,tmpname) |
|
1407 | cmd = "%s < %s" % (pager_cmd,tmpname) | |
1401 | if os.system(cmd): |
|
1408 | if os.system(cmd): | |
1402 | retval = 1 |
|
1409 | retval = 1 | |
1403 | else: |
|
1410 | else: | |
1404 | retval = None |
|
1411 | retval = None | |
1405 | os.remove(tmpname) |
|
1412 | os.remove(tmpname) | |
1406 | else: |
|
1413 | else: | |
1407 | try: |
|
1414 | try: | |
1408 | retval = None |
|
1415 | retval = None | |
1409 | # if I use popen4, things hang. No idea why. |
|
1416 | # if I use popen4, things hang. No idea why. | |
1410 | #pager,shell_out = os.popen4(pager_cmd) |
|
1417 | #pager,shell_out = os.popen4(pager_cmd) | |
1411 | pager = os.popen(pager_cmd,'w') |
|
1418 | pager = os.popen(pager_cmd,'w') | |
1412 | pager.write(strng) |
|
1419 | pager.write(strng) | |
1413 | pager.close() |
|
1420 | pager.close() | |
1414 | retval = pager.close() # success returns None |
|
1421 | retval = pager.close() # success returns None | |
1415 | except IOError,msg: # broken pipe when user quits |
|
1422 | except IOError,msg: # broken pipe when user quits | |
1416 | if msg.args == (32,'Broken pipe'): |
|
1423 | if msg.args == (32,'Broken pipe'): | |
1417 | retval = None |
|
1424 | retval = None | |
1418 | else: |
|
1425 | else: | |
1419 | retval = 1 |
|
1426 | retval = 1 | |
1420 | except OSError: |
|
1427 | except OSError: | |
1421 | # Other strange problems, sometimes seen in Win2k/cygwin |
|
1428 | # Other strange problems, sometimes seen in Win2k/cygwin | |
1422 | retval = 1 |
|
1429 | retval = 1 | |
1423 | if retval is not None: |
|
1430 | if retval is not None: | |
1424 | page_dumb(strng,screen_lines=screen_lines) |
|
1431 | page_dumb(strng,screen_lines=screen_lines) | |
1425 |
|
1432 | |||
1426 | #---------------------------------------------------------------------------- |
|
1433 | #---------------------------------------------------------------------------- | |
1427 | def page_file(fname,start = 0, pager_cmd = None): |
|
1434 | def page_file(fname,start = 0, pager_cmd = None): | |
1428 | """Page a file, using an optional pager command and starting line. |
|
1435 | """Page a file, using an optional pager command and starting line. | |
1429 | """ |
|
1436 | """ | |
1430 |
|
1437 | |||
1431 | pager_cmd = get_pager_cmd(pager_cmd) |
|
1438 | pager_cmd = get_pager_cmd(pager_cmd) | |
1432 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) |
|
1439 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) | |
1433 |
|
1440 | |||
1434 | try: |
|
1441 | try: | |
1435 | if os.environ['TERM'] in ['emacs','dumb']: |
|
1442 | if os.environ['TERM'] in ['emacs','dumb']: | |
1436 | raise EnvironmentError |
|
1443 | raise EnvironmentError | |
1437 | xsys(pager_cmd + ' ' + fname) |
|
1444 | xsys(pager_cmd + ' ' + fname) | |
1438 | except: |
|
1445 | except: | |
1439 | try: |
|
1446 | try: | |
1440 | if start > 0: |
|
1447 | if start > 0: | |
1441 | start -= 1 |
|
1448 | start -= 1 | |
1442 | page(open(fname).read(),start) |
|
1449 | page(open(fname).read(),start) | |
1443 | except: |
|
1450 | except: | |
1444 | print 'Unable to show file',`fname` |
|
1451 | print 'Unable to show file',`fname` | |
1445 |
|
1452 | |||
1446 | #---------------------------------------------------------------------------- |
|
1453 | #---------------------------------------------------------------------------- | |
1447 | def snip_print(str,width = 75,print_full = 0,header = ''): |
|
1454 | def snip_print(str,width = 75,print_full = 0,header = ''): | |
1448 | """Print a string snipping the midsection to fit in width. |
|
1455 | """Print a string snipping the midsection to fit in width. | |
1449 |
|
1456 | |||
1450 | print_full: mode control: |
|
1457 | print_full: mode control: | |
1451 | - 0: only snip long strings |
|
1458 | - 0: only snip long strings | |
1452 | - 1: send to page() directly. |
|
1459 | - 1: send to page() directly. | |
1453 | - 2: snip long strings and ask for full length viewing with page() |
|
1460 | - 2: snip long strings and ask for full length viewing with page() | |
1454 | Return 1 if snipping was necessary, 0 otherwise.""" |
|
1461 | Return 1 if snipping was necessary, 0 otherwise.""" | |
1455 |
|
1462 | |||
1456 | if print_full == 1: |
|
1463 | if print_full == 1: | |
1457 | page(header+str) |
|
1464 | page(header+str) | |
1458 | return 0 |
|
1465 | return 0 | |
1459 |
|
1466 | |||
1460 | print header, |
|
1467 | print header, | |
1461 | if len(str) < width: |
|
1468 | if len(str) < width: | |
1462 | print str |
|
1469 | print str | |
1463 | snip = 0 |
|
1470 | snip = 0 | |
1464 | else: |
|
1471 | else: | |
1465 | whalf = int((width -5)/2) |
|
1472 | whalf = int((width -5)/2) | |
1466 | print str[:whalf] + ' <...> ' + str[-whalf:] |
|
1473 | print str[:whalf] + ' <...> ' + str[-whalf:] | |
1467 | snip = 1 |
|
1474 | snip = 1 | |
1468 | if snip and print_full == 2: |
|
1475 | if snip and print_full == 2: | |
1469 | if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y': |
|
1476 | if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y': | |
1470 | page(str) |
|
1477 | page(str) | |
1471 | return snip |
|
1478 | return snip | |
1472 |
|
1479 | |||
1473 | #**************************************************************************** |
|
1480 | #**************************************************************************** | |
1474 | # lists, dicts and structures |
|
1481 | # lists, dicts and structures | |
1475 |
|
1482 | |||
1476 | def belong(candidates,checklist): |
|
1483 | def belong(candidates,checklist): | |
1477 | """Check whether a list of items appear in a given list of options. |
|
1484 | """Check whether a list of items appear in a given list of options. | |
1478 |
|
1485 | |||
1479 | Returns a list of 1 and 0, one for each candidate given.""" |
|
1486 | Returns a list of 1 and 0, one for each candidate given.""" | |
1480 |
|
1487 | |||
1481 | return [x in checklist for x in candidates] |
|
1488 | return [x in checklist for x in candidates] | |
1482 |
|
1489 | |||
1483 | #---------------------------------------------------------------------------- |
|
1490 | #---------------------------------------------------------------------------- | |
1484 | def uniq_stable(elems): |
|
1491 | def uniq_stable(elems): | |
1485 | """uniq_stable(elems) -> list |
|
1492 | """uniq_stable(elems) -> list | |
1486 |
|
1493 | |||
1487 | Return from an iterable, a list of all the unique elements in the input, |
|
1494 | Return from an iterable, a list of all the unique elements in the input, | |
1488 | but maintaining the order in which they first appear. |
|
1495 | but maintaining the order in which they first appear. | |
1489 |
|
1496 | |||
1490 | A naive solution to this problem which just makes a dictionary with the |
|
1497 | A naive solution to this problem which just makes a dictionary with the | |
1491 | elements as keys fails to respect the stability condition, since |
|
1498 | elements as keys fails to respect the stability condition, since | |
1492 | dictionaries are unsorted by nature. |
|
1499 | dictionaries are unsorted by nature. | |
1493 |
|
1500 | |||
1494 | Note: All elements in the input must be valid dictionary keys for this |
|
1501 | Note: All elements in the input must be valid dictionary keys for this | |
1495 | routine to work, as it internally uses a dictionary for efficiency |
|
1502 | routine to work, as it internally uses a dictionary for efficiency | |
1496 | reasons.""" |
|
1503 | reasons.""" | |
1497 |
|
1504 | |||
1498 | unique = [] |
|
1505 | unique = [] | |
1499 | unique_dict = {} |
|
1506 | unique_dict = {} | |
1500 | for nn in elems: |
|
1507 | for nn in elems: | |
1501 | if nn not in unique_dict: |
|
1508 | if nn not in unique_dict: | |
1502 | unique.append(nn) |
|
1509 | unique.append(nn) | |
1503 | unique_dict[nn] = None |
|
1510 | unique_dict[nn] = None | |
1504 | return unique |
|
1511 | return unique | |
1505 |
|
1512 | |||
1506 | #---------------------------------------------------------------------------- |
|
1513 | #---------------------------------------------------------------------------- | |
1507 | class NLprinter: |
|
1514 | class NLprinter: | |
1508 | """Print an arbitrarily nested list, indicating index numbers. |
|
1515 | """Print an arbitrarily nested list, indicating index numbers. | |
1509 |
|
1516 | |||
1510 | An instance of this class called nlprint is available and callable as a |
|
1517 | An instance of this class called nlprint is available and callable as a | |
1511 | function. |
|
1518 | function. | |
1512 |
|
1519 | |||
1513 | nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent' |
|
1520 | nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent' | |
1514 | and using 'sep' to separate the index from the value. """ |
|
1521 | and using 'sep' to separate the index from the value. """ | |
1515 |
|
1522 | |||
1516 | def __init__(self): |
|
1523 | def __init__(self): | |
1517 | self.depth = 0 |
|
1524 | self.depth = 0 | |
1518 |
|
1525 | |||
1519 | def __call__(self,lst,pos='',**kw): |
|
1526 | def __call__(self,lst,pos='',**kw): | |
1520 | """Prints the nested list numbering levels.""" |
|
1527 | """Prints the nested list numbering levels.""" | |
1521 | kw.setdefault('indent',' ') |
|
1528 | kw.setdefault('indent',' ') | |
1522 | kw.setdefault('sep',': ') |
|
1529 | kw.setdefault('sep',': ') | |
1523 | kw.setdefault('start',0) |
|
1530 | kw.setdefault('start',0) | |
1524 | kw.setdefault('stop',len(lst)) |
|
1531 | kw.setdefault('stop',len(lst)) | |
1525 | # we need to remove start and stop from kw so they don't propagate |
|
1532 | # we need to remove start and stop from kw so they don't propagate | |
1526 | # into a recursive call for a nested list. |
|
1533 | # into a recursive call for a nested list. | |
1527 | start = kw['start']; del kw['start'] |
|
1534 | start = kw['start']; del kw['start'] | |
1528 | stop = kw['stop']; del kw['stop'] |
|
1535 | stop = kw['stop']; del kw['stop'] | |
1529 | if self.depth == 0 and 'header' in kw.keys(): |
|
1536 | if self.depth == 0 and 'header' in kw.keys(): | |
1530 | print kw['header'] |
|
1537 | print kw['header'] | |
1531 |
|
1538 | |||
1532 | for idx in range(start,stop): |
|
1539 | for idx in range(start,stop): | |
1533 | elem = lst[idx] |
|
1540 | elem = lst[idx] | |
1534 | if type(elem)==type([]): |
|
1541 | if type(elem)==type([]): | |
1535 | self.depth += 1 |
|
1542 | self.depth += 1 | |
1536 | self.__call__(elem,itpl('$pos$idx,'),**kw) |
|
1543 | self.__call__(elem,itpl('$pos$idx,'),**kw) | |
1537 | self.depth -= 1 |
|
1544 | self.depth -= 1 | |
1538 | else: |
|
1545 | else: | |
1539 | printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem') |
|
1546 | printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem') | |
1540 |
|
1547 | |||
1541 | nlprint = NLprinter() |
|
1548 | nlprint = NLprinter() | |
1542 | #---------------------------------------------------------------------------- |
|
1549 | #---------------------------------------------------------------------------- | |
1543 | def all_belong(candidates,checklist): |
|
1550 | def all_belong(candidates,checklist): | |
1544 | """Check whether a list of items ALL appear in a given list of options. |
|
1551 | """Check whether a list of items ALL appear in a given list of options. | |
1545 |
|
1552 | |||
1546 | Returns a single 1 or 0 value.""" |
|
1553 | Returns a single 1 or 0 value.""" | |
1547 |
|
1554 | |||
1548 | return 1-(0 in [x in checklist for x in candidates]) |
|
1555 | return 1-(0 in [x in checklist for x in candidates]) | |
1549 |
|
1556 | |||
1550 | #---------------------------------------------------------------------------- |
|
1557 | #---------------------------------------------------------------------------- | |
1551 | def sort_compare(lst1,lst2,inplace = 1): |
|
1558 | def sort_compare(lst1,lst2,inplace = 1): | |
1552 | """Sort and compare two lists. |
|
1559 | """Sort and compare two lists. | |
1553 |
|
1560 | |||
1554 | By default it does it in place, thus modifying the lists. Use inplace = 0 |
|
1561 | By default it does it in place, thus modifying the lists. Use inplace = 0 | |
1555 | to avoid that (at the cost of temporary copy creation).""" |
|
1562 | to avoid that (at the cost of temporary copy creation).""" | |
1556 | if not inplace: |
|
1563 | if not inplace: | |
1557 | lst1 = lst1[:] |
|
1564 | lst1 = lst1[:] | |
1558 | lst2 = lst2[:] |
|
1565 | lst2 = lst2[:] | |
1559 | lst1.sort(); lst2.sort() |
|
1566 | lst1.sort(); lst2.sort() | |
1560 | return lst1 == lst2 |
|
1567 | return lst1 == lst2 | |
1561 |
|
1568 | |||
1562 | #---------------------------------------------------------------------------- |
|
1569 | #---------------------------------------------------------------------------- | |
1563 | def mkdict(**kwargs): |
|
1570 | def mkdict(**kwargs): | |
1564 | """Return a dict from a keyword list. |
|
1571 | """Return a dict from a keyword list. | |
1565 |
|
1572 | |||
1566 | It's just syntactic sugar for making ditcionary creation more convenient: |
|
1573 | It's just syntactic sugar for making ditcionary creation more convenient: | |
1567 | # the standard way |
|
1574 | # the standard way | |
1568 | >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 } |
|
1575 | >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 } | |
1569 | # a cleaner way |
|
1576 | # a cleaner way | |
1570 | >>>data = dict(red=1, green=2, blue=3) |
|
1577 | >>>data = dict(red=1, green=2, blue=3) | |
1571 |
|
1578 | |||
1572 | If you need more than this, look at the Struct() class.""" |
|
1579 | If you need more than this, look at the Struct() class.""" | |
1573 |
|
1580 | |||
1574 | return kwargs |
|
1581 | return kwargs | |
1575 |
|
1582 | |||
1576 | #---------------------------------------------------------------------------- |
|
1583 | #---------------------------------------------------------------------------- | |
1577 | def list2dict(lst): |
|
1584 | def list2dict(lst): | |
1578 | """Takes a list of (key,value) pairs and turns it into a dict.""" |
|
1585 | """Takes a list of (key,value) pairs and turns it into a dict.""" | |
1579 |
|
1586 | |||
1580 | dic = {} |
|
1587 | dic = {} | |
1581 | for k,v in lst: dic[k] = v |
|
1588 | for k,v in lst: dic[k] = v | |
1582 | return dic |
|
1589 | return dic | |
1583 |
|
1590 | |||
1584 | #---------------------------------------------------------------------------- |
|
1591 | #---------------------------------------------------------------------------- | |
1585 | def list2dict2(lst,default=''): |
|
1592 | def list2dict2(lst,default=''): | |
1586 | """Takes a list and turns it into a dict. |
|
1593 | """Takes a list and turns it into a dict. | |
1587 | Much slower than list2dict, but more versatile. This version can take |
|
1594 | Much slower than list2dict, but more versatile. This version can take | |
1588 | lists with sublists of arbitrary length (including sclars).""" |
|
1595 | lists with sublists of arbitrary length (including sclars).""" | |
1589 |
|
1596 | |||
1590 | dic = {} |
|
1597 | dic = {} | |
1591 | for elem in lst: |
|
1598 | for elem in lst: | |
1592 | if type(elem) in (types.ListType,types.TupleType): |
|
1599 | if type(elem) in (types.ListType,types.TupleType): | |
1593 | size = len(elem) |
|
1600 | size = len(elem) | |
1594 | if size == 0: |
|
1601 | if size == 0: | |
1595 | pass |
|
1602 | pass | |
1596 | elif size == 1: |
|
1603 | elif size == 1: | |
1597 | dic[elem] = default |
|
1604 | dic[elem] = default | |
1598 | else: |
|
1605 | else: | |
1599 | k,v = elem[0], elem[1:] |
|
1606 | k,v = elem[0], elem[1:] | |
1600 | if len(v) == 1: v = v[0] |
|
1607 | if len(v) == 1: v = v[0] | |
1601 | dic[k] = v |
|
1608 | dic[k] = v | |
1602 | else: |
|
1609 | else: | |
1603 | dic[elem] = default |
|
1610 | dic[elem] = default | |
1604 | return dic |
|
1611 | return dic | |
1605 |
|
1612 | |||
1606 | #---------------------------------------------------------------------------- |
|
1613 | #---------------------------------------------------------------------------- | |
1607 | def flatten(seq): |
|
1614 | def flatten(seq): | |
1608 | """Flatten a list of lists (NOT recursive, only works for 2d lists).""" |
|
1615 | """Flatten a list of lists (NOT recursive, only works for 2d lists).""" | |
1609 |
|
1616 | |||
1610 | # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in). |
|
1617 | # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in). | |
1611 |
|
1618 | |||
1612 | # if the x=0 isn't made, a *global* variable x is left over after calling |
|
1619 | # if the x=0 isn't made, a *global* variable x is left over after calling | |
1613 | # this function, with the value of the last element in the return |
|
1620 | # this function, with the value of the last element in the return | |
1614 | # list. This does seem like a bug big time to me. |
|
1621 | # list. This does seem like a bug big time to me. | |
1615 |
|
1622 | |||
1616 | # the problem is fixed with the x=0, which seems to force the creation of |
|
1623 | # the problem is fixed with the x=0, which seems to force the creation of | |
1617 | # a local name |
|
1624 | # a local name | |
1618 |
|
1625 | |||
1619 | x = 0 |
|
1626 | x = 0 | |
1620 | return [x for subseq in seq for x in subseq] |
|
1627 | return [x for subseq in seq for x in subseq] | |
1621 |
|
1628 | |||
1622 | #---------------------------------------------------------------------------- |
|
1629 | #---------------------------------------------------------------------------- | |
1623 | def get_slice(seq,start=0,stop=None,step=1): |
|
1630 | def get_slice(seq,start=0,stop=None,step=1): | |
1624 | """Get a slice of a sequence with variable step. Specify start,stop,step.""" |
|
1631 | """Get a slice of a sequence with variable step. Specify start,stop,step.""" | |
1625 | if stop == None: |
|
1632 | if stop == None: | |
1626 | stop = len(seq) |
|
1633 | stop = len(seq) | |
1627 | item = lambda i: seq[i] |
|
1634 | item = lambda i: seq[i] | |
1628 | return map(item,xrange(start,stop,step)) |
|
1635 | return map(item,xrange(start,stop,step)) | |
1629 |
|
1636 | |||
1630 | #---------------------------------------------------------------------------- |
|
1637 | #---------------------------------------------------------------------------- | |
1631 | def chop(seq,size): |
|
1638 | def chop(seq,size): | |
1632 | """Chop a sequence into chunks of the given size.""" |
|
1639 | """Chop a sequence into chunks of the given size.""" | |
1633 | chunk = lambda i: seq[i:i+size] |
|
1640 | chunk = lambda i: seq[i:i+size] | |
1634 | return map(chunk,xrange(0,len(seq),size)) |
|
1641 | return map(chunk,xrange(0,len(seq),size)) | |
1635 |
|
1642 | |||
1636 | #---------------------------------------------------------------------------- |
|
1643 | #---------------------------------------------------------------------------- | |
1637 | def with(object, **args): |
|
1644 | def with(object, **args): | |
1638 | """Set multiple attributes for an object, similar to Pascal's with. |
|
1645 | """Set multiple attributes for an object, similar to Pascal's with. | |
1639 |
|
1646 | |||
1640 | Example: |
|
1647 | Example: | |
1641 | with(jim, |
|
1648 | with(jim, | |
1642 | born = 1960, |
|
1649 | born = 1960, | |
1643 | haircolour = 'Brown', |
|
1650 | haircolour = 'Brown', | |
1644 | eyecolour = 'Green') |
|
1651 | eyecolour = 'Green') | |
1645 |
|
1652 | |||
1646 | Credit: Greg Ewing, in |
|
1653 | Credit: Greg Ewing, in | |
1647 | http://mail.python.org/pipermail/python-list/2001-May/040703.html""" |
|
1654 | http://mail.python.org/pipermail/python-list/2001-May/040703.html""" | |
1648 |
|
1655 | |||
1649 | object.__dict__.update(args) |
|
1656 | object.__dict__.update(args) | |
1650 |
|
1657 | |||
1651 | #---------------------------------------------------------------------------- |
|
1658 | #---------------------------------------------------------------------------- | |
1652 | def setattr_list(obj,alist,nspace = None): |
|
1659 | def setattr_list(obj,alist,nspace = None): | |
1653 | """Set a list of attributes for an object taken from a namespace. |
|
1660 | """Set a list of attributes for an object taken from a namespace. | |
1654 |
|
1661 | |||
1655 | setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in |
|
1662 | setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in | |
1656 | alist with their values taken from nspace, which must be a dict (something |
|
1663 | alist with their values taken from nspace, which must be a dict (something | |
1657 | like locals() will often do) If nspace isn't given, locals() of the |
|
1664 | like locals() will often do) If nspace isn't given, locals() of the | |
1658 | *caller* is used, so in most cases you can omit it. |
|
1665 | *caller* is used, so in most cases you can omit it. | |
1659 |
|
1666 | |||
1660 | Note that alist can be given as a string, which will be automatically |
|
1667 | Note that alist can be given as a string, which will be automatically | |
1661 | split into a list on whitespace. If given as a list, it must be a list of |
|
1668 | split into a list on whitespace. If given as a list, it must be a list of | |
1662 | *strings* (the variable names themselves), not of variables.""" |
|
1669 | *strings* (the variable names themselves), not of variables.""" | |
1663 |
|
1670 | |||
1664 | # this grabs the local variables from the *previous* call frame -- that is |
|
1671 | # this grabs the local variables from the *previous* call frame -- that is | |
1665 | # the locals from the function that called setattr_list(). |
|
1672 | # the locals from the function that called setattr_list(). | |
1666 | # - snipped from weave.inline() |
|
1673 | # - snipped from weave.inline() | |
1667 | if nspace is None: |
|
1674 | if nspace is None: | |
1668 | call_frame = sys._getframe().f_back |
|
1675 | call_frame = sys._getframe().f_back | |
1669 | nspace = call_frame.f_locals |
|
1676 | nspace = call_frame.f_locals | |
1670 |
|
1677 | |||
1671 | if type(alist) in StringTypes: |
|
1678 | if type(alist) in StringTypes: | |
1672 | alist = alist.split() |
|
1679 | alist = alist.split() | |
1673 | for attr in alist: |
|
1680 | for attr in alist: | |
1674 | val = eval(attr,nspace) |
|
1681 | val = eval(attr,nspace) | |
1675 | setattr(obj,attr,val) |
|
1682 | setattr(obj,attr,val) | |
1676 |
|
1683 | |||
1677 | #---------------------------------------------------------------------------- |
|
1684 | #---------------------------------------------------------------------------- | |
1678 | def getattr_list(obj,alist,*args): |
|
1685 | def getattr_list(obj,alist,*args): | |
1679 | """getattr_list(obj,alist[, default]) -> attribute list. |
|
1686 | """getattr_list(obj,alist[, default]) -> attribute list. | |
1680 |
|
1687 | |||
1681 | Get a list of named attributes for an object. When a default argument is |
|
1688 | Get a list of named attributes for an object. When a default argument is | |
1682 | given, it is returned when the attribute doesn't exist; without it, an |
|
1689 | given, it is returned when the attribute doesn't exist; without it, an | |
1683 | exception is raised in that case. |
|
1690 | exception is raised in that case. | |
1684 |
|
1691 | |||
1685 | Note that alist can be given as a string, which will be automatically |
|
1692 | Note that alist can be given as a string, which will be automatically | |
1686 | split into a list on whitespace. If given as a list, it must be a list of |
|
1693 | split into a list on whitespace. If given as a list, it must be a list of | |
1687 | *strings* (the variable names themselves), not of variables.""" |
|
1694 | *strings* (the variable names themselves), not of variables.""" | |
1688 |
|
1695 | |||
1689 | if type(alist) in StringTypes: |
|
1696 | if type(alist) in StringTypes: | |
1690 | alist = alist.split() |
|
1697 | alist = alist.split() | |
1691 | if args: |
|
1698 | if args: | |
1692 | if len(args)==1: |
|
1699 | if len(args)==1: | |
1693 | default = args[0] |
|
1700 | default = args[0] | |
1694 | return map(lambda attr: getattr(obj,attr,default),alist) |
|
1701 | return map(lambda attr: getattr(obj,attr,default),alist) | |
1695 | else: |
|
1702 | else: | |
1696 | raise ValueError,'getattr_list() takes only one optional argument' |
|
1703 | raise ValueError,'getattr_list() takes only one optional argument' | |
1697 | else: |
|
1704 | else: | |
1698 | return map(lambda attr: getattr(obj,attr),alist) |
|
1705 | return map(lambda attr: getattr(obj,attr),alist) | |
1699 |
|
1706 | |||
1700 | #---------------------------------------------------------------------------- |
|
1707 | #---------------------------------------------------------------------------- | |
1701 | def map_method(method,object_list,*argseq,**kw): |
|
1708 | def map_method(method,object_list,*argseq,**kw): | |
1702 | """map_method(method,object_list,*args,**kw) -> list |
|
1709 | """map_method(method,object_list,*args,**kw) -> list | |
1703 |
|
1710 | |||
1704 | Return a list of the results of applying the methods to the items of the |
|
1711 | Return a list of the results of applying the methods to the items of the | |
1705 | argument sequence(s). If more than one sequence is given, the method is |
|
1712 | argument sequence(s). If more than one sequence is given, the method is | |
1706 | called with an argument list consisting of the corresponding item of each |
|
1713 | called with an argument list consisting of the corresponding item of each | |
1707 | sequence. All sequences must be of the same length. |
|
1714 | sequence. All sequences must be of the same length. | |
1708 |
|
1715 | |||
1709 | Keyword arguments are passed verbatim to all objects called. |
|
1716 | Keyword arguments are passed verbatim to all objects called. | |
1710 |
|
1717 | |||
1711 | This is Python code, so it's not nearly as fast as the builtin map().""" |
|
1718 | This is Python code, so it's not nearly as fast as the builtin map().""" | |
1712 |
|
1719 | |||
1713 | out_list = [] |
|
1720 | out_list = [] | |
1714 | idx = 0 |
|
1721 | idx = 0 | |
1715 | for object in object_list: |
|
1722 | for object in object_list: | |
1716 | try: |
|
1723 | try: | |
1717 | handler = getattr(object, method) |
|
1724 | handler = getattr(object, method) | |
1718 | except AttributeError: |
|
1725 | except AttributeError: | |
1719 | out_list.append(None) |
|
1726 | out_list.append(None) | |
1720 | else: |
|
1727 | else: | |
1721 | if argseq: |
|
1728 | if argseq: | |
1722 | args = map(lambda lst:lst[idx],argseq) |
|
1729 | args = map(lambda lst:lst[idx],argseq) | |
1723 | #print 'ob',object,'hand',handler,'ar',args # dbg |
|
1730 | #print 'ob',object,'hand',handler,'ar',args # dbg | |
1724 | out_list.append(handler(args,**kw)) |
|
1731 | out_list.append(handler(args,**kw)) | |
1725 | else: |
|
1732 | else: | |
1726 | out_list.append(handler(**kw)) |
|
1733 | out_list.append(handler(**kw)) | |
1727 | idx += 1 |
|
1734 | idx += 1 | |
1728 | return out_list |
|
1735 | return out_list | |
1729 |
|
1736 | |||
1730 | #---------------------------------------------------------------------------- |
|
1737 | #---------------------------------------------------------------------------- | |
1731 | def import_fail_info(mod_name,fns=None): |
|
1738 | def import_fail_info(mod_name,fns=None): | |
1732 | """Inform load failure for a module.""" |
|
1739 | """Inform load failure for a module.""" | |
1733 |
|
1740 | |||
1734 | if fns == None: |
|
1741 | if fns == None: | |
1735 | warn("Loading of %s failed.\n" % (mod_name,)) |
|
1742 | warn("Loading of %s failed.\n" % (mod_name,)) | |
1736 | else: |
|
1743 | else: | |
1737 | warn("Loading of %s from %s failed.\n" % (fns,mod_name)) |
|
1744 | warn("Loading of %s from %s failed.\n" % (fns,mod_name)) | |
1738 |
|
1745 | |||
1739 | #---------------------------------------------------------------------------- |
|
1746 | #---------------------------------------------------------------------------- | |
1740 | # Proposed popitem() extension, written as a method |
|
1747 | # Proposed popitem() extension, written as a method | |
1741 |
|
1748 | |||
1742 | class NotGiven: pass |
|
1749 | class NotGiven: pass | |
1743 |
|
1750 | |||
1744 | def popkey(dct,key,default=NotGiven): |
|
1751 | def popkey(dct,key,default=NotGiven): | |
1745 | """Return dct[key] and delete dct[key]. |
|
1752 | """Return dct[key] and delete dct[key]. | |
1746 |
|
1753 | |||
1747 | If default is given, return it if dct[key] doesn't exist, otherwise raise |
|
1754 | If default is given, return it if dct[key] doesn't exist, otherwise raise | |
1748 | KeyError. """ |
|
1755 | KeyError. """ | |
1749 |
|
1756 | |||
1750 | try: |
|
1757 | try: | |
1751 | val = dct[key] |
|
1758 | val = dct[key] | |
1752 | except KeyError: |
|
1759 | except KeyError: | |
1753 | if default is NotGiven: |
|
1760 | if default is NotGiven: | |
1754 | raise |
|
1761 | raise | |
1755 | else: |
|
1762 | else: | |
1756 | return default |
|
1763 | return default | |
1757 | else: |
|
1764 | else: | |
1758 | del dct[key] |
|
1765 | del dct[key] | |
1759 | return val |
|
1766 | return val | |
1760 | #*************************** end of file <genutils.py> ********************** |
|
1767 | #*************************** end of file <genutils.py> ********************** | |
1761 |
|
1768 |
@@ -1,5161 +1,5178 b'' | |||||
|
1 | 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu> | |||
|
2 | ||||
|
3 | * IPython/demo.py (IPythonDemo): Add new classes to the demo | |||
|
4 | facilities, for demos processed by the IPython input filter | |||
|
5 | (IPythonDemo), and for running a script one-line-at-a-time as a | |||
|
6 | demo, both for pure Python (LineDemo) and for IPython-processed | |||
|
7 | input (IPythonLineDemo). After a request by Dave Kohel, from the | |||
|
8 | SAGE team. | |||
|
9 | (Demo.edit): added and edit() method to the demo objects, to edit | |||
|
10 | the in-memory copy of the last executed block. | |||
|
11 | ||||
|
12 | * IPython/Magic.py (magic_edit): add '-r' option for 'raw' | |||
|
13 | processing to %edit, %macro and %save. These commands can now be | |||
|
14 | invoked on the unprocessed input as it was typed by the user | |||
|
15 | (without any prefilters applied). After requests by the SAGE team | |||
|
16 | at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html. | |||
|
17 | ||||
1 | 2006-02-01 Ville Vainio <vivainio@gmail.com> |
|
18 | 2006-02-01 Ville Vainio <vivainio@gmail.com> | |
2 |
|
19 | |||
3 | * setup.py, eggsetup.py: easy_install ipython==dev works |
|
20 | * setup.py, eggsetup.py: easy_install ipython==dev works | |
4 | correctly now (on Linux) |
|
21 | correctly now (on Linux) | |
5 |
|
22 | |||
6 | * ipy_user_conf,ipmaker: user config changes, removed spurious |
|
23 | * ipy_user_conf,ipmaker: user config changes, removed spurious | |
7 | warnings |
|
24 | warnings | |
8 |
|
25 | |||
9 | * iplib: if rc.banner is string, use it as is. |
|
26 | * iplib: if rc.banner is string, use it as is. | |
10 |
|
27 | |||
11 | * Magic: %pycat accepts a string argument and pages it's contents. |
|
28 | * Magic: %pycat accepts a string argument and pages it's contents. | |
12 |
|
29 | |||
13 |
|
30 | |||
14 | 2006-01-30 Ville Vainio <vivainio@gmail.com> |
|
31 | 2006-01-30 Ville Vainio <vivainio@gmail.com> | |
15 |
|
32 | |||
16 | * pickleshare,pspersistence,ipapi,Magic: persistence overhaul. |
|
33 | * pickleshare,pspersistence,ipapi,Magic: persistence overhaul. | |
17 | Now %store and bookmarks work through PickleShare, meaning that |
|
34 | Now %store and bookmarks work through PickleShare, meaning that | |
18 | concurrent access is possible and all ipython sessions see the |
|
35 | concurrent access is possible and all ipython sessions see the | |
19 | same database situation all the time, instead of snapshot of |
|
36 | same database situation all the time, instead of snapshot of | |
20 | the situation when the session was started. Hence, %bookmark |
|
37 | the situation when the session was started. Hence, %bookmark | |
21 | results are immediately accessible from othes sessions. The database |
|
38 | results are immediately accessible from othes sessions. The database | |
22 | is also available for use by user extensions. See: |
|
39 | is also available for use by user extensions. See: | |
23 | http://www.python.org/pypi/pickleshare |
|
40 | http://www.python.org/pypi/pickleshare | |
24 |
|
41 | |||
25 | * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'. |
|
42 | * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'. | |
26 |
|
43 | |||
27 | * aliases can now be %store'd |
|
44 | * aliases can now be %store'd | |
28 |
|
45 | |||
29 | * path.py move to Extensions so that pickleshare does not need |
|
46 | * path.py move to Extensions so that pickleshare does not need | |
30 | IPython-specific import. Extensions added to pythonpath right |
|
47 | IPython-specific import. Extensions added to pythonpath right | |
31 | at __init__. |
|
48 | at __init__. | |
32 |
|
49 | |||
33 | * iplib.py: ipalias deprecated/redundant; aliases are converted and |
|
50 | * iplib.py: ipalias deprecated/redundant; aliases are converted and | |
34 | called with _ip.system and the pre-transformed command string. |
|
51 | called with _ip.system and the pre-transformed command string. | |
35 |
|
52 | |||
36 | 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
53 | 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
37 |
|
54 | |||
38 | * IPython/iplib.py (interact): Fix that we were not catching |
|
55 | * IPython/iplib.py (interact): Fix that we were not catching | |
39 | KeyboardInterrupt exceptions properly. I'm not quite sure why the |
|
56 | KeyboardInterrupt exceptions properly. I'm not quite sure why the | |
40 | logic here had to change, but it's fixed now. |
|
57 | logic here had to change, but it's fixed now. | |
41 |
|
58 | |||
42 | 2006-01-29 Ville Vainio <vivainio@gmail.com> |
|
59 | 2006-01-29 Ville Vainio <vivainio@gmail.com> | |
43 |
|
60 | |||
44 | * iplib.py: Try to import pyreadline on Windows. |
|
61 | * iplib.py: Try to import pyreadline on Windows. | |
45 |
|
62 | |||
46 | 2006-01-27 Ville Vainio <vivainio@gmail.com> |
|
63 | 2006-01-27 Ville Vainio <vivainio@gmail.com> | |
47 |
|
64 | |||
48 | * iplib.py: Expose ipapi as _ip in builtin namespace. |
|
65 | * iplib.py: Expose ipapi as _ip in builtin namespace. | |
49 | Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system) |
|
66 | Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system) | |
50 | and ip_set_hook (-> _ip.set_hook) redundant. % and ! |
|
67 | and ip_set_hook (-> _ip.set_hook) redundant. % and ! | |
51 | syntax now produce _ip.* variant of the commands. |
|
68 | syntax now produce _ip.* variant of the commands. | |
52 |
|
69 | |||
53 | * "_ip.options().autoedit_syntax = 2" automatically throws |
|
70 | * "_ip.options().autoedit_syntax = 2" automatically throws | |
54 | user to editor for syntax error correction without prompting. |
|
71 | user to editor for syntax error correction without prompting. | |
55 |
|
72 | |||
56 | 2006-01-27 Ville Vainio <vivainio@gmail.com> |
|
73 | 2006-01-27 Ville Vainio <vivainio@gmail.com> | |
57 |
|
74 | |||
58 | * ipmaker.py: Give "realistic" sys.argv for scripts (without |
|
75 | * ipmaker.py: Give "realistic" sys.argv for scripts (without | |
59 | 'ipython' at argv[0]) executed through command line. |
|
76 | 'ipython' at argv[0]) executed through command line. | |
60 | NOTE: this DEPRECATES calling ipython with multiple scripts |
|
77 | NOTE: this DEPRECATES calling ipython with multiple scripts | |
61 | ("ipython a.py b.py c.py") |
|
78 | ("ipython a.py b.py c.py") | |
62 |
|
79 | |||
63 | * iplib.py, hooks.py: Added configurable input prefilter, |
|
80 | * iplib.py, hooks.py: Added configurable input prefilter, | |
64 | named 'input_prefilter'. See ext_rescapture.py for example |
|
81 | named 'input_prefilter'. See ext_rescapture.py for example | |
65 | usage. |
|
82 | usage. | |
66 |
|
83 | |||
67 | * ext_rescapture.py, Magic.py: Better system command output capture |
|
84 | * ext_rescapture.py, Magic.py: Better system command output capture | |
68 | through 'var = !ls' (deprecates user-visible %sc). Same notation |
|
85 | through 'var = !ls' (deprecates user-visible %sc). Same notation | |
69 | applies for magics, 'var = %alias' assigns alias list to var. |
|
86 | applies for magics, 'var = %alias' assigns alias list to var. | |
70 |
|
87 | |||
71 | * ipapi.py: added meta() for accessing extension-usable data store. |
|
88 | * ipapi.py: added meta() for accessing extension-usable data store. | |
72 |
|
89 | |||
73 | * iplib.py: added InteractiveShell.getapi(). New magics should be |
|
90 | * iplib.py: added InteractiveShell.getapi(). New magics should be | |
74 | written doing self.getapi() instead of using the shell directly. |
|
91 | written doing self.getapi() instead of using the shell directly. | |
75 |
|
92 | |||
76 | * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and |
|
93 | * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and | |
77 | %store foo >> ~/myfoo.txt to store variables to files (in clean |
|
94 | %store foo >> ~/myfoo.txt to store variables to files (in clean | |
78 | textual form, not a restorable pickle). |
|
95 | textual form, not a restorable pickle). | |
79 |
|
96 | |||
80 | * ipmaker.py: now import ipy_profile_PROFILENAME automatically |
|
97 | * ipmaker.py: now import ipy_profile_PROFILENAME automatically | |
81 |
|
98 | |||
82 | * usage.py, Magic.py: added %quickref |
|
99 | * usage.py, Magic.py: added %quickref | |
83 |
|
100 | |||
84 | * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2). |
|
101 | * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2). | |
85 |
|
102 | |||
86 | * GetoptErrors when invoking magics etc. with wrong args |
|
103 | * GetoptErrors when invoking magics etc. with wrong args | |
87 | are now more helpful: |
|
104 | are now more helpful: | |
88 | GetoptError: option -l not recognized (allowed: "qb" ) |
|
105 | GetoptError: option -l not recognized (allowed: "qb" ) | |
89 |
|
106 | |||
90 | 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
107 | 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu> | |
91 |
|
108 | |||
92 | * IPython/demo.py (Demo.show): Flush stdout after each block, so |
|
109 | * IPython/demo.py (Demo.show): Flush stdout after each block, so | |
93 | computationally intensive blocks don't appear to stall the demo. |
|
110 | computationally intensive blocks don't appear to stall the demo. | |
94 |
|
111 | |||
95 | 2006-01-24 Ville Vainio <vivainio@gmail.com> |
|
112 | 2006-01-24 Ville Vainio <vivainio@gmail.com> | |
96 |
|
113 | |||
97 | * iplib.py, hooks.py: 'result_display' hook can return a non-None |
|
114 | * iplib.py, hooks.py: 'result_display' hook can return a non-None | |
98 | value to manipulate resulting history entry. |
|
115 | value to manipulate resulting history entry. | |
99 |
|
116 | |||
100 | * ipapi.py: Moved TryNext here from hooks.py. Moved functions |
|
117 | * ipapi.py: Moved TryNext here from hooks.py. Moved functions | |
101 | to instance methods of IPApi class, to make extending an embedded |
|
118 | to instance methods of IPApi class, to make extending an embedded | |
102 | IPython feasible. See ext_rehashdir.py for example usage. |
|
119 | IPython feasible. See ext_rehashdir.py for example usage. | |
103 |
|
120 | |||
104 | * Merged 1071-1076 from banches/0.7.1 |
|
121 | * Merged 1071-1076 from banches/0.7.1 | |
105 |
|
122 | |||
106 |
|
123 | |||
107 | 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
124 | 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
108 |
|
125 | |||
109 | * tools/release (daystamp): Fix build tools to use the new |
|
126 | * tools/release (daystamp): Fix build tools to use the new | |
110 | eggsetup.py script to build lightweight eggs. |
|
127 | eggsetup.py script to build lightweight eggs. | |
111 |
|
128 | |||
112 | * Applied changesets 1062 and 1064 before 0.7.1 release. |
|
129 | * Applied changesets 1062 and 1064 before 0.7.1 release. | |
113 |
|
130 | |||
114 | * IPython/Magic.py (magic_history): Add '-r' option to %hist, to |
|
131 | * IPython/Magic.py (magic_history): Add '-r' option to %hist, to | |
115 | see the raw input history (without conversions like %ls -> |
|
132 | see the raw input history (without conversions like %ls -> | |
116 | ipmagic("ls")). After a request from W. Stein, SAGE |
|
133 | ipmagic("ls")). After a request from W. Stein, SAGE | |
117 | (http://modular.ucsd.edu/sage) developer. This information is |
|
134 | (http://modular.ucsd.edu/sage) developer. This information is | |
118 | stored in the input_hist_raw attribute of the IPython instance, so |
|
135 | stored in the input_hist_raw attribute of the IPython instance, so | |
119 | developers can access it if needed (it's an InputList instance). |
|
136 | developers can access it if needed (it's an InputList instance). | |
120 |
|
137 | |||
121 | * Versionstring = 0.7.2.svn |
|
138 | * Versionstring = 0.7.2.svn | |
122 |
|
139 | |||
123 | * eggsetup.py: A separate script for constructing eggs, creates |
|
140 | * eggsetup.py: A separate script for constructing eggs, creates | |
124 | proper launch scripts even on Windows (an .exe file in |
|
141 | proper launch scripts even on Windows (an .exe file in | |
125 | \python24\scripts). |
|
142 | \python24\scripts). | |
126 |
|
143 | |||
127 | * ipapi.py: launch_new_instance, launch entry point needed for the |
|
144 | * ipapi.py: launch_new_instance, launch entry point needed for the | |
128 | egg. |
|
145 | egg. | |
129 |
|
146 | |||
130 | 2006-01-23 Ville Vainio <vivainio@gmail.com> |
|
147 | 2006-01-23 Ville Vainio <vivainio@gmail.com> | |
131 |
|
148 | |||
132 | * Added %cpaste magic for pasting python code |
|
149 | * Added %cpaste magic for pasting python code | |
133 |
|
150 | |||
134 | 2006-01-22 Ville Vainio <vivainio@gmail.com> |
|
151 | 2006-01-22 Ville Vainio <vivainio@gmail.com> | |
135 |
|
152 | |||
136 | * Merge from branches/0.7.1 into trunk, revs 1052-1057 |
|
153 | * Merge from branches/0.7.1 into trunk, revs 1052-1057 | |
137 |
|
154 | |||
138 | * Versionstring = 0.7.2.svn |
|
155 | * Versionstring = 0.7.2.svn | |
139 |
|
156 | |||
140 | * eggsetup.py: A separate script for constructing eggs, creates |
|
157 | * eggsetup.py: A separate script for constructing eggs, creates | |
141 | proper launch scripts even on Windows (an .exe file in |
|
158 | proper launch scripts even on Windows (an .exe file in | |
142 | \python24\scripts). |
|
159 | \python24\scripts). | |
143 |
|
160 | |||
144 | * ipapi.py: launch_new_instance, launch entry point needed for the |
|
161 | * ipapi.py: launch_new_instance, launch entry point needed for the | |
145 | egg. |
|
162 | egg. | |
146 |
|
163 | |||
147 | 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
164 | 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu> | |
148 |
|
165 | |||
149 | * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or |
|
166 | * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or | |
150 | %pfile foo would print the file for foo even if it was a binary. |
|
167 | %pfile foo would print the file for foo even if it was a binary. | |
151 | Now, extensions '.so' and '.dll' are skipped. |
|
168 | Now, extensions '.so' and '.dll' are skipped. | |
152 |
|
169 | |||
153 | * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading |
|
170 | * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading | |
154 | bug, where macros would fail in all threaded modes. I'm not 100% |
|
171 | bug, where macros would fail in all threaded modes. I'm not 100% | |
155 | sure, so I'm going to put out an rc instead of making a release |
|
172 | sure, so I'm going to put out an rc instead of making a release | |
156 | today, and wait for feedback for at least a few days. |
|
173 | today, and wait for feedback for at least a few days. | |
157 |
|
174 | |||
158 | * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt |
|
175 | * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt | |
159 | it...) the handling of pasting external code with autoindent on. |
|
176 | it...) the handling of pasting external code with autoindent on. | |
160 | To get out of a multiline input, the rule will appear for most |
|
177 | To get out of a multiline input, the rule will appear for most | |
161 | users unchanged: two blank lines or change the indent level |
|
178 | users unchanged: two blank lines or change the indent level | |
162 | proposed by IPython. But there is a twist now: you can |
|
179 | proposed by IPython. But there is a twist now: you can | |
163 | add/subtract only *one or two spaces*. If you add/subtract three |
|
180 | add/subtract only *one or two spaces*. If you add/subtract three | |
164 | or more (unless you completely delete the line), IPython will |
|
181 | or more (unless you completely delete the line), IPython will | |
165 | accept that line, and you'll need to enter a second one of pure |
|
182 | accept that line, and you'll need to enter a second one of pure | |
166 | whitespace. I know it sounds complicated, but I can't find a |
|
183 | whitespace. I know it sounds complicated, but I can't find a | |
167 | different solution that covers all the cases, with the right |
|
184 | different solution that covers all the cases, with the right | |
168 | heuristics. Hopefully in actual use, nobody will really notice |
|
185 | heuristics. Hopefully in actual use, nobody will really notice | |
169 | all these strange rules and things will 'just work'. |
|
186 | all these strange rules and things will 'just work'. | |
170 |
|
187 | |||
171 | 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu> |
|
188 | 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu> | |
172 |
|
189 | |||
173 | * IPython/iplib.py (interact): catch exceptions which can be |
|
190 | * IPython/iplib.py (interact): catch exceptions which can be | |
174 | triggered asynchronously by signal handlers. Thanks to an |
|
191 | triggered asynchronously by signal handlers. Thanks to an | |
175 | automatic crash report, submitted by Colin Kingsley |
|
192 | automatic crash report, submitted by Colin Kingsley | |
176 | <tercel-AT-gentoo.org>. |
|
193 | <tercel-AT-gentoo.org>. | |
177 |
|
194 | |||
178 | 2006-01-20 Ville Vainio <vivainio@gmail.com> |
|
195 | 2006-01-20 Ville Vainio <vivainio@gmail.com> | |
179 |
|
196 | |||
180 | * Ipython/Extensions/ext_rehashdir.py: Created a usable example |
|
197 | * Ipython/Extensions/ext_rehashdir.py: Created a usable example | |
181 | (%rehashdir, very useful, try it out) of how to extend ipython |
|
198 | (%rehashdir, very useful, try it out) of how to extend ipython | |
182 | with new magics. Also added Extensions dir to pythonpath to make |
|
199 | with new magics. Also added Extensions dir to pythonpath to make | |
183 | importing extensions easy. |
|
200 | importing extensions easy. | |
184 |
|
201 | |||
185 | * %store now complains when trying to store interactively declared |
|
202 | * %store now complains when trying to store interactively declared | |
186 | classes / instances of those classes. |
|
203 | classes / instances of those classes. | |
187 |
|
204 | |||
188 | * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py, |
|
205 | * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py, | |
189 | ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported |
|
206 | ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported | |
190 | if they exist, and ipy_user_conf.py with some defaults is created for |
|
207 | if they exist, and ipy_user_conf.py with some defaults is created for | |
191 | the user. |
|
208 | the user. | |
192 |
|
209 | |||
193 | * Startup rehashing done by the config file, not InterpreterExec. |
|
210 | * Startup rehashing done by the config file, not InterpreterExec. | |
194 | This means system commands are available even without selecting the |
|
211 | This means system commands are available even without selecting the | |
195 | pysh profile. It's the sensible default after all. |
|
212 | pysh profile. It's the sensible default after all. | |
196 |
|
213 | |||
197 | 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
214 | 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu> | |
198 |
|
215 | |||
199 | * IPython/iplib.py (raw_input): I _think_ I got the pasting of |
|
216 | * IPython/iplib.py (raw_input): I _think_ I got the pasting of | |
200 | multiline code with autoindent on working. But I am really not |
|
217 | multiline code with autoindent on working. But I am really not | |
201 | sure, so this needs more testing. Will commit a debug-enabled |
|
218 | sure, so this needs more testing. Will commit a debug-enabled | |
202 | version for now, while I test it some more, so that Ville and |
|
219 | version for now, while I test it some more, so that Ville and | |
203 | others may also catch any problems. Also made |
|
220 | others may also catch any problems. Also made | |
204 | self.indent_current_str() a method, to ensure that there's no |
|
221 | self.indent_current_str() a method, to ensure that there's no | |
205 | chance of the indent space count and the corresponding string |
|
222 | chance of the indent space count and the corresponding string | |
206 | falling out of sync. All code needing the string should just call |
|
223 | falling out of sync. All code needing the string should just call | |
207 | the method. |
|
224 | the method. | |
208 |
|
225 | |||
209 | 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
226 | 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu> | |
210 |
|
227 | |||
211 | * IPython/Magic.py (magic_edit): fix check for when users don't |
|
228 | * IPython/Magic.py (magic_edit): fix check for when users don't | |
212 | save their output files, the try/except was in the wrong section. |
|
229 | save their output files, the try/except was in the wrong section. | |
213 |
|
230 | |||
214 | 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu> |
|
231 | 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu> | |
215 |
|
232 | |||
216 | * IPython/Magic.py (magic_run): fix __file__ global missing from |
|
233 | * IPython/Magic.py (magic_run): fix __file__ global missing from | |
217 | script's namespace when executed via %run. After a report by |
|
234 | script's namespace when executed via %run. After a report by | |
218 | Vivian. |
|
235 | Vivian. | |
219 |
|
236 | |||
220 | * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d' |
|
237 | * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d' | |
221 | when using python 2.4. The parent constructor changed in 2.4, and |
|
238 | when using python 2.4. The parent constructor changed in 2.4, and | |
222 | we need to track it directly (we can't call it, as it messes up |
|
239 | we need to track it directly (we can't call it, as it messes up | |
223 | readline and tab-completion inside our pdb would stop working). |
|
240 | readline and tab-completion inside our pdb would stop working). | |
224 | After a bug report by R. Bernstein <rocky-AT-panix.com>. |
|
241 | After a bug report by R. Bernstein <rocky-AT-panix.com>. | |
225 |
|
242 | |||
226 | 2006-01-16 Ville Vainio <vivainio@gmail.com> |
|
243 | 2006-01-16 Ville Vainio <vivainio@gmail.com> | |
227 |
|
244 | |||
228 | * Ipython/magic.py:Reverted back to old %edit functionality |
|
245 | * Ipython/magic.py:Reverted back to old %edit functionality | |
229 | that returns file contents on exit. |
|
246 | that returns file contents on exit. | |
230 |
|
247 | |||
231 | * IPython/path.py: Added Jason Orendorff's "path" module to |
|
248 | * IPython/path.py: Added Jason Orendorff's "path" module to | |
232 | IPython tree, http://www.jorendorff.com/articles/python/path/. |
|
249 | IPython tree, http://www.jorendorff.com/articles/python/path/. | |
233 | You can get path objects conveniently through %sc, and !!, e.g.: |
|
250 | You can get path objects conveniently through %sc, and !!, e.g.: | |
234 | sc files=ls |
|
251 | sc files=ls | |
235 | for p in files.paths: # or files.p |
|
252 | for p in files.paths: # or files.p | |
236 | print p,p.mtime |
|
253 | print p,p.mtime | |
237 |
|
254 | |||
238 | * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall |
|
255 | * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall | |
239 | now work again without considering the exclusion regexp - |
|
256 | now work again without considering the exclusion regexp - | |
240 | hence, things like ',foo my/path' turn to 'foo("my/path")' |
|
257 | hence, things like ',foo my/path' turn to 'foo("my/path")' | |
241 | instead of syntax error. |
|
258 | instead of syntax error. | |
242 |
|
259 | |||
243 |
|
260 | |||
244 | 2006-01-14 Ville Vainio <vivainio@gmail.com> |
|
261 | 2006-01-14 Ville Vainio <vivainio@gmail.com> | |
245 |
|
262 | |||
246 | * IPython/ipapi.py (ashook, asmagic, options): Added convenience |
|
263 | * IPython/ipapi.py (ashook, asmagic, options): Added convenience | |
247 | ipapi decorators for python 2.4 users, options() provides access to rc |
|
264 | ipapi decorators for python 2.4 users, options() provides access to rc | |
248 | data. |
|
265 | data. | |
249 |
|
266 | |||
250 | * IPython/Magic.py (magic_cd): %cd now accepts backslashes |
|
267 | * IPython/Magic.py (magic_cd): %cd now accepts backslashes | |
251 | as path separators (even on Linux ;-). Space character after |
|
268 | as path separators (even on Linux ;-). Space character after | |
252 | backslash (as yielded by tab completer) is still space; |
|
269 | backslash (as yielded by tab completer) is still space; | |
253 | "%cd long\ name" works as expected. |
|
270 | "%cd long\ name" works as expected. | |
254 |
|
271 | |||
255 | * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented |
|
272 | * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented | |
256 | as "chain of command", with priority. API stays the same, |
|
273 | as "chain of command", with priority. API stays the same, | |
257 | TryNext exception raised by a hook function signals that |
|
274 | TryNext exception raised by a hook function signals that | |
258 | current hook failed and next hook should try handling it, as |
|
275 | current hook failed and next hook should try handling it, as | |
259 | suggested by Walter Dörwald <walter@livinglogic.de>. Walter also |
|
276 | suggested by Walter Dörwald <walter@livinglogic.de>. Walter also | |
260 | requested configurable display hook, which is now implemented. |
|
277 | requested configurable display hook, which is now implemented. | |
261 |
|
278 | |||
262 | 2006-01-13 Ville Vainio <vivainio@gmail.com> |
|
279 | 2006-01-13 Ville Vainio <vivainio@gmail.com> | |
263 |
|
280 | |||
264 | * IPython/platutils*.py: platform specific utility functions, |
|
281 | * IPython/platutils*.py: platform specific utility functions, | |
265 | so far only set_term_title is implemented (change terminal |
|
282 | so far only set_term_title is implemented (change terminal | |
266 | label in windowing systems). %cd now changes the title to |
|
283 | label in windowing systems). %cd now changes the title to | |
267 | current dir. |
|
284 | current dir. | |
268 |
|
285 | |||
269 | * IPython/Release.py: Added myself to "authors" list, |
|
286 | * IPython/Release.py: Added myself to "authors" list, | |
270 | had to create new files. |
|
287 | had to create new files. | |
271 |
|
288 | |||
272 | * IPython/iplib.py (handle_shell_escape): fixed logical flaw in |
|
289 | * IPython/iplib.py (handle_shell_escape): fixed logical flaw in | |
273 | shell escape; not a known bug but had potential to be one in the |
|
290 | shell escape; not a known bug but had potential to be one in the | |
274 | future. |
|
291 | future. | |
275 |
|
292 | |||
276 | * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public" |
|
293 | * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public" | |
277 | extension API for IPython! See the module for usage example. Fix |
|
294 | extension API for IPython! See the module for usage example. Fix | |
278 | OInspect for docstring-less magic functions. |
|
295 | OInspect for docstring-less magic functions. | |
279 |
|
296 | |||
280 |
|
297 | |||
281 | 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
298 | 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu> | |
282 |
|
299 | |||
283 | * IPython/iplib.py (raw_input): temporarily deactivate all |
|
300 | * IPython/iplib.py (raw_input): temporarily deactivate all | |
284 | attempts at allowing pasting of code with autoindent on. It |
|
301 | attempts at allowing pasting of code with autoindent on. It | |
285 | introduced bugs (reported by Prabhu) and I can't seem to find a |
|
302 | introduced bugs (reported by Prabhu) and I can't seem to find a | |
286 | robust combination which works in all cases. Will have to revisit |
|
303 | robust combination which works in all cases. Will have to revisit | |
287 | later. |
|
304 | later. | |
288 |
|
305 | |||
289 | * IPython/genutils.py: remove isspace() function. We've dropped |
|
306 | * IPython/genutils.py: remove isspace() function. We've dropped | |
290 | 2.2 compatibility, so it's OK to use the string method. |
|
307 | 2.2 compatibility, so it's OK to use the string method. | |
291 |
|
308 | |||
292 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
309 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
293 |
|
310 | |||
294 | * IPython/iplib.py (InteractiveShell.__init__): fix regexp |
|
311 | * IPython/iplib.py (InteractiveShell.__init__): fix regexp | |
295 | matching what NOT to autocall on, to include all python binary |
|
312 | matching what NOT to autocall on, to include all python binary | |
296 | operators (including things like 'and', 'or', 'is' and 'in'). |
|
313 | operators (including things like 'and', 'or', 'is' and 'in'). | |
297 | Prompted by a bug report on 'foo & bar', but I realized we had |
|
314 | Prompted by a bug report on 'foo & bar', but I realized we had | |
298 | many more potential bug cases with other operators. The regexp is |
|
315 | many more potential bug cases with other operators. The regexp is | |
299 | self.re_exclude_auto, it's fairly commented. |
|
316 | self.re_exclude_auto, it's fairly commented. | |
300 |
|
317 | |||
301 | 2006-01-12 Ville Vainio <vivainio@gmail.com> |
|
318 | 2006-01-12 Ville Vainio <vivainio@gmail.com> | |
302 |
|
319 | |||
303 | * IPython/iplib.py (make_quoted_expr,handle_shell_escape): |
|
320 | * IPython/iplib.py (make_quoted_expr,handle_shell_escape): | |
304 | Prettified and hardened string/backslash quoting with ipsystem(), |
|
321 | Prettified and hardened string/backslash quoting with ipsystem(), | |
305 | ipalias() and ipmagic(). Now even \ characters are passed to |
|
322 | ipalias() and ipmagic(). Now even \ characters are passed to | |
306 | %magics, !shell escapes and aliases exactly as they are in the |
|
323 | %magics, !shell escapes and aliases exactly as they are in the | |
307 | ipython command line. Should improve backslash experience, |
|
324 | ipython command line. Should improve backslash experience, | |
308 | particularly in Windows (path delimiter for some commands that |
|
325 | particularly in Windows (path delimiter for some commands that | |
309 | won't understand '/'), but Unix benefits as well (regexps). %cd |
|
326 | won't understand '/'), but Unix benefits as well (regexps). %cd | |
310 | magic still doesn't support backslash path delimiters, though. Also |
|
327 | magic still doesn't support backslash path delimiters, though. Also | |
311 | deleted all pretense of supporting multiline command strings in |
|
328 | deleted all pretense of supporting multiline command strings in | |
312 | !system or %magic commands. Thanks to Jerry McRae for suggestions. |
|
329 | !system or %magic commands. Thanks to Jerry McRae for suggestions. | |
313 |
|
330 | |||
314 | * doc/build_doc_instructions.txt added. Documentation on how to |
|
331 | * doc/build_doc_instructions.txt added. Documentation on how to | |
315 | use doc/update_manual.py, added yesterday. Both files contributed |
|
332 | use doc/update_manual.py, added yesterday. Both files contributed | |
316 | by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates |
|
333 | by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates | |
317 | doc/*.sh for deprecation at a later date. |
|
334 | doc/*.sh for deprecation at a later date. | |
318 |
|
335 | |||
319 | * /ipython.py Added ipython.py to root directory for |
|
336 | * /ipython.py Added ipython.py to root directory for | |
320 | zero-installation (tar xzvf ipython.tgz; cd ipython; python |
|
337 | zero-installation (tar xzvf ipython.tgz; cd ipython; python | |
321 | ipython.py) and development convenience (no need to kee doing |
|
338 | ipython.py) and development convenience (no need to kee doing | |
322 | "setup.py install" between changes). |
|
339 | "setup.py install" between changes). | |
323 |
|
340 | |||
324 | * Made ! and !! shell escapes work (again) in multiline expressions: |
|
341 | * Made ! and !! shell escapes work (again) in multiline expressions: | |
325 | if 1: |
|
342 | if 1: | |
326 | !ls |
|
343 | !ls | |
327 | !!ls |
|
344 | !!ls | |
328 |
|
345 | |||
329 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
346 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
330 |
|
347 | |||
331 | * IPython/ipstruct.py (Struct): Rename IPython.Struct to |
|
348 | * IPython/ipstruct.py (Struct): Rename IPython.Struct to | |
332 | IPython.ipstruct, to avoid local shadowing of the stdlib 'struct' |
|
349 | IPython.ipstruct, to avoid local shadowing of the stdlib 'struct' | |
333 | module in case-insensitive installation. Was causing crashes |
|
350 | module in case-insensitive installation. Was causing crashes | |
334 | under win32. Closes http://www.scipy.net/roundup/ipython/issue49. |
|
351 | under win32. Closes http://www.scipy.net/roundup/ipython/issue49. | |
335 |
|
352 | |||
336 | * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart |
|
353 | * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart | |
337 | <marienz-AT-gentoo.org>, closes |
|
354 | <marienz-AT-gentoo.org>, closes | |
338 | http://www.scipy.net/roundup/ipython/issue51. |
|
355 | http://www.scipy.net/roundup/ipython/issue51. | |
339 |
|
356 | |||
340 | 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu> |
|
357 | 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu> | |
341 |
|
358 | |||
342 | * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the |
|
359 | * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the | |
343 | problem of excessive CPU usage under *nix and keyboard lag under |
|
360 | problem of excessive CPU usage under *nix and keyboard lag under | |
344 | win32. |
|
361 | win32. | |
345 |
|
362 | |||
346 | 2006-01-10 *** Released version 0.7.0 |
|
363 | 2006-01-10 *** Released version 0.7.0 | |
347 |
|
364 | |||
348 | 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu> |
|
365 | 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu> | |
349 |
|
366 | |||
350 | * IPython/Release.py (revision): tag version number to 0.7.0, |
|
367 | * IPython/Release.py (revision): tag version number to 0.7.0, | |
351 | ready for release. |
|
368 | ready for release. | |
352 |
|
369 | |||
353 | * IPython/Magic.py (magic_edit): Add print statement to %edit so |
|
370 | * IPython/Magic.py (magic_edit): Add print statement to %edit so | |
354 | it informs the user of the name of the temp. file used. This can |
|
371 | it informs the user of the name of the temp. file used. This can | |
355 | help if you decide later to reuse that same file, so you know |
|
372 | help if you decide later to reuse that same file, so you know | |
356 | where to copy the info from. |
|
373 | where to copy the info from. | |
357 |
|
374 | |||
358 | 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu> |
|
375 | 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu> | |
359 |
|
376 | |||
360 | * setup_bdist_egg.py: little script to build an egg. Added |
|
377 | * setup_bdist_egg.py: little script to build an egg. Added | |
361 | support in the release tools as well. |
|
378 | support in the release tools as well. | |
362 |
|
379 | |||
363 | 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
380 | 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu> | |
364 |
|
381 | |||
365 | * IPython/Shell.py (IPShellWX.__init__): add support for WXPython |
|
382 | * IPython/Shell.py (IPShellWX.__init__): add support for WXPython | |
366 | version selection (new -wxversion command line and ipythonrc |
|
383 | version selection (new -wxversion command line and ipythonrc | |
367 | parameter). Patch contributed by Arnd Baecker |
|
384 | parameter). Patch contributed by Arnd Baecker | |
368 | <arnd.baecker-AT-web.de>. |
|
385 | <arnd.baecker-AT-web.de>. | |
369 |
|
386 | |||
370 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
387 | * IPython/iplib.py (embed_mainloop): fix tab-completion in | |
371 | embedded instances, for variables defined at the interactive |
|
388 | embedded instances, for variables defined at the interactive | |
372 | prompt of the embedded ipython. Reported by Arnd. |
|
389 | prompt of the embedded ipython. Reported by Arnd. | |
373 |
|
390 | |||
374 | * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now |
|
391 | * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now | |
375 | it can be used as a (stateful) toggle, or with a direct parameter. |
|
392 | it can be used as a (stateful) toggle, or with a direct parameter. | |
376 |
|
393 | |||
377 | * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which |
|
394 | * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which | |
378 | could be triggered in certain cases and cause the traceback |
|
395 | could be triggered in certain cases and cause the traceback | |
379 | printer not to work. |
|
396 | printer not to work. | |
380 |
|
397 | |||
381 | 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu> |
|
398 | 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu> | |
382 |
|
399 | |||
383 | * IPython/iplib.py (_should_recompile): Small fix, closes |
|
400 | * IPython/iplib.py (_should_recompile): Small fix, closes | |
384 | http://www.scipy.net/roundup/ipython/issue48. Patch by Scott. |
|
401 | http://www.scipy.net/roundup/ipython/issue48. Patch by Scott. | |
385 |
|
402 | |||
386 | 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu> |
|
403 | 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu> | |
387 |
|
404 | |||
388 | * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK |
|
405 | * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK | |
389 | backend for matplotlib (100% cpu utiliziation). Thanks to Charlie |
|
406 | backend for matplotlib (100% cpu utiliziation). Thanks to Charlie | |
390 | Moad for help with tracking it down. |
|
407 | Moad for help with tracking it down. | |
391 |
|
408 | |||
392 | * IPython/iplib.py (handle_auto): fix autocall handling for |
|
409 | * IPython/iplib.py (handle_auto): fix autocall handling for | |
393 | objects which support BOTH __getitem__ and __call__ (so that f [x] |
|
410 | objects which support BOTH __getitem__ and __call__ (so that f [x] | |
394 | is left alone, instead of becoming f([x]) automatically). |
|
411 | is left alone, instead of becoming f([x]) automatically). | |
395 |
|
412 | |||
396 | * IPython/Magic.py (magic_cd): fix crash when cd -b was used. |
|
413 | * IPython/Magic.py (magic_cd): fix crash when cd -b was used. | |
397 | Ville's patch. |
|
414 | Ville's patch. | |
398 |
|
415 | |||
399 | 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu> |
|
416 | 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu> | |
400 |
|
417 | |||
401 | * IPython/iplib.py (handle_auto): changed autocall semantics to |
|
418 | * IPython/iplib.py (handle_auto): changed autocall semantics to | |
402 | include 'smart' mode, where the autocall transformation is NOT |
|
419 | include 'smart' mode, where the autocall transformation is NOT | |
403 | applied if there are no arguments on the line. This allows you to |
|
420 | applied if there are no arguments on the line. This allows you to | |
404 | just type 'foo' if foo is a callable to see its internal form, |
|
421 | just type 'foo' if foo is a callable to see its internal form, | |
405 | instead of having it called with no arguments (typically a |
|
422 | instead of having it called with no arguments (typically a | |
406 | mistake). The old 'full' autocall still exists: for that, you |
|
423 | mistake). The old 'full' autocall still exists: for that, you | |
407 | need to set the 'autocall' parameter to 2 in your ipythonrc file. |
|
424 | need to set the 'autocall' parameter to 2 in your ipythonrc file. | |
408 |
|
425 | |||
409 | * IPython/completer.py (Completer.attr_matches): add |
|
426 | * IPython/completer.py (Completer.attr_matches): add | |
410 | tab-completion support for Enthoughts' traits. After a report by |
|
427 | tab-completion support for Enthoughts' traits. After a report by | |
411 | Arnd and a patch by Prabhu. |
|
428 | Arnd and a patch by Prabhu. | |
412 |
|
429 | |||
413 | 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu> |
|
430 | 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu> | |
414 |
|
431 | |||
415 | * IPython/ultraTB.py (_fixed_getinnerframes): added Alex |
|
432 | * IPython/ultraTB.py (_fixed_getinnerframes): added Alex | |
416 | Schmolck's patch to fix inspect.getinnerframes(). |
|
433 | Schmolck's patch to fix inspect.getinnerframes(). | |
417 |
|
434 | |||
418 | * IPython/iplib.py (InteractiveShell.__init__): significant fixes |
|
435 | * IPython/iplib.py (InteractiveShell.__init__): significant fixes | |
419 | for embedded instances, regarding handling of namespaces and items |
|
436 | for embedded instances, regarding handling of namespaces and items | |
420 | added to the __builtin__ one. Multiple embedded instances and |
|
437 | added to the __builtin__ one. Multiple embedded instances and | |
421 | recursive embeddings should work better now (though I'm not sure |
|
438 | recursive embeddings should work better now (though I'm not sure | |
422 | I've got all the corner cases fixed, that code is a bit of a brain |
|
439 | I've got all the corner cases fixed, that code is a bit of a brain | |
423 | twister). |
|
440 | twister). | |
424 |
|
441 | |||
425 | * IPython/Magic.py (magic_edit): added support to edit in-memory |
|
442 | * IPython/Magic.py (magic_edit): added support to edit in-memory | |
426 | macros (automatically creates the necessary temp files). %edit |
|
443 | macros (automatically creates the necessary temp files). %edit | |
427 | also doesn't return the file contents anymore, it's just noise. |
|
444 | also doesn't return the file contents anymore, it's just noise. | |
428 |
|
445 | |||
429 | * IPython/completer.py (Completer.attr_matches): revert change to |
|
446 | * IPython/completer.py (Completer.attr_matches): revert change to | |
430 | complete only on attributes listed in __all__. I realized it |
|
447 | complete only on attributes listed in __all__. I realized it | |
431 | cripples the tab-completion system as a tool for exploring the |
|
448 | cripples the tab-completion system as a tool for exploring the | |
432 | internals of unknown libraries (it renders any non-__all__ |
|
449 | internals of unknown libraries (it renders any non-__all__ | |
433 | attribute off-limits). I got bit by this when trying to see |
|
450 | attribute off-limits). I got bit by this when trying to see | |
434 | something inside the dis module. |
|
451 | something inside the dis module. | |
435 |
|
452 | |||
436 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
453 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
437 |
|
454 | |||
438 | * IPython/iplib.py (InteractiveShell.__init__): add .meta |
|
455 | * IPython/iplib.py (InteractiveShell.__init__): add .meta | |
439 | namespace for users and extension writers to hold data in. This |
|
456 | namespace for users and extension writers to hold data in. This | |
440 | follows the discussion in |
|
457 | follows the discussion in | |
441 | http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython. |
|
458 | http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython. | |
442 |
|
459 | |||
443 | * IPython/completer.py (IPCompleter.complete): small patch to help |
|
460 | * IPython/completer.py (IPCompleter.complete): small patch to help | |
444 | tab-completion under Emacs, after a suggestion by John Barnard |
|
461 | tab-completion under Emacs, after a suggestion by John Barnard | |
445 | <barnarj-AT-ccf.org>. |
|
462 | <barnarj-AT-ccf.org>. | |
446 |
|
463 | |||
447 | * IPython/Magic.py (Magic.extract_input_slices): added support for |
|
464 | * IPython/Magic.py (Magic.extract_input_slices): added support for | |
448 | the slice notation in magics to use N-M to represent numbers N...M |
|
465 | the slice notation in magics to use N-M to represent numbers N...M | |
449 | (closed endpoints). This is used by %macro and %save. |
|
466 | (closed endpoints). This is used by %macro and %save. | |
450 |
|
467 | |||
451 | * IPython/completer.py (Completer.attr_matches): for modules which |
|
468 | * IPython/completer.py (Completer.attr_matches): for modules which | |
452 | define __all__, complete only on those. After a patch by Jeffrey |
|
469 | define __all__, complete only on those. After a patch by Jeffrey | |
453 | Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and |
|
470 | Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and | |
454 | speed up this routine. |
|
471 | speed up this routine. | |
455 |
|
472 | |||
456 | * IPython/Logger.py (Logger.log): fix a history handling bug. I |
|
473 | * IPython/Logger.py (Logger.log): fix a history handling bug. I | |
457 | don't know if this is the end of it, but the behavior now is |
|
474 | don't know if this is the end of it, but the behavior now is | |
458 | certainly much more correct. Note that coupled with macros, |
|
475 | certainly much more correct. Note that coupled with macros, | |
459 | slightly surprising (at first) behavior may occur: a macro will in |
|
476 | slightly surprising (at first) behavior may occur: a macro will in | |
460 | general expand to multiple lines of input, so upon exiting, the |
|
477 | general expand to multiple lines of input, so upon exiting, the | |
461 | in/out counters will both be bumped by the corresponding amount |
|
478 | in/out counters will both be bumped by the corresponding amount | |
462 | (as if the macro's contents had been typed interactively). Typing |
|
479 | (as if the macro's contents had been typed interactively). Typing | |
463 | %hist will reveal the intermediate (silently processed) lines. |
|
480 | %hist will reveal the intermediate (silently processed) lines. | |
464 |
|
481 | |||
465 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause |
|
482 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause | |
466 | pickle to fail (%run was overwriting __main__ and not restoring |
|
483 | pickle to fail (%run was overwriting __main__ and not restoring | |
467 | it, but pickle relies on __main__ to operate). |
|
484 | it, but pickle relies on __main__ to operate). | |
468 |
|
485 | |||
469 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now |
|
486 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now | |
470 | using properties, but forgot to make the main InteractiveShell |
|
487 | using properties, but forgot to make the main InteractiveShell | |
471 | class a new-style class. Properties fail silently, and |
|
488 | class a new-style class. Properties fail silently, and | |
472 | misteriously, with old-style class (getters work, but |
|
489 | misteriously, with old-style class (getters work, but | |
473 | setters don't do anything). |
|
490 | setters don't do anything). | |
474 |
|
491 | |||
475 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> |
|
492 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> | |
476 |
|
493 | |||
477 | * IPython/Magic.py (magic_history): fix history reporting bug (I |
|
494 | * IPython/Magic.py (magic_history): fix history reporting bug (I | |
478 | know some nasties are still there, I just can't seem to find a |
|
495 | know some nasties are still there, I just can't seem to find a | |
479 | reproducible test case to track them down; the input history is |
|
496 | reproducible test case to track them down; the input history is | |
480 | falling out of sync...) |
|
497 | falling out of sync...) | |
481 |
|
498 | |||
482 | * IPython/iplib.py (handle_shell_escape): fix bug where both |
|
499 | * IPython/iplib.py (handle_shell_escape): fix bug where both | |
483 | aliases and system accesses where broken for indented code (such |
|
500 | aliases and system accesses where broken for indented code (such | |
484 | as loops). |
|
501 | as loops). | |
485 |
|
502 | |||
486 | * IPython/genutils.py (shell): fix small but critical bug for |
|
503 | * IPython/genutils.py (shell): fix small but critical bug for | |
487 | win32 system access. |
|
504 | win32 system access. | |
488 |
|
505 | |||
489 | 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
506 | 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
490 |
|
507 | |||
491 | * IPython/iplib.py (showtraceback): remove use of the |
|
508 | * IPython/iplib.py (showtraceback): remove use of the | |
492 | sys.last_{type/value/traceback} structures, which are non |
|
509 | sys.last_{type/value/traceback} structures, which are non | |
493 | thread-safe. |
|
510 | thread-safe. | |
494 | (_prefilter): change control flow to ensure that we NEVER |
|
511 | (_prefilter): change control flow to ensure that we NEVER | |
495 | introspect objects when autocall is off. This will guarantee that |
|
512 | introspect objects when autocall is off. This will guarantee that | |
496 | having an input line of the form 'x.y', where access to attribute |
|
513 | having an input line of the form 'x.y', where access to attribute | |
497 | 'y' has side effects, doesn't trigger the side effect TWICE. It |
|
514 | 'y' has side effects, doesn't trigger the side effect TWICE. It | |
498 | is important to note that, with autocall on, these side effects |
|
515 | is important to note that, with autocall on, these side effects | |
499 | can still happen. |
|
516 | can still happen. | |
500 | (ipsystem): new builtin, to complete the ip{magic/alias/system} |
|
517 | (ipsystem): new builtin, to complete the ip{magic/alias/system} | |
501 | trio. IPython offers these three kinds of special calls which are |
|
518 | trio. IPython offers these three kinds of special calls which are | |
502 | not python code, and it's a good thing to have their call method |
|
519 | not python code, and it's a good thing to have their call method | |
503 | be accessible as pure python functions (not just special syntax at |
|
520 | be accessible as pure python functions (not just special syntax at | |
504 | the command line). It gives us a better internal implementation |
|
521 | the command line). It gives us a better internal implementation | |
505 | structure, as well as exposing these for user scripting more |
|
522 | structure, as well as exposing these for user scripting more | |
506 | cleanly. |
|
523 | cleanly. | |
507 |
|
524 | |||
508 | * IPython/macro.py (Macro.__init__): moved macros to a standalone |
|
525 | * IPython/macro.py (Macro.__init__): moved macros to a standalone | |
509 | file. Now that they'll be more likely to be used with the |
|
526 | file. Now that they'll be more likely to be used with the | |
510 | persistance system (%store), I want to make sure their module path |
|
527 | persistance system (%store), I want to make sure their module path | |
511 | doesn't change in the future, so that we don't break things for |
|
528 | doesn't change in the future, so that we don't break things for | |
512 | users' persisted data. |
|
529 | users' persisted data. | |
513 |
|
530 | |||
514 | * IPython/iplib.py (autoindent_update): move indentation |
|
531 | * IPython/iplib.py (autoindent_update): move indentation | |
515 | management into the _text_ processing loop, not the keyboard |
|
532 | management into the _text_ processing loop, not the keyboard | |
516 | interactive one. This is necessary to correctly process non-typed |
|
533 | interactive one. This is necessary to correctly process non-typed | |
517 | multiline input (such as macros). |
|
534 | multiline input (such as macros). | |
518 |
|
535 | |||
519 | * IPython/Magic.py (Magic.format_latex): patch by Stefan van der |
|
536 | * IPython/Magic.py (Magic.format_latex): patch by Stefan van der | |
520 | Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings, |
|
537 | Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings, | |
521 | which was producing problems in the resulting manual. |
|
538 | which was producing problems in the resulting manual. | |
522 | (magic_whos): improve reporting of instances (show their class, |
|
539 | (magic_whos): improve reporting of instances (show their class, | |
523 | instead of simply printing 'instance' which isn't terribly |
|
540 | instead of simply printing 'instance' which isn't terribly | |
524 | informative). |
|
541 | informative). | |
525 |
|
542 | |||
526 | * IPython/genutils.py (shell): commit Jorgen Stenarson's patch |
|
543 | * IPython/genutils.py (shell): commit Jorgen Stenarson's patch | |
527 | (minor mods) to support network shares under win32. |
|
544 | (minor mods) to support network shares under win32. | |
528 |
|
545 | |||
529 | * IPython/winconsole.py (get_console_size): add new winconsole |
|
546 | * IPython/winconsole.py (get_console_size): add new winconsole | |
530 | module and fixes to page_dumb() to improve its behavior under |
|
547 | module and fixes to page_dumb() to improve its behavior under | |
531 | win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>. |
|
548 | win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>. | |
532 |
|
549 | |||
533 | * IPython/Magic.py (Macro): simplified Macro class to just |
|
550 | * IPython/Magic.py (Macro): simplified Macro class to just | |
534 | subclass list. We've had only 2.2 compatibility for a very long |
|
551 | subclass list. We've had only 2.2 compatibility for a very long | |
535 | time, yet I was still avoiding subclassing the builtin types. No |
|
552 | time, yet I was still avoiding subclassing the builtin types. No | |
536 | more (I'm also starting to use properties, though I won't shift to |
|
553 | more (I'm also starting to use properties, though I won't shift to | |
537 | 2.3-specific features quite yet). |
|
554 | 2.3-specific features quite yet). | |
538 | (magic_store): added Ville's patch for lightweight variable |
|
555 | (magic_store): added Ville's patch for lightweight variable | |
539 | persistence, after a request on the user list by Matt Wilkie |
|
556 | persistence, after a request on the user list by Matt Wilkie | |
540 | <maphew-AT-gmail.com>. The new %store magic's docstring has full |
|
557 | <maphew-AT-gmail.com>. The new %store magic's docstring has full | |
541 | details. |
|
558 | details. | |
542 |
|
559 | |||
543 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
560 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
544 | changed the default logfile name from 'ipython.log' to |
|
561 | changed the default logfile name from 'ipython.log' to | |
545 | 'ipython_log.py'. These logs are real python files, and now that |
|
562 | 'ipython_log.py'. These logs are real python files, and now that | |
546 | we have much better multiline support, people are more likely to |
|
563 | we have much better multiline support, people are more likely to | |
547 | want to use them as such. Might as well name them correctly. |
|
564 | want to use them as such. Might as well name them correctly. | |
548 |
|
565 | |||
549 | * IPython/Magic.py: substantial cleanup. While we can't stop |
|
566 | * IPython/Magic.py: substantial cleanup. While we can't stop | |
550 | using magics as mixins, due to the existing customizations 'out |
|
567 | using magics as mixins, due to the existing customizations 'out | |
551 | there' which rely on the mixin naming conventions, at least I |
|
568 | there' which rely on the mixin naming conventions, at least I | |
552 | cleaned out all cross-class name usage. So once we are OK with |
|
569 | cleaned out all cross-class name usage. So once we are OK with | |
553 | breaking compatibility, the two systems can be separated. |
|
570 | breaking compatibility, the two systems can be separated. | |
554 |
|
571 | |||
555 | * IPython/Logger.py: major cleanup. This one is NOT a mixin |
|
572 | * IPython/Logger.py: major cleanup. This one is NOT a mixin | |
556 | anymore, and the class is a fair bit less hideous as well. New |
|
573 | anymore, and the class is a fair bit less hideous as well. New | |
557 | features were also introduced: timestamping of input, and logging |
|
574 | features were also introduced: timestamping of input, and logging | |
558 | of output results. These are user-visible with the -t and -o |
|
575 | of output results. These are user-visible with the -t and -o | |
559 | options to %logstart. Closes |
|
576 | options to %logstart. Closes | |
560 | http://www.scipy.net/roundup/ipython/issue11 and a request by |
|
577 | http://www.scipy.net/roundup/ipython/issue11 and a request by | |
561 | William Stein (SAGE developer - http://modular.ucsd.edu/sage). |
|
578 | William Stein (SAGE developer - http://modular.ucsd.edu/sage). | |
562 |
|
579 | |||
563 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> |
|
580 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> | |
564 |
|
581 | |||
565 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to |
|
582 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to | |
566 | better hadnle backslashes in paths. See the thread 'More Windows |
|
583 | better hadnle backslashes in paths. See the thread 'More Windows | |
567 | questions part 2 - \/ characters revisited' on the iypthon user |
|
584 | questions part 2 - \/ characters revisited' on the iypthon user | |
568 | list: |
|
585 | list: | |
569 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html |
|
586 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html | |
570 |
|
587 | |||
571 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. |
|
588 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. | |
572 |
|
589 | |||
573 | (InteractiveShell.__init__): change threaded shells to not use the |
|
590 | (InteractiveShell.__init__): change threaded shells to not use the | |
574 | ipython crash handler. This was causing more problems than not, |
|
591 | ipython crash handler. This was causing more problems than not, | |
575 | as exceptions in the main thread (GUI code, typically) would |
|
592 | as exceptions in the main thread (GUI code, typically) would | |
576 | always show up as a 'crash', when they really weren't. |
|
593 | always show up as a 'crash', when they really weren't. | |
577 |
|
594 | |||
578 | The colors and exception mode commands (%colors/%xmode) have been |
|
595 | The colors and exception mode commands (%colors/%xmode) have been | |
579 | synchronized to also take this into account, so users can get |
|
596 | synchronized to also take this into account, so users can get | |
580 | verbose exceptions for their threaded code as well. I also added |
|
597 | verbose exceptions for their threaded code as well. I also added | |
581 | support for activating pdb inside this exception handler as well, |
|
598 | support for activating pdb inside this exception handler as well, | |
582 | so now GUI authors can use IPython's enhanced pdb at runtime. |
|
599 | so now GUI authors can use IPython's enhanced pdb at runtime. | |
583 |
|
600 | |||
584 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag |
|
601 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag | |
585 | true by default, and add it to the shipped ipythonrc file. Since |
|
602 | true by default, and add it to the shipped ipythonrc file. Since | |
586 | this asks the user before proceeding, I think it's OK to make it |
|
603 | this asks the user before proceeding, I think it's OK to make it | |
587 | true by default. |
|
604 | true by default. | |
588 |
|
605 | |||
589 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead |
|
606 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead | |
590 | of the previous special-casing of input in the eval loop. I think |
|
607 | of the previous special-casing of input in the eval loop. I think | |
591 | this is cleaner, as they really are commands and shouldn't have |
|
608 | this is cleaner, as they really are commands and shouldn't have | |
592 | a special role in the middle of the core code. |
|
609 | a special role in the middle of the core code. | |
593 |
|
610 | |||
594 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
611 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
595 |
|
612 | |||
596 | * IPython/iplib.py (edit_syntax_error): added support for |
|
613 | * IPython/iplib.py (edit_syntax_error): added support for | |
597 | automatically reopening the editor if the file had a syntax error |
|
614 | automatically reopening the editor if the file had a syntax error | |
598 | in it. Thanks to scottt who provided the patch at: |
|
615 | in it. Thanks to scottt who provided the patch at: | |
599 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified |
|
616 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified | |
600 | version committed). |
|
617 | version committed). | |
601 |
|
618 | |||
602 | * IPython/iplib.py (handle_normal): add suport for multi-line |
|
619 | * IPython/iplib.py (handle_normal): add suport for multi-line | |
603 | input with emtpy lines. This fixes |
|
620 | input with emtpy lines. This fixes | |
604 | http://www.scipy.net/roundup/ipython/issue43 and a similar |
|
621 | http://www.scipy.net/roundup/ipython/issue43 and a similar | |
605 | discussion on the user list. |
|
622 | discussion on the user list. | |
606 |
|
623 | |||
607 | WARNING: a behavior change is necessarily introduced to support |
|
624 | WARNING: a behavior change is necessarily introduced to support | |
608 | blank lines: now a single blank line with whitespace does NOT |
|
625 | blank lines: now a single blank line with whitespace does NOT | |
609 | break the input loop, which means that when autoindent is on, by |
|
626 | break the input loop, which means that when autoindent is on, by | |
610 | default hitting return on the next (indented) line does NOT exit. |
|
627 | default hitting return on the next (indented) line does NOT exit. | |
611 |
|
628 | |||
612 | Instead, to exit a multiline input you can either have: |
|
629 | Instead, to exit a multiline input you can either have: | |
613 |
|
630 | |||
614 | - TWO whitespace lines (just hit return again), or |
|
631 | - TWO whitespace lines (just hit return again), or | |
615 | - a single whitespace line of a different length than provided |
|
632 | - a single whitespace line of a different length than provided | |
616 | by the autoindent (add or remove a space). |
|
633 | by the autoindent (add or remove a space). | |
617 |
|
634 | |||
618 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' |
|
635 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' | |
619 | module to better organize all readline-related functionality. |
|
636 | module to better organize all readline-related functionality. | |
620 | I've deleted FlexCompleter and put all completion clases here. |
|
637 | I've deleted FlexCompleter and put all completion clases here. | |
621 |
|
638 | |||
622 | * IPython/iplib.py (raw_input): improve indentation management. |
|
639 | * IPython/iplib.py (raw_input): improve indentation management. | |
623 | It is now possible to paste indented code with autoindent on, and |
|
640 | It is now possible to paste indented code with autoindent on, and | |
624 | the code is interpreted correctly (though it still looks bad on |
|
641 | the code is interpreted correctly (though it still looks bad on | |
625 | screen, due to the line-oriented nature of ipython). |
|
642 | screen, due to the line-oriented nature of ipython). | |
626 | (MagicCompleter.complete): change behavior so that a TAB key on an |
|
643 | (MagicCompleter.complete): change behavior so that a TAB key on an | |
627 | otherwise empty line actually inserts a tab, instead of completing |
|
644 | otherwise empty line actually inserts a tab, instead of completing | |
628 | on the entire global namespace. This makes it easier to use the |
|
645 | on the entire global namespace. This makes it easier to use the | |
629 | TAB key for indentation. After a request by Hans Meine |
|
646 | TAB key for indentation. After a request by Hans Meine | |
630 | <hans_meine-AT-gmx.net> |
|
647 | <hans_meine-AT-gmx.net> | |
631 | (_prefilter): add support so that typing plain 'exit' or 'quit' |
|
648 | (_prefilter): add support so that typing plain 'exit' or 'quit' | |
632 | does a sensible thing. Originally I tried to deviate as little as |
|
649 | does a sensible thing. Originally I tried to deviate as little as | |
633 | possible from the default python behavior, but even that one may |
|
650 | possible from the default python behavior, but even that one may | |
634 | change in this direction (thread on python-dev to that effect). |
|
651 | change in this direction (thread on python-dev to that effect). | |
635 | Regardless, ipython should do the right thing even if CPython's |
|
652 | Regardless, ipython should do the right thing even if CPython's | |
636 | '>>>' prompt doesn't. |
|
653 | '>>>' prompt doesn't. | |
637 | (InteractiveShell): removed subclassing code.InteractiveConsole |
|
654 | (InteractiveShell): removed subclassing code.InteractiveConsole | |
638 | class. By now we'd overridden just about all of its methods: I've |
|
655 | class. By now we'd overridden just about all of its methods: I've | |
639 | copied the remaining two over, and now ipython is a standalone |
|
656 | copied the remaining two over, and now ipython is a standalone | |
640 | class. This will provide a clearer picture for the chainsaw |
|
657 | class. This will provide a clearer picture for the chainsaw | |
641 | branch refactoring. |
|
658 | branch refactoring. | |
642 |
|
659 | |||
643 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> |
|
660 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> | |
644 |
|
661 | |||
645 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against |
|
662 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against | |
646 | failures for objects which break when dir() is called on them. |
|
663 | failures for objects which break when dir() is called on them. | |
647 |
|
664 | |||
648 | * IPython/FlexCompleter.py (Completer.__init__): Added support for |
|
665 | * IPython/FlexCompleter.py (Completer.__init__): Added support for | |
649 | distinct local and global namespaces in the completer API. This |
|
666 | distinct local and global namespaces in the completer API. This | |
650 | change allows us top properly handle completion with distinct |
|
667 | change allows us top properly handle completion with distinct | |
651 | scopes, including in embedded instances (this had never really |
|
668 | scopes, including in embedded instances (this had never really | |
652 | worked correctly). |
|
669 | worked correctly). | |
653 |
|
670 | |||
654 | Note: this introduces a change in the constructor for |
|
671 | Note: this introduces a change in the constructor for | |
655 | MagicCompleter, as a new global_namespace parameter is now the |
|
672 | MagicCompleter, as a new global_namespace parameter is now the | |
656 | second argument (the others were bumped one position). |
|
673 | second argument (the others were bumped one position). | |
657 |
|
674 | |||
658 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
675 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> | |
659 |
|
676 | |||
660 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
677 | * IPython/iplib.py (embed_mainloop): fix tab-completion in | |
661 | embedded instances (which can be done now thanks to Vivian's |
|
678 | embedded instances (which can be done now thanks to Vivian's | |
662 | frame-handling fixes for pdb). |
|
679 | frame-handling fixes for pdb). | |
663 | (InteractiveShell.__init__): Fix namespace handling problem in |
|
680 | (InteractiveShell.__init__): Fix namespace handling problem in | |
664 | embedded instances. We were overwriting __main__ unconditionally, |
|
681 | embedded instances. We were overwriting __main__ unconditionally, | |
665 | and this should only be done for 'full' (non-embedded) IPython; |
|
682 | and this should only be done for 'full' (non-embedded) IPython; | |
666 | embedded instances must respect the caller's __main__. Thanks to |
|
683 | embedded instances must respect the caller's __main__. Thanks to | |
667 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> |
|
684 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> | |
668 |
|
685 | |||
669 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
686 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
670 |
|
687 | |||
671 | * setup.py: added download_url to setup(). This registers the |
|
688 | * setup.py: added download_url to setup(). This registers the | |
672 | download address at PyPI, which is not only useful to humans |
|
689 | download address at PyPI, which is not only useful to humans | |
673 | browsing the site, but is also picked up by setuptools (the Eggs |
|
690 | browsing the site, but is also picked up by setuptools (the Eggs | |
674 | machinery). Thanks to Ville and R. Kern for the info/discussion |
|
691 | machinery). Thanks to Ville and R. Kern for the info/discussion | |
675 | on this. |
|
692 | on this. | |
676 |
|
693 | |||
677 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
694 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
678 |
|
695 | |||
679 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. |
|
696 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. | |
680 | This brings a lot of nice functionality to the pdb mode, which now |
|
697 | This brings a lot of nice functionality to the pdb mode, which now | |
681 | has tab-completion, syntax highlighting, and better stack handling |
|
698 | has tab-completion, syntax highlighting, and better stack handling | |
682 | than before. Many thanks to Vivian De Smedt |
|
699 | than before. Many thanks to Vivian De Smedt | |
683 | <vivian-AT-vdesmedt.com> for the original patches. |
|
700 | <vivian-AT-vdesmedt.com> for the original patches. | |
684 |
|
701 | |||
685 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
702 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> | |
686 |
|
703 | |||
687 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling |
|
704 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling | |
688 | sequence to consistently accept the banner argument. The |
|
705 | sequence to consistently accept the banner argument. The | |
689 | inconsistency was tripping SAGE, thanks to Gary Zablackis |
|
706 | inconsistency was tripping SAGE, thanks to Gary Zablackis | |
690 | <gzabl-AT-yahoo.com> for the report. |
|
707 | <gzabl-AT-yahoo.com> for the report. | |
691 |
|
708 | |||
692 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
709 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
693 |
|
710 | |||
694 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
711 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
695 | Fix bug where a naked 'alias' call in the ipythonrc file would |
|
712 | Fix bug where a naked 'alias' call in the ipythonrc file would | |
696 | cause a crash. Bug reported by Jorgen Stenarson. |
|
713 | cause a crash. Bug reported by Jorgen Stenarson. | |
697 |
|
714 | |||
698 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
715 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
699 |
|
716 | |||
700 | * IPython/ipmaker.py (make_IPython): cleanups which should improve |
|
717 | * IPython/ipmaker.py (make_IPython): cleanups which should improve | |
701 | startup time. |
|
718 | startup time. | |
702 |
|
719 | |||
703 | * IPython/iplib.py (runcode): my globals 'fix' for embedded |
|
720 | * IPython/iplib.py (runcode): my globals 'fix' for embedded | |
704 | instances had introduced a bug with globals in normal code. Now |
|
721 | instances had introduced a bug with globals in normal code. Now | |
705 | it's working in all cases. |
|
722 | it's working in all cases. | |
706 |
|
723 | |||
707 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and |
|
724 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and | |
708 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' |
|
725 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' | |
709 | has been introduced to set the default case sensitivity of the |
|
726 | has been introduced to set the default case sensitivity of the | |
710 | searches. Users can still select either mode at runtime on a |
|
727 | searches. Users can still select either mode at runtime on a | |
711 | per-search basis. |
|
728 | per-search basis. | |
712 |
|
729 | |||
713 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
730 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> | |
714 |
|
731 | |||
715 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of |
|
732 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of | |
716 | attributes in wildcard searches for subclasses. Modified version |
|
733 | attributes in wildcard searches for subclasses. Modified version | |
717 | of a patch by Jorgen. |
|
734 | of a patch by Jorgen. | |
718 |
|
735 | |||
719 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
736 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
720 |
|
737 | |||
721 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for |
|
738 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for | |
722 | embedded instances. I added a user_global_ns attribute to the |
|
739 | embedded instances. I added a user_global_ns attribute to the | |
723 | InteractiveShell class to handle this. |
|
740 | InteractiveShell class to handle this. | |
724 |
|
741 | |||
725 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
742 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
726 |
|
743 | |||
727 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to |
|
744 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to | |
728 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 |
|
745 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 | |
729 | (reported under win32, but may happen also in other platforms). |
|
746 | (reported under win32, but may happen also in other platforms). | |
730 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> |
|
747 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> | |
731 |
|
748 | |||
732 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
749 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
733 |
|
750 | |||
734 | * IPython/Magic.py (magic_psearch): new support for wildcard |
|
751 | * IPython/Magic.py (magic_psearch): new support for wildcard | |
735 | patterns. Now, typing ?a*b will list all names which begin with a |
|
752 | patterns. Now, typing ?a*b will list all names which begin with a | |
736 | and end in b, for example. The %psearch magic has full |
|
753 | and end in b, for example. The %psearch magic has full | |
737 | docstrings. Many thanks to Jörgen Stenarson |
|
754 | docstrings. Many thanks to Jörgen Stenarson | |
738 | <jorgen.stenarson-AT-bostream.nu>, author of the patches |
|
755 | <jorgen.stenarson-AT-bostream.nu>, author of the patches | |
739 | implementing this functionality. |
|
756 | implementing this functionality. | |
740 |
|
757 | |||
741 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
758 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
742 |
|
759 | |||
743 | * Manual: fixed long-standing annoyance of double-dashes (as in |
|
760 | * Manual: fixed long-standing annoyance of double-dashes (as in | |
744 | --prefix=~, for example) being stripped in the HTML version. This |
|
761 | --prefix=~, for example) being stripped in the HTML version. This | |
745 | is a latex2html bug, but a workaround was provided. Many thanks |
|
762 | is a latex2html bug, but a workaround was provided. Many thanks | |
746 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed |
|
763 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed | |
747 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball |
|
764 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball | |
748 | rolling. This seemingly small issue had tripped a number of users |
|
765 | rolling. This seemingly small issue had tripped a number of users | |
749 | when first installing, so I'm glad to see it gone. |
|
766 | when first installing, so I'm glad to see it gone. | |
750 |
|
767 | |||
751 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
768 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
752 |
|
769 | |||
753 | * IPython/Extensions/numeric_formats.py: fix missing import, |
|
770 | * IPython/Extensions/numeric_formats.py: fix missing import, | |
754 | reported by Stephen Walton. |
|
771 | reported by Stephen Walton. | |
755 |
|
772 | |||
756 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
773 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
757 |
|
774 | |||
758 | * IPython/demo.py: finish demo module, fully documented now. |
|
775 | * IPython/demo.py: finish demo module, fully documented now. | |
759 |
|
776 | |||
760 | * IPython/genutils.py (file_read): simple little utility to read a |
|
777 | * IPython/genutils.py (file_read): simple little utility to read a | |
761 | file and ensure it's closed afterwards. |
|
778 | file and ensure it's closed afterwards. | |
762 |
|
779 | |||
763 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
780 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
764 |
|
781 | |||
765 | * IPython/demo.py (Demo.__init__): added support for individually |
|
782 | * IPython/demo.py (Demo.__init__): added support for individually | |
766 | tagging blocks for automatic execution. |
|
783 | tagging blocks for automatic execution. | |
767 |
|
784 | |||
768 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing |
|
785 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing | |
769 | syntax-highlighted python sources, requested by John. |
|
786 | syntax-highlighted python sources, requested by John. | |
770 |
|
787 | |||
771 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
788 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> | |
772 |
|
789 | |||
773 | * IPython/demo.py (Demo.again): fix bug where again() blocks after |
|
790 | * IPython/demo.py (Demo.again): fix bug where again() blocks after | |
774 | finishing. |
|
791 | finishing. | |
775 |
|
792 | |||
776 | * IPython/genutils.py (shlex_split): moved from Magic to here, |
|
793 | * IPython/genutils.py (shlex_split): moved from Magic to here, | |
777 | where all 2.2 compatibility stuff lives. I needed it for demo.py. |
|
794 | where all 2.2 compatibility stuff lives. I needed it for demo.py. | |
778 |
|
795 | |||
779 | * IPython/demo.py (Demo.__init__): added support for silent |
|
796 | * IPython/demo.py (Demo.__init__): added support for silent | |
780 | blocks, improved marks as regexps, docstrings written. |
|
797 | blocks, improved marks as regexps, docstrings written. | |
781 | (Demo.__init__): better docstring, added support for sys.argv. |
|
798 | (Demo.__init__): better docstring, added support for sys.argv. | |
782 |
|
799 | |||
783 | * IPython/genutils.py (marquee): little utility used by the demo |
|
800 | * IPython/genutils.py (marquee): little utility used by the demo | |
784 | code, handy in general. |
|
801 | code, handy in general. | |
785 |
|
802 | |||
786 | * IPython/demo.py (Demo.__init__): new class for interactive |
|
803 | * IPython/demo.py (Demo.__init__): new class for interactive | |
787 | demos. Not documented yet, I just wrote it in a hurry for |
|
804 | demos. Not documented yet, I just wrote it in a hurry for | |
788 | scipy'05. Will docstring later. |
|
805 | scipy'05. Will docstring later. | |
789 |
|
806 | |||
790 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
807 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> | |
791 |
|
808 | |||
792 | * IPython/Shell.py (sigint_handler): Drastic simplification which |
|
809 | * IPython/Shell.py (sigint_handler): Drastic simplification which | |
793 | also seems to make Ctrl-C work correctly across threads! This is |
|
810 | also seems to make Ctrl-C work correctly across threads! This is | |
794 | so simple, that I can't beleive I'd missed it before. Needs more |
|
811 | so simple, that I can't beleive I'd missed it before. Needs more | |
795 | testing, though. |
|
812 | testing, though. | |
796 | (KBINT): Never mind, revert changes. I'm sure I'd tried something |
|
813 | (KBINT): Never mind, revert changes. I'm sure I'd tried something | |
797 | like this before... |
|
814 | like this before... | |
798 |
|
815 | |||
799 | * IPython/genutils.py (get_home_dir): add protection against |
|
816 | * IPython/genutils.py (get_home_dir): add protection against | |
800 | non-dirs in win32 registry. |
|
817 | non-dirs in win32 registry. | |
801 |
|
818 | |||
802 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix |
|
819 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix | |
803 | bug where dict was mutated while iterating (pysh crash). |
|
820 | bug where dict was mutated while iterating (pysh crash). | |
804 |
|
821 | |||
805 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> |
|
822 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> | |
806 |
|
823 | |||
807 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from |
|
824 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from | |
808 | spurious newlines added by this routine. After a report by |
|
825 | spurious newlines added by this routine. After a report by | |
809 | F. Mantegazza. |
|
826 | F. Mantegazza. | |
810 |
|
827 | |||
811 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
828 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> | |
812 |
|
829 | |||
813 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") |
|
830 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") | |
814 | calls. These were a leftover from the GTK 1.x days, and can cause |
|
831 | calls. These were a leftover from the GTK 1.x days, and can cause | |
815 | problems in certain cases (after a report by John Hunter). |
|
832 | problems in certain cases (after a report by John Hunter). | |
816 |
|
833 | |||
817 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if |
|
834 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if | |
818 | os.getcwd() fails at init time. Thanks to patch from David Remahl |
|
835 | os.getcwd() fails at init time. Thanks to patch from David Remahl | |
819 | <chmod007-AT-mac.com>. |
|
836 | <chmod007-AT-mac.com>. | |
820 | (InteractiveShell.__init__): prevent certain special magics from |
|
837 | (InteractiveShell.__init__): prevent certain special magics from | |
821 | being shadowed by aliases. Closes |
|
838 | being shadowed by aliases. Closes | |
822 | http://www.scipy.net/roundup/ipython/issue41. |
|
839 | http://www.scipy.net/roundup/ipython/issue41. | |
823 |
|
840 | |||
824 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
841 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
825 |
|
842 | |||
826 | * IPython/iplib.py (InteractiveShell.complete): Added new |
|
843 | * IPython/iplib.py (InteractiveShell.complete): Added new | |
827 | top-level completion method to expose the completion mechanism |
|
844 | top-level completion method to expose the completion mechanism | |
828 | beyond readline-based environments. |
|
845 | beyond readline-based environments. | |
829 |
|
846 | |||
830 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> |
|
847 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> | |
831 |
|
848 | |||
832 | * tools/ipsvnc (svnversion): fix svnversion capture. |
|
849 | * tools/ipsvnc (svnversion): fix svnversion capture. | |
833 |
|
850 | |||
834 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline |
|
851 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline | |
835 | attribute to self, which was missing. Before, it was set by a |
|
852 | attribute to self, which was missing. Before, it was set by a | |
836 | routine which in certain cases wasn't being called, so the |
|
853 | routine which in certain cases wasn't being called, so the | |
837 | instance could end up missing the attribute. This caused a crash. |
|
854 | instance could end up missing the attribute. This caused a crash. | |
838 | Closes http://www.scipy.net/roundup/ipython/issue40. |
|
855 | Closes http://www.scipy.net/roundup/ipython/issue40. | |
839 |
|
856 | |||
840 | 2005-08-16 Fernando Perez <fperez@colorado.edu> |
|
857 | 2005-08-16 Fernando Perez <fperez@colorado.edu> | |
841 |
|
858 | |||
842 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object |
|
859 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object | |
843 | contains non-string attribute. Closes |
|
860 | contains non-string attribute. Closes | |
844 | http://www.scipy.net/roundup/ipython/issue38. |
|
861 | http://www.scipy.net/roundup/ipython/issue38. | |
845 |
|
862 | |||
846 | 2005-08-14 Fernando Perez <fperez@colorado.edu> |
|
863 | 2005-08-14 Fernando Perez <fperez@colorado.edu> | |
847 |
|
864 | |||
848 | * tools/ipsvnc: Minor improvements, to add changeset info. |
|
865 | * tools/ipsvnc: Minor improvements, to add changeset info. | |
849 |
|
866 | |||
850 | 2005-08-12 Fernando Perez <fperez@colorado.edu> |
|
867 | 2005-08-12 Fernando Perez <fperez@colorado.edu> | |
851 |
|
868 | |||
852 | * IPython/iplib.py (runsource): remove self.code_to_run_src |
|
869 | * IPython/iplib.py (runsource): remove self.code_to_run_src | |
853 | attribute. I realized this is nothing more than |
|
870 | attribute. I realized this is nothing more than | |
854 | '\n'.join(self.buffer), and having the same data in two different |
|
871 | '\n'.join(self.buffer), and having the same data in two different | |
855 | places is just asking for synchronization bugs. This may impact |
|
872 | places is just asking for synchronization bugs. This may impact | |
856 | people who have custom exception handlers, so I need to warn |
|
873 | people who have custom exception handlers, so I need to warn | |
857 | ipython-dev about it (F. Mantegazza may use them). |
|
874 | ipython-dev about it (F. Mantegazza may use them). | |
858 |
|
875 | |||
859 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
876 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
860 |
|
877 | |||
861 | * IPython/genutils.py: fix 2.2 compatibility (generators) |
|
878 | * IPython/genutils.py: fix 2.2 compatibility (generators) | |
862 |
|
879 | |||
863 | 2005-07-18 Fernando Perez <fperez@colorado.edu> |
|
880 | 2005-07-18 Fernando Perez <fperez@colorado.edu> | |
864 |
|
881 | |||
865 | * IPython/genutils.py (get_home_dir): fix to help users with |
|
882 | * IPython/genutils.py (get_home_dir): fix to help users with | |
866 | invalid $HOME under win32. |
|
883 | invalid $HOME under win32. | |
867 |
|
884 | |||
868 | 2005-07-17 Fernando Perez <fperez@colorado.edu> |
|
885 | 2005-07-17 Fernando Perez <fperez@colorado.edu> | |
869 |
|
886 | |||
870 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove |
|
887 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove | |
871 | some old hacks and clean up a bit other routines; code should be |
|
888 | some old hacks and clean up a bit other routines; code should be | |
872 | simpler and a bit faster. |
|
889 | simpler and a bit faster. | |
873 |
|
890 | |||
874 | * IPython/iplib.py (interact): removed some last-resort attempts |
|
891 | * IPython/iplib.py (interact): removed some last-resort attempts | |
875 | to survive broken stdout/stderr. That code was only making it |
|
892 | to survive broken stdout/stderr. That code was only making it | |
876 | harder to abstract out the i/o (necessary for gui integration), |
|
893 | harder to abstract out the i/o (necessary for gui integration), | |
877 | and the crashes it could prevent were extremely rare in practice |
|
894 | and the crashes it could prevent were extremely rare in practice | |
878 | (besides being fully user-induced in a pretty violent manner). |
|
895 | (besides being fully user-induced in a pretty violent manner). | |
879 |
|
896 | |||
880 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. |
|
897 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. | |
881 | Nothing major yet, but the code is simpler to read; this should |
|
898 | Nothing major yet, but the code is simpler to read; this should | |
882 | make it easier to do more serious modifications in the future. |
|
899 | make it easier to do more serious modifications in the future. | |
883 |
|
900 | |||
884 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, |
|
901 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, | |
885 | which broke in .15 (thanks to a report by Ville). |
|
902 | which broke in .15 (thanks to a report by Ville). | |
886 |
|
903 | |||
887 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not |
|
904 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not | |
888 | be quite correct, I know next to nothing about unicode). This |
|
905 | be quite correct, I know next to nothing about unicode). This | |
889 | will allow unicode strings to be used in prompts, amongst other |
|
906 | will allow unicode strings to be used in prompts, amongst other | |
890 | cases. It also will prevent ipython from crashing when unicode |
|
907 | cases. It also will prevent ipython from crashing when unicode | |
891 | shows up unexpectedly in many places. If ascii encoding fails, we |
|
908 | shows up unexpectedly in many places. If ascii encoding fails, we | |
892 | assume utf_8. Currently the encoding is not a user-visible |
|
909 | assume utf_8. Currently the encoding is not a user-visible | |
893 | setting, though it could be made so if there is demand for it. |
|
910 | setting, though it could be made so if there is demand for it. | |
894 |
|
911 | |||
895 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. |
|
912 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. | |
896 |
|
913 | |||
897 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. |
|
914 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. | |
898 |
|
915 | |||
899 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. |
|
916 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. | |
900 |
|
917 | |||
901 | * IPython/genutils.py: Add 2.2 compatibility here, so all other |
|
918 | * IPython/genutils.py: Add 2.2 compatibility here, so all other | |
902 | code can work transparently for 2.2/2.3. |
|
919 | code can work transparently for 2.2/2.3. | |
903 |
|
920 | |||
904 | 2005-07-16 Fernando Perez <fperez@colorado.edu> |
|
921 | 2005-07-16 Fernando Perez <fperez@colorado.edu> | |
905 |
|
922 | |||
906 | * IPython/ultraTB.py (ExceptionColors): Make a global variable |
|
923 | * IPython/ultraTB.py (ExceptionColors): Make a global variable | |
907 | out of the color scheme table used for coloring exception |
|
924 | out of the color scheme table used for coloring exception | |
908 | tracebacks. This allows user code to add new schemes at runtime. |
|
925 | tracebacks. This allows user code to add new schemes at runtime. | |
909 | This is a minimally modified version of the patch at |
|
926 | This is a minimally modified version of the patch at | |
910 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw |
|
927 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw | |
911 | for the contribution. |
|
928 | for the contribution. | |
912 |
|
929 | |||
913 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a |
|
930 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a | |
914 | slightly modified version of the patch in |
|
931 | slightly modified version of the patch in | |
915 | http://www.scipy.net/roundup/ipython/issue34, which also allows me |
|
932 | http://www.scipy.net/roundup/ipython/issue34, which also allows me | |
916 | to remove the previous try/except solution (which was costlier). |
|
933 | to remove the previous try/except solution (which was costlier). | |
917 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. |
|
934 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. | |
918 |
|
935 | |||
919 | 2005-06-08 Fernando Perez <fperez@colorado.edu> |
|
936 | 2005-06-08 Fernando Perez <fperez@colorado.edu> | |
920 |
|
937 | |||
921 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
|
938 | * IPython/iplib.py (write/write_err): Add methods to abstract all | |
922 | I/O a bit more. |
|
939 | I/O a bit more. | |
923 |
|
940 | |||
924 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation |
|
941 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation | |
925 | warning, reported by Aric Hagberg, fix by JD Hunter. |
|
942 | warning, reported by Aric Hagberg, fix by JD Hunter. | |
926 |
|
943 | |||
927 | 2005-06-02 *** Released version 0.6.15 |
|
944 | 2005-06-02 *** Released version 0.6.15 | |
928 |
|
945 | |||
929 | 2005-06-01 Fernando Perez <fperez@colorado.edu> |
|
946 | 2005-06-01 Fernando Perez <fperez@colorado.edu> | |
930 |
|
947 | |||
931 | * IPython/iplib.py (MagicCompleter.file_matches): Fix |
|
948 | * IPython/iplib.py (MagicCompleter.file_matches): Fix | |
932 | tab-completion of filenames within open-quoted strings. Note that |
|
949 | tab-completion of filenames within open-quoted strings. Note that | |
933 | this requires that in ~/.ipython/ipythonrc, users change the |
|
950 | this requires that in ~/.ipython/ipythonrc, users change the | |
934 | readline delimiters configuration to read: |
|
951 | readline delimiters configuration to read: | |
935 |
|
952 | |||
936 | readline_remove_delims -/~ |
|
953 | readline_remove_delims -/~ | |
937 |
|
954 | |||
938 |
|
955 | |||
939 | 2005-05-31 *** Released version 0.6.14 |
|
956 | 2005-05-31 *** Released version 0.6.14 | |
940 |
|
957 | |||
941 | 2005-05-29 Fernando Perez <fperez@colorado.edu> |
|
958 | 2005-05-29 Fernando Perez <fperez@colorado.edu> | |
942 |
|
959 | |||
943 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks |
|
960 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks | |
944 | with files not on the filesystem. Reported by Eliyahu Sandler |
|
961 | with files not on the filesystem. Reported by Eliyahu Sandler | |
945 | <eli@gondolin.net> |
|
962 | <eli@gondolin.net> | |
946 |
|
963 | |||
947 | 2005-05-22 Fernando Perez <fperez@colorado.edu> |
|
964 | 2005-05-22 Fernando Perez <fperez@colorado.edu> | |
948 |
|
965 | |||
949 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. |
|
966 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. | |
950 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. |
|
967 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. | |
951 |
|
968 | |||
952 | 2005-05-19 Fernando Perez <fperez@colorado.edu> |
|
969 | 2005-05-19 Fernando Perez <fperez@colorado.edu> | |
953 |
|
970 | |||
954 | * IPython/iplib.py (safe_execfile): close a file which could be |
|
971 | * IPython/iplib.py (safe_execfile): close a file which could be | |
955 | left open (causing problems in win32, which locks open files). |
|
972 | left open (causing problems in win32, which locks open files). | |
956 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. |
|
973 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. | |
957 |
|
974 | |||
958 | 2005-05-18 Fernando Perez <fperez@colorado.edu> |
|
975 | 2005-05-18 Fernando Perez <fperez@colorado.edu> | |
959 |
|
976 | |||
960 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all |
|
977 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all | |
961 | keyword arguments correctly to safe_execfile(). |
|
978 | keyword arguments correctly to safe_execfile(). | |
962 |
|
979 | |||
963 | 2005-05-13 Fernando Perez <fperez@colorado.edu> |
|
980 | 2005-05-13 Fernando Perez <fperez@colorado.edu> | |
964 |
|
981 | |||
965 | * ipython.1: Added info about Qt to manpage, and threads warning |
|
982 | * ipython.1: Added info about Qt to manpage, and threads warning | |
966 | to usage page (invoked with --help). |
|
983 | to usage page (invoked with --help). | |
967 |
|
984 | |||
968 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added |
|
985 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added | |
969 | new matcher (it goes at the end of the priority list) to do |
|
986 | new matcher (it goes at the end of the priority list) to do | |
970 | tab-completion on named function arguments. Submitted by George |
|
987 | tab-completion on named function arguments. Submitted by George | |
971 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at |
|
988 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at | |
972 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html |
|
989 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html | |
973 | for more details. |
|
990 | for more details. | |
974 |
|
991 | |||
975 | * IPython/Magic.py (magic_run): Added new -e flag to ignore |
|
992 | * IPython/Magic.py (magic_run): Added new -e flag to ignore | |
976 | SystemExit exceptions in the script being run. Thanks to a report |
|
993 | SystemExit exceptions in the script being run. Thanks to a report | |
977 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this |
|
994 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this | |
978 | producing very annoying behavior when running unit tests. |
|
995 | producing very annoying behavior when running unit tests. | |
979 |
|
996 | |||
980 | 2005-05-12 Fernando Perez <fperez@colorado.edu> |
|
997 | 2005-05-12 Fernando Perez <fperez@colorado.edu> | |
981 |
|
998 | |||
982 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, |
|
999 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, | |
983 | which I'd broken (again) due to a changed regexp. In the process, |
|
1000 | which I'd broken (again) due to a changed regexp. In the process, | |
984 | added ';' as an escape to auto-quote the whole line without |
|
1001 | added ';' as an escape to auto-quote the whole line without | |
985 | splitting its arguments. Thanks to a report by Jerry McRae |
|
1002 | splitting its arguments. Thanks to a report by Jerry McRae | |
986 | <qrs0xyc02-AT-sneakemail.com>. |
|
1003 | <qrs0xyc02-AT-sneakemail.com>. | |
987 |
|
1004 | |||
988 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but |
|
1005 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but | |
989 | possible crashes caused by a TokenError. Reported by Ed Schofield |
|
1006 | possible crashes caused by a TokenError. Reported by Ed Schofield | |
990 | <schofield-AT-ftw.at>. |
|
1007 | <schofield-AT-ftw.at>. | |
991 |
|
1008 | |||
992 | 2005-05-06 Fernando Perez <fperez@colorado.edu> |
|
1009 | 2005-05-06 Fernando Perez <fperez@colorado.edu> | |
993 |
|
1010 | |||
994 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. |
|
1011 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. | |
995 |
|
1012 | |||
996 | 2005-04-29 Fernando Perez <fperez@colorado.edu> |
|
1013 | 2005-04-29 Fernando Perez <fperez@colorado.edu> | |
997 |
|
1014 | |||
998 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière |
|
1015 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière | |
999 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin |
|
1016 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin | |
1000 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option |
|
1017 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option | |
1001 | which provides support for Qt interactive usage (similar to the |
|
1018 | which provides support for Qt interactive usage (similar to the | |
1002 | existing one for WX and GTK). This had been often requested. |
|
1019 | existing one for WX and GTK). This had been often requested. | |
1003 |
|
1020 | |||
1004 | 2005-04-14 *** Released version 0.6.13 |
|
1021 | 2005-04-14 *** Released version 0.6.13 | |
1005 |
|
1022 | |||
1006 | 2005-04-08 Fernando Perez <fperez@colorado.edu> |
|
1023 | 2005-04-08 Fernando Perez <fperez@colorado.edu> | |
1007 |
|
1024 | |||
1008 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation |
|
1025 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation | |
1009 | from _ofind, which gets called on almost every input line. Now, |
|
1026 | from _ofind, which gets called on almost every input line. Now, | |
1010 | we only try to get docstrings if they are actually going to be |
|
1027 | we only try to get docstrings if they are actually going to be | |
1011 | used (the overhead of fetching unnecessary docstrings can be |
|
1028 | used (the overhead of fetching unnecessary docstrings can be | |
1012 | noticeable for certain objects, such as Pyro proxies). |
|
1029 | noticeable for certain objects, such as Pyro proxies). | |
1013 |
|
1030 | |||
1014 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API |
|
1031 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API | |
1015 | for completers. For some reason I had been passing them the state |
|
1032 | for completers. For some reason I had been passing them the state | |
1016 | variable, which completers never actually need, and was in |
|
1033 | variable, which completers never actually need, and was in | |
1017 | conflict with the rlcompleter API. Custom completers ONLY need to |
|
1034 | conflict with the rlcompleter API. Custom completers ONLY need to | |
1018 | take the text parameter. |
|
1035 | take the text parameter. | |
1019 |
|
1036 | |||
1020 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics |
|
1037 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics | |
1021 | work correctly in pysh. I've also moved all the logic which used |
|
1038 | work correctly in pysh. I've also moved all the logic which used | |
1022 | to be in pysh.py here, which will prevent problems with future |
|
1039 | to be in pysh.py here, which will prevent problems with future | |
1023 | upgrades. However, this time I must warn users to update their |
|
1040 | upgrades. However, this time I must warn users to update their | |
1024 | pysh profile to include the line |
|
1041 | pysh profile to include the line | |
1025 |
|
1042 | |||
1026 | import_all IPython.Extensions.InterpreterExec |
|
1043 | import_all IPython.Extensions.InterpreterExec | |
1027 |
|
1044 | |||
1028 | because otherwise things won't work for them. They MUST also |
|
1045 | because otherwise things won't work for them. They MUST also | |
1029 | delete pysh.py and the line |
|
1046 | delete pysh.py and the line | |
1030 |
|
1047 | |||
1031 | execfile pysh.py |
|
1048 | execfile pysh.py | |
1032 |
|
1049 | |||
1033 | from their ipythonrc-pysh. |
|
1050 | from their ipythonrc-pysh. | |
1034 |
|
1051 | |||
1035 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more |
|
1052 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more | |
1036 | robust in the face of objects whose dir() returns non-strings |
|
1053 | robust in the face of objects whose dir() returns non-strings | |
1037 | (which it shouldn't, but some broken libs like ITK do). Thanks to |
|
1054 | (which it shouldn't, but some broken libs like ITK do). Thanks to | |
1038 | a patch by John Hunter (implemented differently, though). Also |
|
1055 | a patch by John Hunter (implemented differently, though). Also | |
1039 | minor improvements by using .extend instead of + on lists. |
|
1056 | minor improvements by using .extend instead of + on lists. | |
1040 |
|
1057 | |||
1041 | * pysh.py: |
|
1058 | * pysh.py: | |
1042 |
|
1059 | |||
1043 | 2005-04-06 Fernando Perez <fperez@colorado.edu> |
|
1060 | 2005-04-06 Fernando Perez <fperez@colorado.edu> | |
1044 |
|
1061 | |||
1045 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on |
|
1062 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on | |
1046 | by default, so that all users benefit from it. Those who don't |
|
1063 | by default, so that all users benefit from it. Those who don't | |
1047 | want it can still turn it off. |
|
1064 | want it can still turn it off. | |
1048 |
|
1065 | |||
1049 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the |
|
1066 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the | |
1050 | config file, I'd forgotten about this, so users were getting it |
|
1067 | config file, I'd forgotten about this, so users were getting it | |
1051 | off by default. |
|
1068 | off by default. | |
1052 |
|
1069 | |||
1053 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for |
|
1070 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for | |
1054 | consistency. Now magics can be called in multiline statements, |
|
1071 | consistency. Now magics can be called in multiline statements, | |
1055 | and python variables can be expanded in magic calls via $var. |
|
1072 | and python variables can be expanded in magic calls via $var. | |
1056 | This makes the magic system behave just like aliases or !system |
|
1073 | This makes the magic system behave just like aliases or !system | |
1057 | calls. |
|
1074 | calls. | |
1058 |
|
1075 | |||
1059 | 2005-03-28 Fernando Perez <fperez@colorado.edu> |
|
1076 | 2005-03-28 Fernando Perez <fperez@colorado.edu> | |
1060 |
|
1077 | |||
1061 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of |
|
1078 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of | |
1062 | expensive string additions for building command. Add support for |
|
1079 | expensive string additions for building command. Add support for | |
1063 | trailing ';' when autocall is used. |
|
1080 | trailing ';' when autocall is used. | |
1064 |
|
1081 | |||
1065 | 2005-03-26 Fernando Perez <fperez@colorado.edu> |
|
1082 | 2005-03-26 Fernando Perez <fperez@colorado.edu> | |
1066 |
|
1083 | |||
1067 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. |
|
1084 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. | |
1068 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make |
|
1085 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make | |
1069 | ipython.el robust against prompts with any number of spaces |
|
1086 | ipython.el robust against prompts with any number of spaces | |
1070 | (including 0) after the ':' character. |
|
1087 | (including 0) after the ':' character. | |
1071 |
|
1088 | |||
1072 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in |
|
1089 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in | |
1073 | continuation prompt, which misled users to think the line was |
|
1090 | continuation prompt, which misled users to think the line was | |
1074 | already indented. Closes debian Bug#300847, reported to me by |
|
1091 | already indented. Closes debian Bug#300847, reported to me by | |
1075 | Norbert Tretkowski <tretkowski-AT-inittab.de>. |
|
1092 | Norbert Tretkowski <tretkowski-AT-inittab.de>. | |
1076 |
|
1093 | |||
1077 | 2005-03-23 Fernando Perez <fperez@colorado.edu> |
|
1094 | 2005-03-23 Fernando Perez <fperez@colorado.edu> | |
1078 |
|
1095 | |||
1079 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are |
|
1096 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are | |
1080 | properly aligned if they have embedded newlines. |
|
1097 | properly aligned if they have embedded newlines. | |
1081 |
|
1098 | |||
1082 | * IPython/iplib.py (runlines): Add a public method to expose |
|
1099 | * IPython/iplib.py (runlines): Add a public method to expose | |
1083 | IPython's code execution machinery, so that users can run strings |
|
1100 | IPython's code execution machinery, so that users can run strings | |
1084 | as if they had been typed at the prompt interactively. |
|
1101 | as if they had been typed at the prompt interactively. | |
1085 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ |
|
1102 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ | |
1086 | methods which can call the system shell, but with python variable |
|
1103 | methods which can call the system shell, but with python variable | |
1087 | expansion. The three such methods are: __IPYTHON__.system, |
|
1104 | expansion. The three such methods are: __IPYTHON__.system, | |
1088 | .getoutput and .getoutputerror. These need to be documented in a |
|
1105 | .getoutput and .getoutputerror. These need to be documented in a | |
1089 | 'public API' section (to be written) of the manual. |
|
1106 | 'public API' section (to be written) of the manual. | |
1090 |
|
1107 | |||
1091 | 2005-03-20 Fernando Perez <fperez@colorado.edu> |
|
1108 | 2005-03-20 Fernando Perez <fperez@colorado.edu> | |
1092 |
|
1109 | |||
1093 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system |
|
1110 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system | |
1094 | for custom exception handling. This is quite powerful, and it |
|
1111 | for custom exception handling. This is quite powerful, and it | |
1095 | allows for user-installable exception handlers which can trap |
|
1112 | allows for user-installable exception handlers which can trap | |
1096 | custom exceptions at runtime and treat them separately from |
|
1113 | custom exceptions at runtime and treat them separately from | |
1097 | IPython's default mechanisms. At the request of Frédéric |
|
1114 | IPython's default mechanisms. At the request of Frédéric | |
1098 | Mantegazza <mantegazza-AT-ill.fr>. |
|
1115 | Mantegazza <mantegazza-AT-ill.fr>. | |
1099 | (InteractiveShell.set_custom_completer): public API function to |
|
1116 | (InteractiveShell.set_custom_completer): public API function to | |
1100 | add new completers at runtime. |
|
1117 | add new completers at runtime. | |
1101 |
|
1118 | |||
1102 | 2005-03-19 Fernando Perez <fperez@colorado.edu> |
|
1119 | 2005-03-19 Fernando Perez <fperez@colorado.edu> | |
1103 |
|
1120 | |||
1104 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to |
|
1121 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to | |
1105 | allow objects which provide their docstrings via non-standard |
|
1122 | allow objects which provide their docstrings via non-standard | |
1106 | mechanisms (like Pyro proxies) to still be inspected by ipython's |
|
1123 | mechanisms (like Pyro proxies) to still be inspected by ipython's | |
1107 | ? system. |
|
1124 | ? system. | |
1108 |
|
1125 | |||
1109 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e |
|
1126 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e | |
1110 | automatic capture system. I tried quite hard to make it work |
|
1127 | automatic capture system. I tried quite hard to make it work | |
1111 | reliably, and simply failed. I tried many combinations with the |
|
1128 | reliably, and simply failed. I tried many combinations with the | |
1112 | subprocess module, but eventually nothing worked in all needed |
|
1129 | subprocess module, but eventually nothing worked in all needed | |
1113 | cases (not blocking stdin for the child, duplicating stdout |
|
1130 | cases (not blocking stdin for the child, duplicating stdout | |
1114 | without blocking, etc). The new %sc/%sx still do capture to these |
|
1131 | without blocking, etc). The new %sc/%sx still do capture to these | |
1115 | magical list/string objects which make shell use much more |
|
1132 | magical list/string objects which make shell use much more | |
1116 | conveninent, so not all is lost. |
|
1133 | conveninent, so not all is lost. | |
1117 |
|
1134 | |||
1118 | XXX - FIX MANUAL for the change above! |
|
1135 | XXX - FIX MANUAL for the change above! | |
1119 |
|
1136 | |||
1120 | (runsource): I copied code.py's runsource() into ipython to modify |
|
1137 | (runsource): I copied code.py's runsource() into ipython to modify | |
1121 | it a bit. Now the code object and source to be executed are |
|
1138 | it a bit. Now the code object and source to be executed are | |
1122 | stored in ipython. This makes this info accessible to third-party |
|
1139 | stored in ipython. This makes this info accessible to third-party | |
1123 | tools, like custom exception handlers. After a request by Frédéric |
|
1140 | tools, like custom exception handlers. After a request by Frédéric | |
1124 | Mantegazza <mantegazza-AT-ill.fr>. |
|
1141 | Mantegazza <mantegazza-AT-ill.fr>. | |
1125 |
|
1142 | |||
1126 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to |
|
1143 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to | |
1127 | history-search via readline (like C-p/C-n). I'd wanted this for a |
|
1144 | history-search via readline (like C-p/C-n). I'd wanted this for a | |
1128 | long time, but only recently found out how to do it. For users |
|
1145 | long time, but only recently found out how to do it. For users | |
1129 | who already have their ipythonrc files made and want this, just |
|
1146 | who already have their ipythonrc files made and want this, just | |
1130 | add: |
|
1147 | add: | |
1131 |
|
1148 | |||
1132 | readline_parse_and_bind "\e[A": history-search-backward |
|
1149 | readline_parse_and_bind "\e[A": history-search-backward | |
1133 | readline_parse_and_bind "\e[B": history-search-forward |
|
1150 | readline_parse_and_bind "\e[B": history-search-forward | |
1134 |
|
1151 | |||
1135 | 2005-03-18 Fernando Perez <fperez@colorado.edu> |
|
1152 | 2005-03-18 Fernando Perez <fperez@colorado.edu> | |
1136 |
|
1153 | |||
1137 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy |
|
1154 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy | |
1138 | LSString and SList classes which allow transparent conversions |
|
1155 | LSString and SList classes which allow transparent conversions | |
1139 | between list mode and whitespace-separated string. |
|
1156 | between list mode and whitespace-separated string. | |
1140 | (magic_r): Fix recursion problem in %r. |
|
1157 | (magic_r): Fix recursion problem in %r. | |
1141 |
|
1158 | |||
1142 | * IPython/genutils.py (LSString): New class to be used for |
|
1159 | * IPython/genutils.py (LSString): New class to be used for | |
1143 | automatic storage of the results of all alias/system calls in _o |
|
1160 | automatic storage of the results of all alias/system calls in _o | |
1144 | and _e (stdout/err). These provide a .l/.list attribute which |
|
1161 | and _e (stdout/err). These provide a .l/.list attribute which | |
1145 | does automatic splitting on newlines. This means that for most |
|
1162 | does automatic splitting on newlines. This means that for most | |
1146 | uses, you'll never need to do capturing of output with %sc/%sx |
|
1163 | uses, you'll never need to do capturing of output with %sc/%sx | |
1147 | anymore, since ipython keeps this always done for you. Note that |
|
1164 | anymore, since ipython keeps this always done for you. Note that | |
1148 | only the LAST results are stored, the _o/e variables are |
|
1165 | only the LAST results are stored, the _o/e variables are | |
1149 | overwritten on each call. If you need to save their contents |
|
1166 | overwritten on each call. If you need to save their contents | |
1150 | further, simply bind them to any other name. |
|
1167 | further, simply bind them to any other name. | |
1151 |
|
1168 | |||
1152 | 2005-03-17 Fernando Perez <fperez@colorado.edu> |
|
1169 | 2005-03-17 Fernando Perez <fperez@colorado.edu> | |
1153 |
|
1170 | |||
1154 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for |
|
1171 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for | |
1155 | prompt namespace handling. |
|
1172 | prompt namespace handling. | |
1156 |
|
1173 | |||
1157 | 2005-03-16 Fernando Perez <fperez@colorado.edu> |
|
1174 | 2005-03-16 Fernando Perez <fperez@colorado.edu> | |
1158 |
|
1175 | |||
1159 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and |
|
1176 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and | |
1160 | classic prompts to be '>>> ' (final space was missing, and it |
|
1177 | classic prompts to be '>>> ' (final space was missing, and it | |
1161 | trips the emacs python mode). |
|
1178 | trips the emacs python mode). | |
1162 | (BasePrompt.__str__): Added safe support for dynamic prompt |
|
1179 | (BasePrompt.__str__): Added safe support for dynamic prompt | |
1163 | strings. Now you can set your prompt string to be '$x', and the |
|
1180 | strings. Now you can set your prompt string to be '$x', and the | |
1164 | value of x will be printed from your interactive namespace. The |
|
1181 | value of x will be printed from your interactive namespace. The | |
1165 | interpolation syntax includes the full Itpl support, so |
|
1182 | interpolation syntax includes the full Itpl support, so | |
1166 | ${foo()+x+bar()} is a valid prompt string now, and the function |
|
1183 | ${foo()+x+bar()} is a valid prompt string now, and the function | |
1167 | calls will be made at runtime. |
|
1184 | calls will be made at runtime. | |
1168 |
|
1185 | |||
1169 | 2005-03-15 Fernando Perez <fperez@colorado.edu> |
|
1186 | 2005-03-15 Fernando Perez <fperez@colorado.edu> | |
1170 |
|
1187 | |||
1171 | * IPython/Magic.py (magic_history): renamed %hist to %history, to |
|
1188 | * IPython/Magic.py (magic_history): renamed %hist to %history, to | |
1172 | avoid name clashes in pylab. %hist still works, it just forwards |
|
1189 | avoid name clashes in pylab. %hist still works, it just forwards | |
1173 | the call to %history. |
|
1190 | the call to %history. | |
1174 |
|
1191 | |||
1175 | 2005-03-02 *** Released version 0.6.12 |
|
1192 | 2005-03-02 *** Released version 0.6.12 | |
1176 |
|
1193 | |||
1177 | 2005-03-02 Fernando Perez <fperez@colorado.edu> |
|
1194 | 2005-03-02 Fernando Perez <fperez@colorado.edu> | |
1178 |
|
1195 | |||
1179 | * IPython/iplib.py (handle_magic): log magic calls properly as |
|
1196 | * IPython/iplib.py (handle_magic): log magic calls properly as | |
1180 | ipmagic() function calls. |
|
1197 | ipmagic() function calls. | |
1181 |
|
1198 | |||
1182 | * IPython/Magic.py (magic_time): Improved %time to support |
|
1199 | * IPython/Magic.py (magic_time): Improved %time to support | |
1183 | statements and provide wall-clock as well as CPU time. |
|
1200 | statements and provide wall-clock as well as CPU time. | |
1184 |
|
1201 | |||
1185 | 2005-02-27 Fernando Perez <fperez@colorado.edu> |
|
1202 | 2005-02-27 Fernando Perez <fperez@colorado.edu> | |
1186 |
|
1203 | |||
1187 | * IPython/hooks.py: New hooks module, to expose user-modifiable |
|
1204 | * IPython/hooks.py: New hooks module, to expose user-modifiable | |
1188 | IPython functionality in a clean manner. For now only the editor |
|
1205 | IPython functionality in a clean manner. For now only the editor | |
1189 | hook is actually written, and other thigns which I intend to turn |
|
1206 | hook is actually written, and other thigns which I intend to turn | |
1190 | into proper hooks aren't yet there. The display and prefilter |
|
1207 | into proper hooks aren't yet there. The display and prefilter | |
1191 | stuff, for example, should be hooks. But at least now the |
|
1208 | stuff, for example, should be hooks. But at least now the | |
1192 | framework is in place, and the rest can be moved here with more |
|
1209 | framework is in place, and the rest can be moved here with more | |
1193 | time later. IPython had had a .hooks variable for a long time for |
|
1210 | time later. IPython had had a .hooks variable for a long time for | |
1194 | this purpose, but I'd never actually used it for anything. |
|
1211 | this purpose, but I'd never actually used it for anything. | |
1195 |
|
1212 | |||
1196 | 2005-02-26 Fernando Perez <fperez@colorado.edu> |
|
1213 | 2005-02-26 Fernando Perez <fperez@colorado.edu> | |
1197 |
|
1214 | |||
1198 | * IPython/ipmaker.py (make_IPython): make the default ipython |
|
1215 | * IPython/ipmaker.py (make_IPython): make the default ipython | |
1199 | directory be called _ipython under win32, to follow more the |
|
1216 | directory be called _ipython under win32, to follow more the | |
1200 | naming peculiarities of that platform (where buggy software like |
|
1217 | naming peculiarities of that platform (where buggy software like | |
1201 | Visual Sourcesafe breaks with .named directories). Reported by |
|
1218 | Visual Sourcesafe breaks with .named directories). Reported by | |
1202 | Ville Vainio. |
|
1219 | Ville Vainio. | |
1203 |
|
1220 | |||
1204 | 2005-02-23 Fernando Perez <fperez@colorado.edu> |
|
1221 | 2005-02-23 Fernando Perez <fperez@colorado.edu> | |
1205 |
|
1222 | |||
1206 | * IPython/iplib.py (InteractiveShell.__init__): removed a few |
|
1223 | * IPython/iplib.py (InteractiveShell.__init__): removed a few | |
1207 | auto_aliases for win32 which were causing problems. Users can |
|
1224 | auto_aliases for win32 which were causing problems. Users can | |
1208 | define the ones they personally like. |
|
1225 | define the ones they personally like. | |
1209 |
|
1226 | |||
1210 | 2005-02-21 Fernando Perez <fperez@colorado.edu> |
|
1227 | 2005-02-21 Fernando Perez <fperez@colorado.edu> | |
1211 |
|
1228 | |||
1212 | * IPython/Magic.py (magic_time): new magic to time execution of |
|
1229 | * IPython/Magic.py (magic_time): new magic to time execution of | |
1213 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. |
|
1230 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. | |
1214 |
|
1231 | |||
1215 | 2005-02-19 Fernando Perez <fperez@colorado.edu> |
|
1232 | 2005-02-19 Fernando Perez <fperez@colorado.edu> | |
1216 |
|
1233 | |||
1217 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings |
|
1234 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings | |
1218 | into keys (for prompts, for example). |
|
1235 | into keys (for prompts, for example). | |
1219 |
|
1236 | |||
1220 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty |
|
1237 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty | |
1221 | prompts in case users want them. This introduces a small behavior |
|
1238 | prompts in case users want them. This introduces a small behavior | |
1222 | change: ipython does not automatically add a space to all prompts |
|
1239 | change: ipython does not automatically add a space to all prompts | |
1223 | anymore. To get the old prompts with a space, users should add it |
|
1240 | anymore. To get the old prompts with a space, users should add it | |
1224 | manually to their ipythonrc file, so for example prompt_in1 should |
|
1241 | manually to their ipythonrc file, so for example prompt_in1 should | |
1225 | now read 'In [\#]: ' instead of 'In [\#]:'. |
|
1242 | now read 'In [\#]: ' instead of 'In [\#]:'. | |
1226 | (BasePrompt.__init__): New option prompts_pad_left (only in rc |
|
1243 | (BasePrompt.__init__): New option prompts_pad_left (only in rc | |
1227 | file) to control left-padding of secondary prompts. |
|
1244 | file) to control left-padding of secondary prompts. | |
1228 |
|
1245 | |||
1229 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if |
|
1246 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if | |
1230 | the profiler can't be imported. Fix for Debian, which removed |
|
1247 | the profiler can't be imported. Fix for Debian, which removed | |
1231 | profile.py because of License issues. I applied a slightly |
|
1248 | profile.py because of License issues. I applied a slightly | |
1232 | modified version of the original Debian patch at |
|
1249 | modified version of the original Debian patch at | |
1233 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. |
|
1250 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. | |
1234 |
|
1251 | |||
1235 | 2005-02-17 Fernando Perez <fperez@colorado.edu> |
|
1252 | 2005-02-17 Fernando Perez <fperez@colorado.edu> | |
1236 |
|
1253 | |||
1237 | * IPython/genutils.py (native_line_ends): Fix bug which would |
|
1254 | * IPython/genutils.py (native_line_ends): Fix bug which would | |
1238 | cause improper line-ends under win32 b/c I was not opening files |
|
1255 | cause improper line-ends under win32 b/c I was not opening files | |
1239 | in binary mode. Bug report and fix thanks to Ville. |
|
1256 | in binary mode. Bug report and fix thanks to Ville. | |
1240 |
|
1257 | |||
1241 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when |
|
1258 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when | |
1242 | trying to catch spurious foo[1] autocalls. My fix actually broke |
|
1259 | trying to catch spurious foo[1] autocalls. My fix actually broke | |
1243 | ',/' autoquote/call with explicit escape (bad regexp). |
|
1260 | ',/' autoquote/call with explicit escape (bad regexp). | |
1244 |
|
1261 | |||
1245 | 2005-02-15 *** Released version 0.6.11 |
|
1262 | 2005-02-15 *** Released version 0.6.11 | |
1246 |
|
1263 | |||
1247 | 2005-02-14 Fernando Perez <fperez@colorado.edu> |
|
1264 | 2005-02-14 Fernando Perez <fperez@colorado.edu> | |
1248 |
|
1265 | |||
1249 | * IPython/background_jobs.py: New background job management |
|
1266 | * IPython/background_jobs.py: New background job management | |
1250 | subsystem. This is implemented via a new set of classes, and |
|
1267 | subsystem. This is implemented via a new set of classes, and | |
1251 | IPython now provides a builtin 'jobs' object for background job |
|
1268 | IPython now provides a builtin 'jobs' object for background job | |
1252 | execution. A convenience %bg magic serves as a lightweight |
|
1269 | execution. A convenience %bg magic serves as a lightweight | |
1253 | frontend for starting the more common type of calls. This was |
|
1270 | frontend for starting the more common type of calls. This was | |
1254 | inspired by discussions with B. Granger and the BackgroundCommand |
|
1271 | inspired by discussions with B. Granger and the BackgroundCommand | |
1255 | class described in the book Python Scripting for Computational |
|
1272 | class described in the book Python Scripting for Computational | |
1256 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting |
|
1273 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting | |
1257 | (although ultimately no code from this text was used, as IPython's |
|
1274 | (although ultimately no code from this text was used, as IPython's | |
1258 | system is a separate implementation). |
|
1275 | system is a separate implementation). | |
1259 |
|
1276 | |||
1260 | * IPython/iplib.py (MagicCompleter.python_matches): add new option |
|
1277 | * IPython/iplib.py (MagicCompleter.python_matches): add new option | |
1261 | to control the completion of single/double underscore names |
|
1278 | to control the completion of single/double underscore names | |
1262 | separately. As documented in the example ipytonrc file, the |
|
1279 | separately. As documented in the example ipytonrc file, the | |
1263 | readline_omit__names variable can now be set to 2, to omit even |
|
1280 | readline_omit__names variable can now be set to 2, to omit even | |
1264 | single underscore names. Thanks to a patch by Brian Wong |
|
1281 | single underscore names. Thanks to a patch by Brian Wong | |
1265 | <BrianWong-AT-AirgoNetworks.Com>. |
|
1282 | <BrianWong-AT-AirgoNetworks.Com>. | |
1266 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to |
|
1283 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to | |
1267 | be autocalled as foo([1]) if foo were callable. A problem for |
|
1284 | be autocalled as foo([1]) if foo were callable. A problem for | |
1268 | things which are both callable and implement __getitem__. |
|
1285 | things which are both callable and implement __getitem__. | |
1269 | (init_readline): Fix autoindentation for win32. Thanks to a patch |
|
1286 | (init_readline): Fix autoindentation for win32. Thanks to a patch | |
1270 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. |
|
1287 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. | |
1271 |
|
1288 | |||
1272 | 2005-02-12 Fernando Perez <fperez@colorado.edu> |
|
1289 | 2005-02-12 Fernando Perez <fperez@colorado.edu> | |
1273 |
|
1290 | |||
1274 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps |
|
1291 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps | |
1275 | which I had written long ago to sort out user error messages which |
|
1292 | which I had written long ago to sort out user error messages which | |
1276 | may occur during startup. This seemed like a good idea initially, |
|
1293 | may occur during startup. This seemed like a good idea initially, | |
1277 | but it has proven a disaster in retrospect. I don't want to |
|
1294 | but it has proven a disaster in retrospect. I don't want to | |
1278 | change much code for now, so my fix is to set the internal 'debug' |
|
1295 | change much code for now, so my fix is to set the internal 'debug' | |
1279 | flag to true everywhere, whose only job was precisely to control |
|
1296 | flag to true everywhere, whose only job was precisely to control | |
1280 | this subsystem. This closes issue 28 (as well as avoiding all |
|
1297 | this subsystem. This closes issue 28 (as well as avoiding all | |
1281 | sorts of strange hangups which occur from time to time). |
|
1298 | sorts of strange hangups which occur from time to time). | |
1282 |
|
1299 | |||
1283 | 2005-02-07 Fernando Perez <fperez@colorado.edu> |
|
1300 | 2005-02-07 Fernando Perez <fperez@colorado.edu> | |
1284 |
|
1301 | |||
1285 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the |
|
1302 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the | |
1286 | previous call produced a syntax error. |
|
1303 | previous call produced a syntax error. | |
1287 |
|
1304 | |||
1288 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
1305 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
1289 | classes without constructor. |
|
1306 | classes without constructor. | |
1290 |
|
1307 | |||
1291 | 2005-02-06 Fernando Perez <fperez@colorado.edu> |
|
1308 | 2005-02-06 Fernando Perez <fperez@colorado.edu> | |
1292 |
|
1309 | |||
1293 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of |
|
1310 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of | |
1294 | completions with the results of each matcher, so we return results |
|
1311 | completions with the results of each matcher, so we return results | |
1295 | to the user from all namespaces. This breaks with ipython |
|
1312 | to the user from all namespaces. This breaks with ipython | |
1296 | tradition, but I think it's a nicer behavior. Now you get all |
|
1313 | tradition, but I think it's a nicer behavior. Now you get all | |
1297 | possible completions listed, from all possible namespaces (python, |
|
1314 | possible completions listed, from all possible namespaces (python, | |
1298 | filesystem, magics...) After a request by John Hunter |
|
1315 | filesystem, magics...) After a request by John Hunter | |
1299 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
1316 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
1300 |
|
1317 | |||
1301 | 2005-02-05 Fernando Perez <fperez@colorado.edu> |
|
1318 | 2005-02-05 Fernando Perez <fperez@colorado.edu> | |
1302 |
|
1319 | |||
1303 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if |
|
1320 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if | |
1304 | the call had quote characters in it (the quotes were stripped). |
|
1321 | the call had quote characters in it (the quotes were stripped). | |
1305 |
|
1322 | |||
1306 | 2005-01-31 Fernando Perez <fperez@colorado.edu> |
|
1323 | 2005-01-31 Fernando Perez <fperez@colorado.edu> | |
1307 |
|
1324 | |||
1308 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on |
|
1325 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on | |
1309 | Itpl.itpl() to make the code more robust against psyco |
|
1326 | Itpl.itpl() to make the code more robust against psyco | |
1310 | optimizations. |
|
1327 | optimizations. | |
1311 |
|
1328 | |||
1312 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead |
|
1329 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead | |
1313 | of causing an exception. Quicker, cleaner. |
|
1330 | of causing an exception. Quicker, cleaner. | |
1314 |
|
1331 | |||
1315 | 2005-01-28 Fernando Perez <fperez@colorado.edu> |
|
1332 | 2005-01-28 Fernando Perez <fperez@colorado.edu> | |
1316 |
|
1333 | |||
1317 | * scripts/ipython_win_post_install.py (install): hardcode |
|
1334 | * scripts/ipython_win_post_install.py (install): hardcode | |
1318 | sys.prefix+'python.exe' as the executable path. It turns out that |
|
1335 | sys.prefix+'python.exe' as the executable path. It turns out that | |
1319 | during the post-installation run, sys.executable resolves to the |
|
1336 | during the post-installation run, sys.executable resolves to the | |
1320 | name of the binary installer! I should report this as a distutils |
|
1337 | name of the binary installer! I should report this as a distutils | |
1321 | bug, I think. I updated the .10 release with this tiny fix, to |
|
1338 | bug, I think. I updated the .10 release with this tiny fix, to | |
1322 | avoid annoying the lists further. |
|
1339 | avoid annoying the lists further. | |
1323 |
|
1340 | |||
1324 | 2005-01-27 *** Released version 0.6.10 |
|
1341 | 2005-01-27 *** Released version 0.6.10 | |
1325 |
|
1342 | |||
1326 | 2005-01-27 Fernando Perez <fperez@colorado.edu> |
|
1343 | 2005-01-27 Fernando Perez <fperez@colorado.edu> | |
1327 |
|
1344 | |||
1328 | * IPython/numutils.py (norm): Added 'inf' as optional name for |
|
1345 | * IPython/numutils.py (norm): Added 'inf' as optional name for | |
1329 | L-infinity norm, included references to mathworld.com for vector |
|
1346 | L-infinity norm, included references to mathworld.com for vector | |
1330 | norm definitions. |
|
1347 | norm definitions. | |
1331 | (amin/amax): added amin/amax for array min/max. Similar to what |
|
1348 | (amin/amax): added amin/amax for array min/max. Similar to what | |
1332 | pylab ships with after the recent reorganization of names. |
|
1349 | pylab ships with after the recent reorganization of names. | |
1333 | (spike/spike_odd): removed deprecated spike/spike_odd functions. |
|
1350 | (spike/spike_odd): removed deprecated spike/spike_odd functions. | |
1334 |
|
1351 | |||
1335 | * ipython.el: committed Alex's recent fixes and improvements. |
|
1352 | * ipython.el: committed Alex's recent fixes and improvements. | |
1336 | Tested with python-mode from CVS, and it looks excellent. Since |
|
1353 | Tested with python-mode from CVS, and it looks excellent. Since | |
1337 | python-mode hasn't released anything in a while, I'm temporarily |
|
1354 | python-mode hasn't released anything in a while, I'm temporarily | |
1338 | putting a copy of today's CVS (v 4.70) of python-mode in: |
|
1355 | putting a copy of today's CVS (v 4.70) of python-mode in: | |
1339 | http://ipython.scipy.org/tmp/python-mode.el |
|
1356 | http://ipython.scipy.org/tmp/python-mode.el | |
1340 |
|
1357 | |||
1341 | * scripts/ipython_win_post_install.py (install): Win32 fix to use |
|
1358 | * scripts/ipython_win_post_install.py (install): Win32 fix to use | |
1342 | sys.executable for the executable name, instead of assuming it's |
|
1359 | sys.executable for the executable name, instead of assuming it's | |
1343 | called 'python.exe' (the post-installer would have produced broken |
|
1360 | called 'python.exe' (the post-installer would have produced broken | |
1344 | setups on systems with a differently named python binary). |
|
1361 | setups on systems with a differently named python binary). | |
1345 |
|
1362 | |||
1346 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' |
|
1363 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' | |
1347 | references to os.linesep, to make the code more |
|
1364 | references to os.linesep, to make the code more | |
1348 | platform-independent. This is also part of the win32 coloring |
|
1365 | platform-independent. This is also part of the win32 coloring | |
1349 | fixes. |
|
1366 | fixes. | |
1350 |
|
1367 | |||
1351 | * IPython/genutils.py (page_dumb): Remove attempts to chop long |
|
1368 | * IPython/genutils.py (page_dumb): Remove attempts to chop long | |
1352 | lines, which actually cause coloring bugs because the length of |
|
1369 | lines, which actually cause coloring bugs because the length of | |
1353 | the line is very difficult to correctly compute with embedded |
|
1370 | the line is very difficult to correctly compute with embedded | |
1354 | escapes. This was the source of all the coloring problems under |
|
1371 | escapes. This was the source of all the coloring problems under | |
1355 | Win32. I think that _finally_, Win32 users have a properly |
|
1372 | Win32. I think that _finally_, Win32 users have a properly | |
1356 | working ipython in all respects. This would never have happened |
|
1373 | working ipython in all respects. This would never have happened | |
1357 | if not for Gary Bishop and Viktor Ransmayr's great help and work. |
|
1374 | if not for Gary Bishop and Viktor Ransmayr's great help and work. | |
1358 |
|
1375 | |||
1359 | 2005-01-26 *** Released version 0.6.9 |
|
1376 | 2005-01-26 *** Released version 0.6.9 | |
1360 |
|
1377 | |||
1361 | 2005-01-25 Fernando Perez <fperez@colorado.edu> |
|
1378 | 2005-01-25 Fernando Perez <fperez@colorado.edu> | |
1362 |
|
1379 | |||
1363 | * setup.py: finally, we have a true Windows installer, thanks to |
|
1380 | * setup.py: finally, we have a true Windows installer, thanks to | |
1364 | the excellent work of Viktor Ransmayr |
|
1381 | the excellent work of Viktor Ransmayr | |
1365 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for |
|
1382 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for | |
1366 | Windows users. The setup routine is quite a bit cleaner thanks to |
|
1383 | Windows users. The setup routine is quite a bit cleaner thanks to | |
1367 | this, and the post-install script uses the proper functions to |
|
1384 | this, and the post-install script uses the proper functions to | |
1368 | allow a clean de-installation using the standard Windows Control |
|
1385 | allow a clean de-installation using the standard Windows Control | |
1369 | Panel. |
|
1386 | Panel. | |
1370 |
|
1387 | |||
1371 | * IPython/genutils.py (get_home_dir): changed to use the $HOME |
|
1388 | * IPython/genutils.py (get_home_dir): changed to use the $HOME | |
1372 | environment variable under all OSes (including win32) if |
|
1389 | environment variable under all OSes (including win32) if | |
1373 | available. This will give consistency to win32 users who have set |
|
1390 | available. This will give consistency to win32 users who have set | |
1374 | this variable for any reason. If os.environ['HOME'] fails, the |
|
1391 | this variable for any reason. If os.environ['HOME'] fails, the | |
1375 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. |
|
1392 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. | |
1376 |
|
1393 | |||
1377 | 2005-01-24 Fernando Perez <fperez@colorado.edu> |
|
1394 | 2005-01-24 Fernando Perez <fperez@colorado.edu> | |
1378 |
|
1395 | |||
1379 | * IPython/numutils.py (empty_like): add empty_like(), similar to |
|
1396 | * IPython/numutils.py (empty_like): add empty_like(), similar to | |
1380 | zeros_like() but taking advantage of the new empty() Numeric routine. |
|
1397 | zeros_like() but taking advantage of the new empty() Numeric routine. | |
1381 |
|
1398 | |||
1382 | 2005-01-23 *** Released version 0.6.8 |
|
1399 | 2005-01-23 *** Released version 0.6.8 | |
1383 |
|
1400 | |||
1384 | 2005-01-22 Fernando Perez <fperez@colorado.edu> |
|
1401 | 2005-01-22 Fernando Perez <fperez@colorado.edu> | |
1385 |
|
1402 | |||
1386 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the |
|
1403 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the | |
1387 | automatic show() calls. After discussing things with JDH, it |
|
1404 | automatic show() calls. After discussing things with JDH, it | |
1388 | turns out there are too many corner cases where this can go wrong. |
|
1405 | turns out there are too many corner cases where this can go wrong. | |
1389 | It's best not to try to be 'too smart', and simply have ipython |
|
1406 | It's best not to try to be 'too smart', and simply have ipython | |
1390 | reproduce as much as possible the default behavior of a normal |
|
1407 | reproduce as much as possible the default behavior of a normal | |
1391 | python shell. |
|
1408 | python shell. | |
1392 |
|
1409 | |||
1393 | * IPython/iplib.py (InteractiveShell.__init__): Modified the |
|
1410 | * IPython/iplib.py (InteractiveShell.__init__): Modified the | |
1394 | line-splitting regexp and _prefilter() to avoid calling getattr() |
|
1411 | line-splitting regexp and _prefilter() to avoid calling getattr() | |
1395 | on assignments. This closes |
|
1412 | on assignments. This closes | |
1396 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's |
|
1413 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's | |
1397 | readline uses getattr(), so a simple <TAB> keypress is still |
|
1414 | readline uses getattr(), so a simple <TAB> keypress is still | |
1398 | enough to trigger getattr() calls on an object. |
|
1415 | enough to trigger getattr() calls on an object. | |
1399 |
|
1416 | |||
1400 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
1417 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
1401 |
|
1418 | |||
1402 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run |
|
1419 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run | |
1403 | docstring under pylab so it doesn't mask the original. |
|
1420 | docstring under pylab so it doesn't mask the original. | |
1404 |
|
1421 | |||
1405 | 2005-01-21 *** Released version 0.6.7 |
|
1422 | 2005-01-21 *** Released version 0.6.7 | |
1406 |
|
1423 | |||
1407 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
1424 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
1408 |
|
1425 | |||
1409 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with |
|
1426 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with | |
1410 | signal handling for win32 users in multithreaded mode. |
|
1427 | signal handling for win32 users in multithreaded mode. | |
1411 |
|
1428 | |||
1412 | 2005-01-17 Fernando Perez <fperez@colorado.edu> |
|
1429 | 2005-01-17 Fernando Perez <fperez@colorado.edu> | |
1413 |
|
1430 | |||
1414 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
1431 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
1415 | instances with no __init__. After a crash report by Norbert Nemec |
|
1432 | instances with no __init__. After a crash report by Norbert Nemec | |
1416 | <Norbert-AT-nemec-online.de>. |
|
1433 | <Norbert-AT-nemec-online.de>. | |
1417 |
|
1434 | |||
1418 | 2005-01-14 Fernando Perez <fperez@colorado.edu> |
|
1435 | 2005-01-14 Fernando Perez <fperez@colorado.edu> | |
1419 |
|
1436 | |||
1420 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of |
|
1437 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of | |
1421 | names for verbose exceptions, when multiple dotted names and the |
|
1438 | names for verbose exceptions, when multiple dotted names and the | |
1422 | 'parent' object were present on the same line. |
|
1439 | 'parent' object were present on the same line. | |
1423 |
|
1440 | |||
1424 | 2005-01-11 Fernando Perez <fperez@colorado.edu> |
|
1441 | 2005-01-11 Fernando Perez <fperez@colorado.edu> | |
1425 |
|
1442 | |||
1426 | * IPython/genutils.py (flag_calls): new utility to trap and flag |
|
1443 | * IPython/genutils.py (flag_calls): new utility to trap and flag | |
1427 | calls in functions. I need it to clean up matplotlib support. |
|
1444 | calls in functions. I need it to clean up matplotlib support. | |
1428 | Also removed some deprecated code in genutils. |
|
1445 | Also removed some deprecated code in genutils. | |
1429 |
|
1446 | |||
1430 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so |
|
1447 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so | |
1431 | that matplotlib scripts called with %run, which don't call show() |
|
1448 | that matplotlib scripts called with %run, which don't call show() | |
1432 | themselves, still have their plotting windows open. |
|
1449 | themselves, still have their plotting windows open. | |
1433 |
|
1450 | |||
1434 | 2005-01-05 Fernando Perez <fperez@colorado.edu> |
|
1451 | 2005-01-05 Fernando Perez <fperez@colorado.edu> | |
1435 |
|
1452 | |||
1436 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw |
|
1453 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw | |
1437 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. |
|
1454 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. | |
1438 |
|
1455 | |||
1439 | 2004-12-19 Fernando Perez <fperez@colorado.edu> |
|
1456 | 2004-12-19 Fernando Perez <fperez@colorado.edu> | |
1440 |
|
1457 | |||
1441 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of |
|
1458 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of | |
1442 | parent_runcode, which was an eyesore. The same result can be |
|
1459 | parent_runcode, which was an eyesore. The same result can be | |
1443 | obtained with Python's regular superclass mechanisms. |
|
1460 | obtained with Python's regular superclass mechanisms. | |
1444 |
|
1461 | |||
1445 | 2004-12-17 Fernando Perez <fperez@colorado.edu> |
|
1462 | 2004-12-17 Fernando Perez <fperez@colorado.edu> | |
1446 |
|
1463 | |||
1447 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem |
|
1464 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem | |
1448 | reported by Prabhu. |
|
1465 | reported by Prabhu. | |
1449 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to |
|
1466 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to | |
1450 | sys.stderr) instead of explicitly calling sys.stderr. This helps |
|
1467 | sys.stderr) instead of explicitly calling sys.stderr. This helps | |
1451 | maintain our I/O abstractions clean, for future GUI embeddings. |
|
1468 | maintain our I/O abstractions clean, for future GUI embeddings. | |
1452 |
|
1469 | |||
1453 | * IPython/genutils.py (info): added new utility for sys.stderr |
|
1470 | * IPython/genutils.py (info): added new utility for sys.stderr | |
1454 | unified info message handling (thin wrapper around warn()). |
|
1471 | unified info message handling (thin wrapper around warn()). | |
1455 |
|
1472 | |||
1456 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global |
|
1473 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global | |
1457 | composite (dotted) names on verbose exceptions. |
|
1474 | composite (dotted) names on verbose exceptions. | |
1458 | (VerboseTB.nullrepr): harden against another kind of errors which |
|
1475 | (VerboseTB.nullrepr): harden against another kind of errors which | |
1459 | Python's inspect module can trigger, and which were crashing |
|
1476 | Python's inspect module can trigger, and which were crashing | |
1460 | IPython. Thanks to a report by Marco Lombardi |
|
1477 | IPython. Thanks to a report by Marco Lombardi | |
1461 | <mlombard-AT-ma010192.hq.eso.org>. |
|
1478 | <mlombard-AT-ma010192.hq.eso.org>. | |
1462 |
|
1479 | |||
1463 | 2004-12-13 *** Released version 0.6.6 |
|
1480 | 2004-12-13 *** Released version 0.6.6 | |
1464 |
|
1481 | |||
1465 | 2004-12-12 Fernando Perez <fperez@colorado.edu> |
|
1482 | 2004-12-12 Fernando Perez <fperez@colorado.edu> | |
1466 |
|
1483 | |||
1467 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors |
|
1484 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors | |
1468 | generated by pygtk upon initialization if it was built without |
|
1485 | generated by pygtk upon initialization if it was built without | |
1469 | threads (for matplotlib users). After a crash reported by |
|
1486 | threads (for matplotlib users). After a crash reported by | |
1470 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. |
|
1487 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. | |
1471 |
|
1488 | |||
1472 | * IPython/ipmaker.py (make_IPython): fix small bug in the |
|
1489 | * IPython/ipmaker.py (make_IPython): fix small bug in the | |
1473 | import_some parameter for multiple imports. |
|
1490 | import_some parameter for multiple imports. | |
1474 |
|
1491 | |||
1475 | * IPython/iplib.py (ipmagic): simplified the interface of |
|
1492 | * IPython/iplib.py (ipmagic): simplified the interface of | |
1476 | ipmagic() to take a single string argument, just as it would be |
|
1493 | ipmagic() to take a single string argument, just as it would be | |
1477 | typed at the IPython cmd line. |
|
1494 | typed at the IPython cmd line. | |
1478 | (ipalias): Added new ipalias() with an interface identical to |
|
1495 | (ipalias): Added new ipalias() with an interface identical to | |
1479 | ipmagic(). This completes exposing a pure python interface to the |
|
1496 | ipmagic(). This completes exposing a pure python interface to the | |
1480 | alias and magic system, which can be used in loops or more complex |
|
1497 | alias and magic system, which can be used in loops or more complex | |
1481 | code where IPython's automatic line mangling is not active. |
|
1498 | code where IPython's automatic line mangling is not active. | |
1482 |
|
1499 | |||
1483 | * IPython/genutils.py (timing): changed interface of timing to |
|
1500 | * IPython/genutils.py (timing): changed interface of timing to | |
1484 | simply run code once, which is the most common case. timings() |
|
1501 | simply run code once, which is the most common case. timings() | |
1485 | remains unchanged, for the cases where you want multiple runs. |
|
1502 | remains unchanged, for the cases where you want multiple runs. | |
1486 |
|
1503 | |||
1487 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a |
|
1504 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a | |
1488 | bug where Python2.2 crashes with exec'ing code which does not end |
|
1505 | bug where Python2.2 crashes with exec'ing code which does not end | |
1489 | in a single newline. Python 2.3 is OK, so I hadn't noticed this |
|
1506 | in a single newline. Python 2.3 is OK, so I hadn't noticed this | |
1490 | before. |
|
1507 | before. | |
1491 |
|
1508 | |||
1492 | 2004-12-10 Fernando Perez <fperez@colorado.edu> |
|
1509 | 2004-12-10 Fernando Perez <fperez@colorado.edu> | |
1493 |
|
1510 | |||
1494 | * IPython/Magic.py (Magic.magic_prun): changed name of option from |
|
1511 | * IPython/Magic.py (Magic.magic_prun): changed name of option from | |
1495 | -t to -T, to accomodate the new -t flag in %run (the %run and |
|
1512 | -t to -T, to accomodate the new -t flag in %run (the %run and | |
1496 | %prun options are kind of intermixed, and it's not easy to change |
|
1513 | %prun options are kind of intermixed, and it's not easy to change | |
1497 | this with the limitations of python's getopt). |
|
1514 | this with the limitations of python's getopt). | |
1498 |
|
1515 | |||
1499 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time |
|
1516 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time | |
1500 | the execution of scripts. It's not as fine-tuned as timeit.py, |
|
1517 | the execution of scripts. It's not as fine-tuned as timeit.py, | |
1501 | but it works from inside ipython (and under 2.2, which lacks |
|
1518 | but it works from inside ipython (and under 2.2, which lacks | |
1502 | timeit.py). Optionally a number of runs > 1 can be given for |
|
1519 | timeit.py). Optionally a number of runs > 1 can be given for | |
1503 | timing very short-running code. |
|
1520 | timing very short-running code. | |
1504 |
|
1521 | |||
1505 | * IPython/genutils.py (uniq_stable): new routine which returns a |
|
1522 | * IPython/genutils.py (uniq_stable): new routine which returns a | |
1506 | list of unique elements in any iterable, but in stable order of |
|
1523 | list of unique elements in any iterable, but in stable order of | |
1507 | appearance. I needed this for the ultraTB fixes, and it's a handy |
|
1524 | appearance. I needed this for the ultraTB fixes, and it's a handy | |
1508 | utility. |
|
1525 | utility. | |
1509 |
|
1526 | |||
1510 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of |
|
1527 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of | |
1511 | dotted names in Verbose exceptions. This had been broken since |
|
1528 | dotted names in Verbose exceptions. This had been broken since | |
1512 | the very start, now x.y will properly be printed in a Verbose |
|
1529 | the very start, now x.y will properly be printed in a Verbose | |
1513 | traceback, instead of x being shown and y appearing always as an |
|
1530 | traceback, instead of x being shown and y appearing always as an | |
1514 | 'undefined global'. Getting this to work was a bit tricky, |
|
1531 | 'undefined global'. Getting this to work was a bit tricky, | |
1515 | because by default python tokenizers are stateless. Saved by |
|
1532 | because by default python tokenizers are stateless. Saved by | |
1516 | python's ability to easily add a bit of state to an arbitrary |
|
1533 | python's ability to easily add a bit of state to an arbitrary | |
1517 | function (without needing to build a full-blown callable object). |
|
1534 | function (without needing to build a full-blown callable object). | |
1518 |
|
1535 | |||
1519 | Also big cleanup of this code, which had horrendous runtime |
|
1536 | Also big cleanup of this code, which had horrendous runtime | |
1520 | lookups of zillions of attributes for colorization. Moved all |
|
1537 | lookups of zillions of attributes for colorization. Moved all | |
1521 | this code into a few templates, which make it cleaner and quicker. |
|
1538 | this code into a few templates, which make it cleaner and quicker. | |
1522 |
|
1539 | |||
1523 | Printout quality was also improved for Verbose exceptions: one |
|
1540 | Printout quality was also improved for Verbose exceptions: one | |
1524 | variable per line, and memory addresses are printed (this can be |
|
1541 | variable per line, and memory addresses are printed (this can be | |
1525 | quite handy in nasty debugging situations, which is what Verbose |
|
1542 | quite handy in nasty debugging situations, which is what Verbose | |
1526 | is for). |
|
1543 | is for). | |
1527 |
|
1544 | |||
1528 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in |
|
1545 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in | |
1529 | the command line as scripts to be loaded by embedded instances. |
|
1546 | the command line as scripts to be loaded by embedded instances. | |
1530 | Doing so has the potential for an infinite recursion if there are |
|
1547 | Doing so has the potential for an infinite recursion if there are | |
1531 | exceptions thrown in the process. This fixes a strange crash |
|
1548 | exceptions thrown in the process. This fixes a strange crash | |
1532 | reported by Philippe MULLER <muller-AT-irit.fr>. |
|
1549 | reported by Philippe MULLER <muller-AT-irit.fr>. | |
1533 |
|
1550 | |||
1534 | 2004-12-09 Fernando Perez <fperez@colorado.edu> |
|
1551 | 2004-12-09 Fernando Perez <fperez@colorado.edu> | |
1535 |
|
1552 | |||
1536 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support |
|
1553 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support | |
1537 | to reflect new names in matplotlib, which now expose the |
|
1554 | to reflect new names in matplotlib, which now expose the | |
1538 | matlab-compatible interface via a pylab module instead of the |
|
1555 | matlab-compatible interface via a pylab module instead of the | |
1539 | 'matlab' name. The new code is backwards compatible, so users of |
|
1556 | 'matlab' name. The new code is backwards compatible, so users of | |
1540 | all matplotlib versions are OK. Patch by J. Hunter. |
|
1557 | all matplotlib versions are OK. Patch by J. Hunter. | |
1541 |
|
1558 | |||
1542 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing |
|
1559 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing | |
1543 | of __init__ docstrings for instances (class docstrings are already |
|
1560 | of __init__ docstrings for instances (class docstrings are already | |
1544 | automatically printed). Instances with customized docstrings |
|
1561 | automatically printed). Instances with customized docstrings | |
1545 | (indep. of the class) are also recognized and all 3 separate |
|
1562 | (indep. of the class) are also recognized and all 3 separate | |
1546 | docstrings are printed (instance, class, constructor). After some |
|
1563 | docstrings are printed (instance, class, constructor). After some | |
1547 | comments/suggestions by J. Hunter. |
|
1564 | comments/suggestions by J. Hunter. | |
1548 |
|
1565 | |||
1549 | 2004-12-05 Fernando Perez <fperez@colorado.edu> |
|
1566 | 2004-12-05 Fernando Perez <fperez@colorado.edu> | |
1550 |
|
1567 | |||
1551 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying |
|
1568 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying | |
1552 | warnings when tab-completion fails and triggers an exception. |
|
1569 | warnings when tab-completion fails and triggers an exception. | |
1553 |
|
1570 | |||
1554 | 2004-12-03 Fernando Perez <fperez@colorado.edu> |
|
1571 | 2004-12-03 Fernando Perez <fperez@colorado.edu> | |
1555 |
|
1572 | |||
1556 | * IPython/Magic.py (magic_prun): Fix bug where an exception would |
|
1573 | * IPython/Magic.py (magic_prun): Fix bug where an exception would | |
1557 | be triggered when using 'run -p'. An incorrect option flag was |
|
1574 | be triggered when using 'run -p'. An incorrect option flag was | |
1558 | being set ('d' instead of 'D'). |
|
1575 | being set ('d' instead of 'D'). | |
1559 | (manpage): fix missing escaped \- sign. |
|
1576 | (manpage): fix missing escaped \- sign. | |
1560 |
|
1577 | |||
1561 | 2004-11-30 *** Released version 0.6.5 |
|
1578 | 2004-11-30 *** Released version 0.6.5 | |
1562 |
|
1579 | |||
1563 | 2004-11-30 Fernando Perez <fperez@colorado.edu> |
|
1580 | 2004-11-30 Fernando Perez <fperez@colorado.edu> | |
1564 |
|
1581 | |||
1565 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint |
|
1582 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint | |
1566 | setting with -d option. |
|
1583 | setting with -d option. | |
1567 |
|
1584 | |||
1568 | * setup.py (docfiles): Fix problem where the doc glob I was using |
|
1585 | * setup.py (docfiles): Fix problem where the doc glob I was using | |
1569 | was COMPLETELY BROKEN. It was giving the right files by pure |
|
1586 | was COMPLETELY BROKEN. It was giving the right files by pure | |
1570 | accident, but failed once I tried to include ipython.el. Note: |
|
1587 | accident, but failed once I tried to include ipython.el. Note: | |
1571 | glob() does NOT allow you to do exclusion on multiple endings! |
|
1588 | glob() does NOT allow you to do exclusion on multiple endings! | |
1572 |
|
1589 | |||
1573 | 2004-11-29 Fernando Perez <fperez@colorado.edu> |
|
1590 | 2004-11-29 Fernando Perez <fperez@colorado.edu> | |
1574 |
|
1591 | |||
1575 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using |
|
1592 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using | |
1576 | the manpage as the source. Better formatting & consistency. |
|
1593 | the manpage as the source. Better formatting & consistency. | |
1577 |
|
1594 | |||
1578 | * IPython/Magic.py (magic_run): Added new -d option, to run |
|
1595 | * IPython/Magic.py (magic_run): Added new -d option, to run | |
1579 | scripts under the control of the python pdb debugger. Note that |
|
1596 | scripts under the control of the python pdb debugger. Note that | |
1580 | this required changing the %prun option -d to -D, to avoid a clash |
|
1597 | this required changing the %prun option -d to -D, to avoid a clash | |
1581 | (since %run must pass options to %prun, and getopt is too dumb to |
|
1598 | (since %run must pass options to %prun, and getopt is too dumb to | |
1582 | handle options with string values with embedded spaces). Thanks |
|
1599 | handle options with string values with embedded spaces). Thanks | |
1583 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. |
|
1600 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. | |
1584 | (magic_who_ls): added type matching to %who and %whos, so that one |
|
1601 | (magic_who_ls): added type matching to %who and %whos, so that one | |
1585 | can filter their output to only include variables of certain |
|
1602 | can filter their output to only include variables of certain | |
1586 | types. Another suggestion by Matthew. |
|
1603 | types. Another suggestion by Matthew. | |
1587 | (magic_whos): Added memory summaries in kb and Mb for arrays. |
|
1604 | (magic_whos): Added memory summaries in kb and Mb for arrays. | |
1588 | (magic_who): Improve formatting (break lines every 9 vars). |
|
1605 | (magic_who): Improve formatting (break lines every 9 vars). | |
1589 |
|
1606 | |||
1590 | 2004-11-28 Fernando Perez <fperez@colorado.edu> |
|
1607 | 2004-11-28 Fernando Perez <fperez@colorado.edu> | |
1591 |
|
1608 | |||
1592 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input |
|
1609 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input | |
1593 | cache when empty lines were present. |
|
1610 | cache when empty lines were present. | |
1594 |
|
1611 | |||
1595 | 2004-11-24 Fernando Perez <fperez@colorado.edu> |
|
1612 | 2004-11-24 Fernando Perez <fperez@colorado.edu> | |
1596 |
|
1613 | |||
1597 | * IPython/usage.py (__doc__): document the re-activated threading |
|
1614 | * IPython/usage.py (__doc__): document the re-activated threading | |
1598 | options for WX and GTK. |
|
1615 | options for WX and GTK. | |
1599 |
|
1616 | |||
1600 | 2004-11-23 Fernando Perez <fperez@colorado.edu> |
|
1617 | 2004-11-23 Fernando Perez <fperez@colorado.edu> | |
1601 |
|
1618 | |||
1602 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate |
|
1619 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate | |
1603 | the -wthread and -gthread options, along with a new -tk one to try |
|
1620 | the -wthread and -gthread options, along with a new -tk one to try | |
1604 | and coordinate Tk threading with wx/gtk. The tk support is very |
|
1621 | and coordinate Tk threading with wx/gtk. The tk support is very | |
1605 | platform dependent, since it seems to require Tcl and Tk to be |
|
1622 | platform dependent, since it seems to require Tcl and Tk to be | |
1606 | built with threads (Fedora1/2 appears NOT to have it, but in |
|
1623 | built with threads (Fedora1/2 appears NOT to have it, but in | |
1607 | Prabhu's Debian boxes it works OK). But even with some Tk |
|
1624 | Prabhu's Debian boxes it works OK). But even with some Tk | |
1608 | limitations, this is a great improvement. |
|
1625 | limitations, this is a great improvement. | |
1609 |
|
1626 | |||
1610 | * IPython/Prompts.py (prompt_specials_color): Added \t for time |
|
1627 | * IPython/Prompts.py (prompt_specials_color): Added \t for time | |
1611 | info in user prompts. Patch by Prabhu. |
|
1628 | info in user prompts. Patch by Prabhu. | |
1612 |
|
1629 | |||
1613 | 2004-11-18 Fernando Perez <fperez@colorado.edu> |
|
1630 | 2004-11-18 Fernando Perez <fperez@colorado.edu> | |
1614 |
|
1631 | |||
1615 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 |
|
1632 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 | |
1616 | EOFErrors and bail, to avoid infinite loops if a non-terminating |
|
1633 | EOFErrors and bail, to avoid infinite loops if a non-terminating | |
1617 | file is fed into ipython. Patch submitted in issue 19 by user, |
|
1634 | file is fed into ipython. Patch submitted in issue 19 by user, | |
1618 | many thanks. |
|
1635 | many thanks. | |
1619 |
|
1636 | |||
1620 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger |
|
1637 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger | |
1621 | autoquote/parens in continuation prompts, which can cause lots of |
|
1638 | autoquote/parens in continuation prompts, which can cause lots of | |
1622 | problems. Closes roundup issue 20. |
|
1639 | problems. Closes roundup issue 20. | |
1623 |
|
1640 | |||
1624 | 2004-11-17 Fernando Perez <fperez@colorado.edu> |
|
1641 | 2004-11-17 Fernando Perez <fperez@colorado.edu> | |
1625 |
|
1642 | |||
1626 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, |
|
1643 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, | |
1627 | reported as debian bug #280505. I'm not sure my local changelog |
|
1644 | reported as debian bug #280505. I'm not sure my local changelog | |
1628 | entry has the proper debian format (Jack?). |
|
1645 | entry has the proper debian format (Jack?). | |
1629 |
|
1646 | |||
1630 | 2004-11-08 *** Released version 0.6.4 |
|
1647 | 2004-11-08 *** Released version 0.6.4 | |
1631 |
|
1648 | |||
1632 | 2004-11-08 Fernando Perez <fperez@colorado.edu> |
|
1649 | 2004-11-08 Fernando Perez <fperez@colorado.edu> | |
1633 |
|
1650 | |||
1634 | * IPython/iplib.py (init_readline): Fix exit message for Windows |
|
1651 | * IPython/iplib.py (init_readline): Fix exit message for Windows | |
1635 | when readline is active. Thanks to a report by Eric Jones |
|
1652 | when readline is active. Thanks to a report by Eric Jones | |
1636 | <eric-AT-enthought.com>. |
|
1653 | <eric-AT-enthought.com>. | |
1637 |
|
1654 | |||
1638 | 2004-11-07 Fernando Perez <fperez@colorado.edu> |
|
1655 | 2004-11-07 Fernando Perez <fperez@colorado.edu> | |
1639 |
|
1656 | |||
1640 | * IPython/genutils.py (page): Add a trap for OSError exceptions, |
|
1657 | * IPython/genutils.py (page): Add a trap for OSError exceptions, | |
1641 | sometimes seen by win2k/cygwin users. |
|
1658 | sometimes seen by win2k/cygwin users. | |
1642 |
|
1659 | |||
1643 | 2004-11-06 Fernando Perez <fperez@colorado.edu> |
|
1660 | 2004-11-06 Fernando Perez <fperez@colorado.edu> | |
1644 |
|
1661 | |||
1645 | * IPython/iplib.py (interact): Change the handling of %Exit from |
|
1662 | * IPython/iplib.py (interact): Change the handling of %Exit from | |
1646 | trying to propagate a SystemExit to an internal ipython flag. |
|
1663 | trying to propagate a SystemExit to an internal ipython flag. | |
1647 | This is less elegant than using Python's exception mechanism, but |
|
1664 | This is less elegant than using Python's exception mechanism, but | |
1648 | I can't get that to work reliably with threads, so under -pylab |
|
1665 | I can't get that to work reliably with threads, so under -pylab | |
1649 | %Exit was hanging IPython. Cross-thread exception handling is |
|
1666 | %Exit was hanging IPython. Cross-thread exception handling is | |
1650 | really a bitch. Thaks to a bug report by Stephen Walton |
|
1667 | really a bitch. Thaks to a bug report by Stephen Walton | |
1651 | <stephen.walton-AT-csun.edu>. |
|
1668 | <stephen.walton-AT-csun.edu>. | |
1652 |
|
1669 | |||
1653 | 2004-11-04 Fernando Perez <fperez@colorado.edu> |
|
1670 | 2004-11-04 Fernando Perez <fperez@colorado.edu> | |
1654 |
|
1671 | |||
1655 | * IPython/iplib.py (raw_input_original): store a pointer to the |
|
1672 | * IPython/iplib.py (raw_input_original): store a pointer to the | |
1656 | true raw_input to harden against code which can modify it |
|
1673 | true raw_input to harden against code which can modify it | |
1657 | (wx.py.PyShell does this and would otherwise crash ipython). |
|
1674 | (wx.py.PyShell does this and would otherwise crash ipython). | |
1658 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. |
|
1675 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. | |
1659 |
|
1676 | |||
1660 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for |
|
1677 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for | |
1661 | Ctrl-C problem, which does not mess up the input line. |
|
1678 | Ctrl-C problem, which does not mess up the input line. | |
1662 |
|
1679 | |||
1663 | 2004-11-03 Fernando Perez <fperez@colorado.edu> |
|
1680 | 2004-11-03 Fernando Perez <fperez@colorado.edu> | |
1664 |
|
1681 | |||
1665 | * IPython/Release.py: Changed licensing to BSD, in all files. |
|
1682 | * IPython/Release.py: Changed licensing to BSD, in all files. | |
1666 | (name): lowercase name for tarball/RPM release. |
|
1683 | (name): lowercase name for tarball/RPM release. | |
1667 |
|
1684 | |||
1668 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for |
|
1685 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for | |
1669 | use throughout ipython. |
|
1686 | use throughout ipython. | |
1670 |
|
1687 | |||
1671 | * IPython/Magic.py (Magic._ofind): Switch to using the new |
|
1688 | * IPython/Magic.py (Magic._ofind): Switch to using the new | |
1672 | OInspect.getdoc() function. |
|
1689 | OInspect.getdoc() function. | |
1673 |
|
1690 | |||
1674 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution |
|
1691 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution | |
1675 | of the line currently being canceled via Ctrl-C. It's extremely |
|
1692 | of the line currently being canceled via Ctrl-C. It's extremely | |
1676 | ugly, but I don't know how to do it better (the problem is one of |
|
1693 | ugly, but I don't know how to do it better (the problem is one of | |
1677 | handling cross-thread exceptions). |
|
1694 | handling cross-thread exceptions). | |
1678 |
|
1695 | |||
1679 | 2004-10-28 Fernando Perez <fperez@colorado.edu> |
|
1696 | 2004-10-28 Fernando Perez <fperez@colorado.edu> | |
1680 |
|
1697 | |||
1681 | * IPython/Shell.py (signal_handler): add signal handlers to trap |
|
1698 | * IPython/Shell.py (signal_handler): add signal handlers to trap | |
1682 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug |
|
1699 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug | |
1683 | report by Francesc Alted. |
|
1700 | report by Francesc Alted. | |
1684 |
|
1701 | |||
1685 | 2004-10-21 Fernando Perez <fperez@colorado.edu> |
|
1702 | 2004-10-21 Fernando Perez <fperez@colorado.edu> | |
1686 |
|
1703 | |||
1687 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ |
|
1704 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ | |
1688 | to % for pysh syntax extensions. |
|
1705 | to % for pysh syntax extensions. | |
1689 |
|
1706 | |||
1690 | 2004-10-09 Fernando Perez <fperez@colorado.edu> |
|
1707 | 2004-10-09 Fernando Perez <fperez@colorado.edu> | |
1691 |
|
1708 | |||
1692 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric |
|
1709 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric | |
1693 | arrays to print a more useful summary, without calling str(arr). |
|
1710 | arrays to print a more useful summary, without calling str(arr). | |
1694 | This avoids the problem of extremely lengthy computations which |
|
1711 | This avoids the problem of extremely lengthy computations which | |
1695 | occur if arr is large, and appear to the user as a system lockup |
|
1712 | occur if arr is large, and appear to the user as a system lockup | |
1696 | with 100% cpu activity. After a suggestion by Kristian Sandberg |
|
1713 | with 100% cpu activity. After a suggestion by Kristian Sandberg | |
1697 | <Kristian.Sandberg@colorado.edu>. |
|
1714 | <Kristian.Sandberg@colorado.edu>. | |
1698 | (Magic.__init__): fix bug in global magic escapes not being |
|
1715 | (Magic.__init__): fix bug in global magic escapes not being | |
1699 | correctly set. |
|
1716 | correctly set. | |
1700 |
|
1717 | |||
1701 | 2004-10-08 Fernando Perez <fperez@colorado.edu> |
|
1718 | 2004-10-08 Fernando Perez <fperez@colorado.edu> | |
1702 |
|
1719 | |||
1703 | * IPython/Magic.py (__license__): change to absolute imports of |
|
1720 | * IPython/Magic.py (__license__): change to absolute imports of | |
1704 | ipython's own internal packages, to start adapting to the absolute |
|
1721 | ipython's own internal packages, to start adapting to the absolute | |
1705 | import requirement of PEP-328. |
|
1722 | import requirement of PEP-328. | |
1706 |
|
1723 | |||
1707 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all |
|
1724 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all | |
1708 | files, and standardize author/license marks through the Release |
|
1725 | files, and standardize author/license marks through the Release | |
1709 | module instead of having per/file stuff (except for files with |
|
1726 | module instead of having per/file stuff (except for files with | |
1710 | particular licenses, like the MIT/PSF-licensed codes). |
|
1727 | particular licenses, like the MIT/PSF-licensed codes). | |
1711 |
|
1728 | |||
1712 | * IPython/Debugger.py: remove dead code for python 2.1 |
|
1729 | * IPython/Debugger.py: remove dead code for python 2.1 | |
1713 |
|
1730 | |||
1714 | 2004-10-04 Fernando Perez <fperez@colorado.edu> |
|
1731 | 2004-10-04 Fernando Perez <fperez@colorado.edu> | |
1715 |
|
1732 | |||
1716 | * IPython/iplib.py (ipmagic): New function for accessing magics |
|
1733 | * IPython/iplib.py (ipmagic): New function for accessing magics | |
1717 | via a normal python function call. |
|
1734 | via a normal python function call. | |
1718 |
|
1735 | |||
1719 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape |
|
1736 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape | |
1720 | from '@' to '%', to accomodate the new @decorator syntax of python |
|
1737 | from '@' to '%', to accomodate the new @decorator syntax of python | |
1721 | 2.4. |
|
1738 | 2.4. | |
1722 |
|
1739 | |||
1723 | 2004-09-29 Fernando Perez <fperez@colorado.edu> |
|
1740 | 2004-09-29 Fernando Perez <fperez@colorado.edu> | |
1724 |
|
1741 | |||
1725 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to |
|
1742 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to | |
1726 | matplotlib.use to prevent running scripts which try to switch |
|
1743 | matplotlib.use to prevent running scripts which try to switch | |
1727 | interactive backends from within ipython. This will just crash |
|
1744 | interactive backends from within ipython. This will just crash | |
1728 | the python interpreter, so we can't allow it (but a detailed error |
|
1745 | the python interpreter, so we can't allow it (but a detailed error | |
1729 | is given to the user). |
|
1746 | is given to the user). | |
1730 |
|
1747 | |||
1731 | 2004-09-28 Fernando Perez <fperez@colorado.edu> |
|
1748 | 2004-09-28 Fernando Perez <fperez@colorado.edu> | |
1732 |
|
1749 | |||
1733 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): |
|
1750 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): | |
1734 | matplotlib-related fixes so that using @run with non-matplotlib |
|
1751 | matplotlib-related fixes so that using @run with non-matplotlib | |
1735 | scripts doesn't pop up spurious plot windows. This requires |
|
1752 | scripts doesn't pop up spurious plot windows. This requires | |
1736 | matplotlib >= 0.63, where I had to make some changes as well. |
|
1753 | matplotlib >= 0.63, where I had to make some changes as well. | |
1737 |
|
1754 | |||
1738 | * IPython/ipmaker.py (make_IPython): update version requirement to |
|
1755 | * IPython/ipmaker.py (make_IPython): update version requirement to | |
1739 | python 2.2. |
|
1756 | python 2.2. | |
1740 |
|
1757 | |||
1741 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional |
|
1758 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional | |
1742 | banner arg for embedded customization. |
|
1759 | banner arg for embedded customization. | |
1743 |
|
1760 | |||
1744 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all |
|
1761 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all | |
1745 | explicit uses of __IP as the IPython's instance name. Now things |
|
1762 | explicit uses of __IP as the IPython's instance name. Now things | |
1746 | are properly handled via the shell.name value. The actual code |
|
1763 | are properly handled via the shell.name value. The actual code | |
1747 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this |
|
1764 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this | |
1748 | is much better than before. I'll clean things completely when the |
|
1765 | is much better than before. I'll clean things completely when the | |
1749 | magic stuff gets a real overhaul. |
|
1766 | magic stuff gets a real overhaul. | |
1750 |
|
1767 | |||
1751 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in |
|
1768 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in | |
1752 | minor changes to debian dir. |
|
1769 | minor changes to debian dir. | |
1753 |
|
1770 | |||
1754 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a |
|
1771 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a | |
1755 | pointer to the shell itself in the interactive namespace even when |
|
1772 | pointer to the shell itself in the interactive namespace even when | |
1756 | a user-supplied dict is provided. This is needed for embedding |
|
1773 | a user-supplied dict is provided. This is needed for embedding | |
1757 | purposes (found by tests with Michel Sanner). |
|
1774 | purposes (found by tests with Michel Sanner). | |
1758 |
|
1775 | |||
1759 | 2004-09-27 Fernando Perez <fperez@colorado.edu> |
|
1776 | 2004-09-27 Fernando Perez <fperez@colorado.edu> | |
1760 |
|
1777 | |||
1761 | * IPython/UserConfig/ipythonrc: remove []{} from |
|
1778 | * IPython/UserConfig/ipythonrc: remove []{} from | |
1762 | readline_remove_delims, so that things like [modname.<TAB> do |
|
1779 | readline_remove_delims, so that things like [modname.<TAB> do | |
1763 | proper completion. This disables [].TAB, but that's a less common |
|
1780 | proper completion. This disables [].TAB, but that's a less common | |
1764 | case than module names in list comprehensions, for example. |
|
1781 | case than module names in list comprehensions, for example. | |
1765 | Thanks to a report by Andrea Riciputi. |
|
1782 | Thanks to a report by Andrea Riciputi. | |
1766 |
|
1783 | |||
1767 | 2004-09-09 Fernando Perez <fperez@colorado.edu> |
|
1784 | 2004-09-09 Fernando Perez <fperez@colorado.edu> | |
1768 |
|
1785 | |||
1769 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid |
|
1786 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid | |
1770 | blocking problems in win32 and osx. Fix by John. |
|
1787 | blocking problems in win32 and osx. Fix by John. | |
1771 |
|
1788 | |||
1772 | 2004-09-08 Fernando Perez <fperez@colorado.edu> |
|
1789 | 2004-09-08 Fernando Perez <fperez@colorado.edu> | |
1773 |
|
1790 | |||
1774 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug |
|
1791 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug | |
1775 | for Win32 and OSX. Fix by John Hunter. |
|
1792 | for Win32 and OSX. Fix by John Hunter. | |
1776 |
|
1793 | |||
1777 | 2004-08-30 *** Released version 0.6.3 |
|
1794 | 2004-08-30 *** Released version 0.6.3 | |
1778 |
|
1795 | |||
1779 | 2004-08-30 Fernando Perez <fperez@colorado.edu> |
|
1796 | 2004-08-30 Fernando Perez <fperez@colorado.edu> | |
1780 |
|
1797 | |||
1781 | * setup.py (isfile): Add manpages to list of dependent files to be |
|
1798 | * setup.py (isfile): Add manpages to list of dependent files to be | |
1782 | updated. |
|
1799 | updated. | |
1783 |
|
1800 | |||
1784 | 2004-08-27 Fernando Perez <fperez@colorado.edu> |
|
1801 | 2004-08-27 Fernando Perez <fperez@colorado.edu> | |
1785 |
|
1802 | |||
1786 | * IPython/Shell.py (start): I've disabled -wthread and -gthread |
|
1803 | * IPython/Shell.py (start): I've disabled -wthread and -gthread | |
1787 | for now. They don't really work with standalone WX/GTK code |
|
1804 | for now. They don't really work with standalone WX/GTK code | |
1788 | (though matplotlib IS working fine with both of those backends). |
|
1805 | (though matplotlib IS working fine with both of those backends). | |
1789 | This will neeed much more testing. I disabled most things with |
|
1806 | This will neeed much more testing. I disabled most things with | |
1790 | comments, so turning it back on later should be pretty easy. |
|
1807 | comments, so turning it back on later should be pretty easy. | |
1791 |
|
1808 | |||
1792 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental |
|
1809 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental | |
1793 | autocalling of expressions like r'foo', by modifying the line |
|
1810 | autocalling of expressions like r'foo', by modifying the line | |
1794 | split regexp. Closes |
|
1811 | split regexp. Closes | |
1795 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas |
|
1812 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas | |
1796 | Riley <ipythonbugs-AT-sabi.net>. |
|
1813 | Riley <ipythonbugs-AT-sabi.net>. | |
1797 | (InteractiveShell.mainloop): honor --nobanner with banner |
|
1814 | (InteractiveShell.mainloop): honor --nobanner with banner | |
1798 | extensions. |
|
1815 | extensions. | |
1799 |
|
1816 | |||
1800 | * IPython/Shell.py: Significant refactoring of all classes, so |
|
1817 | * IPython/Shell.py: Significant refactoring of all classes, so | |
1801 | that we can really support ALL matplotlib backends and threading |
|
1818 | that we can really support ALL matplotlib backends and threading | |
1802 | models (John spotted a bug with Tk which required this). Now we |
|
1819 | models (John spotted a bug with Tk which required this). Now we | |
1803 | should support single-threaded, WX-threads and GTK-threads, both |
|
1820 | should support single-threaded, WX-threads and GTK-threads, both | |
1804 | for generic code and for matplotlib. |
|
1821 | for generic code and for matplotlib. | |
1805 |
|
1822 | |||
1806 | * IPython/ipmaker.py (__call__): Changed -mpthread option to |
|
1823 | * IPython/ipmaker.py (__call__): Changed -mpthread option to | |
1807 | -pylab, to simplify things for users. Will also remove the pylab |
|
1824 | -pylab, to simplify things for users. Will also remove the pylab | |
1808 | profile, since now all of matplotlib configuration is directly |
|
1825 | profile, since now all of matplotlib configuration is directly | |
1809 | handled here. This also reduces startup time. |
|
1826 | handled here. This also reduces startup time. | |
1810 |
|
1827 | |||
1811 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of |
|
1828 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of | |
1812 | shell wasn't being correctly called. Also in IPShellWX. |
|
1829 | shell wasn't being correctly called. Also in IPShellWX. | |
1813 |
|
1830 | |||
1814 | * IPython/iplib.py (InteractiveShell.__init__): Added option to |
|
1831 | * IPython/iplib.py (InteractiveShell.__init__): Added option to | |
1815 | fine-tune banner. |
|
1832 | fine-tune banner. | |
1816 |
|
1833 | |||
1817 | * IPython/numutils.py (spike): Deprecate these spike functions, |
|
1834 | * IPython/numutils.py (spike): Deprecate these spike functions, | |
1818 | delete (long deprecated) gnuplot_exec handler. |
|
1835 | delete (long deprecated) gnuplot_exec handler. | |
1819 |
|
1836 | |||
1820 | 2004-08-26 Fernando Perez <fperez@colorado.edu> |
|
1837 | 2004-08-26 Fernando Perez <fperez@colorado.edu> | |
1821 |
|
1838 | |||
1822 | * ipython.1: Update for threading options, plus some others which |
|
1839 | * ipython.1: Update for threading options, plus some others which | |
1823 | were missing. |
|
1840 | were missing. | |
1824 |
|
1841 | |||
1825 | * IPython/ipmaker.py (__call__): Added -wthread option for |
|
1842 | * IPython/ipmaker.py (__call__): Added -wthread option for | |
1826 | wxpython thread handling. Make sure threading options are only |
|
1843 | wxpython thread handling. Make sure threading options are only | |
1827 | valid at the command line. |
|
1844 | valid at the command line. | |
1828 |
|
1845 | |||
1829 | * scripts/ipython: moved shell selection into a factory function |
|
1846 | * scripts/ipython: moved shell selection into a factory function | |
1830 | in Shell.py, to keep the starter script to a minimum. |
|
1847 | in Shell.py, to keep the starter script to a minimum. | |
1831 |
|
1848 | |||
1832 | 2004-08-25 Fernando Perez <fperez@colorado.edu> |
|
1849 | 2004-08-25 Fernando Perez <fperez@colorado.edu> | |
1833 |
|
1850 | |||
1834 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by |
|
1851 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by | |
1835 | John. Along with some recent changes he made to matplotlib, the |
|
1852 | John. Along with some recent changes he made to matplotlib, the | |
1836 | next versions of both systems should work very well together. |
|
1853 | next versions of both systems should work very well together. | |
1837 |
|
1854 | |||
1838 | 2004-08-24 Fernando Perez <fperez@colorado.edu> |
|
1855 | 2004-08-24 Fernando Perez <fperez@colorado.edu> | |
1839 |
|
1856 | |||
1840 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I |
|
1857 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I | |
1841 | tried to switch the profiling to using hotshot, but I'm getting |
|
1858 | tried to switch the profiling to using hotshot, but I'm getting | |
1842 | strange errors from prof.runctx() there. I may be misreading the |
|
1859 | strange errors from prof.runctx() there. I may be misreading the | |
1843 | docs, but it looks weird. For now the profiling code will |
|
1860 | docs, but it looks weird. For now the profiling code will | |
1844 | continue to use the standard profiler. |
|
1861 | continue to use the standard profiler. | |
1845 |
|
1862 | |||
1846 | 2004-08-23 Fernando Perez <fperez@colorado.edu> |
|
1863 | 2004-08-23 Fernando Perez <fperez@colorado.edu> | |
1847 |
|
1864 | |||
1848 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX |
|
1865 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX | |
1849 | threaded shell, by John Hunter. It's not quite ready yet, but |
|
1866 | threaded shell, by John Hunter. It's not quite ready yet, but | |
1850 | close. |
|
1867 | close. | |
1851 |
|
1868 | |||
1852 | 2004-08-22 Fernando Perez <fperez@colorado.edu> |
|
1869 | 2004-08-22 Fernando Perez <fperez@colorado.edu> | |
1853 |
|
1870 | |||
1854 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also |
|
1871 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also | |
1855 | in Magic and ultraTB. |
|
1872 | in Magic and ultraTB. | |
1856 |
|
1873 | |||
1857 | * ipython.1: document threading options in manpage. |
|
1874 | * ipython.1: document threading options in manpage. | |
1858 |
|
1875 | |||
1859 | * scripts/ipython: Changed name of -thread option to -gthread, |
|
1876 | * scripts/ipython: Changed name of -thread option to -gthread, | |
1860 | since this is GTK specific. I want to leave the door open for a |
|
1877 | since this is GTK specific. I want to leave the door open for a | |
1861 | -wthread option for WX, which will most likely be necessary. This |
|
1878 | -wthread option for WX, which will most likely be necessary. This | |
1862 | change affects usage and ipmaker as well. |
|
1879 | change affects usage and ipmaker as well. | |
1863 |
|
1880 | |||
1864 | * IPython/Shell.py (matplotlib_shell): Add a factory function to |
|
1881 | * IPython/Shell.py (matplotlib_shell): Add a factory function to | |
1865 | handle the matplotlib shell issues. Code by John Hunter |
|
1882 | handle the matplotlib shell issues. Code by John Hunter | |
1866 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
1883 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
1867 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's |
|
1884 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's | |
1868 | broken (and disabled for end users) for now, but it puts the |
|
1885 | broken (and disabled for end users) for now, but it puts the | |
1869 | infrastructure in place. |
|
1886 | infrastructure in place. | |
1870 |
|
1887 | |||
1871 | 2004-08-21 Fernando Perez <fperez@colorado.edu> |
|
1888 | 2004-08-21 Fernando Perez <fperez@colorado.edu> | |
1872 |
|
1889 | |||
1873 | * ipythonrc-pylab: Add matplotlib support. |
|
1890 | * ipythonrc-pylab: Add matplotlib support. | |
1874 |
|
1891 | |||
1875 | * matplotlib_config.py: new files for matplotlib support, part of |
|
1892 | * matplotlib_config.py: new files for matplotlib support, part of | |
1876 | the pylab profile. |
|
1893 | the pylab profile. | |
1877 |
|
1894 | |||
1878 | * IPython/usage.py (__doc__): documented the threading options. |
|
1895 | * IPython/usage.py (__doc__): documented the threading options. | |
1879 |
|
1896 | |||
1880 | 2004-08-20 Fernando Perez <fperez@colorado.edu> |
|
1897 | 2004-08-20 Fernando Perez <fperez@colorado.edu> | |
1881 |
|
1898 | |||
1882 | * ipython: Modified the main calling routine to handle the -thread |
|
1899 | * ipython: Modified the main calling routine to handle the -thread | |
1883 | and -mpthread options. This needs to be done as a top-level hack, |
|
1900 | and -mpthread options. This needs to be done as a top-level hack, | |
1884 | because it determines which class to instantiate for IPython |
|
1901 | because it determines which class to instantiate for IPython | |
1885 | itself. |
|
1902 | itself. | |
1886 |
|
1903 | |||
1887 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of |
|
1904 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of | |
1888 | classes to support multithreaded GTK operation without blocking, |
|
1905 | classes to support multithreaded GTK operation without blocking, | |
1889 | and matplotlib with all backends. This is a lot of still very |
|
1906 | and matplotlib with all backends. This is a lot of still very | |
1890 | experimental code, and threads are tricky. So it may still have a |
|
1907 | experimental code, and threads are tricky. So it may still have a | |
1891 | few rough edges... This code owes a lot to |
|
1908 | few rough edges... This code owes a lot to | |
1892 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by |
|
1909 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by | |
1893 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and |
|
1910 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and | |
1894 | to John Hunter for all the matplotlib work. |
|
1911 | to John Hunter for all the matplotlib work. | |
1895 |
|
1912 | |||
1896 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread |
|
1913 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread | |
1897 | options for gtk thread and matplotlib support. |
|
1914 | options for gtk thread and matplotlib support. | |
1898 |
|
1915 | |||
1899 | 2004-08-16 Fernando Perez <fperez@colorado.edu> |
|
1916 | 2004-08-16 Fernando Perez <fperez@colorado.edu> | |
1900 |
|
1917 | |||
1901 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger |
|
1918 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger | |
1902 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug |
|
1919 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug | |
1903 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. |
|
1920 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. | |
1904 |
|
1921 | |||
1905 | 2004-08-11 Fernando Perez <fperez@colorado.edu> |
|
1922 | 2004-08-11 Fernando Perez <fperez@colorado.edu> | |
1906 |
|
1923 | |||
1907 | * setup.py (isfile): Fix build so documentation gets updated for |
|
1924 | * setup.py (isfile): Fix build so documentation gets updated for | |
1908 | rpms (it was only done for .tgz builds). |
|
1925 | rpms (it was only done for .tgz builds). | |
1909 |
|
1926 | |||
1910 | 2004-08-10 Fernando Perez <fperez@colorado.edu> |
|
1927 | 2004-08-10 Fernando Perez <fperez@colorado.edu> | |
1911 |
|
1928 | |||
1912 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). |
|
1929 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). | |
1913 |
|
1930 | |||
1914 | * iplib.py : Silence syntax error exceptions in tab-completion. |
|
1931 | * iplib.py : Silence syntax error exceptions in tab-completion. | |
1915 |
|
1932 | |||
1916 | 2004-08-05 Fernando Perez <fperez@colorado.edu> |
|
1933 | 2004-08-05 Fernando Perez <fperez@colorado.edu> | |
1917 |
|
1934 | |||
1918 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set |
|
1935 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set | |
1919 | 'color off' mark for continuation prompts. This was causing long |
|
1936 | 'color off' mark for continuation prompts. This was causing long | |
1920 | continuation lines to mis-wrap. |
|
1937 | continuation lines to mis-wrap. | |
1921 |
|
1938 | |||
1922 | 2004-08-01 Fernando Perez <fperez@colorado.edu> |
|
1939 | 2004-08-01 Fernando Perez <fperez@colorado.edu> | |
1923 |
|
1940 | |||
1924 | * IPython/ipmaker.py (make_IPython): Allow the shell class used |
|
1941 | * IPython/ipmaker.py (make_IPython): Allow the shell class used | |
1925 | for building ipython to be a parameter. All this is necessary |
|
1942 | for building ipython to be a parameter. All this is necessary | |
1926 | right now to have a multithreaded version, but this insane |
|
1943 | right now to have a multithreaded version, but this insane | |
1927 | non-design will be cleaned up soon. For now, it's a hack that |
|
1944 | non-design will be cleaned up soon. For now, it's a hack that | |
1928 | works. |
|
1945 | works. | |
1929 |
|
1946 | |||
1930 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default |
|
1947 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default | |
1931 | args in various places. No bugs so far, but it's a dangerous |
|
1948 | args in various places. No bugs so far, but it's a dangerous | |
1932 | practice. |
|
1949 | practice. | |
1933 |
|
1950 | |||
1934 | 2004-07-31 Fernando Perez <fperez@colorado.edu> |
|
1951 | 2004-07-31 Fernando Perez <fperez@colorado.edu> | |
1935 |
|
1952 | |||
1936 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to |
|
1953 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to | |
1937 | fix completion of files with dots in their names under most |
|
1954 | fix completion of files with dots in their names under most | |
1938 | profiles (pysh was OK because the completion order is different). |
|
1955 | profiles (pysh was OK because the completion order is different). | |
1939 |
|
1956 | |||
1940 | 2004-07-27 Fernando Perez <fperez@colorado.edu> |
|
1957 | 2004-07-27 Fernando Perez <fperez@colorado.edu> | |
1941 |
|
1958 | |||
1942 | * IPython/iplib.py (InteractiveShell.__init__): build dict of |
|
1959 | * IPython/iplib.py (InteractiveShell.__init__): build dict of | |
1943 | keywords manually, b/c the one in keyword.py was removed in python |
|
1960 | keywords manually, b/c the one in keyword.py was removed in python | |
1944 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. |
|
1961 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. | |
1945 | This is NOT a bug under python 2.3 and earlier. |
|
1962 | This is NOT a bug under python 2.3 and earlier. | |
1946 |
|
1963 | |||
1947 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1964 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1948 |
|
1965 | |||
1949 | * IPython/ultraTB.py (VerboseTB.text): Add another |
|
1966 | * IPython/ultraTB.py (VerboseTB.text): Add another | |
1950 | linecache.checkcache() call to try to prevent inspect.py from |
|
1967 | linecache.checkcache() call to try to prevent inspect.py from | |
1951 | crashing under python 2.3. I think this fixes |
|
1968 | crashing under python 2.3. I think this fixes | |
1952 | http://www.scipy.net/roundup/ipython/issue17. |
|
1969 | http://www.scipy.net/roundup/ipython/issue17. | |
1953 |
|
1970 | |||
1954 | 2004-07-26 *** Released version 0.6.2 |
|
1971 | 2004-07-26 *** Released version 0.6.2 | |
1955 |
|
1972 | |||
1956 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1973 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1957 |
|
1974 | |||
1958 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would |
|
1975 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would | |
1959 | fail for any number. |
|
1976 | fail for any number. | |
1960 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for |
|
1977 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for | |
1961 | empty bookmarks. |
|
1978 | empty bookmarks. | |
1962 |
|
1979 | |||
1963 | 2004-07-26 *** Released version 0.6.1 |
|
1980 | 2004-07-26 *** Released version 0.6.1 | |
1964 |
|
1981 | |||
1965 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1982 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1966 |
|
1983 | |||
1967 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. |
|
1984 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. | |
1968 |
|
1985 | |||
1969 | * IPython/iplib.py (protect_filename): Applied Ville's patch for |
|
1986 | * IPython/iplib.py (protect_filename): Applied Ville's patch for | |
1970 | escaping '()[]{}' in filenames. |
|
1987 | escaping '()[]{}' in filenames. | |
1971 |
|
1988 | |||
1972 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for |
|
1989 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for | |
1973 | Python 2.2 users who lack a proper shlex.split. |
|
1990 | Python 2.2 users who lack a proper shlex.split. | |
1974 |
|
1991 | |||
1975 | 2004-07-19 Fernando Perez <fperez@colorado.edu> |
|
1992 | 2004-07-19 Fernando Perez <fperez@colorado.edu> | |
1976 |
|
1993 | |||
1977 | * IPython/iplib.py (InteractiveShell.init_readline): Add support |
|
1994 | * IPython/iplib.py (InteractiveShell.init_readline): Add support | |
1978 | for reading readline's init file. I follow the normal chain: |
|
1995 | for reading readline's init file. I follow the normal chain: | |
1979 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a |
|
1996 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a | |
1980 | report by Mike Heeter. This closes |
|
1997 | report by Mike Heeter. This closes | |
1981 | http://www.scipy.net/roundup/ipython/issue16. |
|
1998 | http://www.scipy.net/roundup/ipython/issue16. | |
1982 |
|
1999 | |||
1983 | 2004-07-18 Fernando Perez <fperez@colorado.edu> |
|
2000 | 2004-07-18 Fernando Perez <fperez@colorado.edu> | |
1984 |
|
2001 | |||
1985 | * IPython/iplib.py (__init__): Add better handling of '\' under |
|
2002 | * IPython/iplib.py (__init__): Add better handling of '\' under | |
1986 | Win32 for filenames. After a patch by Ville. |
|
2003 | Win32 for filenames. After a patch by Ville. | |
1987 |
|
2004 | |||
1988 | 2004-07-17 Fernando Perez <fperez@colorado.edu> |
|
2005 | 2004-07-17 Fernando Perez <fperez@colorado.edu> | |
1989 |
|
2006 | |||
1990 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
2007 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
1991 | autocalling would be triggered for 'foo is bar' if foo is |
|
2008 | autocalling would be triggered for 'foo is bar' if foo is | |
1992 | callable. I also cleaned up the autocall detection code to use a |
|
2009 | callable. I also cleaned up the autocall detection code to use a | |
1993 | regexp, which is faster. Bug reported by Alexander Schmolck. |
|
2010 | regexp, which is faster. Bug reported by Alexander Schmolck. | |
1994 |
|
2011 | |||
1995 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with |
|
2012 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with | |
1996 | '?' in them would confuse the help system. Reported by Alex |
|
2013 | '?' in them would confuse the help system. Reported by Alex | |
1997 | Schmolck. |
|
2014 | Schmolck. | |
1998 |
|
2015 | |||
1999 | 2004-07-16 Fernando Perez <fperez@colorado.edu> |
|
2016 | 2004-07-16 Fernando Perez <fperez@colorado.edu> | |
2000 |
|
2017 | |||
2001 | * IPython/GnuplotInteractive.py (__all__): added plot2. |
|
2018 | * IPython/GnuplotInteractive.py (__all__): added plot2. | |
2002 |
|
2019 | |||
2003 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for |
|
2020 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for | |
2004 | plotting dictionaries, lists or tuples of 1d arrays. |
|
2021 | plotting dictionaries, lists or tuples of 1d arrays. | |
2005 |
|
2022 | |||
2006 | * IPython/Magic.py (Magic.magic_hist): small clenaups and |
|
2023 | * IPython/Magic.py (Magic.magic_hist): small clenaups and | |
2007 | optimizations. |
|
2024 | optimizations. | |
2008 |
|
2025 | |||
2009 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is |
|
2026 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is | |
2010 | the information which was there from Janko's original IPP code: |
|
2027 | the information which was there from Janko's original IPP code: | |
2011 |
|
2028 | |||
2012 | 03.05.99 20:53 porto.ifm.uni-kiel.de |
|
2029 | 03.05.99 20:53 porto.ifm.uni-kiel.de | |
2013 | --Started changelog. |
|
2030 | --Started changelog. | |
2014 | --make clear do what it say it does |
|
2031 | --make clear do what it say it does | |
2015 | --added pretty output of lines from inputcache |
|
2032 | --added pretty output of lines from inputcache | |
2016 | --Made Logger a mixin class, simplifies handling of switches |
|
2033 | --Made Logger a mixin class, simplifies handling of switches | |
2017 | --Added own completer class. .string<TAB> expands to last history |
|
2034 | --Added own completer class. .string<TAB> expands to last history | |
2018 | line which starts with string. The new expansion is also present |
|
2035 | line which starts with string. The new expansion is also present | |
2019 | with Ctrl-r from the readline library. But this shows, who this |
|
2036 | with Ctrl-r from the readline library. But this shows, who this | |
2020 | can be done for other cases. |
|
2037 | can be done for other cases. | |
2021 | --Added convention that all shell functions should accept a |
|
2038 | --Added convention that all shell functions should accept a | |
2022 | parameter_string This opens the door for different behaviour for |
|
2039 | parameter_string This opens the door for different behaviour for | |
2023 | each function. @cd is a good example of this. |
|
2040 | each function. @cd is a good example of this. | |
2024 |
|
2041 | |||
2025 | 04.05.99 12:12 porto.ifm.uni-kiel.de |
|
2042 | 04.05.99 12:12 porto.ifm.uni-kiel.de | |
2026 | --added logfile rotation |
|
2043 | --added logfile rotation | |
2027 | --added new mainloop method which freezes first the namespace |
|
2044 | --added new mainloop method which freezes first the namespace | |
2028 |
|
2045 | |||
2029 | 07.05.99 21:24 porto.ifm.uni-kiel.de |
|
2046 | 07.05.99 21:24 porto.ifm.uni-kiel.de | |
2030 | --added the docreader classes. Now there is a help system. |
|
2047 | --added the docreader classes. Now there is a help system. | |
2031 | -This is only a first try. Currently it's not easy to put new |
|
2048 | -This is only a first try. Currently it's not easy to put new | |
2032 | stuff in the indices. But this is the way to go. Info would be |
|
2049 | stuff in the indices. But this is the way to go. Info would be | |
2033 | better, but HTML is every where and not everybody has an info |
|
2050 | better, but HTML is every where and not everybody has an info | |
2034 | system installed and it's not so easy to change html-docs to info. |
|
2051 | system installed and it's not so easy to change html-docs to info. | |
2035 | --added global logfile option |
|
2052 | --added global logfile option | |
2036 | --there is now a hook for object inspection method pinfo needs to |
|
2053 | --there is now a hook for object inspection method pinfo needs to | |
2037 | be provided for this. Can be reached by two '??'. |
|
2054 | be provided for this. Can be reached by two '??'. | |
2038 |
|
2055 | |||
2039 | 08.05.99 20:51 porto.ifm.uni-kiel.de |
|
2056 | 08.05.99 20:51 porto.ifm.uni-kiel.de | |
2040 | --added a README |
|
2057 | --added a README | |
2041 | --bug in rc file. Something has changed so functions in the rc |
|
2058 | --bug in rc file. Something has changed so functions in the rc | |
2042 | file need to reference the shell and not self. Not clear if it's a |
|
2059 | file need to reference the shell and not self. Not clear if it's a | |
2043 | bug or feature. |
|
2060 | bug or feature. | |
2044 | --changed rc file for new behavior |
|
2061 | --changed rc file for new behavior | |
2045 |
|
2062 | |||
2046 | 2004-07-15 Fernando Perez <fperez@colorado.edu> |
|
2063 | 2004-07-15 Fernando Perez <fperez@colorado.edu> | |
2047 |
|
2064 | |||
2048 | * IPython/Logger.py (Logger.log): fixed recent bug where the input |
|
2065 | * IPython/Logger.py (Logger.log): fixed recent bug where the input | |
2049 | cache was falling out of sync in bizarre manners when multi-line |
|
2066 | cache was falling out of sync in bizarre manners when multi-line | |
2050 | input was present. Minor optimizations and cleanup. |
|
2067 | input was present. Minor optimizations and cleanup. | |
2051 |
|
2068 | |||
2052 | (Logger): Remove old Changelog info for cleanup. This is the |
|
2069 | (Logger): Remove old Changelog info for cleanup. This is the | |
2053 | information which was there from Janko's original code: |
|
2070 | information which was there from Janko's original code: | |
2054 |
|
2071 | |||
2055 | Changes to Logger: - made the default log filename a parameter |
|
2072 | Changes to Logger: - made the default log filename a parameter | |
2056 |
|
2073 | |||
2057 | - put a check for lines beginning with !@? in log(). Needed |
|
2074 | - put a check for lines beginning with !@? in log(). Needed | |
2058 | (even if the handlers properly log their lines) for mid-session |
|
2075 | (even if the handlers properly log their lines) for mid-session | |
2059 | logging activation to work properly. Without this, lines logged |
|
2076 | logging activation to work properly. Without this, lines logged | |
2060 | in mid session, which get read from the cache, would end up |
|
2077 | in mid session, which get read from the cache, would end up | |
2061 | 'bare' (with !@? in the open) in the log. Now they are caught |
|
2078 | 'bare' (with !@? in the open) in the log. Now they are caught | |
2062 | and prepended with a #. |
|
2079 | and prepended with a #. | |
2063 |
|
2080 | |||
2064 | * IPython/iplib.py (InteractiveShell.init_readline): added check |
|
2081 | * IPython/iplib.py (InteractiveShell.init_readline): added check | |
2065 | in case MagicCompleter fails to be defined, so we don't crash. |
|
2082 | in case MagicCompleter fails to be defined, so we don't crash. | |
2066 |
|
2083 | |||
2067 | 2004-07-13 Fernando Perez <fperez@colorado.edu> |
|
2084 | 2004-07-13 Fernando Perez <fperez@colorado.edu> | |
2068 |
|
2085 | |||
2069 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation |
|
2086 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation | |
2070 | of EPS if the requested filename ends in '.eps'. |
|
2087 | of EPS if the requested filename ends in '.eps'. | |
2071 |
|
2088 | |||
2072 | 2004-07-04 Fernando Perez <fperez@colorado.edu> |
|
2089 | 2004-07-04 Fernando Perez <fperez@colorado.edu> | |
2073 |
|
2090 | |||
2074 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix |
|
2091 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix | |
2075 | escaping of quotes when calling the shell. |
|
2092 | escaping of quotes when calling the shell. | |
2076 |
|
2093 | |||
2077 | 2004-07-02 Fernando Perez <fperez@colorado.edu> |
|
2094 | 2004-07-02 Fernando Perez <fperez@colorado.edu> | |
2078 |
|
2095 | |||
2079 | * IPython/Prompts.py (CachedOutput.update): Fix problem with |
|
2096 | * IPython/Prompts.py (CachedOutput.update): Fix problem with | |
2080 | gettext not working because we were clobbering '_'. Fixes |
|
2097 | gettext not working because we were clobbering '_'. Fixes | |
2081 | http://www.scipy.net/roundup/ipython/issue6. |
|
2098 | http://www.scipy.net/roundup/ipython/issue6. | |
2082 |
|
2099 | |||
2083 | 2004-07-01 Fernando Perez <fperez@colorado.edu> |
|
2100 | 2004-07-01 Fernando Perez <fperez@colorado.edu> | |
2084 |
|
2101 | |||
2085 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling |
|
2102 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling | |
2086 | into @cd. Patch by Ville. |
|
2103 | into @cd. Patch by Ville. | |
2087 |
|
2104 | |||
2088 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
2105 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
2089 | new function to store things after ipmaker runs. Patch by Ville. |
|
2106 | new function to store things after ipmaker runs. Patch by Ville. | |
2090 | Eventually this will go away once ipmaker is removed and the class |
|
2107 | Eventually this will go away once ipmaker is removed and the class | |
2091 | gets cleaned up, but for now it's ok. Key functionality here is |
|
2108 | gets cleaned up, but for now it's ok. Key functionality here is | |
2092 | the addition of the persistent storage mechanism, a dict for |
|
2109 | the addition of the persistent storage mechanism, a dict for | |
2093 | keeping data across sessions (for now just bookmarks, but more can |
|
2110 | keeping data across sessions (for now just bookmarks, but more can | |
2094 | be implemented later). |
|
2111 | be implemented later). | |
2095 |
|
2112 | |||
2096 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, |
|
2113 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, | |
2097 | persistent across sections. Patch by Ville, I modified it |
|
2114 | persistent across sections. Patch by Ville, I modified it | |
2098 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also |
|
2115 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also | |
2099 | added a '-l' option to list all bookmarks. |
|
2116 | added a '-l' option to list all bookmarks. | |
2100 |
|
2117 | |||
2101 | * IPython/iplib.py (InteractiveShell.atexit_operations): new |
|
2118 | * IPython/iplib.py (InteractiveShell.atexit_operations): new | |
2102 | center for cleanup. Registered with atexit.register(). I moved |
|
2119 | center for cleanup. Registered with atexit.register(). I moved | |
2103 | here the old exit_cleanup(). After a patch by Ville. |
|
2120 | here the old exit_cleanup(). After a patch by Ville. | |
2104 |
|
2121 | |||
2105 | * IPython/Magic.py (get_py_filename): added '~' to the accepted |
|
2122 | * IPython/Magic.py (get_py_filename): added '~' to the accepted | |
2106 | characters in the hacked shlex_split for python 2.2. |
|
2123 | characters in the hacked shlex_split for python 2.2. | |
2107 |
|
2124 | |||
2108 | * IPython/iplib.py (file_matches): more fixes to filenames with |
|
2125 | * IPython/iplib.py (file_matches): more fixes to filenames with | |
2109 | whitespace in them. It's not perfect, but limitations in python's |
|
2126 | whitespace in them. It's not perfect, but limitations in python's | |
2110 | readline make it impossible to go further. |
|
2127 | readline make it impossible to go further. | |
2111 |
|
2128 | |||
2112 | 2004-06-29 Fernando Perez <fperez@colorado.edu> |
|
2129 | 2004-06-29 Fernando Perez <fperez@colorado.edu> | |
2113 |
|
2130 | |||
2114 | * IPython/iplib.py (file_matches): escape whitespace correctly in |
|
2131 | * IPython/iplib.py (file_matches): escape whitespace correctly in | |
2115 | filename completions. Bug reported by Ville. |
|
2132 | filename completions. Bug reported by Ville. | |
2116 |
|
2133 | |||
2117 | 2004-06-28 Fernando Perez <fperez@colorado.edu> |
|
2134 | 2004-06-28 Fernando Perez <fperez@colorado.edu> | |
2118 |
|
2135 | |||
2119 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now |
|
2136 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now | |
2120 | the history file will be called 'history-PROFNAME' (or just |
|
2137 | the history file will be called 'history-PROFNAME' (or just | |
2121 | 'history' if no profile is loaded). I was getting annoyed at |
|
2138 | 'history' if no profile is loaded). I was getting annoyed at | |
2122 | getting my Numerical work history clobbered by pysh sessions. |
|
2139 | getting my Numerical work history clobbered by pysh sessions. | |
2123 |
|
2140 | |||
2124 | * IPython/iplib.py (InteractiveShell.__init__): Internal |
|
2141 | * IPython/iplib.py (InteractiveShell.__init__): Internal | |
2125 | getoutputerror() function so that we can honor the system_verbose |
|
2142 | getoutputerror() function so that we can honor the system_verbose | |
2126 | flag for _all_ system calls. I also added escaping of # |
|
2143 | flag for _all_ system calls. I also added escaping of # | |
2127 | characters here to avoid confusing Itpl. |
|
2144 | characters here to avoid confusing Itpl. | |
2128 |
|
2145 | |||
2129 | * IPython/Magic.py (shlex_split): removed call to shell in |
|
2146 | * IPython/Magic.py (shlex_split): removed call to shell in | |
2130 | parse_options and replaced it with shlex.split(). The annoying |
|
2147 | parse_options and replaced it with shlex.split(). The annoying | |
2131 | part was that in Python 2.2, shlex.split() doesn't exist, so I had |
|
2148 | part was that in Python 2.2, shlex.split() doesn't exist, so I had | |
2132 | to backport it from 2.3, with several frail hacks (the shlex |
|
2149 | to backport it from 2.3, with several frail hacks (the shlex | |
2133 | module is rather limited in 2.2). Thanks to a suggestion by Ville |
|
2150 | module is rather limited in 2.2). Thanks to a suggestion by Ville | |
2134 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no |
|
2151 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no | |
2135 | problem. |
|
2152 | problem. | |
2136 |
|
2153 | |||
2137 | (Magic.magic_system_verbose): new toggle to print the actual |
|
2154 | (Magic.magic_system_verbose): new toggle to print the actual | |
2138 | system calls made by ipython. Mainly for debugging purposes. |
|
2155 | system calls made by ipython. Mainly for debugging purposes. | |
2139 |
|
2156 | |||
2140 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which |
|
2157 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which | |
2141 | doesn't support persistence. Reported (and fix suggested) by |
|
2158 | doesn't support persistence. Reported (and fix suggested) by | |
2142 | Travis Caldwell <travis_caldwell2000@yahoo.com>. |
|
2159 | Travis Caldwell <travis_caldwell2000@yahoo.com>. | |
2143 |
|
2160 | |||
2144 | 2004-06-26 Fernando Perez <fperez@colorado.edu> |
|
2161 | 2004-06-26 Fernando Perez <fperez@colorado.edu> | |
2145 |
|
2162 | |||
2146 | * IPython/Logger.py (Logger.log): fix to handle correctly empty |
|
2163 | * IPython/Logger.py (Logger.log): fix to handle correctly empty | |
2147 | continue prompts. |
|
2164 | continue prompts. | |
2148 |
|
2165 | |||
2149 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() |
|
2166 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() | |
2150 | function (basically a big docstring) and a few more things here to |
|
2167 | function (basically a big docstring) and a few more things here to | |
2151 | speedup startup. pysh.py is now very lightweight. We want because |
|
2168 | speedup startup. pysh.py is now very lightweight. We want because | |
2152 | it gets execfile'd, while InterpreterExec gets imported, so |
|
2169 | it gets execfile'd, while InterpreterExec gets imported, so | |
2153 | byte-compilation saves time. |
|
2170 | byte-compilation saves time. | |
2154 |
|
2171 | |||
2155 | 2004-06-25 Fernando Perez <fperez@colorado.edu> |
|
2172 | 2004-06-25 Fernando Perez <fperez@colorado.edu> | |
2156 |
|
2173 | |||
2157 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd |
|
2174 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd | |
2158 | -NUM', which was recently broken. |
|
2175 | -NUM', which was recently broken. | |
2159 |
|
2176 | |||
2160 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! |
|
2177 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! | |
2161 | in multi-line input (but not !!, which doesn't make sense there). |
|
2178 | in multi-line input (but not !!, which doesn't make sense there). | |
2162 |
|
2179 | |||
2163 | * IPython/UserConfig/ipythonrc: made autoindent on by default. |
|
2180 | * IPython/UserConfig/ipythonrc: made autoindent on by default. | |
2164 | It's just too useful, and people can turn it off in the less |
|
2181 | It's just too useful, and people can turn it off in the less | |
2165 | common cases where it's a problem. |
|
2182 | common cases where it's a problem. | |
2166 |
|
2183 | |||
2167 | 2004-06-24 Fernando Perez <fperez@colorado.edu> |
|
2184 | 2004-06-24 Fernando Perez <fperez@colorado.edu> | |
2168 |
|
2185 | |||
2169 | * IPython/iplib.py (InteractiveShell._prefilter): big change - |
|
2186 | * IPython/iplib.py (InteractiveShell._prefilter): big change - | |
2170 | special syntaxes (like alias calling) is now allied in multi-line |
|
2187 | special syntaxes (like alias calling) is now allied in multi-line | |
2171 | input. This is still _very_ experimental, but it's necessary for |
|
2188 | input. This is still _very_ experimental, but it's necessary for | |
2172 | efficient shell usage combining python looping syntax with system |
|
2189 | efficient shell usage combining python looping syntax with system | |
2173 | calls. For now it's restricted to aliases, I don't think it |
|
2190 | calls. For now it's restricted to aliases, I don't think it | |
2174 | really even makes sense to have this for magics. |
|
2191 | really even makes sense to have this for magics. | |
2175 |
|
2192 | |||
2176 | 2004-06-23 Fernando Perez <fperez@colorado.edu> |
|
2193 | 2004-06-23 Fernando Perez <fperez@colorado.edu> | |
2177 |
|
2194 | |||
2178 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added |
|
2195 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added | |
2179 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. |
|
2196 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. | |
2180 |
|
2197 | |||
2181 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle |
|
2198 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle | |
2182 | extensions under Windows (after code sent by Gary Bishop). The |
|
2199 | extensions under Windows (after code sent by Gary Bishop). The | |
2183 | extensions considered 'executable' are stored in IPython's rc |
|
2200 | extensions considered 'executable' are stored in IPython's rc | |
2184 | structure as win_exec_ext. |
|
2201 | structure as win_exec_ext. | |
2185 |
|
2202 | |||
2186 | * IPython/genutils.py (shell): new function, like system() but |
|
2203 | * IPython/genutils.py (shell): new function, like system() but | |
2187 | without return value. Very useful for interactive shell work. |
|
2204 | without return value. Very useful for interactive shell work. | |
2188 |
|
2205 | |||
2189 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to |
|
2206 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to | |
2190 | delete aliases. |
|
2207 | delete aliases. | |
2191 |
|
2208 | |||
2192 | * IPython/iplib.py (InteractiveShell.alias_table_update): make |
|
2209 | * IPython/iplib.py (InteractiveShell.alias_table_update): make | |
2193 | sure that the alias table doesn't contain python keywords. |
|
2210 | sure that the alias table doesn't contain python keywords. | |
2194 |
|
2211 | |||
2195 | 2004-06-21 Fernando Perez <fperez@colorado.edu> |
|
2212 | 2004-06-21 Fernando Perez <fperez@colorado.edu> | |
2196 |
|
2213 | |||
2197 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when |
|
2214 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when | |
2198 | non-existent items are found in $PATH. Reported by Thorsten. |
|
2215 | non-existent items are found in $PATH. Reported by Thorsten. | |
2199 |
|
2216 | |||
2200 | 2004-06-20 Fernando Perez <fperez@colorado.edu> |
|
2217 | 2004-06-20 Fernando Perez <fperez@colorado.edu> | |
2201 |
|
2218 | |||
2202 | * IPython/iplib.py (complete): modified the completer so that the |
|
2219 | * IPython/iplib.py (complete): modified the completer so that the | |
2203 | order of priorities can be easily changed at runtime. |
|
2220 | order of priorities can be easily changed at runtime. | |
2204 |
|
2221 | |||
2205 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): |
|
2222 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): | |
2206 | Modified to auto-execute all lines beginning with '~', '/' or '.'. |
|
2223 | Modified to auto-execute all lines beginning with '~', '/' or '.'. | |
2207 |
|
2224 | |||
2208 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to |
|
2225 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to | |
2209 | expand Python variables prepended with $ in all system calls. The |
|
2226 | expand Python variables prepended with $ in all system calls. The | |
2210 | same was done to InteractiveShell.handle_shell_escape. Now all |
|
2227 | same was done to InteractiveShell.handle_shell_escape. Now all | |
2211 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the |
|
2228 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the | |
2212 | expansion of python variables and expressions according to the |
|
2229 | expansion of python variables and expressions according to the | |
2213 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. |
|
2230 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. | |
2214 |
|
2231 | |||
2215 | Though PEP-215 has been rejected, a similar (but simpler) one |
|
2232 | Though PEP-215 has been rejected, a similar (but simpler) one | |
2216 | seems like it will go into Python 2.4, PEP-292 - |
|
2233 | seems like it will go into Python 2.4, PEP-292 - | |
2217 | http://www.python.org/peps/pep-0292.html. |
|
2234 | http://www.python.org/peps/pep-0292.html. | |
2218 |
|
2235 | |||
2219 | I'll keep the full syntax of PEP-215, since IPython has since the |
|
2236 | I'll keep the full syntax of PEP-215, since IPython has since the | |
2220 | start used Ka-Ping Yee's reference implementation discussed there |
|
2237 | start used Ka-Ping Yee's reference implementation discussed there | |
2221 | (Itpl), and I actually like the powerful semantics it offers. |
|
2238 | (Itpl), and I actually like the powerful semantics it offers. | |
2222 |
|
2239 | |||
2223 | In order to access normal shell variables, the $ has to be escaped |
|
2240 | In order to access normal shell variables, the $ has to be escaped | |
2224 | via an extra $. For example: |
|
2241 | via an extra $. For example: | |
2225 |
|
2242 | |||
2226 | In [7]: PATH='a python variable' |
|
2243 | In [7]: PATH='a python variable' | |
2227 |
|
2244 | |||
2228 | In [8]: !echo $PATH |
|
2245 | In [8]: !echo $PATH | |
2229 | a python variable |
|
2246 | a python variable | |
2230 |
|
2247 | |||
2231 | In [9]: !echo $$PATH |
|
2248 | In [9]: !echo $$PATH | |
2232 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2249 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2233 |
|
2250 | |||
2234 | (Magic.parse_options): escape $ so the shell doesn't evaluate |
|
2251 | (Magic.parse_options): escape $ so the shell doesn't evaluate | |
2235 | things prematurely. |
|
2252 | things prematurely. | |
2236 |
|
2253 | |||
2237 | * IPython/iplib.py (InteractiveShell.call_alias): added the |
|
2254 | * IPython/iplib.py (InteractiveShell.call_alias): added the | |
2238 | ability for aliases to expand python variables via $. |
|
2255 | ability for aliases to expand python variables via $. | |
2239 |
|
2256 | |||
2240 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias |
|
2257 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias | |
2241 | system, now there's a @rehash/@rehashx pair of magics. These work |
|
2258 | system, now there's a @rehash/@rehashx pair of magics. These work | |
2242 | like the csh rehash command, and can be invoked at any time. They |
|
2259 | like the csh rehash command, and can be invoked at any time. They | |
2243 | build a table of aliases to everything in the user's $PATH |
|
2260 | build a table of aliases to everything in the user's $PATH | |
2244 | (@rehash uses everything, @rehashx is slower but only adds |
|
2261 | (@rehash uses everything, @rehashx is slower but only adds | |
2245 | executable files). With this, the pysh.py-based shell profile can |
|
2262 | executable files). With this, the pysh.py-based shell profile can | |
2246 | now simply call rehash upon startup, and full access to all |
|
2263 | now simply call rehash upon startup, and full access to all | |
2247 | programs in the user's path is obtained. |
|
2264 | programs in the user's path is obtained. | |
2248 |
|
2265 | |||
2249 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias |
|
2266 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias | |
2250 | functionality is now fully in place. I removed the old dynamic |
|
2267 | functionality is now fully in place. I removed the old dynamic | |
2251 | code generation based approach, in favor of a much lighter one |
|
2268 | code generation based approach, in favor of a much lighter one | |
2252 | based on a simple dict. The advantage is that this allows me to |
|
2269 | based on a simple dict. The advantage is that this allows me to | |
2253 | now have thousands of aliases with negligible cost (unthinkable |
|
2270 | now have thousands of aliases with negligible cost (unthinkable | |
2254 | with the old system). |
|
2271 | with the old system). | |
2255 |
|
2272 | |||
2256 | 2004-06-19 Fernando Perez <fperez@colorado.edu> |
|
2273 | 2004-06-19 Fernando Perez <fperez@colorado.edu> | |
2257 |
|
2274 | |||
2258 | * IPython/iplib.py (__init__): extended MagicCompleter class to |
|
2275 | * IPython/iplib.py (__init__): extended MagicCompleter class to | |
2259 | also complete (last in priority) on user aliases. |
|
2276 | also complete (last in priority) on user aliases. | |
2260 |
|
2277 | |||
2261 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in |
|
2278 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in | |
2262 | call to eval. |
|
2279 | call to eval. | |
2263 | (ItplNS.__init__): Added a new class which functions like Itpl, |
|
2280 | (ItplNS.__init__): Added a new class which functions like Itpl, | |
2264 | but allows configuring the namespace for the evaluation to occur |
|
2281 | but allows configuring the namespace for the evaluation to occur | |
2265 | in. |
|
2282 | in. | |
2266 |
|
2283 | |||
2267 | 2004-06-18 Fernando Perez <fperez@colorado.edu> |
|
2284 | 2004-06-18 Fernando Perez <fperez@colorado.edu> | |
2268 |
|
2285 | |||
2269 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a |
|
2286 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a | |
2270 | better message when 'exit' or 'quit' are typed (a common newbie |
|
2287 | better message when 'exit' or 'quit' are typed (a common newbie | |
2271 | confusion). |
|
2288 | confusion). | |
2272 |
|
2289 | |||
2273 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color |
|
2290 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color | |
2274 | check for Windows users. |
|
2291 | check for Windows users. | |
2275 |
|
2292 | |||
2276 | * IPython/iplib.py (InteractiveShell.user_setup): removed |
|
2293 | * IPython/iplib.py (InteractiveShell.user_setup): removed | |
2277 | disabling of colors for Windows. I'll test at runtime and issue a |
|
2294 | disabling of colors for Windows. I'll test at runtime and issue a | |
2278 | warning if Gary's readline isn't found, as to nudge users to |
|
2295 | warning if Gary's readline isn't found, as to nudge users to | |
2279 | download it. |
|
2296 | download it. | |
2280 |
|
2297 | |||
2281 | 2004-06-16 Fernando Perez <fperez@colorado.edu> |
|
2298 | 2004-06-16 Fernando Perez <fperez@colorado.edu> | |
2282 |
|
2299 | |||
2283 | * IPython/genutils.py (Stream.__init__): changed to print errors |
|
2300 | * IPython/genutils.py (Stream.__init__): changed to print errors | |
2284 | to sys.stderr. I had a circular dependency here. Now it's |
|
2301 | to sys.stderr. I had a circular dependency here. Now it's | |
2285 | possible to run ipython as IDLE's shell (consider this pre-alpha, |
|
2302 | possible to run ipython as IDLE's shell (consider this pre-alpha, | |
2286 | since true stdout things end up in the starting terminal instead |
|
2303 | since true stdout things end up in the starting terminal instead | |
2287 | of IDLE's out). |
|
2304 | of IDLE's out). | |
2288 |
|
2305 | |||
2289 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for |
|
2306 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for | |
2290 | users who haven't # updated their prompt_in2 definitions. Remove |
|
2307 | users who haven't # updated their prompt_in2 definitions. Remove | |
2291 | eventually. |
|
2308 | eventually. | |
2292 | (multiple_replace): added credit to original ASPN recipe. |
|
2309 | (multiple_replace): added credit to original ASPN recipe. | |
2293 |
|
2310 | |||
2294 | 2004-06-15 Fernando Perez <fperez@colorado.edu> |
|
2311 | 2004-06-15 Fernando Perez <fperez@colorado.edu> | |
2295 |
|
2312 | |||
2296 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the |
|
2313 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the | |
2297 | list of auto-defined aliases. |
|
2314 | list of auto-defined aliases. | |
2298 |
|
2315 | |||
2299 | 2004-06-13 Fernando Perez <fperez@colorado.edu> |
|
2316 | 2004-06-13 Fernando Perez <fperez@colorado.edu> | |
2300 |
|
2317 | |||
2301 | * setup.py (scriptfiles): Don't trigger win_post_install unless an |
|
2318 | * setup.py (scriptfiles): Don't trigger win_post_install unless an | |
2302 | install was really requested (so setup.py can be used for other |
|
2319 | install was really requested (so setup.py can be used for other | |
2303 | things under Windows). |
|
2320 | things under Windows). | |
2304 |
|
2321 | |||
2305 | 2004-06-10 Fernando Perez <fperez@colorado.edu> |
|
2322 | 2004-06-10 Fernando Perez <fperez@colorado.edu> | |
2306 |
|
2323 | |||
2307 | * IPython/Logger.py (Logger.create_log): Manually remove any old |
|
2324 | * IPython/Logger.py (Logger.create_log): Manually remove any old | |
2308 | backup, since os.remove may fail under Windows. Fixes bug |
|
2325 | backup, since os.remove may fail under Windows. Fixes bug | |
2309 | reported by Thorsten. |
|
2326 | reported by Thorsten. | |
2310 |
|
2327 | |||
2311 | 2004-06-09 Fernando Perez <fperez@colorado.edu> |
|
2328 | 2004-06-09 Fernando Perez <fperez@colorado.edu> | |
2312 |
|
2329 | |||
2313 | * examples/example-embed.py: fixed all references to %n (replaced |
|
2330 | * examples/example-embed.py: fixed all references to %n (replaced | |
2314 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done |
|
2331 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done | |
2315 | for all examples and the manual as well. |
|
2332 | for all examples and the manual as well. | |
2316 |
|
2333 | |||
2317 | 2004-06-08 Fernando Perez <fperez@colorado.edu> |
|
2334 | 2004-06-08 Fernando Perez <fperez@colorado.edu> | |
2318 |
|
2335 | |||
2319 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt |
|
2336 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt | |
2320 | alignment and color management. All 3 prompt subsystems now |
|
2337 | alignment and color management. All 3 prompt subsystems now | |
2321 | inherit from BasePrompt. |
|
2338 | inherit from BasePrompt. | |
2322 |
|
2339 | |||
2323 | * tools/release: updates for windows installer build and tag rpms |
|
2340 | * tools/release: updates for windows installer build and tag rpms | |
2324 | with python version (since paths are fixed). |
|
2341 | with python version (since paths are fixed). | |
2325 |
|
2342 | |||
2326 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, |
|
2343 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, | |
2327 | which will become eventually obsolete. Also fixed the default |
|
2344 | which will become eventually obsolete. Also fixed the default | |
2328 | prompt_in2 to use \D, so at least new users start with the correct |
|
2345 | prompt_in2 to use \D, so at least new users start with the correct | |
2329 | defaults. |
|
2346 | defaults. | |
2330 | WARNING: Users with existing ipythonrc files will need to apply |
|
2347 | WARNING: Users with existing ipythonrc files will need to apply | |
2331 | this fix manually! |
|
2348 | this fix manually! | |
2332 |
|
2349 | |||
2333 | * setup.py: make windows installer (.exe). This is finally the |
|
2350 | * setup.py: make windows installer (.exe). This is finally the | |
2334 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, |
|
2351 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, | |
2335 | which I hadn't included because it required Python 2.3 (or recent |
|
2352 | which I hadn't included because it required Python 2.3 (or recent | |
2336 | distutils). |
|
2353 | distutils). | |
2337 |
|
2354 | |||
2338 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect |
|
2355 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect | |
2339 | usage of new '\D' escape. |
|
2356 | usage of new '\D' escape. | |
2340 |
|
2357 | |||
2341 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which |
|
2358 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which | |
2342 | lacks os.getuid()) |
|
2359 | lacks os.getuid()) | |
2343 | (CachedOutput.set_colors): Added the ability to turn coloring |
|
2360 | (CachedOutput.set_colors): Added the ability to turn coloring | |
2344 | on/off with @colors even for manually defined prompt colors. It |
|
2361 | on/off with @colors even for manually defined prompt colors. It | |
2345 | uses a nasty global, but it works safely and via the generic color |
|
2362 | uses a nasty global, but it works safely and via the generic color | |
2346 | handling mechanism. |
|
2363 | handling mechanism. | |
2347 | (Prompt2.__init__): Introduced new escape '\D' for continuation |
|
2364 | (Prompt2.__init__): Introduced new escape '\D' for continuation | |
2348 | prompts. It represents the counter ('\#') as dots. |
|
2365 | prompts. It represents the counter ('\#') as dots. | |
2349 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will |
|
2366 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will | |
2350 | need to update their ipythonrc files and replace '%n' with '\D' in |
|
2367 | need to update their ipythonrc files and replace '%n' with '\D' in | |
2351 | their prompt_in2 settings everywhere. Sorry, but there's |
|
2368 | their prompt_in2 settings everywhere. Sorry, but there's | |
2352 | otherwise no clean way to get all prompts to properly align. The |
|
2369 | otherwise no clean way to get all prompts to properly align. The | |
2353 | ipythonrc shipped with IPython has been updated. |
|
2370 | ipythonrc shipped with IPython has been updated. | |
2354 |
|
2371 | |||
2355 | 2004-06-07 Fernando Perez <fperez@colorado.edu> |
|
2372 | 2004-06-07 Fernando Perez <fperez@colorado.edu> | |
2356 |
|
2373 | |||
2357 | * setup.py (isfile): Pass local_icons option to latex2html, so the |
|
2374 | * setup.py (isfile): Pass local_icons option to latex2html, so the | |
2358 | resulting HTML file is self-contained. Thanks to |
|
2375 | resulting HTML file is self-contained. Thanks to | |
2359 | dryice-AT-liu.com.cn for the tip. |
|
2376 | dryice-AT-liu.com.cn for the tip. | |
2360 |
|
2377 | |||
2361 | * pysh.py: I created a new profile 'shell', which implements a |
|
2378 | * pysh.py: I created a new profile 'shell', which implements a | |
2362 | _rudimentary_ IPython-based shell. This is in NO WAY a realy |
|
2379 | _rudimentary_ IPython-based shell. This is in NO WAY a realy | |
2363 | system shell, nor will it become one anytime soon. It's mainly |
|
2380 | system shell, nor will it become one anytime soon. It's mainly | |
2364 | meant to illustrate the use of the new flexible bash-like prompts. |
|
2381 | meant to illustrate the use of the new flexible bash-like prompts. | |
2365 | I guess it could be used by hardy souls for true shell management, |
|
2382 | I guess it could be used by hardy souls for true shell management, | |
2366 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' |
|
2383 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' | |
2367 | profile. This uses the InterpreterExec extension provided by |
|
2384 | profile. This uses the InterpreterExec extension provided by | |
2368 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> |
|
2385 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> | |
2369 |
|
2386 | |||
2370 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly |
|
2387 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly | |
2371 | auto-align itself with the length of the previous input prompt |
|
2388 | auto-align itself with the length of the previous input prompt | |
2372 | (taking into account the invisible color escapes). |
|
2389 | (taking into account the invisible color escapes). | |
2373 | (CachedOutput.__init__): Large restructuring of this class. Now |
|
2390 | (CachedOutput.__init__): Large restructuring of this class. Now | |
2374 | all three prompts (primary1, primary2, output) are proper objects, |
|
2391 | all three prompts (primary1, primary2, output) are proper objects, | |
2375 | managed by the 'parent' CachedOutput class. The code is still a |
|
2392 | managed by the 'parent' CachedOutput class. The code is still a | |
2376 | bit hackish (all prompts share state via a pointer to the cache), |
|
2393 | bit hackish (all prompts share state via a pointer to the cache), | |
2377 | but it's overall far cleaner than before. |
|
2394 | but it's overall far cleaner than before. | |
2378 |
|
2395 | |||
2379 | * IPython/genutils.py (getoutputerror): modified to add verbose, |
|
2396 | * IPython/genutils.py (getoutputerror): modified to add verbose, | |
2380 | debug and header options. This makes the interface of all getout* |
|
2397 | debug and header options. This makes the interface of all getout* | |
2381 | functions uniform. |
|
2398 | functions uniform. | |
2382 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. |
|
2399 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. | |
2383 |
|
2400 | |||
2384 | * IPython/Magic.py (Magic.default_option): added a function to |
|
2401 | * IPython/Magic.py (Magic.default_option): added a function to | |
2385 | allow registering default options for any magic command. This |
|
2402 | allow registering default options for any magic command. This | |
2386 | makes it easy to have profiles which customize the magics globally |
|
2403 | makes it easy to have profiles which customize the magics globally | |
2387 | for a certain use. The values set through this function are |
|
2404 | for a certain use. The values set through this function are | |
2388 | picked up by the parse_options() method, which all magics should |
|
2405 | picked up by the parse_options() method, which all magics should | |
2389 | use to parse their options. |
|
2406 | use to parse their options. | |
2390 |
|
2407 | |||
2391 | * IPython/genutils.py (warn): modified the warnings framework to |
|
2408 | * IPython/genutils.py (warn): modified the warnings framework to | |
2392 | use the Term I/O class. I'm trying to slowly unify all of |
|
2409 | use the Term I/O class. I'm trying to slowly unify all of | |
2393 | IPython's I/O operations to pass through Term. |
|
2410 | IPython's I/O operations to pass through Term. | |
2394 |
|
2411 | |||
2395 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in |
|
2412 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in | |
2396 | the secondary prompt to correctly match the length of the primary |
|
2413 | the secondary prompt to correctly match the length of the primary | |
2397 | one for any prompt. Now multi-line code will properly line up |
|
2414 | one for any prompt. Now multi-line code will properly line up | |
2398 | even for path dependent prompts, such as the new ones available |
|
2415 | even for path dependent prompts, such as the new ones available | |
2399 | via the prompt_specials. |
|
2416 | via the prompt_specials. | |
2400 |
|
2417 | |||
2401 | 2004-06-06 Fernando Perez <fperez@colorado.edu> |
|
2418 | 2004-06-06 Fernando Perez <fperez@colorado.edu> | |
2402 |
|
2419 | |||
2403 | * IPython/Prompts.py (prompt_specials): Added the ability to have |
|
2420 | * IPython/Prompts.py (prompt_specials): Added the ability to have | |
2404 | bash-like special sequences in the prompts, which get |
|
2421 | bash-like special sequences in the prompts, which get | |
2405 | automatically expanded. Things like hostname, current working |
|
2422 | automatically expanded. Things like hostname, current working | |
2406 | directory and username are implemented already, but it's easy to |
|
2423 | directory and username are implemented already, but it's easy to | |
2407 | add more in the future. Thanks to a patch by W.J. van der Laan |
|
2424 | add more in the future. Thanks to a patch by W.J. van der Laan | |
2408 | <gnufnork-AT-hetdigitalegat.nl> |
|
2425 | <gnufnork-AT-hetdigitalegat.nl> | |
2409 | (prompt_specials): Added color support for prompt strings, so |
|
2426 | (prompt_specials): Added color support for prompt strings, so | |
2410 | users can define arbitrary color setups for their prompts. |
|
2427 | users can define arbitrary color setups for their prompts. | |
2411 |
|
2428 | |||
2412 | 2004-06-05 Fernando Perez <fperez@colorado.edu> |
|
2429 | 2004-06-05 Fernando Perez <fperez@colorado.edu> | |
2413 |
|
2430 | |||
2414 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific |
|
2431 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific | |
2415 | code to load Gary Bishop's readline and configure it |
|
2432 | code to load Gary Bishop's readline and configure it | |
2416 | automatically. Thanks to Gary for help on this. |
|
2433 | automatically. Thanks to Gary for help on this. | |
2417 |
|
2434 | |||
2418 | 2004-06-01 Fernando Perez <fperez@colorado.edu> |
|
2435 | 2004-06-01 Fernando Perez <fperez@colorado.edu> | |
2419 |
|
2436 | |||
2420 | * IPython/Logger.py (Logger.create_log): fix bug for logging |
|
2437 | * IPython/Logger.py (Logger.create_log): fix bug for logging | |
2421 | with no filename (previous fix was incomplete). |
|
2438 | with no filename (previous fix was incomplete). | |
2422 |
|
2439 | |||
2423 | 2004-05-25 Fernando Perez <fperez@colorado.edu> |
|
2440 | 2004-05-25 Fernando Perez <fperez@colorado.edu> | |
2424 |
|
2441 | |||
2425 | * IPython/Magic.py (Magic.parse_options): fix bug where naked |
|
2442 | * IPython/Magic.py (Magic.parse_options): fix bug where naked | |
2426 | parens would get passed to the shell. |
|
2443 | parens would get passed to the shell. | |
2427 |
|
2444 | |||
2428 | 2004-05-20 Fernando Perez <fperez@colorado.edu> |
|
2445 | 2004-05-20 Fernando Perez <fperez@colorado.edu> | |
2429 |
|
2446 | |||
2430 | * IPython/Magic.py (Magic.magic_prun): changed default profile |
|
2447 | * IPython/Magic.py (Magic.magic_prun): changed default profile | |
2431 | sort order to 'time' (the more common profiling need). |
|
2448 | sort order to 'time' (the more common profiling need). | |
2432 |
|
2449 | |||
2433 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache |
|
2450 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache | |
2434 | so that source code shown is guaranteed in sync with the file on |
|
2451 | so that source code shown is guaranteed in sync with the file on | |
2435 | disk (also changed in psource). Similar fix to the one for |
|
2452 | disk (also changed in psource). Similar fix to the one for | |
2436 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du |
|
2453 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du | |
2437 | <yann.ledu-AT-noos.fr>. |
|
2454 | <yann.ledu-AT-noos.fr>. | |
2438 |
|
2455 | |||
2439 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands |
|
2456 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands | |
2440 | with a single option would not be correctly parsed. Closes |
|
2457 | with a single option would not be correctly parsed. Closes | |
2441 | http://www.scipy.net/roundup/ipython/issue14. This bug had been |
|
2458 | http://www.scipy.net/roundup/ipython/issue14. This bug had been | |
2442 | introduced in 0.6.0 (on 2004-05-06). |
|
2459 | introduced in 0.6.0 (on 2004-05-06). | |
2443 |
|
2460 | |||
2444 | 2004-05-13 *** Released version 0.6.0 |
|
2461 | 2004-05-13 *** Released version 0.6.0 | |
2445 |
|
2462 | |||
2446 | 2004-05-13 Fernando Perez <fperez@colorado.edu> |
|
2463 | 2004-05-13 Fernando Perez <fperez@colorado.edu> | |
2447 |
|
2464 | |||
2448 | * debian/: Added debian/ directory to CVS, so that debian support |
|
2465 | * debian/: Added debian/ directory to CVS, so that debian support | |
2449 | is publicly accessible. The debian package is maintained by Jack |
|
2466 | is publicly accessible. The debian package is maintained by Jack | |
2450 | Moffit <jack-AT-xiph.org>. |
|
2467 | Moffit <jack-AT-xiph.org>. | |
2451 |
|
2468 | |||
2452 | * Documentation: included the notes about an ipython-based system |
|
2469 | * Documentation: included the notes about an ipython-based system | |
2453 | shell (the hypothetical 'pysh') into the new_design.pdf document, |
|
2470 | shell (the hypothetical 'pysh') into the new_design.pdf document, | |
2454 | so that these ideas get distributed to users along with the |
|
2471 | so that these ideas get distributed to users along with the | |
2455 | official documentation. |
|
2472 | official documentation. | |
2456 |
|
2473 | |||
2457 | 2004-05-10 Fernando Perez <fperez@colorado.edu> |
|
2474 | 2004-05-10 Fernando Perez <fperez@colorado.edu> | |
2458 |
|
2475 | |||
2459 | * IPython/Logger.py (Logger.create_log): fix recently introduced |
|
2476 | * IPython/Logger.py (Logger.create_log): fix recently introduced | |
2460 | bug (misindented line) where logstart would fail when not given an |
|
2477 | bug (misindented line) where logstart would fail when not given an | |
2461 | explicit filename. |
|
2478 | explicit filename. | |
2462 |
|
2479 | |||
2463 | 2004-05-09 Fernando Perez <fperez@colorado.edu> |
|
2480 | 2004-05-09 Fernando Perez <fperez@colorado.edu> | |
2464 |
|
2481 | |||
2465 | * IPython/Magic.py (Magic.parse_options): skip system call when |
|
2482 | * IPython/Magic.py (Magic.parse_options): skip system call when | |
2466 | there are no options to look for. Faster, cleaner for the common |
|
2483 | there are no options to look for. Faster, cleaner for the common | |
2467 | case. |
|
2484 | case. | |
2468 |
|
2485 | |||
2469 | * Documentation: many updates to the manual: describing Windows |
|
2486 | * Documentation: many updates to the manual: describing Windows | |
2470 | support better, Gnuplot updates, credits, misc small stuff. Also |
|
2487 | support better, Gnuplot updates, credits, misc small stuff. Also | |
2471 | updated the new_design doc a bit. |
|
2488 | updated the new_design doc a bit. | |
2472 |
|
2489 | |||
2473 | 2004-05-06 *** Released version 0.6.0.rc1 |
|
2490 | 2004-05-06 *** Released version 0.6.0.rc1 | |
2474 |
|
2491 | |||
2475 | 2004-05-06 Fernando Perez <fperez@colorado.edu> |
|
2492 | 2004-05-06 Fernando Perez <fperez@colorado.edu> | |
2476 |
|
2493 | |||
2477 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += |
|
2494 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += | |
2478 | operations to use the vastly more efficient list/''.join() method. |
|
2495 | operations to use the vastly more efficient list/''.join() method. | |
2479 | (FormattedTB.text): Fix |
|
2496 | (FormattedTB.text): Fix | |
2480 | http://www.scipy.net/roundup/ipython/issue12 - exception source |
|
2497 | http://www.scipy.net/roundup/ipython/issue12 - exception source | |
2481 | extract not updated after reload. Thanks to Mike Salib |
|
2498 | extract not updated after reload. Thanks to Mike Salib | |
2482 | <msalib-AT-mit.edu> for pinning the source of the problem. |
|
2499 | <msalib-AT-mit.edu> for pinning the source of the problem. | |
2483 | Fortunately, the solution works inside ipython and doesn't require |
|
2500 | Fortunately, the solution works inside ipython and doesn't require | |
2484 | any changes to python proper. |
|
2501 | any changes to python proper. | |
2485 |
|
2502 | |||
2486 | * IPython/Magic.py (Magic.parse_options): Improved to process the |
|
2503 | * IPython/Magic.py (Magic.parse_options): Improved to process the | |
2487 | argument list as a true shell would (by actually using the |
|
2504 | argument list as a true shell would (by actually using the | |
2488 | underlying system shell). This way, all @magics automatically get |
|
2505 | underlying system shell). This way, all @magics automatically get | |
2489 | shell expansion for variables. Thanks to a comment by Alex |
|
2506 | shell expansion for variables. Thanks to a comment by Alex | |
2490 | Schmolck. |
|
2507 | Schmolck. | |
2491 |
|
2508 | |||
2492 | 2004-04-04 Fernando Perez <fperez@colorado.edu> |
|
2509 | 2004-04-04 Fernando Perez <fperez@colorado.edu> | |
2493 |
|
2510 | |||
2494 | * IPython/iplib.py (InteractiveShell.interact): Added a special |
|
2511 | * IPython/iplib.py (InteractiveShell.interact): Added a special | |
2495 | trap for a debugger quit exception, which is basically impossible |
|
2512 | trap for a debugger quit exception, which is basically impossible | |
2496 | to handle by normal mechanisms, given what pdb does to the stack. |
|
2513 | to handle by normal mechanisms, given what pdb does to the stack. | |
2497 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. |
|
2514 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. | |
2498 |
|
2515 | |||
2499 | 2004-04-03 Fernando Perez <fperez@colorado.edu> |
|
2516 | 2004-04-03 Fernando Perez <fperez@colorado.edu> | |
2500 |
|
2517 | |||
2501 | * IPython/genutils.py (Term): Standardized the names of the Term |
|
2518 | * IPython/genutils.py (Term): Standardized the names of the Term | |
2502 | class streams to cin/cout/cerr, following C++ naming conventions |
|
2519 | class streams to cin/cout/cerr, following C++ naming conventions | |
2503 | (I can't use in/out/err because 'in' is not a valid attribute |
|
2520 | (I can't use in/out/err because 'in' is not a valid attribute | |
2504 | name). |
|
2521 | name). | |
2505 |
|
2522 | |||
2506 | * IPython/iplib.py (InteractiveShell.interact): don't increment |
|
2523 | * IPython/iplib.py (InteractiveShell.interact): don't increment | |
2507 | the prompt if there's no user input. By Daniel 'Dang' Griffith |
|
2524 | the prompt if there's no user input. By Daniel 'Dang' Griffith | |
2508 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from |
|
2525 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from | |
2509 | Francois Pinard. |
|
2526 | Francois Pinard. | |
2510 |
|
2527 | |||
2511 | 2004-04-02 Fernando Perez <fperez@colorado.edu> |
|
2528 | 2004-04-02 Fernando Perez <fperez@colorado.edu> | |
2512 |
|
2529 | |||
2513 | * IPython/genutils.py (Stream.__init__): Modified to survive at |
|
2530 | * IPython/genutils.py (Stream.__init__): Modified to survive at | |
2514 | least importing in contexts where stdin/out/err aren't true file |
|
2531 | least importing in contexts where stdin/out/err aren't true file | |
2515 | objects, such as PyCrust (they lack fileno() and mode). However, |
|
2532 | objects, such as PyCrust (they lack fileno() and mode). However, | |
2516 | the recovery facilities which rely on these things existing will |
|
2533 | the recovery facilities which rely on these things existing will | |
2517 | not work. |
|
2534 | not work. | |
2518 |
|
2535 | |||
2519 | 2004-04-01 Fernando Perez <fperez@colorado.edu> |
|
2536 | 2004-04-01 Fernando Perez <fperez@colorado.edu> | |
2520 |
|
2537 | |||
2521 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to |
|
2538 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to | |
2522 | use the new getoutputerror() function, so it properly |
|
2539 | use the new getoutputerror() function, so it properly | |
2523 | distinguishes stdout/err. |
|
2540 | distinguishes stdout/err. | |
2524 |
|
2541 | |||
2525 | * IPython/genutils.py (getoutputerror): added a function to |
|
2542 | * IPython/genutils.py (getoutputerror): added a function to | |
2526 | capture separately the standard output and error of a command. |
|
2543 | capture separately the standard output and error of a command. | |
2527 | After a comment from dang on the mailing lists. This code is |
|
2544 | After a comment from dang on the mailing lists. This code is | |
2528 | basically a modified version of commands.getstatusoutput(), from |
|
2545 | basically a modified version of commands.getstatusoutput(), from | |
2529 | the standard library. |
|
2546 | the standard library. | |
2530 |
|
2547 | |||
2531 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added |
|
2548 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added | |
2532 | '!!' as a special syntax (shorthand) to access @sx. |
|
2549 | '!!' as a special syntax (shorthand) to access @sx. | |
2533 |
|
2550 | |||
2534 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell |
|
2551 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell | |
2535 | command and return its output as a list split on '\n'. |
|
2552 | command and return its output as a list split on '\n'. | |
2536 |
|
2553 | |||
2537 | 2004-03-31 Fernando Perez <fperez@colorado.edu> |
|
2554 | 2004-03-31 Fernando Perez <fperez@colorado.edu> | |
2538 |
|
2555 | |||
2539 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ |
|
2556 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ | |
2540 | method to dictionaries used as FakeModule instances if they lack |
|
2557 | method to dictionaries used as FakeModule instances if they lack | |
2541 | it. At least pydoc in python2.3 breaks for runtime-defined |
|
2558 | it. At least pydoc in python2.3 breaks for runtime-defined | |
2542 | functions without this hack. At some point I need to _really_ |
|
2559 | functions without this hack. At some point I need to _really_ | |
2543 | understand what FakeModule is doing, because it's a gross hack. |
|
2560 | understand what FakeModule is doing, because it's a gross hack. | |
2544 | But it solves Arnd's problem for now... |
|
2561 | But it solves Arnd's problem for now... | |
2545 |
|
2562 | |||
2546 | 2004-02-27 Fernando Perez <fperez@colorado.edu> |
|
2563 | 2004-02-27 Fernando Perez <fperez@colorado.edu> | |
2547 |
|
2564 | |||
2548 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' |
|
2565 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' | |
2549 | mode would behave erratically. Also increased the number of |
|
2566 | mode would behave erratically. Also increased the number of | |
2550 | possible logs in rotate mod to 999. Thanks to Rod Holland |
|
2567 | possible logs in rotate mod to 999. Thanks to Rod Holland | |
2551 | <rhh@StructureLABS.com> for the report and fixes. |
|
2568 | <rhh@StructureLABS.com> for the report and fixes. | |
2552 |
|
2569 | |||
2553 | 2004-02-26 Fernando Perez <fperez@colorado.edu> |
|
2570 | 2004-02-26 Fernando Perez <fperez@colorado.edu> | |
2554 |
|
2571 | |||
2555 | * IPython/genutils.py (page): Check that the curses module really |
|
2572 | * IPython/genutils.py (page): Check that the curses module really | |
2556 | has the initscr attribute before trying to use it. For some |
|
2573 | has the initscr attribute before trying to use it. For some | |
2557 | reason, the Solaris curses module is missing this. I think this |
|
2574 | reason, the Solaris curses module is missing this. I think this | |
2558 | should be considered a Solaris python bug, but I'm not sure. |
|
2575 | should be considered a Solaris python bug, but I'm not sure. | |
2559 |
|
2576 | |||
2560 | 2004-01-17 Fernando Perez <fperez@colorado.edu> |
|
2577 | 2004-01-17 Fernando Perez <fperez@colorado.edu> | |
2561 |
|
2578 | |||
2562 | * IPython/genutils.py (Stream.__init__): Changes to try to make |
|
2579 | * IPython/genutils.py (Stream.__init__): Changes to try to make | |
2563 | ipython robust against stdin/out/err being closed by the user. |
|
2580 | ipython robust against stdin/out/err being closed by the user. | |
2564 | This is 'user error' (and blocks a normal python session, at least |
|
2581 | This is 'user error' (and blocks a normal python session, at least | |
2565 | the stdout case). However, Ipython should be able to survive such |
|
2582 | the stdout case). However, Ipython should be able to survive such | |
2566 | instances of abuse as gracefully as possible. To simplify the |
|
2583 | instances of abuse as gracefully as possible. To simplify the | |
2567 | coding and maintain compatibility with Gary Bishop's Term |
|
2584 | coding and maintain compatibility with Gary Bishop's Term | |
2568 | contributions, I've made use of classmethods for this. I think |
|
2585 | contributions, I've made use of classmethods for this. I think | |
2569 | this introduces a dependency on python 2.2. |
|
2586 | this introduces a dependency on python 2.2. | |
2570 |
|
2587 | |||
2571 | 2004-01-13 Fernando Perez <fperez@colorado.edu> |
|
2588 | 2004-01-13 Fernando Perez <fperez@colorado.edu> | |
2572 |
|
2589 | |||
2573 | * IPython/numutils.py (exp_safe): simplified the code a bit and |
|
2590 | * IPython/numutils.py (exp_safe): simplified the code a bit and | |
2574 | removed the need for importing the kinds module altogether. |
|
2591 | removed the need for importing the kinds module altogether. | |
2575 |
|
2592 | |||
2576 | 2004-01-06 Fernando Perez <fperez@colorado.edu> |
|
2593 | 2004-01-06 Fernando Perez <fperez@colorado.edu> | |
2577 |
|
2594 | |||
2578 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system |
|
2595 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system | |
2579 | a magic function instead, after some community feedback. No |
|
2596 | a magic function instead, after some community feedback. No | |
2580 | special syntax will exist for it, but its name is deliberately |
|
2597 | special syntax will exist for it, but its name is deliberately | |
2581 | very short. |
|
2598 | very short. | |
2582 |
|
2599 | |||
2583 | 2003-12-20 Fernando Perez <fperez@colorado.edu> |
|
2600 | 2003-12-20 Fernando Perez <fperez@colorado.edu> | |
2584 |
|
2601 | |||
2585 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added |
|
2602 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added | |
2586 | new functionality, to automagically assign the result of a shell |
|
2603 | new functionality, to automagically assign the result of a shell | |
2587 | command to a variable. I'll solicit some community feedback on |
|
2604 | command to a variable. I'll solicit some community feedback on | |
2588 | this before making it permanent. |
|
2605 | this before making it permanent. | |
2589 |
|
2606 | |||
2590 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was |
|
2607 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was | |
2591 | requested about callables for which inspect couldn't obtain a |
|
2608 | requested about callables for which inspect couldn't obtain a | |
2592 | proper argspec. Thanks to a crash report sent by Etienne |
|
2609 | proper argspec. Thanks to a crash report sent by Etienne | |
2593 | Posthumus <etienne-AT-apple01.cs.vu.nl>. |
|
2610 | Posthumus <etienne-AT-apple01.cs.vu.nl>. | |
2594 |
|
2611 | |||
2595 | 2003-12-09 Fernando Perez <fperez@colorado.edu> |
|
2612 | 2003-12-09 Fernando Perez <fperez@colorado.edu> | |
2596 |
|
2613 | |||
2597 | * IPython/genutils.py (page): patch for the pager to work across |
|
2614 | * IPython/genutils.py (page): patch for the pager to work across | |
2598 | various versions of Windows. By Gary Bishop. |
|
2615 | various versions of Windows. By Gary Bishop. | |
2599 |
|
2616 | |||
2600 | 2003-12-04 Fernando Perez <fperez@colorado.edu> |
|
2617 | 2003-12-04 Fernando Perez <fperez@colorado.edu> | |
2601 |
|
2618 | |||
2602 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with |
|
2619 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with | |
2603 | Gnuplot.py version 1.7, whose internal names changed quite a bit. |
|
2620 | Gnuplot.py version 1.7, whose internal names changed quite a bit. | |
2604 | While I tested this and it looks ok, there may still be corner |
|
2621 | While I tested this and it looks ok, there may still be corner | |
2605 | cases I've missed. |
|
2622 | cases I've missed. | |
2606 |
|
2623 | |||
2607 | 2003-12-01 Fernando Perez <fperez@colorado.edu> |
|
2624 | 2003-12-01 Fernando Perez <fperez@colorado.edu> | |
2608 |
|
2625 | |||
2609 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug |
|
2626 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug | |
2610 | where a line like 'p,q=1,2' would fail because the automagic |
|
2627 | where a line like 'p,q=1,2' would fail because the automagic | |
2611 | system would be triggered for @p. |
|
2628 | system would be triggered for @p. | |
2612 |
|
2629 | |||
2613 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related |
|
2630 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related | |
2614 | cleanups, code unmodified. |
|
2631 | cleanups, code unmodified. | |
2615 |
|
2632 | |||
2616 | * IPython/genutils.py (Term): added a class for IPython to handle |
|
2633 | * IPython/genutils.py (Term): added a class for IPython to handle | |
2617 | output. In most cases it will just be a proxy for stdout/err, but |
|
2634 | output. In most cases it will just be a proxy for stdout/err, but | |
2618 | having this allows modifications to be made for some platforms, |
|
2635 | having this allows modifications to be made for some platforms, | |
2619 | such as handling color escapes under Windows. All of this code |
|
2636 | such as handling color escapes under Windows. All of this code | |
2620 | was contributed by Gary Bishop, with minor modifications by me. |
|
2637 | was contributed by Gary Bishop, with minor modifications by me. | |
2621 | The actual changes affect many files. |
|
2638 | The actual changes affect many files. | |
2622 |
|
2639 | |||
2623 | 2003-11-30 Fernando Perez <fperez@colorado.edu> |
|
2640 | 2003-11-30 Fernando Perez <fperez@colorado.edu> | |
2624 |
|
2641 | |||
2625 | * IPython/iplib.py (file_matches): new completion code, courtesy |
|
2642 | * IPython/iplib.py (file_matches): new completion code, courtesy | |
2626 | of Jeff Collins. This enables filename completion again under |
|
2643 | of Jeff Collins. This enables filename completion again under | |
2627 | python 2.3, which disabled it at the C level. |
|
2644 | python 2.3, which disabled it at the C level. | |
2628 |
|
2645 | |||
2629 | 2003-11-11 Fernando Perez <fperez@colorado.edu> |
|
2646 | 2003-11-11 Fernando Perez <fperez@colorado.edu> | |
2630 |
|
2647 | |||
2631 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand |
|
2648 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand | |
2632 | for Numeric.array(map(...)), but often convenient. |
|
2649 | for Numeric.array(map(...)), but often convenient. | |
2633 |
|
2650 | |||
2634 | 2003-11-05 Fernando Perez <fperez@colorado.edu> |
|
2651 | 2003-11-05 Fernando Perez <fperez@colorado.edu> | |
2635 |
|
2652 | |||
2636 | * IPython/numutils.py (frange): Changed a call from int() to |
|
2653 | * IPython/numutils.py (frange): Changed a call from int() to | |
2637 | int(round()) to prevent a problem reported with arange() in the |
|
2654 | int(round()) to prevent a problem reported with arange() in the | |
2638 | numpy list. |
|
2655 | numpy list. | |
2639 |
|
2656 | |||
2640 | 2003-10-06 Fernando Perez <fperez@colorado.edu> |
|
2657 | 2003-10-06 Fernando Perez <fperez@colorado.edu> | |
2641 |
|
2658 | |||
2642 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to |
|
2659 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to | |
2643 | prevent crashes if sys lacks an argv attribute (it happens with |
|
2660 | prevent crashes if sys lacks an argv attribute (it happens with | |
2644 | embedded interpreters which build a bare-bones sys module). |
|
2661 | embedded interpreters which build a bare-bones sys module). | |
2645 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. |
|
2662 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. | |
2646 |
|
2663 | |||
2647 | 2003-09-24 Fernando Perez <fperez@colorado.edu> |
|
2664 | 2003-09-24 Fernando Perez <fperez@colorado.edu> | |
2648 |
|
2665 | |||
2649 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() |
|
2666 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() | |
2650 | to protect against poorly written user objects where __getattr__ |
|
2667 | to protect against poorly written user objects where __getattr__ | |
2651 | raises exceptions other than AttributeError. Thanks to a bug |
|
2668 | raises exceptions other than AttributeError. Thanks to a bug | |
2652 | report by Oliver Sander <osander-AT-gmx.de>. |
|
2669 | report by Oliver Sander <osander-AT-gmx.de>. | |
2653 |
|
2670 | |||
2654 | * IPython/FakeModule.py (FakeModule.__repr__): this method was |
|
2671 | * IPython/FakeModule.py (FakeModule.__repr__): this method was | |
2655 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. |
|
2672 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. | |
2656 |
|
2673 | |||
2657 | 2003-09-09 Fernando Perez <fperez@colorado.edu> |
|
2674 | 2003-09-09 Fernando Perez <fperez@colorado.edu> | |
2658 |
|
2675 | |||
2659 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
2676 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
2660 | unpacking a list whith a callable as first element would |
|
2677 | unpacking a list whith a callable as first element would | |
2661 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery |
|
2678 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery | |
2662 | Collins. |
|
2679 | Collins. | |
2663 |
|
2680 | |||
2664 | 2003-08-25 *** Released version 0.5.0 |
|
2681 | 2003-08-25 *** Released version 0.5.0 | |
2665 |
|
2682 | |||
2666 | 2003-08-22 Fernando Perez <fperez@colorado.edu> |
|
2683 | 2003-08-22 Fernando Perez <fperez@colorado.edu> | |
2667 |
|
2684 | |||
2668 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of |
|
2685 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of | |
2669 | improperly defined user exceptions. Thanks to feedback from Mark |
|
2686 | improperly defined user exceptions. Thanks to feedback from Mark | |
2670 | Russell <mrussell-AT-verio.net>. |
|
2687 | Russell <mrussell-AT-verio.net>. | |
2671 |
|
2688 | |||
2672 | 2003-08-20 Fernando Perez <fperez@colorado.edu> |
|
2689 | 2003-08-20 Fernando Perez <fperez@colorado.edu> | |
2673 |
|
2690 | |||
2674 | * IPython/OInspect.py (Inspector.pinfo): changed String Form |
|
2691 | * IPython/OInspect.py (Inspector.pinfo): changed String Form | |
2675 | printing so that it would print multi-line string forms starting |
|
2692 | printing so that it would print multi-line string forms starting | |
2676 | with a new line. This way the formatting is better respected for |
|
2693 | with a new line. This way the formatting is better respected for | |
2677 | objects which work hard to make nice string forms. |
|
2694 | objects which work hard to make nice string forms. | |
2678 |
|
2695 | |||
2679 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where |
|
2696 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where | |
2680 | autocall would overtake data access for objects with both |
|
2697 | autocall would overtake data access for objects with both | |
2681 | __getitem__ and __call__. |
|
2698 | __getitem__ and __call__. | |
2682 |
|
2699 | |||
2683 | 2003-08-19 *** Released version 0.5.0-rc1 |
|
2700 | 2003-08-19 *** Released version 0.5.0-rc1 | |
2684 |
|
2701 | |||
2685 | 2003-08-19 Fernando Perez <fperez@colorado.edu> |
|
2702 | 2003-08-19 Fernando Perez <fperez@colorado.edu> | |
2686 |
|
2703 | |||
2687 | * IPython/deep_reload.py (load_tail): single tiny change here |
|
2704 | * IPython/deep_reload.py (load_tail): single tiny change here | |
2688 | seems to fix the long-standing bug of dreload() failing to work |
|
2705 | seems to fix the long-standing bug of dreload() failing to work | |
2689 | for dotted names. But this module is pretty tricky, so I may have |
|
2706 | for dotted names. But this module is pretty tricky, so I may have | |
2690 | missed some subtlety. Needs more testing!. |
|
2707 | missed some subtlety. Needs more testing!. | |
2691 |
|
2708 | |||
2692 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user |
|
2709 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user | |
2693 | exceptions which have badly implemented __str__ methods. |
|
2710 | exceptions which have badly implemented __str__ methods. | |
2694 | (VerboseTB.text): harden against inspect.getinnerframes crashing, |
|
2711 | (VerboseTB.text): harden against inspect.getinnerframes crashing, | |
2695 | which I've been getting reports about from Python 2.3 users. I |
|
2712 | which I've been getting reports about from Python 2.3 users. I | |
2696 | wish I had a simple test case to reproduce the problem, so I could |
|
2713 | wish I had a simple test case to reproduce the problem, so I could | |
2697 | either write a cleaner workaround or file a bug report if |
|
2714 | either write a cleaner workaround or file a bug report if | |
2698 | necessary. |
|
2715 | necessary. | |
2699 |
|
2716 | |||
2700 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after |
|
2717 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after | |
2701 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to |
|
2718 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to | |
2702 | a bug report by Tjabo Kloppenburg. |
|
2719 | a bug report by Tjabo Kloppenburg. | |
2703 |
|
2720 | |||
2704 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb |
|
2721 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb | |
2705 | crashes. Wrapped the pdb call in a blanket try/except, since pdb |
|
2722 | crashes. Wrapped the pdb call in a blanket try/except, since pdb | |
2706 | seems rather unstable. Thanks to a bug report by Tjabo |
|
2723 | seems rather unstable. Thanks to a bug report by Tjabo | |
2707 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. |
|
2724 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. | |
2708 |
|
2725 | |||
2709 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put |
|
2726 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put | |
2710 | this out soon because of the critical fixes in the inner loop for |
|
2727 | this out soon because of the critical fixes in the inner loop for | |
2711 | generators. |
|
2728 | generators. | |
2712 |
|
2729 | |||
2713 | * IPython/Magic.py (Magic.getargspec): removed. This (and |
|
2730 | * IPython/Magic.py (Magic.getargspec): removed. This (and | |
2714 | _get_def) have been obsoleted by OInspect for a long time, I |
|
2731 | _get_def) have been obsoleted by OInspect for a long time, I | |
2715 | hadn't noticed that they were dead code. |
|
2732 | hadn't noticed that they were dead code. | |
2716 | (Magic._ofind): restored _ofind functionality for a few literals |
|
2733 | (Magic._ofind): restored _ofind functionality for a few literals | |
2717 | (those in ["''",'""','[]','{}','()']). But it won't work anymore |
|
2734 | (those in ["''",'""','[]','{}','()']). But it won't work anymore | |
2718 | for things like "hello".capitalize?, since that would require a |
|
2735 | for things like "hello".capitalize?, since that would require a | |
2719 | potentially dangerous eval() again. |
|
2736 | potentially dangerous eval() again. | |
2720 |
|
2737 | |||
2721 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the |
|
2738 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the | |
2722 | logic a bit more to clean up the escapes handling and minimize the |
|
2739 | logic a bit more to clean up the escapes handling and minimize the | |
2723 | use of _ofind to only necessary cases. The interactive 'feel' of |
|
2740 | use of _ofind to only necessary cases. The interactive 'feel' of | |
2724 | IPython should have improved quite a bit with the changes in |
|
2741 | IPython should have improved quite a bit with the changes in | |
2725 | _prefilter and _ofind (besides being far safer than before). |
|
2742 | _prefilter and _ofind (besides being far safer than before). | |
2726 |
|
2743 | |||
2727 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather |
|
2744 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather | |
2728 | obscure, never reported). Edit would fail to find the object to |
|
2745 | obscure, never reported). Edit would fail to find the object to | |
2729 | edit under some circumstances. |
|
2746 | edit under some circumstances. | |
2730 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls |
|
2747 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls | |
2731 | which were causing double-calling of generators. Those eval calls |
|
2748 | which were causing double-calling of generators. Those eval calls | |
2732 | were _very_ dangerous, since code with side effects could be |
|
2749 | were _very_ dangerous, since code with side effects could be | |
2733 | triggered. As they say, 'eval is evil'... These were the |
|
2750 | triggered. As they say, 'eval is evil'... These were the | |
2734 | nastiest evals in IPython. Besides, _ofind is now far simpler, |
|
2751 | nastiest evals in IPython. Besides, _ofind is now far simpler, | |
2735 | and it should also be quite a bit faster. Its use of inspect is |
|
2752 | and it should also be quite a bit faster. Its use of inspect is | |
2736 | also safer, so perhaps some of the inspect-related crashes I've |
|
2753 | also safer, so perhaps some of the inspect-related crashes I've | |
2737 | seen lately with Python 2.3 might be taken care of. That will |
|
2754 | seen lately with Python 2.3 might be taken care of. That will | |
2738 | need more testing. |
|
2755 | need more testing. | |
2739 |
|
2756 | |||
2740 | 2003-08-17 Fernando Perez <fperez@colorado.edu> |
|
2757 | 2003-08-17 Fernando Perez <fperez@colorado.edu> | |
2741 |
|
2758 | |||
2742 | * IPython/iplib.py (InteractiveShell._prefilter): significant |
|
2759 | * IPython/iplib.py (InteractiveShell._prefilter): significant | |
2743 | simplifications to the logic for handling user escapes. Faster |
|
2760 | simplifications to the logic for handling user escapes. Faster | |
2744 | and simpler code. |
|
2761 | and simpler code. | |
2745 |
|
2762 | |||
2746 | 2003-08-14 Fernando Perez <fperez@colorado.edu> |
|
2763 | 2003-08-14 Fernando Perez <fperez@colorado.edu> | |
2747 |
|
2764 | |||
2748 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. |
|
2765 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. | |
2749 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, |
|
2766 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, | |
2750 | but it should be quite a bit faster. And the recursive version |
|
2767 | but it should be quite a bit faster. And the recursive version | |
2751 | generated O(log N) intermediate storage for all rank>1 arrays, |
|
2768 | generated O(log N) intermediate storage for all rank>1 arrays, | |
2752 | even if they were contiguous. |
|
2769 | even if they were contiguous. | |
2753 | (l1norm): Added this function. |
|
2770 | (l1norm): Added this function. | |
2754 | (norm): Added this function for arbitrary norms (including |
|
2771 | (norm): Added this function for arbitrary norms (including | |
2755 | l-infinity). l1 and l2 are still special cases for convenience |
|
2772 | l-infinity). l1 and l2 are still special cases for convenience | |
2756 | and speed. |
|
2773 | and speed. | |
2757 |
|
2774 | |||
2758 | 2003-08-03 Fernando Perez <fperez@colorado.edu> |
|
2775 | 2003-08-03 Fernando Perez <fperez@colorado.edu> | |
2759 |
|
2776 | |||
2760 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string |
|
2777 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string | |
2761 | exceptions, which now raise PendingDeprecationWarnings in Python |
|
2778 | exceptions, which now raise PendingDeprecationWarnings in Python | |
2762 | 2.3. There were some in Magic and some in Gnuplot2. |
|
2779 | 2.3. There were some in Magic and some in Gnuplot2. | |
2763 |
|
2780 | |||
2764 | 2003-06-30 Fernando Perez <fperez@colorado.edu> |
|
2781 | 2003-06-30 Fernando Perez <fperez@colorado.edu> | |
2765 |
|
2782 | |||
2766 | * IPython/genutils.py (page): modified to call curses only for |
|
2783 | * IPython/genutils.py (page): modified to call curses only for | |
2767 | terminals where TERM=='xterm'. After problems under many other |
|
2784 | terminals where TERM=='xterm'. After problems under many other | |
2768 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. |
|
2785 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. | |
2769 |
|
2786 | |||
2770 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which |
|
2787 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which | |
2771 | would be triggered when readline was absent. This was just an old |
|
2788 | would be triggered when readline was absent. This was just an old | |
2772 | debugging statement I'd forgotten to take out. |
|
2789 | debugging statement I'd forgotten to take out. | |
2773 |
|
2790 | |||
2774 | 2003-06-20 Fernando Perez <fperez@colorado.edu> |
|
2791 | 2003-06-20 Fernando Perez <fperez@colorado.edu> | |
2775 |
|
2792 | |||
2776 | * IPython/genutils.py (clock): modified to return only user time |
|
2793 | * IPython/genutils.py (clock): modified to return only user time | |
2777 | (not counting system time), after a discussion on scipy. While |
|
2794 | (not counting system time), after a discussion on scipy. While | |
2778 | system time may be a useful quantity occasionally, it may much |
|
2795 | system time may be a useful quantity occasionally, it may much | |
2779 | more easily be skewed by occasional swapping or other similar |
|
2796 | more easily be skewed by occasional swapping or other similar | |
2780 | activity. |
|
2797 | activity. | |
2781 |
|
2798 | |||
2782 | 2003-06-05 Fernando Perez <fperez@colorado.edu> |
|
2799 | 2003-06-05 Fernando Perez <fperez@colorado.edu> | |
2783 |
|
2800 | |||
2784 | * IPython/numutils.py (identity): new function, for building |
|
2801 | * IPython/numutils.py (identity): new function, for building | |
2785 | arbitrary rank Kronecker deltas (mostly backwards compatible with |
|
2802 | arbitrary rank Kronecker deltas (mostly backwards compatible with | |
2786 | Numeric.identity) |
|
2803 | Numeric.identity) | |
2787 |
|
2804 | |||
2788 | 2003-06-03 Fernando Perez <fperez@colorado.edu> |
|
2805 | 2003-06-03 Fernando Perez <fperez@colorado.edu> | |
2789 |
|
2806 | |||
2790 | * IPython/iplib.py (InteractiveShell.handle_magic): protect |
|
2807 | * IPython/iplib.py (InteractiveShell.handle_magic): protect | |
2791 | arguments passed to magics with spaces, to allow trailing '\' to |
|
2808 | arguments passed to magics with spaces, to allow trailing '\' to | |
2792 | work normally (mainly for Windows users). |
|
2809 | work normally (mainly for Windows users). | |
2793 |
|
2810 | |||
2794 | 2003-05-29 Fernando Perez <fperez@colorado.edu> |
|
2811 | 2003-05-29 Fernando Perez <fperez@colorado.edu> | |
2795 |
|
2812 | |||
2796 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help |
|
2813 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help | |
2797 | instead of pydoc.help. This fixes a bizarre behavior where |
|
2814 | instead of pydoc.help. This fixes a bizarre behavior where | |
2798 | printing '%s' % locals() would trigger the help system. Now |
|
2815 | printing '%s' % locals() would trigger the help system. Now | |
2799 | ipython behaves like normal python does. |
|
2816 | ipython behaves like normal python does. | |
2800 |
|
2817 | |||
2801 | Note that if one does 'from pydoc import help', the bizarre |
|
2818 | Note that if one does 'from pydoc import help', the bizarre | |
2802 | behavior returns, but this will also happen in normal python, so |
|
2819 | behavior returns, but this will also happen in normal python, so | |
2803 | it's not an ipython bug anymore (it has to do with how pydoc.help |
|
2820 | it's not an ipython bug anymore (it has to do with how pydoc.help | |
2804 | is implemented). |
|
2821 | is implemented). | |
2805 |
|
2822 | |||
2806 | 2003-05-22 Fernando Perez <fperez@colorado.edu> |
|
2823 | 2003-05-22 Fernando Perez <fperez@colorado.edu> | |
2807 |
|
2824 | |||
2808 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to |
|
2825 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to | |
2809 | return [] instead of None when nothing matches, also match to end |
|
2826 | return [] instead of None when nothing matches, also match to end | |
2810 | of line. Patch by Gary Bishop. |
|
2827 | of line. Patch by Gary Bishop. | |
2811 |
|
2828 | |||
2812 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook |
|
2829 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook | |
2813 | protection as before, for files passed on the command line. This |
|
2830 | protection as before, for files passed on the command line. This | |
2814 | prevents the CrashHandler from kicking in if user files call into |
|
2831 | prevents the CrashHandler from kicking in if user files call into | |
2815 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of |
|
2832 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of | |
2816 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> |
|
2833 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> | |
2817 |
|
2834 | |||
2818 | 2003-05-20 *** Released version 0.4.0 |
|
2835 | 2003-05-20 *** Released version 0.4.0 | |
2819 |
|
2836 | |||
2820 | 2003-05-20 Fernando Perez <fperez@colorado.edu> |
|
2837 | 2003-05-20 Fernando Perez <fperez@colorado.edu> | |
2821 |
|
2838 | |||
2822 | * setup.py: added support for manpages. It's a bit hackish b/c of |
|
2839 | * setup.py: added support for manpages. It's a bit hackish b/c of | |
2823 | a bug in the way the bdist_rpm distutils target handles gzipped |
|
2840 | a bug in the way the bdist_rpm distutils target handles gzipped | |
2824 | manpages, but it works. After a patch by Jack. |
|
2841 | manpages, but it works. After a patch by Jack. | |
2825 |
|
2842 | |||
2826 | 2003-05-19 Fernando Perez <fperez@colorado.edu> |
|
2843 | 2003-05-19 Fernando Perez <fperez@colorado.edu> | |
2827 |
|
2844 | |||
2828 | * IPython/numutils.py: added a mockup of the kinds module, since |
|
2845 | * IPython/numutils.py: added a mockup of the kinds module, since | |
2829 | it was recently removed from Numeric. This way, numutils will |
|
2846 | it was recently removed from Numeric. This way, numutils will | |
2830 | work for all users even if they are missing kinds. |
|
2847 | work for all users even if they are missing kinds. | |
2831 |
|
2848 | |||
2832 | * IPython/Magic.py (Magic._ofind): Harden against an inspect |
|
2849 | * IPython/Magic.py (Magic._ofind): Harden against an inspect | |
2833 | failure, which can occur with SWIG-wrapped extensions. After a |
|
2850 | failure, which can occur with SWIG-wrapped extensions. After a | |
2834 | crash report from Prabhu. |
|
2851 | crash report from Prabhu. | |
2835 |
|
2852 | |||
2836 | 2003-05-16 Fernando Perez <fperez@colorado.edu> |
|
2853 | 2003-05-16 Fernando Perez <fperez@colorado.edu> | |
2837 |
|
2854 | |||
2838 | * IPython/iplib.py (InteractiveShell.excepthook): New method to |
|
2855 | * IPython/iplib.py (InteractiveShell.excepthook): New method to | |
2839 | protect ipython from user code which may call directly |
|
2856 | protect ipython from user code which may call directly | |
2840 | sys.excepthook (this looks like an ipython crash to the user, even |
|
2857 | sys.excepthook (this looks like an ipython crash to the user, even | |
2841 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2858 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2842 | This is especially important to help users of WxWindows, but may |
|
2859 | This is especially important to help users of WxWindows, but may | |
2843 | also be useful in other cases. |
|
2860 | also be useful in other cases. | |
2844 |
|
2861 | |||
2845 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow |
|
2862 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow | |
2846 | an optional tb_offset to be specified, and to preserve exception |
|
2863 | an optional tb_offset to be specified, and to preserve exception | |
2847 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2864 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2848 |
|
2865 | |||
2849 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! |
|
2866 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! | |
2850 |
|
2867 | |||
2851 | 2003-05-15 Fernando Perez <fperez@colorado.edu> |
|
2868 | 2003-05-15 Fernando Perez <fperez@colorado.edu> | |
2852 |
|
2869 | |||
2853 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when |
|
2870 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when | |
2854 | installing for a new user under Windows. |
|
2871 | installing for a new user under Windows. | |
2855 |
|
2872 | |||
2856 | 2003-05-12 Fernando Perez <fperez@colorado.edu> |
|
2873 | 2003-05-12 Fernando Perez <fperez@colorado.edu> | |
2857 |
|
2874 | |||
2858 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line |
|
2875 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line | |
2859 | handler for Emacs comint-based lines. Currently it doesn't do |
|
2876 | handler for Emacs comint-based lines. Currently it doesn't do | |
2860 | much (but importantly, it doesn't update the history cache). In |
|
2877 | much (but importantly, it doesn't update the history cache). In | |
2861 | the future it may be expanded if Alex needs more functionality |
|
2878 | the future it may be expanded if Alex needs more functionality | |
2862 | there. |
|
2879 | there. | |
2863 |
|
2880 | |||
2864 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform |
|
2881 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform | |
2865 | info to crash reports. |
|
2882 | info to crash reports. | |
2866 |
|
2883 | |||
2867 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, |
|
2884 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, | |
2868 | just like Python's -c. Also fixed crash with invalid -color |
|
2885 | just like Python's -c. Also fixed crash with invalid -color | |
2869 | option value at startup. Thanks to Will French |
|
2886 | option value at startup. Thanks to Will French | |
2870 | <wfrench-AT-bestweb.net> for the bug report. |
|
2887 | <wfrench-AT-bestweb.net> for the bug report. | |
2871 |
|
2888 | |||
2872 | 2003-05-09 Fernando Perez <fperez@colorado.edu> |
|
2889 | 2003-05-09 Fernando Perez <fperez@colorado.edu> | |
2873 |
|
2890 | |||
2874 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString |
|
2891 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString | |
2875 | to EvalDict (it's a mapping, after all) and simplified its code |
|
2892 | to EvalDict (it's a mapping, after all) and simplified its code | |
2876 | quite a bit, after a nice discussion on c.l.py where Gustavo |
|
2893 | quite a bit, after a nice discussion on c.l.py where Gustavo | |
2877 | Córdova <gcordova-AT-sismex.com> suggested the new version. |
|
2894 | Córdova <gcordova-AT-sismex.com> suggested the new version. | |
2878 |
|
2895 | |||
2879 | 2003-04-30 Fernando Perez <fperez@colorado.edu> |
|
2896 | 2003-04-30 Fernando Perez <fperez@colorado.edu> | |
2880 |
|
2897 | |||
2881 | * IPython/genutils.py (timings_out): modified it to reduce its |
|
2898 | * IPython/genutils.py (timings_out): modified it to reduce its | |
2882 | overhead in the common reps==1 case. |
|
2899 | overhead in the common reps==1 case. | |
2883 |
|
2900 | |||
2884 | 2003-04-29 Fernando Perez <fperez@colorado.edu> |
|
2901 | 2003-04-29 Fernando Perez <fperez@colorado.edu> | |
2885 |
|
2902 | |||
2886 | * IPython/genutils.py (timings_out): Modified to use the resource |
|
2903 | * IPython/genutils.py (timings_out): Modified to use the resource | |
2887 | module, which avoids the wraparound problems of time.clock(). |
|
2904 | module, which avoids the wraparound problems of time.clock(). | |
2888 |
|
2905 | |||
2889 | 2003-04-17 *** Released version 0.2.15pre4 |
|
2906 | 2003-04-17 *** Released version 0.2.15pre4 | |
2890 |
|
2907 | |||
2891 | 2003-04-17 Fernando Perez <fperez@colorado.edu> |
|
2908 | 2003-04-17 Fernando Perez <fperez@colorado.edu> | |
2892 |
|
2909 | |||
2893 | * setup.py (scriptfiles): Split windows-specific stuff over to a |
|
2910 | * setup.py (scriptfiles): Split windows-specific stuff over to a | |
2894 | separate file, in an attempt to have a Windows GUI installer. |
|
2911 | separate file, in an attempt to have a Windows GUI installer. | |
2895 | That didn't work, but part of the groundwork is done. |
|
2912 | That didn't work, but part of the groundwork is done. | |
2896 |
|
2913 | |||
2897 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for |
|
2914 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for | |
2898 | indent/unindent with 4 spaces. Particularly useful in combination |
|
2915 | indent/unindent with 4 spaces. Particularly useful in combination | |
2899 | with the new auto-indent option. |
|
2916 | with the new auto-indent option. | |
2900 |
|
2917 | |||
2901 | 2003-04-16 Fernando Perez <fperez@colorado.edu> |
|
2918 | 2003-04-16 Fernando Perez <fperez@colorado.edu> | |
2902 |
|
2919 | |||
2903 | * IPython/Magic.py: various replacements of self.rc for |
|
2920 | * IPython/Magic.py: various replacements of self.rc for | |
2904 | self.shell.rc. A lot more remains to be done to fully disentangle |
|
2921 | self.shell.rc. A lot more remains to be done to fully disentangle | |
2905 | this class from the main Shell class. |
|
2922 | this class from the main Shell class. | |
2906 |
|
2923 | |||
2907 | * IPython/GnuplotRuntime.py: added checks for mouse support so |
|
2924 | * IPython/GnuplotRuntime.py: added checks for mouse support so | |
2908 | that we don't try to enable it if the current gnuplot doesn't |
|
2925 | that we don't try to enable it if the current gnuplot doesn't | |
2909 | really support it. Also added checks so that we don't try to |
|
2926 | really support it. Also added checks so that we don't try to | |
2910 | enable persist under Windows (where Gnuplot doesn't recognize the |
|
2927 | enable persist under Windows (where Gnuplot doesn't recognize the | |
2911 | option). |
|
2928 | option). | |
2912 |
|
2929 | |||
2913 | * IPython/iplib.py (InteractiveShell.interact): Added optional |
|
2930 | * IPython/iplib.py (InteractiveShell.interact): Added optional | |
2914 | auto-indenting code, after a patch by King C. Shu |
|
2931 | auto-indenting code, after a patch by King C. Shu | |
2915 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't |
|
2932 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't | |
2916 | get along well with pasting indented code. If I ever figure out |
|
2933 | get along well with pasting indented code. If I ever figure out | |
2917 | how to make that part go well, it will become on by default. |
|
2934 | how to make that part go well, it will become on by default. | |
2918 |
|
2935 | |||
2919 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would |
|
2936 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would | |
2920 | crash ipython if there was an unmatched '%' in the user's prompt |
|
2937 | crash ipython if there was an unmatched '%' in the user's prompt | |
2921 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2938 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2922 |
|
2939 | |||
2923 | * IPython/iplib.py (InteractiveShell.interact): removed the |
|
2940 | * IPython/iplib.py (InteractiveShell.interact): removed the | |
2924 | ability to ask the user whether he wants to crash or not at the |
|
2941 | ability to ask the user whether he wants to crash or not at the | |
2925 | 'last line' exception handler. Calling functions at that point |
|
2942 | 'last line' exception handler. Calling functions at that point | |
2926 | changes the stack, and the error reports would have incorrect |
|
2943 | changes the stack, and the error reports would have incorrect | |
2927 | tracebacks. |
|
2944 | tracebacks. | |
2928 |
|
2945 | |||
2929 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to |
|
2946 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to | |
2930 | pass through a peger a pretty-printed form of any object. After a |
|
2947 | pass through a peger a pretty-printed form of any object. After a | |
2931 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> |
|
2948 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> | |
2932 |
|
2949 | |||
2933 | 2003-04-14 Fernando Perez <fperez@colorado.edu> |
|
2950 | 2003-04-14 Fernando Perez <fperez@colorado.edu> | |
2934 |
|
2951 | |||
2935 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where |
|
2952 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where | |
2936 | all files in ~ would be modified at first install (instead of |
|
2953 | all files in ~ would be modified at first install (instead of | |
2937 | ~/.ipython). This could be potentially disastrous, as the |
|
2954 | ~/.ipython). This could be potentially disastrous, as the | |
2938 | modification (make line-endings native) could damage binary files. |
|
2955 | modification (make line-endings native) could damage binary files. | |
2939 |
|
2956 | |||
2940 | 2003-04-10 Fernando Perez <fperez@colorado.edu> |
|
2957 | 2003-04-10 Fernando Perez <fperez@colorado.edu> | |
2941 |
|
2958 | |||
2942 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to |
|
2959 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to | |
2943 | handle only lines which are invalid python. This now means that |
|
2960 | handle only lines which are invalid python. This now means that | |
2944 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins |
|
2961 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins | |
2945 | for the bug report. |
|
2962 | for the bug report. | |
2946 |
|
2963 | |||
2947 | 2003-04-01 Fernando Perez <fperez@colorado.edu> |
|
2964 | 2003-04-01 Fernando Perez <fperez@colorado.edu> | |
2948 |
|
2965 | |||
2949 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug |
|
2966 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug | |
2950 | where failing to set sys.last_traceback would crash pdb.pm(). |
|
2967 | where failing to set sys.last_traceback would crash pdb.pm(). | |
2951 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug |
|
2968 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug | |
2952 | report. |
|
2969 | report. | |
2953 |
|
2970 | |||
2954 | 2003-03-25 Fernando Perez <fperez@colorado.edu> |
|
2971 | 2003-03-25 Fernando Perez <fperez@colorado.edu> | |
2955 |
|
2972 | |||
2956 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler |
|
2973 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler | |
2957 | before printing it (it had a lot of spurious blank lines at the |
|
2974 | before printing it (it had a lot of spurious blank lines at the | |
2958 | end). |
|
2975 | end). | |
2959 |
|
2976 | |||
2960 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr |
|
2977 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr | |
2961 | output would be sent 21 times! Obviously people don't use this |
|
2978 | output would be sent 21 times! Obviously people don't use this | |
2962 | too often, or I would have heard about it. |
|
2979 | too often, or I would have heard about it. | |
2963 |
|
2980 | |||
2964 | 2003-03-24 Fernando Perez <fperez@colorado.edu> |
|
2981 | 2003-03-24 Fernando Perez <fperez@colorado.edu> | |
2965 |
|
2982 | |||
2966 | * setup.py (scriptfiles): renamed the data_files parameter from |
|
2983 | * setup.py (scriptfiles): renamed the data_files parameter from | |
2967 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink |
|
2984 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink | |
2968 | for the patch. |
|
2985 | for the patch. | |
2969 |
|
2986 | |||
2970 | 2003-03-20 Fernando Perez <fperez@colorado.edu> |
|
2987 | 2003-03-20 Fernando Perez <fperez@colorado.edu> | |
2971 |
|
2988 | |||
2972 | * IPython/genutils.py (error): added error() and fatal() |
|
2989 | * IPython/genutils.py (error): added error() and fatal() | |
2973 | functions. |
|
2990 | functions. | |
2974 |
|
2991 | |||
2975 | 2003-03-18 *** Released version 0.2.15pre3 |
|
2992 | 2003-03-18 *** Released version 0.2.15pre3 | |
2976 |
|
2993 | |||
2977 | 2003-03-18 Fernando Perez <fperez@colorado.edu> |
|
2994 | 2003-03-18 Fernando Perez <fperez@colorado.edu> | |
2978 |
|
2995 | |||
2979 | * setupext/install_data_ext.py |
|
2996 | * setupext/install_data_ext.py | |
2980 | (install_data_ext.initialize_options): Class contributed by Jack |
|
2997 | (install_data_ext.initialize_options): Class contributed by Jack | |
2981 | Moffit for fixing the old distutils hack. He is sending this to |
|
2998 | Moffit for fixing the old distutils hack. He is sending this to | |
2982 | the distutils folks so in the future we may not need it as a |
|
2999 | the distutils folks so in the future we may not need it as a | |
2983 | private fix. |
|
3000 | private fix. | |
2984 |
|
3001 | |||
2985 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's |
|
3002 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's | |
2986 | changes for Debian packaging. See his patch for full details. |
|
3003 | changes for Debian packaging. See his patch for full details. | |
2987 | The old distutils hack of making the ipythonrc* files carry a |
|
3004 | The old distutils hack of making the ipythonrc* files carry a | |
2988 | bogus .py extension is gone, at last. Examples were moved to a |
|
3005 | bogus .py extension is gone, at last. Examples were moved to a | |
2989 | separate subdir under doc/, and the separate executable scripts |
|
3006 | separate subdir under doc/, and the separate executable scripts | |
2990 | now live in their own directory. Overall a great cleanup. The |
|
3007 | now live in their own directory. Overall a great cleanup. The | |
2991 | manual was updated to use the new files, and setup.py has been |
|
3008 | manual was updated to use the new files, and setup.py has been | |
2992 | fixed for this setup. |
|
3009 | fixed for this setup. | |
2993 |
|
3010 | |||
2994 | * IPython/PyColorize.py (Parser.usage): made non-executable and |
|
3011 | * IPython/PyColorize.py (Parser.usage): made non-executable and | |
2995 | created a pycolor wrapper around it to be included as a script. |
|
3012 | created a pycolor wrapper around it to be included as a script. | |
2996 |
|
3013 | |||
2997 | 2003-03-12 *** Released version 0.2.15pre2 |
|
3014 | 2003-03-12 *** Released version 0.2.15pre2 | |
2998 |
|
3015 | |||
2999 | 2003-03-12 Fernando Perez <fperez@colorado.edu> |
|
3016 | 2003-03-12 Fernando Perez <fperez@colorado.edu> | |
3000 |
|
3017 | |||
3001 | * IPython/ColorANSI.py (make_color_table): Finally fixed the |
|
3018 | * IPython/ColorANSI.py (make_color_table): Finally fixed the | |
3002 | long-standing problem with garbage characters in some terminals. |
|
3019 | long-standing problem with garbage characters in some terminals. | |
3003 | The issue was really that the \001 and \002 escapes must _only_ be |
|
3020 | The issue was really that the \001 and \002 escapes must _only_ be | |
3004 | passed to input prompts (which call readline), but _never_ to |
|
3021 | passed to input prompts (which call readline), but _never_ to | |
3005 | normal text to be printed on screen. I changed ColorANSI to have |
|
3022 | normal text to be printed on screen. I changed ColorANSI to have | |
3006 | two classes: TermColors and InputTermColors, each with the |
|
3023 | two classes: TermColors and InputTermColors, each with the | |
3007 | appropriate escapes for input prompts or normal text. The code in |
|
3024 | appropriate escapes for input prompts or normal text. The code in | |
3008 | Prompts.py got slightly more complicated, but this very old and |
|
3025 | Prompts.py got slightly more complicated, but this very old and | |
3009 | annoying bug is finally fixed. |
|
3026 | annoying bug is finally fixed. | |
3010 |
|
3027 | |||
3011 | All the credit for nailing down the real origin of this problem |
|
3028 | All the credit for nailing down the real origin of this problem | |
3012 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. |
|
3029 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. | |
3013 | *Many* thanks to him for spending quite a bit of effort on this. |
|
3030 | *Many* thanks to him for spending quite a bit of effort on this. | |
3014 |
|
3031 | |||
3015 | 2003-03-05 *** Released version 0.2.15pre1 |
|
3032 | 2003-03-05 *** Released version 0.2.15pre1 | |
3016 |
|
3033 | |||
3017 | 2003-03-03 Fernando Perez <fperez@colorado.edu> |
|
3034 | 2003-03-03 Fernando Perez <fperez@colorado.edu> | |
3018 |
|
3035 | |||
3019 | * IPython/FakeModule.py: Moved the former _FakeModule to a |
|
3036 | * IPython/FakeModule.py: Moved the former _FakeModule to a | |
3020 | separate file, because it's also needed by Magic (to fix a similar |
|
3037 | separate file, because it's also needed by Magic (to fix a similar | |
3021 | pickle-related issue in @run). |
|
3038 | pickle-related issue in @run). | |
3022 |
|
3039 | |||
3023 | 2003-03-02 Fernando Perez <fperez@colorado.edu> |
|
3040 | 2003-03-02 Fernando Perez <fperez@colorado.edu> | |
3024 |
|
3041 | |||
3025 | * IPython/Magic.py (Magic.magic_autocall): new magic to control |
|
3042 | * IPython/Magic.py (Magic.magic_autocall): new magic to control | |
3026 | the autocall option at runtime. |
|
3043 | the autocall option at runtime. | |
3027 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns |
|
3044 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns | |
3028 | across Magic.py to start separating Magic from InteractiveShell. |
|
3045 | across Magic.py to start separating Magic from InteractiveShell. | |
3029 | (Magic._ofind): Fixed to return proper namespace for dotted |
|
3046 | (Magic._ofind): Fixed to return proper namespace for dotted | |
3030 | names. Before, a dotted name would always return 'not currently |
|
3047 | names. Before, a dotted name would always return 'not currently | |
3031 | defined', because it would find the 'parent'. s.x would be found, |
|
3048 | defined', because it would find the 'parent'. s.x would be found, | |
3032 | but since 'x' isn't defined by itself, it would get confused. |
|
3049 | but since 'x' isn't defined by itself, it would get confused. | |
3033 | (Magic.magic_run): Fixed pickling problems reported by Ralf |
|
3050 | (Magic.magic_run): Fixed pickling problems reported by Ralf | |
3034 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to |
|
3051 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to | |
3035 | that I'd used when Mike Heeter reported similar issues at the |
|
3052 | that I'd used when Mike Heeter reported similar issues at the | |
3036 | top-level, but now for @run. It boils down to injecting the |
|
3053 | top-level, but now for @run. It boils down to injecting the | |
3037 | namespace where code is being executed with something that looks |
|
3054 | namespace where code is being executed with something that looks | |
3038 | enough like a module to fool pickle.dump(). Since a pickle stores |
|
3055 | enough like a module to fool pickle.dump(). Since a pickle stores | |
3039 | a named reference to the importing module, we need this for |
|
3056 | a named reference to the importing module, we need this for | |
3040 | pickles to save something sensible. |
|
3057 | pickles to save something sensible. | |
3041 |
|
3058 | |||
3042 | * IPython/ipmaker.py (make_IPython): added an autocall option. |
|
3059 | * IPython/ipmaker.py (make_IPython): added an autocall option. | |
3043 |
|
3060 | |||
3044 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of |
|
3061 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of | |
3045 | the auto-eval code. Now autocalling is an option, and the code is |
|
3062 | the auto-eval code. Now autocalling is an option, and the code is | |
3046 | also vastly safer. There is no more eval() involved at all. |
|
3063 | also vastly safer. There is no more eval() involved at all. | |
3047 |
|
3064 | |||
3048 | 2003-03-01 Fernando Perez <fperez@colorado.edu> |
|
3065 | 2003-03-01 Fernando Perez <fperez@colorado.edu> | |
3049 |
|
3066 | |||
3050 | * IPython/Magic.py (Magic._ofind): Changed interface to return a |
|
3067 | * IPython/Magic.py (Magic._ofind): Changed interface to return a | |
3051 | dict with named keys instead of a tuple. |
|
3068 | dict with named keys instead of a tuple. | |
3052 |
|
3069 | |||
3053 | * IPython: Started using CVS for IPython as of 0.2.15pre1. |
|
3070 | * IPython: Started using CVS for IPython as of 0.2.15pre1. | |
3054 |
|
3071 | |||
3055 | * setup.py (make_shortcut): Fixed message about directories |
|
3072 | * setup.py (make_shortcut): Fixed message about directories | |
3056 | created during Windows installation (the directories were ok, just |
|
3073 | created during Windows installation (the directories were ok, just | |
3057 | the printed message was misleading). Thanks to Chris Liechti |
|
3074 | the printed message was misleading). Thanks to Chris Liechti | |
3058 | <cliechti-AT-gmx.net> for the heads up. |
|
3075 | <cliechti-AT-gmx.net> for the heads up. | |
3059 |
|
3076 | |||
3060 | 2003-02-21 Fernando Perez <fperez@colorado.edu> |
|
3077 | 2003-02-21 Fernando Perez <fperez@colorado.edu> | |
3061 |
|
3078 | |||
3062 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching |
|
3079 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching | |
3063 | of ValueError exception when checking for auto-execution. This |
|
3080 | of ValueError exception when checking for auto-execution. This | |
3064 | one is raised by things like Numeric arrays arr.flat when the |
|
3081 | one is raised by things like Numeric arrays arr.flat when the | |
3065 | array is non-contiguous. |
|
3082 | array is non-contiguous. | |
3066 |
|
3083 | |||
3067 | 2003-01-31 Fernando Perez <fperez@colorado.edu> |
|
3084 | 2003-01-31 Fernando Perez <fperez@colorado.edu> | |
3068 |
|
3085 | |||
3069 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would |
|
3086 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would | |
3070 | not return any value at all (even though the command would get |
|
3087 | not return any value at all (even though the command would get | |
3071 | executed). |
|
3088 | executed). | |
3072 | (xsys): Flush stdout right after printing the command to ensure |
|
3089 | (xsys): Flush stdout right after printing the command to ensure | |
3073 | proper ordering of commands and command output in the total |
|
3090 | proper ordering of commands and command output in the total | |
3074 | output. |
|
3091 | output. | |
3075 | (SystemExec/xsys/bq): Switched the names of xsys/bq and |
|
3092 | (SystemExec/xsys/bq): Switched the names of xsys/bq and | |
3076 | system/getoutput as defaults. The old ones are kept for |
|
3093 | system/getoutput as defaults. The old ones are kept for | |
3077 | compatibility reasons, so no code which uses this library needs |
|
3094 | compatibility reasons, so no code which uses this library needs | |
3078 | changing. |
|
3095 | changing. | |
3079 |
|
3096 | |||
3080 | 2003-01-27 *** Released version 0.2.14 |
|
3097 | 2003-01-27 *** Released version 0.2.14 | |
3081 |
|
3098 | |||
3082 | 2003-01-25 Fernando Perez <fperez@colorado.edu> |
|
3099 | 2003-01-25 Fernando Perez <fperez@colorado.edu> | |
3083 |
|
3100 | |||
3084 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where |
|
3101 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where | |
3085 | functions defined in previous edit sessions could not be re-edited |
|
3102 | functions defined in previous edit sessions could not be re-edited | |
3086 | (because the temp files were immediately removed). Now temp files |
|
3103 | (because the temp files were immediately removed). Now temp files | |
3087 | are removed only at IPython's exit. |
|
3104 | are removed only at IPython's exit. | |
3088 | (Magic.magic_run): Improved @run to perform shell-like expansions |
|
3105 | (Magic.magic_run): Improved @run to perform shell-like expansions | |
3089 | on its arguments (~users and $VARS). With this, @run becomes more |
|
3106 | on its arguments (~users and $VARS). With this, @run becomes more | |
3090 | like a normal command-line. |
|
3107 | like a normal command-line. | |
3091 |
|
3108 | |||
3092 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small |
|
3109 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small | |
3093 | bugs related to embedding and cleaned up that code. A fairly |
|
3110 | bugs related to embedding and cleaned up that code. A fairly | |
3094 | important one was the impossibility to access the global namespace |
|
3111 | important one was the impossibility to access the global namespace | |
3095 | through the embedded IPython (only local variables were visible). |
|
3112 | through the embedded IPython (only local variables were visible). | |
3096 |
|
3113 | |||
3097 | 2003-01-14 Fernando Perez <fperez@colorado.edu> |
|
3114 | 2003-01-14 Fernando Perez <fperez@colorado.edu> | |
3098 |
|
3115 | |||
3099 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed |
|
3116 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed | |
3100 | auto-calling to be a bit more conservative. Now it doesn't get |
|
3117 | auto-calling to be a bit more conservative. Now it doesn't get | |
3101 | triggered if any of '!=()<>' are in the rest of the input line, to |
|
3118 | triggered if any of '!=()<>' are in the rest of the input line, to | |
3102 | allow comparing callables. Thanks to Alex for the heads up. |
|
3119 | allow comparing callables. Thanks to Alex for the heads up. | |
3103 |
|
3120 | |||
3104 | 2003-01-07 Fernando Perez <fperez@colorado.edu> |
|
3121 | 2003-01-07 Fernando Perez <fperez@colorado.edu> | |
3105 |
|
3122 | |||
3106 | * IPython/genutils.py (page): fixed estimation of the number of |
|
3123 | * IPython/genutils.py (page): fixed estimation of the number of | |
3107 | lines in a string to be paged to simply count newlines. This |
|
3124 | lines in a string to be paged to simply count newlines. This | |
3108 | prevents over-guessing due to embedded escape sequences. A better |
|
3125 | prevents over-guessing due to embedded escape sequences. A better | |
3109 | long-term solution would involve stripping out the control chars |
|
3126 | long-term solution would involve stripping out the control chars | |
3110 | for the count, but it's potentially so expensive I just don't |
|
3127 | for the count, but it's potentially so expensive I just don't | |
3111 | think it's worth doing. |
|
3128 | think it's worth doing. | |
3112 |
|
3129 | |||
3113 | 2002-12-19 *** Released version 0.2.14pre50 |
|
3130 | 2002-12-19 *** Released version 0.2.14pre50 | |
3114 |
|
3131 | |||
3115 | 2002-12-19 Fernando Perez <fperez@colorado.edu> |
|
3132 | 2002-12-19 Fernando Perez <fperez@colorado.edu> | |
3116 |
|
3133 | |||
3117 | * tools/release (version): Changed release scripts to inform |
|
3134 | * tools/release (version): Changed release scripts to inform | |
3118 | Andrea and build a NEWS file with a list of recent changes. |
|
3135 | Andrea and build a NEWS file with a list of recent changes. | |
3119 |
|
3136 | |||
3120 | * IPython/ColorANSI.py (__all__): changed terminal detection |
|
3137 | * IPython/ColorANSI.py (__all__): changed terminal detection | |
3121 | code. Seems to work better for xterms without breaking |
|
3138 | code. Seems to work better for xterms without breaking | |
3122 | konsole. Will need more testing to determine if WinXP and Mac OSX |
|
3139 | konsole. Will need more testing to determine if WinXP and Mac OSX | |
3123 | also work ok. |
|
3140 | also work ok. | |
3124 |
|
3141 | |||
3125 | 2002-12-18 *** Released version 0.2.14pre49 |
|
3142 | 2002-12-18 *** Released version 0.2.14pre49 | |
3126 |
|
3143 | |||
3127 | 2002-12-18 Fernando Perez <fperez@colorado.edu> |
|
3144 | 2002-12-18 Fernando Perez <fperez@colorado.edu> | |
3128 |
|
3145 | |||
3129 | * Docs: added new info about Mac OSX, from Andrea. |
|
3146 | * Docs: added new info about Mac OSX, from Andrea. | |
3130 |
|
3147 | |||
3131 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to |
|
3148 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to | |
3132 | allow direct plotting of python strings whose format is the same |
|
3149 | allow direct plotting of python strings whose format is the same | |
3133 | of gnuplot data files. |
|
3150 | of gnuplot data files. | |
3134 |
|
3151 | |||
3135 | 2002-12-16 Fernando Perez <fperez@colorado.edu> |
|
3152 | 2002-12-16 Fernando Perez <fperez@colorado.edu> | |
3136 |
|
3153 | |||
3137 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) |
|
3154 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) | |
3138 | value of exit question to be acknowledged. |
|
3155 | value of exit question to be acknowledged. | |
3139 |
|
3156 | |||
3140 | 2002-12-03 Fernando Perez <fperez@colorado.edu> |
|
3157 | 2002-12-03 Fernando Perez <fperez@colorado.edu> | |
3141 |
|
3158 | |||
3142 | * IPython/ipmaker.py: removed generators, which had been added |
|
3159 | * IPython/ipmaker.py: removed generators, which had been added | |
3143 | by mistake in an earlier debugging run. This was causing trouble |
|
3160 | by mistake in an earlier debugging run. This was causing trouble | |
3144 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> |
|
3161 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> | |
3145 | for pointing this out. |
|
3162 | for pointing this out. | |
3146 |
|
3163 | |||
3147 | 2002-11-17 Fernando Perez <fperez@colorado.edu> |
|
3164 | 2002-11-17 Fernando Perez <fperez@colorado.edu> | |
3148 |
|
3165 | |||
3149 | * Manual: updated the Gnuplot section. |
|
3166 | * Manual: updated the Gnuplot section. | |
3150 |
|
3167 | |||
3151 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with |
|
3168 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with | |
3152 | a much better split of what goes in Runtime and what goes in |
|
3169 | a much better split of what goes in Runtime and what goes in | |
3153 | Interactive. |
|
3170 | Interactive. | |
3154 |
|
3171 | |||
3155 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't |
|
3172 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't | |
3156 | being imported from iplib. |
|
3173 | being imported from iplib. | |
3157 |
|
3174 | |||
3158 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc |
|
3175 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc | |
3159 | for command-passing. Now the global Gnuplot instance is called |
|
3176 | for command-passing. Now the global Gnuplot instance is called | |
3160 | 'gp' instead of 'g', which was really a far too fragile and |
|
3177 | 'gp' instead of 'g', which was really a far too fragile and | |
3161 | common name. |
|
3178 | common name. | |
3162 |
|
3179 | |||
3163 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken |
|
3180 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken | |
3164 | bounding boxes generated by Gnuplot for square plots. |
|
3181 | bounding boxes generated by Gnuplot for square plots. | |
3165 |
|
3182 | |||
3166 | * IPython/genutils.py (popkey): new function added. I should |
|
3183 | * IPython/genutils.py (popkey): new function added. I should | |
3167 | suggest this on c.l.py as a dict method, it seems useful. |
|
3184 | suggest this on c.l.py as a dict method, it seems useful. | |
3168 |
|
3185 | |||
3169 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot |
|
3186 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot | |
3170 | to transparently handle PostScript generation. MUCH better than |
|
3187 | to transparently handle PostScript generation. MUCH better than | |
3171 | the previous plot_eps/replot_eps (which I removed now). The code |
|
3188 | the previous plot_eps/replot_eps (which I removed now). The code | |
3172 | is also fairly clean and well documented now (including |
|
3189 | is also fairly clean and well documented now (including | |
3173 | docstrings). |
|
3190 | docstrings). | |
3174 |
|
3191 | |||
3175 | 2002-11-13 Fernando Perez <fperez@colorado.edu> |
|
3192 | 2002-11-13 Fernando Perez <fperez@colorado.edu> | |
3176 |
|
3193 | |||
3177 | * IPython/Magic.py (Magic.magic_edit): fixed docstring |
|
3194 | * IPython/Magic.py (Magic.magic_edit): fixed docstring | |
3178 | (inconsistent with options). |
|
3195 | (inconsistent with options). | |
3179 |
|
3196 | |||
3180 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been |
|
3197 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been | |
3181 | manually disabled, I don't know why. Fixed it. |
|
3198 | manually disabled, I don't know why. Fixed it. | |
3182 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly |
|
3199 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly | |
3183 | eps output. |
|
3200 | eps output. | |
3184 |
|
3201 | |||
3185 | 2002-11-12 Fernando Perez <fperez@colorado.edu> |
|
3202 | 2002-11-12 Fernando Perez <fperez@colorado.edu> | |
3186 |
|
3203 | |||
3187 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they |
|
3204 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they | |
3188 | don't propagate up to caller. Fixes crash reported by François |
|
3205 | don't propagate up to caller. Fixes crash reported by François | |
3189 | Pinard. |
|
3206 | Pinard. | |
3190 |
|
3207 | |||
3191 | 2002-11-09 Fernando Perez <fperez@colorado.edu> |
|
3208 | 2002-11-09 Fernando Perez <fperez@colorado.edu> | |
3192 |
|
3209 | |||
3193 | * IPython/ipmaker.py (make_IPython): fixed problem with writing |
|
3210 | * IPython/ipmaker.py (make_IPython): fixed problem with writing | |
3194 | history file for new users. |
|
3211 | history file for new users. | |
3195 | (make_IPython): fixed bug where initial install would leave the |
|
3212 | (make_IPython): fixed bug where initial install would leave the | |
3196 | user running in the .ipython dir. |
|
3213 | user running in the .ipython dir. | |
3197 | (make_IPython): fixed bug where config dir .ipython would be |
|
3214 | (make_IPython): fixed bug where config dir .ipython would be | |
3198 | created regardless of the given -ipythondir option. Thanks to Cory |
|
3215 | created regardless of the given -ipythondir option. Thanks to Cory | |
3199 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. |
|
3216 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. | |
3200 |
|
3217 | |||
3201 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no |
|
3218 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no | |
3202 | type confirmations. Will need to use it in all of IPython's code |
|
3219 | type confirmations. Will need to use it in all of IPython's code | |
3203 | consistently. |
|
3220 | consistently. | |
3204 |
|
3221 | |||
3205 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the |
|
3222 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the | |
3206 | context to print 31 lines instead of the default 5. This will make |
|
3223 | context to print 31 lines instead of the default 5. This will make | |
3207 | the crash reports extremely detailed in case the problem is in |
|
3224 | the crash reports extremely detailed in case the problem is in | |
3208 | libraries I don't have access to. |
|
3225 | libraries I don't have access to. | |
3209 |
|
3226 | |||
3210 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last |
|
3227 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last | |
3211 | line of defense' code to still crash, but giving users fair |
|
3228 | line of defense' code to still crash, but giving users fair | |
3212 | warning. I don't want internal errors to go unreported: if there's |
|
3229 | warning. I don't want internal errors to go unreported: if there's | |
3213 | an internal problem, IPython should crash and generate a full |
|
3230 | an internal problem, IPython should crash and generate a full | |
3214 | report. |
|
3231 | report. | |
3215 |
|
3232 | |||
3216 | 2002-11-08 Fernando Perez <fperez@colorado.edu> |
|
3233 | 2002-11-08 Fernando Perez <fperez@colorado.edu> | |
3217 |
|
3234 | |||
3218 | * IPython/iplib.py (InteractiveShell.interact): added code to trap |
|
3235 | * IPython/iplib.py (InteractiveShell.interact): added code to trap | |
3219 | otherwise uncaught exceptions which can appear if people set |
|
3236 | otherwise uncaught exceptions which can appear if people set | |
3220 | sys.stdout to something badly broken. Thanks to a crash report |
|
3237 | sys.stdout to something badly broken. Thanks to a crash report | |
3221 | from henni-AT-mail.brainbot.com. |
|
3238 | from henni-AT-mail.brainbot.com. | |
3222 |
|
3239 | |||
3223 | 2002-11-04 Fernando Perez <fperez@colorado.edu> |
|
3240 | 2002-11-04 Fernando Perez <fperez@colorado.edu> | |
3224 |
|
3241 | |||
3225 | * IPython/iplib.py (InteractiveShell.interact): added |
|
3242 | * IPython/iplib.py (InteractiveShell.interact): added | |
3226 | __IPYTHON__active to the builtins. It's a flag which goes on when |
|
3243 | __IPYTHON__active to the builtins. It's a flag which goes on when | |
3227 | the interaction starts and goes off again when it stops. This |
|
3244 | the interaction starts and goes off again when it stops. This | |
3228 | allows embedding code to detect being inside IPython. Before this |
|
3245 | allows embedding code to detect being inside IPython. Before this | |
3229 | was done via __IPYTHON__, but that only shows that an IPython |
|
3246 | was done via __IPYTHON__, but that only shows that an IPython | |
3230 | instance has been created. |
|
3247 | instance has been created. | |
3231 |
|
3248 | |||
3232 | * IPython/Magic.py (Magic.magic_env): I realized that in a |
|
3249 | * IPython/Magic.py (Magic.magic_env): I realized that in a | |
3233 | UserDict, instance.data holds the data as a normal dict. So I |
|
3250 | UserDict, instance.data holds the data as a normal dict. So I | |
3234 | modified @env to return os.environ.data instead of rebuilding a |
|
3251 | modified @env to return os.environ.data instead of rebuilding a | |
3235 | dict by hand. |
|
3252 | dict by hand. | |
3236 |
|
3253 | |||
3237 | 2002-11-02 Fernando Perez <fperez@colorado.edu> |
|
3254 | 2002-11-02 Fernando Perez <fperez@colorado.edu> | |
3238 |
|
3255 | |||
3239 | * IPython/genutils.py (warn): changed so that level 1 prints no |
|
3256 | * IPython/genutils.py (warn): changed so that level 1 prints no | |
3240 | header. Level 2 is now the default (with 'WARNING' header, as |
|
3257 | header. Level 2 is now the default (with 'WARNING' header, as | |
3241 | before). I think I tracked all places where changes were needed in |
|
3258 | before). I think I tracked all places where changes were needed in | |
3242 | IPython, but outside code using the old level numbering may have |
|
3259 | IPython, but outside code using the old level numbering may have | |
3243 | broken. |
|
3260 | broken. | |
3244 |
|
3261 | |||
3245 | * IPython/iplib.py (InteractiveShell.runcode): added this to |
|
3262 | * IPython/iplib.py (InteractiveShell.runcode): added this to | |
3246 | handle the tracebacks in SystemExit traps correctly. The previous |
|
3263 | handle the tracebacks in SystemExit traps correctly. The previous | |
3247 | code (through interact) was printing more of the stack than |
|
3264 | code (through interact) was printing more of the stack than | |
3248 | necessary, showing IPython internal code to the user. |
|
3265 | necessary, showing IPython internal code to the user. | |
3249 |
|
3266 | |||
3250 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by |
|
3267 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by | |
3251 | default. Now that the default at the confirmation prompt is yes, |
|
3268 | default. Now that the default at the confirmation prompt is yes, | |
3252 | it's not so intrusive. François' argument that ipython sessions |
|
3269 | it's not so intrusive. François' argument that ipython sessions | |
3253 | tend to be complex enough not to lose them from an accidental C-d, |
|
3270 | tend to be complex enough not to lose them from an accidental C-d, | |
3254 | is a valid one. |
|
3271 | is a valid one. | |
3255 |
|
3272 | |||
3256 | * IPython/iplib.py (InteractiveShell.interact): added a |
|
3273 | * IPython/iplib.py (InteractiveShell.interact): added a | |
3257 | showtraceback() call to the SystemExit trap, and modified the exit |
|
3274 | showtraceback() call to the SystemExit trap, and modified the exit | |
3258 | confirmation to have yes as the default. |
|
3275 | confirmation to have yes as the default. | |
3259 |
|
3276 | |||
3260 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from |
|
3277 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from | |
3261 | this file. It's been gone from the code for a long time, this was |
|
3278 | this file. It's been gone from the code for a long time, this was | |
3262 | simply leftover junk. |
|
3279 | simply leftover junk. | |
3263 |
|
3280 | |||
3264 | 2002-11-01 Fernando Perez <fperez@colorado.edu> |
|
3281 | 2002-11-01 Fernando Perez <fperez@colorado.edu> | |
3265 |
|
3282 | |||
3266 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option |
|
3283 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option | |
3267 | added. If set, IPython now traps EOF and asks for |
|
3284 | added. If set, IPython now traps EOF and asks for | |
3268 | confirmation. After a request by François Pinard. |
|
3285 | confirmation. After a request by François Pinard. | |
3269 |
|
3286 | |||
3270 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead |
|
3287 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead | |
3271 | of @abort, and with a new (better) mechanism for handling the |
|
3288 | of @abort, and with a new (better) mechanism for handling the | |
3272 | exceptions. |
|
3289 | exceptions. | |
3273 |
|
3290 | |||
3274 | 2002-10-27 Fernando Perez <fperez@colorado.edu> |
|
3291 | 2002-10-27 Fernando Perez <fperez@colorado.edu> | |
3275 |
|
3292 | |||
3276 | * IPython/usage.py (__doc__): updated the --help information and |
|
3293 | * IPython/usage.py (__doc__): updated the --help information and | |
3277 | the ipythonrc file to indicate that -log generates |
|
3294 | the ipythonrc file to indicate that -log generates | |
3278 | ./ipython.log. Also fixed the corresponding info in @logstart. |
|
3295 | ./ipython.log. Also fixed the corresponding info in @logstart. | |
3279 | This and several other fixes in the manuals thanks to reports by |
|
3296 | This and several other fixes in the manuals thanks to reports by | |
3280 | François Pinard <pinard-AT-iro.umontreal.ca>. |
|
3297 | François Pinard <pinard-AT-iro.umontreal.ca>. | |
3281 |
|
3298 | |||
3282 | * IPython/Logger.py (Logger.switch_log): Fixed error message to |
|
3299 | * IPython/Logger.py (Logger.switch_log): Fixed error message to | |
3283 | refer to @logstart (instead of @log, which doesn't exist). |
|
3300 | refer to @logstart (instead of @log, which doesn't exist). | |
3284 |
|
3301 | |||
3285 | * IPython/iplib.py (InteractiveShell._prefilter): fixed |
|
3302 | * IPython/iplib.py (InteractiveShell._prefilter): fixed | |
3286 | AttributeError crash. Thanks to Christopher Armstrong |
|
3303 | AttributeError crash. Thanks to Christopher Armstrong | |
3287 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been |
|
3304 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been | |
3288 | introduced recently (in 0.2.14pre37) with the fix to the eval |
|
3305 | introduced recently (in 0.2.14pre37) with the fix to the eval | |
3289 | problem mentioned below. |
|
3306 | problem mentioned below. | |
3290 |
|
3307 | |||
3291 | 2002-10-17 Fernando Perez <fperez@colorado.edu> |
|
3308 | 2002-10-17 Fernando Perez <fperez@colorado.edu> | |
3292 |
|
3309 | |||
3293 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows |
|
3310 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows | |
3294 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. |
|
3311 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. | |
3295 |
|
3312 | |||
3296 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to |
|
3313 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to | |
3297 | this function to fix a problem reported by Alex Schmolck. He saw |
|
3314 | this function to fix a problem reported by Alex Schmolck. He saw | |
3298 | it with list comprehensions and generators, which were getting |
|
3315 | it with list comprehensions and generators, which were getting | |
3299 | called twice. The real problem was an 'eval' call in testing for |
|
3316 | called twice. The real problem was an 'eval' call in testing for | |
3300 | automagic which was evaluating the input line silently. |
|
3317 | automagic which was evaluating the input line silently. | |
3301 |
|
3318 | |||
3302 | This is a potentially very nasty bug, if the input has side |
|
3319 | This is a potentially very nasty bug, if the input has side | |
3303 | effects which must not be repeated. The code is much cleaner now, |
|
3320 | effects which must not be repeated. The code is much cleaner now, | |
3304 | without any blanket 'except' left and with a regexp test for |
|
3321 | without any blanket 'except' left and with a regexp test for | |
3305 | actual function names. |
|
3322 | actual function names. | |
3306 |
|
3323 | |||
3307 | But an eval remains, which I'm not fully comfortable with. I just |
|
3324 | But an eval remains, which I'm not fully comfortable with. I just | |
3308 | don't know how to find out if an expression could be a callable in |
|
3325 | don't know how to find out if an expression could be a callable in | |
3309 | the user's namespace without doing an eval on the string. However |
|
3326 | the user's namespace without doing an eval on the string. However | |
3310 | that string is now much more strictly checked so that no code |
|
3327 | that string is now much more strictly checked so that no code | |
3311 | slips by, so the eval should only happen for things that can |
|
3328 | slips by, so the eval should only happen for things that can | |
3312 | really be only function/method names. |
|
3329 | really be only function/method names. | |
3313 |
|
3330 | |||
3314 | 2002-10-15 Fernando Perez <fperez@colorado.edu> |
|
3331 | 2002-10-15 Fernando Perez <fperez@colorado.edu> | |
3315 |
|
3332 | |||
3316 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac |
|
3333 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac | |
3317 | OSX information to main manual, removed README_Mac_OSX file from |
|
3334 | OSX information to main manual, removed README_Mac_OSX file from | |
3318 | distribution. Also updated credits for recent additions. |
|
3335 | distribution. Also updated credits for recent additions. | |
3319 |
|
3336 | |||
3320 | 2002-10-10 Fernando Perez <fperez@colorado.edu> |
|
3337 | 2002-10-10 Fernando Perez <fperez@colorado.edu> | |
3321 |
|
3338 | |||
3322 | * README_Mac_OSX: Added a README for Mac OSX users for fixing |
|
3339 | * README_Mac_OSX: Added a README for Mac OSX users for fixing | |
3323 | terminal-related issues. Many thanks to Andrea Riciputi |
|
3340 | terminal-related issues. Many thanks to Andrea Riciputi | |
3324 | <andrea.riciputi-AT-libero.it> for writing it. |
|
3341 | <andrea.riciputi-AT-libero.it> for writing it. | |
3325 |
|
3342 | |||
3326 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, |
|
3343 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, | |
3327 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
3344 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
3328 |
|
3345 | |||
3329 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks |
|
3346 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks | |
3330 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad |
|
3347 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad | |
3331 | <syver-en-AT-online.no> who both submitted patches for this problem. |
|
3348 | <syver-en-AT-online.no> who both submitted patches for this problem. | |
3332 |
|
3349 | |||
3333 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for |
|
3350 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for | |
3334 | global embedding to make sure that things don't overwrite user |
|
3351 | global embedding to make sure that things don't overwrite user | |
3335 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> |
|
3352 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> | |
3336 |
|
3353 | |||
3337 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 |
|
3354 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 | |
3338 | compatibility. Thanks to Hayden Callow |
|
3355 | compatibility. Thanks to Hayden Callow | |
3339 | <h.callow-AT-elec.canterbury.ac.nz> |
|
3356 | <h.callow-AT-elec.canterbury.ac.nz> | |
3340 |
|
3357 | |||
3341 | 2002-10-04 Fernando Perez <fperez@colorado.edu> |
|
3358 | 2002-10-04 Fernando Perez <fperez@colorado.edu> | |
3342 |
|
3359 | |||
3343 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for |
|
3360 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for | |
3344 | Gnuplot.File objects. |
|
3361 | Gnuplot.File objects. | |
3345 |
|
3362 | |||
3346 | 2002-07-23 Fernando Perez <fperez@colorado.edu> |
|
3363 | 2002-07-23 Fernando Perez <fperez@colorado.edu> | |
3347 |
|
3364 | |||
3348 | * IPython/genutils.py (timing): Added timings() and timing() for |
|
3365 | * IPython/genutils.py (timing): Added timings() and timing() for | |
3349 | quick access to the most commonly needed data, the execution |
|
3366 | quick access to the most commonly needed data, the execution | |
3350 | times. Old timing() renamed to timings_out(). |
|
3367 | times. Old timing() renamed to timings_out(). | |
3351 |
|
3368 | |||
3352 | 2002-07-18 Fernando Perez <fperez@colorado.edu> |
|
3369 | 2002-07-18 Fernando Perez <fperez@colorado.edu> | |
3353 |
|
3370 | |||
3354 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed |
|
3371 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed | |
3355 | bug with nested instances disrupting the parent's tab completion. |
|
3372 | bug with nested instances disrupting the parent's tab completion. | |
3356 |
|
3373 | |||
3357 | * IPython/iplib.py (all_completions): Added Alex Schmolck's |
|
3374 | * IPython/iplib.py (all_completions): Added Alex Schmolck's | |
3358 | all_completions code to begin the emacs integration. |
|
3375 | all_completions code to begin the emacs integration. | |
3359 |
|
3376 | |||
3360 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' |
|
3377 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' | |
3361 | argument to allow titling individual arrays when plotting. |
|
3378 | argument to allow titling individual arrays when plotting. | |
3362 |
|
3379 | |||
3363 | 2002-07-15 Fernando Perez <fperez@colorado.edu> |
|
3380 | 2002-07-15 Fernando Perez <fperez@colorado.edu> | |
3364 |
|
3381 | |||
3365 | * setup.py (make_shortcut): changed to retrieve the value of |
|
3382 | * setup.py (make_shortcut): changed to retrieve the value of | |
3366 | 'Program Files' directory from the registry (this value changes in |
|
3383 | 'Program Files' directory from the registry (this value changes in | |
3367 | non-english versions of Windows). Thanks to Thomas Fanslau |
|
3384 | non-english versions of Windows). Thanks to Thomas Fanslau | |
3368 | <tfanslau-AT-gmx.de> for the report. |
|
3385 | <tfanslau-AT-gmx.de> for the report. | |
3369 |
|
3386 | |||
3370 | 2002-07-10 Fernando Perez <fperez@colorado.edu> |
|
3387 | 2002-07-10 Fernando Perez <fperez@colorado.edu> | |
3371 |
|
3388 | |||
3372 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for |
|
3389 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for | |
3373 | a bug in pdb, which crashes if a line with only whitespace is |
|
3390 | a bug in pdb, which crashes if a line with only whitespace is | |
3374 | entered. Bug report submitted to sourceforge. |
|
3391 | entered. Bug report submitted to sourceforge. | |
3375 |
|
3392 | |||
3376 | 2002-07-09 Fernando Perez <fperez@colorado.edu> |
|
3393 | 2002-07-09 Fernando Perez <fperez@colorado.edu> | |
3377 |
|
3394 | |||
3378 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when |
|
3395 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when | |
3379 | reporting exceptions (it's a bug in inspect.py, I just set a |
|
3396 | reporting exceptions (it's a bug in inspect.py, I just set a | |
3380 | workaround). |
|
3397 | workaround). | |
3381 |
|
3398 | |||
3382 | 2002-07-08 Fernando Perez <fperez@colorado.edu> |
|
3399 | 2002-07-08 Fernando Perez <fperez@colorado.edu> | |
3383 |
|
3400 | |||
3384 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to |
|
3401 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to | |
3385 | __IPYTHON__ in __builtins__ to show up in user_ns. |
|
3402 | __IPYTHON__ in __builtins__ to show up in user_ns. | |
3386 |
|
3403 | |||
3387 | 2002-07-03 Fernando Perez <fperez@colorado.edu> |
|
3404 | 2002-07-03 Fernando Perez <fperez@colorado.edu> | |
3388 |
|
3405 | |||
3389 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed |
|
3406 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed | |
3390 | name from @gp_set_instance to @gp_set_default. |
|
3407 | name from @gp_set_instance to @gp_set_default. | |
3391 |
|
3408 | |||
3392 | * IPython/ipmaker.py (make_IPython): default editor value set to |
|
3409 | * IPython/ipmaker.py (make_IPython): default editor value set to | |
3393 | '0' (a string), to match the rc file. Otherwise will crash when |
|
3410 | '0' (a string), to match the rc file. Otherwise will crash when | |
3394 | .strip() is called on it. |
|
3411 | .strip() is called on it. | |
3395 |
|
3412 | |||
3396 |
|
3413 | |||
3397 | 2002-06-28 Fernando Perez <fperez@colorado.edu> |
|
3414 | 2002-06-28 Fernando Perez <fperez@colorado.edu> | |
3398 |
|
3415 | |||
3399 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing |
|
3416 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing | |
3400 | of files in current directory when a file is executed via |
|
3417 | of files in current directory when a file is executed via | |
3401 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. |
|
3418 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. | |
3402 |
|
3419 | |||
3403 | * setup.py (manfiles): fix for rpm builds, submitted by RA |
|
3420 | * setup.py (manfiles): fix for rpm builds, submitted by RA | |
3404 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! |
|
3421 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! | |
3405 |
|
3422 | |||
3406 | * IPython/ipmaker.py (make_IPython): fixed lookup of default |
|
3423 | * IPython/ipmaker.py (make_IPython): fixed lookup of default | |
3407 | editor when set to '0'. Problem was, '0' evaluates to True (it's a |
|
3424 | editor when set to '0'. Problem was, '0' evaluates to True (it's a | |
3408 | string!). A. Schmolck caught this one. |
|
3425 | string!). A. Schmolck caught this one. | |
3409 |
|
3426 | |||
3410 | 2002-06-27 Fernando Perez <fperez@colorado.edu> |
|
3427 | 2002-06-27 Fernando Perez <fperez@colorado.edu> | |
3411 |
|
3428 | |||
3412 | * IPython/ipmaker.py (make_IPython): fixed bug when running user |
|
3429 | * IPython/ipmaker.py (make_IPython): fixed bug when running user | |
3413 | defined files at the cmd line. __name__ wasn't being set to |
|
3430 | defined files at the cmd line. __name__ wasn't being set to | |
3414 | __main__. |
|
3431 | __main__. | |
3415 |
|
3432 | |||
3416 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also |
|
3433 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also | |
3417 | regular lists and tuples besides Numeric arrays. |
|
3434 | regular lists and tuples besides Numeric arrays. | |
3418 |
|
3435 | |||
3419 | * IPython/Prompts.py (CachedOutput.__call__): Added output |
|
3436 | * IPython/Prompts.py (CachedOutput.__call__): Added output | |
3420 | supression for input ending with ';'. Similar to Mathematica and |
|
3437 | supression for input ending with ';'. Similar to Mathematica and | |
3421 | Matlab. The _* vars and Out[] list are still updated, just like |
|
3438 | Matlab. The _* vars and Out[] list are still updated, just like | |
3422 | Mathematica behaves. |
|
3439 | Mathematica behaves. | |
3423 |
|
3440 | |||
3424 | 2002-06-25 Fernando Perez <fperez@colorado.edu> |
|
3441 | 2002-06-25 Fernando Perez <fperez@colorado.edu> | |
3425 |
|
3442 | |||
3426 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of |
|
3443 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of | |
3427 | .ini extensions for profiels under Windows. |
|
3444 | .ini extensions for profiels under Windows. | |
3428 |
|
3445 | |||
3429 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of |
|
3446 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of | |
3430 | string form. Fix contributed by Alexander Schmolck |
|
3447 | string form. Fix contributed by Alexander Schmolck | |
3431 | <a.schmolck-AT-gmx.net> |
|
3448 | <a.schmolck-AT-gmx.net> | |
3432 |
|
3449 | |||
3433 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a |
|
3450 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a | |
3434 | pre-configured Gnuplot instance. |
|
3451 | pre-configured Gnuplot instance. | |
3435 |
|
3452 | |||
3436 | 2002-06-21 Fernando Perez <fperez@colorado.edu> |
|
3453 | 2002-06-21 Fernando Perez <fperez@colorado.edu> | |
3437 |
|
3454 | |||
3438 | * IPython/numutils.py (exp_safe): new function, works around the |
|
3455 | * IPython/numutils.py (exp_safe): new function, works around the | |
3439 | underflow problems in Numeric. |
|
3456 | underflow problems in Numeric. | |
3440 | (log2): New fn. Safe log in base 2: returns exact integer answer |
|
3457 | (log2): New fn. Safe log in base 2: returns exact integer answer | |
3441 | for exact integer powers of 2. |
|
3458 | for exact integer powers of 2. | |
3442 |
|
3459 | |||
3443 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' |
|
3460 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' | |
3444 | properly. |
|
3461 | properly. | |
3445 |
|
3462 | |||
3446 | 2002-06-20 Fernando Perez <fperez@colorado.edu> |
|
3463 | 2002-06-20 Fernando Perez <fperez@colorado.edu> | |
3447 |
|
3464 | |||
3448 | * IPython/genutils.py (timing): new function like |
|
3465 | * IPython/genutils.py (timing): new function like | |
3449 | Mathematica's. Similar to time_test, but returns more info. |
|
3466 | Mathematica's. Similar to time_test, but returns more info. | |
3450 |
|
3467 | |||
3451 | 2002-06-18 Fernando Perez <fperez@colorado.edu> |
|
3468 | 2002-06-18 Fernando Perez <fperez@colorado.edu> | |
3452 |
|
3469 | |||
3453 | * IPython/Magic.py (Magic.magic_save): modified @save and @r |
|
3470 | * IPython/Magic.py (Magic.magic_save): modified @save and @r | |
3454 | according to Mike Heeter's suggestions. |
|
3471 | according to Mike Heeter's suggestions. | |
3455 |
|
3472 | |||
3456 | 2002-06-16 Fernando Perez <fperez@colorado.edu> |
|
3473 | 2002-06-16 Fernando Perez <fperez@colorado.edu> | |
3457 |
|
3474 | |||
3458 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot |
|
3475 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot | |
3459 | system. GnuplotMagic is gone as a user-directory option. New files |
|
3476 | system. GnuplotMagic is gone as a user-directory option. New files | |
3460 | make it easier to use all the gnuplot stuff both from external |
|
3477 | make it easier to use all the gnuplot stuff both from external | |
3461 | programs as well as from IPython. Had to rewrite part of |
|
3478 | programs as well as from IPython. Had to rewrite part of | |
3462 | hardcopy() b/c of a strange bug: often the ps files simply don't |
|
3479 | hardcopy() b/c of a strange bug: often the ps files simply don't | |
3463 | get created, and require a repeat of the command (often several |
|
3480 | get created, and require a repeat of the command (often several | |
3464 | times). |
|
3481 | times). | |
3465 |
|
3482 | |||
3466 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to |
|
3483 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to | |
3467 | resolve output channel at call time, so that if sys.stderr has |
|
3484 | resolve output channel at call time, so that if sys.stderr has | |
3468 | been redirected by user this gets honored. |
|
3485 | been redirected by user this gets honored. | |
3469 |
|
3486 | |||
3470 | 2002-06-13 Fernando Perez <fperez@colorado.edu> |
|
3487 | 2002-06-13 Fernando Perez <fperez@colorado.edu> | |
3471 |
|
3488 | |||
3472 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to |
|
3489 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to | |
3473 | IPShell. Kept a copy with the old names to avoid breaking people's |
|
3490 | IPShell. Kept a copy with the old names to avoid breaking people's | |
3474 | embedded code. |
|
3491 | embedded code. | |
3475 |
|
3492 | |||
3476 | * IPython/ipython: simplified it to the bare minimum after |
|
3493 | * IPython/ipython: simplified it to the bare minimum after | |
3477 | Holger's suggestions. Added info about how to use it in |
|
3494 | Holger's suggestions. Added info about how to use it in | |
3478 | PYTHONSTARTUP. |
|
3495 | PYTHONSTARTUP. | |
3479 |
|
3496 | |||
3480 | * IPython/Shell.py (IPythonShell): changed the options passing |
|
3497 | * IPython/Shell.py (IPythonShell): changed the options passing | |
3481 | from a string with funky %s replacements to a straight list. Maybe |
|
3498 | from a string with funky %s replacements to a straight list. Maybe | |
3482 | a bit more typing, but it follows sys.argv conventions, so there's |
|
3499 | a bit more typing, but it follows sys.argv conventions, so there's | |
3483 | less special-casing to remember. |
|
3500 | less special-casing to remember. | |
3484 |
|
3501 | |||
3485 | 2002-06-12 Fernando Perez <fperez@colorado.edu> |
|
3502 | 2002-06-12 Fernando Perez <fperez@colorado.edu> | |
3486 |
|
3503 | |||
3487 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat |
|
3504 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat | |
3488 | command. Thanks to a suggestion by Mike Heeter. |
|
3505 | command. Thanks to a suggestion by Mike Heeter. | |
3489 | (Magic.magic_pfile): added behavior to look at filenames if given |
|
3506 | (Magic.magic_pfile): added behavior to look at filenames if given | |
3490 | arg is not a defined object. |
|
3507 | arg is not a defined object. | |
3491 | (Magic.magic_save): New @save function to save code snippets. Also |
|
3508 | (Magic.magic_save): New @save function to save code snippets. Also | |
3492 | a Mike Heeter idea. |
|
3509 | a Mike Heeter idea. | |
3493 |
|
3510 | |||
3494 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to |
|
3511 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to | |
3495 | plot() and replot(). Much more convenient now, especially for |
|
3512 | plot() and replot(). Much more convenient now, especially for | |
3496 | interactive use. |
|
3513 | interactive use. | |
3497 |
|
3514 | |||
3498 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to |
|
3515 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to | |
3499 | filenames. |
|
3516 | filenames. | |
3500 |
|
3517 | |||
3501 | 2002-06-02 Fernando Perez <fperez@colorado.edu> |
|
3518 | 2002-06-02 Fernando Perez <fperez@colorado.edu> | |
3502 |
|
3519 | |||
3503 | * IPython/Struct.py (Struct.__init__): modified to admit |
|
3520 | * IPython/Struct.py (Struct.__init__): modified to admit | |
3504 | initialization via another struct. |
|
3521 | initialization via another struct. | |
3505 |
|
3522 | |||
3506 | * IPython/genutils.py (SystemExec.__init__): New stateful |
|
3523 | * IPython/genutils.py (SystemExec.__init__): New stateful | |
3507 | interface to xsys and bq. Useful for writing system scripts. |
|
3524 | interface to xsys and bq. Useful for writing system scripts. | |
3508 |
|
3525 | |||
3509 | 2002-05-30 Fernando Perez <fperez@colorado.edu> |
|
3526 | 2002-05-30 Fernando Perez <fperez@colorado.edu> | |
3510 |
|
3527 | |||
3511 | * MANIFEST.in: Changed docfile selection to exclude all the lyx |
|
3528 | * MANIFEST.in: Changed docfile selection to exclude all the lyx | |
3512 | documents. This will make the user download smaller (it's getting |
|
3529 | documents. This will make the user download smaller (it's getting | |
3513 | too big). |
|
3530 | too big). | |
3514 |
|
3531 | |||
3515 | 2002-05-29 Fernando Perez <fperez@colorado.edu> |
|
3532 | 2002-05-29 Fernando Perez <fperez@colorado.edu> | |
3516 |
|
3533 | |||
3517 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to |
|
3534 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to | |
3518 | fix problems with shelve and pickle. Seems to work, but I don't |
|
3535 | fix problems with shelve and pickle. Seems to work, but I don't | |
3519 | know if corner cases break it. Thanks to Mike Heeter |
|
3536 | know if corner cases break it. Thanks to Mike Heeter | |
3520 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. |
|
3537 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. | |
3521 |
|
3538 | |||
3522 | 2002-05-24 Fernando Perez <fperez@colorado.edu> |
|
3539 | 2002-05-24 Fernando Perez <fperez@colorado.edu> | |
3523 |
|
3540 | |||
3524 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in |
|
3541 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in | |
3525 | macros having broken. |
|
3542 | macros having broken. | |
3526 |
|
3543 | |||
3527 | 2002-05-21 Fernando Perez <fperez@colorado.edu> |
|
3544 | 2002-05-21 Fernando Perez <fperez@colorado.edu> | |
3528 |
|
3545 | |||
3529 | * IPython/Magic.py (Magic.magic_logstart): fixed recently |
|
3546 | * IPython/Magic.py (Magic.magic_logstart): fixed recently | |
3530 | introduced logging bug: all history before logging started was |
|
3547 | introduced logging bug: all history before logging started was | |
3531 | being written one character per line! This came from the redesign |
|
3548 | being written one character per line! This came from the redesign | |
3532 | of the input history as a special list which slices to strings, |
|
3549 | of the input history as a special list which slices to strings, | |
3533 | not to lists. |
|
3550 | not to lists. | |
3534 |
|
3551 | |||
3535 | 2002-05-20 Fernando Perez <fperez@colorado.edu> |
|
3552 | 2002-05-20 Fernando Perez <fperez@colorado.edu> | |
3536 |
|
3553 | |||
3537 | * IPython/Prompts.py (CachedOutput.__init__): made the color table |
|
3554 | * IPython/Prompts.py (CachedOutput.__init__): made the color table | |
3538 | be an attribute of all classes in this module. The design of these |
|
3555 | be an attribute of all classes in this module. The design of these | |
3539 | classes needs some serious overhauling. |
|
3556 | classes needs some serious overhauling. | |
3540 |
|
3557 | |||
3541 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug |
|
3558 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug | |
3542 | which was ignoring '_' in option names. |
|
3559 | which was ignoring '_' in option names. | |
3543 |
|
3560 | |||
3544 | * IPython/ultraTB.py (FormattedTB.__init__): Changed |
|
3561 | * IPython/ultraTB.py (FormattedTB.__init__): Changed | |
3545 | 'Verbose_novars' to 'Context' and made it the new default. It's a |
|
3562 | 'Verbose_novars' to 'Context' and made it the new default. It's a | |
3546 | bit more readable and also safer than verbose. |
|
3563 | bit more readable and also safer than verbose. | |
3547 |
|
3564 | |||
3548 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of |
|
3565 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of | |
3549 | triple-quoted strings. |
|
3566 | triple-quoted strings. | |
3550 |
|
3567 | |||
3551 | * IPython/OInspect.py (__all__): new module exposing the object |
|
3568 | * IPython/OInspect.py (__all__): new module exposing the object | |
3552 | introspection facilities. Now the corresponding magics are dummy |
|
3569 | introspection facilities. Now the corresponding magics are dummy | |
3553 | wrappers around this. Having this module will make it much easier |
|
3570 | wrappers around this. Having this module will make it much easier | |
3554 | to put these functions into our modified pdb. |
|
3571 | to put these functions into our modified pdb. | |
3555 | This new object inspector system uses the new colorizing module, |
|
3572 | This new object inspector system uses the new colorizing module, | |
3556 | so source code and other things are nicely syntax highlighted. |
|
3573 | so source code and other things are nicely syntax highlighted. | |
3557 |
|
3574 | |||
3558 | 2002-05-18 Fernando Perez <fperez@colorado.edu> |
|
3575 | 2002-05-18 Fernando Perez <fperez@colorado.edu> | |
3559 |
|
3576 | |||
3560 | * IPython/ColorANSI.py: Split the coloring tools into a separate |
|
3577 | * IPython/ColorANSI.py: Split the coloring tools into a separate | |
3561 | module so I can use them in other code easier (they were part of |
|
3578 | module so I can use them in other code easier (they were part of | |
3562 | ultraTB). |
|
3579 | ultraTB). | |
3563 |
|
3580 | |||
3564 | 2002-05-17 Fernando Perez <fperez@colorado.edu> |
|
3581 | 2002-05-17 Fernando Perez <fperez@colorado.edu> | |
3565 |
|
3582 | |||
3566 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3583 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
3567 | fixed it to set the global 'g' also to the called instance, as |
|
3584 | fixed it to set the global 'g' also to the called instance, as | |
3568 | long as 'g' was still a gnuplot instance (so it doesn't overwrite |
|
3585 | long as 'g' was still a gnuplot instance (so it doesn't overwrite | |
3569 | user's 'g' variables). |
|
3586 | user's 'g' variables). | |
3570 |
|
3587 | |||
3571 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out |
|
3588 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out | |
3572 | global variables (aliases to _ih,_oh) so that users which expect |
|
3589 | global variables (aliases to _ih,_oh) so that users which expect | |
3573 | In[5] or Out[7] to work aren't unpleasantly surprised. |
|
3590 | In[5] or Out[7] to work aren't unpleasantly surprised. | |
3574 | (InputList.__getslice__): new class to allow executing slices of |
|
3591 | (InputList.__getslice__): new class to allow executing slices of | |
3575 | input history directly. Very simple class, complements the use of |
|
3592 | input history directly. Very simple class, complements the use of | |
3576 | macros. |
|
3593 | macros. | |
3577 |
|
3594 | |||
3578 | 2002-05-16 Fernando Perez <fperez@colorado.edu> |
|
3595 | 2002-05-16 Fernando Perez <fperez@colorado.edu> | |
3579 |
|
3596 | |||
3580 | * setup.py (docdirbase): make doc directory be just doc/IPython |
|
3597 | * setup.py (docdirbase): make doc directory be just doc/IPython | |
3581 | without version numbers, it will reduce clutter for users. |
|
3598 | without version numbers, it will reduce clutter for users. | |
3582 |
|
3599 | |||
3583 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to |
|
3600 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to | |
3584 | execfile call to prevent possible memory leak. See for details: |
|
3601 | execfile call to prevent possible memory leak. See for details: | |
3585 | http://mail.python.org/pipermail/python-list/2002-February/088476.html |
|
3602 | http://mail.python.org/pipermail/python-list/2002-February/088476.html | |
3586 |
|
3603 | |||
3587 | 2002-05-15 Fernando Perez <fperez@colorado.edu> |
|
3604 | 2002-05-15 Fernando Perez <fperez@colorado.edu> | |
3588 |
|
3605 | |||
3589 | * IPython/Magic.py (Magic.magic_psource): made the object |
|
3606 | * IPython/Magic.py (Magic.magic_psource): made the object | |
3590 | introspection names be more standard: pdoc, pdef, pfile and |
|
3607 | introspection names be more standard: pdoc, pdef, pfile and | |
3591 | psource. They all print/page their output, and it makes |
|
3608 | psource. They all print/page their output, and it makes | |
3592 | remembering them easier. Kept old names for compatibility as |
|
3609 | remembering them easier. Kept old names for compatibility as | |
3593 | aliases. |
|
3610 | aliases. | |
3594 |
|
3611 | |||
3595 | 2002-05-14 Fernando Perez <fperez@colorado.edu> |
|
3612 | 2002-05-14 Fernando Perez <fperez@colorado.edu> | |
3596 |
|
3613 | |||
3597 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood |
|
3614 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood | |
3598 | what the mouse problem was. The trick is to use gnuplot with temp |
|
3615 | what the mouse problem was. The trick is to use gnuplot with temp | |
3599 | files and NOT with pipes (for data communication), because having |
|
3616 | files and NOT with pipes (for data communication), because having | |
3600 | both pipes and the mouse on is bad news. |
|
3617 | both pipes and the mouse on is bad news. | |
3601 |
|
3618 | |||
3602 | 2002-05-13 Fernando Perez <fperez@colorado.edu> |
|
3619 | 2002-05-13 Fernando Perez <fperez@colorado.edu> | |
3603 |
|
3620 | |||
3604 | * IPython/Magic.py (Magic._ofind): fixed namespace order search |
|
3621 | * IPython/Magic.py (Magic._ofind): fixed namespace order search | |
3605 | bug. Information would be reported about builtins even when |
|
3622 | bug. Information would be reported about builtins even when | |
3606 | user-defined functions overrode them. |
|
3623 | user-defined functions overrode them. | |
3607 |
|
3624 | |||
3608 | 2002-05-11 Fernando Perez <fperez@colorado.edu> |
|
3625 | 2002-05-11 Fernando Perez <fperez@colorado.edu> | |
3609 |
|
3626 | |||
3610 | * IPython/__init__.py (__all__): removed FlexCompleter from |
|
3627 | * IPython/__init__.py (__all__): removed FlexCompleter from | |
3611 | __all__ so that things don't fail in platforms without readline. |
|
3628 | __all__ so that things don't fail in platforms without readline. | |
3612 |
|
3629 | |||
3613 | 2002-05-10 Fernando Perez <fperez@colorado.edu> |
|
3630 | 2002-05-10 Fernando Perez <fperez@colorado.edu> | |
3614 |
|
3631 | |||
3615 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c |
|
3632 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c | |
3616 | it requires Numeric, effectively making Numeric a dependency for |
|
3633 | it requires Numeric, effectively making Numeric a dependency for | |
3617 | IPython. |
|
3634 | IPython. | |
3618 |
|
3635 | |||
3619 | * Released 0.2.13 |
|
3636 | * Released 0.2.13 | |
3620 |
|
3637 | |||
3621 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the |
|
3638 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the | |
3622 | profiler interface. Now all the major options from the profiler |
|
3639 | profiler interface. Now all the major options from the profiler | |
3623 | module are directly supported in IPython, both for single |
|
3640 | module are directly supported in IPython, both for single | |
3624 | expressions (@prun) and for full programs (@run -p). |
|
3641 | expressions (@prun) and for full programs (@run -p). | |
3625 |
|
3642 | |||
3626 | 2002-05-09 Fernando Perez <fperez@colorado.edu> |
|
3643 | 2002-05-09 Fernando Perez <fperez@colorado.edu> | |
3627 |
|
3644 | |||
3628 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of |
|
3645 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of | |
3629 | magic properly formatted for screen. |
|
3646 | magic properly formatted for screen. | |
3630 |
|
3647 | |||
3631 | * setup.py (make_shortcut): Changed things to put pdf version in |
|
3648 | * setup.py (make_shortcut): Changed things to put pdf version in | |
3632 | doc/ instead of doc/manual (had to change lyxport a bit). |
|
3649 | doc/ instead of doc/manual (had to change lyxport a bit). | |
3633 |
|
3650 | |||
3634 | * IPython/Magic.py (Profile.string_stats): made profile runs go |
|
3651 | * IPython/Magic.py (Profile.string_stats): made profile runs go | |
3635 | through pager (they are long and a pager allows searching, saving, |
|
3652 | through pager (they are long and a pager allows searching, saving, | |
3636 | etc.) |
|
3653 | etc.) | |
3637 |
|
3654 | |||
3638 | 2002-05-08 Fernando Perez <fperez@colorado.edu> |
|
3655 | 2002-05-08 Fernando Perez <fperez@colorado.edu> | |
3639 |
|
3656 | |||
3640 | * Released 0.2.12 |
|
3657 | * Released 0.2.12 | |
3641 |
|
3658 | |||
3642 | 2002-05-06 Fernando Perez <fperez@colorado.edu> |
|
3659 | 2002-05-06 Fernando Perez <fperez@colorado.edu> | |
3643 |
|
3660 | |||
3644 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently |
|
3661 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently | |
3645 | introduced); 'hist n1 n2' was broken. |
|
3662 | introduced); 'hist n1 n2' was broken. | |
3646 | (Magic.magic_pdb): added optional on/off arguments to @pdb |
|
3663 | (Magic.magic_pdb): added optional on/off arguments to @pdb | |
3647 | (Magic.magic_run): added option -i to @run, which executes code in |
|
3664 | (Magic.magic_run): added option -i to @run, which executes code in | |
3648 | the IPython namespace instead of a clean one. Also added @irun as |
|
3665 | the IPython namespace instead of a clean one. Also added @irun as | |
3649 | an alias to @run -i. |
|
3666 | an alias to @run -i. | |
3650 |
|
3667 | |||
3651 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3668 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
3652 | fixed (it didn't really do anything, the namespaces were wrong). |
|
3669 | fixed (it didn't really do anything, the namespaces were wrong). | |
3653 |
|
3670 | |||
3654 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 |
|
3671 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 | |
3655 |
|
3672 | |||
3656 | * IPython/__init__.py (__all__): Fixed package namespace, now |
|
3673 | * IPython/__init__.py (__all__): Fixed package namespace, now | |
3657 | 'import IPython' does give access to IPython.<all> as |
|
3674 | 'import IPython' does give access to IPython.<all> as | |
3658 | expected. Also renamed __release__ to Release. |
|
3675 | expected. Also renamed __release__ to Release. | |
3659 |
|
3676 | |||
3660 | * IPython/Debugger.py (__license__): created new Pdb class which |
|
3677 | * IPython/Debugger.py (__license__): created new Pdb class which | |
3661 | functions like a drop-in for the normal pdb.Pdb but does NOT |
|
3678 | functions like a drop-in for the normal pdb.Pdb but does NOT | |
3662 | import readline by default. This way it doesn't muck up IPython's |
|
3679 | import readline by default. This way it doesn't muck up IPython's | |
3663 | readline handling, and now tab-completion finally works in the |
|
3680 | readline handling, and now tab-completion finally works in the | |
3664 | debugger -- sort of. It completes things globally visible, but the |
|
3681 | debugger -- sort of. It completes things globally visible, but the | |
3665 | completer doesn't track the stack as pdb walks it. That's a bit |
|
3682 | completer doesn't track the stack as pdb walks it. That's a bit | |
3666 | tricky, and I'll have to implement it later. |
|
3683 | tricky, and I'll have to implement it later. | |
3667 |
|
3684 | |||
3668 | 2002-05-05 Fernando Perez <fperez@colorado.edu> |
|
3685 | 2002-05-05 Fernando Perez <fperez@colorado.edu> | |
3669 |
|
3686 | |||
3670 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for |
|
3687 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for | |
3671 | magic docstrings when printed via ? (explicit \'s were being |
|
3688 | magic docstrings when printed via ? (explicit \'s were being | |
3672 | printed). |
|
3689 | printed). | |
3673 |
|
3690 | |||
3674 | * IPython/ipmaker.py (make_IPython): fixed namespace |
|
3691 | * IPython/ipmaker.py (make_IPython): fixed namespace | |
3675 | identification bug. Now variables loaded via logs or command-line |
|
3692 | identification bug. Now variables loaded via logs or command-line | |
3676 | files are recognized in the interactive namespace by @who. |
|
3693 | files are recognized in the interactive namespace by @who. | |
3677 |
|
3694 | |||
3678 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in |
|
3695 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in | |
3679 | log replay system stemming from the string form of Structs. |
|
3696 | log replay system stemming from the string form of Structs. | |
3680 |
|
3697 | |||
3681 | * IPython/Magic.py (Macro.__init__): improved macros to properly |
|
3698 | * IPython/Magic.py (Macro.__init__): improved macros to properly | |
3682 | handle magic commands in them. |
|
3699 | handle magic commands in them. | |
3683 | (Magic.magic_logstart): usernames are now expanded so 'logstart |
|
3700 | (Magic.magic_logstart): usernames are now expanded so 'logstart | |
3684 | ~/mylog' now works. |
|
3701 | ~/mylog' now works. | |
3685 |
|
3702 | |||
3686 | * IPython/iplib.py (complete): fixed bug where paths starting with |
|
3703 | * IPython/iplib.py (complete): fixed bug where paths starting with | |
3687 | '/' would be completed as magic names. |
|
3704 | '/' would be completed as magic names. | |
3688 |
|
3705 | |||
3689 | 2002-05-04 Fernando Perez <fperez@colorado.edu> |
|
3706 | 2002-05-04 Fernando Perez <fperez@colorado.edu> | |
3690 |
|
3707 | |||
3691 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to |
|
3708 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to | |
3692 | allow running full programs under the profiler's control. |
|
3709 | allow running full programs under the profiler's control. | |
3693 |
|
3710 | |||
3694 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars |
|
3711 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars | |
3695 | mode to report exceptions verbosely but without formatting |
|
3712 | mode to report exceptions verbosely but without formatting | |
3696 | variables. This addresses the issue of ipython 'freezing' (it's |
|
3713 | variables. This addresses the issue of ipython 'freezing' (it's | |
3697 | not frozen, but caught in an expensive formatting loop) when huge |
|
3714 | not frozen, but caught in an expensive formatting loop) when huge | |
3698 | variables are in the context of an exception. |
|
3715 | variables are in the context of an exception. | |
3699 | (VerboseTB.text): Added '--->' markers at line where exception was |
|
3716 | (VerboseTB.text): Added '--->' markers at line where exception was | |
3700 | triggered. Much clearer to read, especially in NoColor modes. |
|
3717 | triggered. Much clearer to read, especially in NoColor modes. | |
3701 |
|
3718 | |||
3702 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been |
|
3719 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been | |
3703 | implemented in reverse when changing to the new parse_options(). |
|
3720 | implemented in reverse when changing to the new parse_options(). | |
3704 |
|
3721 | |||
3705 | 2002-05-03 Fernando Perez <fperez@colorado.edu> |
|
3722 | 2002-05-03 Fernando Perez <fperez@colorado.edu> | |
3706 |
|
3723 | |||
3707 | * IPython/Magic.py (Magic.parse_options): new function so that |
|
3724 | * IPython/Magic.py (Magic.parse_options): new function so that | |
3708 | magics can parse options easier. |
|
3725 | magics can parse options easier. | |
3709 | (Magic.magic_prun): new function similar to profile.run(), |
|
3726 | (Magic.magic_prun): new function similar to profile.run(), | |
3710 | suggested by Chris Hart. |
|
3727 | suggested by Chris Hart. | |
3711 | (Magic.magic_cd): fixed behavior so that it only changes if |
|
3728 | (Magic.magic_cd): fixed behavior so that it only changes if | |
3712 | directory actually is in history. |
|
3729 | directory actually is in history. | |
3713 |
|
3730 | |||
3714 | * IPython/usage.py (__doc__): added information about potential |
|
3731 | * IPython/usage.py (__doc__): added information about potential | |
3715 | slowness of Verbose exception mode when there are huge data |
|
3732 | slowness of Verbose exception mode when there are huge data | |
3716 | structures to be formatted (thanks to Archie Paulson). |
|
3733 | structures to be formatted (thanks to Archie Paulson). | |
3717 |
|
3734 | |||
3718 | * IPython/ipmaker.py (make_IPython): Changed default logging |
|
3735 | * IPython/ipmaker.py (make_IPython): Changed default logging | |
3719 | (when simply called with -log) to use curr_dir/ipython.log in |
|
3736 | (when simply called with -log) to use curr_dir/ipython.log in | |
3720 | rotate mode. Fixed crash which was occuring with -log before |
|
3737 | rotate mode. Fixed crash which was occuring with -log before | |
3721 | (thanks to Jim Boyle). |
|
3738 | (thanks to Jim Boyle). | |
3722 |
|
3739 | |||
3723 | 2002-05-01 Fernando Perez <fperez@colorado.edu> |
|
3740 | 2002-05-01 Fernando Perez <fperez@colorado.edu> | |
3724 |
|
3741 | |||
3725 | * Released 0.2.11 for these fixes (mainly the ultraTB one which |
|
3742 | * Released 0.2.11 for these fixes (mainly the ultraTB one which | |
3726 | was nasty -- though somewhat of a corner case). |
|
3743 | was nasty -- though somewhat of a corner case). | |
3727 |
|
3744 | |||
3728 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to |
|
3745 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to | |
3729 | text (was a bug). |
|
3746 | text (was a bug). | |
3730 |
|
3747 | |||
3731 | 2002-04-30 Fernando Perez <fperez@colorado.edu> |
|
3748 | 2002-04-30 Fernando Perez <fperez@colorado.edu> | |
3732 |
|
3749 | |||
3733 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add |
|
3750 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add | |
3734 | a print after ^D or ^C from the user so that the In[] prompt |
|
3751 | a print after ^D or ^C from the user so that the In[] prompt | |
3735 | doesn't over-run the gnuplot one. |
|
3752 | doesn't over-run the gnuplot one. | |
3736 |
|
3753 | |||
3737 | 2002-04-29 Fernando Perez <fperez@colorado.edu> |
|
3754 | 2002-04-29 Fernando Perez <fperez@colorado.edu> | |
3738 |
|
3755 | |||
3739 | * Released 0.2.10 |
|
3756 | * Released 0.2.10 | |
3740 |
|
3757 | |||
3741 | * IPython/__release__.py (version): get date dynamically. |
|
3758 | * IPython/__release__.py (version): get date dynamically. | |
3742 |
|
3759 | |||
3743 | * Misc. documentation updates thanks to Arnd's comments. Also ran |
|
3760 | * Misc. documentation updates thanks to Arnd's comments. Also ran | |
3744 | a full spellcheck on the manual (hadn't been done in a while). |
|
3761 | a full spellcheck on the manual (hadn't been done in a while). | |
3745 |
|
3762 | |||
3746 | 2002-04-27 Fernando Perez <fperez@colorado.edu> |
|
3763 | 2002-04-27 Fernando Perez <fperez@colorado.edu> | |
3747 |
|
3764 | |||
3748 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where |
|
3765 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where | |
3749 | starting a log in mid-session would reset the input history list. |
|
3766 | starting a log in mid-session would reset the input history list. | |
3750 |
|
3767 | |||
3751 | 2002-04-26 Fernando Perez <fperez@colorado.edu> |
|
3768 | 2002-04-26 Fernando Perez <fperez@colorado.edu> | |
3752 |
|
3769 | |||
3753 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not |
|
3770 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not | |
3754 | all files were being included in an update. Now anything in |
|
3771 | all files were being included in an update. Now anything in | |
3755 | UserConfig that matches [A-Za-z]*.py will go (this excludes |
|
3772 | UserConfig that matches [A-Za-z]*.py will go (this excludes | |
3756 | __init__.py) |
|
3773 | __init__.py) | |
3757 |
|
3774 | |||
3758 | 2002-04-25 Fernando Perez <fperez@colorado.edu> |
|
3775 | 2002-04-25 Fernando Perez <fperez@colorado.edu> | |
3759 |
|
3776 | |||
3760 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ |
|
3777 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ | |
3761 | to __builtins__ so that any form of embedded or imported code can |
|
3778 | to __builtins__ so that any form of embedded or imported code can | |
3762 | test for being inside IPython. |
|
3779 | test for being inside IPython. | |
3763 |
|
3780 | |||
3764 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): |
|
3781 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): | |
3765 | changed to GnuplotMagic because it's now an importable module, |
|
3782 | changed to GnuplotMagic because it's now an importable module, | |
3766 | this makes the name follow that of the standard Gnuplot module. |
|
3783 | this makes the name follow that of the standard Gnuplot module. | |
3767 | GnuplotMagic can now be loaded at any time in mid-session. |
|
3784 | GnuplotMagic can now be loaded at any time in mid-session. | |
3768 |
|
3785 | |||
3769 | 2002-04-24 Fernando Perez <fperez@colorado.edu> |
|
3786 | 2002-04-24 Fernando Perez <fperez@colorado.edu> | |
3770 |
|
3787 | |||
3771 | * IPython/numutils.py: removed SIUnits. It doesn't properly set |
|
3788 | * IPython/numutils.py: removed SIUnits. It doesn't properly set | |
3772 | the globals (IPython has its own namespace) and the |
|
3789 | the globals (IPython has its own namespace) and the | |
3773 | PhysicalQuantity stuff is much better anyway. |
|
3790 | PhysicalQuantity stuff is much better anyway. | |
3774 |
|
3791 | |||
3775 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot |
|
3792 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot | |
3776 | embedding example to standard user directory for |
|
3793 | embedding example to standard user directory for | |
3777 | distribution. Also put it in the manual. |
|
3794 | distribution. Also put it in the manual. | |
3778 |
|
3795 | |||
3779 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot |
|
3796 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot | |
3780 | instance as first argument (so it doesn't rely on some obscure |
|
3797 | instance as first argument (so it doesn't rely on some obscure | |
3781 | hidden global). |
|
3798 | hidden global). | |
3782 |
|
3799 | |||
3783 | * IPython/UserConfig/ipythonrc.py: put () back in accepted |
|
3800 | * IPython/UserConfig/ipythonrc.py: put () back in accepted | |
3784 | delimiters. While it prevents ().TAB from working, it allows |
|
3801 | delimiters. While it prevents ().TAB from working, it allows | |
3785 | completions in open (... expressions. This is by far a more common |
|
3802 | completions in open (... expressions. This is by far a more common | |
3786 | case. |
|
3803 | case. | |
3787 |
|
3804 | |||
3788 | 2002-04-23 Fernando Perez <fperez@colorado.edu> |
|
3805 | 2002-04-23 Fernando Perez <fperez@colorado.edu> | |
3789 |
|
3806 | |||
3790 | * IPython/Extensions/InterpreterPasteInput.py: new |
|
3807 | * IPython/Extensions/InterpreterPasteInput.py: new | |
3791 | syntax-processing module for pasting lines with >>> or ... at the |
|
3808 | syntax-processing module for pasting lines with >>> or ... at the | |
3792 | start. |
|
3809 | start. | |
3793 |
|
3810 | |||
3794 | * IPython/Extensions/PhysicalQ_Interactive.py |
|
3811 | * IPython/Extensions/PhysicalQ_Interactive.py | |
3795 | (PhysicalQuantityInteractive.__int__): fixed to work with either |
|
3812 | (PhysicalQuantityInteractive.__int__): fixed to work with either | |
3796 | Numeric or math. |
|
3813 | Numeric or math. | |
3797 |
|
3814 | |||
3798 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the |
|
3815 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the | |
3799 | provided profiles. Now we have: |
|
3816 | provided profiles. Now we have: | |
3800 | -math -> math module as * and cmath with its own namespace. |
|
3817 | -math -> math module as * and cmath with its own namespace. | |
3801 | -numeric -> Numeric as *, plus gnuplot & grace |
|
3818 | -numeric -> Numeric as *, plus gnuplot & grace | |
3802 | -physics -> same as before |
|
3819 | -physics -> same as before | |
3803 |
|
3820 | |||
3804 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where |
|
3821 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where | |
3805 | user-defined magics wouldn't be found by @magic if they were |
|
3822 | user-defined magics wouldn't be found by @magic if they were | |
3806 | defined as class methods. Also cleaned up the namespace search |
|
3823 | defined as class methods. Also cleaned up the namespace search | |
3807 | logic and the string building (to use %s instead of many repeated |
|
3824 | logic and the string building (to use %s instead of many repeated | |
3808 | string adds). |
|
3825 | string adds). | |
3809 |
|
3826 | |||
3810 | * IPython/UserConfig/example-magic.py (magic_foo): updated example |
|
3827 | * IPython/UserConfig/example-magic.py (magic_foo): updated example | |
3811 | of user-defined magics to operate with class methods (cleaner, in |
|
3828 | of user-defined magics to operate with class methods (cleaner, in | |
3812 | line with the gnuplot code). |
|
3829 | line with the gnuplot code). | |
3813 |
|
3830 | |||
3814 | 2002-04-22 Fernando Perez <fperez@colorado.edu> |
|
3831 | 2002-04-22 Fernando Perez <fperez@colorado.edu> | |
3815 |
|
3832 | |||
3816 | * setup.py: updated dependency list so that manual is updated when |
|
3833 | * setup.py: updated dependency list so that manual is updated when | |
3817 | all included files change. |
|
3834 | all included files change. | |
3818 |
|
3835 | |||
3819 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring |
|
3836 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring | |
3820 | the delimiter removal option (the fix is ugly right now). |
|
3837 | the delimiter removal option (the fix is ugly right now). | |
3821 |
|
3838 | |||
3822 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load |
|
3839 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load | |
3823 | all of the math profile (quicker loading, no conflict between |
|
3840 | all of the math profile (quicker loading, no conflict between | |
3824 | g-9.8 and g-gnuplot). |
|
3841 | g-9.8 and g-gnuplot). | |
3825 |
|
3842 | |||
3826 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default |
|
3843 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default | |
3827 | name of post-mortem files to IPython_crash_report.txt. |
|
3844 | name of post-mortem files to IPython_crash_report.txt. | |
3828 |
|
3845 | |||
3829 | * Cleanup/update of the docs. Added all the new readline info and |
|
3846 | * Cleanup/update of the docs. Added all the new readline info and | |
3830 | formatted all lists as 'real lists'. |
|
3847 | formatted all lists as 'real lists'. | |
3831 |
|
3848 | |||
3832 | * IPython/ipmaker.py (make_IPython): removed now-obsolete |
|
3849 | * IPython/ipmaker.py (make_IPython): removed now-obsolete | |
3833 | tab-completion options, since the full readline parse_and_bind is |
|
3850 | tab-completion options, since the full readline parse_and_bind is | |
3834 | now accessible. |
|
3851 | now accessible. | |
3835 |
|
3852 | |||
3836 | * IPython/iplib.py (InteractiveShell.init_readline): Changed |
|
3853 | * IPython/iplib.py (InteractiveShell.init_readline): Changed | |
3837 | handling of readline options. Now users can specify any string to |
|
3854 | handling of readline options. Now users can specify any string to | |
3838 | be passed to parse_and_bind(), as well as the delimiters to be |
|
3855 | be passed to parse_and_bind(), as well as the delimiters to be | |
3839 | removed. |
|
3856 | removed. | |
3840 | (InteractiveShell.__init__): Added __name__ to the global |
|
3857 | (InteractiveShell.__init__): Added __name__ to the global | |
3841 | namespace so that things like Itpl which rely on its existence |
|
3858 | namespace so that things like Itpl which rely on its existence | |
3842 | don't crash. |
|
3859 | don't crash. | |
3843 | (InteractiveShell._prefilter): Defined the default with a _ so |
|
3860 | (InteractiveShell._prefilter): Defined the default with a _ so | |
3844 | that prefilter() is easier to override, while the default one |
|
3861 | that prefilter() is easier to override, while the default one | |
3845 | remains available. |
|
3862 | remains available. | |
3846 |
|
3863 | |||
3847 | 2002-04-18 Fernando Perez <fperez@colorado.edu> |
|
3864 | 2002-04-18 Fernando Perez <fperez@colorado.edu> | |
3848 |
|
3865 | |||
3849 | * Added information about pdb in the docs. |
|
3866 | * Added information about pdb in the docs. | |
3850 |
|
3867 | |||
3851 | 2002-04-17 Fernando Perez <fperez@colorado.edu> |
|
3868 | 2002-04-17 Fernando Perez <fperez@colorado.edu> | |
3852 |
|
3869 | |||
3853 | * IPython/ipmaker.py (make_IPython): added rc_override option to |
|
3870 | * IPython/ipmaker.py (make_IPython): added rc_override option to | |
3854 | allow passing config options at creation time which may override |
|
3871 | allow passing config options at creation time which may override | |
3855 | anything set in the config files or command line. This is |
|
3872 | anything set in the config files or command line. This is | |
3856 | particularly useful for configuring embedded instances. |
|
3873 | particularly useful for configuring embedded instances. | |
3857 |
|
3874 | |||
3858 | 2002-04-15 Fernando Perez <fperez@colorado.edu> |
|
3875 | 2002-04-15 Fernando Perez <fperez@colorado.edu> | |
3859 |
|
3876 | |||
3860 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could |
|
3877 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could | |
3861 | crash embedded instances because of the input cache falling out of |
|
3878 | crash embedded instances because of the input cache falling out of | |
3862 | sync with the output counter. |
|
3879 | sync with the output counter. | |
3863 |
|
3880 | |||
3864 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug |
|
3881 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug | |
3865 | mode which calls pdb after an uncaught exception in IPython itself. |
|
3882 | mode which calls pdb after an uncaught exception in IPython itself. | |
3866 |
|
3883 | |||
3867 | 2002-04-14 Fernando Perez <fperez@colorado.edu> |
|
3884 | 2002-04-14 Fernando Perez <fperez@colorado.edu> | |
3868 |
|
3885 | |||
3869 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up |
|
3886 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up | |
3870 | readline, fix it back after each call. |
|
3887 | readline, fix it back after each call. | |
3871 |
|
3888 | |||
3872 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private |
|
3889 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private | |
3873 | method to force all access via __call__(), which guarantees that |
|
3890 | method to force all access via __call__(), which guarantees that | |
3874 | traceback references are properly deleted. |
|
3891 | traceback references are properly deleted. | |
3875 |
|
3892 | |||
3876 | * IPython/Prompts.py (CachedOutput._display): minor fixes to |
|
3893 | * IPython/Prompts.py (CachedOutput._display): minor fixes to | |
3877 | improve printing when pprint is in use. |
|
3894 | improve printing when pprint is in use. | |
3878 |
|
3895 | |||
3879 | 2002-04-13 Fernando Perez <fperez@colorado.edu> |
|
3896 | 2002-04-13 Fernando Perez <fperez@colorado.edu> | |
3880 |
|
3897 | |||
3881 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit |
|
3898 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit | |
3882 | exceptions aren't caught anymore. If the user triggers one, he |
|
3899 | exceptions aren't caught anymore. If the user triggers one, he | |
3883 | should know why he's doing it and it should go all the way up, |
|
3900 | should know why he's doing it and it should go all the way up, | |
3884 | just like any other exception. So now @abort will fully kill the |
|
3901 | just like any other exception. So now @abort will fully kill the | |
3885 | embedded interpreter and the embedding code (unless that happens |
|
3902 | embedded interpreter and the embedding code (unless that happens | |
3886 | to catch SystemExit). |
|
3903 | to catch SystemExit). | |
3887 |
|
3904 | |||
3888 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag |
|
3905 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag | |
3889 | and a debugger() method to invoke the interactive pdb debugger |
|
3906 | and a debugger() method to invoke the interactive pdb debugger | |
3890 | after printing exception information. Also added the corresponding |
|
3907 | after printing exception information. Also added the corresponding | |
3891 | -pdb option and @pdb magic to control this feature, and updated |
|
3908 | -pdb option and @pdb magic to control this feature, and updated | |
3892 | the docs. After a suggestion from Christopher Hart |
|
3909 | the docs. After a suggestion from Christopher Hart | |
3893 | (hart-AT-caltech.edu). |
|
3910 | (hart-AT-caltech.edu). | |
3894 |
|
3911 | |||
3895 | 2002-04-12 Fernando Perez <fperez@colorado.edu> |
|
3912 | 2002-04-12 Fernando Perez <fperez@colorado.edu> | |
3896 |
|
3913 | |||
3897 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use |
|
3914 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use | |
3898 | the exception handlers defined by the user (not the CrashHandler) |
|
3915 | the exception handlers defined by the user (not the CrashHandler) | |
3899 | so that user exceptions don't trigger an ipython bug report. |
|
3916 | so that user exceptions don't trigger an ipython bug report. | |
3900 |
|
3917 | |||
3901 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme |
|
3918 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme | |
3902 | configurable (it should have always been so). |
|
3919 | configurable (it should have always been so). | |
3903 |
|
3920 | |||
3904 | 2002-03-26 Fernando Perez <fperez@colorado.edu> |
|
3921 | 2002-03-26 Fernando Perez <fperez@colorado.edu> | |
3905 |
|
3922 | |||
3906 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here |
|
3923 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here | |
3907 | and there to fix embedding namespace issues. This should all be |
|
3924 | and there to fix embedding namespace issues. This should all be | |
3908 | done in a more elegant way. |
|
3925 | done in a more elegant way. | |
3909 |
|
3926 | |||
3910 | 2002-03-25 Fernando Perez <fperez@colorado.edu> |
|
3927 | 2002-03-25 Fernando Perez <fperez@colorado.edu> | |
3911 |
|
3928 | |||
3912 | * IPython/genutils.py (get_home_dir): Try to make it work under |
|
3929 | * IPython/genutils.py (get_home_dir): Try to make it work under | |
3913 | win9x also. |
|
3930 | win9x also. | |
3914 |
|
3931 | |||
3915 | 2002-03-20 Fernando Perez <fperez@colorado.edu> |
|
3932 | 2002-03-20 Fernando Perez <fperez@colorado.edu> | |
3916 |
|
3933 | |||
3917 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave |
|
3934 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave | |
3918 | sys.displayhook untouched upon __init__. |
|
3935 | sys.displayhook untouched upon __init__. | |
3919 |
|
3936 | |||
3920 | 2002-03-19 Fernando Perez <fperez@colorado.edu> |
|
3937 | 2002-03-19 Fernando Perez <fperez@colorado.edu> | |
3921 |
|
3938 | |||
3922 | * Released 0.2.9 (for embedding bug, basically). |
|
3939 | * Released 0.2.9 (for embedding bug, basically). | |
3923 |
|
3940 | |||
3924 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit |
|
3941 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit | |
3925 | exceptions so that enclosing shell's state can be restored. |
|
3942 | exceptions so that enclosing shell's state can be restored. | |
3926 |
|
3943 | |||
3927 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize |
|
3944 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize | |
3928 | naming conventions in the .ipython/ dir. |
|
3945 | naming conventions in the .ipython/ dir. | |
3929 |
|
3946 | |||
3930 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' |
|
3947 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' | |
3931 | from delimiters list so filenames with - in them get expanded. |
|
3948 | from delimiters list so filenames with - in them get expanded. | |
3932 |
|
3949 | |||
3933 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with |
|
3950 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with | |
3934 | sys.displayhook not being properly restored after an embedded call. |
|
3951 | sys.displayhook not being properly restored after an embedded call. | |
3935 |
|
3952 | |||
3936 | 2002-03-18 Fernando Perez <fperez@colorado.edu> |
|
3953 | 2002-03-18 Fernando Perez <fperez@colorado.edu> | |
3937 |
|
3954 | |||
3938 | * Released 0.2.8 |
|
3955 | * Released 0.2.8 | |
3939 |
|
3956 | |||
3940 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where |
|
3957 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where | |
3941 | some files weren't being included in a -upgrade. |
|
3958 | some files weren't being included in a -upgrade. | |
3942 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous |
|
3959 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous | |
3943 | on' so that the first tab completes. |
|
3960 | on' so that the first tab completes. | |
3944 | (InteractiveShell.handle_magic): fixed bug with spaces around |
|
3961 | (InteractiveShell.handle_magic): fixed bug with spaces around | |
3945 | quotes breaking many magic commands. |
|
3962 | quotes breaking many magic commands. | |
3946 |
|
3963 | |||
3947 | * setup.py: added note about ignoring the syntax error messages at |
|
3964 | * setup.py: added note about ignoring the syntax error messages at | |
3948 | installation. |
|
3965 | installation. | |
3949 |
|
3966 | |||
3950 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished |
|
3967 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished | |
3951 | streamlining the gnuplot interface, now there's only one magic @gp. |
|
3968 | streamlining the gnuplot interface, now there's only one magic @gp. | |
3952 |
|
3969 | |||
3953 | 2002-03-17 Fernando Perez <fperez@colorado.edu> |
|
3970 | 2002-03-17 Fernando Perez <fperez@colorado.edu> | |
3954 |
|
3971 | |||
3955 | * IPython/UserConfig/magic_gnuplot.py: new name for the |
|
3972 | * IPython/UserConfig/magic_gnuplot.py: new name for the | |
3956 | example-magic_pm.py file. Much enhanced system, now with a shell |
|
3973 | example-magic_pm.py file. Much enhanced system, now with a shell | |
3957 | for communicating directly with gnuplot, one command at a time. |
|
3974 | for communicating directly with gnuplot, one command at a time. | |
3958 |
|
3975 | |||
3959 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent |
|
3976 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent | |
3960 | setting __name__=='__main__'. |
|
3977 | setting __name__=='__main__'. | |
3961 |
|
3978 | |||
3962 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added |
|
3979 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added | |
3963 | mini-shell for accessing gnuplot from inside ipython. Should |
|
3980 | mini-shell for accessing gnuplot from inside ipython. Should | |
3964 | extend it later for grace access too. Inspired by Arnd's |
|
3981 | extend it later for grace access too. Inspired by Arnd's | |
3965 | suggestion. |
|
3982 | suggestion. | |
3966 |
|
3983 | |||
3967 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when |
|
3984 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when | |
3968 | calling magic functions with () in their arguments. Thanks to Arnd |
|
3985 | calling magic functions with () in their arguments. Thanks to Arnd | |
3969 | Baecker for pointing this to me. |
|
3986 | Baecker for pointing this to me. | |
3970 |
|
3987 | |||
3971 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse |
|
3988 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse | |
3972 | infinitely for integer or complex arrays (only worked with floats). |
|
3989 | infinitely for integer or complex arrays (only worked with floats). | |
3973 |
|
3990 | |||
3974 | 2002-03-16 Fernando Perez <fperez@colorado.edu> |
|
3991 | 2002-03-16 Fernando Perez <fperez@colorado.edu> | |
3975 |
|
3992 | |||
3976 | * setup.py: Merged setup and setup_windows into a single script |
|
3993 | * setup.py: Merged setup and setup_windows into a single script | |
3977 | which properly handles things for windows users. |
|
3994 | which properly handles things for windows users. | |
3978 |
|
3995 | |||
3979 | 2002-03-15 Fernando Perez <fperez@colorado.edu> |
|
3996 | 2002-03-15 Fernando Perez <fperez@colorado.edu> | |
3980 |
|
3997 | |||
3981 | * Big change to the manual: now the magics are all automatically |
|
3998 | * Big change to the manual: now the magics are all automatically | |
3982 | documented. This information is generated from their docstrings |
|
3999 | documented. This information is generated from their docstrings | |
3983 | and put in a latex file included by the manual lyx file. This way |
|
4000 | and put in a latex file included by the manual lyx file. This way | |
3984 | we get always up to date information for the magics. The manual |
|
4001 | we get always up to date information for the magics. The manual | |
3985 | now also has proper version information, also auto-synced. |
|
4002 | now also has proper version information, also auto-synced. | |
3986 |
|
4003 | |||
3987 | For this to work, an undocumented --magic_docstrings option was added. |
|
4004 | For this to work, an undocumented --magic_docstrings option was added. | |
3988 |
|
4005 | |||
3989 | 2002-03-13 Fernando Perez <fperez@colorado.edu> |
|
4006 | 2002-03-13 Fernando Perez <fperez@colorado.edu> | |
3990 |
|
4007 | |||
3991 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors |
|
4008 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors | |
3992 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. |
|
4009 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. | |
3993 |
|
4010 | |||
3994 | 2002-03-12 Fernando Perez <fperez@colorado.edu> |
|
4011 | 2002-03-12 Fernando Perez <fperez@colorado.edu> | |
3995 |
|
4012 | |||
3996 | * IPython/ultraTB.py (TermColors): changed color escapes again to |
|
4013 | * IPython/ultraTB.py (TermColors): changed color escapes again to | |
3997 | fix the (old, reintroduced) line-wrapping bug. Basically, if |
|
4014 | fix the (old, reintroduced) line-wrapping bug. Basically, if | |
3998 | \001..\002 aren't given in the color escapes, lines get wrapped |
|
4015 | \001..\002 aren't given in the color escapes, lines get wrapped | |
3999 | weirdly. But giving those screws up old xterms and emacs terms. So |
|
4016 | weirdly. But giving those screws up old xterms and emacs terms. So | |
4000 | I added some logic for emacs terms to be ok, but I can't identify old |
|
4017 | I added some logic for emacs terms to be ok, but I can't identify old | |
4001 | xterms separately ($TERM=='xterm' for many terminals, like konsole). |
|
4018 | xterms separately ($TERM=='xterm' for many terminals, like konsole). | |
4002 |
|
4019 | |||
4003 | 2002-03-10 Fernando Perez <fperez@colorado.edu> |
|
4020 | 2002-03-10 Fernando Perez <fperez@colorado.edu> | |
4004 |
|
4021 | |||
4005 | * IPython/usage.py (__doc__): Various documentation cleanups and |
|
4022 | * IPython/usage.py (__doc__): Various documentation cleanups and | |
4006 | updates, both in usage docstrings and in the manual. |
|
4023 | updates, both in usage docstrings and in the manual. | |
4007 |
|
4024 | |||
4008 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for |
|
4025 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for | |
4009 | handling of caching. Set minimum acceptabe value for having a |
|
4026 | handling of caching. Set minimum acceptabe value for having a | |
4010 | cache at 20 values. |
|
4027 | cache at 20 values. | |
4011 |
|
4028 | |||
4012 | * IPython/iplib.py (InteractiveShell.user_setup): moved the |
|
4029 | * IPython/iplib.py (InteractiveShell.user_setup): moved the | |
4013 | install_first_time function to a method, renamed it and added an |
|
4030 | install_first_time function to a method, renamed it and added an | |
4014 | 'upgrade' mode. Now people can update their config directory with |
|
4031 | 'upgrade' mode. Now people can update their config directory with | |
4015 | a simple command line switch (-upgrade, also new). |
|
4032 | a simple command line switch (-upgrade, also new). | |
4016 |
|
4033 | |||
4017 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to |
|
4034 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to | |
4018 | @file (convenient for automagic users under Python >= 2.2). |
|
4035 | @file (convenient for automagic users under Python >= 2.2). | |
4019 | Removed @files (it seemed more like a plural than an abbrev. of |
|
4036 | Removed @files (it seemed more like a plural than an abbrev. of | |
4020 | 'file show'). |
|
4037 | 'file show'). | |
4021 |
|
4038 | |||
4022 | * IPython/iplib.py (install_first_time): Fixed crash if there were |
|
4039 | * IPython/iplib.py (install_first_time): Fixed crash if there were | |
4023 | backup files ('~') in .ipython/ install directory. |
|
4040 | backup files ('~') in .ipython/ install directory. | |
4024 |
|
4041 | |||
4025 | * IPython/ipmaker.py (make_IPython): fixes for new prompt |
|
4042 | * IPython/ipmaker.py (make_IPython): fixes for new prompt | |
4026 | system. Things look fine, but these changes are fairly |
|
4043 | system. Things look fine, but these changes are fairly | |
4027 | intrusive. Test them for a few days. |
|
4044 | intrusive. Test them for a few days. | |
4028 |
|
4045 | |||
4029 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of |
|
4046 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of | |
4030 | the prompts system. Now all in/out prompt strings are user |
|
4047 | the prompts system. Now all in/out prompt strings are user | |
4031 | controllable. This is particularly useful for embedding, as one |
|
4048 | controllable. This is particularly useful for embedding, as one | |
4032 | can tag embedded instances with particular prompts. |
|
4049 | can tag embedded instances with particular prompts. | |
4033 |
|
4050 | |||
4034 | Also removed global use of sys.ps1/2, which now allows nested |
|
4051 | Also removed global use of sys.ps1/2, which now allows nested | |
4035 | embeddings without any problems. Added command-line options for |
|
4052 | embeddings without any problems. Added command-line options for | |
4036 | the prompt strings. |
|
4053 | the prompt strings. | |
4037 |
|
4054 | |||
4038 | 2002-03-08 Fernando Perez <fperez@colorado.edu> |
|
4055 | 2002-03-08 Fernando Perez <fperez@colorado.edu> | |
4039 |
|
4056 | |||
4040 | * IPython/UserConfig/example-embed-short.py (ipshell): added |
|
4057 | * IPython/UserConfig/example-embed-short.py (ipshell): added | |
4041 | example file with the bare minimum code for embedding. |
|
4058 | example file with the bare minimum code for embedding. | |
4042 |
|
4059 | |||
4043 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added |
|
4060 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added | |
4044 | functionality for the embeddable shell to be activated/deactivated |
|
4061 | functionality for the embeddable shell to be activated/deactivated | |
4045 | either globally or at each call. |
|
4062 | either globally or at each call. | |
4046 |
|
4063 | |||
4047 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of |
|
4064 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of | |
4048 | rewriting the prompt with '--->' for auto-inputs with proper |
|
4065 | rewriting the prompt with '--->' for auto-inputs with proper | |
4049 | coloring. Now the previous UGLY hack in handle_auto() is gone, and |
|
4066 | coloring. Now the previous UGLY hack in handle_auto() is gone, and | |
4050 | this is handled by the prompts class itself, as it should. |
|
4067 | this is handled by the prompts class itself, as it should. | |
4051 |
|
4068 | |||
4052 | 2002-03-05 Fernando Perez <fperez@colorado.edu> |
|
4069 | 2002-03-05 Fernando Perez <fperez@colorado.edu> | |
4053 |
|
4070 | |||
4054 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to |
|
4071 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to | |
4055 | @logstart to avoid name clashes with the math log function. |
|
4072 | @logstart to avoid name clashes with the math log function. | |
4056 |
|
4073 | |||
4057 | * Big updates to X/Emacs section of the manual. |
|
4074 | * Big updates to X/Emacs section of the manual. | |
4058 |
|
4075 | |||
4059 | * Removed ipython_emacs. Milan explained to me how to pass |
|
4076 | * Removed ipython_emacs. Milan explained to me how to pass | |
4060 | arguments to ipython through Emacs. Some day I'm going to end up |
|
4077 | arguments to ipython through Emacs. Some day I'm going to end up | |
4061 | learning some lisp... |
|
4078 | learning some lisp... | |
4062 |
|
4079 | |||
4063 | 2002-03-04 Fernando Perez <fperez@colorado.edu> |
|
4080 | 2002-03-04 Fernando Perez <fperez@colorado.edu> | |
4064 |
|
4081 | |||
4065 | * IPython/ipython_emacs: Created script to be used as the |
|
4082 | * IPython/ipython_emacs: Created script to be used as the | |
4066 | py-python-command Emacs variable so we can pass IPython |
|
4083 | py-python-command Emacs variable so we can pass IPython | |
4067 | parameters. I can't figure out how to tell Emacs directly to pass |
|
4084 | parameters. I can't figure out how to tell Emacs directly to pass | |
4068 | parameters to IPython, so a dummy shell script will do it. |
|
4085 | parameters to IPython, so a dummy shell script will do it. | |
4069 |
|
4086 | |||
4070 | Other enhancements made for things to work better under Emacs' |
|
4087 | Other enhancements made for things to work better under Emacs' | |
4071 | various types of terminals. Many thanks to Milan Zamazal |
|
4088 | various types of terminals. Many thanks to Milan Zamazal | |
4072 | <pdm-AT-zamazal.org> for all the suggestions and pointers. |
|
4089 | <pdm-AT-zamazal.org> for all the suggestions and pointers. | |
4073 |
|
4090 | |||
4074 | 2002-03-01 Fernando Perez <fperez@colorado.edu> |
|
4091 | 2002-03-01 Fernando Perez <fperez@colorado.edu> | |
4075 |
|
4092 | |||
4076 | * IPython/ipmaker.py (make_IPython): added a --readline! option so |
|
4093 | * IPython/ipmaker.py (make_IPython): added a --readline! option so | |
4077 | that loading of readline is now optional. This gives better |
|
4094 | that loading of readline is now optional. This gives better | |
4078 | control to emacs users. |
|
4095 | control to emacs users. | |
4079 |
|
4096 | |||
4080 | * IPython/ultraTB.py (__date__): Modified color escape sequences |
|
4097 | * IPython/ultraTB.py (__date__): Modified color escape sequences | |
4081 | and now things work fine under xterm and in Emacs' term buffers |
|
4098 | and now things work fine under xterm and in Emacs' term buffers | |
4082 | (though not shell ones). Well, in emacs you get colors, but all |
|
4099 | (though not shell ones). Well, in emacs you get colors, but all | |
4083 | seem to be 'light' colors (no difference between dark and light |
|
4100 | seem to be 'light' colors (no difference between dark and light | |
4084 | ones). But the garbage chars are gone, and also in xterms. It |
|
4101 | ones). But the garbage chars are gone, and also in xterms. It | |
4085 | seems that now I'm using 'cleaner' ansi sequences. |
|
4102 | seems that now I'm using 'cleaner' ansi sequences. | |
4086 |
|
4103 | |||
4087 | 2002-02-21 Fernando Perez <fperez@colorado.edu> |
|
4104 | 2002-02-21 Fernando Perez <fperez@colorado.edu> | |
4088 |
|
4105 | |||
4089 | * Released 0.2.7 (mainly to publish the scoping fix). |
|
4106 | * Released 0.2.7 (mainly to publish the scoping fix). | |
4090 |
|
4107 | |||
4091 | * IPython/Logger.py (Logger.logstate): added. A corresponding |
|
4108 | * IPython/Logger.py (Logger.logstate): added. A corresponding | |
4092 | @logstate magic was created. |
|
4109 | @logstate magic was created. | |
4093 |
|
4110 | |||
4094 | * IPython/Magic.py: fixed nested scoping problem under Python |
|
4111 | * IPython/Magic.py: fixed nested scoping problem under Python | |
4095 | 2.1.x (automagic wasn't working). |
|
4112 | 2.1.x (automagic wasn't working). | |
4096 |
|
4113 | |||
4097 | 2002-02-20 Fernando Perez <fperez@colorado.edu> |
|
4114 | 2002-02-20 Fernando Perez <fperez@colorado.edu> | |
4098 |
|
4115 | |||
4099 | * Released 0.2.6. |
|
4116 | * Released 0.2.6. | |
4100 |
|
4117 | |||
4101 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' |
|
4118 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' | |
4102 | option so that logs can come out without any headers at all. |
|
4119 | option so that logs can come out without any headers at all. | |
4103 |
|
4120 | |||
4104 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for |
|
4121 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for | |
4105 | SciPy. |
|
4122 | SciPy. | |
4106 |
|
4123 | |||
4107 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so |
|
4124 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so | |
4108 | that embedded IPython calls don't require vars() to be explicitly |
|
4125 | that embedded IPython calls don't require vars() to be explicitly | |
4109 | passed. Now they are extracted from the caller's frame (code |
|
4126 | passed. Now they are extracted from the caller's frame (code | |
4110 | snatched from Eric Jones' weave). Added better documentation to |
|
4127 | snatched from Eric Jones' weave). Added better documentation to | |
4111 | the section on embedding and the example file. |
|
4128 | the section on embedding and the example file. | |
4112 |
|
4129 | |||
4113 | * IPython/genutils.py (page): Changed so that under emacs, it just |
|
4130 | * IPython/genutils.py (page): Changed so that under emacs, it just | |
4114 | prints the string. You can then page up and down in the emacs |
|
4131 | prints the string. You can then page up and down in the emacs | |
4115 | buffer itself. This is how the builtin help() works. |
|
4132 | buffer itself. This is how the builtin help() works. | |
4116 |
|
4133 | |||
4117 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with |
|
4134 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with | |
4118 | macro scoping: macros need to be executed in the user's namespace |
|
4135 | macro scoping: macros need to be executed in the user's namespace | |
4119 | to work as if they had been typed by the user. |
|
4136 | to work as if they had been typed by the user. | |
4120 |
|
4137 | |||
4121 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they |
|
4138 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they | |
4122 | execute automatically (no need to type 'exec...'). They then |
|
4139 | execute automatically (no need to type 'exec...'). They then | |
4123 | behave like 'true macros'. The printing system was also modified |
|
4140 | behave like 'true macros'. The printing system was also modified | |
4124 | for this to work. |
|
4141 | for this to work. | |
4125 |
|
4142 | |||
4126 | 2002-02-19 Fernando Perez <fperez@colorado.edu> |
|
4143 | 2002-02-19 Fernando Perez <fperez@colorado.edu> | |
4127 |
|
4144 | |||
4128 | * IPython/genutils.py (page_file): new function for paging files |
|
4145 | * IPython/genutils.py (page_file): new function for paging files | |
4129 | in an OS-independent way. Also necessary for file viewing to work |
|
4146 | in an OS-independent way. Also necessary for file viewing to work | |
4130 | well inside Emacs buffers. |
|
4147 | well inside Emacs buffers. | |
4131 | (page): Added checks for being in an emacs buffer. |
|
4148 | (page): Added checks for being in an emacs buffer. | |
4132 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed |
|
4149 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed | |
4133 | same bug in iplib. |
|
4150 | same bug in iplib. | |
4134 |
|
4151 | |||
4135 | 2002-02-18 Fernando Perez <fperez@colorado.edu> |
|
4152 | 2002-02-18 Fernando Perez <fperez@colorado.edu> | |
4136 |
|
4153 | |||
4137 | * IPython/iplib.py (InteractiveShell.init_readline): modified use |
|
4154 | * IPython/iplib.py (InteractiveShell.init_readline): modified use | |
4138 | of readline so that IPython can work inside an Emacs buffer. |
|
4155 | of readline so that IPython can work inside an Emacs buffer. | |
4139 |
|
4156 | |||
4140 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to |
|
4157 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to | |
4141 | method signatures (they weren't really bugs, but it looks cleaner |
|
4158 | method signatures (they weren't really bugs, but it looks cleaner | |
4142 | and keeps PyChecker happy). |
|
4159 | and keeps PyChecker happy). | |
4143 |
|
4160 | |||
4144 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP |
|
4161 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP | |
4145 | for implementing various user-defined hooks. Currently only |
|
4162 | for implementing various user-defined hooks. Currently only | |
4146 | display is done. |
|
4163 | display is done. | |
4147 |
|
4164 | |||
4148 | * IPython/Prompts.py (CachedOutput._display): changed display |
|
4165 | * IPython/Prompts.py (CachedOutput._display): changed display | |
4149 | functions so that they can be dynamically changed by users easily. |
|
4166 | functions so that they can be dynamically changed by users easily. | |
4150 |
|
4167 | |||
4151 | * IPython/Extensions/numeric_formats.py (num_display): added an |
|
4168 | * IPython/Extensions/numeric_formats.py (num_display): added an | |
4152 | extension for printing NumPy arrays in flexible manners. It |
|
4169 | extension for printing NumPy arrays in flexible manners. It | |
4153 | doesn't do anything yet, but all the structure is in |
|
4170 | doesn't do anything yet, but all the structure is in | |
4154 | place. Ultimately the plan is to implement output format control |
|
4171 | place. Ultimately the plan is to implement output format control | |
4155 | like in Octave. |
|
4172 | like in Octave. | |
4156 |
|
4173 | |||
4157 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic |
|
4174 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic | |
4158 | methods are found at run-time by all the automatic machinery. |
|
4175 | methods are found at run-time by all the automatic machinery. | |
4159 |
|
4176 | |||
4160 | 2002-02-17 Fernando Perez <fperez@colorado.edu> |
|
4177 | 2002-02-17 Fernando Perez <fperez@colorado.edu> | |
4161 |
|
4178 | |||
4162 | * setup_Windows.py (make_shortcut): documented. Cleaned up the |
|
4179 | * setup_Windows.py (make_shortcut): documented. Cleaned up the | |
4163 | whole file a little. |
|
4180 | whole file a little. | |
4164 |
|
4181 | |||
4165 | * ToDo: closed this document. Now there's a new_design.lyx |
|
4182 | * ToDo: closed this document. Now there's a new_design.lyx | |
4166 | document for all new ideas. Added making a pdf of it for the |
|
4183 | document for all new ideas. Added making a pdf of it for the | |
4167 | end-user distro. |
|
4184 | end-user distro. | |
4168 |
|
4185 | |||
4169 | * IPython/Logger.py (Logger.switch_log): Created this to replace |
|
4186 | * IPython/Logger.py (Logger.switch_log): Created this to replace | |
4170 | logon() and logoff(). It also fixes a nasty crash reported by |
|
4187 | logon() and logoff(). It also fixes a nasty crash reported by | |
4171 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. |
|
4188 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. | |
4172 |
|
4189 | |||
4173 | * IPython/iplib.py (complete): got auto-completion to work with |
|
4190 | * IPython/iplib.py (complete): got auto-completion to work with | |
4174 | automagic (I had wanted this for a long time). |
|
4191 | automagic (I had wanted this for a long time). | |
4175 |
|
4192 | |||
4176 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias |
|
4193 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias | |
4177 | to @file, since file() is now a builtin and clashes with automagic |
|
4194 | to @file, since file() is now a builtin and clashes with automagic | |
4178 | for @file. |
|
4195 | for @file. | |
4179 |
|
4196 | |||
4180 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All |
|
4197 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All | |
4181 | of this was previously in iplib, which had grown to more than 2000 |
|
4198 | of this was previously in iplib, which had grown to more than 2000 | |
4182 | lines, way too long. No new functionality, but it makes managing |
|
4199 | lines, way too long. No new functionality, but it makes managing | |
4183 | the code a bit easier. |
|
4200 | the code a bit easier. | |
4184 |
|
4201 | |||
4185 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version |
|
4202 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version | |
4186 | information to crash reports. |
|
4203 | information to crash reports. | |
4187 |
|
4204 | |||
4188 | 2002-02-12 Fernando Perez <fperez@colorado.edu> |
|
4205 | 2002-02-12 Fernando Perez <fperez@colorado.edu> | |
4189 |
|
4206 | |||
4190 | * Released 0.2.5. |
|
4207 | * Released 0.2.5. | |
4191 |
|
4208 | |||
4192 | 2002-02-11 Fernando Perez <fperez@colorado.edu> |
|
4209 | 2002-02-11 Fernando Perez <fperez@colorado.edu> | |
4193 |
|
4210 | |||
4194 | * Wrote a relatively complete Windows installer. It puts |
|
4211 | * Wrote a relatively complete Windows installer. It puts | |
4195 | everything in place, creates Start Menu entries and fixes the |
|
4212 | everything in place, creates Start Menu entries and fixes the | |
4196 | color issues. Nothing fancy, but it works. |
|
4213 | color issues. Nothing fancy, but it works. | |
4197 |
|
4214 | |||
4198 | 2002-02-10 Fernando Perez <fperez@colorado.edu> |
|
4215 | 2002-02-10 Fernando Perez <fperez@colorado.edu> | |
4199 |
|
4216 | |||
4200 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an |
|
4217 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an | |
4201 | os.path.expanduser() call so that we can type @run ~/myfile.py and |
|
4218 | os.path.expanduser() call so that we can type @run ~/myfile.py and | |
4202 | have thigs work as expected. |
|
4219 | have thigs work as expected. | |
4203 |
|
4220 | |||
4204 | * IPython/genutils.py (page): fixed exception handling so things |
|
4221 | * IPython/genutils.py (page): fixed exception handling so things | |
4205 | work both in Unix and Windows correctly. Quitting a pager triggers |
|
4222 | work both in Unix and Windows correctly. Quitting a pager triggers | |
4206 | an IOError/broken pipe in Unix, and in windows not finding a pager |
|
4223 | an IOError/broken pipe in Unix, and in windows not finding a pager | |
4207 | is also an IOError, so I had to actually look at the return value |
|
4224 | is also an IOError, so I had to actually look at the return value | |
4208 | of the exception, not just the exception itself. Should be ok now. |
|
4225 | of the exception, not just the exception itself. Should be ok now. | |
4209 |
|
4226 | |||
4210 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): |
|
4227 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): | |
4211 | modified to allow case-insensitive color scheme changes. |
|
4228 | modified to allow case-insensitive color scheme changes. | |
4212 |
|
4229 | |||
4213 | 2002-02-09 Fernando Perez <fperez@colorado.edu> |
|
4230 | 2002-02-09 Fernando Perez <fperez@colorado.edu> | |
4214 |
|
4231 | |||
4215 | * IPython/genutils.py (native_line_ends): new function to leave |
|
4232 | * IPython/genutils.py (native_line_ends): new function to leave | |
4216 | user config files with os-native line-endings. |
|
4233 | user config files with os-native line-endings. | |
4217 |
|
4234 | |||
4218 | * README and manual updates. |
|
4235 | * README and manual updates. | |
4219 |
|
4236 | |||
4220 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes |
|
4237 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes | |
4221 | instead of StringType to catch Unicode strings. |
|
4238 | instead of StringType to catch Unicode strings. | |
4222 |
|
4239 | |||
4223 | * IPython/genutils.py (filefind): fixed bug for paths with |
|
4240 | * IPython/genutils.py (filefind): fixed bug for paths with | |
4224 | embedded spaces (very common in Windows). |
|
4241 | embedded spaces (very common in Windows). | |
4225 |
|
4242 | |||
4226 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc |
|
4243 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc | |
4227 | files under Windows, so that they get automatically associated |
|
4244 | files under Windows, so that they get automatically associated | |
4228 | with a text editor. Windows makes it a pain to handle |
|
4245 | with a text editor. Windows makes it a pain to handle | |
4229 | extension-less files. |
|
4246 | extension-less files. | |
4230 |
|
4247 | |||
4231 | * IPython/iplib.py (InteractiveShell.init_readline): Made the |
|
4248 | * IPython/iplib.py (InteractiveShell.init_readline): Made the | |
4232 | warning about readline only occur for Posix. In Windows there's no |
|
4249 | warning about readline only occur for Posix. In Windows there's no | |
4233 | way to get readline, so why bother with the warning. |
|
4250 | way to get readline, so why bother with the warning. | |
4234 |
|
4251 | |||
4235 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ |
|
4252 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ | |
4236 | for __str__ instead of dir(self), since dir() changed in 2.2. |
|
4253 | for __str__ instead of dir(self), since dir() changed in 2.2. | |
4237 |
|
4254 | |||
4238 | * Ported to Windows! Tested on XP, I suspect it should work fine |
|
4255 | * Ported to Windows! Tested on XP, I suspect it should work fine | |
4239 | on NT/2000, but I don't think it will work on 98 et al. That |
|
4256 | on NT/2000, but I don't think it will work on 98 et al. That | |
4240 | series of Windows is such a piece of junk anyway that I won't try |
|
4257 | series of Windows is such a piece of junk anyway that I won't try | |
4241 | porting it there. The XP port was straightforward, showed a few |
|
4258 | porting it there. The XP port was straightforward, showed a few | |
4242 | bugs here and there (fixed all), in particular some string |
|
4259 | bugs here and there (fixed all), in particular some string | |
4243 | handling stuff which required considering Unicode strings (which |
|
4260 | handling stuff which required considering Unicode strings (which | |
4244 | Windows uses). This is good, but hasn't been too tested :) No |
|
4261 | Windows uses). This is good, but hasn't been too tested :) No | |
4245 | fancy installer yet, I'll put a note in the manual so people at |
|
4262 | fancy installer yet, I'll put a note in the manual so people at | |
4246 | least make manually a shortcut. |
|
4263 | least make manually a shortcut. | |
4247 |
|
4264 | |||
4248 | * IPython/iplib.py (Magic.magic_colors): Unified the color options |
|
4265 | * IPython/iplib.py (Magic.magic_colors): Unified the color options | |
4249 | into a single one, "colors". This now controls both prompt and |
|
4266 | into a single one, "colors". This now controls both prompt and | |
4250 | exception color schemes, and can be changed both at startup |
|
4267 | exception color schemes, and can be changed both at startup | |
4251 | (either via command-line switches or via ipythonrc files) and at |
|
4268 | (either via command-line switches or via ipythonrc files) and at | |
4252 | runtime, with @colors. |
|
4269 | runtime, with @colors. | |
4253 | (Magic.magic_run): renamed @prun to @run and removed the old |
|
4270 | (Magic.magic_run): renamed @prun to @run and removed the old | |
4254 | @run. The two were too similar to warrant keeping both. |
|
4271 | @run. The two were too similar to warrant keeping both. | |
4255 |
|
4272 | |||
4256 | 2002-02-03 Fernando Perez <fperez@colorado.edu> |
|
4273 | 2002-02-03 Fernando Perez <fperez@colorado.edu> | |
4257 |
|
4274 | |||
4258 | * IPython/iplib.py (install_first_time): Added comment on how to |
|
4275 | * IPython/iplib.py (install_first_time): Added comment on how to | |
4259 | configure the color options for first-time users. Put a <return> |
|
4276 | configure the color options for first-time users. Put a <return> | |
4260 | request at the end so that small-terminal users get a chance to |
|
4277 | request at the end so that small-terminal users get a chance to | |
4261 | read the startup info. |
|
4278 | read the startup info. | |
4262 |
|
4279 | |||
4263 | 2002-01-23 Fernando Perez <fperez@colorado.edu> |
|
4280 | 2002-01-23 Fernando Perez <fperez@colorado.edu> | |
4264 |
|
4281 | |||
4265 | * IPython/iplib.py (CachedOutput.update): Changed output memory |
|
4282 | * IPython/iplib.py (CachedOutput.update): Changed output memory | |
4266 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For |
|
4283 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For | |
4267 | input history we still use _i. Did this b/c these variable are |
|
4284 | input history we still use _i. Did this b/c these variable are | |
4268 | very commonly used in interactive work, so the less we need to |
|
4285 | very commonly used in interactive work, so the less we need to | |
4269 | type the better off we are. |
|
4286 | type the better off we are. | |
4270 | (Magic.magic_prun): updated @prun to better handle the namespaces |
|
4287 | (Magic.magic_prun): updated @prun to better handle the namespaces | |
4271 | the file will run in, including a fix for __name__ not being set |
|
4288 | the file will run in, including a fix for __name__ not being set | |
4272 | before. |
|
4289 | before. | |
4273 |
|
4290 | |||
4274 | 2002-01-20 Fernando Perez <fperez@colorado.edu> |
|
4291 | 2002-01-20 Fernando Perez <fperez@colorado.edu> | |
4275 |
|
4292 | |||
4276 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of |
|
4293 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of | |
4277 | extra garbage for Python 2.2. Need to look more carefully into |
|
4294 | extra garbage for Python 2.2. Need to look more carefully into | |
4278 | this later. |
|
4295 | this later. | |
4279 |
|
4296 | |||
4280 | 2002-01-19 Fernando Perez <fperez@colorado.edu> |
|
4297 | 2002-01-19 Fernando Perez <fperez@colorado.edu> | |
4281 |
|
4298 | |||
4282 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to |
|
4299 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to | |
4283 | display SyntaxError exceptions properly formatted when they occur |
|
4300 | display SyntaxError exceptions properly formatted when they occur | |
4284 | (they can be triggered by imported code). |
|
4301 | (they can be triggered by imported code). | |
4285 |
|
4302 | |||
4286 | 2002-01-18 Fernando Perez <fperez@colorado.edu> |
|
4303 | 2002-01-18 Fernando Perez <fperez@colorado.edu> | |
4287 |
|
4304 | |||
4288 | * IPython/iplib.py (InteractiveShell.safe_execfile): now |
|
4305 | * IPython/iplib.py (InteractiveShell.safe_execfile): now | |
4289 | SyntaxError exceptions are reported nicely formatted, instead of |
|
4306 | SyntaxError exceptions are reported nicely formatted, instead of | |
4290 | spitting out only offset information as before. |
|
4307 | spitting out only offset information as before. | |
4291 | (Magic.magic_prun): Added the @prun function for executing |
|
4308 | (Magic.magic_prun): Added the @prun function for executing | |
4292 | programs with command line args inside IPython. |
|
4309 | programs with command line args inside IPython. | |
4293 |
|
4310 | |||
4294 | 2002-01-16 Fernando Perez <fperez@colorado.edu> |
|
4311 | 2002-01-16 Fernando Perez <fperez@colorado.edu> | |
4295 |
|
4312 | |||
4296 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist |
|
4313 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist | |
4297 | to *not* include the last item given in a range. This brings their |
|
4314 | to *not* include the last item given in a range. This brings their | |
4298 | behavior in line with Python's slicing: |
|
4315 | behavior in line with Python's slicing: | |
4299 | a[n1:n2] -> a[n1]...a[n2-1] |
|
4316 | a[n1:n2] -> a[n1]...a[n2-1] | |
4300 | It may be a bit less convenient, but I prefer to stick to Python's |
|
4317 | It may be a bit less convenient, but I prefer to stick to Python's | |
4301 | conventions *everywhere*, so users never have to wonder. |
|
4318 | conventions *everywhere*, so users never have to wonder. | |
4302 | (Magic.magic_macro): Added @macro function to ease the creation of |
|
4319 | (Magic.magic_macro): Added @macro function to ease the creation of | |
4303 | macros. |
|
4320 | macros. | |
4304 |
|
4321 | |||
4305 | 2002-01-05 Fernando Perez <fperez@colorado.edu> |
|
4322 | 2002-01-05 Fernando Perez <fperez@colorado.edu> | |
4306 |
|
4323 | |||
4307 | * Released 0.2.4. |
|
4324 | * Released 0.2.4. | |
4308 |
|
4325 | |||
4309 | * IPython/iplib.py (Magic.magic_pdef): |
|
4326 | * IPython/iplib.py (Magic.magic_pdef): | |
4310 | (InteractiveShell.safe_execfile): report magic lines and error |
|
4327 | (InteractiveShell.safe_execfile): report magic lines and error | |
4311 | lines without line numbers so one can easily copy/paste them for |
|
4328 | lines without line numbers so one can easily copy/paste them for | |
4312 | re-execution. |
|
4329 | re-execution. | |
4313 |
|
4330 | |||
4314 | * Updated manual with recent changes. |
|
4331 | * Updated manual with recent changes. | |
4315 |
|
4332 | |||
4316 | * IPython/iplib.py (Magic.magic_oinfo): added constructor |
|
4333 | * IPython/iplib.py (Magic.magic_oinfo): added constructor | |
4317 | docstring printing when class? is called. Very handy for knowing |
|
4334 | docstring printing when class? is called. Very handy for knowing | |
4318 | how to create class instances (as long as __init__ is well |
|
4335 | how to create class instances (as long as __init__ is well | |
4319 | documented, of course :) |
|
4336 | documented, of course :) | |
4320 | (Magic.magic_doc): print both class and constructor docstrings. |
|
4337 | (Magic.magic_doc): print both class and constructor docstrings. | |
4321 | (Magic.magic_pdef): give constructor info if passed a class and |
|
4338 | (Magic.magic_pdef): give constructor info if passed a class and | |
4322 | __call__ info for callable object instances. |
|
4339 | __call__ info for callable object instances. | |
4323 |
|
4340 | |||
4324 | 2002-01-04 Fernando Perez <fperez@colorado.edu> |
|
4341 | 2002-01-04 Fernando Perez <fperez@colorado.edu> | |
4325 |
|
4342 | |||
4326 | * Made deep_reload() off by default. It doesn't always work |
|
4343 | * Made deep_reload() off by default. It doesn't always work | |
4327 | exactly as intended, so it's probably safer to have it off. It's |
|
4344 | exactly as intended, so it's probably safer to have it off. It's | |
4328 | still available as dreload() anyway, so nothing is lost. |
|
4345 | still available as dreload() anyway, so nothing is lost. | |
4329 |
|
4346 | |||
4330 | 2002-01-02 Fernando Perez <fperez@colorado.edu> |
|
4347 | 2002-01-02 Fernando Perez <fperez@colorado.edu> | |
4331 |
|
4348 | |||
4332 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, |
|
4349 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, | |
4333 | so I wanted an updated release). |
|
4350 | so I wanted an updated release). | |
4334 |
|
4351 | |||
4335 | 2001-12-27 Fernando Perez <fperez@colorado.edu> |
|
4352 | 2001-12-27 Fernando Perez <fperez@colorado.edu> | |
4336 |
|
4353 | |||
4337 | * IPython/iplib.py (InteractiveShell.interact): Added the original |
|
4354 | * IPython/iplib.py (InteractiveShell.interact): Added the original | |
4338 | code from 'code.py' for this module in order to change the |
|
4355 | code from 'code.py' for this module in order to change the | |
4339 | handling of a KeyboardInterrupt. This was necessary b/c otherwise |
|
4356 | handling of a KeyboardInterrupt. This was necessary b/c otherwise | |
4340 | the history cache would break when the user hit Ctrl-C, and |
|
4357 | the history cache would break when the user hit Ctrl-C, and | |
4341 | interact() offers no way to add any hooks to it. |
|
4358 | interact() offers no way to add any hooks to it. | |
4342 |
|
4359 | |||
4343 | 2001-12-23 Fernando Perez <fperez@colorado.edu> |
|
4360 | 2001-12-23 Fernando Perez <fperez@colorado.edu> | |
4344 |
|
4361 | |||
4345 | * setup.py: added check for 'MANIFEST' before trying to remove |
|
4362 | * setup.py: added check for 'MANIFEST' before trying to remove | |
4346 | it. Thanks to Sean Reifschneider. |
|
4363 | it. Thanks to Sean Reifschneider. | |
4347 |
|
4364 | |||
4348 | 2001-12-22 Fernando Perez <fperez@colorado.edu> |
|
4365 | 2001-12-22 Fernando Perez <fperez@colorado.edu> | |
4349 |
|
4366 | |||
4350 | * Released 0.2.2. |
|
4367 | * Released 0.2.2. | |
4351 |
|
4368 | |||
4352 | * Finished (reasonably) writing the manual. Later will add the |
|
4369 | * Finished (reasonably) writing the manual. Later will add the | |
4353 | python-standard navigation stylesheets, but for the time being |
|
4370 | python-standard navigation stylesheets, but for the time being | |
4354 | it's fairly complete. Distribution will include html and pdf |
|
4371 | it's fairly complete. Distribution will include html and pdf | |
4355 | versions. |
|
4372 | versions. | |
4356 |
|
4373 | |||
4357 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu |
|
4374 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu | |
4358 | (MayaVi author). |
|
4375 | (MayaVi author). | |
4359 |
|
4376 | |||
4360 | 2001-12-21 Fernando Perez <fperez@colorado.edu> |
|
4377 | 2001-12-21 Fernando Perez <fperez@colorado.edu> | |
4361 |
|
4378 | |||
4362 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a |
|
4379 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a | |
4363 | good public release, I think (with the manual and the distutils |
|
4380 | good public release, I think (with the manual and the distutils | |
4364 | installer). The manual can use some work, but that can go |
|
4381 | installer). The manual can use some work, but that can go | |
4365 | slowly. Otherwise I think it's quite nice for end users. Next |
|
4382 | slowly. Otherwise I think it's quite nice for end users. Next | |
4366 | summer, rewrite the guts of it... |
|
4383 | summer, rewrite the guts of it... | |
4367 |
|
4384 | |||
4368 | * Changed format of ipythonrc files to use whitespace as the |
|
4385 | * Changed format of ipythonrc files to use whitespace as the | |
4369 | separator instead of an explicit '='. Cleaner. |
|
4386 | separator instead of an explicit '='. Cleaner. | |
4370 |
|
4387 | |||
4371 | 2001-12-20 Fernando Perez <fperez@colorado.edu> |
|
4388 | 2001-12-20 Fernando Perez <fperez@colorado.edu> | |
4372 |
|
4389 | |||
4373 | * Started a manual in LyX. For now it's just a quick merge of the |
|
4390 | * Started a manual in LyX. For now it's just a quick merge of the | |
4374 | various internal docstrings and READMEs. Later it may grow into a |
|
4391 | various internal docstrings and READMEs. Later it may grow into a | |
4375 | nice, full-blown manual. |
|
4392 | nice, full-blown manual. | |
4376 |
|
4393 | |||
4377 | * Set up a distutils based installer. Installation should now be |
|
4394 | * Set up a distutils based installer. Installation should now be | |
4378 | trivially simple for end-users. |
|
4395 | trivially simple for end-users. | |
4379 |
|
4396 | |||
4380 | 2001-12-11 Fernando Perez <fperez@colorado.edu> |
|
4397 | 2001-12-11 Fernando Perez <fperez@colorado.edu> | |
4381 |
|
4398 | |||
4382 | * Released 0.2.0. First public release, announced it at |
|
4399 | * Released 0.2.0. First public release, announced it at | |
4383 | comp.lang.python. From now on, just bugfixes... |
|
4400 | comp.lang.python. From now on, just bugfixes... | |
4384 |
|
4401 | |||
4385 | * Went through all the files, set copyright/license notices and |
|
4402 | * Went through all the files, set copyright/license notices and | |
4386 | cleaned up things. Ready for release. |
|
4403 | cleaned up things. Ready for release. | |
4387 |
|
4404 | |||
4388 | 2001-12-10 Fernando Perez <fperez@colorado.edu> |
|
4405 | 2001-12-10 Fernando Perez <fperez@colorado.edu> | |
4389 |
|
4406 | |||
4390 | * Changed the first-time installer not to use tarfiles. It's more |
|
4407 | * Changed the first-time installer not to use tarfiles. It's more | |
4391 | robust now and less unix-dependent. Also makes it easier for |
|
4408 | robust now and less unix-dependent. Also makes it easier for | |
4392 | people to later upgrade versions. |
|
4409 | people to later upgrade versions. | |
4393 |
|
4410 | |||
4394 | * Changed @exit to @abort to reflect the fact that it's pretty |
|
4411 | * Changed @exit to @abort to reflect the fact that it's pretty | |
4395 | brutal (a sys.exit()). The difference between @abort and Ctrl-D |
|
4412 | brutal (a sys.exit()). The difference between @abort and Ctrl-D | |
4396 | becomes significant only when IPyhton is embedded: in that case, |
|
4413 | becomes significant only when IPyhton is embedded: in that case, | |
4397 | C-D closes IPython only, but @abort kills the enclosing program |
|
4414 | C-D closes IPython only, but @abort kills the enclosing program | |
4398 | too (unless it had called IPython inside a try catching |
|
4415 | too (unless it had called IPython inside a try catching | |
4399 | SystemExit). |
|
4416 | SystemExit). | |
4400 |
|
4417 | |||
4401 | * Created Shell module which exposes the actuall IPython Shell |
|
4418 | * Created Shell module which exposes the actuall IPython Shell | |
4402 | classes, currently the normal and the embeddable one. This at |
|
4419 | classes, currently the normal and the embeddable one. This at | |
4403 | least offers a stable interface we won't need to change when |
|
4420 | least offers a stable interface we won't need to change when | |
4404 | (later) the internals are rewritten. That rewrite will be confined |
|
4421 | (later) the internals are rewritten. That rewrite will be confined | |
4405 | to iplib and ipmaker, but the Shell interface should remain as is. |
|
4422 | to iplib and ipmaker, but the Shell interface should remain as is. | |
4406 |
|
4423 | |||
4407 | * Added embed module which offers an embeddable IPShell object, |
|
4424 | * Added embed module which offers an embeddable IPShell object, | |
4408 | useful to fire up IPython *inside* a running program. Great for |
|
4425 | useful to fire up IPython *inside* a running program. Great for | |
4409 | debugging or dynamical data analysis. |
|
4426 | debugging or dynamical data analysis. | |
4410 |
|
4427 | |||
4411 | 2001-12-08 Fernando Perez <fperez@colorado.edu> |
|
4428 | 2001-12-08 Fernando Perez <fperez@colorado.edu> | |
4412 |
|
4429 | |||
4413 | * Fixed small bug preventing seeing info from methods of defined |
|
4430 | * Fixed small bug preventing seeing info from methods of defined | |
4414 | objects (incorrect namespace in _ofind()). |
|
4431 | objects (incorrect namespace in _ofind()). | |
4415 |
|
4432 | |||
4416 | * Documentation cleanup. Moved the main usage docstrings to a |
|
4433 | * Documentation cleanup. Moved the main usage docstrings to a | |
4417 | separate file, usage.py (cleaner to maintain, and hopefully in the |
|
4434 | separate file, usage.py (cleaner to maintain, and hopefully in the | |
4418 | future some perlpod-like way of producing interactive, man and |
|
4435 | future some perlpod-like way of producing interactive, man and | |
4419 | html docs out of it will be found). |
|
4436 | html docs out of it will be found). | |
4420 |
|
4437 | |||
4421 | * Added @profile to see your profile at any time. |
|
4438 | * Added @profile to see your profile at any time. | |
4422 |
|
4439 | |||
4423 | * Added @p as an alias for 'print'. It's especially convenient if |
|
4440 | * Added @p as an alias for 'print'. It's especially convenient if | |
4424 | using automagic ('p x' prints x). |
|
4441 | using automagic ('p x' prints x). | |
4425 |
|
4442 | |||
4426 | * Small cleanups and fixes after a pychecker run. |
|
4443 | * Small cleanups and fixes after a pychecker run. | |
4427 |
|
4444 | |||
4428 | * Changed the @cd command to handle @cd - and @cd -<n> for |
|
4445 | * Changed the @cd command to handle @cd - and @cd -<n> for | |
4429 | visiting any directory in _dh. |
|
4446 | visiting any directory in _dh. | |
4430 |
|
4447 | |||
4431 | * Introduced _dh, a history of visited directories. @dhist prints |
|
4448 | * Introduced _dh, a history of visited directories. @dhist prints | |
4432 | it out with numbers. |
|
4449 | it out with numbers. | |
4433 |
|
4450 | |||
4434 | 2001-12-07 Fernando Perez <fperez@colorado.edu> |
|
4451 | 2001-12-07 Fernando Perez <fperez@colorado.edu> | |
4435 |
|
4452 | |||
4436 | * Released 0.1.22 |
|
4453 | * Released 0.1.22 | |
4437 |
|
4454 | |||
4438 | * Made initialization a bit more robust against invalid color |
|
4455 | * Made initialization a bit more robust against invalid color | |
4439 | options in user input (exit, not traceback-crash). |
|
4456 | options in user input (exit, not traceback-crash). | |
4440 |
|
4457 | |||
4441 | * Changed the bug crash reporter to write the report only in the |
|
4458 | * Changed the bug crash reporter to write the report only in the | |
4442 | user's .ipython directory. That way IPython won't litter people's |
|
4459 | user's .ipython directory. That way IPython won't litter people's | |
4443 | hard disks with crash files all over the place. Also print on |
|
4460 | hard disks with crash files all over the place. Also print on | |
4444 | screen the necessary mail command. |
|
4461 | screen the necessary mail command. | |
4445 |
|
4462 | |||
4446 | * With the new ultraTB, implemented LightBG color scheme for light |
|
4463 | * With the new ultraTB, implemented LightBG color scheme for light | |
4447 | background terminals. A lot of people like white backgrounds, so I |
|
4464 | background terminals. A lot of people like white backgrounds, so I | |
4448 | guess we should at least give them something readable. |
|
4465 | guess we should at least give them something readable. | |
4449 |
|
4466 | |||
4450 | 2001-12-06 Fernando Perez <fperez@colorado.edu> |
|
4467 | 2001-12-06 Fernando Perez <fperez@colorado.edu> | |
4451 |
|
4468 | |||
4452 | * Modified the structure of ultraTB. Now there's a proper class |
|
4469 | * Modified the structure of ultraTB. Now there's a proper class | |
4453 | for tables of color schemes which allow adding schemes easily and |
|
4470 | for tables of color schemes which allow adding schemes easily and | |
4454 | switching the active scheme without creating a new instance every |
|
4471 | switching the active scheme without creating a new instance every | |
4455 | time (which was ridiculous). The syntax for creating new schemes |
|
4472 | time (which was ridiculous). The syntax for creating new schemes | |
4456 | is also cleaner. I think ultraTB is finally done, with a clean |
|
4473 | is also cleaner. I think ultraTB is finally done, with a clean | |
4457 | class structure. Names are also much cleaner (now there's proper |
|
4474 | class structure. Names are also much cleaner (now there's proper | |
4458 | color tables, no need for every variable to also have 'color' in |
|
4475 | color tables, no need for every variable to also have 'color' in | |
4459 | its name). |
|
4476 | its name). | |
4460 |
|
4477 | |||
4461 | * Broke down genutils into separate files. Now genutils only |
|
4478 | * Broke down genutils into separate files. Now genutils only | |
4462 | contains utility functions, and classes have been moved to their |
|
4479 | contains utility functions, and classes have been moved to their | |
4463 | own files (they had enough independent functionality to warrant |
|
4480 | own files (they had enough independent functionality to warrant | |
4464 | it): ConfigLoader, OutputTrap, Struct. |
|
4481 | it): ConfigLoader, OutputTrap, Struct. | |
4465 |
|
4482 | |||
4466 | 2001-12-05 Fernando Perez <fperez@colorado.edu> |
|
4483 | 2001-12-05 Fernando Perez <fperez@colorado.edu> | |
4467 |
|
4484 | |||
4468 | * IPython turns 21! Released version 0.1.21, as a candidate for |
|
4485 | * IPython turns 21! Released version 0.1.21, as a candidate for | |
4469 | public consumption. If all goes well, release in a few days. |
|
4486 | public consumption. If all goes well, release in a few days. | |
4470 |
|
4487 | |||
4471 | * Fixed path bug (files in Extensions/ directory wouldn't be found |
|
4488 | * Fixed path bug (files in Extensions/ directory wouldn't be found | |
4472 | unless IPython/ was explicitly in sys.path). |
|
4489 | unless IPython/ was explicitly in sys.path). | |
4473 |
|
4490 | |||
4474 | * Extended the FlexCompleter class as MagicCompleter to allow |
|
4491 | * Extended the FlexCompleter class as MagicCompleter to allow | |
4475 | completion of @-starting lines. |
|
4492 | completion of @-starting lines. | |
4476 |
|
4493 | |||
4477 | * Created __release__.py file as a central repository for release |
|
4494 | * Created __release__.py file as a central repository for release | |
4478 | info that other files can read from. |
|
4495 | info that other files can read from. | |
4479 |
|
4496 | |||
4480 | * Fixed small bug in logging: when logging was turned on in |
|
4497 | * Fixed small bug in logging: when logging was turned on in | |
4481 | mid-session, old lines with special meanings (!@?) were being |
|
4498 | mid-session, old lines with special meanings (!@?) were being | |
4482 | logged without the prepended comment, which is necessary since |
|
4499 | logged without the prepended comment, which is necessary since | |
4483 | they are not truly valid python syntax. This should make session |
|
4500 | they are not truly valid python syntax. This should make session | |
4484 | restores produce less errors. |
|
4501 | restores produce less errors. | |
4485 |
|
4502 | |||
4486 | * The namespace cleanup forced me to make a FlexCompleter class |
|
4503 | * The namespace cleanup forced me to make a FlexCompleter class | |
4487 | which is nothing but a ripoff of rlcompleter, but with selectable |
|
4504 | which is nothing but a ripoff of rlcompleter, but with selectable | |
4488 | namespace (rlcompleter only works in __main__.__dict__). I'll try |
|
4505 | namespace (rlcompleter only works in __main__.__dict__). I'll try | |
4489 | to submit a note to the authors to see if this change can be |
|
4506 | to submit a note to the authors to see if this change can be | |
4490 | incorporated in future rlcompleter releases (Dec.6: done) |
|
4507 | incorporated in future rlcompleter releases (Dec.6: done) | |
4491 |
|
4508 | |||
4492 | * More fixes to namespace handling. It was a mess! Now all |
|
4509 | * More fixes to namespace handling. It was a mess! Now all | |
4493 | explicit references to __main__.__dict__ are gone (except when |
|
4510 | explicit references to __main__.__dict__ are gone (except when | |
4494 | really needed) and everything is handled through the namespace |
|
4511 | really needed) and everything is handled through the namespace | |
4495 | dicts in the IPython instance. We seem to be getting somewhere |
|
4512 | dicts in the IPython instance. We seem to be getting somewhere | |
4496 | with this, finally... |
|
4513 | with this, finally... | |
4497 |
|
4514 | |||
4498 | * Small documentation updates. |
|
4515 | * Small documentation updates. | |
4499 |
|
4516 | |||
4500 | * Created the Extensions directory under IPython (with an |
|
4517 | * Created the Extensions directory under IPython (with an | |
4501 | __init__.py). Put the PhysicalQ stuff there. This directory should |
|
4518 | __init__.py). Put the PhysicalQ stuff there. This directory should | |
4502 | be used for all special-purpose extensions. |
|
4519 | be used for all special-purpose extensions. | |
4503 |
|
4520 | |||
4504 | * File renaming: |
|
4521 | * File renaming: | |
4505 | ipythonlib --> ipmaker |
|
4522 | ipythonlib --> ipmaker | |
4506 | ipplib --> iplib |
|
4523 | ipplib --> iplib | |
4507 | This makes a bit more sense in terms of what these files actually do. |
|
4524 | This makes a bit more sense in terms of what these files actually do. | |
4508 |
|
4525 | |||
4509 | * Moved all the classes and functions in ipythonlib to ipplib, so |
|
4526 | * Moved all the classes and functions in ipythonlib to ipplib, so | |
4510 | now ipythonlib only has make_IPython(). This will ease up its |
|
4527 | now ipythonlib only has make_IPython(). This will ease up its | |
4511 | splitting in smaller functional chunks later. |
|
4528 | splitting in smaller functional chunks later. | |
4512 |
|
4529 | |||
4513 | * Cleaned up (done, I think) output of @whos. Better column |
|
4530 | * Cleaned up (done, I think) output of @whos. Better column | |
4514 | formatting, and now shows str(var) for as much as it can, which is |
|
4531 | formatting, and now shows str(var) for as much as it can, which is | |
4515 | typically what one gets with a 'print var'. |
|
4532 | typically what one gets with a 'print var'. | |
4516 |
|
4533 | |||
4517 | 2001-12-04 Fernando Perez <fperez@colorado.edu> |
|
4534 | 2001-12-04 Fernando Perez <fperez@colorado.edu> | |
4518 |
|
4535 | |||
4519 | * Fixed namespace problems. Now builtin/IPyhton/user names get |
|
4536 | * Fixed namespace problems. Now builtin/IPyhton/user names get | |
4520 | properly reported in their namespace. Internal namespace handling |
|
4537 | properly reported in their namespace. Internal namespace handling | |
4521 | is finally getting decent (not perfect yet, but much better than |
|
4538 | is finally getting decent (not perfect yet, but much better than | |
4522 | the ad-hoc mess we had). |
|
4539 | the ad-hoc mess we had). | |
4523 |
|
4540 | |||
4524 | * Removed -exit option. If people just want to run a python |
|
4541 | * Removed -exit option. If people just want to run a python | |
4525 | script, that's what the normal interpreter is for. Less |
|
4542 | script, that's what the normal interpreter is for. Less | |
4526 | unnecessary options, less chances for bugs. |
|
4543 | unnecessary options, less chances for bugs. | |
4527 |
|
4544 | |||
4528 | * Added a crash handler which generates a complete post-mortem if |
|
4545 | * Added a crash handler which generates a complete post-mortem if | |
4529 | IPython crashes. This will help a lot in tracking bugs down the |
|
4546 | IPython crashes. This will help a lot in tracking bugs down the | |
4530 | road. |
|
4547 | road. | |
4531 |
|
4548 | |||
4532 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names |
|
4549 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names | |
4533 | which were boud to functions being reassigned would bypass the |
|
4550 | which were boud to functions being reassigned would bypass the | |
4534 | logger, breaking the sync of _il with the prompt counter. This |
|
4551 | logger, breaking the sync of _il with the prompt counter. This | |
4535 | would then crash IPython later when a new line was logged. |
|
4552 | would then crash IPython later when a new line was logged. | |
4536 |
|
4553 | |||
4537 | 2001-12-02 Fernando Perez <fperez@colorado.edu> |
|
4554 | 2001-12-02 Fernando Perez <fperez@colorado.edu> | |
4538 |
|
4555 | |||
4539 | * Made IPython a package. This means people don't have to clutter |
|
4556 | * Made IPython a package. This means people don't have to clutter | |
4540 | their sys.path with yet another directory. Changed the INSTALL |
|
4557 | their sys.path with yet another directory. Changed the INSTALL | |
4541 | file accordingly. |
|
4558 | file accordingly. | |
4542 |
|
4559 | |||
4543 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now |
|
4560 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now | |
4544 | sorts its output (so @who shows it sorted) and @whos formats the |
|
4561 | sorts its output (so @who shows it sorted) and @whos formats the | |
4545 | table according to the width of the first column. Nicer, easier to |
|
4562 | table according to the width of the first column. Nicer, easier to | |
4546 | read. Todo: write a generic table_format() which takes a list of |
|
4563 | read. Todo: write a generic table_format() which takes a list of | |
4547 | lists and prints it nicely formatted, with optional row/column |
|
4564 | lists and prints it nicely formatted, with optional row/column | |
4548 | separators and proper padding and justification. |
|
4565 | separators and proper padding and justification. | |
4549 |
|
4566 | |||
4550 | * Released 0.1.20 |
|
4567 | * Released 0.1.20 | |
4551 |
|
4568 | |||
4552 | * Fixed bug in @log which would reverse the inputcache list (a |
|
4569 | * Fixed bug in @log which would reverse the inputcache list (a | |
4553 | copy operation was missing). |
|
4570 | copy operation was missing). | |
4554 |
|
4571 | |||
4555 | * Code cleanup. @config was changed to use page(). Better, since |
|
4572 | * Code cleanup. @config was changed to use page(). Better, since | |
4556 | its output is always quite long. |
|
4573 | its output is always quite long. | |
4557 |
|
4574 | |||
4558 | * Itpl is back as a dependency. I was having too many problems |
|
4575 | * Itpl is back as a dependency. I was having too many problems | |
4559 | getting the parametric aliases to work reliably, and it's just |
|
4576 | getting the parametric aliases to work reliably, and it's just | |
4560 | easier to code weird string operations with it than playing %()s |
|
4577 | easier to code weird string operations with it than playing %()s | |
4561 | games. It's only ~6k, so I don't think it's too big a deal. |
|
4578 | games. It's only ~6k, so I don't think it's too big a deal. | |
4562 |
|
4579 | |||
4563 | * Found (and fixed) a very nasty bug with history. !lines weren't |
|
4580 | * Found (and fixed) a very nasty bug with history. !lines weren't | |
4564 | getting cached, and the out of sync caches would crash |
|
4581 | getting cached, and the out of sync caches would crash | |
4565 | IPython. Fixed it by reorganizing the prefilter/handlers/logger |
|
4582 | IPython. Fixed it by reorganizing the prefilter/handlers/logger | |
4566 | division of labor a bit better. Bug fixed, cleaner structure. |
|
4583 | division of labor a bit better. Bug fixed, cleaner structure. | |
4567 |
|
4584 | |||
4568 | 2001-12-01 Fernando Perez <fperez@colorado.edu> |
|
4585 | 2001-12-01 Fernando Perez <fperez@colorado.edu> | |
4569 |
|
4586 | |||
4570 | * Released 0.1.19 |
|
4587 | * Released 0.1.19 | |
4571 |
|
4588 | |||
4572 | * Added option -n to @hist to prevent line number printing. Much |
|
4589 | * Added option -n to @hist to prevent line number printing. Much | |
4573 | easier to copy/paste code this way. |
|
4590 | easier to copy/paste code this way. | |
4574 |
|
4591 | |||
4575 | * Created global _il to hold the input list. Allows easy |
|
4592 | * Created global _il to hold the input list. Allows easy | |
4576 | re-execution of blocks of code by slicing it (inspired by Janko's |
|
4593 | re-execution of blocks of code by slicing it (inspired by Janko's | |
4577 | comment on 'macros'). |
|
4594 | comment on 'macros'). | |
4578 |
|
4595 | |||
4579 | * Small fixes and doc updates. |
|
4596 | * Small fixes and doc updates. | |
4580 |
|
4597 | |||
4581 | * Rewrote @history function (was @h). Renamed it to @hist, @h is |
|
4598 | * Rewrote @history function (was @h). Renamed it to @hist, @h is | |
4582 | much too fragile with automagic. Handles properly multi-line |
|
4599 | much too fragile with automagic. Handles properly multi-line | |
4583 | statements and takes parameters. |
|
4600 | statements and takes parameters. | |
4584 |
|
4601 | |||
4585 | 2001-11-30 Fernando Perez <fperez@colorado.edu> |
|
4602 | 2001-11-30 Fernando Perez <fperez@colorado.edu> | |
4586 |
|
4603 | |||
4587 | * Version 0.1.18 released. |
|
4604 | * Version 0.1.18 released. | |
4588 |
|
4605 | |||
4589 | * Fixed nasty namespace bug in initial module imports. |
|
4606 | * Fixed nasty namespace bug in initial module imports. | |
4590 |
|
4607 | |||
4591 | * Added copyright/license notes to all code files (except |
|
4608 | * Added copyright/license notes to all code files (except | |
4592 | DPyGetOpt). For the time being, LGPL. That could change. |
|
4609 | DPyGetOpt). For the time being, LGPL. That could change. | |
4593 |
|
4610 | |||
4594 | * Rewrote a much nicer README, updated INSTALL, cleaned up |
|
4611 | * Rewrote a much nicer README, updated INSTALL, cleaned up | |
4595 | ipythonrc-* samples. |
|
4612 | ipythonrc-* samples. | |
4596 |
|
4613 | |||
4597 | * Overall code/documentation cleanup. Basically ready for |
|
4614 | * Overall code/documentation cleanup. Basically ready for | |
4598 | release. Only remaining thing: licence decision (LGPL?). |
|
4615 | release. Only remaining thing: licence decision (LGPL?). | |
4599 |
|
4616 | |||
4600 | * Converted load_config to a class, ConfigLoader. Now recursion |
|
4617 | * Converted load_config to a class, ConfigLoader. Now recursion | |
4601 | control is better organized. Doesn't include the same file twice. |
|
4618 | control is better organized. Doesn't include the same file twice. | |
4602 |
|
4619 | |||
4603 | 2001-11-29 Fernando Perez <fperez@colorado.edu> |
|
4620 | 2001-11-29 Fernando Perez <fperez@colorado.edu> | |
4604 |
|
4621 | |||
4605 | * Got input history working. Changed output history variables from |
|
4622 | * Got input history working. Changed output history variables from | |
4606 | _p to _o so that _i is for input and _o for output. Just cleaner |
|
4623 | _p to _o so that _i is for input and _o for output. Just cleaner | |
4607 | convention. |
|
4624 | convention. | |
4608 |
|
4625 | |||
4609 | * Implemented parametric aliases. This pretty much allows the |
|
4626 | * Implemented parametric aliases. This pretty much allows the | |
4610 | alias system to offer full-blown shell convenience, I think. |
|
4627 | alias system to offer full-blown shell convenience, I think. | |
4611 |
|
4628 | |||
4612 | * Version 0.1.17 released, 0.1.18 opened. |
|
4629 | * Version 0.1.17 released, 0.1.18 opened. | |
4613 |
|
4630 | |||
4614 | * dot_ipython/ipythonrc (alias): added documentation. |
|
4631 | * dot_ipython/ipythonrc (alias): added documentation. | |
4615 | (xcolor): Fixed small bug (xcolors -> xcolor) |
|
4632 | (xcolor): Fixed small bug (xcolors -> xcolor) | |
4616 |
|
4633 | |||
4617 | * Changed the alias system. Now alias is a magic command to define |
|
4634 | * Changed the alias system. Now alias is a magic command to define | |
4618 | aliases just like the shell. Rationale: the builtin magics should |
|
4635 | aliases just like the shell. Rationale: the builtin magics should | |
4619 | be there for things deeply connected to IPython's |
|
4636 | be there for things deeply connected to IPython's | |
4620 | architecture. And this is a much lighter system for what I think |
|
4637 | architecture. And this is a much lighter system for what I think | |
4621 | is the really important feature: allowing users to define quickly |
|
4638 | is the really important feature: allowing users to define quickly | |
4622 | magics that will do shell things for them, so they can customize |
|
4639 | magics that will do shell things for them, so they can customize | |
4623 | IPython easily to match their work habits. If someone is really |
|
4640 | IPython easily to match their work habits. If someone is really | |
4624 | desperate to have another name for a builtin alias, they can |
|
4641 | desperate to have another name for a builtin alias, they can | |
4625 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but |
|
4642 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but | |
4626 | works. |
|
4643 | works. | |
4627 |
|
4644 | |||
4628 | 2001-11-28 Fernando Perez <fperez@colorado.edu> |
|
4645 | 2001-11-28 Fernando Perez <fperez@colorado.edu> | |
4629 |
|
4646 | |||
4630 | * Changed @file so that it opens the source file at the proper |
|
4647 | * Changed @file so that it opens the source file at the proper | |
4631 | line. Since it uses less, if your EDITOR environment is |
|
4648 | line. Since it uses less, if your EDITOR environment is | |
4632 | configured, typing v will immediately open your editor of choice |
|
4649 | configured, typing v will immediately open your editor of choice | |
4633 | right at the line where the object is defined. Not as quick as |
|
4650 | right at the line where the object is defined. Not as quick as | |
4634 | having a direct @edit command, but for all intents and purposes it |
|
4651 | having a direct @edit command, but for all intents and purposes it | |
4635 | works. And I don't have to worry about writing @edit to deal with |
|
4652 | works. And I don't have to worry about writing @edit to deal with | |
4636 | all the editors, less does that. |
|
4653 | all the editors, less does that. | |
4637 |
|
4654 | |||
4638 | * Version 0.1.16 released, 0.1.17 opened. |
|
4655 | * Version 0.1.16 released, 0.1.17 opened. | |
4639 |
|
4656 | |||
4640 | * Fixed some nasty bugs in the page/page_dumb combo that could |
|
4657 | * Fixed some nasty bugs in the page/page_dumb combo that could | |
4641 | crash IPython. |
|
4658 | crash IPython. | |
4642 |
|
4659 | |||
4643 | 2001-11-27 Fernando Perez <fperez@colorado.edu> |
|
4660 | 2001-11-27 Fernando Perez <fperez@colorado.edu> | |
4644 |
|
4661 | |||
4645 | * Version 0.1.15 released, 0.1.16 opened. |
|
4662 | * Version 0.1.15 released, 0.1.16 opened. | |
4646 |
|
4663 | |||
4647 | * Finally got ? and ?? to work for undefined things: now it's |
|
4664 | * Finally got ? and ?? to work for undefined things: now it's | |
4648 | possible to type {}.get? and get information about the get method |
|
4665 | possible to type {}.get? and get information about the get method | |
4649 | of dicts, or os.path? even if only os is defined (so technically |
|
4666 | of dicts, or os.path? even if only os is defined (so technically | |
4650 | os.path isn't). Works at any level. For example, after import os, |
|
4667 | os.path isn't). Works at any level. For example, after import os, | |
4651 | os?, os.path?, os.path.abspath? all work. This is great, took some |
|
4668 | os?, os.path?, os.path.abspath? all work. This is great, took some | |
4652 | work in _ofind. |
|
4669 | work in _ofind. | |
4653 |
|
4670 | |||
4654 | * Fixed more bugs with logging. The sanest way to do it was to add |
|
4671 | * Fixed more bugs with logging. The sanest way to do it was to add | |
4655 | to @log a 'mode' parameter. Killed two in one shot (this mode |
|
4672 | to @log a 'mode' parameter. Killed two in one shot (this mode | |
4656 | option was a request of Janko's). I think it's finally clean |
|
4673 | option was a request of Janko's). I think it's finally clean | |
4657 | (famous last words). |
|
4674 | (famous last words). | |
4658 |
|
4675 | |||
4659 | * Added a page_dumb() pager which does a decent job of paging on |
|
4676 | * Added a page_dumb() pager which does a decent job of paging on | |
4660 | screen, if better things (like less) aren't available. One less |
|
4677 | screen, if better things (like less) aren't available. One less | |
4661 | unix dependency (someday maybe somebody will port this to |
|
4678 | unix dependency (someday maybe somebody will port this to | |
4662 | windows). |
|
4679 | windows). | |
4663 |
|
4680 | |||
4664 | * Fixed problem in magic_log: would lock of logging out if log |
|
4681 | * Fixed problem in magic_log: would lock of logging out if log | |
4665 | creation failed (because it would still think it had succeeded). |
|
4682 | creation failed (because it would still think it had succeeded). | |
4666 |
|
4683 | |||
4667 | * Improved the page() function using curses to auto-detect screen |
|
4684 | * Improved the page() function using curses to auto-detect screen | |
4668 | size. Now it can make a much better decision on whether to print |
|
4685 | size. Now it can make a much better decision on whether to print | |
4669 | or page a string. Option screen_length was modified: a value 0 |
|
4686 | or page a string. Option screen_length was modified: a value 0 | |
4670 | means auto-detect, and that's the default now. |
|
4687 | means auto-detect, and that's the default now. | |
4671 |
|
4688 | |||
4672 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to |
|
4689 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to | |
4673 | go out. I'll test it for a few days, then talk to Janko about |
|
4690 | go out. I'll test it for a few days, then talk to Janko about | |
4674 | licences and announce it. |
|
4691 | licences and announce it. | |
4675 |
|
4692 | |||
4676 | * Fixed the length of the auto-generated ---> prompt which appears |
|
4693 | * Fixed the length of the auto-generated ---> prompt which appears | |
4677 | for auto-parens and auto-quotes. Getting this right isn't trivial, |
|
4694 | for auto-parens and auto-quotes. Getting this right isn't trivial, | |
4678 | with all the color escapes, different prompt types and optional |
|
4695 | with all the color escapes, different prompt types and optional | |
4679 | separators. But it seems to be working in all the combinations. |
|
4696 | separators. But it seems to be working in all the combinations. | |
4680 |
|
4697 | |||
4681 | 2001-11-26 Fernando Perez <fperez@colorado.edu> |
|
4698 | 2001-11-26 Fernando Perez <fperez@colorado.edu> | |
4682 |
|
4699 | |||
4683 | * Wrote a regexp filter to get option types from the option names |
|
4700 | * Wrote a regexp filter to get option types from the option names | |
4684 | string. This eliminates the need to manually keep two duplicate |
|
4701 | string. This eliminates the need to manually keep two duplicate | |
4685 | lists. |
|
4702 | lists. | |
4686 |
|
4703 | |||
4687 | * Removed the unneeded check_option_names. Now options are handled |
|
4704 | * Removed the unneeded check_option_names. Now options are handled | |
4688 | in a much saner manner and it's easy to visually check that things |
|
4705 | in a much saner manner and it's easy to visually check that things | |
4689 | are ok. |
|
4706 | are ok. | |
4690 |
|
4707 | |||
4691 | * Updated version numbers on all files I modified to carry a |
|
4708 | * Updated version numbers on all files I modified to carry a | |
4692 | notice so Janko and Nathan have clear version markers. |
|
4709 | notice so Janko and Nathan have clear version markers. | |
4693 |
|
4710 | |||
4694 | * Updated docstring for ultraTB with my changes. I should send |
|
4711 | * Updated docstring for ultraTB with my changes. I should send | |
4695 | this to Nathan. |
|
4712 | this to Nathan. | |
4696 |
|
4713 | |||
4697 | * Lots of small fixes. Ran everything through pychecker again. |
|
4714 | * Lots of small fixes. Ran everything through pychecker again. | |
4698 |
|
4715 | |||
4699 | * Made loading of deep_reload an cmd line option. If it's not too |
|
4716 | * Made loading of deep_reload an cmd line option. If it's not too | |
4700 | kosher, now people can just disable it. With -nodeep_reload it's |
|
4717 | kosher, now people can just disable it. With -nodeep_reload it's | |
4701 | still available as dreload(), it just won't overwrite reload(). |
|
4718 | still available as dreload(), it just won't overwrite reload(). | |
4702 |
|
4719 | |||
4703 | * Moved many options to the no| form (-opt and -noopt |
|
4720 | * Moved many options to the no| form (-opt and -noopt | |
4704 | accepted). Cleaner. |
|
4721 | accepted). Cleaner. | |
4705 |
|
4722 | |||
4706 | * Changed magic_log so that if called with no parameters, it uses |
|
4723 | * Changed magic_log so that if called with no parameters, it uses | |
4707 | 'rotate' mode. That way auto-generated logs aren't automatically |
|
4724 | 'rotate' mode. That way auto-generated logs aren't automatically | |
4708 | over-written. For normal logs, now a backup is made if it exists |
|
4725 | over-written. For normal logs, now a backup is made if it exists | |
4709 | (only 1 level of backups). A new 'backup' mode was added to the |
|
4726 | (only 1 level of backups). A new 'backup' mode was added to the | |
4710 | Logger class to support this. This was a request by Janko. |
|
4727 | Logger class to support this. This was a request by Janko. | |
4711 |
|
4728 | |||
4712 | * Added @logoff/@logon to stop/restart an active log. |
|
4729 | * Added @logoff/@logon to stop/restart an active log. | |
4713 |
|
4730 | |||
4714 | * Fixed a lot of bugs in log saving/replay. It was pretty |
|
4731 | * Fixed a lot of bugs in log saving/replay. It was pretty | |
4715 | broken. Now special lines (!@,/) appear properly in the command |
|
4732 | broken. Now special lines (!@,/) appear properly in the command | |
4716 | history after a log replay. |
|
4733 | history after a log replay. | |
4717 |
|
4734 | |||
4718 | * Tried and failed to implement full session saving via pickle. My |
|
4735 | * Tried and failed to implement full session saving via pickle. My | |
4719 | idea was to pickle __main__.__dict__, but modules can't be |
|
4736 | idea was to pickle __main__.__dict__, but modules can't be | |
4720 | pickled. This would be a better alternative to replaying logs, but |
|
4737 | pickled. This would be a better alternative to replaying logs, but | |
4721 | seems quite tricky to get to work. Changed -session to be called |
|
4738 | seems quite tricky to get to work. Changed -session to be called | |
4722 | -logplay, which more accurately reflects what it does. And if we |
|
4739 | -logplay, which more accurately reflects what it does. And if we | |
4723 | ever get real session saving working, -session is now available. |
|
4740 | ever get real session saving working, -session is now available. | |
4724 |
|
4741 | |||
4725 | * Implemented color schemes for prompts also. As for tracebacks, |
|
4742 | * Implemented color schemes for prompts also. As for tracebacks, | |
4726 | currently only NoColor and Linux are supported. But now the |
|
4743 | currently only NoColor and Linux are supported. But now the | |
4727 | infrastructure is in place, based on a generic ColorScheme |
|
4744 | infrastructure is in place, based on a generic ColorScheme | |
4728 | class. So writing and activating new schemes both for the prompts |
|
4745 | class. So writing and activating new schemes both for the prompts | |
4729 | and the tracebacks should be straightforward. |
|
4746 | and the tracebacks should be straightforward. | |
4730 |
|
4747 | |||
4731 | * Version 0.1.13 released, 0.1.14 opened. |
|
4748 | * Version 0.1.13 released, 0.1.14 opened. | |
4732 |
|
4749 | |||
4733 | * Changed handling of options for output cache. Now counter is |
|
4750 | * Changed handling of options for output cache. Now counter is | |
4734 | hardwired starting at 1 and one specifies the maximum number of |
|
4751 | hardwired starting at 1 and one specifies the maximum number of | |
4735 | entries *in the outcache* (not the max prompt counter). This is |
|
4752 | entries *in the outcache* (not the max prompt counter). This is | |
4736 | much better, since many statements won't increase the cache |
|
4753 | much better, since many statements won't increase the cache | |
4737 | count. It also eliminated some confusing options, now there's only |
|
4754 | count. It also eliminated some confusing options, now there's only | |
4738 | one: cache_size. |
|
4755 | one: cache_size. | |
4739 |
|
4756 | |||
4740 | * Added 'alias' magic function and magic_alias option in the |
|
4757 | * Added 'alias' magic function and magic_alias option in the | |
4741 | ipythonrc file. Now the user can easily define whatever names he |
|
4758 | ipythonrc file. Now the user can easily define whatever names he | |
4742 | wants for the magic functions without having to play weird |
|
4759 | wants for the magic functions without having to play weird | |
4743 | namespace games. This gives IPython a real shell-like feel. |
|
4760 | namespace games. This gives IPython a real shell-like feel. | |
4744 |
|
4761 | |||
4745 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit |
|
4762 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit | |
4746 | @ or not). |
|
4763 | @ or not). | |
4747 |
|
4764 | |||
4748 | This was one of the last remaining 'visible' bugs (that I know |
|
4765 | This was one of the last remaining 'visible' bugs (that I know | |
4749 | of). I think if I can clean up the session loading so it works |
|
4766 | of). I think if I can clean up the session loading so it works | |
4750 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first |
|
4767 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first | |
4751 | about licensing). |
|
4768 | about licensing). | |
4752 |
|
4769 | |||
4753 | 2001-11-25 Fernando Perez <fperez@colorado.edu> |
|
4770 | 2001-11-25 Fernando Perez <fperez@colorado.edu> | |
4754 |
|
4771 | |||
4755 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and |
|
4772 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and | |
4756 | there's a cleaner distinction between what ? and ?? show. |
|
4773 | there's a cleaner distinction between what ? and ?? show. | |
4757 |
|
4774 | |||
4758 | * Added screen_length option. Now the user can define his own |
|
4775 | * Added screen_length option. Now the user can define his own | |
4759 | screen size for page() operations. |
|
4776 | screen size for page() operations. | |
4760 |
|
4777 | |||
4761 | * Implemented magic shell-like functions with automatic code |
|
4778 | * Implemented magic shell-like functions with automatic code | |
4762 | generation. Now adding another function is just a matter of adding |
|
4779 | generation. Now adding another function is just a matter of adding | |
4763 | an entry to a dict, and the function is dynamically generated at |
|
4780 | an entry to a dict, and the function is dynamically generated at | |
4764 | run-time. Python has some really cool features! |
|
4781 | run-time. Python has some really cool features! | |
4765 |
|
4782 | |||
4766 | * Renamed many options to cleanup conventions a little. Now all |
|
4783 | * Renamed many options to cleanup conventions a little. Now all | |
4767 | are lowercase, and only underscores where needed. Also in the code |
|
4784 | are lowercase, and only underscores where needed. Also in the code | |
4768 | option name tables are clearer. |
|
4785 | option name tables are clearer. | |
4769 |
|
4786 | |||
4770 | * Changed prompts a little. Now input is 'In [n]:' instead of |
|
4787 | * Changed prompts a little. Now input is 'In [n]:' instead of | |
4771 | 'In[n]:='. This allows it the numbers to be aligned with the |
|
4788 | 'In[n]:='. This allows it the numbers to be aligned with the | |
4772 | Out[n] numbers, and removes usage of ':=' which doesn't exist in |
|
4789 | Out[n] numbers, and removes usage of ':=' which doesn't exist in | |
4773 | Python (it was a Mathematica thing). The '...' continuation prompt |
|
4790 | Python (it was a Mathematica thing). The '...' continuation prompt | |
4774 | was also changed a little to align better. |
|
4791 | was also changed a little to align better. | |
4775 |
|
4792 | |||
4776 | * Fixed bug when flushing output cache. Not all _p<n> variables |
|
4793 | * Fixed bug when flushing output cache. Not all _p<n> variables | |
4777 | exist, so their deletion needs to be wrapped in a try: |
|
4794 | exist, so their deletion needs to be wrapped in a try: | |
4778 |
|
4795 | |||
4779 | * Figured out how to properly use inspect.formatargspec() (it |
|
4796 | * Figured out how to properly use inspect.formatargspec() (it | |
4780 | requires the args preceded by *). So I removed all the code from |
|
4797 | requires the args preceded by *). So I removed all the code from | |
4781 | _get_pdef in Magic, which was just replicating that. |
|
4798 | _get_pdef in Magic, which was just replicating that. | |
4782 |
|
4799 | |||
4783 | * Added test to prefilter to allow redefining magic function names |
|
4800 | * Added test to prefilter to allow redefining magic function names | |
4784 | as variables. This is ok, since the @ form is always available, |
|
4801 | as variables. This is ok, since the @ form is always available, | |
4785 | but whe should allow the user to define a variable called 'ls' if |
|
4802 | but whe should allow the user to define a variable called 'ls' if | |
4786 | he needs it. |
|
4803 | he needs it. | |
4787 |
|
4804 | |||
4788 | * Moved the ToDo information from README into a separate ToDo. |
|
4805 | * Moved the ToDo information from README into a separate ToDo. | |
4789 |
|
4806 | |||
4790 | * General code cleanup and small bugfixes. I think it's close to a |
|
4807 | * General code cleanup and small bugfixes. I think it's close to a | |
4791 | state where it can be released, obviously with a big 'beta' |
|
4808 | state where it can be released, obviously with a big 'beta' | |
4792 | warning on it. |
|
4809 | warning on it. | |
4793 |
|
4810 | |||
4794 | * Got the magic function split to work. Now all magics are defined |
|
4811 | * Got the magic function split to work. Now all magics are defined | |
4795 | in a separate class. It just organizes things a bit, and now |
|
4812 | in a separate class. It just organizes things a bit, and now | |
4796 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it |
|
4813 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it | |
4797 | was too long). |
|
4814 | was too long). | |
4798 |
|
4815 | |||
4799 | * Changed @clear to @reset to avoid potential confusions with |
|
4816 | * Changed @clear to @reset to avoid potential confusions with | |
4800 | the shell command clear. Also renamed @cl to @clear, which does |
|
4817 | the shell command clear. Also renamed @cl to @clear, which does | |
4801 | exactly what people expect it to from their shell experience. |
|
4818 | exactly what people expect it to from their shell experience. | |
4802 |
|
4819 | |||
4803 | Added a check to the @reset command (since it's so |
|
4820 | Added a check to the @reset command (since it's so | |
4804 | destructive, it's probably a good idea to ask for confirmation). |
|
4821 | destructive, it's probably a good idea to ask for confirmation). | |
4805 | But now reset only works for full namespace resetting. Since the |
|
4822 | But now reset only works for full namespace resetting. Since the | |
4806 | del keyword is already there for deleting a few specific |
|
4823 | del keyword is already there for deleting a few specific | |
4807 | variables, I don't see the point of having a redundant magic |
|
4824 | variables, I don't see the point of having a redundant magic | |
4808 | function for the same task. |
|
4825 | function for the same task. | |
4809 |
|
4826 | |||
4810 | 2001-11-24 Fernando Perez <fperez@colorado.edu> |
|
4827 | 2001-11-24 Fernando Perez <fperez@colorado.edu> | |
4811 |
|
4828 | |||
4812 | * Updated the builtin docs (esp. the ? ones). |
|
4829 | * Updated the builtin docs (esp. the ? ones). | |
4813 |
|
4830 | |||
4814 | * Ran all the code through pychecker. Not terribly impressed with |
|
4831 | * Ran all the code through pychecker. Not terribly impressed with | |
4815 | it: lots of spurious warnings and didn't really find anything of |
|
4832 | it: lots of spurious warnings and didn't really find anything of | |
4816 | substance (just a few modules being imported and not used). |
|
4833 | substance (just a few modules being imported and not used). | |
4817 |
|
4834 | |||
4818 | * Implemented the new ultraTB functionality into IPython. New |
|
4835 | * Implemented the new ultraTB functionality into IPython. New | |
4819 | option: xcolors. This chooses color scheme. xmode now only selects |
|
4836 | option: xcolors. This chooses color scheme. xmode now only selects | |
4820 | between Plain and Verbose. Better orthogonality. |
|
4837 | between Plain and Verbose. Better orthogonality. | |
4821 |
|
4838 | |||
4822 | * Large rewrite of ultraTB. Much cleaner now, with a separation of |
|
4839 | * Large rewrite of ultraTB. Much cleaner now, with a separation of | |
4823 | mode and color scheme for the exception handlers. Now it's |
|
4840 | mode and color scheme for the exception handlers. Now it's | |
4824 | possible to have the verbose traceback with no coloring. |
|
4841 | possible to have the verbose traceback with no coloring. | |
4825 |
|
4842 | |||
4826 | 2001-11-23 Fernando Perez <fperez@colorado.edu> |
|
4843 | 2001-11-23 Fernando Perez <fperez@colorado.edu> | |
4827 |
|
4844 | |||
4828 | * Version 0.1.12 released, 0.1.13 opened. |
|
4845 | * Version 0.1.12 released, 0.1.13 opened. | |
4829 |
|
4846 | |||
4830 | * Removed option to set auto-quote and auto-paren escapes by |
|
4847 | * Removed option to set auto-quote and auto-paren escapes by | |
4831 | user. The chances of breaking valid syntax are just too high. If |
|
4848 | user. The chances of breaking valid syntax are just too high. If | |
4832 | someone *really* wants, they can always dig into the code. |
|
4849 | someone *really* wants, they can always dig into the code. | |
4833 |
|
4850 | |||
4834 | * Made prompt separators configurable. |
|
4851 | * Made prompt separators configurable. | |
4835 |
|
4852 | |||
4836 | 2001-11-22 Fernando Perez <fperez@colorado.edu> |
|
4853 | 2001-11-22 Fernando Perez <fperez@colorado.edu> | |
4837 |
|
4854 | |||
4838 | * Small bugfixes in many places. |
|
4855 | * Small bugfixes in many places. | |
4839 |
|
4856 | |||
4840 | * Removed the MyCompleter class from ipplib. It seemed redundant |
|
4857 | * Removed the MyCompleter class from ipplib. It seemed redundant | |
4841 | with the C-p,C-n history search functionality. Less code to |
|
4858 | with the C-p,C-n history search functionality. Less code to | |
4842 | maintain. |
|
4859 | maintain. | |
4843 |
|
4860 | |||
4844 | * Moved all the original ipython.py code into ipythonlib.py. Right |
|
4861 | * Moved all the original ipython.py code into ipythonlib.py. Right | |
4845 | now it's just one big dump into a function called make_IPython, so |
|
4862 | now it's just one big dump into a function called make_IPython, so | |
4846 | no real modularity has been gained. But at least it makes the |
|
4863 | no real modularity has been gained. But at least it makes the | |
4847 | wrapper script tiny, and since ipythonlib is a module, it gets |
|
4864 | wrapper script tiny, and since ipythonlib is a module, it gets | |
4848 | compiled and startup is much faster. |
|
4865 | compiled and startup is much faster. | |
4849 |
|
4866 | |||
4850 | This is a reasobably 'deep' change, so we should test it for a |
|
4867 | This is a reasobably 'deep' change, so we should test it for a | |
4851 | while without messing too much more with the code. |
|
4868 | while without messing too much more with the code. | |
4852 |
|
4869 | |||
4853 | 2001-11-21 Fernando Perez <fperez@colorado.edu> |
|
4870 | 2001-11-21 Fernando Perez <fperez@colorado.edu> | |
4854 |
|
4871 | |||
4855 | * Version 0.1.11 released, 0.1.12 opened for further work. |
|
4872 | * Version 0.1.11 released, 0.1.12 opened for further work. | |
4856 |
|
4873 | |||
4857 | * Removed dependency on Itpl. It was only needed in one place. It |
|
4874 | * Removed dependency on Itpl. It was only needed in one place. It | |
4858 | would be nice if this became part of python, though. It makes life |
|
4875 | would be nice if this became part of python, though. It makes life | |
4859 | *a lot* easier in some cases. |
|
4876 | *a lot* easier in some cases. | |
4860 |
|
4877 | |||
4861 | * Simplified the prefilter code a bit. Now all handlers are |
|
4878 | * Simplified the prefilter code a bit. Now all handlers are | |
4862 | expected to explicitly return a value (at least a blank string). |
|
4879 | expected to explicitly return a value (at least a blank string). | |
4863 |
|
4880 | |||
4864 | * Heavy edits in ipplib. Removed the help system altogether. Now |
|
4881 | * Heavy edits in ipplib. Removed the help system altogether. Now | |
4865 | obj?/?? is used for inspecting objects, a magic @doc prints |
|
4882 | obj?/?? is used for inspecting objects, a magic @doc prints | |
4866 | docstrings, and full-blown Python help is accessed via the 'help' |
|
4883 | docstrings, and full-blown Python help is accessed via the 'help' | |
4867 | keyword. This cleans up a lot of code (less to maintain) and does |
|
4884 | keyword. This cleans up a lot of code (less to maintain) and does | |
4868 | the job. Since 'help' is now a standard Python component, might as |
|
4885 | the job. Since 'help' is now a standard Python component, might as | |
4869 | well use it and remove duplicate functionality. |
|
4886 | well use it and remove duplicate functionality. | |
4870 |
|
4887 | |||
4871 | Also removed the option to use ipplib as a standalone program. By |
|
4888 | Also removed the option to use ipplib as a standalone program. By | |
4872 | now it's too dependent on other parts of IPython to function alone. |
|
4889 | now it's too dependent on other parts of IPython to function alone. | |
4873 |
|
4890 | |||
4874 | * Fixed bug in genutils.pager. It would crash if the pager was |
|
4891 | * Fixed bug in genutils.pager. It would crash if the pager was | |
4875 | exited immediately after opening (broken pipe). |
|
4892 | exited immediately after opening (broken pipe). | |
4876 |
|
4893 | |||
4877 | * Trimmed down the VerboseTB reporting a little. The header is |
|
4894 | * Trimmed down the VerboseTB reporting a little. The header is | |
4878 | much shorter now and the repeated exception arguments at the end |
|
4895 | much shorter now and the repeated exception arguments at the end | |
4879 | have been removed. For interactive use the old header seemed a bit |
|
4896 | have been removed. For interactive use the old header seemed a bit | |
4880 | excessive. |
|
4897 | excessive. | |
4881 |
|
4898 | |||
4882 | * Fixed small bug in output of @whos for variables with multi-word |
|
4899 | * Fixed small bug in output of @whos for variables with multi-word | |
4883 | types (only first word was displayed). |
|
4900 | types (only first word was displayed). | |
4884 |
|
4901 | |||
4885 | 2001-11-17 Fernando Perez <fperez@colorado.edu> |
|
4902 | 2001-11-17 Fernando Perez <fperez@colorado.edu> | |
4886 |
|
4903 | |||
4887 | * Version 0.1.10 released, 0.1.11 opened for further work. |
|
4904 | * Version 0.1.10 released, 0.1.11 opened for further work. | |
4888 |
|
4905 | |||
4889 | * Modified dirs and friends. dirs now *returns* the stack (not |
|
4906 | * Modified dirs and friends. dirs now *returns* the stack (not | |
4890 | prints), so one can manipulate it as a variable. Convenient to |
|
4907 | prints), so one can manipulate it as a variable. Convenient to | |
4891 | travel along many directories. |
|
4908 | travel along many directories. | |
4892 |
|
4909 | |||
4893 | * Fixed bug in magic_pdef: would only work with functions with |
|
4910 | * Fixed bug in magic_pdef: would only work with functions with | |
4894 | arguments with default values. |
|
4911 | arguments with default values. | |
4895 |
|
4912 | |||
4896 | 2001-11-14 Fernando Perez <fperez@colorado.edu> |
|
4913 | 2001-11-14 Fernando Perez <fperez@colorado.edu> | |
4897 |
|
4914 | |||
4898 | * Added the PhysicsInput stuff to dot_ipython so it ships as an |
|
4915 | * Added the PhysicsInput stuff to dot_ipython so it ships as an | |
4899 | example with IPython. Various other minor fixes and cleanups. |
|
4916 | example with IPython. Various other minor fixes and cleanups. | |
4900 |
|
4917 | |||
4901 | * Version 0.1.9 released, 0.1.10 opened for further work. |
|
4918 | * Version 0.1.9 released, 0.1.10 opened for further work. | |
4902 |
|
4919 | |||
4903 | * Added sys.path to the list of directories searched in the |
|
4920 | * Added sys.path to the list of directories searched in the | |
4904 | execfile= option. It used to be the current directory and the |
|
4921 | execfile= option. It used to be the current directory and the | |
4905 | user's IPYTHONDIR only. |
|
4922 | user's IPYTHONDIR only. | |
4906 |
|
4923 | |||
4907 | 2001-11-13 Fernando Perez <fperez@colorado.edu> |
|
4924 | 2001-11-13 Fernando Perez <fperez@colorado.edu> | |
4908 |
|
4925 | |||
4909 | * Reinstated the raw_input/prefilter separation that Janko had |
|
4926 | * Reinstated the raw_input/prefilter separation that Janko had | |
4910 | initially. This gives a more convenient setup for extending the |
|
4927 | initially. This gives a more convenient setup for extending the | |
4911 | pre-processor from the outside: raw_input always gets a string, |
|
4928 | pre-processor from the outside: raw_input always gets a string, | |
4912 | and prefilter has to process it. We can then redefine prefilter |
|
4929 | and prefilter has to process it. We can then redefine prefilter | |
4913 | from the outside and implement extensions for special |
|
4930 | from the outside and implement extensions for special | |
4914 | purposes. |
|
4931 | purposes. | |
4915 |
|
4932 | |||
4916 | Today I got one for inputting PhysicalQuantity objects |
|
4933 | Today I got one for inputting PhysicalQuantity objects | |
4917 | (from Scientific) without needing any function calls at |
|
4934 | (from Scientific) without needing any function calls at | |
4918 | all. Extremely convenient, and it's all done as a user-level |
|
4935 | all. Extremely convenient, and it's all done as a user-level | |
4919 | extension (no IPython code was touched). Now instead of: |
|
4936 | extension (no IPython code was touched). Now instead of: | |
4920 | a = PhysicalQuantity(4.2,'m/s**2') |
|
4937 | a = PhysicalQuantity(4.2,'m/s**2') | |
4921 | one can simply say |
|
4938 | one can simply say | |
4922 | a = 4.2 m/s**2 |
|
4939 | a = 4.2 m/s**2 | |
4923 | or even |
|
4940 | or even | |
4924 | a = 4.2 m/s^2 |
|
4941 | a = 4.2 m/s^2 | |
4925 |
|
4942 | |||
4926 | I use this, but it's also a proof of concept: IPython really is |
|
4943 | I use this, but it's also a proof of concept: IPython really is | |
4927 | fully user-extensible, even at the level of the parsing of the |
|
4944 | fully user-extensible, even at the level of the parsing of the | |
4928 | command line. It's not trivial, but it's perfectly doable. |
|
4945 | command line. It's not trivial, but it's perfectly doable. | |
4929 |
|
4946 | |||
4930 | * Added 'add_flip' method to inclusion conflict resolver. Fixes |
|
4947 | * Added 'add_flip' method to inclusion conflict resolver. Fixes | |
4931 | the problem of modules being loaded in the inverse order in which |
|
4948 | the problem of modules being loaded in the inverse order in which | |
4932 | they were defined in |
|
4949 | they were defined in | |
4933 |
|
4950 | |||
4934 | * Version 0.1.8 released, 0.1.9 opened for further work. |
|
4951 | * Version 0.1.8 released, 0.1.9 opened for further work. | |
4935 |
|
4952 | |||
4936 | * Added magics pdef, source and file. They respectively show the |
|
4953 | * Added magics pdef, source and file. They respectively show the | |
4937 | definition line ('prototype' in C), source code and full python |
|
4954 | definition line ('prototype' in C), source code and full python | |
4938 | file for any callable object. The object inspector oinfo uses |
|
4955 | file for any callable object. The object inspector oinfo uses | |
4939 | these to show the same information. |
|
4956 | these to show the same information. | |
4940 |
|
4957 | |||
4941 | * Version 0.1.7 released, 0.1.8 opened for further work. |
|
4958 | * Version 0.1.7 released, 0.1.8 opened for further work. | |
4942 |
|
4959 | |||
4943 | * Separated all the magic functions into a class called Magic. The |
|
4960 | * Separated all the magic functions into a class called Magic. The | |
4944 | InteractiveShell class was becoming too big for Xemacs to handle |
|
4961 | InteractiveShell class was becoming too big for Xemacs to handle | |
4945 | (de-indenting a line would lock it up for 10 seconds while it |
|
4962 | (de-indenting a line would lock it up for 10 seconds while it | |
4946 | backtracked on the whole class!) |
|
4963 | backtracked on the whole class!) | |
4947 |
|
4964 | |||
4948 | FIXME: didn't work. It can be done, but right now namespaces are |
|
4965 | FIXME: didn't work. It can be done, but right now namespaces are | |
4949 | all messed up. Do it later (reverted it for now, so at least |
|
4966 | all messed up. Do it later (reverted it for now, so at least | |
4950 | everything works as before). |
|
4967 | everything works as before). | |
4951 |
|
4968 | |||
4952 | * Got the object introspection system (magic_oinfo) working! I |
|
4969 | * Got the object introspection system (magic_oinfo) working! I | |
4953 | think this is pretty much ready for release to Janko, so he can |
|
4970 | think this is pretty much ready for release to Janko, so he can | |
4954 | test it for a while and then announce it. Pretty much 100% of what |
|
4971 | test it for a while and then announce it. Pretty much 100% of what | |
4955 | I wanted for the 'phase 1' release is ready. Happy, tired. |
|
4972 | I wanted for the 'phase 1' release is ready. Happy, tired. | |
4956 |
|
4973 | |||
4957 | 2001-11-12 Fernando Perez <fperez@colorado.edu> |
|
4974 | 2001-11-12 Fernando Perez <fperez@colorado.edu> | |
4958 |
|
4975 | |||
4959 | * Version 0.1.6 released, 0.1.7 opened for further work. |
|
4976 | * Version 0.1.6 released, 0.1.7 opened for further work. | |
4960 |
|
4977 | |||
4961 | * Fixed bug in printing: it used to test for truth before |
|
4978 | * Fixed bug in printing: it used to test for truth before | |
4962 | printing, so 0 wouldn't print. Now checks for None. |
|
4979 | printing, so 0 wouldn't print. Now checks for None. | |
4963 |
|
4980 | |||
4964 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c |
|
4981 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c | |
4965 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it |
|
4982 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it | |
4966 | reaches by hand into the outputcache. Think of a better way to do |
|
4983 | reaches by hand into the outputcache. Think of a better way to do | |
4967 | this later. |
|
4984 | this later. | |
4968 |
|
4985 | |||
4969 | * Various small fixes thanks to Nathan's comments. |
|
4986 | * Various small fixes thanks to Nathan's comments. | |
4970 |
|
4987 | |||
4971 | * Changed magic_pprint to magic_Pprint. This way it doesn't |
|
4988 | * Changed magic_pprint to magic_Pprint. This way it doesn't | |
4972 | collide with pprint() and the name is consistent with the command |
|
4989 | collide with pprint() and the name is consistent with the command | |
4973 | line option. |
|
4990 | line option. | |
4974 |
|
4991 | |||
4975 | * Changed prompt counter behavior to be fully like |
|
4992 | * Changed prompt counter behavior to be fully like | |
4976 | Mathematica's. That is, even input that doesn't return a result |
|
4993 | Mathematica's. That is, even input that doesn't return a result | |
4977 | raises the prompt counter. The old behavior was kind of confusing |
|
4994 | raises the prompt counter. The old behavior was kind of confusing | |
4978 | (getting the same prompt number several times if the operation |
|
4995 | (getting the same prompt number several times if the operation | |
4979 | didn't return a result). |
|
4996 | didn't return a result). | |
4980 |
|
4997 | |||
4981 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). |
|
4998 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). | |
4982 |
|
4999 | |||
4983 | * Fixed -Classic mode (wasn't working anymore). |
|
5000 | * Fixed -Classic mode (wasn't working anymore). | |
4984 |
|
5001 | |||
4985 | * Added colored prompts using Nathan's new code. Colors are |
|
5002 | * Added colored prompts using Nathan's new code. Colors are | |
4986 | currently hardwired, they can be user-configurable. For |
|
5003 | currently hardwired, they can be user-configurable. For | |
4987 | developers, they can be chosen in file ipythonlib.py, at the |
|
5004 | developers, they can be chosen in file ipythonlib.py, at the | |
4988 | beginning of the CachedOutput class def. |
|
5005 | beginning of the CachedOutput class def. | |
4989 |
|
5006 | |||
4990 | 2001-11-11 Fernando Perez <fperez@colorado.edu> |
|
5007 | 2001-11-11 Fernando Perez <fperez@colorado.edu> | |
4991 |
|
5008 | |||
4992 | * Version 0.1.5 released, 0.1.6 opened for further work. |
|
5009 | * Version 0.1.5 released, 0.1.6 opened for further work. | |
4993 |
|
5010 | |||
4994 | * Changed magic_env to *return* the environment as a dict (not to |
|
5011 | * Changed magic_env to *return* the environment as a dict (not to | |
4995 | print it). This way it prints, but it can also be processed. |
|
5012 | print it). This way it prints, but it can also be processed. | |
4996 |
|
5013 | |||
4997 | * Added Verbose exception reporting to interactive |
|
5014 | * Added Verbose exception reporting to interactive | |
4998 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose |
|
5015 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose | |
4999 | traceback. Had to make some changes to the ultraTB file. This is |
|
5016 | traceback. Had to make some changes to the ultraTB file. This is | |
5000 | probably the last 'big' thing in my mental todo list. This ties |
|
5017 | probably the last 'big' thing in my mental todo list. This ties | |
5001 | in with the next entry: |
|
5018 | in with the next entry: | |
5002 |
|
5019 | |||
5003 | * Changed -Xi and -Xf to a single -xmode option. Now all the user |
|
5020 | * Changed -Xi and -Xf to a single -xmode option. Now all the user | |
5004 | has to specify is Plain, Color or Verbose for all exception |
|
5021 | has to specify is Plain, Color or Verbose for all exception | |
5005 | handling. |
|
5022 | handling. | |
5006 |
|
5023 | |||
5007 | * Removed ShellServices option. All this can really be done via |
|
5024 | * Removed ShellServices option. All this can really be done via | |
5008 | the magic system. It's easier to extend, cleaner and has automatic |
|
5025 | the magic system. It's easier to extend, cleaner and has automatic | |
5009 | namespace protection and documentation. |
|
5026 | namespace protection and documentation. | |
5010 |
|
5027 | |||
5011 | 2001-11-09 Fernando Perez <fperez@colorado.edu> |
|
5028 | 2001-11-09 Fernando Perez <fperez@colorado.edu> | |
5012 |
|
5029 | |||
5013 | * Fixed bug in output cache flushing (missing parameter to |
|
5030 | * Fixed bug in output cache flushing (missing parameter to | |
5014 | __init__). Other small bugs fixed (found using pychecker). |
|
5031 | __init__). Other small bugs fixed (found using pychecker). | |
5015 |
|
5032 | |||
5016 | * Version 0.1.4 opened for bugfixing. |
|
5033 | * Version 0.1.4 opened for bugfixing. | |
5017 |
|
5034 | |||
5018 | 2001-11-07 Fernando Perez <fperez@colorado.edu> |
|
5035 | 2001-11-07 Fernando Perez <fperez@colorado.edu> | |
5019 |
|
5036 | |||
5020 | * Version 0.1.3 released, mainly because of the raw_input bug. |
|
5037 | * Version 0.1.3 released, mainly because of the raw_input bug. | |
5021 |
|
5038 | |||
5022 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed |
|
5039 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed | |
5023 | and when testing for whether things were callable, a call could |
|
5040 | and when testing for whether things were callable, a call could | |
5024 | actually be made to certain functions. They would get called again |
|
5041 | actually be made to certain functions. They would get called again | |
5025 | once 'really' executed, with a resulting double call. A disaster |
|
5042 | once 'really' executed, with a resulting double call. A disaster | |
5026 | in many cases (list.reverse() would never work!). |
|
5043 | in many cases (list.reverse() would never work!). | |
5027 |
|
5044 | |||
5028 | * Removed prefilter() function, moved its code to raw_input (which |
|
5045 | * Removed prefilter() function, moved its code to raw_input (which | |
5029 | after all was just a near-empty caller for prefilter). This saves |
|
5046 | after all was just a near-empty caller for prefilter). This saves | |
5030 | a function call on every prompt, and simplifies the class a tiny bit. |
|
5047 | a function call on every prompt, and simplifies the class a tiny bit. | |
5031 |
|
5048 | |||
5032 | * Fix _ip to __ip name in magic example file. |
|
5049 | * Fix _ip to __ip name in magic example file. | |
5033 |
|
5050 | |||
5034 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should |
|
5051 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should | |
5035 | work with non-gnu versions of tar. |
|
5052 | work with non-gnu versions of tar. | |
5036 |
|
5053 | |||
5037 | 2001-11-06 Fernando Perez <fperez@colorado.edu> |
|
5054 | 2001-11-06 Fernando Perez <fperez@colorado.edu> | |
5038 |
|
5055 | |||
5039 | * Version 0.1.2. Just to keep track of the recent changes. |
|
5056 | * Version 0.1.2. Just to keep track of the recent changes. | |
5040 |
|
5057 | |||
5041 | * Fixed nasty bug in output prompt routine. It used to check 'if |
|
5058 | * Fixed nasty bug in output prompt routine. It used to check 'if | |
5042 | arg != None...'. Problem is, this fails if arg implements a |
|
5059 | arg != None...'. Problem is, this fails if arg implements a | |
5043 | special comparison (__cmp__) which disallows comparing to |
|
5060 | special comparison (__cmp__) which disallows comparing to | |
5044 | None. Found it when trying to use the PhysicalQuantity module from |
|
5061 | None. Found it when trying to use the PhysicalQuantity module from | |
5045 | ScientificPython. |
|
5062 | ScientificPython. | |
5046 |
|
5063 | |||
5047 | 2001-11-05 Fernando Perez <fperez@colorado.edu> |
|
5064 | 2001-11-05 Fernando Perez <fperez@colorado.edu> | |
5048 |
|
5065 | |||
5049 | * Also added dirs. Now the pushd/popd/dirs family functions |
|
5066 | * Also added dirs. Now the pushd/popd/dirs family functions | |
5050 | basically like the shell, with the added convenience of going home |
|
5067 | basically like the shell, with the added convenience of going home | |
5051 | when called with no args. |
|
5068 | when called with no args. | |
5052 |
|
5069 | |||
5053 | * pushd/popd slightly modified to mimic shell behavior more |
|
5070 | * pushd/popd slightly modified to mimic shell behavior more | |
5054 | closely. |
|
5071 | closely. | |
5055 |
|
5072 | |||
5056 | * Added env,pushd,popd from ShellServices as magic functions. I |
|
5073 | * Added env,pushd,popd from ShellServices as magic functions. I | |
5057 | think the cleanest will be to port all desired functions from |
|
5074 | think the cleanest will be to port all desired functions from | |
5058 | ShellServices as magics and remove ShellServices altogether. This |
|
5075 | ShellServices as magics and remove ShellServices altogether. This | |
5059 | will provide a single, clean way of adding functionality |
|
5076 | will provide a single, clean way of adding functionality | |
5060 | (shell-type or otherwise) to IP. |
|
5077 | (shell-type or otherwise) to IP. | |
5061 |
|
5078 | |||
5062 | 2001-11-04 Fernando Perez <fperez@colorado.edu> |
|
5079 | 2001-11-04 Fernando Perez <fperez@colorado.edu> | |
5063 |
|
5080 | |||
5064 | * Added .ipython/ directory to sys.path. This way users can keep |
|
5081 | * Added .ipython/ directory to sys.path. This way users can keep | |
5065 | customizations there and access them via import. |
|
5082 | customizations there and access them via import. | |
5066 |
|
5083 | |||
5067 | 2001-11-03 Fernando Perez <fperez@colorado.edu> |
|
5084 | 2001-11-03 Fernando Perez <fperez@colorado.edu> | |
5068 |
|
5085 | |||
5069 | * Opened version 0.1.1 for new changes. |
|
5086 | * Opened version 0.1.1 for new changes. | |
5070 |
|
5087 | |||
5071 | * Changed version number to 0.1.0: first 'public' release, sent to |
|
5088 | * Changed version number to 0.1.0: first 'public' release, sent to | |
5072 | Nathan and Janko. |
|
5089 | Nathan and Janko. | |
5073 |
|
5090 | |||
5074 | * Lots of small fixes and tweaks. |
|
5091 | * Lots of small fixes and tweaks. | |
5075 |
|
5092 | |||
5076 | * Minor changes to whos format. Now strings are shown, snipped if |
|
5093 | * Minor changes to whos format. Now strings are shown, snipped if | |
5077 | too long. |
|
5094 | too long. | |
5078 |
|
5095 | |||
5079 | * Changed ShellServices to work on __main__ so they show up in @who |
|
5096 | * Changed ShellServices to work on __main__ so they show up in @who | |
5080 |
|
5097 | |||
5081 | * Help also works with ? at the end of a line: |
|
5098 | * Help also works with ? at the end of a line: | |
5082 | ?sin and sin? |
|
5099 | ?sin and sin? | |
5083 | both produce the same effect. This is nice, as often I use the |
|
5100 | both produce the same effect. This is nice, as often I use the | |
5084 | tab-complete to find the name of a method, but I used to then have |
|
5101 | tab-complete to find the name of a method, but I used to then have | |
5085 | to go to the beginning of the line to put a ? if I wanted more |
|
5102 | to go to the beginning of the line to put a ? if I wanted more | |
5086 | info. Now I can just add the ? and hit return. Convenient. |
|
5103 | info. Now I can just add the ? and hit return. Convenient. | |
5087 |
|
5104 | |||
5088 | 2001-11-02 Fernando Perez <fperez@colorado.edu> |
|
5105 | 2001-11-02 Fernando Perez <fperez@colorado.edu> | |
5089 |
|
5106 | |||
5090 | * Python version check (>=2.1) added. |
|
5107 | * Python version check (>=2.1) added. | |
5091 |
|
5108 | |||
5092 | * Added LazyPython documentation. At this point the docs are quite |
|
5109 | * Added LazyPython documentation. At this point the docs are quite | |
5093 | a mess. A cleanup is in order. |
|
5110 | a mess. A cleanup is in order. | |
5094 |
|
5111 | |||
5095 | * Auto-installer created. For some bizarre reason, the zipfiles |
|
5112 | * Auto-installer created. For some bizarre reason, the zipfiles | |
5096 | module isn't working on my system. So I made a tar version |
|
5113 | module isn't working on my system. So I made a tar version | |
5097 | (hopefully the command line options in various systems won't kill |
|
5114 | (hopefully the command line options in various systems won't kill | |
5098 | me). |
|
5115 | me). | |
5099 |
|
5116 | |||
5100 | * Fixes to Struct in genutils. Now all dictionary-like methods are |
|
5117 | * Fixes to Struct in genutils. Now all dictionary-like methods are | |
5101 | protected (reasonably). |
|
5118 | protected (reasonably). | |
5102 |
|
5119 | |||
5103 | * Added pager function to genutils and changed ? to print usage |
|
5120 | * Added pager function to genutils and changed ? to print usage | |
5104 | note through it (it was too long). |
|
5121 | note through it (it was too long). | |
5105 |
|
5122 | |||
5106 | * Added the LazyPython functionality. Works great! I changed the |
|
5123 | * Added the LazyPython functionality. Works great! I changed the | |
5107 | auto-quote escape to ';', it's on home row and next to '. But |
|
5124 | auto-quote escape to ';', it's on home row and next to '. But | |
5108 | both auto-quote and auto-paren (still /) escapes are command-line |
|
5125 | both auto-quote and auto-paren (still /) escapes are command-line | |
5109 | parameters. |
|
5126 | parameters. | |
5110 |
|
5127 | |||
5111 |
|
5128 | |||
5112 | 2001-11-01 Fernando Perez <fperez@colorado.edu> |
|
5129 | 2001-11-01 Fernando Perez <fperez@colorado.edu> | |
5113 |
|
5130 | |||
5114 | * Version changed to 0.0.7. Fairly large change: configuration now |
|
5131 | * Version changed to 0.0.7. Fairly large change: configuration now | |
5115 | is all stored in a directory, by default .ipython. There, all |
|
5132 | is all stored in a directory, by default .ipython. There, all | |
5116 | config files have normal looking names (not .names) |
|
5133 | config files have normal looking names (not .names) | |
5117 |
|
5134 | |||
5118 | * Version 0.0.6 Released first to Lucas and Archie as a test |
|
5135 | * Version 0.0.6 Released first to Lucas and Archie as a test | |
5119 | run. Since it's the first 'semi-public' release, change version to |
|
5136 | run. Since it's the first 'semi-public' release, change version to | |
5120 | > 0.0.6 for any changes now. |
|
5137 | > 0.0.6 for any changes now. | |
5121 |
|
5138 | |||
5122 | * Stuff I had put in the ipplib.py changelog: |
|
5139 | * Stuff I had put in the ipplib.py changelog: | |
5123 |
|
5140 | |||
5124 | Changes to InteractiveShell: |
|
5141 | Changes to InteractiveShell: | |
5125 |
|
5142 | |||
5126 | - Made the usage message a parameter. |
|
5143 | - Made the usage message a parameter. | |
5127 |
|
5144 | |||
5128 | - Require the name of the shell variable to be given. It's a bit |
|
5145 | - Require the name of the shell variable to be given. It's a bit | |
5129 | of a hack, but allows the name 'shell' not to be hardwire in the |
|
5146 | of a hack, but allows the name 'shell' not to be hardwire in the | |
5130 | magic (@) handler, which is problematic b/c it requires |
|
5147 | magic (@) handler, which is problematic b/c it requires | |
5131 | polluting the global namespace with 'shell'. This in turn is |
|
5148 | polluting the global namespace with 'shell'. This in turn is | |
5132 | fragile: if a user redefines a variable called shell, things |
|
5149 | fragile: if a user redefines a variable called shell, things | |
5133 | break. |
|
5150 | break. | |
5134 |
|
5151 | |||
5135 | - magic @: all functions available through @ need to be defined |
|
5152 | - magic @: all functions available through @ need to be defined | |
5136 | as magic_<name>, even though they can be called simply as |
|
5153 | as magic_<name>, even though they can be called simply as | |
5137 | @<name>. This allows the special command @magic to gather |
|
5154 | @<name>. This allows the special command @magic to gather | |
5138 | information automatically about all existing magic functions, |
|
5155 | information automatically about all existing magic functions, | |
5139 | even if they are run-time user extensions, by parsing the shell |
|
5156 | even if they are run-time user extensions, by parsing the shell | |
5140 | instance __dict__ looking for special magic_ names. |
|
5157 | instance __dict__ looking for special magic_ names. | |
5141 |
|
5158 | |||
5142 | - mainloop: added *two* local namespace parameters. This allows |
|
5159 | - mainloop: added *two* local namespace parameters. This allows | |
5143 | the class to differentiate between parameters which were there |
|
5160 | the class to differentiate between parameters which were there | |
5144 | before and after command line initialization was processed. This |
|
5161 | before and after command line initialization was processed. This | |
5145 | way, later @who can show things loaded at startup by the |
|
5162 | way, later @who can show things loaded at startup by the | |
5146 | user. This trick was necessary to make session saving/reloading |
|
5163 | user. This trick was necessary to make session saving/reloading | |
5147 | really work: ideally after saving/exiting/reloading a session, |
|
5164 | really work: ideally after saving/exiting/reloading a session, | |
5148 | *everythin* should look the same, including the output of @who. I |
|
5165 | *everythin* should look the same, including the output of @who. I | |
5149 | was only able to make this work with this double namespace |
|
5166 | was only able to make this work with this double namespace | |
5150 | trick. |
|
5167 | trick. | |
5151 |
|
5168 | |||
5152 | - added a header to the logfile which allows (almost) full |
|
5169 | - added a header to the logfile which allows (almost) full | |
5153 | session restoring. |
|
5170 | session restoring. | |
5154 |
|
5171 | |||
5155 | - prepend lines beginning with @ or !, with a and log |
|
5172 | - prepend lines beginning with @ or !, with a and log | |
5156 | them. Why? !lines: may be useful to know what you did @lines: |
|
5173 | them. Why? !lines: may be useful to know what you did @lines: | |
5157 | they may affect session state. So when restoring a session, at |
|
5174 | they may affect session state. So when restoring a session, at | |
5158 | least inform the user of their presence. I couldn't quite get |
|
5175 | least inform the user of their presence. I couldn't quite get | |
5159 | them to properly re-execute, but at least the user is warned. |
|
5176 | them to properly re-execute, but at least the user is warned. | |
5160 |
|
5177 | |||
5161 | * Started ChangeLog. |
|
5178 | * Started ChangeLog. |
General Comments 0
You need to be logged in to leave comments.
Login now