Show More
@@ -1,228 +1,233 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | Logger class for IPython's logging facilities. |
|
3 | Logger class for IPython's logging facilities. | |
4 |
|
4 | |||
5 |
$Id: Logger.py 98 |
|
5 | $Id: Logger.py 988 2006-01-02 21:21:47Z fperez $ | |
6 | """ |
|
6 | """ | |
7 |
|
7 | |||
8 | #***************************************************************************** |
|
8 | #***************************************************************************** | |
9 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
9 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and | |
10 | # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu> |
|
10 | # Copyright (C) 2001-2005 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 | #**************************************************************************** |
|
16 | #**************************************************************************** | |
17 | # Modules and globals |
|
17 | # Modules and globals | |
18 |
|
18 | |||
19 | from IPython import Release |
|
19 | from IPython import Release | |
20 | __author__ = '%s <%s>\n%s <%s>' % \ |
|
20 | __author__ = '%s <%s>\n%s <%s>' % \ | |
21 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) |
|
21 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) | |
22 | __license__ = Release.license |
|
22 | __license__ = Release.license | |
23 |
|
23 | |||
24 | # Python standard modules |
|
24 | # Python standard modules | |
25 | import glob |
|
25 | import glob | |
26 | import os |
|
26 | import os | |
27 | import time |
|
27 | import time | |
28 |
|
28 | |||
29 | #**************************************************************************** |
|
29 | #**************************************************************************** | |
30 | # FIXME: This class isn't a mixin anymore, but it still needs attributes from |
|
30 | # FIXME: This class isn't a mixin anymore, but it still needs attributes from | |
31 | # ipython and does input cache management. Finish cleanup later... |
|
31 | # ipython and does input cache management. Finish cleanup later... | |
32 |
|
32 | |||
33 | class Logger(object): |
|
33 | class Logger(object): | |
34 | """A Logfile class with different policies for file creation""" |
|
34 | """A Logfile class with different policies for file creation""" | |
35 |
|
35 | |||
36 | def __init__(self,shell,logfname='Logger.log',loghead='',logmode='over'): |
|
36 | def __init__(self,shell,logfname='Logger.log',loghead='',logmode='over'): | |
37 |
|
37 | |||
38 | self._i00,self._i,self._ii,self._iii = '','','','' |
|
38 | self._i00,self._i,self._ii,self._iii = '','','','' | |
39 |
|
39 | |||
40 | # this is the full ipython instance, we need some attributes from it |
|
40 | # this is the full ipython instance, we need some attributes from it | |
41 | # which won't exist until later. What a mess, clean up later... |
|
41 | # which won't exist until later. What a mess, clean up later... | |
42 | self.shell = shell |
|
42 | self.shell = shell | |
43 |
|
43 | |||
44 | self.logfname = logfname |
|
44 | self.logfname = logfname | |
45 | self.loghead = loghead |
|
45 | self.loghead = loghead | |
46 | self.logmode = logmode |
|
46 | self.logmode = logmode | |
47 | self.logfile = None |
|
47 | self.logfile = None | |
48 |
|
48 | |||
49 | # whether to also log output |
|
49 | # whether to also log output | |
50 | self.log_output = False |
|
50 | self.log_output = False | |
51 |
|
51 | |||
52 | # whether to put timestamps before each log entry |
|
52 | # whether to put timestamps before each log entry | |
53 | self.timestamp = False |
|
53 | self.timestamp = False | |
54 |
|
54 | |||
55 | # activity control flags |
|
55 | # activity control flags | |
56 | self.log_active = False |
|
56 | self.log_active = False | |
57 |
|
57 | |||
58 | # logmode is a validated property |
|
58 | # logmode is a validated property | |
59 | def _set_mode(self,mode): |
|
59 | def _set_mode(self,mode): | |
60 | if mode not in ['append','backup','global','over','rotate']: |
|
60 | if mode not in ['append','backup','global','over','rotate']: | |
61 | raise ValueError,'invalid log mode %s given' % mode |
|
61 | raise ValueError,'invalid log mode %s given' % mode | |
62 | self._logmode = mode |
|
62 | self._logmode = mode | |
63 |
|
63 | |||
64 | def _get_mode(self): |
|
64 | def _get_mode(self): | |
65 | return self._logmode |
|
65 | return self._logmode | |
66 |
|
66 | |||
67 | logmode = property(_get_mode,_set_mode) |
|
67 | logmode = property(_get_mode,_set_mode) | |
68 |
|
68 | |||
69 | def logstart(self,logfname=None,loghead=None,logmode=None, |
|
69 | def logstart(self,logfname=None,loghead=None,logmode=None, | |
70 | log_output=False,timestamp=False): |
|
70 | log_output=False,timestamp=False): | |
71 | """Generate a new log-file with a default header. |
|
71 | """Generate a new log-file with a default header. | |
72 |
|
72 | |||
73 | Raises RuntimeError if the log has already been started""" |
|
73 | Raises RuntimeError if the log has already been started""" | |
74 |
|
74 | |||
75 | if self.logfile is not None: |
|
75 | if self.logfile is not None: | |
76 | raise RuntimeError('Log file is already active: %s' % |
|
76 | raise RuntimeError('Log file is already active: %s' % | |
77 | self.logfname) |
|
77 | self.logfname) | |
78 |
|
78 | |||
79 | self.log_active = True |
|
79 | self.log_active = True | |
80 |
|
80 | |||
81 | # The three parameters can override constructor defaults |
|
81 | # The three parameters can override constructor defaults | |
82 | if logfname: self.logfname = logfname |
|
82 | if logfname: self.logfname = logfname | |
83 | if loghead: self.loghead = loghead |
|
83 | if loghead: self.loghead = loghead | |
84 | if logmode: self.logmode = logmode |
|
84 | if logmode: self.logmode = logmode | |
85 | self.timestamp = timestamp |
|
85 | self.timestamp = timestamp | |
86 | self.log_output = log_output |
|
86 | self.log_output = log_output | |
87 |
|
87 | |||
88 | # init depending on the log mode requested |
|
88 | # init depending on the log mode requested | |
89 | isfile = os.path.isfile |
|
89 | isfile = os.path.isfile | |
90 | logmode = self.logmode |
|
90 | logmode = self.logmode | |
91 |
|
91 | |||
92 | if logmode == 'append': |
|
92 | if logmode == 'append': | |
93 | self.logfile = open(self.logfname,'a') |
|
93 | self.logfile = open(self.logfname,'a') | |
94 |
|
94 | |||
95 | elif logmode == 'backup': |
|
95 | elif logmode == 'backup': | |
96 | if isfile(self.logfname): |
|
96 | if isfile(self.logfname): | |
97 | backup_logname = self.logfname+'~' |
|
97 | backup_logname = self.logfname+'~' | |
98 | # Manually remove any old backup, since os.rename may fail |
|
98 | # Manually remove any old backup, since os.rename may fail | |
99 | # under Windows. |
|
99 | # under Windows. | |
100 | if isfile(backup_logname): |
|
100 | if isfile(backup_logname): | |
101 | os.remove(backup_logname) |
|
101 | os.remove(backup_logname) | |
102 | os.rename(self.logfname,backup_logname) |
|
102 | os.rename(self.logfname,backup_logname) | |
103 | self.logfile = open(self.logfname,'w') |
|
103 | self.logfile = open(self.logfname,'w') | |
104 |
|
104 | |||
105 | elif logmode == 'global': |
|
105 | elif logmode == 'global': | |
106 | self.logfname = os.path.join(self.shell.home_dir,self.logfname) |
|
106 | self.logfname = os.path.join(self.shell.home_dir,self.logfname) | |
107 | self.logfile = open(self.logfname, 'a') |
|
107 | self.logfile = open(self.logfname, 'a') | |
108 |
|
108 | |||
109 | elif logmode == 'over': |
|
109 | elif logmode == 'over': | |
110 | if isfile(self.logfname): |
|
110 | if isfile(self.logfname): | |
111 | os.remove(self.logfname) |
|
111 | os.remove(self.logfname) | |
112 | self.logfile = open(self.logfname,'w') |
|
112 | self.logfile = open(self.logfname,'w') | |
113 |
|
113 | |||
114 | elif logmode == 'rotate': |
|
114 | elif logmode == 'rotate': | |
115 | if isfile(self.logfname): |
|
115 | if isfile(self.logfname): | |
116 | if isfile(self.logfname+'.001~'): |
|
116 | if isfile(self.logfname+'.001~'): | |
117 | old = glob.glob(self.logfname+'.*~') |
|
117 | old = glob.glob(self.logfname+'.*~') | |
118 | old.sort() |
|
118 | old.sort() | |
119 | old.reverse() |
|
119 | old.reverse() | |
120 | for f in old: |
|
120 | for f in old: | |
121 | root, ext = os.path.splitext(f) |
|
121 | root, ext = os.path.splitext(f) | |
122 | num = int(ext[1:-1])+1 |
|
122 | num = int(ext[1:-1])+1 | |
123 | os.rename(f, root+'.'+`num`.zfill(3)+'~') |
|
123 | os.rename(f, root+'.'+`num`.zfill(3)+'~') | |
124 | os.rename(self.logfname, self.logfname+'.001~') |
|
124 | os.rename(self.logfname, self.logfname+'.001~') | |
125 | self.logfile = open(self.logfname,'w') |
|
125 | self.logfile = open(self.logfname,'w') | |
126 |
|
126 | |||
127 | if logmode != 'append': |
|
127 | if logmode != 'append': | |
128 | self.logfile.write(self.loghead) |
|
128 | self.logfile.write(self.loghead) | |
129 |
|
129 | |||
130 | self.logfile.flush() |
|
130 | self.logfile.flush() | |
131 |
|
131 | |||
132 | def switch_log(self,val): |
|
132 | def switch_log(self,val): | |
133 | """Switch logging on/off. val should be ONLY a boolean.""" |
|
133 | """Switch logging on/off. val should be ONLY a boolean.""" | |
134 |
|
134 | |||
135 | if val not in [False,True,0,1]: |
|
135 | if val not in [False,True,0,1]: | |
136 | raise ValueError, \ |
|
136 | raise ValueError, \ | |
137 | 'Call switch_log ONLY with a boolean argument, not with:',val |
|
137 | 'Call switch_log ONLY with a boolean argument, not with:',val | |
138 |
|
138 | |||
139 | label = {0:'OFF',1:'ON',False:'OFF',True:'ON'} |
|
139 | label = {0:'OFF',1:'ON',False:'OFF',True:'ON'} | |
140 |
|
140 | |||
141 | if self.logfile is None: |
|
141 | if self.logfile is None: | |
142 | print """ |
|
142 | print """ | |
143 | Logging hasn't been started yet (use logstart for that). |
|
143 | Logging hasn't been started yet (use logstart for that). | |
144 |
|
144 | |||
145 | %logon/%logoff are for temporarily starting and stopping logging for a logfile |
|
145 | %logon/%logoff are for temporarily starting and stopping logging for a logfile | |
146 | which already exists. But you must first start the logging process with |
|
146 | which already exists. But you must first start the logging process with | |
147 | %logstart (optionally giving a logfile name).""" |
|
147 | %logstart (optionally giving a logfile name).""" | |
148 |
|
148 | |||
149 | else: |
|
149 | else: | |
150 | if self.log_active == val: |
|
150 | if self.log_active == val: | |
151 | print 'Logging is already',label[val] |
|
151 | print 'Logging is already',label[val] | |
152 | else: |
|
152 | else: | |
153 | print 'Switching logging',label[val] |
|
153 | print 'Switching logging',label[val] | |
154 | self.log_active = not self.log_active |
|
154 | self.log_active = not self.log_active | |
155 | self.log_active_out = self.log_active |
|
155 | self.log_active_out = self.log_active | |
156 |
|
156 | |||
157 | def logstate(self): |
|
157 | def logstate(self): | |
158 | """Print a status message about the logger.""" |
|
158 | """Print a status message about the logger.""" | |
159 | if self.logfile is None: |
|
159 | if self.logfile is None: | |
160 | print 'Logging has not been activated.' |
|
160 | print 'Logging has not been activated.' | |
161 | else: |
|
161 | else: | |
162 | state = self.log_active and 'active' or 'temporarily suspended' |
|
162 | state = self.log_active and 'active' or 'temporarily suspended' | |
163 | print 'Filename :',self.logfname |
|
163 | print 'Filename :',self.logfname | |
164 | print 'Mode :',self.logmode |
|
164 | print 'Mode :',self.logmode | |
165 | print 'Output logging :',self.log_output |
|
165 | print 'Output logging :',self.log_output | |
166 | print 'Timestamping :',self.timestamp |
|
166 | print 'Timestamping :',self.timestamp | |
167 | print 'State :',state |
|
167 | print 'State :',state | |
168 |
|
168 | |||
169 | def log(self, line,continuation=None): |
|
169 | def log(self, line,continuation=None): | |
170 | """Write the line to a log and create input cache variables _i*.""" |
|
170 | """Write the line to a log and create input cache variables _i*.""" | |
171 |
|
171 | |||
172 | # update the auto _i tables |
|
172 | # update the auto _i tables | |
173 | #print '***logging line',line # dbg |
|
173 | #print '***logging line',line # dbg | |
174 | #print '***cache_count', self.shell.outputcache.prompt_count # dbg |
|
174 | #print '***cache_count', self.shell.outputcache.prompt_count # dbg | |
175 | input_hist = self.shell.user_ns['_ih'] |
|
175 | try: | |
|
176 | input_hist = self.shell.user_ns['_ih'] | |||
|
177 | except: | |||
|
178 | print 'userns:',self.shell.user_ns.keys() | |||
|
179 | return | |||
|
180 | ||||
176 | if not continuation and line: |
|
181 | if not continuation and line: | |
177 | self._iii = self._ii |
|
182 | self._iii = self._ii | |
178 | self._ii = self._i |
|
183 | self._ii = self._i | |
179 | self._i = self._i00 |
|
184 | self._i = self._i00 | |
180 | # put back the final \n of every input line |
|
185 | # put back the final \n of every input line | |
181 | self._i00 = line+'\n' |
|
186 | self._i00 = line+'\n' | |
182 | #print 'Logging input:<%s>' % line # dbg |
|
187 | #print 'Logging input:<%s>' % line # dbg | |
183 | input_hist.append(self._i00) |
|
188 | input_hist.append(self._i00) | |
184 | #print '---[%s]' % (len(input_hist)-1,) # dbg |
|
189 | #print '---[%s]' % (len(input_hist)-1,) # dbg | |
185 |
|
190 | |||
186 | # hackish access to top-level namespace to create _i1,_i2... dynamically |
|
191 | # hackish access to top-level namespace to create _i1,_i2... dynamically | |
187 | to_main = {'_i':self._i,'_ii':self._ii,'_iii':self._iii} |
|
192 | to_main = {'_i':self._i,'_ii':self._ii,'_iii':self._iii} | |
188 | if self.shell.outputcache.do_full_cache: |
|
193 | if self.shell.outputcache.do_full_cache: | |
189 | in_num = self.shell.outputcache.prompt_count |
|
194 | in_num = self.shell.outputcache.prompt_count | |
190 | # add blank lines if the input cache fell out of sync. This can |
|
195 | # add blank lines if the input cache fell out of sync. This can | |
191 | # happen for embedded instances which get killed via C-D and then |
|
196 | # happen for embedded instances which get killed via C-D and then | |
192 | # get resumed. |
|
197 | # get resumed. | |
193 | while in_num >= len(input_hist): |
|
198 | while in_num >= len(input_hist): | |
194 | input_hist.append('\n') |
|
199 | input_hist.append('\n') | |
195 | # but if the opposite is true (a macro can produce multiple inputs |
|
200 | # but if the opposite is true (a macro can produce multiple inputs | |
196 | # with no output display called), then bring the output counter in |
|
201 | # with no output display called), then bring the output counter in | |
197 | # sync: |
|
202 | # sync: | |
198 | last_num = len(input_hist)-1 |
|
203 | last_num = len(input_hist)-1 | |
199 | if in_num != last_num: |
|
204 | if in_num != last_num: | |
200 | in_num = self.shell.outputcache.prompt_count = last_num |
|
205 | in_num = self.shell.outputcache.prompt_count = last_num | |
201 | new_i = '_i%s' % in_num |
|
206 | new_i = '_i%s' % in_num | |
202 | if continuation: |
|
207 | if continuation: | |
203 | self._i00 = '%s%s\n' % (self.shell.user_ns[new_i],line) |
|
208 | self._i00 = '%s%s\n' % (self.shell.user_ns[new_i],line) | |
204 | input_hist[in_num] = self._i00 |
|
209 | input_hist[in_num] = self._i00 | |
205 | to_main[new_i] = self._i00 |
|
210 | to_main[new_i] = self._i00 | |
206 | self.shell.user_ns.update(to_main) |
|
211 | self.shell.user_ns.update(to_main) | |
207 | self.log_write(line) |
|
212 | self.log_write(line) | |
208 |
|
213 | |||
209 | def log_write(self,data,kind='input'): |
|
214 | def log_write(self,data,kind='input'): | |
210 | """Write data to the log file, if active""" |
|
215 | """Write data to the log file, if active""" | |
211 |
|
216 | |||
212 | if self.log_active and data: |
|
217 | if self.log_active and data: | |
213 | write = self.logfile.write |
|
218 | write = self.logfile.write | |
214 | if kind=='input': |
|
219 | if kind=='input': | |
215 | if self.timestamp: |
|
220 | if self.timestamp: | |
216 | write(time.strftime('# %a, %d %b %Y %H:%M:%S\n', |
|
221 | write(time.strftime('# %a, %d %b %Y %H:%M:%S\n', | |
217 | time.localtime())) |
|
222 | time.localtime())) | |
218 | write('%s\n' % data) |
|
223 | write('%s\n' % data) | |
219 | elif kind=='output' and self.log_output: |
|
224 | elif kind=='output' and self.log_output: | |
220 | odata = '\n'.join(['#[Out]# %s' % s |
|
225 | odata = '\n'.join(['#[Out]# %s' % s | |
221 | for s in data.split('\n')]) |
|
226 | for s in data.split('\n')]) | |
222 | write('%s\n' % odata) |
|
227 | write('%s\n' % odata) | |
223 | self.logfile.flush() |
|
228 | self.logfile.flush() | |
224 |
|
229 | |||
225 | def close_log(self): |
|
230 | def close_log(self): | |
226 | self.logfile.close() |
|
231 | self.logfile.close() | |
227 | self.logfile = None |
|
232 | self.logfile = None | |
228 | self.logfname = '' |
|
233 | self.logfname = '' |
@@ -1,2690 +1,2706 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 98 |
|
4 | $Id: Magic.py 988 2006-01-02 21:21:47Z 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 | import cPickle as pickle |
|
33 | import cPickle as pickle | |
34 | from cStringIO import StringIO |
|
34 | from cStringIO import StringIO | |
35 | from getopt import getopt |
|
35 | from getopt import getopt | |
36 | from pprint import pprint, pformat |
|
36 | from pprint import pprint, pformat | |
37 |
|
37 | |||
38 | # profile isn't bundled by default in Debian for license reasons |
|
38 | # profile isn't bundled by default in Debian for license reasons | |
39 | try: |
|
39 | try: | |
40 | import profile,pstats |
|
40 | import profile,pstats | |
41 | except ImportError: |
|
41 | except ImportError: | |
42 | profile = pstats = None |
|
42 | profile = pstats = None | |
43 |
|
43 | |||
44 | # Homebrewed |
|
44 | # Homebrewed | |
45 | from IPython import Debugger, OInspect, wildcard |
|
45 | from IPython import Debugger, OInspect, wildcard | |
46 | from IPython.FakeModule import FakeModule |
|
46 | from IPython.FakeModule import FakeModule | |
47 | from IPython.Itpl import Itpl, itpl, printpl,itplns |
|
47 | from IPython.Itpl import Itpl, itpl, printpl,itplns | |
48 | from IPython.PyColorize import Parser |
|
48 | from IPython.PyColorize import Parser | |
49 | from IPython.Struct import Struct |
|
49 | from IPython.Struct import Struct | |
50 | from IPython.macro import Macro |
|
50 | from IPython.macro import Macro | |
51 | from IPython.genutils import * |
|
51 | from IPython.genutils import * | |
52 |
|
52 | |||
53 | #*************************************************************************** |
|
53 | #*************************************************************************** | |
54 | # Utility functions |
|
54 | # Utility functions | |
55 | def on_off(tag): |
|
55 | def on_off(tag): | |
56 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" |
|
56 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" | |
57 | return ['OFF','ON'][tag] |
|
57 | return ['OFF','ON'][tag] | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | #*************************************************************************** |
|
60 | #*************************************************************************** | |
61 | # Main class implementing Magic functionality |
|
61 | # Main class implementing Magic functionality | |
62 | class Magic: |
|
62 | class Magic: | |
63 | """Magic functions for InteractiveShell. |
|
63 | """Magic functions for InteractiveShell. | |
64 |
|
64 | |||
65 | Shell functions which can be reached as %function_name. All magic |
|
65 | Shell functions which can be reached as %function_name. All magic | |
66 | functions should accept a string, which they can parse for their own |
|
66 | functions should accept a string, which they can parse for their own | |
67 | needs. This can make some functions easier to type, eg `%cd ../` |
|
67 | needs. This can make some functions easier to type, eg `%cd ../` | |
68 | vs. `%cd("../")` |
|
68 | vs. `%cd("../")` | |
69 |
|
69 | |||
70 | ALL definitions MUST begin with the prefix magic_. The user won't need it |
|
70 | ALL definitions MUST begin with the prefix magic_. The user won't need it | |
71 | at the command line, but it is is needed in the definition. """ |
|
71 | at the command line, but it is is needed in the definition. """ | |
72 |
|
72 | |||
73 | # class globals |
|
73 | # class globals | |
74 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', |
|
74 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', | |
75 | 'Automagic is ON, % prefix NOT needed for magic functions.'] |
|
75 | 'Automagic is ON, % prefix NOT needed for magic functions.'] | |
76 |
|
76 | |||
77 | #...................................................................... |
|
77 | #...................................................................... | |
78 | # some utility functions |
|
78 | # some utility functions | |
79 |
|
79 | |||
80 | def __init__(self,shell): |
|
80 | def __init__(self,shell): | |
81 |
|
81 | |||
82 | self.options_table = {} |
|
82 | self.options_table = {} | |
83 | if profile is None: |
|
83 | if profile is None: | |
84 | self.magic_prun = self.profile_missing_notice |
|
84 | self.magic_prun = self.profile_missing_notice | |
85 | self.shell = shell |
|
85 | self.shell = shell | |
86 |
|
86 | |||
87 | def profile_missing_notice(self, *args, **kwargs): |
|
87 | def profile_missing_notice(self, *args, **kwargs): | |
88 | error("""\ |
|
88 | error("""\ | |
89 | The profile module could not be found. If you are a Debian user, |
|
89 | The profile module could not be found. If you are a Debian user, | |
90 | it has been removed from the standard Debian package because of its non-free |
|
90 | it has been removed from the standard Debian package because of its non-free | |
91 | license. To use profiling, please install"python2.3-profiler" from non-free.""") |
|
91 | license. To use profiling, please install"python2.3-profiler" from non-free.""") | |
92 |
|
92 | |||
93 | def default_option(self,fn,optstr): |
|
93 | def default_option(self,fn,optstr): | |
94 | """Make an entry in the options_table for fn, with value optstr""" |
|
94 | """Make an entry in the options_table for fn, with value optstr""" | |
95 |
|
95 | |||
96 | if fn not in self.lsmagic(): |
|
96 | if fn not in self.lsmagic(): | |
97 | error("%s is not a magic function" % fn) |
|
97 | error("%s is not a magic function" % fn) | |
98 | self.options_table[fn] = optstr |
|
98 | self.options_table[fn] = optstr | |
99 |
|
99 | |||
100 | def lsmagic(self): |
|
100 | def lsmagic(self): | |
101 | """Return a list of currently available magic functions. |
|
101 | """Return a list of currently available magic functions. | |
102 |
|
102 | |||
103 | Gives a list of the bare names after mangling (['ls','cd', ...], not |
|
103 | Gives a list of the bare names after mangling (['ls','cd', ...], not | |
104 | ['magic_ls','magic_cd',...]""" |
|
104 | ['magic_ls','magic_cd',...]""" | |
105 |
|
105 | |||
106 | # FIXME. This needs a cleanup, in the way the magics list is built. |
|
106 | # FIXME. This needs a cleanup, in the way the magics list is built. | |
107 |
|
107 | |||
108 | # magics in class definition |
|
108 | # magics in class definition | |
109 | class_magic = lambda fn: fn.startswith('magic_') and \ |
|
109 | class_magic = lambda fn: fn.startswith('magic_') and \ | |
110 | callable(Magic.__dict__[fn]) |
|
110 | callable(Magic.__dict__[fn]) | |
111 | # in instance namespace (run-time user additions) |
|
111 | # in instance namespace (run-time user additions) | |
112 | inst_magic = lambda fn: fn.startswith('magic_') and \ |
|
112 | inst_magic = lambda fn: fn.startswith('magic_') and \ | |
113 | callable(self.__dict__[fn]) |
|
113 | callable(self.__dict__[fn]) | |
114 | # and bound magics by user (so they can access self): |
|
114 | # and bound magics by user (so they can access self): | |
115 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ |
|
115 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ | |
116 | callable(self.__class__.__dict__[fn]) |
|
116 | callable(self.__class__.__dict__[fn]) | |
117 | magics = filter(class_magic,Magic.__dict__.keys()) + \ |
|
117 | magics = filter(class_magic,Magic.__dict__.keys()) + \ | |
118 | filter(inst_magic,self.__dict__.keys()) + \ |
|
118 | filter(inst_magic,self.__dict__.keys()) + \ | |
119 | filter(inst_bound_magic,self.__class__.__dict__.keys()) |
|
119 | filter(inst_bound_magic,self.__class__.__dict__.keys()) | |
120 | out = [] |
|
120 | out = [] | |
121 | for fn in magics: |
|
121 | for fn in magics: | |
122 | out.append(fn.replace('magic_','',1)) |
|
122 | out.append(fn.replace('magic_','',1)) | |
123 | out.sort() |
|
123 | out.sort() | |
124 | return out |
|
124 | return out | |
125 |
|
125 | |||
126 | def extract_input_slices(self,slices): |
|
126 | def extract_input_slices(self,slices): | |
127 | """Return as a string a set of input history slices. |
|
127 | """Return as a string a set of input history slices. | |
128 |
|
128 | |||
129 | The set of slices is given as a list of strings (like ['1','4:8','9'], |
|
129 | The set of slices is given as a list of strings (like ['1','4:8','9'], | |
130 | since this function is for use by magic functions which get their |
|
130 | since this function is for use by magic functions which get their | |
131 | arguments as strings. |
|
131 | arguments as strings. | |
132 |
|
132 | |||
133 | Note that slices can be called with two notations: |
|
133 | Note that slices can be called with two notations: | |
134 |
|
134 | |||
135 | N:M -> standard python form, means including items N...(M-1). |
|
135 | N:M -> standard python form, means including items N...(M-1). | |
136 |
|
136 | |||
137 | N-M -> include items N..M (closed endpoint).""" |
|
137 | N-M -> include items N..M (closed endpoint).""" | |
138 |
|
138 | |||
139 | cmds = [] |
|
139 | cmds = [] | |
140 | for chunk in slices: |
|
140 | for chunk in slices: | |
141 | if ':' in chunk: |
|
141 | if ':' in chunk: | |
142 | ini,fin = map(int,chunk.split(':')) |
|
142 | ini,fin = map(int,chunk.split(':')) | |
143 | elif '-' in chunk: |
|
143 | elif '-' in chunk: | |
144 | ini,fin = map(int,chunk.split('-')) |
|
144 | ini,fin = map(int,chunk.split('-')) | |
145 | fin += 1 |
|
145 | fin += 1 | |
146 | else: |
|
146 | else: | |
147 | ini = int(chunk) |
|
147 | ini = int(chunk) | |
148 | fin = ini+1 |
|
148 | fin = ini+1 | |
149 | cmds.append(self.shell.input_hist[ini:fin]) |
|
149 | cmds.append(self.shell.input_hist[ini:fin]) | |
150 | return cmds |
|
150 | return cmds | |
151 |
|
151 | |||
152 | def _ofind(self,oname): |
|
152 | def _ofind(self,oname): | |
153 | """Find an object in the available namespaces. |
|
153 | """Find an object in the available namespaces. | |
154 |
|
154 | |||
155 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic |
|
155 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic | |
156 |
|
156 | |||
157 | Has special code to detect magic functions. |
|
157 | Has special code to detect magic functions. | |
158 | """ |
|
158 | """ | |
159 |
|
159 | |||
160 | oname = oname.strip() |
|
160 | oname = oname.strip() | |
161 |
|
161 | |||
162 | # Namespaces to search in: |
|
162 | # Namespaces to search in: | |
163 | user_ns = self.shell.user_ns |
|
163 | user_ns = self.shell.user_ns | |
164 | internal_ns = self.shell.internal_ns |
|
164 | internal_ns = self.shell.internal_ns | |
165 | builtin_ns = __builtin__.__dict__ |
|
165 | builtin_ns = __builtin__.__dict__ | |
166 | alias_ns = self.shell.alias_table |
|
166 | alias_ns = self.shell.alias_table | |
167 |
|
167 | |||
168 | # Put them in a list. The order is important so that we find things in |
|
168 | # Put them in a list. The order is important so that we find things in | |
169 | # the same order that Python finds them. |
|
169 | # the same order that Python finds them. | |
170 | namespaces = [ ('Interactive',user_ns), |
|
170 | namespaces = [ ('Interactive',user_ns), | |
171 | ('IPython internal',internal_ns), |
|
171 | ('IPython internal',internal_ns), | |
172 | ('Python builtin',builtin_ns), |
|
172 | ('Python builtin',builtin_ns), | |
173 | ('Alias',alias_ns), |
|
173 | ('Alias',alias_ns), | |
174 | ] |
|
174 | ] | |
175 |
|
175 | |||
176 | # initialize results to 'null' |
|
176 | # initialize results to 'null' | |
177 | found = 0; obj = None; ospace = None; ds = None; |
|
177 | found = 0; obj = None; ospace = None; ds = None; | |
178 | ismagic = 0; isalias = 0 |
|
178 | ismagic = 0; isalias = 0 | |
179 |
|
179 | |||
180 | # Look for the given name by splitting it in parts. If the head is |
|
180 | # Look for the given name by splitting it in parts. If the head is | |
181 | # found, then we look for all the remaining parts as members, and only |
|
181 | # found, then we look for all the remaining parts as members, and only | |
182 | # declare success if we can find them all. |
|
182 | # declare success if we can find them all. | |
183 | oname_parts = oname.split('.') |
|
183 | oname_parts = oname.split('.') | |
184 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] |
|
184 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] | |
185 | for nsname,ns in namespaces: |
|
185 | for nsname,ns in namespaces: | |
186 | try: |
|
186 | try: | |
187 | obj = ns[oname_head] |
|
187 | obj = ns[oname_head] | |
188 | except KeyError: |
|
188 | except KeyError: | |
189 | continue |
|
189 | continue | |
190 | else: |
|
190 | else: | |
191 | for part in oname_rest: |
|
191 | for part in oname_rest: | |
192 | try: |
|
192 | try: | |
193 | obj = getattr(obj,part) |
|
193 | obj = getattr(obj,part) | |
194 | except: |
|
194 | except: | |
195 | # Blanket except b/c some badly implemented objects |
|
195 | # Blanket except b/c some badly implemented objects | |
196 | # allow __getattr__ to raise exceptions other than |
|
196 | # allow __getattr__ to raise exceptions other than | |
197 | # AttributeError, which then crashes IPython. |
|
197 | # AttributeError, which then crashes IPython. | |
198 | break |
|
198 | break | |
199 | else: |
|
199 | else: | |
200 | # If we finish the for loop (no break), we got all members |
|
200 | # If we finish the for loop (no break), we got all members | |
201 | found = 1 |
|
201 | found = 1 | |
202 | ospace = nsname |
|
202 | ospace = nsname | |
203 | if ns == alias_ns: |
|
203 | if ns == alias_ns: | |
204 | isalias = 1 |
|
204 | isalias = 1 | |
205 | break # namespace loop |
|
205 | break # namespace loop | |
206 |
|
206 | |||
207 | # Try to see if it's magic |
|
207 | # Try to see if it's magic | |
208 | if not found: |
|
208 | if not found: | |
209 | if oname.startswith(self.shell.ESC_MAGIC): |
|
209 | if oname.startswith(self.shell.ESC_MAGIC): | |
210 | oname = oname[1:] |
|
210 | oname = oname[1:] | |
211 | obj = getattr(self,'magic_'+oname,None) |
|
211 | obj = getattr(self,'magic_'+oname,None) | |
212 | if obj is not None: |
|
212 | if obj is not None: | |
213 | found = 1 |
|
213 | found = 1 | |
214 | ospace = 'IPython internal' |
|
214 | ospace = 'IPython internal' | |
215 | ismagic = 1 |
|
215 | ismagic = 1 | |
216 |
|
216 | |||
217 | # Last try: special-case some literals like '', [], {}, etc: |
|
217 | # Last try: special-case some literals like '', [], {}, etc: | |
218 | if not found and oname_head in ["''",'""','[]','{}','()']: |
|
218 | if not found and oname_head in ["''",'""','[]','{}','()']: | |
219 | obj = eval(oname_head) |
|
219 | obj = eval(oname_head) | |
220 | found = 1 |
|
220 | found = 1 | |
221 | ospace = 'Interactive' |
|
221 | ospace = 'Interactive' | |
222 |
|
222 | |||
223 | return {'found':found, 'obj':obj, 'namespace':ospace, |
|
223 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
224 | 'ismagic':ismagic, 'isalias':isalias} |
|
224 | 'ismagic':ismagic, 'isalias':isalias} | |
225 |
|
225 | |||
226 | def arg_err(self,func): |
|
226 | def arg_err(self,func): | |
227 | """Print docstring if incorrect arguments were passed""" |
|
227 | """Print docstring if incorrect arguments were passed""" | |
228 | print 'Error in arguments:' |
|
228 | print 'Error in arguments:' | |
229 | print OInspect.getdoc(func) |
|
229 | print OInspect.getdoc(func) | |
230 |
|
230 | |||
231 | def format_latex(self,strng): |
|
231 | def format_latex(self,strng): | |
232 | """Format a string for latex inclusion.""" |
|
232 | """Format a string for latex inclusion.""" | |
233 |
|
233 | |||
234 | # Characters that need to be escaped for latex: |
|
234 | # Characters that need to be escaped for latex: | |
235 | escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE) |
|
235 | escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE) | |
236 | # Magic command names as headers: |
|
236 | # Magic command names as headers: | |
237 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, |
|
237 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, | |
238 | re.MULTILINE) |
|
238 | re.MULTILINE) | |
239 | # Magic commands |
|
239 | # Magic commands | |
240 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, |
|
240 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, | |
241 | re.MULTILINE) |
|
241 | re.MULTILINE) | |
242 | # Paragraph continue |
|
242 | # Paragraph continue | |
243 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
243 | par_re = re.compile(r'\\$',re.MULTILINE) | |
244 |
|
244 | |||
245 | # The "\n" symbol |
|
245 | # The "\n" symbol | |
246 | newline_re = re.compile(r'\\n') |
|
246 | newline_re = re.compile(r'\\n') | |
247 |
|
247 | |||
248 | # Now build the string for output: |
|
248 | # Now build the string for output: | |
249 | strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng) |
|
249 | strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng) | |
250 | strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng) |
|
250 | strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng) | |
251 | strng = par_re.sub(r'\\\\',strng) |
|
251 | strng = par_re.sub(r'\\\\',strng) | |
252 | strng = escape_re.sub(r'\\\1',strng) |
|
252 | strng = escape_re.sub(r'\\\1',strng) | |
253 | strng = newline_re.sub(r'\\textbackslash{}n',strng) |
|
253 | strng = newline_re.sub(r'\\textbackslash{}n',strng) | |
254 | return strng |
|
254 | return strng | |
255 |
|
255 | |||
256 | def format_screen(self,strng): |
|
256 | def format_screen(self,strng): | |
257 | """Format a string for screen printing. |
|
257 | """Format a string for screen printing. | |
258 |
|
258 | |||
259 | This removes some latex-type format codes.""" |
|
259 | This removes some latex-type format codes.""" | |
260 | # Paragraph continue |
|
260 | # Paragraph continue | |
261 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
261 | par_re = re.compile(r'\\$',re.MULTILINE) | |
262 | strng = par_re.sub('',strng) |
|
262 | strng = par_re.sub('',strng) | |
263 | return strng |
|
263 | return strng | |
264 |
|
264 | |||
265 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): |
|
265 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): | |
266 | """Parse options passed to an argument string. |
|
266 | """Parse options passed to an argument string. | |
267 |
|
267 | |||
268 | The interface is similar to that of getopt(), but it returns back a |
|
268 | The interface is similar to that of getopt(), but it returns back a | |
269 | Struct with the options as keys and the stripped argument string still |
|
269 | Struct with the options as keys and the stripped argument string still | |
270 | as a string. |
|
270 | as a string. | |
271 |
|
271 | |||
272 | arg_str is quoted as a true sys.argv vector by using shlex.split. |
|
272 | arg_str is quoted as a true sys.argv vector by using shlex.split. | |
273 | This allows us to easily expand variables, glob files, quote |
|
273 | This allows us to easily expand variables, glob files, quote | |
274 | arguments, etc. |
|
274 | arguments, etc. | |
275 |
|
275 | |||
276 | Options: |
|
276 | Options: | |
277 | -mode: default 'string'. If given as 'list', the argument string is |
|
277 | -mode: default 'string'. If given as 'list', the argument string is | |
278 | returned as a list (split on whitespace) instead of a string. |
|
278 | returned as a list (split on whitespace) instead of a string. | |
279 |
|
279 | |||
280 | -list_all: put all option values in lists. Normally only options |
|
280 | -list_all: put all option values in lists. Normally only options | |
281 | appearing more than once are put in a list.""" |
|
281 | appearing more than once are put in a list.""" | |
282 |
|
282 | |||
283 | # inject default options at the beginning of the input line |
|
283 | # inject default options at the beginning of the input line | |
284 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') |
|
284 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') | |
285 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) |
|
285 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) | |
286 |
|
286 | |||
287 | mode = kw.get('mode','string') |
|
287 | mode = kw.get('mode','string') | |
288 | if mode not in ['string','list']: |
|
288 | if mode not in ['string','list']: | |
289 | raise ValueError,'incorrect mode given: %s' % mode |
|
289 | raise ValueError,'incorrect mode given: %s' % mode | |
290 | # Get options |
|
290 | # Get options | |
291 | list_all = kw.get('list_all',0) |
|
291 | list_all = kw.get('list_all',0) | |
292 |
|
292 | |||
293 | # Check if we have more than one argument to warrant extra processing: |
|
293 | # Check if we have more than one argument to warrant extra processing: | |
294 | odict = {} # Dictionary with options |
|
294 | odict = {} # Dictionary with options | |
295 | args = arg_str.split() |
|
295 | args = arg_str.split() | |
296 | if len(args) >= 1: |
|
296 | if len(args) >= 1: | |
297 | # If the list of inputs only has 0 or 1 thing in it, there's no |
|
297 | # If the list of inputs only has 0 or 1 thing in it, there's no | |
298 | # need to look for options |
|
298 | # need to look for options | |
299 | argv = shlex_split(arg_str) |
|
299 | argv = shlex_split(arg_str) | |
300 | # Do regular option processing |
|
300 | # Do regular option processing | |
301 | opts,args = getopt(argv,opt_str,*long_opts) |
|
301 | opts,args = getopt(argv,opt_str,*long_opts) | |
302 | for o,a in opts: |
|
302 | for o,a in opts: | |
303 | if o.startswith('--'): |
|
303 | if o.startswith('--'): | |
304 | o = o[2:] |
|
304 | o = o[2:] | |
305 | else: |
|
305 | else: | |
306 | o = o[1:] |
|
306 | o = o[1:] | |
307 | try: |
|
307 | try: | |
308 | odict[o].append(a) |
|
308 | odict[o].append(a) | |
309 | except AttributeError: |
|
309 | except AttributeError: | |
310 | odict[o] = [odict[o],a] |
|
310 | odict[o] = [odict[o],a] | |
311 | except KeyError: |
|
311 | except KeyError: | |
312 | if list_all: |
|
312 | if list_all: | |
313 | odict[o] = [a] |
|
313 | odict[o] = [a] | |
314 | else: |
|
314 | else: | |
315 | odict[o] = a |
|
315 | odict[o] = a | |
316 |
|
316 | |||
317 | # Prepare opts,args for return |
|
317 | # Prepare opts,args for return | |
318 | opts = Struct(odict) |
|
318 | opts = Struct(odict) | |
319 | if mode == 'string': |
|
319 | if mode == 'string': | |
320 | args = ' '.join(args) |
|
320 | args = ' '.join(args) | |
321 |
|
321 | |||
322 | return opts,args |
|
322 | return opts,args | |
323 |
|
323 | |||
324 | #...................................................................... |
|
324 | #...................................................................... | |
325 | # And now the actual magic functions |
|
325 | # And now the actual magic functions | |
326 |
|
326 | |||
327 | # Functions for IPython shell work (vars,funcs, config, etc) |
|
327 | # Functions for IPython shell work (vars,funcs, config, etc) | |
328 | def magic_lsmagic(self, parameter_s = ''): |
|
328 | def magic_lsmagic(self, parameter_s = ''): | |
329 | """List currently available magic functions.""" |
|
329 | """List currently available magic functions.""" | |
330 | mesc = self.shell.ESC_MAGIC |
|
330 | mesc = self.shell.ESC_MAGIC | |
331 | print 'Available magic functions:\n'+mesc+\ |
|
331 | print 'Available magic functions:\n'+mesc+\ | |
332 | (' '+mesc).join(self.lsmagic()) |
|
332 | (' '+mesc).join(self.lsmagic()) | |
333 | print '\n' + Magic.auto_status[self.shell.rc.automagic] |
|
333 | print '\n' + Magic.auto_status[self.shell.rc.automagic] | |
334 | return None |
|
334 | return None | |
335 |
|
335 | |||
336 | def magic_magic(self, parameter_s = ''): |
|
336 | def magic_magic(self, parameter_s = ''): | |
337 | """Print information about the magic function system.""" |
|
337 | """Print information about the magic function system.""" | |
338 |
|
338 | |||
339 | mode = '' |
|
339 | mode = '' | |
340 | try: |
|
340 | try: | |
341 | if parameter_s.split()[0] == '-latex': |
|
341 | if parameter_s.split()[0] == '-latex': | |
342 | mode = 'latex' |
|
342 | mode = 'latex' | |
343 | except: |
|
343 | except: | |
344 | pass |
|
344 | pass | |
345 |
|
345 | |||
346 | magic_docs = [] |
|
346 | magic_docs = [] | |
347 | for fname in self.lsmagic(): |
|
347 | for fname in self.lsmagic(): | |
348 | mname = 'magic_' + fname |
|
348 | mname = 'magic_' + fname | |
349 | for space in (Magic,self,self.__class__): |
|
349 | for space in (Magic,self,self.__class__): | |
350 | try: |
|
350 | try: | |
351 | fn = space.__dict__[mname] |
|
351 | fn = space.__dict__[mname] | |
352 | except KeyError: |
|
352 | except KeyError: | |
353 | pass |
|
353 | pass | |
354 | else: |
|
354 | else: | |
355 | break |
|
355 | break | |
356 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, |
|
356 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, | |
357 | fname,fn.__doc__)) |
|
357 | fname,fn.__doc__)) | |
358 | magic_docs = ''.join(magic_docs) |
|
358 | magic_docs = ''.join(magic_docs) | |
359 |
|
359 | |||
360 | if mode == 'latex': |
|
360 | if mode == 'latex': | |
361 | print self.format_latex(magic_docs) |
|
361 | print self.format_latex(magic_docs) | |
362 | return |
|
362 | return | |
363 | else: |
|
363 | else: | |
364 | magic_docs = self.format_screen(magic_docs) |
|
364 | magic_docs = self.format_screen(magic_docs) | |
365 |
|
365 | |||
366 | outmsg = """ |
|
366 | outmsg = """ | |
367 | IPython's 'magic' functions |
|
367 | IPython's 'magic' functions | |
368 | =========================== |
|
368 | =========================== | |
369 |
|
369 | |||
370 | The magic function system provides a series of functions which allow you to |
|
370 | The magic function system provides a series of functions which allow you to | |
371 | control the behavior of IPython itself, plus a lot of system-type |
|
371 | control the behavior of IPython itself, plus a lot of system-type | |
372 | features. All these functions are prefixed with a % character, but parameters |
|
372 | features. All these functions are prefixed with a % character, but parameters | |
373 | are given without parentheses or quotes. |
|
373 | are given without parentheses or quotes. | |
374 |
|
374 | |||
375 | NOTE: If you have 'automagic' enabled (via the command line option or with the |
|
375 | NOTE: If you have 'automagic' enabled (via the command line option or with the | |
376 | %automagic function), you don't need to type in the % explicitly. By default, |
|
376 | %automagic function), you don't need to type in the % explicitly. By default, | |
377 | IPython ships with automagic on, so you should only rarely need the % escape. |
|
377 | IPython ships with automagic on, so you should only rarely need the % escape. | |
378 |
|
378 | |||
379 | Example: typing '%cd mydir' (without the quotes) changes you working directory |
|
379 | Example: typing '%cd mydir' (without the quotes) changes you working directory | |
380 | to 'mydir', if it exists. |
|
380 | to 'mydir', if it exists. | |
381 |
|
381 | |||
382 | You can define your own magic functions to extend the system. See the supplied |
|
382 | You can define your own magic functions to extend the system. See the supplied | |
383 | ipythonrc and example-magic.py files for details (in your ipython |
|
383 | ipythonrc and example-magic.py files for details (in your ipython | |
384 | configuration directory, typically $HOME/.ipython/). |
|
384 | configuration directory, typically $HOME/.ipython/). | |
385 |
|
385 | |||
386 | You can also define your own aliased names for magic functions. In your |
|
386 | You can also define your own aliased names for magic functions. In your | |
387 | ipythonrc file, placing a line like: |
|
387 | ipythonrc file, placing a line like: | |
388 |
|
388 | |||
389 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile |
|
389 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile | |
390 |
|
390 | |||
391 | will define %pf as a new name for %profile. |
|
391 | will define %pf as a new name for %profile. | |
392 |
|
392 | |||
393 | You can also call magics in code using the ipmagic() function, which IPython |
|
393 | You can also call magics in code using the ipmagic() function, which IPython | |
394 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. |
|
394 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. | |
395 |
|
395 | |||
396 | For a list of the available magic functions, use %lsmagic. For a description |
|
396 | For a list of the available magic functions, use %lsmagic. For a description | |
397 | of any of them, type %magic_name?, e.g. '%cd?'. |
|
397 | of any of them, type %magic_name?, e.g. '%cd?'. | |
398 |
|
398 | |||
399 | Currently the magic system has the following functions:\n""" |
|
399 | Currently the magic system has the following functions:\n""" | |
400 |
|
400 | |||
401 | mesc = self.shell.ESC_MAGIC |
|
401 | mesc = self.shell.ESC_MAGIC | |
402 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" |
|
402 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" | |
403 | "\n\n%s%s\n\n%s" % (outmsg, |
|
403 | "\n\n%s%s\n\n%s" % (outmsg, | |
404 | magic_docs,mesc,mesc, |
|
404 | magic_docs,mesc,mesc, | |
405 | (' '+mesc).join(self.lsmagic()), |
|
405 | (' '+mesc).join(self.lsmagic()), | |
406 | Magic.auto_status[self.shell.rc.automagic] ) ) |
|
406 | Magic.auto_status[self.shell.rc.automagic] ) ) | |
407 |
|
407 | |||
408 | page(outmsg,screen_lines=self.shell.rc.screen_length) |
|
408 | page(outmsg,screen_lines=self.shell.rc.screen_length) | |
409 |
|
409 | |||
410 | def magic_automagic(self, parameter_s = ''): |
|
410 | def magic_automagic(self, parameter_s = ''): | |
411 | """Make magic functions callable without having to type the initial %. |
|
411 | """Make magic functions callable without having to type the initial %. | |
412 |
|
412 | |||
413 | Toggles on/off (when off, you must call it as %automagic, of |
|
413 | Toggles on/off (when off, you must call it as %automagic, of | |
414 | course). Note that magic functions have lowest priority, so if there's |
|
414 | course). Note that magic functions have lowest priority, so if there's | |
415 | a variable whose name collides with that of a magic fn, automagic |
|
415 | a variable whose name collides with that of a magic fn, automagic | |
416 | won't work for that function (you get the variable instead). However, |
|
416 | won't work for that function (you get the variable instead). However, | |
417 | if you delete the variable (del var), the previously shadowed magic |
|
417 | if you delete the variable (del var), the previously shadowed magic | |
418 | function becomes visible to automagic again.""" |
|
418 | function becomes visible to automagic again.""" | |
419 |
|
419 | |||
420 | rc = self.shell.rc |
|
420 | rc = self.shell.rc | |
421 | rc.automagic = not rc.automagic |
|
421 | rc.automagic = not rc.automagic | |
422 | print '\n' + Magic.auto_status[rc.automagic] |
|
422 | print '\n' + Magic.auto_status[rc.automagic] | |
423 |
|
423 | |||
424 | def magic_autocall(self, parameter_s = ''): |
|
424 | def magic_autocall(self, parameter_s = ''): | |
425 | """Make functions callable without having to type parentheses. |
|
425 | """Make functions callable without having to type parentheses. | |
426 |
|
426 | |||
427 | This toggles the autocall command line option on and off.""" |
|
427 | This toggles the autocall command line option on and off.""" | |
428 |
|
428 | |||
429 | rc = self.shell.rc |
|
429 | rc = self.shell.rc | |
430 | rc.autocall = not rc.autocall |
|
430 | rc.autocall = not rc.autocall | |
431 | print "Automatic calling is:",['OFF','ON'][rc.autocall] |
|
431 | print "Automatic calling is:",['OFF','ON'][rc.autocall] | |
432 |
|
432 | |||
433 | def magic_autoindent(self, parameter_s = ''): |
|
433 | def magic_autoindent(self, parameter_s = ''): | |
434 | """Toggle autoindent on/off (if available).""" |
|
434 | """Toggle autoindent on/off (if available).""" | |
435 |
|
435 | |||
436 | self.shell.set_autoindent() |
|
436 | self.shell.set_autoindent() | |
437 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] |
|
437 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] | |
438 |
|
438 | |||
439 | def magic_system_verbose(self, parameter_s = ''): |
|
439 | def magic_system_verbose(self, parameter_s = ''): | |
440 | """Toggle verbose printing of system calls on/off.""" |
|
440 | """Toggle verbose printing of system calls on/off.""" | |
441 |
|
441 | |||
442 | self.shell.rc_set_toggle('system_verbose') |
|
442 | self.shell.rc_set_toggle('system_verbose') | |
443 | print "System verbose printing is:",\ |
|
443 | print "System verbose printing is:",\ | |
444 | ['OFF','ON'][self.shell.rc.system_verbose] |
|
444 | ['OFF','ON'][self.shell.rc.system_verbose] | |
445 |
|
445 | |||
446 | def magic_history(self, parameter_s = ''): |
|
446 | def magic_history(self, parameter_s = ''): | |
447 | """Print input history (_i<n> variables), with most recent last. |
|
447 | """Print input history (_i<n> variables), with most recent last. | |
448 |
|
448 | |||
449 | %history [-n] -> print at most 40 inputs (some may be multi-line)\\ |
|
449 | %history [-n] -> print at most 40 inputs (some may be multi-line)\\ | |
450 | %history [-n] n -> print at most n inputs\\ |
|
450 | %history [-n] n -> print at most n inputs\\ | |
451 | %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ |
|
451 | %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ | |
452 |
|
452 | |||
453 | Each input's number <n> is shown, and is accessible as the |
|
453 | Each input's number <n> is shown, and is accessible as the | |
454 | automatically generated variable _i<n>. Multi-line statements are |
|
454 | automatically generated variable _i<n>. Multi-line statements are | |
455 | printed starting at a new line for easy copy/paste. |
|
455 | printed starting at a new line for easy copy/paste. | |
456 |
|
456 | |||
457 | If option -n is used, input numbers are not printed. This is useful if |
|
457 | If option -n is used, input numbers are not printed. This is useful if | |
458 | you want to get a printout of many lines which can be directly pasted |
|
458 | you want to get a printout of many lines which can be directly pasted | |
459 | into a text editor. |
|
459 | into a text editor. | |
460 |
|
460 | |||
461 | This feature is only available if numbered prompts are in use.""" |
|
461 | This feature is only available if numbered prompts are in use.""" | |
462 |
|
462 | |||
463 | shell = self.shell |
|
463 | shell = self.shell | |
464 | if not shell.outputcache.do_full_cache: |
|
464 | if not shell.outputcache.do_full_cache: | |
465 | print 'This feature is only available if numbered prompts are in use.' |
|
465 | print 'This feature is only available if numbered prompts are in use.' | |
466 | return |
|
466 | return | |
467 | opts,args = self.parse_options(parameter_s,'n',mode='list') |
|
467 | opts,args = self.parse_options(parameter_s,'n',mode='list') | |
468 |
|
468 | |||
469 | input_hist = shell.input_hist |
|
469 | input_hist = shell.input_hist | |
470 | default_length = 40 |
|
470 | default_length = 40 | |
471 | if len(args) == 0: |
|
471 | if len(args) == 0: | |
472 | final = len(input_hist) |
|
472 | final = len(input_hist) | |
473 | init = max(1,final-default_length) |
|
473 | init = max(1,final-default_length) | |
474 | elif len(args) == 1: |
|
474 | elif len(args) == 1: | |
475 | final = len(input_hist) |
|
475 | final = len(input_hist) | |
476 | init = max(1,final-int(args[0])) |
|
476 | init = max(1,final-int(args[0])) | |
477 | elif len(args) == 2: |
|
477 | elif len(args) == 2: | |
478 | init,final = map(int,args) |
|
478 | init,final = map(int,args) | |
479 | else: |
|
479 | else: | |
480 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') |
|
480 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') | |
481 | print self.magic_hist.__doc__ |
|
481 | print self.magic_hist.__doc__ | |
482 | return |
|
482 | return | |
483 | width = len(str(final)) |
|
483 | width = len(str(final)) | |
484 | line_sep = ['','\n'] |
|
484 | line_sep = ['','\n'] | |
485 | print_nums = not opts.has_key('n') |
|
485 | print_nums = not opts.has_key('n') | |
486 | for in_num in range(init,final): |
|
486 | for in_num in range(init,final): | |
487 | inline = input_hist[in_num] |
|
487 | inline = input_hist[in_num] | |
488 | multiline = int(inline.count('\n') > 1) |
|
488 | multiline = int(inline.count('\n') > 1) | |
489 | if print_nums: |
|
489 | if print_nums: | |
490 | print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), |
|
490 | print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), | |
491 | print inline, |
|
491 | print inline, | |
492 |
|
492 | |||
493 | def magic_hist(self, parameter_s=''): |
|
493 | def magic_hist(self, parameter_s=''): | |
494 | """Alternate name for %history.""" |
|
494 | """Alternate name for %history.""" | |
495 | return self.magic_history(parameter_s) |
|
495 | return self.magic_history(parameter_s) | |
496 |
|
496 | |||
497 | def magic_p(self, parameter_s=''): |
|
497 | def magic_p(self, parameter_s=''): | |
498 | """Just a short alias for Python's 'print'.""" |
|
498 | """Just a short alias for Python's 'print'.""" | |
499 | exec 'print ' + parameter_s in self.shell.user_ns |
|
499 | exec 'print ' + parameter_s in self.shell.user_ns | |
500 |
|
500 | |||
501 | def magic_r(self, parameter_s=''): |
|
501 | def magic_r(self, parameter_s=''): | |
502 | """Repeat previous input. |
|
502 | """Repeat previous input. | |
503 |
|
503 | |||
504 | If given an argument, repeats the previous command which starts with |
|
504 | If given an argument, repeats the previous command which starts with | |
505 | the same string, otherwise it just repeats the previous input. |
|
505 | the same string, otherwise it just repeats the previous input. | |
506 |
|
506 | |||
507 | Shell escaped commands (with ! as first character) are not recognized |
|
507 | Shell escaped commands (with ! as first character) are not recognized | |
508 | by this system, only pure python code and magic commands. |
|
508 | by this system, only pure python code and magic commands. | |
509 | """ |
|
509 | """ | |
510 |
|
510 | |||
511 | start = parameter_s.strip() |
|
511 | start = parameter_s.strip() | |
512 | esc_magic = self.shell.ESC_MAGIC |
|
512 | esc_magic = self.shell.ESC_MAGIC | |
513 | # Identify magic commands even if automagic is on (which means |
|
513 | # Identify magic commands even if automagic is on (which means | |
514 | # the in-memory version is different from that typed by the user). |
|
514 | # the in-memory version is different from that typed by the user). | |
515 | if self.shell.rc.automagic: |
|
515 | if self.shell.rc.automagic: | |
516 | start_magic = esc_magic+start |
|
516 | start_magic = esc_magic+start | |
517 | else: |
|
517 | else: | |
518 | start_magic = start |
|
518 | start_magic = start | |
519 | # Look through the input history in reverse |
|
519 | # Look through the input history in reverse | |
520 | for n in range(len(self.shell.input_hist)-2,0,-1): |
|
520 | for n in range(len(self.shell.input_hist)-2,0,-1): | |
521 | input = self.shell.input_hist[n] |
|
521 | input = self.shell.input_hist[n] | |
522 | # skip plain 'r' lines so we don't recurse to infinity |
|
522 | # skip plain 'r' lines so we don't recurse to infinity | |
523 | if input != 'ipmagic("r")\n' and \ |
|
523 | if input != 'ipmagic("r")\n' and \ | |
524 | (input.startswith(start) or input.startswith(start_magic)): |
|
524 | (input.startswith(start) or input.startswith(start_magic)): | |
525 | #print 'match',`input` # dbg |
|
525 | #print 'match',`input` # dbg | |
526 | print 'Executing:',input, |
|
526 | print 'Executing:',input, | |
527 | self.shell.runlines(input) |
|
527 | self.shell.runlines(input) | |
528 | return |
|
528 | return | |
529 | print 'No previous input matching `%s` found.' % start |
|
529 | print 'No previous input matching `%s` found.' % start | |
530 |
|
530 | |||
531 | def magic_page(self, parameter_s=''): |
|
531 | def magic_page(self, parameter_s=''): | |
532 | """Pretty print the object and display it through a pager. |
|
532 | """Pretty print the object and display it through a pager. | |
533 |
|
533 | |||
534 | If no parameter is given, use _ (last output).""" |
|
534 | If no parameter is given, use _ (last output).""" | |
535 | # After a function contributed by Olivier Aubert, slightly modified. |
|
535 | # After a function contributed by Olivier Aubert, slightly modified. | |
536 |
|
536 | |||
537 | oname = parameter_s and parameter_s or '_' |
|
537 | oname = parameter_s and parameter_s or '_' | |
538 | info = self._ofind(oname) |
|
538 | info = self._ofind(oname) | |
539 | if info['found']: |
|
539 | if info['found']: | |
540 | page(pformat(info['obj'])) |
|
540 | page(pformat(info['obj'])) | |
541 | else: |
|
541 | else: | |
542 | print 'Object `%s` not found' % oname |
|
542 | print 'Object `%s` not found' % oname | |
543 |
|
543 | |||
544 | def magic_profile(self, parameter_s=''): |
|
544 | def magic_profile(self, parameter_s=''): | |
545 | """Print your currently active IPyhton profile.""" |
|
545 | """Print your currently active IPyhton profile.""" | |
546 | if self.shell.rc.profile: |
|
546 | if self.shell.rc.profile: | |
547 | printpl('Current IPython profile: $self.shell.rc.profile.') |
|
547 | printpl('Current IPython profile: $self.shell.rc.profile.') | |
548 | else: |
|
548 | else: | |
549 | print 'No profile active.' |
|
549 | print 'No profile active.' | |
550 |
|
550 | |||
551 | def _inspect(self,meth,oname,**kw): |
|
551 | def _inspect(self,meth,oname,**kw): | |
552 | """Generic interface to the inspector system. |
|
552 | """Generic interface to the inspector system. | |
553 |
|
553 | |||
554 | This function is meant to be called by pdef, pdoc & friends.""" |
|
554 | This function is meant to be called by pdef, pdoc & friends.""" | |
555 |
|
555 | |||
556 | oname = oname.strip() |
|
556 | oname = oname.strip() | |
557 | info = Struct(self._ofind(oname)) |
|
557 | info = Struct(self._ofind(oname)) | |
558 | if info.found: |
|
558 | if info.found: | |
559 | pmethod = getattr(self.shell.inspector,meth) |
|
559 | pmethod = getattr(self.shell.inspector,meth) | |
560 | formatter = info.ismagic and self.format_screen or None |
|
560 | formatter = info.ismagic and self.format_screen or None | |
561 | if meth == 'pdoc': |
|
561 | if meth == 'pdoc': | |
562 | pmethod(info.obj,oname,formatter) |
|
562 | pmethod(info.obj,oname,formatter) | |
563 | elif meth == 'pinfo': |
|
563 | elif meth == 'pinfo': | |
564 | pmethod(info.obj,oname,formatter,info,**kw) |
|
564 | pmethod(info.obj,oname,formatter,info,**kw) | |
565 | else: |
|
565 | else: | |
566 | pmethod(info.obj,oname) |
|
566 | pmethod(info.obj,oname) | |
567 | else: |
|
567 | else: | |
568 | print 'Object `%s` not found.' % oname |
|
568 | print 'Object `%s` not found.' % oname | |
569 | return 'not found' # so callers can take other action |
|
569 | return 'not found' # so callers can take other action | |
570 |
|
570 | |||
571 | def magic_pdef(self, parameter_s=''): |
|
571 | def magic_pdef(self, parameter_s=''): | |
572 | """Print the definition header for any callable object. |
|
572 | """Print the definition header for any callable object. | |
573 |
|
573 | |||
574 | If the object is a class, print the constructor information.""" |
|
574 | If the object is a class, print the constructor information.""" | |
575 | self._inspect('pdef',parameter_s) |
|
575 | self._inspect('pdef',parameter_s) | |
576 |
|
576 | |||
577 | def magic_pdoc(self, parameter_s=''): |
|
577 | def magic_pdoc(self, parameter_s=''): | |
578 | """Print the docstring for an object. |
|
578 | """Print the docstring for an object. | |
579 |
|
579 | |||
580 | If the given object is a class, it will print both the class and the |
|
580 | If the given object is a class, it will print both the class and the | |
581 | constructor docstrings.""" |
|
581 | constructor docstrings.""" | |
582 | self._inspect('pdoc',parameter_s) |
|
582 | self._inspect('pdoc',parameter_s) | |
583 |
|
583 | |||
584 | def magic_psource(self, parameter_s=''): |
|
584 | def magic_psource(self, parameter_s=''): | |
585 | """Print (or run through pager) the source code for an object.""" |
|
585 | """Print (or run through pager) the source code for an object.""" | |
586 | self._inspect('psource',parameter_s) |
|
586 | self._inspect('psource',parameter_s) | |
587 |
|
587 | |||
588 | def magic_pfile(self, parameter_s=''): |
|
588 | def magic_pfile(self, parameter_s=''): | |
589 | """Print (or run through pager) the file where an object is defined. |
|
589 | """Print (or run through pager) the file where an object is defined. | |
590 |
|
590 | |||
591 | The file opens at the line where the object definition begins. IPython |
|
591 | The file opens at the line where the object definition begins. IPython | |
592 | will honor the environment variable PAGER if set, and otherwise will |
|
592 | will honor the environment variable PAGER if set, and otherwise will | |
593 | do its best to print the file in a convenient form. |
|
593 | do its best to print the file in a convenient form. | |
594 |
|
594 | |||
595 | If the given argument is not an object currently defined, IPython will |
|
595 | If the given argument is not an object currently defined, IPython will | |
596 | try to interpret it as a filename (automatically adding a .py extension |
|
596 | try to interpret it as a filename (automatically adding a .py extension | |
597 | if needed). You can thus use %pfile as a syntax highlighting code |
|
597 | if needed). You can thus use %pfile as a syntax highlighting code | |
598 | viewer.""" |
|
598 | viewer.""" | |
599 |
|
599 | |||
600 | # first interpret argument as an object name |
|
600 | # first interpret argument as an object name | |
601 | out = self._inspect('pfile',parameter_s) |
|
601 | out = self._inspect('pfile',parameter_s) | |
602 | # if not, try the input as a filename |
|
602 | # if not, try the input as a filename | |
603 | if out == 'not found': |
|
603 | if out == 'not found': | |
604 | try: |
|
604 | try: | |
605 | filename = get_py_filename(parameter_s) |
|
605 | filename = get_py_filename(parameter_s) | |
606 | except IOError,msg: |
|
606 | except IOError,msg: | |
607 | print msg |
|
607 | print msg | |
608 | return |
|
608 | return | |
609 | page(self.shell.inspector.format(file(filename).read())) |
|
609 | page(self.shell.inspector.format(file(filename).read())) | |
610 |
|
610 | |||
611 | def magic_pinfo(self, parameter_s=''): |
|
611 | def magic_pinfo(self, parameter_s=''): | |
612 | """Provide detailed information about an object. |
|
612 | """Provide detailed information about an object. | |
613 |
|
613 | |||
614 | '%pinfo object' is just a synonym for object? or ?object.""" |
|
614 | '%pinfo object' is just a synonym for object? or ?object.""" | |
615 |
|
615 | |||
616 | #print 'pinfo par: <%s>' % parameter_s # dbg |
|
616 | #print 'pinfo par: <%s>' % parameter_s # dbg | |
617 |
|
617 | |||
618 | # detail_level: 0 -> obj? , 1 -> obj?? |
|
618 | # detail_level: 0 -> obj? , 1 -> obj?? | |
619 | detail_level = 0 |
|
619 | detail_level = 0 | |
620 | # We need to detect if we got called as 'pinfo pinfo foo', which can |
|
620 | # We need to detect if we got called as 'pinfo pinfo foo', which can | |
621 | # happen if the user types 'pinfo foo?' at the cmd line. |
|
621 | # happen if the user types 'pinfo foo?' at the cmd line. | |
622 | pinfo,qmark1,oname,qmark2 = \ |
|
622 | pinfo,qmark1,oname,qmark2 = \ | |
623 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() |
|
623 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() | |
624 | if pinfo or qmark1 or qmark2: |
|
624 | if pinfo or qmark1 or qmark2: | |
625 | detail_level = 1 |
|
625 | detail_level = 1 | |
626 | if "*" in oname: |
|
626 | if "*" in oname: | |
627 | self.magic_psearch(oname) |
|
627 | self.magic_psearch(oname) | |
628 | else: |
|
628 | else: | |
629 | self._inspect('pinfo',oname,detail_level=detail_level) |
|
629 | self._inspect('pinfo',oname,detail_level=detail_level) | |
630 |
|
630 | |||
631 | def magic_psearch(self, parameter_s=''): |
|
631 | def magic_psearch(self, parameter_s=''): | |
632 | """Search for object in namespaces by wildcard. |
|
632 | """Search for object in namespaces by wildcard. | |
633 |
|
633 | |||
634 | %psearch [options] PATTERN [OBJECT TYPE] |
|
634 | %psearch [options] PATTERN [OBJECT TYPE] | |
635 |
|
635 | |||
636 | Note: ? can be used as a synonym for %psearch, at the beginning or at |
|
636 | Note: ? can be used as a synonym for %psearch, at the beginning or at | |
637 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the |
|
637 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the | |
638 | rest of the command line must be unchanged (options come first), so |
|
638 | rest of the command line must be unchanged (options come first), so | |
639 | for example the following forms are equivalent |
|
639 | for example the following forms are equivalent | |
640 |
|
640 | |||
641 | %psearch -i a* function |
|
641 | %psearch -i a* function | |
642 | -i a* function? |
|
642 | -i a* function? | |
643 | ?-i a* function |
|
643 | ?-i a* function | |
644 |
|
644 | |||
645 | Arguments: |
|
645 | Arguments: | |
646 |
|
646 | |||
647 | PATTERN |
|
647 | PATTERN | |
648 |
|
648 | |||
649 | where PATTERN is a string containing * as a wildcard similar to its |
|
649 | where PATTERN is a string containing * as a wildcard similar to its | |
650 | use in a shell. The pattern is matched in all namespaces on the |
|
650 | use in a shell. The pattern is matched in all namespaces on the | |
651 | search path. By default objects starting with a single _ are not |
|
651 | search path. By default objects starting with a single _ are not | |
652 | matched, many IPython generated objects have a single |
|
652 | matched, many IPython generated objects have a single | |
653 | underscore. The default is case insensitive matching. Matching is |
|
653 | underscore. The default is case insensitive matching. Matching is | |
654 | also done on the attributes of objects and not only on the objects |
|
654 | also done on the attributes of objects and not only on the objects | |
655 | in a module. |
|
655 | in a module. | |
656 |
|
656 | |||
657 | [OBJECT TYPE] |
|
657 | [OBJECT TYPE] | |
658 |
|
658 | |||
659 | Is the name of a python type from the types module. The name is |
|
659 | Is the name of a python type from the types module. The name is | |
660 | given in lowercase without the ending type, ex. StringType is |
|
660 | given in lowercase without the ending type, ex. StringType is | |
661 | written string. By adding a type here only objects matching the |
|
661 | written string. By adding a type here only objects matching the | |
662 | given type are matched. Using all here makes the pattern match all |
|
662 | given type are matched. Using all here makes the pattern match all | |
663 | types (this is the default). |
|
663 | types (this is the default). | |
664 |
|
664 | |||
665 | Options: |
|
665 | Options: | |
666 |
|
666 | |||
667 | -a: makes the pattern match even objects whose names start with a |
|
667 | -a: makes the pattern match even objects whose names start with a | |
668 | single underscore. These names are normally ommitted from the |
|
668 | single underscore. These names are normally ommitted from the | |
669 | search. |
|
669 | search. | |
670 |
|
670 | |||
671 | -i/-c: make the pattern case insensitive/sensitive. If neither of |
|
671 | -i/-c: make the pattern case insensitive/sensitive. If neither of | |
672 | these options is given, the default is read from your ipythonrc |
|
672 | these options is given, the default is read from your ipythonrc | |
673 | file. The option name which sets this value is |
|
673 | file. The option name which sets this value is | |
674 | 'wildcards_case_sensitive'. If this option is not specified in your |
|
674 | 'wildcards_case_sensitive'. If this option is not specified in your | |
675 | ipythonrc file, IPython's internal default is to do a case sensitive |
|
675 | ipythonrc file, IPython's internal default is to do a case sensitive | |
676 | search. |
|
676 | search. | |
677 |
|
677 | |||
678 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you |
|
678 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you | |
679 | specifiy can be searched in any of the following namespaces: |
|
679 | specifiy can be searched in any of the following namespaces: | |
680 | 'builtin', 'user', 'user_global','internal', 'alias', where |
|
680 | 'builtin', 'user', 'user_global','internal', 'alias', where | |
681 | 'builtin' and 'user' are the search defaults. Note that you should |
|
681 | 'builtin' and 'user' are the search defaults. Note that you should | |
682 | not use quotes when specifying namespaces. |
|
682 | not use quotes when specifying namespaces. | |
683 |
|
683 | |||
684 | 'Builtin' contains the python module builtin, 'user' contains all |
|
684 | 'Builtin' contains the python module builtin, 'user' contains all | |
685 | user data, 'alias' only contain the shell aliases and no python |
|
685 | user data, 'alias' only contain the shell aliases and no python | |
686 | objects, 'internal' contains objects used by IPython. The |
|
686 | objects, 'internal' contains objects used by IPython. The | |
687 | 'user_global' namespace is only used by embedded IPython instances, |
|
687 | 'user_global' namespace is only used by embedded IPython instances, | |
688 | and it contains module-level globals. You can add namespaces to the |
|
688 | and it contains module-level globals. You can add namespaces to the | |
689 | search with -s or exclude them with -e (these options can be given |
|
689 | search with -s or exclude them with -e (these options can be given | |
690 | more than once). |
|
690 | more than once). | |
691 |
|
691 | |||
692 | Examples: |
|
692 | Examples: | |
693 |
|
693 | |||
694 | %psearch a* -> objects beginning with an a |
|
694 | %psearch a* -> objects beginning with an a | |
695 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a |
|
695 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a | |
696 | %psearch a* function -> all functions beginning with an a |
|
696 | %psearch a* function -> all functions beginning with an a | |
697 | %psearch re.e* -> objects beginning with an e in module re |
|
697 | %psearch re.e* -> objects beginning with an e in module re | |
698 | %psearch r*.e* -> objects that start with e in modules starting in r |
|
698 | %psearch r*.e* -> objects that start with e in modules starting in r | |
699 | %psearch r*.* string -> all strings in modules beginning with r |
|
699 | %psearch r*.* string -> all strings in modules beginning with r | |
700 |
|
700 | |||
701 | Case sensitve search: |
|
701 | Case sensitve search: | |
702 |
|
702 | |||
703 | %psearch -c a* list all object beginning with lower case a |
|
703 | %psearch -c a* list all object beginning with lower case a | |
704 |
|
704 | |||
705 | Show objects beginning with a single _: |
|
705 | Show objects beginning with a single _: | |
706 |
|
706 | |||
707 | %psearch -a _* list objects beginning with a single underscore""" |
|
707 | %psearch -a _* list objects beginning with a single underscore""" | |
708 |
|
708 | |||
709 | # default namespaces to be searched |
|
709 | # default namespaces to be searched | |
710 | def_search = ['user','builtin'] |
|
710 | def_search = ['user','builtin'] | |
711 |
|
711 | |||
712 | # Process options/args |
|
712 | # Process options/args | |
713 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) |
|
713 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) | |
714 | opt = opts.get |
|
714 | opt = opts.get | |
715 | shell = self.shell |
|
715 | shell = self.shell | |
716 | psearch = shell.inspector.psearch |
|
716 | psearch = shell.inspector.psearch | |
717 |
|
717 | |||
718 | # select case options |
|
718 | # select case options | |
719 | if opts.has_key('i'): |
|
719 | if opts.has_key('i'): | |
720 | ignore_case = True |
|
720 | ignore_case = True | |
721 | elif opts.has_key('c'): |
|
721 | elif opts.has_key('c'): | |
722 | ignore_case = False |
|
722 | ignore_case = False | |
723 | else: |
|
723 | else: | |
724 | ignore_case = not shell.rc.wildcards_case_sensitive |
|
724 | ignore_case = not shell.rc.wildcards_case_sensitive | |
725 |
|
725 | |||
726 | # Build list of namespaces to search from user options |
|
726 | # Build list of namespaces to search from user options | |
727 | def_search.extend(opt('s',[])) |
|
727 | def_search.extend(opt('s',[])) | |
728 | ns_exclude = ns_exclude=opt('e',[]) |
|
728 | ns_exclude = ns_exclude=opt('e',[]) | |
729 | ns_search = [nm for nm in def_search if nm not in ns_exclude] |
|
729 | ns_search = [nm for nm in def_search if nm not in ns_exclude] | |
730 |
|
730 | |||
731 | # Call the actual search |
|
731 | # Call the actual search | |
732 | try: |
|
732 | try: | |
733 | psearch(args,shell.ns_table,ns_search, |
|
733 | psearch(args,shell.ns_table,ns_search, | |
734 | show_all=opt('a'),ignore_case=ignore_case) |
|
734 | show_all=opt('a'),ignore_case=ignore_case) | |
735 | except: |
|
735 | except: | |
736 | shell.showtraceback() |
|
736 | shell.showtraceback() | |
737 |
|
737 | |||
738 | def magic_who_ls(self, parameter_s=''): |
|
738 | def magic_who_ls(self, parameter_s=''): | |
739 | """Return a sorted list of all interactive variables. |
|
739 | """Return a sorted list of all interactive variables. | |
740 |
|
740 | |||
741 | If arguments are given, only variables of types matching these |
|
741 | If arguments are given, only variables of types matching these | |
742 | arguments are returned.""" |
|
742 | arguments are returned.""" | |
743 |
|
743 | |||
744 | user_ns = self.shell.user_ns |
|
744 | user_ns = self.shell.user_ns | |
|
745 | internal_ns = self.shell.internal_ns | |||
|
746 | user_config_ns = self.shell.user_config_ns | |||
745 | out = [] |
|
747 | out = [] | |
746 | typelist = parameter_s.split() |
|
748 | typelist = parameter_s.split() | |
747 | for i in self.shell.user_ns.keys(): |
|
749 | ||
|
750 | for i in user_ns: | |||
748 | if not (i.startswith('_') or i.startswith('_i')) \ |
|
751 | if not (i.startswith('_') or i.startswith('_i')) \ | |
749 |
and not ( |
|
752 | and not (i in internal_ns or i in user_config_ns): | |
750 | self.shell.user_config_ns.has_key(i)): |
|
|||
751 | if typelist: |
|
753 | if typelist: | |
752 | if type(user_ns[i]).__name__ in typelist: |
|
754 | if type(user_ns[i]).__name__ in typelist: | |
753 | out.append(i) |
|
755 | out.append(i) | |
754 | else: |
|
756 | else: | |
755 | out.append(i) |
|
757 | out.append(i) | |
756 | out.sort() |
|
758 | out.sort() | |
757 | return out |
|
759 | return out | |
758 |
|
760 | |||
759 | def magic_who(self, parameter_s=''): |
|
761 | def magic_who(self, parameter_s=''): | |
760 | """Print all interactive variables, with some minimal formatting. |
|
762 | """Print all interactive variables, with some minimal formatting. | |
761 |
|
763 | |||
762 | If any arguments are given, only variables whose type matches one of |
|
764 | If any arguments are given, only variables whose type matches one of | |
763 | these are printed. For example: |
|
765 | these are printed. For example: | |
764 |
|
766 | |||
765 | %who function str |
|
767 | %who function str | |
766 |
|
768 | |||
767 | will only list functions and strings, excluding all other types of |
|
769 | will only list functions and strings, excluding all other types of | |
768 | variables. To find the proper type names, simply use type(var) at a |
|
770 | variables. To find the proper type names, simply use type(var) at a | |
769 | command line to see how python prints type names. For example: |
|
771 | command line to see how python prints type names. For example: | |
770 |
|
772 | |||
771 | In [1]: type('hello')\\ |
|
773 | In [1]: type('hello')\\ | |
772 | Out[1]: <type 'str'> |
|
774 | Out[1]: <type 'str'> | |
773 |
|
775 | |||
774 | indicates that the type name for strings is 'str'. |
|
776 | indicates that the type name for strings is 'str'. | |
775 |
|
777 | |||
776 | %who always excludes executed names loaded through your configuration |
|
778 | %who always excludes executed names loaded through your configuration | |
777 | file and things which are internal to IPython. |
|
779 | file and things which are internal to IPython. | |
778 |
|
780 | |||
779 | This is deliberate, as typically you may load many modules and the |
|
781 | This is deliberate, as typically you may load many modules and the | |
780 | purpose of %who is to show you only what you've manually defined.""" |
|
782 | purpose of %who is to show you only what you've manually defined.""" | |
781 |
|
783 | |||
782 | varlist = self.magic_who_ls(parameter_s) |
|
784 | varlist = self.magic_who_ls(parameter_s) | |
783 | if not varlist: |
|
785 | if not varlist: | |
784 | print 'Interactive namespace is empty.' |
|
786 | print 'Interactive namespace is empty.' | |
785 | return |
|
787 | return | |
786 |
|
788 | |||
787 | # if we have variables, move on... |
|
789 | # if we have variables, move on... | |
788 |
|
790 | |||
789 | # stupid flushing problem: when prompts have no separators, stdout is |
|
791 | # stupid flushing problem: when prompts have no separators, stdout is | |
790 | # getting lost. I'm starting to think this is a python bug. I'm having |
|
792 | # getting lost. I'm starting to think this is a python bug. I'm having | |
791 | # to force a flush with a print because even a sys.stdout.flush |
|
793 | # to force a flush with a print because even a sys.stdout.flush | |
792 | # doesn't seem to do anything! |
|
794 | # doesn't seem to do anything! | |
793 |
|
795 | |||
794 | count = 0 |
|
796 | count = 0 | |
795 | for i in varlist: |
|
797 | for i in varlist: | |
796 | print i+'\t', |
|
798 | print i+'\t', | |
797 | count += 1 |
|
799 | count += 1 | |
798 | if count > 8: |
|
800 | if count > 8: | |
799 | count = 0 |
|
801 | count = 0 | |
800 |
|
802 | |||
801 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? |
|
803 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? | |
802 |
|
804 | |||
803 | print # well, this does force a flush at the expense of an extra \n |
|
805 | print # well, this does force a flush at the expense of an extra \n | |
804 |
|
806 | |||
805 | def magic_whos(self, parameter_s=''): |
|
807 | def magic_whos(self, parameter_s=''): | |
806 | """Like %who, but gives some extra information about each variable. |
|
808 | """Like %who, but gives some extra information about each variable. | |
807 |
|
809 | |||
808 | The same type filtering of %who can be applied here. |
|
810 | The same type filtering of %who can be applied here. | |
809 |
|
811 | |||
810 | For all variables, the type is printed. Additionally it prints: |
|
812 | For all variables, the type is printed. Additionally it prints: | |
811 |
|
813 | |||
812 | - For {},[],(): their length. |
|
814 | - For {},[],(): their length. | |
813 |
|
815 | |||
814 | - For Numeric arrays, a summary with shape, number of elements, |
|
816 | - For Numeric arrays, a summary with shape, number of elements, | |
815 | typecode and size in memory. |
|
817 | typecode and size in memory. | |
816 |
|
818 | |||
817 | - Everything else: a string representation, snipping their middle if |
|
819 | - Everything else: a string representation, snipping their middle if | |
818 | too long.""" |
|
820 | too long.""" | |
819 |
|
821 | |||
820 | varnames = self.magic_who_ls(parameter_s) |
|
822 | varnames = self.magic_who_ls(parameter_s) | |
821 | if not varnames: |
|
823 | if not varnames: | |
822 | print 'Interactive namespace is empty.' |
|
824 | print 'Interactive namespace is empty.' | |
823 | return |
|
825 | return | |
824 |
|
826 | |||
825 | # if we have variables, move on... |
|
827 | # if we have variables, move on... | |
826 |
|
828 | |||
827 | # for these types, show len() instead of data: |
|
829 | # for these types, show len() instead of data: | |
828 | seq_types = [types.DictType,types.ListType,types.TupleType] |
|
830 | seq_types = [types.DictType,types.ListType,types.TupleType] | |
829 |
|
831 | |||
830 | # for Numeric arrays, display summary info |
|
832 | # for Numeric arrays, display summary info | |
831 | try: |
|
833 | try: | |
832 | import Numeric |
|
834 | import Numeric | |
833 | except ImportError: |
|
835 | except ImportError: | |
834 | array_type = None |
|
836 | array_type = None | |
835 | else: |
|
837 | else: | |
836 | array_type = Numeric.ArrayType.__name__ |
|
838 | array_type = Numeric.ArrayType.__name__ | |
837 |
|
839 | |||
838 | # Find all variable names and types so we can figure out column sizes |
|
840 | # Find all variable names and types so we can figure out column sizes | |
839 | get_vars = lambda i: self.shell.user_ns[i] |
|
841 | get_vars = lambda i: self.shell.user_ns[i] | |
840 | type_name = lambda v: type(v).__name__ |
|
842 | type_name = lambda v: type(v).__name__ | |
841 | varlist = map(get_vars,varnames) |
|
843 | varlist = map(get_vars,varnames) | |
842 |
|
844 | |||
843 | typelist = [] |
|
845 | typelist = [] | |
844 | for vv in varlist: |
|
846 | for vv in varlist: | |
845 | tt = type_name(vv) |
|
847 | tt = type_name(vv) | |
846 | if tt=='instance': |
|
848 | if tt=='instance': | |
847 | typelist.append(str(vv.__class__)) |
|
849 | typelist.append(str(vv.__class__)) | |
848 | else: |
|
850 | else: | |
849 | typelist.append(tt) |
|
851 | typelist.append(tt) | |
850 |
|
852 | |||
851 | # column labels and # of spaces as separator |
|
853 | # column labels and # of spaces as separator | |
852 | varlabel = 'Variable' |
|
854 | varlabel = 'Variable' | |
853 | typelabel = 'Type' |
|
855 | typelabel = 'Type' | |
854 | datalabel = 'Data/Info' |
|
856 | datalabel = 'Data/Info' | |
855 | colsep = 3 |
|
857 | colsep = 3 | |
856 | # variable format strings |
|
858 | # variable format strings | |
857 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" |
|
859 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" | |
858 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' |
|
860 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' | |
859 | aformat = "%s: %s elems, type `%s`, %s bytes" |
|
861 | aformat = "%s: %s elems, type `%s`, %s bytes" | |
860 | # find the size of the columns to format the output nicely |
|
862 | # find the size of the columns to format the output nicely | |
861 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep |
|
863 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep | |
862 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep |
|
864 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep | |
863 | # table header |
|
865 | # table header | |
864 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ |
|
866 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ | |
865 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) |
|
867 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) | |
866 | # and the table itself |
|
868 | # and the table itself | |
867 | kb = 1024 |
|
869 | kb = 1024 | |
868 | Mb = 1048576 # kb**2 |
|
870 | Mb = 1048576 # kb**2 | |
869 | for vname,var,vtype in zip(varnames,varlist,typelist): |
|
871 | for vname,var,vtype in zip(varnames,varlist,typelist): | |
870 | print itpl(vformat), |
|
872 | print itpl(vformat), | |
871 | if vtype in seq_types: |
|
873 | if vtype in seq_types: | |
872 | print len(var) |
|
874 | print len(var) | |
873 | elif vtype==array_type: |
|
875 | elif vtype==array_type: | |
874 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] |
|
876 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] | |
875 | vsize = Numeric.size(var) |
|
877 | vsize = Numeric.size(var) | |
876 | vbytes = vsize*var.itemsize() |
|
878 | vbytes = vsize*var.itemsize() | |
877 | if vbytes < 100000: |
|
879 | if vbytes < 100000: | |
878 | print aformat % (vshape,vsize,var.typecode(),vbytes) |
|
880 | print aformat % (vshape,vsize,var.typecode(),vbytes) | |
879 | else: |
|
881 | else: | |
880 | print aformat % (vshape,vsize,var.typecode(),vbytes), |
|
882 | print aformat % (vshape,vsize,var.typecode(),vbytes), | |
881 | if vbytes < Mb: |
|
883 | if vbytes < Mb: | |
882 | print '(%s kb)' % (vbytes/kb,) |
|
884 | print '(%s kb)' % (vbytes/kb,) | |
883 | else: |
|
885 | else: | |
884 | print '(%s Mb)' % (vbytes/Mb,) |
|
886 | print '(%s Mb)' % (vbytes/Mb,) | |
885 | else: |
|
887 | else: | |
886 | vstr = str(var).replace('\n','\\n') |
|
888 | vstr = str(var).replace('\n','\\n') | |
887 | if len(vstr) < 50: |
|
889 | if len(vstr) < 50: | |
888 | print vstr |
|
890 | print vstr | |
889 | else: |
|
891 | else: | |
890 | printpl(vfmt_short) |
|
892 | printpl(vfmt_short) | |
891 |
|
893 | |||
892 | def magic_reset(self, parameter_s=''): |
|
894 | def magic_reset(self, parameter_s=''): | |
893 | """Resets the namespace by removing all names defined by the user. |
|
895 | """Resets the namespace by removing all names defined by the user. | |
894 |
|
896 | |||
895 | Input/Output history are left around in case you need them.""" |
|
897 | Input/Output history are left around in case you need them.""" | |
896 |
|
898 | |||
897 | ans = raw_input( |
|
899 | ans = raw_input( | |
898 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") |
|
900 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") | |
899 | if not ans.lower() == 'y': |
|
901 | if not ans.lower() == 'y': | |
900 | print 'Nothing done.' |
|
902 | print 'Nothing done.' | |
901 | return |
|
903 | return | |
902 | user_ns = self.shell.user_ns |
|
904 | user_ns = self.shell.user_ns | |
903 | for i in self.magic_who_ls(): |
|
905 | for i in self.magic_who_ls(): | |
904 | del(user_ns[i]) |
|
906 | del(user_ns[i]) | |
905 |
|
907 | |||
906 | def magic_config(self,parameter_s=''): |
|
908 | def magic_config(self,parameter_s=''): | |
907 | """Show IPython's internal configuration.""" |
|
909 | """Show IPython's internal configuration.""" | |
908 |
|
910 | |||
909 | page('Current configuration structure:\n'+ |
|
911 | page('Current configuration structure:\n'+ | |
910 | pformat(self.shell.rc.dict())) |
|
912 | pformat(self.shell.rc.dict())) | |
911 |
|
913 | |||
912 | def magic_logstart(self,parameter_s=''): |
|
914 | def magic_logstart(self,parameter_s=''): | |
913 | """Start logging anywhere in a session. |
|
915 | """Start logging anywhere in a session. | |
914 |
|
916 | |||
915 | %logstart [-o|-t] [log_name [log_mode]] |
|
917 | %logstart [-o|-t] [log_name [log_mode]] | |
916 |
|
918 | |||
917 | If no name is given, it defaults to a file named 'ipython_log.py' in your |
|
919 | If no name is given, it defaults to a file named 'ipython_log.py' in your | |
918 | current directory, in 'rotate' mode (see below). |
|
920 | current directory, in 'rotate' mode (see below). | |
919 |
|
921 | |||
920 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your |
|
922 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your | |
921 | history up to that point and then continues logging. |
|
923 | history up to that point and then continues logging. | |
922 |
|
924 | |||
923 | %logstart takes a second optional parameter: logging mode. This can be one |
|
925 | %logstart takes a second optional parameter: logging mode. This can be one | |
924 | of (note that the modes are given unquoted):\\ |
|
926 | of (note that the modes are given unquoted):\\ | |
925 | append: well, that says it.\\ |
|
927 | append: well, that says it.\\ | |
926 | backup: rename (if exists) to name~ and start name.\\ |
|
928 | backup: rename (if exists) to name~ and start name.\\ | |
927 | global: single logfile in your home dir, appended to.\\ |
|
929 | global: single logfile in your home dir, appended to.\\ | |
928 | over : overwrite existing log.\\ |
|
930 | over : overwrite existing log.\\ | |
929 | rotate: create rotating logs name.1~, name.2~, etc. |
|
931 | rotate: create rotating logs name.1~, name.2~, etc. | |
930 |
|
932 | |||
931 | Options: |
|
933 | Options: | |
932 |
|
934 | |||
933 | -o: log also IPython's output. In this mode, all commands which |
|
935 | -o: log also IPython's output. In this mode, all commands which | |
934 | generate an Out[NN] prompt are recorded to the logfile, right after |
|
936 | generate an Out[NN] prompt are recorded to the logfile, right after | |
935 | their corresponding input line. The output lines are always |
|
937 | their corresponding input line. The output lines are always | |
936 | prepended with a '#[Out]# ' marker, so that the log remains valid |
|
938 | prepended with a '#[Out]# ' marker, so that the log remains valid | |
937 | Python code. |
|
939 | Python code. | |
938 |
|
940 | |||
939 | Since this marker is always the same, filtering only the output from |
|
941 | Since this marker is always the same, filtering only the output from | |
940 | a log is very easy, using for example a simple awk call: |
|
942 | a log is very easy, using for example a simple awk call: | |
941 |
|
943 | |||
942 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py |
|
944 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py | |
943 |
|
945 | |||
944 | -t: put timestamps before each input line logged (these are put in |
|
946 | -t: put timestamps before each input line logged (these are put in | |
945 | comments).""" |
|
947 | comments).""" | |
946 |
|
948 | |||
947 | opts,par = self.parse_options(parameter_s,'ot') |
|
949 | opts,par = self.parse_options(parameter_s,'ot') | |
948 | log_output = 'o' in opts |
|
950 | log_output = 'o' in opts | |
949 | timestamp = 't' in opts |
|
951 | timestamp = 't' in opts | |
950 |
|
952 | |||
951 | rc = self.shell.rc |
|
953 | rc = self.shell.rc | |
952 | logger = self.shell.logger |
|
954 | logger = self.shell.logger | |
953 |
|
955 | |||
954 | # if no args are given, the defaults set in the logger constructor by |
|
956 | # if no args are given, the defaults set in the logger constructor by | |
955 | # ipytohn remain valid |
|
957 | # ipytohn remain valid | |
956 | if par: |
|
958 | if par: | |
957 | try: |
|
959 | try: | |
958 | logfname,logmode = par.split() |
|
960 | logfname,logmode = par.split() | |
959 | except: |
|
961 | except: | |
960 | logfname = par |
|
962 | logfname = par | |
961 | logmode = 'backup' |
|
963 | logmode = 'backup' | |
962 | else: |
|
964 | else: | |
963 | logfname = logger.logfname |
|
965 | logfname = logger.logfname | |
964 | logmode = logger.logmode |
|
966 | logmode = logger.logmode | |
965 | # put logfname into rc struct as if it had been called on the command |
|
967 | # put logfname into rc struct as if it had been called on the command | |
966 | # line, so it ends up saved in the log header Save it in case we need |
|
968 | # line, so it ends up saved in the log header Save it in case we need | |
967 | # to restore it... |
|
969 | # to restore it... | |
968 | old_logfile = rc.opts.get('logfile','') |
|
970 | old_logfile = rc.opts.get('logfile','') | |
969 | if logfname: |
|
971 | if logfname: | |
970 | logfname = os.path.expanduser(logfname) |
|
972 | logfname = os.path.expanduser(logfname) | |
971 | rc.opts.logfile = logfname |
|
973 | rc.opts.logfile = logfname | |
972 | loghead = self.shell.loghead_tpl % (rc.opts,rc.args) |
|
974 | loghead = self.shell.loghead_tpl % (rc.opts,rc.args) | |
973 | try: |
|
975 | try: | |
974 | started = logger.logstart(logfname,loghead,logmode, |
|
976 | started = logger.logstart(logfname,loghead,logmode, | |
975 | log_output,timestamp) |
|
977 | log_output,timestamp) | |
976 | except: |
|
978 | except: | |
977 | rc.opts.logfile = old_logfile |
|
979 | rc.opts.logfile = old_logfile | |
978 | warn("Couldn't start log: %s" % sys.exc_info()[1]) |
|
980 | warn("Couldn't start log: %s" % sys.exc_info()[1]) | |
979 | else: |
|
981 | else: | |
980 | # log input history up to this point, optionally interleaving |
|
982 | # log input history up to this point, optionally interleaving | |
981 | # output if requested |
|
983 | # output if requested | |
982 |
|
984 | |||
983 | if timestamp: |
|
985 | if timestamp: | |
984 | # disable timestamping for the previous history, since we've |
|
986 | # disable timestamping for the previous history, since we've | |
985 | # lost those already (no time machine here). |
|
987 | # lost those already (no time machine here). | |
986 | logger.timestamp = False |
|
988 | logger.timestamp = False | |
987 | if log_output: |
|
989 | if log_output: | |
988 | log_write = logger.log_write |
|
990 | log_write = logger.log_write | |
989 | input_hist = self.shell.input_hist |
|
991 | input_hist = self.shell.input_hist | |
990 | output_hist = self.shell.output_hist |
|
992 | output_hist = self.shell.output_hist | |
991 | for n in range(1,len(input_hist)-1): |
|
993 | for n in range(1,len(input_hist)-1): | |
992 | log_write(input_hist[n].rstrip()) |
|
994 | log_write(input_hist[n].rstrip()) | |
993 | if n in output_hist: |
|
995 | if n in output_hist: | |
994 | log_write(repr(output_hist[n]),'output') |
|
996 | log_write(repr(output_hist[n]),'output') | |
995 | else: |
|
997 | else: | |
996 | logger.log_write(self.shell.input_hist[1:]) |
|
998 | logger.log_write(self.shell.input_hist[1:]) | |
997 | if timestamp: |
|
999 | if timestamp: | |
998 | # re-enable timestamping |
|
1000 | # re-enable timestamping | |
999 | logger.timestamp = True |
|
1001 | logger.timestamp = True | |
1000 |
|
1002 | |||
1001 | print ('Activating auto-logging. ' |
|
1003 | print ('Activating auto-logging. ' | |
1002 | 'Current session state plus future input saved.') |
|
1004 | 'Current session state plus future input saved.') | |
1003 | logger.logstate() |
|
1005 | logger.logstate() | |
1004 |
|
1006 | |||
1005 | def magic_logoff(self,parameter_s=''): |
|
1007 | def magic_logoff(self,parameter_s=''): | |
1006 | """Temporarily stop logging. |
|
1008 | """Temporarily stop logging. | |
1007 |
|
1009 | |||
1008 | You must have previously started logging.""" |
|
1010 | You must have previously started logging.""" | |
1009 | self.shell.logger.switch_log(0) |
|
1011 | self.shell.logger.switch_log(0) | |
1010 |
|
1012 | |||
1011 | def magic_logon(self,parameter_s=''): |
|
1013 | def magic_logon(self,parameter_s=''): | |
1012 | """Restart logging. |
|
1014 | """Restart logging. | |
1013 |
|
1015 | |||
1014 | This function is for restarting logging which you've temporarily |
|
1016 | This function is for restarting logging which you've temporarily | |
1015 | stopped with %logoff. For starting logging for the first time, you |
|
1017 | stopped with %logoff. For starting logging for the first time, you | |
1016 | must use the %logstart function, which allows you to specify an |
|
1018 | must use the %logstart function, which allows you to specify an | |
1017 | optional log filename.""" |
|
1019 | optional log filename.""" | |
1018 |
|
1020 | |||
1019 | self.shell.logger.switch_log(1) |
|
1021 | self.shell.logger.switch_log(1) | |
1020 |
|
1022 | |||
1021 | def magic_logstate(self,parameter_s=''): |
|
1023 | def magic_logstate(self,parameter_s=''): | |
1022 | """Print the status of the logging system.""" |
|
1024 | """Print the status of the logging system.""" | |
1023 |
|
1025 | |||
1024 | self.shell.logger.logstate() |
|
1026 | self.shell.logger.logstate() | |
1025 |
|
1027 | |||
1026 | def magic_pdb(self, parameter_s=''): |
|
1028 | def magic_pdb(self, parameter_s=''): | |
1027 | """Control the calling of the pdb interactive debugger. |
|
1029 | """Control the calling of the pdb interactive debugger. | |
1028 |
|
1030 | |||
1029 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without |
|
1031 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without | |
1030 | argument it works as a toggle. |
|
1032 | argument it works as a toggle. | |
1031 |
|
1033 | |||
1032 | When an exception is triggered, IPython can optionally call the |
|
1034 | When an exception is triggered, IPython can optionally call the | |
1033 | interactive pdb debugger after the traceback printout. %pdb toggles |
|
1035 | interactive pdb debugger after the traceback printout. %pdb toggles | |
1034 | this feature on and off.""" |
|
1036 | this feature on and off.""" | |
1035 |
|
1037 | |||
1036 | par = parameter_s.strip().lower() |
|
1038 | par = parameter_s.strip().lower() | |
1037 |
|
1039 | |||
1038 | if par: |
|
1040 | if par: | |
1039 | try: |
|
1041 | try: | |
1040 | new_pdb = {'off':0,'0':0,'on':1,'1':1}[par] |
|
1042 | new_pdb = {'off':0,'0':0,'on':1,'1':1}[par] | |
1041 | except KeyError: |
|
1043 | except KeyError: | |
1042 | print ('Incorrect argument. Use on/1, off/0, ' |
|
1044 | print ('Incorrect argument. Use on/1, off/0, ' | |
1043 | 'or nothing for a toggle.') |
|
1045 | 'or nothing for a toggle.') | |
1044 | return |
|
1046 | return | |
1045 | else: |
|
1047 | else: | |
1046 | # toggle |
|
1048 | # toggle | |
1047 | new_pdb = not self.shell.InteractiveTB.call_pdb |
|
1049 | new_pdb = not self.shell.InteractiveTB.call_pdb | |
1048 |
|
1050 | |||
1049 | # set on the shell |
|
1051 | # set on the shell | |
1050 | self.shell.call_pdb = new_pdb |
|
1052 | self.shell.call_pdb = new_pdb | |
1051 | print 'Automatic pdb calling has been turned',on_off(new_pdb) |
|
1053 | print 'Automatic pdb calling has been turned',on_off(new_pdb) | |
1052 |
|
1054 | |||
1053 | def magic_prun(self, parameter_s ='',user_mode=1, |
|
1055 | def magic_prun(self, parameter_s ='',user_mode=1, | |
1054 | opts=None,arg_lst=None,prog_ns=None): |
|
1056 | opts=None,arg_lst=None,prog_ns=None): | |
1055 |
|
1057 | |||
1056 | """Run a statement through the python code profiler. |
|
1058 | """Run a statement through the python code profiler. | |
1057 |
|
1059 | |||
1058 | Usage:\\ |
|
1060 | Usage:\\ | |
1059 | %prun [options] statement |
|
1061 | %prun [options] statement | |
1060 |
|
1062 | |||
1061 | The given statement (which doesn't require quote marks) is run via the |
|
1063 | The given statement (which doesn't require quote marks) is run via the | |
1062 | python profiler in a manner similar to the profile.run() function. |
|
1064 | python profiler in a manner similar to the profile.run() function. | |
1063 | Namespaces are internally managed to work correctly; profile.run |
|
1065 | Namespaces are internally managed to work correctly; profile.run | |
1064 | cannot be used in IPython because it makes certain assumptions about |
|
1066 | cannot be used in IPython because it makes certain assumptions about | |
1065 | namespaces which do not hold under IPython. |
|
1067 | namespaces which do not hold under IPython. | |
1066 |
|
1068 | |||
1067 | Options: |
|
1069 | Options: | |
1068 |
|
1070 | |||
1069 | -l <limit>: you can place restrictions on what or how much of the |
|
1071 | -l <limit>: you can place restrictions on what or how much of the | |
1070 | profile gets printed. The limit value can be: |
|
1072 | profile gets printed. The limit value can be: | |
1071 |
|
1073 | |||
1072 | * A string: only information for function names containing this string |
|
1074 | * A string: only information for function names containing this string | |
1073 | is printed. |
|
1075 | is printed. | |
1074 |
|
1076 | |||
1075 | * An integer: only these many lines are printed. |
|
1077 | * An integer: only these many lines are printed. | |
1076 |
|
1078 | |||
1077 | * A float (between 0 and 1): this fraction of the report is printed |
|
1079 | * A float (between 0 and 1): this fraction of the report is printed | |
1078 | (for example, use a limit of 0.4 to see the topmost 40% only). |
|
1080 | (for example, use a limit of 0.4 to see the topmost 40% only). | |
1079 |
|
1081 | |||
1080 | You can combine several limits with repeated use of the option. For |
|
1082 | You can combine several limits with repeated use of the option. For | |
1081 | example, '-l __init__ -l 5' will print only the topmost 5 lines of |
|
1083 | example, '-l __init__ -l 5' will print only the topmost 5 lines of | |
1082 | information about class constructors. |
|
1084 | information about class constructors. | |
1083 |
|
1085 | |||
1084 | -r: return the pstats.Stats object generated by the profiling. This |
|
1086 | -r: return the pstats.Stats object generated by the profiling. This | |
1085 | object has all the information about the profile in it, and you can |
|
1087 | object has all the information about the profile in it, and you can | |
1086 | later use it for further analysis or in other functions. |
|
1088 | later use it for further analysis or in other functions. | |
1087 |
|
1089 | |||
1088 | Since magic functions have a particular form of calling which prevents |
|
1090 | Since magic functions have a particular form of calling which prevents | |
1089 | you from writing something like:\\ |
|
1091 | you from writing something like:\\ | |
1090 | In [1]: p = %prun -r print 4 # invalid!\\ |
|
1092 | In [1]: p = %prun -r print 4 # invalid!\\ | |
1091 | you must instead use IPython's automatic variables to assign this:\\ |
|
1093 | you must instead use IPython's automatic variables to assign this:\\ | |
1092 | In [1]: %prun -r print 4 \\ |
|
1094 | In [1]: %prun -r print 4 \\ | |
1093 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ |
|
1095 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ | |
1094 | In [2]: stats = _ |
|
1096 | In [2]: stats = _ | |
1095 |
|
1097 | |||
1096 | If you really need to assign this value via an explicit function call, |
|
1098 | If you really need to assign this value via an explicit function call, | |
1097 | you can always tap directly into the true name of the magic function |
|
1099 | you can always tap directly into the true name of the magic function | |
1098 | by using the ipmagic function (which IPython automatically adds to the |
|
1100 | by using the ipmagic function (which IPython automatically adds to the | |
1099 | builtins):\\ |
|
1101 | builtins):\\ | |
1100 | In [3]: stats = ipmagic('prun','-r print 4') |
|
1102 | In [3]: stats = ipmagic('prun','-r print 4') | |
1101 |
|
1103 | |||
1102 | You can type ipmagic? for more details on ipmagic. |
|
1104 | You can type ipmagic? for more details on ipmagic. | |
1103 |
|
1105 | |||
1104 | -s <key>: sort profile by given key. You can provide more than one key |
|
1106 | -s <key>: sort profile by given key. You can provide more than one key | |
1105 | by using the option several times: '-s key1 -s key2 -s key3...'. The |
|
1107 | by using the option several times: '-s key1 -s key2 -s key3...'. The | |
1106 | default sorting key is 'time'. |
|
1108 | default sorting key is 'time'. | |
1107 |
|
1109 | |||
1108 | The following is copied verbatim from the profile documentation |
|
1110 | The following is copied verbatim from the profile documentation | |
1109 | referenced below: |
|
1111 | referenced below: | |
1110 |
|
1112 | |||
1111 | When more than one key is provided, additional keys are used as |
|
1113 | When more than one key is provided, additional keys are used as | |
1112 | secondary criteria when the there is equality in all keys selected |
|
1114 | secondary criteria when the there is equality in all keys selected | |
1113 | before them. |
|
1115 | before them. | |
1114 |
|
1116 | |||
1115 | Abbreviations can be used for any key names, as long as the |
|
1117 | Abbreviations can be used for any key names, as long as the | |
1116 | abbreviation is unambiguous. The following are the keys currently |
|
1118 | abbreviation is unambiguous. The following are the keys currently | |
1117 | defined: |
|
1119 | defined: | |
1118 |
|
1120 | |||
1119 | Valid Arg Meaning\\ |
|
1121 | Valid Arg Meaning\\ | |
1120 | "calls" call count\\ |
|
1122 | "calls" call count\\ | |
1121 | "cumulative" cumulative time\\ |
|
1123 | "cumulative" cumulative time\\ | |
1122 | "file" file name\\ |
|
1124 | "file" file name\\ | |
1123 | "module" file name\\ |
|
1125 | "module" file name\\ | |
1124 | "pcalls" primitive call count\\ |
|
1126 | "pcalls" primitive call count\\ | |
1125 | "line" line number\\ |
|
1127 | "line" line number\\ | |
1126 | "name" function name\\ |
|
1128 | "name" function name\\ | |
1127 | "nfl" name/file/line\\ |
|
1129 | "nfl" name/file/line\\ | |
1128 | "stdname" standard name\\ |
|
1130 | "stdname" standard name\\ | |
1129 | "time" internal time |
|
1131 | "time" internal time | |
1130 |
|
1132 | |||
1131 | Note that all sorts on statistics are in descending order (placing |
|
1133 | Note that all sorts on statistics are in descending order (placing | |
1132 | most time consuming items first), where as name, file, and line number |
|
1134 | most time consuming items first), where as name, file, and line number | |
1133 | searches are in ascending order (i.e., alphabetical). The subtle |
|
1135 | searches are in ascending order (i.e., alphabetical). The subtle | |
1134 | distinction between "nfl" and "stdname" is that the standard name is a |
|
1136 | distinction between "nfl" and "stdname" is that the standard name is a | |
1135 | sort of the name as printed, which means that the embedded line |
|
1137 | sort of the name as printed, which means that the embedded line | |
1136 | numbers get compared in an odd way. For example, lines 3, 20, and 40 |
|
1138 | numbers get compared in an odd way. For example, lines 3, 20, and 40 | |
1137 | would (if the file names were the same) appear in the string order |
|
1139 | would (if the file names were the same) appear in the string order | |
1138 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the |
|
1140 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the | |
1139 | line numbers. In fact, sort_stats("nfl") is the same as |
|
1141 | line numbers. In fact, sort_stats("nfl") is the same as | |
1140 | sort_stats("name", "file", "line"). |
|
1142 | sort_stats("name", "file", "line"). | |
1141 |
|
1143 | |||
1142 | -T <filename>: save profile results as shown on screen to a text |
|
1144 | -T <filename>: save profile results as shown on screen to a text | |
1143 | file. The profile is still shown on screen. |
|
1145 | file. The profile is still shown on screen. | |
1144 |
|
1146 | |||
1145 | -D <filename>: save (via dump_stats) profile statistics to given |
|
1147 | -D <filename>: save (via dump_stats) profile statistics to given | |
1146 | filename. This data is in a format understod by the pstats module, and |
|
1148 | filename. This data is in a format understod by the pstats module, and | |
1147 | is generated by a call to the dump_stats() method of profile |
|
1149 | is generated by a call to the dump_stats() method of profile | |
1148 | objects. The profile is still shown on screen. |
|
1150 | objects. The profile is still shown on screen. | |
1149 |
|
1151 | |||
1150 | If you want to run complete programs under the profiler's control, use |
|
1152 | If you want to run complete programs under the profiler's control, use | |
1151 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts |
|
1153 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts | |
1152 | contains profiler specific options as described here. |
|
1154 | contains profiler specific options as described here. | |
1153 |
|
1155 | |||
1154 | You can read the complete documentation for the profile module with:\\ |
|
1156 | You can read the complete documentation for the profile module with:\\ | |
1155 | In [1]: import profile; profile.help() """ |
|
1157 | In [1]: import profile; profile.help() """ | |
1156 |
|
1158 | |||
1157 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) |
|
1159 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) | |
1158 | # protect user quote marks |
|
1160 | # protect user quote marks | |
1159 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") |
|
1161 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") | |
1160 |
|
1162 | |||
1161 | if user_mode: # regular user call |
|
1163 | if user_mode: # regular user call | |
1162 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', |
|
1164 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', | |
1163 | list_all=1) |
|
1165 | list_all=1) | |
1164 | namespace = self.shell.user_ns |
|
1166 | namespace = self.shell.user_ns | |
1165 | else: # called to run a program by %run -p |
|
1167 | else: # called to run a program by %run -p | |
1166 | try: |
|
1168 | try: | |
1167 | filename = get_py_filename(arg_lst[0]) |
|
1169 | filename = get_py_filename(arg_lst[0]) | |
1168 | except IOError,msg: |
|
1170 | except IOError,msg: | |
1169 | error(msg) |
|
1171 | error(msg) | |
1170 | return |
|
1172 | return | |
1171 |
|
1173 | |||
1172 | arg_str = 'execfile(filename,prog_ns)' |
|
1174 | arg_str = 'execfile(filename,prog_ns)' | |
1173 | namespace = locals() |
|
1175 | namespace = locals() | |
1174 |
|
1176 | |||
1175 | opts.merge(opts_def) |
|
1177 | opts.merge(opts_def) | |
1176 |
|
1178 | |||
1177 | prof = profile.Profile() |
|
1179 | prof = profile.Profile() | |
1178 | try: |
|
1180 | try: | |
1179 | prof = prof.runctx(arg_str,namespace,namespace) |
|
1181 | prof = prof.runctx(arg_str,namespace,namespace) | |
1180 | sys_exit = '' |
|
1182 | sys_exit = '' | |
1181 | except SystemExit: |
|
1183 | except SystemExit: | |
1182 | sys_exit = """*** SystemExit exception caught in code being profiled.""" |
|
1184 | sys_exit = """*** SystemExit exception caught in code being profiled.""" | |
1183 |
|
1185 | |||
1184 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) |
|
1186 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) | |
1185 |
|
1187 | |||
1186 | lims = opts.l |
|
1188 | lims = opts.l | |
1187 | if lims: |
|
1189 | if lims: | |
1188 | lims = [] # rebuild lims with ints/floats/strings |
|
1190 | lims = [] # rebuild lims with ints/floats/strings | |
1189 | for lim in opts.l: |
|
1191 | for lim in opts.l: | |
1190 | try: |
|
1192 | try: | |
1191 | lims.append(int(lim)) |
|
1193 | lims.append(int(lim)) | |
1192 | except ValueError: |
|
1194 | except ValueError: | |
1193 | try: |
|
1195 | try: | |
1194 | lims.append(float(lim)) |
|
1196 | lims.append(float(lim)) | |
1195 | except ValueError: |
|
1197 | except ValueError: | |
1196 | lims.append(lim) |
|
1198 | lims.append(lim) | |
1197 |
|
1199 | |||
1198 | # trap output |
|
1200 | # trap output | |
1199 | sys_stdout = sys.stdout |
|
1201 | sys_stdout = sys.stdout | |
1200 | stdout_trap = StringIO() |
|
1202 | stdout_trap = StringIO() | |
1201 | try: |
|
1203 | try: | |
1202 | sys.stdout = stdout_trap |
|
1204 | sys.stdout = stdout_trap | |
1203 | stats.print_stats(*lims) |
|
1205 | stats.print_stats(*lims) | |
1204 | finally: |
|
1206 | finally: | |
1205 | sys.stdout = sys_stdout |
|
1207 | sys.stdout = sys_stdout | |
1206 | output = stdout_trap.getvalue() |
|
1208 | output = stdout_trap.getvalue() | |
1207 | output = output.rstrip() |
|
1209 | output = output.rstrip() | |
1208 |
|
1210 | |||
1209 | page(output,screen_lines=self.shell.rc.screen_length) |
|
1211 | page(output,screen_lines=self.shell.rc.screen_length) | |
1210 | print sys_exit, |
|
1212 | print sys_exit, | |
1211 |
|
1213 | |||
1212 | dump_file = opts.D[0] |
|
1214 | dump_file = opts.D[0] | |
1213 | text_file = opts.T[0] |
|
1215 | text_file = opts.T[0] | |
1214 | if dump_file: |
|
1216 | if dump_file: | |
1215 | prof.dump_stats(dump_file) |
|
1217 | prof.dump_stats(dump_file) | |
1216 | print '\n*** Profile stats marshalled to file',\ |
|
1218 | print '\n*** Profile stats marshalled to file',\ | |
1217 | `dump_file`+'.',sys_exit |
|
1219 | `dump_file`+'.',sys_exit | |
1218 | if text_file: |
|
1220 | if text_file: | |
1219 | file(text_file,'w').write(output) |
|
1221 | file(text_file,'w').write(output) | |
1220 | print '\n*** Profile printout saved to text file',\ |
|
1222 | print '\n*** Profile printout saved to text file',\ | |
1221 | `text_file`+'.',sys_exit |
|
1223 | `text_file`+'.',sys_exit | |
1222 |
|
1224 | |||
1223 | if opts.has_key('r'): |
|
1225 | if opts.has_key('r'): | |
1224 | return stats |
|
1226 | return stats | |
1225 | else: |
|
1227 | else: | |
1226 | return None |
|
1228 | return None | |
1227 |
|
1229 | |||
1228 | def magic_run(self, parameter_s ='',runner=None): |
|
1230 | def magic_run(self, parameter_s ='',runner=None): | |
1229 | """Run the named file inside IPython as a program. |
|
1231 | """Run the named file inside IPython as a program. | |
1230 |
|
1232 | |||
1231 | Usage:\\ |
|
1233 | Usage:\\ | |
1232 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] |
|
1234 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] | |
1233 |
|
1235 | |||
1234 | Parameters after the filename are passed as command-line arguments to |
|
1236 | Parameters after the filename are passed as command-line arguments to | |
1235 | the program (put in sys.argv). Then, control returns to IPython's |
|
1237 | the program (put in sys.argv). Then, control returns to IPython's | |
1236 | prompt. |
|
1238 | prompt. | |
1237 |
|
1239 | |||
1238 | This is similar to running at a system prompt:\\ |
|
1240 | This is similar to running at a system prompt:\\ | |
1239 | $ python file args\\ |
|
1241 | $ python file args\\ | |
1240 | but with the advantage of giving you IPython's tracebacks, and of |
|
1242 | but with the advantage of giving you IPython's tracebacks, and of | |
1241 | loading all variables into your interactive namespace for further use |
|
1243 | loading all variables into your interactive namespace for further use | |
1242 | (unless -p is used, see below). |
|
1244 | (unless -p is used, see below). | |
1243 |
|
1245 | |||
1244 | The file is executed in a namespace initially consisting only of |
|
1246 | The file is executed in a namespace initially consisting only of | |
1245 | __name__=='__main__' and sys.argv constructed as indicated. It thus |
|
1247 | __name__=='__main__' and sys.argv constructed as indicated. It thus | |
1246 | sees its environment as if it were being run as a stand-alone |
|
1248 | sees its environment as if it were being run as a stand-alone | |
1247 | program. But after execution, the IPython interactive namespace gets |
|
1249 | program. But after execution, the IPython interactive namespace gets | |
1248 | updated with all variables defined in the program (except for __name__ |
|
1250 | updated with all variables defined in the program (except for __name__ | |
1249 | and sys.argv). This allows for very convenient loading of code for |
|
1251 | and sys.argv). This allows for very convenient loading of code for | |
1250 | interactive work, while giving each program a 'clean sheet' to run in. |
|
1252 | interactive work, while giving each program a 'clean sheet' to run in. | |
1251 |
|
1253 | |||
1252 | Options: |
|
1254 | Options: | |
1253 |
|
1255 | |||
1254 | -n: __name__ is NOT set to '__main__', but to the running file's name |
|
1256 | -n: __name__ is NOT set to '__main__', but to the running file's name | |
1255 | without extension (as python does under import). This allows running |
|
1257 | without extension (as python does under import). This allows running | |
1256 | scripts and reloading the definitions in them without calling code |
|
1258 | scripts and reloading the definitions in them without calling code | |
1257 | protected by an ' if __name__ == "__main__" ' clause. |
|
1259 | protected by an ' if __name__ == "__main__" ' clause. | |
1258 |
|
1260 | |||
1259 | -i: run the file in IPython's namespace instead of an empty one. This |
|
1261 | -i: run the file in IPython's namespace instead of an empty one. This | |
1260 | is useful if you are experimenting with code written in a text editor |
|
1262 | is useful if you are experimenting with code written in a text editor | |
1261 | which depends on variables defined interactively. |
|
1263 | which depends on variables defined interactively. | |
1262 |
|
1264 | |||
1263 | -e: ignore sys.exit() calls or SystemExit exceptions in the script |
|
1265 | -e: ignore sys.exit() calls or SystemExit exceptions in the script | |
1264 | being run. This is particularly useful if IPython is being used to |
|
1266 | being run. This is particularly useful if IPython is being used to | |
1265 | run unittests, which always exit with a sys.exit() call. In such |
|
1267 | run unittests, which always exit with a sys.exit() call. In such | |
1266 | cases you are interested in the output of the test results, not in |
|
1268 | cases you are interested in the output of the test results, not in | |
1267 | seeing a traceback of the unittest module. |
|
1269 | seeing a traceback of the unittest module. | |
1268 |
|
1270 | |||
1269 | -t: print timing information at the end of the run. IPython will give |
|
1271 | -t: print timing information at the end of the run. IPython will give | |
1270 | you an estimated CPU time consumption for your script, which under |
|
1272 | you an estimated CPU time consumption for your script, which under | |
1271 | Unix uses the resource module to avoid the wraparound problems of |
|
1273 | Unix uses the resource module to avoid the wraparound problems of | |
1272 | time.clock(). Under Unix, an estimate of time spent on system tasks |
|
1274 | time.clock(). Under Unix, an estimate of time spent on system tasks | |
1273 | is also given (for Windows platforms this is reported as 0.0). |
|
1275 | is also given (for Windows platforms this is reported as 0.0). | |
1274 |
|
1276 | |||
1275 | If -t is given, an additional -N<N> option can be given, where <N> |
|
1277 | If -t is given, an additional -N<N> option can be given, where <N> | |
1276 | must be an integer indicating how many times you want the script to |
|
1278 | must be an integer indicating how many times you want the script to | |
1277 | run. The final timing report will include total and per run results. |
|
1279 | run. The final timing report will include total and per run results. | |
1278 |
|
1280 | |||
1279 | For example (testing the script uniq_stable.py): |
|
1281 | For example (testing the script uniq_stable.py): | |
1280 |
|
1282 | |||
1281 | In [1]: run -t uniq_stable |
|
1283 | In [1]: run -t uniq_stable | |
1282 |
|
1284 | |||
1283 | IPython CPU timings (estimated):\\ |
|
1285 | IPython CPU timings (estimated):\\ | |
1284 | User : 0.19597 s.\\ |
|
1286 | User : 0.19597 s.\\ | |
1285 | System: 0.0 s.\\ |
|
1287 | System: 0.0 s.\\ | |
1286 |
|
1288 | |||
1287 | In [2]: run -t -N5 uniq_stable |
|
1289 | In [2]: run -t -N5 uniq_stable | |
1288 |
|
1290 | |||
1289 | IPython CPU timings (estimated):\\ |
|
1291 | IPython CPU timings (estimated):\\ | |
1290 | Total runs performed: 5\\ |
|
1292 | Total runs performed: 5\\ | |
1291 | Times : Total Per run\\ |
|
1293 | Times : Total Per run\\ | |
1292 | User : 0.910862 s, 0.1821724 s.\\ |
|
1294 | User : 0.910862 s, 0.1821724 s.\\ | |
1293 | System: 0.0 s, 0.0 s. |
|
1295 | System: 0.0 s, 0.0 s. | |
1294 |
|
1296 | |||
1295 | -d: run your program under the control of pdb, the Python debugger. |
|
1297 | -d: run your program under the control of pdb, the Python debugger. | |
1296 | This allows you to execute your program step by step, watch variables, |
|
1298 | This allows you to execute your program step by step, watch variables, | |
1297 | etc. Internally, what IPython does is similar to calling: |
|
1299 | etc. Internally, what IPython does is similar to calling: | |
1298 |
|
1300 | |||
1299 | pdb.run('execfile("YOURFILENAME")') |
|
1301 | pdb.run('execfile("YOURFILENAME")') | |
1300 |
|
1302 | |||
1301 | with a breakpoint set on line 1 of your file. You can change the line |
|
1303 | with a breakpoint set on line 1 of your file. You can change the line | |
1302 | number for this automatic breakpoint to be <N> by using the -bN option |
|
1304 | number for this automatic breakpoint to be <N> by using the -bN option | |
1303 | (where N must be an integer). For example: |
|
1305 | (where N must be an integer). For example: | |
1304 |
|
1306 | |||
1305 | %run -d -b40 myscript |
|
1307 | %run -d -b40 myscript | |
1306 |
|
1308 | |||
1307 | will set the first breakpoint at line 40 in myscript.py. Note that |
|
1309 | will set the first breakpoint at line 40 in myscript.py. Note that | |
1308 | the first breakpoint must be set on a line which actually does |
|
1310 | the first breakpoint must be set on a line which actually does | |
1309 | something (not a comment or docstring) for it to stop execution. |
|
1311 | something (not a comment or docstring) for it to stop execution. | |
1310 |
|
1312 | |||
1311 | When the pdb debugger starts, you will see a (Pdb) prompt. You must |
|
1313 | When the pdb debugger starts, you will see a (Pdb) prompt. You must | |
1312 | first enter 'c' (without qoutes) to start execution up to the first |
|
1314 | first enter 'c' (without qoutes) to start execution up to the first | |
1313 | breakpoint. |
|
1315 | breakpoint. | |
1314 |
|
1316 | |||
1315 | Entering 'help' gives information about the use of the debugger. You |
|
1317 | Entering 'help' gives information about the use of the debugger. You | |
1316 | can easily see pdb's full documentation with "import pdb;pdb.help()" |
|
1318 | can easily see pdb's full documentation with "import pdb;pdb.help()" | |
1317 | at a prompt. |
|
1319 | at a prompt. | |
1318 |
|
1320 | |||
1319 | -p: run program under the control of the Python profiler module (which |
|
1321 | -p: run program under the control of the Python profiler module (which | |
1320 | prints a detailed report of execution times, function calls, etc). |
|
1322 | prints a detailed report of execution times, function calls, etc). | |
1321 |
|
1323 | |||
1322 | You can pass other options after -p which affect the behavior of the |
|
1324 | You can pass other options after -p which affect the behavior of the | |
1323 | profiler itself. See the docs for %prun for details. |
|
1325 | profiler itself. See the docs for %prun for details. | |
1324 |
|
1326 | |||
1325 | In this mode, the program's variables do NOT propagate back to the |
|
1327 | In this mode, the program's variables do NOT propagate back to the | |
1326 | IPython interactive namespace (because they remain in the namespace |
|
1328 | IPython interactive namespace (because they remain in the namespace | |
1327 | where the profiler executes them). |
|
1329 | where the profiler executes them). | |
1328 |
|
1330 | |||
1329 | Internally this triggers a call to %prun, see its documentation for |
|
1331 | Internally this triggers a call to %prun, see its documentation for | |
1330 | details on the options available specifically for profiling.""" |
|
1332 | details on the options available specifically for profiling.""" | |
1331 |
|
1333 | |||
1332 | # get arguments and set sys.argv for program to be run. |
|
1334 | # get arguments and set sys.argv for program to be run. | |
1333 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', |
|
1335 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', | |
1334 | mode='list',list_all=1) |
|
1336 | mode='list',list_all=1) | |
1335 |
|
1337 | |||
1336 | try: |
|
1338 | try: | |
1337 | filename = get_py_filename(arg_lst[0]) |
|
1339 | filename = get_py_filename(arg_lst[0]) | |
1338 | except IndexError: |
|
1340 | except IndexError: | |
1339 | warn('you must provide at least a filename.') |
|
1341 | warn('you must provide at least a filename.') | |
1340 | print '\n%run:\n',OInspect.getdoc(self.magic_run) |
|
1342 | print '\n%run:\n',OInspect.getdoc(self.magic_run) | |
1341 | return |
|
1343 | return | |
1342 | except IOError,msg: |
|
1344 | except IOError,msg: | |
1343 | error(msg) |
|
1345 | error(msg) | |
1344 | return |
|
1346 | return | |
1345 |
|
1347 | |||
1346 | # Control the response to exit() calls made by the script being run |
|
1348 | # Control the response to exit() calls made by the script being run | |
1347 | exit_ignore = opts.has_key('e') |
|
1349 | exit_ignore = opts.has_key('e') | |
1348 |
|
1350 | |||
1349 | # Make sure that the running script gets a proper sys.argv as if it |
|
1351 | # Make sure that the running script gets a proper sys.argv as if it | |
1350 | # were run from a system shell. |
|
1352 | # were run from a system shell. | |
1351 | save_argv = sys.argv # save it for later restoring |
|
1353 | save_argv = sys.argv # save it for later restoring | |
1352 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename |
|
1354 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename | |
1353 |
|
1355 | |||
1354 | if opts.has_key('i'): |
|
1356 | if opts.has_key('i'): | |
1355 | prog_ns = self.shell.user_ns |
|
1357 | prog_ns = self.shell.user_ns | |
1356 | __name__save = self.shell.user_ns['__name__'] |
|
1358 | __name__save = self.shell.user_ns['__name__'] | |
1357 | prog_ns['__name__'] = '__main__' |
|
1359 | prog_ns['__name__'] = '__main__' | |
1358 | else: |
|
1360 | else: | |
1359 | if opts.has_key('n'): |
|
1361 | if opts.has_key('n'): | |
1360 | name = os.path.splitext(os.path.basename(filename))[0] |
|
1362 | name = os.path.splitext(os.path.basename(filename))[0] | |
1361 | else: |
|
1363 | else: | |
1362 | name = '__main__' |
|
1364 | name = '__main__' | |
1363 | prog_ns = {'__name__':name} |
|
1365 | prog_ns = {'__name__':name} | |
1364 |
|
1366 | |||
1365 | # pickle fix. See iplib for an explanation. But we need to make sure |
|
1367 | # pickle fix. See iplib for an explanation. But we need to make sure | |
1366 | # that, if we overwrite __main__, we replace it at the end |
|
1368 | # that, if we overwrite __main__, we replace it at the end | |
1367 | if prog_ns['__name__'] == '__main__': |
|
1369 | if prog_ns['__name__'] == '__main__': | |
1368 | restore_main = sys.modules['__main__'] |
|
1370 | restore_main = sys.modules['__main__'] | |
1369 | else: |
|
1371 | else: | |
1370 | restore_main = False |
|
1372 | restore_main = False | |
1371 |
|
1373 | |||
1372 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) |
|
1374 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) | |
1373 |
|
1375 | |||
1374 | stats = None |
|
1376 | stats = None | |
1375 | try: |
|
1377 | try: | |
1376 | if opts.has_key('p'): |
|
1378 | if opts.has_key('p'): | |
1377 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) |
|
1379 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) | |
1378 | else: |
|
1380 | else: | |
1379 | if opts.has_key('d'): |
|
1381 | if opts.has_key('d'): | |
1380 | deb = Debugger.Pdb(self.shell.rc.colors) |
|
1382 | deb = Debugger.Pdb(self.shell.rc.colors) | |
1381 | # reset Breakpoint state, which is moronically kept |
|
1383 | # reset Breakpoint state, which is moronically kept | |
1382 | # in a class |
|
1384 | # in a class | |
1383 | bdb.Breakpoint.next = 1 |
|
1385 | bdb.Breakpoint.next = 1 | |
1384 | bdb.Breakpoint.bplist = {} |
|
1386 | bdb.Breakpoint.bplist = {} | |
1385 | bdb.Breakpoint.bpbynumber = [None] |
|
1387 | bdb.Breakpoint.bpbynumber = [None] | |
1386 | # Set an initial breakpoint to stop execution |
|
1388 | # Set an initial breakpoint to stop execution | |
1387 | maxtries = 10 |
|
1389 | maxtries = 10 | |
1388 | bp = int(opts.get('b',[1])[0]) |
|
1390 | bp = int(opts.get('b',[1])[0]) | |
1389 | checkline = deb.checkline(filename,bp) |
|
1391 | checkline = deb.checkline(filename,bp) | |
1390 | if not checkline: |
|
1392 | if not checkline: | |
1391 | for bp in range(bp+1,bp+maxtries+1): |
|
1393 | for bp in range(bp+1,bp+maxtries+1): | |
1392 | if deb.checkline(filename,bp): |
|
1394 | if deb.checkline(filename,bp): | |
1393 | break |
|
1395 | break | |
1394 | else: |
|
1396 | else: | |
1395 | msg = ("\nI failed to find a valid line to set " |
|
1397 | msg = ("\nI failed to find a valid line to set " | |
1396 | "a breakpoint\n" |
|
1398 | "a breakpoint\n" | |
1397 | "after trying up to line: %s.\n" |
|
1399 | "after trying up to line: %s.\n" | |
1398 | "Please set a valid breakpoint manually " |
|
1400 | "Please set a valid breakpoint manually " | |
1399 | "with the -b option." % bp) |
|
1401 | "with the -b option." % bp) | |
1400 | error(msg) |
|
1402 | error(msg) | |
1401 | return |
|
1403 | return | |
1402 | # if we find a good linenumber, set the breakpoint |
|
1404 | # if we find a good linenumber, set the breakpoint | |
1403 | deb.do_break('%s:%s' % (filename,bp)) |
|
1405 | deb.do_break('%s:%s' % (filename,bp)) | |
1404 | # Start file run |
|
1406 | # Start file run | |
1405 | print "NOTE: Enter 'c' at the", |
|
1407 | print "NOTE: Enter 'c' at the", | |
1406 | print "ipdb> prompt to start your script." |
|
1408 | print "ipdb> prompt to start your script." | |
1407 | try: |
|
1409 | try: | |
1408 | deb.run('execfile("%s")' % filename,prog_ns) |
|
1410 | deb.run('execfile("%s")' % filename,prog_ns) | |
1409 | except: |
|
1411 | except: | |
1410 | etype, value, tb = sys.exc_info() |
|
1412 | etype, value, tb = sys.exc_info() | |
1411 | # Skip three frames in the traceback: the %run one, |
|
1413 | # Skip three frames in the traceback: the %run one, | |
1412 | # one inside bdb.py, and the command-line typed by the |
|
1414 | # one inside bdb.py, and the command-line typed by the | |
1413 | # user (run by exec in pdb itself). |
|
1415 | # user (run by exec in pdb itself). | |
1414 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) |
|
1416 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) | |
1415 | else: |
|
1417 | else: | |
1416 | if runner is None: |
|
1418 | if runner is None: | |
1417 | runner = self.shell.safe_execfile |
|
1419 | runner = self.shell.safe_execfile | |
1418 | if opts.has_key('t'): |
|
1420 | if opts.has_key('t'): | |
1419 | try: |
|
1421 | try: | |
1420 | nruns = int(opts['N'][0]) |
|
1422 | nruns = int(opts['N'][0]) | |
1421 | if nruns < 1: |
|
1423 | if nruns < 1: | |
1422 | error('Number of runs must be >=1') |
|
1424 | error('Number of runs must be >=1') | |
1423 | return |
|
1425 | return | |
1424 | except (KeyError): |
|
1426 | except (KeyError): | |
1425 | nruns = 1 |
|
1427 | nruns = 1 | |
1426 | if nruns == 1: |
|
1428 | if nruns == 1: | |
1427 | t0 = clock2() |
|
1429 | t0 = clock2() | |
1428 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1430 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1429 | t1 = clock2() |
|
1431 | t1 = clock2() | |
1430 | t_usr = t1[0]-t0[0] |
|
1432 | t_usr = t1[0]-t0[0] | |
1431 | t_sys = t1[1]-t1[1] |
|
1433 | t_sys = t1[1]-t1[1] | |
1432 | print "\nIPython CPU timings (estimated):" |
|
1434 | print "\nIPython CPU timings (estimated):" | |
1433 | print " User : %10s s." % t_usr |
|
1435 | print " User : %10s s." % t_usr | |
1434 | print " System: %10s s." % t_sys |
|
1436 | print " System: %10s s." % t_sys | |
1435 | else: |
|
1437 | else: | |
1436 | runs = range(nruns) |
|
1438 | runs = range(nruns) | |
1437 | t0 = clock2() |
|
1439 | t0 = clock2() | |
1438 | for nr in runs: |
|
1440 | for nr in runs: | |
1439 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1441 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1440 | t1 = clock2() |
|
1442 | t1 = clock2() | |
1441 | t_usr = t1[0]-t0[0] |
|
1443 | t_usr = t1[0]-t0[0] | |
1442 | t_sys = t1[1]-t1[1] |
|
1444 | t_sys = t1[1]-t1[1] | |
1443 | print "\nIPython CPU timings (estimated):" |
|
1445 | print "\nIPython CPU timings (estimated):" | |
1444 | print "Total runs performed:",nruns |
|
1446 | print "Total runs performed:",nruns | |
1445 | print " Times : %10s %10s" % ('Total','Per run') |
|
1447 | print " Times : %10s %10s" % ('Total','Per run') | |
1446 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) |
|
1448 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) | |
1447 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) |
|
1449 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) | |
1448 |
|
1450 | |||
1449 | else: |
|
1451 | else: | |
1450 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1452 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1451 | if opts.has_key('i'): |
|
1453 | if opts.has_key('i'): | |
1452 | self.shell.user_ns['__name__'] = __name__save |
|
1454 | self.shell.user_ns['__name__'] = __name__save | |
1453 | else: |
|
1455 | else: | |
1454 | # update IPython interactive namespace |
|
1456 | # update IPython interactive namespace | |
1455 | del prog_ns['__name__'] |
|
1457 | del prog_ns['__name__'] | |
1456 | self.shell.user_ns.update(prog_ns) |
|
1458 | self.shell.user_ns.update(prog_ns) | |
1457 | finally: |
|
1459 | finally: | |
1458 | sys.argv = save_argv |
|
1460 | sys.argv = save_argv | |
1459 | if restore_main: |
|
1461 | if restore_main: | |
1460 | sys.modules['__main__'] = restore_main |
|
1462 | sys.modules['__main__'] = restore_main | |
1461 | return stats |
|
1463 | return stats | |
1462 |
|
1464 | |||
1463 | def magic_runlog(self, parameter_s =''): |
|
1465 | def magic_runlog(self, parameter_s =''): | |
1464 | """Run files as logs. |
|
1466 | """Run files as logs. | |
1465 |
|
1467 | |||
1466 | Usage:\\ |
|
1468 | Usage:\\ | |
1467 | %runlog file1 file2 ... |
|
1469 | %runlog file1 file2 ... | |
1468 |
|
1470 | |||
1469 | Run the named files (treating them as log files) in sequence inside |
|
1471 | Run the named files (treating them as log files) in sequence inside | |
1470 | the interpreter, and return to the prompt. This is much slower than |
|
1472 | the interpreter, and return to the prompt. This is much slower than | |
1471 | %run because each line is executed in a try/except block, but it |
|
1473 | %run because each line is executed in a try/except block, but it | |
1472 | allows running files with syntax errors in them. |
|
1474 | allows running files with syntax errors in them. | |
1473 |
|
1475 | |||
1474 | Normally IPython will guess when a file is one of its own logfiles, so |
|
1476 | Normally IPython will guess when a file is one of its own logfiles, so | |
1475 | you can typically use %run even for logs. This shorthand allows you to |
|
1477 | you can typically use %run even for logs. This shorthand allows you to | |
1476 | force any file to be treated as a log file.""" |
|
1478 | force any file to be treated as a log file.""" | |
1477 |
|
1479 | |||
1478 | for f in parameter_s.split(): |
|
1480 | for f in parameter_s.split(): | |
1479 | self.shell.safe_execfile(f,self.shell.user_ns, |
|
1481 | self.shell.safe_execfile(f,self.shell.user_ns, | |
1480 | self.shell.user_ns,islog=1) |
|
1482 | self.shell.user_ns,islog=1) | |
1481 |
|
1483 | |||
1482 | def magic_time(self,parameter_s = ''): |
|
1484 | def magic_time(self,parameter_s = ''): | |
1483 | """Time execution of a Python statement or expression. |
|
1485 | """Time execution of a Python statement or expression. | |
1484 |
|
1486 | |||
1485 | The CPU and wall clock times are printed, and the value of the |
|
1487 | The CPU and wall clock times are printed, and the value of the | |
1486 | expression (if any) is returned. Note that under Win32, system time |
|
1488 | expression (if any) is returned. Note that under Win32, system time | |
1487 | is always reported as 0, since it can not be measured. |
|
1489 | is always reported as 0, since it can not be measured. | |
1488 |
|
1490 | |||
1489 | This function provides very basic timing functionality. In Python |
|
1491 | This function provides very basic timing functionality. In Python | |
1490 | 2.3, the timeit module offers more control and sophistication, but for |
|
1492 | 2.3, the timeit module offers more control and sophistication, but for | |
1491 | now IPython supports Python 2.2, so we can not rely on timeit being |
|
1493 | now IPython supports Python 2.2, so we can not rely on timeit being | |
1492 | present. |
|
1494 | present. | |
1493 |
|
1495 | |||
1494 | Some examples: |
|
1496 | Some examples: | |
1495 |
|
1497 | |||
1496 | In [1]: time 2**128 |
|
1498 | In [1]: time 2**128 | |
1497 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1499 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1498 | Wall time: 0.00 |
|
1500 | Wall time: 0.00 | |
1499 | Out[1]: 340282366920938463463374607431768211456L |
|
1501 | Out[1]: 340282366920938463463374607431768211456L | |
1500 |
|
1502 | |||
1501 | In [2]: n = 1000000 |
|
1503 | In [2]: n = 1000000 | |
1502 |
|
1504 | |||
1503 | In [3]: time sum(range(n)) |
|
1505 | In [3]: time sum(range(n)) | |
1504 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s |
|
1506 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s | |
1505 | Wall time: 1.37 |
|
1507 | Wall time: 1.37 | |
1506 | Out[3]: 499999500000L |
|
1508 | Out[3]: 499999500000L | |
1507 |
|
1509 | |||
1508 | In [4]: time print 'hello world' |
|
1510 | In [4]: time print 'hello world' | |
1509 | hello world |
|
1511 | hello world | |
1510 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1512 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1511 | Wall time: 0.00 |
|
1513 | Wall time: 0.00 | |
1512 | """ |
|
1514 | """ | |
1513 |
|
1515 | |||
1514 | # fail immediately if the given expression can't be compiled |
|
1516 | # fail immediately if the given expression can't be compiled | |
1515 | try: |
|
1517 | try: | |
1516 | mode = 'eval' |
|
1518 | mode = 'eval' | |
1517 | code = compile(parameter_s,'<timed eval>',mode) |
|
1519 | code = compile(parameter_s,'<timed eval>',mode) | |
1518 | except SyntaxError: |
|
1520 | except SyntaxError: | |
1519 | mode = 'exec' |
|
1521 | mode = 'exec' | |
1520 | code = compile(parameter_s,'<timed exec>',mode) |
|
1522 | code = compile(parameter_s,'<timed exec>',mode) | |
1521 | # skew measurement as little as possible |
|
1523 | # skew measurement as little as possible | |
1522 | glob = self.shell.user_ns |
|
1524 | glob = self.shell.user_ns | |
1523 | clk = clock2 |
|
1525 | clk = clock2 | |
1524 | wtime = time.time |
|
1526 | wtime = time.time | |
1525 | # time execution |
|
1527 | # time execution | |
1526 | wall_st = wtime() |
|
1528 | wall_st = wtime() | |
1527 | if mode=='eval': |
|
1529 | if mode=='eval': | |
1528 | st = clk() |
|
1530 | st = clk() | |
1529 | out = eval(code,glob) |
|
1531 | out = eval(code,glob) | |
1530 | end = clk() |
|
1532 | end = clk() | |
1531 | else: |
|
1533 | else: | |
1532 | st = clk() |
|
1534 | st = clk() | |
1533 | exec code in glob |
|
1535 | exec code in glob | |
1534 | end = clk() |
|
1536 | end = clk() | |
1535 | out = None |
|
1537 | out = None | |
1536 | wall_end = wtime() |
|
1538 | wall_end = wtime() | |
1537 | # Compute actual times and report |
|
1539 | # Compute actual times and report | |
1538 | wall_time = wall_end-wall_st |
|
1540 | wall_time = wall_end-wall_st | |
1539 | cpu_user = end[0]-st[0] |
|
1541 | cpu_user = end[0]-st[0] | |
1540 | cpu_sys = end[1]-st[1] |
|
1542 | cpu_sys = end[1]-st[1] | |
1541 | cpu_tot = cpu_user+cpu_sys |
|
1543 | cpu_tot = cpu_user+cpu_sys | |
1542 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ |
|
1544 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ | |
1543 | (cpu_user,cpu_sys,cpu_tot) |
|
1545 | (cpu_user,cpu_sys,cpu_tot) | |
1544 | print "Wall time: %.2f" % wall_time |
|
1546 | print "Wall time: %.2f" % wall_time | |
1545 | return out |
|
1547 | return out | |
1546 |
|
1548 | |||
1547 | def magic_macro(self,parameter_s = ''): |
|
1549 | def magic_macro(self,parameter_s = ''): | |
1548 | """Define a set of input lines as a macro for future re-execution. |
|
1550 | """Define a set of input lines as a macro for future re-execution. | |
1549 |
|
1551 | |||
1550 | Usage:\\ |
|
1552 | Usage:\\ | |
1551 | %macro name n1-n2 n3-n4 ... n5 .. n6 ... |
|
1553 | %macro name n1-n2 n3-n4 ... n5 .. n6 ... | |
1552 |
|
1554 | |||
1553 | This will define a global variable called `name` which is a string |
|
1555 | This will define a global variable called `name` which is a string | |
1554 | made of joining the slices and lines you specify (n1,n2,... numbers |
|
1556 | made of joining the slices and lines you specify (n1,n2,... numbers | |
1555 | above) from your input history into a single string. This variable |
|
1557 | above) from your input history into a single string. This variable | |
1556 | acts like an automatic function which re-executes those lines as if |
|
1558 | acts like an automatic function which re-executes those lines as if | |
1557 | you had typed them. You just type 'name' at the prompt and the code |
|
1559 | you had typed them. You just type 'name' at the prompt and the code | |
1558 | executes. |
|
1560 | executes. | |
1559 |
|
1561 | |||
1560 | The notation for indicating number ranges is: n1-n2 means 'use line |
|
1562 | The notation for indicating number ranges is: n1-n2 means 'use line | |
1561 | numbers n1,...n2' (the endpoint is included). That is, '5-7' means |
|
1563 | numbers n1,...n2' (the endpoint is included). That is, '5-7' means | |
1562 | using the lines numbered 5,6 and 7. |
|
1564 | using the lines numbered 5,6 and 7. | |
1563 |
|
1565 | |||
1564 | Note: as a 'hidden' feature, you can also use traditional python slice |
|
1566 | Note: as a 'hidden' feature, you can also use traditional python slice | |
1565 | notation, where N:M means numbers N through M-1. |
|
1567 | notation, where N:M means numbers N through M-1. | |
1566 |
|
1568 | |||
1567 | For example, if your history contains (%hist prints it): |
|
1569 | For example, if your history contains (%hist prints it): | |
1568 |
|
1570 | |||
1569 | 44: x=1\\ |
|
1571 | 44: x=1\\ | |
1570 | 45: y=3\\ |
|
1572 | 45: y=3\\ | |
1571 | 46: z=x+y\\ |
|
1573 | 46: z=x+y\\ | |
1572 | 47: print x\\ |
|
1574 | 47: print x\\ | |
1573 | 48: a=5\\ |
|
1575 | 48: a=5\\ | |
1574 | 49: print 'x',x,'y',y\\ |
|
1576 | 49: print 'x',x,'y',y\\ | |
1575 |
|
1577 | |||
1576 | you can create a macro with lines 44 through 47 (included) and line 49 |
|
1578 | you can create a macro with lines 44 through 47 (included) and line 49 | |
1577 | called my_macro with: |
|
1579 | called my_macro with: | |
1578 |
|
1580 | |||
1579 | In [51]: %macro my_macro 44-47 49 |
|
1581 | In [51]: %macro my_macro 44-47 49 | |
1580 |
|
1582 | |||
1581 | Now, typing `my_macro` (without quotes) will re-execute all this code |
|
1583 | Now, typing `my_macro` (without quotes) will re-execute all this code | |
1582 | in one pass. |
|
1584 | in one pass. | |
1583 |
|
1585 | |||
1584 | You don't need to give the line-numbers in order, and any given line |
|
1586 | You don't need to give the line-numbers in order, and any given line | |
1585 | number can appear multiple times. You can assemble macros with any |
|
1587 | number can appear multiple times. You can assemble macros with any | |
1586 | lines from your input history in any order. |
|
1588 | lines from your input history in any order. | |
1587 |
|
1589 | |||
1588 | The macro is a simple object which holds its value in an attribute, |
|
1590 | The macro is a simple object which holds its value in an attribute, | |
1589 | but IPython's display system checks for macros and executes them as |
|
1591 | but IPython's display system checks for macros and executes them as | |
1590 | code instead of printing them when you type their name. |
|
1592 | code instead of printing them when you type their name. | |
1591 |
|
1593 | |||
1592 | You can view a macro's contents by explicitly printing it with: |
|
1594 | You can view a macro's contents by explicitly printing it with: | |
1593 |
|
1595 | |||
1594 | 'print macro_name'. |
|
1596 | 'print macro_name'. | |
1595 |
|
1597 | |||
1596 | For one-off cases which DON'T contain magic function calls in them you |
|
1598 | For one-off cases which DON'T contain magic function calls in them you | |
1597 | can obtain similar results by explicitly executing slices from your |
|
1599 | can obtain similar results by explicitly executing slices from your | |
1598 | input history with: |
|
1600 | input history with: | |
1599 |
|
1601 | |||
1600 | In [60]: exec In[44:48]+In[49]""" |
|
1602 | In [60]: exec In[44:48]+In[49]""" | |
1601 |
|
1603 | |||
1602 | args = parameter_s.split() |
|
1604 | args = parameter_s.split() | |
1603 | name,ranges = args[0], args[1:] |
|
1605 | name,ranges = args[0], args[1:] | |
1604 | #print 'rng',ranges # dbg |
|
1606 | #print 'rng',ranges # dbg | |
1605 | lines = self.extract_input_slices(ranges) |
|
1607 | lines = self.extract_input_slices(ranges) | |
1606 | macro = Macro(lines) |
|
1608 | macro = Macro(lines) | |
1607 | self.shell.user_ns.update({name:macro}) |
|
1609 | self.shell.user_ns.update({name:macro}) | |
1608 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name |
|
1610 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name | |
1609 | print 'Macro contents:' |
|
1611 | print 'Macro contents:' | |
1610 | print macro, |
|
1612 | print macro, | |
1611 |
|
1613 | |||
1612 | def magic_save(self,parameter_s = ''): |
|
1614 | def magic_save(self,parameter_s = ''): | |
1613 | """Save a set of lines to a given filename. |
|
1615 | """Save a set of lines to a given filename. | |
1614 |
|
1616 | |||
1615 | Usage:\\ |
|
1617 | Usage:\\ | |
1616 | %save filename n1-n2 n3-n4 ... n5 .. n6 ... |
|
1618 | %save filename n1-n2 n3-n4 ... n5 .. n6 ... | |
1617 |
|
1619 | |||
1618 | This function uses the same syntax as %macro for line extraction, but |
|
1620 | This function uses the same syntax as %macro for line extraction, but | |
1619 | instead of creating a macro it saves the resulting string to the |
|
1621 | instead of creating a macro it saves the resulting string to the | |
1620 | filename you specify. |
|
1622 | filename you specify. | |
1621 |
|
1623 | |||
1622 | It adds a '.py' extension to the file if you don't do so yourself, and |
|
1624 | It adds a '.py' extension to the file if you don't do so yourself, and | |
1623 | it asks for confirmation before overwriting existing files.""" |
|
1625 | it asks for confirmation before overwriting existing files.""" | |
1624 |
|
1626 | |||
1625 | args = parameter_s.split() |
|
1627 | args = parameter_s.split() | |
1626 | fname,ranges = args[0], args[1:] |
|
1628 | fname,ranges = args[0], args[1:] | |
1627 | if not fname.endswith('.py'): |
|
1629 | if not fname.endswith('.py'): | |
1628 | fname += '.py' |
|
1630 | fname += '.py' | |
1629 | if os.path.isfile(fname): |
|
1631 | if os.path.isfile(fname): | |
1630 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) |
|
1632 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) | |
1631 | if ans.lower() not in ['y','yes']: |
|
1633 | if ans.lower() not in ['y','yes']: | |
1632 | print 'Operation cancelled.' |
|
1634 | print 'Operation cancelled.' | |
1633 | return |
|
1635 | return | |
1634 | cmds = ''.join(self.extract_input_slices(ranges)) |
|
1636 | cmds = ''.join(self.extract_input_slices(ranges)) | |
1635 | f = file(fname,'w') |
|
1637 | f = file(fname,'w') | |
1636 | f.write(cmds) |
|
1638 | f.write(cmds) | |
1637 | f.close() |
|
1639 | f.close() | |
1638 | print 'The following commands were written to file `%s`:' % fname |
|
1640 | print 'The following commands were written to file `%s`:' % fname | |
1639 | print cmds |
|
1641 | print cmds | |
1640 |
|
1642 | |||
1641 | def magic_ed(self,parameter_s = ''): |
|
1643 | def _edit_macro(self,mname,macro): | |
|
1644 | """open an editor with the macro data in a file""" | |||
|
1645 | filename = self.shell.mktempfile(macro.value) | |||
|
1646 | self.shell.hooks.editor(filename) | |||
|
1647 | ||||
|
1648 | # and make a new macro object, to replace the old one | |||
|
1649 | mfile = open(filename) | |||
|
1650 | mvalue = mfile.read() | |||
|
1651 | mfile.close() | |||
|
1652 | self.shell.user_ns[mname] = Macro(mvalue) | |||
|
1653 | ||||
|
1654 | def magic_ed(self,parameter_s=''): | |||
1642 | """Alias to %edit.""" |
|
1655 | """Alias to %edit.""" | |
1643 | return self.magic_edit(parameter_s) |
|
1656 | return self.magic_edit(parameter_s) | |
1644 |
|
1657 | |||
1645 |
def magic_edit(self,parameter_s |
|
1658 | def magic_edit(self,parameter_s='',last_call=['','']): | |
1646 | """Bring up an editor and execute the resulting code. |
|
1659 | """Bring up an editor and execute the resulting code. | |
1647 |
|
1660 | |||
1648 | Usage: |
|
1661 | Usage: | |
1649 | %edit [options] [args] |
|
1662 | %edit [options] [args] | |
1650 |
|
1663 | |||
1651 | %edit runs IPython's editor hook. The default version of this hook is |
|
1664 | %edit runs IPython's editor hook. The default version of this hook is | |
1652 | set to call the __IPYTHON__.rc.editor command. This is read from your |
|
1665 | set to call the __IPYTHON__.rc.editor command. This is read from your | |
1653 | environment variable $EDITOR. If this isn't found, it will default to |
|
1666 | environment variable $EDITOR. If this isn't found, it will default to | |
1654 | vi under Linux/Unix and to notepad under Windows. See the end of this |
|
1667 | vi under Linux/Unix and to notepad under Windows. See the end of this | |
1655 | docstring for how to change the editor hook. |
|
1668 | docstring for how to change the editor hook. | |
1656 |
|
1669 | |||
1657 | You can also set the value of this editor via the command line option |
|
1670 | You can also set the value of this editor via the command line option | |
1658 | '-editor' or in your ipythonrc file. This is useful if you wish to use |
|
1671 | '-editor' or in your ipythonrc file. This is useful if you wish to use | |
1659 | specifically for IPython an editor different from your typical default |
|
1672 | specifically for IPython an editor different from your typical default | |
1660 | (and for Windows users who typically don't set environment variables). |
|
1673 | (and for Windows users who typically don't set environment variables). | |
1661 |
|
1674 | |||
1662 | This command allows you to conveniently edit multi-line code right in |
|
1675 | This command allows you to conveniently edit multi-line code right in | |
1663 | your IPython session. |
|
1676 | your IPython session. | |
1664 |
|
1677 | |||
1665 | If called without arguments, %edit opens up an empty editor with a |
|
1678 | If called without arguments, %edit opens up an empty editor with a | |
1666 | temporary file and will execute the contents of this file when you |
|
1679 | temporary file and will execute the contents of this file when you | |
1667 | close it (don't forget to save it!). |
|
1680 | close it (don't forget to save it!). | |
1668 |
|
1681 | |||
1669 | Options: |
|
1682 | Options: | |
1670 |
|
1683 | |||
1671 | -p: this will call the editor with the same data as the previous time |
|
1684 | -p: this will call the editor with the same data as the previous time | |
1672 | it was used, regardless of how long ago (in your current session) it |
|
1685 | it was used, regardless of how long ago (in your current session) it | |
1673 | was. |
|
1686 | was. | |
1674 |
|
1687 | |||
1675 | -x: do not execute the edited code immediately upon exit. This is |
|
1688 | -x: do not execute the edited code immediately upon exit. This is | |
1676 | mainly useful if you are editing programs which need to be called with |
|
1689 | mainly useful if you are editing programs which need to be called with | |
1677 | command line arguments, which you can then do using %run. |
|
1690 | command line arguments, which you can then do using %run. | |
1678 |
|
1691 | |||
1679 | Arguments: |
|
1692 | Arguments: | |
1680 |
|
1693 | |||
1681 | If arguments are given, the following possibilites exist: |
|
1694 | If arguments are given, the following possibilites exist: | |
1682 |
|
1695 | |||
1683 | - The arguments are numbers or pairs of colon-separated numbers (like |
|
1696 | - The arguments are numbers or pairs of colon-separated numbers (like | |
1684 | 1 4:8 9). These are interpreted as lines of previous input to be |
|
1697 | 1 4:8 9). These are interpreted as lines of previous input to be | |
1685 | loaded into the editor. The syntax is the same of the %macro command. |
|
1698 | loaded into the editor. The syntax is the same of the %macro command. | |
1686 |
|
1699 | |||
1687 | - If the argument doesn't start with a number, it is evaluated as a |
|
1700 | - If the argument doesn't start with a number, it is evaluated as a | |
1688 | variable and its contents loaded into the editor. You can thus edit |
|
1701 | variable and its contents loaded into the editor. You can thus edit | |
1689 | any string which contains python code (including the result of |
|
1702 | any string which contains python code (including the result of | |
1690 | previous edits). |
|
1703 | previous edits). | |
1691 |
|
1704 | |||
1692 | - If the argument is the name of an object (other than a string), |
|
1705 | - If the argument is the name of an object (other than a string), | |
1693 | IPython will try to locate the file where it was defined and open the |
|
1706 | IPython will try to locate the file where it was defined and open the | |
1694 | editor at the point where it is defined. You can use `%edit function` |
|
1707 | editor at the point where it is defined. You can use `%edit function` | |
1695 | to load an editor exactly at the point where 'function' is defined, |
|
1708 | to load an editor exactly at the point where 'function' is defined, | |
1696 | edit it and have the file be executed automatically. |
|
1709 | edit it and have the file be executed automatically. | |
1697 |
|
1710 | |||
|
1711 | If the object is a macro (see %macro for details), this opens up your | |||
|
1712 | specified editor with a temporary file containing the macro's data. | |||
|
1713 | Upon exit, the macro is reloaded with the contents of the file. | |||
|
1714 | ||||
1698 | Note: opening at an exact line is only supported under Unix, and some |
|
1715 | Note: opening at an exact line is only supported under Unix, and some | |
1699 | editors (like kedit and gedit up to Gnome 2.8) do not understand the |
|
1716 | editors (like kedit and gedit up to Gnome 2.8) do not understand the | |
1700 | '+NUMBER' parameter necessary for this feature. Good editors like |
|
1717 | '+NUMBER' parameter necessary for this feature. Good editors like | |
1701 | (X)Emacs, vi, jed, pico and joe all do. |
|
1718 | (X)Emacs, vi, jed, pico and joe all do. | |
1702 |
|
1719 | |||
1703 | - If the argument is not found as a variable, IPython will look for a |
|
1720 | - If the argument is not found as a variable, IPython will look for a | |
1704 | file with that name (adding .py if necessary) and load it into the |
|
1721 | file with that name (adding .py if necessary) and load it into the | |
1705 | editor. It will execute its contents with execfile() when you exit, |
|
1722 | editor. It will execute its contents with execfile() when you exit, | |
1706 | loading any code in the file into your interactive namespace. |
|
1723 | loading any code in the file into your interactive namespace. | |
1707 |
|
1724 | |||
1708 | After executing your code, %edit will return as output the code you |
|
1725 | After executing your code, %edit will return as output the code you | |
1709 | typed in the editor (except when it was an existing file). This way |
|
1726 | typed in the editor (except when it was an existing file). This way | |
1710 | you can reload the code in further invocations of %edit as a variable, |
|
1727 | you can reload the code in further invocations of %edit as a variable, | |
1711 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of |
|
1728 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of | |
1712 | the output. |
|
1729 | the output. | |
1713 |
|
1730 | |||
1714 | Note that %edit is also available through the alias %ed. |
|
1731 | Note that %edit is also available through the alias %ed. | |
1715 |
|
1732 | |||
1716 | This is an example of creating a simple function inside the editor and |
|
1733 | This is an example of creating a simple function inside the editor and | |
1717 | then modifying it. First, start up the editor: |
|
1734 | then modifying it. First, start up the editor: | |
1718 |
|
1735 | |||
1719 | In [1]: ed\\ |
|
1736 | In [1]: ed\\ | |
1720 | Editing... done. Executing edited code...\\ |
|
1737 | Editing... done. Executing edited code...\\ | |
1721 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' |
|
1738 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' | |
1722 |
|
1739 | |||
1723 | We can then call the function foo(): |
|
1740 | We can then call the function foo(): | |
1724 |
|
1741 | |||
1725 | In [2]: foo()\\ |
|
1742 | In [2]: foo()\\ | |
1726 | foo() was defined in an editing session |
|
1743 | foo() was defined in an editing session | |
1727 |
|
1744 | |||
1728 | Now we edit foo. IPython automatically loads the editor with the |
|
1745 | Now we edit foo. IPython automatically loads the editor with the | |
1729 | (temporary) file where foo() was previously defined: |
|
1746 | (temporary) file where foo() was previously defined: | |
1730 |
|
1747 | |||
1731 | In [3]: ed foo\\ |
|
1748 | In [3]: ed foo\\ | |
1732 | Editing... done. Executing edited code... |
|
1749 | Editing... done. Executing edited code... | |
1733 |
|
1750 | |||
1734 | And if we call foo() again we get the modified version: |
|
1751 | And if we call foo() again we get the modified version: | |
1735 |
|
1752 | |||
1736 | In [4]: foo()\\ |
|
1753 | In [4]: foo()\\ | |
1737 | foo() has now been changed! |
|
1754 | foo() has now been changed! | |
1738 |
|
1755 | |||
1739 | Here is an example of how to edit a code snippet successive |
|
1756 | Here is an example of how to edit a code snippet successive | |
1740 | times. First we call the editor: |
|
1757 | times. First we call the editor: | |
1741 |
|
1758 | |||
1742 | In [8]: ed\\ |
|
1759 | In [8]: ed\\ | |
1743 | Editing... done. Executing edited code...\\ |
|
1760 | Editing... done. Executing edited code...\\ | |
1744 | hello\\ |
|
1761 | hello\\ | |
1745 | Out[8]: "print 'hello'\\n" |
|
1762 | Out[8]: "print 'hello'\\n" | |
1746 |
|
1763 | |||
1747 | Now we call it again with the previous output (stored in _): |
|
1764 | Now we call it again with the previous output (stored in _): | |
1748 |
|
1765 | |||
1749 | In [9]: ed _\\ |
|
1766 | In [9]: ed _\\ | |
1750 | Editing... done. Executing edited code...\\ |
|
1767 | Editing... done. Executing edited code...\\ | |
1751 | hello world\\ |
|
1768 | hello world\\ | |
1752 | Out[9]: "print 'hello world'\\n" |
|
1769 | Out[9]: "print 'hello world'\\n" | |
1753 |
|
1770 | |||
1754 | Now we call it with the output #8 (stored in _8, also as Out[8]): |
|
1771 | Now we call it with the output #8 (stored in _8, also as Out[8]): | |
1755 |
|
1772 | |||
1756 | In [10]: ed _8\\ |
|
1773 | In [10]: ed _8\\ | |
1757 | Editing... done. Executing edited code...\\ |
|
1774 | Editing... done. Executing edited code...\\ | |
1758 | hello again\\ |
|
1775 | hello again\\ | |
1759 | Out[10]: "print 'hello again'\\n" |
|
1776 | Out[10]: "print 'hello again'\\n" | |
1760 |
|
1777 | |||
1761 |
|
1778 | |||
1762 | Changing the default editor hook: |
|
1779 | Changing the default editor hook: | |
1763 |
|
1780 | |||
1764 | If you wish to write your own editor hook, you can put it in a |
|
1781 | If you wish to write your own editor hook, you can put it in a | |
1765 | configuration file which you load at startup time. The default hook |
|
1782 | configuration file which you load at startup time. The default hook | |
1766 | is defined in the IPython.hooks module, and you can use that as a |
|
1783 | is defined in the IPython.hooks module, and you can use that as a | |
1767 | starting example for further modifications. That file also has |
|
1784 | starting example for further modifications. That file also has | |
1768 | general instructions on how to set a new hook for use once you've |
|
1785 | general instructions on how to set a new hook for use once you've | |
1769 | defined it.""" |
|
1786 | defined it.""" | |
1770 |
|
1787 | |||
1771 | # FIXME: This function has become a convoluted mess. It needs a |
|
1788 | # FIXME: This function has become a convoluted mess. It needs a | |
1772 | # ground-up rewrite with clean, simple logic. |
|
1789 | # ground-up rewrite with clean, simple logic. | |
1773 |
|
1790 | |||
1774 | def make_filename(arg): |
|
1791 | def make_filename(arg): | |
1775 | "Make a filename from the given args" |
|
1792 | "Make a filename from the given args" | |
1776 | try: |
|
1793 | try: | |
1777 | filename = get_py_filename(arg) |
|
1794 | filename = get_py_filename(arg) | |
1778 | except IOError: |
|
1795 | except IOError: | |
1779 | if args.endswith('.py'): |
|
1796 | if args.endswith('.py'): | |
1780 | filename = arg |
|
1797 | filename = arg | |
1781 | else: |
|
1798 | else: | |
1782 | filename = None |
|
1799 | filename = None | |
1783 | return filename |
|
1800 | return filename | |
1784 |
|
1801 | |||
1785 | # custom exceptions |
|
1802 | # custom exceptions | |
1786 | class DataIsObject(Exception): pass |
|
1803 | class DataIsObject(Exception): pass | |
1787 |
|
1804 | |||
1788 | opts,args = self.parse_options(parameter_s,'px') |
|
1805 | opts,args = self.parse_options(parameter_s,'px') | |
1789 |
|
1806 | |||
1790 | # Default line number value |
|
1807 | # Default line number value | |
1791 | lineno = None |
|
1808 | lineno = None | |
1792 | if opts.has_key('p'): |
|
1809 | if opts.has_key('p'): | |
1793 | args = '_%s' % last_call[0] |
|
1810 | args = '_%s' % last_call[0] | |
1794 | if not self.shell.user_ns.has_key(args): |
|
1811 | if not self.shell.user_ns.has_key(args): | |
1795 | args = last_call[1] |
|
1812 | args = last_call[1] | |
1796 |
|
1813 | |||
1797 | # use last_call to remember the state of the previous call, but don't |
|
1814 | # use last_call to remember the state of the previous call, but don't | |
1798 | # let it be clobbered by successive '-p' calls. |
|
1815 | # let it be clobbered by successive '-p' calls. | |
1799 | try: |
|
1816 | try: | |
1800 | last_call[0] = self.shell.outputcache.prompt_count |
|
1817 | last_call[0] = self.shell.outputcache.prompt_count | |
1801 | if not opts.has_key('p'): |
|
1818 | if not opts.has_key('p'): | |
1802 | last_call[1] = parameter_s |
|
1819 | last_call[1] = parameter_s | |
1803 | except: |
|
1820 | except: | |
1804 | pass |
|
1821 | pass | |
1805 |
|
1822 | |||
1806 | # by default this is done with temp files, except when the given |
|
1823 | # by default this is done with temp files, except when the given | |
1807 | # arg is a filename |
|
1824 | # arg is a filename | |
1808 | use_temp = 1 |
|
1825 | use_temp = 1 | |
1809 |
|
1826 | |||
1810 | if re.match(r'\d',args): |
|
1827 | if re.match(r'\d',args): | |
1811 | # Mode where user specifies ranges of lines, like in %macro. |
|
1828 | # Mode where user specifies ranges of lines, like in %macro. | |
1812 | # This means that you can't edit files whose names begin with |
|
1829 | # This means that you can't edit files whose names begin with | |
1813 | # numbers this way. Tough. |
|
1830 | # numbers this way. Tough. | |
1814 | ranges = args.split() |
|
1831 | ranges = args.split() | |
1815 | data = ''.join(self.extract_input_slices(ranges)) |
|
1832 | data = ''.join(self.extract_input_slices(ranges)) | |
1816 | elif args.endswith('.py'): |
|
1833 | elif args.endswith('.py'): | |
1817 | filename = make_filename(args) |
|
1834 | filename = make_filename(args) | |
1818 | data = '' |
|
1835 | data = '' | |
1819 | use_temp = 0 |
|
1836 | use_temp = 0 | |
1820 | elif args: |
|
1837 | elif args: | |
1821 | try: |
|
1838 | try: | |
1822 | # Load the parameter given as a variable. If not a string, |
|
1839 | # Load the parameter given as a variable. If not a string, | |
1823 | # process it as an object instead (below) |
|
1840 | # process it as an object instead (below) | |
1824 |
|
1841 | |||
1825 | #print '*** args',args,'type',type(args) # dbg |
|
1842 | #print '*** args',args,'type',type(args) # dbg | |
1826 | data = eval(args,self.shell.user_ns) |
|
1843 | data = eval(args,self.shell.user_ns) | |
1827 | if not type(data) in StringTypes: |
|
1844 | if not type(data) in StringTypes: | |
1828 | raise DataIsObject |
|
1845 | raise DataIsObject | |
|
1846 | ||||
1829 | except (NameError,SyntaxError): |
|
1847 | except (NameError,SyntaxError): | |
1830 | # given argument is not a variable, try as a filename |
|
1848 | # given argument is not a variable, try as a filename | |
1831 | filename = make_filename(args) |
|
1849 | filename = make_filename(args) | |
1832 | if filename is None: |
|
1850 | if filename is None: | |
1833 | warn("Argument given (%s) can't be found as a variable " |
|
1851 | warn("Argument given (%s) can't be found as a variable " | |
1834 | "or as a filename." % args) |
|
1852 | "or as a filename." % args) | |
1835 | return |
|
1853 | return | |
|
1854 | ||||
1836 | data = '' |
|
1855 | data = '' | |
1837 | use_temp = 0 |
|
1856 | use_temp = 0 | |
1838 | except DataIsObject: |
|
1857 | except DataIsObject: | |
|
1858 | ||||
|
1859 | # macros have a special edit function | |||
|
1860 | if isinstance(data,Macro): | |||
|
1861 | self._edit_macro(args,data) | |||
|
1862 | return | |||
|
1863 | ||||
1839 | # For objects, try to edit the file where they are defined |
|
1864 | # For objects, try to edit the file where they are defined | |
1840 | try: |
|
1865 | try: | |
1841 | filename = inspect.getabsfile(data) |
|
1866 | filename = inspect.getabsfile(data) | |
1842 | datafile = 1 |
|
1867 | datafile = 1 | |
1843 | except TypeError: |
|
1868 | except TypeError: | |
1844 | filename = make_filename(args) |
|
1869 | filename = make_filename(args) | |
1845 | datafile = 1 |
|
1870 | datafile = 1 | |
1846 | warn('Could not find file where `%s` is defined.\n' |
|
1871 | warn('Could not find file where `%s` is defined.\n' | |
1847 | 'Opening a file named `%s`' % (args,filename)) |
|
1872 | 'Opening a file named `%s`' % (args,filename)) | |
1848 | # Now, make sure we can actually read the source (if it was in |
|
1873 | # Now, make sure we can actually read the source (if it was in | |
1849 | # a temp file it's gone by now). |
|
1874 | # a temp file it's gone by now). | |
1850 | if datafile: |
|
1875 | if datafile: | |
1851 | try: |
|
1876 | try: | |
1852 | lineno = inspect.getsourcelines(data)[1] |
|
1877 | lineno = inspect.getsourcelines(data)[1] | |
1853 | except IOError: |
|
1878 | except IOError: | |
1854 | filename = make_filename(args) |
|
1879 | filename = make_filename(args) | |
1855 | if filename is None: |
|
1880 | if filename is None: | |
1856 | warn('The file `%s` where `%s` was defined cannot ' |
|
1881 | warn('The file `%s` where `%s` was defined cannot ' | |
1857 | 'be read.' % (filename,data)) |
|
1882 | 'be read.' % (filename,data)) | |
1858 | return |
|
1883 | return | |
1859 | use_temp = 0 |
|
1884 | use_temp = 0 | |
1860 | else: |
|
1885 | else: | |
1861 | data = '' |
|
1886 | data = '' | |
1862 |
|
1887 | |||
1863 | if use_temp: |
|
1888 | if use_temp: | |
1864 |
filename = |
|
1889 | filename = self.shell.mktempfile(data) | |
1865 | self.shell.tempfiles.append(filename) |
|
|||
1866 |
|
||||
1867 | if data and use_temp: |
|
|||
1868 | tmp_file = open(filename,'w') |
|
|||
1869 | tmp_file.write(data) |
|
|||
1870 | tmp_file.close() |
|
|||
1871 |
|
1890 | |||
1872 | # do actual editing here |
|
1891 | # do actual editing here | |
1873 | print 'Editing...', |
|
1892 | print 'Editing...', | |
1874 | sys.stdout.flush() |
|
1893 | sys.stdout.flush() | |
1875 | self.shell.hooks.editor(filename,lineno) |
|
1894 | self.shell.hooks.editor(filename,lineno) | |
1876 | if opts.has_key('x'): # -x prevents actual execution |
|
1895 | if opts.has_key('x'): # -x prevents actual execution | |
1877 |
|
1896 | |||
1878 | else: |
|
1897 | else: | |
1879 | print 'done. Executing edited code...' |
|
1898 | print 'done. Executing edited code...' | |
1880 | try: |
|
1899 | try: | |
1881 | self.shell.safe_execfile(filename,self.shell.user_ns) |
|
1900 | self.shell.safe_execfile(filename,self.shell.user_ns) | |
1882 | except IOError,msg: |
|
1901 | except IOError,msg: | |
1883 | if msg.filename == filename: |
|
1902 | if msg.filename == filename: | |
1884 | warn('File not found. Did you forget to save?') |
|
1903 | warn('File not found. Did you forget to save?') | |
1885 | return |
|
1904 | return | |
1886 | else: |
|
1905 | else: | |
1887 | self.shell.showtraceback() |
|
1906 | self.shell.showtraceback() | |
1888 | except: |
|
1907 | except: | |
1889 | self.shell.showtraceback() |
|
1908 | self.shell.showtraceback() | |
1890 | if use_temp: |
|
|||
1891 | contents = open(filename).read() |
|
|||
1892 | return contents |
|
|||
1893 |
|
1909 | |||
1894 | def magic_xmode(self,parameter_s = ''): |
|
1910 | def magic_xmode(self,parameter_s = ''): | |
1895 | """Switch modes for the exception handlers. |
|
1911 | """Switch modes for the exception handlers. | |
1896 |
|
1912 | |||
1897 | Valid modes: Plain, Context and Verbose. |
|
1913 | Valid modes: Plain, Context and Verbose. | |
1898 |
|
1914 | |||
1899 | If called without arguments, acts as a toggle.""" |
|
1915 | If called without arguments, acts as a toggle.""" | |
1900 |
|
1916 | |||
1901 | def xmode_switch_err(name): |
|
1917 | def xmode_switch_err(name): | |
1902 | warn('Error changing %s exception modes.\n%s' % |
|
1918 | warn('Error changing %s exception modes.\n%s' % | |
1903 | (name,sys.exc_info()[1])) |
|
1919 | (name,sys.exc_info()[1])) | |
1904 |
|
1920 | |||
1905 | shell = self.shell |
|
1921 | shell = self.shell | |
1906 | new_mode = parameter_s.strip().capitalize() |
|
1922 | new_mode = parameter_s.strip().capitalize() | |
1907 | try: |
|
1923 | try: | |
1908 | shell.InteractiveTB.set_mode(mode=new_mode) |
|
1924 | shell.InteractiveTB.set_mode(mode=new_mode) | |
1909 | print 'Exception reporting mode:',shell.InteractiveTB.mode |
|
1925 | print 'Exception reporting mode:',shell.InteractiveTB.mode | |
1910 | except: |
|
1926 | except: | |
1911 | xmode_switch_err('user') |
|
1927 | xmode_switch_err('user') | |
1912 |
|
1928 | |||
1913 | # threaded shells use a special handler in sys.excepthook |
|
1929 | # threaded shells use a special handler in sys.excepthook | |
1914 | if shell.isthreaded: |
|
1930 | if shell.isthreaded: | |
1915 | try: |
|
1931 | try: | |
1916 | shell.sys_excepthook.set_mode(mode=new_mode) |
|
1932 | shell.sys_excepthook.set_mode(mode=new_mode) | |
1917 | except: |
|
1933 | except: | |
1918 | xmode_switch_err('threaded') |
|
1934 | xmode_switch_err('threaded') | |
1919 |
|
1935 | |||
1920 | def magic_colors(self,parameter_s = ''): |
|
1936 | def magic_colors(self,parameter_s = ''): | |
1921 | """Switch color scheme for prompts, info system and exception handlers. |
|
1937 | """Switch color scheme for prompts, info system and exception handlers. | |
1922 |
|
1938 | |||
1923 | Currently implemented schemes: NoColor, Linux, LightBG. |
|
1939 | Currently implemented schemes: NoColor, Linux, LightBG. | |
1924 |
|
1940 | |||
1925 | Color scheme names are not case-sensitive.""" |
|
1941 | Color scheme names are not case-sensitive.""" | |
1926 |
|
1942 | |||
1927 | def color_switch_err(name): |
|
1943 | def color_switch_err(name): | |
1928 | warn('Error changing %s color schemes.\n%s' % |
|
1944 | warn('Error changing %s color schemes.\n%s' % | |
1929 | (name,sys.exc_info()[1])) |
|
1945 | (name,sys.exc_info()[1])) | |
1930 |
|
1946 | |||
1931 |
|
1947 | |||
1932 | new_scheme = parameter_s.strip() |
|
1948 | new_scheme = parameter_s.strip() | |
1933 | if not new_scheme: |
|
1949 | if not new_scheme: | |
1934 | print 'You must specify a color scheme.' |
|
1950 | print 'You must specify a color scheme.' | |
1935 | return |
|
1951 | return | |
1936 | # Under Windows, check for Gary Bishop's readline, which is necessary |
|
1952 | # Under Windows, check for Gary Bishop's readline, which is necessary | |
1937 | # for ANSI coloring |
|
1953 | # for ANSI coloring | |
1938 | if os.name in ['nt','dos']: |
|
1954 | if os.name in ['nt','dos']: | |
1939 | try: |
|
1955 | try: | |
1940 | import readline |
|
1956 | import readline | |
1941 | except ImportError: |
|
1957 | except ImportError: | |
1942 | has_readline = 0 |
|
1958 | has_readline = 0 | |
1943 | else: |
|
1959 | else: | |
1944 | try: |
|
1960 | try: | |
1945 | readline.GetOutputFile() |
|
1961 | readline.GetOutputFile() | |
1946 | except AttributeError: |
|
1962 | except AttributeError: | |
1947 | has_readline = 0 |
|
1963 | has_readline = 0 | |
1948 | else: |
|
1964 | else: | |
1949 | has_readline = 1 |
|
1965 | has_readline = 1 | |
1950 | if not has_readline: |
|
1966 | if not has_readline: | |
1951 | msg = """\ |
|
1967 | msg = """\ | |
1952 | Proper color support under MS Windows requires Gary Bishop's readline library. |
|
1968 | Proper color support under MS Windows requires Gary Bishop's readline library. | |
1953 | You can find it at: |
|
1969 | You can find it at: | |
1954 | http://sourceforge.net/projects/uncpythontools |
|
1970 | http://sourceforge.net/projects/uncpythontools | |
1955 | Gary's readline needs the ctypes module, from: |
|
1971 | Gary's readline needs the ctypes module, from: | |
1956 | http://starship.python.net/crew/theller/ctypes |
|
1972 | http://starship.python.net/crew/theller/ctypes | |
1957 |
|
1973 | |||
1958 | Defaulting color scheme to 'NoColor'""" |
|
1974 | Defaulting color scheme to 'NoColor'""" | |
1959 | new_scheme = 'NoColor' |
|
1975 | new_scheme = 'NoColor' | |
1960 | warn(msg) |
|
1976 | warn(msg) | |
1961 | # local shortcut |
|
1977 | # local shortcut | |
1962 | shell = self.shell |
|
1978 | shell = self.shell | |
1963 |
|
1979 | |||
1964 | # Set prompt colors |
|
1980 | # Set prompt colors | |
1965 | try: |
|
1981 | try: | |
1966 | shell.outputcache.set_colors(new_scheme) |
|
1982 | shell.outputcache.set_colors(new_scheme) | |
1967 | except: |
|
1983 | except: | |
1968 | color_switch_err('prompt') |
|
1984 | color_switch_err('prompt') | |
1969 | else: |
|
1985 | else: | |
1970 | shell.rc.colors = \ |
|
1986 | shell.rc.colors = \ | |
1971 | shell.outputcache.color_table.active_scheme_name |
|
1987 | shell.outputcache.color_table.active_scheme_name | |
1972 | # Set exception colors |
|
1988 | # Set exception colors | |
1973 | try: |
|
1989 | try: | |
1974 | shell.InteractiveTB.set_colors(scheme = new_scheme) |
|
1990 | shell.InteractiveTB.set_colors(scheme = new_scheme) | |
1975 | shell.SyntaxTB.set_colors(scheme = new_scheme) |
|
1991 | shell.SyntaxTB.set_colors(scheme = new_scheme) | |
1976 | except: |
|
1992 | except: | |
1977 | color_switch_err('exception') |
|
1993 | color_switch_err('exception') | |
1978 |
|
1994 | |||
1979 | # threaded shells use a verbose traceback in sys.excepthook |
|
1995 | # threaded shells use a verbose traceback in sys.excepthook | |
1980 | if shell.isthreaded: |
|
1996 | if shell.isthreaded: | |
1981 | try: |
|
1997 | try: | |
1982 | shell.sys_excepthook.set_colors(scheme=new_scheme) |
|
1998 | shell.sys_excepthook.set_colors(scheme=new_scheme) | |
1983 | except: |
|
1999 | except: | |
1984 | color_switch_err('system exception handler') |
|
2000 | color_switch_err('system exception handler') | |
1985 |
|
2001 | |||
1986 | # Set info (for 'object?') colors |
|
2002 | # Set info (for 'object?') colors | |
1987 | if shell.rc.color_info: |
|
2003 | if shell.rc.color_info: | |
1988 | try: |
|
2004 | try: | |
1989 | shell.inspector.set_active_scheme(new_scheme) |
|
2005 | shell.inspector.set_active_scheme(new_scheme) | |
1990 | except: |
|
2006 | except: | |
1991 | color_switch_err('object inspector') |
|
2007 | color_switch_err('object inspector') | |
1992 | else: |
|
2008 | else: | |
1993 | shell.inspector.set_active_scheme('NoColor') |
|
2009 | shell.inspector.set_active_scheme('NoColor') | |
1994 |
|
2010 | |||
1995 | def magic_color_info(self,parameter_s = ''): |
|
2011 | def magic_color_info(self,parameter_s = ''): | |
1996 | """Toggle color_info. |
|
2012 | """Toggle color_info. | |
1997 |
|
2013 | |||
1998 | The color_info configuration parameter controls whether colors are |
|
2014 | The color_info configuration parameter controls whether colors are | |
1999 | used for displaying object details (by things like %psource, %pfile or |
|
2015 | used for displaying object details (by things like %psource, %pfile or | |
2000 | the '?' system). This function toggles this value with each call. |
|
2016 | the '?' system). This function toggles this value with each call. | |
2001 |
|
2017 | |||
2002 | Note that unless you have a fairly recent pager (less works better |
|
2018 | Note that unless you have a fairly recent pager (less works better | |
2003 | than more) in your system, using colored object information displays |
|
2019 | than more) in your system, using colored object information displays | |
2004 | will not work properly. Test it and see.""" |
|
2020 | will not work properly. Test it and see.""" | |
2005 |
|
2021 | |||
2006 | self.shell.rc.color_info = 1 - self.shell.rc.color_info |
|
2022 | self.shell.rc.color_info = 1 - self.shell.rc.color_info | |
2007 | self.magic_colors(self.shell.rc.colors) |
|
2023 | self.magic_colors(self.shell.rc.colors) | |
2008 | print 'Object introspection functions have now coloring:', |
|
2024 | print 'Object introspection functions have now coloring:', | |
2009 | print ['OFF','ON'][self.shell.rc.color_info] |
|
2025 | print ['OFF','ON'][self.shell.rc.color_info] | |
2010 |
|
2026 | |||
2011 | def magic_Pprint(self, parameter_s=''): |
|
2027 | def magic_Pprint(self, parameter_s=''): | |
2012 | """Toggle pretty printing on/off.""" |
|
2028 | """Toggle pretty printing on/off.""" | |
2013 |
|
2029 | |||
2014 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint |
|
2030 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint | |
2015 | print 'Pretty printing has been turned', \ |
|
2031 | print 'Pretty printing has been turned', \ | |
2016 | ['OFF','ON'][self.shell.outputcache.Pprint] |
|
2032 | ['OFF','ON'][self.shell.outputcache.Pprint] | |
2017 |
|
2033 | |||
2018 | def magic_exit(self, parameter_s=''): |
|
2034 | def magic_exit(self, parameter_s=''): | |
2019 | """Exit IPython, confirming if configured to do so. |
|
2035 | """Exit IPython, confirming if configured to do so. | |
2020 |
|
2036 | |||
2021 | You can configure whether IPython asks for confirmation upon exit by |
|
2037 | You can configure whether IPython asks for confirmation upon exit by | |
2022 | setting the confirm_exit flag in the ipythonrc file.""" |
|
2038 | setting the confirm_exit flag in the ipythonrc file.""" | |
2023 |
|
2039 | |||
2024 | self.shell.exit() |
|
2040 | self.shell.exit() | |
2025 |
|
2041 | |||
2026 | def magic_quit(self, parameter_s=''): |
|
2042 | def magic_quit(self, parameter_s=''): | |
2027 | """Exit IPython, confirming if configured to do so (like %exit)""" |
|
2043 | """Exit IPython, confirming if configured to do so (like %exit)""" | |
2028 |
|
2044 | |||
2029 | self.shell.exit() |
|
2045 | self.shell.exit() | |
2030 |
|
2046 | |||
2031 | def magic_Exit(self, parameter_s=''): |
|
2047 | def magic_Exit(self, parameter_s=''): | |
2032 | """Exit IPython without confirmation.""" |
|
2048 | """Exit IPython without confirmation.""" | |
2033 |
|
2049 | |||
2034 | self.shell.exit_now = True |
|
2050 | self.shell.exit_now = True | |
2035 |
|
2051 | |||
2036 | def magic_Quit(self, parameter_s=''): |
|
2052 | def magic_Quit(self, parameter_s=''): | |
2037 | """Exit IPython without confirmation (like %Exit).""" |
|
2053 | """Exit IPython without confirmation (like %Exit).""" | |
2038 |
|
2054 | |||
2039 | self.shell.exit_now = True |
|
2055 | self.shell.exit_now = True | |
2040 |
|
2056 | |||
2041 | #...................................................................... |
|
2057 | #...................................................................... | |
2042 | # Functions to implement unix shell-type things |
|
2058 | # Functions to implement unix shell-type things | |
2043 |
|
2059 | |||
2044 | def magic_alias(self, parameter_s = ''): |
|
2060 | def magic_alias(self, parameter_s = ''): | |
2045 | """Define an alias for a system command. |
|
2061 | """Define an alias for a system command. | |
2046 |
|
2062 | |||
2047 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' |
|
2063 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' | |
2048 |
|
2064 | |||
2049 | Then, typing 'alias_name params' will execute the system command 'cmd |
|
2065 | Then, typing 'alias_name params' will execute the system command 'cmd | |
2050 | params' (from your underlying operating system). |
|
2066 | params' (from your underlying operating system). | |
2051 |
|
2067 | |||
2052 | Aliases have lower precedence than magic functions and Python normal |
|
2068 | Aliases have lower precedence than magic functions and Python normal | |
2053 | variables, so if 'foo' is both a Python variable and an alias, the |
|
2069 | variables, so if 'foo' is both a Python variable and an alias, the | |
2054 | alias can not be executed until 'del foo' removes the Python variable. |
|
2070 | alias can not be executed until 'del foo' removes the Python variable. | |
2055 |
|
2071 | |||
2056 | You can use the %l specifier in an alias definition to represent the |
|
2072 | You can use the %l specifier in an alias definition to represent the | |
2057 | whole line when the alias is called. For example: |
|
2073 | whole line when the alias is called. For example: | |
2058 |
|
2074 | |||
2059 | In [2]: alias all echo "Input in brackets: <%l>"\\ |
|
2075 | In [2]: alias all echo "Input in brackets: <%l>"\\ | |
2060 | In [3]: all hello world\\ |
|
2076 | In [3]: all hello world\\ | |
2061 | Input in brackets: <hello world> |
|
2077 | Input in brackets: <hello world> | |
2062 |
|
2078 | |||
2063 | You can also define aliases with parameters using %s specifiers (one |
|
2079 | You can also define aliases with parameters using %s specifiers (one | |
2064 | per parameter): |
|
2080 | per parameter): | |
2065 |
|
2081 | |||
2066 | In [1]: alias parts echo first %s second %s\\ |
|
2082 | In [1]: alias parts echo first %s second %s\\ | |
2067 | In [2]: %parts A B\\ |
|
2083 | In [2]: %parts A B\\ | |
2068 | first A second B\\ |
|
2084 | first A second B\\ | |
2069 | In [3]: %parts A\\ |
|
2085 | In [3]: %parts A\\ | |
2070 | Incorrect number of arguments: 2 expected.\\ |
|
2086 | Incorrect number of arguments: 2 expected.\\ | |
2071 | parts is an alias to: 'echo first %s second %s' |
|
2087 | parts is an alias to: 'echo first %s second %s' | |
2072 |
|
2088 | |||
2073 | Note that %l and %s are mutually exclusive. You can only use one or |
|
2089 | Note that %l and %s are mutually exclusive. You can only use one or | |
2074 | the other in your aliases. |
|
2090 | the other in your aliases. | |
2075 |
|
2091 | |||
2076 | Aliases expand Python variables just like system calls using ! or !! |
|
2092 | Aliases expand Python variables just like system calls using ! or !! | |
2077 | do: all expressions prefixed with '$' get expanded. For details of |
|
2093 | do: all expressions prefixed with '$' get expanded. For details of | |
2078 | the semantic rules, see PEP-215: |
|
2094 | the semantic rules, see PEP-215: | |
2079 | http://www.python.org/peps/pep-0215.html. This is the library used by |
|
2095 | http://www.python.org/peps/pep-0215.html. This is the library used by | |
2080 | IPython for variable expansion. If you want to access a true shell |
|
2096 | IPython for variable expansion. If you want to access a true shell | |
2081 | variable, an extra $ is necessary to prevent its expansion by IPython: |
|
2097 | variable, an extra $ is necessary to prevent its expansion by IPython: | |
2082 |
|
2098 | |||
2083 | In [6]: alias show echo\\ |
|
2099 | In [6]: alias show echo\\ | |
2084 | In [7]: PATH='A Python string'\\ |
|
2100 | In [7]: PATH='A Python string'\\ | |
2085 | In [8]: show $PATH\\ |
|
2101 | In [8]: show $PATH\\ | |
2086 | A Python string\\ |
|
2102 | A Python string\\ | |
2087 | In [9]: show $$PATH\\ |
|
2103 | In [9]: show $$PATH\\ | |
2088 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2104 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2089 |
|
2105 | |||
2090 | You can use the alias facility to acess all of $PATH. See the %rehash |
|
2106 | You can use the alias facility to acess all of $PATH. See the %rehash | |
2091 | and %rehashx functions, which automatically create aliases for the |
|
2107 | and %rehashx functions, which automatically create aliases for the | |
2092 | contents of your $PATH. |
|
2108 | contents of your $PATH. | |
2093 |
|
2109 | |||
2094 | If called with no parameters, %alias prints the current alias table.""" |
|
2110 | If called with no parameters, %alias prints the current alias table.""" | |
2095 |
|
2111 | |||
2096 | par = parameter_s.strip() |
|
2112 | par = parameter_s.strip() | |
2097 | if not par: |
|
2113 | if not par: | |
2098 | if self.shell.rc.automagic: |
|
2114 | if self.shell.rc.automagic: | |
2099 | prechar = '' |
|
2115 | prechar = '' | |
2100 | else: |
|
2116 | else: | |
2101 | prechar = self.shell.ESC_MAGIC |
|
2117 | prechar = self.shell.ESC_MAGIC | |
2102 | print 'Alias\t\tSystem Command\n'+'-'*30 |
|
2118 | print 'Alias\t\tSystem Command\n'+'-'*30 | |
2103 | atab = self.shell.alias_table |
|
2119 | atab = self.shell.alias_table | |
2104 | aliases = atab.keys() |
|
2120 | aliases = atab.keys() | |
2105 | aliases.sort() |
|
2121 | aliases.sort() | |
2106 | for alias in aliases: |
|
2122 | for alias in aliases: | |
2107 | print prechar+alias+'\t\t'+atab[alias][1] |
|
2123 | print prechar+alias+'\t\t'+atab[alias][1] | |
2108 | print '-'*30+'\nTotal number of aliases:',len(aliases) |
|
2124 | print '-'*30+'\nTotal number of aliases:',len(aliases) | |
2109 | return |
|
2125 | return | |
2110 | try: |
|
2126 | try: | |
2111 | alias,cmd = par.split(None,1) |
|
2127 | alias,cmd = par.split(None,1) | |
2112 | except: |
|
2128 | except: | |
2113 | print OInspect.getdoc(self.magic_alias) |
|
2129 | print OInspect.getdoc(self.magic_alias) | |
2114 | else: |
|
2130 | else: | |
2115 | nargs = cmd.count('%s') |
|
2131 | nargs = cmd.count('%s') | |
2116 | if nargs>0 and cmd.find('%l')>=0: |
|
2132 | if nargs>0 and cmd.find('%l')>=0: | |
2117 | error('The %s and %l specifiers are mutually exclusive ' |
|
2133 | error('The %s and %l specifiers are mutually exclusive ' | |
2118 | 'in alias definitions.') |
|
2134 | 'in alias definitions.') | |
2119 | else: # all looks OK |
|
2135 | else: # all looks OK | |
2120 | self.shell.alias_table[alias] = (nargs,cmd) |
|
2136 | self.shell.alias_table[alias] = (nargs,cmd) | |
2121 | self.shell.alias_table_validate(verbose=1) |
|
2137 | self.shell.alias_table_validate(verbose=1) | |
2122 | # end magic_alias |
|
2138 | # end magic_alias | |
2123 |
|
2139 | |||
2124 | def magic_unalias(self, parameter_s = ''): |
|
2140 | def magic_unalias(self, parameter_s = ''): | |
2125 | """Remove an alias""" |
|
2141 | """Remove an alias""" | |
2126 |
|
2142 | |||
2127 | aname = parameter_s.strip() |
|
2143 | aname = parameter_s.strip() | |
2128 | if aname in self.shell.alias_table: |
|
2144 | if aname in self.shell.alias_table: | |
2129 | del self.shell.alias_table[aname] |
|
2145 | del self.shell.alias_table[aname] | |
2130 |
|
2146 | |||
2131 | def magic_rehash(self, parameter_s = ''): |
|
2147 | def magic_rehash(self, parameter_s = ''): | |
2132 | """Update the alias table with all entries in $PATH. |
|
2148 | """Update the alias table with all entries in $PATH. | |
2133 |
|
2149 | |||
2134 | This version does no checks on execute permissions or whether the |
|
2150 | This version does no checks on execute permissions or whether the | |
2135 | contents of $PATH are truly files (instead of directories or something |
|
2151 | contents of $PATH are truly files (instead of directories or something | |
2136 | else). For such a safer (but slower) version, use %rehashx.""" |
|
2152 | else). For such a safer (but slower) version, use %rehashx.""" | |
2137 |
|
2153 | |||
2138 | # This function (and rehashx) manipulate the alias_table directly |
|
2154 | # This function (and rehashx) manipulate the alias_table directly | |
2139 | # rather than calling magic_alias, for speed reasons. A rehash on a |
|
2155 | # rather than calling magic_alias, for speed reasons. A rehash on a | |
2140 | # typical Linux box involves several thousand entries, so efficiency |
|
2156 | # typical Linux box involves several thousand entries, so efficiency | |
2141 | # here is a top concern. |
|
2157 | # here is a top concern. | |
2142 |
|
2158 | |||
2143 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2159 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2144 | alias_table = self.shell.alias_table |
|
2160 | alias_table = self.shell.alias_table | |
2145 | for pdir in path: |
|
2161 | for pdir in path: | |
2146 | for ff in os.listdir(pdir): |
|
2162 | for ff in os.listdir(pdir): | |
2147 | # each entry in the alias table must be (N,name), where |
|
2163 | # each entry in the alias table must be (N,name), where | |
2148 | # N is the number of positional arguments of the alias. |
|
2164 | # N is the number of positional arguments of the alias. | |
2149 | alias_table[ff] = (0,ff) |
|
2165 | alias_table[ff] = (0,ff) | |
2150 | # Make sure the alias table doesn't contain keywords or builtins |
|
2166 | # Make sure the alias table doesn't contain keywords or builtins | |
2151 | self.shell.alias_table_validate() |
|
2167 | self.shell.alias_table_validate() | |
2152 | # Call again init_auto_alias() so we get 'rm -i' and other modified |
|
2168 | # Call again init_auto_alias() so we get 'rm -i' and other modified | |
2153 | # aliases since %rehash will probably clobber them |
|
2169 | # aliases since %rehash will probably clobber them | |
2154 | self.shell.init_auto_alias() |
|
2170 | self.shell.init_auto_alias() | |
2155 |
|
2171 | |||
2156 | def magic_rehashx(self, parameter_s = ''): |
|
2172 | def magic_rehashx(self, parameter_s = ''): | |
2157 | """Update the alias table with all executable files in $PATH. |
|
2173 | """Update the alias table with all executable files in $PATH. | |
2158 |
|
2174 | |||
2159 | This version explicitly checks that every entry in $PATH is a file |
|
2175 | This version explicitly checks that every entry in $PATH is a file | |
2160 | with execute access (os.X_OK), so it is much slower than %rehash. |
|
2176 | with execute access (os.X_OK), so it is much slower than %rehash. | |
2161 |
|
2177 | |||
2162 | Under Windows, it checks executability as a match agains a |
|
2178 | Under Windows, it checks executability as a match agains a | |
2163 | '|'-separated string of extensions, stored in the IPython config |
|
2179 | '|'-separated string of extensions, stored in the IPython config | |
2164 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ |
|
2180 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ | |
2165 |
|
2181 | |||
2166 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2182 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2167 | alias_table = self.shell.alias_table |
|
2183 | alias_table = self.shell.alias_table | |
2168 |
|
2184 | |||
2169 | if os.name == 'posix': |
|
2185 | if os.name == 'posix': | |
2170 | isexec = lambda fname:os.path.isfile(fname) and \ |
|
2186 | isexec = lambda fname:os.path.isfile(fname) and \ | |
2171 | os.access(fname,os.X_OK) |
|
2187 | os.access(fname,os.X_OK) | |
2172 | else: |
|
2188 | else: | |
2173 |
|
2189 | |||
2174 | try: |
|
2190 | try: | |
2175 | winext = os.environ['pathext'].replace(';','|').replace('.','') |
|
2191 | winext = os.environ['pathext'].replace(';','|').replace('.','') | |
2176 | except KeyError: |
|
2192 | except KeyError: | |
2177 | winext = 'exe|com|bat' |
|
2193 | winext = 'exe|com|bat' | |
2178 |
|
2194 | |||
2179 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) |
|
2195 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) | |
2180 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) |
|
2196 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) | |
2181 | savedir = os.getcwd() |
|
2197 | savedir = os.getcwd() | |
2182 | try: |
|
2198 | try: | |
2183 | # write the whole loop for posix/Windows so we don't have an if in |
|
2199 | # write the whole loop for posix/Windows so we don't have an if in | |
2184 | # the innermost part |
|
2200 | # the innermost part | |
2185 | if os.name == 'posix': |
|
2201 | if os.name == 'posix': | |
2186 | for pdir in path: |
|
2202 | for pdir in path: | |
2187 | os.chdir(pdir) |
|
2203 | os.chdir(pdir) | |
2188 | for ff in os.listdir(pdir): |
|
2204 | for ff in os.listdir(pdir): | |
2189 | if isexec(ff): |
|
2205 | if isexec(ff): | |
2190 | # each entry in the alias table must be (N,name), |
|
2206 | # each entry in the alias table must be (N,name), | |
2191 | # where N is the number of positional arguments of the |
|
2207 | # where N is the number of positional arguments of the | |
2192 | # alias. |
|
2208 | # alias. | |
2193 | alias_table[ff] = (0,ff) |
|
2209 | alias_table[ff] = (0,ff) | |
2194 | else: |
|
2210 | else: | |
2195 | for pdir in path: |
|
2211 | for pdir in path: | |
2196 | os.chdir(pdir) |
|
2212 | os.chdir(pdir) | |
2197 | for ff in os.listdir(pdir): |
|
2213 | for ff in os.listdir(pdir): | |
2198 | if isexec(ff): |
|
2214 | if isexec(ff): | |
2199 | alias_table[execre.sub(r'\1',ff)] = (0,ff) |
|
2215 | alias_table[execre.sub(r'\1',ff)] = (0,ff) | |
2200 | # Make sure the alias table doesn't contain keywords or builtins |
|
2216 | # Make sure the alias table doesn't contain keywords or builtins | |
2201 | self.shell.alias_table_validate() |
|
2217 | self.shell.alias_table_validate() | |
2202 | # Call again init_auto_alias() so we get 'rm -i' and other |
|
2218 | # Call again init_auto_alias() so we get 'rm -i' and other | |
2203 | # modified aliases since %rehashx will probably clobber them |
|
2219 | # modified aliases since %rehashx will probably clobber them | |
2204 | self.shell.init_auto_alias() |
|
2220 | self.shell.init_auto_alias() | |
2205 | finally: |
|
2221 | finally: | |
2206 | os.chdir(savedir) |
|
2222 | os.chdir(savedir) | |
2207 |
|
2223 | |||
2208 | def magic_pwd(self, parameter_s = ''): |
|
2224 | def magic_pwd(self, parameter_s = ''): | |
2209 | """Return the current working directory path.""" |
|
2225 | """Return the current working directory path.""" | |
2210 | return os.getcwd() |
|
2226 | return os.getcwd() | |
2211 |
|
2227 | |||
2212 | def magic_cd(self, parameter_s=''): |
|
2228 | def magic_cd(self, parameter_s=''): | |
2213 | """Change the current working directory. |
|
2229 | """Change the current working directory. | |
2214 |
|
2230 | |||
2215 | This command automatically maintains an internal list of directories |
|
2231 | This command automatically maintains an internal list of directories | |
2216 | you visit during your IPython session, in the variable _dh. The |
|
2232 | you visit during your IPython session, in the variable _dh. The | |
2217 | command %dhist shows this history nicely formatted. |
|
2233 | command %dhist shows this history nicely formatted. | |
2218 |
|
2234 | |||
2219 | Usage: |
|
2235 | Usage: | |
2220 |
|
2236 | |||
2221 | cd 'dir': changes to directory 'dir'. |
|
2237 | cd 'dir': changes to directory 'dir'. | |
2222 |
|
2238 | |||
2223 | cd -: changes to the last visited directory. |
|
2239 | cd -: changes to the last visited directory. | |
2224 |
|
2240 | |||
2225 | cd -<n>: changes to the n-th directory in the directory history. |
|
2241 | cd -<n>: changes to the n-th directory in the directory history. | |
2226 |
|
2242 | |||
2227 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark |
|
2243 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark | |
2228 | (note: cd <bookmark_name> is enough if there is no |
|
2244 | (note: cd <bookmark_name> is enough if there is no | |
2229 | directory <bookmark_name>, but a bookmark with the name exists.) |
|
2245 | directory <bookmark_name>, but a bookmark with the name exists.) | |
2230 |
|
2246 | |||
2231 | Options: |
|
2247 | Options: | |
2232 |
|
2248 | |||
2233 | -q: quiet. Do not print the working directory after the cd command is |
|
2249 | -q: quiet. Do not print the working directory after the cd command is | |
2234 | executed. By default IPython's cd command does print this directory, |
|
2250 | executed. By default IPython's cd command does print this directory, | |
2235 | since the default prompts do not display path information. |
|
2251 | since the default prompts do not display path information. | |
2236 |
|
2252 | |||
2237 | Note that !cd doesn't work for this purpose because the shell where |
|
2253 | Note that !cd doesn't work for this purpose because the shell where | |
2238 | !command runs is immediately discarded after executing 'command'.""" |
|
2254 | !command runs is immediately discarded after executing 'command'.""" | |
2239 |
|
2255 | |||
2240 | parameter_s = parameter_s.strip() |
|
2256 | parameter_s = parameter_s.strip() | |
2241 | bkms = self.shell.persist.get("bookmarks",{}) |
|
2257 | bkms = self.shell.persist.get("bookmarks",{}) | |
2242 |
|
2258 | |||
2243 | numcd = re.match(r'(-)(\d+)$',parameter_s) |
|
2259 | numcd = re.match(r'(-)(\d+)$',parameter_s) | |
2244 | # jump in directory history by number |
|
2260 | # jump in directory history by number | |
2245 | if numcd: |
|
2261 | if numcd: | |
2246 | nn = int(numcd.group(2)) |
|
2262 | nn = int(numcd.group(2)) | |
2247 | try: |
|
2263 | try: | |
2248 | ps = self.shell.user_ns['_dh'][nn] |
|
2264 | ps = self.shell.user_ns['_dh'][nn] | |
2249 | except IndexError: |
|
2265 | except IndexError: | |
2250 | print 'The requested directory does not exist in history.' |
|
2266 | print 'The requested directory does not exist in history.' | |
2251 | return |
|
2267 | return | |
2252 | else: |
|
2268 | else: | |
2253 | opts = {} |
|
2269 | opts = {} | |
2254 | else: |
|
2270 | else: | |
2255 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') |
|
2271 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') | |
2256 | # jump to previous |
|
2272 | # jump to previous | |
2257 | if ps == '-': |
|
2273 | if ps == '-': | |
2258 | try: |
|
2274 | try: | |
2259 | ps = self.shell.user_ns['_dh'][-2] |
|
2275 | ps = self.shell.user_ns['_dh'][-2] | |
2260 | except IndexError: |
|
2276 | except IndexError: | |
2261 | print 'No previous directory to change to.' |
|
2277 | print 'No previous directory to change to.' | |
2262 | return |
|
2278 | return | |
2263 | # jump to bookmark |
|
2279 | # jump to bookmark | |
2264 | elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)): |
|
2280 | elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)): | |
2265 | if bkms.has_key(ps): |
|
2281 | if bkms.has_key(ps): | |
2266 | target = bkms[ps] |
|
2282 | target = bkms[ps] | |
2267 | print '(bookmark:%s) -> %s' % (ps,target) |
|
2283 | print '(bookmark:%s) -> %s' % (ps,target) | |
2268 | ps = target |
|
2284 | ps = target | |
2269 | else: |
|
2285 | else: | |
2270 | if bkms: |
|
2286 | if bkms: | |
2271 | error("Bookmark '%s' not found. " |
|
2287 | error("Bookmark '%s' not found. " | |
2272 | "Use '%bookmark -l' to see your bookmarks." % ps) |
|
2288 | "Use '%bookmark -l' to see your bookmarks." % ps) | |
2273 | else: |
|
2289 | else: | |
2274 | print "Bookmarks not set - use %bookmark <bookmarkname>" |
|
2290 | print "Bookmarks not set - use %bookmark <bookmarkname>" | |
2275 | return |
|
2291 | return | |
2276 |
|
2292 | |||
2277 | # at this point ps should point to the target dir |
|
2293 | # at this point ps should point to the target dir | |
2278 | if ps: |
|
2294 | if ps: | |
2279 | try: |
|
2295 | try: | |
2280 | os.chdir(os.path.expanduser(ps)) |
|
2296 | os.chdir(os.path.expanduser(ps)) | |
2281 | except OSError: |
|
2297 | except OSError: | |
2282 | print sys.exc_info()[1] |
|
2298 | print sys.exc_info()[1] | |
2283 | else: |
|
2299 | else: | |
2284 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2300 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2285 | else: |
|
2301 | else: | |
2286 | os.chdir(self.shell.home_dir) |
|
2302 | os.chdir(self.shell.home_dir) | |
2287 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2303 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2288 | if not 'q' in opts: |
|
2304 | if not 'q' in opts: | |
2289 | print self.shell.user_ns['_dh'][-1] |
|
2305 | print self.shell.user_ns['_dh'][-1] | |
2290 |
|
2306 | |||
2291 | def magic_dhist(self, parameter_s=''): |
|
2307 | def magic_dhist(self, parameter_s=''): | |
2292 | """Print your history of visited directories. |
|
2308 | """Print your history of visited directories. | |
2293 |
|
2309 | |||
2294 | %dhist -> print full history\\ |
|
2310 | %dhist -> print full history\\ | |
2295 | %dhist n -> print last n entries only\\ |
|
2311 | %dhist n -> print last n entries only\\ | |
2296 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ |
|
2312 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ | |
2297 |
|
2313 | |||
2298 | This history is automatically maintained by the %cd command, and |
|
2314 | This history is automatically maintained by the %cd command, and | |
2299 | always available as the global list variable _dh. You can use %cd -<n> |
|
2315 | always available as the global list variable _dh. You can use %cd -<n> | |
2300 | to go to directory number <n>.""" |
|
2316 | to go to directory number <n>.""" | |
2301 |
|
2317 | |||
2302 | dh = self.shell.user_ns['_dh'] |
|
2318 | dh = self.shell.user_ns['_dh'] | |
2303 | if parameter_s: |
|
2319 | if parameter_s: | |
2304 | try: |
|
2320 | try: | |
2305 | args = map(int,parameter_s.split()) |
|
2321 | args = map(int,parameter_s.split()) | |
2306 | except: |
|
2322 | except: | |
2307 | self.arg_err(Magic.magic_dhist) |
|
2323 | self.arg_err(Magic.magic_dhist) | |
2308 | return |
|
2324 | return | |
2309 | if len(args) == 1: |
|
2325 | if len(args) == 1: | |
2310 | ini,fin = max(len(dh)-(args[0]),0),len(dh) |
|
2326 | ini,fin = max(len(dh)-(args[0]),0),len(dh) | |
2311 | elif len(args) == 2: |
|
2327 | elif len(args) == 2: | |
2312 | ini,fin = args |
|
2328 | ini,fin = args | |
2313 | else: |
|
2329 | else: | |
2314 | self.arg_err(Magic.magic_dhist) |
|
2330 | self.arg_err(Magic.magic_dhist) | |
2315 | return |
|
2331 | return | |
2316 | else: |
|
2332 | else: | |
2317 | ini,fin = 0,len(dh) |
|
2333 | ini,fin = 0,len(dh) | |
2318 | nlprint(dh, |
|
2334 | nlprint(dh, | |
2319 | header = 'Directory history (kept in _dh)', |
|
2335 | header = 'Directory history (kept in _dh)', | |
2320 | start=ini,stop=fin) |
|
2336 | start=ini,stop=fin) | |
2321 |
|
2337 | |||
2322 | def magic_env(self, parameter_s=''): |
|
2338 | def magic_env(self, parameter_s=''): | |
2323 | """List environment variables.""" |
|
2339 | """List environment variables.""" | |
2324 |
|
2340 | |||
2325 | return os.environ.data |
|
2341 | return os.environ.data | |
2326 |
|
2342 | |||
2327 | def magic_pushd(self, parameter_s=''): |
|
2343 | def magic_pushd(self, parameter_s=''): | |
2328 | """Place the current dir on stack and change directory. |
|
2344 | """Place the current dir on stack and change directory. | |
2329 |
|
2345 | |||
2330 | Usage:\\ |
|
2346 | Usage:\\ | |
2331 | %pushd ['dirname'] |
|
2347 | %pushd ['dirname'] | |
2332 |
|
2348 | |||
2333 | %pushd with no arguments does a %pushd to your home directory. |
|
2349 | %pushd with no arguments does a %pushd to your home directory. | |
2334 | """ |
|
2350 | """ | |
2335 | if parameter_s == '': parameter_s = '~' |
|
2351 | if parameter_s == '': parameter_s = '~' | |
2336 | dir_s = self.shell.dir_stack |
|
2352 | dir_s = self.shell.dir_stack | |
2337 | if len(dir_s)>0 and os.path.expanduser(parameter_s) != \ |
|
2353 | if len(dir_s)>0 and os.path.expanduser(parameter_s) != \ | |
2338 | os.path.expanduser(self.shell.dir_stack[0]): |
|
2354 | os.path.expanduser(self.shell.dir_stack[0]): | |
2339 | try: |
|
2355 | try: | |
2340 | self.magic_cd(parameter_s) |
|
2356 | self.magic_cd(parameter_s) | |
2341 | dir_s.insert(0,os.getcwd().replace(self.home_dir,'~')) |
|
2357 | dir_s.insert(0,os.getcwd().replace(self.home_dir,'~')) | |
2342 | self.magic_dirs() |
|
2358 | self.magic_dirs() | |
2343 | except: |
|
2359 | except: | |
2344 | print 'Invalid directory' |
|
2360 | print 'Invalid directory' | |
2345 | else: |
|
2361 | else: | |
2346 | print 'You are already there!' |
|
2362 | print 'You are already there!' | |
2347 |
|
2363 | |||
2348 | def magic_popd(self, parameter_s=''): |
|
2364 | def magic_popd(self, parameter_s=''): | |
2349 | """Change to directory popped off the top of the stack. |
|
2365 | """Change to directory popped off the top of the stack. | |
2350 | """ |
|
2366 | """ | |
2351 | if len (self.shell.dir_stack) > 1: |
|
2367 | if len (self.shell.dir_stack) > 1: | |
2352 | self.shell.dir_stack.pop(0) |
|
2368 | self.shell.dir_stack.pop(0) | |
2353 | self.magic_cd(self.shell.dir_stack[0]) |
|
2369 | self.magic_cd(self.shell.dir_stack[0]) | |
2354 | print self.shell.dir_stack[0] |
|
2370 | print self.shell.dir_stack[0] | |
2355 | else: |
|
2371 | else: | |
2356 | print "You can't remove the starting directory from the stack:",\ |
|
2372 | print "You can't remove the starting directory from the stack:",\ | |
2357 | self.shell.dir_stack |
|
2373 | self.shell.dir_stack | |
2358 |
|
2374 | |||
2359 | def magic_dirs(self, parameter_s=''): |
|
2375 | def magic_dirs(self, parameter_s=''): | |
2360 | """Return the current directory stack.""" |
|
2376 | """Return the current directory stack.""" | |
2361 |
|
2377 | |||
2362 | return self.shell.dir_stack[:] |
|
2378 | return self.shell.dir_stack[:] | |
2363 |
|
2379 | |||
2364 | def magic_sc(self, parameter_s=''): |
|
2380 | def magic_sc(self, parameter_s=''): | |
2365 | """Shell capture - execute a shell command and capture its output. |
|
2381 | """Shell capture - execute a shell command and capture its output. | |
2366 |
|
2382 | |||
2367 | %sc [options] varname=command |
|
2383 | %sc [options] varname=command | |
2368 |
|
2384 | |||
2369 | IPython will run the given command using commands.getoutput(), and |
|
2385 | IPython will run the given command using commands.getoutput(), and | |
2370 | will then update the user's interactive namespace with a variable |
|
2386 | will then update the user's interactive namespace with a variable | |
2371 | called varname, containing the value of the call. Your command can |
|
2387 | called varname, containing the value of the call. Your command can | |
2372 | contain shell wildcards, pipes, etc. |
|
2388 | contain shell wildcards, pipes, etc. | |
2373 |
|
2389 | |||
2374 | The '=' sign in the syntax is mandatory, and the variable name you |
|
2390 | The '=' sign in the syntax is mandatory, and the variable name you | |
2375 | supply must follow Python's standard conventions for valid names. |
|
2391 | supply must follow Python's standard conventions for valid names. | |
2376 |
|
2392 | |||
2377 | Options: |
|
2393 | Options: | |
2378 |
|
2394 | |||
2379 | -l: list output. Split the output on newlines into a list before |
|
2395 | -l: list output. Split the output on newlines into a list before | |
2380 | assigning it to the given variable. By default the output is stored |
|
2396 | assigning it to the given variable. By default the output is stored | |
2381 | as a single string. |
|
2397 | as a single string. | |
2382 |
|
2398 | |||
2383 | -v: verbose. Print the contents of the variable. |
|
2399 | -v: verbose. Print the contents of the variable. | |
2384 |
|
2400 | |||
2385 | In most cases you should not need to split as a list, because the |
|
2401 | In most cases you should not need to split as a list, because the | |
2386 | returned value is a special type of string which can automatically |
|
2402 | returned value is a special type of string which can automatically | |
2387 | provide its contents either as a list (split on newlines) or as a |
|
2403 | provide its contents either as a list (split on newlines) or as a | |
2388 | space-separated string. These are convenient, respectively, either |
|
2404 | space-separated string. These are convenient, respectively, either | |
2389 | for sequential processing or to be passed to a shell command. |
|
2405 | for sequential processing or to be passed to a shell command. | |
2390 |
|
2406 | |||
2391 | For example: |
|
2407 | For example: | |
2392 |
|
2408 | |||
2393 | # Capture into variable a |
|
2409 | # Capture into variable a | |
2394 | In [9]: sc a=ls *py |
|
2410 | In [9]: sc a=ls *py | |
2395 |
|
2411 | |||
2396 | # a is a string with embedded newlines |
|
2412 | # a is a string with embedded newlines | |
2397 | In [10]: a |
|
2413 | In [10]: a | |
2398 | Out[10]: 'setup.py\nwin32_manual_post_install.py' |
|
2414 | Out[10]: 'setup.py\nwin32_manual_post_install.py' | |
2399 |
|
2415 | |||
2400 | # which can be seen as a list: |
|
2416 | # which can be seen as a list: | |
2401 | In [11]: a.l |
|
2417 | In [11]: a.l | |
2402 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] |
|
2418 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] | |
2403 |
|
2419 | |||
2404 | # or as a whitespace-separated string: |
|
2420 | # or as a whitespace-separated string: | |
2405 | In [12]: a.s |
|
2421 | In [12]: a.s | |
2406 | Out[12]: 'setup.py win32_manual_post_install.py' |
|
2422 | Out[12]: 'setup.py win32_manual_post_install.py' | |
2407 |
|
2423 | |||
2408 | # a.s is useful to pass as a single command line: |
|
2424 | # a.s is useful to pass as a single command line: | |
2409 | In [13]: !wc -l $a.s |
|
2425 | In [13]: !wc -l $a.s | |
2410 | 146 setup.py |
|
2426 | 146 setup.py | |
2411 | 130 win32_manual_post_install.py |
|
2427 | 130 win32_manual_post_install.py | |
2412 | 276 total |
|
2428 | 276 total | |
2413 |
|
2429 | |||
2414 | # while the list form is useful to loop over: |
|
2430 | # while the list form is useful to loop over: | |
2415 | In [14]: for f in a.l: |
|
2431 | In [14]: for f in a.l: | |
2416 | ....: !wc -l $f |
|
2432 | ....: !wc -l $f | |
2417 | ....: |
|
2433 | ....: | |
2418 | 146 setup.py |
|
2434 | 146 setup.py | |
2419 | 130 win32_manual_post_install.py |
|
2435 | 130 win32_manual_post_install.py | |
2420 |
|
2436 | |||
2421 | Similiarly, the lists returned by the -l option are also special, in |
|
2437 | Similiarly, the lists returned by the -l option are also special, in | |
2422 | the sense that you can equally invoke the .s attribute on them to |
|
2438 | the sense that you can equally invoke the .s attribute on them to | |
2423 | automatically get a whitespace-separated string from their contents: |
|
2439 | automatically get a whitespace-separated string from their contents: | |
2424 |
|
2440 | |||
2425 | In [1]: sc -l b=ls *py |
|
2441 | In [1]: sc -l b=ls *py | |
2426 |
|
2442 | |||
2427 | In [2]: b |
|
2443 | In [2]: b | |
2428 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] |
|
2444 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] | |
2429 |
|
2445 | |||
2430 | In [3]: b.s |
|
2446 | In [3]: b.s | |
2431 | Out[3]: 'setup.py win32_manual_post_install.py' |
|
2447 | Out[3]: 'setup.py win32_manual_post_install.py' | |
2432 |
|
2448 | |||
2433 | In summary, both the lists and strings used for ouptut capture have |
|
2449 | In summary, both the lists and strings used for ouptut capture have | |
2434 | the following special attributes: |
|
2450 | the following special attributes: | |
2435 |
|
2451 | |||
2436 | .l (or .list) : value as list. |
|
2452 | .l (or .list) : value as list. | |
2437 | .n (or .nlstr): value as newline-separated string. |
|
2453 | .n (or .nlstr): value as newline-separated string. | |
2438 | .s (or .spstr): value as space-separated string. |
|
2454 | .s (or .spstr): value as space-separated string. | |
2439 | """ |
|
2455 | """ | |
2440 |
|
2456 | |||
2441 | opts,args = self.parse_options(parameter_s,'lv') |
|
2457 | opts,args = self.parse_options(parameter_s,'lv') | |
2442 | # Try to get a variable name and command to run |
|
2458 | # Try to get a variable name and command to run | |
2443 | try: |
|
2459 | try: | |
2444 | # the variable name must be obtained from the parse_options |
|
2460 | # the variable name must be obtained from the parse_options | |
2445 | # output, which uses shlex.split to strip options out. |
|
2461 | # output, which uses shlex.split to strip options out. | |
2446 | var,_ = args.split('=',1) |
|
2462 | var,_ = args.split('=',1) | |
2447 | var = var.strip() |
|
2463 | var = var.strip() | |
2448 | # But the the command has to be extracted from the original input |
|
2464 | # But the the command has to be extracted from the original input | |
2449 | # parameter_s, not on what parse_options returns, to avoid the |
|
2465 | # parameter_s, not on what parse_options returns, to avoid the | |
2450 | # quote stripping which shlex.split performs on it. |
|
2466 | # quote stripping which shlex.split performs on it. | |
2451 | _,cmd = parameter_s.split('=',1) |
|
2467 | _,cmd = parameter_s.split('=',1) | |
2452 | except ValueError: |
|
2468 | except ValueError: | |
2453 | var,cmd = '','' |
|
2469 | var,cmd = '','' | |
2454 | if not var: |
|
2470 | if not var: | |
2455 | error('you must specify a variable to assign the command to.') |
|
2471 | error('you must specify a variable to assign the command to.') | |
2456 | return |
|
2472 | return | |
2457 | # If all looks ok, proceed |
|
2473 | # If all looks ok, proceed | |
2458 | out,err = self.shell.getoutputerror(cmd) |
|
2474 | out,err = self.shell.getoutputerror(cmd) | |
2459 | if err: |
|
2475 | if err: | |
2460 | print >> Term.cerr,err |
|
2476 | print >> Term.cerr,err | |
2461 | if opts.has_key('l'): |
|
2477 | if opts.has_key('l'): | |
2462 | out = SList(out.split('\n')) |
|
2478 | out = SList(out.split('\n')) | |
2463 | else: |
|
2479 | else: | |
2464 | out = LSString(out) |
|
2480 | out = LSString(out) | |
2465 | if opts.has_key('v'): |
|
2481 | if opts.has_key('v'): | |
2466 | print '%s ==\n%s' % (var,pformat(out)) |
|
2482 | print '%s ==\n%s' % (var,pformat(out)) | |
2467 | self.shell.user_ns.update({var:out}) |
|
2483 | self.shell.user_ns.update({var:out}) | |
2468 |
|
2484 | |||
2469 | def magic_sx(self, parameter_s=''): |
|
2485 | def magic_sx(self, parameter_s=''): | |
2470 | """Shell execute - run a shell command and capture its output. |
|
2486 | """Shell execute - run a shell command and capture its output. | |
2471 |
|
2487 | |||
2472 | %sx command |
|
2488 | %sx command | |
2473 |
|
2489 | |||
2474 | IPython will run the given command using commands.getoutput(), and |
|
2490 | IPython will run the given command using commands.getoutput(), and | |
2475 | return the result formatted as a list (split on '\\n'). Since the |
|
2491 | return the result formatted as a list (split on '\\n'). Since the | |
2476 | output is _returned_, it will be stored in ipython's regular output |
|
2492 | output is _returned_, it will be stored in ipython's regular output | |
2477 | cache Out[N] and in the '_N' automatic variables. |
|
2493 | cache Out[N] and in the '_N' automatic variables. | |
2478 |
|
2494 | |||
2479 | Notes: |
|
2495 | Notes: | |
2480 |
|
2496 | |||
2481 | 1) If an input line begins with '!!', then %sx is automatically |
|
2497 | 1) If an input line begins with '!!', then %sx is automatically | |
2482 | invoked. That is, while: |
|
2498 | invoked. That is, while: | |
2483 | !ls |
|
2499 | !ls | |
2484 | causes ipython to simply issue system('ls'), typing |
|
2500 | causes ipython to simply issue system('ls'), typing | |
2485 | !!ls |
|
2501 | !!ls | |
2486 | is a shorthand equivalent to: |
|
2502 | is a shorthand equivalent to: | |
2487 | %sx ls |
|
2503 | %sx ls | |
2488 |
|
2504 | |||
2489 | 2) %sx differs from %sc in that %sx automatically splits into a list, |
|
2505 | 2) %sx differs from %sc in that %sx automatically splits into a list, | |
2490 | like '%sc -l'. The reason for this is to make it as easy as possible |
|
2506 | like '%sc -l'. The reason for this is to make it as easy as possible | |
2491 | to process line-oriented shell output via further python commands. |
|
2507 | to process line-oriented shell output via further python commands. | |
2492 | %sc is meant to provide much finer control, but requires more |
|
2508 | %sc is meant to provide much finer control, but requires more | |
2493 | typing. |
|
2509 | typing. | |
2494 |
|
2510 | |||
2495 | 3) Just like %sc -l, this is a list with special attributes: |
|
2511 | 3) Just like %sc -l, this is a list with special attributes: | |
2496 |
|
2512 | |||
2497 | .l (or .list) : value as list. |
|
2513 | .l (or .list) : value as list. | |
2498 | .n (or .nlstr): value as newline-separated string. |
|
2514 | .n (or .nlstr): value as newline-separated string. | |
2499 | .s (or .spstr): value as whitespace-separated string. |
|
2515 | .s (or .spstr): value as whitespace-separated string. | |
2500 |
|
2516 | |||
2501 | This is very useful when trying to use such lists as arguments to |
|
2517 | This is very useful when trying to use such lists as arguments to | |
2502 | system commands.""" |
|
2518 | system commands.""" | |
2503 |
|
2519 | |||
2504 | if parameter_s: |
|
2520 | if parameter_s: | |
2505 | out,err = self.shell.getoutputerror(parameter_s) |
|
2521 | out,err = self.shell.getoutputerror(parameter_s) | |
2506 | if err: |
|
2522 | if err: | |
2507 | print >> Term.cerr,err |
|
2523 | print >> Term.cerr,err | |
2508 | return SList(out.split('\n')) |
|
2524 | return SList(out.split('\n')) | |
2509 |
|
2525 | |||
2510 | def magic_bg(self, parameter_s=''): |
|
2526 | def magic_bg(self, parameter_s=''): | |
2511 | """Run a job in the background, in a separate thread. |
|
2527 | """Run a job in the background, in a separate thread. | |
2512 |
|
2528 | |||
2513 | For example, |
|
2529 | For example, | |
2514 |
|
2530 | |||
2515 | %bg myfunc(x,y,z=1) |
|
2531 | %bg myfunc(x,y,z=1) | |
2516 |
|
2532 | |||
2517 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the |
|
2533 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the | |
2518 | execution starts, a message will be printed indicating the job |
|
2534 | execution starts, a message will be printed indicating the job | |
2519 | number. If your job number is 5, you can use |
|
2535 | number. If your job number is 5, you can use | |
2520 |
|
2536 | |||
2521 | myvar = jobs.result(5) or myvar = jobs[5].result |
|
2537 | myvar = jobs.result(5) or myvar = jobs[5].result | |
2522 |
|
2538 | |||
2523 | to assign this result to variable 'myvar'. |
|
2539 | to assign this result to variable 'myvar'. | |
2524 |
|
2540 | |||
2525 | IPython has a job manager, accessible via the 'jobs' object. You can |
|
2541 | IPython has a job manager, accessible via the 'jobs' object. You can | |
2526 | type jobs? to get more information about it, and use jobs.<TAB> to see |
|
2542 | type jobs? to get more information about it, and use jobs.<TAB> to see | |
2527 | its attributes. All attributes not starting with an underscore are |
|
2543 | its attributes. All attributes not starting with an underscore are | |
2528 | meant for public use. |
|
2544 | meant for public use. | |
2529 |
|
2545 | |||
2530 | In particular, look at the jobs.new() method, which is used to create |
|
2546 | In particular, look at the jobs.new() method, which is used to create | |
2531 | new jobs. This magic %bg function is just a convenience wrapper |
|
2547 | new jobs. This magic %bg function is just a convenience wrapper | |
2532 | around jobs.new(), for expression-based jobs. If you want to create a |
|
2548 | around jobs.new(), for expression-based jobs. If you want to create a | |
2533 | new job with an explicit function object and arguments, you must call |
|
2549 | new job with an explicit function object and arguments, you must call | |
2534 | jobs.new() directly. |
|
2550 | jobs.new() directly. | |
2535 |
|
2551 | |||
2536 | The jobs.new docstring also describes in detail several important |
|
2552 | The jobs.new docstring also describes in detail several important | |
2537 | caveats associated with a thread-based model for background job |
|
2553 | caveats associated with a thread-based model for background job | |
2538 | execution. Type jobs.new? for details. |
|
2554 | execution. Type jobs.new? for details. | |
2539 |
|
2555 | |||
2540 | You can check the status of all jobs with jobs.status(). |
|
2556 | You can check the status of all jobs with jobs.status(). | |
2541 |
|
2557 | |||
2542 | The jobs variable is set by IPython into the Python builtin namespace. |
|
2558 | The jobs variable is set by IPython into the Python builtin namespace. | |
2543 | If you ever declare a variable named 'jobs', you will shadow this |
|
2559 | If you ever declare a variable named 'jobs', you will shadow this | |
2544 | name. You can either delete your global jobs variable to regain |
|
2560 | name. You can either delete your global jobs variable to regain | |
2545 | access to the job manager, or make a new name and assign it manually |
|
2561 | access to the job manager, or make a new name and assign it manually | |
2546 | to the manager (stored in IPython's namespace). For example, to |
|
2562 | to the manager (stored in IPython's namespace). For example, to | |
2547 | assign the job manager to the Jobs name, use: |
|
2563 | assign the job manager to the Jobs name, use: | |
2548 |
|
2564 | |||
2549 | Jobs = __builtins__.jobs""" |
|
2565 | Jobs = __builtins__.jobs""" | |
2550 |
|
2566 | |||
2551 | self.shell.jobs.new(parameter_s,self.shell.user_ns) |
|
2567 | self.shell.jobs.new(parameter_s,self.shell.user_ns) | |
2552 |
|
2568 | |||
2553 | def magic_store(self, parameter_s=''): |
|
2569 | def magic_store(self, parameter_s=''): | |
2554 | """Lightweight persistence for python variables. |
|
2570 | """Lightweight persistence for python variables. | |
2555 |
|
2571 | |||
2556 | Example: |
|
2572 | Example: | |
2557 |
|
2573 | |||
2558 | ville@badger[~]|1> A = ['hello',10,'world']\\ |
|
2574 | ville@badger[~]|1> A = ['hello',10,'world']\\ | |
2559 | ville@badger[~]|2> %store A\\ |
|
2575 | ville@badger[~]|2> %store A\\ | |
2560 | ville@badger[~]|3> Exit |
|
2576 | ville@badger[~]|3> Exit | |
2561 |
|
2577 | |||
2562 | (IPython session is closed and started again...) |
|
2578 | (IPython session is closed and started again...) | |
2563 |
|
2579 | |||
2564 | ville@badger:~$ ipython -p pysh\\ |
|
2580 | ville@badger:~$ ipython -p pysh\\ | |
2565 | ville@badger[~]|1> print A |
|
2581 | ville@badger[~]|1> print A | |
2566 |
|
2582 | |||
2567 | ['hello', 10, 'world'] |
|
2583 | ['hello', 10, 'world'] | |
2568 |
|
2584 | |||
2569 | Usage: |
|
2585 | Usage: | |
2570 |
|
2586 | |||
2571 | %store - Show list of all variables and their current values\\ |
|
2587 | %store - Show list of all variables and their current values\\ | |
2572 | %store <var> - Store the *current* value of the variable to disk\\ |
|
2588 | %store <var> - Store the *current* value of the variable to disk\\ | |
2573 |
%store -d |
|
2589 | %store -d <var> - Remove the variable and its value from storage\\ | |
2574 | %store -r - Remove all variables from storage |
|
2590 | %store -r - Remove all variables from storage | |
2575 |
|
2591 | |||
2576 | It should be noted that if you change the value of a variable, you |
|
2592 | It should be noted that if you change the value of a variable, you | |
2577 | need to %store it again if you want to persist the new value. |
|
2593 | need to %store it again if you want to persist the new value. | |
2578 |
|
2594 | |||
2579 | Note also that the variables will need to be pickleable; most basic |
|
2595 | Note also that the variables will need to be pickleable; most basic | |
2580 | python types can be safely %stored. |
|
2596 | python types can be safely %stored. | |
2581 | """ |
|
2597 | """ | |
2582 |
|
2598 | |||
2583 | opts,args = self.parse_options(parameter_s,'dr',mode='list') |
|
2599 | opts,args = self.parse_options(parameter_s,'dr',mode='list') | |
2584 | # delete |
|
2600 | # delete | |
2585 | if opts.has_key('d'): |
|
2601 | if opts.has_key('d'): | |
2586 | try: |
|
2602 | try: | |
2587 | todel = args[0] |
|
2603 | todel = args[0] | |
2588 | except IndexError: |
|
2604 | except IndexError: | |
2589 | error('You must provide the variable to forget') |
|
2605 | error('You must provide the variable to forget') | |
2590 | else: |
|
2606 | else: | |
2591 | try: |
|
2607 | try: | |
2592 | del self.shell.persist['S:' + todel] |
|
2608 | del self.shell.persist['S:' + todel] | |
2593 | except: |
|
2609 | except: | |
2594 | error("Can't delete variable '%s'" % todel) |
|
2610 | error("Can't delete variable '%s'" % todel) | |
2595 | # reset |
|
2611 | # reset | |
2596 | elif opts.has_key('r'): |
|
2612 | elif opts.has_key('r'): | |
2597 | for k in self.shell.persist.keys(): |
|
2613 | for k in self.shell.persist.keys(): | |
2598 | if k.startswith('S:'): |
|
2614 | if k.startswith('S:'): | |
2599 | del self.shell.persist[k] |
|
2615 | del self.shell.persist[k] | |
2600 |
|
2616 | |||
2601 | # run without arguments -> list variables & values |
|
2617 | # run without arguments -> list variables & values | |
2602 | elif not args: |
|
2618 | elif not args: | |
2603 | vars = [v[2:] for v in self.shell.persist.keys() |
|
2619 | vars = [v[2:] for v in self.shell.persist.keys() | |
2604 | if v.startswith('S:')] |
|
2620 | if v.startswith('S:')] | |
2605 | vars.sort() |
|
2621 | vars.sort() | |
2606 | if vars: |
|
2622 | if vars: | |
2607 | size = max(map(len,vars)) |
|
2623 | size = max(map(len,vars)) | |
2608 | else: |
|
2624 | else: | |
2609 | size = 0 |
|
2625 | size = 0 | |
2610 |
|
2626 | |||
2611 | print 'Stored variables and their in-memory values:' |
|
2627 | print 'Stored variables and their in-memory values:' | |
2612 | fmt = '%-'+str(size)+'s -> %s' |
|
2628 | fmt = '%-'+str(size)+'s -> %s' | |
2613 | get = self.shell.user_ns.get |
|
2629 | get = self.shell.user_ns.get | |
2614 | for var in vars: |
|
2630 | for var in vars: | |
2615 | # print 30 first characters from every var |
|
2631 | # print 30 first characters from every var | |
2616 | print fmt % (var,repr(get(var,'<unavailable>'))[:50]) |
|
2632 | print fmt % (var,repr(get(var,'<unavailable>'))[:50]) | |
2617 |
|
2633 | |||
2618 | # default action - store the variable |
|
2634 | # default action - store the variable | |
2619 | else: |
|
2635 | else: | |
2620 | pickled = pickle.dumps(self.shell.user_ns[args[0] ]) |
|
2636 | pickled = pickle.dumps(self.shell.user_ns[args[0] ]) | |
2621 | self.shell.persist[ 'S:' + args[0] ] = pickled |
|
2637 | self.shell.persist[ 'S:' + args[0] ] = pickled | |
2622 | print "Stored '%s' (%d bytes)" % (args[0], len(pickled)) |
|
2638 | print "Stored '%s' (%d bytes)" % (args[0], len(pickled)) | |
2623 |
|
2639 | |||
2624 | def magic_bookmark(self, parameter_s=''): |
|
2640 | def magic_bookmark(self, parameter_s=''): | |
2625 | """Manage IPython's bookmark system. |
|
2641 | """Manage IPython's bookmark system. | |
2626 |
|
2642 | |||
2627 | %bookmark <name> - set bookmark to current dir |
|
2643 | %bookmark <name> - set bookmark to current dir | |
2628 | %bookmark <name> <dir> - set bookmark to <dir> |
|
2644 | %bookmark <name> <dir> - set bookmark to <dir> | |
2629 | %bookmark -l - list all bookmarks |
|
2645 | %bookmark -l - list all bookmarks | |
2630 | %bookmark -d <name> - remove bookmark |
|
2646 | %bookmark -d <name> - remove bookmark | |
2631 | %bookmark -r - remove all bookmarks |
|
2647 | %bookmark -r - remove all bookmarks | |
2632 |
|
2648 | |||
2633 | You can later on access a bookmarked folder with: |
|
2649 | You can later on access a bookmarked folder with: | |
2634 | %cd -b <name> |
|
2650 | %cd -b <name> | |
2635 | or simply '%cd <name>' if there is no directory called <name> AND |
|
2651 | or simply '%cd <name>' if there is no directory called <name> AND | |
2636 | there is such a bookmark defined. |
|
2652 | there is such a bookmark defined. | |
2637 |
|
2653 | |||
2638 | Your bookmarks persist through IPython sessions, but they are |
|
2654 | Your bookmarks persist through IPython sessions, but they are | |
2639 | associated with each profile.""" |
|
2655 | associated with each profile.""" | |
2640 |
|
2656 | |||
2641 | opts,args = self.parse_options(parameter_s,'drl',mode='list') |
|
2657 | opts,args = self.parse_options(parameter_s,'drl',mode='list') | |
2642 | if len(args) > 2: |
|
2658 | if len(args) > 2: | |
2643 | error('You can only give at most two arguments') |
|
2659 | error('You can only give at most two arguments') | |
2644 | return |
|
2660 | return | |
2645 |
|
2661 | |||
2646 | bkms = self.shell.persist.get('bookmarks',{}) |
|
2662 | bkms = self.shell.persist.get('bookmarks',{}) | |
2647 |
|
2663 | |||
2648 | if opts.has_key('d'): |
|
2664 | if opts.has_key('d'): | |
2649 | try: |
|
2665 | try: | |
2650 | todel = args[0] |
|
2666 | todel = args[0] | |
2651 | except IndexError: |
|
2667 | except IndexError: | |
2652 | error('You must provide a bookmark to delete') |
|
2668 | error('You must provide a bookmark to delete') | |
2653 | else: |
|
2669 | else: | |
2654 | try: |
|
2670 | try: | |
2655 | del bkms[todel] |
|
2671 | del bkms[todel] | |
2656 | except: |
|
2672 | except: | |
2657 | error("Can't delete bookmark '%s'" % todel) |
|
2673 | error("Can't delete bookmark '%s'" % todel) | |
2658 | elif opts.has_key('r'): |
|
2674 | elif opts.has_key('r'): | |
2659 | bkms = {} |
|
2675 | bkms = {} | |
2660 | elif opts.has_key('l'): |
|
2676 | elif opts.has_key('l'): | |
2661 | bks = bkms.keys() |
|
2677 | bks = bkms.keys() | |
2662 | bks.sort() |
|
2678 | bks.sort() | |
2663 | if bks: |
|
2679 | if bks: | |
2664 | size = max(map(len,bks)) |
|
2680 | size = max(map(len,bks)) | |
2665 | else: |
|
2681 | else: | |
2666 | size = 0 |
|
2682 | size = 0 | |
2667 | fmt = '%-'+str(size)+'s -> %s' |
|
2683 | fmt = '%-'+str(size)+'s -> %s' | |
2668 | print 'Current bookmarks:' |
|
2684 | print 'Current bookmarks:' | |
2669 | for bk in bks: |
|
2685 | for bk in bks: | |
2670 | print fmt % (bk,bkms[bk]) |
|
2686 | print fmt % (bk,bkms[bk]) | |
2671 | else: |
|
2687 | else: | |
2672 | if not args: |
|
2688 | if not args: | |
2673 | error("You must specify the bookmark name") |
|
2689 | error("You must specify the bookmark name") | |
2674 | elif len(args)==1: |
|
2690 | elif len(args)==1: | |
2675 | bkms[args[0]] = os.getcwd() |
|
2691 | bkms[args[0]] = os.getcwd() | |
2676 | elif len(args)==2: |
|
2692 | elif len(args)==2: | |
2677 | bkms[args[0]] = args[1] |
|
2693 | bkms[args[0]] = args[1] | |
2678 | self.shell.persist['bookmarks'] = bkms |
|
2694 | self.shell.persist['bookmarks'] = bkms | |
2679 |
|
2695 | |||
2680 | def magic_pycat(self, parameter_s=''): |
|
2696 | def magic_pycat(self, parameter_s=''): | |
2681 | """Show a syntax-highlighted file through a pager. |
|
2697 | """Show a syntax-highlighted file through a pager. | |
2682 |
|
2698 | |||
2683 | This magic is similar to the cat utility, but it will assume the file |
|
2699 | This magic is similar to the cat utility, but it will assume the file | |
2684 | to be Python source and will show it with syntax highlighting. """ |
|
2700 | to be Python source and will show it with syntax highlighting. """ | |
2685 |
|
2701 | |||
2686 | filename = get_py_filename(parameter_s) |
|
2702 | filename = get_py_filename(parameter_s) | |
2687 | page(self.shell.colorize(file_read(filename)), |
|
2703 | page(self.shell.colorize(file_read(filename)), | |
2688 | screen_lines=self.shell.rc.screen_length) |
|
2704 | screen_lines=self.shell.rc.screen_length) | |
2689 |
|
2705 | |||
2690 | # end Magic |
|
2706 | # end Magic |
@@ -1,76 +1,76 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Release data for the IPython project. |
|
2 | """Release data for the IPython project. | |
3 |
|
3 | |||
4 |
$Id: Release.py 98 |
|
4 | $Id: Release.py 988 2006-01-02 21:21:47Z fperez $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu> |
|
7 | # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu> | |
8 | # |
|
8 | # | |
9 | # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray |
|
9 | # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray | |
10 | # <n8gray@caltech.edu> |
|
10 | # <n8gray@caltech.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 | # Name of the package for release purposes. This is the name which labels |
|
16 | # Name of the package for release purposes. This is the name which labels | |
17 | # the tarballs and RPMs made by distutils, so it's best to lowercase it. |
|
17 | # the tarballs and RPMs made by distutils, so it's best to lowercase it. | |
18 | name = 'ipython' |
|
18 | name = 'ipython' | |
19 |
|
19 | |||
20 | # For versions with substrings (like 0.6.16.svn), use an extra . to separate |
|
20 | # For versions with substrings (like 0.6.16.svn), use an extra . to separate | |
21 | # the new substring. We have to avoid using either dashes or underscores, |
|
21 | # the new substring. We have to avoid using either dashes or underscores, | |
22 | # because bdist_rpm does not accept dashes (an RPM) convention, and |
|
22 | # because bdist_rpm does not accept dashes (an RPM) convention, and | |
23 | # bdist_deb does not accept underscores (a Debian convention). |
|
23 | # bdist_deb does not accept underscores (a Debian convention). | |
24 |
|
24 | |||
25 |
version = '0.7.0.rc |
|
25 | version = '0.7.0.rc7' | |
26 |
|
26 | |||
27 |
revision = '$Revision: 98 |
|
27 | revision = '$Revision: 988 $' | |
28 |
|
28 | |||
29 | description = "An enhanced interactive Python shell." |
|
29 | description = "An enhanced interactive Python shell." | |
30 |
|
30 | |||
31 | long_description = \ |
|
31 | long_description = \ | |
32 | """ |
|
32 | """ | |
33 | IPython provides a replacement for the interactive Python interpreter with |
|
33 | IPython provides a replacement for the interactive Python interpreter with | |
34 | extra functionality. |
|
34 | extra functionality. | |
35 |
|
35 | |||
36 | Main features: |
|
36 | Main features: | |
37 |
|
37 | |||
38 | * Comprehensive object introspection. |
|
38 | * Comprehensive object introspection. | |
39 |
|
39 | |||
40 | * Input history, persistent across sessions. |
|
40 | * Input history, persistent across sessions. | |
41 |
|
41 | |||
42 | * Caching of output results during a session with automatically generated |
|
42 | * Caching of output results during a session with automatically generated | |
43 | references. |
|
43 | references. | |
44 |
|
44 | |||
45 | * Readline based name completion. |
|
45 | * Readline based name completion. | |
46 |
|
46 | |||
47 | * Extensible system of 'magic' commands for controlling the environment and |
|
47 | * Extensible system of 'magic' commands for controlling the environment and | |
48 | performing many tasks related either to IPython or the operating system. |
|
48 | performing many tasks related either to IPython or the operating system. | |
49 |
|
49 | |||
50 | * Configuration system with easy switching between different setups (simpler |
|
50 | * Configuration system with easy switching between different setups (simpler | |
51 | than changing $PYTHONSTARTUP environment variables every time). |
|
51 | than changing $PYTHONSTARTUP environment variables every time). | |
52 |
|
52 | |||
53 | * Session logging and reloading. |
|
53 | * Session logging and reloading. | |
54 |
|
54 | |||
55 | * Extensible syntax processing for special purpose situations. |
|
55 | * Extensible syntax processing for special purpose situations. | |
56 |
|
56 | |||
57 | * Access to the system shell with user-extensible alias system. |
|
57 | * Access to the system shell with user-extensible alias system. | |
58 |
|
58 | |||
59 | * Easily embeddable in other Python programs. |
|
59 | * Easily embeddable in other Python programs. | |
60 |
|
60 | |||
61 | * Integrated access to the pdb debugger and the Python profiler. """ |
|
61 | * Integrated access to the pdb debugger and the Python profiler. """ | |
62 |
|
62 | |||
63 | license = 'BSD' |
|
63 | license = 'BSD' | |
64 |
|
64 | |||
65 | authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'), |
|
65 | authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'), | |
66 | 'Janko' : ('Janko Hauser','jhauser@zscout.de'), |
|
66 | 'Janko' : ('Janko Hauser','jhauser@zscout.de'), | |
67 | 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu') |
|
67 | 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu') | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | url = 'http://ipython.scipy.org' |
|
70 | url = 'http://ipython.scipy.org' | |
71 |
|
71 | |||
72 | download_url = 'http://ipython.scipy.org/dist' |
|
72 | download_url = 'http://ipython.scipy.org/dist' | |
73 |
|
73 | |||
74 | platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME'] |
|
74 | platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME'] | |
75 |
|
75 | |||
76 | keywords = ['Interactive','Interpreter','Shell'] |
|
76 | keywords = ['Interactive','Interpreter','Shell'] |
@@ -1,543 +1,539 b'' | |||||
1 | """Word completion for IPython. |
|
1 | """Word completion for IPython. | |
2 |
|
2 | |||
3 | This module is a fork of the rlcompleter module in the Python standard |
|
3 | This module is a fork of the rlcompleter module in the Python standard | |
4 | library. The original enhancements made to rlcompleter have been sent |
|
4 | library. The original enhancements made to rlcompleter have been sent | |
5 | upstream and were accepted as of Python 2.3, but we need a lot more |
|
5 | upstream and were accepted as of Python 2.3, but we need a lot more | |
6 | functionality specific to IPython, so this module will continue to live as an |
|
6 | functionality specific to IPython, so this module will continue to live as an | |
7 | IPython-specific utility. |
|
7 | IPython-specific utility. | |
8 |
|
8 | |||
9 | --------------------------------------------------------------------------- |
|
9 | --------------------------------------------------------------------------- | |
10 | Original rlcompleter documentation: |
|
10 | Original rlcompleter documentation: | |
11 |
|
11 | |||
12 | This requires the latest extension to the readline module (the |
|
12 | This requires the latest extension to the readline module (the | |
13 | completes keywords, built-ins and globals in __main__; when completing |
|
13 | completes keywords, built-ins and globals in __main__; when completing | |
14 | NAME.NAME..., it evaluates (!) the expression up to the last dot and |
|
14 | NAME.NAME..., it evaluates (!) the expression up to the last dot and | |
15 | completes its attributes. |
|
15 | completes its attributes. | |
16 |
|
16 | |||
17 | It's very cool to do "import string" type "string.", hit the |
|
17 | It's very cool to do "import string" type "string.", hit the | |
18 | completion key (twice), and see the list of names defined by the |
|
18 | completion key (twice), and see the list of names defined by the | |
19 | string module! |
|
19 | string module! | |
20 |
|
20 | |||
21 | Tip: to use the tab key as the completion key, call |
|
21 | Tip: to use the tab key as the completion key, call | |
22 |
|
22 | |||
23 | readline.parse_and_bind("tab: complete") |
|
23 | readline.parse_and_bind("tab: complete") | |
24 |
|
24 | |||
25 | Notes: |
|
25 | Notes: | |
26 |
|
26 | |||
27 | - Exceptions raised by the completer function are *ignored* (and |
|
27 | - Exceptions raised by the completer function are *ignored* (and | |
28 | generally cause the completion to fail). This is a feature -- since |
|
28 | generally cause the completion to fail). This is a feature -- since | |
29 | readline sets the tty device in raw (or cbreak) mode, printing a |
|
29 | readline sets the tty device in raw (or cbreak) mode, printing a | |
30 | traceback wouldn't work well without some complicated hoopla to save, |
|
30 | traceback wouldn't work well without some complicated hoopla to save, | |
31 | reset and restore the tty state. |
|
31 | reset and restore the tty state. | |
32 |
|
32 | |||
33 | - The evaluation of the NAME.NAME... form may cause arbitrary |
|
33 | - The evaluation of the NAME.NAME... form may cause arbitrary | |
34 | application defined code to be executed if an object with a |
|
34 | application defined code to be executed if an object with a | |
35 | __getattr__ hook is found. Since it is the responsibility of the |
|
35 | __getattr__ hook is found. Since it is the responsibility of the | |
36 | application (or the user) to enable this feature, I consider this an |
|
36 | application (or the user) to enable this feature, I consider this an | |
37 | acceptable risk. More complicated expressions (e.g. function calls or |
|
37 | acceptable risk. More complicated expressions (e.g. function calls or | |
38 | indexing operations) are *not* evaluated. |
|
38 | indexing operations) are *not* evaluated. | |
39 |
|
39 | |||
40 | - GNU readline is also used by the built-in functions input() and |
|
40 | - GNU readline is also used by the built-in functions input() and | |
41 | raw_input(), and thus these also benefit/suffer from the completer |
|
41 | raw_input(), and thus these also benefit/suffer from the completer | |
42 | features. Clearly an interactive application can benefit by |
|
42 | features. Clearly an interactive application can benefit by | |
43 | specifying its own completer function and using raw_input() for all |
|
43 | specifying its own completer function and using raw_input() for all | |
44 | its input. |
|
44 | its input. | |
45 |
|
45 | |||
46 | - When the original stdin is not a tty device, GNU readline is never |
|
46 | - When the original stdin is not a tty device, GNU readline is never | |
47 | used, and this module (and the readline module) are silently inactive. |
|
47 | used, and this module (and the readline module) are silently inactive. | |
48 |
|
48 | |||
49 | """ |
|
49 | """ | |
50 |
|
50 | |||
51 | #***************************************************************************** |
|
51 | #***************************************************************************** | |
52 | # |
|
52 | # | |
53 | # Since this file is essentially a minimally modified copy of the rlcompleter |
|
53 | # Since this file is essentially a minimally modified copy of the rlcompleter | |
54 | # module which is part of the standard Python distribution, I assume that the |
|
54 | # module which is part of the standard Python distribution, I assume that the | |
55 | # proper procedure is to maintain its copyright as belonging to the Python |
|
55 | # proper procedure is to maintain its copyright as belonging to the Python | |
56 | # Software Foundation (in addition to my own, for all new code). |
|
56 | # Software Foundation (in addition to my own, for all new code). | |
57 | # |
|
57 | # | |
58 | # Copyright (C) 2001 Python Software Foundation, www.python.org |
|
58 | # Copyright (C) 2001 Python Software Foundation, www.python.org | |
59 | # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu> |
|
59 | # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu> | |
60 | # |
|
60 | # | |
61 | # Distributed under the terms of the BSD License. The full license is in |
|
61 | # Distributed under the terms of the BSD License. The full license is in | |
62 | # the file COPYING, distributed as part of this software. |
|
62 | # the file COPYING, distributed as part of this software. | |
63 | # |
|
63 | # | |
64 | #***************************************************************************** |
|
64 | #***************************************************************************** | |
65 |
|
65 | |||
66 | import __builtin__ |
|
66 | import __builtin__ | |
67 | import __main__ |
|
67 | import __main__ | |
68 | import glob |
|
68 | import glob | |
69 | import keyword |
|
69 | import keyword | |
70 | import os |
|
70 | import os | |
71 | import re |
|
71 | import re | |
72 | import readline |
|
72 | import readline | |
73 | import sys |
|
73 | import sys | |
74 | import types |
|
74 | import types | |
75 |
|
75 | |||
76 | from IPython.genutils import shlex_split |
|
76 | from IPython.genutils import shlex_split | |
77 |
|
77 | |||
78 | __all__ = ['Completer','IPCompleter'] |
|
78 | __all__ = ['Completer','IPCompleter'] | |
79 |
|
79 | |||
80 | def get_class_members(cls): |
|
80 | def get_class_members(cls): | |
81 | ret = dir(cls) |
|
81 | ret = dir(cls) | |
82 | if hasattr(cls,'__bases__'): |
|
82 | if hasattr(cls,'__bases__'): | |
83 | for base in cls.__bases__: |
|
83 | for base in cls.__bases__: | |
84 | ret.extend(get_class_members(base)) |
|
84 | ret.extend(get_class_members(base)) | |
85 | return ret |
|
85 | return ret | |
86 |
|
86 | |||
87 | class Completer: |
|
87 | class Completer: | |
88 | def __init__(self,namespace=None,global_namespace=None): |
|
88 | def __init__(self,namespace=None,global_namespace=None): | |
89 | """Create a new completer for the command line. |
|
89 | """Create a new completer for the command line. | |
90 |
|
90 | |||
91 | Completer([namespace,global_namespace]) -> completer instance. |
|
91 | Completer([namespace,global_namespace]) -> completer instance. | |
92 |
|
92 | |||
93 | If unspecified, the default namespace where completions are performed |
|
93 | If unspecified, the default namespace where completions are performed | |
94 | is __main__ (technically, __main__.__dict__). Namespaces should be |
|
94 | is __main__ (technically, __main__.__dict__). Namespaces should be | |
95 | given as dictionaries. |
|
95 | given as dictionaries. | |
96 |
|
96 | |||
97 | An optional second namespace can be given. This allows the completer |
|
97 | An optional second namespace can be given. This allows the completer | |
98 | to handle cases where both the local and global scopes need to be |
|
98 | to handle cases where both the local and global scopes need to be | |
99 | distinguished. |
|
99 | distinguished. | |
100 |
|
100 | |||
101 | Completer instances should be used as the completion mechanism of |
|
101 | Completer instances should be used as the completion mechanism of | |
102 | readline via the set_completer() call: |
|
102 | readline via the set_completer() call: | |
103 |
|
103 | |||
104 | readline.set_completer(Completer(my_namespace).complete) |
|
104 | readline.set_completer(Completer(my_namespace).complete) | |
105 | """ |
|
105 | """ | |
106 |
|
106 | |||
107 | # some minimal strict typechecks. For some core data structures, I |
|
107 | # some minimal strict typechecks. For some core data structures, I | |
108 | # want actual basic python types, not just anything that looks like |
|
108 | # want actual basic python types, not just anything that looks like | |
109 | # one. This is especially true for namespaces. |
|
109 | # one. This is especially true for namespaces. | |
110 | for ns in (namespace,global_namespace): |
|
110 | for ns in (namespace,global_namespace): | |
111 | if ns is not None and type(ns) != types.DictType: |
|
111 | if ns is not None and type(ns) != types.DictType: | |
112 | raise TypeError,'namespace must be a dictionary' |
|
112 | raise TypeError,'namespace must be a dictionary' | |
113 |
|
113 | |||
114 | # Don't bind to namespace quite yet, but flag whether the user wants a |
|
114 | # Don't bind to namespace quite yet, but flag whether the user wants a | |
115 | # specific namespace or to use __main__.__dict__. This will allow us |
|
115 | # specific namespace or to use __main__.__dict__. This will allow us | |
116 | # to bind to __main__.__dict__ at completion time, not now. |
|
116 | # to bind to __main__.__dict__ at completion time, not now. | |
117 | if namespace is None: |
|
117 | if namespace is None: | |
118 | self.use_main_ns = 1 |
|
118 | self.use_main_ns = 1 | |
119 | else: |
|
119 | else: | |
120 | self.use_main_ns = 0 |
|
120 | self.use_main_ns = 0 | |
121 | self.namespace = namespace |
|
121 | self.namespace = namespace | |
122 |
|
122 | |||
123 | # The global namespace, if given, can be bound directly |
|
123 | # The global namespace, if given, can be bound directly | |
124 | if global_namespace is None: |
|
124 | if global_namespace is None: | |
125 | self.global_namespace = {} |
|
125 | self.global_namespace = {} | |
126 | else: |
|
126 | else: | |
127 | self.global_namespace = global_namespace |
|
127 | self.global_namespace = global_namespace | |
128 |
|
128 | |||
129 | def complete(self, text, state): |
|
129 | def complete(self, text, state): | |
130 | """Return the next possible completion for 'text'. |
|
130 | """Return the next possible completion for 'text'. | |
131 |
|
131 | |||
132 | This is called successively with state == 0, 1, 2, ... until it |
|
132 | This is called successively with state == 0, 1, 2, ... until it | |
133 | returns None. The completion should begin with 'text'. |
|
133 | returns None. The completion should begin with 'text'. | |
134 |
|
134 | |||
135 | """ |
|
135 | """ | |
136 | if self.use_main_ns: |
|
136 | if self.use_main_ns: | |
137 | self.namespace = __main__.__dict__ |
|
137 | self.namespace = __main__.__dict__ | |
138 |
|
138 | |||
139 | if state == 0: |
|
139 | if state == 0: | |
140 | if "." in text: |
|
140 | if "." in text: | |
141 | self.matches = self.attr_matches(text) |
|
141 | self.matches = self.attr_matches(text) | |
142 | else: |
|
142 | else: | |
143 | self.matches = self.global_matches(text) |
|
143 | self.matches = self.global_matches(text) | |
144 | try: |
|
144 | try: | |
145 | return self.matches[state] |
|
145 | return self.matches[state] | |
146 | except IndexError: |
|
146 | except IndexError: | |
147 | return None |
|
147 | return None | |
148 |
|
148 | |||
149 | def global_matches(self, text): |
|
149 | def global_matches(self, text): | |
150 | """Compute matches when text is a simple name. |
|
150 | """Compute matches when text is a simple name. | |
151 |
|
151 | |||
152 | Return a list of all keywords, built-in functions and names currently |
|
152 | Return a list of all keywords, built-in functions and names currently | |
153 | defined in self.namespace or self.global_namespace that match. |
|
153 | defined in self.namespace or self.global_namespace that match. | |
154 |
|
154 | |||
155 | """ |
|
155 | """ | |
156 | matches = [] |
|
156 | matches = [] | |
157 | match_append = matches.append |
|
157 | match_append = matches.append | |
158 | n = len(text) |
|
158 | n = len(text) | |
159 | for lst in [keyword.kwlist, |
|
159 | for lst in [keyword.kwlist, | |
160 | __builtin__.__dict__.keys(), |
|
160 | __builtin__.__dict__.keys(), | |
161 | self.namespace.keys(), |
|
161 | self.namespace.keys(), | |
162 | self.global_namespace.keys()]: |
|
162 | self.global_namespace.keys()]: | |
163 | for word in lst: |
|
163 | for word in lst: | |
164 | if word[:n] == text and word != "__builtins__": |
|
164 | if word[:n] == text and word != "__builtins__": | |
165 | match_append(word) |
|
165 | match_append(word) | |
166 | return matches |
|
166 | return matches | |
167 |
|
167 | |||
168 | def attr_matches(self, text): |
|
168 | def attr_matches(self, text): | |
169 | """Compute matches when text contains a dot. |
|
169 | """Compute matches when text contains a dot. | |
170 |
|
170 | |||
171 | Assuming the text is of the form NAME.NAME....[NAME], and is |
|
171 | Assuming the text is of the form NAME.NAME....[NAME], and is | |
172 | evaluatable in self.namespace or self.global_namespace, it will be |
|
172 | evaluatable in self.namespace or self.global_namespace, it will be | |
173 | evaluated and its attributes (as revealed by dir()) are used as |
|
173 | evaluated and its attributes (as revealed by dir()) are used as | |
174 | possible completions. (For class instances, class members are are |
|
174 | possible completions. (For class instances, class members are are | |
175 | also considered.) |
|
175 | also considered.) | |
176 |
|
176 | |||
177 | WARNING: this can still invoke arbitrary C code, if an object |
|
177 | WARNING: this can still invoke arbitrary C code, if an object | |
178 | with a __getattr__ hook is evaluated. |
|
178 | with a __getattr__ hook is evaluated. | |
179 |
|
179 | |||
180 | """ |
|
180 | """ | |
181 | import re |
|
181 | import re | |
182 |
|
182 | |||
183 | # Another option, seems to work great. Catches things like ''.<tab> |
|
183 | # Another option, seems to work great. Catches things like ''.<tab> | |
184 | m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text) |
|
184 | m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text) | |
185 |
|
185 | |||
186 | if not m: |
|
186 | if not m: | |
187 | return [] |
|
187 | return [] | |
188 |
|
188 | |||
189 | expr, attr = m.group(1, 3) |
|
189 | expr, attr = m.group(1, 3) | |
190 | try: |
|
190 | try: | |
191 | object = eval(expr, self.namespace) |
|
191 | object = eval(expr, self.namespace) | |
192 | except: |
|
192 | except: | |
193 | object = eval(expr, self.global_namespace) |
|
193 | object = eval(expr, self.global_namespace) | |
194 |
|
194 | |||
195 | # for modules which define __all__, complete only on those. |
|
195 | words = dir(object) | |
196 |
if |
|
196 | if hasattr(object,'__class__'): | |
197 |
words |
|
197 | words.append('__class__') | |
198 | else: |
|
198 | words.extend(get_class_members(object.__class__)) | |
199 | words = dir(object) |
|
|||
200 | if hasattr(object,'__class__'): |
|
|||
201 | words.append('__class__') |
|
|||
202 | words.extend(get_class_members(object.__class__)) |
|
|||
203 |
|
199 | |||
204 | # filter out non-string attributes which may be stuffed by dir() calls |
|
200 | # filter out non-string attributes which may be stuffed by dir() calls | |
205 | # and poor coding in third-party modules |
|
201 | # and poor coding in third-party modules | |
206 | words = [w for w in words |
|
202 | words = [w for w in words | |
207 | if isinstance(w, basestring) and w != "__builtins__"] |
|
203 | if isinstance(w, basestring) and w != "__builtins__"] | |
208 | # Build match list to return |
|
204 | # Build match list to return | |
209 | n = len(attr) |
|
205 | n = len(attr) | |
210 | return ["%s.%s" % (expr, w) for w in words if w[:n] == attr ] |
|
206 | return ["%s.%s" % (expr, w) for w in words if w[:n] == attr ] | |
211 |
|
207 | |||
212 | class IPCompleter(Completer): |
|
208 | class IPCompleter(Completer): | |
213 | """Extension of the completer class with IPython-specific features""" |
|
209 | """Extension of the completer class with IPython-specific features""" | |
214 |
|
210 | |||
215 | def __init__(self,shell,namespace=None,global_namespace=None, |
|
211 | def __init__(self,shell,namespace=None,global_namespace=None, | |
216 | omit__names=0,alias_table=None): |
|
212 | omit__names=0,alias_table=None): | |
217 | """IPCompleter() -> completer |
|
213 | """IPCompleter() -> completer | |
218 |
|
214 | |||
219 | Return a completer object suitable for use by the readline library |
|
215 | Return a completer object suitable for use by the readline library | |
220 | via readline.set_completer(). |
|
216 | via readline.set_completer(). | |
221 |
|
217 | |||
222 | Inputs: |
|
218 | Inputs: | |
223 |
|
219 | |||
224 | - shell: a pointer to the ipython shell itself. This is needed |
|
220 | - shell: a pointer to the ipython shell itself. This is needed | |
225 | because this completer knows about magic functions, and those can |
|
221 | because this completer knows about magic functions, and those can | |
226 | only be accessed via the ipython instance. |
|
222 | only be accessed via the ipython instance. | |
227 |
|
223 | |||
228 | - namespace: an optional dict where completions are performed. |
|
224 | - namespace: an optional dict where completions are performed. | |
229 |
|
225 | |||
230 | - global_namespace: secondary optional dict for completions, to |
|
226 | - global_namespace: secondary optional dict for completions, to | |
231 | handle cases (such as IPython embedded inside functions) where |
|
227 | handle cases (such as IPython embedded inside functions) where | |
232 | both Python scopes are visible. |
|
228 | both Python scopes are visible. | |
233 |
|
229 | |||
234 | - The optional omit__names parameter sets the completer to omit the |
|
230 | - The optional omit__names parameter sets the completer to omit the | |
235 | 'magic' names (__magicname__) for python objects unless the text |
|
231 | 'magic' names (__magicname__) for python objects unless the text | |
236 | to be completed explicitly starts with one or more underscores. |
|
232 | to be completed explicitly starts with one or more underscores. | |
237 |
|
233 | |||
238 | - If alias_table is supplied, it should be a dictionary of aliases |
|
234 | - If alias_table is supplied, it should be a dictionary of aliases | |
239 | to complete. """ |
|
235 | to complete. """ | |
240 |
|
236 | |||
241 | Completer.__init__(self,namespace,global_namespace) |
|
237 | Completer.__init__(self,namespace,global_namespace) | |
242 | self.magic_prefix = shell.name+'.magic_' |
|
238 | self.magic_prefix = shell.name+'.magic_' | |
243 | self.magic_escape = shell.ESC_MAGIC |
|
239 | self.magic_escape = shell.ESC_MAGIC | |
244 | self.readline = readline |
|
240 | self.readline = readline | |
245 | delims = self.readline.get_completer_delims() |
|
241 | delims = self.readline.get_completer_delims() | |
246 | delims = delims.replace(self.magic_escape,'') |
|
242 | delims = delims.replace(self.magic_escape,'') | |
247 | self.readline.set_completer_delims(delims) |
|
243 | self.readline.set_completer_delims(delims) | |
248 | self.get_line_buffer = self.readline.get_line_buffer |
|
244 | self.get_line_buffer = self.readline.get_line_buffer | |
249 | self.omit__names = omit__names |
|
245 | self.omit__names = omit__names | |
250 | self.merge_completions = shell.rc.readline_merge_completions |
|
246 | self.merge_completions = shell.rc.readline_merge_completions | |
251 |
|
247 | |||
252 | if alias_table is None: |
|
248 | if alias_table is None: | |
253 | alias_table = {} |
|
249 | alias_table = {} | |
254 | self.alias_table = alias_table |
|
250 | self.alias_table = alias_table | |
255 | # Regexp to split filenames with spaces in them |
|
251 | # Regexp to split filenames with spaces in them | |
256 | self.space_name_re = re.compile(r'([^\\] )') |
|
252 | self.space_name_re = re.compile(r'([^\\] )') | |
257 | # Hold a local ref. to glob.glob for speed |
|
253 | # Hold a local ref. to glob.glob for speed | |
258 | self.glob = glob.glob |
|
254 | self.glob = glob.glob | |
259 |
|
255 | |||
260 | # Determine if we are running on 'dumb' terminals, like (X)Emacs |
|
256 | # Determine if we are running on 'dumb' terminals, like (X)Emacs | |
261 | # buffers, to avoid completion problems. |
|
257 | # buffers, to avoid completion problems. | |
262 | term = os.environ.get('TERM','xterm') |
|
258 | term = os.environ.get('TERM','xterm') | |
263 | self.dumb_terminal = term in ['dumb','emacs'] |
|
259 | self.dumb_terminal = term in ['dumb','emacs'] | |
264 |
|
260 | |||
265 | # Special handling of backslashes needed in win32 platforms |
|
261 | # Special handling of backslashes needed in win32 platforms | |
266 | if sys.platform == "win32": |
|
262 | if sys.platform == "win32": | |
267 | self.clean_glob = self._clean_glob_win32 |
|
263 | self.clean_glob = self._clean_glob_win32 | |
268 | else: |
|
264 | else: | |
269 | self.clean_glob = self._clean_glob |
|
265 | self.clean_glob = self._clean_glob | |
270 | self.matchers = [self.python_matches, |
|
266 | self.matchers = [self.python_matches, | |
271 | self.file_matches, |
|
267 | self.file_matches, | |
272 | self.alias_matches, |
|
268 | self.alias_matches, | |
273 | self.python_func_kw_matches] |
|
269 | self.python_func_kw_matches] | |
274 |
|
270 | |||
275 | # Code contributed by Alex Schmolck, for ipython/emacs integration |
|
271 | # Code contributed by Alex Schmolck, for ipython/emacs integration | |
276 | def all_completions(self, text): |
|
272 | def all_completions(self, text): | |
277 | """Return all possible completions for the benefit of emacs.""" |
|
273 | """Return all possible completions for the benefit of emacs.""" | |
278 |
|
274 | |||
279 | completions = [] |
|
275 | completions = [] | |
280 | comp_append = completions.append |
|
276 | comp_append = completions.append | |
281 | try: |
|
277 | try: | |
282 | for i in xrange(sys.maxint): |
|
278 | for i in xrange(sys.maxint): | |
283 | res = self.complete(text, i) |
|
279 | res = self.complete(text, i) | |
284 |
|
280 | |||
285 | if not res: break |
|
281 | if not res: break | |
286 |
|
282 | |||
287 | comp_append(res) |
|
283 | comp_append(res) | |
288 | #XXX workaround for ``notDefined.<tab>`` |
|
284 | #XXX workaround for ``notDefined.<tab>`` | |
289 | except NameError: |
|
285 | except NameError: | |
290 | pass |
|
286 | pass | |
291 | return completions |
|
287 | return completions | |
292 | # /end Alex Schmolck code. |
|
288 | # /end Alex Schmolck code. | |
293 |
|
289 | |||
294 | def _clean_glob(self,text): |
|
290 | def _clean_glob(self,text): | |
295 | return self.glob("%s*" % text) |
|
291 | return self.glob("%s*" % text) | |
296 |
|
292 | |||
297 | def _clean_glob_win32(self,text): |
|
293 | def _clean_glob_win32(self,text): | |
298 | return [f.replace("\\","/") |
|
294 | return [f.replace("\\","/") | |
299 | for f in self.glob("%s*" % text)] |
|
295 | for f in self.glob("%s*" % text)] | |
300 |
|
296 | |||
301 | def file_matches(self, text): |
|
297 | def file_matches(self, text): | |
302 | """Match filneames, expanding ~USER type strings. |
|
298 | """Match filneames, expanding ~USER type strings. | |
303 |
|
299 | |||
304 | Most of the seemingly convoluted logic in this completer is an |
|
300 | Most of the seemingly convoluted logic in this completer is an | |
305 | attempt to handle filenames with spaces in them. And yet it's not |
|
301 | attempt to handle filenames with spaces in them. And yet it's not | |
306 | quite perfect, because Python's readline doesn't expose all of the |
|
302 | quite perfect, because Python's readline doesn't expose all of the | |
307 | GNU readline details needed for this to be done correctly. |
|
303 | GNU readline details needed for this to be done correctly. | |
308 |
|
304 | |||
309 | For a filename with a space in it, the printed completions will be |
|
305 | For a filename with a space in it, the printed completions will be | |
310 | only the parts after what's already been typed (instead of the |
|
306 | only the parts after what's already been typed (instead of the | |
311 | full completions, as is normally done). I don't think with the |
|
307 | full completions, as is normally done). I don't think with the | |
312 | current (as of Python 2.3) Python readline it's possible to do |
|
308 | current (as of Python 2.3) Python readline it's possible to do | |
313 | better.""" |
|
309 | better.""" | |
314 |
|
310 | |||
315 | #print 'Completer->file_matches: <%s>' % text # dbg |
|
311 | #print 'Completer->file_matches: <%s>' % text # dbg | |
316 |
|
312 | |||
317 | # chars that require escaping with backslash - i.e. chars |
|
313 | # chars that require escaping with backslash - i.e. chars | |
318 | # that readline treats incorrectly as delimiters, but we |
|
314 | # that readline treats incorrectly as delimiters, but we | |
319 | # don't want to treat as delimiters in filename matching |
|
315 | # don't want to treat as delimiters in filename matching | |
320 | # when escaped with backslash |
|
316 | # when escaped with backslash | |
321 |
|
317 | |||
322 | protectables = ' ()[]{}' |
|
318 | protectables = ' ()[]{}' | |
323 |
|
319 | |||
324 | def protect_filename(s): |
|
320 | def protect_filename(s): | |
325 | return "".join([(ch in protectables and '\\' + ch or ch) |
|
321 | return "".join([(ch in protectables and '\\' + ch or ch) | |
326 | for ch in s]) |
|
322 | for ch in s]) | |
327 |
|
323 | |||
328 | lbuf = self.get_line_buffer()[:self.readline.get_endidx()] |
|
324 | lbuf = self.get_line_buffer()[:self.readline.get_endidx()] | |
329 | open_quotes = 0 # track strings with open quotes |
|
325 | open_quotes = 0 # track strings with open quotes | |
330 | try: |
|
326 | try: | |
331 | lsplit = shlex_split(lbuf)[-1] |
|
327 | lsplit = shlex_split(lbuf)[-1] | |
332 | except ValueError: |
|
328 | except ValueError: | |
333 | # typically an unmatched ", or backslash without escaped char. |
|
329 | # typically an unmatched ", or backslash without escaped char. | |
334 | if lbuf.count('"')==1: |
|
330 | if lbuf.count('"')==1: | |
335 | open_quotes = 1 |
|
331 | open_quotes = 1 | |
336 | lsplit = lbuf.split('"')[-1] |
|
332 | lsplit = lbuf.split('"')[-1] | |
337 | elif lbuf.count("'")==1: |
|
333 | elif lbuf.count("'")==1: | |
338 | open_quotes = 1 |
|
334 | open_quotes = 1 | |
339 | lsplit = lbuf.split("'")[-1] |
|
335 | lsplit = lbuf.split("'")[-1] | |
340 | else: |
|
336 | else: | |
341 | return None |
|
337 | return None | |
342 | except IndexError: |
|
338 | except IndexError: | |
343 | # tab pressed on empty line |
|
339 | # tab pressed on empty line | |
344 | lsplit = "" |
|
340 | lsplit = "" | |
345 |
|
341 | |||
346 | if lsplit != protect_filename(lsplit): |
|
342 | if lsplit != protect_filename(lsplit): | |
347 | # if protectables are found, do matching on the whole escaped |
|
343 | # if protectables are found, do matching on the whole escaped | |
348 | # name |
|
344 | # name | |
349 | has_protectables = 1 |
|
345 | has_protectables = 1 | |
350 | text0,text = text,lsplit |
|
346 | text0,text = text,lsplit | |
351 | else: |
|
347 | else: | |
352 | has_protectables = 0 |
|
348 | has_protectables = 0 | |
353 | text = os.path.expanduser(text) |
|
349 | text = os.path.expanduser(text) | |
354 |
|
350 | |||
355 | if text == "": |
|
351 | if text == "": | |
356 | return [protect_filename(f) for f in self.glob("*")] |
|
352 | return [protect_filename(f) for f in self.glob("*")] | |
357 |
|
353 | |||
358 | m0 = self.clean_glob(text.replace('\\','')) |
|
354 | m0 = self.clean_glob(text.replace('\\','')) | |
359 | if has_protectables: |
|
355 | if has_protectables: | |
360 | # If we had protectables, we need to revert our changes to the |
|
356 | # If we had protectables, we need to revert our changes to the | |
361 | # beginning of filename so that we don't double-write the part |
|
357 | # beginning of filename so that we don't double-write the part | |
362 | # of the filename we have so far |
|
358 | # of the filename we have so far | |
363 | len_lsplit = len(lsplit) |
|
359 | len_lsplit = len(lsplit) | |
364 | matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0] |
|
360 | matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0] | |
365 | else: |
|
361 | else: | |
366 | if open_quotes: |
|
362 | if open_quotes: | |
367 | # if we have a string with an open quote, we don't need to |
|
363 | # if we have a string with an open quote, we don't need to | |
368 | # protect the names at all (and we _shouldn't_, as it |
|
364 | # protect the names at all (and we _shouldn't_, as it | |
369 | # would cause bugs when the filesystem call is made). |
|
365 | # would cause bugs when the filesystem call is made). | |
370 | matches = m0 |
|
366 | matches = m0 | |
371 | else: |
|
367 | else: | |
372 | matches = [protect_filename(f) for f in m0] |
|
368 | matches = [protect_filename(f) for f in m0] | |
373 | if len(matches) == 1 and os.path.isdir(matches[0]): |
|
369 | if len(matches) == 1 and os.path.isdir(matches[0]): | |
374 | # Takes care of links to directories also. Use '/' |
|
370 | # Takes care of links to directories also. Use '/' | |
375 | # explicitly, even under Windows, so that name completions |
|
371 | # explicitly, even under Windows, so that name completions | |
376 | # don't end up escaped. |
|
372 | # don't end up escaped. | |
377 | matches[0] += '/' |
|
373 | matches[0] += '/' | |
378 | return matches |
|
374 | return matches | |
379 |
|
375 | |||
380 | def alias_matches(self, text): |
|
376 | def alias_matches(self, text): | |
381 | """Match internal system aliases""" |
|
377 | """Match internal system aliases""" | |
382 | #print 'Completer->alias_matches:',text # dbg |
|
378 | #print 'Completer->alias_matches:',text # dbg | |
383 | text = os.path.expanduser(text) |
|
379 | text = os.path.expanduser(text) | |
384 | aliases = self.alias_table.keys() |
|
380 | aliases = self.alias_table.keys() | |
385 | if text == "": |
|
381 | if text == "": | |
386 | return aliases |
|
382 | return aliases | |
387 | else: |
|
383 | else: | |
388 | return [alias for alias in aliases if alias.startswith(text)] |
|
384 | return [alias for alias in aliases if alias.startswith(text)] | |
389 |
|
385 | |||
390 | def python_matches(self,text): |
|
386 | def python_matches(self,text): | |
391 | """Match attributes or global python names""" |
|
387 | """Match attributes or global python names""" | |
392 | #print 'Completer->python_matches' # dbg |
|
388 | #print 'Completer->python_matches' # dbg | |
393 | if "." in text: |
|
389 | if "." in text: | |
394 | try: |
|
390 | try: | |
395 | matches = self.attr_matches(text) |
|
391 | matches = self.attr_matches(text) | |
396 | if text.endswith('.') and self.omit__names: |
|
392 | if text.endswith('.') and self.omit__names: | |
397 | if self.omit__names == 1: |
|
393 | if self.omit__names == 1: | |
398 | # true if txt is _not_ a __ name, false otherwise: |
|
394 | # true if txt is _not_ a __ name, false otherwise: | |
399 | no__name = (lambda txt: |
|
395 | no__name = (lambda txt: | |
400 | re.match(r'.*\.__.*?__',txt) is None) |
|
396 | re.match(r'.*\.__.*?__',txt) is None) | |
401 | else: |
|
397 | else: | |
402 | # true if txt is _not_ a _ name, false otherwise: |
|
398 | # true if txt is _not_ a _ name, false otherwise: | |
403 | no__name = (lambda txt: |
|
399 | no__name = (lambda txt: | |
404 | re.match(r'.*\._.*?',txt) is None) |
|
400 | re.match(r'.*\._.*?',txt) is None) | |
405 | matches = filter(no__name, matches) |
|
401 | matches = filter(no__name, matches) | |
406 | except NameError: |
|
402 | except NameError: | |
407 | # catches <undefined attributes>.<tab> |
|
403 | # catches <undefined attributes>.<tab> | |
408 | matches = [] |
|
404 | matches = [] | |
409 | else: |
|
405 | else: | |
410 | matches = self.global_matches(text) |
|
406 | matches = self.global_matches(text) | |
411 | # this is so completion finds magics when automagic is on: |
|
407 | # this is so completion finds magics when automagic is on: | |
412 | if matches == [] and not text.startswith(os.sep): |
|
408 | if matches == [] and not text.startswith(os.sep): | |
413 | matches = self.attr_matches(self.magic_prefix+text) |
|
409 | matches = self.attr_matches(self.magic_prefix+text) | |
414 | return matches |
|
410 | return matches | |
415 |
|
411 | |||
416 | def _default_arguments(self, obj): |
|
412 | def _default_arguments(self, obj): | |
417 | """Return the list of default arguments of obj if it is callable, |
|
413 | """Return the list of default arguments of obj if it is callable, | |
418 | or empty list otherwise.""" |
|
414 | or empty list otherwise.""" | |
419 |
|
415 | |||
420 | if not (inspect.isfunction(obj) or inspect.ismethod(obj)): |
|
416 | if not (inspect.isfunction(obj) or inspect.ismethod(obj)): | |
421 | # for classes, check for __init__,__new__ |
|
417 | # for classes, check for __init__,__new__ | |
422 | if inspect.isclass(obj): |
|
418 | if inspect.isclass(obj): | |
423 | obj = (getattr(obj,'__init__',None) or |
|
419 | obj = (getattr(obj,'__init__',None) or | |
424 | getattr(obj,'__new__',None)) |
|
420 | getattr(obj,'__new__',None)) | |
425 | # for all others, check if they are __call__able |
|
421 | # for all others, check if they are __call__able | |
426 | elif hasattr(obj, '__call__'): |
|
422 | elif hasattr(obj, '__call__'): | |
427 | obj = obj.__call__ |
|
423 | obj = obj.__call__ | |
428 | # XXX: is there a way to handle the builtins ? |
|
424 | # XXX: is there a way to handle the builtins ? | |
429 | try: |
|
425 | try: | |
430 | args,_,_1,defaults = inspect.getargspec(obj) |
|
426 | args,_,_1,defaults = inspect.getargspec(obj) | |
431 | if defaults: |
|
427 | if defaults: | |
432 | return args[-len(defaults):] |
|
428 | return args[-len(defaults):] | |
433 | except TypeError: pass |
|
429 | except TypeError: pass | |
434 | return [] |
|
430 | return [] | |
435 |
|
431 | |||
436 | def python_func_kw_matches(self,text): |
|
432 | def python_func_kw_matches(self,text): | |
437 | """Match named parameters (kwargs) of the last open function""" |
|
433 | """Match named parameters (kwargs) of the last open function""" | |
438 |
|
434 | |||
439 | if "." in text: # a parameter cannot be dotted |
|
435 | if "." in text: # a parameter cannot be dotted | |
440 | return [] |
|
436 | return [] | |
441 | try: regexp = self.__funcParamsRegex |
|
437 | try: regexp = self.__funcParamsRegex | |
442 | except AttributeError: |
|
438 | except AttributeError: | |
443 | regexp = self.__funcParamsRegex = re.compile(r''' |
|
439 | regexp = self.__funcParamsRegex = re.compile(r''' | |
444 | '.*?' | # single quoted strings or |
|
440 | '.*?' | # single quoted strings or | |
445 | ".*?" | # double quoted strings or |
|
441 | ".*?" | # double quoted strings or | |
446 | \w+ | # identifier |
|
442 | \w+ | # identifier | |
447 | \S # other characters |
|
443 | \S # other characters | |
448 | ''', re.VERBOSE | re.DOTALL) |
|
444 | ''', re.VERBOSE | re.DOTALL) | |
449 | # 1. find the nearest identifier that comes before an unclosed |
|
445 | # 1. find the nearest identifier that comes before an unclosed | |
450 | # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo" |
|
446 | # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo" | |
451 | tokens = regexp.findall(self.get_line_buffer()) |
|
447 | tokens = regexp.findall(self.get_line_buffer()) | |
452 | tokens.reverse() |
|
448 | tokens.reverse() | |
453 | iterTokens = iter(tokens); openPar = 0 |
|
449 | iterTokens = iter(tokens); openPar = 0 | |
454 | for token in iterTokens: |
|
450 | for token in iterTokens: | |
455 | if token == ')': |
|
451 | if token == ')': | |
456 | openPar -= 1 |
|
452 | openPar -= 1 | |
457 | elif token == '(': |
|
453 | elif token == '(': | |
458 | openPar += 1 |
|
454 | openPar += 1 | |
459 | if openPar > 0: |
|
455 | if openPar > 0: | |
460 | # found the last unclosed parenthesis |
|
456 | # found the last unclosed parenthesis | |
461 | break |
|
457 | break | |
462 | else: |
|
458 | else: | |
463 | return [] |
|
459 | return [] | |
464 | # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" ) |
|
460 | # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" ) | |
465 | ids = [] |
|
461 | ids = [] | |
466 | isId = re.compile(r'\w+$').match |
|
462 | isId = re.compile(r'\w+$').match | |
467 | while True: |
|
463 | while True: | |
468 | try: |
|
464 | try: | |
469 | ids.append(iterTokens.next()) |
|
465 | ids.append(iterTokens.next()) | |
470 | if not isId(ids[-1]): |
|
466 | if not isId(ids[-1]): | |
471 | ids.pop(); break |
|
467 | ids.pop(); break | |
472 | if not iterTokens.next() == '.': |
|
468 | if not iterTokens.next() == '.': | |
473 | break |
|
469 | break | |
474 | except StopIteration: |
|
470 | except StopIteration: | |
475 | break |
|
471 | break | |
476 | # lookup the candidate callable matches either using global_matches |
|
472 | # lookup the candidate callable matches either using global_matches | |
477 | # or attr_matches for dotted names |
|
473 | # or attr_matches for dotted names | |
478 | if len(ids) == 1: |
|
474 | if len(ids) == 1: | |
479 | callableMatches = self.global_matches(ids[0]) |
|
475 | callableMatches = self.global_matches(ids[0]) | |
480 | else: |
|
476 | else: | |
481 | callableMatches = self.attr_matches('.'.join(ids[::-1])) |
|
477 | callableMatches = self.attr_matches('.'.join(ids[::-1])) | |
482 | argMatches = [] |
|
478 | argMatches = [] | |
483 | for callableMatch in callableMatches: |
|
479 | for callableMatch in callableMatches: | |
484 | try: namedArgs = self._default_arguments(eval(callableMatch, |
|
480 | try: namedArgs = self._default_arguments(eval(callableMatch, | |
485 | self.namespace)) |
|
481 | self.namespace)) | |
486 | except: continue |
|
482 | except: continue | |
487 | for namedArg in namedArgs: |
|
483 | for namedArg in namedArgs: | |
488 | if namedArg.startswith(text): |
|
484 | if namedArg.startswith(text): | |
489 | argMatches.append("%s=" %namedArg) |
|
485 | argMatches.append("%s=" %namedArg) | |
490 | return argMatches |
|
486 | return argMatches | |
491 |
|
487 | |||
492 | def complete(self, text, state): |
|
488 | def complete(self, text, state): | |
493 | """Return the next possible completion for 'text'. |
|
489 | """Return the next possible completion for 'text'. | |
494 |
|
490 | |||
495 | This is called successively with state == 0, 1, 2, ... until it |
|
491 | This is called successively with state == 0, 1, 2, ... until it | |
496 | returns None. The completion should begin with 'text'. """ |
|
492 | returns None. The completion should begin with 'text'. """ | |
497 |
|
493 | |||
498 | #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg |
|
494 | #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg | |
499 |
|
495 | |||
500 | # if there is only a tab on a line with only whitespace, instead |
|
496 | # if there is only a tab on a line with only whitespace, instead | |
501 | # of the mostly useless 'do you want to see all million |
|
497 | # of the mostly useless 'do you want to see all million | |
502 | # completions' message, just do the right thing and give the user |
|
498 | # completions' message, just do the right thing and give the user | |
503 | # his tab! Incidentally, this enables pasting of tabbed text from |
|
499 | # his tab! Incidentally, this enables pasting of tabbed text from | |
504 | # an editor (as long as autoindent is off). |
|
500 | # an editor (as long as autoindent is off). | |
505 |
|
501 | |||
506 | # don't apply this on 'dumb' terminals, such as emacs buffers, so we |
|
502 | # don't apply this on 'dumb' terminals, such as emacs buffers, so we | |
507 | # don't interfere with their own tab-completion mechanism. |
|
503 | # don't interfere with their own tab-completion mechanism. | |
508 | if not (self.dumb_terminal or self.get_line_buffer().strip()): |
|
504 | if not (self.dumb_terminal or self.get_line_buffer().strip()): | |
509 | self.readline.insert_text('\t') |
|
505 | self.readline.insert_text('\t') | |
510 | return None |
|
506 | return None | |
511 |
|
507 | |||
512 | magic_escape = self.magic_escape |
|
508 | magic_escape = self.magic_escape | |
513 | magic_prefix = self.magic_prefix |
|
509 | magic_prefix = self.magic_prefix | |
514 |
|
510 | |||
515 | try: |
|
511 | try: | |
516 | if text.startswith(magic_escape): |
|
512 | if text.startswith(magic_escape): | |
517 | text = text.replace(magic_escape,magic_prefix) |
|
513 | text = text.replace(magic_escape,magic_prefix) | |
518 | elif text.startswith('~'): |
|
514 | elif text.startswith('~'): | |
519 | text = os.path.expanduser(text) |
|
515 | text = os.path.expanduser(text) | |
520 | if state == 0: |
|
516 | if state == 0: | |
521 | # Extend the list of completions with the results of each |
|
517 | # Extend the list of completions with the results of each | |
522 | # matcher, so we return results to the user from all |
|
518 | # matcher, so we return results to the user from all | |
523 | # namespaces. |
|
519 | # namespaces. | |
524 | if self.merge_completions: |
|
520 | if self.merge_completions: | |
525 | self.matches = [] |
|
521 | self.matches = [] | |
526 | for matcher in self.matchers: |
|
522 | for matcher in self.matchers: | |
527 | self.matches.extend(matcher(text)) |
|
523 | self.matches.extend(matcher(text)) | |
528 | else: |
|
524 | else: | |
529 | for matcher in self.matchers: |
|
525 | for matcher in self.matchers: | |
530 | self.matches = matcher(text) |
|
526 | self.matches = matcher(text) | |
531 | if self.matches: |
|
527 | if self.matches: | |
532 | break |
|
528 | break | |
533 |
|
529 | |||
534 | try: |
|
530 | try: | |
535 | return self.matches[state].replace(magic_prefix,magic_escape) |
|
531 | return self.matches[state].replace(magic_prefix,magic_escape) | |
536 | except IndexError: |
|
532 | except IndexError: | |
537 | return None |
|
533 | return None | |
538 | except: |
|
534 | except: | |
539 | #from IPython.ultraTB import AutoFormattedTB; # dbg |
|
535 | #from IPython.ultraTB import AutoFormattedTB; # dbg | |
540 | #tb=AutoFormattedTB('Verbose');tb() #dbg |
|
536 | #tb=AutoFormattedTB('Verbose');tb() #dbg | |
541 |
|
537 | |||
542 | # If completion fails, don't annoy the user. |
|
538 | # If completion fails, don't annoy the user. | |
543 | return None |
|
539 | return None |
@@ -1,95 +1,95 b'' | |||||
1 | """hooks for IPython. |
|
1 | """hooks for IPython. | |
2 |
|
2 | |||
3 | In Python, it is possible to overwrite any method of any object if you really |
|
3 | In Python, it is possible to overwrite any method of any object if you really | |
4 | want to. But IPython exposes a few 'hooks', methods which are _designed_ to |
|
4 | want to. But IPython exposes a few 'hooks', methods which are _designed_ to | |
5 | be overwritten by users for customization purposes. This module defines the |
|
5 | be overwritten by users for customization purposes. This module defines the | |
6 | default versions of all such hooks, which get used by IPython if not |
|
6 | default versions of all such hooks, which get used by IPython if not | |
7 | overridden by the user. |
|
7 | overridden by the user. | |
8 |
|
8 | |||
9 | hooks are simple functions, but they should be declared with 'self' as their |
|
9 | hooks are simple functions, but they should be declared with 'self' as their | |
10 | first argument, because when activated they are registered into IPython as |
|
10 | first argument, because when activated they are registered into IPython as | |
11 | instance methods. The self argument will be the IPython running instance |
|
11 | instance methods. The self argument will be the IPython running instance | |
12 | itself, so hooks have full access to the entire IPython object. |
|
12 | itself, so hooks have full access to the entire IPython object. | |
13 |
|
13 | |||
14 | If you wish to define a new hook and activate it, you need to put the |
|
14 | If you wish to define a new hook and activate it, you need to put the | |
15 | necessary code into a python file which can be either imported or execfile()'d |
|
15 | necessary code into a python file which can be either imported or execfile()'d | |
16 | from within your ipythonrc configuration. |
|
16 | from within your ipythonrc configuration. | |
17 |
|
17 | |||
18 | For example, suppose that you have a module called 'myiphooks' in your |
|
18 | For example, suppose that you have a module called 'myiphooks' in your | |
19 | PYTHONPATH, which contains the following definition: |
|
19 | PYTHONPATH, which contains the following definition: | |
20 |
|
20 | |||
21 | import os |
|
21 | import os | |
22 | def calljed(self,filename, linenum): |
|
22 | def calljed(self,filename, linenum): | |
23 | "My editor hook calls the jed editor directly." |
|
23 | "My editor hook calls the jed editor directly." | |
24 | print "Calling my own editor, jed ..." |
|
24 | print "Calling my own editor, jed ..." | |
25 | os.system('jed +%d %s' % (linenum,filename)) |
|
25 | os.system('jed +%d %s' % (linenum,filename)) | |
26 |
|
26 | |||
27 | You can then execute the following line of code to make it the new IPython |
|
27 | You can then execute the following line of code to make it the new IPython | |
28 | editor hook, after having imported 'myiphooks': |
|
28 | editor hook, after having imported 'myiphooks': | |
29 |
|
29 | |||
30 | ip_set_hook('editor',myiphooks.calljed) |
|
30 | ip_set_hook('editor',myiphooks.calljed) | |
31 |
|
31 | |||
32 | The ip_set_hook function is put by IPython into the builtin namespace, so it |
|
32 | The ip_set_hook function is put by IPython into the builtin namespace, so it | |
33 | is always available from all running code. |
|
33 | is always available from all running code. | |
34 |
|
34 | |||
35 |
$Id: hooks.py 9 |
|
35 | $Id: hooks.py 988 2006-01-02 21:21:47Z fperez $""" | |
36 |
|
36 | |||
37 | #***************************************************************************** |
|
37 | #***************************************************************************** | |
38 | # Copyright (C) 2005 Fernando Perez. <fperez@colorado.edu> |
|
38 | # Copyright (C) 2005 Fernando Perez. <fperez@colorado.edu> | |
39 | # |
|
39 | # | |
40 | # Distributed under the terms of the BSD License. The full license is in |
|
40 | # Distributed under the terms of the BSD License. The full license is in | |
41 | # the file COPYING, distributed as part of this software. |
|
41 | # the file COPYING, distributed as part of this software. | |
42 | #***************************************************************************** |
|
42 | #***************************************************************************** | |
43 |
|
43 | |||
44 | from IPython import Release |
|
44 | from IPython import Release | |
45 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
45 | __author__ = '%s <%s>' % Release.authors['Fernando'] | |
46 | __license__ = Release.license |
|
46 | __license__ = Release.license | |
47 | __version__ = Release.version |
|
47 | __version__ = Release.version | |
48 |
|
48 | |||
49 | import os |
|
49 | import os | |
50 |
|
50 | |||
51 | # List here all the default hooks. For now it's just the editor functions |
|
51 | # List here all the default hooks. For now it's just the editor functions | |
52 | # but over time we'll move here all the public API for user-accessible things. |
|
52 | # but over time we'll move here all the public API for user-accessible things. | |
53 | __all__ = ['editor', 'fix_error_editor'] |
|
53 | __all__ = ['editor', 'fix_error_editor'] | |
54 |
|
54 | |||
55 | def editor(self,filename, linenum): |
|
55 | def editor(self,filename, linenum=None): | |
56 | """Open the default editor at the given filename and linenumber. |
|
56 | """Open the default editor at the given filename and linenumber. | |
57 |
|
57 | |||
58 | This is IPython's default editor hook, you can use it as an example to |
|
58 | This is IPython's default editor hook, you can use it as an example to | |
59 | write your own modified one. To set your own editor function as the |
|
59 | write your own modified one. To set your own editor function as the | |
60 | new editor hook, call ip_set_hook('editor',yourfunc).""" |
|
60 | new editor hook, call ip_set_hook('editor',yourfunc).""" | |
61 |
|
61 | |||
62 | # IPython configures a default editor at startup by reading $EDITOR from |
|
62 | # IPython configures a default editor at startup by reading $EDITOR from | |
63 | # the environment, and falling back on vi (unix) or notepad (win32). |
|
63 | # the environment, and falling back on vi (unix) or notepad (win32). | |
64 | editor = self.rc.editor |
|
64 | editor = self.rc.editor | |
65 |
|
65 | |||
66 | # marker for at which line to open the file (for existing objects) |
|
66 | # marker for at which line to open the file (for existing objects) | |
67 | if linenum is None or editor=='notepad': |
|
67 | if linenum is None or editor=='notepad': | |
68 | linemark = '' |
|
68 | linemark = '' | |
69 | else: |
|
69 | else: | |
70 | linemark = '+%d' % linenum |
|
70 | linemark = '+%d' % linenum | |
71 | # Call the actual editor |
|
71 | # Call the actual editor | |
72 | os.system('%s %s %s' % (editor,linemark,filename)) |
|
72 | os.system('%s %s %s' % (editor,linemark,filename)) | |
73 |
|
73 | |||
74 | import tempfile |
|
74 | import tempfile | |
75 | def fix_error_editor(self,filename,linenum,column,msg): |
|
75 | def fix_error_editor(self,filename,linenum,column,msg): | |
76 | """Open the editor at the given filename, linenumber, column and |
|
76 | """Open the editor at the given filename, linenumber, column and | |
77 | show an error message. This is used for correcting syntax errors. |
|
77 | show an error message. This is used for correcting syntax errors. | |
78 | The current implementation only has special support for the VIM editor, |
|
78 | The current implementation only has special support for the VIM editor, | |
79 | and falls back on the 'editor' hook if VIM is not used. |
|
79 | and falls back on the 'editor' hook if VIM is not used. | |
80 |
|
80 | |||
81 | Call ip_set_hook('fix_error_editor',youfunc) to use your own function, |
|
81 | Call ip_set_hook('fix_error_editor',youfunc) to use your own function, | |
82 | """ |
|
82 | """ | |
83 | def vim_quickfix_file(): |
|
83 | def vim_quickfix_file(): | |
84 | t = tempfile.NamedTemporaryFile() |
|
84 | t = tempfile.NamedTemporaryFile() | |
85 | t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg)) |
|
85 | t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg)) | |
86 | t.flush() |
|
86 | t.flush() | |
87 | return t |
|
87 | return t | |
88 | if os.path.basename(self.rc.editor) != 'vim': |
|
88 | if os.path.basename(self.rc.editor) != 'vim': | |
89 | self.hooks.editor(filename,linenum) |
|
89 | self.hooks.editor(filename,linenum) | |
90 | return |
|
90 | return | |
91 | t = vim_quickfix_file() |
|
91 | t = vim_quickfix_file() | |
92 | try: |
|
92 | try: | |
93 | os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name) |
|
93 | os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name) | |
94 | finally: |
|
94 | finally: | |
95 | t.close() |
|
95 | t.close() |
@@ -1,2065 +1,2138 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 98 |
|
9 | $Id: iplib.py 988 2006-01-02 21:21:47Z 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 tempfile | |||
58 | import traceback |
|
59 | import traceback | |
59 | import types |
|
60 | import types | |
60 |
|
61 | |||
61 | from pprint import pprint, pformat |
|
62 | from pprint import pprint, pformat | |
62 |
|
63 | |||
63 | # IPython's own modules |
|
64 | # IPython's own modules | |
64 | import IPython |
|
65 | import IPython | |
65 | from IPython import OInspect,PyColorize,ultraTB |
|
66 | from IPython import OInspect,PyColorize,ultraTB | |
66 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names |
|
67 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names | |
67 | from IPython.FakeModule import FakeModule |
|
68 | from IPython.FakeModule import FakeModule | |
68 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns |
|
69 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns | |
69 | from IPython.Logger import Logger |
|
70 | from IPython.Logger import Logger | |
70 | from IPython.Magic import Magic |
|
71 | from IPython.Magic import Magic | |
71 | from IPython.Prompts import CachedOutput |
|
72 | from IPython.Prompts import CachedOutput | |
72 | from IPython.Struct import Struct |
|
73 | from IPython.Struct import Struct | |
73 | from IPython.background_jobs import BackgroundJobManager |
|
74 | from IPython.background_jobs import BackgroundJobManager | |
74 | from IPython.usage import cmd_line_usage,interactive_usage |
|
75 | from IPython.usage import cmd_line_usage,interactive_usage | |
75 | from IPython.genutils import * |
|
76 | from IPython.genutils import * | |
76 |
|
77 | |||
77 | # store the builtin raw_input globally, and use this always, in case user code |
|
78 | # store the builtin raw_input globally, and use this always, in case user code | |
78 | # overwrites it (like wx.py.PyShell does) |
|
79 | # overwrites it (like wx.py.PyShell does) | |
79 | raw_input_original = raw_input |
|
80 | raw_input_original = raw_input | |
80 |
|
81 | |||
81 | # compiled regexps for autoindent management |
|
82 | # compiled regexps for autoindent management | |
82 | ini_spaces_re = re.compile(r'^(\s+)') |
|
83 | ini_spaces_re = re.compile(r'^(\s+)') | |
83 | dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') |
|
84 | dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') | |
84 |
|
85 | |||
85 | #**************************************************************************** |
|
86 | #**************************************************************************** | |
86 | # Some utility function definitions |
|
87 | # Some utility function definitions | |
87 |
|
88 | |||
88 | def softspace(file, newvalue): |
|
89 | def softspace(file, newvalue): | |
89 | """Copied from code.py, to remove the dependency""" |
|
90 | """Copied from code.py, to remove the dependency""" | |
90 | oldvalue = 0 |
|
91 | oldvalue = 0 | |
91 | try: |
|
92 | try: | |
92 | oldvalue = file.softspace |
|
93 | oldvalue = file.softspace | |
93 | except AttributeError: |
|
94 | except AttributeError: | |
94 | pass |
|
95 | pass | |
95 | try: |
|
96 | try: | |
96 | file.softspace = newvalue |
|
97 | file.softspace = newvalue | |
97 | except (AttributeError, TypeError): |
|
98 | except (AttributeError, TypeError): | |
98 | # "attribute-less object" or "read-only attributes" |
|
99 | # "attribute-less object" or "read-only attributes" | |
99 | pass |
|
100 | pass | |
100 | return oldvalue |
|
101 | return oldvalue | |
101 |
|
102 | |||
102 | #**************************************************************************** |
|
103 | #**************************************************************************** | |
103 | # These special functions get installed in the builtin namespace, to provide |
|
|||
104 | # programmatic (pure python) access to magics, aliases and system calls. This |
|
|||
105 | # is important for logging, user scripting, and more. |
|
|||
106 |
|
||||
107 | # We are basically exposing, via normal python functions, the three mechanisms |
|
|||
108 | # in which ipython offers special call modes (magics for internal control, |
|
|||
109 | # aliases for direct system access via pre-selected names, and !cmd for |
|
|||
110 | # calling arbitrary system commands). |
|
|||
111 |
|
||||
112 | def ipmagic(arg_s): |
|
|||
113 | """Call a magic function by name. |
|
|||
114 |
|
||||
115 | Input: a string containing the name of the magic function to call and any |
|
|||
116 | additional arguments to be passed to the magic. |
|
|||
117 |
|
||||
118 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython |
|
|||
119 | prompt: |
|
|||
120 |
|
||||
121 | In[1]: %name -opt foo bar |
|
|||
122 |
|
||||
123 | To call a magic without arguments, simply use ipmagic('name'). |
|
|||
124 |
|
||||
125 | This provides a proper Python function to call IPython's magics in any |
|
|||
126 | valid Python code you can type at the interpreter, including loops and |
|
|||
127 | compound statements. It is added by IPython to the Python builtin |
|
|||
128 | namespace upon initialization.""" |
|
|||
129 |
|
||||
130 | args = arg_s.split(' ',1) |
|
|||
131 | magic_name = args[0] |
|
|||
132 | if magic_name.startswith(__IPYTHON__.ESC_MAGIC): |
|
|||
133 | magic_name = magic_name[1:] |
|
|||
134 | try: |
|
|||
135 | magic_args = args[1] |
|
|||
136 | except IndexError: |
|
|||
137 | magic_args = '' |
|
|||
138 | fn = getattr(__IPYTHON__,'magic_'+magic_name,None) |
|
|||
139 | if fn is None: |
|
|||
140 | error("Magic function `%s` not found." % magic_name) |
|
|||
141 | else: |
|
|||
142 | magic_args = __IPYTHON__.var_expand(magic_args) |
|
|||
143 | return fn(magic_args) |
|
|||
144 |
|
||||
145 | def ipalias(arg_s): |
|
|||
146 | """Call an alias by name. |
|
|||
147 |
|
||||
148 | Input: a string containing the name of the alias to call and any |
|
|||
149 | additional arguments to be passed to the magic. |
|
|||
150 |
|
||||
151 | ipalias('name -opt foo bar') is equivalent to typing at the ipython |
|
|||
152 | prompt: |
|
|||
153 |
|
||||
154 | In[1]: name -opt foo bar |
|
|||
155 |
|
||||
156 | To call an alias without arguments, simply use ipalias('name'). |
|
|||
157 |
|
||||
158 | This provides a proper Python function to call IPython's aliases in any |
|
|||
159 | valid Python code you can type at the interpreter, including loops and |
|
|||
160 | compound statements. It is added by IPython to the Python builtin |
|
|||
161 | namespace upon initialization.""" |
|
|||
162 |
|
||||
163 | args = arg_s.split(' ',1) |
|
|||
164 | alias_name = args[0] |
|
|||
165 | try: |
|
|||
166 | alias_args = args[1] |
|
|||
167 | except IndexError: |
|
|||
168 | alias_args = '' |
|
|||
169 | if alias_name in __IPYTHON__.alias_table: |
|
|||
170 | __IPYTHON__.call_alias(alias_name,alias_args) |
|
|||
171 | else: |
|
|||
172 | error("Alias `%s` not found." % alias_name) |
|
|||
173 |
|
||||
174 | def ipsystem(arg_s): |
|
|||
175 | """Make a system call, using IPython.""" |
|
|||
176 | __IPYTHON__.system(arg_s) |
|
|||
177 |
|
104 | |||
178 |
|
105 | |||
179 | #**************************************************************************** |
|
106 | #**************************************************************************** | |
180 | # Local use exceptions |
|
107 | # Local use exceptions | |
181 | class SpaceInInput(exceptions.Exception): pass |
|
108 | class SpaceInInput(exceptions.Exception): pass | |
182 |
|
109 | |||
183 | #**************************************************************************** |
|
110 | #**************************************************************************** | |
184 | # Local use classes |
|
111 | # Local use classes | |
185 | class Bunch: pass |
|
112 | class Bunch: pass | |
186 |
|
113 | |||
|
114 | class Undefined: pass | |||
|
115 | ||||
187 | class InputList(list): |
|
116 | class InputList(list): | |
188 | """Class to store user input. |
|
117 | """Class to store user input. | |
189 |
|
118 | |||
190 | It's basically a list, but slices return a string instead of a list, thus |
|
119 | It's basically a list, but slices return a string instead of a list, thus | |
191 | allowing things like (assuming 'In' is an instance): |
|
120 | allowing things like (assuming 'In' is an instance): | |
192 |
|
121 | |||
193 | exec In[4:7] |
|
122 | exec In[4:7] | |
194 |
|
123 | |||
195 | or |
|
124 | or | |
196 |
|
125 | |||
197 | exec In[5:9] + In[14] + In[21:25]""" |
|
126 | exec In[5:9] + In[14] + In[21:25]""" | |
198 |
|
127 | |||
199 | def __getslice__(self,i,j): |
|
128 | def __getslice__(self,i,j): | |
200 | return ''.join(list.__getslice__(self,i,j)) |
|
129 | return ''.join(list.__getslice__(self,i,j)) | |
201 |
|
130 | |||
202 | class SyntaxTB(ultraTB.ListTB): |
|
131 | class SyntaxTB(ultraTB.ListTB): | |
203 | """Extension which holds some state: the last exception value""" |
|
132 | """Extension which holds some state: the last exception value""" | |
204 |
|
133 | |||
205 | def __init__(self,color_scheme = 'NoColor'): |
|
134 | def __init__(self,color_scheme = 'NoColor'): | |
206 | ultraTB.ListTB.__init__(self,color_scheme) |
|
135 | ultraTB.ListTB.__init__(self,color_scheme) | |
207 | self.last_syntax_error = None |
|
136 | self.last_syntax_error = None | |
208 |
|
137 | |||
209 | def __call__(self, etype, value, elist): |
|
138 | def __call__(self, etype, value, elist): | |
210 | self.last_syntax_error = value |
|
139 | self.last_syntax_error = value | |
211 | ultraTB.ListTB.__call__(self,etype,value,elist) |
|
140 | ultraTB.ListTB.__call__(self,etype,value,elist) | |
212 |
|
141 | |||
213 | def clear_err_state(self): |
|
142 | def clear_err_state(self): | |
214 | """Return the current error state and clear it""" |
|
143 | """Return the current error state and clear it""" | |
215 | e = self.last_syntax_error |
|
144 | e = self.last_syntax_error | |
216 | self.last_syntax_error = None |
|
145 | self.last_syntax_error = None | |
217 | return e |
|
146 | return e | |
218 |
|
147 | |||
219 | #**************************************************************************** |
|
148 | #**************************************************************************** | |
220 | # Main IPython class |
|
149 | # Main IPython class | |
221 |
|
150 | |||
222 | # FIXME: the Magic class is a mixin for now, and will unfortunately remain so |
|
151 | # FIXME: the Magic class is a mixin for now, and will unfortunately remain so | |
223 | # until a full rewrite is made. I've cleaned all cross-class uses of |
|
152 | # until a full rewrite is made. I've cleaned all cross-class uses of | |
224 | # attributes and methods, but too much user code out there relies on the |
|
153 | # attributes and methods, but too much user code out there relies on the | |
225 | # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage. |
|
154 | # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage. | |
226 | # |
|
155 | # | |
227 | # But at least now, all the pieces have been separated and we could, in |
|
156 | # But at least now, all the pieces have been separated and we could, in | |
228 | # principle, stop using the mixin. This will ease the transition to the |
|
157 | # principle, stop using the mixin. This will ease the transition to the | |
229 | # chainsaw branch. |
|
158 | # chainsaw branch. | |
230 |
|
159 | |||
231 | # For reference, the following is the list of 'self.foo' uses in the Magic |
|
160 | # For reference, the following is the list of 'self.foo' uses in the Magic | |
232 | # class as of 2005-12-28. These are names we CAN'T use in the main ipython |
|
161 | # class as of 2005-12-28. These are names we CAN'T use in the main ipython | |
233 | # class, to prevent clashes. |
|
162 | # class, to prevent clashes. | |
234 |
|
163 | |||
235 | # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind', |
|
164 | # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind', | |
236 | # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic', |
|
165 | # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic', | |
237 | # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell', |
|
166 | # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell', | |
238 | # 'self.value'] |
|
167 | # 'self.value'] | |
239 |
|
168 | |||
240 | class InteractiveShell(object,Magic): |
|
169 | class InteractiveShell(object,Magic): | |
241 | """An enhanced console for Python.""" |
|
170 | """An enhanced console for Python.""" | |
242 |
|
171 | |||
243 | # class attribute to indicate whether the class supports threads or not. |
|
172 | # class attribute to indicate whether the class supports threads or not. | |
244 | # Subclasses with thread support should override this as needed. |
|
173 | # Subclasses with thread support should override this as needed. | |
245 | isthreaded = False |
|
174 | isthreaded = False | |
246 |
|
175 | |||
247 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
176 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
248 | user_ns = None,user_global_ns=None,banner2='', |
|
177 | user_ns = None,user_global_ns=None,banner2='', | |
249 | custom_exceptions=((),None),embedded=False): |
|
178 | custom_exceptions=((),None),embedded=False): | |
250 |
|
179 | |||
251 | # some minimal strict typechecks. For some core data structures, I |
|
180 | # some minimal strict typechecks. For some core data structures, I | |
252 | # want actual basic python types, not just anything that looks like |
|
181 | # want actual basic python types, not just anything that looks like | |
253 | # one. This is especially true for namespaces. |
|
182 | # one. This is especially true for namespaces. | |
254 | for ns in (user_ns,user_global_ns): |
|
183 | for ns in (user_ns,user_global_ns): | |
255 | if ns is not None and type(ns) != types.DictType: |
|
184 | if ns is not None and type(ns) != types.DictType: | |
256 | raise TypeError,'namespace must be a dictionary' |
|
185 | raise TypeError,'namespace must be a dictionary' | |
257 |
|
186 | |||
258 | # Put a reference to self in builtins so that any form of embedded or |
|
187 | # Job manager (for jobs run as background threads) | |
259 | # imported code can test for being inside IPython. |
|
188 | self.jobs = BackgroundJobManager() | |
260 | __builtin__.__IPYTHON__ = self |
|
|||
261 |
|
||||
262 | # And load into builtins ipmagic/ipalias/ipsystem as well |
|
|||
263 | __builtin__.ipmagic = ipmagic |
|
|||
264 | __builtin__.ipalias = ipalias |
|
|||
265 | __builtin__.ipsystem = ipsystem |
|
|||
266 |
|
||||
267 | # Add to __builtin__ other parts of IPython's public API |
|
|||
268 | __builtin__.ip_set_hook = self.set_hook |
|
|||
269 |
|
189 | |||
270 | # Keep in the builtins a flag for when IPython is active. We set it |
|
190 | # track which builtins we add, so we can clean up later | |
271 | # with setdefault so that multiple nested IPythons don't clobber one |
|
191 | self.builtins_added = {} | |
272 | # another. Each will increase its value by one upon being activated, |
|
192 | # This method will add the necessary builtins for operation, but | |
273 | # which also gives us a way to determine the nesting level. |
|
193 | # tracking what it did via the builtins_added dict. | |
274 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) |
|
194 | self.add_builtins() | |
275 |
|
195 | |||
276 | # Do the intuitively correct thing for quit/exit: we remove the |
|
196 | # Do the intuitively correct thing for quit/exit: we remove the | |
277 |
# builtins if they exist, and our own |
|
197 | # builtins if they exist, and our own magics will deal with this | |
278 | # these special cases |
|
|||
279 | try: |
|
198 | try: | |
280 | del __builtin__.exit, __builtin__.quit |
|
199 | del __builtin__.exit, __builtin__.quit | |
281 | except AttributeError: |
|
200 | except AttributeError: | |
282 | pass |
|
201 | pass | |
283 |
|
202 | |||
284 | # Store the actual shell's name |
|
203 | # Store the actual shell's name | |
285 | self.name = name |
|
204 | self.name = name | |
286 |
|
205 | |||
287 | # We need to know whether the instance is meant for embedding, since |
|
206 | # We need to know whether the instance is meant for embedding, since | |
288 | # global/local namespaces need to be handled differently in that case |
|
207 | # global/local namespaces need to be handled differently in that case | |
289 | self.embedded = embedded |
|
208 | self.embedded = embedded | |
290 |
|
209 | |||
291 | # command compiler |
|
210 | # command compiler | |
292 | self.compile = codeop.CommandCompiler() |
|
211 | self.compile = codeop.CommandCompiler() | |
293 |
|
212 | |||
294 | # User input buffer |
|
213 | # User input buffer | |
295 | self.buffer = [] |
|
214 | self.buffer = [] | |
296 |
|
215 | |||
297 | # Default name given in compilation of code |
|
216 | # Default name given in compilation of code | |
298 | self.filename = '<ipython console>' |
|
217 | self.filename = '<ipython console>' | |
299 |
|
218 | |||
300 | # Make an empty namespace, which extension writers can rely on both |
|
219 | # Make an empty namespace, which extension writers can rely on both | |
301 | # existing and NEVER being used by ipython itself. This gives them a |
|
220 | # existing and NEVER being used by ipython itself. This gives them a | |
302 | # convenient location for storing additional information and state |
|
221 | # convenient location for storing additional information and state | |
303 | # their extensions may require, without fear of collisions with other |
|
222 | # their extensions may require, without fear of collisions with other | |
304 | # ipython names that may develop later. |
|
223 | # ipython names that may develop later. | |
305 | self.meta = Bunch() |
|
224 | self.meta = Bunch() | |
306 |
|
225 | |||
307 | # Create the namespace where the user will operate. user_ns is |
|
226 | # Create the namespace where the user will operate. user_ns is | |
308 | # normally the only one used, and it is passed to the exec calls as |
|
227 | # normally the only one used, and it is passed to the exec calls as | |
309 | # the locals argument. But we do carry a user_global_ns namespace |
|
228 | # the locals argument. But we do carry a user_global_ns namespace | |
310 | # given as the exec 'globals' argument, This is useful in embedding |
|
229 | # given as the exec 'globals' argument, This is useful in embedding | |
311 | # situations where the ipython shell opens in a context where the |
|
230 | # situations where the ipython shell opens in a context where the | |
312 | # distinction between locals and globals is meaningful. |
|
231 | # distinction between locals and globals is meaningful. | |
313 |
|
232 | |||
314 | # FIXME. For some strange reason, __builtins__ is showing up at user |
|
233 | # FIXME. For some strange reason, __builtins__ is showing up at user | |
315 | # level as a dict instead of a module. This is a manual fix, but I |
|
234 | # level as a dict instead of a module. This is a manual fix, but I | |
316 | # should really track down where the problem is coming from. Alex |
|
235 | # should really track down where the problem is coming from. Alex | |
317 | # Schmolck reported this problem first. |
|
236 | # Schmolck reported this problem first. | |
318 |
|
237 | |||
319 | # A useful post by Alex Martelli on this topic: |
|
238 | # A useful post by Alex Martelli on this topic: | |
320 | # Re: inconsistent value from __builtins__ |
|
239 | # Re: inconsistent value from __builtins__ | |
321 | # Von: Alex Martelli <aleaxit@yahoo.com> |
|
240 | # Von: Alex Martelli <aleaxit@yahoo.com> | |
322 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends |
|
241 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends | |
323 | # Gruppen: comp.lang.python |
|
242 | # Gruppen: comp.lang.python | |
324 |
|
243 | |||
325 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: |
|
244 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: | |
326 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) |
|
245 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) | |
327 | # > <type 'dict'> |
|
246 | # > <type 'dict'> | |
328 | # > >>> print type(__builtins__) |
|
247 | # > >>> print type(__builtins__) | |
329 | # > <type 'module'> |
|
248 | # > <type 'module'> | |
330 | # > Is this difference in return value intentional? |
|
249 | # > Is this difference in return value intentional? | |
331 |
|
250 | |||
332 | # Well, it's documented that '__builtins__' can be either a dictionary |
|
251 | # Well, it's documented that '__builtins__' can be either a dictionary | |
333 | # or a module, and it's been that way for a long time. Whether it's |
|
252 | # or a module, and it's been that way for a long time. Whether it's | |
334 | # intentional (or sensible), I don't know. In any case, the idea is |
|
253 | # intentional (or sensible), I don't know. In any case, the idea is | |
335 | # that if you need to access the built-in namespace directly, you |
|
254 | # that if you need to access the built-in namespace directly, you | |
336 | # should start with "import __builtin__" (note, no 's') which will |
|
255 | # should start with "import __builtin__" (note, no 's') which will | |
337 | # definitely give you a module. Yeah, it's somewhatΒ confusing:-(. |
|
256 | # definitely give you a module. Yeah, it's somewhatΒ confusing:-(. | |
338 |
|
257 | |||
339 | if user_ns is None: |
|
258 | if user_ns is None: | |
340 | # Set __name__ to __main__ to better match the behavior of the |
|
259 | # Set __name__ to __main__ to better match the behavior of the | |
341 | # normal interpreter. |
|
260 | # normal interpreter. | |
342 | user_ns = {'__name__' :'__main__', |
|
261 | user_ns = {'__name__' :'__main__', | |
343 | '__builtins__' : __builtin__, |
|
262 | '__builtins__' : __builtin__, | |
344 | } |
|
263 | } | |
345 |
|
264 | |||
346 | if user_global_ns is None: |
|
265 | if user_global_ns is None: | |
347 | user_global_ns = {} |
|
266 | user_global_ns = {} | |
348 |
|
267 | |||
349 | # Assign namespaces |
|
268 | # Assign namespaces | |
350 | # This is the namespace where all normal user variables live |
|
269 | # This is the namespace where all normal user variables live | |
351 | self.user_ns = user_ns |
|
270 | self.user_ns = user_ns | |
352 | # Embedded instances require a separate namespace for globals. |
|
271 | # Embedded instances require a separate namespace for globals. | |
353 | # Normally this one is unused by non-embedded instances. |
|
272 | # Normally this one is unused by non-embedded instances. | |
354 | self.user_global_ns = user_global_ns |
|
273 | self.user_global_ns = user_global_ns | |
355 | # A namespace to keep track of internal data structures to prevent |
|
274 | # A namespace to keep track of internal data structures to prevent | |
356 | # them from cluttering user-visible stuff. Will be updated later |
|
275 | # them from cluttering user-visible stuff. Will be updated later | |
357 | self.internal_ns = {} |
|
276 | self.internal_ns = {} | |
358 |
|
277 | |||
359 | # Namespace of system aliases. Each entry in the alias |
|
278 | # Namespace of system aliases. Each entry in the alias | |
360 | # table must be a 2-tuple of the form (N,name), where N is the number |
|
279 | # table must be a 2-tuple of the form (N,name), where N is the number | |
361 | # of positional arguments of the alias. |
|
280 | # of positional arguments of the alias. | |
362 | self.alias_table = {} |
|
281 | self.alias_table = {} | |
363 |
|
282 | |||
364 | # A table holding all the namespaces IPython deals with, so that |
|
283 | # A table holding all the namespaces IPython deals with, so that | |
365 | # introspection facilities can search easily. |
|
284 | # introspection facilities can search easily. | |
366 | self.ns_table = {'user':user_ns, |
|
285 | self.ns_table = {'user':user_ns, | |
367 | 'user_global':user_global_ns, |
|
286 | 'user_global':user_global_ns, | |
368 | 'alias':self.alias_table, |
|
287 | 'alias':self.alias_table, | |
369 | 'internal':self.internal_ns, |
|
288 | 'internal':self.internal_ns, | |
370 | 'builtin':__builtin__.__dict__ |
|
289 | 'builtin':__builtin__.__dict__ | |
371 | } |
|
290 | } | |
372 |
|
291 | |||
373 | # The user namespace MUST have a pointer to the shell itself. |
|
292 | # The user namespace MUST have a pointer to the shell itself. | |
374 | self.user_ns[name] = self |
|
293 | self.user_ns[name] = self | |
375 |
|
294 | |||
376 | # We need to insert into sys.modules something that looks like a |
|
295 | # We need to insert into sys.modules something that looks like a | |
377 | # module but which accesses the IPython namespace, for shelve and |
|
296 | # module but which accesses the IPython namespace, for shelve and | |
378 | # pickle to work interactively. Normally they rely on getting |
|
297 | # pickle to work interactively. Normally they rely on getting | |
379 | # everything out of __main__, but for embedding purposes each IPython |
|
298 | # everything out of __main__, but for embedding purposes each IPython | |
380 | # instance has its own private namespace, so we can't go shoving |
|
299 | # instance has its own private namespace, so we can't go shoving | |
381 | # everything into __main__. |
|
300 | # everything into __main__. | |
382 |
|
301 | |||
383 | # note, however, that we should only do this for non-embedded |
|
302 | # note, however, that we should only do this for non-embedded | |
384 | # ipythons, which really mimic the __main__.__dict__ with their own |
|
303 | # ipythons, which really mimic the __main__.__dict__ with their own | |
385 | # namespace. Embedded instances, on the other hand, should not do |
|
304 | # namespace. Embedded instances, on the other hand, should not do | |
386 | # this because they need to manage the user local/global namespaces |
|
305 | # this because they need to manage the user local/global namespaces | |
387 | # only, but they live within a 'normal' __main__ (meaning, they |
|
306 | # only, but they live within a 'normal' __main__ (meaning, they | |
388 | # shouldn't overtake the execution environment of the script they're |
|
307 | # shouldn't overtake the execution environment of the script they're | |
389 | # embedded in). |
|
308 | # embedded in). | |
390 |
|
309 | |||
391 | if not embedded: |
|
310 | if not embedded: | |
392 | try: |
|
311 | try: | |
393 | main_name = self.user_ns['__name__'] |
|
312 | main_name = self.user_ns['__name__'] | |
394 | except KeyError: |
|
313 | except KeyError: | |
395 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' |
|
314 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' | |
396 | else: |
|
315 | else: | |
397 | #print "pickle hack in place" # dbg |
|
316 | #print "pickle hack in place" # dbg | |
398 | #print 'main_name:',main_name # dbg |
|
317 | #print 'main_name:',main_name # dbg | |
399 | sys.modules[main_name] = FakeModule(self.user_ns) |
|
318 | sys.modules[main_name] = FakeModule(self.user_ns) | |
400 |
|
319 | |||
401 | # List of input with multi-line handling. |
|
320 | # List of input with multi-line handling. | |
402 | # Fill its zero entry, user counter starts at 1 |
|
321 | # Fill its zero entry, user counter starts at 1 | |
403 | self.input_hist = InputList(['\n']) |
|
322 | self.input_hist = InputList(['\n']) | |
404 |
|
323 | |||
405 | # list of visited directories |
|
324 | # list of visited directories | |
406 | try: |
|
325 | try: | |
407 | self.dir_hist = [os.getcwd()] |
|
326 | self.dir_hist = [os.getcwd()] | |
408 | except IOError, e: |
|
327 | except IOError, e: | |
409 | self.dir_hist = [] |
|
328 | self.dir_hist = [] | |
410 |
|
329 | |||
411 | # dict of output history |
|
330 | # dict of output history | |
412 | self.output_hist = {} |
|
331 | self.output_hist = {} | |
413 |
|
332 | |||
414 | # dict of things NOT to alias (keywords, builtins and some magics) |
|
333 | # dict of things NOT to alias (keywords, builtins and some magics) | |
415 | no_alias = {} |
|
334 | no_alias = {} | |
416 | no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] |
|
335 | no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] | |
417 | for key in keyword.kwlist + no_alias_magics: |
|
336 | for key in keyword.kwlist + no_alias_magics: | |
418 | no_alias[key] = 1 |
|
337 | no_alias[key] = 1 | |
419 | no_alias.update(__builtin__.__dict__) |
|
338 | no_alias.update(__builtin__.__dict__) | |
420 | self.no_alias = no_alias |
|
339 | self.no_alias = no_alias | |
421 |
|
340 | |||
422 | # make global variables for user access to these |
|
341 | # make global variables for user access to these | |
423 | self.user_ns['_ih'] = self.input_hist |
|
342 | self.user_ns['_ih'] = self.input_hist | |
424 | self.user_ns['_oh'] = self.output_hist |
|
343 | self.user_ns['_oh'] = self.output_hist | |
425 | self.user_ns['_dh'] = self.dir_hist |
|
344 | self.user_ns['_dh'] = self.dir_hist | |
426 |
|
345 | |||
427 | # user aliases to input and output histories |
|
346 | # user aliases to input and output histories | |
428 | self.user_ns['In'] = self.input_hist |
|
347 | self.user_ns['In'] = self.input_hist | |
429 | self.user_ns['Out'] = self.output_hist |
|
348 | self.user_ns['Out'] = self.output_hist | |
430 |
|
349 | |||
431 | # Object variable to store code object waiting execution. This is |
|
350 | # Object variable to store code object waiting execution. This is | |
432 | # used mainly by the multithreaded shells, but it can come in handy in |
|
351 | # used mainly by the multithreaded shells, but it can come in handy in | |
433 | # other situations. No need to use a Queue here, since it's a single |
|
352 | # other situations. No need to use a Queue here, since it's a single | |
434 | # item which gets cleared once run. |
|
353 | # item which gets cleared once run. | |
435 | self.code_to_run = None |
|
354 | self.code_to_run = None | |
436 |
|
355 | |||
437 | # Job manager (for jobs run as background threads) |
|
|||
438 | self.jobs = BackgroundJobManager() |
|
|||
439 | # Put the job manager into builtins so it's always there. |
|
|||
440 | __builtin__.jobs = self.jobs |
|
|||
441 |
|
||||
442 | # escapes for automatic behavior on the command line |
|
356 | # escapes for automatic behavior on the command line | |
443 | self.ESC_SHELL = '!' |
|
357 | self.ESC_SHELL = '!' | |
444 | self.ESC_HELP = '?' |
|
358 | self.ESC_HELP = '?' | |
445 | self.ESC_MAGIC = '%' |
|
359 | self.ESC_MAGIC = '%' | |
446 | self.ESC_QUOTE = ',' |
|
360 | self.ESC_QUOTE = ',' | |
447 | self.ESC_QUOTE2 = ';' |
|
361 | self.ESC_QUOTE2 = ';' | |
448 | self.ESC_PAREN = '/' |
|
362 | self.ESC_PAREN = '/' | |
449 |
|
363 | |||
450 | # And their associated handlers |
|
364 | # And their associated handlers | |
451 | self.esc_handlers = {self.ESC_PAREN : self.handle_auto, |
|
365 | self.esc_handlers = {self.ESC_PAREN : self.handle_auto, | |
452 | self.ESC_QUOTE : self.handle_auto, |
|
366 | self.ESC_QUOTE : self.handle_auto, | |
453 | self.ESC_QUOTE2 : self.handle_auto, |
|
367 | self.ESC_QUOTE2 : self.handle_auto, | |
454 | self.ESC_MAGIC : self.handle_magic, |
|
368 | self.ESC_MAGIC : self.handle_magic, | |
455 | self.ESC_HELP : self.handle_help, |
|
369 | self.ESC_HELP : self.handle_help, | |
456 | self.ESC_SHELL : self.handle_shell_escape, |
|
370 | self.ESC_SHELL : self.handle_shell_escape, | |
457 | } |
|
371 | } | |
458 |
|
372 | |||
459 | # class initializations |
|
373 | # class initializations | |
460 | Magic.__init__(self,self) |
|
374 | Magic.__init__(self,self) | |
461 |
|
375 | |||
462 | # Python source parser/formatter for syntax highlighting |
|
376 | # Python source parser/formatter for syntax highlighting | |
463 | pyformat = PyColorize.Parser().format |
|
377 | pyformat = PyColorize.Parser().format | |
464 | self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) |
|
378 | self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) | |
465 |
|
379 | |||
466 | # hooks holds pointers used for user-side customizations |
|
380 | # hooks holds pointers used for user-side customizations | |
467 | self.hooks = Struct() |
|
381 | self.hooks = Struct() | |
468 |
|
382 | |||
469 | # Set all default hooks, defined in the IPython.hooks module. |
|
383 | # Set all default hooks, defined in the IPython.hooks module. | |
470 | hooks = IPython.hooks |
|
384 | hooks = IPython.hooks | |
471 | for hook_name in hooks.__all__: |
|
385 | for hook_name in hooks.__all__: | |
472 | self.set_hook(hook_name,getattr(hooks,hook_name)) |
|
386 | self.set_hook(hook_name,getattr(hooks,hook_name)) | |
473 |
|
387 | |||
474 | # Flag to mark unconditional exit |
|
388 | # Flag to mark unconditional exit | |
475 | self.exit_now = False |
|
389 | self.exit_now = False | |
476 |
|
390 | |||
477 | self.usage_min = """\ |
|
391 | self.usage_min = """\ | |
478 | An enhanced console for Python. |
|
392 | An enhanced console for Python. | |
479 | Some of its features are: |
|
393 | Some of its features are: | |
480 | - Readline support if the readline library is present. |
|
394 | - Readline support if the readline library is present. | |
481 | - Tab completion in the local namespace. |
|
395 | - Tab completion in the local namespace. | |
482 | - Logging of input, see command-line options. |
|
396 | - Logging of input, see command-line options. | |
483 | - System shell escape via ! , eg !ls. |
|
397 | - System shell escape via ! , eg !ls. | |
484 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) |
|
398 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) | |
485 | - Keeps track of locally defined variables via %who, %whos. |
|
399 | - Keeps track of locally defined variables via %who, %whos. | |
486 | - Show object information with a ? eg ?x or x? (use ?? for more info). |
|
400 | - Show object information with a ? eg ?x or x? (use ?? for more info). | |
487 | """ |
|
401 | """ | |
488 | if usage: self.usage = usage |
|
402 | if usage: self.usage = usage | |
489 | else: self.usage = self.usage_min |
|
403 | else: self.usage = self.usage_min | |
490 |
|
404 | |||
491 | # Storage |
|
405 | # Storage | |
492 | self.rc = rc # This will hold all configuration information |
|
406 | self.rc = rc # This will hold all configuration information | |
493 | self.pager = 'less' |
|
407 | self.pager = 'less' | |
494 | # temporary files used for various purposes. Deleted at exit. |
|
408 | # temporary files used for various purposes. Deleted at exit. | |
495 | self.tempfiles = [] |
|
409 | self.tempfiles = [] | |
496 |
|
410 | |||
497 | # Keep track of readline usage (later set by init_readline) |
|
411 | # Keep track of readline usage (later set by init_readline) | |
498 | self.has_readline = False |
|
412 | self.has_readline = False | |
499 |
|
413 | |||
500 | # template for logfile headers. It gets resolved at runtime by the |
|
414 | # template for logfile headers. It gets resolved at runtime by the | |
501 | # logstart method. |
|
415 | # logstart method. | |
502 | self.loghead_tpl = \ |
|
416 | self.loghead_tpl = \ | |
503 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** |
|
417 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** | |
504 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW |
|
418 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW | |
505 | #log# opts = %s |
|
419 | #log# opts = %s | |
506 | #log# args = %s |
|
420 | #log# args = %s | |
507 | #log# It is safe to make manual edits below here. |
|
421 | #log# It is safe to make manual edits below here. | |
508 | #log#----------------------------------------------------------------------- |
|
422 | #log#----------------------------------------------------------------------- | |
509 | """ |
|
423 | """ | |
510 | # for pushd/popd management |
|
424 | # for pushd/popd management | |
511 | try: |
|
425 | try: | |
512 | self.home_dir = get_home_dir() |
|
426 | self.home_dir = get_home_dir() | |
513 | except HomeDirError,msg: |
|
427 | except HomeDirError,msg: | |
514 | fatal(msg) |
|
428 | fatal(msg) | |
515 |
|
429 | |||
516 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] |
|
430 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] | |
517 |
|
431 | |||
518 | # Functions to call the underlying shell. |
|
432 | # Functions to call the underlying shell. | |
519 |
|
433 | |||
520 | # utility to expand user variables via Itpl |
|
434 | # utility to expand user variables via Itpl | |
521 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), |
|
435 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), | |
522 | self.user_ns)) |
|
436 | self.user_ns)) | |
523 | # The first is similar to os.system, but it doesn't return a value, |
|
437 | # The first is similar to os.system, but it doesn't return a value, | |
524 | # and it allows interpolation of variables in the user's namespace. |
|
438 | # and it allows interpolation of variables in the user's namespace. | |
525 | self.system = lambda cmd: shell(self.var_expand(cmd), |
|
439 | self.system = lambda cmd: shell(self.var_expand(cmd), | |
526 | header='IPython system call: ', |
|
440 | header='IPython system call: ', | |
527 | verbose=self.rc.system_verbose) |
|
441 | verbose=self.rc.system_verbose) | |
528 | # These are for getoutput and getoutputerror: |
|
442 | # These are for getoutput and getoutputerror: | |
529 | self.getoutput = lambda cmd: \ |
|
443 | self.getoutput = lambda cmd: \ | |
530 | getoutput(self.var_expand(cmd), |
|
444 | getoutput(self.var_expand(cmd), | |
531 | header='IPython system call: ', |
|
445 | header='IPython system call: ', | |
532 | verbose=self.rc.system_verbose) |
|
446 | verbose=self.rc.system_verbose) | |
533 | self.getoutputerror = lambda cmd: \ |
|
447 | self.getoutputerror = lambda cmd: \ | |
534 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), |
|
448 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), | |
535 | self.user_ns)), |
|
449 | self.user_ns)), | |
536 | header='IPython system call: ', |
|
450 | header='IPython system call: ', | |
537 | verbose=self.rc.system_verbose) |
|
451 | verbose=self.rc.system_verbose) | |
538 |
|
452 | |||
539 | # RegExp for splitting line contents into pre-char//first |
|
453 | # RegExp for splitting line contents into pre-char//first | |
540 | # word-method//rest. For clarity, each group in on one line. |
|
454 | # word-method//rest. For clarity, each group in on one line. | |
541 |
|
455 | |||
542 | # WARNING: update the regexp if the above escapes are changed, as they |
|
456 | # WARNING: update the regexp if the above escapes are changed, as they | |
543 | # are hardwired in. |
|
457 | # are hardwired in. | |
544 |
|
458 | |||
545 | # Don't get carried away with trying to make the autocalling catch too |
|
459 | # Don't get carried away with trying to make the autocalling catch too | |
546 | # much: it's better to be conservative rather than to trigger hidden |
|
460 | # much: it's better to be conservative rather than to trigger hidden | |
547 | # evals() somewhere and end up causing side effects. |
|
461 | # evals() somewhere and end up causing side effects. | |
548 |
|
462 | |||
549 | self.line_split = re.compile(r'^([\s*,;/])' |
|
463 | self.line_split = re.compile(r'^([\s*,;/])' | |
550 | r'([\?\w\.]+\w*\s*)' |
|
464 | r'([\?\w\.]+\w*\s*)' | |
551 | r'(\(?.*$)') |
|
465 | r'(\(?.*$)') | |
552 |
|
466 | |||
553 | # Original re, keep around for a while in case changes break something |
|
467 | # Original re, keep around for a while in case changes break something | |
554 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' |
|
468 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' | |
555 | # r'(\s*[\?\w\.]+\w*\s*)' |
|
469 | # r'(\s*[\?\w\.]+\w*\s*)' | |
556 | # r'(\(?.*$)') |
|
470 | # r'(\(?.*$)') | |
557 |
|
471 | |||
558 | # RegExp to identify potential function names |
|
472 | # RegExp to identify potential function names | |
559 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') |
|
473 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') | |
560 | # RegExp to exclude strings with this start from autocalling |
|
474 | # RegExp to exclude strings with this start from autocalling | |
561 | self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ') |
|
475 | self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ') | |
562 |
|
476 | |||
563 | # try to catch also methods for stuff in lists/tuples/dicts: off |
|
477 | # try to catch also methods for stuff in lists/tuples/dicts: off | |
564 | # (experimental). For this to work, the line_split regexp would need |
|
478 | # (experimental). For this to work, the line_split regexp would need | |
565 | # to be modified so it wouldn't break things at '['. That line is |
|
479 | # to be modified so it wouldn't break things at '['. That line is | |
566 | # nasty enough that I shouldn't change it until I can test it _well_. |
|
480 | # nasty enough that I shouldn't change it until I can test it _well_. | |
567 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') |
|
481 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') | |
568 |
|
482 | |||
569 | # keep track of where we started running (mainly for crash post-mortem) |
|
483 | # keep track of where we started running (mainly for crash post-mortem) | |
570 | self.starting_dir = os.getcwd() |
|
484 | self.starting_dir = os.getcwd() | |
571 |
|
485 | |||
572 | # Various switches which can be set |
|
486 | # Various switches which can be set | |
573 | self.CACHELENGTH = 5000 # this is cheap, it's just text |
|
487 | self.CACHELENGTH = 5000 # this is cheap, it's just text | |
574 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ |
|
488 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ | |
575 | self.banner2 = banner2 |
|
489 | self.banner2 = banner2 | |
576 |
|
490 | |||
577 | # TraceBack handlers: |
|
491 | # TraceBack handlers: | |
578 |
|
492 | |||
579 | # Syntax error handler. |
|
493 | # Syntax error handler. | |
580 | self.SyntaxTB = SyntaxTB(color_scheme='NoColor') |
|
494 | self.SyntaxTB = SyntaxTB(color_scheme='NoColor') | |
581 |
|
495 | |||
582 | # The interactive one is initialized with an offset, meaning we always |
|
496 | # The interactive one is initialized with an offset, meaning we always | |
583 | # want to remove the topmost item in the traceback, which is our own |
|
497 | # want to remove the topmost item in the traceback, which is our own | |
584 | # internal code. Valid modes: ['Plain','Context','Verbose'] |
|
498 | # internal code. Valid modes: ['Plain','Context','Verbose'] | |
585 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', |
|
499 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', | |
586 | color_scheme='NoColor', |
|
500 | color_scheme='NoColor', | |
587 | tb_offset = 1) |
|
501 | tb_offset = 1) | |
588 |
|
502 | |||
589 | # IPython itself shouldn't crash. This will produce a detailed |
|
503 | # IPython itself shouldn't crash. This will produce a detailed | |
590 | # post-mortem if it does. But we only install the crash handler for |
|
504 | # post-mortem if it does. But we only install the crash handler for | |
591 | # non-threaded shells, the threaded ones use a normal verbose reporter |
|
505 | # non-threaded shells, the threaded ones use a normal verbose reporter | |
592 | # and lose the crash handler. This is because exceptions in the main |
|
506 | # and lose the crash handler. This is because exceptions in the main | |
593 | # thread (such as in GUI code) propagate directly to sys.excepthook, |
|
507 | # thread (such as in GUI code) propagate directly to sys.excepthook, | |
594 | # and there's no point in printing crash dumps for every user exception. |
|
508 | # and there's no point in printing crash dumps for every user exception. | |
595 | if self.isthreaded: |
|
509 | if self.isthreaded: | |
596 | sys.excepthook = ultraTB.FormattedTB() |
|
510 | sys.excepthook = ultraTB.FormattedTB() | |
597 | else: |
|
511 | else: | |
598 | from IPython import CrashHandler |
|
512 | from IPython import CrashHandler | |
599 | sys.excepthook = CrashHandler.CrashHandler(self) |
|
513 | sys.excepthook = CrashHandler.CrashHandler(self) | |
600 |
|
514 | |||
601 | # The instance will store a pointer to this, so that runtime code |
|
515 | # The instance will store a pointer to this, so that runtime code | |
602 | # (such as magics) can access it. This is because during the |
|
516 | # (such as magics) can access it. This is because during the | |
603 | # read-eval loop, it gets temporarily overwritten (to deal with GUI |
|
517 | # read-eval loop, it gets temporarily overwritten (to deal with GUI | |
604 | # frameworks). |
|
518 | # frameworks). | |
605 | self.sys_excepthook = sys.excepthook |
|
519 | self.sys_excepthook = sys.excepthook | |
606 |
|
520 | |||
607 | # and add any custom exception handlers the user may have specified |
|
521 | # and add any custom exception handlers the user may have specified | |
608 | self.set_custom_exc(*custom_exceptions) |
|
522 | self.set_custom_exc(*custom_exceptions) | |
609 |
|
523 | |||
610 | # Object inspector |
|
524 | # Object inspector | |
611 | self.inspector = OInspect.Inspector(OInspect.InspectColors, |
|
525 | self.inspector = OInspect.Inspector(OInspect.InspectColors, | |
612 | PyColorize.ANSICodeColors, |
|
526 | PyColorize.ANSICodeColors, | |
613 | 'NoColor') |
|
527 | 'NoColor') | |
614 | # indentation management |
|
528 | # indentation management | |
615 | self.autoindent = False |
|
529 | self.autoindent = False | |
616 | self.indent_current_nsp = 0 |
|
530 | self.indent_current_nsp = 0 | |
617 | self.indent_current = '' # actual indent string |
|
531 | self.indent_current = '' # actual indent string | |
618 |
|
532 | |||
619 | # Make some aliases automatically |
|
533 | # Make some aliases automatically | |
620 | # Prepare list of shell aliases to auto-define |
|
534 | # Prepare list of shell aliases to auto-define | |
621 | if os.name == 'posix': |
|
535 | if os.name == 'posix': | |
622 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', |
|
536 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', | |
623 | 'mv mv -i','rm rm -i','cp cp -i', |
|
537 | 'mv mv -i','rm rm -i','cp cp -i', | |
624 | 'cat cat','less less','clear clear', |
|
538 | 'cat cat','less less','clear clear', | |
625 | # a better ls |
|
539 | # a better ls | |
626 | 'ls ls -F', |
|
540 | 'ls ls -F', | |
627 | # long ls |
|
541 | # long ls | |
628 | 'll ls -lF', |
|
542 | 'll ls -lF', | |
629 | # color ls |
|
543 | # color ls | |
630 | 'lc ls -F -o --color', |
|
544 | 'lc ls -F -o --color', | |
631 | # ls normal files only |
|
545 | # ls normal files only | |
632 | 'lf ls -F -o --color %l | grep ^-', |
|
546 | 'lf ls -F -o --color %l | grep ^-', | |
633 | # ls symbolic links |
|
547 | # ls symbolic links | |
634 | 'lk ls -F -o --color %l | grep ^l', |
|
548 | 'lk ls -F -o --color %l | grep ^l', | |
635 | # directories or links to directories, |
|
549 | # directories or links to directories, | |
636 | 'ldir ls -F -o --color %l | grep /$', |
|
550 | 'ldir ls -F -o --color %l | grep /$', | |
637 | # things which are executable |
|
551 | # things which are executable | |
638 | 'lx ls -F -o --color %l | grep ^-..x', |
|
552 | 'lx ls -F -o --color %l | grep ^-..x', | |
639 | ) |
|
553 | ) | |
640 | elif os.name in ['nt','dos']: |
|
554 | elif os.name in ['nt','dos']: | |
641 | auto_alias = ('dir dir /on', 'ls dir /on', |
|
555 | auto_alias = ('dir dir /on', 'ls dir /on', | |
642 | 'ddir dir /ad /on', 'ldir dir /ad /on', |
|
556 | 'ddir dir /ad /on', 'ldir dir /ad /on', | |
643 | 'mkdir mkdir','rmdir rmdir','echo echo', |
|
557 | 'mkdir mkdir','rmdir rmdir','echo echo', | |
644 | 'ren ren','cls cls','copy copy') |
|
558 | 'ren ren','cls cls','copy copy') | |
645 | else: |
|
559 | else: | |
646 | auto_alias = () |
|
560 | auto_alias = () | |
647 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) |
|
561 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) | |
648 | # Call the actual (public) initializer |
|
562 | # Call the actual (public) initializer | |
649 | self.init_auto_alias() |
|
563 | self.init_auto_alias() | |
650 | # end __init__ |
|
564 | # end __init__ | |
651 |
|
565 | |||
652 | def post_config_initialization(self): |
|
566 | def post_config_initialization(self): | |
653 | """Post configuration init method |
|
567 | """Post configuration init method | |
654 |
|
568 | |||
655 | This is called after the configuration files have been processed to |
|
569 | This is called after the configuration files have been processed to | |
656 | 'finalize' the initialization.""" |
|
570 | 'finalize' the initialization.""" | |
657 |
|
571 | |||
658 | rc = self.rc |
|
572 | rc = self.rc | |
659 |
|
573 | |||
660 | # Load readline proper |
|
574 | # Load readline proper | |
661 | if rc.readline: |
|
575 | if rc.readline: | |
662 | self.init_readline() |
|
576 | self.init_readline() | |
663 |
|
577 | |||
664 | # log system |
|
578 | # log system | |
665 | self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate') |
|
579 | self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate') | |
666 | # local shortcut, this is used a LOT |
|
580 | # local shortcut, this is used a LOT | |
667 | self.log = self.logger.log |
|
581 | self.log = self.logger.log | |
668 |
|
582 | |||
669 | # Initialize cache, set in/out prompts and printing system |
|
583 | # Initialize cache, set in/out prompts and printing system | |
670 | self.outputcache = CachedOutput(self, |
|
584 | self.outputcache = CachedOutput(self, | |
671 | rc.cache_size, |
|
585 | rc.cache_size, | |
672 | rc.pprint, |
|
586 | rc.pprint, | |
673 | input_sep = rc.separate_in, |
|
587 | input_sep = rc.separate_in, | |
674 | output_sep = rc.separate_out, |
|
588 | output_sep = rc.separate_out, | |
675 | output_sep2 = rc.separate_out2, |
|
589 | output_sep2 = rc.separate_out2, | |
676 | ps1 = rc.prompt_in1, |
|
590 | ps1 = rc.prompt_in1, | |
677 | ps2 = rc.prompt_in2, |
|
591 | ps2 = rc.prompt_in2, | |
678 | ps_out = rc.prompt_out, |
|
592 | ps_out = rc.prompt_out, | |
679 | pad_left = rc.prompts_pad_left) |
|
593 | pad_left = rc.prompts_pad_left) | |
680 |
|
594 | |||
681 | # user may have over-ridden the default print hook: |
|
595 | # user may have over-ridden the default print hook: | |
682 | try: |
|
596 | try: | |
683 | self.outputcache.__class__.display = self.hooks.display |
|
597 | self.outputcache.__class__.display = self.hooks.display | |
684 | except AttributeError: |
|
598 | except AttributeError: | |
685 | pass |
|
599 | pass | |
686 |
|
600 | |||
687 | # I don't like assigning globally to sys, because it means when embedding |
|
601 | # I don't like assigning globally to sys, because it means when embedding | |
688 | # instances, each embedded instance overrides the previous choice. But |
|
602 | # instances, each embedded instance overrides the previous choice. But | |
689 | # sys.displayhook seems to be called internally by exec, so I don't see a |
|
603 | # sys.displayhook seems to be called internally by exec, so I don't see a | |
690 | # way around it. |
|
604 | # way around it. | |
691 | sys.displayhook = self.outputcache |
|
605 | sys.displayhook = self.outputcache | |
692 |
|
606 | |||
693 | # Set user colors (don't do it in the constructor above so that it |
|
607 | # Set user colors (don't do it in the constructor above so that it | |
694 | # doesn't crash if colors option is invalid) |
|
608 | # doesn't crash if colors option is invalid) | |
695 | self.magic_colors(rc.colors) |
|
609 | self.magic_colors(rc.colors) | |
696 |
|
610 | |||
697 | # Set calling of pdb on exceptions |
|
611 | # Set calling of pdb on exceptions | |
698 | self.call_pdb = rc.pdb |
|
612 | self.call_pdb = rc.pdb | |
699 |
|
613 | |||
700 | # Load user aliases |
|
614 | # Load user aliases | |
701 | for alias in rc.alias: |
|
615 | for alias in rc.alias: | |
702 | self.magic_alias(alias) |
|
616 | self.magic_alias(alias) | |
703 |
|
617 | |||
704 | # dynamic data that survives through sessions |
|
618 | # dynamic data that survives through sessions | |
705 | # XXX make the filename a config option? |
|
619 | # XXX make the filename a config option? | |
706 | persist_base = 'persist' |
|
620 | persist_base = 'persist' | |
707 | if rc.profile: |
|
621 | if rc.profile: | |
708 | persist_base += '_%s' % rc.profile |
|
622 | persist_base += '_%s' % rc.profile | |
709 | self.persist_fname = os.path.join(rc.ipythondir,persist_base) |
|
623 | self.persist_fname = os.path.join(rc.ipythondir,persist_base) | |
710 |
|
624 | |||
711 | try: |
|
625 | try: | |
712 | self.persist = pickle.load(file(self.persist_fname)) |
|
626 | self.persist = pickle.load(file(self.persist_fname)) | |
713 | except: |
|
627 | except: | |
714 | self.persist = {} |
|
628 | self.persist = {} | |
715 |
|
629 | |||
716 |
|
630 | |||
717 | for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]: |
|
631 | for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]: | |
718 | try: |
|
632 | try: | |
719 | obj = pickle.loads(value) |
|
633 | obj = pickle.loads(value) | |
720 | except: |
|
634 | except: | |
721 |
|
635 | |||
722 | print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key |
|
636 | print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key | |
723 | print "The error was:",sys.exc_info()[0] |
|
637 | print "The error was:",sys.exc_info()[0] | |
724 | continue |
|
638 | continue | |
725 |
|
639 | |||
726 |
|
640 | |||
727 | self.user_ns[key] = obj |
|
641 | self.user_ns[key] = obj | |
|
642 | ||||
|
643 | def add_builtins(self): | |||
|
644 | """Store ipython references into the builtin namespace. | |||
|
645 | ||||
|
646 | Some parts of ipython operate via builtins injected here, which hold a | |||
|
647 | reference to IPython itself.""" | |||
|
648 | ||||
|
649 | builtins_new = dict(__IPYTHON__ = self, | |||
|
650 | ip_set_hook = self.set_hook, | |||
|
651 | jobs = self.jobs, | |||
|
652 | ipmagic = self.ipmagic, | |||
|
653 | ipalias = self.ipalias, | |||
|
654 | ipsystem = self.ipsystem, | |||
|
655 | ) | |||
|
656 | for biname,bival in builtins_new.items(): | |||
|
657 | try: | |||
|
658 | # store the orignal value so we can restore it | |||
|
659 | self.builtins_added[biname] = __builtin__.__dict__[biname] | |||
|
660 | except KeyError: | |||
|
661 | # or mark that it wasn't defined, and we'll just delete it at | |||
|
662 | # cleanup | |||
|
663 | self.builtins_added[biname] = Undefined | |||
|
664 | __builtin__.__dict__[biname] = bival | |||
|
665 | ||||
|
666 | # Keep in the builtins a flag for when IPython is active. We set it | |||
|
667 | # with setdefault so that multiple nested IPythons don't clobber one | |||
|
668 | # another. Each will increase its value by one upon being activated, | |||
|
669 | # which also gives us a way to determine the nesting level. | |||
|
670 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) | |||
|
671 | ||||
|
672 | def clean_builtins(self): | |||
|
673 | """Remove any builtins which might have been added by add_builtins, or | |||
|
674 | restore overwritten ones to their previous values.""" | |||
|
675 | for biname,bival in self.builtins_added.items(): | |||
|
676 | if bival is Undefined: | |||
|
677 | del __builtin__.__dict__[biname] | |||
|
678 | else: | |||
|
679 | __builtin__.__dict__[biname] = bival | |||
|
680 | self.builtins_added.clear() | |||
728 |
|
681 | |||
729 | def set_hook(self,name,hook): |
|
682 | def set_hook(self,name,hook): | |
730 | """set_hook(name,hook) -> sets an internal IPython hook. |
|
683 | """set_hook(name,hook) -> sets an internal IPython hook. | |
731 |
|
684 | |||
732 | IPython exposes some of its internal API as user-modifiable hooks. By |
|
685 | IPython exposes some of its internal API as user-modifiable hooks. By | |
733 | resetting one of these hooks, you can modify IPython's behavior to |
|
686 | resetting one of these hooks, you can modify IPython's behavior to | |
734 | call at runtime your own routines.""" |
|
687 | call at runtime your own routines.""" | |
735 |
|
688 | |||
736 | # At some point in the future, this should validate the hook before it |
|
689 | # At some point in the future, this should validate the hook before it | |
737 | # accepts it. Probably at least check that the hook takes the number |
|
690 | # accepts it. Probably at least check that the hook takes the number | |
738 | # of args it's supposed to. |
|
691 | # of args it's supposed to. | |
739 | setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) |
|
692 | setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) | |
740 |
|
693 | |||
741 | def set_custom_exc(self,exc_tuple,handler): |
|
694 | def set_custom_exc(self,exc_tuple,handler): | |
742 | """set_custom_exc(exc_tuple,handler) |
|
695 | """set_custom_exc(exc_tuple,handler) | |
743 |
|
696 | |||
744 | Set a custom exception handler, which will be called if any of the |
|
697 | Set a custom exception handler, which will be called if any of the | |
745 | exceptions in exc_tuple occur in the mainloop (specifically, in the |
|
698 | exceptions in exc_tuple occur in the mainloop (specifically, in the | |
746 | runcode() method. |
|
699 | runcode() method. | |
747 |
|
700 | |||
748 | Inputs: |
|
701 | Inputs: | |
749 |
|
702 | |||
750 | - exc_tuple: a *tuple* of valid exceptions to call the defined |
|
703 | - exc_tuple: a *tuple* of valid exceptions to call the defined | |
751 | handler for. It is very important that you use a tuple, and NOT A |
|
704 | handler for. It is very important that you use a tuple, and NOT A | |
752 | LIST here, because of the way Python's except statement works. If |
|
705 | LIST here, because of the way Python's except statement works. If | |
753 | you only want to trap a single exception, use a singleton tuple: |
|
706 | you only want to trap a single exception, use a singleton tuple: | |
754 |
|
707 | |||
755 | exc_tuple == (MyCustomException,) |
|
708 | exc_tuple == (MyCustomException,) | |
756 |
|
709 | |||
757 | - handler: this must be defined as a function with the following |
|
710 | - handler: this must be defined as a function with the following | |
758 | basic interface: def my_handler(self,etype,value,tb). |
|
711 | basic interface: def my_handler(self,etype,value,tb). | |
759 |
|
712 | |||
760 | This will be made into an instance method (via new.instancemethod) |
|
713 | This will be made into an instance method (via new.instancemethod) | |
761 | of IPython itself, and it will be called if any of the exceptions |
|
714 | of IPython itself, and it will be called if any of the exceptions | |
762 | listed in the exc_tuple are caught. If the handler is None, an |
|
715 | listed in the exc_tuple are caught. If the handler is None, an | |
763 | internal basic one is used, which just prints basic info. |
|
716 | internal basic one is used, which just prints basic info. | |
764 |
|
717 | |||
765 | WARNING: by putting in your own exception handler into IPython's main |
|
718 | WARNING: by putting in your own exception handler into IPython's main | |
766 | execution loop, you run a very good chance of nasty crashes. This |
|
719 | execution loop, you run a very good chance of nasty crashes. This | |
767 | facility should only be used if you really know what you are doing.""" |
|
720 | facility should only be used if you really know what you are doing.""" | |
768 |
|
721 | |||
769 | assert type(exc_tuple)==type(()) , \ |
|
722 | assert type(exc_tuple)==type(()) , \ | |
770 | "The custom exceptions must be given AS A TUPLE." |
|
723 | "The custom exceptions must be given AS A TUPLE." | |
771 |
|
724 | |||
772 | def dummy_handler(self,etype,value,tb): |
|
725 | def dummy_handler(self,etype,value,tb): | |
773 | print '*** Simple custom exception handler ***' |
|
726 | print '*** Simple custom exception handler ***' | |
774 | print 'Exception type :',etype |
|
727 | print 'Exception type :',etype | |
775 | print 'Exception value:',value |
|
728 | print 'Exception value:',value | |
776 | print 'Traceback :',tb |
|
729 | print 'Traceback :',tb | |
777 | print 'Source code :','\n'.join(self.buffer) |
|
730 | print 'Source code :','\n'.join(self.buffer) | |
778 |
|
731 | |||
779 | if handler is None: handler = dummy_handler |
|
732 | if handler is None: handler = dummy_handler | |
780 |
|
733 | |||
781 | self.CustomTB = new.instancemethod(handler,self,self.__class__) |
|
734 | self.CustomTB = new.instancemethod(handler,self,self.__class__) | |
782 | self.custom_exceptions = exc_tuple |
|
735 | self.custom_exceptions = exc_tuple | |
783 |
|
736 | |||
784 | def set_custom_completer(self,completer,pos=0): |
|
737 | def set_custom_completer(self,completer,pos=0): | |
785 | """set_custom_completer(completer,pos=0) |
|
738 | """set_custom_completer(completer,pos=0) | |
786 |
|
739 | |||
787 | Adds a new custom completer function. |
|
740 | Adds a new custom completer function. | |
788 |
|
741 | |||
789 | The position argument (defaults to 0) is the index in the completers |
|
742 | The position argument (defaults to 0) is the index in the completers | |
790 | list where you want the completer to be inserted.""" |
|
743 | list where you want the completer to be inserted.""" | |
791 |
|
744 | |||
792 | newcomp = new.instancemethod(completer,self.Completer, |
|
745 | newcomp = new.instancemethod(completer,self.Completer, | |
793 | self.Completer.__class__) |
|
746 | self.Completer.__class__) | |
794 | self.Completer.matchers.insert(pos,newcomp) |
|
747 | self.Completer.matchers.insert(pos,newcomp) | |
795 |
|
748 | |||
796 | def _get_call_pdb(self): |
|
749 | def _get_call_pdb(self): | |
797 | return self._call_pdb |
|
750 | return self._call_pdb | |
798 |
|
751 | |||
799 | def _set_call_pdb(self,val): |
|
752 | def _set_call_pdb(self,val): | |
800 |
|
753 | |||
801 | if val not in (0,1,False,True): |
|
754 | if val not in (0,1,False,True): | |
802 | raise ValueError,'new call_pdb value must be boolean' |
|
755 | raise ValueError,'new call_pdb value must be boolean' | |
803 |
|
756 | |||
804 | # store value in instance |
|
757 | # store value in instance | |
805 | self._call_pdb = val |
|
758 | self._call_pdb = val | |
806 |
|
759 | |||
807 | # notify the actual exception handlers |
|
760 | # notify the actual exception handlers | |
808 | self.InteractiveTB.call_pdb = val |
|
761 | self.InteractiveTB.call_pdb = val | |
809 | if self.isthreaded: |
|
762 | if self.isthreaded: | |
810 | try: |
|
763 | try: | |
811 | self.sys_excepthook.call_pdb = val |
|
764 | self.sys_excepthook.call_pdb = val | |
812 | except: |
|
765 | except: | |
813 | warn('Failed to activate pdb for threaded exception handler') |
|
766 | warn('Failed to activate pdb for threaded exception handler') | |
814 |
|
767 | |||
815 | call_pdb = property(_get_call_pdb,_set_call_pdb,None, |
|
768 | call_pdb = property(_get_call_pdb,_set_call_pdb,None, | |
816 | 'Control auto-activation of pdb at exceptions') |
|
769 | 'Control auto-activation of pdb at exceptions') | |
817 |
|
770 | |||
|
771 | ||||
|
772 | # These special functions get installed in the builtin namespace, to | |||
|
773 | # provide programmatic (pure python) access to magics, aliases and system | |||
|
774 | # calls. This is important for logging, user scripting, and more. | |||
|
775 | ||||
|
776 | # We are basically exposing, via normal python functions, the three | |||
|
777 | # mechanisms in which ipython offers special call modes (magics for | |||
|
778 | # internal control, aliases for direct system access via pre-selected | |||
|
779 | # names, and !cmd for calling arbitrary system commands). | |||
|
780 | ||||
|
781 | def ipmagic(self,arg_s): | |||
|
782 | """Call a magic function by name. | |||
|
783 | ||||
|
784 | Input: a string containing the name of the magic function to call and any | |||
|
785 | additional arguments to be passed to the magic. | |||
|
786 | ||||
|
787 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython | |||
|
788 | prompt: | |||
|
789 | ||||
|
790 | In[1]: %name -opt foo bar | |||
|
791 | ||||
|
792 | To call a magic without arguments, simply use ipmagic('name'). | |||
|
793 | ||||
|
794 | This provides a proper Python function to call IPython's magics in any | |||
|
795 | valid Python code you can type at the interpreter, including loops and | |||
|
796 | compound statements. It is added by IPython to the Python builtin | |||
|
797 | namespace upon initialization.""" | |||
|
798 | ||||
|
799 | args = arg_s.split(' ',1) | |||
|
800 | magic_name = args[0] | |||
|
801 | if magic_name.startswith(self.ESC_MAGIC): | |||
|
802 | magic_name = magic_name[1:] | |||
|
803 | try: | |||
|
804 | magic_args = args[1] | |||
|
805 | except IndexError: | |||
|
806 | magic_args = '' | |||
|
807 | fn = getattr(self,'magic_'+magic_name,None) | |||
|
808 | if fn is None: | |||
|
809 | error("Magic function `%s` not found." % magic_name) | |||
|
810 | else: | |||
|
811 | magic_args = self.var_expand(magic_args) | |||
|
812 | return fn(magic_args) | |||
|
813 | ||||
|
814 | def ipalias(self,arg_s): | |||
|
815 | """Call an alias by name. | |||
|
816 | ||||
|
817 | Input: a string containing the name of the alias to call and any | |||
|
818 | additional arguments to be passed to the magic. | |||
|
819 | ||||
|
820 | ipalias('name -opt foo bar') is equivalent to typing at the ipython | |||
|
821 | prompt: | |||
|
822 | ||||
|
823 | In[1]: name -opt foo bar | |||
|
824 | ||||
|
825 | To call an alias without arguments, simply use ipalias('name'). | |||
|
826 | ||||
|
827 | This provides a proper Python function to call IPython's aliases in any | |||
|
828 | valid Python code you can type at the interpreter, including loops and | |||
|
829 | compound statements. It is added by IPython to the Python builtin | |||
|
830 | namespace upon initialization.""" | |||
|
831 | ||||
|
832 | args = arg_s.split(' ',1) | |||
|
833 | alias_name = args[0] | |||
|
834 | try: | |||
|
835 | alias_args = args[1] | |||
|
836 | except IndexError: | |||
|
837 | alias_args = '' | |||
|
838 | if alias_name in self.alias_table: | |||
|
839 | self.call_alias(alias_name,alias_args) | |||
|
840 | else: | |||
|
841 | error("Alias `%s` not found." % alias_name) | |||
|
842 | ||||
|
843 | def ipsystem(self,arg_s): | |||
|
844 | """Make a system call, using IPython.""" | |||
|
845 | self.system(arg_s) | |||
|
846 | ||||
818 | def complete(self,text): |
|
847 | def complete(self,text): | |
819 | """Return a sorted list of all possible completions on text. |
|
848 | """Return a sorted list of all possible completions on text. | |
820 |
|
849 | |||
821 | Inputs: |
|
850 | Inputs: | |
822 |
|
851 | |||
823 | - text: a string of text to be completed on. |
|
852 | - text: a string of text to be completed on. | |
824 |
|
853 | |||
825 | This is a wrapper around the completion mechanism, similar to what |
|
854 | This is a wrapper around the completion mechanism, similar to what | |
826 | readline does at the command line when the TAB key is hit. By |
|
855 | readline does at the command line when the TAB key is hit. By | |
827 | exposing it as a method, it can be used by other non-readline |
|
856 | exposing it as a method, it can be used by other non-readline | |
828 | environments (such as GUIs) for text completion. |
|
857 | environments (such as GUIs) for text completion. | |
829 |
|
858 | |||
830 | Simple usage example: |
|
859 | Simple usage example: | |
831 |
|
860 | |||
832 | In [1]: x = 'hello' |
|
861 | In [1]: x = 'hello' | |
833 |
|
862 | |||
834 | In [2]: __IP.complete('x.l') |
|
863 | In [2]: __IP.complete('x.l') | |
835 | Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']""" |
|
864 | Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']""" | |
836 |
|
865 | |||
837 | complete = self.Completer.complete |
|
866 | complete = self.Completer.complete | |
838 | state = 0 |
|
867 | state = 0 | |
839 | # use a dict so we get unique keys, since ipyhton's multiple |
|
868 | # use a dict so we get unique keys, since ipyhton's multiple | |
840 | # completers can return duplicates. |
|
869 | # completers can return duplicates. | |
841 | comps = {} |
|
870 | comps = {} | |
842 | while True: |
|
871 | while True: | |
843 | newcomp = complete(text,state) |
|
872 | newcomp = complete(text,state) | |
844 | if newcomp is None: |
|
873 | if newcomp is None: | |
845 | break |
|
874 | break | |
846 | comps[newcomp] = 1 |
|
875 | comps[newcomp] = 1 | |
847 | state += 1 |
|
876 | state += 1 | |
848 | outcomps = comps.keys() |
|
877 | outcomps = comps.keys() | |
849 | outcomps.sort() |
|
878 | outcomps.sort() | |
850 | return outcomps |
|
879 | return outcomps | |
851 |
|
880 | |||
852 | def set_completer_frame(self, frame): |
|
881 | def set_completer_frame(self, frame): | |
853 | if frame: |
|
882 | if frame: | |
854 | self.Completer.namespace = frame.f_locals |
|
883 | self.Completer.namespace = frame.f_locals | |
855 | self.Completer.global_namespace = frame.f_globals |
|
884 | self.Completer.global_namespace = frame.f_globals | |
856 | else: |
|
885 | else: | |
857 | self.Completer.namespace = self.user_ns |
|
886 | self.Completer.namespace = self.user_ns | |
858 | self.Completer.global_namespace = self.user_global_ns |
|
887 | self.Completer.global_namespace = self.user_global_ns | |
859 |
|
888 | |||
860 | def init_auto_alias(self): |
|
889 | def init_auto_alias(self): | |
861 | """Define some aliases automatically. |
|
890 | """Define some aliases automatically. | |
862 |
|
891 | |||
863 | These are ALL parameter-less aliases""" |
|
892 | These are ALL parameter-less aliases""" | |
864 | for alias,cmd in self.auto_alias: |
|
893 | for alias,cmd in self.auto_alias: | |
865 | self.alias_table[alias] = (0,cmd) |
|
894 | self.alias_table[alias] = (0,cmd) | |
866 |
|
895 | |||
867 | def alias_table_validate(self,verbose=0): |
|
896 | def alias_table_validate(self,verbose=0): | |
868 | """Update information about the alias table. |
|
897 | """Update information about the alias table. | |
869 |
|
898 | |||
870 | In particular, make sure no Python keywords/builtins are in it.""" |
|
899 | In particular, make sure no Python keywords/builtins are in it.""" | |
871 |
|
900 | |||
872 | no_alias = self.no_alias |
|
901 | no_alias = self.no_alias | |
873 | for k in self.alias_table.keys(): |
|
902 | for k in self.alias_table.keys(): | |
874 | if k in no_alias: |
|
903 | if k in no_alias: | |
875 | del self.alias_table[k] |
|
904 | del self.alias_table[k] | |
876 | if verbose: |
|
905 | if verbose: | |
877 | print ("Deleting alias <%s>, it's a Python " |
|
906 | print ("Deleting alias <%s>, it's a Python " | |
878 | "keyword or builtin." % k) |
|
907 | "keyword or builtin." % k) | |
879 |
|
908 | |||
880 | def set_autoindent(self,value=None): |
|
909 | def set_autoindent(self,value=None): | |
881 | """Set the autoindent flag, checking for readline support. |
|
910 | """Set the autoindent flag, checking for readline support. | |
882 |
|
911 | |||
883 | If called with no arguments, it acts as a toggle.""" |
|
912 | If called with no arguments, it acts as a toggle.""" | |
884 |
|
913 | |||
885 | if not self.has_readline: |
|
914 | if not self.has_readline: | |
886 | if os.name == 'posix': |
|
915 | if os.name == 'posix': | |
887 | warn("The auto-indent feature requires the readline library") |
|
916 | warn("The auto-indent feature requires the readline library") | |
888 | self.autoindent = 0 |
|
917 | self.autoindent = 0 | |
889 | return |
|
918 | return | |
890 | if value is None: |
|
919 | if value is None: | |
891 | self.autoindent = not self.autoindent |
|
920 | self.autoindent = not self.autoindent | |
892 | else: |
|
921 | else: | |
893 | self.autoindent = value |
|
922 | self.autoindent = value | |
894 |
|
923 | |||
895 | def rc_set_toggle(self,rc_field,value=None): |
|
924 | def rc_set_toggle(self,rc_field,value=None): | |
896 | """Set or toggle a field in IPython's rc config. structure. |
|
925 | """Set or toggle a field in IPython's rc config. structure. | |
897 |
|
926 | |||
898 | If called with no arguments, it acts as a toggle. |
|
927 | If called with no arguments, it acts as a toggle. | |
899 |
|
928 | |||
900 | If called with a non-existent field, the resulting AttributeError |
|
929 | If called with a non-existent field, the resulting AttributeError | |
901 | exception will propagate out.""" |
|
930 | exception will propagate out.""" | |
902 |
|
931 | |||
903 | rc_val = getattr(self.rc,rc_field) |
|
932 | rc_val = getattr(self.rc,rc_field) | |
904 | if value is None: |
|
933 | if value is None: | |
905 | value = not rc_val |
|
934 | value = not rc_val | |
906 | setattr(self.rc,rc_field,value) |
|
935 | setattr(self.rc,rc_field,value) | |
907 |
|
936 | |||
908 | def user_setup(self,ipythondir,rc_suffix,mode='install'): |
|
937 | def user_setup(self,ipythondir,rc_suffix,mode='install'): | |
909 | """Install the user configuration directory. |
|
938 | """Install the user configuration directory. | |
910 |
|
939 | |||
911 | Can be called when running for the first time or to upgrade the user's |
|
940 | Can be called when running for the first time or to upgrade the user's | |
912 | .ipython/ directory with the mode parameter. Valid modes are 'install' |
|
941 | .ipython/ directory with the mode parameter. Valid modes are 'install' | |
913 | and 'upgrade'.""" |
|
942 | and 'upgrade'.""" | |
914 |
|
943 | |||
915 | def wait(): |
|
944 | def wait(): | |
916 | try: |
|
945 | try: | |
917 | raw_input("Please press <RETURN> to start IPython.") |
|
946 | raw_input("Please press <RETURN> to start IPython.") | |
918 | except EOFError: |
|
947 | except EOFError: | |
919 | print >> Term.cout |
|
948 | print >> Term.cout | |
920 | print '*'*70 |
|
949 | print '*'*70 | |
921 |
|
950 | |||
922 | cwd = os.getcwd() # remember where we started |
|
951 | cwd = os.getcwd() # remember where we started | |
923 | glb = glob.glob |
|
952 | glb = glob.glob | |
924 | print '*'*70 |
|
953 | print '*'*70 | |
925 | if mode == 'install': |
|
954 | if mode == 'install': | |
926 | print \ |
|
955 | print \ | |
927 | """Welcome to IPython. I will try to create a personal configuration directory |
|
956 | """Welcome to IPython. I will try to create a personal configuration directory | |
928 | where you can customize many aspects of IPython's functionality in:\n""" |
|
957 | where you can customize many aspects of IPython's functionality in:\n""" | |
929 | else: |
|
958 | else: | |
930 | print 'I am going to upgrade your configuration in:' |
|
959 | print 'I am going to upgrade your configuration in:' | |
931 |
|
960 | |||
932 | print ipythondir |
|
961 | print ipythondir | |
933 |
|
962 | |||
934 | rcdirend = os.path.join('IPython','UserConfig') |
|
963 | rcdirend = os.path.join('IPython','UserConfig') | |
935 | cfg = lambda d: os.path.join(d,rcdirend) |
|
964 | cfg = lambda d: os.path.join(d,rcdirend) | |
936 | try: |
|
965 | try: | |
937 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] |
|
966 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] | |
938 | except IOError: |
|
967 | except IOError: | |
939 | warning = """ |
|
968 | warning = """ | |
940 | Installation error. IPython's directory was not found. |
|
969 | Installation error. IPython's directory was not found. | |
941 |
|
970 | |||
942 | Check the following: |
|
971 | Check the following: | |
943 |
|
972 | |||
944 | The ipython/IPython directory should be in a directory belonging to your |
|
973 | The ipython/IPython directory should be in a directory belonging to your | |
945 | PYTHONPATH environment variable (that is, it should be in a directory |
|
974 | PYTHONPATH environment variable (that is, it should be in a directory | |
946 | belonging to sys.path). You can copy it explicitly there or just link to it. |
|
975 | belonging to sys.path). You can copy it explicitly there or just link to it. | |
947 |
|
976 | |||
948 | IPython will proceed with builtin defaults. |
|
977 | IPython will proceed with builtin defaults. | |
949 | """ |
|
978 | """ | |
950 | warn(warning) |
|
979 | warn(warning) | |
951 | wait() |
|
980 | wait() | |
952 | return |
|
981 | return | |
953 |
|
982 | |||
954 | if mode == 'install': |
|
983 | if mode == 'install': | |
955 | try: |
|
984 | try: | |
956 | shutil.copytree(rcdir,ipythondir) |
|
985 | shutil.copytree(rcdir,ipythondir) | |
957 | os.chdir(ipythondir) |
|
986 | os.chdir(ipythondir) | |
958 | rc_files = glb("ipythonrc*") |
|
987 | rc_files = glb("ipythonrc*") | |
959 | for rc_file in rc_files: |
|
988 | for rc_file in rc_files: | |
960 | os.rename(rc_file,rc_file+rc_suffix) |
|
989 | os.rename(rc_file,rc_file+rc_suffix) | |
961 | except: |
|
990 | except: | |
962 | warning = """ |
|
991 | warning = """ | |
963 |
|
992 | |||
964 | There was a problem with the installation: |
|
993 | There was a problem with the installation: | |
965 | %s |
|
994 | %s | |
966 | Try to correct it or contact the developers if you think it's a bug. |
|
995 | Try to correct it or contact the developers if you think it's a bug. | |
967 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] |
|
996 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] | |
968 | warn(warning) |
|
997 | warn(warning) | |
969 | wait() |
|
998 | wait() | |
970 | return |
|
999 | return | |
971 |
|
1000 | |||
972 | elif mode == 'upgrade': |
|
1001 | elif mode == 'upgrade': | |
973 | try: |
|
1002 | try: | |
974 | os.chdir(ipythondir) |
|
1003 | os.chdir(ipythondir) | |
975 | except: |
|
1004 | except: | |
976 | print """ |
|
1005 | print """ | |
977 | Can not upgrade: changing to directory %s failed. Details: |
|
1006 | Can not upgrade: changing to directory %s failed. Details: | |
978 | %s |
|
1007 | %s | |
979 | """ % (ipythondir,sys.exc_info()[1]) |
|
1008 | """ % (ipythondir,sys.exc_info()[1]) | |
980 | wait() |
|
1009 | wait() | |
981 | return |
|
1010 | return | |
982 | else: |
|
1011 | else: | |
983 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) |
|
1012 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) | |
984 | for new_full_path in sources: |
|
1013 | for new_full_path in sources: | |
985 | new_filename = os.path.basename(new_full_path) |
|
1014 | new_filename = os.path.basename(new_full_path) | |
986 | if new_filename.startswith('ipythonrc'): |
|
1015 | if new_filename.startswith('ipythonrc'): | |
987 | new_filename = new_filename + rc_suffix |
|
1016 | new_filename = new_filename + rc_suffix | |
988 | # The config directory should only contain files, skip any |
|
1017 | # The config directory should only contain files, skip any | |
989 | # directories which may be there (like CVS) |
|
1018 | # directories which may be there (like CVS) | |
990 | if os.path.isdir(new_full_path): |
|
1019 | if os.path.isdir(new_full_path): | |
991 | continue |
|
1020 | continue | |
992 | if os.path.exists(new_filename): |
|
1021 | if os.path.exists(new_filename): | |
993 | old_file = new_filename+'.old' |
|
1022 | old_file = new_filename+'.old' | |
994 | if os.path.exists(old_file): |
|
1023 | if os.path.exists(old_file): | |
995 | os.remove(old_file) |
|
1024 | os.remove(old_file) | |
996 | os.rename(new_filename,old_file) |
|
1025 | os.rename(new_filename,old_file) | |
997 | shutil.copy(new_full_path,new_filename) |
|
1026 | shutil.copy(new_full_path,new_filename) | |
998 | else: |
|
1027 | else: | |
999 | raise ValueError,'unrecognized mode for install:',`mode` |
|
1028 | raise ValueError,'unrecognized mode for install:',`mode` | |
1000 |
|
1029 | |||
1001 | # Fix line-endings to those native to each platform in the config |
|
1030 | # Fix line-endings to those native to each platform in the config | |
1002 | # directory. |
|
1031 | # directory. | |
1003 | try: |
|
1032 | try: | |
1004 | os.chdir(ipythondir) |
|
1033 | os.chdir(ipythondir) | |
1005 | except: |
|
1034 | except: | |
1006 | print """ |
|
1035 | print """ | |
1007 | Problem: changing to directory %s failed. |
|
1036 | Problem: changing to directory %s failed. | |
1008 | Details: |
|
1037 | Details: | |
1009 | %s |
|
1038 | %s | |
1010 |
|
1039 | |||
1011 | Some configuration files may have incorrect line endings. This should not |
|
1040 | Some configuration files may have incorrect line endings. This should not | |
1012 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) |
|
1041 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) | |
1013 | wait() |
|
1042 | wait() | |
1014 | else: |
|
1043 | else: | |
1015 | for fname in glb('ipythonrc*'): |
|
1044 | for fname in glb('ipythonrc*'): | |
1016 | try: |
|
1045 | try: | |
1017 | native_line_ends(fname,backup=0) |
|
1046 | native_line_ends(fname,backup=0) | |
1018 | except IOError: |
|
1047 | except IOError: | |
1019 | pass |
|
1048 | pass | |
1020 |
|
1049 | |||
1021 | if mode == 'install': |
|
1050 | if mode == 'install': | |
1022 | print """ |
|
1051 | print """ | |
1023 | Successful installation! |
|
1052 | Successful installation! | |
1024 |
|
1053 | |||
1025 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the |
|
1054 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the | |
1026 | IPython manual (there are both HTML and PDF versions supplied with the |
|
1055 | IPython manual (there are both HTML and PDF versions supplied with the | |
1027 | distribution) to make sure that your system environment is properly configured |
|
1056 | distribution) to make sure that your system environment is properly configured | |
1028 | to take advantage of IPython's features.""" |
|
1057 | to take advantage of IPython's features.""" | |
1029 | else: |
|
1058 | else: | |
1030 | print """ |
|
1059 | print """ | |
1031 | Successful upgrade! |
|
1060 | Successful upgrade! | |
1032 |
|
1061 | |||
1033 | All files in your directory: |
|
1062 | All files in your directory: | |
1034 | %(ipythondir)s |
|
1063 | %(ipythondir)s | |
1035 | which would have been overwritten by the upgrade were backed up with a .old |
|
1064 | which would have been overwritten by the upgrade were backed up with a .old | |
1036 | extension. If you had made particular customizations in those files you may |
|
1065 | extension. If you had made particular customizations in those files you may | |
1037 | want to merge them back into the new files.""" % locals() |
|
1066 | want to merge them back into the new files.""" % locals() | |
1038 | wait() |
|
1067 | wait() | |
1039 | os.chdir(cwd) |
|
1068 | os.chdir(cwd) | |
1040 | # end user_setup() |
|
1069 | # end user_setup() | |
1041 |
|
1070 | |||
1042 | def atexit_operations(self): |
|
1071 | def atexit_operations(self): | |
1043 | """This will be executed at the time of exit. |
|
1072 | """This will be executed at the time of exit. | |
1044 |
|
1073 | |||
1045 | Saving of persistent data should be performed here. """ |
|
1074 | Saving of persistent data should be performed here. """ | |
1046 |
|
1075 | |||
1047 | # input history |
|
1076 | # input history | |
1048 | self.savehist() |
|
1077 | self.savehist() | |
1049 |
|
1078 | |||
1050 | # Cleanup all tempfiles left around |
|
1079 | # Cleanup all tempfiles left around | |
1051 | for tfile in self.tempfiles: |
|
1080 | for tfile in self.tempfiles: | |
1052 | try: |
|
1081 | try: | |
1053 | os.unlink(tfile) |
|
1082 | os.unlink(tfile) | |
1054 | except OSError: |
|
1083 | except OSError: | |
1055 | pass |
|
1084 | pass | |
1056 |
|
1085 | |||
1057 | # save the "persistent data" catch-all dictionary |
|
1086 | # save the "persistent data" catch-all dictionary | |
1058 | try: |
|
1087 | try: | |
1059 | pickle.dump(self.persist, open(self.persist_fname,"w")) |
|
1088 | pickle.dump(self.persist, open(self.persist_fname,"w")) | |
1060 | except: |
|
1089 | except: | |
1061 | print "*** ERROR *** persistent data saving failed." |
|
1090 | print "*** ERROR *** persistent data saving failed." | |
1062 |
|
1091 | |||
1063 | def savehist(self): |
|
1092 | def savehist(self): | |
1064 | """Save input history to a file (via readline library).""" |
|
1093 | """Save input history to a file (via readline library).""" | |
1065 | try: |
|
1094 | try: | |
1066 | self.readline.write_history_file(self.histfile) |
|
1095 | self.readline.write_history_file(self.histfile) | |
1067 | except: |
|
1096 | except: | |
1068 | print 'Unable to save IPython command history to file: ' + \ |
|
1097 | print 'Unable to save IPython command history to file: ' + \ | |
1069 | `self.histfile` |
|
1098 | `self.histfile` | |
1070 |
|
1099 | |||
1071 | def pre_readline(self): |
|
1100 | def pre_readline(self): | |
1072 | """readline hook to be used at the start of each line. |
|
1101 | """readline hook to be used at the start of each line. | |
1073 |
|
1102 | |||
1074 | Currently it handles auto-indent only.""" |
|
1103 | Currently it handles auto-indent only.""" | |
1075 |
|
1104 | |||
1076 | self.readline.insert_text(self.indent_current) |
|
1105 | self.readline.insert_text(self.indent_current) | |
1077 |
|
1106 | |||
1078 | def init_readline(self): |
|
1107 | def init_readline(self): | |
1079 | """Command history completion/saving/reloading.""" |
|
1108 | """Command history completion/saving/reloading.""" | |
1080 | try: |
|
1109 | try: | |
1081 | import readline |
|
1110 | import readline | |
1082 | except ImportError: |
|
1111 | except ImportError: | |
1083 | self.has_readline = 0 |
|
1112 | self.has_readline = 0 | |
1084 | self.readline = None |
|
1113 | self.readline = None | |
1085 | # no point in bugging windows users with this every time: |
|
1114 | # no point in bugging windows users with this every time: | |
1086 | if os.name == 'posix': |
|
1115 | if os.name == 'posix': | |
1087 | warn('Readline services not available on this platform.') |
|
1116 | warn('Readline services not available on this platform.') | |
1088 | else: |
|
1117 | else: | |
1089 | import atexit |
|
1118 | import atexit | |
1090 | from IPython.completer import IPCompleter |
|
1119 | from IPython.completer import IPCompleter | |
1091 | self.Completer = IPCompleter(self, |
|
1120 | self.Completer = IPCompleter(self, | |
1092 | self.user_ns, |
|
1121 | self.user_ns, | |
1093 | self.user_global_ns, |
|
1122 | self.user_global_ns, | |
1094 | self.rc.readline_omit__names, |
|
1123 | self.rc.readline_omit__names, | |
1095 | self.alias_table) |
|
1124 | self.alias_table) | |
1096 |
|
1125 | |||
1097 | # Platform-specific configuration |
|
1126 | # Platform-specific configuration | |
1098 | if os.name == 'nt': |
|
1127 | if os.name == 'nt': | |
1099 | self.readline_startup_hook = readline.set_pre_input_hook |
|
1128 | self.readline_startup_hook = readline.set_pre_input_hook | |
1100 | else: |
|
1129 | else: | |
1101 | self.readline_startup_hook = readline.set_startup_hook |
|
1130 | self.readline_startup_hook = readline.set_startup_hook | |
1102 |
|
1131 | |||
1103 | # Load user's initrc file (readline config) |
|
1132 | # Load user's initrc file (readline config) | |
1104 | inputrc_name = os.environ.get('INPUTRC') |
|
1133 | inputrc_name = os.environ.get('INPUTRC') | |
1105 | if inputrc_name is None: |
|
1134 | if inputrc_name is None: | |
1106 | home_dir = get_home_dir() |
|
1135 | home_dir = get_home_dir() | |
1107 | if home_dir is not None: |
|
1136 | if home_dir is not None: | |
1108 | inputrc_name = os.path.join(home_dir,'.inputrc') |
|
1137 | inputrc_name = os.path.join(home_dir,'.inputrc') | |
1109 | if os.path.isfile(inputrc_name): |
|
1138 | if os.path.isfile(inputrc_name): | |
1110 | try: |
|
1139 | try: | |
1111 | readline.read_init_file(inputrc_name) |
|
1140 | readline.read_init_file(inputrc_name) | |
1112 | except: |
|
1141 | except: | |
1113 | warn('Problems reading readline initialization file <%s>' |
|
1142 | warn('Problems reading readline initialization file <%s>' | |
1114 | % inputrc_name) |
|
1143 | % inputrc_name) | |
1115 |
|
1144 | |||
1116 | self.has_readline = 1 |
|
1145 | self.has_readline = 1 | |
1117 | self.readline = readline |
|
1146 | self.readline = readline | |
1118 | # save this in sys so embedded copies can restore it properly |
|
1147 | # save this in sys so embedded copies can restore it properly | |
1119 | sys.ipcompleter = self.Completer.complete |
|
1148 | sys.ipcompleter = self.Completer.complete | |
1120 | readline.set_completer(self.Completer.complete) |
|
1149 | readline.set_completer(self.Completer.complete) | |
1121 |
|
1150 | |||
1122 | # Configure readline according to user's prefs |
|
1151 | # Configure readline according to user's prefs | |
1123 | for rlcommand in self.rc.readline_parse_and_bind: |
|
1152 | for rlcommand in self.rc.readline_parse_and_bind: | |
1124 | readline.parse_and_bind(rlcommand) |
|
1153 | readline.parse_and_bind(rlcommand) | |
1125 |
|
1154 | |||
1126 | # remove some chars from the delimiters list |
|
1155 | # remove some chars from the delimiters list | |
1127 | delims = readline.get_completer_delims() |
|
1156 | delims = readline.get_completer_delims() | |
1128 | delims = delims.translate(string._idmap, |
|
1157 | delims = delims.translate(string._idmap, | |
1129 | self.rc.readline_remove_delims) |
|
1158 | self.rc.readline_remove_delims) | |
1130 | readline.set_completer_delims(delims) |
|
1159 | readline.set_completer_delims(delims) | |
1131 | # otherwise we end up with a monster history after a while: |
|
1160 | # otherwise we end up with a monster history after a while: | |
1132 | readline.set_history_length(1000) |
|
1161 | readline.set_history_length(1000) | |
1133 | try: |
|
1162 | try: | |
1134 | #print '*** Reading readline history' # dbg |
|
1163 | #print '*** Reading readline history' # dbg | |
1135 | readline.read_history_file(self.histfile) |
|
1164 | readline.read_history_file(self.histfile) | |
1136 | except IOError: |
|
1165 | except IOError: | |
1137 | pass # It doesn't exist yet. |
|
1166 | pass # It doesn't exist yet. | |
1138 |
|
1167 | |||
1139 | atexit.register(self.atexit_operations) |
|
1168 | atexit.register(self.atexit_operations) | |
1140 | del atexit |
|
1169 | del atexit | |
1141 |
|
1170 | |||
1142 | # Configure auto-indent for all platforms |
|
1171 | # Configure auto-indent for all platforms | |
1143 | self.set_autoindent(self.rc.autoindent) |
|
1172 | self.set_autoindent(self.rc.autoindent) | |
1144 |
|
1173 | |||
1145 | def _should_recompile(self,e): |
|
1174 | def _should_recompile(self,e): | |
1146 | """Utility routine for edit_syntax_error""" |
|
1175 | """Utility routine for edit_syntax_error""" | |
1147 |
|
1176 | |||
1148 | if e.filename in ('<ipython console>','<input>','<string>', |
|
1177 | if e.filename in ('<ipython console>','<input>','<string>', | |
1149 | '<console>'): |
|
1178 | '<console>'): | |
1150 | return False |
|
1179 | return False | |
1151 | try: |
|
1180 | try: | |
1152 | if not ask_yes_no('Return to editor to correct syntax error? ' |
|
1181 | if not ask_yes_no('Return to editor to correct syntax error? ' | |
1153 | '[Y/n] ','y'): |
|
1182 | '[Y/n] ','y'): | |
1154 | return False |
|
1183 | return False | |
1155 | except EOFError: |
|
1184 | except EOFError: | |
1156 | return False |
|
1185 | return False | |
1157 | self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg) |
|
1186 | self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg) | |
1158 | return True |
|
1187 | return True | |
1159 |
|
1188 | |||
1160 | def edit_syntax_error(self): |
|
1189 | def edit_syntax_error(self): | |
1161 | """The bottom half of the syntax error handler called in the main loop. |
|
1190 | """The bottom half of the syntax error handler called in the main loop. | |
1162 |
|
1191 | |||
1163 | Loop until syntax error is fixed or user cancels. |
|
1192 | Loop until syntax error is fixed or user cancels. | |
1164 | """ |
|
1193 | """ | |
1165 |
|
1194 | |||
1166 | while self.SyntaxTB.last_syntax_error: |
|
1195 | while self.SyntaxTB.last_syntax_error: | |
1167 | # copy and clear last_syntax_error |
|
1196 | # copy and clear last_syntax_error | |
1168 | err = self.SyntaxTB.clear_err_state() |
|
1197 | err = self.SyntaxTB.clear_err_state() | |
1169 | if not self._should_recompile(err): |
|
1198 | if not self._should_recompile(err): | |
1170 | return |
|
1199 | return | |
1171 | try: |
|
1200 | try: | |
1172 | # may set last_syntax_error again if a SyntaxError is raised |
|
1201 | # may set last_syntax_error again if a SyntaxError is raised | |
1173 | self.safe_execfile(err.filename,self.shell.user_ns) |
|
1202 | self.safe_execfile(err.filename,self.shell.user_ns) | |
1174 | except: |
|
1203 | except: | |
1175 | self.showtraceback() |
|
1204 | self.showtraceback() | |
1176 | else: |
|
1205 | else: | |
1177 | f = file(err.filename) |
|
1206 | f = file(err.filename) | |
1178 | try: |
|
1207 | try: | |
1179 | sys.displayhook(f.read()) |
|
1208 | sys.displayhook(f.read()) | |
1180 | finally: |
|
1209 | finally: | |
1181 | f.close() |
|
1210 | f.close() | |
1182 |
|
1211 | |||
1183 | def showsyntaxerror(self, filename=None): |
|
1212 | def showsyntaxerror(self, filename=None): | |
1184 | """Display the syntax error that just occurred. |
|
1213 | """Display the syntax error that just occurred. | |
1185 |
|
1214 | |||
1186 | This doesn't display a stack trace because there isn't one. |
|
1215 | This doesn't display a stack trace because there isn't one. | |
1187 |
|
1216 | |||
1188 | If a filename is given, it is stuffed in the exception instead |
|
1217 | If a filename is given, it is stuffed in the exception instead | |
1189 | of what was there before (because Python's parser always uses |
|
1218 | of what was there before (because Python's parser always uses | |
1190 | "<string>" when reading from a string). |
|
1219 | "<string>" when reading from a string). | |
1191 | """ |
|
1220 | """ | |
1192 | etype, value, last_traceback = sys.exc_info() |
|
1221 | etype, value, last_traceback = sys.exc_info() | |
1193 | if filename and etype is SyntaxError: |
|
1222 | if filename and etype is SyntaxError: | |
1194 | # Work hard to stuff the correct filename in the exception |
|
1223 | # Work hard to stuff the correct filename in the exception | |
1195 | try: |
|
1224 | try: | |
1196 | msg, (dummy_filename, lineno, offset, line) = value |
|
1225 | msg, (dummy_filename, lineno, offset, line) = value | |
1197 | except: |
|
1226 | except: | |
1198 | # Not the format we expect; leave it alone |
|
1227 | # Not the format we expect; leave it alone | |
1199 | pass |
|
1228 | pass | |
1200 | else: |
|
1229 | else: | |
1201 | # Stuff in the right filename |
|
1230 | # Stuff in the right filename | |
1202 | try: |
|
1231 | try: | |
1203 | # Assume SyntaxError is a class exception |
|
1232 | # Assume SyntaxError is a class exception | |
1204 | value = SyntaxError(msg, (filename, lineno, offset, line)) |
|
1233 | value = SyntaxError(msg, (filename, lineno, offset, line)) | |
1205 | except: |
|
1234 | except: | |
1206 | # If that failed, assume SyntaxError is a string |
|
1235 | # If that failed, assume SyntaxError is a string | |
1207 | value = msg, (filename, lineno, offset, line) |
|
1236 | value = msg, (filename, lineno, offset, line) | |
1208 | self.SyntaxTB(etype,value,[]) |
|
1237 | self.SyntaxTB(etype,value,[]) | |
1209 |
|
1238 | |||
1210 | def debugger(self): |
|
1239 | def debugger(self): | |
1211 | """Call the pdb debugger.""" |
|
1240 | """Call the pdb debugger.""" | |
1212 |
|
1241 | |||
1213 | if not self.rc.pdb: |
|
1242 | if not self.rc.pdb: | |
1214 | return |
|
1243 | return | |
1215 | pdb.pm() |
|
1244 | pdb.pm() | |
1216 |
|
1245 | |||
1217 | def showtraceback(self,exc_tuple = None,filename=None): |
|
1246 | def showtraceback(self,exc_tuple = None,filename=None): | |
1218 | """Display the exception that just occurred.""" |
|
1247 | """Display the exception that just occurred.""" | |
1219 |
|
1248 | |||
1220 | # Though this won't be called by syntax errors in the input line, |
|
1249 | # Though this won't be called by syntax errors in the input line, | |
1221 | # there may be SyntaxError cases whith imported code. |
|
1250 | # there may be SyntaxError cases whith imported code. | |
1222 | if exc_tuple is None: |
|
1251 | if exc_tuple is None: | |
1223 | type, value, tb = sys.exc_info() |
|
1252 | type, value, tb = sys.exc_info() | |
1224 | else: |
|
1253 | else: | |
1225 | type, value, tb = exc_tuple |
|
1254 | type, value, tb = exc_tuple | |
1226 | if type is SyntaxError: |
|
1255 | if type is SyntaxError: | |
1227 | self.showsyntaxerror(filename) |
|
1256 | self.showsyntaxerror(filename) | |
1228 | else: |
|
1257 | else: | |
1229 | self.InteractiveTB() |
|
1258 | self.InteractiveTB() | |
1230 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1259 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1231 | # pdb mucks up readline, fix it back |
|
1260 | # pdb mucks up readline, fix it back | |
1232 | self.readline.set_completer(self.Completer.complete) |
|
1261 | self.readline.set_completer(self.Completer.complete) | |
1233 |
|
1262 | |||
1234 | def mainloop(self,banner=None): |
|
1263 | def mainloop(self,banner=None): | |
1235 | """Creates the local namespace and starts the mainloop. |
|
1264 | """Creates the local namespace and starts the mainloop. | |
1236 |
|
1265 | |||
1237 | If an optional banner argument is given, it will override the |
|
1266 | If an optional banner argument is given, it will override the | |
1238 | internally created default banner.""" |
|
1267 | internally created default banner.""" | |
1239 |
|
1268 | |||
1240 | if self.rc.c: # Emulate Python's -c option |
|
1269 | if self.rc.c: # Emulate Python's -c option | |
1241 | self.exec_init_cmd() |
|
1270 | self.exec_init_cmd() | |
1242 | if banner is None: |
|
1271 | if banner is None: | |
1243 | if self.rc.banner: |
|
1272 | if self.rc.banner: | |
1244 | banner = self.BANNER+self.banner2 |
|
1273 | banner = self.BANNER+self.banner2 | |
1245 | else: |
|
1274 | else: | |
1246 | banner = '' |
|
1275 | banner = '' | |
1247 | self.interact(banner) |
|
1276 | self.interact(banner) | |
1248 |
|
1277 | |||
1249 | def exec_init_cmd(self): |
|
1278 | def exec_init_cmd(self): | |
1250 | """Execute a command given at the command line. |
|
1279 | """Execute a command given at the command line. | |
1251 |
|
1280 | |||
1252 | This emulates Python's -c option.""" |
|
1281 | This emulates Python's -c option.""" | |
1253 |
|
1282 | |||
1254 | sys.argv = ['-c'] |
|
1283 | sys.argv = ['-c'] | |
1255 | self.push(self.rc.c) |
|
1284 | self.push(self.rc.c) | |
1256 |
|
1285 | |||
1257 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): |
|
1286 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): | |
1258 | """Embeds IPython into a running python program. |
|
1287 | """Embeds IPython into a running python program. | |
1259 |
|
1288 | |||
1260 | Input: |
|
1289 | Input: | |
1261 |
|
1290 | |||
1262 | - header: An optional header message can be specified. |
|
1291 | - header: An optional header message can be specified. | |
1263 |
|
1292 | |||
1264 | - local_ns, global_ns: working namespaces. If given as None, the |
|
1293 | - local_ns, global_ns: working namespaces. If given as None, the | |
1265 | IPython-initialized one is updated with __main__.__dict__, so that |
|
1294 | IPython-initialized one is updated with __main__.__dict__, so that | |
1266 | program variables become visible but user-specific configuration |
|
1295 | program variables become visible but user-specific configuration | |
1267 | remains possible. |
|
1296 | remains possible. | |
1268 |
|
1297 | |||
1269 | - stack_depth: specifies how many levels in the stack to go to |
|
1298 | - stack_depth: specifies how many levels in the stack to go to | |
1270 | looking for namespaces (when local_ns and global_ns are None). This |
|
1299 | looking for namespaces (when local_ns and global_ns are None). This | |
1271 | allows an intermediate caller to make sure that this function gets |
|
1300 | allows an intermediate caller to make sure that this function gets | |
1272 | the namespace from the intended level in the stack. By default (0) |
|
1301 | the namespace from the intended level in the stack. By default (0) | |
1273 | it will get its locals and globals from the immediate caller. |
|
1302 | it will get its locals and globals from the immediate caller. | |
1274 |
|
1303 | |||
1275 | Warning: it's possible to use this in a program which is being run by |
|
1304 | Warning: it's possible to use this in a program which is being run by | |
1276 | IPython itself (via %run), but some funny things will happen (a few |
|
1305 | IPython itself (via %run), but some funny things will happen (a few | |
1277 | globals get overwritten). In the future this will be cleaned up, as |
|
1306 | globals get overwritten). In the future this will be cleaned up, as | |
1278 | there is no fundamental reason why it can't work perfectly.""" |
|
1307 | there is no fundamental reason why it can't work perfectly.""" | |
1279 |
|
1308 | |||
1280 | # Get locals and globals from caller |
|
1309 | # Get locals and globals from caller | |
1281 | if local_ns is None or global_ns is None: |
|
1310 | if local_ns is None or global_ns is None: | |
1282 | call_frame = sys._getframe(stack_depth).f_back |
|
1311 | call_frame = sys._getframe(stack_depth).f_back | |
1283 |
|
1312 | |||
1284 | if local_ns is None: |
|
1313 | if local_ns is None: | |
1285 | local_ns = call_frame.f_locals |
|
1314 | local_ns = call_frame.f_locals | |
1286 | if global_ns is None: |
|
1315 | if global_ns is None: | |
1287 | global_ns = call_frame.f_globals |
|
1316 | global_ns = call_frame.f_globals | |
1288 |
|
1317 | |||
1289 | # Update namespaces and fire up interpreter |
|
1318 | # Update namespaces and fire up interpreter | |
1290 | self.user_ns = local_ns |
|
1319 | ||
|
1320 | # The global one is easy, we can just throw it in | |||
1291 | self.user_global_ns = global_ns |
|
1321 | self.user_global_ns = global_ns | |
1292 |
|
1322 | |||
|
1323 | # but the user/local one is tricky: ipython needs it to store internal | |||
|
1324 | # data, but we also need the locals. We'll copy locals in the user | |||
|
1325 | # one, but will track what got copied so we can delete them at exit. | |||
|
1326 | # This is so that a later embedded call doesn't see locals from a | |||
|
1327 | # previous call (which most likely existed in a separate scope). | |||
|
1328 | local_varnames = local_ns.keys() | |||
|
1329 | self.user_ns.update(local_ns) | |||
|
1330 | ||||
1293 | # Patch for global embedding to make sure that things don't overwrite |
|
1331 | # Patch for global embedding to make sure that things don't overwrite | |
1294 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> |
|
1332 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> | |
1295 | # FIXME. Test this a bit more carefully (the if.. is new) |
|
1333 | # FIXME. Test this a bit more carefully (the if.. is new) | |
1296 | if local_ns is None and global_ns is None: |
|
1334 | if local_ns is None and global_ns is None: | |
1297 | self.user_global_ns.update(__main__.__dict__) |
|
1335 | self.user_global_ns.update(__main__.__dict__) | |
1298 |
|
1336 | |||
1299 | # make sure the tab-completer has the correct frame information, so it |
|
1337 | # make sure the tab-completer has the correct frame information, so it | |
1300 | # actually completes using the frame's locals/globals |
|
1338 | # actually completes using the frame's locals/globals | |
1301 | self.set_completer_frame(call_frame) |
|
1339 | self.set_completer_frame(call_frame) | |
|
1340 | ||||
|
1341 | # before activating the interactive mode, we need to make sure that | |||
|
1342 | # all names in the builtin namespace needed by ipython point to | |||
|
1343 | # ourselves, and not to other instances. | |||
|
1344 | self.add_builtins() | |||
1302 |
|
1345 | |||
1303 | self.interact(header) |
|
1346 | self.interact(header) | |
|
1347 | ||||
|
1348 | # now, purge out the user namespace from anything we might have added | |||
|
1349 | # from the caller's local namespace | |||
|
1350 | delvar = self.user_ns.pop | |||
|
1351 | for var in local_varnames: | |||
|
1352 | delvar(var,None) | |||
|
1353 | # and clean builtins we may have overridden | |||
|
1354 | self.clean_builtins() | |||
1304 |
|
1355 | |||
1305 | def interact(self, banner=None): |
|
1356 | def interact(self, banner=None): | |
1306 | """Closely emulate the interactive Python console. |
|
1357 | """Closely emulate the interactive Python console. | |
1307 |
|
1358 | |||
1308 | The optional banner argument specify the banner to print |
|
1359 | The optional banner argument specify the banner to print | |
1309 | before the first interaction; by default it prints a banner |
|
1360 | before the first interaction; by default it prints a banner | |
1310 | similar to the one printed by the real Python interpreter, |
|
1361 | similar to the one printed by the real Python interpreter, | |
1311 | followed by the current class name in parentheses (so as not |
|
1362 | followed by the current class name in parentheses (so as not | |
1312 | to confuse this with the real interpreter -- since it's so |
|
1363 | to confuse this with the real interpreter -- since it's so | |
1313 | close!). |
|
1364 | close!). | |
1314 |
|
1365 | |||
1315 | """ |
|
1366 | """ | |
1316 | cprt = 'Type "copyright", "credits" or "license" for more information.' |
|
1367 | cprt = 'Type "copyright", "credits" or "license" for more information.' | |
1317 | if banner is None: |
|
1368 | if banner is None: | |
1318 | self.write("Python %s on %s\n%s\n(%s)\n" % |
|
1369 | self.write("Python %s on %s\n%s\n(%s)\n" % | |
1319 | (sys.version, sys.platform, cprt, |
|
1370 | (sys.version, sys.platform, cprt, | |
1320 | self.__class__.__name__)) |
|
1371 | self.__class__.__name__)) | |
1321 | else: |
|
1372 | else: | |
1322 | self.write(banner) |
|
1373 | self.write(banner) | |
1323 |
|
1374 | |||
1324 | more = 0 |
|
1375 | more = 0 | |
1325 |
|
1376 | |||
1326 | # Mark activity in the builtins |
|
1377 | # Mark activity in the builtins | |
1327 | __builtin__.__dict__['__IPYTHON__active'] += 1 |
|
1378 | __builtin__.__dict__['__IPYTHON__active'] += 1 | |
1328 |
|
1379 | |||
1329 | # exit_now is set by a call to %Exit or %Quit |
|
1380 | # exit_now is set by a call to %Exit or %Quit | |
|
1381 | self.exit_now = False | |||
1330 | while not self.exit_now: |
|
1382 | while not self.exit_now: | |
|
1383 | ||||
1331 | try: |
|
1384 | try: | |
1332 | if more: |
|
1385 | if more: | |
1333 | prompt = self.outputcache.prompt2 |
|
1386 | prompt = self.outputcache.prompt2 | |
1334 | if self.autoindent: |
|
1387 | if self.autoindent: | |
1335 | self.readline_startup_hook(self.pre_readline) |
|
1388 | self.readline_startup_hook(self.pre_readline) | |
1336 | else: |
|
1389 | else: | |
1337 | prompt = self.outputcache.prompt1 |
|
1390 | prompt = self.outputcache.prompt1 | |
1338 | try: |
|
1391 | try: | |
1339 | line = self.raw_input(prompt,more) |
|
1392 | line = self.raw_input(prompt,more) | |
1340 | if self.autoindent: |
|
1393 | if self.autoindent: | |
1341 | self.readline_startup_hook(None) |
|
1394 | self.readline_startup_hook(None) | |
1342 | except EOFError: |
|
1395 | except EOFError: | |
1343 | if self.autoindent: |
|
1396 | if self.autoindent: | |
1344 | self.readline_startup_hook(None) |
|
1397 | self.readline_startup_hook(None) | |
1345 | self.write("\n") |
|
1398 | self.write("\n") | |
1346 | self.exit() |
|
1399 | self.exit() | |
1347 | else: |
|
1400 | else: | |
1348 | more = self.push(line) |
|
1401 | more = self.push(line) | |
1349 |
|
1402 | |||
1350 | if (self.SyntaxTB.last_syntax_error and |
|
1403 | if (self.SyntaxTB.last_syntax_error and | |
1351 | self.rc.autoedit_syntax): |
|
1404 | self.rc.autoedit_syntax): | |
1352 | self.edit_syntax_error() |
|
1405 | self.edit_syntax_error() | |
1353 |
|
1406 | |||
1354 | except KeyboardInterrupt: |
|
1407 | except KeyboardInterrupt: | |
1355 | self.write("\nKeyboardInterrupt\n") |
|
1408 | self.write("\nKeyboardInterrupt\n") | |
1356 | self.resetbuffer() |
|
1409 | self.resetbuffer() | |
1357 | more = 0 |
|
1410 | more = 0 | |
1358 | # keep cache in sync with the prompt counter: |
|
1411 | # keep cache in sync with the prompt counter: | |
1359 | self.outputcache.prompt_count -= 1 |
|
1412 | self.outputcache.prompt_count -= 1 | |
1360 |
|
1413 | |||
1361 | if self.autoindent: |
|
1414 | if self.autoindent: | |
1362 | self.indent_current_nsp = 0 |
|
1415 | self.indent_current_nsp = 0 | |
1363 | self.indent_current = ' '* self.indent_current_nsp |
|
1416 | self.indent_current = ' '* self.indent_current_nsp | |
1364 |
|
1417 | |||
1365 | except bdb.BdbQuit: |
|
1418 | except bdb.BdbQuit: | |
1366 | warn("The Python debugger has exited with a BdbQuit exception.\n" |
|
1419 | warn("The Python debugger has exited with a BdbQuit exception.\n" | |
1367 | "Because of how pdb handles the stack, it is impossible\n" |
|
1420 | "Because of how pdb handles the stack, it is impossible\n" | |
1368 | "for IPython to properly format this particular exception.\n" |
|
1421 | "for IPython to properly format this particular exception.\n" | |
1369 | "IPython will resume normal operation.") |
|
1422 | "IPython will resume normal operation.") | |
1370 |
|
1423 | |||
1371 | # We are off again... |
|
1424 | # We are off again... | |
1372 | __builtin__.__dict__['__IPYTHON__active'] -= 1 |
|
1425 | __builtin__.__dict__['__IPYTHON__active'] -= 1 | |
1373 |
|
1426 | |||
1374 | def excepthook(self, type, value, tb): |
|
1427 | def excepthook(self, type, value, tb): | |
1375 | """One more defense for GUI apps that call sys.excepthook. |
|
1428 | """One more defense for GUI apps that call sys.excepthook. | |
1376 |
|
1429 | |||
1377 | GUI frameworks like wxPython trap exceptions and call |
|
1430 | GUI frameworks like wxPython trap exceptions and call | |
1378 | sys.excepthook themselves. I guess this is a feature that |
|
1431 | sys.excepthook themselves. I guess this is a feature that | |
1379 | enables them to keep running after exceptions that would |
|
1432 | enables them to keep running after exceptions that would | |
1380 | otherwise kill their mainloop. This is a bother for IPython |
|
1433 | otherwise kill their mainloop. This is a bother for IPython | |
1381 | which excepts to catch all of the program exceptions with a try: |
|
1434 | which excepts to catch all of the program exceptions with a try: | |
1382 | except: statement. |
|
1435 | except: statement. | |
1383 |
|
1436 | |||
1384 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if |
|
1437 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if | |
1385 | any app directly invokes sys.excepthook, it will look to the user like |
|
1438 | any app directly invokes sys.excepthook, it will look to the user like | |
1386 | IPython crashed. In order to work around this, we can disable the |
|
1439 | IPython crashed. In order to work around this, we can disable the | |
1387 | CrashHandler and replace it with this excepthook instead, which prints a |
|
1440 | CrashHandler and replace it with this excepthook instead, which prints a | |
1388 | regular traceback using our InteractiveTB. In this fashion, apps which |
|
1441 | regular traceback using our InteractiveTB. In this fashion, apps which | |
1389 | call sys.excepthook will generate a regular-looking exception from |
|
1442 | call sys.excepthook will generate a regular-looking exception from | |
1390 | IPython, and the CrashHandler will only be triggered by real IPython |
|
1443 | IPython, and the CrashHandler will only be triggered by real IPython | |
1391 | crashes. |
|
1444 | crashes. | |
1392 |
|
1445 | |||
1393 | This hook should be used sparingly, only in places which are not likely |
|
1446 | This hook should be used sparingly, only in places which are not likely | |
1394 | to be true IPython errors. |
|
1447 | to be true IPython errors. | |
1395 | """ |
|
1448 | """ | |
1396 |
|
1449 | |||
1397 | self.InteractiveTB(type, value, tb, tb_offset=0) |
|
1450 | self.InteractiveTB(type, value, tb, tb_offset=0) | |
1398 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1451 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1399 | self.readline.set_completer(self.Completer.complete) |
|
1452 | self.readline.set_completer(self.Completer.complete) | |
1400 |
|
1453 | |||
1401 | def call_alias(self,alias,rest=''): |
|
1454 | def call_alias(self,alias,rest=''): | |
1402 | """Call an alias given its name and the rest of the line. |
|
1455 | """Call an alias given its name and the rest of the line. | |
1403 |
|
1456 | |||
1404 | This function MUST be given a proper alias, because it doesn't make |
|
1457 | This function MUST be given a proper alias, because it doesn't make | |
1405 | any checks when looking up into the alias table. The caller is |
|
1458 | any checks when looking up into the alias table. The caller is | |
1406 | responsible for invoking it only with a valid alias.""" |
|
1459 | responsible for invoking it only with a valid alias.""" | |
1407 |
|
1460 | |||
1408 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg |
|
1461 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg | |
1409 | nargs,cmd = self.alias_table[alias] |
|
1462 | nargs,cmd = self.alias_table[alias] | |
1410 | # Expand the %l special to be the user's input line |
|
1463 | # Expand the %l special to be the user's input line | |
1411 | if cmd.find('%l') >= 0: |
|
1464 | if cmd.find('%l') >= 0: | |
1412 | cmd = cmd.replace('%l',rest) |
|
1465 | cmd = cmd.replace('%l',rest) | |
1413 | rest = '' |
|
1466 | rest = '' | |
1414 | if nargs==0: |
|
1467 | if nargs==0: | |
1415 | # Simple, argument-less aliases |
|
1468 | # Simple, argument-less aliases | |
1416 | cmd = '%s %s' % (cmd,rest) |
|
1469 | cmd = '%s %s' % (cmd,rest) | |
1417 | else: |
|
1470 | else: | |
1418 | # Handle aliases with positional arguments |
|
1471 | # Handle aliases with positional arguments | |
1419 | args = rest.split(None,nargs) |
|
1472 | args = rest.split(None,nargs) | |
1420 | if len(args)< nargs: |
|
1473 | if len(args)< nargs: | |
1421 | error('Alias <%s> requires %s arguments, %s given.' % |
|
1474 | error('Alias <%s> requires %s arguments, %s given.' % | |
1422 | (alias,nargs,len(args))) |
|
1475 | (alias,nargs,len(args))) | |
1423 | return |
|
1476 | return | |
1424 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) |
|
1477 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) | |
1425 | # Now call the macro, evaluating in the user's namespace |
|
1478 | # Now call the macro, evaluating in the user's namespace | |
1426 | try: |
|
1479 | try: | |
1427 | self.system(cmd) |
|
1480 | self.system(cmd) | |
1428 | except: |
|
1481 | except: | |
1429 | self.showtraceback() |
|
1482 | self.showtraceback() | |
1430 |
|
1483 | |||
1431 | def autoindent_update(self,line): |
|
1484 | def autoindent_update(self,line): | |
1432 | """Keep track of the indent level.""" |
|
1485 | """Keep track of the indent level.""" | |
1433 | if self.autoindent: |
|
1486 | if self.autoindent: | |
1434 | if line: |
|
1487 | if line: | |
1435 | ini_spaces = ini_spaces_re.match(line) |
|
1488 | ini_spaces = ini_spaces_re.match(line) | |
1436 | if ini_spaces: |
|
1489 | if ini_spaces: | |
1437 | nspaces = ini_spaces.end() |
|
1490 | nspaces = ini_spaces.end() | |
1438 | else: |
|
1491 | else: | |
1439 | nspaces = 0 |
|
1492 | nspaces = 0 | |
1440 | self.indent_current_nsp = nspaces |
|
1493 | self.indent_current_nsp = nspaces | |
1441 |
|
1494 | |||
1442 | if line[-1] == ':': |
|
1495 | if line[-1] == ':': | |
1443 | self.indent_current_nsp += 4 |
|
1496 | self.indent_current_nsp += 4 | |
1444 | elif dedent_re.match(line): |
|
1497 | elif dedent_re.match(line): | |
1445 | self.indent_current_nsp -= 4 |
|
1498 | self.indent_current_nsp -= 4 | |
1446 | else: |
|
1499 | else: | |
1447 | self.indent_current_nsp = 0 |
|
1500 | self.indent_current_nsp = 0 | |
1448 |
|
1501 | |||
1449 | # indent_current is the actual string to be inserted |
|
1502 | # indent_current is the actual string to be inserted | |
1450 | # by the readline hooks for indentation |
|
1503 | # by the readline hooks for indentation | |
1451 | self.indent_current = ' '* self.indent_current_nsp |
|
1504 | self.indent_current = ' '* self.indent_current_nsp | |
1452 |
|
1505 | |||
1453 | def runlines(self,lines): |
|
1506 | def runlines(self,lines): | |
1454 | """Run a string of one or more lines of source. |
|
1507 | """Run a string of one or more lines of source. | |
1455 |
|
1508 | |||
1456 | This method is capable of running a string containing multiple source |
|
1509 | This method is capable of running a string containing multiple source | |
1457 | lines, as if they had been entered at the IPython prompt. Since it |
|
1510 | lines, as if they had been entered at the IPython prompt. Since it | |
1458 | exposes IPython's processing machinery, the given strings can contain |
|
1511 | exposes IPython's processing machinery, the given strings can contain | |
1459 | magic calls (%magic), special shell access (!cmd), etc.""" |
|
1512 | magic calls (%magic), special shell access (!cmd), etc.""" | |
1460 |
|
1513 | |||
1461 | # We must start with a clean buffer, in case this is run from an |
|
1514 | # We must start with a clean buffer, in case this is run from an | |
1462 | # interactive IPython session (via a magic, for example). |
|
1515 | # interactive IPython session (via a magic, for example). | |
1463 | self.resetbuffer() |
|
1516 | self.resetbuffer() | |
1464 | lines = lines.split('\n') |
|
1517 | lines = lines.split('\n') | |
1465 | more = 0 |
|
1518 | more = 0 | |
1466 | for line in lines: |
|
1519 | for line in lines: | |
1467 | # skip blank lines so we don't mess up the prompt counter, but do |
|
1520 | # skip blank lines so we don't mess up the prompt counter, but do | |
1468 | # NOT skip even a blank line if we are in a code block (more is |
|
1521 | # NOT skip even a blank line if we are in a code block (more is | |
1469 | # true) |
|
1522 | # true) | |
1470 | if line or more: |
|
1523 | if line or more: | |
1471 | more = self.push(self.prefilter(line,more)) |
|
1524 | more = self.push(self.prefilter(line,more)) | |
1472 | # IPython's runsource returns None if there was an error |
|
1525 | # IPython's runsource returns None if there was an error | |
1473 | # compiling the code. This allows us to stop processing right |
|
1526 | # compiling the code. This allows us to stop processing right | |
1474 | # away, so the user gets the error message at the right place. |
|
1527 | # away, so the user gets the error message at the right place. | |
1475 | if more is None: |
|
1528 | if more is None: | |
1476 | break |
|
1529 | break | |
1477 | # final newline in case the input didn't have it, so that the code |
|
1530 | # final newline in case the input didn't have it, so that the code | |
1478 | # actually does get executed |
|
1531 | # actually does get executed | |
1479 | if more: |
|
1532 | if more: | |
1480 | self.push('\n') |
|
1533 | self.push('\n') | |
1481 |
|
1534 | |||
1482 | def runsource(self, source, filename='<input>', symbol='single'): |
|
1535 | def runsource(self, source, filename='<input>', symbol='single'): | |
1483 | """Compile and run some source in the interpreter. |
|
1536 | """Compile and run some source in the interpreter. | |
1484 |
|
1537 | |||
1485 | Arguments are as for compile_command(). |
|
1538 | Arguments are as for compile_command(). | |
1486 |
|
1539 | |||
1487 | One several things can happen: |
|
1540 | One several things can happen: | |
1488 |
|
1541 | |||
1489 | 1) The input is incorrect; compile_command() raised an |
|
1542 | 1) The input is incorrect; compile_command() raised an | |
1490 | exception (SyntaxError or OverflowError). A syntax traceback |
|
1543 | exception (SyntaxError or OverflowError). A syntax traceback | |
1491 | will be printed by calling the showsyntaxerror() method. |
|
1544 | will be printed by calling the showsyntaxerror() method. | |
1492 |
|
1545 | |||
1493 | 2) The input is incomplete, and more input is required; |
|
1546 | 2) The input is incomplete, and more input is required; | |
1494 | compile_command() returned None. Nothing happens. |
|
1547 | compile_command() returned None. Nothing happens. | |
1495 |
|
1548 | |||
1496 | 3) The input is complete; compile_command() returned a code |
|
1549 | 3) The input is complete; compile_command() returned a code | |
1497 | object. The code is executed by calling self.runcode() (which |
|
1550 | object. The code is executed by calling self.runcode() (which | |
1498 | also handles run-time exceptions, except for SystemExit). |
|
1551 | also handles run-time exceptions, except for SystemExit). | |
1499 |
|
1552 | |||
1500 | The return value is: |
|
1553 | The return value is: | |
1501 |
|
1554 | |||
1502 | - True in case 2 |
|
1555 | - True in case 2 | |
1503 |
|
1556 | |||
1504 | - False in the other cases, unless an exception is raised, where |
|
1557 | - False in the other cases, unless an exception is raised, where | |
1505 | None is returned instead. This can be used by external callers to |
|
1558 | None is returned instead. This can be used by external callers to | |
1506 | know whether to continue feeding input or not. |
|
1559 | know whether to continue feeding input or not. | |
1507 |
|
1560 | |||
1508 | The return value can be used to decide whether to use sys.ps1 or |
|
1561 | The return value can be used to decide whether to use sys.ps1 or | |
1509 | sys.ps2 to prompt the next line.""" |
|
1562 | sys.ps2 to prompt the next line.""" | |
1510 |
|
1563 | |||
1511 | try: |
|
1564 | try: | |
1512 | code = self.compile(source,filename,symbol) |
|
1565 | code = self.compile(source,filename,symbol) | |
1513 | except (OverflowError, SyntaxError, ValueError): |
|
1566 | except (OverflowError, SyntaxError, ValueError): | |
1514 | # Case 1 |
|
1567 | # Case 1 | |
1515 | self.showsyntaxerror(filename) |
|
1568 | self.showsyntaxerror(filename) | |
1516 | return None |
|
1569 | return None | |
1517 |
|
1570 | |||
1518 | if code is None: |
|
1571 | if code is None: | |
1519 | # Case 2 |
|
1572 | # Case 2 | |
1520 | return True |
|
1573 | return True | |
1521 |
|
1574 | |||
1522 | # Case 3 |
|
1575 | # Case 3 | |
1523 | # We store the code object so that threaded shells and |
|
1576 | # We store the code object so that threaded shells and | |
1524 | # custom exception handlers can access all this info if needed. |
|
1577 | # custom exception handlers can access all this info if needed. | |
1525 | # The source corresponding to this can be obtained from the |
|
1578 | # The source corresponding to this can be obtained from the | |
1526 | # buffer attribute as '\n'.join(self.buffer). |
|
1579 | # buffer attribute as '\n'.join(self.buffer). | |
1527 | self.code_to_run = code |
|
1580 | self.code_to_run = code | |
1528 | # now actually execute the code object |
|
1581 | # now actually execute the code object | |
1529 | if self.runcode(code) == 0: |
|
1582 | if self.runcode(code) == 0: | |
1530 | return False |
|
1583 | return False | |
1531 | else: |
|
1584 | else: | |
1532 | return None |
|
1585 | return None | |
1533 |
|
1586 | |||
1534 | def runcode(self,code_obj): |
|
1587 | def runcode(self,code_obj): | |
1535 | """Execute a code object. |
|
1588 | """Execute a code object. | |
1536 |
|
1589 | |||
1537 | When an exception occurs, self.showtraceback() is called to display a |
|
1590 | When an exception occurs, self.showtraceback() is called to display a | |
1538 | traceback. |
|
1591 | traceback. | |
1539 |
|
1592 | |||
1540 | Return value: a flag indicating whether the code to be run completed |
|
1593 | Return value: a flag indicating whether the code to be run completed | |
1541 | successfully: |
|
1594 | successfully: | |
1542 |
|
1595 | |||
1543 | - 0: successful execution. |
|
1596 | - 0: successful execution. | |
1544 | - 1: an error occurred. |
|
1597 | - 1: an error occurred. | |
1545 | """ |
|
1598 | """ | |
1546 |
|
1599 | |||
1547 | # Set our own excepthook in case the user code tries to call it |
|
1600 | # Set our own excepthook in case the user code tries to call it | |
1548 | # directly, so that the IPython crash handler doesn't get triggered |
|
1601 | # directly, so that the IPython crash handler doesn't get triggered | |
1549 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook |
|
1602 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook | |
1550 |
|
1603 | |||
1551 | # we save the original sys.excepthook in the instance, in case config |
|
1604 | # we save the original sys.excepthook in the instance, in case config | |
1552 | # code (such as magics) needs access to it. |
|
1605 | # code (such as magics) needs access to it. | |
1553 | self.sys_excepthook = old_excepthook |
|
1606 | self.sys_excepthook = old_excepthook | |
1554 | outflag = 1 # happens in more places, so it's easier as default |
|
1607 | outflag = 1 # happens in more places, so it's easier as default | |
1555 | try: |
|
1608 | try: | |
1556 | try: |
|
1609 | try: | |
1557 | # Embedded instances require separate global/local namespaces |
|
1610 | # Embedded instances require separate global/local namespaces | |
1558 | # so they can see both the surrounding (local) namespace and |
|
1611 | # so they can see both the surrounding (local) namespace and | |
1559 | # the module-level globals when called inside another function. |
|
1612 | # the module-level globals when called inside another function. | |
1560 | if self.embedded: |
|
1613 | if self.embedded: | |
1561 | exec code_obj in self.user_global_ns, self.user_ns |
|
1614 | exec code_obj in self.user_global_ns, self.user_ns | |
1562 | # Normal (non-embedded) instances should only have a single |
|
1615 | # Normal (non-embedded) instances should only have a single | |
1563 | # namespace for user code execution, otherwise functions won't |
|
1616 | # namespace for user code execution, otherwise functions won't | |
1564 | # see interactive top-level globals. |
|
1617 | # see interactive top-level globals. | |
1565 | else: |
|
1618 | else: | |
1566 | exec code_obj in self.user_ns |
|
1619 | exec code_obj in self.user_ns | |
1567 | finally: |
|
1620 | finally: | |
1568 | # Reset our crash handler in place |
|
1621 | # Reset our crash handler in place | |
1569 | sys.excepthook = old_excepthook |
|
1622 | sys.excepthook = old_excepthook | |
1570 | except SystemExit: |
|
1623 | except SystemExit: | |
1571 | self.resetbuffer() |
|
1624 | self.resetbuffer() | |
1572 | self.showtraceback() |
|
1625 | self.showtraceback() | |
1573 | warn("Type exit or quit to exit IPython " |
|
1626 | warn("Type exit or quit to exit IPython " | |
1574 | "(%Exit or %Quit do so unconditionally).",level=1) |
|
1627 | "(%Exit or %Quit do so unconditionally).",level=1) | |
1575 | except self.custom_exceptions: |
|
1628 | except self.custom_exceptions: | |
1576 | etype,value,tb = sys.exc_info() |
|
1629 | etype,value,tb = sys.exc_info() | |
1577 | self.CustomTB(etype,value,tb) |
|
1630 | self.CustomTB(etype,value,tb) | |
1578 | except: |
|
1631 | except: | |
1579 | self.showtraceback() |
|
1632 | self.showtraceback() | |
1580 | else: |
|
1633 | else: | |
1581 | outflag = 0 |
|
1634 | outflag = 0 | |
1582 | if softspace(sys.stdout, 0): |
|
1635 | if softspace(sys.stdout, 0): | |
1583 |
|
1636 | |||
1584 | # Flush out code object which has been run (and source) |
|
1637 | # Flush out code object which has been run (and source) | |
1585 | self.code_to_run = None |
|
1638 | self.code_to_run = None | |
1586 | return outflag |
|
1639 | return outflag | |
1587 |
|
1640 | |||
1588 | def push(self, line): |
|
1641 | def push(self, line): | |
1589 | """Push a line to the interpreter. |
|
1642 | """Push a line to the interpreter. | |
1590 |
|
1643 | |||
1591 | The line should not have a trailing newline; it may have |
|
1644 | The line should not have a trailing newline; it may have | |
1592 | internal newlines. The line is appended to a buffer and the |
|
1645 | internal newlines. The line is appended to a buffer and the | |
1593 | interpreter's runsource() method is called with the |
|
1646 | interpreter's runsource() method is called with the | |
1594 | concatenated contents of the buffer as source. If this |
|
1647 | concatenated contents of the buffer as source. If this | |
1595 | indicates that the command was executed or invalid, the buffer |
|
1648 | indicates that the command was executed or invalid, the buffer | |
1596 | is reset; otherwise, the command is incomplete, and the buffer |
|
1649 | is reset; otherwise, the command is incomplete, and the buffer | |
1597 | is left as it was after the line was appended. The return |
|
1650 | is left as it was after the line was appended. The return | |
1598 | value is 1 if more input is required, 0 if the line was dealt |
|
1651 | value is 1 if more input is required, 0 if the line was dealt | |
1599 | with in some way (this is the same as runsource()). |
|
1652 | with in some way (this is the same as runsource()). | |
1600 | """ |
|
1653 | """ | |
1601 |
|
1654 | |||
1602 | # autoindent management should be done here, and not in the |
|
1655 | # autoindent management should be done here, and not in the | |
1603 | # interactive loop, since that one is only seen by keyboard input. We |
|
1656 | # interactive loop, since that one is only seen by keyboard input. We | |
1604 | # need this done correctly even for code run via runlines (which uses |
|
1657 | # need this done correctly even for code run via runlines (which uses | |
1605 | # push). |
|
1658 | # push). | |
1606 |
|
1659 | |||
1607 | #print 'push line: <%s>' % line # dbg |
|
1660 | #print 'push line: <%s>' % line # dbg | |
1608 | self.autoindent_update(line) |
|
1661 | self.autoindent_update(line) | |
1609 |
|
1662 | |||
1610 | self.buffer.append(line) |
|
1663 | self.buffer.append(line) | |
1611 | more = self.runsource('\n'.join(self.buffer), self.filename) |
|
1664 | more = self.runsource('\n'.join(self.buffer), self.filename) | |
1612 | if not more: |
|
1665 | if not more: | |
1613 | self.resetbuffer() |
|
1666 | self.resetbuffer() | |
1614 | return more |
|
1667 | return more | |
1615 |
|
1668 | |||
1616 | def resetbuffer(self): |
|
1669 | def resetbuffer(self): | |
1617 | """Reset the input buffer.""" |
|
1670 | """Reset the input buffer.""" | |
1618 | self.buffer[:] = [] |
|
1671 | self.buffer[:] = [] | |
1619 |
|
1672 | |||
1620 | def raw_input(self,prompt='',continue_prompt=False): |
|
1673 | def raw_input(self,prompt='',continue_prompt=False): | |
1621 | """Write a prompt and read a line. |
|
1674 | """Write a prompt and read a line. | |
1622 |
|
1675 | |||
1623 | The returned line does not include the trailing newline. |
|
1676 | The returned line does not include the trailing newline. | |
1624 | When the user enters the EOF key sequence, EOFError is raised. |
|
1677 | When the user enters the EOF key sequence, EOFError is raised. | |
1625 |
|
1678 | |||
1626 | Optional inputs: |
|
1679 | Optional inputs: | |
1627 |
|
1680 | |||
1628 | - prompt(''): a string to be printed to prompt the user. |
|
1681 | - prompt(''): a string to be printed to prompt the user. | |
1629 |
|
1682 | |||
1630 | - continue_prompt(False): whether this line is the first one or a |
|
1683 | - continue_prompt(False): whether this line is the first one or a | |
1631 | continuation in a sequence of inputs. |
|
1684 | continuation in a sequence of inputs. | |
1632 | """ |
|
1685 | """ | |
1633 |
|
1686 | |||
1634 | line = raw_input_original(prompt) |
|
1687 | line = raw_input_original(prompt) | |
1635 | # Try to be reasonably smart about not re-indenting pasted input more |
|
1688 | # Try to be reasonably smart about not re-indenting pasted input more | |
1636 | # than necessary. We do this by trimming out the auto-indent initial |
|
1689 | # than necessary. We do this by trimming out the auto-indent initial | |
1637 | # spaces, if the user's actual input started itself with whitespace. |
|
1690 | # spaces, if the user's actual input started itself with whitespace. | |
1638 | if self.autoindent: |
|
1691 | if self.autoindent: | |
1639 | line2 = line[self.indent_current_nsp:] |
|
1692 | line2 = line[self.indent_current_nsp:] | |
1640 | if line2[0:1] in (' ','\t'): |
|
1693 | if line2[0:1] in (' ','\t'): | |
1641 | line = line2 |
|
1694 | line = line2 | |
1642 | return self.prefilter(line,continue_prompt) |
|
1695 | return self.prefilter(line,continue_prompt) | |
1643 |
|
1696 | |||
1644 | def split_user_input(self,line): |
|
1697 | def split_user_input(self,line): | |
1645 | """Split user input into pre-char, function part and rest.""" |
|
1698 | """Split user input into pre-char, function part and rest.""" | |
1646 |
|
1699 | |||
1647 | lsplit = self.line_split.match(line) |
|
1700 | lsplit = self.line_split.match(line) | |
1648 | if lsplit is None: # no regexp match returns None |
|
1701 | if lsplit is None: # no regexp match returns None | |
1649 | try: |
|
1702 | try: | |
1650 | iFun,theRest = line.split(None,1) |
|
1703 | iFun,theRest = line.split(None,1) | |
1651 | except ValueError: |
|
1704 | except ValueError: | |
1652 | iFun,theRest = line,'' |
|
1705 | iFun,theRest = line,'' | |
1653 | pre = re.match('^(\s*)(.*)',line).groups()[0] |
|
1706 | pre = re.match('^(\s*)(.*)',line).groups()[0] | |
1654 | else: |
|
1707 | else: | |
1655 | pre,iFun,theRest = lsplit.groups() |
|
1708 | pre,iFun,theRest = lsplit.groups() | |
1656 |
|
1709 | |||
1657 | #print 'line:<%s>' % line # dbg |
|
1710 | #print 'line:<%s>' % line # dbg | |
1658 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg |
|
1711 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg | |
1659 | return pre,iFun.strip(),theRest |
|
1712 | return pre,iFun.strip(),theRest | |
1660 |
|
1713 | |||
1661 | def _prefilter(self, line, continue_prompt): |
|
1714 | def _prefilter(self, line, continue_prompt): | |
1662 | """Calls different preprocessors, depending on the form of line.""" |
|
1715 | """Calls different preprocessors, depending on the form of line.""" | |
1663 |
|
1716 | |||
1664 | # All handlers *must* return a value, even if it's blank (''). |
|
1717 | # All handlers *must* return a value, even if it's blank (''). | |
1665 |
|
1718 | |||
1666 | # Lines are NOT logged here. Handlers should process the line as |
|
1719 | # Lines are NOT logged here. Handlers should process the line as | |
1667 | # needed, update the cache AND log it (so that the input cache array |
|
1720 | # needed, update the cache AND log it (so that the input cache array | |
1668 | # stays synced). |
|
1721 | # stays synced). | |
1669 |
|
1722 | |||
1670 | # This function is _very_ delicate, and since it's also the one which |
|
1723 | # This function is _very_ delicate, and since it's also the one which | |
1671 | # determines IPython's response to user input, it must be as efficient |
|
1724 | # determines IPython's response to user input, it must be as efficient | |
1672 | # as possible. For this reason it has _many_ returns in it, trying |
|
1725 | # as possible. For this reason it has _many_ returns in it, trying | |
1673 | # always to exit as quickly as it can figure out what it needs to do. |
|
1726 | # always to exit as quickly as it can figure out what it needs to do. | |
1674 |
|
1727 | |||
1675 | # This function is the main responsible for maintaining IPython's |
|
1728 | # This function is the main responsible for maintaining IPython's | |
1676 | # behavior respectful of Python's semantics. So be _very_ careful if |
|
1729 | # behavior respectful of Python's semantics. So be _very_ careful if | |
1677 | # making changes to anything here. |
|
1730 | # making changes to anything here. | |
1678 |
|
1731 | |||
1679 | #..................................................................... |
|
1732 | #..................................................................... | |
1680 | # Code begins |
|
1733 | # Code begins | |
1681 |
|
1734 | |||
1682 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg |
|
1735 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg | |
1683 |
|
1736 | |||
1684 | # save the line away in case we crash, so the post-mortem handler can |
|
1737 | # save the line away in case we crash, so the post-mortem handler can | |
1685 | # record it |
|
1738 | # record it | |
1686 | self._last_input_line = line |
|
1739 | self._last_input_line = line | |
1687 |
|
1740 | |||
1688 | #print '***line: <%s>' % line # dbg |
|
1741 | #print '***line: <%s>' % line # dbg | |
1689 |
|
1742 | |||
1690 | # the input history needs to track even empty lines |
|
1743 | # the input history needs to track even empty lines | |
1691 | if not line.strip(): |
|
1744 | if not line.strip(): | |
1692 | if not continue_prompt: |
|
1745 | if not continue_prompt: | |
1693 | self.outputcache.prompt_count -= 1 |
|
1746 | self.outputcache.prompt_count -= 1 | |
1694 | return self.handle_normal(line,continue_prompt) |
|
1747 | return self.handle_normal(line,continue_prompt) | |
1695 | #return self.handle_normal('',continue_prompt) |
|
1748 | #return self.handle_normal('',continue_prompt) | |
1696 |
|
1749 | |||
1697 | # print '***cont',continue_prompt # dbg |
|
1750 | # print '***cont',continue_prompt # dbg | |
1698 | # special handlers are only allowed for single line statements |
|
1751 | # special handlers are only allowed for single line statements | |
1699 | if continue_prompt and not self.rc.multi_line_specials: |
|
1752 | if continue_prompt and not self.rc.multi_line_specials: | |
1700 | return self.handle_normal(line,continue_prompt) |
|
1753 | return self.handle_normal(line,continue_prompt) | |
1701 |
|
1754 | |||
1702 | # For the rest, we need the structure of the input |
|
1755 | # For the rest, we need the structure of the input | |
1703 | pre,iFun,theRest = self.split_user_input(line) |
|
1756 | pre,iFun,theRest = self.split_user_input(line) | |
1704 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1757 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1705 |
|
1758 | |||
1706 | # First check for explicit escapes in the last/first character |
|
1759 | # First check for explicit escapes in the last/first character | |
1707 | handler = None |
|
1760 | handler = None | |
1708 | if line[-1] == self.ESC_HELP: |
|
1761 | if line[-1] == self.ESC_HELP: | |
1709 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end |
|
1762 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end | |
1710 | if handler is None: |
|
1763 | if handler is None: | |
1711 | # look at the first character of iFun, NOT of line, so we skip |
|
1764 | # look at the first character of iFun, NOT of line, so we skip | |
1712 | # leading whitespace in multiline input |
|
1765 | # leading whitespace in multiline input | |
1713 | handler = self.esc_handlers.get(iFun[0:1]) |
|
1766 | handler = self.esc_handlers.get(iFun[0:1]) | |
1714 | if handler is not None: |
|
1767 | if handler is not None: | |
1715 | return handler(line,continue_prompt,pre,iFun,theRest) |
|
1768 | return handler(line,continue_prompt,pre,iFun,theRest) | |
1716 | # Emacs ipython-mode tags certain input lines |
|
1769 | # Emacs ipython-mode tags certain input lines | |
1717 | if line.endswith('# PYTHON-MODE'): |
|
1770 | if line.endswith('# PYTHON-MODE'): | |
1718 | return self.handle_emacs(line,continue_prompt) |
|
1771 | return self.handle_emacs(line,continue_prompt) | |
1719 |
|
1772 | |||
1720 | # Next, check if we can automatically execute this thing |
|
1773 | # Next, check if we can automatically execute this thing | |
1721 |
|
1774 | |||
1722 | # Allow ! in multi-line statements if multi_line_specials is on: |
|
1775 | # Allow ! in multi-line statements if multi_line_specials is on: | |
1723 | if continue_prompt and self.rc.multi_line_specials and \ |
|
1776 | if continue_prompt and self.rc.multi_line_specials and \ | |
1724 | iFun.startswith(self.ESC_SHELL): |
|
1777 | iFun.startswith(self.ESC_SHELL): | |
1725 | return self.handle_shell_escape(line,continue_prompt, |
|
1778 | return self.handle_shell_escape(line,continue_prompt, | |
1726 | pre=pre,iFun=iFun, |
|
1779 | pre=pre,iFun=iFun, | |
1727 | theRest=theRest) |
|
1780 | theRest=theRest) | |
1728 |
|
1781 | |||
1729 | # Let's try to find if the input line is a magic fn |
|
1782 | # Let's try to find if the input line is a magic fn | |
1730 | oinfo = None |
|
1783 | oinfo = None | |
1731 | if hasattr(self,'magic_'+iFun): |
|
1784 | if hasattr(self,'magic_'+iFun): | |
1732 | # WARNING: _ofind uses getattr(), so it can consume generators and |
|
1785 | # WARNING: _ofind uses getattr(), so it can consume generators and | |
1733 | # cause other side effects. |
|
1786 | # cause other side effects. | |
1734 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1787 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1735 | if oinfo['ismagic']: |
|
1788 | if oinfo['ismagic']: | |
1736 | # Be careful not to call magics when a variable assignment is |
|
1789 | # Be careful not to call magics when a variable assignment is | |
1737 | # being made (ls='hi', for example) |
|
1790 | # being made (ls='hi', for example) | |
1738 | if self.rc.automagic and \ |
|
1791 | if self.rc.automagic and \ | |
1739 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ |
|
1792 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ | |
1740 | (self.rc.multi_line_specials or not continue_prompt): |
|
1793 | (self.rc.multi_line_specials or not continue_prompt): | |
1741 | return self.handle_magic(line,continue_prompt, |
|
1794 | return self.handle_magic(line,continue_prompt, | |
1742 | pre,iFun,theRest) |
|
1795 | pre,iFun,theRest) | |
1743 | else: |
|
1796 | else: | |
1744 | return self.handle_normal(line,continue_prompt) |
|
1797 | return self.handle_normal(line,continue_prompt) | |
1745 |
|
1798 | |||
1746 | # If the rest of the line begins with an (in)equality, assginment or |
|
1799 | # If the rest of the line begins with an (in)equality, assginment or | |
1747 | # function call, we should not call _ofind but simply execute it. |
|
1800 | # function call, we should not call _ofind but simply execute it. | |
1748 | # This avoids spurious geattr() accesses on objects upon assignment. |
|
1801 | # This avoids spurious geattr() accesses on objects upon assignment. | |
1749 | # |
|
1802 | # | |
1750 | # It also allows users to assign to either alias or magic names true |
|
1803 | # It also allows users to assign to either alias or magic names true | |
1751 | # python variables (the magic/alias systems always take second seat to |
|
1804 | # python variables (the magic/alias systems always take second seat to | |
1752 | # true python code). |
|
1805 | # true python code). | |
1753 | if theRest and theRest[0] in '!=()': |
|
1806 | if theRest and theRest[0] in '!=()': | |
1754 | return self.handle_normal(line,continue_prompt) |
|
1807 | return self.handle_normal(line,continue_prompt) | |
1755 |
|
1808 | |||
1756 | if oinfo is None: |
|
1809 | if oinfo is None: | |
1757 | # let's try to ensure that _oinfo is ONLY called when autocall is |
|
1810 | # let's try to ensure that _oinfo is ONLY called when autocall is | |
1758 | # on. Since it has inevitable potential side effects, at least |
|
1811 | # on. Since it has inevitable potential side effects, at least | |
1759 | # having autocall off should be a guarantee to the user that no |
|
1812 | # having autocall off should be a guarantee to the user that no | |
1760 | # weird things will happen. |
|
1813 | # weird things will happen. | |
1761 |
|
1814 | |||
1762 | if self.rc.autocall: |
|
1815 | if self.rc.autocall: | |
1763 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1816 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1764 | else: |
|
1817 | else: | |
1765 | # in this case, all that's left is either an alias or |
|
1818 | # in this case, all that's left is either an alias or | |
1766 | # processing the line normally. |
|
1819 | # processing the line normally. | |
1767 | if iFun in self.alias_table: |
|
1820 | if iFun in self.alias_table: | |
1768 | return self.handle_alias(line,continue_prompt, |
|
1821 | return self.handle_alias(line,continue_prompt, | |
1769 | pre,iFun,theRest) |
|
1822 | pre,iFun,theRest) | |
1770 | else: |
|
1823 | else: | |
1771 | return self.handle_normal(line,continue_prompt) |
|
1824 | return self.handle_normal(line,continue_prompt) | |
1772 |
|
1825 | |||
1773 | if not oinfo['found']: |
|
1826 | if not oinfo['found']: | |
1774 | return self.handle_normal(line,continue_prompt) |
|
1827 | return self.handle_normal(line,continue_prompt) | |
1775 | else: |
|
1828 | else: | |
1776 | #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg |
|
1829 | #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg | |
1777 | if oinfo['isalias']: |
|
1830 | if oinfo['isalias']: | |
1778 | return self.handle_alias(line,continue_prompt, |
|
1831 | return self.handle_alias(line,continue_prompt, | |
1779 | pre,iFun,theRest) |
|
1832 | pre,iFun,theRest) | |
1780 |
|
1833 | |||
1781 | if self.rc.autocall and \ |
|
1834 | if self.rc.autocall and \ | |
1782 | not self.re_exclude_auto.match(theRest) and \ |
|
1835 | not self.re_exclude_auto.match(theRest) and \ | |
1783 | self.re_fun_name.match(iFun) and \ |
|
1836 | self.re_fun_name.match(iFun) and \ | |
1784 | callable(oinfo['obj']) : |
|
1837 | callable(oinfo['obj']) : | |
1785 | #print 'going auto' # dbg |
|
1838 | #print 'going auto' # dbg | |
1786 | return self.handle_auto(line,continue_prompt,pre,iFun,theRest) |
|
1839 | return self.handle_auto(line,continue_prompt,pre,iFun,theRest) | |
1787 | else: |
|
1840 | else: | |
1788 | #print 'was callable?', callable(oinfo['obj']) # dbg |
|
1841 | #print 'was callable?', callable(oinfo['obj']) # dbg | |
1789 | return self.handle_normal(line,continue_prompt) |
|
1842 | return self.handle_normal(line,continue_prompt) | |
1790 |
|
1843 | |||
1791 | # If we get here, we have a normal Python line. Log and return. |
|
1844 | # If we get here, we have a normal Python line. Log and return. | |
1792 | return self.handle_normal(line,continue_prompt) |
|
1845 | return self.handle_normal(line,continue_prompt) | |
1793 |
|
1846 | |||
1794 | def _prefilter_dumb(self, line, continue_prompt): |
|
1847 | def _prefilter_dumb(self, line, continue_prompt): | |
1795 | """simple prefilter function, for debugging""" |
|
1848 | """simple prefilter function, for debugging""" | |
1796 | return self.handle_normal(line,continue_prompt) |
|
1849 | return self.handle_normal(line,continue_prompt) | |
1797 |
|
1850 | |||
1798 | # Set the default prefilter() function (this can be user-overridden) |
|
1851 | # Set the default prefilter() function (this can be user-overridden) | |
1799 | prefilter = _prefilter |
|
1852 | prefilter = _prefilter | |
1800 |
|
1853 | |||
1801 | def handle_normal(self,line,continue_prompt=None, |
|
1854 | def handle_normal(self,line,continue_prompt=None, | |
1802 | pre=None,iFun=None,theRest=None): |
|
1855 | pre=None,iFun=None,theRest=None): | |
1803 | """Handle normal input lines. Use as a template for handlers.""" |
|
1856 | """Handle normal input lines. Use as a template for handlers.""" | |
1804 |
|
1857 | |||
1805 | # With autoindent on, we need some way to exit the input loop, and I |
|
1858 | # With autoindent on, we need some way to exit the input loop, and I | |
1806 | # don't want to force the user to have to backspace all the way to |
|
1859 | # don't want to force the user to have to backspace all the way to | |
1807 | # clear the line. The rule will be in this case, that either two |
|
1860 | # clear the line. The rule will be in this case, that either two | |
1808 | # lines of pure whitespace in a row, or a line of pure whitespace but |
|
1861 | # lines of pure whitespace in a row, or a line of pure whitespace but | |
1809 | # of a size different to the indent level, will exit the input loop. |
|
1862 | # of a size different to the indent level, will exit the input loop. | |
1810 |
|
1863 | |||
1811 | if (continue_prompt and self.autoindent and isspace(line) and |
|
1864 | if (continue_prompt and self.autoindent and isspace(line) and | |
1812 | (line != self.indent_current or isspace(self.buffer[-1]))): |
|
1865 | (line != self.indent_current or isspace(self.buffer[-1]))): | |
1813 | line = '' |
|
1866 | line = '' | |
1814 |
|
1867 | |||
1815 | self.log(line,continue_prompt) |
|
1868 | self.log(line,continue_prompt) | |
1816 | return line |
|
1869 | return line | |
1817 |
|
1870 | |||
1818 | def handle_alias(self,line,continue_prompt=None, |
|
1871 | def handle_alias(self,line,continue_prompt=None, | |
1819 | pre=None,iFun=None,theRest=None): |
|
1872 | pre=None,iFun=None,theRest=None): | |
1820 | """Handle alias input lines. """ |
|
1873 | """Handle alias input lines. """ | |
1821 |
|
1874 | |||
1822 | # pre is needed, because it carries the leading whitespace. Otherwise |
|
1875 | # pre is needed, because it carries the leading whitespace. Otherwise | |
1823 | # aliases won't work in indented sections. |
|
1876 | # aliases won't work in indented sections. | |
1824 | line_out = '%sipalias("%s %s")' % (pre,iFun,esc_quotes(theRest)) |
|
1877 | line_out = '%sipalias("%s %s")' % (pre,iFun,esc_quotes(theRest)) | |
1825 | self.log(line_out,continue_prompt) |
|
1878 | self.log(line_out,continue_prompt) | |
1826 | return line_out |
|
1879 | return line_out | |
1827 |
|
1880 | |||
1828 | def handle_shell_escape(self, line, continue_prompt=None, |
|
1881 | def handle_shell_escape(self, line, continue_prompt=None, | |
1829 | pre=None,iFun=None,theRest=None): |
|
1882 | pre=None,iFun=None,theRest=None): | |
1830 | """Execute the line in a shell, empty return value""" |
|
1883 | """Execute the line in a shell, empty return value""" | |
1831 |
|
1884 | |||
1832 | #print 'line in :', `line` # dbg |
|
1885 | #print 'line in :', `line` # dbg | |
1833 | # Example of a special handler. Others follow a similar pattern. |
|
1886 | # Example of a special handler. Others follow a similar pattern. | |
1834 | if continue_prompt: # multi-line statements |
|
1887 | if continue_prompt: # multi-line statements | |
1835 | if iFun.startswith('!!'): |
|
1888 | if iFun.startswith('!!'): | |
1836 | print 'SyntaxError: !! is not allowed in multiline statements' |
|
1889 | print 'SyntaxError: !! is not allowed in multiline statements' | |
1837 | return pre |
|
1890 | return pre | |
1838 | else: |
|
1891 | else: | |
1839 | cmd = ("%s %s" % (iFun[1:],theRest)) |
|
1892 | cmd = ("%s %s" % (iFun[1:],theRest)) | |
1840 | line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd + "_") |
|
1893 | line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd + "_") | |
1841 | else: # single-line input |
|
1894 | else: # single-line input | |
1842 | if line.startswith('!!'): |
|
1895 | if line.startswith('!!'): | |
1843 | # rewrite iFun/theRest to properly hold the call to %sx and |
|
1896 | # rewrite iFun/theRest to properly hold the call to %sx and | |
1844 | # the actual command to be executed, so handle_magic can work |
|
1897 | # the actual command to be executed, so handle_magic can work | |
1845 | # correctly |
|
1898 | # correctly | |
1846 | theRest = '%s %s' % (iFun[2:],theRest) |
|
1899 | theRest = '%s %s' % (iFun[2:],theRest) | |
1847 | iFun = 'sx' |
|
1900 | iFun = 'sx' | |
1848 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]), |
|
1901 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]), | |
1849 | continue_prompt,pre,iFun,theRest) |
|
1902 | continue_prompt,pre,iFun,theRest) | |
1850 | else: |
|
1903 | else: | |
1851 | cmd=line[1:] |
|
1904 | cmd=line[1:] | |
1852 | line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd +"_") |
|
1905 | line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd +"_") | |
1853 | # update cache/log and return |
|
1906 | # update cache/log and return | |
1854 | self.log(line_out,continue_prompt) |
|
1907 | self.log(line_out,continue_prompt) | |
1855 | return line_out |
|
1908 | return line_out | |
1856 |
|
1909 | |||
1857 | def handle_magic(self, line, continue_prompt=None, |
|
1910 | def handle_magic(self, line, continue_prompt=None, | |
1858 | pre=None,iFun=None,theRest=None): |
|
1911 | pre=None,iFun=None,theRest=None): | |
1859 | """Execute magic functions. |
|
1912 | """Execute magic functions. | |
1860 |
|
1913 | |||
1861 | Also log them with a prepended # so the log is clean Python.""" |
|
1914 | Also log them with a prepended # so the log is clean Python.""" | |
1862 |
|
1915 | |||
1863 | cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest))) |
|
1916 | cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest))) | |
1864 | self.log(cmd,continue_prompt) |
|
1917 | self.log(cmd,continue_prompt) | |
1865 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg |
|
1918 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg | |
1866 | return cmd |
|
1919 | return cmd | |
1867 |
|
1920 | |||
1868 | def handle_auto(self, line, continue_prompt=None, |
|
1921 | def handle_auto(self, line, continue_prompt=None, | |
1869 | pre=None,iFun=None,theRest=None): |
|
1922 | pre=None,iFun=None,theRest=None): | |
1870 | """Hande lines which can be auto-executed, quoting if requested.""" |
|
1923 | """Hande lines which can be auto-executed, quoting if requested.""" | |
1871 |
|
1924 | |||
1872 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1925 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1873 |
|
1926 | |||
1874 | # This should only be active for single-line input! |
|
1927 | # This should only be active for single-line input! | |
1875 | if continue_prompt: |
|
1928 | if continue_prompt: | |
1876 | return line |
|
1929 | return line | |
1877 |
|
1930 | |||
1878 | if pre == self.ESC_QUOTE: |
|
1931 | if pre == self.ESC_QUOTE: | |
1879 | # Auto-quote splitting on whitespace |
|
1932 | # Auto-quote splitting on whitespace | |
1880 | newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) ) |
|
1933 | newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) ) | |
1881 | elif pre == self.ESC_QUOTE2: |
|
1934 | elif pre == self.ESC_QUOTE2: | |
1882 | # Auto-quote whole string |
|
1935 | # Auto-quote whole string | |
1883 | newcmd = '%s("%s")' % (iFun,theRest) |
|
1936 | newcmd = '%s("%s")' % (iFun,theRest) | |
1884 | else: |
|
1937 | else: | |
1885 | # Auto-paren |
|
1938 | # Auto-paren | |
1886 | if theRest[0:1] in ('=','['): |
|
1939 | if theRest[0:1] in ('=','['): | |
1887 | # Don't autocall in these cases. They can be either |
|
1940 | # Don't autocall in these cases. They can be either | |
1888 | # rebindings of an existing callable's name, or item access |
|
1941 | # rebindings of an existing callable's name, or item access | |
1889 | # for an object which is BOTH callable and implements |
|
1942 | # for an object which is BOTH callable and implements | |
1890 | # __getitem__. |
|
1943 | # __getitem__. | |
1891 | return '%s %s' % (iFun,theRest) |
|
1944 | return '%s %s' % (iFun,theRest) | |
1892 | if theRest.endswith(';'): |
|
1945 | if theRest.endswith(';'): | |
1893 | newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1]) |
|
1946 | newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1]) | |
1894 | else: |
|
1947 | else: | |
1895 | newcmd = '%s(%s)' % (iFun.rstrip(),theRest) |
|
1948 | newcmd = '%s(%s)' % (iFun.rstrip(),theRest) | |
1896 |
|
1949 | |||
1897 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd |
|
1950 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd | |
1898 | # log what is now valid Python, not the actual user input (without the |
|
1951 | # log what is now valid Python, not the actual user input (without the | |
1899 | # final newline) |
|
1952 | # final newline) | |
1900 | self.log(newcmd,continue_prompt) |
|
1953 | self.log(newcmd,continue_prompt) | |
1901 | return newcmd |
|
1954 | return newcmd | |
1902 |
|
1955 | |||
1903 | def handle_help(self, line, continue_prompt=None, |
|
1956 | def handle_help(self, line, continue_prompt=None, | |
1904 | pre=None,iFun=None,theRest=None): |
|
1957 | pre=None,iFun=None,theRest=None): | |
1905 | """Try to get some help for the object. |
|
1958 | """Try to get some help for the object. | |
1906 |
|
1959 | |||
1907 | obj? or ?obj -> basic information. |
|
1960 | obj? or ?obj -> basic information. | |
1908 | obj?? or ??obj -> more details. |
|
1961 | obj?? or ??obj -> more details. | |
1909 | """ |
|
1962 | """ | |
1910 |
|
1963 | |||
1911 | # We need to make sure that we don't process lines which would be |
|
1964 | # We need to make sure that we don't process lines which would be | |
1912 | # otherwise valid python, such as "x=1 # what?" |
|
1965 | # otherwise valid python, such as "x=1 # what?" | |
1913 | try: |
|
1966 | try: | |
1914 | codeop.compile_command(line) |
|
1967 | codeop.compile_command(line) | |
1915 | except SyntaxError: |
|
1968 | except SyntaxError: | |
1916 | # We should only handle as help stuff which is NOT valid syntax |
|
1969 | # We should only handle as help stuff which is NOT valid syntax | |
1917 | if line[0]==self.ESC_HELP: |
|
1970 | if line[0]==self.ESC_HELP: | |
1918 | line = line[1:] |
|
1971 | line = line[1:] | |
1919 | elif line[-1]==self.ESC_HELP: |
|
1972 | elif line[-1]==self.ESC_HELP: | |
1920 | line = line[:-1] |
|
1973 | line = line[:-1] | |
1921 | self.log('#?'+line) |
|
1974 | self.log('#?'+line) | |
1922 | if line: |
|
1975 | if line: | |
1923 | self.magic_pinfo(line) |
|
1976 | self.magic_pinfo(line) | |
1924 | else: |
|
1977 | else: | |
1925 | page(self.usage,screen_lines=self.rc.screen_length) |
|
1978 | page(self.usage,screen_lines=self.rc.screen_length) | |
1926 | return '' # Empty string is needed here! |
|
1979 | return '' # Empty string is needed here! | |
1927 | except: |
|
1980 | except: | |
1928 | # Pass any other exceptions through to the normal handler |
|
1981 | # Pass any other exceptions through to the normal handler | |
1929 | return self.handle_normal(line,continue_prompt) |
|
1982 | return self.handle_normal(line,continue_prompt) | |
1930 | else: |
|
1983 | else: | |
1931 | # If the code compiles ok, we should handle it normally |
|
1984 | # If the code compiles ok, we should handle it normally | |
1932 | return self.handle_normal(line,continue_prompt) |
|
1985 | return self.handle_normal(line,continue_prompt) | |
1933 |
|
1986 | |||
1934 | def handle_emacs(self,line,continue_prompt=None, |
|
1987 | def handle_emacs(self,line,continue_prompt=None, | |
1935 | pre=None,iFun=None,theRest=None): |
|
1988 | pre=None,iFun=None,theRest=None): | |
1936 | """Handle input lines marked by python-mode.""" |
|
1989 | """Handle input lines marked by python-mode.""" | |
1937 |
|
1990 | |||
1938 | # Currently, nothing is done. Later more functionality can be added |
|
1991 | # Currently, nothing is done. Later more functionality can be added | |
1939 | # here if needed. |
|
1992 | # here if needed. | |
1940 |
|
1993 | |||
1941 | # The input cache shouldn't be updated |
|
1994 | # The input cache shouldn't be updated | |
1942 |
|
1995 | |||
1943 | return line |
|
1996 | return line | |
1944 |
|
1997 | |||
|
1998 | def mktempfile(self,data=None): | |||
|
1999 | """Make a new tempfile and return its filename. | |||
|
2000 | ||||
|
2001 | This makes a call to tempfile.mktemp, but it registers the created | |||
|
2002 | filename internally so ipython cleans it up at exit time. | |||
|
2003 | ||||
|
2004 | Optional inputs: | |||
|
2005 | ||||
|
2006 | - data(None): if data is given, it gets written out to the temp file | |||
|
2007 | immediately, and the file is closed again.""" | |||
|
2008 | ||||
|
2009 | filename = tempfile.mktemp('.py') | |||
|
2010 | self.tempfiles.append(filename) | |||
|
2011 | ||||
|
2012 | if data: | |||
|
2013 | tmp_file = open(filename,'w') | |||
|
2014 | tmp_file.write(data) | |||
|
2015 | tmp_file.close() | |||
|
2016 | return filename | |||
|
2017 | ||||
1945 | def write(self,data): |
|
2018 | def write(self,data): | |
1946 | """Write a string to the default output""" |
|
2019 | """Write a string to the default output""" | |
1947 | Term.cout.write(data) |
|
2020 | Term.cout.write(data) | |
1948 |
|
2021 | |||
1949 | def write_err(self,data): |
|
2022 | def write_err(self,data): | |
1950 | """Write a string to the default error output""" |
|
2023 | """Write a string to the default error output""" | |
1951 | Term.cerr.write(data) |
|
2024 | Term.cerr.write(data) | |
1952 |
|
2025 | |||
1953 | def exit(self): |
|
2026 | def exit(self): | |
1954 | """Handle interactive exit. |
|
2027 | """Handle interactive exit. | |
1955 |
|
2028 | |||
1956 | This method sets the exit_now attribute.""" |
|
2029 | This method sets the exit_now attribute.""" | |
1957 |
|
2030 | |||
1958 | if self.rc.confirm_exit: |
|
2031 | if self.rc.confirm_exit: | |
1959 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): |
|
2032 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): | |
1960 | self.exit_now = True |
|
2033 | self.exit_now = True | |
1961 | else: |
|
2034 | else: | |
1962 | self.exit_now = True |
|
2035 | self.exit_now = True | |
1963 | return self.exit_now |
|
2036 | return self.exit_now | |
1964 |
|
2037 | |||
1965 | def safe_execfile(self,fname,*where,**kw): |
|
2038 | def safe_execfile(self,fname,*where,**kw): | |
1966 | fname = os.path.expanduser(fname) |
|
2039 | fname = os.path.expanduser(fname) | |
1967 |
|
2040 | |||
1968 | # find things also in current directory |
|
2041 | # find things also in current directory | |
1969 | dname = os.path.dirname(fname) |
|
2042 | dname = os.path.dirname(fname) | |
1970 | if not sys.path.count(dname): |
|
2043 | if not sys.path.count(dname): | |
1971 | sys.path.append(dname) |
|
2044 | sys.path.append(dname) | |
1972 |
|
2045 | |||
1973 | try: |
|
2046 | try: | |
1974 | xfile = open(fname) |
|
2047 | xfile = open(fname) | |
1975 | except: |
|
2048 | except: | |
1976 | print >> Term.cerr, \ |
|
2049 | print >> Term.cerr, \ | |
1977 | 'Could not open file <%s> for safe execution.' % fname |
|
2050 | 'Could not open file <%s> for safe execution.' % fname | |
1978 | return None |
|
2051 | return None | |
1979 |
|
2052 | |||
1980 | kw.setdefault('islog',0) |
|
2053 | kw.setdefault('islog',0) | |
1981 | kw.setdefault('quiet',1) |
|
2054 | kw.setdefault('quiet',1) | |
1982 | kw.setdefault('exit_ignore',0) |
|
2055 | kw.setdefault('exit_ignore',0) | |
1983 | first = xfile.readline() |
|
2056 | first = xfile.readline() | |
1984 | loghead = str(self.loghead_tpl).split('\n',1)[0].strip() |
|
2057 | loghead = str(self.loghead_tpl).split('\n',1)[0].strip() | |
1985 | xfile.close() |
|
2058 | xfile.close() | |
1986 | # line by line execution |
|
2059 | # line by line execution | |
1987 | if first.startswith(loghead) or kw['islog']: |
|
2060 | if first.startswith(loghead) or kw['islog']: | |
1988 | print 'Loading log file <%s> one line at a time...' % fname |
|
2061 | print 'Loading log file <%s> one line at a time...' % fname | |
1989 | if kw['quiet']: |
|
2062 | if kw['quiet']: | |
1990 | stdout_save = sys.stdout |
|
2063 | stdout_save = sys.stdout | |
1991 | sys.stdout = StringIO.StringIO() |
|
2064 | sys.stdout = StringIO.StringIO() | |
1992 | try: |
|
2065 | try: | |
1993 | globs,locs = where[0:2] |
|
2066 | globs,locs = where[0:2] | |
1994 | except: |
|
2067 | except: | |
1995 | try: |
|
2068 | try: | |
1996 | globs = locs = where[0] |
|
2069 | globs = locs = where[0] | |
1997 | except: |
|
2070 | except: | |
1998 | globs = locs = globals() |
|
2071 | globs = locs = globals() | |
1999 | badblocks = [] |
|
2072 | badblocks = [] | |
2000 |
|
2073 | |||
2001 | # we also need to identify indented blocks of code when replaying |
|
2074 | # we also need to identify indented blocks of code when replaying | |
2002 | # logs and put them together before passing them to an exec |
|
2075 | # logs and put them together before passing them to an exec | |
2003 | # statement. This takes a bit of regexp and look-ahead work in the |
|
2076 | # statement. This takes a bit of regexp and look-ahead work in the | |
2004 | # file. It's easiest if we swallow the whole thing in memory |
|
2077 | # file. It's easiest if we swallow the whole thing in memory | |
2005 | # first, and manually walk through the lines list moving the |
|
2078 | # first, and manually walk through the lines list moving the | |
2006 | # counter ourselves. |
|
2079 | # counter ourselves. | |
2007 | indent_re = re.compile('\s+\S') |
|
2080 | indent_re = re.compile('\s+\S') | |
2008 | xfile = open(fname) |
|
2081 | xfile = open(fname) | |
2009 | filelines = xfile.readlines() |
|
2082 | filelines = xfile.readlines() | |
2010 | xfile.close() |
|
2083 | xfile.close() | |
2011 | nlines = len(filelines) |
|
2084 | nlines = len(filelines) | |
2012 | lnum = 0 |
|
2085 | lnum = 0 | |
2013 | while lnum < nlines: |
|
2086 | while lnum < nlines: | |
2014 | line = filelines[lnum] |
|
2087 | line = filelines[lnum] | |
2015 | lnum += 1 |
|
2088 | lnum += 1 | |
2016 | # don't re-insert logger status info into cache |
|
2089 | # don't re-insert logger status info into cache | |
2017 | if line.startswith('#log#'): |
|
2090 | if line.startswith('#log#'): | |
2018 | continue |
|
2091 | continue | |
2019 | else: |
|
2092 | else: | |
2020 | # build a block of code (maybe a single line) for execution |
|
2093 | # build a block of code (maybe a single line) for execution | |
2021 | block = line |
|
2094 | block = line | |
2022 | try: |
|
2095 | try: | |
2023 | next = filelines[lnum] # lnum has already incremented |
|
2096 | next = filelines[lnum] # lnum has already incremented | |
2024 | except: |
|
2097 | except: | |
2025 | next = None |
|
2098 | next = None | |
2026 | while next and indent_re.match(next): |
|
2099 | while next and indent_re.match(next): | |
2027 | block += next |
|
2100 | block += next | |
2028 | lnum += 1 |
|
2101 | lnum += 1 | |
2029 | try: |
|
2102 | try: | |
2030 | next = filelines[lnum] |
|
2103 | next = filelines[lnum] | |
2031 | except: |
|
2104 | except: | |
2032 | next = None |
|
2105 | next = None | |
2033 | # now execute the block of one or more lines |
|
2106 | # now execute the block of one or more lines | |
2034 | try: |
|
2107 | try: | |
2035 | exec block in globs,locs |
|
2108 | exec block in globs,locs | |
2036 | except SystemExit: |
|
2109 | except SystemExit: | |
2037 | pass |
|
2110 | pass | |
2038 | except: |
|
2111 | except: | |
2039 | badblocks.append(block.rstrip()) |
|
2112 | badblocks.append(block.rstrip()) | |
2040 | if kw['quiet']: # restore stdout |
|
2113 | if kw['quiet']: # restore stdout | |
2041 | sys.stdout.close() |
|
2114 | sys.stdout.close() | |
2042 | sys.stdout = stdout_save |
|
2115 | sys.stdout = stdout_save | |
2043 | print 'Finished replaying log file <%s>' % fname |
|
2116 | print 'Finished replaying log file <%s>' % fname | |
2044 | if badblocks: |
|
2117 | if badblocks: | |
2045 | print >> sys.stderr, ('\nThe following lines/blocks in file ' |
|
2118 | print >> sys.stderr, ('\nThe following lines/blocks in file ' | |
2046 | '<%s> reported errors:' % fname) |
|
2119 | '<%s> reported errors:' % fname) | |
2047 |
|
2120 | |||
2048 | for badline in badblocks: |
|
2121 | for badline in badblocks: | |
2049 | print >> sys.stderr, badline |
|
2122 | print >> sys.stderr, badline | |
2050 | else: # regular file execution |
|
2123 | else: # regular file execution | |
2051 | try: |
|
2124 | try: | |
2052 | execfile(fname,*where) |
|
2125 | execfile(fname,*where) | |
2053 | except SyntaxError: |
|
2126 | except SyntaxError: | |
2054 | etype,evalue = sys.exc_info()[:2] |
|
2127 | etype,evalue = sys.exc_info()[:2] | |
2055 | self.SyntaxTB(etype,evalue,[]) |
|
2128 | self.SyntaxTB(etype,evalue,[]) | |
2056 | warn('Failure executing file: <%s>' % fname) |
|
2129 | warn('Failure executing file: <%s>' % fname) | |
2057 | except SystemExit,status: |
|
2130 | except SystemExit,status: | |
2058 | if not kw['exit_ignore']: |
|
2131 | if not kw['exit_ignore']: | |
2059 | self.InteractiveTB() |
|
2132 | self.InteractiveTB() | |
2060 | warn('Failure executing file: <%s>' % fname) |
|
2133 | warn('Failure executing file: <%s>' % fname) | |
2061 | except: |
|
2134 | except: | |
2062 | self.InteractiveTB() |
|
2135 | self.InteractiveTB() | |
2063 | warn('Failure executing file: <%s>' % fname) |
|
2136 | warn('Failure executing file: <%s>' % fname) | |
2064 |
|
2137 | |||
2065 | #************************* end of file <iplib.py> ***************************** |
|
2138 | #************************* end of file <iplib.py> ***************************** |
@@ -1,796 +1,855 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 9 |
|
63 | $Id: ultraTB.py 988 2006-01-02 21:21:47Z 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 | # Globals | |||
|
99 | # amount of space to put line numbers before verbose tracebacks | |||
|
100 | INDENT_SIZE = 8 | |||
|
101 | ||||
98 | #--------------------------------------------------------------------------- |
|
102 | #--------------------------------------------------------------------------- | |
99 | # Code begins |
|
103 | # Code begins | |
100 |
|
104 | |||
|
105 | # Utility functions | |||
101 | def inspect_error(): |
|
106 | def inspect_error(): | |
102 | """Print a message about internal inspect errors. |
|
107 | """Print a message about internal inspect errors. | |
103 |
|
108 | |||
104 | These are unfortunately quite common.""" |
|
109 | These are unfortunately quite common.""" | |
105 |
|
110 | |||
106 | error('Internal Python error in the inspect module.\n' |
|
111 | error('Internal Python error in the inspect module.\n' | |
107 | 'Below is the traceback from this internal error.\n') |
|
112 | 'Below is the traceback from this internal error.\n') | |
108 |
|
113 | |||
|
114 | def _fixed_getinnerframes(etb, context=1,tb_offset=0): | |||
|
115 | import linecache | |||
|
116 | LNUM_POS, LINES_POS, INDEX_POS = 2, 4, 5 | |||
|
117 | ||||
|
118 | records = inspect.getinnerframes(etb, context) | |||
|
119 | ||||
|
120 | # If the error is at the console, don't build any context, since it would | |||
|
121 | # otherwise produce 5 blank lines printed out (there is no file at the | |||
|
122 | # console) | |||
|
123 | rec_check = records[tb_offset:] | |||
|
124 | rname = rec_check[0][1] | |||
|
125 | if rname == '<ipython console>' or rname.endswith('<string>'): | |||
|
126 | return rec_check | |||
|
127 | ||||
|
128 | aux = traceback.extract_tb(etb) | |||
|
129 | assert len(records) == len(aux) | |||
|
130 | for i, (file, lnum, _, _) in zip(range(len(records)), aux): | |||
|
131 | maybeStart = lnum-1 - context//2 | |||
|
132 | start = max(maybeStart, 0) | |||
|
133 | end = start + context | |||
|
134 | lines = linecache.getlines(file)[start:end] | |||
|
135 | # pad with empty lines if necessary | |||
|
136 | if maybeStart < 0: | |||
|
137 | lines = (['\n'] * -maybeStart) + lines | |||
|
138 | if len(lines) < context: | |||
|
139 | lines += ['\n'] * (context - len(lines)) | |||
|
140 | assert len(lines) == context | |||
|
141 | buf = list(records[i]) | |||
|
142 | buf[LNUM_POS] = lnum | |||
|
143 | buf[INDEX_POS] = lnum - 1 - start | |||
|
144 | buf[LINES_POS] = lines | |||
|
145 | records[i] = tuple(buf) | |||
|
146 | return records[tb_offset:] | |||
|
147 | ||||
|
148 | # Helper function -- largely belongs to VerboseTB, but we need the same | |||
|
149 | # functionality to produce a pseudo verbose TB for SyntaxErrors, so that they | |||
|
150 | # can be recognized properly by ipython.el's py-traceback-line-re | |||
|
151 | # (SyntaxErrors have to be treated specially because they have no traceback) | |||
|
152 | def _formatTracebackLines(lnum, index, lines, Colors, lvals=None): | |||
|
153 | numbers_width = INDENT_SIZE - 1 | |||
|
154 | res = [] | |||
|
155 | i = lnum - index | |||
|
156 | for line in lines: | |||
|
157 | if i == lnum: | |||
|
158 | # This is the line with the error | |||
|
159 | pad = numbers_width - len(str(i)) | |||
|
160 | if pad >= 3: | |||
|
161 | marker = '-'*(pad-3) + '-> ' | |||
|
162 | elif pad == 2: | |||
|
163 | marker = '> ' | |||
|
164 | elif pad == 1: | |||
|
165 | marker = '>' | |||
|
166 | else: | |||
|
167 | marker = '' | |||
|
168 | num = marker + str(i) | |||
|
169 | line = '%s%s%s %s%s' %(Colors.linenoEm, num, | |||
|
170 | Colors.line, line, Colors.Normal) | |||
|
171 | else: | |||
|
172 | num = '%*s' % (numbers_width,i) | |||
|
173 | line = '%s%s%s %s' %(Colors.lineno, num, | |||
|
174 | Colors.Normal, line) | |||
|
175 | ||||
|
176 | res.append(line) | |||
|
177 | if lvals and i == lnum: | |||
|
178 | res.append(lvals + '\n') | |||
|
179 | i = i + 1 | |||
|
180 | return res | |||
|
181 | ||||
|
182 | #--------------------------------------------------------------------------- | |||
|
183 | # Module classes | |||
109 | class TBTools: |
|
184 | class TBTools: | |
110 | """Basic tools used by all traceback printer classes.""" |
|
185 | """Basic tools used by all traceback printer classes.""" | |
111 |
|
186 | |||
112 | def __init__(self,color_scheme = 'NoColor',call_pdb=False): |
|
187 | def __init__(self,color_scheme = 'NoColor',call_pdb=False): | |
113 | # Whether to call the interactive pdb debugger after printing |
|
188 | # Whether to call the interactive pdb debugger after printing | |
114 | # tracebacks or not |
|
189 | # tracebacks or not | |
115 | self.call_pdb = call_pdb |
|
190 | self.call_pdb = call_pdb | |
116 |
|
191 | |||
117 | # Create color table |
|
192 | # Create color table | |
118 | self.color_scheme_table = ExceptionColors |
|
193 | self.color_scheme_table = ExceptionColors | |
119 |
|
194 | |||
120 | self.set_colors(color_scheme) |
|
195 | self.set_colors(color_scheme) | |
121 | self.old_scheme = color_scheme # save initial value for toggles |
|
196 | self.old_scheme = color_scheme # save initial value for toggles | |
122 |
|
197 | |||
123 | if call_pdb: |
|
198 | if call_pdb: | |
124 | self.pdb = Debugger.Pdb(self.color_scheme_table.active_scheme_name) |
|
199 | self.pdb = Debugger.Pdb(self.color_scheme_table.active_scheme_name) | |
125 | else: |
|
200 | else: | |
126 | self.pdb = None |
|
201 | self.pdb = None | |
127 |
|
202 | |||
128 | def set_colors(self,*args,**kw): |
|
203 | def set_colors(self,*args,**kw): | |
129 | """Shorthand access to the color table scheme selector method.""" |
|
204 | """Shorthand access to the color table scheme selector method.""" | |
130 |
|
205 | |||
131 | self.color_scheme_table.set_active_scheme(*args,**kw) |
|
206 | self.color_scheme_table.set_active_scheme(*args,**kw) | |
132 | # for convenience, set Colors to the active scheme |
|
207 | # for convenience, set Colors to the active scheme | |
133 | self.Colors = self.color_scheme_table.active_colors |
|
208 | self.Colors = self.color_scheme_table.active_colors | |
134 |
|
209 | |||
135 | def color_toggle(self): |
|
210 | def color_toggle(self): | |
136 | """Toggle between the currently active color scheme and NoColor.""" |
|
211 | """Toggle between the currently active color scheme and NoColor.""" | |
137 |
|
212 | |||
138 | if self.color_scheme_table.active_scheme_name == 'NoColor': |
|
213 | if self.color_scheme_table.active_scheme_name == 'NoColor': | |
139 | self.color_scheme_table.set_active_scheme(self.old_scheme) |
|
214 | self.color_scheme_table.set_active_scheme(self.old_scheme) | |
140 | self.Colors = self.color_scheme_table.active_colors |
|
215 | self.Colors = self.color_scheme_table.active_colors | |
141 | else: |
|
216 | else: | |
142 | self.old_scheme = self.color_scheme_table.active_scheme_name |
|
217 | self.old_scheme = self.color_scheme_table.active_scheme_name | |
143 | self.color_scheme_table.set_active_scheme('NoColor') |
|
218 | self.color_scheme_table.set_active_scheme('NoColor') | |
144 | self.Colors = self.color_scheme_table.active_colors |
|
219 | self.Colors = self.color_scheme_table.active_colors | |
145 |
|
220 | |||
146 | #--------------------------------------------------------------------------- |
|
221 | #--------------------------------------------------------------------------- | |
147 | class ListTB(TBTools): |
|
222 | class ListTB(TBTools): | |
148 | """Print traceback information from a traceback list, with optional color. |
|
223 | """Print traceback information from a traceback list, with optional color. | |
149 |
|
224 | |||
150 | Calling: requires 3 arguments: |
|
225 | Calling: requires 3 arguments: | |
151 | (etype, evalue, elist) |
|
226 | (etype, evalue, elist) | |
152 | as would be obtained by: |
|
227 | as would be obtained by: | |
153 | etype, evalue, tb = sys.exc_info() |
|
228 | etype, evalue, tb = sys.exc_info() | |
154 | if tb: |
|
229 | if tb: | |
155 | elist = traceback.extract_tb(tb) |
|
230 | elist = traceback.extract_tb(tb) | |
156 | else: |
|
231 | else: | |
157 | elist = None |
|
232 | elist = None | |
158 |
|
233 | |||
159 | It can thus be used by programs which need to process the traceback before |
|
234 | 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 |
|
235 | printing (such as console replacements based on the code module from the | |
161 | standard library). |
|
236 | standard library). | |
162 |
|
237 | |||
163 | Because they are meant to be called without a full traceback (only a |
|
238 | 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.""" |
|
239 | list), instances of this class can't call the interactive pdb debugger.""" | |
165 |
|
240 | |||
166 | def __init__(self,color_scheme = 'NoColor'): |
|
241 | def __init__(self,color_scheme = 'NoColor'): | |
167 | TBTools.__init__(self,color_scheme = color_scheme,call_pdb=0) |
|
242 | TBTools.__init__(self,color_scheme = color_scheme,call_pdb=0) | |
168 |
|
243 | |||
169 | def __call__(self, etype, value, elist): |
|
244 | def __call__(self, etype, value, elist): | |
170 | print >> Term.cerr, self.text(etype,value,elist) |
|
245 | print >> Term.cerr, self.text(etype,value,elist) | |
171 |
|
246 | |||
172 | def text(self,etype, value, elist,context=5): |
|
247 | def text(self,etype, value, elist,context=5): | |
173 | """Return a color formatted string with the traceback info.""" |
|
248 | """Return a color formatted string with the traceback info.""" | |
174 |
|
249 | |||
175 | Colors = self.Colors |
|
250 | Colors = self.Colors | |
176 | out_string = ['%s%s%s\n' % (Colors.topline,'-'*60,Colors.Normal)] |
|
251 | out_string = ['%s%s%s\n' % (Colors.topline,'-'*60,Colors.Normal)] | |
177 | if elist: |
|
252 | if elist: | |
178 | out_string.append('Traceback %s(most recent call last)%s:' % \ |
|
253 | out_string.append('Traceback %s(most recent call last)%s:' % \ | |
179 | (Colors.normalEm, Colors.Normal) + '\n') |
|
254 | (Colors.normalEm, Colors.Normal) + '\n') | |
180 | out_string.extend(self._format_list(elist)) |
|
255 | out_string.extend(self._format_list(elist)) | |
181 | lines = self._format_exception_only(etype, value) |
|
256 | lines = self._format_exception_only(etype, value) | |
182 | for line in lines[:-1]: |
|
257 | for line in lines[:-1]: | |
183 | out_string.append(" "+line) |
|
258 | out_string.append(" "+line) | |
184 | out_string.append(lines[-1]) |
|
259 | out_string.append(lines[-1]) | |
185 | return ''.join(out_string) |
|
260 | return ''.join(out_string) | |
186 |
|
261 | |||
187 | def _format_list(self, extracted_list): |
|
262 | def _format_list(self, extracted_list): | |
188 | """Format a list of traceback entry tuples for printing. |
|
263 | """Format a list of traceback entry tuples for printing. | |
189 |
|
264 | |||
190 | Given a list of tuples as returned by extract_tb() or |
|
265 | Given a list of tuples as returned by extract_tb() or | |
191 | extract_stack(), return a list of strings ready for printing. |
|
266 | extract_stack(), return a list of strings ready for printing. | |
192 | Each string in the resulting list corresponds to the item with the |
|
267 | 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; |
|
268 | same index in the argument list. Each string ends in a newline; | |
194 | the strings may contain internal newlines as well, for those items |
|
269 | the strings may contain internal newlines as well, for those items | |
195 | whose source text line is not None. |
|
270 | whose source text line is not None. | |
196 |
|
271 | |||
197 | Lifted almost verbatim from traceback.py |
|
272 | Lifted almost verbatim from traceback.py | |
198 | """ |
|
273 | """ | |
199 |
|
274 | |||
200 | Colors = self.Colors |
|
275 | Colors = self.Colors | |
201 | list = [] |
|
276 | list = [] | |
202 | for filename, lineno, name, line in extracted_list[:-1]: |
|
277 | for filename, lineno, name, line in extracted_list[:-1]: | |
203 | item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \ |
|
278 | item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \ | |
204 | (Colors.filename, filename, Colors.Normal, |
|
279 | (Colors.filename, filename, Colors.Normal, | |
205 | Colors.lineno, lineno, Colors.Normal, |
|
280 | Colors.lineno, lineno, Colors.Normal, | |
206 | Colors.name, name, Colors.Normal) |
|
281 | Colors.name, name, Colors.Normal) | |
207 | if line: |
|
282 | if line: | |
208 | item = item + ' %s\n' % line.strip() |
|
283 | item = item + ' %s\n' % line.strip() | |
209 | list.append(item) |
|
284 | list.append(item) | |
210 | # Emphasize the last entry |
|
285 | # Emphasize the last entry | |
211 | filename, lineno, name, line = extracted_list[-1] |
|
286 | filename, lineno, name, line = extracted_list[-1] | |
212 | item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \ |
|
287 | item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \ | |
213 | (Colors.normalEm, |
|
288 | (Colors.normalEm, | |
214 | Colors.filenameEm, filename, Colors.normalEm, |
|
289 | Colors.filenameEm, filename, Colors.normalEm, | |
215 | Colors.linenoEm, lineno, Colors.normalEm, |
|
290 | Colors.linenoEm, lineno, Colors.normalEm, | |
216 | Colors.nameEm, name, Colors.normalEm, |
|
291 | Colors.nameEm, name, Colors.normalEm, | |
217 | Colors.Normal) |
|
292 | Colors.Normal) | |
218 | if line: |
|
293 | if line: | |
219 | item = item + '%s %s%s\n' % (Colors.line, line.strip(), |
|
294 | item = item + '%s %s%s\n' % (Colors.line, line.strip(), | |
220 | Colors.Normal) |
|
295 | Colors.Normal) | |
221 | list.append(item) |
|
296 | list.append(item) | |
222 | return list |
|
297 | return list | |
223 |
|
298 | |||
224 | def _format_exception_only(self, etype, value): |
|
299 | def _format_exception_only(self, etype, value): | |
225 | """Format the exception part of a traceback. |
|
300 | """Format the exception part of a traceback. | |
226 |
|
301 | |||
227 | The arguments are the exception type and value such as given by |
|
302 | The arguments are the exception type and value such as given by | |
228 | sys.exc_info()[:2]. The return value is a list of strings, each ending |
|
303 | sys.exc_info()[:2]. The return value is a list of strings, each ending | |
229 | in a newline. Normally, the list contains a single string; however, |
|
304 | in a newline. Normally, the list contains a single string; however, | |
230 | for SyntaxError exceptions, it contains several lines that (when |
|
305 | for SyntaxError exceptions, it contains several lines that (when | |
231 | printed) display detailed information about where the syntax error |
|
306 | printed) display detailed information about where the syntax error | |
232 | occurred. The message indicating which exception occurred is the |
|
307 | occurred. The message indicating which exception occurred is the | |
233 | always last string in the list. |
|
308 | always last string in the list. | |
234 |
|
309 | |||
235 | Also lifted nearly verbatim from traceback.py |
|
310 | Also lifted nearly verbatim from traceback.py | |
236 | """ |
|
311 | """ | |
237 |
|
312 | |||
238 | Colors = self.Colors |
|
313 | Colors = self.Colors | |
239 | list = [] |
|
314 | list = [] | |
240 | if type(etype) == types.ClassType: |
|
315 | if type(etype) == types.ClassType: | |
241 | stype = Colors.excName + etype.__name__ + Colors.Normal |
|
316 | stype = Colors.excName + etype.__name__ + Colors.Normal | |
242 | else: |
|
317 | else: | |
243 | stype = etype # String exceptions don't get special coloring |
|
318 | stype = etype # String exceptions don't get special coloring | |
244 | if value is None: |
|
319 | if value is None: | |
245 | list.append( str(stype) + '\n') |
|
320 | list.append( str(stype) + '\n') | |
246 | else: |
|
321 | else: | |
247 | if etype is SyntaxError: |
|
322 | if etype is SyntaxError: | |
248 | try: |
|
323 | try: | |
249 | msg, (filename, lineno, offset, line) = value |
|
324 | msg, (filename, lineno, offset, line) = value | |
250 | except: |
|
325 | except: | |
251 | pass |
|
326 | pass | |
252 | else: |
|
327 | else: | |
253 | #print 'filename is',filename # dbg |
|
328 | #print 'filename is',filename # dbg | |
254 | if not filename: filename = "<string>" |
|
329 | if not filename: filename = "<string>" | |
255 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ |
|
330 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ | |
256 | (Colors.normalEm, |
|
331 | (Colors.normalEm, | |
257 | Colors.filenameEm, filename, Colors.normalEm, |
|
332 | Colors.filenameEm, filename, Colors.normalEm, | |
258 | Colors.linenoEm, lineno, Colors.Normal )) |
|
333 | Colors.linenoEm, lineno, Colors.Normal )) | |
259 | if line is not None: |
|
334 | if line is not None: | |
260 | i = 0 |
|
335 | i = 0 | |
261 | while i < len(line) and line[i].isspace(): |
|
336 | while i < len(line) and line[i].isspace(): | |
262 | i = i+1 |
|
337 | i = i+1 | |
263 | list.append('%s %s%s\n' % (Colors.line, |
|
338 | list.append('%s %s%s\n' % (Colors.line, | |
264 | line.strip(), |
|
339 | line.strip(), | |
265 | Colors.Normal)) |
|
340 | Colors.Normal)) | |
266 | if offset is not None: |
|
341 | if offset is not None: | |
267 | s = ' ' |
|
342 | s = ' ' | |
268 | for c in line[i:offset-1]: |
|
343 | for c in line[i:offset-1]: | |
269 | if c.isspace(): |
|
344 | if c.isspace(): | |
270 | s = s + c |
|
345 | s = s + c | |
271 | else: |
|
346 | else: | |
272 | s = s + ' ' |
|
347 | s = s + ' ' | |
273 | list.append('%s%s^%s\n' % (Colors.caret, s, |
|
348 | list.append('%s%s^%s\n' % (Colors.caret, s, | |
274 | Colors.Normal) ) |
|
349 | Colors.Normal) ) | |
275 | value = msg |
|
350 | value = msg | |
276 | s = self._some_str(value) |
|
351 | s = self._some_str(value) | |
277 | if s: |
|
352 | if s: | |
278 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, |
|
353 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, | |
279 | Colors.Normal, s)) |
|
354 | Colors.Normal, s)) | |
280 | else: |
|
355 | else: | |
281 | list.append('%s\n' % str(stype)) |
|
356 | list.append('%s\n' % str(stype)) | |
282 | return list |
|
357 | return list | |
283 |
|
358 | |||
284 | def _some_str(self, value): |
|
359 | def _some_str(self, value): | |
285 | # Lifted from traceback.py |
|
360 | # Lifted from traceback.py | |
286 | try: |
|
361 | try: | |
287 | return str(value) |
|
362 | return str(value) | |
288 | except: |
|
363 | except: | |
289 | return '<unprintable %s object>' % type(value).__name__ |
|
364 | return '<unprintable %s object>' % type(value).__name__ | |
290 |
|
365 | |||
291 | #---------------------------------------------------------------------------- |
|
366 | #---------------------------------------------------------------------------- | |
292 | class VerboseTB(TBTools): |
|
367 | class VerboseTB(TBTools): | |
293 | """A port of Ka-Ping Yee's cgitb.py module that outputs color text instead |
|
368 | """A port of Ka-Ping Yee's cgitb.py module that outputs color text instead | |
294 | of HTML. Requires inspect and pydoc. Crazy, man. |
|
369 | of HTML. Requires inspect and pydoc. Crazy, man. | |
295 |
|
370 | |||
296 | Modified version which optionally strips the topmost entries from the |
|
371 | Modified version which optionally strips the topmost entries from the | |
297 | traceback, to be used with alternate interpreters (because their own code |
|
372 | traceback, to be used with alternate interpreters (because their own code | |
298 | would appear in the traceback).""" |
|
373 | would appear in the traceback).""" | |
299 |
|
374 | |||
300 | def __init__(self,color_scheme = 'Linux',tb_offset=0,long_header=0, |
|
375 | def __init__(self,color_scheme = 'Linux',tb_offset=0,long_header=0, | |
301 | call_pdb = 0, include_vars=1): |
|
376 | call_pdb = 0, include_vars=1): | |
302 | """Specify traceback offset, headers and color scheme. |
|
377 | """Specify traceback offset, headers and color scheme. | |
303 |
|
378 | |||
304 | Define how many frames to drop from the tracebacks. Calling it with |
|
379 | 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 |
|
380 | 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 |
|
381 | their own code at the top of the traceback (VerboseTB will first | |
307 | remove that frame before printing the traceback info).""" |
|
382 | remove that frame before printing the traceback info).""" | |
308 | TBTools.__init__(self,color_scheme=color_scheme,call_pdb=call_pdb) |
|
383 | TBTools.__init__(self,color_scheme=color_scheme,call_pdb=call_pdb) | |
309 | self.tb_offset = tb_offset |
|
384 | self.tb_offset = tb_offset | |
310 | self.long_header = long_header |
|
385 | self.long_header = long_header | |
311 | self.include_vars = include_vars |
|
386 | self.include_vars = include_vars | |
312 |
|
387 | |||
313 | def text(self, etype, evalue, etb, context=5): |
|
388 | def text(self, etype, evalue, etb, context=5): | |
314 | """Return a nice text document describing the traceback.""" |
|
389 | """Return a nice text document describing the traceback.""" | |
315 |
|
390 | |||
316 | # some locals |
|
391 | # some locals | |
317 | Colors = self.Colors # just a shorthand + quicker name lookup |
|
392 | Colors = self.Colors # just a shorthand + quicker name lookup | |
318 | ColorsNormal = Colors.Normal # used a lot |
|
393 | ColorsNormal = Colors.Normal # used a lot | |
319 | indent_size = 8 # we need some space to put line numbers before |
|
394 | indent = ' '*INDENT_SIZE | |
320 | indent = ' '*indent_size |
|
|||
321 | numbers_width = indent_size - 1 # leave space between numbers & code |
|
|||
322 | text_repr = pydoc.text.repr |
|
395 | text_repr = pydoc.text.repr | |
323 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) |
|
396 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) | |
324 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) |
|
397 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) | |
325 | undefined = '%sundefined%s' % (Colors.em, ColorsNormal) |
|
398 | undefined = '%sundefined%s' % (Colors.em, ColorsNormal) | |
326 |
|
399 | |||
327 | # some internal-use functions |
|
400 | # some internal-use functions | |
328 | def eqrepr(value, repr=text_repr): return '=%s' % repr(value) |
|
401 | def eqrepr(value, repr=text_repr): return '=%s' % repr(value) | |
329 | def nullrepr(value, repr=text_repr): return '' |
|
402 | def nullrepr(value, repr=text_repr): return '' | |
330 |
|
403 | |||
331 | # meat of the code begins |
|
404 | # meat of the code begins | |
332 | if type(etype) is types.ClassType: |
|
405 | if type(etype) is types.ClassType: | |
333 | etype = etype.__name__ |
|
406 | etype = etype.__name__ | |
334 |
|
407 | |||
335 | if self.long_header: |
|
408 | if self.long_header: | |
336 | # Header with the exception type, python version, and date |
|
409 | # Header with the exception type, python version, and date | |
337 | pyver = 'Python ' + string.split(sys.version)[0] + ': ' + sys.executable |
|
410 | pyver = 'Python ' + string.split(sys.version)[0] + ': ' + sys.executable | |
338 | date = time.ctime(time.time()) |
|
411 | date = time.ctime(time.time()) | |
339 |
|
412 | |||
340 | head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal, |
|
413 | head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal, | |
341 | exc, ' '*(75-len(str(etype))-len(pyver)), |
|
414 | exc, ' '*(75-len(str(etype))-len(pyver)), | |
342 | pyver, string.rjust(date, 75) ) |
|
415 | pyver, string.rjust(date, 75) ) | |
343 | head += "\nA problem occured executing Python code. Here is the sequence of function"\ |
|
416 | 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." |
|
417 | "\ncalls leading up to the error, with the most recent (innermost) call last." | |
345 | else: |
|
418 | else: | |
346 | # Simplified header |
|
419 | # Simplified header | |
347 | head = '%s%s%s\n%s%s' % (Colors.topline, '-'*75, ColorsNormal,exc, |
|
420 | head = '%s%s%s\n%s%s' % (Colors.topline, '-'*75, ColorsNormal,exc, | |
348 | string.rjust('Traceback (most recent call last)', |
|
421 | string.rjust('Traceback (most recent call last)', | |
349 | 75 - len(str(etype)) ) ) |
|
422 | 75 - len(str(etype)) ) ) | |
350 | frames = [] |
|
423 | frames = [] | |
351 | # Flush cache before calling inspect. This helps alleviate some of the |
|
424 | # Flush cache before calling inspect. This helps alleviate some of the | |
352 | # problems with python 2.3's inspect.py. |
|
425 | # problems with python 2.3's inspect.py. | |
353 | linecache.checkcache() |
|
426 | linecache.checkcache() | |
354 | # Drop topmost frames if requested |
|
427 | # Drop topmost frames if requested | |
355 | try: |
|
428 | try: | |
356 | records = inspect.getinnerframes(etb, context)[self.tb_offset:] |
|
429 | # Try the default getinnerframes and Alex's: Alex's fixes some | |
|
430 | # problems, but it generates empty tracebacks for console errors | |||
|
431 | # (5 blanks lines) where none should be returned. | |||
|
432 | #records = inspect.getinnerframes(etb, context)[self.tb_offset:] | |||
|
433 | #print 'python records:', records # dbg | |||
|
434 | records = _fixed_getinnerframes(etb, context,self.tb_offset) | |||
|
435 | #print 'alex records:', records # dbg | |||
357 | except: |
|
436 | except: | |
358 |
|
437 | |||
359 | # FIXME: I've been getting many crash reports from python 2.3 |
|
438 | # 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 |
|
439 | # 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 |
|
440 | # to reproduce this, I should either write a better workaround or | |
362 | # file a bug report against inspect (if that's the real problem). |
|
441 | # 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 |
|
442 | # So far, I haven't been able to find an isolated example to | |
364 | # reproduce the problem. |
|
443 | # reproduce the problem. | |
365 | inspect_error() |
|
444 | inspect_error() | |
366 | traceback.print_exc(file=Term.cerr) |
|
445 | traceback.print_exc(file=Term.cerr) | |
367 | info('\nUnfortunately, your original traceback can not be constructed.\n') |
|
446 | info('\nUnfortunately, your original traceback can not be constructed.\n') | |
368 | return '' |
|
447 | return '' | |
369 |
|
448 | |||
370 | # build some color string templates outside these nested loops |
|
449 | # build some color string templates outside these nested loops | |
371 | tpl_link = '%s%%s%s' % (Colors.filenameEm,ColorsNormal) |
|
450 | tpl_link = '%s%%s%s' % (Colors.filenameEm,ColorsNormal) | |
372 | tpl_call = 'in %s%%s%s%%s%s' % (Colors.vName, Colors.valEm, |
|
451 | tpl_call = 'in %s%%s%s%%s%s' % (Colors.vName, Colors.valEm, | |
373 | ColorsNormal) |
|
452 | ColorsNormal) | |
374 | tpl_call_fail = 'in %s%%s%s(***failed resolving arguments***)%s' % \ |
|
453 | tpl_call_fail = 'in %s%%s%s(***failed resolving arguments***)%s' % \ | |
375 | (Colors.vName, Colors.valEm, ColorsNormal) |
|
454 | (Colors.vName, Colors.valEm, ColorsNormal) | |
376 | tpl_local_var = '%s%%s%s' % (Colors.vName, ColorsNormal) |
|
455 | tpl_local_var = '%s%%s%s' % (Colors.vName, ColorsNormal) | |
377 | tpl_global_var = '%sglobal%s %s%%s%s' % (Colors.em, ColorsNormal, |
|
456 | tpl_global_var = '%sglobal%s %s%%s%s' % (Colors.em, ColorsNormal, | |
378 | Colors.vName, ColorsNormal) |
|
457 | Colors.vName, ColorsNormal) | |
379 | tpl_name_val = '%%s %s= %%s%s' % (Colors.valEm, ColorsNormal) |
|
458 | tpl_name_val = '%%s %s= %%s%s' % (Colors.valEm, ColorsNormal) | |
380 | tpl_line = '%s%%s%s %%s' % (Colors.lineno, ColorsNormal) |
|
459 | tpl_line = '%s%%s%s %%s' % (Colors.lineno, ColorsNormal) | |
381 | tpl_line_em = '%s%%s%s %%s%s' % (Colors.linenoEm,Colors.line, |
|
460 | tpl_line_em = '%s%%s%s %%s%s' % (Colors.linenoEm,Colors.line, | |
382 | ColorsNormal) |
|
461 | ColorsNormal) | |
383 |
|
462 | |||
384 | # now, loop over all records printing context and info |
|
463 | # now, loop over all records printing context and info | |
385 | abspath = os.path.abspath |
|
464 | abspath = os.path.abspath | |
386 | for frame, file, lnum, func, lines, index in records: |
|
465 | for frame, file, lnum, func, lines, index in records: | |
387 | #print '*** record:',file,lnum,func,lines,index # dbg |
|
466 | #print '*** record:',file,lnum,func,lines,index # dbg | |
388 | try: |
|
467 | try: | |
389 | file = file and abspath(file) or '?' |
|
468 | file = file and abspath(file) or '?' | |
390 | except OSError: |
|
469 | except OSError: | |
391 | # if file is '<console>' or something not in the filesystem, |
|
470 | # if file is '<console>' or something not in the filesystem, | |
392 | # the abspath call will throw an OSError. Just ignore it and |
|
471 | # the abspath call will throw an OSError. Just ignore it and | |
393 | # keep the original file string. |
|
472 | # keep the original file string. | |
394 | pass |
|
473 | pass | |
395 | link = tpl_link % file |
|
474 | link = tpl_link % file | |
396 | try: |
|
475 | try: | |
397 | args, varargs, varkw, locals = inspect.getargvalues(frame) |
|
476 | args, varargs, varkw, locals = inspect.getargvalues(frame) | |
398 | except: |
|
477 | except: | |
399 | # This can happen due to a bug in python2.3. We should be |
|
478 | # 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 |
|
479 | # able to remove this try/except when 2.4 becomes a | |
401 | # requirement. Bug details at http://python.org/sf/1005466 |
|
480 | # requirement. Bug details at http://python.org/sf/1005466 | |
402 | inspect_error() |
|
481 | inspect_error() | |
403 | traceback.print_exc(file=Term.cerr) |
|
482 | traceback.print_exc(file=Term.cerr) | |
404 | info("\nIPython's exception reporting continues...\n") |
|
483 | info("\nIPython's exception reporting continues...\n") | |
405 |
|
484 | |||
406 | if func == '?': |
|
485 | if func == '?': | |
407 | call = '' |
|
486 | call = '' | |
408 | else: |
|
487 | else: | |
409 | # Decide whether to include variable details or not |
|
488 | # Decide whether to include variable details or not | |
410 | var_repr = self.include_vars and eqrepr or nullrepr |
|
489 | var_repr = self.include_vars and eqrepr or nullrepr | |
411 | try: |
|
490 | try: | |
412 | call = tpl_call % (func,inspect.formatargvalues(args, |
|
491 | call = tpl_call % (func,inspect.formatargvalues(args, | |
413 | varargs, varkw, |
|
492 | varargs, varkw, | |
414 | locals,formatvalue=var_repr)) |
|
493 | locals,formatvalue=var_repr)) | |
415 | except KeyError: |
|
494 | except KeyError: | |
416 | # Very odd crash from inspect.formatargvalues(). The |
|
495 | # Very odd crash from inspect.formatargvalues(). The | |
417 | # scenario under which it appeared was a call to |
|
496 | # scenario under which it appeared was a call to | |
418 | # view(array,scale) in NumTut.view.view(), where scale had |
|
497 | # view(array,scale) in NumTut.view.view(), where scale had | |
419 | # been defined as a scalar (it should be a tuple). Somehow |
|
498 | # been defined as a scalar (it should be a tuple). Somehow | |
420 | # inspect messes up resolving the argument list of view() |
|
499 | # inspect messes up resolving the argument list of view() | |
421 | # and barfs out. At some point I should dig into this one |
|
500 | # and barfs out. At some point I should dig into this one | |
422 | # and file a bug report about it. |
|
501 | # and file a bug report about it. | |
423 | inspect_error() |
|
502 | inspect_error() | |
424 | traceback.print_exc(file=Term.cerr) |
|
503 | traceback.print_exc(file=Term.cerr) | |
425 | info("\nIPython's exception reporting continues...\n") |
|
504 | info("\nIPython's exception reporting continues...\n") | |
426 | call = tpl_call_fail % func |
|
505 | call = tpl_call_fail % func | |
427 |
|
506 | |||
428 | # Initialize a list of names on the current line, which the |
|
507 | # Initialize a list of names on the current line, which the | |
429 | # tokenizer below will populate. |
|
508 | # tokenizer below will populate. | |
430 | names = [] |
|
509 | names = [] | |
431 |
|
510 | |||
432 | def tokeneater(token_type, token, start, end, line): |
|
511 | def tokeneater(token_type, token, start, end, line): | |
433 | """Stateful tokeneater which builds dotted names. |
|
512 | """Stateful tokeneater which builds dotted names. | |
434 |
|
513 | |||
435 | The list of names it appends to (from the enclosing scope) can |
|
514 | The list of names it appends to (from the enclosing scope) can | |
436 | contain repeated composite names. This is unavoidable, since |
|
515 | contain repeated composite names. This is unavoidable, since | |
437 | there is no way to disambguate partial dotted structures until |
|
516 | there is no way to disambguate partial dotted structures until | |
438 | the full list is known. The caller is responsible for pruning |
|
517 | the full list is known. The caller is responsible for pruning | |
439 | the final list of duplicates before using it.""" |
|
518 | the final list of duplicates before using it.""" | |
440 |
|
519 | |||
441 | # build composite names |
|
520 | # build composite names | |
442 | if token == '.': |
|
521 | if token == '.': | |
443 | try: |
|
522 | try: | |
444 | names[-1] += '.' |
|
523 | names[-1] += '.' | |
445 | # store state so the next token is added for x.y.z names |
|
524 | # store state so the next token is added for x.y.z names | |
446 | tokeneater.name_cont = True |
|
525 | tokeneater.name_cont = True | |
447 | return |
|
526 | return | |
448 | except IndexError: |
|
527 | except IndexError: | |
449 | pass |
|
528 | pass | |
450 | if token_type == tokenize.NAME and token not in keyword.kwlist: |
|
529 | if token_type == tokenize.NAME and token not in keyword.kwlist: | |
451 | if tokeneater.name_cont: |
|
530 | if tokeneater.name_cont: | |
452 | # Dotted names |
|
531 | # Dotted names | |
453 | names[-1] += token |
|
532 | names[-1] += token | |
454 | tokeneater.name_cont = False |
|
533 | tokeneater.name_cont = False | |
455 | else: |
|
534 | else: | |
456 | # Regular new names. We append everything, the caller |
|
535 | # Regular new names. We append everything, the caller | |
457 | # will be responsible for pruning the list later. It's |
|
536 | # will be responsible for pruning the list later. It's | |
458 | # very tricky to try to prune as we go, b/c composite |
|
537 | # very tricky to try to prune as we go, b/c composite | |
459 | # names can fool us. The pruning at the end is easy |
|
538 | # names can fool us. The pruning at the end is easy | |
460 | # to do (or the caller can print a list with repeated |
|
539 | # to do (or the caller can print a list with repeated | |
461 | # names if so desired. |
|
540 | # names if so desired. | |
462 | names.append(token) |
|
541 | names.append(token) | |
463 | elif token_type == tokenize.NEWLINE: |
|
542 | elif token_type == tokenize.NEWLINE: | |
464 | raise IndexError |
|
543 | raise IndexError | |
465 | # we need to store a bit of state in the tokenizer to build |
|
544 | # we need to store a bit of state in the tokenizer to build | |
466 | # dotted names |
|
545 | # dotted names | |
467 | tokeneater.name_cont = False |
|
546 | tokeneater.name_cont = False | |
468 |
|
547 | |||
469 | def linereader(file=file, lnum=[lnum], getline=linecache.getline): |
|
548 | def linereader(file=file, lnum=[lnum], getline=linecache.getline): | |
470 | line = getline(file, lnum[0]) |
|
549 | line = getline(file, lnum[0]) | |
471 | lnum[0] += 1 |
|
550 | lnum[0] += 1 | |
472 | return line |
|
551 | return line | |
473 |
|
552 | |||
474 | # Build the list of names on this line of code where the exception |
|
553 | # Build the list of names on this line of code where the exception | |
475 | # occurred. |
|
554 | # occurred. | |
476 | try: |
|
555 | try: | |
477 | # This builds the names list in-place by capturing it from the |
|
556 | # This builds the names list in-place by capturing it from the | |
478 | # enclosing scope. |
|
557 | # enclosing scope. | |
479 | tokenize.tokenize(linereader, tokeneater) |
|
558 | tokenize.tokenize(linereader, tokeneater) | |
480 | except IndexError: |
|
559 | except IndexError: | |
481 | # signals exit of tokenizer |
|
560 | # signals exit of tokenizer | |
482 | pass |
|
561 | pass | |
483 | except tokenize.TokenError,msg: |
|
562 | except tokenize.TokenError,msg: | |
484 | _m = ("An unexpected error occurred while tokenizing input\n" |
|
563 | _m = ("An unexpected error occurred while tokenizing input\n" | |
485 | "The following traceback may be corrupted or invalid\n" |
|
564 | "The following traceback may be corrupted or invalid\n" | |
486 | "The error message is: %s\n" % msg) |
|
565 | "The error message is: %s\n" % msg) | |
487 | error(_m) |
|
566 | error(_m) | |
488 |
|
567 | |||
489 | # prune names list of duplicates, but keep the right order |
|
568 | # prune names list of duplicates, but keep the right order | |
490 | unique_names = uniq_stable(names) |
|
569 | unique_names = uniq_stable(names) | |
491 |
|
570 | |||
492 | # Start loop over vars |
|
571 | # Start loop over vars | |
493 | lvals = [] |
|
572 | lvals = [] | |
494 | if self.include_vars: |
|
573 | if self.include_vars: | |
495 | for name_full in unique_names: |
|
574 | for name_full in unique_names: | |
496 | name_base = name_full.split('.',1)[0] |
|
575 | name_base = name_full.split('.',1)[0] | |
497 | if name_base in frame.f_code.co_varnames: |
|
576 | if name_base in frame.f_code.co_varnames: | |
498 | if locals.has_key(name_base): |
|
577 | if locals.has_key(name_base): | |
499 | try: |
|
578 | try: | |
500 | value = repr(eval(name_full,locals)) |
|
579 | value = repr(eval(name_full,locals)) | |
501 | except: |
|
580 | except: | |
502 | value = undefined |
|
581 | value = undefined | |
503 | else: |
|
582 | else: | |
504 | value = undefined |
|
583 | value = undefined | |
505 | name = tpl_local_var % name_full |
|
584 | name = tpl_local_var % name_full | |
506 | else: |
|
585 | else: | |
507 | if frame.f_globals.has_key(name_base): |
|
586 | if frame.f_globals.has_key(name_base): | |
508 | try: |
|
587 | try: | |
509 | value = repr(eval(name_full,frame.f_globals)) |
|
588 | value = repr(eval(name_full,frame.f_globals)) | |
510 | except: |
|
589 | except: | |
511 | value = undefined |
|
590 | value = undefined | |
512 | else: |
|
591 | else: | |
513 | value = undefined |
|
592 | value = undefined | |
514 | name = tpl_global_var % name_full |
|
593 | name = tpl_global_var % name_full | |
515 | lvals.append(tpl_name_val % (name,value)) |
|
594 | lvals.append(tpl_name_val % (name,value)) | |
516 | if lvals: |
|
595 | if lvals: | |
517 | lvals = '%s%s' % (indent,em_normal.join(lvals)) |
|
596 | lvals = '%s%s' % (indent,em_normal.join(lvals)) | |
518 | else: |
|
597 | else: | |
519 | lvals = '' |
|
598 | lvals = '' | |
520 |
|
599 | |||
521 | level = '%s %s\n' % (link,call) |
|
600 | level = '%s %s\n' % (link,call) | |
522 | excerpt = [] |
|
601 | ||
523 |
if index is |
|
602 | if index is None: | |
524 | i = lnum - index |
|
603 | frames.append(level) | |
525 | for line in lines: |
|
604 | else: | |
526 | if i == lnum: |
|
605 | frames.append('%s%s' % (level,''.join( | |
527 | # This is the line with the error |
|
606 | _formatTracebackLines(lnum,index,lines,self.Colors,lvals)))) | |
528 | pad = numbers_width - len(str(i)) |
|
|||
529 | if pad >= 3: |
|
|||
530 | marker = '-'*(pad-3) + '-> ' |
|
|||
531 | elif pad == 2: |
|
|||
532 | marker = '> ' |
|
|||
533 | elif pad == 1: |
|
|||
534 | marker = '>' |
|
|||
535 | else: |
|
|||
536 | marker = '' |
|
|||
537 | num = '%s%s' % (marker,i) |
|
|||
538 | line = tpl_line_em % (num,line) |
|
|||
539 | else: |
|
|||
540 | num = '%*s' % (numbers_width,i) |
|
|||
541 | line = tpl_line % (num,line) |
|
|||
542 |
|
||||
543 | excerpt.append(line) |
|
|||
544 | if self.include_vars and i == lnum: |
|
|||
545 | excerpt.append('%s\n' % lvals) |
|
|||
546 | i += 1 |
|
|||
547 | frames.append('%s%s' % (level,''.join(excerpt)) ) |
|
|||
548 |
|
607 | |||
549 | # Get (safely) a string form of the exception info |
|
608 | # Get (safely) a string form of the exception info | |
550 | try: |
|
609 | try: | |
551 | etype_str,evalue_str = map(str,(etype,evalue)) |
|
610 | etype_str,evalue_str = map(str,(etype,evalue)) | |
552 | except: |
|
611 | except: | |
553 | # User exception is improperly defined. |
|
612 | # User exception is improperly defined. | |
554 | etype,evalue = str,sys.exc_info()[:2] |
|
613 | etype,evalue = str,sys.exc_info()[:2] | |
555 | etype_str,evalue_str = map(str,(etype,evalue)) |
|
614 | etype_str,evalue_str = map(str,(etype,evalue)) | |
556 | # ... and format it |
|
615 | # ... and format it | |
557 | exception = ['%s%s%s: %s' % (Colors.excName, etype_str, |
|
616 | exception = ['%s%s%s: %s' % (Colors.excName, etype_str, | |
558 | ColorsNormal, evalue_str)] |
|
617 | ColorsNormal, evalue_str)] | |
559 | if type(evalue) is types.InstanceType: |
|
618 | if type(evalue) is types.InstanceType: | |
560 | try: |
|
619 | try: | |
561 | names = [w for w in dir(evalue) if isinstance(w, basestring)] |
|
620 | names = [w for w in dir(evalue) if isinstance(w, basestring)] | |
562 | except: |
|
621 | except: | |
563 | # Every now and then, an object with funny inernals blows up |
|
622 | # 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 |
|
623 | # when dir() is called on it. We do the best we can to report | |
565 | # the problem and continue |
|
624 | # the problem and continue | |
566 | _m = '%sException reporting error (object with broken dir())%s:' |
|
625 | _m = '%sException reporting error (object with broken dir())%s:' | |
567 | exception.append(_m % (Colors.excName,ColorsNormal)) |
|
626 | exception.append(_m % (Colors.excName,ColorsNormal)) | |
568 | etype_str,evalue_str = map(str,sys.exc_info()[:2]) |
|
627 | etype_str,evalue_str = map(str,sys.exc_info()[:2]) | |
569 | exception.append('%s%s%s: %s' % (Colors.excName,etype_str, |
|
628 | exception.append('%s%s%s: %s' % (Colors.excName,etype_str, | |
570 | ColorsNormal, evalue_str)) |
|
629 | ColorsNormal, evalue_str)) | |
571 | names = [] |
|
630 | names = [] | |
572 | for name in names: |
|
631 | for name in names: | |
573 | value = text_repr(getattr(evalue, name)) |
|
632 | value = text_repr(getattr(evalue, name)) | |
574 | exception.append('\n%s%s = %s' % (indent, name, value)) |
|
633 | exception.append('\n%s%s = %s' % (indent, name, value)) | |
575 | # return all our info assembled as a single string |
|
634 | # return all our info assembled as a single string | |
576 | return '%s\n\n%s\n%s' % (head,'\n'.join(frames),''.join(exception[0]) ) |
|
635 | return '%s\n\n%s\n%s' % (head,'\n'.join(frames),''.join(exception[0]) ) | |
577 |
|
636 | |||
578 | def debugger(self): |
|
637 | def debugger(self): | |
579 | """Call up the pdb debugger if desired, always clean up the tb reference. |
|
638 | """Call up the pdb debugger if desired, always clean up the tb reference. | |
580 |
|
639 | |||
581 | If the call_pdb flag is set, the pdb interactive debugger is |
|
640 | 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 |
|
641 | invoked. In all cases, the self.tb reference to the current traceback | |
583 | is deleted to prevent lingering references which hamper memory |
|
642 | is deleted to prevent lingering references which hamper memory | |
584 | management. |
|
643 | management. | |
585 |
|
644 | |||
586 | Note that each call to pdb() does an 'import readline', so if your app |
|
645 | 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 |
|
646 | requires a special setup for the readline completers, you'll have to | |
588 | fix that by hand after invoking the exception handler.""" |
|
647 | fix that by hand after invoking the exception handler.""" | |
589 |
|
648 | |||
590 | if self.call_pdb: |
|
649 | if self.call_pdb: | |
591 | if self.pdb is None: |
|
650 | if self.pdb is None: | |
592 | self.pdb = Debugger.Pdb( |
|
651 | self.pdb = Debugger.Pdb( | |
593 | self.color_scheme_table.active_scheme_name) |
|
652 | self.color_scheme_table.active_scheme_name) | |
594 | # the system displayhook may have changed, restore the original |
|
653 | # the system displayhook may have changed, restore the original | |
595 | # for pdb |
|
654 | # for pdb | |
596 | dhook = sys.displayhook |
|
655 | dhook = sys.displayhook | |
597 | sys.displayhook = sys.__displayhook__ |
|
656 | sys.displayhook = sys.__displayhook__ | |
598 | self.pdb.reset() |
|
657 | self.pdb.reset() | |
599 | # Find the right frame so we don't pop up inside ipython itself |
|
658 | # Find the right frame so we don't pop up inside ipython itself | |
600 | etb = self.tb |
|
659 | etb = self.tb | |
601 | while self.tb.tb_next is not None: |
|
660 | while self.tb.tb_next is not None: | |
602 | self.tb = self.tb.tb_next |
|
661 | self.tb = self.tb.tb_next | |
603 | try: |
|
662 | try: | |
604 | if etb and etb.tb_next: |
|
663 | if etb and etb.tb_next: | |
605 | etb = etb.tb_next |
|
664 | etb = etb.tb_next | |
606 | self.pdb.botframe = etb.tb_frame |
|
665 | self.pdb.botframe = etb.tb_frame | |
607 | self.pdb.interaction(self.tb.tb_frame, self.tb) |
|
666 | self.pdb.interaction(self.tb.tb_frame, self.tb) | |
608 | except: |
|
667 | except: | |
609 | print '*** ERROR ***' |
|
668 | print '*** ERROR ***' | |
610 | print 'This version of pdb has a bug and crashed.' |
|
669 | print 'This version of pdb has a bug and crashed.' | |
611 | print 'Returning to IPython...' |
|
670 | print 'Returning to IPython...' | |
612 | sys.displayhook = dhook |
|
671 | sys.displayhook = dhook | |
613 | del self.tb |
|
672 | del self.tb | |
614 |
|
673 | |||
615 | def handler(self, info=None): |
|
674 | def handler(self, info=None): | |
616 | (etype, evalue, etb) = info or sys.exc_info() |
|
675 | (etype, evalue, etb) = info or sys.exc_info() | |
617 | self.tb = etb |
|
676 | self.tb = etb | |
618 | print >> Term.cerr, self.text(etype, evalue, etb) |
|
677 | print >> Term.cerr, self.text(etype, evalue, etb) | |
619 |
|
678 | |||
620 | # Changed so an instance can just be called as VerboseTB_inst() and print |
|
679 | # Changed so an instance can just be called as VerboseTB_inst() and print | |
621 | # out the right info on its own. |
|
680 | # out the right info on its own. | |
622 | def __call__(self, etype=None, evalue=None, etb=None): |
|
681 | def __call__(self, etype=None, evalue=None, etb=None): | |
623 | """This hook can replace sys.excepthook (for Python 2.1 or higher).""" |
|
682 | """This hook can replace sys.excepthook (for Python 2.1 or higher).""" | |
624 | if etb is None: |
|
683 | if etb is None: | |
625 | self.handler() |
|
684 | self.handler() | |
626 | else: |
|
685 | else: | |
627 | self.handler((etype, evalue, etb)) |
|
686 | self.handler((etype, evalue, etb)) | |
628 | self.debugger() |
|
687 | self.debugger() | |
629 |
|
688 | |||
630 | #---------------------------------------------------------------------------- |
|
689 | #---------------------------------------------------------------------------- | |
631 | class FormattedTB(VerboseTB,ListTB): |
|
690 | class FormattedTB(VerboseTB,ListTB): | |
632 | """Subclass ListTB but allow calling with a traceback. |
|
691 | """Subclass ListTB but allow calling with a traceback. | |
633 |
|
692 | |||
634 | It can thus be used as a sys.excepthook for Python > 2.1. |
|
693 | It can thus be used as a sys.excepthook for Python > 2.1. | |
635 |
|
694 | |||
636 | Also adds 'Context' and 'Verbose' modes, not available in ListTB. |
|
695 | Also adds 'Context' and 'Verbose' modes, not available in ListTB. | |
637 |
|
696 | |||
638 | Allows a tb_offset to be specified. This is useful for situations where |
|
697 | 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 |
|
698 | 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, |
|
699 | occurs with python programs that themselves execute other python code, | |
641 | like Python shells). """ |
|
700 | like Python shells). """ | |
642 |
|
701 | |||
643 | def __init__(self, mode = 'Plain', color_scheme='Linux', |
|
702 | def __init__(self, mode = 'Plain', color_scheme='Linux', | |
644 | tb_offset = 0,long_header=0,call_pdb=0,include_vars=0): |
|
703 | tb_offset = 0,long_header=0,call_pdb=0,include_vars=0): | |
645 |
|
704 | |||
646 | # NEVER change the order of this list. Put new modes at the end: |
|
705 | # NEVER change the order of this list. Put new modes at the end: | |
647 | self.valid_modes = ['Plain','Context','Verbose'] |
|
706 | self.valid_modes = ['Plain','Context','Verbose'] | |
648 | self.verbose_modes = self.valid_modes[1:3] |
|
707 | self.verbose_modes = self.valid_modes[1:3] | |
649 |
|
708 | |||
650 | VerboseTB.__init__(self,color_scheme,tb_offset,long_header, |
|
709 | VerboseTB.__init__(self,color_scheme,tb_offset,long_header, | |
651 | call_pdb=call_pdb,include_vars=include_vars) |
|
710 | call_pdb=call_pdb,include_vars=include_vars) | |
652 | self.set_mode(mode) |
|
711 | self.set_mode(mode) | |
653 |
|
712 | |||
654 | def _extract_tb(self,tb): |
|
713 | def _extract_tb(self,tb): | |
655 | if tb: |
|
714 | if tb: | |
656 | return traceback.extract_tb(tb) |
|
715 | return traceback.extract_tb(tb) | |
657 | else: |
|
716 | else: | |
658 | return None |
|
717 | return None | |
659 |
|
718 | |||
660 | def text(self, etype, value, tb,context=5,mode=None): |
|
719 | def text(self, etype, value, tb,context=5,mode=None): | |
661 | """Return formatted traceback. |
|
720 | """Return formatted traceback. | |
662 |
|
721 | |||
663 | If the optional mode parameter is given, it overrides the current |
|
722 | If the optional mode parameter is given, it overrides the current | |
664 | mode.""" |
|
723 | mode.""" | |
665 |
|
724 | |||
666 | if mode is None: |
|
725 | if mode is None: | |
667 | mode = self.mode |
|
726 | mode = self.mode | |
668 | if mode in self.verbose_modes: |
|
727 | if mode in self.verbose_modes: | |
669 | # verbose modes need a full traceback |
|
728 | # verbose modes need a full traceback | |
670 | return VerboseTB.text(self,etype, value, tb,context=5) |
|
729 | return VerboseTB.text(self,etype, value, tb,context=5) | |
671 | else: |
|
730 | else: | |
672 | # We must check the source cache because otherwise we can print |
|
731 | # We must check the source cache because otherwise we can print | |
673 | # out-of-date source code. |
|
732 | # out-of-date source code. | |
674 | linecache.checkcache() |
|
733 | linecache.checkcache() | |
675 | # Now we can extract and format the exception |
|
734 | # Now we can extract and format the exception | |
676 | elist = self._extract_tb(tb) |
|
735 | elist = self._extract_tb(tb) | |
677 | if len(elist) > self.tb_offset: |
|
736 | if len(elist) > self.tb_offset: | |
678 | del elist[:self.tb_offset] |
|
737 | del elist[:self.tb_offset] | |
679 | return ListTB.text(self,etype,value,elist) |
|
738 | return ListTB.text(self,etype,value,elist) | |
680 |
|
739 | |||
681 | def set_mode(self,mode=None): |
|
740 | def set_mode(self,mode=None): | |
682 | """Switch to the desired mode. |
|
741 | """Switch to the desired mode. | |
683 |
|
742 | |||
684 | If mode is not specified, cycles through the available modes.""" |
|
743 | If mode is not specified, cycles through the available modes.""" | |
685 |
|
744 | |||
686 | if not mode: |
|
745 | if not mode: | |
687 | new_idx = ( self.valid_modes.index(self.mode) + 1 ) % \ |
|
746 | new_idx = ( self.valid_modes.index(self.mode) + 1 ) % \ | |
688 | len(self.valid_modes) |
|
747 | len(self.valid_modes) | |
689 | self.mode = self.valid_modes[new_idx] |
|
748 | self.mode = self.valid_modes[new_idx] | |
690 | elif mode not in self.valid_modes: |
|
749 | elif mode not in self.valid_modes: | |
691 | raise ValueError, 'Unrecognized mode in FormattedTB: <'+mode+'>\n'\ |
|
750 | raise ValueError, 'Unrecognized mode in FormattedTB: <'+mode+'>\n'\ | |
692 | 'Valid modes: '+str(self.valid_modes) |
|
751 | 'Valid modes: '+str(self.valid_modes) | |
693 | else: |
|
752 | else: | |
694 | self.mode = mode |
|
753 | self.mode = mode | |
695 | # include variable details only in 'Verbose' mode |
|
754 | # include variable details only in 'Verbose' mode | |
696 | self.include_vars = (self.mode == self.valid_modes[2]) |
|
755 | self.include_vars = (self.mode == self.valid_modes[2]) | |
697 |
|
756 | |||
698 | # some convenient shorcuts |
|
757 | # some convenient shorcuts | |
699 | def plain(self): |
|
758 | def plain(self): | |
700 | self.set_mode(self.valid_modes[0]) |
|
759 | self.set_mode(self.valid_modes[0]) | |
701 |
|
760 | |||
702 | def context(self): |
|
761 | def context(self): | |
703 | self.set_mode(self.valid_modes[1]) |
|
762 | self.set_mode(self.valid_modes[1]) | |
704 |
|
763 | |||
705 | def verbose(self): |
|
764 | def verbose(self): | |
706 | self.set_mode(self.valid_modes[2]) |
|
765 | self.set_mode(self.valid_modes[2]) | |
707 |
|
766 | |||
708 | #---------------------------------------------------------------------------- |
|
767 | #---------------------------------------------------------------------------- | |
709 | class AutoFormattedTB(FormattedTB): |
|
768 | class AutoFormattedTB(FormattedTB): | |
710 | """A traceback printer which can be called on the fly. |
|
769 | """A traceback printer which can be called on the fly. | |
711 |
|
770 | |||
712 | It will find out about exceptions by itself. |
|
771 | It will find out about exceptions by itself. | |
713 |
|
772 | |||
714 | A brief example: |
|
773 | A brief example: | |
715 |
|
774 | |||
716 | AutoTB = AutoFormattedTB(mode = 'Verbose',color_scheme='Linux') |
|
775 | AutoTB = AutoFormattedTB(mode = 'Verbose',color_scheme='Linux') | |
717 | try: |
|
776 | try: | |
718 | ... |
|
777 | ... | |
719 | except: |
|
778 | except: | |
720 | AutoTB() # or AutoTB(out=logfile) where logfile is an open file object |
|
779 | AutoTB() # or AutoTB(out=logfile) where logfile is an open file object | |
721 | """ |
|
780 | """ | |
722 | def __call__(self,etype=None,evalue=None,etb=None, |
|
781 | def __call__(self,etype=None,evalue=None,etb=None, | |
723 | out=None,tb_offset=None): |
|
782 | out=None,tb_offset=None): | |
724 | """Print out a formatted exception traceback. |
|
783 | """Print out a formatted exception traceback. | |
725 |
|
784 | |||
726 | Optional arguments: |
|
785 | Optional arguments: | |
727 | - out: an open file-like object to direct output to. |
|
786 | - out: an open file-like object to direct output to. | |
728 |
|
787 | |||
729 | - tb_offset: the number of frames to skip over in the stack, on a |
|
788 | - 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 |
|
789 | per-call basis (this overrides temporarily the instance's tb_offset | |
731 | given at initialization time. """ |
|
790 | given at initialization time. """ | |
732 |
|
791 | |||
733 | if out is None: |
|
792 | if out is None: | |
734 | out = Term.cerr |
|
793 | out = Term.cerr | |
735 | if tb_offset is not None: |
|
794 | if tb_offset is not None: | |
736 | tb_offset, self.tb_offset = self.tb_offset, tb_offset |
|
795 | tb_offset, self.tb_offset = self.tb_offset, tb_offset | |
737 | print >> out, self.text(etype, evalue, etb) |
|
796 | print >> out, self.text(etype, evalue, etb) | |
738 | self.tb_offset = tb_offset |
|
797 | self.tb_offset = tb_offset | |
739 | else: |
|
798 | else: | |
740 | print >> out, self.text(etype, evalue, etb) |
|
799 | print >> out, self.text(etype, evalue, etb) | |
741 | self.debugger() |
|
800 | self.debugger() | |
742 |
|
801 | |||
743 | def text(self,etype=None,value=None,tb=None,context=5,mode=None): |
|
802 | def text(self,etype=None,value=None,tb=None,context=5,mode=None): | |
744 | if etype is None: |
|
803 | if etype is None: | |
745 | etype,value,tb = sys.exc_info() |
|
804 | etype,value,tb = sys.exc_info() | |
746 | self.tb = tb |
|
805 | self.tb = tb | |
747 | return FormattedTB.text(self,etype,value,tb,context=5,mode=mode) |
|
806 | return FormattedTB.text(self,etype,value,tb,context=5,mode=mode) | |
748 |
|
807 | |||
749 | #--------------------------------------------------------------------------- |
|
808 | #--------------------------------------------------------------------------- | |
750 | # A simple class to preserve Nathan's original functionality. |
|
809 | # A simple class to preserve Nathan's original functionality. | |
751 | class ColorTB(FormattedTB): |
|
810 | class ColorTB(FormattedTB): | |
752 | """Shorthand to initialize a FormattedTB in Linux colors mode.""" |
|
811 | """Shorthand to initialize a FormattedTB in Linux colors mode.""" | |
753 | def __init__(self,color_scheme='Linux',call_pdb=0): |
|
812 | def __init__(self,color_scheme='Linux',call_pdb=0): | |
754 | FormattedTB.__init__(self,color_scheme=color_scheme, |
|
813 | FormattedTB.__init__(self,color_scheme=color_scheme, | |
755 | call_pdb=call_pdb) |
|
814 | call_pdb=call_pdb) | |
756 |
|
815 | |||
757 | #---------------------------------------------------------------------------- |
|
816 | #---------------------------------------------------------------------------- | |
758 | # module testing (minimal) |
|
817 | # module testing (minimal) | |
759 | if __name__ == "__main__": |
|
818 | if __name__ == "__main__": | |
760 | def spam(c, (d, e)): |
|
819 | def spam(c, (d, e)): | |
761 | x = c + d |
|
820 | x = c + d | |
762 | y = c * d |
|
821 | y = c * d | |
763 | foo(x, y) |
|
822 | foo(x, y) | |
764 |
|
823 | |||
765 | def foo(a, b, bar=1): |
|
824 | def foo(a, b, bar=1): | |
766 | eggs(a, b + bar) |
|
825 | eggs(a, b + bar) | |
767 |
|
826 | |||
768 | def eggs(f, g, z=globals()): |
|
827 | def eggs(f, g, z=globals()): | |
769 | h = f + g |
|
828 | h = f + g | |
770 | i = f - g |
|
829 | i = f - g | |
771 | return h / i |
|
830 | return h / i | |
772 |
|
831 | |||
773 | print '' |
|
832 | print '' | |
774 | print '*** Before ***' |
|
833 | print '*** Before ***' | |
775 | try: |
|
834 | try: | |
776 | print spam(1, (2, 3)) |
|
835 | print spam(1, (2, 3)) | |
777 | except: |
|
836 | except: | |
778 | traceback.print_exc() |
|
837 | traceback.print_exc() | |
779 | print '' |
|
838 | print '' | |
780 |
|
839 | |||
781 | handler = ColorTB() |
|
840 | handler = ColorTB() | |
782 | print '*** ColorTB ***' |
|
841 | print '*** ColorTB ***' | |
783 | try: |
|
842 | try: | |
784 | print spam(1, (2, 3)) |
|
843 | print spam(1, (2, 3)) | |
785 | except: |
|
844 | except: | |
786 | apply(handler, sys.exc_info() ) |
|
845 | apply(handler, sys.exc_info() ) | |
787 | print '' |
|
846 | print '' | |
788 |
|
847 | |||
789 | handler = VerboseTB() |
|
848 | handler = VerboseTB() | |
790 | print '*** VerboseTB ***' |
|
849 | print '*** VerboseTB ***' | |
791 | try: |
|
850 | try: | |
792 | print spam(1, (2, 3)) |
|
851 | print spam(1, (2, 3)) | |
793 | except: |
|
852 | except: | |
794 | apply(handler, sys.exc_info() ) |
|
853 | apply(handler, sys.exc_info() ) | |
795 | print '' |
|
854 | print '' | |
796 |
|
855 |
@@ -1,4726 +1,4749 b'' | |||||
|
1 | 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu> | |||
|
2 | ||||
|
3 | * IPython/ultraTB.py (_fixed_getinnerframes): added Alex | |||
|
4 | Schmolck's patch to fix inspect.getinnerframes(). | |||
|
5 | ||||
|
6 | * IPython/iplib.py (InteractiveShell.__init__): significant fixes | |||
|
7 | for embedded instances, regarding handling of namespaces and items | |||
|
8 | added to the __builtin__ one. Multiple embedded instances and | |||
|
9 | recursive embeddings should work better now (though I'm not sure | |||
|
10 | I've got all the corner cases fixed, that code is a bit of a brain | |||
|
11 | twister). | |||
|
12 | ||||
|
13 | * IPython/Magic.py (magic_edit): added support to edit in-memory | |||
|
14 | macros (automatically creates the necessary temp files). %edit | |||
|
15 | also doesn't return the file contents anymore, it's just noise. | |||
|
16 | ||||
|
17 | * IPython/completer.py (Completer.attr_matches): revert change to | |||
|
18 | complete only on attributes listed in __all__. I realized it | |||
|
19 | cripples the tab-completion system as a tool for exploring the | |||
|
20 | internals of unknown libraries (it renders any non-__all__ | |||
|
21 | attribute off-limits). I got bit by this when trying to see | |||
|
22 | something inside the dis module. | |||
|
23 | ||||
1 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
24 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
25 | |||
3 | * IPython/iplib.py (InteractiveShell.__init__): add .meta |
|
26 | * IPython/iplib.py (InteractiveShell.__init__): add .meta | |
4 | namespace for users and extension writers to hold data in. This |
|
27 | namespace for users and extension writers to hold data in. This | |
5 | follows the discussion in |
|
28 | follows the discussion in | |
6 | http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython. |
|
29 | http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython. | |
7 |
|
30 | |||
8 | * IPython/completer.py (IPCompleter.complete): small patch to help |
|
31 | * IPython/completer.py (IPCompleter.complete): small patch to help | |
9 | tab-completion under Emacs, after a suggestion by John Barnard |
|
32 | tab-completion under Emacs, after a suggestion by John Barnard | |
10 | <barnarj-AT-ccf.org>. |
|
33 | <barnarj-AT-ccf.org>. | |
11 |
|
34 | |||
12 | * IPython/Magic.py (Magic.extract_input_slices): added support for |
|
35 | * IPython/Magic.py (Magic.extract_input_slices): added support for | |
13 | the slice notation in magics to use N-M to represent numbers N...M |
|
36 | the slice notation in magics to use N-M to represent numbers N...M | |
14 | (closed endpoints). This is used by %macro and %save. |
|
37 | (closed endpoints). This is used by %macro and %save. | |
15 |
|
38 | |||
16 | * IPython/completer.py (Completer.attr_matches): for modules which |
|
39 | * IPython/completer.py (Completer.attr_matches): for modules which | |
17 | define __all__, complete only on those. After a patch by Jeffrey |
|
40 | define __all__, complete only on those. After a patch by Jeffrey | |
18 | Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and |
|
41 | Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and | |
19 | speed up this routine. |
|
42 | speed up this routine. | |
20 |
|
43 | |||
21 | * IPython/Logger.py (Logger.log): fix a history handling bug. I |
|
44 | * IPython/Logger.py (Logger.log): fix a history handling bug. I | |
22 | don't know if this is the end of it, but the behavior now is |
|
45 | don't know if this is the end of it, but the behavior now is | |
23 | certainly much more correct. Note that coupled with macros, |
|
46 | certainly much more correct. Note that coupled with macros, | |
24 | slightly surprising (at first) behavior may occur: a macro will in |
|
47 | slightly surprising (at first) behavior may occur: a macro will in | |
25 | general expand to multiple lines of input, so upon exiting, the |
|
48 | general expand to multiple lines of input, so upon exiting, the | |
26 | in/out counters will both be bumped by the corresponding amount |
|
49 | in/out counters will both be bumped by the corresponding amount | |
27 | (as if the macro's contents had been typed interactively). Typing |
|
50 | (as if the macro's contents had been typed interactively). Typing | |
28 | %hist will reveal the intermediate (silently processed) lines. |
|
51 | %hist will reveal the intermediate (silently processed) lines. | |
29 |
|
52 | |||
30 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause |
|
53 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause | |
31 | pickle to fail (%run was overwriting __main__ and not restoring |
|
54 | pickle to fail (%run was overwriting __main__ and not restoring | |
32 | it, but pickle relies on __main__ to operate). |
|
55 | it, but pickle relies on __main__ to operate). | |
33 |
|
56 | |||
34 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now |
|
57 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now | |
35 | using properties, but forgot to make the main InteractiveShell |
|
58 | using properties, but forgot to make the main InteractiveShell | |
36 | class a new-style class. Properties fail silently, and |
|
59 | class a new-style class. Properties fail silently, and | |
37 | misteriously, with old-style class (getters work, but |
|
60 | misteriously, with old-style class (getters work, but | |
38 | setters don't do anything). |
|
61 | setters don't do anything). | |
39 |
|
62 | |||
40 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> |
|
63 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> | |
41 |
|
64 | |||
42 | * IPython/Magic.py (magic_history): fix history reporting bug (I |
|
65 | * IPython/Magic.py (magic_history): fix history reporting bug (I | |
43 | know some nasties are still there, I just can't seem to find a |
|
66 | know some nasties are still there, I just can't seem to find a | |
44 | reproducible test case to track them down; the input history is |
|
67 | reproducible test case to track them down; the input history is | |
45 | falling out of sync...) |
|
68 | falling out of sync...) | |
46 |
|
69 | |||
47 | * IPython/iplib.py (handle_shell_escape): fix bug where both |
|
70 | * IPython/iplib.py (handle_shell_escape): fix bug where both | |
48 | aliases and system accesses where broken for indented code (such |
|
71 | aliases and system accesses where broken for indented code (such | |
49 | as loops). |
|
72 | as loops). | |
50 |
|
73 | |||
51 | * IPython/genutils.py (shell): fix small but critical bug for |
|
74 | * IPython/genutils.py (shell): fix small but critical bug for | |
52 | win32 system access. |
|
75 | win32 system access. | |
53 |
|
76 | |||
54 | 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
77 | 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
55 |
|
78 | |||
56 | * IPython/iplib.py (showtraceback): remove use of the |
|
79 | * IPython/iplib.py (showtraceback): remove use of the | |
57 | sys.last_{type/value/traceback} structures, which are non |
|
80 | sys.last_{type/value/traceback} structures, which are non | |
58 | thread-safe. |
|
81 | thread-safe. | |
59 | (_prefilter): change control flow to ensure that we NEVER |
|
82 | (_prefilter): change control flow to ensure that we NEVER | |
60 | introspect objects when autocall is off. This will guarantee that |
|
83 | introspect objects when autocall is off. This will guarantee that | |
61 | having an input line of the form 'x.y', where access to attribute |
|
84 | having an input line of the form 'x.y', where access to attribute | |
62 | 'y' has side effects, doesn't trigger the side effect TWICE. It |
|
85 | 'y' has side effects, doesn't trigger the side effect TWICE. It | |
63 | is important to note that, with autocall on, these side effects |
|
86 | is important to note that, with autocall on, these side effects | |
64 | can still happen. |
|
87 | can still happen. | |
65 | (ipsystem): new builtin, to complete the ip{magic/alias/system} |
|
88 | (ipsystem): new builtin, to complete the ip{magic/alias/system} | |
66 | trio. IPython offers these three kinds of special calls which are |
|
89 | trio. IPython offers these three kinds of special calls which are | |
67 | not python code, and it's a good thing to have their call method |
|
90 | not python code, and it's a good thing to have their call method | |
68 | be accessible as pure python functions (not just special syntax at |
|
91 | be accessible as pure python functions (not just special syntax at | |
69 | the command line). It gives us a better internal implementation |
|
92 | the command line). It gives us a better internal implementation | |
70 | structure, as well as exposing these for user scripting more |
|
93 | structure, as well as exposing these for user scripting more | |
71 | cleanly. |
|
94 | cleanly. | |
72 |
|
95 | |||
73 | * IPython/macro.py (Macro.__init__): moved macros to a standalone |
|
96 | * IPython/macro.py (Macro.__init__): moved macros to a standalone | |
74 | file. Now that they'll be more likely to be used with the |
|
97 | file. Now that they'll be more likely to be used with the | |
75 | persistance system (%store), I want to make sure their module path |
|
98 | persistance system (%store), I want to make sure their module path | |
76 | doesn't change in the future, so that we don't break things for |
|
99 | doesn't change in the future, so that we don't break things for | |
77 | users' persisted data. |
|
100 | users' persisted data. | |
78 |
|
101 | |||
79 | * IPython/iplib.py (autoindent_update): move indentation |
|
102 | * IPython/iplib.py (autoindent_update): move indentation | |
80 | management into the _text_ processing loop, not the keyboard |
|
103 | management into the _text_ processing loop, not the keyboard | |
81 | interactive one. This is necessary to correctly process non-typed |
|
104 | interactive one. This is necessary to correctly process non-typed | |
82 | multiline input (such as macros). |
|
105 | multiline input (such as macros). | |
83 |
|
106 | |||
84 | * IPython/Magic.py (Magic.format_latex): patch by Stefan van der |
|
107 | * IPython/Magic.py (Magic.format_latex): patch by Stefan van der | |
85 | Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings, |
|
108 | Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings, | |
86 | which was producing problems in the resulting manual. |
|
109 | which was producing problems in the resulting manual. | |
87 | (magic_whos): improve reporting of instances (show their class, |
|
110 | (magic_whos): improve reporting of instances (show their class, | |
88 | instead of simply printing 'instance' which isn't terribly |
|
111 | instead of simply printing 'instance' which isn't terribly | |
89 | informative). |
|
112 | informative). | |
90 |
|
113 | |||
91 | * IPython/genutils.py (shell): commit Jorgen Stenarson's patch |
|
114 | * IPython/genutils.py (shell): commit Jorgen Stenarson's patch | |
92 | (minor mods) to support network shares under win32. |
|
115 | (minor mods) to support network shares under win32. | |
93 |
|
116 | |||
94 | * IPython/winconsole.py (get_console_size): add new winconsole |
|
117 | * IPython/winconsole.py (get_console_size): add new winconsole | |
95 | module and fixes to page_dumb() to improve its behavior under |
|
118 | module and fixes to page_dumb() to improve its behavior under | |
96 | win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>. |
|
119 | win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>. | |
97 |
|
120 | |||
98 | * IPython/Magic.py (Macro): simplified Macro class to just |
|
121 | * IPython/Magic.py (Macro): simplified Macro class to just | |
99 | subclass list. We've had only 2.2 compatibility for a very long |
|
122 | subclass list. We've had only 2.2 compatibility for a very long | |
100 | time, yet I was still avoiding subclassing the builtin types. No |
|
123 | time, yet I was still avoiding subclassing the builtin types. No | |
101 | more (I'm also starting to use properties, though I won't shift to |
|
124 | more (I'm also starting to use properties, though I won't shift to | |
102 | 2.3-specific features quite yet). |
|
125 | 2.3-specific features quite yet). | |
103 | (magic_store): added Ville's patch for lightweight variable |
|
126 | (magic_store): added Ville's patch for lightweight variable | |
104 | persistence, after a request on the user list by Matt Wilkie |
|
127 | persistence, after a request on the user list by Matt Wilkie | |
105 | <maphew-AT-gmail.com>. The new %store magic's docstring has full |
|
128 | <maphew-AT-gmail.com>. The new %store magic's docstring has full | |
106 | details. |
|
129 | details. | |
107 |
|
130 | |||
108 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
131 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
109 | changed the default logfile name from 'ipython.log' to |
|
132 | changed the default logfile name from 'ipython.log' to | |
110 | 'ipython_log.py'. These logs are real python files, and now that |
|
133 | 'ipython_log.py'. These logs are real python files, and now that | |
111 | we have much better multiline support, people are more likely to |
|
134 | we have much better multiline support, people are more likely to | |
112 | want to use them as such. Might as well name them correctly. |
|
135 | want to use them as such. Might as well name them correctly. | |
113 |
|
136 | |||
114 | * IPython/Magic.py: substantial cleanup. While we can't stop |
|
137 | * IPython/Magic.py: substantial cleanup. While we can't stop | |
115 | using magics as mixins, due to the existing customizations 'out |
|
138 | using magics as mixins, due to the existing customizations 'out | |
116 | there' which rely on the mixin naming conventions, at least I |
|
139 | there' which rely on the mixin naming conventions, at least I | |
117 | cleaned out all cross-class name usage. So once we are OK with |
|
140 | cleaned out all cross-class name usage. So once we are OK with | |
118 | breaking compatibility, the two systems can be separated. |
|
141 | breaking compatibility, the two systems can be separated. | |
119 |
|
142 | |||
120 | * IPython/Logger.py: major cleanup. This one is NOT a mixin |
|
143 | * IPython/Logger.py: major cleanup. This one is NOT a mixin | |
121 | anymore, and the class is a fair bit less hideous as well. New |
|
144 | anymore, and the class is a fair bit less hideous as well. New | |
122 | features were also introduced: timestamping of input, and logging |
|
145 | features were also introduced: timestamping of input, and logging | |
123 | of output results. These are user-visible with the -t and -o |
|
146 | of output results. These are user-visible with the -t and -o | |
124 | options to %logstart. Closes |
|
147 | options to %logstart. Closes | |
125 | http://www.scipy.net/roundup/ipython/issue11 and a request by |
|
148 | http://www.scipy.net/roundup/ipython/issue11 and a request by | |
126 | William Stein (SAGE developer - http://modular.ucsd.edu/sage). |
|
149 | William Stein (SAGE developer - http://modular.ucsd.edu/sage). | |
127 |
|
150 | |||
128 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> |
|
151 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> | |
129 |
|
152 | |||
130 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to |
|
153 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to | |
131 | better hadnle backslashes in paths. See the thread 'More Windows |
|
154 | better hadnle backslashes in paths. See the thread 'More Windows | |
132 | questions part 2 - \/ characters revisited' on the iypthon user |
|
155 | questions part 2 - \/ characters revisited' on the iypthon user | |
133 | list: |
|
156 | list: | |
134 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html |
|
157 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html | |
135 |
|
158 | |||
136 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. |
|
159 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. | |
137 |
|
160 | |||
138 | (InteractiveShell.__init__): change threaded shells to not use the |
|
161 | (InteractiveShell.__init__): change threaded shells to not use the | |
139 | ipython crash handler. This was causing more problems than not, |
|
162 | ipython crash handler. This was causing more problems than not, | |
140 | as exceptions in the main thread (GUI code, typically) would |
|
163 | as exceptions in the main thread (GUI code, typically) would | |
141 | always show up as a 'crash', when they really weren't. |
|
164 | always show up as a 'crash', when they really weren't. | |
142 |
|
165 | |||
143 | The colors and exception mode commands (%colors/%xmode) have been |
|
166 | The colors and exception mode commands (%colors/%xmode) have been | |
144 | synchronized to also take this into account, so users can get |
|
167 | synchronized to also take this into account, so users can get | |
145 | verbose exceptions for their threaded code as well. I also added |
|
168 | verbose exceptions for their threaded code as well. I also added | |
146 | support for activating pdb inside this exception handler as well, |
|
169 | support for activating pdb inside this exception handler as well, | |
147 | so now GUI authors can use IPython's enhanced pdb at runtime. |
|
170 | so now GUI authors can use IPython's enhanced pdb at runtime. | |
148 |
|
171 | |||
149 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag |
|
172 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag | |
150 | true by default, and add it to the shipped ipythonrc file. Since |
|
173 | true by default, and add it to the shipped ipythonrc file. Since | |
151 | this asks the user before proceeding, I think it's OK to make it |
|
174 | this asks the user before proceeding, I think it's OK to make it | |
152 | true by default. |
|
175 | true by default. | |
153 |
|
176 | |||
154 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead |
|
177 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead | |
155 | of the previous special-casing of input in the eval loop. I think |
|
178 | of the previous special-casing of input in the eval loop. I think | |
156 | this is cleaner, as they really are commands and shouldn't have |
|
179 | this is cleaner, as they really are commands and shouldn't have | |
157 | a special role in the middle of the core code. |
|
180 | a special role in the middle of the core code. | |
158 |
|
181 | |||
159 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
182 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
160 |
|
183 | |||
161 | * IPython/iplib.py (edit_syntax_error): added support for |
|
184 | * IPython/iplib.py (edit_syntax_error): added support for | |
162 | automatically reopening the editor if the file had a syntax error |
|
185 | automatically reopening the editor if the file had a syntax error | |
163 | in it. Thanks to scottt who provided the patch at: |
|
186 | in it. Thanks to scottt who provided the patch at: | |
164 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified |
|
187 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified | |
165 | version committed). |
|
188 | version committed). | |
166 |
|
189 | |||
167 | * IPython/iplib.py (handle_normal): add suport for multi-line |
|
190 | * IPython/iplib.py (handle_normal): add suport for multi-line | |
168 | input with emtpy lines. This fixes |
|
191 | input with emtpy lines. This fixes | |
169 | http://www.scipy.net/roundup/ipython/issue43 and a similar |
|
192 | http://www.scipy.net/roundup/ipython/issue43 and a similar | |
170 | discussion on the user list. |
|
193 | discussion on the user list. | |
171 |
|
194 | |||
172 | WARNING: a behavior change is necessarily introduced to support |
|
195 | WARNING: a behavior change is necessarily introduced to support | |
173 | blank lines: now a single blank line with whitespace does NOT |
|
196 | blank lines: now a single blank line with whitespace does NOT | |
174 | break the input loop, which means that when autoindent is on, by |
|
197 | break the input loop, which means that when autoindent is on, by | |
175 | default hitting return on the next (indented) line does NOT exit. |
|
198 | default hitting return on the next (indented) line does NOT exit. | |
176 |
|
199 | |||
177 | Instead, to exit a multiline input you can either have: |
|
200 | Instead, to exit a multiline input you can either have: | |
178 |
|
201 | |||
179 | - TWO whitespace lines (just hit return again), or |
|
202 | - TWO whitespace lines (just hit return again), or | |
180 | - a single whitespace line of a different length than provided |
|
203 | - a single whitespace line of a different length than provided | |
181 | by the autoindent (add or remove a space). |
|
204 | by the autoindent (add or remove a space). | |
182 |
|
205 | |||
183 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' |
|
206 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' | |
184 | module to better organize all readline-related functionality. |
|
207 | module to better organize all readline-related functionality. | |
185 | I've deleted FlexCompleter and put all completion clases here. |
|
208 | I've deleted FlexCompleter and put all completion clases here. | |
186 |
|
209 | |||
187 | * IPython/iplib.py (raw_input): improve indentation management. |
|
210 | * IPython/iplib.py (raw_input): improve indentation management. | |
188 | It is now possible to paste indented code with autoindent on, and |
|
211 | It is now possible to paste indented code with autoindent on, and | |
189 | the code is interpreted correctly (though it still looks bad on |
|
212 | the code is interpreted correctly (though it still looks bad on | |
190 | screen, due to the line-oriented nature of ipython). |
|
213 | screen, due to the line-oriented nature of ipython). | |
191 | (MagicCompleter.complete): change behavior so that a TAB key on an |
|
214 | (MagicCompleter.complete): change behavior so that a TAB key on an | |
192 | otherwise empty line actually inserts a tab, instead of completing |
|
215 | otherwise empty line actually inserts a tab, instead of completing | |
193 | on the entire global namespace. This makes it easier to use the |
|
216 | on the entire global namespace. This makes it easier to use the | |
194 | TAB key for indentation. After a request by Hans Meine |
|
217 | TAB key for indentation. After a request by Hans Meine | |
195 | <hans_meine-AT-gmx.net> |
|
218 | <hans_meine-AT-gmx.net> | |
196 | (_prefilter): add support so that typing plain 'exit' or 'quit' |
|
219 | (_prefilter): add support so that typing plain 'exit' or 'quit' | |
197 | does a sensible thing. Originally I tried to deviate as little as |
|
220 | does a sensible thing. Originally I tried to deviate as little as | |
198 | possible from the default python behavior, but even that one may |
|
221 | possible from the default python behavior, but even that one may | |
199 | change in this direction (thread on python-dev to that effect). |
|
222 | change in this direction (thread on python-dev to that effect). | |
200 | Regardless, ipython should do the right thing even if CPython's |
|
223 | Regardless, ipython should do the right thing even if CPython's | |
201 | '>>>' prompt doesn't. |
|
224 | '>>>' prompt doesn't. | |
202 | (InteractiveShell): removed subclassing code.InteractiveConsole |
|
225 | (InteractiveShell): removed subclassing code.InteractiveConsole | |
203 | class. By now we'd overridden just about all of its methods: I've |
|
226 | class. By now we'd overridden just about all of its methods: I've | |
204 | copied the remaining two over, and now ipython is a standalone |
|
227 | copied the remaining two over, and now ipython is a standalone | |
205 | class. This will provide a clearer picture for the chainsaw |
|
228 | class. This will provide a clearer picture for the chainsaw | |
206 | branch refactoring. |
|
229 | branch refactoring. | |
207 |
|
230 | |||
208 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> |
|
231 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> | |
209 |
|
232 | |||
210 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against |
|
233 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against | |
211 | failures for objects which break when dir() is called on them. |
|
234 | failures for objects which break when dir() is called on them. | |
212 |
|
235 | |||
213 | * IPython/FlexCompleter.py (Completer.__init__): Added support for |
|
236 | * IPython/FlexCompleter.py (Completer.__init__): Added support for | |
214 | distinct local and global namespaces in the completer API. This |
|
237 | distinct local and global namespaces in the completer API. This | |
215 | change allows us top properly handle completion with distinct |
|
238 | change allows us top properly handle completion with distinct | |
216 | scopes, including in embedded instances (this had never really |
|
239 | scopes, including in embedded instances (this had never really | |
217 | worked correctly). |
|
240 | worked correctly). | |
218 |
|
241 | |||
219 | Note: this introduces a change in the constructor for |
|
242 | Note: this introduces a change in the constructor for | |
220 | MagicCompleter, as a new global_namespace parameter is now the |
|
243 | MagicCompleter, as a new global_namespace parameter is now the | |
221 | second argument (the others were bumped one position). |
|
244 | second argument (the others were bumped one position). | |
222 |
|
245 | |||
223 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
246 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> | |
224 |
|
247 | |||
225 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
248 | * IPython/iplib.py (embed_mainloop): fix tab-completion in | |
226 | embedded instances (which can be done now thanks to Vivian's |
|
249 | embedded instances (which can be done now thanks to Vivian's | |
227 | frame-handling fixes for pdb). |
|
250 | frame-handling fixes for pdb). | |
228 | (InteractiveShell.__init__): Fix namespace handling problem in |
|
251 | (InteractiveShell.__init__): Fix namespace handling problem in | |
229 | embedded instances. We were overwriting __main__ unconditionally, |
|
252 | embedded instances. We were overwriting __main__ unconditionally, | |
230 | and this should only be done for 'full' (non-embedded) IPython; |
|
253 | and this should only be done for 'full' (non-embedded) IPython; | |
231 | embedded instances must respect the caller's __main__. Thanks to |
|
254 | embedded instances must respect the caller's __main__. Thanks to | |
232 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> |
|
255 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> | |
233 |
|
256 | |||
234 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
257 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
235 |
|
258 | |||
236 | * setup.py: added download_url to setup(). This registers the |
|
259 | * setup.py: added download_url to setup(). This registers the | |
237 | download address at PyPI, which is not only useful to humans |
|
260 | download address at PyPI, which is not only useful to humans | |
238 | browsing the site, but is also picked up by setuptools (the Eggs |
|
261 | browsing the site, but is also picked up by setuptools (the Eggs | |
239 | machinery). Thanks to Ville and R. Kern for the info/discussion |
|
262 | machinery). Thanks to Ville and R. Kern for the info/discussion | |
240 | on this. |
|
263 | on this. | |
241 |
|
264 | |||
242 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
265 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
243 |
|
266 | |||
244 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. |
|
267 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. | |
245 | This brings a lot of nice functionality to the pdb mode, which now |
|
268 | This brings a lot of nice functionality to the pdb mode, which now | |
246 | has tab-completion, syntax highlighting, and better stack handling |
|
269 | has tab-completion, syntax highlighting, and better stack handling | |
247 | than before. Many thanks to Vivian De Smedt |
|
270 | than before. Many thanks to Vivian De Smedt | |
248 | <vivian-AT-vdesmedt.com> for the original patches. |
|
271 | <vivian-AT-vdesmedt.com> for the original patches. | |
249 |
|
272 | |||
250 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
273 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> | |
251 |
|
274 | |||
252 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling |
|
275 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling | |
253 | sequence to consistently accept the banner argument. The |
|
276 | sequence to consistently accept the banner argument. The | |
254 | inconsistency was tripping SAGE, thanks to Gary Zablackis |
|
277 | inconsistency was tripping SAGE, thanks to Gary Zablackis | |
255 | <gzabl-AT-yahoo.com> for the report. |
|
278 | <gzabl-AT-yahoo.com> for the report. | |
256 |
|
279 | |||
257 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
280 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
258 |
|
281 | |||
259 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
282 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
260 | Fix bug where a naked 'alias' call in the ipythonrc file would |
|
283 | Fix bug where a naked 'alias' call in the ipythonrc file would | |
261 | cause a crash. Bug reported by Jorgen Stenarson. |
|
284 | cause a crash. Bug reported by Jorgen Stenarson. | |
262 |
|
285 | |||
263 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
286 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
264 |
|
287 | |||
265 | * IPython/ipmaker.py (make_IPython): cleanups which should improve |
|
288 | * IPython/ipmaker.py (make_IPython): cleanups which should improve | |
266 | startup time. |
|
289 | startup time. | |
267 |
|
290 | |||
268 | * IPython/iplib.py (runcode): my globals 'fix' for embedded |
|
291 | * IPython/iplib.py (runcode): my globals 'fix' for embedded | |
269 | instances had introduced a bug with globals in normal code. Now |
|
292 | instances had introduced a bug with globals in normal code. Now | |
270 | it's working in all cases. |
|
293 | it's working in all cases. | |
271 |
|
294 | |||
272 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and |
|
295 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and | |
273 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' |
|
296 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' | |
274 | has been introduced to set the default case sensitivity of the |
|
297 | has been introduced to set the default case sensitivity of the | |
275 | searches. Users can still select either mode at runtime on a |
|
298 | searches. Users can still select either mode at runtime on a | |
276 | per-search basis. |
|
299 | per-search basis. | |
277 |
|
300 | |||
278 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
301 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> | |
279 |
|
302 | |||
280 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of |
|
303 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of | |
281 | attributes in wildcard searches for subclasses. Modified version |
|
304 | attributes in wildcard searches for subclasses. Modified version | |
282 | of a patch by Jorgen. |
|
305 | of a patch by Jorgen. | |
283 |
|
306 | |||
284 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
307 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
285 |
|
308 | |||
286 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for |
|
309 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for | |
287 | embedded instances. I added a user_global_ns attribute to the |
|
310 | embedded instances. I added a user_global_ns attribute to the | |
288 | InteractiveShell class to handle this. |
|
311 | InteractiveShell class to handle this. | |
289 |
|
312 | |||
290 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
313 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
291 |
|
314 | |||
292 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to |
|
315 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to | |
293 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 |
|
316 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 | |
294 | (reported under win32, but may happen also in other platforms). |
|
317 | (reported under win32, but may happen also in other platforms). | |
295 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> |
|
318 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> | |
296 |
|
319 | |||
297 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
320 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
298 |
|
321 | |||
299 | * IPython/Magic.py (magic_psearch): new support for wildcard |
|
322 | * IPython/Magic.py (magic_psearch): new support for wildcard | |
300 | patterns. Now, typing ?a*b will list all names which begin with a |
|
323 | patterns. Now, typing ?a*b will list all names which begin with a | |
301 | and end in b, for example. The %psearch magic has full |
|
324 | and end in b, for example. The %psearch magic has full | |
302 | docstrings. Many thanks to JΓΆrgen Stenarson |
|
325 | docstrings. Many thanks to JΓΆrgen Stenarson | |
303 | <jorgen.stenarson-AT-bostream.nu>, author of the patches |
|
326 | <jorgen.stenarson-AT-bostream.nu>, author of the patches | |
304 | implementing this functionality. |
|
327 | implementing this functionality. | |
305 |
|
328 | |||
306 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
329 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
307 |
|
330 | |||
308 | * Manual: fixed long-standing annoyance of double-dashes (as in |
|
331 | * Manual: fixed long-standing annoyance of double-dashes (as in | |
309 | --prefix=~, for example) being stripped in the HTML version. This |
|
332 | --prefix=~, for example) being stripped in the HTML version. This | |
310 | is a latex2html bug, but a workaround was provided. Many thanks |
|
333 | is a latex2html bug, but a workaround was provided. Many thanks | |
311 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed |
|
334 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed | |
312 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball |
|
335 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball | |
313 | rolling. This seemingly small issue had tripped a number of users |
|
336 | rolling. This seemingly small issue had tripped a number of users | |
314 | when first installing, so I'm glad to see it gone. |
|
337 | when first installing, so I'm glad to see it gone. | |
315 |
|
338 | |||
316 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
339 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
317 |
|
340 | |||
318 | * IPython/Extensions/numeric_formats.py: fix missing import, |
|
341 | * IPython/Extensions/numeric_formats.py: fix missing import, | |
319 | reported by Stephen Walton. |
|
342 | reported by Stephen Walton. | |
320 |
|
343 | |||
321 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
344 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
322 |
|
345 | |||
323 | * IPython/demo.py: finish demo module, fully documented now. |
|
346 | * IPython/demo.py: finish demo module, fully documented now. | |
324 |
|
347 | |||
325 | * IPython/genutils.py (file_read): simple little utility to read a |
|
348 | * IPython/genutils.py (file_read): simple little utility to read a | |
326 | file and ensure it's closed afterwards. |
|
349 | file and ensure it's closed afterwards. | |
327 |
|
350 | |||
328 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
351 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
329 |
|
352 | |||
330 | * IPython/demo.py (Demo.__init__): added support for individually |
|
353 | * IPython/demo.py (Demo.__init__): added support for individually | |
331 | tagging blocks for automatic execution. |
|
354 | tagging blocks for automatic execution. | |
332 |
|
355 | |||
333 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing |
|
356 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing | |
334 | syntax-highlighted python sources, requested by John. |
|
357 | syntax-highlighted python sources, requested by John. | |
335 |
|
358 | |||
336 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
359 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> | |
337 |
|
360 | |||
338 | * IPython/demo.py (Demo.again): fix bug where again() blocks after |
|
361 | * IPython/demo.py (Demo.again): fix bug where again() blocks after | |
339 | finishing. |
|
362 | finishing. | |
340 |
|
363 | |||
341 | * IPython/genutils.py (shlex_split): moved from Magic to here, |
|
364 | * IPython/genutils.py (shlex_split): moved from Magic to here, | |
342 | where all 2.2 compatibility stuff lives. I needed it for demo.py. |
|
365 | where all 2.2 compatibility stuff lives. I needed it for demo.py. | |
343 |
|
366 | |||
344 | * IPython/demo.py (Demo.__init__): added support for silent |
|
367 | * IPython/demo.py (Demo.__init__): added support for silent | |
345 | blocks, improved marks as regexps, docstrings written. |
|
368 | blocks, improved marks as regexps, docstrings written. | |
346 | (Demo.__init__): better docstring, added support for sys.argv. |
|
369 | (Demo.__init__): better docstring, added support for sys.argv. | |
347 |
|
370 | |||
348 | * IPython/genutils.py (marquee): little utility used by the demo |
|
371 | * IPython/genutils.py (marquee): little utility used by the demo | |
349 | code, handy in general. |
|
372 | code, handy in general. | |
350 |
|
373 | |||
351 | * IPython/demo.py (Demo.__init__): new class for interactive |
|
374 | * IPython/demo.py (Demo.__init__): new class for interactive | |
352 | demos. Not documented yet, I just wrote it in a hurry for |
|
375 | demos. Not documented yet, I just wrote it in a hurry for | |
353 | scipy'05. Will docstring later. |
|
376 | scipy'05. Will docstring later. | |
354 |
|
377 | |||
355 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
378 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> | |
356 |
|
379 | |||
357 | * IPython/Shell.py (sigint_handler): Drastic simplification which |
|
380 | * IPython/Shell.py (sigint_handler): Drastic simplification which | |
358 | also seems to make Ctrl-C work correctly across threads! This is |
|
381 | also seems to make Ctrl-C work correctly across threads! This is | |
359 | so simple, that I can't beleive I'd missed it before. Needs more |
|
382 | so simple, that I can't beleive I'd missed it before. Needs more | |
360 | testing, though. |
|
383 | testing, though. | |
361 | (KBINT): Never mind, revert changes. I'm sure I'd tried something |
|
384 | (KBINT): Never mind, revert changes. I'm sure I'd tried something | |
362 | like this before... |
|
385 | like this before... | |
363 |
|
386 | |||
364 | * IPython/genutils.py (get_home_dir): add protection against |
|
387 | * IPython/genutils.py (get_home_dir): add protection against | |
365 | non-dirs in win32 registry. |
|
388 | non-dirs in win32 registry. | |
366 |
|
389 | |||
367 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix |
|
390 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix | |
368 | bug where dict was mutated while iterating (pysh crash). |
|
391 | bug where dict was mutated while iterating (pysh crash). | |
369 |
|
392 | |||
370 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> |
|
393 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> | |
371 |
|
394 | |||
372 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from |
|
395 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from | |
373 | spurious newlines added by this routine. After a report by |
|
396 | spurious newlines added by this routine. After a report by | |
374 | F. Mantegazza. |
|
397 | F. Mantegazza. | |
375 |
|
398 | |||
376 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
399 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> | |
377 |
|
400 | |||
378 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") |
|
401 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") | |
379 | calls. These were a leftover from the GTK 1.x days, and can cause |
|
402 | calls. These were a leftover from the GTK 1.x days, and can cause | |
380 | problems in certain cases (after a report by John Hunter). |
|
403 | problems in certain cases (after a report by John Hunter). | |
381 |
|
404 | |||
382 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if |
|
405 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if | |
383 | os.getcwd() fails at init time. Thanks to patch from David Remahl |
|
406 | os.getcwd() fails at init time. Thanks to patch from David Remahl | |
384 | <chmod007-AT-mac.com>. |
|
407 | <chmod007-AT-mac.com>. | |
385 | (InteractiveShell.__init__): prevent certain special magics from |
|
408 | (InteractiveShell.__init__): prevent certain special magics from | |
386 | being shadowed by aliases. Closes |
|
409 | being shadowed by aliases. Closes | |
387 | http://www.scipy.net/roundup/ipython/issue41. |
|
410 | http://www.scipy.net/roundup/ipython/issue41. | |
388 |
|
411 | |||
389 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
412 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
390 |
|
413 | |||
391 | * IPython/iplib.py (InteractiveShell.complete): Added new |
|
414 | * IPython/iplib.py (InteractiveShell.complete): Added new | |
392 | top-level completion method to expose the completion mechanism |
|
415 | top-level completion method to expose the completion mechanism | |
393 | beyond readline-based environments. |
|
416 | beyond readline-based environments. | |
394 |
|
417 | |||
395 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> |
|
418 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> | |
396 |
|
419 | |||
397 | * tools/ipsvnc (svnversion): fix svnversion capture. |
|
420 | * tools/ipsvnc (svnversion): fix svnversion capture. | |
398 |
|
421 | |||
399 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline |
|
422 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline | |
400 | attribute to self, which was missing. Before, it was set by a |
|
423 | attribute to self, which was missing. Before, it was set by a | |
401 | routine which in certain cases wasn't being called, so the |
|
424 | routine which in certain cases wasn't being called, so the | |
402 | instance could end up missing the attribute. This caused a crash. |
|
425 | instance could end up missing the attribute. This caused a crash. | |
403 | Closes http://www.scipy.net/roundup/ipython/issue40. |
|
426 | Closes http://www.scipy.net/roundup/ipython/issue40. | |
404 |
|
427 | |||
405 | 2005-08-16 Fernando Perez <fperez@colorado.edu> |
|
428 | 2005-08-16 Fernando Perez <fperez@colorado.edu> | |
406 |
|
429 | |||
407 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object |
|
430 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object | |
408 | contains non-string attribute. Closes |
|
431 | contains non-string attribute. Closes | |
409 | http://www.scipy.net/roundup/ipython/issue38. |
|
432 | http://www.scipy.net/roundup/ipython/issue38. | |
410 |
|
433 | |||
411 | 2005-08-14 Fernando Perez <fperez@colorado.edu> |
|
434 | 2005-08-14 Fernando Perez <fperez@colorado.edu> | |
412 |
|
435 | |||
413 | * tools/ipsvnc: Minor improvements, to add changeset info. |
|
436 | * tools/ipsvnc: Minor improvements, to add changeset info. | |
414 |
|
437 | |||
415 | 2005-08-12 Fernando Perez <fperez@colorado.edu> |
|
438 | 2005-08-12 Fernando Perez <fperez@colorado.edu> | |
416 |
|
439 | |||
417 | * IPython/iplib.py (runsource): remove self.code_to_run_src |
|
440 | * IPython/iplib.py (runsource): remove self.code_to_run_src | |
418 | attribute. I realized this is nothing more than |
|
441 | attribute. I realized this is nothing more than | |
419 | '\n'.join(self.buffer), and having the same data in two different |
|
442 | '\n'.join(self.buffer), and having the same data in two different | |
420 | places is just asking for synchronization bugs. This may impact |
|
443 | places is just asking for synchronization bugs. This may impact | |
421 | people who have custom exception handlers, so I need to warn |
|
444 | people who have custom exception handlers, so I need to warn | |
422 | ipython-dev about it (F. Mantegazza may use them). |
|
445 | ipython-dev about it (F. Mantegazza may use them). | |
423 |
|
446 | |||
424 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
447 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
425 |
|
448 | |||
426 | * IPython/genutils.py: fix 2.2 compatibility (generators) |
|
449 | * IPython/genutils.py: fix 2.2 compatibility (generators) | |
427 |
|
450 | |||
428 | 2005-07-18 Fernando Perez <fperez@colorado.edu> |
|
451 | 2005-07-18 Fernando Perez <fperez@colorado.edu> | |
429 |
|
452 | |||
430 | * IPython/genutils.py (get_home_dir): fix to help users with |
|
453 | * IPython/genutils.py (get_home_dir): fix to help users with | |
431 | invalid $HOME under win32. |
|
454 | invalid $HOME under win32. | |
432 |
|
455 | |||
433 | 2005-07-17 Fernando Perez <fperez@colorado.edu> |
|
456 | 2005-07-17 Fernando Perez <fperez@colorado.edu> | |
434 |
|
457 | |||
435 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove |
|
458 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove | |
436 | some old hacks and clean up a bit other routines; code should be |
|
459 | some old hacks and clean up a bit other routines; code should be | |
437 | simpler and a bit faster. |
|
460 | simpler and a bit faster. | |
438 |
|
461 | |||
439 | * IPython/iplib.py (interact): removed some last-resort attempts |
|
462 | * IPython/iplib.py (interact): removed some last-resort attempts | |
440 | to survive broken stdout/stderr. That code was only making it |
|
463 | to survive broken stdout/stderr. That code was only making it | |
441 | harder to abstract out the i/o (necessary for gui integration), |
|
464 | harder to abstract out the i/o (necessary for gui integration), | |
442 | and the crashes it could prevent were extremely rare in practice |
|
465 | and the crashes it could prevent were extremely rare in practice | |
443 | (besides being fully user-induced in a pretty violent manner). |
|
466 | (besides being fully user-induced in a pretty violent manner). | |
444 |
|
467 | |||
445 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. |
|
468 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. | |
446 | Nothing major yet, but the code is simpler to read; this should |
|
469 | Nothing major yet, but the code is simpler to read; this should | |
447 | make it easier to do more serious modifications in the future. |
|
470 | make it easier to do more serious modifications in the future. | |
448 |
|
471 | |||
449 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, |
|
472 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, | |
450 | which broke in .15 (thanks to a report by Ville). |
|
473 | which broke in .15 (thanks to a report by Ville). | |
451 |
|
474 | |||
452 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not |
|
475 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not | |
453 | be quite correct, I know next to nothing about unicode). This |
|
476 | be quite correct, I know next to nothing about unicode). This | |
454 | will allow unicode strings to be used in prompts, amongst other |
|
477 | will allow unicode strings to be used in prompts, amongst other | |
455 | cases. It also will prevent ipython from crashing when unicode |
|
478 | cases. It also will prevent ipython from crashing when unicode | |
456 | shows up unexpectedly in many places. If ascii encoding fails, we |
|
479 | shows up unexpectedly in many places. If ascii encoding fails, we | |
457 | assume utf_8. Currently the encoding is not a user-visible |
|
480 | assume utf_8. Currently the encoding is not a user-visible | |
458 | setting, though it could be made so if there is demand for it. |
|
481 | setting, though it could be made so if there is demand for it. | |
459 |
|
482 | |||
460 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. |
|
483 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. | |
461 |
|
484 | |||
462 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. |
|
485 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. | |
463 |
|
486 | |||
464 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. |
|
487 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. | |
465 |
|
488 | |||
466 | * IPython/genutils.py: Add 2.2 compatibility here, so all other |
|
489 | * IPython/genutils.py: Add 2.2 compatibility here, so all other | |
467 | code can work transparently for 2.2/2.3. |
|
490 | code can work transparently for 2.2/2.3. | |
468 |
|
491 | |||
469 | 2005-07-16 Fernando Perez <fperez@colorado.edu> |
|
492 | 2005-07-16 Fernando Perez <fperez@colorado.edu> | |
470 |
|
493 | |||
471 | * IPython/ultraTB.py (ExceptionColors): Make a global variable |
|
494 | * IPython/ultraTB.py (ExceptionColors): Make a global variable | |
472 | out of the color scheme table used for coloring exception |
|
495 | out of the color scheme table used for coloring exception | |
473 | tracebacks. This allows user code to add new schemes at runtime. |
|
496 | tracebacks. This allows user code to add new schemes at runtime. | |
474 | This is a minimally modified version of the patch at |
|
497 | This is a minimally modified version of the patch at | |
475 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw |
|
498 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw | |
476 | for the contribution. |
|
499 | for the contribution. | |
477 |
|
500 | |||
478 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a |
|
501 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a | |
479 | slightly modified version of the patch in |
|
502 | slightly modified version of the patch in | |
480 | http://www.scipy.net/roundup/ipython/issue34, which also allows me |
|
503 | http://www.scipy.net/roundup/ipython/issue34, which also allows me | |
481 | to remove the previous try/except solution (which was costlier). |
|
504 | to remove the previous try/except solution (which was costlier). | |
482 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. |
|
505 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. | |
483 |
|
506 | |||
484 | 2005-06-08 Fernando Perez <fperez@colorado.edu> |
|
507 | 2005-06-08 Fernando Perez <fperez@colorado.edu> | |
485 |
|
508 | |||
486 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
|
509 | * IPython/iplib.py (write/write_err): Add methods to abstract all | |
487 | I/O a bit more. |
|
510 | I/O a bit more. | |
488 |
|
511 | |||
489 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation |
|
512 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation | |
490 | warning, reported by Aric Hagberg, fix by JD Hunter. |
|
513 | warning, reported by Aric Hagberg, fix by JD Hunter. | |
491 |
|
514 | |||
492 | 2005-06-02 *** Released version 0.6.15 |
|
515 | 2005-06-02 *** Released version 0.6.15 | |
493 |
|
516 | |||
494 | 2005-06-01 Fernando Perez <fperez@colorado.edu> |
|
517 | 2005-06-01 Fernando Perez <fperez@colorado.edu> | |
495 |
|
518 | |||
496 | * IPython/iplib.py (MagicCompleter.file_matches): Fix |
|
519 | * IPython/iplib.py (MagicCompleter.file_matches): Fix | |
497 | tab-completion of filenames within open-quoted strings. Note that |
|
520 | tab-completion of filenames within open-quoted strings. Note that | |
498 | this requires that in ~/.ipython/ipythonrc, users change the |
|
521 | this requires that in ~/.ipython/ipythonrc, users change the | |
499 | readline delimiters configuration to read: |
|
522 | readline delimiters configuration to read: | |
500 |
|
523 | |||
501 | readline_remove_delims -/~ |
|
524 | readline_remove_delims -/~ | |
502 |
|
525 | |||
503 |
|
526 | |||
504 | 2005-05-31 *** Released version 0.6.14 |
|
527 | 2005-05-31 *** Released version 0.6.14 | |
505 |
|
528 | |||
506 | 2005-05-29 Fernando Perez <fperez@colorado.edu> |
|
529 | 2005-05-29 Fernando Perez <fperez@colorado.edu> | |
507 |
|
530 | |||
508 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks |
|
531 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks | |
509 | with files not on the filesystem. Reported by Eliyahu Sandler |
|
532 | with files not on the filesystem. Reported by Eliyahu Sandler | |
510 | <eli@gondolin.net> |
|
533 | <eli@gondolin.net> | |
511 |
|
534 | |||
512 | 2005-05-22 Fernando Perez <fperez@colorado.edu> |
|
535 | 2005-05-22 Fernando Perez <fperez@colorado.edu> | |
513 |
|
536 | |||
514 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. |
|
537 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. | |
515 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. |
|
538 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. | |
516 |
|
539 | |||
517 | 2005-05-19 Fernando Perez <fperez@colorado.edu> |
|
540 | 2005-05-19 Fernando Perez <fperez@colorado.edu> | |
518 |
|
541 | |||
519 | * IPython/iplib.py (safe_execfile): close a file which could be |
|
542 | * IPython/iplib.py (safe_execfile): close a file which could be | |
520 | left open (causing problems in win32, which locks open files). |
|
543 | left open (causing problems in win32, which locks open files). | |
521 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. |
|
544 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. | |
522 |
|
545 | |||
523 | 2005-05-18 Fernando Perez <fperez@colorado.edu> |
|
546 | 2005-05-18 Fernando Perez <fperez@colorado.edu> | |
524 |
|
547 | |||
525 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all |
|
548 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all | |
526 | keyword arguments correctly to safe_execfile(). |
|
549 | keyword arguments correctly to safe_execfile(). | |
527 |
|
550 | |||
528 | 2005-05-13 Fernando Perez <fperez@colorado.edu> |
|
551 | 2005-05-13 Fernando Perez <fperez@colorado.edu> | |
529 |
|
552 | |||
530 | * ipython.1: Added info about Qt to manpage, and threads warning |
|
553 | * ipython.1: Added info about Qt to manpage, and threads warning | |
531 | to usage page (invoked with --help). |
|
554 | to usage page (invoked with --help). | |
532 |
|
555 | |||
533 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added |
|
556 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added | |
534 | new matcher (it goes at the end of the priority list) to do |
|
557 | new matcher (it goes at the end of the priority list) to do | |
535 | tab-completion on named function arguments. Submitted by George |
|
558 | tab-completion on named function arguments. Submitted by George | |
536 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at |
|
559 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at | |
537 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html |
|
560 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html | |
538 | for more details. |
|
561 | for more details. | |
539 |
|
562 | |||
540 | * IPython/Magic.py (magic_run): Added new -e flag to ignore |
|
563 | * IPython/Magic.py (magic_run): Added new -e flag to ignore | |
541 | SystemExit exceptions in the script being run. Thanks to a report |
|
564 | SystemExit exceptions in the script being run. Thanks to a report | |
542 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this |
|
565 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this | |
543 | producing very annoying behavior when running unit tests. |
|
566 | producing very annoying behavior when running unit tests. | |
544 |
|
567 | |||
545 | 2005-05-12 Fernando Perez <fperez@colorado.edu> |
|
568 | 2005-05-12 Fernando Perez <fperez@colorado.edu> | |
546 |
|
569 | |||
547 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, |
|
570 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, | |
548 | which I'd broken (again) due to a changed regexp. In the process, |
|
571 | which I'd broken (again) due to a changed regexp. In the process, | |
549 | added ';' as an escape to auto-quote the whole line without |
|
572 | added ';' as an escape to auto-quote the whole line without | |
550 | splitting its arguments. Thanks to a report by Jerry McRae |
|
573 | splitting its arguments. Thanks to a report by Jerry McRae | |
551 | <qrs0xyc02-AT-sneakemail.com>. |
|
574 | <qrs0xyc02-AT-sneakemail.com>. | |
552 |
|
575 | |||
553 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but |
|
576 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but | |
554 | possible crashes caused by a TokenError. Reported by Ed Schofield |
|
577 | possible crashes caused by a TokenError. Reported by Ed Schofield | |
555 | <schofield-AT-ftw.at>. |
|
578 | <schofield-AT-ftw.at>. | |
556 |
|
579 | |||
557 | 2005-05-06 Fernando Perez <fperez@colorado.edu> |
|
580 | 2005-05-06 Fernando Perez <fperez@colorado.edu> | |
558 |
|
581 | |||
559 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. |
|
582 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. | |
560 |
|
583 | |||
561 | 2005-04-29 Fernando Perez <fperez@colorado.edu> |
|
584 | 2005-04-29 Fernando Perez <fperez@colorado.edu> | |
562 |
|
585 | |||
563 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière |
|
586 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière | |
564 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin |
|
587 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin | |
565 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option |
|
588 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option | |
566 | which provides support for Qt interactive usage (similar to the |
|
589 | which provides support for Qt interactive usage (similar to the | |
567 | existing one for WX and GTK). This had been often requested. |
|
590 | existing one for WX and GTK). This had been often requested. | |
568 |
|
591 | |||
569 | 2005-04-14 *** Released version 0.6.13 |
|
592 | 2005-04-14 *** Released version 0.6.13 | |
570 |
|
593 | |||
571 | 2005-04-08 Fernando Perez <fperez@colorado.edu> |
|
594 | 2005-04-08 Fernando Perez <fperez@colorado.edu> | |
572 |
|
595 | |||
573 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation |
|
596 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation | |
574 | from _ofind, which gets called on almost every input line. Now, |
|
597 | from _ofind, which gets called on almost every input line. Now, | |
575 | we only try to get docstrings if they are actually going to be |
|
598 | we only try to get docstrings if they are actually going to be | |
576 | used (the overhead of fetching unnecessary docstrings can be |
|
599 | used (the overhead of fetching unnecessary docstrings can be | |
577 | noticeable for certain objects, such as Pyro proxies). |
|
600 | noticeable for certain objects, such as Pyro proxies). | |
578 |
|
601 | |||
579 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API |
|
602 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API | |
580 | for completers. For some reason I had been passing them the state |
|
603 | for completers. For some reason I had been passing them the state | |
581 | variable, which completers never actually need, and was in |
|
604 | variable, which completers never actually need, and was in | |
582 | conflict with the rlcompleter API. Custom completers ONLY need to |
|
605 | conflict with the rlcompleter API. Custom completers ONLY need to | |
583 | take the text parameter. |
|
606 | take the text parameter. | |
584 |
|
607 | |||
585 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics |
|
608 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics | |
586 | work correctly in pysh. I've also moved all the logic which used |
|
609 | work correctly in pysh. I've also moved all the logic which used | |
587 | to be in pysh.py here, which will prevent problems with future |
|
610 | to be in pysh.py here, which will prevent problems with future | |
588 | upgrades. However, this time I must warn users to update their |
|
611 | upgrades. However, this time I must warn users to update their | |
589 | pysh profile to include the line |
|
612 | pysh profile to include the line | |
590 |
|
613 | |||
591 | import_all IPython.Extensions.InterpreterExec |
|
614 | import_all IPython.Extensions.InterpreterExec | |
592 |
|
615 | |||
593 | because otherwise things won't work for them. They MUST also |
|
616 | because otherwise things won't work for them. They MUST also | |
594 | delete pysh.py and the line |
|
617 | delete pysh.py and the line | |
595 |
|
618 | |||
596 | execfile pysh.py |
|
619 | execfile pysh.py | |
597 |
|
620 | |||
598 | from their ipythonrc-pysh. |
|
621 | from their ipythonrc-pysh. | |
599 |
|
622 | |||
600 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more |
|
623 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more | |
601 | robust in the face of objects whose dir() returns non-strings |
|
624 | robust in the face of objects whose dir() returns non-strings | |
602 | (which it shouldn't, but some broken libs like ITK do). Thanks to |
|
625 | (which it shouldn't, but some broken libs like ITK do). Thanks to | |
603 | a patch by John Hunter (implemented differently, though). Also |
|
626 | a patch by John Hunter (implemented differently, though). Also | |
604 | minor improvements by using .extend instead of + on lists. |
|
627 | minor improvements by using .extend instead of + on lists. | |
605 |
|
628 | |||
606 | * pysh.py: |
|
629 | * pysh.py: | |
607 |
|
630 | |||
608 | 2005-04-06 Fernando Perez <fperez@colorado.edu> |
|
631 | 2005-04-06 Fernando Perez <fperez@colorado.edu> | |
609 |
|
632 | |||
610 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on |
|
633 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on | |
611 | by default, so that all users benefit from it. Those who don't |
|
634 | by default, so that all users benefit from it. Those who don't | |
612 | want it can still turn it off. |
|
635 | want it can still turn it off. | |
613 |
|
636 | |||
614 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the |
|
637 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the | |
615 | config file, I'd forgotten about this, so users were getting it |
|
638 | config file, I'd forgotten about this, so users were getting it | |
616 | off by default. |
|
639 | off by default. | |
617 |
|
640 | |||
618 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for |
|
641 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for | |
619 | consistency. Now magics can be called in multiline statements, |
|
642 | consistency. Now magics can be called in multiline statements, | |
620 | and python variables can be expanded in magic calls via $var. |
|
643 | and python variables can be expanded in magic calls via $var. | |
621 | This makes the magic system behave just like aliases or !system |
|
644 | This makes the magic system behave just like aliases or !system | |
622 | calls. |
|
645 | calls. | |
623 |
|
646 | |||
624 | 2005-03-28 Fernando Perez <fperez@colorado.edu> |
|
647 | 2005-03-28 Fernando Perez <fperez@colorado.edu> | |
625 |
|
648 | |||
626 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of |
|
649 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of | |
627 | expensive string additions for building command. Add support for |
|
650 | expensive string additions for building command. Add support for | |
628 | trailing ';' when autocall is used. |
|
651 | trailing ';' when autocall is used. | |
629 |
|
652 | |||
630 | 2005-03-26 Fernando Perez <fperez@colorado.edu> |
|
653 | 2005-03-26 Fernando Perez <fperez@colorado.edu> | |
631 |
|
654 | |||
632 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. |
|
655 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. | |
633 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make |
|
656 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make | |
634 | ipython.el robust against prompts with any number of spaces |
|
657 | ipython.el robust against prompts with any number of spaces | |
635 | (including 0) after the ':' character. |
|
658 | (including 0) after the ':' character. | |
636 |
|
659 | |||
637 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in |
|
660 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in | |
638 | continuation prompt, which misled users to think the line was |
|
661 | continuation prompt, which misled users to think the line was | |
639 | already indented. Closes debian Bug#300847, reported to me by |
|
662 | already indented. Closes debian Bug#300847, reported to me by | |
640 | Norbert Tretkowski <tretkowski-AT-inittab.de>. |
|
663 | Norbert Tretkowski <tretkowski-AT-inittab.de>. | |
641 |
|
664 | |||
642 | 2005-03-23 Fernando Perez <fperez@colorado.edu> |
|
665 | 2005-03-23 Fernando Perez <fperez@colorado.edu> | |
643 |
|
666 | |||
644 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are |
|
667 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are | |
645 | properly aligned if they have embedded newlines. |
|
668 | properly aligned if they have embedded newlines. | |
646 |
|
669 | |||
647 | * IPython/iplib.py (runlines): Add a public method to expose |
|
670 | * IPython/iplib.py (runlines): Add a public method to expose | |
648 | IPython's code execution machinery, so that users can run strings |
|
671 | IPython's code execution machinery, so that users can run strings | |
649 | as if they had been typed at the prompt interactively. |
|
672 | as if they had been typed at the prompt interactively. | |
650 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ |
|
673 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ | |
651 | methods which can call the system shell, but with python variable |
|
674 | methods which can call the system shell, but with python variable | |
652 | expansion. The three such methods are: __IPYTHON__.system, |
|
675 | expansion. The three such methods are: __IPYTHON__.system, | |
653 | .getoutput and .getoutputerror. These need to be documented in a |
|
676 | .getoutput and .getoutputerror. These need to be documented in a | |
654 | 'public API' section (to be written) of the manual. |
|
677 | 'public API' section (to be written) of the manual. | |
655 |
|
678 | |||
656 | 2005-03-20 Fernando Perez <fperez@colorado.edu> |
|
679 | 2005-03-20 Fernando Perez <fperez@colorado.edu> | |
657 |
|
680 | |||
658 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system |
|
681 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system | |
659 | for custom exception handling. This is quite powerful, and it |
|
682 | for custom exception handling. This is quite powerful, and it | |
660 | allows for user-installable exception handlers which can trap |
|
683 | allows for user-installable exception handlers which can trap | |
661 | custom exceptions at runtime and treat them separately from |
|
684 | custom exceptions at runtime and treat them separately from | |
662 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric |
|
685 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric | |
663 | Mantegazza <mantegazza-AT-ill.fr>. |
|
686 | Mantegazza <mantegazza-AT-ill.fr>. | |
664 | (InteractiveShell.set_custom_completer): public API function to |
|
687 | (InteractiveShell.set_custom_completer): public API function to | |
665 | add new completers at runtime. |
|
688 | add new completers at runtime. | |
666 |
|
689 | |||
667 | 2005-03-19 Fernando Perez <fperez@colorado.edu> |
|
690 | 2005-03-19 Fernando Perez <fperez@colorado.edu> | |
668 |
|
691 | |||
669 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to |
|
692 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to | |
670 | allow objects which provide their docstrings via non-standard |
|
693 | allow objects which provide their docstrings via non-standard | |
671 | mechanisms (like Pyro proxies) to still be inspected by ipython's |
|
694 | mechanisms (like Pyro proxies) to still be inspected by ipython's | |
672 | ? system. |
|
695 | ? system. | |
673 |
|
696 | |||
674 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e |
|
697 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e | |
675 | automatic capture system. I tried quite hard to make it work |
|
698 | automatic capture system. I tried quite hard to make it work | |
676 | reliably, and simply failed. I tried many combinations with the |
|
699 | reliably, and simply failed. I tried many combinations with the | |
677 | subprocess module, but eventually nothing worked in all needed |
|
700 | subprocess module, but eventually nothing worked in all needed | |
678 | cases (not blocking stdin for the child, duplicating stdout |
|
701 | cases (not blocking stdin for the child, duplicating stdout | |
679 | without blocking, etc). The new %sc/%sx still do capture to these |
|
702 | without blocking, etc). The new %sc/%sx still do capture to these | |
680 | magical list/string objects which make shell use much more |
|
703 | magical list/string objects which make shell use much more | |
681 | conveninent, so not all is lost. |
|
704 | conveninent, so not all is lost. | |
682 |
|
705 | |||
683 | XXX - FIX MANUAL for the change above! |
|
706 | XXX - FIX MANUAL for the change above! | |
684 |
|
707 | |||
685 | (runsource): I copied code.py's runsource() into ipython to modify |
|
708 | (runsource): I copied code.py's runsource() into ipython to modify | |
686 | it a bit. Now the code object and source to be executed are |
|
709 | it a bit. Now the code object and source to be executed are | |
687 | stored in ipython. This makes this info accessible to third-party |
|
710 | stored in ipython. This makes this info accessible to third-party | |
688 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric |
|
711 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric | |
689 | Mantegazza <mantegazza-AT-ill.fr>. |
|
712 | Mantegazza <mantegazza-AT-ill.fr>. | |
690 |
|
713 | |||
691 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to |
|
714 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to | |
692 | history-search via readline (like C-p/C-n). I'd wanted this for a |
|
715 | history-search via readline (like C-p/C-n). I'd wanted this for a | |
693 | long time, but only recently found out how to do it. For users |
|
716 | long time, but only recently found out how to do it. For users | |
694 | who already have their ipythonrc files made and want this, just |
|
717 | who already have their ipythonrc files made and want this, just | |
695 | add: |
|
718 | add: | |
696 |
|
719 | |||
697 | readline_parse_and_bind "\e[A": history-search-backward |
|
720 | readline_parse_and_bind "\e[A": history-search-backward | |
698 | readline_parse_and_bind "\e[B": history-search-forward |
|
721 | readline_parse_and_bind "\e[B": history-search-forward | |
699 |
|
722 | |||
700 | 2005-03-18 Fernando Perez <fperez@colorado.edu> |
|
723 | 2005-03-18 Fernando Perez <fperez@colorado.edu> | |
701 |
|
724 | |||
702 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy |
|
725 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy | |
703 | LSString and SList classes which allow transparent conversions |
|
726 | LSString and SList classes which allow transparent conversions | |
704 | between list mode and whitespace-separated string. |
|
727 | between list mode and whitespace-separated string. | |
705 | (magic_r): Fix recursion problem in %r. |
|
728 | (magic_r): Fix recursion problem in %r. | |
706 |
|
729 | |||
707 | * IPython/genutils.py (LSString): New class to be used for |
|
730 | * IPython/genutils.py (LSString): New class to be used for | |
708 | automatic storage of the results of all alias/system calls in _o |
|
731 | automatic storage of the results of all alias/system calls in _o | |
709 | and _e (stdout/err). These provide a .l/.list attribute which |
|
732 | and _e (stdout/err). These provide a .l/.list attribute which | |
710 | does automatic splitting on newlines. This means that for most |
|
733 | does automatic splitting on newlines. This means that for most | |
711 | uses, you'll never need to do capturing of output with %sc/%sx |
|
734 | uses, you'll never need to do capturing of output with %sc/%sx | |
712 | anymore, since ipython keeps this always done for you. Note that |
|
735 | anymore, since ipython keeps this always done for you. Note that | |
713 | only the LAST results are stored, the _o/e variables are |
|
736 | only the LAST results are stored, the _o/e variables are | |
714 | overwritten on each call. If you need to save their contents |
|
737 | overwritten on each call. If you need to save their contents | |
715 | further, simply bind them to any other name. |
|
738 | further, simply bind them to any other name. | |
716 |
|
739 | |||
717 | 2005-03-17 Fernando Perez <fperez@colorado.edu> |
|
740 | 2005-03-17 Fernando Perez <fperez@colorado.edu> | |
718 |
|
741 | |||
719 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for |
|
742 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for | |
720 | prompt namespace handling. |
|
743 | prompt namespace handling. | |
721 |
|
744 | |||
722 | 2005-03-16 Fernando Perez <fperez@colorado.edu> |
|
745 | 2005-03-16 Fernando Perez <fperez@colorado.edu> | |
723 |
|
746 | |||
724 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and |
|
747 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and | |
725 | classic prompts to be '>>> ' (final space was missing, and it |
|
748 | classic prompts to be '>>> ' (final space was missing, and it | |
726 | trips the emacs python mode). |
|
749 | trips the emacs python mode). | |
727 | (BasePrompt.__str__): Added safe support for dynamic prompt |
|
750 | (BasePrompt.__str__): Added safe support for dynamic prompt | |
728 | strings. Now you can set your prompt string to be '$x', and the |
|
751 | strings. Now you can set your prompt string to be '$x', and the | |
729 | value of x will be printed from your interactive namespace. The |
|
752 | value of x will be printed from your interactive namespace. The | |
730 | interpolation syntax includes the full Itpl support, so |
|
753 | interpolation syntax includes the full Itpl support, so | |
731 | ${foo()+x+bar()} is a valid prompt string now, and the function |
|
754 | ${foo()+x+bar()} is a valid prompt string now, and the function | |
732 | calls will be made at runtime. |
|
755 | calls will be made at runtime. | |
733 |
|
756 | |||
734 | 2005-03-15 Fernando Perez <fperez@colorado.edu> |
|
757 | 2005-03-15 Fernando Perez <fperez@colorado.edu> | |
735 |
|
758 | |||
736 | * IPython/Magic.py (magic_history): renamed %hist to %history, to |
|
759 | * IPython/Magic.py (magic_history): renamed %hist to %history, to | |
737 | avoid name clashes in pylab. %hist still works, it just forwards |
|
760 | avoid name clashes in pylab. %hist still works, it just forwards | |
738 | the call to %history. |
|
761 | the call to %history. | |
739 |
|
762 | |||
740 | 2005-03-02 *** Released version 0.6.12 |
|
763 | 2005-03-02 *** Released version 0.6.12 | |
741 |
|
764 | |||
742 | 2005-03-02 Fernando Perez <fperez@colorado.edu> |
|
765 | 2005-03-02 Fernando Perez <fperez@colorado.edu> | |
743 |
|
766 | |||
744 | * IPython/iplib.py (handle_magic): log magic calls properly as |
|
767 | * IPython/iplib.py (handle_magic): log magic calls properly as | |
745 | ipmagic() function calls. |
|
768 | ipmagic() function calls. | |
746 |
|
769 | |||
747 | * IPython/Magic.py (magic_time): Improved %time to support |
|
770 | * IPython/Magic.py (magic_time): Improved %time to support | |
748 | statements and provide wall-clock as well as CPU time. |
|
771 | statements and provide wall-clock as well as CPU time. | |
749 |
|
772 | |||
750 | 2005-02-27 Fernando Perez <fperez@colorado.edu> |
|
773 | 2005-02-27 Fernando Perez <fperez@colorado.edu> | |
751 |
|
774 | |||
752 | * IPython/hooks.py: New hooks module, to expose user-modifiable |
|
775 | * IPython/hooks.py: New hooks module, to expose user-modifiable | |
753 | IPython functionality in a clean manner. For now only the editor |
|
776 | IPython functionality in a clean manner. For now only the editor | |
754 | hook is actually written, and other thigns which I intend to turn |
|
777 | hook is actually written, and other thigns which I intend to turn | |
755 | into proper hooks aren't yet there. The display and prefilter |
|
778 | into proper hooks aren't yet there. The display and prefilter | |
756 | stuff, for example, should be hooks. But at least now the |
|
779 | stuff, for example, should be hooks. But at least now the | |
757 | framework is in place, and the rest can be moved here with more |
|
780 | framework is in place, and the rest can be moved here with more | |
758 | time later. IPython had had a .hooks variable for a long time for |
|
781 | time later. IPython had had a .hooks variable for a long time for | |
759 | this purpose, but I'd never actually used it for anything. |
|
782 | this purpose, but I'd never actually used it for anything. | |
760 |
|
783 | |||
761 | 2005-02-26 Fernando Perez <fperez@colorado.edu> |
|
784 | 2005-02-26 Fernando Perez <fperez@colorado.edu> | |
762 |
|
785 | |||
763 | * IPython/ipmaker.py (make_IPython): make the default ipython |
|
786 | * IPython/ipmaker.py (make_IPython): make the default ipython | |
764 | directory be called _ipython under win32, to follow more the |
|
787 | directory be called _ipython under win32, to follow more the | |
765 | naming peculiarities of that platform (where buggy software like |
|
788 | naming peculiarities of that platform (where buggy software like | |
766 | Visual Sourcesafe breaks with .named directories). Reported by |
|
789 | Visual Sourcesafe breaks with .named directories). Reported by | |
767 | Ville Vainio. |
|
790 | Ville Vainio. | |
768 |
|
791 | |||
769 | 2005-02-23 Fernando Perez <fperez@colorado.edu> |
|
792 | 2005-02-23 Fernando Perez <fperez@colorado.edu> | |
770 |
|
793 | |||
771 | * IPython/iplib.py (InteractiveShell.__init__): removed a few |
|
794 | * IPython/iplib.py (InteractiveShell.__init__): removed a few | |
772 | auto_aliases for win32 which were causing problems. Users can |
|
795 | auto_aliases for win32 which were causing problems. Users can | |
773 | define the ones they personally like. |
|
796 | define the ones they personally like. | |
774 |
|
797 | |||
775 | 2005-02-21 Fernando Perez <fperez@colorado.edu> |
|
798 | 2005-02-21 Fernando Perez <fperez@colorado.edu> | |
776 |
|
799 | |||
777 | * IPython/Magic.py (magic_time): new magic to time execution of |
|
800 | * IPython/Magic.py (magic_time): new magic to time execution of | |
778 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. |
|
801 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. | |
779 |
|
802 | |||
780 | 2005-02-19 Fernando Perez <fperez@colorado.edu> |
|
803 | 2005-02-19 Fernando Perez <fperez@colorado.edu> | |
781 |
|
804 | |||
782 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings |
|
805 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings | |
783 | into keys (for prompts, for example). |
|
806 | into keys (for prompts, for example). | |
784 |
|
807 | |||
785 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty |
|
808 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty | |
786 | prompts in case users want them. This introduces a small behavior |
|
809 | prompts in case users want them. This introduces a small behavior | |
787 | change: ipython does not automatically add a space to all prompts |
|
810 | change: ipython does not automatically add a space to all prompts | |
788 | anymore. To get the old prompts with a space, users should add it |
|
811 | anymore. To get the old prompts with a space, users should add it | |
789 | manually to their ipythonrc file, so for example prompt_in1 should |
|
812 | manually to their ipythonrc file, so for example prompt_in1 should | |
790 | now read 'In [\#]: ' instead of 'In [\#]:'. |
|
813 | now read 'In [\#]: ' instead of 'In [\#]:'. | |
791 | (BasePrompt.__init__): New option prompts_pad_left (only in rc |
|
814 | (BasePrompt.__init__): New option prompts_pad_left (only in rc | |
792 | file) to control left-padding of secondary prompts. |
|
815 | file) to control left-padding of secondary prompts. | |
793 |
|
816 | |||
794 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if |
|
817 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if | |
795 | the profiler can't be imported. Fix for Debian, which removed |
|
818 | the profiler can't be imported. Fix for Debian, which removed | |
796 | profile.py because of License issues. I applied a slightly |
|
819 | profile.py because of License issues. I applied a slightly | |
797 | modified version of the original Debian patch at |
|
820 | modified version of the original Debian patch at | |
798 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. |
|
821 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. | |
799 |
|
822 | |||
800 | 2005-02-17 Fernando Perez <fperez@colorado.edu> |
|
823 | 2005-02-17 Fernando Perez <fperez@colorado.edu> | |
801 |
|
824 | |||
802 | * IPython/genutils.py (native_line_ends): Fix bug which would |
|
825 | * IPython/genutils.py (native_line_ends): Fix bug which would | |
803 | cause improper line-ends under win32 b/c I was not opening files |
|
826 | cause improper line-ends under win32 b/c I was not opening files | |
804 | in binary mode. Bug report and fix thanks to Ville. |
|
827 | in binary mode. Bug report and fix thanks to Ville. | |
805 |
|
828 | |||
806 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when |
|
829 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when | |
807 | trying to catch spurious foo[1] autocalls. My fix actually broke |
|
830 | trying to catch spurious foo[1] autocalls. My fix actually broke | |
808 | ',/' autoquote/call with explicit escape (bad regexp). |
|
831 | ',/' autoquote/call with explicit escape (bad regexp). | |
809 |
|
832 | |||
810 | 2005-02-15 *** Released version 0.6.11 |
|
833 | 2005-02-15 *** Released version 0.6.11 | |
811 |
|
834 | |||
812 | 2005-02-14 Fernando Perez <fperez@colorado.edu> |
|
835 | 2005-02-14 Fernando Perez <fperez@colorado.edu> | |
813 |
|
836 | |||
814 | * IPython/background_jobs.py: New background job management |
|
837 | * IPython/background_jobs.py: New background job management | |
815 | subsystem. This is implemented via a new set of classes, and |
|
838 | subsystem. This is implemented via a new set of classes, and | |
816 | IPython now provides a builtin 'jobs' object for background job |
|
839 | IPython now provides a builtin 'jobs' object for background job | |
817 | execution. A convenience %bg magic serves as a lightweight |
|
840 | execution. A convenience %bg magic serves as a lightweight | |
818 | frontend for starting the more common type of calls. This was |
|
841 | frontend for starting the more common type of calls. This was | |
819 | inspired by discussions with B. Granger and the BackgroundCommand |
|
842 | inspired by discussions with B. Granger and the BackgroundCommand | |
820 | class described in the book Python Scripting for Computational |
|
843 | class described in the book Python Scripting for Computational | |
821 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting |
|
844 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting | |
822 | (although ultimately no code from this text was used, as IPython's |
|
845 | (although ultimately no code from this text was used, as IPython's | |
823 | system is a separate implementation). |
|
846 | system is a separate implementation). | |
824 |
|
847 | |||
825 | * IPython/iplib.py (MagicCompleter.python_matches): add new option |
|
848 | * IPython/iplib.py (MagicCompleter.python_matches): add new option | |
826 | to control the completion of single/double underscore names |
|
849 | to control the completion of single/double underscore names | |
827 | separately. As documented in the example ipytonrc file, the |
|
850 | separately. As documented in the example ipytonrc file, the | |
828 | readline_omit__names variable can now be set to 2, to omit even |
|
851 | readline_omit__names variable can now be set to 2, to omit even | |
829 | single underscore names. Thanks to a patch by Brian Wong |
|
852 | single underscore names. Thanks to a patch by Brian Wong | |
830 | <BrianWong-AT-AirgoNetworks.Com>. |
|
853 | <BrianWong-AT-AirgoNetworks.Com>. | |
831 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to |
|
854 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to | |
832 | be autocalled as foo([1]) if foo were callable. A problem for |
|
855 | be autocalled as foo([1]) if foo were callable. A problem for | |
833 | things which are both callable and implement __getitem__. |
|
856 | things which are both callable and implement __getitem__. | |
834 | (init_readline): Fix autoindentation for win32. Thanks to a patch |
|
857 | (init_readline): Fix autoindentation for win32. Thanks to a patch | |
835 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. |
|
858 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. | |
836 |
|
859 | |||
837 | 2005-02-12 Fernando Perez <fperez@colorado.edu> |
|
860 | 2005-02-12 Fernando Perez <fperez@colorado.edu> | |
838 |
|
861 | |||
839 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps |
|
862 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps | |
840 | which I had written long ago to sort out user error messages which |
|
863 | which I had written long ago to sort out user error messages which | |
841 | may occur during startup. This seemed like a good idea initially, |
|
864 | may occur during startup. This seemed like a good idea initially, | |
842 | but it has proven a disaster in retrospect. I don't want to |
|
865 | but it has proven a disaster in retrospect. I don't want to | |
843 | change much code for now, so my fix is to set the internal 'debug' |
|
866 | change much code for now, so my fix is to set the internal 'debug' | |
844 | flag to true everywhere, whose only job was precisely to control |
|
867 | flag to true everywhere, whose only job was precisely to control | |
845 | this subsystem. This closes issue 28 (as well as avoiding all |
|
868 | this subsystem. This closes issue 28 (as well as avoiding all | |
846 | sorts of strange hangups which occur from time to time). |
|
869 | sorts of strange hangups which occur from time to time). | |
847 |
|
870 | |||
848 | 2005-02-07 Fernando Perez <fperez@colorado.edu> |
|
871 | 2005-02-07 Fernando Perez <fperez@colorado.edu> | |
849 |
|
872 | |||
850 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the |
|
873 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the | |
851 | previous call produced a syntax error. |
|
874 | previous call produced a syntax error. | |
852 |
|
875 | |||
853 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
876 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
854 | classes without constructor. |
|
877 | classes without constructor. | |
855 |
|
878 | |||
856 | 2005-02-06 Fernando Perez <fperez@colorado.edu> |
|
879 | 2005-02-06 Fernando Perez <fperez@colorado.edu> | |
857 |
|
880 | |||
858 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of |
|
881 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of | |
859 | completions with the results of each matcher, so we return results |
|
882 | completions with the results of each matcher, so we return results | |
860 | to the user from all namespaces. This breaks with ipython |
|
883 | to the user from all namespaces. This breaks with ipython | |
861 | tradition, but I think it's a nicer behavior. Now you get all |
|
884 | tradition, but I think it's a nicer behavior. Now you get all | |
862 | possible completions listed, from all possible namespaces (python, |
|
885 | possible completions listed, from all possible namespaces (python, | |
863 | filesystem, magics...) After a request by John Hunter |
|
886 | filesystem, magics...) After a request by John Hunter | |
864 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
887 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
865 |
|
888 | |||
866 | 2005-02-05 Fernando Perez <fperez@colorado.edu> |
|
889 | 2005-02-05 Fernando Perez <fperez@colorado.edu> | |
867 |
|
890 | |||
868 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if |
|
891 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if | |
869 | the call had quote characters in it (the quotes were stripped). |
|
892 | the call had quote characters in it (the quotes were stripped). | |
870 |
|
893 | |||
871 | 2005-01-31 Fernando Perez <fperez@colorado.edu> |
|
894 | 2005-01-31 Fernando Perez <fperez@colorado.edu> | |
872 |
|
895 | |||
873 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on |
|
896 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on | |
874 | Itpl.itpl() to make the code more robust against psyco |
|
897 | Itpl.itpl() to make the code more robust against psyco | |
875 | optimizations. |
|
898 | optimizations. | |
876 |
|
899 | |||
877 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead |
|
900 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead | |
878 | of causing an exception. Quicker, cleaner. |
|
901 | of causing an exception. Quicker, cleaner. | |
879 |
|
902 | |||
880 | 2005-01-28 Fernando Perez <fperez@colorado.edu> |
|
903 | 2005-01-28 Fernando Perez <fperez@colorado.edu> | |
881 |
|
904 | |||
882 | * scripts/ipython_win_post_install.py (install): hardcode |
|
905 | * scripts/ipython_win_post_install.py (install): hardcode | |
883 | sys.prefix+'python.exe' as the executable path. It turns out that |
|
906 | sys.prefix+'python.exe' as the executable path. It turns out that | |
884 | during the post-installation run, sys.executable resolves to the |
|
907 | during the post-installation run, sys.executable resolves to the | |
885 | name of the binary installer! I should report this as a distutils |
|
908 | name of the binary installer! I should report this as a distutils | |
886 | bug, I think. I updated the .10 release with this tiny fix, to |
|
909 | bug, I think. I updated the .10 release with this tiny fix, to | |
887 | avoid annoying the lists further. |
|
910 | avoid annoying the lists further. | |
888 |
|
911 | |||
889 | 2005-01-27 *** Released version 0.6.10 |
|
912 | 2005-01-27 *** Released version 0.6.10 | |
890 |
|
913 | |||
891 | 2005-01-27 Fernando Perez <fperez@colorado.edu> |
|
914 | 2005-01-27 Fernando Perez <fperez@colorado.edu> | |
892 |
|
915 | |||
893 | * IPython/numutils.py (norm): Added 'inf' as optional name for |
|
916 | * IPython/numutils.py (norm): Added 'inf' as optional name for | |
894 | L-infinity norm, included references to mathworld.com for vector |
|
917 | L-infinity norm, included references to mathworld.com for vector | |
895 | norm definitions. |
|
918 | norm definitions. | |
896 | (amin/amax): added amin/amax for array min/max. Similar to what |
|
919 | (amin/amax): added amin/amax for array min/max. Similar to what | |
897 | pylab ships with after the recent reorganization of names. |
|
920 | pylab ships with after the recent reorganization of names. | |
898 | (spike/spike_odd): removed deprecated spike/spike_odd functions. |
|
921 | (spike/spike_odd): removed deprecated spike/spike_odd functions. | |
899 |
|
922 | |||
900 | * ipython.el: committed Alex's recent fixes and improvements. |
|
923 | * ipython.el: committed Alex's recent fixes and improvements. | |
901 | Tested with python-mode from CVS, and it looks excellent. Since |
|
924 | Tested with python-mode from CVS, and it looks excellent. Since | |
902 | python-mode hasn't released anything in a while, I'm temporarily |
|
925 | python-mode hasn't released anything in a while, I'm temporarily | |
903 | putting a copy of today's CVS (v 4.70) of python-mode in: |
|
926 | putting a copy of today's CVS (v 4.70) of python-mode in: | |
904 | http://ipython.scipy.org/tmp/python-mode.el |
|
927 | http://ipython.scipy.org/tmp/python-mode.el | |
905 |
|
928 | |||
906 | * scripts/ipython_win_post_install.py (install): Win32 fix to use |
|
929 | * scripts/ipython_win_post_install.py (install): Win32 fix to use | |
907 | sys.executable for the executable name, instead of assuming it's |
|
930 | sys.executable for the executable name, instead of assuming it's | |
908 | called 'python.exe' (the post-installer would have produced broken |
|
931 | called 'python.exe' (the post-installer would have produced broken | |
909 | setups on systems with a differently named python binary). |
|
932 | setups on systems with a differently named python binary). | |
910 |
|
933 | |||
911 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' |
|
934 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' | |
912 | references to os.linesep, to make the code more |
|
935 | references to os.linesep, to make the code more | |
913 | platform-independent. This is also part of the win32 coloring |
|
936 | platform-independent. This is also part of the win32 coloring | |
914 | fixes. |
|
937 | fixes. | |
915 |
|
938 | |||
916 | * IPython/genutils.py (page_dumb): Remove attempts to chop long |
|
939 | * IPython/genutils.py (page_dumb): Remove attempts to chop long | |
917 | lines, which actually cause coloring bugs because the length of |
|
940 | lines, which actually cause coloring bugs because the length of | |
918 | the line is very difficult to correctly compute with embedded |
|
941 | the line is very difficult to correctly compute with embedded | |
919 | escapes. This was the source of all the coloring problems under |
|
942 | escapes. This was the source of all the coloring problems under | |
920 | Win32. I think that _finally_, Win32 users have a properly |
|
943 | Win32. I think that _finally_, Win32 users have a properly | |
921 | working ipython in all respects. This would never have happened |
|
944 | working ipython in all respects. This would never have happened | |
922 | if not for Gary Bishop and Viktor Ransmayr's great help and work. |
|
945 | if not for Gary Bishop and Viktor Ransmayr's great help and work. | |
923 |
|
946 | |||
924 | 2005-01-26 *** Released version 0.6.9 |
|
947 | 2005-01-26 *** Released version 0.6.9 | |
925 |
|
948 | |||
926 | 2005-01-25 Fernando Perez <fperez@colorado.edu> |
|
949 | 2005-01-25 Fernando Perez <fperez@colorado.edu> | |
927 |
|
950 | |||
928 | * setup.py: finally, we have a true Windows installer, thanks to |
|
951 | * setup.py: finally, we have a true Windows installer, thanks to | |
929 | the excellent work of Viktor Ransmayr |
|
952 | the excellent work of Viktor Ransmayr | |
930 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for |
|
953 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for | |
931 | Windows users. The setup routine is quite a bit cleaner thanks to |
|
954 | Windows users. The setup routine is quite a bit cleaner thanks to | |
932 | this, and the post-install script uses the proper functions to |
|
955 | this, and the post-install script uses the proper functions to | |
933 | allow a clean de-installation using the standard Windows Control |
|
956 | allow a clean de-installation using the standard Windows Control | |
934 | Panel. |
|
957 | Panel. | |
935 |
|
958 | |||
936 | * IPython/genutils.py (get_home_dir): changed to use the $HOME |
|
959 | * IPython/genutils.py (get_home_dir): changed to use the $HOME | |
937 | environment variable under all OSes (including win32) if |
|
960 | environment variable under all OSes (including win32) if | |
938 | available. This will give consistency to win32 users who have set |
|
961 | available. This will give consistency to win32 users who have set | |
939 | this variable for any reason. If os.environ['HOME'] fails, the |
|
962 | this variable for any reason. If os.environ['HOME'] fails, the | |
940 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. |
|
963 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. | |
941 |
|
964 | |||
942 | 2005-01-24 Fernando Perez <fperez@colorado.edu> |
|
965 | 2005-01-24 Fernando Perez <fperez@colorado.edu> | |
943 |
|
966 | |||
944 | * IPython/numutils.py (empty_like): add empty_like(), similar to |
|
967 | * IPython/numutils.py (empty_like): add empty_like(), similar to | |
945 | zeros_like() but taking advantage of the new empty() Numeric routine. |
|
968 | zeros_like() but taking advantage of the new empty() Numeric routine. | |
946 |
|
969 | |||
947 | 2005-01-23 *** Released version 0.6.8 |
|
970 | 2005-01-23 *** Released version 0.6.8 | |
948 |
|
971 | |||
949 | 2005-01-22 Fernando Perez <fperez@colorado.edu> |
|
972 | 2005-01-22 Fernando Perez <fperez@colorado.edu> | |
950 |
|
973 | |||
951 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the |
|
974 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the | |
952 | automatic show() calls. After discussing things with JDH, it |
|
975 | automatic show() calls. After discussing things with JDH, it | |
953 | turns out there are too many corner cases where this can go wrong. |
|
976 | turns out there are too many corner cases where this can go wrong. | |
954 | It's best not to try to be 'too smart', and simply have ipython |
|
977 | It's best not to try to be 'too smart', and simply have ipython | |
955 | reproduce as much as possible the default behavior of a normal |
|
978 | reproduce as much as possible the default behavior of a normal | |
956 | python shell. |
|
979 | python shell. | |
957 |
|
980 | |||
958 | * IPython/iplib.py (InteractiveShell.__init__): Modified the |
|
981 | * IPython/iplib.py (InteractiveShell.__init__): Modified the | |
959 | line-splitting regexp and _prefilter() to avoid calling getattr() |
|
982 | line-splitting regexp and _prefilter() to avoid calling getattr() | |
960 | on assignments. This closes |
|
983 | on assignments. This closes | |
961 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's |
|
984 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's | |
962 | readline uses getattr(), so a simple <TAB> keypress is still |
|
985 | readline uses getattr(), so a simple <TAB> keypress is still | |
963 | enough to trigger getattr() calls on an object. |
|
986 | enough to trigger getattr() calls on an object. | |
964 |
|
987 | |||
965 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
988 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
966 |
|
989 | |||
967 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run |
|
990 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run | |
968 | docstring under pylab so it doesn't mask the original. |
|
991 | docstring under pylab so it doesn't mask the original. | |
969 |
|
992 | |||
970 | 2005-01-21 *** Released version 0.6.7 |
|
993 | 2005-01-21 *** Released version 0.6.7 | |
971 |
|
994 | |||
972 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
995 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
973 |
|
996 | |||
974 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with |
|
997 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with | |
975 | signal handling for win32 users in multithreaded mode. |
|
998 | signal handling for win32 users in multithreaded mode. | |
976 |
|
999 | |||
977 | 2005-01-17 Fernando Perez <fperez@colorado.edu> |
|
1000 | 2005-01-17 Fernando Perez <fperez@colorado.edu> | |
978 |
|
1001 | |||
979 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
1002 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
980 | instances with no __init__. After a crash report by Norbert Nemec |
|
1003 | instances with no __init__. After a crash report by Norbert Nemec | |
981 | <Norbert-AT-nemec-online.de>. |
|
1004 | <Norbert-AT-nemec-online.de>. | |
982 |
|
1005 | |||
983 | 2005-01-14 Fernando Perez <fperez@colorado.edu> |
|
1006 | 2005-01-14 Fernando Perez <fperez@colorado.edu> | |
984 |
|
1007 | |||
985 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of |
|
1008 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of | |
986 | names for verbose exceptions, when multiple dotted names and the |
|
1009 | names for verbose exceptions, when multiple dotted names and the | |
987 | 'parent' object were present on the same line. |
|
1010 | 'parent' object were present on the same line. | |
988 |
|
1011 | |||
989 | 2005-01-11 Fernando Perez <fperez@colorado.edu> |
|
1012 | 2005-01-11 Fernando Perez <fperez@colorado.edu> | |
990 |
|
1013 | |||
991 | * IPython/genutils.py (flag_calls): new utility to trap and flag |
|
1014 | * IPython/genutils.py (flag_calls): new utility to trap and flag | |
992 | calls in functions. I need it to clean up matplotlib support. |
|
1015 | calls in functions. I need it to clean up matplotlib support. | |
993 | Also removed some deprecated code in genutils. |
|
1016 | Also removed some deprecated code in genutils. | |
994 |
|
1017 | |||
995 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so |
|
1018 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so | |
996 | that matplotlib scripts called with %run, which don't call show() |
|
1019 | that matplotlib scripts called with %run, which don't call show() | |
997 | themselves, still have their plotting windows open. |
|
1020 | themselves, still have their plotting windows open. | |
998 |
|
1021 | |||
999 | 2005-01-05 Fernando Perez <fperez@colorado.edu> |
|
1022 | 2005-01-05 Fernando Perez <fperez@colorado.edu> | |
1000 |
|
1023 | |||
1001 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw |
|
1024 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw | |
1002 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. |
|
1025 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. | |
1003 |
|
1026 | |||
1004 | 2004-12-19 Fernando Perez <fperez@colorado.edu> |
|
1027 | 2004-12-19 Fernando Perez <fperez@colorado.edu> | |
1005 |
|
1028 | |||
1006 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of |
|
1029 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of | |
1007 | parent_runcode, which was an eyesore. The same result can be |
|
1030 | parent_runcode, which was an eyesore. The same result can be | |
1008 | obtained with Python's regular superclass mechanisms. |
|
1031 | obtained with Python's regular superclass mechanisms. | |
1009 |
|
1032 | |||
1010 | 2004-12-17 Fernando Perez <fperez@colorado.edu> |
|
1033 | 2004-12-17 Fernando Perez <fperez@colorado.edu> | |
1011 |
|
1034 | |||
1012 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem |
|
1035 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem | |
1013 | reported by Prabhu. |
|
1036 | reported by Prabhu. | |
1014 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to |
|
1037 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to | |
1015 | sys.stderr) instead of explicitly calling sys.stderr. This helps |
|
1038 | sys.stderr) instead of explicitly calling sys.stderr. This helps | |
1016 | maintain our I/O abstractions clean, for future GUI embeddings. |
|
1039 | maintain our I/O abstractions clean, for future GUI embeddings. | |
1017 |
|
1040 | |||
1018 | * IPython/genutils.py (info): added new utility for sys.stderr |
|
1041 | * IPython/genutils.py (info): added new utility for sys.stderr | |
1019 | unified info message handling (thin wrapper around warn()). |
|
1042 | unified info message handling (thin wrapper around warn()). | |
1020 |
|
1043 | |||
1021 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global |
|
1044 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global | |
1022 | composite (dotted) names on verbose exceptions. |
|
1045 | composite (dotted) names on verbose exceptions. | |
1023 | (VerboseTB.nullrepr): harden against another kind of errors which |
|
1046 | (VerboseTB.nullrepr): harden against another kind of errors which | |
1024 | Python's inspect module can trigger, and which were crashing |
|
1047 | Python's inspect module can trigger, and which were crashing | |
1025 | IPython. Thanks to a report by Marco Lombardi |
|
1048 | IPython. Thanks to a report by Marco Lombardi | |
1026 | <mlombard-AT-ma010192.hq.eso.org>. |
|
1049 | <mlombard-AT-ma010192.hq.eso.org>. | |
1027 |
|
1050 | |||
1028 | 2004-12-13 *** Released version 0.6.6 |
|
1051 | 2004-12-13 *** Released version 0.6.6 | |
1029 |
|
1052 | |||
1030 | 2004-12-12 Fernando Perez <fperez@colorado.edu> |
|
1053 | 2004-12-12 Fernando Perez <fperez@colorado.edu> | |
1031 |
|
1054 | |||
1032 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors |
|
1055 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors | |
1033 | generated by pygtk upon initialization if it was built without |
|
1056 | generated by pygtk upon initialization if it was built without | |
1034 | threads (for matplotlib users). After a crash reported by |
|
1057 | threads (for matplotlib users). After a crash reported by | |
1035 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. |
|
1058 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. | |
1036 |
|
1059 | |||
1037 | * IPython/ipmaker.py (make_IPython): fix small bug in the |
|
1060 | * IPython/ipmaker.py (make_IPython): fix small bug in the | |
1038 | import_some parameter for multiple imports. |
|
1061 | import_some parameter for multiple imports. | |
1039 |
|
1062 | |||
1040 | * IPython/iplib.py (ipmagic): simplified the interface of |
|
1063 | * IPython/iplib.py (ipmagic): simplified the interface of | |
1041 | ipmagic() to take a single string argument, just as it would be |
|
1064 | ipmagic() to take a single string argument, just as it would be | |
1042 | typed at the IPython cmd line. |
|
1065 | typed at the IPython cmd line. | |
1043 | (ipalias): Added new ipalias() with an interface identical to |
|
1066 | (ipalias): Added new ipalias() with an interface identical to | |
1044 | ipmagic(). This completes exposing a pure python interface to the |
|
1067 | ipmagic(). This completes exposing a pure python interface to the | |
1045 | alias and magic system, which can be used in loops or more complex |
|
1068 | alias and magic system, which can be used in loops or more complex | |
1046 | code where IPython's automatic line mangling is not active. |
|
1069 | code where IPython's automatic line mangling is not active. | |
1047 |
|
1070 | |||
1048 | * IPython/genutils.py (timing): changed interface of timing to |
|
1071 | * IPython/genutils.py (timing): changed interface of timing to | |
1049 | simply run code once, which is the most common case. timings() |
|
1072 | simply run code once, which is the most common case. timings() | |
1050 | remains unchanged, for the cases where you want multiple runs. |
|
1073 | remains unchanged, for the cases where you want multiple runs. | |
1051 |
|
1074 | |||
1052 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a |
|
1075 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a | |
1053 | bug where Python2.2 crashes with exec'ing code which does not end |
|
1076 | bug where Python2.2 crashes with exec'ing code which does not end | |
1054 | in a single newline. Python 2.3 is OK, so I hadn't noticed this |
|
1077 | in a single newline. Python 2.3 is OK, so I hadn't noticed this | |
1055 | before. |
|
1078 | before. | |
1056 |
|
1079 | |||
1057 | 2004-12-10 Fernando Perez <fperez@colorado.edu> |
|
1080 | 2004-12-10 Fernando Perez <fperez@colorado.edu> | |
1058 |
|
1081 | |||
1059 | * IPython/Magic.py (Magic.magic_prun): changed name of option from |
|
1082 | * IPython/Magic.py (Magic.magic_prun): changed name of option from | |
1060 | -t to -T, to accomodate the new -t flag in %run (the %run and |
|
1083 | -t to -T, to accomodate the new -t flag in %run (the %run and | |
1061 | %prun options are kind of intermixed, and it's not easy to change |
|
1084 | %prun options are kind of intermixed, and it's not easy to change | |
1062 | this with the limitations of python's getopt). |
|
1085 | this with the limitations of python's getopt). | |
1063 |
|
1086 | |||
1064 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time |
|
1087 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time | |
1065 | the execution of scripts. It's not as fine-tuned as timeit.py, |
|
1088 | the execution of scripts. It's not as fine-tuned as timeit.py, | |
1066 | but it works from inside ipython (and under 2.2, which lacks |
|
1089 | but it works from inside ipython (and under 2.2, which lacks | |
1067 | timeit.py). Optionally a number of runs > 1 can be given for |
|
1090 | timeit.py). Optionally a number of runs > 1 can be given for | |
1068 | timing very short-running code. |
|
1091 | timing very short-running code. | |
1069 |
|
1092 | |||
1070 | * IPython/genutils.py (uniq_stable): new routine which returns a |
|
1093 | * IPython/genutils.py (uniq_stable): new routine which returns a | |
1071 | list of unique elements in any iterable, but in stable order of |
|
1094 | list of unique elements in any iterable, but in stable order of | |
1072 | appearance. I needed this for the ultraTB fixes, and it's a handy |
|
1095 | appearance. I needed this for the ultraTB fixes, and it's a handy | |
1073 | utility. |
|
1096 | utility. | |
1074 |
|
1097 | |||
1075 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of |
|
1098 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of | |
1076 | dotted names in Verbose exceptions. This had been broken since |
|
1099 | dotted names in Verbose exceptions. This had been broken since | |
1077 | the very start, now x.y will properly be printed in a Verbose |
|
1100 | the very start, now x.y will properly be printed in a Verbose | |
1078 | traceback, instead of x being shown and y appearing always as an |
|
1101 | traceback, instead of x being shown and y appearing always as an | |
1079 | 'undefined global'. Getting this to work was a bit tricky, |
|
1102 | 'undefined global'. Getting this to work was a bit tricky, | |
1080 | because by default python tokenizers are stateless. Saved by |
|
1103 | because by default python tokenizers are stateless. Saved by | |
1081 | python's ability to easily add a bit of state to an arbitrary |
|
1104 | python's ability to easily add a bit of state to an arbitrary | |
1082 | function (without needing to build a full-blown callable object). |
|
1105 | function (without needing to build a full-blown callable object). | |
1083 |
|
1106 | |||
1084 | Also big cleanup of this code, which had horrendous runtime |
|
1107 | Also big cleanup of this code, which had horrendous runtime | |
1085 | lookups of zillions of attributes for colorization. Moved all |
|
1108 | lookups of zillions of attributes for colorization. Moved all | |
1086 | this code into a few templates, which make it cleaner and quicker. |
|
1109 | this code into a few templates, which make it cleaner and quicker. | |
1087 |
|
1110 | |||
1088 | Printout quality was also improved for Verbose exceptions: one |
|
1111 | Printout quality was also improved for Verbose exceptions: one | |
1089 | variable per line, and memory addresses are printed (this can be |
|
1112 | variable per line, and memory addresses are printed (this can be | |
1090 | quite handy in nasty debugging situations, which is what Verbose |
|
1113 | quite handy in nasty debugging situations, which is what Verbose | |
1091 | is for). |
|
1114 | is for). | |
1092 |
|
1115 | |||
1093 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in |
|
1116 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in | |
1094 | the command line as scripts to be loaded by embedded instances. |
|
1117 | the command line as scripts to be loaded by embedded instances. | |
1095 | Doing so has the potential for an infinite recursion if there are |
|
1118 | Doing so has the potential for an infinite recursion if there are | |
1096 | exceptions thrown in the process. This fixes a strange crash |
|
1119 | exceptions thrown in the process. This fixes a strange crash | |
1097 | reported by Philippe MULLER <muller-AT-irit.fr>. |
|
1120 | reported by Philippe MULLER <muller-AT-irit.fr>. | |
1098 |
|
1121 | |||
1099 | 2004-12-09 Fernando Perez <fperez@colorado.edu> |
|
1122 | 2004-12-09 Fernando Perez <fperez@colorado.edu> | |
1100 |
|
1123 | |||
1101 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support |
|
1124 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support | |
1102 | to reflect new names in matplotlib, which now expose the |
|
1125 | to reflect new names in matplotlib, which now expose the | |
1103 | matlab-compatible interface via a pylab module instead of the |
|
1126 | matlab-compatible interface via a pylab module instead of the | |
1104 | 'matlab' name. The new code is backwards compatible, so users of |
|
1127 | 'matlab' name. The new code is backwards compatible, so users of | |
1105 | all matplotlib versions are OK. Patch by J. Hunter. |
|
1128 | all matplotlib versions are OK. Patch by J. Hunter. | |
1106 |
|
1129 | |||
1107 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing |
|
1130 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing | |
1108 | of __init__ docstrings for instances (class docstrings are already |
|
1131 | of __init__ docstrings for instances (class docstrings are already | |
1109 | automatically printed). Instances with customized docstrings |
|
1132 | automatically printed). Instances with customized docstrings | |
1110 | (indep. of the class) are also recognized and all 3 separate |
|
1133 | (indep. of the class) are also recognized and all 3 separate | |
1111 | docstrings are printed (instance, class, constructor). After some |
|
1134 | docstrings are printed (instance, class, constructor). After some | |
1112 | comments/suggestions by J. Hunter. |
|
1135 | comments/suggestions by J. Hunter. | |
1113 |
|
1136 | |||
1114 | 2004-12-05 Fernando Perez <fperez@colorado.edu> |
|
1137 | 2004-12-05 Fernando Perez <fperez@colorado.edu> | |
1115 |
|
1138 | |||
1116 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying |
|
1139 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying | |
1117 | warnings when tab-completion fails and triggers an exception. |
|
1140 | warnings when tab-completion fails and triggers an exception. | |
1118 |
|
1141 | |||
1119 | 2004-12-03 Fernando Perez <fperez@colorado.edu> |
|
1142 | 2004-12-03 Fernando Perez <fperez@colorado.edu> | |
1120 |
|
1143 | |||
1121 | * IPython/Magic.py (magic_prun): Fix bug where an exception would |
|
1144 | * IPython/Magic.py (magic_prun): Fix bug where an exception would | |
1122 | be triggered when using 'run -p'. An incorrect option flag was |
|
1145 | be triggered when using 'run -p'. An incorrect option flag was | |
1123 | being set ('d' instead of 'D'). |
|
1146 | being set ('d' instead of 'D'). | |
1124 | (manpage): fix missing escaped \- sign. |
|
1147 | (manpage): fix missing escaped \- sign. | |
1125 |
|
1148 | |||
1126 | 2004-11-30 *** Released version 0.6.5 |
|
1149 | 2004-11-30 *** Released version 0.6.5 | |
1127 |
|
1150 | |||
1128 | 2004-11-30 Fernando Perez <fperez@colorado.edu> |
|
1151 | 2004-11-30 Fernando Perez <fperez@colorado.edu> | |
1129 |
|
1152 | |||
1130 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint |
|
1153 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint | |
1131 | setting with -d option. |
|
1154 | setting with -d option. | |
1132 |
|
1155 | |||
1133 | * setup.py (docfiles): Fix problem where the doc glob I was using |
|
1156 | * setup.py (docfiles): Fix problem where the doc glob I was using | |
1134 | was COMPLETELY BROKEN. It was giving the right files by pure |
|
1157 | was COMPLETELY BROKEN. It was giving the right files by pure | |
1135 | accident, but failed once I tried to include ipython.el. Note: |
|
1158 | accident, but failed once I tried to include ipython.el. Note: | |
1136 | glob() does NOT allow you to do exclusion on multiple endings! |
|
1159 | glob() does NOT allow you to do exclusion on multiple endings! | |
1137 |
|
1160 | |||
1138 | 2004-11-29 Fernando Perez <fperez@colorado.edu> |
|
1161 | 2004-11-29 Fernando Perez <fperez@colorado.edu> | |
1139 |
|
1162 | |||
1140 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using |
|
1163 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using | |
1141 | the manpage as the source. Better formatting & consistency. |
|
1164 | the manpage as the source. Better formatting & consistency. | |
1142 |
|
1165 | |||
1143 | * IPython/Magic.py (magic_run): Added new -d option, to run |
|
1166 | * IPython/Magic.py (magic_run): Added new -d option, to run | |
1144 | scripts under the control of the python pdb debugger. Note that |
|
1167 | scripts under the control of the python pdb debugger. Note that | |
1145 | this required changing the %prun option -d to -D, to avoid a clash |
|
1168 | this required changing the %prun option -d to -D, to avoid a clash | |
1146 | (since %run must pass options to %prun, and getopt is too dumb to |
|
1169 | (since %run must pass options to %prun, and getopt is too dumb to | |
1147 | handle options with string values with embedded spaces). Thanks |
|
1170 | handle options with string values with embedded spaces). Thanks | |
1148 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. |
|
1171 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. | |
1149 | (magic_who_ls): added type matching to %who and %whos, so that one |
|
1172 | (magic_who_ls): added type matching to %who and %whos, so that one | |
1150 | can filter their output to only include variables of certain |
|
1173 | can filter their output to only include variables of certain | |
1151 | types. Another suggestion by Matthew. |
|
1174 | types. Another suggestion by Matthew. | |
1152 | (magic_whos): Added memory summaries in kb and Mb for arrays. |
|
1175 | (magic_whos): Added memory summaries in kb and Mb for arrays. | |
1153 | (magic_who): Improve formatting (break lines every 9 vars). |
|
1176 | (magic_who): Improve formatting (break lines every 9 vars). | |
1154 |
|
1177 | |||
1155 | 2004-11-28 Fernando Perez <fperez@colorado.edu> |
|
1178 | 2004-11-28 Fernando Perez <fperez@colorado.edu> | |
1156 |
|
1179 | |||
1157 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input |
|
1180 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input | |
1158 | cache when empty lines were present. |
|
1181 | cache when empty lines were present. | |
1159 |
|
1182 | |||
1160 | 2004-11-24 Fernando Perez <fperez@colorado.edu> |
|
1183 | 2004-11-24 Fernando Perez <fperez@colorado.edu> | |
1161 |
|
1184 | |||
1162 | * IPython/usage.py (__doc__): document the re-activated threading |
|
1185 | * IPython/usage.py (__doc__): document the re-activated threading | |
1163 | options for WX and GTK. |
|
1186 | options for WX and GTK. | |
1164 |
|
1187 | |||
1165 | 2004-11-23 Fernando Perez <fperez@colorado.edu> |
|
1188 | 2004-11-23 Fernando Perez <fperez@colorado.edu> | |
1166 |
|
1189 | |||
1167 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate |
|
1190 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate | |
1168 | the -wthread and -gthread options, along with a new -tk one to try |
|
1191 | the -wthread and -gthread options, along with a new -tk one to try | |
1169 | and coordinate Tk threading with wx/gtk. The tk support is very |
|
1192 | and coordinate Tk threading with wx/gtk. The tk support is very | |
1170 | platform dependent, since it seems to require Tcl and Tk to be |
|
1193 | platform dependent, since it seems to require Tcl and Tk to be | |
1171 | built with threads (Fedora1/2 appears NOT to have it, but in |
|
1194 | built with threads (Fedora1/2 appears NOT to have it, but in | |
1172 | Prabhu's Debian boxes it works OK). But even with some Tk |
|
1195 | Prabhu's Debian boxes it works OK). But even with some Tk | |
1173 | limitations, this is a great improvement. |
|
1196 | limitations, this is a great improvement. | |
1174 |
|
1197 | |||
1175 | * IPython/Prompts.py (prompt_specials_color): Added \t for time |
|
1198 | * IPython/Prompts.py (prompt_specials_color): Added \t for time | |
1176 | info in user prompts. Patch by Prabhu. |
|
1199 | info in user prompts. Patch by Prabhu. | |
1177 |
|
1200 | |||
1178 | 2004-11-18 Fernando Perez <fperez@colorado.edu> |
|
1201 | 2004-11-18 Fernando Perez <fperez@colorado.edu> | |
1179 |
|
1202 | |||
1180 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 |
|
1203 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 | |
1181 | EOFErrors and bail, to avoid infinite loops if a non-terminating |
|
1204 | EOFErrors and bail, to avoid infinite loops if a non-terminating | |
1182 | file is fed into ipython. Patch submitted in issue 19 by user, |
|
1205 | file is fed into ipython. Patch submitted in issue 19 by user, | |
1183 | many thanks. |
|
1206 | many thanks. | |
1184 |
|
1207 | |||
1185 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger |
|
1208 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger | |
1186 | autoquote/parens in continuation prompts, which can cause lots of |
|
1209 | autoquote/parens in continuation prompts, which can cause lots of | |
1187 | problems. Closes roundup issue 20. |
|
1210 | problems. Closes roundup issue 20. | |
1188 |
|
1211 | |||
1189 | 2004-11-17 Fernando Perez <fperez@colorado.edu> |
|
1212 | 2004-11-17 Fernando Perez <fperez@colorado.edu> | |
1190 |
|
1213 | |||
1191 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, |
|
1214 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, | |
1192 | reported as debian bug #280505. I'm not sure my local changelog |
|
1215 | reported as debian bug #280505. I'm not sure my local changelog | |
1193 | entry has the proper debian format (Jack?). |
|
1216 | entry has the proper debian format (Jack?). | |
1194 |
|
1217 | |||
1195 | 2004-11-08 *** Released version 0.6.4 |
|
1218 | 2004-11-08 *** Released version 0.6.4 | |
1196 |
|
1219 | |||
1197 | 2004-11-08 Fernando Perez <fperez@colorado.edu> |
|
1220 | 2004-11-08 Fernando Perez <fperez@colorado.edu> | |
1198 |
|
1221 | |||
1199 | * IPython/iplib.py (init_readline): Fix exit message for Windows |
|
1222 | * IPython/iplib.py (init_readline): Fix exit message for Windows | |
1200 | when readline is active. Thanks to a report by Eric Jones |
|
1223 | when readline is active. Thanks to a report by Eric Jones | |
1201 | <eric-AT-enthought.com>. |
|
1224 | <eric-AT-enthought.com>. | |
1202 |
|
1225 | |||
1203 | 2004-11-07 Fernando Perez <fperez@colorado.edu> |
|
1226 | 2004-11-07 Fernando Perez <fperez@colorado.edu> | |
1204 |
|
1227 | |||
1205 | * IPython/genutils.py (page): Add a trap for OSError exceptions, |
|
1228 | * IPython/genutils.py (page): Add a trap for OSError exceptions, | |
1206 | sometimes seen by win2k/cygwin users. |
|
1229 | sometimes seen by win2k/cygwin users. | |
1207 |
|
1230 | |||
1208 | 2004-11-06 Fernando Perez <fperez@colorado.edu> |
|
1231 | 2004-11-06 Fernando Perez <fperez@colorado.edu> | |
1209 |
|
1232 | |||
1210 | * IPython/iplib.py (interact): Change the handling of %Exit from |
|
1233 | * IPython/iplib.py (interact): Change the handling of %Exit from | |
1211 | trying to propagate a SystemExit to an internal ipython flag. |
|
1234 | trying to propagate a SystemExit to an internal ipython flag. | |
1212 | This is less elegant than using Python's exception mechanism, but |
|
1235 | This is less elegant than using Python's exception mechanism, but | |
1213 | I can't get that to work reliably with threads, so under -pylab |
|
1236 | I can't get that to work reliably with threads, so under -pylab | |
1214 | %Exit was hanging IPython. Cross-thread exception handling is |
|
1237 | %Exit was hanging IPython. Cross-thread exception handling is | |
1215 | really a bitch. Thaks to a bug report by Stephen Walton |
|
1238 | really a bitch. Thaks to a bug report by Stephen Walton | |
1216 | <stephen.walton-AT-csun.edu>. |
|
1239 | <stephen.walton-AT-csun.edu>. | |
1217 |
|
1240 | |||
1218 | 2004-11-04 Fernando Perez <fperez@colorado.edu> |
|
1241 | 2004-11-04 Fernando Perez <fperez@colorado.edu> | |
1219 |
|
1242 | |||
1220 | * IPython/iplib.py (raw_input_original): store a pointer to the |
|
1243 | * IPython/iplib.py (raw_input_original): store a pointer to the | |
1221 | true raw_input to harden against code which can modify it |
|
1244 | true raw_input to harden against code which can modify it | |
1222 | (wx.py.PyShell does this and would otherwise crash ipython). |
|
1245 | (wx.py.PyShell does this and would otherwise crash ipython). | |
1223 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. |
|
1246 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. | |
1224 |
|
1247 | |||
1225 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for |
|
1248 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for | |
1226 | Ctrl-C problem, which does not mess up the input line. |
|
1249 | Ctrl-C problem, which does not mess up the input line. | |
1227 |
|
1250 | |||
1228 | 2004-11-03 Fernando Perez <fperez@colorado.edu> |
|
1251 | 2004-11-03 Fernando Perez <fperez@colorado.edu> | |
1229 |
|
1252 | |||
1230 | * IPython/Release.py: Changed licensing to BSD, in all files. |
|
1253 | * IPython/Release.py: Changed licensing to BSD, in all files. | |
1231 | (name): lowercase name for tarball/RPM release. |
|
1254 | (name): lowercase name for tarball/RPM release. | |
1232 |
|
1255 | |||
1233 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for |
|
1256 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for | |
1234 | use throughout ipython. |
|
1257 | use throughout ipython. | |
1235 |
|
1258 | |||
1236 | * IPython/Magic.py (Magic._ofind): Switch to using the new |
|
1259 | * IPython/Magic.py (Magic._ofind): Switch to using the new | |
1237 | OInspect.getdoc() function. |
|
1260 | OInspect.getdoc() function. | |
1238 |
|
1261 | |||
1239 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution |
|
1262 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution | |
1240 | of the line currently being canceled via Ctrl-C. It's extremely |
|
1263 | of the line currently being canceled via Ctrl-C. It's extremely | |
1241 | ugly, but I don't know how to do it better (the problem is one of |
|
1264 | ugly, but I don't know how to do it better (the problem is one of | |
1242 | handling cross-thread exceptions). |
|
1265 | handling cross-thread exceptions). | |
1243 |
|
1266 | |||
1244 | 2004-10-28 Fernando Perez <fperez@colorado.edu> |
|
1267 | 2004-10-28 Fernando Perez <fperez@colorado.edu> | |
1245 |
|
1268 | |||
1246 | * IPython/Shell.py (signal_handler): add signal handlers to trap |
|
1269 | * IPython/Shell.py (signal_handler): add signal handlers to trap | |
1247 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug |
|
1270 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug | |
1248 | report by Francesc Alted. |
|
1271 | report by Francesc Alted. | |
1249 |
|
1272 | |||
1250 | 2004-10-21 Fernando Perez <fperez@colorado.edu> |
|
1273 | 2004-10-21 Fernando Perez <fperez@colorado.edu> | |
1251 |
|
1274 | |||
1252 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ |
|
1275 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ | |
1253 | to % for pysh syntax extensions. |
|
1276 | to % for pysh syntax extensions. | |
1254 |
|
1277 | |||
1255 | 2004-10-09 Fernando Perez <fperez@colorado.edu> |
|
1278 | 2004-10-09 Fernando Perez <fperez@colorado.edu> | |
1256 |
|
1279 | |||
1257 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric |
|
1280 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric | |
1258 | arrays to print a more useful summary, without calling str(arr). |
|
1281 | arrays to print a more useful summary, without calling str(arr). | |
1259 | This avoids the problem of extremely lengthy computations which |
|
1282 | This avoids the problem of extremely lengthy computations which | |
1260 | occur if arr is large, and appear to the user as a system lockup |
|
1283 | occur if arr is large, and appear to the user as a system lockup | |
1261 | with 100% cpu activity. After a suggestion by Kristian Sandberg |
|
1284 | with 100% cpu activity. After a suggestion by Kristian Sandberg | |
1262 | <Kristian.Sandberg@colorado.edu>. |
|
1285 | <Kristian.Sandberg@colorado.edu>. | |
1263 | (Magic.__init__): fix bug in global magic escapes not being |
|
1286 | (Magic.__init__): fix bug in global magic escapes not being | |
1264 | correctly set. |
|
1287 | correctly set. | |
1265 |
|
1288 | |||
1266 | 2004-10-08 Fernando Perez <fperez@colorado.edu> |
|
1289 | 2004-10-08 Fernando Perez <fperez@colorado.edu> | |
1267 |
|
1290 | |||
1268 | * IPython/Magic.py (__license__): change to absolute imports of |
|
1291 | * IPython/Magic.py (__license__): change to absolute imports of | |
1269 | ipython's own internal packages, to start adapting to the absolute |
|
1292 | ipython's own internal packages, to start adapting to the absolute | |
1270 | import requirement of PEP-328. |
|
1293 | import requirement of PEP-328. | |
1271 |
|
1294 | |||
1272 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all |
|
1295 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all | |
1273 | files, and standardize author/license marks through the Release |
|
1296 | files, and standardize author/license marks through the Release | |
1274 | module instead of having per/file stuff (except for files with |
|
1297 | module instead of having per/file stuff (except for files with | |
1275 | particular licenses, like the MIT/PSF-licensed codes). |
|
1298 | particular licenses, like the MIT/PSF-licensed codes). | |
1276 |
|
1299 | |||
1277 | * IPython/Debugger.py: remove dead code for python 2.1 |
|
1300 | * IPython/Debugger.py: remove dead code for python 2.1 | |
1278 |
|
1301 | |||
1279 | 2004-10-04 Fernando Perez <fperez@colorado.edu> |
|
1302 | 2004-10-04 Fernando Perez <fperez@colorado.edu> | |
1280 |
|
1303 | |||
1281 | * IPython/iplib.py (ipmagic): New function for accessing magics |
|
1304 | * IPython/iplib.py (ipmagic): New function for accessing magics | |
1282 | via a normal python function call. |
|
1305 | via a normal python function call. | |
1283 |
|
1306 | |||
1284 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape |
|
1307 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape | |
1285 | from '@' to '%', to accomodate the new @decorator syntax of python |
|
1308 | from '@' to '%', to accomodate the new @decorator syntax of python | |
1286 | 2.4. |
|
1309 | 2.4. | |
1287 |
|
1310 | |||
1288 | 2004-09-29 Fernando Perez <fperez@colorado.edu> |
|
1311 | 2004-09-29 Fernando Perez <fperez@colorado.edu> | |
1289 |
|
1312 | |||
1290 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to |
|
1313 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to | |
1291 | matplotlib.use to prevent running scripts which try to switch |
|
1314 | matplotlib.use to prevent running scripts which try to switch | |
1292 | interactive backends from within ipython. This will just crash |
|
1315 | interactive backends from within ipython. This will just crash | |
1293 | the python interpreter, so we can't allow it (but a detailed error |
|
1316 | the python interpreter, so we can't allow it (but a detailed error | |
1294 | is given to the user). |
|
1317 | is given to the user). | |
1295 |
|
1318 | |||
1296 | 2004-09-28 Fernando Perez <fperez@colorado.edu> |
|
1319 | 2004-09-28 Fernando Perez <fperez@colorado.edu> | |
1297 |
|
1320 | |||
1298 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): |
|
1321 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): | |
1299 | matplotlib-related fixes so that using @run with non-matplotlib |
|
1322 | matplotlib-related fixes so that using @run with non-matplotlib | |
1300 | scripts doesn't pop up spurious plot windows. This requires |
|
1323 | scripts doesn't pop up spurious plot windows. This requires | |
1301 | matplotlib >= 0.63, where I had to make some changes as well. |
|
1324 | matplotlib >= 0.63, where I had to make some changes as well. | |
1302 |
|
1325 | |||
1303 | * IPython/ipmaker.py (make_IPython): update version requirement to |
|
1326 | * IPython/ipmaker.py (make_IPython): update version requirement to | |
1304 | python 2.2. |
|
1327 | python 2.2. | |
1305 |
|
1328 | |||
1306 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional |
|
1329 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional | |
1307 | banner arg for embedded customization. |
|
1330 | banner arg for embedded customization. | |
1308 |
|
1331 | |||
1309 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all |
|
1332 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all | |
1310 | explicit uses of __IP as the IPython's instance name. Now things |
|
1333 | explicit uses of __IP as the IPython's instance name. Now things | |
1311 | are properly handled via the shell.name value. The actual code |
|
1334 | are properly handled via the shell.name value. The actual code | |
1312 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this |
|
1335 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this | |
1313 | is much better than before. I'll clean things completely when the |
|
1336 | is much better than before. I'll clean things completely when the | |
1314 | magic stuff gets a real overhaul. |
|
1337 | magic stuff gets a real overhaul. | |
1315 |
|
1338 | |||
1316 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in |
|
1339 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in | |
1317 | minor changes to debian dir. |
|
1340 | minor changes to debian dir. | |
1318 |
|
1341 | |||
1319 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a |
|
1342 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a | |
1320 | pointer to the shell itself in the interactive namespace even when |
|
1343 | pointer to the shell itself in the interactive namespace even when | |
1321 | a user-supplied dict is provided. This is needed for embedding |
|
1344 | a user-supplied dict is provided. This is needed for embedding | |
1322 | purposes (found by tests with Michel Sanner). |
|
1345 | purposes (found by tests with Michel Sanner). | |
1323 |
|
1346 | |||
1324 | 2004-09-27 Fernando Perez <fperez@colorado.edu> |
|
1347 | 2004-09-27 Fernando Perez <fperez@colorado.edu> | |
1325 |
|
1348 | |||
1326 | * IPython/UserConfig/ipythonrc: remove []{} from |
|
1349 | * IPython/UserConfig/ipythonrc: remove []{} from | |
1327 | readline_remove_delims, so that things like [modname.<TAB> do |
|
1350 | readline_remove_delims, so that things like [modname.<TAB> do | |
1328 | proper completion. This disables [].TAB, but that's a less common |
|
1351 | proper completion. This disables [].TAB, but that's a less common | |
1329 | case than module names in list comprehensions, for example. |
|
1352 | case than module names in list comprehensions, for example. | |
1330 | Thanks to a report by Andrea Riciputi. |
|
1353 | Thanks to a report by Andrea Riciputi. | |
1331 |
|
1354 | |||
1332 | 2004-09-09 Fernando Perez <fperez@colorado.edu> |
|
1355 | 2004-09-09 Fernando Perez <fperez@colorado.edu> | |
1333 |
|
1356 | |||
1334 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid |
|
1357 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid | |
1335 | blocking problems in win32 and osx. Fix by John. |
|
1358 | blocking problems in win32 and osx. Fix by John. | |
1336 |
|
1359 | |||
1337 | 2004-09-08 Fernando Perez <fperez@colorado.edu> |
|
1360 | 2004-09-08 Fernando Perez <fperez@colorado.edu> | |
1338 |
|
1361 | |||
1339 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug |
|
1362 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug | |
1340 | for Win32 and OSX. Fix by John Hunter. |
|
1363 | for Win32 and OSX. Fix by John Hunter. | |
1341 |
|
1364 | |||
1342 | 2004-08-30 *** Released version 0.6.3 |
|
1365 | 2004-08-30 *** Released version 0.6.3 | |
1343 |
|
1366 | |||
1344 | 2004-08-30 Fernando Perez <fperez@colorado.edu> |
|
1367 | 2004-08-30 Fernando Perez <fperez@colorado.edu> | |
1345 |
|
1368 | |||
1346 | * setup.py (isfile): Add manpages to list of dependent files to be |
|
1369 | * setup.py (isfile): Add manpages to list of dependent files to be | |
1347 | updated. |
|
1370 | updated. | |
1348 |
|
1371 | |||
1349 | 2004-08-27 Fernando Perez <fperez@colorado.edu> |
|
1372 | 2004-08-27 Fernando Perez <fperez@colorado.edu> | |
1350 |
|
1373 | |||
1351 | * IPython/Shell.py (start): I've disabled -wthread and -gthread |
|
1374 | * IPython/Shell.py (start): I've disabled -wthread and -gthread | |
1352 | for now. They don't really work with standalone WX/GTK code |
|
1375 | for now. They don't really work with standalone WX/GTK code | |
1353 | (though matplotlib IS working fine with both of those backends). |
|
1376 | (though matplotlib IS working fine with both of those backends). | |
1354 | This will neeed much more testing. I disabled most things with |
|
1377 | This will neeed much more testing. I disabled most things with | |
1355 | comments, so turning it back on later should be pretty easy. |
|
1378 | comments, so turning it back on later should be pretty easy. | |
1356 |
|
1379 | |||
1357 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental |
|
1380 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental | |
1358 | autocalling of expressions like r'foo', by modifying the line |
|
1381 | autocalling of expressions like r'foo', by modifying the line | |
1359 | split regexp. Closes |
|
1382 | split regexp. Closes | |
1360 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas |
|
1383 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas | |
1361 | Riley <ipythonbugs-AT-sabi.net>. |
|
1384 | Riley <ipythonbugs-AT-sabi.net>. | |
1362 | (InteractiveShell.mainloop): honor --nobanner with banner |
|
1385 | (InteractiveShell.mainloop): honor --nobanner with banner | |
1363 | extensions. |
|
1386 | extensions. | |
1364 |
|
1387 | |||
1365 | * IPython/Shell.py: Significant refactoring of all classes, so |
|
1388 | * IPython/Shell.py: Significant refactoring of all classes, so | |
1366 | that we can really support ALL matplotlib backends and threading |
|
1389 | that we can really support ALL matplotlib backends and threading | |
1367 | models (John spotted a bug with Tk which required this). Now we |
|
1390 | models (John spotted a bug with Tk which required this). Now we | |
1368 | should support single-threaded, WX-threads and GTK-threads, both |
|
1391 | should support single-threaded, WX-threads and GTK-threads, both | |
1369 | for generic code and for matplotlib. |
|
1392 | for generic code and for matplotlib. | |
1370 |
|
1393 | |||
1371 | * IPython/ipmaker.py (__call__): Changed -mpthread option to |
|
1394 | * IPython/ipmaker.py (__call__): Changed -mpthread option to | |
1372 | -pylab, to simplify things for users. Will also remove the pylab |
|
1395 | -pylab, to simplify things for users. Will also remove the pylab | |
1373 | profile, since now all of matplotlib configuration is directly |
|
1396 | profile, since now all of matplotlib configuration is directly | |
1374 | handled here. This also reduces startup time. |
|
1397 | handled here. This also reduces startup time. | |
1375 |
|
1398 | |||
1376 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of |
|
1399 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of | |
1377 | shell wasn't being correctly called. Also in IPShellWX. |
|
1400 | shell wasn't being correctly called. Also in IPShellWX. | |
1378 |
|
1401 | |||
1379 | * IPython/iplib.py (InteractiveShell.__init__): Added option to |
|
1402 | * IPython/iplib.py (InteractiveShell.__init__): Added option to | |
1380 | fine-tune banner. |
|
1403 | fine-tune banner. | |
1381 |
|
1404 | |||
1382 | * IPython/numutils.py (spike): Deprecate these spike functions, |
|
1405 | * IPython/numutils.py (spike): Deprecate these spike functions, | |
1383 | delete (long deprecated) gnuplot_exec handler. |
|
1406 | delete (long deprecated) gnuplot_exec handler. | |
1384 |
|
1407 | |||
1385 | 2004-08-26 Fernando Perez <fperez@colorado.edu> |
|
1408 | 2004-08-26 Fernando Perez <fperez@colorado.edu> | |
1386 |
|
1409 | |||
1387 | * ipython.1: Update for threading options, plus some others which |
|
1410 | * ipython.1: Update for threading options, plus some others which | |
1388 | were missing. |
|
1411 | were missing. | |
1389 |
|
1412 | |||
1390 | * IPython/ipmaker.py (__call__): Added -wthread option for |
|
1413 | * IPython/ipmaker.py (__call__): Added -wthread option for | |
1391 | wxpython thread handling. Make sure threading options are only |
|
1414 | wxpython thread handling. Make sure threading options are only | |
1392 | valid at the command line. |
|
1415 | valid at the command line. | |
1393 |
|
1416 | |||
1394 | * scripts/ipython: moved shell selection into a factory function |
|
1417 | * scripts/ipython: moved shell selection into a factory function | |
1395 | in Shell.py, to keep the starter script to a minimum. |
|
1418 | in Shell.py, to keep the starter script to a minimum. | |
1396 |
|
1419 | |||
1397 | 2004-08-25 Fernando Perez <fperez@colorado.edu> |
|
1420 | 2004-08-25 Fernando Perez <fperez@colorado.edu> | |
1398 |
|
1421 | |||
1399 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by |
|
1422 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by | |
1400 | John. Along with some recent changes he made to matplotlib, the |
|
1423 | John. Along with some recent changes he made to matplotlib, the | |
1401 | next versions of both systems should work very well together. |
|
1424 | next versions of both systems should work very well together. | |
1402 |
|
1425 | |||
1403 | 2004-08-24 Fernando Perez <fperez@colorado.edu> |
|
1426 | 2004-08-24 Fernando Perez <fperez@colorado.edu> | |
1404 |
|
1427 | |||
1405 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I |
|
1428 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I | |
1406 | tried to switch the profiling to using hotshot, but I'm getting |
|
1429 | tried to switch the profiling to using hotshot, but I'm getting | |
1407 | strange errors from prof.runctx() there. I may be misreading the |
|
1430 | strange errors from prof.runctx() there. I may be misreading the | |
1408 | docs, but it looks weird. For now the profiling code will |
|
1431 | docs, but it looks weird. For now the profiling code will | |
1409 | continue to use the standard profiler. |
|
1432 | continue to use the standard profiler. | |
1410 |
|
1433 | |||
1411 | 2004-08-23 Fernando Perez <fperez@colorado.edu> |
|
1434 | 2004-08-23 Fernando Perez <fperez@colorado.edu> | |
1412 |
|
1435 | |||
1413 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX |
|
1436 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX | |
1414 | threaded shell, by John Hunter. It's not quite ready yet, but |
|
1437 | threaded shell, by John Hunter. It's not quite ready yet, but | |
1415 | close. |
|
1438 | close. | |
1416 |
|
1439 | |||
1417 | 2004-08-22 Fernando Perez <fperez@colorado.edu> |
|
1440 | 2004-08-22 Fernando Perez <fperez@colorado.edu> | |
1418 |
|
1441 | |||
1419 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also |
|
1442 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also | |
1420 | in Magic and ultraTB. |
|
1443 | in Magic and ultraTB. | |
1421 |
|
1444 | |||
1422 | * ipython.1: document threading options in manpage. |
|
1445 | * ipython.1: document threading options in manpage. | |
1423 |
|
1446 | |||
1424 | * scripts/ipython: Changed name of -thread option to -gthread, |
|
1447 | * scripts/ipython: Changed name of -thread option to -gthread, | |
1425 | since this is GTK specific. I want to leave the door open for a |
|
1448 | since this is GTK specific. I want to leave the door open for a | |
1426 | -wthread option for WX, which will most likely be necessary. This |
|
1449 | -wthread option for WX, which will most likely be necessary. This | |
1427 | change affects usage and ipmaker as well. |
|
1450 | change affects usage and ipmaker as well. | |
1428 |
|
1451 | |||
1429 | * IPython/Shell.py (matplotlib_shell): Add a factory function to |
|
1452 | * IPython/Shell.py (matplotlib_shell): Add a factory function to | |
1430 | handle the matplotlib shell issues. Code by John Hunter |
|
1453 | handle the matplotlib shell issues. Code by John Hunter | |
1431 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
1454 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
1432 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's |
|
1455 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's | |
1433 | broken (and disabled for end users) for now, but it puts the |
|
1456 | broken (and disabled for end users) for now, but it puts the | |
1434 | infrastructure in place. |
|
1457 | infrastructure in place. | |
1435 |
|
1458 | |||
1436 | 2004-08-21 Fernando Perez <fperez@colorado.edu> |
|
1459 | 2004-08-21 Fernando Perez <fperez@colorado.edu> | |
1437 |
|
1460 | |||
1438 | * ipythonrc-pylab: Add matplotlib support. |
|
1461 | * ipythonrc-pylab: Add matplotlib support. | |
1439 |
|
1462 | |||
1440 | * matplotlib_config.py: new files for matplotlib support, part of |
|
1463 | * matplotlib_config.py: new files for matplotlib support, part of | |
1441 | the pylab profile. |
|
1464 | the pylab profile. | |
1442 |
|
1465 | |||
1443 | * IPython/usage.py (__doc__): documented the threading options. |
|
1466 | * IPython/usage.py (__doc__): documented the threading options. | |
1444 |
|
1467 | |||
1445 | 2004-08-20 Fernando Perez <fperez@colorado.edu> |
|
1468 | 2004-08-20 Fernando Perez <fperez@colorado.edu> | |
1446 |
|
1469 | |||
1447 | * ipython: Modified the main calling routine to handle the -thread |
|
1470 | * ipython: Modified the main calling routine to handle the -thread | |
1448 | and -mpthread options. This needs to be done as a top-level hack, |
|
1471 | and -mpthread options. This needs to be done as a top-level hack, | |
1449 | because it determines which class to instantiate for IPython |
|
1472 | because it determines which class to instantiate for IPython | |
1450 | itself. |
|
1473 | itself. | |
1451 |
|
1474 | |||
1452 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of |
|
1475 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of | |
1453 | classes to support multithreaded GTK operation without blocking, |
|
1476 | classes to support multithreaded GTK operation without blocking, | |
1454 | and matplotlib with all backends. This is a lot of still very |
|
1477 | and matplotlib with all backends. This is a lot of still very | |
1455 | experimental code, and threads are tricky. So it may still have a |
|
1478 | experimental code, and threads are tricky. So it may still have a | |
1456 | few rough edges... This code owes a lot to |
|
1479 | few rough edges... This code owes a lot to | |
1457 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by |
|
1480 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by | |
1458 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and |
|
1481 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and | |
1459 | to John Hunter for all the matplotlib work. |
|
1482 | to John Hunter for all the matplotlib work. | |
1460 |
|
1483 | |||
1461 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread |
|
1484 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread | |
1462 | options for gtk thread and matplotlib support. |
|
1485 | options for gtk thread and matplotlib support. | |
1463 |
|
1486 | |||
1464 | 2004-08-16 Fernando Perez <fperez@colorado.edu> |
|
1487 | 2004-08-16 Fernando Perez <fperez@colorado.edu> | |
1465 |
|
1488 | |||
1466 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger |
|
1489 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger | |
1467 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug |
|
1490 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug | |
1468 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. |
|
1491 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. | |
1469 |
|
1492 | |||
1470 | 2004-08-11 Fernando Perez <fperez@colorado.edu> |
|
1493 | 2004-08-11 Fernando Perez <fperez@colorado.edu> | |
1471 |
|
1494 | |||
1472 | * setup.py (isfile): Fix build so documentation gets updated for |
|
1495 | * setup.py (isfile): Fix build so documentation gets updated for | |
1473 | rpms (it was only done for .tgz builds). |
|
1496 | rpms (it was only done for .tgz builds). | |
1474 |
|
1497 | |||
1475 | 2004-08-10 Fernando Perez <fperez@colorado.edu> |
|
1498 | 2004-08-10 Fernando Perez <fperez@colorado.edu> | |
1476 |
|
1499 | |||
1477 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). |
|
1500 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). | |
1478 |
|
1501 | |||
1479 | * iplib.py : Silence syntax error exceptions in tab-completion. |
|
1502 | * iplib.py : Silence syntax error exceptions in tab-completion. | |
1480 |
|
1503 | |||
1481 | 2004-08-05 Fernando Perez <fperez@colorado.edu> |
|
1504 | 2004-08-05 Fernando Perez <fperez@colorado.edu> | |
1482 |
|
1505 | |||
1483 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set |
|
1506 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set | |
1484 | 'color off' mark for continuation prompts. This was causing long |
|
1507 | 'color off' mark for continuation prompts. This was causing long | |
1485 | continuation lines to mis-wrap. |
|
1508 | continuation lines to mis-wrap. | |
1486 |
|
1509 | |||
1487 | 2004-08-01 Fernando Perez <fperez@colorado.edu> |
|
1510 | 2004-08-01 Fernando Perez <fperez@colorado.edu> | |
1488 |
|
1511 | |||
1489 | * IPython/ipmaker.py (make_IPython): Allow the shell class used |
|
1512 | * IPython/ipmaker.py (make_IPython): Allow the shell class used | |
1490 | for building ipython to be a parameter. All this is necessary |
|
1513 | for building ipython to be a parameter. All this is necessary | |
1491 | right now to have a multithreaded version, but this insane |
|
1514 | right now to have a multithreaded version, but this insane | |
1492 | non-design will be cleaned up soon. For now, it's a hack that |
|
1515 | non-design will be cleaned up soon. For now, it's a hack that | |
1493 | works. |
|
1516 | works. | |
1494 |
|
1517 | |||
1495 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default |
|
1518 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default | |
1496 | args in various places. No bugs so far, but it's a dangerous |
|
1519 | args in various places. No bugs so far, but it's a dangerous | |
1497 | practice. |
|
1520 | practice. | |
1498 |
|
1521 | |||
1499 | 2004-07-31 Fernando Perez <fperez@colorado.edu> |
|
1522 | 2004-07-31 Fernando Perez <fperez@colorado.edu> | |
1500 |
|
1523 | |||
1501 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to |
|
1524 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to | |
1502 | fix completion of files with dots in their names under most |
|
1525 | fix completion of files with dots in their names under most | |
1503 | profiles (pysh was OK because the completion order is different). |
|
1526 | profiles (pysh was OK because the completion order is different). | |
1504 |
|
1527 | |||
1505 | 2004-07-27 Fernando Perez <fperez@colorado.edu> |
|
1528 | 2004-07-27 Fernando Perez <fperez@colorado.edu> | |
1506 |
|
1529 | |||
1507 | * IPython/iplib.py (InteractiveShell.__init__): build dict of |
|
1530 | * IPython/iplib.py (InteractiveShell.__init__): build dict of | |
1508 | keywords manually, b/c the one in keyword.py was removed in python |
|
1531 | keywords manually, b/c the one in keyword.py was removed in python | |
1509 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. |
|
1532 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. | |
1510 | This is NOT a bug under python 2.3 and earlier. |
|
1533 | This is NOT a bug under python 2.3 and earlier. | |
1511 |
|
1534 | |||
1512 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1535 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1513 |
|
1536 | |||
1514 | * IPython/ultraTB.py (VerboseTB.text): Add another |
|
1537 | * IPython/ultraTB.py (VerboseTB.text): Add another | |
1515 | linecache.checkcache() call to try to prevent inspect.py from |
|
1538 | linecache.checkcache() call to try to prevent inspect.py from | |
1516 | crashing under python 2.3. I think this fixes |
|
1539 | crashing under python 2.3. I think this fixes | |
1517 | http://www.scipy.net/roundup/ipython/issue17. |
|
1540 | http://www.scipy.net/roundup/ipython/issue17. | |
1518 |
|
1541 | |||
1519 | 2004-07-26 *** Released version 0.6.2 |
|
1542 | 2004-07-26 *** Released version 0.6.2 | |
1520 |
|
1543 | |||
1521 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1544 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1522 |
|
1545 | |||
1523 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would |
|
1546 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would | |
1524 | fail for any number. |
|
1547 | fail for any number. | |
1525 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for |
|
1548 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for | |
1526 | empty bookmarks. |
|
1549 | empty bookmarks. | |
1527 |
|
1550 | |||
1528 | 2004-07-26 *** Released version 0.6.1 |
|
1551 | 2004-07-26 *** Released version 0.6.1 | |
1529 |
|
1552 | |||
1530 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1553 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1531 |
|
1554 | |||
1532 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. |
|
1555 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. | |
1533 |
|
1556 | |||
1534 | * IPython/iplib.py (protect_filename): Applied Ville's patch for |
|
1557 | * IPython/iplib.py (protect_filename): Applied Ville's patch for | |
1535 | escaping '()[]{}' in filenames. |
|
1558 | escaping '()[]{}' in filenames. | |
1536 |
|
1559 | |||
1537 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for |
|
1560 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for | |
1538 | Python 2.2 users who lack a proper shlex.split. |
|
1561 | Python 2.2 users who lack a proper shlex.split. | |
1539 |
|
1562 | |||
1540 | 2004-07-19 Fernando Perez <fperez@colorado.edu> |
|
1563 | 2004-07-19 Fernando Perez <fperez@colorado.edu> | |
1541 |
|
1564 | |||
1542 | * IPython/iplib.py (InteractiveShell.init_readline): Add support |
|
1565 | * IPython/iplib.py (InteractiveShell.init_readline): Add support | |
1543 | for reading readline's init file. I follow the normal chain: |
|
1566 | for reading readline's init file. I follow the normal chain: | |
1544 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a |
|
1567 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a | |
1545 | report by Mike Heeter. This closes |
|
1568 | report by Mike Heeter. This closes | |
1546 | http://www.scipy.net/roundup/ipython/issue16. |
|
1569 | http://www.scipy.net/roundup/ipython/issue16. | |
1547 |
|
1570 | |||
1548 | 2004-07-18 Fernando Perez <fperez@colorado.edu> |
|
1571 | 2004-07-18 Fernando Perez <fperez@colorado.edu> | |
1549 |
|
1572 | |||
1550 | * IPython/iplib.py (__init__): Add better handling of '\' under |
|
1573 | * IPython/iplib.py (__init__): Add better handling of '\' under | |
1551 | Win32 for filenames. After a patch by Ville. |
|
1574 | Win32 for filenames. After a patch by Ville. | |
1552 |
|
1575 | |||
1553 | 2004-07-17 Fernando Perez <fperez@colorado.edu> |
|
1576 | 2004-07-17 Fernando Perez <fperez@colorado.edu> | |
1554 |
|
1577 | |||
1555 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
1578 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
1556 | autocalling would be triggered for 'foo is bar' if foo is |
|
1579 | autocalling would be triggered for 'foo is bar' if foo is | |
1557 | callable. I also cleaned up the autocall detection code to use a |
|
1580 | callable. I also cleaned up the autocall detection code to use a | |
1558 | regexp, which is faster. Bug reported by Alexander Schmolck. |
|
1581 | regexp, which is faster. Bug reported by Alexander Schmolck. | |
1559 |
|
1582 | |||
1560 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with |
|
1583 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with | |
1561 | '?' in them would confuse the help system. Reported by Alex |
|
1584 | '?' in them would confuse the help system. Reported by Alex | |
1562 | Schmolck. |
|
1585 | Schmolck. | |
1563 |
|
1586 | |||
1564 | 2004-07-16 Fernando Perez <fperez@colorado.edu> |
|
1587 | 2004-07-16 Fernando Perez <fperez@colorado.edu> | |
1565 |
|
1588 | |||
1566 | * IPython/GnuplotInteractive.py (__all__): added plot2. |
|
1589 | * IPython/GnuplotInteractive.py (__all__): added plot2. | |
1567 |
|
1590 | |||
1568 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for |
|
1591 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for | |
1569 | plotting dictionaries, lists or tuples of 1d arrays. |
|
1592 | plotting dictionaries, lists or tuples of 1d arrays. | |
1570 |
|
1593 | |||
1571 | * IPython/Magic.py (Magic.magic_hist): small clenaups and |
|
1594 | * IPython/Magic.py (Magic.magic_hist): small clenaups and | |
1572 | optimizations. |
|
1595 | optimizations. | |
1573 |
|
1596 | |||
1574 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is |
|
1597 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is | |
1575 | the information which was there from Janko's original IPP code: |
|
1598 | the information which was there from Janko's original IPP code: | |
1576 |
|
1599 | |||
1577 | 03.05.99 20:53 porto.ifm.uni-kiel.de |
|
1600 | 03.05.99 20:53 porto.ifm.uni-kiel.de | |
1578 | --Started changelog. |
|
1601 | --Started changelog. | |
1579 | --make clear do what it say it does |
|
1602 | --make clear do what it say it does | |
1580 | --added pretty output of lines from inputcache |
|
1603 | --added pretty output of lines from inputcache | |
1581 | --Made Logger a mixin class, simplifies handling of switches |
|
1604 | --Made Logger a mixin class, simplifies handling of switches | |
1582 | --Added own completer class. .string<TAB> expands to last history |
|
1605 | --Added own completer class. .string<TAB> expands to last history | |
1583 | line which starts with string. The new expansion is also present |
|
1606 | line which starts with string. The new expansion is also present | |
1584 | with Ctrl-r from the readline library. But this shows, who this |
|
1607 | with Ctrl-r from the readline library. But this shows, who this | |
1585 | can be done for other cases. |
|
1608 | can be done for other cases. | |
1586 | --Added convention that all shell functions should accept a |
|
1609 | --Added convention that all shell functions should accept a | |
1587 | parameter_string This opens the door for different behaviour for |
|
1610 | parameter_string This opens the door for different behaviour for | |
1588 | each function. @cd is a good example of this. |
|
1611 | each function. @cd is a good example of this. | |
1589 |
|
1612 | |||
1590 | 04.05.99 12:12 porto.ifm.uni-kiel.de |
|
1613 | 04.05.99 12:12 porto.ifm.uni-kiel.de | |
1591 | --added logfile rotation |
|
1614 | --added logfile rotation | |
1592 | --added new mainloop method which freezes first the namespace |
|
1615 | --added new mainloop method which freezes first the namespace | |
1593 |
|
1616 | |||
1594 | 07.05.99 21:24 porto.ifm.uni-kiel.de |
|
1617 | 07.05.99 21:24 porto.ifm.uni-kiel.de | |
1595 | --added the docreader classes. Now there is a help system. |
|
1618 | --added the docreader classes. Now there is a help system. | |
1596 | -This is only a first try. Currently it's not easy to put new |
|
1619 | -This is only a first try. Currently it's not easy to put new | |
1597 | stuff in the indices. But this is the way to go. Info would be |
|
1620 | stuff in the indices. But this is the way to go. Info would be | |
1598 | better, but HTML is every where and not everybody has an info |
|
1621 | better, but HTML is every where and not everybody has an info | |
1599 | system installed and it's not so easy to change html-docs to info. |
|
1622 | system installed and it's not so easy to change html-docs to info. | |
1600 | --added global logfile option |
|
1623 | --added global logfile option | |
1601 | --there is now a hook for object inspection method pinfo needs to |
|
1624 | --there is now a hook for object inspection method pinfo needs to | |
1602 | be provided for this. Can be reached by two '??'. |
|
1625 | be provided for this. Can be reached by two '??'. | |
1603 |
|
1626 | |||
1604 | 08.05.99 20:51 porto.ifm.uni-kiel.de |
|
1627 | 08.05.99 20:51 porto.ifm.uni-kiel.de | |
1605 | --added a README |
|
1628 | --added a README | |
1606 | --bug in rc file. Something has changed so functions in the rc |
|
1629 | --bug in rc file. Something has changed so functions in the rc | |
1607 | file need to reference the shell and not self. Not clear if it's a |
|
1630 | file need to reference the shell and not self. Not clear if it's a | |
1608 | bug or feature. |
|
1631 | bug or feature. | |
1609 | --changed rc file for new behavior |
|
1632 | --changed rc file for new behavior | |
1610 |
|
1633 | |||
1611 | 2004-07-15 Fernando Perez <fperez@colorado.edu> |
|
1634 | 2004-07-15 Fernando Perez <fperez@colorado.edu> | |
1612 |
|
1635 | |||
1613 | * IPython/Logger.py (Logger.log): fixed recent bug where the input |
|
1636 | * IPython/Logger.py (Logger.log): fixed recent bug where the input | |
1614 | cache was falling out of sync in bizarre manners when multi-line |
|
1637 | cache was falling out of sync in bizarre manners when multi-line | |
1615 | input was present. Minor optimizations and cleanup. |
|
1638 | input was present. Minor optimizations and cleanup. | |
1616 |
|
1639 | |||
1617 | (Logger): Remove old Changelog info for cleanup. This is the |
|
1640 | (Logger): Remove old Changelog info for cleanup. This is the | |
1618 | information which was there from Janko's original code: |
|
1641 | information which was there from Janko's original code: | |
1619 |
|
1642 | |||
1620 | Changes to Logger: - made the default log filename a parameter |
|
1643 | Changes to Logger: - made the default log filename a parameter | |
1621 |
|
1644 | |||
1622 | - put a check for lines beginning with !@? in log(). Needed |
|
1645 | - put a check for lines beginning with !@? in log(). Needed | |
1623 | (even if the handlers properly log their lines) for mid-session |
|
1646 | (even if the handlers properly log their lines) for mid-session | |
1624 | logging activation to work properly. Without this, lines logged |
|
1647 | logging activation to work properly. Without this, lines logged | |
1625 | in mid session, which get read from the cache, would end up |
|
1648 | in mid session, which get read from the cache, would end up | |
1626 | 'bare' (with !@? in the open) in the log. Now they are caught |
|
1649 | 'bare' (with !@? in the open) in the log. Now they are caught | |
1627 | and prepended with a #. |
|
1650 | and prepended with a #. | |
1628 |
|
1651 | |||
1629 | * IPython/iplib.py (InteractiveShell.init_readline): added check |
|
1652 | * IPython/iplib.py (InteractiveShell.init_readline): added check | |
1630 | in case MagicCompleter fails to be defined, so we don't crash. |
|
1653 | in case MagicCompleter fails to be defined, so we don't crash. | |
1631 |
|
1654 | |||
1632 | 2004-07-13 Fernando Perez <fperez@colorado.edu> |
|
1655 | 2004-07-13 Fernando Perez <fperez@colorado.edu> | |
1633 |
|
1656 | |||
1634 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation |
|
1657 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation | |
1635 | of EPS if the requested filename ends in '.eps'. |
|
1658 | of EPS if the requested filename ends in '.eps'. | |
1636 |
|
1659 | |||
1637 | 2004-07-04 Fernando Perez <fperez@colorado.edu> |
|
1660 | 2004-07-04 Fernando Perez <fperez@colorado.edu> | |
1638 |
|
1661 | |||
1639 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix |
|
1662 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix | |
1640 | escaping of quotes when calling the shell. |
|
1663 | escaping of quotes when calling the shell. | |
1641 |
|
1664 | |||
1642 | 2004-07-02 Fernando Perez <fperez@colorado.edu> |
|
1665 | 2004-07-02 Fernando Perez <fperez@colorado.edu> | |
1643 |
|
1666 | |||
1644 | * IPython/Prompts.py (CachedOutput.update): Fix problem with |
|
1667 | * IPython/Prompts.py (CachedOutput.update): Fix problem with | |
1645 | gettext not working because we were clobbering '_'. Fixes |
|
1668 | gettext not working because we were clobbering '_'. Fixes | |
1646 | http://www.scipy.net/roundup/ipython/issue6. |
|
1669 | http://www.scipy.net/roundup/ipython/issue6. | |
1647 |
|
1670 | |||
1648 | 2004-07-01 Fernando Perez <fperez@colorado.edu> |
|
1671 | 2004-07-01 Fernando Perez <fperez@colorado.edu> | |
1649 |
|
1672 | |||
1650 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling |
|
1673 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling | |
1651 | into @cd. Patch by Ville. |
|
1674 | into @cd. Patch by Ville. | |
1652 |
|
1675 | |||
1653 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
1676 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
1654 | new function to store things after ipmaker runs. Patch by Ville. |
|
1677 | new function to store things after ipmaker runs. Patch by Ville. | |
1655 | Eventually this will go away once ipmaker is removed and the class |
|
1678 | Eventually this will go away once ipmaker is removed and the class | |
1656 | gets cleaned up, but for now it's ok. Key functionality here is |
|
1679 | gets cleaned up, but for now it's ok. Key functionality here is | |
1657 | the addition of the persistent storage mechanism, a dict for |
|
1680 | the addition of the persistent storage mechanism, a dict for | |
1658 | keeping data across sessions (for now just bookmarks, but more can |
|
1681 | keeping data across sessions (for now just bookmarks, but more can | |
1659 | be implemented later). |
|
1682 | be implemented later). | |
1660 |
|
1683 | |||
1661 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, |
|
1684 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, | |
1662 | persistent across sections. Patch by Ville, I modified it |
|
1685 | persistent across sections. Patch by Ville, I modified it | |
1663 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also |
|
1686 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also | |
1664 | added a '-l' option to list all bookmarks. |
|
1687 | added a '-l' option to list all bookmarks. | |
1665 |
|
1688 | |||
1666 | * IPython/iplib.py (InteractiveShell.atexit_operations): new |
|
1689 | * IPython/iplib.py (InteractiveShell.atexit_operations): new | |
1667 | center for cleanup. Registered with atexit.register(). I moved |
|
1690 | center for cleanup. Registered with atexit.register(). I moved | |
1668 | here the old exit_cleanup(). After a patch by Ville. |
|
1691 | here the old exit_cleanup(). After a patch by Ville. | |
1669 |
|
1692 | |||
1670 | * IPython/Magic.py (get_py_filename): added '~' to the accepted |
|
1693 | * IPython/Magic.py (get_py_filename): added '~' to the accepted | |
1671 | characters in the hacked shlex_split for python 2.2. |
|
1694 | characters in the hacked shlex_split for python 2.2. | |
1672 |
|
1695 | |||
1673 | * IPython/iplib.py (file_matches): more fixes to filenames with |
|
1696 | * IPython/iplib.py (file_matches): more fixes to filenames with | |
1674 | whitespace in them. It's not perfect, but limitations in python's |
|
1697 | whitespace in them. It's not perfect, but limitations in python's | |
1675 | readline make it impossible to go further. |
|
1698 | readline make it impossible to go further. | |
1676 |
|
1699 | |||
1677 | 2004-06-29 Fernando Perez <fperez@colorado.edu> |
|
1700 | 2004-06-29 Fernando Perez <fperez@colorado.edu> | |
1678 |
|
1701 | |||
1679 | * IPython/iplib.py (file_matches): escape whitespace correctly in |
|
1702 | * IPython/iplib.py (file_matches): escape whitespace correctly in | |
1680 | filename completions. Bug reported by Ville. |
|
1703 | filename completions. Bug reported by Ville. | |
1681 |
|
1704 | |||
1682 | 2004-06-28 Fernando Perez <fperez@colorado.edu> |
|
1705 | 2004-06-28 Fernando Perez <fperez@colorado.edu> | |
1683 |
|
1706 | |||
1684 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now |
|
1707 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now | |
1685 | the history file will be called 'history-PROFNAME' (or just |
|
1708 | the history file will be called 'history-PROFNAME' (or just | |
1686 | 'history' if no profile is loaded). I was getting annoyed at |
|
1709 | 'history' if no profile is loaded). I was getting annoyed at | |
1687 | getting my Numerical work history clobbered by pysh sessions. |
|
1710 | getting my Numerical work history clobbered by pysh sessions. | |
1688 |
|
1711 | |||
1689 | * IPython/iplib.py (InteractiveShell.__init__): Internal |
|
1712 | * IPython/iplib.py (InteractiveShell.__init__): Internal | |
1690 | getoutputerror() function so that we can honor the system_verbose |
|
1713 | getoutputerror() function so that we can honor the system_verbose | |
1691 | flag for _all_ system calls. I also added escaping of # |
|
1714 | flag for _all_ system calls. I also added escaping of # | |
1692 | characters here to avoid confusing Itpl. |
|
1715 | characters here to avoid confusing Itpl. | |
1693 |
|
1716 | |||
1694 | * IPython/Magic.py (shlex_split): removed call to shell in |
|
1717 | * IPython/Magic.py (shlex_split): removed call to shell in | |
1695 | parse_options and replaced it with shlex.split(). The annoying |
|
1718 | parse_options and replaced it with shlex.split(). The annoying | |
1696 | part was that in Python 2.2, shlex.split() doesn't exist, so I had |
|
1719 | part was that in Python 2.2, shlex.split() doesn't exist, so I had | |
1697 | to backport it from 2.3, with several frail hacks (the shlex |
|
1720 | to backport it from 2.3, with several frail hacks (the shlex | |
1698 | module is rather limited in 2.2). Thanks to a suggestion by Ville |
|
1721 | module is rather limited in 2.2). Thanks to a suggestion by Ville | |
1699 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no |
|
1722 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no | |
1700 | problem. |
|
1723 | problem. | |
1701 |
|
1724 | |||
1702 | (Magic.magic_system_verbose): new toggle to print the actual |
|
1725 | (Magic.magic_system_verbose): new toggle to print the actual | |
1703 | system calls made by ipython. Mainly for debugging purposes. |
|
1726 | system calls made by ipython. Mainly for debugging purposes. | |
1704 |
|
1727 | |||
1705 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which |
|
1728 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which | |
1706 | doesn't support persistence. Reported (and fix suggested) by |
|
1729 | doesn't support persistence. Reported (and fix suggested) by | |
1707 | Travis Caldwell <travis_caldwell2000@yahoo.com>. |
|
1730 | Travis Caldwell <travis_caldwell2000@yahoo.com>. | |
1708 |
|
1731 | |||
1709 | 2004-06-26 Fernando Perez <fperez@colorado.edu> |
|
1732 | 2004-06-26 Fernando Perez <fperez@colorado.edu> | |
1710 |
|
1733 | |||
1711 | * IPython/Logger.py (Logger.log): fix to handle correctly empty |
|
1734 | * IPython/Logger.py (Logger.log): fix to handle correctly empty | |
1712 | continue prompts. |
|
1735 | continue prompts. | |
1713 |
|
1736 | |||
1714 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() |
|
1737 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() | |
1715 | function (basically a big docstring) and a few more things here to |
|
1738 | function (basically a big docstring) and a few more things here to | |
1716 | speedup startup. pysh.py is now very lightweight. We want because |
|
1739 | speedup startup. pysh.py is now very lightweight. We want because | |
1717 | it gets execfile'd, while InterpreterExec gets imported, so |
|
1740 | it gets execfile'd, while InterpreterExec gets imported, so | |
1718 | byte-compilation saves time. |
|
1741 | byte-compilation saves time. | |
1719 |
|
1742 | |||
1720 | 2004-06-25 Fernando Perez <fperez@colorado.edu> |
|
1743 | 2004-06-25 Fernando Perez <fperez@colorado.edu> | |
1721 |
|
1744 | |||
1722 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd |
|
1745 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd | |
1723 | -NUM', which was recently broken. |
|
1746 | -NUM', which was recently broken. | |
1724 |
|
1747 | |||
1725 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! |
|
1748 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! | |
1726 | in multi-line input (but not !!, which doesn't make sense there). |
|
1749 | in multi-line input (but not !!, which doesn't make sense there). | |
1727 |
|
1750 | |||
1728 | * IPython/UserConfig/ipythonrc: made autoindent on by default. |
|
1751 | * IPython/UserConfig/ipythonrc: made autoindent on by default. | |
1729 | It's just too useful, and people can turn it off in the less |
|
1752 | It's just too useful, and people can turn it off in the less | |
1730 | common cases where it's a problem. |
|
1753 | common cases where it's a problem. | |
1731 |
|
1754 | |||
1732 | 2004-06-24 Fernando Perez <fperez@colorado.edu> |
|
1755 | 2004-06-24 Fernando Perez <fperez@colorado.edu> | |
1733 |
|
1756 | |||
1734 | * IPython/iplib.py (InteractiveShell._prefilter): big change - |
|
1757 | * IPython/iplib.py (InteractiveShell._prefilter): big change - | |
1735 | special syntaxes (like alias calling) is now allied in multi-line |
|
1758 | special syntaxes (like alias calling) is now allied in multi-line | |
1736 | input. This is still _very_ experimental, but it's necessary for |
|
1759 | input. This is still _very_ experimental, but it's necessary for | |
1737 | efficient shell usage combining python looping syntax with system |
|
1760 | efficient shell usage combining python looping syntax with system | |
1738 | calls. For now it's restricted to aliases, I don't think it |
|
1761 | calls. For now it's restricted to aliases, I don't think it | |
1739 | really even makes sense to have this for magics. |
|
1762 | really even makes sense to have this for magics. | |
1740 |
|
1763 | |||
1741 | 2004-06-23 Fernando Perez <fperez@colorado.edu> |
|
1764 | 2004-06-23 Fernando Perez <fperez@colorado.edu> | |
1742 |
|
1765 | |||
1743 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added |
|
1766 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added | |
1744 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. |
|
1767 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. | |
1745 |
|
1768 | |||
1746 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle |
|
1769 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle | |
1747 | extensions under Windows (after code sent by Gary Bishop). The |
|
1770 | extensions under Windows (after code sent by Gary Bishop). The | |
1748 | extensions considered 'executable' are stored in IPython's rc |
|
1771 | extensions considered 'executable' are stored in IPython's rc | |
1749 | structure as win_exec_ext. |
|
1772 | structure as win_exec_ext. | |
1750 |
|
1773 | |||
1751 | * IPython/genutils.py (shell): new function, like system() but |
|
1774 | * IPython/genutils.py (shell): new function, like system() but | |
1752 | without return value. Very useful for interactive shell work. |
|
1775 | without return value. Very useful for interactive shell work. | |
1753 |
|
1776 | |||
1754 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to |
|
1777 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to | |
1755 | delete aliases. |
|
1778 | delete aliases. | |
1756 |
|
1779 | |||
1757 | * IPython/iplib.py (InteractiveShell.alias_table_update): make |
|
1780 | * IPython/iplib.py (InteractiveShell.alias_table_update): make | |
1758 | sure that the alias table doesn't contain python keywords. |
|
1781 | sure that the alias table doesn't contain python keywords. | |
1759 |
|
1782 | |||
1760 | 2004-06-21 Fernando Perez <fperez@colorado.edu> |
|
1783 | 2004-06-21 Fernando Perez <fperez@colorado.edu> | |
1761 |
|
1784 | |||
1762 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when |
|
1785 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when | |
1763 | non-existent items are found in $PATH. Reported by Thorsten. |
|
1786 | non-existent items are found in $PATH. Reported by Thorsten. | |
1764 |
|
1787 | |||
1765 | 2004-06-20 Fernando Perez <fperez@colorado.edu> |
|
1788 | 2004-06-20 Fernando Perez <fperez@colorado.edu> | |
1766 |
|
1789 | |||
1767 | * IPython/iplib.py (complete): modified the completer so that the |
|
1790 | * IPython/iplib.py (complete): modified the completer so that the | |
1768 | order of priorities can be easily changed at runtime. |
|
1791 | order of priorities can be easily changed at runtime. | |
1769 |
|
1792 | |||
1770 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): |
|
1793 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): | |
1771 | Modified to auto-execute all lines beginning with '~', '/' or '.'. |
|
1794 | Modified to auto-execute all lines beginning with '~', '/' or '.'. | |
1772 |
|
1795 | |||
1773 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to |
|
1796 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to | |
1774 | expand Python variables prepended with $ in all system calls. The |
|
1797 | expand Python variables prepended with $ in all system calls. The | |
1775 | same was done to InteractiveShell.handle_shell_escape. Now all |
|
1798 | same was done to InteractiveShell.handle_shell_escape. Now all | |
1776 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the |
|
1799 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the | |
1777 | expansion of python variables and expressions according to the |
|
1800 | expansion of python variables and expressions according to the | |
1778 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. |
|
1801 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. | |
1779 |
|
1802 | |||
1780 | Though PEP-215 has been rejected, a similar (but simpler) one |
|
1803 | Though PEP-215 has been rejected, a similar (but simpler) one | |
1781 | seems like it will go into Python 2.4, PEP-292 - |
|
1804 | seems like it will go into Python 2.4, PEP-292 - | |
1782 | http://www.python.org/peps/pep-0292.html. |
|
1805 | http://www.python.org/peps/pep-0292.html. | |
1783 |
|
1806 | |||
1784 | I'll keep the full syntax of PEP-215, since IPython has since the |
|
1807 | I'll keep the full syntax of PEP-215, since IPython has since the | |
1785 | start used Ka-Ping Yee's reference implementation discussed there |
|
1808 | start used Ka-Ping Yee's reference implementation discussed there | |
1786 | (Itpl), and I actually like the powerful semantics it offers. |
|
1809 | (Itpl), and I actually like the powerful semantics it offers. | |
1787 |
|
1810 | |||
1788 | In order to access normal shell variables, the $ has to be escaped |
|
1811 | In order to access normal shell variables, the $ has to be escaped | |
1789 | via an extra $. For example: |
|
1812 | via an extra $. For example: | |
1790 |
|
1813 | |||
1791 | In [7]: PATH='a python variable' |
|
1814 | In [7]: PATH='a python variable' | |
1792 |
|
1815 | |||
1793 | In [8]: !echo $PATH |
|
1816 | In [8]: !echo $PATH | |
1794 | a python variable |
|
1817 | a python variable | |
1795 |
|
1818 | |||
1796 | In [9]: !echo $$PATH |
|
1819 | In [9]: !echo $$PATH | |
1797 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
1820 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
1798 |
|
1821 | |||
1799 | (Magic.parse_options): escape $ so the shell doesn't evaluate |
|
1822 | (Magic.parse_options): escape $ so the shell doesn't evaluate | |
1800 | things prematurely. |
|
1823 | things prematurely. | |
1801 |
|
1824 | |||
1802 | * IPython/iplib.py (InteractiveShell.call_alias): added the |
|
1825 | * IPython/iplib.py (InteractiveShell.call_alias): added the | |
1803 | ability for aliases to expand python variables via $. |
|
1826 | ability for aliases to expand python variables via $. | |
1804 |
|
1827 | |||
1805 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias |
|
1828 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias | |
1806 | system, now there's a @rehash/@rehashx pair of magics. These work |
|
1829 | system, now there's a @rehash/@rehashx pair of magics. These work | |
1807 | like the csh rehash command, and can be invoked at any time. They |
|
1830 | like the csh rehash command, and can be invoked at any time. They | |
1808 | build a table of aliases to everything in the user's $PATH |
|
1831 | build a table of aliases to everything in the user's $PATH | |
1809 | (@rehash uses everything, @rehashx is slower but only adds |
|
1832 | (@rehash uses everything, @rehashx is slower but only adds | |
1810 | executable files). With this, the pysh.py-based shell profile can |
|
1833 | executable files). With this, the pysh.py-based shell profile can | |
1811 | now simply call rehash upon startup, and full access to all |
|
1834 | now simply call rehash upon startup, and full access to all | |
1812 | programs in the user's path is obtained. |
|
1835 | programs in the user's path is obtained. | |
1813 |
|
1836 | |||
1814 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias |
|
1837 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias | |
1815 | functionality is now fully in place. I removed the old dynamic |
|
1838 | functionality is now fully in place. I removed the old dynamic | |
1816 | code generation based approach, in favor of a much lighter one |
|
1839 | code generation based approach, in favor of a much lighter one | |
1817 | based on a simple dict. The advantage is that this allows me to |
|
1840 | based on a simple dict. The advantage is that this allows me to | |
1818 | now have thousands of aliases with negligible cost (unthinkable |
|
1841 | now have thousands of aliases with negligible cost (unthinkable | |
1819 | with the old system). |
|
1842 | with the old system). | |
1820 |
|
1843 | |||
1821 | 2004-06-19 Fernando Perez <fperez@colorado.edu> |
|
1844 | 2004-06-19 Fernando Perez <fperez@colorado.edu> | |
1822 |
|
1845 | |||
1823 | * IPython/iplib.py (__init__): extended MagicCompleter class to |
|
1846 | * IPython/iplib.py (__init__): extended MagicCompleter class to | |
1824 | also complete (last in priority) on user aliases. |
|
1847 | also complete (last in priority) on user aliases. | |
1825 |
|
1848 | |||
1826 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in |
|
1849 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in | |
1827 | call to eval. |
|
1850 | call to eval. | |
1828 | (ItplNS.__init__): Added a new class which functions like Itpl, |
|
1851 | (ItplNS.__init__): Added a new class which functions like Itpl, | |
1829 | but allows configuring the namespace for the evaluation to occur |
|
1852 | but allows configuring the namespace for the evaluation to occur | |
1830 | in. |
|
1853 | in. | |
1831 |
|
1854 | |||
1832 | 2004-06-18 Fernando Perez <fperez@colorado.edu> |
|
1855 | 2004-06-18 Fernando Perez <fperez@colorado.edu> | |
1833 |
|
1856 | |||
1834 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a |
|
1857 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a | |
1835 | better message when 'exit' or 'quit' are typed (a common newbie |
|
1858 | better message when 'exit' or 'quit' are typed (a common newbie | |
1836 | confusion). |
|
1859 | confusion). | |
1837 |
|
1860 | |||
1838 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color |
|
1861 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color | |
1839 | check for Windows users. |
|
1862 | check for Windows users. | |
1840 |
|
1863 | |||
1841 | * IPython/iplib.py (InteractiveShell.user_setup): removed |
|
1864 | * IPython/iplib.py (InteractiveShell.user_setup): removed | |
1842 | disabling of colors for Windows. I'll test at runtime and issue a |
|
1865 | disabling of colors for Windows. I'll test at runtime and issue a | |
1843 | warning if Gary's readline isn't found, as to nudge users to |
|
1866 | warning if Gary's readline isn't found, as to nudge users to | |
1844 | download it. |
|
1867 | download it. | |
1845 |
|
1868 | |||
1846 | 2004-06-16 Fernando Perez <fperez@colorado.edu> |
|
1869 | 2004-06-16 Fernando Perez <fperez@colorado.edu> | |
1847 |
|
1870 | |||
1848 | * IPython/genutils.py (Stream.__init__): changed to print errors |
|
1871 | * IPython/genutils.py (Stream.__init__): changed to print errors | |
1849 | to sys.stderr. I had a circular dependency here. Now it's |
|
1872 | to sys.stderr. I had a circular dependency here. Now it's | |
1850 | possible to run ipython as IDLE's shell (consider this pre-alpha, |
|
1873 | possible to run ipython as IDLE's shell (consider this pre-alpha, | |
1851 | since true stdout things end up in the starting terminal instead |
|
1874 | since true stdout things end up in the starting terminal instead | |
1852 | of IDLE's out). |
|
1875 | of IDLE's out). | |
1853 |
|
1876 | |||
1854 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for |
|
1877 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for | |
1855 | users who haven't # updated their prompt_in2 definitions. Remove |
|
1878 | users who haven't # updated their prompt_in2 definitions. Remove | |
1856 | eventually. |
|
1879 | eventually. | |
1857 | (multiple_replace): added credit to original ASPN recipe. |
|
1880 | (multiple_replace): added credit to original ASPN recipe. | |
1858 |
|
1881 | |||
1859 | 2004-06-15 Fernando Perez <fperez@colorado.edu> |
|
1882 | 2004-06-15 Fernando Perez <fperez@colorado.edu> | |
1860 |
|
1883 | |||
1861 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the |
|
1884 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the | |
1862 | list of auto-defined aliases. |
|
1885 | list of auto-defined aliases. | |
1863 |
|
1886 | |||
1864 | 2004-06-13 Fernando Perez <fperez@colorado.edu> |
|
1887 | 2004-06-13 Fernando Perez <fperez@colorado.edu> | |
1865 |
|
1888 | |||
1866 | * setup.py (scriptfiles): Don't trigger win_post_install unless an |
|
1889 | * setup.py (scriptfiles): Don't trigger win_post_install unless an | |
1867 | install was really requested (so setup.py can be used for other |
|
1890 | install was really requested (so setup.py can be used for other | |
1868 | things under Windows). |
|
1891 | things under Windows). | |
1869 |
|
1892 | |||
1870 | 2004-06-10 Fernando Perez <fperez@colorado.edu> |
|
1893 | 2004-06-10 Fernando Perez <fperez@colorado.edu> | |
1871 |
|
1894 | |||
1872 | * IPython/Logger.py (Logger.create_log): Manually remove any old |
|
1895 | * IPython/Logger.py (Logger.create_log): Manually remove any old | |
1873 | backup, since os.remove may fail under Windows. Fixes bug |
|
1896 | backup, since os.remove may fail under Windows. Fixes bug | |
1874 | reported by Thorsten. |
|
1897 | reported by Thorsten. | |
1875 |
|
1898 | |||
1876 | 2004-06-09 Fernando Perez <fperez@colorado.edu> |
|
1899 | 2004-06-09 Fernando Perez <fperez@colorado.edu> | |
1877 |
|
1900 | |||
1878 | * examples/example-embed.py: fixed all references to %n (replaced |
|
1901 | * examples/example-embed.py: fixed all references to %n (replaced | |
1879 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done |
|
1902 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done | |
1880 | for all examples and the manual as well. |
|
1903 | for all examples and the manual as well. | |
1881 |
|
1904 | |||
1882 | 2004-06-08 Fernando Perez <fperez@colorado.edu> |
|
1905 | 2004-06-08 Fernando Perez <fperez@colorado.edu> | |
1883 |
|
1906 | |||
1884 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt |
|
1907 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt | |
1885 | alignment and color management. All 3 prompt subsystems now |
|
1908 | alignment and color management. All 3 prompt subsystems now | |
1886 | inherit from BasePrompt. |
|
1909 | inherit from BasePrompt. | |
1887 |
|
1910 | |||
1888 | * tools/release: updates for windows installer build and tag rpms |
|
1911 | * tools/release: updates for windows installer build and tag rpms | |
1889 | with python version (since paths are fixed). |
|
1912 | with python version (since paths are fixed). | |
1890 |
|
1913 | |||
1891 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, |
|
1914 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, | |
1892 | which will become eventually obsolete. Also fixed the default |
|
1915 | which will become eventually obsolete. Also fixed the default | |
1893 | prompt_in2 to use \D, so at least new users start with the correct |
|
1916 | prompt_in2 to use \D, so at least new users start with the correct | |
1894 | defaults. |
|
1917 | defaults. | |
1895 | WARNING: Users with existing ipythonrc files will need to apply |
|
1918 | WARNING: Users with existing ipythonrc files will need to apply | |
1896 | this fix manually! |
|
1919 | this fix manually! | |
1897 |
|
1920 | |||
1898 | * setup.py: make windows installer (.exe). This is finally the |
|
1921 | * setup.py: make windows installer (.exe). This is finally the | |
1899 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, |
|
1922 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, | |
1900 | which I hadn't included because it required Python 2.3 (or recent |
|
1923 | which I hadn't included because it required Python 2.3 (or recent | |
1901 | distutils). |
|
1924 | distutils). | |
1902 |
|
1925 | |||
1903 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect |
|
1926 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect | |
1904 | usage of new '\D' escape. |
|
1927 | usage of new '\D' escape. | |
1905 |
|
1928 | |||
1906 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which |
|
1929 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which | |
1907 | lacks os.getuid()) |
|
1930 | lacks os.getuid()) | |
1908 | (CachedOutput.set_colors): Added the ability to turn coloring |
|
1931 | (CachedOutput.set_colors): Added the ability to turn coloring | |
1909 | on/off with @colors even for manually defined prompt colors. It |
|
1932 | on/off with @colors even for manually defined prompt colors. It | |
1910 | uses a nasty global, but it works safely and via the generic color |
|
1933 | uses a nasty global, but it works safely and via the generic color | |
1911 | handling mechanism. |
|
1934 | handling mechanism. | |
1912 | (Prompt2.__init__): Introduced new escape '\D' for continuation |
|
1935 | (Prompt2.__init__): Introduced new escape '\D' for continuation | |
1913 | prompts. It represents the counter ('\#') as dots. |
|
1936 | prompts. It represents the counter ('\#') as dots. | |
1914 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will |
|
1937 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will | |
1915 | need to update their ipythonrc files and replace '%n' with '\D' in |
|
1938 | need to update their ipythonrc files and replace '%n' with '\D' in | |
1916 | their prompt_in2 settings everywhere. Sorry, but there's |
|
1939 | their prompt_in2 settings everywhere. Sorry, but there's | |
1917 | otherwise no clean way to get all prompts to properly align. The |
|
1940 | otherwise no clean way to get all prompts to properly align. The | |
1918 | ipythonrc shipped with IPython has been updated. |
|
1941 | ipythonrc shipped with IPython has been updated. | |
1919 |
|
1942 | |||
1920 | 2004-06-07 Fernando Perez <fperez@colorado.edu> |
|
1943 | 2004-06-07 Fernando Perez <fperez@colorado.edu> | |
1921 |
|
1944 | |||
1922 | * setup.py (isfile): Pass local_icons option to latex2html, so the |
|
1945 | * setup.py (isfile): Pass local_icons option to latex2html, so the | |
1923 | resulting HTML file is self-contained. Thanks to |
|
1946 | resulting HTML file is self-contained. Thanks to | |
1924 | dryice-AT-liu.com.cn for the tip. |
|
1947 | dryice-AT-liu.com.cn for the tip. | |
1925 |
|
1948 | |||
1926 | * pysh.py: I created a new profile 'shell', which implements a |
|
1949 | * pysh.py: I created a new profile 'shell', which implements a | |
1927 | _rudimentary_ IPython-based shell. This is in NO WAY a realy |
|
1950 | _rudimentary_ IPython-based shell. This is in NO WAY a realy | |
1928 | system shell, nor will it become one anytime soon. It's mainly |
|
1951 | system shell, nor will it become one anytime soon. It's mainly | |
1929 | meant to illustrate the use of the new flexible bash-like prompts. |
|
1952 | meant to illustrate the use of the new flexible bash-like prompts. | |
1930 | I guess it could be used by hardy souls for true shell management, |
|
1953 | I guess it could be used by hardy souls for true shell management, | |
1931 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' |
|
1954 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' | |
1932 | profile. This uses the InterpreterExec extension provided by |
|
1955 | profile. This uses the InterpreterExec extension provided by | |
1933 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> |
|
1956 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> | |
1934 |
|
1957 | |||
1935 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly |
|
1958 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly | |
1936 | auto-align itself with the length of the previous input prompt |
|
1959 | auto-align itself with the length of the previous input prompt | |
1937 | (taking into account the invisible color escapes). |
|
1960 | (taking into account the invisible color escapes). | |
1938 | (CachedOutput.__init__): Large restructuring of this class. Now |
|
1961 | (CachedOutput.__init__): Large restructuring of this class. Now | |
1939 | all three prompts (primary1, primary2, output) are proper objects, |
|
1962 | all three prompts (primary1, primary2, output) are proper objects, | |
1940 | managed by the 'parent' CachedOutput class. The code is still a |
|
1963 | managed by the 'parent' CachedOutput class. The code is still a | |
1941 | bit hackish (all prompts share state via a pointer to the cache), |
|
1964 | bit hackish (all prompts share state via a pointer to the cache), | |
1942 | but it's overall far cleaner than before. |
|
1965 | but it's overall far cleaner than before. | |
1943 |
|
1966 | |||
1944 | * IPython/genutils.py (getoutputerror): modified to add verbose, |
|
1967 | * IPython/genutils.py (getoutputerror): modified to add verbose, | |
1945 | debug and header options. This makes the interface of all getout* |
|
1968 | debug and header options. This makes the interface of all getout* | |
1946 | functions uniform. |
|
1969 | functions uniform. | |
1947 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. |
|
1970 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. | |
1948 |
|
1971 | |||
1949 | * IPython/Magic.py (Magic.default_option): added a function to |
|
1972 | * IPython/Magic.py (Magic.default_option): added a function to | |
1950 | allow registering default options for any magic command. This |
|
1973 | allow registering default options for any magic command. This | |
1951 | makes it easy to have profiles which customize the magics globally |
|
1974 | makes it easy to have profiles which customize the magics globally | |
1952 | for a certain use. The values set through this function are |
|
1975 | for a certain use. The values set through this function are | |
1953 | picked up by the parse_options() method, which all magics should |
|
1976 | picked up by the parse_options() method, which all magics should | |
1954 | use to parse their options. |
|
1977 | use to parse their options. | |
1955 |
|
1978 | |||
1956 | * IPython/genutils.py (warn): modified the warnings framework to |
|
1979 | * IPython/genutils.py (warn): modified the warnings framework to | |
1957 | use the Term I/O class. I'm trying to slowly unify all of |
|
1980 | use the Term I/O class. I'm trying to slowly unify all of | |
1958 | IPython's I/O operations to pass through Term. |
|
1981 | IPython's I/O operations to pass through Term. | |
1959 |
|
1982 | |||
1960 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in |
|
1983 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in | |
1961 | the secondary prompt to correctly match the length of the primary |
|
1984 | the secondary prompt to correctly match the length of the primary | |
1962 | one for any prompt. Now multi-line code will properly line up |
|
1985 | one for any prompt. Now multi-line code will properly line up | |
1963 | even for path dependent prompts, such as the new ones available |
|
1986 | even for path dependent prompts, such as the new ones available | |
1964 | via the prompt_specials. |
|
1987 | via the prompt_specials. | |
1965 |
|
1988 | |||
1966 | 2004-06-06 Fernando Perez <fperez@colorado.edu> |
|
1989 | 2004-06-06 Fernando Perez <fperez@colorado.edu> | |
1967 |
|
1990 | |||
1968 | * IPython/Prompts.py (prompt_specials): Added the ability to have |
|
1991 | * IPython/Prompts.py (prompt_specials): Added the ability to have | |
1969 | bash-like special sequences in the prompts, which get |
|
1992 | bash-like special sequences in the prompts, which get | |
1970 | automatically expanded. Things like hostname, current working |
|
1993 | automatically expanded. Things like hostname, current working | |
1971 | directory and username are implemented already, but it's easy to |
|
1994 | directory and username are implemented already, but it's easy to | |
1972 | add more in the future. Thanks to a patch by W.J. van der Laan |
|
1995 | add more in the future. Thanks to a patch by W.J. van der Laan | |
1973 | <gnufnork-AT-hetdigitalegat.nl> |
|
1996 | <gnufnork-AT-hetdigitalegat.nl> | |
1974 | (prompt_specials): Added color support for prompt strings, so |
|
1997 | (prompt_specials): Added color support for prompt strings, so | |
1975 | users can define arbitrary color setups for their prompts. |
|
1998 | users can define arbitrary color setups for their prompts. | |
1976 |
|
1999 | |||
1977 | 2004-06-05 Fernando Perez <fperez@colorado.edu> |
|
2000 | 2004-06-05 Fernando Perez <fperez@colorado.edu> | |
1978 |
|
2001 | |||
1979 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific |
|
2002 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific | |
1980 | code to load Gary Bishop's readline and configure it |
|
2003 | code to load Gary Bishop's readline and configure it | |
1981 | automatically. Thanks to Gary for help on this. |
|
2004 | automatically. Thanks to Gary for help on this. | |
1982 |
|
2005 | |||
1983 | 2004-06-01 Fernando Perez <fperez@colorado.edu> |
|
2006 | 2004-06-01 Fernando Perez <fperez@colorado.edu> | |
1984 |
|
2007 | |||
1985 | * IPython/Logger.py (Logger.create_log): fix bug for logging |
|
2008 | * IPython/Logger.py (Logger.create_log): fix bug for logging | |
1986 | with no filename (previous fix was incomplete). |
|
2009 | with no filename (previous fix was incomplete). | |
1987 |
|
2010 | |||
1988 | 2004-05-25 Fernando Perez <fperez@colorado.edu> |
|
2011 | 2004-05-25 Fernando Perez <fperez@colorado.edu> | |
1989 |
|
2012 | |||
1990 | * IPython/Magic.py (Magic.parse_options): fix bug where naked |
|
2013 | * IPython/Magic.py (Magic.parse_options): fix bug where naked | |
1991 | parens would get passed to the shell. |
|
2014 | parens would get passed to the shell. | |
1992 |
|
2015 | |||
1993 | 2004-05-20 Fernando Perez <fperez@colorado.edu> |
|
2016 | 2004-05-20 Fernando Perez <fperez@colorado.edu> | |
1994 |
|
2017 | |||
1995 | * IPython/Magic.py (Magic.magic_prun): changed default profile |
|
2018 | * IPython/Magic.py (Magic.magic_prun): changed default profile | |
1996 | sort order to 'time' (the more common profiling need). |
|
2019 | sort order to 'time' (the more common profiling need). | |
1997 |
|
2020 | |||
1998 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache |
|
2021 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache | |
1999 | so that source code shown is guaranteed in sync with the file on |
|
2022 | so that source code shown is guaranteed in sync with the file on | |
2000 | disk (also changed in psource). Similar fix to the one for |
|
2023 | disk (also changed in psource). Similar fix to the one for | |
2001 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du |
|
2024 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du | |
2002 | <yann.ledu-AT-noos.fr>. |
|
2025 | <yann.ledu-AT-noos.fr>. | |
2003 |
|
2026 | |||
2004 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands |
|
2027 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands | |
2005 | with a single option would not be correctly parsed. Closes |
|
2028 | with a single option would not be correctly parsed. Closes | |
2006 | http://www.scipy.net/roundup/ipython/issue14. This bug had been |
|
2029 | http://www.scipy.net/roundup/ipython/issue14. This bug had been | |
2007 | introduced in 0.6.0 (on 2004-05-06). |
|
2030 | introduced in 0.6.0 (on 2004-05-06). | |
2008 |
|
2031 | |||
2009 | 2004-05-13 *** Released version 0.6.0 |
|
2032 | 2004-05-13 *** Released version 0.6.0 | |
2010 |
|
2033 | |||
2011 | 2004-05-13 Fernando Perez <fperez@colorado.edu> |
|
2034 | 2004-05-13 Fernando Perez <fperez@colorado.edu> | |
2012 |
|
2035 | |||
2013 | * debian/: Added debian/ directory to CVS, so that debian support |
|
2036 | * debian/: Added debian/ directory to CVS, so that debian support | |
2014 | is publicly accessible. The debian package is maintained by Jack |
|
2037 | is publicly accessible. The debian package is maintained by Jack | |
2015 | Moffit <jack-AT-xiph.org>. |
|
2038 | Moffit <jack-AT-xiph.org>. | |
2016 |
|
2039 | |||
2017 | * Documentation: included the notes about an ipython-based system |
|
2040 | * Documentation: included the notes about an ipython-based system | |
2018 | shell (the hypothetical 'pysh') into the new_design.pdf document, |
|
2041 | shell (the hypothetical 'pysh') into the new_design.pdf document, | |
2019 | so that these ideas get distributed to users along with the |
|
2042 | so that these ideas get distributed to users along with the | |
2020 | official documentation. |
|
2043 | official documentation. | |
2021 |
|
2044 | |||
2022 | 2004-05-10 Fernando Perez <fperez@colorado.edu> |
|
2045 | 2004-05-10 Fernando Perez <fperez@colorado.edu> | |
2023 |
|
2046 | |||
2024 | * IPython/Logger.py (Logger.create_log): fix recently introduced |
|
2047 | * IPython/Logger.py (Logger.create_log): fix recently introduced | |
2025 | bug (misindented line) where logstart would fail when not given an |
|
2048 | bug (misindented line) where logstart would fail when not given an | |
2026 | explicit filename. |
|
2049 | explicit filename. | |
2027 |
|
2050 | |||
2028 | 2004-05-09 Fernando Perez <fperez@colorado.edu> |
|
2051 | 2004-05-09 Fernando Perez <fperez@colorado.edu> | |
2029 |
|
2052 | |||
2030 | * IPython/Magic.py (Magic.parse_options): skip system call when |
|
2053 | * IPython/Magic.py (Magic.parse_options): skip system call when | |
2031 | there are no options to look for. Faster, cleaner for the common |
|
2054 | there are no options to look for. Faster, cleaner for the common | |
2032 | case. |
|
2055 | case. | |
2033 |
|
2056 | |||
2034 | * Documentation: many updates to the manual: describing Windows |
|
2057 | * Documentation: many updates to the manual: describing Windows | |
2035 | support better, Gnuplot updates, credits, misc small stuff. Also |
|
2058 | support better, Gnuplot updates, credits, misc small stuff. Also | |
2036 | updated the new_design doc a bit. |
|
2059 | updated the new_design doc a bit. | |
2037 |
|
2060 | |||
2038 | 2004-05-06 *** Released version 0.6.0.rc1 |
|
2061 | 2004-05-06 *** Released version 0.6.0.rc1 | |
2039 |
|
2062 | |||
2040 | 2004-05-06 Fernando Perez <fperez@colorado.edu> |
|
2063 | 2004-05-06 Fernando Perez <fperez@colorado.edu> | |
2041 |
|
2064 | |||
2042 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += |
|
2065 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += | |
2043 | operations to use the vastly more efficient list/''.join() method. |
|
2066 | operations to use the vastly more efficient list/''.join() method. | |
2044 | (FormattedTB.text): Fix |
|
2067 | (FormattedTB.text): Fix | |
2045 | http://www.scipy.net/roundup/ipython/issue12 - exception source |
|
2068 | http://www.scipy.net/roundup/ipython/issue12 - exception source | |
2046 | extract not updated after reload. Thanks to Mike Salib |
|
2069 | extract not updated after reload. Thanks to Mike Salib | |
2047 | <msalib-AT-mit.edu> for pinning the source of the problem. |
|
2070 | <msalib-AT-mit.edu> for pinning the source of the problem. | |
2048 | Fortunately, the solution works inside ipython and doesn't require |
|
2071 | Fortunately, the solution works inside ipython and doesn't require | |
2049 | any changes to python proper. |
|
2072 | any changes to python proper. | |
2050 |
|
2073 | |||
2051 | * IPython/Magic.py (Magic.parse_options): Improved to process the |
|
2074 | * IPython/Magic.py (Magic.parse_options): Improved to process the | |
2052 | argument list as a true shell would (by actually using the |
|
2075 | argument list as a true shell would (by actually using the | |
2053 | underlying system shell). This way, all @magics automatically get |
|
2076 | underlying system shell). This way, all @magics automatically get | |
2054 | shell expansion for variables. Thanks to a comment by Alex |
|
2077 | shell expansion for variables. Thanks to a comment by Alex | |
2055 | Schmolck. |
|
2078 | Schmolck. | |
2056 |
|
2079 | |||
2057 | 2004-04-04 Fernando Perez <fperez@colorado.edu> |
|
2080 | 2004-04-04 Fernando Perez <fperez@colorado.edu> | |
2058 |
|
2081 | |||
2059 | * IPython/iplib.py (InteractiveShell.interact): Added a special |
|
2082 | * IPython/iplib.py (InteractiveShell.interact): Added a special | |
2060 | trap for a debugger quit exception, which is basically impossible |
|
2083 | trap for a debugger quit exception, which is basically impossible | |
2061 | to handle by normal mechanisms, given what pdb does to the stack. |
|
2084 | to handle by normal mechanisms, given what pdb does to the stack. | |
2062 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. |
|
2085 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. | |
2063 |
|
2086 | |||
2064 | 2004-04-03 Fernando Perez <fperez@colorado.edu> |
|
2087 | 2004-04-03 Fernando Perez <fperez@colorado.edu> | |
2065 |
|
2088 | |||
2066 | * IPython/genutils.py (Term): Standardized the names of the Term |
|
2089 | * IPython/genutils.py (Term): Standardized the names of the Term | |
2067 | class streams to cin/cout/cerr, following C++ naming conventions |
|
2090 | class streams to cin/cout/cerr, following C++ naming conventions | |
2068 | (I can't use in/out/err because 'in' is not a valid attribute |
|
2091 | (I can't use in/out/err because 'in' is not a valid attribute | |
2069 | name). |
|
2092 | name). | |
2070 |
|
2093 | |||
2071 | * IPython/iplib.py (InteractiveShell.interact): don't increment |
|
2094 | * IPython/iplib.py (InteractiveShell.interact): don't increment | |
2072 | the prompt if there's no user input. By Daniel 'Dang' Griffith |
|
2095 | the prompt if there's no user input. By Daniel 'Dang' Griffith | |
2073 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from |
|
2096 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from | |
2074 | Francois Pinard. |
|
2097 | Francois Pinard. | |
2075 |
|
2098 | |||
2076 | 2004-04-02 Fernando Perez <fperez@colorado.edu> |
|
2099 | 2004-04-02 Fernando Perez <fperez@colorado.edu> | |
2077 |
|
2100 | |||
2078 | * IPython/genutils.py (Stream.__init__): Modified to survive at |
|
2101 | * IPython/genutils.py (Stream.__init__): Modified to survive at | |
2079 | least importing in contexts where stdin/out/err aren't true file |
|
2102 | least importing in contexts where stdin/out/err aren't true file | |
2080 | objects, such as PyCrust (they lack fileno() and mode). However, |
|
2103 | objects, such as PyCrust (they lack fileno() and mode). However, | |
2081 | the recovery facilities which rely on these things existing will |
|
2104 | the recovery facilities which rely on these things existing will | |
2082 | not work. |
|
2105 | not work. | |
2083 |
|
2106 | |||
2084 | 2004-04-01 Fernando Perez <fperez@colorado.edu> |
|
2107 | 2004-04-01 Fernando Perez <fperez@colorado.edu> | |
2085 |
|
2108 | |||
2086 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to |
|
2109 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to | |
2087 | use the new getoutputerror() function, so it properly |
|
2110 | use the new getoutputerror() function, so it properly | |
2088 | distinguishes stdout/err. |
|
2111 | distinguishes stdout/err. | |
2089 |
|
2112 | |||
2090 | * IPython/genutils.py (getoutputerror): added a function to |
|
2113 | * IPython/genutils.py (getoutputerror): added a function to | |
2091 | capture separately the standard output and error of a command. |
|
2114 | capture separately the standard output and error of a command. | |
2092 | After a comment from dang on the mailing lists. This code is |
|
2115 | After a comment from dang on the mailing lists. This code is | |
2093 | basically a modified version of commands.getstatusoutput(), from |
|
2116 | basically a modified version of commands.getstatusoutput(), from | |
2094 | the standard library. |
|
2117 | the standard library. | |
2095 |
|
2118 | |||
2096 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added |
|
2119 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added | |
2097 | '!!' as a special syntax (shorthand) to access @sx. |
|
2120 | '!!' as a special syntax (shorthand) to access @sx. | |
2098 |
|
2121 | |||
2099 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell |
|
2122 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell | |
2100 | command and return its output as a list split on '\n'. |
|
2123 | command and return its output as a list split on '\n'. | |
2101 |
|
2124 | |||
2102 | 2004-03-31 Fernando Perez <fperez@colorado.edu> |
|
2125 | 2004-03-31 Fernando Perez <fperez@colorado.edu> | |
2103 |
|
2126 | |||
2104 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ |
|
2127 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ | |
2105 | method to dictionaries used as FakeModule instances if they lack |
|
2128 | method to dictionaries used as FakeModule instances if they lack | |
2106 | it. At least pydoc in python2.3 breaks for runtime-defined |
|
2129 | it. At least pydoc in python2.3 breaks for runtime-defined | |
2107 | functions without this hack. At some point I need to _really_ |
|
2130 | functions without this hack. At some point I need to _really_ | |
2108 | understand what FakeModule is doing, because it's a gross hack. |
|
2131 | understand what FakeModule is doing, because it's a gross hack. | |
2109 | But it solves Arnd's problem for now... |
|
2132 | But it solves Arnd's problem for now... | |
2110 |
|
2133 | |||
2111 | 2004-02-27 Fernando Perez <fperez@colorado.edu> |
|
2134 | 2004-02-27 Fernando Perez <fperez@colorado.edu> | |
2112 |
|
2135 | |||
2113 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' |
|
2136 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' | |
2114 | mode would behave erratically. Also increased the number of |
|
2137 | mode would behave erratically. Also increased the number of | |
2115 | possible logs in rotate mod to 999. Thanks to Rod Holland |
|
2138 | possible logs in rotate mod to 999. Thanks to Rod Holland | |
2116 | <rhh@StructureLABS.com> for the report and fixes. |
|
2139 | <rhh@StructureLABS.com> for the report and fixes. | |
2117 |
|
2140 | |||
2118 | 2004-02-26 Fernando Perez <fperez@colorado.edu> |
|
2141 | 2004-02-26 Fernando Perez <fperez@colorado.edu> | |
2119 |
|
2142 | |||
2120 | * IPython/genutils.py (page): Check that the curses module really |
|
2143 | * IPython/genutils.py (page): Check that the curses module really | |
2121 | has the initscr attribute before trying to use it. For some |
|
2144 | has the initscr attribute before trying to use it. For some | |
2122 | reason, the Solaris curses module is missing this. I think this |
|
2145 | reason, the Solaris curses module is missing this. I think this | |
2123 | should be considered a Solaris python bug, but I'm not sure. |
|
2146 | should be considered a Solaris python bug, but I'm not sure. | |
2124 |
|
2147 | |||
2125 | 2004-01-17 Fernando Perez <fperez@colorado.edu> |
|
2148 | 2004-01-17 Fernando Perez <fperez@colorado.edu> | |
2126 |
|
2149 | |||
2127 | * IPython/genutils.py (Stream.__init__): Changes to try to make |
|
2150 | * IPython/genutils.py (Stream.__init__): Changes to try to make | |
2128 | ipython robust against stdin/out/err being closed by the user. |
|
2151 | ipython robust against stdin/out/err being closed by the user. | |
2129 | This is 'user error' (and blocks a normal python session, at least |
|
2152 | This is 'user error' (and blocks a normal python session, at least | |
2130 | the stdout case). However, Ipython should be able to survive such |
|
2153 | the stdout case). However, Ipython should be able to survive such | |
2131 | instances of abuse as gracefully as possible. To simplify the |
|
2154 | instances of abuse as gracefully as possible. To simplify the | |
2132 | coding and maintain compatibility with Gary Bishop's Term |
|
2155 | coding and maintain compatibility with Gary Bishop's Term | |
2133 | contributions, I've made use of classmethods for this. I think |
|
2156 | contributions, I've made use of classmethods for this. I think | |
2134 | this introduces a dependency on python 2.2. |
|
2157 | this introduces a dependency on python 2.2. | |
2135 |
|
2158 | |||
2136 | 2004-01-13 Fernando Perez <fperez@colorado.edu> |
|
2159 | 2004-01-13 Fernando Perez <fperez@colorado.edu> | |
2137 |
|
2160 | |||
2138 | * IPython/numutils.py (exp_safe): simplified the code a bit and |
|
2161 | * IPython/numutils.py (exp_safe): simplified the code a bit and | |
2139 | removed the need for importing the kinds module altogether. |
|
2162 | removed the need for importing the kinds module altogether. | |
2140 |
|
2163 | |||
2141 | 2004-01-06 Fernando Perez <fperez@colorado.edu> |
|
2164 | 2004-01-06 Fernando Perez <fperez@colorado.edu> | |
2142 |
|
2165 | |||
2143 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system |
|
2166 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system | |
2144 | a magic function instead, after some community feedback. No |
|
2167 | a magic function instead, after some community feedback. No | |
2145 | special syntax will exist for it, but its name is deliberately |
|
2168 | special syntax will exist for it, but its name is deliberately | |
2146 | very short. |
|
2169 | very short. | |
2147 |
|
2170 | |||
2148 | 2003-12-20 Fernando Perez <fperez@colorado.edu> |
|
2171 | 2003-12-20 Fernando Perez <fperez@colorado.edu> | |
2149 |
|
2172 | |||
2150 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added |
|
2173 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added | |
2151 | new functionality, to automagically assign the result of a shell |
|
2174 | new functionality, to automagically assign the result of a shell | |
2152 | command to a variable. I'll solicit some community feedback on |
|
2175 | command to a variable. I'll solicit some community feedback on | |
2153 | this before making it permanent. |
|
2176 | this before making it permanent. | |
2154 |
|
2177 | |||
2155 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was |
|
2178 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was | |
2156 | requested about callables for which inspect couldn't obtain a |
|
2179 | requested about callables for which inspect couldn't obtain a | |
2157 | proper argspec. Thanks to a crash report sent by Etienne |
|
2180 | proper argspec. Thanks to a crash report sent by Etienne | |
2158 | Posthumus <etienne-AT-apple01.cs.vu.nl>. |
|
2181 | Posthumus <etienne-AT-apple01.cs.vu.nl>. | |
2159 |
|
2182 | |||
2160 | 2003-12-09 Fernando Perez <fperez@colorado.edu> |
|
2183 | 2003-12-09 Fernando Perez <fperez@colorado.edu> | |
2161 |
|
2184 | |||
2162 | * IPython/genutils.py (page): patch for the pager to work across |
|
2185 | * IPython/genutils.py (page): patch for the pager to work across | |
2163 | various versions of Windows. By Gary Bishop. |
|
2186 | various versions of Windows. By Gary Bishop. | |
2164 |
|
2187 | |||
2165 | 2003-12-04 Fernando Perez <fperez@colorado.edu> |
|
2188 | 2003-12-04 Fernando Perez <fperez@colorado.edu> | |
2166 |
|
2189 | |||
2167 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with |
|
2190 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with | |
2168 | Gnuplot.py version 1.7, whose internal names changed quite a bit. |
|
2191 | Gnuplot.py version 1.7, whose internal names changed quite a bit. | |
2169 | While I tested this and it looks ok, there may still be corner |
|
2192 | While I tested this and it looks ok, there may still be corner | |
2170 | cases I've missed. |
|
2193 | cases I've missed. | |
2171 |
|
2194 | |||
2172 | 2003-12-01 Fernando Perez <fperez@colorado.edu> |
|
2195 | 2003-12-01 Fernando Perez <fperez@colorado.edu> | |
2173 |
|
2196 | |||
2174 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug |
|
2197 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug | |
2175 | where a line like 'p,q=1,2' would fail because the automagic |
|
2198 | where a line like 'p,q=1,2' would fail because the automagic | |
2176 | system would be triggered for @p. |
|
2199 | system would be triggered for @p. | |
2177 |
|
2200 | |||
2178 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related |
|
2201 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related | |
2179 | cleanups, code unmodified. |
|
2202 | cleanups, code unmodified. | |
2180 |
|
2203 | |||
2181 | * IPython/genutils.py (Term): added a class for IPython to handle |
|
2204 | * IPython/genutils.py (Term): added a class for IPython to handle | |
2182 | output. In most cases it will just be a proxy for stdout/err, but |
|
2205 | output. In most cases it will just be a proxy for stdout/err, but | |
2183 | having this allows modifications to be made for some platforms, |
|
2206 | having this allows modifications to be made for some platforms, | |
2184 | such as handling color escapes under Windows. All of this code |
|
2207 | such as handling color escapes under Windows. All of this code | |
2185 | was contributed by Gary Bishop, with minor modifications by me. |
|
2208 | was contributed by Gary Bishop, with minor modifications by me. | |
2186 | The actual changes affect many files. |
|
2209 | The actual changes affect many files. | |
2187 |
|
2210 | |||
2188 | 2003-11-30 Fernando Perez <fperez@colorado.edu> |
|
2211 | 2003-11-30 Fernando Perez <fperez@colorado.edu> | |
2189 |
|
2212 | |||
2190 | * IPython/iplib.py (file_matches): new completion code, courtesy |
|
2213 | * IPython/iplib.py (file_matches): new completion code, courtesy | |
2191 | of Jeff Collins. This enables filename completion again under |
|
2214 | of Jeff Collins. This enables filename completion again under | |
2192 | python 2.3, which disabled it at the C level. |
|
2215 | python 2.3, which disabled it at the C level. | |
2193 |
|
2216 | |||
2194 | 2003-11-11 Fernando Perez <fperez@colorado.edu> |
|
2217 | 2003-11-11 Fernando Perez <fperez@colorado.edu> | |
2195 |
|
2218 | |||
2196 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand |
|
2219 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand | |
2197 | for Numeric.array(map(...)), but often convenient. |
|
2220 | for Numeric.array(map(...)), but often convenient. | |
2198 |
|
2221 | |||
2199 | 2003-11-05 Fernando Perez <fperez@colorado.edu> |
|
2222 | 2003-11-05 Fernando Perez <fperez@colorado.edu> | |
2200 |
|
2223 | |||
2201 | * IPython/numutils.py (frange): Changed a call from int() to |
|
2224 | * IPython/numutils.py (frange): Changed a call from int() to | |
2202 | int(round()) to prevent a problem reported with arange() in the |
|
2225 | int(round()) to prevent a problem reported with arange() in the | |
2203 | numpy list. |
|
2226 | numpy list. | |
2204 |
|
2227 | |||
2205 | 2003-10-06 Fernando Perez <fperez@colorado.edu> |
|
2228 | 2003-10-06 Fernando Perez <fperez@colorado.edu> | |
2206 |
|
2229 | |||
2207 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to |
|
2230 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to | |
2208 | prevent crashes if sys lacks an argv attribute (it happens with |
|
2231 | prevent crashes if sys lacks an argv attribute (it happens with | |
2209 | embedded interpreters which build a bare-bones sys module). |
|
2232 | embedded interpreters which build a bare-bones sys module). | |
2210 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. |
|
2233 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. | |
2211 |
|
2234 | |||
2212 | 2003-09-24 Fernando Perez <fperez@colorado.edu> |
|
2235 | 2003-09-24 Fernando Perez <fperez@colorado.edu> | |
2213 |
|
2236 | |||
2214 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() |
|
2237 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() | |
2215 | to protect against poorly written user objects where __getattr__ |
|
2238 | to protect against poorly written user objects where __getattr__ | |
2216 | raises exceptions other than AttributeError. Thanks to a bug |
|
2239 | raises exceptions other than AttributeError. Thanks to a bug | |
2217 | report by Oliver Sander <osander-AT-gmx.de>. |
|
2240 | report by Oliver Sander <osander-AT-gmx.de>. | |
2218 |
|
2241 | |||
2219 | * IPython/FakeModule.py (FakeModule.__repr__): this method was |
|
2242 | * IPython/FakeModule.py (FakeModule.__repr__): this method was | |
2220 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. |
|
2243 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. | |
2221 |
|
2244 | |||
2222 | 2003-09-09 Fernando Perez <fperez@colorado.edu> |
|
2245 | 2003-09-09 Fernando Perez <fperez@colorado.edu> | |
2223 |
|
2246 | |||
2224 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
2247 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
2225 | unpacking a list whith a callable as first element would |
|
2248 | unpacking a list whith a callable as first element would | |
2226 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery |
|
2249 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery | |
2227 | Collins. |
|
2250 | Collins. | |
2228 |
|
2251 | |||
2229 | 2003-08-25 *** Released version 0.5.0 |
|
2252 | 2003-08-25 *** Released version 0.5.0 | |
2230 |
|
2253 | |||
2231 | 2003-08-22 Fernando Perez <fperez@colorado.edu> |
|
2254 | 2003-08-22 Fernando Perez <fperez@colorado.edu> | |
2232 |
|
2255 | |||
2233 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of |
|
2256 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of | |
2234 | improperly defined user exceptions. Thanks to feedback from Mark |
|
2257 | improperly defined user exceptions. Thanks to feedback from Mark | |
2235 | Russell <mrussell-AT-verio.net>. |
|
2258 | Russell <mrussell-AT-verio.net>. | |
2236 |
|
2259 | |||
2237 | 2003-08-20 Fernando Perez <fperez@colorado.edu> |
|
2260 | 2003-08-20 Fernando Perez <fperez@colorado.edu> | |
2238 |
|
2261 | |||
2239 | * IPython/OInspect.py (Inspector.pinfo): changed String Form |
|
2262 | * IPython/OInspect.py (Inspector.pinfo): changed String Form | |
2240 | printing so that it would print multi-line string forms starting |
|
2263 | printing so that it would print multi-line string forms starting | |
2241 | with a new line. This way the formatting is better respected for |
|
2264 | with a new line. This way the formatting is better respected for | |
2242 | objects which work hard to make nice string forms. |
|
2265 | objects which work hard to make nice string forms. | |
2243 |
|
2266 | |||
2244 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where |
|
2267 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where | |
2245 | autocall would overtake data access for objects with both |
|
2268 | autocall would overtake data access for objects with both | |
2246 | __getitem__ and __call__. |
|
2269 | __getitem__ and __call__. | |
2247 |
|
2270 | |||
2248 | 2003-08-19 *** Released version 0.5.0-rc1 |
|
2271 | 2003-08-19 *** Released version 0.5.0-rc1 | |
2249 |
|
2272 | |||
2250 | 2003-08-19 Fernando Perez <fperez@colorado.edu> |
|
2273 | 2003-08-19 Fernando Perez <fperez@colorado.edu> | |
2251 |
|
2274 | |||
2252 | * IPython/deep_reload.py (load_tail): single tiny change here |
|
2275 | * IPython/deep_reload.py (load_tail): single tiny change here | |
2253 | seems to fix the long-standing bug of dreload() failing to work |
|
2276 | seems to fix the long-standing bug of dreload() failing to work | |
2254 | for dotted names. But this module is pretty tricky, so I may have |
|
2277 | for dotted names. But this module is pretty tricky, so I may have | |
2255 | missed some subtlety. Needs more testing!. |
|
2278 | missed some subtlety. Needs more testing!. | |
2256 |
|
2279 | |||
2257 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user |
|
2280 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user | |
2258 | exceptions which have badly implemented __str__ methods. |
|
2281 | exceptions which have badly implemented __str__ methods. | |
2259 | (VerboseTB.text): harden against inspect.getinnerframes crashing, |
|
2282 | (VerboseTB.text): harden against inspect.getinnerframes crashing, | |
2260 | which I've been getting reports about from Python 2.3 users. I |
|
2283 | which I've been getting reports about from Python 2.3 users. I | |
2261 | wish I had a simple test case to reproduce the problem, so I could |
|
2284 | wish I had a simple test case to reproduce the problem, so I could | |
2262 | either write a cleaner workaround or file a bug report if |
|
2285 | either write a cleaner workaround or file a bug report if | |
2263 | necessary. |
|
2286 | necessary. | |
2264 |
|
2287 | |||
2265 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after |
|
2288 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after | |
2266 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to |
|
2289 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to | |
2267 | a bug report by Tjabo Kloppenburg. |
|
2290 | a bug report by Tjabo Kloppenburg. | |
2268 |
|
2291 | |||
2269 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb |
|
2292 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb | |
2270 | crashes. Wrapped the pdb call in a blanket try/except, since pdb |
|
2293 | crashes. Wrapped the pdb call in a blanket try/except, since pdb | |
2271 | seems rather unstable. Thanks to a bug report by Tjabo |
|
2294 | seems rather unstable. Thanks to a bug report by Tjabo | |
2272 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. |
|
2295 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. | |
2273 |
|
2296 | |||
2274 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put |
|
2297 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put | |
2275 | this out soon because of the critical fixes in the inner loop for |
|
2298 | this out soon because of the critical fixes in the inner loop for | |
2276 | generators. |
|
2299 | generators. | |
2277 |
|
2300 | |||
2278 | * IPython/Magic.py (Magic.getargspec): removed. This (and |
|
2301 | * IPython/Magic.py (Magic.getargspec): removed. This (and | |
2279 | _get_def) have been obsoleted by OInspect for a long time, I |
|
2302 | _get_def) have been obsoleted by OInspect for a long time, I | |
2280 | hadn't noticed that they were dead code. |
|
2303 | hadn't noticed that they were dead code. | |
2281 | (Magic._ofind): restored _ofind functionality for a few literals |
|
2304 | (Magic._ofind): restored _ofind functionality for a few literals | |
2282 | (those in ["''",'""','[]','{}','()']). But it won't work anymore |
|
2305 | (those in ["''",'""','[]','{}','()']). But it won't work anymore | |
2283 | for things like "hello".capitalize?, since that would require a |
|
2306 | for things like "hello".capitalize?, since that would require a | |
2284 | potentially dangerous eval() again. |
|
2307 | potentially dangerous eval() again. | |
2285 |
|
2308 | |||
2286 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the |
|
2309 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the | |
2287 | logic a bit more to clean up the escapes handling and minimize the |
|
2310 | logic a bit more to clean up the escapes handling and minimize the | |
2288 | use of _ofind to only necessary cases. The interactive 'feel' of |
|
2311 | use of _ofind to only necessary cases. The interactive 'feel' of | |
2289 | IPython should have improved quite a bit with the changes in |
|
2312 | IPython should have improved quite a bit with the changes in | |
2290 | _prefilter and _ofind (besides being far safer than before). |
|
2313 | _prefilter and _ofind (besides being far safer than before). | |
2291 |
|
2314 | |||
2292 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather |
|
2315 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather | |
2293 | obscure, never reported). Edit would fail to find the object to |
|
2316 | obscure, never reported). Edit would fail to find the object to | |
2294 | edit under some circumstances. |
|
2317 | edit under some circumstances. | |
2295 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls |
|
2318 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls | |
2296 | which were causing double-calling of generators. Those eval calls |
|
2319 | which were causing double-calling of generators. Those eval calls | |
2297 | were _very_ dangerous, since code with side effects could be |
|
2320 | were _very_ dangerous, since code with side effects could be | |
2298 | triggered. As they say, 'eval is evil'... These were the |
|
2321 | triggered. As they say, 'eval is evil'... These were the | |
2299 | nastiest evals in IPython. Besides, _ofind is now far simpler, |
|
2322 | nastiest evals in IPython. Besides, _ofind is now far simpler, | |
2300 | and it should also be quite a bit faster. Its use of inspect is |
|
2323 | and it should also be quite a bit faster. Its use of inspect is | |
2301 | also safer, so perhaps some of the inspect-related crashes I've |
|
2324 | also safer, so perhaps some of the inspect-related crashes I've | |
2302 | seen lately with Python 2.3 might be taken care of. That will |
|
2325 | seen lately with Python 2.3 might be taken care of. That will | |
2303 | need more testing. |
|
2326 | need more testing. | |
2304 |
|
2327 | |||
2305 | 2003-08-17 Fernando Perez <fperez@colorado.edu> |
|
2328 | 2003-08-17 Fernando Perez <fperez@colorado.edu> | |
2306 |
|
2329 | |||
2307 | * IPython/iplib.py (InteractiveShell._prefilter): significant |
|
2330 | * IPython/iplib.py (InteractiveShell._prefilter): significant | |
2308 | simplifications to the logic for handling user escapes. Faster |
|
2331 | simplifications to the logic for handling user escapes. Faster | |
2309 | and simpler code. |
|
2332 | and simpler code. | |
2310 |
|
2333 | |||
2311 | 2003-08-14 Fernando Perez <fperez@colorado.edu> |
|
2334 | 2003-08-14 Fernando Perez <fperez@colorado.edu> | |
2312 |
|
2335 | |||
2313 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. |
|
2336 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. | |
2314 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, |
|
2337 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, | |
2315 | but it should be quite a bit faster. And the recursive version |
|
2338 | but it should be quite a bit faster. And the recursive version | |
2316 | generated O(log N) intermediate storage for all rank>1 arrays, |
|
2339 | generated O(log N) intermediate storage for all rank>1 arrays, | |
2317 | even if they were contiguous. |
|
2340 | even if they were contiguous. | |
2318 | (l1norm): Added this function. |
|
2341 | (l1norm): Added this function. | |
2319 | (norm): Added this function for arbitrary norms (including |
|
2342 | (norm): Added this function for arbitrary norms (including | |
2320 | l-infinity). l1 and l2 are still special cases for convenience |
|
2343 | l-infinity). l1 and l2 are still special cases for convenience | |
2321 | and speed. |
|
2344 | and speed. | |
2322 |
|
2345 | |||
2323 | 2003-08-03 Fernando Perez <fperez@colorado.edu> |
|
2346 | 2003-08-03 Fernando Perez <fperez@colorado.edu> | |
2324 |
|
2347 | |||
2325 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string |
|
2348 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string | |
2326 | exceptions, which now raise PendingDeprecationWarnings in Python |
|
2349 | exceptions, which now raise PendingDeprecationWarnings in Python | |
2327 | 2.3. There were some in Magic and some in Gnuplot2. |
|
2350 | 2.3. There were some in Magic and some in Gnuplot2. | |
2328 |
|
2351 | |||
2329 | 2003-06-30 Fernando Perez <fperez@colorado.edu> |
|
2352 | 2003-06-30 Fernando Perez <fperez@colorado.edu> | |
2330 |
|
2353 | |||
2331 | * IPython/genutils.py (page): modified to call curses only for |
|
2354 | * IPython/genutils.py (page): modified to call curses only for | |
2332 | terminals where TERM=='xterm'. After problems under many other |
|
2355 | terminals where TERM=='xterm'. After problems under many other | |
2333 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. |
|
2356 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. | |
2334 |
|
2357 | |||
2335 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which |
|
2358 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which | |
2336 | would be triggered when readline was absent. This was just an old |
|
2359 | would be triggered when readline was absent. This was just an old | |
2337 | debugging statement I'd forgotten to take out. |
|
2360 | debugging statement I'd forgotten to take out. | |
2338 |
|
2361 | |||
2339 | 2003-06-20 Fernando Perez <fperez@colorado.edu> |
|
2362 | 2003-06-20 Fernando Perez <fperez@colorado.edu> | |
2340 |
|
2363 | |||
2341 | * IPython/genutils.py (clock): modified to return only user time |
|
2364 | * IPython/genutils.py (clock): modified to return only user time | |
2342 | (not counting system time), after a discussion on scipy. While |
|
2365 | (not counting system time), after a discussion on scipy. While | |
2343 | system time may be a useful quantity occasionally, it may much |
|
2366 | system time may be a useful quantity occasionally, it may much | |
2344 | more easily be skewed by occasional swapping or other similar |
|
2367 | more easily be skewed by occasional swapping or other similar | |
2345 | activity. |
|
2368 | activity. | |
2346 |
|
2369 | |||
2347 | 2003-06-05 Fernando Perez <fperez@colorado.edu> |
|
2370 | 2003-06-05 Fernando Perez <fperez@colorado.edu> | |
2348 |
|
2371 | |||
2349 | * IPython/numutils.py (identity): new function, for building |
|
2372 | * IPython/numutils.py (identity): new function, for building | |
2350 | arbitrary rank Kronecker deltas (mostly backwards compatible with |
|
2373 | arbitrary rank Kronecker deltas (mostly backwards compatible with | |
2351 | Numeric.identity) |
|
2374 | Numeric.identity) | |
2352 |
|
2375 | |||
2353 | 2003-06-03 Fernando Perez <fperez@colorado.edu> |
|
2376 | 2003-06-03 Fernando Perez <fperez@colorado.edu> | |
2354 |
|
2377 | |||
2355 | * IPython/iplib.py (InteractiveShell.handle_magic): protect |
|
2378 | * IPython/iplib.py (InteractiveShell.handle_magic): protect | |
2356 | arguments passed to magics with spaces, to allow trailing '\' to |
|
2379 | arguments passed to magics with spaces, to allow trailing '\' to | |
2357 | work normally (mainly for Windows users). |
|
2380 | work normally (mainly for Windows users). | |
2358 |
|
2381 | |||
2359 | 2003-05-29 Fernando Perez <fperez@colorado.edu> |
|
2382 | 2003-05-29 Fernando Perez <fperez@colorado.edu> | |
2360 |
|
2383 | |||
2361 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help |
|
2384 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help | |
2362 | instead of pydoc.help. This fixes a bizarre behavior where |
|
2385 | instead of pydoc.help. This fixes a bizarre behavior where | |
2363 | printing '%s' % locals() would trigger the help system. Now |
|
2386 | printing '%s' % locals() would trigger the help system. Now | |
2364 | ipython behaves like normal python does. |
|
2387 | ipython behaves like normal python does. | |
2365 |
|
2388 | |||
2366 | Note that if one does 'from pydoc import help', the bizarre |
|
2389 | Note that if one does 'from pydoc import help', the bizarre | |
2367 | behavior returns, but this will also happen in normal python, so |
|
2390 | behavior returns, but this will also happen in normal python, so | |
2368 | it's not an ipython bug anymore (it has to do with how pydoc.help |
|
2391 | it's not an ipython bug anymore (it has to do with how pydoc.help | |
2369 | is implemented). |
|
2392 | is implemented). | |
2370 |
|
2393 | |||
2371 | 2003-05-22 Fernando Perez <fperez@colorado.edu> |
|
2394 | 2003-05-22 Fernando Perez <fperez@colorado.edu> | |
2372 |
|
2395 | |||
2373 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to |
|
2396 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to | |
2374 | return [] instead of None when nothing matches, also match to end |
|
2397 | return [] instead of None when nothing matches, also match to end | |
2375 | of line. Patch by Gary Bishop. |
|
2398 | of line. Patch by Gary Bishop. | |
2376 |
|
2399 | |||
2377 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook |
|
2400 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook | |
2378 | protection as before, for files passed on the command line. This |
|
2401 | protection as before, for files passed on the command line. This | |
2379 | prevents the CrashHandler from kicking in if user files call into |
|
2402 | prevents the CrashHandler from kicking in if user files call into | |
2380 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of |
|
2403 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of | |
2381 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> |
|
2404 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> | |
2382 |
|
2405 | |||
2383 | 2003-05-20 *** Released version 0.4.0 |
|
2406 | 2003-05-20 *** Released version 0.4.0 | |
2384 |
|
2407 | |||
2385 | 2003-05-20 Fernando Perez <fperez@colorado.edu> |
|
2408 | 2003-05-20 Fernando Perez <fperez@colorado.edu> | |
2386 |
|
2409 | |||
2387 | * setup.py: added support for manpages. It's a bit hackish b/c of |
|
2410 | * setup.py: added support for manpages. It's a bit hackish b/c of | |
2388 | a bug in the way the bdist_rpm distutils target handles gzipped |
|
2411 | a bug in the way the bdist_rpm distutils target handles gzipped | |
2389 | manpages, but it works. After a patch by Jack. |
|
2412 | manpages, but it works. After a patch by Jack. | |
2390 |
|
2413 | |||
2391 | 2003-05-19 Fernando Perez <fperez@colorado.edu> |
|
2414 | 2003-05-19 Fernando Perez <fperez@colorado.edu> | |
2392 |
|
2415 | |||
2393 | * IPython/numutils.py: added a mockup of the kinds module, since |
|
2416 | * IPython/numutils.py: added a mockup of the kinds module, since | |
2394 | it was recently removed from Numeric. This way, numutils will |
|
2417 | it was recently removed from Numeric. This way, numutils will | |
2395 | work for all users even if they are missing kinds. |
|
2418 | work for all users even if they are missing kinds. | |
2396 |
|
2419 | |||
2397 | * IPython/Magic.py (Magic._ofind): Harden against an inspect |
|
2420 | * IPython/Magic.py (Magic._ofind): Harden against an inspect | |
2398 | failure, which can occur with SWIG-wrapped extensions. After a |
|
2421 | failure, which can occur with SWIG-wrapped extensions. After a | |
2399 | crash report from Prabhu. |
|
2422 | crash report from Prabhu. | |
2400 |
|
2423 | |||
2401 | 2003-05-16 Fernando Perez <fperez@colorado.edu> |
|
2424 | 2003-05-16 Fernando Perez <fperez@colorado.edu> | |
2402 |
|
2425 | |||
2403 | * IPython/iplib.py (InteractiveShell.excepthook): New method to |
|
2426 | * IPython/iplib.py (InteractiveShell.excepthook): New method to | |
2404 | protect ipython from user code which may call directly |
|
2427 | protect ipython from user code which may call directly | |
2405 | sys.excepthook (this looks like an ipython crash to the user, even |
|
2428 | sys.excepthook (this looks like an ipython crash to the user, even | |
2406 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2429 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2407 | This is especially important to help users of WxWindows, but may |
|
2430 | This is especially important to help users of WxWindows, but may | |
2408 | also be useful in other cases. |
|
2431 | also be useful in other cases. | |
2409 |
|
2432 | |||
2410 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow |
|
2433 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow | |
2411 | an optional tb_offset to be specified, and to preserve exception |
|
2434 | an optional tb_offset to be specified, and to preserve exception | |
2412 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2435 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2413 |
|
2436 | |||
2414 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! |
|
2437 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! | |
2415 |
|
2438 | |||
2416 | 2003-05-15 Fernando Perez <fperez@colorado.edu> |
|
2439 | 2003-05-15 Fernando Perez <fperez@colorado.edu> | |
2417 |
|
2440 | |||
2418 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when |
|
2441 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when | |
2419 | installing for a new user under Windows. |
|
2442 | installing for a new user under Windows. | |
2420 |
|
2443 | |||
2421 | 2003-05-12 Fernando Perez <fperez@colorado.edu> |
|
2444 | 2003-05-12 Fernando Perez <fperez@colorado.edu> | |
2422 |
|
2445 | |||
2423 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line |
|
2446 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line | |
2424 | handler for Emacs comint-based lines. Currently it doesn't do |
|
2447 | handler for Emacs comint-based lines. Currently it doesn't do | |
2425 | much (but importantly, it doesn't update the history cache). In |
|
2448 | much (but importantly, it doesn't update the history cache). In | |
2426 | the future it may be expanded if Alex needs more functionality |
|
2449 | the future it may be expanded if Alex needs more functionality | |
2427 | there. |
|
2450 | there. | |
2428 |
|
2451 | |||
2429 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform |
|
2452 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform | |
2430 | info to crash reports. |
|
2453 | info to crash reports. | |
2431 |
|
2454 | |||
2432 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, |
|
2455 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, | |
2433 | just like Python's -c. Also fixed crash with invalid -color |
|
2456 | just like Python's -c. Also fixed crash with invalid -color | |
2434 | option value at startup. Thanks to Will French |
|
2457 | option value at startup. Thanks to Will French | |
2435 | <wfrench-AT-bestweb.net> for the bug report. |
|
2458 | <wfrench-AT-bestweb.net> for the bug report. | |
2436 |
|
2459 | |||
2437 | 2003-05-09 Fernando Perez <fperez@colorado.edu> |
|
2460 | 2003-05-09 Fernando Perez <fperez@colorado.edu> | |
2438 |
|
2461 | |||
2439 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString |
|
2462 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString | |
2440 | to EvalDict (it's a mapping, after all) and simplified its code |
|
2463 | to EvalDict (it's a mapping, after all) and simplified its code | |
2441 | quite a bit, after a nice discussion on c.l.py where Gustavo |
|
2464 | quite a bit, after a nice discussion on c.l.py where Gustavo | |
2442 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. |
|
2465 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. | |
2443 |
|
2466 | |||
2444 | 2003-04-30 Fernando Perez <fperez@colorado.edu> |
|
2467 | 2003-04-30 Fernando Perez <fperez@colorado.edu> | |
2445 |
|
2468 | |||
2446 | * IPython/genutils.py (timings_out): modified it to reduce its |
|
2469 | * IPython/genutils.py (timings_out): modified it to reduce its | |
2447 | overhead in the common reps==1 case. |
|
2470 | overhead in the common reps==1 case. | |
2448 |
|
2471 | |||
2449 | 2003-04-29 Fernando Perez <fperez@colorado.edu> |
|
2472 | 2003-04-29 Fernando Perez <fperez@colorado.edu> | |
2450 |
|
2473 | |||
2451 | * IPython/genutils.py (timings_out): Modified to use the resource |
|
2474 | * IPython/genutils.py (timings_out): Modified to use the resource | |
2452 | module, which avoids the wraparound problems of time.clock(). |
|
2475 | module, which avoids the wraparound problems of time.clock(). | |
2453 |
|
2476 | |||
2454 | 2003-04-17 *** Released version 0.2.15pre4 |
|
2477 | 2003-04-17 *** Released version 0.2.15pre4 | |
2455 |
|
2478 | |||
2456 | 2003-04-17 Fernando Perez <fperez@colorado.edu> |
|
2479 | 2003-04-17 Fernando Perez <fperez@colorado.edu> | |
2457 |
|
2480 | |||
2458 | * setup.py (scriptfiles): Split windows-specific stuff over to a |
|
2481 | * setup.py (scriptfiles): Split windows-specific stuff over to a | |
2459 | separate file, in an attempt to have a Windows GUI installer. |
|
2482 | separate file, in an attempt to have a Windows GUI installer. | |
2460 | That didn't work, but part of the groundwork is done. |
|
2483 | That didn't work, but part of the groundwork is done. | |
2461 |
|
2484 | |||
2462 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for |
|
2485 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for | |
2463 | indent/unindent with 4 spaces. Particularly useful in combination |
|
2486 | indent/unindent with 4 spaces. Particularly useful in combination | |
2464 | with the new auto-indent option. |
|
2487 | with the new auto-indent option. | |
2465 |
|
2488 | |||
2466 | 2003-04-16 Fernando Perez <fperez@colorado.edu> |
|
2489 | 2003-04-16 Fernando Perez <fperez@colorado.edu> | |
2467 |
|
2490 | |||
2468 | * IPython/Magic.py: various replacements of self.rc for |
|
2491 | * IPython/Magic.py: various replacements of self.rc for | |
2469 | self.shell.rc. A lot more remains to be done to fully disentangle |
|
2492 | self.shell.rc. A lot more remains to be done to fully disentangle | |
2470 | this class from the main Shell class. |
|
2493 | this class from the main Shell class. | |
2471 |
|
2494 | |||
2472 | * IPython/GnuplotRuntime.py: added checks for mouse support so |
|
2495 | * IPython/GnuplotRuntime.py: added checks for mouse support so | |
2473 | that we don't try to enable it if the current gnuplot doesn't |
|
2496 | that we don't try to enable it if the current gnuplot doesn't | |
2474 | really support it. Also added checks so that we don't try to |
|
2497 | really support it. Also added checks so that we don't try to | |
2475 | enable persist under Windows (where Gnuplot doesn't recognize the |
|
2498 | enable persist under Windows (where Gnuplot doesn't recognize the | |
2476 | option). |
|
2499 | option). | |
2477 |
|
2500 | |||
2478 | * IPython/iplib.py (InteractiveShell.interact): Added optional |
|
2501 | * IPython/iplib.py (InteractiveShell.interact): Added optional | |
2479 | auto-indenting code, after a patch by King C. Shu |
|
2502 | auto-indenting code, after a patch by King C. Shu | |
2480 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't |
|
2503 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't | |
2481 | get along well with pasting indented code. If I ever figure out |
|
2504 | get along well with pasting indented code. If I ever figure out | |
2482 | how to make that part go well, it will become on by default. |
|
2505 | how to make that part go well, it will become on by default. | |
2483 |
|
2506 | |||
2484 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would |
|
2507 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would | |
2485 | crash ipython if there was an unmatched '%' in the user's prompt |
|
2508 | crash ipython if there was an unmatched '%' in the user's prompt | |
2486 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2509 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2487 |
|
2510 | |||
2488 | * IPython/iplib.py (InteractiveShell.interact): removed the |
|
2511 | * IPython/iplib.py (InteractiveShell.interact): removed the | |
2489 | ability to ask the user whether he wants to crash or not at the |
|
2512 | ability to ask the user whether he wants to crash or not at the | |
2490 | 'last line' exception handler. Calling functions at that point |
|
2513 | 'last line' exception handler. Calling functions at that point | |
2491 | changes the stack, and the error reports would have incorrect |
|
2514 | changes the stack, and the error reports would have incorrect | |
2492 | tracebacks. |
|
2515 | tracebacks. | |
2493 |
|
2516 | |||
2494 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to |
|
2517 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to | |
2495 | pass through a peger a pretty-printed form of any object. After a |
|
2518 | pass through a peger a pretty-printed form of any object. After a | |
2496 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> |
|
2519 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> | |
2497 |
|
2520 | |||
2498 | 2003-04-14 Fernando Perez <fperez@colorado.edu> |
|
2521 | 2003-04-14 Fernando Perez <fperez@colorado.edu> | |
2499 |
|
2522 | |||
2500 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where |
|
2523 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where | |
2501 | all files in ~ would be modified at first install (instead of |
|
2524 | all files in ~ would be modified at first install (instead of | |
2502 | ~/.ipython). This could be potentially disastrous, as the |
|
2525 | ~/.ipython). This could be potentially disastrous, as the | |
2503 | modification (make line-endings native) could damage binary files. |
|
2526 | modification (make line-endings native) could damage binary files. | |
2504 |
|
2527 | |||
2505 | 2003-04-10 Fernando Perez <fperez@colorado.edu> |
|
2528 | 2003-04-10 Fernando Perez <fperez@colorado.edu> | |
2506 |
|
2529 | |||
2507 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to |
|
2530 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to | |
2508 | handle only lines which are invalid python. This now means that |
|
2531 | handle only lines which are invalid python. This now means that | |
2509 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins |
|
2532 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins | |
2510 | for the bug report. |
|
2533 | for the bug report. | |
2511 |
|
2534 | |||
2512 | 2003-04-01 Fernando Perez <fperez@colorado.edu> |
|
2535 | 2003-04-01 Fernando Perez <fperez@colorado.edu> | |
2513 |
|
2536 | |||
2514 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug |
|
2537 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug | |
2515 | where failing to set sys.last_traceback would crash pdb.pm(). |
|
2538 | where failing to set sys.last_traceback would crash pdb.pm(). | |
2516 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug |
|
2539 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug | |
2517 | report. |
|
2540 | report. | |
2518 |
|
2541 | |||
2519 | 2003-03-25 Fernando Perez <fperez@colorado.edu> |
|
2542 | 2003-03-25 Fernando Perez <fperez@colorado.edu> | |
2520 |
|
2543 | |||
2521 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler |
|
2544 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler | |
2522 | before printing it (it had a lot of spurious blank lines at the |
|
2545 | before printing it (it had a lot of spurious blank lines at the | |
2523 | end). |
|
2546 | end). | |
2524 |
|
2547 | |||
2525 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr |
|
2548 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr | |
2526 | output would be sent 21 times! Obviously people don't use this |
|
2549 | output would be sent 21 times! Obviously people don't use this | |
2527 | too often, or I would have heard about it. |
|
2550 | too often, or I would have heard about it. | |
2528 |
|
2551 | |||
2529 | 2003-03-24 Fernando Perez <fperez@colorado.edu> |
|
2552 | 2003-03-24 Fernando Perez <fperez@colorado.edu> | |
2530 |
|
2553 | |||
2531 | * setup.py (scriptfiles): renamed the data_files parameter from |
|
2554 | * setup.py (scriptfiles): renamed the data_files parameter from | |
2532 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink |
|
2555 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink | |
2533 | for the patch. |
|
2556 | for the patch. | |
2534 |
|
2557 | |||
2535 | 2003-03-20 Fernando Perez <fperez@colorado.edu> |
|
2558 | 2003-03-20 Fernando Perez <fperez@colorado.edu> | |
2536 |
|
2559 | |||
2537 | * IPython/genutils.py (error): added error() and fatal() |
|
2560 | * IPython/genutils.py (error): added error() and fatal() | |
2538 | functions. |
|
2561 | functions. | |
2539 |
|
2562 | |||
2540 | 2003-03-18 *** Released version 0.2.15pre3 |
|
2563 | 2003-03-18 *** Released version 0.2.15pre3 | |
2541 |
|
2564 | |||
2542 | 2003-03-18 Fernando Perez <fperez@colorado.edu> |
|
2565 | 2003-03-18 Fernando Perez <fperez@colorado.edu> | |
2543 |
|
2566 | |||
2544 | * setupext/install_data_ext.py |
|
2567 | * setupext/install_data_ext.py | |
2545 | (install_data_ext.initialize_options): Class contributed by Jack |
|
2568 | (install_data_ext.initialize_options): Class contributed by Jack | |
2546 | Moffit for fixing the old distutils hack. He is sending this to |
|
2569 | Moffit for fixing the old distutils hack. He is sending this to | |
2547 | the distutils folks so in the future we may not need it as a |
|
2570 | the distutils folks so in the future we may not need it as a | |
2548 | private fix. |
|
2571 | private fix. | |
2549 |
|
2572 | |||
2550 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's |
|
2573 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's | |
2551 | changes for Debian packaging. See his patch for full details. |
|
2574 | changes for Debian packaging. See his patch for full details. | |
2552 | The old distutils hack of making the ipythonrc* files carry a |
|
2575 | The old distutils hack of making the ipythonrc* files carry a | |
2553 | bogus .py extension is gone, at last. Examples were moved to a |
|
2576 | bogus .py extension is gone, at last. Examples were moved to a | |
2554 | separate subdir under doc/, and the separate executable scripts |
|
2577 | separate subdir under doc/, and the separate executable scripts | |
2555 | now live in their own directory. Overall a great cleanup. The |
|
2578 | now live in their own directory. Overall a great cleanup. The | |
2556 | manual was updated to use the new files, and setup.py has been |
|
2579 | manual was updated to use the new files, and setup.py has been | |
2557 | fixed for this setup. |
|
2580 | fixed for this setup. | |
2558 |
|
2581 | |||
2559 | * IPython/PyColorize.py (Parser.usage): made non-executable and |
|
2582 | * IPython/PyColorize.py (Parser.usage): made non-executable and | |
2560 | created a pycolor wrapper around it to be included as a script. |
|
2583 | created a pycolor wrapper around it to be included as a script. | |
2561 |
|
2584 | |||
2562 | 2003-03-12 *** Released version 0.2.15pre2 |
|
2585 | 2003-03-12 *** Released version 0.2.15pre2 | |
2563 |
|
2586 | |||
2564 | 2003-03-12 Fernando Perez <fperez@colorado.edu> |
|
2587 | 2003-03-12 Fernando Perez <fperez@colorado.edu> | |
2565 |
|
2588 | |||
2566 | * IPython/ColorANSI.py (make_color_table): Finally fixed the |
|
2589 | * IPython/ColorANSI.py (make_color_table): Finally fixed the | |
2567 | long-standing problem with garbage characters in some terminals. |
|
2590 | long-standing problem with garbage characters in some terminals. | |
2568 | The issue was really that the \001 and \002 escapes must _only_ be |
|
2591 | The issue was really that the \001 and \002 escapes must _only_ be | |
2569 | passed to input prompts (which call readline), but _never_ to |
|
2592 | passed to input prompts (which call readline), but _never_ to | |
2570 | normal text to be printed on screen. I changed ColorANSI to have |
|
2593 | normal text to be printed on screen. I changed ColorANSI to have | |
2571 | two classes: TermColors and InputTermColors, each with the |
|
2594 | two classes: TermColors and InputTermColors, each with the | |
2572 | appropriate escapes for input prompts or normal text. The code in |
|
2595 | appropriate escapes for input prompts or normal text. The code in | |
2573 | Prompts.py got slightly more complicated, but this very old and |
|
2596 | Prompts.py got slightly more complicated, but this very old and | |
2574 | annoying bug is finally fixed. |
|
2597 | annoying bug is finally fixed. | |
2575 |
|
2598 | |||
2576 | All the credit for nailing down the real origin of this problem |
|
2599 | All the credit for nailing down the real origin of this problem | |
2577 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. |
|
2600 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. | |
2578 | *Many* thanks to him for spending quite a bit of effort on this. |
|
2601 | *Many* thanks to him for spending quite a bit of effort on this. | |
2579 |
|
2602 | |||
2580 | 2003-03-05 *** Released version 0.2.15pre1 |
|
2603 | 2003-03-05 *** Released version 0.2.15pre1 | |
2581 |
|
2604 | |||
2582 | 2003-03-03 Fernando Perez <fperez@colorado.edu> |
|
2605 | 2003-03-03 Fernando Perez <fperez@colorado.edu> | |
2583 |
|
2606 | |||
2584 | * IPython/FakeModule.py: Moved the former _FakeModule to a |
|
2607 | * IPython/FakeModule.py: Moved the former _FakeModule to a | |
2585 | separate file, because it's also needed by Magic (to fix a similar |
|
2608 | separate file, because it's also needed by Magic (to fix a similar | |
2586 | pickle-related issue in @run). |
|
2609 | pickle-related issue in @run). | |
2587 |
|
2610 | |||
2588 | 2003-03-02 Fernando Perez <fperez@colorado.edu> |
|
2611 | 2003-03-02 Fernando Perez <fperez@colorado.edu> | |
2589 |
|
2612 | |||
2590 | * IPython/Magic.py (Magic.magic_autocall): new magic to control |
|
2613 | * IPython/Magic.py (Magic.magic_autocall): new magic to control | |
2591 | the autocall option at runtime. |
|
2614 | the autocall option at runtime. | |
2592 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns |
|
2615 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns | |
2593 | across Magic.py to start separating Magic from InteractiveShell. |
|
2616 | across Magic.py to start separating Magic from InteractiveShell. | |
2594 | (Magic._ofind): Fixed to return proper namespace for dotted |
|
2617 | (Magic._ofind): Fixed to return proper namespace for dotted | |
2595 | names. Before, a dotted name would always return 'not currently |
|
2618 | names. Before, a dotted name would always return 'not currently | |
2596 | defined', because it would find the 'parent'. s.x would be found, |
|
2619 | defined', because it would find the 'parent'. s.x would be found, | |
2597 | but since 'x' isn't defined by itself, it would get confused. |
|
2620 | but since 'x' isn't defined by itself, it would get confused. | |
2598 | (Magic.magic_run): Fixed pickling problems reported by Ralf |
|
2621 | (Magic.magic_run): Fixed pickling problems reported by Ralf | |
2599 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to |
|
2622 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to | |
2600 | that I'd used when Mike Heeter reported similar issues at the |
|
2623 | that I'd used when Mike Heeter reported similar issues at the | |
2601 | top-level, but now for @run. It boils down to injecting the |
|
2624 | top-level, but now for @run. It boils down to injecting the | |
2602 | namespace where code is being executed with something that looks |
|
2625 | namespace where code is being executed with something that looks | |
2603 | enough like a module to fool pickle.dump(). Since a pickle stores |
|
2626 | enough like a module to fool pickle.dump(). Since a pickle stores | |
2604 | a named reference to the importing module, we need this for |
|
2627 | a named reference to the importing module, we need this for | |
2605 | pickles to save something sensible. |
|
2628 | pickles to save something sensible. | |
2606 |
|
2629 | |||
2607 | * IPython/ipmaker.py (make_IPython): added an autocall option. |
|
2630 | * IPython/ipmaker.py (make_IPython): added an autocall option. | |
2608 |
|
2631 | |||
2609 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of |
|
2632 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of | |
2610 | the auto-eval code. Now autocalling is an option, and the code is |
|
2633 | the auto-eval code. Now autocalling is an option, and the code is | |
2611 | also vastly safer. There is no more eval() involved at all. |
|
2634 | also vastly safer. There is no more eval() involved at all. | |
2612 |
|
2635 | |||
2613 | 2003-03-01 Fernando Perez <fperez@colorado.edu> |
|
2636 | 2003-03-01 Fernando Perez <fperez@colorado.edu> | |
2614 |
|
2637 | |||
2615 | * IPython/Magic.py (Magic._ofind): Changed interface to return a |
|
2638 | * IPython/Magic.py (Magic._ofind): Changed interface to return a | |
2616 | dict with named keys instead of a tuple. |
|
2639 | dict with named keys instead of a tuple. | |
2617 |
|
2640 | |||
2618 | * IPython: Started using CVS for IPython as of 0.2.15pre1. |
|
2641 | * IPython: Started using CVS for IPython as of 0.2.15pre1. | |
2619 |
|
2642 | |||
2620 | * setup.py (make_shortcut): Fixed message about directories |
|
2643 | * setup.py (make_shortcut): Fixed message about directories | |
2621 | created during Windows installation (the directories were ok, just |
|
2644 | created during Windows installation (the directories were ok, just | |
2622 | the printed message was misleading). Thanks to Chris Liechti |
|
2645 | the printed message was misleading). Thanks to Chris Liechti | |
2623 | <cliechti-AT-gmx.net> for the heads up. |
|
2646 | <cliechti-AT-gmx.net> for the heads up. | |
2624 |
|
2647 | |||
2625 | 2003-02-21 Fernando Perez <fperez@colorado.edu> |
|
2648 | 2003-02-21 Fernando Perez <fperez@colorado.edu> | |
2626 |
|
2649 | |||
2627 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching |
|
2650 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching | |
2628 | of ValueError exception when checking for auto-execution. This |
|
2651 | of ValueError exception when checking for auto-execution. This | |
2629 | one is raised by things like Numeric arrays arr.flat when the |
|
2652 | one is raised by things like Numeric arrays arr.flat when the | |
2630 | array is non-contiguous. |
|
2653 | array is non-contiguous. | |
2631 |
|
2654 | |||
2632 | 2003-01-31 Fernando Perez <fperez@colorado.edu> |
|
2655 | 2003-01-31 Fernando Perez <fperez@colorado.edu> | |
2633 |
|
2656 | |||
2634 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would |
|
2657 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would | |
2635 | not return any value at all (even though the command would get |
|
2658 | not return any value at all (even though the command would get | |
2636 | executed). |
|
2659 | executed). | |
2637 | (xsys): Flush stdout right after printing the command to ensure |
|
2660 | (xsys): Flush stdout right after printing the command to ensure | |
2638 | proper ordering of commands and command output in the total |
|
2661 | proper ordering of commands and command output in the total | |
2639 | output. |
|
2662 | output. | |
2640 | (SystemExec/xsys/bq): Switched the names of xsys/bq and |
|
2663 | (SystemExec/xsys/bq): Switched the names of xsys/bq and | |
2641 | system/getoutput as defaults. The old ones are kept for |
|
2664 | system/getoutput as defaults. The old ones are kept for | |
2642 | compatibility reasons, so no code which uses this library needs |
|
2665 | compatibility reasons, so no code which uses this library needs | |
2643 | changing. |
|
2666 | changing. | |
2644 |
|
2667 | |||
2645 | 2003-01-27 *** Released version 0.2.14 |
|
2668 | 2003-01-27 *** Released version 0.2.14 | |
2646 |
|
2669 | |||
2647 | 2003-01-25 Fernando Perez <fperez@colorado.edu> |
|
2670 | 2003-01-25 Fernando Perez <fperez@colorado.edu> | |
2648 |
|
2671 | |||
2649 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where |
|
2672 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where | |
2650 | functions defined in previous edit sessions could not be re-edited |
|
2673 | functions defined in previous edit sessions could not be re-edited | |
2651 | (because the temp files were immediately removed). Now temp files |
|
2674 | (because the temp files were immediately removed). Now temp files | |
2652 | are removed only at IPython's exit. |
|
2675 | are removed only at IPython's exit. | |
2653 | (Magic.magic_run): Improved @run to perform shell-like expansions |
|
2676 | (Magic.magic_run): Improved @run to perform shell-like expansions | |
2654 | on its arguments (~users and $VARS). With this, @run becomes more |
|
2677 | on its arguments (~users and $VARS). With this, @run becomes more | |
2655 | like a normal command-line. |
|
2678 | like a normal command-line. | |
2656 |
|
2679 | |||
2657 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small |
|
2680 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small | |
2658 | bugs related to embedding and cleaned up that code. A fairly |
|
2681 | bugs related to embedding and cleaned up that code. A fairly | |
2659 | important one was the impossibility to access the global namespace |
|
2682 | important one was the impossibility to access the global namespace | |
2660 | through the embedded IPython (only local variables were visible). |
|
2683 | through the embedded IPython (only local variables were visible). | |
2661 |
|
2684 | |||
2662 | 2003-01-14 Fernando Perez <fperez@colorado.edu> |
|
2685 | 2003-01-14 Fernando Perez <fperez@colorado.edu> | |
2663 |
|
2686 | |||
2664 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed |
|
2687 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed | |
2665 | auto-calling to be a bit more conservative. Now it doesn't get |
|
2688 | auto-calling to be a bit more conservative. Now it doesn't get | |
2666 | triggered if any of '!=()<>' are in the rest of the input line, to |
|
2689 | triggered if any of '!=()<>' are in the rest of the input line, to | |
2667 | allow comparing callables. Thanks to Alex for the heads up. |
|
2690 | allow comparing callables. Thanks to Alex for the heads up. | |
2668 |
|
2691 | |||
2669 | 2003-01-07 Fernando Perez <fperez@colorado.edu> |
|
2692 | 2003-01-07 Fernando Perez <fperez@colorado.edu> | |
2670 |
|
2693 | |||
2671 | * IPython/genutils.py (page): fixed estimation of the number of |
|
2694 | * IPython/genutils.py (page): fixed estimation of the number of | |
2672 | lines in a string to be paged to simply count newlines. This |
|
2695 | lines in a string to be paged to simply count newlines. This | |
2673 | prevents over-guessing due to embedded escape sequences. A better |
|
2696 | prevents over-guessing due to embedded escape sequences. A better | |
2674 | long-term solution would involve stripping out the control chars |
|
2697 | long-term solution would involve stripping out the control chars | |
2675 | for the count, but it's potentially so expensive I just don't |
|
2698 | for the count, but it's potentially so expensive I just don't | |
2676 | think it's worth doing. |
|
2699 | think it's worth doing. | |
2677 |
|
2700 | |||
2678 | 2002-12-19 *** Released version 0.2.14pre50 |
|
2701 | 2002-12-19 *** Released version 0.2.14pre50 | |
2679 |
|
2702 | |||
2680 | 2002-12-19 Fernando Perez <fperez@colorado.edu> |
|
2703 | 2002-12-19 Fernando Perez <fperez@colorado.edu> | |
2681 |
|
2704 | |||
2682 | * tools/release (version): Changed release scripts to inform |
|
2705 | * tools/release (version): Changed release scripts to inform | |
2683 | Andrea and build a NEWS file with a list of recent changes. |
|
2706 | Andrea and build a NEWS file with a list of recent changes. | |
2684 |
|
2707 | |||
2685 | * IPython/ColorANSI.py (__all__): changed terminal detection |
|
2708 | * IPython/ColorANSI.py (__all__): changed terminal detection | |
2686 | code. Seems to work better for xterms without breaking |
|
2709 | code. Seems to work better for xterms without breaking | |
2687 | konsole. Will need more testing to determine if WinXP and Mac OSX |
|
2710 | konsole. Will need more testing to determine if WinXP and Mac OSX | |
2688 | also work ok. |
|
2711 | also work ok. | |
2689 |
|
2712 | |||
2690 | 2002-12-18 *** Released version 0.2.14pre49 |
|
2713 | 2002-12-18 *** Released version 0.2.14pre49 | |
2691 |
|
2714 | |||
2692 | 2002-12-18 Fernando Perez <fperez@colorado.edu> |
|
2715 | 2002-12-18 Fernando Perez <fperez@colorado.edu> | |
2693 |
|
2716 | |||
2694 | * Docs: added new info about Mac OSX, from Andrea. |
|
2717 | * Docs: added new info about Mac OSX, from Andrea. | |
2695 |
|
2718 | |||
2696 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to |
|
2719 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to | |
2697 | allow direct plotting of python strings whose format is the same |
|
2720 | allow direct plotting of python strings whose format is the same | |
2698 | of gnuplot data files. |
|
2721 | of gnuplot data files. | |
2699 |
|
2722 | |||
2700 | 2002-12-16 Fernando Perez <fperez@colorado.edu> |
|
2723 | 2002-12-16 Fernando Perez <fperez@colorado.edu> | |
2701 |
|
2724 | |||
2702 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) |
|
2725 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) | |
2703 | value of exit question to be acknowledged. |
|
2726 | value of exit question to be acknowledged. | |
2704 |
|
2727 | |||
2705 | 2002-12-03 Fernando Perez <fperez@colorado.edu> |
|
2728 | 2002-12-03 Fernando Perez <fperez@colorado.edu> | |
2706 |
|
2729 | |||
2707 | * IPython/ipmaker.py: removed generators, which had been added |
|
2730 | * IPython/ipmaker.py: removed generators, which had been added | |
2708 | by mistake in an earlier debugging run. This was causing trouble |
|
2731 | by mistake in an earlier debugging run. This was causing trouble | |
2709 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> |
|
2732 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> | |
2710 | for pointing this out. |
|
2733 | for pointing this out. | |
2711 |
|
2734 | |||
2712 | 2002-11-17 Fernando Perez <fperez@colorado.edu> |
|
2735 | 2002-11-17 Fernando Perez <fperez@colorado.edu> | |
2713 |
|
2736 | |||
2714 | * Manual: updated the Gnuplot section. |
|
2737 | * Manual: updated the Gnuplot section. | |
2715 |
|
2738 | |||
2716 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with |
|
2739 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with | |
2717 | a much better split of what goes in Runtime and what goes in |
|
2740 | a much better split of what goes in Runtime and what goes in | |
2718 | Interactive. |
|
2741 | Interactive. | |
2719 |
|
2742 | |||
2720 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't |
|
2743 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't | |
2721 | being imported from iplib. |
|
2744 | being imported from iplib. | |
2722 |
|
2745 | |||
2723 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc |
|
2746 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc | |
2724 | for command-passing. Now the global Gnuplot instance is called |
|
2747 | for command-passing. Now the global Gnuplot instance is called | |
2725 | 'gp' instead of 'g', which was really a far too fragile and |
|
2748 | 'gp' instead of 'g', which was really a far too fragile and | |
2726 | common name. |
|
2749 | common name. | |
2727 |
|
2750 | |||
2728 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken |
|
2751 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken | |
2729 | bounding boxes generated by Gnuplot for square plots. |
|
2752 | bounding boxes generated by Gnuplot for square plots. | |
2730 |
|
2753 | |||
2731 | * IPython/genutils.py (popkey): new function added. I should |
|
2754 | * IPython/genutils.py (popkey): new function added. I should | |
2732 | suggest this on c.l.py as a dict method, it seems useful. |
|
2755 | suggest this on c.l.py as a dict method, it seems useful. | |
2733 |
|
2756 | |||
2734 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot |
|
2757 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot | |
2735 | to transparently handle PostScript generation. MUCH better than |
|
2758 | to transparently handle PostScript generation. MUCH better than | |
2736 | the previous plot_eps/replot_eps (which I removed now). The code |
|
2759 | the previous plot_eps/replot_eps (which I removed now). The code | |
2737 | is also fairly clean and well documented now (including |
|
2760 | is also fairly clean and well documented now (including | |
2738 | docstrings). |
|
2761 | docstrings). | |
2739 |
|
2762 | |||
2740 | 2002-11-13 Fernando Perez <fperez@colorado.edu> |
|
2763 | 2002-11-13 Fernando Perez <fperez@colorado.edu> | |
2741 |
|
2764 | |||
2742 | * IPython/Magic.py (Magic.magic_edit): fixed docstring |
|
2765 | * IPython/Magic.py (Magic.magic_edit): fixed docstring | |
2743 | (inconsistent with options). |
|
2766 | (inconsistent with options). | |
2744 |
|
2767 | |||
2745 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been |
|
2768 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been | |
2746 | manually disabled, I don't know why. Fixed it. |
|
2769 | manually disabled, I don't know why. Fixed it. | |
2747 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly |
|
2770 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly | |
2748 | eps output. |
|
2771 | eps output. | |
2749 |
|
2772 | |||
2750 | 2002-11-12 Fernando Perez <fperez@colorado.edu> |
|
2773 | 2002-11-12 Fernando Perez <fperez@colorado.edu> | |
2751 |
|
2774 | |||
2752 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they |
|
2775 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they | |
2753 | don't propagate up to caller. Fixes crash reported by François |
|
2776 | don't propagate up to caller. Fixes crash reported by François | |
2754 | Pinard. |
|
2777 | Pinard. | |
2755 |
|
2778 | |||
2756 | 2002-11-09 Fernando Perez <fperez@colorado.edu> |
|
2779 | 2002-11-09 Fernando Perez <fperez@colorado.edu> | |
2757 |
|
2780 | |||
2758 | * IPython/ipmaker.py (make_IPython): fixed problem with writing |
|
2781 | * IPython/ipmaker.py (make_IPython): fixed problem with writing | |
2759 | history file for new users. |
|
2782 | history file for new users. | |
2760 | (make_IPython): fixed bug where initial install would leave the |
|
2783 | (make_IPython): fixed bug where initial install would leave the | |
2761 | user running in the .ipython dir. |
|
2784 | user running in the .ipython dir. | |
2762 | (make_IPython): fixed bug where config dir .ipython would be |
|
2785 | (make_IPython): fixed bug where config dir .ipython would be | |
2763 | created regardless of the given -ipythondir option. Thanks to Cory |
|
2786 | created regardless of the given -ipythondir option. Thanks to Cory | |
2764 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. |
|
2787 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. | |
2765 |
|
2788 | |||
2766 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no |
|
2789 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no | |
2767 | type confirmations. Will need to use it in all of IPython's code |
|
2790 | type confirmations. Will need to use it in all of IPython's code | |
2768 | consistently. |
|
2791 | consistently. | |
2769 |
|
2792 | |||
2770 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the |
|
2793 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the | |
2771 | context to print 31 lines instead of the default 5. This will make |
|
2794 | context to print 31 lines instead of the default 5. This will make | |
2772 | the crash reports extremely detailed in case the problem is in |
|
2795 | the crash reports extremely detailed in case the problem is in | |
2773 | libraries I don't have access to. |
|
2796 | libraries I don't have access to. | |
2774 |
|
2797 | |||
2775 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last |
|
2798 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last | |
2776 | line of defense' code to still crash, but giving users fair |
|
2799 | line of defense' code to still crash, but giving users fair | |
2777 | warning. I don't want internal errors to go unreported: if there's |
|
2800 | warning. I don't want internal errors to go unreported: if there's | |
2778 | an internal problem, IPython should crash and generate a full |
|
2801 | an internal problem, IPython should crash and generate a full | |
2779 | report. |
|
2802 | report. | |
2780 |
|
2803 | |||
2781 | 2002-11-08 Fernando Perez <fperez@colorado.edu> |
|
2804 | 2002-11-08 Fernando Perez <fperez@colorado.edu> | |
2782 |
|
2805 | |||
2783 | * IPython/iplib.py (InteractiveShell.interact): added code to trap |
|
2806 | * IPython/iplib.py (InteractiveShell.interact): added code to trap | |
2784 | otherwise uncaught exceptions which can appear if people set |
|
2807 | otherwise uncaught exceptions which can appear if people set | |
2785 | sys.stdout to something badly broken. Thanks to a crash report |
|
2808 | sys.stdout to something badly broken. Thanks to a crash report | |
2786 | from henni-AT-mail.brainbot.com. |
|
2809 | from henni-AT-mail.brainbot.com. | |
2787 |
|
2810 | |||
2788 | 2002-11-04 Fernando Perez <fperez@colorado.edu> |
|
2811 | 2002-11-04 Fernando Perez <fperez@colorado.edu> | |
2789 |
|
2812 | |||
2790 | * IPython/iplib.py (InteractiveShell.interact): added |
|
2813 | * IPython/iplib.py (InteractiveShell.interact): added | |
2791 | __IPYTHON__active to the builtins. It's a flag which goes on when |
|
2814 | __IPYTHON__active to the builtins. It's a flag which goes on when | |
2792 | the interaction starts and goes off again when it stops. This |
|
2815 | the interaction starts and goes off again when it stops. This | |
2793 | allows embedding code to detect being inside IPython. Before this |
|
2816 | allows embedding code to detect being inside IPython. Before this | |
2794 | was done via __IPYTHON__, but that only shows that an IPython |
|
2817 | was done via __IPYTHON__, but that only shows that an IPython | |
2795 | instance has been created. |
|
2818 | instance has been created. | |
2796 |
|
2819 | |||
2797 | * IPython/Magic.py (Magic.magic_env): I realized that in a |
|
2820 | * IPython/Magic.py (Magic.magic_env): I realized that in a | |
2798 | UserDict, instance.data holds the data as a normal dict. So I |
|
2821 | UserDict, instance.data holds the data as a normal dict. So I | |
2799 | modified @env to return os.environ.data instead of rebuilding a |
|
2822 | modified @env to return os.environ.data instead of rebuilding a | |
2800 | dict by hand. |
|
2823 | dict by hand. | |
2801 |
|
2824 | |||
2802 | 2002-11-02 Fernando Perez <fperez@colorado.edu> |
|
2825 | 2002-11-02 Fernando Perez <fperez@colorado.edu> | |
2803 |
|
2826 | |||
2804 | * IPython/genutils.py (warn): changed so that level 1 prints no |
|
2827 | * IPython/genutils.py (warn): changed so that level 1 prints no | |
2805 | header. Level 2 is now the default (with 'WARNING' header, as |
|
2828 | header. Level 2 is now the default (with 'WARNING' header, as | |
2806 | before). I think I tracked all places where changes were needed in |
|
2829 | before). I think I tracked all places where changes were needed in | |
2807 | IPython, but outside code using the old level numbering may have |
|
2830 | IPython, but outside code using the old level numbering may have | |
2808 | broken. |
|
2831 | broken. | |
2809 |
|
2832 | |||
2810 | * IPython/iplib.py (InteractiveShell.runcode): added this to |
|
2833 | * IPython/iplib.py (InteractiveShell.runcode): added this to | |
2811 | handle the tracebacks in SystemExit traps correctly. The previous |
|
2834 | handle the tracebacks in SystemExit traps correctly. The previous | |
2812 | code (through interact) was printing more of the stack than |
|
2835 | code (through interact) was printing more of the stack than | |
2813 | necessary, showing IPython internal code to the user. |
|
2836 | necessary, showing IPython internal code to the user. | |
2814 |
|
2837 | |||
2815 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by |
|
2838 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by | |
2816 | default. Now that the default at the confirmation prompt is yes, |
|
2839 | default. Now that the default at the confirmation prompt is yes, | |
2817 | it's not so intrusive. François' argument that ipython sessions |
|
2840 | it's not so intrusive. François' argument that ipython sessions | |
2818 | tend to be complex enough not to lose them from an accidental C-d, |
|
2841 | tend to be complex enough not to lose them from an accidental C-d, | |
2819 | is a valid one. |
|
2842 | is a valid one. | |
2820 |
|
2843 | |||
2821 | * IPython/iplib.py (InteractiveShell.interact): added a |
|
2844 | * IPython/iplib.py (InteractiveShell.interact): added a | |
2822 | showtraceback() call to the SystemExit trap, and modified the exit |
|
2845 | showtraceback() call to the SystemExit trap, and modified the exit | |
2823 | confirmation to have yes as the default. |
|
2846 | confirmation to have yes as the default. | |
2824 |
|
2847 | |||
2825 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from |
|
2848 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from | |
2826 | this file. It's been gone from the code for a long time, this was |
|
2849 | this file. It's been gone from the code for a long time, this was | |
2827 | simply leftover junk. |
|
2850 | simply leftover junk. | |
2828 |
|
2851 | |||
2829 | 2002-11-01 Fernando Perez <fperez@colorado.edu> |
|
2852 | 2002-11-01 Fernando Perez <fperez@colorado.edu> | |
2830 |
|
2853 | |||
2831 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option |
|
2854 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option | |
2832 | added. If set, IPython now traps EOF and asks for |
|
2855 | added. If set, IPython now traps EOF and asks for | |
2833 | confirmation. After a request by François Pinard. |
|
2856 | confirmation. After a request by François Pinard. | |
2834 |
|
2857 | |||
2835 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead |
|
2858 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead | |
2836 | of @abort, and with a new (better) mechanism for handling the |
|
2859 | of @abort, and with a new (better) mechanism for handling the | |
2837 | exceptions. |
|
2860 | exceptions. | |
2838 |
|
2861 | |||
2839 | 2002-10-27 Fernando Perez <fperez@colorado.edu> |
|
2862 | 2002-10-27 Fernando Perez <fperez@colorado.edu> | |
2840 |
|
2863 | |||
2841 | * IPython/usage.py (__doc__): updated the --help information and |
|
2864 | * IPython/usage.py (__doc__): updated the --help information and | |
2842 | the ipythonrc file to indicate that -log generates |
|
2865 | the ipythonrc file to indicate that -log generates | |
2843 | ./ipython.log. Also fixed the corresponding info in @logstart. |
|
2866 | ./ipython.log. Also fixed the corresponding info in @logstart. | |
2844 | This and several other fixes in the manuals thanks to reports by |
|
2867 | This and several other fixes in the manuals thanks to reports by | |
2845 | François Pinard <pinard-AT-iro.umontreal.ca>. |
|
2868 | François Pinard <pinard-AT-iro.umontreal.ca>. | |
2846 |
|
2869 | |||
2847 | * IPython/Logger.py (Logger.switch_log): Fixed error message to |
|
2870 | * IPython/Logger.py (Logger.switch_log): Fixed error message to | |
2848 | refer to @logstart (instead of @log, which doesn't exist). |
|
2871 | refer to @logstart (instead of @log, which doesn't exist). | |
2849 |
|
2872 | |||
2850 | * IPython/iplib.py (InteractiveShell._prefilter): fixed |
|
2873 | * IPython/iplib.py (InteractiveShell._prefilter): fixed | |
2851 | AttributeError crash. Thanks to Christopher Armstrong |
|
2874 | AttributeError crash. Thanks to Christopher Armstrong | |
2852 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been |
|
2875 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been | |
2853 | introduced recently (in 0.2.14pre37) with the fix to the eval |
|
2876 | introduced recently (in 0.2.14pre37) with the fix to the eval | |
2854 | problem mentioned below. |
|
2877 | problem mentioned below. | |
2855 |
|
2878 | |||
2856 | 2002-10-17 Fernando Perez <fperez@colorado.edu> |
|
2879 | 2002-10-17 Fernando Perez <fperez@colorado.edu> | |
2857 |
|
2880 | |||
2858 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows |
|
2881 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows | |
2859 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. |
|
2882 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. | |
2860 |
|
2883 | |||
2861 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to |
|
2884 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to | |
2862 | this function to fix a problem reported by Alex Schmolck. He saw |
|
2885 | this function to fix a problem reported by Alex Schmolck. He saw | |
2863 | it with list comprehensions and generators, which were getting |
|
2886 | it with list comprehensions and generators, which were getting | |
2864 | called twice. The real problem was an 'eval' call in testing for |
|
2887 | called twice. The real problem was an 'eval' call in testing for | |
2865 | automagic which was evaluating the input line silently. |
|
2888 | automagic which was evaluating the input line silently. | |
2866 |
|
2889 | |||
2867 | This is a potentially very nasty bug, if the input has side |
|
2890 | This is a potentially very nasty bug, if the input has side | |
2868 | effects which must not be repeated. The code is much cleaner now, |
|
2891 | effects which must not be repeated. The code is much cleaner now, | |
2869 | without any blanket 'except' left and with a regexp test for |
|
2892 | without any blanket 'except' left and with a regexp test for | |
2870 | actual function names. |
|
2893 | actual function names. | |
2871 |
|
2894 | |||
2872 | But an eval remains, which I'm not fully comfortable with. I just |
|
2895 | But an eval remains, which I'm not fully comfortable with. I just | |
2873 | don't know how to find out if an expression could be a callable in |
|
2896 | don't know how to find out if an expression could be a callable in | |
2874 | the user's namespace without doing an eval on the string. However |
|
2897 | the user's namespace without doing an eval on the string. However | |
2875 | that string is now much more strictly checked so that no code |
|
2898 | that string is now much more strictly checked so that no code | |
2876 | slips by, so the eval should only happen for things that can |
|
2899 | slips by, so the eval should only happen for things that can | |
2877 | really be only function/method names. |
|
2900 | really be only function/method names. | |
2878 |
|
2901 | |||
2879 | 2002-10-15 Fernando Perez <fperez@colorado.edu> |
|
2902 | 2002-10-15 Fernando Perez <fperez@colorado.edu> | |
2880 |
|
2903 | |||
2881 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac |
|
2904 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac | |
2882 | OSX information to main manual, removed README_Mac_OSX file from |
|
2905 | OSX information to main manual, removed README_Mac_OSX file from | |
2883 | distribution. Also updated credits for recent additions. |
|
2906 | distribution. Also updated credits for recent additions. | |
2884 |
|
2907 | |||
2885 | 2002-10-10 Fernando Perez <fperez@colorado.edu> |
|
2908 | 2002-10-10 Fernando Perez <fperez@colorado.edu> | |
2886 |
|
2909 | |||
2887 | * README_Mac_OSX: Added a README for Mac OSX users for fixing |
|
2910 | * README_Mac_OSX: Added a README for Mac OSX users for fixing | |
2888 | terminal-related issues. Many thanks to Andrea Riciputi |
|
2911 | terminal-related issues. Many thanks to Andrea Riciputi | |
2889 | <andrea.riciputi-AT-libero.it> for writing it. |
|
2912 | <andrea.riciputi-AT-libero.it> for writing it. | |
2890 |
|
2913 | |||
2891 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, |
|
2914 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, | |
2892 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2915 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2893 |
|
2916 | |||
2894 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks |
|
2917 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks | |
2895 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad |
|
2918 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad | |
2896 | <syver-en-AT-online.no> who both submitted patches for this problem. |
|
2919 | <syver-en-AT-online.no> who both submitted patches for this problem. | |
2897 |
|
2920 | |||
2898 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for |
|
2921 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for | |
2899 | global embedding to make sure that things don't overwrite user |
|
2922 | global embedding to make sure that things don't overwrite user | |
2900 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> |
|
2923 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> | |
2901 |
|
2924 | |||
2902 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 |
|
2925 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 | |
2903 | compatibility. Thanks to Hayden Callow |
|
2926 | compatibility. Thanks to Hayden Callow | |
2904 | <h.callow-AT-elec.canterbury.ac.nz> |
|
2927 | <h.callow-AT-elec.canterbury.ac.nz> | |
2905 |
|
2928 | |||
2906 | 2002-10-04 Fernando Perez <fperez@colorado.edu> |
|
2929 | 2002-10-04 Fernando Perez <fperez@colorado.edu> | |
2907 |
|
2930 | |||
2908 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for |
|
2931 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for | |
2909 | Gnuplot.File objects. |
|
2932 | Gnuplot.File objects. | |
2910 |
|
2933 | |||
2911 | 2002-07-23 Fernando Perez <fperez@colorado.edu> |
|
2934 | 2002-07-23 Fernando Perez <fperez@colorado.edu> | |
2912 |
|
2935 | |||
2913 | * IPython/genutils.py (timing): Added timings() and timing() for |
|
2936 | * IPython/genutils.py (timing): Added timings() and timing() for | |
2914 | quick access to the most commonly needed data, the execution |
|
2937 | quick access to the most commonly needed data, the execution | |
2915 | times. Old timing() renamed to timings_out(). |
|
2938 | times. Old timing() renamed to timings_out(). | |
2916 |
|
2939 | |||
2917 | 2002-07-18 Fernando Perez <fperez@colorado.edu> |
|
2940 | 2002-07-18 Fernando Perez <fperez@colorado.edu> | |
2918 |
|
2941 | |||
2919 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed |
|
2942 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed | |
2920 | bug with nested instances disrupting the parent's tab completion. |
|
2943 | bug with nested instances disrupting the parent's tab completion. | |
2921 |
|
2944 | |||
2922 | * IPython/iplib.py (all_completions): Added Alex Schmolck's |
|
2945 | * IPython/iplib.py (all_completions): Added Alex Schmolck's | |
2923 | all_completions code to begin the emacs integration. |
|
2946 | all_completions code to begin the emacs integration. | |
2924 |
|
2947 | |||
2925 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' |
|
2948 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' | |
2926 | argument to allow titling individual arrays when plotting. |
|
2949 | argument to allow titling individual arrays when plotting. | |
2927 |
|
2950 | |||
2928 | 2002-07-15 Fernando Perez <fperez@colorado.edu> |
|
2951 | 2002-07-15 Fernando Perez <fperez@colorado.edu> | |
2929 |
|
2952 | |||
2930 | * setup.py (make_shortcut): changed to retrieve the value of |
|
2953 | * setup.py (make_shortcut): changed to retrieve the value of | |
2931 | 'Program Files' directory from the registry (this value changes in |
|
2954 | 'Program Files' directory from the registry (this value changes in | |
2932 | non-english versions of Windows). Thanks to Thomas Fanslau |
|
2955 | non-english versions of Windows). Thanks to Thomas Fanslau | |
2933 | <tfanslau-AT-gmx.de> for the report. |
|
2956 | <tfanslau-AT-gmx.de> for the report. | |
2934 |
|
2957 | |||
2935 | 2002-07-10 Fernando Perez <fperez@colorado.edu> |
|
2958 | 2002-07-10 Fernando Perez <fperez@colorado.edu> | |
2936 |
|
2959 | |||
2937 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for |
|
2960 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for | |
2938 | a bug in pdb, which crashes if a line with only whitespace is |
|
2961 | a bug in pdb, which crashes if a line with only whitespace is | |
2939 | entered. Bug report submitted to sourceforge. |
|
2962 | entered. Bug report submitted to sourceforge. | |
2940 |
|
2963 | |||
2941 | 2002-07-09 Fernando Perez <fperez@colorado.edu> |
|
2964 | 2002-07-09 Fernando Perez <fperez@colorado.edu> | |
2942 |
|
2965 | |||
2943 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when |
|
2966 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when | |
2944 | reporting exceptions (it's a bug in inspect.py, I just set a |
|
2967 | reporting exceptions (it's a bug in inspect.py, I just set a | |
2945 | workaround). |
|
2968 | workaround). | |
2946 |
|
2969 | |||
2947 | 2002-07-08 Fernando Perez <fperez@colorado.edu> |
|
2970 | 2002-07-08 Fernando Perez <fperez@colorado.edu> | |
2948 |
|
2971 | |||
2949 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to |
|
2972 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to | |
2950 | __IPYTHON__ in __builtins__ to show up in user_ns. |
|
2973 | __IPYTHON__ in __builtins__ to show up in user_ns. | |
2951 |
|
2974 | |||
2952 | 2002-07-03 Fernando Perez <fperez@colorado.edu> |
|
2975 | 2002-07-03 Fernando Perez <fperez@colorado.edu> | |
2953 |
|
2976 | |||
2954 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed |
|
2977 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed | |
2955 | name from @gp_set_instance to @gp_set_default. |
|
2978 | name from @gp_set_instance to @gp_set_default. | |
2956 |
|
2979 | |||
2957 | * IPython/ipmaker.py (make_IPython): default editor value set to |
|
2980 | * IPython/ipmaker.py (make_IPython): default editor value set to | |
2958 | '0' (a string), to match the rc file. Otherwise will crash when |
|
2981 | '0' (a string), to match the rc file. Otherwise will crash when | |
2959 | .strip() is called on it. |
|
2982 | .strip() is called on it. | |
2960 |
|
2983 | |||
2961 |
|
2984 | |||
2962 | 2002-06-28 Fernando Perez <fperez@colorado.edu> |
|
2985 | 2002-06-28 Fernando Perez <fperez@colorado.edu> | |
2963 |
|
2986 | |||
2964 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing |
|
2987 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing | |
2965 | of files in current directory when a file is executed via |
|
2988 | of files in current directory when a file is executed via | |
2966 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. |
|
2989 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. | |
2967 |
|
2990 | |||
2968 | * setup.py (manfiles): fix for rpm builds, submitted by RA |
|
2991 | * setup.py (manfiles): fix for rpm builds, submitted by RA | |
2969 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! |
|
2992 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! | |
2970 |
|
2993 | |||
2971 | * IPython/ipmaker.py (make_IPython): fixed lookup of default |
|
2994 | * IPython/ipmaker.py (make_IPython): fixed lookup of default | |
2972 | editor when set to '0'. Problem was, '0' evaluates to True (it's a |
|
2995 | editor when set to '0'. Problem was, '0' evaluates to True (it's a | |
2973 | string!). A. Schmolck caught this one. |
|
2996 | string!). A. Schmolck caught this one. | |
2974 |
|
2997 | |||
2975 | 2002-06-27 Fernando Perez <fperez@colorado.edu> |
|
2998 | 2002-06-27 Fernando Perez <fperez@colorado.edu> | |
2976 |
|
2999 | |||
2977 | * IPython/ipmaker.py (make_IPython): fixed bug when running user |
|
3000 | * IPython/ipmaker.py (make_IPython): fixed bug when running user | |
2978 | defined files at the cmd line. __name__ wasn't being set to |
|
3001 | defined files at the cmd line. __name__ wasn't being set to | |
2979 | __main__. |
|
3002 | __main__. | |
2980 |
|
3003 | |||
2981 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also |
|
3004 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also | |
2982 | regular lists and tuples besides Numeric arrays. |
|
3005 | regular lists and tuples besides Numeric arrays. | |
2983 |
|
3006 | |||
2984 | * IPython/Prompts.py (CachedOutput.__call__): Added output |
|
3007 | * IPython/Prompts.py (CachedOutput.__call__): Added output | |
2985 | supression for input ending with ';'. Similar to Mathematica and |
|
3008 | supression for input ending with ';'. Similar to Mathematica and | |
2986 | Matlab. The _* vars and Out[] list are still updated, just like |
|
3009 | Matlab. The _* vars and Out[] list are still updated, just like | |
2987 | Mathematica behaves. |
|
3010 | Mathematica behaves. | |
2988 |
|
3011 | |||
2989 | 2002-06-25 Fernando Perez <fperez@colorado.edu> |
|
3012 | 2002-06-25 Fernando Perez <fperez@colorado.edu> | |
2990 |
|
3013 | |||
2991 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of |
|
3014 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of | |
2992 | .ini extensions for profiels under Windows. |
|
3015 | .ini extensions for profiels under Windows. | |
2993 |
|
3016 | |||
2994 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of |
|
3017 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of | |
2995 | string form. Fix contributed by Alexander Schmolck |
|
3018 | string form. Fix contributed by Alexander Schmolck | |
2996 | <a.schmolck-AT-gmx.net> |
|
3019 | <a.schmolck-AT-gmx.net> | |
2997 |
|
3020 | |||
2998 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a |
|
3021 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a | |
2999 | pre-configured Gnuplot instance. |
|
3022 | pre-configured Gnuplot instance. | |
3000 |
|
3023 | |||
3001 | 2002-06-21 Fernando Perez <fperez@colorado.edu> |
|
3024 | 2002-06-21 Fernando Perez <fperez@colorado.edu> | |
3002 |
|
3025 | |||
3003 | * IPython/numutils.py (exp_safe): new function, works around the |
|
3026 | * IPython/numutils.py (exp_safe): new function, works around the | |
3004 | underflow problems in Numeric. |
|
3027 | underflow problems in Numeric. | |
3005 | (log2): New fn. Safe log in base 2: returns exact integer answer |
|
3028 | (log2): New fn. Safe log in base 2: returns exact integer answer | |
3006 | for exact integer powers of 2. |
|
3029 | for exact integer powers of 2. | |
3007 |
|
3030 | |||
3008 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' |
|
3031 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' | |
3009 | properly. |
|
3032 | properly. | |
3010 |
|
3033 | |||
3011 | 2002-06-20 Fernando Perez <fperez@colorado.edu> |
|
3034 | 2002-06-20 Fernando Perez <fperez@colorado.edu> | |
3012 |
|
3035 | |||
3013 | * IPython/genutils.py (timing): new function like |
|
3036 | * IPython/genutils.py (timing): new function like | |
3014 | Mathematica's. Similar to time_test, but returns more info. |
|
3037 | Mathematica's. Similar to time_test, but returns more info. | |
3015 |
|
3038 | |||
3016 | 2002-06-18 Fernando Perez <fperez@colorado.edu> |
|
3039 | 2002-06-18 Fernando Perez <fperez@colorado.edu> | |
3017 |
|
3040 | |||
3018 | * IPython/Magic.py (Magic.magic_save): modified @save and @r |
|
3041 | * IPython/Magic.py (Magic.magic_save): modified @save and @r | |
3019 | according to Mike Heeter's suggestions. |
|
3042 | according to Mike Heeter's suggestions. | |
3020 |
|
3043 | |||
3021 | 2002-06-16 Fernando Perez <fperez@colorado.edu> |
|
3044 | 2002-06-16 Fernando Perez <fperez@colorado.edu> | |
3022 |
|
3045 | |||
3023 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot |
|
3046 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot | |
3024 | system. GnuplotMagic is gone as a user-directory option. New files |
|
3047 | system. GnuplotMagic is gone as a user-directory option. New files | |
3025 | make it easier to use all the gnuplot stuff both from external |
|
3048 | make it easier to use all the gnuplot stuff both from external | |
3026 | programs as well as from IPython. Had to rewrite part of |
|
3049 | programs as well as from IPython. Had to rewrite part of | |
3027 | hardcopy() b/c of a strange bug: often the ps files simply don't |
|
3050 | hardcopy() b/c of a strange bug: often the ps files simply don't | |
3028 | get created, and require a repeat of the command (often several |
|
3051 | get created, and require a repeat of the command (often several | |
3029 | times). |
|
3052 | times). | |
3030 |
|
3053 | |||
3031 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to |
|
3054 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to | |
3032 | resolve output channel at call time, so that if sys.stderr has |
|
3055 | resolve output channel at call time, so that if sys.stderr has | |
3033 | been redirected by user this gets honored. |
|
3056 | been redirected by user this gets honored. | |
3034 |
|
3057 | |||
3035 | 2002-06-13 Fernando Perez <fperez@colorado.edu> |
|
3058 | 2002-06-13 Fernando Perez <fperez@colorado.edu> | |
3036 |
|
3059 | |||
3037 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to |
|
3060 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to | |
3038 | IPShell. Kept a copy with the old names to avoid breaking people's |
|
3061 | IPShell. Kept a copy with the old names to avoid breaking people's | |
3039 | embedded code. |
|
3062 | embedded code. | |
3040 |
|
3063 | |||
3041 | * IPython/ipython: simplified it to the bare minimum after |
|
3064 | * IPython/ipython: simplified it to the bare minimum after | |
3042 | Holger's suggestions. Added info about how to use it in |
|
3065 | Holger's suggestions. Added info about how to use it in | |
3043 | PYTHONSTARTUP. |
|
3066 | PYTHONSTARTUP. | |
3044 |
|
3067 | |||
3045 | * IPython/Shell.py (IPythonShell): changed the options passing |
|
3068 | * IPython/Shell.py (IPythonShell): changed the options passing | |
3046 | from a string with funky %s replacements to a straight list. Maybe |
|
3069 | from a string with funky %s replacements to a straight list. Maybe | |
3047 | a bit more typing, but it follows sys.argv conventions, so there's |
|
3070 | a bit more typing, but it follows sys.argv conventions, so there's | |
3048 | less special-casing to remember. |
|
3071 | less special-casing to remember. | |
3049 |
|
3072 | |||
3050 | 2002-06-12 Fernando Perez <fperez@colorado.edu> |
|
3073 | 2002-06-12 Fernando Perez <fperez@colorado.edu> | |
3051 |
|
3074 | |||
3052 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat |
|
3075 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat | |
3053 | command. Thanks to a suggestion by Mike Heeter. |
|
3076 | command. Thanks to a suggestion by Mike Heeter. | |
3054 | (Magic.magic_pfile): added behavior to look at filenames if given |
|
3077 | (Magic.magic_pfile): added behavior to look at filenames if given | |
3055 | arg is not a defined object. |
|
3078 | arg is not a defined object. | |
3056 | (Magic.magic_save): New @save function to save code snippets. Also |
|
3079 | (Magic.magic_save): New @save function to save code snippets. Also | |
3057 | a Mike Heeter idea. |
|
3080 | a Mike Heeter idea. | |
3058 |
|
3081 | |||
3059 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to |
|
3082 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to | |
3060 | plot() and replot(). Much more convenient now, especially for |
|
3083 | plot() and replot(). Much more convenient now, especially for | |
3061 | interactive use. |
|
3084 | interactive use. | |
3062 |
|
3085 | |||
3063 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to |
|
3086 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to | |
3064 | filenames. |
|
3087 | filenames. | |
3065 |
|
3088 | |||
3066 | 2002-06-02 Fernando Perez <fperez@colorado.edu> |
|
3089 | 2002-06-02 Fernando Perez <fperez@colorado.edu> | |
3067 |
|
3090 | |||
3068 | * IPython/Struct.py (Struct.__init__): modified to admit |
|
3091 | * IPython/Struct.py (Struct.__init__): modified to admit | |
3069 | initialization via another struct. |
|
3092 | initialization via another struct. | |
3070 |
|
3093 | |||
3071 | * IPython/genutils.py (SystemExec.__init__): New stateful |
|
3094 | * IPython/genutils.py (SystemExec.__init__): New stateful | |
3072 | interface to xsys and bq. Useful for writing system scripts. |
|
3095 | interface to xsys and bq. Useful for writing system scripts. | |
3073 |
|
3096 | |||
3074 | 2002-05-30 Fernando Perez <fperez@colorado.edu> |
|
3097 | 2002-05-30 Fernando Perez <fperez@colorado.edu> | |
3075 |
|
3098 | |||
3076 | * MANIFEST.in: Changed docfile selection to exclude all the lyx |
|
3099 | * MANIFEST.in: Changed docfile selection to exclude all the lyx | |
3077 | documents. This will make the user download smaller (it's getting |
|
3100 | documents. This will make the user download smaller (it's getting | |
3078 | too big). |
|
3101 | too big). | |
3079 |
|
3102 | |||
3080 | 2002-05-29 Fernando Perez <fperez@colorado.edu> |
|
3103 | 2002-05-29 Fernando Perez <fperez@colorado.edu> | |
3081 |
|
3104 | |||
3082 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to |
|
3105 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to | |
3083 | fix problems with shelve and pickle. Seems to work, but I don't |
|
3106 | fix problems with shelve and pickle. Seems to work, but I don't | |
3084 | know if corner cases break it. Thanks to Mike Heeter |
|
3107 | know if corner cases break it. Thanks to Mike Heeter | |
3085 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. |
|
3108 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. | |
3086 |
|
3109 | |||
3087 | 2002-05-24 Fernando Perez <fperez@colorado.edu> |
|
3110 | 2002-05-24 Fernando Perez <fperez@colorado.edu> | |
3088 |
|
3111 | |||
3089 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in |
|
3112 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in | |
3090 | macros having broken. |
|
3113 | macros having broken. | |
3091 |
|
3114 | |||
3092 | 2002-05-21 Fernando Perez <fperez@colorado.edu> |
|
3115 | 2002-05-21 Fernando Perez <fperez@colorado.edu> | |
3093 |
|
3116 | |||
3094 | * IPython/Magic.py (Magic.magic_logstart): fixed recently |
|
3117 | * IPython/Magic.py (Magic.magic_logstart): fixed recently | |
3095 | introduced logging bug: all history before logging started was |
|
3118 | introduced logging bug: all history before logging started was | |
3096 | being written one character per line! This came from the redesign |
|
3119 | being written one character per line! This came from the redesign | |
3097 | of the input history as a special list which slices to strings, |
|
3120 | of the input history as a special list which slices to strings, | |
3098 | not to lists. |
|
3121 | not to lists. | |
3099 |
|
3122 | |||
3100 | 2002-05-20 Fernando Perez <fperez@colorado.edu> |
|
3123 | 2002-05-20 Fernando Perez <fperez@colorado.edu> | |
3101 |
|
3124 | |||
3102 | * IPython/Prompts.py (CachedOutput.__init__): made the color table |
|
3125 | * IPython/Prompts.py (CachedOutput.__init__): made the color table | |
3103 | be an attribute of all classes in this module. The design of these |
|
3126 | be an attribute of all classes in this module. The design of these | |
3104 | classes needs some serious overhauling. |
|
3127 | classes needs some serious overhauling. | |
3105 |
|
3128 | |||
3106 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug |
|
3129 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug | |
3107 | which was ignoring '_' in option names. |
|
3130 | which was ignoring '_' in option names. | |
3108 |
|
3131 | |||
3109 | * IPython/ultraTB.py (FormattedTB.__init__): Changed |
|
3132 | * IPython/ultraTB.py (FormattedTB.__init__): Changed | |
3110 | 'Verbose_novars' to 'Context' and made it the new default. It's a |
|
3133 | 'Verbose_novars' to 'Context' and made it the new default. It's a | |
3111 | bit more readable and also safer than verbose. |
|
3134 | bit more readable and also safer than verbose. | |
3112 |
|
3135 | |||
3113 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of |
|
3136 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of | |
3114 | triple-quoted strings. |
|
3137 | triple-quoted strings. | |
3115 |
|
3138 | |||
3116 | * IPython/OInspect.py (__all__): new module exposing the object |
|
3139 | * IPython/OInspect.py (__all__): new module exposing the object | |
3117 | introspection facilities. Now the corresponding magics are dummy |
|
3140 | introspection facilities. Now the corresponding magics are dummy | |
3118 | wrappers around this. Having this module will make it much easier |
|
3141 | wrappers around this. Having this module will make it much easier | |
3119 | to put these functions into our modified pdb. |
|
3142 | to put these functions into our modified pdb. | |
3120 | This new object inspector system uses the new colorizing module, |
|
3143 | This new object inspector system uses the new colorizing module, | |
3121 | so source code and other things are nicely syntax highlighted. |
|
3144 | so source code and other things are nicely syntax highlighted. | |
3122 |
|
3145 | |||
3123 | 2002-05-18 Fernando Perez <fperez@colorado.edu> |
|
3146 | 2002-05-18 Fernando Perez <fperez@colorado.edu> | |
3124 |
|
3147 | |||
3125 | * IPython/ColorANSI.py: Split the coloring tools into a separate |
|
3148 | * IPython/ColorANSI.py: Split the coloring tools into a separate | |
3126 | module so I can use them in other code easier (they were part of |
|
3149 | module so I can use them in other code easier (they were part of | |
3127 | ultraTB). |
|
3150 | ultraTB). | |
3128 |
|
3151 | |||
3129 | 2002-05-17 Fernando Perez <fperez@colorado.edu> |
|
3152 | 2002-05-17 Fernando Perez <fperez@colorado.edu> | |
3130 |
|
3153 | |||
3131 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3154 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
3132 | fixed it to set the global 'g' also to the called instance, as |
|
3155 | fixed it to set the global 'g' also to the called instance, as | |
3133 | long as 'g' was still a gnuplot instance (so it doesn't overwrite |
|
3156 | long as 'g' was still a gnuplot instance (so it doesn't overwrite | |
3134 | user's 'g' variables). |
|
3157 | user's 'g' variables). | |
3135 |
|
3158 | |||
3136 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out |
|
3159 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out | |
3137 | global variables (aliases to _ih,_oh) so that users which expect |
|
3160 | global variables (aliases to _ih,_oh) so that users which expect | |
3138 | In[5] or Out[7] to work aren't unpleasantly surprised. |
|
3161 | In[5] or Out[7] to work aren't unpleasantly surprised. | |
3139 | (InputList.__getslice__): new class to allow executing slices of |
|
3162 | (InputList.__getslice__): new class to allow executing slices of | |
3140 | input history directly. Very simple class, complements the use of |
|
3163 | input history directly. Very simple class, complements the use of | |
3141 | macros. |
|
3164 | macros. | |
3142 |
|
3165 | |||
3143 | 2002-05-16 Fernando Perez <fperez@colorado.edu> |
|
3166 | 2002-05-16 Fernando Perez <fperez@colorado.edu> | |
3144 |
|
3167 | |||
3145 | * setup.py (docdirbase): make doc directory be just doc/IPython |
|
3168 | * setup.py (docdirbase): make doc directory be just doc/IPython | |
3146 | without version numbers, it will reduce clutter for users. |
|
3169 | without version numbers, it will reduce clutter for users. | |
3147 |
|
3170 | |||
3148 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to |
|
3171 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to | |
3149 | execfile call to prevent possible memory leak. See for details: |
|
3172 | execfile call to prevent possible memory leak. See for details: | |
3150 | http://mail.python.org/pipermail/python-list/2002-February/088476.html |
|
3173 | http://mail.python.org/pipermail/python-list/2002-February/088476.html | |
3151 |
|
3174 | |||
3152 | 2002-05-15 Fernando Perez <fperez@colorado.edu> |
|
3175 | 2002-05-15 Fernando Perez <fperez@colorado.edu> | |
3153 |
|
3176 | |||
3154 | * IPython/Magic.py (Magic.magic_psource): made the object |
|
3177 | * IPython/Magic.py (Magic.magic_psource): made the object | |
3155 | introspection names be more standard: pdoc, pdef, pfile and |
|
3178 | introspection names be more standard: pdoc, pdef, pfile and | |
3156 | psource. They all print/page their output, and it makes |
|
3179 | psource. They all print/page their output, and it makes | |
3157 | remembering them easier. Kept old names for compatibility as |
|
3180 | remembering them easier. Kept old names for compatibility as | |
3158 | aliases. |
|
3181 | aliases. | |
3159 |
|
3182 | |||
3160 | 2002-05-14 Fernando Perez <fperez@colorado.edu> |
|
3183 | 2002-05-14 Fernando Perez <fperez@colorado.edu> | |
3161 |
|
3184 | |||
3162 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood |
|
3185 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood | |
3163 | what the mouse problem was. The trick is to use gnuplot with temp |
|
3186 | what the mouse problem was. The trick is to use gnuplot with temp | |
3164 | files and NOT with pipes (for data communication), because having |
|
3187 | files and NOT with pipes (for data communication), because having | |
3165 | both pipes and the mouse on is bad news. |
|
3188 | both pipes and the mouse on is bad news. | |
3166 |
|
3189 | |||
3167 | 2002-05-13 Fernando Perez <fperez@colorado.edu> |
|
3190 | 2002-05-13 Fernando Perez <fperez@colorado.edu> | |
3168 |
|
3191 | |||
3169 | * IPython/Magic.py (Magic._ofind): fixed namespace order search |
|
3192 | * IPython/Magic.py (Magic._ofind): fixed namespace order search | |
3170 | bug. Information would be reported about builtins even when |
|
3193 | bug. Information would be reported about builtins even when | |
3171 | user-defined functions overrode them. |
|
3194 | user-defined functions overrode them. | |
3172 |
|
3195 | |||
3173 | 2002-05-11 Fernando Perez <fperez@colorado.edu> |
|
3196 | 2002-05-11 Fernando Perez <fperez@colorado.edu> | |
3174 |
|
3197 | |||
3175 | * IPython/__init__.py (__all__): removed FlexCompleter from |
|
3198 | * IPython/__init__.py (__all__): removed FlexCompleter from | |
3176 | __all__ so that things don't fail in platforms without readline. |
|
3199 | __all__ so that things don't fail in platforms without readline. | |
3177 |
|
3200 | |||
3178 | 2002-05-10 Fernando Perez <fperez@colorado.edu> |
|
3201 | 2002-05-10 Fernando Perez <fperez@colorado.edu> | |
3179 |
|
3202 | |||
3180 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c |
|
3203 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c | |
3181 | it requires Numeric, effectively making Numeric a dependency for |
|
3204 | it requires Numeric, effectively making Numeric a dependency for | |
3182 | IPython. |
|
3205 | IPython. | |
3183 |
|
3206 | |||
3184 | * Released 0.2.13 |
|
3207 | * Released 0.2.13 | |
3185 |
|
3208 | |||
3186 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the |
|
3209 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the | |
3187 | profiler interface. Now all the major options from the profiler |
|
3210 | profiler interface. Now all the major options from the profiler | |
3188 | module are directly supported in IPython, both for single |
|
3211 | module are directly supported in IPython, both for single | |
3189 | expressions (@prun) and for full programs (@run -p). |
|
3212 | expressions (@prun) and for full programs (@run -p). | |
3190 |
|
3213 | |||
3191 | 2002-05-09 Fernando Perez <fperez@colorado.edu> |
|
3214 | 2002-05-09 Fernando Perez <fperez@colorado.edu> | |
3192 |
|
3215 | |||
3193 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of |
|
3216 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of | |
3194 | magic properly formatted for screen. |
|
3217 | magic properly formatted for screen. | |
3195 |
|
3218 | |||
3196 | * setup.py (make_shortcut): Changed things to put pdf version in |
|
3219 | * setup.py (make_shortcut): Changed things to put pdf version in | |
3197 | doc/ instead of doc/manual (had to change lyxport a bit). |
|
3220 | doc/ instead of doc/manual (had to change lyxport a bit). | |
3198 |
|
3221 | |||
3199 | * IPython/Magic.py (Profile.string_stats): made profile runs go |
|
3222 | * IPython/Magic.py (Profile.string_stats): made profile runs go | |
3200 | through pager (they are long and a pager allows searching, saving, |
|
3223 | through pager (they are long and a pager allows searching, saving, | |
3201 | etc.) |
|
3224 | etc.) | |
3202 |
|
3225 | |||
3203 | 2002-05-08 Fernando Perez <fperez@colorado.edu> |
|
3226 | 2002-05-08 Fernando Perez <fperez@colorado.edu> | |
3204 |
|
3227 | |||
3205 | * Released 0.2.12 |
|
3228 | * Released 0.2.12 | |
3206 |
|
3229 | |||
3207 | 2002-05-06 Fernando Perez <fperez@colorado.edu> |
|
3230 | 2002-05-06 Fernando Perez <fperez@colorado.edu> | |
3208 |
|
3231 | |||
3209 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently |
|
3232 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently | |
3210 | introduced); 'hist n1 n2' was broken. |
|
3233 | introduced); 'hist n1 n2' was broken. | |
3211 | (Magic.magic_pdb): added optional on/off arguments to @pdb |
|
3234 | (Magic.magic_pdb): added optional on/off arguments to @pdb | |
3212 | (Magic.magic_run): added option -i to @run, which executes code in |
|
3235 | (Magic.magic_run): added option -i to @run, which executes code in | |
3213 | the IPython namespace instead of a clean one. Also added @irun as |
|
3236 | the IPython namespace instead of a clean one. Also added @irun as | |
3214 | an alias to @run -i. |
|
3237 | an alias to @run -i. | |
3215 |
|
3238 | |||
3216 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3239 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
3217 | fixed (it didn't really do anything, the namespaces were wrong). |
|
3240 | fixed (it didn't really do anything, the namespaces were wrong). | |
3218 |
|
3241 | |||
3219 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 |
|
3242 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 | |
3220 |
|
3243 | |||
3221 | * IPython/__init__.py (__all__): Fixed package namespace, now |
|
3244 | * IPython/__init__.py (__all__): Fixed package namespace, now | |
3222 | 'import IPython' does give access to IPython.<all> as |
|
3245 | 'import IPython' does give access to IPython.<all> as | |
3223 | expected. Also renamed __release__ to Release. |
|
3246 | expected. Also renamed __release__ to Release. | |
3224 |
|
3247 | |||
3225 | * IPython/Debugger.py (__license__): created new Pdb class which |
|
3248 | * IPython/Debugger.py (__license__): created new Pdb class which | |
3226 | functions like a drop-in for the normal pdb.Pdb but does NOT |
|
3249 | functions like a drop-in for the normal pdb.Pdb but does NOT | |
3227 | import readline by default. This way it doesn't muck up IPython's |
|
3250 | import readline by default. This way it doesn't muck up IPython's | |
3228 | readline handling, and now tab-completion finally works in the |
|
3251 | readline handling, and now tab-completion finally works in the | |
3229 | debugger -- sort of. It completes things globally visible, but the |
|
3252 | debugger -- sort of. It completes things globally visible, but the | |
3230 | completer doesn't track the stack as pdb walks it. That's a bit |
|
3253 | completer doesn't track the stack as pdb walks it. That's a bit | |
3231 | tricky, and I'll have to implement it later. |
|
3254 | tricky, and I'll have to implement it later. | |
3232 |
|
3255 | |||
3233 | 2002-05-05 Fernando Perez <fperez@colorado.edu> |
|
3256 | 2002-05-05 Fernando Perez <fperez@colorado.edu> | |
3234 |
|
3257 | |||
3235 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for |
|
3258 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for | |
3236 | magic docstrings when printed via ? (explicit \'s were being |
|
3259 | magic docstrings when printed via ? (explicit \'s were being | |
3237 | printed). |
|
3260 | printed). | |
3238 |
|
3261 | |||
3239 | * IPython/ipmaker.py (make_IPython): fixed namespace |
|
3262 | * IPython/ipmaker.py (make_IPython): fixed namespace | |
3240 | identification bug. Now variables loaded via logs or command-line |
|
3263 | identification bug. Now variables loaded via logs or command-line | |
3241 | files are recognized in the interactive namespace by @who. |
|
3264 | files are recognized in the interactive namespace by @who. | |
3242 |
|
3265 | |||
3243 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in |
|
3266 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in | |
3244 | log replay system stemming from the string form of Structs. |
|
3267 | log replay system stemming from the string form of Structs. | |
3245 |
|
3268 | |||
3246 | * IPython/Magic.py (Macro.__init__): improved macros to properly |
|
3269 | * IPython/Magic.py (Macro.__init__): improved macros to properly | |
3247 | handle magic commands in them. |
|
3270 | handle magic commands in them. | |
3248 | (Magic.magic_logstart): usernames are now expanded so 'logstart |
|
3271 | (Magic.magic_logstart): usernames are now expanded so 'logstart | |
3249 | ~/mylog' now works. |
|
3272 | ~/mylog' now works. | |
3250 |
|
3273 | |||
3251 | * IPython/iplib.py (complete): fixed bug where paths starting with |
|
3274 | * IPython/iplib.py (complete): fixed bug where paths starting with | |
3252 | '/' would be completed as magic names. |
|
3275 | '/' would be completed as magic names. | |
3253 |
|
3276 | |||
3254 | 2002-05-04 Fernando Perez <fperez@colorado.edu> |
|
3277 | 2002-05-04 Fernando Perez <fperez@colorado.edu> | |
3255 |
|
3278 | |||
3256 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to |
|
3279 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to | |
3257 | allow running full programs under the profiler's control. |
|
3280 | allow running full programs under the profiler's control. | |
3258 |
|
3281 | |||
3259 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars |
|
3282 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars | |
3260 | mode to report exceptions verbosely but without formatting |
|
3283 | mode to report exceptions verbosely but without formatting | |
3261 | variables. This addresses the issue of ipython 'freezing' (it's |
|
3284 | variables. This addresses the issue of ipython 'freezing' (it's | |
3262 | not frozen, but caught in an expensive formatting loop) when huge |
|
3285 | not frozen, but caught in an expensive formatting loop) when huge | |
3263 | variables are in the context of an exception. |
|
3286 | variables are in the context of an exception. | |
3264 | (VerboseTB.text): Added '--->' markers at line where exception was |
|
3287 | (VerboseTB.text): Added '--->' markers at line where exception was | |
3265 | triggered. Much clearer to read, especially in NoColor modes. |
|
3288 | triggered. Much clearer to read, especially in NoColor modes. | |
3266 |
|
3289 | |||
3267 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been |
|
3290 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been | |
3268 | implemented in reverse when changing to the new parse_options(). |
|
3291 | implemented in reverse when changing to the new parse_options(). | |
3269 |
|
3292 | |||
3270 | 2002-05-03 Fernando Perez <fperez@colorado.edu> |
|
3293 | 2002-05-03 Fernando Perez <fperez@colorado.edu> | |
3271 |
|
3294 | |||
3272 | * IPython/Magic.py (Magic.parse_options): new function so that |
|
3295 | * IPython/Magic.py (Magic.parse_options): new function so that | |
3273 | magics can parse options easier. |
|
3296 | magics can parse options easier. | |
3274 | (Magic.magic_prun): new function similar to profile.run(), |
|
3297 | (Magic.magic_prun): new function similar to profile.run(), | |
3275 | suggested by Chris Hart. |
|
3298 | suggested by Chris Hart. | |
3276 | (Magic.magic_cd): fixed behavior so that it only changes if |
|
3299 | (Magic.magic_cd): fixed behavior so that it only changes if | |
3277 | directory actually is in history. |
|
3300 | directory actually is in history. | |
3278 |
|
3301 | |||
3279 | * IPython/usage.py (__doc__): added information about potential |
|
3302 | * IPython/usage.py (__doc__): added information about potential | |
3280 | slowness of Verbose exception mode when there are huge data |
|
3303 | slowness of Verbose exception mode when there are huge data | |
3281 | structures to be formatted (thanks to Archie Paulson). |
|
3304 | structures to be formatted (thanks to Archie Paulson). | |
3282 |
|
3305 | |||
3283 | * IPython/ipmaker.py (make_IPython): Changed default logging |
|
3306 | * IPython/ipmaker.py (make_IPython): Changed default logging | |
3284 | (when simply called with -log) to use curr_dir/ipython.log in |
|
3307 | (when simply called with -log) to use curr_dir/ipython.log in | |
3285 | rotate mode. Fixed crash which was occuring with -log before |
|
3308 | rotate mode. Fixed crash which was occuring with -log before | |
3286 | (thanks to Jim Boyle). |
|
3309 | (thanks to Jim Boyle). | |
3287 |
|
3310 | |||
3288 | 2002-05-01 Fernando Perez <fperez@colorado.edu> |
|
3311 | 2002-05-01 Fernando Perez <fperez@colorado.edu> | |
3289 |
|
3312 | |||
3290 | * Released 0.2.11 for these fixes (mainly the ultraTB one which |
|
3313 | * Released 0.2.11 for these fixes (mainly the ultraTB one which | |
3291 | was nasty -- though somewhat of a corner case). |
|
3314 | was nasty -- though somewhat of a corner case). | |
3292 |
|
3315 | |||
3293 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to |
|
3316 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to | |
3294 | text (was a bug). |
|
3317 | text (was a bug). | |
3295 |
|
3318 | |||
3296 | 2002-04-30 Fernando Perez <fperez@colorado.edu> |
|
3319 | 2002-04-30 Fernando Perez <fperez@colorado.edu> | |
3297 |
|
3320 | |||
3298 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add |
|
3321 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add | |
3299 | a print after ^D or ^C from the user so that the In[] prompt |
|
3322 | a print after ^D or ^C from the user so that the In[] prompt | |
3300 | doesn't over-run the gnuplot one. |
|
3323 | doesn't over-run the gnuplot one. | |
3301 |
|
3324 | |||
3302 | 2002-04-29 Fernando Perez <fperez@colorado.edu> |
|
3325 | 2002-04-29 Fernando Perez <fperez@colorado.edu> | |
3303 |
|
3326 | |||
3304 | * Released 0.2.10 |
|
3327 | * Released 0.2.10 | |
3305 |
|
3328 | |||
3306 | * IPython/__release__.py (version): get date dynamically. |
|
3329 | * IPython/__release__.py (version): get date dynamically. | |
3307 |
|
3330 | |||
3308 | * Misc. documentation updates thanks to Arnd's comments. Also ran |
|
3331 | * Misc. documentation updates thanks to Arnd's comments. Also ran | |
3309 | a full spellcheck on the manual (hadn't been done in a while). |
|
3332 | a full spellcheck on the manual (hadn't been done in a while). | |
3310 |
|
3333 | |||
3311 | 2002-04-27 Fernando Perez <fperez@colorado.edu> |
|
3334 | 2002-04-27 Fernando Perez <fperez@colorado.edu> | |
3312 |
|
3335 | |||
3313 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where |
|
3336 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where | |
3314 | starting a log in mid-session would reset the input history list. |
|
3337 | starting a log in mid-session would reset the input history list. | |
3315 |
|
3338 | |||
3316 | 2002-04-26 Fernando Perez <fperez@colorado.edu> |
|
3339 | 2002-04-26 Fernando Perez <fperez@colorado.edu> | |
3317 |
|
3340 | |||
3318 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not |
|
3341 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not | |
3319 | all files were being included in an update. Now anything in |
|
3342 | all files were being included in an update. Now anything in | |
3320 | UserConfig that matches [A-Za-z]*.py will go (this excludes |
|
3343 | UserConfig that matches [A-Za-z]*.py will go (this excludes | |
3321 | __init__.py) |
|
3344 | __init__.py) | |
3322 |
|
3345 | |||
3323 | 2002-04-25 Fernando Perez <fperez@colorado.edu> |
|
3346 | 2002-04-25 Fernando Perez <fperez@colorado.edu> | |
3324 |
|
3347 | |||
3325 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ |
|
3348 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ | |
3326 | to __builtins__ so that any form of embedded or imported code can |
|
3349 | to __builtins__ so that any form of embedded or imported code can | |
3327 | test for being inside IPython. |
|
3350 | test for being inside IPython. | |
3328 |
|
3351 | |||
3329 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): |
|
3352 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): | |
3330 | changed to GnuplotMagic because it's now an importable module, |
|
3353 | changed to GnuplotMagic because it's now an importable module, | |
3331 | this makes the name follow that of the standard Gnuplot module. |
|
3354 | this makes the name follow that of the standard Gnuplot module. | |
3332 | GnuplotMagic can now be loaded at any time in mid-session. |
|
3355 | GnuplotMagic can now be loaded at any time in mid-session. | |
3333 |
|
3356 | |||
3334 | 2002-04-24 Fernando Perez <fperez@colorado.edu> |
|
3357 | 2002-04-24 Fernando Perez <fperez@colorado.edu> | |
3335 |
|
3358 | |||
3336 | * IPython/numutils.py: removed SIUnits. It doesn't properly set |
|
3359 | * IPython/numutils.py: removed SIUnits. It doesn't properly set | |
3337 | the globals (IPython has its own namespace) and the |
|
3360 | the globals (IPython has its own namespace) and the | |
3338 | PhysicalQuantity stuff is much better anyway. |
|
3361 | PhysicalQuantity stuff is much better anyway. | |
3339 |
|
3362 | |||
3340 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot |
|
3363 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot | |
3341 | embedding example to standard user directory for |
|
3364 | embedding example to standard user directory for | |
3342 | distribution. Also put it in the manual. |
|
3365 | distribution. Also put it in the manual. | |
3343 |
|
3366 | |||
3344 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot |
|
3367 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot | |
3345 | instance as first argument (so it doesn't rely on some obscure |
|
3368 | instance as first argument (so it doesn't rely on some obscure | |
3346 | hidden global). |
|
3369 | hidden global). | |
3347 |
|
3370 | |||
3348 | * IPython/UserConfig/ipythonrc.py: put () back in accepted |
|
3371 | * IPython/UserConfig/ipythonrc.py: put () back in accepted | |
3349 | delimiters. While it prevents ().TAB from working, it allows |
|
3372 | delimiters. While it prevents ().TAB from working, it allows | |
3350 | completions in open (... expressions. This is by far a more common |
|
3373 | completions in open (... expressions. This is by far a more common | |
3351 | case. |
|
3374 | case. | |
3352 |
|
3375 | |||
3353 | 2002-04-23 Fernando Perez <fperez@colorado.edu> |
|
3376 | 2002-04-23 Fernando Perez <fperez@colorado.edu> | |
3354 |
|
3377 | |||
3355 | * IPython/Extensions/InterpreterPasteInput.py: new |
|
3378 | * IPython/Extensions/InterpreterPasteInput.py: new | |
3356 | syntax-processing module for pasting lines with >>> or ... at the |
|
3379 | syntax-processing module for pasting lines with >>> or ... at the | |
3357 | start. |
|
3380 | start. | |
3358 |
|
3381 | |||
3359 | * IPython/Extensions/PhysicalQ_Interactive.py |
|
3382 | * IPython/Extensions/PhysicalQ_Interactive.py | |
3360 | (PhysicalQuantityInteractive.__int__): fixed to work with either |
|
3383 | (PhysicalQuantityInteractive.__int__): fixed to work with either | |
3361 | Numeric or math. |
|
3384 | Numeric or math. | |
3362 |
|
3385 | |||
3363 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the |
|
3386 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the | |
3364 | provided profiles. Now we have: |
|
3387 | provided profiles. Now we have: | |
3365 | -math -> math module as * and cmath with its own namespace. |
|
3388 | -math -> math module as * and cmath with its own namespace. | |
3366 | -numeric -> Numeric as *, plus gnuplot & grace |
|
3389 | -numeric -> Numeric as *, plus gnuplot & grace | |
3367 | -physics -> same as before |
|
3390 | -physics -> same as before | |
3368 |
|
3391 | |||
3369 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where |
|
3392 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where | |
3370 | user-defined magics wouldn't be found by @magic if they were |
|
3393 | user-defined magics wouldn't be found by @magic if they were | |
3371 | defined as class methods. Also cleaned up the namespace search |
|
3394 | defined as class methods. Also cleaned up the namespace search | |
3372 | logic and the string building (to use %s instead of many repeated |
|
3395 | logic and the string building (to use %s instead of many repeated | |
3373 | string adds). |
|
3396 | string adds). | |
3374 |
|
3397 | |||
3375 | * IPython/UserConfig/example-magic.py (magic_foo): updated example |
|
3398 | * IPython/UserConfig/example-magic.py (magic_foo): updated example | |
3376 | of user-defined magics to operate with class methods (cleaner, in |
|
3399 | of user-defined magics to operate with class methods (cleaner, in | |
3377 | line with the gnuplot code). |
|
3400 | line with the gnuplot code). | |
3378 |
|
3401 | |||
3379 | 2002-04-22 Fernando Perez <fperez@colorado.edu> |
|
3402 | 2002-04-22 Fernando Perez <fperez@colorado.edu> | |
3380 |
|
3403 | |||
3381 | * setup.py: updated dependency list so that manual is updated when |
|
3404 | * setup.py: updated dependency list so that manual is updated when | |
3382 | all included files change. |
|
3405 | all included files change. | |
3383 |
|
3406 | |||
3384 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring |
|
3407 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring | |
3385 | the delimiter removal option (the fix is ugly right now). |
|
3408 | the delimiter removal option (the fix is ugly right now). | |
3386 |
|
3409 | |||
3387 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load |
|
3410 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load | |
3388 | all of the math profile (quicker loading, no conflict between |
|
3411 | all of the math profile (quicker loading, no conflict between | |
3389 | g-9.8 and g-gnuplot). |
|
3412 | g-9.8 and g-gnuplot). | |
3390 |
|
3413 | |||
3391 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default |
|
3414 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default | |
3392 | name of post-mortem files to IPython_crash_report.txt. |
|
3415 | name of post-mortem files to IPython_crash_report.txt. | |
3393 |
|
3416 | |||
3394 | * Cleanup/update of the docs. Added all the new readline info and |
|
3417 | * Cleanup/update of the docs. Added all the new readline info and | |
3395 | formatted all lists as 'real lists'. |
|
3418 | formatted all lists as 'real lists'. | |
3396 |
|
3419 | |||
3397 | * IPython/ipmaker.py (make_IPython): removed now-obsolete |
|
3420 | * IPython/ipmaker.py (make_IPython): removed now-obsolete | |
3398 | tab-completion options, since the full readline parse_and_bind is |
|
3421 | tab-completion options, since the full readline parse_and_bind is | |
3399 | now accessible. |
|
3422 | now accessible. | |
3400 |
|
3423 | |||
3401 | * IPython/iplib.py (InteractiveShell.init_readline): Changed |
|
3424 | * IPython/iplib.py (InteractiveShell.init_readline): Changed | |
3402 | handling of readline options. Now users can specify any string to |
|
3425 | handling of readline options. Now users can specify any string to | |
3403 | be passed to parse_and_bind(), as well as the delimiters to be |
|
3426 | be passed to parse_and_bind(), as well as the delimiters to be | |
3404 | removed. |
|
3427 | removed. | |
3405 | (InteractiveShell.__init__): Added __name__ to the global |
|
3428 | (InteractiveShell.__init__): Added __name__ to the global | |
3406 | namespace so that things like Itpl which rely on its existence |
|
3429 | namespace so that things like Itpl which rely on its existence | |
3407 | don't crash. |
|
3430 | don't crash. | |
3408 | (InteractiveShell._prefilter): Defined the default with a _ so |
|
3431 | (InteractiveShell._prefilter): Defined the default with a _ so | |
3409 | that prefilter() is easier to override, while the default one |
|
3432 | that prefilter() is easier to override, while the default one | |
3410 | remains available. |
|
3433 | remains available. | |
3411 |
|
3434 | |||
3412 | 2002-04-18 Fernando Perez <fperez@colorado.edu> |
|
3435 | 2002-04-18 Fernando Perez <fperez@colorado.edu> | |
3413 |
|
3436 | |||
3414 | * Added information about pdb in the docs. |
|
3437 | * Added information about pdb in the docs. | |
3415 |
|
3438 | |||
3416 | 2002-04-17 Fernando Perez <fperez@colorado.edu> |
|
3439 | 2002-04-17 Fernando Perez <fperez@colorado.edu> | |
3417 |
|
3440 | |||
3418 | * IPython/ipmaker.py (make_IPython): added rc_override option to |
|
3441 | * IPython/ipmaker.py (make_IPython): added rc_override option to | |
3419 | allow passing config options at creation time which may override |
|
3442 | allow passing config options at creation time which may override | |
3420 | anything set in the config files or command line. This is |
|
3443 | anything set in the config files or command line. This is | |
3421 | particularly useful for configuring embedded instances. |
|
3444 | particularly useful for configuring embedded instances. | |
3422 |
|
3445 | |||
3423 | 2002-04-15 Fernando Perez <fperez@colorado.edu> |
|
3446 | 2002-04-15 Fernando Perez <fperez@colorado.edu> | |
3424 |
|
3447 | |||
3425 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could |
|
3448 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could | |
3426 | crash embedded instances because of the input cache falling out of |
|
3449 | crash embedded instances because of the input cache falling out of | |
3427 | sync with the output counter. |
|
3450 | sync with the output counter. | |
3428 |
|
3451 | |||
3429 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug |
|
3452 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug | |
3430 | mode which calls pdb after an uncaught exception in IPython itself. |
|
3453 | mode which calls pdb after an uncaught exception in IPython itself. | |
3431 |
|
3454 | |||
3432 | 2002-04-14 Fernando Perez <fperez@colorado.edu> |
|
3455 | 2002-04-14 Fernando Perez <fperez@colorado.edu> | |
3433 |
|
3456 | |||
3434 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up |
|
3457 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up | |
3435 | readline, fix it back after each call. |
|
3458 | readline, fix it back after each call. | |
3436 |
|
3459 | |||
3437 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private |
|
3460 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private | |
3438 | method to force all access via __call__(), which guarantees that |
|
3461 | method to force all access via __call__(), which guarantees that | |
3439 | traceback references are properly deleted. |
|
3462 | traceback references are properly deleted. | |
3440 |
|
3463 | |||
3441 | * IPython/Prompts.py (CachedOutput._display): minor fixes to |
|
3464 | * IPython/Prompts.py (CachedOutput._display): minor fixes to | |
3442 | improve printing when pprint is in use. |
|
3465 | improve printing when pprint is in use. | |
3443 |
|
3466 | |||
3444 | 2002-04-13 Fernando Perez <fperez@colorado.edu> |
|
3467 | 2002-04-13 Fernando Perez <fperez@colorado.edu> | |
3445 |
|
3468 | |||
3446 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit |
|
3469 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit | |
3447 | exceptions aren't caught anymore. If the user triggers one, he |
|
3470 | exceptions aren't caught anymore. If the user triggers one, he | |
3448 | should know why he's doing it and it should go all the way up, |
|
3471 | should know why he's doing it and it should go all the way up, | |
3449 | just like any other exception. So now @abort will fully kill the |
|
3472 | just like any other exception. So now @abort will fully kill the | |
3450 | embedded interpreter and the embedding code (unless that happens |
|
3473 | embedded interpreter and the embedding code (unless that happens | |
3451 | to catch SystemExit). |
|
3474 | to catch SystemExit). | |
3452 |
|
3475 | |||
3453 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag |
|
3476 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag | |
3454 | and a debugger() method to invoke the interactive pdb debugger |
|
3477 | and a debugger() method to invoke the interactive pdb debugger | |
3455 | after printing exception information. Also added the corresponding |
|
3478 | after printing exception information. Also added the corresponding | |
3456 | -pdb option and @pdb magic to control this feature, and updated |
|
3479 | -pdb option and @pdb magic to control this feature, and updated | |
3457 | the docs. After a suggestion from Christopher Hart |
|
3480 | the docs. After a suggestion from Christopher Hart | |
3458 | (hart-AT-caltech.edu). |
|
3481 | (hart-AT-caltech.edu). | |
3459 |
|
3482 | |||
3460 | 2002-04-12 Fernando Perez <fperez@colorado.edu> |
|
3483 | 2002-04-12 Fernando Perez <fperez@colorado.edu> | |
3461 |
|
3484 | |||
3462 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use |
|
3485 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use | |
3463 | the exception handlers defined by the user (not the CrashHandler) |
|
3486 | the exception handlers defined by the user (not the CrashHandler) | |
3464 | so that user exceptions don't trigger an ipython bug report. |
|
3487 | so that user exceptions don't trigger an ipython bug report. | |
3465 |
|
3488 | |||
3466 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme |
|
3489 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme | |
3467 | configurable (it should have always been so). |
|
3490 | configurable (it should have always been so). | |
3468 |
|
3491 | |||
3469 | 2002-03-26 Fernando Perez <fperez@colorado.edu> |
|
3492 | 2002-03-26 Fernando Perez <fperez@colorado.edu> | |
3470 |
|
3493 | |||
3471 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here |
|
3494 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here | |
3472 | and there to fix embedding namespace issues. This should all be |
|
3495 | and there to fix embedding namespace issues. This should all be | |
3473 | done in a more elegant way. |
|
3496 | done in a more elegant way. | |
3474 |
|
3497 | |||
3475 | 2002-03-25 Fernando Perez <fperez@colorado.edu> |
|
3498 | 2002-03-25 Fernando Perez <fperez@colorado.edu> | |
3476 |
|
3499 | |||
3477 | * IPython/genutils.py (get_home_dir): Try to make it work under |
|
3500 | * IPython/genutils.py (get_home_dir): Try to make it work under | |
3478 | win9x also. |
|
3501 | win9x also. | |
3479 |
|
3502 | |||
3480 | 2002-03-20 Fernando Perez <fperez@colorado.edu> |
|
3503 | 2002-03-20 Fernando Perez <fperez@colorado.edu> | |
3481 |
|
3504 | |||
3482 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave |
|
3505 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave | |
3483 | sys.displayhook untouched upon __init__. |
|
3506 | sys.displayhook untouched upon __init__. | |
3484 |
|
3507 | |||
3485 | 2002-03-19 Fernando Perez <fperez@colorado.edu> |
|
3508 | 2002-03-19 Fernando Perez <fperez@colorado.edu> | |
3486 |
|
3509 | |||
3487 | * Released 0.2.9 (for embedding bug, basically). |
|
3510 | * Released 0.2.9 (for embedding bug, basically). | |
3488 |
|
3511 | |||
3489 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit |
|
3512 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit | |
3490 | exceptions so that enclosing shell's state can be restored. |
|
3513 | exceptions so that enclosing shell's state can be restored. | |
3491 |
|
3514 | |||
3492 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize |
|
3515 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize | |
3493 | naming conventions in the .ipython/ dir. |
|
3516 | naming conventions in the .ipython/ dir. | |
3494 |
|
3517 | |||
3495 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' |
|
3518 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' | |
3496 | from delimiters list so filenames with - in them get expanded. |
|
3519 | from delimiters list so filenames with - in them get expanded. | |
3497 |
|
3520 | |||
3498 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with |
|
3521 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with | |
3499 | sys.displayhook not being properly restored after an embedded call. |
|
3522 | sys.displayhook not being properly restored after an embedded call. | |
3500 |
|
3523 | |||
3501 | 2002-03-18 Fernando Perez <fperez@colorado.edu> |
|
3524 | 2002-03-18 Fernando Perez <fperez@colorado.edu> | |
3502 |
|
3525 | |||
3503 | * Released 0.2.8 |
|
3526 | * Released 0.2.8 | |
3504 |
|
3527 | |||
3505 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where |
|
3528 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where | |
3506 | some files weren't being included in a -upgrade. |
|
3529 | some files weren't being included in a -upgrade. | |
3507 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous |
|
3530 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous | |
3508 | on' so that the first tab completes. |
|
3531 | on' so that the first tab completes. | |
3509 | (InteractiveShell.handle_magic): fixed bug with spaces around |
|
3532 | (InteractiveShell.handle_magic): fixed bug with spaces around | |
3510 | quotes breaking many magic commands. |
|
3533 | quotes breaking many magic commands. | |
3511 |
|
3534 | |||
3512 | * setup.py: added note about ignoring the syntax error messages at |
|
3535 | * setup.py: added note about ignoring the syntax error messages at | |
3513 | installation. |
|
3536 | installation. | |
3514 |
|
3537 | |||
3515 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished |
|
3538 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished | |
3516 | streamlining the gnuplot interface, now there's only one magic @gp. |
|
3539 | streamlining the gnuplot interface, now there's only one magic @gp. | |
3517 |
|
3540 | |||
3518 | 2002-03-17 Fernando Perez <fperez@colorado.edu> |
|
3541 | 2002-03-17 Fernando Perez <fperez@colorado.edu> | |
3519 |
|
3542 | |||
3520 | * IPython/UserConfig/magic_gnuplot.py: new name for the |
|
3543 | * IPython/UserConfig/magic_gnuplot.py: new name for the | |
3521 | example-magic_pm.py file. Much enhanced system, now with a shell |
|
3544 | example-magic_pm.py file. Much enhanced system, now with a shell | |
3522 | for communicating directly with gnuplot, one command at a time. |
|
3545 | for communicating directly with gnuplot, one command at a time. | |
3523 |
|
3546 | |||
3524 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent |
|
3547 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent | |
3525 | setting __name__=='__main__'. |
|
3548 | setting __name__=='__main__'. | |
3526 |
|
3549 | |||
3527 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added |
|
3550 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added | |
3528 | mini-shell for accessing gnuplot from inside ipython. Should |
|
3551 | mini-shell for accessing gnuplot from inside ipython. Should | |
3529 | extend it later for grace access too. Inspired by Arnd's |
|
3552 | extend it later for grace access too. Inspired by Arnd's | |
3530 | suggestion. |
|
3553 | suggestion. | |
3531 |
|
3554 | |||
3532 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when |
|
3555 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when | |
3533 | calling magic functions with () in their arguments. Thanks to Arnd |
|
3556 | calling magic functions with () in their arguments. Thanks to Arnd | |
3534 | Baecker for pointing this to me. |
|
3557 | Baecker for pointing this to me. | |
3535 |
|
3558 | |||
3536 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse |
|
3559 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse | |
3537 | infinitely for integer or complex arrays (only worked with floats). |
|
3560 | infinitely for integer or complex arrays (only worked with floats). | |
3538 |
|
3561 | |||
3539 | 2002-03-16 Fernando Perez <fperez@colorado.edu> |
|
3562 | 2002-03-16 Fernando Perez <fperez@colorado.edu> | |
3540 |
|
3563 | |||
3541 | * setup.py: Merged setup and setup_windows into a single script |
|
3564 | * setup.py: Merged setup and setup_windows into a single script | |
3542 | which properly handles things for windows users. |
|
3565 | which properly handles things for windows users. | |
3543 |
|
3566 | |||
3544 | 2002-03-15 Fernando Perez <fperez@colorado.edu> |
|
3567 | 2002-03-15 Fernando Perez <fperez@colorado.edu> | |
3545 |
|
3568 | |||
3546 | * Big change to the manual: now the magics are all automatically |
|
3569 | * Big change to the manual: now the magics are all automatically | |
3547 | documented. This information is generated from their docstrings |
|
3570 | documented. This information is generated from their docstrings | |
3548 | and put in a latex file included by the manual lyx file. This way |
|
3571 | and put in a latex file included by the manual lyx file. This way | |
3549 | we get always up to date information for the magics. The manual |
|
3572 | we get always up to date information for the magics. The manual | |
3550 | now also has proper version information, also auto-synced. |
|
3573 | now also has proper version information, also auto-synced. | |
3551 |
|
3574 | |||
3552 | For this to work, an undocumented --magic_docstrings option was added. |
|
3575 | For this to work, an undocumented --magic_docstrings option was added. | |
3553 |
|
3576 | |||
3554 | 2002-03-13 Fernando Perez <fperez@colorado.edu> |
|
3577 | 2002-03-13 Fernando Perez <fperez@colorado.edu> | |
3555 |
|
3578 | |||
3556 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors |
|
3579 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors | |
3557 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. |
|
3580 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. | |
3558 |
|
3581 | |||
3559 | 2002-03-12 Fernando Perez <fperez@colorado.edu> |
|
3582 | 2002-03-12 Fernando Perez <fperez@colorado.edu> | |
3560 |
|
3583 | |||
3561 | * IPython/ultraTB.py (TermColors): changed color escapes again to |
|
3584 | * IPython/ultraTB.py (TermColors): changed color escapes again to | |
3562 | fix the (old, reintroduced) line-wrapping bug. Basically, if |
|
3585 | fix the (old, reintroduced) line-wrapping bug. Basically, if | |
3563 | \001..\002 aren't given in the color escapes, lines get wrapped |
|
3586 | \001..\002 aren't given in the color escapes, lines get wrapped | |
3564 | weirdly. But giving those screws up old xterms and emacs terms. So |
|
3587 | weirdly. But giving those screws up old xterms and emacs terms. So | |
3565 | I added some logic for emacs terms to be ok, but I can't identify old |
|
3588 | I added some logic for emacs terms to be ok, but I can't identify old | |
3566 | xterms separately ($TERM=='xterm' for many terminals, like konsole). |
|
3589 | xterms separately ($TERM=='xterm' for many terminals, like konsole). | |
3567 |
|
3590 | |||
3568 | 2002-03-10 Fernando Perez <fperez@colorado.edu> |
|
3591 | 2002-03-10 Fernando Perez <fperez@colorado.edu> | |
3569 |
|
3592 | |||
3570 | * IPython/usage.py (__doc__): Various documentation cleanups and |
|
3593 | * IPython/usage.py (__doc__): Various documentation cleanups and | |
3571 | updates, both in usage docstrings and in the manual. |
|
3594 | updates, both in usage docstrings and in the manual. | |
3572 |
|
3595 | |||
3573 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for |
|
3596 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for | |
3574 | handling of caching. Set minimum acceptabe value for having a |
|
3597 | handling of caching. Set minimum acceptabe value for having a | |
3575 | cache at 20 values. |
|
3598 | cache at 20 values. | |
3576 |
|
3599 | |||
3577 | * IPython/iplib.py (InteractiveShell.user_setup): moved the |
|
3600 | * IPython/iplib.py (InteractiveShell.user_setup): moved the | |
3578 | install_first_time function to a method, renamed it and added an |
|
3601 | install_first_time function to a method, renamed it and added an | |
3579 | 'upgrade' mode. Now people can update their config directory with |
|
3602 | 'upgrade' mode. Now people can update their config directory with | |
3580 | a simple command line switch (-upgrade, also new). |
|
3603 | a simple command line switch (-upgrade, also new). | |
3581 |
|
3604 | |||
3582 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to |
|
3605 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to | |
3583 | @file (convenient for automagic users under Python >= 2.2). |
|
3606 | @file (convenient for automagic users under Python >= 2.2). | |
3584 | Removed @files (it seemed more like a plural than an abbrev. of |
|
3607 | Removed @files (it seemed more like a plural than an abbrev. of | |
3585 | 'file show'). |
|
3608 | 'file show'). | |
3586 |
|
3609 | |||
3587 | * IPython/iplib.py (install_first_time): Fixed crash if there were |
|
3610 | * IPython/iplib.py (install_first_time): Fixed crash if there were | |
3588 | backup files ('~') in .ipython/ install directory. |
|
3611 | backup files ('~') in .ipython/ install directory. | |
3589 |
|
3612 | |||
3590 | * IPython/ipmaker.py (make_IPython): fixes for new prompt |
|
3613 | * IPython/ipmaker.py (make_IPython): fixes for new prompt | |
3591 | system. Things look fine, but these changes are fairly |
|
3614 | system. Things look fine, but these changes are fairly | |
3592 | intrusive. Test them for a few days. |
|
3615 | intrusive. Test them for a few days. | |
3593 |
|
3616 | |||
3594 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of |
|
3617 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of | |
3595 | the prompts system. Now all in/out prompt strings are user |
|
3618 | the prompts system. Now all in/out prompt strings are user | |
3596 | controllable. This is particularly useful for embedding, as one |
|
3619 | controllable. This is particularly useful for embedding, as one | |
3597 | can tag embedded instances with particular prompts. |
|
3620 | can tag embedded instances with particular prompts. | |
3598 |
|
3621 | |||
3599 | Also removed global use of sys.ps1/2, which now allows nested |
|
3622 | Also removed global use of sys.ps1/2, which now allows nested | |
3600 | embeddings without any problems. Added command-line options for |
|
3623 | embeddings without any problems. Added command-line options for | |
3601 | the prompt strings. |
|
3624 | the prompt strings. | |
3602 |
|
3625 | |||
3603 | 2002-03-08 Fernando Perez <fperez@colorado.edu> |
|
3626 | 2002-03-08 Fernando Perez <fperez@colorado.edu> | |
3604 |
|
3627 | |||
3605 | * IPython/UserConfig/example-embed-short.py (ipshell): added |
|
3628 | * IPython/UserConfig/example-embed-short.py (ipshell): added | |
3606 | example file with the bare minimum code for embedding. |
|
3629 | example file with the bare minimum code for embedding. | |
3607 |
|
3630 | |||
3608 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added |
|
3631 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added | |
3609 | functionality for the embeddable shell to be activated/deactivated |
|
3632 | functionality for the embeddable shell to be activated/deactivated | |
3610 | either globally or at each call. |
|
3633 | either globally or at each call. | |
3611 |
|
3634 | |||
3612 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of |
|
3635 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of | |
3613 | rewriting the prompt with '--->' for auto-inputs with proper |
|
3636 | rewriting the prompt with '--->' for auto-inputs with proper | |
3614 | coloring. Now the previous UGLY hack in handle_auto() is gone, and |
|
3637 | coloring. Now the previous UGLY hack in handle_auto() is gone, and | |
3615 | this is handled by the prompts class itself, as it should. |
|
3638 | this is handled by the prompts class itself, as it should. | |
3616 |
|
3639 | |||
3617 | 2002-03-05 Fernando Perez <fperez@colorado.edu> |
|
3640 | 2002-03-05 Fernando Perez <fperez@colorado.edu> | |
3618 |
|
3641 | |||
3619 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to |
|
3642 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to | |
3620 | @logstart to avoid name clashes with the math log function. |
|
3643 | @logstart to avoid name clashes with the math log function. | |
3621 |
|
3644 | |||
3622 | * Big updates to X/Emacs section of the manual. |
|
3645 | * Big updates to X/Emacs section of the manual. | |
3623 |
|
3646 | |||
3624 | * Removed ipython_emacs. Milan explained to me how to pass |
|
3647 | * Removed ipython_emacs. Milan explained to me how to pass | |
3625 | arguments to ipython through Emacs. Some day I'm going to end up |
|
3648 | arguments to ipython through Emacs. Some day I'm going to end up | |
3626 | learning some lisp... |
|
3649 | learning some lisp... | |
3627 |
|
3650 | |||
3628 | 2002-03-04 Fernando Perez <fperez@colorado.edu> |
|
3651 | 2002-03-04 Fernando Perez <fperez@colorado.edu> | |
3629 |
|
3652 | |||
3630 | * IPython/ipython_emacs: Created script to be used as the |
|
3653 | * IPython/ipython_emacs: Created script to be used as the | |
3631 | py-python-command Emacs variable so we can pass IPython |
|
3654 | py-python-command Emacs variable so we can pass IPython | |
3632 | parameters. I can't figure out how to tell Emacs directly to pass |
|
3655 | parameters. I can't figure out how to tell Emacs directly to pass | |
3633 | parameters to IPython, so a dummy shell script will do it. |
|
3656 | parameters to IPython, so a dummy shell script will do it. | |
3634 |
|
3657 | |||
3635 | Other enhancements made for things to work better under Emacs' |
|
3658 | Other enhancements made for things to work better under Emacs' | |
3636 | various types of terminals. Many thanks to Milan Zamazal |
|
3659 | various types of terminals. Many thanks to Milan Zamazal | |
3637 | <pdm-AT-zamazal.org> for all the suggestions and pointers. |
|
3660 | <pdm-AT-zamazal.org> for all the suggestions and pointers. | |
3638 |
|
3661 | |||
3639 | 2002-03-01 Fernando Perez <fperez@colorado.edu> |
|
3662 | 2002-03-01 Fernando Perez <fperez@colorado.edu> | |
3640 |
|
3663 | |||
3641 | * IPython/ipmaker.py (make_IPython): added a --readline! option so |
|
3664 | * IPython/ipmaker.py (make_IPython): added a --readline! option so | |
3642 | that loading of readline is now optional. This gives better |
|
3665 | that loading of readline is now optional. This gives better | |
3643 | control to emacs users. |
|
3666 | control to emacs users. | |
3644 |
|
3667 | |||
3645 | * IPython/ultraTB.py (__date__): Modified color escape sequences |
|
3668 | * IPython/ultraTB.py (__date__): Modified color escape sequences | |
3646 | and now things work fine under xterm and in Emacs' term buffers |
|
3669 | and now things work fine under xterm and in Emacs' term buffers | |
3647 | (though not shell ones). Well, in emacs you get colors, but all |
|
3670 | (though not shell ones). Well, in emacs you get colors, but all | |
3648 | seem to be 'light' colors (no difference between dark and light |
|
3671 | seem to be 'light' colors (no difference between dark and light | |
3649 | ones). But the garbage chars are gone, and also in xterms. It |
|
3672 | ones). But the garbage chars are gone, and also in xterms. It | |
3650 | seems that now I'm using 'cleaner' ansi sequences. |
|
3673 | seems that now I'm using 'cleaner' ansi sequences. | |
3651 |
|
3674 | |||
3652 | 2002-02-21 Fernando Perez <fperez@colorado.edu> |
|
3675 | 2002-02-21 Fernando Perez <fperez@colorado.edu> | |
3653 |
|
3676 | |||
3654 | * Released 0.2.7 (mainly to publish the scoping fix). |
|
3677 | * Released 0.2.7 (mainly to publish the scoping fix). | |
3655 |
|
3678 | |||
3656 | * IPython/Logger.py (Logger.logstate): added. A corresponding |
|
3679 | * IPython/Logger.py (Logger.logstate): added. A corresponding | |
3657 | @logstate magic was created. |
|
3680 | @logstate magic was created. | |
3658 |
|
3681 | |||
3659 | * IPython/Magic.py: fixed nested scoping problem under Python |
|
3682 | * IPython/Magic.py: fixed nested scoping problem under Python | |
3660 | 2.1.x (automagic wasn't working). |
|
3683 | 2.1.x (automagic wasn't working). | |
3661 |
|
3684 | |||
3662 | 2002-02-20 Fernando Perez <fperez@colorado.edu> |
|
3685 | 2002-02-20 Fernando Perez <fperez@colorado.edu> | |
3663 |
|
3686 | |||
3664 | * Released 0.2.6. |
|
3687 | * Released 0.2.6. | |
3665 |
|
3688 | |||
3666 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' |
|
3689 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' | |
3667 | option so that logs can come out without any headers at all. |
|
3690 | option so that logs can come out without any headers at all. | |
3668 |
|
3691 | |||
3669 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for |
|
3692 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for | |
3670 | SciPy. |
|
3693 | SciPy. | |
3671 |
|
3694 | |||
3672 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so |
|
3695 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so | |
3673 | that embedded IPython calls don't require vars() to be explicitly |
|
3696 | that embedded IPython calls don't require vars() to be explicitly | |
3674 | passed. Now they are extracted from the caller's frame (code |
|
3697 | passed. Now they are extracted from the caller's frame (code | |
3675 | snatched from Eric Jones' weave). Added better documentation to |
|
3698 | snatched from Eric Jones' weave). Added better documentation to | |
3676 | the section on embedding and the example file. |
|
3699 | the section on embedding and the example file. | |
3677 |
|
3700 | |||
3678 | * IPython/genutils.py (page): Changed so that under emacs, it just |
|
3701 | * IPython/genutils.py (page): Changed so that under emacs, it just | |
3679 | prints the string. You can then page up and down in the emacs |
|
3702 | prints the string. You can then page up and down in the emacs | |
3680 | buffer itself. This is how the builtin help() works. |
|
3703 | buffer itself. This is how the builtin help() works. | |
3681 |
|
3704 | |||
3682 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with |
|
3705 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with | |
3683 | macro scoping: macros need to be executed in the user's namespace |
|
3706 | macro scoping: macros need to be executed in the user's namespace | |
3684 | to work as if they had been typed by the user. |
|
3707 | to work as if they had been typed by the user. | |
3685 |
|
3708 | |||
3686 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they |
|
3709 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they | |
3687 | execute automatically (no need to type 'exec...'). They then |
|
3710 | execute automatically (no need to type 'exec...'). They then | |
3688 | behave like 'true macros'. The printing system was also modified |
|
3711 | behave like 'true macros'. The printing system was also modified | |
3689 | for this to work. |
|
3712 | for this to work. | |
3690 |
|
3713 | |||
3691 | 2002-02-19 Fernando Perez <fperez@colorado.edu> |
|
3714 | 2002-02-19 Fernando Perez <fperez@colorado.edu> | |
3692 |
|
3715 | |||
3693 | * IPython/genutils.py (page_file): new function for paging files |
|
3716 | * IPython/genutils.py (page_file): new function for paging files | |
3694 | in an OS-independent way. Also necessary for file viewing to work |
|
3717 | in an OS-independent way. Also necessary for file viewing to work | |
3695 | well inside Emacs buffers. |
|
3718 | well inside Emacs buffers. | |
3696 | (page): Added checks for being in an emacs buffer. |
|
3719 | (page): Added checks for being in an emacs buffer. | |
3697 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed |
|
3720 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed | |
3698 | same bug in iplib. |
|
3721 | same bug in iplib. | |
3699 |
|
3722 | |||
3700 | 2002-02-18 Fernando Perez <fperez@colorado.edu> |
|
3723 | 2002-02-18 Fernando Perez <fperez@colorado.edu> | |
3701 |
|
3724 | |||
3702 | * IPython/iplib.py (InteractiveShell.init_readline): modified use |
|
3725 | * IPython/iplib.py (InteractiveShell.init_readline): modified use | |
3703 | of readline so that IPython can work inside an Emacs buffer. |
|
3726 | of readline so that IPython can work inside an Emacs buffer. | |
3704 |
|
3727 | |||
3705 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to |
|
3728 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to | |
3706 | method signatures (they weren't really bugs, but it looks cleaner |
|
3729 | method signatures (they weren't really bugs, but it looks cleaner | |
3707 | and keeps PyChecker happy). |
|
3730 | and keeps PyChecker happy). | |
3708 |
|
3731 | |||
3709 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP |
|
3732 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP | |
3710 | for implementing various user-defined hooks. Currently only |
|
3733 | for implementing various user-defined hooks. Currently only | |
3711 | display is done. |
|
3734 | display is done. | |
3712 |
|
3735 | |||
3713 | * IPython/Prompts.py (CachedOutput._display): changed display |
|
3736 | * IPython/Prompts.py (CachedOutput._display): changed display | |
3714 | functions so that they can be dynamically changed by users easily. |
|
3737 | functions so that they can be dynamically changed by users easily. | |
3715 |
|
3738 | |||
3716 | * IPython/Extensions/numeric_formats.py (num_display): added an |
|
3739 | * IPython/Extensions/numeric_formats.py (num_display): added an | |
3717 | extension for printing NumPy arrays in flexible manners. It |
|
3740 | extension for printing NumPy arrays in flexible manners. It | |
3718 | doesn't do anything yet, but all the structure is in |
|
3741 | doesn't do anything yet, but all the structure is in | |
3719 | place. Ultimately the plan is to implement output format control |
|
3742 | place. Ultimately the plan is to implement output format control | |
3720 | like in Octave. |
|
3743 | like in Octave. | |
3721 |
|
3744 | |||
3722 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic |
|
3745 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic | |
3723 | methods are found at run-time by all the automatic machinery. |
|
3746 | methods are found at run-time by all the automatic machinery. | |
3724 |
|
3747 | |||
3725 | 2002-02-17 Fernando Perez <fperez@colorado.edu> |
|
3748 | 2002-02-17 Fernando Perez <fperez@colorado.edu> | |
3726 |
|
3749 | |||
3727 | * setup_Windows.py (make_shortcut): documented. Cleaned up the |
|
3750 | * setup_Windows.py (make_shortcut): documented. Cleaned up the | |
3728 | whole file a little. |
|
3751 | whole file a little. | |
3729 |
|
3752 | |||
3730 | * ToDo: closed this document. Now there's a new_design.lyx |
|
3753 | * ToDo: closed this document. Now there's a new_design.lyx | |
3731 | document for all new ideas. Added making a pdf of it for the |
|
3754 | document for all new ideas. Added making a pdf of it for the | |
3732 | end-user distro. |
|
3755 | end-user distro. | |
3733 |
|
3756 | |||
3734 | * IPython/Logger.py (Logger.switch_log): Created this to replace |
|
3757 | * IPython/Logger.py (Logger.switch_log): Created this to replace | |
3735 | logon() and logoff(). It also fixes a nasty crash reported by |
|
3758 | logon() and logoff(). It also fixes a nasty crash reported by | |
3736 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. |
|
3759 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. | |
3737 |
|
3760 | |||
3738 | * IPython/iplib.py (complete): got auto-completion to work with |
|
3761 | * IPython/iplib.py (complete): got auto-completion to work with | |
3739 | automagic (I had wanted this for a long time). |
|
3762 | automagic (I had wanted this for a long time). | |
3740 |
|
3763 | |||
3741 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias |
|
3764 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias | |
3742 | to @file, since file() is now a builtin and clashes with automagic |
|
3765 | to @file, since file() is now a builtin and clashes with automagic | |
3743 | for @file. |
|
3766 | for @file. | |
3744 |
|
3767 | |||
3745 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All |
|
3768 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All | |
3746 | of this was previously in iplib, which had grown to more than 2000 |
|
3769 | of this was previously in iplib, which had grown to more than 2000 | |
3747 | lines, way too long. No new functionality, but it makes managing |
|
3770 | lines, way too long. No new functionality, but it makes managing | |
3748 | the code a bit easier. |
|
3771 | the code a bit easier. | |
3749 |
|
3772 | |||
3750 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version |
|
3773 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version | |
3751 | information to crash reports. |
|
3774 | information to crash reports. | |
3752 |
|
3775 | |||
3753 | 2002-02-12 Fernando Perez <fperez@colorado.edu> |
|
3776 | 2002-02-12 Fernando Perez <fperez@colorado.edu> | |
3754 |
|
3777 | |||
3755 | * Released 0.2.5. |
|
3778 | * Released 0.2.5. | |
3756 |
|
3779 | |||
3757 | 2002-02-11 Fernando Perez <fperez@colorado.edu> |
|
3780 | 2002-02-11 Fernando Perez <fperez@colorado.edu> | |
3758 |
|
3781 | |||
3759 | * Wrote a relatively complete Windows installer. It puts |
|
3782 | * Wrote a relatively complete Windows installer. It puts | |
3760 | everything in place, creates Start Menu entries and fixes the |
|
3783 | everything in place, creates Start Menu entries and fixes the | |
3761 | color issues. Nothing fancy, but it works. |
|
3784 | color issues. Nothing fancy, but it works. | |
3762 |
|
3785 | |||
3763 | 2002-02-10 Fernando Perez <fperez@colorado.edu> |
|
3786 | 2002-02-10 Fernando Perez <fperez@colorado.edu> | |
3764 |
|
3787 | |||
3765 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an |
|
3788 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an | |
3766 | os.path.expanduser() call so that we can type @run ~/myfile.py and |
|
3789 | os.path.expanduser() call so that we can type @run ~/myfile.py and | |
3767 | have thigs work as expected. |
|
3790 | have thigs work as expected. | |
3768 |
|
3791 | |||
3769 | * IPython/genutils.py (page): fixed exception handling so things |
|
3792 | * IPython/genutils.py (page): fixed exception handling so things | |
3770 | work both in Unix and Windows correctly. Quitting a pager triggers |
|
3793 | work both in Unix and Windows correctly. Quitting a pager triggers | |
3771 | an IOError/broken pipe in Unix, and in windows not finding a pager |
|
3794 | an IOError/broken pipe in Unix, and in windows not finding a pager | |
3772 | is also an IOError, so I had to actually look at the return value |
|
3795 | is also an IOError, so I had to actually look at the return value | |
3773 | of the exception, not just the exception itself. Should be ok now. |
|
3796 | of the exception, not just the exception itself. Should be ok now. | |
3774 |
|
3797 | |||
3775 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): |
|
3798 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): | |
3776 | modified to allow case-insensitive color scheme changes. |
|
3799 | modified to allow case-insensitive color scheme changes. | |
3777 |
|
3800 | |||
3778 | 2002-02-09 Fernando Perez <fperez@colorado.edu> |
|
3801 | 2002-02-09 Fernando Perez <fperez@colorado.edu> | |
3779 |
|
3802 | |||
3780 | * IPython/genutils.py (native_line_ends): new function to leave |
|
3803 | * IPython/genutils.py (native_line_ends): new function to leave | |
3781 | user config files with os-native line-endings. |
|
3804 | user config files with os-native line-endings. | |
3782 |
|
3805 | |||
3783 | * README and manual updates. |
|
3806 | * README and manual updates. | |
3784 |
|
3807 | |||
3785 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes |
|
3808 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes | |
3786 | instead of StringType to catch Unicode strings. |
|
3809 | instead of StringType to catch Unicode strings. | |
3787 |
|
3810 | |||
3788 | * IPython/genutils.py (filefind): fixed bug for paths with |
|
3811 | * IPython/genutils.py (filefind): fixed bug for paths with | |
3789 | embedded spaces (very common in Windows). |
|
3812 | embedded spaces (very common in Windows). | |
3790 |
|
3813 | |||
3791 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc |
|
3814 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc | |
3792 | files under Windows, so that they get automatically associated |
|
3815 | files under Windows, so that they get automatically associated | |
3793 | with a text editor. Windows makes it a pain to handle |
|
3816 | with a text editor. Windows makes it a pain to handle | |
3794 | extension-less files. |
|
3817 | extension-less files. | |
3795 |
|
3818 | |||
3796 | * IPython/iplib.py (InteractiveShell.init_readline): Made the |
|
3819 | * IPython/iplib.py (InteractiveShell.init_readline): Made the | |
3797 | warning about readline only occur for Posix. In Windows there's no |
|
3820 | warning about readline only occur for Posix. In Windows there's no | |
3798 | way to get readline, so why bother with the warning. |
|
3821 | way to get readline, so why bother with the warning. | |
3799 |
|
3822 | |||
3800 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ |
|
3823 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ | |
3801 | for __str__ instead of dir(self), since dir() changed in 2.2. |
|
3824 | for __str__ instead of dir(self), since dir() changed in 2.2. | |
3802 |
|
3825 | |||
3803 | * Ported to Windows! Tested on XP, I suspect it should work fine |
|
3826 | * Ported to Windows! Tested on XP, I suspect it should work fine | |
3804 | on NT/2000, but I don't think it will work on 98 et al. That |
|
3827 | on NT/2000, but I don't think it will work on 98 et al. That | |
3805 | series of Windows is such a piece of junk anyway that I won't try |
|
3828 | series of Windows is such a piece of junk anyway that I won't try | |
3806 | porting it there. The XP port was straightforward, showed a few |
|
3829 | porting it there. The XP port was straightforward, showed a few | |
3807 | bugs here and there (fixed all), in particular some string |
|
3830 | bugs here and there (fixed all), in particular some string | |
3808 | handling stuff which required considering Unicode strings (which |
|
3831 | handling stuff which required considering Unicode strings (which | |
3809 | Windows uses). This is good, but hasn't been too tested :) No |
|
3832 | Windows uses). This is good, but hasn't been too tested :) No | |
3810 | fancy installer yet, I'll put a note in the manual so people at |
|
3833 | fancy installer yet, I'll put a note in the manual so people at | |
3811 | least make manually a shortcut. |
|
3834 | least make manually a shortcut. | |
3812 |
|
3835 | |||
3813 | * IPython/iplib.py (Magic.magic_colors): Unified the color options |
|
3836 | * IPython/iplib.py (Magic.magic_colors): Unified the color options | |
3814 | into a single one, "colors". This now controls both prompt and |
|
3837 | into a single one, "colors". This now controls both prompt and | |
3815 | exception color schemes, and can be changed both at startup |
|
3838 | exception color schemes, and can be changed both at startup | |
3816 | (either via command-line switches or via ipythonrc files) and at |
|
3839 | (either via command-line switches or via ipythonrc files) and at | |
3817 | runtime, with @colors. |
|
3840 | runtime, with @colors. | |
3818 | (Magic.magic_run): renamed @prun to @run and removed the old |
|
3841 | (Magic.magic_run): renamed @prun to @run and removed the old | |
3819 | @run. The two were too similar to warrant keeping both. |
|
3842 | @run. The two were too similar to warrant keeping both. | |
3820 |
|
3843 | |||
3821 | 2002-02-03 Fernando Perez <fperez@colorado.edu> |
|
3844 | 2002-02-03 Fernando Perez <fperez@colorado.edu> | |
3822 |
|
3845 | |||
3823 | * IPython/iplib.py (install_first_time): Added comment on how to |
|
3846 | * IPython/iplib.py (install_first_time): Added comment on how to | |
3824 | configure the color options for first-time users. Put a <return> |
|
3847 | configure the color options for first-time users. Put a <return> | |
3825 | request at the end so that small-terminal users get a chance to |
|
3848 | request at the end so that small-terminal users get a chance to | |
3826 | read the startup info. |
|
3849 | read the startup info. | |
3827 |
|
3850 | |||
3828 | 2002-01-23 Fernando Perez <fperez@colorado.edu> |
|
3851 | 2002-01-23 Fernando Perez <fperez@colorado.edu> | |
3829 |
|
3852 | |||
3830 | * IPython/iplib.py (CachedOutput.update): Changed output memory |
|
3853 | * IPython/iplib.py (CachedOutput.update): Changed output memory | |
3831 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For |
|
3854 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For | |
3832 | input history we still use _i. Did this b/c these variable are |
|
3855 | input history we still use _i. Did this b/c these variable are | |
3833 | very commonly used in interactive work, so the less we need to |
|
3856 | very commonly used in interactive work, so the less we need to | |
3834 | type the better off we are. |
|
3857 | type the better off we are. | |
3835 | (Magic.magic_prun): updated @prun to better handle the namespaces |
|
3858 | (Magic.magic_prun): updated @prun to better handle the namespaces | |
3836 | the file will run in, including a fix for __name__ not being set |
|
3859 | the file will run in, including a fix for __name__ not being set | |
3837 | before. |
|
3860 | before. | |
3838 |
|
3861 | |||
3839 | 2002-01-20 Fernando Perez <fperez@colorado.edu> |
|
3862 | 2002-01-20 Fernando Perez <fperez@colorado.edu> | |
3840 |
|
3863 | |||
3841 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of |
|
3864 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of | |
3842 | extra garbage for Python 2.2. Need to look more carefully into |
|
3865 | extra garbage for Python 2.2. Need to look more carefully into | |
3843 | this later. |
|
3866 | this later. | |
3844 |
|
3867 | |||
3845 | 2002-01-19 Fernando Perez <fperez@colorado.edu> |
|
3868 | 2002-01-19 Fernando Perez <fperez@colorado.edu> | |
3846 |
|
3869 | |||
3847 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to |
|
3870 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to | |
3848 | display SyntaxError exceptions properly formatted when they occur |
|
3871 | display SyntaxError exceptions properly formatted when they occur | |
3849 | (they can be triggered by imported code). |
|
3872 | (they can be triggered by imported code). | |
3850 |
|
3873 | |||
3851 | 2002-01-18 Fernando Perez <fperez@colorado.edu> |
|
3874 | 2002-01-18 Fernando Perez <fperez@colorado.edu> | |
3852 |
|
3875 | |||
3853 | * IPython/iplib.py (InteractiveShell.safe_execfile): now |
|
3876 | * IPython/iplib.py (InteractiveShell.safe_execfile): now | |
3854 | SyntaxError exceptions are reported nicely formatted, instead of |
|
3877 | SyntaxError exceptions are reported nicely formatted, instead of | |
3855 | spitting out only offset information as before. |
|
3878 | spitting out only offset information as before. | |
3856 | (Magic.magic_prun): Added the @prun function for executing |
|
3879 | (Magic.magic_prun): Added the @prun function for executing | |
3857 | programs with command line args inside IPython. |
|
3880 | programs with command line args inside IPython. | |
3858 |
|
3881 | |||
3859 | 2002-01-16 Fernando Perez <fperez@colorado.edu> |
|
3882 | 2002-01-16 Fernando Perez <fperez@colorado.edu> | |
3860 |
|
3883 | |||
3861 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist |
|
3884 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist | |
3862 | to *not* include the last item given in a range. This brings their |
|
3885 | to *not* include the last item given in a range. This brings their | |
3863 | behavior in line with Python's slicing: |
|
3886 | behavior in line with Python's slicing: | |
3864 | a[n1:n2] -> a[n1]...a[n2-1] |
|
3887 | a[n1:n2] -> a[n1]...a[n2-1] | |
3865 | It may be a bit less convenient, but I prefer to stick to Python's |
|
3888 | It may be a bit less convenient, but I prefer to stick to Python's | |
3866 | conventions *everywhere*, so users never have to wonder. |
|
3889 | conventions *everywhere*, so users never have to wonder. | |
3867 | (Magic.magic_macro): Added @macro function to ease the creation of |
|
3890 | (Magic.magic_macro): Added @macro function to ease the creation of | |
3868 | macros. |
|
3891 | macros. | |
3869 |
|
3892 | |||
3870 | 2002-01-05 Fernando Perez <fperez@colorado.edu> |
|
3893 | 2002-01-05 Fernando Perez <fperez@colorado.edu> | |
3871 |
|
3894 | |||
3872 | * Released 0.2.4. |
|
3895 | * Released 0.2.4. | |
3873 |
|
3896 | |||
3874 | * IPython/iplib.py (Magic.magic_pdef): |
|
3897 | * IPython/iplib.py (Magic.magic_pdef): | |
3875 | (InteractiveShell.safe_execfile): report magic lines and error |
|
3898 | (InteractiveShell.safe_execfile): report magic lines and error | |
3876 | lines without line numbers so one can easily copy/paste them for |
|
3899 | lines without line numbers so one can easily copy/paste them for | |
3877 | re-execution. |
|
3900 | re-execution. | |
3878 |
|
3901 | |||
3879 | * Updated manual with recent changes. |
|
3902 | * Updated manual with recent changes. | |
3880 |
|
3903 | |||
3881 | * IPython/iplib.py (Magic.magic_oinfo): added constructor |
|
3904 | * IPython/iplib.py (Magic.magic_oinfo): added constructor | |
3882 | docstring printing when class? is called. Very handy for knowing |
|
3905 | docstring printing when class? is called. Very handy for knowing | |
3883 | how to create class instances (as long as __init__ is well |
|
3906 | how to create class instances (as long as __init__ is well | |
3884 | documented, of course :) |
|
3907 | documented, of course :) | |
3885 | (Magic.magic_doc): print both class and constructor docstrings. |
|
3908 | (Magic.magic_doc): print both class and constructor docstrings. | |
3886 | (Magic.magic_pdef): give constructor info if passed a class and |
|
3909 | (Magic.magic_pdef): give constructor info if passed a class and | |
3887 | __call__ info for callable object instances. |
|
3910 | __call__ info for callable object instances. | |
3888 |
|
3911 | |||
3889 | 2002-01-04 Fernando Perez <fperez@colorado.edu> |
|
3912 | 2002-01-04 Fernando Perez <fperez@colorado.edu> | |
3890 |
|
3913 | |||
3891 | * Made deep_reload() off by default. It doesn't always work |
|
3914 | * Made deep_reload() off by default. It doesn't always work | |
3892 | exactly as intended, so it's probably safer to have it off. It's |
|
3915 | exactly as intended, so it's probably safer to have it off. It's | |
3893 | still available as dreload() anyway, so nothing is lost. |
|
3916 | still available as dreload() anyway, so nothing is lost. | |
3894 |
|
3917 | |||
3895 | 2002-01-02 Fernando Perez <fperez@colorado.edu> |
|
3918 | 2002-01-02 Fernando Perez <fperez@colorado.edu> | |
3896 |
|
3919 | |||
3897 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, |
|
3920 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, | |
3898 | so I wanted an updated release). |
|
3921 | so I wanted an updated release). | |
3899 |
|
3922 | |||
3900 | 2001-12-27 Fernando Perez <fperez@colorado.edu> |
|
3923 | 2001-12-27 Fernando Perez <fperez@colorado.edu> | |
3901 |
|
3924 | |||
3902 | * IPython/iplib.py (InteractiveShell.interact): Added the original |
|
3925 | * IPython/iplib.py (InteractiveShell.interact): Added the original | |
3903 | code from 'code.py' for this module in order to change the |
|
3926 | code from 'code.py' for this module in order to change the | |
3904 | handling of a KeyboardInterrupt. This was necessary b/c otherwise |
|
3927 | handling of a KeyboardInterrupt. This was necessary b/c otherwise | |
3905 | the history cache would break when the user hit Ctrl-C, and |
|
3928 | the history cache would break when the user hit Ctrl-C, and | |
3906 | interact() offers no way to add any hooks to it. |
|
3929 | interact() offers no way to add any hooks to it. | |
3907 |
|
3930 | |||
3908 | 2001-12-23 Fernando Perez <fperez@colorado.edu> |
|
3931 | 2001-12-23 Fernando Perez <fperez@colorado.edu> | |
3909 |
|
3932 | |||
3910 | * setup.py: added check for 'MANIFEST' before trying to remove |
|
3933 | * setup.py: added check for 'MANIFEST' before trying to remove | |
3911 | it. Thanks to Sean Reifschneider. |
|
3934 | it. Thanks to Sean Reifschneider. | |
3912 |
|
3935 | |||
3913 | 2001-12-22 Fernando Perez <fperez@colorado.edu> |
|
3936 | 2001-12-22 Fernando Perez <fperez@colorado.edu> | |
3914 |
|
3937 | |||
3915 | * Released 0.2.2. |
|
3938 | * Released 0.2.2. | |
3916 |
|
3939 | |||
3917 | * Finished (reasonably) writing the manual. Later will add the |
|
3940 | * Finished (reasonably) writing the manual. Later will add the | |
3918 | python-standard navigation stylesheets, but for the time being |
|
3941 | python-standard navigation stylesheets, but for the time being | |
3919 | it's fairly complete. Distribution will include html and pdf |
|
3942 | it's fairly complete. Distribution will include html and pdf | |
3920 | versions. |
|
3943 | versions. | |
3921 |
|
3944 | |||
3922 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu |
|
3945 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu | |
3923 | (MayaVi author). |
|
3946 | (MayaVi author). | |
3924 |
|
3947 | |||
3925 | 2001-12-21 Fernando Perez <fperez@colorado.edu> |
|
3948 | 2001-12-21 Fernando Perez <fperez@colorado.edu> | |
3926 |
|
3949 | |||
3927 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a |
|
3950 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a | |
3928 | good public release, I think (with the manual and the distutils |
|
3951 | good public release, I think (with the manual and the distutils | |
3929 | installer). The manual can use some work, but that can go |
|
3952 | installer). The manual can use some work, but that can go | |
3930 | slowly. Otherwise I think it's quite nice for end users. Next |
|
3953 | slowly. Otherwise I think it's quite nice for end users. Next | |
3931 | summer, rewrite the guts of it... |
|
3954 | summer, rewrite the guts of it... | |
3932 |
|
3955 | |||
3933 | * Changed format of ipythonrc files to use whitespace as the |
|
3956 | * Changed format of ipythonrc files to use whitespace as the | |
3934 | separator instead of an explicit '='. Cleaner. |
|
3957 | separator instead of an explicit '='. Cleaner. | |
3935 |
|
3958 | |||
3936 | 2001-12-20 Fernando Perez <fperez@colorado.edu> |
|
3959 | 2001-12-20 Fernando Perez <fperez@colorado.edu> | |
3937 |
|
3960 | |||
3938 | * Started a manual in LyX. For now it's just a quick merge of the |
|
3961 | * Started a manual in LyX. For now it's just a quick merge of the | |
3939 | various internal docstrings and READMEs. Later it may grow into a |
|
3962 | various internal docstrings and READMEs. Later it may grow into a | |
3940 | nice, full-blown manual. |
|
3963 | nice, full-blown manual. | |
3941 |
|
3964 | |||
3942 | * Set up a distutils based installer. Installation should now be |
|
3965 | * Set up a distutils based installer. Installation should now be | |
3943 | trivially simple for end-users. |
|
3966 | trivially simple for end-users. | |
3944 |
|
3967 | |||
3945 | 2001-12-11 Fernando Perez <fperez@colorado.edu> |
|
3968 | 2001-12-11 Fernando Perez <fperez@colorado.edu> | |
3946 |
|
3969 | |||
3947 | * Released 0.2.0. First public release, announced it at |
|
3970 | * Released 0.2.0. First public release, announced it at | |
3948 | comp.lang.python. From now on, just bugfixes... |
|
3971 | comp.lang.python. From now on, just bugfixes... | |
3949 |
|
3972 | |||
3950 | * Went through all the files, set copyright/license notices and |
|
3973 | * Went through all the files, set copyright/license notices and | |
3951 | cleaned up things. Ready for release. |
|
3974 | cleaned up things. Ready for release. | |
3952 |
|
3975 | |||
3953 | 2001-12-10 Fernando Perez <fperez@colorado.edu> |
|
3976 | 2001-12-10 Fernando Perez <fperez@colorado.edu> | |
3954 |
|
3977 | |||
3955 | * Changed the first-time installer not to use tarfiles. It's more |
|
3978 | * Changed the first-time installer not to use tarfiles. It's more | |
3956 | robust now and less unix-dependent. Also makes it easier for |
|
3979 | robust now and less unix-dependent. Also makes it easier for | |
3957 | people to later upgrade versions. |
|
3980 | people to later upgrade versions. | |
3958 |
|
3981 | |||
3959 | * Changed @exit to @abort to reflect the fact that it's pretty |
|
3982 | * Changed @exit to @abort to reflect the fact that it's pretty | |
3960 | brutal (a sys.exit()). The difference between @abort and Ctrl-D |
|
3983 | brutal (a sys.exit()). The difference between @abort and Ctrl-D | |
3961 | becomes significant only when IPyhton is embedded: in that case, |
|
3984 | becomes significant only when IPyhton is embedded: in that case, | |
3962 | C-D closes IPython only, but @abort kills the enclosing program |
|
3985 | C-D closes IPython only, but @abort kills the enclosing program | |
3963 | too (unless it had called IPython inside a try catching |
|
3986 | too (unless it had called IPython inside a try catching | |
3964 | SystemExit). |
|
3987 | SystemExit). | |
3965 |
|
3988 | |||
3966 | * Created Shell module which exposes the actuall IPython Shell |
|
3989 | * Created Shell module which exposes the actuall IPython Shell | |
3967 | classes, currently the normal and the embeddable one. This at |
|
3990 | classes, currently the normal and the embeddable one. This at | |
3968 | least offers a stable interface we won't need to change when |
|
3991 | least offers a stable interface we won't need to change when | |
3969 | (later) the internals are rewritten. That rewrite will be confined |
|
3992 | (later) the internals are rewritten. That rewrite will be confined | |
3970 | to iplib and ipmaker, but the Shell interface should remain as is. |
|
3993 | to iplib and ipmaker, but the Shell interface should remain as is. | |
3971 |
|
3994 | |||
3972 | * Added embed module which offers an embeddable IPShell object, |
|
3995 | * Added embed module which offers an embeddable IPShell object, | |
3973 | useful to fire up IPython *inside* a running program. Great for |
|
3996 | useful to fire up IPython *inside* a running program. Great for | |
3974 | debugging or dynamical data analysis. |
|
3997 | debugging or dynamical data analysis. | |
3975 |
|
3998 | |||
3976 | 2001-12-08 Fernando Perez <fperez@colorado.edu> |
|
3999 | 2001-12-08 Fernando Perez <fperez@colorado.edu> | |
3977 |
|
4000 | |||
3978 | * Fixed small bug preventing seeing info from methods of defined |
|
4001 | * Fixed small bug preventing seeing info from methods of defined | |
3979 | objects (incorrect namespace in _ofind()). |
|
4002 | objects (incorrect namespace in _ofind()). | |
3980 |
|
4003 | |||
3981 | * Documentation cleanup. Moved the main usage docstrings to a |
|
4004 | * Documentation cleanup. Moved the main usage docstrings to a | |
3982 | separate file, usage.py (cleaner to maintain, and hopefully in the |
|
4005 | separate file, usage.py (cleaner to maintain, and hopefully in the | |
3983 | future some perlpod-like way of producing interactive, man and |
|
4006 | future some perlpod-like way of producing interactive, man and | |
3984 | html docs out of it will be found). |
|
4007 | html docs out of it will be found). | |
3985 |
|
4008 | |||
3986 | * Added @profile to see your profile at any time. |
|
4009 | * Added @profile to see your profile at any time. | |
3987 |
|
4010 | |||
3988 | * Added @p as an alias for 'print'. It's especially convenient if |
|
4011 | * Added @p as an alias for 'print'. It's especially convenient if | |
3989 | using automagic ('p x' prints x). |
|
4012 | using automagic ('p x' prints x). | |
3990 |
|
4013 | |||
3991 | * Small cleanups and fixes after a pychecker run. |
|
4014 | * Small cleanups and fixes after a pychecker run. | |
3992 |
|
4015 | |||
3993 | * Changed the @cd command to handle @cd - and @cd -<n> for |
|
4016 | * Changed the @cd command to handle @cd - and @cd -<n> for | |
3994 | visiting any directory in _dh. |
|
4017 | visiting any directory in _dh. | |
3995 |
|
4018 | |||
3996 | * Introduced _dh, a history of visited directories. @dhist prints |
|
4019 | * Introduced _dh, a history of visited directories. @dhist prints | |
3997 | it out with numbers. |
|
4020 | it out with numbers. | |
3998 |
|
4021 | |||
3999 | 2001-12-07 Fernando Perez <fperez@colorado.edu> |
|
4022 | 2001-12-07 Fernando Perez <fperez@colorado.edu> | |
4000 |
|
4023 | |||
4001 | * Released 0.1.22 |
|
4024 | * Released 0.1.22 | |
4002 |
|
4025 | |||
4003 | * Made initialization a bit more robust against invalid color |
|
4026 | * Made initialization a bit more robust against invalid color | |
4004 | options in user input (exit, not traceback-crash). |
|
4027 | options in user input (exit, not traceback-crash). | |
4005 |
|
4028 | |||
4006 | * Changed the bug crash reporter to write the report only in the |
|
4029 | * Changed the bug crash reporter to write the report only in the | |
4007 | user's .ipython directory. That way IPython won't litter people's |
|
4030 | user's .ipython directory. That way IPython won't litter people's | |
4008 | hard disks with crash files all over the place. Also print on |
|
4031 | hard disks with crash files all over the place. Also print on | |
4009 | screen the necessary mail command. |
|
4032 | screen the necessary mail command. | |
4010 |
|
4033 | |||
4011 | * With the new ultraTB, implemented LightBG color scheme for light |
|
4034 | * With the new ultraTB, implemented LightBG color scheme for light | |
4012 | background terminals. A lot of people like white backgrounds, so I |
|
4035 | background terminals. A lot of people like white backgrounds, so I | |
4013 | guess we should at least give them something readable. |
|
4036 | guess we should at least give them something readable. | |
4014 |
|
4037 | |||
4015 | 2001-12-06 Fernando Perez <fperez@colorado.edu> |
|
4038 | 2001-12-06 Fernando Perez <fperez@colorado.edu> | |
4016 |
|
4039 | |||
4017 | * Modified the structure of ultraTB. Now there's a proper class |
|
4040 | * Modified the structure of ultraTB. Now there's a proper class | |
4018 | for tables of color schemes which allow adding schemes easily and |
|
4041 | for tables of color schemes which allow adding schemes easily and | |
4019 | switching the active scheme without creating a new instance every |
|
4042 | switching the active scheme without creating a new instance every | |
4020 | time (which was ridiculous). The syntax for creating new schemes |
|
4043 | time (which was ridiculous). The syntax for creating new schemes | |
4021 | is also cleaner. I think ultraTB is finally done, with a clean |
|
4044 | is also cleaner. I think ultraTB is finally done, with a clean | |
4022 | class structure. Names are also much cleaner (now there's proper |
|
4045 | class structure. Names are also much cleaner (now there's proper | |
4023 | color tables, no need for every variable to also have 'color' in |
|
4046 | color tables, no need for every variable to also have 'color' in | |
4024 | its name). |
|
4047 | its name). | |
4025 |
|
4048 | |||
4026 | * Broke down genutils into separate files. Now genutils only |
|
4049 | * Broke down genutils into separate files. Now genutils only | |
4027 | contains utility functions, and classes have been moved to their |
|
4050 | contains utility functions, and classes have been moved to their | |
4028 | own files (they had enough independent functionality to warrant |
|
4051 | own files (they had enough independent functionality to warrant | |
4029 | it): ConfigLoader, OutputTrap, Struct. |
|
4052 | it): ConfigLoader, OutputTrap, Struct. | |
4030 |
|
4053 | |||
4031 | 2001-12-05 Fernando Perez <fperez@colorado.edu> |
|
4054 | 2001-12-05 Fernando Perez <fperez@colorado.edu> | |
4032 |
|
4055 | |||
4033 | * IPython turns 21! Released version 0.1.21, as a candidate for |
|
4056 | * IPython turns 21! Released version 0.1.21, as a candidate for | |
4034 | public consumption. If all goes well, release in a few days. |
|
4057 | public consumption. If all goes well, release in a few days. | |
4035 |
|
4058 | |||
4036 | * Fixed path bug (files in Extensions/ directory wouldn't be found |
|
4059 | * Fixed path bug (files in Extensions/ directory wouldn't be found | |
4037 | unless IPython/ was explicitly in sys.path). |
|
4060 | unless IPython/ was explicitly in sys.path). | |
4038 |
|
4061 | |||
4039 | * Extended the FlexCompleter class as MagicCompleter to allow |
|
4062 | * Extended the FlexCompleter class as MagicCompleter to allow | |
4040 | completion of @-starting lines. |
|
4063 | completion of @-starting lines. | |
4041 |
|
4064 | |||
4042 | * Created __release__.py file as a central repository for release |
|
4065 | * Created __release__.py file as a central repository for release | |
4043 | info that other files can read from. |
|
4066 | info that other files can read from. | |
4044 |
|
4067 | |||
4045 | * Fixed small bug in logging: when logging was turned on in |
|
4068 | * Fixed small bug in logging: when logging was turned on in | |
4046 | mid-session, old lines with special meanings (!@?) were being |
|
4069 | mid-session, old lines with special meanings (!@?) were being | |
4047 | logged without the prepended comment, which is necessary since |
|
4070 | logged without the prepended comment, which is necessary since | |
4048 | they are not truly valid python syntax. This should make session |
|
4071 | they are not truly valid python syntax. This should make session | |
4049 | restores produce less errors. |
|
4072 | restores produce less errors. | |
4050 |
|
4073 | |||
4051 | * The namespace cleanup forced me to make a FlexCompleter class |
|
4074 | * The namespace cleanup forced me to make a FlexCompleter class | |
4052 | which is nothing but a ripoff of rlcompleter, but with selectable |
|
4075 | which is nothing but a ripoff of rlcompleter, but with selectable | |
4053 | namespace (rlcompleter only works in __main__.__dict__). I'll try |
|
4076 | namespace (rlcompleter only works in __main__.__dict__). I'll try | |
4054 | to submit a note to the authors to see if this change can be |
|
4077 | to submit a note to the authors to see if this change can be | |
4055 | incorporated in future rlcompleter releases (Dec.6: done) |
|
4078 | incorporated in future rlcompleter releases (Dec.6: done) | |
4056 |
|
4079 | |||
4057 | * More fixes to namespace handling. It was a mess! Now all |
|
4080 | * More fixes to namespace handling. It was a mess! Now all | |
4058 | explicit references to __main__.__dict__ are gone (except when |
|
4081 | explicit references to __main__.__dict__ are gone (except when | |
4059 | really needed) and everything is handled through the namespace |
|
4082 | really needed) and everything is handled through the namespace | |
4060 | dicts in the IPython instance. We seem to be getting somewhere |
|
4083 | dicts in the IPython instance. We seem to be getting somewhere | |
4061 | with this, finally... |
|
4084 | with this, finally... | |
4062 |
|
4085 | |||
4063 | * Small documentation updates. |
|
4086 | * Small documentation updates. | |
4064 |
|
4087 | |||
4065 | * Created the Extensions directory under IPython (with an |
|
4088 | * Created the Extensions directory under IPython (with an | |
4066 | __init__.py). Put the PhysicalQ stuff there. This directory should |
|
4089 | __init__.py). Put the PhysicalQ stuff there. This directory should | |
4067 | be used for all special-purpose extensions. |
|
4090 | be used for all special-purpose extensions. | |
4068 |
|
4091 | |||
4069 | * File renaming: |
|
4092 | * File renaming: | |
4070 | ipythonlib --> ipmaker |
|
4093 | ipythonlib --> ipmaker | |
4071 | ipplib --> iplib |
|
4094 | ipplib --> iplib | |
4072 | This makes a bit more sense in terms of what these files actually do. |
|
4095 | This makes a bit more sense in terms of what these files actually do. | |
4073 |
|
4096 | |||
4074 | * Moved all the classes and functions in ipythonlib to ipplib, so |
|
4097 | * Moved all the classes and functions in ipythonlib to ipplib, so | |
4075 | now ipythonlib only has make_IPython(). This will ease up its |
|
4098 | now ipythonlib only has make_IPython(). This will ease up its | |
4076 | splitting in smaller functional chunks later. |
|
4099 | splitting in smaller functional chunks later. | |
4077 |
|
4100 | |||
4078 | * Cleaned up (done, I think) output of @whos. Better column |
|
4101 | * Cleaned up (done, I think) output of @whos. Better column | |
4079 | formatting, and now shows str(var) for as much as it can, which is |
|
4102 | formatting, and now shows str(var) for as much as it can, which is | |
4080 | typically what one gets with a 'print var'. |
|
4103 | typically what one gets with a 'print var'. | |
4081 |
|
4104 | |||
4082 | 2001-12-04 Fernando Perez <fperez@colorado.edu> |
|
4105 | 2001-12-04 Fernando Perez <fperez@colorado.edu> | |
4083 |
|
4106 | |||
4084 | * Fixed namespace problems. Now builtin/IPyhton/user names get |
|
4107 | * Fixed namespace problems. Now builtin/IPyhton/user names get | |
4085 | properly reported in their namespace. Internal namespace handling |
|
4108 | properly reported in their namespace. Internal namespace handling | |
4086 | is finally getting decent (not perfect yet, but much better than |
|
4109 | is finally getting decent (not perfect yet, but much better than | |
4087 | the ad-hoc mess we had). |
|
4110 | the ad-hoc mess we had). | |
4088 |
|
4111 | |||
4089 | * Removed -exit option. If people just want to run a python |
|
4112 | * Removed -exit option. If people just want to run a python | |
4090 | script, that's what the normal interpreter is for. Less |
|
4113 | script, that's what the normal interpreter is for. Less | |
4091 | unnecessary options, less chances for bugs. |
|
4114 | unnecessary options, less chances for bugs. | |
4092 |
|
4115 | |||
4093 | * Added a crash handler which generates a complete post-mortem if |
|
4116 | * Added a crash handler which generates a complete post-mortem if | |
4094 | IPython crashes. This will help a lot in tracking bugs down the |
|
4117 | IPython crashes. This will help a lot in tracking bugs down the | |
4095 | road. |
|
4118 | road. | |
4096 |
|
4119 | |||
4097 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names |
|
4120 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names | |
4098 | which were boud to functions being reassigned would bypass the |
|
4121 | which were boud to functions being reassigned would bypass the | |
4099 | logger, breaking the sync of _il with the prompt counter. This |
|
4122 | logger, breaking the sync of _il with the prompt counter. This | |
4100 | would then crash IPython later when a new line was logged. |
|
4123 | would then crash IPython later when a new line was logged. | |
4101 |
|
4124 | |||
4102 | 2001-12-02 Fernando Perez <fperez@colorado.edu> |
|
4125 | 2001-12-02 Fernando Perez <fperez@colorado.edu> | |
4103 |
|
4126 | |||
4104 | * Made IPython a package. This means people don't have to clutter |
|
4127 | * Made IPython a package. This means people don't have to clutter | |
4105 | their sys.path with yet another directory. Changed the INSTALL |
|
4128 | their sys.path with yet another directory. Changed the INSTALL | |
4106 | file accordingly. |
|
4129 | file accordingly. | |
4107 |
|
4130 | |||
4108 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now |
|
4131 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now | |
4109 | sorts its output (so @who shows it sorted) and @whos formats the |
|
4132 | sorts its output (so @who shows it sorted) and @whos formats the | |
4110 | table according to the width of the first column. Nicer, easier to |
|
4133 | table according to the width of the first column. Nicer, easier to | |
4111 | read. Todo: write a generic table_format() which takes a list of |
|
4134 | read. Todo: write a generic table_format() which takes a list of | |
4112 | lists and prints it nicely formatted, with optional row/column |
|
4135 | lists and prints it nicely formatted, with optional row/column | |
4113 | separators and proper padding and justification. |
|
4136 | separators and proper padding and justification. | |
4114 |
|
4137 | |||
4115 | * Released 0.1.20 |
|
4138 | * Released 0.1.20 | |
4116 |
|
4139 | |||
4117 | * Fixed bug in @log which would reverse the inputcache list (a |
|
4140 | * Fixed bug in @log which would reverse the inputcache list (a | |
4118 | copy operation was missing). |
|
4141 | copy operation was missing). | |
4119 |
|
4142 | |||
4120 | * Code cleanup. @config was changed to use page(). Better, since |
|
4143 | * Code cleanup. @config was changed to use page(). Better, since | |
4121 | its output is always quite long. |
|
4144 | its output is always quite long. | |
4122 |
|
4145 | |||
4123 | * Itpl is back as a dependency. I was having too many problems |
|
4146 | * Itpl is back as a dependency. I was having too many problems | |
4124 | getting the parametric aliases to work reliably, and it's just |
|
4147 | getting the parametric aliases to work reliably, and it's just | |
4125 | easier to code weird string operations with it than playing %()s |
|
4148 | easier to code weird string operations with it than playing %()s | |
4126 | games. It's only ~6k, so I don't think it's too big a deal. |
|
4149 | games. It's only ~6k, so I don't think it's too big a deal. | |
4127 |
|
4150 | |||
4128 | * Found (and fixed) a very nasty bug with history. !lines weren't |
|
4151 | * Found (and fixed) a very nasty bug with history. !lines weren't | |
4129 | getting cached, and the out of sync caches would crash |
|
4152 | getting cached, and the out of sync caches would crash | |
4130 | IPython. Fixed it by reorganizing the prefilter/handlers/logger |
|
4153 | IPython. Fixed it by reorganizing the prefilter/handlers/logger | |
4131 | division of labor a bit better. Bug fixed, cleaner structure. |
|
4154 | division of labor a bit better. Bug fixed, cleaner structure. | |
4132 |
|
4155 | |||
4133 | 2001-12-01 Fernando Perez <fperez@colorado.edu> |
|
4156 | 2001-12-01 Fernando Perez <fperez@colorado.edu> | |
4134 |
|
4157 | |||
4135 | * Released 0.1.19 |
|
4158 | * Released 0.1.19 | |
4136 |
|
4159 | |||
4137 | * Added option -n to @hist to prevent line number printing. Much |
|
4160 | * Added option -n to @hist to prevent line number printing. Much | |
4138 | easier to copy/paste code this way. |
|
4161 | easier to copy/paste code this way. | |
4139 |
|
4162 | |||
4140 | * Created global _il to hold the input list. Allows easy |
|
4163 | * Created global _il to hold the input list. Allows easy | |
4141 | re-execution of blocks of code by slicing it (inspired by Janko's |
|
4164 | re-execution of blocks of code by slicing it (inspired by Janko's | |
4142 | comment on 'macros'). |
|
4165 | comment on 'macros'). | |
4143 |
|
4166 | |||
4144 | * Small fixes and doc updates. |
|
4167 | * Small fixes and doc updates. | |
4145 |
|
4168 | |||
4146 | * Rewrote @history function (was @h). Renamed it to @hist, @h is |
|
4169 | * Rewrote @history function (was @h). Renamed it to @hist, @h is | |
4147 | much too fragile with automagic. Handles properly multi-line |
|
4170 | much too fragile with automagic. Handles properly multi-line | |
4148 | statements and takes parameters. |
|
4171 | statements and takes parameters. | |
4149 |
|
4172 | |||
4150 | 2001-11-30 Fernando Perez <fperez@colorado.edu> |
|
4173 | 2001-11-30 Fernando Perez <fperez@colorado.edu> | |
4151 |
|
4174 | |||
4152 | * Version 0.1.18 released. |
|
4175 | * Version 0.1.18 released. | |
4153 |
|
4176 | |||
4154 | * Fixed nasty namespace bug in initial module imports. |
|
4177 | * Fixed nasty namespace bug in initial module imports. | |
4155 |
|
4178 | |||
4156 | * Added copyright/license notes to all code files (except |
|
4179 | * Added copyright/license notes to all code files (except | |
4157 | DPyGetOpt). For the time being, LGPL. That could change. |
|
4180 | DPyGetOpt). For the time being, LGPL. That could change. | |
4158 |
|
4181 | |||
4159 | * Rewrote a much nicer README, updated INSTALL, cleaned up |
|
4182 | * Rewrote a much nicer README, updated INSTALL, cleaned up | |
4160 | ipythonrc-* samples. |
|
4183 | ipythonrc-* samples. | |
4161 |
|
4184 | |||
4162 | * Overall code/documentation cleanup. Basically ready for |
|
4185 | * Overall code/documentation cleanup. Basically ready for | |
4163 | release. Only remaining thing: licence decision (LGPL?). |
|
4186 | release. Only remaining thing: licence decision (LGPL?). | |
4164 |
|
4187 | |||
4165 | * Converted load_config to a class, ConfigLoader. Now recursion |
|
4188 | * Converted load_config to a class, ConfigLoader. Now recursion | |
4166 | control is better organized. Doesn't include the same file twice. |
|
4189 | control is better organized. Doesn't include the same file twice. | |
4167 |
|
4190 | |||
4168 | 2001-11-29 Fernando Perez <fperez@colorado.edu> |
|
4191 | 2001-11-29 Fernando Perez <fperez@colorado.edu> | |
4169 |
|
4192 | |||
4170 | * Got input history working. Changed output history variables from |
|
4193 | * Got input history working. Changed output history variables from | |
4171 | _p to _o so that _i is for input and _o for output. Just cleaner |
|
4194 | _p to _o so that _i is for input and _o for output. Just cleaner | |
4172 | convention. |
|
4195 | convention. | |
4173 |
|
4196 | |||
4174 | * Implemented parametric aliases. This pretty much allows the |
|
4197 | * Implemented parametric aliases. This pretty much allows the | |
4175 | alias system to offer full-blown shell convenience, I think. |
|
4198 | alias system to offer full-blown shell convenience, I think. | |
4176 |
|
4199 | |||
4177 | * Version 0.1.17 released, 0.1.18 opened. |
|
4200 | * Version 0.1.17 released, 0.1.18 opened. | |
4178 |
|
4201 | |||
4179 | * dot_ipython/ipythonrc (alias): added documentation. |
|
4202 | * dot_ipython/ipythonrc (alias): added documentation. | |
4180 | (xcolor): Fixed small bug (xcolors -> xcolor) |
|
4203 | (xcolor): Fixed small bug (xcolors -> xcolor) | |
4181 |
|
4204 | |||
4182 | * Changed the alias system. Now alias is a magic command to define |
|
4205 | * Changed the alias system. Now alias is a magic command to define | |
4183 | aliases just like the shell. Rationale: the builtin magics should |
|
4206 | aliases just like the shell. Rationale: the builtin magics should | |
4184 | be there for things deeply connected to IPython's |
|
4207 | be there for things deeply connected to IPython's | |
4185 | architecture. And this is a much lighter system for what I think |
|
4208 | architecture. And this is a much lighter system for what I think | |
4186 | is the really important feature: allowing users to define quickly |
|
4209 | is the really important feature: allowing users to define quickly | |
4187 | magics that will do shell things for them, so they can customize |
|
4210 | magics that will do shell things for them, so they can customize | |
4188 | IPython easily to match their work habits. If someone is really |
|
4211 | IPython easily to match their work habits. If someone is really | |
4189 | desperate to have another name for a builtin alias, they can |
|
4212 | desperate to have another name for a builtin alias, they can | |
4190 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but |
|
4213 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but | |
4191 | works. |
|
4214 | works. | |
4192 |
|
4215 | |||
4193 | 2001-11-28 Fernando Perez <fperez@colorado.edu> |
|
4216 | 2001-11-28 Fernando Perez <fperez@colorado.edu> | |
4194 |
|
4217 | |||
4195 | * Changed @file so that it opens the source file at the proper |
|
4218 | * Changed @file so that it opens the source file at the proper | |
4196 | line. Since it uses less, if your EDITOR environment is |
|
4219 | line. Since it uses less, if your EDITOR environment is | |
4197 | configured, typing v will immediately open your editor of choice |
|
4220 | configured, typing v will immediately open your editor of choice | |
4198 | right at the line where the object is defined. Not as quick as |
|
4221 | right at the line where the object is defined. Not as quick as | |
4199 | having a direct @edit command, but for all intents and purposes it |
|
4222 | having a direct @edit command, but for all intents and purposes it | |
4200 | works. And I don't have to worry about writing @edit to deal with |
|
4223 | works. And I don't have to worry about writing @edit to deal with | |
4201 | all the editors, less does that. |
|
4224 | all the editors, less does that. | |
4202 |
|
4225 | |||
4203 | * Version 0.1.16 released, 0.1.17 opened. |
|
4226 | * Version 0.1.16 released, 0.1.17 opened. | |
4204 |
|
4227 | |||
4205 | * Fixed some nasty bugs in the page/page_dumb combo that could |
|
4228 | * Fixed some nasty bugs in the page/page_dumb combo that could | |
4206 | crash IPython. |
|
4229 | crash IPython. | |
4207 |
|
4230 | |||
4208 | 2001-11-27 Fernando Perez <fperez@colorado.edu> |
|
4231 | 2001-11-27 Fernando Perez <fperez@colorado.edu> | |
4209 |
|
4232 | |||
4210 | * Version 0.1.15 released, 0.1.16 opened. |
|
4233 | * Version 0.1.15 released, 0.1.16 opened. | |
4211 |
|
4234 | |||
4212 | * Finally got ? and ?? to work for undefined things: now it's |
|
4235 | * Finally got ? and ?? to work for undefined things: now it's | |
4213 | possible to type {}.get? and get information about the get method |
|
4236 | possible to type {}.get? and get information about the get method | |
4214 | of dicts, or os.path? even if only os is defined (so technically |
|
4237 | of dicts, or os.path? even if only os is defined (so technically | |
4215 | os.path isn't). Works at any level. For example, after import os, |
|
4238 | os.path isn't). Works at any level. For example, after import os, | |
4216 | os?, os.path?, os.path.abspath? all work. This is great, took some |
|
4239 | os?, os.path?, os.path.abspath? all work. This is great, took some | |
4217 | work in _ofind. |
|
4240 | work in _ofind. | |
4218 |
|
4241 | |||
4219 | * Fixed more bugs with logging. The sanest way to do it was to add |
|
4242 | * Fixed more bugs with logging. The sanest way to do it was to add | |
4220 | to @log a 'mode' parameter. Killed two in one shot (this mode |
|
4243 | to @log a 'mode' parameter. Killed two in one shot (this mode | |
4221 | option was a request of Janko's). I think it's finally clean |
|
4244 | option was a request of Janko's). I think it's finally clean | |
4222 | (famous last words). |
|
4245 | (famous last words). | |
4223 |
|
4246 | |||
4224 | * Added a page_dumb() pager which does a decent job of paging on |
|
4247 | * Added a page_dumb() pager which does a decent job of paging on | |
4225 | screen, if better things (like less) aren't available. One less |
|
4248 | screen, if better things (like less) aren't available. One less | |
4226 | unix dependency (someday maybe somebody will port this to |
|
4249 | unix dependency (someday maybe somebody will port this to | |
4227 | windows). |
|
4250 | windows). | |
4228 |
|
4251 | |||
4229 | * Fixed problem in magic_log: would lock of logging out if log |
|
4252 | * Fixed problem in magic_log: would lock of logging out if log | |
4230 | creation failed (because it would still think it had succeeded). |
|
4253 | creation failed (because it would still think it had succeeded). | |
4231 |
|
4254 | |||
4232 | * Improved the page() function using curses to auto-detect screen |
|
4255 | * Improved the page() function using curses to auto-detect screen | |
4233 | size. Now it can make a much better decision on whether to print |
|
4256 | size. Now it can make a much better decision on whether to print | |
4234 | or page a string. Option screen_length was modified: a value 0 |
|
4257 | or page a string. Option screen_length was modified: a value 0 | |
4235 | means auto-detect, and that's the default now. |
|
4258 | means auto-detect, and that's the default now. | |
4236 |
|
4259 | |||
4237 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to |
|
4260 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to | |
4238 | go out. I'll test it for a few days, then talk to Janko about |
|
4261 | go out. I'll test it for a few days, then talk to Janko about | |
4239 | licences and announce it. |
|
4262 | licences and announce it. | |
4240 |
|
4263 | |||
4241 | * Fixed the length of the auto-generated ---> prompt which appears |
|
4264 | * Fixed the length of the auto-generated ---> prompt which appears | |
4242 | for auto-parens and auto-quotes. Getting this right isn't trivial, |
|
4265 | for auto-parens and auto-quotes. Getting this right isn't trivial, | |
4243 | with all the color escapes, different prompt types and optional |
|
4266 | with all the color escapes, different prompt types and optional | |
4244 | separators. But it seems to be working in all the combinations. |
|
4267 | separators. But it seems to be working in all the combinations. | |
4245 |
|
4268 | |||
4246 | 2001-11-26 Fernando Perez <fperez@colorado.edu> |
|
4269 | 2001-11-26 Fernando Perez <fperez@colorado.edu> | |
4247 |
|
4270 | |||
4248 | * Wrote a regexp filter to get option types from the option names |
|
4271 | * Wrote a regexp filter to get option types from the option names | |
4249 | string. This eliminates the need to manually keep two duplicate |
|
4272 | string. This eliminates the need to manually keep two duplicate | |
4250 | lists. |
|
4273 | lists. | |
4251 |
|
4274 | |||
4252 | * Removed the unneeded check_option_names. Now options are handled |
|
4275 | * Removed the unneeded check_option_names. Now options are handled | |
4253 | in a much saner manner and it's easy to visually check that things |
|
4276 | in a much saner manner and it's easy to visually check that things | |
4254 | are ok. |
|
4277 | are ok. | |
4255 |
|
4278 | |||
4256 | * Updated version numbers on all files I modified to carry a |
|
4279 | * Updated version numbers on all files I modified to carry a | |
4257 | notice so Janko and Nathan have clear version markers. |
|
4280 | notice so Janko and Nathan have clear version markers. | |
4258 |
|
4281 | |||
4259 | * Updated docstring for ultraTB with my changes. I should send |
|
4282 | * Updated docstring for ultraTB with my changes. I should send | |
4260 | this to Nathan. |
|
4283 | this to Nathan. | |
4261 |
|
4284 | |||
4262 | * Lots of small fixes. Ran everything through pychecker again. |
|
4285 | * Lots of small fixes. Ran everything through pychecker again. | |
4263 |
|
4286 | |||
4264 | * Made loading of deep_reload an cmd line option. If it's not too |
|
4287 | * Made loading of deep_reload an cmd line option. If it's not too | |
4265 | kosher, now people can just disable it. With -nodeep_reload it's |
|
4288 | kosher, now people can just disable it. With -nodeep_reload it's | |
4266 | still available as dreload(), it just won't overwrite reload(). |
|
4289 | still available as dreload(), it just won't overwrite reload(). | |
4267 |
|
4290 | |||
4268 | * Moved many options to the no| form (-opt and -noopt |
|
4291 | * Moved many options to the no| form (-opt and -noopt | |
4269 | accepted). Cleaner. |
|
4292 | accepted). Cleaner. | |
4270 |
|
4293 | |||
4271 | * Changed magic_log so that if called with no parameters, it uses |
|
4294 | * Changed magic_log so that if called with no parameters, it uses | |
4272 | 'rotate' mode. That way auto-generated logs aren't automatically |
|
4295 | 'rotate' mode. That way auto-generated logs aren't automatically | |
4273 | over-written. For normal logs, now a backup is made if it exists |
|
4296 | over-written. For normal logs, now a backup is made if it exists | |
4274 | (only 1 level of backups). A new 'backup' mode was added to the |
|
4297 | (only 1 level of backups). A new 'backup' mode was added to the | |
4275 | Logger class to support this. This was a request by Janko. |
|
4298 | Logger class to support this. This was a request by Janko. | |
4276 |
|
4299 | |||
4277 | * Added @logoff/@logon to stop/restart an active log. |
|
4300 | * Added @logoff/@logon to stop/restart an active log. | |
4278 |
|
4301 | |||
4279 | * Fixed a lot of bugs in log saving/replay. It was pretty |
|
4302 | * Fixed a lot of bugs in log saving/replay. It was pretty | |
4280 | broken. Now special lines (!@,/) appear properly in the command |
|
4303 | broken. Now special lines (!@,/) appear properly in the command | |
4281 | history after a log replay. |
|
4304 | history after a log replay. | |
4282 |
|
4305 | |||
4283 | * Tried and failed to implement full session saving via pickle. My |
|
4306 | * Tried and failed to implement full session saving via pickle. My | |
4284 | idea was to pickle __main__.__dict__, but modules can't be |
|
4307 | idea was to pickle __main__.__dict__, but modules can't be | |
4285 | pickled. This would be a better alternative to replaying logs, but |
|
4308 | pickled. This would be a better alternative to replaying logs, but | |
4286 | seems quite tricky to get to work. Changed -session to be called |
|
4309 | seems quite tricky to get to work. Changed -session to be called | |
4287 | -logplay, which more accurately reflects what it does. And if we |
|
4310 | -logplay, which more accurately reflects what it does. And if we | |
4288 | ever get real session saving working, -session is now available. |
|
4311 | ever get real session saving working, -session is now available. | |
4289 |
|
4312 | |||
4290 | * Implemented color schemes for prompts also. As for tracebacks, |
|
4313 | * Implemented color schemes for prompts also. As for tracebacks, | |
4291 | currently only NoColor and Linux are supported. But now the |
|
4314 | currently only NoColor and Linux are supported. But now the | |
4292 | infrastructure is in place, based on a generic ColorScheme |
|
4315 | infrastructure is in place, based on a generic ColorScheme | |
4293 | class. So writing and activating new schemes both for the prompts |
|
4316 | class. So writing and activating new schemes both for the prompts | |
4294 | and the tracebacks should be straightforward. |
|
4317 | and the tracebacks should be straightforward. | |
4295 |
|
4318 | |||
4296 | * Version 0.1.13 released, 0.1.14 opened. |
|
4319 | * Version 0.1.13 released, 0.1.14 opened. | |
4297 |
|
4320 | |||
4298 | * Changed handling of options for output cache. Now counter is |
|
4321 | * Changed handling of options for output cache. Now counter is | |
4299 | hardwired starting at 1 and one specifies the maximum number of |
|
4322 | hardwired starting at 1 and one specifies the maximum number of | |
4300 | entries *in the outcache* (not the max prompt counter). This is |
|
4323 | entries *in the outcache* (not the max prompt counter). This is | |
4301 | much better, since many statements won't increase the cache |
|
4324 | much better, since many statements won't increase the cache | |
4302 | count. It also eliminated some confusing options, now there's only |
|
4325 | count. It also eliminated some confusing options, now there's only | |
4303 | one: cache_size. |
|
4326 | one: cache_size. | |
4304 |
|
4327 | |||
4305 | * Added 'alias' magic function and magic_alias option in the |
|
4328 | * Added 'alias' magic function and magic_alias option in the | |
4306 | ipythonrc file. Now the user can easily define whatever names he |
|
4329 | ipythonrc file. Now the user can easily define whatever names he | |
4307 | wants for the magic functions without having to play weird |
|
4330 | wants for the magic functions without having to play weird | |
4308 | namespace games. This gives IPython a real shell-like feel. |
|
4331 | namespace games. This gives IPython a real shell-like feel. | |
4309 |
|
4332 | |||
4310 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit |
|
4333 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit | |
4311 | @ or not). |
|
4334 | @ or not). | |
4312 |
|
4335 | |||
4313 | This was one of the last remaining 'visible' bugs (that I know |
|
4336 | This was one of the last remaining 'visible' bugs (that I know | |
4314 | of). I think if I can clean up the session loading so it works |
|
4337 | of). I think if I can clean up the session loading so it works | |
4315 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first |
|
4338 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first | |
4316 | about licensing). |
|
4339 | about licensing). | |
4317 |
|
4340 | |||
4318 | 2001-11-25 Fernando Perez <fperez@colorado.edu> |
|
4341 | 2001-11-25 Fernando Perez <fperez@colorado.edu> | |
4319 |
|
4342 | |||
4320 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and |
|
4343 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and | |
4321 | there's a cleaner distinction between what ? and ?? show. |
|
4344 | there's a cleaner distinction between what ? and ?? show. | |
4322 |
|
4345 | |||
4323 | * Added screen_length option. Now the user can define his own |
|
4346 | * Added screen_length option. Now the user can define his own | |
4324 | screen size for page() operations. |
|
4347 | screen size for page() operations. | |
4325 |
|
4348 | |||
4326 | * Implemented magic shell-like functions with automatic code |
|
4349 | * Implemented magic shell-like functions with automatic code | |
4327 | generation. Now adding another function is just a matter of adding |
|
4350 | generation. Now adding another function is just a matter of adding | |
4328 | an entry to a dict, and the function is dynamically generated at |
|
4351 | an entry to a dict, and the function is dynamically generated at | |
4329 | run-time. Python has some really cool features! |
|
4352 | run-time. Python has some really cool features! | |
4330 |
|
4353 | |||
4331 | * Renamed many options to cleanup conventions a little. Now all |
|
4354 | * Renamed many options to cleanup conventions a little. Now all | |
4332 | are lowercase, and only underscores where needed. Also in the code |
|
4355 | are lowercase, and only underscores where needed. Also in the code | |
4333 | option name tables are clearer. |
|
4356 | option name tables are clearer. | |
4334 |
|
4357 | |||
4335 | * Changed prompts a little. Now input is 'In [n]:' instead of |
|
4358 | * Changed prompts a little. Now input is 'In [n]:' instead of | |
4336 | 'In[n]:='. This allows it the numbers to be aligned with the |
|
4359 | 'In[n]:='. This allows it the numbers to be aligned with the | |
4337 | Out[n] numbers, and removes usage of ':=' which doesn't exist in |
|
4360 | Out[n] numbers, and removes usage of ':=' which doesn't exist in | |
4338 | Python (it was a Mathematica thing). The '...' continuation prompt |
|
4361 | Python (it was a Mathematica thing). The '...' continuation prompt | |
4339 | was also changed a little to align better. |
|
4362 | was also changed a little to align better. | |
4340 |
|
4363 | |||
4341 | * Fixed bug when flushing output cache. Not all _p<n> variables |
|
4364 | * Fixed bug when flushing output cache. Not all _p<n> variables | |
4342 | exist, so their deletion needs to be wrapped in a try: |
|
4365 | exist, so their deletion needs to be wrapped in a try: | |
4343 |
|
4366 | |||
4344 | * Figured out how to properly use inspect.formatargspec() (it |
|
4367 | * Figured out how to properly use inspect.formatargspec() (it | |
4345 | requires the args preceded by *). So I removed all the code from |
|
4368 | requires the args preceded by *). So I removed all the code from | |
4346 | _get_pdef in Magic, which was just replicating that. |
|
4369 | _get_pdef in Magic, which was just replicating that. | |
4347 |
|
4370 | |||
4348 | * Added test to prefilter to allow redefining magic function names |
|
4371 | * Added test to prefilter to allow redefining magic function names | |
4349 | as variables. This is ok, since the @ form is always available, |
|
4372 | as variables. This is ok, since the @ form is always available, | |
4350 | but whe should allow the user to define a variable called 'ls' if |
|
4373 | but whe should allow the user to define a variable called 'ls' if | |
4351 | he needs it. |
|
4374 | he needs it. | |
4352 |
|
4375 | |||
4353 | * Moved the ToDo information from README into a separate ToDo. |
|
4376 | * Moved the ToDo information from README into a separate ToDo. | |
4354 |
|
4377 | |||
4355 | * General code cleanup and small bugfixes. I think it's close to a |
|
4378 | * General code cleanup and small bugfixes. I think it's close to a | |
4356 | state where it can be released, obviously with a big 'beta' |
|
4379 | state where it can be released, obviously with a big 'beta' | |
4357 | warning on it. |
|
4380 | warning on it. | |
4358 |
|
4381 | |||
4359 | * Got the magic function split to work. Now all magics are defined |
|
4382 | * Got the magic function split to work. Now all magics are defined | |
4360 | in a separate class. It just organizes things a bit, and now |
|
4383 | in a separate class. It just organizes things a bit, and now | |
4361 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it |
|
4384 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it | |
4362 | was too long). |
|
4385 | was too long). | |
4363 |
|
4386 | |||
4364 | * Changed @clear to @reset to avoid potential confusions with |
|
4387 | * Changed @clear to @reset to avoid potential confusions with | |
4365 | the shell command clear. Also renamed @cl to @clear, which does |
|
4388 | the shell command clear. Also renamed @cl to @clear, which does | |
4366 | exactly what people expect it to from their shell experience. |
|
4389 | exactly what people expect it to from their shell experience. | |
4367 |
|
4390 | |||
4368 | Added a check to the @reset command (since it's so |
|
4391 | Added a check to the @reset command (since it's so | |
4369 | destructive, it's probably a good idea to ask for confirmation). |
|
4392 | destructive, it's probably a good idea to ask for confirmation). | |
4370 | But now reset only works for full namespace resetting. Since the |
|
4393 | But now reset only works for full namespace resetting. Since the | |
4371 | del keyword is already there for deleting a few specific |
|
4394 | del keyword is already there for deleting a few specific | |
4372 | variables, I don't see the point of having a redundant magic |
|
4395 | variables, I don't see the point of having a redundant magic | |
4373 | function for the same task. |
|
4396 | function for the same task. | |
4374 |
|
4397 | |||
4375 | 2001-11-24 Fernando Perez <fperez@colorado.edu> |
|
4398 | 2001-11-24 Fernando Perez <fperez@colorado.edu> | |
4376 |
|
4399 | |||
4377 | * Updated the builtin docs (esp. the ? ones). |
|
4400 | * Updated the builtin docs (esp. the ? ones). | |
4378 |
|
4401 | |||
4379 | * Ran all the code through pychecker. Not terribly impressed with |
|
4402 | * Ran all the code through pychecker. Not terribly impressed with | |
4380 | it: lots of spurious warnings and didn't really find anything of |
|
4403 | it: lots of spurious warnings and didn't really find anything of | |
4381 | substance (just a few modules being imported and not used). |
|
4404 | substance (just a few modules being imported and not used). | |
4382 |
|
4405 | |||
4383 | * Implemented the new ultraTB functionality into IPython. New |
|
4406 | * Implemented the new ultraTB functionality into IPython. New | |
4384 | option: xcolors. This chooses color scheme. xmode now only selects |
|
4407 | option: xcolors. This chooses color scheme. xmode now only selects | |
4385 | between Plain and Verbose. Better orthogonality. |
|
4408 | between Plain and Verbose. Better orthogonality. | |
4386 |
|
4409 | |||
4387 | * Large rewrite of ultraTB. Much cleaner now, with a separation of |
|
4410 | * Large rewrite of ultraTB. Much cleaner now, with a separation of | |
4388 | mode and color scheme for the exception handlers. Now it's |
|
4411 | mode and color scheme for the exception handlers. Now it's | |
4389 | possible to have the verbose traceback with no coloring. |
|
4412 | possible to have the verbose traceback with no coloring. | |
4390 |
|
4413 | |||
4391 | 2001-11-23 Fernando Perez <fperez@colorado.edu> |
|
4414 | 2001-11-23 Fernando Perez <fperez@colorado.edu> | |
4392 |
|
4415 | |||
4393 | * Version 0.1.12 released, 0.1.13 opened. |
|
4416 | * Version 0.1.12 released, 0.1.13 opened. | |
4394 |
|
4417 | |||
4395 | * Removed option to set auto-quote and auto-paren escapes by |
|
4418 | * Removed option to set auto-quote and auto-paren escapes by | |
4396 | user. The chances of breaking valid syntax are just too high. If |
|
4419 | user. The chances of breaking valid syntax are just too high. If | |
4397 | someone *really* wants, they can always dig into the code. |
|
4420 | someone *really* wants, they can always dig into the code. | |
4398 |
|
4421 | |||
4399 | * Made prompt separators configurable. |
|
4422 | * Made prompt separators configurable. | |
4400 |
|
4423 | |||
4401 | 2001-11-22 Fernando Perez <fperez@colorado.edu> |
|
4424 | 2001-11-22 Fernando Perez <fperez@colorado.edu> | |
4402 |
|
4425 | |||
4403 | * Small bugfixes in many places. |
|
4426 | * Small bugfixes in many places. | |
4404 |
|
4427 | |||
4405 | * Removed the MyCompleter class from ipplib. It seemed redundant |
|
4428 | * Removed the MyCompleter class from ipplib. It seemed redundant | |
4406 | with the C-p,C-n history search functionality. Less code to |
|
4429 | with the C-p,C-n history search functionality. Less code to | |
4407 | maintain. |
|
4430 | maintain. | |
4408 |
|
4431 | |||
4409 | * Moved all the original ipython.py code into ipythonlib.py. Right |
|
4432 | * Moved all the original ipython.py code into ipythonlib.py. Right | |
4410 | now it's just one big dump into a function called make_IPython, so |
|
4433 | now it's just one big dump into a function called make_IPython, so | |
4411 | no real modularity has been gained. But at least it makes the |
|
4434 | no real modularity has been gained. But at least it makes the | |
4412 | wrapper script tiny, and since ipythonlib is a module, it gets |
|
4435 | wrapper script tiny, and since ipythonlib is a module, it gets | |
4413 | compiled and startup is much faster. |
|
4436 | compiled and startup is much faster. | |
4414 |
|
4437 | |||
4415 | This is a reasobably 'deep' change, so we should test it for a |
|
4438 | This is a reasobably 'deep' change, so we should test it for a | |
4416 | while without messing too much more with the code. |
|
4439 | while without messing too much more with the code. | |
4417 |
|
4440 | |||
4418 | 2001-11-21 Fernando Perez <fperez@colorado.edu> |
|
4441 | 2001-11-21 Fernando Perez <fperez@colorado.edu> | |
4419 |
|
4442 | |||
4420 | * Version 0.1.11 released, 0.1.12 opened for further work. |
|
4443 | * Version 0.1.11 released, 0.1.12 opened for further work. | |
4421 |
|
4444 | |||
4422 | * Removed dependency on Itpl. It was only needed in one place. It |
|
4445 | * Removed dependency on Itpl. It was only needed in one place. It | |
4423 | would be nice if this became part of python, though. It makes life |
|
4446 | would be nice if this became part of python, though. It makes life | |
4424 | *a lot* easier in some cases. |
|
4447 | *a lot* easier in some cases. | |
4425 |
|
4448 | |||
4426 | * Simplified the prefilter code a bit. Now all handlers are |
|
4449 | * Simplified the prefilter code a bit. Now all handlers are | |
4427 | expected to explicitly return a value (at least a blank string). |
|
4450 | expected to explicitly return a value (at least a blank string). | |
4428 |
|
4451 | |||
4429 | * Heavy edits in ipplib. Removed the help system altogether. Now |
|
4452 | * Heavy edits in ipplib. Removed the help system altogether. Now | |
4430 | obj?/?? is used for inspecting objects, a magic @doc prints |
|
4453 | obj?/?? is used for inspecting objects, a magic @doc prints | |
4431 | docstrings, and full-blown Python help is accessed via the 'help' |
|
4454 | docstrings, and full-blown Python help is accessed via the 'help' | |
4432 | keyword. This cleans up a lot of code (less to maintain) and does |
|
4455 | keyword. This cleans up a lot of code (less to maintain) and does | |
4433 | the job. Since 'help' is now a standard Python component, might as |
|
4456 | the job. Since 'help' is now a standard Python component, might as | |
4434 | well use it and remove duplicate functionality. |
|
4457 | well use it and remove duplicate functionality. | |
4435 |
|
4458 | |||
4436 | Also removed the option to use ipplib as a standalone program. By |
|
4459 | Also removed the option to use ipplib as a standalone program. By | |
4437 | now it's too dependent on other parts of IPython to function alone. |
|
4460 | now it's too dependent on other parts of IPython to function alone. | |
4438 |
|
4461 | |||
4439 | * Fixed bug in genutils.pager. It would crash if the pager was |
|
4462 | * Fixed bug in genutils.pager. It would crash if the pager was | |
4440 | exited immediately after opening (broken pipe). |
|
4463 | exited immediately after opening (broken pipe). | |
4441 |
|
4464 | |||
4442 | * Trimmed down the VerboseTB reporting a little. The header is |
|
4465 | * Trimmed down the VerboseTB reporting a little. The header is | |
4443 | much shorter now and the repeated exception arguments at the end |
|
4466 | much shorter now and the repeated exception arguments at the end | |
4444 | have been removed. For interactive use the old header seemed a bit |
|
4467 | have been removed. For interactive use the old header seemed a bit | |
4445 | excessive. |
|
4468 | excessive. | |
4446 |
|
4469 | |||
4447 | * Fixed small bug in output of @whos for variables with multi-word |
|
4470 | * Fixed small bug in output of @whos for variables with multi-word | |
4448 | types (only first word was displayed). |
|
4471 | types (only first word was displayed). | |
4449 |
|
4472 | |||
4450 | 2001-11-17 Fernando Perez <fperez@colorado.edu> |
|
4473 | 2001-11-17 Fernando Perez <fperez@colorado.edu> | |
4451 |
|
4474 | |||
4452 | * Version 0.1.10 released, 0.1.11 opened for further work. |
|
4475 | * Version 0.1.10 released, 0.1.11 opened for further work. | |
4453 |
|
4476 | |||
4454 | * Modified dirs and friends. dirs now *returns* the stack (not |
|
4477 | * Modified dirs and friends. dirs now *returns* the stack (not | |
4455 | prints), so one can manipulate it as a variable. Convenient to |
|
4478 | prints), so one can manipulate it as a variable. Convenient to | |
4456 | travel along many directories. |
|
4479 | travel along many directories. | |
4457 |
|
4480 | |||
4458 | * Fixed bug in magic_pdef: would only work with functions with |
|
4481 | * Fixed bug in magic_pdef: would only work with functions with | |
4459 | arguments with default values. |
|
4482 | arguments with default values. | |
4460 |
|
4483 | |||
4461 | 2001-11-14 Fernando Perez <fperez@colorado.edu> |
|
4484 | 2001-11-14 Fernando Perez <fperez@colorado.edu> | |
4462 |
|
4485 | |||
4463 | * Added the PhysicsInput stuff to dot_ipython so it ships as an |
|
4486 | * Added the PhysicsInput stuff to dot_ipython so it ships as an | |
4464 | example with IPython. Various other minor fixes and cleanups. |
|
4487 | example with IPython. Various other minor fixes and cleanups. | |
4465 |
|
4488 | |||
4466 | * Version 0.1.9 released, 0.1.10 opened for further work. |
|
4489 | * Version 0.1.9 released, 0.1.10 opened for further work. | |
4467 |
|
4490 | |||
4468 | * Added sys.path to the list of directories searched in the |
|
4491 | * Added sys.path to the list of directories searched in the | |
4469 | execfile= option. It used to be the current directory and the |
|
4492 | execfile= option. It used to be the current directory and the | |
4470 | user's IPYTHONDIR only. |
|
4493 | user's IPYTHONDIR only. | |
4471 |
|
4494 | |||
4472 | 2001-11-13 Fernando Perez <fperez@colorado.edu> |
|
4495 | 2001-11-13 Fernando Perez <fperez@colorado.edu> | |
4473 |
|
4496 | |||
4474 | * Reinstated the raw_input/prefilter separation that Janko had |
|
4497 | * Reinstated the raw_input/prefilter separation that Janko had | |
4475 | initially. This gives a more convenient setup for extending the |
|
4498 | initially. This gives a more convenient setup for extending the | |
4476 | pre-processor from the outside: raw_input always gets a string, |
|
4499 | pre-processor from the outside: raw_input always gets a string, | |
4477 | and prefilter has to process it. We can then redefine prefilter |
|
4500 | and prefilter has to process it. We can then redefine prefilter | |
4478 | from the outside and implement extensions for special |
|
4501 | from the outside and implement extensions for special | |
4479 | purposes. |
|
4502 | purposes. | |
4480 |
|
4503 | |||
4481 | Today I got one for inputting PhysicalQuantity objects |
|
4504 | Today I got one for inputting PhysicalQuantity objects | |
4482 | (from Scientific) without needing any function calls at |
|
4505 | (from Scientific) without needing any function calls at | |
4483 | all. Extremely convenient, and it's all done as a user-level |
|
4506 | all. Extremely convenient, and it's all done as a user-level | |
4484 | extension (no IPython code was touched). Now instead of: |
|
4507 | extension (no IPython code was touched). Now instead of: | |
4485 | a = PhysicalQuantity(4.2,'m/s**2') |
|
4508 | a = PhysicalQuantity(4.2,'m/s**2') | |
4486 | one can simply say |
|
4509 | one can simply say | |
4487 | a = 4.2 m/s**2 |
|
4510 | a = 4.2 m/s**2 | |
4488 | or even |
|
4511 | or even | |
4489 | a = 4.2 m/s^2 |
|
4512 | a = 4.2 m/s^2 | |
4490 |
|
4513 | |||
4491 | I use this, but it's also a proof of concept: IPython really is |
|
4514 | I use this, but it's also a proof of concept: IPython really is | |
4492 | fully user-extensible, even at the level of the parsing of the |
|
4515 | fully user-extensible, even at the level of the parsing of the | |
4493 | command line. It's not trivial, but it's perfectly doable. |
|
4516 | command line. It's not trivial, but it's perfectly doable. | |
4494 |
|
4517 | |||
4495 | * Added 'add_flip' method to inclusion conflict resolver. Fixes |
|
4518 | * Added 'add_flip' method to inclusion conflict resolver. Fixes | |
4496 | the problem of modules being loaded in the inverse order in which |
|
4519 | the problem of modules being loaded in the inverse order in which | |
4497 | they were defined in |
|
4520 | they were defined in | |
4498 |
|
4521 | |||
4499 | * Version 0.1.8 released, 0.1.9 opened for further work. |
|
4522 | * Version 0.1.8 released, 0.1.9 opened for further work. | |
4500 |
|
4523 | |||
4501 | * Added magics pdef, source and file. They respectively show the |
|
4524 | * Added magics pdef, source and file. They respectively show the | |
4502 | definition line ('prototype' in C), source code and full python |
|
4525 | definition line ('prototype' in C), source code and full python | |
4503 | file for any callable object. The object inspector oinfo uses |
|
4526 | file for any callable object. The object inspector oinfo uses | |
4504 | these to show the same information. |
|
4527 | these to show the same information. | |
4505 |
|
4528 | |||
4506 | * Version 0.1.7 released, 0.1.8 opened for further work. |
|
4529 | * Version 0.1.7 released, 0.1.8 opened for further work. | |
4507 |
|
4530 | |||
4508 | * Separated all the magic functions into a class called Magic. The |
|
4531 | * Separated all the magic functions into a class called Magic. The | |
4509 | InteractiveShell class was becoming too big for Xemacs to handle |
|
4532 | InteractiveShell class was becoming too big for Xemacs to handle | |
4510 | (de-indenting a line would lock it up for 10 seconds while it |
|
4533 | (de-indenting a line would lock it up for 10 seconds while it | |
4511 | backtracked on the whole class!) |
|
4534 | backtracked on the whole class!) | |
4512 |
|
4535 | |||
4513 | FIXME: didn't work. It can be done, but right now namespaces are |
|
4536 | FIXME: didn't work. It can be done, but right now namespaces are | |
4514 | all messed up. Do it later (reverted it for now, so at least |
|
4537 | all messed up. Do it later (reverted it for now, so at least | |
4515 | everything works as before). |
|
4538 | everything works as before). | |
4516 |
|
4539 | |||
4517 | * Got the object introspection system (magic_oinfo) working! I |
|
4540 | * Got the object introspection system (magic_oinfo) working! I | |
4518 | think this is pretty much ready for release to Janko, so he can |
|
4541 | think this is pretty much ready for release to Janko, so he can | |
4519 | test it for a while and then announce it. Pretty much 100% of what |
|
4542 | test it for a while and then announce it. Pretty much 100% of what | |
4520 | I wanted for the 'phase 1' release is ready. Happy, tired. |
|
4543 | I wanted for the 'phase 1' release is ready. Happy, tired. | |
4521 |
|
4544 | |||
4522 | 2001-11-12 Fernando Perez <fperez@colorado.edu> |
|
4545 | 2001-11-12 Fernando Perez <fperez@colorado.edu> | |
4523 |
|
4546 | |||
4524 | * Version 0.1.6 released, 0.1.7 opened for further work. |
|
4547 | * Version 0.1.6 released, 0.1.7 opened for further work. | |
4525 |
|
4548 | |||
4526 | * Fixed bug in printing: it used to test for truth before |
|
4549 | * Fixed bug in printing: it used to test for truth before | |
4527 | printing, so 0 wouldn't print. Now checks for None. |
|
4550 | printing, so 0 wouldn't print. Now checks for None. | |
4528 |
|
4551 | |||
4529 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c |
|
4552 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c | |
4530 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it |
|
4553 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it | |
4531 | reaches by hand into the outputcache. Think of a better way to do |
|
4554 | reaches by hand into the outputcache. Think of a better way to do | |
4532 | this later. |
|
4555 | this later. | |
4533 |
|
4556 | |||
4534 | * Various small fixes thanks to Nathan's comments. |
|
4557 | * Various small fixes thanks to Nathan's comments. | |
4535 |
|
4558 | |||
4536 | * Changed magic_pprint to magic_Pprint. This way it doesn't |
|
4559 | * Changed magic_pprint to magic_Pprint. This way it doesn't | |
4537 | collide with pprint() and the name is consistent with the command |
|
4560 | collide with pprint() and the name is consistent with the command | |
4538 | line option. |
|
4561 | line option. | |
4539 |
|
4562 | |||
4540 | * Changed prompt counter behavior to be fully like |
|
4563 | * Changed prompt counter behavior to be fully like | |
4541 | Mathematica's. That is, even input that doesn't return a result |
|
4564 | Mathematica's. That is, even input that doesn't return a result | |
4542 | raises the prompt counter. The old behavior was kind of confusing |
|
4565 | raises the prompt counter. The old behavior was kind of confusing | |
4543 | (getting the same prompt number several times if the operation |
|
4566 | (getting the same prompt number several times if the operation | |
4544 | didn't return a result). |
|
4567 | didn't return a result). | |
4545 |
|
4568 | |||
4546 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). |
|
4569 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). | |
4547 |
|
4570 | |||
4548 | * Fixed -Classic mode (wasn't working anymore). |
|
4571 | * Fixed -Classic mode (wasn't working anymore). | |
4549 |
|
4572 | |||
4550 | * Added colored prompts using Nathan's new code. Colors are |
|
4573 | * Added colored prompts using Nathan's new code. Colors are | |
4551 | currently hardwired, they can be user-configurable. For |
|
4574 | currently hardwired, they can be user-configurable. For | |
4552 | developers, they can be chosen in file ipythonlib.py, at the |
|
4575 | developers, they can be chosen in file ipythonlib.py, at the | |
4553 | beginning of the CachedOutput class def. |
|
4576 | beginning of the CachedOutput class def. | |
4554 |
|
4577 | |||
4555 | 2001-11-11 Fernando Perez <fperez@colorado.edu> |
|
4578 | 2001-11-11 Fernando Perez <fperez@colorado.edu> | |
4556 |
|
4579 | |||
4557 | * Version 0.1.5 released, 0.1.6 opened for further work. |
|
4580 | * Version 0.1.5 released, 0.1.6 opened for further work. | |
4558 |
|
4581 | |||
4559 | * Changed magic_env to *return* the environment as a dict (not to |
|
4582 | * Changed magic_env to *return* the environment as a dict (not to | |
4560 | print it). This way it prints, but it can also be processed. |
|
4583 | print it). This way it prints, but it can also be processed. | |
4561 |
|
4584 | |||
4562 | * Added Verbose exception reporting to interactive |
|
4585 | * Added Verbose exception reporting to interactive | |
4563 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose |
|
4586 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose | |
4564 | traceback. Had to make some changes to the ultraTB file. This is |
|
4587 | traceback. Had to make some changes to the ultraTB file. This is | |
4565 | probably the last 'big' thing in my mental todo list. This ties |
|
4588 | probably the last 'big' thing in my mental todo list. This ties | |
4566 | in with the next entry: |
|
4589 | in with the next entry: | |
4567 |
|
4590 | |||
4568 | * Changed -Xi and -Xf to a single -xmode option. Now all the user |
|
4591 | * Changed -Xi and -Xf to a single -xmode option. Now all the user | |
4569 | has to specify is Plain, Color or Verbose for all exception |
|
4592 | has to specify is Plain, Color or Verbose for all exception | |
4570 | handling. |
|
4593 | handling. | |
4571 |
|
4594 | |||
4572 | * Removed ShellServices option. All this can really be done via |
|
4595 | * Removed ShellServices option. All this can really be done via | |
4573 | the magic system. It's easier to extend, cleaner and has automatic |
|
4596 | the magic system. It's easier to extend, cleaner and has automatic | |
4574 | namespace protection and documentation. |
|
4597 | namespace protection and documentation. | |
4575 |
|
4598 | |||
4576 | 2001-11-09 Fernando Perez <fperez@colorado.edu> |
|
4599 | 2001-11-09 Fernando Perez <fperez@colorado.edu> | |
4577 |
|
4600 | |||
4578 | * Fixed bug in output cache flushing (missing parameter to |
|
4601 | * Fixed bug in output cache flushing (missing parameter to | |
4579 | __init__). Other small bugs fixed (found using pychecker). |
|
4602 | __init__). Other small bugs fixed (found using pychecker). | |
4580 |
|
4603 | |||
4581 | * Version 0.1.4 opened for bugfixing. |
|
4604 | * Version 0.1.4 opened for bugfixing. | |
4582 |
|
4605 | |||
4583 | 2001-11-07 Fernando Perez <fperez@colorado.edu> |
|
4606 | 2001-11-07 Fernando Perez <fperez@colorado.edu> | |
4584 |
|
4607 | |||
4585 | * Version 0.1.3 released, mainly because of the raw_input bug. |
|
4608 | * Version 0.1.3 released, mainly because of the raw_input bug. | |
4586 |
|
4609 | |||
4587 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed |
|
4610 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed | |
4588 | and when testing for whether things were callable, a call could |
|
4611 | and when testing for whether things were callable, a call could | |
4589 | actually be made to certain functions. They would get called again |
|
4612 | actually be made to certain functions. They would get called again | |
4590 | once 'really' executed, with a resulting double call. A disaster |
|
4613 | once 'really' executed, with a resulting double call. A disaster | |
4591 | in many cases (list.reverse() would never work!). |
|
4614 | in many cases (list.reverse() would never work!). | |
4592 |
|
4615 | |||
4593 | * Removed prefilter() function, moved its code to raw_input (which |
|
4616 | * Removed prefilter() function, moved its code to raw_input (which | |
4594 | after all was just a near-empty caller for prefilter). This saves |
|
4617 | after all was just a near-empty caller for prefilter). This saves | |
4595 | a function call on every prompt, and simplifies the class a tiny bit. |
|
4618 | a function call on every prompt, and simplifies the class a tiny bit. | |
4596 |
|
4619 | |||
4597 | * Fix _ip to __ip name in magic example file. |
|
4620 | * Fix _ip to __ip name in magic example file. | |
4598 |
|
4621 | |||
4599 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should |
|
4622 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should | |
4600 | work with non-gnu versions of tar. |
|
4623 | work with non-gnu versions of tar. | |
4601 |
|
4624 | |||
4602 | 2001-11-06 Fernando Perez <fperez@colorado.edu> |
|
4625 | 2001-11-06 Fernando Perez <fperez@colorado.edu> | |
4603 |
|
4626 | |||
4604 | * Version 0.1.2. Just to keep track of the recent changes. |
|
4627 | * Version 0.1.2. Just to keep track of the recent changes. | |
4605 |
|
4628 | |||
4606 | * Fixed nasty bug in output prompt routine. It used to check 'if |
|
4629 | * Fixed nasty bug in output prompt routine. It used to check 'if | |
4607 | arg != None...'. Problem is, this fails if arg implements a |
|
4630 | arg != None...'. Problem is, this fails if arg implements a | |
4608 | special comparison (__cmp__) which disallows comparing to |
|
4631 | special comparison (__cmp__) which disallows comparing to | |
4609 | None. Found it when trying to use the PhysicalQuantity module from |
|
4632 | None. Found it when trying to use the PhysicalQuantity module from | |
4610 | ScientificPython. |
|
4633 | ScientificPython. | |
4611 |
|
4634 | |||
4612 | 2001-11-05 Fernando Perez <fperez@colorado.edu> |
|
4635 | 2001-11-05 Fernando Perez <fperez@colorado.edu> | |
4613 |
|
4636 | |||
4614 | * Also added dirs. Now the pushd/popd/dirs family functions |
|
4637 | * Also added dirs. Now the pushd/popd/dirs family functions | |
4615 | basically like the shell, with the added convenience of going home |
|
4638 | basically like the shell, with the added convenience of going home | |
4616 | when called with no args. |
|
4639 | when called with no args. | |
4617 |
|
4640 | |||
4618 | * pushd/popd slightly modified to mimic shell behavior more |
|
4641 | * pushd/popd slightly modified to mimic shell behavior more | |
4619 | closely. |
|
4642 | closely. | |
4620 |
|
4643 | |||
4621 | * Added env,pushd,popd from ShellServices as magic functions. I |
|
4644 | * Added env,pushd,popd from ShellServices as magic functions. I | |
4622 | think the cleanest will be to port all desired functions from |
|
4645 | think the cleanest will be to port all desired functions from | |
4623 | ShellServices as magics and remove ShellServices altogether. This |
|
4646 | ShellServices as magics and remove ShellServices altogether. This | |
4624 | will provide a single, clean way of adding functionality |
|
4647 | will provide a single, clean way of adding functionality | |
4625 | (shell-type or otherwise) to IP. |
|
4648 | (shell-type or otherwise) to IP. | |
4626 |
|
4649 | |||
4627 | 2001-11-04 Fernando Perez <fperez@colorado.edu> |
|
4650 | 2001-11-04 Fernando Perez <fperez@colorado.edu> | |
4628 |
|
4651 | |||
4629 | * Added .ipython/ directory to sys.path. This way users can keep |
|
4652 | * Added .ipython/ directory to sys.path. This way users can keep | |
4630 | customizations there and access them via import. |
|
4653 | customizations there and access them via import. | |
4631 |
|
4654 | |||
4632 | 2001-11-03 Fernando Perez <fperez@colorado.edu> |
|
4655 | 2001-11-03 Fernando Perez <fperez@colorado.edu> | |
4633 |
|
4656 | |||
4634 | * Opened version 0.1.1 for new changes. |
|
4657 | * Opened version 0.1.1 for new changes. | |
4635 |
|
4658 | |||
4636 | * Changed version number to 0.1.0: first 'public' release, sent to |
|
4659 | * Changed version number to 0.1.0: first 'public' release, sent to | |
4637 | Nathan and Janko. |
|
4660 | Nathan and Janko. | |
4638 |
|
4661 | |||
4639 | * Lots of small fixes and tweaks. |
|
4662 | * Lots of small fixes and tweaks. | |
4640 |
|
4663 | |||
4641 | * Minor changes to whos format. Now strings are shown, snipped if |
|
4664 | * Minor changes to whos format. Now strings are shown, snipped if | |
4642 | too long. |
|
4665 | too long. | |
4643 |
|
4666 | |||
4644 | * Changed ShellServices to work on __main__ so they show up in @who |
|
4667 | * Changed ShellServices to work on __main__ so they show up in @who | |
4645 |
|
4668 | |||
4646 | * Help also works with ? at the end of a line: |
|
4669 | * Help also works with ? at the end of a line: | |
4647 | ?sin and sin? |
|
4670 | ?sin and sin? | |
4648 | both produce the same effect. This is nice, as often I use the |
|
4671 | both produce the same effect. This is nice, as often I use the | |
4649 | tab-complete to find the name of a method, but I used to then have |
|
4672 | tab-complete to find the name of a method, but I used to then have | |
4650 | to go to the beginning of the line to put a ? if I wanted more |
|
4673 | to go to the beginning of the line to put a ? if I wanted more | |
4651 | info. Now I can just add the ? and hit return. Convenient. |
|
4674 | info. Now I can just add the ? and hit return. Convenient. | |
4652 |
|
4675 | |||
4653 | 2001-11-02 Fernando Perez <fperez@colorado.edu> |
|
4676 | 2001-11-02 Fernando Perez <fperez@colorado.edu> | |
4654 |
|
4677 | |||
4655 | * Python version check (>=2.1) added. |
|
4678 | * Python version check (>=2.1) added. | |
4656 |
|
4679 | |||
4657 | * Added LazyPython documentation. At this point the docs are quite |
|
4680 | * Added LazyPython documentation. At this point the docs are quite | |
4658 | a mess. A cleanup is in order. |
|
4681 | a mess. A cleanup is in order. | |
4659 |
|
4682 | |||
4660 | * Auto-installer created. For some bizarre reason, the zipfiles |
|
4683 | * Auto-installer created. For some bizarre reason, the zipfiles | |
4661 | module isn't working on my system. So I made a tar version |
|
4684 | module isn't working on my system. So I made a tar version | |
4662 | (hopefully the command line options in various systems won't kill |
|
4685 | (hopefully the command line options in various systems won't kill | |
4663 | me). |
|
4686 | me). | |
4664 |
|
4687 | |||
4665 | * Fixes to Struct in genutils. Now all dictionary-like methods are |
|
4688 | * Fixes to Struct in genutils. Now all dictionary-like methods are | |
4666 | protected (reasonably). |
|
4689 | protected (reasonably). | |
4667 |
|
4690 | |||
4668 | * Added pager function to genutils and changed ? to print usage |
|
4691 | * Added pager function to genutils and changed ? to print usage | |
4669 | note through it (it was too long). |
|
4692 | note through it (it was too long). | |
4670 |
|
4693 | |||
4671 | * Added the LazyPython functionality. Works great! I changed the |
|
4694 | * Added the LazyPython functionality. Works great! I changed the | |
4672 | auto-quote escape to ';', it's on home row and next to '. But |
|
4695 | auto-quote escape to ';', it's on home row and next to '. But | |
4673 | both auto-quote and auto-paren (still /) escapes are command-line |
|
4696 | both auto-quote and auto-paren (still /) escapes are command-line | |
4674 | parameters. |
|
4697 | parameters. | |
4675 |
|
4698 | |||
4676 |
|
4699 | |||
4677 | 2001-11-01 Fernando Perez <fperez@colorado.edu> |
|
4700 | 2001-11-01 Fernando Perez <fperez@colorado.edu> | |
4678 |
|
4701 | |||
4679 | * Version changed to 0.0.7. Fairly large change: configuration now |
|
4702 | * Version changed to 0.0.7. Fairly large change: configuration now | |
4680 | is all stored in a directory, by default .ipython. There, all |
|
4703 | is all stored in a directory, by default .ipython. There, all | |
4681 | config files have normal looking names (not .names) |
|
4704 | config files have normal looking names (not .names) | |
4682 |
|
4705 | |||
4683 | * Version 0.0.6 Released first to Lucas and Archie as a test |
|
4706 | * Version 0.0.6 Released first to Lucas and Archie as a test | |
4684 | run. Since it's the first 'semi-public' release, change version to |
|
4707 | run. Since it's the first 'semi-public' release, change version to | |
4685 | > 0.0.6 for any changes now. |
|
4708 | > 0.0.6 for any changes now. | |
4686 |
|
4709 | |||
4687 | * Stuff I had put in the ipplib.py changelog: |
|
4710 | * Stuff I had put in the ipplib.py changelog: | |
4688 |
|
4711 | |||
4689 | Changes to InteractiveShell: |
|
4712 | Changes to InteractiveShell: | |
4690 |
|
4713 | |||
4691 | - Made the usage message a parameter. |
|
4714 | - Made the usage message a parameter. | |
4692 |
|
4715 | |||
4693 | - Require the name of the shell variable to be given. It's a bit |
|
4716 | - Require the name of the shell variable to be given. It's a bit | |
4694 | of a hack, but allows the name 'shell' not to be hardwire in the |
|
4717 | of a hack, but allows the name 'shell' not to be hardwire in the | |
4695 | magic (@) handler, which is problematic b/c it requires |
|
4718 | magic (@) handler, which is problematic b/c it requires | |
4696 | polluting the global namespace with 'shell'. This in turn is |
|
4719 | polluting the global namespace with 'shell'. This in turn is | |
4697 | fragile: if a user redefines a variable called shell, things |
|
4720 | fragile: if a user redefines a variable called shell, things | |
4698 | break. |
|
4721 | break. | |
4699 |
|
4722 | |||
4700 | - magic @: all functions available through @ need to be defined |
|
4723 | - magic @: all functions available through @ need to be defined | |
4701 | as magic_<name>, even though they can be called simply as |
|
4724 | as magic_<name>, even though they can be called simply as | |
4702 | @<name>. This allows the special command @magic to gather |
|
4725 | @<name>. This allows the special command @magic to gather | |
4703 | information automatically about all existing magic functions, |
|
4726 | information automatically about all existing magic functions, | |
4704 | even if they are run-time user extensions, by parsing the shell |
|
4727 | even if they are run-time user extensions, by parsing the shell | |
4705 | instance __dict__ looking for special magic_ names. |
|
4728 | instance __dict__ looking for special magic_ names. | |
4706 |
|
4729 | |||
4707 | - mainloop: added *two* local namespace parameters. This allows |
|
4730 | - mainloop: added *two* local namespace parameters. This allows | |
4708 | the class to differentiate between parameters which were there |
|
4731 | the class to differentiate between parameters which were there | |
4709 | before and after command line initialization was processed. This |
|
4732 | before and after command line initialization was processed. This | |
4710 | way, later @who can show things loaded at startup by the |
|
4733 | way, later @who can show things loaded at startup by the | |
4711 | user. This trick was necessary to make session saving/reloading |
|
4734 | user. This trick was necessary to make session saving/reloading | |
4712 | really work: ideally after saving/exiting/reloading a session, |
|
4735 | really work: ideally after saving/exiting/reloading a session, | |
4713 | *everythin* should look the same, including the output of @who. I |
|
4736 | *everythin* should look the same, including the output of @who. I | |
4714 | was only able to make this work with this double namespace |
|
4737 | was only able to make this work with this double namespace | |
4715 | trick. |
|
4738 | trick. | |
4716 |
|
4739 | |||
4717 | - added a header to the logfile which allows (almost) full |
|
4740 | - added a header to the logfile which allows (almost) full | |
4718 | session restoring. |
|
4741 | session restoring. | |
4719 |
|
4742 | |||
4720 | - prepend lines beginning with @ or !, with a and log |
|
4743 | - prepend lines beginning with @ or !, with a and log | |
4721 | them. Why? !lines: may be useful to know what you did @lines: |
|
4744 | them. Why? !lines: may be useful to know what you did @lines: | |
4722 | they may affect session state. So when restoring a session, at |
|
4745 | they may affect session state. So when restoring a session, at | |
4723 | least inform the user of their presence. I couldn't quite get |
|
4746 | least inform the user of their presence. I couldn't quite get | |
4724 | them to properly re-execute, but at least the user is warned. |
|
4747 | them to properly re-execute, but at least the user is warned. | |
4725 |
|
4748 | |||
4726 | * Started ChangeLog. |
|
4749 | * Started ChangeLog. |
@@ -1,127 +1,129 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | |||
3 | """An example of how to embed an IPython shell into a running program. |
|
3 | """An example of how to embed an IPython shell into a running program. | |
4 |
|
4 | |||
5 | Please see the documentation in the IPython.Shell module for more details. |
|
5 | Please see the documentation in the IPython.Shell module for more details. | |
6 |
|
6 | |||
7 | The accompanying file example-embed-short.py has quick code fragments for |
|
7 | The accompanying file example-embed-short.py has quick code fragments for | |
8 | embedding which you can cut and paste in your code once you understand how |
|
8 | embedding which you can cut and paste in your code once you understand how | |
9 | things work. |
|
9 | things work. | |
10 |
|
10 | |||
11 | The code in this file is deliberately extra-verbose, meant for learning.""" |
|
11 | The code in this file is deliberately extra-verbose, meant for learning.""" | |
12 |
|
12 | |||
13 | # The basics to get you going: |
|
13 | # The basics to get you going: | |
14 |
|
14 | |||
15 | # IPython sets the __IPYTHON__ variable so you can know if you have nested |
|
15 | # IPython sets the __IPYTHON__ variable so you can know if you have nested | |
16 | # copies running. |
|
16 | # copies running. | |
17 |
|
17 | |||
18 | # Try running this code both at the command line and from inside IPython (with |
|
18 | # Try running this code both at the command line and from inside IPython (with | |
19 | # %run example-embed.py) |
|
19 | # %run example-embed.py) | |
20 | try: |
|
20 | try: | |
21 | __IPYTHON__ |
|
21 | __IPYTHON__ | |
22 | except NameError: |
|
22 | except NameError: | |
23 | nested = 0 |
|
23 | nested = 0 | |
24 | args = [''] |
|
24 | args = [''] | |
25 | else: |
|
25 | else: | |
26 | print "Running nested copies of IPython." |
|
26 | print "Running nested copies of IPython." | |
27 | print "The prompts for the nested copy have been modified" |
|
27 | print "The prompts for the nested copy have been modified" | |
28 | nested = 1 |
|
28 | nested = 1 | |
29 | # what the embedded instance will see as sys.argv: |
|
29 | # what the embedded instance will see as sys.argv: | |
30 |
args = ['-pi1','In <\\#>:','-pi2',' .\\D.:', |
|
30 | args = ['-pi1','In <\\#>: ','-pi2',' .\\D.: ', | |
|
31 | '-po','Out<\\#>: ','-nosep'] | |||
31 |
|
32 | |||
32 | # First import the embeddable shell class |
|
33 | # First import the embeddable shell class | |
33 | from IPython.Shell import IPShellEmbed |
|
34 | from IPython.Shell import IPShellEmbed | |
34 |
|
35 | |||
35 | # Now create an instance of the embeddable shell. The first argument is a |
|
36 | # Now create an instance of the embeddable shell. The first argument is a | |
36 | # string with options exactly as you would type them if you were starting |
|
37 | # string with options exactly as you would type them if you were starting | |
37 | # IPython at the system command line. Any parameters you want to define for |
|
38 | # IPython at the system command line. Any parameters you want to define for | |
38 | # configuration can thus be specified here. |
|
39 | # configuration can thus be specified here. | |
39 | ipshell = IPShellEmbed(args, |
|
40 | ipshell = IPShellEmbed(args, | |
40 | banner = 'Dropping into IPython', |
|
41 | banner = 'Dropping into IPython', | |
41 | exit_msg = 'Leaving Interpreter, back to program.') |
|
42 | exit_msg = 'Leaving Interpreter, back to program.') | |
42 |
|
43 | |||
43 | # Make a second instance, you can have as many as you want. |
|
44 | # Make a second instance, you can have as many as you want. | |
44 | if nested: |
|
45 | if nested: | |
45 | args[1] = 'In2<\\#>' |
|
46 | args[1] = 'In2<\\#>' | |
46 | else: |
|
47 | else: | |
47 |
args = ['-pi1','In2<\\#>:','-pi2',' .\\D.:', |
|
48 | args = ['-pi1','In2<\\#>: ','-pi2',' .\\D.: ', | |
|
49 | '-po','Out<\\#>: ','-nosep'] | |||
48 | ipshell2 = IPShellEmbed(args,banner = 'Second IPython instance.') |
|
50 | ipshell2 = IPShellEmbed(args,banner = 'Second IPython instance.') | |
49 |
|
51 | |||
50 | print '\nHello. This is printed from the main controller program.\n' |
|
52 | print '\nHello. This is printed from the main controller program.\n' | |
51 |
|
53 | |||
52 | # You can then call ipshell() anywhere you need it (with an optional |
|
54 | # You can then call ipshell() anywhere you need it (with an optional | |
53 | # message): |
|
55 | # message): | |
54 | ipshell('***Called from top level. ' |
|
56 | ipshell('***Called from top level. ' | |
55 | 'Hit Ctrl-D to exit interpreter and continue program.') |
|
57 | 'Hit Ctrl-D to exit interpreter and continue program.') | |
56 |
|
58 | |||
57 | print '\nBack in caller program, moving along...\n' |
|
59 | print '\nBack in caller program, moving along...\n' | |
58 |
|
60 | |||
59 | #--------------------------------------------------------------------------- |
|
61 | #--------------------------------------------------------------------------- | |
60 | # More details: |
|
62 | # More details: | |
61 |
|
63 | |||
62 | # IPShellEmbed instances don't print the standard system banner and |
|
64 | # IPShellEmbed instances don't print the standard system banner and | |
63 | # messages. The IPython banner (which actually may contain initialization |
|
65 | # messages. The IPython banner (which actually may contain initialization | |
64 | # messages) is available as <instance>.IP.BANNER in case you want it. |
|
66 | # messages) is available as <instance>.IP.BANNER in case you want it. | |
65 |
|
67 | |||
66 | # IPShellEmbed instances print the following information everytime they |
|
68 | # IPShellEmbed instances print the following information everytime they | |
67 | # start: |
|
69 | # start: | |
68 |
|
70 | |||
69 | # - A global startup banner. |
|
71 | # - A global startup banner. | |
70 |
|
72 | |||
71 | # - A call-specific header string, which you can use to indicate where in the |
|
73 | # - A call-specific header string, which you can use to indicate where in the | |
72 | # execution flow the shell is starting. |
|
74 | # execution flow the shell is starting. | |
73 |
|
75 | |||
74 | # They also print an exit message every time they exit. |
|
76 | # They also print an exit message every time they exit. | |
75 |
|
77 | |||
76 | # Both the startup banner and the exit message default to None, and can be set |
|
78 | # Both the startup banner and the exit message default to None, and can be set | |
77 | # either at the instance constructor or at any other time with the |
|
79 | # either at the instance constructor or at any other time with the | |
78 | # set_banner() and set_exit_msg() methods. |
|
80 | # set_banner() and set_exit_msg() methods. | |
79 |
|
81 | |||
80 | # The shell instance can be also put in 'dummy' mode globally or on a per-call |
|
82 | # The shell instance can be also put in 'dummy' mode globally or on a per-call | |
81 | # basis. This gives you fine control for debugging without having to change |
|
83 | # basis. This gives you fine control for debugging without having to change | |
82 | # code all over the place. |
|
84 | # code all over the place. | |
83 |
|
85 | |||
84 | # The code below illustrates all this. |
|
86 | # The code below illustrates all this. | |
85 |
|
87 | |||
86 |
|
88 | |||
87 | # This is how the global banner and exit_msg can be reset at any point |
|
89 | # This is how the global banner and exit_msg can be reset at any point | |
88 | ipshell.set_banner('Entering interpreter - New Banner') |
|
90 | ipshell.set_banner('Entering interpreter - New Banner') | |
89 | ipshell.set_exit_msg('Leaving interpreter - New exit_msg') |
|
91 | ipshell.set_exit_msg('Leaving interpreter - New exit_msg') | |
90 |
|
92 | |||
91 | def foo(m): |
|
93 | def foo(m): | |
92 | s = 'spam' |
|
94 | s = 'spam' | |
93 | ipshell('***In foo(). Try @whos, or print s or m:') |
|
95 | ipshell('***In foo(). Try @whos, or print s or m:') | |
94 | print 'foo says m = ',m |
|
96 | print 'foo says m = ',m | |
95 |
|
97 | |||
96 | def bar(n): |
|
98 | def bar(n): | |
97 | s = 'eggs' |
|
99 | s = 'eggs' | |
98 | ipshell('***In bar(). Try @whos, or print s or n:') |
|
100 | ipshell('***In bar(). Try @whos, or print s or n:') | |
99 | print 'bar says n = ',n |
|
101 | print 'bar says n = ',n | |
100 |
|
102 | |||
101 | # Some calls to the above functions which will trigger IPython: |
|
103 | # Some calls to the above functions which will trigger IPython: | |
102 | print 'Main program calling foo("eggs")\n' |
|
104 | print 'Main program calling foo("eggs")\n' | |
103 | foo('eggs') |
|
105 | foo('eggs') | |
104 |
|
106 | |||
105 | # The shell can be put in 'dummy' mode where calls to it silently return. This |
|
107 | # The shell can be put in 'dummy' mode where calls to it silently return. This | |
106 | # allows you, for example, to globally turn off debugging for a program with a |
|
108 | # allows you, for example, to globally turn off debugging for a program with a | |
107 | # single call. |
|
109 | # single call. | |
108 | ipshell.set_dummy_mode(1) |
|
110 | ipshell.set_dummy_mode(1) | |
109 | print '\nTrying to call IPython which is now "dummy":' |
|
111 | print '\nTrying to call IPython which is now "dummy":' | |
110 | ipshell() |
|
112 | ipshell() | |
111 | print 'Nothing happened...' |
|
113 | print 'Nothing happened...' | |
112 | # The global 'dummy' mode can still be overridden for a single call |
|
114 | # The global 'dummy' mode can still be overridden for a single call | |
113 | print '\nOverriding dummy mode manually:' |
|
115 | print '\nOverriding dummy mode manually:' | |
114 | ipshell(dummy=0) |
|
116 | ipshell(dummy=0) | |
115 |
|
117 | |||
116 | # Reactivate the IPython shell |
|
118 | # Reactivate the IPython shell | |
117 | ipshell.set_dummy_mode(0) |
|
119 | ipshell.set_dummy_mode(0) | |
118 |
|
120 | |||
119 | print 'You can even have multiple embedded instances:' |
|
121 | print 'You can even have multiple embedded instances:' | |
120 | ipshell2() |
|
122 | ipshell2() | |
121 |
|
123 | |||
122 | print '\nMain program calling bar("spam")\n' |
|
124 | print '\nMain program calling bar("spam")\n' | |
123 | bar('spam') |
|
125 | bar('spam') | |
124 |
|
126 | |||
125 | print 'Main program finished. Bye!' |
|
127 | print 'Main program finished. Bye!' | |
126 |
|
128 | |||
127 | #********************** End of file <example-embed.py> *********************** |
|
129 | #********************** End of file <example-embed.py> *********************** |
General Comments 0
You need to be logged in to leave comments.
Login now