Show More
@@ -1,2592 +1,2620 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 96 |
|
4 | $Id: Magic.py 965 2005-12-28 23:23:09Z 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-2004 Fernando Perez <fperez@colorado.edu> |
|
8 | # Copyright (C) 2001-2004 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 | from cStringIO import StringIO |
|
33 | from cStringIO import StringIO | |
34 | from getopt import getopt |
|
34 | from getopt import getopt | |
35 | from pprint import pprint, pformat |
|
35 | from pprint import pprint, pformat | |
36 |
|
36 | |||
37 | # profile isn't bundled by default in Debian for license reasons |
|
37 | # profile isn't bundled by default in Debian for license reasons | |
38 | try: |
|
38 | try: | |
39 | import profile,pstats |
|
39 | import profile,pstats | |
40 | except ImportError: |
|
40 | except ImportError: | |
41 | profile = pstats = None |
|
41 | profile = pstats = None | |
42 |
|
42 | |||
43 | # Homebrewed |
|
43 | # Homebrewed | |
44 | from IPython import Debugger, OInspect, wildcard |
|
44 | from IPython import Debugger, OInspect, wildcard | |
45 | from IPython.FakeModule import FakeModule |
|
45 | from IPython.FakeModule import FakeModule | |
46 | from IPython.Itpl import Itpl, itpl, printpl,itplns |
|
46 | from IPython.Itpl import Itpl, itpl, printpl,itplns | |
47 | from IPython.PyColorize import Parser |
|
47 | from IPython.PyColorize import Parser | |
48 | from IPython.Struct import Struct |
|
48 | from IPython.Struct import Struct | |
49 | from IPython.genutils import * |
|
49 | from IPython.genutils import * | |
50 |
|
50 | |||
51 | # Globals to be set later by Magic constructor |
|
51 | # Globals to be set later by Magic constructor | |
52 | MAGIC_PREFIX = '' |
|
52 | MAGIC_PREFIX = '' | |
53 | MAGIC_ESCAPE = '' |
|
53 | MAGIC_ESCAPE = '' | |
54 |
|
54 | |||
55 | #*************************************************************************** |
|
55 | #*************************************************************************** | |
56 | # Utility functions |
|
56 | # Utility functions | |
57 | def magic2python(cmd): |
|
57 | def magic2python(cmd): | |
58 | """Convert a command string of magic syntax to valid Python code.""" |
|
58 | """Convert a command string of magic syntax to valid Python code.""" | |
59 |
|
59 | |||
60 | if cmd.startswith('#'+MAGIC_ESCAPE) or \ |
|
60 | if cmd.startswith('#'+MAGIC_ESCAPE) or \ | |
61 | cmd.startswith(MAGIC_ESCAPE): |
|
61 | cmd.startswith(MAGIC_ESCAPE): | |
62 | if cmd[0]=='#': |
|
62 | if cmd[0]=='#': | |
63 | cmd = cmd[1:] |
|
63 | cmd = cmd[1:] | |
64 | # we need to return the proper line end later |
|
64 | # we need to return the proper line end later | |
65 | if cmd[-1] == '\n': |
|
65 | if cmd[-1] == '\n': | |
66 | endl = '\n' |
|
66 | endl = '\n' | |
67 | else: |
|
67 | else: | |
68 | endl = '' |
|
68 | endl = '' | |
69 | try: |
|
69 | try: | |
70 | func,args = cmd[1:].split(' ',1) |
|
70 | func,args = cmd[1:].split(' ',1) | |
71 | except: |
|
71 | except: | |
72 | func,args = cmd[1:].rstrip(),'' |
|
72 | func,args = cmd[1:].rstrip(),'' | |
73 | args = args.replace('"','\\"').replace("'","\\'").rstrip() |
|
73 | args = args.replace('"','\\"').replace("'","\\'").rstrip() | |
74 | return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl) |
|
74 | return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl) | |
75 | else: |
|
75 | else: | |
76 | return cmd |
|
76 | return cmd | |
77 |
|
77 | |||
78 | def on_off(tag): |
|
78 | def on_off(tag): | |
79 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" |
|
79 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" | |
80 | return ['OFF','ON'][tag] |
|
80 | return ['OFF','ON'][tag] | |
81 |
|
81 | |||
82 |
|
82 | |||
83 | #**************************************************************************** |
|
83 | #**************************************************************************** | |
84 | # Utility classes |
|
84 | # Utility classes | |
85 | class Macro: |
|
85 | class Macro: | |
86 | """Simple class to store the value of macros as strings. |
|
86 | """Simple class to store the value of macros as strings. | |
87 |
|
87 | |||
88 | This allows us to later exec them by checking when something is an |
|
88 | This allows us to later exec them by checking when something is an | |
89 | instance of this class.""" |
|
89 | instance of this class.""" | |
90 |
|
90 | |||
91 | def __init__(self,cmds): |
|
91 | def __init__(self,cmds): | |
92 | """Build a macro from a list of commands.""" |
|
92 | """Build a macro from a list of commands.""" | |
93 |
|
93 | |||
94 | # Since the list may include multi-line entries, first make sure that |
|
94 | # Since the list may include multi-line entries, first make sure that | |
95 | # they've been all broken up before passing it to magic2python |
|
95 | # they've been all broken up before passing it to magic2python | |
96 | cmdlist = map(magic2python,''.join(cmds).split('\n')) |
|
96 | cmdlist = map(magic2python,''.join(cmds).split('\n')) | |
97 | self.value = '\n'.join(cmdlist) |
|
97 | self.value = '\n'.join(cmdlist) | |
98 |
|
98 | |||
99 | def __str__(self): |
|
99 | def __str__(self): | |
100 | return self.value |
|
100 | return self.value | |
101 |
|
101 | |||
102 | #*************************************************************************** |
|
102 | #*************************************************************************** | |
103 | # Main class implementing Magic functionality |
|
103 | # Main class implementing Magic functionality | |
104 | class Magic: |
|
104 | class Magic: | |
105 | """Magic functions for InteractiveShell. |
|
105 | """Magic functions for InteractiveShell. | |
106 |
|
106 | |||
107 | Shell functions which can be reached as %function_name. All magic |
|
107 | Shell functions which can be reached as %function_name. All magic | |
108 | functions should accept a string, which they can parse for their own |
|
108 | functions should accept a string, which they can parse for their own | |
109 | needs. This can make some functions easier to type, eg `%cd ../` |
|
109 | needs. This can make some functions easier to type, eg `%cd ../` | |
110 | vs. `%cd("../")` |
|
110 | vs. `%cd("../")` | |
111 |
|
111 | |||
112 | ALL definitions MUST begin with the prefix magic_. The user won't need it |
|
112 | ALL definitions MUST begin with the prefix magic_. The user won't need it | |
113 | at the command line, but it is is needed in the definition. """ |
|
113 | at the command line, but it is is needed in the definition. """ | |
114 |
|
114 | |||
115 | # class globals |
|
115 | # class globals | |
116 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', |
|
116 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', | |
117 | 'Automagic is ON, % prefix NOT needed for magic functions.'] |
|
117 | 'Automagic is ON, % prefix NOT needed for magic functions.'] | |
118 |
|
118 | |||
119 | #...................................................................... |
|
119 | #...................................................................... | |
120 | # some utility functions |
|
120 | # some utility functions | |
121 |
|
121 | |||
122 | def __init__(self,shell): |
|
122 | def __init__(self,shell): | |
123 | # XXX This is hackish, clean up later to avoid these messy globals |
|
123 | # XXX This is hackish, clean up later to avoid these messy globals | |
124 | global MAGIC_PREFIX, MAGIC_ESCAPE |
|
124 | global MAGIC_PREFIX, MAGIC_ESCAPE | |
125 |
|
125 | |||
126 | self.options_table = {} |
|
126 | self.options_table = {} | |
127 | MAGIC_PREFIX = shell.name+'.magic_' |
|
127 | MAGIC_PREFIX = shell.name+'.magic_' | |
128 | MAGIC_ESCAPE = shell.ESC_MAGIC |
|
128 | MAGIC_ESCAPE = shell.ESC_MAGIC | |
129 | if profile is None: |
|
129 | if profile is None: | |
130 | self.magic_prun = self.profile_missing_notice |
|
130 | self.magic_prun = self.profile_missing_notice | |
131 |
|
131 | |||
132 | def profile_missing_notice(self, *args, **kwargs): |
|
132 | def profile_missing_notice(self, *args, **kwargs): | |
133 | error("""\ |
|
133 | error("""\ | |
134 | The profile module could not be found. If you are a Debian user, |
|
134 | The profile module could not be found. If you are a Debian user, | |
135 | it has been removed from the standard Debian package because of its non-free |
|
135 | it has been removed from the standard Debian package because of its non-free | |
136 | license. To use profiling, please install"python2.3-profiler" from non-free.""") |
|
136 | license. To use profiling, please install"python2.3-profiler" from non-free.""") | |
137 |
|
137 | |||
138 | def default_option(self,fn,optstr): |
|
138 | def default_option(self,fn,optstr): | |
139 | """Make an entry in the options_table for fn, with value optstr""" |
|
139 | """Make an entry in the options_table for fn, with value optstr""" | |
140 |
|
140 | |||
141 | if fn not in self.lsmagic(): |
|
141 | if fn not in self.lsmagic(): | |
142 | error("%s is not a magic function" % fn) |
|
142 | error("%s is not a magic function" % fn) | |
143 | self.options_table[fn] = optstr |
|
143 | self.options_table[fn] = optstr | |
144 |
|
144 | |||
145 | def lsmagic(self): |
|
145 | def lsmagic(self): | |
146 | """Return a list of currently available magic functions. |
|
146 | """Return a list of currently available magic functions. | |
147 |
|
147 | |||
148 | Gives a list of the bare names after mangling (['ls','cd', ...], not |
|
148 | Gives a list of the bare names after mangling (['ls','cd', ...], not | |
149 | ['magic_ls','magic_cd',...]""" |
|
149 | ['magic_ls','magic_cd',...]""" | |
150 |
|
150 | |||
151 | # FIXME. This needs a cleanup, in the way the magics list is built. |
|
151 | # FIXME. This needs a cleanup, in the way the magics list is built. | |
152 |
|
152 | |||
153 | # magics in class definition |
|
153 | # magics in class definition | |
154 | class_magic = lambda fn: fn.startswith('magic_') and \ |
|
154 | class_magic = lambda fn: fn.startswith('magic_') and \ | |
155 | callable(Magic.__dict__[fn]) |
|
155 | callable(Magic.__dict__[fn]) | |
156 | # in instance namespace (run-time user additions) |
|
156 | # in instance namespace (run-time user additions) | |
157 | inst_magic = lambda fn: fn.startswith('magic_') and \ |
|
157 | inst_magic = lambda fn: fn.startswith('magic_') and \ | |
158 | callable(self.__dict__[fn]) |
|
158 | callable(self.__dict__[fn]) | |
159 | # and bound magics by user (so they can access self): |
|
159 | # and bound magics by user (so they can access self): | |
160 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ |
|
160 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ | |
161 | callable(self.__class__.__dict__[fn]) |
|
161 | callable(self.__class__.__dict__[fn]) | |
162 | magics = filter(class_magic,Magic.__dict__.keys()) + \ |
|
162 | magics = filter(class_magic,Magic.__dict__.keys()) + \ | |
163 | filter(inst_magic,self.__dict__.keys()) + \ |
|
163 | filter(inst_magic,self.__dict__.keys()) + \ | |
164 | filter(inst_bound_magic,self.__class__.__dict__.keys()) |
|
164 | filter(inst_bound_magic,self.__class__.__dict__.keys()) | |
165 | out = [] |
|
165 | out = [] | |
166 | for fn in magics: |
|
166 | for fn in magics: | |
167 | out.append(fn.replace('magic_','',1)) |
|
167 | out.append(fn.replace('magic_','',1)) | |
168 | out.sort() |
|
168 | out.sort() | |
169 | return out |
|
169 | return out | |
170 |
|
170 | |||
171 | def set_shell(self,shell): |
|
171 | def set_shell(self,shell): | |
172 | self.shell = shell |
|
172 | self.shell = shell | |
173 | self.alias_table = shell.alias_table |
|
173 | self.alias_table = shell.alias_table | |
174 |
|
174 | |||
175 | def extract_input_slices(self,slices): |
|
175 | def extract_input_slices(self,slices): | |
176 | """Return as a string a set of input history slices. |
|
176 | """Return as a string a set of input history slices. | |
177 |
|
177 | |||
178 | The set of slices is given as a list of strings (like ['1','4:8','9'], |
|
178 | The set of slices is given as a list of strings (like ['1','4:8','9'], | |
179 | since this function is for use by magic functions which get their |
|
179 | since this function is for use by magic functions which get their | |
180 | arguments as strings.""" |
|
180 | arguments as strings.""" | |
181 |
|
181 | |||
182 | cmds = [] |
|
182 | cmds = [] | |
183 | for chunk in slices: |
|
183 | for chunk in slices: | |
184 | if ':' in chunk: |
|
184 | if ':' in chunk: | |
185 | ini,fin = map(int,chunk.split(':')) |
|
185 | ini,fin = map(int,chunk.split(':')) | |
186 | else: |
|
186 | else: | |
187 | ini = int(chunk) |
|
187 | ini = int(chunk) | |
188 | fin = ini+1 |
|
188 | fin = ini+1 | |
189 | cmds.append(self.shell.input_hist[ini:fin]) |
|
189 | cmds.append(self.shell.input_hist[ini:fin]) | |
190 | return cmds |
|
190 | return cmds | |
191 |
|
191 | |||
192 | def _ofind(self,oname): |
|
192 | def _ofind(self,oname): | |
193 | """Find an object in the available namespaces. |
|
193 | """Find an object in the available namespaces. | |
194 |
|
194 | |||
195 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic |
|
195 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic | |
196 |
|
196 | |||
197 | Has special code to detect magic functions. |
|
197 | Has special code to detect magic functions. | |
198 | """ |
|
198 | """ | |
199 |
|
199 | |||
200 | oname = oname.strip() |
|
200 | oname = oname.strip() | |
201 |
|
201 | |||
202 | # Namespaces to search in: |
|
202 | # Namespaces to search in: | |
203 | user_ns = self.shell.user_ns |
|
203 | user_ns = self.shell.user_ns | |
204 | internal_ns = self.shell.internal_ns |
|
204 | internal_ns = self.shell.internal_ns | |
205 | builtin_ns = __builtin__.__dict__ |
|
205 | builtin_ns = __builtin__.__dict__ | |
206 | alias_ns = self.shell.alias_table |
|
206 | alias_ns = self.shell.alias_table | |
207 |
|
207 | |||
208 | # Put them in a list. The order is important so that we find things in |
|
208 | # Put them in a list. The order is important so that we find things in | |
209 | # the same order that Python finds them. |
|
209 | # the same order that Python finds them. | |
210 | namespaces = [ ('Interactive',user_ns), |
|
210 | namespaces = [ ('Interactive',user_ns), | |
211 | ('IPython internal',internal_ns), |
|
211 | ('IPython internal',internal_ns), | |
212 | ('Python builtin',builtin_ns), |
|
212 | ('Python builtin',builtin_ns), | |
213 | ('Alias',alias_ns), |
|
213 | ('Alias',alias_ns), | |
214 | ] |
|
214 | ] | |
215 |
|
215 | |||
216 | # initialize results to 'null' |
|
216 | # initialize results to 'null' | |
217 | found = 0; obj = None; ospace = None; ds = None; |
|
217 | found = 0; obj = None; ospace = None; ds = None; | |
218 | ismagic = 0; isalias = 0 |
|
218 | ismagic = 0; isalias = 0 | |
219 |
|
219 | |||
220 | # Look for the given name by splitting it in parts. If the head is |
|
220 | # Look for the given name by splitting it in parts. If the head is | |
221 | # found, then we look for all the remaining parts as members, and only |
|
221 | # found, then we look for all the remaining parts as members, and only | |
222 | # declare success if we can find them all. |
|
222 | # declare success if we can find them all. | |
223 | oname_parts = oname.split('.') |
|
223 | oname_parts = oname.split('.') | |
224 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] |
|
224 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] | |
225 | for nsname,ns in namespaces: |
|
225 | for nsname,ns in namespaces: | |
226 | try: |
|
226 | try: | |
227 | obj = ns[oname_head] |
|
227 | obj = ns[oname_head] | |
228 | except KeyError: |
|
228 | except KeyError: | |
229 | continue |
|
229 | continue | |
230 | else: |
|
230 | else: | |
231 | for part in oname_rest: |
|
231 | for part in oname_rest: | |
232 | try: |
|
232 | try: | |
233 | obj = getattr(obj,part) |
|
233 | obj = getattr(obj,part) | |
234 | except: |
|
234 | except: | |
235 | # Blanket except b/c some badly implemented objects |
|
235 | # Blanket except b/c some badly implemented objects | |
236 | # allow __getattr__ to raise exceptions other than |
|
236 | # allow __getattr__ to raise exceptions other than | |
237 | # AttributeError, which then crashes IPython. |
|
237 | # AttributeError, which then crashes IPython. | |
238 | break |
|
238 | break | |
239 | else: |
|
239 | else: | |
240 | # If we finish the for loop (no break), we got all members |
|
240 | # If we finish the for loop (no break), we got all members | |
241 | found = 1 |
|
241 | found = 1 | |
242 | ospace = nsname |
|
242 | ospace = nsname | |
243 | if ns == alias_ns: |
|
243 | if ns == alias_ns: | |
244 | isalias = 1 |
|
244 | isalias = 1 | |
245 | break # namespace loop |
|
245 | break # namespace loop | |
246 |
|
246 | |||
247 | # Try to see if it's magic |
|
247 | # Try to see if it's magic | |
248 | if not found: |
|
248 | if not found: | |
249 | if oname.startswith(self.shell.ESC_MAGIC): |
|
249 | if oname.startswith(self.shell.ESC_MAGIC): | |
250 | oname = oname[1:] |
|
250 | oname = oname[1:] | |
251 | obj = getattr(self,'magic_'+oname,None) |
|
251 | obj = getattr(self,'magic_'+oname,None) | |
252 | if obj is not None: |
|
252 | if obj is not None: | |
253 | found = 1 |
|
253 | found = 1 | |
254 | ospace = 'IPython internal' |
|
254 | ospace = 'IPython internal' | |
255 | ismagic = 1 |
|
255 | ismagic = 1 | |
256 |
|
256 | |||
257 | # Last try: special-case some literals like '', [], {}, etc: |
|
257 | # Last try: special-case some literals like '', [], {}, etc: | |
258 | if not found and oname_head in ["''",'""','[]','{}','()']: |
|
258 | if not found and oname_head in ["''",'""','[]','{}','()']: | |
259 | obj = eval(oname_head) |
|
259 | obj = eval(oname_head) | |
260 | found = 1 |
|
260 | found = 1 | |
261 | ospace = 'Interactive' |
|
261 | ospace = 'Interactive' | |
262 |
|
262 | |||
263 | return {'found':found, 'obj':obj, 'namespace':ospace, |
|
263 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
264 | 'ismagic':ismagic, 'isalias':isalias} |
|
264 | 'ismagic':ismagic, 'isalias':isalias} | |
265 |
|
265 | |||
266 | def arg_err(self,func): |
|
266 | def arg_err(self,func): | |
267 | """Print docstring if incorrect arguments were passed""" |
|
267 | """Print docstring if incorrect arguments were passed""" | |
268 | print 'Error in arguments:' |
|
268 | print 'Error in arguments:' | |
269 | print OInspect.getdoc(func) |
|
269 | print OInspect.getdoc(func) | |
270 |
|
270 | |||
271 |
|
271 | |||
272 | def format_latex(self,str): |
|
272 | def format_latex(self,str): | |
273 | """Format a string for latex inclusion.""" |
|
273 | """Format a string for latex inclusion.""" | |
274 |
|
274 | |||
275 | # Characters that need to be escaped for latex: |
|
275 | # Characters that need to be escaped for latex: | |
276 | escape_re = re.compile(r'(%|_|\$)',re.MULTILINE) |
|
276 | escape_re = re.compile(r'(%|_|\$)',re.MULTILINE) | |
277 | # Magic command names as headers: |
|
277 | # Magic command names as headers: | |
278 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, |
|
278 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, | |
279 | re.MULTILINE) |
|
279 | re.MULTILINE) | |
280 | # Magic commands |
|
280 | # Magic commands | |
281 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, |
|
281 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, | |
282 | re.MULTILINE) |
|
282 | re.MULTILINE) | |
283 | # Paragraph continue |
|
283 | # Paragraph continue | |
284 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
284 | par_re = re.compile(r'\\$',re.MULTILINE) | |
285 |
|
285 | |||
286 | str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str) |
|
286 | str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str) | |
287 | str = cmd_re.sub(r'\\texttt{\g<cmd>}',str) |
|
287 | str = cmd_re.sub(r'\\texttt{\g<cmd>}',str) | |
288 | str = par_re.sub(r'\\\\',str) |
|
288 | str = par_re.sub(r'\\\\',str) | |
289 | str = escape_re.sub(r'\\\1',str) |
|
289 | str = escape_re.sub(r'\\\1',str) | |
290 | return str |
|
290 | return str | |
291 |
|
291 | |||
292 | def format_screen(self,str): |
|
292 | def format_screen(self,str): | |
293 | """Format a string for screen printing. |
|
293 | """Format a string for screen printing. | |
294 |
|
294 | |||
295 | This removes some latex-type format codes.""" |
|
295 | This removes some latex-type format codes.""" | |
296 | # Paragraph continue |
|
296 | # Paragraph continue | |
297 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
297 | par_re = re.compile(r'\\$',re.MULTILINE) | |
298 | str = par_re.sub('',str) |
|
298 | str = par_re.sub('',str) | |
299 | return str |
|
299 | return str | |
300 |
|
300 | |||
301 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): |
|
301 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): | |
302 | """Parse options passed to an argument string. |
|
302 | """Parse options passed to an argument string. | |
303 |
|
303 | |||
304 | The interface is similar to that of getopt(), but it returns back a |
|
304 | The interface is similar to that of getopt(), but it returns back a | |
305 | Struct with the options as keys and the stripped argument string still |
|
305 | Struct with the options as keys and the stripped argument string still | |
306 | as a string. |
|
306 | as a string. | |
307 |
|
307 | |||
308 | arg_str is quoted as a true sys.argv vector by using shlex.split. |
|
308 | arg_str is quoted as a true sys.argv vector by using shlex.split. | |
309 | This allows us to easily expand variables, glob files, quote |
|
309 | This allows us to easily expand variables, glob files, quote | |
310 | arguments, etc. |
|
310 | arguments, etc. | |
311 |
|
311 | |||
312 | Options: |
|
312 | Options: | |
313 | -mode: default 'string'. If given as 'list', the argument string is |
|
313 | -mode: default 'string'. If given as 'list', the argument string is | |
314 | returned as a list (split on whitespace) instead of a string. |
|
314 | returned as a list (split on whitespace) instead of a string. | |
315 |
|
315 | |||
316 | -list_all: put all option values in lists. Normally only options |
|
316 | -list_all: put all option values in lists. Normally only options | |
317 | appearing more than once are put in a list.""" |
|
317 | appearing more than once are put in a list.""" | |
318 |
|
318 | |||
319 | # inject default options at the beginning of the input line |
|
319 | # inject default options at the beginning of the input line | |
320 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') |
|
320 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') | |
321 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) |
|
321 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) | |
322 |
|
322 | |||
323 | mode = kw.get('mode','string') |
|
323 | mode = kw.get('mode','string') | |
324 | if mode not in ['string','list']: |
|
324 | if mode not in ['string','list']: | |
325 | raise ValueError,'incorrect mode given: %s' % mode |
|
325 | raise ValueError,'incorrect mode given: %s' % mode | |
326 | # Get options |
|
326 | # Get options | |
327 | list_all = kw.get('list_all',0) |
|
327 | list_all = kw.get('list_all',0) | |
328 |
|
328 | |||
329 | # Check if we have more than one argument to warrant extra processing: |
|
329 | # Check if we have more than one argument to warrant extra processing: | |
330 | odict = {} # Dictionary with options |
|
330 | odict = {} # Dictionary with options | |
331 | args = arg_str.split() |
|
331 | args = arg_str.split() | |
332 | if len(args) >= 1: |
|
332 | if len(args) >= 1: | |
333 | # If the list of inputs only has 0 or 1 thing in it, there's no |
|
333 | # If the list of inputs only has 0 or 1 thing in it, there's no | |
334 | # need to look for options |
|
334 | # need to look for options | |
335 | argv = shlex_split(arg_str) |
|
335 | argv = shlex_split(arg_str) | |
336 | # Do regular option processing |
|
336 | # Do regular option processing | |
337 | opts,args = getopt(argv,opt_str,*long_opts) |
|
337 | opts,args = getopt(argv,opt_str,*long_opts) | |
338 | for o,a in opts: |
|
338 | for o,a in opts: | |
339 | if o.startswith('--'): |
|
339 | if o.startswith('--'): | |
340 | o = o[2:] |
|
340 | o = o[2:] | |
341 | else: |
|
341 | else: | |
342 | o = o[1:] |
|
342 | o = o[1:] | |
343 | try: |
|
343 | try: | |
344 | odict[o].append(a) |
|
344 | odict[o].append(a) | |
345 | except AttributeError: |
|
345 | except AttributeError: | |
346 | odict[o] = [odict[o],a] |
|
346 | odict[o] = [odict[o],a] | |
347 | except KeyError: |
|
347 | except KeyError: | |
348 | if list_all: |
|
348 | if list_all: | |
349 | odict[o] = [a] |
|
349 | odict[o] = [a] | |
350 | else: |
|
350 | else: | |
351 | odict[o] = a |
|
351 | odict[o] = a | |
352 |
|
352 | |||
353 | # Prepare opts,args for return |
|
353 | # Prepare opts,args for return | |
354 | opts = Struct(odict) |
|
354 | opts = Struct(odict) | |
355 | if mode == 'string': |
|
355 | if mode == 'string': | |
356 | args = ' '.join(args) |
|
356 | args = ' '.join(args) | |
357 |
|
357 | |||
358 | return opts,args |
|
358 | return opts,args | |
359 |
|
359 | |||
360 | #...................................................................... |
|
360 | #...................................................................... | |
361 | # And now the actual magic functions |
|
361 | # And now the actual magic functions | |
362 |
|
362 | |||
363 | # Functions for IPython shell work (vars,funcs, config, etc) |
|
363 | # Functions for IPython shell work (vars,funcs, config, etc) | |
364 | def magic_lsmagic(self, parameter_s = ''): |
|
364 | def magic_lsmagic(self, parameter_s = ''): | |
365 | """List currently available magic functions.""" |
|
365 | """List currently available magic functions.""" | |
366 | mesc = self.shell.ESC_MAGIC |
|
366 | mesc = self.shell.ESC_MAGIC | |
367 | print 'Available magic functions:\n'+mesc+\ |
|
367 | print 'Available magic functions:\n'+mesc+\ | |
368 | (' '+mesc).join(self.lsmagic()) |
|
368 | (' '+mesc).join(self.lsmagic()) | |
369 | print '\n' + Magic.auto_status[self.shell.rc.automagic] |
|
369 | print '\n' + Magic.auto_status[self.shell.rc.automagic] | |
370 | return None |
|
370 | return None | |
371 |
|
371 | |||
372 | def magic_magic(self, parameter_s = ''): |
|
372 | def magic_magic(self, parameter_s = ''): | |
373 | """Print information about the magic function system.""" |
|
373 | """Print information about the magic function system.""" | |
374 |
|
374 | |||
375 | mode = '' |
|
375 | mode = '' | |
376 | try: |
|
376 | try: | |
377 | if parameter_s.split()[0] == '-latex': |
|
377 | if parameter_s.split()[0] == '-latex': | |
378 | mode = 'latex' |
|
378 | mode = 'latex' | |
379 | except: |
|
379 | except: | |
380 | pass |
|
380 | pass | |
381 |
|
381 | |||
382 | magic_docs = [] |
|
382 | magic_docs = [] | |
383 | for fname in self.lsmagic(): |
|
383 | for fname in self.lsmagic(): | |
384 | mname = 'magic_' + fname |
|
384 | mname = 'magic_' + fname | |
385 | for space in (Magic,self,self.__class__): |
|
385 | for space in (Magic,self,self.__class__): | |
386 | try: |
|
386 | try: | |
387 | fn = space.__dict__[mname] |
|
387 | fn = space.__dict__[mname] | |
388 | except KeyError: |
|
388 | except KeyError: | |
389 | pass |
|
389 | pass | |
390 | else: |
|
390 | else: | |
391 | break |
|
391 | break | |
392 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, |
|
392 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, | |
393 | fname,fn.__doc__)) |
|
393 | fname,fn.__doc__)) | |
394 | magic_docs = ''.join(magic_docs) |
|
394 | magic_docs = ''.join(magic_docs) | |
395 |
|
395 | |||
396 | if mode == 'latex': |
|
396 | if mode == 'latex': | |
397 | print self.format_latex(magic_docs) |
|
397 | print self.format_latex(magic_docs) | |
398 | return |
|
398 | return | |
399 | else: |
|
399 | else: | |
400 | magic_docs = self.format_screen(magic_docs) |
|
400 | magic_docs = self.format_screen(magic_docs) | |
401 |
|
401 | |||
402 | outmsg = """ |
|
402 | outmsg = """ | |
403 | IPython's 'magic' functions |
|
403 | IPython's 'magic' functions | |
404 | =========================== |
|
404 | =========================== | |
405 |
|
405 | |||
406 | The magic function system provides a series of functions which allow you to |
|
406 | The magic function system provides a series of functions which allow you to | |
407 | control the behavior of IPython itself, plus a lot of system-type |
|
407 | control the behavior of IPython itself, plus a lot of system-type | |
408 | features. All these functions are prefixed with a % character, but parameters |
|
408 | features. All these functions are prefixed with a % character, but parameters | |
409 | are given without parentheses or quotes. |
|
409 | are given without parentheses or quotes. | |
410 |
|
410 | |||
411 | NOTE: If you have 'automagic' enabled (via the command line option or with the |
|
411 | NOTE: If you have 'automagic' enabled (via the command line option or with the | |
412 | %automagic function), you don't need to type in the % explicitly. By default, |
|
412 | %automagic function), you don't need to type in the % explicitly. By default, | |
413 | IPython ships with automagic on, so you should only rarely need the % escape. |
|
413 | IPython ships with automagic on, so you should only rarely need the % escape. | |
414 |
|
414 | |||
415 | Example: typing '%cd mydir' (without the quotes) changes you working directory |
|
415 | Example: typing '%cd mydir' (without the quotes) changes you working directory | |
416 | to 'mydir', if it exists. |
|
416 | to 'mydir', if it exists. | |
417 |
|
417 | |||
418 | You can define your own magic functions to extend the system. See the supplied |
|
418 | You can define your own magic functions to extend the system. See the supplied | |
419 | ipythonrc and example-magic.py files for details (in your ipython |
|
419 | ipythonrc and example-magic.py files for details (in your ipython | |
420 | configuration directory, typically $HOME/.ipython/). |
|
420 | configuration directory, typically $HOME/.ipython/). | |
421 |
|
421 | |||
422 | You can also define your own aliased names for magic functions. In your |
|
422 | You can also define your own aliased names for magic functions. In your | |
423 | ipythonrc file, placing a line like: |
|
423 | ipythonrc file, placing a line like: | |
424 |
|
424 | |||
425 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile |
|
425 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile | |
426 |
|
426 | |||
427 | will define %pf as a new name for %profile. |
|
427 | will define %pf as a new name for %profile. | |
428 |
|
428 | |||
429 | You can also call magics in code using the ipmagic() function, which IPython |
|
429 | You can also call magics in code using the ipmagic() function, which IPython | |
430 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. |
|
430 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. | |
431 |
|
431 | |||
432 | For a list of the available magic functions, use %lsmagic. For a description |
|
432 | For a list of the available magic functions, use %lsmagic. For a description | |
433 | of any of them, type %magic_name?, e.g. '%cd?'. |
|
433 | of any of them, type %magic_name?, e.g. '%cd?'. | |
434 |
|
434 | |||
435 | Currently the magic system has the following functions:\n""" |
|
435 | Currently the magic system has the following functions:\n""" | |
436 |
|
436 | |||
437 | mesc = self.shell.ESC_MAGIC |
|
437 | mesc = self.shell.ESC_MAGIC | |
438 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" |
|
438 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" | |
439 | "\n\n%s%s\n\n%s" % (outmsg, |
|
439 | "\n\n%s%s\n\n%s" % (outmsg, | |
440 | magic_docs,mesc,mesc, |
|
440 | magic_docs,mesc,mesc, | |
441 | (' '+mesc).join(self.lsmagic()), |
|
441 | (' '+mesc).join(self.lsmagic()), | |
442 | Magic.auto_status[self.shell.rc.automagic] ) ) |
|
442 | Magic.auto_status[self.shell.rc.automagic] ) ) | |
443 |
|
443 | |||
444 | page(outmsg,screen_lines=self.shell.rc.screen_length) |
|
444 | page(outmsg,screen_lines=self.shell.rc.screen_length) | |
445 |
|
445 | |||
446 | def magic_automagic(self, parameter_s = ''): |
|
446 | def magic_automagic(self, parameter_s = ''): | |
447 | """Make magic functions callable without having to type the initial %. |
|
447 | """Make magic functions callable without having to type the initial %. | |
448 |
|
448 | |||
449 | Toggles on/off (when off, you must call it as %automagic, of |
|
449 | Toggles on/off (when off, you must call it as %automagic, of | |
450 | course). Note that magic functions have lowest priority, so if there's |
|
450 | course). Note that magic functions have lowest priority, so if there's | |
451 | a variable whose name collides with that of a magic fn, automagic |
|
451 | a variable whose name collides with that of a magic fn, automagic | |
452 | won't work for that function (you get the variable instead). However, |
|
452 | won't work for that function (you get the variable instead). However, | |
453 | if you delete the variable (del var), the previously shadowed magic |
|
453 | if you delete the variable (del var), the previously shadowed magic | |
454 | function becomes visible to automagic again.""" |
|
454 | function becomes visible to automagic again.""" | |
455 |
|
455 | |||
456 | rc = self.shell.rc |
|
456 | rc = self.shell.rc | |
457 | rc.automagic = not rc.automagic |
|
457 | rc.automagic = not rc.automagic | |
458 | print '\n' + Magic.auto_status[rc.automagic] |
|
458 | print '\n' + Magic.auto_status[rc.automagic] | |
459 |
|
459 | |||
460 | def magic_autocall(self, parameter_s = ''): |
|
460 | def magic_autocall(self, parameter_s = ''): | |
461 | """Make functions callable without having to type parentheses. |
|
461 | """Make functions callable without having to type parentheses. | |
462 |
|
462 | |||
463 | This toggles the autocall command line option on and off.""" |
|
463 | This toggles the autocall command line option on and off.""" | |
464 |
|
464 | |||
465 | rc = self.shell.rc |
|
465 | rc = self.shell.rc | |
466 | rc.autocall = not rc.autocall |
|
466 | rc.autocall = not rc.autocall | |
467 | print "Automatic calling is:",['OFF','ON'][rc.autocall] |
|
467 | print "Automatic calling is:",['OFF','ON'][rc.autocall] | |
468 |
|
468 | |||
469 | def magic_autoindent(self, parameter_s = ''): |
|
469 | def magic_autoindent(self, parameter_s = ''): | |
470 | """Toggle autoindent on/off (if available).""" |
|
470 | """Toggle autoindent on/off (if available).""" | |
471 |
|
471 | |||
472 | self.shell.set_autoindent() |
|
472 | self.shell.set_autoindent() | |
473 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] |
|
473 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] | |
474 |
|
474 | |||
475 | def magic_system_verbose(self, parameter_s = ''): |
|
475 | def magic_system_verbose(self, parameter_s = ''): | |
476 | """Toggle verbose printing of system calls on/off.""" |
|
476 | """Toggle verbose printing of system calls on/off.""" | |
477 |
|
477 | |||
478 | self.shell.rc_set_toggle('system_verbose') |
|
478 | self.shell.rc_set_toggle('system_verbose') | |
479 | print "System verbose printing is:",\ |
|
479 | print "System verbose printing is:",\ | |
480 | ['OFF','ON'][self.shell.rc.system_verbose] |
|
480 | ['OFF','ON'][self.shell.rc.system_verbose] | |
481 |
|
481 | |||
482 | def magic_history(self, parameter_s = ''): |
|
482 | def magic_history(self, parameter_s = ''): | |
483 | """Print input history (_i<n> variables), with most recent last. |
|
483 | """Print input history (_i<n> variables), with most recent last. | |
484 |
|
484 | |||
485 | %history [-n] -> print at most 40 inputs (some may be multi-line)\\ |
|
485 | %history [-n] -> print at most 40 inputs (some may be multi-line)\\ | |
486 | %history [-n] n -> print at most n inputs\\ |
|
486 | %history [-n] n -> print at most n inputs\\ | |
487 | %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ |
|
487 | %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ | |
488 |
|
488 | |||
489 | Each input's number <n> is shown, and is accessible as the |
|
489 | Each input's number <n> is shown, and is accessible as the | |
490 | automatically generated variable _i<n>. Multi-line statements are |
|
490 | automatically generated variable _i<n>. Multi-line statements are | |
491 | printed starting at a new line for easy copy/paste. |
|
491 | printed starting at a new line for easy copy/paste. | |
492 |
|
492 | |||
493 | If option -n is used, input numbers are not printed. This is useful if |
|
493 | If option -n is used, input numbers are not printed. This is useful if | |
494 | you want to get a printout of many lines which can be directly pasted |
|
494 | you want to get a printout of many lines which can be directly pasted | |
495 | into a text editor. |
|
495 | into a text editor. | |
496 |
|
496 | |||
497 | This feature is only available if numbered prompts are in use.""" |
|
497 | This feature is only available if numbered prompts are in use.""" | |
498 |
|
498 | |||
499 | if not self.do_full_cache: |
|
499 | if not self.do_full_cache: | |
500 | print 'This feature is only available if numbered prompts are in use.' |
|
500 | print 'This feature is only available if numbered prompts are in use.' | |
501 | return |
|
501 | return | |
502 | opts,args = self.parse_options(parameter_s,'n',mode='list') |
|
502 | opts,args = self.parse_options(parameter_s,'n',mode='list') | |
503 |
|
503 | |||
504 | default_length = 40 |
|
504 | default_length = 40 | |
505 | if len(args) == 0: |
|
505 | if len(args) == 0: | |
506 | final = self.outputcache.prompt_count |
|
506 | final = self.outputcache.prompt_count | |
507 | init = max(1,final-default_length) |
|
507 | init = max(1,final-default_length) | |
508 | elif len(args) == 1: |
|
508 | elif len(args) == 1: | |
509 | final = self.outputcache.prompt_count |
|
509 | final = self.outputcache.prompt_count | |
510 | init = max(1,final-int(args[0])) |
|
510 | init = max(1,final-int(args[0])) | |
511 | elif len(args) == 2: |
|
511 | elif len(args) == 2: | |
512 | init,final = map(int,args) |
|
512 | init,final = map(int,args) | |
513 | else: |
|
513 | else: | |
514 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') |
|
514 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') | |
515 | print self.magic_hist.__doc__ |
|
515 | print self.magic_hist.__doc__ | |
516 | return |
|
516 | return | |
517 | width = len(str(final)) |
|
517 | width = len(str(final)) | |
518 | line_sep = ['','\n'] |
|
518 | line_sep = ['','\n'] | |
519 | input_hist = self.shell.input_hist |
|
519 | input_hist = self.shell.input_hist | |
520 | print_nums = not opts.has_key('n') |
|
520 | print_nums = not opts.has_key('n') | |
521 | for in_num in range(init,final): |
|
521 | for in_num in range(init,final): | |
522 | inline = input_hist[in_num] |
|
522 | inline = input_hist[in_num] | |
523 | multiline = inline.count('\n') > 1 |
|
523 | multiline = inline.count('\n') > 1 | |
524 | if print_nums: |
|
524 | if print_nums: | |
525 | print str(in_num).ljust(width)+':'+ line_sep[multiline], |
|
525 | print str(in_num).ljust(width)+':'+ line_sep[multiline], | |
526 | if inline.startswith('#'+self.shell.ESC_MAGIC) or \ |
|
526 | if inline.startswith('#'+self.shell.ESC_MAGIC) or \ | |
527 | inline.startswith('#!'): |
|
527 | inline.startswith('#!'): | |
528 | print inline[1:], |
|
528 | print inline[1:], | |
529 | else: |
|
529 | else: | |
530 | print inline, |
|
530 | print inline, | |
531 |
|
531 | |||
532 | def magic_hist(self, parameter_s=''): |
|
532 | def magic_hist(self, parameter_s=''): | |
533 | """Alternate name for %history.""" |
|
533 | """Alternate name for %history.""" | |
534 | return self.magic_history(parameter_s) |
|
534 | return self.magic_history(parameter_s) | |
535 |
|
535 | |||
536 | def magic_p(self, parameter_s=''): |
|
536 | def magic_p(self, parameter_s=''): | |
537 | """Just a short alias for Python's 'print'.""" |
|
537 | """Just a short alias for Python's 'print'.""" | |
538 | exec 'print ' + parameter_s in self.shell.user_ns |
|
538 | exec 'print ' + parameter_s in self.shell.user_ns | |
539 |
|
539 | |||
540 | def magic_r(self, parameter_s=''): |
|
540 | def magic_r(self, parameter_s=''): | |
541 | """Repeat previous input. |
|
541 | """Repeat previous input. | |
542 |
|
542 | |||
543 | If given an argument, repeats the previous command which starts with |
|
543 | If given an argument, repeats the previous command which starts with | |
544 | the same string, otherwise it just repeats the previous input. |
|
544 | the same string, otherwise it just repeats the previous input. | |
545 |
|
545 | |||
546 | Shell escaped commands (with ! as first character) are not recognized |
|
546 | Shell escaped commands (with ! as first character) are not recognized | |
547 | by this system, only pure python code and magic commands. |
|
547 | by this system, only pure python code and magic commands. | |
548 | """ |
|
548 | """ | |
549 |
|
549 | |||
550 | start = parameter_s.strip() |
|
550 | start = parameter_s.strip() | |
551 | esc_magic = self.shell.ESC_MAGIC |
|
551 | esc_magic = self.shell.ESC_MAGIC | |
552 | # Identify magic commands even if automagic is on (which means |
|
552 | # Identify magic commands even if automagic is on (which means | |
553 | # the in-memory version is different from that typed by the user). |
|
553 | # the in-memory version is different from that typed by the user). | |
554 | if self.shell.rc.automagic: |
|
554 | if self.shell.rc.automagic: | |
555 | start_magic = esc_magic+start |
|
555 | start_magic = esc_magic+start | |
556 | else: |
|
556 | else: | |
557 | start_magic = start |
|
557 | start_magic = start | |
558 | # Look through the input history in reverse |
|
558 | # Look through the input history in reverse | |
559 | for n in range(len(self.shell.input_hist)-2,0,-1): |
|
559 | for n in range(len(self.shell.input_hist)-2,0,-1): | |
560 | input = self.shell.input_hist[n] |
|
560 | input = self.shell.input_hist[n] | |
561 | # skip plain 'r' lines so we don't recurse to infinity |
|
561 | # skip plain 'r' lines so we don't recurse to infinity | |
562 | if input != 'ipmagic("r")\n' and \ |
|
562 | if input != 'ipmagic("r")\n' and \ | |
563 | (input.startswith(start) or input.startswith(start_magic)): |
|
563 | (input.startswith(start) or input.startswith(start_magic)): | |
564 | #print 'match',`input` # dbg |
|
564 | #print 'match',`input` # dbg | |
565 | if input.startswith(esc_magic): |
|
565 | if input.startswith(esc_magic): | |
566 | input = magic2python(input) |
|
566 | input = magic2python(input) | |
567 | #print 'modified',`input` # dbg |
|
567 | #print 'modified',`input` # dbg | |
568 | print 'Executing:',input, |
|
568 | print 'Executing:',input, | |
569 | exec input in self.shell.user_ns |
|
569 | exec input in self.shell.user_ns | |
570 | return |
|
570 | return | |
571 | print 'No previous input matching `%s` found.' % start |
|
571 | print 'No previous input matching `%s` found.' % start | |
572 |
|
572 | |||
573 | def magic_page(self, parameter_s=''): |
|
573 | def magic_page(self, parameter_s=''): | |
574 | """Pretty print the object and display it through a pager. |
|
574 | """Pretty print the object and display it through a pager. | |
575 |
|
575 | |||
576 | If no parameter is given, use _ (last output).""" |
|
576 | If no parameter is given, use _ (last output).""" | |
577 | # After a function contributed by Olivier Aubert, slightly modified. |
|
577 | # After a function contributed by Olivier Aubert, slightly modified. | |
578 |
|
578 | |||
579 | oname = parameter_s and parameter_s or '_' |
|
579 | oname = parameter_s and parameter_s or '_' | |
580 | info = self._ofind(oname) |
|
580 | info = self._ofind(oname) | |
581 | if info['found']: |
|
581 | if info['found']: | |
582 | page(pformat(info['obj'])) |
|
582 | page(pformat(info['obj'])) | |
583 | else: |
|
583 | else: | |
584 | print 'Object `%s` not found' % oname |
|
584 | print 'Object `%s` not found' % oname | |
585 |
|
585 | |||
586 | def magic_profile(self, parameter_s=''): |
|
586 | def magic_profile(self, parameter_s=''): | |
587 | """Print your currently active IPyhton profile.""" |
|
587 | """Print your currently active IPyhton profile.""" | |
588 | if self.shell.rc.profile: |
|
588 | if self.shell.rc.profile: | |
589 | printpl('Current IPython profile: $self.shell.rc.profile.') |
|
589 | printpl('Current IPython profile: $self.shell.rc.profile.') | |
590 | else: |
|
590 | else: | |
591 | print 'No profile active.' |
|
591 | print 'No profile active.' | |
592 |
|
592 | |||
593 | def _inspect(self,meth,oname,**kw): |
|
593 | def _inspect(self,meth,oname,**kw): | |
594 | """Generic interface to the inspector system. |
|
594 | """Generic interface to the inspector system. | |
595 |
|
595 | |||
596 | This function is meant to be called by pdef, pdoc & friends.""" |
|
596 | This function is meant to be called by pdef, pdoc & friends.""" | |
597 |
|
597 | |||
598 | oname = oname.strip() |
|
598 | oname = oname.strip() | |
599 | info = Struct(self._ofind(oname)) |
|
599 | info = Struct(self._ofind(oname)) | |
600 | if info.found: |
|
600 | if info.found: | |
601 | pmethod = getattr(self.shell.inspector,meth) |
|
601 | pmethod = getattr(self.shell.inspector,meth) | |
602 | formatter = info.ismagic and self.format_screen or None |
|
602 | formatter = info.ismagic and self.format_screen or None | |
603 | if meth == 'pdoc': |
|
603 | if meth == 'pdoc': | |
604 | pmethod(info.obj,oname,formatter) |
|
604 | pmethod(info.obj,oname,formatter) | |
605 | elif meth == 'pinfo': |
|
605 | elif meth == 'pinfo': | |
606 | pmethod(info.obj,oname,formatter,info,**kw) |
|
606 | pmethod(info.obj,oname,formatter,info,**kw) | |
607 | else: |
|
607 | else: | |
608 | pmethod(info.obj,oname) |
|
608 | pmethod(info.obj,oname) | |
609 | else: |
|
609 | else: | |
610 | print 'Object `%s` not found.' % oname |
|
610 | print 'Object `%s` not found.' % oname | |
611 | return 'not found' # so callers can take other action |
|
611 | return 'not found' # so callers can take other action | |
612 |
|
612 | |||
613 | def magic_pdef(self, parameter_s=''): |
|
613 | def magic_pdef(self, parameter_s=''): | |
614 | """Print the definition header for any callable object. |
|
614 | """Print the definition header for any callable object. | |
615 |
|
615 | |||
616 | If the object is a class, print the constructor information.""" |
|
616 | If the object is a class, print the constructor information.""" | |
617 | self._inspect('pdef',parameter_s) |
|
617 | self._inspect('pdef',parameter_s) | |
618 |
|
618 | |||
619 | def magic_pdoc(self, parameter_s=''): |
|
619 | def magic_pdoc(self, parameter_s=''): | |
620 | """Print the docstring for an object. |
|
620 | """Print the docstring for an object. | |
621 |
|
621 | |||
622 | If the given object is a class, it will print both the class and the |
|
622 | If the given object is a class, it will print both the class and the | |
623 | constructor docstrings.""" |
|
623 | constructor docstrings.""" | |
624 | self._inspect('pdoc',parameter_s) |
|
624 | self._inspect('pdoc',parameter_s) | |
625 |
|
625 | |||
626 | def magic_psource(self, parameter_s=''): |
|
626 | def magic_psource(self, parameter_s=''): | |
627 | """Print (or run through pager) the source code for an object.""" |
|
627 | """Print (or run through pager) the source code for an object.""" | |
628 | self._inspect('psource',parameter_s) |
|
628 | self._inspect('psource',parameter_s) | |
629 |
|
629 | |||
630 | def magic_pfile(self, parameter_s=''): |
|
630 | def magic_pfile(self, parameter_s=''): | |
631 | """Print (or run through pager) the file where an object is defined. |
|
631 | """Print (or run through pager) the file where an object is defined. | |
632 |
|
632 | |||
633 | The file opens at the line where the object definition begins. IPython |
|
633 | The file opens at the line where the object definition begins. IPython | |
634 | will honor the environment variable PAGER if set, and otherwise will |
|
634 | will honor the environment variable PAGER if set, and otherwise will | |
635 | do its best to print the file in a convenient form. |
|
635 | do its best to print the file in a convenient form. | |
636 |
|
636 | |||
637 | If the given argument is not an object currently defined, IPython will |
|
637 | If the given argument is not an object currently defined, IPython will | |
638 | try to interpret it as a filename (automatically adding a .py extension |
|
638 | try to interpret it as a filename (automatically adding a .py extension | |
639 | if needed). You can thus use %pfile as a syntax highlighting code |
|
639 | if needed). You can thus use %pfile as a syntax highlighting code | |
640 | viewer.""" |
|
640 | viewer.""" | |
641 |
|
641 | |||
642 | # first interpret argument as an object name |
|
642 | # first interpret argument as an object name | |
643 | out = self._inspect('pfile',parameter_s) |
|
643 | out = self._inspect('pfile',parameter_s) | |
644 | # if not, try the input as a filename |
|
644 | # if not, try the input as a filename | |
645 | if out == 'not found': |
|
645 | if out == 'not found': | |
646 | try: |
|
646 | try: | |
647 | filename = get_py_filename(parameter_s) |
|
647 | filename = get_py_filename(parameter_s) | |
648 | except IOError,msg: |
|
648 | except IOError,msg: | |
649 | print msg |
|
649 | print msg | |
650 | return |
|
650 | return | |
651 | page(self.shell.inspector.format(file(filename).read())) |
|
651 | page(self.shell.inspector.format(file(filename).read())) | |
652 |
|
652 | |||
653 | def magic_pinfo(self, parameter_s=''): |
|
653 | def magic_pinfo(self, parameter_s=''): | |
654 | """Provide detailed information about an object. |
|
654 | """Provide detailed information about an object. | |
655 |
|
655 | |||
656 | '%pinfo object' is just a synonym for object? or ?object.""" |
|
656 | '%pinfo object' is just a synonym for object? or ?object.""" | |
657 |
|
657 | |||
658 | #print 'pinfo par: <%s>' % parameter_s # dbg |
|
658 | #print 'pinfo par: <%s>' % parameter_s # dbg | |
659 |
|
659 | |||
660 | # detail_level: 0 -> obj? , 1 -> obj?? |
|
660 | # detail_level: 0 -> obj? , 1 -> obj?? | |
661 | detail_level = 0 |
|
661 | detail_level = 0 | |
662 | # We need to detect if we got called as 'pinfo pinfo foo', which can |
|
662 | # We need to detect if we got called as 'pinfo pinfo foo', which can | |
663 | # happen if the user types 'pinfo foo?' at the cmd line. |
|
663 | # happen if the user types 'pinfo foo?' at the cmd line. | |
664 | pinfo,qmark1,oname,qmark2 = \ |
|
664 | pinfo,qmark1,oname,qmark2 = \ | |
665 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() |
|
665 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() | |
666 | if pinfo or qmark1 or qmark2: |
|
666 | if pinfo or qmark1 or qmark2: | |
667 | detail_level = 1 |
|
667 | detail_level = 1 | |
668 | if "*" in oname: |
|
668 | if "*" in oname: | |
669 | self.magic_psearch(oname) |
|
669 | self.magic_psearch(oname) | |
670 | else: |
|
670 | else: | |
671 | self._inspect('pinfo',oname,detail_level=detail_level) |
|
671 | self._inspect('pinfo',oname,detail_level=detail_level) | |
672 |
|
672 | |||
673 | def magic_psearch(self, parameter_s=''): |
|
673 | def magic_psearch(self, parameter_s=''): | |
674 | """Search for object in namespaces by wildcard. |
|
674 | """Search for object in namespaces by wildcard. | |
675 |
|
675 | |||
676 | %psearch [options] PATTERN [OBJECT TYPE] |
|
676 | %psearch [options] PATTERN [OBJECT TYPE] | |
677 |
|
677 | |||
678 | Note: ? can be used as a synonym for %psearch, at the beginning or at |
|
678 | Note: ? can be used as a synonym for %psearch, at the beginning or at | |
679 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the |
|
679 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the | |
680 | rest of the command line must be unchanged (options come first), so |
|
680 | rest of the command line must be unchanged (options come first), so | |
681 | for example the following forms are equivalent |
|
681 | for example the following forms are equivalent | |
682 |
|
682 | |||
683 | %psearch -i a* function |
|
683 | %psearch -i a* function | |
684 | -i a* function? |
|
684 | -i a* function? | |
685 | ?-i a* function |
|
685 | ?-i a* function | |
686 |
|
686 | |||
687 | Arguments: |
|
687 | Arguments: | |
688 |
|
688 | |||
689 | PATTERN |
|
689 | PATTERN | |
690 |
|
690 | |||
691 | where PATTERN is a string containing * as a wildcard similar to its |
|
691 | where PATTERN is a string containing * as a wildcard similar to its | |
692 | use in a shell. The pattern is matched in all namespaces on the |
|
692 | use in a shell. The pattern is matched in all namespaces on the | |
693 | search path. By default objects starting with a single _ are not |
|
693 | search path. By default objects starting with a single _ are not | |
694 | matched, many IPython generated objects have a single |
|
694 | matched, many IPython generated objects have a single | |
695 | underscore. The default is case insensitive matching. Matching is |
|
695 | underscore. The default is case insensitive matching. Matching is | |
696 | also done on the attributes of objects and not only on the objects |
|
696 | also done on the attributes of objects and not only on the objects | |
697 | in a module. |
|
697 | in a module. | |
698 |
|
698 | |||
699 | [OBJECT TYPE] |
|
699 | [OBJECT TYPE] | |
700 |
|
700 | |||
701 | Is the name of a python type from the types module. The name is |
|
701 | Is the name of a python type from the types module. The name is | |
702 | given in lowercase without the ending type, ex. StringType is |
|
702 | given in lowercase without the ending type, ex. StringType is | |
703 | written string. By adding a type here only objects matching the |
|
703 | written string. By adding a type here only objects matching the | |
704 | given type are matched. Using all here makes the pattern match all |
|
704 | given type are matched. Using all here makes the pattern match all | |
705 | types (this is the default). |
|
705 | types (this is the default). | |
706 |
|
706 | |||
707 | Options: |
|
707 | Options: | |
708 |
|
708 | |||
709 | -a: makes the pattern match even objects whose names start with a |
|
709 | -a: makes the pattern match even objects whose names start with a | |
710 | single underscore. These names are normally ommitted from the |
|
710 | single underscore. These names are normally ommitted from the | |
711 | search. |
|
711 | search. | |
712 |
|
712 | |||
713 | -i/-c: make the pattern case insensitive/sensitive. If neither of |
|
713 | -i/-c: make the pattern case insensitive/sensitive. If neither of | |
714 | these options is given, the default is read from your ipythonrc |
|
714 | these options is given, the default is read from your ipythonrc | |
715 | file. The option name which sets this value is |
|
715 | file. The option name which sets this value is | |
716 | 'wildcards_case_sensitive'. If this option is not specified in your |
|
716 | 'wildcards_case_sensitive'. If this option is not specified in your | |
717 | ipythonrc file, IPython's internal default is to do a case sensitive |
|
717 | ipythonrc file, IPython's internal default is to do a case sensitive | |
718 | search. |
|
718 | search. | |
719 |
|
719 | |||
720 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you |
|
720 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you | |
721 | specifiy can be searched in any of the following namespaces: |
|
721 | specifiy can be searched in any of the following namespaces: | |
722 | 'builtin', 'user', 'user_global','internal', 'alias', where |
|
722 | 'builtin', 'user', 'user_global','internal', 'alias', where | |
723 | 'builtin' and 'user' are the search defaults. Note that you should |
|
723 | 'builtin' and 'user' are the search defaults. Note that you should | |
724 | not use quotes when specifying namespaces. |
|
724 | not use quotes when specifying namespaces. | |
725 |
|
725 | |||
726 | 'Builtin' contains the python module builtin, 'user' contains all |
|
726 | 'Builtin' contains the python module builtin, 'user' contains all | |
727 | user data, 'alias' only contain the shell aliases and no python |
|
727 | user data, 'alias' only contain the shell aliases and no python | |
728 | objects, 'internal' contains objects used by IPython. The |
|
728 | objects, 'internal' contains objects used by IPython. The | |
729 | 'user_global' namespace is only used by embedded IPython instances, |
|
729 | 'user_global' namespace is only used by embedded IPython instances, | |
730 | and it contains module-level globals. You can add namespaces to the |
|
730 | and it contains module-level globals. You can add namespaces to the | |
731 | search with -s or exclude them with -e (these options can be given |
|
731 | search with -s or exclude them with -e (these options can be given | |
732 | more than once). |
|
732 | more than once). | |
733 |
|
733 | |||
734 | Examples: |
|
734 | Examples: | |
735 |
|
735 | |||
736 | %psearch a* -> objects beginning with an a |
|
736 | %psearch a* -> objects beginning with an a | |
737 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a |
|
737 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a | |
738 | %psearch a* function -> all functions beginning with an a |
|
738 | %psearch a* function -> all functions beginning with an a | |
739 | %psearch re.e* -> objects beginning with an e in module re |
|
739 | %psearch re.e* -> objects beginning with an e in module re | |
740 | %psearch r*.e* -> objects that start with e in modules starting in r |
|
740 | %psearch r*.e* -> objects that start with e in modules starting in r | |
741 | %psearch r*.* string -> all strings in modules beginning with r |
|
741 | %psearch r*.* string -> all strings in modules beginning with r | |
742 |
|
742 | |||
743 | Case sensitve search: |
|
743 | Case sensitve search: | |
744 |
|
744 | |||
745 | %psearch -c a* list all object beginning with lower case a |
|
745 | %psearch -c a* list all object beginning with lower case a | |
746 |
|
746 | |||
747 | Show objects beginning with a single _: |
|
747 | Show objects beginning with a single _: | |
748 |
|
748 | |||
749 | %psearch -a _* list objects beginning with a single underscore""" |
|
749 | %psearch -a _* list objects beginning with a single underscore""" | |
750 |
|
750 | |||
751 | # default namespaces to be searched |
|
751 | # default namespaces to be searched | |
752 | def_search = ['user','builtin'] |
|
752 | def_search = ['user','builtin'] | |
753 |
|
753 | |||
754 | # Process options/args |
|
754 | # Process options/args | |
755 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) |
|
755 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) | |
756 | opt = opts.get |
|
756 | opt = opts.get | |
757 | shell = self.shell |
|
757 | shell = self.shell | |
758 | psearch = shell.inspector.psearch |
|
758 | psearch = shell.inspector.psearch | |
759 |
|
759 | |||
760 | # select case options |
|
760 | # select case options | |
761 | if opts.has_key('i'): |
|
761 | if opts.has_key('i'): | |
762 | ignore_case = True |
|
762 | ignore_case = True | |
763 | elif opts.has_key('c'): |
|
763 | elif opts.has_key('c'): | |
764 | ignore_case = False |
|
764 | ignore_case = False | |
765 | else: |
|
765 | else: | |
766 | ignore_case = not shell.rc.wildcards_case_sensitive |
|
766 | ignore_case = not shell.rc.wildcards_case_sensitive | |
767 |
|
767 | |||
768 | # Build list of namespaces to search from user options |
|
768 | # Build list of namespaces to search from user options | |
769 | def_search.extend(opt('s',[])) |
|
769 | def_search.extend(opt('s',[])) | |
770 | ns_exclude = ns_exclude=opt('e',[]) |
|
770 | ns_exclude = ns_exclude=opt('e',[]) | |
771 | ns_search = [nm for nm in def_search if nm not in ns_exclude] |
|
771 | ns_search = [nm for nm in def_search if nm not in ns_exclude] | |
772 |
|
772 | |||
773 | # Call the actual search |
|
773 | # Call the actual search | |
774 | try: |
|
774 | try: | |
775 | psearch(args,shell.ns_table,ns_search, |
|
775 | psearch(args,shell.ns_table,ns_search, | |
776 | show_all=opt('a'),ignore_case=ignore_case) |
|
776 | show_all=opt('a'),ignore_case=ignore_case) | |
777 | except: |
|
777 | except: | |
778 | shell.showtraceback() |
|
778 | shell.showtraceback() | |
779 |
|
779 | |||
780 | def magic_who_ls(self, parameter_s=''): |
|
780 | def magic_who_ls(self, parameter_s=''): | |
781 | """Return a sorted list of all interactive variables. |
|
781 | """Return a sorted list of all interactive variables. | |
782 |
|
782 | |||
783 | If arguments are given, only variables of types matching these |
|
783 | If arguments are given, only variables of types matching these | |
784 | arguments are returned.""" |
|
784 | arguments are returned.""" | |
785 |
|
785 | |||
786 | user_ns = self.shell.user_ns |
|
786 | user_ns = self.shell.user_ns | |
787 | out = [] |
|
787 | out = [] | |
788 | typelist = parameter_s.split() |
|
788 | typelist = parameter_s.split() | |
789 | for i in self.shell.user_ns.keys(): |
|
789 | for i in self.shell.user_ns.keys(): | |
790 | if not (i.startswith('_') or i.startswith('_i')) \ |
|
790 | if not (i.startswith('_') or i.startswith('_i')) \ | |
791 | and not (self.internal_ns.has_key(i) or |
|
791 | and not (self.internal_ns.has_key(i) or | |
792 | self.user_config_ns.has_key(i)): |
|
792 | self.user_config_ns.has_key(i)): | |
793 | if typelist: |
|
793 | if typelist: | |
794 | if type(user_ns[i]).__name__ in typelist: |
|
794 | if type(user_ns[i]).__name__ in typelist: | |
795 | out.append(i) |
|
795 | out.append(i) | |
796 | else: |
|
796 | else: | |
797 | out.append(i) |
|
797 | out.append(i) | |
798 | out.sort() |
|
798 | out.sort() | |
799 | return out |
|
799 | return out | |
800 |
|
800 | |||
801 | def magic_who(self, parameter_s=''): |
|
801 | def magic_who(self, parameter_s=''): | |
802 | """Print all interactive variables, with some minimal formatting. |
|
802 | """Print all interactive variables, with some minimal formatting. | |
803 |
|
803 | |||
804 | If any arguments are given, only variables whose type matches one of |
|
804 | If any arguments are given, only variables whose type matches one of | |
805 | these are printed. For example: |
|
805 | these are printed. For example: | |
806 |
|
806 | |||
807 | %who function str |
|
807 | %who function str | |
808 |
|
808 | |||
809 | will only list functions and strings, excluding all other types of |
|
809 | will only list functions and strings, excluding all other types of | |
810 | variables. To find the proper type names, simply use type(var) at a |
|
810 | variables. To find the proper type names, simply use type(var) at a | |
811 | command line to see how python prints type names. For example: |
|
811 | command line to see how python prints type names. For example: | |
812 |
|
812 | |||
813 | In [1]: type('hello')\\ |
|
813 | In [1]: type('hello')\\ | |
814 | Out[1]: <type 'str'> |
|
814 | Out[1]: <type 'str'> | |
815 |
|
815 | |||
816 | indicates that the type name for strings is 'str'. |
|
816 | indicates that the type name for strings is 'str'. | |
817 |
|
817 | |||
818 | %who always excludes executed names loaded through your configuration |
|
818 | %who always excludes executed names loaded through your configuration | |
819 | file and things which are internal to IPython. |
|
819 | file and things which are internal to IPython. | |
820 |
|
820 | |||
821 | This is deliberate, as typically you may load many modules and the |
|
821 | This is deliberate, as typically you may load many modules and the | |
822 | purpose of %who is to show you only what you've manually defined.""" |
|
822 | purpose of %who is to show you only what you've manually defined.""" | |
823 |
|
823 | |||
824 | varlist = self.magic_who_ls(parameter_s) |
|
824 | varlist = self.magic_who_ls(parameter_s) | |
825 | if not varlist: |
|
825 | if not varlist: | |
826 | print 'Interactive namespace is empty.' |
|
826 | print 'Interactive namespace is empty.' | |
827 | return |
|
827 | return | |
828 |
|
828 | |||
829 | # if we have variables, move on... |
|
829 | # if we have variables, move on... | |
830 |
|
830 | |||
831 | # stupid flushing problem: when prompts have no separators, stdout is |
|
831 | # stupid flushing problem: when prompts have no separators, stdout is | |
832 | # getting lost. I'm starting to think this is a python bug. I'm having |
|
832 | # getting lost. I'm starting to think this is a python bug. I'm having | |
833 | # to force a flush with a print because even a sys.stdout.flush |
|
833 | # to force a flush with a print because even a sys.stdout.flush | |
834 | # doesn't seem to do anything! |
|
834 | # doesn't seem to do anything! | |
835 |
|
835 | |||
836 | count = 0 |
|
836 | count = 0 | |
837 | for i in varlist: |
|
837 | for i in varlist: | |
838 | print i+'\t', |
|
838 | print i+'\t', | |
839 | count += 1 |
|
839 | count += 1 | |
840 | if count > 8: |
|
840 | if count > 8: | |
841 | count = 0 |
|
841 | count = 0 | |
842 |
|
842 | |||
843 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? |
|
843 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? | |
844 |
|
844 | |||
845 | print # well, this does force a flush at the expense of an extra \n |
|
845 | print # well, this does force a flush at the expense of an extra \n | |
846 |
|
846 | |||
847 | def magic_whos(self, parameter_s=''): |
|
847 | def magic_whos(self, parameter_s=''): | |
848 | """Like %who, but gives some extra information about each variable. |
|
848 | """Like %who, but gives some extra information about each variable. | |
849 |
|
849 | |||
850 | The same type filtering of %who can be applied here. |
|
850 | The same type filtering of %who can be applied here. | |
851 |
|
851 | |||
852 | For all variables, the type is printed. Additionally it prints: |
|
852 | For all variables, the type is printed. Additionally it prints: | |
853 |
|
853 | |||
854 | - For {},[],(): their length. |
|
854 | - For {},[],(): their length. | |
855 |
|
855 | |||
856 | - For Numeric arrays, a summary with shape, number of elements, |
|
856 | - For Numeric arrays, a summary with shape, number of elements, | |
857 | typecode and size in memory. |
|
857 | typecode and size in memory. | |
858 |
|
858 | |||
859 | - Everything else: a string representation, snipping their middle if |
|
859 | - Everything else: a string representation, snipping their middle if | |
860 | too long.""" |
|
860 | too long.""" | |
861 |
|
861 | |||
862 | varnames = self.magic_who_ls(parameter_s) |
|
862 | varnames = self.magic_who_ls(parameter_s) | |
863 | if not varnames: |
|
863 | if not varnames: | |
864 | print 'Interactive namespace is empty.' |
|
864 | print 'Interactive namespace is empty.' | |
865 | return |
|
865 | return | |
866 |
|
866 | |||
867 | # if we have variables, move on... |
|
867 | # if we have variables, move on... | |
868 |
|
868 | |||
869 | # for these types, show len() instead of data: |
|
869 | # for these types, show len() instead of data: | |
870 | seq_types = [types.DictType,types.ListType,types.TupleType] |
|
870 | seq_types = [types.DictType,types.ListType,types.TupleType] | |
871 |
|
871 | |||
872 | # for Numeric arrays, display summary info |
|
872 | # for Numeric arrays, display summary info | |
873 | try: |
|
873 | try: | |
874 | import Numeric |
|
874 | import Numeric | |
875 | except ImportError: |
|
875 | except ImportError: | |
876 | array_type = None |
|
876 | array_type = None | |
877 | else: |
|
877 | else: | |
878 | array_type = Numeric.ArrayType.__name__ |
|
878 | array_type = Numeric.ArrayType.__name__ | |
879 |
|
879 | |||
880 | # Find all variable names and types so we can figure out column sizes |
|
880 | # Find all variable names and types so we can figure out column sizes | |
881 | get_vars = lambda i: self.shell.user_ns[i] |
|
881 | get_vars = lambda i: self.shell.user_ns[i] | |
882 | type_name = lambda v: type(v).__name__ |
|
882 | type_name = lambda v: type(v).__name__ | |
883 | varlist = map(get_vars,varnames) |
|
883 | varlist = map(get_vars,varnames) | |
884 | typelist = map(type_name,varlist) |
|
884 | typelist = map(type_name,varlist) | |
885 | # column labels and # of spaces as separator |
|
885 | # column labels and # of spaces as separator | |
886 | varlabel = 'Variable' |
|
886 | varlabel = 'Variable' | |
887 | typelabel = 'Type' |
|
887 | typelabel = 'Type' | |
888 | datalabel = 'Data/Info' |
|
888 | datalabel = 'Data/Info' | |
889 | colsep = 3 |
|
889 | colsep = 3 | |
890 | # variable format strings |
|
890 | # variable format strings | |
891 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" |
|
891 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" | |
892 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' |
|
892 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' | |
893 | aformat = "%s: %s elems, type `%s`, %s bytes" |
|
893 | aformat = "%s: %s elems, type `%s`, %s bytes" | |
894 | # find the size of the columns to format the output nicely |
|
894 | # find the size of the columns to format the output nicely | |
895 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep |
|
895 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep | |
896 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep |
|
896 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep | |
897 | # table header |
|
897 | # table header | |
898 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ |
|
898 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ | |
899 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) |
|
899 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) | |
900 | # and the table itself |
|
900 | # and the table itself | |
901 | kb = 1024 |
|
901 | kb = 1024 | |
902 | Mb = 1048576 # kb**2 |
|
902 | Mb = 1048576 # kb**2 | |
903 | for vname,var,vtype in zip(varnames,varlist,typelist): |
|
903 | for vname,var,vtype in zip(varnames,varlist,typelist): | |
904 | print itpl(vformat), |
|
904 | print itpl(vformat), | |
905 | if vtype in seq_types: |
|
905 | if vtype in seq_types: | |
906 | print len(var) |
|
906 | print len(var) | |
907 | elif vtype==array_type: |
|
907 | elif vtype==array_type: | |
908 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] |
|
908 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] | |
909 | vsize = Numeric.size(var) |
|
909 | vsize = Numeric.size(var) | |
910 | vbytes = vsize*var.itemsize() |
|
910 | vbytes = vsize*var.itemsize() | |
911 | if vbytes < 100000: |
|
911 | if vbytes < 100000: | |
912 | print aformat % (vshape,vsize,var.typecode(),vbytes) |
|
912 | print aformat % (vshape,vsize,var.typecode(),vbytes) | |
913 | else: |
|
913 | else: | |
914 | print aformat % (vshape,vsize,var.typecode(),vbytes), |
|
914 | print aformat % (vshape,vsize,var.typecode(),vbytes), | |
915 | if vbytes < Mb: |
|
915 | if vbytes < Mb: | |
916 | print '(%s kb)' % (vbytes/kb,) |
|
916 | print '(%s kb)' % (vbytes/kb,) | |
917 | else: |
|
917 | else: | |
918 | print '(%s Mb)' % (vbytes/Mb,) |
|
918 | print '(%s Mb)' % (vbytes/Mb,) | |
919 | else: |
|
919 | else: | |
920 | vstr = str(var) |
|
920 | vstr = str(var) | |
921 | if len(vstr) < 50: |
|
921 | if len(vstr) < 50: | |
922 | print vstr |
|
922 | print vstr | |
923 | else: |
|
923 | else: | |
924 | printpl(vfmt_short) |
|
924 | printpl(vfmt_short) | |
925 |
|
925 | |||
926 | def magic_reset(self, parameter_s=''): |
|
926 | def magic_reset(self, parameter_s=''): | |
927 | """Resets the namespace by removing all names defined by the user. |
|
927 | """Resets the namespace by removing all names defined by the user. | |
928 |
|
928 | |||
929 | Input/Output history are left around in case you need them.""" |
|
929 | Input/Output history are left around in case you need them.""" | |
930 |
|
930 | |||
931 | ans = raw_input( |
|
931 | ans = raw_input( | |
932 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") |
|
932 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") | |
933 | if not ans.lower() == 'y': |
|
933 | if not ans.lower() == 'y': | |
934 | print 'Nothing done.' |
|
934 | print 'Nothing done.' | |
935 | return |
|
935 | return | |
936 | user_ns = self.shell.user_ns |
|
936 | user_ns = self.shell.user_ns | |
937 | for i in self.magic_who_ls(): |
|
937 | for i in self.magic_who_ls(): | |
938 | del(user_ns[i]) |
|
938 | del(user_ns[i]) | |
939 |
|
939 | |||
940 | def magic_config(self,parameter_s=''): |
|
940 | def magic_config(self,parameter_s=''): | |
941 | """Show IPython's internal configuration.""" |
|
941 | """Show IPython's internal configuration.""" | |
942 |
|
942 | |||
943 | page('Current configuration structure:\n'+ |
|
943 | page('Current configuration structure:\n'+ | |
944 | pformat(self.shell.rc.dict())) |
|
944 | pformat(self.shell.rc.dict())) | |
945 |
|
945 | |||
946 | def magic_logstart(self,parameter_s=''): |
|
946 | def magic_logstart(self,parameter_s=''): | |
947 | """Start logging anywhere in a session. |
|
947 | """Start logging anywhere in a session. | |
948 |
|
948 | |||
949 | %logstart [log_name [log_mode]] |
|
949 | %logstart [log_name [log_mode]] | |
950 |
|
950 | |||
951 | If no name is given, it defaults to a file named 'ipython.log' in your |
|
951 | If no name is given, it defaults to a file named 'ipython.log' in your | |
952 | current directory, in 'rotate' mode (see below). |
|
952 | current directory, in 'rotate' mode (see below). | |
953 |
|
953 | |||
954 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your |
|
954 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your | |
955 | history up to that point and then continues logging. |
|
955 | history up to that point and then continues logging. | |
956 |
|
956 | |||
957 | %logstart takes a second optional parameter: logging mode. This can be one |
|
957 | %logstart takes a second optional parameter: logging mode. This can be one | |
958 | of (note that the modes are given unquoted):\\ |
|
958 | of (note that the modes are given unquoted):\\ | |
959 | over: overwrite existing log.\\ |
|
959 | over: overwrite existing log.\\ | |
960 | backup: rename (if exists) to name~ and start name.\\ |
|
960 | backup: rename (if exists) to name~ and start name.\\ | |
961 | append: well, that says it.\\ |
|
961 | append: well, that says it.\\ | |
962 | rotate: create rotating logs name.1~, name.2~, etc. |
|
962 | rotate: create rotating logs name.1~, name.2~, etc. | |
963 | """ |
|
963 | """ | |
964 |
|
964 | |||
965 | #FIXME. This function should all be moved to the Logger class. |
|
965 | #FIXME. This function should all be moved to the Logger class. | |
966 |
|
966 | |||
967 | valid_modes = qw('over backup append rotate') |
|
967 | valid_modes = qw('over backup append rotate') | |
968 | if self.LOG: |
|
968 | if self.LOG: | |
969 | print 'Logging is already in place. Logfile:',self.LOG |
|
969 | print 'Logging is already in place. Logfile:',self.LOG | |
970 | return |
|
970 | return | |
971 |
|
971 | |||
972 | par = parameter_s.strip() |
|
972 | par = parameter_s.strip() | |
973 | if not par: |
|
973 | if not par: | |
974 | logname = self.LOGDEF |
|
974 | logname = self.LOGDEF | |
975 | logmode = 'rotate' # use rotate for the auto-generated logs |
|
975 | logmode = 'rotate' # use rotate for the auto-generated logs | |
976 | else: |
|
976 | else: | |
977 | try: |
|
977 | try: | |
978 | logname,logmode = par.split() |
|
978 | logname,logmode = par.split() | |
979 | except: |
|
979 | except: | |
980 | try: |
|
980 | try: | |
981 | logname = par |
|
981 | logname = par | |
982 | logmode = 'backup' |
|
982 | logmode = 'backup' | |
983 | except: |
|
983 | except: | |
984 | warn('Usage: %log [log_name [log_mode]]') |
|
984 | warn('Usage: %log [log_name [log_mode]]') | |
985 | return |
|
985 | return | |
986 | if not logmode in valid_modes: |
|
986 | if not logmode in valid_modes: | |
987 | warn('Logging NOT activated.\n' |
|
987 | warn('Logging NOT activated.\n' | |
988 | 'Usage: %log [log_name [log_mode]]\n' |
|
988 | 'Usage: %log [log_name [log_mode]]\n' | |
989 | 'Valid modes: '+str(valid_modes)) |
|
989 | 'Valid modes: '+str(valid_modes)) | |
990 | return |
|
990 | return | |
991 |
|
991 | |||
992 | # If we made it this far, I think we're ok: |
|
992 | # If we made it this far, I think we're ok: | |
993 | print 'Activating auto-logging.' |
|
993 | print 'Activating auto-logging.' | |
994 | print 'Current session state plus future input saved to:',logname |
|
994 | print 'Current session state plus future input saved to:',logname | |
995 | print 'Logging mode: ',logmode |
|
995 | print 'Logging mode: ',logmode | |
996 | # put logname into rc struct as if it had been called on the command line, |
|
996 | # put logname into rc struct as if it had been called on the command line, | |
997 | # so it ends up saved in the log header |
|
997 | # so it ends up saved in the log header | |
998 | # Save it in case we need to restore it... |
|
998 | # Save it in case we need to restore it... | |
999 | old_logfile = self.shell.rc.opts.get('logfile','') |
|
999 | old_logfile = self.shell.rc.opts.get('logfile','') | |
1000 | logname = os.path.expanduser(logname) |
|
1000 | logname = os.path.expanduser(logname) | |
1001 | self.shell.rc.opts.logfile = logname |
|
1001 | self.shell.rc.opts.logfile = logname | |
1002 | self.LOGMODE = logmode # FIXME: this should be set through a function. |
|
1002 | self.LOGMODE = logmode # FIXME: this should be set through a function. | |
1003 | try: |
|
1003 | try: | |
1004 | header = str(self.LOGHEAD) |
|
1004 | header = str(self.LOGHEAD) | |
1005 | self.create_log(header,logname) |
|
1005 | self.create_log(header,logname) | |
1006 | self.logstart(header,logname) |
|
1006 | self.logstart(header,logname) | |
1007 | except: |
|
1007 | except: | |
1008 | self.LOG = '' # we are NOT logging, something went wrong |
|
1008 | self.LOG = '' # we are NOT logging, something went wrong | |
1009 | self.shell.rc.opts.logfile = old_logfile |
|
1009 | self.shell.rc.opts.logfile = old_logfile | |
1010 | warn("Couldn't start log: "+str(sys.exc_info()[1])) |
|
1010 | warn("Couldn't start log: "+str(sys.exc_info()[1])) | |
1011 | else: # log input history up to this point |
|
1011 | else: # log input history up to this point | |
1012 | self.logfile.write(self.shell.user_ns['_ih'][1:]) |
|
1012 | self.logfile.write(self.shell.user_ns['_ih'][1:]) | |
1013 | self.logfile.flush() |
|
1013 | self.logfile.flush() | |
1014 |
|
1014 | |||
1015 | def magic_logoff(self,parameter_s=''): |
|
1015 | def magic_logoff(self,parameter_s=''): | |
1016 | """Temporarily stop logging. |
|
1016 | """Temporarily stop logging. | |
1017 |
|
1017 | |||
1018 | You must have previously started logging.""" |
|
1018 | You must have previously started logging.""" | |
1019 | self.switch_log(0) |
|
1019 | self.switch_log(0) | |
1020 |
|
1020 | |||
1021 | def magic_logon(self,parameter_s=''): |
|
1021 | def magic_logon(self,parameter_s=''): | |
1022 | """Restart logging. |
|
1022 | """Restart logging. | |
1023 |
|
1023 | |||
1024 | This function is for restarting logging which you've temporarily |
|
1024 | This function is for restarting logging which you've temporarily | |
1025 | stopped with %logoff. For starting logging for the first time, you |
|
1025 | stopped with %logoff. For starting logging for the first time, you | |
1026 | must use the %logstart function, which allows you to specify an |
|
1026 | must use the %logstart function, which allows you to specify an | |
1027 | optional log filename.""" |
|
1027 | optional log filename.""" | |
1028 |
|
1028 | |||
1029 | self.switch_log(1) |
|
1029 | self.switch_log(1) | |
1030 |
|
1030 | |||
1031 | def magic_logstate(self,parameter_s=''): |
|
1031 | def magic_logstate(self,parameter_s=''): | |
1032 | """Print the status of the logging system.""" |
|
1032 | """Print the status of the logging system.""" | |
1033 |
|
1033 | |||
1034 | self.logstate() |
|
1034 | self.logstate() | |
1035 |
|
1035 | |||
1036 | def magic_pdb(self, parameter_s=''): |
|
1036 | def magic_pdb(self, parameter_s=''): | |
1037 | """Control the calling of the pdb interactive debugger. |
|
1037 | """Control the calling of the pdb interactive debugger. | |
1038 |
|
1038 | |||
1039 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without |
|
1039 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without | |
1040 | argument it works as a toggle. |
|
1040 | argument it works as a toggle. | |
1041 |
|
1041 | |||
1042 | When an exception is triggered, IPython can optionally call the |
|
1042 | When an exception is triggered, IPython can optionally call the | |
1043 | interactive pdb debugger after the traceback printout. %pdb toggles |
|
1043 | interactive pdb debugger after the traceback printout. %pdb toggles | |
1044 | this feature on and off.""" |
|
1044 | this feature on and off.""" | |
1045 |
|
1045 | |||
1046 | par = parameter_s.strip().lower() |
|
1046 | par = parameter_s.strip().lower() | |
1047 |
|
1047 | |||
1048 | if par: |
|
1048 | if par: | |
1049 | try: |
|
1049 | try: | |
1050 | pdb = {'off':0,'0':0,'on':1,'1':1}[par] |
|
1050 | pdb = {'off':0,'0':0,'on':1,'1':1}[par] | |
1051 | except KeyError: |
|
1051 | except KeyError: | |
1052 | print 'Incorrect argument. Use on/1, off/0 or nothing for a toggle.' |
|
1052 | print 'Incorrect argument. Use on/1, off/0, or nothing for a toggle.' | |
1053 | return |
|
1053 | return | |
1054 | else: |
|
1054 | else: | |
1055 | self.shell.InteractiveTB.call_pdb = pdb |
|
1055 | self.shell.InteractiveTB.call_pdb = pdb | |
1056 | else: |
|
1056 | else: | |
1057 |
|
|
1057 | new_pdb = not self.shell.InteractiveTB.call_pdb | |
1058 | print 'Automatic pdb calling has been turned',\ |
|
1058 | self.shell.InteractiveTB.call_pdb = new_pdb | |
1059 |
|
|
1059 | if self.shell.isthreaded: | |
|
1060 | try: | |||
|
1061 | self.sys_excepthook.call_pdb = new_pdb | |||
|
1062 | except: | |||
|
1063 | warn('Failed to activate pdb for threaded exception handler') | |||
|
1064 | ||||
|
1065 | print 'Automatic pdb calling has been turned',on_off(new_pdb) | |||
|
1066 | ||||
1060 |
|
1067 | |||
1061 |
|
1068 | |||
1062 | def magic_prun(self, parameter_s ='',user_mode=1, |
|
1069 | def magic_prun(self, parameter_s ='',user_mode=1, | |
1063 | opts=None,arg_lst=None,prog_ns=None): |
|
1070 | opts=None,arg_lst=None,prog_ns=None): | |
1064 |
|
1071 | |||
1065 | """Run a statement through the python code profiler. |
|
1072 | """Run a statement through the python code profiler. | |
1066 |
|
1073 | |||
1067 | Usage:\\ |
|
1074 | Usage:\\ | |
1068 | %prun [options] statement |
|
1075 | %prun [options] statement | |
1069 |
|
1076 | |||
1070 | The given statement (which doesn't require quote marks) is run via the |
|
1077 | The given statement (which doesn't require quote marks) is run via the | |
1071 | python profiler in a manner similar to the profile.run() function. |
|
1078 | python profiler in a manner similar to the profile.run() function. | |
1072 | Namespaces are internally managed to work correctly; profile.run |
|
1079 | Namespaces are internally managed to work correctly; profile.run | |
1073 | cannot be used in IPython because it makes certain assumptions about |
|
1080 | cannot be used in IPython because it makes certain assumptions about | |
1074 | namespaces which do not hold under IPython. |
|
1081 | namespaces which do not hold under IPython. | |
1075 |
|
1082 | |||
1076 | Options: |
|
1083 | Options: | |
1077 |
|
1084 | |||
1078 | -l <limit>: you can place restrictions on what or how much of the |
|
1085 | -l <limit>: you can place restrictions on what or how much of the | |
1079 | profile gets printed. The limit value can be: |
|
1086 | profile gets printed. The limit value can be: | |
1080 |
|
1087 | |||
1081 | * A string: only information for function names containing this string |
|
1088 | * A string: only information for function names containing this string | |
1082 | is printed. |
|
1089 | is printed. | |
1083 |
|
1090 | |||
1084 | * An integer: only these many lines are printed. |
|
1091 | * An integer: only these many lines are printed. | |
1085 |
|
1092 | |||
1086 | * A float (between 0 and 1): this fraction of the report is printed |
|
1093 | * A float (between 0 and 1): this fraction of the report is printed | |
1087 | (for example, use a limit of 0.4 to see the topmost 40% only). |
|
1094 | (for example, use a limit of 0.4 to see the topmost 40% only). | |
1088 |
|
1095 | |||
1089 | You can combine several limits with repeated use of the option. For |
|
1096 | You can combine several limits with repeated use of the option. For | |
1090 | example, '-l __init__ -l 5' will print only the topmost 5 lines of |
|
1097 | example, '-l __init__ -l 5' will print only the topmost 5 lines of | |
1091 | information about class constructors. |
|
1098 | information about class constructors. | |
1092 |
|
1099 | |||
1093 | -r: return the pstats.Stats object generated by the profiling. This |
|
1100 | -r: return the pstats.Stats object generated by the profiling. This | |
1094 | object has all the information about the profile in it, and you can |
|
1101 | object has all the information about the profile in it, and you can | |
1095 | later use it for further analysis or in other functions. |
|
1102 | later use it for further analysis or in other functions. | |
1096 |
|
1103 | |||
1097 | Since magic functions have a particular form of calling which prevents |
|
1104 | Since magic functions have a particular form of calling which prevents | |
1098 | you from writing something like:\\ |
|
1105 | you from writing something like:\\ | |
1099 | In [1]: p = %prun -r print 4 # invalid!\\ |
|
1106 | In [1]: p = %prun -r print 4 # invalid!\\ | |
1100 | you must instead use IPython's automatic variables to assign this:\\ |
|
1107 | you must instead use IPython's automatic variables to assign this:\\ | |
1101 | In [1]: %prun -r print 4 \\ |
|
1108 | In [1]: %prun -r print 4 \\ | |
1102 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ |
|
1109 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ | |
1103 | In [2]: stats = _ |
|
1110 | In [2]: stats = _ | |
1104 |
|
1111 | |||
1105 | If you really need to assign this value via an explicit function call, |
|
1112 | If you really need to assign this value via an explicit function call, | |
1106 | you can always tap directly into the true name of the magic function |
|
1113 | you can always tap directly into the true name of the magic function | |
1107 | by using the ipmagic function (which IPython automatically adds to the |
|
1114 | by using the ipmagic function (which IPython automatically adds to the | |
1108 | builtins):\\ |
|
1115 | builtins):\\ | |
1109 | In [3]: stats = ipmagic('prun','-r print 4') |
|
1116 | In [3]: stats = ipmagic('prun','-r print 4') | |
1110 |
|
1117 | |||
1111 | You can type ipmagic? for more details on ipmagic. |
|
1118 | You can type ipmagic? for more details on ipmagic. | |
1112 |
|
1119 | |||
1113 | -s <key>: sort profile by given key. You can provide more than one key |
|
1120 | -s <key>: sort profile by given key. You can provide more than one key | |
1114 | by using the option several times: '-s key1 -s key2 -s key3...'. The |
|
1121 | by using the option several times: '-s key1 -s key2 -s key3...'. The | |
1115 | default sorting key is 'time'. |
|
1122 | default sorting key is 'time'. | |
1116 |
|
1123 | |||
1117 | The following is copied verbatim from the profile documentation |
|
1124 | The following is copied verbatim from the profile documentation | |
1118 | referenced below: |
|
1125 | referenced below: | |
1119 |
|
1126 | |||
1120 | When more than one key is provided, additional keys are used as |
|
1127 | When more than one key is provided, additional keys are used as | |
1121 | secondary criteria when the there is equality in all keys selected |
|
1128 | secondary criteria when the there is equality in all keys selected | |
1122 | before them. |
|
1129 | before them. | |
1123 |
|
1130 | |||
1124 | Abbreviations can be used for any key names, as long as the |
|
1131 | Abbreviations can be used for any key names, as long as the | |
1125 | abbreviation is unambiguous. The following are the keys currently |
|
1132 | abbreviation is unambiguous. The following are the keys currently | |
1126 | defined: |
|
1133 | defined: | |
1127 |
|
1134 | |||
1128 | Valid Arg Meaning\\ |
|
1135 | Valid Arg Meaning\\ | |
1129 | "calls" call count\\ |
|
1136 | "calls" call count\\ | |
1130 | "cumulative" cumulative time\\ |
|
1137 | "cumulative" cumulative time\\ | |
1131 | "file" file name\\ |
|
1138 | "file" file name\\ | |
1132 | "module" file name\\ |
|
1139 | "module" file name\\ | |
1133 | "pcalls" primitive call count\\ |
|
1140 | "pcalls" primitive call count\\ | |
1134 | "line" line number\\ |
|
1141 | "line" line number\\ | |
1135 | "name" function name\\ |
|
1142 | "name" function name\\ | |
1136 | "nfl" name/file/line\\ |
|
1143 | "nfl" name/file/line\\ | |
1137 | "stdname" standard name\\ |
|
1144 | "stdname" standard name\\ | |
1138 | "time" internal time |
|
1145 | "time" internal time | |
1139 |
|
1146 | |||
1140 | Note that all sorts on statistics are in descending order (placing |
|
1147 | Note that all sorts on statistics are in descending order (placing | |
1141 | most time consuming items first), where as name, file, and line number |
|
1148 | most time consuming items first), where as name, file, and line number | |
1142 | searches are in ascending order (i.e., alphabetical). The subtle |
|
1149 | searches are in ascending order (i.e., alphabetical). The subtle | |
1143 | distinction between "nfl" and "stdname" is that the standard name is a |
|
1150 | distinction between "nfl" and "stdname" is that the standard name is a | |
1144 | sort of the name as printed, which means that the embedded line |
|
1151 | sort of the name as printed, which means that the embedded line | |
1145 | numbers get compared in an odd way. For example, lines 3, 20, and 40 |
|
1152 | numbers get compared in an odd way. For example, lines 3, 20, and 40 | |
1146 | would (if the file names were the same) appear in the string order |
|
1153 | would (if the file names were the same) appear in the string order | |
1147 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the |
|
1154 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the | |
1148 | line numbers. In fact, sort_stats("nfl") is the same as |
|
1155 | line numbers. In fact, sort_stats("nfl") is the same as | |
1149 | sort_stats("name", "file", "line"). |
|
1156 | sort_stats("name", "file", "line"). | |
1150 |
|
1157 | |||
1151 | -T <filename>: save profile results as shown on screen to a text |
|
1158 | -T <filename>: save profile results as shown on screen to a text | |
1152 | file. The profile is still shown on screen. |
|
1159 | file. The profile is still shown on screen. | |
1153 |
|
1160 | |||
1154 | -D <filename>: save (via dump_stats) profile statistics to given |
|
1161 | -D <filename>: save (via dump_stats) profile statistics to given | |
1155 | filename. This data is in a format understod by the pstats module, and |
|
1162 | filename. This data is in a format understod by the pstats module, and | |
1156 | is generated by a call to the dump_stats() method of profile |
|
1163 | is generated by a call to the dump_stats() method of profile | |
1157 | objects. The profile is still shown on screen. |
|
1164 | objects. The profile is still shown on screen. | |
1158 |
|
1165 | |||
1159 | If you want to run complete programs under the profiler's control, use |
|
1166 | If you want to run complete programs under the profiler's control, use | |
1160 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts |
|
1167 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts | |
1161 | contains profiler specific options as described here. |
|
1168 | contains profiler specific options as described here. | |
1162 |
|
1169 | |||
1163 | You can read the complete documentation for the profile module with:\\ |
|
1170 | You can read the complete documentation for the profile module with:\\ | |
1164 | In [1]: import profile; profile.help() """ |
|
1171 | In [1]: import profile; profile.help() """ | |
1165 |
|
1172 | |||
1166 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) |
|
1173 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) | |
1167 | # protect user quote marks |
|
1174 | # protect user quote marks | |
1168 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") |
|
1175 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") | |
1169 |
|
1176 | |||
1170 | if user_mode: # regular user call |
|
1177 | if user_mode: # regular user call | |
1171 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', |
|
1178 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', | |
1172 | list_all=1) |
|
1179 | list_all=1) | |
1173 | namespace = self.shell.user_ns |
|
1180 | namespace = self.shell.user_ns | |
1174 | else: # called to run a program by %run -p |
|
1181 | else: # called to run a program by %run -p | |
1175 | try: |
|
1182 | try: | |
1176 | filename = get_py_filename(arg_lst[0]) |
|
1183 | filename = get_py_filename(arg_lst[0]) | |
1177 | except IOError,msg: |
|
1184 | except IOError,msg: | |
1178 | error(msg) |
|
1185 | error(msg) | |
1179 | return |
|
1186 | return | |
1180 |
|
1187 | |||
1181 | arg_str = 'execfile(filename,prog_ns)' |
|
1188 | arg_str = 'execfile(filename,prog_ns)' | |
1182 | namespace = locals() |
|
1189 | namespace = locals() | |
1183 |
|
1190 | |||
1184 | opts.merge(opts_def) |
|
1191 | opts.merge(opts_def) | |
1185 |
|
1192 | |||
1186 | prof = profile.Profile() |
|
1193 | prof = profile.Profile() | |
1187 | try: |
|
1194 | try: | |
1188 | prof = prof.runctx(arg_str,namespace,namespace) |
|
1195 | prof = prof.runctx(arg_str,namespace,namespace) | |
1189 | sys_exit = '' |
|
1196 | sys_exit = '' | |
1190 | except SystemExit: |
|
1197 | except SystemExit: | |
1191 | sys_exit = """*** SystemExit exception caught in code being profiled.""" |
|
1198 | sys_exit = """*** SystemExit exception caught in code being profiled.""" | |
1192 |
|
1199 | |||
1193 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) |
|
1200 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) | |
1194 |
|
1201 | |||
1195 | lims = opts.l |
|
1202 | lims = opts.l | |
1196 | if lims: |
|
1203 | if lims: | |
1197 | lims = [] # rebuild lims with ints/floats/strings |
|
1204 | lims = [] # rebuild lims with ints/floats/strings | |
1198 | for lim in opts.l: |
|
1205 | for lim in opts.l: | |
1199 | try: |
|
1206 | try: | |
1200 | lims.append(int(lim)) |
|
1207 | lims.append(int(lim)) | |
1201 | except ValueError: |
|
1208 | except ValueError: | |
1202 | try: |
|
1209 | try: | |
1203 | lims.append(float(lim)) |
|
1210 | lims.append(float(lim)) | |
1204 | except ValueError: |
|
1211 | except ValueError: | |
1205 | lims.append(lim) |
|
1212 | lims.append(lim) | |
1206 |
|
1213 | |||
1207 | # trap output |
|
1214 | # trap output | |
1208 | sys_stdout = sys.stdout |
|
1215 | sys_stdout = sys.stdout | |
1209 | stdout_trap = StringIO() |
|
1216 | stdout_trap = StringIO() | |
1210 | try: |
|
1217 | try: | |
1211 | sys.stdout = stdout_trap |
|
1218 | sys.stdout = stdout_trap | |
1212 | stats.print_stats(*lims) |
|
1219 | stats.print_stats(*lims) | |
1213 | finally: |
|
1220 | finally: | |
1214 | sys.stdout = sys_stdout |
|
1221 | sys.stdout = sys_stdout | |
1215 | output = stdout_trap.getvalue() |
|
1222 | output = stdout_trap.getvalue() | |
1216 | output = output.rstrip() |
|
1223 | output = output.rstrip() | |
1217 |
|
1224 | |||
1218 | page(output,screen_lines=self.shell.rc.screen_length) |
|
1225 | page(output,screen_lines=self.shell.rc.screen_length) | |
1219 | print sys_exit, |
|
1226 | print sys_exit, | |
1220 |
|
1227 | |||
1221 | dump_file = opts.D[0] |
|
1228 | dump_file = opts.D[0] | |
1222 | text_file = opts.T[0] |
|
1229 | text_file = opts.T[0] | |
1223 | if dump_file: |
|
1230 | if dump_file: | |
1224 | prof.dump_stats(dump_file) |
|
1231 | prof.dump_stats(dump_file) | |
1225 | print '\n*** Profile stats marshalled to file',\ |
|
1232 | print '\n*** Profile stats marshalled to file',\ | |
1226 | `dump_file`+'.',sys_exit |
|
1233 | `dump_file`+'.',sys_exit | |
1227 | if text_file: |
|
1234 | if text_file: | |
1228 | file(text_file,'w').write(output) |
|
1235 | file(text_file,'w').write(output) | |
1229 | print '\n*** Profile printout saved to text file',\ |
|
1236 | print '\n*** Profile printout saved to text file',\ | |
1230 | `text_file`+'.',sys_exit |
|
1237 | `text_file`+'.',sys_exit | |
1231 |
|
1238 | |||
1232 | if opts.has_key('r'): |
|
1239 | if opts.has_key('r'): | |
1233 | return stats |
|
1240 | return stats | |
1234 | else: |
|
1241 | else: | |
1235 | return None |
|
1242 | return None | |
1236 |
|
1243 | |||
1237 | def magic_run(self, parameter_s ='',runner=None): |
|
1244 | def magic_run(self, parameter_s ='',runner=None): | |
1238 | """Run the named file inside IPython as a program. |
|
1245 | """Run the named file inside IPython as a program. | |
1239 |
|
1246 | |||
1240 | Usage:\\ |
|
1247 | Usage:\\ | |
1241 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] |
|
1248 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] | |
1242 |
|
1249 | |||
1243 | Parameters after the filename are passed as command-line arguments to |
|
1250 | Parameters after the filename are passed as command-line arguments to | |
1244 | the program (put in sys.argv). Then, control returns to IPython's |
|
1251 | the program (put in sys.argv). Then, control returns to IPython's | |
1245 | prompt. |
|
1252 | prompt. | |
1246 |
|
1253 | |||
1247 | This is similar to running at a system prompt:\\ |
|
1254 | This is similar to running at a system prompt:\\ | |
1248 | $ python file args\\ |
|
1255 | $ python file args\\ | |
1249 | but with the advantage of giving you IPython's tracebacks, and of |
|
1256 | but with the advantage of giving you IPython's tracebacks, and of | |
1250 | loading all variables into your interactive namespace for further use |
|
1257 | loading all variables into your interactive namespace for further use | |
1251 | (unless -p is used, see below). |
|
1258 | (unless -p is used, see below). | |
1252 |
|
1259 | |||
1253 | The file is executed in a namespace initially consisting only of |
|
1260 | The file is executed in a namespace initially consisting only of | |
1254 | __name__=='__main__' and sys.argv constructed as indicated. It thus |
|
1261 | __name__=='__main__' and sys.argv constructed as indicated. It thus | |
1255 | sees its environment as if it were being run as a stand-alone |
|
1262 | sees its environment as if it were being run as a stand-alone | |
1256 | program. But after execution, the IPython interactive namespace gets |
|
1263 | program. But after execution, the IPython interactive namespace gets | |
1257 | updated with all variables defined in the program (except for __name__ |
|
1264 | updated with all variables defined in the program (except for __name__ | |
1258 | and sys.argv). This allows for very convenient loading of code for |
|
1265 | and sys.argv). This allows for very convenient loading of code for | |
1259 | interactive work, while giving each program a 'clean sheet' to run in. |
|
1266 | interactive work, while giving each program a 'clean sheet' to run in. | |
1260 |
|
1267 | |||
1261 | Options: |
|
1268 | Options: | |
1262 |
|
1269 | |||
1263 | -n: __name__ is NOT set to '__main__', but to the running file's name |
|
1270 | -n: __name__ is NOT set to '__main__', but to the running file's name | |
1264 | without extension (as python does under import). This allows running |
|
1271 | without extension (as python does under import). This allows running | |
1265 | scripts and reloading the definitions in them without calling code |
|
1272 | scripts and reloading the definitions in them without calling code | |
1266 | protected by an ' if __name__ == "__main__" ' clause. |
|
1273 | protected by an ' if __name__ == "__main__" ' clause. | |
1267 |
|
1274 | |||
1268 | -i: run the file in IPython's namespace instead of an empty one. This |
|
1275 | -i: run the file in IPython's namespace instead of an empty one. This | |
1269 | is useful if you are experimenting with code written in a text editor |
|
1276 | is useful if you are experimenting with code written in a text editor | |
1270 | which depends on variables defined interactively. |
|
1277 | which depends on variables defined interactively. | |
1271 |
|
1278 | |||
1272 | -e: ignore sys.exit() calls or SystemExit exceptions in the script |
|
1279 | -e: ignore sys.exit() calls or SystemExit exceptions in the script | |
1273 | being run. This is particularly useful if IPython is being used to |
|
1280 | being run. This is particularly useful if IPython is being used to | |
1274 | run unittests, which always exit with a sys.exit() call. In such |
|
1281 | run unittests, which always exit with a sys.exit() call. In such | |
1275 | cases you are interested in the output of the test results, not in |
|
1282 | cases you are interested in the output of the test results, not in | |
1276 | seeing a traceback of the unittest module. |
|
1283 | seeing a traceback of the unittest module. | |
1277 |
|
1284 | |||
1278 | -t: print timing information at the end of the run. IPython will give |
|
1285 | -t: print timing information at the end of the run. IPython will give | |
1279 | you an estimated CPU time consumption for your script, which under |
|
1286 | you an estimated CPU time consumption for your script, which under | |
1280 | Unix uses the resource module to avoid the wraparound problems of |
|
1287 | Unix uses the resource module to avoid the wraparound problems of | |
1281 | time.clock(). Under Unix, an estimate of time spent on system tasks |
|
1288 | time.clock(). Under Unix, an estimate of time spent on system tasks | |
1282 | is also given (for Windows platforms this is reported as 0.0). |
|
1289 | is also given (for Windows platforms this is reported as 0.0). | |
1283 |
|
1290 | |||
1284 | If -t is given, an additional -N<N> option can be given, where <N> |
|
1291 | If -t is given, an additional -N<N> option can be given, where <N> | |
1285 | must be an integer indicating how many times you want the script to |
|
1292 | must be an integer indicating how many times you want the script to | |
1286 | run. The final timing report will include total and per run results. |
|
1293 | run. The final timing report will include total and per run results. | |
1287 |
|
1294 | |||
1288 | For example (testing the script uniq_stable.py): |
|
1295 | For example (testing the script uniq_stable.py): | |
1289 |
|
1296 | |||
1290 | In [1]: run -t uniq_stable |
|
1297 | In [1]: run -t uniq_stable | |
1291 |
|
1298 | |||
1292 | IPython CPU timings (estimated):\\ |
|
1299 | IPython CPU timings (estimated):\\ | |
1293 | User : 0.19597 s.\\ |
|
1300 | User : 0.19597 s.\\ | |
1294 | System: 0.0 s.\\ |
|
1301 | System: 0.0 s.\\ | |
1295 |
|
1302 | |||
1296 | In [2]: run -t -N5 uniq_stable |
|
1303 | In [2]: run -t -N5 uniq_stable | |
1297 |
|
1304 | |||
1298 | IPython CPU timings (estimated):\\ |
|
1305 | IPython CPU timings (estimated):\\ | |
1299 | Total runs performed: 5\\ |
|
1306 | Total runs performed: 5\\ | |
1300 | Times : Total Per run\\ |
|
1307 | Times : Total Per run\\ | |
1301 | User : 0.910862 s, 0.1821724 s.\\ |
|
1308 | User : 0.910862 s, 0.1821724 s.\\ | |
1302 | System: 0.0 s, 0.0 s. |
|
1309 | System: 0.0 s, 0.0 s. | |
1303 |
|
1310 | |||
1304 | -d: run your program under the control of pdb, the Python debugger. |
|
1311 | -d: run your program under the control of pdb, the Python debugger. | |
1305 | This allows you to execute your program step by step, watch variables, |
|
1312 | This allows you to execute your program step by step, watch variables, | |
1306 | etc. Internally, what IPython does is similar to calling: |
|
1313 | etc. Internally, what IPython does is similar to calling: | |
1307 |
|
1314 | |||
1308 | pdb.run('execfile("YOURFILENAME")') |
|
1315 | pdb.run('execfile("YOURFILENAME")') | |
1309 |
|
1316 | |||
1310 | with a breakpoint set on line 1 of your file. You can change the line |
|
1317 | with a breakpoint set on line 1 of your file. You can change the line | |
1311 | number for this automatic breakpoint to be <N> by using the -bN option |
|
1318 | number for this automatic breakpoint to be <N> by using the -bN option | |
1312 | (where N must be an integer). For example: |
|
1319 | (where N must be an integer). For example: | |
1313 |
|
1320 | |||
1314 | %run -d -b40 myscript |
|
1321 | %run -d -b40 myscript | |
1315 |
|
1322 | |||
1316 | will set the first breakpoint at line 40 in myscript.py. Note that |
|
1323 | will set the first breakpoint at line 40 in myscript.py. Note that | |
1317 | the first breakpoint must be set on a line which actually does |
|
1324 | the first breakpoint must be set on a line which actually does | |
1318 | something (not a comment or docstring) for it to stop execution. |
|
1325 | something (not a comment or docstring) for it to stop execution. | |
1319 |
|
1326 | |||
1320 | When the pdb debugger starts, you will see a (Pdb) prompt. You must |
|
1327 | When the pdb debugger starts, you will see a (Pdb) prompt. You must | |
1321 | first enter 'c' (without qoutes) to start execution up to the first |
|
1328 | first enter 'c' (without qoutes) to start execution up to the first | |
1322 | breakpoint. |
|
1329 | breakpoint. | |
1323 |
|
1330 | |||
1324 | Entering 'help' gives information about the use of the debugger. You |
|
1331 | Entering 'help' gives information about the use of the debugger. You | |
1325 | can easily see pdb's full documentation with "import pdb;pdb.help()" |
|
1332 | can easily see pdb's full documentation with "import pdb;pdb.help()" | |
1326 | at a prompt. |
|
1333 | at a prompt. | |
1327 |
|
1334 | |||
1328 | -p: run program under the control of the Python profiler module (which |
|
1335 | -p: run program under the control of the Python profiler module (which | |
1329 | prints a detailed report of execution times, function calls, etc). |
|
1336 | prints a detailed report of execution times, function calls, etc). | |
1330 |
|
1337 | |||
1331 | You can pass other options after -p which affect the behavior of the |
|
1338 | You can pass other options after -p which affect the behavior of the | |
1332 | profiler itself. See the docs for %prun for details. |
|
1339 | profiler itself. See the docs for %prun for details. | |
1333 |
|
1340 | |||
1334 | In this mode, the program's variables do NOT propagate back to the |
|
1341 | In this mode, the program's variables do NOT propagate back to the | |
1335 | IPython interactive namespace (because they remain in the namespace |
|
1342 | IPython interactive namespace (because they remain in the namespace | |
1336 | where the profiler executes them). |
|
1343 | where the profiler executes them). | |
1337 |
|
1344 | |||
1338 | Internally this triggers a call to %prun, see its documentation for |
|
1345 | Internally this triggers a call to %prun, see its documentation for | |
1339 | details on the options available specifically for profiling.""" |
|
1346 | details on the options available specifically for profiling.""" | |
1340 |
|
1347 | |||
1341 | # get arguments and set sys.argv for program to be run. |
|
1348 | # get arguments and set sys.argv for program to be run. | |
1342 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', |
|
1349 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', | |
1343 | mode='list',list_all=1) |
|
1350 | mode='list',list_all=1) | |
1344 |
|
1351 | |||
1345 | try: |
|
1352 | try: | |
1346 | filename = get_py_filename(arg_lst[0]) |
|
1353 | filename = get_py_filename(arg_lst[0]) | |
1347 | except IndexError: |
|
1354 | except IndexError: | |
1348 | warn('you must provide at least a filename.') |
|
1355 | warn('you must provide at least a filename.') | |
1349 | print '\n%run:\n',OInspect.getdoc(self.magic_run) |
|
1356 | print '\n%run:\n',OInspect.getdoc(self.magic_run) | |
1350 | return |
|
1357 | return | |
1351 | except IOError,msg: |
|
1358 | except IOError,msg: | |
1352 | error(msg) |
|
1359 | error(msg) | |
1353 | return |
|
1360 | return | |
1354 |
|
1361 | |||
1355 | # Control the response to exit() calls made by the script being run |
|
1362 | # Control the response to exit() calls made by the script being run | |
1356 | exit_ignore = opts.has_key('e') |
|
1363 | exit_ignore = opts.has_key('e') | |
1357 |
|
1364 | |||
1358 | # Make sure that the running script gets a proper sys.argv as if it |
|
1365 | # Make sure that the running script gets a proper sys.argv as if it | |
1359 | # were run from a system shell. |
|
1366 | # were run from a system shell. | |
1360 | save_argv = sys.argv # save it for later restoring |
|
1367 | save_argv = sys.argv # save it for later restoring | |
1361 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename |
|
1368 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename | |
1362 |
|
1369 | |||
1363 | if opts.has_key('i'): |
|
1370 | if opts.has_key('i'): | |
1364 | prog_ns = self.shell.user_ns |
|
1371 | prog_ns = self.shell.user_ns | |
1365 | __name__save = self.shell.user_ns['__name__'] |
|
1372 | __name__save = self.shell.user_ns['__name__'] | |
1366 | prog_ns['__name__'] = '__main__' |
|
1373 | prog_ns['__name__'] = '__main__' | |
1367 | else: |
|
1374 | else: | |
1368 | if opts.has_key('n'): |
|
1375 | if opts.has_key('n'): | |
1369 | name = os.path.splitext(os.path.basename(filename))[0] |
|
1376 | name = os.path.splitext(os.path.basename(filename))[0] | |
1370 | else: |
|
1377 | else: | |
1371 | name = '__main__' |
|
1378 | name = '__main__' | |
1372 | prog_ns = {'__name__':name} |
|
1379 | prog_ns = {'__name__':name} | |
1373 |
|
1380 | |||
1374 | # pickle fix. See iplib for an explanation |
|
1381 | # pickle fix. See iplib for an explanation | |
1375 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) |
|
1382 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) | |
1376 |
|
1383 | |||
1377 | stats = None |
|
1384 | stats = None | |
1378 | try: |
|
1385 | try: | |
1379 | if opts.has_key('p'): |
|
1386 | if opts.has_key('p'): | |
1380 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) |
|
1387 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) | |
1381 | else: |
|
1388 | else: | |
1382 | if opts.has_key('d'): |
|
1389 | if opts.has_key('d'): | |
1383 | deb = Debugger.Pdb(self.shell.rc.colors) |
|
1390 | deb = Debugger.Pdb(self.shell.rc.colors) | |
1384 | # reset Breakpoint state, which is moronically kept |
|
1391 | # reset Breakpoint state, which is moronically kept | |
1385 | # in a class |
|
1392 | # in a class | |
1386 | bdb.Breakpoint.next = 1 |
|
1393 | bdb.Breakpoint.next = 1 | |
1387 | bdb.Breakpoint.bplist = {} |
|
1394 | bdb.Breakpoint.bplist = {} | |
1388 | bdb.Breakpoint.bpbynumber = [None] |
|
1395 | bdb.Breakpoint.bpbynumber = [None] | |
1389 | # Set an initial breakpoint to stop execution |
|
1396 | # Set an initial breakpoint to stop execution | |
1390 | maxtries = 10 |
|
1397 | maxtries = 10 | |
1391 | bp = int(opts.get('b',[1])[0]) |
|
1398 | bp = int(opts.get('b',[1])[0]) | |
1392 | checkline = deb.checkline(filename,bp) |
|
1399 | checkline = deb.checkline(filename,bp) | |
1393 | if not checkline: |
|
1400 | if not checkline: | |
1394 | for bp in range(bp+1,bp+maxtries+1): |
|
1401 | for bp in range(bp+1,bp+maxtries+1): | |
1395 | if deb.checkline(filename,bp): |
|
1402 | if deb.checkline(filename,bp): | |
1396 | break |
|
1403 | break | |
1397 | else: |
|
1404 | else: | |
1398 | msg = ("\nI failed to find a valid line to set " |
|
1405 | msg = ("\nI failed to find a valid line to set " | |
1399 | "a breakpoint\n" |
|
1406 | "a breakpoint\n" | |
1400 | "after trying up to line: %s.\n" |
|
1407 | "after trying up to line: %s.\n" | |
1401 | "Please set a valid breakpoint manually " |
|
1408 | "Please set a valid breakpoint manually " | |
1402 | "with the -b option." % bp) |
|
1409 | "with the -b option." % bp) | |
1403 | error(msg) |
|
1410 | error(msg) | |
1404 | return |
|
1411 | return | |
1405 | # if we find a good linenumber, set the breakpoint |
|
1412 | # if we find a good linenumber, set the breakpoint | |
1406 | deb.do_break('%s:%s' % (filename,bp)) |
|
1413 | deb.do_break('%s:%s' % (filename,bp)) | |
1407 | # Start file run |
|
1414 | # Start file run | |
1408 | print "NOTE: Enter 'c' at the", |
|
1415 | print "NOTE: Enter 'c' at the", | |
1409 | print "ipdb> prompt to start your script." |
|
1416 | print "ipdb> prompt to start your script." | |
1410 | try: |
|
1417 | try: | |
1411 | deb.run('execfile("%s")' % filename,prog_ns) |
|
1418 | deb.run('execfile("%s")' % filename,prog_ns) | |
1412 | except: |
|
1419 | except: | |
1413 | etype, value, tb = sys.exc_info() |
|
1420 | etype, value, tb = sys.exc_info() | |
1414 | # Skip three frames in the traceback: the %run one, |
|
1421 | # Skip three frames in the traceback: the %run one, | |
1415 | # one inside bdb.py, and the command-line typed by the |
|
1422 | # one inside bdb.py, and the command-line typed by the | |
1416 | # user (run by exec in pdb itself). |
|
1423 | # user (run by exec in pdb itself). | |
1417 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) |
|
1424 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) | |
1418 | else: |
|
1425 | else: | |
1419 | if runner is None: |
|
1426 | if runner is None: | |
1420 | runner = self.shell.safe_execfile |
|
1427 | runner = self.shell.safe_execfile | |
1421 | if opts.has_key('t'): |
|
1428 | if opts.has_key('t'): | |
1422 | try: |
|
1429 | try: | |
1423 | nruns = int(opts['N'][0]) |
|
1430 | nruns = int(opts['N'][0]) | |
1424 | if nruns < 1: |
|
1431 | if nruns < 1: | |
1425 | error('Number of runs must be >=1') |
|
1432 | error('Number of runs must be >=1') | |
1426 | return |
|
1433 | return | |
1427 | except (KeyError): |
|
1434 | except (KeyError): | |
1428 | nruns = 1 |
|
1435 | nruns = 1 | |
1429 | if nruns == 1: |
|
1436 | if nruns == 1: | |
1430 | t0 = clock2() |
|
1437 | t0 = clock2() | |
1431 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1438 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1432 | t1 = clock2() |
|
1439 | t1 = clock2() | |
1433 | t_usr = t1[0]-t0[0] |
|
1440 | t_usr = t1[0]-t0[0] | |
1434 | t_sys = t1[1]-t1[1] |
|
1441 | t_sys = t1[1]-t1[1] | |
1435 | print "\nIPython CPU timings (estimated):" |
|
1442 | print "\nIPython CPU timings (estimated):" | |
1436 | print " User : %10s s." % t_usr |
|
1443 | print " User : %10s s." % t_usr | |
1437 | print " System: %10s s." % t_sys |
|
1444 | print " System: %10s s." % t_sys | |
1438 | else: |
|
1445 | else: | |
1439 | runs = range(nruns) |
|
1446 | runs = range(nruns) | |
1440 | t0 = clock2() |
|
1447 | t0 = clock2() | |
1441 | for nr in runs: |
|
1448 | for nr in runs: | |
1442 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1449 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1443 | t1 = clock2() |
|
1450 | t1 = clock2() | |
1444 | t_usr = t1[0]-t0[0] |
|
1451 | t_usr = t1[0]-t0[0] | |
1445 | t_sys = t1[1]-t1[1] |
|
1452 | t_sys = t1[1]-t1[1] | |
1446 | print "\nIPython CPU timings (estimated):" |
|
1453 | print "\nIPython CPU timings (estimated):" | |
1447 | print "Total runs performed:",nruns |
|
1454 | print "Total runs performed:",nruns | |
1448 | print " Times : %10s %10s" % ('Total','Per run') |
|
1455 | print " Times : %10s %10s" % ('Total','Per run') | |
1449 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) |
|
1456 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) | |
1450 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) |
|
1457 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) | |
1451 |
|
1458 | |||
1452 | else: |
|
1459 | else: | |
1453 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1460 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1454 | if opts.has_key('i'): |
|
1461 | if opts.has_key('i'): | |
1455 | self.shell.user_ns['__name__'] = __name__save |
|
1462 | self.shell.user_ns['__name__'] = __name__save | |
1456 | else: |
|
1463 | else: | |
1457 | # update IPython interactive namespace |
|
1464 | # update IPython interactive namespace | |
1458 | del prog_ns['__name__'] |
|
1465 | del prog_ns['__name__'] | |
1459 | self.shell.user_ns.update(prog_ns) |
|
1466 | self.shell.user_ns.update(prog_ns) | |
1460 | finally: |
|
1467 | finally: | |
1461 | sys.argv = save_argv |
|
1468 | sys.argv = save_argv | |
1462 | return stats |
|
1469 | return stats | |
1463 |
|
1470 | |||
1464 | def magic_runlog(self, parameter_s =''): |
|
1471 | def magic_runlog(self, parameter_s =''): | |
1465 | """Run files as logs. |
|
1472 | """Run files as logs. | |
1466 |
|
1473 | |||
1467 | Usage:\\ |
|
1474 | Usage:\\ | |
1468 | %runlog file1 file2 ... |
|
1475 | %runlog file1 file2 ... | |
1469 |
|
1476 | |||
1470 | Run the named files (treating them as log files) in sequence inside |
|
1477 | Run the named files (treating them as log files) in sequence inside | |
1471 | the interpreter, and return to the prompt. This is much slower than |
|
1478 | the interpreter, and return to the prompt. This is much slower than | |
1472 | %run because each line is executed in a try/except block, but it |
|
1479 | %run because each line is executed in a try/except block, but it | |
1473 | allows running files with syntax errors in them. |
|
1480 | allows running files with syntax errors in them. | |
1474 |
|
1481 | |||
1475 | Normally IPython will guess when a file is one of its own logfiles, so |
|
1482 | Normally IPython will guess when a file is one of its own logfiles, so | |
1476 | you can typically use %run even for logs. This shorthand allows you to |
|
1483 | you can typically use %run even for logs. This shorthand allows you to | |
1477 | force any file to be treated as a log file.""" |
|
1484 | force any file to be treated as a log file.""" | |
1478 |
|
1485 | |||
1479 | for f in parameter_s.split(): |
|
1486 | for f in parameter_s.split(): | |
1480 | self.shell.safe_execfile(f,self.shell.user_ns, |
|
1487 | self.shell.safe_execfile(f,self.shell.user_ns, | |
1481 | self.shell.user_ns,islog=1) |
|
1488 | self.shell.user_ns,islog=1) | |
1482 |
|
1489 | |||
1483 | def magic_time(self,parameter_s = ''): |
|
1490 | def magic_time(self,parameter_s = ''): | |
1484 | """Time execution of a Python statement or expression. |
|
1491 | """Time execution of a Python statement or expression. | |
1485 |
|
1492 | |||
1486 | The CPU and wall clock times are printed, and the value of the |
|
1493 | The CPU and wall clock times are printed, and the value of the | |
1487 | expression (if any) is returned. Note that under Win32, system time |
|
1494 | expression (if any) is returned. Note that under Win32, system time | |
1488 | is always reported as 0, since it can not be measured. |
|
1495 | is always reported as 0, since it can not be measured. | |
1489 |
|
1496 | |||
1490 | This function provides very basic timing functionality. In Python |
|
1497 | This function provides very basic timing functionality. In Python | |
1491 | 2.3, the timeit module offers more control and sophistication, but for |
|
1498 | 2.3, the timeit module offers more control and sophistication, but for | |
1492 | now IPython supports Python 2.2, so we can not rely on timeit being |
|
1499 | now IPython supports Python 2.2, so we can not rely on timeit being | |
1493 | present. |
|
1500 | present. | |
1494 |
|
1501 | |||
1495 | Some examples: |
|
1502 | Some examples: | |
1496 |
|
1503 | |||
1497 | In [1]: time 2**128 |
|
1504 | In [1]: time 2**128 | |
1498 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1505 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1499 | Wall time: 0.00 |
|
1506 | Wall time: 0.00 | |
1500 | Out[1]: 340282366920938463463374607431768211456L |
|
1507 | Out[1]: 340282366920938463463374607431768211456L | |
1501 |
|
1508 | |||
1502 | In [2]: n = 1000000 |
|
1509 | In [2]: n = 1000000 | |
1503 |
|
1510 | |||
1504 | In [3]: time sum(range(n)) |
|
1511 | In [3]: time sum(range(n)) | |
1505 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s |
|
1512 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s | |
1506 | Wall time: 1.37 |
|
1513 | Wall time: 1.37 | |
1507 | Out[3]: 499999500000L |
|
1514 | Out[3]: 499999500000L | |
1508 |
|
1515 | |||
1509 | In [4]: time print 'hello world' |
|
1516 | In [4]: time print 'hello world' | |
1510 | hello world |
|
1517 | hello world | |
1511 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1518 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1512 | Wall time: 0.00 |
|
1519 | Wall time: 0.00 | |
1513 | """ |
|
1520 | """ | |
1514 |
|
1521 | |||
1515 | # fail immediately if the given expression can't be compiled |
|
1522 | # fail immediately if the given expression can't be compiled | |
1516 | try: |
|
1523 | try: | |
1517 | mode = 'eval' |
|
1524 | mode = 'eval' | |
1518 | code = compile(parameter_s,'<timed eval>',mode) |
|
1525 | code = compile(parameter_s,'<timed eval>',mode) | |
1519 | except SyntaxError: |
|
1526 | except SyntaxError: | |
1520 | mode = 'exec' |
|
1527 | mode = 'exec' | |
1521 | code = compile(parameter_s,'<timed exec>',mode) |
|
1528 | code = compile(parameter_s,'<timed exec>',mode) | |
1522 | # skew measurement as little as possible |
|
1529 | # skew measurement as little as possible | |
1523 | glob = self.shell.user_ns |
|
1530 | glob = self.shell.user_ns | |
1524 | clk = clock2 |
|
1531 | clk = clock2 | |
1525 | wtime = time.time |
|
1532 | wtime = time.time | |
1526 | # time execution |
|
1533 | # time execution | |
1527 | wall_st = wtime() |
|
1534 | wall_st = wtime() | |
1528 | if mode=='eval': |
|
1535 | if mode=='eval': | |
1529 | st = clk() |
|
1536 | st = clk() | |
1530 | out = eval(code,glob) |
|
1537 | out = eval(code,glob) | |
1531 | end = clk() |
|
1538 | end = clk() | |
1532 | else: |
|
1539 | else: | |
1533 | st = clk() |
|
1540 | st = clk() | |
1534 | exec code in glob |
|
1541 | exec code in glob | |
1535 | end = clk() |
|
1542 | end = clk() | |
1536 | out = None |
|
1543 | out = None | |
1537 | wall_end = wtime() |
|
1544 | wall_end = wtime() | |
1538 | # Compute actual times and report |
|
1545 | # Compute actual times and report | |
1539 | wall_time = wall_end-wall_st |
|
1546 | wall_time = wall_end-wall_st | |
1540 | cpu_user = end[0]-st[0] |
|
1547 | cpu_user = end[0]-st[0] | |
1541 | cpu_sys = end[1]-st[1] |
|
1548 | cpu_sys = end[1]-st[1] | |
1542 | cpu_tot = cpu_user+cpu_sys |
|
1549 | cpu_tot = cpu_user+cpu_sys | |
1543 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ |
|
1550 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ | |
1544 | (cpu_user,cpu_sys,cpu_tot) |
|
1551 | (cpu_user,cpu_sys,cpu_tot) | |
1545 | print "Wall time: %.2f" % wall_time |
|
1552 | print "Wall time: %.2f" % wall_time | |
1546 | return out |
|
1553 | return out | |
1547 |
|
1554 | |||
1548 | def magic_macro(self,parameter_s = ''): |
|
1555 | def magic_macro(self,parameter_s = ''): | |
1549 | """Define a set of input lines as a macro for future re-execution. |
|
1556 | """Define a set of input lines as a macro for future re-execution. | |
1550 |
|
1557 | |||
1551 | Usage:\\ |
|
1558 | Usage:\\ | |
1552 | %macro name n1:n2 n3:n4 ... n5 .. n6 ... |
|
1559 | %macro name n1:n2 n3:n4 ... n5 .. n6 ... | |
1553 |
|
1560 | |||
1554 | This will define a global variable called `name` which is a string |
|
1561 | This will define a global variable called `name` which is a string | |
1555 | made of joining the slices and lines you specify (n1,n2,... numbers |
|
1562 | made of joining the slices and lines you specify (n1,n2,... numbers | |
1556 | above) from your input history into a single string. This variable |
|
1563 | above) from your input history into a single string. This variable | |
1557 | acts like an automatic function which re-executes those lines as if |
|
1564 | acts like an automatic function which re-executes those lines as if | |
1558 | you had typed them. You just type 'name' at the prompt and the code |
|
1565 | you had typed them. You just type 'name' at the prompt and the code | |
1559 | executes. |
|
1566 | executes. | |
1560 |
|
1567 | |||
1561 | Note that the slices use the standard Python slicing notation (5:8 |
|
1568 | Note that the slices use the standard Python slicing notation (5:8 | |
1562 | means include lines numbered 5,6,7). |
|
1569 | means include lines numbered 5,6,7). | |
1563 |
|
1570 | |||
1564 | For example, if your history contains (%hist prints it): |
|
1571 | For example, if your history contains (%hist prints it): | |
1565 |
|
1572 | |||
1566 | 44: x=1\\ |
|
1573 | 44: x=1\\ | |
1567 | 45: y=3\\ |
|
1574 | 45: y=3\\ | |
1568 | 46: z=x+y\\ |
|
1575 | 46: z=x+y\\ | |
1569 | 47: print x\\ |
|
1576 | 47: print x\\ | |
1570 | 48: a=5\\ |
|
1577 | 48: a=5\\ | |
1571 | 49: print 'x',x,'y',y\\ |
|
1578 | 49: print 'x',x,'y',y\\ | |
1572 |
|
1579 | |||
1573 | you can create a macro with lines 44 through 47 (included) and line 49 |
|
1580 | you can create a macro with lines 44 through 47 (included) and line 49 | |
1574 | called my_macro with: |
|
1581 | called my_macro with: | |
1575 |
|
1582 | |||
1576 | In [51]: %macro my_macro 44:48 49 |
|
1583 | In [51]: %macro my_macro 44:48 49 | |
1577 |
|
1584 | |||
1578 | Now, typing `my_macro` (without quotes) will re-execute all this code |
|
1585 | Now, typing `my_macro` (without quotes) will re-execute all this code | |
1579 | in one pass. |
|
1586 | in one pass. | |
1580 |
|
1587 | |||
1581 | You don't need to give the line-numbers in order, and any given line |
|
1588 | You don't need to give the line-numbers in order, and any given line | |
1582 | number can appear multiple times. You can assemble macros with any |
|
1589 | number can appear multiple times. You can assemble macros with any | |
1583 | lines from your input history in any order. |
|
1590 | lines from your input history in any order. | |
1584 |
|
1591 | |||
1585 | The macro is a simple object which holds its value in an attribute, |
|
1592 | The macro is a simple object which holds its value in an attribute, | |
1586 | but IPython's display system checks for macros and executes them as |
|
1593 | but IPython's display system checks for macros and executes them as | |
1587 | code instead of printing them when you type their name. |
|
1594 | code instead of printing them when you type their name. | |
1588 |
|
1595 | |||
1589 | You can view a macro's contents by explicitly printing it with: |
|
1596 | You can view a macro's contents by explicitly printing it with: | |
1590 |
|
1597 | |||
1591 | 'print macro_name'. |
|
1598 | 'print macro_name'. | |
1592 |
|
1599 | |||
1593 | For one-off cases which DON'T contain magic function calls in them you |
|
1600 | For one-off cases which DON'T contain magic function calls in them you | |
1594 | can obtain similar results by explicitly executing slices from your |
|
1601 | can obtain similar results by explicitly executing slices from your | |
1595 | input history with: |
|
1602 | input history with: | |
1596 |
|
1603 | |||
1597 | In [60]: exec In[44:48]+In[49]""" |
|
1604 | In [60]: exec In[44:48]+In[49]""" | |
1598 |
|
1605 | |||
1599 | args = parameter_s.split() |
|
1606 | args = parameter_s.split() | |
1600 | name,ranges = args[0], args[1:] |
|
1607 | name,ranges = args[0], args[1:] | |
1601 | #print 'rng',ranges # dbg |
|
1608 | #print 'rng',ranges # dbg | |
1602 | cmds = self.extract_input_slices(ranges) |
|
1609 | cmds = self.extract_input_slices(ranges) | |
1603 | macro = Macro(cmds) |
|
1610 | macro = Macro(cmds) | |
1604 | self.shell.user_ns.update({name:macro}) |
|
1611 | self.shell.user_ns.update({name:macro}) | |
1605 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name |
|
1612 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name | |
1606 | print 'Macro contents:' |
|
1613 | print 'Macro contents:' | |
1607 | print str(macro).rstrip(), |
|
1614 | print str(macro).rstrip(), | |
1608 |
|
1615 | |||
1609 | def magic_save(self,parameter_s = ''): |
|
1616 | def magic_save(self,parameter_s = ''): | |
1610 | """Save a set of lines to a given filename. |
|
1617 | """Save a set of lines to a given filename. | |
1611 |
|
1618 | |||
1612 | Usage:\\ |
|
1619 | Usage:\\ | |
1613 | %save filename n1:n2 n3:n4 ... n5 .. n6 ... |
|
1620 | %save filename n1:n2 n3:n4 ... n5 .. n6 ... | |
1614 |
|
1621 | |||
1615 | This function uses the same syntax as %macro for line extraction, but |
|
1622 | This function uses the same syntax as %macro for line extraction, but | |
1616 | instead of creating a macro it saves the resulting string to the |
|
1623 | instead of creating a macro it saves the resulting string to the | |
1617 | filename you specify. |
|
1624 | filename you specify. | |
1618 |
|
1625 | |||
1619 | It adds a '.py' extension to the file if you don't do so yourself, and |
|
1626 | It adds a '.py' extension to the file if you don't do so yourself, and | |
1620 | it asks for confirmation before overwriting existing files.""" |
|
1627 | it asks for confirmation before overwriting existing files.""" | |
1621 |
|
1628 | |||
1622 | args = parameter_s.split() |
|
1629 | args = parameter_s.split() | |
1623 | fname,ranges = args[0], args[1:] |
|
1630 | fname,ranges = args[0], args[1:] | |
1624 | if not fname.endswith('.py'): |
|
1631 | if not fname.endswith('.py'): | |
1625 | fname += '.py' |
|
1632 | fname += '.py' | |
1626 | if os.path.isfile(fname): |
|
1633 | if os.path.isfile(fname): | |
1627 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) |
|
1634 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) | |
1628 | if ans.lower() not in ['y','yes']: |
|
1635 | if ans.lower() not in ['y','yes']: | |
1629 | print 'Operation cancelled.' |
|
1636 | print 'Operation cancelled.' | |
1630 | return |
|
1637 | return | |
1631 | cmds = ''.join(self.extract_input_slices(ranges)) |
|
1638 | cmds = ''.join(self.extract_input_slices(ranges)) | |
1632 | f = file(fname,'w') |
|
1639 | f = file(fname,'w') | |
1633 | f.write(cmds) |
|
1640 | f.write(cmds) | |
1634 | f.close() |
|
1641 | f.close() | |
1635 | print 'The following commands were written to file `%s`:' % fname |
|
1642 | print 'The following commands were written to file `%s`:' % fname | |
1636 | print cmds |
|
1643 | print cmds | |
1637 |
|
1644 | |||
1638 | def magic_ed(self,parameter_s = ''): |
|
1645 | def magic_ed(self,parameter_s = ''): | |
1639 | """Alias to %edit.""" |
|
1646 | """Alias to %edit.""" | |
1640 | return self.magic_edit(parameter_s) |
|
1647 | return self.magic_edit(parameter_s) | |
1641 |
|
1648 | |||
1642 | def magic_edit(self,parameter_s = '',last_call=['','']): |
|
1649 | def magic_edit(self,parameter_s = '',last_call=['','']): | |
1643 | """Bring up an editor and execute the resulting code. |
|
1650 | """Bring up an editor and execute the resulting code. | |
1644 |
|
1651 | |||
1645 | Usage: |
|
1652 | Usage: | |
1646 | %edit [options] [args] |
|
1653 | %edit [options] [args] | |
1647 |
|
1654 | |||
1648 | %edit runs IPython's editor hook. The default version of this hook is |
|
1655 | %edit runs IPython's editor hook. The default version of this hook is | |
1649 | set to call the __IPYTHON__.rc.editor command. This is read from your |
|
1656 | set to call the __IPYTHON__.rc.editor command. This is read from your | |
1650 | environment variable $EDITOR. If this isn't found, it will default to |
|
1657 | environment variable $EDITOR. If this isn't found, it will default to | |
1651 | vi under Linux/Unix and to notepad under Windows. See the end of this |
|
1658 | vi under Linux/Unix and to notepad under Windows. See the end of this | |
1652 | docstring for how to change the editor hook. |
|
1659 | docstring for how to change the editor hook. | |
1653 |
|
1660 | |||
1654 | You can also set the value of this editor via the command line option |
|
1661 | You can also set the value of this editor via the command line option | |
1655 | '-editor' or in your ipythonrc file. This is useful if you wish to use |
|
1662 | '-editor' or in your ipythonrc file. This is useful if you wish to use | |
1656 | specifically for IPython an editor different from your typical default |
|
1663 | specifically for IPython an editor different from your typical default | |
1657 | (and for Windows users who typically don't set environment variables). |
|
1664 | (and for Windows users who typically don't set environment variables). | |
1658 |
|
1665 | |||
1659 | This command allows you to conveniently edit multi-line code right in |
|
1666 | This command allows you to conveniently edit multi-line code right in | |
1660 | your IPython session. |
|
1667 | your IPython session. | |
1661 |
|
1668 | |||
1662 | If called without arguments, %edit opens up an empty editor with a |
|
1669 | If called without arguments, %edit opens up an empty editor with a | |
1663 | temporary file and will execute the contents of this file when you |
|
1670 | temporary file and will execute the contents of this file when you | |
1664 | close it (don't forget to save it!). |
|
1671 | close it (don't forget to save it!). | |
1665 |
|
1672 | |||
1666 | Options: |
|
1673 | Options: | |
1667 |
|
1674 | |||
1668 | -p: this will call the editor with the same data as the previous time |
|
1675 | -p: this will call the editor with the same data as the previous time | |
1669 | it was used, regardless of how long ago (in your current session) it |
|
1676 | it was used, regardless of how long ago (in your current session) it | |
1670 | was. |
|
1677 | was. | |
1671 |
|
1678 | |||
1672 | -x: do not execute the edited code immediately upon exit. This is |
|
1679 | -x: do not execute the edited code immediately upon exit. This is | |
1673 | mainly useful if you are editing programs which need to be called with |
|
1680 | mainly useful if you are editing programs which need to be called with | |
1674 | command line arguments, which you can then do using %run. |
|
1681 | command line arguments, which you can then do using %run. | |
1675 |
|
1682 | |||
1676 | Arguments: |
|
1683 | Arguments: | |
1677 |
|
1684 | |||
1678 | If arguments are given, the following possibilites exist: |
|
1685 | If arguments are given, the following possibilites exist: | |
1679 |
|
1686 | |||
1680 | - The arguments are numbers or pairs of colon-separated numbers (like |
|
1687 | - The arguments are numbers or pairs of colon-separated numbers (like | |
1681 | 1 4:8 9). These are interpreted as lines of previous input to be |
|
1688 | 1 4:8 9). These are interpreted as lines of previous input to be | |
1682 | loaded into the editor. The syntax is the same of the %macro command. |
|
1689 | loaded into the editor. The syntax is the same of the %macro command. | |
1683 |
|
1690 | |||
1684 | - If the argument doesn't start with a number, it is evaluated as a |
|
1691 | - If the argument doesn't start with a number, it is evaluated as a | |
1685 | variable and its contents loaded into the editor. You can thus edit |
|
1692 | variable and its contents loaded into the editor. You can thus edit | |
1686 | any string which contains python code (including the result of |
|
1693 | any string which contains python code (including the result of | |
1687 | previous edits). |
|
1694 | previous edits). | |
1688 |
|
1695 | |||
1689 | - If the argument is the name of an object (other than a string), |
|
1696 | - If the argument is the name of an object (other than a string), | |
1690 | IPython will try to locate the file where it was defined and open the |
|
1697 | IPython will try to locate the file where it was defined and open the | |
1691 | editor at the point where it is defined. You can use `%edit function` |
|
1698 | editor at the point where it is defined. You can use `%edit function` | |
1692 | to load an editor exactly at the point where 'function' is defined, |
|
1699 | to load an editor exactly at the point where 'function' is defined, | |
1693 | edit it and have the file be executed automatically. |
|
1700 | edit it and have the file be executed automatically. | |
1694 |
|
1701 | |||
1695 | Note: opening at an exact line is only supported under Unix, and some |
|
1702 | Note: opening at an exact line is only supported under Unix, and some | |
1696 | editors (like kedit and gedit up to Gnome 2.8) do not understand the |
|
1703 | editors (like kedit and gedit up to Gnome 2.8) do not understand the | |
1697 | '+NUMBER' parameter necessary for this feature. Good editors like |
|
1704 | '+NUMBER' parameter necessary for this feature. Good editors like | |
1698 | (X)Emacs, vi, jed, pico and joe all do. |
|
1705 | (X)Emacs, vi, jed, pico and joe all do. | |
1699 |
|
1706 | |||
1700 | - If the argument is not found as a variable, IPython will look for a |
|
1707 | - If the argument is not found as a variable, IPython will look for a | |
1701 | file with that name (adding .py if necessary) and load it into the |
|
1708 | file with that name (adding .py if necessary) and load it into the | |
1702 | editor. It will execute its contents with execfile() when you exit, |
|
1709 | editor. It will execute its contents with execfile() when you exit, | |
1703 | loading any code in the file into your interactive namespace. |
|
1710 | loading any code in the file into your interactive namespace. | |
1704 |
|
1711 | |||
1705 | After executing your code, %edit will return as output the code you |
|
1712 | After executing your code, %edit will return as output the code you | |
1706 | typed in the editor (except when it was an existing file). This way |
|
1713 | typed in the editor (except when it was an existing file). This way | |
1707 | you can reload the code in further invocations of %edit as a variable, |
|
1714 | you can reload the code in further invocations of %edit as a variable, | |
1708 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of |
|
1715 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of | |
1709 | the output. |
|
1716 | the output. | |
1710 |
|
1717 | |||
1711 | Note that %edit is also available through the alias %ed. |
|
1718 | Note that %edit is also available through the alias %ed. | |
1712 |
|
1719 | |||
1713 | This is an example of creating a simple function inside the editor and |
|
1720 | This is an example of creating a simple function inside the editor and | |
1714 | then modifying it. First, start up the editor: |
|
1721 | then modifying it. First, start up the editor: | |
1715 |
|
1722 | |||
1716 | In [1]: ed\\ |
|
1723 | In [1]: ed\\ | |
1717 | Editing... done. Executing edited code...\\ |
|
1724 | Editing... done. Executing edited code...\\ | |
1718 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' |
|
1725 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' | |
1719 |
|
1726 | |||
1720 | We can then call the function foo(): |
|
1727 | We can then call the function foo(): | |
1721 |
|
1728 | |||
1722 | In [2]: foo()\\ |
|
1729 | In [2]: foo()\\ | |
1723 | foo() was defined in an editing session |
|
1730 | foo() was defined in an editing session | |
1724 |
|
1731 | |||
1725 | Now we edit foo. IPython automatically loads the editor with the |
|
1732 | Now we edit foo. IPython automatically loads the editor with the | |
1726 | (temporary) file where foo() was previously defined: |
|
1733 | (temporary) file where foo() was previously defined: | |
1727 |
|
1734 | |||
1728 | In [3]: ed foo\\ |
|
1735 | In [3]: ed foo\\ | |
1729 | Editing... done. Executing edited code... |
|
1736 | Editing... done. Executing edited code... | |
1730 |
|
1737 | |||
1731 | And if we call foo() again we get the modified version: |
|
1738 | And if we call foo() again we get the modified version: | |
1732 |
|
1739 | |||
1733 | In [4]: foo()\\ |
|
1740 | In [4]: foo()\\ | |
1734 | foo() has now been changed! |
|
1741 | foo() has now been changed! | |
1735 |
|
1742 | |||
1736 | Here is an example of how to edit a code snippet successive |
|
1743 | Here is an example of how to edit a code snippet successive | |
1737 | times. First we call the editor: |
|
1744 | times. First we call the editor: | |
1738 |
|
1745 | |||
1739 | In [8]: ed\\ |
|
1746 | In [8]: ed\\ | |
1740 | Editing... done. Executing edited code...\\ |
|
1747 | Editing... done. Executing edited code...\\ | |
1741 | hello\\ |
|
1748 | hello\\ | |
1742 | Out[8]: "print 'hello'\\n" |
|
1749 | Out[8]: "print 'hello'\\n" | |
1743 |
|
1750 | |||
1744 | Now we call it again with the previous output (stored in _): |
|
1751 | Now we call it again with the previous output (stored in _): | |
1745 |
|
1752 | |||
1746 | In [9]: ed _\\ |
|
1753 | In [9]: ed _\\ | |
1747 | Editing... done. Executing edited code...\\ |
|
1754 | Editing... done. Executing edited code...\\ | |
1748 | hello world\\ |
|
1755 | hello world\\ | |
1749 | Out[9]: "print 'hello world'\\n" |
|
1756 | Out[9]: "print 'hello world'\\n" | |
1750 |
|
1757 | |||
1751 | Now we call it with the output #8 (stored in _8, also as Out[8]): |
|
1758 | Now we call it with the output #8 (stored in _8, also as Out[8]): | |
1752 |
|
1759 | |||
1753 | In [10]: ed _8\\ |
|
1760 | In [10]: ed _8\\ | |
1754 | Editing... done. Executing edited code...\\ |
|
1761 | Editing... done. Executing edited code...\\ | |
1755 | hello again\\ |
|
1762 | hello again\\ | |
1756 | Out[10]: "print 'hello again'\\n" |
|
1763 | Out[10]: "print 'hello again'\\n" | |
1757 |
|
1764 | |||
1758 |
|
1765 | |||
1759 | Changing the default editor hook: |
|
1766 | Changing the default editor hook: | |
1760 |
|
1767 | |||
1761 | If you wish to write your own editor hook, you can put it in a |
|
1768 | If you wish to write your own editor hook, you can put it in a | |
1762 | configuration file which you load at startup time. The default hook |
|
1769 | configuration file which you load at startup time. The default hook | |
1763 | is defined in the IPython.hooks module, and you can use that as a |
|
1770 | is defined in the IPython.hooks module, and you can use that as a | |
1764 | starting example for further modifications. That file also has |
|
1771 | starting example for further modifications. That file also has | |
1765 | general instructions on how to set a new hook for use once you've |
|
1772 | general instructions on how to set a new hook for use once you've | |
1766 | defined it.""" |
|
1773 | defined it.""" | |
1767 |
|
1774 | |||
1768 | # FIXME: This function has become a convoluted mess. It needs a |
|
1775 | # FIXME: This function has become a convoluted mess. It needs a | |
1769 | # ground-up rewrite with clean, simple logic. |
|
1776 | # ground-up rewrite with clean, simple logic. | |
1770 |
|
1777 | |||
1771 | def make_filename(arg): |
|
1778 | def make_filename(arg): | |
1772 | "Make a filename from the given args" |
|
1779 | "Make a filename from the given args" | |
1773 | try: |
|
1780 | try: | |
1774 | filename = get_py_filename(arg) |
|
1781 | filename = get_py_filename(arg) | |
1775 | except IOError: |
|
1782 | except IOError: | |
1776 | if args.endswith('.py'): |
|
1783 | if args.endswith('.py'): | |
1777 | filename = arg |
|
1784 | filename = arg | |
1778 | else: |
|
1785 | else: | |
1779 | filename = None |
|
1786 | filename = None | |
1780 | return filename |
|
1787 | return filename | |
1781 |
|
1788 | |||
1782 | # custom exceptions |
|
1789 | # custom exceptions | |
1783 | class DataIsObject(Exception): pass |
|
1790 | class DataIsObject(Exception): pass | |
1784 |
|
1791 | |||
1785 | opts,args = self.parse_options(parameter_s,'px') |
|
1792 | opts,args = self.parse_options(parameter_s,'px') | |
1786 |
|
1793 | |||
1787 | # Default line number value |
|
1794 | # Default line number value | |
1788 | lineno = None |
|
1795 | lineno = None | |
1789 | if opts.has_key('p'): |
|
1796 | if opts.has_key('p'): | |
1790 | args = '_%s' % last_call[0] |
|
1797 | args = '_%s' % last_call[0] | |
1791 | if not self.shell.user_ns.has_key(args): |
|
1798 | if not self.shell.user_ns.has_key(args): | |
1792 | args = last_call[1] |
|
1799 | args = last_call[1] | |
1793 |
|
1800 | |||
1794 | # use last_call to remember the state of the previous call, but don't |
|
1801 | # use last_call to remember the state of the previous call, but don't | |
1795 | # let it be clobbered by successive '-p' calls. |
|
1802 | # let it be clobbered by successive '-p' calls. | |
1796 | try: |
|
1803 | try: | |
1797 | last_call[0] = self.shell.outputcache.prompt_count |
|
1804 | last_call[0] = self.shell.outputcache.prompt_count | |
1798 | if not opts.has_key('p'): |
|
1805 | if not opts.has_key('p'): | |
1799 | last_call[1] = parameter_s |
|
1806 | last_call[1] = parameter_s | |
1800 | except: |
|
1807 | except: | |
1801 | pass |
|
1808 | pass | |
1802 |
|
1809 | |||
1803 | # by default this is done with temp files, except when the given |
|
1810 | # by default this is done with temp files, except when the given | |
1804 | # arg is a filename |
|
1811 | # arg is a filename | |
1805 | use_temp = 1 |
|
1812 | use_temp = 1 | |
1806 |
|
1813 | |||
1807 | if re.match(r'\d',args): |
|
1814 | if re.match(r'\d',args): | |
1808 | # Mode where user specifies ranges of lines, like in %macro. |
|
1815 | # Mode where user specifies ranges of lines, like in %macro. | |
1809 | # This means that you can't edit files whose names begin with |
|
1816 | # This means that you can't edit files whose names begin with | |
1810 | # numbers this way. Tough. |
|
1817 | # numbers this way. Tough. | |
1811 | ranges = args.split() |
|
1818 | ranges = args.split() | |
1812 | data = ''.join(self.extract_input_slices(ranges)) |
|
1819 | data = ''.join(self.extract_input_slices(ranges)) | |
1813 | elif args.endswith('.py'): |
|
1820 | elif args.endswith('.py'): | |
1814 | filename = make_filename(args) |
|
1821 | filename = make_filename(args) | |
1815 | data = '' |
|
1822 | data = '' | |
1816 | use_temp = 0 |
|
1823 | use_temp = 0 | |
1817 | elif args: |
|
1824 | elif args: | |
1818 | try: |
|
1825 | try: | |
1819 | # Load the parameter given as a variable. If not a string, |
|
1826 | # Load the parameter given as a variable. If not a string, | |
1820 | # process it as an object instead (below) |
|
1827 | # process it as an object instead (below) | |
1821 |
|
1828 | |||
1822 | #print '*** args',args,'type',type(args) # dbg |
|
1829 | #print '*** args',args,'type',type(args) # dbg | |
1823 | data = eval(args,self.shell.user_ns) |
|
1830 | data = eval(args,self.shell.user_ns) | |
1824 | if not type(data) in StringTypes: |
|
1831 | if not type(data) in StringTypes: | |
1825 | raise DataIsObject |
|
1832 | raise DataIsObject | |
1826 | except (NameError,SyntaxError): |
|
1833 | except (NameError,SyntaxError): | |
1827 | # given argument is not a variable, try as a filename |
|
1834 | # given argument is not a variable, try as a filename | |
1828 | filename = make_filename(args) |
|
1835 | filename = make_filename(args) | |
1829 | if filename is None: |
|
1836 | if filename is None: | |
1830 | warn("Argument given (%s) can't be found as a variable " |
|
1837 | warn("Argument given (%s) can't be found as a variable " | |
1831 | "or as a filename." % args) |
|
1838 | "or as a filename." % args) | |
1832 | return |
|
1839 | return | |
1833 | data = '' |
|
1840 | data = '' | |
1834 | use_temp = 0 |
|
1841 | use_temp = 0 | |
1835 | except DataIsObject: |
|
1842 | except DataIsObject: | |
1836 | # For objects, try to edit the file where they are defined |
|
1843 | # For objects, try to edit the file where they are defined | |
1837 | try: |
|
1844 | try: | |
1838 | filename = inspect.getabsfile(data) |
|
1845 | filename = inspect.getabsfile(data) | |
1839 | datafile = 1 |
|
1846 | datafile = 1 | |
1840 | except TypeError: |
|
1847 | except TypeError: | |
1841 | filename = make_filename(args) |
|
1848 | filename = make_filename(args) | |
1842 | datafile = 1 |
|
1849 | datafile = 1 | |
1843 | warn('Could not find file where `%s` is defined.\n' |
|
1850 | warn('Could not find file where `%s` is defined.\n' | |
1844 | 'Opening a file named `%s`' % (args,filename)) |
|
1851 | 'Opening a file named `%s`' % (args,filename)) | |
1845 | # Now, make sure we can actually read the source (if it was in |
|
1852 | # Now, make sure we can actually read the source (if it was in | |
1846 | # a temp file it's gone by now). |
|
1853 | # a temp file it's gone by now). | |
1847 | if datafile: |
|
1854 | if datafile: | |
1848 | try: |
|
1855 | try: | |
1849 | lineno = inspect.getsourcelines(data)[1] |
|
1856 | lineno = inspect.getsourcelines(data)[1] | |
1850 | except IOError: |
|
1857 | except IOError: | |
1851 | filename = make_filename(args) |
|
1858 | filename = make_filename(args) | |
1852 | if filename is None: |
|
1859 | if filename is None: | |
1853 | warn('The file `%s` where `%s` was defined cannot ' |
|
1860 | warn('The file `%s` where `%s` was defined cannot ' | |
1854 | 'be read.' % (filename,data)) |
|
1861 | 'be read.' % (filename,data)) | |
1855 | return |
|
1862 | return | |
1856 | use_temp = 0 |
|
1863 | use_temp = 0 | |
1857 | else: |
|
1864 | else: | |
1858 | data = '' |
|
1865 | data = '' | |
1859 |
|
1866 | |||
1860 | if use_temp: |
|
1867 | if use_temp: | |
1861 | filename = tempfile.mktemp('.py') |
|
1868 | filename = tempfile.mktemp('.py') | |
1862 | self.shell.tempfiles.append(filename) |
|
1869 | self.shell.tempfiles.append(filename) | |
1863 |
|
1870 | |||
1864 | if data and use_temp: |
|
1871 | if data and use_temp: | |
1865 | tmp_file = open(filename,'w') |
|
1872 | tmp_file = open(filename,'w') | |
1866 | tmp_file.write(data) |
|
1873 | tmp_file.write(data) | |
1867 | tmp_file.close() |
|
1874 | tmp_file.close() | |
1868 |
|
1875 | |||
1869 | # do actual editing here |
|
1876 | # do actual editing here | |
1870 | print 'Editing...', |
|
1877 | print 'Editing...', | |
1871 | sys.stdout.flush() |
|
1878 | sys.stdout.flush() | |
1872 | self.shell.hooks.editor(filename,lineno) |
|
1879 | self.shell.hooks.editor(filename,lineno) | |
1873 | if opts.has_key('x'): # -x prevents actual execution |
|
1880 | if opts.has_key('x'): # -x prevents actual execution | |
1874 |
|
1881 | |||
1875 | else: |
|
1882 | else: | |
1876 | print 'done. Executing edited code...' |
|
1883 | print 'done. Executing edited code...' | |
1877 | try: |
|
1884 | try: | |
1878 | self.shell.safe_execfile(filename,self.shell.user_ns) |
|
1885 | self.shell.safe_execfile(filename,self.shell.user_ns) | |
1879 | except IOError,msg: |
|
1886 | except IOError,msg: | |
1880 | if msg.filename == filename: |
|
1887 | if msg.filename == filename: | |
1881 | warn('File not found. Did you forget to save?') |
|
1888 | warn('File not found. Did you forget to save?') | |
1882 | return |
|
1889 | return | |
1883 | else: |
|
1890 | else: | |
1884 | self.shell.showtraceback() |
|
1891 | self.shell.showtraceback() | |
1885 | except: |
|
1892 | except: | |
1886 | self.shell.showtraceback() |
|
1893 | self.shell.showtraceback() | |
1887 | if use_temp: |
|
1894 | if use_temp: | |
1888 | contents = open(filename).read() |
|
1895 | contents = open(filename).read() | |
1889 | return contents |
|
1896 | return contents | |
1890 |
|
1897 | |||
1891 | def magic_xmode(self,parameter_s = ''): |
|
1898 | def magic_xmode(self,parameter_s = ''): | |
1892 | """Switch modes for the exception handlers. |
|
1899 | """Switch modes for the exception handlers. | |
1893 |
|
1900 | |||
1894 | Valid modes: Plain, Context and Verbose. |
|
1901 | Valid modes: Plain, Context and Verbose. | |
1895 |
|
1902 | |||
1896 | If called without arguments, acts as a toggle.""" |
|
1903 | If called without arguments, acts as a toggle.""" | |
1897 |
|
1904 | |||
|
1905 | def xmode_switch_err(name): | |||
|
1906 | warn('Error changing %s exception modes.\n%s' % | |||
|
1907 | (name,sys.exc_info()[1])) | |||
|
1908 | ||||
1898 | new_mode = parameter_s.strip().capitalize() |
|
1909 | new_mode = parameter_s.strip().capitalize() | |
1899 | try: |
|
1910 | try: | |
1900 |
self.InteractiveTB.set_mode(mode |
|
1911 | self.InteractiveTB.set_mode(mode=new_mode) | |
1901 | print 'Exception reporting mode:',self.InteractiveTB.mode |
|
1912 | print 'Exception reporting mode:',self.InteractiveTB.mode | |
1902 | except: |
|
1913 | except: | |
1903 | warn('Error changing exception modes.\n' + str(sys.exc_info()[1])) |
|
1914 | xmode_switch_err('user') | |
|
1915 | ||||
|
1916 | # threaded shells use a special handler in sys.excepthook | |||
|
1917 | if self.isthreaded: | |||
|
1918 | try: | |||
|
1919 | self.shell.sys_excepthook.set_mode(mode=new_mode) | |||
|
1920 | except: | |||
|
1921 | xmode_switch_err('threaded') | |||
1904 |
|
1922 | |||
1905 | def magic_colors(self,parameter_s = ''): |
|
1923 | def magic_colors(self,parameter_s = ''): | |
1906 | """Switch color scheme for prompts, info system and exception handlers. |
|
1924 | """Switch color scheme for prompts, info system and exception handlers. | |
1907 |
|
1925 | |||
1908 | Currently implemented schemes: NoColor, Linux, LightBG. |
|
1926 | Currently implemented schemes: NoColor, Linux, LightBG. | |
1909 |
|
1927 | |||
1910 | Color scheme names are not case-sensitive.""" |
|
1928 | Color scheme names are not case-sensitive.""" | |
|
1929 | ||||
|
1930 | def color_switch_err(name): | |||
|
1931 | warn('Error changing %s color schemes.\n%s' % | |||
|
1932 | (name,sys.exc_info()[1])) | |||
|
1933 | ||||
1911 |
|
1934 | |||
1912 | new_scheme = parameter_s.strip() |
|
1935 | new_scheme = parameter_s.strip() | |
1913 | if not new_scheme: |
|
1936 | if not new_scheme: | |
1914 | print 'You must specify a color scheme.' |
|
1937 | print 'You must specify a color scheme.' | |
1915 | return |
|
1938 | return | |
1916 | # Under Windows, check for Gary Bishop's readline, which is necessary |
|
1939 | # Under Windows, check for Gary Bishop's readline, which is necessary | |
1917 | # for ANSI coloring |
|
1940 | # for ANSI coloring | |
1918 | if os.name in ['nt','dos']: |
|
1941 | if os.name in ['nt','dos']: | |
1919 | try: |
|
1942 | try: | |
1920 | import readline |
|
1943 | import readline | |
1921 | except ImportError: |
|
1944 | except ImportError: | |
1922 | has_readline = 0 |
|
1945 | has_readline = 0 | |
1923 | else: |
|
1946 | else: | |
1924 | try: |
|
1947 | try: | |
1925 | readline.GetOutputFile() |
|
1948 | readline.GetOutputFile() | |
1926 | except AttributeError: |
|
1949 | except AttributeError: | |
1927 | has_readline = 0 |
|
1950 | has_readline = 0 | |
1928 | else: |
|
1951 | else: | |
1929 | has_readline = 1 |
|
1952 | has_readline = 1 | |
1930 | if not has_readline: |
|
1953 | if not has_readline: | |
1931 | msg = """\ |
|
1954 | msg = """\ | |
1932 | Proper color support under MS Windows requires Gary Bishop's readline library. |
|
1955 | Proper color support under MS Windows requires Gary Bishop's readline library. | |
1933 | You can find it at: |
|
1956 | You can find it at: | |
1934 | http://sourceforge.net/projects/uncpythontools |
|
1957 | http://sourceforge.net/projects/uncpythontools | |
1935 | Gary's readline needs the ctypes module, from: |
|
1958 | Gary's readline needs the ctypes module, from: | |
1936 | http://starship.python.net/crew/theller/ctypes |
|
1959 | http://starship.python.net/crew/theller/ctypes | |
1937 |
|
1960 | |||
1938 | Defaulting color scheme to 'NoColor'""" |
|
1961 | Defaulting color scheme to 'NoColor'""" | |
1939 | new_scheme = 'NoColor' |
|
1962 | new_scheme = 'NoColor' | |
1940 | warn(msg) |
|
1963 | warn(msg) | |
1941 |
|
1964 | |||
1942 | # Set prompt colors |
|
1965 | # Set prompt colors | |
1943 | try: |
|
1966 | try: | |
1944 | self.shell.outputcache.set_colors(new_scheme) |
|
1967 | self.shell.outputcache.set_colors(new_scheme) | |
1945 | except: |
|
1968 | except: | |
1946 | warn('Error changing prompt color schemes.\n' |
|
1969 | color_switch_err('prompt') | |
1947 | + str(sys.exc_info()[1])) |
|
|||
1948 | else: |
|
1970 | else: | |
1949 | self.shell.rc.colors = \ |
|
1971 | self.shell.rc.colors = \ | |
1950 | self.shell.outputcache.color_table.active_scheme_name |
|
1972 | self.shell.outputcache.color_table.active_scheme_name | |
1951 | # Set exception colors |
|
1973 | # Set exception colors | |
1952 | try: |
|
1974 | try: | |
1953 | self.shell.InteractiveTB.set_colors(scheme = new_scheme) |
|
1975 | self.shell.InteractiveTB.set_colors(scheme = new_scheme) | |
1954 | self.shell.SyntaxTB.set_colors(scheme = new_scheme) |
|
1976 | self.shell.SyntaxTB.set_colors(scheme = new_scheme) | |
1955 | except: |
|
1977 | except: | |
1956 | warn('Error changing exception color schemes.\n' |
|
1978 | color_switch_err('exception') | |
1957 | + str(sys.exc_info()[1])) |
|
1979 | ||
|
1980 | # threaded shells use a verbose traceback in sys.excepthook | |||
|
1981 | if self.isthreaded: | |||
|
1982 | try: | |||
|
1983 | self.shell.sys_excepthook.set_colors(scheme=new_scheme) | |||
|
1984 | except: | |||
|
1985 | color_switch_err('system exception handler') | |||
|
1986 | ||||
1958 | # Set info (for 'object?') colors |
|
1987 | # Set info (for 'object?') colors | |
1959 | if self.shell.rc.color_info: |
|
1988 | if self.shell.rc.color_info: | |
1960 | try: |
|
1989 | try: | |
1961 | self.shell.inspector.set_active_scheme(new_scheme) |
|
1990 | self.shell.inspector.set_active_scheme(new_scheme) | |
1962 | except: |
|
1991 | except: | |
1963 |
|
|
1992 | color_switch_err('object inspector') | |
1964 | + str(sys.exc_info()[1])) |
|
|||
1965 | else: |
|
1993 | else: | |
1966 | self.shell.inspector.set_active_scheme('NoColor') |
|
1994 | self.shell.inspector.set_active_scheme('NoColor') | |
1967 |
|
1995 | |||
1968 | def magic_color_info(self,parameter_s = ''): |
|
1996 | def magic_color_info(self,parameter_s = ''): | |
1969 | """Toggle color_info. |
|
1997 | """Toggle color_info. | |
1970 |
|
1998 | |||
1971 | The color_info configuration parameter controls whether colors are |
|
1999 | The color_info configuration parameter controls whether colors are | |
1972 | used for displaying object details (by things like %psource, %pfile or |
|
2000 | used for displaying object details (by things like %psource, %pfile or | |
1973 | the '?' system). This function toggles this value with each call. |
|
2001 | the '?' system). This function toggles this value with each call. | |
1974 |
|
2002 | |||
1975 | Note that unless you have a fairly recent pager (less works better |
|
2003 | Note that unless you have a fairly recent pager (less works better | |
1976 | than more) in your system, using colored object information displays |
|
2004 | than more) in your system, using colored object information displays | |
1977 | will not work properly. Test it and see.""" |
|
2005 | will not work properly. Test it and see.""" | |
1978 |
|
2006 | |||
1979 | self.shell.rc.color_info = 1 - self.shell.rc.color_info |
|
2007 | self.shell.rc.color_info = 1 - self.shell.rc.color_info | |
1980 | self.magic_colors(self.shell.rc.colors) |
|
2008 | self.magic_colors(self.shell.rc.colors) | |
1981 | print 'Object introspection functions have now coloring:', |
|
2009 | print 'Object introspection functions have now coloring:', | |
1982 | print ['OFF','ON'][self.shell.rc.color_info] |
|
2010 | print ['OFF','ON'][self.shell.rc.color_info] | |
1983 |
|
2011 | |||
1984 | def magic_Pprint(self, parameter_s=''): |
|
2012 | def magic_Pprint(self, parameter_s=''): | |
1985 | """Toggle pretty printing on/off.""" |
|
2013 | """Toggle pretty printing on/off.""" | |
1986 |
|
2014 | |||
1987 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint |
|
2015 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint | |
1988 | print 'Pretty printing has been turned', \ |
|
2016 | print 'Pretty printing has been turned', \ | |
1989 | ['OFF','ON'][self.shell.outputcache.Pprint] |
|
2017 | ['OFF','ON'][self.shell.outputcache.Pprint] | |
1990 |
|
2018 | |||
1991 | def magic_exit(self, parameter_s=''): |
|
2019 | def magic_exit(self, parameter_s=''): | |
1992 | """Exit IPython, confirming if configured to do so. |
|
2020 | """Exit IPython, confirming if configured to do so. | |
1993 |
|
2021 | |||
1994 | You can configure whether IPython asks for confirmation upon exit by |
|
2022 | You can configure whether IPython asks for confirmation upon exit by | |
1995 | setting the confirm_exit flag in the ipythonrc file.""" |
|
2023 | setting the confirm_exit flag in the ipythonrc file.""" | |
1996 |
|
2024 | |||
1997 | self.shell.exit() |
|
2025 | self.shell.exit() | |
1998 |
|
2026 | |||
1999 | def magic_quit(self, parameter_s=''): |
|
2027 | def magic_quit(self, parameter_s=''): | |
2000 | """Exit IPython, confirming if configured to do so (like %exit)""" |
|
2028 | """Exit IPython, confirming if configured to do so (like %exit)""" | |
2001 |
|
2029 | |||
2002 | self.shell.exit() |
|
2030 | self.shell.exit() | |
2003 |
|
2031 | |||
2004 | def magic_Exit(self, parameter_s=''): |
|
2032 | def magic_Exit(self, parameter_s=''): | |
2005 | """Exit IPython without confirmation.""" |
|
2033 | """Exit IPython without confirmation.""" | |
2006 |
|
2034 | |||
2007 | self.shell.exit_now = True |
|
2035 | self.shell.exit_now = True | |
2008 |
|
2036 | |||
2009 | def magic_Quit(self, parameter_s=''): |
|
2037 | def magic_Quit(self, parameter_s=''): | |
2010 | """Exit IPython without confirmation (like %Exit).""" |
|
2038 | """Exit IPython without confirmation (like %Exit).""" | |
2011 |
|
2039 | |||
2012 | self.shell.exit_now = True |
|
2040 | self.shell.exit_now = True | |
2013 |
|
2041 | |||
2014 | #...................................................................... |
|
2042 | #...................................................................... | |
2015 | # Functions to implement unix shell-type things |
|
2043 | # Functions to implement unix shell-type things | |
2016 |
|
2044 | |||
2017 | def magic_alias(self, parameter_s = ''): |
|
2045 | def magic_alias(self, parameter_s = ''): | |
2018 | """Define an alias for a system command. |
|
2046 | """Define an alias for a system command. | |
2019 |
|
2047 | |||
2020 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' |
|
2048 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' | |
2021 |
|
2049 | |||
2022 | Then, typing 'alias_name params' will execute the system command 'cmd |
|
2050 | Then, typing 'alias_name params' will execute the system command 'cmd | |
2023 | params' (from your underlying operating system). |
|
2051 | params' (from your underlying operating system). | |
2024 |
|
2052 | |||
2025 | Aliases have lower precedence than magic functions and Python normal |
|
2053 | Aliases have lower precedence than magic functions and Python normal | |
2026 | variables, so if 'foo' is both a Python variable and an alias, the |
|
2054 | variables, so if 'foo' is both a Python variable and an alias, the | |
2027 | alias can not be executed until 'del foo' removes the Python variable. |
|
2055 | alias can not be executed until 'del foo' removes the Python variable. | |
2028 |
|
2056 | |||
2029 | You can use the %l specifier in an alias definition to represent the |
|
2057 | You can use the %l specifier in an alias definition to represent the | |
2030 | whole line when the alias is called. For example: |
|
2058 | whole line when the alias is called. For example: | |
2031 |
|
2059 | |||
2032 | In [2]: alias all echo "Input in brackets: <%l>"\\ |
|
2060 | In [2]: alias all echo "Input in brackets: <%l>"\\ | |
2033 | In [3]: all hello world\\ |
|
2061 | In [3]: all hello world\\ | |
2034 | Input in brackets: <hello world> |
|
2062 | Input in brackets: <hello world> | |
2035 |
|
2063 | |||
2036 | You can also define aliases with parameters using %s specifiers (one |
|
2064 | You can also define aliases with parameters using %s specifiers (one | |
2037 | per parameter): |
|
2065 | per parameter): | |
2038 |
|
2066 | |||
2039 | In [1]: alias parts echo first %s second %s\\ |
|
2067 | In [1]: alias parts echo first %s second %s\\ | |
2040 | In [2]: %parts A B\\ |
|
2068 | In [2]: %parts A B\\ | |
2041 | first A second B\\ |
|
2069 | first A second B\\ | |
2042 | In [3]: %parts A\\ |
|
2070 | In [3]: %parts A\\ | |
2043 | Incorrect number of arguments: 2 expected.\\ |
|
2071 | Incorrect number of arguments: 2 expected.\\ | |
2044 | parts is an alias to: 'echo first %s second %s' |
|
2072 | parts is an alias to: 'echo first %s second %s' | |
2045 |
|
2073 | |||
2046 | Note that %l and %s are mutually exclusive. You can only use one or |
|
2074 | Note that %l and %s are mutually exclusive. You can only use one or | |
2047 | the other in your aliases. |
|
2075 | the other in your aliases. | |
2048 |
|
2076 | |||
2049 | Aliases expand Python variables just like system calls using ! or !! |
|
2077 | Aliases expand Python variables just like system calls using ! or !! | |
2050 | do: all expressions prefixed with '$' get expanded. For details of |
|
2078 | do: all expressions prefixed with '$' get expanded. For details of | |
2051 | the semantic rules, see PEP-215: |
|
2079 | the semantic rules, see PEP-215: | |
2052 | http://www.python.org/peps/pep-0215.html. This is the library used by |
|
2080 | http://www.python.org/peps/pep-0215.html. This is the library used by | |
2053 | IPython for variable expansion. If you want to access a true shell |
|
2081 | IPython for variable expansion. If you want to access a true shell | |
2054 | variable, an extra $ is necessary to prevent its expansion by IPython: |
|
2082 | variable, an extra $ is necessary to prevent its expansion by IPython: | |
2055 |
|
2083 | |||
2056 | In [6]: alias show echo\\ |
|
2084 | In [6]: alias show echo\\ | |
2057 | In [7]: PATH='A Python string'\\ |
|
2085 | In [7]: PATH='A Python string'\\ | |
2058 | In [8]: show $PATH\\ |
|
2086 | In [8]: show $PATH\\ | |
2059 | A Python string\\ |
|
2087 | A Python string\\ | |
2060 | In [9]: show $$PATH\\ |
|
2088 | In [9]: show $$PATH\\ | |
2061 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2089 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2062 |
|
2090 | |||
2063 | You can use the alias facility to acess all of $PATH. See the %rehash |
|
2091 | You can use the alias facility to acess all of $PATH. See the %rehash | |
2064 | and %rehashx functions, which automatically create aliases for the |
|
2092 | and %rehashx functions, which automatically create aliases for the | |
2065 | contents of your $PATH. |
|
2093 | contents of your $PATH. | |
2066 |
|
2094 | |||
2067 | If called with no parameters, %alias prints the current alias table.""" |
|
2095 | If called with no parameters, %alias prints the current alias table.""" | |
2068 |
|
2096 | |||
2069 | par = parameter_s.strip() |
|
2097 | par = parameter_s.strip() | |
2070 | if not par: |
|
2098 | if not par: | |
2071 | if self.shell.rc.automagic: |
|
2099 | if self.shell.rc.automagic: | |
2072 | prechar = '' |
|
2100 | prechar = '' | |
2073 | else: |
|
2101 | else: | |
2074 | prechar = self.shell.ESC_MAGIC |
|
2102 | prechar = self.shell.ESC_MAGIC | |
2075 | print 'Alias\t\tSystem Command\n'+'-'*30 |
|
2103 | print 'Alias\t\tSystem Command\n'+'-'*30 | |
2076 | atab = self.shell.alias_table |
|
2104 | atab = self.shell.alias_table | |
2077 | aliases = atab.keys() |
|
2105 | aliases = atab.keys() | |
2078 | aliases.sort() |
|
2106 | aliases.sort() | |
2079 | for alias in aliases: |
|
2107 | for alias in aliases: | |
2080 | print prechar+alias+'\t\t'+atab[alias][1] |
|
2108 | print prechar+alias+'\t\t'+atab[alias][1] | |
2081 | print '-'*30+'\nTotal number of aliases:',len(aliases) |
|
2109 | print '-'*30+'\nTotal number of aliases:',len(aliases) | |
2082 | return |
|
2110 | return | |
2083 | try: |
|
2111 | try: | |
2084 | alias,cmd = par.split(None,1) |
|
2112 | alias,cmd = par.split(None,1) | |
2085 | except: |
|
2113 | except: | |
2086 | print OInspect.getdoc(self.magic_alias) |
|
2114 | print OInspect.getdoc(self.magic_alias) | |
2087 | else: |
|
2115 | else: | |
2088 | nargs = cmd.count('%s') |
|
2116 | nargs = cmd.count('%s') | |
2089 | if nargs>0 and cmd.find('%l')>=0: |
|
2117 | if nargs>0 and cmd.find('%l')>=0: | |
2090 | error('The %s and %l specifiers are mutually exclusive ' |
|
2118 | error('The %s and %l specifiers are mutually exclusive ' | |
2091 | 'in alias definitions.') |
|
2119 | 'in alias definitions.') | |
2092 | else: # all looks OK |
|
2120 | else: # all looks OK | |
2093 | self.shell.alias_table[alias] = (nargs,cmd) |
|
2121 | self.shell.alias_table[alias] = (nargs,cmd) | |
2094 | self.shell.alias_table_validate(verbose=1) |
|
2122 | self.shell.alias_table_validate(verbose=1) | |
2095 | # end magic_alias |
|
2123 | # end magic_alias | |
2096 |
|
2124 | |||
2097 | def magic_unalias(self, parameter_s = ''): |
|
2125 | def magic_unalias(self, parameter_s = ''): | |
2098 | """Remove an alias""" |
|
2126 | """Remove an alias""" | |
2099 |
|
2127 | |||
2100 | aname = parameter_s.strip() |
|
2128 | aname = parameter_s.strip() | |
2101 | if aname in self.shell.alias_table: |
|
2129 | if aname in self.shell.alias_table: | |
2102 | del self.shell.alias_table[aname] |
|
2130 | del self.shell.alias_table[aname] | |
2103 |
|
2131 | |||
2104 | def magic_rehash(self, parameter_s = ''): |
|
2132 | def magic_rehash(self, parameter_s = ''): | |
2105 | """Update the alias table with all entries in $PATH. |
|
2133 | """Update the alias table with all entries in $PATH. | |
2106 |
|
2134 | |||
2107 | This version does no checks on execute permissions or whether the |
|
2135 | This version does no checks on execute permissions or whether the | |
2108 | contents of $PATH are truly files (instead of directories or something |
|
2136 | contents of $PATH are truly files (instead of directories or something | |
2109 | else). For such a safer (but slower) version, use %rehashx.""" |
|
2137 | else). For such a safer (but slower) version, use %rehashx.""" | |
2110 |
|
2138 | |||
2111 | # This function (and rehashx) manipulate the alias_table directly |
|
2139 | # This function (and rehashx) manipulate the alias_table directly | |
2112 | # rather than calling magic_alias, for speed reasons. A rehash on a |
|
2140 | # rather than calling magic_alias, for speed reasons. A rehash on a | |
2113 | # typical Linux box involves several thousand entries, so efficiency |
|
2141 | # typical Linux box involves several thousand entries, so efficiency | |
2114 | # here is a top concern. |
|
2142 | # here is a top concern. | |
2115 |
|
2143 | |||
2116 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2144 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2117 | alias_table = self.shell.alias_table |
|
2145 | alias_table = self.shell.alias_table | |
2118 | for pdir in path: |
|
2146 | for pdir in path: | |
2119 | for ff in os.listdir(pdir): |
|
2147 | for ff in os.listdir(pdir): | |
2120 | # each entry in the alias table must be (N,name), where |
|
2148 | # each entry in the alias table must be (N,name), where | |
2121 | # N is the number of positional arguments of the alias. |
|
2149 | # N is the number of positional arguments of the alias. | |
2122 | alias_table[ff] = (0,ff) |
|
2150 | alias_table[ff] = (0,ff) | |
2123 | # Make sure the alias table doesn't contain keywords or builtins |
|
2151 | # Make sure the alias table doesn't contain keywords or builtins | |
2124 | self.shell.alias_table_validate() |
|
2152 | self.shell.alias_table_validate() | |
2125 | # Call again init_auto_alias() so we get 'rm -i' and other modified |
|
2153 | # Call again init_auto_alias() so we get 'rm -i' and other modified | |
2126 | # aliases since %rehash will probably clobber them |
|
2154 | # aliases since %rehash will probably clobber them | |
2127 | self.shell.init_auto_alias() |
|
2155 | self.shell.init_auto_alias() | |
2128 |
|
2156 | |||
2129 | def magic_rehashx(self, parameter_s = ''): |
|
2157 | def magic_rehashx(self, parameter_s = ''): | |
2130 | """Update the alias table with all executable files in $PATH. |
|
2158 | """Update the alias table with all executable files in $PATH. | |
2131 |
|
2159 | |||
2132 | This version explicitly checks that every entry in $PATH is a file |
|
2160 | This version explicitly checks that every entry in $PATH is a file | |
2133 | with execute access (os.X_OK), so it is much slower than %rehash. |
|
2161 | with execute access (os.X_OK), so it is much slower than %rehash. | |
2134 |
|
2162 | |||
2135 | Under Windows, it checks executability as a match agains a |
|
2163 | Under Windows, it checks executability as a match agains a | |
2136 | '|'-separated string of extensions, stored in the IPython config |
|
2164 | '|'-separated string of extensions, stored in the IPython config | |
2137 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ |
|
2165 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ | |
2138 |
|
2166 | |||
2139 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2167 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2140 | alias_table = self.shell.alias_table |
|
2168 | alias_table = self.shell.alias_table | |
2141 |
|
2169 | |||
2142 | if os.name == 'posix': |
|
2170 | if os.name == 'posix': | |
2143 | isexec = lambda fname:os.path.isfile(fname) and \ |
|
2171 | isexec = lambda fname:os.path.isfile(fname) and \ | |
2144 | os.access(fname,os.X_OK) |
|
2172 | os.access(fname,os.X_OK) | |
2145 | else: |
|
2173 | else: | |
2146 |
|
2174 | |||
2147 | try: |
|
2175 | try: | |
2148 | winext = os.environ['pathext'].replace(';','|').replace('.','') |
|
2176 | winext = os.environ['pathext'].replace(';','|').replace('.','') | |
2149 | except KeyError: |
|
2177 | except KeyError: | |
2150 | winext = 'exe|com|bat' |
|
2178 | winext = 'exe|com|bat' | |
2151 |
|
2179 | |||
2152 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) |
|
2180 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) | |
2153 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) |
|
2181 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) | |
2154 | savedir = os.getcwd() |
|
2182 | savedir = os.getcwd() | |
2155 | try: |
|
2183 | try: | |
2156 | # write the whole loop for posix/Windows so we don't have an if in |
|
2184 | # write the whole loop for posix/Windows so we don't have an if in | |
2157 | # the innermost part |
|
2185 | # the innermost part | |
2158 | if os.name == 'posix': |
|
2186 | if os.name == 'posix': | |
2159 | for pdir in path: |
|
2187 | for pdir in path: | |
2160 | os.chdir(pdir) |
|
2188 | os.chdir(pdir) | |
2161 | for ff in os.listdir(pdir): |
|
2189 | for ff in os.listdir(pdir): | |
2162 | if isexec(ff): |
|
2190 | if isexec(ff): | |
2163 | # each entry in the alias table must be (N,name), |
|
2191 | # each entry in the alias table must be (N,name), | |
2164 | # where N is the number of positional arguments of the |
|
2192 | # where N is the number of positional arguments of the | |
2165 | # alias. |
|
2193 | # alias. | |
2166 | alias_table[ff] = (0,ff) |
|
2194 | alias_table[ff] = (0,ff) | |
2167 | else: |
|
2195 | else: | |
2168 | for pdir in path: |
|
2196 | for pdir in path: | |
2169 | os.chdir(pdir) |
|
2197 | os.chdir(pdir) | |
2170 | for ff in os.listdir(pdir): |
|
2198 | for ff in os.listdir(pdir): | |
2171 | if isexec(ff): |
|
2199 | if isexec(ff): | |
2172 | alias_table[execre.sub(r'\1',ff)] = (0,ff) |
|
2200 | alias_table[execre.sub(r'\1',ff)] = (0,ff) | |
2173 | # Make sure the alias table doesn't contain keywords or builtins |
|
2201 | # Make sure the alias table doesn't contain keywords or builtins | |
2174 | self.shell.alias_table_validate() |
|
2202 | self.shell.alias_table_validate() | |
2175 | # Call again init_auto_alias() so we get 'rm -i' and other |
|
2203 | # Call again init_auto_alias() so we get 'rm -i' and other | |
2176 | # modified aliases since %rehashx will probably clobber them |
|
2204 | # modified aliases since %rehashx will probably clobber them | |
2177 | self.shell.init_auto_alias() |
|
2205 | self.shell.init_auto_alias() | |
2178 | finally: |
|
2206 | finally: | |
2179 | os.chdir(savedir) |
|
2207 | os.chdir(savedir) | |
2180 |
|
2208 | |||
2181 | def magic_pwd(self, parameter_s = ''): |
|
2209 | def magic_pwd(self, parameter_s = ''): | |
2182 | """Return the current working directory path.""" |
|
2210 | """Return the current working directory path.""" | |
2183 | return os.getcwd() |
|
2211 | return os.getcwd() | |
2184 |
|
2212 | |||
2185 | def magic_cd(self, parameter_s=''): |
|
2213 | def magic_cd(self, parameter_s=''): | |
2186 | """Change the current working directory. |
|
2214 | """Change the current working directory. | |
2187 |
|
2215 | |||
2188 | This command automatically maintains an internal list of directories |
|
2216 | This command automatically maintains an internal list of directories | |
2189 | you visit during your IPython session, in the variable _dh. The |
|
2217 | you visit during your IPython session, in the variable _dh. The | |
2190 | command %dhist shows this history nicely formatted. |
|
2218 | command %dhist shows this history nicely formatted. | |
2191 |
|
2219 | |||
2192 | Usage: |
|
2220 | Usage: | |
2193 |
|
2221 | |||
2194 | cd 'dir': changes to directory 'dir'. |
|
2222 | cd 'dir': changes to directory 'dir'. | |
2195 |
|
2223 | |||
2196 | cd -: changes to the last visited directory. |
|
2224 | cd -: changes to the last visited directory. | |
2197 |
|
2225 | |||
2198 | cd -<n>: changes to the n-th directory in the directory history. |
|
2226 | cd -<n>: changes to the n-th directory in the directory history. | |
2199 |
|
2227 | |||
2200 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark |
|
2228 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark | |
2201 | (note: cd <bookmark_name> is enough if there is no |
|
2229 | (note: cd <bookmark_name> is enough if there is no | |
2202 | directory <bookmark_name>, but a bookmark with the name exists.) |
|
2230 | directory <bookmark_name>, but a bookmark with the name exists.) | |
2203 |
|
2231 | |||
2204 | Options: |
|
2232 | Options: | |
2205 |
|
2233 | |||
2206 | -q: quiet. Do not print the working directory after the cd command is |
|
2234 | -q: quiet. Do not print the working directory after the cd command is | |
2207 | executed. By default IPython's cd command does print this directory, |
|
2235 | executed. By default IPython's cd command does print this directory, | |
2208 | since the default prompts do not display path information. |
|
2236 | since the default prompts do not display path information. | |
2209 |
|
2237 | |||
2210 | Note that !cd doesn't work for this purpose because the shell where |
|
2238 | Note that !cd doesn't work for this purpose because the shell where | |
2211 | !command runs is immediately discarded after executing 'command'.""" |
|
2239 | !command runs is immediately discarded after executing 'command'.""" | |
2212 |
|
2240 | |||
2213 | parameter_s = parameter_s.strip() |
|
2241 | parameter_s = parameter_s.strip() | |
2214 | bkms = self.shell.persist.get("bookmarks",{}) |
|
2242 | bkms = self.shell.persist.get("bookmarks",{}) | |
2215 |
|
2243 | |||
2216 | numcd = re.match(r'(-)(\d+)$',parameter_s) |
|
2244 | numcd = re.match(r'(-)(\d+)$',parameter_s) | |
2217 | # jump in directory history by number |
|
2245 | # jump in directory history by number | |
2218 | if numcd: |
|
2246 | if numcd: | |
2219 | nn = int(numcd.group(2)) |
|
2247 | nn = int(numcd.group(2)) | |
2220 | try: |
|
2248 | try: | |
2221 | ps = self.shell.user_ns['_dh'][nn] |
|
2249 | ps = self.shell.user_ns['_dh'][nn] | |
2222 | except IndexError: |
|
2250 | except IndexError: | |
2223 | print 'The requested directory does not exist in history.' |
|
2251 | print 'The requested directory does not exist in history.' | |
2224 | return |
|
2252 | return | |
2225 | else: |
|
2253 | else: | |
2226 | opts = {} |
|
2254 | opts = {} | |
2227 | else: |
|
2255 | else: | |
2228 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') |
|
2256 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') | |
2229 | # jump to previous |
|
2257 | # jump to previous | |
2230 | if ps == '-': |
|
2258 | if ps == '-': | |
2231 | try: |
|
2259 | try: | |
2232 | ps = self.shell.user_ns['_dh'][-2] |
|
2260 | ps = self.shell.user_ns['_dh'][-2] | |
2233 | except IndexError: |
|
2261 | except IndexError: | |
2234 | print 'No previous directory to change to.' |
|
2262 | print 'No previous directory to change to.' | |
2235 | return |
|
2263 | return | |
2236 | # jump to bookmark |
|
2264 | # jump to bookmark | |
2237 | elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)): |
|
2265 | elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)): | |
2238 | if bkms.has_key(ps): |
|
2266 | if bkms.has_key(ps): | |
2239 | target = bkms[ps] |
|
2267 | target = bkms[ps] | |
2240 | print '(bookmark:%s) -> %s' % (ps,target) |
|
2268 | print '(bookmark:%s) -> %s' % (ps,target) | |
2241 | ps = target |
|
2269 | ps = target | |
2242 | else: |
|
2270 | else: | |
2243 | if bkms: |
|
2271 | if bkms: | |
2244 | error("Bookmark '%s' not found. " |
|
2272 | error("Bookmark '%s' not found. " | |
2245 | "Use '%bookmark -l' to see your bookmarks." % ps) |
|
2273 | "Use '%bookmark -l' to see your bookmarks." % ps) | |
2246 | else: |
|
2274 | else: | |
2247 | print "Bookmarks not set - use %bookmark <bookmarkname>" |
|
2275 | print "Bookmarks not set - use %bookmark <bookmarkname>" | |
2248 | return |
|
2276 | return | |
2249 |
|
2277 | |||
2250 | # at this point ps should point to the target dir |
|
2278 | # at this point ps should point to the target dir | |
2251 | if ps: |
|
2279 | if ps: | |
2252 | try: |
|
2280 | try: | |
2253 | os.chdir(os.path.expanduser(ps)) |
|
2281 | os.chdir(os.path.expanduser(ps)) | |
2254 | except OSError: |
|
2282 | except OSError: | |
2255 | print sys.exc_info()[1] |
|
2283 | print sys.exc_info()[1] | |
2256 | else: |
|
2284 | else: | |
2257 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2285 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2258 | else: |
|
2286 | else: | |
2259 | os.chdir(self.home_dir) |
|
2287 | os.chdir(self.home_dir) | |
2260 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2288 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2261 | if not 'q' in opts: |
|
2289 | if not 'q' in opts: | |
2262 | print self.shell.user_ns['_dh'][-1] |
|
2290 | print self.shell.user_ns['_dh'][-1] | |
2263 |
|
2291 | |||
2264 | def magic_dhist(self, parameter_s=''): |
|
2292 | def magic_dhist(self, parameter_s=''): | |
2265 | """Print your history of visited directories. |
|
2293 | """Print your history of visited directories. | |
2266 |
|
2294 | |||
2267 | %dhist -> print full history\\ |
|
2295 | %dhist -> print full history\\ | |
2268 | %dhist n -> print last n entries only\\ |
|
2296 | %dhist n -> print last n entries only\\ | |
2269 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ |
|
2297 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ | |
2270 |
|
2298 | |||
2271 | This history is automatically maintained by the %cd command, and |
|
2299 | This history is automatically maintained by the %cd command, and | |
2272 | always available as the global list variable _dh. You can use %cd -<n> |
|
2300 | always available as the global list variable _dh. You can use %cd -<n> | |
2273 | to go to directory number <n>.""" |
|
2301 | to go to directory number <n>.""" | |
2274 |
|
2302 | |||
2275 | dh = self.shell.user_ns['_dh'] |
|
2303 | dh = self.shell.user_ns['_dh'] | |
2276 | if parameter_s: |
|
2304 | if parameter_s: | |
2277 | try: |
|
2305 | try: | |
2278 | args = map(int,parameter_s.split()) |
|
2306 | args = map(int,parameter_s.split()) | |
2279 | except: |
|
2307 | except: | |
2280 | self.arg_err(Magic.magic_dhist) |
|
2308 | self.arg_err(Magic.magic_dhist) | |
2281 | return |
|
2309 | return | |
2282 | if len(args) == 1: |
|
2310 | if len(args) == 1: | |
2283 | ini,fin = max(len(dh)-(args[0]),0),len(dh) |
|
2311 | ini,fin = max(len(dh)-(args[0]),0),len(dh) | |
2284 | elif len(args) == 2: |
|
2312 | elif len(args) == 2: | |
2285 | ini,fin = args |
|
2313 | ini,fin = args | |
2286 | else: |
|
2314 | else: | |
2287 | self.arg_err(Magic.magic_dhist) |
|
2315 | self.arg_err(Magic.magic_dhist) | |
2288 | return |
|
2316 | return | |
2289 | else: |
|
2317 | else: | |
2290 | ini,fin = 0,len(dh) |
|
2318 | ini,fin = 0,len(dh) | |
2291 | nlprint(dh, |
|
2319 | nlprint(dh, | |
2292 | header = 'Directory history (kept in _dh)', |
|
2320 | header = 'Directory history (kept in _dh)', | |
2293 | start=ini,stop=fin) |
|
2321 | start=ini,stop=fin) | |
2294 |
|
2322 | |||
2295 | def magic_env(self, parameter_s=''): |
|
2323 | def magic_env(self, parameter_s=''): | |
2296 | """List environment variables.""" |
|
2324 | """List environment variables.""" | |
2297 |
|
2325 | |||
2298 | # environ is an instance of UserDict |
|
2326 | # environ is an instance of UserDict | |
2299 | return os.environ.data |
|
2327 | return os.environ.data | |
2300 |
|
2328 | |||
2301 | def magic_pushd(self, parameter_s=''): |
|
2329 | def magic_pushd(self, parameter_s=''): | |
2302 | """Place the current dir on stack and change directory. |
|
2330 | """Place the current dir on stack and change directory. | |
2303 |
|
2331 | |||
2304 | Usage:\\ |
|
2332 | Usage:\\ | |
2305 | %pushd ['dirname'] |
|
2333 | %pushd ['dirname'] | |
2306 |
|
2334 | |||
2307 | %pushd with no arguments does a %pushd to your home directory. |
|
2335 | %pushd with no arguments does a %pushd to your home directory. | |
2308 | """ |
|
2336 | """ | |
2309 | if parameter_s == '': parameter_s = '~' |
|
2337 | if parameter_s == '': parameter_s = '~' | |
2310 | if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \ |
|
2338 | if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \ | |
2311 | os.path.expanduser(self.dir_stack[0]): |
|
2339 | os.path.expanduser(self.dir_stack[0]): | |
2312 | try: |
|
2340 | try: | |
2313 | self.magic_cd(parameter_s) |
|
2341 | self.magic_cd(parameter_s) | |
2314 | self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~')) |
|
2342 | self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~')) | |
2315 | self.magic_dirs() |
|
2343 | self.magic_dirs() | |
2316 | except: |
|
2344 | except: | |
2317 | print 'Invalid directory' |
|
2345 | print 'Invalid directory' | |
2318 | else: |
|
2346 | else: | |
2319 | print 'You are already there!' |
|
2347 | print 'You are already there!' | |
2320 |
|
2348 | |||
2321 | def magic_popd(self, parameter_s=''): |
|
2349 | def magic_popd(self, parameter_s=''): | |
2322 | """Change to directory popped off the top of the stack. |
|
2350 | """Change to directory popped off the top of the stack. | |
2323 | """ |
|
2351 | """ | |
2324 | if len (self.dir_stack) > 1: |
|
2352 | if len (self.dir_stack) > 1: | |
2325 | self.dir_stack.pop(0) |
|
2353 | self.dir_stack.pop(0) | |
2326 | self.magic_cd(self.dir_stack[0]) |
|
2354 | self.magic_cd(self.dir_stack[0]) | |
2327 | print self.dir_stack[0] |
|
2355 | print self.dir_stack[0] | |
2328 | else: |
|
2356 | else: | |
2329 | print "You can't remove the starting directory from the stack:",\ |
|
2357 | print "You can't remove the starting directory from the stack:",\ | |
2330 | self.dir_stack |
|
2358 | self.dir_stack | |
2331 |
|
2359 | |||
2332 | def magic_dirs(self, parameter_s=''): |
|
2360 | def magic_dirs(self, parameter_s=''): | |
2333 | """Return the current directory stack.""" |
|
2361 | """Return the current directory stack.""" | |
2334 |
|
2362 | |||
2335 | return self.dir_stack[:] |
|
2363 | return self.dir_stack[:] | |
2336 |
|
2364 | |||
2337 | def magic_sc(self, parameter_s=''): |
|
2365 | def magic_sc(self, parameter_s=''): | |
2338 | """Shell capture - execute a shell command and capture its output. |
|
2366 | """Shell capture - execute a shell command and capture its output. | |
2339 |
|
2367 | |||
2340 | %sc [options] varname=command |
|
2368 | %sc [options] varname=command | |
2341 |
|
2369 | |||
2342 | IPython will run the given command using commands.getoutput(), and |
|
2370 | IPython will run the given command using commands.getoutput(), and | |
2343 | will then update the user's interactive namespace with a variable |
|
2371 | will then update the user's interactive namespace with a variable | |
2344 | called varname, containing the value of the call. Your command can |
|
2372 | called varname, containing the value of the call. Your command can | |
2345 | contain shell wildcards, pipes, etc. |
|
2373 | contain shell wildcards, pipes, etc. | |
2346 |
|
2374 | |||
2347 | The '=' sign in the syntax is mandatory, and the variable name you |
|
2375 | The '=' sign in the syntax is mandatory, and the variable name you | |
2348 | supply must follow Python's standard conventions for valid names. |
|
2376 | supply must follow Python's standard conventions for valid names. | |
2349 |
|
2377 | |||
2350 | Options: |
|
2378 | Options: | |
2351 |
|
2379 | |||
2352 | -l: list output. Split the output on newlines into a list before |
|
2380 | -l: list output. Split the output on newlines into a list before | |
2353 | assigning it to the given variable. By default the output is stored |
|
2381 | assigning it to the given variable. By default the output is stored | |
2354 | as a single string. |
|
2382 | as a single string. | |
2355 |
|
2383 | |||
2356 | -v: verbose. Print the contents of the variable. |
|
2384 | -v: verbose. Print the contents of the variable. | |
2357 |
|
2385 | |||
2358 | In most cases you should not need to split as a list, because the |
|
2386 | In most cases you should not need to split as a list, because the | |
2359 | returned value is a special type of string which can automatically |
|
2387 | returned value is a special type of string which can automatically | |
2360 | provide its contents either as a list (split on newlines) or as a |
|
2388 | provide its contents either as a list (split on newlines) or as a | |
2361 | space-separated string. These are convenient, respectively, either |
|
2389 | space-separated string. These are convenient, respectively, either | |
2362 | for sequential processing or to be passed to a shell command. |
|
2390 | for sequential processing or to be passed to a shell command. | |
2363 |
|
2391 | |||
2364 | For example: |
|
2392 | For example: | |
2365 |
|
2393 | |||
2366 | # Capture into variable a |
|
2394 | # Capture into variable a | |
2367 | In [9]: sc a=ls *py |
|
2395 | In [9]: sc a=ls *py | |
2368 |
|
2396 | |||
2369 | # a is a string with embedded newlines |
|
2397 | # a is a string with embedded newlines | |
2370 | In [10]: a |
|
2398 | In [10]: a | |
2371 | Out[10]: 'setup.py\nwin32_manual_post_install.py' |
|
2399 | Out[10]: 'setup.py\nwin32_manual_post_install.py' | |
2372 |
|
2400 | |||
2373 | # which can be seen as a list: |
|
2401 | # which can be seen as a list: | |
2374 | In [11]: a.l |
|
2402 | In [11]: a.l | |
2375 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] |
|
2403 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] | |
2376 |
|
2404 | |||
2377 | # or as a whitespace-separated string: |
|
2405 | # or as a whitespace-separated string: | |
2378 | In [12]: a.s |
|
2406 | In [12]: a.s | |
2379 | Out[12]: 'setup.py win32_manual_post_install.py' |
|
2407 | Out[12]: 'setup.py win32_manual_post_install.py' | |
2380 |
|
2408 | |||
2381 | # a.s is useful to pass as a single command line: |
|
2409 | # a.s is useful to pass as a single command line: | |
2382 | In [13]: !wc -l $a.s |
|
2410 | In [13]: !wc -l $a.s | |
2383 | 146 setup.py |
|
2411 | 146 setup.py | |
2384 | 130 win32_manual_post_install.py |
|
2412 | 130 win32_manual_post_install.py | |
2385 | 276 total |
|
2413 | 276 total | |
2386 |
|
2414 | |||
2387 | # while the list form is useful to loop over: |
|
2415 | # while the list form is useful to loop over: | |
2388 | In [14]: for f in a.l: |
|
2416 | In [14]: for f in a.l: | |
2389 | ....: !wc -l $f |
|
2417 | ....: !wc -l $f | |
2390 | ....: |
|
2418 | ....: | |
2391 | 146 setup.py |
|
2419 | 146 setup.py | |
2392 | 130 win32_manual_post_install.py |
|
2420 | 130 win32_manual_post_install.py | |
2393 |
|
2421 | |||
2394 | Similiarly, the lists returned by the -l option are also special, in |
|
2422 | Similiarly, the lists returned by the -l option are also special, in | |
2395 | the sense that you can equally invoke the .s attribute on them to |
|
2423 | the sense that you can equally invoke the .s attribute on them to | |
2396 | automatically get a whitespace-separated string from their contents: |
|
2424 | automatically get a whitespace-separated string from their contents: | |
2397 |
|
2425 | |||
2398 | In [1]: sc -l b=ls *py |
|
2426 | In [1]: sc -l b=ls *py | |
2399 |
|
2427 | |||
2400 | In [2]: b |
|
2428 | In [2]: b | |
2401 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] |
|
2429 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] | |
2402 |
|
2430 | |||
2403 | In [3]: b.s |
|
2431 | In [3]: b.s | |
2404 | Out[3]: 'setup.py win32_manual_post_install.py' |
|
2432 | Out[3]: 'setup.py win32_manual_post_install.py' | |
2405 |
|
2433 | |||
2406 | In summary, both the lists and strings used for ouptut capture have |
|
2434 | In summary, both the lists and strings used for ouptut capture have | |
2407 | the following special attributes: |
|
2435 | the following special attributes: | |
2408 |
|
2436 | |||
2409 | .l (or .list) : value as list. |
|
2437 | .l (or .list) : value as list. | |
2410 | .n (or .nlstr): value as newline-separated string. |
|
2438 | .n (or .nlstr): value as newline-separated string. | |
2411 | .s (or .spstr): value as space-separated string. |
|
2439 | .s (or .spstr): value as space-separated string. | |
2412 | """ |
|
2440 | """ | |
2413 |
|
2441 | |||
2414 | opts,args = self.parse_options(parameter_s,'lv') |
|
2442 | opts,args = self.parse_options(parameter_s,'lv') | |
2415 | # Try to get a variable name and command to run |
|
2443 | # Try to get a variable name and command to run | |
2416 | try: |
|
2444 | try: | |
2417 | # the variable name must be obtained from the parse_options |
|
2445 | # the variable name must be obtained from the parse_options | |
2418 | # output, which uses shlex.split to strip options out. |
|
2446 | # output, which uses shlex.split to strip options out. | |
2419 | var,_ = args.split('=',1) |
|
2447 | var,_ = args.split('=',1) | |
2420 | var = var.strip() |
|
2448 | var = var.strip() | |
2421 | # But the the command has to be extracted from the original input |
|
2449 | # But the the command has to be extracted from the original input | |
2422 | # parameter_s, not on what parse_options returns, to avoid the |
|
2450 | # parameter_s, not on what parse_options returns, to avoid the | |
2423 | # quote stripping which shlex.split performs on it. |
|
2451 | # quote stripping which shlex.split performs on it. | |
2424 | _,cmd = parameter_s.split('=',1) |
|
2452 | _,cmd = parameter_s.split('=',1) | |
2425 | except ValueError: |
|
2453 | except ValueError: | |
2426 | var,cmd = '','' |
|
2454 | var,cmd = '','' | |
2427 | if not var: |
|
2455 | if not var: | |
2428 | error('you must specify a variable to assign the command to.') |
|
2456 | error('you must specify a variable to assign the command to.') | |
2429 | return |
|
2457 | return | |
2430 | # If all looks ok, proceed |
|
2458 | # If all looks ok, proceed | |
2431 | out,err = self.shell.getoutputerror(cmd) |
|
2459 | out,err = self.shell.getoutputerror(cmd) | |
2432 | if err: |
|
2460 | if err: | |
2433 | print >> Term.cerr,err |
|
2461 | print >> Term.cerr,err | |
2434 | if opts.has_key('l'): |
|
2462 | if opts.has_key('l'): | |
2435 | out = SList(out.split('\n')) |
|
2463 | out = SList(out.split('\n')) | |
2436 | else: |
|
2464 | else: | |
2437 | out = LSString(out) |
|
2465 | out = LSString(out) | |
2438 | if opts.has_key('v'): |
|
2466 | if opts.has_key('v'): | |
2439 | print '%s ==\n%s' % (var,pformat(out)) |
|
2467 | print '%s ==\n%s' % (var,pformat(out)) | |
2440 | self.shell.user_ns.update({var:out}) |
|
2468 | self.shell.user_ns.update({var:out}) | |
2441 |
|
2469 | |||
2442 | def magic_sx(self, parameter_s=''): |
|
2470 | def magic_sx(self, parameter_s=''): | |
2443 | """Shell execute - run a shell command and capture its output. |
|
2471 | """Shell execute - run a shell command and capture its output. | |
2444 |
|
2472 | |||
2445 | %sx command |
|
2473 | %sx command | |
2446 |
|
2474 | |||
2447 | IPython will run the given command using commands.getoutput(), and |
|
2475 | IPython will run the given command using commands.getoutput(), and | |
2448 | return the result formatted as a list (split on '\\n'). Since the |
|
2476 | return the result formatted as a list (split on '\\n'). Since the | |
2449 | output is _returned_, it will be stored in ipython's regular output |
|
2477 | output is _returned_, it will be stored in ipython's regular output | |
2450 | cache Out[N] and in the '_N' automatic variables. |
|
2478 | cache Out[N] and in the '_N' automatic variables. | |
2451 |
|
2479 | |||
2452 | Notes: |
|
2480 | Notes: | |
2453 |
|
2481 | |||
2454 | 1) If an input line begins with '!!', then %sx is automatically |
|
2482 | 1) If an input line begins with '!!', then %sx is automatically | |
2455 | invoked. That is, while: |
|
2483 | invoked. That is, while: | |
2456 | !ls |
|
2484 | !ls | |
2457 | causes ipython to simply issue system('ls'), typing |
|
2485 | causes ipython to simply issue system('ls'), typing | |
2458 | !!ls |
|
2486 | !!ls | |
2459 | is a shorthand equivalent to: |
|
2487 | is a shorthand equivalent to: | |
2460 | %sx ls |
|
2488 | %sx ls | |
2461 |
|
2489 | |||
2462 | 2) %sx differs from %sc in that %sx automatically splits into a list, |
|
2490 | 2) %sx differs from %sc in that %sx automatically splits into a list, | |
2463 | like '%sc -l'. The reason for this is to make it as easy as possible |
|
2491 | like '%sc -l'. The reason for this is to make it as easy as possible | |
2464 | to process line-oriented shell output via further python commands. |
|
2492 | to process line-oriented shell output via further python commands. | |
2465 | %sc is meant to provide much finer control, but requires more |
|
2493 | %sc is meant to provide much finer control, but requires more | |
2466 | typing. |
|
2494 | typing. | |
2467 |
|
2495 | |||
2468 | 3) Just like %sc -l, this is a list with special attributes: |
|
2496 | 3) Just like %sc -l, this is a list with special attributes: | |
2469 |
|
2497 | |||
2470 | .l (or .list) : value as list. |
|
2498 | .l (or .list) : value as list. | |
2471 | .n (or .nlstr): value as newline-separated string. |
|
2499 | .n (or .nlstr): value as newline-separated string. | |
2472 | .s (or .spstr): value as whitespace-separated string. |
|
2500 | .s (or .spstr): value as whitespace-separated string. | |
2473 |
|
2501 | |||
2474 | This is very useful when trying to use such lists as arguments to |
|
2502 | This is very useful when trying to use such lists as arguments to | |
2475 | system commands.""" |
|
2503 | system commands.""" | |
2476 |
|
2504 | |||
2477 | if parameter_s: |
|
2505 | if parameter_s: | |
2478 | out,err = self.shell.getoutputerror(parameter_s) |
|
2506 | out,err = self.shell.getoutputerror(parameter_s) | |
2479 | if err: |
|
2507 | if err: | |
2480 | print >> Term.cerr,err |
|
2508 | print >> Term.cerr,err | |
2481 | return SList(out.split('\n')) |
|
2509 | return SList(out.split('\n')) | |
2482 |
|
2510 | |||
2483 | def magic_bg(self, parameter_s=''): |
|
2511 | def magic_bg(self, parameter_s=''): | |
2484 | """Run a job in the background, in a separate thread. |
|
2512 | """Run a job in the background, in a separate thread. | |
2485 |
|
2513 | |||
2486 | For example, |
|
2514 | For example, | |
2487 |
|
2515 | |||
2488 | %bg myfunc(x,y,z=1) |
|
2516 | %bg myfunc(x,y,z=1) | |
2489 |
|
2517 | |||
2490 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the |
|
2518 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the | |
2491 | execution starts, a message will be printed indicating the job |
|
2519 | execution starts, a message will be printed indicating the job | |
2492 | number. If your job number is 5, you can use |
|
2520 | number. If your job number is 5, you can use | |
2493 |
|
2521 | |||
2494 | myvar = jobs.result(5) or myvar = jobs[5].result |
|
2522 | myvar = jobs.result(5) or myvar = jobs[5].result | |
2495 |
|
2523 | |||
2496 | to assign this result to variable 'myvar'. |
|
2524 | to assign this result to variable 'myvar'. | |
2497 |
|
2525 | |||
2498 | IPython has a job manager, accessible via the 'jobs' object. You can |
|
2526 | IPython has a job manager, accessible via the 'jobs' object. You can | |
2499 | type jobs? to get more information about it, and use jobs.<TAB> to see |
|
2527 | type jobs? to get more information about it, and use jobs.<TAB> to see | |
2500 | its attributes. All attributes not starting with an underscore are |
|
2528 | its attributes. All attributes not starting with an underscore are | |
2501 | meant for public use. |
|
2529 | meant for public use. | |
2502 |
|
2530 | |||
2503 | In particular, look at the jobs.new() method, which is used to create |
|
2531 | In particular, look at the jobs.new() method, which is used to create | |
2504 | new jobs. This magic %bg function is just a convenience wrapper |
|
2532 | new jobs. This magic %bg function is just a convenience wrapper | |
2505 | around jobs.new(), for expression-based jobs. If you want to create a |
|
2533 | around jobs.new(), for expression-based jobs. If you want to create a | |
2506 | new job with an explicit function object and arguments, you must call |
|
2534 | new job with an explicit function object and arguments, you must call | |
2507 | jobs.new() directly. |
|
2535 | jobs.new() directly. | |
2508 |
|
2536 | |||
2509 | The jobs.new docstring also describes in detail several important |
|
2537 | The jobs.new docstring also describes in detail several important | |
2510 | caveats associated with a thread-based model for background job |
|
2538 | caveats associated with a thread-based model for background job | |
2511 | execution. Type jobs.new? for details. |
|
2539 | execution. Type jobs.new? for details. | |
2512 |
|
2540 | |||
2513 | You can check the status of all jobs with jobs.status(). |
|
2541 | You can check the status of all jobs with jobs.status(). | |
2514 |
|
2542 | |||
2515 | The jobs variable is set by IPython into the Python builtin namespace. |
|
2543 | The jobs variable is set by IPython into the Python builtin namespace. | |
2516 | If you ever declare a variable named 'jobs', you will shadow this |
|
2544 | If you ever declare a variable named 'jobs', you will shadow this | |
2517 | name. You can either delete your global jobs variable to regain |
|
2545 | name. You can either delete your global jobs variable to regain | |
2518 | access to the job manager, or make a new name and assign it manually |
|
2546 | access to the job manager, or make a new name and assign it manually | |
2519 | to the manager (stored in IPython's namespace). For example, to |
|
2547 | to the manager (stored in IPython's namespace). For example, to | |
2520 | assign the job manager to the Jobs name, use: |
|
2548 | assign the job manager to the Jobs name, use: | |
2521 |
|
2549 | |||
2522 | Jobs = __builtins__.jobs""" |
|
2550 | Jobs = __builtins__.jobs""" | |
2523 |
|
2551 | |||
2524 | self.shell.jobs.new(parameter_s,self.shell.user_ns) |
|
2552 | self.shell.jobs.new(parameter_s,self.shell.user_ns) | |
2525 |
|
2553 | |||
2526 | def magic_bookmark(self, parameter_s=''): |
|
2554 | def magic_bookmark(self, parameter_s=''): | |
2527 | """Manage IPython's bookmark system. |
|
2555 | """Manage IPython's bookmark system. | |
2528 |
|
2556 | |||
2529 | %bookmark <name> - set bookmark to current dir |
|
2557 | %bookmark <name> - set bookmark to current dir | |
2530 | %bookmark <name> <dir> - set bookmark to <dir> |
|
2558 | %bookmark <name> <dir> - set bookmark to <dir> | |
2531 | %bookmark -l - list all bookmarks |
|
2559 | %bookmark -l - list all bookmarks | |
2532 | %bookmark -d <name> - remove bookmark |
|
2560 | %bookmark -d <name> - remove bookmark | |
2533 | %bookmark -r - remove all bookmarks |
|
2561 | %bookmark -r - remove all bookmarks | |
2534 |
|
2562 | |||
2535 | You can later on access a bookmarked folder with: |
|
2563 | You can later on access a bookmarked folder with: | |
2536 | %cd -b <name> |
|
2564 | %cd -b <name> | |
2537 | or simply '%cd <name>' if there is no directory called <name> AND |
|
2565 | or simply '%cd <name>' if there is no directory called <name> AND | |
2538 | there is such a bookmark defined. |
|
2566 | there is such a bookmark defined. | |
2539 |
|
2567 | |||
2540 | Your bookmarks persist through IPython sessions, but they are |
|
2568 | Your bookmarks persist through IPython sessions, but they are | |
2541 | associated with each profile.""" |
|
2569 | associated with each profile.""" | |
2542 |
|
2570 | |||
2543 | opts,args = self.parse_options(parameter_s,'drl',mode='list') |
|
2571 | opts,args = self.parse_options(parameter_s,'drl',mode='list') | |
2544 | if len(args) > 2: |
|
2572 | if len(args) > 2: | |
2545 | error('You can only give at most two arguments') |
|
2573 | error('You can only give at most two arguments') | |
2546 | return |
|
2574 | return | |
2547 |
|
2575 | |||
2548 | bkms = self.shell.persist.get('bookmarks',{}) |
|
2576 | bkms = self.shell.persist.get('bookmarks',{}) | |
2549 |
|
2577 | |||
2550 | if opts.has_key('d'): |
|
2578 | if opts.has_key('d'): | |
2551 | try: |
|
2579 | try: | |
2552 | todel = args[0] |
|
2580 | todel = args[0] | |
2553 | except IndexError: |
|
2581 | except IndexError: | |
2554 | error('You must provide a bookmark to delete') |
|
2582 | error('You must provide a bookmark to delete') | |
2555 | else: |
|
2583 | else: | |
2556 | try: |
|
2584 | try: | |
2557 | del bkms[todel] |
|
2585 | del bkms[todel] | |
2558 | except: |
|
2586 | except: | |
2559 | error("Can't delete bookmark '%s'" % todel) |
|
2587 | error("Can't delete bookmark '%s'" % todel) | |
2560 | elif opts.has_key('r'): |
|
2588 | elif opts.has_key('r'): | |
2561 | bkms = {} |
|
2589 | bkms = {} | |
2562 | elif opts.has_key('l'): |
|
2590 | elif opts.has_key('l'): | |
2563 | bks = bkms.keys() |
|
2591 | bks = bkms.keys() | |
2564 | bks.sort() |
|
2592 | bks.sort() | |
2565 | if bks: |
|
2593 | if bks: | |
2566 | size = max(map(len,bks)) |
|
2594 | size = max(map(len,bks)) | |
2567 | else: |
|
2595 | else: | |
2568 | size = 0 |
|
2596 | size = 0 | |
2569 | fmt = '%-'+str(size)+'s -> %s' |
|
2597 | fmt = '%-'+str(size)+'s -> %s' | |
2570 | print 'Current bookmarks:' |
|
2598 | print 'Current bookmarks:' | |
2571 | for bk in bks: |
|
2599 | for bk in bks: | |
2572 | print fmt % (bk,bkms[bk]) |
|
2600 | print fmt % (bk,bkms[bk]) | |
2573 | else: |
|
2601 | else: | |
2574 | if not args: |
|
2602 | if not args: | |
2575 | error("You must specify the bookmark name") |
|
2603 | error("You must specify the bookmark name") | |
2576 | elif len(args)==1: |
|
2604 | elif len(args)==1: | |
2577 | bkms[args[0]] = os.getcwd() |
|
2605 | bkms[args[0]] = os.getcwd() | |
2578 | elif len(args)==2: |
|
2606 | elif len(args)==2: | |
2579 | bkms[args[0]] = args[1] |
|
2607 | bkms[args[0]] = args[1] | |
2580 | self.persist['bookmarks'] = bkms |
|
2608 | self.persist['bookmarks'] = bkms | |
2581 |
|
2609 | |||
2582 | def magic_pycat(self, parameter_s=''): |
|
2610 | def magic_pycat(self, parameter_s=''): | |
2583 | """Show a syntax-highlighted file through a pager. |
|
2611 | """Show a syntax-highlighted file through a pager. | |
2584 |
|
2612 | |||
2585 | This magic is similar to the cat utility, but it will assume the file |
|
2613 | This magic is similar to the cat utility, but it will assume the file | |
2586 | to be Python source and will show it with syntax highlighting. """ |
|
2614 | to be Python source and will show it with syntax highlighting. """ | |
2587 |
|
2615 | |||
2588 | filename = get_py_filename(parameter_s) |
|
2616 | filename = get_py_filename(parameter_s) | |
2589 | page(self.shell.colorize(file_read(filename)), |
|
2617 | page(self.shell.colorize(file_read(filename)), | |
2590 | screen_lines=self.shell.rc.screen_length) |
|
2618 | screen_lines=self.shell.rc.screen_length) | |
2591 |
|
2619 | |||
2592 | # end Magic |
|
2620 | # end Magic |
@@ -1,913 +1,917 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """IPython Shell classes. |
|
2 | """IPython Shell classes. | |
3 |
|
3 | |||
4 | All the matplotlib support code was co-developed with John Hunter, |
|
4 | All the matplotlib support code was co-developed with John Hunter, | |
5 | matplotlib's author. |
|
5 | matplotlib's author. | |
6 |
|
6 | |||
7 |
$Id: Shell.py 96 |
|
7 | $Id: Shell.py 965 2005-12-28 23:23:09Z fperez $""" | |
8 |
|
8 | |||
9 | #***************************************************************************** |
|
9 | #***************************************************************************** | |
10 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> |
|
10 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> | |
11 | # |
|
11 | # | |
12 | # Distributed under the terms of the BSD License. The full license is in |
|
12 | # Distributed under the terms of the BSD License. The full license is in | |
13 | # the file COPYING, distributed as part of this software. |
|
13 | # the file COPYING, distributed as part of this software. | |
14 | #***************************************************************************** |
|
14 | #***************************************************************************** | |
15 |
|
15 | |||
16 | from IPython import Release |
|
16 | from IPython import Release | |
17 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
17 | __author__ = '%s <%s>' % Release.authors['Fernando'] | |
18 | __license__ = Release.license |
|
18 | __license__ = Release.license | |
19 |
|
19 | |||
20 | # Code begins |
|
20 | # Code begins | |
21 | import __main__ |
|
21 | import __main__ | |
22 | import __builtin__ |
|
22 | import __builtin__ | |
23 | import os |
|
23 | import os | |
24 | import sys |
|
24 | import sys | |
25 | import signal |
|
25 | import signal | |
26 | import threading |
|
26 | import threading | |
27 |
|
27 | |||
28 | import IPython |
|
28 | import IPython | |
29 | from IPython import ultraTB |
|
29 | from IPython import ultraTB | |
30 | from IPython.genutils import Term,warn,error,flag_calls |
|
30 | from IPython.genutils import Term,warn,error,flag_calls | |
31 | from IPython.iplib import InteractiveShell |
|
31 | from IPython.iplib import InteractiveShell | |
32 | from IPython.ipmaker import make_IPython |
|
32 | from IPython.ipmaker import make_IPython | |
33 | from IPython.Magic import Magic |
|
33 | from IPython.Magic import Magic | |
34 | from IPython.Struct import Struct |
|
34 | from IPython.Struct import Struct | |
35 |
|
35 | |||
36 | # global flag to pass around information about Ctrl-C without exceptions |
|
36 | # global flag to pass around information about Ctrl-C without exceptions | |
37 | KBINT = False |
|
37 | KBINT = False | |
38 |
|
38 | |||
39 | # global flag to turn on/off Tk support. |
|
39 | # global flag to turn on/off Tk support. | |
40 | USE_TK = False |
|
40 | USE_TK = False | |
41 |
|
41 | |||
42 | #----------------------------------------------------------------------------- |
|
42 | #----------------------------------------------------------------------------- | |
43 | # This class is trivial now, but I want to have it in to publish a clean |
|
43 | # This class is trivial now, but I want to have it in to publish a clean | |
44 | # interface. Later when the internals are reorganized, code that uses this |
|
44 | # interface. Later when the internals are reorganized, code that uses this | |
45 | # shouldn't have to change. |
|
45 | # shouldn't have to change. | |
46 |
|
46 | |||
47 | class IPShell: |
|
47 | class IPShell: | |
48 | """Create an IPython instance.""" |
|
48 | """Create an IPython instance.""" | |
49 |
|
49 | |||
50 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
50 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, | |
51 | debug=1,shell_class=InteractiveShell): |
|
51 | debug=1,shell_class=InteractiveShell): | |
52 | self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns, |
|
52 | self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns, | |
53 | debug=debug,shell_class=shell_class) |
|
53 | debug=debug,shell_class=shell_class) | |
54 |
|
54 | |||
55 | def mainloop(self,sys_exit=0,banner=None): |
|
55 | def mainloop(self,sys_exit=0,banner=None): | |
56 | self.IP.mainloop(banner) |
|
56 | self.IP.mainloop(banner) | |
57 | if sys_exit: |
|
57 | if sys_exit: | |
58 | sys.exit() |
|
58 | sys.exit() | |
59 |
|
59 | |||
60 | #----------------------------------------------------------------------------- |
|
60 | #----------------------------------------------------------------------------- | |
61 | class IPShellEmbed: |
|
61 | class IPShellEmbed: | |
62 | """Allow embedding an IPython shell into a running program. |
|
62 | """Allow embedding an IPython shell into a running program. | |
63 |
|
63 | |||
64 | Instances of this class are callable, with the __call__ method being an |
|
64 | Instances of this class are callable, with the __call__ method being an | |
65 | alias to the embed() method of an InteractiveShell instance. |
|
65 | alias to the embed() method of an InteractiveShell instance. | |
66 |
|
66 | |||
67 | Usage (see also the example-embed.py file for a running example): |
|
67 | Usage (see also the example-embed.py file for a running example): | |
68 |
|
68 | |||
69 | ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override]) |
|
69 | ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override]) | |
70 |
|
70 | |||
71 | - argv: list containing valid command-line options for IPython, as they |
|
71 | - argv: list containing valid command-line options for IPython, as they | |
72 | would appear in sys.argv[1:]. |
|
72 | would appear in sys.argv[1:]. | |
73 |
|
73 | |||
74 | For example, the following command-line options: |
|
74 | For example, the following command-line options: | |
75 |
|
75 | |||
76 | $ ipython -prompt_in1 'Input <\\#>' -colors LightBG |
|
76 | $ ipython -prompt_in1 'Input <\\#>' -colors LightBG | |
77 |
|
77 | |||
78 | would be passed in the argv list as: |
|
78 | would be passed in the argv list as: | |
79 |
|
79 | |||
80 | ['-prompt_in1','Input <\\#>','-colors','LightBG'] |
|
80 | ['-prompt_in1','Input <\\#>','-colors','LightBG'] | |
81 |
|
81 | |||
82 | - banner: string which gets printed every time the interpreter starts. |
|
82 | - banner: string which gets printed every time the interpreter starts. | |
83 |
|
83 | |||
84 | - exit_msg: string which gets printed every time the interpreter exits. |
|
84 | - exit_msg: string which gets printed every time the interpreter exits. | |
85 |
|
85 | |||
86 | - rc_override: a dict or Struct of configuration options such as those |
|
86 | - rc_override: a dict or Struct of configuration options such as those | |
87 | used by IPython. These options are read from your ~/.ipython/ipythonrc |
|
87 | used by IPython. These options are read from your ~/.ipython/ipythonrc | |
88 | file when the Shell object is created. Passing an explicit rc_override |
|
88 | file when the Shell object is created. Passing an explicit rc_override | |
89 | dict with any options you want allows you to override those values at |
|
89 | dict with any options you want allows you to override those values at | |
90 | creation time without having to modify the file. This way you can create |
|
90 | creation time without having to modify the file. This way you can create | |
91 | embeddable instances configured in any way you want without editing any |
|
91 | embeddable instances configured in any way you want without editing any | |
92 | global files (thus keeping your interactive IPython configuration |
|
92 | global files (thus keeping your interactive IPython configuration | |
93 | unchanged). |
|
93 | unchanged). | |
94 |
|
94 | |||
95 | Then the ipshell instance can be called anywhere inside your code: |
|
95 | Then the ipshell instance can be called anywhere inside your code: | |
96 |
|
96 | |||
97 | ipshell(header='') -> Opens up an IPython shell. |
|
97 | ipshell(header='') -> Opens up an IPython shell. | |
98 |
|
98 | |||
99 | - header: string printed by the IPython shell upon startup. This can let |
|
99 | - header: string printed by the IPython shell upon startup. This can let | |
100 | you know where in your code you are when dropping into the shell. Note |
|
100 | you know where in your code you are when dropping into the shell. Note | |
101 | that 'banner' gets prepended to all calls, so header is used for |
|
101 | that 'banner' gets prepended to all calls, so header is used for | |
102 | location-specific information. |
|
102 | location-specific information. | |
103 |
|
103 | |||
104 | For more details, see the __call__ method below. |
|
104 | For more details, see the __call__ method below. | |
105 |
|
105 | |||
106 | When the IPython shell is exited with Ctrl-D, normal program execution |
|
106 | When the IPython shell is exited with Ctrl-D, normal program execution | |
107 | resumes. |
|
107 | resumes. | |
108 |
|
108 | |||
109 | This functionality was inspired by a posting on comp.lang.python by cmkl |
|
109 | This functionality was inspired by a posting on comp.lang.python by cmkl | |
110 | <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and |
|
110 | <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and | |
111 | by the IDL stop/continue commands.""" |
|
111 | by the IDL stop/continue commands.""" | |
112 |
|
112 | |||
113 | def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None): |
|
113 | def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None): | |
114 | """Note that argv here is a string, NOT a list.""" |
|
114 | """Note that argv here is a string, NOT a list.""" | |
115 | self.set_banner(banner) |
|
115 | self.set_banner(banner) | |
116 | self.set_exit_msg(exit_msg) |
|
116 | self.set_exit_msg(exit_msg) | |
117 | self.set_dummy_mode(0) |
|
117 | self.set_dummy_mode(0) | |
118 |
|
118 | |||
119 | # sys.displayhook is a global, we need to save the user's original |
|
119 | # sys.displayhook is a global, we need to save the user's original | |
120 | # Don't rely on __displayhook__, as the user may have changed that. |
|
120 | # Don't rely on __displayhook__, as the user may have changed that. | |
121 | self.sys_displayhook_ori = sys.displayhook |
|
121 | self.sys_displayhook_ori = sys.displayhook | |
122 |
|
122 | |||
123 | # save readline completer status |
|
123 | # save readline completer status | |
124 | try: |
|
124 | try: | |
125 | #print 'Save completer',sys.ipcompleter # dbg |
|
125 | #print 'Save completer',sys.ipcompleter # dbg | |
126 | self.sys_ipcompleter_ori = sys.ipcompleter |
|
126 | self.sys_ipcompleter_ori = sys.ipcompleter | |
127 | except: |
|
127 | except: | |
128 | pass # not nested with IPython |
|
128 | pass # not nested with IPython | |
129 |
|
129 | |||
130 | # FIXME. Passing user_ns breaks namespace handling. |
|
130 | # FIXME. Passing user_ns breaks namespace handling. | |
131 | #self.IP = make_IPython(argv,user_ns=__main__.__dict__) |
|
131 | #self.IP = make_IPython(argv,user_ns=__main__.__dict__) | |
132 | self.IP = make_IPython(argv,rc_override=rc_override,embedded=True) |
|
132 | self.IP = make_IPython(argv,rc_override=rc_override,embedded=True) | |
133 |
|
133 | |||
134 | # copy our own displayhook also |
|
134 | # copy our own displayhook also | |
135 | self.sys_displayhook_embed = sys.displayhook |
|
135 | self.sys_displayhook_embed = sys.displayhook | |
136 | # and leave the system's display hook clean |
|
136 | # and leave the system's display hook clean | |
137 | sys.displayhook = self.sys_displayhook_ori |
|
137 | sys.displayhook = self.sys_displayhook_ori | |
138 | # don't use the ipython crash handler so that user exceptions aren't |
|
138 | # don't use the ipython crash handler so that user exceptions aren't | |
139 | # trapped |
|
139 | # trapped | |
140 | sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors, |
|
140 | sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors, | |
141 | mode = self.IP.rc.xmode, |
|
141 | mode = self.IP.rc.xmode, | |
142 | call_pdb = self.IP.rc.pdb) |
|
142 | call_pdb = self.IP.rc.pdb) | |
143 | self.restore_system_completer() |
|
143 | self.restore_system_completer() | |
144 |
|
144 | |||
145 | def restore_system_completer(self): |
|
145 | def restore_system_completer(self): | |
146 | """Restores the readline completer which was in place. |
|
146 | """Restores the readline completer which was in place. | |
147 |
|
147 | |||
148 | This allows embedded IPython within IPython not to disrupt the |
|
148 | This allows embedded IPython within IPython not to disrupt the | |
149 | parent's completion. |
|
149 | parent's completion. | |
150 | """ |
|
150 | """ | |
151 |
|
151 | |||
152 | try: |
|
152 | try: | |
153 | self.IP.readline.set_completer(self.sys_ipcompleter_ori) |
|
153 | self.IP.readline.set_completer(self.sys_ipcompleter_ori) | |
154 | sys.ipcompleter = self.sys_ipcompleter_ori |
|
154 | sys.ipcompleter = self.sys_ipcompleter_ori | |
155 | except: |
|
155 | except: | |
156 | pass |
|
156 | pass | |
157 |
|
157 | |||
158 | def __call__(self,header='',local_ns=None,global_ns=None,dummy=None): |
|
158 | def __call__(self,header='',local_ns=None,global_ns=None,dummy=None): | |
159 | """Activate the interactive interpreter. |
|
159 | """Activate the interactive interpreter. | |
160 |
|
160 | |||
161 | __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start |
|
161 | __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start | |
162 | the interpreter shell with the given local and global namespaces, and |
|
162 | the interpreter shell with the given local and global namespaces, and | |
163 | optionally print a header string at startup. |
|
163 | optionally print a header string at startup. | |
164 |
|
164 | |||
165 | The shell can be globally activated/deactivated using the |
|
165 | The shell can be globally activated/deactivated using the | |
166 | set/get_dummy_mode methods. This allows you to turn off a shell used |
|
166 | set/get_dummy_mode methods. This allows you to turn off a shell used | |
167 | for debugging globally. |
|
167 | for debugging globally. | |
168 |
|
168 | |||
169 | However, *each* time you call the shell you can override the current |
|
169 | However, *each* time you call the shell you can override the current | |
170 | state of dummy_mode with the optional keyword parameter 'dummy'. For |
|
170 | state of dummy_mode with the optional keyword parameter 'dummy'. For | |
171 | example, if you set dummy mode on with IPShell.set_dummy_mode(1), you |
|
171 | example, if you set dummy mode on with IPShell.set_dummy_mode(1), you | |
172 | can still have a specific call work by making it as IPShell(dummy=0). |
|
172 | can still have a specific call work by making it as IPShell(dummy=0). | |
173 |
|
173 | |||
174 | The optional keyword parameter dummy controls whether the call |
|
174 | The optional keyword parameter dummy controls whether the call | |
175 | actually does anything. """ |
|
175 | actually does anything. """ | |
176 |
|
176 | |||
177 | # Allow the dummy parameter to override the global __dummy_mode |
|
177 | # Allow the dummy parameter to override the global __dummy_mode | |
178 | if dummy or (dummy != 0 and self.__dummy_mode): |
|
178 | if dummy or (dummy != 0 and self.__dummy_mode): | |
179 | return |
|
179 | return | |
180 |
|
180 | |||
181 | # Set global subsystems (display,completions) to our values |
|
181 | # Set global subsystems (display,completions) to our values | |
182 | sys.displayhook = self.sys_displayhook_embed |
|
182 | sys.displayhook = self.sys_displayhook_embed | |
183 | if self.IP.has_readline: |
|
183 | if self.IP.has_readline: | |
184 | self.IP.readline.set_completer(self.IP.Completer.complete) |
|
184 | self.IP.readline.set_completer(self.IP.Completer.complete) | |
185 |
|
185 | |||
186 | if self.banner and header: |
|
186 | if self.banner and header: | |
187 | format = '%s\n%s\n' |
|
187 | format = '%s\n%s\n' | |
188 | else: |
|
188 | else: | |
189 | format = '%s%s\n' |
|
189 | format = '%s%s\n' | |
190 | banner = format % (self.banner,header) |
|
190 | banner = format % (self.banner,header) | |
191 |
|
191 | |||
192 | # Call the embedding code with a stack depth of 1 so it can skip over |
|
192 | # Call the embedding code with a stack depth of 1 so it can skip over | |
193 | # our call and get the original caller's namespaces. |
|
193 | # our call and get the original caller's namespaces. | |
194 | self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1) |
|
194 | self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1) | |
195 |
|
195 | |||
196 | if self.exit_msg: |
|
196 | if self.exit_msg: | |
197 | print self.exit_msg |
|
197 | print self.exit_msg | |
198 |
|
198 | |||
199 | # Restore global systems (display, completion) |
|
199 | # Restore global systems (display, completion) | |
200 | sys.displayhook = self.sys_displayhook_ori |
|
200 | sys.displayhook = self.sys_displayhook_ori | |
201 | self.restore_system_completer() |
|
201 | self.restore_system_completer() | |
202 |
|
202 | |||
203 | def set_dummy_mode(self,dummy): |
|
203 | def set_dummy_mode(self,dummy): | |
204 | """Sets the embeddable shell's dummy mode parameter. |
|
204 | """Sets the embeddable shell's dummy mode parameter. | |
205 |
|
205 | |||
206 | set_dummy_mode(dummy): dummy = 0 or 1. |
|
206 | set_dummy_mode(dummy): dummy = 0 or 1. | |
207 |
|
207 | |||
208 | This parameter is persistent and makes calls to the embeddable shell |
|
208 | This parameter is persistent and makes calls to the embeddable shell | |
209 | silently return without performing any action. This allows you to |
|
209 | silently return without performing any action. This allows you to | |
210 | globally activate or deactivate a shell you're using with a single call. |
|
210 | globally activate or deactivate a shell you're using with a single call. | |
211 |
|
211 | |||
212 | If you need to manually""" |
|
212 | If you need to manually""" | |
213 |
|
213 | |||
214 | if dummy not in [0,1,False,True]: |
|
214 | if dummy not in [0,1,False,True]: | |
215 | raise ValueError,'dummy parameter must be boolean' |
|
215 | raise ValueError,'dummy parameter must be boolean' | |
216 | self.__dummy_mode = dummy |
|
216 | self.__dummy_mode = dummy | |
217 |
|
217 | |||
218 | def get_dummy_mode(self): |
|
218 | def get_dummy_mode(self): | |
219 | """Return the current value of the dummy mode parameter. |
|
219 | """Return the current value of the dummy mode parameter. | |
220 | """ |
|
220 | """ | |
221 | return self.__dummy_mode |
|
221 | return self.__dummy_mode | |
222 |
|
222 | |||
223 | def set_banner(self,banner): |
|
223 | def set_banner(self,banner): | |
224 | """Sets the global banner. |
|
224 | """Sets the global banner. | |
225 |
|
225 | |||
226 | This banner gets prepended to every header printed when the shell |
|
226 | This banner gets prepended to every header printed when the shell | |
227 | instance is called.""" |
|
227 | instance is called.""" | |
228 |
|
228 | |||
229 | self.banner = banner |
|
229 | self.banner = banner | |
230 |
|
230 | |||
231 | def set_exit_msg(self,exit_msg): |
|
231 | def set_exit_msg(self,exit_msg): | |
232 | """Sets the global exit_msg. |
|
232 | """Sets the global exit_msg. | |
233 |
|
233 | |||
234 | This exit message gets printed upon exiting every time the embedded |
|
234 | This exit message gets printed upon exiting every time the embedded | |
235 | shell is called. It is None by default. """ |
|
235 | shell is called. It is None by default. """ | |
236 |
|
236 | |||
237 | self.exit_msg = exit_msg |
|
237 | self.exit_msg = exit_msg | |
238 |
|
238 | |||
239 | #----------------------------------------------------------------------------- |
|
239 | #----------------------------------------------------------------------------- | |
240 | def sigint_handler (signum,stack_frame): |
|
240 | def sigint_handler (signum,stack_frame): | |
241 | """Sigint handler for threaded apps. |
|
241 | """Sigint handler for threaded apps. | |
242 |
|
242 | |||
243 | This is a horrible hack to pass information about SIGINT _without_ using |
|
243 | This is a horrible hack to pass information about SIGINT _without_ using | |
244 | exceptions, since I haven't been able to properly manage cross-thread |
|
244 | exceptions, since I haven't been able to properly manage cross-thread | |
245 | exceptions in GTK/WX. In fact, I don't think it can be done (or at least |
|
245 | exceptions in GTK/WX. In fact, I don't think it can be done (or at least | |
246 | that's my understanding from a c.l.py thread where this was discussed).""" |
|
246 | that's my understanding from a c.l.py thread where this was discussed).""" | |
247 |
|
247 | |||
248 | global KBINT |
|
248 | global KBINT | |
249 |
|
249 | |||
250 | print '\nKeyboardInterrupt - Press <Enter> to continue.', |
|
250 | print '\nKeyboardInterrupt - Press <Enter> to continue.', | |
251 | Term.cout.flush() |
|
251 | Term.cout.flush() | |
252 | # Set global flag so that runsource can know that Ctrl-C was hit |
|
252 | # Set global flag so that runsource can know that Ctrl-C was hit | |
253 | KBINT = True |
|
253 | KBINT = True | |
254 |
|
254 | |||
255 | class MTInteractiveShell(InteractiveShell): |
|
255 | class MTInteractiveShell(InteractiveShell): | |
256 | """Simple multi-threaded shell.""" |
|
256 | """Simple multi-threaded shell.""" | |
257 |
|
257 | |||
258 | # Threading strategy taken from: |
|
258 | # Threading strategy taken from: | |
259 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian |
|
259 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian | |
260 | # McErlean and John Finlay. Modified with corrections by Antoon Pardon, |
|
260 | # McErlean and John Finlay. Modified with corrections by Antoon Pardon, | |
261 | # from the pygtk mailing list, to avoid lockups with system calls. |
|
261 | # from the pygtk mailing list, to avoid lockups with system calls. | |
262 |
|
262 | |||
|
263 | # class attribute to indicate whether the class supports threads or not. | |||
|
264 | # Subclasses with thread support should override this as needed. | |||
|
265 | isthreaded = True | |||
|
266 | ||||
263 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
267 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
264 | user_ns=None,user_global_ns=None,banner2='',**kw): |
|
268 | user_ns=None,user_global_ns=None,banner2='',**kw): | |
265 | """Similar to the normal InteractiveShell, but with threading control""" |
|
269 | """Similar to the normal InteractiveShell, but with threading control""" | |
266 |
|
270 | |||
267 | InteractiveShell.__init__(self,name,usage,rc,user_ns, |
|
271 | InteractiveShell.__init__(self,name,usage,rc,user_ns, | |
268 | user_global_ns,banner2) |
|
272 | user_global_ns,banner2) | |
269 |
|
273 | |||
270 | # Locking control variable |
|
274 | # Locking control variable | |
271 | self.thread_ready = threading.Condition() |
|
275 | self.thread_ready = threading.Condition() | |
272 |
|
276 | |||
273 | # Stuff to do at closing time |
|
277 | # Stuff to do at closing time | |
274 | self._kill = False |
|
278 | self._kill = False | |
275 | on_kill = kw.get('on_kill') |
|
279 | on_kill = kw.get('on_kill') | |
276 | if on_kill is None: |
|
280 | if on_kill is None: | |
277 | on_kill = [] |
|
281 | on_kill = [] | |
278 | # Check that all things to kill are callable: |
|
282 | # Check that all things to kill are callable: | |
279 | for t in on_kill: |
|
283 | for t in on_kill: | |
280 | if not callable(t): |
|
284 | if not callable(t): | |
281 | raise TypeError,'on_kill must be a list of callables' |
|
285 | raise TypeError,'on_kill must be a list of callables' | |
282 | self.on_kill = on_kill |
|
286 | self.on_kill = on_kill | |
283 |
|
287 | |||
284 | def runsource(self, source, filename="<input>", symbol="single"): |
|
288 | def runsource(self, source, filename="<input>", symbol="single"): | |
285 | """Compile and run some source in the interpreter. |
|
289 | """Compile and run some source in the interpreter. | |
286 |
|
290 | |||
287 | Modified version of code.py's runsource(), to handle threading issues. |
|
291 | Modified version of code.py's runsource(), to handle threading issues. | |
288 | See the original for full docstring details.""" |
|
292 | See the original for full docstring details.""" | |
289 |
|
293 | |||
290 | global KBINT |
|
294 | global KBINT | |
291 |
|
295 | |||
292 | # If Ctrl-C was typed, we reset the flag and return right away |
|
296 | # If Ctrl-C was typed, we reset the flag and return right away | |
293 | if KBINT: |
|
297 | if KBINT: | |
294 | KBINT = False |
|
298 | KBINT = False | |
295 | return False |
|
299 | return False | |
296 |
|
300 | |||
297 | try: |
|
301 | try: | |
298 | code = self.compile(source, filename, symbol) |
|
302 | code = self.compile(source, filename, symbol) | |
299 | except (OverflowError, SyntaxError, ValueError): |
|
303 | except (OverflowError, SyntaxError, ValueError): | |
300 | # Case 1 |
|
304 | # Case 1 | |
301 | self.showsyntaxerror(filename) |
|
305 | self.showsyntaxerror(filename) | |
302 | return False |
|
306 | return False | |
303 |
|
307 | |||
304 | if code is None: |
|
308 | if code is None: | |
305 | # Case 2 |
|
309 | # Case 2 | |
306 | return True |
|
310 | return True | |
307 |
|
311 | |||
308 | # Case 3 |
|
312 | # Case 3 | |
309 | # Store code in self, so the execution thread can handle it |
|
313 | # Store code in self, so the execution thread can handle it | |
310 | self.thread_ready.acquire() |
|
314 | self.thread_ready.acquire() | |
311 | self.code_to_run = code |
|
315 | self.code_to_run = code | |
312 | self.thread_ready.wait() # Wait until processed in timeout interval |
|
316 | self.thread_ready.wait() # Wait until processed in timeout interval | |
313 | self.thread_ready.release() |
|
317 | self.thread_ready.release() | |
314 |
|
318 | |||
315 | return False |
|
319 | return False | |
316 |
|
320 | |||
317 | def runcode(self): |
|
321 | def runcode(self): | |
318 | """Execute a code object. |
|
322 | """Execute a code object. | |
319 |
|
323 | |||
320 | Multithreaded wrapper around IPython's runcode().""" |
|
324 | Multithreaded wrapper around IPython's runcode().""" | |
321 |
|
325 | |||
322 | # lock thread-protected stuff |
|
326 | # lock thread-protected stuff | |
323 | self.thread_ready.acquire() |
|
327 | self.thread_ready.acquire() | |
324 |
|
328 | |||
325 | # Install sigint handler |
|
329 | # Install sigint handler | |
326 | try: |
|
330 | try: | |
327 | signal.signal(signal.SIGINT, sigint_handler) |
|
331 | signal.signal(signal.SIGINT, sigint_handler) | |
328 | except SystemError: |
|
332 | except SystemError: | |
329 | # This happens under Windows, which seems to have all sorts |
|
333 | # This happens under Windows, which seems to have all sorts | |
330 | # of problems with signal handling. Oh well... |
|
334 | # of problems with signal handling. Oh well... | |
331 | pass |
|
335 | pass | |
332 |
|
336 | |||
333 | if self._kill: |
|
337 | if self._kill: | |
334 | print >>Term.cout, 'Closing threads...', |
|
338 | print >>Term.cout, 'Closing threads...', | |
335 | Term.cout.flush() |
|
339 | Term.cout.flush() | |
336 | for tokill in self.on_kill: |
|
340 | for tokill in self.on_kill: | |
337 | tokill() |
|
341 | tokill() | |
338 | print >>Term.cout, 'Done.' |
|
342 | print >>Term.cout, 'Done.' | |
339 |
|
343 | |||
340 | # Run pending code by calling parent class |
|
344 | # Run pending code by calling parent class | |
341 | if self.code_to_run is not None: |
|
345 | if self.code_to_run is not None: | |
342 | self.thread_ready.notify() |
|
346 | self.thread_ready.notify() | |
343 | InteractiveShell.runcode(self,self.code_to_run) |
|
347 | InteractiveShell.runcode(self,self.code_to_run) | |
344 |
|
348 | |||
345 | # We're done with thread-protected variables |
|
349 | # We're done with thread-protected variables | |
346 | self.thread_ready.release() |
|
350 | self.thread_ready.release() | |
347 | # This MUST return true for gtk threading to work |
|
351 | # This MUST return true for gtk threading to work | |
348 | return True |
|
352 | return True | |
349 |
|
353 | |||
350 | def kill (self): |
|
354 | def kill (self): | |
351 | """Kill the thread, returning when it has been shut down.""" |
|
355 | """Kill the thread, returning when it has been shut down.""" | |
352 | self.thread_ready.acquire() |
|
356 | self.thread_ready.acquire() | |
353 | self._kill = True |
|
357 | self._kill = True | |
354 | self.thread_ready.release() |
|
358 | self.thread_ready.release() | |
355 |
|
359 | |||
356 | class MatplotlibShellBase: |
|
360 | class MatplotlibShellBase: | |
357 | """Mixin class to provide the necessary modifications to regular IPython |
|
361 | """Mixin class to provide the necessary modifications to regular IPython | |
358 | shell classes for matplotlib support. |
|
362 | shell classes for matplotlib support. | |
359 |
|
363 | |||
360 | Given Python's MRO, this should be used as the FIRST class in the |
|
364 | Given Python's MRO, this should be used as the FIRST class in the | |
361 | inheritance hierarchy, so that it overrides the relevant methods.""" |
|
365 | inheritance hierarchy, so that it overrides the relevant methods.""" | |
362 |
|
366 | |||
363 | def _matplotlib_config(self,name): |
|
367 | def _matplotlib_config(self,name): | |
364 | """Return various items needed to setup the user's shell with matplotlib""" |
|
368 | """Return various items needed to setup the user's shell with matplotlib""" | |
365 |
|
369 | |||
366 | # Initialize matplotlib to interactive mode always |
|
370 | # Initialize matplotlib to interactive mode always | |
367 | import matplotlib |
|
371 | import matplotlib | |
368 | from matplotlib import backends |
|
372 | from matplotlib import backends | |
369 | matplotlib.interactive(True) |
|
373 | matplotlib.interactive(True) | |
370 |
|
374 | |||
371 | def use(arg): |
|
375 | def use(arg): | |
372 | """IPython wrapper for matplotlib's backend switcher. |
|
376 | """IPython wrapper for matplotlib's backend switcher. | |
373 |
|
377 | |||
374 | In interactive use, we can not allow switching to a different |
|
378 | In interactive use, we can not allow switching to a different | |
375 | interactive backend, since thread conflicts will most likely crash |
|
379 | interactive backend, since thread conflicts will most likely crash | |
376 | the python interpreter. This routine does a safety check first, |
|
380 | the python interpreter. This routine does a safety check first, | |
377 | and refuses to perform a dangerous switch. It still allows |
|
381 | and refuses to perform a dangerous switch. It still allows | |
378 | switching to non-interactive backends.""" |
|
382 | switching to non-interactive backends.""" | |
379 |
|
383 | |||
380 | if arg in backends.interactive_bk and arg != self.mpl_backend: |
|
384 | if arg in backends.interactive_bk and arg != self.mpl_backend: | |
381 | m=('invalid matplotlib backend switch.\n' |
|
385 | m=('invalid matplotlib backend switch.\n' | |
382 | 'This script attempted to switch to the interactive ' |
|
386 | 'This script attempted to switch to the interactive ' | |
383 | 'backend: `%s`\n' |
|
387 | 'backend: `%s`\n' | |
384 | 'Your current choice of interactive backend is: `%s`\n\n' |
|
388 | 'Your current choice of interactive backend is: `%s`\n\n' | |
385 | 'Switching interactive matplotlib backends at runtime\n' |
|
389 | 'Switching interactive matplotlib backends at runtime\n' | |
386 | 'would crash the python interpreter, ' |
|
390 | 'would crash the python interpreter, ' | |
387 | 'and IPython has blocked it.\n\n' |
|
391 | 'and IPython has blocked it.\n\n' | |
388 | 'You need to either change your choice of matplotlib backend\n' |
|
392 | 'You need to either change your choice of matplotlib backend\n' | |
389 | 'by editing your .matplotlibrc file, or run this script as a \n' |
|
393 | 'by editing your .matplotlibrc file, or run this script as a \n' | |
390 | 'standalone file from the command line, not using IPython.\n' % |
|
394 | 'standalone file from the command line, not using IPython.\n' % | |
391 | (arg,self.mpl_backend) ) |
|
395 | (arg,self.mpl_backend) ) | |
392 | raise RuntimeError, m |
|
396 | raise RuntimeError, m | |
393 | else: |
|
397 | else: | |
394 | self.mpl_use(arg) |
|
398 | self.mpl_use(arg) | |
395 | self.mpl_use._called = True |
|
399 | self.mpl_use._called = True | |
396 |
|
400 | |||
397 | self.matplotlib = matplotlib |
|
401 | self.matplotlib = matplotlib | |
398 | self.mpl_backend = matplotlib.rcParams['backend'] |
|
402 | self.mpl_backend = matplotlib.rcParams['backend'] | |
399 |
|
403 | |||
400 | # we also need to block switching of interactive backends by use() |
|
404 | # we also need to block switching of interactive backends by use() | |
401 | self.mpl_use = matplotlib.use |
|
405 | self.mpl_use = matplotlib.use | |
402 | self.mpl_use._called = False |
|
406 | self.mpl_use._called = False | |
403 | # overwrite the original matplotlib.use with our wrapper |
|
407 | # overwrite the original matplotlib.use with our wrapper | |
404 | matplotlib.use = use |
|
408 | matplotlib.use = use | |
405 |
|
409 | |||
406 |
|
410 | |||
407 | # This must be imported last in the matplotlib series, after |
|
411 | # This must be imported last in the matplotlib series, after | |
408 | # backend/interactivity choices have been made |
|
412 | # backend/interactivity choices have been made | |
409 | try: |
|
413 | try: | |
410 | import matplotlib.pylab as pylab |
|
414 | import matplotlib.pylab as pylab | |
411 | self.pylab = pylab |
|
415 | self.pylab = pylab | |
412 | self.pylab_name = 'pylab' |
|
416 | self.pylab_name = 'pylab' | |
413 | except ImportError: |
|
417 | except ImportError: | |
414 | import matplotlib.matlab as matlab |
|
418 | import matplotlib.matlab as matlab | |
415 | self.pylab = matlab |
|
419 | self.pylab = matlab | |
416 | self.pylab_name = 'matlab' |
|
420 | self.pylab_name = 'matlab' | |
417 |
|
421 | |||
418 | self.pylab.show._needmain = False |
|
422 | self.pylab.show._needmain = False | |
419 | # We need to detect at runtime whether show() is called by the user. |
|
423 | # We need to detect at runtime whether show() is called by the user. | |
420 | # For this, we wrap it into a decorator which adds a 'called' flag. |
|
424 | # For this, we wrap it into a decorator which adds a 'called' flag. | |
421 | self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive) |
|
425 | self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive) | |
422 |
|
426 | |||
423 | # Build a user namespace initialized with matplotlib/matlab features. |
|
427 | # Build a user namespace initialized with matplotlib/matlab features. | |
424 | user_ns = {'__name__':'__main__', |
|
428 | user_ns = {'__name__':'__main__', | |
425 | '__builtins__' : __builtin__ } |
|
429 | '__builtins__' : __builtin__ } | |
426 |
|
430 | |||
427 | # Be careful not to remove the final \n in the code string below, or |
|
431 | # Be careful not to remove the final \n in the code string below, or | |
428 | # things will break badly with py22 (I think it's a python bug, 2.3 is |
|
432 | # things will break badly with py22 (I think it's a python bug, 2.3 is | |
429 | # OK). |
|
433 | # OK). | |
430 | pname = self.pylab_name # Python can't interpolate dotted var names |
|
434 | pname = self.pylab_name # Python can't interpolate dotted var names | |
431 | exec ("import matplotlib\n" |
|
435 | exec ("import matplotlib\n" | |
432 | "import matplotlib.%(pname)s as %(pname)s\n" |
|
436 | "import matplotlib.%(pname)s as %(pname)s\n" | |
433 | "from matplotlib.%(pname)s import *\n" % locals()) in user_ns |
|
437 | "from matplotlib.%(pname)s import *\n" % locals()) in user_ns | |
434 |
|
438 | |||
435 | # Build matplotlib info banner |
|
439 | # Build matplotlib info banner | |
436 | b=""" |
|
440 | b=""" | |
437 | Welcome to pylab, a matplotlib-based Python environment. |
|
441 | Welcome to pylab, a matplotlib-based Python environment. | |
438 | For more information, type 'help(pylab)'. |
|
442 | For more information, type 'help(pylab)'. | |
439 | """ |
|
443 | """ | |
440 | return user_ns,b |
|
444 | return user_ns,b | |
441 |
|
445 | |||
442 | def mplot_exec(self,fname,*where,**kw): |
|
446 | def mplot_exec(self,fname,*where,**kw): | |
443 | """Execute a matplotlib script. |
|
447 | """Execute a matplotlib script. | |
444 |
|
448 | |||
445 | This is a call to execfile(), but wrapped in safeties to properly |
|
449 | This is a call to execfile(), but wrapped in safeties to properly | |
446 | handle interactive rendering and backend switching.""" |
|
450 | handle interactive rendering and backend switching.""" | |
447 |
|
451 | |||
448 | #print '*** Matplotlib runner ***' # dbg |
|
452 | #print '*** Matplotlib runner ***' # dbg | |
449 | # turn off rendering until end of script |
|
453 | # turn off rendering until end of script | |
450 | isInteractive = self.matplotlib.rcParams['interactive'] |
|
454 | isInteractive = self.matplotlib.rcParams['interactive'] | |
451 | self.matplotlib.interactive(False) |
|
455 | self.matplotlib.interactive(False) | |
452 | self.safe_execfile(fname,*where,**kw) |
|
456 | self.safe_execfile(fname,*where,**kw) | |
453 | self.matplotlib.interactive(isInteractive) |
|
457 | self.matplotlib.interactive(isInteractive) | |
454 | # make rendering call now, if the user tried to do it |
|
458 | # make rendering call now, if the user tried to do it | |
455 | if self.pylab.draw_if_interactive.called: |
|
459 | if self.pylab.draw_if_interactive.called: | |
456 | self.pylab.draw() |
|
460 | self.pylab.draw() | |
457 | self.pylab.draw_if_interactive.called = False |
|
461 | self.pylab.draw_if_interactive.called = False | |
458 |
|
462 | |||
459 | # if a backend switch was performed, reverse it now |
|
463 | # if a backend switch was performed, reverse it now | |
460 | if self.mpl_use._called: |
|
464 | if self.mpl_use._called: | |
461 | self.matplotlib.rcParams['backend'] = self.mpl_backend |
|
465 | self.matplotlib.rcParams['backend'] = self.mpl_backend | |
462 |
|
466 | |||
463 | def magic_run(self,parameter_s=''): |
|
467 | def magic_run(self,parameter_s=''): | |
464 | Magic.magic_run(self,parameter_s,runner=self.mplot_exec) |
|
468 | Magic.magic_run(self,parameter_s,runner=self.mplot_exec) | |
465 |
|
469 | |||
466 | # Fix the docstring so users see the original as well |
|
470 | # Fix the docstring so users see the original as well | |
467 | magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__, |
|
471 | magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__, | |
468 | "\n *** Modified %run for Matplotlib," |
|
472 | "\n *** Modified %run for Matplotlib," | |
469 | " with proper interactive handling ***") |
|
473 | " with proper interactive handling ***") | |
470 |
|
474 | |||
471 | # Now we provide 2 versions of a matplotlib-aware IPython base shells, single |
|
475 | # Now we provide 2 versions of a matplotlib-aware IPython base shells, single | |
472 | # and multithreaded. Note that these are meant for internal use, the IPShell* |
|
476 | # and multithreaded. Note that these are meant for internal use, the IPShell* | |
473 | # classes below are the ones meant for public consumption. |
|
477 | # classes below are the ones meant for public consumption. | |
474 |
|
478 | |||
475 | class MatplotlibShell(MatplotlibShellBase,InteractiveShell): |
|
479 | class MatplotlibShell(MatplotlibShellBase,InteractiveShell): | |
476 | """Single-threaded shell with matplotlib support.""" |
|
480 | """Single-threaded shell with matplotlib support.""" | |
477 |
|
481 | |||
478 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
482 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
479 | user_ns=None,user_global_ns=None,**kw): |
|
483 | user_ns=None,user_global_ns=None,**kw): | |
480 | user_ns,b2 = self._matplotlib_config(name) |
|
484 | user_ns,b2 = self._matplotlib_config(name) | |
481 | InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns, |
|
485 | InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns, | |
482 | banner2=b2,**kw) |
|
486 | banner2=b2,**kw) | |
483 |
|
487 | |||
484 | class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell): |
|
488 | class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell): | |
485 | """Multi-threaded shell with matplotlib support.""" |
|
489 | """Multi-threaded shell with matplotlib support.""" | |
486 |
|
490 | |||
487 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
491 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
488 | user_ns=None,user_global_ns=None, **kw): |
|
492 | user_ns=None,user_global_ns=None, **kw): | |
489 | user_ns,b2 = self._matplotlib_config(name) |
|
493 | user_ns,b2 = self._matplotlib_config(name) | |
490 | MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns, |
|
494 | MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns, | |
491 | banner2=b2,**kw) |
|
495 | banner2=b2,**kw) | |
492 |
|
496 | |||
493 | #----------------------------------------------------------------------------- |
|
497 | #----------------------------------------------------------------------------- | |
494 | # Utility functions for the different GUI enabled IPShell* classes. |
|
498 | # Utility functions for the different GUI enabled IPShell* classes. | |
495 |
|
499 | |||
496 | def get_tk(): |
|
500 | def get_tk(): | |
497 | """Tries to import Tkinter and returns a withdrawn Tkinter root |
|
501 | """Tries to import Tkinter and returns a withdrawn Tkinter root | |
498 | window. If Tkinter is already imported or not available, this |
|
502 | window. If Tkinter is already imported or not available, this | |
499 | returns None. This function calls `hijack_tk` underneath. |
|
503 | returns None. This function calls `hijack_tk` underneath. | |
500 | """ |
|
504 | """ | |
501 | if not USE_TK or sys.modules.has_key('Tkinter'): |
|
505 | if not USE_TK or sys.modules.has_key('Tkinter'): | |
502 | return None |
|
506 | return None | |
503 | else: |
|
507 | else: | |
504 | try: |
|
508 | try: | |
505 | import Tkinter |
|
509 | import Tkinter | |
506 | except ImportError: |
|
510 | except ImportError: | |
507 | return None |
|
511 | return None | |
508 | else: |
|
512 | else: | |
509 | hijack_tk() |
|
513 | hijack_tk() | |
510 | r = Tkinter.Tk() |
|
514 | r = Tkinter.Tk() | |
511 | r.withdraw() |
|
515 | r.withdraw() | |
512 | return r |
|
516 | return r | |
513 |
|
517 | |||
514 | def hijack_tk(): |
|
518 | def hijack_tk(): | |
515 | """Modifies Tkinter's mainloop with a dummy so when a module calls |
|
519 | """Modifies Tkinter's mainloop with a dummy so when a module calls | |
516 | mainloop, it does not block. |
|
520 | mainloop, it does not block. | |
517 |
|
521 | |||
518 | """ |
|
522 | """ | |
519 | def misc_mainloop(self, n=0): |
|
523 | def misc_mainloop(self, n=0): | |
520 | pass |
|
524 | pass | |
521 | def tkinter_mainloop(n=0): |
|
525 | def tkinter_mainloop(n=0): | |
522 | pass |
|
526 | pass | |
523 |
|
527 | |||
524 | import Tkinter |
|
528 | import Tkinter | |
525 | Tkinter.Misc.mainloop = misc_mainloop |
|
529 | Tkinter.Misc.mainloop = misc_mainloop | |
526 | Tkinter.mainloop = tkinter_mainloop |
|
530 | Tkinter.mainloop = tkinter_mainloop | |
527 |
|
531 | |||
528 | def update_tk(tk): |
|
532 | def update_tk(tk): | |
529 | """Updates the Tkinter event loop. This is typically called from |
|
533 | """Updates the Tkinter event loop. This is typically called from | |
530 | the respective WX or GTK mainloops. |
|
534 | the respective WX or GTK mainloops. | |
531 | """ |
|
535 | """ | |
532 | if tk: |
|
536 | if tk: | |
533 | tk.update() |
|
537 | tk.update() | |
534 |
|
538 | |||
535 | def hijack_wx(): |
|
539 | def hijack_wx(): | |
536 | """Modifies wxPython's MainLoop with a dummy so user code does not |
|
540 | """Modifies wxPython's MainLoop with a dummy so user code does not | |
537 | block IPython. The hijacked mainloop function is returned. |
|
541 | block IPython. The hijacked mainloop function is returned. | |
538 | """ |
|
542 | """ | |
539 | def dummy_mainloop(*args, **kw): |
|
543 | def dummy_mainloop(*args, **kw): | |
540 | pass |
|
544 | pass | |
541 | import wxPython |
|
545 | import wxPython | |
542 | ver = wxPython.__version__ |
|
546 | ver = wxPython.__version__ | |
543 | orig_mainloop = None |
|
547 | orig_mainloop = None | |
544 | if ver[:3] >= '2.5': |
|
548 | if ver[:3] >= '2.5': | |
545 | import wx |
|
549 | import wx | |
546 | if hasattr(wx, '_core_'): core = getattr(wx, '_core_') |
|
550 | if hasattr(wx, '_core_'): core = getattr(wx, '_core_') | |
547 | elif hasattr(wx, '_core'): core = getattr(wx, '_core') |
|
551 | elif hasattr(wx, '_core'): core = getattr(wx, '_core') | |
548 | else: raise AttributeError('Could not find wx core module') |
|
552 | else: raise AttributeError('Could not find wx core module') | |
549 | orig_mainloop = core.PyApp_MainLoop |
|
553 | orig_mainloop = core.PyApp_MainLoop | |
550 | core.PyApp_MainLoop = dummy_mainloop |
|
554 | core.PyApp_MainLoop = dummy_mainloop | |
551 | elif ver[:3] == '2.4': |
|
555 | elif ver[:3] == '2.4': | |
552 | orig_mainloop = wxPython.wxc.wxPyApp_MainLoop |
|
556 | orig_mainloop = wxPython.wxc.wxPyApp_MainLoop | |
553 | wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop |
|
557 | wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop | |
554 | else: |
|
558 | else: | |
555 | warn("Unable to find either wxPython version 2.4 or >= 2.5.") |
|
559 | warn("Unable to find either wxPython version 2.4 or >= 2.5.") | |
556 | return orig_mainloop |
|
560 | return orig_mainloop | |
557 |
|
561 | |||
558 | def hijack_gtk(): |
|
562 | def hijack_gtk(): | |
559 | """Modifies pyGTK's mainloop with a dummy so user code does not |
|
563 | """Modifies pyGTK's mainloop with a dummy so user code does not | |
560 | block IPython. This function returns the original `gtk.mainloop` |
|
564 | block IPython. This function returns the original `gtk.mainloop` | |
561 | function that has been hijacked. |
|
565 | function that has been hijacked. | |
562 | """ |
|
566 | """ | |
563 | def dummy_mainloop(*args, **kw): |
|
567 | def dummy_mainloop(*args, **kw): | |
564 | pass |
|
568 | pass | |
565 | import gtk |
|
569 | import gtk | |
566 | if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main |
|
570 | if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main | |
567 | else: orig_mainloop = gtk.mainloop |
|
571 | else: orig_mainloop = gtk.mainloop | |
568 | gtk.mainloop = dummy_mainloop |
|
572 | gtk.mainloop = dummy_mainloop | |
569 | gtk.main = dummy_mainloop |
|
573 | gtk.main = dummy_mainloop | |
570 | return orig_mainloop |
|
574 | return orig_mainloop | |
571 |
|
575 | |||
572 | #----------------------------------------------------------------------------- |
|
576 | #----------------------------------------------------------------------------- | |
573 | # The IPShell* classes below are the ones meant to be run by external code as |
|
577 | # The IPShell* classes below are the ones meant to be run by external code as | |
574 | # IPython instances. Note that unless a specific threading strategy is |
|
578 | # IPython instances. Note that unless a specific threading strategy is | |
575 | # desired, the factory function start() below should be used instead (it |
|
579 | # desired, the factory function start() below should be used instead (it | |
576 | # selects the proper threaded class). |
|
580 | # selects the proper threaded class). | |
577 |
|
581 | |||
578 | class IPShellGTK(threading.Thread): |
|
582 | class IPShellGTK(threading.Thread): | |
579 | """Run a gtk mainloop() in a separate thread. |
|
583 | """Run a gtk mainloop() in a separate thread. | |
580 |
|
584 | |||
581 | Python commands can be passed to the thread where they will be executed. |
|
585 | Python commands can be passed to the thread where they will be executed. | |
582 | This is implemented by periodically checking for passed code using a |
|
586 | This is implemented by periodically checking for passed code using a | |
583 | GTK timeout callback.""" |
|
587 | GTK timeout callback.""" | |
584 |
|
588 | |||
585 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
589 | TIMEOUT = 100 # Millisecond interval between timeouts. | |
586 |
|
590 | |||
587 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
591 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, | |
588 | debug=1,shell_class=MTInteractiveShell): |
|
592 | debug=1,shell_class=MTInteractiveShell): | |
589 |
|
593 | |||
590 | import gtk |
|
594 | import gtk | |
591 |
|
595 | |||
592 | self.gtk = gtk |
|
596 | self.gtk = gtk | |
593 | self.gtk_mainloop = hijack_gtk() |
|
597 | self.gtk_mainloop = hijack_gtk() | |
594 |
|
598 | |||
595 | # Allows us to use both Tk and GTK. |
|
599 | # Allows us to use both Tk and GTK. | |
596 | self.tk = get_tk() |
|
600 | self.tk = get_tk() | |
597 |
|
601 | |||
598 | if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit |
|
602 | if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit | |
599 | else: mainquit = self.gtk.mainquit |
|
603 | else: mainquit = self.gtk.mainquit | |
600 |
|
604 | |||
601 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
605 | self.IP = make_IPython(argv,user_ns=user_ns, | |
602 | user_global_ns=user_global_ns, |
|
606 | user_global_ns=user_global_ns, | |
603 | debug=debug, |
|
607 | debug=debug, | |
604 | shell_class=shell_class, |
|
608 | shell_class=shell_class, | |
605 | on_kill=[mainquit]) |
|
609 | on_kill=[mainquit]) | |
606 |
|
610 | |||
607 | # HACK: slot for banner in self; it will be passed to the mainloop |
|
611 | # HACK: slot for banner in self; it will be passed to the mainloop | |
608 | # method only and .run() needs it. The actual value will be set by |
|
612 | # method only and .run() needs it. The actual value will be set by | |
609 | # .mainloop(). |
|
613 | # .mainloop(). | |
610 | self._banner = None |
|
614 | self._banner = None | |
611 |
|
615 | |||
612 | threading.Thread.__init__(self) |
|
616 | threading.Thread.__init__(self) | |
613 |
|
617 | |||
614 | def run(self): |
|
618 | def run(self): | |
615 | self.IP.mainloop(self._banner) |
|
619 | self.IP.mainloop(self._banner) | |
616 | self.IP.kill() |
|
620 | self.IP.kill() | |
617 |
|
621 | |||
618 | def mainloop(self,sys_exit=0,banner=None): |
|
622 | def mainloop(self,sys_exit=0,banner=None): | |
619 |
|
623 | |||
620 | self._banner = banner |
|
624 | self._banner = banner | |
621 |
|
625 | |||
622 | if self.gtk.pygtk_version >= (2,4,0): |
|
626 | if self.gtk.pygtk_version >= (2,4,0): | |
623 | import gobject |
|
627 | import gobject | |
624 | gobject.idle_add(self.on_timer) |
|
628 | gobject.idle_add(self.on_timer) | |
625 | else: |
|
629 | else: | |
626 | self.gtk.idle_add(self.on_timer) |
|
630 | self.gtk.idle_add(self.on_timer) | |
627 |
|
631 | |||
628 | if sys.platform != 'win32': |
|
632 | if sys.platform != 'win32': | |
629 | try: |
|
633 | try: | |
630 | if self.gtk.gtk_version[0] >= 2: |
|
634 | if self.gtk.gtk_version[0] >= 2: | |
631 | self.gtk.threads_init() |
|
635 | self.gtk.threads_init() | |
632 | except AttributeError: |
|
636 | except AttributeError: | |
633 | pass |
|
637 | pass | |
634 | except RuntimeError: |
|
638 | except RuntimeError: | |
635 | error('Your pyGTK likely has not been compiled with ' |
|
639 | error('Your pyGTK likely has not been compiled with ' | |
636 | 'threading support.\n' |
|
640 | 'threading support.\n' | |
637 | 'The exception printout is below.\n' |
|
641 | 'The exception printout is below.\n' | |
638 | 'You can either rebuild pyGTK with threads, or ' |
|
642 | 'You can either rebuild pyGTK with threads, or ' | |
639 | 'try using \n' |
|
643 | 'try using \n' | |
640 | 'matplotlib with a different backend (like Tk or WX).\n' |
|
644 | 'matplotlib with a different backend (like Tk or WX).\n' | |
641 | 'Note that matplotlib will most likely not work in its ' |
|
645 | 'Note that matplotlib will most likely not work in its ' | |
642 | 'current state!') |
|
646 | 'current state!') | |
643 | self.IP.InteractiveTB() |
|
647 | self.IP.InteractiveTB() | |
644 | self.start() |
|
648 | self.start() | |
645 | self.gtk.threads_enter() |
|
649 | self.gtk.threads_enter() | |
646 | self.gtk_mainloop() |
|
650 | self.gtk_mainloop() | |
647 | self.gtk.threads_leave() |
|
651 | self.gtk.threads_leave() | |
648 | self.join() |
|
652 | self.join() | |
649 |
|
653 | |||
650 | def on_timer(self): |
|
654 | def on_timer(self): | |
651 | update_tk(self.tk) |
|
655 | update_tk(self.tk) | |
652 | return self.IP.runcode() |
|
656 | return self.IP.runcode() | |
653 |
|
657 | |||
654 |
|
658 | |||
655 | class IPShellWX(threading.Thread): |
|
659 | class IPShellWX(threading.Thread): | |
656 | """Run a wx mainloop() in a separate thread. |
|
660 | """Run a wx mainloop() in a separate thread. | |
657 |
|
661 | |||
658 | Python commands can be passed to the thread where they will be executed. |
|
662 | Python commands can be passed to the thread where they will be executed. | |
659 | This is implemented by periodically checking for passed code using a |
|
663 | This is implemented by periodically checking for passed code using a | |
660 | GTK timeout callback.""" |
|
664 | GTK timeout callback.""" | |
661 |
|
665 | |||
662 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
666 | TIMEOUT = 100 # Millisecond interval between timeouts. | |
663 |
|
667 | |||
664 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
668 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, | |
665 | debug=1,shell_class=MTInteractiveShell): |
|
669 | debug=1,shell_class=MTInteractiveShell): | |
666 |
|
670 | |||
667 | import wxPython.wx as wx |
|
671 | import wxPython.wx as wx | |
668 |
|
672 | |||
669 | threading.Thread.__init__(self) |
|
673 | threading.Thread.__init__(self) | |
670 | self.wx = wx |
|
674 | self.wx = wx | |
671 | self.wx_mainloop = hijack_wx() |
|
675 | self.wx_mainloop = hijack_wx() | |
672 |
|
676 | |||
673 | # Allows us to use both Tk and GTK. |
|
677 | # Allows us to use both Tk and GTK. | |
674 | self.tk = get_tk() |
|
678 | self.tk = get_tk() | |
675 |
|
679 | |||
676 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
680 | self.IP = make_IPython(argv,user_ns=user_ns, | |
677 | user_global_ns=user_global_ns, |
|
681 | user_global_ns=user_global_ns, | |
678 | debug=debug, |
|
682 | debug=debug, | |
679 | shell_class=shell_class, |
|
683 | shell_class=shell_class, | |
680 | on_kill=[self.wxexit]) |
|
684 | on_kill=[self.wxexit]) | |
681 | # HACK: slot for banner in self; it will be passed to the mainloop |
|
685 | # HACK: slot for banner in self; it will be passed to the mainloop | |
682 | # method only and .run() needs it. The actual value will be set by |
|
686 | # method only and .run() needs it. The actual value will be set by | |
683 | # .mainloop(). |
|
687 | # .mainloop(). | |
684 | self._banner = None |
|
688 | self._banner = None | |
685 |
|
689 | |||
686 | self.app = None |
|
690 | self.app = None | |
687 |
|
691 | |||
688 | def wxexit(self, *args): |
|
692 | def wxexit(self, *args): | |
689 | if self.app is not None: |
|
693 | if self.app is not None: | |
690 | self.app.agent.timer.Stop() |
|
694 | self.app.agent.timer.Stop() | |
691 | self.app.ExitMainLoop() |
|
695 | self.app.ExitMainLoop() | |
692 |
|
696 | |||
693 | def run(self): |
|
697 | def run(self): | |
694 | self.IP.mainloop(self._banner) |
|
698 | self.IP.mainloop(self._banner) | |
695 | self.IP.kill() |
|
699 | self.IP.kill() | |
696 |
|
700 | |||
697 | def mainloop(self,sys_exit=0,banner=None): |
|
701 | def mainloop(self,sys_exit=0,banner=None): | |
698 |
|
702 | |||
699 | self._banner = banner |
|
703 | self._banner = banner | |
700 |
|
704 | |||
701 | self.start() |
|
705 | self.start() | |
702 |
|
706 | |||
703 | class TimerAgent(self.wx.wxMiniFrame): |
|
707 | class TimerAgent(self.wx.wxMiniFrame): | |
704 | wx = self.wx |
|
708 | wx = self.wx | |
705 | IP = self.IP |
|
709 | IP = self.IP | |
706 | tk = self.tk |
|
710 | tk = self.tk | |
707 | def __init__(self, parent, interval): |
|
711 | def __init__(self, parent, interval): | |
708 | style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ |
|
712 | style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ | |
709 | self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200), |
|
713 | self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200), | |
710 | size=(100, 100),style=style) |
|
714 | size=(100, 100),style=style) | |
711 | self.Show(False) |
|
715 | self.Show(False) | |
712 | self.interval = interval |
|
716 | self.interval = interval | |
713 | self.timerId = self.wx.wxNewId() |
|
717 | self.timerId = self.wx.wxNewId() | |
714 |
|
718 | |||
715 | def StartWork(self): |
|
719 | def StartWork(self): | |
716 | self.timer = self.wx.wxTimer(self, self.timerId) |
|
720 | self.timer = self.wx.wxTimer(self, self.timerId) | |
717 | self.wx.EVT_TIMER(self, self.timerId, self.OnTimer) |
|
721 | self.wx.EVT_TIMER(self, self.timerId, self.OnTimer) | |
718 | self.timer.Start(self.interval) |
|
722 | self.timer.Start(self.interval) | |
719 |
|
723 | |||
720 | def OnTimer(self, event): |
|
724 | def OnTimer(self, event): | |
721 | update_tk(self.tk) |
|
725 | update_tk(self.tk) | |
722 | self.IP.runcode() |
|
726 | self.IP.runcode() | |
723 |
|
727 | |||
724 | class App(self.wx.wxApp): |
|
728 | class App(self.wx.wxApp): | |
725 | wx = self.wx |
|
729 | wx = self.wx | |
726 | TIMEOUT = self.TIMEOUT |
|
730 | TIMEOUT = self.TIMEOUT | |
727 | def OnInit(self): |
|
731 | def OnInit(self): | |
728 | 'Create the main window and insert the custom frame' |
|
732 | 'Create the main window and insert the custom frame' | |
729 | self.agent = TimerAgent(None, self.TIMEOUT) |
|
733 | self.agent = TimerAgent(None, self.TIMEOUT) | |
730 | self.agent.Show(self.wx.false) |
|
734 | self.agent.Show(self.wx.false) | |
731 | self.agent.StartWork() |
|
735 | self.agent.StartWork() | |
732 | return self.wx.true |
|
736 | return self.wx.true | |
733 |
|
737 | |||
734 | self.app = App(redirect=False) |
|
738 | self.app = App(redirect=False) | |
735 | self.wx_mainloop(self.app) |
|
739 | self.wx_mainloop(self.app) | |
736 | self.join() |
|
740 | self.join() | |
737 |
|
741 | |||
738 |
|
742 | |||
739 | class IPShellQt(threading.Thread): |
|
743 | class IPShellQt(threading.Thread): | |
740 | """Run a Qt event loop in a separate thread. |
|
744 | """Run a Qt event loop in a separate thread. | |
741 |
|
745 | |||
742 | Python commands can be passed to the thread where they will be executed. |
|
746 | Python commands can be passed to the thread where they will be executed. | |
743 | This is implemented by periodically checking for passed code using a |
|
747 | This is implemented by periodically checking for passed code using a | |
744 | Qt timer / slot.""" |
|
748 | Qt timer / slot.""" | |
745 |
|
749 | |||
746 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
750 | TIMEOUT = 100 # Millisecond interval between timeouts. | |
747 |
|
751 | |||
748 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
752 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, | |
749 | debug=0,shell_class=MTInteractiveShell): |
|
753 | debug=0,shell_class=MTInteractiveShell): | |
750 |
|
754 | |||
751 | import qt |
|
755 | import qt | |
752 |
|
756 | |||
753 | class newQApplication: |
|
757 | class newQApplication: | |
754 | def __init__( self ): |
|
758 | def __init__( self ): | |
755 | self.QApplication = qt.QApplication |
|
759 | self.QApplication = qt.QApplication | |
756 |
|
760 | |||
757 | def __call__( *args, **kwargs ): |
|
761 | def __call__( *args, **kwargs ): | |
758 | return qt.qApp |
|
762 | return qt.qApp | |
759 |
|
763 | |||
760 | def exec_loop( *args, **kwargs ): |
|
764 | def exec_loop( *args, **kwargs ): | |
761 | pass |
|
765 | pass | |
762 |
|
766 | |||
763 | def __getattr__( self, name ): |
|
767 | def __getattr__( self, name ): | |
764 | return getattr( self.QApplication, name ) |
|
768 | return getattr( self.QApplication, name ) | |
765 |
|
769 | |||
766 | qt.QApplication = newQApplication() |
|
770 | qt.QApplication = newQApplication() | |
767 |
|
771 | |||
768 | # Allows us to use both Tk and QT. |
|
772 | # Allows us to use both Tk and QT. | |
769 | self.tk = get_tk() |
|
773 | self.tk = get_tk() | |
770 |
|
774 | |||
771 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
775 | self.IP = make_IPython(argv,user_ns=user_ns, | |
772 | user_global_ns=user_global_ns, |
|
776 | user_global_ns=user_global_ns, | |
773 | debug=debug, |
|
777 | debug=debug, | |
774 | shell_class=shell_class, |
|
778 | shell_class=shell_class, | |
775 | on_kill=[qt.qApp.exit]) |
|
779 | on_kill=[qt.qApp.exit]) | |
776 |
|
780 | |||
777 | # HACK: slot for banner in self; it will be passed to the mainloop |
|
781 | # HACK: slot for banner in self; it will be passed to the mainloop | |
778 | # method only and .run() needs it. The actual value will be set by |
|
782 | # method only and .run() needs it. The actual value will be set by | |
779 | # .mainloop(). |
|
783 | # .mainloop(). | |
780 | self._banner = None |
|
784 | self._banner = None | |
781 |
|
785 | |||
782 | threading.Thread.__init__(self) |
|
786 | threading.Thread.__init__(self) | |
783 |
|
787 | |||
784 | def run(self): |
|
788 | def run(self): | |
785 | self.IP.mainloop(self._banner) |
|
789 | self.IP.mainloop(self._banner) | |
786 | self.IP.kill() |
|
790 | self.IP.kill() | |
787 |
|
791 | |||
788 | def mainloop(self,sys_exit=0,banner=None): |
|
792 | def mainloop(self,sys_exit=0,banner=None): | |
789 |
|
793 | |||
790 | import qt |
|
794 | import qt | |
791 |
|
795 | |||
792 | self._banner = banner |
|
796 | self._banner = banner | |
793 |
|
797 | |||
794 | if qt.QApplication.startingUp(): |
|
798 | if qt.QApplication.startingUp(): | |
795 | a = qt.QApplication.QApplication(sys.argv) |
|
799 | a = qt.QApplication.QApplication(sys.argv) | |
796 | self.timer = qt.QTimer() |
|
800 | self.timer = qt.QTimer() | |
797 | qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer ) |
|
801 | qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer ) | |
798 |
|
802 | |||
799 | self.start() |
|
803 | self.start() | |
800 | self.timer.start( self.TIMEOUT, True ) |
|
804 | self.timer.start( self.TIMEOUT, True ) | |
801 | while True: |
|
805 | while True: | |
802 | if self.IP._kill: break |
|
806 | if self.IP._kill: break | |
803 | qt.qApp.exec_loop() |
|
807 | qt.qApp.exec_loop() | |
804 | self.join() |
|
808 | self.join() | |
805 |
|
809 | |||
806 | def on_timer(self): |
|
810 | def on_timer(self): | |
807 | update_tk(self.tk) |
|
811 | update_tk(self.tk) | |
808 | result = self.IP.runcode() |
|
812 | result = self.IP.runcode() | |
809 | self.timer.start( self.TIMEOUT, True ) |
|
813 | self.timer.start( self.TIMEOUT, True ) | |
810 | return result |
|
814 | return result | |
811 |
|
815 | |||
812 | # A set of matplotlib public IPython shell classes, for single-threaded |
|
816 | # A set of matplotlib public IPython shell classes, for single-threaded | |
813 | # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. |
|
817 | # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. | |
814 | class IPShellMatplotlib(IPShell): |
|
818 | class IPShellMatplotlib(IPShell): | |
815 | """Subclass IPShell with MatplotlibShell as the internal shell. |
|
819 | """Subclass IPShell with MatplotlibShell as the internal shell. | |
816 |
|
820 | |||
817 | Single-threaded class, meant for the Tk* and FLTK* backends. |
|
821 | Single-threaded class, meant for the Tk* and FLTK* backends. | |
818 |
|
822 | |||
819 | Having this on a separate class simplifies the external driver code.""" |
|
823 | Having this on a separate class simplifies the external driver code.""" | |
820 |
|
824 | |||
821 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
825 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
822 | IPShell.__init__(self,argv,user_ns,user_global_ns,debug, |
|
826 | IPShell.__init__(self,argv,user_ns,user_global_ns,debug, | |
823 | shell_class=MatplotlibShell) |
|
827 | shell_class=MatplotlibShell) | |
824 |
|
828 | |||
825 | class IPShellMatplotlibGTK(IPShellGTK): |
|
829 | class IPShellMatplotlibGTK(IPShellGTK): | |
826 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. |
|
830 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. | |
827 |
|
831 | |||
828 | Multi-threaded class, meant for the GTK* backends.""" |
|
832 | Multi-threaded class, meant for the GTK* backends.""" | |
829 |
|
833 | |||
830 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
834 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
831 | IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug, |
|
835 | IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug, | |
832 | shell_class=MatplotlibMTShell) |
|
836 | shell_class=MatplotlibMTShell) | |
833 |
|
837 | |||
834 | class IPShellMatplotlibWX(IPShellWX): |
|
838 | class IPShellMatplotlibWX(IPShellWX): | |
835 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. |
|
839 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. | |
836 |
|
840 | |||
837 | Multi-threaded class, meant for the WX* backends.""" |
|
841 | Multi-threaded class, meant for the WX* backends.""" | |
838 |
|
842 | |||
839 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
843 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
840 | IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug, |
|
844 | IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug, | |
841 | shell_class=MatplotlibMTShell) |
|
845 | shell_class=MatplotlibMTShell) | |
842 |
|
846 | |||
843 | class IPShellMatplotlibQt(IPShellQt): |
|
847 | class IPShellMatplotlibQt(IPShellQt): | |
844 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. |
|
848 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. | |
845 |
|
849 | |||
846 | Multi-threaded class, meant for the Qt* backends.""" |
|
850 | Multi-threaded class, meant for the Qt* backends.""" | |
847 |
|
851 | |||
848 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
852 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): | |
849 | IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, |
|
853 | IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, | |
850 | shell_class=MatplotlibMTShell) |
|
854 | shell_class=MatplotlibMTShell) | |
851 |
|
855 | |||
852 | #----------------------------------------------------------------------------- |
|
856 | #----------------------------------------------------------------------------- | |
853 | # Factory functions to actually start the proper thread-aware shell |
|
857 | # Factory functions to actually start the proper thread-aware shell | |
854 |
|
858 | |||
855 | def _matplotlib_shell_class(): |
|
859 | def _matplotlib_shell_class(): | |
856 | """Factory function to handle shell class selection for matplotlib. |
|
860 | """Factory function to handle shell class selection for matplotlib. | |
857 |
|
861 | |||
858 | The proper shell class to use depends on the matplotlib backend, since |
|
862 | The proper shell class to use depends on the matplotlib backend, since | |
859 | each backend requires a different threading strategy.""" |
|
863 | each backend requires a different threading strategy.""" | |
860 |
|
864 | |||
861 | try: |
|
865 | try: | |
862 | import matplotlib |
|
866 | import matplotlib | |
863 | except ImportError: |
|
867 | except ImportError: | |
864 | error('matplotlib could NOT be imported! Starting normal IPython.') |
|
868 | error('matplotlib could NOT be imported! Starting normal IPython.') | |
865 | sh_class = IPShell |
|
869 | sh_class = IPShell | |
866 | else: |
|
870 | else: | |
867 | backend = matplotlib.rcParams['backend'] |
|
871 | backend = matplotlib.rcParams['backend'] | |
868 | if backend.startswith('GTK'): |
|
872 | if backend.startswith('GTK'): | |
869 | sh_class = IPShellMatplotlibGTK |
|
873 | sh_class = IPShellMatplotlibGTK | |
870 | elif backend.startswith('WX'): |
|
874 | elif backend.startswith('WX'): | |
871 | sh_class = IPShellMatplotlibWX |
|
875 | sh_class = IPShellMatplotlibWX | |
872 | elif backend.startswith('Qt'): |
|
876 | elif backend.startswith('Qt'): | |
873 | sh_class = IPShellMatplotlibQt |
|
877 | sh_class = IPShellMatplotlibQt | |
874 | else: |
|
878 | else: | |
875 | sh_class = IPShellMatplotlib |
|
879 | sh_class = IPShellMatplotlib | |
876 | #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg |
|
880 | #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg | |
877 | return sh_class |
|
881 | return sh_class | |
878 |
|
882 | |||
879 | # This is the one which should be called by external code. |
|
883 | # This is the one which should be called by external code. | |
880 | def start(): |
|
884 | def start(): | |
881 | """Return a running shell instance, dealing with threading options. |
|
885 | """Return a running shell instance, dealing with threading options. | |
882 |
|
886 | |||
883 | This is a factory function which will instantiate the proper IPython shell |
|
887 | This is a factory function which will instantiate the proper IPython shell | |
884 | based on the user's threading choice. Such a selector is needed because |
|
888 | based on the user's threading choice. Such a selector is needed because | |
885 | different GUI toolkits require different thread handling details.""" |
|
889 | different GUI toolkits require different thread handling details.""" | |
886 |
|
890 | |||
887 | global USE_TK |
|
891 | global USE_TK | |
888 | # Crude sys.argv hack to extract the threading options. |
|
892 | # Crude sys.argv hack to extract the threading options. | |
889 | argv = sys.argv |
|
893 | argv = sys.argv | |
890 | if len(argv) > 1: |
|
894 | if len(argv) > 1: | |
891 | if len(argv) > 2: |
|
895 | if len(argv) > 2: | |
892 | arg2 = argv[2] |
|
896 | arg2 = argv[2] | |
893 | if arg2.endswith('-tk'): |
|
897 | if arg2.endswith('-tk'): | |
894 | USE_TK = True |
|
898 | USE_TK = True | |
895 | arg1 = argv[1] |
|
899 | arg1 = argv[1] | |
896 | if arg1.endswith('-gthread'): |
|
900 | if arg1.endswith('-gthread'): | |
897 | shell = IPShellGTK |
|
901 | shell = IPShellGTK | |
898 | elif arg1.endswith( '-qthread' ): |
|
902 | elif arg1.endswith( '-qthread' ): | |
899 | shell = IPShellQt |
|
903 | shell = IPShellQt | |
900 | elif arg1.endswith('-wthread'): |
|
904 | elif arg1.endswith('-wthread'): | |
901 | shell = IPShellWX |
|
905 | shell = IPShellWX | |
902 | elif arg1.endswith('-pylab'): |
|
906 | elif arg1.endswith('-pylab'): | |
903 | shell = _matplotlib_shell_class() |
|
907 | shell = _matplotlib_shell_class() | |
904 | else: |
|
908 | else: | |
905 | shell = IPShell |
|
909 | shell = IPShell | |
906 | else: |
|
910 | else: | |
907 | shell = IPShell |
|
911 | shell = IPShell | |
908 | return shell() |
|
912 | return shell() | |
909 |
|
913 | |||
910 | # Some aliases for backwards compatibility |
|
914 | # Some aliases for backwards compatibility | |
911 | IPythonShell = IPShell |
|
915 | IPythonShell = IPShell | |
912 | IPythonShellEmbed = IPShellEmbed |
|
916 | IPythonShellEmbed = IPShellEmbed | |
913 | #************************ End of file <Shell.py> *************************** |
|
917 | #************************ End of file <Shell.py> *************************** |
@@ -1,1968 +1,1997 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | IPython -- An enhanced Interactive Python |
|
3 | IPython -- An enhanced Interactive Python | |
4 |
|
4 | |||
5 | Requires Python 2.1 or newer. |
|
5 | Requires Python 2.1 or newer. | |
6 |
|
6 | |||
7 | This file contains all the classes and helper functions specific to IPython. |
|
7 | This file contains all the classes and helper functions specific to IPython. | |
8 |
|
8 | |||
9 |
$Id: iplib.py 96 |
|
9 | $Id: iplib.py 965 2005-12-28 23:23:09Z fperez $ | |
10 | """ |
|
10 | """ | |
11 |
|
11 | |||
12 | #***************************************************************************** |
|
12 | #***************************************************************************** | |
13 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
13 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and | |
14 | # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu> |
|
14 | # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu> | |
15 | # |
|
15 | # | |
16 | # Distributed under the terms of the BSD License. The full license is in |
|
16 | # Distributed under the terms of the BSD License. The full license is in | |
17 | # the file COPYING, distributed as part of this software. |
|
17 | # the file COPYING, distributed as part of this software. | |
18 | # |
|
18 | # | |
19 | # Note: this code originally subclassed code.InteractiveConsole from the |
|
19 | # Note: this code originally subclassed code.InteractiveConsole from the | |
20 | # Python standard library. Over time, all of that class has been copied |
|
20 | # Python standard library. Over time, all of that class has been copied | |
21 | # verbatim here for modifications which could not be accomplished by |
|
21 | # verbatim here for modifications which could not be accomplished by | |
22 | # subclassing. At this point, there are no dependencies at all on the code |
|
22 | # subclassing. At this point, there are no dependencies at all on the code | |
23 | # module anymore (it is not even imported). The Python License (sec. 2) |
|
23 | # module anymore (it is not even imported). The Python License (sec. 2) | |
24 | # allows for this, but it's always nice to acknowledge credit where credit is |
|
24 | # allows for this, but it's always nice to acknowledge credit where credit is | |
25 | # due. |
|
25 | # due. | |
26 | #***************************************************************************** |
|
26 | #***************************************************************************** | |
27 |
|
27 | |||
28 | #**************************************************************************** |
|
28 | #**************************************************************************** | |
29 | # Modules and globals |
|
29 | # Modules and globals | |
30 |
|
30 | |||
31 | from __future__ import generators # for 2.2 backwards-compatibility |
|
31 | from __future__ import generators # for 2.2 backwards-compatibility | |
32 |
|
32 | |||
33 | from IPython import Release |
|
33 | from IPython import Release | |
34 | __author__ = '%s <%s>\n%s <%s>' % \ |
|
34 | __author__ = '%s <%s>\n%s <%s>' % \ | |
35 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) |
|
35 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) | |
36 | __license__ = Release.license |
|
36 | __license__ = Release.license | |
37 | __version__ = Release.version |
|
37 | __version__ = Release.version | |
38 |
|
38 | |||
39 | # Python standard modules |
|
39 | # Python standard modules | |
40 | import __main__ |
|
40 | import __main__ | |
41 | import __builtin__ |
|
41 | import __builtin__ | |
42 | import StringIO |
|
42 | import StringIO | |
43 | import bdb |
|
43 | import bdb | |
44 | import cPickle as pickle |
|
44 | import cPickle as pickle | |
45 | import codeop |
|
45 | import codeop | |
46 | import exceptions |
|
46 | import exceptions | |
47 | import glob |
|
47 | import glob | |
48 | import inspect |
|
48 | import inspect | |
49 | import keyword |
|
49 | import keyword | |
50 | import new |
|
50 | import new | |
51 | import os |
|
51 | import os | |
52 | import pdb |
|
52 | import pdb | |
53 | import pydoc |
|
53 | import pydoc | |
54 | import re |
|
54 | import re | |
55 | import shutil |
|
55 | import shutil | |
56 | import string |
|
56 | import string | |
57 | import sys |
|
57 | import sys | |
58 | import traceback |
|
58 | import traceback | |
59 | import types |
|
59 | import types | |
60 |
|
60 | |||
61 | from pprint import pprint, pformat |
|
61 | from pprint import pprint, pformat | |
62 |
|
62 | |||
63 | # IPython's own modules |
|
63 | # IPython's own modules | |
64 | import IPython |
|
64 | import IPython | |
65 | from IPython import OInspect,PyColorize,ultraTB |
|
65 | from IPython import OInspect,PyColorize,ultraTB | |
66 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names |
|
66 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names | |
67 | from IPython.FakeModule import FakeModule |
|
67 | from IPython.FakeModule import FakeModule | |
68 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns |
|
68 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns | |
69 | from IPython.Logger import Logger |
|
69 | from IPython.Logger import Logger | |
70 | from IPython.Magic import Magic,magic2python |
|
70 | from IPython.Magic import Magic,magic2python | |
71 | from IPython.Struct import Struct |
|
71 | from IPython.Struct import Struct | |
72 | from IPython.background_jobs import BackgroundJobManager |
|
72 | from IPython.background_jobs import BackgroundJobManager | |
73 | from IPython.usage import cmd_line_usage,interactive_usage |
|
73 | from IPython.usage import cmd_line_usage,interactive_usage | |
74 | from IPython.genutils import * |
|
74 | from IPython.genutils import * | |
75 |
|
75 | |||
76 | # store the builtin raw_input globally, and use this always, in case user code |
|
76 | # store the builtin raw_input globally, and use this always, in case user code | |
77 | # overwrites it (like wx.py.PyShell does) |
|
77 | # overwrites it (like wx.py.PyShell does) | |
78 | raw_input_original = raw_input |
|
78 | raw_input_original = raw_input | |
79 |
|
79 | |||
80 | #**************************************************************************** |
|
80 | #**************************************************************************** | |
81 | # Some utility function definitions |
|
81 | # Some utility function definitions | |
82 |
|
82 | |||
83 | # This can be replaced with an isspace() call once we drop 2.2 compatibility |
|
83 | # This can be replaced with an isspace() call once we drop 2.2 compatibility | |
84 | _isspace_match = re.compile(r'^\s+$').match |
|
84 | _isspace_match = re.compile(r'^\s+$').match | |
85 | def isspace(s): |
|
85 | def isspace(s): | |
86 | return bool(_isspace_match(s)) |
|
86 | return bool(_isspace_match(s)) | |
87 |
|
87 | |||
88 | def esc_quotes(strng): |
|
88 | def esc_quotes(strng): | |
89 | """Return the input string with single and double quotes escaped out""" |
|
89 | """Return the input string with single and double quotes escaped out""" | |
90 |
|
90 | |||
91 | return strng.replace('"','\\"').replace("'","\\'") |
|
91 | return strng.replace('"','\\"').replace("'","\\'") | |
92 |
|
92 | |||
93 | def import_fail_info(mod_name,fns=None): |
|
93 | def import_fail_info(mod_name,fns=None): | |
94 | """Inform load failure for a module.""" |
|
94 | """Inform load failure for a module.""" | |
95 |
|
95 | |||
96 | if fns == None: |
|
96 | if fns == None: | |
97 | warn("Loading of %s failed.\n" % (mod_name,)) |
|
97 | warn("Loading of %s failed.\n" % (mod_name,)) | |
98 | else: |
|
98 | else: | |
99 | warn("Loading of %s from %s failed.\n" % (fns,mod_name)) |
|
99 | warn("Loading of %s from %s failed.\n" % (fns,mod_name)) | |
100 |
|
100 | |||
101 | def qw_lol(indata): |
|
101 | def qw_lol(indata): | |
102 | """qw_lol('a b') -> [['a','b']], |
|
102 | """qw_lol('a b') -> [['a','b']], | |
103 | otherwise it's just a call to qw(). |
|
103 | otherwise it's just a call to qw(). | |
104 |
|
104 | |||
105 | We need this to make sure the modules_some keys *always* end up as a |
|
105 | We need this to make sure the modules_some keys *always* end up as a | |
106 | list of lists.""" |
|
106 | list of lists.""" | |
107 |
|
107 | |||
108 | if type(indata) in StringTypes: |
|
108 | if type(indata) in StringTypes: | |
109 | return [qw(indata)] |
|
109 | return [qw(indata)] | |
110 | else: |
|
110 | else: | |
111 | return qw(indata) |
|
111 | return qw(indata) | |
112 |
|
112 | |||
113 | def ipmagic(arg_s): |
|
113 | def ipmagic(arg_s): | |
114 | """Call a magic function by name. |
|
114 | """Call a magic function by name. | |
115 |
|
115 | |||
116 | Input: a string containing the name of the magic function to call and any |
|
116 | Input: a string containing the name of the magic function to call and any | |
117 | additional arguments to be passed to the magic. |
|
117 | additional arguments to be passed to the magic. | |
118 |
|
118 | |||
119 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython |
|
119 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython | |
120 | prompt: |
|
120 | prompt: | |
121 |
|
121 | |||
122 | In[1]: %name -opt foo bar |
|
122 | In[1]: %name -opt foo bar | |
123 |
|
123 | |||
124 | To call a magic without arguments, simply use ipmagic('name'). |
|
124 | To call a magic without arguments, simply use ipmagic('name'). | |
125 |
|
125 | |||
126 | This provides a proper Python function to call IPython's magics in any |
|
126 | This provides a proper Python function to call IPython's magics in any | |
127 | valid Python code you can type at the interpreter, including loops and |
|
127 | valid Python code you can type at the interpreter, including loops and | |
128 | compound statements. It is added by IPython to the Python builtin |
|
128 | compound statements. It is added by IPython to the Python builtin | |
129 | namespace upon initialization.""" |
|
129 | namespace upon initialization.""" | |
130 |
|
130 | |||
131 | args = arg_s.split(' ',1) |
|
131 | args = arg_s.split(' ',1) | |
132 | magic_name = args[0] |
|
132 | magic_name = args[0] | |
133 | if magic_name.startswith(__IPYTHON__.ESC_MAGIC): |
|
133 | if magic_name.startswith(__IPYTHON__.ESC_MAGIC): | |
134 | magic_name = magic_name[1:] |
|
134 | magic_name = magic_name[1:] | |
135 | try: |
|
135 | try: | |
136 | magic_args = args[1] |
|
136 | magic_args = args[1] | |
137 | except IndexError: |
|
137 | except IndexError: | |
138 | magic_args = '' |
|
138 | magic_args = '' | |
139 | fn = getattr(__IPYTHON__,'magic_'+magic_name,None) |
|
139 | fn = getattr(__IPYTHON__,'magic_'+magic_name,None) | |
140 | if fn is None: |
|
140 | if fn is None: | |
141 | error("Magic function `%s` not found." % magic_name) |
|
141 | error("Magic function `%s` not found." % magic_name) | |
142 | else: |
|
142 | else: | |
143 | magic_args = __IPYTHON__.var_expand(magic_args) |
|
143 | magic_args = __IPYTHON__.var_expand(magic_args) | |
144 | return fn(magic_args) |
|
144 | return fn(magic_args) | |
145 |
|
145 | |||
146 | def ipalias(arg_s): |
|
146 | def ipalias(arg_s): | |
147 | """Call an alias by name. |
|
147 | """Call an alias by name. | |
148 |
|
148 | |||
149 | Input: a string containing the name of the alias to call and any |
|
149 | Input: a string containing the name of the alias to call and any | |
150 | additional arguments to be passed to the magic. |
|
150 | additional arguments to be passed to the magic. | |
151 |
|
151 | |||
152 | ipalias('name -opt foo bar') is equivalent to typing at the ipython |
|
152 | ipalias('name -opt foo bar') is equivalent to typing at the ipython | |
153 | prompt: |
|
153 | prompt: | |
154 |
|
154 | |||
155 | In[1]: name -opt foo bar |
|
155 | In[1]: name -opt foo bar | |
156 |
|
156 | |||
157 | To call an alias without arguments, simply use ipalias('name'). |
|
157 | To call an alias without arguments, simply use ipalias('name'). | |
158 |
|
158 | |||
159 | This provides a proper Python function to call IPython's aliases in any |
|
159 | This provides a proper Python function to call IPython's aliases in any | |
160 | valid Python code you can type at the interpreter, including loops and |
|
160 | valid Python code you can type at the interpreter, including loops and | |
161 | compound statements. It is added by IPython to the Python builtin |
|
161 | compound statements. It is added by IPython to the Python builtin | |
162 | namespace upon initialization.""" |
|
162 | namespace upon initialization.""" | |
163 |
|
163 | |||
164 | args = arg_s.split(' ',1) |
|
164 | args = arg_s.split(' ',1) | |
165 | alias_name = args[0] |
|
165 | alias_name = args[0] | |
166 | try: |
|
166 | try: | |
167 | alias_args = args[1] |
|
167 | alias_args = args[1] | |
168 | except IndexError: |
|
168 | except IndexError: | |
169 | alias_args = '' |
|
169 | alias_args = '' | |
170 | if alias_name in __IPYTHON__.alias_table: |
|
170 | if alias_name in __IPYTHON__.alias_table: | |
171 | __IPYTHON__.call_alias(alias_name,alias_args) |
|
171 | __IPYTHON__.call_alias(alias_name,alias_args) | |
172 | else: |
|
172 | else: | |
173 | error("Alias `%s` not found." % alias_name) |
|
173 | error("Alias `%s` not found." % alias_name) | |
174 |
|
174 | |||
175 | def softspace(file, newvalue): |
|
175 | def softspace(file, newvalue): | |
176 | """Copied from code.py, to remove the dependency""" |
|
176 | """Copied from code.py, to remove the dependency""" | |
177 | oldvalue = 0 |
|
177 | oldvalue = 0 | |
178 | try: |
|
178 | try: | |
179 | oldvalue = file.softspace |
|
179 | oldvalue = file.softspace | |
180 | except AttributeError: |
|
180 | except AttributeError: | |
181 | pass |
|
181 | pass | |
182 | try: |
|
182 | try: | |
183 | file.softspace = newvalue |
|
183 | file.softspace = newvalue | |
184 | except (AttributeError, TypeError): |
|
184 | except (AttributeError, TypeError): | |
185 | # "attribute-less object" or "read-only attributes" |
|
185 | # "attribute-less object" or "read-only attributes" | |
186 | pass |
|
186 | pass | |
187 | return oldvalue |
|
187 | return oldvalue | |
188 |
|
188 | |||
189 |
|
189 | |||
190 | #**************************************************************************** |
|
190 | #**************************************************************************** | |
191 | # Local use exceptions |
|
191 | # Local use exceptions | |
192 | class SpaceInInput(exceptions.Exception): pass |
|
192 | class SpaceInInput(exceptions.Exception): pass | |
193 |
|
193 | |||
194 | #**************************************************************************** |
|
194 | #**************************************************************************** | |
195 | # Local use classes |
|
195 | # Local use classes | |
196 | class Bunch: pass |
|
196 | class Bunch: pass | |
197 |
|
197 | |||
198 | class InputList(list): |
|
198 | class InputList(list): | |
199 | """Class to store user input. |
|
199 | """Class to store user input. | |
200 |
|
200 | |||
201 | It's basically a list, but slices return a string instead of a list, thus |
|
201 | It's basically a list, but slices return a string instead of a list, thus | |
202 | allowing things like (assuming 'In' is an instance): |
|
202 | allowing things like (assuming 'In' is an instance): | |
203 |
|
203 | |||
204 | exec In[4:7] |
|
204 | exec In[4:7] | |
205 |
|
205 | |||
206 | or |
|
206 | or | |
207 |
|
207 | |||
208 | exec In[5:9] + In[14] + In[21:25]""" |
|
208 | exec In[5:9] + In[14] + In[21:25]""" | |
209 |
|
209 | |||
210 | def __getslice__(self,i,j): |
|
210 | def __getslice__(self,i,j): | |
211 | return ''.join(list.__getslice__(self,i,j)) |
|
211 | return ''.join(list.__getslice__(self,i,j)) | |
212 |
|
212 | |||
213 | class SyntaxTB(ultraTB.ListTB): |
|
213 | class SyntaxTB(ultraTB.ListTB): | |
214 | """Extension which holds some state: the last exception value""" |
|
214 | """Extension which holds some state: the last exception value""" | |
215 |
|
215 | |||
216 | def __init__(self,color_scheme = 'NoColor'): |
|
216 | def __init__(self,color_scheme = 'NoColor'): | |
217 | ultraTB.ListTB.__init__(self,color_scheme) |
|
217 | ultraTB.ListTB.__init__(self,color_scheme) | |
218 | self.last_syntax_error = None |
|
218 | self.last_syntax_error = None | |
219 |
|
219 | |||
220 | def __call__(self, etype, value, elist): |
|
220 | def __call__(self, etype, value, elist): | |
221 | self.last_syntax_error = value |
|
221 | self.last_syntax_error = value | |
222 | ultraTB.ListTB.__call__(self,etype,value,elist) |
|
222 | ultraTB.ListTB.__call__(self,etype,value,elist) | |
223 |
|
223 | |||
224 | def clear_err_state(self): |
|
224 | def clear_err_state(self): | |
225 | """Return the current error state and clear it""" |
|
225 | """Return the current error state and clear it""" | |
226 | e = self.last_syntax_error |
|
226 | e = self.last_syntax_error | |
227 | self.last_syntax_error = None |
|
227 | self.last_syntax_error = None | |
228 | return e |
|
228 | return e | |
229 |
|
229 | |||
230 | #**************************************************************************** |
|
230 | #**************************************************************************** | |
231 | # Main IPython class |
|
231 | # Main IPython class | |
232 | class InteractiveShell(Logger, Magic): |
|
232 | class InteractiveShell(Logger, Magic): | |
233 | """An enhanced console for Python.""" |
|
233 | """An enhanced console for Python.""" | |
234 |
|
234 | |||
|
235 | # class attribute to indicate whether the class supports threads or not. | |||
|
236 | # Subclasses with thread support should override this as needed. | |||
|
237 | isthreaded = False | |||
|
238 | ||||
235 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
239 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
236 | user_ns = None,user_global_ns=None,banner2='', |
|
240 | user_ns = None,user_global_ns=None,banner2='', | |
237 | custom_exceptions=((),None),embedded=False): |
|
241 | custom_exceptions=((),None),embedded=False): | |
238 |
|
242 | |||
239 | # some minimal strict typechecks. For some core data structures, I |
|
243 | # some minimal strict typechecks. For some core data structures, I | |
240 | # want actual basic python types, not just anything that looks like |
|
244 | # want actual basic python types, not just anything that looks like | |
241 | # one. This is especially true for namespaces. |
|
245 | # one. This is especially true for namespaces. | |
242 | for ns in (user_ns,user_global_ns): |
|
246 | for ns in (user_ns,user_global_ns): | |
243 | if ns is not None and type(ns) != types.DictType: |
|
247 | if ns is not None and type(ns) != types.DictType: | |
244 | raise TypeError,'namespace must be a dictionary' |
|
248 | raise TypeError,'namespace must be a dictionary' | |
245 |
|
249 | |||
246 | # Put a reference to self in builtins so that any form of embedded or |
|
250 | # Put a reference to self in builtins so that any form of embedded or | |
247 | # imported code can test for being inside IPython. |
|
251 | # imported code can test for being inside IPython. | |
248 | __builtin__.__IPYTHON__ = self |
|
252 | __builtin__.__IPYTHON__ = self | |
249 |
|
253 | |||
250 | # And load into builtins ipmagic/ipalias as well |
|
254 | # And load into builtins ipmagic/ipalias as well | |
251 | __builtin__.ipmagic = ipmagic |
|
255 | __builtin__.ipmagic = ipmagic | |
252 | __builtin__.ipalias = ipalias |
|
256 | __builtin__.ipalias = ipalias | |
253 |
|
257 | |||
254 | # Add to __builtin__ other parts of IPython's public API |
|
258 | # Add to __builtin__ other parts of IPython's public API | |
255 | __builtin__.ip_set_hook = self.set_hook |
|
259 | __builtin__.ip_set_hook = self.set_hook | |
256 |
|
260 | |||
257 | # Keep in the builtins a flag for when IPython is active. We set it |
|
261 | # Keep in the builtins a flag for when IPython is active. We set it | |
258 | # with setdefault so that multiple nested IPythons don't clobber one |
|
262 | # with setdefault so that multiple nested IPythons don't clobber one | |
259 | # another. Each will increase its value by one upon being activated, |
|
263 | # another. Each will increase its value by one upon being activated, | |
260 | # which also gives us a way to determine the nesting level. |
|
264 | # which also gives us a way to determine the nesting level. | |
261 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) |
|
265 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) | |
262 |
|
266 | |||
263 | # Do the intuitively correct thing for quit/exit: we remove the |
|
267 | # Do the intuitively correct thing for quit/exit: we remove the | |
264 | # builtins if they exist, and our own prefilter routine will handle |
|
268 | # builtins if they exist, and our own prefilter routine will handle | |
265 | # these special cases |
|
269 | # these special cases | |
266 | try: |
|
270 | try: | |
267 | del __builtin__.exit, __builtin__.quit |
|
271 | del __builtin__.exit, __builtin__.quit | |
268 | except AttributeError: |
|
272 | except AttributeError: | |
269 | pass |
|
273 | pass | |
270 |
|
274 | |||
|
275 | # Store the actual shell's name | |||
|
276 | self.name = name | |||
|
277 | ||||
271 | # We need to know whether the instance is meant for embedding, since |
|
278 | # We need to know whether the instance is meant for embedding, since | |
272 | # global/local namespaces need to be handled differently in that case |
|
279 | # global/local namespaces need to be handled differently in that case | |
273 | self.embedded = embedded |
|
280 | self.embedded = embedded | |
274 |
|
281 | |||
275 | # command compiler |
|
282 | # command compiler | |
276 | self.compile = codeop.CommandCompiler() |
|
283 | self.compile = codeop.CommandCompiler() | |
277 |
|
284 | |||
278 | # User input buffer |
|
285 | # User input buffer | |
279 | self.buffer = [] |
|
286 | self.buffer = [] | |
280 |
|
287 | |||
281 | # Default name given in compilation of code |
|
288 | # Default name given in compilation of code | |
282 | self.filename = '<ipython console>' |
|
289 | self.filename = '<ipython console>' | |
283 |
|
290 | |||
284 | # Create the namespace where the user will operate. user_ns is |
|
291 | # Create the namespace where the user will operate. user_ns is | |
285 | # normally the only one used, and it is passed to the exec calls as |
|
292 | # normally the only one used, and it is passed to the exec calls as | |
286 | # the locals argument. But we do carry a user_global_ns namespace |
|
293 | # the locals argument. But we do carry a user_global_ns namespace | |
287 | # given as the exec 'globals' argument, This is useful in embedding |
|
294 | # given as the exec 'globals' argument, This is useful in embedding | |
288 | # situations where the ipython shell opens in a context where the |
|
295 | # situations where the ipython shell opens in a context where the | |
289 | # distinction between locals and globals is meaningful. |
|
296 | # distinction between locals and globals is meaningful. | |
290 |
|
297 | |||
291 | # FIXME. For some strange reason, __builtins__ is showing up at user |
|
298 | # FIXME. For some strange reason, __builtins__ is showing up at user | |
292 | # level as a dict instead of a module. This is a manual fix, but I |
|
299 | # level as a dict instead of a module. This is a manual fix, but I | |
293 | # should really track down where the problem is coming from. Alex |
|
300 | # should really track down where the problem is coming from. Alex | |
294 | # Schmolck reported this problem first. |
|
301 | # Schmolck reported this problem first. | |
295 |
|
302 | |||
296 | # A useful post by Alex Martelli on this topic: |
|
303 | # A useful post by Alex Martelli on this topic: | |
297 | # Re: inconsistent value from __builtins__ |
|
304 | # Re: inconsistent value from __builtins__ | |
298 | # Von: Alex Martelli <aleaxit@yahoo.com> |
|
305 | # Von: Alex Martelli <aleaxit@yahoo.com> | |
299 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends |
|
306 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends | |
300 | # Gruppen: comp.lang.python |
|
307 | # Gruppen: comp.lang.python | |
301 | # Referenzen: 1 |
|
308 | # Referenzen: 1 | |
302 |
|
309 | |||
303 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: |
|
310 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: | |
304 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) |
|
311 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) | |
305 | # > <type 'dict'> |
|
312 | # > <type 'dict'> | |
306 | # > >>> print type(__builtins__) |
|
313 | # > >>> print type(__builtins__) | |
307 | # > <type 'module'> |
|
314 | # > <type 'module'> | |
308 | # > Is this difference in return value intentional? |
|
315 | # > Is this difference in return value intentional? | |
309 |
|
316 | |||
310 | # Well, it's documented that '__builtins__' can be either a dictionary |
|
317 | # Well, it's documented that '__builtins__' can be either a dictionary | |
311 | # or a module, and it's been that way for a long time. Whether it's |
|
318 | # or a module, and it's been that way for a long time. Whether it's | |
312 | # intentional (or sensible), I don't know. In any case, the idea is |
|
319 | # intentional (or sensible), I don't know. In any case, the idea is | |
313 | # that if you need to access the built-in namespace directly, you |
|
320 | # that if you need to access the built-in namespace directly, you | |
314 | # should start with "import __builtin__" (note, no 's') which will |
|
321 | # should start with "import __builtin__" (note, no 's') which will | |
315 | # definitely give you a module. Yeah, it's somewhatΒ confusing:-(. |
|
322 | # definitely give you a module. Yeah, it's somewhatΒ confusing:-(. | |
316 |
|
323 | |||
317 | if user_ns is None: |
|
324 | if user_ns is None: | |
318 | # Set __name__ to __main__ to better match the behavior of the |
|
325 | # Set __name__ to __main__ to better match the behavior of the | |
319 | # normal interpreter. |
|
326 | # normal interpreter. | |
320 | user_ns = {'__name__' :'__main__', |
|
327 | user_ns = {'__name__' :'__main__', | |
321 | '__builtins__' : __builtin__, |
|
328 | '__builtins__' : __builtin__, | |
322 | } |
|
329 | } | |
323 |
|
330 | |||
324 | if user_global_ns is None: |
|
331 | if user_global_ns is None: | |
325 | user_global_ns = {} |
|
332 | user_global_ns = {} | |
326 |
|
333 | |||
327 | # Assign namespaces |
|
334 | # Assign namespaces | |
328 | # This is the namespace where all normal user variables live |
|
335 | # This is the namespace where all normal user variables live | |
329 | self.user_ns = user_ns |
|
336 | self.user_ns = user_ns | |
330 | # Embedded instances require a separate namespace for globals. |
|
337 | # Embedded instances require a separate namespace for globals. | |
331 | # Normally this one is unused by non-embedded instances. |
|
338 | # Normally this one is unused by non-embedded instances. | |
332 | self.user_global_ns = user_global_ns |
|
339 | self.user_global_ns = user_global_ns | |
333 | # A namespace to keep track of internal data structures to prevent |
|
340 | # A namespace to keep track of internal data structures to prevent | |
334 | # them from cluttering user-visible stuff. Will be updated later |
|
341 | # them from cluttering user-visible stuff. Will be updated later | |
335 | self.internal_ns = {} |
|
342 | self.internal_ns = {} | |
336 |
|
343 | |||
337 | # Namespace of system aliases. Each entry in the alias |
|
344 | # Namespace of system aliases. Each entry in the alias | |
338 | # table must be a 2-tuple of the form (N,name), where N is the number |
|
345 | # table must be a 2-tuple of the form (N,name), where N is the number | |
339 | # of positional arguments of the alias. |
|
346 | # of positional arguments of the alias. | |
340 | self.alias_table = {} |
|
347 | self.alias_table = {} | |
341 |
|
348 | |||
342 | # A table holding all the namespaces IPython deals with, so that |
|
349 | # A table holding all the namespaces IPython deals with, so that | |
343 | # introspection facilities can search easily. |
|
350 | # introspection facilities can search easily. | |
344 | self.ns_table = {'user':user_ns, |
|
351 | self.ns_table = {'user':user_ns, | |
345 | 'user_global':user_global_ns, |
|
352 | 'user_global':user_global_ns, | |
346 | 'alias':self.alias_table, |
|
353 | 'alias':self.alias_table, | |
347 | 'internal':self.internal_ns, |
|
354 | 'internal':self.internal_ns, | |
348 | 'builtin':__builtin__.__dict__ |
|
355 | 'builtin':__builtin__.__dict__ | |
349 | } |
|
356 | } | |
350 |
|
357 | |||
351 | # The user namespace MUST have a pointer to the shell itself. |
|
358 | # The user namespace MUST have a pointer to the shell itself. | |
352 | self.user_ns[name] = self |
|
359 | self.user_ns[name] = self | |
353 |
|
360 | |||
354 | # We need to insert into sys.modules something that looks like a |
|
361 | # We need to insert into sys.modules something that looks like a | |
355 | # module but which accesses the IPython namespace, for shelve and |
|
362 | # module but which accesses the IPython namespace, for shelve and | |
356 | # pickle to work interactively. Normally they rely on getting |
|
363 | # pickle to work interactively. Normally they rely on getting | |
357 | # everything out of __main__, but for embedding purposes each IPython |
|
364 | # everything out of __main__, but for embedding purposes each IPython | |
358 | # instance has its own private namespace, so we can't go shoving |
|
365 | # instance has its own private namespace, so we can't go shoving | |
359 | # everything into __main__. |
|
366 | # everything into __main__. | |
360 |
|
367 | |||
361 | # note, however, that we should only do this for non-embedded |
|
368 | # note, however, that we should only do this for non-embedded | |
362 | # ipythons, which really mimic the __main__.__dict__ with their own |
|
369 | # ipythons, which really mimic the __main__.__dict__ with their own | |
363 | # namespace. Embedded instances, on the other hand, should not do |
|
370 | # namespace. Embedded instances, on the other hand, should not do | |
364 | # this because they need to manage the user local/global namespaces |
|
371 | # this because they need to manage the user local/global namespaces | |
365 | # only, but they live within a 'normal' __main__ (meaning, they |
|
372 | # only, but they live within a 'normal' __main__ (meaning, they | |
366 | # shouldn't overtake the execution environment of the script they're |
|
373 | # shouldn't overtake the execution environment of the script they're | |
367 | # embedded in). |
|
374 | # embedded in). | |
368 |
|
375 | |||
369 | if not embedded: |
|
376 | if not embedded: | |
370 | try: |
|
377 | try: | |
371 | main_name = self.user_ns['__name__'] |
|
378 | main_name = self.user_ns['__name__'] | |
372 | except KeyError: |
|
379 | except KeyError: | |
373 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' |
|
380 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' | |
374 | else: |
|
381 | else: | |
375 | #print "pickle hack in place" # dbg |
|
382 | #print "pickle hack in place" # dbg | |
376 | sys.modules[main_name] = FakeModule(self.user_ns) |
|
383 | sys.modules[main_name] = FakeModule(self.user_ns) | |
377 |
|
384 | |||
378 | # List of input with multi-line handling. |
|
385 | # List of input with multi-line handling. | |
379 | # Fill its zero entry, user counter starts at 1 |
|
386 | # Fill its zero entry, user counter starts at 1 | |
380 | self.input_hist = InputList(['\n']) |
|
387 | self.input_hist = InputList(['\n']) | |
381 |
|
388 | |||
382 | # list of visited directories |
|
389 | # list of visited directories | |
383 | try: |
|
390 | try: | |
384 | self.dir_hist = [os.getcwd()] |
|
391 | self.dir_hist = [os.getcwd()] | |
385 | except IOError, e: |
|
392 | except IOError, e: | |
386 | self.dir_hist = [] |
|
393 | self.dir_hist = [] | |
387 |
|
394 | |||
388 | # dict of output history |
|
395 | # dict of output history | |
389 | self.output_hist = {} |
|
396 | self.output_hist = {} | |
390 |
|
397 | |||
391 | # dict of things NOT to alias (keywords, builtins and some magics) |
|
398 | # dict of things NOT to alias (keywords, builtins and some magics) | |
392 | no_alias = {} |
|
399 | no_alias = {} | |
393 | no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] |
|
400 | no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] | |
394 | for key in keyword.kwlist + no_alias_magics: |
|
401 | for key in keyword.kwlist + no_alias_magics: | |
395 | no_alias[key] = 1 |
|
402 | no_alias[key] = 1 | |
396 | no_alias.update(__builtin__.__dict__) |
|
403 | no_alias.update(__builtin__.__dict__) | |
397 | self.no_alias = no_alias |
|
404 | self.no_alias = no_alias | |
398 |
|
405 | |||
399 | # make global variables for user access to these |
|
406 | # make global variables for user access to these | |
400 | self.user_ns['_ih'] = self.input_hist |
|
407 | self.user_ns['_ih'] = self.input_hist | |
401 | self.user_ns['_oh'] = self.output_hist |
|
408 | self.user_ns['_oh'] = self.output_hist | |
402 | self.user_ns['_dh'] = self.dir_hist |
|
409 | self.user_ns['_dh'] = self.dir_hist | |
403 |
|
410 | |||
404 | # user aliases to input and output histories |
|
411 | # user aliases to input and output histories | |
405 | self.user_ns['In'] = self.input_hist |
|
412 | self.user_ns['In'] = self.input_hist | |
406 | self.user_ns['Out'] = self.output_hist |
|
413 | self.user_ns['Out'] = self.output_hist | |
407 |
|
414 | |||
408 | # Store the actual shell's name |
|
|||
409 | self.name = name |
|
|||
410 |
|
||||
411 | # Object variable to store code object waiting execution. This is |
|
415 | # Object variable to store code object waiting execution. This is | |
412 | # used mainly by the multithreaded shells, but it can come in handy in |
|
416 | # used mainly by the multithreaded shells, but it can come in handy in | |
413 | # other situations. No need to use a Queue here, since it's a single |
|
417 | # other situations. No need to use a Queue here, since it's a single | |
414 | # item which gets cleared once run. |
|
418 | # item which gets cleared once run. | |
415 | self.code_to_run = None |
|
419 | self.code_to_run = None | |
416 |
|
420 | |||
417 | # Job manager (for jobs run as background threads) |
|
421 | # Job manager (for jobs run as background threads) | |
418 | self.jobs = BackgroundJobManager() |
|
422 | self.jobs = BackgroundJobManager() | |
419 | # Put the job manager into builtins so it's always there. |
|
423 | # Put the job manager into builtins so it's always there. | |
420 | __builtin__.jobs = self.jobs |
|
424 | __builtin__.jobs = self.jobs | |
421 |
|
425 | |||
422 | # escapes for automatic behavior on the command line |
|
426 | # escapes for automatic behavior on the command line | |
423 | self.ESC_SHELL = '!' |
|
427 | self.ESC_SHELL = '!' | |
424 | self.ESC_HELP = '?' |
|
428 | self.ESC_HELP = '?' | |
425 | self.ESC_MAGIC = '%' |
|
429 | self.ESC_MAGIC = '%' | |
426 | self.ESC_QUOTE = ',' |
|
430 | self.ESC_QUOTE = ',' | |
427 | self.ESC_QUOTE2 = ';' |
|
431 | self.ESC_QUOTE2 = ';' | |
428 | self.ESC_PAREN = '/' |
|
432 | self.ESC_PAREN = '/' | |
429 |
|
433 | |||
430 | # And their associated handlers |
|
434 | # And their associated handlers | |
431 | self.esc_handlers = {self.ESC_PAREN:self.handle_auto, |
|
435 | self.esc_handlers = {self.ESC_PAREN:self.handle_auto, | |
432 | self.ESC_QUOTE:self.handle_auto, |
|
436 | self.ESC_QUOTE:self.handle_auto, | |
433 | self.ESC_QUOTE2:self.handle_auto, |
|
437 | self.ESC_QUOTE2:self.handle_auto, | |
434 | self.ESC_MAGIC:self.handle_magic, |
|
438 | self.ESC_MAGIC:self.handle_magic, | |
435 | self.ESC_HELP:self.handle_help, |
|
439 | self.ESC_HELP:self.handle_help, | |
436 | self.ESC_SHELL:self.handle_shell_escape, |
|
440 | self.ESC_SHELL:self.handle_shell_escape, | |
437 | } |
|
441 | } | |
438 |
|
442 | |||
439 | # class initializations |
|
443 | # class initializations | |
440 | Logger.__init__(self,log_ns = self.user_ns) |
|
444 | Logger.__init__(self,log_ns = self.user_ns) | |
441 | Magic.__init__(self,self) |
|
445 | Magic.__init__(self,self) | |
442 |
|
446 | |||
443 | # an ugly hack to get a pointer to the shell, so I can start writing |
|
447 | # an ugly hack to get a pointer to the shell, so I can start writing | |
444 | # magic code via this pointer instead of the current mixin salad. |
|
448 | # magic code via this pointer instead of the current mixin salad. | |
445 | Magic.set_shell(self,self) |
|
449 | Magic.set_shell(self,self) | |
446 |
|
450 | |||
447 | # Python source parser/formatter for syntax highlighting |
|
451 | # Python source parser/formatter for syntax highlighting | |
448 | pyformat = PyColorize.Parser().format |
|
452 | pyformat = PyColorize.Parser().format | |
449 | self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) |
|
453 | self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) | |
450 |
|
454 | |||
451 | # hooks holds pointers used for user-side customizations |
|
455 | # hooks holds pointers used for user-side customizations | |
452 | self.hooks = Struct() |
|
456 | self.hooks = Struct() | |
453 |
|
457 | |||
454 | # Set all default hooks, defined in the IPython.hooks module. |
|
458 | # Set all default hooks, defined in the IPython.hooks module. | |
455 | hooks = IPython.hooks |
|
459 | hooks = IPython.hooks | |
456 | for hook_name in hooks.__all__: |
|
460 | for hook_name in hooks.__all__: | |
457 | self.set_hook(hook_name,getattr(hooks,hook_name)) |
|
461 | self.set_hook(hook_name,getattr(hooks,hook_name)) | |
458 |
|
462 | |||
459 | # Flag to mark unconditional exit |
|
463 | # Flag to mark unconditional exit | |
460 | self.exit_now = False |
|
464 | self.exit_now = False | |
461 |
|
465 | |||
462 | self.usage_min = """\ |
|
466 | self.usage_min = """\ | |
463 | An enhanced console for Python. |
|
467 | An enhanced console for Python. | |
464 | Some of its features are: |
|
468 | Some of its features are: | |
465 | - Readline support if the readline library is present. |
|
469 | - Readline support if the readline library is present. | |
466 | - Tab completion in the local namespace. |
|
470 | - Tab completion in the local namespace. | |
467 | - Logging of input, see command-line options. |
|
471 | - Logging of input, see command-line options. | |
468 | - System shell escape via ! , eg !ls. |
|
472 | - System shell escape via ! , eg !ls. | |
469 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) |
|
473 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) | |
470 | - Keeps track of locally defined variables via %who, %whos. |
|
474 | - Keeps track of locally defined variables via %who, %whos. | |
471 | - Show object information with a ? eg ?x or x? (use ?? for more info). |
|
475 | - Show object information with a ? eg ?x or x? (use ?? for more info). | |
472 | """ |
|
476 | """ | |
473 | if usage: self.usage = usage |
|
477 | if usage: self.usage = usage | |
474 | else: self.usage = self.usage_min |
|
478 | else: self.usage = self.usage_min | |
475 |
|
479 | |||
476 | # Storage |
|
480 | # Storage | |
477 | self.rc = rc # This will hold all configuration information |
|
481 | self.rc = rc # This will hold all configuration information | |
478 | self.inputcache = [] |
|
482 | self.inputcache = [] | |
479 | self._boundcache = [] |
|
483 | self._boundcache = [] | |
480 | self.pager = 'less' |
|
484 | self.pager = 'less' | |
481 | # temporary files used for various purposes. Deleted at exit. |
|
485 | # temporary files used for various purposes. Deleted at exit. | |
482 | self.tempfiles = [] |
|
486 | self.tempfiles = [] | |
483 |
|
487 | |||
484 | # Keep track of readline usage (later set by init_readline) |
|
488 | # Keep track of readline usage (later set by init_readline) | |
485 | self.has_readline = False |
|
489 | self.has_readline = False | |
486 |
|
490 | |||
487 | # for pushd/popd management |
|
491 | # for pushd/popd management | |
488 | try: |
|
492 | try: | |
489 | self.home_dir = get_home_dir() |
|
493 | self.home_dir = get_home_dir() | |
490 | except HomeDirError,msg: |
|
494 | except HomeDirError,msg: | |
491 | fatal(msg) |
|
495 | fatal(msg) | |
492 |
|
496 | |||
493 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] |
|
497 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] | |
494 |
|
498 | |||
495 | # Functions to call the underlying shell. |
|
499 | # Functions to call the underlying shell. | |
496 |
|
500 | |||
497 | # utility to expand user variables via Itpl |
|
501 | # utility to expand user variables via Itpl | |
498 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), |
|
502 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), | |
499 | self.user_ns)) |
|
503 | self.user_ns)) | |
500 | # The first is similar to os.system, but it doesn't return a value, |
|
504 | # The first is similar to os.system, but it doesn't return a value, | |
501 | # and it allows interpolation of variables in the user's namespace. |
|
505 | # and it allows interpolation of variables in the user's namespace. | |
502 | self.system = lambda cmd: shell(self.var_expand(cmd), |
|
506 | self.system = lambda cmd: shell(self.var_expand(cmd), | |
503 | header='IPython system call: ', |
|
507 | header='IPython system call: ', | |
504 | verbose=self.rc.system_verbose) |
|
508 | verbose=self.rc.system_verbose) | |
505 | # These are for getoutput and getoutputerror: |
|
509 | # These are for getoutput and getoutputerror: | |
506 | self.getoutput = lambda cmd: \ |
|
510 | self.getoutput = lambda cmd: \ | |
507 | getoutput(self.var_expand(cmd), |
|
511 | getoutput(self.var_expand(cmd), | |
508 | header='IPython system call: ', |
|
512 | header='IPython system call: ', | |
509 | verbose=self.rc.system_verbose) |
|
513 | verbose=self.rc.system_verbose) | |
510 | self.getoutputerror = lambda cmd: \ |
|
514 | self.getoutputerror = lambda cmd: \ | |
511 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), |
|
515 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), | |
512 | self.user_ns)), |
|
516 | self.user_ns)), | |
513 | header='IPython system call: ', |
|
517 | header='IPython system call: ', | |
514 | verbose=self.rc.system_verbose) |
|
518 | verbose=self.rc.system_verbose) | |
515 |
|
519 | |||
516 | # RegExp for splitting line contents into pre-char//first |
|
520 | # RegExp for splitting line contents into pre-char//first | |
517 | # word-method//rest. For clarity, each group in on one line. |
|
521 | # word-method//rest. For clarity, each group in on one line. | |
518 |
|
522 | |||
519 | # WARNING: update the regexp if the above escapes are changed, as they |
|
523 | # WARNING: update the regexp if the above escapes are changed, as they | |
520 | # are hardwired in. |
|
524 | # are hardwired in. | |
521 |
|
525 | |||
522 | # Don't get carried away with trying to make the autocalling catch too |
|
526 | # Don't get carried away with trying to make the autocalling catch too | |
523 | # much: it's better to be conservative rather than to trigger hidden |
|
527 | # much: it's better to be conservative rather than to trigger hidden | |
524 | # evals() somewhere and end up causing side effects. |
|
528 | # evals() somewhere and end up causing side effects. | |
525 |
|
529 | |||
526 | self.line_split = re.compile(r'^([\s*,;/])' |
|
530 | self.line_split = re.compile(r'^([\s*,;/])' | |
527 | r'([\?\w\.]+\w*\s*)' |
|
531 | r'([\?\w\.]+\w*\s*)' | |
528 | r'(\(?.*$)') |
|
532 | r'(\(?.*$)') | |
529 |
|
533 | |||
530 | # Original re, keep around for a while in case changes break something |
|
534 | # Original re, keep around for a while in case changes break something | |
531 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' |
|
535 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' | |
532 | # r'(\s*[\?\w\.]+\w*\s*)' |
|
536 | # r'(\s*[\?\w\.]+\w*\s*)' | |
533 | # r'(\(?.*$)') |
|
537 | # r'(\(?.*$)') | |
534 |
|
538 | |||
535 | # RegExp to identify potential function names |
|
539 | # RegExp to identify potential function names | |
536 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') |
|
540 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') | |
537 | # RegExp to exclude strings with this start from autocalling |
|
541 | # RegExp to exclude strings with this start from autocalling | |
538 | self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ') |
|
542 | self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ') | |
539 |
|
543 | |||
540 | # try to catch also methods for stuff in lists/tuples/dicts: off |
|
544 | # try to catch also methods for stuff in lists/tuples/dicts: off | |
541 | # (experimental). For this to work, the line_split regexp would need |
|
545 | # (experimental). For this to work, the line_split regexp would need | |
542 | # to be modified so it wouldn't break things at '['. That line is |
|
546 | # to be modified so it wouldn't break things at '['. That line is | |
543 | # nasty enough that I shouldn't change it until I can test it _well_. |
|
547 | # nasty enough that I shouldn't change it until I can test it _well_. | |
544 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') |
|
548 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') | |
545 |
|
549 | |||
546 | # keep track of where we started running (mainly for crash post-mortem) |
|
550 | # keep track of where we started running (mainly for crash post-mortem) | |
547 | self.starting_dir = os.getcwd() |
|
551 | self.starting_dir = os.getcwd() | |
548 |
|
552 | |||
549 | # Attributes for Logger mixin class, make defaults here |
|
553 | # Attributes for Logger mixin class, make defaults here | |
550 | self._dolog = False |
|
554 | self._dolog = False | |
551 | self.LOG = '' |
|
555 | self.LOG = '' | |
552 | self.LOGDEF = '.InteractiveShell.log' |
|
556 | self.LOGDEF = '.InteractiveShell.log' | |
553 | self.LOGMODE = 'over' |
|
557 | self.LOGMODE = 'over' | |
554 | self.LOGHEAD = Itpl( |
|
558 | self.LOGHEAD = Itpl( | |
555 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** |
|
559 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** | |
556 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW |
|
560 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW | |
557 | #log# opts = $self.rc.opts |
|
561 | #log# opts = $self.rc.opts | |
558 | #log# args = $self.rc.args |
|
562 | #log# args = $self.rc.args | |
559 | #log# It is safe to make manual edits below here. |
|
563 | #log# It is safe to make manual edits below here. | |
560 | #log#----------------------------------------------------------------------- |
|
564 | #log#----------------------------------------------------------------------- | |
561 | """) |
|
565 | """) | |
562 | # Various switches which can be set |
|
566 | # Various switches which can be set | |
563 | self.CACHELENGTH = 5000 # this is cheap, it's just text |
|
567 | self.CACHELENGTH = 5000 # this is cheap, it's just text | |
564 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ |
|
568 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ | |
565 | self.banner2 = banner2 |
|
569 | self.banner2 = banner2 | |
566 |
|
570 | |||
567 | # TraceBack handlers: |
|
571 | # TraceBack handlers: | |
568 | # Need two, one for syntax errors and one for other exceptions. |
|
572 | ||
|
573 | # Syntax error handler. | |||
569 | self.SyntaxTB = SyntaxTB(color_scheme='NoColor') |
|
574 | self.SyntaxTB = SyntaxTB(color_scheme='NoColor') | |
|
575 | ||||
570 | # The interactive one is initialized with an offset, meaning we always |
|
576 | # The interactive one is initialized with an offset, meaning we always | |
571 | # want to remove the topmost item in the traceback, which is our own |
|
577 | # want to remove the topmost item in the traceback, which is our own | |
572 | # internal code. Valid modes: ['Plain','Context','Verbose'] |
|
578 | # internal code. Valid modes: ['Plain','Context','Verbose'] | |
573 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', |
|
579 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', | |
574 | color_scheme='NoColor', |
|
580 | color_scheme='NoColor', | |
575 | tb_offset = 1) |
|
581 | tb_offset = 1) | |
|
582 | ||||
|
583 | # IPython itself shouldn't crash. This will produce a detailed | |||
|
584 | # post-mortem if it does. But we only install the crash handler for | |||
|
585 | # non-threaded shells, the threaded ones use a normal verbose reporter | |||
|
586 | # and lose the crash handler. This is because exceptions in the main | |||
|
587 | # thread (such as in GUI code) propagate directly to sys.excepthook, | |||
|
588 | # and there's no point in printing crash dumps for every user exception. | |||
|
589 | if self.isthreaded: | |||
|
590 | sys.excepthook = ultraTB.FormattedTB() | |||
|
591 | else: | |||
|
592 | from IPython import CrashHandler | |||
|
593 | sys.excepthook = CrashHandler.CrashHandler(self) | |||
|
594 | ||||
|
595 | # The instance will store a pointer to this, so that runtime code | |||
|
596 | # (such as magics) can access it. This is because during the | |||
|
597 | # read-eval loop, it gets temporarily overwritten (to deal with GUI | |||
|
598 | # frameworks). | |||
|
599 | self.sys_excepthook = sys.excepthook | |||
|
600 | ||||
576 | # and add any custom exception handlers the user may have specified |
|
601 | # and add any custom exception handlers the user may have specified | |
577 | self.set_custom_exc(*custom_exceptions) |
|
602 | self.set_custom_exc(*custom_exceptions) | |
578 |
|
603 | |||
579 | # Object inspector |
|
604 | # Object inspector | |
580 | self.inspector = OInspect.Inspector(OInspect.InspectColors, |
|
605 | self.inspector = OInspect.Inspector(OInspect.InspectColors, | |
581 | PyColorize.ANSICodeColors, |
|
606 | PyColorize.ANSICodeColors, | |
582 | 'NoColor') |
|
607 | 'NoColor') | |
583 | # indentation management |
|
608 | # indentation management | |
584 | self.autoindent = False |
|
609 | self.autoindent = False | |
585 | self.indent_current_nsp = 0 |
|
610 | self.indent_current_nsp = 0 | |
586 | self.indent_current = '' # actual indent string |
|
611 | self.indent_current = '' # actual indent string | |
587 |
|
612 | |||
588 | # Make some aliases automatically |
|
613 | # Make some aliases automatically | |
589 | # Prepare list of shell aliases to auto-define |
|
614 | # Prepare list of shell aliases to auto-define | |
590 | if os.name == 'posix': |
|
615 | if os.name == 'posix': | |
591 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', |
|
616 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', | |
592 | 'mv mv -i','rm rm -i','cp cp -i', |
|
617 | 'mv mv -i','rm rm -i','cp cp -i', | |
593 | 'cat cat','less less','clear clear', |
|
618 | 'cat cat','less less','clear clear', | |
594 | # a better ls |
|
619 | # a better ls | |
595 | 'ls ls -F', |
|
620 | 'ls ls -F', | |
596 | # long ls |
|
621 | # long ls | |
597 | 'll ls -lF', |
|
622 | 'll ls -lF', | |
598 | # color ls |
|
623 | # color ls | |
599 | 'lc ls -F -o --color', |
|
624 | 'lc ls -F -o --color', | |
600 | # ls normal files only |
|
625 | # ls normal files only | |
601 | 'lf ls -F -o --color %l | grep ^-', |
|
626 | 'lf ls -F -o --color %l | grep ^-', | |
602 | # ls symbolic links |
|
627 | # ls symbolic links | |
603 | 'lk ls -F -o --color %l | grep ^l', |
|
628 | 'lk ls -F -o --color %l | grep ^l', | |
604 | # directories or links to directories, |
|
629 | # directories or links to directories, | |
605 | 'ldir ls -F -o --color %l | grep /$', |
|
630 | 'ldir ls -F -o --color %l | grep /$', | |
606 | # things which are executable |
|
631 | # things which are executable | |
607 | 'lx ls -F -o --color %l | grep ^-..x', |
|
632 | 'lx ls -F -o --color %l | grep ^-..x', | |
608 | ) |
|
633 | ) | |
609 | elif os.name in ['nt','dos']: |
|
634 | elif os.name in ['nt','dos']: | |
610 | auto_alias = ('dir dir /on', 'ls dir /on', |
|
635 | auto_alias = ('dir dir /on', 'ls dir /on', | |
611 | 'ddir dir /ad /on', 'ldir dir /ad /on', |
|
636 | 'ddir dir /ad /on', 'ldir dir /ad /on', | |
612 | 'mkdir mkdir','rmdir rmdir','echo echo', |
|
637 | 'mkdir mkdir','rmdir rmdir','echo echo', | |
613 | 'ren ren','cls cls','copy copy') |
|
638 | 'ren ren','cls cls','copy copy') | |
614 | else: |
|
639 | else: | |
615 | auto_alias = () |
|
640 | auto_alias = () | |
616 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) |
|
641 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) | |
617 | # Call the actual (public) initializer |
|
642 | # Call the actual (public) initializer | |
618 | self.init_auto_alias() |
|
643 | self.init_auto_alias() | |
619 | # end __init__ |
|
644 | # end __init__ | |
620 |
|
645 | |||
|
646 | def post_config_initialization(self): | |||
|
647 | """Post configuration init method | |||
|
648 | ||||
|
649 | This is called after the configuration files have been processed to | |||
|
650 | 'finalize' the initialization.""" | |||
|
651 | ||||
|
652 | rc = self.rc | |||
|
653 | ||||
|
654 | # Load readline proper | |||
|
655 | if rc.readline: | |||
|
656 | self.init_readline() | |||
|
657 | ||||
|
658 | # Set user colors (don't do it in the constructor above so that it | |||
|
659 | # doesn't crash if colors option is invalid) | |||
|
660 | self.magic_colors(rc.colors) | |||
|
661 | ||||
|
662 | # Load user aliases | |||
|
663 | for alias in rc.alias: | |||
|
664 | self.magic_alias(alias) | |||
|
665 | ||||
|
666 | # dynamic data that survives through sessions | |||
|
667 | # XXX make the filename a config option? | |||
|
668 | persist_base = 'persist' | |||
|
669 | if rc.profile: | |||
|
670 | persist_base += '_%s' % rc.profile | |||
|
671 | self.persist_fname = os.path.join(rc.ipythondir,persist_base) | |||
|
672 | ||||
|
673 | try: | |||
|
674 | self.persist = pickle.load(file(self.persist_fname)) | |||
|
675 | except: | |||
|
676 | self.persist = {} | |||
|
677 | ||||
621 | def set_hook(self,name,hook): |
|
678 | def set_hook(self,name,hook): | |
622 | """set_hook(name,hook) -> sets an internal IPython hook. |
|
679 | """set_hook(name,hook) -> sets an internal IPython hook. | |
623 |
|
680 | |||
624 | IPython exposes some of its internal API as user-modifiable hooks. By |
|
681 | IPython exposes some of its internal API as user-modifiable hooks. By | |
625 | resetting one of these hooks, you can modify IPython's behavior to |
|
682 | resetting one of these hooks, you can modify IPython's behavior to | |
626 | call at runtime your own routines.""" |
|
683 | call at runtime your own routines.""" | |
627 |
|
684 | |||
628 | # At some point in the future, this should validate the hook before it |
|
685 | # At some point in the future, this should validate the hook before it | |
629 | # accepts it. Probably at least check that the hook takes the number |
|
686 | # accepts it. Probably at least check that the hook takes the number | |
630 | # of args it's supposed to. |
|
687 | # of args it's supposed to. | |
631 | setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) |
|
688 | setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) | |
632 |
|
689 | |||
633 | def set_custom_exc(self,exc_tuple,handler): |
|
690 | def set_custom_exc(self,exc_tuple,handler): | |
634 | """set_custom_exc(exc_tuple,handler) |
|
691 | """set_custom_exc(exc_tuple,handler) | |
635 |
|
692 | |||
636 | Set a custom exception handler, which will be called if any of the |
|
693 | Set a custom exception handler, which will be called if any of the | |
637 | exceptions in exc_tuple occur in the mainloop (specifically, in the |
|
694 | exceptions in exc_tuple occur in the mainloop (specifically, in the | |
638 | runcode() method. |
|
695 | runcode() method. | |
639 |
|
696 | |||
640 | Inputs: |
|
697 | Inputs: | |
641 |
|
698 | |||
642 | - exc_tuple: a *tuple* of valid exceptions to call the defined |
|
699 | - exc_tuple: a *tuple* of valid exceptions to call the defined | |
643 | handler for. It is very important that you use a tuple, and NOT A |
|
700 | handler for. It is very important that you use a tuple, and NOT A | |
644 | LIST here, because of the way Python's except statement works. If |
|
701 | LIST here, because of the way Python's except statement works. If | |
645 | you only want to trap a single exception, use a singleton tuple: |
|
702 | you only want to trap a single exception, use a singleton tuple: | |
646 |
|
703 | |||
647 | exc_tuple == (MyCustomException,) |
|
704 | exc_tuple == (MyCustomException,) | |
648 |
|
705 | |||
649 | - handler: this must be defined as a function with the following |
|
706 | - handler: this must be defined as a function with the following | |
650 | basic interface: def my_handler(self,etype,value,tb). |
|
707 | basic interface: def my_handler(self,etype,value,tb). | |
651 |
|
708 | |||
652 | This will be made into an instance method (via new.instancemethod) |
|
709 | This will be made into an instance method (via new.instancemethod) | |
653 | of IPython itself, and it will be called if any of the exceptions |
|
710 | of IPython itself, and it will be called if any of the exceptions | |
654 | listed in the exc_tuple are caught. If the handler is None, an |
|
711 | listed in the exc_tuple are caught. If the handler is None, an | |
655 | internal basic one is used, which just prints basic info. |
|
712 | internal basic one is used, which just prints basic info. | |
656 |
|
713 | |||
657 | WARNING: by putting in your own exception handler into IPython's main |
|
714 | WARNING: by putting in your own exception handler into IPython's main | |
658 | execution loop, you run a very good chance of nasty crashes. This |
|
715 | execution loop, you run a very good chance of nasty crashes. This | |
659 | facility should only be used if you really know what you are doing.""" |
|
716 | facility should only be used if you really know what you are doing.""" | |
660 |
|
717 | |||
661 | assert type(exc_tuple)==type(()) , \ |
|
718 | assert type(exc_tuple)==type(()) , \ | |
662 | "The custom exceptions must be given AS A TUPLE." |
|
719 | "The custom exceptions must be given AS A TUPLE." | |
663 |
|
720 | |||
664 | def dummy_handler(self,etype,value,tb): |
|
721 | def dummy_handler(self,etype,value,tb): | |
665 | print '*** Simple custom exception handler ***' |
|
722 | print '*** Simple custom exception handler ***' | |
666 | print 'Exception type :',etype |
|
723 | print 'Exception type :',etype | |
667 | print 'Exception value:',value |
|
724 | print 'Exception value:',value | |
668 | print 'Traceback :',tb |
|
725 | print 'Traceback :',tb | |
669 | print 'Source code :','\n'.join(self.buffer) |
|
726 | print 'Source code :','\n'.join(self.buffer) | |
670 |
|
727 | |||
671 | if handler is None: handler = dummy_handler |
|
728 | if handler is None: handler = dummy_handler | |
672 |
|
729 | |||
673 | self.CustomTB = new.instancemethod(handler,self,self.__class__) |
|
730 | self.CustomTB = new.instancemethod(handler,self,self.__class__) | |
674 | self.custom_exceptions = exc_tuple |
|
731 | self.custom_exceptions = exc_tuple | |
675 |
|
732 | |||
676 | def set_custom_completer(self,completer,pos=0): |
|
733 | def set_custom_completer(self,completer,pos=0): | |
677 | """set_custom_completer(completer,pos=0) |
|
734 | """set_custom_completer(completer,pos=0) | |
678 |
|
735 | |||
679 | Adds a new custom completer function. |
|
736 | Adds a new custom completer function. | |
680 |
|
737 | |||
681 | The position argument (defaults to 0) is the index in the completers |
|
738 | The position argument (defaults to 0) is the index in the completers | |
682 | list where you want the completer to be inserted.""" |
|
739 | list where you want the completer to be inserted.""" | |
683 |
|
740 | |||
684 | newcomp = new.instancemethod(completer,self.Completer, |
|
741 | newcomp = new.instancemethod(completer,self.Completer, | |
685 | self.Completer.__class__) |
|
742 | self.Completer.__class__) | |
686 | self.Completer.matchers.insert(pos,newcomp) |
|
743 | self.Completer.matchers.insert(pos,newcomp) | |
687 |
|
744 | |||
688 | def complete(self,text): |
|
745 | def complete(self,text): | |
689 | """Return a sorted list of all possible completions on text. |
|
746 | """Return a sorted list of all possible completions on text. | |
690 |
|
747 | |||
691 | Inputs: |
|
748 | Inputs: | |
692 |
|
749 | |||
693 | - text: a string of text to be completed on. |
|
750 | - text: a string of text to be completed on. | |
694 |
|
751 | |||
695 | This is a wrapper around the completion mechanism, similar to what |
|
752 | This is a wrapper around the completion mechanism, similar to what | |
696 | readline does at the command line when the TAB key is hit. By |
|
753 | readline does at the command line when the TAB key is hit. By | |
697 | exposing it as a method, it can be used by other non-readline |
|
754 | exposing it as a method, it can be used by other non-readline | |
698 | environments (such as GUIs) for text completion. |
|
755 | environments (such as GUIs) for text completion. | |
699 |
|
756 | |||
700 | Simple usage example: |
|
757 | Simple usage example: | |
701 |
|
758 | |||
702 | In [1]: x = 'hello' |
|
759 | In [1]: x = 'hello' | |
703 |
|
760 | |||
704 | In [2]: __IP.complete('x.l') |
|
761 | In [2]: __IP.complete('x.l') | |
705 | Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']""" |
|
762 | Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']""" | |
706 |
|
763 | |||
707 | complete = self.Completer.complete |
|
764 | complete = self.Completer.complete | |
708 | state = 0 |
|
765 | state = 0 | |
709 | # use a dict so we get unique keys, since ipyhton's multiple |
|
766 | # use a dict so we get unique keys, since ipyhton's multiple | |
710 | # completers can return duplicates. |
|
767 | # completers can return duplicates. | |
711 | comps = {} |
|
768 | comps = {} | |
712 | while True: |
|
769 | while True: | |
713 | newcomp = complete(text,state) |
|
770 | newcomp = complete(text,state) | |
714 | if newcomp is None: |
|
771 | if newcomp is None: | |
715 | break |
|
772 | break | |
716 | comps[newcomp] = 1 |
|
773 | comps[newcomp] = 1 | |
717 | state += 1 |
|
774 | state += 1 | |
718 | outcomps = comps.keys() |
|
775 | outcomps = comps.keys() | |
719 | outcomps.sort() |
|
776 | outcomps.sort() | |
720 | return outcomps |
|
777 | return outcomps | |
721 |
|
778 | |||
722 | def set_completer_frame(self, frame): |
|
779 | def set_completer_frame(self, frame): | |
723 | if frame: |
|
780 | if frame: | |
724 | self.Completer.namespace = frame.f_locals |
|
781 | self.Completer.namespace = frame.f_locals | |
725 | self.Completer.global_namespace = frame.f_globals |
|
782 | self.Completer.global_namespace = frame.f_globals | |
726 | else: |
|
783 | else: | |
727 | self.Completer.namespace = self.user_ns |
|
784 | self.Completer.namespace = self.user_ns | |
728 | self.Completer.global_namespace = self.user_global_ns |
|
785 | self.Completer.global_namespace = self.user_global_ns | |
729 |
|
786 | |||
730 | def post_config_initialization(self): |
|
|||
731 | """Post configuration init method |
|
|||
732 |
|
||||
733 | This is called after the configuration files have been processed to |
|
|||
734 | 'finalize' the initialization.""" |
|
|||
735 |
|
||||
736 | rc = self.rc |
|
|||
737 |
|
||||
738 | # Load readline proper |
|
|||
739 | if rc.readline: |
|
|||
740 | self.init_readline() |
|
|||
741 |
|
||||
742 | # Set user colors (don't do it in the constructor above so that it |
|
|||
743 | # doesn't crash if colors option is invalid) |
|
|||
744 | self.magic_colors(rc.colors) |
|
|||
745 |
|
||||
746 | # Load user aliases |
|
|||
747 | for alias in rc.alias: |
|
|||
748 | self.magic_alias(alias) |
|
|||
749 |
|
||||
750 | # dynamic data that survives through sessions |
|
|||
751 | # XXX make the filename a config option? |
|
|||
752 | persist_base = 'persist' |
|
|||
753 | if rc.profile: |
|
|||
754 | persist_base += '_%s' % rc.profile |
|
|||
755 | self.persist_fname = os.path.join(rc.ipythondir,persist_base) |
|
|||
756 |
|
||||
757 | try: |
|
|||
758 | self.persist = pickle.load(file(self.persist_fname)) |
|
|||
759 | except: |
|
|||
760 | self.persist = {} |
|
|||
761 |
|
||||
762 | def init_auto_alias(self): |
|
787 | def init_auto_alias(self): | |
763 | """Define some aliases automatically. |
|
788 | """Define some aliases automatically. | |
764 |
|
789 | |||
765 | These are ALL parameter-less aliases""" |
|
790 | These are ALL parameter-less aliases""" | |
766 | for alias,cmd in self.auto_alias: |
|
791 | for alias,cmd in self.auto_alias: | |
767 | self.alias_table[alias] = (0,cmd) |
|
792 | self.alias_table[alias] = (0,cmd) | |
768 |
|
793 | |||
769 | def alias_table_validate(self,verbose=0): |
|
794 | def alias_table_validate(self,verbose=0): | |
770 | """Update information about the alias table. |
|
795 | """Update information about the alias table. | |
771 |
|
796 | |||
772 | In particular, make sure no Python keywords/builtins are in it.""" |
|
797 | In particular, make sure no Python keywords/builtins are in it.""" | |
773 |
|
798 | |||
774 | no_alias = self.no_alias |
|
799 | no_alias = self.no_alias | |
775 | for k in self.alias_table.keys(): |
|
800 | for k in self.alias_table.keys(): | |
776 | if k in no_alias: |
|
801 | if k in no_alias: | |
777 | del self.alias_table[k] |
|
802 | del self.alias_table[k] | |
778 | if verbose: |
|
803 | if verbose: | |
779 | print ("Deleting alias <%s>, it's a Python " |
|
804 | print ("Deleting alias <%s>, it's a Python " | |
780 | "keyword or builtin." % k) |
|
805 | "keyword or builtin." % k) | |
781 |
|
806 | |||
782 | def set_autoindent(self,value=None): |
|
807 | def set_autoindent(self,value=None): | |
783 | """Set the autoindent flag, checking for readline support. |
|
808 | """Set the autoindent flag, checking for readline support. | |
784 |
|
809 | |||
785 | If called with no arguments, it acts as a toggle.""" |
|
810 | If called with no arguments, it acts as a toggle.""" | |
786 |
|
811 | |||
787 | if not self.has_readline: |
|
812 | if not self.has_readline: | |
788 | if os.name == 'posix': |
|
813 | if os.name == 'posix': | |
789 | warn("The auto-indent feature requires the readline library") |
|
814 | warn("The auto-indent feature requires the readline library") | |
790 | self.autoindent = 0 |
|
815 | self.autoindent = 0 | |
791 | return |
|
816 | return | |
792 | if value is None: |
|
817 | if value is None: | |
793 | self.autoindent = not self.autoindent |
|
818 | self.autoindent = not self.autoindent | |
794 | else: |
|
819 | else: | |
795 | self.autoindent = value |
|
820 | self.autoindent = value | |
796 |
|
821 | |||
797 | def rc_set_toggle(self,rc_field,value=None): |
|
822 | def rc_set_toggle(self,rc_field,value=None): | |
798 | """Set or toggle a field in IPython's rc config. structure. |
|
823 | """Set or toggle a field in IPython's rc config. structure. | |
799 |
|
824 | |||
800 | If called with no arguments, it acts as a toggle. |
|
825 | If called with no arguments, it acts as a toggle. | |
801 |
|
826 | |||
802 | If called with a non-existent field, the resulting AttributeError |
|
827 | If called with a non-existent field, the resulting AttributeError | |
803 | exception will propagate out.""" |
|
828 | exception will propagate out.""" | |
804 |
|
829 | |||
805 | rc_val = getattr(self.rc,rc_field) |
|
830 | rc_val = getattr(self.rc,rc_field) | |
806 | if value is None: |
|
831 | if value is None: | |
807 | value = not rc_val |
|
832 | value = not rc_val | |
808 | setattr(self.rc,rc_field,value) |
|
833 | setattr(self.rc,rc_field,value) | |
809 |
|
834 | |||
810 | def user_setup(self,ipythondir,rc_suffix,mode='install'): |
|
835 | def user_setup(self,ipythondir,rc_suffix,mode='install'): | |
811 | """Install the user configuration directory. |
|
836 | """Install the user configuration directory. | |
812 |
|
837 | |||
813 | Can be called when running for the first time or to upgrade the user's |
|
838 | Can be called when running for the first time or to upgrade the user's | |
814 | .ipython/ directory with the mode parameter. Valid modes are 'install' |
|
839 | .ipython/ directory with the mode parameter. Valid modes are 'install' | |
815 | and 'upgrade'.""" |
|
840 | and 'upgrade'.""" | |
816 |
|
841 | |||
817 | def wait(): |
|
842 | def wait(): | |
818 | try: |
|
843 | try: | |
819 | raw_input("Please press <RETURN> to start IPython.") |
|
844 | raw_input("Please press <RETURN> to start IPython.") | |
820 | except EOFError: |
|
845 | except EOFError: | |
821 | print >> Term.cout |
|
846 | print >> Term.cout | |
822 | print '*'*70 |
|
847 | print '*'*70 | |
823 |
|
848 | |||
824 | cwd = os.getcwd() # remember where we started |
|
849 | cwd = os.getcwd() # remember where we started | |
825 | glb = glob.glob |
|
850 | glb = glob.glob | |
826 | print '*'*70 |
|
851 | print '*'*70 | |
827 | if mode == 'install': |
|
852 | if mode == 'install': | |
828 | print \ |
|
853 | print \ | |
829 | """Welcome to IPython. I will try to create a personal configuration directory |
|
854 | """Welcome to IPython. I will try to create a personal configuration directory | |
830 | where you can customize many aspects of IPython's functionality in:\n""" |
|
855 | where you can customize many aspects of IPython's functionality in:\n""" | |
831 | else: |
|
856 | else: | |
832 | print 'I am going to upgrade your configuration in:' |
|
857 | print 'I am going to upgrade your configuration in:' | |
833 |
|
858 | |||
834 | print ipythondir |
|
859 | print ipythondir | |
835 |
|
860 | |||
836 | rcdirend = os.path.join('IPython','UserConfig') |
|
861 | rcdirend = os.path.join('IPython','UserConfig') | |
837 | cfg = lambda d: os.path.join(d,rcdirend) |
|
862 | cfg = lambda d: os.path.join(d,rcdirend) | |
838 | try: |
|
863 | try: | |
839 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] |
|
864 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] | |
840 | except IOError: |
|
865 | except IOError: | |
841 | warning = """ |
|
866 | warning = """ | |
842 | Installation error. IPython's directory was not found. |
|
867 | Installation error. IPython's directory was not found. | |
843 |
|
868 | |||
844 | Check the following: |
|
869 | Check the following: | |
845 |
|
870 | |||
846 | The ipython/IPython directory should be in a directory belonging to your |
|
871 | The ipython/IPython directory should be in a directory belonging to your | |
847 | PYTHONPATH environment variable (that is, it should be in a directory |
|
872 | PYTHONPATH environment variable (that is, it should be in a directory | |
848 | belonging to sys.path). You can copy it explicitly there or just link to it. |
|
873 | belonging to sys.path). You can copy it explicitly there or just link to it. | |
849 |
|
874 | |||
850 | IPython will proceed with builtin defaults. |
|
875 | IPython will proceed with builtin defaults. | |
851 | """ |
|
876 | """ | |
852 | warn(warning) |
|
877 | warn(warning) | |
853 | wait() |
|
878 | wait() | |
854 | return |
|
879 | return | |
855 |
|
880 | |||
856 | if mode == 'install': |
|
881 | if mode == 'install': | |
857 | try: |
|
882 | try: | |
858 | shutil.copytree(rcdir,ipythondir) |
|
883 | shutil.copytree(rcdir,ipythondir) | |
859 | os.chdir(ipythondir) |
|
884 | os.chdir(ipythondir) | |
860 | rc_files = glb("ipythonrc*") |
|
885 | rc_files = glb("ipythonrc*") | |
861 | for rc_file in rc_files: |
|
886 | for rc_file in rc_files: | |
862 | os.rename(rc_file,rc_file+rc_suffix) |
|
887 | os.rename(rc_file,rc_file+rc_suffix) | |
863 | except: |
|
888 | except: | |
864 | warning = """ |
|
889 | warning = """ | |
865 |
|
890 | |||
866 | There was a problem with the installation: |
|
891 | There was a problem with the installation: | |
867 | %s |
|
892 | %s | |
868 | Try to correct it or contact the developers if you think it's a bug. |
|
893 | Try to correct it or contact the developers if you think it's a bug. | |
869 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] |
|
894 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] | |
870 | warn(warning) |
|
895 | warn(warning) | |
871 | wait() |
|
896 | wait() | |
872 | return |
|
897 | return | |
873 |
|
898 | |||
874 | elif mode == 'upgrade': |
|
899 | elif mode == 'upgrade': | |
875 | try: |
|
900 | try: | |
876 | os.chdir(ipythondir) |
|
901 | os.chdir(ipythondir) | |
877 | except: |
|
902 | except: | |
878 | print """ |
|
903 | print """ | |
879 | Can not upgrade: changing to directory %s failed. Details: |
|
904 | Can not upgrade: changing to directory %s failed. Details: | |
880 | %s |
|
905 | %s | |
881 | """ % (ipythondir,sys.exc_info()[1]) |
|
906 | """ % (ipythondir,sys.exc_info()[1]) | |
882 | wait() |
|
907 | wait() | |
883 | return |
|
908 | return | |
884 | else: |
|
909 | else: | |
885 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) |
|
910 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) | |
886 | for new_full_path in sources: |
|
911 | for new_full_path in sources: | |
887 | new_filename = os.path.basename(new_full_path) |
|
912 | new_filename = os.path.basename(new_full_path) | |
888 | if new_filename.startswith('ipythonrc'): |
|
913 | if new_filename.startswith('ipythonrc'): | |
889 | new_filename = new_filename + rc_suffix |
|
914 | new_filename = new_filename + rc_suffix | |
890 | # The config directory should only contain files, skip any |
|
915 | # The config directory should only contain files, skip any | |
891 | # directories which may be there (like CVS) |
|
916 | # directories which may be there (like CVS) | |
892 | if os.path.isdir(new_full_path): |
|
917 | if os.path.isdir(new_full_path): | |
893 | continue |
|
918 | continue | |
894 | if os.path.exists(new_filename): |
|
919 | if os.path.exists(new_filename): | |
895 | old_file = new_filename+'.old' |
|
920 | old_file = new_filename+'.old' | |
896 | if os.path.exists(old_file): |
|
921 | if os.path.exists(old_file): | |
897 | os.remove(old_file) |
|
922 | os.remove(old_file) | |
898 | os.rename(new_filename,old_file) |
|
923 | os.rename(new_filename,old_file) | |
899 | shutil.copy(new_full_path,new_filename) |
|
924 | shutil.copy(new_full_path,new_filename) | |
900 | else: |
|
925 | else: | |
901 | raise ValueError,'unrecognized mode for install:',`mode` |
|
926 | raise ValueError,'unrecognized mode for install:',`mode` | |
902 |
|
927 | |||
903 | # Fix line-endings to those native to each platform in the config |
|
928 | # Fix line-endings to those native to each platform in the config | |
904 | # directory. |
|
929 | # directory. | |
905 | try: |
|
930 | try: | |
906 | os.chdir(ipythondir) |
|
931 | os.chdir(ipythondir) | |
907 | except: |
|
932 | except: | |
908 | print """ |
|
933 | print """ | |
909 | Problem: changing to directory %s failed. |
|
934 | Problem: changing to directory %s failed. | |
910 | Details: |
|
935 | Details: | |
911 | %s |
|
936 | %s | |
912 |
|
937 | |||
913 | Some configuration files may have incorrect line endings. This should not |
|
938 | Some configuration files may have incorrect line endings. This should not | |
914 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) |
|
939 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) | |
915 | wait() |
|
940 | wait() | |
916 | else: |
|
941 | else: | |
917 | for fname in glb('ipythonrc*'): |
|
942 | for fname in glb('ipythonrc*'): | |
918 | try: |
|
943 | try: | |
919 | native_line_ends(fname,backup=0) |
|
944 | native_line_ends(fname,backup=0) | |
920 | except IOError: |
|
945 | except IOError: | |
921 | pass |
|
946 | pass | |
922 |
|
947 | |||
923 | if mode == 'install': |
|
948 | if mode == 'install': | |
924 | print """ |
|
949 | print """ | |
925 | Successful installation! |
|
950 | Successful installation! | |
926 |
|
951 | |||
927 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the |
|
952 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the | |
928 | IPython manual (there are both HTML and PDF versions supplied with the |
|
953 | IPython manual (there are both HTML and PDF versions supplied with the | |
929 | distribution) to make sure that your system environment is properly configured |
|
954 | distribution) to make sure that your system environment is properly configured | |
930 | to take advantage of IPython's features.""" |
|
955 | to take advantage of IPython's features.""" | |
931 | else: |
|
956 | else: | |
932 | print """ |
|
957 | print """ | |
933 | Successful upgrade! |
|
958 | Successful upgrade! | |
934 |
|
959 | |||
935 | All files in your directory: |
|
960 | All files in your directory: | |
936 | %(ipythondir)s |
|
961 | %(ipythondir)s | |
937 | which would have been overwritten by the upgrade were backed up with a .old |
|
962 | which would have been overwritten by the upgrade were backed up with a .old | |
938 | extension. If you had made particular customizations in those files you may |
|
963 | extension. If you had made particular customizations in those files you may | |
939 | want to merge them back into the new files.""" % locals() |
|
964 | want to merge them back into the new files.""" % locals() | |
940 | wait() |
|
965 | wait() | |
941 | os.chdir(cwd) |
|
966 | os.chdir(cwd) | |
942 | # end user_setup() |
|
967 | # end user_setup() | |
943 |
|
968 | |||
944 | def atexit_operations(self): |
|
969 | def atexit_operations(self): | |
945 | """This will be executed at the time of exit. |
|
970 | """This will be executed at the time of exit. | |
946 |
|
971 | |||
947 | Saving of persistent data should be performed here. """ |
|
972 | Saving of persistent data should be performed here. """ | |
948 |
|
973 | |||
949 | # input history |
|
974 | # input history | |
950 | self.savehist() |
|
975 | self.savehist() | |
951 |
|
976 | |||
952 | # Cleanup all tempfiles left around |
|
977 | # Cleanup all tempfiles left around | |
953 | for tfile in self.tempfiles: |
|
978 | for tfile in self.tempfiles: | |
954 | try: |
|
979 | try: | |
955 | os.unlink(tfile) |
|
980 | os.unlink(tfile) | |
956 | except OSError: |
|
981 | except OSError: | |
957 | pass |
|
982 | pass | |
958 |
|
983 | |||
959 | # save the "persistent data" catch-all dictionary |
|
984 | # save the "persistent data" catch-all dictionary | |
960 | try: |
|
985 | try: | |
961 | pickle.dump(self.persist, open(self.persist_fname,"w")) |
|
986 | pickle.dump(self.persist, open(self.persist_fname,"w")) | |
962 | except: |
|
987 | except: | |
963 | print "*** ERROR *** persistent data saving failed." |
|
988 | print "*** ERROR *** persistent data saving failed." | |
964 |
|
989 | |||
965 | def savehist(self): |
|
990 | def savehist(self): | |
966 | """Save input history to a file (via readline library).""" |
|
991 | """Save input history to a file (via readline library).""" | |
967 | try: |
|
992 | try: | |
968 | self.readline.write_history_file(self.histfile) |
|
993 | self.readline.write_history_file(self.histfile) | |
969 | except: |
|
994 | except: | |
970 | print 'Unable to save IPython command history to file: ' + \ |
|
995 | print 'Unable to save IPython command history to file: ' + \ | |
971 | `self.histfile` |
|
996 | `self.histfile` | |
972 |
|
997 | |||
973 | def pre_readline(self): |
|
998 | def pre_readline(self): | |
974 | """readline hook to be used at the start of each line. |
|
999 | """readline hook to be used at the start of each line. | |
975 |
|
1000 | |||
976 | Currently it handles auto-indent only.""" |
|
1001 | Currently it handles auto-indent only.""" | |
977 |
|
1002 | |||
978 | self.readline.insert_text(self.indent_current) |
|
1003 | self.readline.insert_text(self.indent_current) | |
979 |
|
1004 | |||
980 | def init_readline(self): |
|
1005 | def init_readline(self): | |
981 | """Command history completion/saving/reloading.""" |
|
1006 | """Command history completion/saving/reloading.""" | |
982 | try: |
|
1007 | try: | |
983 | import readline |
|
1008 | import readline | |
984 | except ImportError: |
|
1009 | except ImportError: | |
985 | self.has_readline = 0 |
|
1010 | self.has_readline = 0 | |
986 | self.readline = None |
|
1011 | self.readline = None | |
987 | # no point in bugging windows users with this every time: |
|
1012 | # no point in bugging windows users with this every time: | |
988 | if os.name == 'posix': |
|
1013 | if os.name == 'posix': | |
989 | warn('Readline services not available on this platform.') |
|
1014 | warn('Readline services not available on this platform.') | |
990 | else: |
|
1015 | else: | |
991 | import atexit |
|
1016 | import atexit | |
992 | from IPython.completer import IPCompleter |
|
1017 | from IPython.completer import IPCompleter | |
993 | self.Completer = IPCompleter(self, |
|
1018 | self.Completer = IPCompleter(self, | |
994 | self.user_ns, |
|
1019 | self.user_ns, | |
995 | self.user_global_ns, |
|
1020 | self.user_global_ns, | |
996 | self.rc.readline_omit__names, |
|
1021 | self.rc.readline_omit__names, | |
997 | self.alias_table) |
|
1022 | self.alias_table) | |
998 |
|
1023 | |||
999 | # Platform-specific configuration |
|
1024 | # Platform-specific configuration | |
1000 | if os.name == 'nt': |
|
1025 | if os.name == 'nt': | |
1001 | self.readline_startup_hook = readline.set_pre_input_hook |
|
1026 | self.readline_startup_hook = readline.set_pre_input_hook | |
1002 | else: |
|
1027 | else: | |
1003 | self.readline_startup_hook = readline.set_startup_hook |
|
1028 | self.readline_startup_hook = readline.set_startup_hook | |
1004 |
|
1029 | |||
1005 | # Load user's initrc file (readline config) |
|
1030 | # Load user's initrc file (readline config) | |
1006 | inputrc_name = os.environ.get('INPUTRC') |
|
1031 | inputrc_name = os.environ.get('INPUTRC') | |
1007 | if inputrc_name is None: |
|
1032 | if inputrc_name is None: | |
1008 | home_dir = get_home_dir() |
|
1033 | home_dir = get_home_dir() | |
1009 | if home_dir is not None: |
|
1034 | if home_dir is not None: | |
1010 | inputrc_name = os.path.join(home_dir,'.inputrc') |
|
1035 | inputrc_name = os.path.join(home_dir,'.inputrc') | |
1011 | if os.path.isfile(inputrc_name): |
|
1036 | if os.path.isfile(inputrc_name): | |
1012 | try: |
|
1037 | try: | |
1013 | readline.read_init_file(inputrc_name) |
|
1038 | readline.read_init_file(inputrc_name) | |
1014 | except: |
|
1039 | except: | |
1015 | warn('Problems reading readline initialization file <%s>' |
|
1040 | warn('Problems reading readline initialization file <%s>' | |
1016 | % inputrc_name) |
|
1041 | % inputrc_name) | |
1017 |
|
1042 | |||
1018 | self.has_readline = 1 |
|
1043 | self.has_readline = 1 | |
1019 | self.readline = readline |
|
1044 | self.readline = readline | |
1020 | # save this in sys so embedded copies can restore it properly |
|
1045 | # save this in sys so embedded copies can restore it properly | |
1021 | sys.ipcompleter = self.Completer.complete |
|
1046 | sys.ipcompleter = self.Completer.complete | |
1022 | readline.set_completer(self.Completer.complete) |
|
1047 | readline.set_completer(self.Completer.complete) | |
1023 |
|
1048 | |||
1024 | # Configure readline according to user's prefs |
|
1049 | # Configure readline according to user's prefs | |
1025 | for rlcommand in self.rc.readline_parse_and_bind: |
|
1050 | for rlcommand in self.rc.readline_parse_and_bind: | |
1026 | readline.parse_and_bind(rlcommand) |
|
1051 | readline.parse_and_bind(rlcommand) | |
1027 |
|
1052 | |||
1028 | # remove some chars from the delimiters list |
|
1053 | # remove some chars from the delimiters list | |
1029 | delims = readline.get_completer_delims() |
|
1054 | delims = readline.get_completer_delims() | |
1030 | delims = delims.translate(string._idmap, |
|
1055 | delims = delims.translate(string._idmap, | |
1031 | self.rc.readline_remove_delims) |
|
1056 | self.rc.readline_remove_delims) | |
1032 | readline.set_completer_delims(delims) |
|
1057 | readline.set_completer_delims(delims) | |
1033 | # otherwise we end up with a monster history after a while: |
|
1058 | # otherwise we end up with a monster history after a while: | |
1034 | readline.set_history_length(1000) |
|
1059 | readline.set_history_length(1000) | |
1035 | try: |
|
1060 | try: | |
1036 | #print '*** Reading readline history' # dbg |
|
1061 | #print '*** Reading readline history' # dbg | |
1037 | readline.read_history_file(self.histfile) |
|
1062 | readline.read_history_file(self.histfile) | |
1038 | except IOError: |
|
1063 | except IOError: | |
1039 | pass # It doesn't exist yet. |
|
1064 | pass # It doesn't exist yet. | |
1040 |
|
1065 | |||
1041 | atexit.register(self.atexit_operations) |
|
1066 | atexit.register(self.atexit_operations) | |
1042 | del atexit |
|
1067 | del atexit | |
1043 |
|
1068 | |||
1044 | # Configure auto-indent for all platforms |
|
1069 | # Configure auto-indent for all platforms | |
1045 | self.set_autoindent(self.rc.autoindent) |
|
1070 | self.set_autoindent(self.rc.autoindent) | |
1046 |
|
1071 | |||
1047 | def _should_recompile(self,e): |
|
1072 | def _should_recompile(self,e): | |
1048 | """Utility routine for edit_syntax_error""" |
|
1073 | """Utility routine for edit_syntax_error""" | |
1049 |
|
1074 | |||
1050 | if e.filename in ('<ipython console>','<input>','<string>', |
|
1075 | if e.filename in ('<ipython console>','<input>','<string>', | |
1051 | '<console>'): |
|
1076 | '<console>'): | |
1052 | return False |
|
1077 | return False | |
1053 | try: |
|
1078 | try: | |
1054 | if not ask_yes_no('Return to editor to correct syntax error? ' |
|
1079 | if not ask_yes_no('Return to editor to correct syntax error? ' | |
1055 | '[Y/n] ','y'): |
|
1080 | '[Y/n] ','y'): | |
1056 | return False |
|
1081 | return False | |
1057 | except EOFError: |
|
1082 | except EOFError: | |
1058 | return False |
|
1083 | return False | |
1059 | self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg) |
|
1084 | self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg) | |
1060 | return True |
|
1085 | return True | |
1061 |
|
1086 | |||
1062 | def edit_syntax_error(self): |
|
1087 | def edit_syntax_error(self): | |
1063 | """The bottom half of the syntax error handler called in the main loop. |
|
1088 | """The bottom half of the syntax error handler called in the main loop. | |
1064 |
|
1089 | |||
1065 | Loop until syntax error is fixed or user cancels. |
|
1090 | Loop until syntax error is fixed or user cancels. | |
1066 | """ |
|
1091 | """ | |
1067 |
|
1092 | |||
1068 | while self.SyntaxTB.last_syntax_error: |
|
1093 | while self.SyntaxTB.last_syntax_error: | |
1069 | # copy and clear last_syntax_error |
|
1094 | # copy and clear last_syntax_error | |
1070 | err = self.SyntaxTB.clear_err_state() |
|
1095 | err = self.SyntaxTB.clear_err_state() | |
1071 | if not self._should_recompile(err): |
|
1096 | if not self._should_recompile(err): | |
1072 | return |
|
1097 | return | |
1073 | try: |
|
1098 | try: | |
1074 | # may set last_syntax_error again if a SyntaxError is raised |
|
1099 | # may set last_syntax_error again if a SyntaxError is raised | |
1075 | self.safe_execfile(err.filename,self.shell.user_ns) |
|
1100 | self.safe_execfile(err.filename,self.shell.user_ns) | |
1076 | except: |
|
1101 | except: | |
1077 | self.showtraceback() |
|
1102 | self.showtraceback() | |
1078 | else: |
|
1103 | else: | |
1079 | f = file(err.filename) |
|
1104 | f = file(err.filename) | |
1080 | try: |
|
1105 | try: | |
1081 | sys.displayhook(f.read()) |
|
1106 | sys.displayhook(f.read()) | |
1082 | finally: |
|
1107 | finally: | |
1083 | f.close() |
|
1108 | f.close() | |
1084 |
|
1109 | |||
1085 | def showsyntaxerror(self, filename=None): |
|
1110 | def showsyntaxerror(self, filename=None): | |
1086 | """Display the syntax error that just occurred. |
|
1111 | """Display the syntax error that just occurred. | |
1087 |
|
1112 | |||
1088 | This doesn't display a stack trace because there isn't one. |
|
1113 | This doesn't display a stack trace because there isn't one. | |
1089 |
|
1114 | |||
1090 | If a filename is given, it is stuffed in the exception instead |
|
1115 | If a filename is given, it is stuffed in the exception instead | |
1091 | of what was there before (because Python's parser always uses |
|
1116 | of what was there before (because Python's parser always uses | |
1092 | "<string>" when reading from a string). |
|
1117 | "<string>" when reading from a string). | |
1093 | """ |
|
1118 | """ | |
1094 | type, value, sys.last_traceback = sys.exc_info() |
|
1119 | type, value, sys.last_traceback = sys.exc_info() | |
1095 | sys.last_type = type |
|
1120 | sys.last_type = type | |
1096 | sys.last_value = value |
|
1121 | sys.last_value = value | |
1097 | if filename and type is SyntaxError: |
|
1122 | if filename and type is SyntaxError: | |
1098 | # Work hard to stuff the correct filename in the exception |
|
1123 | # Work hard to stuff the correct filename in the exception | |
1099 | try: |
|
1124 | try: | |
1100 | msg, (dummy_filename, lineno, offset, line) = value |
|
1125 | msg, (dummy_filename, lineno, offset, line) = value | |
1101 | except: |
|
1126 | except: | |
1102 | # Not the format we expect; leave it alone |
|
1127 | # Not the format we expect; leave it alone | |
1103 | pass |
|
1128 | pass | |
1104 | else: |
|
1129 | else: | |
1105 | # Stuff in the right filename |
|
1130 | # Stuff in the right filename | |
1106 | try: |
|
1131 | try: | |
1107 | # Assume SyntaxError is a class exception |
|
1132 | # Assume SyntaxError is a class exception | |
1108 | value = SyntaxError(msg, (filename, lineno, offset, line)) |
|
1133 | value = SyntaxError(msg, (filename, lineno, offset, line)) | |
1109 | except: |
|
1134 | except: | |
1110 | # If that failed, assume SyntaxError is a string |
|
1135 | # If that failed, assume SyntaxError is a string | |
1111 | value = msg, (filename, lineno, offset, line) |
|
1136 | value = msg, (filename, lineno, offset, line) | |
1112 | self.SyntaxTB(type,value,[]) |
|
1137 | self.SyntaxTB(type,value,[]) | |
1113 |
|
1138 | |||
1114 | def debugger(self): |
|
1139 | def debugger(self): | |
1115 | """Call the pdb debugger.""" |
|
1140 | """Call the pdb debugger.""" | |
1116 |
|
1141 | |||
1117 | if not self.rc.pdb: |
|
1142 | if not self.rc.pdb: | |
1118 | return |
|
1143 | return | |
1119 | pdb.pm() |
|
1144 | pdb.pm() | |
1120 |
|
1145 | |||
1121 | def showtraceback(self,exc_tuple = None,filename=None): |
|
1146 | def showtraceback(self,exc_tuple = None,filename=None): | |
1122 | """Display the exception that just occurred.""" |
|
1147 | """Display the exception that just occurred.""" | |
1123 |
|
1148 | |||
1124 | # Though this won't be called by syntax errors in the input line, |
|
1149 | # Though this won't be called by syntax errors in the input line, | |
1125 | # there may be SyntaxError cases whith imported code. |
|
1150 | # there may be SyntaxError cases whith imported code. | |
1126 | if exc_tuple is None: |
|
1151 | if exc_tuple is None: | |
1127 | type, value, tb = sys.exc_info() |
|
1152 | type, value, tb = sys.exc_info() | |
1128 | else: |
|
1153 | else: | |
1129 | type, value, tb = exc_tuple |
|
1154 | type, value, tb = exc_tuple | |
1130 | if type is SyntaxError: |
|
1155 | if type is SyntaxError: | |
1131 | self.showsyntaxerror(filename) |
|
1156 | self.showsyntaxerror(filename) | |
1132 | else: |
|
1157 | else: | |
1133 | sys.last_type = type |
|
1158 | sys.last_type = type | |
1134 | sys.last_value = value |
|
1159 | sys.last_value = value | |
1135 | sys.last_traceback = tb |
|
1160 | sys.last_traceback = tb | |
1136 | self.InteractiveTB() |
|
1161 | self.InteractiveTB() | |
1137 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1162 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1138 | # pdb mucks up readline, fix it back |
|
1163 | # pdb mucks up readline, fix it back | |
1139 | self.readline.set_completer(self.Completer.complete) |
|
1164 | self.readline.set_completer(self.Completer.complete) | |
1140 |
|
1165 | |||
1141 | def update_cache(self, line): |
|
1166 | def update_cache(self, line): | |
1142 | """puts line into cache""" |
|
1167 | """puts line into cache""" | |
1143 | self.inputcache.insert(0, line) # This copies the cache every time ... :-( |
|
1168 | self.inputcache.insert(0, line) # This copies the cache every time ... :-( | |
1144 | if len(self.inputcache) >= self.CACHELENGTH: |
|
1169 | if len(self.inputcache) >= self.CACHELENGTH: | |
1145 | self.inputcache.pop() # This doesn't :-) |
|
1170 | self.inputcache.pop() # This doesn't :-) | |
1146 |
|
1171 | |||
1147 | def mainloop(self,banner=None): |
|
1172 | def mainloop(self,banner=None): | |
1148 | """Creates the local namespace and starts the mainloop. |
|
1173 | """Creates the local namespace and starts the mainloop. | |
1149 |
|
1174 | |||
1150 | If an optional banner argument is given, it will override the |
|
1175 | If an optional banner argument is given, it will override the | |
1151 | internally created default banner.""" |
|
1176 | internally created default banner.""" | |
1152 |
|
1177 | |||
1153 | if self.rc.c: # Emulate Python's -c option |
|
1178 | if self.rc.c: # Emulate Python's -c option | |
1154 | self.exec_init_cmd() |
|
1179 | self.exec_init_cmd() | |
1155 | if banner is None: |
|
1180 | if banner is None: | |
1156 | if self.rc.banner: |
|
1181 | if self.rc.banner: | |
1157 | banner = self.BANNER+self.banner2 |
|
1182 | banner = self.BANNER+self.banner2 | |
1158 | else: |
|
1183 | else: | |
1159 | banner = '' |
|
1184 | banner = '' | |
1160 | self.interact(banner) |
|
1185 | self.interact(banner) | |
1161 |
|
1186 | |||
1162 | def exec_init_cmd(self): |
|
1187 | def exec_init_cmd(self): | |
1163 | """Execute a command given at the command line. |
|
1188 | """Execute a command given at the command line. | |
1164 |
|
1189 | |||
1165 | This emulates Python's -c option.""" |
|
1190 | This emulates Python's -c option.""" | |
1166 |
|
1191 | |||
1167 | sys.argv = ['-c'] |
|
1192 | sys.argv = ['-c'] | |
1168 | self.push(self.rc.c) |
|
1193 | self.push(self.rc.c) | |
1169 |
|
1194 | |||
1170 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): |
|
1195 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): | |
1171 | """Embeds IPython into a running python program. |
|
1196 | """Embeds IPython into a running python program. | |
1172 |
|
1197 | |||
1173 | Input: |
|
1198 | Input: | |
1174 |
|
1199 | |||
1175 | - header: An optional header message can be specified. |
|
1200 | - header: An optional header message can be specified. | |
1176 |
|
1201 | |||
1177 | - local_ns, global_ns: working namespaces. If given as None, the |
|
1202 | - local_ns, global_ns: working namespaces. If given as None, the | |
1178 | IPython-initialized one is updated with __main__.__dict__, so that |
|
1203 | IPython-initialized one is updated with __main__.__dict__, so that | |
1179 | program variables become visible but user-specific configuration |
|
1204 | program variables become visible but user-specific configuration | |
1180 | remains possible. |
|
1205 | remains possible. | |
1181 |
|
1206 | |||
1182 | - stack_depth: specifies how many levels in the stack to go to |
|
1207 | - stack_depth: specifies how many levels in the stack to go to | |
1183 | looking for namespaces (when local_ns and global_ns are None). This |
|
1208 | looking for namespaces (when local_ns and global_ns are None). This | |
1184 | allows an intermediate caller to make sure that this function gets |
|
1209 | allows an intermediate caller to make sure that this function gets | |
1185 | the namespace from the intended level in the stack. By default (0) |
|
1210 | the namespace from the intended level in the stack. By default (0) | |
1186 | it will get its locals and globals from the immediate caller. |
|
1211 | it will get its locals and globals from the immediate caller. | |
1187 |
|
1212 | |||
1188 | Warning: it's possible to use this in a program which is being run by |
|
1213 | Warning: it's possible to use this in a program which is being run by | |
1189 | IPython itself (via %run), but some funny things will happen (a few |
|
1214 | IPython itself (via %run), but some funny things will happen (a few | |
1190 | globals get overwritten). In the future this will be cleaned up, as |
|
1215 | globals get overwritten). In the future this will be cleaned up, as | |
1191 | there is no fundamental reason why it can't work perfectly.""" |
|
1216 | there is no fundamental reason why it can't work perfectly.""" | |
1192 |
|
1217 | |||
1193 | # Get locals and globals from caller |
|
1218 | # Get locals and globals from caller | |
1194 | if local_ns is None or global_ns is None: |
|
1219 | if local_ns is None or global_ns is None: | |
1195 | call_frame = sys._getframe(stack_depth).f_back |
|
1220 | call_frame = sys._getframe(stack_depth).f_back | |
1196 |
|
1221 | |||
1197 | if local_ns is None: |
|
1222 | if local_ns is None: | |
1198 | local_ns = call_frame.f_locals |
|
1223 | local_ns = call_frame.f_locals | |
1199 | if global_ns is None: |
|
1224 | if global_ns is None: | |
1200 | global_ns = call_frame.f_globals |
|
1225 | global_ns = call_frame.f_globals | |
1201 |
|
1226 | |||
1202 | # Update namespaces and fire up interpreter |
|
1227 | # Update namespaces and fire up interpreter | |
1203 | self.user_ns = local_ns |
|
1228 | self.user_ns = local_ns | |
1204 | self.user_global_ns = global_ns |
|
1229 | self.user_global_ns = global_ns | |
1205 |
|
1230 | |||
1206 | # Patch for global embedding to make sure that things don't overwrite |
|
1231 | # Patch for global embedding to make sure that things don't overwrite | |
1207 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> |
|
1232 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> | |
1208 | # FIXME. Test this a bit more carefully (the if.. is new) |
|
1233 | # FIXME. Test this a bit more carefully (the if.. is new) | |
1209 | if local_ns is None and global_ns is None: |
|
1234 | if local_ns is None and global_ns is None: | |
1210 | self.user_global_ns.update(__main__.__dict__) |
|
1235 | self.user_global_ns.update(__main__.__dict__) | |
1211 |
|
1236 | |||
1212 | # make sure the tab-completer has the correct frame information, so it |
|
1237 | # make sure the tab-completer has the correct frame information, so it | |
1213 | # actually completes using the frame's locals/globals |
|
1238 | # actually completes using the frame's locals/globals | |
1214 | self.set_completer_frame(call_frame) |
|
1239 | self.set_completer_frame(call_frame) | |
1215 |
|
1240 | |||
1216 | self.interact(header) |
|
1241 | self.interact(header) | |
1217 |
|
1242 | |||
1218 | def interact(self, banner=None): |
|
1243 | def interact(self, banner=None): | |
1219 | """Closely emulate the interactive Python console. |
|
1244 | """Closely emulate the interactive Python console. | |
1220 |
|
1245 | |||
1221 | The optional banner argument specify the banner to print |
|
1246 | The optional banner argument specify the banner to print | |
1222 | before the first interaction; by default it prints a banner |
|
1247 | before the first interaction; by default it prints a banner | |
1223 | similar to the one printed by the real Python interpreter, |
|
1248 | similar to the one printed by the real Python interpreter, | |
1224 | followed by the current class name in parentheses (so as not |
|
1249 | followed by the current class name in parentheses (so as not | |
1225 | to confuse this with the real interpreter -- since it's so |
|
1250 | to confuse this with the real interpreter -- since it's so | |
1226 | close!). |
|
1251 | close!). | |
1227 |
|
1252 | |||
1228 | """ |
|
1253 | """ | |
1229 | cprt = 'Type "copyright", "credits" or "license" for more information.' |
|
1254 | cprt = 'Type "copyright", "credits" or "license" for more information.' | |
1230 | if banner is None: |
|
1255 | if banner is None: | |
1231 | self.write("Python %s on %s\n%s\n(%s)\n" % |
|
1256 | self.write("Python %s on %s\n%s\n(%s)\n" % | |
1232 | (sys.version, sys.platform, cprt, |
|
1257 | (sys.version, sys.platform, cprt, | |
1233 | self.__class__.__name__)) |
|
1258 | self.__class__.__name__)) | |
1234 | else: |
|
1259 | else: | |
1235 | self.write(banner) |
|
1260 | self.write(banner) | |
1236 |
|
1261 | |||
1237 | more = 0 |
|
1262 | more = 0 | |
1238 |
|
1263 | |||
1239 | # Mark activity in the builtins |
|
1264 | # Mark activity in the builtins | |
1240 | __builtin__.__dict__['__IPYTHON__active'] += 1 |
|
1265 | __builtin__.__dict__['__IPYTHON__active'] += 1 | |
1241 |
|
1266 | |||
1242 | # compiled regexps for autoindent management |
|
1267 | # compiled regexps for autoindent management | |
1243 | ini_spaces_re = re.compile(r'^(\s+)') |
|
1268 | ini_spaces_re = re.compile(r'^(\s+)') | |
1244 | dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') |
|
1269 | dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') | |
1245 |
|
1270 | |||
1246 | # exit_now is set by a call to %Exit or %Quit |
|
1271 | # exit_now is set by a call to %Exit or %Quit | |
1247 | while not self.exit_now: |
|
1272 | while not self.exit_now: | |
1248 | try: |
|
1273 | try: | |
1249 | if more: |
|
1274 | if more: | |
1250 | prompt = self.outputcache.prompt2 |
|
1275 | prompt = self.outputcache.prompt2 | |
1251 | if self.autoindent: |
|
1276 | if self.autoindent: | |
1252 | self.readline_startup_hook(self.pre_readline) |
|
1277 | self.readline_startup_hook(self.pre_readline) | |
1253 | else: |
|
1278 | else: | |
1254 | prompt = self.outputcache.prompt1 |
|
1279 | prompt = self.outputcache.prompt1 | |
1255 | try: |
|
1280 | try: | |
1256 | line = self.raw_input(prompt,more) |
|
1281 | line = self.raw_input(prompt,more) | |
1257 | if self.autoindent: |
|
1282 | if self.autoindent: | |
1258 | self.readline_startup_hook(None) |
|
1283 | self.readline_startup_hook(None) | |
1259 | except EOFError: |
|
1284 | except EOFError: | |
1260 | if self.autoindent: |
|
1285 | if self.autoindent: | |
1261 | self.readline_startup_hook(None) |
|
1286 | self.readline_startup_hook(None) | |
1262 | self.write("\n") |
|
1287 | self.write("\n") | |
1263 | self.exit() |
|
1288 | self.exit() | |
1264 | else: |
|
1289 | else: | |
1265 | more = self.push(line) |
|
1290 | more = self.push(line) | |
1266 | # Auto-indent management |
|
1291 | # Auto-indent management | |
1267 | if self.autoindent: |
|
1292 | if self.autoindent: | |
1268 | if line: |
|
1293 | if line: | |
1269 | ini_spaces = ini_spaces_re.match(line) |
|
1294 | ini_spaces = ini_spaces_re.match(line) | |
1270 | if ini_spaces: |
|
1295 | if ini_spaces: | |
1271 | nspaces = ini_spaces.end() |
|
1296 | nspaces = ini_spaces.end() | |
1272 | else: |
|
1297 | else: | |
1273 | nspaces = 0 |
|
1298 | nspaces = 0 | |
1274 | self.indent_current_nsp = nspaces |
|
1299 | self.indent_current_nsp = nspaces | |
1275 |
|
1300 | |||
1276 | if line[-1] == ':': |
|
1301 | if line[-1] == ':': | |
1277 | self.indent_current_nsp += 4 |
|
1302 | self.indent_current_nsp += 4 | |
1278 | elif dedent_re.match(line): |
|
1303 | elif dedent_re.match(line): | |
1279 | self.indent_current_nsp -= 4 |
|
1304 | self.indent_current_nsp -= 4 | |
1280 | else: |
|
1305 | else: | |
1281 | self.indent_current_nsp = 0 |
|
1306 | self.indent_current_nsp = 0 | |
1282 |
|
1307 | |||
1283 | # indent_current is the actual string to be inserted |
|
1308 | # indent_current is the actual string to be inserted | |
1284 | # by the readline hooks for indentation |
|
1309 | # by the readline hooks for indentation | |
1285 | self.indent_current = ' '* self.indent_current_nsp |
|
1310 | self.indent_current = ' '* self.indent_current_nsp | |
1286 |
|
1311 | |||
1287 | if (self.SyntaxTB.last_syntax_error and |
|
1312 | if (self.SyntaxTB.last_syntax_error and | |
1288 | self.rc.autoedit_syntax): |
|
1313 | self.rc.autoedit_syntax): | |
1289 | self.edit_syntax_error() |
|
1314 | self.edit_syntax_error() | |
1290 |
|
1315 | |||
1291 | except KeyboardInterrupt: |
|
1316 | except KeyboardInterrupt: | |
1292 | self.write("\nKeyboardInterrupt\n") |
|
1317 | self.write("\nKeyboardInterrupt\n") | |
1293 | self.resetbuffer() |
|
1318 | self.resetbuffer() | |
1294 | more = 0 |
|
1319 | more = 0 | |
1295 | # keep cache in sync with the prompt counter: |
|
1320 | # keep cache in sync with the prompt counter: | |
1296 | self.outputcache.prompt_count -= 1 |
|
1321 | self.outputcache.prompt_count -= 1 | |
1297 |
|
1322 | |||
1298 | if self.autoindent: |
|
1323 | if self.autoindent: | |
1299 | self.indent_current_nsp = 0 |
|
1324 | self.indent_current_nsp = 0 | |
1300 | self.indent_current = ' '* self.indent_current_nsp |
|
1325 | self.indent_current = ' '* self.indent_current_nsp | |
1301 |
|
1326 | |||
1302 | except bdb.BdbQuit: |
|
1327 | except bdb.BdbQuit: | |
1303 | warn("The Python debugger has exited with a BdbQuit exception.\n" |
|
1328 | warn("The Python debugger has exited with a BdbQuit exception.\n" | |
1304 | "Because of how pdb handles the stack, it is impossible\n" |
|
1329 | "Because of how pdb handles the stack, it is impossible\n" | |
1305 | "for IPython to properly format this particular exception.\n" |
|
1330 | "for IPython to properly format this particular exception.\n" | |
1306 | "IPython will resume normal operation.") |
|
1331 | "IPython will resume normal operation.") | |
1307 |
|
1332 | |||
1308 | # We are off again... |
|
1333 | # We are off again... | |
1309 | __builtin__.__dict__['__IPYTHON__active'] -= 1 |
|
1334 | __builtin__.__dict__['__IPYTHON__active'] -= 1 | |
1310 |
|
1335 | |||
1311 | def excepthook(self, type, value, tb): |
|
1336 | def excepthook(self, type, value, tb): | |
1312 | """One more defense for GUI apps that call sys.excepthook. |
|
1337 | """One more defense for GUI apps that call sys.excepthook. | |
1313 |
|
1338 | |||
1314 | GUI frameworks like wxPython trap exceptions and call |
|
1339 | GUI frameworks like wxPython trap exceptions and call | |
1315 | sys.excepthook themselves. I guess this is a feature that |
|
1340 | sys.excepthook themselves. I guess this is a feature that | |
1316 | enables them to keep running after exceptions that would |
|
1341 | enables them to keep running after exceptions that would | |
1317 | otherwise kill their mainloop. This is a bother for IPython |
|
1342 | otherwise kill their mainloop. This is a bother for IPython | |
1318 | which excepts to catch all of the program exceptions with a try: |
|
1343 | which excepts to catch all of the program exceptions with a try: | |
1319 | except: statement. |
|
1344 | except: statement. | |
1320 |
|
1345 | |||
1321 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if |
|
1346 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if | |
1322 | any app directly invokes sys.excepthook, it will look to the user like |
|
1347 | any app directly invokes sys.excepthook, it will look to the user like | |
1323 | IPython crashed. In order to work around this, we can disable the |
|
1348 | IPython crashed. In order to work around this, we can disable the | |
1324 | CrashHandler and replace it with this excepthook instead, which prints a |
|
1349 | CrashHandler and replace it with this excepthook instead, which prints a | |
1325 | regular traceback using our InteractiveTB. In this fashion, apps which |
|
1350 | regular traceback using our InteractiveTB. In this fashion, apps which | |
1326 | call sys.excepthook will generate a regular-looking exception from |
|
1351 | call sys.excepthook will generate a regular-looking exception from | |
1327 | IPython, and the CrashHandler will only be triggered by real IPython |
|
1352 | IPython, and the CrashHandler will only be triggered by real IPython | |
1328 | crashes. |
|
1353 | crashes. | |
1329 |
|
1354 | |||
1330 | This hook should be used sparingly, only in places which are not likely |
|
1355 | This hook should be used sparingly, only in places which are not likely | |
1331 | to be true IPython errors. |
|
1356 | to be true IPython errors. | |
1332 | """ |
|
1357 | """ | |
1333 |
|
1358 | |||
1334 | self.InteractiveTB(type, value, tb, tb_offset=0) |
|
1359 | self.InteractiveTB(type, value, tb, tb_offset=0) | |
1335 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1360 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1336 | self.readline.set_completer(self.Completer.complete) |
|
1361 | self.readline.set_completer(self.Completer.complete) | |
1337 |
|
1362 | |||
1338 | def call_alias(self,alias,rest=''): |
|
1363 | def call_alias(self,alias,rest=''): | |
1339 | """Call an alias given its name and the rest of the line. |
|
1364 | """Call an alias given its name and the rest of the line. | |
1340 |
|
1365 | |||
1341 | This function MUST be given a proper alias, because it doesn't make |
|
1366 | This function MUST be given a proper alias, because it doesn't make | |
1342 | any checks when looking up into the alias table. The caller is |
|
1367 | any checks when looking up into the alias table. The caller is | |
1343 | responsible for invoking it only with a valid alias.""" |
|
1368 | responsible for invoking it only with a valid alias.""" | |
1344 |
|
1369 | |||
1345 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg |
|
1370 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg | |
1346 | nargs,cmd = self.alias_table[alias] |
|
1371 | nargs,cmd = self.alias_table[alias] | |
1347 | # Expand the %l special to be the user's input line |
|
1372 | # Expand the %l special to be the user's input line | |
1348 | if cmd.find('%l') >= 0: |
|
1373 | if cmd.find('%l') >= 0: | |
1349 | cmd = cmd.replace('%l',rest) |
|
1374 | cmd = cmd.replace('%l',rest) | |
1350 | rest = '' |
|
1375 | rest = '' | |
1351 | if nargs==0: |
|
1376 | if nargs==0: | |
1352 | # Simple, argument-less aliases |
|
1377 | # Simple, argument-less aliases | |
1353 | cmd = '%s %s' % (cmd,rest) |
|
1378 | cmd = '%s %s' % (cmd,rest) | |
1354 | else: |
|
1379 | else: | |
1355 | # Handle aliases with positional arguments |
|
1380 | # Handle aliases with positional arguments | |
1356 | args = rest.split(None,nargs) |
|
1381 | args = rest.split(None,nargs) | |
1357 | if len(args)< nargs: |
|
1382 | if len(args)< nargs: | |
1358 | error('Alias <%s> requires %s arguments, %s given.' % |
|
1383 | error('Alias <%s> requires %s arguments, %s given.' % | |
1359 | (alias,nargs,len(args))) |
|
1384 | (alias,nargs,len(args))) | |
1360 | return |
|
1385 | return | |
1361 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) |
|
1386 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) | |
1362 | # Now call the macro, evaluating in the user's namespace |
|
1387 | # Now call the macro, evaluating in the user's namespace | |
1363 | try: |
|
1388 | try: | |
1364 | self.system(cmd) |
|
1389 | self.system(cmd) | |
1365 | except: |
|
1390 | except: | |
1366 | self.showtraceback() |
|
1391 | self.showtraceback() | |
1367 |
|
1392 | |||
1368 | def runlines(self,lines): |
|
1393 | def runlines(self,lines): | |
1369 | """Run a string of one or more lines of source. |
|
1394 | """Run a string of one or more lines of source. | |
1370 |
|
1395 | |||
1371 | This method is capable of running a string containing multiple source |
|
1396 | This method is capable of running a string containing multiple source | |
1372 | lines, as if they had been entered at the IPython prompt. Since it |
|
1397 | lines, as if they had been entered at the IPython prompt. Since it | |
1373 | exposes IPython's processing machinery, the given strings can contain |
|
1398 | exposes IPython's processing machinery, the given strings can contain | |
1374 | magic calls (%magic), special shell access (!cmd), etc.""" |
|
1399 | magic calls (%magic), special shell access (!cmd), etc.""" | |
1375 |
|
1400 | |||
1376 | # We must start with a clean buffer, in case this is run from an |
|
1401 | # We must start with a clean buffer, in case this is run from an | |
1377 | # interactive IPython session (via a magic, for example). |
|
1402 | # interactive IPython session (via a magic, for example). | |
1378 | self.resetbuffer() |
|
1403 | self.resetbuffer() | |
1379 | lines = lines.split('\n') |
|
1404 | lines = lines.split('\n') | |
1380 | more = 0 |
|
1405 | more = 0 | |
1381 | for line in lines: |
|
1406 | for line in lines: | |
1382 | # skip blank lines so we don't mess up the prompt counter, but do |
|
1407 | # skip blank lines so we don't mess up the prompt counter, but do | |
1383 | # NOT skip even a blank line if we are in a code block (more is |
|
1408 | # NOT skip even a blank line if we are in a code block (more is | |
1384 | # true) |
|
1409 | # true) | |
1385 | if line or more: |
|
1410 | if line or more: | |
1386 | more = self.push((self.prefilter(line,more))) |
|
1411 | more = self.push((self.prefilter(line,more))) | |
1387 | # IPython's runsource returns None if there was an error |
|
1412 | # IPython's runsource returns None if there was an error | |
1388 | # compiling the code. This allows us to stop processing right |
|
1413 | # compiling the code. This allows us to stop processing right | |
1389 | # away, so the user gets the error message at the right place. |
|
1414 | # away, so the user gets the error message at the right place. | |
1390 | if more is None: |
|
1415 | if more is None: | |
1391 | break |
|
1416 | break | |
1392 | # final newline in case the input didn't have it, so that the code |
|
1417 | # final newline in case the input didn't have it, so that the code | |
1393 | # actually does get executed |
|
1418 | # actually does get executed | |
1394 | if more: |
|
1419 | if more: | |
1395 | self.push('\n') |
|
1420 | self.push('\n') | |
1396 |
|
1421 | |||
1397 | def runsource(self, source, filename='<input>', symbol='single'): |
|
1422 | def runsource(self, source, filename='<input>', symbol='single'): | |
1398 | """Compile and run some source in the interpreter. |
|
1423 | """Compile and run some source in the interpreter. | |
1399 |
|
1424 | |||
1400 | Arguments are as for compile_command(). |
|
1425 | Arguments are as for compile_command(). | |
1401 |
|
1426 | |||
1402 | One several things can happen: |
|
1427 | One several things can happen: | |
1403 |
|
1428 | |||
1404 | 1) The input is incorrect; compile_command() raised an |
|
1429 | 1) The input is incorrect; compile_command() raised an | |
1405 | exception (SyntaxError or OverflowError). A syntax traceback |
|
1430 | exception (SyntaxError or OverflowError). A syntax traceback | |
1406 | will be printed by calling the showsyntaxerror() method. |
|
1431 | will be printed by calling the showsyntaxerror() method. | |
1407 |
|
1432 | |||
1408 | 2) The input is incomplete, and more input is required; |
|
1433 | 2) The input is incomplete, and more input is required; | |
1409 | compile_command() returned None. Nothing happens. |
|
1434 | compile_command() returned None. Nothing happens. | |
1410 |
|
1435 | |||
1411 | 3) The input is complete; compile_command() returned a code |
|
1436 | 3) The input is complete; compile_command() returned a code | |
1412 | object. The code is executed by calling self.runcode() (which |
|
1437 | object. The code is executed by calling self.runcode() (which | |
1413 | also handles run-time exceptions, except for SystemExit). |
|
1438 | also handles run-time exceptions, except for SystemExit). | |
1414 |
|
1439 | |||
1415 | The return value is: |
|
1440 | The return value is: | |
1416 |
|
1441 | |||
1417 | - True in case 2 |
|
1442 | - True in case 2 | |
1418 |
|
1443 | |||
1419 | - False in the other cases, unless an exception is raised, where |
|
1444 | - False in the other cases, unless an exception is raised, where | |
1420 | None is returned instead. This can be used by external callers to |
|
1445 | None is returned instead. This can be used by external callers to | |
1421 | know whether to continue feeding input or not. |
|
1446 | know whether to continue feeding input or not. | |
1422 |
|
1447 | |||
1423 | The return value can be used to decide whether to use sys.ps1 or |
|
1448 | The return value can be used to decide whether to use sys.ps1 or | |
1424 | sys.ps2 to prompt the next line.""" |
|
1449 | sys.ps2 to prompt the next line.""" | |
1425 |
|
1450 | |||
1426 | try: |
|
1451 | try: | |
1427 | code = self.compile(source,filename,symbol) |
|
1452 | code = self.compile(source,filename,symbol) | |
1428 | except (OverflowError, SyntaxError, ValueError): |
|
1453 | except (OverflowError, SyntaxError, ValueError): | |
1429 | # Case 1 |
|
1454 | # Case 1 | |
1430 | self.showsyntaxerror(filename) |
|
1455 | self.showsyntaxerror(filename) | |
1431 | return None |
|
1456 | return None | |
1432 |
|
1457 | |||
1433 | if code is None: |
|
1458 | if code is None: | |
1434 | # Case 2 |
|
1459 | # Case 2 | |
1435 | return True |
|
1460 | return True | |
1436 |
|
1461 | |||
1437 | # Case 3 |
|
1462 | # Case 3 | |
1438 | # We store the code object so that threaded shells and |
|
1463 | # We store the code object so that threaded shells and | |
1439 | # custom exception handlers can access all this info if needed. |
|
1464 | # custom exception handlers can access all this info if needed. | |
1440 | # The source corresponding to this can be obtained from the |
|
1465 | # The source corresponding to this can be obtained from the | |
1441 | # buffer attribute as '\n'.join(self.buffer). |
|
1466 | # buffer attribute as '\n'.join(self.buffer). | |
1442 | self.code_to_run = code |
|
1467 | self.code_to_run = code | |
1443 | # now actually execute the code object |
|
1468 | # now actually execute the code object | |
1444 | if self.runcode(code) == 0: |
|
1469 | if self.runcode(code) == 0: | |
1445 | return False |
|
1470 | return False | |
1446 | else: |
|
1471 | else: | |
1447 | return None |
|
1472 | return None | |
1448 |
|
1473 | |||
1449 | def runcode(self,code_obj): |
|
1474 | def runcode(self,code_obj): | |
1450 | """Execute a code object. |
|
1475 | """Execute a code object. | |
1451 |
|
1476 | |||
1452 | When an exception occurs, self.showtraceback() is called to display a |
|
1477 | When an exception occurs, self.showtraceback() is called to display a | |
1453 | traceback. |
|
1478 | traceback. | |
1454 |
|
1479 | |||
1455 | Return value: a flag indicating whether the code to be run completed |
|
1480 | Return value: a flag indicating whether the code to be run completed | |
1456 | successfully: |
|
1481 | successfully: | |
1457 |
|
1482 | |||
1458 | - 0: successful execution. |
|
1483 | - 0: successful execution. | |
1459 | - 1: an error occurred. |
|
1484 | - 1: an error occurred. | |
1460 | """ |
|
1485 | """ | |
1461 |
|
1486 | |||
1462 | # Set our own excepthook in case the user code tries to call it |
|
1487 | # Set our own excepthook in case the user code tries to call it | |
1463 | # directly, so that the IPython crash handler doesn't get triggered |
|
1488 | # directly, so that the IPython crash handler doesn't get triggered | |
1464 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook |
|
1489 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook | |
|
1490 | ||||
|
1491 | # we save the original sys.excepthook in the instance, in case config | |||
|
1492 | # code (such as magics) needs access to it. | |||
|
1493 | self.sys_excepthook = old_excepthook | |||
1465 | outflag = 1 # happens in more places, so it's easier as default |
|
1494 | outflag = 1 # happens in more places, so it's easier as default | |
1466 | try: |
|
1495 | try: | |
1467 | try: |
|
1496 | try: | |
1468 | # Embedded instances require separate global/local namespaces |
|
1497 | # Embedded instances require separate global/local namespaces | |
1469 | # so they can see both the surrounding (local) namespace and |
|
1498 | # so they can see both the surrounding (local) namespace and | |
1470 | # the module-level globals when called inside another function. |
|
1499 | # the module-level globals when called inside another function. | |
1471 | if self.embedded: |
|
1500 | if self.embedded: | |
1472 | exec code_obj in self.user_global_ns, self.user_ns |
|
1501 | exec code_obj in self.user_global_ns, self.user_ns | |
1473 | # Normal (non-embedded) instances should only have a single |
|
1502 | # Normal (non-embedded) instances should only have a single | |
1474 | # namespace for user code execution, otherwise functions won't |
|
1503 | # namespace for user code execution, otherwise functions won't | |
1475 | # see interactive top-level globals. |
|
1504 | # see interactive top-level globals. | |
1476 | else: |
|
1505 | else: | |
1477 | exec code_obj in self.user_ns |
|
1506 | exec code_obj in self.user_ns | |
1478 | finally: |
|
1507 | finally: | |
1479 | # Reset our crash handler in place |
|
1508 | # Reset our crash handler in place | |
1480 | sys.excepthook = old_excepthook |
|
1509 | sys.excepthook = old_excepthook | |
1481 | except SystemExit: |
|
1510 | except SystemExit: | |
1482 | self.resetbuffer() |
|
1511 | self.resetbuffer() | |
1483 | self.showtraceback() |
|
1512 | self.showtraceback() | |
1484 | warn("Type exit or quit to exit IPython " |
|
1513 | warn("Type exit or quit to exit IPython " | |
1485 | "(%Exit or %Quit do so unconditionally).",level=1) |
|
1514 | "(%Exit or %Quit do so unconditionally).",level=1) | |
1486 | except self.custom_exceptions: |
|
1515 | except self.custom_exceptions: | |
1487 | etype,value,tb = sys.exc_info() |
|
1516 | etype,value,tb = sys.exc_info() | |
1488 | self.CustomTB(etype,value,tb) |
|
1517 | self.CustomTB(etype,value,tb) | |
1489 | except: |
|
1518 | except: | |
1490 | self.showtraceback() |
|
1519 | self.showtraceback() | |
1491 | else: |
|
1520 | else: | |
1492 | outflag = 0 |
|
1521 | outflag = 0 | |
1493 | if softspace(sys.stdout, 0): |
|
1522 | if softspace(sys.stdout, 0): | |
1494 |
|
1523 | |||
1495 | # Flush out code object which has been run (and source) |
|
1524 | # Flush out code object which has been run (and source) | |
1496 | self.code_to_run = None |
|
1525 | self.code_to_run = None | |
1497 | return outflag |
|
1526 | return outflag | |
1498 |
|
1527 | |||
1499 | def push(self, line): |
|
1528 | def push(self, line): | |
1500 | """Push a line to the interpreter. |
|
1529 | """Push a line to the interpreter. | |
1501 |
|
1530 | |||
1502 | The line should not have a trailing newline; it may have |
|
1531 | The line should not have a trailing newline; it may have | |
1503 | internal newlines. The line is appended to a buffer and the |
|
1532 | internal newlines. The line is appended to a buffer and the | |
1504 | interpreter's runsource() method is called with the |
|
1533 | interpreter's runsource() method is called with the | |
1505 | concatenated contents of the buffer as source. If this |
|
1534 | concatenated contents of the buffer as source. If this | |
1506 | indicates that the command was executed or invalid, the buffer |
|
1535 | indicates that the command was executed or invalid, the buffer | |
1507 | is reset; otherwise, the command is incomplete, and the buffer |
|
1536 | is reset; otherwise, the command is incomplete, and the buffer | |
1508 | is left as it was after the line was appended. The return |
|
1537 | is left as it was after the line was appended. The return | |
1509 | value is 1 if more input is required, 0 if the line was dealt |
|
1538 | value is 1 if more input is required, 0 if the line was dealt | |
1510 | with in some way (this is the same as runsource()). |
|
1539 | with in some way (this is the same as runsource()). | |
1511 |
|
1540 | |||
1512 | """ |
|
1541 | """ | |
1513 | self.buffer.append(line) |
|
1542 | self.buffer.append(line) | |
1514 | more = self.runsource('\n'.join(self.buffer), self.filename) |
|
1543 | more = self.runsource('\n'.join(self.buffer), self.filename) | |
1515 | if not more: |
|
1544 | if not more: | |
1516 | self.resetbuffer() |
|
1545 | self.resetbuffer() | |
1517 | return more |
|
1546 | return more | |
1518 |
|
1547 | |||
1519 | def resetbuffer(self): |
|
1548 | def resetbuffer(self): | |
1520 | """Reset the input buffer.""" |
|
1549 | """Reset the input buffer.""" | |
1521 | self.buffer[:] = [] |
|
1550 | self.buffer[:] = [] | |
1522 |
|
1551 | |||
1523 | def raw_input(self,prompt='',continue_prompt=False): |
|
1552 | def raw_input(self,prompt='',continue_prompt=False): | |
1524 | """Write a prompt and read a line. |
|
1553 | """Write a prompt and read a line. | |
1525 |
|
1554 | |||
1526 | The returned line does not include the trailing newline. |
|
1555 | The returned line does not include the trailing newline. | |
1527 | When the user enters the EOF key sequence, EOFError is raised. |
|
1556 | When the user enters the EOF key sequence, EOFError is raised. | |
1528 |
|
1557 | |||
1529 | Optional inputs: |
|
1558 | Optional inputs: | |
1530 |
|
1559 | |||
1531 | - prompt(''): a string to be printed to prompt the user. |
|
1560 | - prompt(''): a string to be printed to prompt the user. | |
1532 |
|
1561 | |||
1533 | - continue_prompt(False): whether this line is the first one or a |
|
1562 | - continue_prompt(False): whether this line is the first one or a | |
1534 | continuation in a sequence of inputs. |
|
1563 | continuation in a sequence of inputs. | |
1535 | """ |
|
1564 | """ | |
1536 |
|
1565 | |||
1537 | line = raw_input_original(prompt) |
|
1566 | line = raw_input_original(prompt) | |
1538 | # Try to be reasonably smart about not re-indenting pasted input more |
|
1567 | # Try to be reasonably smart about not re-indenting pasted input more | |
1539 | # than necessary. We do this by trimming out the auto-indent initial |
|
1568 | # than necessary. We do this by trimming out the auto-indent initial | |
1540 | # spaces, if the user's actual input started itself with whitespace. |
|
1569 | # spaces, if the user's actual input started itself with whitespace. | |
1541 | if self.autoindent: |
|
1570 | if self.autoindent: | |
1542 | line2 = line[self.indent_current_nsp:] |
|
1571 | line2 = line[self.indent_current_nsp:] | |
1543 | if line2[0:1] in (' ','\t'): |
|
1572 | if line2[0:1] in (' ','\t'): | |
1544 | line = line2 |
|
1573 | line = line2 | |
1545 | return self.prefilter(line,continue_prompt) |
|
1574 | return self.prefilter(line,continue_prompt) | |
1546 |
|
1575 | |||
1547 | def split_user_input(self,line): |
|
1576 | def split_user_input(self,line): | |
1548 | """Split user input into pre-char, function part and rest.""" |
|
1577 | """Split user input into pre-char, function part and rest.""" | |
1549 |
|
1578 | |||
1550 | lsplit = self.line_split.match(line) |
|
1579 | lsplit = self.line_split.match(line) | |
1551 | if lsplit is None: # no regexp match returns None |
|
1580 | if lsplit is None: # no regexp match returns None | |
1552 | try: |
|
1581 | try: | |
1553 | iFun,theRest = line.split(None,1) |
|
1582 | iFun,theRest = line.split(None,1) | |
1554 | except ValueError: |
|
1583 | except ValueError: | |
1555 | iFun,theRest = line,'' |
|
1584 | iFun,theRest = line,'' | |
1556 | pre = re.match('^(\s*)(.*)',line).groups()[0] |
|
1585 | pre = re.match('^(\s*)(.*)',line).groups()[0] | |
1557 | else: |
|
1586 | else: | |
1558 | pre,iFun,theRest = lsplit.groups() |
|
1587 | pre,iFun,theRest = lsplit.groups() | |
1559 |
|
1588 | |||
1560 | #print 'line:<%s>' % line # dbg |
|
1589 | #print 'line:<%s>' % line # dbg | |
1561 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg |
|
1590 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg | |
1562 | return pre,iFun.strip(),theRest |
|
1591 | return pre,iFun.strip(),theRest | |
1563 |
|
1592 | |||
1564 | def _prefilter(self, line, continue_prompt): |
|
1593 | def _prefilter(self, line, continue_prompt): | |
1565 | """Calls different preprocessors, depending on the form of line.""" |
|
1594 | """Calls different preprocessors, depending on the form of line.""" | |
1566 |
|
1595 | |||
1567 | # All handlers *must* return a value, even if it's blank (''). |
|
1596 | # All handlers *must* return a value, even if it's blank (''). | |
1568 |
|
1597 | |||
1569 | # Lines are NOT logged here. Handlers should process the line as |
|
1598 | # Lines are NOT logged here. Handlers should process the line as | |
1570 | # needed, update the cache AND log it (so that the input cache array |
|
1599 | # needed, update the cache AND log it (so that the input cache array | |
1571 | # stays synced). |
|
1600 | # stays synced). | |
1572 |
|
1601 | |||
1573 | # This function is _very_ delicate, and since it's also the one which |
|
1602 | # This function is _very_ delicate, and since it's also the one which | |
1574 | # determines IPython's response to user input, it must be as efficient |
|
1603 | # determines IPython's response to user input, it must be as efficient | |
1575 | # as possible. For this reason it has _many_ returns in it, trying |
|
1604 | # as possible. For this reason it has _many_ returns in it, trying | |
1576 | # always to exit as quickly as it can figure out what it needs to do. |
|
1605 | # always to exit as quickly as it can figure out what it needs to do. | |
1577 |
|
1606 | |||
1578 | # This function is the main responsible for maintaining IPython's |
|
1607 | # This function is the main responsible for maintaining IPython's | |
1579 | # behavior respectful of Python's semantics. So be _very_ careful if |
|
1608 | # behavior respectful of Python's semantics. So be _very_ careful if | |
1580 | # making changes to anything here. |
|
1609 | # making changes to anything here. | |
1581 |
|
1610 | |||
1582 | #..................................................................... |
|
1611 | #..................................................................... | |
1583 | # Code begins |
|
1612 | # Code begins | |
1584 |
|
1613 | |||
1585 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg |
|
1614 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg | |
1586 |
|
1615 | |||
1587 | # save the line away in case we crash, so the post-mortem handler can |
|
1616 | # save the line away in case we crash, so the post-mortem handler can | |
1588 | # record it |
|
1617 | # record it | |
1589 | self._last_input_line = line |
|
1618 | self._last_input_line = line | |
1590 |
|
1619 | |||
1591 | #print '***line: <%s>' % line # dbg |
|
1620 | #print '***line: <%s>' % line # dbg | |
1592 |
|
1621 | |||
1593 | # the input history needs to track even empty lines |
|
1622 | # the input history needs to track even empty lines | |
1594 | if not line.strip(): |
|
1623 | if not line.strip(): | |
1595 | if not continue_prompt: |
|
1624 | if not continue_prompt: | |
1596 | self.outputcache.prompt_count -= 1 |
|
1625 | self.outputcache.prompt_count -= 1 | |
1597 | return self.handle_normal(line,continue_prompt) |
|
1626 | return self.handle_normal(line,continue_prompt) | |
1598 | #return self.handle_normal('',continue_prompt) |
|
1627 | #return self.handle_normal('',continue_prompt) | |
1599 |
|
1628 | |||
1600 | # print '***cont',continue_prompt # dbg |
|
1629 | # print '***cont',continue_prompt # dbg | |
1601 | # special handlers are only allowed for single line statements |
|
1630 | # special handlers are only allowed for single line statements | |
1602 | if continue_prompt and not self.rc.multi_line_specials: |
|
1631 | if continue_prompt and not self.rc.multi_line_specials: | |
1603 | return self.handle_normal(line,continue_prompt) |
|
1632 | return self.handle_normal(line,continue_prompt) | |
1604 |
|
1633 | |||
1605 | # For the rest, we need the structure of the input |
|
1634 | # For the rest, we need the structure of the input | |
1606 | pre,iFun,theRest = self.split_user_input(line) |
|
1635 | pre,iFun,theRest = self.split_user_input(line) | |
1607 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1636 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1608 |
|
1637 | |||
1609 | # First check for explicit escapes in the last/first character |
|
1638 | # First check for explicit escapes in the last/first character | |
1610 | handler = None |
|
1639 | handler = None | |
1611 | if line[-1] == self.ESC_HELP: |
|
1640 | if line[-1] == self.ESC_HELP: | |
1612 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end |
|
1641 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end | |
1613 | if handler is None: |
|
1642 | if handler is None: | |
1614 | # look at the first character of iFun, NOT of line, so we skip |
|
1643 | # look at the first character of iFun, NOT of line, so we skip | |
1615 | # leading whitespace in multiline input |
|
1644 | # leading whitespace in multiline input | |
1616 | handler = self.esc_handlers.get(iFun[0:1]) |
|
1645 | handler = self.esc_handlers.get(iFun[0:1]) | |
1617 | if handler is not None: |
|
1646 | if handler is not None: | |
1618 | return handler(line,continue_prompt,pre,iFun,theRest) |
|
1647 | return handler(line,continue_prompt,pre,iFun,theRest) | |
1619 | # Emacs ipython-mode tags certain input lines |
|
1648 | # Emacs ipython-mode tags certain input lines | |
1620 | if line.endswith('# PYTHON-MODE'): |
|
1649 | if line.endswith('# PYTHON-MODE'): | |
1621 | return self.handle_emacs(line,continue_prompt) |
|
1650 | return self.handle_emacs(line,continue_prompt) | |
1622 |
|
1651 | |||
1623 | # Next, check if we can automatically execute this thing |
|
1652 | # Next, check if we can automatically execute this thing | |
1624 |
|
1653 | |||
1625 | # Allow ! in multi-line statements if multi_line_specials is on: |
|
1654 | # Allow ! in multi-line statements if multi_line_specials is on: | |
1626 | if continue_prompt and self.rc.multi_line_specials and \ |
|
1655 | if continue_prompt and self.rc.multi_line_specials and \ | |
1627 | iFun.startswith(self.ESC_SHELL): |
|
1656 | iFun.startswith(self.ESC_SHELL): | |
1628 | return self.handle_shell_escape(line,continue_prompt, |
|
1657 | return self.handle_shell_escape(line,continue_prompt, | |
1629 | pre=pre,iFun=iFun, |
|
1658 | pre=pre,iFun=iFun, | |
1630 | theRest=theRest) |
|
1659 | theRest=theRest) | |
1631 |
|
1660 | |||
1632 | # Let's try to find if the input line is a magic fn |
|
1661 | # Let's try to find if the input line is a magic fn | |
1633 | oinfo = None |
|
1662 | oinfo = None | |
1634 | if hasattr(self,'magic_'+iFun): |
|
1663 | if hasattr(self,'magic_'+iFun): | |
1635 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1664 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1636 | if oinfo['ismagic']: |
|
1665 | if oinfo['ismagic']: | |
1637 | # Be careful not to call magics when a variable assignment is |
|
1666 | # Be careful not to call magics when a variable assignment is | |
1638 | # being made (ls='hi', for example) |
|
1667 | # being made (ls='hi', for example) | |
1639 | if self.rc.automagic and \ |
|
1668 | if self.rc.automagic and \ | |
1640 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ |
|
1669 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ | |
1641 | (self.rc.multi_line_specials or not continue_prompt): |
|
1670 | (self.rc.multi_line_specials or not continue_prompt): | |
1642 | return self.handle_magic(line,continue_prompt, |
|
1671 | return self.handle_magic(line,continue_prompt, | |
1643 | pre,iFun,theRest) |
|
1672 | pre,iFun,theRest) | |
1644 | else: |
|
1673 | else: | |
1645 | return self.handle_normal(line,continue_prompt) |
|
1674 | return self.handle_normal(line,continue_prompt) | |
1646 |
|
1675 | |||
1647 | # If the rest of the line begins with an (in)equality, assginment or |
|
1676 | # If the rest of the line begins with an (in)equality, assginment or | |
1648 | # function call, we should not call _ofind but simply execute it. |
|
1677 | # function call, we should not call _ofind but simply execute it. | |
1649 | # This avoids spurious geattr() accesses on objects upon assignment. |
|
1678 | # This avoids spurious geattr() accesses on objects upon assignment. | |
1650 | # |
|
1679 | # | |
1651 | # It also allows users to assign to either alias or magic names true |
|
1680 | # It also allows users to assign to either alias or magic names true | |
1652 | # python variables (the magic/alias systems always take second seat to |
|
1681 | # python variables (the magic/alias systems always take second seat to | |
1653 | # true python code). |
|
1682 | # true python code). | |
1654 | if theRest and theRest[0] in '!=()': |
|
1683 | if theRest and theRest[0] in '!=()': | |
1655 | return self.handle_normal(line,continue_prompt) |
|
1684 | return self.handle_normal(line,continue_prompt) | |
1656 |
|
1685 | |||
1657 | if oinfo is None: |
|
1686 | if oinfo is None: | |
1658 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1687 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1659 |
|
1688 | |||
1660 | if not oinfo['found']: |
|
1689 | if not oinfo['found']: | |
1661 | return self.handle_normal(line,continue_prompt) |
|
1690 | return self.handle_normal(line,continue_prompt) | |
1662 | else: |
|
1691 | else: | |
1663 | #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg |
|
1692 | #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg | |
1664 | if oinfo['isalias']: |
|
1693 | if oinfo['isalias']: | |
1665 | return self.handle_alias(line,continue_prompt, |
|
1694 | return self.handle_alias(line,continue_prompt, | |
1666 | pre,iFun,theRest) |
|
1695 | pre,iFun,theRest) | |
1667 |
|
1696 | |||
1668 | if self.rc.autocall and \ |
|
1697 | if self.rc.autocall and \ | |
1669 | not self.re_exclude_auto.match(theRest) and \ |
|
1698 | not self.re_exclude_auto.match(theRest) and \ | |
1670 | self.re_fun_name.match(iFun) and \ |
|
1699 | self.re_fun_name.match(iFun) and \ | |
1671 | callable(oinfo['obj']) : |
|
1700 | callable(oinfo['obj']) : | |
1672 | #print 'going auto' # dbg |
|
1701 | #print 'going auto' # dbg | |
1673 | return self.handle_auto(line,continue_prompt,pre,iFun,theRest) |
|
1702 | return self.handle_auto(line,continue_prompt,pre,iFun,theRest) | |
1674 | else: |
|
1703 | else: | |
1675 | #print 'was callable?', callable(oinfo['obj']) # dbg |
|
1704 | #print 'was callable?', callable(oinfo['obj']) # dbg | |
1676 | return self.handle_normal(line,continue_prompt) |
|
1705 | return self.handle_normal(line,continue_prompt) | |
1677 |
|
1706 | |||
1678 | # If we get here, we have a normal Python line. Log and return. |
|
1707 | # If we get here, we have a normal Python line. Log and return. | |
1679 | return self.handle_normal(line,continue_prompt) |
|
1708 | return self.handle_normal(line,continue_prompt) | |
1680 |
|
1709 | |||
1681 | def _prefilter_dumb(self, line, continue_prompt): |
|
1710 | def _prefilter_dumb(self, line, continue_prompt): | |
1682 | """simple prefilter function, for debugging""" |
|
1711 | """simple prefilter function, for debugging""" | |
1683 | return self.handle_normal(line,continue_prompt) |
|
1712 | return self.handle_normal(line,continue_prompt) | |
1684 |
|
1713 | |||
1685 | # Set the default prefilter() function (this can be user-overridden) |
|
1714 | # Set the default prefilter() function (this can be user-overridden) | |
1686 | prefilter = _prefilter |
|
1715 | prefilter = _prefilter | |
1687 |
|
1716 | |||
1688 | def handle_normal(self,line,continue_prompt=None, |
|
1717 | def handle_normal(self,line,continue_prompt=None, | |
1689 | pre=None,iFun=None,theRest=None): |
|
1718 | pre=None,iFun=None,theRest=None): | |
1690 | """Handle normal input lines. Use as a template for handlers.""" |
|
1719 | """Handle normal input lines. Use as a template for handlers.""" | |
1691 |
|
1720 | |||
1692 | # With autoindent on, we need some way to exit the input loop, and I |
|
1721 | # With autoindent on, we need some way to exit the input loop, and I | |
1693 | # don't want to force the user to have to backspace all the way to |
|
1722 | # don't want to force the user to have to backspace all the way to | |
1694 | # clear the line. The rule will be in this case, that either two |
|
1723 | # clear the line. The rule will be in this case, that either two | |
1695 | # lines of pure whitespace in a row, or a line of pure whitespace but |
|
1724 | # lines of pure whitespace in a row, or a line of pure whitespace but | |
1696 | # of a size different to the indent level, will exit the input loop. |
|
1725 | # of a size different to the indent level, will exit the input loop. | |
1697 | if (continue_prompt and self.autoindent and isspace(line) and |
|
1726 | if (continue_prompt and self.autoindent and isspace(line) and | |
1698 | (line != self.indent_current or isspace(self.buffer[-1]))): |
|
1727 | (line != self.indent_current or isspace(self.buffer[-1]))): | |
1699 | line = '' |
|
1728 | line = '' | |
1700 |
|
1729 | |||
1701 | self.log(line,continue_prompt) |
|
1730 | self.log(line,continue_prompt) | |
1702 | self.update_cache(line) |
|
1731 | self.update_cache(line) | |
1703 | return line |
|
1732 | return line | |
1704 |
|
1733 | |||
1705 | def handle_alias(self,line,continue_prompt=None, |
|
1734 | def handle_alias(self,line,continue_prompt=None, | |
1706 | pre=None,iFun=None,theRest=None): |
|
1735 | pre=None,iFun=None,theRest=None): | |
1707 | """Handle alias input lines. """ |
|
1736 | """Handle alias input lines. """ | |
1708 |
|
1737 | |||
1709 | theRest = esc_quotes(theRest) |
|
1738 | theRest = esc_quotes(theRest) | |
1710 | line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest) |
|
1739 | line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest) | |
1711 | self.log(line_out,continue_prompt) |
|
1740 | self.log(line_out,continue_prompt) | |
1712 | self.update_cache(line_out) |
|
1741 | self.update_cache(line_out) | |
1713 | return line_out |
|
1742 | return line_out | |
1714 |
|
1743 | |||
1715 | def handle_shell_escape(self, line, continue_prompt=None, |
|
1744 | def handle_shell_escape(self, line, continue_prompt=None, | |
1716 | pre=None,iFun=None,theRest=None): |
|
1745 | pre=None,iFun=None,theRest=None): | |
1717 | """Execute the line in a shell, empty return value""" |
|
1746 | """Execute the line in a shell, empty return value""" | |
1718 |
|
1747 | |||
1719 | #print 'line in :', `line` # dbg |
|
1748 | #print 'line in :', `line` # dbg | |
1720 | # Example of a special handler. Others follow a similar pattern. |
|
1749 | # Example of a special handler. Others follow a similar pattern. | |
1721 | if continue_prompt: # multi-line statements |
|
1750 | if continue_prompt: # multi-line statements | |
1722 | if iFun.startswith('!!'): |
|
1751 | if iFun.startswith('!!'): | |
1723 | print 'SyntaxError: !! is not allowed in multiline statements' |
|
1752 | print 'SyntaxError: !! is not allowed in multiline statements' | |
1724 | return pre |
|
1753 | return pre | |
1725 | else: |
|
1754 | else: | |
1726 | cmd = ("%s %s" % (iFun[1:],theRest)) #.replace('"','\\"') |
|
1755 | cmd = ("%s %s" % (iFun[1:],theRest)) #.replace('"','\\"') | |
1727 | #line_out = '%s%s.system("%s")' % (pre,self.name,cmd) |
|
1756 | #line_out = '%s%s.system("%s")' % (pre,self.name,cmd) | |
1728 | line_out = '%s%s.system(r"""%s"""[:-1])' % (pre,self.name,cmd + "_") |
|
1757 | line_out = '%s%s.system(r"""%s"""[:-1])' % (pre,self.name,cmd + "_") | |
1729 | #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')' |
|
1758 | #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')' | |
1730 | else: # single-line input |
|
1759 | else: # single-line input | |
1731 | if line.startswith('!!'): |
|
1760 | if line.startswith('!!'): | |
1732 | # rewrite iFun/theRest to properly hold the call to %sx and |
|
1761 | # rewrite iFun/theRest to properly hold the call to %sx and | |
1733 | # the actual command to be executed, so handle_magic can work |
|
1762 | # the actual command to be executed, so handle_magic can work | |
1734 | # correctly |
|
1763 | # correctly | |
1735 | theRest = '%s %s' % (iFun[2:],theRest) |
|
1764 | theRest = '%s %s' % (iFun[2:],theRest) | |
1736 | iFun = 'sx' |
|
1765 | iFun = 'sx' | |
1737 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]), |
|
1766 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]), | |
1738 | continue_prompt,pre,iFun,theRest) |
|
1767 | continue_prompt,pre,iFun,theRest) | |
1739 | else: |
|
1768 | else: | |
1740 | #cmd = esc_quotes(line[1:]) |
|
1769 | #cmd = esc_quotes(line[1:]) | |
1741 | cmd=line[1:] |
|
1770 | cmd=line[1:] | |
1742 | #line_out = '%s.system("%s")' % (self.name,cmd) |
|
1771 | #line_out = '%s.system("%s")' % (self.name,cmd) | |
1743 | line_out = '%s.system(r"""%s"""[:-1])' % (self.name,cmd +"_") |
|
1772 | line_out = '%s.system(r"""%s"""[:-1])' % (self.name,cmd +"_") | |
1744 | #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')' |
|
1773 | #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')' | |
1745 | # update cache/log and return |
|
1774 | # update cache/log and return | |
1746 | self.log(line_out,continue_prompt) |
|
1775 | self.log(line_out,continue_prompt) | |
1747 | self.update_cache(line_out) # readline cache gets normal line |
|
1776 | self.update_cache(line_out) # readline cache gets normal line | |
1748 | #print 'line out r:', `line_out` # dbg |
|
1777 | #print 'line out r:', `line_out` # dbg | |
1749 | #print 'line out s:', line_out # dbg |
|
1778 | #print 'line out s:', line_out # dbg | |
1750 | return line_out |
|
1779 | return line_out | |
1751 |
|
1780 | |||
1752 | def handle_magic(self, line, continue_prompt=None, |
|
1781 | def handle_magic(self, line, continue_prompt=None, | |
1753 | pre=None,iFun=None,theRest=None): |
|
1782 | pre=None,iFun=None,theRest=None): | |
1754 | """Execute magic functions. |
|
1783 | """Execute magic functions. | |
1755 |
|
1784 | |||
1756 | Also log them with a prepended # so the log is clean Python.""" |
|
1785 | Also log them with a prepended # so the log is clean Python.""" | |
1757 |
|
1786 | |||
1758 | cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest))) |
|
1787 | cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest))) | |
1759 | self.log(cmd,continue_prompt) |
|
1788 | self.log(cmd,continue_prompt) | |
1760 | self.update_cache(line) |
|
1789 | self.update_cache(line) | |
1761 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg |
|
1790 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg | |
1762 | return cmd |
|
1791 | return cmd | |
1763 |
|
1792 | |||
1764 | def handle_auto(self, line, continue_prompt=None, |
|
1793 | def handle_auto(self, line, continue_prompt=None, | |
1765 | pre=None,iFun=None,theRest=None): |
|
1794 | pre=None,iFun=None,theRest=None): | |
1766 | """Hande lines which can be auto-executed, quoting if requested.""" |
|
1795 | """Hande lines which can be auto-executed, quoting if requested.""" | |
1767 |
|
1796 | |||
1768 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1797 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1769 |
|
1798 | |||
1770 | # This should only be active for single-line input! |
|
1799 | # This should only be active for single-line input! | |
1771 | if continue_prompt: |
|
1800 | if continue_prompt: | |
1772 | return line |
|
1801 | return line | |
1773 |
|
1802 | |||
1774 | if pre == self.ESC_QUOTE: |
|
1803 | if pre == self.ESC_QUOTE: | |
1775 | # Auto-quote splitting on whitespace |
|
1804 | # Auto-quote splitting on whitespace | |
1776 | newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) ) |
|
1805 | newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) ) | |
1777 | elif pre == self.ESC_QUOTE2: |
|
1806 | elif pre == self.ESC_QUOTE2: | |
1778 | # Auto-quote whole string |
|
1807 | # Auto-quote whole string | |
1779 | newcmd = '%s("%s")' % (iFun,theRest) |
|
1808 | newcmd = '%s("%s")' % (iFun,theRest) | |
1780 | else: |
|
1809 | else: | |
1781 | # Auto-paren |
|
1810 | # Auto-paren | |
1782 | if theRest[0:1] in ('=','['): |
|
1811 | if theRest[0:1] in ('=','['): | |
1783 | # Don't autocall in these cases. They can be either |
|
1812 | # Don't autocall in these cases. They can be either | |
1784 | # rebindings of an existing callable's name, or item access |
|
1813 | # rebindings of an existing callable's name, or item access | |
1785 | # for an object which is BOTH callable and implements |
|
1814 | # for an object which is BOTH callable and implements | |
1786 | # __getitem__. |
|
1815 | # __getitem__. | |
1787 | return '%s %s' % (iFun,theRest) |
|
1816 | return '%s %s' % (iFun,theRest) | |
1788 | if theRest.endswith(';'): |
|
1817 | if theRest.endswith(';'): | |
1789 | newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1]) |
|
1818 | newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1]) | |
1790 | else: |
|
1819 | else: | |
1791 | newcmd = '%s(%s)' % (iFun.rstrip(),theRest) |
|
1820 | newcmd = '%s(%s)' % (iFun.rstrip(),theRest) | |
1792 |
|
1821 | |||
1793 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd |
|
1822 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd | |
1794 | # log what is now valid Python, not the actual user input (without the |
|
1823 | # log what is now valid Python, not the actual user input (without the | |
1795 | # final newline) |
|
1824 | # final newline) | |
1796 | self.log(newcmd,continue_prompt) |
|
1825 | self.log(newcmd,continue_prompt) | |
1797 | return newcmd |
|
1826 | return newcmd | |
1798 |
|
1827 | |||
1799 | def handle_help(self, line, continue_prompt=None, |
|
1828 | def handle_help(self, line, continue_prompt=None, | |
1800 | pre=None,iFun=None,theRest=None): |
|
1829 | pre=None,iFun=None,theRest=None): | |
1801 | """Try to get some help for the object. |
|
1830 | """Try to get some help for the object. | |
1802 |
|
1831 | |||
1803 | obj? or ?obj -> basic information. |
|
1832 | obj? or ?obj -> basic information. | |
1804 | obj?? or ??obj -> more details. |
|
1833 | obj?? or ??obj -> more details. | |
1805 | """ |
|
1834 | """ | |
1806 |
|
1835 | |||
1807 | # We need to make sure that we don't process lines which would be |
|
1836 | # We need to make sure that we don't process lines which would be | |
1808 | # otherwise valid python, such as "x=1 # what?" |
|
1837 | # otherwise valid python, such as "x=1 # what?" | |
1809 | try: |
|
1838 | try: | |
1810 | codeop.compile_command(line) |
|
1839 | codeop.compile_command(line) | |
1811 | except SyntaxError: |
|
1840 | except SyntaxError: | |
1812 | # We should only handle as help stuff which is NOT valid syntax |
|
1841 | # We should only handle as help stuff which is NOT valid syntax | |
1813 | if line[0]==self.ESC_HELP: |
|
1842 | if line[0]==self.ESC_HELP: | |
1814 | line = line[1:] |
|
1843 | line = line[1:] | |
1815 | elif line[-1]==self.ESC_HELP: |
|
1844 | elif line[-1]==self.ESC_HELP: | |
1816 | line = line[:-1] |
|
1845 | line = line[:-1] | |
1817 | self.log('#?'+line) |
|
1846 | self.log('#?'+line) | |
1818 | self.update_cache(line) |
|
1847 | self.update_cache(line) | |
1819 | if line: |
|
1848 | if line: | |
1820 | self.magic_pinfo(line) |
|
1849 | self.magic_pinfo(line) | |
1821 | else: |
|
1850 | else: | |
1822 | page(self.usage,screen_lines=self.rc.screen_length) |
|
1851 | page(self.usage,screen_lines=self.rc.screen_length) | |
1823 | return '' # Empty string is needed here! |
|
1852 | return '' # Empty string is needed here! | |
1824 | except: |
|
1853 | except: | |
1825 | # Pass any other exceptions through to the normal handler |
|
1854 | # Pass any other exceptions through to the normal handler | |
1826 | return self.handle_normal(line,continue_prompt) |
|
1855 | return self.handle_normal(line,continue_prompt) | |
1827 | else: |
|
1856 | else: | |
1828 | # If the code compiles ok, we should handle it normally |
|
1857 | # If the code compiles ok, we should handle it normally | |
1829 | return self.handle_normal(line,continue_prompt) |
|
1858 | return self.handle_normal(line,continue_prompt) | |
1830 |
|
1859 | |||
1831 | def handle_emacs(self,line,continue_prompt=None, |
|
1860 | def handle_emacs(self,line,continue_prompt=None, | |
1832 | pre=None,iFun=None,theRest=None): |
|
1861 | pre=None,iFun=None,theRest=None): | |
1833 | """Handle input lines marked by python-mode.""" |
|
1862 | """Handle input lines marked by python-mode.""" | |
1834 |
|
1863 | |||
1835 | # Currently, nothing is done. Later more functionality can be added |
|
1864 | # Currently, nothing is done. Later more functionality can be added | |
1836 | # here if needed. |
|
1865 | # here if needed. | |
1837 |
|
1866 | |||
1838 | # The input cache shouldn't be updated |
|
1867 | # The input cache shouldn't be updated | |
1839 |
|
1868 | |||
1840 | return line |
|
1869 | return line | |
1841 |
|
1870 | |||
1842 | def write(self,data): |
|
1871 | def write(self,data): | |
1843 | """Write a string to the default output""" |
|
1872 | """Write a string to the default output""" | |
1844 | Term.cout.write(data) |
|
1873 | Term.cout.write(data) | |
1845 |
|
1874 | |||
1846 | def write_err(self,data): |
|
1875 | def write_err(self,data): | |
1847 | """Write a string to the default error output""" |
|
1876 | """Write a string to the default error output""" | |
1848 | Term.cerr.write(data) |
|
1877 | Term.cerr.write(data) | |
1849 |
|
1878 | |||
1850 | def exit(self): |
|
1879 | def exit(self): | |
1851 | """Handle interactive exit. |
|
1880 | """Handle interactive exit. | |
1852 |
|
1881 | |||
1853 | This method sets the exit_now attribute.""" |
|
1882 | This method sets the exit_now attribute.""" | |
1854 |
|
1883 | |||
1855 | if self.rc.confirm_exit: |
|
1884 | if self.rc.confirm_exit: | |
1856 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): |
|
1885 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): | |
1857 | self.exit_now = True |
|
1886 | self.exit_now = True | |
1858 | else: |
|
1887 | else: | |
1859 | self.exit_now = True |
|
1888 | self.exit_now = True | |
1860 | return self.exit_now |
|
1889 | return self.exit_now | |
1861 |
|
1890 | |||
1862 | def safe_execfile(self,fname,*where,**kw): |
|
1891 | def safe_execfile(self,fname,*where,**kw): | |
1863 | fname = os.path.expanduser(fname) |
|
1892 | fname = os.path.expanduser(fname) | |
1864 |
|
1893 | |||
1865 | # find things also in current directory |
|
1894 | # find things also in current directory | |
1866 | dname = os.path.dirname(fname) |
|
1895 | dname = os.path.dirname(fname) | |
1867 | if not sys.path.count(dname): |
|
1896 | if not sys.path.count(dname): | |
1868 | sys.path.append(dname) |
|
1897 | sys.path.append(dname) | |
1869 |
|
1898 | |||
1870 | try: |
|
1899 | try: | |
1871 | xfile = open(fname) |
|
1900 | xfile = open(fname) | |
1872 | except: |
|
1901 | except: | |
1873 | print >> Term.cerr, \ |
|
1902 | print >> Term.cerr, \ | |
1874 | 'Could not open file <%s> for safe execution.' % fname |
|
1903 | 'Could not open file <%s> for safe execution.' % fname | |
1875 | return None |
|
1904 | return None | |
1876 |
|
1905 | |||
1877 | kw.setdefault('islog',0) |
|
1906 | kw.setdefault('islog',0) | |
1878 | kw.setdefault('quiet',1) |
|
1907 | kw.setdefault('quiet',1) | |
1879 | kw.setdefault('exit_ignore',0) |
|
1908 | kw.setdefault('exit_ignore',0) | |
1880 | first = xfile.readline() |
|
1909 | first = xfile.readline() | |
1881 | _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip() |
|
1910 | _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip() | |
1882 | xfile.close() |
|
1911 | xfile.close() | |
1883 | # line by line execution |
|
1912 | # line by line execution | |
1884 | if first.startswith(_LOGHEAD) or kw['islog']: |
|
1913 | if first.startswith(_LOGHEAD) or kw['islog']: | |
1885 | print 'Loading log file <%s> one line at a time...' % fname |
|
1914 | print 'Loading log file <%s> one line at a time...' % fname | |
1886 | if kw['quiet']: |
|
1915 | if kw['quiet']: | |
1887 | stdout_save = sys.stdout |
|
1916 | stdout_save = sys.stdout | |
1888 | sys.stdout = StringIO.StringIO() |
|
1917 | sys.stdout = StringIO.StringIO() | |
1889 | try: |
|
1918 | try: | |
1890 | globs,locs = where[0:2] |
|
1919 | globs,locs = where[0:2] | |
1891 | except: |
|
1920 | except: | |
1892 | try: |
|
1921 | try: | |
1893 | globs = locs = where[0] |
|
1922 | globs = locs = where[0] | |
1894 | except: |
|
1923 | except: | |
1895 | globs = locs = globals() |
|
1924 | globs = locs = globals() | |
1896 | badblocks = [] |
|
1925 | badblocks = [] | |
1897 |
|
1926 | |||
1898 | # we also need to identify indented blocks of code when replaying |
|
1927 | # we also need to identify indented blocks of code when replaying | |
1899 | # logs and put them together before passing them to an exec |
|
1928 | # logs and put them together before passing them to an exec | |
1900 | # statement. This takes a bit of regexp and look-ahead work in the |
|
1929 | # statement. This takes a bit of regexp and look-ahead work in the | |
1901 | # file. It's easiest if we swallow the whole thing in memory |
|
1930 | # file. It's easiest if we swallow the whole thing in memory | |
1902 | # first, and manually walk through the lines list moving the |
|
1931 | # first, and manually walk through the lines list moving the | |
1903 | # counter ourselves. |
|
1932 | # counter ourselves. | |
1904 | indent_re = re.compile('\s+\S') |
|
1933 | indent_re = re.compile('\s+\S') | |
1905 | xfile = open(fname) |
|
1934 | xfile = open(fname) | |
1906 | filelines = xfile.readlines() |
|
1935 | filelines = xfile.readlines() | |
1907 | xfile.close() |
|
1936 | xfile.close() | |
1908 | nlines = len(filelines) |
|
1937 | nlines = len(filelines) | |
1909 | lnum = 0 |
|
1938 | lnum = 0 | |
1910 | while lnum < nlines: |
|
1939 | while lnum < nlines: | |
1911 | line = filelines[lnum] |
|
1940 | line = filelines[lnum] | |
1912 | lnum += 1 |
|
1941 | lnum += 1 | |
1913 | # don't re-insert logger status info into cache |
|
1942 | # don't re-insert logger status info into cache | |
1914 | if line.startswith('#log#'): |
|
1943 | if line.startswith('#log#'): | |
1915 | continue |
|
1944 | continue | |
1916 | elif line.startswith('#%s'% self.ESC_MAGIC): |
|
1945 | elif line.startswith('#%s'% self.ESC_MAGIC): | |
1917 | self.update_cache(line[1:]) |
|
1946 | self.update_cache(line[1:]) | |
1918 | line = magic2python(line) |
|
1947 | line = magic2python(line) | |
1919 | elif line.startswith('#!'): |
|
1948 | elif line.startswith('#!'): | |
1920 | self.update_cache(line[1:]) |
|
1949 | self.update_cache(line[1:]) | |
1921 | else: |
|
1950 | else: | |
1922 | # build a block of code (maybe a single line) for execution |
|
1951 | # build a block of code (maybe a single line) for execution | |
1923 | block = line |
|
1952 | block = line | |
1924 | try: |
|
1953 | try: | |
1925 | next = filelines[lnum] # lnum has already incremented |
|
1954 | next = filelines[lnum] # lnum has already incremented | |
1926 | except: |
|
1955 | except: | |
1927 | next = None |
|
1956 | next = None | |
1928 | while next and indent_re.match(next): |
|
1957 | while next and indent_re.match(next): | |
1929 | block += next |
|
1958 | block += next | |
1930 | lnum += 1 |
|
1959 | lnum += 1 | |
1931 | try: |
|
1960 | try: | |
1932 | next = filelines[lnum] |
|
1961 | next = filelines[lnum] | |
1933 | except: |
|
1962 | except: | |
1934 | next = None |
|
1963 | next = None | |
1935 | # now execute the block of one or more lines |
|
1964 | # now execute the block of one or more lines | |
1936 | try: |
|
1965 | try: | |
1937 | exec block in globs,locs |
|
1966 | exec block in globs,locs | |
1938 | self.update_cache(block.rstrip()) |
|
1967 | self.update_cache(block.rstrip()) | |
1939 | except SystemExit: |
|
1968 | except SystemExit: | |
1940 | pass |
|
1969 | pass | |
1941 | except: |
|
1970 | except: | |
1942 | badblocks.append(block.rstrip()) |
|
1971 | badblocks.append(block.rstrip()) | |
1943 | if kw['quiet']: # restore stdout |
|
1972 | if kw['quiet']: # restore stdout | |
1944 | sys.stdout.close() |
|
1973 | sys.stdout.close() | |
1945 | sys.stdout = stdout_save |
|
1974 | sys.stdout = stdout_save | |
1946 | print 'Finished replaying log file <%s>' % fname |
|
1975 | print 'Finished replaying log file <%s>' % fname | |
1947 | if badblocks: |
|
1976 | if badblocks: | |
1948 | print >> sys.stderr, ('\nThe following lines/blocks in file ' |
|
1977 | print >> sys.stderr, ('\nThe following lines/blocks in file ' | |
1949 | '<%s> reported errors:' % fname) |
|
1978 | '<%s> reported errors:' % fname) | |
1950 |
|
1979 | |||
1951 | for badline in badblocks: |
|
1980 | for badline in badblocks: | |
1952 | print >> sys.stderr, badline |
|
1981 | print >> sys.stderr, badline | |
1953 | else: # regular file execution |
|
1982 | else: # regular file execution | |
1954 | try: |
|
1983 | try: | |
1955 | execfile(fname,*where) |
|
1984 | execfile(fname,*where) | |
1956 | except SyntaxError: |
|
1985 | except SyntaxError: | |
1957 |
etype, |
|
1986 | etype,evalue = sys.exc_info()[:2] | |
1958 | self.SyntaxTB(etype,evalue,[]) |
|
1987 | self.SyntaxTB(etype,evalue,[]) | |
1959 | warn('Failure executing file: <%s>' % fname) |
|
1988 | warn('Failure executing file: <%s>' % fname) | |
1960 | except SystemExit,status: |
|
1989 | except SystemExit,status: | |
1961 | if not kw['exit_ignore']: |
|
1990 | if not kw['exit_ignore']: | |
1962 | self.InteractiveTB() |
|
1991 | self.InteractiveTB() | |
1963 | warn('Failure executing file: <%s>' % fname) |
|
1992 | warn('Failure executing file: <%s>' % fname) | |
1964 | except: |
|
1993 | except: | |
1965 | self.InteractiveTB() |
|
1994 | self.InteractiveTB() | |
1966 | warn('Failure executing file: <%s>' % fname) |
|
1995 | warn('Failure executing file: <%s>' % fname) | |
1967 |
|
1996 | |||
1968 | #************************* end of file <iplib.py> ***************************** |
|
1997 | #************************* end of file <iplib.py> ***************************** |
@@ -1,739 +1,735 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | IPython -- An enhanced Interactive Python |
|
3 | IPython -- An enhanced Interactive Python | |
4 |
|
4 | |||
5 | Requires Python 2.1 or better. |
|
5 | Requires Python 2.1 or better. | |
6 |
|
6 | |||
7 | This file contains the main make_IPython() starter function. |
|
7 | This file contains the main make_IPython() starter function. | |
8 |
|
8 | |||
9 |
$Id: ipmaker.py 96 |
|
9 | $Id: ipmaker.py 965 2005-12-28 23:23:09Z fperez $""" | |
10 |
|
10 | |||
11 | #***************************************************************************** |
|
11 | #***************************************************************************** | |
12 | # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu> |
|
12 | # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu> | |
13 | # |
|
13 | # | |
14 | # Distributed under the terms of the BSD License. The full license is in |
|
14 | # Distributed under the terms of the BSD License. The full license is in | |
15 | # the file COPYING, distributed as part of this software. |
|
15 | # the file COPYING, distributed as part of this software. | |
16 | #***************************************************************************** |
|
16 | #***************************************************************************** | |
17 |
|
17 | |||
18 | from IPython import Release |
|
18 | from IPython import Release | |
19 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
19 | __author__ = '%s <%s>' % Release.authors['Fernando'] | |
20 | __license__ = Release.license |
|
20 | __license__ = Release.license | |
21 | __version__ = Release.version |
|
21 | __version__ = Release.version | |
22 |
|
22 | |||
23 | credits._Printer__data = """ |
|
23 | credits._Printer__data = """ | |
24 | Python: %s |
|
24 | Python: %s | |
25 |
|
25 | |||
26 | IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users. |
|
26 | IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users. | |
27 | See http://ipython.scipy.org for more information.""" \ |
|
27 | See http://ipython.scipy.org for more information.""" \ | |
28 | % credits._Printer__data |
|
28 | % credits._Printer__data | |
29 |
|
29 | |||
30 | copyright._Printer__data += """ |
|
30 | copyright._Printer__data += """ | |
31 |
|
31 | |||
32 | Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray. |
|
32 | Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray. | |
33 | All Rights Reserved.""" |
|
33 | All Rights Reserved.""" | |
34 |
|
34 | |||
35 | #**************************************************************************** |
|
35 | #**************************************************************************** | |
36 | # Required modules |
|
36 | # Required modules | |
37 |
|
37 | |||
38 | # From the standard library |
|
38 | # From the standard library | |
39 | import __main__ |
|
39 | import __main__ | |
40 | import __builtin__ |
|
40 | import __builtin__ | |
41 | import os |
|
41 | import os | |
42 | import re |
|
42 | import re | |
43 | import sys |
|
43 | import sys | |
44 | import types |
|
44 | import types | |
45 | from pprint import pprint,pformat |
|
45 | from pprint import pprint,pformat | |
46 |
|
46 | |||
47 | # Our own |
|
47 | # Our own | |
48 | from IPython import DPyGetOpt |
|
48 | from IPython import DPyGetOpt | |
49 | from IPython.Struct import Struct |
|
49 | from IPython.Struct import Struct | |
50 | from IPython.OutputTrap import OutputTrap |
|
50 | from IPython.OutputTrap import OutputTrap | |
51 | from IPython.ConfigLoader import ConfigLoader |
|
51 | from IPython.ConfigLoader import ConfigLoader | |
52 | from IPython.iplib import InteractiveShell,qw_lol,import_fail_info |
|
52 | from IPython.iplib import InteractiveShell,qw_lol,import_fail_info | |
53 | from IPython.usage import cmd_line_usage,interactive_usage |
|
53 | from IPython.usage import cmd_line_usage,interactive_usage | |
54 | from IPython.Prompts import CachedOutput |
|
54 | from IPython.Prompts import CachedOutput | |
55 | from IPython.genutils import * |
|
55 | from IPython.genutils import * | |
56 |
|
56 | |||
57 | #----------------------------------------------------------------------------- |
|
57 | #----------------------------------------------------------------------------- | |
58 | def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1, |
|
58 | def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1, | |
59 | rc_override=None,shell_class=InteractiveShell, |
|
59 | rc_override=None,shell_class=InteractiveShell, | |
60 | embedded=False,**kw): |
|
60 | embedded=False,**kw): | |
61 | """This is a dump of IPython into a single function. |
|
61 | """This is a dump of IPython into a single function. | |
62 |
|
62 | |||
63 | Later it will have to be broken up in a sensible manner. |
|
63 | Later it will have to be broken up in a sensible manner. | |
64 |
|
64 | |||
65 | Arguments: |
|
65 | Arguments: | |
66 |
|
66 | |||
67 | - argv: a list similar to sys.argv[1:]. It should NOT contain the desired |
|
67 | - argv: a list similar to sys.argv[1:]. It should NOT contain the desired | |
68 | script name, b/c DPyGetOpt strips the first argument only for the real |
|
68 | script name, b/c DPyGetOpt strips the first argument only for the real | |
69 | sys.argv. |
|
69 | sys.argv. | |
70 |
|
70 | |||
71 | - user_ns: a dict to be used as the user's namespace.""" |
|
71 | - user_ns: a dict to be used as the user's namespace.""" | |
72 |
|
72 | |||
73 | #---------------------------------------------------------------------- |
|
73 | #---------------------------------------------------------------------- | |
74 | # Defaults and initialization |
|
74 | # Defaults and initialization | |
75 |
|
75 | |||
76 | # For developer debugging, deactivates crash handler and uses pdb. |
|
76 | # For developer debugging, deactivates crash handler and uses pdb. | |
77 | DEVDEBUG = False |
|
77 | DEVDEBUG = False | |
78 |
|
78 | |||
79 | if argv is None: |
|
79 | if argv is None: | |
80 | argv = sys.argv |
|
80 | argv = sys.argv | |
81 |
|
81 | |||
82 | # __IP is the main global that lives throughout and represents the whole |
|
82 | # __IP is the main global that lives throughout and represents the whole | |
83 | # application. If the user redefines it, all bets are off as to what |
|
83 | # application. If the user redefines it, all bets are off as to what | |
84 | # happens. |
|
84 | # happens. | |
85 |
|
85 | |||
86 | # __IP is the name of he global which the caller will have accessible as |
|
86 | # __IP is the name of he global which the caller will have accessible as | |
87 | # __IP.name. We set its name via the first parameter passed to |
|
87 | # __IP.name. We set its name via the first parameter passed to | |
88 | # InteractiveShell: |
|
88 | # InteractiveShell: | |
89 |
|
89 | |||
90 | IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns, |
|
90 | IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns, | |
91 | embedded=embedded,**kw) |
|
91 | embedded=embedded,**kw) | |
92 |
|
92 | |||
93 | # Put 'help' in the user namespace |
|
93 | # Put 'help' in the user namespace | |
94 | from site import _Helper |
|
94 | from site import _Helper | |
95 | IP.user_ns['help'] = _Helper() |
|
95 | IP.user_ns['help'] = _Helper() | |
96 |
|
96 | |||
|
97 | ||||
97 | if DEVDEBUG: |
|
98 | if DEVDEBUG: | |
98 | # For developer debugging only (global flag) |
|
99 | # For developer debugging only (global flag) | |
99 | from IPython import ultraTB |
|
100 | from IPython import ultraTB | |
100 | sys.excepthook = ultraTB.VerboseTB(call_pdb=1) |
|
101 | sys.excepthook = ultraTB.VerboseTB(call_pdb=1) | |
101 | else: |
|
|||
102 | # IPython itself shouldn't crash. This will produce a detailed |
|
|||
103 | # post-mortem if it does |
|
|||
104 | from IPython import CrashHandler |
|
|||
105 | sys.excepthook = CrashHandler.CrashHandler(IP) |
|
|||
106 |
|
102 | |||
107 | IP.BANNER_PARTS = ['Python %s\n' |
|
103 | IP.BANNER_PARTS = ['Python %s\n' | |
108 | 'Type "copyright", "credits" or "license" ' |
|
104 | 'Type "copyright", "credits" or "license" ' | |
109 | 'for more information.\n' |
|
105 | 'for more information.\n' | |
110 | % (sys.version.split('\n')[0],), |
|
106 | % (sys.version.split('\n')[0],), | |
111 | "IPython %s -- An enhanced Interactive Python." |
|
107 | "IPython %s -- An enhanced Interactive Python." | |
112 | % (__version__,), |
|
108 | % (__version__,), | |
113 | """? -> Introduction to IPython's features. |
|
109 | """? -> Introduction to IPython's features. | |
114 | %magic -> Information about IPython's 'magic' % functions. |
|
110 | %magic -> Information about IPython's 'magic' % functions. | |
115 | help -> Python's own help system. |
|
111 | help -> Python's own help system. | |
116 | object? -> Details about 'object'. ?object also works, ?? prints more. |
|
112 | object? -> Details about 'object'. ?object also works, ?? prints more. | |
117 | """ ] |
|
113 | """ ] | |
118 |
|
114 | |||
119 | IP.usage = interactive_usage |
|
115 | IP.usage = interactive_usage | |
120 |
|
116 | |||
121 | # Platform-dependent suffix and directory names. We use _ipython instead |
|
117 | # Platform-dependent suffix and directory names. We use _ipython instead | |
122 | # of .ipython under win32 b/c there's software that breaks with .named |
|
118 | # of .ipython under win32 b/c there's software that breaks with .named | |
123 | # directories on that platform. |
|
119 | # directories on that platform. | |
124 | if os.name == 'posix': |
|
120 | if os.name == 'posix': | |
125 | rc_suffix = '' |
|
121 | rc_suffix = '' | |
126 | ipdir_def = '.ipython' |
|
122 | ipdir_def = '.ipython' | |
127 | else: |
|
123 | else: | |
128 | rc_suffix = '.ini' |
|
124 | rc_suffix = '.ini' | |
129 | ipdir_def = '_ipython' |
|
125 | ipdir_def = '_ipython' | |
130 |
|
126 | |||
131 | # default directory for configuration |
|
127 | # default directory for configuration | |
132 | ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR', |
|
128 | ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR', | |
133 | os.path.join(IP.home_dir,ipdir_def))) |
|
129 | os.path.join(IP.home_dir,ipdir_def))) | |
134 |
|
130 | |||
135 | # we need the directory where IPython itself is installed |
|
131 | # we need the directory where IPython itself is installed | |
136 | import IPython |
|
132 | import IPython | |
137 | IPython_dir = os.path.dirname(IPython.__file__) |
|
133 | IPython_dir = os.path.dirname(IPython.__file__) | |
138 | del IPython |
|
134 | del IPython | |
139 |
|
135 | |||
140 | #------------------------------------------------------------------------- |
|
136 | #------------------------------------------------------------------------- | |
141 | # Command line handling |
|
137 | # Command line handling | |
142 |
|
138 | |||
143 | # Valid command line options (uses DPyGetOpt syntax, like Perl's |
|
139 | # Valid command line options (uses DPyGetOpt syntax, like Perl's | |
144 | # GetOpt::Long) |
|
140 | # GetOpt::Long) | |
145 |
|
141 | |||
146 | # Any key not listed here gets deleted even if in the file (like session |
|
142 | # Any key not listed here gets deleted even if in the file (like session | |
147 | # or profile). That's deliberate, to maintain the rc namespace clean. |
|
143 | # or profile). That's deliberate, to maintain the rc namespace clean. | |
148 |
|
144 | |||
149 | # Each set of options appears twice: under _conv only the names are |
|
145 | # Each set of options appears twice: under _conv only the names are | |
150 | # listed, indicating which type they must be converted to when reading the |
|
146 | # listed, indicating which type they must be converted to when reading the | |
151 | # ipythonrc file. And under DPyGetOpt they are listed with the regular |
|
147 | # ipythonrc file. And under DPyGetOpt they are listed with the regular | |
152 | # DPyGetOpt syntax (=s,=i,:f,etc). |
|
148 | # DPyGetOpt syntax (=s,=i,:f,etc). | |
153 |
|
149 | |||
154 | # Make sure there's a space before each end of line (they get auto-joined!) |
|
150 | # Make sure there's a space before each end of line (they get auto-joined!) | |
155 | cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i ' |
|
151 | cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i ' | |
156 | 'c=s classic|cl color_info! colors=s confirm_exit! ' |
|
152 | 'c=s classic|cl color_info! colors=s confirm_exit! ' | |
157 | 'debug! deep_reload! editor=s log|l messages! nosep pdb! ' |
|
153 | 'debug! deep_reload! editor=s log|l messages! nosep pdb! ' | |
158 | 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s ' |
|
154 | 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s ' | |
159 | 'quick screen_length|sl=i prompts_pad_left=i ' |
|
155 | 'quick screen_length|sl=i prompts_pad_left=i ' | |
160 | 'logfile|lf=s logplay|lp=s profile|p=s ' |
|
156 | 'logfile|lf=s logplay|lp=s profile|p=s ' | |
161 | 'readline! readline_merge_completions! ' |
|
157 | 'readline! readline_merge_completions! ' | |
162 | 'readline_omit__names! ' |
|
158 | 'readline_omit__names! ' | |
163 | 'rcfile=s separate_in|si=s separate_out|so=s ' |
|
159 | 'rcfile=s separate_in|si=s separate_out|so=s ' | |
164 | 'separate_out2|so2=s xmode=s wildcards_case_sensitive! ' |
|
160 | 'separate_out2|so2=s xmode=s wildcards_case_sensitive! ' | |
165 | 'magic_docstrings system_verbose! ' |
|
161 | 'magic_docstrings system_verbose! ' | |
166 | 'multi_line_specials! ' |
|
162 | 'multi_line_specials! ' | |
167 | 'autoedit_syntax!') |
|
163 | 'autoedit_syntax!') | |
168 |
|
164 | |||
169 | # Options that can *only* appear at the cmd line (not in rcfiles). |
|
165 | # Options that can *only* appear at the cmd line (not in rcfiles). | |
170 |
|
166 | |||
171 | # The "ignore" option is a kludge so that Emacs buffers don't crash, since |
|
167 | # The "ignore" option is a kludge so that Emacs buffers don't crash, since | |
172 | # the 'C-c !' command in emacs automatically appends a -i option at the end. |
|
168 | # the 'C-c !' command in emacs automatically appends a -i option at the end. | |
173 | cmdline_only = ('help ignore|i ipythondir=s Version upgrade ' |
|
169 | cmdline_only = ('help ignore|i ipythondir=s Version upgrade ' | |
174 | 'gthread! qthread! wthread! pylab! tk!') |
|
170 | 'gthread! qthread! wthread! pylab! tk!') | |
175 |
|
171 | |||
176 | # Build the actual name list to be used by DPyGetOpt |
|
172 | # Build the actual name list to be used by DPyGetOpt | |
177 | opts_names = qw(cmdline_opts) + qw(cmdline_only) |
|
173 | opts_names = qw(cmdline_opts) + qw(cmdline_only) | |
178 |
|
174 | |||
179 | # Set sensible command line defaults. |
|
175 | # Set sensible command line defaults. | |
180 | # This should have everything from cmdline_opts and cmdline_only |
|
176 | # This should have everything from cmdline_opts and cmdline_only | |
181 | opts_def = Struct(autocall = 1, |
|
177 | opts_def = Struct(autocall = 1, | |
182 | autoedit_syntax = 1, |
|
178 | autoedit_syntax = 1, | |
183 | autoindent=0, |
|
179 | autoindent=0, | |
184 | automagic = 1, |
|
180 | automagic = 1, | |
185 | banner = 1, |
|
181 | banner = 1, | |
186 | cache_size = 1000, |
|
182 | cache_size = 1000, | |
187 | c = '', |
|
183 | c = '', | |
188 | classic = 0, |
|
184 | classic = 0, | |
189 | colors = 'NoColor', |
|
185 | colors = 'NoColor', | |
190 | color_info = 0, |
|
186 | color_info = 0, | |
191 | confirm_exit = 1, |
|
187 | confirm_exit = 1, | |
192 | debug = 0, |
|
188 | debug = 0, | |
193 | deep_reload = 0, |
|
189 | deep_reload = 0, | |
194 | editor = '0', |
|
190 | editor = '0', | |
195 | help = 0, |
|
191 | help = 0, | |
196 | ignore = 0, |
|
192 | ignore = 0, | |
197 | ipythondir = ipythondir, |
|
193 | ipythondir = ipythondir, | |
198 | log = 0, |
|
194 | log = 0, | |
199 | logfile = '', |
|
195 | logfile = '', | |
200 | logplay = '', |
|
196 | logplay = '', | |
201 | multi_line_specials = 1, |
|
197 | multi_line_specials = 1, | |
202 | messages = 1, |
|
198 | messages = 1, | |
203 | nosep = 0, |
|
199 | nosep = 0, | |
204 | pdb = 0, |
|
200 | pdb = 0, | |
205 | pprint = 0, |
|
201 | pprint = 0, | |
206 | profile = '', |
|
202 | profile = '', | |
207 | prompt_in1 = 'In [\\#]: ', |
|
203 | prompt_in1 = 'In [\\#]: ', | |
208 | prompt_in2 = ' .\\D.: ', |
|
204 | prompt_in2 = ' .\\D.: ', | |
209 | prompt_out = 'Out[\\#]: ', |
|
205 | prompt_out = 'Out[\\#]: ', | |
210 | prompts_pad_left = 1, |
|
206 | prompts_pad_left = 1, | |
211 | quick = 0, |
|
207 | quick = 0, | |
212 | readline = 1, |
|
208 | readline = 1, | |
213 | readline_merge_completions = 1, |
|
209 | readline_merge_completions = 1, | |
214 | readline_omit__names = 0, |
|
210 | readline_omit__names = 0, | |
215 | rcfile = 'ipythonrc' + rc_suffix, |
|
211 | rcfile = 'ipythonrc' + rc_suffix, | |
216 | screen_length = 0, |
|
212 | screen_length = 0, | |
217 | separate_in = '\n', |
|
213 | separate_in = '\n', | |
218 | separate_out = '\n', |
|
214 | separate_out = '\n', | |
219 | separate_out2 = '', |
|
215 | separate_out2 = '', | |
220 | system_verbose = 0, |
|
216 | system_verbose = 0, | |
221 | gthread = 0, |
|
217 | gthread = 0, | |
222 | qthread = 0, |
|
218 | qthread = 0, | |
223 | wthread = 0, |
|
219 | wthread = 0, | |
224 | pylab = 0, |
|
220 | pylab = 0, | |
225 | tk = 0, |
|
221 | tk = 0, | |
226 | upgrade = 0, |
|
222 | upgrade = 0, | |
227 | Version = 0, |
|
223 | Version = 0, | |
228 | xmode = 'Verbose', |
|
224 | xmode = 'Verbose', | |
229 | wildcards_case_sensitive = 1, |
|
225 | wildcards_case_sensitive = 1, | |
230 | magic_docstrings = 0, # undocumented, for doc generation |
|
226 | magic_docstrings = 0, # undocumented, for doc generation | |
231 | ) |
|
227 | ) | |
232 |
|
228 | |||
233 | # Things that will *only* appear in rcfiles (not at the command line). |
|
229 | # Things that will *only* appear in rcfiles (not at the command line). | |
234 | # Make sure there's a space before each end of line (they get auto-joined!) |
|
230 | # Make sure there's a space before each end of line (they get auto-joined!) | |
235 | rcfile_opts = { qwflat: 'include import_mod import_all execfile ', |
|
231 | rcfile_opts = { qwflat: 'include import_mod import_all execfile ', | |
236 | qw_lol: 'import_some ', |
|
232 | qw_lol: 'import_some ', | |
237 | # for things with embedded whitespace: |
|
233 | # for things with embedded whitespace: | |
238 | list_strings:'execute alias readline_parse_and_bind ', |
|
234 | list_strings:'execute alias readline_parse_and_bind ', | |
239 | # Regular strings need no conversion: |
|
235 | # Regular strings need no conversion: | |
240 | None:'readline_remove_delims ', |
|
236 | None:'readline_remove_delims ', | |
241 | } |
|
237 | } | |
242 | # Default values for these |
|
238 | # Default values for these | |
243 | rc_def = Struct(include = [], |
|
239 | rc_def = Struct(include = [], | |
244 | import_mod = [], |
|
240 | import_mod = [], | |
245 | import_all = [], |
|
241 | import_all = [], | |
246 | import_some = [[]], |
|
242 | import_some = [[]], | |
247 | execute = [], |
|
243 | execute = [], | |
248 | execfile = [], |
|
244 | execfile = [], | |
249 | alias = [], |
|
245 | alias = [], | |
250 | readline_parse_and_bind = [], |
|
246 | readline_parse_and_bind = [], | |
251 | readline_remove_delims = '', |
|
247 | readline_remove_delims = '', | |
252 | ) |
|
248 | ) | |
253 |
|
249 | |||
254 | # Build the type conversion dictionary from the above tables: |
|
250 | # Build the type conversion dictionary from the above tables: | |
255 | typeconv = rcfile_opts.copy() |
|
251 | typeconv = rcfile_opts.copy() | |
256 | typeconv.update(optstr2types(cmdline_opts)) |
|
252 | typeconv.update(optstr2types(cmdline_opts)) | |
257 |
|
253 | |||
258 | # FIXME: the None key appears in both, put that back together by hand. Ugly! |
|
254 | # FIXME: the None key appears in both, put that back together by hand. Ugly! | |
259 | typeconv[None] += ' ' + rcfile_opts[None] |
|
255 | typeconv[None] += ' ' + rcfile_opts[None] | |
260 |
|
256 | |||
261 | # Remove quotes at ends of all strings (used to protect spaces) |
|
257 | # Remove quotes at ends of all strings (used to protect spaces) | |
262 | typeconv[unquote_ends] = typeconv[None] |
|
258 | typeconv[unquote_ends] = typeconv[None] | |
263 | del typeconv[None] |
|
259 | del typeconv[None] | |
264 |
|
260 | |||
265 | # Build the list we'll use to make all config decisions with defaults: |
|
261 | # Build the list we'll use to make all config decisions with defaults: | |
266 | opts_all = opts_def.copy() |
|
262 | opts_all = opts_def.copy() | |
267 | opts_all.update(rc_def) |
|
263 | opts_all.update(rc_def) | |
268 |
|
264 | |||
269 | # Build conflict resolver for recursive loading of config files: |
|
265 | # Build conflict resolver for recursive loading of config files: | |
270 | # - preserve means the outermost file maintains the value, it is not |
|
266 | # - preserve means the outermost file maintains the value, it is not | |
271 | # overwritten if an included file has the same key. |
|
267 | # overwritten if an included file has the same key. | |
272 | # - add_flip applies + to the two values, so it better make sense to add |
|
268 | # - add_flip applies + to the two values, so it better make sense to add | |
273 | # those types of keys. But it flips them first so that things loaded |
|
269 | # those types of keys. But it flips them first so that things loaded | |
274 | # deeper in the inclusion chain have lower precedence. |
|
270 | # deeper in the inclusion chain have lower precedence. | |
275 | conflict = {'preserve': ' '.join([ typeconv[int], |
|
271 | conflict = {'preserve': ' '.join([ typeconv[int], | |
276 | typeconv[unquote_ends] ]), |
|
272 | typeconv[unquote_ends] ]), | |
277 | 'add_flip': ' '.join([ typeconv[qwflat], |
|
273 | 'add_flip': ' '.join([ typeconv[qwflat], | |
278 | typeconv[qw_lol], |
|
274 | typeconv[qw_lol], | |
279 | typeconv[list_strings] ]) |
|
275 | typeconv[list_strings] ]) | |
280 | } |
|
276 | } | |
281 |
|
277 | |||
282 | # Now actually process the command line |
|
278 | # Now actually process the command line | |
283 | getopt = DPyGetOpt.DPyGetOpt() |
|
279 | getopt = DPyGetOpt.DPyGetOpt() | |
284 | getopt.setIgnoreCase(0) |
|
280 | getopt.setIgnoreCase(0) | |
285 |
|
281 | |||
286 | getopt.parseConfiguration(opts_names) |
|
282 | getopt.parseConfiguration(opts_names) | |
287 |
|
283 | |||
288 | try: |
|
284 | try: | |
289 | getopt.processArguments(argv) |
|
285 | getopt.processArguments(argv) | |
290 | except: |
|
286 | except: | |
291 | print cmd_line_usage |
|
287 | print cmd_line_usage | |
292 | warn('\nError in Arguments: ' + `sys.exc_value`) |
|
288 | warn('\nError in Arguments: ' + `sys.exc_value`) | |
293 | sys.exit(1) |
|
289 | sys.exit(1) | |
294 |
|
290 | |||
295 | # convert the options dict to a struct for much lighter syntax later |
|
291 | # convert the options dict to a struct for much lighter syntax later | |
296 | opts = Struct(getopt.optionValues) |
|
292 | opts = Struct(getopt.optionValues) | |
297 | args = getopt.freeValues |
|
293 | args = getopt.freeValues | |
298 |
|
294 | |||
299 | # this is the struct (which has default values at this point) with which |
|
295 | # this is the struct (which has default values at this point) with which | |
300 | # we make all decisions: |
|
296 | # we make all decisions: | |
301 | opts_all.update(opts) |
|
297 | opts_all.update(opts) | |
302 |
|
298 | |||
303 | # Options that force an immediate exit |
|
299 | # Options that force an immediate exit | |
304 | if opts_all.help: |
|
300 | if opts_all.help: | |
305 | page(cmd_line_usage) |
|
301 | page(cmd_line_usage) | |
306 | sys.exit() |
|
302 | sys.exit() | |
307 |
|
303 | |||
308 | if opts_all.Version: |
|
304 | if opts_all.Version: | |
309 | print __version__ |
|
305 | print __version__ | |
310 | sys.exit() |
|
306 | sys.exit() | |
311 |
|
307 | |||
312 | if opts_all.magic_docstrings: |
|
308 | if opts_all.magic_docstrings: | |
313 | IP.magic_magic('-latex') |
|
309 | IP.magic_magic('-latex') | |
314 | sys.exit() |
|
310 | sys.exit() | |
315 |
|
311 | |||
316 | # Create user config directory if it doesn't exist. This must be done |
|
312 | # Create user config directory if it doesn't exist. This must be done | |
317 | # *after* getting the cmd line options. |
|
313 | # *after* getting the cmd line options. | |
318 | if not os.path.isdir(opts_all.ipythondir): |
|
314 | if not os.path.isdir(opts_all.ipythondir): | |
319 | IP.user_setup(opts_all.ipythondir,rc_suffix,'install') |
|
315 | IP.user_setup(opts_all.ipythondir,rc_suffix,'install') | |
320 |
|
316 | |||
321 | # upgrade user config files while preserving a copy of the originals |
|
317 | # upgrade user config files while preserving a copy of the originals | |
322 | if opts_all.upgrade: |
|
318 | if opts_all.upgrade: | |
323 | IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade') |
|
319 | IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade') | |
324 |
|
320 | |||
325 | # check mutually exclusive options in the *original* command line |
|
321 | # check mutually exclusive options in the *original* command line | |
326 | mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'), |
|
322 | mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'), | |
327 | qw('classic profile'),qw('classic rcfile')]) |
|
323 | qw('classic profile'),qw('classic rcfile')]) | |
328 |
|
324 | |||
329 | # default logfilename used when -log is called. |
|
325 | # default logfilename used when -log is called. | |
330 | IP.LOGDEF = 'ipython.log' |
|
326 | IP.LOGDEF = 'ipython.log' | |
331 |
|
327 | |||
332 | #--------------------------------------------------------------------------- |
|
328 | #--------------------------------------------------------------------------- | |
333 | # Log replay |
|
329 | # Log replay | |
334 |
|
330 | |||
335 | # if -logplay, we need to 'become' the other session. That basically means |
|
331 | # if -logplay, we need to 'become' the other session. That basically means | |
336 | # replacing the current command line environment with that of the old |
|
332 | # replacing the current command line environment with that of the old | |
337 | # session and moving on. |
|
333 | # session and moving on. | |
338 |
|
334 | |||
339 | # this is needed so that later we know we're in session reload mode, as |
|
335 | # this is needed so that later we know we're in session reload mode, as | |
340 | # opts_all will get overwritten: |
|
336 | # opts_all will get overwritten: | |
341 | load_logplay = 0 |
|
337 | load_logplay = 0 | |
342 |
|
338 | |||
343 | if opts_all.logplay: |
|
339 | if opts_all.logplay: | |
344 | load_logplay = opts_all.logplay |
|
340 | load_logplay = opts_all.logplay | |
345 | opts_debug_save = opts_all.debug |
|
341 | opts_debug_save = opts_all.debug | |
346 | try: |
|
342 | try: | |
347 | logplay = open(opts_all.logplay) |
|
343 | logplay = open(opts_all.logplay) | |
348 | except IOError: |
|
344 | except IOError: | |
349 | if opts_all.debug: IP.InteractiveTB() |
|
345 | if opts_all.debug: IP.InteractiveTB() | |
350 | warn('Could not open logplay file '+`opts_all.logplay`) |
|
346 | warn('Could not open logplay file '+`opts_all.logplay`) | |
351 | # restore state as if nothing had happened and move on, but make |
|
347 | # restore state as if nothing had happened and move on, but make | |
352 | # sure that later we don't try to actually load the session file |
|
348 | # sure that later we don't try to actually load the session file | |
353 | logplay = None |
|
349 | logplay = None | |
354 | load_logplay = 0 |
|
350 | load_logplay = 0 | |
355 | del opts_all.logplay |
|
351 | del opts_all.logplay | |
356 | else: |
|
352 | else: | |
357 | try: |
|
353 | try: | |
358 | logplay.readline() |
|
354 | logplay.readline() | |
359 | logplay.readline(); |
|
355 | logplay.readline(); | |
360 | # this reloads that session's command line |
|
356 | # this reloads that session's command line | |
361 | cmd = logplay.readline()[6:] |
|
357 | cmd = logplay.readline()[6:] | |
362 | exec cmd |
|
358 | exec cmd | |
363 | # restore the true debug flag given so that the process of |
|
359 | # restore the true debug flag given so that the process of | |
364 | # session loading itself can be monitored. |
|
360 | # session loading itself can be monitored. | |
365 | opts.debug = opts_debug_save |
|
361 | opts.debug = opts_debug_save | |
366 | # save the logplay flag so later we don't overwrite the log |
|
362 | # save the logplay flag so later we don't overwrite the log | |
367 | opts.logplay = load_logplay |
|
363 | opts.logplay = load_logplay | |
368 | # now we must update our own structure with defaults |
|
364 | # now we must update our own structure with defaults | |
369 | opts_all.update(opts) |
|
365 | opts_all.update(opts) | |
370 | # now load args |
|
366 | # now load args | |
371 | cmd = logplay.readline()[6:] |
|
367 | cmd = logplay.readline()[6:] | |
372 | exec cmd |
|
368 | exec cmd | |
373 | logplay.close() |
|
369 | logplay.close() | |
374 | except: |
|
370 | except: | |
375 | logplay.close() |
|
371 | logplay.close() | |
376 | if opts_all.debug: IP.InteractiveTB() |
|
372 | if opts_all.debug: IP.InteractiveTB() | |
377 | warn("Logplay file lacking full configuration information.\n" |
|
373 | warn("Logplay file lacking full configuration information.\n" | |
378 | "I'll try to read it, but some things may not work.") |
|
374 | "I'll try to read it, but some things may not work.") | |
379 |
|
375 | |||
380 | #------------------------------------------------------------------------- |
|
376 | #------------------------------------------------------------------------- | |
381 | # set up output traps: catch all output from files, being run, modules |
|
377 | # set up output traps: catch all output from files, being run, modules | |
382 | # loaded, etc. Then give it to the user in a clean form at the end. |
|
378 | # loaded, etc. Then give it to the user in a clean form at the end. | |
383 |
|
379 | |||
384 | msg_out = 'Output messages. ' |
|
380 | msg_out = 'Output messages. ' | |
385 | msg_err = 'Error messages. ' |
|
381 | msg_err = 'Error messages. ' | |
386 | msg_sep = '\n' |
|
382 | msg_sep = '\n' | |
387 | msg = Struct(config = OutputTrap('Configuration Loader',msg_out, |
|
383 | msg = Struct(config = OutputTrap('Configuration Loader',msg_out, | |
388 | msg_err,msg_sep,debug, |
|
384 | msg_err,msg_sep,debug, | |
389 | quiet_out=1), |
|
385 | quiet_out=1), | |
390 | user_exec = OutputTrap('User File Execution',msg_out, |
|
386 | user_exec = OutputTrap('User File Execution',msg_out, | |
391 | msg_err,msg_sep,debug), |
|
387 | msg_err,msg_sep,debug), | |
392 | logplay = OutputTrap('Log Loader',msg_out, |
|
388 | logplay = OutputTrap('Log Loader',msg_out, | |
393 | msg_err,msg_sep,debug), |
|
389 | msg_err,msg_sep,debug), | |
394 | summary = '' |
|
390 | summary = '' | |
395 | ) |
|
391 | ) | |
396 |
|
392 | |||
397 | #------------------------------------------------------------------------- |
|
393 | #------------------------------------------------------------------------- | |
398 | # Process user ipythonrc-type configuration files |
|
394 | # Process user ipythonrc-type configuration files | |
399 |
|
395 | |||
400 | # turn on output trapping and log to msg.config |
|
396 | # turn on output trapping and log to msg.config | |
401 | # remember that with debug on, trapping is actually disabled |
|
397 | # remember that with debug on, trapping is actually disabled | |
402 | msg.config.trap_all() |
|
398 | msg.config.trap_all() | |
403 |
|
399 | |||
404 | # look for rcfile in current or default directory |
|
400 | # look for rcfile in current or default directory | |
405 | try: |
|
401 | try: | |
406 | opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir) |
|
402 | opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir) | |
407 | except IOError: |
|
403 | except IOError: | |
408 | if opts_all.debug: IP.InteractiveTB() |
|
404 | if opts_all.debug: IP.InteractiveTB() | |
409 | warn('Configuration file %s not found. Ignoring request.' |
|
405 | warn('Configuration file %s not found. Ignoring request.' | |
410 | % (opts_all.rcfile) ) |
|
406 | % (opts_all.rcfile) ) | |
411 |
|
407 | |||
412 | # 'profiles' are a shorthand notation for config filenames |
|
408 | # 'profiles' are a shorthand notation for config filenames | |
413 | if opts_all.profile: |
|
409 | if opts_all.profile: | |
414 | try: |
|
410 | try: | |
415 | opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile |
|
411 | opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile | |
416 | + rc_suffix, |
|
412 | + rc_suffix, | |
417 | opts_all.ipythondir) |
|
413 | opts_all.ipythondir) | |
418 | except IOError: |
|
414 | except IOError: | |
419 | if opts_all.debug: IP.InteractiveTB() |
|
415 | if opts_all.debug: IP.InteractiveTB() | |
420 | opts.profile = '' # remove profile from options if invalid |
|
416 | opts.profile = '' # remove profile from options if invalid | |
421 | warn('Profile configuration file %s not found. Ignoring request.' |
|
417 | warn('Profile configuration file %s not found. Ignoring request.' | |
422 | % (opts_all.profile) ) |
|
418 | % (opts_all.profile) ) | |
423 |
|
419 | |||
424 | # load the config file |
|
420 | # load the config file | |
425 | rcfiledata = None |
|
421 | rcfiledata = None | |
426 | if opts_all.quick: |
|
422 | if opts_all.quick: | |
427 | print 'Launching IPython in quick mode. No config file read.' |
|
423 | print 'Launching IPython in quick mode. No config file read.' | |
428 | elif opts_all.classic: |
|
424 | elif opts_all.classic: | |
429 | print 'Launching IPython in classic mode. No config file read.' |
|
425 | print 'Launching IPython in classic mode. No config file read.' | |
430 | elif opts_all.rcfile: |
|
426 | elif opts_all.rcfile: | |
431 | try: |
|
427 | try: | |
432 | cfg_loader = ConfigLoader(conflict) |
|
428 | cfg_loader = ConfigLoader(conflict) | |
433 | rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv, |
|
429 | rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv, | |
434 | 'include',opts_all.ipythondir, |
|
430 | 'include',opts_all.ipythondir, | |
435 | purge = 1, |
|
431 | purge = 1, | |
436 | unique = conflict['preserve']) |
|
432 | unique = conflict['preserve']) | |
437 | except: |
|
433 | except: | |
438 | IP.InteractiveTB() |
|
434 | IP.InteractiveTB() | |
439 | warn('Problems loading configuration file '+ |
|
435 | warn('Problems loading configuration file '+ | |
440 | `opts_all.rcfile`+ |
|
436 | `opts_all.rcfile`+ | |
441 | '\nStarting with default -bare bones- configuration.') |
|
437 | '\nStarting with default -bare bones- configuration.') | |
442 | else: |
|
438 | else: | |
443 | warn('No valid configuration file found in either currrent directory\n'+ |
|
439 | warn('No valid configuration file found in either currrent directory\n'+ | |
444 | 'or in the IPython config. directory: '+`opts_all.ipythondir`+ |
|
440 | 'or in the IPython config. directory: '+`opts_all.ipythondir`+ | |
445 | '\nProceeding with internal defaults.') |
|
441 | '\nProceeding with internal defaults.') | |
446 |
|
442 | |||
447 | #------------------------------------------------------------------------ |
|
443 | #------------------------------------------------------------------------ | |
448 | # Set exception handlers in mode requested by user. |
|
444 | # Set exception handlers in mode requested by user. | |
449 | otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode |
|
445 | otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode | |
450 | IP.magic_xmode(opts_all.xmode) |
|
446 | IP.magic_xmode(opts_all.xmode) | |
451 | otrap.release_out() |
|
447 | otrap.release_out() | |
452 |
|
448 | |||
453 | #------------------------------------------------------------------------ |
|
449 | #------------------------------------------------------------------------ | |
454 | # Execute user config |
|
450 | # Execute user config | |
455 |
|
451 | |||
456 | # Create a valid config structure with the right precedence order: |
|
452 | # Create a valid config structure with the right precedence order: | |
457 | # defaults < rcfile < command line. This needs to be in the instance, so |
|
453 | # defaults < rcfile < command line. This needs to be in the instance, so | |
458 | # that method calls below that rely on it find it. |
|
454 | # that method calls below that rely on it find it. | |
459 | IP.rc = rc_def.copy() |
|
455 | IP.rc = rc_def.copy() | |
460 |
|
456 | |||
461 | # Work with a local alias inside this routine to avoid unnecessary |
|
457 | # Work with a local alias inside this routine to avoid unnecessary | |
462 | # attribute lookups. |
|
458 | # attribute lookups. | |
463 | IP_rc = IP.rc |
|
459 | IP_rc = IP.rc | |
464 |
|
460 | |||
465 | IP_rc.update(opts_def) |
|
461 | IP_rc.update(opts_def) | |
466 | if rcfiledata: |
|
462 | if rcfiledata: | |
467 | # now we can update |
|
463 | # now we can update | |
468 | IP_rc.update(rcfiledata) |
|
464 | IP_rc.update(rcfiledata) | |
469 | IP_rc.update(opts) |
|
465 | IP_rc.update(opts) | |
470 | IP_rc.update(rc_override) |
|
466 | IP_rc.update(rc_override) | |
471 |
|
467 | |||
472 | # Store the original cmd line for reference: |
|
468 | # Store the original cmd line for reference: | |
473 | IP_rc.opts = opts |
|
469 | IP_rc.opts = opts | |
474 | IP_rc.args = args |
|
470 | IP_rc.args = args | |
475 |
|
471 | |||
476 | # create a *runtime* Struct like rc for holding parameters which may be |
|
472 | # create a *runtime* Struct like rc for holding parameters which may be | |
477 | # created and/or modified by runtime user extensions. |
|
473 | # created and/or modified by runtime user extensions. | |
478 | IP.runtime_rc = Struct() |
|
474 | IP.runtime_rc = Struct() | |
479 |
|
475 | |||
480 | # from this point on, all config should be handled through IP_rc, |
|
476 | # from this point on, all config should be handled through IP_rc, | |
481 | # opts* shouldn't be used anymore. |
|
477 | # opts* shouldn't be used anymore. | |
482 |
|
478 | |||
483 | # add personal .ipython dir to sys.path so that users can put things in |
|
479 | # add personal .ipython dir to sys.path so that users can put things in | |
484 | # there for customization |
|
480 | # there for customization | |
485 | sys.path.append(IP_rc.ipythondir) |
|
481 | sys.path.append(IP_rc.ipythondir) | |
486 | sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran |
|
482 | sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran | |
487 |
|
483 | |||
488 | # update IP_rc with some special things that need manual |
|
484 | # update IP_rc with some special things that need manual | |
489 | # tweaks. Basically options which affect other options. I guess this |
|
485 | # tweaks. Basically options which affect other options. I guess this | |
490 | # should just be written so that options are fully orthogonal and we |
|
486 | # should just be written so that options are fully orthogonal and we | |
491 | # wouldn't worry about this stuff! |
|
487 | # wouldn't worry about this stuff! | |
492 |
|
488 | |||
493 | if IP_rc.classic: |
|
489 | if IP_rc.classic: | |
494 | IP_rc.quick = 1 |
|
490 | IP_rc.quick = 1 | |
495 | IP_rc.cache_size = 0 |
|
491 | IP_rc.cache_size = 0 | |
496 | IP_rc.pprint = 0 |
|
492 | IP_rc.pprint = 0 | |
497 | IP_rc.prompt_in1 = '>>> ' |
|
493 | IP_rc.prompt_in1 = '>>> ' | |
498 | IP_rc.prompt_in2 = '... ' |
|
494 | IP_rc.prompt_in2 = '... ' | |
499 | IP_rc.prompt_out = '' |
|
495 | IP_rc.prompt_out = '' | |
500 | IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0' |
|
496 | IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0' | |
501 | IP_rc.colors = 'NoColor' |
|
497 | IP_rc.colors = 'NoColor' | |
502 | IP_rc.xmode = 'Plain' |
|
498 | IP_rc.xmode = 'Plain' | |
503 |
|
499 | |||
504 | # configure readline |
|
500 | # configure readline | |
505 | # Define the history file for saving commands in between sessions |
|
501 | # Define the history file for saving commands in between sessions | |
506 | if IP_rc.profile: |
|
502 | if IP_rc.profile: | |
507 | histfname = 'history-%s' % IP_rc.profile |
|
503 | histfname = 'history-%s' % IP_rc.profile | |
508 | else: |
|
504 | else: | |
509 | histfname = 'history' |
|
505 | histfname = 'history' | |
510 | IP.histfile = os.path.join(opts_all.ipythondir,histfname) |
|
506 | IP.histfile = os.path.join(opts_all.ipythondir,histfname) | |
511 |
|
507 | |||
512 | # update exception handlers with rc file status |
|
508 | # update exception handlers with rc file status | |
513 | otrap.trap_out() # I don't want these messages ever. |
|
509 | otrap.trap_out() # I don't want these messages ever. | |
514 | IP.magic_xmode(IP_rc.xmode) |
|
510 | IP.magic_xmode(IP_rc.xmode) | |
515 | otrap.release_out() |
|
511 | otrap.release_out() | |
516 |
|
512 | |||
517 | # activate logging if requested and not reloading a log |
|
513 | # activate logging if requested and not reloading a log | |
518 | if IP_rc.logplay: |
|
514 | if IP_rc.logplay: | |
519 | IP.magic_logstart(IP_rc.logplay + ' append') |
|
515 | IP.magic_logstart(IP_rc.logplay + ' append') | |
520 | elif IP_rc.logfile: |
|
516 | elif IP_rc.logfile: | |
521 | IP.magic_logstart(IP_rc.logfile) |
|
517 | IP.magic_logstart(IP_rc.logfile) | |
522 | elif IP_rc.log: |
|
518 | elif IP_rc.log: | |
523 | IP.magic_logstart() |
|
519 | IP.magic_logstart() | |
524 |
|
520 | |||
525 | # find user editor so that it we don't have to look it up constantly |
|
521 | # find user editor so that it we don't have to look it up constantly | |
526 | if IP_rc.editor.strip()=='0': |
|
522 | if IP_rc.editor.strip()=='0': | |
527 | try: |
|
523 | try: | |
528 | ed = os.environ['EDITOR'] |
|
524 | ed = os.environ['EDITOR'] | |
529 | except KeyError: |
|
525 | except KeyError: | |
530 | if os.name == 'posix': |
|
526 | if os.name == 'posix': | |
531 | ed = 'vi' # the only one guaranteed to be there! |
|
527 | ed = 'vi' # the only one guaranteed to be there! | |
532 | else: |
|
528 | else: | |
533 | ed = 'notepad' # same in Windows! |
|
529 | ed = 'notepad' # same in Windows! | |
534 | IP_rc.editor = ed |
|
530 | IP_rc.editor = ed | |
535 |
|
531 | |||
536 | # Keep track of whether this is an embedded instance or not (useful for |
|
532 | # Keep track of whether this is an embedded instance or not (useful for | |
537 | # post-mortems). |
|
533 | # post-mortems). | |
538 | IP_rc.embedded = IP.embedded |
|
534 | IP_rc.embedded = IP.embedded | |
539 |
|
535 | |||
540 | # Recursive reload |
|
536 | # Recursive reload | |
541 | try: |
|
537 | try: | |
542 | from IPython import deep_reload |
|
538 | from IPython import deep_reload | |
543 | if IP_rc.deep_reload: |
|
539 | if IP_rc.deep_reload: | |
544 | __builtin__.reload = deep_reload.reload |
|
540 | __builtin__.reload = deep_reload.reload | |
545 | else: |
|
541 | else: | |
546 | __builtin__.dreload = deep_reload.reload |
|
542 | __builtin__.dreload = deep_reload.reload | |
547 | del deep_reload |
|
543 | del deep_reload | |
548 | except ImportError: |
|
544 | except ImportError: | |
549 | pass |
|
545 | pass | |
550 |
|
546 | |||
551 | # Save the current state of our namespace so that the interactive shell |
|
547 | # Save the current state of our namespace so that the interactive shell | |
552 | # can later know which variables have been created by us from config files |
|
548 | # can later know which variables have been created by us from config files | |
553 | # and loading. This way, loading a file (in any way) is treated just like |
|
549 | # and loading. This way, loading a file (in any way) is treated just like | |
554 | # defining things on the command line, and %who works as expected. |
|
550 | # defining things on the command line, and %who works as expected. | |
555 |
|
551 | |||
556 | # DON'T do anything that affects the namespace beyond this point! |
|
552 | # DON'T do anything that affects the namespace beyond this point! | |
557 | IP.internal_ns.update(__main__.__dict__) |
|
553 | IP.internal_ns.update(__main__.__dict__) | |
558 |
|
554 | |||
559 | #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who |
|
555 | #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who | |
560 |
|
556 | |||
561 | # Now run through the different sections of the users's config |
|
557 | # Now run through the different sections of the users's config | |
562 | if IP_rc.debug: |
|
558 | if IP_rc.debug: | |
563 | print 'Trying to execute the following configuration structure:' |
|
559 | print 'Trying to execute the following configuration structure:' | |
564 | print '(Things listed first are deeper in the inclusion tree and get' |
|
560 | print '(Things listed first are deeper in the inclusion tree and get' | |
565 | print 'loaded first).\n' |
|
561 | print 'loaded first).\n' | |
566 | pprint(IP_rc.__dict__) |
|
562 | pprint(IP_rc.__dict__) | |
567 |
|
563 | |||
568 | for mod in IP_rc.import_mod: |
|
564 | for mod in IP_rc.import_mod: | |
569 | try: |
|
565 | try: | |
570 | exec 'import '+mod in IP.user_ns |
|
566 | exec 'import '+mod in IP.user_ns | |
571 | except : |
|
567 | except : | |
572 | IP.InteractiveTB() |
|
568 | IP.InteractiveTB() | |
573 | import_fail_info(mod) |
|
569 | import_fail_info(mod) | |
574 |
|
570 | |||
575 | for mod_fn in IP_rc.import_some: |
|
571 | for mod_fn in IP_rc.import_some: | |
576 | if mod_fn == []: break |
|
572 | if mod_fn == []: break | |
577 | mod,fn = mod_fn[0],','.join(mod_fn[1:]) |
|
573 | mod,fn = mod_fn[0],','.join(mod_fn[1:]) | |
578 | try: |
|
574 | try: | |
579 | exec 'from '+mod+' import '+fn in IP.user_ns |
|
575 | exec 'from '+mod+' import '+fn in IP.user_ns | |
580 | except : |
|
576 | except : | |
581 | IP.InteractiveTB() |
|
577 | IP.InteractiveTB() | |
582 | import_fail_info(mod,fn) |
|
578 | import_fail_info(mod,fn) | |
583 |
|
579 | |||
584 | for mod in IP_rc.import_all: |
|
580 | for mod in IP_rc.import_all: | |
585 | try: |
|
581 | try: | |
586 | exec 'from '+mod+' import *' in IP.user_ns |
|
582 | exec 'from '+mod+' import *' in IP.user_ns | |
587 | except : |
|
583 | except : | |
588 | IP.InteractiveTB() |
|
584 | IP.InteractiveTB() | |
589 | import_fail_info(mod) |
|
585 | import_fail_info(mod) | |
590 |
|
586 | |||
591 | for code in IP_rc.execute: |
|
587 | for code in IP_rc.execute: | |
592 | try: |
|
588 | try: | |
593 | exec code in IP.user_ns |
|
589 | exec code in IP.user_ns | |
594 | except: |
|
590 | except: | |
595 | IP.InteractiveTB() |
|
591 | IP.InteractiveTB() | |
596 | warn('Failure executing code: ' + `code`) |
|
592 | warn('Failure executing code: ' + `code`) | |
597 |
|
593 | |||
598 | # Execute the files the user wants in ipythonrc |
|
594 | # Execute the files the user wants in ipythonrc | |
599 | for file in IP_rc.execfile: |
|
595 | for file in IP_rc.execfile: | |
600 | try: |
|
596 | try: | |
601 | file = filefind(file,sys.path+[IPython_dir]) |
|
597 | file = filefind(file,sys.path+[IPython_dir]) | |
602 | except IOError: |
|
598 | except IOError: | |
603 | warn(itpl('File $file not found. Skipping it.')) |
|
599 | warn(itpl('File $file not found. Skipping it.')) | |
604 | else: |
|
600 | else: | |
605 | IP.safe_execfile(os.path.expanduser(file),IP.user_ns) |
|
601 | IP.safe_execfile(os.path.expanduser(file),IP.user_ns) | |
606 |
|
602 | |||
607 | # release stdout and stderr and save config log into a global summary |
|
603 | # release stdout and stderr and save config log into a global summary | |
608 | msg.config.release_all() |
|
604 | msg.config.release_all() | |
609 | if IP_rc.messages: |
|
605 | if IP_rc.messages: | |
610 | msg.summary += msg.config.summary_all() |
|
606 | msg.summary += msg.config.summary_all() | |
611 |
|
607 | |||
612 | #------------------------------------------------------------------------ |
|
608 | #------------------------------------------------------------------------ | |
613 | # Setup interactive session |
|
609 | # Setup interactive session | |
614 |
|
610 | |||
615 | # Now we should be fully configured. We can then execute files or load |
|
611 | # Now we should be fully configured. We can then execute files or load | |
616 | # things only needed for interactive use. Then we'll open the shell. |
|
612 | # things only needed for interactive use. Then we'll open the shell. | |
617 |
|
613 | |||
618 | # Take a snapshot of the user namespace before opening the shell. That way |
|
614 | # Take a snapshot of the user namespace before opening the shell. That way | |
619 | # we'll be able to identify which things were interactively defined and |
|
615 | # we'll be able to identify which things were interactively defined and | |
620 | # which were defined through config files. |
|
616 | # which were defined through config files. | |
621 | IP.user_config_ns = IP.user_ns.copy() |
|
617 | IP.user_config_ns = IP.user_ns.copy() | |
622 |
|
618 | |||
623 | # Force reading a file as if it were a session log. Slower but safer. |
|
619 | # Force reading a file as if it were a session log. Slower but safer. | |
624 | if load_logplay: |
|
620 | if load_logplay: | |
625 | print 'Replaying log...' |
|
621 | print 'Replaying log...' | |
626 | try: |
|
622 | try: | |
627 | if IP_rc.debug: |
|
623 | if IP_rc.debug: | |
628 | logplay_quiet = 0 |
|
624 | logplay_quiet = 0 | |
629 | else: |
|
625 | else: | |
630 | logplay_quiet = 1 |
|
626 | logplay_quiet = 1 | |
631 |
|
627 | |||
632 | msg.logplay.trap_all() |
|
628 | msg.logplay.trap_all() | |
633 | IP.safe_execfile(load_logplay,IP.user_ns, |
|
629 | IP.safe_execfile(load_logplay,IP.user_ns, | |
634 | islog = 1, quiet = logplay_quiet) |
|
630 | islog = 1, quiet = logplay_quiet) | |
635 | msg.logplay.release_all() |
|
631 | msg.logplay.release_all() | |
636 | if IP_rc.messages: |
|
632 | if IP_rc.messages: | |
637 | msg.summary += msg.logplay.summary_all() |
|
633 | msg.summary += msg.logplay.summary_all() | |
638 | except: |
|
634 | except: | |
639 | warn('Problems replaying logfile %s.' % load_logplay) |
|
635 | warn('Problems replaying logfile %s.' % load_logplay) | |
640 | IP.InteractiveTB() |
|
636 | IP.InteractiveTB() | |
641 |
|
637 | |||
642 | # Load remaining files in command line |
|
638 | # Load remaining files in command line | |
643 | msg.user_exec.trap_all() |
|
639 | msg.user_exec.trap_all() | |
644 |
|
640 | |||
645 | # Do NOT execute files named in the command line as scripts to be loaded |
|
641 | # Do NOT execute files named in the command line as scripts to be loaded | |
646 | # by embedded instances. Doing so has the potential for an infinite |
|
642 | # by embedded instances. Doing so has the potential for an infinite | |
647 | # recursion if there are exceptions thrown in the process. |
|
643 | # recursion if there are exceptions thrown in the process. | |
648 |
|
644 | |||
649 | # XXX FIXME: the execution of user files should be moved out to after |
|
645 | # XXX FIXME: the execution of user files should be moved out to after | |
650 | # ipython is fully initialized, just as if they were run via %run at the |
|
646 | # ipython is fully initialized, just as if they were run via %run at the | |
651 | # ipython prompt. This would also give them the benefit of ipython's |
|
647 | # ipython prompt. This would also give them the benefit of ipython's | |
652 | # nice tracebacks. |
|
648 | # nice tracebacks. | |
653 |
|
649 | |||
654 | if not embedded and IP_rc.args: |
|
650 | if not embedded and IP_rc.args: | |
655 | name_save = IP.user_ns['__name__'] |
|
651 | name_save = IP.user_ns['__name__'] | |
656 | IP.user_ns['__name__'] = '__main__' |
|
652 | IP.user_ns['__name__'] = '__main__' | |
657 | try: |
|
653 | try: | |
658 | # Set our own excepthook in case the user code tries to call it |
|
654 | # Set our own excepthook in case the user code tries to call it | |
659 | # directly. This prevents triggering the IPython crash handler. |
|
655 | # directly. This prevents triggering the IPython crash handler. | |
660 | old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook |
|
656 | old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook | |
661 | for run in args: |
|
657 | for run in args: | |
662 | IP.safe_execfile(run,IP.user_ns) |
|
658 | IP.safe_execfile(run,IP.user_ns) | |
663 | finally: |
|
659 | finally: | |
664 | # Reset our crash handler in place |
|
660 | # Reset our crash handler in place | |
665 | sys.excepthook = old_excepthook |
|
661 | sys.excepthook = old_excepthook | |
666 |
|
662 | |||
667 | IP.user_ns['__name__'] = name_save |
|
663 | IP.user_ns['__name__'] = name_save | |
668 |
|
664 | |||
669 | msg.user_exec.release_all() |
|
665 | msg.user_exec.release_all() | |
670 | if IP_rc.messages: |
|
666 | if IP_rc.messages: | |
671 | msg.summary += msg.user_exec.summary_all() |
|
667 | msg.summary += msg.user_exec.summary_all() | |
672 |
|
668 | |||
673 | # since we can't specify a null string on the cmd line, 0 is the equivalent: |
|
669 | # since we can't specify a null string on the cmd line, 0 is the equivalent: | |
674 | if IP_rc.nosep: |
|
670 | if IP_rc.nosep: | |
675 | IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0' |
|
671 | IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0' | |
676 | if IP_rc.separate_in == '0': IP_rc.separate_in = '' |
|
672 | if IP_rc.separate_in == '0': IP_rc.separate_in = '' | |
677 | if IP_rc.separate_out == '0': IP_rc.separate_out = '' |
|
673 | if IP_rc.separate_out == '0': IP_rc.separate_out = '' | |
678 | if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = '' |
|
674 | if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = '' | |
679 | IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n') |
|
675 | IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n') | |
680 | IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n') |
|
676 | IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n') | |
681 | IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n') |
|
677 | IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n') | |
682 |
|
678 | |||
683 | # Determine how many lines at the bottom of the screen are needed for |
|
679 | # Determine how many lines at the bottom of the screen are needed for | |
684 | # showing prompts, so we can know wheter long strings are to be printed or |
|
680 | # showing prompts, so we can know wheter long strings are to be printed or | |
685 | # paged: |
|
681 | # paged: | |
686 | num_lines_bot = IP_rc.separate_in.count('\n')+1 |
|
682 | num_lines_bot = IP_rc.separate_in.count('\n')+1 | |
687 | IP_rc.screen_length = IP_rc.screen_length - num_lines_bot |
|
683 | IP_rc.screen_length = IP_rc.screen_length - num_lines_bot | |
688 | # Initialize cache, set in/out prompts and printing system |
|
684 | # Initialize cache, set in/out prompts and printing system | |
689 | IP.outputcache = CachedOutput(IP_rc.cache_size, |
|
685 | IP.outputcache = CachedOutput(IP_rc.cache_size, | |
690 | IP_rc.pprint, |
|
686 | IP_rc.pprint, | |
691 | input_sep = IP_rc.separate_in, |
|
687 | input_sep = IP_rc.separate_in, | |
692 | output_sep = IP_rc.separate_out, |
|
688 | output_sep = IP_rc.separate_out, | |
693 | output_sep2 = IP_rc.separate_out2, |
|
689 | output_sep2 = IP_rc.separate_out2, | |
694 | ps1 = IP_rc.prompt_in1, |
|
690 | ps1 = IP_rc.prompt_in1, | |
695 | ps2 = IP_rc.prompt_in2, |
|
691 | ps2 = IP_rc.prompt_in2, | |
696 | ps_out = IP_rc.prompt_out, |
|
692 | ps_out = IP_rc.prompt_out, | |
697 | user_ns = IP.user_ns, |
|
693 | user_ns = IP.user_ns, | |
698 | input_hist = IP.input_hist, |
|
694 | input_hist = IP.input_hist, | |
699 | pad_left = IP_rc.prompts_pad_left) |
|
695 | pad_left = IP_rc.prompts_pad_left) | |
700 |
|
696 | |||
701 | # user may have over-ridden the default print hook: |
|
697 | # user may have over-ridden the default print hook: | |
702 | try: |
|
698 | try: | |
703 | IP.outputcache.__class__.display = IP.hooks.display |
|
699 | IP.outputcache.__class__.display = IP.hooks.display | |
704 | except AttributeError: |
|
700 | except AttributeError: | |
705 | pass |
|
701 | pass | |
706 |
|
702 | |||
707 | # Set calling of pdb on exceptions |
|
703 | # Set calling of pdb on exceptions | |
708 | IP.InteractiveTB.call_pdb = IP_rc.pdb |
|
704 | IP.InteractiveTB.call_pdb = IP_rc.pdb | |
709 |
|
705 | |||
710 | # I don't like assigning globally to sys, because it means when embedding |
|
706 | # I don't like assigning globally to sys, because it means when embedding | |
711 | # instances, each embedded instance overrides the previous choice. But |
|
707 | # instances, each embedded instance overrides the previous choice. But | |
712 | # sys.displayhook seems to be called internally by exec, so I don't see a |
|
708 | # sys.displayhook seems to be called internally by exec, so I don't see a | |
713 | # way around it. |
|
709 | # way around it. | |
714 | sys.displayhook = IP.outputcache |
|
710 | sys.displayhook = IP.outputcache | |
715 |
|
711 | |||
716 | # we need to know globally if we're caching i/o or not |
|
712 | # we need to know globally if we're caching i/o or not | |
717 | IP.do_full_cache = IP.outputcache.do_full_cache |
|
713 | IP.do_full_cache = IP.outputcache.do_full_cache | |
718 |
|
714 | |||
719 | # configure startup banner |
|
715 | # configure startup banner | |
720 | if IP_rc.c: # regular python doesn't print the banner with -c |
|
716 | if IP_rc.c: # regular python doesn't print the banner with -c | |
721 | IP_rc.banner = 0 |
|
717 | IP_rc.banner = 0 | |
722 | if IP_rc.banner: |
|
718 | if IP_rc.banner: | |
723 | BANN_P = IP.BANNER_PARTS |
|
719 | BANN_P = IP.BANNER_PARTS | |
724 | else: |
|
720 | else: | |
725 | BANN_P = [] |
|
721 | BANN_P = [] | |
726 |
|
722 | |||
727 | if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile) |
|
723 | if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile) | |
728 |
|
724 | |||
729 | # add message log (possibly empty) |
|
725 | # add message log (possibly empty) | |
730 | if msg.summary: BANN_P.append(msg.summary) |
|
726 | if msg.summary: BANN_P.append(msg.summary) | |
731 | # Final banner is a string |
|
727 | # Final banner is a string | |
732 | IP.BANNER = '\n'.join(BANN_P) |
|
728 | IP.BANNER = '\n'.join(BANN_P) | |
733 |
|
729 | |||
734 | # Finalize the IPython instance. This assumes the rc structure is fully |
|
730 | # Finalize the IPython instance. This assumes the rc structure is fully | |
735 | # in place. |
|
731 | # in place. | |
736 | IP.post_config_initialization() |
|
732 | IP.post_config_initialization() | |
737 |
|
733 | |||
738 | return IP |
|
734 | return IP | |
739 | #************************ end of file <ipmaker.py> ************************** |
|
735 | #************************ end of file <ipmaker.py> ************************** |
@@ -1,796 +1,796 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | ultraTB.py -- Spice up your tracebacks! |
|
3 | ultraTB.py -- Spice up your tracebacks! | |
4 |
|
4 | |||
5 | * ColorTB |
|
5 | * ColorTB | |
6 | I've always found it a bit hard to visually parse tracebacks in Python. The |
|
6 | I've always found it a bit hard to visually parse tracebacks in Python. The | |
7 | ColorTB class is a solution to that problem. It colors the different parts of a |
|
7 | ColorTB class is a solution to that problem. It colors the different parts of a | |
8 | traceback in a manner similar to what you would expect from a syntax-highlighting |
|
8 | traceback in a manner similar to what you would expect from a syntax-highlighting | |
9 | text editor. |
|
9 | text editor. | |
10 |
|
10 | |||
11 | Installation instructions for ColorTB: |
|
11 | Installation instructions for ColorTB: | |
12 | import sys,ultraTB |
|
12 | import sys,ultraTB | |
13 | sys.excepthook = ultraTB.ColorTB() |
|
13 | sys.excepthook = ultraTB.ColorTB() | |
14 |
|
14 | |||
15 | * VerboseTB |
|
15 | * VerboseTB | |
16 | I've also included a port of Ka-Ping Yee's "cgitb.py" that produces all kinds |
|
16 | I've also included a port of Ka-Ping Yee's "cgitb.py" that produces all kinds | |
17 | of useful info when a traceback occurs. Ping originally had it spit out HTML |
|
17 | of useful info when a traceback occurs. Ping originally had it spit out HTML | |
18 | and intended it for CGI programmers, but why should they have all the fun? I |
|
18 | and intended it for CGI programmers, but why should they have all the fun? I | |
19 | altered it to spit out colored text to the terminal. It's a bit overwhelming, |
|
19 | altered it to spit out colored text to the terminal. It's a bit overwhelming, | |
20 | but kind of neat, and maybe useful for long-running programs that you believe |
|
20 | but kind of neat, and maybe useful for long-running programs that you believe | |
21 | are bug-free. If a crash *does* occur in that type of program you want details. |
|
21 | are bug-free. If a crash *does* occur in that type of program you want details. | |
22 | Give it a shot--you'll love it or you'll hate it. |
|
22 | Give it a shot--you'll love it or you'll hate it. | |
23 |
|
23 | |||
24 | Note: |
|
24 | Note: | |
25 |
|
25 | |||
26 | The Verbose mode prints the variables currently visible where the exception |
|
26 | The Verbose mode prints the variables currently visible where the exception | |
27 | happened (shortening their strings if too long). This can potentially be |
|
27 | happened (shortening their strings if too long). This can potentially be | |
28 | very slow, if you happen to have a huge data structure whose string |
|
28 | very slow, if you happen to have a huge data structure whose string | |
29 | representation is complex to compute. Your computer may appear to freeze for |
|
29 | representation is complex to compute. Your computer may appear to freeze for | |
30 | a while with cpu usage at 100%. If this occurs, you can cancel the traceback |
|
30 | a while with cpu usage at 100%. If this occurs, you can cancel the traceback | |
31 | with Ctrl-C (maybe hitting it more than once). |
|
31 | with Ctrl-C (maybe hitting it more than once). | |
32 |
|
32 | |||
33 | If you encounter this kind of situation often, you may want to use the |
|
33 | If you encounter this kind of situation often, you may want to use the | |
34 | Verbose_novars mode instead of the regular Verbose, which avoids formatting |
|
34 | Verbose_novars mode instead of the regular Verbose, which avoids formatting | |
35 | variables (but otherwise includes the information and context given by |
|
35 | variables (but otherwise includes the information and context given by | |
36 | Verbose). |
|
36 | Verbose). | |
37 |
|
37 | |||
38 |
|
38 | |||
39 | Installation instructions for ColorTB: |
|
39 | Installation instructions for ColorTB: | |
40 | import sys,ultraTB |
|
40 | import sys,ultraTB | |
41 | sys.excepthook = ultraTB.VerboseTB() |
|
41 | sys.excepthook = ultraTB.VerboseTB() | |
42 |
|
42 | |||
43 | Note: Much of the code in this module was lifted verbatim from the standard |
|
43 | Note: Much of the code in this module was lifted verbatim from the standard | |
44 | library module 'traceback.py' and Ka-Ping Yee's 'cgitb.py'. |
|
44 | library module 'traceback.py' and Ka-Ping Yee's 'cgitb.py'. | |
45 |
|
45 | |||
46 | * Color schemes |
|
46 | * Color schemes | |
47 | The colors are defined in the class TBTools through the use of the |
|
47 | The colors are defined in the class TBTools through the use of the | |
48 | ColorSchemeTable class. Currently the following exist: |
|
48 | ColorSchemeTable class. Currently the following exist: | |
49 |
|
49 | |||
50 | - NoColor: allows all of this module to be used in any terminal (the color |
|
50 | - NoColor: allows all of this module to be used in any terminal (the color | |
51 | escapes are just dummy blank strings). |
|
51 | escapes are just dummy blank strings). | |
52 |
|
52 | |||
53 | - Linux: is meant to look good in a terminal like the Linux console (black |
|
53 | - Linux: is meant to look good in a terminal like the Linux console (black | |
54 | or very dark background). |
|
54 | or very dark background). | |
55 |
|
55 | |||
56 | - LightBG: similar to Linux but swaps dark/light colors to be more readable |
|
56 | - LightBG: similar to Linux but swaps dark/light colors to be more readable | |
57 | in light background terminals. |
|
57 | in light background terminals. | |
58 |
|
58 | |||
59 | You can implement other color schemes easily, the syntax is fairly |
|
59 | You can implement other color schemes easily, the syntax is fairly | |
60 | self-explanatory. Please send back new schemes you develop to the author for |
|
60 | self-explanatory. Please send back new schemes you develop to the author for | |
61 | possible inclusion in future releases. |
|
61 | possible inclusion in future releases. | |
62 |
|
62 | |||
63 |
$Id: ultraTB.py 95 |
|
63 | $Id: ultraTB.py 965 2005-12-28 23:23:09Z fperez $""" | |
64 |
|
64 | |||
65 | #***************************************************************************** |
|
65 | #***************************************************************************** | |
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> |
|
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> | |
67 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> |
|
67 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> | |
68 | # |
|
68 | # | |
69 | # Distributed under the terms of the BSD License. The full license is in |
|
69 | # Distributed under the terms of the BSD License. The full license is in | |
70 | # the file COPYING, distributed as part of this software. |
|
70 | # the file COPYING, distributed as part of this software. | |
71 | #***************************************************************************** |
|
71 | #***************************************************************************** | |
72 |
|
72 | |||
73 | from IPython import Release |
|
73 | from IPython import Release | |
74 | __author__ = '%s <%s>\n%s <%s>' % (Release.authors['Nathan']+ |
|
74 | __author__ = '%s <%s>\n%s <%s>' % (Release.authors['Nathan']+ | |
75 | Release.authors['Fernando']) |
|
75 | Release.authors['Fernando']) | |
76 | __license__ = Release.license |
|
76 | __license__ = Release.license | |
77 |
|
77 | |||
78 | # Required modules |
|
78 | # Required modules | |
79 | import inspect |
|
79 | import inspect | |
80 | import keyword |
|
80 | import keyword | |
81 | import linecache |
|
81 | import linecache | |
82 | import os |
|
82 | import os | |
83 | import pydoc |
|
83 | import pydoc | |
84 | import string |
|
84 | import string | |
85 | import sys |
|
85 | import sys | |
86 | import time |
|
86 | import time | |
87 | import tokenize |
|
87 | import tokenize | |
88 | import traceback |
|
88 | import traceback | |
89 | import types |
|
89 | import types | |
90 |
|
90 | |||
91 | # IPython's own modules |
|
91 | # IPython's own modules | |
92 | # Modified pdb which doesn't damage IPython's readline handling |
|
92 | # Modified pdb which doesn't damage IPython's readline handling | |
93 | from IPython import Debugger |
|
93 | from IPython import Debugger | |
94 | from IPython.Struct import Struct |
|
94 | from IPython.Struct import Struct | |
95 | from IPython.excolors import ExceptionColors |
|
95 | from IPython.excolors import ExceptionColors | |
96 | from IPython.genutils import Term,uniq_stable,error,info |
|
96 | from IPython.genutils import Term,uniq_stable,error,info | |
97 |
|
97 | |||
98 | #--------------------------------------------------------------------------- |
|
98 | #--------------------------------------------------------------------------- | |
99 | # Code begins |
|
99 | # Code begins | |
100 |
|
100 | |||
101 | def inspect_error(): |
|
101 | def inspect_error(): | |
102 | """Print a message about internal inspect errors. |
|
102 | """Print a message about internal inspect errors. | |
103 |
|
103 | |||
104 | These are unfortunately quite common.""" |
|
104 | These are unfortunately quite common.""" | |
105 |
|
105 | |||
106 | error('Internal Python error in the inspect module.\n' |
|
106 | error('Internal Python error in the inspect module.\n' | |
107 | 'Below is the traceback from this internal error.\n') |
|
107 | 'Below is the traceback from this internal error.\n') | |
108 |
|
108 | |||
109 | class TBTools: |
|
109 | class TBTools: | |
110 | """Basic tools used by all traceback printer classes.""" |
|
110 | """Basic tools used by all traceback printer classes.""" | |
111 |
|
111 | |||
112 | def __init__(self,color_scheme = 'NoColor',call_pdb=False): |
|
112 | def __init__(self,color_scheme = 'NoColor',call_pdb=False): | |
113 | # Whether to call the interactive pdb debugger after printing |
|
113 | # Whether to call the interactive pdb debugger after printing | |
114 | # tracebacks or not |
|
114 | # tracebacks or not | |
115 | self.call_pdb = call_pdb |
|
115 | self.call_pdb = call_pdb | |
116 |
|
116 | |||
117 | # Create color table |
|
117 | # Create color table | |
118 | self.color_scheme_table = ExceptionColors |
|
118 | self.color_scheme_table = ExceptionColors | |
119 |
|
119 | |||
120 | self.set_colors(color_scheme) |
|
120 | self.set_colors(color_scheme) | |
121 | self.old_scheme = color_scheme # save initial value for toggles |
|
121 | self.old_scheme = color_scheme # save initial value for toggles | |
122 |
|
122 | |||
123 | if call_pdb: |
|
123 | if call_pdb: | |
124 | self.pdb = Debugger.Pdb(self.color_scheme_table.active_scheme_name) |
|
124 | self.pdb = Debugger.Pdb(self.color_scheme_table.active_scheme_name) | |
125 | else: |
|
125 | else: | |
126 | self.pdb = None |
|
126 | self.pdb = None | |
127 |
|
127 | |||
128 | def set_colors(self,*args,**kw): |
|
128 | def set_colors(self,*args,**kw): | |
129 | """Shorthand access to the color table scheme selector method.""" |
|
129 | """Shorthand access to the color table scheme selector method.""" | |
130 |
|
130 | |||
131 | self.color_scheme_table.set_active_scheme(*args,**kw) |
|
131 | self.color_scheme_table.set_active_scheme(*args,**kw) | |
132 | # for convenience, set Colors to the active scheme |
|
132 | # for convenience, set Colors to the active scheme | |
133 | self.Colors = self.color_scheme_table.active_colors |
|
133 | self.Colors = self.color_scheme_table.active_colors | |
134 |
|
134 | |||
135 | def color_toggle(self): |
|
135 | def color_toggle(self): | |
136 | """Toggle between the currently active color scheme and NoColor.""" |
|
136 | """Toggle between the currently active color scheme and NoColor.""" | |
137 |
|
137 | |||
138 | if self.color_scheme_table.active_scheme_name == 'NoColor': |
|
138 | if self.color_scheme_table.active_scheme_name == 'NoColor': | |
139 | self.color_scheme_table.set_active_scheme(self.old_scheme) |
|
139 | self.color_scheme_table.set_active_scheme(self.old_scheme) | |
140 | self.Colors = self.color_scheme_table.active_colors |
|
140 | self.Colors = self.color_scheme_table.active_colors | |
141 | else: |
|
141 | else: | |
142 | self.old_scheme = self.color_scheme_table.active_scheme_name |
|
142 | self.old_scheme = self.color_scheme_table.active_scheme_name | |
143 | self.color_scheme_table.set_active_scheme('NoColor') |
|
143 | self.color_scheme_table.set_active_scheme('NoColor') | |
144 | self.Colors = self.color_scheme_table.active_colors |
|
144 | self.Colors = self.color_scheme_table.active_colors | |
145 |
|
145 | |||
146 | #--------------------------------------------------------------------------- |
|
146 | #--------------------------------------------------------------------------- | |
147 | class ListTB(TBTools): |
|
147 | class ListTB(TBTools): | |
148 | """Print traceback information from a traceback list, with optional color. |
|
148 | """Print traceback information from a traceback list, with optional color. | |
149 |
|
149 | |||
150 | Calling: requires 3 arguments: |
|
150 | Calling: requires 3 arguments: | |
151 | (etype, evalue, elist) |
|
151 | (etype, evalue, elist) | |
152 | as would be obtained by: |
|
152 | as would be obtained by: | |
153 | etype, evalue, tb = sys.exc_info() |
|
153 | etype, evalue, tb = sys.exc_info() | |
154 | if tb: |
|
154 | if tb: | |
155 | elist = traceback.extract_tb(tb) |
|
155 | elist = traceback.extract_tb(tb) | |
156 | else: |
|
156 | else: | |
157 | elist = None |
|
157 | elist = None | |
158 |
|
158 | |||
159 | It can thus be used by programs which need to process the traceback before |
|
159 | It can thus be used by programs which need to process the traceback before | |
160 | printing (such as console replacements based on the code module from the |
|
160 | printing (such as console replacements based on the code module from the | |
161 | standard library). |
|
161 | standard library). | |
162 |
|
162 | |||
163 | Because they are meant to be called without a full traceback (only a |
|
163 | Because they are meant to be called without a full traceback (only a | |
164 | list), instances of this class can't call the interactive pdb debugger.""" |
|
164 | list), instances of this class can't call the interactive pdb debugger.""" | |
165 |
|
165 | |||
166 | def __init__(self,color_scheme = 'NoColor'): |
|
166 | def __init__(self,color_scheme = 'NoColor'): | |
167 | TBTools.__init__(self,color_scheme = color_scheme,call_pdb=0) |
|
167 | TBTools.__init__(self,color_scheme = color_scheme,call_pdb=0) | |
168 |
|
168 | |||
169 | def __call__(self, etype, value, elist): |
|
169 | def __call__(self, etype, value, elist): | |
170 | print >> Term.cerr, self.text(etype,value,elist) |
|
170 | print >> Term.cerr, self.text(etype,value,elist) | |
171 |
|
171 | |||
172 | def text(self,etype, value, elist,context=5): |
|
172 | def text(self,etype, value, elist,context=5): | |
173 | """Return a color formatted string with the traceback info.""" |
|
173 | """Return a color formatted string with the traceback info.""" | |
174 |
|
174 | |||
175 | Colors = self.Colors |
|
175 | Colors = self.Colors | |
176 | out_string = ['%s%s%s\n' % (Colors.topline,'-'*60,Colors.Normal)] |
|
176 | out_string = ['%s%s%s\n' % (Colors.topline,'-'*60,Colors.Normal)] | |
177 | if elist: |
|
177 | if elist: | |
178 | out_string.append('Traceback %s(most recent call last)%s:' % \ |
|
178 | out_string.append('Traceback %s(most recent call last)%s:' % \ | |
179 | (Colors.normalEm, Colors.Normal) + '\n') |
|
179 | (Colors.normalEm, Colors.Normal) + '\n') | |
180 | out_string.extend(self._format_list(elist)) |
|
180 | out_string.extend(self._format_list(elist)) | |
181 | lines = self._format_exception_only(etype, value) |
|
181 | lines = self._format_exception_only(etype, value) | |
182 | for line in lines[:-1]: |
|
182 | for line in lines[:-1]: | |
183 | out_string.append(" "+line) |
|
183 | out_string.append(" "+line) | |
184 | out_string.append(lines[-1]) |
|
184 | out_string.append(lines[-1]) | |
185 | return ''.join(out_string) |
|
185 | return ''.join(out_string) | |
186 |
|
186 | |||
187 | def _format_list(self, extracted_list): |
|
187 | def _format_list(self, extracted_list): | |
188 | """Format a list of traceback entry tuples for printing. |
|
188 | """Format a list of traceback entry tuples for printing. | |
189 |
|
189 | |||
190 | Given a list of tuples as returned by extract_tb() or |
|
190 | Given a list of tuples as returned by extract_tb() or | |
191 | extract_stack(), return a list of strings ready for printing. |
|
191 | extract_stack(), return a list of strings ready for printing. | |
192 | Each string in the resulting list corresponds to the item with the |
|
192 | Each string in the resulting list corresponds to the item with the | |
193 | same index in the argument list. Each string ends in a newline; |
|
193 | same index in the argument list. Each string ends in a newline; | |
194 | the strings may contain internal newlines as well, for those items |
|
194 | the strings may contain internal newlines as well, for those items | |
195 | whose source text line is not None. |
|
195 | whose source text line is not None. | |
196 |
|
196 | |||
197 | Lifted almost verbatim from traceback.py |
|
197 | Lifted almost verbatim from traceback.py | |
198 | """ |
|
198 | """ | |
199 |
|
199 | |||
200 | Colors = self.Colors |
|
200 | Colors = self.Colors | |
201 | list = [] |
|
201 | list = [] | |
202 | for filename, lineno, name, line in extracted_list[:-1]: |
|
202 | for filename, lineno, name, line in extracted_list[:-1]: | |
203 | item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \ |
|
203 | item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \ | |
204 | (Colors.filename, filename, Colors.Normal, |
|
204 | (Colors.filename, filename, Colors.Normal, | |
205 | Colors.lineno, lineno, Colors.Normal, |
|
205 | Colors.lineno, lineno, Colors.Normal, | |
206 | Colors.name, name, Colors.Normal) |
|
206 | Colors.name, name, Colors.Normal) | |
207 | if line: |
|
207 | if line: | |
208 | item = item + ' %s\n' % line.strip() |
|
208 | item = item + ' %s\n' % line.strip() | |
209 | list.append(item) |
|
209 | list.append(item) | |
210 | # Emphasize the last entry |
|
210 | # Emphasize the last entry | |
211 | filename, lineno, name, line = extracted_list[-1] |
|
211 | filename, lineno, name, line = extracted_list[-1] | |
212 | item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \ |
|
212 | item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \ | |
213 | (Colors.normalEm, |
|
213 | (Colors.normalEm, | |
214 | Colors.filenameEm, filename, Colors.normalEm, |
|
214 | Colors.filenameEm, filename, Colors.normalEm, | |
215 | Colors.linenoEm, lineno, Colors.normalEm, |
|
215 | Colors.linenoEm, lineno, Colors.normalEm, | |
216 | Colors.nameEm, name, Colors.normalEm, |
|
216 | Colors.nameEm, name, Colors.normalEm, | |
217 | Colors.Normal) |
|
217 | Colors.Normal) | |
218 | if line: |
|
218 | if line: | |
219 | item = item + '%s %s%s\n' % (Colors.line, line.strip(), |
|
219 | item = item + '%s %s%s\n' % (Colors.line, line.strip(), | |
220 | Colors.Normal) |
|
220 | Colors.Normal) | |
221 | list.append(item) |
|
221 | list.append(item) | |
222 | return list |
|
222 | return list | |
223 |
|
223 | |||
224 | def _format_exception_only(self, etype, value): |
|
224 | def _format_exception_only(self, etype, value): | |
225 | """Format the exception part of a traceback. |
|
225 | """Format the exception part of a traceback. | |
226 |
|
226 | |||
227 | The arguments are the exception type and value such as given by |
|
227 | The arguments are the exception type and value such as given by | |
228 | sys.last_type and sys.last_value. The return value is a list of |
|
228 | sys.last_type and sys.last_value. The return value is a list of | |
229 | strings, each ending in a newline. Normally, the list contains a |
|
229 | strings, each ending in a newline. Normally, the list contains a | |
230 | single string; however, for SyntaxError exceptions, it contains |
|
230 | single string; however, for SyntaxError exceptions, it contains | |
231 | several lines that (when printed) display detailed information |
|
231 | several lines that (when printed) display detailed information | |
232 | about where the syntax error occurred. The message indicating |
|
232 | about where the syntax error occurred. The message indicating | |
233 | which exception occurred is the always last string in the list. |
|
233 | which exception occurred is the always last string in the list. | |
234 |
|
234 | |||
235 | Also lifted nearly verbatim from traceback.py |
|
235 | Also lifted nearly verbatim from traceback.py | |
236 | """ |
|
236 | """ | |
237 |
|
237 | |||
238 | Colors = self.Colors |
|
238 | Colors = self.Colors | |
239 | list = [] |
|
239 | list = [] | |
240 | if type(etype) == types.ClassType: |
|
240 | if type(etype) == types.ClassType: | |
241 | stype = Colors.excName + etype.__name__ + Colors.Normal |
|
241 | stype = Colors.excName + etype.__name__ + Colors.Normal | |
242 | else: |
|
242 | else: | |
243 | stype = etype # String exceptions don't get special coloring |
|
243 | stype = etype # String exceptions don't get special coloring | |
244 | if value is None: |
|
244 | if value is None: | |
245 | list.append( str(stype) + '\n') |
|
245 | list.append( str(stype) + '\n') | |
246 | else: |
|
246 | else: | |
247 | if etype is SyntaxError: |
|
247 | if etype is SyntaxError: | |
248 | try: |
|
248 | try: | |
249 | msg, (filename, lineno, offset, line) = value |
|
249 | msg, (filename, lineno, offset, line) = value | |
250 | except: |
|
250 | except: | |
251 | pass |
|
251 | pass | |
252 | else: |
|
252 | else: | |
253 | #print 'filename is',filename # dbg |
|
253 | #print 'filename is',filename # dbg | |
254 | if not filename: filename = "<string>" |
|
254 | if not filename: filename = "<string>" | |
255 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ |
|
255 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ | |
256 | (Colors.normalEm, |
|
256 | (Colors.normalEm, | |
257 | Colors.filenameEm, filename, Colors.normalEm, |
|
257 | Colors.filenameEm, filename, Colors.normalEm, | |
258 | Colors.linenoEm, lineno, Colors.Normal )) |
|
258 | Colors.linenoEm, lineno, Colors.Normal )) | |
259 | if line is not None: |
|
259 | if line is not None: | |
260 | i = 0 |
|
260 | i = 0 | |
261 | while i < len(line) and line[i].isspace(): |
|
261 | while i < len(line) and line[i].isspace(): | |
262 | i = i+1 |
|
262 | i = i+1 | |
263 | list.append('%s %s%s\n' % (Colors.line, |
|
263 | list.append('%s %s%s\n' % (Colors.line, | |
264 | line.strip(), |
|
264 | line.strip(), | |
265 | Colors.Normal)) |
|
265 | Colors.Normal)) | |
266 | if offset is not None: |
|
266 | if offset is not None: | |
267 | s = ' ' |
|
267 | s = ' ' | |
268 | for c in line[i:offset-1]: |
|
268 | for c in line[i:offset-1]: | |
269 | if c.isspace(): |
|
269 | if c.isspace(): | |
270 | s = s + c |
|
270 | s = s + c | |
271 | else: |
|
271 | else: | |
272 | s = s + ' ' |
|
272 | s = s + ' ' | |
273 | list.append('%s%s^%s\n' % (Colors.caret, s, |
|
273 | list.append('%s%s^%s\n' % (Colors.caret, s, | |
274 | Colors.Normal) ) |
|
274 | Colors.Normal) ) | |
275 | value = msg |
|
275 | value = msg | |
276 | s = self._some_str(value) |
|
276 | s = self._some_str(value) | |
277 | if s: |
|
277 | if s: | |
278 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, |
|
278 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, | |
279 | Colors.Normal, s)) |
|
279 | Colors.Normal, s)) | |
280 | else: |
|
280 | else: | |
281 | list.append('%s\n' % str(stype)) |
|
281 | list.append('%s\n' % str(stype)) | |
282 | return list |
|
282 | return list | |
283 |
|
283 | |||
284 | def _some_str(self, value): |
|
284 | def _some_str(self, value): | |
285 | # Lifted from traceback.py |
|
285 | # Lifted from traceback.py | |
286 | try: |
|
286 | try: | |
287 | return str(value) |
|
287 | return str(value) | |
288 | except: |
|
288 | except: | |
289 | return '<unprintable %s object>' % type(value).__name__ |
|
289 | return '<unprintable %s object>' % type(value).__name__ | |
290 |
|
290 | |||
291 | #---------------------------------------------------------------------------- |
|
291 | #---------------------------------------------------------------------------- | |
292 | class VerboseTB(TBTools): |
|
292 | class VerboseTB(TBTools): | |
293 | """A port of Ka-Ping Yee's cgitb.py module that outputs color text instead |
|
293 | """A port of Ka-Ping Yee's cgitb.py module that outputs color text instead | |
294 | of HTML. Requires inspect and pydoc. Crazy, man. |
|
294 | of HTML. Requires inspect and pydoc. Crazy, man. | |
295 |
|
295 | |||
296 | Modified version which optionally strips the topmost entries from the |
|
296 | Modified version which optionally strips the topmost entries from the | |
297 | traceback, to be used with alternate interpreters (because their own code |
|
297 | traceback, to be used with alternate interpreters (because their own code | |
298 | would appear in the traceback).""" |
|
298 | would appear in the traceback).""" | |
299 |
|
299 | |||
300 | def __init__(self,color_scheme = 'Linux',tb_offset=0,long_header=0, |
|
300 | def __init__(self,color_scheme = 'Linux',tb_offset=0,long_header=0, | |
301 | call_pdb = 0, include_vars=1): |
|
301 | call_pdb = 0, include_vars=1): | |
302 | """Specify traceback offset, headers and color scheme. |
|
302 | """Specify traceback offset, headers and color scheme. | |
303 |
|
303 | |||
304 | Define how many frames to drop from the tracebacks. Calling it with |
|
304 | Define how many frames to drop from the tracebacks. Calling it with | |
305 | tb_offset=1 allows use of this handler in interpreters which will have |
|
305 | tb_offset=1 allows use of this handler in interpreters which will have | |
306 | their own code at the top of the traceback (VerboseTB will first |
|
306 | their own code at the top of the traceback (VerboseTB will first | |
307 | remove that frame before printing the traceback info).""" |
|
307 | remove that frame before printing the traceback info).""" | |
308 | TBTools.__init__(self,color_scheme=color_scheme,call_pdb=call_pdb) |
|
308 | TBTools.__init__(self,color_scheme=color_scheme,call_pdb=call_pdb) | |
309 | self.tb_offset = tb_offset |
|
309 | self.tb_offset = tb_offset | |
310 | self.long_header = long_header |
|
310 | self.long_header = long_header | |
311 | self.include_vars = include_vars |
|
311 | self.include_vars = include_vars | |
312 |
|
312 | |||
313 | def text(self, etype, evalue, etb, context=5): |
|
313 | def text(self, etype, evalue, etb, context=5): | |
314 | """Return a nice text document describing the traceback.""" |
|
314 | """Return a nice text document describing the traceback.""" | |
315 |
|
315 | |||
316 | # some locals |
|
316 | # some locals | |
317 | Colors = self.Colors # just a shorthand + quicker name lookup |
|
317 | Colors = self.Colors # just a shorthand + quicker name lookup | |
318 | ColorsNormal = Colors.Normal # used a lot |
|
318 | ColorsNormal = Colors.Normal # used a lot | |
319 | indent_size = 8 # we need some space to put line numbers before |
|
319 | indent_size = 8 # we need some space to put line numbers before | |
320 | indent = ' '*indent_size |
|
320 | indent = ' '*indent_size | |
321 | numbers_width = indent_size - 1 # leave space between numbers & code |
|
321 | numbers_width = indent_size - 1 # leave space between numbers & code | |
322 | text_repr = pydoc.text.repr |
|
322 | text_repr = pydoc.text.repr | |
323 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) |
|
323 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) | |
324 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) |
|
324 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) | |
325 | undefined = '%sundefined%s' % (Colors.em, ColorsNormal) |
|
325 | undefined = '%sundefined%s' % (Colors.em, ColorsNormal) | |
326 |
|
326 | |||
327 | # some internal-use functions |
|
327 | # some internal-use functions | |
328 | def eqrepr(value, repr=text_repr): return '=%s' % repr(value) |
|
328 | def eqrepr(value, repr=text_repr): return '=%s' % repr(value) | |
329 | def nullrepr(value, repr=text_repr): return '' |
|
329 | def nullrepr(value, repr=text_repr): return '' | |
330 |
|
330 | |||
331 | # meat of the code begins |
|
331 | # meat of the code begins | |
332 | if type(etype) is types.ClassType: |
|
332 | if type(etype) is types.ClassType: | |
333 | etype = etype.__name__ |
|
333 | etype = etype.__name__ | |
334 |
|
334 | |||
335 | if self.long_header: |
|
335 | if self.long_header: | |
336 | # Header with the exception type, python version, and date |
|
336 | # Header with the exception type, python version, and date | |
337 | pyver = 'Python ' + string.split(sys.version)[0] + ': ' + sys.executable |
|
337 | pyver = 'Python ' + string.split(sys.version)[0] + ': ' + sys.executable | |
338 | date = time.ctime(time.time()) |
|
338 | date = time.ctime(time.time()) | |
339 |
|
339 | |||
340 | head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal, |
|
340 | head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal, | |
341 | exc, ' '*(75-len(str(etype))-len(pyver)), |
|
341 | exc, ' '*(75-len(str(etype))-len(pyver)), | |
342 | pyver, string.rjust(date, 75) ) |
|
342 | pyver, string.rjust(date, 75) ) | |
343 | head += "\nA problem occured executing Python code. Here is the sequence of function"\ |
|
343 | head += "\nA problem occured executing Python code. Here is the sequence of function"\ | |
344 | "\ncalls leading up to the error, with the most recent (innermost) call last." |
|
344 | "\ncalls leading up to the error, with the most recent (innermost) call last." | |
345 | else: |
|
345 | else: | |
346 | # Simplified header |
|
346 | # Simplified header | |
347 | head = '%s%s%s\n%s%s' % (Colors.topline, '-'*75, ColorsNormal,exc, |
|
347 | head = '%s%s%s\n%s%s' % (Colors.topline, '-'*75, ColorsNormal,exc, | |
348 | string.rjust('Traceback (most recent call last)', |
|
348 | string.rjust('Traceback (most recent call last)', | |
349 | 75 - len(str(etype)) ) ) |
|
349 | 75 - len(str(etype)) ) ) | |
350 | frames = [] |
|
350 | frames = [] | |
351 | # Flush cache before calling inspect. This helps alleviate some of the |
|
351 | # Flush cache before calling inspect. This helps alleviate some of the | |
352 | # problems with python 2.3's inspect.py. |
|
352 | # problems with python 2.3's inspect.py. | |
353 | linecache.checkcache() |
|
353 | linecache.checkcache() | |
354 | # Drop topmost frames if requested |
|
354 | # Drop topmost frames if requested | |
355 | try: |
|
355 | try: | |
356 | records = inspect.getinnerframes(etb, context)[self.tb_offset:] |
|
356 | records = inspect.getinnerframes(etb, context)[self.tb_offset:] | |
357 | except: |
|
357 | except: | |
358 |
|
358 | |||
359 | # FIXME: I've been getting many crash reports from python 2.3 |
|
359 | # FIXME: I've been getting many crash reports from python 2.3 | |
360 | # users, traceable to inspect.py. If I can find a small test-case |
|
360 | # users, traceable to inspect.py. If I can find a small test-case | |
361 | # to reproduce this, I should either write a better workaround or |
|
361 | # to reproduce this, I should either write a better workaround or | |
362 | # file a bug report against inspect (if that's the real problem). |
|
362 | # file a bug report against inspect (if that's the real problem). | |
363 | # So far, I haven't been able to find an isolated example to |
|
363 | # So far, I haven't been able to find an isolated example to | |
364 | # reproduce the problem. |
|
364 | # reproduce the problem. | |
365 | inspect_error() |
|
365 | inspect_error() | |
366 | traceback.print_exc(file=Term.cerr) |
|
366 | traceback.print_exc(file=Term.cerr) | |
367 | info('\nUnfortunately, your original traceback can not be constructed.\n') |
|
367 | info('\nUnfortunately, your original traceback can not be constructed.\n') | |
368 | return '' |
|
368 | return '' | |
369 |
|
369 | |||
370 | # build some color string templates outside these nested loops |
|
370 | # build some color string templates outside these nested loops | |
371 | tpl_link = '%s%%s%s' % (Colors.filenameEm,ColorsNormal) |
|
371 | tpl_link = '%s%%s%s' % (Colors.filenameEm,ColorsNormal) | |
372 | tpl_call = 'in %s%%s%s%%s%s' % (Colors.vName, Colors.valEm, |
|
372 | tpl_call = 'in %s%%s%s%%s%s' % (Colors.vName, Colors.valEm, | |
373 | ColorsNormal) |
|
373 | ColorsNormal) | |
374 | tpl_call_fail = 'in %s%%s%s(***failed resolving arguments***)%s' % \ |
|
374 | tpl_call_fail = 'in %s%%s%s(***failed resolving arguments***)%s' % \ | |
375 | (Colors.vName, Colors.valEm, ColorsNormal) |
|
375 | (Colors.vName, Colors.valEm, ColorsNormal) | |
376 | tpl_local_var = '%s%%s%s' % (Colors.vName, ColorsNormal) |
|
376 | tpl_local_var = '%s%%s%s' % (Colors.vName, ColorsNormal) | |
377 | tpl_global_var = '%sglobal%s %s%%s%s' % (Colors.em, ColorsNormal, |
|
377 | tpl_global_var = '%sglobal%s %s%%s%s' % (Colors.em, ColorsNormal, | |
378 | Colors.vName, ColorsNormal) |
|
378 | Colors.vName, ColorsNormal) | |
379 | tpl_name_val = '%%s %s= %%s%s' % (Colors.valEm, ColorsNormal) |
|
379 | tpl_name_val = '%%s %s= %%s%s' % (Colors.valEm, ColorsNormal) | |
380 | tpl_line = '%s%%s%s %%s' % (Colors.lineno, ColorsNormal) |
|
380 | tpl_line = '%s%%s%s %%s' % (Colors.lineno, ColorsNormal) | |
381 | tpl_line_em = '%s%%s%s %%s%s' % (Colors.linenoEm,Colors.line, |
|
381 | tpl_line_em = '%s%%s%s %%s%s' % (Colors.linenoEm,Colors.line, | |
382 | ColorsNormal) |
|
382 | ColorsNormal) | |
383 |
|
383 | |||
384 | # now, loop over all records printing context and info |
|
384 | # now, loop over all records printing context and info | |
385 | abspath = os.path.abspath |
|
385 | abspath = os.path.abspath | |
386 | for frame, file, lnum, func, lines, index in records: |
|
386 | for frame, file, lnum, func, lines, index in records: | |
387 | #print '*** record:',file,lnum,func,lines,index # dbg |
|
387 | #print '*** record:',file,lnum,func,lines,index # dbg | |
388 | try: |
|
388 | try: | |
389 | file = file and abspath(file) or '?' |
|
389 | file = file and abspath(file) or '?' | |
390 | except OSError: |
|
390 | except OSError: | |
391 | # if file is '<console>' or something not in the filesystem, |
|
391 | # if file is '<console>' or something not in the filesystem, | |
392 | # the abspath call will throw an OSError. Just ignore it and |
|
392 | # the abspath call will throw an OSError. Just ignore it and | |
393 | # keep the original file string. |
|
393 | # keep the original file string. | |
394 | pass |
|
394 | pass | |
395 | link = tpl_link % file |
|
395 | link = tpl_link % file | |
396 | try: |
|
396 | try: | |
397 | args, varargs, varkw, locals = inspect.getargvalues(frame) |
|
397 | args, varargs, varkw, locals = inspect.getargvalues(frame) | |
398 | except: |
|
398 | except: | |
399 | # This can happen due to a bug in python2.3. We should be |
|
399 | # This can happen due to a bug in python2.3. We should be | |
400 | # able to remove this try/except when 2.4 becomes a |
|
400 | # able to remove this try/except when 2.4 becomes a | |
401 | # requirement. Bug details at http://python.org/sf/1005466 |
|
401 | # requirement. Bug details at http://python.org/sf/1005466 | |
402 | inspect_error() |
|
402 | inspect_error() | |
403 | traceback.print_exc(file=Term.cerr) |
|
403 | traceback.print_exc(file=Term.cerr) | |
404 | info("\nIPython's exception reporting continues...\n") |
|
404 | info("\nIPython's exception reporting continues...\n") | |
405 |
|
405 | |||
406 | if func == '?': |
|
406 | if func == '?': | |
407 | call = '' |
|
407 | call = '' | |
408 | else: |
|
408 | else: | |
409 | # Decide whether to include variable details or not |
|
409 | # Decide whether to include variable details or not | |
410 | var_repr = self.include_vars and eqrepr or nullrepr |
|
410 | var_repr = self.include_vars and eqrepr or nullrepr | |
411 | try: |
|
411 | try: | |
412 | call = tpl_call % (func,inspect.formatargvalues(args, |
|
412 | call = tpl_call % (func,inspect.formatargvalues(args, | |
413 | varargs, varkw, |
|
413 | varargs, varkw, | |
414 | locals,formatvalue=var_repr)) |
|
414 | locals,formatvalue=var_repr)) | |
415 | except KeyError: |
|
415 | except KeyError: | |
416 | # Very odd crash from inspect.formatargvalues(). The |
|
416 | # Very odd crash from inspect.formatargvalues(). The | |
417 | # scenario under which it appeared was a call to |
|
417 | # scenario under which it appeared was a call to | |
418 | # view(array,scale) in NumTut.view.view(), where scale had |
|
418 | # view(array,scale) in NumTut.view.view(), where scale had | |
419 | # been defined as a scalar (it should be a tuple). Somehow |
|
419 | # been defined as a scalar (it should be a tuple). Somehow | |
420 | # inspect messes up resolving the argument list of view() |
|
420 | # inspect messes up resolving the argument list of view() | |
421 | # and barfs out. At some point I should dig into this one |
|
421 | # and barfs out. At some point I should dig into this one | |
422 | # and file a bug report about it. |
|
422 | # and file a bug report about it. | |
423 | inspect_error() |
|
423 | inspect_error() | |
424 | traceback.print_exc(file=Term.cerr) |
|
424 | traceback.print_exc(file=Term.cerr) | |
425 | info("\nIPython's exception reporting continues...\n") |
|
425 | info("\nIPython's exception reporting continues...\n") | |
426 | call = tpl_call_fail % func |
|
426 | call = tpl_call_fail % func | |
427 |
|
427 | |||
428 | # Initialize a list of names on the current line, which the |
|
428 | # Initialize a list of names on the current line, which the | |
429 | # tokenizer below will populate. |
|
429 | # tokenizer below will populate. | |
430 | names = [] |
|
430 | names = [] | |
431 |
|
431 | |||
432 | def tokeneater(token_type, token, start, end, line): |
|
432 | def tokeneater(token_type, token, start, end, line): | |
433 | """Stateful tokeneater which builds dotted names. |
|
433 | """Stateful tokeneater which builds dotted names. | |
434 |
|
434 | |||
435 | The list of names it appends to (from the enclosing scope) can |
|
435 | The list of names it appends to (from the enclosing scope) can | |
436 | contain repeated composite names. This is unavoidable, since |
|
436 | contain repeated composite names. This is unavoidable, since | |
437 | there is no way to disambguate partial dotted structures until |
|
437 | there is no way to disambguate partial dotted structures until | |
438 | the full list is known. The caller is responsible for pruning |
|
438 | the full list is known. The caller is responsible for pruning | |
439 | the final list of duplicates before using it.""" |
|
439 | the final list of duplicates before using it.""" | |
440 |
|
440 | |||
441 | # build composite names |
|
441 | # build composite names | |
442 | if token == '.': |
|
442 | if token == '.': | |
443 | try: |
|
443 | try: | |
444 | names[-1] += '.' |
|
444 | names[-1] += '.' | |
445 | # store state so the next token is added for x.y.z names |
|
445 | # store state so the next token is added for x.y.z names | |
446 | tokeneater.name_cont = True |
|
446 | tokeneater.name_cont = True | |
447 | return |
|
447 | return | |
448 | except IndexError: |
|
448 | except IndexError: | |
449 | pass |
|
449 | pass | |
450 | if token_type == tokenize.NAME and token not in keyword.kwlist: |
|
450 | if token_type == tokenize.NAME and token not in keyword.kwlist: | |
451 | if tokeneater.name_cont: |
|
451 | if tokeneater.name_cont: | |
452 | # Dotted names |
|
452 | # Dotted names | |
453 | names[-1] += token |
|
453 | names[-1] += token | |
454 | tokeneater.name_cont = False |
|
454 | tokeneater.name_cont = False | |
455 | else: |
|
455 | else: | |
456 | # Regular new names. We append everything, the caller |
|
456 | # Regular new names. We append everything, the caller | |
457 | # will be responsible for pruning the list later. It's |
|
457 | # will be responsible for pruning the list later. It's | |
458 | # very tricky to try to prune as we go, b/c composite |
|
458 | # very tricky to try to prune as we go, b/c composite | |
459 | # names can fool us. The pruning at the end is easy |
|
459 | # names can fool us. The pruning at the end is easy | |
460 | # to do (or the caller can print a list with repeated |
|
460 | # to do (or the caller can print a list with repeated | |
461 | # names if so desired. |
|
461 | # names if so desired. | |
462 | names.append(token) |
|
462 | names.append(token) | |
463 | elif token_type == tokenize.NEWLINE: |
|
463 | elif token_type == tokenize.NEWLINE: | |
464 | raise IndexError |
|
464 | raise IndexError | |
465 | # we need to store a bit of state in the tokenizer to build |
|
465 | # we need to store a bit of state in the tokenizer to build | |
466 | # dotted names |
|
466 | # dotted names | |
467 | tokeneater.name_cont = False |
|
467 | tokeneater.name_cont = False | |
468 |
|
468 | |||
469 | def linereader(file=file, lnum=[lnum], getline=linecache.getline): |
|
469 | def linereader(file=file, lnum=[lnum], getline=linecache.getline): | |
470 | line = getline(file, lnum[0]) |
|
470 | line = getline(file, lnum[0]) | |
471 | lnum[0] += 1 |
|
471 | lnum[0] += 1 | |
472 | return line |
|
472 | return line | |
473 |
|
473 | |||
474 | # Build the list of names on this line of code where the exception |
|
474 | # Build the list of names on this line of code where the exception | |
475 | # occurred. |
|
475 | # occurred. | |
476 | try: |
|
476 | try: | |
477 | # This builds the names list in-place by capturing it from the |
|
477 | # This builds the names list in-place by capturing it from the | |
478 | # enclosing scope. |
|
478 | # enclosing scope. | |
479 | tokenize.tokenize(linereader, tokeneater) |
|
479 | tokenize.tokenize(linereader, tokeneater) | |
480 | except IndexError: |
|
480 | except IndexError: | |
481 | # signals exit of tokenizer |
|
481 | # signals exit of tokenizer | |
482 | pass |
|
482 | pass | |
483 | except tokenize.TokenError,msg: |
|
483 | except tokenize.TokenError,msg: | |
484 | _m = ("An unexpected error occurred while tokenizing input\n" |
|
484 | _m = ("An unexpected error occurred while tokenizing input\n" | |
485 | "The following traceback may be corrupted or invalid\n" |
|
485 | "The following traceback may be corrupted or invalid\n" | |
486 | "The error message is: %s\n" % msg) |
|
486 | "The error message is: %s\n" % msg) | |
487 | error(_m) |
|
487 | error(_m) | |
488 |
|
488 | |||
489 | # prune names list of duplicates, but keep the right order |
|
489 | # prune names list of duplicates, but keep the right order | |
490 | unique_names = uniq_stable(names) |
|
490 | unique_names = uniq_stable(names) | |
491 |
|
491 | |||
492 | # Start loop over vars |
|
492 | # Start loop over vars | |
493 | lvals = [] |
|
493 | lvals = [] | |
494 | if self.include_vars: |
|
494 | if self.include_vars: | |
495 | for name_full in unique_names: |
|
495 | for name_full in unique_names: | |
496 | name_base = name_full.split('.',1)[0] |
|
496 | name_base = name_full.split('.',1)[0] | |
497 | if name_base in frame.f_code.co_varnames: |
|
497 | if name_base in frame.f_code.co_varnames: | |
498 | if locals.has_key(name_base): |
|
498 | if locals.has_key(name_base): | |
499 | try: |
|
499 | try: | |
500 | value = repr(eval(name_full,locals)) |
|
500 | value = repr(eval(name_full,locals)) | |
501 | except: |
|
501 | except: | |
502 | value = undefined |
|
502 | value = undefined | |
503 | else: |
|
503 | else: | |
504 | value = undefined |
|
504 | value = undefined | |
505 | name = tpl_local_var % name_full |
|
505 | name = tpl_local_var % name_full | |
506 | else: |
|
506 | else: | |
507 | if frame.f_globals.has_key(name_base): |
|
507 | if frame.f_globals.has_key(name_base): | |
508 | try: |
|
508 | try: | |
509 | value = repr(eval(name_full,frame.f_globals)) |
|
509 | value = repr(eval(name_full,frame.f_globals)) | |
510 | except: |
|
510 | except: | |
511 | value = undefined |
|
511 | value = undefined | |
512 | else: |
|
512 | else: | |
513 | value = undefined |
|
513 | value = undefined | |
514 | name = tpl_global_var % name_full |
|
514 | name = tpl_global_var % name_full | |
515 | lvals.append(tpl_name_val % (name,value)) |
|
515 | lvals.append(tpl_name_val % (name,value)) | |
516 | if lvals: |
|
516 | if lvals: | |
517 | lvals = '%s%s' % (indent,em_normal.join(lvals)) |
|
517 | lvals = '%s%s' % (indent,em_normal.join(lvals)) | |
518 | else: |
|
518 | else: | |
519 | lvals = '' |
|
519 | lvals = '' | |
520 |
|
520 | |||
521 | level = '%s %s\n' % (link,call) |
|
521 | level = '%s %s\n' % (link,call) | |
522 | excerpt = [] |
|
522 | excerpt = [] | |
523 | if index is not None: |
|
523 | if index is not None: | |
524 | i = lnum - index |
|
524 | i = lnum - index | |
525 | for line in lines: |
|
525 | for line in lines: | |
526 | if i == lnum: |
|
526 | if i == lnum: | |
527 | # This is the line with the error |
|
527 | # This is the line with the error | |
528 | pad = numbers_width - len(str(i)) |
|
528 | pad = numbers_width - len(str(i)) | |
529 | if pad >= 3: |
|
529 | if pad >= 3: | |
530 | marker = '-'*(pad-3) + '-> ' |
|
530 | marker = '-'*(pad-3) + '-> ' | |
531 | elif pad == 2: |
|
531 | elif pad == 2: | |
532 | marker = '> ' |
|
532 | marker = '> ' | |
533 | elif pad == 1: |
|
533 | elif pad == 1: | |
534 | marker = '>' |
|
534 | marker = '>' | |
535 | else: |
|
535 | else: | |
536 | marker = '' |
|
536 | marker = '' | |
537 | num = '%s%s' % (marker,i) |
|
537 | num = '%s%s' % (marker,i) | |
538 | line = tpl_line_em % (num,line) |
|
538 | line = tpl_line_em % (num,line) | |
539 | else: |
|
539 | else: | |
540 | num = '%*s' % (numbers_width,i) |
|
540 | num = '%*s' % (numbers_width,i) | |
541 | line = tpl_line % (num,line) |
|
541 | line = tpl_line % (num,line) | |
542 |
|
542 | |||
543 | excerpt.append(line) |
|
543 | excerpt.append(line) | |
544 | if self.include_vars and i == lnum: |
|
544 | if self.include_vars and i == lnum: | |
545 | excerpt.append('%s\n' % lvals) |
|
545 | excerpt.append('%s\n' % lvals) | |
546 | i += 1 |
|
546 | i += 1 | |
547 | frames.append('%s%s' % (level,''.join(excerpt)) ) |
|
547 | frames.append('%s%s' % (level,''.join(excerpt)) ) | |
548 |
|
548 | |||
549 | # Get (safely) a string form of the exception info |
|
549 | # Get (safely) a string form of the exception info | |
550 | try: |
|
550 | try: | |
551 | etype_str,evalue_str = map(str,(etype,evalue)) |
|
551 | etype_str,evalue_str = map(str,(etype,evalue)) | |
552 | except: |
|
552 | except: | |
553 | # User exception is improperly defined. |
|
553 | # User exception is improperly defined. | |
554 | etype,evalue = str,sys.exc_info()[:2] |
|
554 | etype,evalue = str,sys.exc_info()[:2] | |
555 | etype_str,evalue_str = map(str,(etype,evalue)) |
|
555 | etype_str,evalue_str = map(str,(etype,evalue)) | |
556 | # ... and format it |
|
556 | # ... and format it | |
557 | exception = ['%s%s%s: %s' % (Colors.excName, etype_str, |
|
557 | exception = ['%s%s%s: %s' % (Colors.excName, etype_str, | |
558 | ColorsNormal, evalue_str)] |
|
558 | ColorsNormal, evalue_str)] | |
559 | if type(evalue) is types.InstanceType: |
|
559 | if type(evalue) is types.InstanceType: | |
560 | try: |
|
560 | try: | |
561 | names = [w for w in dir(evalue) if isinstance(w, basestring)] |
|
561 | names = [w for w in dir(evalue) if isinstance(w, basestring)] | |
562 | except: |
|
562 | except: | |
563 | # Every now and then, an object with funny inernals blows up |
|
563 | # Every now and then, an object with funny inernals blows up | |
564 | # when dir() is called on it. We do the best we can to report |
|
564 | # when dir() is called on it. We do the best we can to report | |
565 | # the problem and continue |
|
565 | # the problem and continue | |
566 | _m = '%sException reporting error (object with broken dir())%s:' |
|
566 | _m = '%sException reporting error (object with broken dir())%s:' | |
567 | exception.append(_m % (Colors.excName,ColorsNormal)) |
|
567 | exception.append(_m % (Colors.excName,ColorsNormal)) | |
568 | etype_str,evalue_str = map(str,sys.exc_info()[:2]) |
|
568 | etype_str,evalue_str = map(str,sys.exc_info()[:2]) | |
569 | exception.append('%s%s%s: %s' % (Colors.excName,etype_str, |
|
569 | exception.append('%s%s%s: %s' % (Colors.excName,etype_str, | |
570 | ColorsNormal, evalue_str)) |
|
570 | ColorsNormal, evalue_str)) | |
571 | names = [] |
|
571 | names = [] | |
572 | for name in names: |
|
572 | for name in names: | |
573 | value = text_repr(getattr(evalue, name)) |
|
573 | value = text_repr(getattr(evalue, name)) | |
574 | exception.append('\n%s%s = %s' % (indent, name, value)) |
|
574 | exception.append('\n%s%s = %s' % (indent, name, value)) | |
575 | # return all our info assembled as a single string |
|
575 | # return all our info assembled as a single string | |
576 | return '%s\n\n%s\n%s' % (head,'\n'.join(frames),''.join(exception[0]) ) |
|
576 | return '%s\n\n%s\n%s' % (head,'\n'.join(frames),''.join(exception[0]) ) | |
577 |
|
577 | |||
578 | def debugger(self): |
|
578 | def debugger(self): | |
579 | """Call up the pdb debugger if desired, always clean up the tb reference. |
|
579 | """Call up the pdb debugger if desired, always clean up the tb reference. | |
580 |
|
580 | |||
581 | If the call_pdb flag is set, the pdb interactive debugger is |
|
581 | If the call_pdb flag is set, the pdb interactive debugger is | |
582 | invoked. In all cases, the self.tb reference to the current traceback |
|
582 | invoked. In all cases, the self.tb reference to the current traceback | |
583 | is deleted to prevent lingering references which hamper memory |
|
583 | is deleted to prevent lingering references which hamper memory | |
584 | management. |
|
584 | management. | |
585 |
|
585 | |||
586 | Note that each call to pdb() does an 'import readline', so if your app |
|
586 | Note that each call to pdb() does an 'import readline', so if your app | |
587 | requires a special setup for the readline completers, you'll have to |
|
587 | requires a special setup for the readline completers, you'll have to | |
588 | fix that by hand after invoking the exception handler.""" |
|
588 | fix that by hand after invoking the exception handler.""" | |
589 |
|
589 | |||
590 | if self.call_pdb: |
|
590 | if self.call_pdb: | |
591 | if self.pdb is None: |
|
591 | if self.pdb is None: | |
592 | self.pdb = Debugger.Pdb( |
|
592 | self.pdb = Debugger.Pdb( | |
593 | self.color_scheme_table.active_scheme_name) |
|
593 | self.color_scheme_table.active_scheme_name) | |
594 | # the system displayhook may have changed, restore the original |
|
594 | # the system displayhook may have changed, restore the original | |
595 | # for pdb |
|
595 | # for pdb | |
596 | dhook = sys.displayhook |
|
596 | dhook = sys.displayhook | |
597 | sys.displayhook = sys.__displayhook__ |
|
597 | sys.displayhook = sys.__displayhook__ | |
598 | self.pdb.reset() |
|
598 | self.pdb.reset() | |
599 | # Find the right frame so we don't pop up inside ipython itself |
|
599 | # Find the right frame so we don't pop up inside ipython itself | |
600 | etb = self.tb |
|
600 | etb = self.tb | |
601 | while self.tb.tb_next is not None: |
|
601 | while self.tb.tb_next is not None: | |
602 | self.tb = self.tb.tb_next |
|
602 | self.tb = self.tb.tb_next | |
603 | try: |
|
603 | try: | |
604 | if etb and etb.tb_next: |
|
604 | if etb and etb.tb_next: | |
605 | etb = etb.tb_next |
|
605 | etb = etb.tb_next | |
606 | self.pdb.botframe = etb.tb_frame |
|
606 | self.pdb.botframe = etb.tb_frame | |
607 | self.pdb.interaction(self.tb.tb_frame, self.tb) |
|
607 | self.pdb.interaction(self.tb.tb_frame, self.tb) | |
608 | except: |
|
608 | except: | |
609 | print '*** ERROR ***' |
|
609 | print '*** ERROR ***' | |
610 | print 'This version of pdb has a bug and crashed.' |
|
610 | print 'This version of pdb has a bug and crashed.' | |
611 | print 'Returning to IPython...' |
|
611 | print 'Returning to IPython...' | |
612 | sys.displayhook = dhook |
|
612 | sys.displayhook = dhook | |
613 | del self.tb |
|
613 | del self.tb | |
614 |
|
614 | |||
615 | def handler(self, info=None): |
|
615 | def handler(self, info=None): | |
616 | (etype, evalue, etb) = info or sys.exc_info() |
|
616 | (etype, evalue, etb) = info or sys.exc_info() | |
617 | self.tb = etb |
|
617 | self.tb = etb | |
618 | print >> Term.cerr, self.text(etype, evalue, etb) |
|
618 | print >> Term.cerr, self.text(etype, evalue, etb) | |
619 |
|
619 | |||
620 | # Changed so an instance can just be called as VerboseTB_inst() and print |
|
620 | # Changed so an instance can just be called as VerboseTB_inst() and print | |
621 | # out the right info on its own. |
|
621 | # out the right info on its own. | |
622 | def __call__(self, etype=None, evalue=None, etb=None): |
|
622 | def __call__(self, etype=None, evalue=None, etb=None): | |
623 | """This hook can replace sys.excepthook (for Python 2.1 or higher).""" |
|
623 | """This hook can replace sys.excepthook (for Python 2.1 or higher).""" | |
624 |
if etb is |
|
624 | if etb is None: | |
625 | self.handler((etype, evalue, etb)) |
|
|||
626 | else: |
|
|||
627 | self.handler() |
|
625 | self.handler() | |
|
626 | else: | |||
|
627 | self.handler((etype, evalue, etb)) | |||
628 | self.debugger() |
|
628 | self.debugger() | |
629 |
|
629 | |||
630 | #---------------------------------------------------------------------------- |
|
630 | #---------------------------------------------------------------------------- | |
631 | class FormattedTB(VerboseTB,ListTB): |
|
631 | class FormattedTB(VerboseTB,ListTB): | |
632 | """Subclass ListTB but allow calling with a traceback. |
|
632 | """Subclass ListTB but allow calling with a traceback. | |
633 |
|
633 | |||
634 | It can thus be used as a sys.excepthook for Python > 2.1. |
|
634 | It can thus be used as a sys.excepthook for Python > 2.1. | |
635 |
|
635 | |||
636 | Also adds 'Context' and 'Verbose' modes, not available in ListTB. |
|
636 | Also adds 'Context' and 'Verbose' modes, not available in ListTB. | |
637 |
|
637 | |||
638 | Allows a tb_offset to be specified. This is useful for situations where |
|
638 | Allows a tb_offset to be specified. This is useful for situations where | |
639 | one needs to remove a number of topmost frames from the traceback (such as |
|
639 | one needs to remove a number of topmost frames from the traceback (such as | |
640 | occurs with python programs that themselves execute other python code, |
|
640 | occurs with python programs that themselves execute other python code, | |
641 | like Python shells). """ |
|
641 | like Python shells). """ | |
642 |
|
642 | |||
643 | def __init__(self, mode = 'Plain', color_scheme='Linux', |
|
643 | def __init__(self, mode = 'Plain', color_scheme='Linux', | |
644 | tb_offset = 0,long_header=0,call_pdb=0,include_vars=0): |
|
644 | tb_offset = 0,long_header=0,call_pdb=0,include_vars=0): | |
645 |
|
645 | |||
646 | # NEVER change the order of this list. Put new modes at the end: |
|
646 | # NEVER change the order of this list. Put new modes at the end: | |
647 | self.valid_modes = ['Plain','Context','Verbose'] |
|
647 | self.valid_modes = ['Plain','Context','Verbose'] | |
648 | self.verbose_modes = self.valid_modes[1:3] |
|
648 | self.verbose_modes = self.valid_modes[1:3] | |
649 |
|
649 | |||
650 | VerboseTB.__init__(self,color_scheme,tb_offset,long_header, |
|
650 | VerboseTB.__init__(self,color_scheme,tb_offset,long_header, | |
651 | call_pdb=call_pdb,include_vars=include_vars) |
|
651 | call_pdb=call_pdb,include_vars=include_vars) | |
652 | self.set_mode(mode) |
|
652 | self.set_mode(mode) | |
653 |
|
653 | |||
654 | def _extract_tb(self,tb): |
|
654 | def _extract_tb(self,tb): | |
655 | if tb: |
|
655 | if tb: | |
656 | return traceback.extract_tb(tb) |
|
656 | return traceback.extract_tb(tb) | |
657 | else: |
|
657 | else: | |
658 | return None |
|
658 | return None | |
659 |
|
659 | |||
660 | def text(self, etype, value, tb,context=5,mode=None): |
|
660 | def text(self, etype, value, tb,context=5,mode=None): | |
661 | """Return formatted traceback. |
|
661 | """Return formatted traceback. | |
662 |
|
662 | |||
663 | If the optional mode parameter is given, it overrides the current |
|
663 | If the optional mode parameter is given, it overrides the current | |
664 | mode.""" |
|
664 | mode.""" | |
665 |
|
665 | |||
666 | if mode is None: |
|
666 | if mode is None: | |
667 | mode = self.mode |
|
667 | mode = self.mode | |
668 | if mode in self.verbose_modes: |
|
668 | if mode in self.verbose_modes: | |
669 | # verbose modes need a full traceback |
|
669 | # verbose modes need a full traceback | |
670 | return VerboseTB.text(self,etype, value, tb,context=5) |
|
670 | return VerboseTB.text(self,etype, value, tb,context=5) | |
671 | else: |
|
671 | else: | |
672 | # We must check the source cache because otherwise we can print |
|
672 | # We must check the source cache because otherwise we can print | |
673 | # out-of-date source code. |
|
673 | # out-of-date source code. | |
674 | linecache.checkcache() |
|
674 | linecache.checkcache() | |
675 | # Now we can extract and format the exception |
|
675 | # Now we can extract and format the exception | |
676 | elist = self._extract_tb(tb) |
|
676 | elist = self._extract_tb(tb) | |
677 | if len(elist) > self.tb_offset: |
|
677 | if len(elist) > self.tb_offset: | |
678 | del elist[:self.tb_offset] |
|
678 | del elist[:self.tb_offset] | |
679 | return ListTB.text(self,etype,value,elist) |
|
679 | return ListTB.text(self,etype,value,elist) | |
680 |
|
680 | |||
681 | def set_mode(self,mode=None): |
|
681 | def set_mode(self,mode=None): | |
682 | """Switch to the desired mode. |
|
682 | """Switch to the desired mode. | |
683 |
|
683 | |||
684 | If mode is not specified, cycles through the available modes.""" |
|
684 | If mode is not specified, cycles through the available modes.""" | |
685 |
|
685 | |||
686 | if not mode: |
|
686 | if not mode: | |
687 | new_idx = ( self.valid_modes.index(self.mode) + 1 ) % \ |
|
687 | new_idx = ( self.valid_modes.index(self.mode) + 1 ) % \ | |
688 | len(self.valid_modes) |
|
688 | len(self.valid_modes) | |
689 | self.mode = self.valid_modes[new_idx] |
|
689 | self.mode = self.valid_modes[new_idx] | |
690 | elif mode not in self.valid_modes: |
|
690 | elif mode not in self.valid_modes: | |
691 | raise ValueError, 'Unrecognized mode in FormattedTB: <'+mode+'>\n'\ |
|
691 | raise ValueError, 'Unrecognized mode in FormattedTB: <'+mode+'>\n'\ | |
692 | 'Valid modes: '+str(self.valid_modes) |
|
692 | 'Valid modes: '+str(self.valid_modes) | |
693 | else: |
|
693 | else: | |
694 | self.mode = mode |
|
694 | self.mode = mode | |
695 | # include variable details only in 'Verbose' mode |
|
695 | # include variable details only in 'Verbose' mode | |
696 | self.include_vars = (self.mode == self.valid_modes[2]) |
|
696 | self.include_vars = (self.mode == self.valid_modes[2]) | |
697 |
|
697 | |||
698 | # some convenient shorcuts |
|
698 | # some convenient shorcuts | |
699 | def plain(self): |
|
699 | def plain(self): | |
700 | self.set_mode(self.valid_modes[0]) |
|
700 | self.set_mode(self.valid_modes[0]) | |
701 |
|
701 | |||
702 | def context(self): |
|
702 | def context(self): | |
703 | self.set_mode(self.valid_modes[1]) |
|
703 | self.set_mode(self.valid_modes[1]) | |
704 |
|
704 | |||
705 | def verbose(self): |
|
705 | def verbose(self): | |
706 | self.set_mode(self.valid_modes[2]) |
|
706 | self.set_mode(self.valid_modes[2]) | |
707 |
|
707 | |||
708 | #---------------------------------------------------------------------------- |
|
708 | #---------------------------------------------------------------------------- | |
709 | class AutoFormattedTB(FormattedTB): |
|
709 | class AutoFormattedTB(FormattedTB): | |
710 | """A traceback printer which can be called on the fly. |
|
710 | """A traceback printer which can be called on the fly. | |
711 |
|
711 | |||
712 | It will find out about exceptions by itself. |
|
712 | It will find out about exceptions by itself. | |
713 |
|
713 | |||
714 | A brief example: |
|
714 | A brief example: | |
715 |
|
715 | |||
716 | AutoTB = AutoFormattedTB(mode = 'Verbose',color_scheme='Linux') |
|
716 | AutoTB = AutoFormattedTB(mode = 'Verbose',color_scheme='Linux') | |
717 | try: |
|
717 | try: | |
718 | ... |
|
718 | ... | |
719 | except: |
|
719 | except: | |
720 | AutoTB() # or AutoTB(out=logfile) where logfile is an open file object |
|
720 | AutoTB() # or AutoTB(out=logfile) where logfile is an open file object | |
721 | """ |
|
721 | """ | |
722 | def __call__(self,etype=None,evalue=None,etb=None, |
|
722 | def __call__(self,etype=None,evalue=None,etb=None, | |
723 | out=None,tb_offset=None): |
|
723 | out=None,tb_offset=None): | |
724 | """Print out a formatted exception traceback. |
|
724 | """Print out a formatted exception traceback. | |
725 |
|
725 | |||
726 | Optional arguments: |
|
726 | Optional arguments: | |
727 | - out: an open file-like object to direct output to. |
|
727 | - out: an open file-like object to direct output to. | |
728 |
|
728 | |||
729 | - tb_offset: the number of frames to skip over in the stack, on a |
|
729 | - tb_offset: the number of frames to skip over in the stack, on a | |
730 | per-call basis (this overrides temporarily the instance's tb_offset |
|
730 | per-call basis (this overrides temporarily the instance's tb_offset | |
731 | given at initialization time. """ |
|
731 | given at initialization time. """ | |
732 |
|
732 | |||
733 | if out is None: |
|
733 | if out is None: | |
734 | out = Term.cerr |
|
734 | out = Term.cerr | |
735 | if tb_offset is not None: |
|
735 | if tb_offset is not None: | |
736 | tb_offset, self.tb_offset = self.tb_offset, tb_offset |
|
736 | tb_offset, self.tb_offset = self.tb_offset, tb_offset | |
737 | print >> out, self.text(etype, evalue, etb) |
|
737 | print >> out, self.text(etype, evalue, etb) | |
738 | self.tb_offset = tb_offset |
|
738 | self.tb_offset = tb_offset | |
739 | else: |
|
739 | else: | |
740 | print >> out, self.text(etype, evalue, etb) |
|
740 | print >> out, self.text(etype, evalue, etb) | |
741 | self.debugger() |
|
741 | self.debugger() | |
742 |
|
742 | |||
743 | def text(self,etype=None,value=None,tb=None,context=5,mode=None): |
|
743 | def text(self,etype=None,value=None,tb=None,context=5,mode=None): | |
744 | if etype is None: |
|
744 | if etype is None: | |
745 | etype,value,tb = sys.exc_info() |
|
745 | etype,value,tb = sys.exc_info() | |
746 | self.tb = tb |
|
746 | self.tb = tb | |
747 | return FormattedTB.text(self,etype,value,tb,context=5,mode=mode) |
|
747 | return FormattedTB.text(self,etype,value,tb,context=5,mode=mode) | |
748 |
|
748 | |||
749 | #--------------------------------------------------------------------------- |
|
749 | #--------------------------------------------------------------------------- | |
750 | # A simple class to preserve Nathan's original functionality. |
|
750 | # A simple class to preserve Nathan's original functionality. | |
751 | class ColorTB(FormattedTB): |
|
751 | class ColorTB(FormattedTB): | |
752 | """Shorthand to initialize a FormattedTB in Linux colors mode.""" |
|
752 | """Shorthand to initialize a FormattedTB in Linux colors mode.""" | |
753 | def __init__(self,color_scheme='Linux',call_pdb=0): |
|
753 | def __init__(self,color_scheme='Linux',call_pdb=0): | |
754 | FormattedTB.__init__(self,color_scheme=color_scheme, |
|
754 | FormattedTB.__init__(self,color_scheme=color_scheme, | |
755 | call_pdb=call_pdb) |
|
755 | call_pdb=call_pdb) | |
756 |
|
756 | |||
757 | #---------------------------------------------------------------------------- |
|
757 | #---------------------------------------------------------------------------- | |
758 | # module testing (minimal) |
|
758 | # module testing (minimal) | |
759 | if __name__ == "__main__": |
|
759 | if __name__ == "__main__": | |
760 | def spam(c, (d, e)): |
|
760 | def spam(c, (d, e)): | |
761 | x = c + d |
|
761 | x = c + d | |
762 | y = c * d |
|
762 | y = c * d | |
763 | foo(x, y) |
|
763 | foo(x, y) | |
764 |
|
764 | |||
765 | def foo(a, b, bar=1): |
|
765 | def foo(a, b, bar=1): | |
766 | eggs(a, b + bar) |
|
766 | eggs(a, b + bar) | |
767 |
|
767 | |||
768 | def eggs(f, g, z=globals()): |
|
768 | def eggs(f, g, z=globals()): | |
769 | h = f + g |
|
769 | h = f + g | |
770 | i = f - g |
|
770 | i = f - g | |
771 | return h / i |
|
771 | return h / i | |
772 |
|
772 | |||
773 | print '' |
|
773 | print '' | |
774 | print '*** Before ***' |
|
774 | print '*** Before ***' | |
775 | try: |
|
775 | try: | |
776 | print spam(1, (2, 3)) |
|
776 | print spam(1, (2, 3)) | |
777 | except: |
|
777 | except: | |
778 | traceback.print_exc() |
|
778 | traceback.print_exc() | |
779 | print '' |
|
779 | print '' | |
780 |
|
780 | |||
781 | handler = ColorTB() |
|
781 | handler = ColorTB() | |
782 | print '*** ColorTB ***' |
|
782 | print '*** ColorTB ***' | |
783 | try: |
|
783 | try: | |
784 | print spam(1, (2, 3)) |
|
784 | print spam(1, (2, 3)) | |
785 | except: |
|
785 | except: | |
786 | apply(handler, sys.exc_info() ) |
|
786 | apply(handler, sys.exc_info() ) | |
787 | print '' |
|
787 | print '' | |
788 |
|
788 | |||
789 | handler = VerboseTB() |
|
789 | handler = VerboseTB() | |
790 | print '*** VerboseTB ***' |
|
790 | print '*** VerboseTB ***' | |
791 | try: |
|
791 | try: | |
792 | print spam(1, (2, 3)) |
|
792 | print spam(1, (2, 3)) | |
793 | except: |
|
793 | except: | |
794 | apply(handler, sys.exc_info() ) |
|
794 | apply(handler, sys.exc_info() ) | |
795 | print '' |
|
795 | print '' | |
796 |
|
796 |
@@ -1,4587 +1,4599 b'' | |||||
1 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
2 | |||
3 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to |
|
3 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to | |
4 | better hadnle backslashes in paths. See the thread 'More Windows |
|
4 | better hadnle backslashes in paths. See the thread 'More Windows | |
5 | questions part 2 - \/ characters revisited' on the iypthon user |
|
5 | questions part 2 - \/ characters revisited' on the iypthon user | |
6 | list: |
|
6 | list: | |
7 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html |
|
7 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html | |
|
8 | ||||
8 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. |
|
9 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. | |
9 |
|
10 | |||
|
11 | (InteractiveShell.__init__): change threaded shells to not use the | |||
|
12 | ipython crash handler. This was causing more problems than not, | |||
|
13 | as exceptions in the main thread (GUI code, typically) would | |||
|
14 | always show up as a 'crash', when they really weren't. | |||
|
15 | ||||
|
16 | The colors and exception mode commands (%colors/%xmode) have been | |||
|
17 | synchronized to also take this into account, so users can get | |||
|
18 | verbose exceptions for their threaded code as well. I also added | |||
|
19 | support for activating pdb inside this exception handler as well, | |||
|
20 | so now GUI authors can use IPython's enhanced pdb at runtime. | |||
|
21 | ||||
10 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag |
|
22 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag | |
11 | true by default, and add it to the shipped ipythonrc file. Since |
|
23 | true by default, and add it to the shipped ipythonrc file. Since | |
12 | this asks the user before proceeding, I think it's OK to make it |
|
24 | this asks the user before proceeding, I think it's OK to make it | |
13 | true by default. |
|
25 | true by default. | |
14 |
|
26 | |||
15 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead |
|
27 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead | |
16 | of the previous special-casing of input in the eval loop. I think |
|
28 | of the previous special-casing of input in the eval loop. I think | |
17 | this is cleaner, as they really are commands and shouldn't have |
|
29 | this is cleaner, as they really are commands and shouldn't have | |
18 | a special role in the middle of the core code. |
|
30 | a special role in the middle of the core code. | |
19 |
|
31 | |||
20 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
32 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
21 |
|
33 | |||
22 | * IPython/iplib.py (edit_syntax_error): added support for |
|
34 | * IPython/iplib.py (edit_syntax_error): added support for | |
23 | automatically reopening the editor if the file had a syntax error |
|
35 | automatically reopening the editor if the file had a syntax error | |
24 | in it. Thanks to scottt who provided the patch at: |
|
36 | in it. Thanks to scottt who provided the patch at: | |
25 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified |
|
37 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified | |
26 | version committed). |
|
38 | version committed). | |
27 |
|
39 | |||
28 | * IPython/iplib.py (handle_normal): add suport for multi-line |
|
40 | * IPython/iplib.py (handle_normal): add suport for multi-line | |
29 | input with emtpy lines. This fixes |
|
41 | input with emtpy lines. This fixes | |
30 | http://www.scipy.net/roundup/ipython/issue43 and a similar |
|
42 | http://www.scipy.net/roundup/ipython/issue43 and a similar | |
31 | discussion on the user list. |
|
43 | discussion on the user list. | |
32 |
|
44 | |||
33 | WARNING: a behavior change is necessarily introduced to support |
|
45 | WARNING: a behavior change is necessarily introduced to support | |
34 | blank lines: now a single blank line with whitespace does NOT |
|
46 | blank lines: now a single blank line with whitespace does NOT | |
35 | break the input loop, which means that when autoindent is on, by |
|
47 | break the input loop, which means that when autoindent is on, by | |
36 | default hitting return on the next (indented) line does NOT exit. |
|
48 | default hitting return on the next (indented) line does NOT exit. | |
37 |
|
49 | |||
38 | Instead, to exit a multiline input you can either have: |
|
50 | Instead, to exit a multiline input you can either have: | |
39 |
|
51 | |||
40 | - TWO whitespace lines (just hit return again), or |
|
52 | - TWO whitespace lines (just hit return again), or | |
41 | - a single whitespace line of a different length than provided |
|
53 | - a single whitespace line of a different length than provided | |
42 | by the autoindent (add or remove a space). |
|
54 | by the autoindent (add or remove a space). | |
43 |
|
55 | |||
44 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' |
|
56 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' | |
45 | module to better organize all readline-related functionality. |
|
57 | module to better organize all readline-related functionality. | |
46 | I've deleted FlexCompleter and put all completion clases here. |
|
58 | I've deleted FlexCompleter and put all completion clases here. | |
47 |
|
59 | |||
48 | * IPython/iplib.py (raw_input): improve indentation management. |
|
60 | * IPython/iplib.py (raw_input): improve indentation management. | |
49 | It is now possible to paste indented code with autoindent on, and |
|
61 | It is now possible to paste indented code with autoindent on, and | |
50 | the code is interpreted correctly (though it still looks bad on |
|
62 | the code is interpreted correctly (though it still looks bad on | |
51 | screen, due to the line-oriented nature of ipython). |
|
63 | screen, due to the line-oriented nature of ipython). | |
52 | (MagicCompleter.complete): change behavior so that a TAB key on an |
|
64 | (MagicCompleter.complete): change behavior so that a TAB key on an | |
53 | otherwise empty line actually inserts a tab, instead of completing |
|
65 | otherwise empty line actually inserts a tab, instead of completing | |
54 | on the entire global namespace. This makes it easier to use the |
|
66 | on the entire global namespace. This makes it easier to use the | |
55 | TAB key for indentation. After a request by Hans Meine |
|
67 | TAB key for indentation. After a request by Hans Meine | |
56 | <hans_meine-AT-gmx.net> |
|
68 | <hans_meine-AT-gmx.net> | |
57 | (_prefilter): add support so that typing plain 'exit' or 'quit' |
|
69 | (_prefilter): add support so that typing plain 'exit' or 'quit' | |
58 | does a sensible thing. Originally I tried to deviate as little as |
|
70 | does a sensible thing. Originally I tried to deviate as little as | |
59 | possible from the default python behavior, but even that one may |
|
71 | possible from the default python behavior, but even that one may | |
60 | change in this direction (thread on python-dev to that effect). |
|
72 | change in this direction (thread on python-dev to that effect). | |
61 | Regardless, ipython should do the right thing even if CPython's |
|
73 | Regardless, ipython should do the right thing even if CPython's | |
62 | '>>>' prompt doesn't. |
|
74 | '>>>' prompt doesn't. | |
63 | (InteractiveShell): removed subclassing code.InteractiveConsole |
|
75 | (InteractiveShell): removed subclassing code.InteractiveConsole | |
64 | class. By now we'd overridden just about all of its methods: I've |
|
76 | class. By now we'd overridden just about all of its methods: I've | |
65 | copied the remaining two over, and now ipython is a standalone |
|
77 | copied the remaining two over, and now ipython is a standalone | |
66 | class. This will provide a clearer picture for the chainsaw |
|
78 | class. This will provide a clearer picture for the chainsaw | |
67 | branch refactoring. |
|
79 | branch refactoring. | |
68 |
|
80 | |||
69 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> |
|
81 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> | |
70 |
|
82 | |||
71 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against |
|
83 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against | |
72 | failures for objects which break when dir() is called on them. |
|
84 | failures for objects which break when dir() is called on them. | |
73 |
|
85 | |||
74 | * IPython/FlexCompleter.py (Completer.__init__): Added support for |
|
86 | * IPython/FlexCompleter.py (Completer.__init__): Added support for | |
75 | distinct local and global namespaces in the completer API. This |
|
87 | distinct local and global namespaces in the completer API. This | |
76 | change allows us top properly handle completion with distinct |
|
88 | change allows us top properly handle completion with distinct | |
77 | scopes, including in embedded instances (this had never really |
|
89 | scopes, including in embedded instances (this had never really | |
78 | worked correctly). |
|
90 | worked correctly). | |
79 |
|
91 | |||
80 | Note: this introduces a change in the constructor for |
|
92 | Note: this introduces a change in the constructor for | |
81 | MagicCompleter, as a new global_namespace parameter is now the |
|
93 | MagicCompleter, as a new global_namespace parameter is now the | |
82 | second argument (the others were bumped one position). |
|
94 | second argument (the others were bumped one position). | |
83 |
|
95 | |||
84 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
96 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> | |
85 |
|
97 | |||
86 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
98 | * IPython/iplib.py (embed_mainloop): fix tab-completion in | |
87 | embedded instances (which can be done now thanks to Vivian's |
|
99 | embedded instances (which can be done now thanks to Vivian's | |
88 | frame-handling fixes for pdb). |
|
100 | frame-handling fixes for pdb). | |
89 | (InteractiveShell.__init__): Fix namespace handling problem in |
|
101 | (InteractiveShell.__init__): Fix namespace handling problem in | |
90 | embedded instances. We were overwriting __main__ unconditionally, |
|
102 | embedded instances. We were overwriting __main__ unconditionally, | |
91 | and this should only be done for 'full' (non-embedded) IPython; |
|
103 | and this should only be done for 'full' (non-embedded) IPython; | |
92 | embedded instances must respect the caller's __main__. Thanks to |
|
104 | embedded instances must respect the caller's __main__. Thanks to | |
93 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> |
|
105 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> | |
94 |
|
106 | |||
95 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
107 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
96 |
|
108 | |||
97 | * setup.py: added download_url to setup(). This registers the |
|
109 | * setup.py: added download_url to setup(). This registers the | |
98 | download address at PyPI, which is not only useful to humans |
|
110 | download address at PyPI, which is not only useful to humans | |
99 | browsing the site, but is also picked up by setuptools (the Eggs |
|
111 | browsing the site, but is also picked up by setuptools (the Eggs | |
100 | machinery). Thanks to Ville and R. Kern for the info/discussion |
|
112 | machinery). Thanks to Ville and R. Kern for the info/discussion | |
101 | on this. |
|
113 | on this. | |
102 |
|
114 | |||
103 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
115 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
104 |
|
116 | |||
105 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. |
|
117 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. | |
106 | This brings a lot of nice functionality to the pdb mode, which now |
|
118 | This brings a lot of nice functionality to the pdb mode, which now | |
107 | has tab-completion, syntax highlighting, and better stack handling |
|
119 | has tab-completion, syntax highlighting, and better stack handling | |
108 | than before. Many thanks to Vivian De Smedt |
|
120 | than before. Many thanks to Vivian De Smedt | |
109 | <vivian-AT-vdesmedt.com> for the original patches. |
|
121 | <vivian-AT-vdesmedt.com> for the original patches. | |
110 |
|
122 | |||
111 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
123 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> | |
112 |
|
124 | |||
113 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling |
|
125 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling | |
114 | sequence to consistently accept the banner argument. The |
|
126 | sequence to consistently accept the banner argument. The | |
115 | inconsistency was tripping SAGE, thanks to Gary Zablackis |
|
127 | inconsistency was tripping SAGE, thanks to Gary Zablackis | |
116 | <gzabl-AT-yahoo.com> for the report. |
|
128 | <gzabl-AT-yahoo.com> for the report. | |
117 |
|
129 | |||
118 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
130 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
119 |
|
131 | |||
120 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
132 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
121 | Fix bug where a naked 'alias' call in the ipythonrc file would |
|
133 | Fix bug where a naked 'alias' call in the ipythonrc file would | |
122 | cause a crash. Bug reported by Jorgen Stenarson. |
|
134 | cause a crash. Bug reported by Jorgen Stenarson. | |
123 |
|
135 | |||
124 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
136 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
125 |
|
137 | |||
126 | * IPython/ipmaker.py (make_IPython): cleanups which should improve |
|
138 | * IPython/ipmaker.py (make_IPython): cleanups which should improve | |
127 | startup time. |
|
139 | startup time. | |
128 |
|
140 | |||
129 | * IPython/iplib.py (runcode): my globals 'fix' for embedded |
|
141 | * IPython/iplib.py (runcode): my globals 'fix' for embedded | |
130 | instances had introduced a bug with globals in normal code. Now |
|
142 | instances had introduced a bug with globals in normal code. Now | |
131 | it's working in all cases. |
|
143 | it's working in all cases. | |
132 |
|
144 | |||
133 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and |
|
145 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and | |
134 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' |
|
146 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' | |
135 | has been introduced to set the default case sensitivity of the |
|
147 | has been introduced to set the default case sensitivity of the | |
136 | searches. Users can still select either mode at runtime on a |
|
148 | searches. Users can still select either mode at runtime on a | |
137 | per-search basis. |
|
149 | per-search basis. | |
138 |
|
150 | |||
139 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
151 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> | |
140 |
|
152 | |||
141 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of |
|
153 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of | |
142 | attributes in wildcard searches for subclasses. Modified version |
|
154 | attributes in wildcard searches for subclasses. Modified version | |
143 | of a patch by Jorgen. |
|
155 | of a patch by Jorgen. | |
144 |
|
156 | |||
145 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
157 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
146 |
|
158 | |||
147 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for |
|
159 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for | |
148 | embedded instances. I added a user_global_ns attribute to the |
|
160 | embedded instances. I added a user_global_ns attribute to the | |
149 | InteractiveShell class to handle this. |
|
161 | InteractiveShell class to handle this. | |
150 |
|
162 | |||
151 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
163 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
152 |
|
164 | |||
153 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to |
|
165 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to | |
154 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 |
|
166 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 | |
155 | (reported under win32, but may happen also in other platforms). |
|
167 | (reported under win32, but may happen also in other platforms). | |
156 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> |
|
168 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> | |
157 |
|
169 | |||
158 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
170 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
159 |
|
171 | |||
160 | * IPython/Magic.py (magic_psearch): new support for wildcard |
|
172 | * IPython/Magic.py (magic_psearch): new support for wildcard | |
161 | patterns. Now, typing ?a*b will list all names which begin with a |
|
173 | patterns. Now, typing ?a*b will list all names which begin with a | |
162 | and end in b, for example. The %psearch magic has full |
|
174 | and end in b, for example. The %psearch magic has full | |
163 | docstrings. Many thanks to JΓΆrgen Stenarson |
|
175 | docstrings. Many thanks to JΓΆrgen Stenarson | |
164 | <jorgen.stenarson-AT-bostream.nu>, author of the patches |
|
176 | <jorgen.stenarson-AT-bostream.nu>, author of the patches | |
165 | implementing this functionality. |
|
177 | implementing this functionality. | |
166 |
|
178 | |||
167 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
179 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
168 |
|
180 | |||
169 | * Manual: fixed long-standing annoyance of double-dashes (as in |
|
181 | * Manual: fixed long-standing annoyance of double-dashes (as in | |
170 | --prefix=~, for example) being stripped in the HTML version. This |
|
182 | --prefix=~, for example) being stripped in the HTML version. This | |
171 | is a latex2html bug, but a workaround was provided. Many thanks |
|
183 | is a latex2html bug, but a workaround was provided. Many thanks | |
172 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed |
|
184 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed | |
173 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball |
|
185 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball | |
174 | rolling. This seemingly small issue had tripped a number of users |
|
186 | rolling. This seemingly small issue had tripped a number of users | |
175 | when first installing, so I'm glad to see it gone. |
|
187 | when first installing, so I'm glad to see it gone. | |
176 |
|
188 | |||
177 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
189 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
178 |
|
190 | |||
179 | * IPython/Extensions/numeric_formats.py: fix missing import, |
|
191 | * IPython/Extensions/numeric_formats.py: fix missing import, | |
180 | reported by Stephen Walton. |
|
192 | reported by Stephen Walton. | |
181 |
|
193 | |||
182 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
194 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
183 |
|
195 | |||
184 | * IPython/demo.py: finish demo module, fully documented now. |
|
196 | * IPython/demo.py: finish demo module, fully documented now. | |
185 |
|
197 | |||
186 | * IPython/genutils.py (file_read): simple little utility to read a |
|
198 | * IPython/genutils.py (file_read): simple little utility to read a | |
187 | file and ensure it's closed afterwards. |
|
199 | file and ensure it's closed afterwards. | |
188 |
|
200 | |||
189 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
201 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
190 |
|
202 | |||
191 | * IPython/demo.py (Demo.__init__): added support for individually |
|
203 | * IPython/demo.py (Demo.__init__): added support for individually | |
192 | tagging blocks for automatic execution. |
|
204 | tagging blocks for automatic execution. | |
193 |
|
205 | |||
194 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing |
|
206 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing | |
195 | syntax-highlighted python sources, requested by John. |
|
207 | syntax-highlighted python sources, requested by John. | |
196 |
|
208 | |||
197 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
209 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> | |
198 |
|
210 | |||
199 | * IPython/demo.py (Demo.again): fix bug where again() blocks after |
|
211 | * IPython/demo.py (Demo.again): fix bug where again() blocks after | |
200 | finishing. |
|
212 | finishing. | |
201 |
|
213 | |||
202 | * IPython/genutils.py (shlex_split): moved from Magic to here, |
|
214 | * IPython/genutils.py (shlex_split): moved from Magic to here, | |
203 | where all 2.2 compatibility stuff lives. I needed it for demo.py. |
|
215 | where all 2.2 compatibility stuff lives. I needed it for demo.py. | |
204 |
|
216 | |||
205 | * IPython/demo.py (Demo.__init__): added support for silent |
|
217 | * IPython/demo.py (Demo.__init__): added support for silent | |
206 | blocks, improved marks as regexps, docstrings written. |
|
218 | blocks, improved marks as regexps, docstrings written. | |
207 | (Demo.__init__): better docstring, added support for sys.argv. |
|
219 | (Demo.__init__): better docstring, added support for sys.argv. | |
208 |
|
220 | |||
209 | * IPython/genutils.py (marquee): little utility used by the demo |
|
221 | * IPython/genutils.py (marquee): little utility used by the demo | |
210 | code, handy in general. |
|
222 | code, handy in general. | |
211 |
|
223 | |||
212 | * IPython/demo.py (Demo.__init__): new class for interactive |
|
224 | * IPython/demo.py (Demo.__init__): new class for interactive | |
213 | demos. Not documented yet, I just wrote it in a hurry for |
|
225 | demos. Not documented yet, I just wrote it in a hurry for | |
214 | scipy'05. Will docstring later. |
|
226 | scipy'05. Will docstring later. | |
215 |
|
227 | |||
216 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
228 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> | |
217 |
|
229 | |||
218 | * IPython/Shell.py (sigint_handler): Drastic simplification which |
|
230 | * IPython/Shell.py (sigint_handler): Drastic simplification which | |
219 | also seems to make Ctrl-C work correctly across threads! This is |
|
231 | also seems to make Ctrl-C work correctly across threads! This is | |
220 | so simple, that I can't beleive I'd missed it before. Needs more |
|
232 | so simple, that I can't beleive I'd missed it before. Needs more | |
221 | testing, though. |
|
233 | testing, though. | |
222 | (KBINT): Never mind, revert changes. I'm sure I'd tried something |
|
234 | (KBINT): Never mind, revert changes. I'm sure I'd tried something | |
223 | like this before... |
|
235 | like this before... | |
224 |
|
236 | |||
225 | * IPython/genutils.py (get_home_dir): add protection against |
|
237 | * IPython/genutils.py (get_home_dir): add protection against | |
226 | non-dirs in win32 registry. |
|
238 | non-dirs in win32 registry. | |
227 |
|
239 | |||
228 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix |
|
240 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix | |
229 | bug where dict was mutated while iterating (pysh crash). |
|
241 | bug where dict was mutated while iterating (pysh crash). | |
230 |
|
242 | |||
231 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> |
|
243 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> | |
232 |
|
244 | |||
233 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from |
|
245 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from | |
234 | spurious newlines added by this routine. After a report by |
|
246 | spurious newlines added by this routine. After a report by | |
235 | F. Mantegazza. |
|
247 | F. Mantegazza. | |
236 |
|
248 | |||
237 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
249 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> | |
238 |
|
250 | |||
239 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") |
|
251 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") | |
240 | calls. These were a leftover from the GTK 1.x days, and can cause |
|
252 | calls. These were a leftover from the GTK 1.x days, and can cause | |
241 | problems in certain cases (after a report by John Hunter). |
|
253 | problems in certain cases (after a report by John Hunter). | |
242 |
|
254 | |||
243 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if |
|
255 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if | |
244 | os.getcwd() fails at init time. Thanks to patch from David Remahl |
|
256 | os.getcwd() fails at init time. Thanks to patch from David Remahl | |
245 | <chmod007-AT-mac.com>. |
|
257 | <chmod007-AT-mac.com>. | |
246 | (InteractiveShell.__init__): prevent certain special magics from |
|
258 | (InteractiveShell.__init__): prevent certain special magics from | |
247 | being shadowed by aliases. Closes |
|
259 | being shadowed by aliases. Closes | |
248 | http://www.scipy.net/roundup/ipython/issue41. |
|
260 | http://www.scipy.net/roundup/ipython/issue41. | |
249 |
|
261 | |||
250 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
262 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
251 |
|
263 | |||
252 | * IPython/iplib.py (InteractiveShell.complete): Added new |
|
264 | * IPython/iplib.py (InteractiveShell.complete): Added new | |
253 | top-level completion method to expose the completion mechanism |
|
265 | top-level completion method to expose the completion mechanism | |
254 | beyond readline-based environments. |
|
266 | beyond readline-based environments. | |
255 |
|
267 | |||
256 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> |
|
268 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> | |
257 |
|
269 | |||
258 | * tools/ipsvnc (svnversion): fix svnversion capture. |
|
270 | * tools/ipsvnc (svnversion): fix svnversion capture. | |
259 |
|
271 | |||
260 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline |
|
272 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline | |
261 | attribute to self, which was missing. Before, it was set by a |
|
273 | attribute to self, which was missing. Before, it was set by a | |
262 | routine which in certain cases wasn't being called, so the |
|
274 | routine which in certain cases wasn't being called, so the | |
263 | instance could end up missing the attribute. This caused a crash. |
|
275 | instance could end up missing the attribute. This caused a crash. | |
264 | Closes http://www.scipy.net/roundup/ipython/issue40. |
|
276 | Closes http://www.scipy.net/roundup/ipython/issue40. | |
265 |
|
277 | |||
266 | 2005-08-16 Fernando Perez <fperez@colorado.edu> |
|
278 | 2005-08-16 Fernando Perez <fperez@colorado.edu> | |
267 |
|
279 | |||
268 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object |
|
280 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object | |
269 | contains non-string attribute. Closes |
|
281 | contains non-string attribute. Closes | |
270 | http://www.scipy.net/roundup/ipython/issue38. |
|
282 | http://www.scipy.net/roundup/ipython/issue38. | |
271 |
|
283 | |||
272 | 2005-08-14 Fernando Perez <fperez@colorado.edu> |
|
284 | 2005-08-14 Fernando Perez <fperez@colorado.edu> | |
273 |
|
285 | |||
274 | * tools/ipsvnc: Minor improvements, to add changeset info. |
|
286 | * tools/ipsvnc: Minor improvements, to add changeset info. | |
275 |
|
287 | |||
276 | 2005-08-12 Fernando Perez <fperez@colorado.edu> |
|
288 | 2005-08-12 Fernando Perez <fperez@colorado.edu> | |
277 |
|
289 | |||
278 | * IPython/iplib.py (runsource): remove self.code_to_run_src |
|
290 | * IPython/iplib.py (runsource): remove self.code_to_run_src | |
279 | attribute. I realized this is nothing more than |
|
291 | attribute. I realized this is nothing more than | |
280 | '\n'.join(self.buffer), and having the same data in two different |
|
292 | '\n'.join(self.buffer), and having the same data in two different | |
281 | places is just asking for synchronization bugs. This may impact |
|
293 | places is just asking for synchronization bugs. This may impact | |
282 | people who have custom exception handlers, so I need to warn |
|
294 | people who have custom exception handlers, so I need to warn | |
283 | ipython-dev about it (F. Mantegazza may use them). |
|
295 | ipython-dev about it (F. Mantegazza may use them). | |
284 |
|
296 | |||
285 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
297 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
286 |
|
298 | |||
287 | * IPython/genutils.py: fix 2.2 compatibility (generators) |
|
299 | * IPython/genutils.py: fix 2.2 compatibility (generators) | |
288 |
|
300 | |||
289 | 2005-07-18 Fernando Perez <fperez@colorado.edu> |
|
301 | 2005-07-18 Fernando Perez <fperez@colorado.edu> | |
290 |
|
302 | |||
291 | * IPython/genutils.py (get_home_dir): fix to help users with |
|
303 | * IPython/genutils.py (get_home_dir): fix to help users with | |
292 | invalid $HOME under win32. |
|
304 | invalid $HOME under win32. | |
293 |
|
305 | |||
294 | 2005-07-17 Fernando Perez <fperez@colorado.edu> |
|
306 | 2005-07-17 Fernando Perez <fperez@colorado.edu> | |
295 |
|
307 | |||
296 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove |
|
308 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove | |
297 | some old hacks and clean up a bit other routines; code should be |
|
309 | some old hacks and clean up a bit other routines; code should be | |
298 | simpler and a bit faster. |
|
310 | simpler and a bit faster. | |
299 |
|
311 | |||
300 | * IPython/iplib.py (interact): removed some last-resort attempts |
|
312 | * IPython/iplib.py (interact): removed some last-resort attempts | |
301 | to survive broken stdout/stderr. That code was only making it |
|
313 | to survive broken stdout/stderr. That code was only making it | |
302 | harder to abstract out the i/o (necessary for gui integration), |
|
314 | harder to abstract out the i/o (necessary for gui integration), | |
303 | and the crashes it could prevent were extremely rare in practice |
|
315 | and the crashes it could prevent were extremely rare in practice | |
304 | (besides being fully user-induced in a pretty violent manner). |
|
316 | (besides being fully user-induced in a pretty violent manner). | |
305 |
|
317 | |||
306 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. |
|
318 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. | |
307 | Nothing major yet, but the code is simpler to read; this should |
|
319 | Nothing major yet, but the code is simpler to read; this should | |
308 | make it easier to do more serious modifications in the future. |
|
320 | make it easier to do more serious modifications in the future. | |
309 |
|
321 | |||
310 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, |
|
322 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, | |
311 | which broke in .15 (thanks to a report by Ville). |
|
323 | which broke in .15 (thanks to a report by Ville). | |
312 |
|
324 | |||
313 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not |
|
325 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not | |
314 | be quite correct, I know next to nothing about unicode). This |
|
326 | be quite correct, I know next to nothing about unicode). This | |
315 | will allow unicode strings to be used in prompts, amongst other |
|
327 | will allow unicode strings to be used in prompts, amongst other | |
316 | cases. It also will prevent ipython from crashing when unicode |
|
328 | cases. It also will prevent ipython from crashing when unicode | |
317 | shows up unexpectedly in many places. If ascii encoding fails, we |
|
329 | shows up unexpectedly in many places. If ascii encoding fails, we | |
318 | assume utf_8. Currently the encoding is not a user-visible |
|
330 | assume utf_8. Currently the encoding is not a user-visible | |
319 | setting, though it could be made so if there is demand for it. |
|
331 | setting, though it could be made so if there is demand for it. | |
320 |
|
332 | |||
321 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. |
|
333 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. | |
322 |
|
334 | |||
323 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. |
|
335 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. | |
324 |
|
336 | |||
325 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. |
|
337 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. | |
326 |
|
338 | |||
327 | * IPython/genutils.py: Add 2.2 compatibility here, so all other |
|
339 | * IPython/genutils.py: Add 2.2 compatibility here, so all other | |
328 | code can work transparently for 2.2/2.3. |
|
340 | code can work transparently for 2.2/2.3. | |
329 |
|
341 | |||
330 | 2005-07-16 Fernando Perez <fperez@colorado.edu> |
|
342 | 2005-07-16 Fernando Perez <fperez@colorado.edu> | |
331 |
|
343 | |||
332 | * IPython/ultraTB.py (ExceptionColors): Make a global variable |
|
344 | * IPython/ultraTB.py (ExceptionColors): Make a global variable | |
333 | out of the color scheme table used for coloring exception |
|
345 | out of the color scheme table used for coloring exception | |
334 | tracebacks. This allows user code to add new schemes at runtime. |
|
346 | tracebacks. This allows user code to add new schemes at runtime. | |
335 | This is a minimally modified version of the patch at |
|
347 | This is a minimally modified version of the patch at | |
336 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw |
|
348 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw | |
337 | for the contribution. |
|
349 | for the contribution. | |
338 |
|
350 | |||
339 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a |
|
351 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a | |
340 | slightly modified version of the patch in |
|
352 | slightly modified version of the patch in | |
341 | http://www.scipy.net/roundup/ipython/issue34, which also allows me |
|
353 | http://www.scipy.net/roundup/ipython/issue34, which also allows me | |
342 | to remove the previous try/except solution (which was costlier). |
|
354 | to remove the previous try/except solution (which was costlier). | |
343 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. |
|
355 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. | |
344 |
|
356 | |||
345 | 2005-06-08 Fernando Perez <fperez@colorado.edu> |
|
357 | 2005-06-08 Fernando Perez <fperez@colorado.edu> | |
346 |
|
358 | |||
347 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
|
359 | * IPython/iplib.py (write/write_err): Add methods to abstract all | |
348 | I/O a bit more. |
|
360 | I/O a bit more. | |
349 |
|
361 | |||
350 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation |
|
362 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation | |
351 | warning, reported by Aric Hagberg, fix by JD Hunter. |
|
363 | warning, reported by Aric Hagberg, fix by JD Hunter. | |
352 |
|
364 | |||
353 | 2005-06-02 *** Released version 0.6.15 |
|
365 | 2005-06-02 *** Released version 0.6.15 | |
354 |
|
366 | |||
355 | 2005-06-01 Fernando Perez <fperez@colorado.edu> |
|
367 | 2005-06-01 Fernando Perez <fperez@colorado.edu> | |
356 |
|
368 | |||
357 | * IPython/iplib.py (MagicCompleter.file_matches): Fix |
|
369 | * IPython/iplib.py (MagicCompleter.file_matches): Fix | |
358 | tab-completion of filenames within open-quoted strings. Note that |
|
370 | tab-completion of filenames within open-quoted strings. Note that | |
359 | this requires that in ~/.ipython/ipythonrc, users change the |
|
371 | this requires that in ~/.ipython/ipythonrc, users change the | |
360 | readline delimiters configuration to read: |
|
372 | readline delimiters configuration to read: | |
361 |
|
373 | |||
362 | readline_remove_delims -/~ |
|
374 | readline_remove_delims -/~ | |
363 |
|
375 | |||
364 |
|
376 | |||
365 | 2005-05-31 *** Released version 0.6.14 |
|
377 | 2005-05-31 *** Released version 0.6.14 | |
366 |
|
378 | |||
367 | 2005-05-29 Fernando Perez <fperez@colorado.edu> |
|
379 | 2005-05-29 Fernando Perez <fperez@colorado.edu> | |
368 |
|
380 | |||
369 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks |
|
381 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks | |
370 | with files not on the filesystem. Reported by Eliyahu Sandler |
|
382 | with files not on the filesystem. Reported by Eliyahu Sandler | |
371 | <eli@gondolin.net> |
|
383 | <eli@gondolin.net> | |
372 |
|
384 | |||
373 | 2005-05-22 Fernando Perez <fperez@colorado.edu> |
|
385 | 2005-05-22 Fernando Perez <fperez@colorado.edu> | |
374 |
|
386 | |||
375 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. |
|
387 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. | |
376 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. |
|
388 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. | |
377 |
|
389 | |||
378 | 2005-05-19 Fernando Perez <fperez@colorado.edu> |
|
390 | 2005-05-19 Fernando Perez <fperez@colorado.edu> | |
379 |
|
391 | |||
380 | * IPython/iplib.py (safe_execfile): close a file which could be |
|
392 | * IPython/iplib.py (safe_execfile): close a file which could be | |
381 | left open (causing problems in win32, which locks open files). |
|
393 | left open (causing problems in win32, which locks open files). | |
382 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. |
|
394 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. | |
383 |
|
395 | |||
384 | 2005-05-18 Fernando Perez <fperez@colorado.edu> |
|
396 | 2005-05-18 Fernando Perez <fperez@colorado.edu> | |
385 |
|
397 | |||
386 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all |
|
398 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all | |
387 | keyword arguments correctly to safe_execfile(). |
|
399 | keyword arguments correctly to safe_execfile(). | |
388 |
|
400 | |||
389 | 2005-05-13 Fernando Perez <fperez@colorado.edu> |
|
401 | 2005-05-13 Fernando Perez <fperez@colorado.edu> | |
390 |
|
402 | |||
391 | * ipython.1: Added info about Qt to manpage, and threads warning |
|
403 | * ipython.1: Added info about Qt to manpage, and threads warning | |
392 | to usage page (invoked with --help). |
|
404 | to usage page (invoked with --help). | |
393 |
|
405 | |||
394 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added |
|
406 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added | |
395 | new matcher (it goes at the end of the priority list) to do |
|
407 | new matcher (it goes at the end of the priority list) to do | |
396 | tab-completion on named function arguments. Submitted by George |
|
408 | tab-completion on named function arguments. Submitted by George | |
397 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at |
|
409 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at | |
398 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html |
|
410 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html | |
399 | for more details. |
|
411 | for more details. | |
400 |
|
412 | |||
401 | * IPython/Magic.py (magic_run): Added new -e flag to ignore |
|
413 | * IPython/Magic.py (magic_run): Added new -e flag to ignore | |
402 | SystemExit exceptions in the script being run. Thanks to a report |
|
414 | SystemExit exceptions in the script being run. Thanks to a report | |
403 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this |
|
415 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this | |
404 | producing very annoying behavior when running unit tests. |
|
416 | producing very annoying behavior when running unit tests. | |
405 |
|
417 | |||
406 | 2005-05-12 Fernando Perez <fperez@colorado.edu> |
|
418 | 2005-05-12 Fernando Perez <fperez@colorado.edu> | |
407 |
|
419 | |||
408 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, |
|
420 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, | |
409 | which I'd broken (again) due to a changed regexp. In the process, |
|
421 | which I'd broken (again) due to a changed regexp. In the process, | |
410 | added ';' as an escape to auto-quote the whole line without |
|
422 | added ';' as an escape to auto-quote the whole line without | |
411 | splitting its arguments. Thanks to a report by Jerry McRae |
|
423 | splitting its arguments. Thanks to a report by Jerry McRae | |
412 | <qrs0xyc02-AT-sneakemail.com>. |
|
424 | <qrs0xyc02-AT-sneakemail.com>. | |
413 |
|
425 | |||
414 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but |
|
426 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but | |
415 | possible crashes caused by a TokenError. Reported by Ed Schofield |
|
427 | possible crashes caused by a TokenError. Reported by Ed Schofield | |
416 | <schofield-AT-ftw.at>. |
|
428 | <schofield-AT-ftw.at>. | |
417 |
|
429 | |||
418 | 2005-05-06 Fernando Perez <fperez@colorado.edu> |
|
430 | 2005-05-06 Fernando Perez <fperez@colorado.edu> | |
419 |
|
431 | |||
420 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. |
|
432 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. | |
421 |
|
433 | |||
422 | 2005-04-29 Fernando Perez <fperez@colorado.edu> |
|
434 | 2005-04-29 Fernando Perez <fperez@colorado.edu> | |
423 |
|
435 | |||
424 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière |
|
436 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière | |
425 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin |
|
437 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin | |
426 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option |
|
438 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option | |
427 | which provides support for Qt interactive usage (similar to the |
|
439 | which provides support for Qt interactive usage (similar to the | |
428 | existing one for WX and GTK). This had been often requested. |
|
440 | existing one for WX and GTK). This had been often requested. | |
429 |
|
441 | |||
430 | 2005-04-14 *** Released version 0.6.13 |
|
442 | 2005-04-14 *** Released version 0.6.13 | |
431 |
|
443 | |||
432 | 2005-04-08 Fernando Perez <fperez@colorado.edu> |
|
444 | 2005-04-08 Fernando Perez <fperez@colorado.edu> | |
433 |
|
445 | |||
434 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation |
|
446 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation | |
435 | from _ofind, which gets called on almost every input line. Now, |
|
447 | from _ofind, which gets called on almost every input line. Now, | |
436 | we only try to get docstrings if they are actually going to be |
|
448 | we only try to get docstrings if they are actually going to be | |
437 | used (the overhead of fetching unnecessary docstrings can be |
|
449 | used (the overhead of fetching unnecessary docstrings can be | |
438 | noticeable for certain objects, such as Pyro proxies). |
|
450 | noticeable for certain objects, such as Pyro proxies). | |
439 |
|
451 | |||
440 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API |
|
452 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API | |
441 | for completers. For some reason I had been passing them the state |
|
453 | for completers. For some reason I had been passing them the state | |
442 | variable, which completers never actually need, and was in |
|
454 | variable, which completers never actually need, and was in | |
443 | conflict with the rlcompleter API. Custom completers ONLY need to |
|
455 | conflict with the rlcompleter API. Custom completers ONLY need to | |
444 | take the text parameter. |
|
456 | take the text parameter. | |
445 |
|
457 | |||
446 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics |
|
458 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics | |
447 | work correctly in pysh. I've also moved all the logic which used |
|
459 | work correctly in pysh. I've also moved all the logic which used | |
448 | to be in pysh.py here, which will prevent problems with future |
|
460 | to be in pysh.py here, which will prevent problems with future | |
449 | upgrades. However, this time I must warn users to update their |
|
461 | upgrades. However, this time I must warn users to update their | |
450 | pysh profile to include the line |
|
462 | pysh profile to include the line | |
451 |
|
463 | |||
452 | import_all IPython.Extensions.InterpreterExec |
|
464 | import_all IPython.Extensions.InterpreterExec | |
453 |
|
465 | |||
454 | because otherwise things won't work for them. They MUST also |
|
466 | because otherwise things won't work for them. They MUST also | |
455 | delete pysh.py and the line |
|
467 | delete pysh.py and the line | |
456 |
|
468 | |||
457 | execfile pysh.py |
|
469 | execfile pysh.py | |
458 |
|
470 | |||
459 | from their ipythonrc-pysh. |
|
471 | from their ipythonrc-pysh. | |
460 |
|
472 | |||
461 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more |
|
473 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more | |
462 | robust in the face of objects whose dir() returns non-strings |
|
474 | robust in the face of objects whose dir() returns non-strings | |
463 | (which it shouldn't, but some broken libs like ITK do). Thanks to |
|
475 | (which it shouldn't, but some broken libs like ITK do). Thanks to | |
464 | a patch by John Hunter (implemented differently, though). Also |
|
476 | a patch by John Hunter (implemented differently, though). Also | |
465 | minor improvements by using .extend instead of + on lists. |
|
477 | minor improvements by using .extend instead of + on lists. | |
466 |
|
478 | |||
467 | * pysh.py: |
|
479 | * pysh.py: | |
468 |
|
480 | |||
469 | 2005-04-06 Fernando Perez <fperez@colorado.edu> |
|
481 | 2005-04-06 Fernando Perez <fperez@colorado.edu> | |
470 |
|
482 | |||
471 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on |
|
483 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on | |
472 | by default, so that all users benefit from it. Those who don't |
|
484 | by default, so that all users benefit from it. Those who don't | |
473 | want it can still turn it off. |
|
485 | want it can still turn it off. | |
474 |
|
486 | |||
475 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the |
|
487 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the | |
476 | config file, I'd forgotten about this, so users were getting it |
|
488 | config file, I'd forgotten about this, so users were getting it | |
477 | off by default. |
|
489 | off by default. | |
478 |
|
490 | |||
479 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for |
|
491 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for | |
480 | consistency. Now magics can be called in multiline statements, |
|
492 | consistency. Now magics can be called in multiline statements, | |
481 | and python variables can be expanded in magic calls via $var. |
|
493 | and python variables can be expanded in magic calls via $var. | |
482 | This makes the magic system behave just like aliases or !system |
|
494 | This makes the magic system behave just like aliases or !system | |
483 | calls. |
|
495 | calls. | |
484 |
|
496 | |||
485 | 2005-03-28 Fernando Perez <fperez@colorado.edu> |
|
497 | 2005-03-28 Fernando Perez <fperez@colorado.edu> | |
486 |
|
498 | |||
487 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of |
|
499 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of | |
488 | expensive string additions for building command. Add support for |
|
500 | expensive string additions for building command. Add support for | |
489 | trailing ';' when autocall is used. |
|
501 | trailing ';' when autocall is used. | |
490 |
|
502 | |||
491 | 2005-03-26 Fernando Perez <fperez@colorado.edu> |
|
503 | 2005-03-26 Fernando Perez <fperez@colorado.edu> | |
492 |
|
504 | |||
493 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. |
|
505 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. | |
494 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make |
|
506 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make | |
495 | ipython.el robust against prompts with any number of spaces |
|
507 | ipython.el robust against prompts with any number of spaces | |
496 | (including 0) after the ':' character. |
|
508 | (including 0) after the ':' character. | |
497 |
|
509 | |||
498 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in |
|
510 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in | |
499 | continuation prompt, which misled users to think the line was |
|
511 | continuation prompt, which misled users to think the line was | |
500 | already indented. Closes debian Bug#300847, reported to me by |
|
512 | already indented. Closes debian Bug#300847, reported to me by | |
501 | Norbert Tretkowski <tretkowski-AT-inittab.de>. |
|
513 | Norbert Tretkowski <tretkowski-AT-inittab.de>. | |
502 |
|
514 | |||
503 | 2005-03-23 Fernando Perez <fperez@colorado.edu> |
|
515 | 2005-03-23 Fernando Perez <fperez@colorado.edu> | |
504 |
|
516 | |||
505 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are |
|
517 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are | |
506 | properly aligned if they have embedded newlines. |
|
518 | properly aligned if they have embedded newlines. | |
507 |
|
519 | |||
508 | * IPython/iplib.py (runlines): Add a public method to expose |
|
520 | * IPython/iplib.py (runlines): Add a public method to expose | |
509 | IPython's code execution machinery, so that users can run strings |
|
521 | IPython's code execution machinery, so that users can run strings | |
510 | as if they had been typed at the prompt interactively. |
|
522 | as if they had been typed at the prompt interactively. | |
511 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ |
|
523 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ | |
512 | methods which can call the system shell, but with python variable |
|
524 | methods which can call the system shell, but with python variable | |
513 | expansion. The three such methods are: __IPYTHON__.system, |
|
525 | expansion. The three such methods are: __IPYTHON__.system, | |
514 | .getoutput and .getoutputerror. These need to be documented in a |
|
526 | .getoutput and .getoutputerror. These need to be documented in a | |
515 | 'public API' section (to be written) of the manual. |
|
527 | 'public API' section (to be written) of the manual. | |
516 |
|
528 | |||
517 | 2005-03-20 Fernando Perez <fperez@colorado.edu> |
|
529 | 2005-03-20 Fernando Perez <fperez@colorado.edu> | |
518 |
|
530 | |||
519 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system |
|
531 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system | |
520 | for custom exception handling. This is quite powerful, and it |
|
532 | for custom exception handling. This is quite powerful, and it | |
521 | allows for user-installable exception handlers which can trap |
|
533 | allows for user-installable exception handlers which can trap | |
522 | custom exceptions at runtime and treat them separately from |
|
534 | custom exceptions at runtime and treat them separately from | |
523 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric |
|
535 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric | |
524 | Mantegazza <mantegazza-AT-ill.fr>. |
|
536 | Mantegazza <mantegazza-AT-ill.fr>. | |
525 | (InteractiveShell.set_custom_completer): public API function to |
|
537 | (InteractiveShell.set_custom_completer): public API function to | |
526 | add new completers at runtime. |
|
538 | add new completers at runtime. | |
527 |
|
539 | |||
528 | 2005-03-19 Fernando Perez <fperez@colorado.edu> |
|
540 | 2005-03-19 Fernando Perez <fperez@colorado.edu> | |
529 |
|
541 | |||
530 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to |
|
542 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to | |
531 | allow objects which provide their docstrings via non-standard |
|
543 | allow objects which provide their docstrings via non-standard | |
532 | mechanisms (like Pyro proxies) to still be inspected by ipython's |
|
544 | mechanisms (like Pyro proxies) to still be inspected by ipython's | |
533 | ? system. |
|
545 | ? system. | |
534 |
|
546 | |||
535 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e |
|
547 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e | |
536 | automatic capture system. I tried quite hard to make it work |
|
548 | automatic capture system. I tried quite hard to make it work | |
537 | reliably, and simply failed. I tried many combinations with the |
|
549 | reliably, and simply failed. I tried many combinations with the | |
538 | subprocess module, but eventually nothing worked in all needed |
|
550 | subprocess module, but eventually nothing worked in all needed | |
539 | cases (not blocking stdin for the child, duplicating stdout |
|
551 | cases (not blocking stdin for the child, duplicating stdout | |
540 | without blocking, etc). The new %sc/%sx still do capture to these |
|
552 | without blocking, etc). The new %sc/%sx still do capture to these | |
541 | magical list/string objects which make shell use much more |
|
553 | magical list/string objects which make shell use much more | |
542 | conveninent, so not all is lost. |
|
554 | conveninent, so not all is lost. | |
543 |
|
555 | |||
544 | XXX - FIX MANUAL for the change above! |
|
556 | XXX - FIX MANUAL for the change above! | |
545 |
|
557 | |||
546 | (runsource): I copied code.py's runsource() into ipython to modify |
|
558 | (runsource): I copied code.py's runsource() into ipython to modify | |
547 | it a bit. Now the code object and source to be executed are |
|
559 | it a bit. Now the code object and source to be executed are | |
548 | stored in ipython. This makes this info accessible to third-party |
|
560 | stored in ipython. This makes this info accessible to third-party | |
549 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric |
|
561 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric | |
550 | Mantegazza <mantegazza-AT-ill.fr>. |
|
562 | Mantegazza <mantegazza-AT-ill.fr>. | |
551 |
|
563 | |||
552 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to |
|
564 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to | |
553 | history-search via readline (like C-p/C-n). I'd wanted this for a |
|
565 | history-search via readline (like C-p/C-n). I'd wanted this for a | |
554 | long time, but only recently found out how to do it. For users |
|
566 | long time, but only recently found out how to do it. For users | |
555 | who already have their ipythonrc files made and want this, just |
|
567 | who already have their ipythonrc files made and want this, just | |
556 | add: |
|
568 | add: | |
557 |
|
569 | |||
558 | readline_parse_and_bind "\e[A": history-search-backward |
|
570 | readline_parse_and_bind "\e[A": history-search-backward | |
559 | readline_parse_and_bind "\e[B": history-search-forward |
|
571 | readline_parse_and_bind "\e[B": history-search-forward | |
560 |
|
572 | |||
561 | 2005-03-18 Fernando Perez <fperez@colorado.edu> |
|
573 | 2005-03-18 Fernando Perez <fperez@colorado.edu> | |
562 |
|
574 | |||
563 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy |
|
575 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy | |
564 | LSString and SList classes which allow transparent conversions |
|
576 | LSString and SList classes which allow transparent conversions | |
565 | between list mode and whitespace-separated string. |
|
577 | between list mode and whitespace-separated string. | |
566 | (magic_r): Fix recursion problem in %r. |
|
578 | (magic_r): Fix recursion problem in %r. | |
567 |
|
579 | |||
568 | * IPython/genutils.py (LSString): New class to be used for |
|
580 | * IPython/genutils.py (LSString): New class to be used for | |
569 | automatic storage of the results of all alias/system calls in _o |
|
581 | automatic storage of the results of all alias/system calls in _o | |
570 | and _e (stdout/err). These provide a .l/.list attribute which |
|
582 | and _e (stdout/err). These provide a .l/.list attribute which | |
571 | does automatic splitting on newlines. This means that for most |
|
583 | does automatic splitting on newlines. This means that for most | |
572 | uses, you'll never need to do capturing of output with %sc/%sx |
|
584 | uses, you'll never need to do capturing of output with %sc/%sx | |
573 | anymore, since ipython keeps this always done for you. Note that |
|
585 | anymore, since ipython keeps this always done for you. Note that | |
574 | only the LAST results are stored, the _o/e variables are |
|
586 | only the LAST results are stored, the _o/e variables are | |
575 | overwritten on each call. If you need to save their contents |
|
587 | overwritten on each call. If you need to save their contents | |
576 | further, simply bind them to any other name. |
|
588 | further, simply bind them to any other name. | |
577 |
|
589 | |||
578 | 2005-03-17 Fernando Perez <fperez@colorado.edu> |
|
590 | 2005-03-17 Fernando Perez <fperez@colorado.edu> | |
579 |
|
591 | |||
580 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for |
|
592 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for | |
581 | prompt namespace handling. |
|
593 | prompt namespace handling. | |
582 |
|
594 | |||
583 | 2005-03-16 Fernando Perez <fperez@colorado.edu> |
|
595 | 2005-03-16 Fernando Perez <fperez@colorado.edu> | |
584 |
|
596 | |||
585 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and |
|
597 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and | |
586 | classic prompts to be '>>> ' (final space was missing, and it |
|
598 | classic prompts to be '>>> ' (final space was missing, and it | |
587 | trips the emacs python mode). |
|
599 | trips the emacs python mode). | |
588 | (BasePrompt.__str__): Added safe support for dynamic prompt |
|
600 | (BasePrompt.__str__): Added safe support for dynamic prompt | |
589 | strings. Now you can set your prompt string to be '$x', and the |
|
601 | strings. Now you can set your prompt string to be '$x', and the | |
590 | value of x will be printed from your interactive namespace. The |
|
602 | value of x will be printed from your interactive namespace. The | |
591 | interpolation syntax includes the full Itpl support, so |
|
603 | interpolation syntax includes the full Itpl support, so | |
592 | ${foo()+x+bar()} is a valid prompt string now, and the function |
|
604 | ${foo()+x+bar()} is a valid prompt string now, and the function | |
593 | calls will be made at runtime. |
|
605 | calls will be made at runtime. | |
594 |
|
606 | |||
595 | 2005-03-15 Fernando Perez <fperez@colorado.edu> |
|
607 | 2005-03-15 Fernando Perez <fperez@colorado.edu> | |
596 |
|
608 | |||
597 | * IPython/Magic.py (magic_history): renamed %hist to %history, to |
|
609 | * IPython/Magic.py (magic_history): renamed %hist to %history, to | |
598 | avoid name clashes in pylab. %hist still works, it just forwards |
|
610 | avoid name clashes in pylab. %hist still works, it just forwards | |
599 | the call to %history. |
|
611 | the call to %history. | |
600 |
|
612 | |||
601 | 2005-03-02 *** Released version 0.6.12 |
|
613 | 2005-03-02 *** Released version 0.6.12 | |
602 |
|
614 | |||
603 | 2005-03-02 Fernando Perez <fperez@colorado.edu> |
|
615 | 2005-03-02 Fernando Perez <fperez@colorado.edu> | |
604 |
|
616 | |||
605 | * IPython/iplib.py (handle_magic): log magic calls properly as |
|
617 | * IPython/iplib.py (handle_magic): log magic calls properly as | |
606 | ipmagic() function calls. |
|
618 | ipmagic() function calls. | |
607 |
|
619 | |||
608 | * IPython/Magic.py (magic_time): Improved %time to support |
|
620 | * IPython/Magic.py (magic_time): Improved %time to support | |
609 | statements and provide wall-clock as well as CPU time. |
|
621 | statements and provide wall-clock as well as CPU time. | |
610 |
|
622 | |||
611 | 2005-02-27 Fernando Perez <fperez@colorado.edu> |
|
623 | 2005-02-27 Fernando Perez <fperez@colorado.edu> | |
612 |
|
624 | |||
613 | * IPython/hooks.py: New hooks module, to expose user-modifiable |
|
625 | * IPython/hooks.py: New hooks module, to expose user-modifiable | |
614 | IPython functionality in a clean manner. For now only the editor |
|
626 | IPython functionality in a clean manner. For now only the editor | |
615 | hook is actually written, and other thigns which I intend to turn |
|
627 | hook is actually written, and other thigns which I intend to turn | |
616 | into proper hooks aren't yet there. The display and prefilter |
|
628 | into proper hooks aren't yet there. The display and prefilter | |
617 | stuff, for example, should be hooks. But at least now the |
|
629 | stuff, for example, should be hooks. But at least now the | |
618 | framework is in place, and the rest can be moved here with more |
|
630 | framework is in place, and the rest can be moved here with more | |
619 | time later. IPython had had a .hooks variable for a long time for |
|
631 | time later. IPython had had a .hooks variable for a long time for | |
620 | this purpose, but I'd never actually used it for anything. |
|
632 | this purpose, but I'd never actually used it for anything. | |
621 |
|
633 | |||
622 | 2005-02-26 Fernando Perez <fperez@colorado.edu> |
|
634 | 2005-02-26 Fernando Perez <fperez@colorado.edu> | |
623 |
|
635 | |||
624 | * IPython/ipmaker.py (make_IPython): make the default ipython |
|
636 | * IPython/ipmaker.py (make_IPython): make the default ipython | |
625 | directory be called _ipython under win32, to follow more the |
|
637 | directory be called _ipython under win32, to follow more the | |
626 | naming peculiarities of that platform (where buggy software like |
|
638 | naming peculiarities of that platform (where buggy software like | |
627 | Visual Sourcesafe breaks with .named directories). Reported by |
|
639 | Visual Sourcesafe breaks with .named directories). Reported by | |
628 | Ville Vainio. |
|
640 | Ville Vainio. | |
629 |
|
641 | |||
630 | 2005-02-23 Fernando Perez <fperez@colorado.edu> |
|
642 | 2005-02-23 Fernando Perez <fperez@colorado.edu> | |
631 |
|
643 | |||
632 | * IPython/iplib.py (InteractiveShell.__init__): removed a few |
|
644 | * IPython/iplib.py (InteractiveShell.__init__): removed a few | |
633 | auto_aliases for win32 which were causing problems. Users can |
|
645 | auto_aliases for win32 which were causing problems. Users can | |
634 | define the ones they personally like. |
|
646 | define the ones they personally like. | |
635 |
|
647 | |||
636 | 2005-02-21 Fernando Perez <fperez@colorado.edu> |
|
648 | 2005-02-21 Fernando Perez <fperez@colorado.edu> | |
637 |
|
649 | |||
638 | * IPython/Magic.py (magic_time): new magic to time execution of |
|
650 | * IPython/Magic.py (magic_time): new magic to time execution of | |
639 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. |
|
651 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. | |
640 |
|
652 | |||
641 | 2005-02-19 Fernando Perez <fperez@colorado.edu> |
|
653 | 2005-02-19 Fernando Perez <fperez@colorado.edu> | |
642 |
|
654 | |||
643 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings |
|
655 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings | |
644 | into keys (for prompts, for example). |
|
656 | into keys (for prompts, for example). | |
645 |
|
657 | |||
646 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty |
|
658 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty | |
647 | prompts in case users want them. This introduces a small behavior |
|
659 | prompts in case users want them. This introduces a small behavior | |
648 | change: ipython does not automatically add a space to all prompts |
|
660 | change: ipython does not automatically add a space to all prompts | |
649 | anymore. To get the old prompts with a space, users should add it |
|
661 | anymore. To get the old prompts with a space, users should add it | |
650 | manually to their ipythonrc file, so for example prompt_in1 should |
|
662 | manually to their ipythonrc file, so for example prompt_in1 should | |
651 | now read 'In [\#]: ' instead of 'In [\#]:'. |
|
663 | now read 'In [\#]: ' instead of 'In [\#]:'. | |
652 | (BasePrompt.__init__): New option prompts_pad_left (only in rc |
|
664 | (BasePrompt.__init__): New option prompts_pad_left (only in rc | |
653 | file) to control left-padding of secondary prompts. |
|
665 | file) to control left-padding of secondary prompts. | |
654 |
|
666 | |||
655 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if |
|
667 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if | |
656 | the profiler can't be imported. Fix for Debian, which removed |
|
668 | the profiler can't be imported. Fix for Debian, which removed | |
657 | profile.py because of License issues. I applied a slightly |
|
669 | profile.py because of License issues. I applied a slightly | |
658 | modified version of the original Debian patch at |
|
670 | modified version of the original Debian patch at | |
659 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. |
|
671 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. | |
660 |
|
672 | |||
661 | 2005-02-17 Fernando Perez <fperez@colorado.edu> |
|
673 | 2005-02-17 Fernando Perez <fperez@colorado.edu> | |
662 |
|
674 | |||
663 | * IPython/genutils.py (native_line_ends): Fix bug which would |
|
675 | * IPython/genutils.py (native_line_ends): Fix bug which would | |
664 | cause improper line-ends under win32 b/c I was not opening files |
|
676 | cause improper line-ends under win32 b/c I was not opening files | |
665 | in binary mode. Bug report and fix thanks to Ville. |
|
677 | in binary mode. Bug report and fix thanks to Ville. | |
666 |
|
678 | |||
667 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when |
|
679 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when | |
668 | trying to catch spurious foo[1] autocalls. My fix actually broke |
|
680 | trying to catch spurious foo[1] autocalls. My fix actually broke | |
669 | ',/' autoquote/call with explicit escape (bad regexp). |
|
681 | ',/' autoquote/call with explicit escape (bad regexp). | |
670 |
|
682 | |||
671 | 2005-02-15 *** Released version 0.6.11 |
|
683 | 2005-02-15 *** Released version 0.6.11 | |
672 |
|
684 | |||
673 | 2005-02-14 Fernando Perez <fperez@colorado.edu> |
|
685 | 2005-02-14 Fernando Perez <fperez@colorado.edu> | |
674 |
|
686 | |||
675 | * IPython/background_jobs.py: New background job management |
|
687 | * IPython/background_jobs.py: New background job management | |
676 | subsystem. This is implemented via a new set of classes, and |
|
688 | subsystem. This is implemented via a new set of classes, and | |
677 | IPython now provides a builtin 'jobs' object for background job |
|
689 | IPython now provides a builtin 'jobs' object for background job | |
678 | execution. A convenience %bg magic serves as a lightweight |
|
690 | execution. A convenience %bg magic serves as a lightweight | |
679 | frontend for starting the more common type of calls. This was |
|
691 | frontend for starting the more common type of calls. This was | |
680 | inspired by discussions with B. Granger and the BackgroundCommand |
|
692 | inspired by discussions with B. Granger and the BackgroundCommand | |
681 | class described in the book Python Scripting for Computational |
|
693 | class described in the book Python Scripting for Computational | |
682 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting |
|
694 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting | |
683 | (although ultimately no code from this text was used, as IPython's |
|
695 | (although ultimately no code from this text was used, as IPython's | |
684 | system is a separate implementation). |
|
696 | system is a separate implementation). | |
685 |
|
697 | |||
686 | * IPython/iplib.py (MagicCompleter.python_matches): add new option |
|
698 | * IPython/iplib.py (MagicCompleter.python_matches): add new option | |
687 | to control the completion of single/double underscore names |
|
699 | to control the completion of single/double underscore names | |
688 | separately. As documented in the example ipytonrc file, the |
|
700 | separately. As documented in the example ipytonrc file, the | |
689 | readline_omit__names variable can now be set to 2, to omit even |
|
701 | readline_omit__names variable can now be set to 2, to omit even | |
690 | single underscore names. Thanks to a patch by Brian Wong |
|
702 | single underscore names. Thanks to a patch by Brian Wong | |
691 | <BrianWong-AT-AirgoNetworks.Com>. |
|
703 | <BrianWong-AT-AirgoNetworks.Com>. | |
692 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to |
|
704 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to | |
693 | be autocalled as foo([1]) if foo were callable. A problem for |
|
705 | be autocalled as foo([1]) if foo were callable. A problem for | |
694 | things which are both callable and implement __getitem__. |
|
706 | things which are both callable and implement __getitem__. | |
695 | (init_readline): Fix autoindentation for win32. Thanks to a patch |
|
707 | (init_readline): Fix autoindentation for win32. Thanks to a patch | |
696 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. |
|
708 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. | |
697 |
|
709 | |||
698 | 2005-02-12 Fernando Perez <fperez@colorado.edu> |
|
710 | 2005-02-12 Fernando Perez <fperez@colorado.edu> | |
699 |
|
711 | |||
700 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps |
|
712 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps | |
701 | which I had written long ago to sort out user error messages which |
|
713 | which I had written long ago to sort out user error messages which | |
702 | may occur during startup. This seemed like a good idea initially, |
|
714 | may occur during startup. This seemed like a good idea initially, | |
703 | but it has proven a disaster in retrospect. I don't want to |
|
715 | but it has proven a disaster in retrospect. I don't want to | |
704 | change much code for now, so my fix is to set the internal 'debug' |
|
716 | change much code for now, so my fix is to set the internal 'debug' | |
705 | flag to true everywhere, whose only job was precisely to control |
|
717 | flag to true everywhere, whose only job was precisely to control | |
706 | this subsystem. This closes issue 28 (as well as avoiding all |
|
718 | this subsystem. This closes issue 28 (as well as avoiding all | |
707 | sorts of strange hangups which occur from time to time). |
|
719 | sorts of strange hangups which occur from time to time). | |
708 |
|
720 | |||
709 | 2005-02-07 Fernando Perez <fperez@colorado.edu> |
|
721 | 2005-02-07 Fernando Perez <fperez@colorado.edu> | |
710 |
|
722 | |||
711 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the |
|
723 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the | |
712 | previous call produced a syntax error. |
|
724 | previous call produced a syntax error. | |
713 |
|
725 | |||
714 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
726 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
715 | classes without constructor. |
|
727 | classes without constructor. | |
716 |
|
728 | |||
717 | 2005-02-06 Fernando Perez <fperez@colorado.edu> |
|
729 | 2005-02-06 Fernando Perez <fperez@colorado.edu> | |
718 |
|
730 | |||
719 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of |
|
731 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of | |
720 | completions with the results of each matcher, so we return results |
|
732 | completions with the results of each matcher, so we return results | |
721 | to the user from all namespaces. This breaks with ipython |
|
733 | to the user from all namespaces. This breaks with ipython | |
722 | tradition, but I think it's a nicer behavior. Now you get all |
|
734 | tradition, but I think it's a nicer behavior. Now you get all | |
723 | possible completions listed, from all possible namespaces (python, |
|
735 | possible completions listed, from all possible namespaces (python, | |
724 | filesystem, magics...) After a request by John Hunter |
|
736 | filesystem, magics...) After a request by John Hunter | |
725 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
737 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
726 |
|
738 | |||
727 | 2005-02-05 Fernando Perez <fperez@colorado.edu> |
|
739 | 2005-02-05 Fernando Perez <fperez@colorado.edu> | |
728 |
|
740 | |||
729 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if |
|
741 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if | |
730 | the call had quote characters in it (the quotes were stripped). |
|
742 | the call had quote characters in it (the quotes were stripped). | |
731 |
|
743 | |||
732 | 2005-01-31 Fernando Perez <fperez@colorado.edu> |
|
744 | 2005-01-31 Fernando Perez <fperez@colorado.edu> | |
733 |
|
745 | |||
734 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on |
|
746 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on | |
735 | Itpl.itpl() to make the code more robust against psyco |
|
747 | Itpl.itpl() to make the code more robust against psyco | |
736 | optimizations. |
|
748 | optimizations. | |
737 |
|
749 | |||
738 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead |
|
750 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead | |
739 | of causing an exception. Quicker, cleaner. |
|
751 | of causing an exception. Quicker, cleaner. | |
740 |
|
752 | |||
741 | 2005-01-28 Fernando Perez <fperez@colorado.edu> |
|
753 | 2005-01-28 Fernando Perez <fperez@colorado.edu> | |
742 |
|
754 | |||
743 | * scripts/ipython_win_post_install.py (install): hardcode |
|
755 | * scripts/ipython_win_post_install.py (install): hardcode | |
744 | sys.prefix+'python.exe' as the executable path. It turns out that |
|
756 | sys.prefix+'python.exe' as the executable path. It turns out that | |
745 | during the post-installation run, sys.executable resolves to the |
|
757 | during the post-installation run, sys.executable resolves to the | |
746 | name of the binary installer! I should report this as a distutils |
|
758 | name of the binary installer! I should report this as a distutils | |
747 | bug, I think. I updated the .10 release with this tiny fix, to |
|
759 | bug, I think. I updated the .10 release with this tiny fix, to | |
748 | avoid annoying the lists further. |
|
760 | avoid annoying the lists further. | |
749 |
|
761 | |||
750 | 2005-01-27 *** Released version 0.6.10 |
|
762 | 2005-01-27 *** Released version 0.6.10 | |
751 |
|
763 | |||
752 | 2005-01-27 Fernando Perez <fperez@colorado.edu> |
|
764 | 2005-01-27 Fernando Perez <fperez@colorado.edu> | |
753 |
|
765 | |||
754 | * IPython/numutils.py (norm): Added 'inf' as optional name for |
|
766 | * IPython/numutils.py (norm): Added 'inf' as optional name for | |
755 | L-infinity norm, included references to mathworld.com for vector |
|
767 | L-infinity norm, included references to mathworld.com for vector | |
756 | norm definitions. |
|
768 | norm definitions. | |
757 | (amin/amax): added amin/amax for array min/max. Similar to what |
|
769 | (amin/amax): added amin/amax for array min/max. Similar to what | |
758 | pylab ships with after the recent reorganization of names. |
|
770 | pylab ships with after the recent reorganization of names. | |
759 | (spike/spike_odd): removed deprecated spike/spike_odd functions. |
|
771 | (spike/spike_odd): removed deprecated spike/spike_odd functions. | |
760 |
|
772 | |||
761 | * ipython.el: committed Alex's recent fixes and improvements. |
|
773 | * ipython.el: committed Alex's recent fixes and improvements. | |
762 | Tested with python-mode from CVS, and it looks excellent. Since |
|
774 | Tested with python-mode from CVS, and it looks excellent. Since | |
763 | python-mode hasn't released anything in a while, I'm temporarily |
|
775 | python-mode hasn't released anything in a while, I'm temporarily | |
764 | putting a copy of today's CVS (v 4.70) of python-mode in: |
|
776 | putting a copy of today's CVS (v 4.70) of python-mode in: | |
765 | http://ipython.scipy.org/tmp/python-mode.el |
|
777 | http://ipython.scipy.org/tmp/python-mode.el | |
766 |
|
778 | |||
767 | * scripts/ipython_win_post_install.py (install): Win32 fix to use |
|
779 | * scripts/ipython_win_post_install.py (install): Win32 fix to use | |
768 | sys.executable for the executable name, instead of assuming it's |
|
780 | sys.executable for the executable name, instead of assuming it's | |
769 | called 'python.exe' (the post-installer would have produced broken |
|
781 | called 'python.exe' (the post-installer would have produced broken | |
770 | setups on systems with a differently named python binary). |
|
782 | setups on systems with a differently named python binary). | |
771 |
|
783 | |||
772 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' |
|
784 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' | |
773 | references to os.linesep, to make the code more |
|
785 | references to os.linesep, to make the code more | |
774 | platform-independent. This is also part of the win32 coloring |
|
786 | platform-independent. This is also part of the win32 coloring | |
775 | fixes. |
|
787 | fixes. | |
776 |
|
788 | |||
777 | * IPython/genutils.py (page_dumb): Remove attempts to chop long |
|
789 | * IPython/genutils.py (page_dumb): Remove attempts to chop long | |
778 | lines, which actually cause coloring bugs because the length of |
|
790 | lines, which actually cause coloring bugs because the length of | |
779 | the line is very difficult to correctly compute with embedded |
|
791 | the line is very difficult to correctly compute with embedded | |
780 | escapes. This was the source of all the coloring problems under |
|
792 | escapes. This was the source of all the coloring problems under | |
781 | Win32. I think that _finally_, Win32 users have a properly |
|
793 | Win32. I think that _finally_, Win32 users have a properly | |
782 | working ipython in all respects. This would never have happened |
|
794 | working ipython in all respects. This would never have happened | |
783 | if not for Gary Bishop and Viktor Ransmayr's great help and work. |
|
795 | if not for Gary Bishop and Viktor Ransmayr's great help and work. | |
784 |
|
796 | |||
785 | 2005-01-26 *** Released version 0.6.9 |
|
797 | 2005-01-26 *** Released version 0.6.9 | |
786 |
|
798 | |||
787 | 2005-01-25 Fernando Perez <fperez@colorado.edu> |
|
799 | 2005-01-25 Fernando Perez <fperez@colorado.edu> | |
788 |
|
800 | |||
789 | * setup.py: finally, we have a true Windows installer, thanks to |
|
801 | * setup.py: finally, we have a true Windows installer, thanks to | |
790 | the excellent work of Viktor Ransmayr |
|
802 | the excellent work of Viktor Ransmayr | |
791 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for |
|
803 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for | |
792 | Windows users. The setup routine is quite a bit cleaner thanks to |
|
804 | Windows users. The setup routine is quite a bit cleaner thanks to | |
793 | this, and the post-install script uses the proper functions to |
|
805 | this, and the post-install script uses the proper functions to | |
794 | allow a clean de-installation using the standard Windows Control |
|
806 | allow a clean de-installation using the standard Windows Control | |
795 | Panel. |
|
807 | Panel. | |
796 |
|
808 | |||
797 | * IPython/genutils.py (get_home_dir): changed to use the $HOME |
|
809 | * IPython/genutils.py (get_home_dir): changed to use the $HOME | |
798 | environment variable under all OSes (including win32) if |
|
810 | environment variable under all OSes (including win32) if | |
799 | available. This will give consistency to win32 users who have set |
|
811 | available. This will give consistency to win32 users who have set | |
800 | this variable for any reason. If os.environ['HOME'] fails, the |
|
812 | this variable for any reason. If os.environ['HOME'] fails, the | |
801 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. |
|
813 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. | |
802 |
|
814 | |||
803 | 2005-01-24 Fernando Perez <fperez@colorado.edu> |
|
815 | 2005-01-24 Fernando Perez <fperez@colorado.edu> | |
804 |
|
816 | |||
805 | * IPython/numutils.py (empty_like): add empty_like(), similar to |
|
817 | * IPython/numutils.py (empty_like): add empty_like(), similar to | |
806 | zeros_like() but taking advantage of the new empty() Numeric routine. |
|
818 | zeros_like() but taking advantage of the new empty() Numeric routine. | |
807 |
|
819 | |||
808 | 2005-01-23 *** Released version 0.6.8 |
|
820 | 2005-01-23 *** Released version 0.6.8 | |
809 |
|
821 | |||
810 | 2005-01-22 Fernando Perez <fperez@colorado.edu> |
|
822 | 2005-01-22 Fernando Perez <fperez@colorado.edu> | |
811 |
|
823 | |||
812 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the |
|
824 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the | |
813 | automatic show() calls. After discussing things with JDH, it |
|
825 | automatic show() calls. After discussing things with JDH, it | |
814 | turns out there are too many corner cases where this can go wrong. |
|
826 | turns out there are too many corner cases where this can go wrong. | |
815 | It's best not to try to be 'too smart', and simply have ipython |
|
827 | It's best not to try to be 'too smart', and simply have ipython | |
816 | reproduce as much as possible the default behavior of a normal |
|
828 | reproduce as much as possible the default behavior of a normal | |
817 | python shell. |
|
829 | python shell. | |
818 |
|
830 | |||
819 | * IPython/iplib.py (InteractiveShell.__init__): Modified the |
|
831 | * IPython/iplib.py (InteractiveShell.__init__): Modified the | |
820 | line-splitting regexp and _prefilter() to avoid calling getattr() |
|
832 | line-splitting regexp and _prefilter() to avoid calling getattr() | |
821 | on assignments. This closes |
|
833 | on assignments. This closes | |
822 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's |
|
834 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's | |
823 | readline uses getattr(), so a simple <TAB> keypress is still |
|
835 | readline uses getattr(), so a simple <TAB> keypress is still | |
824 | enough to trigger getattr() calls on an object. |
|
836 | enough to trigger getattr() calls on an object. | |
825 |
|
837 | |||
826 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
838 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
827 |
|
839 | |||
828 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run |
|
840 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run | |
829 | docstring under pylab so it doesn't mask the original. |
|
841 | docstring under pylab so it doesn't mask the original. | |
830 |
|
842 | |||
831 | 2005-01-21 *** Released version 0.6.7 |
|
843 | 2005-01-21 *** Released version 0.6.7 | |
832 |
|
844 | |||
833 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
845 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
834 |
|
846 | |||
835 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with |
|
847 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with | |
836 | signal handling for win32 users in multithreaded mode. |
|
848 | signal handling for win32 users in multithreaded mode. | |
837 |
|
849 | |||
838 | 2005-01-17 Fernando Perez <fperez@colorado.edu> |
|
850 | 2005-01-17 Fernando Perez <fperez@colorado.edu> | |
839 |
|
851 | |||
840 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
852 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
841 | instances with no __init__. After a crash report by Norbert Nemec |
|
853 | instances with no __init__. After a crash report by Norbert Nemec | |
842 | <Norbert-AT-nemec-online.de>. |
|
854 | <Norbert-AT-nemec-online.de>. | |
843 |
|
855 | |||
844 | 2005-01-14 Fernando Perez <fperez@colorado.edu> |
|
856 | 2005-01-14 Fernando Perez <fperez@colorado.edu> | |
845 |
|
857 | |||
846 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of |
|
858 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of | |
847 | names for verbose exceptions, when multiple dotted names and the |
|
859 | names for verbose exceptions, when multiple dotted names and the | |
848 | 'parent' object were present on the same line. |
|
860 | 'parent' object were present on the same line. | |
849 |
|
861 | |||
850 | 2005-01-11 Fernando Perez <fperez@colorado.edu> |
|
862 | 2005-01-11 Fernando Perez <fperez@colorado.edu> | |
851 |
|
863 | |||
852 | * IPython/genutils.py (flag_calls): new utility to trap and flag |
|
864 | * IPython/genutils.py (flag_calls): new utility to trap and flag | |
853 | calls in functions. I need it to clean up matplotlib support. |
|
865 | calls in functions. I need it to clean up matplotlib support. | |
854 | Also removed some deprecated code in genutils. |
|
866 | Also removed some deprecated code in genutils. | |
855 |
|
867 | |||
856 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so |
|
868 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so | |
857 | that matplotlib scripts called with %run, which don't call show() |
|
869 | that matplotlib scripts called with %run, which don't call show() | |
858 | themselves, still have their plotting windows open. |
|
870 | themselves, still have their plotting windows open. | |
859 |
|
871 | |||
860 | 2005-01-05 Fernando Perez <fperez@colorado.edu> |
|
872 | 2005-01-05 Fernando Perez <fperez@colorado.edu> | |
861 |
|
873 | |||
862 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw |
|
874 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw | |
863 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. |
|
875 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. | |
864 |
|
876 | |||
865 | 2004-12-19 Fernando Perez <fperez@colorado.edu> |
|
877 | 2004-12-19 Fernando Perez <fperez@colorado.edu> | |
866 |
|
878 | |||
867 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of |
|
879 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of | |
868 | parent_runcode, which was an eyesore. The same result can be |
|
880 | parent_runcode, which was an eyesore. The same result can be | |
869 | obtained with Python's regular superclass mechanisms. |
|
881 | obtained with Python's regular superclass mechanisms. | |
870 |
|
882 | |||
871 | 2004-12-17 Fernando Perez <fperez@colorado.edu> |
|
883 | 2004-12-17 Fernando Perez <fperez@colorado.edu> | |
872 |
|
884 | |||
873 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem |
|
885 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem | |
874 | reported by Prabhu. |
|
886 | reported by Prabhu. | |
875 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to |
|
887 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to | |
876 | sys.stderr) instead of explicitly calling sys.stderr. This helps |
|
888 | sys.stderr) instead of explicitly calling sys.stderr. This helps | |
877 | maintain our I/O abstractions clean, for future GUI embeddings. |
|
889 | maintain our I/O abstractions clean, for future GUI embeddings. | |
878 |
|
890 | |||
879 | * IPython/genutils.py (info): added new utility for sys.stderr |
|
891 | * IPython/genutils.py (info): added new utility for sys.stderr | |
880 | unified info message handling (thin wrapper around warn()). |
|
892 | unified info message handling (thin wrapper around warn()). | |
881 |
|
893 | |||
882 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global |
|
894 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global | |
883 | composite (dotted) names on verbose exceptions. |
|
895 | composite (dotted) names on verbose exceptions. | |
884 | (VerboseTB.nullrepr): harden against another kind of errors which |
|
896 | (VerboseTB.nullrepr): harden against another kind of errors which | |
885 | Python's inspect module can trigger, and which were crashing |
|
897 | Python's inspect module can trigger, and which were crashing | |
886 | IPython. Thanks to a report by Marco Lombardi |
|
898 | IPython. Thanks to a report by Marco Lombardi | |
887 | <mlombard-AT-ma010192.hq.eso.org>. |
|
899 | <mlombard-AT-ma010192.hq.eso.org>. | |
888 |
|
900 | |||
889 | 2004-12-13 *** Released version 0.6.6 |
|
901 | 2004-12-13 *** Released version 0.6.6 | |
890 |
|
902 | |||
891 | 2004-12-12 Fernando Perez <fperez@colorado.edu> |
|
903 | 2004-12-12 Fernando Perez <fperez@colorado.edu> | |
892 |
|
904 | |||
893 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors |
|
905 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors | |
894 | generated by pygtk upon initialization if it was built without |
|
906 | generated by pygtk upon initialization if it was built without | |
895 | threads (for matplotlib users). After a crash reported by |
|
907 | threads (for matplotlib users). After a crash reported by | |
896 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. |
|
908 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. | |
897 |
|
909 | |||
898 | * IPython/ipmaker.py (make_IPython): fix small bug in the |
|
910 | * IPython/ipmaker.py (make_IPython): fix small bug in the | |
899 | import_some parameter for multiple imports. |
|
911 | import_some parameter for multiple imports. | |
900 |
|
912 | |||
901 | * IPython/iplib.py (ipmagic): simplified the interface of |
|
913 | * IPython/iplib.py (ipmagic): simplified the interface of | |
902 | ipmagic() to take a single string argument, just as it would be |
|
914 | ipmagic() to take a single string argument, just as it would be | |
903 | typed at the IPython cmd line. |
|
915 | typed at the IPython cmd line. | |
904 | (ipalias): Added new ipalias() with an interface identical to |
|
916 | (ipalias): Added new ipalias() with an interface identical to | |
905 | ipmagic(). This completes exposing a pure python interface to the |
|
917 | ipmagic(). This completes exposing a pure python interface to the | |
906 | alias and magic system, which can be used in loops or more complex |
|
918 | alias and magic system, which can be used in loops or more complex | |
907 | code where IPython's automatic line mangling is not active. |
|
919 | code where IPython's automatic line mangling is not active. | |
908 |
|
920 | |||
909 | * IPython/genutils.py (timing): changed interface of timing to |
|
921 | * IPython/genutils.py (timing): changed interface of timing to | |
910 | simply run code once, which is the most common case. timings() |
|
922 | simply run code once, which is the most common case. timings() | |
911 | remains unchanged, for the cases where you want multiple runs. |
|
923 | remains unchanged, for the cases where you want multiple runs. | |
912 |
|
924 | |||
913 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a |
|
925 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a | |
914 | bug where Python2.2 crashes with exec'ing code which does not end |
|
926 | bug where Python2.2 crashes with exec'ing code which does not end | |
915 | in a single newline. Python 2.3 is OK, so I hadn't noticed this |
|
927 | in a single newline. Python 2.3 is OK, so I hadn't noticed this | |
916 | before. |
|
928 | before. | |
917 |
|
929 | |||
918 | 2004-12-10 Fernando Perez <fperez@colorado.edu> |
|
930 | 2004-12-10 Fernando Perez <fperez@colorado.edu> | |
919 |
|
931 | |||
920 | * IPython/Magic.py (Magic.magic_prun): changed name of option from |
|
932 | * IPython/Magic.py (Magic.magic_prun): changed name of option from | |
921 | -t to -T, to accomodate the new -t flag in %run (the %run and |
|
933 | -t to -T, to accomodate the new -t flag in %run (the %run and | |
922 | %prun options are kind of intermixed, and it's not easy to change |
|
934 | %prun options are kind of intermixed, and it's not easy to change | |
923 | this with the limitations of python's getopt). |
|
935 | this with the limitations of python's getopt). | |
924 |
|
936 | |||
925 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time |
|
937 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time | |
926 | the execution of scripts. It's not as fine-tuned as timeit.py, |
|
938 | the execution of scripts. It's not as fine-tuned as timeit.py, | |
927 | but it works from inside ipython (and under 2.2, which lacks |
|
939 | but it works from inside ipython (and under 2.2, which lacks | |
928 | timeit.py). Optionally a number of runs > 1 can be given for |
|
940 | timeit.py). Optionally a number of runs > 1 can be given for | |
929 | timing very short-running code. |
|
941 | timing very short-running code. | |
930 |
|
942 | |||
931 | * IPython/genutils.py (uniq_stable): new routine which returns a |
|
943 | * IPython/genutils.py (uniq_stable): new routine which returns a | |
932 | list of unique elements in any iterable, but in stable order of |
|
944 | list of unique elements in any iterable, but in stable order of | |
933 | appearance. I needed this for the ultraTB fixes, and it's a handy |
|
945 | appearance. I needed this for the ultraTB fixes, and it's a handy | |
934 | utility. |
|
946 | utility. | |
935 |
|
947 | |||
936 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of |
|
948 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of | |
937 | dotted names in Verbose exceptions. This had been broken since |
|
949 | dotted names in Verbose exceptions. This had been broken since | |
938 | the very start, now x.y will properly be printed in a Verbose |
|
950 | the very start, now x.y will properly be printed in a Verbose | |
939 | traceback, instead of x being shown and y appearing always as an |
|
951 | traceback, instead of x being shown and y appearing always as an | |
940 | 'undefined global'. Getting this to work was a bit tricky, |
|
952 | 'undefined global'. Getting this to work was a bit tricky, | |
941 | because by default python tokenizers are stateless. Saved by |
|
953 | because by default python tokenizers are stateless. Saved by | |
942 | python's ability to easily add a bit of state to an arbitrary |
|
954 | python's ability to easily add a bit of state to an arbitrary | |
943 | function (without needing to build a full-blown callable object). |
|
955 | function (without needing to build a full-blown callable object). | |
944 |
|
956 | |||
945 | Also big cleanup of this code, which had horrendous runtime |
|
957 | Also big cleanup of this code, which had horrendous runtime | |
946 | lookups of zillions of attributes for colorization. Moved all |
|
958 | lookups of zillions of attributes for colorization. Moved all | |
947 | this code into a few templates, which make it cleaner and quicker. |
|
959 | this code into a few templates, which make it cleaner and quicker. | |
948 |
|
960 | |||
949 | Printout quality was also improved for Verbose exceptions: one |
|
961 | Printout quality was also improved for Verbose exceptions: one | |
950 | variable per line, and memory addresses are printed (this can be |
|
962 | variable per line, and memory addresses are printed (this can be | |
951 | quite handy in nasty debugging situations, which is what Verbose |
|
963 | quite handy in nasty debugging situations, which is what Verbose | |
952 | is for). |
|
964 | is for). | |
953 |
|
965 | |||
954 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in |
|
966 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in | |
955 | the command line as scripts to be loaded by embedded instances. |
|
967 | the command line as scripts to be loaded by embedded instances. | |
956 | Doing so has the potential for an infinite recursion if there are |
|
968 | Doing so has the potential for an infinite recursion if there are | |
957 | exceptions thrown in the process. This fixes a strange crash |
|
969 | exceptions thrown in the process. This fixes a strange crash | |
958 | reported by Philippe MULLER <muller-AT-irit.fr>. |
|
970 | reported by Philippe MULLER <muller-AT-irit.fr>. | |
959 |
|
971 | |||
960 | 2004-12-09 Fernando Perez <fperez@colorado.edu> |
|
972 | 2004-12-09 Fernando Perez <fperez@colorado.edu> | |
961 |
|
973 | |||
962 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support |
|
974 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support | |
963 | to reflect new names in matplotlib, which now expose the |
|
975 | to reflect new names in matplotlib, which now expose the | |
964 | matlab-compatible interface via a pylab module instead of the |
|
976 | matlab-compatible interface via a pylab module instead of the | |
965 | 'matlab' name. The new code is backwards compatible, so users of |
|
977 | 'matlab' name. The new code is backwards compatible, so users of | |
966 | all matplotlib versions are OK. Patch by J. Hunter. |
|
978 | all matplotlib versions are OK. Patch by J. Hunter. | |
967 |
|
979 | |||
968 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing |
|
980 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing | |
969 | of __init__ docstrings for instances (class docstrings are already |
|
981 | of __init__ docstrings for instances (class docstrings are already | |
970 | automatically printed). Instances with customized docstrings |
|
982 | automatically printed). Instances with customized docstrings | |
971 | (indep. of the class) are also recognized and all 3 separate |
|
983 | (indep. of the class) are also recognized and all 3 separate | |
972 | docstrings are printed (instance, class, constructor). After some |
|
984 | docstrings are printed (instance, class, constructor). After some | |
973 | comments/suggestions by J. Hunter. |
|
985 | comments/suggestions by J. Hunter. | |
974 |
|
986 | |||
975 | 2004-12-05 Fernando Perez <fperez@colorado.edu> |
|
987 | 2004-12-05 Fernando Perez <fperez@colorado.edu> | |
976 |
|
988 | |||
977 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying |
|
989 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying | |
978 | warnings when tab-completion fails and triggers an exception. |
|
990 | warnings when tab-completion fails and triggers an exception. | |
979 |
|
991 | |||
980 | 2004-12-03 Fernando Perez <fperez@colorado.edu> |
|
992 | 2004-12-03 Fernando Perez <fperez@colorado.edu> | |
981 |
|
993 | |||
982 | * IPython/Magic.py (magic_prun): Fix bug where an exception would |
|
994 | * IPython/Magic.py (magic_prun): Fix bug where an exception would | |
983 | be triggered when using 'run -p'. An incorrect option flag was |
|
995 | be triggered when using 'run -p'. An incorrect option flag was | |
984 | being set ('d' instead of 'D'). |
|
996 | being set ('d' instead of 'D'). | |
985 | (manpage): fix missing escaped \- sign. |
|
997 | (manpage): fix missing escaped \- sign. | |
986 |
|
998 | |||
987 | 2004-11-30 *** Released version 0.6.5 |
|
999 | 2004-11-30 *** Released version 0.6.5 | |
988 |
|
1000 | |||
989 | 2004-11-30 Fernando Perez <fperez@colorado.edu> |
|
1001 | 2004-11-30 Fernando Perez <fperez@colorado.edu> | |
990 |
|
1002 | |||
991 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint |
|
1003 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint | |
992 | setting with -d option. |
|
1004 | setting with -d option. | |
993 |
|
1005 | |||
994 | * setup.py (docfiles): Fix problem where the doc glob I was using |
|
1006 | * setup.py (docfiles): Fix problem where the doc glob I was using | |
995 | was COMPLETELY BROKEN. It was giving the right files by pure |
|
1007 | was COMPLETELY BROKEN. It was giving the right files by pure | |
996 | accident, but failed once I tried to include ipython.el. Note: |
|
1008 | accident, but failed once I tried to include ipython.el. Note: | |
997 | glob() does NOT allow you to do exclusion on multiple endings! |
|
1009 | glob() does NOT allow you to do exclusion on multiple endings! | |
998 |
|
1010 | |||
999 | 2004-11-29 Fernando Perez <fperez@colorado.edu> |
|
1011 | 2004-11-29 Fernando Perez <fperez@colorado.edu> | |
1000 |
|
1012 | |||
1001 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using |
|
1013 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using | |
1002 | the manpage as the source. Better formatting & consistency. |
|
1014 | the manpage as the source. Better formatting & consistency. | |
1003 |
|
1015 | |||
1004 | * IPython/Magic.py (magic_run): Added new -d option, to run |
|
1016 | * IPython/Magic.py (magic_run): Added new -d option, to run | |
1005 | scripts under the control of the python pdb debugger. Note that |
|
1017 | scripts under the control of the python pdb debugger. Note that | |
1006 | this required changing the %prun option -d to -D, to avoid a clash |
|
1018 | this required changing the %prun option -d to -D, to avoid a clash | |
1007 | (since %run must pass options to %prun, and getopt is too dumb to |
|
1019 | (since %run must pass options to %prun, and getopt is too dumb to | |
1008 | handle options with string values with embedded spaces). Thanks |
|
1020 | handle options with string values with embedded spaces). Thanks | |
1009 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. |
|
1021 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. | |
1010 | (magic_who_ls): added type matching to %who and %whos, so that one |
|
1022 | (magic_who_ls): added type matching to %who and %whos, so that one | |
1011 | can filter their output to only include variables of certain |
|
1023 | can filter their output to only include variables of certain | |
1012 | types. Another suggestion by Matthew. |
|
1024 | types. Another suggestion by Matthew. | |
1013 | (magic_whos): Added memory summaries in kb and Mb for arrays. |
|
1025 | (magic_whos): Added memory summaries in kb and Mb for arrays. | |
1014 | (magic_who): Improve formatting (break lines every 9 vars). |
|
1026 | (magic_who): Improve formatting (break lines every 9 vars). | |
1015 |
|
1027 | |||
1016 | 2004-11-28 Fernando Perez <fperez@colorado.edu> |
|
1028 | 2004-11-28 Fernando Perez <fperez@colorado.edu> | |
1017 |
|
1029 | |||
1018 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input |
|
1030 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input | |
1019 | cache when empty lines were present. |
|
1031 | cache when empty lines were present. | |
1020 |
|
1032 | |||
1021 | 2004-11-24 Fernando Perez <fperez@colorado.edu> |
|
1033 | 2004-11-24 Fernando Perez <fperez@colorado.edu> | |
1022 |
|
1034 | |||
1023 | * IPython/usage.py (__doc__): document the re-activated threading |
|
1035 | * IPython/usage.py (__doc__): document the re-activated threading | |
1024 | options for WX and GTK. |
|
1036 | options for WX and GTK. | |
1025 |
|
1037 | |||
1026 | 2004-11-23 Fernando Perez <fperez@colorado.edu> |
|
1038 | 2004-11-23 Fernando Perez <fperez@colorado.edu> | |
1027 |
|
1039 | |||
1028 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate |
|
1040 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate | |
1029 | the -wthread and -gthread options, along with a new -tk one to try |
|
1041 | the -wthread and -gthread options, along with a new -tk one to try | |
1030 | and coordinate Tk threading with wx/gtk. The tk support is very |
|
1042 | and coordinate Tk threading with wx/gtk. The tk support is very | |
1031 | platform dependent, since it seems to require Tcl and Tk to be |
|
1043 | platform dependent, since it seems to require Tcl and Tk to be | |
1032 | built with threads (Fedora1/2 appears NOT to have it, but in |
|
1044 | built with threads (Fedora1/2 appears NOT to have it, but in | |
1033 | Prabhu's Debian boxes it works OK). But even with some Tk |
|
1045 | Prabhu's Debian boxes it works OK). But even with some Tk | |
1034 | limitations, this is a great improvement. |
|
1046 | limitations, this is a great improvement. | |
1035 |
|
1047 | |||
1036 | * IPython/Prompts.py (prompt_specials_color): Added \t for time |
|
1048 | * IPython/Prompts.py (prompt_specials_color): Added \t for time | |
1037 | info in user prompts. Patch by Prabhu. |
|
1049 | info in user prompts. Patch by Prabhu. | |
1038 |
|
1050 | |||
1039 | 2004-11-18 Fernando Perez <fperez@colorado.edu> |
|
1051 | 2004-11-18 Fernando Perez <fperez@colorado.edu> | |
1040 |
|
1052 | |||
1041 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 |
|
1053 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 | |
1042 | EOFErrors and bail, to avoid infinite loops if a non-terminating |
|
1054 | EOFErrors and bail, to avoid infinite loops if a non-terminating | |
1043 | file is fed into ipython. Patch submitted in issue 19 by user, |
|
1055 | file is fed into ipython. Patch submitted in issue 19 by user, | |
1044 | many thanks. |
|
1056 | many thanks. | |
1045 |
|
1057 | |||
1046 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger |
|
1058 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger | |
1047 | autoquote/parens in continuation prompts, which can cause lots of |
|
1059 | autoquote/parens in continuation prompts, which can cause lots of | |
1048 | problems. Closes roundup issue 20. |
|
1060 | problems. Closes roundup issue 20. | |
1049 |
|
1061 | |||
1050 | 2004-11-17 Fernando Perez <fperez@colorado.edu> |
|
1062 | 2004-11-17 Fernando Perez <fperez@colorado.edu> | |
1051 |
|
1063 | |||
1052 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, |
|
1064 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, | |
1053 | reported as debian bug #280505. I'm not sure my local changelog |
|
1065 | reported as debian bug #280505. I'm not sure my local changelog | |
1054 | entry has the proper debian format (Jack?). |
|
1066 | entry has the proper debian format (Jack?). | |
1055 |
|
1067 | |||
1056 | 2004-11-08 *** Released version 0.6.4 |
|
1068 | 2004-11-08 *** Released version 0.6.4 | |
1057 |
|
1069 | |||
1058 | 2004-11-08 Fernando Perez <fperez@colorado.edu> |
|
1070 | 2004-11-08 Fernando Perez <fperez@colorado.edu> | |
1059 |
|
1071 | |||
1060 | * IPython/iplib.py (init_readline): Fix exit message for Windows |
|
1072 | * IPython/iplib.py (init_readline): Fix exit message for Windows | |
1061 | when readline is active. Thanks to a report by Eric Jones |
|
1073 | when readline is active. Thanks to a report by Eric Jones | |
1062 | <eric-AT-enthought.com>. |
|
1074 | <eric-AT-enthought.com>. | |
1063 |
|
1075 | |||
1064 | 2004-11-07 Fernando Perez <fperez@colorado.edu> |
|
1076 | 2004-11-07 Fernando Perez <fperez@colorado.edu> | |
1065 |
|
1077 | |||
1066 | * IPython/genutils.py (page): Add a trap for OSError exceptions, |
|
1078 | * IPython/genutils.py (page): Add a trap for OSError exceptions, | |
1067 | sometimes seen by win2k/cygwin users. |
|
1079 | sometimes seen by win2k/cygwin users. | |
1068 |
|
1080 | |||
1069 | 2004-11-06 Fernando Perez <fperez@colorado.edu> |
|
1081 | 2004-11-06 Fernando Perez <fperez@colorado.edu> | |
1070 |
|
1082 | |||
1071 | * IPython/iplib.py (interact): Change the handling of %Exit from |
|
1083 | * IPython/iplib.py (interact): Change the handling of %Exit from | |
1072 | trying to propagate a SystemExit to an internal ipython flag. |
|
1084 | trying to propagate a SystemExit to an internal ipython flag. | |
1073 | This is less elegant than using Python's exception mechanism, but |
|
1085 | This is less elegant than using Python's exception mechanism, but | |
1074 | I can't get that to work reliably with threads, so under -pylab |
|
1086 | I can't get that to work reliably with threads, so under -pylab | |
1075 | %Exit was hanging IPython. Cross-thread exception handling is |
|
1087 | %Exit was hanging IPython. Cross-thread exception handling is | |
1076 | really a bitch. Thaks to a bug report by Stephen Walton |
|
1088 | really a bitch. Thaks to a bug report by Stephen Walton | |
1077 | <stephen.walton-AT-csun.edu>. |
|
1089 | <stephen.walton-AT-csun.edu>. | |
1078 |
|
1090 | |||
1079 | 2004-11-04 Fernando Perez <fperez@colorado.edu> |
|
1091 | 2004-11-04 Fernando Perez <fperez@colorado.edu> | |
1080 |
|
1092 | |||
1081 | * IPython/iplib.py (raw_input_original): store a pointer to the |
|
1093 | * IPython/iplib.py (raw_input_original): store a pointer to the | |
1082 | true raw_input to harden against code which can modify it |
|
1094 | true raw_input to harden against code which can modify it | |
1083 | (wx.py.PyShell does this and would otherwise crash ipython). |
|
1095 | (wx.py.PyShell does this and would otherwise crash ipython). | |
1084 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. |
|
1096 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. | |
1085 |
|
1097 | |||
1086 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for |
|
1098 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for | |
1087 | Ctrl-C problem, which does not mess up the input line. |
|
1099 | Ctrl-C problem, which does not mess up the input line. | |
1088 |
|
1100 | |||
1089 | 2004-11-03 Fernando Perez <fperez@colorado.edu> |
|
1101 | 2004-11-03 Fernando Perez <fperez@colorado.edu> | |
1090 |
|
1102 | |||
1091 | * IPython/Release.py: Changed licensing to BSD, in all files. |
|
1103 | * IPython/Release.py: Changed licensing to BSD, in all files. | |
1092 | (name): lowercase name for tarball/RPM release. |
|
1104 | (name): lowercase name for tarball/RPM release. | |
1093 |
|
1105 | |||
1094 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for |
|
1106 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for | |
1095 | use throughout ipython. |
|
1107 | use throughout ipython. | |
1096 |
|
1108 | |||
1097 | * IPython/Magic.py (Magic._ofind): Switch to using the new |
|
1109 | * IPython/Magic.py (Magic._ofind): Switch to using the new | |
1098 | OInspect.getdoc() function. |
|
1110 | OInspect.getdoc() function. | |
1099 |
|
1111 | |||
1100 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution |
|
1112 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution | |
1101 | of the line currently being canceled via Ctrl-C. It's extremely |
|
1113 | of the line currently being canceled via Ctrl-C. It's extremely | |
1102 | ugly, but I don't know how to do it better (the problem is one of |
|
1114 | ugly, but I don't know how to do it better (the problem is one of | |
1103 | handling cross-thread exceptions). |
|
1115 | handling cross-thread exceptions). | |
1104 |
|
1116 | |||
1105 | 2004-10-28 Fernando Perez <fperez@colorado.edu> |
|
1117 | 2004-10-28 Fernando Perez <fperez@colorado.edu> | |
1106 |
|
1118 | |||
1107 | * IPython/Shell.py (signal_handler): add signal handlers to trap |
|
1119 | * IPython/Shell.py (signal_handler): add signal handlers to trap | |
1108 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug |
|
1120 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug | |
1109 | report by Francesc Alted. |
|
1121 | report by Francesc Alted. | |
1110 |
|
1122 | |||
1111 | 2004-10-21 Fernando Perez <fperez@colorado.edu> |
|
1123 | 2004-10-21 Fernando Perez <fperez@colorado.edu> | |
1112 |
|
1124 | |||
1113 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ |
|
1125 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ | |
1114 | to % for pysh syntax extensions. |
|
1126 | to % for pysh syntax extensions. | |
1115 |
|
1127 | |||
1116 | 2004-10-09 Fernando Perez <fperez@colorado.edu> |
|
1128 | 2004-10-09 Fernando Perez <fperez@colorado.edu> | |
1117 |
|
1129 | |||
1118 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric |
|
1130 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric | |
1119 | arrays to print a more useful summary, without calling str(arr). |
|
1131 | arrays to print a more useful summary, without calling str(arr). | |
1120 | This avoids the problem of extremely lengthy computations which |
|
1132 | This avoids the problem of extremely lengthy computations which | |
1121 | occur if arr is large, and appear to the user as a system lockup |
|
1133 | occur if arr is large, and appear to the user as a system lockup | |
1122 | with 100% cpu activity. After a suggestion by Kristian Sandberg |
|
1134 | with 100% cpu activity. After a suggestion by Kristian Sandberg | |
1123 | <Kristian.Sandberg@colorado.edu>. |
|
1135 | <Kristian.Sandberg@colorado.edu>. | |
1124 | (Magic.__init__): fix bug in global magic escapes not being |
|
1136 | (Magic.__init__): fix bug in global magic escapes not being | |
1125 | correctly set. |
|
1137 | correctly set. | |
1126 |
|
1138 | |||
1127 | 2004-10-08 Fernando Perez <fperez@colorado.edu> |
|
1139 | 2004-10-08 Fernando Perez <fperez@colorado.edu> | |
1128 |
|
1140 | |||
1129 | * IPython/Magic.py (__license__): change to absolute imports of |
|
1141 | * IPython/Magic.py (__license__): change to absolute imports of | |
1130 | ipython's own internal packages, to start adapting to the absolute |
|
1142 | ipython's own internal packages, to start adapting to the absolute | |
1131 | import requirement of PEP-328. |
|
1143 | import requirement of PEP-328. | |
1132 |
|
1144 | |||
1133 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all |
|
1145 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all | |
1134 | files, and standardize author/license marks through the Release |
|
1146 | files, and standardize author/license marks through the Release | |
1135 | module instead of having per/file stuff (except for files with |
|
1147 | module instead of having per/file stuff (except for files with | |
1136 | particular licenses, like the MIT/PSF-licensed codes). |
|
1148 | particular licenses, like the MIT/PSF-licensed codes). | |
1137 |
|
1149 | |||
1138 | * IPython/Debugger.py: remove dead code for python 2.1 |
|
1150 | * IPython/Debugger.py: remove dead code for python 2.1 | |
1139 |
|
1151 | |||
1140 | 2004-10-04 Fernando Perez <fperez@colorado.edu> |
|
1152 | 2004-10-04 Fernando Perez <fperez@colorado.edu> | |
1141 |
|
1153 | |||
1142 | * IPython/iplib.py (ipmagic): New function for accessing magics |
|
1154 | * IPython/iplib.py (ipmagic): New function for accessing magics | |
1143 | via a normal python function call. |
|
1155 | via a normal python function call. | |
1144 |
|
1156 | |||
1145 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape |
|
1157 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape | |
1146 | from '@' to '%', to accomodate the new @decorator syntax of python |
|
1158 | from '@' to '%', to accomodate the new @decorator syntax of python | |
1147 | 2.4. |
|
1159 | 2.4. | |
1148 |
|
1160 | |||
1149 | 2004-09-29 Fernando Perez <fperez@colorado.edu> |
|
1161 | 2004-09-29 Fernando Perez <fperez@colorado.edu> | |
1150 |
|
1162 | |||
1151 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to |
|
1163 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to | |
1152 | matplotlib.use to prevent running scripts which try to switch |
|
1164 | matplotlib.use to prevent running scripts which try to switch | |
1153 | interactive backends from within ipython. This will just crash |
|
1165 | interactive backends from within ipython. This will just crash | |
1154 | the python interpreter, so we can't allow it (but a detailed error |
|
1166 | the python interpreter, so we can't allow it (but a detailed error | |
1155 | is given to the user). |
|
1167 | is given to the user). | |
1156 |
|
1168 | |||
1157 | 2004-09-28 Fernando Perez <fperez@colorado.edu> |
|
1169 | 2004-09-28 Fernando Perez <fperez@colorado.edu> | |
1158 |
|
1170 | |||
1159 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): |
|
1171 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): | |
1160 | matplotlib-related fixes so that using @run with non-matplotlib |
|
1172 | matplotlib-related fixes so that using @run with non-matplotlib | |
1161 | scripts doesn't pop up spurious plot windows. This requires |
|
1173 | scripts doesn't pop up spurious plot windows. This requires | |
1162 | matplotlib >= 0.63, where I had to make some changes as well. |
|
1174 | matplotlib >= 0.63, where I had to make some changes as well. | |
1163 |
|
1175 | |||
1164 | * IPython/ipmaker.py (make_IPython): update version requirement to |
|
1176 | * IPython/ipmaker.py (make_IPython): update version requirement to | |
1165 | python 2.2. |
|
1177 | python 2.2. | |
1166 |
|
1178 | |||
1167 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional |
|
1179 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional | |
1168 | banner arg for embedded customization. |
|
1180 | banner arg for embedded customization. | |
1169 |
|
1181 | |||
1170 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all |
|
1182 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all | |
1171 | explicit uses of __IP as the IPython's instance name. Now things |
|
1183 | explicit uses of __IP as the IPython's instance name. Now things | |
1172 | are properly handled via the shell.name value. The actual code |
|
1184 | are properly handled via the shell.name value. The actual code | |
1173 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this |
|
1185 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this | |
1174 | is much better than before. I'll clean things completely when the |
|
1186 | is much better than before. I'll clean things completely when the | |
1175 | magic stuff gets a real overhaul. |
|
1187 | magic stuff gets a real overhaul. | |
1176 |
|
1188 | |||
1177 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in |
|
1189 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in | |
1178 | minor changes to debian dir. |
|
1190 | minor changes to debian dir. | |
1179 |
|
1191 | |||
1180 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a |
|
1192 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a | |
1181 | pointer to the shell itself in the interactive namespace even when |
|
1193 | pointer to the shell itself in the interactive namespace even when | |
1182 | a user-supplied dict is provided. This is needed for embedding |
|
1194 | a user-supplied dict is provided. This is needed for embedding | |
1183 | purposes (found by tests with Michel Sanner). |
|
1195 | purposes (found by tests with Michel Sanner). | |
1184 |
|
1196 | |||
1185 | 2004-09-27 Fernando Perez <fperez@colorado.edu> |
|
1197 | 2004-09-27 Fernando Perez <fperez@colorado.edu> | |
1186 |
|
1198 | |||
1187 | * IPython/UserConfig/ipythonrc: remove []{} from |
|
1199 | * IPython/UserConfig/ipythonrc: remove []{} from | |
1188 | readline_remove_delims, so that things like [modname.<TAB> do |
|
1200 | readline_remove_delims, so that things like [modname.<TAB> do | |
1189 | proper completion. This disables [].TAB, but that's a less common |
|
1201 | proper completion. This disables [].TAB, but that's a less common | |
1190 | case than module names in list comprehensions, for example. |
|
1202 | case than module names in list comprehensions, for example. | |
1191 | Thanks to a report by Andrea Riciputi. |
|
1203 | Thanks to a report by Andrea Riciputi. | |
1192 |
|
1204 | |||
1193 | 2004-09-09 Fernando Perez <fperez@colorado.edu> |
|
1205 | 2004-09-09 Fernando Perez <fperez@colorado.edu> | |
1194 |
|
1206 | |||
1195 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid |
|
1207 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid | |
1196 | blocking problems in win32 and osx. Fix by John. |
|
1208 | blocking problems in win32 and osx. Fix by John. | |
1197 |
|
1209 | |||
1198 | 2004-09-08 Fernando Perez <fperez@colorado.edu> |
|
1210 | 2004-09-08 Fernando Perez <fperez@colorado.edu> | |
1199 |
|
1211 | |||
1200 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug |
|
1212 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug | |
1201 | for Win32 and OSX. Fix by John Hunter. |
|
1213 | for Win32 and OSX. Fix by John Hunter. | |
1202 |
|
1214 | |||
1203 | 2004-08-30 *** Released version 0.6.3 |
|
1215 | 2004-08-30 *** Released version 0.6.3 | |
1204 |
|
1216 | |||
1205 | 2004-08-30 Fernando Perez <fperez@colorado.edu> |
|
1217 | 2004-08-30 Fernando Perez <fperez@colorado.edu> | |
1206 |
|
1218 | |||
1207 | * setup.py (isfile): Add manpages to list of dependent files to be |
|
1219 | * setup.py (isfile): Add manpages to list of dependent files to be | |
1208 | updated. |
|
1220 | updated. | |
1209 |
|
1221 | |||
1210 | 2004-08-27 Fernando Perez <fperez@colorado.edu> |
|
1222 | 2004-08-27 Fernando Perez <fperez@colorado.edu> | |
1211 |
|
1223 | |||
1212 | * IPython/Shell.py (start): I've disabled -wthread and -gthread |
|
1224 | * IPython/Shell.py (start): I've disabled -wthread and -gthread | |
1213 | for now. They don't really work with standalone WX/GTK code |
|
1225 | for now. They don't really work with standalone WX/GTK code | |
1214 | (though matplotlib IS working fine with both of those backends). |
|
1226 | (though matplotlib IS working fine with both of those backends). | |
1215 | This will neeed much more testing. I disabled most things with |
|
1227 | This will neeed much more testing. I disabled most things with | |
1216 | comments, so turning it back on later should be pretty easy. |
|
1228 | comments, so turning it back on later should be pretty easy. | |
1217 |
|
1229 | |||
1218 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental |
|
1230 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental | |
1219 | autocalling of expressions like r'foo', by modifying the line |
|
1231 | autocalling of expressions like r'foo', by modifying the line | |
1220 | split regexp. Closes |
|
1232 | split regexp. Closes | |
1221 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas |
|
1233 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas | |
1222 | Riley <ipythonbugs-AT-sabi.net>. |
|
1234 | Riley <ipythonbugs-AT-sabi.net>. | |
1223 | (InteractiveShell.mainloop): honor --nobanner with banner |
|
1235 | (InteractiveShell.mainloop): honor --nobanner with banner | |
1224 | extensions. |
|
1236 | extensions. | |
1225 |
|
1237 | |||
1226 | * IPython/Shell.py: Significant refactoring of all classes, so |
|
1238 | * IPython/Shell.py: Significant refactoring of all classes, so | |
1227 | that we can really support ALL matplotlib backends and threading |
|
1239 | that we can really support ALL matplotlib backends and threading | |
1228 | models (John spotted a bug with Tk which required this). Now we |
|
1240 | models (John spotted a bug with Tk which required this). Now we | |
1229 | should support single-threaded, WX-threads and GTK-threads, both |
|
1241 | should support single-threaded, WX-threads and GTK-threads, both | |
1230 | for generic code and for matplotlib. |
|
1242 | for generic code and for matplotlib. | |
1231 |
|
1243 | |||
1232 | * IPython/ipmaker.py (__call__): Changed -mpthread option to |
|
1244 | * IPython/ipmaker.py (__call__): Changed -mpthread option to | |
1233 | -pylab, to simplify things for users. Will also remove the pylab |
|
1245 | -pylab, to simplify things for users. Will also remove the pylab | |
1234 | profile, since now all of matplotlib configuration is directly |
|
1246 | profile, since now all of matplotlib configuration is directly | |
1235 | handled here. This also reduces startup time. |
|
1247 | handled here. This also reduces startup time. | |
1236 |
|
1248 | |||
1237 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of |
|
1249 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of | |
1238 | shell wasn't being correctly called. Also in IPShellWX. |
|
1250 | shell wasn't being correctly called. Also in IPShellWX. | |
1239 |
|
1251 | |||
1240 | * IPython/iplib.py (InteractiveShell.__init__): Added option to |
|
1252 | * IPython/iplib.py (InteractiveShell.__init__): Added option to | |
1241 | fine-tune banner. |
|
1253 | fine-tune banner. | |
1242 |
|
1254 | |||
1243 | * IPython/numutils.py (spike): Deprecate these spike functions, |
|
1255 | * IPython/numutils.py (spike): Deprecate these spike functions, | |
1244 | delete (long deprecated) gnuplot_exec handler. |
|
1256 | delete (long deprecated) gnuplot_exec handler. | |
1245 |
|
1257 | |||
1246 | 2004-08-26 Fernando Perez <fperez@colorado.edu> |
|
1258 | 2004-08-26 Fernando Perez <fperez@colorado.edu> | |
1247 |
|
1259 | |||
1248 | * ipython.1: Update for threading options, plus some others which |
|
1260 | * ipython.1: Update for threading options, plus some others which | |
1249 | were missing. |
|
1261 | were missing. | |
1250 |
|
1262 | |||
1251 | * IPython/ipmaker.py (__call__): Added -wthread option for |
|
1263 | * IPython/ipmaker.py (__call__): Added -wthread option for | |
1252 | wxpython thread handling. Make sure threading options are only |
|
1264 | wxpython thread handling. Make sure threading options are only | |
1253 | valid at the command line. |
|
1265 | valid at the command line. | |
1254 |
|
1266 | |||
1255 | * scripts/ipython: moved shell selection into a factory function |
|
1267 | * scripts/ipython: moved shell selection into a factory function | |
1256 | in Shell.py, to keep the starter script to a minimum. |
|
1268 | in Shell.py, to keep the starter script to a minimum. | |
1257 |
|
1269 | |||
1258 | 2004-08-25 Fernando Perez <fperez@colorado.edu> |
|
1270 | 2004-08-25 Fernando Perez <fperez@colorado.edu> | |
1259 |
|
1271 | |||
1260 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by |
|
1272 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by | |
1261 | John. Along with some recent changes he made to matplotlib, the |
|
1273 | John. Along with some recent changes he made to matplotlib, the | |
1262 | next versions of both systems should work very well together. |
|
1274 | next versions of both systems should work very well together. | |
1263 |
|
1275 | |||
1264 | 2004-08-24 Fernando Perez <fperez@colorado.edu> |
|
1276 | 2004-08-24 Fernando Perez <fperez@colorado.edu> | |
1265 |
|
1277 | |||
1266 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I |
|
1278 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I | |
1267 | tried to switch the profiling to using hotshot, but I'm getting |
|
1279 | tried to switch the profiling to using hotshot, but I'm getting | |
1268 | strange errors from prof.runctx() there. I may be misreading the |
|
1280 | strange errors from prof.runctx() there. I may be misreading the | |
1269 | docs, but it looks weird. For now the profiling code will |
|
1281 | docs, but it looks weird. For now the profiling code will | |
1270 | continue to use the standard profiler. |
|
1282 | continue to use the standard profiler. | |
1271 |
|
1283 | |||
1272 | 2004-08-23 Fernando Perez <fperez@colorado.edu> |
|
1284 | 2004-08-23 Fernando Perez <fperez@colorado.edu> | |
1273 |
|
1285 | |||
1274 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX |
|
1286 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX | |
1275 | threaded shell, by John Hunter. It's not quite ready yet, but |
|
1287 | threaded shell, by John Hunter. It's not quite ready yet, but | |
1276 | close. |
|
1288 | close. | |
1277 |
|
1289 | |||
1278 | 2004-08-22 Fernando Perez <fperez@colorado.edu> |
|
1290 | 2004-08-22 Fernando Perez <fperez@colorado.edu> | |
1279 |
|
1291 | |||
1280 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also |
|
1292 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also | |
1281 | in Magic and ultraTB. |
|
1293 | in Magic and ultraTB. | |
1282 |
|
1294 | |||
1283 | * ipython.1: document threading options in manpage. |
|
1295 | * ipython.1: document threading options in manpage. | |
1284 |
|
1296 | |||
1285 | * scripts/ipython: Changed name of -thread option to -gthread, |
|
1297 | * scripts/ipython: Changed name of -thread option to -gthread, | |
1286 | since this is GTK specific. I want to leave the door open for a |
|
1298 | since this is GTK specific. I want to leave the door open for a | |
1287 | -wthread option for WX, which will most likely be necessary. This |
|
1299 | -wthread option for WX, which will most likely be necessary. This | |
1288 | change affects usage and ipmaker as well. |
|
1300 | change affects usage and ipmaker as well. | |
1289 |
|
1301 | |||
1290 | * IPython/Shell.py (matplotlib_shell): Add a factory function to |
|
1302 | * IPython/Shell.py (matplotlib_shell): Add a factory function to | |
1291 | handle the matplotlib shell issues. Code by John Hunter |
|
1303 | handle the matplotlib shell issues. Code by John Hunter | |
1292 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
1304 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
1293 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's |
|
1305 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's | |
1294 | broken (and disabled for end users) for now, but it puts the |
|
1306 | broken (and disabled for end users) for now, but it puts the | |
1295 | infrastructure in place. |
|
1307 | infrastructure in place. | |
1296 |
|
1308 | |||
1297 | 2004-08-21 Fernando Perez <fperez@colorado.edu> |
|
1309 | 2004-08-21 Fernando Perez <fperez@colorado.edu> | |
1298 |
|
1310 | |||
1299 | * ipythonrc-pylab: Add matplotlib support. |
|
1311 | * ipythonrc-pylab: Add matplotlib support. | |
1300 |
|
1312 | |||
1301 | * matplotlib_config.py: new files for matplotlib support, part of |
|
1313 | * matplotlib_config.py: new files for matplotlib support, part of | |
1302 | the pylab profile. |
|
1314 | the pylab profile. | |
1303 |
|
1315 | |||
1304 | * IPython/usage.py (__doc__): documented the threading options. |
|
1316 | * IPython/usage.py (__doc__): documented the threading options. | |
1305 |
|
1317 | |||
1306 | 2004-08-20 Fernando Perez <fperez@colorado.edu> |
|
1318 | 2004-08-20 Fernando Perez <fperez@colorado.edu> | |
1307 |
|
1319 | |||
1308 | * ipython: Modified the main calling routine to handle the -thread |
|
1320 | * ipython: Modified the main calling routine to handle the -thread | |
1309 | and -mpthread options. This needs to be done as a top-level hack, |
|
1321 | and -mpthread options. This needs to be done as a top-level hack, | |
1310 | because it determines which class to instantiate for IPython |
|
1322 | because it determines which class to instantiate for IPython | |
1311 | itself. |
|
1323 | itself. | |
1312 |
|
1324 | |||
1313 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of |
|
1325 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of | |
1314 | classes to support multithreaded GTK operation without blocking, |
|
1326 | classes to support multithreaded GTK operation without blocking, | |
1315 | and matplotlib with all backends. This is a lot of still very |
|
1327 | and matplotlib with all backends. This is a lot of still very | |
1316 | experimental code, and threads are tricky. So it may still have a |
|
1328 | experimental code, and threads are tricky. So it may still have a | |
1317 | few rough edges... This code owes a lot to |
|
1329 | few rough edges... This code owes a lot to | |
1318 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by |
|
1330 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by | |
1319 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and |
|
1331 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and | |
1320 | to John Hunter for all the matplotlib work. |
|
1332 | to John Hunter for all the matplotlib work. | |
1321 |
|
1333 | |||
1322 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread |
|
1334 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread | |
1323 | options for gtk thread and matplotlib support. |
|
1335 | options for gtk thread and matplotlib support. | |
1324 |
|
1336 | |||
1325 | 2004-08-16 Fernando Perez <fperez@colorado.edu> |
|
1337 | 2004-08-16 Fernando Perez <fperez@colorado.edu> | |
1326 |
|
1338 | |||
1327 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger |
|
1339 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger | |
1328 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug |
|
1340 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug | |
1329 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. |
|
1341 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. | |
1330 |
|
1342 | |||
1331 | 2004-08-11 Fernando Perez <fperez@colorado.edu> |
|
1343 | 2004-08-11 Fernando Perez <fperez@colorado.edu> | |
1332 |
|
1344 | |||
1333 | * setup.py (isfile): Fix build so documentation gets updated for |
|
1345 | * setup.py (isfile): Fix build so documentation gets updated for | |
1334 | rpms (it was only done for .tgz builds). |
|
1346 | rpms (it was only done for .tgz builds). | |
1335 |
|
1347 | |||
1336 | 2004-08-10 Fernando Perez <fperez@colorado.edu> |
|
1348 | 2004-08-10 Fernando Perez <fperez@colorado.edu> | |
1337 |
|
1349 | |||
1338 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). |
|
1350 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). | |
1339 |
|
1351 | |||
1340 | * iplib.py : Silence syntax error exceptions in tab-completion. |
|
1352 | * iplib.py : Silence syntax error exceptions in tab-completion. | |
1341 |
|
1353 | |||
1342 | 2004-08-05 Fernando Perez <fperez@colorado.edu> |
|
1354 | 2004-08-05 Fernando Perez <fperez@colorado.edu> | |
1343 |
|
1355 | |||
1344 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set |
|
1356 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set | |
1345 | 'color off' mark for continuation prompts. This was causing long |
|
1357 | 'color off' mark for continuation prompts. This was causing long | |
1346 | continuation lines to mis-wrap. |
|
1358 | continuation lines to mis-wrap. | |
1347 |
|
1359 | |||
1348 | 2004-08-01 Fernando Perez <fperez@colorado.edu> |
|
1360 | 2004-08-01 Fernando Perez <fperez@colorado.edu> | |
1349 |
|
1361 | |||
1350 | * IPython/ipmaker.py (make_IPython): Allow the shell class used |
|
1362 | * IPython/ipmaker.py (make_IPython): Allow the shell class used | |
1351 | for building ipython to be a parameter. All this is necessary |
|
1363 | for building ipython to be a parameter. All this is necessary | |
1352 | right now to have a multithreaded version, but this insane |
|
1364 | right now to have a multithreaded version, but this insane | |
1353 | non-design will be cleaned up soon. For now, it's a hack that |
|
1365 | non-design will be cleaned up soon. For now, it's a hack that | |
1354 | works. |
|
1366 | works. | |
1355 |
|
1367 | |||
1356 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default |
|
1368 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default | |
1357 | args in various places. No bugs so far, but it's a dangerous |
|
1369 | args in various places. No bugs so far, but it's a dangerous | |
1358 | practice. |
|
1370 | practice. | |
1359 |
|
1371 | |||
1360 | 2004-07-31 Fernando Perez <fperez@colorado.edu> |
|
1372 | 2004-07-31 Fernando Perez <fperez@colorado.edu> | |
1361 |
|
1373 | |||
1362 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to |
|
1374 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to | |
1363 | fix completion of files with dots in their names under most |
|
1375 | fix completion of files with dots in their names under most | |
1364 | profiles (pysh was OK because the completion order is different). |
|
1376 | profiles (pysh was OK because the completion order is different). | |
1365 |
|
1377 | |||
1366 | 2004-07-27 Fernando Perez <fperez@colorado.edu> |
|
1378 | 2004-07-27 Fernando Perez <fperez@colorado.edu> | |
1367 |
|
1379 | |||
1368 | * IPython/iplib.py (InteractiveShell.__init__): build dict of |
|
1380 | * IPython/iplib.py (InteractiveShell.__init__): build dict of | |
1369 | keywords manually, b/c the one in keyword.py was removed in python |
|
1381 | keywords manually, b/c the one in keyword.py was removed in python | |
1370 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. |
|
1382 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. | |
1371 | This is NOT a bug under python 2.3 and earlier. |
|
1383 | This is NOT a bug under python 2.3 and earlier. | |
1372 |
|
1384 | |||
1373 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1385 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1374 |
|
1386 | |||
1375 | * IPython/ultraTB.py (VerboseTB.text): Add another |
|
1387 | * IPython/ultraTB.py (VerboseTB.text): Add another | |
1376 | linecache.checkcache() call to try to prevent inspect.py from |
|
1388 | linecache.checkcache() call to try to prevent inspect.py from | |
1377 | crashing under python 2.3. I think this fixes |
|
1389 | crashing under python 2.3. I think this fixes | |
1378 | http://www.scipy.net/roundup/ipython/issue17. |
|
1390 | http://www.scipy.net/roundup/ipython/issue17. | |
1379 |
|
1391 | |||
1380 | 2004-07-26 *** Released version 0.6.2 |
|
1392 | 2004-07-26 *** Released version 0.6.2 | |
1381 |
|
1393 | |||
1382 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1394 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1383 |
|
1395 | |||
1384 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would |
|
1396 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would | |
1385 | fail for any number. |
|
1397 | fail for any number. | |
1386 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for |
|
1398 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for | |
1387 | empty bookmarks. |
|
1399 | empty bookmarks. | |
1388 |
|
1400 | |||
1389 | 2004-07-26 *** Released version 0.6.1 |
|
1401 | 2004-07-26 *** Released version 0.6.1 | |
1390 |
|
1402 | |||
1391 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1403 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1392 |
|
1404 | |||
1393 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. |
|
1405 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. | |
1394 |
|
1406 | |||
1395 | * IPython/iplib.py (protect_filename): Applied Ville's patch for |
|
1407 | * IPython/iplib.py (protect_filename): Applied Ville's patch for | |
1396 | escaping '()[]{}' in filenames. |
|
1408 | escaping '()[]{}' in filenames. | |
1397 |
|
1409 | |||
1398 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for |
|
1410 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for | |
1399 | Python 2.2 users who lack a proper shlex.split. |
|
1411 | Python 2.2 users who lack a proper shlex.split. | |
1400 |
|
1412 | |||
1401 | 2004-07-19 Fernando Perez <fperez@colorado.edu> |
|
1413 | 2004-07-19 Fernando Perez <fperez@colorado.edu> | |
1402 |
|
1414 | |||
1403 | * IPython/iplib.py (InteractiveShell.init_readline): Add support |
|
1415 | * IPython/iplib.py (InteractiveShell.init_readline): Add support | |
1404 | for reading readline's init file. I follow the normal chain: |
|
1416 | for reading readline's init file. I follow the normal chain: | |
1405 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a |
|
1417 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a | |
1406 | report by Mike Heeter. This closes |
|
1418 | report by Mike Heeter. This closes | |
1407 | http://www.scipy.net/roundup/ipython/issue16. |
|
1419 | http://www.scipy.net/roundup/ipython/issue16. | |
1408 |
|
1420 | |||
1409 | 2004-07-18 Fernando Perez <fperez@colorado.edu> |
|
1421 | 2004-07-18 Fernando Perez <fperez@colorado.edu> | |
1410 |
|
1422 | |||
1411 | * IPython/iplib.py (__init__): Add better handling of '\' under |
|
1423 | * IPython/iplib.py (__init__): Add better handling of '\' under | |
1412 | Win32 for filenames. After a patch by Ville. |
|
1424 | Win32 for filenames. After a patch by Ville. | |
1413 |
|
1425 | |||
1414 | 2004-07-17 Fernando Perez <fperez@colorado.edu> |
|
1426 | 2004-07-17 Fernando Perez <fperez@colorado.edu> | |
1415 |
|
1427 | |||
1416 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
1428 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
1417 | autocalling would be triggered for 'foo is bar' if foo is |
|
1429 | autocalling would be triggered for 'foo is bar' if foo is | |
1418 | callable. I also cleaned up the autocall detection code to use a |
|
1430 | callable. I also cleaned up the autocall detection code to use a | |
1419 | regexp, which is faster. Bug reported by Alexander Schmolck. |
|
1431 | regexp, which is faster. Bug reported by Alexander Schmolck. | |
1420 |
|
1432 | |||
1421 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with |
|
1433 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with | |
1422 | '?' in them would confuse the help system. Reported by Alex |
|
1434 | '?' in them would confuse the help system. Reported by Alex | |
1423 | Schmolck. |
|
1435 | Schmolck. | |
1424 |
|
1436 | |||
1425 | 2004-07-16 Fernando Perez <fperez@colorado.edu> |
|
1437 | 2004-07-16 Fernando Perez <fperez@colorado.edu> | |
1426 |
|
1438 | |||
1427 | * IPython/GnuplotInteractive.py (__all__): added plot2. |
|
1439 | * IPython/GnuplotInteractive.py (__all__): added plot2. | |
1428 |
|
1440 | |||
1429 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for |
|
1441 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for | |
1430 | plotting dictionaries, lists or tuples of 1d arrays. |
|
1442 | plotting dictionaries, lists or tuples of 1d arrays. | |
1431 |
|
1443 | |||
1432 | * IPython/Magic.py (Magic.magic_hist): small clenaups and |
|
1444 | * IPython/Magic.py (Magic.magic_hist): small clenaups and | |
1433 | optimizations. |
|
1445 | optimizations. | |
1434 |
|
1446 | |||
1435 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is |
|
1447 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is | |
1436 | the information which was there from Janko's original IPP code: |
|
1448 | the information which was there from Janko's original IPP code: | |
1437 |
|
1449 | |||
1438 | 03.05.99 20:53 porto.ifm.uni-kiel.de |
|
1450 | 03.05.99 20:53 porto.ifm.uni-kiel.de | |
1439 | --Started changelog. |
|
1451 | --Started changelog. | |
1440 | --make clear do what it say it does |
|
1452 | --make clear do what it say it does | |
1441 | --added pretty output of lines from inputcache |
|
1453 | --added pretty output of lines from inputcache | |
1442 | --Made Logger a mixin class, simplifies handling of switches |
|
1454 | --Made Logger a mixin class, simplifies handling of switches | |
1443 | --Added own completer class. .string<TAB> expands to last history |
|
1455 | --Added own completer class. .string<TAB> expands to last history | |
1444 | line which starts with string. The new expansion is also present |
|
1456 | line which starts with string. The new expansion is also present | |
1445 | with Ctrl-r from the readline library. But this shows, who this |
|
1457 | with Ctrl-r from the readline library. But this shows, who this | |
1446 | can be done for other cases. |
|
1458 | can be done for other cases. | |
1447 | --Added convention that all shell functions should accept a |
|
1459 | --Added convention that all shell functions should accept a | |
1448 | parameter_string This opens the door for different behaviour for |
|
1460 | parameter_string This opens the door for different behaviour for | |
1449 | each function. @cd is a good example of this. |
|
1461 | each function. @cd is a good example of this. | |
1450 |
|
1462 | |||
1451 | 04.05.99 12:12 porto.ifm.uni-kiel.de |
|
1463 | 04.05.99 12:12 porto.ifm.uni-kiel.de | |
1452 | --added logfile rotation |
|
1464 | --added logfile rotation | |
1453 | --added new mainloop method which freezes first the namespace |
|
1465 | --added new mainloop method which freezes first the namespace | |
1454 |
|
1466 | |||
1455 | 07.05.99 21:24 porto.ifm.uni-kiel.de |
|
1467 | 07.05.99 21:24 porto.ifm.uni-kiel.de | |
1456 | --added the docreader classes. Now there is a help system. |
|
1468 | --added the docreader classes. Now there is a help system. | |
1457 | -This is only a first try. Currently it's not easy to put new |
|
1469 | -This is only a first try. Currently it's not easy to put new | |
1458 | stuff in the indices. But this is the way to go. Info would be |
|
1470 | stuff in the indices. But this is the way to go. Info would be | |
1459 | better, but HTML is every where and not everybody has an info |
|
1471 | better, but HTML is every where and not everybody has an info | |
1460 | system installed and it's not so easy to change html-docs to info. |
|
1472 | system installed and it's not so easy to change html-docs to info. | |
1461 | --added global logfile option |
|
1473 | --added global logfile option | |
1462 | --there is now a hook for object inspection method pinfo needs to |
|
1474 | --there is now a hook for object inspection method pinfo needs to | |
1463 | be provided for this. Can be reached by two '??'. |
|
1475 | be provided for this. Can be reached by two '??'. | |
1464 |
|
1476 | |||
1465 | 08.05.99 20:51 porto.ifm.uni-kiel.de |
|
1477 | 08.05.99 20:51 porto.ifm.uni-kiel.de | |
1466 | --added a README |
|
1478 | --added a README | |
1467 | --bug in rc file. Something has changed so functions in the rc |
|
1479 | --bug in rc file. Something has changed so functions in the rc | |
1468 | file need to reference the shell and not self. Not clear if it's a |
|
1480 | file need to reference the shell and not self. Not clear if it's a | |
1469 | bug or feature. |
|
1481 | bug or feature. | |
1470 | --changed rc file for new behavior |
|
1482 | --changed rc file for new behavior | |
1471 |
|
1483 | |||
1472 | 2004-07-15 Fernando Perez <fperez@colorado.edu> |
|
1484 | 2004-07-15 Fernando Perez <fperez@colorado.edu> | |
1473 |
|
1485 | |||
1474 | * IPython/Logger.py (Logger.log): fixed recent bug where the input |
|
1486 | * IPython/Logger.py (Logger.log): fixed recent bug where the input | |
1475 | cache was falling out of sync in bizarre manners when multi-line |
|
1487 | cache was falling out of sync in bizarre manners when multi-line | |
1476 | input was present. Minor optimizations and cleanup. |
|
1488 | input was present. Minor optimizations and cleanup. | |
1477 |
|
1489 | |||
1478 | (Logger): Remove old Changelog info for cleanup. This is the |
|
1490 | (Logger): Remove old Changelog info for cleanup. This is the | |
1479 | information which was there from Janko's original code: |
|
1491 | information which was there from Janko's original code: | |
1480 |
|
1492 | |||
1481 | Changes to Logger: - made the default log filename a parameter |
|
1493 | Changes to Logger: - made the default log filename a parameter | |
1482 |
|
1494 | |||
1483 | - put a check for lines beginning with !@? in log(). Needed |
|
1495 | - put a check for lines beginning with !@? in log(). Needed | |
1484 | (even if the handlers properly log their lines) for mid-session |
|
1496 | (even if the handlers properly log their lines) for mid-session | |
1485 | logging activation to work properly. Without this, lines logged |
|
1497 | logging activation to work properly. Without this, lines logged | |
1486 | in mid session, which get read from the cache, would end up |
|
1498 | in mid session, which get read from the cache, would end up | |
1487 | 'bare' (with !@? in the open) in the log. Now they are caught |
|
1499 | 'bare' (with !@? in the open) in the log. Now they are caught | |
1488 | and prepended with a #. |
|
1500 | and prepended with a #. | |
1489 |
|
1501 | |||
1490 | * IPython/iplib.py (InteractiveShell.init_readline): added check |
|
1502 | * IPython/iplib.py (InteractiveShell.init_readline): added check | |
1491 | in case MagicCompleter fails to be defined, so we don't crash. |
|
1503 | in case MagicCompleter fails to be defined, so we don't crash. | |
1492 |
|
1504 | |||
1493 | 2004-07-13 Fernando Perez <fperez@colorado.edu> |
|
1505 | 2004-07-13 Fernando Perez <fperez@colorado.edu> | |
1494 |
|
1506 | |||
1495 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation |
|
1507 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation | |
1496 | of EPS if the requested filename ends in '.eps'. |
|
1508 | of EPS if the requested filename ends in '.eps'. | |
1497 |
|
1509 | |||
1498 | 2004-07-04 Fernando Perez <fperez@colorado.edu> |
|
1510 | 2004-07-04 Fernando Perez <fperez@colorado.edu> | |
1499 |
|
1511 | |||
1500 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix |
|
1512 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix | |
1501 | escaping of quotes when calling the shell. |
|
1513 | escaping of quotes when calling the shell. | |
1502 |
|
1514 | |||
1503 | 2004-07-02 Fernando Perez <fperez@colorado.edu> |
|
1515 | 2004-07-02 Fernando Perez <fperez@colorado.edu> | |
1504 |
|
1516 | |||
1505 | * IPython/Prompts.py (CachedOutput.update): Fix problem with |
|
1517 | * IPython/Prompts.py (CachedOutput.update): Fix problem with | |
1506 | gettext not working because we were clobbering '_'. Fixes |
|
1518 | gettext not working because we were clobbering '_'. Fixes | |
1507 | http://www.scipy.net/roundup/ipython/issue6. |
|
1519 | http://www.scipy.net/roundup/ipython/issue6. | |
1508 |
|
1520 | |||
1509 | 2004-07-01 Fernando Perez <fperez@colorado.edu> |
|
1521 | 2004-07-01 Fernando Perez <fperez@colorado.edu> | |
1510 |
|
1522 | |||
1511 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling |
|
1523 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling | |
1512 | into @cd. Patch by Ville. |
|
1524 | into @cd. Patch by Ville. | |
1513 |
|
1525 | |||
1514 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
1526 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
1515 | new function to store things after ipmaker runs. Patch by Ville. |
|
1527 | new function to store things after ipmaker runs. Patch by Ville. | |
1516 | Eventually this will go away once ipmaker is removed and the class |
|
1528 | Eventually this will go away once ipmaker is removed and the class | |
1517 | gets cleaned up, but for now it's ok. Key functionality here is |
|
1529 | gets cleaned up, but for now it's ok. Key functionality here is | |
1518 | the addition of the persistent storage mechanism, a dict for |
|
1530 | the addition of the persistent storage mechanism, a dict for | |
1519 | keeping data across sessions (for now just bookmarks, but more can |
|
1531 | keeping data across sessions (for now just bookmarks, but more can | |
1520 | be implemented later). |
|
1532 | be implemented later). | |
1521 |
|
1533 | |||
1522 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, |
|
1534 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, | |
1523 | persistent across sections. Patch by Ville, I modified it |
|
1535 | persistent across sections. Patch by Ville, I modified it | |
1524 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also |
|
1536 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also | |
1525 | added a '-l' option to list all bookmarks. |
|
1537 | added a '-l' option to list all bookmarks. | |
1526 |
|
1538 | |||
1527 | * IPython/iplib.py (InteractiveShell.atexit_operations): new |
|
1539 | * IPython/iplib.py (InteractiveShell.atexit_operations): new | |
1528 | center for cleanup. Registered with atexit.register(). I moved |
|
1540 | center for cleanup. Registered with atexit.register(). I moved | |
1529 | here the old exit_cleanup(). After a patch by Ville. |
|
1541 | here the old exit_cleanup(). After a patch by Ville. | |
1530 |
|
1542 | |||
1531 | * IPython/Magic.py (get_py_filename): added '~' to the accepted |
|
1543 | * IPython/Magic.py (get_py_filename): added '~' to the accepted | |
1532 | characters in the hacked shlex_split for python 2.2. |
|
1544 | characters in the hacked shlex_split for python 2.2. | |
1533 |
|
1545 | |||
1534 | * IPython/iplib.py (file_matches): more fixes to filenames with |
|
1546 | * IPython/iplib.py (file_matches): more fixes to filenames with | |
1535 | whitespace in them. It's not perfect, but limitations in python's |
|
1547 | whitespace in them. It's not perfect, but limitations in python's | |
1536 | readline make it impossible to go further. |
|
1548 | readline make it impossible to go further. | |
1537 |
|
1549 | |||
1538 | 2004-06-29 Fernando Perez <fperez@colorado.edu> |
|
1550 | 2004-06-29 Fernando Perez <fperez@colorado.edu> | |
1539 |
|
1551 | |||
1540 | * IPython/iplib.py (file_matches): escape whitespace correctly in |
|
1552 | * IPython/iplib.py (file_matches): escape whitespace correctly in | |
1541 | filename completions. Bug reported by Ville. |
|
1553 | filename completions. Bug reported by Ville. | |
1542 |
|
1554 | |||
1543 | 2004-06-28 Fernando Perez <fperez@colorado.edu> |
|
1555 | 2004-06-28 Fernando Perez <fperez@colorado.edu> | |
1544 |
|
1556 | |||
1545 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now |
|
1557 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now | |
1546 | the history file will be called 'history-PROFNAME' (or just |
|
1558 | the history file will be called 'history-PROFNAME' (or just | |
1547 | 'history' if no profile is loaded). I was getting annoyed at |
|
1559 | 'history' if no profile is loaded). I was getting annoyed at | |
1548 | getting my Numerical work history clobbered by pysh sessions. |
|
1560 | getting my Numerical work history clobbered by pysh sessions. | |
1549 |
|
1561 | |||
1550 | * IPython/iplib.py (InteractiveShell.__init__): Internal |
|
1562 | * IPython/iplib.py (InteractiveShell.__init__): Internal | |
1551 | getoutputerror() function so that we can honor the system_verbose |
|
1563 | getoutputerror() function so that we can honor the system_verbose | |
1552 | flag for _all_ system calls. I also added escaping of # |
|
1564 | flag for _all_ system calls. I also added escaping of # | |
1553 | characters here to avoid confusing Itpl. |
|
1565 | characters here to avoid confusing Itpl. | |
1554 |
|
1566 | |||
1555 | * IPython/Magic.py (shlex_split): removed call to shell in |
|
1567 | * IPython/Magic.py (shlex_split): removed call to shell in | |
1556 | parse_options and replaced it with shlex.split(). The annoying |
|
1568 | parse_options and replaced it with shlex.split(). The annoying | |
1557 | part was that in Python 2.2, shlex.split() doesn't exist, so I had |
|
1569 | part was that in Python 2.2, shlex.split() doesn't exist, so I had | |
1558 | to backport it from 2.3, with several frail hacks (the shlex |
|
1570 | to backport it from 2.3, with several frail hacks (the shlex | |
1559 | module is rather limited in 2.2). Thanks to a suggestion by Ville |
|
1571 | module is rather limited in 2.2). Thanks to a suggestion by Ville | |
1560 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no |
|
1572 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no | |
1561 | problem. |
|
1573 | problem. | |
1562 |
|
1574 | |||
1563 | (Magic.magic_system_verbose): new toggle to print the actual |
|
1575 | (Magic.magic_system_verbose): new toggle to print the actual | |
1564 | system calls made by ipython. Mainly for debugging purposes. |
|
1576 | system calls made by ipython. Mainly for debugging purposes. | |
1565 |
|
1577 | |||
1566 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which |
|
1578 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which | |
1567 | doesn't support persistence. Reported (and fix suggested) by |
|
1579 | doesn't support persistence. Reported (and fix suggested) by | |
1568 | Travis Caldwell <travis_caldwell2000@yahoo.com>. |
|
1580 | Travis Caldwell <travis_caldwell2000@yahoo.com>. | |
1569 |
|
1581 | |||
1570 | 2004-06-26 Fernando Perez <fperez@colorado.edu> |
|
1582 | 2004-06-26 Fernando Perez <fperez@colorado.edu> | |
1571 |
|
1583 | |||
1572 | * IPython/Logger.py (Logger.log): fix to handle correctly empty |
|
1584 | * IPython/Logger.py (Logger.log): fix to handle correctly empty | |
1573 | continue prompts. |
|
1585 | continue prompts. | |
1574 |
|
1586 | |||
1575 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() |
|
1587 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() | |
1576 | function (basically a big docstring) and a few more things here to |
|
1588 | function (basically a big docstring) and a few more things here to | |
1577 | speedup startup. pysh.py is now very lightweight. We want because |
|
1589 | speedup startup. pysh.py is now very lightweight. We want because | |
1578 | it gets execfile'd, while InterpreterExec gets imported, so |
|
1590 | it gets execfile'd, while InterpreterExec gets imported, so | |
1579 | byte-compilation saves time. |
|
1591 | byte-compilation saves time. | |
1580 |
|
1592 | |||
1581 | 2004-06-25 Fernando Perez <fperez@colorado.edu> |
|
1593 | 2004-06-25 Fernando Perez <fperez@colorado.edu> | |
1582 |
|
1594 | |||
1583 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd |
|
1595 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd | |
1584 | -NUM', which was recently broken. |
|
1596 | -NUM', which was recently broken. | |
1585 |
|
1597 | |||
1586 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! |
|
1598 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! | |
1587 | in multi-line input (but not !!, which doesn't make sense there). |
|
1599 | in multi-line input (but not !!, which doesn't make sense there). | |
1588 |
|
1600 | |||
1589 | * IPython/UserConfig/ipythonrc: made autoindent on by default. |
|
1601 | * IPython/UserConfig/ipythonrc: made autoindent on by default. | |
1590 | It's just too useful, and people can turn it off in the less |
|
1602 | It's just too useful, and people can turn it off in the less | |
1591 | common cases where it's a problem. |
|
1603 | common cases where it's a problem. | |
1592 |
|
1604 | |||
1593 | 2004-06-24 Fernando Perez <fperez@colorado.edu> |
|
1605 | 2004-06-24 Fernando Perez <fperez@colorado.edu> | |
1594 |
|
1606 | |||
1595 | * IPython/iplib.py (InteractiveShell._prefilter): big change - |
|
1607 | * IPython/iplib.py (InteractiveShell._prefilter): big change - | |
1596 | special syntaxes (like alias calling) is now allied in multi-line |
|
1608 | special syntaxes (like alias calling) is now allied in multi-line | |
1597 | input. This is still _very_ experimental, but it's necessary for |
|
1609 | input. This is still _very_ experimental, but it's necessary for | |
1598 | efficient shell usage combining python looping syntax with system |
|
1610 | efficient shell usage combining python looping syntax with system | |
1599 | calls. For now it's restricted to aliases, I don't think it |
|
1611 | calls. For now it's restricted to aliases, I don't think it | |
1600 | really even makes sense to have this for magics. |
|
1612 | really even makes sense to have this for magics. | |
1601 |
|
1613 | |||
1602 | 2004-06-23 Fernando Perez <fperez@colorado.edu> |
|
1614 | 2004-06-23 Fernando Perez <fperez@colorado.edu> | |
1603 |
|
1615 | |||
1604 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added |
|
1616 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added | |
1605 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. |
|
1617 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. | |
1606 |
|
1618 | |||
1607 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle |
|
1619 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle | |
1608 | extensions under Windows (after code sent by Gary Bishop). The |
|
1620 | extensions under Windows (after code sent by Gary Bishop). The | |
1609 | extensions considered 'executable' are stored in IPython's rc |
|
1621 | extensions considered 'executable' are stored in IPython's rc | |
1610 | structure as win_exec_ext. |
|
1622 | structure as win_exec_ext. | |
1611 |
|
1623 | |||
1612 | * IPython/genutils.py (shell): new function, like system() but |
|
1624 | * IPython/genutils.py (shell): new function, like system() but | |
1613 | without return value. Very useful for interactive shell work. |
|
1625 | without return value. Very useful for interactive shell work. | |
1614 |
|
1626 | |||
1615 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to |
|
1627 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to | |
1616 | delete aliases. |
|
1628 | delete aliases. | |
1617 |
|
1629 | |||
1618 | * IPython/iplib.py (InteractiveShell.alias_table_update): make |
|
1630 | * IPython/iplib.py (InteractiveShell.alias_table_update): make | |
1619 | sure that the alias table doesn't contain python keywords. |
|
1631 | sure that the alias table doesn't contain python keywords. | |
1620 |
|
1632 | |||
1621 | 2004-06-21 Fernando Perez <fperez@colorado.edu> |
|
1633 | 2004-06-21 Fernando Perez <fperez@colorado.edu> | |
1622 |
|
1634 | |||
1623 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when |
|
1635 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when | |
1624 | non-existent items are found in $PATH. Reported by Thorsten. |
|
1636 | non-existent items are found in $PATH. Reported by Thorsten. | |
1625 |
|
1637 | |||
1626 | 2004-06-20 Fernando Perez <fperez@colorado.edu> |
|
1638 | 2004-06-20 Fernando Perez <fperez@colorado.edu> | |
1627 |
|
1639 | |||
1628 | * IPython/iplib.py (complete): modified the completer so that the |
|
1640 | * IPython/iplib.py (complete): modified the completer so that the | |
1629 | order of priorities can be easily changed at runtime. |
|
1641 | order of priorities can be easily changed at runtime. | |
1630 |
|
1642 | |||
1631 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): |
|
1643 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): | |
1632 | Modified to auto-execute all lines beginning with '~', '/' or '.'. |
|
1644 | Modified to auto-execute all lines beginning with '~', '/' or '.'. | |
1633 |
|
1645 | |||
1634 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to |
|
1646 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to | |
1635 | expand Python variables prepended with $ in all system calls. The |
|
1647 | expand Python variables prepended with $ in all system calls. The | |
1636 | same was done to InteractiveShell.handle_shell_escape. Now all |
|
1648 | same was done to InteractiveShell.handle_shell_escape. Now all | |
1637 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the |
|
1649 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the | |
1638 | expansion of python variables and expressions according to the |
|
1650 | expansion of python variables and expressions according to the | |
1639 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. |
|
1651 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. | |
1640 |
|
1652 | |||
1641 | Though PEP-215 has been rejected, a similar (but simpler) one |
|
1653 | Though PEP-215 has been rejected, a similar (but simpler) one | |
1642 | seems like it will go into Python 2.4, PEP-292 - |
|
1654 | seems like it will go into Python 2.4, PEP-292 - | |
1643 | http://www.python.org/peps/pep-0292.html. |
|
1655 | http://www.python.org/peps/pep-0292.html. | |
1644 |
|
1656 | |||
1645 | I'll keep the full syntax of PEP-215, since IPython has since the |
|
1657 | I'll keep the full syntax of PEP-215, since IPython has since the | |
1646 | start used Ka-Ping Yee's reference implementation discussed there |
|
1658 | start used Ka-Ping Yee's reference implementation discussed there | |
1647 | (Itpl), and I actually like the powerful semantics it offers. |
|
1659 | (Itpl), and I actually like the powerful semantics it offers. | |
1648 |
|
1660 | |||
1649 | In order to access normal shell variables, the $ has to be escaped |
|
1661 | In order to access normal shell variables, the $ has to be escaped | |
1650 | via an extra $. For example: |
|
1662 | via an extra $. For example: | |
1651 |
|
1663 | |||
1652 | In [7]: PATH='a python variable' |
|
1664 | In [7]: PATH='a python variable' | |
1653 |
|
1665 | |||
1654 | In [8]: !echo $PATH |
|
1666 | In [8]: !echo $PATH | |
1655 | a python variable |
|
1667 | a python variable | |
1656 |
|
1668 | |||
1657 | In [9]: !echo $$PATH |
|
1669 | In [9]: !echo $$PATH | |
1658 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
1670 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
1659 |
|
1671 | |||
1660 | (Magic.parse_options): escape $ so the shell doesn't evaluate |
|
1672 | (Magic.parse_options): escape $ so the shell doesn't evaluate | |
1661 | things prematurely. |
|
1673 | things prematurely. | |
1662 |
|
1674 | |||
1663 | * IPython/iplib.py (InteractiveShell.call_alias): added the |
|
1675 | * IPython/iplib.py (InteractiveShell.call_alias): added the | |
1664 | ability for aliases to expand python variables via $. |
|
1676 | ability for aliases to expand python variables via $. | |
1665 |
|
1677 | |||
1666 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias |
|
1678 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias | |
1667 | system, now there's a @rehash/@rehashx pair of magics. These work |
|
1679 | system, now there's a @rehash/@rehashx pair of magics. These work | |
1668 | like the csh rehash command, and can be invoked at any time. They |
|
1680 | like the csh rehash command, and can be invoked at any time. They | |
1669 | build a table of aliases to everything in the user's $PATH |
|
1681 | build a table of aliases to everything in the user's $PATH | |
1670 | (@rehash uses everything, @rehashx is slower but only adds |
|
1682 | (@rehash uses everything, @rehashx is slower but only adds | |
1671 | executable files). With this, the pysh.py-based shell profile can |
|
1683 | executable files). With this, the pysh.py-based shell profile can | |
1672 | now simply call rehash upon startup, and full access to all |
|
1684 | now simply call rehash upon startup, and full access to all | |
1673 | programs in the user's path is obtained. |
|
1685 | programs in the user's path is obtained. | |
1674 |
|
1686 | |||
1675 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias |
|
1687 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias | |
1676 | functionality is now fully in place. I removed the old dynamic |
|
1688 | functionality is now fully in place. I removed the old dynamic | |
1677 | code generation based approach, in favor of a much lighter one |
|
1689 | code generation based approach, in favor of a much lighter one | |
1678 | based on a simple dict. The advantage is that this allows me to |
|
1690 | based on a simple dict. The advantage is that this allows me to | |
1679 | now have thousands of aliases with negligible cost (unthinkable |
|
1691 | now have thousands of aliases with negligible cost (unthinkable | |
1680 | with the old system). |
|
1692 | with the old system). | |
1681 |
|
1693 | |||
1682 | 2004-06-19 Fernando Perez <fperez@colorado.edu> |
|
1694 | 2004-06-19 Fernando Perez <fperez@colorado.edu> | |
1683 |
|
1695 | |||
1684 | * IPython/iplib.py (__init__): extended MagicCompleter class to |
|
1696 | * IPython/iplib.py (__init__): extended MagicCompleter class to | |
1685 | also complete (last in priority) on user aliases. |
|
1697 | also complete (last in priority) on user aliases. | |
1686 |
|
1698 | |||
1687 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in |
|
1699 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in | |
1688 | call to eval. |
|
1700 | call to eval. | |
1689 | (ItplNS.__init__): Added a new class which functions like Itpl, |
|
1701 | (ItplNS.__init__): Added a new class which functions like Itpl, | |
1690 | but allows configuring the namespace for the evaluation to occur |
|
1702 | but allows configuring the namespace for the evaluation to occur | |
1691 | in. |
|
1703 | in. | |
1692 |
|
1704 | |||
1693 | 2004-06-18 Fernando Perez <fperez@colorado.edu> |
|
1705 | 2004-06-18 Fernando Perez <fperez@colorado.edu> | |
1694 |
|
1706 | |||
1695 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a |
|
1707 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a | |
1696 | better message when 'exit' or 'quit' are typed (a common newbie |
|
1708 | better message when 'exit' or 'quit' are typed (a common newbie | |
1697 | confusion). |
|
1709 | confusion). | |
1698 |
|
1710 | |||
1699 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color |
|
1711 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color | |
1700 | check for Windows users. |
|
1712 | check for Windows users. | |
1701 |
|
1713 | |||
1702 | * IPython/iplib.py (InteractiveShell.user_setup): removed |
|
1714 | * IPython/iplib.py (InteractiveShell.user_setup): removed | |
1703 | disabling of colors for Windows. I'll test at runtime and issue a |
|
1715 | disabling of colors for Windows. I'll test at runtime and issue a | |
1704 | warning if Gary's readline isn't found, as to nudge users to |
|
1716 | warning if Gary's readline isn't found, as to nudge users to | |
1705 | download it. |
|
1717 | download it. | |
1706 |
|
1718 | |||
1707 | 2004-06-16 Fernando Perez <fperez@colorado.edu> |
|
1719 | 2004-06-16 Fernando Perez <fperez@colorado.edu> | |
1708 |
|
1720 | |||
1709 | * IPython/genutils.py (Stream.__init__): changed to print errors |
|
1721 | * IPython/genutils.py (Stream.__init__): changed to print errors | |
1710 | to sys.stderr. I had a circular dependency here. Now it's |
|
1722 | to sys.stderr. I had a circular dependency here. Now it's | |
1711 | possible to run ipython as IDLE's shell (consider this pre-alpha, |
|
1723 | possible to run ipython as IDLE's shell (consider this pre-alpha, | |
1712 | since true stdout things end up in the starting terminal instead |
|
1724 | since true stdout things end up in the starting terminal instead | |
1713 | of IDLE's out). |
|
1725 | of IDLE's out). | |
1714 |
|
1726 | |||
1715 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for |
|
1727 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for | |
1716 | users who haven't # updated their prompt_in2 definitions. Remove |
|
1728 | users who haven't # updated their prompt_in2 definitions. Remove | |
1717 | eventually. |
|
1729 | eventually. | |
1718 | (multiple_replace): added credit to original ASPN recipe. |
|
1730 | (multiple_replace): added credit to original ASPN recipe. | |
1719 |
|
1731 | |||
1720 | 2004-06-15 Fernando Perez <fperez@colorado.edu> |
|
1732 | 2004-06-15 Fernando Perez <fperez@colorado.edu> | |
1721 |
|
1733 | |||
1722 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the |
|
1734 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the | |
1723 | list of auto-defined aliases. |
|
1735 | list of auto-defined aliases. | |
1724 |
|
1736 | |||
1725 | 2004-06-13 Fernando Perez <fperez@colorado.edu> |
|
1737 | 2004-06-13 Fernando Perez <fperez@colorado.edu> | |
1726 |
|
1738 | |||
1727 | * setup.py (scriptfiles): Don't trigger win_post_install unless an |
|
1739 | * setup.py (scriptfiles): Don't trigger win_post_install unless an | |
1728 | install was really requested (so setup.py can be used for other |
|
1740 | install was really requested (so setup.py can be used for other | |
1729 | things under Windows). |
|
1741 | things under Windows). | |
1730 |
|
1742 | |||
1731 | 2004-06-10 Fernando Perez <fperez@colorado.edu> |
|
1743 | 2004-06-10 Fernando Perez <fperez@colorado.edu> | |
1732 |
|
1744 | |||
1733 | * IPython/Logger.py (Logger.create_log): Manually remove any old |
|
1745 | * IPython/Logger.py (Logger.create_log): Manually remove any old | |
1734 | backup, since os.remove may fail under Windows. Fixes bug |
|
1746 | backup, since os.remove may fail under Windows. Fixes bug | |
1735 | reported by Thorsten. |
|
1747 | reported by Thorsten. | |
1736 |
|
1748 | |||
1737 | 2004-06-09 Fernando Perez <fperez@colorado.edu> |
|
1749 | 2004-06-09 Fernando Perez <fperez@colorado.edu> | |
1738 |
|
1750 | |||
1739 | * examples/example-embed.py: fixed all references to %n (replaced |
|
1751 | * examples/example-embed.py: fixed all references to %n (replaced | |
1740 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done |
|
1752 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done | |
1741 | for all examples and the manual as well. |
|
1753 | for all examples and the manual as well. | |
1742 |
|
1754 | |||
1743 | 2004-06-08 Fernando Perez <fperez@colorado.edu> |
|
1755 | 2004-06-08 Fernando Perez <fperez@colorado.edu> | |
1744 |
|
1756 | |||
1745 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt |
|
1757 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt | |
1746 | alignment and color management. All 3 prompt subsystems now |
|
1758 | alignment and color management. All 3 prompt subsystems now | |
1747 | inherit from BasePrompt. |
|
1759 | inherit from BasePrompt. | |
1748 |
|
1760 | |||
1749 | * tools/release: updates for windows installer build and tag rpms |
|
1761 | * tools/release: updates for windows installer build and tag rpms | |
1750 | with python version (since paths are fixed). |
|
1762 | with python version (since paths are fixed). | |
1751 |
|
1763 | |||
1752 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, |
|
1764 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, | |
1753 | which will become eventually obsolete. Also fixed the default |
|
1765 | which will become eventually obsolete. Also fixed the default | |
1754 | prompt_in2 to use \D, so at least new users start with the correct |
|
1766 | prompt_in2 to use \D, so at least new users start with the correct | |
1755 | defaults. |
|
1767 | defaults. | |
1756 | WARNING: Users with existing ipythonrc files will need to apply |
|
1768 | WARNING: Users with existing ipythonrc files will need to apply | |
1757 | this fix manually! |
|
1769 | this fix manually! | |
1758 |
|
1770 | |||
1759 | * setup.py: make windows installer (.exe). This is finally the |
|
1771 | * setup.py: make windows installer (.exe). This is finally the | |
1760 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, |
|
1772 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, | |
1761 | which I hadn't included because it required Python 2.3 (or recent |
|
1773 | which I hadn't included because it required Python 2.3 (or recent | |
1762 | distutils). |
|
1774 | distutils). | |
1763 |
|
1775 | |||
1764 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect |
|
1776 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect | |
1765 | usage of new '\D' escape. |
|
1777 | usage of new '\D' escape. | |
1766 |
|
1778 | |||
1767 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which |
|
1779 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which | |
1768 | lacks os.getuid()) |
|
1780 | lacks os.getuid()) | |
1769 | (CachedOutput.set_colors): Added the ability to turn coloring |
|
1781 | (CachedOutput.set_colors): Added the ability to turn coloring | |
1770 | on/off with @colors even for manually defined prompt colors. It |
|
1782 | on/off with @colors even for manually defined prompt colors. It | |
1771 | uses a nasty global, but it works safely and via the generic color |
|
1783 | uses a nasty global, but it works safely and via the generic color | |
1772 | handling mechanism. |
|
1784 | handling mechanism. | |
1773 | (Prompt2.__init__): Introduced new escape '\D' for continuation |
|
1785 | (Prompt2.__init__): Introduced new escape '\D' for continuation | |
1774 | prompts. It represents the counter ('\#') as dots. |
|
1786 | prompts. It represents the counter ('\#') as dots. | |
1775 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will |
|
1787 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will | |
1776 | need to update their ipythonrc files and replace '%n' with '\D' in |
|
1788 | need to update their ipythonrc files and replace '%n' with '\D' in | |
1777 | their prompt_in2 settings everywhere. Sorry, but there's |
|
1789 | their prompt_in2 settings everywhere. Sorry, but there's | |
1778 | otherwise no clean way to get all prompts to properly align. The |
|
1790 | otherwise no clean way to get all prompts to properly align. The | |
1779 | ipythonrc shipped with IPython has been updated. |
|
1791 | ipythonrc shipped with IPython has been updated. | |
1780 |
|
1792 | |||
1781 | 2004-06-07 Fernando Perez <fperez@colorado.edu> |
|
1793 | 2004-06-07 Fernando Perez <fperez@colorado.edu> | |
1782 |
|
1794 | |||
1783 | * setup.py (isfile): Pass local_icons option to latex2html, so the |
|
1795 | * setup.py (isfile): Pass local_icons option to latex2html, so the | |
1784 | resulting HTML file is self-contained. Thanks to |
|
1796 | resulting HTML file is self-contained. Thanks to | |
1785 | dryice-AT-liu.com.cn for the tip. |
|
1797 | dryice-AT-liu.com.cn for the tip. | |
1786 |
|
1798 | |||
1787 | * pysh.py: I created a new profile 'shell', which implements a |
|
1799 | * pysh.py: I created a new profile 'shell', which implements a | |
1788 | _rudimentary_ IPython-based shell. This is in NO WAY a realy |
|
1800 | _rudimentary_ IPython-based shell. This is in NO WAY a realy | |
1789 | system shell, nor will it become one anytime soon. It's mainly |
|
1801 | system shell, nor will it become one anytime soon. It's mainly | |
1790 | meant to illustrate the use of the new flexible bash-like prompts. |
|
1802 | meant to illustrate the use of the new flexible bash-like prompts. | |
1791 | I guess it could be used by hardy souls for true shell management, |
|
1803 | I guess it could be used by hardy souls for true shell management, | |
1792 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' |
|
1804 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' | |
1793 | profile. This uses the InterpreterExec extension provided by |
|
1805 | profile. This uses the InterpreterExec extension provided by | |
1794 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> |
|
1806 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> | |
1795 |
|
1807 | |||
1796 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly |
|
1808 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly | |
1797 | auto-align itself with the length of the previous input prompt |
|
1809 | auto-align itself with the length of the previous input prompt | |
1798 | (taking into account the invisible color escapes). |
|
1810 | (taking into account the invisible color escapes). | |
1799 | (CachedOutput.__init__): Large restructuring of this class. Now |
|
1811 | (CachedOutput.__init__): Large restructuring of this class. Now | |
1800 | all three prompts (primary1, primary2, output) are proper objects, |
|
1812 | all three prompts (primary1, primary2, output) are proper objects, | |
1801 | managed by the 'parent' CachedOutput class. The code is still a |
|
1813 | managed by the 'parent' CachedOutput class. The code is still a | |
1802 | bit hackish (all prompts share state via a pointer to the cache), |
|
1814 | bit hackish (all prompts share state via a pointer to the cache), | |
1803 | but it's overall far cleaner than before. |
|
1815 | but it's overall far cleaner than before. | |
1804 |
|
1816 | |||
1805 | * IPython/genutils.py (getoutputerror): modified to add verbose, |
|
1817 | * IPython/genutils.py (getoutputerror): modified to add verbose, | |
1806 | debug and header options. This makes the interface of all getout* |
|
1818 | debug and header options. This makes the interface of all getout* | |
1807 | functions uniform. |
|
1819 | functions uniform. | |
1808 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. |
|
1820 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. | |
1809 |
|
1821 | |||
1810 | * IPython/Magic.py (Magic.default_option): added a function to |
|
1822 | * IPython/Magic.py (Magic.default_option): added a function to | |
1811 | allow registering default options for any magic command. This |
|
1823 | allow registering default options for any magic command. This | |
1812 | makes it easy to have profiles which customize the magics globally |
|
1824 | makes it easy to have profiles which customize the magics globally | |
1813 | for a certain use. The values set through this function are |
|
1825 | for a certain use. The values set through this function are | |
1814 | picked up by the parse_options() method, which all magics should |
|
1826 | picked up by the parse_options() method, which all magics should | |
1815 | use to parse their options. |
|
1827 | use to parse their options. | |
1816 |
|
1828 | |||
1817 | * IPython/genutils.py (warn): modified the warnings framework to |
|
1829 | * IPython/genutils.py (warn): modified the warnings framework to | |
1818 | use the Term I/O class. I'm trying to slowly unify all of |
|
1830 | use the Term I/O class. I'm trying to slowly unify all of | |
1819 | IPython's I/O operations to pass through Term. |
|
1831 | IPython's I/O operations to pass through Term. | |
1820 |
|
1832 | |||
1821 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in |
|
1833 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in | |
1822 | the secondary prompt to correctly match the length of the primary |
|
1834 | the secondary prompt to correctly match the length of the primary | |
1823 | one for any prompt. Now multi-line code will properly line up |
|
1835 | one for any prompt. Now multi-line code will properly line up | |
1824 | even for path dependent prompts, such as the new ones available |
|
1836 | even for path dependent prompts, such as the new ones available | |
1825 | via the prompt_specials. |
|
1837 | via the prompt_specials. | |
1826 |
|
1838 | |||
1827 | 2004-06-06 Fernando Perez <fperez@colorado.edu> |
|
1839 | 2004-06-06 Fernando Perez <fperez@colorado.edu> | |
1828 |
|
1840 | |||
1829 | * IPython/Prompts.py (prompt_specials): Added the ability to have |
|
1841 | * IPython/Prompts.py (prompt_specials): Added the ability to have | |
1830 | bash-like special sequences in the prompts, which get |
|
1842 | bash-like special sequences in the prompts, which get | |
1831 | automatically expanded. Things like hostname, current working |
|
1843 | automatically expanded. Things like hostname, current working | |
1832 | directory and username are implemented already, but it's easy to |
|
1844 | directory and username are implemented already, but it's easy to | |
1833 | add more in the future. Thanks to a patch by W.J. van der Laan |
|
1845 | add more in the future. Thanks to a patch by W.J. van der Laan | |
1834 | <gnufnork-AT-hetdigitalegat.nl> |
|
1846 | <gnufnork-AT-hetdigitalegat.nl> | |
1835 | (prompt_specials): Added color support for prompt strings, so |
|
1847 | (prompt_specials): Added color support for prompt strings, so | |
1836 | users can define arbitrary color setups for their prompts. |
|
1848 | users can define arbitrary color setups for their prompts. | |
1837 |
|
1849 | |||
1838 | 2004-06-05 Fernando Perez <fperez@colorado.edu> |
|
1850 | 2004-06-05 Fernando Perez <fperez@colorado.edu> | |
1839 |
|
1851 | |||
1840 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific |
|
1852 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific | |
1841 | code to load Gary Bishop's readline and configure it |
|
1853 | code to load Gary Bishop's readline and configure it | |
1842 | automatically. Thanks to Gary for help on this. |
|
1854 | automatically. Thanks to Gary for help on this. | |
1843 |
|
1855 | |||
1844 | 2004-06-01 Fernando Perez <fperez@colorado.edu> |
|
1856 | 2004-06-01 Fernando Perez <fperez@colorado.edu> | |
1845 |
|
1857 | |||
1846 | * IPython/Logger.py (Logger.create_log): fix bug for logging |
|
1858 | * IPython/Logger.py (Logger.create_log): fix bug for logging | |
1847 | with no filename (previous fix was incomplete). |
|
1859 | with no filename (previous fix was incomplete). | |
1848 |
|
1860 | |||
1849 | 2004-05-25 Fernando Perez <fperez@colorado.edu> |
|
1861 | 2004-05-25 Fernando Perez <fperez@colorado.edu> | |
1850 |
|
1862 | |||
1851 | * IPython/Magic.py (Magic.parse_options): fix bug where naked |
|
1863 | * IPython/Magic.py (Magic.parse_options): fix bug where naked | |
1852 | parens would get passed to the shell. |
|
1864 | parens would get passed to the shell. | |
1853 |
|
1865 | |||
1854 | 2004-05-20 Fernando Perez <fperez@colorado.edu> |
|
1866 | 2004-05-20 Fernando Perez <fperez@colorado.edu> | |
1855 |
|
1867 | |||
1856 | * IPython/Magic.py (Magic.magic_prun): changed default profile |
|
1868 | * IPython/Magic.py (Magic.magic_prun): changed default profile | |
1857 | sort order to 'time' (the more common profiling need). |
|
1869 | sort order to 'time' (the more common profiling need). | |
1858 |
|
1870 | |||
1859 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache |
|
1871 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache | |
1860 | so that source code shown is guaranteed in sync with the file on |
|
1872 | so that source code shown is guaranteed in sync with the file on | |
1861 | disk (also changed in psource). Similar fix to the one for |
|
1873 | disk (also changed in psource). Similar fix to the one for | |
1862 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du |
|
1874 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du | |
1863 | <yann.ledu-AT-noos.fr>. |
|
1875 | <yann.ledu-AT-noos.fr>. | |
1864 |
|
1876 | |||
1865 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands |
|
1877 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands | |
1866 | with a single option would not be correctly parsed. Closes |
|
1878 | with a single option would not be correctly parsed. Closes | |
1867 | http://www.scipy.net/roundup/ipython/issue14. This bug had been |
|
1879 | http://www.scipy.net/roundup/ipython/issue14. This bug had been | |
1868 | introduced in 0.6.0 (on 2004-05-06). |
|
1880 | introduced in 0.6.0 (on 2004-05-06). | |
1869 |
|
1881 | |||
1870 | 2004-05-13 *** Released version 0.6.0 |
|
1882 | 2004-05-13 *** Released version 0.6.0 | |
1871 |
|
1883 | |||
1872 | 2004-05-13 Fernando Perez <fperez@colorado.edu> |
|
1884 | 2004-05-13 Fernando Perez <fperez@colorado.edu> | |
1873 |
|
1885 | |||
1874 | * debian/: Added debian/ directory to CVS, so that debian support |
|
1886 | * debian/: Added debian/ directory to CVS, so that debian support | |
1875 | is publicly accessible. The debian package is maintained by Jack |
|
1887 | is publicly accessible. The debian package is maintained by Jack | |
1876 | Moffit <jack-AT-xiph.org>. |
|
1888 | Moffit <jack-AT-xiph.org>. | |
1877 |
|
1889 | |||
1878 | * Documentation: included the notes about an ipython-based system |
|
1890 | * Documentation: included the notes about an ipython-based system | |
1879 | shell (the hypothetical 'pysh') into the new_design.pdf document, |
|
1891 | shell (the hypothetical 'pysh') into the new_design.pdf document, | |
1880 | so that these ideas get distributed to users along with the |
|
1892 | so that these ideas get distributed to users along with the | |
1881 | official documentation. |
|
1893 | official documentation. | |
1882 |
|
1894 | |||
1883 | 2004-05-10 Fernando Perez <fperez@colorado.edu> |
|
1895 | 2004-05-10 Fernando Perez <fperez@colorado.edu> | |
1884 |
|
1896 | |||
1885 | * IPython/Logger.py (Logger.create_log): fix recently introduced |
|
1897 | * IPython/Logger.py (Logger.create_log): fix recently introduced | |
1886 | bug (misindented line) where logstart would fail when not given an |
|
1898 | bug (misindented line) where logstart would fail when not given an | |
1887 | explicit filename. |
|
1899 | explicit filename. | |
1888 |
|
1900 | |||
1889 | 2004-05-09 Fernando Perez <fperez@colorado.edu> |
|
1901 | 2004-05-09 Fernando Perez <fperez@colorado.edu> | |
1890 |
|
1902 | |||
1891 | * IPython/Magic.py (Magic.parse_options): skip system call when |
|
1903 | * IPython/Magic.py (Magic.parse_options): skip system call when | |
1892 | there are no options to look for. Faster, cleaner for the common |
|
1904 | there are no options to look for. Faster, cleaner for the common | |
1893 | case. |
|
1905 | case. | |
1894 |
|
1906 | |||
1895 | * Documentation: many updates to the manual: describing Windows |
|
1907 | * Documentation: many updates to the manual: describing Windows | |
1896 | support better, Gnuplot updates, credits, misc small stuff. Also |
|
1908 | support better, Gnuplot updates, credits, misc small stuff. Also | |
1897 | updated the new_design doc a bit. |
|
1909 | updated the new_design doc a bit. | |
1898 |
|
1910 | |||
1899 | 2004-05-06 *** Released version 0.6.0.rc1 |
|
1911 | 2004-05-06 *** Released version 0.6.0.rc1 | |
1900 |
|
1912 | |||
1901 | 2004-05-06 Fernando Perez <fperez@colorado.edu> |
|
1913 | 2004-05-06 Fernando Perez <fperez@colorado.edu> | |
1902 |
|
1914 | |||
1903 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += |
|
1915 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += | |
1904 | operations to use the vastly more efficient list/''.join() method. |
|
1916 | operations to use the vastly more efficient list/''.join() method. | |
1905 | (FormattedTB.text): Fix |
|
1917 | (FormattedTB.text): Fix | |
1906 | http://www.scipy.net/roundup/ipython/issue12 - exception source |
|
1918 | http://www.scipy.net/roundup/ipython/issue12 - exception source | |
1907 | extract not updated after reload. Thanks to Mike Salib |
|
1919 | extract not updated after reload. Thanks to Mike Salib | |
1908 | <msalib-AT-mit.edu> for pinning the source of the problem. |
|
1920 | <msalib-AT-mit.edu> for pinning the source of the problem. | |
1909 | Fortunately, the solution works inside ipython and doesn't require |
|
1921 | Fortunately, the solution works inside ipython and doesn't require | |
1910 | any changes to python proper. |
|
1922 | any changes to python proper. | |
1911 |
|
1923 | |||
1912 | * IPython/Magic.py (Magic.parse_options): Improved to process the |
|
1924 | * IPython/Magic.py (Magic.parse_options): Improved to process the | |
1913 | argument list as a true shell would (by actually using the |
|
1925 | argument list as a true shell would (by actually using the | |
1914 | underlying system shell). This way, all @magics automatically get |
|
1926 | underlying system shell). This way, all @magics automatically get | |
1915 | shell expansion for variables. Thanks to a comment by Alex |
|
1927 | shell expansion for variables. Thanks to a comment by Alex | |
1916 | Schmolck. |
|
1928 | Schmolck. | |
1917 |
|
1929 | |||
1918 | 2004-04-04 Fernando Perez <fperez@colorado.edu> |
|
1930 | 2004-04-04 Fernando Perez <fperez@colorado.edu> | |
1919 |
|
1931 | |||
1920 | * IPython/iplib.py (InteractiveShell.interact): Added a special |
|
1932 | * IPython/iplib.py (InteractiveShell.interact): Added a special | |
1921 | trap for a debugger quit exception, which is basically impossible |
|
1933 | trap for a debugger quit exception, which is basically impossible | |
1922 | to handle by normal mechanisms, given what pdb does to the stack. |
|
1934 | to handle by normal mechanisms, given what pdb does to the stack. | |
1923 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. |
|
1935 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. | |
1924 |
|
1936 | |||
1925 | 2004-04-03 Fernando Perez <fperez@colorado.edu> |
|
1937 | 2004-04-03 Fernando Perez <fperez@colorado.edu> | |
1926 |
|
1938 | |||
1927 | * IPython/genutils.py (Term): Standardized the names of the Term |
|
1939 | * IPython/genutils.py (Term): Standardized the names of the Term | |
1928 | class streams to cin/cout/cerr, following C++ naming conventions |
|
1940 | class streams to cin/cout/cerr, following C++ naming conventions | |
1929 | (I can't use in/out/err because 'in' is not a valid attribute |
|
1941 | (I can't use in/out/err because 'in' is not a valid attribute | |
1930 | name). |
|
1942 | name). | |
1931 |
|
1943 | |||
1932 | * IPython/iplib.py (InteractiveShell.interact): don't increment |
|
1944 | * IPython/iplib.py (InteractiveShell.interact): don't increment | |
1933 | the prompt if there's no user input. By Daniel 'Dang' Griffith |
|
1945 | the prompt if there's no user input. By Daniel 'Dang' Griffith | |
1934 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from |
|
1946 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from | |
1935 | Francois Pinard. |
|
1947 | Francois Pinard. | |
1936 |
|
1948 | |||
1937 | 2004-04-02 Fernando Perez <fperez@colorado.edu> |
|
1949 | 2004-04-02 Fernando Perez <fperez@colorado.edu> | |
1938 |
|
1950 | |||
1939 | * IPython/genutils.py (Stream.__init__): Modified to survive at |
|
1951 | * IPython/genutils.py (Stream.__init__): Modified to survive at | |
1940 | least importing in contexts where stdin/out/err aren't true file |
|
1952 | least importing in contexts where stdin/out/err aren't true file | |
1941 | objects, such as PyCrust (they lack fileno() and mode). However, |
|
1953 | objects, such as PyCrust (they lack fileno() and mode). However, | |
1942 | the recovery facilities which rely on these things existing will |
|
1954 | the recovery facilities which rely on these things existing will | |
1943 | not work. |
|
1955 | not work. | |
1944 |
|
1956 | |||
1945 | 2004-04-01 Fernando Perez <fperez@colorado.edu> |
|
1957 | 2004-04-01 Fernando Perez <fperez@colorado.edu> | |
1946 |
|
1958 | |||
1947 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to |
|
1959 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to | |
1948 | use the new getoutputerror() function, so it properly |
|
1960 | use the new getoutputerror() function, so it properly | |
1949 | distinguishes stdout/err. |
|
1961 | distinguishes stdout/err. | |
1950 |
|
1962 | |||
1951 | * IPython/genutils.py (getoutputerror): added a function to |
|
1963 | * IPython/genutils.py (getoutputerror): added a function to | |
1952 | capture separately the standard output and error of a command. |
|
1964 | capture separately the standard output and error of a command. | |
1953 | After a comment from dang on the mailing lists. This code is |
|
1965 | After a comment from dang on the mailing lists. This code is | |
1954 | basically a modified version of commands.getstatusoutput(), from |
|
1966 | basically a modified version of commands.getstatusoutput(), from | |
1955 | the standard library. |
|
1967 | the standard library. | |
1956 |
|
1968 | |||
1957 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added |
|
1969 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added | |
1958 | '!!' as a special syntax (shorthand) to access @sx. |
|
1970 | '!!' as a special syntax (shorthand) to access @sx. | |
1959 |
|
1971 | |||
1960 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell |
|
1972 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell | |
1961 | command and return its output as a list split on '\n'. |
|
1973 | command and return its output as a list split on '\n'. | |
1962 |
|
1974 | |||
1963 | 2004-03-31 Fernando Perez <fperez@colorado.edu> |
|
1975 | 2004-03-31 Fernando Perez <fperez@colorado.edu> | |
1964 |
|
1976 | |||
1965 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ |
|
1977 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ | |
1966 | method to dictionaries used as FakeModule instances if they lack |
|
1978 | method to dictionaries used as FakeModule instances if they lack | |
1967 | it. At least pydoc in python2.3 breaks for runtime-defined |
|
1979 | it. At least pydoc in python2.3 breaks for runtime-defined | |
1968 | functions without this hack. At some point I need to _really_ |
|
1980 | functions without this hack. At some point I need to _really_ | |
1969 | understand what FakeModule is doing, because it's a gross hack. |
|
1981 | understand what FakeModule is doing, because it's a gross hack. | |
1970 | But it solves Arnd's problem for now... |
|
1982 | But it solves Arnd's problem for now... | |
1971 |
|
1983 | |||
1972 | 2004-02-27 Fernando Perez <fperez@colorado.edu> |
|
1984 | 2004-02-27 Fernando Perez <fperez@colorado.edu> | |
1973 |
|
1985 | |||
1974 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' |
|
1986 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' | |
1975 | mode would behave erratically. Also increased the number of |
|
1987 | mode would behave erratically. Also increased the number of | |
1976 | possible logs in rotate mod to 999. Thanks to Rod Holland |
|
1988 | possible logs in rotate mod to 999. Thanks to Rod Holland | |
1977 | <rhh@StructureLABS.com> for the report and fixes. |
|
1989 | <rhh@StructureLABS.com> for the report and fixes. | |
1978 |
|
1990 | |||
1979 | 2004-02-26 Fernando Perez <fperez@colorado.edu> |
|
1991 | 2004-02-26 Fernando Perez <fperez@colorado.edu> | |
1980 |
|
1992 | |||
1981 | * IPython/genutils.py (page): Check that the curses module really |
|
1993 | * IPython/genutils.py (page): Check that the curses module really | |
1982 | has the initscr attribute before trying to use it. For some |
|
1994 | has the initscr attribute before trying to use it. For some | |
1983 | reason, the Solaris curses module is missing this. I think this |
|
1995 | reason, the Solaris curses module is missing this. I think this | |
1984 | should be considered a Solaris python bug, but I'm not sure. |
|
1996 | should be considered a Solaris python bug, but I'm not sure. | |
1985 |
|
1997 | |||
1986 | 2004-01-17 Fernando Perez <fperez@colorado.edu> |
|
1998 | 2004-01-17 Fernando Perez <fperez@colorado.edu> | |
1987 |
|
1999 | |||
1988 | * IPython/genutils.py (Stream.__init__): Changes to try to make |
|
2000 | * IPython/genutils.py (Stream.__init__): Changes to try to make | |
1989 | ipython robust against stdin/out/err being closed by the user. |
|
2001 | ipython robust against stdin/out/err being closed by the user. | |
1990 | This is 'user error' (and blocks a normal python session, at least |
|
2002 | This is 'user error' (and blocks a normal python session, at least | |
1991 | the stdout case). However, Ipython should be able to survive such |
|
2003 | the stdout case). However, Ipython should be able to survive such | |
1992 | instances of abuse as gracefully as possible. To simplify the |
|
2004 | instances of abuse as gracefully as possible. To simplify the | |
1993 | coding and maintain compatibility with Gary Bishop's Term |
|
2005 | coding and maintain compatibility with Gary Bishop's Term | |
1994 | contributions, I've made use of classmethods for this. I think |
|
2006 | contributions, I've made use of classmethods for this. I think | |
1995 | this introduces a dependency on python 2.2. |
|
2007 | this introduces a dependency on python 2.2. | |
1996 |
|
2008 | |||
1997 | 2004-01-13 Fernando Perez <fperez@colorado.edu> |
|
2009 | 2004-01-13 Fernando Perez <fperez@colorado.edu> | |
1998 |
|
2010 | |||
1999 | * IPython/numutils.py (exp_safe): simplified the code a bit and |
|
2011 | * IPython/numutils.py (exp_safe): simplified the code a bit and | |
2000 | removed the need for importing the kinds module altogether. |
|
2012 | removed the need for importing the kinds module altogether. | |
2001 |
|
2013 | |||
2002 | 2004-01-06 Fernando Perez <fperez@colorado.edu> |
|
2014 | 2004-01-06 Fernando Perez <fperez@colorado.edu> | |
2003 |
|
2015 | |||
2004 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system |
|
2016 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system | |
2005 | a magic function instead, after some community feedback. No |
|
2017 | a magic function instead, after some community feedback. No | |
2006 | special syntax will exist for it, but its name is deliberately |
|
2018 | special syntax will exist for it, but its name is deliberately | |
2007 | very short. |
|
2019 | very short. | |
2008 |
|
2020 | |||
2009 | 2003-12-20 Fernando Perez <fperez@colorado.edu> |
|
2021 | 2003-12-20 Fernando Perez <fperez@colorado.edu> | |
2010 |
|
2022 | |||
2011 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added |
|
2023 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added | |
2012 | new functionality, to automagically assign the result of a shell |
|
2024 | new functionality, to automagically assign the result of a shell | |
2013 | command to a variable. I'll solicit some community feedback on |
|
2025 | command to a variable. I'll solicit some community feedback on | |
2014 | this before making it permanent. |
|
2026 | this before making it permanent. | |
2015 |
|
2027 | |||
2016 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was |
|
2028 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was | |
2017 | requested about callables for which inspect couldn't obtain a |
|
2029 | requested about callables for which inspect couldn't obtain a | |
2018 | proper argspec. Thanks to a crash report sent by Etienne |
|
2030 | proper argspec. Thanks to a crash report sent by Etienne | |
2019 | Posthumus <etienne-AT-apple01.cs.vu.nl>. |
|
2031 | Posthumus <etienne-AT-apple01.cs.vu.nl>. | |
2020 |
|
2032 | |||
2021 | 2003-12-09 Fernando Perez <fperez@colorado.edu> |
|
2033 | 2003-12-09 Fernando Perez <fperez@colorado.edu> | |
2022 |
|
2034 | |||
2023 | * IPython/genutils.py (page): patch for the pager to work across |
|
2035 | * IPython/genutils.py (page): patch for the pager to work across | |
2024 | various versions of Windows. By Gary Bishop. |
|
2036 | various versions of Windows. By Gary Bishop. | |
2025 |
|
2037 | |||
2026 | 2003-12-04 Fernando Perez <fperez@colorado.edu> |
|
2038 | 2003-12-04 Fernando Perez <fperez@colorado.edu> | |
2027 |
|
2039 | |||
2028 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with |
|
2040 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with | |
2029 | Gnuplot.py version 1.7, whose internal names changed quite a bit. |
|
2041 | Gnuplot.py version 1.7, whose internal names changed quite a bit. | |
2030 | While I tested this and it looks ok, there may still be corner |
|
2042 | While I tested this and it looks ok, there may still be corner | |
2031 | cases I've missed. |
|
2043 | cases I've missed. | |
2032 |
|
2044 | |||
2033 | 2003-12-01 Fernando Perez <fperez@colorado.edu> |
|
2045 | 2003-12-01 Fernando Perez <fperez@colorado.edu> | |
2034 |
|
2046 | |||
2035 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug |
|
2047 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug | |
2036 | where a line like 'p,q=1,2' would fail because the automagic |
|
2048 | where a line like 'p,q=1,2' would fail because the automagic | |
2037 | system would be triggered for @p. |
|
2049 | system would be triggered for @p. | |
2038 |
|
2050 | |||
2039 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related |
|
2051 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related | |
2040 | cleanups, code unmodified. |
|
2052 | cleanups, code unmodified. | |
2041 |
|
2053 | |||
2042 | * IPython/genutils.py (Term): added a class for IPython to handle |
|
2054 | * IPython/genutils.py (Term): added a class for IPython to handle | |
2043 | output. In most cases it will just be a proxy for stdout/err, but |
|
2055 | output. In most cases it will just be a proxy for stdout/err, but | |
2044 | having this allows modifications to be made for some platforms, |
|
2056 | having this allows modifications to be made for some platforms, | |
2045 | such as handling color escapes under Windows. All of this code |
|
2057 | such as handling color escapes under Windows. All of this code | |
2046 | was contributed by Gary Bishop, with minor modifications by me. |
|
2058 | was contributed by Gary Bishop, with minor modifications by me. | |
2047 | The actual changes affect many files. |
|
2059 | The actual changes affect many files. | |
2048 |
|
2060 | |||
2049 | 2003-11-30 Fernando Perez <fperez@colorado.edu> |
|
2061 | 2003-11-30 Fernando Perez <fperez@colorado.edu> | |
2050 |
|
2062 | |||
2051 | * IPython/iplib.py (file_matches): new completion code, courtesy |
|
2063 | * IPython/iplib.py (file_matches): new completion code, courtesy | |
2052 | of Jeff Collins. This enables filename completion again under |
|
2064 | of Jeff Collins. This enables filename completion again under | |
2053 | python 2.3, which disabled it at the C level. |
|
2065 | python 2.3, which disabled it at the C level. | |
2054 |
|
2066 | |||
2055 | 2003-11-11 Fernando Perez <fperez@colorado.edu> |
|
2067 | 2003-11-11 Fernando Perez <fperez@colorado.edu> | |
2056 |
|
2068 | |||
2057 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand |
|
2069 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand | |
2058 | for Numeric.array(map(...)), but often convenient. |
|
2070 | for Numeric.array(map(...)), but often convenient. | |
2059 |
|
2071 | |||
2060 | 2003-11-05 Fernando Perez <fperez@colorado.edu> |
|
2072 | 2003-11-05 Fernando Perez <fperez@colorado.edu> | |
2061 |
|
2073 | |||
2062 | * IPython/numutils.py (frange): Changed a call from int() to |
|
2074 | * IPython/numutils.py (frange): Changed a call from int() to | |
2063 | int(round()) to prevent a problem reported with arange() in the |
|
2075 | int(round()) to prevent a problem reported with arange() in the | |
2064 | numpy list. |
|
2076 | numpy list. | |
2065 |
|
2077 | |||
2066 | 2003-10-06 Fernando Perez <fperez@colorado.edu> |
|
2078 | 2003-10-06 Fernando Perez <fperez@colorado.edu> | |
2067 |
|
2079 | |||
2068 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to |
|
2080 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to | |
2069 | prevent crashes if sys lacks an argv attribute (it happens with |
|
2081 | prevent crashes if sys lacks an argv attribute (it happens with | |
2070 | embedded interpreters which build a bare-bones sys module). |
|
2082 | embedded interpreters which build a bare-bones sys module). | |
2071 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. |
|
2083 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. | |
2072 |
|
2084 | |||
2073 | 2003-09-24 Fernando Perez <fperez@colorado.edu> |
|
2085 | 2003-09-24 Fernando Perez <fperez@colorado.edu> | |
2074 |
|
2086 | |||
2075 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() |
|
2087 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() | |
2076 | to protect against poorly written user objects where __getattr__ |
|
2088 | to protect against poorly written user objects where __getattr__ | |
2077 | raises exceptions other than AttributeError. Thanks to a bug |
|
2089 | raises exceptions other than AttributeError. Thanks to a bug | |
2078 | report by Oliver Sander <osander-AT-gmx.de>. |
|
2090 | report by Oliver Sander <osander-AT-gmx.de>. | |
2079 |
|
2091 | |||
2080 | * IPython/FakeModule.py (FakeModule.__repr__): this method was |
|
2092 | * IPython/FakeModule.py (FakeModule.__repr__): this method was | |
2081 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. |
|
2093 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. | |
2082 |
|
2094 | |||
2083 | 2003-09-09 Fernando Perez <fperez@colorado.edu> |
|
2095 | 2003-09-09 Fernando Perez <fperez@colorado.edu> | |
2084 |
|
2096 | |||
2085 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
2097 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
2086 | unpacking a list whith a callable as first element would |
|
2098 | unpacking a list whith a callable as first element would | |
2087 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery |
|
2099 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery | |
2088 | Collins. |
|
2100 | Collins. | |
2089 |
|
2101 | |||
2090 | 2003-08-25 *** Released version 0.5.0 |
|
2102 | 2003-08-25 *** Released version 0.5.0 | |
2091 |
|
2103 | |||
2092 | 2003-08-22 Fernando Perez <fperez@colorado.edu> |
|
2104 | 2003-08-22 Fernando Perez <fperez@colorado.edu> | |
2093 |
|
2105 | |||
2094 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of |
|
2106 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of | |
2095 | improperly defined user exceptions. Thanks to feedback from Mark |
|
2107 | improperly defined user exceptions. Thanks to feedback from Mark | |
2096 | Russell <mrussell-AT-verio.net>. |
|
2108 | Russell <mrussell-AT-verio.net>. | |
2097 |
|
2109 | |||
2098 | 2003-08-20 Fernando Perez <fperez@colorado.edu> |
|
2110 | 2003-08-20 Fernando Perez <fperez@colorado.edu> | |
2099 |
|
2111 | |||
2100 | * IPython/OInspect.py (Inspector.pinfo): changed String Form |
|
2112 | * IPython/OInspect.py (Inspector.pinfo): changed String Form | |
2101 | printing so that it would print multi-line string forms starting |
|
2113 | printing so that it would print multi-line string forms starting | |
2102 | with a new line. This way the formatting is better respected for |
|
2114 | with a new line. This way the formatting is better respected for | |
2103 | objects which work hard to make nice string forms. |
|
2115 | objects which work hard to make nice string forms. | |
2104 |
|
2116 | |||
2105 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where |
|
2117 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where | |
2106 | autocall would overtake data access for objects with both |
|
2118 | autocall would overtake data access for objects with both | |
2107 | __getitem__ and __call__. |
|
2119 | __getitem__ and __call__. | |
2108 |
|
2120 | |||
2109 | 2003-08-19 *** Released version 0.5.0-rc1 |
|
2121 | 2003-08-19 *** Released version 0.5.0-rc1 | |
2110 |
|
2122 | |||
2111 | 2003-08-19 Fernando Perez <fperez@colorado.edu> |
|
2123 | 2003-08-19 Fernando Perez <fperez@colorado.edu> | |
2112 |
|
2124 | |||
2113 | * IPython/deep_reload.py (load_tail): single tiny change here |
|
2125 | * IPython/deep_reload.py (load_tail): single tiny change here | |
2114 | seems to fix the long-standing bug of dreload() failing to work |
|
2126 | seems to fix the long-standing bug of dreload() failing to work | |
2115 | for dotted names. But this module is pretty tricky, so I may have |
|
2127 | for dotted names. But this module is pretty tricky, so I may have | |
2116 | missed some subtlety. Needs more testing!. |
|
2128 | missed some subtlety. Needs more testing!. | |
2117 |
|
2129 | |||
2118 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user |
|
2130 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user | |
2119 | exceptions which have badly implemented __str__ methods. |
|
2131 | exceptions which have badly implemented __str__ methods. | |
2120 | (VerboseTB.text): harden against inspect.getinnerframes crashing, |
|
2132 | (VerboseTB.text): harden against inspect.getinnerframes crashing, | |
2121 | which I've been getting reports about from Python 2.3 users. I |
|
2133 | which I've been getting reports about from Python 2.3 users. I | |
2122 | wish I had a simple test case to reproduce the problem, so I could |
|
2134 | wish I had a simple test case to reproduce the problem, so I could | |
2123 | either write a cleaner workaround or file a bug report if |
|
2135 | either write a cleaner workaround or file a bug report if | |
2124 | necessary. |
|
2136 | necessary. | |
2125 |
|
2137 | |||
2126 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after |
|
2138 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after | |
2127 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to |
|
2139 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to | |
2128 | a bug report by Tjabo Kloppenburg. |
|
2140 | a bug report by Tjabo Kloppenburg. | |
2129 |
|
2141 | |||
2130 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb |
|
2142 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb | |
2131 | crashes. Wrapped the pdb call in a blanket try/except, since pdb |
|
2143 | crashes. Wrapped the pdb call in a blanket try/except, since pdb | |
2132 | seems rather unstable. Thanks to a bug report by Tjabo |
|
2144 | seems rather unstable. Thanks to a bug report by Tjabo | |
2133 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. |
|
2145 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. | |
2134 |
|
2146 | |||
2135 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put |
|
2147 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put | |
2136 | this out soon because of the critical fixes in the inner loop for |
|
2148 | this out soon because of the critical fixes in the inner loop for | |
2137 | generators. |
|
2149 | generators. | |
2138 |
|
2150 | |||
2139 | * IPython/Magic.py (Magic.getargspec): removed. This (and |
|
2151 | * IPython/Magic.py (Magic.getargspec): removed. This (and | |
2140 | _get_def) have been obsoleted by OInspect for a long time, I |
|
2152 | _get_def) have been obsoleted by OInspect for a long time, I | |
2141 | hadn't noticed that they were dead code. |
|
2153 | hadn't noticed that they were dead code. | |
2142 | (Magic._ofind): restored _ofind functionality for a few literals |
|
2154 | (Magic._ofind): restored _ofind functionality for a few literals | |
2143 | (those in ["''",'""','[]','{}','()']). But it won't work anymore |
|
2155 | (those in ["''",'""','[]','{}','()']). But it won't work anymore | |
2144 | for things like "hello".capitalize?, since that would require a |
|
2156 | for things like "hello".capitalize?, since that would require a | |
2145 | potentially dangerous eval() again. |
|
2157 | potentially dangerous eval() again. | |
2146 |
|
2158 | |||
2147 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the |
|
2159 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the | |
2148 | logic a bit more to clean up the escapes handling and minimize the |
|
2160 | logic a bit more to clean up the escapes handling and minimize the | |
2149 | use of _ofind to only necessary cases. The interactive 'feel' of |
|
2161 | use of _ofind to only necessary cases. The interactive 'feel' of | |
2150 | IPython should have improved quite a bit with the changes in |
|
2162 | IPython should have improved quite a bit with the changes in | |
2151 | _prefilter and _ofind (besides being far safer than before). |
|
2163 | _prefilter and _ofind (besides being far safer than before). | |
2152 |
|
2164 | |||
2153 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather |
|
2165 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather | |
2154 | obscure, never reported). Edit would fail to find the object to |
|
2166 | obscure, never reported). Edit would fail to find the object to | |
2155 | edit under some circumstances. |
|
2167 | edit under some circumstances. | |
2156 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls |
|
2168 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls | |
2157 | which were causing double-calling of generators. Those eval calls |
|
2169 | which were causing double-calling of generators. Those eval calls | |
2158 | were _very_ dangerous, since code with side effects could be |
|
2170 | were _very_ dangerous, since code with side effects could be | |
2159 | triggered. As they say, 'eval is evil'... These were the |
|
2171 | triggered. As they say, 'eval is evil'... These were the | |
2160 | nastiest evals in IPython. Besides, _ofind is now far simpler, |
|
2172 | nastiest evals in IPython. Besides, _ofind is now far simpler, | |
2161 | and it should also be quite a bit faster. Its use of inspect is |
|
2173 | and it should also be quite a bit faster. Its use of inspect is | |
2162 | also safer, so perhaps some of the inspect-related crashes I've |
|
2174 | also safer, so perhaps some of the inspect-related crashes I've | |
2163 | seen lately with Python 2.3 might be taken care of. That will |
|
2175 | seen lately with Python 2.3 might be taken care of. That will | |
2164 | need more testing. |
|
2176 | need more testing. | |
2165 |
|
2177 | |||
2166 | 2003-08-17 Fernando Perez <fperez@colorado.edu> |
|
2178 | 2003-08-17 Fernando Perez <fperez@colorado.edu> | |
2167 |
|
2179 | |||
2168 | * IPython/iplib.py (InteractiveShell._prefilter): significant |
|
2180 | * IPython/iplib.py (InteractiveShell._prefilter): significant | |
2169 | simplifications to the logic for handling user escapes. Faster |
|
2181 | simplifications to the logic for handling user escapes. Faster | |
2170 | and simpler code. |
|
2182 | and simpler code. | |
2171 |
|
2183 | |||
2172 | 2003-08-14 Fernando Perez <fperez@colorado.edu> |
|
2184 | 2003-08-14 Fernando Perez <fperez@colorado.edu> | |
2173 |
|
2185 | |||
2174 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. |
|
2186 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. | |
2175 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, |
|
2187 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, | |
2176 | but it should be quite a bit faster. And the recursive version |
|
2188 | but it should be quite a bit faster. And the recursive version | |
2177 | generated O(log N) intermediate storage for all rank>1 arrays, |
|
2189 | generated O(log N) intermediate storage for all rank>1 arrays, | |
2178 | even if they were contiguous. |
|
2190 | even if they were contiguous. | |
2179 | (l1norm): Added this function. |
|
2191 | (l1norm): Added this function. | |
2180 | (norm): Added this function for arbitrary norms (including |
|
2192 | (norm): Added this function for arbitrary norms (including | |
2181 | l-infinity). l1 and l2 are still special cases for convenience |
|
2193 | l-infinity). l1 and l2 are still special cases for convenience | |
2182 | and speed. |
|
2194 | and speed. | |
2183 |
|
2195 | |||
2184 | 2003-08-03 Fernando Perez <fperez@colorado.edu> |
|
2196 | 2003-08-03 Fernando Perez <fperez@colorado.edu> | |
2185 |
|
2197 | |||
2186 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string |
|
2198 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string | |
2187 | exceptions, which now raise PendingDeprecationWarnings in Python |
|
2199 | exceptions, which now raise PendingDeprecationWarnings in Python | |
2188 | 2.3. There were some in Magic and some in Gnuplot2. |
|
2200 | 2.3. There were some in Magic and some in Gnuplot2. | |
2189 |
|
2201 | |||
2190 | 2003-06-30 Fernando Perez <fperez@colorado.edu> |
|
2202 | 2003-06-30 Fernando Perez <fperez@colorado.edu> | |
2191 |
|
2203 | |||
2192 | * IPython/genutils.py (page): modified to call curses only for |
|
2204 | * IPython/genutils.py (page): modified to call curses only for | |
2193 | terminals where TERM=='xterm'. After problems under many other |
|
2205 | terminals where TERM=='xterm'. After problems under many other | |
2194 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. |
|
2206 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. | |
2195 |
|
2207 | |||
2196 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which |
|
2208 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which | |
2197 | would be triggered when readline was absent. This was just an old |
|
2209 | would be triggered when readline was absent. This was just an old | |
2198 | debugging statement I'd forgotten to take out. |
|
2210 | debugging statement I'd forgotten to take out. | |
2199 |
|
2211 | |||
2200 | 2003-06-20 Fernando Perez <fperez@colorado.edu> |
|
2212 | 2003-06-20 Fernando Perez <fperez@colorado.edu> | |
2201 |
|
2213 | |||
2202 | * IPython/genutils.py (clock): modified to return only user time |
|
2214 | * IPython/genutils.py (clock): modified to return only user time | |
2203 | (not counting system time), after a discussion on scipy. While |
|
2215 | (not counting system time), after a discussion on scipy. While | |
2204 | system time may be a useful quantity occasionally, it may much |
|
2216 | system time may be a useful quantity occasionally, it may much | |
2205 | more easily be skewed by occasional swapping or other similar |
|
2217 | more easily be skewed by occasional swapping or other similar | |
2206 | activity. |
|
2218 | activity. | |
2207 |
|
2219 | |||
2208 | 2003-06-05 Fernando Perez <fperez@colorado.edu> |
|
2220 | 2003-06-05 Fernando Perez <fperez@colorado.edu> | |
2209 |
|
2221 | |||
2210 | * IPython/numutils.py (identity): new function, for building |
|
2222 | * IPython/numutils.py (identity): new function, for building | |
2211 | arbitrary rank Kronecker deltas (mostly backwards compatible with |
|
2223 | arbitrary rank Kronecker deltas (mostly backwards compatible with | |
2212 | Numeric.identity) |
|
2224 | Numeric.identity) | |
2213 |
|
2225 | |||
2214 | 2003-06-03 Fernando Perez <fperez@colorado.edu> |
|
2226 | 2003-06-03 Fernando Perez <fperez@colorado.edu> | |
2215 |
|
2227 | |||
2216 | * IPython/iplib.py (InteractiveShell.handle_magic): protect |
|
2228 | * IPython/iplib.py (InteractiveShell.handle_magic): protect | |
2217 | arguments passed to magics with spaces, to allow trailing '\' to |
|
2229 | arguments passed to magics with spaces, to allow trailing '\' to | |
2218 | work normally (mainly for Windows users). |
|
2230 | work normally (mainly for Windows users). | |
2219 |
|
2231 | |||
2220 | 2003-05-29 Fernando Perez <fperez@colorado.edu> |
|
2232 | 2003-05-29 Fernando Perez <fperez@colorado.edu> | |
2221 |
|
2233 | |||
2222 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help |
|
2234 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help | |
2223 | instead of pydoc.help. This fixes a bizarre behavior where |
|
2235 | instead of pydoc.help. This fixes a bizarre behavior where | |
2224 | printing '%s' % locals() would trigger the help system. Now |
|
2236 | printing '%s' % locals() would trigger the help system. Now | |
2225 | ipython behaves like normal python does. |
|
2237 | ipython behaves like normal python does. | |
2226 |
|
2238 | |||
2227 | Note that if one does 'from pydoc import help', the bizarre |
|
2239 | Note that if one does 'from pydoc import help', the bizarre | |
2228 | behavior returns, but this will also happen in normal python, so |
|
2240 | behavior returns, but this will also happen in normal python, so | |
2229 | it's not an ipython bug anymore (it has to do with how pydoc.help |
|
2241 | it's not an ipython bug anymore (it has to do with how pydoc.help | |
2230 | is implemented). |
|
2242 | is implemented). | |
2231 |
|
2243 | |||
2232 | 2003-05-22 Fernando Perez <fperez@colorado.edu> |
|
2244 | 2003-05-22 Fernando Perez <fperez@colorado.edu> | |
2233 |
|
2245 | |||
2234 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to |
|
2246 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to | |
2235 | return [] instead of None when nothing matches, also match to end |
|
2247 | return [] instead of None when nothing matches, also match to end | |
2236 | of line. Patch by Gary Bishop. |
|
2248 | of line. Patch by Gary Bishop. | |
2237 |
|
2249 | |||
2238 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook |
|
2250 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook | |
2239 | protection as before, for files passed on the command line. This |
|
2251 | protection as before, for files passed on the command line. This | |
2240 | prevents the CrashHandler from kicking in if user files call into |
|
2252 | prevents the CrashHandler from kicking in if user files call into | |
2241 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of |
|
2253 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of | |
2242 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> |
|
2254 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> | |
2243 |
|
2255 | |||
2244 | 2003-05-20 *** Released version 0.4.0 |
|
2256 | 2003-05-20 *** Released version 0.4.0 | |
2245 |
|
2257 | |||
2246 | 2003-05-20 Fernando Perez <fperez@colorado.edu> |
|
2258 | 2003-05-20 Fernando Perez <fperez@colorado.edu> | |
2247 |
|
2259 | |||
2248 | * setup.py: added support for manpages. It's a bit hackish b/c of |
|
2260 | * setup.py: added support for manpages. It's a bit hackish b/c of | |
2249 | a bug in the way the bdist_rpm distutils target handles gzipped |
|
2261 | a bug in the way the bdist_rpm distutils target handles gzipped | |
2250 | manpages, but it works. After a patch by Jack. |
|
2262 | manpages, but it works. After a patch by Jack. | |
2251 |
|
2263 | |||
2252 | 2003-05-19 Fernando Perez <fperez@colorado.edu> |
|
2264 | 2003-05-19 Fernando Perez <fperez@colorado.edu> | |
2253 |
|
2265 | |||
2254 | * IPython/numutils.py: added a mockup of the kinds module, since |
|
2266 | * IPython/numutils.py: added a mockup of the kinds module, since | |
2255 | it was recently removed from Numeric. This way, numutils will |
|
2267 | it was recently removed from Numeric. This way, numutils will | |
2256 | work for all users even if they are missing kinds. |
|
2268 | work for all users even if they are missing kinds. | |
2257 |
|
2269 | |||
2258 | * IPython/Magic.py (Magic._ofind): Harden against an inspect |
|
2270 | * IPython/Magic.py (Magic._ofind): Harden against an inspect | |
2259 | failure, which can occur with SWIG-wrapped extensions. After a |
|
2271 | failure, which can occur with SWIG-wrapped extensions. After a | |
2260 | crash report from Prabhu. |
|
2272 | crash report from Prabhu. | |
2261 |
|
2273 | |||
2262 | 2003-05-16 Fernando Perez <fperez@colorado.edu> |
|
2274 | 2003-05-16 Fernando Perez <fperez@colorado.edu> | |
2263 |
|
2275 | |||
2264 | * IPython/iplib.py (InteractiveShell.excepthook): New method to |
|
2276 | * IPython/iplib.py (InteractiveShell.excepthook): New method to | |
2265 | protect ipython from user code which may call directly |
|
2277 | protect ipython from user code which may call directly | |
2266 | sys.excepthook (this looks like an ipython crash to the user, even |
|
2278 | sys.excepthook (this looks like an ipython crash to the user, even | |
2267 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2279 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2268 | This is especially important to help users of WxWindows, but may |
|
2280 | This is especially important to help users of WxWindows, but may | |
2269 | also be useful in other cases. |
|
2281 | also be useful in other cases. | |
2270 |
|
2282 | |||
2271 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow |
|
2283 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow | |
2272 | an optional tb_offset to be specified, and to preserve exception |
|
2284 | an optional tb_offset to be specified, and to preserve exception | |
2273 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2285 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2274 |
|
2286 | |||
2275 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! |
|
2287 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! | |
2276 |
|
2288 | |||
2277 | 2003-05-15 Fernando Perez <fperez@colorado.edu> |
|
2289 | 2003-05-15 Fernando Perez <fperez@colorado.edu> | |
2278 |
|
2290 | |||
2279 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when |
|
2291 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when | |
2280 | installing for a new user under Windows. |
|
2292 | installing for a new user under Windows. | |
2281 |
|
2293 | |||
2282 | 2003-05-12 Fernando Perez <fperez@colorado.edu> |
|
2294 | 2003-05-12 Fernando Perez <fperez@colorado.edu> | |
2283 |
|
2295 | |||
2284 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line |
|
2296 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line | |
2285 | handler for Emacs comint-based lines. Currently it doesn't do |
|
2297 | handler for Emacs comint-based lines. Currently it doesn't do | |
2286 | much (but importantly, it doesn't update the history cache). In |
|
2298 | much (but importantly, it doesn't update the history cache). In | |
2287 | the future it may be expanded if Alex needs more functionality |
|
2299 | the future it may be expanded if Alex needs more functionality | |
2288 | there. |
|
2300 | there. | |
2289 |
|
2301 | |||
2290 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform |
|
2302 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform | |
2291 | info to crash reports. |
|
2303 | info to crash reports. | |
2292 |
|
2304 | |||
2293 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, |
|
2305 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, | |
2294 | just like Python's -c. Also fixed crash with invalid -color |
|
2306 | just like Python's -c. Also fixed crash with invalid -color | |
2295 | option value at startup. Thanks to Will French |
|
2307 | option value at startup. Thanks to Will French | |
2296 | <wfrench-AT-bestweb.net> for the bug report. |
|
2308 | <wfrench-AT-bestweb.net> for the bug report. | |
2297 |
|
2309 | |||
2298 | 2003-05-09 Fernando Perez <fperez@colorado.edu> |
|
2310 | 2003-05-09 Fernando Perez <fperez@colorado.edu> | |
2299 |
|
2311 | |||
2300 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString |
|
2312 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString | |
2301 | to EvalDict (it's a mapping, after all) and simplified its code |
|
2313 | to EvalDict (it's a mapping, after all) and simplified its code | |
2302 | quite a bit, after a nice discussion on c.l.py where Gustavo |
|
2314 | quite a bit, after a nice discussion on c.l.py where Gustavo | |
2303 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. |
|
2315 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. | |
2304 |
|
2316 | |||
2305 | 2003-04-30 Fernando Perez <fperez@colorado.edu> |
|
2317 | 2003-04-30 Fernando Perez <fperez@colorado.edu> | |
2306 |
|
2318 | |||
2307 | * IPython/genutils.py (timings_out): modified it to reduce its |
|
2319 | * IPython/genutils.py (timings_out): modified it to reduce its | |
2308 | overhead in the common reps==1 case. |
|
2320 | overhead in the common reps==1 case. | |
2309 |
|
2321 | |||
2310 | 2003-04-29 Fernando Perez <fperez@colorado.edu> |
|
2322 | 2003-04-29 Fernando Perez <fperez@colorado.edu> | |
2311 |
|
2323 | |||
2312 | * IPython/genutils.py (timings_out): Modified to use the resource |
|
2324 | * IPython/genutils.py (timings_out): Modified to use the resource | |
2313 | module, which avoids the wraparound problems of time.clock(). |
|
2325 | module, which avoids the wraparound problems of time.clock(). | |
2314 |
|
2326 | |||
2315 | 2003-04-17 *** Released version 0.2.15pre4 |
|
2327 | 2003-04-17 *** Released version 0.2.15pre4 | |
2316 |
|
2328 | |||
2317 | 2003-04-17 Fernando Perez <fperez@colorado.edu> |
|
2329 | 2003-04-17 Fernando Perez <fperez@colorado.edu> | |
2318 |
|
2330 | |||
2319 | * setup.py (scriptfiles): Split windows-specific stuff over to a |
|
2331 | * setup.py (scriptfiles): Split windows-specific stuff over to a | |
2320 | separate file, in an attempt to have a Windows GUI installer. |
|
2332 | separate file, in an attempt to have a Windows GUI installer. | |
2321 | That didn't work, but part of the groundwork is done. |
|
2333 | That didn't work, but part of the groundwork is done. | |
2322 |
|
2334 | |||
2323 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for |
|
2335 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for | |
2324 | indent/unindent with 4 spaces. Particularly useful in combination |
|
2336 | indent/unindent with 4 spaces. Particularly useful in combination | |
2325 | with the new auto-indent option. |
|
2337 | with the new auto-indent option. | |
2326 |
|
2338 | |||
2327 | 2003-04-16 Fernando Perez <fperez@colorado.edu> |
|
2339 | 2003-04-16 Fernando Perez <fperez@colorado.edu> | |
2328 |
|
2340 | |||
2329 | * IPython/Magic.py: various replacements of self.rc for |
|
2341 | * IPython/Magic.py: various replacements of self.rc for | |
2330 | self.shell.rc. A lot more remains to be done to fully disentangle |
|
2342 | self.shell.rc. A lot more remains to be done to fully disentangle | |
2331 | this class from the main Shell class. |
|
2343 | this class from the main Shell class. | |
2332 |
|
2344 | |||
2333 | * IPython/GnuplotRuntime.py: added checks for mouse support so |
|
2345 | * IPython/GnuplotRuntime.py: added checks for mouse support so | |
2334 | that we don't try to enable it if the current gnuplot doesn't |
|
2346 | that we don't try to enable it if the current gnuplot doesn't | |
2335 | really support it. Also added checks so that we don't try to |
|
2347 | really support it. Also added checks so that we don't try to | |
2336 | enable persist under Windows (where Gnuplot doesn't recognize the |
|
2348 | enable persist under Windows (where Gnuplot doesn't recognize the | |
2337 | option). |
|
2349 | option). | |
2338 |
|
2350 | |||
2339 | * IPython/iplib.py (InteractiveShell.interact): Added optional |
|
2351 | * IPython/iplib.py (InteractiveShell.interact): Added optional | |
2340 | auto-indenting code, after a patch by King C. Shu |
|
2352 | auto-indenting code, after a patch by King C. Shu | |
2341 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't |
|
2353 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't | |
2342 | get along well with pasting indented code. If I ever figure out |
|
2354 | get along well with pasting indented code. If I ever figure out | |
2343 | how to make that part go well, it will become on by default. |
|
2355 | how to make that part go well, it will become on by default. | |
2344 |
|
2356 | |||
2345 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would |
|
2357 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would | |
2346 | crash ipython if there was an unmatched '%' in the user's prompt |
|
2358 | crash ipython if there was an unmatched '%' in the user's prompt | |
2347 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2359 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2348 |
|
2360 | |||
2349 | * IPython/iplib.py (InteractiveShell.interact): removed the |
|
2361 | * IPython/iplib.py (InteractiveShell.interact): removed the | |
2350 | ability to ask the user whether he wants to crash or not at the |
|
2362 | ability to ask the user whether he wants to crash or not at the | |
2351 | 'last line' exception handler. Calling functions at that point |
|
2363 | 'last line' exception handler. Calling functions at that point | |
2352 | changes the stack, and the error reports would have incorrect |
|
2364 | changes the stack, and the error reports would have incorrect | |
2353 | tracebacks. |
|
2365 | tracebacks. | |
2354 |
|
2366 | |||
2355 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to |
|
2367 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to | |
2356 | pass through a peger a pretty-printed form of any object. After a |
|
2368 | pass through a peger a pretty-printed form of any object. After a | |
2357 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> |
|
2369 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> | |
2358 |
|
2370 | |||
2359 | 2003-04-14 Fernando Perez <fperez@colorado.edu> |
|
2371 | 2003-04-14 Fernando Perez <fperez@colorado.edu> | |
2360 |
|
2372 | |||
2361 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where |
|
2373 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where | |
2362 | all files in ~ would be modified at first install (instead of |
|
2374 | all files in ~ would be modified at first install (instead of | |
2363 | ~/.ipython). This could be potentially disastrous, as the |
|
2375 | ~/.ipython). This could be potentially disastrous, as the | |
2364 | modification (make line-endings native) could damage binary files. |
|
2376 | modification (make line-endings native) could damage binary files. | |
2365 |
|
2377 | |||
2366 | 2003-04-10 Fernando Perez <fperez@colorado.edu> |
|
2378 | 2003-04-10 Fernando Perez <fperez@colorado.edu> | |
2367 |
|
2379 | |||
2368 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to |
|
2380 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to | |
2369 | handle only lines which are invalid python. This now means that |
|
2381 | handle only lines which are invalid python. This now means that | |
2370 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins |
|
2382 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins | |
2371 | for the bug report. |
|
2383 | for the bug report. | |
2372 |
|
2384 | |||
2373 | 2003-04-01 Fernando Perez <fperez@colorado.edu> |
|
2385 | 2003-04-01 Fernando Perez <fperez@colorado.edu> | |
2374 |
|
2386 | |||
2375 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug |
|
2387 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug | |
2376 | where failing to set sys.last_traceback would crash pdb.pm(). |
|
2388 | where failing to set sys.last_traceback would crash pdb.pm(). | |
2377 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug |
|
2389 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug | |
2378 | report. |
|
2390 | report. | |
2379 |
|
2391 | |||
2380 | 2003-03-25 Fernando Perez <fperez@colorado.edu> |
|
2392 | 2003-03-25 Fernando Perez <fperez@colorado.edu> | |
2381 |
|
2393 | |||
2382 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler |
|
2394 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler | |
2383 | before printing it (it had a lot of spurious blank lines at the |
|
2395 | before printing it (it had a lot of spurious blank lines at the | |
2384 | end). |
|
2396 | end). | |
2385 |
|
2397 | |||
2386 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr |
|
2398 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr | |
2387 | output would be sent 21 times! Obviously people don't use this |
|
2399 | output would be sent 21 times! Obviously people don't use this | |
2388 | too often, or I would have heard about it. |
|
2400 | too often, or I would have heard about it. | |
2389 |
|
2401 | |||
2390 | 2003-03-24 Fernando Perez <fperez@colorado.edu> |
|
2402 | 2003-03-24 Fernando Perez <fperez@colorado.edu> | |
2391 |
|
2403 | |||
2392 | * setup.py (scriptfiles): renamed the data_files parameter from |
|
2404 | * setup.py (scriptfiles): renamed the data_files parameter from | |
2393 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink |
|
2405 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink | |
2394 | for the patch. |
|
2406 | for the patch. | |
2395 |
|
2407 | |||
2396 | 2003-03-20 Fernando Perez <fperez@colorado.edu> |
|
2408 | 2003-03-20 Fernando Perez <fperez@colorado.edu> | |
2397 |
|
2409 | |||
2398 | * IPython/genutils.py (error): added error() and fatal() |
|
2410 | * IPython/genutils.py (error): added error() and fatal() | |
2399 | functions. |
|
2411 | functions. | |
2400 |
|
2412 | |||
2401 | 2003-03-18 *** Released version 0.2.15pre3 |
|
2413 | 2003-03-18 *** Released version 0.2.15pre3 | |
2402 |
|
2414 | |||
2403 | 2003-03-18 Fernando Perez <fperez@colorado.edu> |
|
2415 | 2003-03-18 Fernando Perez <fperez@colorado.edu> | |
2404 |
|
2416 | |||
2405 | * setupext/install_data_ext.py |
|
2417 | * setupext/install_data_ext.py | |
2406 | (install_data_ext.initialize_options): Class contributed by Jack |
|
2418 | (install_data_ext.initialize_options): Class contributed by Jack | |
2407 | Moffit for fixing the old distutils hack. He is sending this to |
|
2419 | Moffit for fixing the old distutils hack. He is sending this to | |
2408 | the distutils folks so in the future we may not need it as a |
|
2420 | the distutils folks so in the future we may not need it as a | |
2409 | private fix. |
|
2421 | private fix. | |
2410 |
|
2422 | |||
2411 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's |
|
2423 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's | |
2412 | changes for Debian packaging. See his patch for full details. |
|
2424 | changes for Debian packaging. See his patch for full details. | |
2413 | The old distutils hack of making the ipythonrc* files carry a |
|
2425 | The old distutils hack of making the ipythonrc* files carry a | |
2414 | bogus .py extension is gone, at last. Examples were moved to a |
|
2426 | bogus .py extension is gone, at last. Examples were moved to a | |
2415 | separate subdir under doc/, and the separate executable scripts |
|
2427 | separate subdir under doc/, and the separate executable scripts | |
2416 | now live in their own directory. Overall a great cleanup. The |
|
2428 | now live in their own directory. Overall a great cleanup. The | |
2417 | manual was updated to use the new files, and setup.py has been |
|
2429 | manual was updated to use the new files, and setup.py has been | |
2418 | fixed for this setup. |
|
2430 | fixed for this setup. | |
2419 |
|
2431 | |||
2420 | * IPython/PyColorize.py (Parser.usage): made non-executable and |
|
2432 | * IPython/PyColorize.py (Parser.usage): made non-executable and | |
2421 | created a pycolor wrapper around it to be included as a script. |
|
2433 | created a pycolor wrapper around it to be included as a script. | |
2422 |
|
2434 | |||
2423 | 2003-03-12 *** Released version 0.2.15pre2 |
|
2435 | 2003-03-12 *** Released version 0.2.15pre2 | |
2424 |
|
2436 | |||
2425 | 2003-03-12 Fernando Perez <fperez@colorado.edu> |
|
2437 | 2003-03-12 Fernando Perez <fperez@colorado.edu> | |
2426 |
|
2438 | |||
2427 | * IPython/ColorANSI.py (make_color_table): Finally fixed the |
|
2439 | * IPython/ColorANSI.py (make_color_table): Finally fixed the | |
2428 | long-standing problem with garbage characters in some terminals. |
|
2440 | long-standing problem with garbage characters in some terminals. | |
2429 | The issue was really that the \001 and \002 escapes must _only_ be |
|
2441 | The issue was really that the \001 and \002 escapes must _only_ be | |
2430 | passed to input prompts (which call readline), but _never_ to |
|
2442 | passed to input prompts (which call readline), but _never_ to | |
2431 | normal text to be printed on screen. I changed ColorANSI to have |
|
2443 | normal text to be printed on screen. I changed ColorANSI to have | |
2432 | two classes: TermColors and InputTermColors, each with the |
|
2444 | two classes: TermColors and InputTermColors, each with the | |
2433 | appropriate escapes for input prompts or normal text. The code in |
|
2445 | appropriate escapes for input prompts or normal text. The code in | |
2434 | Prompts.py got slightly more complicated, but this very old and |
|
2446 | Prompts.py got slightly more complicated, but this very old and | |
2435 | annoying bug is finally fixed. |
|
2447 | annoying bug is finally fixed. | |
2436 |
|
2448 | |||
2437 | All the credit for nailing down the real origin of this problem |
|
2449 | All the credit for nailing down the real origin of this problem | |
2438 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. |
|
2450 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. | |
2439 | *Many* thanks to him for spending quite a bit of effort on this. |
|
2451 | *Many* thanks to him for spending quite a bit of effort on this. | |
2440 |
|
2452 | |||
2441 | 2003-03-05 *** Released version 0.2.15pre1 |
|
2453 | 2003-03-05 *** Released version 0.2.15pre1 | |
2442 |
|
2454 | |||
2443 | 2003-03-03 Fernando Perez <fperez@colorado.edu> |
|
2455 | 2003-03-03 Fernando Perez <fperez@colorado.edu> | |
2444 |
|
2456 | |||
2445 | * IPython/FakeModule.py: Moved the former _FakeModule to a |
|
2457 | * IPython/FakeModule.py: Moved the former _FakeModule to a | |
2446 | separate file, because it's also needed by Magic (to fix a similar |
|
2458 | separate file, because it's also needed by Magic (to fix a similar | |
2447 | pickle-related issue in @run). |
|
2459 | pickle-related issue in @run). | |
2448 |
|
2460 | |||
2449 | 2003-03-02 Fernando Perez <fperez@colorado.edu> |
|
2461 | 2003-03-02 Fernando Perez <fperez@colorado.edu> | |
2450 |
|
2462 | |||
2451 | * IPython/Magic.py (Magic.magic_autocall): new magic to control |
|
2463 | * IPython/Magic.py (Magic.magic_autocall): new magic to control | |
2452 | the autocall option at runtime. |
|
2464 | the autocall option at runtime. | |
2453 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns |
|
2465 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns | |
2454 | across Magic.py to start separating Magic from InteractiveShell. |
|
2466 | across Magic.py to start separating Magic from InteractiveShell. | |
2455 | (Magic._ofind): Fixed to return proper namespace for dotted |
|
2467 | (Magic._ofind): Fixed to return proper namespace for dotted | |
2456 | names. Before, a dotted name would always return 'not currently |
|
2468 | names. Before, a dotted name would always return 'not currently | |
2457 | defined', because it would find the 'parent'. s.x would be found, |
|
2469 | defined', because it would find the 'parent'. s.x would be found, | |
2458 | but since 'x' isn't defined by itself, it would get confused. |
|
2470 | but since 'x' isn't defined by itself, it would get confused. | |
2459 | (Magic.magic_run): Fixed pickling problems reported by Ralf |
|
2471 | (Magic.magic_run): Fixed pickling problems reported by Ralf | |
2460 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to |
|
2472 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to | |
2461 | that I'd used when Mike Heeter reported similar issues at the |
|
2473 | that I'd used when Mike Heeter reported similar issues at the | |
2462 | top-level, but now for @run. It boils down to injecting the |
|
2474 | top-level, but now for @run. It boils down to injecting the | |
2463 | namespace where code is being executed with something that looks |
|
2475 | namespace where code is being executed with something that looks | |
2464 | enough like a module to fool pickle.dump(). Since a pickle stores |
|
2476 | enough like a module to fool pickle.dump(). Since a pickle stores | |
2465 | a named reference to the importing module, we need this for |
|
2477 | a named reference to the importing module, we need this for | |
2466 | pickles to save something sensible. |
|
2478 | pickles to save something sensible. | |
2467 |
|
2479 | |||
2468 | * IPython/ipmaker.py (make_IPython): added an autocall option. |
|
2480 | * IPython/ipmaker.py (make_IPython): added an autocall option. | |
2469 |
|
2481 | |||
2470 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of |
|
2482 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of | |
2471 | the auto-eval code. Now autocalling is an option, and the code is |
|
2483 | the auto-eval code. Now autocalling is an option, and the code is | |
2472 | also vastly safer. There is no more eval() involved at all. |
|
2484 | also vastly safer. There is no more eval() involved at all. | |
2473 |
|
2485 | |||
2474 | 2003-03-01 Fernando Perez <fperez@colorado.edu> |
|
2486 | 2003-03-01 Fernando Perez <fperez@colorado.edu> | |
2475 |
|
2487 | |||
2476 | * IPython/Magic.py (Magic._ofind): Changed interface to return a |
|
2488 | * IPython/Magic.py (Magic._ofind): Changed interface to return a | |
2477 | dict with named keys instead of a tuple. |
|
2489 | dict with named keys instead of a tuple. | |
2478 |
|
2490 | |||
2479 | * IPython: Started using CVS for IPython as of 0.2.15pre1. |
|
2491 | * IPython: Started using CVS for IPython as of 0.2.15pre1. | |
2480 |
|
2492 | |||
2481 | * setup.py (make_shortcut): Fixed message about directories |
|
2493 | * setup.py (make_shortcut): Fixed message about directories | |
2482 | created during Windows installation (the directories were ok, just |
|
2494 | created during Windows installation (the directories were ok, just | |
2483 | the printed message was misleading). Thanks to Chris Liechti |
|
2495 | the printed message was misleading). Thanks to Chris Liechti | |
2484 | <cliechti-AT-gmx.net> for the heads up. |
|
2496 | <cliechti-AT-gmx.net> for the heads up. | |
2485 |
|
2497 | |||
2486 | 2003-02-21 Fernando Perez <fperez@colorado.edu> |
|
2498 | 2003-02-21 Fernando Perez <fperez@colorado.edu> | |
2487 |
|
2499 | |||
2488 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching |
|
2500 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching | |
2489 | of ValueError exception when checking for auto-execution. This |
|
2501 | of ValueError exception when checking for auto-execution. This | |
2490 | one is raised by things like Numeric arrays arr.flat when the |
|
2502 | one is raised by things like Numeric arrays arr.flat when the | |
2491 | array is non-contiguous. |
|
2503 | array is non-contiguous. | |
2492 |
|
2504 | |||
2493 | 2003-01-31 Fernando Perez <fperez@colorado.edu> |
|
2505 | 2003-01-31 Fernando Perez <fperez@colorado.edu> | |
2494 |
|
2506 | |||
2495 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would |
|
2507 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would | |
2496 | not return any value at all (even though the command would get |
|
2508 | not return any value at all (even though the command would get | |
2497 | executed). |
|
2509 | executed). | |
2498 | (xsys): Flush stdout right after printing the command to ensure |
|
2510 | (xsys): Flush stdout right after printing the command to ensure | |
2499 | proper ordering of commands and command output in the total |
|
2511 | proper ordering of commands and command output in the total | |
2500 | output. |
|
2512 | output. | |
2501 | (SystemExec/xsys/bq): Switched the names of xsys/bq and |
|
2513 | (SystemExec/xsys/bq): Switched the names of xsys/bq and | |
2502 | system/getoutput as defaults. The old ones are kept for |
|
2514 | system/getoutput as defaults. The old ones are kept for | |
2503 | compatibility reasons, so no code which uses this library needs |
|
2515 | compatibility reasons, so no code which uses this library needs | |
2504 | changing. |
|
2516 | changing. | |
2505 |
|
2517 | |||
2506 | 2003-01-27 *** Released version 0.2.14 |
|
2518 | 2003-01-27 *** Released version 0.2.14 | |
2507 |
|
2519 | |||
2508 | 2003-01-25 Fernando Perez <fperez@colorado.edu> |
|
2520 | 2003-01-25 Fernando Perez <fperez@colorado.edu> | |
2509 |
|
2521 | |||
2510 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where |
|
2522 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where | |
2511 | functions defined in previous edit sessions could not be re-edited |
|
2523 | functions defined in previous edit sessions could not be re-edited | |
2512 | (because the temp files were immediately removed). Now temp files |
|
2524 | (because the temp files were immediately removed). Now temp files | |
2513 | are removed only at IPython's exit. |
|
2525 | are removed only at IPython's exit. | |
2514 | (Magic.magic_run): Improved @run to perform shell-like expansions |
|
2526 | (Magic.magic_run): Improved @run to perform shell-like expansions | |
2515 | on its arguments (~users and $VARS). With this, @run becomes more |
|
2527 | on its arguments (~users and $VARS). With this, @run becomes more | |
2516 | like a normal command-line. |
|
2528 | like a normal command-line. | |
2517 |
|
2529 | |||
2518 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small |
|
2530 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small | |
2519 | bugs related to embedding and cleaned up that code. A fairly |
|
2531 | bugs related to embedding and cleaned up that code. A fairly | |
2520 | important one was the impossibility to access the global namespace |
|
2532 | important one was the impossibility to access the global namespace | |
2521 | through the embedded IPython (only local variables were visible). |
|
2533 | through the embedded IPython (only local variables were visible). | |
2522 |
|
2534 | |||
2523 | 2003-01-14 Fernando Perez <fperez@colorado.edu> |
|
2535 | 2003-01-14 Fernando Perez <fperez@colorado.edu> | |
2524 |
|
2536 | |||
2525 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed |
|
2537 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed | |
2526 | auto-calling to be a bit more conservative. Now it doesn't get |
|
2538 | auto-calling to be a bit more conservative. Now it doesn't get | |
2527 | triggered if any of '!=()<>' are in the rest of the input line, to |
|
2539 | triggered if any of '!=()<>' are in the rest of the input line, to | |
2528 | allow comparing callables. Thanks to Alex for the heads up. |
|
2540 | allow comparing callables. Thanks to Alex for the heads up. | |
2529 |
|
2541 | |||
2530 | 2003-01-07 Fernando Perez <fperez@colorado.edu> |
|
2542 | 2003-01-07 Fernando Perez <fperez@colorado.edu> | |
2531 |
|
2543 | |||
2532 | * IPython/genutils.py (page): fixed estimation of the number of |
|
2544 | * IPython/genutils.py (page): fixed estimation of the number of | |
2533 | lines in a string to be paged to simply count newlines. This |
|
2545 | lines in a string to be paged to simply count newlines. This | |
2534 | prevents over-guessing due to embedded escape sequences. A better |
|
2546 | prevents over-guessing due to embedded escape sequences. A better | |
2535 | long-term solution would involve stripping out the control chars |
|
2547 | long-term solution would involve stripping out the control chars | |
2536 | for the count, but it's potentially so expensive I just don't |
|
2548 | for the count, but it's potentially so expensive I just don't | |
2537 | think it's worth doing. |
|
2549 | think it's worth doing. | |
2538 |
|
2550 | |||
2539 | 2002-12-19 *** Released version 0.2.14pre50 |
|
2551 | 2002-12-19 *** Released version 0.2.14pre50 | |
2540 |
|
2552 | |||
2541 | 2002-12-19 Fernando Perez <fperez@colorado.edu> |
|
2553 | 2002-12-19 Fernando Perez <fperez@colorado.edu> | |
2542 |
|
2554 | |||
2543 | * tools/release (version): Changed release scripts to inform |
|
2555 | * tools/release (version): Changed release scripts to inform | |
2544 | Andrea and build a NEWS file with a list of recent changes. |
|
2556 | Andrea and build a NEWS file with a list of recent changes. | |
2545 |
|
2557 | |||
2546 | * IPython/ColorANSI.py (__all__): changed terminal detection |
|
2558 | * IPython/ColorANSI.py (__all__): changed terminal detection | |
2547 | code. Seems to work better for xterms without breaking |
|
2559 | code. Seems to work better for xterms without breaking | |
2548 | konsole. Will need more testing to determine if WinXP and Mac OSX |
|
2560 | konsole. Will need more testing to determine if WinXP and Mac OSX | |
2549 | also work ok. |
|
2561 | also work ok. | |
2550 |
|
2562 | |||
2551 | 2002-12-18 *** Released version 0.2.14pre49 |
|
2563 | 2002-12-18 *** Released version 0.2.14pre49 | |
2552 |
|
2564 | |||
2553 | 2002-12-18 Fernando Perez <fperez@colorado.edu> |
|
2565 | 2002-12-18 Fernando Perez <fperez@colorado.edu> | |
2554 |
|
2566 | |||
2555 | * Docs: added new info about Mac OSX, from Andrea. |
|
2567 | * Docs: added new info about Mac OSX, from Andrea. | |
2556 |
|
2568 | |||
2557 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to |
|
2569 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to | |
2558 | allow direct plotting of python strings whose format is the same |
|
2570 | allow direct plotting of python strings whose format is the same | |
2559 | of gnuplot data files. |
|
2571 | of gnuplot data files. | |
2560 |
|
2572 | |||
2561 | 2002-12-16 Fernando Perez <fperez@colorado.edu> |
|
2573 | 2002-12-16 Fernando Perez <fperez@colorado.edu> | |
2562 |
|
2574 | |||
2563 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) |
|
2575 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) | |
2564 | value of exit question to be acknowledged. |
|
2576 | value of exit question to be acknowledged. | |
2565 |
|
2577 | |||
2566 | 2002-12-03 Fernando Perez <fperez@colorado.edu> |
|
2578 | 2002-12-03 Fernando Perez <fperez@colorado.edu> | |
2567 |
|
2579 | |||
2568 | * IPython/ipmaker.py: removed generators, which had been added |
|
2580 | * IPython/ipmaker.py: removed generators, which had been added | |
2569 | by mistake in an earlier debugging run. This was causing trouble |
|
2581 | by mistake in an earlier debugging run. This was causing trouble | |
2570 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> |
|
2582 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> | |
2571 | for pointing this out. |
|
2583 | for pointing this out. | |
2572 |
|
2584 | |||
2573 | 2002-11-17 Fernando Perez <fperez@colorado.edu> |
|
2585 | 2002-11-17 Fernando Perez <fperez@colorado.edu> | |
2574 |
|
2586 | |||
2575 | * Manual: updated the Gnuplot section. |
|
2587 | * Manual: updated the Gnuplot section. | |
2576 |
|
2588 | |||
2577 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with |
|
2589 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with | |
2578 | a much better split of what goes in Runtime and what goes in |
|
2590 | a much better split of what goes in Runtime and what goes in | |
2579 | Interactive. |
|
2591 | Interactive. | |
2580 |
|
2592 | |||
2581 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't |
|
2593 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't | |
2582 | being imported from iplib. |
|
2594 | being imported from iplib. | |
2583 |
|
2595 | |||
2584 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc |
|
2596 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc | |
2585 | for command-passing. Now the global Gnuplot instance is called |
|
2597 | for command-passing. Now the global Gnuplot instance is called | |
2586 | 'gp' instead of 'g', which was really a far too fragile and |
|
2598 | 'gp' instead of 'g', which was really a far too fragile and | |
2587 | common name. |
|
2599 | common name. | |
2588 |
|
2600 | |||
2589 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken |
|
2601 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken | |
2590 | bounding boxes generated by Gnuplot for square plots. |
|
2602 | bounding boxes generated by Gnuplot for square plots. | |
2591 |
|
2603 | |||
2592 | * IPython/genutils.py (popkey): new function added. I should |
|
2604 | * IPython/genutils.py (popkey): new function added. I should | |
2593 | suggest this on c.l.py as a dict method, it seems useful. |
|
2605 | suggest this on c.l.py as a dict method, it seems useful. | |
2594 |
|
2606 | |||
2595 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot |
|
2607 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot | |
2596 | to transparently handle PostScript generation. MUCH better than |
|
2608 | to transparently handle PostScript generation. MUCH better than | |
2597 | the previous plot_eps/replot_eps (which I removed now). The code |
|
2609 | the previous plot_eps/replot_eps (which I removed now). The code | |
2598 | is also fairly clean and well documented now (including |
|
2610 | is also fairly clean and well documented now (including | |
2599 | docstrings). |
|
2611 | docstrings). | |
2600 |
|
2612 | |||
2601 | 2002-11-13 Fernando Perez <fperez@colorado.edu> |
|
2613 | 2002-11-13 Fernando Perez <fperez@colorado.edu> | |
2602 |
|
2614 | |||
2603 | * IPython/Magic.py (Magic.magic_edit): fixed docstring |
|
2615 | * IPython/Magic.py (Magic.magic_edit): fixed docstring | |
2604 | (inconsistent with options). |
|
2616 | (inconsistent with options). | |
2605 |
|
2617 | |||
2606 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been |
|
2618 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been | |
2607 | manually disabled, I don't know why. Fixed it. |
|
2619 | manually disabled, I don't know why. Fixed it. | |
2608 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly |
|
2620 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly | |
2609 | eps output. |
|
2621 | eps output. | |
2610 |
|
2622 | |||
2611 | 2002-11-12 Fernando Perez <fperez@colorado.edu> |
|
2623 | 2002-11-12 Fernando Perez <fperez@colorado.edu> | |
2612 |
|
2624 | |||
2613 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they |
|
2625 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they | |
2614 | don't propagate up to caller. Fixes crash reported by François |
|
2626 | don't propagate up to caller. Fixes crash reported by François | |
2615 | Pinard. |
|
2627 | Pinard. | |
2616 |
|
2628 | |||
2617 | 2002-11-09 Fernando Perez <fperez@colorado.edu> |
|
2629 | 2002-11-09 Fernando Perez <fperez@colorado.edu> | |
2618 |
|
2630 | |||
2619 | * IPython/ipmaker.py (make_IPython): fixed problem with writing |
|
2631 | * IPython/ipmaker.py (make_IPython): fixed problem with writing | |
2620 | history file for new users. |
|
2632 | history file for new users. | |
2621 | (make_IPython): fixed bug where initial install would leave the |
|
2633 | (make_IPython): fixed bug where initial install would leave the | |
2622 | user running in the .ipython dir. |
|
2634 | user running in the .ipython dir. | |
2623 | (make_IPython): fixed bug where config dir .ipython would be |
|
2635 | (make_IPython): fixed bug where config dir .ipython would be | |
2624 | created regardless of the given -ipythondir option. Thanks to Cory |
|
2636 | created regardless of the given -ipythondir option. Thanks to Cory | |
2625 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. |
|
2637 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. | |
2626 |
|
2638 | |||
2627 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no |
|
2639 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no | |
2628 | type confirmations. Will need to use it in all of IPython's code |
|
2640 | type confirmations. Will need to use it in all of IPython's code | |
2629 | consistently. |
|
2641 | consistently. | |
2630 |
|
2642 | |||
2631 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the |
|
2643 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the | |
2632 | context to print 31 lines instead of the default 5. This will make |
|
2644 | context to print 31 lines instead of the default 5. This will make | |
2633 | the crash reports extremely detailed in case the problem is in |
|
2645 | the crash reports extremely detailed in case the problem is in | |
2634 | libraries I don't have access to. |
|
2646 | libraries I don't have access to. | |
2635 |
|
2647 | |||
2636 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last |
|
2648 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last | |
2637 | line of defense' code to still crash, but giving users fair |
|
2649 | line of defense' code to still crash, but giving users fair | |
2638 | warning. I don't want internal errors to go unreported: if there's |
|
2650 | warning. I don't want internal errors to go unreported: if there's | |
2639 | an internal problem, IPython should crash and generate a full |
|
2651 | an internal problem, IPython should crash and generate a full | |
2640 | report. |
|
2652 | report. | |
2641 |
|
2653 | |||
2642 | 2002-11-08 Fernando Perez <fperez@colorado.edu> |
|
2654 | 2002-11-08 Fernando Perez <fperez@colorado.edu> | |
2643 |
|
2655 | |||
2644 | * IPython/iplib.py (InteractiveShell.interact): added code to trap |
|
2656 | * IPython/iplib.py (InteractiveShell.interact): added code to trap | |
2645 | otherwise uncaught exceptions which can appear if people set |
|
2657 | otherwise uncaught exceptions which can appear if people set | |
2646 | sys.stdout to something badly broken. Thanks to a crash report |
|
2658 | sys.stdout to something badly broken. Thanks to a crash report | |
2647 | from henni-AT-mail.brainbot.com. |
|
2659 | from henni-AT-mail.brainbot.com. | |
2648 |
|
2660 | |||
2649 | 2002-11-04 Fernando Perez <fperez@colorado.edu> |
|
2661 | 2002-11-04 Fernando Perez <fperez@colorado.edu> | |
2650 |
|
2662 | |||
2651 | * IPython/iplib.py (InteractiveShell.interact): added |
|
2663 | * IPython/iplib.py (InteractiveShell.interact): added | |
2652 | __IPYTHON__active to the builtins. It's a flag which goes on when |
|
2664 | __IPYTHON__active to the builtins. It's a flag which goes on when | |
2653 | the interaction starts and goes off again when it stops. This |
|
2665 | the interaction starts and goes off again when it stops. This | |
2654 | allows embedding code to detect being inside IPython. Before this |
|
2666 | allows embedding code to detect being inside IPython. Before this | |
2655 | was done via __IPYTHON__, but that only shows that an IPython |
|
2667 | was done via __IPYTHON__, but that only shows that an IPython | |
2656 | instance has been created. |
|
2668 | instance has been created. | |
2657 |
|
2669 | |||
2658 | * IPython/Magic.py (Magic.magic_env): I realized that in a |
|
2670 | * IPython/Magic.py (Magic.magic_env): I realized that in a | |
2659 | UserDict, instance.data holds the data as a normal dict. So I |
|
2671 | UserDict, instance.data holds the data as a normal dict. So I | |
2660 | modified @env to return os.environ.data instead of rebuilding a |
|
2672 | modified @env to return os.environ.data instead of rebuilding a | |
2661 | dict by hand. |
|
2673 | dict by hand. | |
2662 |
|
2674 | |||
2663 | 2002-11-02 Fernando Perez <fperez@colorado.edu> |
|
2675 | 2002-11-02 Fernando Perez <fperez@colorado.edu> | |
2664 |
|
2676 | |||
2665 | * IPython/genutils.py (warn): changed so that level 1 prints no |
|
2677 | * IPython/genutils.py (warn): changed so that level 1 prints no | |
2666 | header. Level 2 is now the default (with 'WARNING' header, as |
|
2678 | header. Level 2 is now the default (with 'WARNING' header, as | |
2667 | before). I think I tracked all places where changes were needed in |
|
2679 | before). I think I tracked all places where changes were needed in | |
2668 | IPython, but outside code using the old level numbering may have |
|
2680 | IPython, but outside code using the old level numbering may have | |
2669 | broken. |
|
2681 | broken. | |
2670 |
|
2682 | |||
2671 | * IPython/iplib.py (InteractiveShell.runcode): added this to |
|
2683 | * IPython/iplib.py (InteractiveShell.runcode): added this to | |
2672 | handle the tracebacks in SystemExit traps correctly. The previous |
|
2684 | handle the tracebacks in SystemExit traps correctly. The previous | |
2673 | code (through interact) was printing more of the stack than |
|
2685 | code (through interact) was printing more of the stack than | |
2674 | necessary, showing IPython internal code to the user. |
|
2686 | necessary, showing IPython internal code to the user. | |
2675 |
|
2687 | |||
2676 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by |
|
2688 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by | |
2677 | default. Now that the default at the confirmation prompt is yes, |
|
2689 | default. Now that the default at the confirmation prompt is yes, | |
2678 | it's not so intrusive. François' argument that ipython sessions |
|
2690 | it's not so intrusive. François' argument that ipython sessions | |
2679 | tend to be complex enough not to lose them from an accidental C-d, |
|
2691 | tend to be complex enough not to lose them from an accidental C-d, | |
2680 | is a valid one. |
|
2692 | is a valid one. | |
2681 |
|
2693 | |||
2682 | * IPython/iplib.py (InteractiveShell.interact): added a |
|
2694 | * IPython/iplib.py (InteractiveShell.interact): added a | |
2683 | showtraceback() call to the SystemExit trap, and modified the exit |
|
2695 | showtraceback() call to the SystemExit trap, and modified the exit | |
2684 | confirmation to have yes as the default. |
|
2696 | confirmation to have yes as the default. | |
2685 |
|
2697 | |||
2686 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from |
|
2698 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from | |
2687 | this file. It's been gone from the code for a long time, this was |
|
2699 | this file. It's been gone from the code for a long time, this was | |
2688 | simply leftover junk. |
|
2700 | simply leftover junk. | |
2689 |
|
2701 | |||
2690 | 2002-11-01 Fernando Perez <fperez@colorado.edu> |
|
2702 | 2002-11-01 Fernando Perez <fperez@colorado.edu> | |
2691 |
|
2703 | |||
2692 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option |
|
2704 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option | |
2693 | added. If set, IPython now traps EOF and asks for |
|
2705 | added. If set, IPython now traps EOF and asks for | |
2694 | confirmation. After a request by François Pinard. |
|
2706 | confirmation. After a request by François Pinard. | |
2695 |
|
2707 | |||
2696 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead |
|
2708 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead | |
2697 | of @abort, and with a new (better) mechanism for handling the |
|
2709 | of @abort, and with a new (better) mechanism for handling the | |
2698 | exceptions. |
|
2710 | exceptions. | |
2699 |
|
2711 | |||
2700 | 2002-10-27 Fernando Perez <fperez@colorado.edu> |
|
2712 | 2002-10-27 Fernando Perez <fperez@colorado.edu> | |
2701 |
|
2713 | |||
2702 | * IPython/usage.py (__doc__): updated the --help information and |
|
2714 | * IPython/usage.py (__doc__): updated the --help information and | |
2703 | the ipythonrc file to indicate that -log generates |
|
2715 | the ipythonrc file to indicate that -log generates | |
2704 | ./ipython.log. Also fixed the corresponding info in @logstart. |
|
2716 | ./ipython.log. Also fixed the corresponding info in @logstart. | |
2705 | This and several other fixes in the manuals thanks to reports by |
|
2717 | This and several other fixes in the manuals thanks to reports by | |
2706 | François Pinard <pinard-AT-iro.umontreal.ca>. |
|
2718 | François Pinard <pinard-AT-iro.umontreal.ca>. | |
2707 |
|
2719 | |||
2708 | * IPython/Logger.py (Logger.switch_log): Fixed error message to |
|
2720 | * IPython/Logger.py (Logger.switch_log): Fixed error message to | |
2709 | refer to @logstart (instead of @log, which doesn't exist). |
|
2721 | refer to @logstart (instead of @log, which doesn't exist). | |
2710 |
|
2722 | |||
2711 | * IPython/iplib.py (InteractiveShell._prefilter): fixed |
|
2723 | * IPython/iplib.py (InteractiveShell._prefilter): fixed | |
2712 | AttributeError crash. Thanks to Christopher Armstrong |
|
2724 | AttributeError crash. Thanks to Christopher Armstrong | |
2713 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been |
|
2725 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been | |
2714 | introduced recently (in 0.2.14pre37) with the fix to the eval |
|
2726 | introduced recently (in 0.2.14pre37) with the fix to the eval | |
2715 | problem mentioned below. |
|
2727 | problem mentioned below. | |
2716 |
|
2728 | |||
2717 | 2002-10-17 Fernando Perez <fperez@colorado.edu> |
|
2729 | 2002-10-17 Fernando Perez <fperez@colorado.edu> | |
2718 |
|
2730 | |||
2719 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows |
|
2731 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows | |
2720 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. |
|
2732 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. | |
2721 |
|
2733 | |||
2722 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to |
|
2734 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to | |
2723 | this function to fix a problem reported by Alex Schmolck. He saw |
|
2735 | this function to fix a problem reported by Alex Schmolck. He saw | |
2724 | it with list comprehensions and generators, which were getting |
|
2736 | it with list comprehensions and generators, which were getting | |
2725 | called twice. The real problem was an 'eval' call in testing for |
|
2737 | called twice. The real problem was an 'eval' call in testing for | |
2726 | automagic which was evaluating the input line silently. |
|
2738 | automagic which was evaluating the input line silently. | |
2727 |
|
2739 | |||
2728 | This is a potentially very nasty bug, if the input has side |
|
2740 | This is a potentially very nasty bug, if the input has side | |
2729 | effects which must not be repeated. The code is much cleaner now, |
|
2741 | effects which must not be repeated. The code is much cleaner now, | |
2730 | without any blanket 'except' left and with a regexp test for |
|
2742 | without any blanket 'except' left and with a regexp test for | |
2731 | actual function names. |
|
2743 | actual function names. | |
2732 |
|
2744 | |||
2733 | But an eval remains, which I'm not fully comfortable with. I just |
|
2745 | But an eval remains, which I'm not fully comfortable with. I just | |
2734 | don't know how to find out if an expression could be a callable in |
|
2746 | don't know how to find out if an expression could be a callable in | |
2735 | the user's namespace without doing an eval on the string. However |
|
2747 | the user's namespace without doing an eval on the string. However | |
2736 | that string is now much more strictly checked so that no code |
|
2748 | that string is now much more strictly checked so that no code | |
2737 | slips by, so the eval should only happen for things that can |
|
2749 | slips by, so the eval should only happen for things that can | |
2738 | really be only function/method names. |
|
2750 | really be only function/method names. | |
2739 |
|
2751 | |||
2740 | 2002-10-15 Fernando Perez <fperez@colorado.edu> |
|
2752 | 2002-10-15 Fernando Perez <fperez@colorado.edu> | |
2741 |
|
2753 | |||
2742 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac |
|
2754 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac | |
2743 | OSX information to main manual, removed README_Mac_OSX file from |
|
2755 | OSX information to main manual, removed README_Mac_OSX file from | |
2744 | distribution. Also updated credits for recent additions. |
|
2756 | distribution. Also updated credits for recent additions. | |
2745 |
|
2757 | |||
2746 | 2002-10-10 Fernando Perez <fperez@colorado.edu> |
|
2758 | 2002-10-10 Fernando Perez <fperez@colorado.edu> | |
2747 |
|
2759 | |||
2748 | * README_Mac_OSX: Added a README for Mac OSX users for fixing |
|
2760 | * README_Mac_OSX: Added a README for Mac OSX users for fixing | |
2749 | terminal-related issues. Many thanks to Andrea Riciputi |
|
2761 | terminal-related issues. Many thanks to Andrea Riciputi | |
2750 | <andrea.riciputi-AT-libero.it> for writing it. |
|
2762 | <andrea.riciputi-AT-libero.it> for writing it. | |
2751 |
|
2763 | |||
2752 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, |
|
2764 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, | |
2753 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2765 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2754 |
|
2766 | |||
2755 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks |
|
2767 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks | |
2756 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad |
|
2768 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad | |
2757 | <syver-en-AT-online.no> who both submitted patches for this problem. |
|
2769 | <syver-en-AT-online.no> who both submitted patches for this problem. | |
2758 |
|
2770 | |||
2759 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for |
|
2771 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for | |
2760 | global embedding to make sure that things don't overwrite user |
|
2772 | global embedding to make sure that things don't overwrite user | |
2761 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> |
|
2773 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> | |
2762 |
|
2774 | |||
2763 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 |
|
2775 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 | |
2764 | compatibility. Thanks to Hayden Callow |
|
2776 | compatibility. Thanks to Hayden Callow | |
2765 | <h.callow-AT-elec.canterbury.ac.nz> |
|
2777 | <h.callow-AT-elec.canterbury.ac.nz> | |
2766 |
|
2778 | |||
2767 | 2002-10-04 Fernando Perez <fperez@colorado.edu> |
|
2779 | 2002-10-04 Fernando Perez <fperez@colorado.edu> | |
2768 |
|
2780 | |||
2769 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for |
|
2781 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for | |
2770 | Gnuplot.File objects. |
|
2782 | Gnuplot.File objects. | |
2771 |
|
2783 | |||
2772 | 2002-07-23 Fernando Perez <fperez@colorado.edu> |
|
2784 | 2002-07-23 Fernando Perez <fperez@colorado.edu> | |
2773 |
|
2785 | |||
2774 | * IPython/genutils.py (timing): Added timings() and timing() for |
|
2786 | * IPython/genutils.py (timing): Added timings() and timing() for | |
2775 | quick access to the most commonly needed data, the execution |
|
2787 | quick access to the most commonly needed data, the execution | |
2776 | times. Old timing() renamed to timings_out(). |
|
2788 | times. Old timing() renamed to timings_out(). | |
2777 |
|
2789 | |||
2778 | 2002-07-18 Fernando Perez <fperez@colorado.edu> |
|
2790 | 2002-07-18 Fernando Perez <fperez@colorado.edu> | |
2779 |
|
2791 | |||
2780 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed |
|
2792 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed | |
2781 | bug with nested instances disrupting the parent's tab completion. |
|
2793 | bug with nested instances disrupting the parent's tab completion. | |
2782 |
|
2794 | |||
2783 | * IPython/iplib.py (all_completions): Added Alex Schmolck's |
|
2795 | * IPython/iplib.py (all_completions): Added Alex Schmolck's | |
2784 | all_completions code to begin the emacs integration. |
|
2796 | all_completions code to begin the emacs integration. | |
2785 |
|
2797 | |||
2786 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' |
|
2798 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' | |
2787 | argument to allow titling individual arrays when plotting. |
|
2799 | argument to allow titling individual arrays when plotting. | |
2788 |
|
2800 | |||
2789 | 2002-07-15 Fernando Perez <fperez@colorado.edu> |
|
2801 | 2002-07-15 Fernando Perez <fperez@colorado.edu> | |
2790 |
|
2802 | |||
2791 | * setup.py (make_shortcut): changed to retrieve the value of |
|
2803 | * setup.py (make_shortcut): changed to retrieve the value of | |
2792 | 'Program Files' directory from the registry (this value changes in |
|
2804 | 'Program Files' directory from the registry (this value changes in | |
2793 | non-english versions of Windows). Thanks to Thomas Fanslau |
|
2805 | non-english versions of Windows). Thanks to Thomas Fanslau | |
2794 | <tfanslau-AT-gmx.de> for the report. |
|
2806 | <tfanslau-AT-gmx.de> for the report. | |
2795 |
|
2807 | |||
2796 | 2002-07-10 Fernando Perez <fperez@colorado.edu> |
|
2808 | 2002-07-10 Fernando Perez <fperez@colorado.edu> | |
2797 |
|
2809 | |||
2798 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for |
|
2810 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for | |
2799 | a bug in pdb, which crashes if a line with only whitespace is |
|
2811 | a bug in pdb, which crashes if a line with only whitespace is | |
2800 | entered. Bug report submitted to sourceforge. |
|
2812 | entered. Bug report submitted to sourceforge. | |
2801 |
|
2813 | |||
2802 | 2002-07-09 Fernando Perez <fperez@colorado.edu> |
|
2814 | 2002-07-09 Fernando Perez <fperez@colorado.edu> | |
2803 |
|
2815 | |||
2804 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when |
|
2816 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when | |
2805 | reporting exceptions (it's a bug in inspect.py, I just set a |
|
2817 | reporting exceptions (it's a bug in inspect.py, I just set a | |
2806 | workaround). |
|
2818 | workaround). | |
2807 |
|
2819 | |||
2808 | 2002-07-08 Fernando Perez <fperez@colorado.edu> |
|
2820 | 2002-07-08 Fernando Perez <fperez@colorado.edu> | |
2809 |
|
2821 | |||
2810 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to |
|
2822 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to | |
2811 | __IPYTHON__ in __builtins__ to show up in user_ns. |
|
2823 | __IPYTHON__ in __builtins__ to show up in user_ns. | |
2812 |
|
2824 | |||
2813 | 2002-07-03 Fernando Perez <fperez@colorado.edu> |
|
2825 | 2002-07-03 Fernando Perez <fperez@colorado.edu> | |
2814 |
|
2826 | |||
2815 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed |
|
2827 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed | |
2816 | name from @gp_set_instance to @gp_set_default. |
|
2828 | name from @gp_set_instance to @gp_set_default. | |
2817 |
|
2829 | |||
2818 | * IPython/ipmaker.py (make_IPython): default editor value set to |
|
2830 | * IPython/ipmaker.py (make_IPython): default editor value set to | |
2819 | '0' (a string), to match the rc file. Otherwise will crash when |
|
2831 | '0' (a string), to match the rc file. Otherwise will crash when | |
2820 | .strip() is called on it. |
|
2832 | .strip() is called on it. | |
2821 |
|
2833 | |||
2822 |
|
2834 | |||
2823 | 2002-06-28 Fernando Perez <fperez@colorado.edu> |
|
2835 | 2002-06-28 Fernando Perez <fperez@colorado.edu> | |
2824 |
|
2836 | |||
2825 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing |
|
2837 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing | |
2826 | of files in current directory when a file is executed via |
|
2838 | of files in current directory when a file is executed via | |
2827 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. |
|
2839 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. | |
2828 |
|
2840 | |||
2829 | * setup.py (manfiles): fix for rpm builds, submitted by RA |
|
2841 | * setup.py (manfiles): fix for rpm builds, submitted by RA | |
2830 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! |
|
2842 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! | |
2831 |
|
2843 | |||
2832 | * IPython/ipmaker.py (make_IPython): fixed lookup of default |
|
2844 | * IPython/ipmaker.py (make_IPython): fixed lookup of default | |
2833 | editor when set to '0'. Problem was, '0' evaluates to True (it's a |
|
2845 | editor when set to '0'. Problem was, '0' evaluates to True (it's a | |
2834 | string!). A. Schmolck caught this one. |
|
2846 | string!). A. Schmolck caught this one. | |
2835 |
|
2847 | |||
2836 | 2002-06-27 Fernando Perez <fperez@colorado.edu> |
|
2848 | 2002-06-27 Fernando Perez <fperez@colorado.edu> | |
2837 |
|
2849 | |||
2838 | * IPython/ipmaker.py (make_IPython): fixed bug when running user |
|
2850 | * IPython/ipmaker.py (make_IPython): fixed bug when running user | |
2839 | defined files at the cmd line. __name__ wasn't being set to |
|
2851 | defined files at the cmd line. __name__ wasn't being set to | |
2840 | __main__. |
|
2852 | __main__. | |
2841 |
|
2853 | |||
2842 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also |
|
2854 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also | |
2843 | regular lists and tuples besides Numeric arrays. |
|
2855 | regular lists and tuples besides Numeric arrays. | |
2844 |
|
2856 | |||
2845 | * IPython/Prompts.py (CachedOutput.__call__): Added output |
|
2857 | * IPython/Prompts.py (CachedOutput.__call__): Added output | |
2846 | supression for input ending with ';'. Similar to Mathematica and |
|
2858 | supression for input ending with ';'. Similar to Mathematica and | |
2847 | Matlab. The _* vars and Out[] list are still updated, just like |
|
2859 | Matlab. The _* vars and Out[] list are still updated, just like | |
2848 | Mathematica behaves. |
|
2860 | Mathematica behaves. | |
2849 |
|
2861 | |||
2850 | 2002-06-25 Fernando Perez <fperez@colorado.edu> |
|
2862 | 2002-06-25 Fernando Perez <fperez@colorado.edu> | |
2851 |
|
2863 | |||
2852 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of |
|
2864 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of | |
2853 | .ini extensions for profiels under Windows. |
|
2865 | .ini extensions for profiels under Windows. | |
2854 |
|
2866 | |||
2855 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of |
|
2867 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of | |
2856 | string form. Fix contributed by Alexander Schmolck |
|
2868 | string form. Fix contributed by Alexander Schmolck | |
2857 | <a.schmolck-AT-gmx.net> |
|
2869 | <a.schmolck-AT-gmx.net> | |
2858 |
|
2870 | |||
2859 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a |
|
2871 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a | |
2860 | pre-configured Gnuplot instance. |
|
2872 | pre-configured Gnuplot instance. | |
2861 |
|
2873 | |||
2862 | 2002-06-21 Fernando Perez <fperez@colorado.edu> |
|
2874 | 2002-06-21 Fernando Perez <fperez@colorado.edu> | |
2863 |
|
2875 | |||
2864 | * IPython/numutils.py (exp_safe): new function, works around the |
|
2876 | * IPython/numutils.py (exp_safe): new function, works around the | |
2865 | underflow problems in Numeric. |
|
2877 | underflow problems in Numeric. | |
2866 | (log2): New fn. Safe log in base 2: returns exact integer answer |
|
2878 | (log2): New fn. Safe log in base 2: returns exact integer answer | |
2867 | for exact integer powers of 2. |
|
2879 | for exact integer powers of 2. | |
2868 |
|
2880 | |||
2869 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' |
|
2881 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' | |
2870 | properly. |
|
2882 | properly. | |
2871 |
|
2883 | |||
2872 | 2002-06-20 Fernando Perez <fperez@colorado.edu> |
|
2884 | 2002-06-20 Fernando Perez <fperez@colorado.edu> | |
2873 |
|
2885 | |||
2874 | * IPython/genutils.py (timing): new function like |
|
2886 | * IPython/genutils.py (timing): new function like | |
2875 | Mathematica's. Similar to time_test, but returns more info. |
|
2887 | Mathematica's. Similar to time_test, but returns more info. | |
2876 |
|
2888 | |||
2877 | 2002-06-18 Fernando Perez <fperez@colorado.edu> |
|
2889 | 2002-06-18 Fernando Perez <fperez@colorado.edu> | |
2878 |
|
2890 | |||
2879 | * IPython/Magic.py (Magic.magic_save): modified @save and @r |
|
2891 | * IPython/Magic.py (Magic.magic_save): modified @save and @r | |
2880 | according to Mike Heeter's suggestions. |
|
2892 | according to Mike Heeter's suggestions. | |
2881 |
|
2893 | |||
2882 | 2002-06-16 Fernando Perez <fperez@colorado.edu> |
|
2894 | 2002-06-16 Fernando Perez <fperez@colorado.edu> | |
2883 |
|
2895 | |||
2884 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot |
|
2896 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot | |
2885 | system. GnuplotMagic is gone as a user-directory option. New files |
|
2897 | system. GnuplotMagic is gone as a user-directory option. New files | |
2886 | make it easier to use all the gnuplot stuff both from external |
|
2898 | make it easier to use all the gnuplot stuff both from external | |
2887 | programs as well as from IPython. Had to rewrite part of |
|
2899 | programs as well as from IPython. Had to rewrite part of | |
2888 | hardcopy() b/c of a strange bug: often the ps files simply don't |
|
2900 | hardcopy() b/c of a strange bug: often the ps files simply don't | |
2889 | get created, and require a repeat of the command (often several |
|
2901 | get created, and require a repeat of the command (often several | |
2890 | times). |
|
2902 | times). | |
2891 |
|
2903 | |||
2892 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to |
|
2904 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to | |
2893 | resolve output channel at call time, so that if sys.stderr has |
|
2905 | resolve output channel at call time, so that if sys.stderr has | |
2894 | been redirected by user this gets honored. |
|
2906 | been redirected by user this gets honored. | |
2895 |
|
2907 | |||
2896 | 2002-06-13 Fernando Perez <fperez@colorado.edu> |
|
2908 | 2002-06-13 Fernando Perez <fperez@colorado.edu> | |
2897 |
|
2909 | |||
2898 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to |
|
2910 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to | |
2899 | IPShell. Kept a copy with the old names to avoid breaking people's |
|
2911 | IPShell. Kept a copy with the old names to avoid breaking people's | |
2900 | embedded code. |
|
2912 | embedded code. | |
2901 |
|
2913 | |||
2902 | * IPython/ipython: simplified it to the bare minimum after |
|
2914 | * IPython/ipython: simplified it to the bare minimum after | |
2903 | Holger's suggestions. Added info about how to use it in |
|
2915 | Holger's suggestions. Added info about how to use it in | |
2904 | PYTHONSTARTUP. |
|
2916 | PYTHONSTARTUP. | |
2905 |
|
2917 | |||
2906 | * IPython/Shell.py (IPythonShell): changed the options passing |
|
2918 | * IPython/Shell.py (IPythonShell): changed the options passing | |
2907 | from a string with funky %s replacements to a straight list. Maybe |
|
2919 | from a string with funky %s replacements to a straight list. Maybe | |
2908 | a bit more typing, but it follows sys.argv conventions, so there's |
|
2920 | a bit more typing, but it follows sys.argv conventions, so there's | |
2909 | less special-casing to remember. |
|
2921 | less special-casing to remember. | |
2910 |
|
2922 | |||
2911 | 2002-06-12 Fernando Perez <fperez@colorado.edu> |
|
2923 | 2002-06-12 Fernando Perez <fperez@colorado.edu> | |
2912 |
|
2924 | |||
2913 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat |
|
2925 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat | |
2914 | command. Thanks to a suggestion by Mike Heeter. |
|
2926 | command. Thanks to a suggestion by Mike Heeter. | |
2915 | (Magic.magic_pfile): added behavior to look at filenames if given |
|
2927 | (Magic.magic_pfile): added behavior to look at filenames if given | |
2916 | arg is not a defined object. |
|
2928 | arg is not a defined object. | |
2917 | (Magic.magic_save): New @save function to save code snippets. Also |
|
2929 | (Magic.magic_save): New @save function to save code snippets. Also | |
2918 | a Mike Heeter idea. |
|
2930 | a Mike Heeter idea. | |
2919 |
|
2931 | |||
2920 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to |
|
2932 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to | |
2921 | plot() and replot(). Much more convenient now, especially for |
|
2933 | plot() and replot(). Much more convenient now, especially for | |
2922 | interactive use. |
|
2934 | interactive use. | |
2923 |
|
2935 | |||
2924 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to |
|
2936 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to | |
2925 | filenames. |
|
2937 | filenames. | |
2926 |
|
2938 | |||
2927 | 2002-06-02 Fernando Perez <fperez@colorado.edu> |
|
2939 | 2002-06-02 Fernando Perez <fperez@colorado.edu> | |
2928 |
|
2940 | |||
2929 | * IPython/Struct.py (Struct.__init__): modified to admit |
|
2941 | * IPython/Struct.py (Struct.__init__): modified to admit | |
2930 | initialization via another struct. |
|
2942 | initialization via another struct. | |
2931 |
|
2943 | |||
2932 | * IPython/genutils.py (SystemExec.__init__): New stateful |
|
2944 | * IPython/genutils.py (SystemExec.__init__): New stateful | |
2933 | interface to xsys and bq. Useful for writing system scripts. |
|
2945 | interface to xsys and bq. Useful for writing system scripts. | |
2934 |
|
2946 | |||
2935 | 2002-05-30 Fernando Perez <fperez@colorado.edu> |
|
2947 | 2002-05-30 Fernando Perez <fperez@colorado.edu> | |
2936 |
|
2948 | |||
2937 | * MANIFEST.in: Changed docfile selection to exclude all the lyx |
|
2949 | * MANIFEST.in: Changed docfile selection to exclude all the lyx | |
2938 | documents. This will make the user download smaller (it's getting |
|
2950 | documents. This will make the user download smaller (it's getting | |
2939 | too big). |
|
2951 | too big). | |
2940 |
|
2952 | |||
2941 | 2002-05-29 Fernando Perez <fperez@colorado.edu> |
|
2953 | 2002-05-29 Fernando Perez <fperez@colorado.edu> | |
2942 |
|
2954 | |||
2943 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to |
|
2955 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to | |
2944 | fix problems with shelve and pickle. Seems to work, but I don't |
|
2956 | fix problems with shelve and pickle. Seems to work, but I don't | |
2945 | know if corner cases break it. Thanks to Mike Heeter |
|
2957 | know if corner cases break it. Thanks to Mike Heeter | |
2946 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. |
|
2958 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. | |
2947 |
|
2959 | |||
2948 | 2002-05-24 Fernando Perez <fperez@colorado.edu> |
|
2960 | 2002-05-24 Fernando Perez <fperez@colorado.edu> | |
2949 |
|
2961 | |||
2950 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in |
|
2962 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in | |
2951 | macros having broken. |
|
2963 | macros having broken. | |
2952 |
|
2964 | |||
2953 | 2002-05-21 Fernando Perez <fperez@colorado.edu> |
|
2965 | 2002-05-21 Fernando Perez <fperez@colorado.edu> | |
2954 |
|
2966 | |||
2955 | * IPython/Magic.py (Magic.magic_logstart): fixed recently |
|
2967 | * IPython/Magic.py (Magic.magic_logstart): fixed recently | |
2956 | introduced logging bug: all history before logging started was |
|
2968 | introduced logging bug: all history before logging started was | |
2957 | being written one character per line! This came from the redesign |
|
2969 | being written one character per line! This came from the redesign | |
2958 | of the input history as a special list which slices to strings, |
|
2970 | of the input history as a special list which slices to strings, | |
2959 | not to lists. |
|
2971 | not to lists. | |
2960 |
|
2972 | |||
2961 | 2002-05-20 Fernando Perez <fperez@colorado.edu> |
|
2973 | 2002-05-20 Fernando Perez <fperez@colorado.edu> | |
2962 |
|
2974 | |||
2963 | * IPython/Prompts.py (CachedOutput.__init__): made the color table |
|
2975 | * IPython/Prompts.py (CachedOutput.__init__): made the color table | |
2964 | be an attribute of all classes in this module. The design of these |
|
2976 | be an attribute of all classes in this module. The design of these | |
2965 | classes needs some serious overhauling. |
|
2977 | classes needs some serious overhauling. | |
2966 |
|
2978 | |||
2967 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug |
|
2979 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug | |
2968 | which was ignoring '_' in option names. |
|
2980 | which was ignoring '_' in option names. | |
2969 |
|
2981 | |||
2970 | * IPython/ultraTB.py (FormattedTB.__init__): Changed |
|
2982 | * IPython/ultraTB.py (FormattedTB.__init__): Changed | |
2971 | 'Verbose_novars' to 'Context' and made it the new default. It's a |
|
2983 | 'Verbose_novars' to 'Context' and made it the new default. It's a | |
2972 | bit more readable and also safer than verbose. |
|
2984 | bit more readable and also safer than verbose. | |
2973 |
|
2985 | |||
2974 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of |
|
2986 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of | |
2975 | triple-quoted strings. |
|
2987 | triple-quoted strings. | |
2976 |
|
2988 | |||
2977 | * IPython/OInspect.py (__all__): new module exposing the object |
|
2989 | * IPython/OInspect.py (__all__): new module exposing the object | |
2978 | introspection facilities. Now the corresponding magics are dummy |
|
2990 | introspection facilities. Now the corresponding magics are dummy | |
2979 | wrappers around this. Having this module will make it much easier |
|
2991 | wrappers around this. Having this module will make it much easier | |
2980 | to put these functions into our modified pdb. |
|
2992 | to put these functions into our modified pdb. | |
2981 | This new object inspector system uses the new colorizing module, |
|
2993 | This new object inspector system uses the new colorizing module, | |
2982 | so source code and other things are nicely syntax highlighted. |
|
2994 | so source code and other things are nicely syntax highlighted. | |
2983 |
|
2995 | |||
2984 | 2002-05-18 Fernando Perez <fperez@colorado.edu> |
|
2996 | 2002-05-18 Fernando Perez <fperez@colorado.edu> | |
2985 |
|
2997 | |||
2986 | * IPython/ColorANSI.py: Split the coloring tools into a separate |
|
2998 | * IPython/ColorANSI.py: Split the coloring tools into a separate | |
2987 | module so I can use them in other code easier (they were part of |
|
2999 | module so I can use them in other code easier (they were part of | |
2988 | ultraTB). |
|
3000 | ultraTB). | |
2989 |
|
3001 | |||
2990 | 2002-05-17 Fernando Perez <fperez@colorado.edu> |
|
3002 | 2002-05-17 Fernando Perez <fperez@colorado.edu> | |
2991 |
|
3003 | |||
2992 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3004 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
2993 | fixed it to set the global 'g' also to the called instance, as |
|
3005 | fixed it to set the global 'g' also to the called instance, as | |
2994 | long as 'g' was still a gnuplot instance (so it doesn't overwrite |
|
3006 | long as 'g' was still a gnuplot instance (so it doesn't overwrite | |
2995 | user's 'g' variables). |
|
3007 | user's 'g' variables). | |
2996 |
|
3008 | |||
2997 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out |
|
3009 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out | |
2998 | global variables (aliases to _ih,_oh) so that users which expect |
|
3010 | global variables (aliases to _ih,_oh) so that users which expect | |
2999 | In[5] or Out[7] to work aren't unpleasantly surprised. |
|
3011 | In[5] or Out[7] to work aren't unpleasantly surprised. | |
3000 | (InputList.__getslice__): new class to allow executing slices of |
|
3012 | (InputList.__getslice__): new class to allow executing slices of | |
3001 | input history directly. Very simple class, complements the use of |
|
3013 | input history directly. Very simple class, complements the use of | |
3002 | macros. |
|
3014 | macros. | |
3003 |
|
3015 | |||
3004 | 2002-05-16 Fernando Perez <fperez@colorado.edu> |
|
3016 | 2002-05-16 Fernando Perez <fperez@colorado.edu> | |
3005 |
|
3017 | |||
3006 | * setup.py (docdirbase): make doc directory be just doc/IPython |
|
3018 | * setup.py (docdirbase): make doc directory be just doc/IPython | |
3007 | without version numbers, it will reduce clutter for users. |
|
3019 | without version numbers, it will reduce clutter for users. | |
3008 |
|
3020 | |||
3009 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to |
|
3021 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to | |
3010 | execfile call to prevent possible memory leak. See for details: |
|
3022 | execfile call to prevent possible memory leak. See for details: | |
3011 | http://mail.python.org/pipermail/python-list/2002-February/088476.html |
|
3023 | http://mail.python.org/pipermail/python-list/2002-February/088476.html | |
3012 |
|
3024 | |||
3013 | 2002-05-15 Fernando Perez <fperez@colorado.edu> |
|
3025 | 2002-05-15 Fernando Perez <fperez@colorado.edu> | |
3014 |
|
3026 | |||
3015 | * IPython/Magic.py (Magic.magic_psource): made the object |
|
3027 | * IPython/Magic.py (Magic.magic_psource): made the object | |
3016 | introspection names be more standard: pdoc, pdef, pfile and |
|
3028 | introspection names be more standard: pdoc, pdef, pfile and | |
3017 | psource. They all print/page their output, and it makes |
|
3029 | psource. They all print/page their output, and it makes | |
3018 | remembering them easier. Kept old names for compatibility as |
|
3030 | remembering them easier. Kept old names for compatibility as | |
3019 | aliases. |
|
3031 | aliases. | |
3020 |
|
3032 | |||
3021 | 2002-05-14 Fernando Perez <fperez@colorado.edu> |
|
3033 | 2002-05-14 Fernando Perez <fperez@colorado.edu> | |
3022 |
|
3034 | |||
3023 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood |
|
3035 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood | |
3024 | what the mouse problem was. The trick is to use gnuplot with temp |
|
3036 | what the mouse problem was. The trick is to use gnuplot with temp | |
3025 | files and NOT with pipes (for data communication), because having |
|
3037 | files and NOT with pipes (for data communication), because having | |
3026 | both pipes and the mouse on is bad news. |
|
3038 | both pipes and the mouse on is bad news. | |
3027 |
|
3039 | |||
3028 | 2002-05-13 Fernando Perez <fperez@colorado.edu> |
|
3040 | 2002-05-13 Fernando Perez <fperez@colorado.edu> | |
3029 |
|
3041 | |||
3030 | * IPython/Magic.py (Magic._ofind): fixed namespace order search |
|
3042 | * IPython/Magic.py (Magic._ofind): fixed namespace order search | |
3031 | bug. Information would be reported about builtins even when |
|
3043 | bug. Information would be reported about builtins even when | |
3032 | user-defined functions overrode them. |
|
3044 | user-defined functions overrode them. | |
3033 |
|
3045 | |||
3034 | 2002-05-11 Fernando Perez <fperez@colorado.edu> |
|
3046 | 2002-05-11 Fernando Perez <fperez@colorado.edu> | |
3035 |
|
3047 | |||
3036 | * IPython/__init__.py (__all__): removed FlexCompleter from |
|
3048 | * IPython/__init__.py (__all__): removed FlexCompleter from | |
3037 | __all__ so that things don't fail in platforms without readline. |
|
3049 | __all__ so that things don't fail in platforms without readline. | |
3038 |
|
3050 | |||
3039 | 2002-05-10 Fernando Perez <fperez@colorado.edu> |
|
3051 | 2002-05-10 Fernando Perez <fperez@colorado.edu> | |
3040 |
|
3052 | |||
3041 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c |
|
3053 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c | |
3042 | it requires Numeric, effectively making Numeric a dependency for |
|
3054 | it requires Numeric, effectively making Numeric a dependency for | |
3043 | IPython. |
|
3055 | IPython. | |
3044 |
|
3056 | |||
3045 | * Released 0.2.13 |
|
3057 | * Released 0.2.13 | |
3046 |
|
3058 | |||
3047 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the |
|
3059 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the | |
3048 | profiler interface. Now all the major options from the profiler |
|
3060 | profiler interface. Now all the major options from the profiler | |
3049 | module are directly supported in IPython, both for single |
|
3061 | module are directly supported in IPython, both for single | |
3050 | expressions (@prun) and for full programs (@run -p). |
|
3062 | expressions (@prun) and for full programs (@run -p). | |
3051 |
|
3063 | |||
3052 | 2002-05-09 Fernando Perez <fperez@colorado.edu> |
|
3064 | 2002-05-09 Fernando Perez <fperez@colorado.edu> | |
3053 |
|
3065 | |||
3054 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of |
|
3066 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of | |
3055 | magic properly formatted for screen. |
|
3067 | magic properly formatted for screen. | |
3056 |
|
3068 | |||
3057 | * setup.py (make_shortcut): Changed things to put pdf version in |
|
3069 | * setup.py (make_shortcut): Changed things to put pdf version in | |
3058 | doc/ instead of doc/manual (had to change lyxport a bit). |
|
3070 | doc/ instead of doc/manual (had to change lyxport a bit). | |
3059 |
|
3071 | |||
3060 | * IPython/Magic.py (Profile.string_stats): made profile runs go |
|
3072 | * IPython/Magic.py (Profile.string_stats): made profile runs go | |
3061 | through pager (they are long and a pager allows searching, saving, |
|
3073 | through pager (they are long and a pager allows searching, saving, | |
3062 | etc.) |
|
3074 | etc.) | |
3063 |
|
3075 | |||
3064 | 2002-05-08 Fernando Perez <fperez@colorado.edu> |
|
3076 | 2002-05-08 Fernando Perez <fperez@colorado.edu> | |
3065 |
|
3077 | |||
3066 | * Released 0.2.12 |
|
3078 | * Released 0.2.12 | |
3067 |
|
3079 | |||
3068 | 2002-05-06 Fernando Perez <fperez@colorado.edu> |
|
3080 | 2002-05-06 Fernando Perez <fperez@colorado.edu> | |
3069 |
|
3081 | |||
3070 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently |
|
3082 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently | |
3071 | introduced); 'hist n1 n2' was broken. |
|
3083 | introduced); 'hist n1 n2' was broken. | |
3072 | (Magic.magic_pdb): added optional on/off arguments to @pdb |
|
3084 | (Magic.magic_pdb): added optional on/off arguments to @pdb | |
3073 | (Magic.magic_run): added option -i to @run, which executes code in |
|
3085 | (Magic.magic_run): added option -i to @run, which executes code in | |
3074 | the IPython namespace instead of a clean one. Also added @irun as |
|
3086 | the IPython namespace instead of a clean one. Also added @irun as | |
3075 | an alias to @run -i. |
|
3087 | an alias to @run -i. | |
3076 |
|
3088 | |||
3077 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3089 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
3078 | fixed (it didn't really do anything, the namespaces were wrong). |
|
3090 | fixed (it didn't really do anything, the namespaces were wrong). | |
3079 |
|
3091 | |||
3080 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 |
|
3092 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 | |
3081 |
|
3093 | |||
3082 | * IPython/__init__.py (__all__): Fixed package namespace, now |
|
3094 | * IPython/__init__.py (__all__): Fixed package namespace, now | |
3083 | 'import IPython' does give access to IPython.<all> as |
|
3095 | 'import IPython' does give access to IPython.<all> as | |
3084 | expected. Also renamed __release__ to Release. |
|
3096 | expected. Also renamed __release__ to Release. | |
3085 |
|
3097 | |||
3086 | * IPython/Debugger.py (__license__): created new Pdb class which |
|
3098 | * IPython/Debugger.py (__license__): created new Pdb class which | |
3087 | functions like a drop-in for the normal pdb.Pdb but does NOT |
|
3099 | functions like a drop-in for the normal pdb.Pdb but does NOT | |
3088 | import readline by default. This way it doesn't muck up IPython's |
|
3100 | import readline by default. This way it doesn't muck up IPython's | |
3089 | readline handling, and now tab-completion finally works in the |
|
3101 | readline handling, and now tab-completion finally works in the | |
3090 | debugger -- sort of. It completes things globally visible, but the |
|
3102 | debugger -- sort of. It completes things globally visible, but the | |
3091 | completer doesn't track the stack as pdb walks it. That's a bit |
|
3103 | completer doesn't track the stack as pdb walks it. That's a bit | |
3092 | tricky, and I'll have to implement it later. |
|
3104 | tricky, and I'll have to implement it later. | |
3093 |
|
3105 | |||
3094 | 2002-05-05 Fernando Perez <fperez@colorado.edu> |
|
3106 | 2002-05-05 Fernando Perez <fperez@colorado.edu> | |
3095 |
|
3107 | |||
3096 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for |
|
3108 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for | |
3097 | magic docstrings when printed via ? (explicit \'s were being |
|
3109 | magic docstrings when printed via ? (explicit \'s were being | |
3098 | printed). |
|
3110 | printed). | |
3099 |
|
3111 | |||
3100 | * IPython/ipmaker.py (make_IPython): fixed namespace |
|
3112 | * IPython/ipmaker.py (make_IPython): fixed namespace | |
3101 | identification bug. Now variables loaded via logs or command-line |
|
3113 | identification bug. Now variables loaded via logs or command-line | |
3102 | files are recognized in the interactive namespace by @who. |
|
3114 | files are recognized in the interactive namespace by @who. | |
3103 |
|
3115 | |||
3104 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in |
|
3116 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in | |
3105 | log replay system stemming from the string form of Structs. |
|
3117 | log replay system stemming from the string form of Structs. | |
3106 |
|
3118 | |||
3107 | * IPython/Magic.py (Macro.__init__): improved macros to properly |
|
3119 | * IPython/Magic.py (Macro.__init__): improved macros to properly | |
3108 | handle magic commands in them. |
|
3120 | handle magic commands in them. | |
3109 | (Magic.magic_logstart): usernames are now expanded so 'logstart |
|
3121 | (Magic.magic_logstart): usernames are now expanded so 'logstart | |
3110 | ~/mylog' now works. |
|
3122 | ~/mylog' now works. | |
3111 |
|
3123 | |||
3112 | * IPython/iplib.py (complete): fixed bug where paths starting with |
|
3124 | * IPython/iplib.py (complete): fixed bug where paths starting with | |
3113 | '/' would be completed as magic names. |
|
3125 | '/' would be completed as magic names. | |
3114 |
|
3126 | |||
3115 | 2002-05-04 Fernando Perez <fperez@colorado.edu> |
|
3127 | 2002-05-04 Fernando Perez <fperez@colorado.edu> | |
3116 |
|
3128 | |||
3117 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to |
|
3129 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to | |
3118 | allow running full programs under the profiler's control. |
|
3130 | allow running full programs under the profiler's control. | |
3119 |
|
3131 | |||
3120 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars |
|
3132 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars | |
3121 | mode to report exceptions verbosely but without formatting |
|
3133 | mode to report exceptions verbosely but without formatting | |
3122 | variables. This addresses the issue of ipython 'freezing' (it's |
|
3134 | variables. This addresses the issue of ipython 'freezing' (it's | |
3123 | not frozen, but caught in an expensive formatting loop) when huge |
|
3135 | not frozen, but caught in an expensive formatting loop) when huge | |
3124 | variables are in the context of an exception. |
|
3136 | variables are in the context of an exception. | |
3125 | (VerboseTB.text): Added '--->' markers at line where exception was |
|
3137 | (VerboseTB.text): Added '--->' markers at line where exception was | |
3126 | triggered. Much clearer to read, especially in NoColor modes. |
|
3138 | triggered. Much clearer to read, especially in NoColor modes. | |
3127 |
|
3139 | |||
3128 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been |
|
3140 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been | |
3129 | implemented in reverse when changing to the new parse_options(). |
|
3141 | implemented in reverse when changing to the new parse_options(). | |
3130 |
|
3142 | |||
3131 | 2002-05-03 Fernando Perez <fperez@colorado.edu> |
|
3143 | 2002-05-03 Fernando Perez <fperez@colorado.edu> | |
3132 |
|
3144 | |||
3133 | * IPython/Magic.py (Magic.parse_options): new function so that |
|
3145 | * IPython/Magic.py (Magic.parse_options): new function so that | |
3134 | magics can parse options easier. |
|
3146 | magics can parse options easier. | |
3135 | (Magic.magic_prun): new function similar to profile.run(), |
|
3147 | (Magic.magic_prun): new function similar to profile.run(), | |
3136 | suggested by Chris Hart. |
|
3148 | suggested by Chris Hart. | |
3137 | (Magic.magic_cd): fixed behavior so that it only changes if |
|
3149 | (Magic.magic_cd): fixed behavior so that it only changes if | |
3138 | directory actually is in history. |
|
3150 | directory actually is in history. | |
3139 |
|
3151 | |||
3140 | * IPython/usage.py (__doc__): added information about potential |
|
3152 | * IPython/usage.py (__doc__): added information about potential | |
3141 | slowness of Verbose exception mode when there are huge data |
|
3153 | slowness of Verbose exception mode when there are huge data | |
3142 | structures to be formatted (thanks to Archie Paulson). |
|
3154 | structures to be formatted (thanks to Archie Paulson). | |
3143 |
|
3155 | |||
3144 | * IPython/ipmaker.py (make_IPython): Changed default logging |
|
3156 | * IPython/ipmaker.py (make_IPython): Changed default logging | |
3145 | (when simply called with -log) to use curr_dir/ipython.log in |
|
3157 | (when simply called with -log) to use curr_dir/ipython.log in | |
3146 | rotate mode. Fixed crash which was occuring with -log before |
|
3158 | rotate mode. Fixed crash which was occuring with -log before | |
3147 | (thanks to Jim Boyle). |
|
3159 | (thanks to Jim Boyle). | |
3148 |
|
3160 | |||
3149 | 2002-05-01 Fernando Perez <fperez@colorado.edu> |
|
3161 | 2002-05-01 Fernando Perez <fperez@colorado.edu> | |
3150 |
|
3162 | |||
3151 | * Released 0.2.11 for these fixes (mainly the ultraTB one which |
|
3163 | * Released 0.2.11 for these fixes (mainly the ultraTB one which | |
3152 | was nasty -- though somewhat of a corner case). |
|
3164 | was nasty -- though somewhat of a corner case). | |
3153 |
|
3165 | |||
3154 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to |
|
3166 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to | |
3155 | text (was a bug). |
|
3167 | text (was a bug). | |
3156 |
|
3168 | |||
3157 | 2002-04-30 Fernando Perez <fperez@colorado.edu> |
|
3169 | 2002-04-30 Fernando Perez <fperez@colorado.edu> | |
3158 |
|
3170 | |||
3159 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add |
|
3171 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add | |
3160 | a print after ^D or ^C from the user so that the In[] prompt |
|
3172 | a print after ^D or ^C from the user so that the In[] prompt | |
3161 | doesn't over-run the gnuplot one. |
|
3173 | doesn't over-run the gnuplot one. | |
3162 |
|
3174 | |||
3163 | 2002-04-29 Fernando Perez <fperez@colorado.edu> |
|
3175 | 2002-04-29 Fernando Perez <fperez@colorado.edu> | |
3164 |
|
3176 | |||
3165 | * Released 0.2.10 |
|
3177 | * Released 0.2.10 | |
3166 |
|
3178 | |||
3167 | * IPython/__release__.py (version): get date dynamically. |
|
3179 | * IPython/__release__.py (version): get date dynamically. | |
3168 |
|
3180 | |||
3169 | * Misc. documentation updates thanks to Arnd's comments. Also ran |
|
3181 | * Misc. documentation updates thanks to Arnd's comments. Also ran | |
3170 | a full spellcheck on the manual (hadn't been done in a while). |
|
3182 | a full spellcheck on the manual (hadn't been done in a while). | |
3171 |
|
3183 | |||
3172 | 2002-04-27 Fernando Perez <fperez@colorado.edu> |
|
3184 | 2002-04-27 Fernando Perez <fperez@colorado.edu> | |
3173 |
|
3185 | |||
3174 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where |
|
3186 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where | |
3175 | starting a log in mid-session would reset the input history list. |
|
3187 | starting a log in mid-session would reset the input history list. | |
3176 |
|
3188 | |||
3177 | 2002-04-26 Fernando Perez <fperez@colorado.edu> |
|
3189 | 2002-04-26 Fernando Perez <fperez@colorado.edu> | |
3178 |
|
3190 | |||
3179 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not |
|
3191 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not | |
3180 | all files were being included in an update. Now anything in |
|
3192 | all files were being included in an update. Now anything in | |
3181 | UserConfig that matches [A-Za-z]*.py will go (this excludes |
|
3193 | UserConfig that matches [A-Za-z]*.py will go (this excludes | |
3182 | __init__.py) |
|
3194 | __init__.py) | |
3183 |
|
3195 | |||
3184 | 2002-04-25 Fernando Perez <fperez@colorado.edu> |
|
3196 | 2002-04-25 Fernando Perez <fperez@colorado.edu> | |
3185 |
|
3197 | |||
3186 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ |
|
3198 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ | |
3187 | to __builtins__ so that any form of embedded or imported code can |
|
3199 | to __builtins__ so that any form of embedded or imported code can | |
3188 | test for being inside IPython. |
|
3200 | test for being inside IPython. | |
3189 |
|
3201 | |||
3190 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): |
|
3202 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): | |
3191 | changed to GnuplotMagic because it's now an importable module, |
|
3203 | changed to GnuplotMagic because it's now an importable module, | |
3192 | this makes the name follow that of the standard Gnuplot module. |
|
3204 | this makes the name follow that of the standard Gnuplot module. | |
3193 | GnuplotMagic can now be loaded at any time in mid-session. |
|
3205 | GnuplotMagic can now be loaded at any time in mid-session. | |
3194 |
|
3206 | |||
3195 | 2002-04-24 Fernando Perez <fperez@colorado.edu> |
|
3207 | 2002-04-24 Fernando Perez <fperez@colorado.edu> | |
3196 |
|
3208 | |||
3197 | * IPython/numutils.py: removed SIUnits. It doesn't properly set |
|
3209 | * IPython/numutils.py: removed SIUnits. It doesn't properly set | |
3198 | the globals (IPython has its own namespace) and the |
|
3210 | the globals (IPython has its own namespace) and the | |
3199 | PhysicalQuantity stuff is much better anyway. |
|
3211 | PhysicalQuantity stuff is much better anyway. | |
3200 |
|
3212 | |||
3201 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot |
|
3213 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot | |
3202 | embedding example to standard user directory for |
|
3214 | embedding example to standard user directory for | |
3203 | distribution. Also put it in the manual. |
|
3215 | distribution. Also put it in the manual. | |
3204 |
|
3216 | |||
3205 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot |
|
3217 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot | |
3206 | instance as first argument (so it doesn't rely on some obscure |
|
3218 | instance as first argument (so it doesn't rely on some obscure | |
3207 | hidden global). |
|
3219 | hidden global). | |
3208 |
|
3220 | |||
3209 | * IPython/UserConfig/ipythonrc.py: put () back in accepted |
|
3221 | * IPython/UserConfig/ipythonrc.py: put () back in accepted | |
3210 | delimiters. While it prevents ().TAB from working, it allows |
|
3222 | delimiters. While it prevents ().TAB from working, it allows | |
3211 | completions in open (... expressions. This is by far a more common |
|
3223 | completions in open (... expressions. This is by far a more common | |
3212 | case. |
|
3224 | case. | |
3213 |
|
3225 | |||
3214 | 2002-04-23 Fernando Perez <fperez@colorado.edu> |
|
3226 | 2002-04-23 Fernando Perez <fperez@colorado.edu> | |
3215 |
|
3227 | |||
3216 | * IPython/Extensions/InterpreterPasteInput.py: new |
|
3228 | * IPython/Extensions/InterpreterPasteInput.py: new | |
3217 | syntax-processing module for pasting lines with >>> or ... at the |
|
3229 | syntax-processing module for pasting lines with >>> or ... at the | |
3218 | start. |
|
3230 | start. | |
3219 |
|
3231 | |||
3220 | * IPython/Extensions/PhysicalQ_Interactive.py |
|
3232 | * IPython/Extensions/PhysicalQ_Interactive.py | |
3221 | (PhysicalQuantityInteractive.__int__): fixed to work with either |
|
3233 | (PhysicalQuantityInteractive.__int__): fixed to work with either | |
3222 | Numeric or math. |
|
3234 | Numeric or math. | |
3223 |
|
3235 | |||
3224 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the |
|
3236 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the | |
3225 | provided profiles. Now we have: |
|
3237 | provided profiles. Now we have: | |
3226 | -math -> math module as * and cmath with its own namespace. |
|
3238 | -math -> math module as * and cmath with its own namespace. | |
3227 | -numeric -> Numeric as *, plus gnuplot & grace |
|
3239 | -numeric -> Numeric as *, plus gnuplot & grace | |
3228 | -physics -> same as before |
|
3240 | -physics -> same as before | |
3229 |
|
3241 | |||
3230 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where |
|
3242 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where | |
3231 | user-defined magics wouldn't be found by @magic if they were |
|
3243 | user-defined magics wouldn't be found by @magic if they were | |
3232 | defined as class methods. Also cleaned up the namespace search |
|
3244 | defined as class methods. Also cleaned up the namespace search | |
3233 | logic and the string building (to use %s instead of many repeated |
|
3245 | logic and the string building (to use %s instead of many repeated | |
3234 | string adds). |
|
3246 | string adds). | |
3235 |
|
3247 | |||
3236 | * IPython/UserConfig/example-magic.py (magic_foo): updated example |
|
3248 | * IPython/UserConfig/example-magic.py (magic_foo): updated example | |
3237 | of user-defined magics to operate with class methods (cleaner, in |
|
3249 | of user-defined magics to operate with class methods (cleaner, in | |
3238 | line with the gnuplot code). |
|
3250 | line with the gnuplot code). | |
3239 |
|
3251 | |||
3240 | 2002-04-22 Fernando Perez <fperez@colorado.edu> |
|
3252 | 2002-04-22 Fernando Perez <fperez@colorado.edu> | |
3241 |
|
3253 | |||
3242 | * setup.py: updated dependency list so that manual is updated when |
|
3254 | * setup.py: updated dependency list so that manual is updated when | |
3243 | all included files change. |
|
3255 | all included files change. | |
3244 |
|
3256 | |||
3245 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring |
|
3257 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring | |
3246 | the delimiter removal option (the fix is ugly right now). |
|
3258 | the delimiter removal option (the fix is ugly right now). | |
3247 |
|
3259 | |||
3248 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load |
|
3260 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load | |
3249 | all of the math profile (quicker loading, no conflict between |
|
3261 | all of the math profile (quicker loading, no conflict between | |
3250 | g-9.8 and g-gnuplot). |
|
3262 | g-9.8 and g-gnuplot). | |
3251 |
|
3263 | |||
3252 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default |
|
3264 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default | |
3253 | name of post-mortem files to IPython_crash_report.txt. |
|
3265 | name of post-mortem files to IPython_crash_report.txt. | |
3254 |
|
3266 | |||
3255 | * Cleanup/update of the docs. Added all the new readline info and |
|
3267 | * Cleanup/update of the docs. Added all the new readline info and | |
3256 | formatted all lists as 'real lists'. |
|
3268 | formatted all lists as 'real lists'. | |
3257 |
|
3269 | |||
3258 | * IPython/ipmaker.py (make_IPython): removed now-obsolete |
|
3270 | * IPython/ipmaker.py (make_IPython): removed now-obsolete | |
3259 | tab-completion options, since the full readline parse_and_bind is |
|
3271 | tab-completion options, since the full readline parse_and_bind is | |
3260 | now accessible. |
|
3272 | now accessible. | |
3261 |
|
3273 | |||
3262 | * IPython/iplib.py (InteractiveShell.init_readline): Changed |
|
3274 | * IPython/iplib.py (InteractiveShell.init_readline): Changed | |
3263 | handling of readline options. Now users can specify any string to |
|
3275 | handling of readline options. Now users can specify any string to | |
3264 | be passed to parse_and_bind(), as well as the delimiters to be |
|
3276 | be passed to parse_and_bind(), as well as the delimiters to be | |
3265 | removed. |
|
3277 | removed. | |
3266 | (InteractiveShell.__init__): Added __name__ to the global |
|
3278 | (InteractiveShell.__init__): Added __name__ to the global | |
3267 | namespace so that things like Itpl which rely on its existence |
|
3279 | namespace so that things like Itpl which rely on its existence | |
3268 | don't crash. |
|
3280 | don't crash. | |
3269 | (InteractiveShell._prefilter): Defined the default with a _ so |
|
3281 | (InteractiveShell._prefilter): Defined the default with a _ so | |
3270 | that prefilter() is easier to override, while the default one |
|
3282 | that prefilter() is easier to override, while the default one | |
3271 | remains available. |
|
3283 | remains available. | |
3272 |
|
3284 | |||
3273 | 2002-04-18 Fernando Perez <fperez@colorado.edu> |
|
3285 | 2002-04-18 Fernando Perez <fperez@colorado.edu> | |
3274 |
|
3286 | |||
3275 | * Added information about pdb in the docs. |
|
3287 | * Added information about pdb in the docs. | |
3276 |
|
3288 | |||
3277 | 2002-04-17 Fernando Perez <fperez@colorado.edu> |
|
3289 | 2002-04-17 Fernando Perez <fperez@colorado.edu> | |
3278 |
|
3290 | |||
3279 | * IPython/ipmaker.py (make_IPython): added rc_override option to |
|
3291 | * IPython/ipmaker.py (make_IPython): added rc_override option to | |
3280 | allow passing config options at creation time which may override |
|
3292 | allow passing config options at creation time which may override | |
3281 | anything set in the config files or command line. This is |
|
3293 | anything set in the config files or command line. This is | |
3282 | particularly useful for configuring embedded instances. |
|
3294 | particularly useful for configuring embedded instances. | |
3283 |
|
3295 | |||
3284 | 2002-04-15 Fernando Perez <fperez@colorado.edu> |
|
3296 | 2002-04-15 Fernando Perez <fperez@colorado.edu> | |
3285 |
|
3297 | |||
3286 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could |
|
3298 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could | |
3287 | crash embedded instances because of the input cache falling out of |
|
3299 | crash embedded instances because of the input cache falling out of | |
3288 | sync with the output counter. |
|
3300 | sync with the output counter. | |
3289 |
|
3301 | |||
3290 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug |
|
3302 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug | |
3291 | mode which calls pdb after an uncaught exception in IPython itself. |
|
3303 | mode which calls pdb after an uncaught exception in IPython itself. | |
3292 |
|
3304 | |||
3293 | 2002-04-14 Fernando Perez <fperez@colorado.edu> |
|
3305 | 2002-04-14 Fernando Perez <fperez@colorado.edu> | |
3294 |
|
3306 | |||
3295 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up |
|
3307 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up | |
3296 | readline, fix it back after each call. |
|
3308 | readline, fix it back after each call. | |
3297 |
|
3309 | |||
3298 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private |
|
3310 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private | |
3299 | method to force all access via __call__(), which guarantees that |
|
3311 | method to force all access via __call__(), which guarantees that | |
3300 | traceback references are properly deleted. |
|
3312 | traceback references are properly deleted. | |
3301 |
|
3313 | |||
3302 | * IPython/Prompts.py (CachedOutput._display): minor fixes to |
|
3314 | * IPython/Prompts.py (CachedOutput._display): minor fixes to | |
3303 | improve printing when pprint is in use. |
|
3315 | improve printing when pprint is in use. | |
3304 |
|
3316 | |||
3305 | 2002-04-13 Fernando Perez <fperez@colorado.edu> |
|
3317 | 2002-04-13 Fernando Perez <fperez@colorado.edu> | |
3306 |
|
3318 | |||
3307 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit |
|
3319 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit | |
3308 | exceptions aren't caught anymore. If the user triggers one, he |
|
3320 | exceptions aren't caught anymore. If the user triggers one, he | |
3309 | should know why he's doing it and it should go all the way up, |
|
3321 | should know why he's doing it and it should go all the way up, | |
3310 | just like any other exception. So now @abort will fully kill the |
|
3322 | just like any other exception. So now @abort will fully kill the | |
3311 | embedded interpreter and the embedding code (unless that happens |
|
3323 | embedded interpreter and the embedding code (unless that happens | |
3312 | to catch SystemExit). |
|
3324 | to catch SystemExit). | |
3313 |
|
3325 | |||
3314 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag |
|
3326 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag | |
3315 | and a debugger() method to invoke the interactive pdb debugger |
|
3327 | and a debugger() method to invoke the interactive pdb debugger | |
3316 | after printing exception information. Also added the corresponding |
|
3328 | after printing exception information. Also added the corresponding | |
3317 | -pdb option and @pdb magic to control this feature, and updated |
|
3329 | -pdb option and @pdb magic to control this feature, and updated | |
3318 | the docs. After a suggestion from Christopher Hart |
|
3330 | the docs. After a suggestion from Christopher Hart | |
3319 | (hart-AT-caltech.edu). |
|
3331 | (hart-AT-caltech.edu). | |
3320 |
|
3332 | |||
3321 | 2002-04-12 Fernando Perez <fperez@colorado.edu> |
|
3333 | 2002-04-12 Fernando Perez <fperez@colorado.edu> | |
3322 |
|
3334 | |||
3323 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use |
|
3335 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use | |
3324 | the exception handlers defined by the user (not the CrashHandler) |
|
3336 | the exception handlers defined by the user (not the CrashHandler) | |
3325 | so that user exceptions don't trigger an ipython bug report. |
|
3337 | so that user exceptions don't trigger an ipython bug report. | |
3326 |
|
3338 | |||
3327 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme |
|
3339 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme | |
3328 | configurable (it should have always been so). |
|
3340 | configurable (it should have always been so). | |
3329 |
|
3341 | |||
3330 | 2002-03-26 Fernando Perez <fperez@colorado.edu> |
|
3342 | 2002-03-26 Fernando Perez <fperez@colorado.edu> | |
3331 |
|
3343 | |||
3332 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here |
|
3344 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here | |
3333 | and there to fix embedding namespace issues. This should all be |
|
3345 | and there to fix embedding namespace issues. This should all be | |
3334 | done in a more elegant way. |
|
3346 | done in a more elegant way. | |
3335 |
|
3347 | |||
3336 | 2002-03-25 Fernando Perez <fperez@colorado.edu> |
|
3348 | 2002-03-25 Fernando Perez <fperez@colorado.edu> | |
3337 |
|
3349 | |||
3338 | * IPython/genutils.py (get_home_dir): Try to make it work under |
|
3350 | * IPython/genutils.py (get_home_dir): Try to make it work under | |
3339 | win9x also. |
|
3351 | win9x also. | |
3340 |
|
3352 | |||
3341 | 2002-03-20 Fernando Perez <fperez@colorado.edu> |
|
3353 | 2002-03-20 Fernando Perez <fperez@colorado.edu> | |
3342 |
|
3354 | |||
3343 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave |
|
3355 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave | |
3344 | sys.displayhook untouched upon __init__. |
|
3356 | sys.displayhook untouched upon __init__. | |
3345 |
|
3357 | |||
3346 | 2002-03-19 Fernando Perez <fperez@colorado.edu> |
|
3358 | 2002-03-19 Fernando Perez <fperez@colorado.edu> | |
3347 |
|
3359 | |||
3348 | * Released 0.2.9 (for embedding bug, basically). |
|
3360 | * Released 0.2.9 (for embedding bug, basically). | |
3349 |
|
3361 | |||
3350 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit |
|
3362 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit | |
3351 | exceptions so that enclosing shell's state can be restored. |
|
3363 | exceptions so that enclosing shell's state can be restored. | |
3352 |
|
3364 | |||
3353 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize |
|
3365 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize | |
3354 | naming conventions in the .ipython/ dir. |
|
3366 | naming conventions in the .ipython/ dir. | |
3355 |
|
3367 | |||
3356 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' |
|
3368 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' | |
3357 | from delimiters list so filenames with - in them get expanded. |
|
3369 | from delimiters list so filenames with - in them get expanded. | |
3358 |
|
3370 | |||
3359 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with |
|
3371 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with | |
3360 | sys.displayhook not being properly restored after an embedded call. |
|
3372 | sys.displayhook not being properly restored after an embedded call. | |
3361 |
|
3373 | |||
3362 | 2002-03-18 Fernando Perez <fperez@colorado.edu> |
|
3374 | 2002-03-18 Fernando Perez <fperez@colorado.edu> | |
3363 |
|
3375 | |||
3364 | * Released 0.2.8 |
|
3376 | * Released 0.2.8 | |
3365 |
|
3377 | |||
3366 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where |
|
3378 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where | |
3367 | some files weren't being included in a -upgrade. |
|
3379 | some files weren't being included in a -upgrade. | |
3368 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous |
|
3380 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous | |
3369 | on' so that the first tab completes. |
|
3381 | on' so that the first tab completes. | |
3370 | (InteractiveShell.handle_magic): fixed bug with spaces around |
|
3382 | (InteractiveShell.handle_magic): fixed bug with spaces around | |
3371 | quotes breaking many magic commands. |
|
3383 | quotes breaking many magic commands. | |
3372 |
|
3384 | |||
3373 | * setup.py: added note about ignoring the syntax error messages at |
|
3385 | * setup.py: added note about ignoring the syntax error messages at | |
3374 | installation. |
|
3386 | installation. | |
3375 |
|
3387 | |||
3376 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished |
|
3388 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished | |
3377 | streamlining the gnuplot interface, now there's only one magic @gp. |
|
3389 | streamlining the gnuplot interface, now there's only one magic @gp. | |
3378 |
|
3390 | |||
3379 | 2002-03-17 Fernando Perez <fperez@colorado.edu> |
|
3391 | 2002-03-17 Fernando Perez <fperez@colorado.edu> | |
3380 |
|
3392 | |||
3381 | * IPython/UserConfig/magic_gnuplot.py: new name for the |
|
3393 | * IPython/UserConfig/magic_gnuplot.py: new name for the | |
3382 | example-magic_pm.py file. Much enhanced system, now with a shell |
|
3394 | example-magic_pm.py file. Much enhanced system, now with a shell | |
3383 | for communicating directly with gnuplot, one command at a time. |
|
3395 | for communicating directly with gnuplot, one command at a time. | |
3384 |
|
3396 | |||
3385 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent |
|
3397 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent | |
3386 | setting __name__=='__main__'. |
|
3398 | setting __name__=='__main__'. | |
3387 |
|
3399 | |||
3388 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added |
|
3400 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added | |
3389 | mini-shell for accessing gnuplot from inside ipython. Should |
|
3401 | mini-shell for accessing gnuplot from inside ipython. Should | |
3390 | extend it later for grace access too. Inspired by Arnd's |
|
3402 | extend it later for grace access too. Inspired by Arnd's | |
3391 | suggestion. |
|
3403 | suggestion. | |
3392 |
|
3404 | |||
3393 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when |
|
3405 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when | |
3394 | calling magic functions with () in their arguments. Thanks to Arnd |
|
3406 | calling magic functions with () in their arguments. Thanks to Arnd | |
3395 | Baecker for pointing this to me. |
|
3407 | Baecker for pointing this to me. | |
3396 |
|
3408 | |||
3397 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse |
|
3409 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse | |
3398 | infinitely for integer or complex arrays (only worked with floats). |
|
3410 | infinitely for integer or complex arrays (only worked with floats). | |
3399 |
|
3411 | |||
3400 | 2002-03-16 Fernando Perez <fperez@colorado.edu> |
|
3412 | 2002-03-16 Fernando Perez <fperez@colorado.edu> | |
3401 |
|
3413 | |||
3402 | * setup.py: Merged setup and setup_windows into a single script |
|
3414 | * setup.py: Merged setup and setup_windows into a single script | |
3403 | which properly handles things for windows users. |
|
3415 | which properly handles things for windows users. | |
3404 |
|
3416 | |||
3405 | 2002-03-15 Fernando Perez <fperez@colorado.edu> |
|
3417 | 2002-03-15 Fernando Perez <fperez@colorado.edu> | |
3406 |
|
3418 | |||
3407 | * Big change to the manual: now the magics are all automatically |
|
3419 | * Big change to the manual: now the magics are all automatically | |
3408 | documented. This information is generated from their docstrings |
|
3420 | documented. This information is generated from their docstrings | |
3409 | and put in a latex file included by the manual lyx file. This way |
|
3421 | and put in a latex file included by the manual lyx file. This way | |
3410 | we get always up to date information for the magics. The manual |
|
3422 | we get always up to date information for the magics. The manual | |
3411 | now also has proper version information, also auto-synced. |
|
3423 | now also has proper version information, also auto-synced. | |
3412 |
|
3424 | |||
3413 | For this to work, an undocumented --magic_docstrings option was added. |
|
3425 | For this to work, an undocumented --magic_docstrings option was added. | |
3414 |
|
3426 | |||
3415 | 2002-03-13 Fernando Perez <fperez@colorado.edu> |
|
3427 | 2002-03-13 Fernando Perez <fperez@colorado.edu> | |
3416 |
|
3428 | |||
3417 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors |
|
3429 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors | |
3418 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. |
|
3430 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. | |
3419 |
|
3431 | |||
3420 | 2002-03-12 Fernando Perez <fperez@colorado.edu> |
|
3432 | 2002-03-12 Fernando Perez <fperez@colorado.edu> | |
3421 |
|
3433 | |||
3422 | * IPython/ultraTB.py (TermColors): changed color escapes again to |
|
3434 | * IPython/ultraTB.py (TermColors): changed color escapes again to | |
3423 | fix the (old, reintroduced) line-wrapping bug. Basically, if |
|
3435 | fix the (old, reintroduced) line-wrapping bug. Basically, if | |
3424 | \001..\002 aren't given in the color escapes, lines get wrapped |
|
3436 | \001..\002 aren't given in the color escapes, lines get wrapped | |
3425 | weirdly. But giving those screws up old xterms and emacs terms. So |
|
3437 | weirdly. But giving those screws up old xterms and emacs terms. So | |
3426 | I added some logic for emacs terms to be ok, but I can't identify old |
|
3438 | I added some logic for emacs terms to be ok, but I can't identify old | |
3427 | xterms separately ($TERM=='xterm' for many terminals, like konsole). |
|
3439 | xterms separately ($TERM=='xterm' for many terminals, like konsole). | |
3428 |
|
3440 | |||
3429 | 2002-03-10 Fernando Perez <fperez@colorado.edu> |
|
3441 | 2002-03-10 Fernando Perez <fperez@colorado.edu> | |
3430 |
|
3442 | |||
3431 | * IPython/usage.py (__doc__): Various documentation cleanups and |
|
3443 | * IPython/usage.py (__doc__): Various documentation cleanups and | |
3432 | updates, both in usage docstrings and in the manual. |
|
3444 | updates, both in usage docstrings and in the manual. | |
3433 |
|
3445 | |||
3434 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for |
|
3446 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for | |
3435 | handling of caching. Set minimum acceptabe value for having a |
|
3447 | handling of caching. Set minimum acceptabe value for having a | |
3436 | cache at 20 values. |
|
3448 | cache at 20 values. | |
3437 |
|
3449 | |||
3438 | * IPython/iplib.py (InteractiveShell.user_setup): moved the |
|
3450 | * IPython/iplib.py (InteractiveShell.user_setup): moved the | |
3439 | install_first_time function to a method, renamed it and added an |
|
3451 | install_first_time function to a method, renamed it and added an | |
3440 | 'upgrade' mode. Now people can update their config directory with |
|
3452 | 'upgrade' mode. Now people can update their config directory with | |
3441 | a simple command line switch (-upgrade, also new). |
|
3453 | a simple command line switch (-upgrade, also new). | |
3442 |
|
3454 | |||
3443 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to |
|
3455 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to | |
3444 | @file (convenient for automagic users under Python >= 2.2). |
|
3456 | @file (convenient for automagic users under Python >= 2.2). | |
3445 | Removed @files (it seemed more like a plural than an abbrev. of |
|
3457 | Removed @files (it seemed more like a plural than an abbrev. of | |
3446 | 'file show'). |
|
3458 | 'file show'). | |
3447 |
|
3459 | |||
3448 | * IPython/iplib.py (install_first_time): Fixed crash if there were |
|
3460 | * IPython/iplib.py (install_first_time): Fixed crash if there were | |
3449 | backup files ('~') in .ipython/ install directory. |
|
3461 | backup files ('~') in .ipython/ install directory. | |
3450 |
|
3462 | |||
3451 | * IPython/ipmaker.py (make_IPython): fixes for new prompt |
|
3463 | * IPython/ipmaker.py (make_IPython): fixes for new prompt | |
3452 | system. Things look fine, but these changes are fairly |
|
3464 | system. Things look fine, but these changes are fairly | |
3453 | intrusive. Test them for a few days. |
|
3465 | intrusive. Test them for a few days. | |
3454 |
|
3466 | |||
3455 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of |
|
3467 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of | |
3456 | the prompts system. Now all in/out prompt strings are user |
|
3468 | the prompts system. Now all in/out prompt strings are user | |
3457 | controllable. This is particularly useful for embedding, as one |
|
3469 | controllable. This is particularly useful for embedding, as one | |
3458 | can tag embedded instances with particular prompts. |
|
3470 | can tag embedded instances with particular prompts. | |
3459 |
|
3471 | |||
3460 | Also removed global use of sys.ps1/2, which now allows nested |
|
3472 | Also removed global use of sys.ps1/2, which now allows nested | |
3461 | embeddings without any problems. Added command-line options for |
|
3473 | embeddings without any problems. Added command-line options for | |
3462 | the prompt strings. |
|
3474 | the prompt strings. | |
3463 |
|
3475 | |||
3464 | 2002-03-08 Fernando Perez <fperez@colorado.edu> |
|
3476 | 2002-03-08 Fernando Perez <fperez@colorado.edu> | |
3465 |
|
3477 | |||
3466 | * IPython/UserConfig/example-embed-short.py (ipshell): added |
|
3478 | * IPython/UserConfig/example-embed-short.py (ipshell): added | |
3467 | example file with the bare minimum code for embedding. |
|
3479 | example file with the bare minimum code for embedding. | |
3468 |
|
3480 | |||
3469 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added |
|
3481 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added | |
3470 | functionality for the embeddable shell to be activated/deactivated |
|
3482 | functionality for the embeddable shell to be activated/deactivated | |
3471 | either globally or at each call. |
|
3483 | either globally or at each call. | |
3472 |
|
3484 | |||
3473 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of |
|
3485 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of | |
3474 | rewriting the prompt with '--->' for auto-inputs with proper |
|
3486 | rewriting the prompt with '--->' for auto-inputs with proper | |
3475 | coloring. Now the previous UGLY hack in handle_auto() is gone, and |
|
3487 | coloring. Now the previous UGLY hack in handle_auto() is gone, and | |
3476 | this is handled by the prompts class itself, as it should. |
|
3488 | this is handled by the prompts class itself, as it should. | |
3477 |
|
3489 | |||
3478 | 2002-03-05 Fernando Perez <fperez@colorado.edu> |
|
3490 | 2002-03-05 Fernando Perez <fperez@colorado.edu> | |
3479 |
|
3491 | |||
3480 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to |
|
3492 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to | |
3481 | @logstart to avoid name clashes with the math log function. |
|
3493 | @logstart to avoid name clashes with the math log function. | |
3482 |
|
3494 | |||
3483 | * Big updates to X/Emacs section of the manual. |
|
3495 | * Big updates to X/Emacs section of the manual. | |
3484 |
|
3496 | |||
3485 | * Removed ipython_emacs. Milan explained to me how to pass |
|
3497 | * Removed ipython_emacs. Milan explained to me how to pass | |
3486 | arguments to ipython through Emacs. Some day I'm going to end up |
|
3498 | arguments to ipython through Emacs. Some day I'm going to end up | |
3487 | learning some lisp... |
|
3499 | learning some lisp... | |
3488 |
|
3500 | |||
3489 | 2002-03-04 Fernando Perez <fperez@colorado.edu> |
|
3501 | 2002-03-04 Fernando Perez <fperez@colorado.edu> | |
3490 |
|
3502 | |||
3491 | * IPython/ipython_emacs: Created script to be used as the |
|
3503 | * IPython/ipython_emacs: Created script to be used as the | |
3492 | py-python-command Emacs variable so we can pass IPython |
|
3504 | py-python-command Emacs variable so we can pass IPython | |
3493 | parameters. I can't figure out how to tell Emacs directly to pass |
|
3505 | parameters. I can't figure out how to tell Emacs directly to pass | |
3494 | parameters to IPython, so a dummy shell script will do it. |
|
3506 | parameters to IPython, so a dummy shell script will do it. | |
3495 |
|
3507 | |||
3496 | Other enhancements made for things to work better under Emacs' |
|
3508 | Other enhancements made for things to work better under Emacs' | |
3497 | various types of terminals. Many thanks to Milan Zamazal |
|
3509 | various types of terminals. Many thanks to Milan Zamazal | |
3498 | <pdm-AT-zamazal.org> for all the suggestions and pointers. |
|
3510 | <pdm-AT-zamazal.org> for all the suggestions and pointers. | |
3499 |
|
3511 | |||
3500 | 2002-03-01 Fernando Perez <fperez@colorado.edu> |
|
3512 | 2002-03-01 Fernando Perez <fperez@colorado.edu> | |
3501 |
|
3513 | |||
3502 | * IPython/ipmaker.py (make_IPython): added a --readline! option so |
|
3514 | * IPython/ipmaker.py (make_IPython): added a --readline! option so | |
3503 | that loading of readline is now optional. This gives better |
|
3515 | that loading of readline is now optional. This gives better | |
3504 | control to emacs users. |
|
3516 | control to emacs users. | |
3505 |
|
3517 | |||
3506 | * IPython/ultraTB.py (__date__): Modified color escape sequences |
|
3518 | * IPython/ultraTB.py (__date__): Modified color escape sequences | |
3507 | and now things work fine under xterm and in Emacs' term buffers |
|
3519 | and now things work fine under xterm and in Emacs' term buffers | |
3508 | (though not shell ones). Well, in emacs you get colors, but all |
|
3520 | (though not shell ones). Well, in emacs you get colors, but all | |
3509 | seem to be 'light' colors (no difference between dark and light |
|
3521 | seem to be 'light' colors (no difference between dark and light | |
3510 | ones). But the garbage chars are gone, and also in xterms. It |
|
3522 | ones). But the garbage chars are gone, and also in xterms. It | |
3511 | seems that now I'm using 'cleaner' ansi sequences. |
|
3523 | seems that now I'm using 'cleaner' ansi sequences. | |
3512 |
|
3524 | |||
3513 | 2002-02-21 Fernando Perez <fperez@colorado.edu> |
|
3525 | 2002-02-21 Fernando Perez <fperez@colorado.edu> | |
3514 |
|
3526 | |||
3515 | * Released 0.2.7 (mainly to publish the scoping fix). |
|
3527 | * Released 0.2.7 (mainly to publish the scoping fix). | |
3516 |
|
3528 | |||
3517 | * IPython/Logger.py (Logger.logstate): added. A corresponding |
|
3529 | * IPython/Logger.py (Logger.logstate): added. A corresponding | |
3518 | @logstate magic was created. |
|
3530 | @logstate magic was created. | |
3519 |
|
3531 | |||
3520 | * IPython/Magic.py: fixed nested scoping problem under Python |
|
3532 | * IPython/Magic.py: fixed nested scoping problem under Python | |
3521 | 2.1.x (automagic wasn't working). |
|
3533 | 2.1.x (automagic wasn't working). | |
3522 |
|
3534 | |||
3523 | 2002-02-20 Fernando Perez <fperez@colorado.edu> |
|
3535 | 2002-02-20 Fernando Perez <fperez@colorado.edu> | |
3524 |
|
3536 | |||
3525 | * Released 0.2.6. |
|
3537 | * Released 0.2.6. | |
3526 |
|
3538 | |||
3527 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' |
|
3539 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' | |
3528 | option so that logs can come out without any headers at all. |
|
3540 | option so that logs can come out without any headers at all. | |
3529 |
|
3541 | |||
3530 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for |
|
3542 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for | |
3531 | SciPy. |
|
3543 | SciPy. | |
3532 |
|
3544 | |||
3533 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so |
|
3545 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so | |
3534 | that embedded IPython calls don't require vars() to be explicitly |
|
3546 | that embedded IPython calls don't require vars() to be explicitly | |
3535 | passed. Now they are extracted from the caller's frame (code |
|
3547 | passed. Now they are extracted from the caller's frame (code | |
3536 | snatched from Eric Jones' weave). Added better documentation to |
|
3548 | snatched from Eric Jones' weave). Added better documentation to | |
3537 | the section on embedding and the example file. |
|
3549 | the section on embedding and the example file. | |
3538 |
|
3550 | |||
3539 | * IPython/genutils.py (page): Changed so that under emacs, it just |
|
3551 | * IPython/genutils.py (page): Changed so that under emacs, it just | |
3540 | prints the string. You can then page up and down in the emacs |
|
3552 | prints the string. You can then page up and down in the emacs | |
3541 | buffer itself. This is how the builtin help() works. |
|
3553 | buffer itself. This is how the builtin help() works. | |
3542 |
|
3554 | |||
3543 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with |
|
3555 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with | |
3544 | macro scoping: macros need to be executed in the user's namespace |
|
3556 | macro scoping: macros need to be executed in the user's namespace | |
3545 | to work as if they had been typed by the user. |
|
3557 | to work as if they had been typed by the user. | |
3546 |
|
3558 | |||
3547 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they |
|
3559 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they | |
3548 | execute automatically (no need to type 'exec...'). They then |
|
3560 | execute automatically (no need to type 'exec...'). They then | |
3549 | behave like 'true macros'. The printing system was also modified |
|
3561 | behave like 'true macros'. The printing system was also modified | |
3550 | for this to work. |
|
3562 | for this to work. | |
3551 |
|
3563 | |||
3552 | 2002-02-19 Fernando Perez <fperez@colorado.edu> |
|
3564 | 2002-02-19 Fernando Perez <fperez@colorado.edu> | |
3553 |
|
3565 | |||
3554 | * IPython/genutils.py (page_file): new function for paging files |
|
3566 | * IPython/genutils.py (page_file): new function for paging files | |
3555 | in an OS-independent way. Also necessary for file viewing to work |
|
3567 | in an OS-independent way. Also necessary for file viewing to work | |
3556 | well inside Emacs buffers. |
|
3568 | well inside Emacs buffers. | |
3557 | (page): Added checks for being in an emacs buffer. |
|
3569 | (page): Added checks for being in an emacs buffer. | |
3558 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed |
|
3570 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed | |
3559 | same bug in iplib. |
|
3571 | same bug in iplib. | |
3560 |
|
3572 | |||
3561 | 2002-02-18 Fernando Perez <fperez@colorado.edu> |
|
3573 | 2002-02-18 Fernando Perez <fperez@colorado.edu> | |
3562 |
|
3574 | |||
3563 | * IPython/iplib.py (InteractiveShell.init_readline): modified use |
|
3575 | * IPython/iplib.py (InteractiveShell.init_readline): modified use | |
3564 | of readline so that IPython can work inside an Emacs buffer. |
|
3576 | of readline so that IPython can work inside an Emacs buffer. | |
3565 |
|
3577 | |||
3566 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to |
|
3578 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to | |
3567 | method signatures (they weren't really bugs, but it looks cleaner |
|
3579 | method signatures (they weren't really bugs, but it looks cleaner | |
3568 | and keeps PyChecker happy). |
|
3580 | and keeps PyChecker happy). | |
3569 |
|
3581 | |||
3570 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP |
|
3582 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP | |
3571 | for implementing various user-defined hooks. Currently only |
|
3583 | for implementing various user-defined hooks. Currently only | |
3572 | display is done. |
|
3584 | display is done. | |
3573 |
|
3585 | |||
3574 | * IPython/Prompts.py (CachedOutput._display): changed display |
|
3586 | * IPython/Prompts.py (CachedOutput._display): changed display | |
3575 | functions so that they can be dynamically changed by users easily. |
|
3587 | functions so that they can be dynamically changed by users easily. | |
3576 |
|
3588 | |||
3577 | * IPython/Extensions/numeric_formats.py (num_display): added an |
|
3589 | * IPython/Extensions/numeric_formats.py (num_display): added an | |
3578 | extension for printing NumPy arrays in flexible manners. It |
|
3590 | extension for printing NumPy arrays in flexible manners. It | |
3579 | doesn't do anything yet, but all the structure is in |
|
3591 | doesn't do anything yet, but all the structure is in | |
3580 | place. Ultimately the plan is to implement output format control |
|
3592 | place. Ultimately the plan is to implement output format control | |
3581 | like in Octave. |
|
3593 | like in Octave. | |
3582 |
|
3594 | |||
3583 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic |
|
3595 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic | |
3584 | methods are found at run-time by all the automatic machinery. |
|
3596 | methods are found at run-time by all the automatic machinery. | |
3585 |
|
3597 | |||
3586 | 2002-02-17 Fernando Perez <fperez@colorado.edu> |
|
3598 | 2002-02-17 Fernando Perez <fperez@colorado.edu> | |
3587 |
|
3599 | |||
3588 | * setup_Windows.py (make_shortcut): documented. Cleaned up the |
|
3600 | * setup_Windows.py (make_shortcut): documented. Cleaned up the | |
3589 | whole file a little. |
|
3601 | whole file a little. | |
3590 |
|
3602 | |||
3591 | * ToDo: closed this document. Now there's a new_design.lyx |
|
3603 | * ToDo: closed this document. Now there's a new_design.lyx | |
3592 | document for all new ideas. Added making a pdf of it for the |
|
3604 | document for all new ideas. Added making a pdf of it for the | |
3593 | end-user distro. |
|
3605 | end-user distro. | |
3594 |
|
3606 | |||
3595 | * IPython/Logger.py (Logger.switch_log): Created this to replace |
|
3607 | * IPython/Logger.py (Logger.switch_log): Created this to replace | |
3596 | logon() and logoff(). It also fixes a nasty crash reported by |
|
3608 | logon() and logoff(). It also fixes a nasty crash reported by | |
3597 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. |
|
3609 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. | |
3598 |
|
3610 | |||
3599 | * IPython/iplib.py (complete): got auto-completion to work with |
|
3611 | * IPython/iplib.py (complete): got auto-completion to work with | |
3600 | automagic (I had wanted this for a long time). |
|
3612 | automagic (I had wanted this for a long time). | |
3601 |
|
3613 | |||
3602 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias |
|
3614 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias | |
3603 | to @file, since file() is now a builtin and clashes with automagic |
|
3615 | to @file, since file() is now a builtin and clashes with automagic | |
3604 | for @file. |
|
3616 | for @file. | |
3605 |
|
3617 | |||
3606 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All |
|
3618 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All | |
3607 | of this was previously in iplib, which had grown to more than 2000 |
|
3619 | of this was previously in iplib, which had grown to more than 2000 | |
3608 | lines, way too long. No new functionality, but it makes managing |
|
3620 | lines, way too long. No new functionality, but it makes managing | |
3609 | the code a bit easier. |
|
3621 | the code a bit easier. | |
3610 |
|
3622 | |||
3611 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version |
|
3623 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version | |
3612 | information to crash reports. |
|
3624 | information to crash reports. | |
3613 |
|
3625 | |||
3614 | 2002-02-12 Fernando Perez <fperez@colorado.edu> |
|
3626 | 2002-02-12 Fernando Perez <fperez@colorado.edu> | |
3615 |
|
3627 | |||
3616 | * Released 0.2.5. |
|
3628 | * Released 0.2.5. | |
3617 |
|
3629 | |||
3618 | 2002-02-11 Fernando Perez <fperez@colorado.edu> |
|
3630 | 2002-02-11 Fernando Perez <fperez@colorado.edu> | |
3619 |
|
3631 | |||
3620 | * Wrote a relatively complete Windows installer. It puts |
|
3632 | * Wrote a relatively complete Windows installer. It puts | |
3621 | everything in place, creates Start Menu entries and fixes the |
|
3633 | everything in place, creates Start Menu entries and fixes the | |
3622 | color issues. Nothing fancy, but it works. |
|
3634 | color issues. Nothing fancy, but it works. | |
3623 |
|
3635 | |||
3624 | 2002-02-10 Fernando Perez <fperez@colorado.edu> |
|
3636 | 2002-02-10 Fernando Perez <fperez@colorado.edu> | |
3625 |
|
3637 | |||
3626 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an |
|
3638 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an | |
3627 | os.path.expanduser() call so that we can type @run ~/myfile.py and |
|
3639 | os.path.expanduser() call so that we can type @run ~/myfile.py and | |
3628 | have thigs work as expected. |
|
3640 | have thigs work as expected. | |
3629 |
|
3641 | |||
3630 | * IPython/genutils.py (page): fixed exception handling so things |
|
3642 | * IPython/genutils.py (page): fixed exception handling so things | |
3631 | work both in Unix and Windows correctly. Quitting a pager triggers |
|
3643 | work both in Unix and Windows correctly. Quitting a pager triggers | |
3632 | an IOError/broken pipe in Unix, and in windows not finding a pager |
|
3644 | an IOError/broken pipe in Unix, and in windows not finding a pager | |
3633 | is also an IOError, so I had to actually look at the return value |
|
3645 | is also an IOError, so I had to actually look at the return value | |
3634 | of the exception, not just the exception itself. Should be ok now. |
|
3646 | of the exception, not just the exception itself. Should be ok now. | |
3635 |
|
3647 | |||
3636 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): |
|
3648 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): | |
3637 | modified to allow case-insensitive color scheme changes. |
|
3649 | modified to allow case-insensitive color scheme changes. | |
3638 |
|
3650 | |||
3639 | 2002-02-09 Fernando Perez <fperez@colorado.edu> |
|
3651 | 2002-02-09 Fernando Perez <fperez@colorado.edu> | |
3640 |
|
3652 | |||
3641 | * IPython/genutils.py (native_line_ends): new function to leave |
|
3653 | * IPython/genutils.py (native_line_ends): new function to leave | |
3642 | user config files with os-native line-endings. |
|
3654 | user config files with os-native line-endings. | |
3643 |
|
3655 | |||
3644 | * README and manual updates. |
|
3656 | * README and manual updates. | |
3645 |
|
3657 | |||
3646 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes |
|
3658 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes | |
3647 | instead of StringType to catch Unicode strings. |
|
3659 | instead of StringType to catch Unicode strings. | |
3648 |
|
3660 | |||
3649 | * IPython/genutils.py (filefind): fixed bug for paths with |
|
3661 | * IPython/genutils.py (filefind): fixed bug for paths with | |
3650 | embedded spaces (very common in Windows). |
|
3662 | embedded spaces (very common in Windows). | |
3651 |
|
3663 | |||
3652 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc |
|
3664 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc | |
3653 | files under Windows, so that they get automatically associated |
|
3665 | files under Windows, so that they get automatically associated | |
3654 | with a text editor. Windows makes it a pain to handle |
|
3666 | with a text editor. Windows makes it a pain to handle | |
3655 | extension-less files. |
|
3667 | extension-less files. | |
3656 |
|
3668 | |||
3657 | * IPython/iplib.py (InteractiveShell.init_readline): Made the |
|
3669 | * IPython/iplib.py (InteractiveShell.init_readline): Made the | |
3658 | warning about readline only occur for Posix. In Windows there's no |
|
3670 | warning about readline only occur for Posix. In Windows there's no | |
3659 | way to get readline, so why bother with the warning. |
|
3671 | way to get readline, so why bother with the warning. | |
3660 |
|
3672 | |||
3661 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ |
|
3673 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ | |
3662 | for __str__ instead of dir(self), since dir() changed in 2.2. |
|
3674 | for __str__ instead of dir(self), since dir() changed in 2.2. | |
3663 |
|
3675 | |||
3664 | * Ported to Windows! Tested on XP, I suspect it should work fine |
|
3676 | * Ported to Windows! Tested on XP, I suspect it should work fine | |
3665 | on NT/2000, but I don't think it will work on 98 et al. That |
|
3677 | on NT/2000, but I don't think it will work on 98 et al. That | |
3666 | series of Windows is such a piece of junk anyway that I won't try |
|
3678 | series of Windows is such a piece of junk anyway that I won't try | |
3667 | porting it there. The XP port was straightforward, showed a few |
|
3679 | porting it there. The XP port was straightforward, showed a few | |
3668 | bugs here and there (fixed all), in particular some string |
|
3680 | bugs here and there (fixed all), in particular some string | |
3669 | handling stuff which required considering Unicode strings (which |
|
3681 | handling stuff which required considering Unicode strings (which | |
3670 | Windows uses). This is good, but hasn't been too tested :) No |
|
3682 | Windows uses). This is good, but hasn't been too tested :) No | |
3671 | fancy installer yet, I'll put a note in the manual so people at |
|
3683 | fancy installer yet, I'll put a note in the manual so people at | |
3672 | least make manually a shortcut. |
|
3684 | least make manually a shortcut. | |
3673 |
|
3685 | |||
3674 | * IPython/iplib.py (Magic.magic_colors): Unified the color options |
|
3686 | * IPython/iplib.py (Magic.magic_colors): Unified the color options | |
3675 | into a single one, "colors". This now controls both prompt and |
|
3687 | into a single one, "colors". This now controls both prompt and | |
3676 | exception color schemes, and can be changed both at startup |
|
3688 | exception color schemes, and can be changed both at startup | |
3677 | (either via command-line switches or via ipythonrc files) and at |
|
3689 | (either via command-line switches or via ipythonrc files) and at | |
3678 | runtime, with @colors. |
|
3690 | runtime, with @colors. | |
3679 | (Magic.magic_run): renamed @prun to @run and removed the old |
|
3691 | (Magic.magic_run): renamed @prun to @run and removed the old | |
3680 | @run. The two were too similar to warrant keeping both. |
|
3692 | @run. The two were too similar to warrant keeping both. | |
3681 |
|
3693 | |||
3682 | 2002-02-03 Fernando Perez <fperez@colorado.edu> |
|
3694 | 2002-02-03 Fernando Perez <fperez@colorado.edu> | |
3683 |
|
3695 | |||
3684 | * IPython/iplib.py (install_first_time): Added comment on how to |
|
3696 | * IPython/iplib.py (install_first_time): Added comment on how to | |
3685 | configure the color options for first-time users. Put a <return> |
|
3697 | configure the color options for first-time users. Put a <return> | |
3686 | request at the end so that small-terminal users get a chance to |
|
3698 | request at the end so that small-terminal users get a chance to | |
3687 | read the startup info. |
|
3699 | read the startup info. | |
3688 |
|
3700 | |||
3689 | 2002-01-23 Fernando Perez <fperez@colorado.edu> |
|
3701 | 2002-01-23 Fernando Perez <fperez@colorado.edu> | |
3690 |
|
3702 | |||
3691 | * IPython/iplib.py (CachedOutput.update): Changed output memory |
|
3703 | * IPython/iplib.py (CachedOutput.update): Changed output memory | |
3692 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For |
|
3704 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For | |
3693 | input history we still use _i. Did this b/c these variable are |
|
3705 | input history we still use _i. Did this b/c these variable are | |
3694 | very commonly used in interactive work, so the less we need to |
|
3706 | very commonly used in interactive work, so the less we need to | |
3695 | type the better off we are. |
|
3707 | type the better off we are. | |
3696 | (Magic.magic_prun): updated @prun to better handle the namespaces |
|
3708 | (Magic.magic_prun): updated @prun to better handle the namespaces | |
3697 | the file will run in, including a fix for __name__ not being set |
|
3709 | the file will run in, including a fix for __name__ not being set | |
3698 | before. |
|
3710 | before. | |
3699 |
|
3711 | |||
3700 | 2002-01-20 Fernando Perez <fperez@colorado.edu> |
|
3712 | 2002-01-20 Fernando Perez <fperez@colorado.edu> | |
3701 |
|
3713 | |||
3702 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of |
|
3714 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of | |
3703 | extra garbage for Python 2.2. Need to look more carefully into |
|
3715 | extra garbage for Python 2.2. Need to look more carefully into | |
3704 | this later. |
|
3716 | this later. | |
3705 |
|
3717 | |||
3706 | 2002-01-19 Fernando Perez <fperez@colorado.edu> |
|
3718 | 2002-01-19 Fernando Perez <fperez@colorado.edu> | |
3707 |
|
3719 | |||
3708 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to |
|
3720 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to | |
3709 | display SyntaxError exceptions properly formatted when they occur |
|
3721 | display SyntaxError exceptions properly formatted when they occur | |
3710 | (they can be triggered by imported code). |
|
3722 | (they can be triggered by imported code). | |
3711 |
|
3723 | |||
3712 | 2002-01-18 Fernando Perez <fperez@colorado.edu> |
|
3724 | 2002-01-18 Fernando Perez <fperez@colorado.edu> | |
3713 |
|
3725 | |||
3714 | * IPython/iplib.py (InteractiveShell.safe_execfile): now |
|
3726 | * IPython/iplib.py (InteractiveShell.safe_execfile): now | |
3715 | SyntaxError exceptions are reported nicely formatted, instead of |
|
3727 | SyntaxError exceptions are reported nicely formatted, instead of | |
3716 | spitting out only offset information as before. |
|
3728 | spitting out only offset information as before. | |
3717 | (Magic.magic_prun): Added the @prun function for executing |
|
3729 | (Magic.magic_prun): Added the @prun function for executing | |
3718 | programs with command line args inside IPython. |
|
3730 | programs with command line args inside IPython. | |
3719 |
|
3731 | |||
3720 | 2002-01-16 Fernando Perez <fperez@colorado.edu> |
|
3732 | 2002-01-16 Fernando Perez <fperez@colorado.edu> | |
3721 |
|
3733 | |||
3722 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist |
|
3734 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist | |
3723 | to *not* include the last item given in a range. This brings their |
|
3735 | to *not* include the last item given in a range. This brings their | |
3724 | behavior in line with Python's slicing: |
|
3736 | behavior in line with Python's slicing: | |
3725 | a[n1:n2] -> a[n1]...a[n2-1] |
|
3737 | a[n1:n2] -> a[n1]...a[n2-1] | |
3726 | It may be a bit less convenient, but I prefer to stick to Python's |
|
3738 | It may be a bit less convenient, but I prefer to stick to Python's | |
3727 | conventions *everywhere*, so users never have to wonder. |
|
3739 | conventions *everywhere*, so users never have to wonder. | |
3728 | (Magic.magic_macro): Added @macro function to ease the creation of |
|
3740 | (Magic.magic_macro): Added @macro function to ease the creation of | |
3729 | macros. |
|
3741 | macros. | |
3730 |
|
3742 | |||
3731 | 2002-01-05 Fernando Perez <fperez@colorado.edu> |
|
3743 | 2002-01-05 Fernando Perez <fperez@colorado.edu> | |
3732 |
|
3744 | |||
3733 | * Released 0.2.4. |
|
3745 | * Released 0.2.4. | |
3734 |
|
3746 | |||
3735 | * IPython/iplib.py (Magic.magic_pdef): |
|
3747 | * IPython/iplib.py (Magic.magic_pdef): | |
3736 | (InteractiveShell.safe_execfile): report magic lines and error |
|
3748 | (InteractiveShell.safe_execfile): report magic lines and error | |
3737 | lines without line numbers so one can easily copy/paste them for |
|
3749 | lines without line numbers so one can easily copy/paste them for | |
3738 | re-execution. |
|
3750 | re-execution. | |
3739 |
|
3751 | |||
3740 | * Updated manual with recent changes. |
|
3752 | * Updated manual with recent changes. | |
3741 |
|
3753 | |||
3742 | * IPython/iplib.py (Magic.magic_oinfo): added constructor |
|
3754 | * IPython/iplib.py (Magic.magic_oinfo): added constructor | |
3743 | docstring printing when class? is called. Very handy for knowing |
|
3755 | docstring printing when class? is called. Very handy for knowing | |
3744 | how to create class instances (as long as __init__ is well |
|
3756 | how to create class instances (as long as __init__ is well | |
3745 | documented, of course :) |
|
3757 | documented, of course :) | |
3746 | (Magic.magic_doc): print both class and constructor docstrings. |
|
3758 | (Magic.magic_doc): print both class and constructor docstrings. | |
3747 | (Magic.magic_pdef): give constructor info if passed a class and |
|
3759 | (Magic.magic_pdef): give constructor info if passed a class and | |
3748 | __call__ info for callable object instances. |
|
3760 | __call__ info for callable object instances. | |
3749 |
|
3761 | |||
3750 | 2002-01-04 Fernando Perez <fperez@colorado.edu> |
|
3762 | 2002-01-04 Fernando Perez <fperez@colorado.edu> | |
3751 |
|
3763 | |||
3752 | * Made deep_reload() off by default. It doesn't always work |
|
3764 | * Made deep_reload() off by default. It doesn't always work | |
3753 | exactly as intended, so it's probably safer to have it off. It's |
|
3765 | exactly as intended, so it's probably safer to have it off. It's | |
3754 | still available as dreload() anyway, so nothing is lost. |
|
3766 | still available as dreload() anyway, so nothing is lost. | |
3755 |
|
3767 | |||
3756 | 2002-01-02 Fernando Perez <fperez@colorado.edu> |
|
3768 | 2002-01-02 Fernando Perez <fperez@colorado.edu> | |
3757 |
|
3769 | |||
3758 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, |
|
3770 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, | |
3759 | so I wanted an updated release). |
|
3771 | so I wanted an updated release). | |
3760 |
|
3772 | |||
3761 | 2001-12-27 Fernando Perez <fperez@colorado.edu> |
|
3773 | 2001-12-27 Fernando Perez <fperez@colorado.edu> | |
3762 |
|
3774 | |||
3763 | * IPython/iplib.py (InteractiveShell.interact): Added the original |
|
3775 | * IPython/iplib.py (InteractiveShell.interact): Added the original | |
3764 | code from 'code.py' for this module in order to change the |
|
3776 | code from 'code.py' for this module in order to change the | |
3765 | handling of a KeyboardInterrupt. This was necessary b/c otherwise |
|
3777 | handling of a KeyboardInterrupt. This was necessary b/c otherwise | |
3766 | the history cache would break when the user hit Ctrl-C, and |
|
3778 | the history cache would break when the user hit Ctrl-C, and | |
3767 | interact() offers no way to add any hooks to it. |
|
3779 | interact() offers no way to add any hooks to it. | |
3768 |
|
3780 | |||
3769 | 2001-12-23 Fernando Perez <fperez@colorado.edu> |
|
3781 | 2001-12-23 Fernando Perez <fperez@colorado.edu> | |
3770 |
|
3782 | |||
3771 | * setup.py: added check for 'MANIFEST' before trying to remove |
|
3783 | * setup.py: added check for 'MANIFEST' before trying to remove | |
3772 | it. Thanks to Sean Reifschneider. |
|
3784 | it. Thanks to Sean Reifschneider. | |
3773 |
|
3785 | |||
3774 | 2001-12-22 Fernando Perez <fperez@colorado.edu> |
|
3786 | 2001-12-22 Fernando Perez <fperez@colorado.edu> | |
3775 |
|
3787 | |||
3776 | * Released 0.2.2. |
|
3788 | * Released 0.2.2. | |
3777 |
|
3789 | |||
3778 | * Finished (reasonably) writing the manual. Later will add the |
|
3790 | * Finished (reasonably) writing the manual. Later will add the | |
3779 | python-standard navigation stylesheets, but for the time being |
|
3791 | python-standard navigation stylesheets, but for the time being | |
3780 | it's fairly complete. Distribution will include html and pdf |
|
3792 | it's fairly complete. Distribution will include html and pdf | |
3781 | versions. |
|
3793 | versions. | |
3782 |
|
3794 | |||
3783 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu |
|
3795 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu | |
3784 | (MayaVi author). |
|
3796 | (MayaVi author). | |
3785 |
|
3797 | |||
3786 | 2001-12-21 Fernando Perez <fperez@colorado.edu> |
|
3798 | 2001-12-21 Fernando Perez <fperez@colorado.edu> | |
3787 |
|
3799 | |||
3788 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a |
|
3800 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a | |
3789 | good public release, I think (with the manual and the distutils |
|
3801 | good public release, I think (with the manual and the distutils | |
3790 | installer). The manual can use some work, but that can go |
|
3802 | installer). The manual can use some work, but that can go | |
3791 | slowly. Otherwise I think it's quite nice for end users. Next |
|
3803 | slowly. Otherwise I think it's quite nice for end users. Next | |
3792 | summer, rewrite the guts of it... |
|
3804 | summer, rewrite the guts of it... | |
3793 |
|
3805 | |||
3794 | * Changed format of ipythonrc files to use whitespace as the |
|
3806 | * Changed format of ipythonrc files to use whitespace as the | |
3795 | separator instead of an explicit '='. Cleaner. |
|
3807 | separator instead of an explicit '='. Cleaner. | |
3796 |
|
3808 | |||
3797 | 2001-12-20 Fernando Perez <fperez@colorado.edu> |
|
3809 | 2001-12-20 Fernando Perez <fperez@colorado.edu> | |
3798 |
|
3810 | |||
3799 | * Started a manual in LyX. For now it's just a quick merge of the |
|
3811 | * Started a manual in LyX. For now it's just a quick merge of the | |
3800 | various internal docstrings and READMEs. Later it may grow into a |
|
3812 | various internal docstrings and READMEs. Later it may grow into a | |
3801 | nice, full-blown manual. |
|
3813 | nice, full-blown manual. | |
3802 |
|
3814 | |||
3803 | * Set up a distutils based installer. Installation should now be |
|
3815 | * Set up a distutils based installer. Installation should now be | |
3804 | trivially simple for end-users. |
|
3816 | trivially simple for end-users. | |
3805 |
|
3817 | |||
3806 | 2001-12-11 Fernando Perez <fperez@colorado.edu> |
|
3818 | 2001-12-11 Fernando Perez <fperez@colorado.edu> | |
3807 |
|
3819 | |||
3808 | * Released 0.2.0. First public release, announced it at |
|
3820 | * Released 0.2.0. First public release, announced it at | |
3809 | comp.lang.python. From now on, just bugfixes... |
|
3821 | comp.lang.python. From now on, just bugfixes... | |
3810 |
|
3822 | |||
3811 | * Went through all the files, set copyright/license notices and |
|
3823 | * Went through all the files, set copyright/license notices and | |
3812 | cleaned up things. Ready for release. |
|
3824 | cleaned up things. Ready for release. | |
3813 |
|
3825 | |||
3814 | 2001-12-10 Fernando Perez <fperez@colorado.edu> |
|
3826 | 2001-12-10 Fernando Perez <fperez@colorado.edu> | |
3815 |
|
3827 | |||
3816 | * Changed the first-time installer not to use tarfiles. It's more |
|
3828 | * Changed the first-time installer not to use tarfiles. It's more | |
3817 | robust now and less unix-dependent. Also makes it easier for |
|
3829 | robust now and less unix-dependent. Also makes it easier for | |
3818 | people to later upgrade versions. |
|
3830 | people to later upgrade versions. | |
3819 |
|
3831 | |||
3820 | * Changed @exit to @abort to reflect the fact that it's pretty |
|
3832 | * Changed @exit to @abort to reflect the fact that it's pretty | |
3821 | brutal (a sys.exit()). The difference between @abort and Ctrl-D |
|
3833 | brutal (a sys.exit()). The difference between @abort and Ctrl-D | |
3822 | becomes significant only when IPyhton is embedded: in that case, |
|
3834 | becomes significant only when IPyhton is embedded: in that case, | |
3823 | C-D closes IPython only, but @abort kills the enclosing program |
|
3835 | C-D closes IPython only, but @abort kills the enclosing program | |
3824 | too (unless it had called IPython inside a try catching |
|
3836 | too (unless it had called IPython inside a try catching | |
3825 | SystemExit). |
|
3837 | SystemExit). | |
3826 |
|
3838 | |||
3827 | * Created Shell module which exposes the actuall IPython Shell |
|
3839 | * Created Shell module which exposes the actuall IPython Shell | |
3828 | classes, currently the normal and the embeddable one. This at |
|
3840 | classes, currently the normal and the embeddable one. This at | |
3829 | least offers a stable interface we won't need to change when |
|
3841 | least offers a stable interface we won't need to change when | |
3830 | (later) the internals are rewritten. That rewrite will be confined |
|
3842 | (later) the internals are rewritten. That rewrite will be confined | |
3831 | to iplib and ipmaker, but the Shell interface should remain as is. |
|
3843 | to iplib and ipmaker, but the Shell interface should remain as is. | |
3832 |
|
3844 | |||
3833 | * Added embed module which offers an embeddable IPShell object, |
|
3845 | * Added embed module which offers an embeddable IPShell object, | |
3834 | useful to fire up IPython *inside* a running program. Great for |
|
3846 | useful to fire up IPython *inside* a running program. Great for | |
3835 | debugging or dynamical data analysis. |
|
3847 | debugging or dynamical data analysis. | |
3836 |
|
3848 | |||
3837 | 2001-12-08 Fernando Perez <fperez@colorado.edu> |
|
3849 | 2001-12-08 Fernando Perez <fperez@colorado.edu> | |
3838 |
|
3850 | |||
3839 | * Fixed small bug preventing seeing info from methods of defined |
|
3851 | * Fixed small bug preventing seeing info from methods of defined | |
3840 | objects (incorrect namespace in _ofind()). |
|
3852 | objects (incorrect namespace in _ofind()). | |
3841 |
|
3853 | |||
3842 | * Documentation cleanup. Moved the main usage docstrings to a |
|
3854 | * Documentation cleanup. Moved the main usage docstrings to a | |
3843 | separate file, usage.py (cleaner to maintain, and hopefully in the |
|
3855 | separate file, usage.py (cleaner to maintain, and hopefully in the | |
3844 | future some perlpod-like way of producing interactive, man and |
|
3856 | future some perlpod-like way of producing interactive, man and | |
3845 | html docs out of it will be found). |
|
3857 | html docs out of it will be found). | |
3846 |
|
3858 | |||
3847 | * Added @profile to see your profile at any time. |
|
3859 | * Added @profile to see your profile at any time. | |
3848 |
|
3860 | |||
3849 | * Added @p as an alias for 'print'. It's especially convenient if |
|
3861 | * Added @p as an alias for 'print'. It's especially convenient if | |
3850 | using automagic ('p x' prints x). |
|
3862 | using automagic ('p x' prints x). | |
3851 |
|
3863 | |||
3852 | * Small cleanups and fixes after a pychecker run. |
|
3864 | * Small cleanups and fixes after a pychecker run. | |
3853 |
|
3865 | |||
3854 | * Changed the @cd command to handle @cd - and @cd -<n> for |
|
3866 | * Changed the @cd command to handle @cd - and @cd -<n> for | |
3855 | visiting any directory in _dh. |
|
3867 | visiting any directory in _dh. | |
3856 |
|
3868 | |||
3857 | * Introduced _dh, a history of visited directories. @dhist prints |
|
3869 | * Introduced _dh, a history of visited directories. @dhist prints | |
3858 | it out with numbers. |
|
3870 | it out with numbers. | |
3859 |
|
3871 | |||
3860 | 2001-12-07 Fernando Perez <fperez@colorado.edu> |
|
3872 | 2001-12-07 Fernando Perez <fperez@colorado.edu> | |
3861 |
|
3873 | |||
3862 | * Released 0.1.22 |
|
3874 | * Released 0.1.22 | |
3863 |
|
3875 | |||
3864 | * Made initialization a bit more robust against invalid color |
|
3876 | * Made initialization a bit more robust against invalid color | |
3865 | options in user input (exit, not traceback-crash). |
|
3877 | options in user input (exit, not traceback-crash). | |
3866 |
|
3878 | |||
3867 | * Changed the bug crash reporter to write the report only in the |
|
3879 | * Changed the bug crash reporter to write the report only in the | |
3868 | user's .ipython directory. That way IPython won't litter people's |
|
3880 | user's .ipython directory. That way IPython won't litter people's | |
3869 | hard disks with crash files all over the place. Also print on |
|
3881 | hard disks with crash files all over the place. Also print on | |
3870 | screen the necessary mail command. |
|
3882 | screen the necessary mail command. | |
3871 |
|
3883 | |||
3872 | * With the new ultraTB, implemented LightBG color scheme for light |
|
3884 | * With the new ultraTB, implemented LightBG color scheme for light | |
3873 | background terminals. A lot of people like white backgrounds, so I |
|
3885 | background terminals. A lot of people like white backgrounds, so I | |
3874 | guess we should at least give them something readable. |
|
3886 | guess we should at least give them something readable. | |
3875 |
|
3887 | |||
3876 | 2001-12-06 Fernando Perez <fperez@colorado.edu> |
|
3888 | 2001-12-06 Fernando Perez <fperez@colorado.edu> | |
3877 |
|
3889 | |||
3878 | * Modified the structure of ultraTB. Now there's a proper class |
|
3890 | * Modified the structure of ultraTB. Now there's a proper class | |
3879 | for tables of color schemes which allow adding schemes easily and |
|
3891 | for tables of color schemes which allow adding schemes easily and | |
3880 | switching the active scheme without creating a new instance every |
|
3892 | switching the active scheme without creating a new instance every | |
3881 | time (which was ridiculous). The syntax for creating new schemes |
|
3893 | time (which was ridiculous). The syntax for creating new schemes | |
3882 | is also cleaner. I think ultraTB is finally done, with a clean |
|
3894 | is also cleaner. I think ultraTB is finally done, with a clean | |
3883 | class structure. Names are also much cleaner (now there's proper |
|
3895 | class structure. Names are also much cleaner (now there's proper | |
3884 | color tables, no need for every variable to also have 'color' in |
|
3896 | color tables, no need for every variable to also have 'color' in | |
3885 | its name). |
|
3897 | its name). | |
3886 |
|
3898 | |||
3887 | * Broke down genutils into separate files. Now genutils only |
|
3899 | * Broke down genutils into separate files. Now genutils only | |
3888 | contains utility functions, and classes have been moved to their |
|
3900 | contains utility functions, and classes have been moved to their | |
3889 | own files (they had enough independent functionality to warrant |
|
3901 | own files (they had enough independent functionality to warrant | |
3890 | it): ConfigLoader, OutputTrap, Struct. |
|
3902 | it): ConfigLoader, OutputTrap, Struct. | |
3891 |
|
3903 | |||
3892 | 2001-12-05 Fernando Perez <fperez@colorado.edu> |
|
3904 | 2001-12-05 Fernando Perez <fperez@colorado.edu> | |
3893 |
|
3905 | |||
3894 | * IPython turns 21! Released version 0.1.21, as a candidate for |
|
3906 | * IPython turns 21! Released version 0.1.21, as a candidate for | |
3895 | public consumption. If all goes well, release in a few days. |
|
3907 | public consumption. If all goes well, release in a few days. | |
3896 |
|
3908 | |||
3897 | * Fixed path bug (files in Extensions/ directory wouldn't be found |
|
3909 | * Fixed path bug (files in Extensions/ directory wouldn't be found | |
3898 | unless IPython/ was explicitly in sys.path). |
|
3910 | unless IPython/ was explicitly in sys.path). | |
3899 |
|
3911 | |||
3900 | * Extended the FlexCompleter class as MagicCompleter to allow |
|
3912 | * Extended the FlexCompleter class as MagicCompleter to allow | |
3901 | completion of @-starting lines. |
|
3913 | completion of @-starting lines. | |
3902 |
|
3914 | |||
3903 | * Created __release__.py file as a central repository for release |
|
3915 | * Created __release__.py file as a central repository for release | |
3904 | info that other files can read from. |
|
3916 | info that other files can read from. | |
3905 |
|
3917 | |||
3906 | * Fixed small bug in logging: when logging was turned on in |
|
3918 | * Fixed small bug in logging: when logging was turned on in | |
3907 | mid-session, old lines with special meanings (!@?) were being |
|
3919 | mid-session, old lines with special meanings (!@?) were being | |
3908 | logged without the prepended comment, which is necessary since |
|
3920 | logged without the prepended comment, which is necessary since | |
3909 | they are not truly valid python syntax. This should make session |
|
3921 | they are not truly valid python syntax. This should make session | |
3910 | restores produce less errors. |
|
3922 | restores produce less errors. | |
3911 |
|
3923 | |||
3912 | * The namespace cleanup forced me to make a FlexCompleter class |
|
3924 | * The namespace cleanup forced me to make a FlexCompleter class | |
3913 | which is nothing but a ripoff of rlcompleter, but with selectable |
|
3925 | which is nothing but a ripoff of rlcompleter, but with selectable | |
3914 | namespace (rlcompleter only works in __main__.__dict__). I'll try |
|
3926 | namespace (rlcompleter only works in __main__.__dict__). I'll try | |
3915 | to submit a note to the authors to see if this change can be |
|
3927 | to submit a note to the authors to see if this change can be | |
3916 | incorporated in future rlcompleter releases (Dec.6: done) |
|
3928 | incorporated in future rlcompleter releases (Dec.6: done) | |
3917 |
|
3929 | |||
3918 | * More fixes to namespace handling. It was a mess! Now all |
|
3930 | * More fixes to namespace handling. It was a mess! Now all | |
3919 | explicit references to __main__.__dict__ are gone (except when |
|
3931 | explicit references to __main__.__dict__ are gone (except when | |
3920 | really needed) and everything is handled through the namespace |
|
3932 | really needed) and everything is handled through the namespace | |
3921 | dicts in the IPython instance. We seem to be getting somewhere |
|
3933 | dicts in the IPython instance. We seem to be getting somewhere | |
3922 | with this, finally... |
|
3934 | with this, finally... | |
3923 |
|
3935 | |||
3924 | * Small documentation updates. |
|
3936 | * Small documentation updates. | |
3925 |
|
3937 | |||
3926 | * Created the Extensions directory under IPython (with an |
|
3938 | * Created the Extensions directory under IPython (with an | |
3927 | __init__.py). Put the PhysicalQ stuff there. This directory should |
|
3939 | __init__.py). Put the PhysicalQ stuff there. This directory should | |
3928 | be used for all special-purpose extensions. |
|
3940 | be used for all special-purpose extensions. | |
3929 |
|
3941 | |||
3930 | * File renaming: |
|
3942 | * File renaming: | |
3931 | ipythonlib --> ipmaker |
|
3943 | ipythonlib --> ipmaker | |
3932 | ipplib --> iplib |
|
3944 | ipplib --> iplib | |
3933 | This makes a bit more sense in terms of what these files actually do. |
|
3945 | This makes a bit more sense in terms of what these files actually do. | |
3934 |
|
3946 | |||
3935 | * Moved all the classes and functions in ipythonlib to ipplib, so |
|
3947 | * Moved all the classes and functions in ipythonlib to ipplib, so | |
3936 | now ipythonlib only has make_IPython(). This will ease up its |
|
3948 | now ipythonlib only has make_IPython(). This will ease up its | |
3937 | splitting in smaller functional chunks later. |
|
3949 | splitting in smaller functional chunks later. | |
3938 |
|
3950 | |||
3939 | * Cleaned up (done, I think) output of @whos. Better column |
|
3951 | * Cleaned up (done, I think) output of @whos. Better column | |
3940 | formatting, and now shows str(var) for as much as it can, which is |
|
3952 | formatting, and now shows str(var) for as much as it can, which is | |
3941 | typically what one gets with a 'print var'. |
|
3953 | typically what one gets with a 'print var'. | |
3942 |
|
3954 | |||
3943 | 2001-12-04 Fernando Perez <fperez@colorado.edu> |
|
3955 | 2001-12-04 Fernando Perez <fperez@colorado.edu> | |
3944 |
|
3956 | |||
3945 | * Fixed namespace problems. Now builtin/IPyhton/user names get |
|
3957 | * Fixed namespace problems. Now builtin/IPyhton/user names get | |
3946 | properly reported in their namespace. Internal namespace handling |
|
3958 | properly reported in their namespace. Internal namespace handling | |
3947 | is finally getting decent (not perfect yet, but much better than |
|
3959 | is finally getting decent (not perfect yet, but much better than | |
3948 | the ad-hoc mess we had). |
|
3960 | the ad-hoc mess we had). | |
3949 |
|
3961 | |||
3950 | * Removed -exit option. If people just want to run a python |
|
3962 | * Removed -exit option. If people just want to run a python | |
3951 | script, that's what the normal interpreter is for. Less |
|
3963 | script, that's what the normal interpreter is for. Less | |
3952 | unnecessary options, less chances for bugs. |
|
3964 | unnecessary options, less chances for bugs. | |
3953 |
|
3965 | |||
3954 | * Added a crash handler which generates a complete post-mortem if |
|
3966 | * Added a crash handler which generates a complete post-mortem if | |
3955 | IPython crashes. This will help a lot in tracking bugs down the |
|
3967 | IPython crashes. This will help a lot in tracking bugs down the | |
3956 | road. |
|
3968 | road. | |
3957 |
|
3969 | |||
3958 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names |
|
3970 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names | |
3959 | which were boud to functions being reassigned would bypass the |
|
3971 | which were boud to functions being reassigned would bypass the | |
3960 | logger, breaking the sync of _il with the prompt counter. This |
|
3972 | logger, breaking the sync of _il with the prompt counter. This | |
3961 | would then crash IPython later when a new line was logged. |
|
3973 | would then crash IPython later when a new line was logged. | |
3962 |
|
3974 | |||
3963 | 2001-12-02 Fernando Perez <fperez@colorado.edu> |
|
3975 | 2001-12-02 Fernando Perez <fperez@colorado.edu> | |
3964 |
|
3976 | |||
3965 | * Made IPython a package. This means people don't have to clutter |
|
3977 | * Made IPython a package. This means people don't have to clutter | |
3966 | their sys.path with yet another directory. Changed the INSTALL |
|
3978 | their sys.path with yet another directory. Changed the INSTALL | |
3967 | file accordingly. |
|
3979 | file accordingly. | |
3968 |
|
3980 | |||
3969 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now |
|
3981 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now | |
3970 | sorts its output (so @who shows it sorted) and @whos formats the |
|
3982 | sorts its output (so @who shows it sorted) and @whos formats the | |
3971 | table according to the width of the first column. Nicer, easier to |
|
3983 | table according to the width of the first column. Nicer, easier to | |
3972 | read. Todo: write a generic table_format() which takes a list of |
|
3984 | read. Todo: write a generic table_format() which takes a list of | |
3973 | lists and prints it nicely formatted, with optional row/column |
|
3985 | lists and prints it nicely formatted, with optional row/column | |
3974 | separators and proper padding and justification. |
|
3986 | separators and proper padding and justification. | |
3975 |
|
3987 | |||
3976 | * Released 0.1.20 |
|
3988 | * Released 0.1.20 | |
3977 |
|
3989 | |||
3978 | * Fixed bug in @log which would reverse the inputcache list (a |
|
3990 | * Fixed bug in @log which would reverse the inputcache list (a | |
3979 | copy operation was missing). |
|
3991 | copy operation was missing). | |
3980 |
|
3992 | |||
3981 | * Code cleanup. @config was changed to use page(). Better, since |
|
3993 | * Code cleanup. @config was changed to use page(). Better, since | |
3982 | its output is always quite long. |
|
3994 | its output is always quite long. | |
3983 |
|
3995 | |||
3984 | * Itpl is back as a dependency. I was having too many problems |
|
3996 | * Itpl is back as a dependency. I was having too many problems | |
3985 | getting the parametric aliases to work reliably, and it's just |
|
3997 | getting the parametric aliases to work reliably, and it's just | |
3986 | easier to code weird string operations with it than playing %()s |
|
3998 | easier to code weird string operations with it than playing %()s | |
3987 | games. It's only ~6k, so I don't think it's too big a deal. |
|
3999 | games. It's only ~6k, so I don't think it's too big a deal. | |
3988 |
|
4000 | |||
3989 | * Found (and fixed) a very nasty bug with history. !lines weren't |
|
4001 | * Found (and fixed) a very nasty bug with history. !lines weren't | |
3990 | getting cached, and the out of sync caches would crash |
|
4002 | getting cached, and the out of sync caches would crash | |
3991 | IPython. Fixed it by reorganizing the prefilter/handlers/logger |
|
4003 | IPython. Fixed it by reorganizing the prefilter/handlers/logger | |
3992 | division of labor a bit better. Bug fixed, cleaner structure. |
|
4004 | division of labor a bit better. Bug fixed, cleaner structure. | |
3993 |
|
4005 | |||
3994 | 2001-12-01 Fernando Perez <fperez@colorado.edu> |
|
4006 | 2001-12-01 Fernando Perez <fperez@colorado.edu> | |
3995 |
|
4007 | |||
3996 | * Released 0.1.19 |
|
4008 | * Released 0.1.19 | |
3997 |
|
4009 | |||
3998 | * Added option -n to @hist to prevent line number printing. Much |
|
4010 | * Added option -n to @hist to prevent line number printing. Much | |
3999 | easier to copy/paste code this way. |
|
4011 | easier to copy/paste code this way. | |
4000 |
|
4012 | |||
4001 | * Created global _il to hold the input list. Allows easy |
|
4013 | * Created global _il to hold the input list. Allows easy | |
4002 | re-execution of blocks of code by slicing it (inspired by Janko's |
|
4014 | re-execution of blocks of code by slicing it (inspired by Janko's | |
4003 | comment on 'macros'). |
|
4015 | comment on 'macros'). | |
4004 |
|
4016 | |||
4005 | * Small fixes and doc updates. |
|
4017 | * Small fixes and doc updates. | |
4006 |
|
4018 | |||
4007 | * Rewrote @history function (was @h). Renamed it to @hist, @h is |
|
4019 | * Rewrote @history function (was @h). Renamed it to @hist, @h is | |
4008 | much too fragile with automagic. Handles properly multi-line |
|
4020 | much too fragile with automagic. Handles properly multi-line | |
4009 | statements and takes parameters. |
|
4021 | statements and takes parameters. | |
4010 |
|
4022 | |||
4011 | 2001-11-30 Fernando Perez <fperez@colorado.edu> |
|
4023 | 2001-11-30 Fernando Perez <fperez@colorado.edu> | |
4012 |
|
4024 | |||
4013 | * Version 0.1.18 released. |
|
4025 | * Version 0.1.18 released. | |
4014 |
|
4026 | |||
4015 | * Fixed nasty namespace bug in initial module imports. |
|
4027 | * Fixed nasty namespace bug in initial module imports. | |
4016 |
|
4028 | |||
4017 | * Added copyright/license notes to all code files (except |
|
4029 | * Added copyright/license notes to all code files (except | |
4018 | DPyGetOpt). For the time being, LGPL. That could change. |
|
4030 | DPyGetOpt). For the time being, LGPL. That could change. | |
4019 |
|
4031 | |||
4020 | * Rewrote a much nicer README, updated INSTALL, cleaned up |
|
4032 | * Rewrote a much nicer README, updated INSTALL, cleaned up | |
4021 | ipythonrc-* samples. |
|
4033 | ipythonrc-* samples. | |
4022 |
|
4034 | |||
4023 | * Overall code/documentation cleanup. Basically ready for |
|
4035 | * Overall code/documentation cleanup. Basically ready for | |
4024 | release. Only remaining thing: licence decision (LGPL?). |
|
4036 | release. Only remaining thing: licence decision (LGPL?). | |
4025 |
|
4037 | |||
4026 | * Converted load_config to a class, ConfigLoader. Now recursion |
|
4038 | * Converted load_config to a class, ConfigLoader. Now recursion | |
4027 | control is better organized. Doesn't include the same file twice. |
|
4039 | control is better organized. Doesn't include the same file twice. | |
4028 |
|
4040 | |||
4029 | 2001-11-29 Fernando Perez <fperez@colorado.edu> |
|
4041 | 2001-11-29 Fernando Perez <fperez@colorado.edu> | |
4030 |
|
4042 | |||
4031 | * Got input history working. Changed output history variables from |
|
4043 | * Got input history working. Changed output history variables from | |
4032 | _p to _o so that _i is for input and _o for output. Just cleaner |
|
4044 | _p to _o so that _i is for input and _o for output. Just cleaner | |
4033 | convention. |
|
4045 | convention. | |
4034 |
|
4046 | |||
4035 | * Implemented parametric aliases. This pretty much allows the |
|
4047 | * Implemented parametric aliases. This pretty much allows the | |
4036 | alias system to offer full-blown shell convenience, I think. |
|
4048 | alias system to offer full-blown shell convenience, I think. | |
4037 |
|
4049 | |||
4038 | * Version 0.1.17 released, 0.1.18 opened. |
|
4050 | * Version 0.1.17 released, 0.1.18 opened. | |
4039 |
|
4051 | |||
4040 | * dot_ipython/ipythonrc (alias): added documentation. |
|
4052 | * dot_ipython/ipythonrc (alias): added documentation. | |
4041 | (xcolor): Fixed small bug (xcolors -> xcolor) |
|
4053 | (xcolor): Fixed small bug (xcolors -> xcolor) | |
4042 |
|
4054 | |||
4043 | * Changed the alias system. Now alias is a magic command to define |
|
4055 | * Changed the alias system. Now alias is a magic command to define | |
4044 | aliases just like the shell. Rationale: the builtin magics should |
|
4056 | aliases just like the shell. Rationale: the builtin magics should | |
4045 | be there for things deeply connected to IPython's |
|
4057 | be there for things deeply connected to IPython's | |
4046 | architecture. And this is a much lighter system for what I think |
|
4058 | architecture. And this is a much lighter system for what I think | |
4047 | is the really important feature: allowing users to define quickly |
|
4059 | is the really important feature: allowing users to define quickly | |
4048 | magics that will do shell things for them, so they can customize |
|
4060 | magics that will do shell things for them, so they can customize | |
4049 | IPython easily to match their work habits. If someone is really |
|
4061 | IPython easily to match their work habits. If someone is really | |
4050 | desperate to have another name for a builtin alias, they can |
|
4062 | desperate to have another name for a builtin alias, they can | |
4051 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but |
|
4063 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but | |
4052 | works. |
|
4064 | works. | |
4053 |
|
4065 | |||
4054 | 2001-11-28 Fernando Perez <fperez@colorado.edu> |
|
4066 | 2001-11-28 Fernando Perez <fperez@colorado.edu> | |
4055 |
|
4067 | |||
4056 | * Changed @file so that it opens the source file at the proper |
|
4068 | * Changed @file so that it opens the source file at the proper | |
4057 | line. Since it uses less, if your EDITOR environment is |
|
4069 | line. Since it uses less, if your EDITOR environment is | |
4058 | configured, typing v will immediately open your editor of choice |
|
4070 | configured, typing v will immediately open your editor of choice | |
4059 | right at the line where the object is defined. Not as quick as |
|
4071 | right at the line where the object is defined. Not as quick as | |
4060 | having a direct @edit command, but for all intents and purposes it |
|
4072 | having a direct @edit command, but for all intents and purposes it | |
4061 | works. And I don't have to worry about writing @edit to deal with |
|
4073 | works. And I don't have to worry about writing @edit to deal with | |
4062 | all the editors, less does that. |
|
4074 | all the editors, less does that. | |
4063 |
|
4075 | |||
4064 | * Version 0.1.16 released, 0.1.17 opened. |
|
4076 | * Version 0.1.16 released, 0.1.17 opened. | |
4065 |
|
4077 | |||
4066 | * Fixed some nasty bugs in the page/page_dumb combo that could |
|
4078 | * Fixed some nasty bugs in the page/page_dumb combo that could | |
4067 | crash IPython. |
|
4079 | crash IPython. | |
4068 |
|
4080 | |||
4069 | 2001-11-27 Fernando Perez <fperez@colorado.edu> |
|
4081 | 2001-11-27 Fernando Perez <fperez@colorado.edu> | |
4070 |
|
4082 | |||
4071 | * Version 0.1.15 released, 0.1.16 opened. |
|
4083 | * Version 0.1.15 released, 0.1.16 opened. | |
4072 |
|
4084 | |||
4073 | * Finally got ? and ?? to work for undefined things: now it's |
|
4085 | * Finally got ? and ?? to work for undefined things: now it's | |
4074 | possible to type {}.get? and get information about the get method |
|
4086 | possible to type {}.get? and get information about the get method | |
4075 | of dicts, or os.path? even if only os is defined (so technically |
|
4087 | of dicts, or os.path? even if only os is defined (so technically | |
4076 | os.path isn't). Works at any level. For example, after import os, |
|
4088 | os.path isn't). Works at any level. For example, after import os, | |
4077 | os?, os.path?, os.path.abspath? all work. This is great, took some |
|
4089 | os?, os.path?, os.path.abspath? all work. This is great, took some | |
4078 | work in _ofind. |
|
4090 | work in _ofind. | |
4079 |
|
4091 | |||
4080 | * Fixed more bugs with logging. The sanest way to do it was to add |
|
4092 | * Fixed more bugs with logging. The sanest way to do it was to add | |
4081 | to @log a 'mode' parameter. Killed two in one shot (this mode |
|
4093 | to @log a 'mode' parameter. Killed two in one shot (this mode | |
4082 | option was a request of Janko's). I think it's finally clean |
|
4094 | option was a request of Janko's). I think it's finally clean | |
4083 | (famous last words). |
|
4095 | (famous last words). | |
4084 |
|
4096 | |||
4085 | * Added a page_dumb() pager which does a decent job of paging on |
|
4097 | * Added a page_dumb() pager which does a decent job of paging on | |
4086 | screen, if better things (like less) aren't available. One less |
|
4098 | screen, if better things (like less) aren't available. One less | |
4087 | unix dependency (someday maybe somebody will port this to |
|
4099 | unix dependency (someday maybe somebody will port this to | |
4088 | windows). |
|
4100 | windows). | |
4089 |
|
4101 | |||
4090 | * Fixed problem in magic_log: would lock of logging out if log |
|
4102 | * Fixed problem in magic_log: would lock of logging out if log | |
4091 | creation failed (because it would still think it had succeeded). |
|
4103 | creation failed (because it would still think it had succeeded). | |
4092 |
|
4104 | |||
4093 | * Improved the page() function using curses to auto-detect screen |
|
4105 | * Improved the page() function using curses to auto-detect screen | |
4094 | size. Now it can make a much better decision on whether to print |
|
4106 | size. Now it can make a much better decision on whether to print | |
4095 | or page a string. Option screen_length was modified: a value 0 |
|
4107 | or page a string. Option screen_length was modified: a value 0 | |
4096 | means auto-detect, and that's the default now. |
|
4108 | means auto-detect, and that's the default now. | |
4097 |
|
4109 | |||
4098 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to |
|
4110 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to | |
4099 | go out. I'll test it for a few days, then talk to Janko about |
|
4111 | go out. I'll test it for a few days, then talk to Janko about | |
4100 | licences and announce it. |
|
4112 | licences and announce it. | |
4101 |
|
4113 | |||
4102 | * Fixed the length of the auto-generated ---> prompt which appears |
|
4114 | * Fixed the length of the auto-generated ---> prompt which appears | |
4103 | for auto-parens and auto-quotes. Getting this right isn't trivial, |
|
4115 | for auto-parens and auto-quotes. Getting this right isn't trivial, | |
4104 | with all the color escapes, different prompt types and optional |
|
4116 | with all the color escapes, different prompt types and optional | |
4105 | separators. But it seems to be working in all the combinations. |
|
4117 | separators. But it seems to be working in all the combinations. | |
4106 |
|
4118 | |||
4107 | 2001-11-26 Fernando Perez <fperez@colorado.edu> |
|
4119 | 2001-11-26 Fernando Perez <fperez@colorado.edu> | |
4108 |
|
4120 | |||
4109 | * Wrote a regexp filter to get option types from the option names |
|
4121 | * Wrote a regexp filter to get option types from the option names | |
4110 | string. This eliminates the need to manually keep two duplicate |
|
4122 | string. This eliminates the need to manually keep two duplicate | |
4111 | lists. |
|
4123 | lists. | |
4112 |
|
4124 | |||
4113 | * Removed the unneeded check_option_names. Now options are handled |
|
4125 | * Removed the unneeded check_option_names. Now options are handled | |
4114 | in a much saner manner and it's easy to visually check that things |
|
4126 | in a much saner manner and it's easy to visually check that things | |
4115 | are ok. |
|
4127 | are ok. | |
4116 |
|
4128 | |||
4117 | * Updated version numbers on all files I modified to carry a |
|
4129 | * Updated version numbers on all files I modified to carry a | |
4118 | notice so Janko and Nathan have clear version markers. |
|
4130 | notice so Janko and Nathan have clear version markers. | |
4119 |
|
4131 | |||
4120 | * Updated docstring for ultraTB with my changes. I should send |
|
4132 | * Updated docstring for ultraTB with my changes. I should send | |
4121 | this to Nathan. |
|
4133 | this to Nathan. | |
4122 |
|
4134 | |||
4123 | * Lots of small fixes. Ran everything through pychecker again. |
|
4135 | * Lots of small fixes. Ran everything through pychecker again. | |
4124 |
|
4136 | |||
4125 | * Made loading of deep_reload an cmd line option. If it's not too |
|
4137 | * Made loading of deep_reload an cmd line option. If it's not too | |
4126 | kosher, now people can just disable it. With -nodeep_reload it's |
|
4138 | kosher, now people can just disable it. With -nodeep_reload it's | |
4127 | still available as dreload(), it just won't overwrite reload(). |
|
4139 | still available as dreload(), it just won't overwrite reload(). | |
4128 |
|
4140 | |||
4129 | * Moved many options to the no| form (-opt and -noopt |
|
4141 | * Moved many options to the no| form (-opt and -noopt | |
4130 | accepted). Cleaner. |
|
4142 | accepted). Cleaner. | |
4131 |
|
4143 | |||
4132 | * Changed magic_log so that if called with no parameters, it uses |
|
4144 | * Changed magic_log so that if called with no parameters, it uses | |
4133 | 'rotate' mode. That way auto-generated logs aren't automatically |
|
4145 | 'rotate' mode. That way auto-generated logs aren't automatically | |
4134 | over-written. For normal logs, now a backup is made if it exists |
|
4146 | over-written. For normal logs, now a backup is made if it exists | |
4135 | (only 1 level of backups). A new 'backup' mode was added to the |
|
4147 | (only 1 level of backups). A new 'backup' mode was added to the | |
4136 | Logger class to support this. This was a request by Janko. |
|
4148 | Logger class to support this. This was a request by Janko. | |
4137 |
|
4149 | |||
4138 | * Added @logoff/@logon to stop/restart an active log. |
|
4150 | * Added @logoff/@logon to stop/restart an active log. | |
4139 |
|
4151 | |||
4140 | * Fixed a lot of bugs in log saving/replay. It was pretty |
|
4152 | * Fixed a lot of bugs in log saving/replay. It was pretty | |
4141 | broken. Now special lines (!@,/) appear properly in the command |
|
4153 | broken. Now special lines (!@,/) appear properly in the command | |
4142 | history after a log replay. |
|
4154 | history after a log replay. | |
4143 |
|
4155 | |||
4144 | * Tried and failed to implement full session saving via pickle. My |
|
4156 | * Tried and failed to implement full session saving via pickle. My | |
4145 | idea was to pickle __main__.__dict__, but modules can't be |
|
4157 | idea was to pickle __main__.__dict__, but modules can't be | |
4146 | pickled. This would be a better alternative to replaying logs, but |
|
4158 | pickled. This would be a better alternative to replaying logs, but | |
4147 | seems quite tricky to get to work. Changed -session to be called |
|
4159 | seems quite tricky to get to work. Changed -session to be called | |
4148 | -logplay, which more accurately reflects what it does. And if we |
|
4160 | -logplay, which more accurately reflects what it does. And if we | |
4149 | ever get real session saving working, -session is now available. |
|
4161 | ever get real session saving working, -session is now available. | |
4150 |
|
4162 | |||
4151 | * Implemented color schemes for prompts also. As for tracebacks, |
|
4163 | * Implemented color schemes for prompts also. As for tracebacks, | |
4152 | currently only NoColor and Linux are supported. But now the |
|
4164 | currently only NoColor and Linux are supported. But now the | |
4153 | infrastructure is in place, based on a generic ColorScheme |
|
4165 | infrastructure is in place, based on a generic ColorScheme | |
4154 | class. So writing and activating new schemes both for the prompts |
|
4166 | class. So writing and activating new schemes both for the prompts | |
4155 | and the tracebacks should be straightforward. |
|
4167 | and the tracebacks should be straightforward. | |
4156 |
|
4168 | |||
4157 | * Version 0.1.13 released, 0.1.14 opened. |
|
4169 | * Version 0.1.13 released, 0.1.14 opened. | |
4158 |
|
4170 | |||
4159 | * Changed handling of options for output cache. Now counter is |
|
4171 | * Changed handling of options for output cache. Now counter is | |
4160 | hardwired starting at 1 and one specifies the maximum number of |
|
4172 | hardwired starting at 1 and one specifies the maximum number of | |
4161 | entries *in the outcache* (not the max prompt counter). This is |
|
4173 | entries *in the outcache* (not the max prompt counter). This is | |
4162 | much better, since many statements won't increase the cache |
|
4174 | much better, since many statements won't increase the cache | |
4163 | count. It also eliminated some confusing options, now there's only |
|
4175 | count. It also eliminated some confusing options, now there's only | |
4164 | one: cache_size. |
|
4176 | one: cache_size. | |
4165 |
|
4177 | |||
4166 | * Added 'alias' magic function and magic_alias option in the |
|
4178 | * Added 'alias' magic function and magic_alias option in the | |
4167 | ipythonrc file. Now the user can easily define whatever names he |
|
4179 | ipythonrc file. Now the user can easily define whatever names he | |
4168 | wants for the magic functions without having to play weird |
|
4180 | wants for the magic functions without having to play weird | |
4169 | namespace games. This gives IPython a real shell-like feel. |
|
4181 | namespace games. This gives IPython a real shell-like feel. | |
4170 |
|
4182 | |||
4171 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit |
|
4183 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit | |
4172 | @ or not). |
|
4184 | @ or not). | |
4173 |
|
4185 | |||
4174 | This was one of the last remaining 'visible' bugs (that I know |
|
4186 | This was one of the last remaining 'visible' bugs (that I know | |
4175 | of). I think if I can clean up the session loading so it works |
|
4187 | of). I think if I can clean up the session loading so it works | |
4176 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first |
|
4188 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first | |
4177 | about licensing). |
|
4189 | about licensing). | |
4178 |
|
4190 | |||
4179 | 2001-11-25 Fernando Perez <fperez@colorado.edu> |
|
4191 | 2001-11-25 Fernando Perez <fperez@colorado.edu> | |
4180 |
|
4192 | |||
4181 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and |
|
4193 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and | |
4182 | there's a cleaner distinction between what ? and ?? show. |
|
4194 | there's a cleaner distinction between what ? and ?? show. | |
4183 |
|
4195 | |||
4184 | * Added screen_length option. Now the user can define his own |
|
4196 | * Added screen_length option. Now the user can define his own | |
4185 | screen size for page() operations. |
|
4197 | screen size for page() operations. | |
4186 |
|
4198 | |||
4187 | * Implemented magic shell-like functions with automatic code |
|
4199 | * Implemented magic shell-like functions with automatic code | |
4188 | generation. Now adding another function is just a matter of adding |
|
4200 | generation. Now adding another function is just a matter of adding | |
4189 | an entry to a dict, and the function is dynamically generated at |
|
4201 | an entry to a dict, and the function is dynamically generated at | |
4190 | run-time. Python has some really cool features! |
|
4202 | run-time. Python has some really cool features! | |
4191 |
|
4203 | |||
4192 | * Renamed many options to cleanup conventions a little. Now all |
|
4204 | * Renamed many options to cleanup conventions a little. Now all | |
4193 | are lowercase, and only underscores where needed. Also in the code |
|
4205 | are lowercase, and only underscores where needed. Also in the code | |
4194 | option name tables are clearer. |
|
4206 | option name tables are clearer. | |
4195 |
|
4207 | |||
4196 | * Changed prompts a little. Now input is 'In [n]:' instead of |
|
4208 | * Changed prompts a little. Now input is 'In [n]:' instead of | |
4197 | 'In[n]:='. This allows it the numbers to be aligned with the |
|
4209 | 'In[n]:='. This allows it the numbers to be aligned with the | |
4198 | Out[n] numbers, and removes usage of ':=' which doesn't exist in |
|
4210 | Out[n] numbers, and removes usage of ':=' which doesn't exist in | |
4199 | Python (it was a Mathematica thing). The '...' continuation prompt |
|
4211 | Python (it was a Mathematica thing). The '...' continuation prompt | |
4200 | was also changed a little to align better. |
|
4212 | was also changed a little to align better. | |
4201 |
|
4213 | |||
4202 | * Fixed bug when flushing output cache. Not all _p<n> variables |
|
4214 | * Fixed bug when flushing output cache. Not all _p<n> variables | |
4203 | exist, so their deletion needs to be wrapped in a try: |
|
4215 | exist, so their deletion needs to be wrapped in a try: | |
4204 |
|
4216 | |||
4205 | * Figured out how to properly use inspect.formatargspec() (it |
|
4217 | * Figured out how to properly use inspect.formatargspec() (it | |
4206 | requires the args preceded by *). So I removed all the code from |
|
4218 | requires the args preceded by *). So I removed all the code from | |
4207 | _get_pdef in Magic, which was just replicating that. |
|
4219 | _get_pdef in Magic, which was just replicating that. | |
4208 |
|
4220 | |||
4209 | * Added test to prefilter to allow redefining magic function names |
|
4221 | * Added test to prefilter to allow redefining magic function names | |
4210 | as variables. This is ok, since the @ form is always available, |
|
4222 | as variables. This is ok, since the @ form is always available, | |
4211 | but whe should allow the user to define a variable called 'ls' if |
|
4223 | but whe should allow the user to define a variable called 'ls' if | |
4212 | he needs it. |
|
4224 | he needs it. | |
4213 |
|
4225 | |||
4214 | * Moved the ToDo information from README into a separate ToDo. |
|
4226 | * Moved the ToDo information from README into a separate ToDo. | |
4215 |
|
4227 | |||
4216 | * General code cleanup and small bugfixes. I think it's close to a |
|
4228 | * General code cleanup and small bugfixes. I think it's close to a | |
4217 | state where it can be released, obviously with a big 'beta' |
|
4229 | state where it can be released, obviously with a big 'beta' | |
4218 | warning on it. |
|
4230 | warning on it. | |
4219 |
|
4231 | |||
4220 | * Got the magic function split to work. Now all magics are defined |
|
4232 | * Got the magic function split to work. Now all magics are defined | |
4221 | in a separate class. It just organizes things a bit, and now |
|
4233 | in a separate class. It just organizes things a bit, and now | |
4222 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it |
|
4234 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it | |
4223 | was too long). |
|
4235 | was too long). | |
4224 |
|
4236 | |||
4225 | * Changed @clear to @reset to avoid potential confusions with |
|
4237 | * Changed @clear to @reset to avoid potential confusions with | |
4226 | the shell command clear. Also renamed @cl to @clear, which does |
|
4238 | the shell command clear. Also renamed @cl to @clear, which does | |
4227 | exactly what people expect it to from their shell experience. |
|
4239 | exactly what people expect it to from their shell experience. | |
4228 |
|
4240 | |||
4229 | Added a check to the @reset command (since it's so |
|
4241 | Added a check to the @reset command (since it's so | |
4230 | destructive, it's probably a good idea to ask for confirmation). |
|
4242 | destructive, it's probably a good idea to ask for confirmation). | |
4231 | But now reset only works for full namespace resetting. Since the |
|
4243 | But now reset only works for full namespace resetting. Since the | |
4232 | del keyword is already there for deleting a few specific |
|
4244 | del keyword is already there for deleting a few specific | |
4233 | variables, I don't see the point of having a redundant magic |
|
4245 | variables, I don't see the point of having a redundant magic | |
4234 | function for the same task. |
|
4246 | function for the same task. | |
4235 |
|
4247 | |||
4236 | 2001-11-24 Fernando Perez <fperez@colorado.edu> |
|
4248 | 2001-11-24 Fernando Perez <fperez@colorado.edu> | |
4237 |
|
4249 | |||
4238 | * Updated the builtin docs (esp. the ? ones). |
|
4250 | * Updated the builtin docs (esp. the ? ones). | |
4239 |
|
4251 | |||
4240 | * Ran all the code through pychecker. Not terribly impressed with |
|
4252 | * Ran all the code through pychecker. Not terribly impressed with | |
4241 | it: lots of spurious warnings and didn't really find anything of |
|
4253 | it: lots of spurious warnings and didn't really find anything of | |
4242 | substance (just a few modules being imported and not used). |
|
4254 | substance (just a few modules being imported and not used). | |
4243 |
|
4255 | |||
4244 | * Implemented the new ultraTB functionality into IPython. New |
|
4256 | * Implemented the new ultraTB functionality into IPython. New | |
4245 | option: xcolors. This chooses color scheme. xmode now only selects |
|
4257 | option: xcolors. This chooses color scheme. xmode now only selects | |
4246 | between Plain and Verbose. Better orthogonality. |
|
4258 | between Plain and Verbose. Better orthogonality. | |
4247 |
|
4259 | |||
4248 | * Large rewrite of ultraTB. Much cleaner now, with a separation of |
|
4260 | * Large rewrite of ultraTB. Much cleaner now, with a separation of | |
4249 | mode and color scheme for the exception handlers. Now it's |
|
4261 | mode and color scheme for the exception handlers. Now it's | |
4250 | possible to have the verbose traceback with no coloring. |
|
4262 | possible to have the verbose traceback with no coloring. | |
4251 |
|
4263 | |||
4252 | 2001-11-23 Fernando Perez <fperez@colorado.edu> |
|
4264 | 2001-11-23 Fernando Perez <fperez@colorado.edu> | |
4253 |
|
4265 | |||
4254 | * Version 0.1.12 released, 0.1.13 opened. |
|
4266 | * Version 0.1.12 released, 0.1.13 opened. | |
4255 |
|
4267 | |||
4256 | * Removed option to set auto-quote and auto-paren escapes by |
|
4268 | * Removed option to set auto-quote and auto-paren escapes by | |
4257 | user. The chances of breaking valid syntax are just too high. If |
|
4269 | user. The chances of breaking valid syntax are just too high. If | |
4258 | someone *really* wants, they can always dig into the code. |
|
4270 | someone *really* wants, they can always dig into the code. | |
4259 |
|
4271 | |||
4260 | * Made prompt separators configurable. |
|
4272 | * Made prompt separators configurable. | |
4261 |
|
4273 | |||
4262 | 2001-11-22 Fernando Perez <fperez@colorado.edu> |
|
4274 | 2001-11-22 Fernando Perez <fperez@colorado.edu> | |
4263 |
|
4275 | |||
4264 | * Small bugfixes in many places. |
|
4276 | * Small bugfixes in many places. | |
4265 |
|
4277 | |||
4266 | * Removed the MyCompleter class from ipplib. It seemed redundant |
|
4278 | * Removed the MyCompleter class from ipplib. It seemed redundant | |
4267 | with the C-p,C-n history search functionality. Less code to |
|
4279 | with the C-p,C-n history search functionality. Less code to | |
4268 | maintain. |
|
4280 | maintain. | |
4269 |
|
4281 | |||
4270 | * Moved all the original ipython.py code into ipythonlib.py. Right |
|
4282 | * Moved all the original ipython.py code into ipythonlib.py. Right | |
4271 | now it's just one big dump into a function called make_IPython, so |
|
4283 | now it's just one big dump into a function called make_IPython, so | |
4272 | no real modularity has been gained. But at least it makes the |
|
4284 | no real modularity has been gained. But at least it makes the | |
4273 | wrapper script tiny, and since ipythonlib is a module, it gets |
|
4285 | wrapper script tiny, and since ipythonlib is a module, it gets | |
4274 | compiled and startup is much faster. |
|
4286 | compiled and startup is much faster. | |
4275 |
|
4287 | |||
4276 | This is a reasobably 'deep' change, so we should test it for a |
|
4288 | This is a reasobably 'deep' change, so we should test it for a | |
4277 | while without messing too much more with the code. |
|
4289 | while without messing too much more with the code. | |
4278 |
|
4290 | |||
4279 | 2001-11-21 Fernando Perez <fperez@colorado.edu> |
|
4291 | 2001-11-21 Fernando Perez <fperez@colorado.edu> | |
4280 |
|
4292 | |||
4281 | * Version 0.1.11 released, 0.1.12 opened for further work. |
|
4293 | * Version 0.1.11 released, 0.1.12 opened for further work. | |
4282 |
|
4294 | |||
4283 | * Removed dependency on Itpl. It was only needed in one place. It |
|
4295 | * Removed dependency on Itpl. It was only needed in one place. It | |
4284 | would be nice if this became part of python, though. It makes life |
|
4296 | would be nice if this became part of python, though. It makes life | |
4285 | *a lot* easier in some cases. |
|
4297 | *a lot* easier in some cases. | |
4286 |
|
4298 | |||
4287 | * Simplified the prefilter code a bit. Now all handlers are |
|
4299 | * Simplified the prefilter code a bit. Now all handlers are | |
4288 | expected to explicitly return a value (at least a blank string). |
|
4300 | expected to explicitly return a value (at least a blank string). | |
4289 |
|
4301 | |||
4290 | * Heavy edits in ipplib. Removed the help system altogether. Now |
|
4302 | * Heavy edits in ipplib. Removed the help system altogether. Now | |
4291 | obj?/?? is used for inspecting objects, a magic @doc prints |
|
4303 | obj?/?? is used for inspecting objects, a magic @doc prints | |
4292 | docstrings, and full-blown Python help is accessed via the 'help' |
|
4304 | docstrings, and full-blown Python help is accessed via the 'help' | |
4293 | keyword. This cleans up a lot of code (less to maintain) and does |
|
4305 | keyword. This cleans up a lot of code (less to maintain) and does | |
4294 | the job. Since 'help' is now a standard Python component, might as |
|
4306 | the job. Since 'help' is now a standard Python component, might as | |
4295 | well use it and remove duplicate functionality. |
|
4307 | well use it and remove duplicate functionality. | |
4296 |
|
4308 | |||
4297 | Also removed the option to use ipplib as a standalone program. By |
|
4309 | Also removed the option to use ipplib as a standalone program. By | |
4298 | now it's too dependent on other parts of IPython to function alone. |
|
4310 | now it's too dependent on other parts of IPython to function alone. | |
4299 |
|
4311 | |||
4300 | * Fixed bug in genutils.pager. It would crash if the pager was |
|
4312 | * Fixed bug in genutils.pager. It would crash if the pager was | |
4301 | exited immediately after opening (broken pipe). |
|
4313 | exited immediately after opening (broken pipe). | |
4302 |
|
4314 | |||
4303 | * Trimmed down the VerboseTB reporting a little. The header is |
|
4315 | * Trimmed down the VerboseTB reporting a little. The header is | |
4304 | much shorter now and the repeated exception arguments at the end |
|
4316 | much shorter now and the repeated exception arguments at the end | |
4305 | have been removed. For interactive use the old header seemed a bit |
|
4317 | have been removed. For interactive use the old header seemed a bit | |
4306 | excessive. |
|
4318 | excessive. | |
4307 |
|
4319 | |||
4308 | * Fixed small bug in output of @whos for variables with multi-word |
|
4320 | * Fixed small bug in output of @whos for variables with multi-word | |
4309 | types (only first word was displayed). |
|
4321 | types (only first word was displayed). | |
4310 |
|
4322 | |||
4311 | 2001-11-17 Fernando Perez <fperez@colorado.edu> |
|
4323 | 2001-11-17 Fernando Perez <fperez@colorado.edu> | |
4312 |
|
4324 | |||
4313 | * Version 0.1.10 released, 0.1.11 opened for further work. |
|
4325 | * Version 0.1.10 released, 0.1.11 opened for further work. | |
4314 |
|
4326 | |||
4315 | * Modified dirs and friends. dirs now *returns* the stack (not |
|
4327 | * Modified dirs and friends. dirs now *returns* the stack (not | |
4316 | prints), so one can manipulate it as a variable. Convenient to |
|
4328 | prints), so one can manipulate it as a variable. Convenient to | |
4317 | travel along many directories. |
|
4329 | travel along many directories. | |
4318 |
|
4330 | |||
4319 | * Fixed bug in magic_pdef: would only work with functions with |
|
4331 | * Fixed bug in magic_pdef: would only work with functions with | |
4320 | arguments with default values. |
|
4332 | arguments with default values. | |
4321 |
|
4333 | |||
4322 | 2001-11-14 Fernando Perez <fperez@colorado.edu> |
|
4334 | 2001-11-14 Fernando Perez <fperez@colorado.edu> | |
4323 |
|
4335 | |||
4324 | * Added the PhysicsInput stuff to dot_ipython so it ships as an |
|
4336 | * Added the PhysicsInput stuff to dot_ipython so it ships as an | |
4325 | example with IPython. Various other minor fixes and cleanups. |
|
4337 | example with IPython. Various other minor fixes and cleanups. | |
4326 |
|
4338 | |||
4327 | * Version 0.1.9 released, 0.1.10 opened for further work. |
|
4339 | * Version 0.1.9 released, 0.1.10 opened for further work. | |
4328 |
|
4340 | |||
4329 | * Added sys.path to the list of directories searched in the |
|
4341 | * Added sys.path to the list of directories searched in the | |
4330 | execfile= option. It used to be the current directory and the |
|
4342 | execfile= option. It used to be the current directory and the | |
4331 | user's IPYTHONDIR only. |
|
4343 | user's IPYTHONDIR only. | |
4332 |
|
4344 | |||
4333 | 2001-11-13 Fernando Perez <fperez@colorado.edu> |
|
4345 | 2001-11-13 Fernando Perez <fperez@colorado.edu> | |
4334 |
|
4346 | |||
4335 | * Reinstated the raw_input/prefilter separation that Janko had |
|
4347 | * Reinstated the raw_input/prefilter separation that Janko had | |
4336 | initially. This gives a more convenient setup for extending the |
|
4348 | initially. This gives a more convenient setup for extending the | |
4337 | pre-processor from the outside: raw_input always gets a string, |
|
4349 | pre-processor from the outside: raw_input always gets a string, | |
4338 | and prefilter has to process it. We can then redefine prefilter |
|
4350 | and prefilter has to process it. We can then redefine prefilter | |
4339 | from the outside and implement extensions for special |
|
4351 | from the outside and implement extensions for special | |
4340 | purposes. |
|
4352 | purposes. | |
4341 |
|
4353 | |||
4342 | Today I got one for inputting PhysicalQuantity objects |
|
4354 | Today I got one for inputting PhysicalQuantity objects | |
4343 | (from Scientific) without needing any function calls at |
|
4355 | (from Scientific) without needing any function calls at | |
4344 | all. Extremely convenient, and it's all done as a user-level |
|
4356 | all. Extremely convenient, and it's all done as a user-level | |
4345 | extension (no IPython code was touched). Now instead of: |
|
4357 | extension (no IPython code was touched). Now instead of: | |
4346 | a = PhysicalQuantity(4.2,'m/s**2') |
|
4358 | a = PhysicalQuantity(4.2,'m/s**2') | |
4347 | one can simply say |
|
4359 | one can simply say | |
4348 | a = 4.2 m/s**2 |
|
4360 | a = 4.2 m/s**2 | |
4349 | or even |
|
4361 | or even | |
4350 | a = 4.2 m/s^2 |
|
4362 | a = 4.2 m/s^2 | |
4351 |
|
4363 | |||
4352 | I use this, but it's also a proof of concept: IPython really is |
|
4364 | I use this, but it's also a proof of concept: IPython really is | |
4353 | fully user-extensible, even at the level of the parsing of the |
|
4365 | fully user-extensible, even at the level of the parsing of the | |
4354 | command line. It's not trivial, but it's perfectly doable. |
|
4366 | command line. It's not trivial, but it's perfectly doable. | |
4355 |
|
4367 | |||
4356 | * Added 'add_flip' method to inclusion conflict resolver. Fixes |
|
4368 | * Added 'add_flip' method to inclusion conflict resolver. Fixes | |
4357 | the problem of modules being loaded in the inverse order in which |
|
4369 | the problem of modules being loaded in the inverse order in which | |
4358 | they were defined in |
|
4370 | they were defined in | |
4359 |
|
4371 | |||
4360 | * Version 0.1.8 released, 0.1.9 opened for further work. |
|
4372 | * Version 0.1.8 released, 0.1.9 opened for further work. | |
4361 |
|
4373 | |||
4362 | * Added magics pdef, source and file. They respectively show the |
|
4374 | * Added magics pdef, source and file. They respectively show the | |
4363 | definition line ('prototype' in C), source code and full python |
|
4375 | definition line ('prototype' in C), source code and full python | |
4364 | file for any callable object. The object inspector oinfo uses |
|
4376 | file for any callable object. The object inspector oinfo uses | |
4365 | these to show the same information. |
|
4377 | these to show the same information. | |
4366 |
|
4378 | |||
4367 | * Version 0.1.7 released, 0.1.8 opened for further work. |
|
4379 | * Version 0.1.7 released, 0.1.8 opened for further work. | |
4368 |
|
4380 | |||
4369 | * Separated all the magic functions into a class called Magic. The |
|
4381 | * Separated all the magic functions into a class called Magic. The | |
4370 | InteractiveShell class was becoming too big for Xemacs to handle |
|
4382 | InteractiveShell class was becoming too big for Xemacs to handle | |
4371 | (de-indenting a line would lock it up for 10 seconds while it |
|
4383 | (de-indenting a line would lock it up for 10 seconds while it | |
4372 | backtracked on the whole class!) |
|
4384 | backtracked on the whole class!) | |
4373 |
|
4385 | |||
4374 | FIXME: didn't work. It can be done, but right now namespaces are |
|
4386 | FIXME: didn't work. It can be done, but right now namespaces are | |
4375 | all messed up. Do it later (reverted it for now, so at least |
|
4387 | all messed up. Do it later (reverted it for now, so at least | |
4376 | everything works as before). |
|
4388 | everything works as before). | |
4377 |
|
4389 | |||
4378 | * Got the object introspection system (magic_oinfo) working! I |
|
4390 | * Got the object introspection system (magic_oinfo) working! I | |
4379 | think this is pretty much ready for release to Janko, so he can |
|
4391 | think this is pretty much ready for release to Janko, so he can | |
4380 | test it for a while and then announce it. Pretty much 100% of what |
|
4392 | test it for a while and then announce it. Pretty much 100% of what | |
4381 | I wanted for the 'phase 1' release is ready. Happy, tired. |
|
4393 | I wanted for the 'phase 1' release is ready. Happy, tired. | |
4382 |
|
4394 | |||
4383 | 2001-11-12 Fernando Perez <fperez@colorado.edu> |
|
4395 | 2001-11-12 Fernando Perez <fperez@colorado.edu> | |
4384 |
|
4396 | |||
4385 | * Version 0.1.6 released, 0.1.7 opened for further work. |
|
4397 | * Version 0.1.6 released, 0.1.7 opened for further work. | |
4386 |
|
4398 | |||
4387 | * Fixed bug in printing: it used to test for truth before |
|
4399 | * Fixed bug in printing: it used to test for truth before | |
4388 | printing, so 0 wouldn't print. Now checks for None. |
|
4400 | printing, so 0 wouldn't print. Now checks for None. | |
4389 |
|
4401 | |||
4390 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c |
|
4402 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c | |
4391 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it |
|
4403 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it | |
4392 | reaches by hand into the outputcache. Think of a better way to do |
|
4404 | reaches by hand into the outputcache. Think of a better way to do | |
4393 | this later. |
|
4405 | this later. | |
4394 |
|
4406 | |||
4395 | * Various small fixes thanks to Nathan's comments. |
|
4407 | * Various small fixes thanks to Nathan's comments. | |
4396 |
|
4408 | |||
4397 | * Changed magic_pprint to magic_Pprint. This way it doesn't |
|
4409 | * Changed magic_pprint to magic_Pprint. This way it doesn't | |
4398 | collide with pprint() and the name is consistent with the command |
|
4410 | collide with pprint() and the name is consistent with the command | |
4399 | line option. |
|
4411 | line option. | |
4400 |
|
4412 | |||
4401 | * Changed prompt counter behavior to be fully like |
|
4413 | * Changed prompt counter behavior to be fully like | |
4402 | Mathematica's. That is, even input that doesn't return a result |
|
4414 | Mathematica's. That is, even input that doesn't return a result | |
4403 | raises the prompt counter. The old behavior was kind of confusing |
|
4415 | raises the prompt counter. The old behavior was kind of confusing | |
4404 | (getting the same prompt number several times if the operation |
|
4416 | (getting the same prompt number several times if the operation | |
4405 | didn't return a result). |
|
4417 | didn't return a result). | |
4406 |
|
4418 | |||
4407 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). |
|
4419 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). | |
4408 |
|
4420 | |||
4409 | * Fixed -Classic mode (wasn't working anymore). |
|
4421 | * Fixed -Classic mode (wasn't working anymore). | |
4410 |
|
4422 | |||
4411 | * Added colored prompts using Nathan's new code. Colors are |
|
4423 | * Added colored prompts using Nathan's new code. Colors are | |
4412 | currently hardwired, they can be user-configurable. For |
|
4424 | currently hardwired, they can be user-configurable. For | |
4413 | developers, they can be chosen in file ipythonlib.py, at the |
|
4425 | developers, they can be chosen in file ipythonlib.py, at the | |
4414 | beginning of the CachedOutput class def. |
|
4426 | beginning of the CachedOutput class def. | |
4415 |
|
4427 | |||
4416 | 2001-11-11 Fernando Perez <fperez@colorado.edu> |
|
4428 | 2001-11-11 Fernando Perez <fperez@colorado.edu> | |
4417 |
|
4429 | |||
4418 | * Version 0.1.5 released, 0.1.6 opened for further work. |
|
4430 | * Version 0.1.5 released, 0.1.6 opened for further work. | |
4419 |
|
4431 | |||
4420 | * Changed magic_env to *return* the environment as a dict (not to |
|
4432 | * Changed magic_env to *return* the environment as a dict (not to | |
4421 | print it). This way it prints, but it can also be processed. |
|
4433 | print it). This way it prints, but it can also be processed. | |
4422 |
|
4434 | |||
4423 | * Added Verbose exception reporting to interactive |
|
4435 | * Added Verbose exception reporting to interactive | |
4424 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose |
|
4436 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose | |
4425 | traceback. Had to make some changes to the ultraTB file. This is |
|
4437 | traceback. Had to make some changes to the ultraTB file. This is | |
4426 | probably the last 'big' thing in my mental todo list. This ties |
|
4438 | probably the last 'big' thing in my mental todo list. This ties | |
4427 | in with the next entry: |
|
4439 | in with the next entry: | |
4428 |
|
4440 | |||
4429 | * Changed -Xi and -Xf to a single -xmode option. Now all the user |
|
4441 | * Changed -Xi and -Xf to a single -xmode option. Now all the user | |
4430 | has to specify is Plain, Color or Verbose for all exception |
|
4442 | has to specify is Plain, Color or Verbose for all exception | |
4431 | handling. |
|
4443 | handling. | |
4432 |
|
4444 | |||
4433 | * Removed ShellServices option. All this can really be done via |
|
4445 | * Removed ShellServices option. All this can really be done via | |
4434 | the magic system. It's easier to extend, cleaner and has automatic |
|
4446 | the magic system. It's easier to extend, cleaner and has automatic | |
4435 | namespace protection and documentation. |
|
4447 | namespace protection and documentation. | |
4436 |
|
4448 | |||
4437 | 2001-11-09 Fernando Perez <fperez@colorado.edu> |
|
4449 | 2001-11-09 Fernando Perez <fperez@colorado.edu> | |
4438 |
|
4450 | |||
4439 | * Fixed bug in output cache flushing (missing parameter to |
|
4451 | * Fixed bug in output cache flushing (missing parameter to | |
4440 | __init__). Other small bugs fixed (found using pychecker). |
|
4452 | __init__). Other small bugs fixed (found using pychecker). | |
4441 |
|
4453 | |||
4442 | * Version 0.1.4 opened for bugfixing. |
|
4454 | * Version 0.1.4 opened for bugfixing. | |
4443 |
|
4455 | |||
4444 | 2001-11-07 Fernando Perez <fperez@colorado.edu> |
|
4456 | 2001-11-07 Fernando Perez <fperez@colorado.edu> | |
4445 |
|
4457 | |||
4446 | * Version 0.1.3 released, mainly because of the raw_input bug. |
|
4458 | * Version 0.1.3 released, mainly because of the raw_input bug. | |
4447 |
|
4459 | |||
4448 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed |
|
4460 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed | |
4449 | and when testing for whether things were callable, a call could |
|
4461 | and when testing for whether things were callable, a call could | |
4450 | actually be made to certain functions. They would get called again |
|
4462 | actually be made to certain functions. They would get called again | |
4451 | once 'really' executed, with a resulting double call. A disaster |
|
4463 | once 'really' executed, with a resulting double call. A disaster | |
4452 | in many cases (list.reverse() would never work!). |
|
4464 | in many cases (list.reverse() would never work!). | |
4453 |
|
4465 | |||
4454 | * Removed prefilter() function, moved its code to raw_input (which |
|
4466 | * Removed prefilter() function, moved its code to raw_input (which | |
4455 | after all was just a near-empty caller for prefilter). This saves |
|
4467 | after all was just a near-empty caller for prefilter). This saves | |
4456 | a function call on every prompt, and simplifies the class a tiny bit. |
|
4468 | a function call on every prompt, and simplifies the class a tiny bit. | |
4457 |
|
4469 | |||
4458 | * Fix _ip to __ip name in magic example file. |
|
4470 | * Fix _ip to __ip name in magic example file. | |
4459 |
|
4471 | |||
4460 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should |
|
4472 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should | |
4461 | work with non-gnu versions of tar. |
|
4473 | work with non-gnu versions of tar. | |
4462 |
|
4474 | |||
4463 | 2001-11-06 Fernando Perez <fperez@colorado.edu> |
|
4475 | 2001-11-06 Fernando Perez <fperez@colorado.edu> | |
4464 |
|
4476 | |||
4465 | * Version 0.1.2. Just to keep track of the recent changes. |
|
4477 | * Version 0.1.2. Just to keep track of the recent changes. | |
4466 |
|
4478 | |||
4467 | * Fixed nasty bug in output prompt routine. It used to check 'if |
|
4479 | * Fixed nasty bug in output prompt routine. It used to check 'if | |
4468 | arg != None...'. Problem is, this fails if arg implements a |
|
4480 | arg != None...'. Problem is, this fails if arg implements a | |
4469 | special comparison (__cmp__) which disallows comparing to |
|
4481 | special comparison (__cmp__) which disallows comparing to | |
4470 | None. Found it when trying to use the PhysicalQuantity module from |
|
4482 | None. Found it when trying to use the PhysicalQuantity module from | |
4471 | ScientificPython. |
|
4483 | ScientificPython. | |
4472 |
|
4484 | |||
4473 | 2001-11-05 Fernando Perez <fperez@colorado.edu> |
|
4485 | 2001-11-05 Fernando Perez <fperez@colorado.edu> | |
4474 |
|
4486 | |||
4475 | * Also added dirs. Now the pushd/popd/dirs family functions |
|
4487 | * Also added dirs. Now the pushd/popd/dirs family functions | |
4476 | basically like the shell, with the added convenience of going home |
|
4488 | basically like the shell, with the added convenience of going home | |
4477 | when called with no args. |
|
4489 | when called with no args. | |
4478 |
|
4490 | |||
4479 | * pushd/popd slightly modified to mimic shell behavior more |
|
4491 | * pushd/popd slightly modified to mimic shell behavior more | |
4480 | closely. |
|
4492 | closely. | |
4481 |
|
4493 | |||
4482 | * Added env,pushd,popd from ShellServices as magic functions. I |
|
4494 | * Added env,pushd,popd from ShellServices as magic functions. I | |
4483 | think the cleanest will be to port all desired functions from |
|
4495 | think the cleanest will be to port all desired functions from | |
4484 | ShellServices as magics and remove ShellServices altogether. This |
|
4496 | ShellServices as magics and remove ShellServices altogether. This | |
4485 | will provide a single, clean way of adding functionality |
|
4497 | will provide a single, clean way of adding functionality | |
4486 | (shell-type or otherwise) to IP. |
|
4498 | (shell-type or otherwise) to IP. | |
4487 |
|
4499 | |||
4488 | 2001-11-04 Fernando Perez <fperez@colorado.edu> |
|
4500 | 2001-11-04 Fernando Perez <fperez@colorado.edu> | |
4489 |
|
4501 | |||
4490 | * Added .ipython/ directory to sys.path. This way users can keep |
|
4502 | * Added .ipython/ directory to sys.path. This way users can keep | |
4491 | customizations there and access them via import. |
|
4503 | customizations there and access them via import. | |
4492 |
|
4504 | |||
4493 | 2001-11-03 Fernando Perez <fperez@colorado.edu> |
|
4505 | 2001-11-03 Fernando Perez <fperez@colorado.edu> | |
4494 |
|
4506 | |||
4495 | * Opened version 0.1.1 for new changes. |
|
4507 | * Opened version 0.1.1 for new changes. | |
4496 |
|
4508 | |||
4497 | * Changed version number to 0.1.0: first 'public' release, sent to |
|
4509 | * Changed version number to 0.1.0: first 'public' release, sent to | |
4498 | Nathan and Janko. |
|
4510 | Nathan and Janko. | |
4499 |
|
4511 | |||
4500 | * Lots of small fixes and tweaks. |
|
4512 | * Lots of small fixes and tweaks. | |
4501 |
|
4513 | |||
4502 | * Minor changes to whos format. Now strings are shown, snipped if |
|
4514 | * Minor changes to whos format. Now strings are shown, snipped if | |
4503 | too long. |
|
4515 | too long. | |
4504 |
|
4516 | |||
4505 | * Changed ShellServices to work on __main__ so they show up in @who |
|
4517 | * Changed ShellServices to work on __main__ so they show up in @who | |
4506 |
|
4518 | |||
4507 | * Help also works with ? at the end of a line: |
|
4519 | * Help also works with ? at the end of a line: | |
4508 | ?sin and sin? |
|
4520 | ?sin and sin? | |
4509 | both produce the same effect. This is nice, as often I use the |
|
4521 | both produce the same effect. This is nice, as often I use the | |
4510 | tab-complete to find the name of a method, but I used to then have |
|
4522 | tab-complete to find the name of a method, but I used to then have | |
4511 | to go to the beginning of the line to put a ? if I wanted more |
|
4523 | to go to the beginning of the line to put a ? if I wanted more | |
4512 | info. Now I can just add the ? and hit return. Convenient. |
|
4524 | info. Now I can just add the ? and hit return. Convenient. | |
4513 |
|
4525 | |||
4514 | 2001-11-02 Fernando Perez <fperez@colorado.edu> |
|
4526 | 2001-11-02 Fernando Perez <fperez@colorado.edu> | |
4515 |
|
4527 | |||
4516 | * Python version check (>=2.1) added. |
|
4528 | * Python version check (>=2.1) added. | |
4517 |
|
4529 | |||
4518 | * Added LazyPython documentation. At this point the docs are quite |
|
4530 | * Added LazyPython documentation. At this point the docs are quite | |
4519 | a mess. A cleanup is in order. |
|
4531 | a mess. A cleanup is in order. | |
4520 |
|
4532 | |||
4521 | * Auto-installer created. For some bizarre reason, the zipfiles |
|
4533 | * Auto-installer created. For some bizarre reason, the zipfiles | |
4522 | module isn't working on my system. So I made a tar version |
|
4534 | module isn't working on my system. So I made a tar version | |
4523 | (hopefully the command line options in various systems won't kill |
|
4535 | (hopefully the command line options in various systems won't kill | |
4524 | me). |
|
4536 | me). | |
4525 |
|
4537 | |||
4526 | * Fixes to Struct in genutils. Now all dictionary-like methods are |
|
4538 | * Fixes to Struct in genutils. Now all dictionary-like methods are | |
4527 | protected (reasonably). |
|
4539 | protected (reasonably). | |
4528 |
|
4540 | |||
4529 | * Added pager function to genutils and changed ? to print usage |
|
4541 | * Added pager function to genutils and changed ? to print usage | |
4530 | note through it (it was too long). |
|
4542 | note through it (it was too long). | |
4531 |
|
4543 | |||
4532 | * Added the LazyPython functionality. Works great! I changed the |
|
4544 | * Added the LazyPython functionality. Works great! I changed the | |
4533 | auto-quote escape to ';', it's on home row and next to '. But |
|
4545 | auto-quote escape to ';', it's on home row and next to '. But | |
4534 | both auto-quote and auto-paren (still /) escapes are command-line |
|
4546 | both auto-quote and auto-paren (still /) escapes are command-line | |
4535 | parameters. |
|
4547 | parameters. | |
4536 |
|
4548 | |||
4537 |
|
4549 | |||
4538 | 2001-11-01 Fernando Perez <fperez@colorado.edu> |
|
4550 | 2001-11-01 Fernando Perez <fperez@colorado.edu> | |
4539 |
|
4551 | |||
4540 | * Version changed to 0.0.7. Fairly large change: configuration now |
|
4552 | * Version changed to 0.0.7. Fairly large change: configuration now | |
4541 | is all stored in a directory, by default .ipython. There, all |
|
4553 | is all stored in a directory, by default .ipython. There, all | |
4542 | config files have normal looking names (not .names) |
|
4554 | config files have normal looking names (not .names) | |
4543 |
|
4555 | |||
4544 | * Version 0.0.6 Released first to Lucas and Archie as a test |
|
4556 | * Version 0.0.6 Released first to Lucas and Archie as a test | |
4545 | run. Since it's the first 'semi-public' release, change version to |
|
4557 | run. Since it's the first 'semi-public' release, change version to | |
4546 | > 0.0.6 for any changes now. |
|
4558 | > 0.0.6 for any changes now. | |
4547 |
|
4559 | |||
4548 | * Stuff I had put in the ipplib.py changelog: |
|
4560 | * Stuff I had put in the ipplib.py changelog: | |
4549 |
|
4561 | |||
4550 | Changes to InteractiveShell: |
|
4562 | Changes to InteractiveShell: | |
4551 |
|
4563 | |||
4552 | - Made the usage message a parameter. |
|
4564 | - Made the usage message a parameter. | |
4553 |
|
4565 | |||
4554 | - Require the name of the shell variable to be given. It's a bit |
|
4566 | - Require the name of the shell variable to be given. It's a bit | |
4555 | of a hack, but allows the name 'shell' not to be hardwire in the |
|
4567 | of a hack, but allows the name 'shell' not to be hardwire in the | |
4556 | magic (@) handler, which is problematic b/c it requires |
|
4568 | magic (@) handler, which is problematic b/c it requires | |
4557 | polluting the global namespace with 'shell'. This in turn is |
|
4569 | polluting the global namespace with 'shell'. This in turn is | |
4558 | fragile: if a user redefines a variable called shell, things |
|
4570 | fragile: if a user redefines a variable called shell, things | |
4559 | break. |
|
4571 | break. | |
4560 |
|
4572 | |||
4561 | - magic @: all functions available through @ need to be defined |
|
4573 | - magic @: all functions available through @ need to be defined | |
4562 | as magic_<name>, even though they can be called simply as |
|
4574 | as magic_<name>, even though they can be called simply as | |
4563 | @<name>. This allows the special command @magic to gather |
|
4575 | @<name>. This allows the special command @magic to gather | |
4564 | information automatically about all existing magic functions, |
|
4576 | information automatically about all existing magic functions, | |
4565 | even if they are run-time user extensions, by parsing the shell |
|
4577 | even if they are run-time user extensions, by parsing the shell | |
4566 | instance __dict__ looking for special magic_ names. |
|
4578 | instance __dict__ looking for special magic_ names. | |
4567 |
|
4579 | |||
4568 | - mainloop: added *two* local namespace parameters. This allows |
|
4580 | - mainloop: added *two* local namespace parameters. This allows | |
4569 | the class to differentiate between parameters which were there |
|
4581 | the class to differentiate between parameters which were there | |
4570 | before and after command line initialization was processed. This |
|
4582 | before and after command line initialization was processed. This | |
4571 | way, later @who can show things loaded at startup by the |
|
4583 | way, later @who can show things loaded at startup by the | |
4572 | user. This trick was necessary to make session saving/reloading |
|
4584 | user. This trick was necessary to make session saving/reloading | |
4573 | really work: ideally after saving/exiting/reloading a session, |
|
4585 | really work: ideally after saving/exiting/reloading a session, | |
4574 | *everythin* should look the same, including the output of @who. I |
|
4586 | *everythin* should look the same, including the output of @who. I | |
4575 | was only able to make this work with this double namespace |
|
4587 | was only able to make this work with this double namespace | |
4576 | trick. |
|
4588 | trick. | |
4577 |
|
4589 | |||
4578 | - added a header to the logfile which allows (almost) full |
|
4590 | - added a header to the logfile which allows (almost) full | |
4579 | session restoring. |
|
4591 | session restoring. | |
4580 |
|
4592 | |||
4581 | - prepend lines beginning with @ or !, with a and log |
|
4593 | - prepend lines beginning with @ or !, with a and log | |
4582 | them. Why? !lines: may be useful to know what you did @lines: |
|
4594 | them. Why? !lines: may be useful to know what you did @lines: | |
4583 | they may affect session state. So when restoring a session, at |
|
4595 | they may affect session state. So when restoring a session, at | |
4584 | least inform the user of their presence. I couldn't quite get |
|
4596 | least inform the user of their presence. I couldn't quite get | |
4585 | them to properly re-execute, but at least the user is warned. |
|
4597 | them to properly re-execute, but at least the user is warned. | |
4586 |
|
4598 | |||
4587 | * Started ChangeLog. |
|
4599 | * Started ChangeLog. |
General Comments 0
You need to be logged in to leave comments.
Login now