Show More
@@ -0,0 +1,267 b'' | |||||
|
1 | #!/usr/bin/env python | |||
|
2 | ||||
|
3 | """ PickleShare - a small 'shelve' like datastore with concurrency support | |||
|
4 | ||||
|
5 | Like shelve, a PickleShareDB object acts like a normal dictionary. Unlike | |||
|
6 | shelve, many processes can access the database simultaneously. Changing a | |||
|
7 | value in database is immediately visible to other processes accessing the | |||
|
8 | same database. | |||
|
9 | ||||
|
10 | Concurrency is possible because the values are stored in separate files. Hence | |||
|
11 | the "database" is a directory where *all* files are governed by PickleShare. | |||
|
12 | ||||
|
13 | Example usage:: | |||
|
14 | ||||
|
15 | from pickleshare import * | |||
|
16 | db = PickleShareDB('~/testpickleshare') | |||
|
17 | db.clear() | |||
|
18 | print "Should be empty:",db.items() | |||
|
19 | db['hello'] = 15 | |||
|
20 | db['aku ankka'] = [1,2,313] | |||
|
21 | db['paths/are/ok/key'] = [1,(5,46)] | |||
|
22 | print db.keys() | |||
|
23 | del db['aku ankka'] | |||
|
24 | ||||
|
25 | This module is certainly not ZODB, but can be used for low-load | |||
|
26 | (non-mission-critical) situations where tiny code size trumps the | |||
|
27 | advanced features of a "real" object database. | |||
|
28 | ||||
|
29 | Installation guide: easy_install pickleshare | |||
|
30 | ||||
|
31 | Author: Ville Vainio <vivainio@gmail.com> | |||
|
32 | License: MIT open source license. | |||
|
33 | ||||
|
34 | """ | |||
|
35 | ||||
|
36 | from path import path as Path | |||
|
37 | import os,stat,time | |||
|
38 | import cPickle as pickle | |||
|
39 | import UserDict | |||
|
40 | import warnings | |||
|
41 | import glob | |||
|
42 | ||||
|
43 | class PickleShareDB(UserDict.DictMixin): | |||
|
44 | """ The main 'connection' object for PickleShare database """ | |||
|
45 | def __init__(self,root): | |||
|
46 | """ Return a db object that will manage the specied directory""" | |||
|
47 | self.root = Path(root).expanduser().abspath() | |||
|
48 | if not self.root.isdir(): | |||
|
49 | self.root.makedirs() | |||
|
50 | # cache has { 'key' : (obj, orig_mod_time) } | |||
|
51 | self.cache = {} | |||
|
52 | ||||
|
53 | def __getitem__(self,key): | |||
|
54 | """ db['key'] reading """ | |||
|
55 | fil = self.root / key | |||
|
56 | try: | |||
|
57 | mtime = (fil.stat()[stat.ST_MTIME]) | |||
|
58 | except OSError: | |||
|
59 | raise KeyError(key) | |||
|
60 | ||||
|
61 | if fil in self.cache and mtime == self.cache[fil][1]: | |||
|
62 | return self.cache[fil][0] | |||
|
63 | try: | |||
|
64 | # The cached item has expired, need to read | |||
|
65 | obj = pickle.load(fil.open()) | |||
|
66 | except: | |||
|
67 | raise KeyError(key) | |||
|
68 | ||||
|
69 | self.cache[fil] = (obj,mtime) | |||
|
70 | return obj | |||
|
71 | ||||
|
72 | def __setitem__(self,key,value): | |||
|
73 | """ db['key'] = 5 """ | |||
|
74 | fil = self.root / key | |||
|
75 | parent = fil.parent | |||
|
76 | if parent and not parent.isdir(): | |||
|
77 | parent.makedirs() | |||
|
78 | pickled = pickle.dump(value,fil.open('w')) | |||
|
79 | try: | |||
|
80 | self.cache[fil] = (value,fil.mtime) | |||
|
81 | except OSError,e: | |||
|
82 | if e.errno != 2: | |||
|
83 | raise | |||
|
84 | ||||
|
85 | def __delitem__(self,key): | |||
|
86 | """ del db["key"] """ | |||
|
87 | fil = self.root / key | |||
|
88 | self.cache.pop(fil,None) | |||
|
89 | try: | |||
|
90 | fil.remove() | |||
|
91 | except OSError: | |||
|
92 | # notfound and permission denied are ok - we | |||
|
93 | # lost, the other process wins the conflict | |||
|
94 | pass | |||
|
95 | ||||
|
96 | def _normalized(self, p): | |||
|
97 | """ Make a key suitable for user's eyes """ | |||
|
98 | return str(self.root.relpathto(p)).replace('\\','/') | |||
|
99 | ||||
|
100 | def keys(self, globpat = None): | |||
|
101 | """ All keys in DB, or all keys matching a glob""" | |||
|
102 | ||||
|
103 | if globpat is None: | |||
|
104 | files = self.root.walkfiles() | |||
|
105 | else: | |||
|
106 | files = [Path(p) for p in glob.glob(self.root/globpat)] | |||
|
107 | return [self._normalized(p) for p in files if p.isfile()] | |||
|
108 | ||||
|
109 | def uncache(self,*items): | |||
|
110 | """ Removes all, or specified items from cache | |||
|
111 | ||||
|
112 | Use this after reading a large amount of large objects | |||
|
113 | to free up memory, when you won't be needing the objects | |||
|
114 | for a while. | |||
|
115 | ||||
|
116 | """ | |||
|
117 | if not items: | |||
|
118 | self.cache = {} | |||
|
119 | for it in items: | |||
|
120 | self.cache.pop(it,None) | |||
|
121 | ||||
|
122 | def waitget(self,key, maxwaittime = 60 ): | |||
|
123 | """ Wait (poll) for a key to get a value | |||
|
124 | ||||
|
125 | Will wait for `maxwaittime` seconds before raising a KeyError. | |||
|
126 | The call exits normally if the `key` field in db gets a value | |||
|
127 | within the timeout period. | |||
|
128 | ||||
|
129 | Use this for synchronizing different processes or for ensuring | |||
|
130 | that an unfortunately timed "db['key'] = newvalue" operation | |||
|
131 | in another process (which causes all 'get' operation to cause a | |||
|
132 | KeyError for the duration of pickling) won't screw up your program | |||
|
133 | logic. | |||
|
134 | """ | |||
|
135 | ||||
|
136 | wtimes = [0.2] * 3 + [0.5] * 2 + [1] | |||
|
137 | tries = 0 | |||
|
138 | waited = 0 | |||
|
139 | while 1: | |||
|
140 | try: | |||
|
141 | val = self[key] | |||
|
142 | return val | |||
|
143 | except KeyError: | |||
|
144 | pass | |||
|
145 | ||||
|
146 | if waited > maxwaittime: | |||
|
147 | raise KeyError(key) | |||
|
148 | ||||
|
149 | time.sleep(wtimes[tries]) | |||
|
150 | waited+=wtimes[tries] | |||
|
151 | if tries < len(wtimes) -1: | |||
|
152 | tries+=1 | |||
|
153 | ||||
|
154 | def getlink(self,folder): | |||
|
155 | """ Get a convenient link for accessing items """ | |||
|
156 | return PickleShareLink(self, folder) | |||
|
157 | ||||
|
158 | def __repr__(self): | |||
|
159 | return "PickleShareDB('%s')" % self.root | |||
|
160 | ||||
|
161 | ||||
|
162 | ||||
|
163 | class PickleShareLink: | |||
|
164 | """ A shortdand for accessing nested PickleShare data conveniently. | |||
|
165 | ||||
|
166 | Created through PickleShareDB.getlink(), example:: | |||
|
167 | ||||
|
168 | lnk = db.getlink('myobjects/test') | |||
|
169 | lnk.foo = 2 | |||
|
170 | lnk.bar = lnk.foo + 5 | |||
|
171 | ||||
|
172 | """ | |||
|
173 | def __init__(self, db, keydir ): | |||
|
174 | self.__dict__.update(locals()) | |||
|
175 | ||||
|
176 | def __getattr__(self,key): | |||
|
177 | return self.__dict__['db'][self.__dict__['keydir']+'/' + key] | |||
|
178 | def __setattr__(self,key,val): | |||
|
179 | self.db[self.keydir+'/' + key] = val | |||
|
180 | def __repr__(self): | |||
|
181 | db = self.__dict__['db'] | |||
|
182 | keys = db.keys( self.__dict__['keydir'] +"/*") | |||
|
183 | return "<PickleShareLink '%s': %s>" % ( | |||
|
184 | self.__dict__['keydir'], | |||
|
185 | ";".join([Path(k).basename() for k in keys])) | |||
|
186 | ||||
|
187 | ||||
|
188 | def test(): | |||
|
189 | db = PickleShareDB('~/testpickleshare') | |||
|
190 | db.clear() | |||
|
191 | print "Should be empty:",db.items() | |||
|
192 | db['hello'] = 15 | |||
|
193 | db['aku ankka'] = [1,2,313] | |||
|
194 | db['paths/nest/ok/keyname'] = [1,(5,46)] | |||
|
195 | print db.keys() | |||
|
196 | print db.keys('paths/nest/ok/k*') | |||
|
197 | print dict(db) # snapsot of whole db | |||
|
198 | db.uncache() # frees memory, causes re-reads later | |||
|
199 | ||||
|
200 | # shorthand for accessing deeply nested files | |||
|
201 | lnk = db.getlink('myobjects/test') | |||
|
202 | lnk.foo = 2 | |||
|
203 | lnk.bar = lnk.foo + 5 | |||
|
204 | print lnk.bar # 7 | |||
|
205 | ||||
|
206 | def stress(): | |||
|
207 | db = PickleShareDB('~/fsdbtest') | |||
|
208 | import time,sys | |||
|
209 | for i in range(1000): | |||
|
210 | for j in range(300): | |||
|
211 | if i % 15 == 0 and i < 200: | |||
|
212 | if str(j) in db: | |||
|
213 | del db[str(j)] | |||
|
214 | continue | |||
|
215 | ||||
|
216 | if j%33 == 0: | |||
|
217 | time.sleep(0.02) | |||
|
218 | ||||
|
219 | db[str(j)] = db.get(str(j), []) + [(i,j,"proc %d" % os.getpid())] | |||
|
220 | print i, | |||
|
221 | sys.stdout.flush() | |||
|
222 | if i % 10 == 0: | |||
|
223 | db.uncache() | |||
|
224 | ||||
|
225 | def main(): | |||
|
226 | import textwrap | |||
|
227 | usage = textwrap.dedent("""\ | |||
|
228 | pickleshare - manage PickleShare databases | |||
|
229 | ||||
|
230 | Usage: | |||
|
231 | ||||
|
232 | pickleshare dump /path/to/db > dump.txt | |||
|
233 | pickleshare load /path/to/db < dump.txt | |||
|
234 | pickleshare test /path/to/db | |||
|
235 | """) | |||
|
236 | DB = PickleShareDB | |||
|
237 | import sys | |||
|
238 | if len(sys.argv) < 2: | |||
|
239 | print usage | |||
|
240 | return | |||
|
241 | ||||
|
242 | cmd = sys.argv[1] | |||
|
243 | args = sys.argv[2:] | |||
|
244 | if cmd == 'dump': | |||
|
245 | if not args: args= ['.'] | |||
|
246 | db = DB(args[0]) | |||
|
247 | import pprint | |||
|
248 | pprint.pprint(db.items()) | |||
|
249 | elif cmd == 'load': | |||
|
250 | cont = sys.stdin.read() | |||
|
251 | db = DB(args[0]) | |||
|
252 | data = eval(cont) | |||
|
253 | db.clear() | |||
|
254 | for k,v in db.items(): | |||
|
255 | db[k] = v | |||
|
256 | elif cmd == 'testwait': | |||
|
257 | db = DB(args[0]) | |||
|
258 | db.clear() | |||
|
259 | print db.waitget('250') | |||
|
260 | elif cmd == 'test': | |||
|
261 | test() | |||
|
262 | stress() | |||
|
263 | ||||
|
264 | if __name__== "__main__": | |||
|
265 | main() | |||
|
266 | ||||
|
267 | No newline at end of file |
@@ -0,0 +1,149 b'' | |||||
|
1 | import IPython.ipapi | |||
|
2 | ip = IPython.ipapi.get() | |||
|
3 | ||||
|
4 | import pickleshare | |||
|
5 | ||||
|
6 | import inspect,pickle,os,textwrap | |||
|
7 | from IPython.FakeModule import FakeModule | |||
|
8 | ||||
|
9 | def refresh_variables(ip): | |||
|
10 | db = ip.getdb() | |||
|
11 | for key in db.keys('autorestore/*'): | |||
|
12 | # strip autorestore | |||
|
13 | justkey = os.path.basename(key) | |||
|
14 | try: | |||
|
15 | obj = db[key] | |||
|
16 | except KeyError: | |||
|
17 | print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % justkey | |||
|
18 | print "The error was:",sys.exc_info()[0] | |||
|
19 | else: | |||
|
20 | #print "restored",justkey,"=",obj #dbg | |||
|
21 | ip.user_ns()[justkey] = obj | |||
|
22 | ||||
|
23 | ||||
|
24 | ||||
|
25 | def restore_data(self): | |||
|
26 | #o = ip.options() | |||
|
27 | #self.db = pickleshare.PickleShareDB(o.ipythondir + "/db") | |||
|
28 | #print "restoring ps data" # dbg | |||
|
29 | ||||
|
30 | ip = self.getapi() | |||
|
31 | refresh_variables(ip) | |||
|
32 | raise IPython.ipapi.TryNext | |||
|
33 | ||||
|
34 | ||||
|
35 | ip.set_hook('late_startup_hook', restore_data) | |||
|
36 | ||||
|
37 | def magic_store(self, parameter_s=''): | |||
|
38 | """Lightweight persistence for python variables. | |||
|
39 | ||||
|
40 | Example: | |||
|
41 | ||||
|
42 | ville@badger[~]|1> A = ['hello',10,'world']\\ | |||
|
43 | ville@badger[~]|2> %store A\\ | |||
|
44 | ville@badger[~]|3> Exit | |||
|
45 | ||||
|
46 | (IPython session is closed and started again...) | |||
|
47 | ||||
|
48 | ville@badger:~$ ipython -p pysh\\ | |||
|
49 | ville@badger[~]|1> print A | |||
|
50 | ||||
|
51 | ['hello', 10, 'world'] | |||
|
52 | ||||
|
53 | Usage: | |||
|
54 | ||||
|
55 | %store - Show list of all variables and their current values\\ | |||
|
56 | %store <var> - Store the *current* value of the variable to disk\\ | |||
|
57 | %store -d <var> - Remove the variable and its value from storage\\ | |||
|
58 | %store -z - Remove all variables from storage\\ | |||
|
59 | %store -r - Refresh all variables from store (delete current vals)\\ | |||
|
60 | %store foo >a.txt - Store value of foo to new file a.txt\\ | |||
|
61 | %store foo >>a.txt - Append value of foo to file a.txt\\ | |||
|
62 | ||||
|
63 | It should be noted that if you change the value of a variable, you | |||
|
64 | need to %store it again if you want to persist the new value. | |||
|
65 | ||||
|
66 | Note also that the variables will need to be pickleable; most basic | |||
|
67 | python types can be safely %stored. | |||
|
68 | """ | |||
|
69 | ||||
|
70 | opts,argsl = self.parse_options(parameter_s,'drz',mode='string') | |||
|
71 | args = argsl.split(None,1) | |||
|
72 | ip = self.getapi() | |||
|
73 | # delete | |||
|
74 | if opts.has_key('d'): | |||
|
75 | try: | |||
|
76 | todel = args[0] | |||
|
77 | except IndexError: | |||
|
78 | error('You must provide the variable to forget') | |||
|
79 | else: | |||
|
80 | try: | |||
|
81 | del self.db['autorestore/' + todel] | |||
|
82 | except: | |||
|
83 | error("Can't delete variable '%s'" % todel) | |||
|
84 | # reset | |||
|
85 | elif opts.has_key('z'): | |||
|
86 | for k in self.db.keys('autorestore/*'): | |||
|
87 | del self.db[k] | |||
|
88 | ||||
|
89 | elif opts.has_key('r'): | |||
|
90 | refresh_variables(ip) | |||
|
91 | ||||
|
92 | ||||
|
93 | # run without arguments -> list variables & values | |||
|
94 | elif not args: | |||
|
95 | vars = self.db.keys('autorestore/*') | |||
|
96 | vars.sort() | |||
|
97 | if vars: | |||
|
98 | size = max(map(len,vars)) | |||
|
99 | else: | |||
|
100 | size = 0 | |||
|
101 | ||||
|
102 | print 'Stored variables and their in-db values:' | |||
|
103 | fmt = '%-'+str(size)+'s -> %s' | |||
|
104 | get = self.db.get | |||
|
105 | for var in vars: | |||
|
106 | justkey = os.path.basename(var) | |||
|
107 | # print 30 first characters from every var | |||
|
108 | print fmt % (justkey,repr(get(var,'<unavailable>'))[:50]) | |||
|
109 | ||||
|
110 | # default action - store the variable | |||
|
111 | else: | |||
|
112 | # %store foo >file.txt or >>file.txt | |||
|
113 | if len(args) > 1 and args[1].startswith('>'): | |||
|
114 | fnam = os.path.expanduser(args[1].lstrip('>').lstrip()) | |||
|
115 | if args[1].startswith('>>'): | |||
|
116 | fil = open(fnam,'a') | |||
|
117 | else: | |||
|
118 | fil = open(fnam,'w') | |||
|
119 | obj = ip.ev(args[0]) | |||
|
120 | print "Writing '%s' (%s) to file '%s'." % (args[0], | |||
|
121 | obj.__class__.__name__, fnam) | |||
|
122 | ||||
|
123 | ||||
|
124 | if not isinstance (obj,basestring): | |||
|
125 | pprint(obj,fil) | |||
|
126 | else: | |||
|
127 | fil.write(obj) | |||
|
128 | if not obj.endswith('\n'): | |||
|
129 | fil.write('\n') | |||
|
130 | ||||
|
131 | fil.close() | |||
|
132 | return | |||
|
133 | ||||
|
134 | # %store foo | |||
|
135 | obj = ip.ev(args[0]) | |||
|
136 | if isinstance(inspect.getmodule(obj), FakeModule): | |||
|
137 | print textwrap.dedent("""\ | |||
|
138 | Warning:%s is %s | |||
|
139 | Proper storage of interactively declared classes (or instances | |||
|
140 | of those classes) is not possible! Only instances | |||
|
141 | of classes in real modules on file system can be %%store'd. | |||
|
142 | """ % (args[0], obj) ) | |||
|
143 | return | |||
|
144 | #pickled = pickle.dumps(obj) | |||
|
145 | self.db[ 'autorestore/' + args[0] ] = obj | |||
|
146 | print "Stored '%s' (%s)" % (args[0], obj.__class__.__name__) | |||
|
147 | ||||
|
148 | ip.expose_magic('store',magic_store) | |||
|
149 | No newline at end of file |
@@ -1,18 +1,19 b'' | |||||
1 | """ System wide configuration file for IPython. |
|
1 | """ System wide configuration file for IPython. | |
2 |
|
2 | |||
3 | This will be imported by ipython for all users. |
|
3 | This will be imported by ipython for all users. | |
4 |
|
4 | |||
5 | After this ipy_user_conf.py is imported, user specific configuration |
|
5 | After this ipy_user_conf.py is imported, user specific configuration | |
6 | should reside there. |
|
6 | should reside there. | |
7 |
|
7 | |||
8 | """ |
|
8 | """ | |
9 |
|
9 | |||
10 | import IPython.ipapi as ip |
|
10 | import IPython.ipapi as ip | |
11 |
|
11 | |||
12 | # add system wide configuration information, import extensions etc. here. |
|
12 | # add system wide configuration information, import extensions etc. here. | |
13 | # nothing here is essential |
|
13 | # nothing here is essential | |
14 |
|
14 | |||
15 | import sys |
|
15 | import sys | |
16 |
|
16 | |||
17 | import ext_rehashdir # %rehashdir magic |
|
17 | import ext_rehashdir # %rehashdir magic | |
18 | import ext_rescapture # var = !ls and var = %magic |
|
18 | import ext_rescapture # var = !ls and var = %magic | |
|
19 | import pspersistence # %store magic No newline at end of file |
@@ -1,2859 +1,2754 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 1 |
|
4 | $Id: Magic.py 1107 2006-01-30 19:02:20Z vivainio $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and | |
8 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
8 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
9 | # |
|
9 | # | |
10 | # Distributed under the terms of the BSD License. The full license is in |
|
10 | # Distributed under the terms of the BSD License. The full license is in | |
11 | # the file COPYING, distributed as part of this software. |
|
11 | # the file COPYING, distributed as part of this software. | |
12 | #***************************************************************************** |
|
12 | #***************************************************************************** | |
13 |
|
13 | |||
14 | #**************************************************************************** |
|
14 | #**************************************************************************** | |
15 | # Modules and globals |
|
15 | # Modules and globals | |
16 |
|
16 | |||
17 | from IPython import Release |
|
17 | from IPython import Release | |
18 | __author__ = '%s <%s>\n%s <%s>' % \ |
|
18 | __author__ = '%s <%s>\n%s <%s>' % \ | |
19 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) |
|
19 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) | |
20 | __license__ = Release.license |
|
20 | __license__ = Release.license | |
21 |
|
21 | |||
22 | # Python standard modules |
|
22 | # Python standard modules | |
23 | import __builtin__ |
|
23 | import __builtin__ | |
24 | import bdb |
|
24 | import bdb | |
25 | import inspect |
|
25 | import inspect | |
26 | import os |
|
26 | import os | |
27 | import pdb |
|
27 | import pdb | |
28 | import pydoc |
|
28 | import pydoc | |
29 | import sys |
|
29 | import sys | |
30 | import re |
|
30 | import re | |
31 | import tempfile |
|
31 | import tempfile | |
32 | import time |
|
32 | import time | |
33 | import cPickle as pickle |
|
33 | import cPickle as pickle | |
34 | import textwrap |
|
34 | import textwrap | |
35 | from cStringIO import StringIO |
|
35 | from cStringIO import StringIO | |
36 | from getopt import getopt,GetoptError |
|
36 | from getopt import getopt,GetoptError | |
37 | from pprint import pprint, pformat |
|
37 | from pprint import pprint, pformat | |
38 |
|
38 | |||
39 | # profile isn't bundled by default in Debian for license reasons |
|
39 | # profile isn't bundled by default in Debian for license reasons | |
40 | try: |
|
40 | try: | |
41 | import profile,pstats |
|
41 | import profile,pstats | |
42 | except ImportError: |
|
42 | except ImportError: | |
43 | profile = pstats = None |
|
43 | profile = pstats = None | |
44 |
|
44 | |||
45 | # Homebrewed |
|
45 | # Homebrewed | |
46 | from IPython import Debugger, OInspect, wildcard |
|
46 | from IPython import Debugger, OInspect, wildcard | |
47 | from IPython.FakeModule import FakeModule |
|
47 | from IPython.FakeModule import FakeModule | |
48 | from IPython.Itpl import Itpl, itpl, printpl,itplns |
|
48 | from IPython.Itpl import Itpl, itpl, printpl,itplns | |
49 | from IPython.PyColorize import Parser |
|
49 | from IPython.PyColorize import Parser | |
50 | from IPython.ipstruct import Struct |
|
50 | from IPython.ipstruct import Struct | |
51 | from IPython.macro import Macro |
|
51 | from IPython.macro import Macro | |
52 | from IPython.genutils import * |
|
52 | from IPython.genutils import * | |
53 | from IPython import platutils |
|
53 | from IPython import platutils | |
54 |
|
54 | |||
55 | #*************************************************************************** |
|
55 | #*************************************************************************** | |
56 | # Utility functions |
|
56 | # Utility functions | |
57 | def on_off(tag): |
|
57 | def on_off(tag): | |
58 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" |
|
58 | """Return an ON/OFF string for a 1/0 input. Simple utility function.""" | |
59 | return ['OFF','ON'][tag] |
|
59 | return ['OFF','ON'][tag] | |
60 |
|
60 | |||
61 | class Bunch: pass |
|
61 | class Bunch: pass | |
62 |
|
62 | |||
63 | #*************************************************************************** |
|
63 | #*************************************************************************** | |
64 | # Main class implementing Magic functionality |
|
64 | # Main class implementing Magic functionality | |
65 | class Magic: |
|
65 | class Magic: | |
66 | """Magic functions for InteractiveShell. |
|
66 | """Magic functions for InteractiveShell. | |
67 |
|
67 | |||
68 | Shell functions which can be reached as %function_name. All magic |
|
68 | Shell functions which can be reached as %function_name. All magic | |
69 | functions should accept a string, which they can parse for their own |
|
69 | functions should accept a string, which they can parse for their own | |
70 | needs. This can make some functions easier to type, eg `%cd ../` |
|
70 | needs. This can make some functions easier to type, eg `%cd ../` | |
71 | vs. `%cd("../")` |
|
71 | vs. `%cd("../")` | |
72 |
|
72 | |||
73 | ALL definitions MUST begin with the prefix magic_. The user won't need it |
|
73 | ALL definitions MUST begin with the prefix magic_. The user won't need it | |
74 | at the command line, but it is is needed in the definition. """ |
|
74 | at the command line, but it is is needed in the definition. """ | |
75 |
|
75 | |||
76 | # class globals |
|
76 | # class globals | |
77 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', |
|
77 | auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.', | |
78 | 'Automagic is ON, % prefix NOT needed for magic functions.'] |
|
78 | 'Automagic is ON, % prefix NOT needed for magic functions.'] | |
79 |
|
79 | |||
80 | #...................................................................... |
|
80 | #...................................................................... | |
81 | # some utility functions |
|
81 | # some utility functions | |
82 |
|
82 | |||
83 | def __init__(self,shell): |
|
83 | def __init__(self,shell): | |
84 |
|
84 | |||
85 | self.options_table = {} |
|
85 | self.options_table = {} | |
86 | if profile is None: |
|
86 | if profile is None: | |
87 | self.magic_prun = self.profile_missing_notice |
|
87 | self.magic_prun = self.profile_missing_notice | |
88 | self.shell = shell |
|
88 | self.shell = shell | |
89 |
|
89 | |||
90 | # namespace for holding state we may need |
|
90 | # namespace for holding state we may need | |
91 | self._magic_state = Bunch() |
|
91 | self._magic_state = Bunch() | |
92 |
|
92 | |||
93 | def profile_missing_notice(self, *args, **kwargs): |
|
93 | def profile_missing_notice(self, *args, **kwargs): | |
94 | error("""\ |
|
94 | error("""\ | |
95 | The profile module could not be found. If you are a Debian user, |
|
95 | The profile module could not be found. If you are a Debian user, | |
96 | it has been removed from the standard Debian package because of its non-free |
|
96 | it has been removed from the standard Debian package because of its non-free | |
97 | license. To use profiling, please install"python2.3-profiler" from non-free.""") |
|
97 | license. To use profiling, please install"python2.3-profiler" from non-free.""") | |
98 |
|
98 | |||
99 | def default_option(self,fn,optstr): |
|
99 | def default_option(self,fn,optstr): | |
100 | """Make an entry in the options_table for fn, with value optstr""" |
|
100 | """Make an entry in the options_table for fn, with value optstr""" | |
101 |
|
101 | |||
102 | if fn not in self.lsmagic(): |
|
102 | if fn not in self.lsmagic(): | |
103 | error("%s is not a magic function" % fn) |
|
103 | error("%s is not a magic function" % fn) | |
104 | self.options_table[fn] = optstr |
|
104 | self.options_table[fn] = optstr | |
105 |
|
105 | |||
106 | def lsmagic(self): |
|
106 | def lsmagic(self): | |
107 | """Return a list of currently available magic functions. |
|
107 | """Return a list of currently available magic functions. | |
108 |
|
108 | |||
109 | Gives a list of the bare names after mangling (['ls','cd', ...], not |
|
109 | Gives a list of the bare names after mangling (['ls','cd', ...], not | |
110 | ['magic_ls','magic_cd',...]""" |
|
110 | ['magic_ls','magic_cd',...]""" | |
111 |
|
111 | |||
112 | # FIXME. This needs a cleanup, in the way the magics list is built. |
|
112 | # FIXME. This needs a cleanup, in the way the magics list is built. | |
113 |
|
113 | |||
114 | # magics in class definition |
|
114 | # magics in class definition | |
115 | class_magic = lambda fn: fn.startswith('magic_') and \ |
|
115 | class_magic = lambda fn: fn.startswith('magic_') and \ | |
116 | callable(Magic.__dict__[fn]) |
|
116 | callable(Magic.__dict__[fn]) | |
117 | # in instance namespace (run-time user additions) |
|
117 | # in instance namespace (run-time user additions) | |
118 | inst_magic = lambda fn: fn.startswith('magic_') and \ |
|
118 | inst_magic = lambda fn: fn.startswith('magic_') and \ | |
119 | callable(self.__dict__[fn]) |
|
119 | callable(self.__dict__[fn]) | |
120 | # and bound magics by user (so they can access self): |
|
120 | # and bound magics by user (so they can access self): | |
121 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ |
|
121 | inst_bound_magic = lambda fn: fn.startswith('magic_') and \ | |
122 | callable(self.__class__.__dict__[fn]) |
|
122 | callable(self.__class__.__dict__[fn]) | |
123 | magics = filter(class_magic,Magic.__dict__.keys()) + \ |
|
123 | magics = filter(class_magic,Magic.__dict__.keys()) + \ | |
124 | filter(inst_magic,self.__dict__.keys()) + \ |
|
124 | filter(inst_magic,self.__dict__.keys()) + \ | |
125 | filter(inst_bound_magic,self.__class__.__dict__.keys()) |
|
125 | filter(inst_bound_magic,self.__class__.__dict__.keys()) | |
126 | out = [] |
|
126 | out = [] | |
127 | for fn in magics: |
|
127 | for fn in magics: | |
128 | out.append(fn.replace('magic_','',1)) |
|
128 | out.append(fn.replace('magic_','',1)) | |
129 | out.sort() |
|
129 | out.sort() | |
130 | return out |
|
130 | return out | |
131 |
|
131 | |||
132 | def extract_input_slices(self,slices): |
|
132 | def extract_input_slices(self,slices): | |
133 | """Return as a string a set of input history slices. |
|
133 | """Return as a string a set of input history slices. | |
134 |
|
134 | |||
135 | The set of slices is given as a list of strings (like ['1','4:8','9'], |
|
135 | The set of slices is given as a list of strings (like ['1','4:8','9'], | |
136 | since this function is for use by magic functions which get their |
|
136 | since this function is for use by magic functions which get their | |
137 | arguments as strings. |
|
137 | arguments as strings. | |
138 |
|
138 | |||
139 | Note that slices can be called with two notations: |
|
139 | Note that slices can be called with two notations: | |
140 |
|
140 | |||
141 | N:M -> standard python form, means including items N...(M-1). |
|
141 | N:M -> standard python form, means including items N...(M-1). | |
142 |
|
142 | |||
143 | N-M -> include items N..M (closed endpoint).""" |
|
143 | N-M -> include items N..M (closed endpoint).""" | |
144 |
|
144 | |||
145 | cmds = [] |
|
145 | cmds = [] | |
146 | for chunk in slices: |
|
146 | for chunk in slices: | |
147 | if ':' in chunk: |
|
147 | if ':' in chunk: | |
148 | ini,fin = map(int,chunk.split(':')) |
|
148 | ini,fin = map(int,chunk.split(':')) | |
149 | elif '-' in chunk: |
|
149 | elif '-' in chunk: | |
150 | ini,fin = map(int,chunk.split('-')) |
|
150 | ini,fin = map(int,chunk.split('-')) | |
151 | fin += 1 |
|
151 | fin += 1 | |
152 | else: |
|
152 | else: | |
153 | ini = int(chunk) |
|
153 | ini = int(chunk) | |
154 | fin = ini+1 |
|
154 | fin = ini+1 | |
155 | cmds.append(self.shell.input_hist[ini:fin]) |
|
155 | cmds.append(self.shell.input_hist[ini:fin]) | |
156 | return cmds |
|
156 | return cmds | |
157 |
|
157 | |||
158 | def _ofind(self,oname): |
|
158 | def _ofind(self,oname): | |
159 | """Find an object in the available namespaces. |
|
159 | """Find an object in the available namespaces. | |
160 |
|
160 | |||
161 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic |
|
161 | self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic | |
162 |
|
162 | |||
163 | Has special code to detect magic functions. |
|
163 | Has special code to detect magic functions. | |
164 | """ |
|
164 | """ | |
165 |
|
165 | |||
166 | oname = oname.strip() |
|
166 | oname = oname.strip() | |
167 |
|
167 | |||
168 | # Namespaces to search in: |
|
168 | # Namespaces to search in: | |
169 | user_ns = self.shell.user_ns |
|
169 | user_ns = self.shell.user_ns | |
170 | internal_ns = self.shell.internal_ns |
|
170 | internal_ns = self.shell.internal_ns | |
171 | builtin_ns = __builtin__.__dict__ |
|
171 | builtin_ns = __builtin__.__dict__ | |
172 | alias_ns = self.shell.alias_table |
|
172 | alias_ns = self.shell.alias_table | |
173 |
|
173 | |||
174 | # Put them in a list. The order is important so that we find things in |
|
174 | # Put them in a list. The order is important so that we find things in | |
175 | # the same order that Python finds them. |
|
175 | # the same order that Python finds them. | |
176 | namespaces = [ ('Interactive',user_ns), |
|
176 | namespaces = [ ('Interactive',user_ns), | |
177 | ('IPython internal',internal_ns), |
|
177 | ('IPython internal',internal_ns), | |
178 | ('Python builtin',builtin_ns), |
|
178 | ('Python builtin',builtin_ns), | |
179 | ('Alias',alias_ns), |
|
179 | ('Alias',alias_ns), | |
180 | ] |
|
180 | ] | |
181 |
|
181 | |||
182 | # initialize results to 'null' |
|
182 | # initialize results to 'null' | |
183 | found = 0; obj = None; ospace = None; ds = None; |
|
183 | found = 0; obj = None; ospace = None; ds = None; | |
184 | ismagic = 0; isalias = 0 |
|
184 | ismagic = 0; isalias = 0 | |
185 |
|
185 | |||
186 | # Look for the given name by splitting it in parts. If the head is |
|
186 | # Look for the given name by splitting it in parts. If the head is | |
187 | # found, then we look for all the remaining parts as members, and only |
|
187 | # found, then we look for all the remaining parts as members, and only | |
188 | # declare success if we can find them all. |
|
188 | # declare success if we can find them all. | |
189 | oname_parts = oname.split('.') |
|
189 | oname_parts = oname.split('.') | |
190 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] |
|
190 | oname_head, oname_rest = oname_parts[0],oname_parts[1:] | |
191 | for nsname,ns in namespaces: |
|
191 | for nsname,ns in namespaces: | |
192 | try: |
|
192 | try: | |
193 | obj = ns[oname_head] |
|
193 | obj = ns[oname_head] | |
194 | except KeyError: |
|
194 | except KeyError: | |
195 | continue |
|
195 | continue | |
196 | else: |
|
196 | else: | |
197 | for part in oname_rest: |
|
197 | for part in oname_rest: | |
198 | try: |
|
198 | try: | |
199 | obj = getattr(obj,part) |
|
199 | obj = getattr(obj,part) | |
200 | except: |
|
200 | except: | |
201 | # Blanket except b/c some badly implemented objects |
|
201 | # Blanket except b/c some badly implemented objects | |
202 | # allow __getattr__ to raise exceptions other than |
|
202 | # allow __getattr__ to raise exceptions other than | |
203 | # AttributeError, which then crashes IPython. |
|
203 | # AttributeError, which then crashes IPython. | |
204 | break |
|
204 | break | |
205 | else: |
|
205 | else: | |
206 | # If we finish the for loop (no break), we got all members |
|
206 | # If we finish the for loop (no break), we got all members | |
207 | found = 1 |
|
207 | found = 1 | |
208 | ospace = nsname |
|
208 | ospace = nsname | |
209 | if ns == alias_ns: |
|
209 | if ns == alias_ns: | |
210 | isalias = 1 |
|
210 | isalias = 1 | |
211 | break # namespace loop |
|
211 | break # namespace loop | |
212 |
|
212 | |||
213 | # Try to see if it's magic |
|
213 | # Try to see if it's magic | |
214 | if not found: |
|
214 | if not found: | |
215 | if oname.startswith(self.shell.ESC_MAGIC): |
|
215 | if oname.startswith(self.shell.ESC_MAGIC): | |
216 | oname = oname[1:] |
|
216 | oname = oname[1:] | |
217 | obj = getattr(self,'magic_'+oname,None) |
|
217 | obj = getattr(self,'magic_'+oname,None) | |
218 | if obj is not None: |
|
218 | if obj is not None: | |
219 | found = 1 |
|
219 | found = 1 | |
220 | ospace = 'IPython internal' |
|
220 | ospace = 'IPython internal' | |
221 | ismagic = 1 |
|
221 | ismagic = 1 | |
222 |
|
222 | |||
223 | # Last try: special-case some literals like '', [], {}, etc: |
|
223 | # Last try: special-case some literals like '', [], {}, etc: | |
224 | if not found and oname_head in ["''",'""','[]','{}','()']: |
|
224 | if not found and oname_head in ["''",'""','[]','{}','()']: | |
225 | obj = eval(oname_head) |
|
225 | obj = eval(oname_head) | |
226 | found = 1 |
|
226 | found = 1 | |
227 | ospace = 'Interactive' |
|
227 | ospace = 'Interactive' | |
228 |
|
228 | |||
229 | return {'found':found, 'obj':obj, 'namespace':ospace, |
|
229 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
230 | 'ismagic':ismagic, 'isalias':isalias} |
|
230 | 'ismagic':ismagic, 'isalias':isalias} | |
231 |
|
231 | |||
232 | def arg_err(self,func): |
|
232 | def arg_err(self,func): | |
233 | """Print docstring if incorrect arguments were passed""" |
|
233 | """Print docstring if incorrect arguments were passed""" | |
234 | print 'Error in arguments:' |
|
234 | print 'Error in arguments:' | |
235 | print OInspect.getdoc(func) |
|
235 | print OInspect.getdoc(func) | |
236 |
|
236 | |||
237 | def format_latex(self,strng): |
|
237 | def format_latex(self,strng): | |
238 | """Format a string for latex inclusion.""" |
|
238 | """Format a string for latex inclusion.""" | |
239 |
|
239 | |||
240 | # Characters that need to be escaped for latex: |
|
240 | # Characters that need to be escaped for latex: | |
241 | escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE) |
|
241 | escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE) | |
242 | # Magic command names as headers: |
|
242 | # Magic command names as headers: | |
243 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, |
|
243 | cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC, | |
244 | re.MULTILINE) |
|
244 | re.MULTILINE) | |
245 | # Magic commands |
|
245 | # Magic commands | |
246 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, |
|
246 | cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC, | |
247 | re.MULTILINE) |
|
247 | re.MULTILINE) | |
248 | # Paragraph continue |
|
248 | # Paragraph continue | |
249 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
249 | par_re = re.compile(r'\\$',re.MULTILINE) | |
250 |
|
250 | |||
251 | # The "\n" symbol |
|
251 | # The "\n" symbol | |
252 | newline_re = re.compile(r'\\n') |
|
252 | newline_re = re.compile(r'\\n') | |
253 |
|
253 | |||
254 | # Now build the string for output: |
|
254 | # Now build the string for output: | |
255 | #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng) |
|
255 | #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng) | |
256 | strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:', |
|
256 | strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:', | |
257 | strng) |
|
257 | strng) | |
258 | strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng) |
|
258 | strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng) | |
259 | strng = par_re.sub(r'\\\\',strng) |
|
259 | strng = par_re.sub(r'\\\\',strng) | |
260 | strng = escape_re.sub(r'\\\1',strng) |
|
260 | strng = escape_re.sub(r'\\\1',strng) | |
261 | strng = newline_re.sub(r'\\textbackslash{}n',strng) |
|
261 | strng = newline_re.sub(r'\\textbackslash{}n',strng) | |
262 | return strng |
|
262 | return strng | |
263 |
|
263 | |||
264 | def format_screen(self,strng): |
|
264 | def format_screen(self,strng): | |
265 | """Format a string for screen printing. |
|
265 | """Format a string for screen printing. | |
266 |
|
266 | |||
267 | This removes some latex-type format codes.""" |
|
267 | This removes some latex-type format codes.""" | |
268 | # Paragraph continue |
|
268 | # Paragraph continue | |
269 | par_re = re.compile(r'\\$',re.MULTILINE) |
|
269 | par_re = re.compile(r'\\$',re.MULTILINE) | |
270 | strng = par_re.sub('',strng) |
|
270 | strng = par_re.sub('',strng) | |
271 | return strng |
|
271 | return strng | |
272 |
|
272 | |||
273 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): |
|
273 | def parse_options(self,arg_str,opt_str,*long_opts,**kw): | |
274 | """Parse options passed to an argument string. |
|
274 | """Parse options passed to an argument string. | |
275 |
|
275 | |||
276 | The interface is similar to that of getopt(), but it returns back a |
|
276 | The interface is similar to that of getopt(), but it returns back a | |
277 | Struct with the options as keys and the stripped argument string still |
|
277 | Struct with the options as keys and the stripped argument string still | |
278 | as a string. |
|
278 | as a string. | |
279 |
|
279 | |||
280 | arg_str is quoted as a true sys.argv vector by using shlex.split. |
|
280 | arg_str is quoted as a true sys.argv vector by using shlex.split. | |
281 | This allows us to easily expand variables, glob files, quote |
|
281 | This allows us to easily expand variables, glob files, quote | |
282 | arguments, etc. |
|
282 | arguments, etc. | |
283 |
|
283 | |||
284 | Options: |
|
284 | Options: | |
285 | -mode: default 'string'. If given as 'list', the argument string is |
|
285 | -mode: default 'string'. If given as 'list', the argument string is | |
286 | returned as a list (split on whitespace) instead of a string. |
|
286 | returned as a list (split on whitespace) instead of a string. | |
287 |
|
287 | |||
288 | -list_all: put all option values in lists. Normally only options |
|
288 | -list_all: put all option values in lists. Normally only options | |
289 | appearing more than once are put in a list.""" |
|
289 | appearing more than once are put in a list.""" | |
290 |
|
290 | |||
291 | # inject default options at the beginning of the input line |
|
291 | # inject default options at the beginning of the input line | |
292 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') |
|
292 | caller = sys._getframe(1).f_code.co_name.replace('magic_','') | |
293 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) |
|
293 | arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str) | |
294 |
|
294 | |||
295 | mode = kw.get('mode','string') |
|
295 | mode = kw.get('mode','string') | |
296 | if mode not in ['string','list']: |
|
296 | if mode not in ['string','list']: | |
297 | raise ValueError,'incorrect mode given: %s' % mode |
|
297 | raise ValueError,'incorrect mode given: %s' % mode | |
298 | # Get options |
|
298 | # Get options | |
299 | list_all = kw.get('list_all',0) |
|
299 | list_all = kw.get('list_all',0) | |
300 |
|
300 | |||
301 | # Check if we have more than one argument to warrant extra processing: |
|
301 | # Check if we have more than one argument to warrant extra processing: | |
302 | odict = {} # Dictionary with options |
|
302 | odict = {} # Dictionary with options | |
303 | args = arg_str.split() |
|
303 | args = arg_str.split() | |
304 | if len(args) >= 1: |
|
304 | if len(args) >= 1: | |
305 | # If the list of inputs only has 0 or 1 thing in it, there's no |
|
305 | # If the list of inputs only has 0 or 1 thing in it, there's no | |
306 | # need to look for options |
|
306 | # need to look for options | |
307 | argv = shlex_split(arg_str) |
|
307 | argv = shlex_split(arg_str) | |
308 | # Do regular option processing |
|
308 | # Do regular option processing | |
309 | try: |
|
309 | try: | |
310 | opts,args = getopt(argv,opt_str,*long_opts) |
|
310 | opts,args = getopt(argv,opt_str,*long_opts) | |
311 | except GetoptError,e: |
|
311 | except GetoptError,e: | |
312 | raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str, |
|
312 | raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str, | |
313 | " ".join(long_opts))) |
|
313 | " ".join(long_opts))) | |
314 | for o,a in opts: |
|
314 | for o,a in opts: | |
315 | if o.startswith('--'): |
|
315 | if o.startswith('--'): | |
316 | o = o[2:] |
|
316 | o = o[2:] | |
317 | else: |
|
317 | else: | |
318 | o = o[1:] |
|
318 | o = o[1:] | |
319 | try: |
|
319 | try: | |
320 | odict[o].append(a) |
|
320 | odict[o].append(a) | |
321 | except AttributeError: |
|
321 | except AttributeError: | |
322 | odict[o] = [odict[o],a] |
|
322 | odict[o] = [odict[o],a] | |
323 | except KeyError: |
|
323 | except KeyError: | |
324 | if list_all: |
|
324 | if list_all: | |
325 | odict[o] = [a] |
|
325 | odict[o] = [a] | |
326 | else: |
|
326 | else: | |
327 | odict[o] = a |
|
327 | odict[o] = a | |
328 |
|
328 | |||
329 | # Prepare opts,args for return |
|
329 | # Prepare opts,args for return | |
330 | opts = Struct(odict) |
|
330 | opts = Struct(odict) | |
331 | if mode == 'string': |
|
331 | if mode == 'string': | |
332 | args = ' '.join(args) |
|
332 | args = ' '.join(args) | |
333 |
|
333 | |||
334 | return opts,args |
|
334 | return opts,args | |
335 |
|
335 | |||
336 | #...................................................................... |
|
336 | #...................................................................... | |
337 | # And now the actual magic functions |
|
337 | # And now the actual magic functions | |
338 |
|
338 | |||
339 | # Functions for IPython shell work (vars,funcs, config, etc) |
|
339 | # Functions for IPython shell work (vars,funcs, config, etc) | |
340 | def magic_lsmagic(self, parameter_s = ''): |
|
340 | def magic_lsmagic(self, parameter_s = ''): | |
341 | """List currently available magic functions.""" |
|
341 | """List currently available magic functions.""" | |
342 | mesc = self.shell.ESC_MAGIC |
|
342 | mesc = self.shell.ESC_MAGIC | |
343 | print 'Available magic functions:\n'+mesc+\ |
|
343 | print 'Available magic functions:\n'+mesc+\ | |
344 | (' '+mesc).join(self.lsmagic()) |
|
344 | (' '+mesc).join(self.lsmagic()) | |
345 | print '\n' + Magic.auto_status[self.shell.rc.automagic] |
|
345 | print '\n' + Magic.auto_status[self.shell.rc.automagic] | |
346 | return None |
|
346 | return None | |
347 |
|
347 | |||
348 | def magic_magic(self, parameter_s = ''): |
|
348 | def magic_magic(self, parameter_s = ''): | |
349 | """Print information about the magic function system.""" |
|
349 | """Print information about the magic function system.""" | |
350 |
|
350 | |||
351 | mode = '' |
|
351 | mode = '' | |
352 | try: |
|
352 | try: | |
353 | if parameter_s.split()[0] == '-latex': |
|
353 | if parameter_s.split()[0] == '-latex': | |
354 | mode = 'latex' |
|
354 | mode = 'latex' | |
355 | except: |
|
355 | except: | |
356 | pass |
|
356 | pass | |
357 |
|
357 | |||
358 | magic_docs = [] |
|
358 | magic_docs = [] | |
359 | for fname in self.lsmagic(): |
|
359 | for fname in self.lsmagic(): | |
360 | mname = 'magic_' + fname |
|
360 | mname = 'magic_' + fname | |
361 | for space in (Magic,self,self.__class__): |
|
361 | for space in (Magic,self,self.__class__): | |
362 | try: |
|
362 | try: | |
363 | fn = space.__dict__[mname] |
|
363 | fn = space.__dict__[mname] | |
364 | except KeyError: |
|
364 | except KeyError: | |
365 | pass |
|
365 | pass | |
366 | else: |
|
366 | else: | |
367 | break |
|
367 | break | |
368 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, |
|
368 | magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, | |
369 | fname,fn.__doc__)) |
|
369 | fname,fn.__doc__)) | |
370 | magic_docs = ''.join(magic_docs) |
|
370 | magic_docs = ''.join(magic_docs) | |
371 |
|
371 | |||
372 | if mode == 'latex': |
|
372 | if mode == 'latex': | |
373 | print self.format_latex(magic_docs) |
|
373 | print self.format_latex(magic_docs) | |
374 | return |
|
374 | return | |
375 | else: |
|
375 | else: | |
376 | magic_docs = self.format_screen(magic_docs) |
|
376 | magic_docs = self.format_screen(magic_docs) | |
377 |
|
377 | |||
378 | outmsg = """ |
|
378 | outmsg = """ | |
379 | IPython's 'magic' functions |
|
379 | IPython's 'magic' functions | |
380 | =========================== |
|
380 | =========================== | |
381 |
|
381 | |||
382 | The magic function system provides a series of functions which allow you to |
|
382 | The magic function system provides a series of functions which allow you to | |
383 | control the behavior of IPython itself, plus a lot of system-type |
|
383 | control the behavior of IPython itself, plus a lot of system-type | |
384 | features. All these functions are prefixed with a % character, but parameters |
|
384 | features. All these functions are prefixed with a % character, but parameters | |
385 | are given without parentheses or quotes. |
|
385 | are given without parentheses or quotes. | |
386 |
|
386 | |||
387 | NOTE: If you have 'automagic' enabled (via the command line option or with the |
|
387 | NOTE: If you have 'automagic' enabled (via the command line option or with the | |
388 | %automagic function), you don't need to type in the % explicitly. By default, |
|
388 | %automagic function), you don't need to type in the % explicitly. By default, | |
389 | IPython ships with automagic on, so you should only rarely need the % escape. |
|
389 | IPython ships with automagic on, so you should only rarely need the % escape. | |
390 |
|
390 | |||
391 | Example: typing '%cd mydir' (without the quotes) changes you working directory |
|
391 | Example: typing '%cd mydir' (without the quotes) changes you working directory | |
392 | to 'mydir', if it exists. |
|
392 | to 'mydir', if it exists. | |
393 |
|
393 | |||
394 | You can define your own magic functions to extend the system. See the supplied |
|
394 | You can define your own magic functions to extend the system. See the supplied | |
395 | ipythonrc and example-magic.py files for details (in your ipython |
|
395 | ipythonrc and example-magic.py files for details (in your ipython | |
396 | configuration directory, typically $HOME/.ipython/). |
|
396 | configuration directory, typically $HOME/.ipython/). | |
397 |
|
397 | |||
398 | You can also define your own aliased names for magic functions. In your |
|
398 | You can also define your own aliased names for magic functions. In your | |
399 | ipythonrc file, placing a line like: |
|
399 | ipythonrc file, placing a line like: | |
400 |
|
400 | |||
401 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile |
|
401 | execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile | |
402 |
|
402 | |||
403 | will define %pf as a new name for %profile. |
|
403 | will define %pf as a new name for %profile. | |
404 |
|
404 | |||
405 | You can also call magics in code using the ipmagic() function, which IPython |
|
405 | You can also call magics in code using the ipmagic() function, which IPython | |
406 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. |
|
406 | automatically adds to the builtin namespace. Type 'ipmagic?' for details. | |
407 |
|
407 | |||
408 | For a list of the available magic functions, use %lsmagic. For a description |
|
408 | For a list of the available magic functions, use %lsmagic. For a description | |
409 | of any of them, type %magic_name?, e.g. '%cd?'. |
|
409 | of any of them, type %magic_name?, e.g. '%cd?'. | |
410 |
|
410 | |||
411 | Currently the magic system has the following functions:\n""" |
|
411 | Currently the magic system has the following functions:\n""" | |
412 |
|
412 | |||
413 | mesc = self.shell.ESC_MAGIC |
|
413 | mesc = self.shell.ESC_MAGIC | |
414 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" |
|
414 | outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):" | |
415 | "\n\n%s%s\n\n%s" % (outmsg, |
|
415 | "\n\n%s%s\n\n%s" % (outmsg, | |
416 | magic_docs,mesc,mesc, |
|
416 | magic_docs,mesc,mesc, | |
417 | (' '+mesc).join(self.lsmagic()), |
|
417 | (' '+mesc).join(self.lsmagic()), | |
418 | Magic.auto_status[self.shell.rc.automagic] ) ) |
|
418 | Magic.auto_status[self.shell.rc.automagic] ) ) | |
419 |
|
419 | |||
420 | page(outmsg,screen_lines=self.shell.rc.screen_length) |
|
420 | page(outmsg,screen_lines=self.shell.rc.screen_length) | |
421 |
|
421 | |||
422 | def magic_automagic(self, parameter_s = ''): |
|
422 | def magic_automagic(self, parameter_s = ''): | |
423 | """Make magic functions callable without having to type the initial %. |
|
423 | """Make magic functions callable without having to type the initial %. | |
424 |
|
424 | |||
425 | Toggles on/off (when off, you must call it as %automagic, of |
|
425 | Toggles on/off (when off, you must call it as %automagic, of | |
426 | course). Note that magic functions have lowest priority, so if there's |
|
426 | course). Note that magic functions have lowest priority, so if there's | |
427 | a variable whose name collides with that of a magic fn, automagic |
|
427 | a variable whose name collides with that of a magic fn, automagic | |
428 | won't work for that function (you get the variable instead). However, |
|
428 | won't work for that function (you get the variable instead). However, | |
429 | if you delete the variable (del var), the previously shadowed magic |
|
429 | if you delete the variable (del var), the previously shadowed magic | |
430 | function becomes visible to automagic again.""" |
|
430 | function becomes visible to automagic again.""" | |
431 |
|
431 | |||
432 | rc = self.shell.rc |
|
432 | rc = self.shell.rc | |
433 | rc.automagic = not rc.automagic |
|
433 | rc.automagic = not rc.automagic | |
434 | print '\n' + Magic.auto_status[rc.automagic] |
|
434 | print '\n' + Magic.auto_status[rc.automagic] | |
435 |
|
435 | |||
436 | def magic_autocall(self, parameter_s = ''): |
|
436 | def magic_autocall(self, parameter_s = ''): | |
437 | """Make functions callable without having to type parentheses. |
|
437 | """Make functions callable without having to type parentheses. | |
438 |
|
438 | |||
439 | Usage: |
|
439 | Usage: | |
440 |
|
440 | |||
441 | %autocall [mode] |
|
441 | %autocall [mode] | |
442 |
|
442 | |||
443 | The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the |
|
443 | The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the | |
444 | value is toggled on and off (remembering the previous state).""" |
|
444 | value is toggled on and off (remembering the previous state).""" | |
445 |
|
445 | |||
446 | rc = self.shell.rc |
|
446 | rc = self.shell.rc | |
447 |
|
447 | |||
448 | if parameter_s: |
|
448 | if parameter_s: | |
449 | arg = int(parameter_s) |
|
449 | arg = int(parameter_s) | |
450 | else: |
|
450 | else: | |
451 | arg = 'toggle' |
|
451 | arg = 'toggle' | |
452 |
|
452 | |||
453 | if not arg in (0,1,2,'toggle'): |
|
453 | if not arg in (0,1,2,'toggle'): | |
454 | error('Valid modes: (0->Off, 1->Smart, 2->Full') |
|
454 | error('Valid modes: (0->Off, 1->Smart, 2->Full') | |
455 | return |
|
455 | return | |
456 |
|
456 | |||
457 | if arg in (0,1,2): |
|
457 | if arg in (0,1,2): | |
458 | rc.autocall = arg |
|
458 | rc.autocall = arg | |
459 | else: # toggle |
|
459 | else: # toggle | |
460 | if rc.autocall: |
|
460 | if rc.autocall: | |
461 | self._magic_state.autocall_save = rc.autocall |
|
461 | self._magic_state.autocall_save = rc.autocall | |
462 | rc.autocall = 0 |
|
462 | rc.autocall = 0 | |
463 | else: |
|
463 | else: | |
464 | try: |
|
464 | try: | |
465 | rc.autocall = self._magic_state.autocall_save |
|
465 | rc.autocall = self._magic_state.autocall_save | |
466 | except AttributeError: |
|
466 | except AttributeError: | |
467 | rc.autocall = self._magic_state.autocall_save = 1 |
|
467 | rc.autocall = self._magic_state.autocall_save = 1 | |
468 |
|
468 | |||
469 | print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall] |
|
469 | print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall] | |
470 |
|
470 | |||
471 | def magic_autoindent(self, parameter_s = ''): |
|
471 | def magic_autoindent(self, parameter_s = ''): | |
472 | """Toggle autoindent on/off (if available).""" |
|
472 | """Toggle autoindent on/off (if available).""" | |
473 |
|
473 | |||
474 | self.shell.set_autoindent() |
|
474 | self.shell.set_autoindent() | |
475 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] |
|
475 | print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent] | |
476 |
|
476 | |||
477 | def magic_system_verbose(self, parameter_s = ''): |
|
477 | def magic_system_verbose(self, parameter_s = ''): | |
478 | """Toggle verbose printing of system calls on/off.""" |
|
478 | """Toggle verbose printing of system calls on/off.""" | |
479 |
|
479 | |||
480 | self.shell.rc_set_toggle('system_verbose') |
|
480 | self.shell.rc_set_toggle('system_verbose') | |
481 | print "System verbose printing is:",\ |
|
481 | print "System verbose printing is:",\ | |
482 | ['OFF','ON'][self.shell.rc.system_verbose] |
|
482 | ['OFF','ON'][self.shell.rc.system_verbose] | |
483 |
|
483 | |||
484 | def magic_history(self, parameter_s = ''): |
|
484 | def magic_history(self, parameter_s = ''): | |
485 | """Print input history (_i<n> variables), with most recent last. |
|
485 | """Print input history (_i<n> variables), with most recent last. | |
486 |
|
486 | |||
487 | %history -> print at most 40 inputs (some may be multi-line)\\ |
|
487 | %history -> print at most 40 inputs (some may be multi-line)\\ | |
488 | %history n -> print at most n inputs\\ |
|
488 | %history n -> print at most n inputs\\ | |
489 | %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ |
|
489 | %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ | |
490 |
|
490 | |||
491 | Each input's number <n> is shown, and is accessible as the |
|
491 | Each input's number <n> is shown, and is accessible as the | |
492 | automatically generated variable _i<n>. Multi-line statements are |
|
492 | automatically generated variable _i<n>. Multi-line statements are | |
493 | printed starting at a new line for easy copy/paste. |
|
493 | printed starting at a new line for easy copy/paste. | |
494 |
|
494 | |||
495 |
|
495 | |||
496 | Options: |
|
496 | Options: | |
497 |
|
497 | |||
498 | -n: do NOT print line numbers. This is useful if you want to get a |
|
498 | -n: do NOT print line numbers. This is useful if you want to get a | |
499 | printout of many lines which can be directly pasted into a text |
|
499 | printout of many lines which can be directly pasted into a text | |
500 | editor. |
|
500 | editor. | |
501 |
|
501 | |||
502 | This feature is only available if numbered prompts are in use. |
|
502 | This feature is only available if numbered prompts are in use. | |
503 |
|
503 | |||
504 | -r: print the 'raw' history. IPython filters your input and |
|
504 | -r: print the 'raw' history. IPython filters your input and | |
505 | converts it all into valid Python source before executing it (things |
|
505 | converts it all into valid Python source before executing it (things | |
506 | like magics or aliases are turned into function calls, for |
|
506 | like magics or aliases are turned into function calls, for | |
507 | example). With this option, you'll see the unfiltered history |
|
507 | example). With this option, you'll see the unfiltered history | |
508 | instead of the filtered version: '%cd /' will be seen as '%cd /' |
|
508 | instead of the filtered version: '%cd /' will be seen as '%cd /' | |
509 | instead of '_ip.magic("%cd /")'. |
|
509 | instead of '_ip.magic("%cd /")'. | |
510 | """ |
|
510 | """ | |
511 |
|
511 | |||
512 | shell = self.shell |
|
512 | shell = self.shell | |
513 | if not shell.outputcache.do_full_cache: |
|
513 | if not shell.outputcache.do_full_cache: | |
514 | print 'This feature is only available if numbered prompts are in use.' |
|
514 | print 'This feature is only available if numbered prompts are in use.' | |
515 | return |
|
515 | return | |
516 | opts,args = self.parse_options(parameter_s,'nr',mode='list') |
|
516 | opts,args = self.parse_options(parameter_s,'nr',mode='list') | |
517 |
|
517 | |||
518 | if opts.has_key('r'): |
|
518 | if opts.has_key('r'): | |
519 | input_hist = shell.input_hist_raw |
|
519 | input_hist = shell.input_hist_raw | |
520 | else: |
|
520 | else: | |
521 | input_hist = shell.input_hist |
|
521 | input_hist = shell.input_hist | |
522 |
|
522 | |||
523 | default_length = 40 |
|
523 | default_length = 40 | |
524 | if len(args) == 0: |
|
524 | if len(args) == 0: | |
525 | final = len(input_hist) |
|
525 | final = len(input_hist) | |
526 | init = max(1,final-default_length) |
|
526 | init = max(1,final-default_length) | |
527 | elif len(args) == 1: |
|
527 | elif len(args) == 1: | |
528 | final = len(input_hist) |
|
528 | final = len(input_hist) | |
529 | init = max(1,final-int(args[0])) |
|
529 | init = max(1,final-int(args[0])) | |
530 | elif len(args) == 2: |
|
530 | elif len(args) == 2: | |
531 | init,final = map(int,args) |
|
531 | init,final = map(int,args) | |
532 | else: |
|
532 | else: | |
533 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') |
|
533 | warn('%hist takes 0, 1 or 2 arguments separated by spaces.') | |
534 | print self.magic_hist.__doc__ |
|
534 | print self.magic_hist.__doc__ | |
535 | return |
|
535 | return | |
536 | width = len(str(final)) |
|
536 | width = len(str(final)) | |
537 | line_sep = ['','\n'] |
|
537 | line_sep = ['','\n'] | |
538 | print_nums = not opts.has_key('n') |
|
538 | print_nums = not opts.has_key('n') | |
539 | for in_num in range(init,final): |
|
539 | for in_num in range(init,final): | |
540 | inline = input_hist[in_num] |
|
540 | inline = input_hist[in_num] | |
541 | multiline = int(inline.count('\n') > 1) |
|
541 | multiline = int(inline.count('\n') > 1) | |
542 | if print_nums: |
|
542 | if print_nums: | |
543 | print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), |
|
543 | print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), | |
544 | print inline, |
|
544 | print inline, | |
545 |
|
545 | |||
546 | def magic_hist(self, parameter_s=''): |
|
546 | def magic_hist(self, parameter_s=''): | |
547 | """Alternate name for %history.""" |
|
547 | """Alternate name for %history.""" | |
548 | return self.magic_history(parameter_s) |
|
548 | return self.magic_history(parameter_s) | |
549 |
|
549 | |||
550 | def magic_p(self, parameter_s=''): |
|
550 | def magic_p(self, parameter_s=''): | |
551 | """Just a short alias for Python's 'print'.""" |
|
551 | """Just a short alias for Python's 'print'.""" | |
552 | exec 'print ' + parameter_s in self.shell.user_ns |
|
552 | exec 'print ' + parameter_s in self.shell.user_ns | |
553 |
|
553 | |||
554 | def magic_r(self, parameter_s=''): |
|
554 | def magic_r(self, parameter_s=''): | |
555 | """Repeat previous input. |
|
555 | """Repeat previous input. | |
556 |
|
556 | |||
557 | If given an argument, repeats the previous command which starts with |
|
557 | If given an argument, repeats the previous command which starts with | |
558 | the same string, otherwise it just repeats the previous input. |
|
558 | the same string, otherwise it just repeats the previous input. | |
559 |
|
559 | |||
560 | Shell escaped commands (with ! as first character) are not recognized |
|
560 | Shell escaped commands (with ! as first character) are not recognized | |
561 | by this system, only pure python code and magic commands. |
|
561 | by this system, only pure python code and magic commands. | |
562 | """ |
|
562 | """ | |
563 |
|
563 | |||
564 | start = parameter_s.strip() |
|
564 | start = parameter_s.strip() | |
565 | esc_magic = self.shell.ESC_MAGIC |
|
565 | esc_magic = self.shell.ESC_MAGIC | |
566 | # Identify magic commands even if automagic is on (which means |
|
566 | # Identify magic commands even if automagic is on (which means | |
567 | # the in-memory version is different from that typed by the user). |
|
567 | # the in-memory version is different from that typed by the user). | |
568 | if self.shell.rc.automagic: |
|
568 | if self.shell.rc.automagic: | |
569 | start_magic = esc_magic+start |
|
569 | start_magic = esc_magic+start | |
570 | else: |
|
570 | else: | |
571 | start_magic = start |
|
571 | start_magic = start | |
572 | # Look through the input history in reverse |
|
572 | # Look through the input history in reverse | |
573 | for n in range(len(self.shell.input_hist)-2,0,-1): |
|
573 | for n in range(len(self.shell.input_hist)-2,0,-1): | |
574 | input = self.shell.input_hist[n] |
|
574 | input = self.shell.input_hist[n] | |
575 | # skip plain 'r' lines so we don't recurse to infinity |
|
575 | # skip plain 'r' lines so we don't recurse to infinity | |
576 | if input != '_ip.magic("r")\n' and \ |
|
576 | if input != '_ip.magic("r")\n' and \ | |
577 | (input.startswith(start) or input.startswith(start_magic)): |
|
577 | (input.startswith(start) or input.startswith(start_magic)): | |
578 | #print 'match',`input` # dbg |
|
578 | #print 'match',`input` # dbg | |
579 | print 'Executing:',input, |
|
579 | print 'Executing:',input, | |
580 | self.shell.runlines(input) |
|
580 | self.shell.runlines(input) | |
581 | return |
|
581 | return | |
582 | print 'No previous input matching `%s` found.' % start |
|
582 | print 'No previous input matching `%s` found.' % start | |
583 |
|
583 | |||
584 | def magic_page(self, parameter_s=''): |
|
584 | def magic_page(self, parameter_s=''): | |
585 | """Pretty print the object and display it through a pager. |
|
585 | """Pretty print the object and display it through a pager. | |
586 |
|
586 | |||
587 | If no parameter is given, use _ (last output).""" |
|
587 | If no parameter is given, use _ (last output).""" | |
588 | # After a function contributed by Olivier Aubert, slightly modified. |
|
588 | # After a function contributed by Olivier Aubert, slightly modified. | |
589 |
|
589 | |||
590 | oname = parameter_s and parameter_s or '_' |
|
590 | oname = parameter_s and parameter_s or '_' | |
591 | info = self._ofind(oname) |
|
591 | info = self._ofind(oname) | |
592 | if info['found']: |
|
592 | if info['found']: | |
593 | page(pformat(info['obj'])) |
|
593 | page(pformat(info['obj'])) | |
594 | else: |
|
594 | else: | |
595 | print 'Object `%s` not found' % oname |
|
595 | print 'Object `%s` not found' % oname | |
596 |
|
596 | |||
597 | def magic_profile(self, parameter_s=''): |
|
597 | def magic_profile(self, parameter_s=''): | |
598 | """Print your currently active IPyhton profile.""" |
|
598 | """Print your currently active IPyhton profile.""" | |
599 | if self.shell.rc.profile: |
|
599 | if self.shell.rc.profile: | |
600 | printpl('Current IPython profile: $self.shell.rc.profile.') |
|
600 | printpl('Current IPython profile: $self.shell.rc.profile.') | |
601 | else: |
|
601 | else: | |
602 | print 'No profile active.' |
|
602 | print 'No profile active.' | |
603 |
|
603 | |||
604 | def _inspect(self,meth,oname,**kw): |
|
604 | def _inspect(self,meth,oname,**kw): | |
605 | """Generic interface to the inspector system. |
|
605 | """Generic interface to the inspector system. | |
606 |
|
606 | |||
607 | This function is meant to be called by pdef, pdoc & friends.""" |
|
607 | This function is meant to be called by pdef, pdoc & friends.""" | |
608 |
|
608 | |||
609 | oname = oname.strip() |
|
609 | oname = oname.strip() | |
610 | info = Struct(self._ofind(oname)) |
|
610 | info = Struct(self._ofind(oname)) | |
611 | if info.found: |
|
611 | if info.found: | |
612 | pmethod = getattr(self.shell.inspector,meth) |
|
612 | pmethod = getattr(self.shell.inspector,meth) | |
613 | formatter = info.ismagic and self.format_screen or None |
|
613 | formatter = info.ismagic and self.format_screen or None | |
614 | if meth == 'pdoc': |
|
614 | if meth == 'pdoc': | |
615 | pmethod(info.obj,oname,formatter) |
|
615 | pmethod(info.obj,oname,formatter) | |
616 | elif meth == 'pinfo': |
|
616 | elif meth == 'pinfo': | |
617 | pmethod(info.obj,oname,formatter,info,**kw) |
|
617 | pmethod(info.obj,oname,formatter,info,**kw) | |
618 | else: |
|
618 | else: | |
619 | pmethod(info.obj,oname) |
|
619 | pmethod(info.obj,oname) | |
620 | else: |
|
620 | else: | |
621 | print 'Object `%s` not found.' % oname |
|
621 | print 'Object `%s` not found.' % oname | |
622 | return 'not found' # so callers can take other action |
|
622 | return 'not found' # so callers can take other action | |
623 |
|
623 | |||
624 | def magic_pdef(self, parameter_s=''): |
|
624 | def magic_pdef(self, parameter_s=''): | |
625 | """Print the definition header for any callable object. |
|
625 | """Print the definition header for any callable object. | |
626 |
|
626 | |||
627 | If the object is a class, print the constructor information.""" |
|
627 | If the object is a class, print the constructor information.""" | |
628 | self._inspect('pdef',parameter_s) |
|
628 | self._inspect('pdef',parameter_s) | |
629 |
|
629 | |||
630 | def magic_pdoc(self, parameter_s=''): |
|
630 | def magic_pdoc(self, parameter_s=''): | |
631 | """Print the docstring for an object. |
|
631 | """Print the docstring for an object. | |
632 |
|
632 | |||
633 | If the given object is a class, it will print both the class and the |
|
633 | If the given object is a class, it will print both the class and the | |
634 | constructor docstrings.""" |
|
634 | constructor docstrings.""" | |
635 | self._inspect('pdoc',parameter_s) |
|
635 | self._inspect('pdoc',parameter_s) | |
636 |
|
636 | |||
637 | def magic_psource(self, parameter_s=''): |
|
637 | def magic_psource(self, parameter_s=''): | |
638 | """Print (or run through pager) the source code for an object.""" |
|
638 | """Print (or run through pager) the source code for an object.""" | |
639 | self._inspect('psource',parameter_s) |
|
639 | self._inspect('psource',parameter_s) | |
640 |
|
640 | |||
641 | def magic_pfile(self, parameter_s=''): |
|
641 | def magic_pfile(self, parameter_s=''): | |
642 | """Print (or run through pager) the file where an object is defined. |
|
642 | """Print (or run through pager) the file where an object is defined. | |
643 |
|
643 | |||
644 | The file opens at the line where the object definition begins. IPython |
|
644 | The file opens at the line where the object definition begins. IPython | |
645 | will honor the environment variable PAGER if set, and otherwise will |
|
645 | will honor the environment variable PAGER if set, and otherwise will | |
646 | do its best to print the file in a convenient form. |
|
646 | do its best to print the file in a convenient form. | |
647 |
|
647 | |||
648 | If the given argument is not an object currently defined, IPython will |
|
648 | If the given argument is not an object currently defined, IPython will | |
649 | try to interpret it as a filename (automatically adding a .py extension |
|
649 | try to interpret it as a filename (automatically adding a .py extension | |
650 | if needed). You can thus use %pfile as a syntax highlighting code |
|
650 | if needed). You can thus use %pfile as a syntax highlighting code | |
651 | viewer.""" |
|
651 | viewer.""" | |
652 |
|
652 | |||
653 | # first interpret argument as an object name |
|
653 | # first interpret argument as an object name | |
654 | out = self._inspect('pfile',parameter_s) |
|
654 | out = self._inspect('pfile',parameter_s) | |
655 | # if not, try the input as a filename |
|
655 | # if not, try the input as a filename | |
656 | if out == 'not found': |
|
656 | if out == 'not found': | |
657 | try: |
|
657 | try: | |
658 | filename = get_py_filename(parameter_s) |
|
658 | filename = get_py_filename(parameter_s) | |
659 | except IOError,msg: |
|
659 | except IOError,msg: | |
660 | print msg |
|
660 | print msg | |
661 | return |
|
661 | return | |
662 | page(self.shell.inspector.format(file(filename).read())) |
|
662 | page(self.shell.inspector.format(file(filename).read())) | |
663 |
|
663 | |||
664 | def magic_pinfo(self, parameter_s=''): |
|
664 | def magic_pinfo(self, parameter_s=''): | |
665 | """Provide detailed information about an object. |
|
665 | """Provide detailed information about an object. | |
666 |
|
666 | |||
667 | '%pinfo object' is just a synonym for object? or ?object.""" |
|
667 | '%pinfo object' is just a synonym for object? or ?object.""" | |
668 |
|
668 | |||
669 | #print 'pinfo par: <%s>' % parameter_s # dbg |
|
669 | #print 'pinfo par: <%s>' % parameter_s # dbg | |
670 |
|
670 | |||
671 | # detail_level: 0 -> obj? , 1 -> obj?? |
|
671 | # detail_level: 0 -> obj? , 1 -> obj?? | |
672 | detail_level = 0 |
|
672 | detail_level = 0 | |
673 | # We need to detect if we got called as 'pinfo pinfo foo', which can |
|
673 | # We need to detect if we got called as 'pinfo pinfo foo', which can | |
674 | # happen if the user types 'pinfo foo?' at the cmd line. |
|
674 | # happen if the user types 'pinfo foo?' at the cmd line. | |
675 | pinfo,qmark1,oname,qmark2 = \ |
|
675 | pinfo,qmark1,oname,qmark2 = \ | |
676 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() |
|
676 | re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups() | |
677 | if pinfo or qmark1 or qmark2: |
|
677 | if pinfo or qmark1 or qmark2: | |
678 | detail_level = 1 |
|
678 | detail_level = 1 | |
679 | if "*" in oname: |
|
679 | if "*" in oname: | |
680 | self.magic_psearch(oname) |
|
680 | self.magic_psearch(oname) | |
681 | else: |
|
681 | else: | |
682 | self._inspect('pinfo',oname,detail_level=detail_level) |
|
682 | self._inspect('pinfo',oname,detail_level=detail_level) | |
683 |
|
683 | |||
684 | def magic_psearch(self, parameter_s=''): |
|
684 | def magic_psearch(self, parameter_s=''): | |
685 | """Search for object in namespaces by wildcard. |
|
685 | """Search for object in namespaces by wildcard. | |
686 |
|
686 | |||
687 | %psearch [options] PATTERN [OBJECT TYPE] |
|
687 | %psearch [options] PATTERN [OBJECT TYPE] | |
688 |
|
688 | |||
689 | Note: ? can be used as a synonym for %psearch, at the beginning or at |
|
689 | Note: ? can be used as a synonym for %psearch, at the beginning or at | |
690 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the |
|
690 | the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the | |
691 | rest of the command line must be unchanged (options come first), so |
|
691 | rest of the command line must be unchanged (options come first), so | |
692 | for example the following forms are equivalent |
|
692 | for example the following forms are equivalent | |
693 |
|
693 | |||
694 | %psearch -i a* function |
|
694 | %psearch -i a* function | |
695 | -i a* function? |
|
695 | -i a* function? | |
696 | ?-i a* function |
|
696 | ?-i a* function | |
697 |
|
697 | |||
698 | Arguments: |
|
698 | Arguments: | |
699 |
|
699 | |||
700 | PATTERN |
|
700 | PATTERN | |
701 |
|
701 | |||
702 | where PATTERN is a string containing * as a wildcard similar to its |
|
702 | where PATTERN is a string containing * as a wildcard similar to its | |
703 | use in a shell. The pattern is matched in all namespaces on the |
|
703 | use in a shell. The pattern is matched in all namespaces on the | |
704 | search path. By default objects starting with a single _ are not |
|
704 | search path. By default objects starting with a single _ are not | |
705 | matched, many IPython generated objects have a single |
|
705 | matched, many IPython generated objects have a single | |
706 | underscore. The default is case insensitive matching. Matching is |
|
706 | underscore. The default is case insensitive matching. Matching is | |
707 | also done on the attributes of objects and not only on the objects |
|
707 | also done on the attributes of objects and not only on the objects | |
708 | in a module. |
|
708 | in a module. | |
709 |
|
709 | |||
710 | [OBJECT TYPE] |
|
710 | [OBJECT TYPE] | |
711 |
|
711 | |||
712 | Is the name of a python type from the types module. The name is |
|
712 | Is the name of a python type from the types module. The name is | |
713 | given in lowercase without the ending type, ex. StringType is |
|
713 | given in lowercase without the ending type, ex. StringType is | |
714 | written string. By adding a type here only objects matching the |
|
714 | written string. By adding a type here only objects matching the | |
715 | given type are matched. Using all here makes the pattern match all |
|
715 | given type are matched. Using all here makes the pattern match all | |
716 | types (this is the default). |
|
716 | types (this is the default). | |
717 |
|
717 | |||
718 | Options: |
|
718 | Options: | |
719 |
|
719 | |||
720 | -a: makes the pattern match even objects whose names start with a |
|
720 | -a: makes the pattern match even objects whose names start with a | |
721 | single underscore. These names are normally ommitted from the |
|
721 | single underscore. These names are normally ommitted from the | |
722 | search. |
|
722 | search. | |
723 |
|
723 | |||
724 | -i/-c: make the pattern case insensitive/sensitive. If neither of |
|
724 | -i/-c: make the pattern case insensitive/sensitive. If neither of | |
725 | these options is given, the default is read from your ipythonrc |
|
725 | these options is given, the default is read from your ipythonrc | |
726 | file. The option name which sets this value is |
|
726 | file. The option name which sets this value is | |
727 | 'wildcards_case_sensitive'. If this option is not specified in your |
|
727 | 'wildcards_case_sensitive'. If this option is not specified in your | |
728 | ipythonrc file, IPython's internal default is to do a case sensitive |
|
728 | ipythonrc file, IPython's internal default is to do a case sensitive | |
729 | search. |
|
729 | search. | |
730 |
|
730 | |||
731 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you |
|
731 | -e/-s NAMESPACE: exclude/search a given namespace. The pattern you | |
732 | specifiy can be searched in any of the following namespaces: |
|
732 | specifiy can be searched in any of the following namespaces: | |
733 | 'builtin', 'user', 'user_global','internal', 'alias', where |
|
733 | 'builtin', 'user', 'user_global','internal', 'alias', where | |
734 | 'builtin' and 'user' are the search defaults. Note that you should |
|
734 | 'builtin' and 'user' are the search defaults. Note that you should | |
735 | not use quotes when specifying namespaces. |
|
735 | not use quotes when specifying namespaces. | |
736 |
|
736 | |||
737 | 'Builtin' contains the python module builtin, 'user' contains all |
|
737 | 'Builtin' contains the python module builtin, 'user' contains all | |
738 | user data, 'alias' only contain the shell aliases and no python |
|
738 | user data, 'alias' only contain the shell aliases and no python | |
739 | objects, 'internal' contains objects used by IPython. The |
|
739 | objects, 'internal' contains objects used by IPython. The | |
740 | 'user_global' namespace is only used by embedded IPython instances, |
|
740 | 'user_global' namespace is only used by embedded IPython instances, | |
741 | and it contains module-level globals. You can add namespaces to the |
|
741 | and it contains module-level globals. You can add namespaces to the | |
742 | search with -s or exclude them with -e (these options can be given |
|
742 | search with -s or exclude them with -e (these options can be given | |
743 | more than once). |
|
743 | more than once). | |
744 |
|
744 | |||
745 | Examples: |
|
745 | Examples: | |
746 |
|
746 | |||
747 | %psearch a* -> objects beginning with an a |
|
747 | %psearch a* -> objects beginning with an a | |
748 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a |
|
748 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a | |
749 | %psearch a* function -> all functions beginning with an a |
|
749 | %psearch a* function -> all functions beginning with an a | |
750 | %psearch re.e* -> objects beginning with an e in module re |
|
750 | %psearch re.e* -> objects beginning with an e in module re | |
751 | %psearch r*.e* -> objects that start with e in modules starting in r |
|
751 | %psearch r*.e* -> objects that start with e in modules starting in r | |
752 | %psearch r*.* string -> all strings in modules beginning with r |
|
752 | %psearch r*.* string -> all strings in modules beginning with r | |
753 |
|
753 | |||
754 | Case sensitve search: |
|
754 | Case sensitve search: | |
755 |
|
755 | |||
756 | %psearch -c a* list all object beginning with lower case a |
|
756 | %psearch -c a* list all object beginning with lower case a | |
757 |
|
757 | |||
758 | Show objects beginning with a single _: |
|
758 | Show objects beginning with a single _: | |
759 |
|
759 | |||
760 | %psearch -a _* list objects beginning with a single underscore""" |
|
760 | %psearch -a _* list objects beginning with a single underscore""" | |
761 |
|
761 | |||
762 | # default namespaces to be searched |
|
762 | # default namespaces to be searched | |
763 | def_search = ['user','builtin'] |
|
763 | def_search = ['user','builtin'] | |
764 |
|
764 | |||
765 | # Process options/args |
|
765 | # Process options/args | |
766 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) |
|
766 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) | |
767 | opt = opts.get |
|
767 | opt = opts.get | |
768 | shell = self.shell |
|
768 | shell = self.shell | |
769 | psearch = shell.inspector.psearch |
|
769 | psearch = shell.inspector.psearch | |
770 |
|
770 | |||
771 | # select case options |
|
771 | # select case options | |
772 | if opts.has_key('i'): |
|
772 | if opts.has_key('i'): | |
773 | ignore_case = True |
|
773 | ignore_case = True | |
774 | elif opts.has_key('c'): |
|
774 | elif opts.has_key('c'): | |
775 | ignore_case = False |
|
775 | ignore_case = False | |
776 | else: |
|
776 | else: | |
777 | ignore_case = not shell.rc.wildcards_case_sensitive |
|
777 | ignore_case = not shell.rc.wildcards_case_sensitive | |
778 |
|
778 | |||
779 | # Build list of namespaces to search from user options |
|
779 | # Build list of namespaces to search from user options | |
780 | def_search.extend(opt('s',[])) |
|
780 | def_search.extend(opt('s',[])) | |
781 | ns_exclude = ns_exclude=opt('e',[]) |
|
781 | ns_exclude = ns_exclude=opt('e',[]) | |
782 | ns_search = [nm for nm in def_search if nm not in ns_exclude] |
|
782 | ns_search = [nm for nm in def_search if nm not in ns_exclude] | |
783 |
|
783 | |||
784 | # Call the actual search |
|
784 | # Call the actual search | |
785 | try: |
|
785 | try: | |
786 | psearch(args,shell.ns_table,ns_search, |
|
786 | psearch(args,shell.ns_table,ns_search, | |
787 | show_all=opt('a'),ignore_case=ignore_case) |
|
787 | show_all=opt('a'),ignore_case=ignore_case) | |
788 | except: |
|
788 | except: | |
789 | shell.showtraceback() |
|
789 | shell.showtraceback() | |
790 |
|
790 | |||
791 | def magic_who_ls(self, parameter_s=''): |
|
791 | def magic_who_ls(self, parameter_s=''): | |
792 | """Return a sorted list of all interactive variables. |
|
792 | """Return a sorted list of all interactive variables. | |
793 |
|
793 | |||
794 | If arguments are given, only variables of types matching these |
|
794 | If arguments are given, only variables of types matching these | |
795 | arguments are returned.""" |
|
795 | arguments are returned.""" | |
796 |
|
796 | |||
797 | user_ns = self.shell.user_ns |
|
797 | user_ns = self.shell.user_ns | |
798 | internal_ns = self.shell.internal_ns |
|
798 | internal_ns = self.shell.internal_ns | |
799 | user_config_ns = self.shell.user_config_ns |
|
799 | user_config_ns = self.shell.user_config_ns | |
800 | out = [] |
|
800 | out = [] | |
801 | typelist = parameter_s.split() |
|
801 | typelist = parameter_s.split() | |
802 |
|
802 | |||
803 | for i in user_ns: |
|
803 | for i in user_ns: | |
804 | if not (i.startswith('_') or i.startswith('_i')) \ |
|
804 | if not (i.startswith('_') or i.startswith('_i')) \ | |
805 | and not (i in internal_ns or i in user_config_ns): |
|
805 | and not (i in internal_ns or i in user_config_ns): | |
806 | if typelist: |
|
806 | if typelist: | |
807 | if type(user_ns[i]).__name__ in typelist: |
|
807 | if type(user_ns[i]).__name__ in typelist: | |
808 | out.append(i) |
|
808 | out.append(i) | |
809 | else: |
|
809 | else: | |
810 | out.append(i) |
|
810 | out.append(i) | |
811 | out.sort() |
|
811 | out.sort() | |
812 | return out |
|
812 | return out | |
813 |
|
813 | |||
814 | def magic_who(self, parameter_s=''): |
|
814 | def magic_who(self, parameter_s=''): | |
815 | """Print all interactive variables, with some minimal formatting. |
|
815 | """Print all interactive variables, with some minimal formatting. | |
816 |
|
816 | |||
817 | If any arguments are given, only variables whose type matches one of |
|
817 | If any arguments are given, only variables whose type matches one of | |
818 | these are printed. For example: |
|
818 | these are printed. For example: | |
819 |
|
819 | |||
820 | %who function str |
|
820 | %who function str | |
821 |
|
821 | |||
822 | will only list functions and strings, excluding all other types of |
|
822 | will only list functions and strings, excluding all other types of | |
823 | variables. To find the proper type names, simply use type(var) at a |
|
823 | variables. To find the proper type names, simply use type(var) at a | |
824 | command line to see how python prints type names. For example: |
|
824 | command line to see how python prints type names. For example: | |
825 |
|
825 | |||
826 | In [1]: type('hello')\\ |
|
826 | In [1]: type('hello')\\ | |
827 | Out[1]: <type 'str'> |
|
827 | Out[1]: <type 'str'> | |
828 |
|
828 | |||
829 | indicates that the type name for strings is 'str'. |
|
829 | indicates that the type name for strings is 'str'. | |
830 |
|
830 | |||
831 | %who always excludes executed names loaded through your configuration |
|
831 | %who always excludes executed names loaded through your configuration | |
832 | file and things which are internal to IPython. |
|
832 | file and things which are internal to IPython. | |
833 |
|
833 | |||
834 | This is deliberate, as typically you may load many modules and the |
|
834 | This is deliberate, as typically you may load many modules and the | |
835 | purpose of %who is to show you only what you've manually defined.""" |
|
835 | purpose of %who is to show you only what you've manually defined.""" | |
836 |
|
836 | |||
837 | varlist = self.magic_who_ls(parameter_s) |
|
837 | varlist = self.magic_who_ls(parameter_s) | |
838 | if not varlist: |
|
838 | if not varlist: | |
839 | print 'Interactive namespace is empty.' |
|
839 | print 'Interactive namespace is empty.' | |
840 | return |
|
840 | return | |
841 |
|
841 | |||
842 | # if we have variables, move on... |
|
842 | # if we have variables, move on... | |
843 |
|
843 | |||
844 | # stupid flushing problem: when prompts have no separators, stdout is |
|
844 | # stupid flushing problem: when prompts have no separators, stdout is | |
845 | # getting lost. I'm starting to think this is a python bug. I'm having |
|
845 | # getting lost. I'm starting to think this is a python bug. I'm having | |
846 | # to force a flush with a print because even a sys.stdout.flush |
|
846 | # to force a flush with a print because even a sys.stdout.flush | |
847 | # doesn't seem to do anything! |
|
847 | # doesn't seem to do anything! | |
848 |
|
848 | |||
849 | count = 0 |
|
849 | count = 0 | |
850 | for i in varlist: |
|
850 | for i in varlist: | |
851 | print i+'\t', |
|
851 | print i+'\t', | |
852 | count += 1 |
|
852 | count += 1 | |
853 | if count > 8: |
|
853 | if count > 8: | |
854 | count = 0 |
|
854 | count = 0 | |
855 |
|
855 | |||
856 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? |
|
856 | sys.stdout.flush() # FIXME. Why the hell isn't this flushing??? | |
857 |
|
857 | |||
858 | print # well, this does force a flush at the expense of an extra \n |
|
858 | print # well, this does force a flush at the expense of an extra \n | |
859 |
|
859 | |||
860 | def magic_whos(self, parameter_s=''): |
|
860 | def magic_whos(self, parameter_s=''): | |
861 | """Like %who, but gives some extra information about each variable. |
|
861 | """Like %who, but gives some extra information about each variable. | |
862 |
|
862 | |||
863 | The same type filtering of %who can be applied here. |
|
863 | The same type filtering of %who can be applied here. | |
864 |
|
864 | |||
865 | For all variables, the type is printed. Additionally it prints: |
|
865 | For all variables, the type is printed. Additionally it prints: | |
866 |
|
866 | |||
867 | - For {},[],(): their length. |
|
867 | - For {},[],(): their length. | |
868 |
|
868 | |||
869 | - For Numeric arrays, a summary with shape, number of elements, |
|
869 | - For Numeric arrays, a summary with shape, number of elements, | |
870 | typecode and size in memory. |
|
870 | typecode and size in memory. | |
871 |
|
871 | |||
872 | - Everything else: a string representation, snipping their middle if |
|
872 | - Everything else: a string representation, snipping their middle if | |
873 | too long.""" |
|
873 | too long.""" | |
874 |
|
874 | |||
875 | varnames = self.magic_who_ls(parameter_s) |
|
875 | varnames = self.magic_who_ls(parameter_s) | |
876 | if not varnames: |
|
876 | if not varnames: | |
877 | print 'Interactive namespace is empty.' |
|
877 | print 'Interactive namespace is empty.' | |
878 | return |
|
878 | return | |
879 |
|
879 | |||
880 | # if we have variables, move on... |
|
880 | # if we have variables, move on... | |
881 |
|
881 | |||
882 | # for these types, show len() instead of data: |
|
882 | # for these types, show len() instead of data: | |
883 | seq_types = [types.DictType,types.ListType,types.TupleType] |
|
883 | seq_types = [types.DictType,types.ListType,types.TupleType] | |
884 |
|
884 | |||
885 | # for Numeric arrays, display summary info |
|
885 | # for Numeric arrays, display summary info | |
886 | try: |
|
886 | try: | |
887 | import Numeric |
|
887 | import Numeric | |
888 | except ImportError: |
|
888 | except ImportError: | |
889 | array_type = None |
|
889 | array_type = None | |
890 | else: |
|
890 | else: | |
891 | array_type = Numeric.ArrayType.__name__ |
|
891 | array_type = Numeric.ArrayType.__name__ | |
892 |
|
892 | |||
893 | # Find all variable names and types so we can figure out column sizes |
|
893 | # Find all variable names and types so we can figure out column sizes | |
894 | get_vars = lambda i: self.shell.user_ns[i] |
|
894 | get_vars = lambda i: self.shell.user_ns[i] | |
895 | type_name = lambda v: type(v).__name__ |
|
895 | type_name = lambda v: type(v).__name__ | |
896 | varlist = map(get_vars,varnames) |
|
896 | varlist = map(get_vars,varnames) | |
897 |
|
897 | |||
898 | typelist = [] |
|
898 | typelist = [] | |
899 | for vv in varlist: |
|
899 | for vv in varlist: | |
900 | tt = type_name(vv) |
|
900 | tt = type_name(vv) | |
901 | if tt=='instance': |
|
901 | if tt=='instance': | |
902 | typelist.append(str(vv.__class__)) |
|
902 | typelist.append(str(vv.__class__)) | |
903 | else: |
|
903 | else: | |
904 | typelist.append(tt) |
|
904 | typelist.append(tt) | |
905 |
|
905 | |||
906 | # column labels and # of spaces as separator |
|
906 | # column labels and # of spaces as separator | |
907 | varlabel = 'Variable' |
|
907 | varlabel = 'Variable' | |
908 | typelabel = 'Type' |
|
908 | typelabel = 'Type' | |
909 | datalabel = 'Data/Info' |
|
909 | datalabel = 'Data/Info' | |
910 | colsep = 3 |
|
910 | colsep = 3 | |
911 | # variable format strings |
|
911 | # variable format strings | |
912 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" |
|
912 | vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)" | |
913 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' |
|
913 | vfmt_short = '$vstr[:25]<...>$vstr[-25:]' | |
914 | aformat = "%s: %s elems, type `%s`, %s bytes" |
|
914 | aformat = "%s: %s elems, type `%s`, %s bytes" | |
915 | # find the size of the columns to format the output nicely |
|
915 | # find the size of the columns to format the output nicely | |
916 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep |
|
916 | varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep | |
917 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep |
|
917 | typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep | |
918 | # table header |
|
918 | # table header | |
919 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ |
|
919 | print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \ | |
920 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) |
|
920 | ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1) | |
921 | # and the table itself |
|
921 | # and the table itself | |
922 | kb = 1024 |
|
922 | kb = 1024 | |
923 | Mb = 1048576 # kb**2 |
|
923 | Mb = 1048576 # kb**2 | |
924 | for vname,var,vtype in zip(varnames,varlist,typelist): |
|
924 | for vname,var,vtype in zip(varnames,varlist,typelist): | |
925 | print itpl(vformat), |
|
925 | print itpl(vformat), | |
926 | if vtype in seq_types: |
|
926 | if vtype in seq_types: | |
927 | print len(var) |
|
927 | print len(var) | |
928 | elif vtype==array_type: |
|
928 | elif vtype==array_type: | |
929 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] |
|
929 | vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] | |
930 | vsize = Numeric.size(var) |
|
930 | vsize = Numeric.size(var) | |
931 | vbytes = vsize*var.itemsize() |
|
931 | vbytes = vsize*var.itemsize() | |
932 | if vbytes < 100000: |
|
932 | if vbytes < 100000: | |
933 | print aformat % (vshape,vsize,var.typecode(),vbytes) |
|
933 | print aformat % (vshape,vsize,var.typecode(),vbytes) | |
934 | else: |
|
934 | else: | |
935 | print aformat % (vshape,vsize,var.typecode(),vbytes), |
|
935 | print aformat % (vshape,vsize,var.typecode(),vbytes), | |
936 | if vbytes < Mb: |
|
936 | if vbytes < Mb: | |
937 | print '(%s kb)' % (vbytes/kb,) |
|
937 | print '(%s kb)' % (vbytes/kb,) | |
938 | else: |
|
938 | else: | |
939 | print '(%s Mb)' % (vbytes/Mb,) |
|
939 | print '(%s Mb)' % (vbytes/Mb,) | |
940 | else: |
|
940 | else: | |
941 | vstr = str(var).replace('\n','\\n') |
|
941 | vstr = str(var).replace('\n','\\n') | |
942 | if len(vstr) < 50: |
|
942 | if len(vstr) < 50: | |
943 | print vstr |
|
943 | print vstr | |
944 | else: |
|
944 | else: | |
945 | printpl(vfmt_short) |
|
945 | printpl(vfmt_short) | |
946 |
|
946 | |||
947 | def magic_reset(self, parameter_s=''): |
|
947 | def magic_reset(self, parameter_s=''): | |
948 | """Resets the namespace by removing all names defined by the user. |
|
948 | """Resets the namespace by removing all names defined by the user. | |
949 |
|
949 | |||
950 | Input/Output history are left around in case you need them.""" |
|
950 | Input/Output history are left around in case you need them.""" | |
951 |
|
951 | |||
952 | ans = raw_input( |
|
952 | ans = raw_input( | |
953 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") |
|
953 | "Once deleted, variables cannot be recovered. Proceed (y/n)? ") | |
954 | if not ans.lower() == 'y': |
|
954 | if not ans.lower() == 'y': | |
955 | print 'Nothing done.' |
|
955 | print 'Nothing done.' | |
956 | return |
|
956 | return | |
957 | user_ns = self.shell.user_ns |
|
957 | user_ns = self.shell.user_ns | |
958 | for i in self.magic_who_ls(): |
|
958 | for i in self.magic_who_ls(): | |
959 | del(user_ns[i]) |
|
959 | del(user_ns[i]) | |
960 |
|
960 | |||
961 | def magic_config(self,parameter_s=''): |
|
961 | def magic_config(self,parameter_s=''): | |
962 | """Show IPython's internal configuration.""" |
|
962 | """Show IPython's internal configuration.""" | |
963 |
|
963 | |||
964 | page('Current configuration structure:\n'+ |
|
964 | page('Current configuration structure:\n'+ | |
965 | pformat(self.shell.rc.dict())) |
|
965 | pformat(self.shell.rc.dict())) | |
966 |
|
966 | |||
967 | def magic_logstart(self,parameter_s=''): |
|
967 | def magic_logstart(self,parameter_s=''): | |
968 | """Start logging anywhere in a session. |
|
968 | """Start logging anywhere in a session. | |
969 |
|
969 | |||
970 | %logstart [-o|-t] [log_name [log_mode]] |
|
970 | %logstart [-o|-t] [log_name [log_mode]] | |
971 |
|
971 | |||
972 | If no name is given, it defaults to a file named 'ipython_log.py' in your |
|
972 | If no name is given, it defaults to a file named 'ipython_log.py' in your | |
973 | current directory, in 'rotate' mode (see below). |
|
973 | current directory, in 'rotate' mode (see below). | |
974 |
|
974 | |||
975 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your |
|
975 | '%logstart name' saves to file 'name' in 'backup' mode. It saves your | |
976 | history up to that point and then continues logging. |
|
976 | history up to that point and then continues logging. | |
977 |
|
977 | |||
978 | %logstart takes a second optional parameter: logging mode. This can be one |
|
978 | %logstart takes a second optional parameter: logging mode. This can be one | |
979 | of (note that the modes are given unquoted):\\ |
|
979 | of (note that the modes are given unquoted):\\ | |
980 | append: well, that says it.\\ |
|
980 | append: well, that says it.\\ | |
981 | backup: rename (if exists) to name~ and start name.\\ |
|
981 | backup: rename (if exists) to name~ and start name.\\ | |
982 | global: single logfile in your home dir, appended to.\\ |
|
982 | global: single logfile in your home dir, appended to.\\ | |
983 | over : overwrite existing log.\\ |
|
983 | over : overwrite existing log.\\ | |
984 | rotate: create rotating logs name.1~, name.2~, etc. |
|
984 | rotate: create rotating logs name.1~, name.2~, etc. | |
985 |
|
985 | |||
986 | Options: |
|
986 | Options: | |
987 |
|
987 | |||
988 | -o: log also IPython's output. In this mode, all commands which |
|
988 | -o: log also IPython's output. In this mode, all commands which | |
989 | generate an Out[NN] prompt are recorded to the logfile, right after |
|
989 | generate an Out[NN] prompt are recorded to the logfile, right after | |
990 | their corresponding input line. The output lines are always |
|
990 | their corresponding input line. The output lines are always | |
991 | prepended with a '#[Out]# ' marker, so that the log remains valid |
|
991 | prepended with a '#[Out]# ' marker, so that the log remains valid | |
992 | Python code. |
|
992 | Python code. | |
993 |
|
993 | |||
994 | Since this marker is always the same, filtering only the output from |
|
994 | Since this marker is always the same, filtering only the output from | |
995 | a log is very easy, using for example a simple awk call: |
|
995 | a log is very easy, using for example a simple awk call: | |
996 |
|
996 | |||
997 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py |
|
997 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py | |
998 |
|
998 | |||
999 | -t: put timestamps before each input line logged (these are put in |
|
999 | -t: put timestamps before each input line logged (these are put in | |
1000 | comments).""" |
|
1000 | comments).""" | |
1001 |
|
1001 | |||
1002 | opts,par = self.parse_options(parameter_s,'ot') |
|
1002 | opts,par = self.parse_options(parameter_s,'ot') | |
1003 | log_output = 'o' in opts |
|
1003 | log_output = 'o' in opts | |
1004 | timestamp = 't' in opts |
|
1004 | timestamp = 't' in opts | |
1005 |
|
1005 | |||
1006 | rc = self.shell.rc |
|
1006 | rc = self.shell.rc | |
1007 | logger = self.shell.logger |
|
1007 | logger = self.shell.logger | |
1008 |
|
1008 | |||
1009 | # if no args are given, the defaults set in the logger constructor by |
|
1009 | # if no args are given, the defaults set in the logger constructor by | |
1010 | # ipytohn remain valid |
|
1010 | # ipytohn remain valid | |
1011 | if par: |
|
1011 | if par: | |
1012 | try: |
|
1012 | try: | |
1013 | logfname,logmode = par.split() |
|
1013 | logfname,logmode = par.split() | |
1014 | except: |
|
1014 | except: | |
1015 | logfname = par |
|
1015 | logfname = par | |
1016 | logmode = 'backup' |
|
1016 | logmode = 'backup' | |
1017 | else: |
|
1017 | else: | |
1018 | logfname = logger.logfname |
|
1018 | logfname = logger.logfname | |
1019 | logmode = logger.logmode |
|
1019 | logmode = logger.logmode | |
1020 | # put logfname into rc struct as if it had been called on the command |
|
1020 | # put logfname into rc struct as if it had been called on the command | |
1021 | # line, so it ends up saved in the log header Save it in case we need |
|
1021 | # line, so it ends up saved in the log header Save it in case we need | |
1022 | # to restore it... |
|
1022 | # to restore it... | |
1023 | old_logfile = rc.opts.get('logfile','') |
|
1023 | old_logfile = rc.opts.get('logfile','') | |
1024 | if logfname: |
|
1024 | if logfname: | |
1025 | logfname = os.path.expanduser(logfname) |
|
1025 | logfname = os.path.expanduser(logfname) | |
1026 | rc.opts.logfile = logfname |
|
1026 | rc.opts.logfile = logfname | |
1027 | loghead = self.shell.loghead_tpl % (rc.opts,rc.args) |
|
1027 | loghead = self.shell.loghead_tpl % (rc.opts,rc.args) | |
1028 | try: |
|
1028 | try: | |
1029 | started = logger.logstart(logfname,loghead,logmode, |
|
1029 | started = logger.logstart(logfname,loghead,logmode, | |
1030 | log_output,timestamp) |
|
1030 | log_output,timestamp) | |
1031 | except: |
|
1031 | except: | |
1032 | rc.opts.logfile = old_logfile |
|
1032 | rc.opts.logfile = old_logfile | |
1033 | warn("Couldn't start log: %s" % sys.exc_info()[1]) |
|
1033 | warn("Couldn't start log: %s" % sys.exc_info()[1]) | |
1034 | else: |
|
1034 | else: | |
1035 | # log input history up to this point, optionally interleaving |
|
1035 | # log input history up to this point, optionally interleaving | |
1036 | # output if requested |
|
1036 | # output if requested | |
1037 |
|
1037 | |||
1038 | if timestamp: |
|
1038 | if timestamp: | |
1039 | # disable timestamping for the previous history, since we've |
|
1039 | # disable timestamping for the previous history, since we've | |
1040 | # lost those already (no time machine here). |
|
1040 | # lost those already (no time machine here). | |
1041 | logger.timestamp = False |
|
1041 | logger.timestamp = False | |
1042 | if log_output: |
|
1042 | if log_output: | |
1043 | log_write = logger.log_write |
|
1043 | log_write = logger.log_write | |
1044 | input_hist = self.shell.input_hist |
|
1044 | input_hist = self.shell.input_hist | |
1045 | output_hist = self.shell.output_hist |
|
1045 | output_hist = self.shell.output_hist | |
1046 | for n in range(1,len(input_hist)-1): |
|
1046 | for n in range(1,len(input_hist)-1): | |
1047 | log_write(input_hist[n].rstrip()) |
|
1047 | log_write(input_hist[n].rstrip()) | |
1048 | if n in output_hist: |
|
1048 | if n in output_hist: | |
1049 | log_write(repr(output_hist[n]),'output') |
|
1049 | log_write(repr(output_hist[n]),'output') | |
1050 | else: |
|
1050 | else: | |
1051 | logger.log_write(self.shell.input_hist[1:]) |
|
1051 | logger.log_write(self.shell.input_hist[1:]) | |
1052 | if timestamp: |
|
1052 | if timestamp: | |
1053 | # re-enable timestamping |
|
1053 | # re-enable timestamping | |
1054 | logger.timestamp = True |
|
1054 | logger.timestamp = True | |
1055 |
|
1055 | |||
1056 | print ('Activating auto-logging. ' |
|
1056 | print ('Activating auto-logging. ' | |
1057 | 'Current session state plus future input saved.') |
|
1057 | 'Current session state plus future input saved.') | |
1058 | logger.logstate() |
|
1058 | logger.logstate() | |
1059 |
|
1059 | |||
1060 | def magic_logoff(self,parameter_s=''): |
|
1060 | def magic_logoff(self,parameter_s=''): | |
1061 | """Temporarily stop logging. |
|
1061 | """Temporarily stop logging. | |
1062 |
|
1062 | |||
1063 | You must have previously started logging.""" |
|
1063 | You must have previously started logging.""" | |
1064 | self.shell.logger.switch_log(0) |
|
1064 | self.shell.logger.switch_log(0) | |
1065 |
|
1065 | |||
1066 | def magic_logon(self,parameter_s=''): |
|
1066 | def magic_logon(self,parameter_s=''): | |
1067 | """Restart logging. |
|
1067 | """Restart logging. | |
1068 |
|
1068 | |||
1069 | This function is for restarting logging which you've temporarily |
|
1069 | This function is for restarting logging which you've temporarily | |
1070 | stopped with %logoff. For starting logging for the first time, you |
|
1070 | stopped with %logoff. For starting logging for the first time, you | |
1071 | must use the %logstart function, which allows you to specify an |
|
1071 | must use the %logstart function, which allows you to specify an | |
1072 | optional log filename.""" |
|
1072 | optional log filename.""" | |
1073 |
|
1073 | |||
1074 | self.shell.logger.switch_log(1) |
|
1074 | self.shell.logger.switch_log(1) | |
1075 |
|
1075 | |||
1076 | def magic_logstate(self,parameter_s=''): |
|
1076 | def magic_logstate(self,parameter_s=''): | |
1077 | """Print the status of the logging system.""" |
|
1077 | """Print the status of the logging system.""" | |
1078 |
|
1078 | |||
1079 | self.shell.logger.logstate() |
|
1079 | self.shell.logger.logstate() | |
1080 |
|
1080 | |||
1081 | def magic_pdb(self, parameter_s=''): |
|
1081 | def magic_pdb(self, parameter_s=''): | |
1082 | """Control the calling of the pdb interactive debugger. |
|
1082 | """Control the calling of the pdb interactive debugger. | |
1083 |
|
1083 | |||
1084 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without |
|
1084 | Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without | |
1085 | argument it works as a toggle. |
|
1085 | argument it works as a toggle. | |
1086 |
|
1086 | |||
1087 | When an exception is triggered, IPython can optionally call the |
|
1087 | When an exception is triggered, IPython can optionally call the | |
1088 | interactive pdb debugger after the traceback printout. %pdb toggles |
|
1088 | interactive pdb debugger after the traceback printout. %pdb toggles | |
1089 | this feature on and off.""" |
|
1089 | this feature on and off.""" | |
1090 |
|
1090 | |||
1091 | par = parameter_s.strip().lower() |
|
1091 | par = parameter_s.strip().lower() | |
1092 |
|
1092 | |||
1093 | if par: |
|
1093 | if par: | |
1094 | try: |
|
1094 | try: | |
1095 | new_pdb = {'off':0,'0':0,'on':1,'1':1}[par] |
|
1095 | new_pdb = {'off':0,'0':0,'on':1,'1':1}[par] | |
1096 | except KeyError: |
|
1096 | except KeyError: | |
1097 | print ('Incorrect argument. Use on/1, off/0, ' |
|
1097 | print ('Incorrect argument. Use on/1, off/0, ' | |
1098 | 'or nothing for a toggle.') |
|
1098 | 'or nothing for a toggle.') | |
1099 | return |
|
1099 | return | |
1100 | else: |
|
1100 | else: | |
1101 | # toggle |
|
1101 | # toggle | |
1102 | new_pdb = not self.shell.InteractiveTB.call_pdb |
|
1102 | new_pdb = not self.shell.InteractiveTB.call_pdb | |
1103 |
|
1103 | |||
1104 | # set on the shell |
|
1104 | # set on the shell | |
1105 | self.shell.call_pdb = new_pdb |
|
1105 | self.shell.call_pdb = new_pdb | |
1106 | print 'Automatic pdb calling has been turned',on_off(new_pdb) |
|
1106 | print 'Automatic pdb calling has been turned',on_off(new_pdb) | |
1107 |
|
1107 | |||
1108 | def magic_prun(self, parameter_s ='',user_mode=1, |
|
1108 | def magic_prun(self, parameter_s ='',user_mode=1, | |
1109 | opts=None,arg_lst=None,prog_ns=None): |
|
1109 | opts=None,arg_lst=None,prog_ns=None): | |
1110 |
|
1110 | |||
1111 | """Run a statement through the python code profiler. |
|
1111 | """Run a statement through the python code profiler. | |
1112 |
|
1112 | |||
1113 | Usage:\\ |
|
1113 | Usage:\\ | |
1114 | %prun [options] statement |
|
1114 | %prun [options] statement | |
1115 |
|
1115 | |||
1116 | The given statement (which doesn't require quote marks) is run via the |
|
1116 | The given statement (which doesn't require quote marks) is run via the | |
1117 | python profiler in a manner similar to the profile.run() function. |
|
1117 | python profiler in a manner similar to the profile.run() function. | |
1118 | Namespaces are internally managed to work correctly; profile.run |
|
1118 | Namespaces are internally managed to work correctly; profile.run | |
1119 | cannot be used in IPython because it makes certain assumptions about |
|
1119 | cannot be used in IPython because it makes certain assumptions about | |
1120 | namespaces which do not hold under IPython. |
|
1120 | namespaces which do not hold under IPython. | |
1121 |
|
1121 | |||
1122 | Options: |
|
1122 | Options: | |
1123 |
|
1123 | |||
1124 | -l <limit>: you can place restrictions on what or how much of the |
|
1124 | -l <limit>: you can place restrictions on what or how much of the | |
1125 | profile gets printed. The limit value can be: |
|
1125 | profile gets printed. The limit value can be: | |
1126 |
|
1126 | |||
1127 | * A string: only information for function names containing this string |
|
1127 | * A string: only information for function names containing this string | |
1128 | is printed. |
|
1128 | is printed. | |
1129 |
|
1129 | |||
1130 | * An integer: only these many lines are printed. |
|
1130 | * An integer: only these many lines are printed. | |
1131 |
|
1131 | |||
1132 | * A float (between 0 and 1): this fraction of the report is printed |
|
1132 | * A float (between 0 and 1): this fraction of the report is printed | |
1133 | (for example, use a limit of 0.4 to see the topmost 40% only). |
|
1133 | (for example, use a limit of 0.4 to see the topmost 40% only). | |
1134 |
|
1134 | |||
1135 | You can combine several limits with repeated use of the option. For |
|
1135 | You can combine several limits with repeated use of the option. For | |
1136 | example, '-l __init__ -l 5' will print only the topmost 5 lines of |
|
1136 | example, '-l __init__ -l 5' will print only the topmost 5 lines of | |
1137 | information about class constructors. |
|
1137 | information about class constructors. | |
1138 |
|
1138 | |||
1139 | -r: return the pstats.Stats object generated by the profiling. This |
|
1139 | -r: return the pstats.Stats object generated by the profiling. This | |
1140 | object has all the information about the profile in it, and you can |
|
1140 | object has all the information about the profile in it, and you can | |
1141 | later use it for further analysis or in other functions. |
|
1141 | later use it for further analysis or in other functions. | |
1142 |
|
1142 | |||
1143 | Since magic functions have a particular form of calling which prevents |
|
1143 | Since magic functions have a particular form of calling which prevents | |
1144 | you from writing something like:\\ |
|
1144 | you from writing something like:\\ | |
1145 | In [1]: p = %prun -r print 4 # invalid!\\ |
|
1145 | In [1]: p = %prun -r print 4 # invalid!\\ | |
1146 | you must instead use IPython's automatic variables to assign this:\\ |
|
1146 | you must instead use IPython's automatic variables to assign this:\\ | |
1147 | In [1]: %prun -r print 4 \\ |
|
1147 | In [1]: %prun -r print 4 \\ | |
1148 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ |
|
1148 | Out[1]: <pstats.Stats instance at 0x8222cec>\\ | |
1149 | In [2]: stats = _ |
|
1149 | In [2]: stats = _ | |
1150 |
|
1150 | |||
1151 | If you really need to assign this value via an explicit function call, |
|
1151 | If you really need to assign this value via an explicit function call, | |
1152 | you can always tap directly into the true name of the magic function |
|
1152 | you can always tap directly into the true name of the magic function | |
1153 | by using the _ip.magic function:\\ |
|
1153 | by using the _ip.magic function:\\ | |
1154 | In [3]: stats = _ip.magic('prun','-r print 4') |
|
1154 | In [3]: stats = _ip.magic('prun','-r print 4') | |
1155 |
|
1155 | |||
1156 | You can type _ip.magic? for more details. |
|
1156 | You can type _ip.magic? for more details. | |
1157 |
|
1157 | |||
1158 | -s <key>: sort profile by given key. You can provide more than one key |
|
1158 | -s <key>: sort profile by given key. You can provide more than one key | |
1159 | by using the option several times: '-s key1 -s key2 -s key3...'. The |
|
1159 | by using the option several times: '-s key1 -s key2 -s key3...'. The | |
1160 | default sorting key is 'time'. |
|
1160 | default sorting key is 'time'. | |
1161 |
|
1161 | |||
1162 | The following is copied verbatim from the profile documentation |
|
1162 | The following is copied verbatim from the profile documentation | |
1163 | referenced below: |
|
1163 | referenced below: | |
1164 |
|
1164 | |||
1165 | When more than one key is provided, additional keys are used as |
|
1165 | When more than one key is provided, additional keys are used as | |
1166 | secondary criteria when the there is equality in all keys selected |
|
1166 | secondary criteria when the there is equality in all keys selected | |
1167 | before them. |
|
1167 | before them. | |
1168 |
|
1168 | |||
1169 | Abbreviations can be used for any key names, as long as the |
|
1169 | Abbreviations can be used for any key names, as long as the | |
1170 | abbreviation is unambiguous. The following are the keys currently |
|
1170 | abbreviation is unambiguous. The following are the keys currently | |
1171 | defined: |
|
1171 | defined: | |
1172 |
|
1172 | |||
1173 | Valid Arg Meaning\\ |
|
1173 | Valid Arg Meaning\\ | |
1174 | "calls" call count\\ |
|
1174 | "calls" call count\\ | |
1175 | "cumulative" cumulative time\\ |
|
1175 | "cumulative" cumulative time\\ | |
1176 | "file" file name\\ |
|
1176 | "file" file name\\ | |
1177 | "module" file name\\ |
|
1177 | "module" file name\\ | |
1178 | "pcalls" primitive call count\\ |
|
1178 | "pcalls" primitive call count\\ | |
1179 | "line" line number\\ |
|
1179 | "line" line number\\ | |
1180 | "name" function name\\ |
|
1180 | "name" function name\\ | |
1181 | "nfl" name/file/line\\ |
|
1181 | "nfl" name/file/line\\ | |
1182 | "stdname" standard name\\ |
|
1182 | "stdname" standard name\\ | |
1183 | "time" internal time |
|
1183 | "time" internal time | |
1184 |
|
1184 | |||
1185 | Note that all sorts on statistics are in descending order (placing |
|
1185 | Note that all sorts on statistics are in descending order (placing | |
1186 | most time consuming items first), where as name, file, and line number |
|
1186 | most time consuming items first), where as name, file, and line number | |
1187 | searches are in ascending order (i.e., alphabetical). The subtle |
|
1187 | searches are in ascending order (i.e., alphabetical). The subtle | |
1188 | distinction between "nfl" and "stdname" is that the standard name is a |
|
1188 | distinction between "nfl" and "stdname" is that the standard name is a | |
1189 | sort of the name as printed, which means that the embedded line |
|
1189 | sort of the name as printed, which means that the embedded line | |
1190 | numbers get compared in an odd way. For example, lines 3, 20, and 40 |
|
1190 | numbers get compared in an odd way. For example, lines 3, 20, and 40 | |
1191 | would (if the file names were the same) appear in the string order |
|
1191 | would (if the file names were the same) appear in the string order | |
1192 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the |
|
1192 | "20" "3" and "40". In contrast, "nfl" does a numeric compare of the | |
1193 | line numbers. In fact, sort_stats("nfl") is the same as |
|
1193 | line numbers. In fact, sort_stats("nfl") is the same as | |
1194 | sort_stats("name", "file", "line"). |
|
1194 | sort_stats("name", "file", "line"). | |
1195 |
|
1195 | |||
1196 | -T <filename>: save profile results as shown on screen to a text |
|
1196 | -T <filename>: save profile results as shown on screen to a text | |
1197 | file. The profile is still shown on screen. |
|
1197 | file. The profile is still shown on screen. | |
1198 |
|
1198 | |||
1199 | -D <filename>: save (via dump_stats) profile statistics to given |
|
1199 | -D <filename>: save (via dump_stats) profile statistics to given | |
1200 | filename. This data is in a format understod by the pstats module, and |
|
1200 | filename. This data is in a format understod by the pstats module, and | |
1201 | is generated by a call to the dump_stats() method of profile |
|
1201 | is generated by a call to the dump_stats() method of profile | |
1202 | objects. The profile is still shown on screen. |
|
1202 | objects. The profile is still shown on screen. | |
1203 |
|
1203 | |||
1204 | If you want to run complete programs under the profiler's control, use |
|
1204 | If you want to run complete programs under the profiler's control, use | |
1205 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts |
|
1205 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts | |
1206 | contains profiler specific options as described here. |
|
1206 | contains profiler specific options as described here. | |
1207 |
|
1207 | |||
1208 | You can read the complete documentation for the profile module with:\\ |
|
1208 | You can read the complete documentation for the profile module with:\\ | |
1209 | In [1]: import profile; profile.help() """ |
|
1209 | In [1]: import profile; profile.help() """ | |
1210 |
|
1210 | |||
1211 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) |
|
1211 | opts_def = Struct(D=[''],l=[],s=['time'],T=['']) | |
1212 | # protect user quote marks |
|
1212 | # protect user quote marks | |
1213 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") |
|
1213 | parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'") | |
1214 |
|
1214 | |||
1215 | if user_mode: # regular user call |
|
1215 | if user_mode: # regular user call | |
1216 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', |
|
1216 | opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:', | |
1217 | list_all=1) |
|
1217 | list_all=1) | |
1218 | namespace = self.shell.user_ns |
|
1218 | namespace = self.shell.user_ns | |
1219 | else: # called to run a program by %run -p |
|
1219 | else: # called to run a program by %run -p | |
1220 | try: |
|
1220 | try: | |
1221 | filename = get_py_filename(arg_lst[0]) |
|
1221 | filename = get_py_filename(arg_lst[0]) | |
1222 | except IOError,msg: |
|
1222 | except IOError,msg: | |
1223 | error(msg) |
|
1223 | error(msg) | |
1224 | return |
|
1224 | return | |
1225 |
|
1225 | |||
1226 | arg_str = 'execfile(filename,prog_ns)' |
|
1226 | arg_str = 'execfile(filename,prog_ns)' | |
1227 | namespace = locals() |
|
1227 | namespace = locals() | |
1228 |
|
1228 | |||
1229 | opts.merge(opts_def) |
|
1229 | opts.merge(opts_def) | |
1230 |
|
1230 | |||
1231 | prof = profile.Profile() |
|
1231 | prof = profile.Profile() | |
1232 | try: |
|
1232 | try: | |
1233 | prof = prof.runctx(arg_str,namespace,namespace) |
|
1233 | prof = prof.runctx(arg_str,namespace,namespace) | |
1234 | sys_exit = '' |
|
1234 | sys_exit = '' | |
1235 | except SystemExit: |
|
1235 | except SystemExit: | |
1236 | sys_exit = """*** SystemExit exception caught in code being profiled.""" |
|
1236 | sys_exit = """*** SystemExit exception caught in code being profiled.""" | |
1237 |
|
1237 | |||
1238 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) |
|
1238 | stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s) | |
1239 |
|
1239 | |||
1240 | lims = opts.l |
|
1240 | lims = opts.l | |
1241 | if lims: |
|
1241 | if lims: | |
1242 | lims = [] # rebuild lims with ints/floats/strings |
|
1242 | lims = [] # rebuild lims with ints/floats/strings | |
1243 | for lim in opts.l: |
|
1243 | for lim in opts.l: | |
1244 | try: |
|
1244 | try: | |
1245 | lims.append(int(lim)) |
|
1245 | lims.append(int(lim)) | |
1246 | except ValueError: |
|
1246 | except ValueError: | |
1247 | try: |
|
1247 | try: | |
1248 | lims.append(float(lim)) |
|
1248 | lims.append(float(lim)) | |
1249 | except ValueError: |
|
1249 | except ValueError: | |
1250 | lims.append(lim) |
|
1250 | lims.append(lim) | |
1251 |
|
1251 | |||
1252 | # trap output |
|
1252 | # trap output | |
1253 | sys_stdout = sys.stdout |
|
1253 | sys_stdout = sys.stdout | |
1254 | stdout_trap = StringIO() |
|
1254 | stdout_trap = StringIO() | |
1255 | try: |
|
1255 | try: | |
1256 | sys.stdout = stdout_trap |
|
1256 | sys.stdout = stdout_trap | |
1257 | stats.print_stats(*lims) |
|
1257 | stats.print_stats(*lims) | |
1258 | finally: |
|
1258 | finally: | |
1259 | sys.stdout = sys_stdout |
|
1259 | sys.stdout = sys_stdout | |
1260 | output = stdout_trap.getvalue() |
|
1260 | output = stdout_trap.getvalue() | |
1261 | output = output.rstrip() |
|
1261 | output = output.rstrip() | |
1262 |
|
1262 | |||
1263 | page(output,screen_lines=self.shell.rc.screen_length) |
|
1263 | page(output,screen_lines=self.shell.rc.screen_length) | |
1264 | print sys_exit, |
|
1264 | print sys_exit, | |
1265 |
|
1265 | |||
1266 | dump_file = opts.D[0] |
|
1266 | dump_file = opts.D[0] | |
1267 | text_file = opts.T[0] |
|
1267 | text_file = opts.T[0] | |
1268 | if dump_file: |
|
1268 | if dump_file: | |
1269 | prof.dump_stats(dump_file) |
|
1269 | prof.dump_stats(dump_file) | |
1270 | print '\n*** Profile stats marshalled to file',\ |
|
1270 | print '\n*** Profile stats marshalled to file',\ | |
1271 | `dump_file`+'.',sys_exit |
|
1271 | `dump_file`+'.',sys_exit | |
1272 | if text_file: |
|
1272 | if text_file: | |
1273 | file(text_file,'w').write(output) |
|
1273 | file(text_file,'w').write(output) | |
1274 | print '\n*** Profile printout saved to text file',\ |
|
1274 | print '\n*** Profile printout saved to text file',\ | |
1275 | `text_file`+'.',sys_exit |
|
1275 | `text_file`+'.',sys_exit | |
1276 |
|
1276 | |||
1277 | if opts.has_key('r'): |
|
1277 | if opts.has_key('r'): | |
1278 | return stats |
|
1278 | return stats | |
1279 | else: |
|
1279 | else: | |
1280 | return None |
|
1280 | return None | |
1281 |
|
1281 | |||
1282 | def magic_run(self, parameter_s ='',runner=None): |
|
1282 | def magic_run(self, parameter_s ='',runner=None): | |
1283 | """Run the named file inside IPython as a program. |
|
1283 | """Run the named file inside IPython as a program. | |
1284 |
|
1284 | |||
1285 | Usage:\\ |
|
1285 | Usage:\\ | |
1286 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] |
|
1286 | %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args] | |
1287 |
|
1287 | |||
1288 | Parameters after the filename are passed as command-line arguments to |
|
1288 | Parameters after the filename are passed as command-line arguments to | |
1289 | the program (put in sys.argv). Then, control returns to IPython's |
|
1289 | the program (put in sys.argv). Then, control returns to IPython's | |
1290 | prompt. |
|
1290 | prompt. | |
1291 |
|
1291 | |||
1292 | This is similar to running at a system prompt:\\ |
|
1292 | This is similar to running at a system prompt:\\ | |
1293 | $ python file args\\ |
|
1293 | $ python file args\\ | |
1294 | but with the advantage of giving you IPython's tracebacks, and of |
|
1294 | but with the advantage of giving you IPython's tracebacks, and of | |
1295 | loading all variables into your interactive namespace for further use |
|
1295 | loading all variables into your interactive namespace for further use | |
1296 | (unless -p is used, see below). |
|
1296 | (unless -p is used, see below). | |
1297 |
|
1297 | |||
1298 | The file is executed in a namespace initially consisting only of |
|
1298 | The file is executed in a namespace initially consisting only of | |
1299 | __name__=='__main__' and sys.argv constructed as indicated. It thus |
|
1299 | __name__=='__main__' and sys.argv constructed as indicated. It thus | |
1300 | sees its environment as if it were being run as a stand-alone |
|
1300 | sees its environment as if it were being run as a stand-alone | |
1301 | program. But after execution, the IPython interactive namespace gets |
|
1301 | program. But after execution, the IPython interactive namespace gets | |
1302 | updated with all variables defined in the program (except for __name__ |
|
1302 | updated with all variables defined in the program (except for __name__ | |
1303 | and sys.argv). This allows for very convenient loading of code for |
|
1303 | and sys.argv). This allows for very convenient loading of code for | |
1304 | interactive work, while giving each program a 'clean sheet' to run in. |
|
1304 | interactive work, while giving each program a 'clean sheet' to run in. | |
1305 |
|
1305 | |||
1306 | Options: |
|
1306 | Options: | |
1307 |
|
1307 | |||
1308 | -n: __name__ is NOT set to '__main__', but to the running file's name |
|
1308 | -n: __name__ is NOT set to '__main__', but to the running file's name | |
1309 | without extension (as python does under import). This allows running |
|
1309 | without extension (as python does under import). This allows running | |
1310 | scripts and reloading the definitions in them without calling code |
|
1310 | scripts and reloading the definitions in them without calling code | |
1311 | protected by an ' if __name__ == "__main__" ' clause. |
|
1311 | protected by an ' if __name__ == "__main__" ' clause. | |
1312 |
|
1312 | |||
1313 | -i: run the file in IPython's namespace instead of an empty one. This |
|
1313 | -i: run the file in IPython's namespace instead of an empty one. This | |
1314 | is useful if you are experimenting with code written in a text editor |
|
1314 | is useful if you are experimenting with code written in a text editor | |
1315 | which depends on variables defined interactively. |
|
1315 | which depends on variables defined interactively. | |
1316 |
|
1316 | |||
1317 | -e: ignore sys.exit() calls or SystemExit exceptions in the script |
|
1317 | -e: ignore sys.exit() calls or SystemExit exceptions in the script | |
1318 | being run. This is particularly useful if IPython is being used to |
|
1318 | being run. This is particularly useful if IPython is being used to | |
1319 | run unittests, which always exit with a sys.exit() call. In such |
|
1319 | run unittests, which always exit with a sys.exit() call. In such | |
1320 | cases you are interested in the output of the test results, not in |
|
1320 | cases you are interested in the output of the test results, not in | |
1321 | seeing a traceback of the unittest module. |
|
1321 | seeing a traceback of the unittest module. | |
1322 |
|
1322 | |||
1323 | -t: print timing information at the end of the run. IPython will give |
|
1323 | -t: print timing information at the end of the run. IPython will give | |
1324 | you an estimated CPU time consumption for your script, which under |
|
1324 | you an estimated CPU time consumption for your script, which under | |
1325 | Unix uses the resource module to avoid the wraparound problems of |
|
1325 | Unix uses the resource module to avoid the wraparound problems of | |
1326 | time.clock(). Under Unix, an estimate of time spent on system tasks |
|
1326 | time.clock(). Under Unix, an estimate of time spent on system tasks | |
1327 | is also given (for Windows platforms this is reported as 0.0). |
|
1327 | is also given (for Windows platforms this is reported as 0.0). | |
1328 |
|
1328 | |||
1329 | If -t is given, an additional -N<N> option can be given, where <N> |
|
1329 | If -t is given, an additional -N<N> option can be given, where <N> | |
1330 | must be an integer indicating how many times you want the script to |
|
1330 | must be an integer indicating how many times you want the script to | |
1331 | run. The final timing report will include total and per run results. |
|
1331 | run. The final timing report will include total and per run results. | |
1332 |
|
1332 | |||
1333 | For example (testing the script uniq_stable.py): |
|
1333 | For example (testing the script uniq_stable.py): | |
1334 |
|
1334 | |||
1335 | In [1]: run -t uniq_stable |
|
1335 | In [1]: run -t uniq_stable | |
1336 |
|
1336 | |||
1337 | IPython CPU timings (estimated):\\ |
|
1337 | IPython CPU timings (estimated):\\ | |
1338 | User : 0.19597 s.\\ |
|
1338 | User : 0.19597 s.\\ | |
1339 | System: 0.0 s.\\ |
|
1339 | System: 0.0 s.\\ | |
1340 |
|
1340 | |||
1341 | In [2]: run -t -N5 uniq_stable |
|
1341 | In [2]: run -t -N5 uniq_stable | |
1342 |
|
1342 | |||
1343 | IPython CPU timings (estimated):\\ |
|
1343 | IPython CPU timings (estimated):\\ | |
1344 | Total runs performed: 5\\ |
|
1344 | Total runs performed: 5\\ | |
1345 | Times : Total Per run\\ |
|
1345 | Times : Total Per run\\ | |
1346 | User : 0.910862 s, 0.1821724 s.\\ |
|
1346 | User : 0.910862 s, 0.1821724 s.\\ | |
1347 | System: 0.0 s, 0.0 s. |
|
1347 | System: 0.0 s, 0.0 s. | |
1348 |
|
1348 | |||
1349 | -d: run your program under the control of pdb, the Python debugger. |
|
1349 | -d: run your program under the control of pdb, the Python debugger. | |
1350 | This allows you to execute your program step by step, watch variables, |
|
1350 | This allows you to execute your program step by step, watch variables, | |
1351 | etc. Internally, what IPython does is similar to calling: |
|
1351 | etc. Internally, what IPython does is similar to calling: | |
1352 |
|
1352 | |||
1353 | pdb.run('execfile("YOURFILENAME")') |
|
1353 | pdb.run('execfile("YOURFILENAME")') | |
1354 |
|
1354 | |||
1355 | with a breakpoint set on line 1 of your file. You can change the line |
|
1355 | with a breakpoint set on line 1 of your file. You can change the line | |
1356 | number for this automatic breakpoint to be <N> by using the -bN option |
|
1356 | number for this automatic breakpoint to be <N> by using the -bN option | |
1357 | (where N must be an integer). For example: |
|
1357 | (where N must be an integer). For example: | |
1358 |
|
1358 | |||
1359 | %run -d -b40 myscript |
|
1359 | %run -d -b40 myscript | |
1360 |
|
1360 | |||
1361 | will set the first breakpoint at line 40 in myscript.py. Note that |
|
1361 | will set the first breakpoint at line 40 in myscript.py. Note that | |
1362 | the first breakpoint must be set on a line which actually does |
|
1362 | the first breakpoint must be set on a line which actually does | |
1363 | something (not a comment or docstring) for it to stop execution. |
|
1363 | something (not a comment or docstring) for it to stop execution. | |
1364 |
|
1364 | |||
1365 | When the pdb debugger starts, you will see a (Pdb) prompt. You must |
|
1365 | When the pdb debugger starts, you will see a (Pdb) prompt. You must | |
1366 | first enter 'c' (without qoutes) to start execution up to the first |
|
1366 | first enter 'c' (without qoutes) to start execution up to the first | |
1367 | breakpoint. |
|
1367 | breakpoint. | |
1368 |
|
1368 | |||
1369 | Entering 'help' gives information about the use of the debugger. You |
|
1369 | Entering 'help' gives information about the use of the debugger. You | |
1370 | can easily see pdb's full documentation with "import pdb;pdb.help()" |
|
1370 | can easily see pdb's full documentation with "import pdb;pdb.help()" | |
1371 | at a prompt. |
|
1371 | at a prompt. | |
1372 |
|
1372 | |||
1373 | -p: run program under the control of the Python profiler module (which |
|
1373 | -p: run program under the control of the Python profiler module (which | |
1374 | prints a detailed report of execution times, function calls, etc). |
|
1374 | prints a detailed report of execution times, function calls, etc). | |
1375 |
|
1375 | |||
1376 | You can pass other options after -p which affect the behavior of the |
|
1376 | You can pass other options after -p which affect the behavior of the | |
1377 | profiler itself. See the docs for %prun for details. |
|
1377 | profiler itself. See the docs for %prun for details. | |
1378 |
|
1378 | |||
1379 | In this mode, the program's variables do NOT propagate back to the |
|
1379 | In this mode, the program's variables do NOT propagate back to the | |
1380 | IPython interactive namespace (because they remain in the namespace |
|
1380 | IPython interactive namespace (because they remain in the namespace | |
1381 | where the profiler executes them). |
|
1381 | where the profiler executes them). | |
1382 |
|
1382 | |||
1383 | Internally this triggers a call to %prun, see its documentation for |
|
1383 | Internally this triggers a call to %prun, see its documentation for | |
1384 | details on the options available specifically for profiling.""" |
|
1384 | details on the options available specifically for profiling.""" | |
1385 |
|
1385 | |||
1386 | # get arguments and set sys.argv for program to be run. |
|
1386 | # get arguments and set sys.argv for program to be run. | |
1387 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', |
|
1387 | opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e', | |
1388 | mode='list',list_all=1) |
|
1388 | mode='list',list_all=1) | |
1389 |
|
1389 | |||
1390 | try: |
|
1390 | try: | |
1391 | filename = get_py_filename(arg_lst[0]) |
|
1391 | filename = get_py_filename(arg_lst[0]) | |
1392 | except IndexError: |
|
1392 | except IndexError: | |
1393 | warn('you must provide at least a filename.') |
|
1393 | warn('you must provide at least a filename.') | |
1394 | print '\n%run:\n',OInspect.getdoc(self.magic_run) |
|
1394 | print '\n%run:\n',OInspect.getdoc(self.magic_run) | |
1395 | return |
|
1395 | return | |
1396 | except IOError,msg: |
|
1396 | except IOError,msg: | |
1397 | error(msg) |
|
1397 | error(msg) | |
1398 | return |
|
1398 | return | |
1399 |
|
1399 | |||
1400 | # Control the response to exit() calls made by the script being run |
|
1400 | # Control the response to exit() calls made by the script being run | |
1401 | exit_ignore = opts.has_key('e') |
|
1401 | exit_ignore = opts.has_key('e') | |
1402 |
|
1402 | |||
1403 | # Make sure that the running script gets a proper sys.argv as if it |
|
1403 | # Make sure that the running script gets a proper sys.argv as if it | |
1404 | # were run from a system shell. |
|
1404 | # were run from a system shell. | |
1405 | save_argv = sys.argv # save it for later restoring |
|
1405 | save_argv = sys.argv # save it for later restoring | |
1406 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename |
|
1406 | sys.argv = [filename]+ arg_lst[1:] # put in the proper filename | |
1407 |
|
1407 | |||
1408 | if opts.has_key('i'): |
|
1408 | if opts.has_key('i'): | |
1409 | prog_ns = self.shell.user_ns |
|
1409 | prog_ns = self.shell.user_ns | |
1410 | __name__save = self.shell.user_ns['__name__'] |
|
1410 | __name__save = self.shell.user_ns['__name__'] | |
1411 | prog_ns['__name__'] = '__main__' |
|
1411 | prog_ns['__name__'] = '__main__' | |
1412 | else: |
|
1412 | else: | |
1413 | if opts.has_key('n'): |
|
1413 | if opts.has_key('n'): | |
1414 | name = os.path.splitext(os.path.basename(filename))[0] |
|
1414 | name = os.path.splitext(os.path.basename(filename))[0] | |
1415 | else: |
|
1415 | else: | |
1416 | name = '__main__' |
|
1416 | name = '__main__' | |
1417 | prog_ns = {'__name__':name} |
|
1417 | prog_ns = {'__name__':name} | |
1418 |
|
1418 | |||
1419 | # Since '%run foo' emulates 'python foo.py' at the cmd line, we must |
|
1419 | # Since '%run foo' emulates 'python foo.py' at the cmd line, we must | |
1420 | # set the __file__ global in the script's namespace |
|
1420 | # set the __file__ global in the script's namespace | |
1421 | prog_ns['__file__'] = filename |
|
1421 | prog_ns['__file__'] = filename | |
1422 |
|
1422 | |||
1423 | # pickle fix. See iplib for an explanation. But we need to make sure |
|
1423 | # pickle fix. See iplib for an explanation. But we need to make sure | |
1424 | # that, if we overwrite __main__, we replace it at the end |
|
1424 | # that, if we overwrite __main__, we replace it at the end | |
1425 | if prog_ns['__name__'] == '__main__': |
|
1425 | if prog_ns['__name__'] == '__main__': | |
1426 | restore_main = sys.modules['__main__'] |
|
1426 | restore_main = sys.modules['__main__'] | |
1427 | else: |
|
1427 | else: | |
1428 | restore_main = False |
|
1428 | restore_main = False | |
1429 |
|
1429 | |||
1430 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) |
|
1430 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) | |
1431 |
|
1431 | |||
1432 | stats = None |
|
1432 | stats = None | |
1433 | try: |
|
1433 | try: | |
1434 | if opts.has_key('p'): |
|
1434 | if opts.has_key('p'): | |
1435 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) |
|
1435 | stats = self.magic_prun('',0,opts,arg_lst,prog_ns) | |
1436 | else: |
|
1436 | else: | |
1437 | if opts.has_key('d'): |
|
1437 | if opts.has_key('d'): | |
1438 | deb = Debugger.Pdb(self.shell.rc.colors) |
|
1438 | deb = Debugger.Pdb(self.shell.rc.colors) | |
1439 | # reset Breakpoint state, which is moronically kept |
|
1439 | # reset Breakpoint state, which is moronically kept | |
1440 | # in a class |
|
1440 | # in a class | |
1441 | bdb.Breakpoint.next = 1 |
|
1441 | bdb.Breakpoint.next = 1 | |
1442 | bdb.Breakpoint.bplist = {} |
|
1442 | bdb.Breakpoint.bplist = {} | |
1443 | bdb.Breakpoint.bpbynumber = [None] |
|
1443 | bdb.Breakpoint.bpbynumber = [None] | |
1444 | # Set an initial breakpoint to stop execution |
|
1444 | # Set an initial breakpoint to stop execution | |
1445 | maxtries = 10 |
|
1445 | maxtries = 10 | |
1446 | bp = int(opts.get('b',[1])[0]) |
|
1446 | bp = int(opts.get('b',[1])[0]) | |
1447 | checkline = deb.checkline(filename,bp) |
|
1447 | checkline = deb.checkline(filename,bp) | |
1448 | if not checkline: |
|
1448 | if not checkline: | |
1449 | for bp in range(bp+1,bp+maxtries+1): |
|
1449 | for bp in range(bp+1,bp+maxtries+1): | |
1450 | if deb.checkline(filename,bp): |
|
1450 | if deb.checkline(filename,bp): | |
1451 | break |
|
1451 | break | |
1452 | else: |
|
1452 | else: | |
1453 | msg = ("\nI failed to find a valid line to set " |
|
1453 | msg = ("\nI failed to find a valid line to set " | |
1454 | "a breakpoint\n" |
|
1454 | "a breakpoint\n" | |
1455 | "after trying up to line: %s.\n" |
|
1455 | "after trying up to line: %s.\n" | |
1456 | "Please set a valid breakpoint manually " |
|
1456 | "Please set a valid breakpoint manually " | |
1457 | "with the -b option." % bp) |
|
1457 | "with the -b option." % bp) | |
1458 | error(msg) |
|
1458 | error(msg) | |
1459 | return |
|
1459 | return | |
1460 | # if we find a good linenumber, set the breakpoint |
|
1460 | # if we find a good linenumber, set the breakpoint | |
1461 | deb.do_break('%s:%s' % (filename,bp)) |
|
1461 | deb.do_break('%s:%s' % (filename,bp)) | |
1462 | # Start file run |
|
1462 | # Start file run | |
1463 | print "NOTE: Enter 'c' at the", |
|
1463 | print "NOTE: Enter 'c' at the", | |
1464 | print "ipdb> prompt to start your script." |
|
1464 | print "ipdb> prompt to start your script." | |
1465 | try: |
|
1465 | try: | |
1466 | deb.run('execfile("%s")' % filename,prog_ns) |
|
1466 | deb.run('execfile("%s")' % filename,prog_ns) | |
1467 | except: |
|
1467 | except: | |
1468 | etype, value, tb = sys.exc_info() |
|
1468 | etype, value, tb = sys.exc_info() | |
1469 | # Skip three frames in the traceback: the %run one, |
|
1469 | # Skip three frames in the traceback: the %run one, | |
1470 | # one inside bdb.py, and the command-line typed by the |
|
1470 | # one inside bdb.py, and the command-line typed by the | |
1471 | # user (run by exec in pdb itself). |
|
1471 | # user (run by exec in pdb itself). | |
1472 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) |
|
1472 | self.shell.InteractiveTB(etype,value,tb,tb_offset=3) | |
1473 | else: |
|
1473 | else: | |
1474 | if runner is None: |
|
1474 | if runner is None: | |
1475 | runner = self.shell.safe_execfile |
|
1475 | runner = self.shell.safe_execfile | |
1476 | if opts.has_key('t'): |
|
1476 | if opts.has_key('t'): | |
1477 | try: |
|
1477 | try: | |
1478 | nruns = int(opts['N'][0]) |
|
1478 | nruns = int(opts['N'][0]) | |
1479 | if nruns < 1: |
|
1479 | if nruns < 1: | |
1480 | error('Number of runs must be >=1') |
|
1480 | error('Number of runs must be >=1') | |
1481 | return |
|
1481 | return | |
1482 | except (KeyError): |
|
1482 | except (KeyError): | |
1483 | nruns = 1 |
|
1483 | nruns = 1 | |
1484 | if nruns == 1: |
|
1484 | if nruns == 1: | |
1485 | t0 = clock2() |
|
1485 | t0 = clock2() | |
1486 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1486 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1487 | t1 = clock2() |
|
1487 | t1 = clock2() | |
1488 | t_usr = t1[0]-t0[0] |
|
1488 | t_usr = t1[0]-t0[0] | |
1489 | t_sys = t1[1]-t1[1] |
|
1489 | t_sys = t1[1]-t1[1] | |
1490 | print "\nIPython CPU timings (estimated):" |
|
1490 | print "\nIPython CPU timings (estimated):" | |
1491 | print " User : %10s s." % t_usr |
|
1491 | print " User : %10s s." % t_usr | |
1492 | print " System: %10s s." % t_sys |
|
1492 | print " System: %10s s." % t_sys | |
1493 | else: |
|
1493 | else: | |
1494 | runs = range(nruns) |
|
1494 | runs = range(nruns) | |
1495 | t0 = clock2() |
|
1495 | t0 = clock2() | |
1496 | for nr in runs: |
|
1496 | for nr in runs: | |
1497 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1497 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1498 | t1 = clock2() |
|
1498 | t1 = clock2() | |
1499 | t_usr = t1[0]-t0[0] |
|
1499 | t_usr = t1[0]-t0[0] | |
1500 | t_sys = t1[1]-t1[1] |
|
1500 | t_sys = t1[1]-t1[1] | |
1501 | print "\nIPython CPU timings (estimated):" |
|
1501 | print "\nIPython CPU timings (estimated):" | |
1502 | print "Total runs performed:",nruns |
|
1502 | print "Total runs performed:",nruns | |
1503 | print " Times : %10s %10s" % ('Total','Per run') |
|
1503 | print " Times : %10s %10s" % ('Total','Per run') | |
1504 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) |
|
1504 | print " User : %10s s, %10s s." % (t_usr,t_usr/nruns) | |
1505 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) |
|
1505 | print " System: %10s s, %10s s." % (t_sys,t_sys/nruns) | |
1506 |
|
1506 | |||
1507 | else: |
|
1507 | else: | |
1508 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) |
|
1508 | runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore) | |
1509 | if opts.has_key('i'): |
|
1509 | if opts.has_key('i'): | |
1510 | self.shell.user_ns['__name__'] = __name__save |
|
1510 | self.shell.user_ns['__name__'] = __name__save | |
1511 | else: |
|
1511 | else: | |
1512 | # update IPython interactive namespace |
|
1512 | # update IPython interactive namespace | |
1513 | del prog_ns['__name__'] |
|
1513 | del prog_ns['__name__'] | |
1514 | self.shell.user_ns.update(prog_ns) |
|
1514 | self.shell.user_ns.update(prog_ns) | |
1515 | finally: |
|
1515 | finally: | |
1516 | sys.argv = save_argv |
|
1516 | sys.argv = save_argv | |
1517 | if restore_main: |
|
1517 | if restore_main: | |
1518 | sys.modules['__main__'] = restore_main |
|
1518 | sys.modules['__main__'] = restore_main | |
1519 | return stats |
|
1519 | return stats | |
1520 |
|
1520 | |||
1521 | def magic_runlog(self, parameter_s =''): |
|
1521 | def magic_runlog(self, parameter_s =''): | |
1522 | """Run files as logs. |
|
1522 | """Run files as logs. | |
1523 |
|
1523 | |||
1524 | Usage:\\ |
|
1524 | Usage:\\ | |
1525 | %runlog file1 file2 ... |
|
1525 | %runlog file1 file2 ... | |
1526 |
|
1526 | |||
1527 | Run the named files (treating them as log files) in sequence inside |
|
1527 | Run the named files (treating them as log files) in sequence inside | |
1528 | the interpreter, and return to the prompt. This is much slower than |
|
1528 | the interpreter, and return to the prompt. This is much slower than | |
1529 | %run because each line is executed in a try/except block, but it |
|
1529 | %run because each line is executed in a try/except block, but it | |
1530 | allows running files with syntax errors in them. |
|
1530 | allows running files with syntax errors in them. | |
1531 |
|
1531 | |||
1532 | Normally IPython will guess when a file is one of its own logfiles, so |
|
1532 | Normally IPython will guess when a file is one of its own logfiles, so | |
1533 | you can typically use %run even for logs. This shorthand allows you to |
|
1533 | you can typically use %run even for logs. This shorthand allows you to | |
1534 | force any file to be treated as a log file.""" |
|
1534 | force any file to be treated as a log file.""" | |
1535 |
|
1535 | |||
1536 | for f in parameter_s.split(): |
|
1536 | for f in parameter_s.split(): | |
1537 | self.shell.safe_execfile(f,self.shell.user_ns, |
|
1537 | self.shell.safe_execfile(f,self.shell.user_ns, | |
1538 | self.shell.user_ns,islog=1) |
|
1538 | self.shell.user_ns,islog=1) | |
1539 |
|
1539 | |||
1540 | def magic_time(self,parameter_s = ''): |
|
1540 | def magic_time(self,parameter_s = ''): | |
1541 | """Time execution of a Python statement or expression. |
|
1541 | """Time execution of a Python statement or expression. | |
1542 |
|
1542 | |||
1543 | The CPU and wall clock times are printed, and the value of the |
|
1543 | The CPU and wall clock times are printed, and the value of the | |
1544 | expression (if any) is returned. Note that under Win32, system time |
|
1544 | expression (if any) is returned. Note that under Win32, system time | |
1545 | is always reported as 0, since it can not be measured. |
|
1545 | is always reported as 0, since it can not be measured. | |
1546 |
|
1546 | |||
1547 | This function provides very basic timing functionality. In Python |
|
1547 | This function provides very basic timing functionality. In Python | |
1548 | 2.3, the timeit module offers more control and sophistication, but for |
|
1548 | 2.3, the timeit module offers more control and sophistication, but for | |
1549 | now IPython supports Python 2.2, so we can not rely on timeit being |
|
1549 | now IPython supports Python 2.2, so we can not rely on timeit being | |
1550 | present. |
|
1550 | present. | |
1551 |
|
1551 | |||
1552 | Some examples: |
|
1552 | Some examples: | |
1553 |
|
1553 | |||
1554 | In [1]: time 2**128 |
|
1554 | In [1]: time 2**128 | |
1555 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1555 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1556 | Wall time: 0.00 |
|
1556 | Wall time: 0.00 | |
1557 | Out[1]: 340282366920938463463374607431768211456L |
|
1557 | Out[1]: 340282366920938463463374607431768211456L | |
1558 |
|
1558 | |||
1559 | In [2]: n = 1000000 |
|
1559 | In [2]: n = 1000000 | |
1560 |
|
1560 | |||
1561 | In [3]: time sum(range(n)) |
|
1561 | In [3]: time sum(range(n)) | |
1562 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s |
|
1562 | CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s | |
1563 | Wall time: 1.37 |
|
1563 | Wall time: 1.37 | |
1564 | Out[3]: 499999500000L |
|
1564 | Out[3]: 499999500000L | |
1565 |
|
1565 | |||
1566 | In [4]: time print 'hello world' |
|
1566 | In [4]: time print 'hello world' | |
1567 | hello world |
|
1567 | hello world | |
1568 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1568 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1569 | Wall time: 0.00 |
|
1569 | Wall time: 0.00 | |
1570 | """ |
|
1570 | """ | |
1571 |
|
1571 | |||
1572 | # fail immediately if the given expression can't be compiled |
|
1572 | # fail immediately if the given expression can't be compiled | |
1573 | try: |
|
1573 | try: | |
1574 | mode = 'eval' |
|
1574 | mode = 'eval' | |
1575 | code = compile(parameter_s,'<timed eval>',mode) |
|
1575 | code = compile(parameter_s,'<timed eval>',mode) | |
1576 | except SyntaxError: |
|
1576 | except SyntaxError: | |
1577 | mode = 'exec' |
|
1577 | mode = 'exec' | |
1578 | code = compile(parameter_s,'<timed exec>',mode) |
|
1578 | code = compile(parameter_s,'<timed exec>',mode) | |
1579 | # skew measurement as little as possible |
|
1579 | # skew measurement as little as possible | |
1580 | glob = self.shell.user_ns |
|
1580 | glob = self.shell.user_ns | |
1581 | clk = clock2 |
|
1581 | clk = clock2 | |
1582 | wtime = time.time |
|
1582 | wtime = time.time | |
1583 | # time execution |
|
1583 | # time execution | |
1584 | wall_st = wtime() |
|
1584 | wall_st = wtime() | |
1585 | if mode=='eval': |
|
1585 | if mode=='eval': | |
1586 | st = clk() |
|
1586 | st = clk() | |
1587 | out = eval(code,glob) |
|
1587 | out = eval(code,glob) | |
1588 | end = clk() |
|
1588 | end = clk() | |
1589 | else: |
|
1589 | else: | |
1590 | st = clk() |
|
1590 | st = clk() | |
1591 | exec code in glob |
|
1591 | exec code in glob | |
1592 | end = clk() |
|
1592 | end = clk() | |
1593 | out = None |
|
1593 | out = None | |
1594 | wall_end = wtime() |
|
1594 | wall_end = wtime() | |
1595 | # Compute actual times and report |
|
1595 | # Compute actual times and report | |
1596 | wall_time = wall_end-wall_st |
|
1596 | wall_time = wall_end-wall_st | |
1597 | cpu_user = end[0]-st[0] |
|
1597 | cpu_user = end[0]-st[0] | |
1598 | cpu_sys = end[1]-st[1] |
|
1598 | cpu_sys = end[1]-st[1] | |
1599 | cpu_tot = cpu_user+cpu_sys |
|
1599 | cpu_tot = cpu_user+cpu_sys | |
1600 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ |
|
1600 | print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \ | |
1601 | (cpu_user,cpu_sys,cpu_tot) |
|
1601 | (cpu_user,cpu_sys,cpu_tot) | |
1602 | print "Wall time: %.2f" % wall_time |
|
1602 | print "Wall time: %.2f" % wall_time | |
1603 | return out |
|
1603 | return out | |
1604 |
|
1604 | |||
1605 | def magic_macro(self,parameter_s = ''): |
|
1605 | def magic_macro(self,parameter_s = ''): | |
1606 | """Define a set of input lines as a macro for future re-execution. |
|
1606 | """Define a set of input lines as a macro for future re-execution. | |
1607 |
|
1607 | |||
1608 | Usage:\\ |
|
1608 | Usage:\\ | |
1609 | %macro name n1-n2 n3-n4 ... n5 .. n6 ... |
|
1609 | %macro name n1-n2 n3-n4 ... n5 .. n6 ... | |
1610 |
|
1610 | |||
1611 | This will define a global variable called `name` which is a string |
|
1611 | This will define a global variable called `name` which is a string | |
1612 | made of joining the slices and lines you specify (n1,n2,... numbers |
|
1612 | made of joining the slices and lines you specify (n1,n2,... numbers | |
1613 | above) from your input history into a single string. This variable |
|
1613 | above) from your input history into a single string. This variable | |
1614 | acts like an automatic function which re-executes those lines as if |
|
1614 | acts like an automatic function which re-executes those lines as if | |
1615 | you had typed them. You just type 'name' at the prompt and the code |
|
1615 | you had typed them. You just type 'name' at the prompt and the code | |
1616 | executes. |
|
1616 | executes. | |
1617 |
|
1617 | |||
1618 | The notation for indicating number ranges is: n1-n2 means 'use line |
|
1618 | The notation for indicating number ranges is: n1-n2 means 'use line | |
1619 | numbers n1,...n2' (the endpoint is included). That is, '5-7' means |
|
1619 | numbers n1,...n2' (the endpoint is included). That is, '5-7' means | |
1620 | using the lines numbered 5,6 and 7. |
|
1620 | using the lines numbered 5,6 and 7. | |
1621 |
|
1621 | |||
1622 | Note: as a 'hidden' feature, you can also use traditional python slice |
|
1622 | Note: as a 'hidden' feature, you can also use traditional python slice | |
1623 | notation, where N:M means numbers N through M-1. |
|
1623 | notation, where N:M means numbers N through M-1. | |
1624 |
|
1624 | |||
1625 | For example, if your history contains (%hist prints it): |
|
1625 | For example, if your history contains (%hist prints it): | |
1626 |
|
1626 | |||
1627 | 44: x=1\\ |
|
1627 | 44: x=1\\ | |
1628 | 45: y=3\\ |
|
1628 | 45: y=3\\ | |
1629 | 46: z=x+y\\ |
|
1629 | 46: z=x+y\\ | |
1630 | 47: print x\\ |
|
1630 | 47: print x\\ | |
1631 | 48: a=5\\ |
|
1631 | 48: a=5\\ | |
1632 | 49: print 'x',x,'y',y\\ |
|
1632 | 49: print 'x',x,'y',y\\ | |
1633 |
|
1633 | |||
1634 | you can create a macro with lines 44 through 47 (included) and line 49 |
|
1634 | you can create a macro with lines 44 through 47 (included) and line 49 | |
1635 | called my_macro with: |
|
1635 | called my_macro with: | |
1636 |
|
1636 | |||
1637 | In [51]: %macro my_macro 44-47 49 |
|
1637 | In [51]: %macro my_macro 44-47 49 | |
1638 |
|
1638 | |||
1639 | Now, typing `my_macro` (without quotes) will re-execute all this code |
|
1639 | Now, typing `my_macro` (without quotes) will re-execute all this code | |
1640 | in one pass. |
|
1640 | in one pass. | |
1641 |
|
1641 | |||
1642 | You don't need to give the line-numbers in order, and any given line |
|
1642 | You don't need to give the line-numbers in order, and any given line | |
1643 | number can appear multiple times. You can assemble macros with any |
|
1643 | number can appear multiple times. You can assemble macros with any | |
1644 | lines from your input history in any order. |
|
1644 | lines from your input history in any order. | |
1645 |
|
1645 | |||
1646 | The macro is a simple object which holds its value in an attribute, |
|
1646 | The macro is a simple object which holds its value in an attribute, | |
1647 | but IPython's display system checks for macros and executes them as |
|
1647 | but IPython's display system checks for macros and executes them as | |
1648 | code instead of printing them when you type their name. |
|
1648 | code instead of printing them when you type their name. | |
1649 |
|
1649 | |||
1650 | You can view a macro's contents by explicitly printing it with: |
|
1650 | You can view a macro's contents by explicitly printing it with: | |
1651 |
|
1651 | |||
1652 | 'print macro_name'. |
|
1652 | 'print macro_name'. | |
1653 |
|
1653 | |||
1654 | For one-off cases which DON'T contain magic function calls in them you |
|
1654 | For one-off cases which DON'T contain magic function calls in them you | |
1655 | can obtain similar results by explicitly executing slices from your |
|
1655 | can obtain similar results by explicitly executing slices from your | |
1656 | input history with: |
|
1656 | input history with: | |
1657 |
|
1657 | |||
1658 | In [60]: exec In[44:48]+In[49]""" |
|
1658 | In [60]: exec In[44:48]+In[49]""" | |
1659 |
|
1659 | |||
1660 | args = parameter_s.split() |
|
1660 | args = parameter_s.split() | |
1661 | name,ranges = args[0], args[1:] |
|
1661 | name,ranges = args[0], args[1:] | |
1662 | #print 'rng',ranges # dbg |
|
1662 | #print 'rng',ranges # dbg | |
1663 | lines = self.extract_input_slices(ranges) |
|
1663 | lines = self.extract_input_slices(ranges) | |
1664 | macro = Macro(lines) |
|
1664 | macro = Macro(lines) | |
1665 | self.shell.user_ns.update({name:macro}) |
|
1665 | self.shell.user_ns.update({name:macro}) | |
1666 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name |
|
1666 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name | |
1667 | print 'Macro contents:' |
|
1667 | print 'Macro contents:' | |
1668 | print macro, |
|
1668 | print macro, | |
1669 |
|
1669 | |||
1670 | def magic_save(self,parameter_s = ''): |
|
1670 | def magic_save(self,parameter_s = ''): | |
1671 | """Save a set of lines to a given filename. |
|
1671 | """Save a set of lines to a given filename. | |
1672 |
|
1672 | |||
1673 | Usage:\\ |
|
1673 | Usage:\\ | |
1674 | %save filename n1-n2 n3-n4 ... n5 .. n6 ... |
|
1674 | %save filename n1-n2 n3-n4 ... n5 .. n6 ... | |
1675 |
|
1675 | |||
1676 | This function uses the same syntax as %macro for line extraction, but |
|
1676 | This function uses the same syntax as %macro for line extraction, but | |
1677 | instead of creating a macro it saves the resulting string to the |
|
1677 | instead of creating a macro it saves the resulting string to the | |
1678 | filename you specify. |
|
1678 | filename you specify. | |
1679 |
|
1679 | |||
1680 | It adds a '.py' extension to the file if you don't do so yourself, and |
|
1680 | It adds a '.py' extension to the file if you don't do so yourself, and | |
1681 | it asks for confirmation before overwriting existing files.""" |
|
1681 | it asks for confirmation before overwriting existing files.""" | |
1682 |
|
1682 | |||
1683 | args = parameter_s.split() |
|
1683 | args = parameter_s.split() | |
1684 | fname,ranges = args[0], args[1:] |
|
1684 | fname,ranges = args[0], args[1:] | |
1685 | if not fname.endswith('.py'): |
|
1685 | if not fname.endswith('.py'): | |
1686 | fname += '.py' |
|
1686 | fname += '.py' | |
1687 | if os.path.isfile(fname): |
|
1687 | if os.path.isfile(fname): | |
1688 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) |
|
1688 | ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname) | |
1689 | if ans.lower() not in ['y','yes']: |
|
1689 | if ans.lower() not in ['y','yes']: | |
1690 | print 'Operation cancelled.' |
|
1690 | print 'Operation cancelled.' | |
1691 | return |
|
1691 | return | |
1692 | cmds = ''.join(self.extract_input_slices(ranges)) |
|
1692 | cmds = ''.join(self.extract_input_slices(ranges)) | |
1693 | f = file(fname,'w') |
|
1693 | f = file(fname,'w') | |
1694 | f.write(cmds) |
|
1694 | f.write(cmds) | |
1695 | f.close() |
|
1695 | f.close() | |
1696 | print 'The following commands were written to file `%s`:' % fname |
|
1696 | print 'The following commands were written to file `%s`:' % fname | |
1697 | print cmds |
|
1697 | print cmds | |
1698 |
|
1698 | |||
1699 | def _edit_macro(self,mname,macro): |
|
1699 | def _edit_macro(self,mname,macro): | |
1700 | """open an editor with the macro data in a file""" |
|
1700 | """open an editor with the macro data in a file""" | |
1701 | filename = self.shell.mktempfile(macro.value) |
|
1701 | filename = self.shell.mktempfile(macro.value) | |
1702 | self.shell.hooks.editor(filename) |
|
1702 | self.shell.hooks.editor(filename) | |
1703 |
|
1703 | |||
1704 | # and make a new macro object, to replace the old one |
|
1704 | # and make a new macro object, to replace the old one | |
1705 | mfile = open(filename) |
|
1705 | mfile = open(filename) | |
1706 | mvalue = mfile.read() |
|
1706 | mvalue = mfile.read() | |
1707 | mfile.close() |
|
1707 | mfile.close() | |
1708 | self.shell.user_ns[mname] = Macro(mvalue) |
|
1708 | self.shell.user_ns[mname] = Macro(mvalue) | |
1709 |
|
1709 | |||
1710 | def magic_ed(self,parameter_s=''): |
|
1710 | def magic_ed(self,parameter_s=''): | |
1711 | """Alias to %edit.""" |
|
1711 | """Alias to %edit.""" | |
1712 | return self.magic_edit(parameter_s) |
|
1712 | return self.magic_edit(parameter_s) | |
1713 |
|
1713 | |||
1714 | def magic_edit(self,parameter_s='',last_call=['','']): |
|
1714 | def magic_edit(self,parameter_s='',last_call=['','']): | |
1715 | """Bring up an editor and execute the resulting code. |
|
1715 | """Bring up an editor and execute the resulting code. | |
1716 |
|
1716 | |||
1717 | Usage: |
|
1717 | Usage: | |
1718 | %edit [options] [args] |
|
1718 | %edit [options] [args] | |
1719 |
|
1719 | |||
1720 | %edit runs IPython's editor hook. The default version of this hook is |
|
1720 | %edit runs IPython's editor hook. The default version of this hook is | |
1721 | set to call the __IPYTHON__.rc.editor command. This is read from your |
|
1721 | set to call the __IPYTHON__.rc.editor command. This is read from your | |
1722 | environment variable $EDITOR. If this isn't found, it will default to |
|
1722 | environment variable $EDITOR. If this isn't found, it will default to | |
1723 | vi under Linux/Unix and to notepad under Windows. See the end of this |
|
1723 | vi under Linux/Unix and to notepad under Windows. See the end of this | |
1724 | docstring for how to change the editor hook. |
|
1724 | docstring for how to change the editor hook. | |
1725 |
|
1725 | |||
1726 | You can also set the value of this editor via the command line option |
|
1726 | You can also set the value of this editor via the command line option | |
1727 | '-editor' or in your ipythonrc file. This is useful if you wish to use |
|
1727 | '-editor' or in your ipythonrc file. This is useful if you wish to use | |
1728 | specifically for IPython an editor different from your typical default |
|
1728 | specifically for IPython an editor different from your typical default | |
1729 | (and for Windows users who typically don't set environment variables). |
|
1729 | (and for Windows users who typically don't set environment variables). | |
1730 |
|
1730 | |||
1731 | This command allows you to conveniently edit multi-line code right in |
|
1731 | This command allows you to conveniently edit multi-line code right in | |
1732 | your IPython session. |
|
1732 | your IPython session. | |
1733 |
|
1733 | |||
1734 | If called without arguments, %edit opens up an empty editor with a |
|
1734 | If called without arguments, %edit opens up an empty editor with a | |
1735 | temporary file and will execute the contents of this file when you |
|
1735 | temporary file and will execute the contents of this file when you | |
1736 | close it (don't forget to save it!). |
|
1736 | close it (don't forget to save it!). | |
1737 |
|
1737 | |||
1738 |
|
1738 | |||
1739 | Options: |
|
1739 | Options: | |
1740 |
|
1740 | |||
1741 | -p: this will call the editor with the same data as the previous time |
|
1741 | -p: this will call the editor with the same data as the previous time | |
1742 | it was used, regardless of how long ago (in your current session) it |
|
1742 | it was used, regardless of how long ago (in your current session) it | |
1743 | was. |
|
1743 | was. | |
1744 |
|
1744 | |||
1745 | -x: do not execute the edited code immediately upon exit. This is |
|
1745 | -x: do not execute the edited code immediately upon exit. This is | |
1746 | mainly useful if you are editing programs which need to be called with |
|
1746 | mainly useful if you are editing programs which need to be called with | |
1747 | command line arguments, which you can then do using %run. |
|
1747 | command line arguments, which you can then do using %run. | |
1748 |
|
1748 | |||
1749 |
|
1749 | |||
1750 | Arguments: |
|
1750 | Arguments: | |
1751 |
|
1751 | |||
1752 | If arguments are given, the following possibilites exist: |
|
1752 | If arguments are given, the following possibilites exist: | |
1753 |
|
1753 | |||
1754 | - The arguments are numbers or pairs of colon-separated numbers (like |
|
1754 | - The arguments are numbers or pairs of colon-separated numbers (like | |
1755 | 1 4:8 9). These are interpreted as lines of previous input to be |
|
1755 | 1 4:8 9). These are interpreted as lines of previous input to be | |
1756 | loaded into the editor. The syntax is the same of the %macro command. |
|
1756 | loaded into the editor. The syntax is the same of the %macro command. | |
1757 |
|
1757 | |||
1758 | - If the argument doesn't start with a number, it is evaluated as a |
|
1758 | - If the argument doesn't start with a number, it is evaluated as a | |
1759 | variable and its contents loaded into the editor. You can thus edit |
|
1759 | variable and its contents loaded into the editor. You can thus edit | |
1760 | any string which contains python code (including the result of |
|
1760 | any string which contains python code (including the result of | |
1761 | previous edits). |
|
1761 | previous edits). | |
1762 |
|
1762 | |||
1763 | - If the argument is the name of an object (other than a string), |
|
1763 | - If the argument is the name of an object (other than a string), | |
1764 | IPython will try to locate the file where it was defined and open the |
|
1764 | IPython will try to locate the file where it was defined and open the | |
1765 | editor at the point where it is defined. You can use `%edit function` |
|
1765 | editor at the point where it is defined. You can use `%edit function` | |
1766 | to load an editor exactly at the point where 'function' is defined, |
|
1766 | to load an editor exactly at the point where 'function' is defined, | |
1767 | edit it and have the file be executed automatically. |
|
1767 | edit it and have the file be executed automatically. | |
1768 |
|
1768 | |||
1769 | If the object is a macro (see %macro for details), this opens up your |
|
1769 | If the object is a macro (see %macro for details), this opens up your | |
1770 | specified editor with a temporary file containing the macro's data. |
|
1770 | specified editor with a temporary file containing the macro's data. | |
1771 | Upon exit, the macro is reloaded with the contents of the file. |
|
1771 | Upon exit, the macro is reloaded with the contents of the file. | |
1772 |
|
1772 | |||
1773 | Note: opening at an exact line is only supported under Unix, and some |
|
1773 | Note: opening at an exact line is only supported under Unix, and some | |
1774 | editors (like kedit and gedit up to Gnome 2.8) do not understand the |
|
1774 | editors (like kedit and gedit up to Gnome 2.8) do not understand the | |
1775 | '+NUMBER' parameter necessary for this feature. Good editors like |
|
1775 | '+NUMBER' parameter necessary for this feature. Good editors like | |
1776 | (X)Emacs, vi, jed, pico and joe all do. |
|
1776 | (X)Emacs, vi, jed, pico and joe all do. | |
1777 |
|
1777 | |||
1778 | - If the argument is not found as a variable, IPython will look for a |
|
1778 | - If the argument is not found as a variable, IPython will look for a | |
1779 | file with that name (adding .py if necessary) and load it into the |
|
1779 | file with that name (adding .py if necessary) and load it into the | |
1780 | editor. It will execute its contents with execfile() when you exit, |
|
1780 | editor. It will execute its contents with execfile() when you exit, | |
1781 | loading any code in the file into your interactive namespace. |
|
1781 | loading any code in the file into your interactive namespace. | |
1782 |
|
1782 | |||
1783 | After executing your code, %edit will return as output the code you |
|
1783 | After executing your code, %edit will return as output the code you | |
1784 | typed in the editor (except when it was an existing file). This way |
|
1784 | typed in the editor (except when it was an existing file). This way | |
1785 | you can reload the code in further invocations of %edit as a variable, |
|
1785 | you can reload the code in further invocations of %edit as a variable, | |
1786 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of |
|
1786 | via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of | |
1787 | the output. |
|
1787 | the output. | |
1788 |
|
1788 | |||
1789 | Note that %edit is also available through the alias %ed. |
|
1789 | Note that %edit is also available through the alias %ed. | |
1790 |
|
1790 | |||
1791 | This is an example of creating a simple function inside the editor and |
|
1791 | This is an example of creating a simple function inside the editor and | |
1792 | then modifying it. First, start up the editor: |
|
1792 | then modifying it. First, start up the editor: | |
1793 |
|
1793 | |||
1794 | In [1]: ed\\ |
|
1794 | In [1]: ed\\ | |
1795 | Editing... done. Executing edited code...\\ |
|
1795 | Editing... done. Executing edited code...\\ | |
1796 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' |
|
1796 | Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n' | |
1797 |
|
1797 | |||
1798 | We can then call the function foo(): |
|
1798 | We can then call the function foo(): | |
1799 |
|
1799 | |||
1800 | In [2]: foo()\\ |
|
1800 | In [2]: foo()\\ | |
1801 | foo() was defined in an editing session |
|
1801 | foo() was defined in an editing session | |
1802 |
|
1802 | |||
1803 | Now we edit foo. IPython automatically loads the editor with the |
|
1803 | Now we edit foo. IPython automatically loads the editor with the | |
1804 | (temporary) file where foo() was previously defined: |
|
1804 | (temporary) file where foo() was previously defined: | |
1805 |
|
1805 | |||
1806 | In [3]: ed foo\\ |
|
1806 | In [3]: ed foo\\ | |
1807 | Editing... done. Executing edited code... |
|
1807 | Editing... done. Executing edited code... | |
1808 |
|
1808 | |||
1809 | And if we call foo() again we get the modified version: |
|
1809 | And if we call foo() again we get the modified version: | |
1810 |
|
1810 | |||
1811 | In [4]: foo()\\ |
|
1811 | In [4]: foo()\\ | |
1812 | foo() has now been changed! |
|
1812 | foo() has now been changed! | |
1813 |
|
1813 | |||
1814 | Here is an example of how to edit a code snippet successive |
|
1814 | Here is an example of how to edit a code snippet successive | |
1815 | times. First we call the editor: |
|
1815 | times. First we call the editor: | |
1816 |
|
1816 | |||
1817 | In [8]: ed\\ |
|
1817 | In [8]: ed\\ | |
1818 | Editing... done. Executing edited code...\\ |
|
1818 | Editing... done. Executing edited code...\\ | |
1819 | hello\\ |
|
1819 | hello\\ | |
1820 | Out[8]: "print 'hello'\\n" |
|
1820 | Out[8]: "print 'hello'\\n" | |
1821 |
|
1821 | |||
1822 | Now we call it again with the previous output (stored in _): |
|
1822 | Now we call it again with the previous output (stored in _): | |
1823 |
|
1823 | |||
1824 | In [9]: ed _\\ |
|
1824 | In [9]: ed _\\ | |
1825 | Editing... done. Executing edited code...\\ |
|
1825 | Editing... done. Executing edited code...\\ | |
1826 | hello world\\ |
|
1826 | hello world\\ | |
1827 | Out[9]: "print 'hello world'\\n" |
|
1827 | Out[9]: "print 'hello world'\\n" | |
1828 |
|
1828 | |||
1829 | Now we call it with the output #8 (stored in _8, also as Out[8]): |
|
1829 | Now we call it with the output #8 (stored in _8, also as Out[8]): | |
1830 |
|
1830 | |||
1831 | In [10]: ed _8\\ |
|
1831 | In [10]: ed _8\\ | |
1832 | Editing... done. Executing edited code...\\ |
|
1832 | Editing... done. Executing edited code...\\ | |
1833 | hello again\\ |
|
1833 | hello again\\ | |
1834 | Out[10]: "print 'hello again'\\n" |
|
1834 | Out[10]: "print 'hello again'\\n" | |
1835 |
|
1835 | |||
1836 |
|
1836 | |||
1837 | Changing the default editor hook: |
|
1837 | Changing the default editor hook: | |
1838 |
|
1838 | |||
1839 | If you wish to write your own editor hook, you can put it in a |
|
1839 | If you wish to write your own editor hook, you can put it in a | |
1840 | configuration file which you load at startup time. The default hook |
|
1840 | configuration file which you load at startup time. The default hook | |
1841 | is defined in the IPython.hooks module, and you can use that as a |
|
1841 | is defined in the IPython.hooks module, and you can use that as a | |
1842 | starting example for further modifications. That file also has |
|
1842 | starting example for further modifications. That file also has | |
1843 | general instructions on how to set a new hook for use once you've |
|
1843 | general instructions on how to set a new hook for use once you've | |
1844 | defined it.""" |
|
1844 | defined it.""" | |
1845 |
|
1845 | |||
1846 | # FIXME: This function has become a convoluted mess. It needs a |
|
1846 | # FIXME: This function has become a convoluted mess. It needs a | |
1847 | # ground-up rewrite with clean, simple logic. |
|
1847 | # ground-up rewrite with clean, simple logic. | |
1848 |
|
1848 | |||
1849 | def make_filename(arg): |
|
1849 | def make_filename(arg): | |
1850 | "Make a filename from the given args" |
|
1850 | "Make a filename from the given args" | |
1851 | try: |
|
1851 | try: | |
1852 | filename = get_py_filename(arg) |
|
1852 | filename = get_py_filename(arg) | |
1853 | except IOError: |
|
1853 | except IOError: | |
1854 | if args.endswith('.py'): |
|
1854 | if args.endswith('.py'): | |
1855 | filename = arg |
|
1855 | filename = arg | |
1856 | else: |
|
1856 | else: | |
1857 | filename = None |
|
1857 | filename = None | |
1858 | return filename |
|
1858 | return filename | |
1859 |
|
1859 | |||
1860 | # custom exceptions |
|
1860 | # custom exceptions | |
1861 | class DataIsObject(Exception): pass |
|
1861 | class DataIsObject(Exception): pass | |
1862 |
|
1862 | |||
1863 | opts,args = self.parse_options(parameter_s,'px') |
|
1863 | opts,args = self.parse_options(parameter_s,'px') | |
1864 |
|
1864 | |||
1865 | # Default line number value |
|
1865 | # Default line number value | |
1866 | lineno = None |
|
1866 | lineno = None | |
1867 | if opts.has_key('p'): |
|
1867 | if opts.has_key('p'): | |
1868 | args = '_%s' % last_call[0] |
|
1868 | args = '_%s' % last_call[0] | |
1869 | if not self.shell.user_ns.has_key(args): |
|
1869 | if not self.shell.user_ns.has_key(args): | |
1870 | args = last_call[1] |
|
1870 | args = last_call[1] | |
1871 |
|
1871 | |||
1872 | # use last_call to remember the state of the previous call, but don't |
|
1872 | # use last_call to remember the state of the previous call, but don't | |
1873 | # let it be clobbered by successive '-p' calls. |
|
1873 | # let it be clobbered by successive '-p' calls. | |
1874 | try: |
|
1874 | try: | |
1875 | last_call[0] = self.shell.outputcache.prompt_count |
|
1875 | last_call[0] = self.shell.outputcache.prompt_count | |
1876 | if not opts.has_key('p'): |
|
1876 | if not opts.has_key('p'): | |
1877 | last_call[1] = parameter_s |
|
1877 | last_call[1] = parameter_s | |
1878 | except: |
|
1878 | except: | |
1879 | pass |
|
1879 | pass | |
1880 |
|
1880 | |||
1881 | # by default this is done with temp files, except when the given |
|
1881 | # by default this is done with temp files, except when the given | |
1882 | # arg is a filename |
|
1882 | # arg is a filename | |
1883 | use_temp = 1 |
|
1883 | use_temp = 1 | |
1884 |
|
1884 | |||
1885 | if re.match(r'\d',args): |
|
1885 | if re.match(r'\d',args): | |
1886 | # Mode where user specifies ranges of lines, like in %macro. |
|
1886 | # Mode where user specifies ranges of lines, like in %macro. | |
1887 | # This means that you can't edit files whose names begin with |
|
1887 | # This means that you can't edit files whose names begin with | |
1888 | # numbers this way. Tough. |
|
1888 | # numbers this way. Tough. | |
1889 | ranges = args.split() |
|
1889 | ranges = args.split() | |
1890 | data = ''.join(self.extract_input_slices(ranges)) |
|
1890 | data = ''.join(self.extract_input_slices(ranges)) | |
1891 | elif args.endswith('.py'): |
|
1891 | elif args.endswith('.py'): | |
1892 | filename = make_filename(args) |
|
1892 | filename = make_filename(args) | |
1893 | data = '' |
|
1893 | data = '' | |
1894 | use_temp = 0 |
|
1894 | use_temp = 0 | |
1895 | elif args: |
|
1895 | elif args: | |
1896 | try: |
|
1896 | try: | |
1897 | # Load the parameter given as a variable. If not a string, |
|
1897 | # Load the parameter given as a variable. If not a string, | |
1898 | # process it as an object instead (below) |
|
1898 | # process it as an object instead (below) | |
1899 |
|
1899 | |||
1900 | #print '*** args',args,'type',type(args) # dbg |
|
1900 | #print '*** args',args,'type',type(args) # dbg | |
1901 | data = eval(args,self.shell.user_ns) |
|
1901 | data = eval(args,self.shell.user_ns) | |
1902 | if not type(data) in StringTypes: |
|
1902 | if not type(data) in StringTypes: | |
1903 | raise DataIsObject |
|
1903 | raise DataIsObject | |
1904 |
|
1904 | |||
1905 | except (NameError,SyntaxError): |
|
1905 | except (NameError,SyntaxError): | |
1906 | # given argument is not a variable, try as a filename |
|
1906 | # given argument is not a variable, try as a filename | |
1907 | filename = make_filename(args) |
|
1907 | filename = make_filename(args) | |
1908 | if filename is None: |
|
1908 | if filename is None: | |
1909 | warn("Argument given (%s) can't be found as a variable " |
|
1909 | warn("Argument given (%s) can't be found as a variable " | |
1910 | "or as a filename." % args) |
|
1910 | "or as a filename." % args) | |
1911 | return |
|
1911 | return | |
1912 |
|
1912 | |||
1913 | data = '' |
|
1913 | data = '' | |
1914 | use_temp = 0 |
|
1914 | use_temp = 0 | |
1915 | except DataIsObject: |
|
1915 | except DataIsObject: | |
1916 |
|
1916 | |||
1917 | # macros have a special edit function |
|
1917 | # macros have a special edit function | |
1918 | if isinstance(data,Macro): |
|
1918 | if isinstance(data,Macro): | |
1919 | self._edit_macro(args,data) |
|
1919 | self._edit_macro(args,data) | |
1920 | return |
|
1920 | return | |
1921 |
|
1921 | |||
1922 | # For objects, try to edit the file where they are defined |
|
1922 | # For objects, try to edit the file where they are defined | |
1923 | try: |
|
1923 | try: | |
1924 | filename = inspect.getabsfile(data) |
|
1924 | filename = inspect.getabsfile(data) | |
1925 | datafile = 1 |
|
1925 | datafile = 1 | |
1926 | except TypeError: |
|
1926 | except TypeError: | |
1927 | filename = make_filename(args) |
|
1927 | filename = make_filename(args) | |
1928 | datafile = 1 |
|
1928 | datafile = 1 | |
1929 | warn('Could not find file where `%s` is defined.\n' |
|
1929 | warn('Could not find file where `%s` is defined.\n' | |
1930 | 'Opening a file named `%s`' % (args,filename)) |
|
1930 | 'Opening a file named `%s`' % (args,filename)) | |
1931 | # Now, make sure we can actually read the source (if it was in |
|
1931 | # Now, make sure we can actually read the source (if it was in | |
1932 | # a temp file it's gone by now). |
|
1932 | # a temp file it's gone by now). | |
1933 | if datafile: |
|
1933 | if datafile: | |
1934 | try: |
|
1934 | try: | |
1935 | lineno = inspect.getsourcelines(data)[1] |
|
1935 | lineno = inspect.getsourcelines(data)[1] | |
1936 | except IOError: |
|
1936 | except IOError: | |
1937 | filename = make_filename(args) |
|
1937 | filename = make_filename(args) | |
1938 | if filename is None: |
|
1938 | if filename is None: | |
1939 | warn('The file `%s` where `%s` was defined cannot ' |
|
1939 | warn('The file `%s` where `%s` was defined cannot ' | |
1940 | 'be read.' % (filename,data)) |
|
1940 | 'be read.' % (filename,data)) | |
1941 | return |
|
1941 | return | |
1942 | use_temp = 0 |
|
1942 | use_temp = 0 | |
1943 | else: |
|
1943 | else: | |
1944 | data = '' |
|
1944 | data = '' | |
1945 |
|
1945 | |||
1946 | if use_temp: |
|
1946 | if use_temp: | |
1947 | filename = self.shell.mktempfile(data) |
|
1947 | filename = self.shell.mktempfile(data) | |
1948 | print 'IPython will make a temporary file named:',filename |
|
1948 | print 'IPython will make a temporary file named:',filename | |
1949 |
|
1949 | |||
1950 | # do actual editing here |
|
1950 | # do actual editing here | |
1951 | print 'Editing...', |
|
1951 | print 'Editing...', | |
1952 | sys.stdout.flush() |
|
1952 | sys.stdout.flush() | |
1953 | self.shell.hooks.editor(filename,lineno) |
|
1953 | self.shell.hooks.editor(filename,lineno) | |
1954 | if opts.has_key('x'): # -x prevents actual execution |
|
1954 | if opts.has_key('x'): # -x prevents actual execution | |
1955 |
|
1955 | |||
1956 | else: |
|
1956 | else: | |
1957 | print 'done. Executing edited code...' |
|
1957 | print 'done. Executing edited code...' | |
1958 | self.shell.safe_execfile(filename,self.shell.user_ns) |
|
1958 | self.shell.safe_execfile(filename,self.shell.user_ns) | |
1959 | if use_temp: |
|
1959 | if use_temp: | |
1960 | try: |
|
1960 | try: | |
1961 | return open(filename).read() |
|
1961 | return open(filename).read() | |
1962 | except IOError,msg: |
|
1962 | except IOError,msg: | |
1963 | if msg.filename == filename: |
|
1963 | if msg.filename == filename: | |
1964 | warn('File not found. Did you forget to save?') |
|
1964 | warn('File not found. Did you forget to save?') | |
1965 | return |
|
1965 | return | |
1966 | else: |
|
1966 | else: | |
1967 | self.shell.showtraceback() |
|
1967 | self.shell.showtraceback() | |
1968 |
|
1968 | |||
1969 | def magic_xmode(self,parameter_s = ''): |
|
1969 | def magic_xmode(self,parameter_s = ''): | |
1970 | """Switch modes for the exception handlers. |
|
1970 | """Switch modes for the exception handlers. | |
1971 |
|
1971 | |||
1972 | Valid modes: Plain, Context and Verbose. |
|
1972 | Valid modes: Plain, Context and Verbose. | |
1973 |
|
1973 | |||
1974 | If called without arguments, acts as a toggle.""" |
|
1974 | If called without arguments, acts as a toggle.""" | |
1975 |
|
1975 | |||
1976 | def xmode_switch_err(name): |
|
1976 | def xmode_switch_err(name): | |
1977 | warn('Error changing %s exception modes.\n%s' % |
|
1977 | warn('Error changing %s exception modes.\n%s' % | |
1978 | (name,sys.exc_info()[1])) |
|
1978 | (name,sys.exc_info()[1])) | |
1979 |
|
1979 | |||
1980 | shell = self.shell |
|
1980 | shell = self.shell | |
1981 | new_mode = parameter_s.strip().capitalize() |
|
1981 | new_mode = parameter_s.strip().capitalize() | |
1982 | try: |
|
1982 | try: | |
1983 | shell.InteractiveTB.set_mode(mode=new_mode) |
|
1983 | shell.InteractiveTB.set_mode(mode=new_mode) | |
1984 | print 'Exception reporting mode:',shell.InteractiveTB.mode |
|
1984 | print 'Exception reporting mode:',shell.InteractiveTB.mode | |
1985 | except: |
|
1985 | except: | |
1986 | xmode_switch_err('user') |
|
1986 | xmode_switch_err('user') | |
1987 |
|
1987 | |||
1988 | # threaded shells use a special handler in sys.excepthook |
|
1988 | # threaded shells use a special handler in sys.excepthook | |
1989 | if shell.isthreaded: |
|
1989 | if shell.isthreaded: | |
1990 | try: |
|
1990 | try: | |
1991 | shell.sys_excepthook.set_mode(mode=new_mode) |
|
1991 | shell.sys_excepthook.set_mode(mode=new_mode) | |
1992 | except: |
|
1992 | except: | |
1993 | xmode_switch_err('threaded') |
|
1993 | xmode_switch_err('threaded') | |
1994 |
|
1994 | |||
1995 | def magic_colors(self,parameter_s = ''): |
|
1995 | def magic_colors(self,parameter_s = ''): | |
1996 | """Switch color scheme for prompts, info system and exception handlers. |
|
1996 | """Switch color scheme for prompts, info system and exception handlers. | |
1997 |
|
1997 | |||
1998 | Currently implemented schemes: NoColor, Linux, LightBG. |
|
1998 | Currently implemented schemes: NoColor, Linux, LightBG. | |
1999 |
|
1999 | |||
2000 | Color scheme names are not case-sensitive.""" |
|
2000 | Color scheme names are not case-sensitive.""" | |
2001 |
|
2001 | |||
2002 | def color_switch_err(name): |
|
2002 | def color_switch_err(name): | |
2003 | warn('Error changing %s color schemes.\n%s' % |
|
2003 | warn('Error changing %s color schemes.\n%s' % | |
2004 | (name,sys.exc_info()[1])) |
|
2004 | (name,sys.exc_info()[1])) | |
2005 |
|
2005 | |||
2006 |
|
2006 | |||
2007 | new_scheme = parameter_s.strip() |
|
2007 | new_scheme = parameter_s.strip() | |
2008 | if not new_scheme: |
|
2008 | if not new_scheme: | |
2009 | print 'You must specify a color scheme.' |
|
2009 | print 'You must specify a color scheme.' | |
2010 | return |
|
2010 | return | |
2011 | import IPython.rlineimpl as readline |
|
2011 | import IPython.rlineimpl as readline | |
2012 | if not readline.have_readline: |
|
2012 | if not readline.have_readline: | |
2013 | msg = """\ |
|
2013 | msg = """\ | |
2014 | Proper color support under MS Windows requires Gary Bishop's readline library. |
|
2014 | Proper color support under MS Windows requires Gary Bishop's readline library. | |
2015 | You can find it at: |
|
2015 | You can find it at: | |
2016 | http://sourceforge.net/projects/uncpythontools |
|
2016 | http://sourceforge.net/projects/uncpythontools | |
2017 | Gary's readline needs the ctypes module, from: |
|
2017 | Gary's readline needs the ctypes module, from: | |
2018 | http://starship.python.net/crew/theller/ctypes |
|
2018 | http://starship.python.net/crew/theller/ctypes | |
2019 |
|
2019 | |||
2020 | Defaulting color scheme to 'NoColor'""" |
|
2020 | Defaulting color scheme to 'NoColor'""" | |
2021 | new_scheme = 'NoColor' |
|
2021 | new_scheme = 'NoColor' | |
2022 | warn(msg) |
|
2022 | warn(msg) | |
2023 | # local shortcut |
|
2023 | # local shortcut | |
2024 | shell = self.shell |
|
2024 | shell = self.shell | |
2025 |
|
2025 | |||
2026 | # Set prompt colors |
|
2026 | # Set prompt colors | |
2027 | try: |
|
2027 | try: | |
2028 | shell.outputcache.set_colors(new_scheme) |
|
2028 | shell.outputcache.set_colors(new_scheme) | |
2029 | except: |
|
2029 | except: | |
2030 | color_switch_err('prompt') |
|
2030 | color_switch_err('prompt') | |
2031 | else: |
|
2031 | else: | |
2032 | shell.rc.colors = \ |
|
2032 | shell.rc.colors = \ | |
2033 | shell.outputcache.color_table.active_scheme_name |
|
2033 | shell.outputcache.color_table.active_scheme_name | |
2034 | # Set exception colors |
|
2034 | # Set exception colors | |
2035 | try: |
|
2035 | try: | |
2036 | shell.InteractiveTB.set_colors(scheme = new_scheme) |
|
2036 | shell.InteractiveTB.set_colors(scheme = new_scheme) | |
2037 | shell.SyntaxTB.set_colors(scheme = new_scheme) |
|
2037 | shell.SyntaxTB.set_colors(scheme = new_scheme) | |
2038 | except: |
|
2038 | except: | |
2039 | color_switch_err('exception') |
|
2039 | color_switch_err('exception') | |
2040 |
|
2040 | |||
2041 | # threaded shells use a verbose traceback in sys.excepthook |
|
2041 | # threaded shells use a verbose traceback in sys.excepthook | |
2042 | if shell.isthreaded: |
|
2042 | if shell.isthreaded: | |
2043 | try: |
|
2043 | try: | |
2044 | shell.sys_excepthook.set_colors(scheme=new_scheme) |
|
2044 | shell.sys_excepthook.set_colors(scheme=new_scheme) | |
2045 | except: |
|
2045 | except: | |
2046 | color_switch_err('system exception handler') |
|
2046 | color_switch_err('system exception handler') | |
2047 |
|
2047 | |||
2048 | # Set info (for 'object?') colors |
|
2048 | # Set info (for 'object?') colors | |
2049 | if shell.rc.color_info: |
|
2049 | if shell.rc.color_info: | |
2050 | try: |
|
2050 | try: | |
2051 | shell.inspector.set_active_scheme(new_scheme) |
|
2051 | shell.inspector.set_active_scheme(new_scheme) | |
2052 | except: |
|
2052 | except: | |
2053 | color_switch_err('object inspector') |
|
2053 | color_switch_err('object inspector') | |
2054 | else: |
|
2054 | else: | |
2055 | shell.inspector.set_active_scheme('NoColor') |
|
2055 | shell.inspector.set_active_scheme('NoColor') | |
2056 |
|
2056 | |||
2057 | def magic_color_info(self,parameter_s = ''): |
|
2057 | def magic_color_info(self,parameter_s = ''): | |
2058 | """Toggle color_info. |
|
2058 | """Toggle color_info. | |
2059 |
|
2059 | |||
2060 | The color_info configuration parameter controls whether colors are |
|
2060 | The color_info configuration parameter controls whether colors are | |
2061 | used for displaying object details (by things like %psource, %pfile or |
|
2061 | used for displaying object details (by things like %psource, %pfile or | |
2062 | the '?' system). This function toggles this value with each call. |
|
2062 | the '?' system). This function toggles this value with each call. | |
2063 |
|
2063 | |||
2064 | Note that unless you have a fairly recent pager (less works better |
|
2064 | Note that unless you have a fairly recent pager (less works better | |
2065 | than more) in your system, using colored object information displays |
|
2065 | than more) in your system, using colored object information displays | |
2066 | will not work properly. Test it and see.""" |
|
2066 | will not work properly. Test it and see.""" | |
2067 |
|
2067 | |||
2068 | self.shell.rc.color_info = 1 - self.shell.rc.color_info |
|
2068 | self.shell.rc.color_info = 1 - self.shell.rc.color_info | |
2069 | self.magic_colors(self.shell.rc.colors) |
|
2069 | self.magic_colors(self.shell.rc.colors) | |
2070 | print 'Object introspection functions have now coloring:', |
|
2070 | print 'Object introspection functions have now coloring:', | |
2071 | print ['OFF','ON'][self.shell.rc.color_info] |
|
2071 | print ['OFF','ON'][self.shell.rc.color_info] | |
2072 |
|
2072 | |||
2073 | def magic_Pprint(self, parameter_s=''): |
|
2073 | def magic_Pprint(self, parameter_s=''): | |
2074 | """Toggle pretty printing on/off.""" |
|
2074 | """Toggle pretty printing on/off.""" | |
2075 |
|
2075 | |||
2076 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint |
|
2076 | self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint | |
2077 | print 'Pretty printing has been turned', \ |
|
2077 | print 'Pretty printing has been turned', \ | |
2078 | ['OFF','ON'][self.shell.outputcache.Pprint] |
|
2078 | ['OFF','ON'][self.shell.outputcache.Pprint] | |
2079 |
|
2079 | |||
2080 | def magic_exit(self, parameter_s=''): |
|
2080 | def magic_exit(self, parameter_s=''): | |
2081 | """Exit IPython, confirming if configured to do so. |
|
2081 | """Exit IPython, confirming if configured to do so. | |
2082 |
|
2082 | |||
2083 | You can configure whether IPython asks for confirmation upon exit by |
|
2083 | You can configure whether IPython asks for confirmation upon exit by | |
2084 | setting the confirm_exit flag in the ipythonrc file.""" |
|
2084 | setting the confirm_exit flag in the ipythonrc file.""" | |
2085 |
|
2085 | |||
2086 | self.shell.exit() |
|
2086 | self.shell.exit() | |
2087 |
|
2087 | |||
2088 | def magic_quit(self, parameter_s=''): |
|
2088 | def magic_quit(self, parameter_s=''): | |
2089 | """Exit IPython, confirming if configured to do so (like %exit)""" |
|
2089 | """Exit IPython, confirming if configured to do so (like %exit)""" | |
2090 |
|
2090 | |||
2091 | self.shell.exit() |
|
2091 | self.shell.exit() | |
2092 |
|
2092 | |||
2093 | def magic_Exit(self, parameter_s=''): |
|
2093 | def magic_Exit(self, parameter_s=''): | |
2094 | """Exit IPython without confirmation.""" |
|
2094 | """Exit IPython without confirmation.""" | |
2095 |
|
2095 | |||
2096 | self.shell.exit_now = True |
|
2096 | self.shell.exit_now = True | |
2097 |
|
2097 | |||
2098 | def magic_Quit(self, parameter_s=''): |
|
2098 | def magic_Quit(self, parameter_s=''): | |
2099 | """Exit IPython without confirmation (like %Exit).""" |
|
2099 | """Exit IPython without confirmation (like %Exit).""" | |
2100 |
|
2100 | |||
2101 | self.shell.exit_now = True |
|
2101 | self.shell.exit_now = True | |
2102 |
|
2102 | |||
2103 | #...................................................................... |
|
2103 | #...................................................................... | |
2104 | # Functions to implement unix shell-type things |
|
2104 | # Functions to implement unix shell-type things | |
2105 |
|
2105 | |||
2106 | def magic_alias(self, parameter_s = ''): |
|
2106 | def magic_alias(self, parameter_s = ''): | |
2107 | """Define an alias for a system command. |
|
2107 | """Define an alias for a system command. | |
2108 |
|
2108 | |||
2109 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' |
|
2109 | '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd' | |
2110 |
|
2110 | |||
2111 | Then, typing 'alias_name params' will execute the system command 'cmd |
|
2111 | Then, typing 'alias_name params' will execute the system command 'cmd | |
2112 | params' (from your underlying operating system). |
|
2112 | params' (from your underlying operating system). | |
2113 |
|
2113 | |||
2114 | Aliases have lower precedence than magic functions and Python normal |
|
2114 | Aliases have lower precedence than magic functions and Python normal | |
2115 | variables, so if 'foo' is both a Python variable and an alias, the |
|
2115 | variables, so if 'foo' is both a Python variable and an alias, the | |
2116 | alias can not be executed until 'del foo' removes the Python variable. |
|
2116 | alias can not be executed until 'del foo' removes the Python variable. | |
2117 |
|
2117 | |||
2118 | You can use the %l specifier in an alias definition to represent the |
|
2118 | You can use the %l specifier in an alias definition to represent the | |
2119 | whole line when the alias is called. For example: |
|
2119 | whole line when the alias is called. For example: | |
2120 |
|
2120 | |||
2121 | In [2]: alias all echo "Input in brackets: <%l>"\\ |
|
2121 | In [2]: alias all echo "Input in brackets: <%l>"\\ | |
2122 | In [3]: all hello world\\ |
|
2122 | In [3]: all hello world\\ | |
2123 | Input in brackets: <hello world> |
|
2123 | Input in brackets: <hello world> | |
2124 |
|
2124 | |||
2125 | You can also define aliases with parameters using %s specifiers (one |
|
2125 | You can also define aliases with parameters using %s specifiers (one | |
2126 | per parameter): |
|
2126 | per parameter): | |
2127 |
|
2127 | |||
2128 | In [1]: alias parts echo first %s second %s\\ |
|
2128 | In [1]: alias parts echo first %s second %s\\ | |
2129 | In [2]: %parts A B\\ |
|
2129 | In [2]: %parts A B\\ | |
2130 | first A second B\\ |
|
2130 | first A second B\\ | |
2131 | In [3]: %parts A\\ |
|
2131 | In [3]: %parts A\\ | |
2132 | Incorrect number of arguments: 2 expected.\\ |
|
2132 | Incorrect number of arguments: 2 expected.\\ | |
2133 | parts is an alias to: 'echo first %s second %s' |
|
2133 | parts is an alias to: 'echo first %s second %s' | |
2134 |
|
2134 | |||
2135 | Note that %l and %s are mutually exclusive. You can only use one or |
|
2135 | Note that %l and %s are mutually exclusive. You can only use one or | |
2136 | the other in your aliases. |
|
2136 | the other in your aliases. | |
2137 |
|
2137 | |||
2138 | Aliases expand Python variables just like system calls using ! or !! |
|
2138 | Aliases expand Python variables just like system calls using ! or !! | |
2139 | do: all expressions prefixed with '$' get expanded. For details of |
|
2139 | do: all expressions prefixed with '$' get expanded. For details of | |
2140 | the semantic rules, see PEP-215: |
|
2140 | the semantic rules, see PEP-215: | |
2141 | http://www.python.org/peps/pep-0215.html. This is the library used by |
|
2141 | http://www.python.org/peps/pep-0215.html. This is the library used by | |
2142 | IPython for variable expansion. If you want to access a true shell |
|
2142 | IPython for variable expansion. If you want to access a true shell | |
2143 | variable, an extra $ is necessary to prevent its expansion by IPython: |
|
2143 | variable, an extra $ is necessary to prevent its expansion by IPython: | |
2144 |
|
2144 | |||
2145 | In [6]: alias show echo\\ |
|
2145 | In [6]: alias show echo\\ | |
2146 | In [7]: PATH='A Python string'\\ |
|
2146 | In [7]: PATH='A Python string'\\ | |
2147 | In [8]: show $PATH\\ |
|
2147 | In [8]: show $PATH\\ | |
2148 | A Python string\\ |
|
2148 | A Python string\\ | |
2149 | In [9]: show $$PATH\\ |
|
2149 | In [9]: show $$PATH\\ | |
2150 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2150 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2151 |
|
2151 | |||
2152 | You can use the alias facility to acess all of $PATH. See the %rehash |
|
2152 | You can use the alias facility to acess all of $PATH. See the %rehash | |
2153 | and %rehashx functions, which automatically create aliases for the |
|
2153 | and %rehashx functions, which automatically create aliases for the | |
2154 | contents of your $PATH. |
|
2154 | contents of your $PATH. | |
2155 |
|
2155 | |||
2156 | If called with no parameters, %alias prints the current alias table.""" |
|
2156 | If called with no parameters, %alias prints the current alias table.""" | |
2157 |
|
2157 | |||
2158 | par = parameter_s.strip() |
|
2158 | par = parameter_s.strip() | |
2159 | if not par: |
|
2159 | if not par: | |
2160 | if self.shell.rc.automagic: |
|
2160 | if self.shell.rc.automagic: | |
2161 | prechar = '' |
|
2161 | prechar = '' | |
2162 | else: |
|
2162 | else: | |
2163 | prechar = self.shell.ESC_MAGIC |
|
2163 | prechar = self.shell.ESC_MAGIC | |
2164 | #print 'Alias\t\tSystem Command\n'+'-'*30 |
|
2164 | #print 'Alias\t\tSystem Command\n'+'-'*30 | |
2165 | atab = self.shell.alias_table |
|
2165 | atab = self.shell.alias_table | |
2166 | aliases = atab.keys() |
|
2166 | aliases = atab.keys() | |
2167 | aliases.sort() |
|
2167 | aliases.sort() | |
2168 | res = [] |
|
2168 | res = [] | |
2169 | for alias in aliases: |
|
2169 | for alias in aliases: | |
2170 | res.append((alias, atab[alias][1])) |
|
2170 | res.append((alias, atab[alias][1])) | |
2171 | print "Total number of aliases:",len(aliases) |
|
2171 | print "Total number of aliases:",len(aliases) | |
2172 | return res |
|
2172 | return res | |
2173 | try: |
|
2173 | try: | |
2174 | alias,cmd = par.split(None,1) |
|
2174 | alias,cmd = par.split(None,1) | |
2175 | except: |
|
2175 | except: | |
2176 | print OInspect.getdoc(self.magic_alias) |
|
2176 | print OInspect.getdoc(self.magic_alias) | |
2177 | else: |
|
2177 | else: | |
2178 | nargs = cmd.count('%s') |
|
2178 | nargs = cmd.count('%s') | |
2179 | if nargs>0 and cmd.find('%l')>=0: |
|
2179 | if nargs>0 and cmd.find('%l')>=0: | |
2180 | error('The %s and %l specifiers are mutually exclusive ' |
|
2180 | error('The %s and %l specifiers are mutually exclusive ' | |
2181 | 'in alias definitions.') |
|
2181 | 'in alias definitions.') | |
2182 | else: # all looks OK |
|
2182 | else: # all looks OK | |
2183 | self.shell.alias_table[alias] = (nargs,cmd) |
|
2183 | self.shell.alias_table[alias] = (nargs,cmd) | |
2184 | self.shell.alias_table_validate(verbose=1) |
|
2184 | self.shell.alias_table_validate(verbose=1) | |
2185 | # end magic_alias |
|
2185 | # end magic_alias | |
2186 |
|
2186 | |||
2187 | def magic_unalias(self, parameter_s = ''): |
|
2187 | def magic_unalias(self, parameter_s = ''): | |
2188 | """Remove an alias""" |
|
2188 | """Remove an alias""" | |
2189 |
|
2189 | |||
2190 | aname = parameter_s.strip() |
|
2190 | aname = parameter_s.strip() | |
2191 | if aname in self.shell.alias_table: |
|
2191 | if aname in self.shell.alias_table: | |
2192 | del self.shell.alias_table[aname] |
|
2192 | del self.shell.alias_table[aname] | |
2193 |
|
2193 | |||
2194 | def magic_rehash(self, parameter_s = ''): |
|
2194 | def magic_rehash(self, parameter_s = ''): | |
2195 | """Update the alias table with all entries in $PATH. |
|
2195 | """Update the alias table with all entries in $PATH. | |
2196 |
|
2196 | |||
2197 | This version does no checks on execute permissions or whether the |
|
2197 | This version does no checks on execute permissions or whether the | |
2198 | contents of $PATH are truly files (instead of directories or something |
|
2198 | contents of $PATH are truly files (instead of directories or something | |
2199 | else). For such a safer (but slower) version, use %rehashx.""" |
|
2199 | else). For such a safer (but slower) version, use %rehashx.""" | |
2200 |
|
2200 | |||
2201 | # This function (and rehashx) manipulate the alias_table directly |
|
2201 | # This function (and rehashx) manipulate the alias_table directly | |
2202 | # rather than calling magic_alias, for speed reasons. A rehash on a |
|
2202 | # rather than calling magic_alias, for speed reasons. A rehash on a | |
2203 | # typical Linux box involves several thousand entries, so efficiency |
|
2203 | # typical Linux box involves several thousand entries, so efficiency | |
2204 | # here is a top concern. |
|
2204 | # here is a top concern. | |
2205 |
|
2205 | |||
2206 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2206 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2207 | alias_table = self.shell.alias_table |
|
2207 | alias_table = self.shell.alias_table | |
2208 | for pdir in path: |
|
2208 | for pdir in path: | |
2209 | for ff in os.listdir(pdir): |
|
2209 | for ff in os.listdir(pdir): | |
2210 | # each entry in the alias table must be (N,name), where |
|
2210 | # each entry in the alias table must be (N,name), where | |
2211 | # N is the number of positional arguments of the alias. |
|
2211 | # N is the number of positional arguments of the alias. | |
2212 | alias_table[ff] = (0,ff) |
|
2212 | alias_table[ff] = (0,ff) | |
2213 | # Make sure the alias table doesn't contain keywords or builtins |
|
2213 | # Make sure the alias table doesn't contain keywords or builtins | |
2214 | self.shell.alias_table_validate() |
|
2214 | self.shell.alias_table_validate() | |
2215 | # Call again init_auto_alias() so we get 'rm -i' and other modified |
|
2215 | # Call again init_auto_alias() so we get 'rm -i' and other modified | |
2216 | # aliases since %rehash will probably clobber them |
|
2216 | # aliases since %rehash will probably clobber them | |
2217 | self.shell.init_auto_alias() |
|
2217 | self.shell.init_auto_alias() | |
2218 |
|
2218 | |||
2219 | def magic_rehashx(self, parameter_s = ''): |
|
2219 | def magic_rehashx(self, parameter_s = ''): | |
2220 | """Update the alias table with all executable files in $PATH. |
|
2220 | """Update the alias table with all executable files in $PATH. | |
2221 |
|
2221 | |||
2222 | This version explicitly checks that every entry in $PATH is a file |
|
2222 | This version explicitly checks that every entry in $PATH is a file | |
2223 | with execute access (os.X_OK), so it is much slower than %rehash. |
|
2223 | with execute access (os.X_OK), so it is much slower than %rehash. | |
2224 |
|
2224 | |||
2225 | Under Windows, it checks executability as a match agains a |
|
2225 | Under Windows, it checks executability as a match agains a | |
2226 | '|'-separated string of extensions, stored in the IPython config |
|
2226 | '|'-separated string of extensions, stored in the IPython config | |
2227 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ |
|
2227 | variable win_exec_ext. This defaults to 'exe|com|bat'. """ | |
2228 |
|
2228 | |||
2229 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) |
|
2229 | path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep)) | |
2230 | alias_table = self.shell.alias_table |
|
2230 | alias_table = self.shell.alias_table | |
2231 |
|
2231 | |||
2232 | if os.name == 'posix': |
|
2232 | if os.name == 'posix': | |
2233 | isexec = lambda fname:os.path.isfile(fname) and \ |
|
2233 | isexec = lambda fname:os.path.isfile(fname) and \ | |
2234 | os.access(fname,os.X_OK) |
|
2234 | os.access(fname,os.X_OK) | |
2235 | else: |
|
2235 | else: | |
2236 |
|
2236 | |||
2237 | try: |
|
2237 | try: | |
2238 | winext = os.environ['pathext'].replace(';','|').replace('.','') |
|
2238 | winext = os.environ['pathext'].replace(';','|').replace('.','') | |
2239 | except KeyError: |
|
2239 | except KeyError: | |
2240 | winext = 'exe|com|bat' |
|
2240 | winext = 'exe|com|bat' | |
2241 |
|
2241 | |||
2242 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) |
|
2242 | execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) | |
2243 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) |
|
2243 | isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) | |
2244 | savedir = os.getcwd() |
|
2244 | savedir = os.getcwd() | |
2245 | try: |
|
2245 | try: | |
2246 | # write the whole loop for posix/Windows so we don't have an if in |
|
2246 | # write the whole loop for posix/Windows so we don't have an if in | |
2247 | # the innermost part |
|
2247 | # the innermost part | |
2248 | if os.name == 'posix': |
|
2248 | if os.name == 'posix': | |
2249 | for pdir in path: |
|
2249 | for pdir in path: | |
2250 | os.chdir(pdir) |
|
2250 | os.chdir(pdir) | |
2251 | for ff in os.listdir(pdir): |
|
2251 | for ff in os.listdir(pdir): | |
2252 | if isexec(ff): |
|
2252 | if isexec(ff): | |
2253 | # each entry in the alias table must be (N,name), |
|
2253 | # each entry in the alias table must be (N,name), | |
2254 | # where N is the number of positional arguments of the |
|
2254 | # where N is the number of positional arguments of the | |
2255 | # alias. |
|
2255 | # alias. | |
2256 | alias_table[ff] = (0,ff) |
|
2256 | alias_table[ff] = (0,ff) | |
2257 | else: |
|
2257 | else: | |
2258 | for pdir in path: |
|
2258 | for pdir in path: | |
2259 | os.chdir(pdir) |
|
2259 | os.chdir(pdir) | |
2260 | for ff in os.listdir(pdir): |
|
2260 | for ff in os.listdir(pdir): | |
2261 | if isexec(ff): |
|
2261 | if isexec(ff): | |
2262 | alias_table[execre.sub(r'\1',ff)] = (0,ff) |
|
2262 | alias_table[execre.sub(r'\1',ff)] = (0,ff) | |
2263 | # Make sure the alias table doesn't contain keywords or builtins |
|
2263 | # Make sure the alias table doesn't contain keywords or builtins | |
2264 | self.shell.alias_table_validate() |
|
2264 | self.shell.alias_table_validate() | |
2265 | # Call again init_auto_alias() so we get 'rm -i' and other |
|
2265 | # Call again init_auto_alias() so we get 'rm -i' and other | |
2266 | # modified aliases since %rehashx will probably clobber them |
|
2266 | # modified aliases since %rehashx will probably clobber them | |
2267 | self.shell.init_auto_alias() |
|
2267 | self.shell.init_auto_alias() | |
2268 | finally: |
|
2268 | finally: | |
2269 | os.chdir(savedir) |
|
2269 | os.chdir(savedir) | |
2270 |
|
2270 | |||
2271 | def magic_pwd(self, parameter_s = ''): |
|
2271 | def magic_pwd(self, parameter_s = ''): | |
2272 | """Return the current working directory path.""" |
|
2272 | """Return the current working directory path.""" | |
2273 | return os.getcwd() |
|
2273 | return os.getcwd() | |
2274 |
|
2274 | |||
2275 | def magic_cd(self, parameter_s=''): |
|
2275 | def magic_cd(self, parameter_s=''): | |
2276 | """Change the current working directory. |
|
2276 | """Change the current working directory. | |
2277 |
|
2277 | |||
2278 | This command automatically maintains an internal list of directories |
|
2278 | This command automatically maintains an internal list of directories | |
2279 | you visit during your IPython session, in the variable _dh. The |
|
2279 | you visit during your IPython session, in the variable _dh. The | |
2280 | command %dhist shows this history nicely formatted. |
|
2280 | command %dhist shows this history nicely formatted. | |
2281 |
|
2281 | |||
2282 | Usage: |
|
2282 | Usage: | |
2283 |
|
2283 | |||
2284 | cd 'dir': changes to directory 'dir'. |
|
2284 | cd 'dir': changes to directory 'dir'. | |
2285 |
|
2285 | |||
2286 | cd -: changes to the last visited directory. |
|
2286 | cd -: changes to the last visited directory. | |
2287 |
|
2287 | |||
2288 | cd -<n>: changes to the n-th directory in the directory history. |
|
2288 | cd -<n>: changes to the n-th directory in the directory history. | |
2289 |
|
2289 | |||
2290 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark |
|
2290 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark | |
2291 | (note: cd <bookmark_name> is enough if there is no |
|
2291 | (note: cd <bookmark_name> is enough if there is no | |
2292 | directory <bookmark_name>, but a bookmark with the name exists.) |
|
2292 | directory <bookmark_name>, but a bookmark with the name exists.) | |
2293 |
|
2293 | |||
2294 | Options: |
|
2294 | Options: | |
2295 |
|
2295 | |||
2296 | -q: quiet. Do not print the working directory after the cd command is |
|
2296 | -q: quiet. Do not print the working directory after the cd command is | |
2297 | executed. By default IPython's cd command does print this directory, |
|
2297 | executed. By default IPython's cd command does print this directory, | |
2298 | since the default prompts do not display path information. |
|
2298 | since the default prompts do not display path information. | |
2299 |
|
2299 | |||
2300 | Note that !cd doesn't work for this purpose because the shell where |
|
2300 | Note that !cd doesn't work for this purpose because the shell where | |
2301 | !command runs is immediately discarded after executing 'command'.""" |
|
2301 | !command runs is immediately discarded after executing 'command'.""" | |
2302 |
|
2302 | |||
2303 | parameter_s = parameter_s.strip() |
|
2303 | parameter_s = parameter_s.strip() | |
2304 | bkms = self.shell.persist.get("bookmarks",{}) |
|
2304 | #bkms = self.shell.persist.get("bookmarks",{}) | |
2305 |
|
2305 | |||
2306 | numcd = re.match(r'(-)(\d+)$',parameter_s) |
|
2306 | numcd = re.match(r'(-)(\d+)$',parameter_s) | |
2307 | # jump in directory history by number |
|
2307 | # jump in directory history by number | |
2308 | if numcd: |
|
2308 | if numcd: | |
2309 | nn = int(numcd.group(2)) |
|
2309 | nn = int(numcd.group(2)) | |
2310 | try: |
|
2310 | try: | |
2311 | ps = self.shell.user_ns['_dh'][nn] |
|
2311 | ps = self.shell.user_ns['_dh'][nn] | |
2312 | except IndexError: |
|
2312 | except IndexError: | |
2313 | print 'The requested directory does not exist in history.' |
|
2313 | print 'The requested directory does not exist in history.' | |
2314 | return |
|
2314 | return | |
2315 | else: |
|
2315 | else: | |
2316 | opts = {} |
|
2316 | opts = {} | |
2317 | else: |
|
2317 | else: | |
2318 | #turn all non-space-escaping backslashes to slashes, |
|
2318 | #turn all non-space-escaping backslashes to slashes, | |
2319 | # for c:\windows\directory\names\ |
|
2319 | # for c:\windows\directory\names\ | |
2320 | parameter_s = re.sub(r'\\(?! )','/', parameter_s) |
|
2320 | parameter_s = re.sub(r'\\(?! )','/', parameter_s) | |
2321 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') |
|
2321 | opts,ps = self.parse_options(parameter_s,'qb',mode='string') | |
2322 | # jump to previous |
|
2322 | # jump to previous | |
2323 | if ps == '-': |
|
2323 | if ps == '-': | |
2324 | try: |
|
2324 | try: | |
2325 | ps = self.shell.user_ns['_dh'][-2] |
|
2325 | ps = self.shell.user_ns['_dh'][-2] | |
2326 | except IndexError: |
|
2326 | except IndexError: | |
2327 | print 'No previous directory to change to.' |
|
2327 | print 'No previous directory to change to.' | |
2328 | return |
|
2328 | return | |
2329 | # jump to bookmark |
|
2329 | # jump to bookmark if needed | |
2330 | elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)): |
|
2330 | else: | |
|
2331 | if not os.path.isdir(ps) or opts.has_key('b'): | |||
|
2332 | bkms = self.db.get('bookmarks', {}) | |||
|
2333 | ||||
2331 | if bkms.has_key(ps): |
|
2334 | if bkms.has_key(ps): | |
2332 | target = bkms[ps] |
|
2335 | target = bkms[ps] | |
2333 | print '(bookmark:%s) -> %s' % (ps,target) |
|
2336 | print '(bookmark:%s) -> %s' % (ps,target) | |
2334 | ps = target |
|
2337 | ps = target | |
2335 | else: |
|
2338 | else: | |
2336 |
if |
|
2339 | if opts.has_key('b'): | |
2337 | error("Bookmark '%s' not found. " |
|
2340 | error("Bookmark '%s' not found. " | |
2338 | "Use '%%bookmark -l' to see your bookmarks." % ps) |
|
2341 | "Use '%%bookmark -l' to see your bookmarks." % ps) | |
2339 | else: |
|
|||
2340 | print "Bookmarks not set - use %bookmark <bookmarkname>" |
|
|||
2341 | return |
|
2342 | return | |
2342 |
|
2343 | |||
2343 | # at this point ps should point to the target dir |
|
2344 | # at this point ps should point to the target dir | |
2344 | if ps: |
|
2345 | if ps: | |
2345 | try: |
|
2346 | try: | |
2346 | os.chdir(os.path.expanduser(ps)) |
|
2347 | os.chdir(os.path.expanduser(ps)) | |
2347 | ttitle = ("IPy:" + ( |
|
2348 | ttitle = ("IPy:" + ( | |
2348 | os.getcwd() == '/' and '/' or os.path.basename(os.getcwd()))) |
|
2349 | os.getcwd() == '/' and '/' or os.path.basename(os.getcwd()))) | |
2349 | platutils.set_term_title(ttitle) |
|
2350 | platutils.set_term_title(ttitle) | |
2350 | except OSError: |
|
2351 | except OSError: | |
2351 | print sys.exc_info()[1] |
|
2352 | print sys.exc_info()[1] | |
2352 | else: |
|
2353 | else: | |
2353 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2354 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2354 | else: |
|
2355 | else: | |
2355 | os.chdir(self.shell.home_dir) |
|
2356 | os.chdir(self.shell.home_dir) | |
2356 | platutils.set_term_title("IPy:~") |
|
2357 | platutils.set_term_title("IPy:~") | |
2357 | self.shell.user_ns['_dh'].append(os.getcwd()) |
|
2358 | self.shell.user_ns['_dh'].append(os.getcwd()) | |
2358 | if not 'q' in opts: |
|
2359 | if not 'q' in opts: | |
2359 | print self.shell.user_ns['_dh'][-1] |
|
2360 | print self.shell.user_ns['_dh'][-1] | |
2360 |
|
2361 | |||
2361 | def magic_dhist(self, parameter_s=''): |
|
2362 | def magic_dhist(self, parameter_s=''): | |
2362 | """Print your history of visited directories. |
|
2363 | """Print your history of visited directories. | |
2363 |
|
2364 | |||
2364 | %dhist -> print full history\\ |
|
2365 | %dhist -> print full history\\ | |
2365 | %dhist n -> print last n entries only\\ |
|
2366 | %dhist n -> print last n entries only\\ | |
2366 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ |
|
2367 | %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ | |
2367 |
|
2368 | |||
2368 | This history is automatically maintained by the %cd command, and |
|
2369 | This history is automatically maintained by the %cd command, and | |
2369 | always available as the global list variable _dh. You can use %cd -<n> |
|
2370 | always available as the global list variable _dh. You can use %cd -<n> | |
2370 | to go to directory number <n>.""" |
|
2371 | to go to directory number <n>.""" | |
2371 |
|
2372 | |||
2372 | dh = self.shell.user_ns['_dh'] |
|
2373 | dh = self.shell.user_ns['_dh'] | |
2373 | if parameter_s: |
|
2374 | if parameter_s: | |
2374 | try: |
|
2375 | try: | |
2375 | args = map(int,parameter_s.split()) |
|
2376 | args = map(int,parameter_s.split()) | |
2376 | except: |
|
2377 | except: | |
2377 | self.arg_err(Magic.magic_dhist) |
|
2378 | self.arg_err(Magic.magic_dhist) | |
2378 | return |
|
2379 | return | |
2379 | if len(args) == 1: |
|
2380 | if len(args) == 1: | |
2380 | ini,fin = max(len(dh)-(args[0]),0),len(dh) |
|
2381 | ini,fin = max(len(dh)-(args[0]),0),len(dh) | |
2381 | elif len(args) == 2: |
|
2382 | elif len(args) == 2: | |
2382 | ini,fin = args |
|
2383 | ini,fin = args | |
2383 | else: |
|
2384 | else: | |
2384 | self.arg_err(Magic.magic_dhist) |
|
2385 | self.arg_err(Magic.magic_dhist) | |
2385 | return |
|
2386 | return | |
2386 | else: |
|
2387 | else: | |
2387 | ini,fin = 0,len(dh) |
|
2388 | ini,fin = 0,len(dh) | |
2388 | nlprint(dh, |
|
2389 | nlprint(dh, | |
2389 | header = 'Directory history (kept in _dh)', |
|
2390 | header = 'Directory history (kept in _dh)', | |
2390 | start=ini,stop=fin) |
|
2391 | start=ini,stop=fin) | |
2391 |
|
2392 | |||
2392 | def magic_env(self, parameter_s=''): |
|
2393 | def magic_env(self, parameter_s=''): | |
2393 | """List environment variables.""" |
|
2394 | """List environment variables.""" | |
2394 |
|
2395 | |||
2395 | return os.environ.data |
|
2396 | return os.environ.data | |
2396 |
|
2397 | |||
2397 | def magic_pushd(self, parameter_s=''): |
|
2398 | def magic_pushd(self, parameter_s=''): | |
2398 | """Place the current dir on stack and change directory. |
|
2399 | """Place the current dir on stack and change directory. | |
2399 |
|
2400 | |||
2400 | Usage:\\ |
|
2401 | Usage:\\ | |
2401 | %pushd ['dirname'] |
|
2402 | %pushd ['dirname'] | |
2402 |
|
2403 | |||
2403 | %pushd with no arguments does a %pushd to your home directory. |
|
2404 | %pushd with no arguments does a %pushd to your home directory. | |
2404 | """ |
|
2405 | """ | |
2405 | if parameter_s == '': parameter_s = '~' |
|
2406 | if parameter_s == '': parameter_s = '~' | |
2406 | dir_s = self.shell.dir_stack |
|
2407 | dir_s = self.shell.dir_stack | |
2407 | if len(dir_s)>0 and os.path.expanduser(parameter_s) != \ |
|
2408 | if len(dir_s)>0 and os.path.expanduser(parameter_s) != \ | |
2408 | os.path.expanduser(self.shell.dir_stack[0]): |
|
2409 | os.path.expanduser(self.shell.dir_stack[0]): | |
2409 | try: |
|
2410 | try: | |
2410 | self.magic_cd(parameter_s) |
|
2411 | self.magic_cd(parameter_s) | |
2411 | dir_s.insert(0,os.getcwd().replace(self.home_dir,'~')) |
|
2412 | dir_s.insert(0,os.getcwd().replace(self.home_dir,'~')) | |
2412 | self.magic_dirs() |
|
2413 | self.magic_dirs() | |
2413 | except: |
|
2414 | except: | |
2414 | print 'Invalid directory' |
|
2415 | print 'Invalid directory' | |
2415 | else: |
|
2416 | else: | |
2416 | print 'You are already there!' |
|
2417 | print 'You are already there!' | |
2417 |
|
2418 | |||
2418 | def magic_popd(self, parameter_s=''): |
|
2419 | def magic_popd(self, parameter_s=''): | |
2419 | """Change to directory popped off the top of the stack. |
|
2420 | """Change to directory popped off the top of the stack. | |
2420 | """ |
|
2421 | """ | |
2421 | if len (self.shell.dir_stack) > 1: |
|
2422 | if len (self.shell.dir_stack) > 1: | |
2422 | self.shell.dir_stack.pop(0) |
|
2423 | self.shell.dir_stack.pop(0) | |
2423 | self.magic_cd(self.shell.dir_stack[0]) |
|
2424 | self.magic_cd(self.shell.dir_stack[0]) | |
2424 | print self.shell.dir_stack[0] |
|
2425 | print self.shell.dir_stack[0] | |
2425 | else: |
|
2426 | else: | |
2426 | print "You can't remove the starting directory from the stack:",\ |
|
2427 | print "You can't remove the starting directory from the stack:",\ | |
2427 | self.shell.dir_stack |
|
2428 | self.shell.dir_stack | |
2428 |
|
2429 | |||
2429 | def magic_dirs(self, parameter_s=''): |
|
2430 | def magic_dirs(self, parameter_s=''): | |
2430 | """Return the current directory stack.""" |
|
2431 | """Return the current directory stack.""" | |
2431 |
|
2432 | |||
2432 | return self.shell.dir_stack[:] |
|
2433 | return self.shell.dir_stack[:] | |
2433 |
|
2434 | |||
2434 | def magic_sc(self, parameter_s=''): |
|
2435 | def magic_sc(self, parameter_s=''): | |
2435 | """Shell capture - execute a shell command and capture its output. |
|
2436 | """Shell capture - execute a shell command and capture its output. | |
2436 |
|
2437 | |||
2437 | DEPRECATED. Suboptimal, retained for backwards compatibility. |
|
2438 | DEPRECATED. Suboptimal, retained for backwards compatibility. | |
2438 |
|
2439 | |||
2439 | You should use the form 'var = !command' instead. Example: |
|
2440 | You should use the form 'var = !command' instead. Example: | |
2440 |
|
2441 | |||
2441 | "%sc -l myfiles = ls ~" should now be written as |
|
2442 | "%sc -l myfiles = ls ~" should now be written as | |
2442 |
|
2443 | |||
2443 | "myfiles = !ls ~" |
|
2444 | "myfiles = !ls ~" | |
2444 |
|
2445 | |||
2445 | myfiles.s, myfiles.l and myfiles.n still apply as documented |
|
2446 | myfiles.s, myfiles.l and myfiles.n still apply as documented | |
2446 | below. |
|
2447 | below. | |
2447 |
|
2448 | |||
2448 | -- |
|
2449 | -- | |
2449 | %sc [options] varname=command |
|
2450 | %sc [options] varname=command | |
2450 |
|
2451 | |||
2451 | IPython will run the given command using commands.getoutput(), and |
|
2452 | IPython will run the given command using commands.getoutput(), and | |
2452 | will then update the user's interactive namespace with a variable |
|
2453 | will then update the user's interactive namespace with a variable | |
2453 | called varname, containing the value of the call. Your command can |
|
2454 | called varname, containing the value of the call. Your command can | |
2454 | contain shell wildcards, pipes, etc. |
|
2455 | contain shell wildcards, pipes, etc. | |
2455 |
|
2456 | |||
2456 | The '=' sign in the syntax is mandatory, and the variable name you |
|
2457 | The '=' sign in the syntax is mandatory, and the variable name you | |
2457 | supply must follow Python's standard conventions for valid names. |
|
2458 | supply must follow Python's standard conventions for valid names. | |
2458 |
|
2459 | |||
2459 | (A special format without variable name exists for internal use) |
|
2460 | (A special format without variable name exists for internal use) | |
2460 |
|
2461 | |||
2461 | Options: |
|
2462 | Options: | |
2462 |
|
2463 | |||
2463 | -l: list output. Split the output on newlines into a list before |
|
2464 | -l: list output. Split the output on newlines into a list before | |
2464 | assigning it to the given variable. By default the output is stored |
|
2465 | assigning it to the given variable. By default the output is stored | |
2465 | as a single string. |
|
2466 | as a single string. | |
2466 |
|
2467 | |||
2467 | -v: verbose. Print the contents of the variable. |
|
2468 | -v: verbose. Print the contents of the variable. | |
2468 |
|
2469 | |||
2469 | In most cases you should not need to split as a list, because the |
|
2470 | In most cases you should not need to split as a list, because the | |
2470 | returned value is a special type of string which can automatically |
|
2471 | returned value is a special type of string which can automatically | |
2471 | provide its contents either as a list (split on newlines) or as a |
|
2472 | provide its contents either as a list (split on newlines) or as a | |
2472 | space-separated string. These are convenient, respectively, either |
|
2473 | space-separated string. These are convenient, respectively, either | |
2473 | for sequential processing or to be passed to a shell command. |
|
2474 | for sequential processing or to be passed to a shell command. | |
2474 |
|
2475 | |||
2475 | For example: |
|
2476 | For example: | |
2476 |
|
2477 | |||
2477 | # Capture into variable a |
|
2478 | # Capture into variable a | |
2478 | In [9]: sc a=ls *py |
|
2479 | In [9]: sc a=ls *py | |
2479 |
|
2480 | |||
2480 | # a is a string with embedded newlines |
|
2481 | # a is a string with embedded newlines | |
2481 | In [10]: a |
|
2482 | In [10]: a | |
2482 | Out[10]: 'setup.py\nwin32_manual_post_install.py' |
|
2483 | Out[10]: 'setup.py\nwin32_manual_post_install.py' | |
2483 |
|
2484 | |||
2484 | # which can be seen as a list: |
|
2485 | # which can be seen as a list: | |
2485 | In [11]: a.l |
|
2486 | In [11]: a.l | |
2486 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] |
|
2487 | Out[11]: ['setup.py', 'win32_manual_post_install.py'] | |
2487 |
|
2488 | |||
2488 | # or as a whitespace-separated string: |
|
2489 | # or as a whitespace-separated string: | |
2489 | In [12]: a.s |
|
2490 | In [12]: a.s | |
2490 | Out[12]: 'setup.py win32_manual_post_install.py' |
|
2491 | Out[12]: 'setup.py win32_manual_post_install.py' | |
2491 |
|
2492 | |||
2492 | # a.s is useful to pass as a single command line: |
|
2493 | # a.s is useful to pass as a single command line: | |
2493 | In [13]: !wc -l $a.s |
|
2494 | In [13]: !wc -l $a.s | |
2494 | 146 setup.py |
|
2495 | 146 setup.py | |
2495 | 130 win32_manual_post_install.py |
|
2496 | 130 win32_manual_post_install.py | |
2496 | 276 total |
|
2497 | 276 total | |
2497 |
|
2498 | |||
2498 | # while the list form is useful to loop over: |
|
2499 | # while the list form is useful to loop over: | |
2499 | In [14]: for f in a.l: |
|
2500 | In [14]: for f in a.l: | |
2500 | ....: !wc -l $f |
|
2501 | ....: !wc -l $f | |
2501 | ....: |
|
2502 | ....: | |
2502 | 146 setup.py |
|
2503 | 146 setup.py | |
2503 | 130 win32_manual_post_install.py |
|
2504 | 130 win32_manual_post_install.py | |
2504 |
|
2505 | |||
2505 | Similiarly, the lists returned by the -l option are also special, in |
|
2506 | Similiarly, the lists returned by the -l option are also special, in | |
2506 | the sense that you can equally invoke the .s attribute on them to |
|
2507 | the sense that you can equally invoke the .s attribute on them to | |
2507 | automatically get a whitespace-separated string from their contents: |
|
2508 | automatically get a whitespace-separated string from their contents: | |
2508 |
|
2509 | |||
2509 | In [1]: sc -l b=ls *py |
|
2510 | In [1]: sc -l b=ls *py | |
2510 |
|
2511 | |||
2511 | In [2]: b |
|
2512 | In [2]: b | |
2512 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] |
|
2513 | Out[2]: ['setup.py', 'win32_manual_post_install.py'] | |
2513 |
|
2514 | |||
2514 | In [3]: b.s |
|
2515 | In [3]: b.s | |
2515 | Out[3]: 'setup.py win32_manual_post_install.py' |
|
2516 | Out[3]: 'setup.py win32_manual_post_install.py' | |
2516 |
|
2517 | |||
2517 | In summary, both the lists and strings used for ouptut capture have |
|
2518 | In summary, both the lists and strings used for ouptut capture have | |
2518 | the following special attributes: |
|
2519 | the following special attributes: | |
2519 |
|
2520 | |||
2520 | .l (or .list) : value as list. |
|
2521 | .l (or .list) : value as list. | |
2521 | .n (or .nlstr): value as newline-separated string. |
|
2522 | .n (or .nlstr): value as newline-separated string. | |
2522 | .s (or .spstr): value as space-separated string. |
|
2523 | .s (or .spstr): value as space-separated string. | |
2523 | """ |
|
2524 | """ | |
2524 |
|
2525 | |||
2525 | opts,args = self.parse_options(parameter_s,'lv') |
|
2526 | opts,args = self.parse_options(parameter_s,'lv') | |
2526 | # Try to get a variable name and command to run |
|
2527 | # Try to get a variable name and command to run | |
2527 | try: |
|
2528 | try: | |
2528 | # the variable name must be obtained from the parse_options |
|
2529 | # the variable name must be obtained from the parse_options | |
2529 | # output, which uses shlex.split to strip options out. |
|
2530 | # output, which uses shlex.split to strip options out. | |
2530 | var,_ = args.split('=',1) |
|
2531 | var,_ = args.split('=',1) | |
2531 | var = var.strip() |
|
2532 | var = var.strip() | |
2532 | # But the the command has to be extracted from the original input |
|
2533 | # But the the command has to be extracted from the original input | |
2533 | # parameter_s, not on what parse_options returns, to avoid the |
|
2534 | # parameter_s, not on what parse_options returns, to avoid the | |
2534 | # quote stripping which shlex.split performs on it. |
|
2535 | # quote stripping which shlex.split performs on it. | |
2535 | _,cmd = parameter_s.split('=',1) |
|
2536 | _,cmd = parameter_s.split('=',1) | |
2536 | except ValueError: |
|
2537 | except ValueError: | |
2537 | var,cmd = '','' |
|
2538 | var,cmd = '','' | |
2538 | # If all looks ok, proceed |
|
2539 | # If all looks ok, proceed | |
2539 | out,err = self.shell.getoutputerror(cmd) |
|
2540 | out,err = self.shell.getoutputerror(cmd) | |
2540 | if err: |
|
2541 | if err: | |
2541 | print >> Term.cerr,err |
|
2542 | print >> Term.cerr,err | |
2542 | if opts.has_key('l'): |
|
2543 | if opts.has_key('l'): | |
2543 | out = SList(out.split('\n')) |
|
2544 | out = SList(out.split('\n')) | |
2544 | else: |
|
2545 | else: | |
2545 | out = LSString(out) |
|
2546 | out = LSString(out) | |
2546 | if opts.has_key('v'): |
|
2547 | if opts.has_key('v'): | |
2547 | print '%s ==\n%s' % (var,pformat(out)) |
|
2548 | print '%s ==\n%s' % (var,pformat(out)) | |
2548 | if var: |
|
2549 | if var: | |
2549 | self.shell.user_ns.update({var:out}) |
|
2550 | self.shell.user_ns.update({var:out}) | |
2550 | else: |
|
2551 | else: | |
2551 | return out |
|
2552 | return out | |
2552 |
|
2553 | |||
2553 | def magic_sx(self, parameter_s=''): |
|
2554 | def magic_sx(self, parameter_s=''): | |
2554 | """Shell execute - run a shell command and capture its output. |
|
2555 | """Shell execute - run a shell command and capture its output. | |
2555 |
|
2556 | |||
2556 | %sx command |
|
2557 | %sx command | |
2557 |
|
2558 | |||
2558 | IPython will run the given command using commands.getoutput(), and |
|
2559 | IPython will run the given command using commands.getoutput(), and | |
2559 | return the result formatted as a list (split on '\\n'). Since the |
|
2560 | return the result formatted as a list (split on '\\n'). Since the | |
2560 | output is _returned_, it will be stored in ipython's regular output |
|
2561 | output is _returned_, it will be stored in ipython's regular output | |
2561 | cache Out[N] and in the '_N' automatic variables. |
|
2562 | cache Out[N] and in the '_N' automatic variables. | |
2562 |
|
2563 | |||
2563 | Notes: |
|
2564 | Notes: | |
2564 |
|
2565 | |||
2565 | 1) If an input line begins with '!!', then %sx is automatically |
|
2566 | 1) If an input line begins with '!!', then %sx is automatically | |
2566 | invoked. That is, while: |
|
2567 | invoked. That is, while: | |
2567 | !ls |
|
2568 | !ls | |
2568 | causes ipython to simply issue system('ls'), typing |
|
2569 | causes ipython to simply issue system('ls'), typing | |
2569 | !!ls |
|
2570 | !!ls | |
2570 | is a shorthand equivalent to: |
|
2571 | is a shorthand equivalent to: | |
2571 | %sx ls |
|
2572 | %sx ls | |
2572 |
|
2573 | |||
2573 | 2) %sx differs from %sc in that %sx automatically splits into a list, |
|
2574 | 2) %sx differs from %sc in that %sx automatically splits into a list, | |
2574 | like '%sc -l'. The reason for this is to make it as easy as possible |
|
2575 | like '%sc -l'. The reason for this is to make it as easy as possible | |
2575 | to process line-oriented shell output via further python commands. |
|
2576 | to process line-oriented shell output via further python commands. | |
2576 | %sc is meant to provide much finer control, but requires more |
|
2577 | %sc is meant to provide much finer control, but requires more | |
2577 | typing. |
|
2578 | typing. | |
2578 |
|
2579 | |||
2579 | 3) Just like %sc -l, this is a list with special attributes: |
|
2580 | 3) Just like %sc -l, this is a list with special attributes: | |
2580 |
|
2581 | |||
2581 | .l (or .list) : value as list. |
|
2582 | .l (or .list) : value as list. | |
2582 | .n (or .nlstr): value as newline-separated string. |
|
2583 | .n (or .nlstr): value as newline-separated string. | |
2583 | .s (or .spstr): value as whitespace-separated string. |
|
2584 | .s (or .spstr): value as whitespace-separated string. | |
2584 |
|
2585 | |||
2585 | This is very useful when trying to use such lists as arguments to |
|
2586 | This is very useful when trying to use such lists as arguments to | |
2586 | system commands.""" |
|
2587 | system commands.""" | |
2587 |
|
2588 | |||
2588 | if parameter_s: |
|
2589 | if parameter_s: | |
2589 | out,err = self.shell.getoutputerror(parameter_s) |
|
2590 | out,err = self.shell.getoutputerror(parameter_s) | |
2590 | if err: |
|
2591 | if err: | |
2591 | print >> Term.cerr,err |
|
2592 | print >> Term.cerr,err | |
2592 | return SList(out.split('\n')) |
|
2593 | return SList(out.split('\n')) | |
2593 |
|
2594 | |||
2594 | def magic_bg(self, parameter_s=''): |
|
2595 | def magic_bg(self, parameter_s=''): | |
2595 | """Run a job in the background, in a separate thread. |
|
2596 | """Run a job in the background, in a separate thread. | |
2596 |
|
2597 | |||
2597 | For example, |
|
2598 | For example, | |
2598 |
|
2599 | |||
2599 | %bg myfunc(x,y,z=1) |
|
2600 | %bg myfunc(x,y,z=1) | |
2600 |
|
2601 | |||
2601 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the |
|
2602 | will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the | |
2602 | execution starts, a message will be printed indicating the job |
|
2603 | execution starts, a message will be printed indicating the job | |
2603 | number. If your job number is 5, you can use |
|
2604 | number. If your job number is 5, you can use | |
2604 |
|
2605 | |||
2605 | myvar = jobs.result(5) or myvar = jobs[5].result |
|
2606 | myvar = jobs.result(5) or myvar = jobs[5].result | |
2606 |
|
2607 | |||
2607 | to assign this result to variable 'myvar'. |
|
2608 | to assign this result to variable 'myvar'. | |
2608 |
|
2609 | |||
2609 | IPython has a job manager, accessible via the 'jobs' object. You can |
|
2610 | IPython has a job manager, accessible via the 'jobs' object. You can | |
2610 | type jobs? to get more information about it, and use jobs.<TAB> to see |
|
2611 | type jobs? to get more information about it, and use jobs.<TAB> to see | |
2611 | its attributes. All attributes not starting with an underscore are |
|
2612 | its attributes. All attributes not starting with an underscore are | |
2612 | meant for public use. |
|
2613 | meant for public use. | |
2613 |
|
2614 | |||
2614 | In particular, look at the jobs.new() method, which is used to create |
|
2615 | In particular, look at the jobs.new() method, which is used to create | |
2615 | new jobs. This magic %bg function is just a convenience wrapper |
|
2616 | new jobs. This magic %bg function is just a convenience wrapper | |
2616 | around jobs.new(), for expression-based jobs. If you want to create a |
|
2617 | around jobs.new(), for expression-based jobs. If you want to create a | |
2617 | new job with an explicit function object and arguments, you must call |
|
2618 | new job with an explicit function object and arguments, you must call | |
2618 | jobs.new() directly. |
|
2619 | jobs.new() directly. | |
2619 |
|
2620 | |||
2620 | The jobs.new docstring also describes in detail several important |
|
2621 | The jobs.new docstring also describes in detail several important | |
2621 | caveats associated with a thread-based model for background job |
|
2622 | caveats associated with a thread-based model for background job | |
2622 | execution. Type jobs.new? for details. |
|
2623 | execution. Type jobs.new? for details. | |
2623 |
|
2624 | |||
2624 | You can check the status of all jobs with jobs.status(). |
|
2625 | You can check the status of all jobs with jobs.status(). | |
2625 |
|
2626 | |||
2626 | The jobs variable is set by IPython into the Python builtin namespace. |
|
2627 | The jobs variable is set by IPython into the Python builtin namespace. | |
2627 | If you ever declare a variable named 'jobs', you will shadow this |
|
2628 | If you ever declare a variable named 'jobs', you will shadow this | |
2628 | name. You can either delete your global jobs variable to regain |
|
2629 | name. You can either delete your global jobs variable to regain | |
2629 | access to the job manager, or make a new name and assign it manually |
|
2630 | access to the job manager, or make a new name and assign it manually | |
2630 | to the manager (stored in IPython's namespace). For example, to |
|
2631 | to the manager (stored in IPython's namespace). For example, to | |
2631 | assign the job manager to the Jobs name, use: |
|
2632 | assign the job manager to the Jobs name, use: | |
2632 |
|
2633 | |||
2633 | Jobs = __builtins__.jobs""" |
|
2634 | Jobs = __builtins__.jobs""" | |
2634 |
|
2635 | |||
2635 | self.shell.jobs.new(parameter_s,self.shell.user_ns) |
|
2636 | self.shell.jobs.new(parameter_s,self.shell.user_ns) | |
2636 |
|
2637 | |||
2637 | def magic_store(self, parameter_s=''): |
|
|||
2638 | """Lightweight persistence for python variables. |
|
|||
2639 |
|
||||
2640 | Example: |
|
|||
2641 |
|
||||
2642 | ville@badger[~]|1> A = ['hello',10,'world']\\ |
|
|||
2643 | ville@badger[~]|2> %store A\\ |
|
|||
2644 | ville@badger[~]|3> Exit |
|
|||
2645 |
|
||||
2646 | (IPython session is closed and started again...) |
|
|||
2647 |
|
||||
2648 | ville@badger:~$ ipython -p pysh\\ |
|
|||
2649 | ville@badger[~]|1> print A |
|
|||
2650 |
|
||||
2651 | ['hello', 10, 'world'] |
|
|||
2652 |
|
||||
2653 | Usage: |
|
|||
2654 |
|
||||
2655 | %store - Show list of all variables and their current values\\ |
|
|||
2656 | %store <var> - Store the *current* value of the variable to disk\\ |
|
|||
2657 | %store -d <var> - Remove the variable and its value from storage\\ |
|
|||
2658 | %store -r - Remove all variables from storage\\ |
|
|||
2659 | %store foo >a.txt - Store value of foo to new file a.txt\\ |
|
|||
2660 | %store foo >>a.txt - Append value of foo to file a.txt\\ |
|
|||
2661 |
|
||||
2662 | It should be noted that if you change the value of a variable, you |
|
|||
2663 | need to %store it again if you want to persist the new value. |
|
|||
2664 |
|
||||
2665 | Note also that the variables will need to be pickleable; most basic |
|
|||
2666 | python types can be safely %stored. |
|
|||
2667 | """ |
|
|||
2668 |
|
||||
2669 | opts,argsl = self.parse_options(parameter_s,'dr',mode='string') |
|
|||
2670 | args = argsl.split(None,1) |
|
|||
2671 | ip = self.getapi() |
|
|||
2672 | # delete |
|
|||
2673 | if opts.has_key('d'): |
|
|||
2674 | try: |
|
|||
2675 | todel = args[0] |
|
|||
2676 | except IndexError: |
|
|||
2677 | error('You must provide the variable to forget') |
|
|||
2678 | else: |
|
|||
2679 | try: |
|
|||
2680 | del self.shell.persist['S:' + todel] |
|
|||
2681 | except: |
|
|||
2682 | error("Can't delete variable '%s'" % todel) |
|
|||
2683 | # reset |
|
|||
2684 | elif opts.has_key('r'): |
|
|||
2685 | for k in self.shell.persist.keys(): |
|
|||
2686 | if k.startswith('S:'): |
|
|||
2687 | del self.shell.persist[k] |
|
|||
2688 |
|
||||
2689 | # run without arguments -> list variables & values |
|
|||
2690 | elif not args: |
|
|||
2691 | vars = [v[2:] for v in self.shell.persist.keys() |
|
|||
2692 | if v.startswith('S:')] |
|
|||
2693 | vars.sort() |
|
|||
2694 | if vars: |
|
|||
2695 | size = max(map(len,vars)) |
|
|||
2696 | else: |
|
|||
2697 | size = 0 |
|
|||
2698 |
|
||||
2699 | print 'Stored variables and their in-memory values:' |
|
|||
2700 | fmt = '%-'+str(size)+'s -> %s' |
|
|||
2701 | get = self.shell.user_ns.get |
|
|||
2702 | for var in vars: |
|
|||
2703 | # print 30 first characters from every var |
|
|||
2704 | print fmt % (var,repr(get(var,'<unavailable>'))[:50]) |
|
|||
2705 |
|
||||
2706 | # default action - store the variable |
|
|||
2707 | else: |
|
|||
2708 | # %store foo >file.txt or >>file.txt |
|
|||
2709 | if len(args) > 1 and args[1].startswith('>'): |
|
|||
2710 | fnam = os.path.expanduser(args[1].lstrip('>').lstrip()) |
|
|||
2711 | if args[1].startswith('>>'): |
|
|||
2712 | fil = open(fnam,'a') |
|
|||
2713 | else: |
|
|||
2714 | fil = open(fnam,'w') |
|
|||
2715 | obj = ip.ev(args[0]) |
|
|||
2716 | print "Writing '%s' (%s) to file '%s'." % (args[0], |
|
|||
2717 | obj.__class__.__name__, fnam) |
|
|||
2718 |
|
||||
2719 |
|
||||
2720 | if not isinstance (obj,basestring): |
|
|||
2721 | pprint(obj,fil) |
|
|||
2722 | else: |
|
|||
2723 | fil.write(obj) |
|
|||
2724 | if not obj.endswith('\n'): |
|
|||
2725 | fil.write('\n') |
|
|||
2726 |
|
||||
2727 | fil.close() |
|
|||
2728 | return |
|
|||
2729 |
|
||||
2730 | # %store foo |
|
|||
2731 | obj = self.shell.user_ns[args[0] ] |
|
|||
2732 | if isinstance(inspect.getmodule(obj), FakeModule): |
|
|||
2733 | print textwrap.dedent("""\ |
|
|||
2734 | Warning:%s is %s |
|
|||
2735 | Proper storage of interactively declared classes (or instances |
|
|||
2736 | of those classes) is not possible! Only instances |
|
|||
2737 | of classes in real modules on file system can be %%store'd. |
|
|||
2738 | """ % (args[0], obj) ) |
|
|||
2739 | return |
|
|||
2740 | pickled = pickle.dumps(obj) |
|
|||
2741 | self.shell.persist[ 'S:' + args[0] ] = pickled |
|
|||
2742 | print "Stored '%s' (%s, %d bytes)" % (args[0], obj.__class__.__name__,len(pickled)) |
|
|||
2743 |
|
2638 | |||
2744 | def magic_bookmark(self, parameter_s=''): |
|
2639 | def magic_bookmark(self, parameter_s=''): | |
2745 | """Manage IPython's bookmark system. |
|
2640 | """Manage IPython's bookmark system. | |
2746 |
|
2641 | |||
2747 | %bookmark <name> - set bookmark to current dir |
|
2642 | %bookmark <name> - set bookmark to current dir | |
2748 | %bookmark <name> <dir> - set bookmark to <dir> |
|
2643 | %bookmark <name> <dir> - set bookmark to <dir> | |
2749 | %bookmark -l - list all bookmarks |
|
2644 | %bookmark -l - list all bookmarks | |
2750 | %bookmark -d <name> - remove bookmark |
|
2645 | %bookmark -d <name> - remove bookmark | |
2751 | %bookmark -r - remove all bookmarks |
|
2646 | %bookmark -r - remove all bookmarks | |
2752 |
|
2647 | |||
2753 | You can later on access a bookmarked folder with: |
|
2648 | You can later on access a bookmarked folder with: | |
2754 | %cd -b <name> |
|
2649 | %cd -b <name> | |
2755 | or simply '%cd <name>' if there is no directory called <name> AND |
|
2650 | or simply '%cd <name>' if there is no directory called <name> AND | |
2756 | there is such a bookmark defined. |
|
2651 | there is such a bookmark defined. | |
2757 |
|
2652 | |||
2758 | Your bookmarks persist through IPython sessions, but they are |
|
2653 | Your bookmarks persist through IPython sessions, but they are | |
2759 | associated with each profile.""" |
|
2654 | associated with each profile.""" | |
2760 |
|
2655 | |||
2761 | opts,args = self.parse_options(parameter_s,'drl',mode='list') |
|
2656 | opts,args = self.parse_options(parameter_s,'drl',mode='list') | |
2762 | if len(args) > 2: |
|
2657 | if len(args) > 2: | |
2763 | error('You can only give at most two arguments') |
|
2658 | error('You can only give at most two arguments') | |
2764 | return |
|
2659 | return | |
2765 |
|
2660 | |||
2766 |
bkms = self. |
|
2661 | bkms = self.db.get('bookmarks',{}) | |
2767 |
|
2662 | |||
2768 | if opts.has_key('d'): |
|
2663 | if opts.has_key('d'): | |
2769 | try: |
|
2664 | try: | |
2770 | todel = args[0] |
|
2665 | todel = args[0] | |
2771 | except IndexError: |
|
2666 | except IndexError: | |
2772 | error('You must provide a bookmark to delete') |
|
2667 | error('You must provide a bookmark to delete') | |
2773 | else: |
|
2668 | else: | |
2774 | try: |
|
2669 | try: | |
2775 | del bkms[todel] |
|
2670 | del bkms[todel] | |
2776 | except: |
|
2671 | except: | |
2777 | error("Can't delete bookmark '%s'" % todel) |
|
2672 | error("Can't delete bookmark '%s'" % todel) | |
2778 | elif opts.has_key('r'): |
|
2673 | elif opts.has_key('r'): | |
2779 | bkms = {} |
|
2674 | bkms = {} | |
2780 | elif opts.has_key('l'): |
|
2675 | elif opts.has_key('l'): | |
2781 | bks = bkms.keys() |
|
2676 | bks = bkms.keys() | |
2782 | bks.sort() |
|
2677 | bks.sort() | |
2783 | if bks: |
|
2678 | if bks: | |
2784 | size = max(map(len,bks)) |
|
2679 | size = max(map(len,bks)) | |
2785 | else: |
|
2680 | else: | |
2786 | size = 0 |
|
2681 | size = 0 | |
2787 | fmt = '%-'+str(size)+'s -> %s' |
|
2682 | fmt = '%-'+str(size)+'s -> %s' | |
2788 | print 'Current bookmarks:' |
|
2683 | print 'Current bookmarks:' | |
2789 | for bk in bks: |
|
2684 | for bk in bks: | |
2790 | print fmt % (bk,bkms[bk]) |
|
2685 | print fmt % (bk,bkms[bk]) | |
2791 | else: |
|
2686 | else: | |
2792 | if not args: |
|
2687 | if not args: | |
2793 | error("You must specify the bookmark name") |
|
2688 | error("You must specify the bookmark name") | |
2794 | elif len(args)==1: |
|
2689 | elif len(args)==1: | |
2795 | bkms[args[0]] = os.getcwd() |
|
2690 | bkms[args[0]] = os.getcwd() | |
2796 | elif len(args)==2: |
|
2691 | elif len(args)==2: | |
2797 | bkms[args[0]] = args[1] |
|
2692 | bkms[args[0]] = args[1] | |
2798 |
self. |
|
2693 | self.db['bookmarks'] = bkms | |
2799 |
|
2694 | |||
2800 | def magic_pycat(self, parameter_s=''): |
|
2695 | def magic_pycat(self, parameter_s=''): | |
2801 | """Show a syntax-highlighted file through a pager. |
|
2696 | """Show a syntax-highlighted file through a pager. | |
2802 |
|
2697 | |||
2803 | This magic is similar to the cat utility, but it will assume the file |
|
2698 | This magic is similar to the cat utility, but it will assume the file | |
2804 | to be Python source and will show it with syntax highlighting. """ |
|
2699 | to be Python source and will show it with syntax highlighting. """ | |
2805 |
|
2700 | |||
2806 | filename = get_py_filename(parameter_s) |
|
2701 | filename = get_py_filename(parameter_s) | |
2807 | page(self.shell.pycolorize(file_read(filename)), |
|
2702 | page(self.shell.pycolorize(file_read(filename)), | |
2808 | screen_lines=self.shell.rc.screen_length) |
|
2703 | screen_lines=self.shell.rc.screen_length) | |
2809 |
|
2704 | |||
2810 | def magic_cpaste(self, parameter_s=''): |
|
2705 | def magic_cpaste(self, parameter_s=''): | |
2811 | """Allows you to paste & execute a pre-formatted code block from |
|
2706 | """Allows you to paste & execute a pre-formatted code block from | |
2812 | clipboard. |
|
2707 | clipboard. | |
2813 |
|
2708 | |||
2814 | You must terminate the block with '--' (two minus-signs) alone on the |
|
2709 | You must terminate the block with '--' (two minus-signs) alone on the | |
2815 | line. You can also provide your own sentinel with '%paste -s %%' ('%%' |
|
2710 | line. You can also provide your own sentinel with '%paste -s %%' ('%%' | |
2816 | is the new sentinel for this operation) |
|
2711 | is the new sentinel for this operation) | |
2817 |
|
2712 | |||
2818 | The block is dedented prior to execution to enable execution of |
|
2713 | The block is dedented prior to execution to enable execution of | |
2819 | method definitions. The executed block is also assigned to variable |
|
2714 | method definitions. The executed block is also assigned to variable | |
2820 | named 'pasted_block' for later editing with '%edit pasted_block'. |
|
2715 | named 'pasted_block' for later editing with '%edit pasted_block'. | |
2821 |
|
2716 | |||
2822 | You can also pass a variable name as an argument, e.g. '%cpaste foo'. |
|
2717 | You can also pass a variable name as an argument, e.g. '%cpaste foo'. | |
2823 | This assigns the pasted block to variable 'foo' as string, without |
|
2718 | This assigns the pasted block to variable 'foo' as string, without | |
2824 | dedenting or executing it. |
|
2719 | dedenting or executing it. | |
2825 |
|
2720 | |||
2826 | Do not be alarmed by garbled output on Windows (it's a readline bug). |
|
2721 | Do not be alarmed by garbled output on Windows (it's a readline bug). | |
2827 | Just press enter and type -- (and press enter again) and the block |
|
2722 | Just press enter and type -- (and press enter again) and the block | |
2828 | will be what was just pasted. |
|
2723 | will be what was just pasted. | |
2829 |
|
2724 | |||
2830 | IPython statements (magics, shell escapes) are not supported (yet). |
|
2725 | IPython statements (magics, shell escapes) are not supported (yet). | |
2831 | """ |
|
2726 | """ | |
2832 | opts,args = self.parse_options(parameter_s,'s:',mode='string') |
|
2727 | opts,args = self.parse_options(parameter_s,'s:',mode='string') | |
2833 | par = args.strip() |
|
2728 | par = args.strip() | |
2834 | sentinel = opts.get('s','--') |
|
2729 | sentinel = opts.get('s','--') | |
2835 |
|
2730 | |||
2836 | from IPython import iplib |
|
2731 | from IPython import iplib | |
2837 | lines = [] |
|
2732 | lines = [] | |
2838 | print "Pasting code; enter '%s' alone on the line to stop." % sentinel |
|
2733 | print "Pasting code; enter '%s' alone on the line to stop." % sentinel | |
2839 | while 1: |
|
2734 | while 1: | |
2840 | l = iplib.raw_input_original(':') |
|
2735 | l = iplib.raw_input_original(':') | |
2841 | if l ==sentinel: |
|
2736 | if l ==sentinel: | |
2842 | break |
|
2737 | break | |
2843 | lines.append(l) |
|
2738 | lines.append(l) | |
2844 | block = "\n".join(lines) + '\n' |
|
2739 | block = "\n".join(lines) + '\n' | |
2845 | #print "block:\n",block |
|
2740 | #print "block:\n",block | |
2846 | if not par: |
|
2741 | if not par: | |
2847 | b = textwrap.dedent(block) |
|
2742 | b = textwrap.dedent(block) | |
2848 | exec b in self.user_ns |
|
2743 | exec b in self.user_ns | |
2849 | self.user_ns['pasted_block'] = b |
|
2744 | self.user_ns['pasted_block'] = b | |
2850 | else: |
|
2745 | else: | |
2851 | self.user_ns[par] = block |
|
2746 | self.user_ns[par] = block | |
2852 | print "Block assigned to '%s'" % par |
|
2747 | print "Block assigned to '%s'" % par | |
2853 | def magic_quickref(self,arg): |
|
2748 | def magic_quickref(self,arg): | |
2854 | import IPython.usage |
|
2749 | import IPython.usage | |
2855 | page(IPython.usage.quick_reference) |
|
2750 | page(IPython.usage.quick_reference) | |
2856 | del IPython.usage |
|
2751 | del IPython.usage | |
2857 |
|
2752 | |||
2858 |
|
2753 | |||
2859 | # end Magic |
|
2754 | # end Magic |
@@ -1,169 +1,184 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 | import IPython.ipapi |
|
22 | import IPython.ipapi | |
23 | ip = IPython.ipapi.get() |
|
23 | ip = IPython.ipapi.get() | |
24 |
|
24 | |||
25 | def calljed(self,filename, linenum): |
|
25 | def calljed(self,filename, linenum): | |
26 | "My editor hook calls the jed editor directly." |
|
26 | "My editor hook calls the jed editor directly." | |
27 | print "Calling my own editor, jed ..." |
|
27 | print "Calling my own editor, jed ..." | |
28 | os.system('jed +%d %s' % (linenum,filename)) |
|
28 | os.system('jed +%d %s' % (linenum,filename)) | |
29 |
|
29 | |||
30 | ip.set_hook('editor', calljed) |
|
30 | ip.set_hook('editor', calljed) | |
31 |
|
31 | |||
32 | You can then enable the functionality by doing 'import myiphooks' |
|
32 | You can then enable the functionality by doing 'import myiphooks' | |
33 | somewhere in your configuration files or ipython command line. |
|
33 | somewhere in your configuration files or ipython command line. | |
34 |
|
34 | |||
35 |
$Id: hooks.py 1 |
|
35 | $Id: hooks.py 1107 2006-01-30 19:02:20Z vivainio $""" | |
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 | from IPython import ipapi |
|
45 | from IPython import ipapi | |
46 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
46 | __author__ = '%s <%s>' % Release.authors['Fernando'] | |
47 | __license__ = Release.license |
|
47 | __license__ = Release.license | |
48 | __version__ = Release.version |
|
48 | __version__ = Release.version | |
49 |
|
49 | |||
50 | import os,bisect |
|
50 | import os,bisect | |
51 | from genutils import Term |
|
51 | from genutils import Term | |
52 | from pprint import pformat |
|
52 | from pprint import pformat | |
53 |
|
53 | |||
54 | # List here all the default hooks. For now it's just the editor functions |
|
54 | # List here all the default hooks. For now it's just the editor functions | |
55 | # but over time we'll move here all the public API for user-accessible things. |
|
55 | # but over time we'll move here all the public API for user-accessible things. | |
56 | __all__ = ['editor', 'fix_error_editor', 'result_display', |
|
56 | __all__ = ['editor', 'fix_error_editor', 'result_display', | |
57 | 'input_prefilter'] |
|
57 | 'input_prefilter', 'shutdown_hook', 'late_startup_hook'] | |
58 |
|
58 | |||
59 | def editor(self,filename, linenum=None): |
|
59 | def editor(self,filename, linenum=None): | |
60 | """Open the default editor at the given filename and linenumber. |
|
60 | """Open the default editor at the given filename and linenumber. | |
61 |
|
61 | |||
62 | This is IPython's default editor hook, you can use it as an example to |
|
62 | This is IPython's default editor hook, you can use it as an example to | |
63 | write your own modified one. To set your own editor function as the |
|
63 | write your own modified one. To set your own editor function as the | |
64 | new editor hook, call ip.set_hook('editor',yourfunc).""" |
|
64 | new editor hook, call ip.set_hook('editor',yourfunc).""" | |
65 |
|
65 | |||
66 | # IPython configures a default editor at startup by reading $EDITOR from |
|
66 | # IPython configures a default editor at startup by reading $EDITOR from | |
67 | # the environment, and falling back on vi (unix) or notepad (win32). |
|
67 | # the environment, and falling back on vi (unix) or notepad (win32). | |
68 | editor = self.rc.editor |
|
68 | editor = self.rc.editor | |
69 |
|
69 | |||
70 | # marker for at which line to open the file (for existing objects) |
|
70 | # marker for at which line to open the file (for existing objects) | |
71 | if linenum is None or editor=='notepad': |
|
71 | if linenum is None or editor=='notepad': | |
72 | linemark = '' |
|
72 | linemark = '' | |
73 | else: |
|
73 | else: | |
74 | linemark = '+%d' % linenum |
|
74 | linemark = '+%d' % linenum | |
75 | # Call the actual editor |
|
75 | # Call the actual editor | |
76 | os.system('%s %s %s' % (editor,linemark,filename)) |
|
76 | os.system('%s %s %s' % (editor,linemark,filename)) | |
77 |
|
77 | |||
78 | import tempfile |
|
78 | import tempfile | |
79 | def fix_error_editor(self,filename,linenum,column,msg): |
|
79 | def fix_error_editor(self,filename,linenum,column,msg): | |
80 | """Open the editor at the given filename, linenumber, column and |
|
80 | """Open the editor at the given filename, linenumber, column and | |
81 | show an error message. This is used for correcting syntax errors. |
|
81 | show an error message. This is used for correcting syntax errors. | |
82 | The current implementation only has special support for the VIM editor, |
|
82 | The current implementation only has special support for the VIM editor, | |
83 | and falls back on the 'editor' hook if VIM is not used. |
|
83 | and falls back on the 'editor' hook if VIM is not used. | |
84 |
|
84 | |||
85 | Call ip.set_hook('fix_error_editor',youfunc) to use your own function, |
|
85 | Call ip.set_hook('fix_error_editor',youfunc) to use your own function, | |
86 | """ |
|
86 | """ | |
87 | def vim_quickfix_file(): |
|
87 | def vim_quickfix_file(): | |
88 | t = tempfile.NamedTemporaryFile() |
|
88 | t = tempfile.NamedTemporaryFile() | |
89 | t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg)) |
|
89 | t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg)) | |
90 | t.flush() |
|
90 | t.flush() | |
91 | return t |
|
91 | return t | |
92 | if os.path.basename(self.rc.editor) != 'vim': |
|
92 | if os.path.basename(self.rc.editor) != 'vim': | |
93 | self.hooks.editor(filename,linenum) |
|
93 | self.hooks.editor(filename,linenum) | |
94 | return |
|
94 | return | |
95 | t = vim_quickfix_file() |
|
95 | t = vim_quickfix_file() | |
96 | try: |
|
96 | try: | |
97 | os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name) |
|
97 | os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name) | |
98 | finally: |
|
98 | finally: | |
99 | t.close() |
|
99 | t.close() | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | class CommandChainDispatcher: |
|
102 | class CommandChainDispatcher: | |
103 | """ Dispatch calls to a chain of commands until some func can handle it |
|
103 | """ Dispatch calls to a chain of commands until some func can handle it | |
104 |
|
104 | |||
105 | Usage: instantiate, execute "add" to add commands (with optional |
|
105 | Usage: instantiate, execute "add" to add commands (with optional | |
106 | priority), execute normally via f() calling mechanism. |
|
106 | priority), execute normally via f() calling mechanism. | |
107 |
|
107 | |||
108 | """ |
|
108 | """ | |
109 | def __init__(self,commands=None): |
|
109 | def __init__(self,commands=None): | |
110 | if commands is None: |
|
110 | if commands is None: | |
111 | self.chain = [] |
|
111 | self.chain = [] | |
112 | else: |
|
112 | else: | |
113 | self.chain = commands |
|
113 | self.chain = commands | |
114 |
|
114 | |||
115 |
|
115 | |||
116 | def __call__(self,*args, **kw): |
|
116 | def __call__(self,*args, **kw): | |
117 | """ Command chain is called just like normal func. |
|
117 | """ Command chain is called just like normal func. | |
118 |
|
118 | |||
119 | This will call all funcs in chain with the same args as were given to this |
|
119 | This will call all funcs in chain with the same args as were given to this | |
120 | function, and return the result of first func that didn't raise |
|
120 | function, and return the result of first func that didn't raise | |
121 | TryNext """ |
|
121 | TryNext """ | |
122 |
|
122 | |||
123 | for prio,cmd in self.chain: |
|
123 | for prio,cmd in self.chain: | |
124 | #print "prio",prio,"cmd",cmd #dbg |
|
124 | #print "prio",prio,"cmd",cmd #dbg | |
125 | try: |
|
125 | try: | |
126 | ret = cmd(*args, **kw) |
|
126 | ret = cmd(*args, **kw) | |
127 | return ret |
|
127 | return ret | |
128 | except ipapi.TryNext: |
|
128 | except ipapi.TryNext: | |
129 | pass |
|
129 | pass | |
130 |
|
130 | |||
131 | def __str__(self): |
|
131 | def __str__(self): | |
132 | return str(self.chain) |
|
132 | return str(self.chain) | |
133 |
|
133 | |||
134 | def add(self, func, priority=0): |
|
134 | def add(self, func, priority=0): | |
135 | """ Add a func to the cmd chain with given priority """ |
|
135 | """ Add a func to the cmd chain with given priority """ | |
136 | bisect.insort(self.chain,(priority,func)) |
|
136 | bisect.insort(self.chain,(priority,func)) | |
137 |
|
137 | |||
138 | def result_display(self,arg): |
|
138 | def result_display(self,arg): | |
139 | """ Default display hook. |
|
139 | """ Default display hook. | |
140 |
|
140 | |||
141 | Called for displaying the result to the user. |
|
141 | Called for displaying the result to the user. | |
142 | """ |
|
142 | """ | |
143 |
|
143 | |||
144 | if self.rc.pprint: |
|
144 | if self.rc.pprint: | |
145 | out = pformat(arg) |
|
145 | out = pformat(arg) | |
146 | if '\n' in out: |
|
146 | if '\n' in out: | |
147 | # So that multi-line strings line up with the left column of |
|
147 | # So that multi-line strings line up with the left column of | |
148 | # the screen, instead of having the output prompt mess up |
|
148 | # the screen, instead of having the output prompt mess up | |
149 | # their first line. |
|
149 | # their first line. | |
150 | Term.cout.write('\n') |
|
150 | Term.cout.write('\n') | |
151 | print >>Term.cout, out |
|
151 | print >>Term.cout, out | |
152 | else: |
|
152 | else: | |
153 | print >>Term.cout, arg |
|
153 | print >>Term.cout, arg | |
154 | # the default display hook doesn't manipulate the value to put in history |
|
154 | # the default display hook doesn't manipulate the value to put in history | |
155 | return None |
|
155 | return None | |
156 |
|
156 | |||
157 | def input_prefilter(self,line): |
|
157 | def input_prefilter(self,line): | |
158 | """ Default input prefilter |
|
158 | """ Default input prefilter | |
159 |
|
159 | |||
160 | This returns the line as unchanged, so that the interpreter |
|
160 | This returns the line as unchanged, so that the interpreter | |
161 | knows that nothing was done and proceeds with "classic" prefiltering |
|
161 | knows that nothing was done and proceeds with "classic" prefiltering | |
162 | (%magics, !shell commands etc.). |
|
162 | (%magics, !shell commands etc.). | |
163 |
|
163 | |||
164 | Note that leading whitespace is not passed to this hook. Prefilter |
|
164 | Note that leading whitespace is not passed to this hook. Prefilter | |
165 | can't alter indentation. |
|
165 | can't alter indentation. | |
166 |
|
166 | |||
167 | """ |
|
167 | """ | |
168 | #print "attempt to rewrite",line #dbg |
|
168 | #print "attempt to rewrite",line #dbg | |
169 | return line |
|
169 | return line | |
|
170 | ||||
|
171 | def shutdown_hook(self): | |||
|
172 | """ default shutdown hook | |||
|
173 | ||||
|
174 | Typically, shotdown hooks should raise TryNext so all shutdown ops are done | |||
|
175 | """ | |||
|
176 | ||||
|
177 | #print "default shutdown hook ok" # dbg | |||
|
178 | return | |||
|
179 | ||||
|
180 | def late_startup_hook(self): | |||
|
181 | """ Executed after ipython has been constructed and configured | |||
|
182 | ||||
|
183 | """ | |||
|
184 | #print "default startup hook ok" # dbg No newline at end of file |
@@ -1,177 +1,184 b'' | |||||
1 | ''' IPython customization API |
|
1 | ''' IPython customization API | |
2 |
|
2 | |||
3 | Your one-stop module for configuring & extending ipython |
|
3 | Your one-stop module for configuring & extending ipython | |
4 |
|
4 | |||
5 | The API will probably break when ipython 1.0 is released, but so |
|
5 | The API will probably break when ipython 1.0 is released, but so | |
6 | will the other configuration method (rc files). |
|
6 | will the other configuration method (rc files). | |
7 |
|
7 | |||
8 | All names prefixed by underscores are for internal use, not part |
|
8 | All names prefixed by underscores are for internal use, not part | |
9 | of the public api. |
|
9 | of the public api. | |
10 |
|
10 | |||
11 | Below is an example that you can just put to a module and import from ipython. |
|
11 | Below is an example that you can just put to a module and import from ipython. | |
12 |
|
12 | |||
13 | A good practice is to install the config script below as e.g. |
|
13 | A good practice is to install the config script below as e.g. | |
14 |
|
14 | |||
15 | ~/.ipython/my_private_conf.py |
|
15 | ~/.ipython/my_private_conf.py | |
16 |
|
16 | |||
17 | And do |
|
17 | And do | |
18 |
|
18 | |||
19 | import_mod my_private_conf |
|
19 | import_mod my_private_conf | |
20 |
|
20 | |||
21 | in ~/.ipython/ipythonrc |
|
21 | in ~/.ipython/ipythonrc | |
22 |
|
22 | |||
23 | That way the module is imported at startup and you can have all your |
|
23 | That way the module is imported at startup and you can have all your | |
24 | personal configuration (as opposed to boilerplate ipythonrc-PROFILENAME |
|
24 | personal configuration (as opposed to boilerplate ipythonrc-PROFILENAME | |
25 | stuff) in there. |
|
25 | stuff) in there. | |
26 |
|
26 | |||
27 | ----------------------------------------------- |
|
27 | ----------------------------------------------- | |
28 | import IPython.ipapi as ip |
|
28 | import IPython.ipapi as ip | |
29 |
|
29 | |||
30 | def ankka_f(self, arg): |
|
30 | def ankka_f(self, arg): | |
31 | print "Ankka",self,"says uppercase:",arg.upper() |
|
31 | print "Ankka",self,"says uppercase:",arg.upper() | |
32 |
|
32 | |||
33 | ip.expose_magic("ankka",ankka_f) |
|
33 | ip.expose_magic("ankka",ankka_f) | |
34 |
|
34 | |||
35 | ip.magic('alias sayhi echo "Testing, hi ok"') |
|
35 | ip.magic('alias sayhi echo "Testing, hi ok"') | |
36 | ip.magic('alias helloworld echo "Hello world"') |
|
36 | ip.magic('alias helloworld echo "Hello world"') | |
37 | ip.system('pwd') |
|
37 | ip.system('pwd') | |
38 |
|
38 | |||
39 | ip.ex('import re') |
|
39 | ip.ex('import re') | |
40 | ip.ex(""" |
|
40 | ip.ex(""" | |
41 | def funcci(a,b): |
|
41 | def funcci(a,b): | |
42 | print a+b |
|
42 | print a+b | |
43 | print funcci(3,4) |
|
43 | print funcci(3,4) | |
44 | """) |
|
44 | """) | |
45 | ip.ex("funcci(348,9)") |
|
45 | ip.ex("funcci(348,9)") | |
46 |
|
46 | |||
47 | def jed_editor(self,filename, linenum=None): |
|
47 | def jed_editor(self,filename, linenum=None): | |
48 | print "Calling my own editor, jed ... via hook!" |
|
48 | print "Calling my own editor, jed ... via hook!" | |
49 | import os |
|
49 | import os | |
50 | if linenum is None: linenum = 0 |
|
50 | if linenum is None: linenum = 0 | |
51 | os.system('jed +%d %s' % (linenum, filename)) |
|
51 | os.system('jed +%d %s' % (linenum, filename)) | |
52 | print "exiting jed" |
|
52 | print "exiting jed" | |
53 |
|
53 | |||
54 | ip.set_hook('editor',jed_editor) |
|
54 | ip.set_hook('editor',jed_editor) | |
55 |
|
55 | |||
56 | o = ip.options() |
|
56 | o = ip.options() | |
57 | o.autocall = 2 # FULL autocall mode |
|
57 | o.autocall = 2 # FULL autocall mode | |
58 |
|
58 | |||
59 | print "done!" |
|
59 | print "done!" | |
60 |
|
60 | |||
61 | ''' |
|
61 | ''' | |
62 |
|
62 | |||
63 |
|
63 | |||
64 | class TryNext(Exception): |
|
64 | class TryNext(Exception): | |
65 | """ Try next hook exception. |
|
65 | """ Try next hook exception. | |
66 |
|
66 | |||
67 | Raise this in your hook function to indicate that the next |
|
67 | Raise this in your hook function to indicate that the next | |
68 | hook handler should be used to handle the operation. |
|
68 | hook handler should be used to handle the operation. | |
69 | """ |
|
69 | """ | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | # contains the most recently instantiated IPApi |
|
72 | # contains the most recently instantiated IPApi | |
73 | _recent = None |
|
73 | _recent = None | |
74 |
|
74 | |||
75 | def get(): |
|
75 | def get(): | |
76 | """ Get an IPApi object, or None if not running under ipython |
|
76 | """ Get an IPApi object, or None if not running under ipython | |
77 |
|
77 | |||
78 | Running this should be the first thing you do when writing |
|
78 | Running this should be the first thing you do when writing | |
79 | extensions that can be imported as normal modules. You can then |
|
79 | extensions that can be imported as normal modules. You can then | |
80 | direct all the configuration operations against the returned |
|
80 | direct all the configuration operations against the returned | |
81 | object. |
|
81 | object. | |
82 |
|
82 | |||
83 | """ |
|
83 | """ | |
84 |
|
84 | |||
85 | return _recent |
|
85 | return _recent | |
86 |
|
86 | |||
87 |
|
87 | |||
88 |
|
88 | |||
89 | class IPApi: |
|
89 | class IPApi: | |
90 | """ The actual API class for configuring IPython |
|
90 | """ The actual API class for configuring IPython | |
91 |
|
91 | |||
92 | You should do all of the IPython configuration by getting |
|
92 | You should do all of the IPython configuration by getting | |
93 | an IPApi object with IPython.ipapi.get() and using the provided |
|
93 | an IPApi object with IPython.ipapi.get() and using the provided | |
94 | methods. |
|
94 | methods. | |
95 |
|
95 | |||
96 | """ |
|
96 | """ | |
97 | def __init__(self,ip): |
|
97 | def __init__(self,ip): | |
98 |
|
98 | |||
99 | self.magic = ip.ipmagic |
|
99 | self.magic = ip.ipmagic | |
100 |
|
100 | |||
101 | self.system = ip.ipsystem |
|
101 | self.system = ip.ipsystem | |
102 |
|
102 | |||
103 | self.set_hook = ip.set_hook |
|
103 | self.set_hook = ip.set_hook | |
104 |
|
104 | |||
105 | self.IP = ip |
|
105 | self.IP = ip | |
106 | global _recent |
|
106 | global _recent | |
107 | _recent = self |
|
107 | _recent = self | |
108 |
|
108 | |||
109 |
|
109 | |||
110 |
|
110 | |||
111 | def options(self): |
|
111 | def options(self): | |
112 | """ All configurable variables """ |
|
112 | """ All configurable variables """ | |
113 | return self.IP.rc |
|
113 | return self.IP.rc | |
114 |
|
114 | |||
115 | def user_ns(self): |
|
115 | def user_ns(self): | |
116 | return self.IP.user_ns |
|
116 | return self.IP.user_ns | |
117 |
|
117 | |||
118 | def expose_magic(self,magicname, func): |
|
118 | def expose_magic(self,magicname, func): | |
119 | ''' Expose own function as magic function for ipython |
|
119 | ''' Expose own function as magic function for ipython | |
120 |
|
120 | |||
121 | def foo_impl(self,parameter_s=''): |
|
121 | def foo_impl(self,parameter_s=''): | |
122 | """My very own magic!. (Use docstrings, IPython reads them).""" |
|
122 | """My very own magic!. (Use docstrings, IPython reads them).""" | |
123 | print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>' |
|
123 | print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>' | |
124 | print 'The self object is:',self |
|
124 | print 'The self object is:',self | |
125 |
|
125 | |||
126 | ipapi.expose_magic("foo",foo_impl) |
|
126 | ipapi.expose_magic("foo",foo_impl) | |
127 | ''' |
|
127 | ''' | |
128 |
|
128 | |||
129 | import new |
|
129 | import new | |
130 | im = new.instancemethod(func,self.IP, self.IP.__class__) |
|
130 | im = new.instancemethod(func,self.IP, self.IP.__class__) | |
131 | setattr(self.IP, "magic_" + magicname, im) |
|
131 | setattr(self.IP, "magic_" + magicname, im) | |
132 |
|
132 | |||
133 |
|
133 | |||
134 | def ex(self,cmd): |
|
134 | def ex(self,cmd): | |
135 | """ Execute a normal python statement in user namespace """ |
|
135 | """ Execute a normal python statement in user namespace """ | |
136 | exec cmd in self.user_ns() |
|
136 | exec cmd in self.user_ns() | |
137 |
|
137 | |||
138 | def ev(self,expr): |
|
138 | def ev(self,expr): | |
139 | """ Evaluate python expression expr in user namespace |
|
139 | """ Evaluate python expression expr in user namespace | |
140 |
|
140 | |||
141 | Returns the result of evaluation""" |
|
141 | Returns the result of evaluation""" | |
142 | return eval(expr,self.user_ns()) |
|
142 | return eval(expr,self.user_ns()) | |
143 |
|
143 | |||
144 | def meta(self): |
|
144 | def meta(self): | |
145 | """ Get a session-specific data store |
|
145 | """ Get a session-specific data store | |
146 |
|
146 | |||
147 | Object returned by this method can be used to store |
|
147 | Object returned by this method can be used to store | |
148 | data that should persist through the ipython session. |
|
148 | data that should persist through the ipython session. | |
149 | """ |
|
149 | """ | |
150 | return self.IP.meta |
|
150 | return self.IP.meta | |
151 |
|
|
151 | ||
|
152 | def getdb(self): | |||
|
153 | """ Return a handle to persistent dict-like database | |||
|
154 | ||||
|
155 | Return a PickleShareDB object. | |||
|
156 | """ | |||
|
157 | return self.IP.db | |||
|
158 | ||||
152 |
|
159 | |||
153 | def launch_new_instance(user_ns = None): |
|
160 | def launch_new_instance(user_ns = None): | |
154 | """ Create and start a new ipython instance. |
|
161 | """ Create and start a new ipython instance. | |
155 |
|
162 | |||
156 | This can be called even without having an already initialized |
|
163 | This can be called even without having an already initialized | |
157 | ipython session running. |
|
164 | ipython session running. | |
158 |
|
165 | |||
159 | This is also used as the egg entry point for the 'ipython' script. |
|
166 | This is also used as the egg entry point for the 'ipython' script. | |
160 |
|
167 | |||
161 | """ |
|
168 | """ | |
162 | ses = create_session(user_ns) |
|
169 | ses = create_session(user_ns) | |
163 | ses.mainloop() |
|
170 | ses.mainloop() | |
164 |
|
171 | |||
165 |
|
172 | |||
166 | def create_session(user_ns = None): |
|
173 | def create_session(user_ns = None): | |
167 | """ Creates, but does not launch an IPython session. |
|
174 | """ Creates, but does not launch an IPython session. | |
168 |
|
175 | |||
169 | Later on you can call obj.mainloop() on the returned object. |
|
176 | Later on you can call obj.mainloop() on the returned object. | |
170 |
|
177 | |||
171 | This should *not* be run when a session exists already. |
|
178 | This should *not* be run when a session exists already. | |
172 |
|
179 | |||
173 | """ |
|
180 | """ | |
174 | if user_ns is not None: |
|
181 | if user_ns is not None: | |
175 | user_ns["__name__"] = user_ns.get("__name__",'ipy_session') |
|
182 | user_ns["__name__"] = user_ns.get("__name__",'ipy_session') | |
176 | import IPython |
|
183 | import IPython | |
177 | return IPython.Shell.start(user_ns = user_ns) No newline at end of file |
|
184 | return IPython.Shell.start(user_ns = user_ns) |
@@ -1,2267 +1,2244 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.3 or newer. |
|
5 | Requires Python 2.3 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 110 |
|
9 | $Id: iplib.py 1107 2006-01-30 19:02:20Z vivainio $ | |
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-2006 Fernando Perez. <fperez@colorado.edu> |
|
14 | # Copyright (C) 2001-2006 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 tempfile | |
59 | import traceback |
|
59 | import traceback | |
60 | import types |
|
60 | import types | |
|
61 | import pickleshare | |||
61 |
|
62 | |||
62 | from pprint import pprint, pformat |
|
63 | from pprint import pprint, pformat | |
63 |
|
64 | |||
64 | # IPython's own modules |
|
65 | # IPython's own modules | |
65 | import IPython |
|
66 | import IPython | |
66 | from IPython import OInspect,PyColorize,ultraTB |
|
67 | from IPython import OInspect,PyColorize,ultraTB | |
67 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names |
|
68 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names | |
68 | from IPython.FakeModule import FakeModule |
|
69 | from IPython.FakeModule import FakeModule | |
69 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns |
|
70 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns | |
70 | from IPython.Logger import Logger |
|
71 | from IPython.Logger import Logger | |
71 | from IPython.Magic import Magic |
|
72 | from IPython.Magic import Magic | |
72 | from IPython.Prompts import CachedOutput |
|
73 | from IPython.Prompts import CachedOutput | |
73 | from IPython.ipstruct import Struct |
|
74 | from IPython.ipstruct import Struct | |
74 | from IPython.background_jobs import BackgroundJobManager |
|
75 | from IPython.background_jobs import BackgroundJobManager | |
75 | from IPython.usage import cmd_line_usage,interactive_usage |
|
76 | from IPython.usage import cmd_line_usage,interactive_usage | |
76 | from IPython.genutils import * |
|
77 | from IPython.genutils import * | |
77 | import IPython.ipapi |
|
78 | import IPython.ipapi | |
78 |
|
79 | |||
79 | # Globals |
|
80 | # Globals | |
80 |
|
81 | |||
81 | # store the builtin raw_input globally, and use this always, in case user code |
|
82 | # store the builtin raw_input globally, and use this always, in case user code | |
82 | # overwrites it (like wx.py.PyShell does) |
|
83 | # overwrites it (like wx.py.PyShell does) | |
83 | raw_input_original = raw_input |
|
84 | raw_input_original = raw_input | |
84 |
|
85 | |||
85 | # compiled regexps for autoindent management |
|
86 | # compiled regexps for autoindent management | |
86 | dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') |
|
87 | dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') | |
87 |
|
88 | |||
88 |
|
89 | |||
89 | #**************************************************************************** |
|
90 | #**************************************************************************** | |
90 | # Some utility function definitions |
|
91 | # Some utility function definitions | |
91 |
|
92 | |||
92 | ini_spaces_re = re.compile(r'^(\s+)') |
|
93 | ini_spaces_re = re.compile(r'^(\s+)') | |
93 |
|
94 | |||
94 | def num_ini_spaces(strng): |
|
95 | def num_ini_spaces(strng): | |
95 | """Return the number of initial spaces in a string""" |
|
96 | """Return the number of initial spaces in a string""" | |
96 |
|
97 | |||
97 | ini_spaces = ini_spaces_re.match(strng) |
|
98 | ini_spaces = ini_spaces_re.match(strng) | |
98 | if ini_spaces: |
|
99 | if ini_spaces: | |
99 | return ini_spaces.end() |
|
100 | return ini_spaces.end() | |
100 | else: |
|
101 | else: | |
101 | return 0 |
|
102 | return 0 | |
102 |
|
103 | |||
103 | def softspace(file, newvalue): |
|
104 | def softspace(file, newvalue): | |
104 | """Copied from code.py, to remove the dependency""" |
|
105 | """Copied from code.py, to remove the dependency""" | |
105 |
|
106 | |||
106 | oldvalue = 0 |
|
107 | oldvalue = 0 | |
107 | try: |
|
108 | try: | |
108 | oldvalue = file.softspace |
|
109 | oldvalue = file.softspace | |
109 | except AttributeError: |
|
110 | except AttributeError: | |
110 | pass |
|
111 | pass | |
111 | try: |
|
112 | try: | |
112 | file.softspace = newvalue |
|
113 | file.softspace = newvalue | |
113 | except (AttributeError, TypeError): |
|
114 | except (AttributeError, TypeError): | |
114 | # "attribute-less object" or "read-only attributes" |
|
115 | # "attribute-less object" or "read-only attributes" | |
115 | pass |
|
116 | pass | |
116 | return oldvalue |
|
117 | return oldvalue | |
117 |
|
118 | |||
118 |
|
119 | |||
119 | #**************************************************************************** |
|
120 | #**************************************************************************** | |
120 | # Local use exceptions |
|
121 | # Local use exceptions | |
121 | class SpaceInInput(exceptions.Exception): pass |
|
122 | class SpaceInInput(exceptions.Exception): pass | |
122 |
|
123 | |||
123 |
|
124 | |||
124 | #**************************************************************************** |
|
125 | #**************************************************************************** | |
125 | # Local use classes |
|
126 | # Local use classes | |
126 | class Bunch: pass |
|
127 | class Bunch: pass | |
127 |
|
128 | |||
128 | class Undefined: pass |
|
129 | class Undefined: pass | |
129 |
|
130 | |||
130 | class InputList(list): |
|
131 | class InputList(list): | |
131 | """Class to store user input. |
|
132 | """Class to store user input. | |
132 |
|
133 | |||
133 | It's basically a list, but slices return a string instead of a list, thus |
|
134 | It's basically a list, but slices return a string instead of a list, thus | |
134 | allowing things like (assuming 'In' is an instance): |
|
135 | allowing things like (assuming 'In' is an instance): | |
135 |
|
136 | |||
136 | exec In[4:7] |
|
137 | exec In[4:7] | |
137 |
|
138 | |||
138 | or |
|
139 | or | |
139 |
|
140 | |||
140 | exec In[5:9] + In[14] + In[21:25]""" |
|
141 | exec In[5:9] + In[14] + In[21:25]""" | |
141 |
|
142 | |||
142 | def __getslice__(self,i,j): |
|
143 | def __getslice__(self,i,j): | |
143 | return ''.join(list.__getslice__(self,i,j)) |
|
144 | return ''.join(list.__getslice__(self,i,j)) | |
144 |
|
145 | |||
145 | class SyntaxTB(ultraTB.ListTB): |
|
146 | class SyntaxTB(ultraTB.ListTB): | |
146 | """Extension which holds some state: the last exception value""" |
|
147 | """Extension which holds some state: the last exception value""" | |
147 |
|
148 | |||
148 | def __init__(self,color_scheme = 'NoColor'): |
|
149 | def __init__(self,color_scheme = 'NoColor'): | |
149 | ultraTB.ListTB.__init__(self,color_scheme) |
|
150 | ultraTB.ListTB.__init__(self,color_scheme) | |
150 | self.last_syntax_error = None |
|
151 | self.last_syntax_error = None | |
151 |
|
152 | |||
152 | def __call__(self, etype, value, elist): |
|
153 | def __call__(self, etype, value, elist): | |
153 | self.last_syntax_error = value |
|
154 | self.last_syntax_error = value | |
154 | ultraTB.ListTB.__call__(self,etype,value,elist) |
|
155 | ultraTB.ListTB.__call__(self,etype,value,elist) | |
155 |
|
156 | |||
156 | def clear_err_state(self): |
|
157 | def clear_err_state(self): | |
157 | """Return the current error state and clear it""" |
|
158 | """Return the current error state and clear it""" | |
158 | e = self.last_syntax_error |
|
159 | e = self.last_syntax_error | |
159 | self.last_syntax_error = None |
|
160 | self.last_syntax_error = None | |
160 | return e |
|
161 | return e | |
161 |
|
162 | |||
162 | #**************************************************************************** |
|
163 | #**************************************************************************** | |
163 | # Main IPython class |
|
164 | # Main IPython class | |
164 |
|
165 | |||
165 | # FIXME: the Magic class is a mixin for now, and will unfortunately remain so |
|
166 | # FIXME: the Magic class is a mixin for now, and will unfortunately remain so | |
166 | # until a full rewrite is made. I've cleaned all cross-class uses of |
|
167 | # until a full rewrite is made. I've cleaned all cross-class uses of | |
167 | # attributes and methods, but too much user code out there relies on the |
|
168 | # attributes and methods, but too much user code out there relies on the | |
168 | # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage. |
|
169 | # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage. | |
169 | # |
|
170 | # | |
170 | # But at least now, all the pieces have been separated and we could, in |
|
171 | # But at least now, all the pieces have been separated and we could, in | |
171 | # principle, stop using the mixin. This will ease the transition to the |
|
172 | # principle, stop using the mixin. This will ease the transition to the | |
172 | # chainsaw branch. |
|
173 | # chainsaw branch. | |
173 |
|
174 | |||
174 | # For reference, the following is the list of 'self.foo' uses in the Magic |
|
175 | # For reference, the following is the list of 'self.foo' uses in the Magic | |
175 | # class as of 2005-12-28. These are names we CAN'T use in the main ipython |
|
176 | # class as of 2005-12-28. These are names we CAN'T use in the main ipython | |
176 | # class, to prevent clashes. |
|
177 | # class, to prevent clashes. | |
177 |
|
178 | |||
178 | # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind', |
|
179 | # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind', | |
179 | # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic', |
|
180 | # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic', | |
180 | # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell', |
|
181 | # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell', | |
181 | # 'self.value'] |
|
182 | # 'self.value'] | |
182 |
|
183 | |||
183 | class InteractiveShell(object,Magic): |
|
184 | class InteractiveShell(object,Magic): | |
184 | """An enhanced console for Python.""" |
|
185 | """An enhanced console for Python.""" | |
185 |
|
186 | |||
186 | # class attribute to indicate whether the class supports threads or not. |
|
187 | # class attribute to indicate whether the class supports threads or not. | |
187 | # Subclasses with thread support should override this as needed. |
|
188 | # Subclasses with thread support should override this as needed. | |
188 | isthreaded = False |
|
189 | isthreaded = False | |
189 |
|
190 | |||
190 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
191 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
191 | user_ns = None,user_global_ns=None,banner2='', |
|
192 | user_ns = None,user_global_ns=None,banner2='', | |
192 | custom_exceptions=((),None),embedded=False): |
|
193 | custom_exceptions=((),None),embedded=False): | |
193 |
|
194 | |||
|
195 | ||||
194 | # log system |
|
196 | # log system | |
195 | self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate') |
|
197 | self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate') | |
196 |
|
198 | |||
197 | # Produce a public API instance |
|
199 | # Produce a public API instance | |
198 |
|
200 | |||
199 | self.api = IPython.ipapi.IPApi(self) |
|
201 | self.api = IPython.ipapi.IPApi(self) | |
200 |
|
202 | |||
201 | # some minimal strict typechecks. For some core data structures, I |
|
203 | # some minimal strict typechecks. For some core data structures, I | |
202 | # want actual basic python types, not just anything that looks like |
|
204 | # want actual basic python types, not just anything that looks like | |
203 | # one. This is especially true for namespaces. |
|
205 | # one. This is especially true for namespaces. | |
204 | for ns in (user_ns,user_global_ns): |
|
206 | for ns in (user_ns,user_global_ns): | |
205 | if ns is not None and type(ns) != types.DictType: |
|
207 | if ns is not None and type(ns) != types.DictType: | |
206 | raise TypeError,'namespace must be a dictionary' |
|
208 | raise TypeError,'namespace must be a dictionary' | |
207 |
|
209 | |||
208 | # Job manager (for jobs run as background threads) |
|
210 | # Job manager (for jobs run as background threads) | |
209 | self.jobs = BackgroundJobManager() |
|
211 | self.jobs = BackgroundJobManager() | |
210 |
|
212 | |||
211 | # track which builtins we add, so we can clean up later |
|
213 | # track which builtins we add, so we can clean up later | |
212 | self.builtins_added = {} |
|
214 | self.builtins_added = {} | |
213 | # This method will add the necessary builtins for operation, but |
|
215 | # This method will add the necessary builtins for operation, but | |
214 | # tracking what it did via the builtins_added dict. |
|
216 | # tracking what it did via the builtins_added dict. | |
215 | self.add_builtins() |
|
217 | self.add_builtins() | |
216 |
|
218 | |||
217 | # Do the intuitively correct thing for quit/exit: we remove the |
|
219 | # Do the intuitively correct thing for quit/exit: we remove the | |
218 | # builtins if they exist, and our own magics will deal with this |
|
220 | # builtins if they exist, and our own magics will deal with this | |
219 | try: |
|
221 | try: | |
220 | del __builtin__.exit, __builtin__.quit |
|
222 | del __builtin__.exit, __builtin__.quit | |
221 | except AttributeError: |
|
223 | except AttributeError: | |
222 | pass |
|
224 | pass | |
223 |
|
225 | |||
224 | # Store the actual shell's name |
|
226 | # Store the actual shell's name | |
225 | self.name = name |
|
227 | self.name = name | |
226 |
|
228 | |||
227 | # We need to know whether the instance is meant for embedding, since |
|
229 | # We need to know whether the instance is meant for embedding, since | |
228 | # global/local namespaces need to be handled differently in that case |
|
230 | # global/local namespaces need to be handled differently in that case | |
229 | self.embedded = embedded |
|
231 | self.embedded = embedded | |
230 |
|
232 | |||
231 | # command compiler |
|
233 | # command compiler | |
232 | self.compile = codeop.CommandCompiler() |
|
234 | self.compile = codeop.CommandCompiler() | |
233 |
|
235 | |||
234 | # User input buffer |
|
236 | # User input buffer | |
235 | self.buffer = [] |
|
237 | self.buffer = [] | |
236 |
|
238 | |||
237 | # Default name given in compilation of code |
|
239 | # Default name given in compilation of code | |
238 | self.filename = '<ipython console>' |
|
240 | self.filename = '<ipython console>' | |
239 |
|
241 | |||
240 | # Make an empty namespace, which extension writers can rely on both |
|
242 | # Make an empty namespace, which extension writers can rely on both | |
241 | # existing and NEVER being used by ipython itself. This gives them a |
|
243 | # existing and NEVER being used by ipython itself. This gives them a | |
242 | # convenient location for storing additional information and state |
|
244 | # convenient location for storing additional information and state | |
243 | # their extensions may require, without fear of collisions with other |
|
245 | # their extensions may require, without fear of collisions with other | |
244 | # ipython names that may develop later. |
|
246 | # ipython names that may develop later. | |
245 | self.meta = Struct() |
|
247 | self.meta = Struct() | |
246 |
|
248 | |||
247 | # Create the namespace where the user will operate. user_ns is |
|
249 | # Create the namespace where the user will operate. user_ns is | |
248 | # normally the only one used, and it is passed to the exec calls as |
|
250 | # normally the only one used, and it is passed to the exec calls as | |
249 | # the locals argument. But we do carry a user_global_ns namespace |
|
251 | # the locals argument. But we do carry a user_global_ns namespace | |
250 | # given as the exec 'globals' argument, This is useful in embedding |
|
252 | # given as the exec 'globals' argument, This is useful in embedding | |
251 | # situations where the ipython shell opens in a context where the |
|
253 | # situations where the ipython shell opens in a context where the | |
252 | # distinction between locals and globals is meaningful. |
|
254 | # distinction between locals and globals is meaningful. | |
253 |
|
255 | |||
254 | # FIXME. For some strange reason, __builtins__ is showing up at user |
|
256 | # FIXME. For some strange reason, __builtins__ is showing up at user | |
255 | # level as a dict instead of a module. This is a manual fix, but I |
|
257 | # level as a dict instead of a module. This is a manual fix, but I | |
256 | # should really track down where the problem is coming from. Alex |
|
258 | # should really track down where the problem is coming from. Alex | |
257 | # Schmolck reported this problem first. |
|
259 | # Schmolck reported this problem first. | |
258 |
|
260 | |||
259 | # A useful post by Alex Martelli on this topic: |
|
261 | # A useful post by Alex Martelli on this topic: | |
260 | # Re: inconsistent value from __builtins__ |
|
262 | # Re: inconsistent value from __builtins__ | |
261 | # Von: Alex Martelli <aleaxit@yahoo.com> |
|
263 | # Von: Alex Martelli <aleaxit@yahoo.com> | |
262 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends |
|
264 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends | |
263 | # Gruppen: comp.lang.python |
|
265 | # Gruppen: comp.lang.python | |
264 |
|
266 | |||
265 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: |
|
267 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: | |
266 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) |
|
268 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) | |
267 | # > <type 'dict'> |
|
269 | # > <type 'dict'> | |
268 | # > >>> print type(__builtins__) |
|
270 | # > >>> print type(__builtins__) | |
269 | # > <type 'module'> |
|
271 | # > <type 'module'> | |
270 | # > Is this difference in return value intentional? |
|
272 | # > Is this difference in return value intentional? | |
271 |
|
273 | |||
272 | # Well, it's documented that '__builtins__' can be either a dictionary |
|
274 | # Well, it's documented that '__builtins__' can be either a dictionary | |
273 | # or a module, and it's been that way for a long time. Whether it's |
|
275 | # or a module, and it's been that way for a long time. Whether it's | |
274 | # intentional (or sensible), I don't know. In any case, the idea is |
|
276 | # intentional (or sensible), I don't know. In any case, the idea is | |
275 | # that if you need to access the built-in namespace directly, you |
|
277 | # that if you need to access the built-in namespace directly, you | |
276 | # should start with "import __builtin__" (note, no 's') which will |
|
278 | # should start with "import __builtin__" (note, no 's') which will | |
277 | # definitely give you a module. Yeah, it's somewhat confusing:-(. |
|
279 | # definitely give you a module. Yeah, it's somewhat confusing:-(. | |
278 |
|
280 | |||
279 | if user_ns is None: |
|
281 | if user_ns is None: | |
280 | # Set __name__ to __main__ to better match the behavior of the |
|
282 | # Set __name__ to __main__ to better match the behavior of the | |
281 | # normal interpreter. |
|
283 | # normal interpreter. | |
282 | user_ns = {'__name__' :'__main__', |
|
284 | user_ns = {'__name__' :'__main__', | |
283 | '__builtins__' : __builtin__, |
|
285 | '__builtins__' : __builtin__, | |
284 | } |
|
286 | } | |
285 |
|
287 | |||
286 | if user_global_ns is None: |
|
288 | if user_global_ns is None: | |
287 | user_global_ns = {} |
|
289 | user_global_ns = {} | |
288 |
|
290 | |||
289 | # Assign namespaces |
|
291 | # Assign namespaces | |
290 | # This is the namespace where all normal user variables live |
|
292 | # This is the namespace where all normal user variables live | |
291 | self.user_ns = user_ns |
|
293 | self.user_ns = user_ns | |
292 | # Embedded instances require a separate namespace for globals. |
|
294 | # Embedded instances require a separate namespace for globals. | |
293 | # Normally this one is unused by non-embedded instances. |
|
295 | # Normally this one is unused by non-embedded instances. | |
294 | self.user_global_ns = user_global_ns |
|
296 | self.user_global_ns = user_global_ns | |
295 | # A namespace to keep track of internal data structures to prevent |
|
297 | # A namespace to keep track of internal data structures to prevent | |
296 | # them from cluttering user-visible stuff. Will be updated later |
|
298 | # them from cluttering user-visible stuff. Will be updated later | |
297 | self.internal_ns = {} |
|
299 | self.internal_ns = {} | |
298 |
|
300 | |||
299 | # Namespace of system aliases. Each entry in the alias |
|
301 | # Namespace of system aliases. Each entry in the alias | |
300 | # table must be a 2-tuple of the form (N,name), where N is the number |
|
302 | # table must be a 2-tuple of the form (N,name), where N is the number | |
301 | # of positional arguments of the alias. |
|
303 | # of positional arguments of the alias. | |
302 | self.alias_table = {} |
|
304 | self.alias_table = {} | |
303 |
|
305 | |||
304 | # A table holding all the namespaces IPython deals with, so that |
|
306 | # A table holding all the namespaces IPython deals with, so that | |
305 | # introspection facilities can search easily. |
|
307 | # introspection facilities can search easily. | |
306 | self.ns_table = {'user':user_ns, |
|
308 | self.ns_table = {'user':user_ns, | |
307 | 'user_global':user_global_ns, |
|
309 | 'user_global':user_global_ns, | |
308 | 'alias':self.alias_table, |
|
310 | 'alias':self.alias_table, | |
309 | 'internal':self.internal_ns, |
|
311 | 'internal':self.internal_ns, | |
310 | 'builtin':__builtin__.__dict__ |
|
312 | 'builtin':__builtin__.__dict__ | |
311 | } |
|
313 | } | |
312 |
|
314 | |||
313 | # The user namespace MUST have a pointer to the shell itself. |
|
315 | # The user namespace MUST have a pointer to the shell itself. | |
314 | self.user_ns[name] = self |
|
316 | self.user_ns[name] = self | |
315 |
|
317 | |||
316 | # We need to insert into sys.modules something that looks like a |
|
318 | # We need to insert into sys.modules something that looks like a | |
317 | # module but which accesses the IPython namespace, for shelve and |
|
319 | # module but which accesses the IPython namespace, for shelve and | |
318 | # pickle to work interactively. Normally they rely on getting |
|
320 | # pickle to work interactively. Normally they rely on getting | |
319 | # everything out of __main__, but for embedding purposes each IPython |
|
321 | # everything out of __main__, but for embedding purposes each IPython | |
320 | # instance has its own private namespace, so we can't go shoving |
|
322 | # instance has its own private namespace, so we can't go shoving | |
321 | # everything into __main__. |
|
323 | # everything into __main__. | |
322 |
|
324 | |||
323 | # note, however, that we should only do this for non-embedded |
|
325 | # note, however, that we should only do this for non-embedded | |
324 | # ipythons, which really mimic the __main__.__dict__ with their own |
|
326 | # ipythons, which really mimic the __main__.__dict__ with their own | |
325 | # namespace. Embedded instances, on the other hand, should not do |
|
327 | # namespace. Embedded instances, on the other hand, should not do | |
326 | # this because they need to manage the user local/global namespaces |
|
328 | # this because they need to manage the user local/global namespaces | |
327 | # only, but they live within a 'normal' __main__ (meaning, they |
|
329 | # only, but they live within a 'normal' __main__ (meaning, they | |
328 | # shouldn't overtake the execution environment of the script they're |
|
330 | # shouldn't overtake the execution environment of the script they're | |
329 | # embedded in). |
|
331 | # embedded in). | |
330 |
|
332 | |||
331 | if not embedded: |
|
333 | if not embedded: | |
332 | try: |
|
334 | try: | |
333 | main_name = self.user_ns['__name__'] |
|
335 | main_name = self.user_ns['__name__'] | |
334 | except KeyError: |
|
336 | except KeyError: | |
335 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' |
|
337 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' | |
336 | else: |
|
338 | else: | |
337 | #print "pickle hack in place" # dbg |
|
339 | #print "pickle hack in place" # dbg | |
338 | #print 'main_name:',main_name # dbg |
|
340 | #print 'main_name:',main_name # dbg | |
339 | sys.modules[main_name] = FakeModule(self.user_ns) |
|
341 | sys.modules[main_name] = FakeModule(self.user_ns) | |
340 |
|
342 | |||
341 | # List of input with multi-line handling. |
|
343 | # List of input with multi-line handling. | |
342 | # Fill its zero entry, user counter starts at 1 |
|
344 | # Fill its zero entry, user counter starts at 1 | |
343 | self.input_hist = InputList(['\n']) |
|
345 | self.input_hist = InputList(['\n']) | |
344 | # This one will hold the 'raw' input history, without any |
|
346 | # This one will hold the 'raw' input history, without any | |
345 | # pre-processing. This will allow users to retrieve the input just as |
|
347 | # pre-processing. This will allow users to retrieve the input just as | |
346 | # it was exactly typed in by the user, with %hist -r. |
|
348 | # it was exactly typed in by the user, with %hist -r. | |
347 | self.input_hist_raw = InputList(['\n']) |
|
349 | self.input_hist_raw = InputList(['\n']) | |
348 |
|
350 | |||
349 | # list of visited directories |
|
351 | # list of visited directories | |
350 | try: |
|
352 | try: | |
351 | self.dir_hist = [os.getcwd()] |
|
353 | self.dir_hist = [os.getcwd()] | |
352 | except IOError, e: |
|
354 | except IOError, e: | |
353 | self.dir_hist = [] |
|
355 | self.dir_hist = [] | |
354 |
|
356 | |||
355 | # dict of output history |
|
357 | # dict of output history | |
356 | self.output_hist = {} |
|
358 | self.output_hist = {} | |
357 |
|
359 | |||
358 | # dict of things NOT to alias (keywords, builtins and some magics) |
|
360 | # dict of things NOT to alias (keywords, builtins and some magics) | |
359 | no_alias = {} |
|
361 | no_alias = {} | |
360 | no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] |
|
362 | no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] | |
361 | for key in keyword.kwlist + no_alias_magics: |
|
363 | for key in keyword.kwlist + no_alias_magics: | |
362 | no_alias[key] = 1 |
|
364 | no_alias[key] = 1 | |
363 | no_alias.update(__builtin__.__dict__) |
|
365 | no_alias.update(__builtin__.__dict__) | |
364 | self.no_alias = no_alias |
|
366 | self.no_alias = no_alias | |
365 |
|
367 | |||
366 | # make global variables for user access to these |
|
368 | # make global variables for user access to these | |
367 | self.user_ns['_ih'] = self.input_hist |
|
369 | self.user_ns['_ih'] = self.input_hist | |
368 | self.user_ns['_oh'] = self.output_hist |
|
370 | self.user_ns['_oh'] = self.output_hist | |
369 | self.user_ns['_dh'] = self.dir_hist |
|
371 | self.user_ns['_dh'] = self.dir_hist | |
370 |
|
372 | |||
371 | # user aliases to input and output histories |
|
373 | # user aliases to input and output histories | |
372 | self.user_ns['In'] = self.input_hist |
|
374 | self.user_ns['In'] = self.input_hist | |
373 | self.user_ns['Out'] = self.output_hist |
|
375 | self.user_ns['Out'] = self.output_hist | |
374 |
|
376 | |||
375 | # Object variable to store code object waiting execution. This is |
|
377 | # Object variable to store code object waiting execution. This is | |
376 | # used mainly by the multithreaded shells, but it can come in handy in |
|
378 | # used mainly by the multithreaded shells, but it can come in handy in | |
377 | # other situations. No need to use a Queue here, since it's a single |
|
379 | # other situations. No need to use a Queue here, since it's a single | |
378 | # item which gets cleared once run. |
|
380 | # item which gets cleared once run. | |
379 | self.code_to_run = None |
|
381 | self.code_to_run = None | |
380 |
|
382 | |||
381 | # escapes for automatic behavior on the command line |
|
383 | # escapes for automatic behavior on the command line | |
382 | self.ESC_SHELL = '!' |
|
384 | self.ESC_SHELL = '!' | |
383 | self.ESC_HELP = '?' |
|
385 | self.ESC_HELP = '?' | |
384 | self.ESC_MAGIC = '%' |
|
386 | self.ESC_MAGIC = '%' | |
385 | self.ESC_QUOTE = ',' |
|
387 | self.ESC_QUOTE = ',' | |
386 | self.ESC_QUOTE2 = ';' |
|
388 | self.ESC_QUOTE2 = ';' | |
387 | self.ESC_PAREN = '/' |
|
389 | self.ESC_PAREN = '/' | |
388 |
|
390 | |||
389 | # And their associated handlers |
|
391 | # And their associated handlers | |
390 | self.esc_handlers = {self.ESC_PAREN : self.handle_auto, |
|
392 | self.esc_handlers = {self.ESC_PAREN : self.handle_auto, | |
391 | self.ESC_QUOTE : self.handle_auto, |
|
393 | self.ESC_QUOTE : self.handle_auto, | |
392 | self.ESC_QUOTE2 : self.handle_auto, |
|
394 | self.ESC_QUOTE2 : self.handle_auto, | |
393 | self.ESC_MAGIC : self.handle_magic, |
|
395 | self.ESC_MAGIC : self.handle_magic, | |
394 | self.ESC_HELP : self.handle_help, |
|
396 | self.ESC_HELP : self.handle_help, | |
395 | self.ESC_SHELL : self.handle_shell_escape, |
|
397 | self.ESC_SHELL : self.handle_shell_escape, | |
396 | } |
|
398 | } | |
397 |
|
399 | |||
398 | # class initializations |
|
400 | # class initializations | |
399 | Magic.__init__(self,self) |
|
401 | Magic.__init__(self,self) | |
400 |
|
402 | |||
401 | # Python source parser/formatter for syntax highlighting |
|
403 | # Python source parser/formatter for syntax highlighting | |
402 | pyformat = PyColorize.Parser().format |
|
404 | pyformat = PyColorize.Parser().format | |
403 | self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) |
|
405 | self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) | |
404 |
|
406 | |||
405 | # hooks holds pointers used for user-side customizations |
|
407 | # hooks holds pointers used for user-side customizations | |
406 | self.hooks = Struct() |
|
408 | self.hooks = Struct() | |
407 |
|
409 | |||
408 | # Set all default hooks, defined in the IPython.hooks module. |
|
410 | # Set all default hooks, defined in the IPython.hooks module. | |
409 | hooks = IPython.hooks |
|
411 | hooks = IPython.hooks | |
410 | for hook_name in hooks.__all__: |
|
412 | for hook_name in hooks.__all__: | |
411 | # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority |
|
413 | # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority | |
412 | self.set_hook(hook_name,getattr(hooks,hook_name), 100) |
|
414 | self.set_hook(hook_name,getattr(hooks,hook_name), 100) | |
413 | #print "bound hook",hook_name |
|
415 | #print "bound hook",hook_name | |
414 |
|
416 | |||
415 | # Flag to mark unconditional exit |
|
417 | # Flag to mark unconditional exit | |
416 | self.exit_now = False |
|
418 | self.exit_now = False | |
417 |
|
419 | |||
418 | self.usage_min = """\ |
|
420 | self.usage_min = """\ | |
419 | An enhanced console for Python. |
|
421 | An enhanced console for Python. | |
420 | Some of its features are: |
|
422 | Some of its features are: | |
421 | - Readline support if the readline library is present. |
|
423 | - Readline support if the readline library is present. | |
422 | - Tab completion in the local namespace. |
|
424 | - Tab completion in the local namespace. | |
423 | - Logging of input, see command-line options. |
|
425 | - Logging of input, see command-line options. | |
424 | - System shell escape via ! , eg !ls. |
|
426 | - System shell escape via ! , eg !ls. | |
425 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) |
|
427 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) | |
426 | - Keeps track of locally defined variables via %who, %whos. |
|
428 | - Keeps track of locally defined variables via %who, %whos. | |
427 | - Show object information with a ? eg ?x or x? (use ?? for more info). |
|
429 | - Show object information with a ? eg ?x or x? (use ?? for more info). | |
428 | """ |
|
430 | """ | |
429 | if usage: self.usage = usage |
|
431 | if usage: self.usage = usage | |
430 | else: self.usage = self.usage_min |
|
432 | else: self.usage = self.usage_min | |
431 |
|
433 | |||
432 | # Storage |
|
434 | # Storage | |
433 | self.rc = rc # This will hold all configuration information |
|
435 | self.rc = rc # This will hold all configuration information | |
434 | self.pager = 'less' |
|
436 | self.pager = 'less' | |
435 | # temporary files used for various purposes. Deleted at exit. |
|
437 | # temporary files used for various purposes. Deleted at exit. | |
436 | self.tempfiles = [] |
|
438 | self.tempfiles = [] | |
437 |
|
439 | |||
438 | # Keep track of readline usage (later set by init_readline) |
|
440 | # Keep track of readline usage (later set by init_readline) | |
439 | self.has_readline = False |
|
441 | self.has_readline = False | |
440 |
|
442 | |||
441 | # template for logfile headers. It gets resolved at runtime by the |
|
443 | # template for logfile headers. It gets resolved at runtime by the | |
442 | # logstart method. |
|
444 | # logstart method. | |
443 | self.loghead_tpl = \ |
|
445 | self.loghead_tpl = \ | |
444 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** |
|
446 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** | |
445 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW |
|
447 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW | |
446 | #log# opts = %s |
|
448 | #log# opts = %s | |
447 | #log# args = %s |
|
449 | #log# args = %s | |
448 | #log# It is safe to make manual edits below here. |
|
450 | #log# It is safe to make manual edits below here. | |
449 | #log#----------------------------------------------------------------------- |
|
451 | #log#----------------------------------------------------------------------- | |
450 | """ |
|
452 | """ | |
451 | # for pushd/popd management |
|
453 | # for pushd/popd management | |
452 | try: |
|
454 | try: | |
453 | self.home_dir = get_home_dir() |
|
455 | self.home_dir = get_home_dir() | |
454 | except HomeDirError,msg: |
|
456 | except HomeDirError,msg: | |
455 | fatal(msg) |
|
457 | fatal(msg) | |
456 |
|
458 | |||
457 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] |
|
459 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] | |
458 |
|
460 | |||
459 | # Functions to call the underlying shell. |
|
461 | # Functions to call the underlying shell. | |
460 |
|
462 | |||
461 | # utility to expand user variables via Itpl |
|
463 | # utility to expand user variables via Itpl | |
462 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), |
|
464 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), | |
463 | self.user_ns)) |
|
465 | self.user_ns)) | |
464 | # The first is similar to os.system, but it doesn't return a value, |
|
466 | # The first is similar to os.system, but it doesn't return a value, | |
465 | # and it allows interpolation of variables in the user's namespace. |
|
467 | # and it allows interpolation of variables in the user's namespace. | |
466 | self.system = lambda cmd: shell(self.var_expand(cmd), |
|
468 | self.system = lambda cmd: shell(self.var_expand(cmd), | |
467 | header='IPython system call: ', |
|
469 | header='IPython system call: ', | |
468 | verbose=self.rc.system_verbose) |
|
470 | verbose=self.rc.system_verbose) | |
469 | # These are for getoutput and getoutputerror: |
|
471 | # These are for getoutput and getoutputerror: | |
470 | self.getoutput = lambda cmd: \ |
|
472 | self.getoutput = lambda cmd: \ | |
471 | getoutput(self.var_expand(cmd), |
|
473 | getoutput(self.var_expand(cmd), | |
472 | header='IPython system call: ', |
|
474 | header='IPython system call: ', | |
473 | verbose=self.rc.system_verbose) |
|
475 | verbose=self.rc.system_verbose) | |
474 | self.getoutputerror = lambda cmd: \ |
|
476 | self.getoutputerror = lambda cmd: \ | |
475 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), |
|
477 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), | |
476 | self.user_ns)), |
|
478 | self.user_ns)), | |
477 | header='IPython system call: ', |
|
479 | header='IPython system call: ', | |
478 | verbose=self.rc.system_verbose) |
|
480 | verbose=self.rc.system_verbose) | |
479 |
|
481 | |||
480 | # RegExp for splitting line contents into pre-char//first |
|
482 | # RegExp for splitting line contents into pre-char//first | |
481 | # word-method//rest. For clarity, each group in on one line. |
|
483 | # word-method//rest. For clarity, each group in on one line. | |
482 |
|
484 | |||
483 | # WARNING: update the regexp if the above escapes are changed, as they |
|
485 | # WARNING: update the regexp if the above escapes are changed, as they | |
484 | # are hardwired in. |
|
486 | # are hardwired in. | |
485 |
|
487 | |||
486 | # Don't get carried away with trying to make the autocalling catch too |
|
488 | # Don't get carried away with trying to make the autocalling catch too | |
487 | # much: it's better to be conservative rather than to trigger hidden |
|
489 | # much: it's better to be conservative rather than to trigger hidden | |
488 | # evals() somewhere and end up causing side effects. |
|
490 | # evals() somewhere and end up causing side effects. | |
489 |
|
491 | |||
490 | self.line_split = re.compile(r'^([\s*,;/])' |
|
492 | self.line_split = re.compile(r'^([\s*,;/])' | |
491 | r'([\?\w\.]+\w*\s*)' |
|
493 | r'([\?\w\.]+\w*\s*)' | |
492 | r'(\(?.*$)') |
|
494 | r'(\(?.*$)') | |
493 |
|
495 | |||
494 | # Original re, keep around for a while in case changes break something |
|
496 | # Original re, keep around for a while in case changes break something | |
495 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' |
|
497 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' | |
496 | # r'(\s*[\?\w\.]+\w*\s*)' |
|
498 | # r'(\s*[\?\w\.]+\w*\s*)' | |
497 | # r'(\(?.*$)') |
|
499 | # r'(\(?.*$)') | |
498 |
|
500 | |||
499 | # RegExp to identify potential function names |
|
501 | # RegExp to identify potential function names | |
500 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') |
|
502 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') | |
501 |
|
503 | |||
502 | # RegExp to exclude strings with this start from autocalling. In |
|
504 | # RegExp to exclude strings with this start from autocalling. In | |
503 | # particular, all binary operators should be excluded, so that if foo |
|
505 | # particular, all binary operators should be excluded, so that if foo | |
504 | # is callable, foo OP bar doesn't become foo(OP bar), which is |
|
506 | # is callable, foo OP bar doesn't become foo(OP bar), which is | |
505 | # invalid. The characters '!=()' don't need to be checked for, as the |
|
507 | # invalid. The characters '!=()' don't need to be checked for, as the | |
506 | # _prefilter routine explicitely does so, to catch direct calls and |
|
508 | # _prefilter routine explicitely does so, to catch direct calls and | |
507 | # rebindings of existing names. |
|
509 | # rebindings of existing names. | |
508 |
|
510 | |||
509 | # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise |
|
511 | # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise | |
510 | # it affects the rest of the group in square brackets. |
|
512 | # it affects the rest of the group in square brackets. | |
511 | self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]' |
|
513 | self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]' | |
512 | '|^is |^not |^in |^and |^or ') |
|
514 | '|^is |^not |^in |^and |^or ') | |
513 |
|
515 | |||
514 | # try to catch also methods for stuff in lists/tuples/dicts: off |
|
516 | # try to catch also methods for stuff in lists/tuples/dicts: off | |
515 | # (experimental). For this to work, the line_split regexp would need |
|
517 | # (experimental). For this to work, the line_split regexp would need | |
516 | # to be modified so it wouldn't break things at '['. That line is |
|
518 | # to be modified so it wouldn't break things at '['. That line is | |
517 | # nasty enough that I shouldn't change it until I can test it _well_. |
|
519 | # nasty enough that I shouldn't change it until I can test it _well_. | |
518 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') |
|
520 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') | |
519 |
|
521 | |||
520 | # keep track of where we started running (mainly for crash post-mortem) |
|
522 | # keep track of where we started running (mainly for crash post-mortem) | |
521 | self.starting_dir = os.getcwd() |
|
523 | self.starting_dir = os.getcwd() | |
522 |
|
524 | |||
523 | # Various switches which can be set |
|
525 | # Various switches which can be set | |
524 | self.CACHELENGTH = 5000 # this is cheap, it's just text |
|
526 | self.CACHELENGTH = 5000 # this is cheap, it's just text | |
525 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ |
|
527 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ | |
526 | self.banner2 = banner2 |
|
528 | self.banner2 = banner2 | |
527 |
|
529 | |||
528 | # TraceBack handlers: |
|
530 | # TraceBack handlers: | |
529 |
|
531 | |||
530 | # Syntax error handler. |
|
532 | # Syntax error handler. | |
531 | self.SyntaxTB = SyntaxTB(color_scheme='NoColor') |
|
533 | self.SyntaxTB = SyntaxTB(color_scheme='NoColor') | |
532 |
|
534 | |||
533 | # The interactive one is initialized with an offset, meaning we always |
|
535 | # The interactive one is initialized with an offset, meaning we always | |
534 | # want to remove the topmost item in the traceback, which is our own |
|
536 | # want to remove the topmost item in the traceback, which is our own | |
535 | # internal code. Valid modes: ['Plain','Context','Verbose'] |
|
537 | # internal code. Valid modes: ['Plain','Context','Verbose'] | |
536 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', |
|
538 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', | |
537 | color_scheme='NoColor', |
|
539 | color_scheme='NoColor', | |
538 | tb_offset = 1) |
|
540 | tb_offset = 1) | |
539 |
|
541 | |||
540 | # IPython itself shouldn't crash. This will produce a detailed |
|
542 | # IPython itself shouldn't crash. This will produce a detailed | |
541 | # post-mortem if it does. But we only install the crash handler for |
|
543 | # post-mortem if it does. But we only install the crash handler for | |
542 | # non-threaded shells, the threaded ones use a normal verbose reporter |
|
544 | # non-threaded shells, the threaded ones use a normal verbose reporter | |
543 | # and lose the crash handler. This is because exceptions in the main |
|
545 | # and lose the crash handler. This is because exceptions in the main | |
544 | # thread (such as in GUI code) propagate directly to sys.excepthook, |
|
546 | # thread (such as in GUI code) propagate directly to sys.excepthook, | |
545 | # and there's no point in printing crash dumps for every user exception. |
|
547 | # and there's no point in printing crash dumps for every user exception. | |
546 | if self.isthreaded: |
|
548 | if self.isthreaded: | |
547 | sys.excepthook = ultraTB.FormattedTB() |
|
549 | sys.excepthook = ultraTB.FormattedTB() | |
548 | else: |
|
550 | else: | |
549 | from IPython import CrashHandler |
|
551 | from IPython import CrashHandler | |
550 | sys.excepthook = CrashHandler.CrashHandler(self) |
|
552 | sys.excepthook = CrashHandler.CrashHandler(self) | |
551 |
|
553 | |||
552 | # The instance will store a pointer to this, so that runtime code |
|
554 | # The instance will store a pointer to this, so that runtime code | |
553 | # (such as magics) can access it. This is because during the |
|
555 | # (such as magics) can access it. This is because during the | |
554 | # read-eval loop, it gets temporarily overwritten (to deal with GUI |
|
556 | # read-eval loop, it gets temporarily overwritten (to deal with GUI | |
555 | # frameworks). |
|
557 | # frameworks). | |
556 | self.sys_excepthook = sys.excepthook |
|
558 | self.sys_excepthook = sys.excepthook | |
557 |
|
559 | |||
558 | # and add any custom exception handlers the user may have specified |
|
560 | # and add any custom exception handlers the user may have specified | |
559 | self.set_custom_exc(*custom_exceptions) |
|
561 | self.set_custom_exc(*custom_exceptions) | |
560 |
|
562 | |||
561 | # Object inspector |
|
563 | # Object inspector | |
562 | self.inspector = OInspect.Inspector(OInspect.InspectColors, |
|
564 | self.inspector = OInspect.Inspector(OInspect.InspectColors, | |
563 | PyColorize.ANSICodeColors, |
|
565 | PyColorize.ANSICodeColors, | |
564 | 'NoColor') |
|
566 | 'NoColor') | |
565 | # indentation management |
|
567 | # indentation management | |
566 | self.autoindent = False |
|
568 | self.autoindent = False | |
567 | self.indent_current_nsp = 0 |
|
569 | self.indent_current_nsp = 0 | |
568 |
|
570 | |||
569 | # Make some aliases automatically |
|
571 | # Make some aliases automatically | |
570 | # Prepare list of shell aliases to auto-define |
|
572 | # Prepare list of shell aliases to auto-define | |
571 | if os.name == 'posix': |
|
573 | if os.name == 'posix': | |
572 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', |
|
574 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', | |
573 | 'mv mv -i','rm rm -i','cp cp -i', |
|
575 | 'mv mv -i','rm rm -i','cp cp -i', | |
574 | 'cat cat','less less','clear clear', |
|
576 | 'cat cat','less less','clear clear', | |
575 | # a better ls |
|
577 | # a better ls | |
576 | 'ls ls -F', |
|
578 | 'ls ls -F', | |
577 | # long ls |
|
579 | # long ls | |
578 | 'll ls -lF', |
|
580 | 'll ls -lF', | |
579 | # color ls |
|
581 | # color ls | |
580 | 'lc ls -F -o --color', |
|
582 | 'lc ls -F -o --color', | |
581 | # ls normal files only |
|
583 | # ls normal files only | |
582 | 'lf ls -F -o --color %l | grep ^-', |
|
584 | 'lf ls -F -o --color %l | grep ^-', | |
583 | # ls symbolic links |
|
585 | # ls symbolic links | |
584 | 'lk ls -F -o --color %l | grep ^l', |
|
586 | 'lk ls -F -o --color %l | grep ^l', | |
585 | # directories or links to directories, |
|
587 | # directories or links to directories, | |
586 | 'ldir ls -F -o --color %l | grep /$', |
|
588 | 'ldir ls -F -o --color %l | grep /$', | |
587 | # things which are executable |
|
589 | # things which are executable | |
588 | 'lx ls -F -o --color %l | grep ^-..x', |
|
590 | 'lx ls -F -o --color %l | grep ^-..x', | |
589 | ) |
|
591 | ) | |
590 | elif os.name in ['nt','dos']: |
|
592 | elif os.name in ['nt','dos']: | |
591 | auto_alias = ('dir dir /on', 'ls dir /on', |
|
593 | auto_alias = ('dir dir /on', 'ls dir /on', | |
592 | 'ddir dir /ad /on', 'ldir dir /ad /on', |
|
594 | 'ddir dir /ad /on', 'ldir dir /ad /on', | |
593 | 'mkdir mkdir','rmdir rmdir','echo echo', |
|
595 | 'mkdir mkdir','rmdir rmdir','echo echo', | |
594 | 'ren ren','cls cls','copy copy') |
|
596 | 'ren ren','cls cls','copy copy') | |
595 | else: |
|
597 | else: | |
596 | auto_alias = () |
|
598 | auto_alias = () | |
597 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) |
|
599 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) | |
598 | # Call the actual (public) initializer |
|
600 | # Call the actual (public) initializer | |
599 | self.init_auto_alias() |
|
601 | self.init_auto_alias() | |
600 | # end __init__ |
|
602 | # end __init__ | |
601 |
|
603 | |||
602 | def post_config_initialization(self): |
|
604 | def post_config_initialization(self): | |
603 | """Post configuration init method |
|
605 | """Post configuration init method | |
604 |
|
606 | |||
605 | This is called after the configuration files have been processed to |
|
607 | This is called after the configuration files have been processed to | |
606 | 'finalize' the initialization.""" |
|
608 | 'finalize' the initialization.""" | |
607 |
|
609 | |||
608 | rc = self.rc |
|
610 | rc = self.rc | |
609 |
|
611 | |||
|
612 | self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db") | |||
610 | # Load readline proper |
|
613 | # Load readline proper | |
611 | if rc.readline: |
|
614 | if rc.readline: | |
612 | self.init_readline() |
|
615 | self.init_readline() | |
613 |
|
616 | |||
614 | # local shortcut, this is used a LOT |
|
617 | # local shortcut, this is used a LOT | |
615 | self.log = self.logger.log |
|
618 | self.log = self.logger.log | |
616 |
|
619 | |||
617 | # Initialize cache, set in/out prompts and printing system |
|
620 | # Initialize cache, set in/out prompts and printing system | |
618 | self.outputcache = CachedOutput(self, |
|
621 | self.outputcache = CachedOutput(self, | |
619 | rc.cache_size, |
|
622 | rc.cache_size, | |
620 | rc.pprint, |
|
623 | rc.pprint, | |
621 | input_sep = rc.separate_in, |
|
624 | input_sep = rc.separate_in, | |
622 | output_sep = rc.separate_out, |
|
625 | output_sep = rc.separate_out, | |
623 | output_sep2 = rc.separate_out2, |
|
626 | output_sep2 = rc.separate_out2, | |
624 | ps1 = rc.prompt_in1, |
|
627 | ps1 = rc.prompt_in1, | |
625 | ps2 = rc.prompt_in2, |
|
628 | ps2 = rc.prompt_in2, | |
626 | ps_out = rc.prompt_out, |
|
629 | ps_out = rc.prompt_out, | |
627 | pad_left = rc.prompts_pad_left) |
|
630 | pad_left = rc.prompts_pad_left) | |
628 |
|
631 | |||
629 | # user may have over-ridden the default print hook: |
|
632 | # user may have over-ridden the default print hook: | |
630 | try: |
|
633 | try: | |
631 | self.outputcache.__class__.display = self.hooks.display |
|
634 | self.outputcache.__class__.display = self.hooks.display | |
632 | except AttributeError: |
|
635 | except AttributeError: | |
633 | pass |
|
636 | pass | |
634 |
|
637 | |||
635 | # I don't like assigning globally to sys, because it means when embedding |
|
638 | # I don't like assigning globally to sys, because it means when embedding | |
636 | # instances, each embedded instance overrides the previous choice. But |
|
639 | # instances, each embedded instance overrides the previous choice. But | |
637 | # sys.displayhook seems to be called internally by exec, so I don't see a |
|
640 | # sys.displayhook seems to be called internally by exec, so I don't see a | |
638 | # way around it. |
|
641 | # way around it. | |
639 | sys.displayhook = self.outputcache |
|
642 | sys.displayhook = self.outputcache | |
640 |
|
643 | |||
641 | # Set user colors (don't do it in the constructor above so that it |
|
644 | # Set user colors (don't do it in the constructor above so that it | |
642 | # doesn't crash if colors option is invalid) |
|
645 | # doesn't crash if colors option is invalid) | |
643 | self.magic_colors(rc.colors) |
|
646 | self.magic_colors(rc.colors) | |
644 |
|
647 | |||
645 | # Set calling of pdb on exceptions |
|
648 | # Set calling of pdb on exceptions | |
646 | self.call_pdb = rc.pdb |
|
649 | self.call_pdb = rc.pdb | |
647 |
|
650 | |||
648 | # Load user aliases |
|
651 | # Load user aliases | |
649 | for alias in rc.alias: |
|
652 | for alias in rc.alias: | |
650 | self.magic_alias(alias) |
|
653 | self.magic_alias(alias) | |
651 |
|
654 | self.hooks.late_startup_hook() | ||
652 | # dynamic data that survives through sessions |
|
|||
653 | # XXX make the filename a config option? |
|
|||
654 | persist_base = 'persist' |
|
|||
655 | if rc.profile: |
|
|||
656 | persist_base += '_%s' % rc.profile |
|
|||
657 | self.persist_fname = os.path.join(rc.ipythondir,persist_base) |
|
|||
658 |
|
||||
659 | try: |
|
|||
660 | self.persist = pickle.load(file(self.persist_fname)) |
|
|||
661 | except: |
|
|||
662 | self.persist = {} |
|
|||
663 |
|
||||
664 |
|
||||
665 | for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]: |
|
|||
666 | try: |
|
|||
667 | obj = pickle.loads(value) |
|
|||
668 | except: |
|
|||
669 |
|
||||
670 | print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key |
|
|||
671 | print "The error was:",sys.exc_info()[0] |
|
|||
672 | continue |
|
|||
673 |
|
|
655 | ||
674 |
|
656 | |||
675 | self.user_ns[key] = obj |
|
|||
676 |
|
||||
677 | def add_builtins(self): |
|
657 | def add_builtins(self): | |
678 | """Store ipython references into the builtin namespace. |
|
658 | """Store ipython references into the builtin namespace. | |
679 |
|
659 | |||
680 | Some parts of ipython operate via builtins injected here, which hold a |
|
660 | Some parts of ipython operate via builtins injected here, which hold a | |
681 | reference to IPython itself.""" |
|
661 | reference to IPython itself.""" | |
682 |
|
662 | |||
683 | # TODO: deprecate all except _ip; 'jobs' should be installed |
|
663 | # TODO: deprecate all except _ip; 'jobs' should be installed | |
684 | # by an extension and the rest are under _ip |
|
664 | # by an extension and the rest are under _ip | |
685 | builtins_new = dict(__IPYTHON__ = self, |
|
665 | builtins_new = dict(__IPYTHON__ = self, | |
686 | ip_set_hook = self.set_hook, |
|
666 | ip_set_hook = self.set_hook, | |
687 | jobs = self.jobs, |
|
667 | jobs = self.jobs, | |
688 | ipmagic = self.ipmagic, |
|
668 | ipmagic = self.ipmagic, | |
689 | ipalias = self.ipalias, |
|
669 | ipalias = self.ipalias, | |
690 | ipsystem = self.ipsystem, |
|
670 | ipsystem = self.ipsystem, | |
691 | _ip = self.api |
|
671 | _ip = self.api | |
692 | ) |
|
672 | ) | |
693 | for biname,bival in builtins_new.items(): |
|
673 | for biname,bival in builtins_new.items(): | |
694 | try: |
|
674 | try: | |
695 | # store the orignal value so we can restore it |
|
675 | # store the orignal value so we can restore it | |
696 | self.builtins_added[biname] = __builtin__.__dict__[biname] |
|
676 | self.builtins_added[biname] = __builtin__.__dict__[biname] | |
697 | except KeyError: |
|
677 | except KeyError: | |
698 | # or mark that it wasn't defined, and we'll just delete it at |
|
678 | # or mark that it wasn't defined, and we'll just delete it at | |
699 | # cleanup |
|
679 | # cleanup | |
700 | self.builtins_added[biname] = Undefined |
|
680 | self.builtins_added[biname] = Undefined | |
701 | __builtin__.__dict__[biname] = bival |
|
681 | __builtin__.__dict__[biname] = bival | |
702 |
|
682 | |||
703 | # Keep in the builtins a flag for when IPython is active. We set it |
|
683 | # Keep in the builtins a flag for when IPython is active. We set it | |
704 | # with setdefault so that multiple nested IPythons don't clobber one |
|
684 | # with setdefault so that multiple nested IPythons don't clobber one | |
705 | # another. Each will increase its value by one upon being activated, |
|
685 | # another. Each will increase its value by one upon being activated, | |
706 | # which also gives us a way to determine the nesting level. |
|
686 | # which also gives us a way to determine the nesting level. | |
707 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) |
|
687 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) | |
708 |
|
688 | |||
709 | def clean_builtins(self): |
|
689 | def clean_builtins(self): | |
710 | """Remove any builtins which might have been added by add_builtins, or |
|
690 | """Remove any builtins which might have been added by add_builtins, or | |
711 | restore overwritten ones to their previous values.""" |
|
691 | restore overwritten ones to their previous values.""" | |
712 | for biname,bival in self.builtins_added.items(): |
|
692 | for biname,bival in self.builtins_added.items(): | |
713 | if bival is Undefined: |
|
693 | if bival is Undefined: | |
714 | del __builtin__.__dict__[biname] |
|
694 | del __builtin__.__dict__[biname] | |
715 | else: |
|
695 | else: | |
716 | __builtin__.__dict__[biname] = bival |
|
696 | __builtin__.__dict__[biname] = bival | |
717 | self.builtins_added.clear() |
|
697 | self.builtins_added.clear() | |
718 |
|
698 | |||
719 | def set_hook(self,name,hook, priority = 50): |
|
699 | def set_hook(self,name,hook, priority = 50): | |
720 | """set_hook(name,hook) -> sets an internal IPython hook. |
|
700 | """set_hook(name,hook) -> sets an internal IPython hook. | |
721 |
|
701 | |||
722 | IPython exposes some of its internal API as user-modifiable hooks. By |
|
702 | IPython exposes some of its internal API as user-modifiable hooks. By | |
723 | adding your function to one of these hooks, you can modify IPython's |
|
703 | adding your function to one of these hooks, you can modify IPython's | |
724 | behavior to call at runtime your own routines.""" |
|
704 | behavior to call at runtime your own routines.""" | |
725 |
|
705 | |||
726 | # At some point in the future, this should validate the hook before it |
|
706 | # At some point in the future, this should validate the hook before it | |
727 | # accepts it. Probably at least check that the hook takes the number |
|
707 | # accepts it. Probably at least check that the hook takes the number | |
728 | # of args it's supposed to. |
|
708 | # of args it's supposed to. | |
729 | dp = getattr(self.hooks, name, None) |
|
709 | dp = getattr(self.hooks, name, None) | |
730 | if name not in IPython.hooks.__all__: |
|
710 | if name not in IPython.hooks.__all__: | |
731 | print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ ) |
|
711 | print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ ) | |
732 | if not dp: |
|
712 | if not dp: | |
733 | dp = IPython.hooks.CommandChainDispatcher() |
|
713 | dp = IPython.hooks.CommandChainDispatcher() | |
734 |
|
714 | |||
735 | f = new.instancemethod(hook,self,self.__class__) |
|
715 | f = new.instancemethod(hook,self,self.__class__) | |
736 | try: |
|
716 | try: | |
737 | dp.add(f,priority) |
|
717 | dp.add(f,priority) | |
738 | except AttributeError: |
|
718 | except AttributeError: | |
739 | # it was not commandchain, plain old func - replace |
|
719 | # it was not commandchain, plain old func - replace | |
740 | dp = f |
|
720 | dp = f | |
741 |
|
721 | |||
742 | setattr(self.hooks,name, dp) |
|
722 | setattr(self.hooks,name, dp) | |
743 |
|
723 | |||
744 |
|
724 | |||
745 | #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) |
|
725 | #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) | |
746 |
|
726 | |||
747 | def set_custom_exc(self,exc_tuple,handler): |
|
727 | def set_custom_exc(self,exc_tuple,handler): | |
748 | """set_custom_exc(exc_tuple,handler) |
|
728 | """set_custom_exc(exc_tuple,handler) | |
749 |
|
729 | |||
750 | Set a custom exception handler, which will be called if any of the |
|
730 | Set a custom exception handler, which will be called if any of the | |
751 | exceptions in exc_tuple occur in the mainloop (specifically, in the |
|
731 | exceptions in exc_tuple occur in the mainloop (specifically, in the | |
752 | runcode() method. |
|
732 | runcode() method. | |
753 |
|
733 | |||
754 | Inputs: |
|
734 | Inputs: | |
755 |
|
735 | |||
756 | - exc_tuple: a *tuple* of valid exceptions to call the defined |
|
736 | - exc_tuple: a *tuple* of valid exceptions to call the defined | |
757 | handler for. It is very important that you use a tuple, and NOT A |
|
737 | handler for. It is very important that you use a tuple, and NOT A | |
758 | LIST here, because of the way Python's except statement works. If |
|
738 | LIST here, because of the way Python's except statement works. If | |
759 | you only want to trap a single exception, use a singleton tuple: |
|
739 | you only want to trap a single exception, use a singleton tuple: | |
760 |
|
740 | |||
761 | exc_tuple == (MyCustomException,) |
|
741 | exc_tuple == (MyCustomException,) | |
762 |
|
742 | |||
763 | - handler: this must be defined as a function with the following |
|
743 | - handler: this must be defined as a function with the following | |
764 | basic interface: def my_handler(self,etype,value,tb). |
|
744 | basic interface: def my_handler(self,etype,value,tb). | |
765 |
|
745 | |||
766 | This will be made into an instance method (via new.instancemethod) |
|
746 | This will be made into an instance method (via new.instancemethod) | |
767 | of IPython itself, and it will be called if any of the exceptions |
|
747 | of IPython itself, and it will be called if any of the exceptions | |
768 | listed in the exc_tuple are caught. If the handler is None, an |
|
748 | listed in the exc_tuple are caught. If the handler is None, an | |
769 | internal basic one is used, which just prints basic info. |
|
749 | internal basic one is used, which just prints basic info. | |
770 |
|
750 | |||
771 | WARNING: by putting in your own exception handler into IPython's main |
|
751 | WARNING: by putting in your own exception handler into IPython's main | |
772 | execution loop, you run a very good chance of nasty crashes. This |
|
752 | execution loop, you run a very good chance of nasty crashes. This | |
773 | facility should only be used if you really know what you are doing.""" |
|
753 | facility should only be used if you really know what you are doing.""" | |
774 |
|
754 | |||
775 | assert type(exc_tuple)==type(()) , \ |
|
755 | assert type(exc_tuple)==type(()) , \ | |
776 | "The custom exceptions must be given AS A TUPLE." |
|
756 | "The custom exceptions must be given AS A TUPLE." | |
777 |
|
757 | |||
778 | def dummy_handler(self,etype,value,tb): |
|
758 | def dummy_handler(self,etype,value,tb): | |
779 | print '*** Simple custom exception handler ***' |
|
759 | print '*** Simple custom exception handler ***' | |
780 | print 'Exception type :',etype |
|
760 | print 'Exception type :',etype | |
781 | print 'Exception value:',value |
|
761 | print 'Exception value:',value | |
782 | print 'Traceback :',tb |
|
762 | print 'Traceback :',tb | |
783 | print 'Source code :','\n'.join(self.buffer) |
|
763 | print 'Source code :','\n'.join(self.buffer) | |
784 |
|
764 | |||
785 | if handler is None: handler = dummy_handler |
|
765 | if handler is None: handler = dummy_handler | |
786 |
|
766 | |||
787 | self.CustomTB = new.instancemethod(handler,self,self.__class__) |
|
767 | self.CustomTB = new.instancemethod(handler,self,self.__class__) | |
788 | self.custom_exceptions = exc_tuple |
|
768 | self.custom_exceptions = exc_tuple | |
789 |
|
769 | |||
790 | def set_custom_completer(self,completer,pos=0): |
|
770 | def set_custom_completer(self,completer,pos=0): | |
791 | """set_custom_completer(completer,pos=0) |
|
771 | """set_custom_completer(completer,pos=0) | |
792 |
|
772 | |||
793 | Adds a new custom completer function. |
|
773 | Adds a new custom completer function. | |
794 |
|
774 | |||
795 | The position argument (defaults to 0) is the index in the completers |
|
775 | The position argument (defaults to 0) is the index in the completers | |
796 | list where you want the completer to be inserted.""" |
|
776 | list where you want the completer to be inserted.""" | |
797 |
|
777 | |||
798 | newcomp = new.instancemethod(completer,self.Completer, |
|
778 | newcomp = new.instancemethod(completer,self.Completer, | |
799 | self.Completer.__class__) |
|
779 | self.Completer.__class__) | |
800 | self.Completer.matchers.insert(pos,newcomp) |
|
780 | self.Completer.matchers.insert(pos,newcomp) | |
801 |
|
781 | |||
802 | def _get_call_pdb(self): |
|
782 | def _get_call_pdb(self): | |
803 | return self._call_pdb |
|
783 | return self._call_pdb | |
804 |
|
784 | |||
805 | def _set_call_pdb(self,val): |
|
785 | def _set_call_pdb(self,val): | |
806 |
|
786 | |||
807 | if val not in (0,1,False,True): |
|
787 | if val not in (0,1,False,True): | |
808 | raise ValueError,'new call_pdb value must be boolean' |
|
788 | raise ValueError,'new call_pdb value must be boolean' | |
809 |
|
789 | |||
810 | # store value in instance |
|
790 | # store value in instance | |
811 | self._call_pdb = val |
|
791 | self._call_pdb = val | |
812 |
|
792 | |||
813 | # notify the actual exception handlers |
|
793 | # notify the actual exception handlers | |
814 | self.InteractiveTB.call_pdb = val |
|
794 | self.InteractiveTB.call_pdb = val | |
815 | if self.isthreaded: |
|
795 | if self.isthreaded: | |
816 | try: |
|
796 | try: | |
817 | self.sys_excepthook.call_pdb = val |
|
797 | self.sys_excepthook.call_pdb = val | |
818 | except: |
|
798 | except: | |
819 | warn('Failed to activate pdb for threaded exception handler') |
|
799 | warn('Failed to activate pdb for threaded exception handler') | |
820 |
|
800 | |||
821 | call_pdb = property(_get_call_pdb,_set_call_pdb,None, |
|
801 | call_pdb = property(_get_call_pdb,_set_call_pdb,None, | |
822 | 'Control auto-activation of pdb at exceptions') |
|
802 | 'Control auto-activation of pdb at exceptions') | |
823 |
|
803 | |||
824 |
|
804 | |||
825 | # These special functions get installed in the builtin namespace, to |
|
805 | # These special functions get installed in the builtin namespace, to | |
826 | # provide programmatic (pure python) access to magics, aliases and system |
|
806 | # provide programmatic (pure python) access to magics, aliases and system | |
827 | # calls. This is important for logging, user scripting, and more. |
|
807 | # calls. This is important for logging, user scripting, and more. | |
828 |
|
808 | |||
829 | # We are basically exposing, via normal python functions, the three |
|
809 | # We are basically exposing, via normal python functions, the three | |
830 | # mechanisms in which ipython offers special call modes (magics for |
|
810 | # mechanisms in which ipython offers special call modes (magics for | |
831 | # internal control, aliases for direct system access via pre-selected |
|
811 | # internal control, aliases for direct system access via pre-selected | |
832 | # names, and !cmd for calling arbitrary system commands). |
|
812 | # names, and !cmd for calling arbitrary system commands). | |
833 |
|
813 | |||
834 | def ipmagic(self,arg_s): |
|
814 | def ipmagic(self,arg_s): | |
835 | """Call a magic function by name. |
|
815 | """Call a magic function by name. | |
836 |
|
816 | |||
837 | Input: a string containing the name of the magic function to call and any |
|
817 | Input: a string containing the name of the magic function to call and any | |
838 | additional arguments to be passed to the magic. |
|
818 | additional arguments to be passed to the magic. | |
839 |
|
819 | |||
840 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython |
|
820 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython | |
841 | prompt: |
|
821 | prompt: | |
842 |
|
822 | |||
843 | In[1]: %name -opt foo bar |
|
823 | In[1]: %name -opt foo bar | |
844 |
|
824 | |||
845 | To call a magic without arguments, simply use ipmagic('name'). |
|
825 | To call a magic without arguments, simply use ipmagic('name'). | |
846 |
|
826 | |||
847 | This provides a proper Python function to call IPython's magics in any |
|
827 | This provides a proper Python function to call IPython's magics in any | |
848 | valid Python code you can type at the interpreter, including loops and |
|
828 | valid Python code you can type at the interpreter, including loops and | |
849 | compound statements. It is added by IPython to the Python builtin |
|
829 | compound statements. It is added by IPython to the Python builtin | |
850 | namespace upon initialization.""" |
|
830 | namespace upon initialization.""" | |
851 |
|
831 | |||
852 | args = arg_s.split(' ',1) |
|
832 | args = arg_s.split(' ',1) | |
853 | magic_name = args[0] |
|
833 | magic_name = args[0] | |
854 | magic_name = magic_name.lstrip(self.ESC_MAGIC) |
|
834 | magic_name = magic_name.lstrip(self.ESC_MAGIC) | |
855 |
|
835 | |||
856 | try: |
|
836 | try: | |
857 | magic_args = args[1] |
|
837 | magic_args = args[1] | |
858 | except IndexError: |
|
838 | except IndexError: | |
859 | magic_args = '' |
|
839 | magic_args = '' | |
860 | fn = getattr(self,'magic_'+magic_name,None) |
|
840 | fn = getattr(self,'magic_'+magic_name,None) | |
861 | if fn is None: |
|
841 | if fn is None: | |
862 | error("Magic function `%s` not found." % magic_name) |
|
842 | error("Magic function `%s` not found." % magic_name) | |
863 | else: |
|
843 | else: | |
864 | magic_args = self.var_expand(magic_args) |
|
844 | magic_args = self.var_expand(magic_args) | |
865 | return fn(magic_args) |
|
845 | return fn(magic_args) | |
866 |
|
846 | |||
867 | def ipalias(self,arg_s): |
|
847 | def ipalias(self,arg_s): | |
868 | """Call an alias by name. |
|
848 | """Call an alias by name. | |
869 |
|
849 | |||
870 | Input: a string containing the name of the alias to call and any |
|
850 | Input: a string containing the name of the alias to call and any | |
871 | additional arguments to be passed to the magic. |
|
851 | additional arguments to be passed to the magic. | |
872 |
|
852 | |||
873 | ipalias('name -opt foo bar') is equivalent to typing at the ipython |
|
853 | ipalias('name -opt foo bar') is equivalent to typing at the ipython | |
874 | prompt: |
|
854 | prompt: | |
875 |
|
855 | |||
876 | In[1]: name -opt foo bar |
|
856 | In[1]: name -opt foo bar | |
877 |
|
857 | |||
878 | To call an alias without arguments, simply use ipalias('name'). |
|
858 | To call an alias without arguments, simply use ipalias('name'). | |
879 |
|
859 | |||
880 | This provides a proper Python function to call IPython's aliases in any |
|
860 | This provides a proper Python function to call IPython's aliases in any | |
881 | valid Python code you can type at the interpreter, including loops and |
|
861 | valid Python code you can type at the interpreter, including loops and | |
882 | compound statements. It is added by IPython to the Python builtin |
|
862 | compound statements. It is added by IPython to the Python builtin | |
883 | namespace upon initialization.""" |
|
863 | namespace upon initialization.""" | |
884 |
|
864 | |||
885 | args = arg_s.split(' ',1) |
|
865 | args = arg_s.split(' ',1) | |
886 | alias_name = args[0] |
|
866 | alias_name = args[0] | |
887 | try: |
|
867 | try: | |
888 | alias_args = args[1] |
|
868 | alias_args = args[1] | |
889 | except IndexError: |
|
869 | except IndexError: | |
890 | alias_args = '' |
|
870 | alias_args = '' | |
891 | if alias_name in self.alias_table: |
|
871 | if alias_name in self.alias_table: | |
892 | self.call_alias(alias_name,alias_args) |
|
872 | self.call_alias(alias_name,alias_args) | |
893 | else: |
|
873 | else: | |
894 | error("Alias `%s` not found." % alias_name) |
|
874 | error("Alias `%s` not found." % alias_name) | |
895 |
|
875 | |||
896 | def ipsystem(self,arg_s): |
|
876 | def ipsystem(self,arg_s): | |
897 | """Make a system call, using IPython.""" |
|
877 | """Make a system call, using IPython.""" | |
898 |
|
878 | |||
899 | self.system(arg_s) |
|
879 | self.system(arg_s) | |
900 |
|
880 | |||
901 | def complete(self,text): |
|
881 | def complete(self,text): | |
902 | """Return a sorted list of all possible completions on text. |
|
882 | """Return a sorted list of all possible completions on text. | |
903 |
|
883 | |||
904 | Inputs: |
|
884 | Inputs: | |
905 |
|
885 | |||
906 | - text: a string of text to be completed on. |
|
886 | - text: a string of text to be completed on. | |
907 |
|
887 | |||
908 | This is a wrapper around the completion mechanism, similar to what |
|
888 | This is a wrapper around the completion mechanism, similar to what | |
909 | readline does at the command line when the TAB key is hit. By |
|
889 | readline does at the command line when the TAB key is hit. By | |
910 | exposing it as a method, it can be used by other non-readline |
|
890 | exposing it as a method, it can be used by other non-readline | |
911 | environments (such as GUIs) for text completion. |
|
891 | environments (such as GUIs) for text completion. | |
912 |
|
892 | |||
913 | Simple usage example: |
|
893 | Simple usage example: | |
914 |
|
894 | |||
915 | In [1]: x = 'hello' |
|
895 | In [1]: x = 'hello' | |
916 |
|
896 | |||
917 | In [2]: __IP.complete('x.l') |
|
897 | In [2]: __IP.complete('x.l') | |
918 | Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']""" |
|
898 | Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']""" | |
919 |
|
899 | |||
920 | complete = self.Completer.complete |
|
900 | complete = self.Completer.complete | |
921 | state = 0 |
|
901 | state = 0 | |
922 | # use a dict so we get unique keys, since ipyhton's multiple |
|
902 | # use a dict so we get unique keys, since ipyhton's multiple | |
923 | # completers can return duplicates. |
|
903 | # completers can return duplicates. | |
924 | comps = {} |
|
904 | comps = {} | |
925 | while True: |
|
905 | while True: | |
926 | newcomp = complete(text,state) |
|
906 | newcomp = complete(text,state) | |
927 | if newcomp is None: |
|
907 | if newcomp is None: | |
928 | break |
|
908 | break | |
929 | comps[newcomp] = 1 |
|
909 | comps[newcomp] = 1 | |
930 | state += 1 |
|
910 | state += 1 | |
931 | outcomps = comps.keys() |
|
911 | outcomps = comps.keys() | |
932 | outcomps.sort() |
|
912 | outcomps.sort() | |
933 | return outcomps |
|
913 | return outcomps | |
934 |
|
914 | |||
935 | def set_completer_frame(self, frame=None): |
|
915 | def set_completer_frame(self, frame=None): | |
936 | if frame: |
|
916 | if frame: | |
937 | self.Completer.namespace = frame.f_locals |
|
917 | self.Completer.namespace = frame.f_locals | |
938 | self.Completer.global_namespace = frame.f_globals |
|
918 | self.Completer.global_namespace = frame.f_globals | |
939 | else: |
|
919 | else: | |
940 | self.Completer.namespace = self.user_ns |
|
920 | self.Completer.namespace = self.user_ns | |
941 | self.Completer.global_namespace = self.user_global_ns |
|
921 | self.Completer.global_namespace = self.user_global_ns | |
942 |
|
922 | |||
943 | def init_auto_alias(self): |
|
923 | def init_auto_alias(self): | |
944 | """Define some aliases automatically. |
|
924 | """Define some aliases automatically. | |
945 |
|
925 | |||
946 | These are ALL parameter-less aliases""" |
|
926 | These are ALL parameter-less aliases""" | |
947 |
|
927 | |||
948 | for alias,cmd in self.auto_alias: |
|
928 | for alias,cmd in self.auto_alias: | |
949 | self.alias_table[alias] = (0,cmd) |
|
929 | self.alias_table[alias] = (0,cmd) | |
950 |
|
930 | |||
951 | def alias_table_validate(self,verbose=0): |
|
931 | def alias_table_validate(self,verbose=0): | |
952 | """Update information about the alias table. |
|
932 | """Update information about the alias table. | |
953 |
|
933 | |||
954 | In particular, make sure no Python keywords/builtins are in it.""" |
|
934 | In particular, make sure no Python keywords/builtins are in it.""" | |
955 |
|
935 | |||
956 | no_alias = self.no_alias |
|
936 | no_alias = self.no_alias | |
957 | for k in self.alias_table.keys(): |
|
937 | for k in self.alias_table.keys(): | |
958 | if k in no_alias: |
|
938 | if k in no_alias: | |
959 | del self.alias_table[k] |
|
939 | del self.alias_table[k] | |
960 | if verbose: |
|
940 | if verbose: | |
961 | print ("Deleting alias <%s>, it's a Python " |
|
941 | print ("Deleting alias <%s>, it's a Python " | |
962 | "keyword or builtin." % k) |
|
942 | "keyword or builtin." % k) | |
963 |
|
943 | |||
964 | def set_autoindent(self,value=None): |
|
944 | def set_autoindent(self,value=None): | |
965 | """Set the autoindent flag, checking for readline support. |
|
945 | """Set the autoindent flag, checking for readline support. | |
966 |
|
946 | |||
967 | If called with no arguments, it acts as a toggle.""" |
|
947 | If called with no arguments, it acts as a toggle.""" | |
968 |
|
948 | |||
969 | if not self.has_readline: |
|
949 | if not self.has_readline: | |
970 | if os.name == 'posix': |
|
950 | if os.name == 'posix': | |
971 | warn("The auto-indent feature requires the readline library") |
|
951 | warn("The auto-indent feature requires the readline library") | |
972 | self.autoindent = 0 |
|
952 | self.autoindent = 0 | |
973 | return |
|
953 | return | |
974 | if value is None: |
|
954 | if value is None: | |
975 | self.autoindent = not self.autoindent |
|
955 | self.autoindent = not self.autoindent | |
976 | else: |
|
956 | else: | |
977 | self.autoindent = value |
|
957 | self.autoindent = value | |
978 |
|
958 | |||
979 | def rc_set_toggle(self,rc_field,value=None): |
|
959 | def rc_set_toggle(self,rc_field,value=None): | |
980 | """Set or toggle a field in IPython's rc config. structure. |
|
960 | """Set or toggle a field in IPython's rc config. structure. | |
981 |
|
961 | |||
982 | If called with no arguments, it acts as a toggle. |
|
962 | If called with no arguments, it acts as a toggle. | |
983 |
|
963 | |||
984 | If called with a non-existent field, the resulting AttributeError |
|
964 | If called with a non-existent field, the resulting AttributeError | |
985 | exception will propagate out.""" |
|
965 | exception will propagate out.""" | |
986 |
|
966 | |||
987 | rc_val = getattr(self.rc,rc_field) |
|
967 | rc_val = getattr(self.rc,rc_field) | |
988 | if value is None: |
|
968 | if value is None: | |
989 | value = not rc_val |
|
969 | value = not rc_val | |
990 | setattr(self.rc,rc_field,value) |
|
970 | setattr(self.rc,rc_field,value) | |
991 |
|
971 | |||
992 | def user_setup(self,ipythondir,rc_suffix,mode='install'): |
|
972 | def user_setup(self,ipythondir,rc_suffix,mode='install'): | |
993 | """Install the user configuration directory. |
|
973 | """Install the user configuration directory. | |
994 |
|
974 | |||
995 | Can be called when running for the first time or to upgrade the user's |
|
975 | Can be called when running for the first time or to upgrade the user's | |
996 | .ipython/ directory with the mode parameter. Valid modes are 'install' |
|
976 | .ipython/ directory with the mode parameter. Valid modes are 'install' | |
997 | and 'upgrade'.""" |
|
977 | and 'upgrade'.""" | |
998 |
|
978 | |||
999 | def wait(): |
|
979 | def wait(): | |
1000 | try: |
|
980 | try: | |
1001 | raw_input("Please press <RETURN> to start IPython.") |
|
981 | raw_input("Please press <RETURN> to start IPython.") | |
1002 | except EOFError: |
|
982 | except EOFError: | |
1003 | print >> Term.cout |
|
983 | print >> Term.cout | |
1004 | print '*'*70 |
|
984 | print '*'*70 | |
1005 |
|
985 | |||
1006 | cwd = os.getcwd() # remember where we started |
|
986 | cwd = os.getcwd() # remember where we started | |
1007 | glb = glob.glob |
|
987 | glb = glob.glob | |
1008 | print '*'*70 |
|
988 | print '*'*70 | |
1009 | if mode == 'install': |
|
989 | if mode == 'install': | |
1010 | print \ |
|
990 | print \ | |
1011 | """Welcome to IPython. I will try to create a personal configuration directory |
|
991 | """Welcome to IPython. I will try to create a personal configuration directory | |
1012 | where you can customize many aspects of IPython's functionality in:\n""" |
|
992 | where you can customize many aspects of IPython's functionality in:\n""" | |
1013 | else: |
|
993 | else: | |
1014 | print 'I am going to upgrade your configuration in:' |
|
994 | print 'I am going to upgrade your configuration in:' | |
1015 |
|
995 | |||
1016 | print ipythondir |
|
996 | print ipythondir | |
1017 |
|
997 | |||
1018 | rcdirend = os.path.join('IPython','UserConfig') |
|
998 | rcdirend = os.path.join('IPython','UserConfig') | |
1019 | cfg = lambda d: os.path.join(d,rcdirend) |
|
999 | cfg = lambda d: os.path.join(d,rcdirend) | |
1020 | try: |
|
1000 | try: | |
1021 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] |
|
1001 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] | |
1022 | except IOError: |
|
1002 | except IOError: | |
1023 | warning = """ |
|
1003 | warning = """ | |
1024 | Installation error. IPython's directory was not found. |
|
1004 | Installation error. IPython's directory was not found. | |
1025 |
|
1005 | |||
1026 | Check the following: |
|
1006 | Check the following: | |
1027 |
|
1007 | |||
1028 | The ipython/IPython directory should be in a directory belonging to your |
|
1008 | The ipython/IPython directory should be in a directory belonging to your | |
1029 | PYTHONPATH environment variable (that is, it should be in a directory |
|
1009 | PYTHONPATH environment variable (that is, it should be in a directory | |
1030 | belonging to sys.path). You can copy it explicitly there or just link to it. |
|
1010 | belonging to sys.path). You can copy it explicitly there or just link to it. | |
1031 |
|
1011 | |||
1032 | IPython will proceed with builtin defaults. |
|
1012 | IPython will proceed with builtin defaults. | |
1033 | """ |
|
1013 | """ | |
1034 | warn(warning) |
|
1014 | warn(warning) | |
1035 | wait() |
|
1015 | wait() | |
1036 | return |
|
1016 | return | |
1037 |
|
1017 | |||
1038 | if mode == 'install': |
|
1018 | if mode == 'install': | |
1039 | try: |
|
1019 | try: | |
1040 | shutil.copytree(rcdir,ipythondir) |
|
1020 | shutil.copytree(rcdir,ipythondir) | |
1041 | os.chdir(ipythondir) |
|
1021 | os.chdir(ipythondir) | |
1042 | rc_files = glb("ipythonrc*") |
|
1022 | rc_files = glb("ipythonrc*") | |
1043 | for rc_file in rc_files: |
|
1023 | for rc_file in rc_files: | |
1044 | os.rename(rc_file,rc_file+rc_suffix) |
|
1024 | os.rename(rc_file,rc_file+rc_suffix) | |
1045 | except: |
|
1025 | except: | |
1046 | warning = """ |
|
1026 | warning = """ | |
1047 |
|
1027 | |||
1048 | There was a problem with the installation: |
|
1028 | There was a problem with the installation: | |
1049 | %s |
|
1029 | %s | |
1050 | Try to correct it or contact the developers if you think it's a bug. |
|
1030 | Try to correct it or contact the developers if you think it's a bug. | |
1051 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] |
|
1031 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] | |
1052 | warn(warning) |
|
1032 | warn(warning) | |
1053 | wait() |
|
1033 | wait() | |
1054 | return |
|
1034 | return | |
1055 |
|
1035 | |||
1056 | elif mode == 'upgrade': |
|
1036 | elif mode == 'upgrade': | |
1057 | try: |
|
1037 | try: | |
1058 | os.chdir(ipythondir) |
|
1038 | os.chdir(ipythondir) | |
1059 | except: |
|
1039 | except: | |
1060 | print """ |
|
1040 | print """ | |
1061 | Can not upgrade: changing to directory %s failed. Details: |
|
1041 | Can not upgrade: changing to directory %s failed. Details: | |
1062 | %s |
|
1042 | %s | |
1063 | """ % (ipythondir,sys.exc_info()[1]) |
|
1043 | """ % (ipythondir,sys.exc_info()[1]) | |
1064 | wait() |
|
1044 | wait() | |
1065 | return |
|
1045 | return | |
1066 | else: |
|
1046 | else: | |
1067 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) |
|
1047 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) | |
1068 | for new_full_path in sources: |
|
1048 | for new_full_path in sources: | |
1069 | new_filename = os.path.basename(new_full_path) |
|
1049 | new_filename = os.path.basename(new_full_path) | |
1070 | if new_filename.startswith('ipythonrc'): |
|
1050 | if new_filename.startswith('ipythonrc'): | |
1071 | new_filename = new_filename + rc_suffix |
|
1051 | new_filename = new_filename + rc_suffix | |
1072 | # The config directory should only contain files, skip any |
|
1052 | # The config directory should only contain files, skip any | |
1073 | # directories which may be there (like CVS) |
|
1053 | # directories which may be there (like CVS) | |
1074 | if os.path.isdir(new_full_path): |
|
1054 | if os.path.isdir(new_full_path): | |
1075 | continue |
|
1055 | continue | |
1076 | if os.path.exists(new_filename): |
|
1056 | if os.path.exists(new_filename): | |
1077 | old_file = new_filename+'.old' |
|
1057 | old_file = new_filename+'.old' | |
1078 | if os.path.exists(old_file): |
|
1058 | if os.path.exists(old_file): | |
1079 | os.remove(old_file) |
|
1059 | os.remove(old_file) | |
1080 | os.rename(new_filename,old_file) |
|
1060 | os.rename(new_filename,old_file) | |
1081 | shutil.copy(new_full_path,new_filename) |
|
1061 | shutil.copy(new_full_path,new_filename) | |
1082 | else: |
|
1062 | else: | |
1083 | raise ValueError,'unrecognized mode for install:',`mode` |
|
1063 | raise ValueError,'unrecognized mode for install:',`mode` | |
1084 |
|
1064 | |||
1085 | # Fix line-endings to those native to each platform in the config |
|
1065 | # Fix line-endings to those native to each platform in the config | |
1086 | # directory. |
|
1066 | # directory. | |
1087 | try: |
|
1067 | try: | |
1088 | os.chdir(ipythondir) |
|
1068 | os.chdir(ipythondir) | |
1089 | except: |
|
1069 | except: | |
1090 | print """ |
|
1070 | print """ | |
1091 | Problem: changing to directory %s failed. |
|
1071 | Problem: changing to directory %s failed. | |
1092 | Details: |
|
1072 | Details: | |
1093 | %s |
|
1073 | %s | |
1094 |
|
1074 | |||
1095 | Some configuration files may have incorrect line endings. This should not |
|
1075 | Some configuration files may have incorrect line endings. This should not | |
1096 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) |
|
1076 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) | |
1097 | wait() |
|
1077 | wait() | |
1098 | else: |
|
1078 | else: | |
1099 | for fname in glb('ipythonrc*'): |
|
1079 | for fname in glb('ipythonrc*'): | |
1100 | try: |
|
1080 | try: | |
1101 | native_line_ends(fname,backup=0) |
|
1081 | native_line_ends(fname,backup=0) | |
1102 | except IOError: |
|
1082 | except IOError: | |
1103 | pass |
|
1083 | pass | |
1104 |
|
1084 | |||
1105 | if mode == 'install': |
|
1085 | if mode == 'install': | |
1106 | print """ |
|
1086 | print """ | |
1107 | Successful installation! |
|
1087 | Successful installation! | |
1108 |
|
1088 | |||
1109 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the |
|
1089 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the | |
1110 | IPython manual (there are both HTML and PDF versions supplied with the |
|
1090 | IPython manual (there are both HTML and PDF versions supplied with the | |
1111 | distribution) to make sure that your system environment is properly configured |
|
1091 | distribution) to make sure that your system environment is properly configured | |
1112 | to take advantage of IPython's features. |
|
1092 | to take advantage of IPython's features. | |
1113 |
|
1093 | |||
1114 | Important note: the configuration system has changed! The old system is |
|
1094 | Important note: the configuration system has changed! The old system is | |
1115 | still in place, but its setting may be partly overridden by the settings in |
|
1095 | still in place, but its setting may be partly overridden by the settings in | |
1116 | "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file |
|
1096 | "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file | |
1117 | if some of the new settings bother you. |
|
1097 | if some of the new settings bother you. | |
1118 |
|
1098 | |||
1119 | """ |
|
1099 | """ | |
1120 | else: |
|
1100 | else: | |
1121 | print """ |
|
1101 | print """ | |
1122 | Successful upgrade! |
|
1102 | Successful upgrade! | |
1123 |
|
1103 | |||
1124 | All files in your directory: |
|
1104 | All files in your directory: | |
1125 | %(ipythondir)s |
|
1105 | %(ipythondir)s | |
1126 | which would have been overwritten by the upgrade were backed up with a .old |
|
1106 | which would have been overwritten by the upgrade were backed up with a .old | |
1127 | extension. If you had made particular customizations in those files you may |
|
1107 | extension. If you had made particular customizations in those files you may | |
1128 | want to merge them back into the new files.""" % locals() |
|
1108 | want to merge them back into the new files.""" % locals() | |
1129 | wait() |
|
1109 | wait() | |
1130 | os.chdir(cwd) |
|
1110 | os.chdir(cwd) | |
1131 | # end user_setup() |
|
1111 | # end user_setup() | |
1132 |
|
1112 | |||
1133 | def atexit_operations(self): |
|
1113 | def atexit_operations(self): | |
1134 | """This will be executed at the time of exit. |
|
1114 | """This will be executed at the time of exit. | |
1135 |
|
1115 | |||
1136 | Saving of persistent data should be performed here. """ |
|
1116 | Saving of persistent data should be performed here. """ | |
1137 |
|
1117 | |||
1138 | #print '*** IPython exit cleanup ***' # dbg |
|
1118 | #print '*** IPython exit cleanup ***' # dbg | |
1139 | # input history |
|
1119 | # input history | |
1140 | self.savehist() |
|
1120 | self.savehist() | |
1141 |
|
1121 | |||
1142 | # Cleanup all tempfiles left around |
|
1122 | # Cleanup all tempfiles left around | |
1143 | for tfile in self.tempfiles: |
|
1123 | for tfile in self.tempfiles: | |
1144 | try: |
|
1124 | try: | |
1145 | os.unlink(tfile) |
|
1125 | os.unlink(tfile) | |
1146 | except OSError: |
|
1126 | except OSError: | |
1147 | pass |
|
1127 | pass | |
1148 |
|
1128 | |||
1149 | # save the "persistent data" catch-all dictionary |
|
1129 | # save the "persistent data" catch-all dictionary | |
1150 | try: |
|
1130 | self.hooks.shutdown_hook() | |
1151 | pickle.dump(self.persist, open(self.persist_fname,"w")) |
|
|||
1152 | except: |
|
|||
1153 | print "*** ERROR *** persistent data saving failed." |
|
|||
1154 |
|
1131 | |||
1155 | def savehist(self): |
|
1132 | def savehist(self): | |
1156 | """Save input history to a file (via readline library).""" |
|
1133 | """Save input history to a file (via readline library).""" | |
1157 | try: |
|
1134 | try: | |
1158 | self.readline.write_history_file(self.histfile) |
|
1135 | self.readline.write_history_file(self.histfile) | |
1159 | except: |
|
1136 | except: | |
1160 | print 'Unable to save IPython command history to file: ' + \ |
|
1137 | print 'Unable to save IPython command history to file: ' + \ | |
1161 | `self.histfile` |
|
1138 | `self.histfile` | |
1162 |
|
1139 | |||
1163 | def pre_readline(self): |
|
1140 | def pre_readline(self): | |
1164 | """readline hook to be used at the start of each line. |
|
1141 | """readline hook to be used at the start of each line. | |
1165 |
|
1142 | |||
1166 | Currently it handles auto-indent only.""" |
|
1143 | Currently it handles auto-indent only.""" | |
1167 |
|
1144 | |||
1168 | #debugx('self.indent_current_nsp','pre_readline:') |
|
1145 | #debugx('self.indent_current_nsp','pre_readline:') | |
1169 | self.readline.insert_text(self.indent_current_str()) |
|
1146 | self.readline.insert_text(self.indent_current_str()) | |
1170 |
|
1147 | |||
1171 | def init_readline(self): |
|
1148 | def init_readline(self): | |
1172 | """Command history completion/saving/reloading.""" |
|
1149 | """Command history completion/saving/reloading.""" | |
1173 |
|
1150 | |||
1174 | import IPython.rlineimpl as readline |
|
1151 | import IPython.rlineimpl as readline | |
1175 | if not readline.have_readline: |
|
1152 | if not readline.have_readline: | |
1176 | self.has_readline = 0 |
|
1153 | self.has_readline = 0 | |
1177 | self.readline = None |
|
1154 | self.readline = None | |
1178 | # no point in bugging windows users with this every time: |
|
1155 | # no point in bugging windows users with this every time: | |
1179 | warn('Readline services not available on this platform.') |
|
1156 | warn('Readline services not available on this platform.') | |
1180 | else: |
|
1157 | else: | |
1181 | sys.modules['readline'] = readline |
|
1158 | sys.modules['readline'] = readline | |
1182 | import atexit |
|
1159 | import atexit | |
1183 | from IPython.completer import IPCompleter |
|
1160 | from IPython.completer import IPCompleter | |
1184 | self.Completer = IPCompleter(self, |
|
1161 | self.Completer = IPCompleter(self, | |
1185 | self.user_ns, |
|
1162 | self.user_ns, | |
1186 | self.user_global_ns, |
|
1163 | self.user_global_ns, | |
1187 | self.rc.readline_omit__names, |
|
1164 | self.rc.readline_omit__names, | |
1188 | self.alias_table) |
|
1165 | self.alias_table) | |
1189 |
|
1166 | |||
1190 | # Platform-specific configuration |
|
1167 | # Platform-specific configuration | |
1191 | if os.name == 'nt': |
|
1168 | if os.name == 'nt': | |
1192 | self.readline_startup_hook = readline.set_pre_input_hook |
|
1169 | self.readline_startup_hook = readline.set_pre_input_hook | |
1193 | else: |
|
1170 | else: | |
1194 | self.readline_startup_hook = readline.set_startup_hook |
|
1171 | self.readline_startup_hook = readline.set_startup_hook | |
1195 |
|
1172 | |||
1196 | # Load user's initrc file (readline config) |
|
1173 | # Load user's initrc file (readline config) | |
1197 | inputrc_name = os.environ.get('INPUTRC') |
|
1174 | inputrc_name = os.environ.get('INPUTRC') | |
1198 | if inputrc_name is None: |
|
1175 | if inputrc_name is None: | |
1199 | home_dir = get_home_dir() |
|
1176 | home_dir = get_home_dir() | |
1200 | if home_dir is not None: |
|
1177 | if home_dir is not None: | |
1201 | inputrc_name = os.path.join(home_dir,'.inputrc') |
|
1178 | inputrc_name = os.path.join(home_dir,'.inputrc') | |
1202 | if os.path.isfile(inputrc_name): |
|
1179 | if os.path.isfile(inputrc_name): | |
1203 | try: |
|
1180 | try: | |
1204 | readline.read_init_file(inputrc_name) |
|
1181 | readline.read_init_file(inputrc_name) | |
1205 | except: |
|
1182 | except: | |
1206 | warn('Problems reading readline initialization file <%s>' |
|
1183 | warn('Problems reading readline initialization file <%s>' | |
1207 | % inputrc_name) |
|
1184 | % inputrc_name) | |
1208 |
|
1185 | |||
1209 | self.has_readline = 1 |
|
1186 | self.has_readline = 1 | |
1210 | self.readline = readline |
|
1187 | self.readline = readline | |
1211 | # save this in sys so embedded copies can restore it properly |
|
1188 | # save this in sys so embedded copies can restore it properly | |
1212 | sys.ipcompleter = self.Completer.complete |
|
1189 | sys.ipcompleter = self.Completer.complete | |
1213 | readline.set_completer(self.Completer.complete) |
|
1190 | readline.set_completer(self.Completer.complete) | |
1214 |
|
1191 | |||
1215 | # Configure readline according to user's prefs |
|
1192 | # Configure readline according to user's prefs | |
1216 | for rlcommand in self.rc.readline_parse_and_bind: |
|
1193 | for rlcommand in self.rc.readline_parse_and_bind: | |
1217 | readline.parse_and_bind(rlcommand) |
|
1194 | readline.parse_and_bind(rlcommand) | |
1218 |
|
1195 | |||
1219 | # remove some chars from the delimiters list |
|
1196 | # remove some chars from the delimiters list | |
1220 | delims = readline.get_completer_delims() |
|
1197 | delims = readline.get_completer_delims() | |
1221 | delims = delims.translate(string._idmap, |
|
1198 | delims = delims.translate(string._idmap, | |
1222 | self.rc.readline_remove_delims) |
|
1199 | self.rc.readline_remove_delims) | |
1223 | readline.set_completer_delims(delims) |
|
1200 | readline.set_completer_delims(delims) | |
1224 | # otherwise we end up with a monster history after a while: |
|
1201 | # otherwise we end up with a monster history after a while: | |
1225 | readline.set_history_length(1000) |
|
1202 | readline.set_history_length(1000) | |
1226 | try: |
|
1203 | try: | |
1227 | #print '*** Reading readline history' # dbg |
|
1204 | #print '*** Reading readline history' # dbg | |
1228 | readline.read_history_file(self.histfile) |
|
1205 | readline.read_history_file(self.histfile) | |
1229 | except IOError: |
|
1206 | except IOError: | |
1230 | pass # It doesn't exist yet. |
|
1207 | pass # It doesn't exist yet. | |
1231 |
|
1208 | |||
1232 | atexit.register(self.atexit_operations) |
|
1209 | atexit.register(self.atexit_operations) | |
1233 | del atexit |
|
1210 | del atexit | |
1234 |
|
1211 | |||
1235 | # Configure auto-indent for all platforms |
|
1212 | # Configure auto-indent for all platforms | |
1236 | self.set_autoindent(self.rc.autoindent) |
|
1213 | self.set_autoindent(self.rc.autoindent) | |
1237 |
|
1214 | |||
1238 | def _should_recompile(self,e): |
|
1215 | def _should_recompile(self,e): | |
1239 | """Utility routine for edit_syntax_error""" |
|
1216 | """Utility routine for edit_syntax_error""" | |
1240 |
|
1217 | |||
1241 | if e.filename in ('<ipython console>','<input>','<string>', |
|
1218 | if e.filename in ('<ipython console>','<input>','<string>', | |
1242 | '<console>',None): |
|
1219 | '<console>',None): | |
1243 |
|
1220 | |||
1244 | return False |
|
1221 | return False | |
1245 | try: |
|
1222 | try: | |
1246 | if (self.rc.autoedit_syntax != 2 and |
|
1223 | if (self.rc.autoedit_syntax != 2 and | |
1247 | not ask_yes_no('Return to editor to correct syntax error? ' |
|
1224 | not ask_yes_no('Return to editor to correct syntax error? ' | |
1248 | '[Y/n] ','y')): |
|
1225 | '[Y/n] ','y')): | |
1249 | return False |
|
1226 | return False | |
1250 | except EOFError: |
|
1227 | except EOFError: | |
1251 | return False |
|
1228 | return False | |
1252 |
|
1229 | |||
1253 | def int0(x): |
|
1230 | def int0(x): | |
1254 | try: |
|
1231 | try: | |
1255 | return int(x) |
|
1232 | return int(x) | |
1256 | except TypeError: |
|
1233 | except TypeError: | |
1257 | return 0 |
|
1234 | return 0 | |
1258 | # always pass integer line and offset values to editor hook |
|
1235 | # always pass integer line and offset values to editor hook | |
1259 | self.hooks.fix_error_editor(e.filename, |
|
1236 | self.hooks.fix_error_editor(e.filename, | |
1260 | int0(e.lineno),int0(e.offset),e.msg) |
|
1237 | int0(e.lineno),int0(e.offset),e.msg) | |
1261 | return True |
|
1238 | return True | |
1262 |
|
1239 | |||
1263 | def edit_syntax_error(self): |
|
1240 | def edit_syntax_error(self): | |
1264 | """The bottom half of the syntax error handler called in the main loop. |
|
1241 | """The bottom half of the syntax error handler called in the main loop. | |
1265 |
|
1242 | |||
1266 | Loop until syntax error is fixed or user cancels. |
|
1243 | Loop until syntax error is fixed or user cancels. | |
1267 | """ |
|
1244 | """ | |
1268 |
|
1245 | |||
1269 | while self.SyntaxTB.last_syntax_error: |
|
1246 | while self.SyntaxTB.last_syntax_error: | |
1270 | # copy and clear last_syntax_error |
|
1247 | # copy and clear last_syntax_error | |
1271 | err = self.SyntaxTB.clear_err_state() |
|
1248 | err = self.SyntaxTB.clear_err_state() | |
1272 | if not self._should_recompile(err): |
|
1249 | if not self._should_recompile(err): | |
1273 | return |
|
1250 | return | |
1274 | try: |
|
1251 | try: | |
1275 | # may set last_syntax_error again if a SyntaxError is raised |
|
1252 | # may set last_syntax_error again if a SyntaxError is raised | |
1276 | self.safe_execfile(err.filename,self.shell.user_ns) |
|
1253 | self.safe_execfile(err.filename,self.shell.user_ns) | |
1277 | except: |
|
1254 | except: | |
1278 | self.showtraceback() |
|
1255 | self.showtraceback() | |
1279 | else: |
|
1256 | else: | |
1280 | f = file(err.filename) |
|
1257 | f = file(err.filename) | |
1281 | try: |
|
1258 | try: | |
1282 | sys.displayhook(f.read()) |
|
1259 | sys.displayhook(f.read()) | |
1283 | finally: |
|
1260 | finally: | |
1284 | f.close() |
|
1261 | f.close() | |
1285 |
|
1262 | |||
1286 | def showsyntaxerror(self, filename=None): |
|
1263 | def showsyntaxerror(self, filename=None): | |
1287 | """Display the syntax error that just occurred. |
|
1264 | """Display the syntax error that just occurred. | |
1288 |
|
1265 | |||
1289 | This doesn't display a stack trace because there isn't one. |
|
1266 | This doesn't display a stack trace because there isn't one. | |
1290 |
|
1267 | |||
1291 | If a filename is given, it is stuffed in the exception instead |
|
1268 | If a filename is given, it is stuffed in the exception instead | |
1292 | of what was there before (because Python's parser always uses |
|
1269 | of what was there before (because Python's parser always uses | |
1293 | "<string>" when reading from a string). |
|
1270 | "<string>" when reading from a string). | |
1294 | """ |
|
1271 | """ | |
1295 | etype, value, last_traceback = sys.exc_info() |
|
1272 | etype, value, last_traceback = sys.exc_info() | |
1296 | if filename and etype is SyntaxError: |
|
1273 | if filename and etype is SyntaxError: | |
1297 | # Work hard to stuff the correct filename in the exception |
|
1274 | # Work hard to stuff the correct filename in the exception | |
1298 | try: |
|
1275 | try: | |
1299 | msg, (dummy_filename, lineno, offset, line) = value |
|
1276 | msg, (dummy_filename, lineno, offset, line) = value | |
1300 | except: |
|
1277 | except: | |
1301 | # Not the format we expect; leave it alone |
|
1278 | # Not the format we expect; leave it alone | |
1302 | pass |
|
1279 | pass | |
1303 | else: |
|
1280 | else: | |
1304 | # Stuff in the right filename |
|
1281 | # Stuff in the right filename | |
1305 | try: |
|
1282 | try: | |
1306 | # Assume SyntaxError is a class exception |
|
1283 | # Assume SyntaxError is a class exception | |
1307 | value = SyntaxError(msg, (filename, lineno, offset, line)) |
|
1284 | value = SyntaxError(msg, (filename, lineno, offset, line)) | |
1308 | except: |
|
1285 | except: | |
1309 | # If that failed, assume SyntaxError is a string |
|
1286 | # If that failed, assume SyntaxError is a string | |
1310 | value = msg, (filename, lineno, offset, line) |
|
1287 | value = msg, (filename, lineno, offset, line) | |
1311 | self.SyntaxTB(etype,value,[]) |
|
1288 | self.SyntaxTB(etype,value,[]) | |
1312 |
|
1289 | |||
1313 | def debugger(self): |
|
1290 | def debugger(self): | |
1314 | """Call the pdb debugger.""" |
|
1291 | """Call the pdb debugger.""" | |
1315 |
|
1292 | |||
1316 | if not self.rc.pdb: |
|
1293 | if not self.rc.pdb: | |
1317 | return |
|
1294 | return | |
1318 | pdb.pm() |
|
1295 | pdb.pm() | |
1319 |
|
1296 | |||
1320 | def showtraceback(self,exc_tuple = None,filename=None): |
|
1297 | def showtraceback(self,exc_tuple = None,filename=None): | |
1321 | """Display the exception that just occurred.""" |
|
1298 | """Display the exception that just occurred.""" | |
1322 |
|
1299 | |||
1323 | # Though this won't be called by syntax errors in the input line, |
|
1300 | # Though this won't be called by syntax errors in the input line, | |
1324 | # there may be SyntaxError cases whith imported code. |
|
1301 | # there may be SyntaxError cases whith imported code. | |
1325 | if exc_tuple is None: |
|
1302 | if exc_tuple is None: | |
1326 | type, value, tb = sys.exc_info() |
|
1303 | type, value, tb = sys.exc_info() | |
1327 | else: |
|
1304 | else: | |
1328 | type, value, tb = exc_tuple |
|
1305 | type, value, tb = exc_tuple | |
1329 | if type is SyntaxError: |
|
1306 | if type is SyntaxError: | |
1330 | self.showsyntaxerror(filename) |
|
1307 | self.showsyntaxerror(filename) | |
1331 | else: |
|
1308 | else: | |
1332 | self.InteractiveTB() |
|
1309 | self.InteractiveTB() | |
1333 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1310 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1334 | # pdb mucks up readline, fix it back |
|
1311 | # pdb mucks up readline, fix it back | |
1335 | self.readline.set_completer(self.Completer.complete) |
|
1312 | self.readline.set_completer(self.Completer.complete) | |
1336 |
|
1313 | |||
1337 | def mainloop(self,banner=None): |
|
1314 | def mainloop(self,banner=None): | |
1338 | """Creates the local namespace and starts the mainloop. |
|
1315 | """Creates the local namespace and starts the mainloop. | |
1339 |
|
1316 | |||
1340 | If an optional banner argument is given, it will override the |
|
1317 | If an optional banner argument is given, it will override the | |
1341 | internally created default banner.""" |
|
1318 | internally created default banner.""" | |
1342 |
|
1319 | |||
1343 | if self.rc.c: # Emulate Python's -c option |
|
1320 | if self.rc.c: # Emulate Python's -c option | |
1344 | self.exec_init_cmd() |
|
1321 | self.exec_init_cmd() | |
1345 | if banner is None: |
|
1322 | if banner is None: | |
1346 | if self.rc.banner: |
|
1323 | if self.rc.banner: | |
1347 | banner = self.BANNER+self.banner2 |
|
1324 | banner = self.BANNER+self.banner2 | |
1348 | else: |
|
1325 | else: | |
1349 | banner = '' |
|
1326 | banner = '' | |
1350 | self.interact(banner) |
|
1327 | self.interact(banner) | |
1351 |
|
1328 | |||
1352 | def exec_init_cmd(self): |
|
1329 | def exec_init_cmd(self): | |
1353 | """Execute a command given at the command line. |
|
1330 | """Execute a command given at the command line. | |
1354 |
|
1331 | |||
1355 | This emulates Python's -c option.""" |
|
1332 | This emulates Python's -c option.""" | |
1356 |
|
1333 | |||
1357 | #sys.argv = ['-c'] |
|
1334 | #sys.argv = ['-c'] | |
1358 | self.push(self.rc.c) |
|
1335 | self.push(self.rc.c) | |
1359 |
|
1336 | |||
1360 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): |
|
1337 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): | |
1361 | """Embeds IPython into a running python program. |
|
1338 | """Embeds IPython into a running python program. | |
1362 |
|
1339 | |||
1363 | Input: |
|
1340 | Input: | |
1364 |
|
1341 | |||
1365 | - header: An optional header message can be specified. |
|
1342 | - header: An optional header message can be specified. | |
1366 |
|
1343 | |||
1367 | - local_ns, global_ns: working namespaces. If given as None, the |
|
1344 | - local_ns, global_ns: working namespaces. If given as None, the | |
1368 | IPython-initialized one is updated with __main__.__dict__, so that |
|
1345 | IPython-initialized one is updated with __main__.__dict__, so that | |
1369 | program variables become visible but user-specific configuration |
|
1346 | program variables become visible but user-specific configuration | |
1370 | remains possible. |
|
1347 | remains possible. | |
1371 |
|
1348 | |||
1372 | - stack_depth: specifies how many levels in the stack to go to |
|
1349 | - stack_depth: specifies how many levels in the stack to go to | |
1373 | looking for namespaces (when local_ns and global_ns are None). This |
|
1350 | looking for namespaces (when local_ns and global_ns are None). This | |
1374 | allows an intermediate caller to make sure that this function gets |
|
1351 | allows an intermediate caller to make sure that this function gets | |
1375 | the namespace from the intended level in the stack. By default (0) |
|
1352 | the namespace from the intended level in the stack. By default (0) | |
1376 | it will get its locals and globals from the immediate caller. |
|
1353 | it will get its locals and globals from the immediate caller. | |
1377 |
|
1354 | |||
1378 | Warning: it's possible to use this in a program which is being run by |
|
1355 | Warning: it's possible to use this in a program which is being run by | |
1379 | IPython itself (via %run), but some funny things will happen (a few |
|
1356 | IPython itself (via %run), but some funny things will happen (a few | |
1380 | globals get overwritten). In the future this will be cleaned up, as |
|
1357 | globals get overwritten). In the future this will be cleaned up, as | |
1381 | there is no fundamental reason why it can't work perfectly.""" |
|
1358 | there is no fundamental reason why it can't work perfectly.""" | |
1382 |
|
1359 | |||
1383 | # Get locals and globals from caller |
|
1360 | # Get locals and globals from caller | |
1384 | if local_ns is None or global_ns is None: |
|
1361 | if local_ns is None or global_ns is None: | |
1385 | call_frame = sys._getframe(stack_depth).f_back |
|
1362 | call_frame = sys._getframe(stack_depth).f_back | |
1386 |
|
1363 | |||
1387 | if local_ns is None: |
|
1364 | if local_ns is None: | |
1388 | local_ns = call_frame.f_locals |
|
1365 | local_ns = call_frame.f_locals | |
1389 | if global_ns is None: |
|
1366 | if global_ns is None: | |
1390 | global_ns = call_frame.f_globals |
|
1367 | global_ns = call_frame.f_globals | |
1391 |
|
1368 | |||
1392 | # Update namespaces and fire up interpreter |
|
1369 | # Update namespaces and fire up interpreter | |
1393 |
|
1370 | |||
1394 | # The global one is easy, we can just throw it in |
|
1371 | # The global one is easy, we can just throw it in | |
1395 | self.user_global_ns = global_ns |
|
1372 | self.user_global_ns = global_ns | |
1396 |
|
1373 | |||
1397 | # but the user/local one is tricky: ipython needs it to store internal |
|
1374 | # but the user/local one is tricky: ipython needs it to store internal | |
1398 | # data, but we also need the locals. We'll copy locals in the user |
|
1375 | # data, but we also need the locals. We'll copy locals in the user | |
1399 | # one, but will track what got copied so we can delete them at exit. |
|
1376 | # one, but will track what got copied so we can delete them at exit. | |
1400 | # This is so that a later embedded call doesn't see locals from a |
|
1377 | # This is so that a later embedded call doesn't see locals from a | |
1401 | # previous call (which most likely existed in a separate scope). |
|
1378 | # previous call (which most likely existed in a separate scope). | |
1402 | local_varnames = local_ns.keys() |
|
1379 | local_varnames = local_ns.keys() | |
1403 | self.user_ns.update(local_ns) |
|
1380 | self.user_ns.update(local_ns) | |
1404 |
|
1381 | |||
1405 | # Patch for global embedding to make sure that things don't overwrite |
|
1382 | # Patch for global embedding to make sure that things don't overwrite | |
1406 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> |
|
1383 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> | |
1407 | # FIXME. Test this a bit more carefully (the if.. is new) |
|
1384 | # FIXME. Test this a bit more carefully (the if.. is new) | |
1408 | if local_ns is None and global_ns is None: |
|
1385 | if local_ns is None and global_ns is None: | |
1409 | self.user_global_ns.update(__main__.__dict__) |
|
1386 | self.user_global_ns.update(__main__.__dict__) | |
1410 |
|
1387 | |||
1411 | # make sure the tab-completer has the correct frame information, so it |
|
1388 | # make sure the tab-completer has the correct frame information, so it | |
1412 | # actually completes using the frame's locals/globals |
|
1389 | # actually completes using the frame's locals/globals | |
1413 | self.set_completer_frame() |
|
1390 | self.set_completer_frame() | |
1414 |
|
1391 | |||
1415 | # before activating the interactive mode, we need to make sure that |
|
1392 | # before activating the interactive mode, we need to make sure that | |
1416 | # all names in the builtin namespace needed by ipython point to |
|
1393 | # all names in the builtin namespace needed by ipython point to | |
1417 | # ourselves, and not to other instances. |
|
1394 | # ourselves, and not to other instances. | |
1418 | self.add_builtins() |
|
1395 | self.add_builtins() | |
1419 |
|
1396 | |||
1420 | self.interact(header) |
|
1397 | self.interact(header) | |
1421 |
|
1398 | |||
1422 | # now, purge out the user namespace from anything we might have added |
|
1399 | # now, purge out the user namespace from anything we might have added | |
1423 | # from the caller's local namespace |
|
1400 | # from the caller's local namespace | |
1424 | delvar = self.user_ns.pop |
|
1401 | delvar = self.user_ns.pop | |
1425 | for var in local_varnames: |
|
1402 | for var in local_varnames: | |
1426 | delvar(var,None) |
|
1403 | delvar(var,None) | |
1427 | # and clean builtins we may have overridden |
|
1404 | # and clean builtins we may have overridden | |
1428 | self.clean_builtins() |
|
1405 | self.clean_builtins() | |
1429 |
|
1406 | |||
1430 | def interact(self, banner=None): |
|
1407 | def interact(self, banner=None): | |
1431 | """Closely emulate the interactive Python console. |
|
1408 | """Closely emulate the interactive Python console. | |
1432 |
|
1409 | |||
1433 | The optional banner argument specify the banner to print |
|
1410 | The optional banner argument specify the banner to print | |
1434 | before the first interaction; by default it prints a banner |
|
1411 | before the first interaction; by default it prints a banner | |
1435 | similar to the one printed by the real Python interpreter, |
|
1412 | similar to the one printed by the real Python interpreter, | |
1436 | followed by the current class name in parentheses (so as not |
|
1413 | followed by the current class name in parentheses (so as not | |
1437 | to confuse this with the real interpreter -- since it's so |
|
1414 | to confuse this with the real interpreter -- since it's so | |
1438 | close!). |
|
1415 | close!). | |
1439 |
|
1416 | |||
1440 | """ |
|
1417 | """ | |
1441 | cprt = 'Type "copyright", "credits" or "license" for more information.' |
|
1418 | cprt = 'Type "copyright", "credits" or "license" for more information.' | |
1442 | if banner is None: |
|
1419 | if banner is None: | |
1443 | self.write("Python %s on %s\n%s\n(%s)\n" % |
|
1420 | self.write("Python %s on %s\n%s\n(%s)\n" % | |
1444 | (sys.version, sys.platform, cprt, |
|
1421 | (sys.version, sys.platform, cprt, | |
1445 | self.__class__.__name__)) |
|
1422 | self.__class__.__name__)) | |
1446 | else: |
|
1423 | else: | |
1447 | self.write(banner) |
|
1424 | self.write(banner) | |
1448 |
|
1425 | |||
1449 | more = 0 |
|
1426 | more = 0 | |
1450 |
|
1427 | |||
1451 | # Mark activity in the builtins |
|
1428 | # Mark activity in the builtins | |
1452 | __builtin__.__dict__['__IPYTHON__active'] += 1 |
|
1429 | __builtin__.__dict__['__IPYTHON__active'] += 1 | |
1453 |
|
1430 | |||
1454 | # exit_now is set by a call to %Exit or %Quit |
|
1431 | # exit_now is set by a call to %Exit or %Quit | |
1455 | self.exit_now = False |
|
1432 | self.exit_now = False | |
1456 | while not self.exit_now: |
|
1433 | while not self.exit_now: | |
1457 | if more: |
|
1434 | if more: | |
1458 | prompt = self.outputcache.prompt2 |
|
1435 | prompt = self.outputcache.prompt2 | |
1459 | if self.autoindent: |
|
1436 | if self.autoindent: | |
1460 | self.readline_startup_hook(self.pre_readline) |
|
1437 | self.readline_startup_hook(self.pre_readline) | |
1461 | else: |
|
1438 | else: | |
1462 | prompt = self.outputcache.prompt1 |
|
1439 | prompt = self.outputcache.prompt1 | |
1463 | try: |
|
1440 | try: | |
1464 | line = self.raw_input(prompt,more) |
|
1441 | line = self.raw_input(prompt,more) | |
1465 | if self.autoindent: |
|
1442 | if self.autoindent: | |
1466 | self.readline_startup_hook(None) |
|
1443 | self.readline_startup_hook(None) | |
1467 | except KeyboardInterrupt: |
|
1444 | except KeyboardInterrupt: | |
1468 | self.write('\nKeyboardInterrupt\n') |
|
1445 | self.write('\nKeyboardInterrupt\n') | |
1469 | self.resetbuffer() |
|
1446 | self.resetbuffer() | |
1470 | # keep cache in sync with the prompt counter: |
|
1447 | # keep cache in sync with the prompt counter: | |
1471 | self.outputcache.prompt_count -= 1 |
|
1448 | self.outputcache.prompt_count -= 1 | |
1472 |
|
1449 | |||
1473 | if self.autoindent: |
|
1450 | if self.autoindent: | |
1474 | self.indent_current_nsp = 0 |
|
1451 | self.indent_current_nsp = 0 | |
1475 | more = 0 |
|
1452 | more = 0 | |
1476 | except EOFError: |
|
1453 | except EOFError: | |
1477 | if self.autoindent: |
|
1454 | if self.autoindent: | |
1478 | self.readline_startup_hook(None) |
|
1455 | self.readline_startup_hook(None) | |
1479 | self.write('\n') |
|
1456 | self.write('\n') | |
1480 | self.exit() |
|
1457 | self.exit() | |
1481 | except bdb.BdbQuit: |
|
1458 | except bdb.BdbQuit: | |
1482 | warn('The Python debugger has exited with a BdbQuit exception.\n' |
|
1459 | warn('The Python debugger has exited with a BdbQuit exception.\n' | |
1483 | 'Because of how pdb handles the stack, it is impossible\n' |
|
1460 | 'Because of how pdb handles the stack, it is impossible\n' | |
1484 | 'for IPython to properly format this particular exception.\n' |
|
1461 | 'for IPython to properly format this particular exception.\n' | |
1485 | 'IPython will resume normal operation.') |
|
1462 | 'IPython will resume normal operation.') | |
1486 | except: |
|
1463 | except: | |
1487 | # exceptions here are VERY RARE, but they can be triggered |
|
1464 | # exceptions here are VERY RARE, but they can be triggered | |
1488 | # asynchronously by signal handlers, for example. |
|
1465 | # asynchronously by signal handlers, for example. | |
1489 | self.showtraceback() |
|
1466 | self.showtraceback() | |
1490 | else: |
|
1467 | else: | |
1491 | more = self.push(line) |
|
1468 | more = self.push(line) | |
1492 | if (self.SyntaxTB.last_syntax_error and |
|
1469 | if (self.SyntaxTB.last_syntax_error and | |
1493 | self.rc.autoedit_syntax): |
|
1470 | self.rc.autoedit_syntax): | |
1494 | self.edit_syntax_error() |
|
1471 | self.edit_syntax_error() | |
1495 |
|
1472 | |||
1496 | # We are off again... |
|
1473 | # We are off again... | |
1497 | __builtin__.__dict__['__IPYTHON__active'] -= 1 |
|
1474 | __builtin__.__dict__['__IPYTHON__active'] -= 1 | |
1498 |
|
1475 | |||
1499 | def excepthook(self, type, value, tb): |
|
1476 | def excepthook(self, type, value, tb): | |
1500 | """One more defense for GUI apps that call sys.excepthook. |
|
1477 | """One more defense for GUI apps that call sys.excepthook. | |
1501 |
|
1478 | |||
1502 | GUI frameworks like wxPython trap exceptions and call |
|
1479 | GUI frameworks like wxPython trap exceptions and call | |
1503 | sys.excepthook themselves. I guess this is a feature that |
|
1480 | sys.excepthook themselves. I guess this is a feature that | |
1504 | enables them to keep running after exceptions that would |
|
1481 | enables them to keep running after exceptions that would | |
1505 | otherwise kill their mainloop. This is a bother for IPython |
|
1482 | otherwise kill their mainloop. This is a bother for IPython | |
1506 | which excepts to catch all of the program exceptions with a try: |
|
1483 | which excepts to catch all of the program exceptions with a try: | |
1507 | except: statement. |
|
1484 | except: statement. | |
1508 |
|
1485 | |||
1509 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if |
|
1486 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if | |
1510 | any app directly invokes sys.excepthook, it will look to the user like |
|
1487 | any app directly invokes sys.excepthook, it will look to the user like | |
1511 | IPython crashed. In order to work around this, we can disable the |
|
1488 | IPython crashed. In order to work around this, we can disable the | |
1512 | CrashHandler and replace it with this excepthook instead, which prints a |
|
1489 | CrashHandler and replace it with this excepthook instead, which prints a | |
1513 | regular traceback using our InteractiveTB. In this fashion, apps which |
|
1490 | regular traceback using our InteractiveTB. In this fashion, apps which | |
1514 | call sys.excepthook will generate a regular-looking exception from |
|
1491 | call sys.excepthook will generate a regular-looking exception from | |
1515 | IPython, and the CrashHandler will only be triggered by real IPython |
|
1492 | IPython, and the CrashHandler will only be triggered by real IPython | |
1516 | crashes. |
|
1493 | crashes. | |
1517 |
|
1494 | |||
1518 | This hook should be used sparingly, only in places which are not likely |
|
1495 | This hook should be used sparingly, only in places which are not likely | |
1519 | to be true IPython errors. |
|
1496 | to be true IPython errors. | |
1520 | """ |
|
1497 | """ | |
1521 |
|
1498 | |||
1522 | self.InteractiveTB(type, value, tb, tb_offset=0) |
|
1499 | self.InteractiveTB(type, value, tb, tb_offset=0) | |
1523 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1500 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1524 | self.readline.set_completer(self.Completer.complete) |
|
1501 | self.readline.set_completer(self.Completer.complete) | |
1525 |
|
1502 | |||
1526 | def call_alias(self,alias,rest=''): |
|
1503 | def call_alias(self,alias,rest=''): | |
1527 | """Call an alias given its name and the rest of the line. |
|
1504 | """Call an alias given its name and the rest of the line. | |
1528 |
|
1505 | |||
1529 | This function MUST be given a proper alias, because it doesn't make |
|
1506 | This function MUST be given a proper alias, because it doesn't make | |
1530 | any checks when looking up into the alias table. The caller is |
|
1507 | any checks when looking up into the alias table. The caller is | |
1531 | responsible for invoking it only with a valid alias.""" |
|
1508 | responsible for invoking it only with a valid alias.""" | |
1532 |
|
1509 | |||
1533 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg |
|
1510 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg | |
1534 | nargs,cmd = self.alias_table[alias] |
|
1511 | nargs,cmd = self.alias_table[alias] | |
1535 | # Expand the %l special to be the user's input line |
|
1512 | # Expand the %l special to be the user's input line | |
1536 | if cmd.find('%l') >= 0: |
|
1513 | if cmd.find('%l') >= 0: | |
1537 | cmd = cmd.replace('%l',rest) |
|
1514 | cmd = cmd.replace('%l',rest) | |
1538 | rest = '' |
|
1515 | rest = '' | |
1539 | if nargs==0: |
|
1516 | if nargs==0: | |
1540 | # Simple, argument-less aliases |
|
1517 | # Simple, argument-less aliases | |
1541 | cmd = '%s %s' % (cmd,rest) |
|
1518 | cmd = '%s %s' % (cmd,rest) | |
1542 | else: |
|
1519 | else: | |
1543 | # Handle aliases with positional arguments |
|
1520 | # Handle aliases with positional arguments | |
1544 | args = rest.split(None,nargs) |
|
1521 | args = rest.split(None,nargs) | |
1545 | if len(args)< nargs: |
|
1522 | if len(args)< nargs: | |
1546 | error('Alias <%s> requires %s arguments, %s given.' % |
|
1523 | error('Alias <%s> requires %s arguments, %s given.' % | |
1547 | (alias,nargs,len(args))) |
|
1524 | (alias,nargs,len(args))) | |
1548 | return |
|
1525 | return | |
1549 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) |
|
1526 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) | |
1550 | # Now call the macro, evaluating in the user's namespace |
|
1527 | # Now call the macro, evaluating in the user's namespace | |
1551 | try: |
|
1528 | try: | |
1552 | self.system(cmd) |
|
1529 | self.system(cmd) | |
1553 | except: |
|
1530 | except: | |
1554 | self.showtraceback() |
|
1531 | self.showtraceback() | |
1555 |
|
1532 | |||
1556 | def indent_current_str(self): |
|
1533 | def indent_current_str(self): | |
1557 | """return the current level of indentation as a string""" |
|
1534 | """return the current level of indentation as a string""" | |
1558 | return self.indent_current_nsp * ' ' |
|
1535 | return self.indent_current_nsp * ' ' | |
1559 |
|
1536 | |||
1560 | def autoindent_update(self,line): |
|
1537 | def autoindent_update(self,line): | |
1561 | """Keep track of the indent level.""" |
|
1538 | """Keep track of the indent level.""" | |
1562 |
|
1539 | |||
1563 | #debugx('line') |
|
1540 | #debugx('line') | |
1564 | #debugx('self.indent_current_nsp') |
|
1541 | #debugx('self.indent_current_nsp') | |
1565 | if self.autoindent: |
|
1542 | if self.autoindent: | |
1566 | if line: |
|
1543 | if line: | |
1567 | inisp = num_ini_spaces(line) |
|
1544 | inisp = num_ini_spaces(line) | |
1568 | if inisp < self.indent_current_nsp: |
|
1545 | if inisp < self.indent_current_nsp: | |
1569 | self.indent_current_nsp = inisp |
|
1546 | self.indent_current_nsp = inisp | |
1570 |
|
1547 | |||
1571 | if line[-1] == ':': |
|
1548 | if line[-1] == ':': | |
1572 | self.indent_current_nsp += 4 |
|
1549 | self.indent_current_nsp += 4 | |
1573 | elif dedent_re.match(line): |
|
1550 | elif dedent_re.match(line): | |
1574 | self.indent_current_nsp -= 4 |
|
1551 | self.indent_current_nsp -= 4 | |
1575 | else: |
|
1552 | else: | |
1576 | self.indent_current_nsp = 0 |
|
1553 | self.indent_current_nsp = 0 | |
1577 |
|
1554 | |||
1578 | def runlines(self,lines): |
|
1555 | def runlines(self,lines): | |
1579 | """Run a string of one or more lines of source. |
|
1556 | """Run a string of one or more lines of source. | |
1580 |
|
1557 | |||
1581 | This method is capable of running a string containing multiple source |
|
1558 | This method is capable of running a string containing multiple source | |
1582 | lines, as if they had been entered at the IPython prompt. Since it |
|
1559 | lines, as if they had been entered at the IPython prompt. Since it | |
1583 | exposes IPython's processing machinery, the given strings can contain |
|
1560 | exposes IPython's processing machinery, the given strings can contain | |
1584 | magic calls (%magic), special shell access (!cmd), etc.""" |
|
1561 | magic calls (%magic), special shell access (!cmd), etc.""" | |
1585 |
|
1562 | |||
1586 | # We must start with a clean buffer, in case this is run from an |
|
1563 | # We must start with a clean buffer, in case this is run from an | |
1587 | # interactive IPython session (via a magic, for example). |
|
1564 | # interactive IPython session (via a magic, for example). | |
1588 | self.resetbuffer() |
|
1565 | self.resetbuffer() | |
1589 | lines = lines.split('\n') |
|
1566 | lines = lines.split('\n') | |
1590 | more = 0 |
|
1567 | more = 0 | |
1591 | for line in lines: |
|
1568 | for line in lines: | |
1592 | # skip blank lines so we don't mess up the prompt counter, but do |
|
1569 | # skip blank lines so we don't mess up the prompt counter, but do | |
1593 | # NOT skip even a blank line if we are in a code block (more is |
|
1570 | # NOT skip even a blank line if we are in a code block (more is | |
1594 | # true) |
|
1571 | # true) | |
1595 | if line or more: |
|
1572 | if line or more: | |
1596 | more = self.push(self.prefilter(line,more)) |
|
1573 | more = self.push(self.prefilter(line,more)) | |
1597 | # IPython's runsource returns None if there was an error |
|
1574 | # IPython's runsource returns None if there was an error | |
1598 | # compiling the code. This allows us to stop processing right |
|
1575 | # compiling the code. This allows us to stop processing right | |
1599 | # away, so the user gets the error message at the right place. |
|
1576 | # away, so the user gets the error message at the right place. | |
1600 | if more is None: |
|
1577 | if more is None: | |
1601 | break |
|
1578 | break | |
1602 | # final newline in case the input didn't have it, so that the code |
|
1579 | # final newline in case the input didn't have it, so that the code | |
1603 | # actually does get executed |
|
1580 | # actually does get executed | |
1604 | if more: |
|
1581 | if more: | |
1605 | self.push('\n') |
|
1582 | self.push('\n') | |
1606 |
|
1583 | |||
1607 | def runsource(self, source, filename='<input>', symbol='single'): |
|
1584 | def runsource(self, source, filename='<input>', symbol='single'): | |
1608 | """Compile and run some source in the interpreter. |
|
1585 | """Compile and run some source in the interpreter. | |
1609 |
|
1586 | |||
1610 | Arguments are as for compile_command(). |
|
1587 | Arguments are as for compile_command(). | |
1611 |
|
1588 | |||
1612 | One several things can happen: |
|
1589 | One several things can happen: | |
1613 |
|
1590 | |||
1614 | 1) The input is incorrect; compile_command() raised an |
|
1591 | 1) The input is incorrect; compile_command() raised an | |
1615 | exception (SyntaxError or OverflowError). A syntax traceback |
|
1592 | exception (SyntaxError or OverflowError). A syntax traceback | |
1616 | will be printed by calling the showsyntaxerror() method. |
|
1593 | will be printed by calling the showsyntaxerror() method. | |
1617 |
|
1594 | |||
1618 | 2) The input is incomplete, and more input is required; |
|
1595 | 2) The input is incomplete, and more input is required; | |
1619 | compile_command() returned None. Nothing happens. |
|
1596 | compile_command() returned None. Nothing happens. | |
1620 |
|
1597 | |||
1621 | 3) The input is complete; compile_command() returned a code |
|
1598 | 3) The input is complete; compile_command() returned a code | |
1622 | object. The code is executed by calling self.runcode() (which |
|
1599 | object. The code is executed by calling self.runcode() (which | |
1623 | also handles run-time exceptions, except for SystemExit). |
|
1600 | also handles run-time exceptions, except for SystemExit). | |
1624 |
|
1601 | |||
1625 | The return value is: |
|
1602 | The return value is: | |
1626 |
|
1603 | |||
1627 | - True in case 2 |
|
1604 | - True in case 2 | |
1628 |
|
1605 | |||
1629 | - False in the other cases, unless an exception is raised, where |
|
1606 | - False in the other cases, unless an exception is raised, where | |
1630 | None is returned instead. This can be used by external callers to |
|
1607 | None is returned instead. This can be used by external callers to | |
1631 | know whether to continue feeding input or not. |
|
1608 | know whether to continue feeding input or not. | |
1632 |
|
1609 | |||
1633 | The return value can be used to decide whether to use sys.ps1 or |
|
1610 | The return value can be used to decide whether to use sys.ps1 or | |
1634 | sys.ps2 to prompt the next line.""" |
|
1611 | sys.ps2 to prompt the next line.""" | |
1635 |
|
1612 | |||
1636 | try: |
|
1613 | try: | |
1637 | code = self.compile(source,filename,symbol) |
|
1614 | code = self.compile(source,filename,symbol) | |
1638 | except (OverflowError, SyntaxError, ValueError): |
|
1615 | except (OverflowError, SyntaxError, ValueError): | |
1639 | # Case 1 |
|
1616 | # Case 1 | |
1640 | self.showsyntaxerror(filename) |
|
1617 | self.showsyntaxerror(filename) | |
1641 | return None |
|
1618 | return None | |
1642 |
|
1619 | |||
1643 | if code is None: |
|
1620 | if code is None: | |
1644 | # Case 2 |
|
1621 | # Case 2 | |
1645 | return True |
|
1622 | return True | |
1646 |
|
1623 | |||
1647 | # Case 3 |
|
1624 | # Case 3 | |
1648 | # We store the code object so that threaded shells and |
|
1625 | # We store the code object so that threaded shells and | |
1649 | # custom exception handlers can access all this info if needed. |
|
1626 | # custom exception handlers can access all this info if needed. | |
1650 | # The source corresponding to this can be obtained from the |
|
1627 | # The source corresponding to this can be obtained from the | |
1651 | # buffer attribute as '\n'.join(self.buffer). |
|
1628 | # buffer attribute as '\n'.join(self.buffer). | |
1652 | self.code_to_run = code |
|
1629 | self.code_to_run = code | |
1653 | # now actually execute the code object |
|
1630 | # now actually execute the code object | |
1654 | if self.runcode(code) == 0: |
|
1631 | if self.runcode(code) == 0: | |
1655 | return False |
|
1632 | return False | |
1656 | else: |
|
1633 | else: | |
1657 | return None |
|
1634 | return None | |
1658 |
|
1635 | |||
1659 | def runcode(self,code_obj): |
|
1636 | def runcode(self,code_obj): | |
1660 | """Execute a code object. |
|
1637 | """Execute a code object. | |
1661 |
|
1638 | |||
1662 | When an exception occurs, self.showtraceback() is called to display a |
|
1639 | When an exception occurs, self.showtraceback() is called to display a | |
1663 | traceback. |
|
1640 | traceback. | |
1664 |
|
1641 | |||
1665 | Return value: a flag indicating whether the code to be run completed |
|
1642 | Return value: a flag indicating whether the code to be run completed | |
1666 | successfully: |
|
1643 | successfully: | |
1667 |
|
1644 | |||
1668 | - 0: successful execution. |
|
1645 | - 0: successful execution. | |
1669 | - 1: an error occurred. |
|
1646 | - 1: an error occurred. | |
1670 | """ |
|
1647 | """ | |
1671 |
|
1648 | |||
1672 | # Set our own excepthook in case the user code tries to call it |
|
1649 | # Set our own excepthook in case the user code tries to call it | |
1673 | # directly, so that the IPython crash handler doesn't get triggered |
|
1650 | # directly, so that the IPython crash handler doesn't get triggered | |
1674 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook |
|
1651 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook | |
1675 |
|
1652 | |||
1676 | # we save the original sys.excepthook in the instance, in case config |
|
1653 | # we save the original sys.excepthook in the instance, in case config | |
1677 | # code (such as magics) needs access to it. |
|
1654 | # code (such as magics) needs access to it. | |
1678 | self.sys_excepthook = old_excepthook |
|
1655 | self.sys_excepthook = old_excepthook | |
1679 | outflag = 1 # happens in more places, so it's easier as default |
|
1656 | outflag = 1 # happens in more places, so it's easier as default | |
1680 | try: |
|
1657 | try: | |
1681 | try: |
|
1658 | try: | |
1682 | # Embedded instances require separate global/local namespaces |
|
1659 | # Embedded instances require separate global/local namespaces | |
1683 | # so they can see both the surrounding (local) namespace and |
|
1660 | # so they can see both the surrounding (local) namespace and | |
1684 | # the module-level globals when called inside another function. |
|
1661 | # the module-level globals when called inside another function. | |
1685 | if self.embedded: |
|
1662 | if self.embedded: | |
1686 | exec code_obj in self.user_global_ns, self.user_ns |
|
1663 | exec code_obj in self.user_global_ns, self.user_ns | |
1687 | # Normal (non-embedded) instances should only have a single |
|
1664 | # Normal (non-embedded) instances should only have a single | |
1688 | # namespace for user code execution, otherwise functions won't |
|
1665 | # namespace for user code execution, otherwise functions won't | |
1689 | # see interactive top-level globals. |
|
1666 | # see interactive top-level globals. | |
1690 | else: |
|
1667 | else: | |
1691 | exec code_obj in self.user_ns |
|
1668 | exec code_obj in self.user_ns | |
1692 | finally: |
|
1669 | finally: | |
1693 | # Reset our crash handler in place |
|
1670 | # Reset our crash handler in place | |
1694 | sys.excepthook = old_excepthook |
|
1671 | sys.excepthook = old_excepthook | |
1695 | except SystemExit: |
|
1672 | except SystemExit: | |
1696 | self.resetbuffer() |
|
1673 | self.resetbuffer() | |
1697 | self.showtraceback() |
|
1674 | self.showtraceback() | |
1698 | warn("Type exit or quit to exit IPython " |
|
1675 | warn("Type exit or quit to exit IPython " | |
1699 | "(%Exit or %Quit do so unconditionally).",level=1) |
|
1676 | "(%Exit or %Quit do so unconditionally).",level=1) | |
1700 | except self.custom_exceptions: |
|
1677 | except self.custom_exceptions: | |
1701 | etype,value,tb = sys.exc_info() |
|
1678 | etype,value,tb = sys.exc_info() | |
1702 | self.CustomTB(etype,value,tb) |
|
1679 | self.CustomTB(etype,value,tb) | |
1703 | except: |
|
1680 | except: | |
1704 | self.showtraceback() |
|
1681 | self.showtraceback() | |
1705 | else: |
|
1682 | else: | |
1706 | outflag = 0 |
|
1683 | outflag = 0 | |
1707 | if softspace(sys.stdout, 0): |
|
1684 | if softspace(sys.stdout, 0): | |
1708 |
|
1685 | |||
1709 | # Flush out code object which has been run (and source) |
|
1686 | # Flush out code object which has been run (and source) | |
1710 | self.code_to_run = None |
|
1687 | self.code_to_run = None | |
1711 | return outflag |
|
1688 | return outflag | |
1712 |
|
1689 | |||
1713 | def push(self, line): |
|
1690 | def push(self, line): | |
1714 | """Push a line to the interpreter. |
|
1691 | """Push a line to the interpreter. | |
1715 |
|
1692 | |||
1716 | The line should not have a trailing newline; it may have |
|
1693 | The line should not have a trailing newline; it may have | |
1717 | internal newlines. The line is appended to a buffer and the |
|
1694 | internal newlines. The line is appended to a buffer and the | |
1718 | interpreter's runsource() method is called with the |
|
1695 | interpreter's runsource() method is called with the | |
1719 | concatenated contents of the buffer as source. If this |
|
1696 | concatenated contents of the buffer as source. If this | |
1720 | indicates that the command was executed or invalid, the buffer |
|
1697 | indicates that the command was executed or invalid, the buffer | |
1721 | is reset; otherwise, the command is incomplete, and the buffer |
|
1698 | is reset; otherwise, the command is incomplete, and the buffer | |
1722 | is left as it was after the line was appended. The return |
|
1699 | is left as it was after the line was appended. The return | |
1723 | value is 1 if more input is required, 0 if the line was dealt |
|
1700 | value is 1 if more input is required, 0 if the line was dealt | |
1724 | with in some way (this is the same as runsource()). |
|
1701 | with in some way (this is the same as runsource()). | |
1725 | """ |
|
1702 | """ | |
1726 |
|
1703 | |||
1727 | # autoindent management should be done here, and not in the |
|
1704 | # autoindent management should be done here, and not in the | |
1728 | # interactive loop, since that one is only seen by keyboard input. We |
|
1705 | # interactive loop, since that one is only seen by keyboard input. We | |
1729 | # need this done correctly even for code run via runlines (which uses |
|
1706 | # need this done correctly even for code run via runlines (which uses | |
1730 | # push). |
|
1707 | # push). | |
1731 |
|
1708 | |||
1732 | #print 'push line: <%s>' % line # dbg |
|
1709 | #print 'push line: <%s>' % line # dbg | |
1733 | self.autoindent_update(line) |
|
1710 | self.autoindent_update(line) | |
1734 |
|
1711 | |||
1735 | self.buffer.append(line) |
|
1712 | self.buffer.append(line) | |
1736 | more = self.runsource('\n'.join(self.buffer), self.filename) |
|
1713 | more = self.runsource('\n'.join(self.buffer), self.filename) | |
1737 | if not more: |
|
1714 | if not more: | |
1738 | self.resetbuffer() |
|
1715 | self.resetbuffer() | |
1739 | return more |
|
1716 | return more | |
1740 |
|
1717 | |||
1741 | def resetbuffer(self): |
|
1718 | def resetbuffer(self): | |
1742 | """Reset the input buffer.""" |
|
1719 | """Reset the input buffer.""" | |
1743 | self.buffer[:] = [] |
|
1720 | self.buffer[:] = [] | |
1744 |
|
1721 | |||
1745 | def raw_input(self,prompt='',continue_prompt=False): |
|
1722 | def raw_input(self,prompt='',continue_prompt=False): | |
1746 | """Write a prompt and read a line. |
|
1723 | """Write a prompt and read a line. | |
1747 |
|
1724 | |||
1748 | The returned line does not include the trailing newline. |
|
1725 | The returned line does not include the trailing newline. | |
1749 | When the user enters the EOF key sequence, EOFError is raised. |
|
1726 | When the user enters the EOF key sequence, EOFError is raised. | |
1750 |
|
1727 | |||
1751 | Optional inputs: |
|
1728 | Optional inputs: | |
1752 |
|
1729 | |||
1753 | - prompt(''): a string to be printed to prompt the user. |
|
1730 | - prompt(''): a string to be printed to prompt the user. | |
1754 |
|
1731 | |||
1755 | - continue_prompt(False): whether this line is the first one or a |
|
1732 | - continue_prompt(False): whether this line is the first one or a | |
1756 | continuation in a sequence of inputs. |
|
1733 | continuation in a sequence of inputs. | |
1757 | """ |
|
1734 | """ | |
1758 |
|
1735 | |||
1759 | line = raw_input_original(prompt) |
|
1736 | line = raw_input_original(prompt) | |
1760 |
|
1737 | |||
1761 | # Try to be reasonably smart about not re-indenting pasted input more |
|
1738 | # Try to be reasonably smart about not re-indenting pasted input more | |
1762 | # than necessary. We do this by trimming out the auto-indent initial |
|
1739 | # than necessary. We do this by trimming out the auto-indent initial | |
1763 | # spaces, if the user's actual input started itself with whitespace. |
|
1740 | # spaces, if the user's actual input started itself with whitespace. | |
1764 | #debugx('self.buffer[-1]') |
|
1741 | #debugx('self.buffer[-1]') | |
1765 |
|
1742 | |||
1766 | if self.autoindent: |
|
1743 | if self.autoindent: | |
1767 | if num_ini_spaces(line) > self.indent_current_nsp: |
|
1744 | if num_ini_spaces(line) > self.indent_current_nsp: | |
1768 | line = line[self.indent_current_nsp:] |
|
1745 | line = line[self.indent_current_nsp:] | |
1769 | self.indent_current_nsp = 0 |
|
1746 | self.indent_current_nsp = 0 | |
1770 |
|
1747 | |||
1771 | # store the unfiltered input before the user has any chance to modify |
|
1748 | # store the unfiltered input before the user has any chance to modify | |
1772 | # it. |
|
1749 | # it. | |
1773 | if line.strip(): |
|
1750 | if line.strip(): | |
1774 | if continue_prompt: |
|
1751 | if continue_prompt: | |
1775 | self.input_hist_raw[-1] += '%s\n' % line |
|
1752 | self.input_hist_raw[-1] += '%s\n' % line | |
1776 | else: |
|
1753 | else: | |
1777 | self.input_hist_raw.append('%s\n' % line) |
|
1754 | self.input_hist_raw.append('%s\n' % line) | |
1778 |
|
1755 | |||
1779 | lineout = self.prefilter(line,continue_prompt) |
|
1756 | lineout = self.prefilter(line,continue_prompt) | |
1780 | return lineout |
|
1757 | return lineout | |
1781 |
|
1758 | |||
1782 | def split_user_input(self,line): |
|
1759 | def split_user_input(self,line): | |
1783 | """Split user input into pre-char, function part and rest.""" |
|
1760 | """Split user input into pre-char, function part and rest.""" | |
1784 |
|
1761 | |||
1785 | lsplit = self.line_split.match(line) |
|
1762 | lsplit = self.line_split.match(line) | |
1786 | if lsplit is None: # no regexp match returns None |
|
1763 | if lsplit is None: # no regexp match returns None | |
1787 | try: |
|
1764 | try: | |
1788 | iFun,theRest = line.split(None,1) |
|
1765 | iFun,theRest = line.split(None,1) | |
1789 | except ValueError: |
|
1766 | except ValueError: | |
1790 | iFun,theRest = line,'' |
|
1767 | iFun,theRest = line,'' | |
1791 | pre = re.match('^(\s*)(.*)',line).groups()[0] |
|
1768 | pre = re.match('^(\s*)(.*)',line).groups()[0] | |
1792 | else: |
|
1769 | else: | |
1793 | pre,iFun,theRest = lsplit.groups() |
|
1770 | pre,iFun,theRest = lsplit.groups() | |
1794 |
|
1771 | |||
1795 | #print 'line:<%s>' % line # dbg |
|
1772 | #print 'line:<%s>' % line # dbg | |
1796 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg |
|
1773 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg | |
1797 | return pre,iFun.strip(),theRest |
|
1774 | return pre,iFun.strip(),theRest | |
1798 |
|
1775 | |||
1799 | def _prefilter(self, line, continue_prompt): |
|
1776 | def _prefilter(self, line, continue_prompt): | |
1800 | """Calls different preprocessors, depending on the form of line.""" |
|
1777 | """Calls different preprocessors, depending on the form of line.""" | |
1801 |
|
1778 | |||
1802 | # All handlers *must* return a value, even if it's blank (''). |
|
1779 | # All handlers *must* return a value, even if it's blank (''). | |
1803 |
|
1780 | |||
1804 | # Lines are NOT logged here. Handlers should process the line as |
|
1781 | # Lines are NOT logged here. Handlers should process the line as | |
1805 | # needed, update the cache AND log it (so that the input cache array |
|
1782 | # needed, update the cache AND log it (so that the input cache array | |
1806 | # stays synced). |
|
1783 | # stays synced). | |
1807 |
|
1784 | |||
1808 | # This function is _very_ delicate, and since it's also the one which |
|
1785 | # This function is _very_ delicate, and since it's also the one which | |
1809 | # determines IPython's response to user input, it must be as efficient |
|
1786 | # determines IPython's response to user input, it must be as efficient | |
1810 | # as possible. For this reason it has _many_ returns in it, trying |
|
1787 | # as possible. For this reason it has _many_ returns in it, trying | |
1811 | # always to exit as quickly as it can figure out what it needs to do. |
|
1788 | # always to exit as quickly as it can figure out what it needs to do. | |
1812 |
|
1789 | |||
1813 | # This function is the main responsible for maintaining IPython's |
|
1790 | # This function is the main responsible for maintaining IPython's | |
1814 | # behavior respectful of Python's semantics. So be _very_ careful if |
|
1791 | # behavior respectful of Python's semantics. So be _very_ careful if | |
1815 | # making changes to anything here. |
|
1792 | # making changes to anything here. | |
1816 |
|
1793 | |||
1817 | #..................................................................... |
|
1794 | #..................................................................... | |
1818 | # Code begins |
|
1795 | # Code begins | |
1819 |
|
1796 | |||
1820 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg |
|
1797 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg | |
1821 |
|
1798 | |||
1822 | # save the line away in case we crash, so the post-mortem handler can |
|
1799 | # save the line away in case we crash, so the post-mortem handler can | |
1823 | # record it |
|
1800 | # record it | |
1824 | self._last_input_line = line |
|
1801 | self._last_input_line = line | |
1825 |
|
1802 | |||
1826 | #print '***line: <%s>' % line # dbg |
|
1803 | #print '***line: <%s>' % line # dbg | |
1827 |
|
1804 | |||
1828 | # the input history needs to track even empty lines |
|
1805 | # the input history needs to track even empty lines | |
1829 | stripped = line.strip() |
|
1806 | stripped = line.strip() | |
1830 |
|
1807 | |||
1831 | if not stripped: |
|
1808 | if not stripped: | |
1832 | if not continue_prompt: |
|
1809 | if not continue_prompt: | |
1833 | self.outputcache.prompt_count -= 1 |
|
1810 | self.outputcache.prompt_count -= 1 | |
1834 | return self.handle_normal(line,continue_prompt) |
|
1811 | return self.handle_normal(line,continue_prompt) | |
1835 | #return self.handle_normal('',continue_prompt) |
|
1812 | #return self.handle_normal('',continue_prompt) | |
1836 |
|
1813 | |||
1837 | # print '***cont',continue_prompt # dbg |
|
1814 | # print '***cont',continue_prompt # dbg | |
1838 | # special handlers are only allowed for single line statements |
|
1815 | # special handlers are only allowed for single line statements | |
1839 | if continue_prompt and not self.rc.multi_line_specials: |
|
1816 | if continue_prompt and not self.rc.multi_line_specials: | |
1840 | return self.handle_normal(line,continue_prompt) |
|
1817 | return self.handle_normal(line,continue_prompt) | |
1841 |
|
1818 | |||
1842 |
|
1819 | |||
1843 | # For the rest, we need the structure of the input |
|
1820 | # For the rest, we need the structure of the input | |
1844 | pre,iFun,theRest = self.split_user_input(line) |
|
1821 | pre,iFun,theRest = self.split_user_input(line) | |
1845 |
|
1822 | |||
1846 | # See whether any pre-existing handler can take care of it |
|
1823 | # See whether any pre-existing handler can take care of it | |
1847 |
|
1824 | |||
1848 | rewritten = self.hooks.input_prefilter(stripped) |
|
1825 | rewritten = self.hooks.input_prefilter(stripped) | |
1849 | if rewritten != stripped: # ok, some prefilter did something |
|
1826 | if rewritten != stripped: # ok, some prefilter did something | |
1850 | rewritten = pre + rewritten # add indentation |
|
1827 | rewritten = pre + rewritten # add indentation | |
1851 | return self.handle_normal(rewritten) |
|
1828 | return self.handle_normal(rewritten) | |
1852 |
|
1829 | |||
1853 |
|
1830 | |||
1854 |
|
1831 | |||
1855 |
|
1832 | |||
1856 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1833 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1857 |
|
1834 | |||
1858 | # First check for explicit escapes in the last/first character |
|
1835 | # First check for explicit escapes in the last/first character | |
1859 | handler = None |
|
1836 | handler = None | |
1860 | if line[-1] == self.ESC_HELP: |
|
1837 | if line[-1] == self.ESC_HELP: | |
1861 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end |
|
1838 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end | |
1862 | if handler is None: |
|
1839 | if handler is None: | |
1863 | # look at the first character of iFun, NOT of line, so we skip |
|
1840 | # look at the first character of iFun, NOT of line, so we skip | |
1864 | # leading whitespace in multiline input |
|
1841 | # leading whitespace in multiline input | |
1865 | handler = self.esc_handlers.get(iFun[0:1]) |
|
1842 | handler = self.esc_handlers.get(iFun[0:1]) | |
1866 | if handler is not None: |
|
1843 | if handler is not None: | |
1867 | return handler(line,continue_prompt,pre,iFun,theRest) |
|
1844 | return handler(line,continue_prompt,pre,iFun,theRest) | |
1868 | # Emacs ipython-mode tags certain input lines |
|
1845 | # Emacs ipython-mode tags certain input lines | |
1869 | if line.endswith('# PYTHON-MODE'): |
|
1846 | if line.endswith('# PYTHON-MODE'): | |
1870 | return self.handle_emacs(line,continue_prompt) |
|
1847 | return self.handle_emacs(line,continue_prompt) | |
1871 |
|
1848 | |||
1872 | # Next, check if we can automatically execute this thing |
|
1849 | # Next, check if we can automatically execute this thing | |
1873 |
|
1850 | |||
1874 | # Allow ! in multi-line statements if multi_line_specials is on: |
|
1851 | # Allow ! in multi-line statements if multi_line_specials is on: | |
1875 | if continue_prompt and self.rc.multi_line_specials and \ |
|
1852 | if continue_prompt and self.rc.multi_line_specials and \ | |
1876 | iFun.startswith(self.ESC_SHELL): |
|
1853 | iFun.startswith(self.ESC_SHELL): | |
1877 | return self.handle_shell_escape(line,continue_prompt, |
|
1854 | return self.handle_shell_escape(line,continue_prompt, | |
1878 | pre=pre,iFun=iFun, |
|
1855 | pre=pre,iFun=iFun, | |
1879 | theRest=theRest) |
|
1856 | theRest=theRest) | |
1880 |
|
1857 | |||
1881 | # Let's try to find if the input line is a magic fn |
|
1858 | # Let's try to find if the input line is a magic fn | |
1882 | oinfo = None |
|
1859 | oinfo = None | |
1883 | if hasattr(self,'magic_'+iFun): |
|
1860 | if hasattr(self,'magic_'+iFun): | |
1884 | # WARNING: _ofind uses getattr(), so it can consume generators and |
|
1861 | # WARNING: _ofind uses getattr(), so it can consume generators and | |
1885 | # cause other side effects. |
|
1862 | # cause other side effects. | |
1886 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1863 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1887 | if oinfo['ismagic']: |
|
1864 | if oinfo['ismagic']: | |
1888 | # Be careful not to call magics when a variable assignment is |
|
1865 | # Be careful not to call magics when a variable assignment is | |
1889 | # being made (ls='hi', for example) |
|
1866 | # being made (ls='hi', for example) | |
1890 | if self.rc.automagic and \ |
|
1867 | if self.rc.automagic and \ | |
1891 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ |
|
1868 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ | |
1892 | (self.rc.multi_line_specials or not continue_prompt): |
|
1869 | (self.rc.multi_line_specials or not continue_prompt): | |
1893 | return self.handle_magic(line,continue_prompt, |
|
1870 | return self.handle_magic(line,continue_prompt, | |
1894 | pre,iFun,theRest) |
|
1871 | pre,iFun,theRest) | |
1895 | else: |
|
1872 | else: | |
1896 | return self.handle_normal(line,continue_prompt) |
|
1873 | return self.handle_normal(line,continue_prompt) | |
1897 |
|
1874 | |||
1898 | # If the rest of the line begins with an (in)equality, assginment or |
|
1875 | # If the rest of the line begins with an (in)equality, assginment or | |
1899 | # function call, we should not call _ofind but simply execute it. |
|
1876 | # function call, we should not call _ofind but simply execute it. | |
1900 | # This avoids spurious geattr() accesses on objects upon assignment. |
|
1877 | # This avoids spurious geattr() accesses on objects upon assignment. | |
1901 | # |
|
1878 | # | |
1902 | # It also allows users to assign to either alias or magic names true |
|
1879 | # It also allows users to assign to either alias or magic names true | |
1903 | # python variables (the magic/alias systems always take second seat to |
|
1880 | # python variables (the magic/alias systems always take second seat to | |
1904 | # true python code). |
|
1881 | # true python code). | |
1905 | if theRest and theRest[0] in '!=()': |
|
1882 | if theRest and theRest[0] in '!=()': | |
1906 | return self.handle_normal(line,continue_prompt) |
|
1883 | return self.handle_normal(line,continue_prompt) | |
1907 |
|
1884 | |||
1908 | if oinfo is None: |
|
1885 | if oinfo is None: | |
1909 | # let's try to ensure that _oinfo is ONLY called when autocall is |
|
1886 | # let's try to ensure that _oinfo is ONLY called when autocall is | |
1910 | # on. Since it has inevitable potential side effects, at least |
|
1887 | # on. Since it has inevitable potential side effects, at least | |
1911 | # having autocall off should be a guarantee to the user that no |
|
1888 | # having autocall off should be a guarantee to the user that no | |
1912 | # weird things will happen. |
|
1889 | # weird things will happen. | |
1913 |
|
1890 | |||
1914 | if self.rc.autocall: |
|
1891 | if self.rc.autocall: | |
1915 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1892 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1916 | else: |
|
1893 | else: | |
1917 | # in this case, all that's left is either an alias or |
|
1894 | # in this case, all that's left is either an alias or | |
1918 | # processing the line normally. |
|
1895 | # processing the line normally. | |
1919 | if iFun in self.alias_table: |
|
1896 | if iFun in self.alias_table: | |
1920 | return self.handle_alias(line,continue_prompt, |
|
1897 | return self.handle_alias(line,continue_prompt, | |
1921 | pre,iFun,theRest) |
|
1898 | pre,iFun,theRest) | |
1922 |
|
1899 | |||
1923 | else: |
|
1900 | else: | |
1924 | return self.handle_normal(line,continue_prompt) |
|
1901 | return self.handle_normal(line,continue_prompt) | |
1925 |
|
1902 | |||
1926 | if not oinfo['found']: |
|
1903 | if not oinfo['found']: | |
1927 | return self.handle_normal(line,continue_prompt) |
|
1904 | return self.handle_normal(line,continue_prompt) | |
1928 | else: |
|
1905 | else: | |
1929 | #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1906 | #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1930 | if oinfo['isalias']: |
|
1907 | if oinfo['isalias']: | |
1931 | return self.handle_alias(line,continue_prompt, |
|
1908 | return self.handle_alias(line,continue_prompt, | |
1932 | pre,iFun,theRest) |
|
1909 | pre,iFun,theRest) | |
1933 |
|
1910 | |||
1934 | if (self.rc.autocall |
|
1911 | if (self.rc.autocall | |
1935 | and |
|
1912 | and | |
1936 | ( |
|
1913 | ( | |
1937 | #only consider exclusion re if not "," or ";" autoquoting |
|
1914 | #only consider exclusion re if not "," or ";" autoquoting | |
1938 | (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2 |
|
1915 | (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2 | |
1939 | or pre == self.ESC_PAREN) or |
|
1916 | or pre == self.ESC_PAREN) or | |
1940 | (not self.re_exclude_auto.match(theRest))) |
|
1917 | (not self.re_exclude_auto.match(theRest))) | |
1941 | and |
|
1918 | and | |
1942 | self.re_fun_name.match(iFun) and |
|
1919 | self.re_fun_name.match(iFun) and | |
1943 | callable(oinfo['obj'])) : |
|
1920 | callable(oinfo['obj'])) : | |
1944 | #print 'going auto' # dbg |
|
1921 | #print 'going auto' # dbg | |
1945 | return self.handle_auto(line,continue_prompt, |
|
1922 | return self.handle_auto(line,continue_prompt, | |
1946 | pre,iFun,theRest,oinfo['obj']) |
|
1923 | pre,iFun,theRest,oinfo['obj']) | |
1947 | else: |
|
1924 | else: | |
1948 | #print 'was callable?', callable(oinfo['obj']) # dbg |
|
1925 | #print 'was callable?', callable(oinfo['obj']) # dbg | |
1949 | return self.handle_normal(line,continue_prompt) |
|
1926 | return self.handle_normal(line,continue_prompt) | |
1950 |
|
1927 | |||
1951 | # If we get here, we have a normal Python line. Log and return. |
|
1928 | # If we get here, we have a normal Python line. Log and return. | |
1952 | return self.handle_normal(line,continue_prompt) |
|
1929 | return self.handle_normal(line,continue_prompt) | |
1953 |
|
1930 | |||
1954 | def _prefilter_dumb(self, line, continue_prompt): |
|
1931 | def _prefilter_dumb(self, line, continue_prompt): | |
1955 | """simple prefilter function, for debugging""" |
|
1932 | """simple prefilter function, for debugging""" | |
1956 | return self.handle_normal(line,continue_prompt) |
|
1933 | return self.handle_normal(line,continue_prompt) | |
1957 |
|
1934 | |||
1958 | # Set the default prefilter() function (this can be user-overridden) |
|
1935 | # Set the default prefilter() function (this can be user-overridden) | |
1959 | prefilter = _prefilter |
|
1936 | prefilter = _prefilter | |
1960 |
|
1937 | |||
1961 | def handle_normal(self,line,continue_prompt=None, |
|
1938 | def handle_normal(self,line,continue_prompt=None, | |
1962 | pre=None,iFun=None,theRest=None): |
|
1939 | pre=None,iFun=None,theRest=None): | |
1963 | """Handle normal input lines. Use as a template for handlers.""" |
|
1940 | """Handle normal input lines. Use as a template for handlers.""" | |
1964 |
|
1941 | |||
1965 | # With autoindent on, we need some way to exit the input loop, and I |
|
1942 | # With autoindent on, we need some way to exit the input loop, and I | |
1966 | # don't want to force the user to have to backspace all the way to |
|
1943 | # don't want to force the user to have to backspace all the way to | |
1967 | # clear the line. The rule will be in this case, that either two |
|
1944 | # clear the line. The rule will be in this case, that either two | |
1968 | # lines of pure whitespace in a row, or a line of pure whitespace but |
|
1945 | # lines of pure whitespace in a row, or a line of pure whitespace but | |
1969 | # of a size different to the indent level, will exit the input loop. |
|
1946 | # of a size different to the indent level, will exit the input loop. | |
1970 |
|
1947 | |||
1971 | if (continue_prompt and self.autoindent and line.isspace() and |
|
1948 | if (continue_prompt and self.autoindent and line.isspace() and | |
1972 | (0 < abs(len(line) - self.indent_current_nsp) <= 2 or |
|
1949 | (0 < abs(len(line) - self.indent_current_nsp) <= 2 or | |
1973 | (self.buffer[-1]).isspace() )): |
|
1950 | (self.buffer[-1]).isspace() )): | |
1974 | line = '' |
|
1951 | line = '' | |
1975 |
|
1952 | |||
1976 | self.log(line,continue_prompt) |
|
1953 | self.log(line,continue_prompt) | |
1977 | return line |
|
1954 | return line | |
1978 |
|
1955 | |||
1979 | def handle_alias(self,line,continue_prompt=None, |
|
1956 | def handle_alias(self,line,continue_prompt=None, | |
1980 | pre=None,iFun=None,theRest=None): |
|
1957 | pre=None,iFun=None,theRest=None): | |
1981 | """Handle alias input lines. """ |
|
1958 | """Handle alias input lines. """ | |
1982 |
|
1959 | |||
1983 | # pre is needed, because it carries the leading whitespace. Otherwise |
|
1960 | # pre is needed, because it carries the leading whitespace. Otherwise | |
1984 | # aliases won't work in indented sections. |
|
1961 | # aliases won't work in indented sections. | |
1985 | line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest)) |
|
1962 | line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest)) | |
1986 | self.log(line_out,continue_prompt) |
|
1963 | self.log(line_out,continue_prompt) | |
1987 | return line_out |
|
1964 | return line_out | |
1988 |
|
1965 | |||
1989 | def handle_shell_escape(self, line, continue_prompt=None, |
|
1966 | def handle_shell_escape(self, line, continue_prompt=None, | |
1990 | pre=None,iFun=None,theRest=None): |
|
1967 | pre=None,iFun=None,theRest=None): | |
1991 | """Execute the line in a shell, empty return value""" |
|
1968 | """Execute the line in a shell, empty return value""" | |
1992 |
|
1969 | |||
1993 | #print 'line in :', `line` # dbg |
|
1970 | #print 'line in :', `line` # dbg | |
1994 | # Example of a special handler. Others follow a similar pattern. |
|
1971 | # Example of a special handler. Others follow a similar pattern. | |
1995 | if line.lstrip().startswith('!!'): |
|
1972 | if line.lstrip().startswith('!!'): | |
1996 | # rewrite iFun/theRest to properly hold the call to %sx and |
|
1973 | # rewrite iFun/theRest to properly hold the call to %sx and | |
1997 | # the actual command to be executed, so handle_magic can work |
|
1974 | # the actual command to be executed, so handle_magic can work | |
1998 | # correctly |
|
1975 | # correctly | |
1999 | theRest = '%s %s' % (iFun[2:],theRest) |
|
1976 | theRest = '%s %s' % (iFun[2:],theRest) | |
2000 | iFun = 'sx' |
|
1977 | iFun = 'sx' | |
2001 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC, |
|
1978 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC, | |
2002 | line.lstrip()[2:]), |
|
1979 | line.lstrip()[2:]), | |
2003 | continue_prompt,pre,iFun,theRest) |
|
1980 | continue_prompt,pre,iFun,theRest) | |
2004 | else: |
|
1981 | else: | |
2005 | cmd=line.lstrip().lstrip('!') |
|
1982 | cmd=line.lstrip().lstrip('!') | |
2006 | line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd)) |
|
1983 | line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd)) | |
2007 | # update cache/log and return |
|
1984 | # update cache/log and return | |
2008 | self.log(line_out,continue_prompt) |
|
1985 | self.log(line_out,continue_prompt) | |
2009 | return line_out |
|
1986 | return line_out | |
2010 |
|
1987 | |||
2011 | def handle_magic(self, line, continue_prompt=None, |
|
1988 | def handle_magic(self, line, continue_prompt=None, | |
2012 | pre=None,iFun=None,theRest=None): |
|
1989 | pre=None,iFun=None,theRest=None): | |
2013 | """Execute magic functions.""" |
|
1990 | """Execute magic functions.""" | |
2014 |
|
1991 | |||
2015 |
|
1992 | |||
2016 | cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest)) |
|
1993 | cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest)) | |
2017 | self.log(cmd,continue_prompt) |
|
1994 | self.log(cmd,continue_prompt) | |
2018 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg |
|
1995 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg | |
2019 | return cmd |
|
1996 | return cmd | |
2020 |
|
1997 | |||
2021 | def handle_auto(self, line, continue_prompt=None, |
|
1998 | def handle_auto(self, line, continue_prompt=None, | |
2022 | pre=None,iFun=None,theRest=None,obj=None): |
|
1999 | pre=None,iFun=None,theRest=None,obj=None): | |
2023 | """Hande lines which can be auto-executed, quoting if requested.""" |
|
2000 | """Hande lines which can be auto-executed, quoting if requested.""" | |
2024 |
|
2001 | |||
2025 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
2002 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
2026 |
|
2003 | |||
2027 | # This should only be active for single-line input! |
|
2004 | # This should only be active for single-line input! | |
2028 | if continue_prompt: |
|
2005 | if continue_prompt: | |
2029 | self.log(line,continue_prompt) |
|
2006 | self.log(line,continue_prompt) | |
2030 | return line |
|
2007 | return line | |
2031 |
|
2008 | |||
2032 | auto_rewrite = True |
|
2009 | auto_rewrite = True | |
2033 |
|
2010 | |||
2034 | if pre == self.ESC_QUOTE: |
|
2011 | if pre == self.ESC_QUOTE: | |
2035 | # Auto-quote splitting on whitespace |
|
2012 | # Auto-quote splitting on whitespace | |
2036 | newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) ) |
|
2013 | newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) ) | |
2037 | elif pre == self.ESC_QUOTE2: |
|
2014 | elif pre == self.ESC_QUOTE2: | |
2038 | # Auto-quote whole string |
|
2015 | # Auto-quote whole string | |
2039 | newcmd = '%s("%s")' % (iFun,theRest) |
|
2016 | newcmd = '%s("%s")' % (iFun,theRest) | |
2040 | elif pre == self.ESC_PAREN: |
|
2017 | elif pre == self.ESC_PAREN: | |
2041 | newcmd = '%s(%s)' % (iFun,",".join(theRest.split())) |
|
2018 | newcmd = '%s(%s)' % (iFun,",".join(theRest.split())) | |
2042 | else: |
|
2019 | else: | |
2043 | # Auto-paren. |
|
2020 | # Auto-paren. | |
2044 | # We only apply it to argument-less calls if the autocall |
|
2021 | # We only apply it to argument-less calls if the autocall | |
2045 | # parameter is set to 2. We only need to check that autocall is < |
|
2022 | # parameter is set to 2. We only need to check that autocall is < | |
2046 | # 2, since this function isn't called unless it's at least 1. |
|
2023 | # 2, since this function isn't called unless it's at least 1. | |
2047 | if not theRest and (self.rc.autocall < 2): |
|
2024 | if not theRest and (self.rc.autocall < 2): | |
2048 | newcmd = '%s %s' % (iFun,theRest) |
|
2025 | newcmd = '%s %s' % (iFun,theRest) | |
2049 | auto_rewrite = False |
|
2026 | auto_rewrite = False | |
2050 | else: |
|
2027 | else: | |
2051 | if theRest.startswith('['): |
|
2028 | if theRest.startswith('['): | |
2052 | if hasattr(obj,'__getitem__'): |
|
2029 | if hasattr(obj,'__getitem__'): | |
2053 | # Don't autocall in this case: item access for an object |
|
2030 | # Don't autocall in this case: item access for an object | |
2054 | # which is BOTH callable and implements __getitem__. |
|
2031 | # which is BOTH callable and implements __getitem__. | |
2055 | newcmd = '%s %s' % (iFun,theRest) |
|
2032 | newcmd = '%s %s' % (iFun,theRest) | |
2056 | auto_rewrite = False |
|
2033 | auto_rewrite = False | |
2057 | else: |
|
2034 | else: | |
2058 | # if the object doesn't support [] access, go ahead and |
|
2035 | # if the object doesn't support [] access, go ahead and | |
2059 | # autocall |
|
2036 | # autocall | |
2060 | newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split())) |
|
2037 | newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split())) | |
2061 | elif theRest.endswith(';'): |
|
2038 | elif theRest.endswith(';'): | |
2062 | newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1]) |
|
2039 | newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1]) | |
2063 | else: |
|
2040 | else: | |
2064 | newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split())) |
|
2041 | newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split())) | |
2065 |
|
2042 | |||
2066 | if auto_rewrite: |
|
2043 | if auto_rewrite: | |
2067 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd |
|
2044 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd | |
2068 | # log what is now valid Python, not the actual user input (without the |
|
2045 | # log what is now valid Python, not the actual user input (without the | |
2069 | # final newline) |
|
2046 | # final newline) | |
2070 | self.log(newcmd,continue_prompt) |
|
2047 | self.log(newcmd,continue_prompt) | |
2071 | return newcmd |
|
2048 | return newcmd | |
2072 |
|
2049 | |||
2073 | def handle_help(self, line, continue_prompt=None, |
|
2050 | def handle_help(self, line, continue_prompt=None, | |
2074 | pre=None,iFun=None,theRest=None): |
|
2051 | pre=None,iFun=None,theRest=None): | |
2075 | """Try to get some help for the object. |
|
2052 | """Try to get some help for the object. | |
2076 |
|
2053 | |||
2077 | obj? or ?obj -> basic information. |
|
2054 | obj? or ?obj -> basic information. | |
2078 | obj?? or ??obj -> more details. |
|
2055 | obj?? or ??obj -> more details. | |
2079 | """ |
|
2056 | """ | |
2080 |
|
2057 | |||
2081 | # We need to make sure that we don't process lines which would be |
|
2058 | # We need to make sure that we don't process lines which would be | |
2082 | # otherwise valid python, such as "x=1 # what?" |
|
2059 | # otherwise valid python, such as "x=1 # what?" | |
2083 | try: |
|
2060 | try: | |
2084 | codeop.compile_command(line) |
|
2061 | codeop.compile_command(line) | |
2085 | except SyntaxError: |
|
2062 | except SyntaxError: | |
2086 | # We should only handle as help stuff which is NOT valid syntax |
|
2063 | # We should only handle as help stuff which is NOT valid syntax | |
2087 | if line[0]==self.ESC_HELP: |
|
2064 | if line[0]==self.ESC_HELP: | |
2088 | line = line[1:] |
|
2065 | line = line[1:] | |
2089 | elif line[-1]==self.ESC_HELP: |
|
2066 | elif line[-1]==self.ESC_HELP: | |
2090 | line = line[:-1] |
|
2067 | line = line[:-1] | |
2091 | self.log('#?'+line) |
|
2068 | self.log('#?'+line) | |
2092 | if line: |
|
2069 | if line: | |
2093 | self.magic_pinfo(line) |
|
2070 | self.magic_pinfo(line) | |
2094 | else: |
|
2071 | else: | |
2095 | page(self.usage,screen_lines=self.rc.screen_length) |
|
2072 | page(self.usage,screen_lines=self.rc.screen_length) | |
2096 | return '' # Empty string is needed here! |
|
2073 | return '' # Empty string is needed here! | |
2097 | except: |
|
2074 | except: | |
2098 | # Pass any other exceptions through to the normal handler |
|
2075 | # Pass any other exceptions through to the normal handler | |
2099 | return self.handle_normal(line,continue_prompt) |
|
2076 | return self.handle_normal(line,continue_prompt) | |
2100 | else: |
|
2077 | else: | |
2101 | # If the code compiles ok, we should handle it normally |
|
2078 | # If the code compiles ok, we should handle it normally | |
2102 | return self.handle_normal(line,continue_prompt) |
|
2079 | return self.handle_normal(line,continue_prompt) | |
2103 |
|
2080 | |||
2104 | def getapi(self): |
|
2081 | def getapi(self): | |
2105 | """ Get an IPApi object for this shell instance |
|
2082 | """ Get an IPApi object for this shell instance | |
2106 |
|
2083 | |||
2107 | Getting an IPApi object is always preferable to accessing the shell |
|
2084 | Getting an IPApi object is always preferable to accessing the shell | |
2108 | directly, but this holds true especially for extensions. |
|
2085 | directly, but this holds true especially for extensions. | |
2109 |
|
2086 | |||
2110 | It should always be possible to implement an extension with IPApi |
|
2087 | It should always be possible to implement an extension with IPApi | |
2111 | alone. If not, contact maintainer to request an addition. |
|
2088 | alone. If not, contact maintainer to request an addition. | |
2112 |
|
2089 | |||
2113 | """ |
|
2090 | """ | |
2114 | return self.api |
|
2091 | return self.api | |
2115 |
|
2092 | |||
2116 | def handle_emacs(self,line,continue_prompt=None, |
|
2093 | def handle_emacs(self,line,continue_prompt=None, | |
2117 | pre=None,iFun=None,theRest=None): |
|
2094 | pre=None,iFun=None,theRest=None): | |
2118 | """Handle input lines marked by python-mode.""" |
|
2095 | """Handle input lines marked by python-mode.""" | |
2119 |
|
2096 | |||
2120 | # Currently, nothing is done. Later more functionality can be added |
|
2097 | # Currently, nothing is done. Later more functionality can be added | |
2121 | # here if needed. |
|
2098 | # here if needed. | |
2122 |
|
2099 | |||
2123 | # The input cache shouldn't be updated |
|
2100 | # The input cache shouldn't be updated | |
2124 |
|
2101 | |||
2125 | return line |
|
2102 | return line | |
2126 |
|
2103 | |||
2127 | def mktempfile(self,data=None): |
|
2104 | def mktempfile(self,data=None): | |
2128 | """Make a new tempfile and return its filename. |
|
2105 | """Make a new tempfile and return its filename. | |
2129 |
|
2106 | |||
2130 | This makes a call to tempfile.mktemp, but it registers the created |
|
2107 | This makes a call to tempfile.mktemp, but it registers the created | |
2131 | filename internally so ipython cleans it up at exit time. |
|
2108 | filename internally so ipython cleans it up at exit time. | |
2132 |
|
2109 | |||
2133 | Optional inputs: |
|
2110 | Optional inputs: | |
2134 |
|
2111 | |||
2135 | - data(None): if data is given, it gets written out to the temp file |
|
2112 | - data(None): if data is given, it gets written out to the temp file | |
2136 | immediately, and the file is closed again.""" |
|
2113 | immediately, and the file is closed again.""" | |
2137 |
|
2114 | |||
2138 | filename = tempfile.mktemp('.py','ipython_edit_') |
|
2115 | filename = tempfile.mktemp('.py','ipython_edit_') | |
2139 | self.tempfiles.append(filename) |
|
2116 | self.tempfiles.append(filename) | |
2140 |
|
2117 | |||
2141 | if data: |
|
2118 | if data: | |
2142 | tmp_file = open(filename,'w') |
|
2119 | tmp_file = open(filename,'w') | |
2143 | tmp_file.write(data) |
|
2120 | tmp_file.write(data) | |
2144 | tmp_file.close() |
|
2121 | tmp_file.close() | |
2145 | return filename |
|
2122 | return filename | |
2146 |
|
2123 | |||
2147 | def write(self,data): |
|
2124 | def write(self,data): | |
2148 | """Write a string to the default output""" |
|
2125 | """Write a string to the default output""" | |
2149 | Term.cout.write(data) |
|
2126 | Term.cout.write(data) | |
2150 |
|
2127 | |||
2151 | def write_err(self,data): |
|
2128 | def write_err(self,data): | |
2152 | """Write a string to the default error output""" |
|
2129 | """Write a string to the default error output""" | |
2153 | Term.cerr.write(data) |
|
2130 | Term.cerr.write(data) | |
2154 |
|
2131 | |||
2155 | def exit(self): |
|
2132 | def exit(self): | |
2156 | """Handle interactive exit. |
|
2133 | """Handle interactive exit. | |
2157 |
|
2134 | |||
2158 | This method sets the exit_now attribute.""" |
|
2135 | This method sets the exit_now attribute.""" | |
2159 |
|
2136 | |||
2160 | if self.rc.confirm_exit: |
|
2137 | if self.rc.confirm_exit: | |
2161 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): |
|
2138 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): | |
2162 | self.exit_now = True |
|
2139 | self.exit_now = True | |
2163 | else: |
|
2140 | else: | |
2164 | self.exit_now = True |
|
2141 | self.exit_now = True | |
2165 | return self.exit_now |
|
2142 | return self.exit_now | |
2166 |
|
2143 | |||
2167 | def safe_execfile(self,fname,*where,**kw): |
|
2144 | def safe_execfile(self,fname,*where,**kw): | |
2168 | fname = os.path.expanduser(fname) |
|
2145 | fname = os.path.expanduser(fname) | |
2169 |
|
2146 | |||
2170 | # find things also in current directory |
|
2147 | # find things also in current directory | |
2171 | dname = os.path.dirname(fname) |
|
2148 | dname = os.path.dirname(fname) | |
2172 | if not sys.path.count(dname): |
|
2149 | if not sys.path.count(dname): | |
2173 | sys.path.append(dname) |
|
2150 | sys.path.append(dname) | |
2174 |
|
2151 | |||
2175 | try: |
|
2152 | try: | |
2176 | xfile = open(fname) |
|
2153 | xfile = open(fname) | |
2177 | except: |
|
2154 | except: | |
2178 | print >> Term.cerr, \ |
|
2155 | print >> Term.cerr, \ | |
2179 | 'Could not open file <%s> for safe execution.' % fname |
|
2156 | 'Could not open file <%s> for safe execution.' % fname | |
2180 | return None |
|
2157 | return None | |
2181 |
|
2158 | |||
2182 | kw.setdefault('islog',0) |
|
2159 | kw.setdefault('islog',0) | |
2183 | kw.setdefault('quiet',1) |
|
2160 | kw.setdefault('quiet',1) | |
2184 | kw.setdefault('exit_ignore',0) |
|
2161 | kw.setdefault('exit_ignore',0) | |
2185 | first = xfile.readline() |
|
2162 | first = xfile.readline() | |
2186 | loghead = str(self.loghead_tpl).split('\n',1)[0].strip() |
|
2163 | loghead = str(self.loghead_tpl).split('\n',1)[0].strip() | |
2187 | xfile.close() |
|
2164 | xfile.close() | |
2188 | # line by line execution |
|
2165 | # line by line execution | |
2189 | if first.startswith(loghead) or kw['islog']: |
|
2166 | if first.startswith(loghead) or kw['islog']: | |
2190 | print 'Loading log file <%s> one line at a time...' % fname |
|
2167 | print 'Loading log file <%s> one line at a time...' % fname | |
2191 | if kw['quiet']: |
|
2168 | if kw['quiet']: | |
2192 | stdout_save = sys.stdout |
|
2169 | stdout_save = sys.stdout | |
2193 | sys.stdout = StringIO.StringIO() |
|
2170 | sys.stdout = StringIO.StringIO() | |
2194 | try: |
|
2171 | try: | |
2195 | globs,locs = where[0:2] |
|
2172 | globs,locs = where[0:2] | |
2196 | except: |
|
2173 | except: | |
2197 | try: |
|
2174 | try: | |
2198 | globs = locs = where[0] |
|
2175 | globs = locs = where[0] | |
2199 | except: |
|
2176 | except: | |
2200 | globs = locs = globals() |
|
2177 | globs = locs = globals() | |
2201 | badblocks = [] |
|
2178 | badblocks = [] | |
2202 |
|
2179 | |||
2203 | # we also need to identify indented blocks of code when replaying |
|
2180 | # we also need to identify indented blocks of code when replaying | |
2204 | # logs and put them together before passing them to an exec |
|
2181 | # logs and put them together before passing them to an exec | |
2205 | # statement. This takes a bit of regexp and look-ahead work in the |
|
2182 | # statement. This takes a bit of regexp and look-ahead work in the | |
2206 | # file. It's easiest if we swallow the whole thing in memory |
|
2183 | # file. It's easiest if we swallow the whole thing in memory | |
2207 | # first, and manually walk through the lines list moving the |
|
2184 | # first, and manually walk through the lines list moving the | |
2208 | # counter ourselves. |
|
2185 | # counter ourselves. | |
2209 | indent_re = re.compile('\s+\S') |
|
2186 | indent_re = re.compile('\s+\S') | |
2210 | xfile = open(fname) |
|
2187 | xfile = open(fname) | |
2211 | filelines = xfile.readlines() |
|
2188 | filelines = xfile.readlines() | |
2212 | xfile.close() |
|
2189 | xfile.close() | |
2213 | nlines = len(filelines) |
|
2190 | nlines = len(filelines) | |
2214 | lnum = 0 |
|
2191 | lnum = 0 | |
2215 | while lnum < nlines: |
|
2192 | while lnum < nlines: | |
2216 | line = filelines[lnum] |
|
2193 | line = filelines[lnum] | |
2217 | lnum += 1 |
|
2194 | lnum += 1 | |
2218 | # don't re-insert logger status info into cache |
|
2195 | # don't re-insert logger status info into cache | |
2219 | if line.startswith('#log#'): |
|
2196 | if line.startswith('#log#'): | |
2220 | continue |
|
2197 | continue | |
2221 | else: |
|
2198 | else: | |
2222 | # build a block of code (maybe a single line) for execution |
|
2199 | # build a block of code (maybe a single line) for execution | |
2223 | block = line |
|
2200 | block = line | |
2224 | try: |
|
2201 | try: | |
2225 | next = filelines[lnum] # lnum has already incremented |
|
2202 | next = filelines[lnum] # lnum has already incremented | |
2226 | except: |
|
2203 | except: | |
2227 | next = None |
|
2204 | next = None | |
2228 | while next and indent_re.match(next): |
|
2205 | while next and indent_re.match(next): | |
2229 | block += next |
|
2206 | block += next | |
2230 | lnum += 1 |
|
2207 | lnum += 1 | |
2231 | try: |
|
2208 | try: | |
2232 | next = filelines[lnum] |
|
2209 | next = filelines[lnum] | |
2233 | except: |
|
2210 | except: | |
2234 | next = None |
|
2211 | next = None | |
2235 | # now execute the block of one or more lines |
|
2212 | # now execute the block of one or more lines | |
2236 | try: |
|
2213 | try: | |
2237 | exec block in globs,locs |
|
2214 | exec block in globs,locs | |
2238 | except SystemExit: |
|
2215 | except SystemExit: | |
2239 | pass |
|
2216 | pass | |
2240 | except: |
|
2217 | except: | |
2241 | badblocks.append(block.rstrip()) |
|
2218 | badblocks.append(block.rstrip()) | |
2242 | if kw['quiet']: # restore stdout |
|
2219 | if kw['quiet']: # restore stdout | |
2243 | sys.stdout.close() |
|
2220 | sys.stdout.close() | |
2244 | sys.stdout = stdout_save |
|
2221 | sys.stdout = stdout_save | |
2245 | print 'Finished replaying log file <%s>' % fname |
|
2222 | print 'Finished replaying log file <%s>' % fname | |
2246 | if badblocks: |
|
2223 | if badblocks: | |
2247 | print >> sys.stderr, ('\nThe following lines/blocks in file ' |
|
2224 | print >> sys.stderr, ('\nThe following lines/blocks in file ' | |
2248 | '<%s> reported errors:' % fname) |
|
2225 | '<%s> reported errors:' % fname) | |
2249 |
|
2226 | |||
2250 | for badline in badblocks: |
|
2227 | for badline in badblocks: | |
2251 | print >> sys.stderr, badline |
|
2228 | print >> sys.stderr, badline | |
2252 | else: # regular file execution |
|
2229 | else: # regular file execution | |
2253 | try: |
|
2230 | try: | |
2254 | execfile(fname,*where) |
|
2231 | execfile(fname,*where) | |
2255 | except SyntaxError: |
|
2232 | except SyntaxError: | |
2256 | etype,evalue = sys.exc_info()[:2] |
|
2233 | etype,evalue = sys.exc_info()[:2] | |
2257 | self.SyntaxTB(etype,evalue,[]) |
|
2234 | self.SyntaxTB(etype,evalue,[]) | |
2258 | warn('Failure executing file: <%s>' % fname) |
|
2235 | warn('Failure executing file: <%s>' % fname) | |
2259 | except SystemExit,status: |
|
2236 | except SystemExit,status: | |
2260 | if not kw['exit_ignore']: |
|
2237 | if not kw['exit_ignore']: | |
2261 | self.InteractiveTB() |
|
2238 | self.InteractiveTB() | |
2262 | warn('Failure executing file: <%s>' % fname) |
|
2239 | warn('Failure executing file: <%s>' % fname) | |
2263 | except: |
|
2240 | except: | |
2264 | self.InteractiveTB() |
|
2241 | self.InteractiveTB() | |
2265 | warn('Failure executing file: <%s>' % fname) |
|
2242 | warn('Failure executing file: <%s>' % fname) | |
2266 |
|
2243 | |||
2267 | #************************* end of file <iplib.py> ***************************** |
|
2244 | #************************* end of file <iplib.py> ***************************** |
@@ -1,5126 +1,5139 b'' | |||||
|
1 | 2006-01-30 Ville Vainio <vivainio@gmail.com> | |||
|
2 | ||||
|
3 | * pickleshare,pspersistence,ipapi,Magic: persistence overhaul. | |||
|
4 | Now %store and bookmarks work through PickleShare, meaning that | |||
|
5 | concurrent access is possible and all ipython sessions see the | |||
|
6 | same database situation all the time, instead of snapshot of | |||
|
7 | the situation when the session was started. Hence, %bookmark | |||
|
8 | results are immediately accessible from othes sessions. The database | |||
|
9 | is also available for use by user extensions. See: | |||
|
10 | http://www.python.org/pypi/pickleshare | |||
|
11 | ||||
|
12 | * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'. | |||
|
13 | ||||
1 | 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
14 | 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
15 | |||
3 | * IPython/iplib.py (interact): Fix that we were not catching |
|
16 | * IPython/iplib.py (interact): Fix that we were not catching | |
4 | KeyboardInterrupt exceptions properly. I'm not quite sure why the |
|
17 | KeyboardInterrupt exceptions properly. I'm not quite sure why the | |
5 | logic here had to change, but it's fixed now. |
|
18 | logic here had to change, but it's fixed now. | |
6 |
|
19 | |||
7 | 2006-01-29 Ville Vainio <vivainio@gmail.com> |
|
20 | 2006-01-29 Ville Vainio <vivainio@gmail.com> | |
8 |
|
21 | |||
9 | * iplib.py: Try to import pyreadline on Windows. |
|
22 | * iplib.py: Try to import pyreadline on Windows. | |
10 |
|
23 | |||
11 | 2006-01-27 Ville Vainio <vivainio@gmail.com> |
|
24 | 2006-01-27 Ville Vainio <vivainio@gmail.com> | |
12 |
|
25 | |||
13 | * iplib.py: Expose ipapi as _ip in builtin namespace. |
|
26 | * iplib.py: Expose ipapi as _ip in builtin namespace. | |
14 | Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system) |
|
27 | Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system) | |
15 | and ip_set_hook (-> _ip.set_hook) redundant. % and ! |
|
28 | and ip_set_hook (-> _ip.set_hook) redundant. % and ! | |
16 | syntax now produce _ip.* variant of the commands. |
|
29 | syntax now produce _ip.* variant of the commands. | |
17 |
|
30 | |||
18 | * "_ip.options().autoedit_syntax = 2" automatically throws |
|
31 | * "_ip.options().autoedit_syntax = 2" automatically throws | |
19 | user to editor for syntax error correction without prompting. |
|
32 | user to editor for syntax error correction without prompting. | |
20 |
|
33 | |||
21 | 2006-01-27 Ville Vainio <vivainio@gmail.com> |
|
34 | 2006-01-27 Ville Vainio <vivainio@gmail.com> | |
22 |
|
35 | |||
23 | * ipmaker.py: Give "realistic" sys.argv for scripts (without |
|
36 | * ipmaker.py: Give "realistic" sys.argv for scripts (without | |
24 | 'ipython' at argv[0]) executed through command line. |
|
37 | 'ipython' at argv[0]) executed through command line. | |
25 | NOTE: this DEPRECATES calling ipython with multiple scripts |
|
38 | NOTE: this DEPRECATES calling ipython with multiple scripts | |
26 | ("ipython a.py b.py c.py") |
|
39 | ("ipython a.py b.py c.py") | |
27 |
|
40 | |||
28 | * iplib.py, hooks.py: Added configurable input prefilter, |
|
41 | * iplib.py, hooks.py: Added configurable input prefilter, | |
29 | named 'input_prefilter'. See ext_rescapture.py for example |
|
42 | named 'input_prefilter'. See ext_rescapture.py for example | |
30 | usage. |
|
43 | usage. | |
31 |
|
44 | |||
32 | * ext_rescapture.py, Magic.py: Better system command output capture |
|
45 | * ext_rescapture.py, Magic.py: Better system command output capture | |
33 | through 'var = !ls' (deprecates user-visible %sc). Same notation |
|
46 | through 'var = !ls' (deprecates user-visible %sc). Same notation | |
34 | applies for magics, 'var = %alias' assigns alias list to var. |
|
47 | applies for magics, 'var = %alias' assigns alias list to var. | |
35 |
|
48 | |||
36 | * ipapi.py: added meta() for accessing extension-usable data store. |
|
49 | * ipapi.py: added meta() for accessing extension-usable data store. | |
37 |
|
50 | |||
38 | * iplib.py: added InteractiveShell.getapi(). New magics should be |
|
51 | * iplib.py: added InteractiveShell.getapi(). New magics should be | |
39 | written doing self.getapi() instead of using the shell directly. |
|
52 | written doing self.getapi() instead of using the shell directly. | |
40 |
|
53 | |||
41 | * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and |
|
54 | * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and | |
42 | %store foo >> ~/myfoo.txt to store variables to files (in clean |
|
55 | %store foo >> ~/myfoo.txt to store variables to files (in clean | |
43 | textual form, not a restorable pickle). |
|
56 | textual form, not a restorable pickle). | |
44 |
|
57 | |||
45 | * ipmaker.py: now import ipy_profile_PROFILENAME automatically |
|
58 | * ipmaker.py: now import ipy_profile_PROFILENAME automatically | |
46 |
|
59 | |||
47 | * usage.py, Magic.py: added %quickref |
|
60 | * usage.py, Magic.py: added %quickref | |
48 |
|
61 | |||
49 | * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2). |
|
62 | * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2). | |
50 |
|
63 | |||
51 | * GetoptErrors when invoking magics etc. with wrong args |
|
64 | * GetoptErrors when invoking magics etc. with wrong args | |
52 | are now more helpful: |
|
65 | are now more helpful: | |
53 | GetoptError: option -l not recognized (allowed: "qb" ) |
|
66 | GetoptError: option -l not recognized (allowed: "qb" ) | |
54 |
|
67 | |||
55 | 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
68 | 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu> | |
56 |
|
69 | |||
57 | * IPython/demo.py (Demo.show): Flush stdout after each block, so |
|
70 | * IPython/demo.py (Demo.show): Flush stdout after each block, so | |
58 | computationally intensive blocks don't appear to stall the demo. |
|
71 | computationally intensive blocks don't appear to stall the demo. | |
59 |
|
72 | |||
60 | 2006-01-24 Ville Vainio <vivainio@gmail.com> |
|
73 | 2006-01-24 Ville Vainio <vivainio@gmail.com> | |
61 |
|
74 | |||
62 | * iplib.py, hooks.py: 'result_display' hook can return a non-None |
|
75 | * iplib.py, hooks.py: 'result_display' hook can return a non-None | |
63 | value to manipulate resulting history entry. |
|
76 | value to manipulate resulting history entry. | |
64 |
|
77 | |||
65 | * ipapi.py: Moved TryNext here from hooks.py. Moved functions |
|
78 | * ipapi.py: Moved TryNext here from hooks.py. Moved functions | |
66 | to instance methods of IPApi class, to make extending an embedded |
|
79 | to instance methods of IPApi class, to make extending an embedded | |
67 | IPython feasible. See ext_rehashdir.py for example usage. |
|
80 | IPython feasible. See ext_rehashdir.py for example usage. | |
68 |
|
81 | |||
69 | * Merged 1071-1076 from banches/0.7.1 |
|
82 | * Merged 1071-1076 from banches/0.7.1 | |
70 |
|
83 | |||
71 |
|
84 | |||
72 | 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
85 | 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
73 |
|
86 | |||
74 | * tools/release (daystamp): Fix build tools to use the new |
|
87 | * tools/release (daystamp): Fix build tools to use the new | |
75 | eggsetup.py script to build lightweight eggs. |
|
88 | eggsetup.py script to build lightweight eggs. | |
76 |
|
89 | |||
77 | * Applied changesets 1062 and 1064 before 0.7.1 release. |
|
90 | * Applied changesets 1062 and 1064 before 0.7.1 release. | |
78 |
|
91 | |||
79 | * IPython/Magic.py (magic_history): Add '-r' option to %hist, to |
|
92 | * IPython/Magic.py (magic_history): Add '-r' option to %hist, to | |
80 | see the raw input history (without conversions like %ls -> |
|
93 | see the raw input history (without conversions like %ls -> | |
81 | ipmagic("ls")). After a request from W. Stein, SAGE |
|
94 | ipmagic("ls")). After a request from W. Stein, SAGE | |
82 | (http://modular.ucsd.edu/sage) developer. This information is |
|
95 | (http://modular.ucsd.edu/sage) developer. This information is | |
83 | stored in the input_hist_raw attribute of the IPython instance, so |
|
96 | stored in the input_hist_raw attribute of the IPython instance, so | |
84 | developers can access it if needed (it's an InputList instance). |
|
97 | developers can access it if needed (it's an InputList instance). | |
85 |
|
98 | |||
86 | * Versionstring = 0.7.2.svn |
|
99 | * Versionstring = 0.7.2.svn | |
87 |
|
100 | |||
88 | * eggsetup.py: A separate script for constructing eggs, creates |
|
101 | * eggsetup.py: A separate script for constructing eggs, creates | |
89 | proper launch scripts even on Windows (an .exe file in |
|
102 | proper launch scripts even on Windows (an .exe file in | |
90 | \python24\scripts). |
|
103 | \python24\scripts). | |
91 |
|
104 | |||
92 | * ipapi.py: launch_new_instance, launch entry point needed for the |
|
105 | * ipapi.py: launch_new_instance, launch entry point needed for the | |
93 | egg. |
|
106 | egg. | |
94 |
|
107 | |||
95 | 2006-01-23 Ville Vainio <vivainio@gmail.com> |
|
108 | 2006-01-23 Ville Vainio <vivainio@gmail.com> | |
96 |
|
109 | |||
97 | * Added %cpaste magic for pasting python code |
|
110 | * Added %cpaste magic for pasting python code | |
98 |
|
111 | |||
99 | 2006-01-22 Ville Vainio <vivainio@gmail.com> |
|
112 | 2006-01-22 Ville Vainio <vivainio@gmail.com> | |
100 |
|
113 | |||
101 | * Merge from branches/0.7.1 into trunk, revs 1052-1057 |
|
114 | * Merge from branches/0.7.1 into trunk, revs 1052-1057 | |
102 |
|
115 | |||
103 | * Versionstring = 0.7.2.svn |
|
116 | * Versionstring = 0.7.2.svn | |
104 |
|
117 | |||
105 | * eggsetup.py: A separate script for constructing eggs, creates |
|
118 | * eggsetup.py: A separate script for constructing eggs, creates | |
106 | proper launch scripts even on Windows (an .exe file in |
|
119 | proper launch scripts even on Windows (an .exe file in | |
107 | \python24\scripts). |
|
120 | \python24\scripts). | |
108 |
|
121 | |||
109 | * ipapi.py: launch_new_instance, launch entry point needed for the |
|
122 | * ipapi.py: launch_new_instance, launch entry point needed for the | |
110 | egg. |
|
123 | egg. | |
111 |
|
124 | |||
112 | 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
125 | 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu> | |
113 |
|
126 | |||
114 | * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or |
|
127 | * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or | |
115 | %pfile foo would print the file for foo even if it was a binary. |
|
128 | %pfile foo would print the file for foo even if it was a binary. | |
116 | Now, extensions '.so' and '.dll' are skipped. |
|
129 | Now, extensions '.so' and '.dll' are skipped. | |
117 |
|
130 | |||
118 | * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading |
|
131 | * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading | |
119 | bug, where macros would fail in all threaded modes. I'm not 100% |
|
132 | bug, where macros would fail in all threaded modes. I'm not 100% | |
120 | sure, so I'm going to put out an rc instead of making a release |
|
133 | sure, so I'm going to put out an rc instead of making a release | |
121 | today, and wait for feedback for at least a few days. |
|
134 | today, and wait for feedback for at least a few days. | |
122 |
|
135 | |||
123 | * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt |
|
136 | * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt | |
124 | it...) the handling of pasting external code with autoindent on. |
|
137 | it...) the handling of pasting external code with autoindent on. | |
125 | To get out of a multiline input, the rule will appear for most |
|
138 | To get out of a multiline input, the rule will appear for most | |
126 | users unchanged: two blank lines or change the indent level |
|
139 | users unchanged: two blank lines or change the indent level | |
127 | proposed by IPython. But there is a twist now: you can |
|
140 | proposed by IPython. But there is a twist now: you can | |
128 | add/subtract only *one or two spaces*. If you add/subtract three |
|
141 | add/subtract only *one or two spaces*. If you add/subtract three | |
129 | or more (unless you completely delete the line), IPython will |
|
142 | or more (unless you completely delete the line), IPython will | |
130 | accept that line, and you'll need to enter a second one of pure |
|
143 | accept that line, and you'll need to enter a second one of pure | |
131 | whitespace. I know it sounds complicated, but I can't find a |
|
144 | whitespace. I know it sounds complicated, but I can't find a | |
132 | different solution that covers all the cases, with the right |
|
145 | different solution that covers all the cases, with the right | |
133 | heuristics. Hopefully in actual use, nobody will really notice |
|
146 | heuristics. Hopefully in actual use, nobody will really notice | |
134 | all these strange rules and things will 'just work'. |
|
147 | all these strange rules and things will 'just work'. | |
135 |
|
148 | |||
136 | 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu> |
|
149 | 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu> | |
137 |
|
150 | |||
138 | * IPython/iplib.py (interact): catch exceptions which can be |
|
151 | * IPython/iplib.py (interact): catch exceptions which can be | |
139 | triggered asynchronously by signal handlers. Thanks to an |
|
152 | triggered asynchronously by signal handlers. Thanks to an | |
140 | automatic crash report, submitted by Colin Kingsley |
|
153 | automatic crash report, submitted by Colin Kingsley | |
141 | <tercel-AT-gentoo.org>. |
|
154 | <tercel-AT-gentoo.org>. | |
142 |
|
155 | |||
143 | 2006-01-20 Ville Vainio <vivainio@gmail.com> |
|
156 | 2006-01-20 Ville Vainio <vivainio@gmail.com> | |
144 |
|
157 | |||
145 | * Ipython/Extensions/ext_rehashdir.py: Created a usable example |
|
158 | * Ipython/Extensions/ext_rehashdir.py: Created a usable example | |
146 | (%rehashdir, very useful, try it out) of how to extend ipython |
|
159 | (%rehashdir, very useful, try it out) of how to extend ipython | |
147 | with new magics. Also added Extensions dir to pythonpath to make |
|
160 | with new magics. Also added Extensions dir to pythonpath to make | |
148 | importing extensions easy. |
|
161 | importing extensions easy. | |
149 |
|
162 | |||
150 | * %store now complains when trying to store interactively declared |
|
163 | * %store now complains when trying to store interactively declared | |
151 | classes / instances of those classes. |
|
164 | classes / instances of those classes. | |
152 |
|
165 | |||
153 | * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py, |
|
166 | * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py, | |
154 | ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported |
|
167 | ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported | |
155 | if they exist, and ipy_user_conf.py with some defaults is created for |
|
168 | if they exist, and ipy_user_conf.py with some defaults is created for | |
156 | the user. |
|
169 | the user. | |
157 |
|
170 | |||
158 | * Startup rehashing done by the config file, not InterpreterExec. |
|
171 | * Startup rehashing done by the config file, not InterpreterExec. | |
159 | This means system commands are available even without selecting the |
|
172 | This means system commands are available even without selecting the | |
160 | pysh profile. It's the sensible default after all. |
|
173 | pysh profile. It's the sensible default after all. | |
161 |
|
174 | |||
162 | 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
175 | 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu> | |
163 |
|
176 | |||
164 | * IPython/iplib.py (raw_input): I _think_ I got the pasting of |
|
177 | * IPython/iplib.py (raw_input): I _think_ I got the pasting of | |
165 | multiline code with autoindent on working. But I am really not |
|
178 | multiline code with autoindent on working. But I am really not | |
166 | sure, so this needs more testing. Will commit a debug-enabled |
|
179 | sure, so this needs more testing. Will commit a debug-enabled | |
167 | version for now, while I test it some more, so that Ville and |
|
180 | version for now, while I test it some more, so that Ville and | |
168 | others may also catch any problems. Also made |
|
181 | others may also catch any problems. Also made | |
169 | self.indent_current_str() a method, to ensure that there's no |
|
182 | self.indent_current_str() a method, to ensure that there's no | |
170 | chance of the indent space count and the corresponding string |
|
183 | chance of the indent space count and the corresponding string | |
171 | falling out of sync. All code needing the string should just call |
|
184 | falling out of sync. All code needing the string should just call | |
172 | the method. |
|
185 | the method. | |
173 |
|
186 | |||
174 | 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
187 | 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu> | |
175 |
|
188 | |||
176 | * IPython/Magic.py (magic_edit): fix check for when users don't |
|
189 | * IPython/Magic.py (magic_edit): fix check for when users don't | |
177 | save their output files, the try/except was in the wrong section. |
|
190 | save their output files, the try/except was in the wrong section. | |
178 |
|
191 | |||
179 | 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu> |
|
192 | 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu> | |
180 |
|
193 | |||
181 | * IPython/Magic.py (magic_run): fix __file__ global missing from |
|
194 | * IPython/Magic.py (magic_run): fix __file__ global missing from | |
182 | script's namespace when executed via %run. After a report by |
|
195 | script's namespace when executed via %run. After a report by | |
183 | Vivian. |
|
196 | Vivian. | |
184 |
|
197 | |||
185 | * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d' |
|
198 | * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d' | |
186 | when using python 2.4. The parent constructor changed in 2.4, and |
|
199 | when using python 2.4. The parent constructor changed in 2.4, and | |
187 | we need to track it directly (we can't call it, as it messes up |
|
200 | we need to track it directly (we can't call it, as it messes up | |
188 | readline and tab-completion inside our pdb would stop working). |
|
201 | readline and tab-completion inside our pdb would stop working). | |
189 | After a bug report by R. Bernstein <rocky-AT-panix.com>. |
|
202 | After a bug report by R. Bernstein <rocky-AT-panix.com>. | |
190 |
|
203 | |||
191 | 2006-01-16 Ville Vainio <vivainio@gmail.com> |
|
204 | 2006-01-16 Ville Vainio <vivainio@gmail.com> | |
192 |
|
205 | |||
193 | * Ipython/magic.py:Reverted back to old %edit functionality |
|
206 | * Ipython/magic.py:Reverted back to old %edit functionality | |
194 | that returns file contents on exit. |
|
207 | that returns file contents on exit. | |
195 |
|
208 | |||
196 | * IPython/path.py: Added Jason Orendorff's "path" module to |
|
209 | * IPython/path.py: Added Jason Orendorff's "path" module to | |
197 | IPython tree, http://www.jorendorff.com/articles/python/path/. |
|
210 | IPython tree, http://www.jorendorff.com/articles/python/path/. | |
198 | You can get path objects conveniently through %sc, and !!, e.g.: |
|
211 | You can get path objects conveniently through %sc, and !!, e.g.: | |
199 | sc files=ls |
|
212 | sc files=ls | |
200 | for p in files.paths: # or files.p |
|
213 | for p in files.paths: # or files.p | |
201 | print p,p.mtime |
|
214 | print p,p.mtime | |
202 |
|
215 | |||
203 | * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall |
|
216 | * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall | |
204 | now work again without considering the exclusion regexp - |
|
217 | now work again without considering the exclusion regexp - | |
205 | hence, things like ',foo my/path' turn to 'foo("my/path")' |
|
218 | hence, things like ',foo my/path' turn to 'foo("my/path")' | |
206 | instead of syntax error. |
|
219 | instead of syntax error. | |
207 |
|
220 | |||
208 |
|
221 | |||
209 | 2006-01-14 Ville Vainio <vivainio@gmail.com> |
|
222 | 2006-01-14 Ville Vainio <vivainio@gmail.com> | |
210 |
|
223 | |||
211 | * IPython/ipapi.py (ashook, asmagic, options): Added convenience |
|
224 | * IPython/ipapi.py (ashook, asmagic, options): Added convenience | |
212 | ipapi decorators for python 2.4 users, options() provides access to rc |
|
225 | ipapi decorators for python 2.4 users, options() provides access to rc | |
213 | data. |
|
226 | data. | |
214 |
|
227 | |||
215 | * IPython/Magic.py (magic_cd): %cd now accepts backslashes |
|
228 | * IPython/Magic.py (magic_cd): %cd now accepts backslashes | |
216 | as path separators (even on Linux ;-). Space character after |
|
229 | as path separators (even on Linux ;-). Space character after | |
217 | backslash (as yielded by tab completer) is still space; |
|
230 | backslash (as yielded by tab completer) is still space; | |
218 | "%cd long\ name" works as expected. |
|
231 | "%cd long\ name" works as expected. | |
219 |
|
232 | |||
220 | * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented |
|
233 | * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented | |
221 | as "chain of command", with priority. API stays the same, |
|
234 | as "chain of command", with priority. API stays the same, | |
222 | TryNext exception raised by a hook function signals that |
|
235 | TryNext exception raised by a hook function signals that | |
223 | current hook failed and next hook should try handling it, as |
|
236 | current hook failed and next hook should try handling it, as | |
224 | suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also |
|
237 | suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also | |
225 | requested configurable display hook, which is now implemented. |
|
238 | requested configurable display hook, which is now implemented. | |
226 |
|
239 | |||
227 | 2006-01-13 Ville Vainio <vivainio@gmail.com> |
|
240 | 2006-01-13 Ville Vainio <vivainio@gmail.com> | |
228 |
|
241 | |||
229 | * IPython/platutils*.py: platform specific utility functions, |
|
242 | * IPython/platutils*.py: platform specific utility functions, | |
230 | so far only set_term_title is implemented (change terminal |
|
243 | so far only set_term_title is implemented (change terminal | |
231 | label in windowing systems). %cd now changes the title to |
|
244 | label in windowing systems). %cd now changes the title to | |
232 | current dir. |
|
245 | current dir. | |
233 |
|
246 | |||
234 | * IPython/Release.py: Added myself to "authors" list, |
|
247 | * IPython/Release.py: Added myself to "authors" list, | |
235 | had to create new files. |
|
248 | had to create new files. | |
236 |
|
249 | |||
237 | * IPython/iplib.py (handle_shell_escape): fixed logical flaw in |
|
250 | * IPython/iplib.py (handle_shell_escape): fixed logical flaw in | |
238 | shell escape; not a known bug but had potential to be one in the |
|
251 | shell escape; not a known bug but had potential to be one in the | |
239 | future. |
|
252 | future. | |
240 |
|
253 | |||
241 | * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public" |
|
254 | * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public" | |
242 | extension API for IPython! See the module for usage example. Fix |
|
255 | extension API for IPython! See the module for usage example. Fix | |
243 | OInspect for docstring-less magic functions. |
|
256 | OInspect for docstring-less magic functions. | |
244 |
|
257 | |||
245 |
|
258 | |||
246 | 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
259 | 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu> | |
247 |
|
260 | |||
248 | * IPython/iplib.py (raw_input): temporarily deactivate all |
|
261 | * IPython/iplib.py (raw_input): temporarily deactivate all | |
249 | attempts at allowing pasting of code with autoindent on. It |
|
262 | attempts at allowing pasting of code with autoindent on. It | |
250 | introduced bugs (reported by Prabhu) and I can't seem to find a |
|
263 | introduced bugs (reported by Prabhu) and I can't seem to find a | |
251 | robust combination which works in all cases. Will have to revisit |
|
264 | robust combination which works in all cases. Will have to revisit | |
252 | later. |
|
265 | later. | |
253 |
|
266 | |||
254 | * IPython/genutils.py: remove isspace() function. We've dropped |
|
267 | * IPython/genutils.py: remove isspace() function. We've dropped | |
255 | 2.2 compatibility, so it's OK to use the string method. |
|
268 | 2.2 compatibility, so it's OK to use the string method. | |
256 |
|
269 | |||
257 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
270 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
258 |
|
271 | |||
259 | * IPython/iplib.py (InteractiveShell.__init__): fix regexp |
|
272 | * IPython/iplib.py (InteractiveShell.__init__): fix regexp | |
260 | matching what NOT to autocall on, to include all python binary |
|
273 | matching what NOT to autocall on, to include all python binary | |
261 | operators (including things like 'and', 'or', 'is' and 'in'). |
|
274 | operators (including things like 'and', 'or', 'is' and 'in'). | |
262 | Prompted by a bug report on 'foo & bar', but I realized we had |
|
275 | Prompted by a bug report on 'foo & bar', but I realized we had | |
263 | many more potential bug cases with other operators. The regexp is |
|
276 | many more potential bug cases with other operators. The regexp is | |
264 | self.re_exclude_auto, it's fairly commented. |
|
277 | self.re_exclude_auto, it's fairly commented. | |
265 |
|
278 | |||
266 | 2006-01-12 Ville Vainio <vivainio@gmail.com> |
|
279 | 2006-01-12 Ville Vainio <vivainio@gmail.com> | |
267 |
|
280 | |||
268 | * IPython/iplib.py (make_quoted_expr,handle_shell_escape): |
|
281 | * IPython/iplib.py (make_quoted_expr,handle_shell_escape): | |
269 | Prettified and hardened string/backslash quoting with ipsystem(), |
|
282 | Prettified and hardened string/backslash quoting with ipsystem(), | |
270 | ipalias() and ipmagic(). Now even \ characters are passed to |
|
283 | ipalias() and ipmagic(). Now even \ characters are passed to | |
271 | %magics, !shell escapes and aliases exactly as they are in the |
|
284 | %magics, !shell escapes and aliases exactly as they are in the | |
272 | ipython command line. Should improve backslash experience, |
|
285 | ipython command line. Should improve backslash experience, | |
273 | particularly in Windows (path delimiter for some commands that |
|
286 | particularly in Windows (path delimiter for some commands that | |
274 | won't understand '/'), but Unix benefits as well (regexps). %cd |
|
287 | won't understand '/'), but Unix benefits as well (regexps). %cd | |
275 | magic still doesn't support backslash path delimiters, though. Also |
|
288 | magic still doesn't support backslash path delimiters, though. Also | |
276 | deleted all pretense of supporting multiline command strings in |
|
289 | deleted all pretense of supporting multiline command strings in | |
277 | !system or %magic commands. Thanks to Jerry McRae for suggestions. |
|
290 | !system or %magic commands. Thanks to Jerry McRae for suggestions. | |
278 |
|
291 | |||
279 | * doc/build_doc_instructions.txt added. Documentation on how to |
|
292 | * doc/build_doc_instructions.txt added. Documentation on how to | |
280 | use doc/update_manual.py, added yesterday. Both files contributed |
|
293 | use doc/update_manual.py, added yesterday. Both files contributed | |
281 | by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates |
|
294 | by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates | |
282 | doc/*.sh for deprecation at a later date. |
|
295 | doc/*.sh for deprecation at a later date. | |
283 |
|
296 | |||
284 | * /ipython.py Added ipython.py to root directory for |
|
297 | * /ipython.py Added ipython.py to root directory for | |
285 | zero-installation (tar xzvf ipython.tgz; cd ipython; python |
|
298 | zero-installation (tar xzvf ipython.tgz; cd ipython; python | |
286 | ipython.py) and development convenience (no need to kee doing |
|
299 | ipython.py) and development convenience (no need to kee doing | |
287 | "setup.py install" between changes). |
|
300 | "setup.py install" between changes). | |
288 |
|
301 | |||
289 | * Made ! and !! shell escapes work (again) in multiline expressions: |
|
302 | * Made ! and !! shell escapes work (again) in multiline expressions: | |
290 | if 1: |
|
303 | if 1: | |
291 | !ls |
|
304 | !ls | |
292 | !!ls |
|
305 | !!ls | |
293 |
|
306 | |||
294 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
307 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
295 |
|
308 | |||
296 | * IPython/ipstruct.py (Struct): Rename IPython.Struct to |
|
309 | * IPython/ipstruct.py (Struct): Rename IPython.Struct to | |
297 | IPython.ipstruct, to avoid local shadowing of the stdlib 'struct' |
|
310 | IPython.ipstruct, to avoid local shadowing of the stdlib 'struct' | |
298 | module in case-insensitive installation. Was causing crashes |
|
311 | module in case-insensitive installation. Was causing crashes | |
299 | under win32. Closes http://www.scipy.net/roundup/ipython/issue49. |
|
312 | under win32. Closes http://www.scipy.net/roundup/ipython/issue49. | |
300 |
|
313 | |||
301 | * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart |
|
314 | * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart | |
302 | <marienz-AT-gentoo.org>, closes |
|
315 | <marienz-AT-gentoo.org>, closes | |
303 | http://www.scipy.net/roundup/ipython/issue51. |
|
316 | http://www.scipy.net/roundup/ipython/issue51. | |
304 |
|
317 | |||
305 | 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu> |
|
318 | 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu> | |
306 |
|
319 | |||
307 | * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the |
|
320 | * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the | |
308 | problem of excessive CPU usage under *nix and keyboard lag under |
|
321 | problem of excessive CPU usage under *nix and keyboard lag under | |
309 | win32. |
|
322 | win32. | |
310 |
|
323 | |||
311 | 2006-01-10 *** Released version 0.7.0 |
|
324 | 2006-01-10 *** Released version 0.7.0 | |
312 |
|
325 | |||
313 | 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu> |
|
326 | 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu> | |
314 |
|
327 | |||
315 | * IPython/Release.py (revision): tag version number to 0.7.0, |
|
328 | * IPython/Release.py (revision): tag version number to 0.7.0, | |
316 | ready for release. |
|
329 | ready for release. | |
317 |
|
330 | |||
318 | * IPython/Magic.py (magic_edit): Add print statement to %edit so |
|
331 | * IPython/Magic.py (magic_edit): Add print statement to %edit so | |
319 | it informs the user of the name of the temp. file used. This can |
|
332 | it informs the user of the name of the temp. file used. This can | |
320 | help if you decide later to reuse that same file, so you know |
|
333 | help if you decide later to reuse that same file, so you know | |
321 | where to copy the info from. |
|
334 | where to copy the info from. | |
322 |
|
335 | |||
323 | 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu> |
|
336 | 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu> | |
324 |
|
337 | |||
325 | * setup_bdist_egg.py: little script to build an egg. Added |
|
338 | * setup_bdist_egg.py: little script to build an egg. Added | |
326 | support in the release tools as well. |
|
339 | support in the release tools as well. | |
327 |
|
340 | |||
328 | 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
341 | 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu> | |
329 |
|
342 | |||
330 | * IPython/Shell.py (IPShellWX.__init__): add support for WXPython |
|
343 | * IPython/Shell.py (IPShellWX.__init__): add support for WXPython | |
331 | version selection (new -wxversion command line and ipythonrc |
|
344 | version selection (new -wxversion command line and ipythonrc | |
332 | parameter). Patch contributed by Arnd Baecker |
|
345 | parameter). Patch contributed by Arnd Baecker | |
333 | <arnd.baecker-AT-web.de>. |
|
346 | <arnd.baecker-AT-web.de>. | |
334 |
|
347 | |||
335 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
348 | * IPython/iplib.py (embed_mainloop): fix tab-completion in | |
336 | embedded instances, for variables defined at the interactive |
|
349 | embedded instances, for variables defined at the interactive | |
337 | prompt of the embedded ipython. Reported by Arnd. |
|
350 | prompt of the embedded ipython. Reported by Arnd. | |
338 |
|
351 | |||
339 | * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now |
|
352 | * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now | |
340 | it can be used as a (stateful) toggle, or with a direct parameter. |
|
353 | it can be used as a (stateful) toggle, or with a direct parameter. | |
341 |
|
354 | |||
342 | * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which |
|
355 | * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which | |
343 | could be triggered in certain cases and cause the traceback |
|
356 | could be triggered in certain cases and cause the traceback | |
344 | printer not to work. |
|
357 | printer not to work. | |
345 |
|
358 | |||
346 | 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu> |
|
359 | 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu> | |
347 |
|
360 | |||
348 | * IPython/iplib.py (_should_recompile): Small fix, closes |
|
361 | * IPython/iplib.py (_should_recompile): Small fix, closes | |
349 | http://www.scipy.net/roundup/ipython/issue48. Patch by Scott. |
|
362 | http://www.scipy.net/roundup/ipython/issue48. Patch by Scott. | |
350 |
|
363 | |||
351 | 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu> |
|
364 | 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu> | |
352 |
|
365 | |||
353 | * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK |
|
366 | * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK | |
354 | backend for matplotlib (100% cpu utiliziation). Thanks to Charlie |
|
367 | backend for matplotlib (100% cpu utiliziation). Thanks to Charlie | |
355 | Moad for help with tracking it down. |
|
368 | Moad for help with tracking it down. | |
356 |
|
369 | |||
357 | * IPython/iplib.py (handle_auto): fix autocall handling for |
|
370 | * IPython/iplib.py (handle_auto): fix autocall handling for | |
358 | objects which support BOTH __getitem__ and __call__ (so that f [x] |
|
371 | objects which support BOTH __getitem__ and __call__ (so that f [x] | |
359 | is left alone, instead of becoming f([x]) automatically). |
|
372 | is left alone, instead of becoming f([x]) automatically). | |
360 |
|
373 | |||
361 | * IPython/Magic.py (magic_cd): fix crash when cd -b was used. |
|
374 | * IPython/Magic.py (magic_cd): fix crash when cd -b was used. | |
362 | Ville's patch. |
|
375 | Ville's patch. | |
363 |
|
376 | |||
364 | 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu> |
|
377 | 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu> | |
365 |
|
378 | |||
366 | * IPython/iplib.py (handle_auto): changed autocall semantics to |
|
379 | * IPython/iplib.py (handle_auto): changed autocall semantics to | |
367 | include 'smart' mode, where the autocall transformation is NOT |
|
380 | include 'smart' mode, where the autocall transformation is NOT | |
368 | applied if there are no arguments on the line. This allows you to |
|
381 | applied if there are no arguments on the line. This allows you to | |
369 | just type 'foo' if foo is a callable to see its internal form, |
|
382 | just type 'foo' if foo is a callable to see its internal form, | |
370 | instead of having it called with no arguments (typically a |
|
383 | instead of having it called with no arguments (typically a | |
371 | mistake). The old 'full' autocall still exists: for that, you |
|
384 | mistake). The old 'full' autocall still exists: for that, you | |
372 | need to set the 'autocall' parameter to 2 in your ipythonrc file. |
|
385 | need to set the 'autocall' parameter to 2 in your ipythonrc file. | |
373 |
|
386 | |||
374 | * IPython/completer.py (Completer.attr_matches): add |
|
387 | * IPython/completer.py (Completer.attr_matches): add | |
375 | tab-completion support for Enthoughts' traits. After a report by |
|
388 | tab-completion support for Enthoughts' traits. After a report by | |
376 | Arnd and a patch by Prabhu. |
|
389 | Arnd and a patch by Prabhu. | |
377 |
|
390 | |||
378 | 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu> |
|
391 | 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu> | |
379 |
|
392 | |||
380 | * IPython/ultraTB.py (_fixed_getinnerframes): added Alex |
|
393 | * IPython/ultraTB.py (_fixed_getinnerframes): added Alex | |
381 | Schmolck's patch to fix inspect.getinnerframes(). |
|
394 | Schmolck's patch to fix inspect.getinnerframes(). | |
382 |
|
395 | |||
383 | * IPython/iplib.py (InteractiveShell.__init__): significant fixes |
|
396 | * IPython/iplib.py (InteractiveShell.__init__): significant fixes | |
384 | for embedded instances, regarding handling of namespaces and items |
|
397 | for embedded instances, regarding handling of namespaces and items | |
385 | added to the __builtin__ one. Multiple embedded instances and |
|
398 | added to the __builtin__ one. Multiple embedded instances and | |
386 | recursive embeddings should work better now (though I'm not sure |
|
399 | recursive embeddings should work better now (though I'm not sure | |
387 | I've got all the corner cases fixed, that code is a bit of a brain |
|
400 | I've got all the corner cases fixed, that code is a bit of a brain | |
388 | twister). |
|
401 | twister). | |
389 |
|
402 | |||
390 | * IPython/Magic.py (magic_edit): added support to edit in-memory |
|
403 | * IPython/Magic.py (magic_edit): added support to edit in-memory | |
391 | macros (automatically creates the necessary temp files). %edit |
|
404 | macros (automatically creates the necessary temp files). %edit | |
392 | also doesn't return the file contents anymore, it's just noise. |
|
405 | also doesn't return the file contents anymore, it's just noise. | |
393 |
|
406 | |||
394 | * IPython/completer.py (Completer.attr_matches): revert change to |
|
407 | * IPython/completer.py (Completer.attr_matches): revert change to | |
395 | complete only on attributes listed in __all__. I realized it |
|
408 | complete only on attributes listed in __all__. I realized it | |
396 | cripples the tab-completion system as a tool for exploring the |
|
409 | cripples the tab-completion system as a tool for exploring the | |
397 | internals of unknown libraries (it renders any non-__all__ |
|
410 | internals of unknown libraries (it renders any non-__all__ | |
398 | attribute off-limits). I got bit by this when trying to see |
|
411 | attribute off-limits). I got bit by this when trying to see | |
399 | something inside the dis module. |
|
412 | something inside the dis module. | |
400 |
|
413 | |||
401 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
414 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
402 |
|
415 | |||
403 | * IPython/iplib.py (InteractiveShell.__init__): add .meta |
|
416 | * IPython/iplib.py (InteractiveShell.__init__): add .meta | |
404 | namespace for users and extension writers to hold data in. This |
|
417 | namespace for users and extension writers to hold data in. This | |
405 | follows the discussion in |
|
418 | follows the discussion in | |
406 | http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython. |
|
419 | http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython. | |
407 |
|
420 | |||
408 | * IPython/completer.py (IPCompleter.complete): small patch to help |
|
421 | * IPython/completer.py (IPCompleter.complete): small patch to help | |
409 | tab-completion under Emacs, after a suggestion by John Barnard |
|
422 | tab-completion under Emacs, after a suggestion by John Barnard | |
410 | <barnarj-AT-ccf.org>. |
|
423 | <barnarj-AT-ccf.org>. | |
411 |
|
424 | |||
412 | * IPython/Magic.py (Magic.extract_input_slices): added support for |
|
425 | * IPython/Magic.py (Magic.extract_input_slices): added support for | |
413 | the slice notation in magics to use N-M to represent numbers N...M |
|
426 | the slice notation in magics to use N-M to represent numbers N...M | |
414 | (closed endpoints). This is used by %macro and %save. |
|
427 | (closed endpoints). This is used by %macro and %save. | |
415 |
|
428 | |||
416 | * IPython/completer.py (Completer.attr_matches): for modules which |
|
429 | * IPython/completer.py (Completer.attr_matches): for modules which | |
417 | define __all__, complete only on those. After a patch by Jeffrey |
|
430 | define __all__, complete only on those. After a patch by Jeffrey | |
418 | Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and |
|
431 | Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and | |
419 | speed up this routine. |
|
432 | speed up this routine. | |
420 |
|
433 | |||
421 | * IPython/Logger.py (Logger.log): fix a history handling bug. I |
|
434 | * IPython/Logger.py (Logger.log): fix a history handling bug. I | |
422 | don't know if this is the end of it, but the behavior now is |
|
435 | don't know if this is the end of it, but the behavior now is | |
423 | certainly much more correct. Note that coupled with macros, |
|
436 | certainly much more correct. Note that coupled with macros, | |
424 | slightly surprising (at first) behavior may occur: a macro will in |
|
437 | slightly surprising (at first) behavior may occur: a macro will in | |
425 | general expand to multiple lines of input, so upon exiting, the |
|
438 | general expand to multiple lines of input, so upon exiting, the | |
426 | in/out counters will both be bumped by the corresponding amount |
|
439 | in/out counters will both be bumped by the corresponding amount | |
427 | (as if the macro's contents had been typed interactively). Typing |
|
440 | (as if the macro's contents had been typed interactively). Typing | |
428 | %hist will reveal the intermediate (silently processed) lines. |
|
441 | %hist will reveal the intermediate (silently processed) lines. | |
429 |
|
442 | |||
430 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause |
|
443 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause | |
431 | pickle to fail (%run was overwriting __main__ and not restoring |
|
444 | pickle to fail (%run was overwriting __main__ and not restoring | |
432 | it, but pickle relies on __main__ to operate). |
|
445 | it, but pickle relies on __main__ to operate). | |
433 |
|
446 | |||
434 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now |
|
447 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now | |
435 | using properties, but forgot to make the main InteractiveShell |
|
448 | using properties, but forgot to make the main InteractiveShell | |
436 | class a new-style class. Properties fail silently, and |
|
449 | class a new-style class. Properties fail silently, and | |
437 | misteriously, with old-style class (getters work, but |
|
450 | misteriously, with old-style class (getters work, but | |
438 | setters don't do anything). |
|
451 | setters don't do anything). | |
439 |
|
452 | |||
440 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> |
|
453 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> | |
441 |
|
454 | |||
442 | * IPython/Magic.py (magic_history): fix history reporting bug (I |
|
455 | * IPython/Magic.py (magic_history): fix history reporting bug (I | |
443 | know some nasties are still there, I just can't seem to find a |
|
456 | know some nasties are still there, I just can't seem to find a | |
444 | reproducible test case to track them down; the input history is |
|
457 | reproducible test case to track them down; the input history is | |
445 | falling out of sync...) |
|
458 | falling out of sync...) | |
446 |
|
459 | |||
447 | * IPython/iplib.py (handle_shell_escape): fix bug where both |
|
460 | * IPython/iplib.py (handle_shell_escape): fix bug where both | |
448 | aliases and system accesses where broken for indented code (such |
|
461 | aliases and system accesses where broken for indented code (such | |
449 | as loops). |
|
462 | as loops). | |
450 |
|
463 | |||
451 | * IPython/genutils.py (shell): fix small but critical bug for |
|
464 | * IPython/genutils.py (shell): fix small but critical bug for | |
452 | win32 system access. |
|
465 | win32 system access. | |
453 |
|
466 | |||
454 | 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
467 | 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
455 |
|
468 | |||
456 | * IPython/iplib.py (showtraceback): remove use of the |
|
469 | * IPython/iplib.py (showtraceback): remove use of the | |
457 | sys.last_{type/value/traceback} structures, which are non |
|
470 | sys.last_{type/value/traceback} structures, which are non | |
458 | thread-safe. |
|
471 | thread-safe. | |
459 | (_prefilter): change control flow to ensure that we NEVER |
|
472 | (_prefilter): change control flow to ensure that we NEVER | |
460 | introspect objects when autocall is off. This will guarantee that |
|
473 | introspect objects when autocall is off. This will guarantee that | |
461 | having an input line of the form 'x.y', where access to attribute |
|
474 | having an input line of the form 'x.y', where access to attribute | |
462 | 'y' has side effects, doesn't trigger the side effect TWICE. It |
|
475 | 'y' has side effects, doesn't trigger the side effect TWICE. It | |
463 | is important to note that, with autocall on, these side effects |
|
476 | is important to note that, with autocall on, these side effects | |
464 | can still happen. |
|
477 | can still happen. | |
465 | (ipsystem): new builtin, to complete the ip{magic/alias/system} |
|
478 | (ipsystem): new builtin, to complete the ip{magic/alias/system} | |
466 | trio. IPython offers these three kinds of special calls which are |
|
479 | trio. IPython offers these three kinds of special calls which are | |
467 | not python code, and it's a good thing to have their call method |
|
480 | not python code, and it's a good thing to have their call method | |
468 | be accessible as pure python functions (not just special syntax at |
|
481 | be accessible as pure python functions (not just special syntax at | |
469 | the command line). It gives us a better internal implementation |
|
482 | the command line). It gives us a better internal implementation | |
470 | structure, as well as exposing these for user scripting more |
|
483 | structure, as well as exposing these for user scripting more | |
471 | cleanly. |
|
484 | cleanly. | |
472 |
|
485 | |||
473 | * IPython/macro.py (Macro.__init__): moved macros to a standalone |
|
486 | * IPython/macro.py (Macro.__init__): moved macros to a standalone | |
474 | file. Now that they'll be more likely to be used with the |
|
487 | file. Now that they'll be more likely to be used with the | |
475 | persistance system (%store), I want to make sure their module path |
|
488 | persistance system (%store), I want to make sure their module path | |
476 | doesn't change in the future, so that we don't break things for |
|
489 | doesn't change in the future, so that we don't break things for | |
477 | users' persisted data. |
|
490 | users' persisted data. | |
478 |
|
491 | |||
479 | * IPython/iplib.py (autoindent_update): move indentation |
|
492 | * IPython/iplib.py (autoindent_update): move indentation | |
480 | management into the _text_ processing loop, not the keyboard |
|
493 | management into the _text_ processing loop, not the keyboard | |
481 | interactive one. This is necessary to correctly process non-typed |
|
494 | interactive one. This is necessary to correctly process non-typed | |
482 | multiline input (such as macros). |
|
495 | multiline input (such as macros). | |
483 |
|
496 | |||
484 | * IPython/Magic.py (Magic.format_latex): patch by Stefan van der |
|
497 | * IPython/Magic.py (Magic.format_latex): patch by Stefan van der | |
485 | Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings, |
|
498 | Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings, | |
486 | which was producing problems in the resulting manual. |
|
499 | which was producing problems in the resulting manual. | |
487 | (magic_whos): improve reporting of instances (show their class, |
|
500 | (magic_whos): improve reporting of instances (show their class, | |
488 | instead of simply printing 'instance' which isn't terribly |
|
501 | instead of simply printing 'instance' which isn't terribly | |
489 | informative). |
|
502 | informative). | |
490 |
|
503 | |||
491 | * IPython/genutils.py (shell): commit Jorgen Stenarson's patch |
|
504 | * IPython/genutils.py (shell): commit Jorgen Stenarson's patch | |
492 | (minor mods) to support network shares under win32. |
|
505 | (minor mods) to support network shares under win32. | |
493 |
|
506 | |||
494 | * IPython/winconsole.py (get_console_size): add new winconsole |
|
507 | * IPython/winconsole.py (get_console_size): add new winconsole | |
495 | module and fixes to page_dumb() to improve its behavior under |
|
508 | module and fixes to page_dumb() to improve its behavior under | |
496 | win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>. |
|
509 | win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>. | |
497 |
|
510 | |||
498 | * IPython/Magic.py (Macro): simplified Macro class to just |
|
511 | * IPython/Magic.py (Macro): simplified Macro class to just | |
499 | subclass list. We've had only 2.2 compatibility for a very long |
|
512 | subclass list. We've had only 2.2 compatibility for a very long | |
500 | time, yet I was still avoiding subclassing the builtin types. No |
|
513 | time, yet I was still avoiding subclassing the builtin types. No | |
501 | more (I'm also starting to use properties, though I won't shift to |
|
514 | more (I'm also starting to use properties, though I won't shift to | |
502 | 2.3-specific features quite yet). |
|
515 | 2.3-specific features quite yet). | |
503 | (magic_store): added Ville's patch for lightweight variable |
|
516 | (magic_store): added Ville's patch for lightweight variable | |
504 | persistence, after a request on the user list by Matt Wilkie |
|
517 | persistence, after a request on the user list by Matt Wilkie | |
505 | <maphew-AT-gmail.com>. The new %store magic's docstring has full |
|
518 | <maphew-AT-gmail.com>. The new %store magic's docstring has full | |
506 | details. |
|
519 | details. | |
507 |
|
520 | |||
508 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
521 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
509 | changed the default logfile name from 'ipython.log' to |
|
522 | changed the default logfile name from 'ipython.log' to | |
510 | 'ipython_log.py'. These logs are real python files, and now that |
|
523 | 'ipython_log.py'. These logs are real python files, and now that | |
511 | we have much better multiline support, people are more likely to |
|
524 | we have much better multiline support, people are more likely to | |
512 | want to use them as such. Might as well name them correctly. |
|
525 | want to use them as such. Might as well name them correctly. | |
513 |
|
526 | |||
514 | * IPython/Magic.py: substantial cleanup. While we can't stop |
|
527 | * IPython/Magic.py: substantial cleanup. While we can't stop | |
515 | using magics as mixins, due to the existing customizations 'out |
|
528 | using magics as mixins, due to the existing customizations 'out | |
516 | there' which rely on the mixin naming conventions, at least I |
|
529 | there' which rely on the mixin naming conventions, at least I | |
517 | cleaned out all cross-class name usage. So once we are OK with |
|
530 | cleaned out all cross-class name usage. So once we are OK with | |
518 | breaking compatibility, the two systems can be separated. |
|
531 | breaking compatibility, the two systems can be separated. | |
519 |
|
532 | |||
520 | * IPython/Logger.py: major cleanup. This one is NOT a mixin |
|
533 | * IPython/Logger.py: major cleanup. This one is NOT a mixin | |
521 | anymore, and the class is a fair bit less hideous as well. New |
|
534 | anymore, and the class is a fair bit less hideous as well. New | |
522 | features were also introduced: timestamping of input, and logging |
|
535 | features were also introduced: timestamping of input, and logging | |
523 | of output results. These are user-visible with the -t and -o |
|
536 | of output results. These are user-visible with the -t and -o | |
524 | options to %logstart. Closes |
|
537 | options to %logstart. Closes | |
525 | http://www.scipy.net/roundup/ipython/issue11 and a request by |
|
538 | http://www.scipy.net/roundup/ipython/issue11 and a request by | |
526 | William Stein (SAGE developer - http://modular.ucsd.edu/sage). |
|
539 | William Stein (SAGE developer - http://modular.ucsd.edu/sage). | |
527 |
|
540 | |||
528 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> |
|
541 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> | |
529 |
|
542 | |||
530 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to |
|
543 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to | |
531 | better hadnle backslashes in paths. See the thread 'More Windows |
|
544 | better hadnle backslashes in paths. See the thread 'More Windows | |
532 | questions part 2 - \/ characters revisited' on the iypthon user |
|
545 | questions part 2 - \/ characters revisited' on the iypthon user | |
533 | list: |
|
546 | list: | |
534 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html |
|
547 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html | |
535 |
|
548 | |||
536 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. |
|
549 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. | |
537 |
|
550 | |||
538 | (InteractiveShell.__init__): change threaded shells to not use the |
|
551 | (InteractiveShell.__init__): change threaded shells to not use the | |
539 | ipython crash handler. This was causing more problems than not, |
|
552 | ipython crash handler. This was causing more problems than not, | |
540 | as exceptions in the main thread (GUI code, typically) would |
|
553 | as exceptions in the main thread (GUI code, typically) would | |
541 | always show up as a 'crash', when they really weren't. |
|
554 | always show up as a 'crash', when they really weren't. | |
542 |
|
555 | |||
543 | The colors and exception mode commands (%colors/%xmode) have been |
|
556 | The colors and exception mode commands (%colors/%xmode) have been | |
544 | synchronized to also take this into account, so users can get |
|
557 | synchronized to also take this into account, so users can get | |
545 | verbose exceptions for their threaded code as well. I also added |
|
558 | verbose exceptions for their threaded code as well. I also added | |
546 | support for activating pdb inside this exception handler as well, |
|
559 | support for activating pdb inside this exception handler as well, | |
547 | so now GUI authors can use IPython's enhanced pdb at runtime. |
|
560 | so now GUI authors can use IPython's enhanced pdb at runtime. | |
548 |
|
561 | |||
549 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag |
|
562 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag | |
550 | true by default, and add it to the shipped ipythonrc file. Since |
|
563 | true by default, and add it to the shipped ipythonrc file. Since | |
551 | this asks the user before proceeding, I think it's OK to make it |
|
564 | this asks the user before proceeding, I think it's OK to make it | |
552 | true by default. |
|
565 | true by default. | |
553 |
|
566 | |||
554 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead |
|
567 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead | |
555 | of the previous special-casing of input in the eval loop. I think |
|
568 | of the previous special-casing of input in the eval loop. I think | |
556 | this is cleaner, as they really are commands and shouldn't have |
|
569 | this is cleaner, as they really are commands and shouldn't have | |
557 | a special role in the middle of the core code. |
|
570 | a special role in the middle of the core code. | |
558 |
|
571 | |||
559 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
572 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
560 |
|
573 | |||
561 | * IPython/iplib.py (edit_syntax_error): added support for |
|
574 | * IPython/iplib.py (edit_syntax_error): added support for | |
562 | automatically reopening the editor if the file had a syntax error |
|
575 | automatically reopening the editor if the file had a syntax error | |
563 | in it. Thanks to scottt who provided the patch at: |
|
576 | in it. Thanks to scottt who provided the patch at: | |
564 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified |
|
577 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified | |
565 | version committed). |
|
578 | version committed). | |
566 |
|
579 | |||
567 | * IPython/iplib.py (handle_normal): add suport for multi-line |
|
580 | * IPython/iplib.py (handle_normal): add suport for multi-line | |
568 | input with emtpy lines. This fixes |
|
581 | input with emtpy lines. This fixes | |
569 | http://www.scipy.net/roundup/ipython/issue43 and a similar |
|
582 | http://www.scipy.net/roundup/ipython/issue43 and a similar | |
570 | discussion on the user list. |
|
583 | discussion on the user list. | |
571 |
|
584 | |||
572 | WARNING: a behavior change is necessarily introduced to support |
|
585 | WARNING: a behavior change is necessarily introduced to support | |
573 | blank lines: now a single blank line with whitespace does NOT |
|
586 | blank lines: now a single blank line with whitespace does NOT | |
574 | break the input loop, which means that when autoindent is on, by |
|
587 | break the input loop, which means that when autoindent is on, by | |
575 | default hitting return on the next (indented) line does NOT exit. |
|
588 | default hitting return on the next (indented) line does NOT exit. | |
576 |
|
589 | |||
577 | Instead, to exit a multiline input you can either have: |
|
590 | Instead, to exit a multiline input you can either have: | |
578 |
|
591 | |||
579 | - TWO whitespace lines (just hit return again), or |
|
592 | - TWO whitespace lines (just hit return again), or | |
580 | - a single whitespace line of a different length than provided |
|
593 | - a single whitespace line of a different length than provided | |
581 | by the autoindent (add or remove a space). |
|
594 | by the autoindent (add or remove a space). | |
582 |
|
595 | |||
583 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' |
|
596 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' | |
584 | module to better organize all readline-related functionality. |
|
597 | module to better organize all readline-related functionality. | |
585 | I've deleted FlexCompleter and put all completion clases here. |
|
598 | I've deleted FlexCompleter and put all completion clases here. | |
586 |
|
599 | |||
587 | * IPython/iplib.py (raw_input): improve indentation management. |
|
600 | * IPython/iplib.py (raw_input): improve indentation management. | |
588 | It is now possible to paste indented code with autoindent on, and |
|
601 | It is now possible to paste indented code with autoindent on, and | |
589 | the code is interpreted correctly (though it still looks bad on |
|
602 | the code is interpreted correctly (though it still looks bad on | |
590 | screen, due to the line-oriented nature of ipython). |
|
603 | screen, due to the line-oriented nature of ipython). | |
591 | (MagicCompleter.complete): change behavior so that a TAB key on an |
|
604 | (MagicCompleter.complete): change behavior so that a TAB key on an | |
592 | otherwise empty line actually inserts a tab, instead of completing |
|
605 | otherwise empty line actually inserts a tab, instead of completing | |
593 | on the entire global namespace. This makes it easier to use the |
|
606 | on the entire global namespace. This makes it easier to use the | |
594 | TAB key for indentation. After a request by Hans Meine |
|
607 | TAB key for indentation. After a request by Hans Meine | |
595 | <hans_meine-AT-gmx.net> |
|
608 | <hans_meine-AT-gmx.net> | |
596 | (_prefilter): add support so that typing plain 'exit' or 'quit' |
|
609 | (_prefilter): add support so that typing plain 'exit' or 'quit' | |
597 | does a sensible thing. Originally I tried to deviate as little as |
|
610 | does a sensible thing. Originally I tried to deviate as little as | |
598 | possible from the default python behavior, but even that one may |
|
611 | possible from the default python behavior, but even that one may | |
599 | change in this direction (thread on python-dev to that effect). |
|
612 | change in this direction (thread on python-dev to that effect). | |
600 | Regardless, ipython should do the right thing even if CPython's |
|
613 | Regardless, ipython should do the right thing even if CPython's | |
601 | '>>>' prompt doesn't. |
|
614 | '>>>' prompt doesn't. | |
602 | (InteractiveShell): removed subclassing code.InteractiveConsole |
|
615 | (InteractiveShell): removed subclassing code.InteractiveConsole | |
603 | class. By now we'd overridden just about all of its methods: I've |
|
616 | class. By now we'd overridden just about all of its methods: I've | |
604 | copied the remaining two over, and now ipython is a standalone |
|
617 | copied the remaining two over, and now ipython is a standalone | |
605 | class. This will provide a clearer picture for the chainsaw |
|
618 | class. This will provide a clearer picture for the chainsaw | |
606 | branch refactoring. |
|
619 | branch refactoring. | |
607 |
|
620 | |||
608 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> |
|
621 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> | |
609 |
|
622 | |||
610 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against |
|
623 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against | |
611 | failures for objects which break when dir() is called on them. |
|
624 | failures for objects which break when dir() is called on them. | |
612 |
|
625 | |||
613 | * IPython/FlexCompleter.py (Completer.__init__): Added support for |
|
626 | * IPython/FlexCompleter.py (Completer.__init__): Added support for | |
614 | distinct local and global namespaces in the completer API. This |
|
627 | distinct local and global namespaces in the completer API. This | |
615 | change allows us top properly handle completion with distinct |
|
628 | change allows us top properly handle completion with distinct | |
616 | scopes, including in embedded instances (this had never really |
|
629 | scopes, including in embedded instances (this had never really | |
617 | worked correctly). |
|
630 | worked correctly). | |
618 |
|
631 | |||
619 | Note: this introduces a change in the constructor for |
|
632 | Note: this introduces a change in the constructor for | |
620 | MagicCompleter, as a new global_namespace parameter is now the |
|
633 | MagicCompleter, as a new global_namespace parameter is now the | |
621 | second argument (the others were bumped one position). |
|
634 | second argument (the others were bumped one position). | |
622 |
|
635 | |||
623 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
636 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> | |
624 |
|
637 | |||
625 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
638 | * IPython/iplib.py (embed_mainloop): fix tab-completion in | |
626 | embedded instances (which can be done now thanks to Vivian's |
|
639 | embedded instances (which can be done now thanks to Vivian's | |
627 | frame-handling fixes for pdb). |
|
640 | frame-handling fixes for pdb). | |
628 | (InteractiveShell.__init__): Fix namespace handling problem in |
|
641 | (InteractiveShell.__init__): Fix namespace handling problem in | |
629 | embedded instances. We were overwriting __main__ unconditionally, |
|
642 | embedded instances. We were overwriting __main__ unconditionally, | |
630 | and this should only be done for 'full' (non-embedded) IPython; |
|
643 | and this should only be done for 'full' (non-embedded) IPython; | |
631 | embedded instances must respect the caller's __main__. Thanks to |
|
644 | embedded instances must respect the caller's __main__. Thanks to | |
632 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> |
|
645 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> | |
633 |
|
646 | |||
634 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
647 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
635 |
|
648 | |||
636 | * setup.py: added download_url to setup(). This registers the |
|
649 | * setup.py: added download_url to setup(). This registers the | |
637 | download address at PyPI, which is not only useful to humans |
|
650 | download address at PyPI, which is not only useful to humans | |
638 | browsing the site, but is also picked up by setuptools (the Eggs |
|
651 | browsing the site, but is also picked up by setuptools (the Eggs | |
639 | machinery). Thanks to Ville and R. Kern for the info/discussion |
|
652 | machinery). Thanks to Ville and R. Kern for the info/discussion | |
640 | on this. |
|
653 | on this. | |
641 |
|
654 | |||
642 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
655 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
643 |
|
656 | |||
644 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. |
|
657 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. | |
645 | This brings a lot of nice functionality to the pdb mode, which now |
|
658 | This brings a lot of nice functionality to the pdb mode, which now | |
646 | has tab-completion, syntax highlighting, and better stack handling |
|
659 | has tab-completion, syntax highlighting, and better stack handling | |
647 | than before. Many thanks to Vivian De Smedt |
|
660 | than before. Many thanks to Vivian De Smedt | |
648 | <vivian-AT-vdesmedt.com> for the original patches. |
|
661 | <vivian-AT-vdesmedt.com> for the original patches. | |
649 |
|
662 | |||
650 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
663 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> | |
651 |
|
664 | |||
652 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling |
|
665 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling | |
653 | sequence to consistently accept the banner argument. The |
|
666 | sequence to consistently accept the banner argument. The | |
654 | inconsistency was tripping SAGE, thanks to Gary Zablackis |
|
667 | inconsistency was tripping SAGE, thanks to Gary Zablackis | |
655 | <gzabl-AT-yahoo.com> for the report. |
|
668 | <gzabl-AT-yahoo.com> for the report. | |
656 |
|
669 | |||
657 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
670 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
658 |
|
671 | |||
659 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
672 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
660 | Fix bug where a naked 'alias' call in the ipythonrc file would |
|
673 | Fix bug where a naked 'alias' call in the ipythonrc file would | |
661 | cause a crash. Bug reported by Jorgen Stenarson. |
|
674 | cause a crash. Bug reported by Jorgen Stenarson. | |
662 |
|
675 | |||
663 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
676 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
664 |
|
677 | |||
665 | * IPython/ipmaker.py (make_IPython): cleanups which should improve |
|
678 | * IPython/ipmaker.py (make_IPython): cleanups which should improve | |
666 | startup time. |
|
679 | startup time. | |
667 |
|
680 | |||
668 | * IPython/iplib.py (runcode): my globals 'fix' for embedded |
|
681 | * IPython/iplib.py (runcode): my globals 'fix' for embedded | |
669 | instances had introduced a bug with globals in normal code. Now |
|
682 | instances had introduced a bug with globals in normal code. Now | |
670 | it's working in all cases. |
|
683 | it's working in all cases. | |
671 |
|
684 | |||
672 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and |
|
685 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and | |
673 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' |
|
686 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' | |
674 | has been introduced to set the default case sensitivity of the |
|
687 | has been introduced to set the default case sensitivity of the | |
675 | searches. Users can still select either mode at runtime on a |
|
688 | searches. Users can still select either mode at runtime on a | |
676 | per-search basis. |
|
689 | per-search basis. | |
677 |
|
690 | |||
678 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
691 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> | |
679 |
|
692 | |||
680 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of |
|
693 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of | |
681 | attributes in wildcard searches for subclasses. Modified version |
|
694 | attributes in wildcard searches for subclasses. Modified version | |
682 | of a patch by Jorgen. |
|
695 | of a patch by Jorgen. | |
683 |
|
696 | |||
684 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
697 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> | |
685 |
|
698 | |||
686 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for |
|
699 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for | |
687 | embedded instances. I added a user_global_ns attribute to the |
|
700 | embedded instances. I added a user_global_ns attribute to the | |
688 | InteractiveShell class to handle this. |
|
701 | InteractiveShell class to handle this. | |
689 |
|
702 | |||
690 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
703 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
691 |
|
704 | |||
692 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to |
|
705 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to | |
693 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 |
|
706 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 | |
694 | (reported under win32, but may happen also in other platforms). |
|
707 | (reported under win32, but may happen also in other platforms). | |
695 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> |
|
708 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> | |
696 |
|
709 | |||
697 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
710 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> | |
698 |
|
711 | |||
699 | * IPython/Magic.py (magic_psearch): new support for wildcard |
|
712 | * IPython/Magic.py (magic_psearch): new support for wildcard | |
700 | patterns. Now, typing ?a*b will list all names which begin with a |
|
713 | patterns. Now, typing ?a*b will list all names which begin with a | |
701 | and end in b, for example. The %psearch magic has full |
|
714 | and end in b, for example. The %psearch magic has full | |
702 | docstrings. Many thanks to JΓΆrgen Stenarson |
|
715 | docstrings. Many thanks to JΓΆrgen Stenarson | |
703 | <jorgen.stenarson-AT-bostream.nu>, author of the patches |
|
716 | <jorgen.stenarson-AT-bostream.nu>, author of the patches | |
704 | implementing this functionality. |
|
717 | implementing this functionality. | |
705 |
|
718 | |||
706 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
719 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
707 |
|
720 | |||
708 | * Manual: fixed long-standing annoyance of double-dashes (as in |
|
721 | * Manual: fixed long-standing annoyance of double-dashes (as in | |
709 | --prefix=~, for example) being stripped in the HTML version. This |
|
722 | --prefix=~, for example) being stripped in the HTML version. This | |
710 | is a latex2html bug, but a workaround was provided. Many thanks |
|
723 | is a latex2html bug, but a workaround was provided. Many thanks | |
711 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed |
|
724 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed | |
712 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball |
|
725 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball | |
713 | rolling. This seemingly small issue had tripped a number of users |
|
726 | rolling. This seemingly small issue had tripped a number of users | |
714 | when first installing, so I'm glad to see it gone. |
|
727 | when first installing, so I'm glad to see it gone. | |
715 |
|
728 | |||
716 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
729 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> | |
717 |
|
730 | |||
718 | * IPython/Extensions/numeric_formats.py: fix missing import, |
|
731 | * IPython/Extensions/numeric_formats.py: fix missing import, | |
719 | reported by Stephen Walton. |
|
732 | reported by Stephen Walton. | |
720 |
|
733 | |||
721 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
734 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> | |
722 |
|
735 | |||
723 | * IPython/demo.py: finish demo module, fully documented now. |
|
736 | * IPython/demo.py: finish demo module, fully documented now. | |
724 |
|
737 | |||
725 | * IPython/genutils.py (file_read): simple little utility to read a |
|
738 | * IPython/genutils.py (file_read): simple little utility to read a | |
726 | file and ensure it's closed afterwards. |
|
739 | file and ensure it's closed afterwards. | |
727 |
|
740 | |||
728 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
741 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> | |
729 |
|
742 | |||
730 | * IPython/demo.py (Demo.__init__): added support for individually |
|
743 | * IPython/demo.py (Demo.__init__): added support for individually | |
731 | tagging blocks for automatic execution. |
|
744 | tagging blocks for automatic execution. | |
732 |
|
745 | |||
733 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing |
|
746 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing | |
734 | syntax-highlighted python sources, requested by John. |
|
747 | syntax-highlighted python sources, requested by John. | |
735 |
|
748 | |||
736 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
749 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> | |
737 |
|
750 | |||
738 | * IPython/demo.py (Demo.again): fix bug where again() blocks after |
|
751 | * IPython/demo.py (Demo.again): fix bug where again() blocks after | |
739 | finishing. |
|
752 | finishing. | |
740 |
|
753 | |||
741 | * IPython/genutils.py (shlex_split): moved from Magic to here, |
|
754 | * IPython/genutils.py (shlex_split): moved from Magic to here, | |
742 | where all 2.2 compatibility stuff lives. I needed it for demo.py. |
|
755 | where all 2.2 compatibility stuff lives. I needed it for demo.py. | |
743 |
|
756 | |||
744 | * IPython/demo.py (Demo.__init__): added support for silent |
|
757 | * IPython/demo.py (Demo.__init__): added support for silent | |
745 | blocks, improved marks as regexps, docstrings written. |
|
758 | blocks, improved marks as regexps, docstrings written. | |
746 | (Demo.__init__): better docstring, added support for sys.argv. |
|
759 | (Demo.__init__): better docstring, added support for sys.argv. | |
747 |
|
760 | |||
748 | * IPython/genutils.py (marquee): little utility used by the demo |
|
761 | * IPython/genutils.py (marquee): little utility used by the demo | |
749 | code, handy in general. |
|
762 | code, handy in general. | |
750 |
|
763 | |||
751 | * IPython/demo.py (Demo.__init__): new class for interactive |
|
764 | * IPython/demo.py (Demo.__init__): new class for interactive | |
752 | demos. Not documented yet, I just wrote it in a hurry for |
|
765 | demos. Not documented yet, I just wrote it in a hurry for | |
753 | scipy'05. Will docstring later. |
|
766 | scipy'05. Will docstring later. | |
754 |
|
767 | |||
755 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
768 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> | |
756 |
|
769 | |||
757 | * IPython/Shell.py (sigint_handler): Drastic simplification which |
|
770 | * IPython/Shell.py (sigint_handler): Drastic simplification which | |
758 | also seems to make Ctrl-C work correctly across threads! This is |
|
771 | also seems to make Ctrl-C work correctly across threads! This is | |
759 | so simple, that I can't beleive I'd missed it before. Needs more |
|
772 | so simple, that I can't beleive I'd missed it before. Needs more | |
760 | testing, though. |
|
773 | testing, though. | |
761 | (KBINT): Never mind, revert changes. I'm sure I'd tried something |
|
774 | (KBINT): Never mind, revert changes. I'm sure I'd tried something | |
762 | like this before... |
|
775 | like this before... | |
763 |
|
776 | |||
764 | * IPython/genutils.py (get_home_dir): add protection against |
|
777 | * IPython/genutils.py (get_home_dir): add protection against | |
765 | non-dirs in win32 registry. |
|
778 | non-dirs in win32 registry. | |
766 |
|
779 | |||
767 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix |
|
780 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix | |
768 | bug where dict was mutated while iterating (pysh crash). |
|
781 | bug where dict was mutated while iterating (pysh crash). | |
769 |
|
782 | |||
770 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> |
|
783 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> | |
771 |
|
784 | |||
772 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from |
|
785 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from | |
773 | spurious newlines added by this routine. After a report by |
|
786 | spurious newlines added by this routine. After a report by | |
774 | F. Mantegazza. |
|
787 | F. Mantegazza. | |
775 |
|
788 | |||
776 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
789 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> | |
777 |
|
790 | |||
778 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") |
|
791 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") | |
779 | calls. These were a leftover from the GTK 1.x days, and can cause |
|
792 | calls. These were a leftover from the GTK 1.x days, and can cause | |
780 | problems in certain cases (after a report by John Hunter). |
|
793 | problems in certain cases (after a report by John Hunter). | |
781 |
|
794 | |||
782 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if |
|
795 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if | |
783 | os.getcwd() fails at init time. Thanks to patch from David Remahl |
|
796 | os.getcwd() fails at init time. Thanks to patch from David Remahl | |
784 | <chmod007-AT-mac.com>. |
|
797 | <chmod007-AT-mac.com>. | |
785 | (InteractiveShell.__init__): prevent certain special magics from |
|
798 | (InteractiveShell.__init__): prevent certain special magics from | |
786 | being shadowed by aliases. Closes |
|
799 | being shadowed by aliases. Closes | |
787 | http://www.scipy.net/roundup/ipython/issue41. |
|
800 | http://www.scipy.net/roundup/ipython/issue41. | |
788 |
|
801 | |||
789 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
802 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> | |
790 |
|
803 | |||
791 | * IPython/iplib.py (InteractiveShell.complete): Added new |
|
804 | * IPython/iplib.py (InteractiveShell.complete): Added new | |
792 | top-level completion method to expose the completion mechanism |
|
805 | top-level completion method to expose the completion mechanism | |
793 | beyond readline-based environments. |
|
806 | beyond readline-based environments. | |
794 |
|
807 | |||
795 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> |
|
808 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> | |
796 |
|
809 | |||
797 | * tools/ipsvnc (svnversion): fix svnversion capture. |
|
810 | * tools/ipsvnc (svnversion): fix svnversion capture. | |
798 |
|
811 | |||
799 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline |
|
812 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline | |
800 | attribute to self, which was missing. Before, it was set by a |
|
813 | attribute to self, which was missing. Before, it was set by a | |
801 | routine which in certain cases wasn't being called, so the |
|
814 | routine which in certain cases wasn't being called, so the | |
802 | instance could end up missing the attribute. This caused a crash. |
|
815 | instance could end up missing the attribute. This caused a crash. | |
803 | Closes http://www.scipy.net/roundup/ipython/issue40. |
|
816 | Closes http://www.scipy.net/roundup/ipython/issue40. | |
804 |
|
817 | |||
805 | 2005-08-16 Fernando Perez <fperez@colorado.edu> |
|
818 | 2005-08-16 Fernando Perez <fperez@colorado.edu> | |
806 |
|
819 | |||
807 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object |
|
820 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object | |
808 | contains non-string attribute. Closes |
|
821 | contains non-string attribute. Closes | |
809 | http://www.scipy.net/roundup/ipython/issue38. |
|
822 | http://www.scipy.net/roundup/ipython/issue38. | |
810 |
|
823 | |||
811 | 2005-08-14 Fernando Perez <fperez@colorado.edu> |
|
824 | 2005-08-14 Fernando Perez <fperez@colorado.edu> | |
812 |
|
825 | |||
813 | * tools/ipsvnc: Minor improvements, to add changeset info. |
|
826 | * tools/ipsvnc: Minor improvements, to add changeset info. | |
814 |
|
827 | |||
815 | 2005-08-12 Fernando Perez <fperez@colorado.edu> |
|
828 | 2005-08-12 Fernando Perez <fperez@colorado.edu> | |
816 |
|
829 | |||
817 | * IPython/iplib.py (runsource): remove self.code_to_run_src |
|
830 | * IPython/iplib.py (runsource): remove self.code_to_run_src | |
818 | attribute. I realized this is nothing more than |
|
831 | attribute. I realized this is nothing more than | |
819 | '\n'.join(self.buffer), and having the same data in two different |
|
832 | '\n'.join(self.buffer), and having the same data in two different | |
820 | places is just asking for synchronization bugs. This may impact |
|
833 | places is just asking for synchronization bugs. This may impact | |
821 | people who have custom exception handlers, so I need to warn |
|
834 | people who have custom exception handlers, so I need to warn | |
822 | ipython-dev about it (F. Mantegazza may use them). |
|
835 | ipython-dev about it (F. Mantegazza may use them). | |
823 |
|
836 | |||
824 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
837 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
825 |
|
838 | |||
826 | * IPython/genutils.py: fix 2.2 compatibility (generators) |
|
839 | * IPython/genutils.py: fix 2.2 compatibility (generators) | |
827 |
|
840 | |||
828 | 2005-07-18 Fernando Perez <fperez@colorado.edu> |
|
841 | 2005-07-18 Fernando Perez <fperez@colorado.edu> | |
829 |
|
842 | |||
830 | * IPython/genutils.py (get_home_dir): fix to help users with |
|
843 | * IPython/genutils.py (get_home_dir): fix to help users with | |
831 | invalid $HOME under win32. |
|
844 | invalid $HOME under win32. | |
832 |
|
845 | |||
833 | 2005-07-17 Fernando Perez <fperez@colorado.edu> |
|
846 | 2005-07-17 Fernando Perez <fperez@colorado.edu> | |
834 |
|
847 | |||
835 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove |
|
848 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove | |
836 | some old hacks and clean up a bit other routines; code should be |
|
849 | some old hacks and clean up a bit other routines; code should be | |
837 | simpler and a bit faster. |
|
850 | simpler and a bit faster. | |
838 |
|
851 | |||
839 | * IPython/iplib.py (interact): removed some last-resort attempts |
|
852 | * IPython/iplib.py (interact): removed some last-resort attempts | |
840 | to survive broken stdout/stderr. That code was only making it |
|
853 | to survive broken stdout/stderr. That code was only making it | |
841 | harder to abstract out the i/o (necessary for gui integration), |
|
854 | harder to abstract out the i/o (necessary for gui integration), | |
842 | and the crashes it could prevent were extremely rare in practice |
|
855 | and the crashes it could prevent were extremely rare in practice | |
843 | (besides being fully user-induced in a pretty violent manner). |
|
856 | (besides being fully user-induced in a pretty violent manner). | |
844 |
|
857 | |||
845 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. |
|
858 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. | |
846 | Nothing major yet, but the code is simpler to read; this should |
|
859 | Nothing major yet, but the code is simpler to read; this should | |
847 | make it easier to do more serious modifications in the future. |
|
860 | make it easier to do more serious modifications in the future. | |
848 |
|
861 | |||
849 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, |
|
862 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, | |
850 | which broke in .15 (thanks to a report by Ville). |
|
863 | which broke in .15 (thanks to a report by Ville). | |
851 |
|
864 | |||
852 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not |
|
865 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not | |
853 | be quite correct, I know next to nothing about unicode). This |
|
866 | be quite correct, I know next to nothing about unicode). This | |
854 | will allow unicode strings to be used in prompts, amongst other |
|
867 | will allow unicode strings to be used in prompts, amongst other | |
855 | cases. It also will prevent ipython from crashing when unicode |
|
868 | cases. It also will prevent ipython from crashing when unicode | |
856 | shows up unexpectedly in many places. If ascii encoding fails, we |
|
869 | shows up unexpectedly in many places. If ascii encoding fails, we | |
857 | assume utf_8. Currently the encoding is not a user-visible |
|
870 | assume utf_8. Currently the encoding is not a user-visible | |
858 | setting, though it could be made so if there is demand for it. |
|
871 | setting, though it could be made so if there is demand for it. | |
859 |
|
872 | |||
860 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. |
|
873 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. | |
861 |
|
874 | |||
862 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. |
|
875 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. | |
863 |
|
876 | |||
864 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. |
|
877 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. | |
865 |
|
878 | |||
866 | * IPython/genutils.py: Add 2.2 compatibility here, so all other |
|
879 | * IPython/genutils.py: Add 2.2 compatibility here, so all other | |
867 | code can work transparently for 2.2/2.3. |
|
880 | code can work transparently for 2.2/2.3. | |
868 |
|
881 | |||
869 | 2005-07-16 Fernando Perez <fperez@colorado.edu> |
|
882 | 2005-07-16 Fernando Perez <fperez@colorado.edu> | |
870 |
|
883 | |||
871 | * IPython/ultraTB.py (ExceptionColors): Make a global variable |
|
884 | * IPython/ultraTB.py (ExceptionColors): Make a global variable | |
872 | out of the color scheme table used for coloring exception |
|
885 | out of the color scheme table used for coloring exception | |
873 | tracebacks. This allows user code to add new schemes at runtime. |
|
886 | tracebacks. This allows user code to add new schemes at runtime. | |
874 | This is a minimally modified version of the patch at |
|
887 | This is a minimally modified version of the patch at | |
875 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw |
|
888 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw | |
876 | for the contribution. |
|
889 | for the contribution. | |
877 |
|
890 | |||
878 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a |
|
891 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a | |
879 | slightly modified version of the patch in |
|
892 | slightly modified version of the patch in | |
880 | http://www.scipy.net/roundup/ipython/issue34, which also allows me |
|
893 | http://www.scipy.net/roundup/ipython/issue34, which also allows me | |
881 | to remove the previous try/except solution (which was costlier). |
|
894 | to remove the previous try/except solution (which was costlier). | |
882 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. |
|
895 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. | |
883 |
|
896 | |||
884 | 2005-06-08 Fernando Perez <fperez@colorado.edu> |
|
897 | 2005-06-08 Fernando Perez <fperez@colorado.edu> | |
885 |
|
898 | |||
886 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
|
899 | * IPython/iplib.py (write/write_err): Add methods to abstract all | |
887 | I/O a bit more. |
|
900 | I/O a bit more. | |
888 |
|
901 | |||
889 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation |
|
902 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation | |
890 | warning, reported by Aric Hagberg, fix by JD Hunter. |
|
903 | warning, reported by Aric Hagberg, fix by JD Hunter. | |
891 |
|
904 | |||
892 | 2005-06-02 *** Released version 0.6.15 |
|
905 | 2005-06-02 *** Released version 0.6.15 | |
893 |
|
906 | |||
894 | 2005-06-01 Fernando Perez <fperez@colorado.edu> |
|
907 | 2005-06-01 Fernando Perez <fperez@colorado.edu> | |
895 |
|
908 | |||
896 | * IPython/iplib.py (MagicCompleter.file_matches): Fix |
|
909 | * IPython/iplib.py (MagicCompleter.file_matches): Fix | |
897 | tab-completion of filenames within open-quoted strings. Note that |
|
910 | tab-completion of filenames within open-quoted strings. Note that | |
898 | this requires that in ~/.ipython/ipythonrc, users change the |
|
911 | this requires that in ~/.ipython/ipythonrc, users change the | |
899 | readline delimiters configuration to read: |
|
912 | readline delimiters configuration to read: | |
900 |
|
913 | |||
901 | readline_remove_delims -/~ |
|
914 | readline_remove_delims -/~ | |
902 |
|
915 | |||
903 |
|
916 | |||
904 | 2005-05-31 *** Released version 0.6.14 |
|
917 | 2005-05-31 *** Released version 0.6.14 | |
905 |
|
918 | |||
906 | 2005-05-29 Fernando Perez <fperez@colorado.edu> |
|
919 | 2005-05-29 Fernando Perez <fperez@colorado.edu> | |
907 |
|
920 | |||
908 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks |
|
921 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks | |
909 | with files not on the filesystem. Reported by Eliyahu Sandler |
|
922 | with files not on the filesystem. Reported by Eliyahu Sandler | |
910 | <eli@gondolin.net> |
|
923 | <eli@gondolin.net> | |
911 |
|
924 | |||
912 | 2005-05-22 Fernando Perez <fperez@colorado.edu> |
|
925 | 2005-05-22 Fernando Perez <fperez@colorado.edu> | |
913 |
|
926 | |||
914 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. |
|
927 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. | |
915 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. |
|
928 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. | |
916 |
|
929 | |||
917 | 2005-05-19 Fernando Perez <fperez@colorado.edu> |
|
930 | 2005-05-19 Fernando Perez <fperez@colorado.edu> | |
918 |
|
931 | |||
919 | * IPython/iplib.py (safe_execfile): close a file which could be |
|
932 | * IPython/iplib.py (safe_execfile): close a file which could be | |
920 | left open (causing problems in win32, which locks open files). |
|
933 | left open (causing problems in win32, which locks open files). | |
921 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. |
|
934 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. | |
922 |
|
935 | |||
923 | 2005-05-18 Fernando Perez <fperez@colorado.edu> |
|
936 | 2005-05-18 Fernando Perez <fperez@colorado.edu> | |
924 |
|
937 | |||
925 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all |
|
938 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all | |
926 | keyword arguments correctly to safe_execfile(). |
|
939 | keyword arguments correctly to safe_execfile(). | |
927 |
|
940 | |||
928 | 2005-05-13 Fernando Perez <fperez@colorado.edu> |
|
941 | 2005-05-13 Fernando Perez <fperez@colorado.edu> | |
929 |
|
942 | |||
930 | * ipython.1: Added info about Qt to manpage, and threads warning |
|
943 | * ipython.1: Added info about Qt to manpage, and threads warning | |
931 | to usage page (invoked with --help). |
|
944 | to usage page (invoked with --help). | |
932 |
|
945 | |||
933 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added |
|
946 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added | |
934 | new matcher (it goes at the end of the priority list) to do |
|
947 | new matcher (it goes at the end of the priority list) to do | |
935 | tab-completion on named function arguments. Submitted by George |
|
948 | tab-completion on named function arguments. Submitted by George | |
936 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at |
|
949 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at | |
937 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html |
|
950 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html | |
938 | for more details. |
|
951 | for more details. | |
939 |
|
952 | |||
940 | * IPython/Magic.py (magic_run): Added new -e flag to ignore |
|
953 | * IPython/Magic.py (magic_run): Added new -e flag to ignore | |
941 | SystemExit exceptions in the script being run. Thanks to a report |
|
954 | SystemExit exceptions in the script being run. Thanks to a report | |
942 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this |
|
955 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this | |
943 | producing very annoying behavior when running unit tests. |
|
956 | producing very annoying behavior when running unit tests. | |
944 |
|
957 | |||
945 | 2005-05-12 Fernando Perez <fperez@colorado.edu> |
|
958 | 2005-05-12 Fernando Perez <fperez@colorado.edu> | |
946 |
|
959 | |||
947 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, |
|
960 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, | |
948 | which I'd broken (again) due to a changed regexp. In the process, |
|
961 | which I'd broken (again) due to a changed regexp. In the process, | |
949 | added ';' as an escape to auto-quote the whole line without |
|
962 | added ';' as an escape to auto-quote the whole line without | |
950 | splitting its arguments. Thanks to a report by Jerry McRae |
|
963 | splitting its arguments. Thanks to a report by Jerry McRae | |
951 | <qrs0xyc02-AT-sneakemail.com>. |
|
964 | <qrs0xyc02-AT-sneakemail.com>. | |
952 |
|
965 | |||
953 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but |
|
966 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but | |
954 | possible crashes caused by a TokenError. Reported by Ed Schofield |
|
967 | possible crashes caused by a TokenError. Reported by Ed Schofield | |
955 | <schofield-AT-ftw.at>. |
|
968 | <schofield-AT-ftw.at>. | |
956 |
|
969 | |||
957 | 2005-05-06 Fernando Perez <fperez@colorado.edu> |
|
970 | 2005-05-06 Fernando Perez <fperez@colorado.edu> | |
958 |
|
971 | |||
959 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. |
|
972 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. | |
960 |
|
973 | |||
961 | 2005-04-29 Fernando Perez <fperez@colorado.edu> |
|
974 | 2005-04-29 Fernando Perez <fperez@colorado.edu> | |
962 |
|
975 | |||
963 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière |
|
976 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière | |
964 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin |
|
977 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin | |
965 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option |
|
978 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option | |
966 | which provides support for Qt interactive usage (similar to the |
|
979 | which provides support for Qt interactive usage (similar to the | |
967 | existing one for WX and GTK). This had been often requested. |
|
980 | existing one for WX and GTK). This had been often requested. | |
968 |
|
981 | |||
969 | 2005-04-14 *** Released version 0.6.13 |
|
982 | 2005-04-14 *** Released version 0.6.13 | |
970 |
|
983 | |||
971 | 2005-04-08 Fernando Perez <fperez@colorado.edu> |
|
984 | 2005-04-08 Fernando Perez <fperez@colorado.edu> | |
972 |
|
985 | |||
973 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation |
|
986 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation | |
974 | from _ofind, which gets called on almost every input line. Now, |
|
987 | from _ofind, which gets called on almost every input line. Now, | |
975 | we only try to get docstrings if they are actually going to be |
|
988 | we only try to get docstrings if they are actually going to be | |
976 | used (the overhead of fetching unnecessary docstrings can be |
|
989 | used (the overhead of fetching unnecessary docstrings can be | |
977 | noticeable for certain objects, such as Pyro proxies). |
|
990 | noticeable for certain objects, such as Pyro proxies). | |
978 |
|
991 | |||
979 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API |
|
992 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API | |
980 | for completers. For some reason I had been passing them the state |
|
993 | for completers. For some reason I had been passing them the state | |
981 | variable, which completers never actually need, and was in |
|
994 | variable, which completers never actually need, and was in | |
982 | conflict with the rlcompleter API. Custom completers ONLY need to |
|
995 | conflict with the rlcompleter API. Custom completers ONLY need to | |
983 | take the text parameter. |
|
996 | take the text parameter. | |
984 |
|
997 | |||
985 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics |
|
998 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics | |
986 | work correctly in pysh. I've also moved all the logic which used |
|
999 | work correctly in pysh. I've also moved all the logic which used | |
987 | to be in pysh.py here, which will prevent problems with future |
|
1000 | to be in pysh.py here, which will prevent problems with future | |
988 | upgrades. However, this time I must warn users to update their |
|
1001 | upgrades. However, this time I must warn users to update their | |
989 | pysh profile to include the line |
|
1002 | pysh profile to include the line | |
990 |
|
1003 | |||
991 | import_all IPython.Extensions.InterpreterExec |
|
1004 | import_all IPython.Extensions.InterpreterExec | |
992 |
|
1005 | |||
993 | because otherwise things won't work for them. They MUST also |
|
1006 | because otherwise things won't work for them. They MUST also | |
994 | delete pysh.py and the line |
|
1007 | delete pysh.py and the line | |
995 |
|
1008 | |||
996 | execfile pysh.py |
|
1009 | execfile pysh.py | |
997 |
|
1010 | |||
998 | from their ipythonrc-pysh. |
|
1011 | from their ipythonrc-pysh. | |
999 |
|
1012 | |||
1000 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more |
|
1013 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more | |
1001 | robust in the face of objects whose dir() returns non-strings |
|
1014 | robust in the face of objects whose dir() returns non-strings | |
1002 | (which it shouldn't, but some broken libs like ITK do). Thanks to |
|
1015 | (which it shouldn't, but some broken libs like ITK do). Thanks to | |
1003 | a patch by John Hunter (implemented differently, though). Also |
|
1016 | a patch by John Hunter (implemented differently, though). Also | |
1004 | minor improvements by using .extend instead of + on lists. |
|
1017 | minor improvements by using .extend instead of + on lists. | |
1005 |
|
1018 | |||
1006 | * pysh.py: |
|
1019 | * pysh.py: | |
1007 |
|
1020 | |||
1008 | 2005-04-06 Fernando Perez <fperez@colorado.edu> |
|
1021 | 2005-04-06 Fernando Perez <fperez@colorado.edu> | |
1009 |
|
1022 | |||
1010 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on |
|
1023 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on | |
1011 | by default, so that all users benefit from it. Those who don't |
|
1024 | by default, so that all users benefit from it. Those who don't | |
1012 | want it can still turn it off. |
|
1025 | want it can still turn it off. | |
1013 |
|
1026 | |||
1014 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the |
|
1027 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the | |
1015 | config file, I'd forgotten about this, so users were getting it |
|
1028 | config file, I'd forgotten about this, so users were getting it | |
1016 | off by default. |
|
1029 | off by default. | |
1017 |
|
1030 | |||
1018 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for |
|
1031 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for | |
1019 | consistency. Now magics can be called in multiline statements, |
|
1032 | consistency. Now magics can be called in multiline statements, | |
1020 | and python variables can be expanded in magic calls via $var. |
|
1033 | and python variables can be expanded in magic calls via $var. | |
1021 | This makes the magic system behave just like aliases or !system |
|
1034 | This makes the magic system behave just like aliases or !system | |
1022 | calls. |
|
1035 | calls. | |
1023 |
|
1036 | |||
1024 | 2005-03-28 Fernando Perez <fperez@colorado.edu> |
|
1037 | 2005-03-28 Fernando Perez <fperez@colorado.edu> | |
1025 |
|
1038 | |||
1026 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of |
|
1039 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of | |
1027 | expensive string additions for building command. Add support for |
|
1040 | expensive string additions for building command. Add support for | |
1028 | trailing ';' when autocall is used. |
|
1041 | trailing ';' when autocall is used. | |
1029 |
|
1042 | |||
1030 | 2005-03-26 Fernando Perez <fperez@colorado.edu> |
|
1043 | 2005-03-26 Fernando Perez <fperez@colorado.edu> | |
1031 |
|
1044 | |||
1032 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. |
|
1045 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. | |
1033 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make |
|
1046 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make | |
1034 | ipython.el robust against prompts with any number of spaces |
|
1047 | ipython.el robust against prompts with any number of spaces | |
1035 | (including 0) after the ':' character. |
|
1048 | (including 0) after the ':' character. | |
1036 |
|
1049 | |||
1037 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in |
|
1050 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in | |
1038 | continuation prompt, which misled users to think the line was |
|
1051 | continuation prompt, which misled users to think the line was | |
1039 | already indented. Closes debian Bug#300847, reported to me by |
|
1052 | already indented. Closes debian Bug#300847, reported to me by | |
1040 | Norbert Tretkowski <tretkowski-AT-inittab.de>. |
|
1053 | Norbert Tretkowski <tretkowski-AT-inittab.de>. | |
1041 |
|
1054 | |||
1042 | 2005-03-23 Fernando Perez <fperez@colorado.edu> |
|
1055 | 2005-03-23 Fernando Perez <fperez@colorado.edu> | |
1043 |
|
1056 | |||
1044 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are |
|
1057 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are | |
1045 | properly aligned if they have embedded newlines. |
|
1058 | properly aligned if they have embedded newlines. | |
1046 |
|
1059 | |||
1047 | * IPython/iplib.py (runlines): Add a public method to expose |
|
1060 | * IPython/iplib.py (runlines): Add a public method to expose | |
1048 | IPython's code execution machinery, so that users can run strings |
|
1061 | IPython's code execution machinery, so that users can run strings | |
1049 | as if they had been typed at the prompt interactively. |
|
1062 | as if they had been typed at the prompt interactively. | |
1050 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ |
|
1063 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ | |
1051 | methods which can call the system shell, but with python variable |
|
1064 | methods which can call the system shell, but with python variable | |
1052 | expansion. The three such methods are: __IPYTHON__.system, |
|
1065 | expansion. The three such methods are: __IPYTHON__.system, | |
1053 | .getoutput and .getoutputerror. These need to be documented in a |
|
1066 | .getoutput and .getoutputerror. These need to be documented in a | |
1054 | 'public API' section (to be written) of the manual. |
|
1067 | 'public API' section (to be written) of the manual. | |
1055 |
|
1068 | |||
1056 | 2005-03-20 Fernando Perez <fperez@colorado.edu> |
|
1069 | 2005-03-20 Fernando Perez <fperez@colorado.edu> | |
1057 |
|
1070 | |||
1058 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system |
|
1071 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system | |
1059 | for custom exception handling. This is quite powerful, and it |
|
1072 | for custom exception handling. This is quite powerful, and it | |
1060 | allows for user-installable exception handlers which can trap |
|
1073 | allows for user-installable exception handlers which can trap | |
1061 | custom exceptions at runtime and treat them separately from |
|
1074 | custom exceptions at runtime and treat them separately from | |
1062 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric |
|
1075 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric | |
1063 | Mantegazza <mantegazza-AT-ill.fr>. |
|
1076 | Mantegazza <mantegazza-AT-ill.fr>. | |
1064 | (InteractiveShell.set_custom_completer): public API function to |
|
1077 | (InteractiveShell.set_custom_completer): public API function to | |
1065 | add new completers at runtime. |
|
1078 | add new completers at runtime. | |
1066 |
|
1079 | |||
1067 | 2005-03-19 Fernando Perez <fperez@colorado.edu> |
|
1080 | 2005-03-19 Fernando Perez <fperez@colorado.edu> | |
1068 |
|
1081 | |||
1069 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to |
|
1082 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to | |
1070 | allow objects which provide their docstrings via non-standard |
|
1083 | allow objects which provide their docstrings via non-standard | |
1071 | mechanisms (like Pyro proxies) to still be inspected by ipython's |
|
1084 | mechanisms (like Pyro proxies) to still be inspected by ipython's | |
1072 | ? system. |
|
1085 | ? system. | |
1073 |
|
1086 | |||
1074 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e |
|
1087 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e | |
1075 | automatic capture system. I tried quite hard to make it work |
|
1088 | automatic capture system. I tried quite hard to make it work | |
1076 | reliably, and simply failed. I tried many combinations with the |
|
1089 | reliably, and simply failed. I tried many combinations with the | |
1077 | subprocess module, but eventually nothing worked in all needed |
|
1090 | subprocess module, but eventually nothing worked in all needed | |
1078 | cases (not blocking stdin for the child, duplicating stdout |
|
1091 | cases (not blocking stdin for the child, duplicating stdout | |
1079 | without blocking, etc). The new %sc/%sx still do capture to these |
|
1092 | without blocking, etc). The new %sc/%sx still do capture to these | |
1080 | magical list/string objects which make shell use much more |
|
1093 | magical list/string objects which make shell use much more | |
1081 | conveninent, so not all is lost. |
|
1094 | conveninent, so not all is lost. | |
1082 |
|
1095 | |||
1083 | XXX - FIX MANUAL for the change above! |
|
1096 | XXX - FIX MANUAL for the change above! | |
1084 |
|
1097 | |||
1085 | (runsource): I copied code.py's runsource() into ipython to modify |
|
1098 | (runsource): I copied code.py's runsource() into ipython to modify | |
1086 | it a bit. Now the code object and source to be executed are |
|
1099 | it a bit. Now the code object and source to be executed are | |
1087 | stored in ipython. This makes this info accessible to third-party |
|
1100 | stored in ipython. This makes this info accessible to third-party | |
1088 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric |
|
1101 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric | |
1089 | Mantegazza <mantegazza-AT-ill.fr>. |
|
1102 | Mantegazza <mantegazza-AT-ill.fr>. | |
1090 |
|
1103 | |||
1091 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to |
|
1104 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to | |
1092 | history-search via readline (like C-p/C-n). I'd wanted this for a |
|
1105 | history-search via readline (like C-p/C-n). I'd wanted this for a | |
1093 | long time, but only recently found out how to do it. For users |
|
1106 | long time, but only recently found out how to do it. For users | |
1094 | who already have their ipythonrc files made and want this, just |
|
1107 | who already have their ipythonrc files made and want this, just | |
1095 | add: |
|
1108 | add: | |
1096 |
|
1109 | |||
1097 | readline_parse_and_bind "\e[A": history-search-backward |
|
1110 | readline_parse_and_bind "\e[A": history-search-backward | |
1098 | readline_parse_and_bind "\e[B": history-search-forward |
|
1111 | readline_parse_and_bind "\e[B": history-search-forward | |
1099 |
|
1112 | |||
1100 | 2005-03-18 Fernando Perez <fperez@colorado.edu> |
|
1113 | 2005-03-18 Fernando Perez <fperez@colorado.edu> | |
1101 |
|
1114 | |||
1102 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy |
|
1115 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy | |
1103 | LSString and SList classes which allow transparent conversions |
|
1116 | LSString and SList classes which allow transparent conversions | |
1104 | between list mode and whitespace-separated string. |
|
1117 | between list mode and whitespace-separated string. | |
1105 | (magic_r): Fix recursion problem in %r. |
|
1118 | (magic_r): Fix recursion problem in %r. | |
1106 |
|
1119 | |||
1107 | * IPython/genutils.py (LSString): New class to be used for |
|
1120 | * IPython/genutils.py (LSString): New class to be used for | |
1108 | automatic storage of the results of all alias/system calls in _o |
|
1121 | automatic storage of the results of all alias/system calls in _o | |
1109 | and _e (stdout/err). These provide a .l/.list attribute which |
|
1122 | and _e (stdout/err). These provide a .l/.list attribute which | |
1110 | does automatic splitting on newlines. This means that for most |
|
1123 | does automatic splitting on newlines. This means that for most | |
1111 | uses, you'll never need to do capturing of output with %sc/%sx |
|
1124 | uses, you'll never need to do capturing of output with %sc/%sx | |
1112 | anymore, since ipython keeps this always done for you. Note that |
|
1125 | anymore, since ipython keeps this always done for you. Note that | |
1113 | only the LAST results are stored, the _o/e variables are |
|
1126 | only the LAST results are stored, the _o/e variables are | |
1114 | overwritten on each call. If you need to save their contents |
|
1127 | overwritten on each call. If you need to save their contents | |
1115 | further, simply bind them to any other name. |
|
1128 | further, simply bind them to any other name. | |
1116 |
|
1129 | |||
1117 | 2005-03-17 Fernando Perez <fperez@colorado.edu> |
|
1130 | 2005-03-17 Fernando Perez <fperez@colorado.edu> | |
1118 |
|
1131 | |||
1119 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for |
|
1132 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for | |
1120 | prompt namespace handling. |
|
1133 | prompt namespace handling. | |
1121 |
|
1134 | |||
1122 | 2005-03-16 Fernando Perez <fperez@colorado.edu> |
|
1135 | 2005-03-16 Fernando Perez <fperez@colorado.edu> | |
1123 |
|
1136 | |||
1124 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and |
|
1137 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and | |
1125 | classic prompts to be '>>> ' (final space was missing, and it |
|
1138 | classic prompts to be '>>> ' (final space was missing, and it | |
1126 | trips the emacs python mode). |
|
1139 | trips the emacs python mode). | |
1127 | (BasePrompt.__str__): Added safe support for dynamic prompt |
|
1140 | (BasePrompt.__str__): Added safe support for dynamic prompt | |
1128 | strings. Now you can set your prompt string to be '$x', and the |
|
1141 | strings. Now you can set your prompt string to be '$x', and the | |
1129 | value of x will be printed from your interactive namespace. The |
|
1142 | value of x will be printed from your interactive namespace. The | |
1130 | interpolation syntax includes the full Itpl support, so |
|
1143 | interpolation syntax includes the full Itpl support, so | |
1131 | ${foo()+x+bar()} is a valid prompt string now, and the function |
|
1144 | ${foo()+x+bar()} is a valid prompt string now, and the function | |
1132 | calls will be made at runtime. |
|
1145 | calls will be made at runtime. | |
1133 |
|
1146 | |||
1134 | 2005-03-15 Fernando Perez <fperez@colorado.edu> |
|
1147 | 2005-03-15 Fernando Perez <fperez@colorado.edu> | |
1135 |
|
1148 | |||
1136 | * IPython/Magic.py (magic_history): renamed %hist to %history, to |
|
1149 | * IPython/Magic.py (magic_history): renamed %hist to %history, to | |
1137 | avoid name clashes in pylab. %hist still works, it just forwards |
|
1150 | avoid name clashes in pylab. %hist still works, it just forwards | |
1138 | the call to %history. |
|
1151 | the call to %history. | |
1139 |
|
1152 | |||
1140 | 2005-03-02 *** Released version 0.6.12 |
|
1153 | 2005-03-02 *** Released version 0.6.12 | |
1141 |
|
1154 | |||
1142 | 2005-03-02 Fernando Perez <fperez@colorado.edu> |
|
1155 | 2005-03-02 Fernando Perez <fperez@colorado.edu> | |
1143 |
|
1156 | |||
1144 | * IPython/iplib.py (handle_magic): log magic calls properly as |
|
1157 | * IPython/iplib.py (handle_magic): log magic calls properly as | |
1145 | ipmagic() function calls. |
|
1158 | ipmagic() function calls. | |
1146 |
|
1159 | |||
1147 | * IPython/Magic.py (magic_time): Improved %time to support |
|
1160 | * IPython/Magic.py (magic_time): Improved %time to support | |
1148 | statements and provide wall-clock as well as CPU time. |
|
1161 | statements and provide wall-clock as well as CPU time. | |
1149 |
|
1162 | |||
1150 | 2005-02-27 Fernando Perez <fperez@colorado.edu> |
|
1163 | 2005-02-27 Fernando Perez <fperez@colorado.edu> | |
1151 |
|
1164 | |||
1152 | * IPython/hooks.py: New hooks module, to expose user-modifiable |
|
1165 | * IPython/hooks.py: New hooks module, to expose user-modifiable | |
1153 | IPython functionality in a clean manner. For now only the editor |
|
1166 | IPython functionality in a clean manner. For now only the editor | |
1154 | hook is actually written, and other thigns which I intend to turn |
|
1167 | hook is actually written, and other thigns which I intend to turn | |
1155 | into proper hooks aren't yet there. The display and prefilter |
|
1168 | into proper hooks aren't yet there. The display and prefilter | |
1156 | stuff, for example, should be hooks. But at least now the |
|
1169 | stuff, for example, should be hooks. But at least now the | |
1157 | framework is in place, and the rest can be moved here with more |
|
1170 | framework is in place, and the rest can be moved here with more | |
1158 | time later. IPython had had a .hooks variable for a long time for |
|
1171 | time later. IPython had had a .hooks variable for a long time for | |
1159 | this purpose, but I'd never actually used it for anything. |
|
1172 | this purpose, but I'd never actually used it for anything. | |
1160 |
|
1173 | |||
1161 | 2005-02-26 Fernando Perez <fperez@colorado.edu> |
|
1174 | 2005-02-26 Fernando Perez <fperez@colorado.edu> | |
1162 |
|
1175 | |||
1163 | * IPython/ipmaker.py (make_IPython): make the default ipython |
|
1176 | * IPython/ipmaker.py (make_IPython): make the default ipython | |
1164 | directory be called _ipython under win32, to follow more the |
|
1177 | directory be called _ipython under win32, to follow more the | |
1165 | naming peculiarities of that platform (where buggy software like |
|
1178 | naming peculiarities of that platform (where buggy software like | |
1166 | Visual Sourcesafe breaks with .named directories). Reported by |
|
1179 | Visual Sourcesafe breaks with .named directories). Reported by | |
1167 | Ville Vainio. |
|
1180 | Ville Vainio. | |
1168 |
|
1181 | |||
1169 | 2005-02-23 Fernando Perez <fperez@colorado.edu> |
|
1182 | 2005-02-23 Fernando Perez <fperez@colorado.edu> | |
1170 |
|
1183 | |||
1171 | * IPython/iplib.py (InteractiveShell.__init__): removed a few |
|
1184 | * IPython/iplib.py (InteractiveShell.__init__): removed a few | |
1172 | auto_aliases for win32 which were causing problems. Users can |
|
1185 | auto_aliases for win32 which were causing problems. Users can | |
1173 | define the ones they personally like. |
|
1186 | define the ones they personally like. | |
1174 |
|
1187 | |||
1175 | 2005-02-21 Fernando Perez <fperez@colorado.edu> |
|
1188 | 2005-02-21 Fernando Perez <fperez@colorado.edu> | |
1176 |
|
1189 | |||
1177 | * IPython/Magic.py (magic_time): new magic to time execution of |
|
1190 | * IPython/Magic.py (magic_time): new magic to time execution of | |
1178 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. |
|
1191 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. | |
1179 |
|
1192 | |||
1180 | 2005-02-19 Fernando Perez <fperez@colorado.edu> |
|
1193 | 2005-02-19 Fernando Perez <fperez@colorado.edu> | |
1181 |
|
1194 | |||
1182 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings |
|
1195 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings | |
1183 | into keys (for prompts, for example). |
|
1196 | into keys (for prompts, for example). | |
1184 |
|
1197 | |||
1185 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty |
|
1198 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty | |
1186 | prompts in case users want them. This introduces a small behavior |
|
1199 | prompts in case users want them. This introduces a small behavior | |
1187 | change: ipython does not automatically add a space to all prompts |
|
1200 | change: ipython does not automatically add a space to all prompts | |
1188 | anymore. To get the old prompts with a space, users should add it |
|
1201 | anymore. To get the old prompts with a space, users should add it | |
1189 | manually to their ipythonrc file, so for example prompt_in1 should |
|
1202 | manually to their ipythonrc file, so for example prompt_in1 should | |
1190 | now read 'In [\#]: ' instead of 'In [\#]:'. |
|
1203 | now read 'In [\#]: ' instead of 'In [\#]:'. | |
1191 | (BasePrompt.__init__): New option prompts_pad_left (only in rc |
|
1204 | (BasePrompt.__init__): New option prompts_pad_left (only in rc | |
1192 | file) to control left-padding of secondary prompts. |
|
1205 | file) to control left-padding of secondary prompts. | |
1193 |
|
1206 | |||
1194 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if |
|
1207 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if | |
1195 | the profiler can't be imported. Fix for Debian, which removed |
|
1208 | the profiler can't be imported. Fix for Debian, which removed | |
1196 | profile.py because of License issues. I applied a slightly |
|
1209 | profile.py because of License issues. I applied a slightly | |
1197 | modified version of the original Debian patch at |
|
1210 | modified version of the original Debian patch at | |
1198 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. |
|
1211 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. | |
1199 |
|
1212 | |||
1200 | 2005-02-17 Fernando Perez <fperez@colorado.edu> |
|
1213 | 2005-02-17 Fernando Perez <fperez@colorado.edu> | |
1201 |
|
1214 | |||
1202 | * IPython/genutils.py (native_line_ends): Fix bug which would |
|
1215 | * IPython/genutils.py (native_line_ends): Fix bug which would | |
1203 | cause improper line-ends under win32 b/c I was not opening files |
|
1216 | cause improper line-ends under win32 b/c I was not opening files | |
1204 | in binary mode. Bug report and fix thanks to Ville. |
|
1217 | in binary mode. Bug report and fix thanks to Ville. | |
1205 |
|
1218 | |||
1206 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when |
|
1219 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when | |
1207 | trying to catch spurious foo[1] autocalls. My fix actually broke |
|
1220 | trying to catch spurious foo[1] autocalls. My fix actually broke | |
1208 | ',/' autoquote/call with explicit escape (bad regexp). |
|
1221 | ',/' autoquote/call with explicit escape (bad regexp). | |
1209 |
|
1222 | |||
1210 | 2005-02-15 *** Released version 0.6.11 |
|
1223 | 2005-02-15 *** Released version 0.6.11 | |
1211 |
|
1224 | |||
1212 | 2005-02-14 Fernando Perez <fperez@colorado.edu> |
|
1225 | 2005-02-14 Fernando Perez <fperez@colorado.edu> | |
1213 |
|
1226 | |||
1214 | * IPython/background_jobs.py: New background job management |
|
1227 | * IPython/background_jobs.py: New background job management | |
1215 | subsystem. This is implemented via a new set of classes, and |
|
1228 | subsystem. This is implemented via a new set of classes, and | |
1216 | IPython now provides a builtin 'jobs' object for background job |
|
1229 | IPython now provides a builtin 'jobs' object for background job | |
1217 | execution. A convenience %bg magic serves as a lightweight |
|
1230 | execution. A convenience %bg magic serves as a lightweight | |
1218 | frontend for starting the more common type of calls. This was |
|
1231 | frontend for starting the more common type of calls. This was | |
1219 | inspired by discussions with B. Granger and the BackgroundCommand |
|
1232 | inspired by discussions with B. Granger and the BackgroundCommand | |
1220 | class described in the book Python Scripting for Computational |
|
1233 | class described in the book Python Scripting for Computational | |
1221 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting |
|
1234 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting | |
1222 | (although ultimately no code from this text was used, as IPython's |
|
1235 | (although ultimately no code from this text was used, as IPython's | |
1223 | system is a separate implementation). |
|
1236 | system is a separate implementation). | |
1224 |
|
1237 | |||
1225 | * IPython/iplib.py (MagicCompleter.python_matches): add new option |
|
1238 | * IPython/iplib.py (MagicCompleter.python_matches): add new option | |
1226 | to control the completion of single/double underscore names |
|
1239 | to control the completion of single/double underscore names | |
1227 | separately. As documented in the example ipytonrc file, the |
|
1240 | separately. As documented in the example ipytonrc file, the | |
1228 | readline_omit__names variable can now be set to 2, to omit even |
|
1241 | readline_omit__names variable can now be set to 2, to omit even | |
1229 | single underscore names. Thanks to a patch by Brian Wong |
|
1242 | single underscore names. Thanks to a patch by Brian Wong | |
1230 | <BrianWong-AT-AirgoNetworks.Com>. |
|
1243 | <BrianWong-AT-AirgoNetworks.Com>. | |
1231 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to |
|
1244 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to | |
1232 | be autocalled as foo([1]) if foo were callable. A problem for |
|
1245 | be autocalled as foo([1]) if foo were callable. A problem for | |
1233 | things which are both callable and implement __getitem__. |
|
1246 | things which are both callable and implement __getitem__. | |
1234 | (init_readline): Fix autoindentation for win32. Thanks to a patch |
|
1247 | (init_readline): Fix autoindentation for win32. Thanks to a patch | |
1235 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. |
|
1248 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. | |
1236 |
|
1249 | |||
1237 | 2005-02-12 Fernando Perez <fperez@colorado.edu> |
|
1250 | 2005-02-12 Fernando Perez <fperez@colorado.edu> | |
1238 |
|
1251 | |||
1239 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps |
|
1252 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps | |
1240 | which I had written long ago to sort out user error messages which |
|
1253 | which I had written long ago to sort out user error messages which | |
1241 | may occur during startup. This seemed like a good idea initially, |
|
1254 | may occur during startup. This seemed like a good idea initially, | |
1242 | but it has proven a disaster in retrospect. I don't want to |
|
1255 | but it has proven a disaster in retrospect. I don't want to | |
1243 | change much code for now, so my fix is to set the internal 'debug' |
|
1256 | change much code for now, so my fix is to set the internal 'debug' | |
1244 | flag to true everywhere, whose only job was precisely to control |
|
1257 | flag to true everywhere, whose only job was precisely to control | |
1245 | this subsystem. This closes issue 28 (as well as avoiding all |
|
1258 | this subsystem. This closes issue 28 (as well as avoiding all | |
1246 | sorts of strange hangups which occur from time to time). |
|
1259 | sorts of strange hangups which occur from time to time). | |
1247 |
|
1260 | |||
1248 | 2005-02-07 Fernando Perez <fperez@colorado.edu> |
|
1261 | 2005-02-07 Fernando Perez <fperez@colorado.edu> | |
1249 |
|
1262 | |||
1250 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the |
|
1263 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the | |
1251 | previous call produced a syntax error. |
|
1264 | previous call produced a syntax error. | |
1252 |
|
1265 | |||
1253 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
1266 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
1254 | classes without constructor. |
|
1267 | classes without constructor. | |
1255 |
|
1268 | |||
1256 | 2005-02-06 Fernando Perez <fperez@colorado.edu> |
|
1269 | 2005-02-06 Fernando Perez <fperez@colorado.edu> | |
1257 |
|
1270 | |||
1258 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of |
|
1271 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of | |
1259 | completions with the results of each matcher, so we return results |
|
1272 | completions with the results of each matcher, so we return results | |
1260 | to the user from all namespaces. This breaks with ipython |
|
1273 | to the user from all namespaces. This breaks with ipython | |
1261 | tradition, but I think it's a nicer behavior. Now you get all |
|
1274 | tradition, but I think it's a nicer behavior. Now you get all | |
1262 | possible completions listed, from all possible namespaces (python, |
|
1275 | possible completions listed, from all possible namespaces (python, | |
1263 | filesystem, magics...) After a request by John Hunter |
|
1276 | filesystem, magics...) After a request by John Hunter | |
1264 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
1277 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
1265 |
|
1278 | |||
1266 | 2005-02-05 Fernando Perez <fperez@colorado.edu> |
|
1279 | 2005-02-05 Fernando Perez <fperez@colorado.edu> | |
1267 |
|
1280 | |||
1268 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if |
|
1281 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if | |
1269 | the call had quote characters in it (the quotes were stripped). |
|
1282 | the call had quote characters in it (the quotes were stripped). | |
1270 |
|
1283 | |||
1271 | 2005-01-31 Fernando Perez <fperez@colorado.edu> |
|
1284 | 2005-01-31 Fernando Perez <fperez@colorado.edu> | |
1272 |
|
1285 | |||
1273 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on |
|
1286 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on | |
1274 | Itpl.itpl() to make the code more robust against psyco |
|
1287 | Itpl.itpl() to make the code more robust against psyco | |
1275 | optimizations. |
|
1288 | optimizations. | |
1276 |
|
1289 | |||
1277 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead |
|
1290 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead | |
1278 | of causing an exception. Quicker, cleaner. |
|
1291 | of causing an exception. Quicker, cleaner. | |
1279 |
|
1292 | |||
1280 | 2005-01-28 Fernando Perez <fperez@colorado.edu> |
|
1293 | 2005-01-28 Fernando Perez <fperez@colorado.edu> | |
1281 |
|
1294 | |||
1282 | * scripts/ipython_win_post_install.py (install): hardcode |
|
1295 | * scripts/ipython_win_post_install.py (install): hardcode | |
1283 | sys.prefix+'python.exe' as the executable path. It turns out that |
|
1296 | sys.prefix+'python.exe' as the executable path. It turns out that | |
1284 | during the post-installation run, sys.executable resolves to the |
|
1297 | during the post-installation run, sys.executable resolves to the | |
1285 | name of the binary installer! I should report this as a distutils |
|
1298 | name of the binary installer! I should report this as a distutils | |
1286 | bug, I think. I updated the .10 release with this tiny fix, to |
|
1299 | bug, I think. I updated the .10 release with this tiny fix, to | |
1287 | avoid annoying the lists further. |
|
1300 | avoid annoying the lists further. | |
1288 |
|
1301 | |||
1289 | 2005-01-27 *** Released version 0.6.10 |
|
1302 | 2005-01-27 *** Released version 0.6.10 | |
1290 |
|
1303 | |||
1291 | 2005-01-27 Fernando Perez <fperez@colorado.edu> |
|
1304 | 2005-01-27 Fernando Perez <fperez@colorado.edu> | |
1292 |
|
1305 | |||
1293 | * IPython/numutils.py (norm): Added 'inf' as optional name for |
|
1306 | * IPython/numutils.py (norm): Added 'inf' as optional name for | |
1294 | L-infinity norm, included references to mathworld.com for vector |
|
1307 | L-infinity norm, included references to mathworld.com for vector | |
1295 | norm definitions. |
|
1308 | norm definitions. | |
1296 | (amin/amax): added amin/amax for array min/max. Similar to what |
|
1309 | (amin/amax): added amin/amax for array min/max. Similar to what | |
1297 | pylab ships with after the recent reorganization of names. |
|
1310 | pylab ships with after the recent reorganization of names. | |
1298 | (spike/spike_odd): removed deprecated spike/spike_odd functions. |
|
1311 | (spike/spike_odd): removed deprecated spike/spike_odd functions. | |
1299 |
|
1312 | |||
1300 | * ipython.el: committed Alex's recent fixes and improvements. |
|
1313 | * ipython.el: committed Alex's recent fixes and improvements. | |
1301 | Tested with python-mode from CVS, and it looks excellent. Since |
|
1314 | Tested with python-mode from CVS, and it looks excellent. Since | |
1302 | python-mode hasn't released anything in a while, I'm temporarily |
|
1315 | python-mode hasn't released anything in a while, I'm temporarily | |
1303 | putting a copy of today's CVS (v 4.70) of python-mode in: |
|
1316 | putting a copy of today's CVS (v 4.70) of python-mode in: | |
1304 | http://ipython.scipy.org/tmp/python-mode.el |
|
1317 | http://ipython.scipy.org/tmp/python-mode.el | |
1305 |
|
1318 | |||
1306 | * scripts/ipython_win_post_install.py (install): Win32 fix to use |
|
1319 | * scripts/ipython_win_post_install.py (install): Win32 fix to use | |
1307 | sys.executable for the executable name, instead of assuming it's |
|
1320 | sys.executable for the executable name, instead of assuming it's | |
1308 | called 'python.exe' (the post-installer would have produced broken |
|
1321 | called 'python.exe' (the post-installer would have produced broken | |
1309 | setups on systems with a differently named python binary). |
|
1322 | setups on systems with a differently named python binary). | |
1310 |
|
1323 | |||
1311 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' |
|
1324 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' | |
1312 | references to os.linesep, to make the code more |
|
1325 | references to os.linesep, to make the code more | |
1313 | platform-independent. This is also part of the win32 coloring |
|
1326 | platform-independent. This is also part of the win32 coloring | |
1314 | fixes. |
|
1327 | fixes. | |
1315 |
|
1328 | |||
1316 | * IPython/genutils.py (page_dumb): Remove attempts to chop long |
|
1329 | * IPython/genutils.py (page_dumb): Remove attempts to chop long | |
1317 | lines, which actually cause coloring bugs because the length of |
|
1330 | lines, which actually cause coloring bugs because the length of | |
1318 | the line is very difficult to correctly compute with embedded |
|
1331 | the line is very difficult to correctly compute with embedded | |
1319 | escapes. This was the source of all the coloring problems under |
|
1332 | escapes. This was the source of all the coloring problems under | |
1320 | Win32. I think that _finally_, Win32 users have a properly |
|
1333 | Win32. I think that _finally_, Win32 users have a properly | |
1321 | working ipython in all respects. This would never have happened |
|
1334 | working ipython in all respects. This would never have happened | |
1322 | if not for Gary Bishop and Viktor Ransmayr's great help and work. |
|
1335 | if not for Gary Bishop and Viktor Ransmayr's great help and work. | |
1323 |
|
1336 | |||
1324 | 2005-01-26 *** Released version 0.6.9 |
|
1337 | 2005-01-26 *** Released version 0.6.9 | |
1325 |
|
1338 | |||
1326 | 2005-01-25 Fernando Perez <fperez@colorado.edu> |
|
1339 | 2005-01-25 Fernando Perez <fperez@colorado.edu> | |
1327 |
|
1340 | |||
1328 | * setup.py: finally, we have a true Windows installer, thanks to |
|
1341 | * setup.py: finally, we have a true Windows installer, thanks to | |
1329 | the excellent work of Viktor Ransmayr |
|
1342 | the excellent work of Viktor Ransmayr | |
1330 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for |
|
1343 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for | |
1331 | Windows users. The setup routine is quite a bit cleaner thanks to |
|
1344 | Windows users. The setup routine is quite a bit cleaner thanks to | |
1332 | this, and the post-install script uses the proper functions to |
|
1345 | this, and the post-install script uses the proper functions to | |
1333 | allow a clean de-installation using the standard Windows Control |
|
1346 | allow a clean de-installation using the standard Windows Control | |
1334 | Panel. |
|
1347 | Panel. | |
1335 |
|
1348 | |||
1336 | * IPython/genutils.py (get_home_dir): changed to use the $HOME |
|
1349 | * IPython/genutils.py (get_home_dir): changed to use the $HOME | |
1337 | environment variable under all OSes (including win32) if |
|
1350 | environment variable under all OSes (including win32) if | |
1338 | available. This will give consistency to win32 users who have set |
|
1351 | available. This will give consistency to win32 users who have set | |
1339 | this variable for any reason. If os.environ['HOME'] fails, the |
|
1352 | this variable for any reason. If os.environ['HOME'] fails, the | |
1340 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. |
|
1353 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. | |
1341 |
|
1354 | |||
1342 | 2005-01-24 Fernando Perez <fperez@colorado.edu> |
|
1355 | 2005-01-24 Fernando Perez <fperez@colorado.edu> | |
1343 |
|
1356 | |||
1344 | * IPython/numutils.py (empty_like): add empty_like(), similar to |
|
1357 | * IPython/numutils.py (empty_like): add empty_like(), similar to | |
1345 | zeros_like() but taking advantage of the new empty() Numeric routine. |
|
1358 | zeros_like() but taking advantage of the new empty() Numeric routine. | |
1346 |
|
1359 | |||
1347 | 2005-01-23 *** Released version 0.6.8 |
|
1360 | 2005-01-23 *** Released version 0.6.8 | |
1348 |
|
1361 | |||
1349 | 2005-01-22 Fernando Perez <fperez@colorado.edu> |
|
1362 | 2005-01-22 Fernando Perez <fperez@colorado.edu> | |
1350 |
|
1363 | |||
1351 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the |
|
1364 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the | |
1352 | automatic show() calls. After discussing things with JDH, it |
|
1365 | automatic show() calls. After discussing things with JDH, it | |
1353 | turns out there are too many corner cases where this can go wrong. |
|
1366 | turns out there are too many corner cases where this can go wrong. | |
1354 | It's best not to try to be 'too smart', and simply have ipython |
|
1367 | It's best not to try to be 'too smart', and simply have ipython | |
1355 | reproduce as much as possible the default behavior of a normal |
|
1368 | reproduce as much as possible the default behavior of a normal | |
1356 | python shell. |
|
1369 | python shell. | |
1357 |
|
1370 | |||
1358 | * IPython/iplib.py (InteractiveShell.__init__): Modified the |
|
1371 | * IPython/iplib.py (InteractiveShell.__init__): Modified the | |
1359 | line-splitting regexp and _prefilter() to avoid calling getattr() |
|
1372 | line-splitting regexp and _prefilter() to avoid calling getattr() | |
1360 | on assignments. This closes |
|
1373 | on assignments. This closes | |
1361 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's |
|
1374 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's | |
1362 | readline uses getattr(), so a simple <TAB> keypress is still |
|
1375 | readline uses getattr(), so a simple <TAB> keypress is still | |
1363 | enough to trigger getattr() calls on an object. |
|
1376 | enough to trigger getattr() calls on an object. | |
1364 |
|
1377 | |||
1365 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
1378 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
1366 |
|
1379 | |||
1367 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run |
|
1380 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run | |
1368 | docstring under pylab so it doesn't mask the original. |
|
1381 | docstring under pylab so it doesn't mask the original. | |
1369 |
|
1382 | |||
1370 | 2005-01-21 *** Released version 0.6.7 |
|
1383 | 2005-01-21 *** Released version 0.6.7 | |
1371 |
|
1384 | |||
1372 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
1385 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
1373 |
|
1386 | |||
1374 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with |
|
1387 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with | |
1375 | signal handling for win32 users in multithreaded mode. |
|
1388 | signal handling for win32 users in multithreaded mode. | |
1376 |
|
1389 | |||
1377 | 2005-01-17 Fernando Perez <fperez@colorado.edu> |
|
1390 | 2005-01-17 Fernando Perez <fperez@colorado.edu> | |
1378 |
|
1391 | |||
1379 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
1392 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
1380 | instances with no __init__. After a crash report by Norbert Nemec |
|
1393 | instances with no __init__. After a crash report by Norbert Nemec | |
1381 | <Norbert-AT-nemec-online.de>. |
|
1394 | <Norbert-AT-nemec-online.de>. | |
1382 |
|
1395 | |||
1383 | 2005-01-14 Fernando Perez <fperez@colorado.edu> |
|
1396 | 2005-01-14 Fernando Perez <fperez@colorado.edu> | |
1384 |
|
1397 | |||
1385 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of |
|
1398 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of | |
1386 | names for verbose exceptions, when multiple dotted names and the |
|
1399 | names for verbose exceptions, when multiple dotted names and the | |
1387 | 'parent' object were present on the same line. |
|
1400 | 'parent' object were present on the same line. | |
1388 |
|
1401 | |||
1389 | 2005-01-11 Fernando Perez <fperez@colorado.edu> |
|
1402 | 2005-01-11 Fernando Perez <fperez@colorado.edu> | |
1390 |
|
1403 | |||
1391 | * IPython/genutils.py (flag_calls): new utility to trap and flag |
|
1404 | * IPython/genutils.py (flag_calls): new utility to trap and flag | |
1392 | calls in functions. I need it to clean up matplotlib support. |
|
1405 | calls in functions. I need it to clean up matplotlib support. | |
1393 | Also removed some deprecated code in genutils. |
|
1406 | Also removed some deprecated code in genutils. | |
1394 |
|
1407 | |||
1395 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so |
|
1408 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so | |
1396 | that matplotlib scripts called with %run, which don't call show() |
|
1409 | that matplotlib scripts called with %run, which don't call show() | |
1397 | themselves, still have their plotting windows open. |
|
1410 | themselves, still have their plotting windows open. | |
1398 |
|
1411 | |||
1399 | 2005-01-05 Fernando Perez <fperez@colorado.edu> |
|
1412 | 2005-01-05 Fernando Perez <fperez@colorado.edu> | |
1400 |
|
1413 | |||
1401 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw |
|
1414 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw | |
1402 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. |
|
1415 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. | |
1403 |
|
1416 | |||
1404 | 2004-12-19 Fernando Perez <fperez@colorado.edu> |
|
1417 | 2004-12-19 Fernando Perez <fperez@colorado.edu> | |
1405 |
|
1418 | |||
1406 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of |
|
1419 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of | |
1407 | parent_runcode, which was an eyesore. The same result can be |
|
1420 | parent_runcode, which was an eyesore. The same result can be | |
1408 | obtained with Python's regular superclass mechanisms. |
|
1421 | obtained with Python's regular superclass mechanisms. | |
1409 |
|
1422 | |||
1410 | 2004-12-17 Fernando Perez <fperez@colorado.edu> |
|
1423 | 2004-12-17 Fernando Perez <fperez@colorado.edu> | |
1411 |
|
1424 | |||
1412 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem |
|
1425 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem | |
1413 | reported by Prabhu. |
|
1426 | reported by Prabhu. | |
1414 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to |
|
1427 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to | |
1415 | sys.stderr) instead of explicitly calling sys.stderr. This helps |
|
1428 | sys.stderr) instead of explicitly calling sys.stderr. This helps | |
1416 | maintain our I/O abstractions clean, for future GUI embeddings. |
|
1429 | maintain our I/O abstractions clean, for future GUI embeddings. | |
1417 |
|
1430 | |||
1418 | * IPython/genutils.py (info): added new utility for sys.stderr |
|
1431 | * IPython/genutils.py (info): added new utility for sys.stderr | |
1419 | unified info message handling (thin wrapper around warn()). |
|
1432 | unified info message handling (thin wrapper around warn()). | |
1420 |
|
1433 | |||
1421 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global |
|
1434 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global | |
1422 | composite (dotted) names on verbose exceptions. |
|
1435 | composite (dotted) names on verbose exceptions. | |
1423 | (VerboseTB.nullrepr): harden against another kind of errors which |
|
1436 | (VerboseTB.nullrepr): harden against another kind of errors which | |
1424 | Python's inspect module can trigger, and which were crashing |
|
1437 | Python's inspect module can trigger, and which were crashing | |
1425 | IPython. Thanks to a report by Marco Lombardi |
|
1438 | IPython. Thanks to a report by Marco Lombardi | |
1426 | <mlombard-AT-ma010192.hq.eso.org>. |
|
1439 | <mlombard-AT-ma010192.hq.eso.org>. | |
1427 |
|
1440 | |||
1428 | 2004-12-13 *** Released version 0.6.6 |
|
1441 | 2004-12-13 *** Released version 0.6.6 | |
1429 |
|
1442 | |||
1430 | 2004-12-12 Fernando Perez <fperez@colorado.edu> |
|
1443 | 2004-12-12 Fernando Perez <fperez@colorado.edu> | |
1431 |
|
1444 | |||
1432 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors |
|
1445 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors | |
1433 | generated by pygtk upon initialization if it was built without |
|
1446 | generated by pygtk upon initialization if it was built without | |
1434 | threads (for matplotlib users). After a crash reported by |
|
1447 | threads (for matplotlib users). After a crash reported by | |
1435 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. |
|
1448 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. | |
1436 |
|
1449 | |||
1437 | * IPython/ipmaker.py (make_IPython): fix small bug in the |
|
1450 | * IPython/ipmaker.py (make_IPython): fix small bug in the | |
1438 | import_some parameter for multiple imports. |
|
1451 | import_some parameter for multiple imports. | |
1439 |
|
1452 | |||
1440 | * IPython/iplib.py (ipmagic): simplified the interface of |
|
1453 | * IPython/iplib.py (ipmagic): simplified the interface of | |
1441 | ipmagic() to take a single string argument, just as it would be |
|
1454 | ipmagic() to take a single string argument, just as it would be | |
1442 | typed at the IPython cmd line. |
|
1455 | typed at the IPython cmd line. | |
1443 | (ipalias): Added new ipalias() with an interface identical to |
|
1456 | (ipalias): Added new ipalias() with an interface identical to | |
1444 | ipmagic(). This completes exposing a pure python interface to the |
|
1457 | ipmagic(). This completes exposing a pure python interface to the | |
1445 | alias and magic system, which can be used in loops or more complex |
|
1458 | alias and magic system, which can be used in loops or more complex | |
1446 | code where IPython's automatic line mangling is not active. |
|
1459 | code where IPython's automatic line mangling is not active. | |
1447 |
|
1460 | |||
1448 | * IPython/genutils.py (timing): changed interface of timing to |
|
1461 | * IPython/genutils.py (timing): changed interface of timing to | |
1449 | simply run code once, which is the most common case. timings() |
|
1462 | simply run code once, which is the most common case. timings() | |
1450 | remains unchanged, for the cases where you want multiple runs. |
|
1463 | remains unchanged, for the cases where you want multiple runs. | |
1451 |
|
1464 | |||
1452 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a |
|
1465 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a | |
1453 | bug where Python2.2 crashes with exec'ing code which does not end |
|
1466 | bug where Python2.2 crashes with exec'ing code which does not end | |
1454 | in a single newline. Python 2.3 is OK, so I hadn't noticed this |
|
1467 | in a single newline. Python 2.3 is OK, so I hadn't noticed this | |
1455 | before. |
|
1468 | before. | |
1456 |
|
1469 | |||
1457 | 2004-12-10 Fernando Perez <fperez@colorado.edu> |
|
1470 | 2004-12-10 Fernando Perez <fperez@colorado.edu> | |
1458 |
|
1471 | |||
1459 | * IPython/Magic.py (Magic.magic_prun): changed name of option from |
|
1472 | * IPython/Magic.py (Magic.magic_prun): changed name of option from | |
1460 | -t to -T, to accomodate the new -t flag in %run (the %run and |
|
1473 | -t to -T, to accomodate the new -t flag in %run (the %run and | |
1461 | %prun options are kind of intermixed, and it's not easy to change |
|
1474 | %prun options are kind of intermixed, and it's not easy to change | |
1462 | this with the limitations of python's getopt). |
|
1475 | this with the limitations of python's getopt). | |
1463 |
|
1476 | |||
1464 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time |
|
1477 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time | |
1465 | the execution of scripts. It's not as fine-tuned as timeit.py, |
|
1478 | the execution of scripts. It's not as fine-tuned as timeit.py, | |
1466 | but it works from inside ipython (and under 2.2, which lacks |
|
1479 | but it works from inside ipython (and under 2.2, which lacks | |
1467 | timeit.py). Optionally a number of runs > 1 can be given for |
|
1480 | timeit.py). Optionally a number of runs > 1 can be given for | |
1468 | timing very short-running code. |
|
1481 | timing very short-running code. | |
1469 |
|
1482 | |||
1470 | * IPython/genutils.py (uniq_stable): new routine which returns a |
|
1483 | * IPython/genutils.py (uniq_stable): new routine which returns a | |
1471 | list of unique elements in any iterable, but in stable order of |
|
1484 | list of unique elements in any iterable, but in stable order of | |
1472 | appearance. I needed this for the ultraTB fixes, and it's a handy |
|
1485 | appearance. I needed this for the ultraTB fixes, and it's a handy | |
1473 | utility. |
|
1486 | utility. | |
1474 |
|
1487 | |||
1475 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of |
|
1488 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of | |
1476 | dotted names in Verbose exceptions. This had been broken since |
|
1489 | dotted names in Verbose exceptions. This had been broken since | |
1477 | the very start, now x.y will properly be printed in a Verbose |
|
1490 | the very start, now x.y will properly be printed in a Verbose | |
1478 | traceback, instead of x being shown and y appearing always as an |
|
1491 | traceback, instead of x being shown and y appearing always as an | |
1479 | 'undefined global'. Getting this to work was a bit tricky, |
|
1492 | 'undefined global'. Getting this to work was a bit tricky, | |
1480 | because by default python tokenizers are stateless. Saved by |
|
1493 | because by default python tokenizers are stateless. Saved by | |
1481 | python's ability to easily add a bit of state to an arbitrary |
|
1494 | python's ability to easily add a bit of state to an arbitrary | |
1482 | function (without needing to build a full-blown callable object). |
|
1495 | function (without needing to build a full-blown callable object). | |
1483 |
|
1496 | |||
1484 | Also big cleanup of this code, which had horrendous runtime |
|
1497 | Also big cleanup of this code, which had horrendous runtime | |
1485 | lookups of zillions of attributes for colorization. Moved all |
|
1498 | lookups of zillions of attributes for colorization. Moved all | |
1486 | this code into a few templates, which make it cleaner and quicker. |
|
1499 | this code into a few templates, which make it cleaner and quicker. | |
1487 |
|
1500 | |||
1488 | Printout quality was also improved for Verbose exceptions: one |
|
1501 | Printout quality was also improved for Verbose exceptions: one | |
1489 | variable per line, and memory addresses are printed (this can be |
|
1502 | variable per line, and memory addresses are printed (this can be | |
1490 | quite handy in nasty debugging situations, which is what Verbose |
|
1503 | quite handy in nasty debugging situations, which is what Verbose | |
1491 | is for). |
|
1504 | is for). | |
1492 |
|
1505 | |||
1493 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in |
|
1506 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in | |
1494 | the command line as scripts to be loaded by embedded instances. |
|
1507 | the command line as scripts to be loaded by embedded instances. | |
1495 | Doing so has the potential for an infinite recursion if there are |
|
1508 | Doing so has the potential for an infinite recursion if there are | |
1496 | exceptions thrown in the process. This fixes a strange crash |
|
1509 | exceptions thrown in the process. This fixes a strange crash | |
1497 | reported by Philippe MULLER <muller-AT-irit.fr>. |
|
1510 | reported by Philippe MULLER <muller-AT-irit.fr>. | |
1498 |
|
1511 | |||
1499 | 2004-12-09 Fernando Perez <fperez@colorado.edu> |
|
1512 | 2004-12-09 Fernando Perez <fperez@colorado.edu> | |
1500 |
|
1513 | |||
1501 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support |
|
1514 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support | |
1502 | to reflect new names in matplotlib, which now expose the |
|
1515 | to reflect new names in matplotlib, which now expose the | |
1503 | matlab-compatible interface via a pylab module instead of the |
|
1516 | matlab-compatible interface via a pylab module instead of the | |
1504 | 'matlab' name. The new code is backwards compatible, so users of |
|
1517 | 'matlab' name. The new code is backwards compatible, so users of | |
1505 | all matplotlib versions are OK. Patch by J. Hunter. |
|
1518 | all matplotlib versions are OK. Patch by J. Hunter. | |
1506 |
|
1519 | |||
1507 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing |
|
1520 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing | |
1508 | of __init__ docstrings for instances (class docstrings are already |
|
1521 | of __init__ docstrings for instances (class docstrings are already | |
1509 | automatically printed). Instances with customized docstrings |
|
1522 | automatically printed). Instances with customized docstrings | |
1510 | (indep. of the class) are also recognized and all 3 separate |
|
1523 | (indep. of the class) are also recognized and all 3 separate | |
1511 | docstrings are printed (instance, class, constructor). After some |
|
1524 | docstrings are printed (instance, class, constructor). After some | |
1512 | comments/suggestions by J. Hunter. |
|
1525 | comments/suggestions by J. Hunter. | |
1513 |
|
1526 | |||
1514 | 2004-12-05 Fernando Perez <fperez@colorado.edu> |
|
1527 | 2004-12-05 Fernando Perez <fperez@colorado.edu> | |
1515 |
|
1528 | |||
1516 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying |
|
1529 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying | |
1517 | warnings when tab-completion fails and triggers an exception. |
|
1530 | warnings when tab-completion fails and triggers an exception. | |
1518 |
|
1531 | |||
1519 | 2004-12-03 Fernando Perez <fperez@colorado.edu> |
|
1532 | 2004-12-03 Fernando Perez <fperez@colorado.edu> | |
1520 |
|
1533 | |||
1521 | * IPython/Magic.py (magic_prun): Fix bug where an exception would |
|
1534 | * IPython/Magic.py (magic_prun): Fix bug where an exception would | |
1522 | be triggered when using 'run -p'. An incorrect option flag was |
|
1535 | be triggered when using 'run -p'. An incorrect option flag was | |
1523 | being set ('d' instead of 'D'). |
|
1536 | being set ('d' instead of 'D'). | |
1524 | (manpage): fix missing escaped \- sign. |
|
1537 | (manpage): fix missing escaped \- sign. | |
1525 |
|
1538 | |||
1526 | 2004-11-30 *** Released version 0.6.5 |
|
1539 | 2004-11-30 *** Released version 0.6.5 | |
1527 |
|
1540 | |||
1528 | 2004-11-30 Fernando Perez <fperez@colorado.edu> |
|
1541 | 2004-11-30 Fernando Perez <fperez@colorado.edu> | |
1529 |
|
1542 | |||
1530 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint |
|
1543 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint | |
1531 | setting with -d option. |
|
1544 | setting with -d option. | |
1532 |
|
1545 | |||
1533 | * setup.py (docfiles): Fix problem where the doc glob I was using |
|
1546 | * setup.py (docfiles): Fix problem where the doc glob I was using | |
1534 | was COMPLETELY BROKEN. It was giving the right files by pure |
|
1547 | was COMPLETELY BROKEN. It was giving the right files by pure | |
1535 | accident, but failed once I tried to include ipython.el. Note: |
|
1548 | accident, but failed once I tried to include ipython.el. Note: | |
1536 | glob() does NOT allow you to do exclusion on multiple endings! |
|
1549 | glob() does NOT allow you to do exclusion on multiple endings! | |
1537 |
|
1550 | |||
1538 | 2004-11-29 Fernando Perez <fperez@colorado.edu> |
|
1551 | 2004-11-29 Fernando Perez <fperez@colorado.edu> | |
1539 |
|
1552 | |||
1540 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using |
|
1553 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using | |
1541 | the manpage as the source. Better formatting & consistency. |
|
1554 | the manpage as the source. Better formatting & consistency. | |
1542 |
|
1555 | |||
1543 | * IPython/Magic.py (magic_run): Added new -d option, to run |
|
1556 | * IPython/Magic.py (magic_run): Added new -d option, to run | |
1544 | scripts under the control of the python pdb debugger. Note that |
|
1557 | scripts under the control of the python pdb debugger. Note that | |
1545 | this required changing the %prun option -d to -D, to avoid a clash |
|
1558 | this required changing the %prun option -d to -D, to avoid a clash | |
1546 | (since %run must pass options to %prun, and getopt is too dumb to |
|
1559 | (since %run must pass options to %prun, and getopt is too dumb to | |
1547 | handle options with string values with embedded spaces). Thanks |
|
1560 | handle options with string values with embedded spaces). Thanks | |
1548 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. |
|
1561 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. | |
1549 | (magic_who_ls): added type matching to %who and %whos, so that one |
|
1562 | (magic_who_ls): added type matching to %who and %whos, so that one | |
1550 | can filter their output to only include variables of certain |
|
1563 | can filter their output to only include variables of certain | |
1551 | types. Another suggestion by Matthew. |
|
1564 | types. Another suggestion by Matthew. | |
1552 | (magic_whos): Added memory summaries in kb and Mb for arrays. |
|
1565 | (magic_whos): Added memory summaries in kb and Mb for arrays. | |
1553 | (magic_who): Improve formatting (break lines every 9 vars). |
|
1566 | (magic_who): Improve formatting (break lines every 9 vars). | |
1554 |
|
1567 | |||
1555 | 2004-11-28 Fernando Perez <fperez@colorado.edu> |
|
1568 | 2004-11-28 Fernando Perez <fperez@colorado.edu> | |
1556 |
|
1569 | |||
1557 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input |
|
1570 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input | |
1558 | cache when empty lines were present. |
|
1571 | cache when empty lines were present. | |
1559 |
|
1572 | |||
1560 | 2004-11-24 Fernando Perez <fperez@colorado.edu> |
|
1573 | 2004-11-24 Fernando Perez <fperez@colorado.edu> | |
1561 |
|
1574 | |||
1562 | * IPython/usage.py (__doc__): document the re-activated threading |
|
1575 | * IPython/usage.py (__doc__): document the re-activated threading | |
1563 | options for WX and GTK. |
|
1576 | options for WX and GTK. | |
1564 |
|
1577 | |||
1565 | 2004-11-23 Fernando Perez <fperez@colorado.edu> |
|
1578 | 2004-11-23 Fernando Perez <fperez@colorado.edu> | |
1566 |
|
1579 | |||
1567 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate |
|
1580 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate | |
1568 | the -wthread and -gthread options, along with a new -tk one to try |
|
1581 | the -wthread and -gthread options, along with a new -tk one to try | |
1569 | and coordinate Tk threading with wx/gtk. The tk support is very |
|
1582 | and coordinate Tk threading with wx/gtk. The tk support is very | |
1570 | platform dependent, since it seems to require Tcl and Tk to be |
|
1583 | platform dependent, since it seems to require Tcl and Tk to be | |
1571 | built with threads (Fedora1/2 appears NOT to have it, but in |
|
1584 | built with threads (Fedora1/2 appears NOT to have it, but in | |
1572 | Prabhu's Debian boxes it works OK). But even with some Tk |
|
1585 | Prabhu's Debian boxes it works OK). But even with some Tk | |
1573 | limitations, this is a great improvement. |
|
1586 | limitations, this is a great improvement. | |
1574 |
|
1587 | |||
1575 | * IPython/Prompts.py (prompt_specials_color): Added \t for time |
|
1588 | * IPython/Prompts.py (prompt_specials_color): Added \t for time | |
1576 | info in user prompts. Patch by Prabhu. |
|
1589 | info in user prompts. Patch by Prabhu. | |
1577 |
|
1590 | |||
1578 | 2004-11-18 Fernando Perez <fperez@colorado.edu> |
|
1591 | 2004-11-18 Fernando Perez <fperez@colorado.edu> | |
1579 |
|
1592 | |||
1580 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 |
|
1593 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 | |
1581 | EOFErrors and bail, to avoid infinite loops if a non-terminating |
|
1594 | EOFErrors and bail, to avoid infinite loops if a non-terminating | |
1582 | file is fed into ipython. Patch submitted in issue 19 by user, |
|
1595 | file is fed into ipython. Patch submitted in issue 19 by user, | |
1583 | many thanks. |
|
1596 | many thanks. | |
1584 |
|
1597 | |||
1585 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger |
|
1598 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger | |
1586 | autoquote/parens in continuation prompts, which can cause lots of |
|
1599 | autoquote/parens in continuation prompts, which can cause lots of | |
1587 | problems. Closes roundup issue 20. |
|
1600 | problems. Closes roundup issue 20. | |
1588 |
|
1601 | |||
1589 | 2004-11-17 Fernando Perez <fperez@colorado.edu> |
|
1602 | 2004-11-17 Fernando Perez <fperez@colorado.edu> | |
1590 |
|
1603 | |||
1591 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, |
|
1604 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, | |
1592 | reported as debian bug #280505. I'm not sure my local changelog |
|
1605 | reported as debian bug #280505. I'm not sure my local changelog | |
1593 | entry has the proper debian format (Jack?). |
|
1606 | entry has the proper debian format (Jack?). | |
1594 |
|
1607 | |||
1595 | 2004-11-08 *** Released version 0.6.4 |
|
1608 | 2004-11-08 *** Released version 0.6.4 | |
1596 |
|
1609 | |||
1597 | 2004-11-08 Fernando Perez <fperez@colorado.edu> |
|
1610 | 2004-11-08 Fernando Perez <fperez@colorado.edu> | |
1598 |
|
1611 | |||
1599 | * IPython/iplib.py (init_readline): Fix exit message for Windows |
|
1612 | * IPython/iplib.py (init_readline): Fix exit message for Windows | |
1600 | when readline is active. Thanks to a report by Eric Jones |
|
1613 | when readline is active. Thanks to a report by Eric Jones | |
1601 | <eric-AT-enthought.com>. |
|
1614 | <eric-AT-enthought.com>. | |
1602 |
|
1615 | |||
1603 | 2004-11-07 Fernando Perez <fperez@colorado.edu> |
|
1616 | 2004-11-07 Fernando Perez <fperez@colorado.edu> | |
1604 |
|
1617 | |||
1605 | * IPython/genutils.py (page): Add a trap for OSError exceptions, |
|
1618 | * IPython/genutils.py (page): Add a trap for OSError exceptions, | |
1606 | sometimes seen by win2k/cygwin users. |
|
1619 | sometimes seen by win2k/cygwin users. | |
1607 |
|
1620 | |||
1608 | 2004-11-06 Fernando Perez <fperez@colorado.edu> |
|
1621 | 2004-11-06 Fernando Perez <fperez@colorado.edu> | |
1609 |
|
1622 | |||
1610 | * IPython/iplib.py (interact): Change the handling of %Exit from |
|
1623 | * IPython/iplib.py (interact): Change the handling of %Exit from | |
1611 | trying to propagate a SystemExit to an internal ipython flag. |
|
1624 | trying to propagate a SystemExit to an internal ipython flag. | |
1612 | This is less elegant than using Python's exception mechanism, but |
|
1625 | This is less elegant than using Python's exception mechanism, but | |
1613 | I can't get that to work reliably with threads, so under -pylab |
|
1626 | I can't get that to work reliably with threads, so under -pylab | |
1614 | %Exit was hanging IPython. Cross-thread exception handling is |
|
1627 | %Exit was hanging IPython. Cross-thread exception handling is | |
1615 | really a bitch. Thaks to a bug report by Stephen Walton |
|
1628 | really a bitch. Thaks to a bug report by Stephen Walton | |
1616 | <stephen.walton-AT-csun.edu>. |
|
1629 | <stephen.walton-AT-csun.edu>. | |
1617 |
|
1630 | |||
1618 | 2004-11-04 Fernando Perez <fperez@colorado.edu> |
|
1631 | 2004-11-04 Fernando Perez <fperez@colorado.edu> | |
1619 |
|
1632 | |||
1620 | * IPython/iplib.py (raw_input_original): store a pointer to the |
|
1633 | * IPython/iplib.py (raw_input_original): store a pointer to the | |
1621 | true raw_input to harden against code which can modify it |
|
1634 | true raw_input to harden against code which can modify it | |
1622 | (wx.py.PyShell does this and would otherwise crash ipython). |
|
1635 | (wx.py.PyShell does this and would otherwise crash ipython). | |
1623 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. |
|
1636 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. | |
1624 |
|
1637 | |||
1625 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for |
|
1638 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for | |
1626 | Ctrl-C problem, which does not mess up the input line. |
|
1639 | Ctrl-C problem, which does not mess up the input line. | |
1627 |
|
1640 | |||
1628 | 2004-11-03 Fernando Perez <fperez@colorado.edu> |
|
1641 | 2004-11-03 Fernando Perez <fperez@colorado.edu> | |
1629 |
|
1642 | |||
1630 | * IPython/Release.py: Changed licensing to BSD, in all files. |
|
1643 | * IPython/Release.py: Changed licensing to BSD, in all files. | |
1631 | (name): lowercase name for tarball/RPM release. |
|
1644 | (name): lowercase name for tarball/RPM release. | |
1632 |
|
1645 | |||
1633 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for |
|
1646 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for | |
1634 | use throughout ipython. |
|
1647 | use throughout ipython. | |
1635 |
|
1648 | |||
1636 | * IPython/Magic.py (Magic._ofind): Switch to using the new |
|
1649 | * IPython/Magic.py (Magic._ofind): Switch to using the new | |
1637 | OInspect.getdoc() function. |
|
1650 | OInspect.getdoc() function. | |
1638 |
|
1651 | |||
1639 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution |
|
1652 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution | |
1640 | of the line currently being canceled via Ctrl-C. It's extremely |
|
1653 | of the line currently being canceled via Ctrl-C. It's extremely | |
1641 | ugly, but I don't know how to do it better (the problem is one of |
|
1654 | ugly, but I don't know how to do it better (the problem is one of | |
1642 | handling cross-thread exceptions). |
|
1655 | handling cross-thread exceptions). | |
1643 |
|
1656 | |||
1644 | 2004-10-28 Fernando Perez <fperez@colorado.edu> |
|
1657 | 2004-10-28 Fernando Perez <fperez@colorado.edu> | |
1645 |
|
1658 | |||
1646 | * IPython/Shell.py (signal_handler): add signal handlers to trap |
|
1659 | * IPython/Shell.py (signal_handler): add signal handlers to trap | |
1647 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug |
|
1660 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug | |
1648 | report by Francesc Alted. |
|
1661 | report by Francesc Alted. | |
1649 |
|
1662 | |||
1650 | 2004-10-21 Fernando Perez <fperez@colorado.edu> |
|
1663 | 2004-10-21 Fernando Perez <fperez@colorado.edu> | |
1651 |
|
1664 | |||
1652 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ |
|
1665 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ | |
1653 | to % for pysh syntax extensions. |
|
1666 | to % for pysh syntax extensions. | |
1654 |
|
1667 | |||
1655 | 2004-10-09 Fernando Perez <fperez@colorado.edu> |
|
1668 | 2004-10-09 Fernando Perez <fperez@colorado.edu> | |
1656 |
|
1669 | |||
1657 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric |
|
1670 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric | |
1658 | arrays to print a more useful summary, without calling str(arr). |
|
1671 | arrays to print a more useful summary, without calling str(arr). | |
1659 | This avoids the problem of extremely lengthy computations which |
|
1672 | This avoids the problem of extremely lengthy computations which | |
1660 | occur if arr is large, and appear to the user as a system lockup |
|
1673 | occur if arr is large, and appear to the user as a system lockup | |
1661 | with 100% cpu activity. After a suggestion by Kristian Sandberg |
|
1674 | with 100% cpu activity. After a suggestion by Kristian Sandberg | |
1662 | <Kristian.Sandberg@colorado.edu>. |
|
1675 | <Kristian.Sandberg@colorado.edu>. | |
1663 | (Magic.__init__): fix bug in global magic escapes not being |
|
1676 | (Magic.__init__): fix bug in global magic escapes not being | |
1664 | correctly set. |
|
1677 | correctly set. | |
1665 |
|
1678 | |||
1666 | 2004-10-08 Fernando Perez <fperez@colorado.edu> |
|
1679 | 2004-10-08 Fernando Perez <fperez@colorado.edu> | |
1667 |
|
1680 | |||
1668 | * IPython/Magic.py (__license__): change to absolute imports of |
|
1681 | * IPython/Magic.py (__license__): change to absolute imports of | |
1669 | ipython's own internal packages, to start adapting to the absolute |
|
1682 | ipython's own internal packages, to start adapting to the absolute | |
1670 | import requirement of PEP-328. |
|
1683 | import requirement of PEP-328. | |
1671 |
|
1684 | |||
1672 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all |
|
1685 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all | |
1673 | files, and standardize author/license marks through the Release |
|
1686 | files, and standardize author/license marks through the Release | |
1674 | module instead of having per/file stuff (except for files with |
|
1687 | module instead of having per/file stuff (except for files with | |
1675 | particular licenses, like the MIT/PSF-licensed codes). |
|
1688 | particular licenses, like the MIT/PSF-licensed codes). | |
1676 |
|
1689 | |||
1677 | * IPython/Debugger.py: remove dead code for python 2.1 |
|
1690 | * IPython/Debugger.py: remove dead code for python 2.1 | |
1678 |
|
1691 | |||
1679 | 2004-10-04 Fernando Perez <fperez@colorado.edu> |
|
1692 | 2004-10-04 Fernando Perez <fperez@colorado.edu> | |
1680 |
|
1693 | |||
1681 | * IPython/iplib.py (ipmagic): New function for accessing magics |
|
1694 | * IPython/iplib.py (ipmagic): New function for accessing magics | |
1682 | via a normal python function call. |
|
1695 | via a normal python function call. | |
1683 |
|
1696 | |||
1684 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape |
|
1697 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape | |
1685 | from '@' to '%', to accomodate the new @decorator syntax of python |
|
1698 | from '@' to '%', to accomodate the new @decorator syntax of python | |
1686 | 2.4. |
|
1699 | 2.4. | |
1687 |
|
1700 | |||
1688 | 2004-09-29 Fernando Perez <fperez@colorado.edu> |
|
1701 | 2004-09-29 Fernando Perez <fperez@colorado.edu> | |
1689 |
|
1702 | |||
1690 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to |
|
1703 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to | |
1691 | matplotlib.use to prevent running scripts which try to switch |
|
1704 | matplotlib.use to prevent running scripts which try to switch | |
1692 | interactive backends from within ipython. This will just crash |
|
1705 | interactive backends from within ipython. This will just crash | |
1693 | the python interpreter, so we can't allow it (but a detailed error |
|
1706 | the python interpreter, so we can't allow it (but a detailed error | |
1694 | is given to the user). |
|
1707 | is given to the user). | |
1695 |
|
1708 | |||
1696 | 2004-09-28 Fernando Perez <fperez@colorado.edu> |
|
1709 | 2004-09-28 Fernando Perez <fperez@colorado.edu> | |
1697 |
|
1710 | |||
1698 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): |
|
1711 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): | |
1699 | matplotlib-related fixes so that using @run with non-matplotlib |
|
1712 | matplotlib-related fixes so that using @run with non-matplotlib | |
1700 | scripts doesn't pop up spurious plot windows. This requires |
|
1713 | scripts doesn't pop up spurious plot windows. This requires | |
1701 | matplotlib >= 0.63, where I had to make some changes as well. |
|
1714 | matplotlib >= 0.63, where I had to make some changes as well. | |
1702 |
|
1715 | |||
1703 | * IPython/ipmaker.py (make_IPython): update version requirement to |
|
1716 | * IPython/ipmaker.py (make_IPython): update version requirement to | |
1704 | python 2.2. |
|
1717 | python 2.2. | |
1705 |
|
1718 | |||
1706 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional |
|
1719 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional | |
1707 | banner arg for embedded customization. |
|
1720 | banner arg for embedded customization. | |
1708 |
|
1721 | |||
1709 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all |
|
1722 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all | |
1710 | explicit uses of __IP as the IPython's instance name. Now things |
|
1723 | explicit uses of __IP as the IPython's instance name. Now things | |
1711 | are properly handled via the shell.name value. The actual code |
|
1724 | are properly handled via the shell.name value. The actual code | |
1712 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this |
|
1725 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this | |
1713 | is much better than before. I'll clean things completely when the |
|
1726 | is much better than before. I'll clean things completely when the | |
1714 | magic stuff gets a real overhaul. |
|
1727 | magic stuff gets a real overhaul. | |
1715 |
|
1728 | |||
1716 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in |
|
1729 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in | |
1717 | minor changes to debian dir. |
|
1730 | minor changes to debian dir. | |
1718 |
|
1731 | |||
1719 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a |
|
1732 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a | |
1720 | pointer to the shell itself in the interactive namespace even when |
|
1733 | pointer to the shell itself in the interactive namespace even when | |
1721 | a user-supplied dict is provided. This is needed for embedding |
|
1734 | a user-supplied dict is provided. This is needed for embedding | |
1722 | purposes (found by tests with Michel Sanner). |
|
1735 | purposes (found by tests with Michel Sanner). | |
1723 |
|
1736 | |||
1724 | 2004-09-27 Fernando Perez <fperez@colorado.edu> |
|
1737 | 2004-09-27 Fernando Perez <fperez@colorado.edu> | |
1725 |
|
1738 | |||
1726 | * IPython/UserConfig/ipythonrc: remove []{} from |
|
1739 | * IPython/UserConfig/ipythonrc: remove []{} from | |
1727 | readline_remove_delims, so that things like [modname.<TAB> do |
|
1740 | readline_remove_delims, so that things like [modname.<TAB> do | |
1728 | proper completion. This disables [].TAB, but that's a less common |
|
1741 | proper completion. This disables [].TAB, but that's a less common | |
1729 | case than module names in list comprehensions, for example. |
|
1742 | case than module names in list comprehensions, for example. | |
1730 | Thanks to a report by Andrea Riciputi. |
|
1743 | Thanks to a report by Andrea Riciputi. | |
1731 |
|
1744 | |||
1732 | 2004-09-09 Fernando Perez <fperez@colorado.edu> |
|
1745 | 2004-09-09 Fernando Perez <fperez@colorado.edu> | |
1733 |
|
1746 | |||
1734 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid |
|
1747 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid | |
1735 | blocking problems in win32 and osx. Fix by John. |
|
1748 | blocking problems in win32 and osx. Fix by John. | |
1736 |
|
1749 | |||
1737 | 2004-09-08 Fernando Perez <fperez@colorado.edu> |
|
1750 | 2004-09-08 Fernando Perez <fperez@colorado.edu> | |
1738 |
|
1751 | |||
1739 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug |
|
1752 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug | |
1740 | for Win32 and OSX. Fix by John Hunter. |
|
1753 | for Win32 and OSX. Fix by John Hunter. | |
1741 |
|
1754 | |||
1742 | 2004-08-30 *** Released version 0.6.3 |
|
1755 | 2004-08-30 *** Released version 0.6.3 | |
1743 |
|
1756 | |||
1744 | 2004-08-30 Fernando Perez <fperez@colorado.edu> |
|
1757 | 2004-08-30 Fernando Perez <fperez@colorado.edu> | |
1745 |
|
1758 | |||
1746 | * setup.py (isfile): Add manpages to list of dependent files to be |
|
1759 | * setup.py (isfile): Add manpages to list of dependent files to be | |
1747 | updated. |
|
1760 | updated. | |
1748 |
|
1761 | |||
1749 | 2004-08-27 Fernando Perez <fperez@colorado.edu> |
|
1762 | 2004-08-27 Fernando Perez <fperez@colorado.edu> | |
1750 |
|
1763 | |||
1751 | * IPython/Shell.py (start): I've disabled -wthread and -gthread |
|
1764 | * IPython/Shell.py (start): I've disabled -wthread and -gthread | |
1752 | for now. They don't really work with standalone WX/GTK code |
|
1765 | for now. They don't really work with standalone WX/GTK code | |
1753 | (though matplotlib IS working fine with both of those backends). |
|
1766 | (though matplotlib IS working fine with both of those backends). | |
1754 | This will neeed much more testing. I disabled most things with |
|
1767 | This will neeed much more testing. I disabled most things with | |
1755 | comments, so turning it back on later should be pretty easy. |
|
1768 | comments, so turning it back on later should be pretty easy. | |
1756 |
|
1769 | |||
1757 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental |
|
1770 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental | |
1758 | autocalling of expressions like r'foo', by modifying the line |
|
1771 | autocalling of expressions like r'foo', by modifying the line | |
1759 | split regexp. Closes |
|
1772 | split regexp. Closes | |
1760 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas |
|
1773 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas | |
1761 | Riley <ipythonbugs-AT-sabi.net>. |
|
1774 | Riley <ipythonbugs-AT-sabi.net>. | |
1762 | (InteractiveShell.mainloop): honor --nobanner with banner |
|
1775 | (InteractiveShell.mainloop): honor --nobanner with banner | |
1763 | extensions. |
|
1776 | extensions. | |
1764 |
|
1777 | |||
1765 | * IPython/Shell.py: Significant refactoring of all classes, so |
|
1778 | * IPython/Shell.py: Significant refactoring of all classes, so | |
1766 | that we can really support ALL matplotlib backends and threading |
|
1779 | that we can really support ALL matplotlib backends and threading | |
1767 | models (John spotted a bug with Tk which required this). Now we |
|
1780 | models (John spotted a bug with Tk which required this). Now we | |
1768 | should support single-threaded, WX-threads and GTK-threads, both |
|
1781 | should support single-threaded, WX-threads and GTK-threads, both | |
1769 | for generic code and for matplotlib. |
|
1782 | for generic code and for matplotlib. | |
1770 |
|
1783 | |||
1771 | * IPython/ipmaker.py (__call__): Changed -mpthread option to |
|
1784 | * IPython/ipmaker.py (__call__): Changed -mpthread option to | |
1772 | -pylab, to simplify things for users. Will also remove the pylab |
|
1785 | -pylab, to simplify things for users. Will also remove the pylab | |
1773 | profile, since now all of matplotlib configuration is directly |
|
1786 | profile, since now all of matplotlib configuration is directly | |
1774 | handled here. This also reduces startup time. |
|
1787 | handled here. This also reduces startup time. | |
1775 |
|
1788 | |||
1776 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of |
|
1789 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of | |
1777 | shell wasn't being correctly called. Also in IPShellWX. |
|
1790 | shell wasn't being correctly called. Also in IPShellWX. | |
1778 |
|
1791 | |||
1779 | * IPython/iplib.py (InteractiveShell.__init__): Added option to |
|
1792 | * IPython/iplib.py (InteractiveShell.__init__): Added option to | |
1780 | fine-tune banner. |
|
1793 | fine-tune banner. | |
1781 |
|
1794 | |||
1782 | * IPython/numutils.py (spike): Deprecate these spike functions, |
|
1795 | * IPython/numutils.py (spike): Deprecate these spike functions, | |
1783 | delete (long deprecated) gnuplot_exec handler. |
|
1796 | delete (long deprecated) gnuplot_exec handler. | |
1784 |
|
1797 | |||
1785 | 2004-08-26 Fernando Perez <fperez@colorado.edu> |
|
1798 | 2004-08-26 Fernando Perez <fperez@colorado.edu> | |
1786 |
|
1799 | |||
1787 | * ipython.1: Update for threading options, plus some others which |
|
1800 | * ipython.1: Update for threading options, plus some others which | |
1788 | were missing. |
|
1801 | were missing. | |
1789 |
|
1802 | |||
1790 | * IPython/ipmaker.py (__call__): Added -wthread option for |
|
1803 | * IPython/ipmaker.py (__call__): Added -wthread option for | |
1791 | wxpython thread handling. Make sure threading options are only |
|
1804 | wxpython thread handling. Make sure threading options are only | |
1792 | valid at the command line. |
|
1805 | valid at the command line. | |
1793 |
|
1806 | |||
1794 | * scripts/ipython: moved shell selection into a factory function |
|
1807 | * scripts/ipython: moved shell selection into a factory function | |
1795 | in Shell.py, to keep the starter script to a minimum. |
|
1808 | in Shell.py, to keep the starter script to a minimum. | |
1796 |
|
1809 | |||
1797 | 2004-08-25 Fernando Perez <fperez@colorado.edu> |
|
1810 | 2004-08-25 Fernando Perez <fperez@colorado.edu> | |
1798 |
|
1811 | |||
1799 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by |
|
1812 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by | |
1800 | John. Along with some recent changes he made to matplotlib, the |
|
1813 | John. Along with some recent changes he made to matplotlib, the | |
1801 | next versions of both systems should work very well together. |
|
1814 | next versions of both systems should work very well together. | |
1802 |
|
1815 | |||
1803 | 2004-08-24 Fernando Perez <fperez@colorado.edu> |
|
1816 | 2004-08-24 Fernando Perez <fperez@colorado.edu> | |
1804 |
|
1817 | |||
1805 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I |
|
1818 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I | |
1806 | tried to switch the profiling to using hotshot, but I'm getting |
|
1819 | tried to switch the profiling to using hotshot, but I'm getting | |
1807 | strange errors from prof.runctx() there. I may be misreading the |
|
1820 | strange errors from prof.runctx() there. I may be misreading the | |
1808 | docs, but it looks weird. For now the profiling code will |
|
1821 | docs, but it looks weird. For now the profiling code will | |
1809 | continue to use the standard profiler. |
|
1822 | continue to use the standard profiler. | |
1810 |
|
1823 | |||
1811 | 2004-08-23 Fernando Perez <fperez@colorado.edu> |
|
1824 | 2004-08-23 Fernando Perez <fperez@colorado.edu> | |
1812 |
|
1825 | |||
1813 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX |
|
1826 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX | |
1814 | threaded shell, by John Hunter. It's not quite ready yet, but |
|
1827 | threaded shell, by John Hunter. It's not quite ready yet, but | |
1815 | close. |
|
1828 | close. | |
1816 |
|
1829 | |||
1817 | 2004-08-22 Fernando Perez <fperez@colorado.edu> |
|
1830 | 2004-08-22 Fernando Perez <fperez@colorado.edu> | |
1818 |
|
1831 | |||
1819 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also |
|
1832 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also | |
1820 | in Magic and ultraTB. |
|
1833 | in Magic and ultraTB. | |
1821 |
|
1834 | |||
1822 | * ipython.1: document threading options in manpage. |
|
1835 | * ipython.1: document threading options in manpage. | |
1823 |
|
1836 | |||
1824 | * scripts/ipython: Changed name of -thread option to -gthread, |
|
1837 | * scripts/ipython: Changed name of -thread option to -gthread, | |
1825 | since this is GTK specific. I want to leave the door open for a |
|
1838 | since this is GTK specific. I want to leave the door open for a | |
1826 | -wthread option for WX, which will most likely be necessary. This |
|
1839 | -wthread option for WX, which will most likely be necessary. This | |
1827 | change affects usage and ipmaker as well. |
|
1840 | change affects usage and ipmaker as well. | |
1828 |
|
1841 | |||
1829 | * IPython/Shell.py (matplotlib_shell): Add a factory function to |
|
1842 | * IPython/Shell.py (matplotlib_shell): Add a factory function to | |
1830 | handle the matplotlib shell issues. Code by John Hunter |
|
1843 | handle the matplotlib shell issues. Code by John Hunter | |
1831 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
1844 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
1832 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's |
|
1845 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's | |
1833 | broken (and disabled for end users) for now, but it puts the |
|
1846 | broken (and disabled for end users) for now, but it puts the | |
1834 | infrastructure in place. |
|
1847 | infrastructure in place. | |
1835 |
|
1848 | |||
1836 | 2004-08-21 Fernando Perez <fperez@colorado.edu> |
|
1849 | 2004-08-21 Fernando Perez <fperez@colorado.edu> | |
1837 |
|
1850 | |||
1838 | * ipythonrc-pylab: Add matplotlib support. |
|
1851 | * ipythonrc-pylab: Add matplotlib support. | |
1839 |
|
1852 | |||
1840 | * matplotlib_config.py: new files for matplotlib support, part of |
|
1853 | * matplotlib_config.py: new files for matplotlib support, part of | |
1841 | the pylab profile. |
|
1854 | the pylab profile. | |
1842 |
|
1855 | |||
1843 | * IPython/usage.py (__doc__): documented the threading options. |
|
1856 | * IPython/usage.py (__doc__): documented the threading options. | |
1844 |
|
1857 | |||
1845 | 2004-08-20 Fernando Perez <fperez@colorado.edu> |
|
1858 | 2004-08-20 Fernando Perez <fperez@colorado.edu> | |
1846 |
|
1859 | |||
1847 | * ipython: Modified the main calling routine to handle the -thread |
|
1860 | * ipython: Modified the main calling routine to handle the -thread | |
1848 | and -mpthread options. This needs to be done as a top-level hack, |
|
1861 | and -mpthread options. This needs to be done as a top-level hack, | |
1849 | because it determines which class to instantiate for IPython |
|
1862 | because it determines which class to instantiate for IPython | |
1850 | itself. |
|
1863 | itself. | |
1851 |
|
1864 | |||
1852 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of |
|
1865 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of | |
1853 | classes to support multithreaded GTK operation without blocking, |
|
1866 | classes to support multithreaded GTK operation without blocking, | |
1854 | and matplotlib with all backends. This is a lot of still very |
|
1867 | and matplotlib with all backends. This is a lot of still very | |
1855 | experimental code, and threads are tricky. So it may still have a |
|
1868 | experimental code, and threads are tricky. So it may still have a | |
1856 | few rough edges... This code owes a lot to |
|
1869 | few rough edges... This code owes a lot to | |
1857 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by |
|
1870 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by | |
1858 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and |
|
1871 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and | |
1859 | to John Hunter for all the matplotlib work. |
|
1872 | to John Hunter for all the matplotlib work. | |
1860 |
|
1873 | |||
1861 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread |
|
1874 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread | |
1862 | options for gtk thread and matplotlib support. |
|
1875 | options for gtk thread and matplotlib support. | |
1863 |
|
1876 | |||
1864 | 2004-08-16 Fernando Perez <fperez@colorado.edu> |
|
1877 | 2004-08-16 Fernando Perez <fperez@colorado.edu> | |
1865 |
|
1878 | |||
1866 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger |
|
1879 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger | |
1867 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug |
|
1880 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug | |
1868 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. |
|
1881 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. | |
1869 |
|
1882 | |||
1870 | 2004-08-11 Fernando Perez <fperez@colorado.edu> |
|
1883 | 2004-08-11 Fernando Perez <fperez@colorado.edu> | |
1871 |
|
1884 | |||
1872 | * setup.py (isfile): Fix build so documentation gets updated for |
|
1885 | * setup.py (isfile): Fix build so documentation gets updated for | |
1873 | rpms (it was only done for .tgz builds). |
|
1886 | rpms (it was only done for .tgz builds). | |
1874 |
|
1887 | |||
1875 | 2004-08-10 Fernando Perez <fperez@colorado.edu> |
|
1888 | 2004-08-10 Fernando Perez <fperez@colorado.edu> | |
1876 |
|
1889 | |||
1877 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). |
|
1890 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). | |
1878 |
|
1891 | |||
1879 | * iplib.py : Silence syntax error exceptions in tab-completion. |
|
1892 | * iplib.py : Silence syntax error exceptions in tab-completion. | |
1880 |
|
1893 | |||
1881 | 2004-08-05 Fernando Perez <fperez@colorado.edu> |
|
1894 | 2004-08-05 Fernando Perez <fperez@colorado.edu> | |
1882 |
|
1895 | |||
1883 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set |
|
1896 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set | |
1884 | 'color off' mark for continuation prompts. This was causing long |
|
1897 | 'color off' mark for continuation prompts. This was causing long | |
1885 | continuation lines to mis-wrap. |
|
1898 | continuation lines to mis-wrap. | |
1886 |
|
1899 | |||
1887 | 2004-08-01 Fernando Perez <fperez@colorado.edu> |
|
1900 | 2004-08-01 Fernando Perez <fperez@colorado.edu> | |
1888 |
|
1901 | |||
1889 | * IPython/ipmaker.py (make_IPython): Allow the shell class used |
|
1902 | * IPython/ipmaker.py (make_IPython): Allow the shell class used | |
1890 | for building ipython to be a parameter. All this is necessary |
|
1903 | for building ipython to be a parameter. All this is necessary | |
1891 | right now to have a multithreaded version, but this insane |
|
1904 | right now to have a multithreaded version, but this insane | |
1892 | non-design will be cleaned up soon. For now, it's a hack that |
|
1905 | non-design will be cleaned up soon. For now, it's a hack that | |
1893 | works. |
|
1906 | works. | |
1894 |
|
1907 | |||
1895 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default |
|
1908 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default | |
1896 | args in various places. No bugs so far, but it's a dangerous |
|
1909 | args in various places. No bugs so far, but it's a dangerous | |
1897 | practice. |
|
1910 | practice. | |
1898 |
|
1911 | |||
1899 | 2004-07-31 Fernando Perez <fperez@colorado.edu> |
|
1912 | 2004-07-31 Fernando Perez <fperez@colorado.edu> | |
1900 |
|
1913 | |||
1901 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to |
|
1914 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to | |
1902 | fix completion of files with dots in their names under most |
|
1915 | fix completion of files with dots in their names under most | |
1903 | profiles (pysh was OK because the completion order is different). |
|
1916 | profiles (pysh was OK because the completion order is different). | |
1904 |
|
1917 | |||
1905 | 2004-07-27 Fernando Perez <fperez@colorado.edu> |
|
1918 | 2004-07-27 Fernando Perez <fperez@colorado.edu> | |
1906 |
|
1919 | |||
1907 | * IPython/iplib.py (InteractiveShell.__init__): build dict of |
|
1920 | * IPython/iplib.py (InteractiveShell.__init__): build dict of | |
1908 | keywords manually, b/c the one in keyword.py was removed in python |
|
1921 | keywords manually, b/c the one in keyword.py was removed in python | |
1909 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. |
|
1922 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. | |
1910 | This is NOT a bug under python 2.3 and earlier. |
|
1923 | This is NOT a bug under python 2.3 and earlier. | |
1911 |
|
1924 | |||
1912 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1925 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1913 |
|
1926 | |||
1914 | * IPython/ultraTB.py (VerboseTB.text): Add another |
|
1927 | * IPython/ultraTB.py (VerboseTB.text): Add another | |
1915 | linecache.checkcache() call to try to prevent inspect.py from |
|
1928 | linecache.checkcache() call to try to prevent inspect.py from | |
1916 | crashing under python 2.3. I think this fixes |
|
1929 | crashing under python 2.3. I think this fixes | |
1917 | http://www.scipy.net/roundup/ipython/issue17. |
|
1930 | http://www.scipy.net/roundup/ipython/issue17. | |
1918 |
|
1931 | |||
1919 | 2004-07-26 *** Released version 0.6.2 |
|
1932 | 2004-07-26 *** Released version 0.6.2 | |
1920 |
|
1933 | |||
1921 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1934 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1922 |
|
1935 | |||
1923 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would |
|
1936 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would | |
1924 | fail for any number. |
|
1937 | fail for any number. | |
1925 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for |
|
1938 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for | |
1926 | empty bookmarks. |
|
1939 | empty bookmarks. | |
1927 |
|
1940 | |||
1928 | 2004-07-26 *** Released version 0.6.1 |
|
1941 | 2004-07-26 *** Released version 0.6.1 | |
1929 |
|
1942 | |||
1930 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1943 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1931 |
|
1944 | |||
1932 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. |
|
1945 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. | |
1933 |
|
1946 | |||
1934 | * IPython/iplib.py (protect_filename): Applied Ville's patch for |
|
1947 | * IPython/iplib.py (protect_filename): Applied Ville's patch for | |
1935 | escaping '()[]{}' in filenames. |
|
1948 | escaping '()[]{}' in filenames. | |
1936 |
|
1949 | |||
1937 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for |
|
1950 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for | |
1938 | Python 2.2 users who lack a proper shlex.split. |
|
1951 | Python 2.2 users who lack a proper shlex.split. | |
1939 |
|
1952 | |||
1940 | 2004-07-19 Fernando Perez <fperez@colorado.edu> |
|
1953 | 2004-07-19 Fernando Perez <fperez@colorado.edu> | |
1941 |
|
1954 | |||
1942 | * IPython/iplib.py (InteractiveShell.init_readline): Add support |
|
1955 | * IPython/iplib.py (InteractiveShell.init_readline): Add support | |
1943 | for reading readline's init file. I follow the normal chain: |
|
1956 | for reading readline's init file. I follow the normal chain: | |
1944 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a |
|
1957 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a | |
1945 | report by Mike Heeter. This closes |
|
1958 | report by Mike Heeter. This closes | |
1946 | http://www.scipy.net/roundup/ipython/issue16. |
|
1959 | http://www.scipy.net/roundup/ipython/issue16. | |
1947 |
|
1960 | |||
1948 | 2004-07-18 Fernando Perez <fperez@colorado.edu> |
|
1961 | 2004-07-18 Fernando Perez <fperez@colorado.edu> | |
1949 |
|
1962 | |||
1950 | * IPython/iplib.py (__init__): Add better handling of '\' under |
|
1963 | * IPython/iplib.py (__init__): Add better handling of '\' under | |
1951 | Win32 for filenames. After a patch by Ville. |
|
1964 | Win32 for filenames. After a patch by Ville. | |
1952 |
|
1965 | |||
1953 | 2004-07-17 Fernando Perez <fperez@colorado.edu> |
|
1966 | 2004-07-17 Fernando Perez <fperez@colorado.edu> | |
1954 |
|
1967 | |||
1955 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
1968 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
1956 | autocalling would be triggered for 'foo is bar' if foo is |
|
1969 | autocalling would be triggered for 'foo is bar' if foo is | |
1957 | callable. I also cleaned up the autocall detection code to use a |
|
1970 | callable. I also cleaned up the autocall detection code to use a | |
1958 | regexp, which is faster. Bug reported by Alexander Schmolck. |
|
1971 | regexp, which is faster. Bug reported by Alexander Schmolck. | |
1959 |
|
1972 | |||
1960 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with |
|
1973 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with | |
1961 | '?' in them would confuse the help system. Reported by Alex |
|
1974 | '?' in them would confuse the help system. Reported by Alex | |
1962 | Schmolck. |
|
1975 | Schmolck. | |
1963 |
|
1976 | |||
1964 | 2004-07-16 Fernando Perez <fperez@colorado.edu> |
|
1977 | 2004-07-16 Fernando Perez <fperez@colorado.edu> | |
1965 |
|
1978 | |||
1966 | * IPython/GnuplotInteractive.py (__all__): added plot2. |
|
1979 | * IPython/GnuplotInteractive.py (__all__): added plot2. | |
1967 |
|
1980 | |||
1968 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for |
|
1981 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for | |
1969 | plotting dictionaries, lists or tuples of 1d arrays. |
|
1982 | plotting dictionaries, lists or tuples of 1d arrays. | |
1970 |
|
1983 | |||
1971 | * IPython/Magic.py (Magic.magic_hist): small clenaups and |
|
1984 | * IPython/Magic.py (Magic.magic_hist): small clenaups and | |
1972 | optimizations. |
|
1985 | optimizations. | |
1973 |
|
1986 | |||
1974 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is |
|
1987 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is | |
1975 | the information which was there from Janko's original IPP code: |
|
1988 | the information which was there from Janko's original IPP code: | |
1976 |
|
1989 | |||
1977 | 03.05.99 20:53 porto.ifm.uni-kiel.de |
|
1990 | 03.05.99 20:53 porto.ifm.uni-kiel.de | |
1978 | --Started changelog. |
|
1991 | --Started changelog. | |
1979 | --make clear do what it say it does |
|
1992 | --make clear do what it say it does | |
1980 | --added pretty output of lines from inputcache |
|
1993 | --added pretty output of lines from inputcache | |
1981 | --Made Logger a mixin class, simplifies handling of switches |
|
1994 | --Made Logger a mixin class, simplifies handling of switches | |
1982 | --Added own completer class. .string<TAB> expands to last history |
|
1995 | --Added own completer class. .string<TAB> expands to last history | |
1983 | line which starts with string. The new expansion is also present |
|
1996 | line which starts with string. The new expansion is also present | |
1984 | with Ctrl-r from the readline library. But this shows, who this |
|
1997 | with Ctrl-r from the readline library. But this shows, who this | |
1985 | can be done for other cases. |
|
1998 | can be done for other cases. | |
1986 | --Added convention that all shell functions should accept a |
|
1999 | --Added convention that all shell functions should accept a | |
1987 | parameter_string This opens the door for different behaviour for |
|
2000 | parameter_string This opens the door for different behaviour for | |
1988 | each function. @cd is a good example of this. |
|
2001 | each function. @cd is a good example of this. | |
1989 |
|
2002 | |||
1990 | 04.05.99 12:12 porto.ifm.uni-kiel.de |
|
2003 | 04.05.99 12:12 porto.ifm.uni-kiel.de | |
1991 | --added logfile rotation |
|
2004 | --added logfile rotation | |
1992 | --added new mainloop method which freezes first the namespace |
|
2005 | --added new mainloop method which freezes first the namespace | |
1993 |
|
2006 | |||
1994 | 07.05.99 21:24 porto.ifm.uni-kiel.de |
|
2007 | 07.05.99 21:24 porto.ifm.uni-kiel.de | |
1995 | --added the docreader classes. Now there is a help system. |
|
2008 | --added the docreader classes. Now there is a help system. | |
1996 | -This is only a first try. Currently it's not easy to put new |
|
2009 | -This is only a first try. Currently it's not easy to put new | |
1997 | stuff in the indices. But this is the way to go. Info would be |
|
2010 | stuff in the indices. But this is the way to go. Info would be | |
1998 | better, but HTML is every where and not everybody has an info |
|
2011 | better, but HTML is every where and not everybody has an info | |
1999 | system installed and it's not so easy to change html-docs to info. |
|
2012 | system installed and it's not so easy to change html-docs to info. | |
2000 | --added global logfile option |
|
2013 | --added global logfile option | |
2001 | --there is now a hook for object inspection method pinfo needs to |
|
2014 | --there is now a hook for object inspection method pinfo needs to | |
2002 | be provided for this. Can be reached by two '??'. |
|
2015 | be provided for this. Can be reached by two '??'. | |
2003 |
|
2016 | |||
2004 | 08.05.99 20:51 porto.ifm.uni-kiel.de |
|
2017 | 08.05.99 20:51 porto.ifm.uni-kiel.de | |
2005 | --added a README |
|
2018 | --added a README | |
2006 | --bug in rc file. Something has changed so functions in the rc |
|
2019 | --bug in rc file. Something has changed so functions in the rc | |
2007 | file need to reference the shell and not self. Not clear if it's a |
|
2020 | file need to reference the shell and not self. Not clear if it's a | |
2008 | bug or feature. |
|
2021 | bug or feature. | |
2009 | --changed rc file for new behavior |
|
2022 | --changed rc file for new behavior | |
2010 |
|
2023 | |||
2011 | 2004-07-15 Fernando Perez <fperez@colorado.edu> |
|
2024 | 2004-07-15 Fernando Perez <fperez@colorado.edu> | |
2012 |
|
2025 | |||
2013 | * IPython/Logger.py (Logger.log): fixed recent bug where the input |
|
2026 | * IPython/Logger.py (Logger.log): fixed recent bug where the input | |
2014 | cache was falling out of sync in bizarre manners when multi-line |
|
2027 | cache was falling out of sync in bizarre manners when multi-line | |
2015 | input was present. Minor optimizations and cleanup. |
|
2028 | input was present. Minor optimizations and cleanup. | |
2016 |
|
2029 | |||
2017 | (Logger): Remove old Changelog info for cleanup. This is the |
|
2030 | (Logger): Remove old Changelog info for cleanup. This is the | |
2018 | information which was there from Janko's original code: |
|
2031 | information which was there from Janko's original code: | |
2019 |
|
2032 | |||
2020 | Changes to Logger: - made the default log filename a parameter |
|
2033 | Changes to Logger: - made the default log filename a parameter | |
2021 |
|
2034 | |||
2022 | - put a check for lines beginning with !@? in log(). Needed |
|
2035 | - put a check for lines beginning with !@? in log(). Needed | |
2023 | (even if the handlers properly log their lines) for mid-session |
|
2036 | (even if the handlers properly log their lines) for mid-session | |
2024 | logging activation to work properly. Without this, lines logged |
|
2037 | logging activation to work properly. Without this, lines logged | |
2025 | in mid session, which get read from the cache, would end up |
|
2038 | in mid session, which get read from the cache, would end up | |
2026 | 'bare' (with !@? in the open) in the log. Now they are caught |
|
2039 | 'bare' (with !@? in the open) in the log. Now they are caught | |
2027 | and prepended with a #. |
|
2040 | and prepended with a #. | |
2028 |
|
2041 | |||
2029 | * IPython/iplib.py (InteractiveShell.init_readline): added check |
|
2042 | * IPython/iplib.py (InteractiveShell.init_readline): added check | |
2030 | in case MagicCompleter fails to be defined, so we don't crash. |
|
2043 | in case MagicCompleter fails to be defined, so we don't crash. | |
2031 |
|
2044 | |||
2032 | 2004-07-13 Fernando Perez <fperez@colorado.edu> |
|
2045 | 2004-07-13 Fernando Perez <fperez@colorado.edu> | |
2033 |
|
2046 | |||
2034 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation |
|
2047 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation | |
2035 | of EPS if the requested filename ends in '.eps'. |
|
2048 | of EPS if the requested filename ends in '.eps'. | |
2036 |
|
2049 | |||
2037 | 2004-07-04 Fernando Perez <fperez@colorado.edu> |
|
2050 | 2004-07-04 Fernando Perez <fperez@colorado.edu> | |
2038 |
|
2051 | |||
2039 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix |
|
2052 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix | |
2040 | escaping of quotes when calling the shell. |
|
2053 | escaping of quotes when calling the shell. | |
2041 |
|
2054 | |||
2042 | 2004-07-02 Fernando Perez <fperez@colorado.edu> |
|
2055 | 2004-07-02 Fernando Perez <fperez@colorado.edu> | |
2043 |
|
2056 | |||
2044 | * IPython/Prompts.py (CachedOutput.update): Fix problem with |
|
2057 | * IPython/Prompts.py (CachedOutput.update): Fix problem with | |
2045 | gettext not working because we were clobbering '_'. Fixes |
|
2058 | gettext not working because we were clobbering '_'. Fixes | |
2046 | http://www.scipy.net/roundup/ipython/issue6. |
|
2059 | http://www.scipy.net/roundup/ipython/issue6. | |
2047 |
|
2060 | |||
2048 | 2004-07-01 Fernando Perez <fperez@colorado.edu> |
|
2061 | 2004-07-01 Fernando Perez <fperez@colorado.edu> | |
2049 |
|
2062 | |||
2050 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling |
|
2063 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling | |
2051 | into @cd. Patch by Ville. |
|
2064 | into @cd. Patch by Ville. | |
2052 |
|
2065 | |||
2053 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
2066 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
2054 | new function to store things after ipmaker runs. Patch by Ville. |
|
2067 | new function to store things after ipmaker runs. Patch by Ville. | |
2055 | Eventually this will go away once ipmaker is removed and the class |
|
2068 | Eventually this will go away once ipmaker is removed and the class | |
2056 | gets cleaned up, but for now it's ok. Key functionality here is |
|
2069 | gets cleaned up, but for now it's ok. Key functionality here is | |
2057 | the addition of the persistent storage mechanism, a dict for |
|
2070 | the addition of the persistent storage mechanism, a dict for | |
2058 | keeping data across sessions (for now just bookmarks, but more can |
|
2071 | keeping data across sessions (for now just bookmarks, but more can | |
2059 | be implemented later). |
|
2072 | be implemented later). | |
2060 |
|
2073 | |||
2061 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, |
|
2074 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, | |
2062 | persistent across sections. Patch by Ville, I modified it |
|
2075 | persistent across sections. Patch by Ville, I modified it | |
2063 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also |
|
2076 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also | |
2064 | added a '-l' option to list all bookmarks. |
|
2077 | added a '-l' option to list all bookmarks. | |
2065 |
|
2078 | |||
2066 | * IPython/iplib.py (InteractiveShell.atexit_operations): new |
|
2079 | * IPython/iplib.py (InteractiveShell.atexit_operations): new | |
2067 | center for cleanup. Registered with atexit.register(). I moved |
|
2080 | center for cleanup. Registered with atexit.register(). I moved | |
2068 | here the old exit_cleanup(). After a patch by Ville. |
|
2081 | here the old exit_cleanup(). After a patch by Ville. | |
2069 |
|
2082 | |||
2070 | * IPython/Magic.py (get_py_filename): added '~' to the accepted |
|
2083 | * IPython/Magic.py (get_py_filename): added '~' to the accepted | |
2071 | characters in the hacked shlex_split for python 2.2. |
|
2084 | characters in the hacked shlex_split for python 2.2. | |
2072 |
|
2085 | |||
2073 | * IPython/iplib.py (file_matches): more fixes to filenames with |
|
2086 | * IPython/iplib.py (file_matches): more fixes to filenames with | |
2074 | whitespace in them. It's not perfect, but limitations in python's |
|
2087 | whitespace in them. It's not perfect, but limitations in python's | |
2075 | readline make it impossible to go further. |
|
2088 | readline make it impossible to go further. | |
2076 |
|
2089 | |||
2077 | 2004-06-29 Fernando Perez <fperez@colorado.edu> |
|
2090 | 2004-06-29 Fernando Perez <fperez@colorado.edu> | |
2078 |
|
2091 | |||
2079 | * IPython/iplib.py (file_matches): escape whitespace correctly in |
|
2092 | * IPython/iplib.py (file_matches): escape whitespace correctly in | |
2080 | filename completions. Bug reported by Ville. |
|
2093 | filename completions. Bug reported by Ville. | |
2081 |
|
2094 | |||
2082 | 2004-06-28 Fernando Perez <fperez@colorado.edu> |
|
2095 | 2004-06-28 Fernando Perez <fperez@colorado.edu> | |
2083 |
|
2096 | |||
2084 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now |
|
2097 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now | |
2085 | the history file will be called 'history-PROFNAME' (or just |
|
2098 | the history file will be called 'history-PROFNAME' (or just | |
2086 | 'history' if no profile is loaded). I was getting annoyed at |
|
2099 | 'history' if no profile is loaded). I was getting annoyed at | |
2087 | getting my Numerical work history clobbered by pysh sessions. |
|
2100 | getting my Numerical work history clobbered by pysh sessions. | |
2088 |
|
2101 | |||
2089 | * IPython/iplib.py (InteractiveShell.__init__): Internal |
|
2102 | * IPython/iplib.py (InteractiveShell.__init__): Internal | |
2090 | getoutputerror() function so that we can honor the system_verbose |
|
2103 | getoutputerror() function so that we can honor the system_verbose | |
2091 | flag for _all_ system calls. I also added escaping of # |
|
2104 | flag for _all_ system calls. I also added escaping of # | |
2092 | characters here to avoid confusing Itpl. |
|
2105 | characters here to avoid confusing Itpl. | |
2093 |
|
2106 | |||
2094 | * IPython/Magic.py (shlex_split): removed call to shell in |
|
2107 | * IPython/Magic.py (shlex_split): removed call to shell in | |
2095 | parse_options and replaced it with shlex.split(). The annoying |
|
2108 | parse_options and replaced it with shlex.split(). The annoying | |
2096 | part was that in Python 2.2, shlex.split() doesn't exist, so I had |
|
2109 | part was that in Python 2.2, shlex.split() doesn't exist, so I had | |
2097 | to backport it from 2.3, with several frail hacks (the shlex |
|
2110 | to backport it from 2.3, with several frail hacks (the shlex | |
2098 | module is rather limited in 2.2). Thanks to a suggestion by Ville |
|
2111 | module is rather limited in 2.2). Thanks to a suggestion by Ville | |
2099 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no |
|
2112 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no | |
2100 | problem. |
|
2113 | problem. | |
2101 |
|
2114 | |||
2102 | (Magic.magic_system_verbose): new toggle to print the actual |
|
2115 | (Magic.magic_system_verbose): new toggle to print the actual | |
2103 | system calls made by ipython. Mainly for debugging purposes. |
|
2116 | system calls made by ipython. Mainly for debugging purposes. | |
2104 |
|
2117 | |||
2105 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which |
|
2118 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which | |
2106 | doesn't support persistence. Reported (and fix suggested) by |
|
2119 | doesn't support persistence. Reported (and fix suggested) by | |
2107 | Travis Caldwell <travis_caldwell2000@yahoo.com>. |
|
2120 | Travis Caldwell <travis_caldwell2000@yahoo.com>. | |
2108 |
|
2121 | |||
2109 | 2004-06-26 Fernando Perez <fperez@colorado.edu> |
|
2122 | 2004-06-26 Fernando Perez <fperez@colorado.edu> | |
2110 |
|
2123 | |||
2111 | * IPython/Logger.py (Logger.log): fix to handle correctly empty |
|
2124 | * IPython/Logger.py (Logger.log): fix to handle correctly empty | |
2112 | continue prompts. |
|
2125 | continue prompts. | |
2113 |
|
2126 | |||
2114 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() |
|
2127 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() | |
2115 | function (basically a big docstring) and a few more things here to |
|
2128 | function (basically a big docstring) and a few more things here to | |
2116 | speedup startup. pysh.py is now very lightweight. We want because |
|
2129 | speedup startup. pysh.py is now very lightweight. We want because | |
2117 | it gets execfile'd, while InterpreterExec gets imported, so |
|
2130 | it gets execfile'd, while InterpreterExec gets imported, so | |
2118 | byte-compilation saves time. |
|
2131 | byte-compilation saves time. | |
2119 |
|
2132 | |||
2120 | 2004-06-25 Fernando Perez <fperez@colorado.edu> |
|
2133 | 2004-06-25 Fernando Perez <fperez@colorado.edu> | |
2121 |
|
2134 | |||
2122 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd |
|
2135 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd | |
2123 | -NUM', which was recently broken. |
|
2136 | -NUM', which was recently broken. | |
2124 |
|
2137 | |||
2125 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! |
|
2138 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! | |
2126 | in multi-line input (but not !!, which doesn't make sense there). |
|
2139 | in multi-line input (but not !!, which doesn't make sense there). | |
2127 |
|
2140 | |||
2128 | * IPython/UserConfig/ipythonrc: made autoindent on by default. |
|
2141 | * IPython/UserConfig/ipythonrc: made autoindent on by default. | |
2129 | It's just too useful, and people can turn it off in the less |
|
2142 | It's just too useful, and people can turn it off in the less | |
2130 | common cases where it's a problem. |
|
2143 | common cases where it's a problem. | |
2131 |
|
2144 | |||
2132 | 2004-06-24 Fernando Perez <fperez@colorado.edu> |
|
2145 | 2004-06-24 Fernando Perez <fperez@colorado.edu> | |
2133 |
|
2146 | |||
2134 | * IPython/iplib.py (InteractiveShell._prefilter): big change - |
|
2147 | * IPython/iplib.py (InteractiveShell._prefilter): big change - | |
2135 | special syntaxes (like alias calling) is now allied in multi-line |
|
2148 | special syntaxes (like alias calling) is now allied in multi-line | |
2136 | input. This is still _very_ experimental, but it's necessary for |
|
2149 | input. This is still _very_ experimental, but it's necessary for | |
2137 | efficient shell usage combining python looping syntax with system |
|
2150 | efficient shell usage combining python looping syntax with system | |
2138 | calls. For now it's restricted to aliases, I don't think it |
|
2151 | calls. For now it's restricted to aliases, I don't think it | |
2139 | really even makes sense to have this for magics. |
|
2152 | really even makes sense to have this for magics. | |
2140 |
|
2153 | |||
2141 | 2004-06-23 Fernando Perez <fperez@colorado.edu> |
|
2154 | 2004-06-23 Fernando Perez <fperez@colorado.edu> | |
2142 |
|
2155 | |||
2143 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added |
|
2156 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added | |
2144 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. |
|
2157 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. | |
2145 |
|
2158 | |||
2146 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle |
|
2159 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle | |
2147 | extensions under Windows (after code sent by Gary Bishop). The |
|
2160 | extensions under Windows (after code sent by Gary Bishop). The | |
2148 | extensions considered 'executable' are stored in IPython's rc |
|
2161 | extensions considered 'executable' are stored in IPython's rc | |
2149 | structure as win_exec_ext. |
|
2162 | structure as win_exec_ext. | |
2150 |
|
2163 | |||
2151 | * IPython/genutils.py (shell): new function, like system() but |
|
2164 | * IPython/genutils.py (shell): new function, like system() but | |
2152 | without return value. Very useful for interactive shell work. |
|
2165 | without return value. Very useful for interactive shell work. | |
2153 |
|
2166 | |||
2154 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to |
|
2167 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to | |
2155 | delete aliases. |
|
2168 | delete aliases. | |
2156 |
|
2169 | |||
2157 | * IPython/iplib.py (InteractiveShell.alias_table_update): make |
|
2170 | * IPython/iplib.py (InteractiveShell.alias_table_update): make | |
2158 | sure that the alias table doesn't contain python keywords. |
|
2171 | sure that the alias table doesn't contain python keywords. | |
2159 |
|
2172 | |||
2160 | 2004-06-21 Fernando Perez <fperez@colorado.edu> |
|
2173 | 2004-06-21 Fernando Perez <fperez@colorado.edu> | |
2161 |
|
2174 | |||
2162 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when |
|
2175 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when | |
2163 | non-existent items are found in $PATH. Reported by Thorsten. |
|
2176 | non-existent items are found in $PATH. Reported by Thorsten. | |
2164 |
|
2177 | |||
2165 | 2004-06-20 Fernando Perez <fperez@colorado.edu> |
|
2178 | 2004-06-20 Fernando Perez <fperez@colorado.edu> | |
2166 |
|
2179 | |||
2167 | * IPython/iplib.py (complete): modified the completer so that the |
|
2180 | * IPython/iplib.py (complete): modified the completer so that the | |
2168 | order of priorities can be easily changed at runtime. |
|
2181 | order of priorities can be easily changed at runtime. | |
2169 |
|
2182 | |||
2170 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): |
|
2183 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): | |
2171 | Modified to auto-execute all lines beginning with '~', '/' or '.'. |
|
2184 | Modified to auto-execute all lines beginning with '~', '/' or '.'. | |
2172 |
|
2185 | |||
2173 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to |
|
2186 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to | |
2174 | expand Python variables prepended with $ in all system calls. The |
|
2187 | expand Python variables prepended with $ in all system calls. The | |
2175 | same was done to InteractiveShell.handle_shell_escape. Now all |
|
2188 | same was done to InteractiveShell.handle_shell_escape. Now all | |
2176 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the |
|
2189 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the | |
2177 | expansion of python variables and expressions according to the |
|
2190 | expansion of python variables and expressions according to the | |
2178 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. |
|
2191 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. | |
2179 |
|
2192 | |||
2180 | Though PEP-215 has been rejected, a similar (but simpler) one |
|
2193 | Though PEP-215 has been rejected, a similar (but simpler) one | |
2181 | seems like it will go into Python 2.4, PEP-292 - |
|
2194 | seems like it will go into Python 2.4, PEP-292 - | |
2182 | http://www.python.org/peps/pep-0292.html. |
|
2195 | http://www.python.org/peps/pep-0292.html. | |
2183 |
|
2196 | |||
2184 | I'll keep the full syntax of PEP-215, since IPython has since the |
|
2197 | I'll keep the full syntax of PEP-215, since IPython has since the | |
2185 | start used Ka-Ping Yee's reference implementation discussed there |
|
2198 | start used Ka-Ping Yee's reference implementation discussed there | |
2186 | (Itpl), and I actually like the powerful semantics it offers. |
|
2199 | (Itpl), and I actually like the powerful semantics it offers. | |
2187 |
|
2200 | |||
2188 | In order to access normal shell variables, the $ has to be escaped |
|
2201 | In order to access normal shell variables, the $ has to be escaped | |
2189 | via an extra $. For example: |
|
2202 | via an extra $. For example: | |
2190 |
|
2203 | |||
2191 | In [7]: PATH='a python variable' |
|
2204 | In [7]: PATH='a python variable' | |
2192 |
|
2205 | |||
2193 | In [8]: !echo $PATH |
|
2206 | In [8]: !echo $PATH | |
2194 | a python variable |
|
2207 | a python variable | |
2195 |
|
2208 | |||
2196 | In [9]: !echo $$PATH |
|
2209 | In [9]: !echo $$PATH | |
2197 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2210 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2198 |
|
2211 | |||
2199 | (Magic.parse_options): escape $ so the shell doesn't evaluate |
|
2212 | (Magic.parse_options): escape $ so the shell doesn't evaluate | |
2200 | things prematurely. |
|
2213 | things prematurely. | |
2201 |
|
2214 | |||
2202 | * IPython/iplib.py (InteractiveShell.call_alias): added the |
|
2215 | * IPython/iplib.py (InteractiveShell.call_alias): added the | |
2203 | ability for aliases to expand python variables via $. |
|
2216 | ability for aliases to expand python variables via $. | |
2204 |
|
2217 | |||
2205 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias |
|
2218 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias | |
2206 | system, now there's a @rehash/@rehashx pair of magics. These work |
|
2219 | system, now there's a @rehash/@rehashx pair of magics. These work | |
2207 | like the csh rehash command, and can be invoked at any time. They |
|
2220 | like the csh rehash command, and can be invoked at any time. They | |
2208 | build a table of aliases to everything in the user's $PATH |
|
2221 | build a table of aliases to everything in the user's $PATH | |
2209 | (@rehash uses everything, @rehashx is slower but only adds |
|
2222 | (@rehash uses everything, @rehashx is slower but only adds | |
2210 | executable files). With this, the pysh.py-based shell profile can |
|
2223 | executable files). With this, the pysh.py-based shell profile can | |
2211 | now simply call rehash upon startup, and full access to all |
|
2224 | now simply call rehash upon startup, and full access to all | |
2212 | programs in the user's path is obtained. |
|
2225 | programs in the user's path is obtained. | |
2213 |
|
2226 | |||
2214 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias |
|
2227 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias | |
2215 | functionality is now fully in place. I removed the old dynamic |
|
2228 | functionality is now fully in place. I removed the old dynamic | |
2216 | code generation based approach, in favor of a much lighter one |
|
2229 | code generation based approach, in favor of a much lighter one | |
2217 | based on a simple dict. The advantage is that this allows me to |
|
2230 | based on a simple dict. The advantage is that this allows me to | |
2218 | now have thousands of aliases with negligible cost (unthinkable |
|
2231 | now have thousands of aliases with negligible cost (unthinkable | |
2219 | with the old system). |
|
2232 | with the old system). | |
2220 |
|
2233 | |||
2221 | 2004-06-19 Fernando Perez <fperez@colorado.edu> |
|
2234 | 2004-06-19 Fernando Perez <fperez@colorado.edu> | |
2222 |
|
2235 | |||
2223 | * IPython/iplib.py (__init__): extended MagicCompleter class to |
|
2236 | * IPython/iplib.py (__init__): extended MagicCompleter class to | |
2224 | also complete (last in priority) on user aliases. |
|
2237 | also complete (last in priority) on user aliases. | |
2225 |
|
2238 | |||
2226 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in |
|
2239 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in | |
2227 | call to eval. |
|
2240 | call to eval. | |
2228 | (ItplNS.__init__): Added a new class which functions like Itpl, |
|
2241 | (ItplNS.__init__): Added a new class which functions like Itpl, | |
2229 | but allows configuring the namespace for the evaluation to occur |
|
2242 | but allows configuring the namespace for the evaluation to occur | |
2230 | in. |
|
2243 | in. | |
2231 |
|
2244 | |||
2232 | 2004-06-18 Fernando Perez <fperez@colorado.edu> |
|
2245 | 2004-06-18 Fernando Perez <fperez@colorado.edu> | |
2233 |
|
2246 | |||
2234 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a |
|
2247 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a | |
2235 | better message when 'exit' or 'quit' are typed (a common newbie |
|
2248 | better message when 'exit' or 'quit' are typed (a common newbie | |
2236 | confusion). |
|
2249 | confusion). | |
2237 |
|
2250 | |||
2238 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color |
|
2251 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color | |
2239 | check for Windows users. |
|
2252 | check for Windows users. | |
2240 |
|
2253 | |||
2241 | * IPython/iplib.py (InteractiveShell.user_setup): removed |
|
2254 | * IPython/iplib.py (InteractiveShell.user_setup): removed | |
2242 | disabling of colors for Windows. I'll test at runtime and issue a |
|
2255 | disabling of colors for Windows. I'll test at runtime and issue a | |
2243 | warning if Gary's readline isn't found, as to nudge users to |
|
2256 | warning if Gary's readline isn't found, as to nudge users to | |
2244 | download it. |
|
2257 | download it. | |
2245 |
|
2258 | |||
2246 | 2004-06-16 Fernando Perez <fperez@colorado.edu> |
|
2259 | 2004-06-16 Fernando Perez <fperez@colorado.edu> | |
2247 |
|
2260 | |||
2248 | * IPython/genutils.py (Stream.__init__): changed to print errors |
|
2261 | * IPython/genutils.py (Stream.__init__): changed to print errors | |
2249 | to sys.stderr. I had a circular dependency here. Now it's |
|
2262 | to sys.stderr. I had a circular dependency here. Now it's | |
2250 | possible to run ipython as IDLE's shell (consider this pre-alpha, |
|
2263 | possible to run ipython as IDLE's shell (consider this pre-alpha, | |
2251 | since true stdout things end up in the starting terminal instead |
|
2264 | since true stdout things end up in the starting terminal instead | |
2252 | of IDLE's out). |
|
2265 | of IDLE's out). | |
2253 |
|
2266 | |||
2254 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for |
|
2267 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for | |
2255 | users who haven't # updated their prompt_in2 definitions. Remove |
|
2268 | users who haven't # updated their prompt_in2 definitions. Remove | |
2256 | eventually. |
|
2269 | eventually. | |
2257 | (multiple_replace): added credit to original ASPN recipe. |
|
2270 | (multiple_replace): added credit to original ASPN recipe. | |
2258 |
|
2271 | |||
2259 | 2004-06-15 Fernando Perez <fperez@colorado.edu> |
|
2272 | 2004-06-15 Fernando Perez <fperez@colorado.edu> | |
2260 |
|
2273 | |||
2261 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the |
|
2274 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the | |
2262 | list of auto-defined aliases. |
|
2275 | list of auto-defined aliases. | |
2263 |
|
2276 | |||
2264 | 2004-06-13 Fernando Perez <fperez@colorado.edu> |
|
2277 | 2004-06-13 Fernando Perez <fperez@colorado.edu> | |
2265 |
|
2278 | |||
2266 | * setup.py (scriptfiles): Don't trigger win_post_install unless an |
|
2279 | * setup.py (scriptfiles): Don't trigger win_post_install unless an | |
2267 | install was really requested (so setup.py can be used for other |
|
2280 | install was really requested (so setup.py can be used for other | |
2268 | things under Windows). |
|
2281 | things under Windows). | |
2269 |
|
2282 | |||
2270 | 2004-06-10 Fernando Perez <fperez@colorado.edu> |
|
2283 | 2004-06-10 Fernando Perez <fperez@colorado.edu> | |
2271 |
|
2284 | |||
2272 | * IPython/Logger.py (Logger.create_log): Manually remove any old |
|
2285 | * IPython/Logger.py (Logger.create_log): Manually remove any old | |
2273 | backup, since os.remove may fail under Windows. Fixes bug |
|
2286 | backup, since os.remove may fail under Windows. Fixes bug | |
2274 | reported by Thorsten. |
|
2287 | reported by Thorsten. | |
2275 |
|
2288 | |||
2276 | 2004-06-09 Fernando Perez <fperez@colorado.edu> |
|
2289 | 2004-06-09 Fernando Perez <fperez@colorado.edu> | |
2277 |
|
2290 | |||
2278 | * examples/example-embed.py: fixed all references to %n (replaced |
|
2291 | * examples/example-embed.py: fixed all references to %n (replaced | |
2279 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done |
|
2292 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done | |
2280 | for all examples and the manual as well. |
|
2293 | for all examples and the manual as well. | |
2281 |
|
2294 | |||
2282 | 2004-06-08 Fernando Perez <fperez@colorado.edu> |
|
2295 | 2004-06-08 Fernando Perez <fperez@colorado.edu> | |
2283 |
|
2296 | |||
2284 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt |
|
2297 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt | |
2285 | alignment and color management. All 3 prompt subsystems now |
|
2298 | alignment and color management. All 3 prompt subsystems now | |
2286 | inherit from BasePrompt. |
|
2299 | inherit from BasePrompt. | |
2287 |
|
2300 | |||
2288 | * tools/release: updates for windows installer build and tag rpms |
|
2301 | * tools/release: updates for windows installer build and tag rpms | |
2289 | with python version (since paths are fixed). |
|
2302 | with python version (since paths are fixed). | |
2290 |
|
2303 | |||
2291 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, |
|
2304 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, | |
2292 | which will become eventually obsolete. Also fixed the default |
|
2305 | which will become eventually obsolete. Also fixed the default | |
2293 | prompt_in2 to use \D, so at least new users start with the correct |
|
2306 | prompt_in2 to use \D, so at least new users start with the correct | |
2294 | defaults. |
|
2307 | defaults. | |
2295 | WARNING: Users with existing ipythonrc files will need to apply |
|
2308 | WARNING: Users with existing ipythonrc files will need to apply | |
2296 | this fix manually! |
|
2309 | this fix manually! | |
2297 |
|
2310 | |||
2298 | * setup.py: make windows installer (.exe). This is finally the |
|
2311 | * setup.py: make windows installer (.exe). This is finally the | |
2299 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, |
|
2312 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, | |
2300 | which I hadn't included because it required Python 2.3 (or recent |
|
2313 | which I hadn't included because it required Python 2.3 (or recent | |
2301 | distutils). |
|
2314 | distutils). | |
2302 |
|
2315 | |||
2303 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect |
|
2316 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect | |
2304 | usage of new '\D' escape. |
|
2317 | usage of new '\D' escape. | |
2305 |
|
2318 | |||
2306 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which |
|
2319 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which | |
2307 | lacks os.getuid()) |
|
2320 | lacks os.getuid()) | |
2308 | (CachedOutput.set_colors): Added the ability to turn coloring |
|
2321 | (CachedOutput.set_colors): Added the ability to turn coloring | |
2309 | on/off with @colors even for manually defined prompt colors. It |
|
2322 | on/off with @colors even for manually defined prompt colors. It | |
2310 | uses a nasty global, but it works safely and via the generic color |
|
2323 | uses a nasty global, but it works safely and via the generic color | |
2311 | handling mechanism. |
|
2324 | handling mechanism. | |
2312 | (Prompt2.__init__): Introduced new escape '\D' for continuation |
|
2325 | (Prompt2.__init__): Introduced new escape '\D' for continuation | |
2313 | prompts. It represents the counter ('\#') as dots. |
|
2326 | prompts. It represents the counter ('\#') as dots. | |
2314 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will |
|
2327 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will | |
2315 | need to update their ipythonrc files and replace '%n' with '\D' in |
|
2328 | need to update their ipythonrc files and replace '%n' with '\D' in | |
2316 | their prompt_in2 settings everywhere. Sorry, but there's |
|
2329 | their prompt_in2 settings everywhere. Sorry, but there's | |
2317 | otherwise no clean way to get all prompts to properly align. The |
|
2330 | otherwise no clean way to get all prompts to properly align. The | |
2318 | ipythonrc shipped with IPython has been updated. |
|
2331 | ipythonrc shipped with IPython has been updated. | |
2319 |
|
2332 | |||
2320 | 2004-06-07 Fernando Perez <fperez@colorado.edu> |
|
2333 | 2004-06-07 Fernando Perez <fperez@colorado.edu> | |
2321 |
|
2334 | |||
2322 | * setup.py (isfile): Pass local_icons option to latex2html, so the |
|
2335 | * setup.py (isfile): Pass local_icons option to latex2html, so the | |
2323 | resulting HTML file is self-contained. Thanks to |
|
2336 | resulting HTML file is self-contained. Thanks to | |
2324 | dryice-AT-liu.com.cn for the tip. |
|
2337 | dryice-AT-liu.com.cn for the tip. | |
2325 |
|
2338 | |||
2326 | * pysh.py: I created a new profile 'shell', which implements a |
|
2339 | * pysh.py: I created a new profile 'shell', which implements a | |
2327 | _rudimentary_ IPython-based shell. This is in NO WAY a realy |
|
2340 | _rudimentary_ IPython-based shell. This is in NO WAY a realy | |
2328 | system shell, nor will it become one anytime soon. It's mainly |
|
2341 | system shell, nor will it become one anytime soon. It's mainly | |
2329 | meant to illustrate the use of the new flexible bash-like prompts. |
|
2342 | meant to illustrate the use of the new flexible bash-like prompts. | |
2330 | I guess it could be used by hardy souls for true shell management, |
|
2343 | I guess it could be used by hardy souls for true shell management, | |
2331 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' |
|
2344 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' | |
2332 | profile. This uses the InterpreterExec extension provided by |
|
2345 | profile. This uses the InterpreterExec extension provided by | |
2333 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> |
|
2346 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> | |
2334 |
|
2347 | |||
2335 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly |
|
2348 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly | |
2336 | auto-align itself with the length of the previous input prompt |
|
2349 | auto-align itself with the length of the previous input prompt | |
2337 | (taking into account the invisible color escapes). |
|
2350 | (taking into account the invisible color escapes). | |
2338 | (CachedOutput.__init__): Large restructuring of this class. Now |
|
2351 | (CachedOutput.__init__): Large restructuring of this class. Now | |
2339 | all three prompts (primary1, primary2, output) are proper objects, |
|
2352 | all three prompts (primary1, primary2, output) are proper objects, | |
2340 | managed by the 'parent' CachedOutput class. The code is still a |
|
2353 | managed by the 'parent' CachedOutput class. The code is still a | |
2341 | bit hackish (all prompts share state via a pointer to the cache), |
|
2354 | bit hackish (all prompts share state via a pointer to the cache), | |
2342 | but it's overall far cleaner than before. |
|
2355 | but it's overall far cleaner than before. | |
2343 |
|
2356 | |||
2344 | * IPython/genutils.py (getoutputerror): modified to add verbose, |
|
2357 | * IPython/genutils.py (getoutputerror): modified to add verbose, | |
2345 | debug and header options. This makes the interface of all getout* |
|
2358 | debug and header options. This makes the interface of all getout* | |
2346 | functions uniform. |
|
2359 | functions uniform. | |
2347 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. |
|
2360 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. | |
2348 |
|
2361 | |||
2349 | * IPython/Magic.py (Magic.default_option): added a function to |
|
2362 | * IPython/Magic.py (Magic.default_option): added a function to | |
2350 | allow registering default options for any magic command. This |
|
2363 | allow registering default options for any magic command. This | |
2351 | makes it easy to have profiles which customize the magics globally |
|
2364 | makes it easy to have profiles which customize the magics globally | |
2352 | for a certain use. The values set through this function are |
|
2365 | for a certain use. The values set through this function are | |
2353 | picked up by the parse_options() method, which all magics should |
|
2366 | picked up by the parse_options() method, which all magics should | |
2354 | use to parse their options. |
|
2367 | use to parse their options. | |
2355 |
|
2368 | |||
2356 | * IPython/genutils.py (warn): modified the warnings framework to |
|
2369 | * IPython/genutils.py (warn): modified the warnings framework to | |
2357 | use the Term I/O class. I'm trying to slowly unify all of |
|
2370 | use the Term I/O class. I'm trying to slowly unify all of | |
2358 | IPython's I/O operations to pass through Term. |
|
2371 | IPython's I/O operations to pass through Term. | |
2359 |
|
2372 | |||
2360 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in |
|
2373 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in | |
2361 | the secondary prompt to correctly match the length of the primary |
|
2374 | the secondary prompt to correctly match the length of the primary | |
2362 | one for any prompt. Now multi-line code will properly line up |
|
2375 | one for any prompt. Now multi-line code will properly line up | |
2363 | even for path dependent prompts, such as the new ones available |
|
2376 | even for path dependent prompts, such as the new ones available | |
2364 | via the prompt_specials. |
|
2377 | via the prompt_specials. | |
2365 |
|
2378 | |||
2366 | 2004-06-06 Fernando Perez <fperez@colorado.edu> |
|
2379 | 2004-06-06 Fernando Perez <fperez@colorado.edu> | |
2367 |
|
2380 | |||
2368 | * IPython/Prompts.py (prompt_specials): Added the ability to have |
|
2381 | * IPython/Prompts.py (prompt_specials): Added the ability to have | |
2369 | bash-like special sequences in the prompts, which get |
|
2382 | bash-like special sequences in the prompts, which get | |
2370 | automatically expanded. Things like hostname, current working |
|
2383 | automatically expanded. Things like hostname, current working | |
2371 | directory and username are implemented already, but it's easy to |
|
2384 | directory and username are implemented already, but it's easy to | |
2372 | add more in the future. Thanks to a patch by W.J. van der Laan |
|
2385 | add more in the future. Thanks to a patch by W.J. van der Laan | |
2373 | <gnufnork-AT-hetdigitalegat.nl> |
|
2386 | <gnufnork-AT-hetdigitalegat.nl> | |
2374 | (prompt_specials): Added color support for prompt strings, so |
|
2387 | (prompt_specials): Added color support for prompt strings, so | |
2375 | users can define arbitrary color setups for their prompts. |
|
2388 | users can define arbitrary color setups for their prompts. | |
2376 |
|
2389 | |||
2377 | 2004-06-05 Fernando Perez <fperez@colorado.edu> |
|
2390 | 2004-06-05 Fernando Perez <fperez@colorado.edu> | |
2378 |
|
2391 | |||
2379 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific |
|
2392 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific | |
2380 | code to load Gary Bishop's readline and configure it |
|
2393 | code to load Gary Bishop's readline and configure it | |
2381 | automatically. Thanks to Gary for help on this. |
|
2394 | automatically. Thanks to Gary for help on this. | |
2382 |
|
2395 | |||
2383 | 2004-06-01 Fernando Perez <fperez@colorado.edu> |
|
2396 | 2004-06-01 Fernando Perez <fperez@colorado.edu> | |
2384 |
|
2397 | |||
2385 | * IPython/Logger.py (Logger.create_log): fix bug for logging |
|
2398 | * IPython/Logger.py (Logger.create_log): fix bug for logging | |
2386 | with no filename (previous fix was incomplete). |
|
2399 | with no filename (previous fix was incomplete). | |
2387 |
|
2400 | |||
2388 | 2004-05-25 Fernando Perez <fperez@colorado.edu> |
|
2401 | 2004-05-25 Fernando Perez <fperez@colorado.edu> | |
2389 |
|
2402 | |||
2390 | * IPython/Magic.py (Magic.parse_options): fix bug where naked |
|
2403 | * IPython/Magic.py (Magic.parse_options): fix bug where naked | |
2391 | parens would get passed to the shell. |
|
2404 | parens would get passed to the shell. | |
2392 |
|
2405 | |||
2393 | 2004-05-20 Fernando Perez <fperez@colorado.edu> |
|
2406 | 2004-05-20 Fernando Perez <fperez@colorado.edu> | |
2394 |
|
2407 | |||
2395 | * IPython/Magic.py (Magic.magic_prun): changed default profile |
|
2408 | * IPython/Magic.py (Magic.magic_prun): changed default profile | |
2396 | sort order to 'time' (the more common profiling need). |
|
2409 | sort order to 'time' (the more common profiling need). | |
2397 |
|
2410 | |||
2398 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache |
|
2411 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache | |
2399 | so that source code shown is guaranteed in sync with the file on |
|
2412 | so that source code shown is guaranteed in sync with the file on | |
2400 | disk (also changed in psource). Similar fix to the one for |
|
2413 | disk (also changed in psource). Similar fix to the one for | |
2401 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du |
|
2414 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du | |
2402 | <yann.ledu-AT-noos.fr>. |
|
2415 | <yann.ledu-AT-noos.fr>. | |
2403 |
|
2416 | |||
2404 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands |
|
2417 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands | |
2405 | with a single option would not be correctly parsed. Closes |
|
2418 | with a single option would not be correctly parsed. Closes | |
2406 | http://www.scipy.net/roundup/ipython/issue14. This bug had been |
|
2419 | http://www.scipy.net/roundup/ipython/issue14. This bug had been | |
2407 | introduced in 0.6.0 (on 2004-05-06). |
|
2420 | introduced in 0.6.0 (on 2004-05-06). | |
2408 |
|
2421 | |||
2409 | 2004-05-13 *** Released version 0.6.0 |
|
2422 | 2004-05-13 *** Released version 0.6.0 | |
2410 |
|
2423 | |||
2411 | 2004-05-13 Fernando Perez <fperez@colorado.edu> |
|
2424 | 2004-05-13 Fernando Perez <fperez@colorado.edu> | |
2412 |
|
2425 | |||
2413 | * debian/: Added debian/ directory to CVS, so that debian support |
|
2426 | * debian/: Added debian/ directory to CVS, so that debian support | |
2414 | is publicly accessible. The debian package is maintained by Jack |
|
2427 | is publicly accessible. The debian package is maintained by Jack | |
2415 | Moffit <jack-AT-xiph.org>. |
|
2428 | Moffit <jack-AT-xiph.org>. | |
2416 |
|
2429 | |||
2417 | * Documentation: included the notes about an ipython-based system |
|
2430 | * Documentation: included the notes about an ipython-based system | |
2418 | shell (the hypothetical 'pysh') into the new_design.pdf document, |
|
2431 | shell (the hypothetical 'pysh') into the new_design.pdf document, | |
2419 | so that these ideas get distributed to users along with the |
|
2432 | so that these ideas get distributed to users along with the | |
2420 | official documentation. |
|
2433 | official documentation. | |
2421 |
|
2434 | |||
2422 | 2004-05-10 Fernando Perez <fperez@colorado.edu> |
|
2435 | 2004-05-10 Fernando Perez <fperez@colorado.edu> | |
2423 |
|
2436 | |||
2424 | * IPython/Logger.py (Logger.create_log): fix recently introduced |
|
2437 | * IPython/Logger.py (Logger.create_log): fix recently introduced | |
2425 | bug (misindented line) where logstart would fail when not given an |
|
2438 | bug (misindented line) where logstart would fail when not given an | |
2426 | explicit filename. |
|
2439 | explicit filename. | |
2427 |
|
2440 | |||
2428 | 2004-05-09 Fernando Perez <fperez@colorado.edu> |
|
2441 | 2004-05-09 Fernando Perez <fperez@colorado.edu> | |
2429 |
|
2442 | |||
2430 | * IPython/Magic.py (Magic.parse_options): skip system call when |
|
2443 | * IPython/Magic.py (Magic.parse_options): skip system call when | |
2431 | there are no options to look for. Faster, cleaner for the common |
|
2444 | there are no options to look for. Faster, cleaner for the common | |
2432 | case. |
|
2445 | case. | |
2433 |
|
2446 | |||
2434 | * Documentation: many updates to the manual: describing Windows |
|
2447 | * Documentation: many updates to the manual: describing Windows | |
2435 | support better, Gnuplot updates, credits, misc small stuff. Also |
|
2448 | support better, Gnuplot updates, credits, misc small stuff. Also | |
2436 | updated the new_design doc a bit. |
|
2449 | updated the new_design doc a bit. | |
2437 |
|
2450 | |||
2438 | 2004-05-06 *** Released version 0.6.0.rc1 |
|
2451 | 2004-05-06 *** Released version 0.6.0.rc1 | |
2439 |
|
2452 | |||
2440 | 2004-05-06 Fernando Perez <fperez@colorado.edu> |
|
2453 | 2004-05-06 Fernando Perez <fperez@colorado.edu> | |
2441 |
|
2454 | |||
2442 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += |
|
2455 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += | |
2443 | operations to use the vastly more efficient list/''.join() method. |
|
2456 | operations to use the vastly more efficient list/''.join() method. | |
2444 | (FormattedTB.text): Fix |
|
2457 | (FormattedTB.text): Fix | |
2445 | http://www.scipy.net/roundup/ipython/issue12 - exception source |
|
2458 | http://www.scipy.net/roundup/ipython/issue12 - exception source | |
2446 | extract not updated after reload. Thanks to Mike Salib |
|
2459 | extract not updated after reload. Thanks to Mike Salib | |
2447 | <msalib-AT-mit.edu> for pinning the source of the problem. |
|
2460 | <msalib-AT-mit.edu> for pinning the source of the problem. | |
2448 | Fortunately, the solution works inside ipython and doesn't require |
|
2461 | Fortunately, the solution works inside ipython and doesn't require | |
2449 | any changes to python proper. |
|
2462 | any changes to python proper. | |
2450 |
|
2463 | |||
2451 | * IPython/Magic.py (Magic.parse_options): Improved to process the |
|
2464 | * IPython/Magic.py (Magic.parse_options): Improved to process the | |
2452 | argument list as a true shell would (by actually using the |
|
2465 | argument list as a true shell would (by actually using the | |
2453 | underlying system shell). This way, all @magics automatically get |
|
2466 | underlying system shell). This way, all @magics automatically get | |
2454 | shell expansion for variables. Thanks to a comment by Alex |
|
2467 | shell expansion for variables. Thanks to a comment by Alex | |
2455 | Schmolck. |
|
2468 | Schmolck. | |
2456 |
|
2469 | |||
2457 | 2004-04-04 Fernando Perez <fperez@colorado.edu> |
|
2470 | 2004-04-04 Fernando Perez <fperez@colorado.edu> | |
2458 |
|
2471 | |||
2459 | * IPython/iplib.py (InteractiveShell.interact): Added a special |
|
2472 | * IPython/iplib.py (InteractiveShell.interact): Added a special | |
2460 | trap for a debugger quit exception, which is basically impossible |
|
2473 | trap for a debugger quit exception, which is basically impossible | |
2461 | to handle by normal mechanisms, given what pdb does to the stack. |
|
2474 | to handle by normal mechanisms, given what pdb does to the stack. | |
2462 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. |
|
2475 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. | |
2463 |
|
2476 | |||
2464 | 2004-04-03 Fernando Perez <fperez@colorado.edu> |
|
2477 | 2004-04-03 Fernando Perez <fperez@colorado.edu> | |
2465 |
|
2478 | |||
2466 | * IPython/genutils.py (Term): Standardized the names of the Term |
|
2479 | * IPython/genutils.py (Term): Standardized the names of the Term | |
2467 | class streams to cin/cout/cerr, following C++ naming conventions |
|
2480 | class streams to cin/cout/cerr, following C++ naming conventions | |
2468 | (I can't use in/out/err because 'in' is not a valid attribute |
|
2481 | (I can't use in/out/err because 'in' is not a valid attribute | |
2469 | name). |
|
2482 | name). | |
2470 |
|
2483 | |||
2471 | * IPython/iplib.py (InteractiveShell.interact): don't increment |
|
2484 | * IPython/iplib.py (InteractiveShell.interact): don't increment | |
2472 | the prompt if there's no user input. By Daniel 'Dang' Griffith |
|
2485 | the prompt if there's no user input. By Daniel 'Dang' Griffith | |
2473 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from |
|
2486 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from | |
2474 | Francois Pinard. |
|
2487 | Francois Pinard. | |
2475 |
|
2488 | |||
2476 | 2004-04-02 Fernando Perez <fperez@colorado.edu> |
|
2489 | 2004-04-02 Fernando Perez <fperez@colorado.edu> | |
2477 |
|
2490 | |||
2478 | * IPython/genutils.py (Stream.__init__): Modified to survive at |
|
2491 | * IPython/genutils.py (Stream.__init__): Modified to survive at | |
2479 | least importing in contexts where stdin/out/err aren't true file |
|
2492 | least importing in contexts where stdin/out/err aren't true file | |
2480 | objects, such as PyCrust (they lack fileno() and mode). However, |
|
2493 | objects, such as PyCrust (they lack fileno() and mode). However, | |
2481 | the recovery facilities which rely on these things existing will |
|
2494 | the recovery facilities which rely on these things existing will | |
2482 | not work. |
|
2495 | not work. | |
2483 |
|
2496 | |||
2484 | 2004-04-01 Fernando Perez <fperez@colorado.edu> |
|
2497 | 2004-04-01 Fernando Perez <fperez@colorado.edu> | |
2485 |
|
2498 | |||
2486 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to |
|
2499 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to | |
2487 | use the new getoutputerror() function, so it properly |
|
2500 | use the new getoutputerror() function, so it properly | |
2488 | distinguishes stdout/err. |
|
2501 | distinguishes stdout/err. | |
2489 |
|
2502 | |||
2490 | * IPython/genutils.py (getoutputerror): added a function to |
|
2503 | * IPython/genutils.py (getoutputerror): added a function to | |
2491 | capture separately the standard output and error of a command. |
|
2504 | capture separately the standard output and error of a command. | |
2492 | After a comment from dang on the mailing lists. This code is |
|
2505 | After a comment from dang on the mailing lists. This code is | |
2493 | basically a modified version of commands.getstatusoutput(), from |
|
2506 | basically a modified version of commands.getstatusoutput(), from | |
2494 | the standard library. |
|
2507 | the standard library. | |
2495 |
|
2508 | |||
2496 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added |
|
2509 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added | |
2497 | '!!' as a special syntax (shorthand) to access @sx. |
|
2510 | '!!' as a special syntax (shorthand) to access @sx. | |
2498 |
|
2511 | |||
2499 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell |
|
2512 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell | |
2500 | command and return its output as a list split on '\n'. |
|
2513 | command and return its output as a list split on '\n'. | |
2501 |
|
2514 | |||
2502 | 2004-03-31 Fernando Perez <fperez@colorado.edu> |
|
2515 | 2004-03-31 Fernando Perez <fperez@colorado.edu> | |
2503 |
|
2516 | |||
2504 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ |
|
2517 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ | |
2505 | method to dictionaries used as FakeModule instances if they lack |
|
2518 | method to dictionaries used as FakeModule instances if they lack | |
2506 | it. At least pydoc in python2.3 breaks for runtime-defined |
|
2519 | it. At least pydoc in python2.3 breaks for runtime-defined | |
2507 | functions without this hack. At some point I need to _really_ |
|
2520 | functions without this hack. At some point I need to _really_ | |
2508 | understand what FakeModule is doing, because it's a gross hack. |
|
2521 | understand what FakeModule is doing, because it's a gross hack. | |
2509 | But it solves Arnd's problem for now... |
|
2522 | But it solves Arnd's problem for now... | |
2510 |
|
2523 | |||
2511 | 2004-02-27 Fernando Perez <fperez@colorado.edu> |
|
2524 | 2004-02-27 Fernando Perez <fperez@colorado.edu> | |
2512 |
|
2525 | |||
2513 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' |
|
2526 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' | |
2514 | mode would behave erratically. Also increased the number of |
|
2527 | mode would behave erratically. Also increased the number of | |
2515 | possible logs in rotate mod to 999. Thanks to Rod Holland |
|
2528 | possible logs in rotate mod to 999. Thanks to Rod Holland | |
2516 | <rhh@StructureLABS.com> for the report and fixes. |
|
2529 | <rhh@StructureLABS.com> for the report and fixes. | |
2517 |
|
2530 | |||
2518 | 2004-02-26 Fernando Perez <fperez@colorado.edu> |
|
2531 | 2004-02-26 Fernando Perez <fperez@colorado.edu> | |
2519 |
|
2532 | |||
2520 | * IPython/genutils.py (page): Check that the curses module really |
|
2533 | * IPython/genutils.py (page): Check that the curses module really | |
2521 | has the initscr attribute before trying to use it. For some |
|
2534 | has the initscr attribute before trying to use it. For some | |
2522 | reason, the Solaris curses module is missing this. I think this |
|
2535 | reason, the Solaris curses module is missing this. I think this | |
2523 | should be considered a Solaris python bug, but I'm not sure. |
|
2536 | should be considered a Solaris python bug, but I'm not sure. | |
2524 |
|
2537 | |||
2525 | 2004-01-17 Fernando Perez <fperez@colorado.edu> |
|
2538 | 2004-01-17 Fernando Perez <fperez@colorado.edu> | |
2526 |
|
2539 | |||
2527 | * IPython/genutils.py (Stream.__init__): Changes to try to make |
|
2540 | * IPython/genutils.py (Stream.__init__): Changes to try to make | |
2528 | ipython robust against stdin/out/err being closed by the user. |
|
2541 | ipython robust against stdin/out/err being closed by the user. | |
2529 | This is 'user error' (and blocks a normal python session, at least |
|
2542 | This is 'user error' (and blocks a normal python session, at least | |
2530 | the stdout case). However, Ipython should be able to survive such |
|
2543 | the stdout case). However, Ipython should be able to survive such | |
2531 | instances of abuse as gracefully as possible. To simplify the |
|
2544 | instances of abuse as gracefully as possible. To simplify the | |
2532 | coding and maintain compatibility with Gary Bishop's Term |
|
2545 | coding and maintain compatibility with Gary Bishop's Term | |
2533 | contributions, I've made use of classmethods for this. I think |
|
2546 | contributions, I've made use of classmethods for this. I think | |
2534 | this introduces a dependency on python 2.2. |
|
2547 | this introduces a dependency on python 2.2. | |
2535 |
|
2548 | |||
2536 | 2004-01-13 Fernando Perez <fperez@colorado.edu> |
|
2549 | 2004-01-13 Fernando Perez <fperez@colorado.edu> | |
2537 |
|
2550 | |||
2538 | * IPython/numutils.py (exp_safe): simplified the code a bit and |
|
2551 | * IPython/numutils.py (exp_safe): simplified the code a bit and | |
2539 | removed the need for importing the kinds module altogether. |
|
2552 | removed the need for importing the kinds module altogether. | |
2540 |
|
2553 | |||
2541 | 2004-01-06 Fernando Perez <fperez@colorado.edu> |
|
2554 | 2004-01-06 Fernando Perez <fperez@colorado.edu> | |
2542 |
|
2555 | |||
2543 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system |
|
2556 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system | |
2544 | a magic function instead, after some community feedback. No |
|
2557 | a magic function instead, after some community feedback. No | |
2545 | special syntax will exist for it, but its name is deliberately |
|
2558 | special syntax will exist for it, but its name is deliberately | |
2546 | very short. |
|
2559 | very short. | |
2547 |
|
2560 | |||
2548 | 2003-12-20 Fernando Perez <fperez@colorado.edu> |
|
2561 | 2003-12-20 Fernando Perez <fperez@colorado.edu> | |
2549 |
|
2562 | |||
2550 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added |
|
2563 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added | |
2551 | new functionality, to automagically assign the result of a shell |
|
2564 | new functionality, to automagically assign the result of a shell | |
2552 | command to a variable. I'll solicit some community feedback on |
|
2565 | command to a variable. I'll solicit some community feedback on | |
2553 | this before making it permanent. |
|
2566 | this before making it permanent. | |
2554 |
|
2567 | |||
2555 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was |
|
2568 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was | |
2556 | requested about callables for which inspect couldn't obtain a |
|
2569 | requested about callables for which inspect couldn't obtain a | |
2557 | proper argspec. Thanks to a crash report sent by Etienne |
|
2570 | proper argspec. Thanks to a crash report sent by Etienne | |
2558 | Posthumus <etienne-AT-apple01.cs.vu.nl>. |
|
2571 | Posthumus <etienne-AT-apple01.cs.vu.nl>. | |
2559 |
|
2572 | |||
2560 | 2003-12-09 Fernando Perez <fperez@colorado.edu> |
|
2573 | 2003-12-09 Fernando Perez <fperez@colorado.edu> | |
2561 |
|
2574 | |||
2562 | * IPython/genutils.py (page): patch for the pager to work across |
|
2575 | * IPython/genutils.py (page): patch for the pager to work across | |
2563 | various versions of Windows. By Gary Bishop. |
|
2576 | various versions of Windows. By Gary Bishop. | |
2564 |
|
2577 | |||
2565 | 2003-12-04 Fernando Perez <fperez@colorado.edu> |
|
2578 | 2003-12-04 Fernando Perez <fperez@colorado.edu> | |
2566 |
|
2579 | |||
2567 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with |
|
2580 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with | |
2568 | Gnuplot.py version 1.7, whose internal names changed quite a bit. |
|
2581 | Gnuplot.py version 1.7, whose internal names changed quite a bit. | |
2569 | While I tested this and it looks ok, there may still be corner |
|
2582 | While I tested this and it looks ok, there may still be corner | |
2570 | cases I've missed. |
|
2583 | cases I've missed. | |
2571 |
|
2584 | |||
2572 | 2003-12-01 Fernando Perez <fperez@colorado.edu> |
|
2585 | 2003-12-01 Fernando Perez <fperez@colorado.edu> | |
2573 |
|
2586 | |||
2574 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug |
|
2587 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug | |
2575 | where a line like 'p,q=1,2' would fail because the automagic |
|
2588 | where a line like 'p,q=1,2' would fail because the automagic | |
2576 | system would be triggered for @p. |
|
2589 | system would be triggered for @p. | |
2577 |
|
2590 | |||
2578 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related |
|
2591 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related | |
2579 | cleanups, code unmodified. |
|
2592 | cleanups, code unmodified. | |
2580 |
|
2593 | |||
2581 | * IPython/genutils.py (Term): added a class for IPython to handle |
|
2594 | * IPython/genutils.py (Term): added a class for IPython to handle | |
2582 | output. In most cases it will just be a proxy for stdout/err, but |
|
2595 | output. In most cases it will just be a proxy for stdout/err, but | |
2583 | having this allows modifications to be made for some platforms, |
|
2596 | having this allows modifications to be made for some platforms, | |
2584 | such as handling color escapes under Windows. All of this code |
|
2597 | such as handling color escapes under Windows. All of this code | |
2585 | was contributed by Gary Bishop, with minor modifications by me. |
|
2598 | was contributed by Gary Bishop, with minor modifications by me. | |
2586 | The actual changes affect many files. |
|
2599 | The actual changes affect many files. | |
2587 |
|
2600 | |||
2588 | 2003-11-30 Fernando Perez <fperez@colorado.edu> |
|
2601 | 2003-11-30 Fernando Perez <fperez@colorado.edu> | |
2589 |
|
2602 | |||
2590 | * IPython/iplib.py (file_matches): new completion code, courtesy |
|
2603 | * IPython/iplib.py (file_matches): new completion code, courtesy | |
2591 | of Jeff Collins. This enables filename completion again under |
|
2604 | of Jeff Collins. This enables filename completion again under | |
2592 | python 2.3, which disabled it at the C level. |
|
2605 | python 2.3, which disabled it at the C level. | |
2593 |
|
2606 | |||
2594 | 2003-11-11 Fernando Perez <fperez@colorado.edu> |
|
2607 | 2003-11-11 Fernando Perez <fperez@colorado.edu> | |
2595 |
|
2608 | |||
2596 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand |
|
2609 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand | |
2597 | for Numeric.array(map(...)), but often convenient. |
|
2610 | for Numeric.array(map(...)), but often convenient. | |
2598 |
|
2611 | |||
2599 | 2003-11-05 Fernando Perez <fperez@colorado.edu> |
|
2612 | 2003-11-05 Fernando Perez <fperez@colorado.edu> | |
2600 |
|
2613 | |||
2601 | * IPython/numutils.py (frange): Changed a call from int() to |
|
2614 | * IPython/numutils.py (frange): Changed a call from int() to | |
2602 | int(round()) to prevent a problem reported with arange() in the |
|
2615 | int(round()) to prevent a problem reported with arange() in the | |
2603 | numpy list. |
|
2616 | numpy list. | |
2604 |
|
2617 | |||
2605 | 2003-10-06 Fernando Perez <fperez@colorado.edu> |
|
2618 | 2003-10-06 Fernando Perez <fperez@colorado.edu> | |
2606 |
|
2619 | |||
2607 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to |
|
2620 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to | |
2608 | prevent crashes if sys lacks an argv attribute (it happens with |
|
2621 | prevent crashes if sys lacks an argv attribute (it happens with | |
2609 | embedded interpreters which build a bare-bones sys module). |
|
2622 | embedded interpreters which build a bare-bones sys module). | |
2610 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. |
|
2623 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. | |
2611 |
|
2624 | |||
2612 | 2003-09-24 Fernando Perez <fperez@colorado.edu> |
|
2625 | 2003-09-24 Fernando Perez <fperez@colorado.edu> | |
2613 |
|
2626 | |||
2614 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() |
|
2627 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() | |
2615 | to protect against poorly written user objects where __getattr__ |
|
2628 | to protect against poorly written user objects where __getattr__ | |
2616 | raises exceptions other than AttributeError. Thanks to a bug |
|
2629 | raises exceptions other than AttributeError. Thanks to a bug | |
2617 | report by Oliver Sander <osander-AT-gmx.de>. |
|
2630 | report by Oliver Sander <osander-AT-gmx.de>. | |
2618 |
|
2631 | |||
2619 | * IPython/FakeModule.py (FakeModule.__repr__): this method was |
|
2632 | * IPython/FakeModule.py (FakeModule.__repr__): this method was | |
2620 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. |
|
2633 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. | |
2621 |
|
2634 | |||
2622 | 2003-09-09 Fernando Perez <fperez@colorado.edu> |
|
2635 | 2003-09-09 Fernando Perez <fperez@colorado.edu> | |
2623 |
|
2636 | |||
2624 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
2637 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
2625 | unpacking a list whith a callable as first element would |
|
2638 | unpacking a list whith a callable as first element would | |
2626 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery |
|
2639 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery | |
2627 | Collins. |
|
2640 | Collins. | |
2628 |
|
2641 | |||
2629 | 2003-08-25 *** Released version 0.5.0 |
|
2642 | 2003-08-25 *** Released version 0.5.0 | |
2630 |
|
2643 | |||
2631 | 2003-08-22 Fernando Perez <fperez@colorado.edu> |
|
2644 | 2003-08-22 Fernando Perez <fperez@colorado.edu> | |
2632 |
|
2645 | |||
2633 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of |
|
2646 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of | |
2634 | improperly defined user exceptions. Thanks to feedback from Mark |
|
2647 | improperly defined user exceptions. Thanks to feedback from Mark | |
2635 | Russell <mrussell-AT-verio.net>. |
|
2648 | Russell <mrussell-AT-verio.net>. | |
2636 |
|
2649 | |||
2637 | 2003-08-20 Fernando Perez <fperez@colorado.edu> |
|
2650 | 2003-08-20 Fernando Perez <fperez@colorado.edu> | |
2638 |
|
2651 | |||
2639 | * IPython/OInspect.py (Inspector.pinfo): changed String Form |
|
2652 | * IPython/OInspect.py (Inspector.pinfo): changed String Form | |
2640 | printing so that it would print multi-line string forms starting |
|
2653 | printing so that it would print multi-line string forms starting | |
2641 | with a new line. This way the formatting is better respected for |
|
2654 | with a new line. This way the formatting is better respected for | |
2642 | objects which work hard to make nice string forms. |
|
2655 | objects which work hard to make nice string forms. | |
2643 |
|
2656 | |||
2644 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where |
|
2657 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where | |
2645 | autocall would overtake data access for objects with both |
|
2658 | autocall would overtake data access for objects with both | |
2646 | __getitem__ and __call__. |
|
2659 | __getitem__ and __call__. | |
2647 |
|
2660 | |||
2648 | 2003-08-19 *** Released version 0.5.0-rc1 |
|
2661 | 2003-08-19 *** Released version 0.5.0-rc1 | |
2649 |
|
2662 | |||
2650 | 2003-08-19 Fernando Perez <fperez@colorado.edu> |
|
2663 | 2003-08-19 Fernando Perez <fperez@colorado.edu> | |
2651 |
|
2664 | |||
2652 | * IPython/deep_reload.py (load_tail): single tiny change here |
|
2665 | * IPython/deep_reload.py (load_tail): single tiny change here | |
2653 | seems to fix the long-standing bug of dreload() failing to work |
|
2666 | seems to fix the long-standing bug of dreload() failing to work | |
2654 | for dotted names. But this module is pretty tricky, so I may have |
|
2667 | for dotted names. But this module is pretty tricky, so I may have | |
2655 | missed some subtlety. Needs more testing!. |
|
2668 | missed some subtlety. Needs more testing!. | |
2656 |
|
2669 | |||
2657 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user |
|
2670 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user | |
2658 | exceptions which have badly implemented __str__ methods. |
|
2671 | exceptions which have badly implemented __str__ methods. | |
2659 | (VerboseTB.text): harden against inspect.getinnerframes crashing, |
|
2672 | (VerboseTB.text): harden against inspect.getinnerframes crashing, | |
2660 | which I've been getting reports about from Python 2.3 users. I |
|
2673 | which I've been getting reports about from Python 2.3 users. I | |
2661 | wish I had a simple test case to reproduce the problem, so I could |
|
2674 | wish I had a simple test case to reproduce the problem, so I could | |
2662 | either write a cleaner workaround or file a bug report if |
|
2675 | either write a cleaner workaround or file a bug report if | |
2663 | necessary. |
|
2676 | necessary. | |
2664 |
|
2677 | |||
2665 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after |
|
2678 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after | |
2666 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to |
|
2679 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to | |
2667 | a bug report by Tjabo Kloppenburg. |
|
2680 | a bug report by Tjabo Kloppenburg. | |
2668 |
|
2681 | |||
2669 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb |
|
2682 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb | |
2670 | crashes. Wrapped the pdb call in a blanket try/except, since pdb |
|
2683 | crashes. Wrapped the pdb call in a blanket try/except, since pdb | |
2671 | seems rather unstable. Thanks to a bug report by Tjabo |
|
2684 | seems rather unstable. Thanks to a bug report by Tjabo | |
2672 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. |
|
2685 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. | |
2673 |
|
2686 | |||
2674 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put |
|
2687 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put | |
2675 | this out soon because of the critical fixes in the inner loop for |
|
2688 | this out soon because of the critical fixes in the inner loop for | |
2676 | generators. |
|
2689 | generators. | |
2677 |
|
2690 | |||
2678 | * IPython/Magic.py (Magic.getargspec): removed. This (and |
|
2691 | * IPython/Magic.py (Magic.getargspec): removed. This (and | |
2679 | _get_def) have been obsoleted by OInspect for a long time, I |
|
2692 | _get_def) have been obsoleted by OInspect for a long time, I | |
2680 | hadn't noticed that they were dead code. |
|
2693 | hadn't noticed that they were dead code. | |
2681 | (Magic._ofind): restored _ofind functionality for a few literals |
|
2694 | (Magic._ofind): restored _ofind functionality for a few literals | |
2682 | (those in ["''",'""','[]','{}','()']). But it won't work anymore |
|
2695 | (those in ["''",'""','[]','{}','()']). But it won't work anymore | |
2683 | for things like "hello".capitalize?, since that would require a |
|
2696 | for things like "hello".capitalize?, since that would require a | |
2684 | potentially dangerous eval() again. |
|
2697 | potentially dangerous eval() again. | |
2685 |
|
2698 | |||
2686 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the |
|
2699 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the | |
2687 | logic a bit more to clean up the escapes handling and minimize the |
|
2700 | logic a bit more to clean up the escapes handling and minimize the | |
2688 | use of _ofind to only necessary cases. The interactive 'feel' of |
|
2701 | use of _ofind to only necessary cases. The interactive 'feel' of | |
2689 | IPython should have improved quite a bit with the changes in |
|
2702 | IPython should have improved quite a bit with the changes in | |
2690 | _prefilter and _ofind (besides being far safer than before). |
|
2703 | _prefilter and _ofind (besides being far safer than before). | |
2691 |
|
2704 | |||
2692 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather |
|
2705 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather | |
2693 | obscure, never reported). Edit would fail to find the object to |
|
2706 | obscure, never reported). Edit would fail to find the object to | |
2694 | edit under some circumstances. |
|
2707 | edit under some circumstances. | |
2695 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls |
|
2708 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls | |
2696 | which were causing double-calling of generators. Those eval calls |
|
2709 | which were causing double-calling of generators. Those eval calls | |
2697 | were _very_ dangerous, since code with side effects could be |
|
2710 | were _very_ dangerous, since code with side effects could be | |
2698 | triggered. As they say, 'eval is evil'... These were the |
|
2711 | triggered. As they say, 'eval is evil'... These were the | |
2699 | nastiest evals in IPython. Besides, _ofind is now far simpler, |
|
2712 | nastiest evals in IPython. Besides, _ofind is now far simpler, | |
2700 | and it should also be quite a bit faster. Its use of inspect is |
|
2713 | and it should also be quite a bit faster. Its use of inspect is | |
2701 | also safer, so perhaps some of the inspect-related crashes I've |
|
2714 | also safer, so perhaps some of the inspect-related crashes I've | |
2702 | seen lately with Python 2.3 might be taken care of. That will |
|
2715 | seen lately with Python 2.3 might be taken care of. That will | |
2703 | need more testing. |
|
2716 | need more testing. | |
2704 |
|
2717 | |||
2705 | 2003-08-17 Fernando Perez <fperez@colorado.edu> |
|
2718 | 2003-08-17 Fernando Perez <fperez@colorado.edu> | |
2706 |
|
2719 | |||
2707 | * IPython/iplib.py (InteractiveShell._prefilter): significant |
|
2720 | * IPython/iplib.py (InteractiveShell._prefilter): significant | |
2708 | simplifications to the logic for handling user escapes. Faster |
|
2721 | simplifications to the logic for handling user escapes. Faster | |
2709 | and simpler code. |
|
2722 | and simpler code. | |
2710 |
|
2723 | |||
2711 | 2003-08-14 Fernando Perez <fperez@colorado.edu> |
|
2724 | 2003-08-14 Fernando Perez <fperez@colorado.edu> | |
2712 |
|
2725 | |||
2713 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. |
|
2726 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. | |
2714 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, |
|
2727 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, | |
2715 | but it should be quite a bit faster. And the recursive version |
|
2728 | but it should be quite a bit faster. And the recursive version | |
2716 | generated O(log N) intermediate storage for all rank>1 arrays, |
|
2729 | generated O(log N) intermediate storage for all rank>1 arrays, | |
2717 | even if they were contiguous. |
|
2730 | even if they were contiguous. | |
2718 | (l1norm): Added this function. |
|
2731 | (l1norm): Added this function. | |
2719 | (norm): Added this function for arbitrary norms (including |
|
2732 | (norm): Added this function for arbitrary norms (including | |
2720 | l-infinity). l1 and l2 are still special cases for convenience |
|
2733 | l-infinity). l1 and l2 are still special cases for convenience | |
2721 | and speed. |
|
2734 | and speed. | |
2722 |
|
2735 | |||
2723 | 2003-08-03 Fernando Perez <fperez@colorado.edu> |
|
2736 | 2003-08-03 Fernando Perez <fperez@colorado.edu> | |
2724 |
|
2737 | |||
2725 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string |
|
2738 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string | |
2726 | exceptions, which now raise PendingDeprecationWarnings in Python |
|
2739 | exceptions, which now raise PendingDeprecationWarnings in Python | |
2727 | 2.3. There were some in Magic and some in Gnuplot2. |
|
2740 | 2.3. There were some in Magic and some in Gnuplot2. | |
2728 |
|
2741 | |||
2729 | 2003-06-30 Fernando Perez <fperez@colorado.edu> |
|
2742 | 2003-06-30 Fernando Perez <fperez@colorado.edu> | |
2730 |
|
2743 | |||
2731 | * IPython/genutils.py (page): modified to call curses only for |
|
2744 | * IPython/genutils.py (page): modified to call curses only for | |
2732 | terminals where TERM=='xterm'. After problems under many other |
|
2745 | terminals where TERM=='xterm'. After problems under many other | |
2733 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. |
|
2746 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. | |
2734 |
|
2747 | |||
2735 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which |
|
2748 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which | |
2736 | would be triggered when readline was absent. This was just an old |
|
2749 | would be triggered when readline was absent. This was just an old | |
2737 | debugging statement I'd forgotten to take out. |
|
2750 | debugging statement I'd forgotten to take out. | |
2738 |
|
2751 | |||
2739 | 2003-06-20 Fernando Perez <fperez@colorado.edu> |
|
2752 | 2003-06-20 Fernando Perez <fperez@colorado.edu> | |
2740 |
|
2753 | |||
2741 | * IPython/genutils.py (clock): modified to return only user time |
|
2754 | * IPython/genutils.py (clock): modified to return only user time | |
2742 | (not counting system time), after a discussion on scipy. While |
|
2755 | (not counting system time), after a discussion on scipy. While | |
2743 | system time may be a useful quantity occasionally, it may much |
|
2756 | system time may be a useful quantity occasionally, it may much | |
2744 | more easily be skewed by occasional swapping or other similar |
|
2757 | more easily be skewed by occasional swapping or other similar | |
2745 | activity. |
|
2758 | activity. | |
2746 |
|
2759 | |||
2747 | 2003-06-05 Fernando Perez <fperez@colorado.edu> |
|
2760 | 2003-06-05 Fernando Perez <fperez@colorado.edu> | |
2748 |
|
2761 | |||
2749 | * IPython/numutils.py (identity): new function, for building |
|
2762 | * IPython/numutils.py (identity): new function, for building | |
2750 | arbitrary rank Kronecker deltas (mostly backwards compatible with |
|
2763 | arbitrary rank Kronecker deltas (mostly backwards compatible with | |
2751 | Numeric.identity) |
|
2764 | Numeric.identity) | |
2752 |
|
2765 | |||
2753 | 2003-06-03 Fernando Perez <fperez@colorado.edu> |
|
2766 | 2003-06-03 Fernando Perez <fperez@colorado.edu> | |
2754 |
|
2767 | |||
2755 | * IPython/iplib.py (InteractiveShell.handle_magic): protect |
|
2768 | * IPython/iplib.py (InteractiveShell.handle_magic): protect | |
2756 | arguments passed to magics with spaces, to allow trailing '\' to |
|
2769 | arguments passed to magics with spaces, to allow trailing '\' to | |
2757 | work normally (mainly for Windows users). |
|
2770 | work normally (mainly for Windows users). | |
2758 |
|
2771 | |||
2759 | 2003-05-29 Fernando Perez <fperez@colorado.edu> |
|
2772 | 2003-05-29 Fernando Perez <fperez@colorado.edu> | |
2760 |
|
2773 | |||
2761 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help |
|
2774 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help | |
2762 | instead of pydoc.help. This fixes a bizarre behavior where |
|
2775 | instead of pydoc.help. This fixes a bizarre behavior where | |
2763 | printing '%s' % locals() would trigger the help system. Now |
|
2776 | printing '%s' % locals() would trigger the help system. Now | |
2764 | ipython behaves like normal python does. |
|
2777 | ipython behaves like normal python does. | |
2765 |
|
2778 | |||
2766 | Note that if one does 'from pydoc import help', the bizarre |
|
2779 | Note that if one does 'from pydoc import help', the bizarre | |
2767 | behavior returns, but this will also happen in normal python, so |
|
2780 | behavior returns, but this will also happen in normal python, so | |
2768 | it's not an ipython bug anymore (it has to do with how pydoc.help |
|
2781 | it's not an ipython bug anymore (it has to do with how pydoc.help | |
2769 | is implemented). |
|
2782 | is implemented). | |
2770 |
|
2783 | |||
2771 | 2003-05-22 Fernando Perez <fperez@colorado.edu> |
|
2784 | 2003-05-22 Fernando Perez <fperez@colorado.edu> | |
2772 |
|
2785 | |||
2773 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to |
|
2786 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to | |
2774 | return [] instead of None when nothing matches, also match to end |
|
2787 | return [] instead of None when nothing matches, also match to end | |
2775 | of line. Patch by Gary Bishop. |
|
2788 | of line. Patch by Gary Bishop. | |
2776 |
|
2789 | |||
2777 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook |
|
2790 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook | |
2778 | protection as before, for files passed on the command line. This |
|
2791 | protection as before, for files passed on the command line. This | |
2779 | prevents the CrashHandler from kicking in if user files call into |
|
2792 | prevents the CrashHandler from kicking in if user files call into | |
2780 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of |
|
2793 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of | |
2781 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> |
|
2794 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> | |
2782 |
|
2795 | |||
2783 | 2003-05-20 *** Released version 0.4.0 |
|
2796 | 2003-05-20 *** Released version 0.4.0 | |
2784 |
|
2797 | |||
2785 | 2003-05-20 Fernando Perez <fperez@colorado.edu> |
|
2798 | 2003-05-20 Fernando Perez <fperez@colorado.edu> | |
2786 |
|
2799 | |||
2787 | * setup.py: added support for manpages. It's a bit hackish b/c of |
|
2800 | * setup.py: added support for manpages. It's a bit hackish b/c of | |
2788 | a bug in the way the bdist_rpm distutils target handles gzipped |
|
2801 | a bug in the way the bdist_rpm distutils target handles gzipped | |
2789 | manpages, but it works. After a patch by Jack. |
|
2802 | manpages, but it works. After a patch by Jack. | |
2790 |
|
2803 | |||
2791 | 2003-05-19 Fernando Perez <fperez@colorado.edu> |
|
2804 | 2003-05-19 Fernando Perez <fperez@colorado.edu> | |
2792 |
|
2805 | |||
2793 | * IPython/numutils.py: added a mockup of the kinds module, since |
|
2806 | * IPython/numutils.py: added a mockup of the kinds module, since | |
2794 | it was recently removed from Numeric. This way, numutils will |
|
2807 | it was recently removed from Numeric. This way, numutils will | |
2795 | work for all users even if they are missing kinds. |
|
2808 | work for all users even if they are missing kinds. | |
2796 |
|
2809 | |||
2797 | * IPython/Magic.py (Magic._ofind): Harden against an inspect |
|
2810 | * IPython/Magic.py (Magic._ofind): Harden against an inspect | |
2798 | failure, which can occur with SWIG-wrapped extensions. After a |
|
2811 | failure, which can occur with SWIG-wrapped extensions. After a | |
2799 | crash report from Prabhu. |
|
2812 | crash report from Prabhu. | |
2800 |
|
2813 | |||
2801 | 2003-05-16 Fernando Perez <fperez@colorado.edu> |
|
2814 | 2003-05-16 Fernando Perez <fperez@colorado.edu> | |
2802 |
|
2815 | |||
2803 | * IPython/iplib.py (InteractiveShell.excepthook): New method to |
|
2816 | * IPython/iplib.py (InteractiveShell.excepthook): New method to | |
2804 | protect ipython from user code which may call directly |
|
2817 | protect ipython from user code which may call directly | |
2805 | sys.excepthook (this looks like an ipython crash to the user, even |
|
2818 | sys.excepthook (this looks like an ipython crash to the user, even | |
2806 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2819 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2807 | This is especially important to help users of WxWindows, but may |
|
2820 | This is especially important to help users of WxWindows, but may | |
2808 | also be useful in other cases. |
|
2821 | also be useful in other cases. | |
2809 |
|
2822 | |||
2810 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow |
|
2823 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow | |
2811 | an optional tb_offset to be specified, and to preserve exception |
|
2824 | an optional tb_offset to be specified, and to preserve exception | |
2812 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2825 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
2813 |
|
2826 | |||
2814 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! |
|
2827 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! | |
2815 |
|
2828 | |||
2816 | 2003-05-15 Fernando Perez <fperez@colorado.edu> |
|
2829 | 2003-05-15 Fernando Perez <fperez@colorado.edu> | |
2817 |
|
2830 | |||
2818 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when |
|
2831 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when | |
2819 | installing for a new user under Windows. |
|
2832 | installing for a new user under Windows. | |
2820 |
|
2833 | |||
2821 | 2003-05-12 Fernando Perez <fperez@colorado.edu> |
|
2834 | 2003-05-12 Fernando Perez <fperez@colorado.edu> | |
2822 |
|
2835 | |||
2823 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line |
|
2836 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line | |
2824 | handler for Emacs comint-based lines. Currently it doesn't do |
|
2837 | handler for Emacs comint-based lines. Currently it doesn't do | |
2825 | much (but importantly, it doesn't update the history cache). In |
|
2838 | much (but importantly, it doesn't update the history cache). In | |
2826 | the future it may be expanded if Alex needs more functionality |
|
2839 | the future it may be expanded if Alex needs more functionality | |
2827 | there. |
|
2840 | there. | |
2828 |
|
2841 | |||
2829 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform |
|
2842 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform | |
2830 | info to crash reports. |
|
2843 | info to crash reports. | |
2831 |
|
2844 | |||
2832 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, |
|
2845 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, | |
2833 | just like Python's -c. Also fixed crash with invalid -color |
|
2846 | just like Python's -c. Also fixed crash with invalid -color | |
2834 | option value at startup. Thanks to Will French |
|
2847 | option value at startup. Thanks to Will French | |
2835 | <wfrench-AT-bestweb.net> for the bug report. |
|
2848 | <wfrench-AT-bestweb.net> for the bug report. | |
2836 |
|
2849 | |||
2837 | 2003-05-09 Fernando Perez <fperez@colorado.edu> |
|
2850 | 2003-05-09 Fernando Perez <fperez@colorado.edu> | |
2838 |
|
2851 | |||
2839 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString |
|
2852 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString | |
2840 | to EvalDict (it's a mapping, after all) and simplified its code |
|
2853 | to EvalDict (it's a mapping, after all) and simplified its code | |
2841 | quite a bit, after a nice discussion on c.l.py where Gustavo |
|
2854 | quite a bit, after a nice discussion on c.l.py where Gustavo | |
2842 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. |
|
2855 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. | |
2843 |
|
2856 | |||
2844 | 2003-04-30 Fernando Perez <fperez@colorado.edu> |
|
2857 | 2003-04-30 Fernando Perez <fperez@colorado.edu> | |
2845 |
|
2858 | |||
2846 | * IPython/genutils.py (timings_out): modified it to reduce its |
|
2859 | * IPython/genutils.py (timings_out): modified it to reduce its | |
2847 | overhead in the common reps==1 case. |
|
2860 | overhead in the common reps==1 case. | |
2848 |
|
2861 | |||
2849 | 2003-04-29 Fernando Perez <fperez@colorado.edu> |
|
2862 | 2003-04-29 Fernando Perez <fperez@colorado.edu> | |
2850 |
|
2863 | |||
2851 | * IPython/genutils.py (timings_out): Modified to use the resource |
|
2864 | * IPython/genutils.py (timings_out): Modified to use the resource | |
2852 | module, which avoids the wraparound problems of time.clock(). |
|
2865 | module, which avoids the wraparound problems of time.clock(). | |
2853 |
|
2866 | |||
2854 | 2003-04-17 *** Released version 0.2.15pre4 |
|
2867 | 2003-04-17 *** Released version 0.2.15pre4 | |
2855 |
|
2868 | |||
2856 | 2003-04-17 Fernando Perez <fperez@colorado.edu> |
|
2869 | 2003-04-17 Fernando Perez <fperez@colorado.edu> | |
2857 |
|
2870 | |||
2858 | * setup.py (scriptfiles): Split windows-specific stuff over to a |
|
2871 | * setup.py (scriptfiles): Split windows-specific stuff over to a | |
2859 | separate file, in an attempt to have a Windows GUI installer. |
|
2872 | separate file, in an attempt to have a Windows GUI installer. | |
2860 | That didn't work, but part of the groundwork is done. |
|
2873 | That didn't work, but part of the groundwork is done. | |
2861 |
|
2874 | |||
2862 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for |
|
2875 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for | |
2863 | indent/unindent with 4 spaces. Particularly useful in combination |
|
2876 | indent/unindent with 4 spaces. Particularly useful in combination | |
2864 | with the new auto-indent option. |
|
2877 | with the new auto-indent option. | |
2865 |
|
2878 | |||
2866 | 2003-04-16 Fernando Perez <fperez@colorado.edu> |
|
2879 | 2003-04-16 Fernando Perez <fperez@colorado.edu> | |
2867 |
|
2880 | |||
2868 | * IPython/Magic.py: various replacements of self.rc for |
|
2881 | * IPython/Magic.py: various replacements of self.rc for | |
2869 | self.shell.rc. A lot more remains to be done to fully disentangle |
|
2882 | self.shell.rc. A lot more remains to be done to fully disentangle | |
2870 | this class from the main Shell class. |
|
2883 | this class from the main Shell class. | |
2871 |
|
2884 | |||
2872 | * IPython/GnuplotRuntime.py: added checks for mouse support so |
|
2885 | * IPython/GnuplotRuntime.py: added checks for mouse support so | |
2873 | that we don't try to enable it if the current gnuplot doesn't |
|
2886 | that we don't try to enable it if the current gnuplot doesn't | |
2874 | really support it. Also added checks so that we don't try to |
|
2887 | really support it. Also added checks so that we don't try to | |
2875 | enable persist under Windows (where Gnuplot doesn't recognize the |
|
2888 | enable persist under Windows (where Gnuplot doesn't recognize the | |
2876 | option). |
|
2889 | option). | |
2877 |
|
2890 | |||
2878 | * IPython/iplib.py (InteractiveShell.interact): Added optional |
|
2891 | * IPython/iplib.py (InteractiveShell.interact): Added optional | |
2879 | auto-indenting code, after a patch by King C. Shu |
|
2892 | auto-indenting code, after a patch by King C. Shu | |
2880 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't |
|
2893 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't | |
2881 | get along well with pasting indented code. If I ever figure out |
|
2894 | get along well with pasting indented code. If I ever figure out | |
2882 | how to make that part go well, it will become on by default. |
|
2895 | how to make that part go well, it will become on by default. | |
2883 |
|
2896 | |||
2884 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would |
|
2897 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would | |
2885 | crash ipython if there was an unmatched '%' in the user's prompt |
|
2898 | crash ipython if there was an unmatched '%' in the user's prompt | |
2886 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2899 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2887 |
|
2900 | |||
2888 | * IPython/iplib.py (InteractiveShell.interact): removed the |
|
2901 | * IPython/iplib.py (InteractiveShell.interact): removed the | |
2889 | ability to ask the user whether he wants to crash or not at the |
|
2902 | ability to ask the user whether he wants to crash or not at the | |
2890 | 'last line' exception handler. Calling functions at that point |
|
2903 | 'last line' exception handler. Calling functions at that point | |
2891 | changes the stack, and the error reports would have incorrect |
|
2904 | changes the stack, and the error reports would have incorrect | |
2892 | tracebacks. |
|
2905 | tracebacks. | |
2893 |
|
2906 | |||
2894 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to |
|
2907 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to | |
2895 | pass through a peger a pretty-printed form of any object. After a |
|
2908 | pass through a peger a pretty-printed form of any object. After a | |
2896 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> |
|
2909 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> | |
2897 |
|
2910 | |||
2898 | 2003-04-14 Fernando Perez <fperez@colorado.edu> |
|
2911 | 2003-04-14 Fernando Perez <fperez@colorado.edu> | |
2899 |
|
2912 | |||
2900 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where |
|
2913 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where | |
2901 | all files in ~ would be modified at first install (instead of |
|
2914 | all files in ~ would be modified at first install (instead of | |
2902 | ~/.ipython). This could be potentially disastrous, as the |
|
2915 | ~/.ipython). This could be potentially disastrous, as the | |
2903 | modification (make line-endings native) could damage binary files. |
|
2916 | modification (make line-endings native) could damage binary files. | |
2904 |
|
2917 | |||
2905 | 2003-04-10 Fernando Perez <fperez@colorado.edu> |
|
2918 | 2003-04-10 Fernando Perez <fperez@colorado.edu> | |
2906 |
|
2919 | |||
2907 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to |
|
2920 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to | |
2908 | handle only lines which are invalid python. This now means that |
|
2921 | handle only lines which are invalid python. This now means that | |
2909 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins |
|
2922 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins | |
2910 | for the bug report. |
|
2923 | for the bug report. | |
2911 |
|
2924 | |||
2912 | 2003-04-01 Fernando Perez <fperez@colorado.edu> |
|
2925 | 2003-04-01 Fernando Perez <fperez@colorado.edu> | |
2913 |
|
2926 | |||
2914 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug |
|
2927 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug | |
2915 | where failing to set sys.last_traceback would crash pdb.pm(). |
|
2928 | where failing to set sys.last_traceback would crash pdb.pm(). | |
2916 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug |
|
2929 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug | |
2917 | report. |
|
2930 | report. | |
2918 |
|
2931 | |||
2919 | 2003-03-25 Fernando Perez <fperez@colorado.edu> |
|
2932 | 2003-03-25 Fernando Perez <fperez@colorado.edu> | |
2920 |
|
2933 | |||
2921 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler |
|
2934 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler | |
2922 | before printing it (it had a lot of spurious blank lines at the |
|
2935 | before printing it (it had a lot of spurious blank lines at the | |
2923 | end). |
|
2936 | end). | |
2924 |
|
2937 | |||
2925 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr |
|
2938 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr | |
2926 | output would be sent 21 times! Obviously people don't use this |
|
2939 | output would be sent 21 times! Obviously people don't use this | |
2927 | too often, or I would have heard about it. |
|
2940 | too often, or I would have heard about it. | |
2928 |
|
2941 | |||
2929 | 2003-03-24 Fernando Perez <fperez@colorado.edu> |
|
2942 | 2003-03-24 Fernando Perez <fperez@colorado.edu> | |
2930 |
|
2943 | |||
2931 | * setup.py (scriptfiles): renamed the data_files parameter from |
|
2944 | * setup.py (scriptfiles): renamed the data_files parameter from | |
2932 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink |
|
2945 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink | |
2933 | for the patch. |
|
2946 | for the patch. | |
2934 |
|
2947 | |||
2935 | 2003-03-20 Fernando Perez <fperez@colorado.edu> |
|
2948 | 2003-03-20 Fernando Perez <fperez@colorado.edu> | |
2936 |
|
2949 | |||
2937 | * IPython/genutils.py (error): added error() and fatal() |
|
2950 | * IPython/genutils.py (error): added error() and fatal() | |
2938 | functions. |
|
2951 | functions. | |
2939 |
|
2952 | |||
2940 | 2003-03-18 *** Released version 0.2.15pre3 |
|
2953 | 2003-03-18 *** Released version 0.2.15pre3 | |
2941 |
|
2954 | |||
2942 | 2003-03-18 Fernando Perez <fperez@colorado.edu> |
|
2955 | 2003-03-18 Fernando Perez <fperez@colorado.edu> | |
2943 |
|
2956 | |||
2944 | * setupext/install_data_ext.py |
|
2957 | * setupext/install_data_ext.py | |
2945 | (install_data_ext.initialize_options): Class contributed by Jack |
|
2958 | (install_data_ext.initialize_options): Class contributed by Jack | |
2946 | Moffit for fixing the old distutils hack. He is sending this to |
|
2959 | Moffit for fixing the old distutils hack. He is sending this to | |
2947 | the distutils folks so in the future we may not need it as a |
|
2960 | the distutils folks so in the future we may not need it as a | |
2948 | private fix. |
|
2961 | private fix. | |
2949 |
|
2962 | |||
2950 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's |
|
2963 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's | |
2951 | changes for Debian packaging. See his patch for full details. |
|
2964 | changes for Debian packaging. See his patch for full details. | |
2952 | The old distutils hack of making the ipythonrc* files carry a |
|
2965 | The old distutils hack of making the ipythonrc* files carry a | |
2953 | bogus .py extension is gone, at last. Examples were moved to a |
|
2966 | bogus .py extension is gone, at last. Examples were moved to a | |
2954 | separate subdir under doc/, and the separate executable scripts |
|
2967 | separate subdir under doc/, and the separate executable scripts | |
2955 | now live in their own directory. Overall a great cleanup. The |
|
2968 | now live in their own directory. Overall a great cleanup. The | |
2956 | manual was updated to use the new files, and setup.py has been |
|
2969 | manual was updated to use the new files, and setup.py has been | |
2957 | fixed for this setup. |
|
2970 | fixed for this setup. | |
2958 |
|
2971 | |||
2959 | * IPython/PyColorize.py (Parser.usage): made non-executable and |
|
2972 | * IPython/PyColorize.py (Parser.usage): made non-executable and | |
2960 | created a pycolor wrapper around it to be included as a script. |
|
2973 | created a pycolor wrapper around it to be included as a script. | |
2961 |
|
2974 | |||
2962 | 2003-03-12 *** Released version 0.2.15pre2 |
|
2975 | 2003-03-12 *** Released version 0.2.15pre2 | |
2963 |
|
2976 | |||
2964 | 2003-03-12 Fernando Perez <fperez@colorado.edu> |
|
2977 | 2003-03-12 Fernando Perez <fperez@colorado.edu> | |
2965 |
|
2978 | |||
2966 | * IPython/ColorANSI.py (make_color_table): Finally fixed the |
|
2979 | * IPython/ColorANSI.py (make_color_table): Finally fixed the | |
2967 | long-standing problem with garbage characters in some terminals. |
|
2980 | long-standing problem with garbage characters in some terminals. | |
2968 | The issue was really that the \001 and \002 escapes must _only_ be |
|
2981 | The issue was really that the \001 and \002 escapes must _only_ be | |
2969 | passed to input prompts (which call readline), but _never_ to |
|
2982 | passed to input prompts (which call readline), but _never_ to | |
2970 | normal text to be printed on screen. I changed ColorANSI to have |
|
2983 | normal text to be printed on screen. I changed ColorANSI to have | |
2971 | two classes: TermColors and InputTermColors, each with the |
|
2984 | two classes: TermColors and InputTermColors, each with the | |
2972 | appropriate escapes for input prompts or normal text. The code in |
|
2985 | appropriate escapes for input prompts or normal text. The code in | |
2973 | Prompts.py got slightly more complicated, but this very old and |
|
2986 | Prompts.py got slightly more complicated, but this very old and | |
2974 | annoying bug is finally fixed. |
|
2987 | annoying bug is finally fixed. | |
2975 |
|
2988 | |||
2976 | All the credit for nailing down the real origin of this problem |
|
2989 | All the credit for nailing down the real origin of this problem | |
2977 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. |
|
2990 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. | |
2978 | *Many* thanks to him for spending quite a bit of effort on this. |
|
2991 | *Many* thanks to him for spending quite a bit of effort on this. | |
2979 |
|
2992 | |||
2980 | 2003-03-05 *** Released version 0.2.15pre1 |
|
2993 | 2003-03-05 *** Released version 0.2.15pre1 | |
2981 |
|
2994 | |||
2982 | 2003-03-03 Fernando Perez <fperez@colorado.edu> |
|
2995 | 2003-03-03 Fernando Perez <fperez@colorado.edu> | |
2983 |
|
2996 | |||
2984 | * IPython/FakeModule.py: Moved the former _FakeModule to a |
|
2997 | * IPython/FakeModule.py: Moved the former _FakeModule to a | |
2985 | separate file, because it's also needed by Magic (to fix a similar |
|
2998 | separate file, because it's also needed by Magic (to fix a similar | |
2986 | pickle-related issue in @run). |
|
2999 | pickle-related issue in @run). | |
2987 |
|
3000 | |||
2988 | 2003-03-02 Fernando Perez <fperez@colorado.edu> |
|
3001 | 2003-03-02 Fernando Perez <fperez@colorado.edu> | |
2989 |
|
3002 | |||
2990 | * IPython/Magic.py (Magic.magic_autocall): new magic to control |
|
3003 | * IPython/Magic.py (Magic.magic_autocall): new magic to control | |
2991 | the autocall option at runtime. |
|
3004 | the autocall option at runtime. | |
2992 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns |
|
3005 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns | |
2993 | across Magic.py to start separating Magic from InteractiveShell. |
|
3006 | across Magic.py to start separating Magic from InteractiveShell. | |
2994 | (Magic._ofind): Fixed to return proper namespace for dotted |
|
3007 | (Magic._ofind): Fixed to return proper namespace for dotted | |
2995 | names. Before, a dotted name would always return 'not currently |
|
3008 | names. Before, a dotted name would always return 'not currently | |
2996 | defined', because it would find the 'parent'. s.x would be found, |
|
3009 | defined', because it would find the 'parent'. s.x would be found, | |
2997 | but since 'x' isn't defined by itself, it would get confused. |
|
3010 | but since 'x' isn't defined by itself, it would get confused. | |
2998 | (Magic.magic_run): Fixed pickling problems reported by Ralf |
|
3011 | (Magic.magic_run): Fixed pickling problems reported by Ralf | |
2999 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to |
|
3012 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to | |
3000 | that I'd used when Mike Heeter reported similar issues at the |
|
3013 | that I'd used when Mike Heeter reported similar issues at the | |
3001 | top-level, but now for @run. It boils down to injecting the |
|
3014 | top-level, but now for @run. It boils down to injecting the | |
3002 | namespace where code is being executed with something that looks |
|
3015 | namespace where code is being executed with something that looks | |
3003 | enough like a module to fool pickle.dump(). Since a pickle stores |
|
3016 | enough like a module to fool pickle.dump(). Since a pickle stores | |
3004 | a named reference to the importing module, we need this for |
|
3017 | a named reference to the importing module, we need this for | |
3005 | pickles to save something sensible. |
|
3018 | pickles to save something sensible. | |
3006 |
|
3019 | |||
3007 | * IPython/ipmaker.py (make_IPython): added an autocall option. |
|
3020 | * IPython/ipmaker.py (make_IPython): added an autocall option. | |
3008 |
|
3021 | |||
3009 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of |
|
3022 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of | |
3010 | the auto-eval code. Now autocalling is an option, and the code is |
|
3023 | the auto-eval code. Now autocalling is an option, and the code is | |
3011 | also vastly safer. There is no more eval() involved at all. |
|
3024 | also vastly safer. There is no more eval() involved at all. | |
3012 |
|
3025 | |||
3013 | 2003-03-01 Fernando Perez <fperez@colorado.edu> |
|
3026 | 2003-03-01 Fernando Perez <fperez@colorado.edu> | |
3014 |
|
3027 | |||
3015 | * IPython/Magic.py (Magic._ofind): Changed interface to return a |
|
3028 | * IPython/Magic.py (Magic._ofind): Changed interface to return a | |
3016 | dict with named keys instead of a tuple. |
|
3029 | dict with named keys instead of a tuple. | |
3017 |
|
3030 | |||
3018 | * IPython: Started using CVS for IPython as of 0.2.15pre1. |
|
3031 | * IPython: Started using CVS for IPython as of 0.2.15pre1. | |
3019 |
|
3032 | |||
3020 | * setup.py (make_shortcut): Fixed message about directories |
|
3033 | * setup.py (make_shortcut): Fixed message about directories | |
3021 | created during Windows installation (the directories were ok, just |
|
3034 | created during Windows installation (the directories were ok, just | |
3022 | the printed message was misleading). Thanks to Chris Liechti |
|
3035 | the printed message was misleading). Thanks to Chris Liechti | |
3023 | <cliechti-AT-gmx.net> for the heads up. |
|
3036 | <cliechti-AT-gmx.net> for the heads up. | |
3024 |
|
3037 | |||
3025 | 2003-02-21 Fernando Perez <fperez@colorado.edu> |
|
3038 | 2003-02-21 Fernando Perez <fperez@colorado.edu> | |
3026 |
|
3039 | |||
3027 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching |
|
3040 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching | |
3028 | of ValueError exception when checking for auto-execution. This |
|
3041 | of ValueError exception when checking for auto-execution. This | |
3029 | one is raised by things like Numeric arrays arr.flat when the |
|
3042 | one is raised by things like Numeric arrays arr.flat when the | |
3030 | array is non-contiguous. |
|
3043 | array is non-contiguous. | |
3031 |
|
3044 | |||
3032 | 2003-01-31 Fernando Perez <fperez@colorado.edu> |
|
3045 | 2003-01-31 Fernando Perez <fperez@colorado.edu> | |
3033 |
|
3046 | |||
3034 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would |
|
3047 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would | |
3035 | not return any value at all (even though the command would get |
|
3048 | not return any value at all (even though the command would get | |
3036 | executed). |
|
3049 | executed). | |
3037 | (xsys): Flush stdout right after printing the command to ensure |
|
3050 | (xsys): Flush stdout right after printing the command to ensure | |
3038 | proper ordering of commands and command output in the total |
|
3051 | proper ordering of commands and command output in the total | |
3039 | output. |
|
3052 | output. | |
3040 | (SystemExec/xsys/bq): Switched the names of xsys/bq and |
|
3053 | (SystemExec/xsys/bq): Switched the names of xsys/bq and | |
3041 | system/getoutput as defaults. The old ones are kept for |
|
3054 | system/getoutput as defaults. The old ones are kept for | |
3042 | compatibility reasons, so no code which uses this library needs |
|
3055 | compatibility reasons, so no code which uses this library needs | |
3043 | changing. |
|
3056 | changing. | |
3044 |
|
3057 | |||
3045 | 2003-01-27 *** Released version 0.2.14 |
|
3058 | 2003-01-27 *** Released version 0.2.14 | |
3046 |
|
3059 | |||
3047 | 2003-01-25 Fernando Perez <fperez@colorado.edu> |
|
3060 | 2003-01-25 Fernando Perez <fperez@colorado.edu> | |
3048 |
|
3061 | |||
3049 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where |
|
3062 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where | |
3050 | functions defined in previous edit sessions could not be re-edited |
|
3063 | functions defined in previous edit sessions could not be re-edited | |
3051 | (because the temp files were immediately removed). Now temp files |
|
3064 | (because the temp files were immediately removed). Now temp files | |
3052 | are removed only at IPython's exit. |
|
3065 | are removed only at IPython's exit. | |
3053 | (Magic.magic_run): Improved @run to perform shell-like expansions |
|
3066 | (Magic.magic_run): Improved @run to perform shell-like expansions | |
3054 | on its arguments (~users and $VARS). With this, @run becomes more |
|
3067 | on its arguments (~users and $VARS). With this, @run becomes more | |
3055 | like a normal command-line. |
|
3068 | like a normal command-line. | |
3056 |
|
3069 | |||
3057 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small |
|
3070 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small | |
3058 | bugs related to embedding and cleaned up that code. A fairly |
|
3071 | bugs related to embedding and cleaned up that code. A fairly | |
3059 | important one was the impossibility to access the global namespace |
|
3072 | important one was the impossibility to access the global namespace | |
3060 | through the embedded IPython (only local variables were visible). |
|
3073 | through the embedded IPython (only local variables were visible). | |
3061 |
|
3074 | |||
3062 | 2003-01-14 Fernando Perez <fperez@colorado.edu> |
|
3075 | 2003-01-14 Fernando Perez <fperez@colorado.edu> | |
3063 |
|
3076 | |||
3064 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed |
|
3077 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed | |
3065 | auto-calling to be a bit more conservative. Now it doesn't get |
|
3078 | auto-calling to be a bit more conservative. Now it doesn't get | |
3066 | triggered if any of '!=()<>' are in the rest of the input line, to |
|
3079 | triggered if any of '!=()<>' are in the rest of the input line, to | |
3067 | allow comparing callables. Thanks to Alex for the heads up. |
|
3080 | allow comparing callables. Thanks to Alex for the heads up. | |
3068 |
|
3081 | |||
3069 | 2003-01-07 Fernando Perez <fperez@colorado.edu> |
|
3082 | 2003-01-07 Fernando Perez <fperez@colorado.edu> | |
3070 |
|
3083 | |||
3071 | * IPython/genutils.py (page): fixed estimation of the number of |
|
3084 | * IPython/genutils.py (page): fixed estimation of the number of | |
3072 | lines in a string to be paged to simply count newlines. This |
|
3085 | lines in a string to be paged to simply count newlines. This | |
3073 | prevents over-guessing due to embedded escape sequences. A better |
|
3086 | prevents over-guessing due to embedded escape sequences. A better | |
3074 | long-term solution would involve stripping out the control chars |
|
3087 | long-term solution would involve stripping out the control chars | |
3075 | for the count, but it's potentially so expensive I just don't |
|
3088 | for the count, but it's potentially so expensive I just don't | |
3076 | think it's worth doing. |
|
3089 | think it's worth doing. | |
3077 |
|
3090 | |||
3078 | 2002-12-19 *** Released version 0.2.14pre50 |
|
3091 | 2002-12-19 *** Released version 0.2.14pre50 | |
3079 |
|
3092 | |||
3080 | 2002-12-19 Fernando Perez <fperez@colorado.edu> |
|
3093 | 2002-12-19 Fernando Perez <fperez@colorado.edu> | |
3081 |
|
3094 | |||
3082 | * tools/release (version): Changed release scripts to inform |
|
3095 | * tools/release (version): Changed release scripts to inform | |
3083 | Andrea and build a NEWS file with a list of recent changes. |
|
3096 | Andrea and build a NEWS file with a list of recent changes. | |
3084 |
|
3097 | |||
3085 | * IPython/ColorANSI.py (__all__): changed terminal detection |
|
3098 | * IPython/ColorANSI.py (__all__): changed terminal detection | |
3086 | code. Seems to work better for xterms without breaking |
|
3099 | code. Seems to work better for xterms without breaking | |
3087 | konsole. Will need more testing to determine if WinXP and Mac OSX |
|
3100 | konsole. Will need more testing to determine if WinXP and Mac OSX | |
3088 | also work ok. |
|
3101 | also work ok. | |
3089 |
|
3102 | |||
3090 | 2002-12-18 *** Released version 0.2.14pre49 |
|
3103 | 2002-12-18 *** Released version 0.2.14pre49 | |
3091 |
|
3104 | |||
3092 | 2002-12-18 Fernando Perez <fperez@colorado.edu> |
|
3105 | 2002-12-18 Fernando Perez <fperez@colorado.edu> | |
3093 |
|
3106 | |||
3094 | * Docs: added new info about Mac OSX, from Andrea. |
|
3107 | * Docs: added new info about Mac OSX, from Andrea. | |
3095 |
|
3108 | |||
3096 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to |
|
3109 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to | |
3097 | allow direct plotting of python strings whose format is the same |
|
3110 | allow direct plotting of python strings whose format is the same | |
3098 | of gnuplot data files. |
|
3111 | of gnuplot data files. | |
3099 |
|
3112 | |||
3100 | 2002-12-16 Fernando Perez <fperez@colorado.edu> |
|
3113 | 2002-12-16 Fernando Perez <fperez@colorado.edu> | |
3101 |
|
3114 | |||
3102 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) |
|
3115 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) | |
3103 | value of exit question to be acknowledged. |
|
3116 | value of exit question to be acknowledged. | |
3104 |
|
3117 | |||
3105 | 2002-12-03 Fernando Perez <fperez@colorado.edu> |
|
3118 | 2002-12-03 Fernando Perez <fperez@colorado.edu> | |
3106 |
|
3119 | |||
3107 | * IPython/ipmaker.py: removed generators, which had been added |
|
3120 | * IPython/ipmaker.py: removed generators, which had been added | |
3108 | by mistake in an earlier debugging run. This was causing trouble |
|
3121 | by mistake in an earlier debugging run. This was causing trouble | |
3109 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> |
|
3122 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> | |
3110 | for pointing this out. |
|
3123 | for pointing this out. | |
3111 |
|
3124 | |||
3112 | 2002-11-17 Fernando Perez <fperez@colorado.edu> |
|
3125 | 2002-11-17 Fernando Perez <fperez@colorado.edu> | |
3113 |
|
3126 | |||
3114 | * Manual: updated the Gnuplot section. |
|
3127 | * Manual: updated the Gnuplot section. | |
3115 |
|
3128 | |||
3116 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with |
|
3129 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with | |
3117 | a much better split of what goes in Runtime and what goes in |
|
3130 | a much better split of what goes in Runtime and what goes in | |
3118 | Interactive. |
|
3131 | Interactive. | |
3119 |
|
3132 | |||
3120 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't |
|
3133 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't | |
3121 | being imported from iplib. |
|
3134 | being imported from iplib. | |
3122 |
|
3135 | |||
3123 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc |
|
3136 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc | |
3124 | for command-passing. Now the global Gnuplot instance is called |
|
3137 | for command-passing. Now the global Gnuplot instance is called | |
3125 | 'gp' instead of 'g', which was really a far too fragile and |
|
3138 | 'gp' instead of 'g', which was really a far too fragile and | |
3126 | common name. |
|
3139 | common name. | |
3127 |
|
3140 | |||
3128 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken |
|
3141 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken | |
3129 | bounding boxes generated by Gnuplot for square plots. |
|
3142 | bounding boxes generated by Gnuplot for square plots. | |
3130 |
|
3143 | |||
3131 | * IPython/genutils.py (popkey): new function added. I should |
|
3144 | * IPython/genutils.py (popkey): new function added. I should | |
3132 | suggest this on c.l.py as a dict method, it seems useful. |
|
3145 | suggest this on c.l.py as a dict method, it seems useful. | |
3133 |
|
3146 | |||
3134 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot |
|
3147 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot | |
3135 | to transparently handle PostScript generation. MUCH better than |
|
3148 | to transparently handle PostScript generation. MUCH better than | |
3136 | the previous plot_eps/replot_eps (which I removed now). The code |
|
3149 | the previous plot_eps/replot_eps (which I removed now). The code | |
3137 | is also fairly clean and well documented now (including |
|
3150 | is also fairly clean and well documented now (including | |
3138 | docstrings). |
|
3151 | docstrings). | |
3139 |
|
3152 | |||
3140 | 2002-11-13 Fernando Perez <fperez@colorado.edu> |
|
3153 | 2002-11-13 Fernando Perez <fperez@colorado.edu> | |
3141 |
|
3154 | |||
3142 | * IPython/Magic.py (Magic.magic_edit): fixed docstring |
|
3155 | * IPython/Magic.py (Magic.magic_edit): fixed docstring | |
3143 | (inconsistent with options). |
|
3156 | (inconsistent with options). | |
3144 |
|
3157 | |||
3145 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been |
|
3158 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been | |
3146 | manually disabled, I don't know why. Fixed it. |
|
3159 | manually disabled, I don't know why. Fixed it. | |
3147 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly |
|
3160 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly | |
3148 | eps output. |
|
3161 | eps output. | |
3149 |
|
3162 | |||
3150 | 2002-11-12 Fernando Perez <fperez@colorado.edu> |
|
3163 | 2002-11-12 Fernando Perez <fperez@colorado.edu> | |
3151 |
|
3164 | |||
3152 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they |
|
3165 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they | |
3153 | don't propagate up to caller. Fixes crash reported by François |
|
3166 | don't propagate up to caller. Fixes crash reported by François | |
3154 | Pinard. |
|
3167 | Pinard. | |
3155 |
|
3168 | |||
3156 | 2002-11-09 Fernando Perez <fperez@colorado.edu> |
|
3169 | 2002-11-09 Fernando Perez <fperez@colorado.edu> | |
3157 |
|
3170 | |||
3158 | * IPython/ipmaker.py (make_IPython): fixed problem with writing |
|
3171 | * IPython/ipmaker.py (make_IPython): fixed problem with writing | |
3159 | history file for new users. |
|
3172 | history file for new users. | |
3160 | (make_IPython): fixed bug where initial install would leave the |
|
3173 | (make_IPython): fixed bug where initial install would leave the | |
3161 | user running in the .ipython dir. |
|
3174 | user running in the .ipython dir. | |
3162 | (make_IPython): fixed bug where config dir .ipython would be |
|
3175 | (make_IPython): fixed bug where config dir .ipython would be | |
3163 | created regardless of the given -ipythondir option. Thanks to Cory |
|
3176 | created regardless of the given -ipythondir option. Thanks to Cory | |
3164 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. |
|
3177 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. | |
3165 |
|
3178 | |||
3166 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no |
|
3179 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no | |
3167 | type confirmations. Will need to use it in all of IPython's code |
|
3180 | type confirmations. Will need to use it in all of IPython's code | |
3168 | consistently. |
|
3181 | consistently. | |
3169 |
|
3182 | |||
3170 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the |
|
3183 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the | |
3171 | context to print 31 lines instead of the default 5. This will make |
|
3184 | context to print 31 lines instead of the default 5. This will make | |
3172 | the crash reports extremely detailed in case the problem is in |
|
3185 | the crash reports extremely detailed in case the problem is in | |
3173 | libraries I don't have access to. |
|
3186 | libraries I don't have access to. | |
3174 |
|
3187 | |||
3175 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last |
|
3188 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last | |
3176 | line of defense' code to still crash, but giving users fair |
|
3189 | line of defense' code to still crash, but giving users fair | |
3177 | warning. I don't want internal errors to go unreported: if there's |
|
3190 | warning. I don't want internal errors to go unreported: if there's | |
3178 | an internal problem, IPython should crash and generate a full |
|
3191 | an internal problem, IPython should crash and generate a full | |
3179 | report. |
|
3192 | report. | |
3180 |
|
3193 | |||
3181 | 2002-11-08 Fernando Perez <fperez@colorado.edu> |
|
3194 | 2002-11-08 Fernando Perez <fperez@colorado.edu> | |
3182 |
|
3195 | |||
3183 | * IPython/iplib.py (InteractiveShell.interact): added code to trap |
|
3196 | * IPython/iplib.py (InteractiveShell.interact): added code to trap | |
3184 | otherwise uncaught exceptions which can appear if people set |
|
3197 | otherwise uncaught exceptions which can appear if people set | |
3185 | sys.stdout to something badly broken. Thanks to a crash report |
|
3198 | sys.stdout to something badly broken. Thanks to a crash report | |
3186 | from henni-AT-mail.brainbot.com. |
|
3199 | from henni-AT-mail.brainbot.com. | |
3187 |
|
3200 | |||
3188 | 2002-11-04 Fernando Perez <fperez@colorado.edu> |
|
3201 | 2002-11-04 Fernando Perez <fperez@colorado.edu> | |
3189 |
|
3202 | |||
3190 | * IPython/iplib.py (InteractiveShell.interact): added |
|
3203 | * IPython/iplib.py (InteractiveShell.interact): added | |
3191 | __IPYTHON__active to the builtins. It's a flag which goes on when |
|
3204 | __IPYTHON__active to the builtins. It's a flag which goes on when | |
3192 | the interaction starts and goes off again when it stops. This |
|
3205 | the interaction starts and goes off again when it stops. This | |
3193 | allows embedding code to detect being inside IPython. Before this |
|
3206 | allows embedding code to detect being inside IPython. Before this | |
3194 | was done via __IPYTHON__, but that only shows that an IPython |
|
3207 | was done via __IPYTHON__, but that only shows that an IPython | |
3195 | instance has been created. |
|
3208 | instance has been created. | |
3196 |
|
3209 | |||
3197 | * IPython/Magic.py (Magic.magic_env): I realized that in a |
|
3210 | * IPython/Magic.py (Magic.magic_env): I realized that in a | |
3198 | UserDict, instance.data holds the data as a normal dict. So I |
|
3211 | UserDict, instance.data holds the data as a normal dict. So I | |
3199 | modified @env to return os.environ.data instead of rebuilding a |
|
3212 | modified @env to return os.environ.data instead of rebuilding a | |
3200 | dict by hand. |
|
3213 | dict by hand. | |
3201 |
|
3214 | |||
3202 | 2002-11-02 Fernando Perez <fperez@colorado.edu> |
|
3215 | 2002-11-02 Fernando Perez <fperez@colorado.edu> | |
3203 |
|
3216 | |||
3204 | * IPython/genutils.py (warn): changed so that level 1 prints no |
|
3217 | * IPython/genutils.py (warn): changed so that level 1 prints no | |
3205 | header. Level 2 is now the default (with 'WARNING' header, as |
|
3218 | header. Level 2 is now the default (with 'WARNING' header, as | |
3206 | before). I think I tracked all places where changes were needed in |
|
3219 | before). I think I tracked all places where changes were needed in | |
3207 | IPython, but outside code using the old level numbering may have |
|
3220 | IPython, but outside code using the old level numbering may have | |
3208 | broken. |
|
3221 | broken. | |
3209 |
|
3222 | |||
3210 | * IPython/iplib.py (InteractiveShell.runcode): added this to |
|
3223 | * IPython/iplib.py (InteractiveShell.runcode): added this to | |
3211 | handle the tracebacks in SystemExit traps correctly. The previous |
|
3224 | handle the tracebacks in SystemExit traps correctly. The previous | |
3212 | code (through interact) was printing more of the stack than |
|
3225 | code (through interact) was printing more of the stack than | |
3213 | necessary, showing IPython internal code to the user. |
|
3226 | necessary, showing IPython internal code to the user. | |
3214 |
|
3227 | |||
3215 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by |
|
3228 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by | |
3216 | default. Now that the default at the confirmation prompt is yes, |
|
3229 | default. Now that the default at the confirmation prompt is yes, | |
3217 | it's not so intrusive. François' argument that ipython sessions |
|
3230 | it's not so intrusive. François' argument that ipython sessions | |
3218 | tend to be complex enough not to lose them from an accidental C-d, |
|
3231 | tend to be complex enough not to lose them from an accidental C-d, | |
3219 | is a valid one. |
|
3232 | is a valid one. | |
3220 |
|
3233 | |||
3221 | * IPython/iplib.py (InteractiveShell.interact): added a |
|
3234 | * IPython/iplib.py (InteractiveShell.interact): added a | |
3222 | showtraceback() call to the SystemExit trap, and modified the exit |
|
3235 | showtraceback() call to the SystemExit trap, and modified the exit | |
3223 | confirmation to have yes as the default. |
|
3236 | confirmation to have yes as the default. | |
3224 |
|
3237 | |||
3225 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from |
|
3238 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from | |
3226 | this file. It's been gone from the code for a long time, this was |
|
3239 | this file. It's been gone from the code for a long time, this was | |
3227 | simply leftover junk. |
|
3240 | simply leftover junk. | |
3228 |
|
3241 | |||
3229 | 2002-11-01 Fernando Perez <fperez@colorado.edu> |
|
3242 | 2002-11-01 Fernando Perez <fperez@colorado.edu> | |
3230 |
|
3243 | |||
3231 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option |
|
3244 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option | |
3232 | added. If set, IPython now traps EOF and asks for |
|
3245 | added. If set, IPython now traps EOF and asks for | |
3233 | confirmation. After a request by François Pinard. |
|
3246 | confirmation. After a request by François Pinard. | |
3234 |
|
3247 | |||
3235 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead |
|
3248 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead | |
3236 | of @abort, and with a new (better) mechanism for handling the |
|
3249 | of @abort, and with a new (better) mechanism for handling the | |
3237 | exceptions. |
|
3250 | exceptions. | |
3238 |
|
3251 | |||
3239 | 2002-10-27 Fernando Perez <fperez@colorado.edu> |
|
3252 | 2002-10-27 Fernando Perez <fperez@colorado.edu> | |
3240 |
|
3253 | |||
3241 | * IPython/usage.py (__doc__): updated the --help information and |
|
3254 | * IPython/usage.py (__doc__): updated the --help information and | |
3242 | the ipythonrc file to indicate that -log generates |
|
3255 | the ipythonrc file to indicate that -log generates | |
3243 | ./ipython.log. Also fixed the corresponding info in @logstart. |
|
3256 | ./ipython.log. Also fixed the corresponding info in @logstart. | |
3244 | This and several other fixes in the manuals thanks to reports by |
|
3257 | This and several other fixes in the manuals thanks to reports by | |
3245 | François Pinard <pinard-AT-iro.umontreal.ca>. |
|
3258 | François Pinard <pinard-AT-iro.umontreal.ca>. | |
3246 |
|
3259 | |||
3247 | * IPython/Logger.py (Logger.switch_log): Fixed error message to |
|
3260 | * IPython/Logger.py (Logger.switch_log): Fixed error message to | |
3248 | refer to @logstart (instead of @log, which doesn't exist). |
|
3261 | refer to @logstart (instead of @log, which doesn't exist). | |
3249 |
|
3262 | |||
3250 | * IPython/iplib.py (InteractiveShell._prefilter): fixed |
|
3263 | * IPython/iplib.py (InteractiveShell._prefilter): fixed | |
3251 | AttributeError crash. Thanks to Christopher Armstrong |
|
3264 | AttributeError crash. Thanks to Christopher Armstrong | |
3252 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been |
|
3265 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been | |
3253 | introduced recently (in 0.2.14pre37) with the fix to the eval |
|
3266 | introduced recently (in 0.2.14pre37) with the fix to the eval | |
3254 | problem mentioned below. |
|
3267 | problem mentioned below. | |
3255 |
|
3268 | |||
3256 | 2002-10-17 Fernando Perez <fperez@colorado.edu> |
|
3269 | 2002-10-17 Fernando Perez <fperez@colorado.edu> | |
3257 |
|
3270 | |||
3258 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows |
|
3271 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows | |
3259 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. |
|
3272 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. | |
3260 |
|
3273 | |||
3261 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to |
|
3274 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to | |
3262 | this function to fix a problem reported by Alex Schmolck. He saw |
|
3275 | this function to fix a problem reported by Alex Schmolck. He saw | |
3263 | it with list comprehensions and generators, which were getting |
|
3276 | it with list comprehensions and generators, which were getting | |
3264 | called twice. The real problem was an 'eval' call in testing for |
|
3277 | called twice. The real problem was an 'eval' call in testing for | |
3265 | automagic which was evaluating the input line silently. |
|
3278 | automagic which was evaluating the input line silently. | |
3266 |
|
3279 | |||
3267 | This is a potentially very nasty bug, if the input has side |
|
3280 | This is a potentially very nasty bug, if the input has side | |
3268 | effects which must not be repeated. The code is much cleaner now, |
|
3281 | effects which must not be repeated. The code is much cleaner now, | |
3269 | without any blanket 'except' left and with a regexp test for |
|
3282 | without any blanket 'except' left and with a regexp test for | |
3270 | actual function names. |
|
3283 | actual function names. | |
3271 |
|
3284 | |||
3272 | But an eval remains, which I'm not fully comfortable with. I just |
|
3285 | But an eval remains, which I'm not fully comfortable with. I just | |
3273 | don't know how to find out if an expression could be a callable in |
|
3286 | don't know how to find out if an expression could be a callable in | |
3274 | the user's namespace without doing an eval on the string. However |
|
3287 | the user's namespace without doing an eval on the string. However | |
3275 | that string is now much more strictly checked so that no code |
|
3288 | that string is now much more strictly checked so that no code | |
3276 | slips by, so the eval should only happen for things that can |
|
3289 | slips by, so the eval should only happen for things that can | |
3277 | really be only function/method names. |
|
3290 | really be only function/method names. | |
3278 |
|
3291 | |||
3279 | 2002-10-15 Fernando Perez <fperez@colorado.edu> |
|
3292 | 2002-10-15 Fernando Perez <fperez@colorado.edu> | |
3280 |
|
3293 | |||
3281 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac |
|
3294 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac | |
3282 | OSX information to main manual, removed README_Mac_OSX file from |
|
3295 | OSX information to main manual, removed README_Mac_OSX file from | |
3283 | distribution. Also updated credits for recent additions. |
|
3296 | distribution. Also updated credits for recent additions. | |
3284 |
|
3297 | |||
3285 | 2002-10-10 Fernando Perez <fperez@colorado.edu> |
|
3298 | 2002-10-10 Fernando Perez <fperez@colorado.edu> | |
3286 |
|
3299 | |||
3287 | * README_Mac_OSX: Added a README for Mac OSX users for fixing |
|
3300 | * README_Mac_OSX: Added a README for Mac OSX users for fixing | |
3288 | terminal-related issues. Many thanks to Andrea Riciputi |
|
3301 | terminal-related issues. Many thanks to Andrea Riciputi | |
3289 | <andrea.riciputi-AT-libero.it> for writing it. |
|
3302 | <andrea.riciputi-AT-libero.it> for writing it. | |
3290 |
|
3303 | |||
3291 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, |
|
3304 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, | |
3292 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
3305 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
3293 |
|
3306 | |||
3294 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks |
|
3307 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks | |
3295 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad |
|
3308 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad | |
3296 | <syver-en-AT-online.no> who both submitted patches for this problem. |
|
3309 | <syver-en-AT-online.no> who both submitted patches for this problem. | |
3297 |
|
3310 | |||
3298 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for |
|
3311 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for | |
3299 | global embedding to make sure that things don't overwrite user |
|
3312 | global embedding to make sure that things don't overwrite user | |
3300 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> |
|
3313 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> | |
3301 |
|
3314 | |||
3302 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 |
|
3315 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 | |
3303 | compatibility. Thanks to Hayden Callow |
|
3316 | compatibility. Thanks to Hayden Callow | |
3304 | <h.callow-AT-elec.canterbury.ac.nz> |
|
3317 | <h.callow-AT-elec.canterbury.ac.nz> | |
3305 |
|
3318 | |||
3306 | 2002-10-04 Fernando Perez <fperez@colorado.edu> |
|
3319 | 2002-10-04 Fernando Perez <fperez@colorado.edu> | |
3307 |
|
3320 | |||
3308 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for |
|
3321 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for | |
3309 | Gnuplot.File objects. |
|
3322 | Gnuplot.File objects. | |
3310 |
|
3323 | |||
3311 | 2002-07-23 Fernando Perez <fperez@colorado.edu> |
|
3324 | 2002-07-23 Fernando Perez <fperez@colorado.edu> | |
3312 |
|
3325 | |||
3313 | * IPython/genutils.py (timing): Added timings() and timing() for |
|
3326 | * IPython/genutils.py (timing): Added timings() and timing() for | |
3314 | quick access to the most commonly needed data, the execution |
|
3327 | quick access to the most commonly needed data, the execution | |
3315 | times. Old timing() renamed to timings_out(). |
|
3328 | times. Old timing() renamed to timings_out(). | |
3316 |
|
3329 | |||
3317 | 2002-07-18 Fernando Perez <fperez@colorado.edu> |
|
3330 | 2002-07-18 Fernando Perez <fperez@colorado.edu> | |
3318 |
|
3331 | |||
3319 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed |
|
3332 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed | |
3320 | bug with nested instances disrupting the parent's tab completion. |
|
3333 | bug with nested instances disrupting the parent's tab completion. | |
3321 |
|
3334 | |||
3322 | * IPython/iplib.py (all_completions): Added Alex Schmolck's |
|
3335 | * IPython/iplib.py (all_completions): Added Alex Schmolck's | |
3323 | all_completions code to begin the emacs integration. |
|
3336 | all_completions code to begin the emacs integration. | |
3324 |
|
3337 | |||
3325 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' |
|
3338 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' | |
3326 | argument to allow titling individual arrays when plotting. |
|
3339 | argument to allow titling individual arrays when plotting. | |
3327 |
|
3340 | |||
3328 | 2002-07-15 Fernando Perez <fperez@colorado.edu> |
|
3341 | 2002-07-15 Fernando Perez <fperez@colorado.edu> | |
3329 |
|
3342 | |||
3330 | * setup.py (make_shortcut): changed to retrieve the value of |
|
3343 | * setup.py (make_shortcut): changed to retrieve the value of | |
3331 | 'Program Files' directory from the registry (this value changes in |
|
3344 | 'Program Files' directory from the registry (this value changes in | |
3332 | non-english versions of Windows). Thanks to Thomas Fanslau |
|
3345 | non-english versions of Windows). Thanks to Thomas Fanslau | |
3333 | <tfanslau-AT-gmx.de> for the report. |
|
3346 | <tfanslau-AT-gmx.de> for the report. | |
3334 |
|
3347 | |||
3335 | 2002-07-10 Fernando Perez <fperez@colorado.edu> |
|
3348 | 2002-07-10 Fernando Perez <fperez@colorado.edu> | |
3336 |
|
3349 | |||
3337 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for |
|
3350 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for | |
3338 | a bug in pdb, which crashes if a line with only whitespace is |
|
3351 | a bug in pdb, which crashes if a line with only whitespace is | |
3339 | entered. Bug report submitted to sourceforge. |
|
3352 | entered. Bug report submitted to sourceforge. | |
3340 |
|
3353 | |||
3341 | 2002-07-09 Fernando Perez <fperez@colorado.edu> |
|
3354 | 2002-07-09 Fernando Perez <fperez@colorado.edu> | |
3342 |
|
3355 | |||
3343 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when |
|
3356 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when | |
3344 | reporting exceptions (it's a bug in inspect.py, I just set a |
|
3357 | reporting exceptions (it's a bug in inspect.py, I just set a | |
3345 | workaround). |
|
3358 | workaround). | |
3346 |
|
3359 | |||
3347 | 2002-07-08 Fernando Perez <fperez@colorado.edu> |
|
3360 | 2002-07-08 Fernando Perez <fperez@colorado.edu> | |
3348 |
|
3361 | |||
3349 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to |
|
3362 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to | |
3350 | __IPYTHON__ in __builtins__ to show up in user_ns. |
|
3363 | __IPYTHON__ in __builtins__ to show up in user_ns. | |
3351 |
|
3364 | |||
3352 | 2002-07-03 Fernando Perez <fperez@colorado.edu> |
|
3365 | 2002-07-03 Fernando Perez <fperez@colorado.edu> | |
3353 |
|
3366 | |||
3354 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed |
|
3367 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed | |
3355 | name from @gp_set_instance to @gp_set_default. |
|
3368 | name from @gp_set_instance to @gp_set_default. | |
3356 |
|
3369 | |||
3357 | * IPython/ipmaker.py (make_IPython): default editor value set to |
|
3370 | * IPython/ipmaker.py (make_IPython): default editor value set to | |
3358 | '0' (a string), to match the rc file. Otherwise will crash when |
|
3371 | '0' (a string), to match the rc file. Otherwise will crash when | |
3359 | .strip() is called on it. |
|
3372 | .strip() is called on it. | |
3360 |
|
3373 | |||
3361 |
|
3374 | |||
3362 | 2002-06-28 Fernando Perez <fperez@colorado.edu> |
|
3375 | 2002-06-28 Fernando Perez <fperez@colorado.edu> | |
3363 |
|
3376 | |||
3364 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing |
|
3377 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing | |
3365 | of files in current directory when a file is executed via |
|
3378 | of files in current directory when a file is executed via | |
3366 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. |
|
3379 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. | |
3367 |
|
3380 | |||
3368 | * setup.py (manfiles): fix for rpm builds, submitted by RA |
|
3381 | * setup.py (manfiles): fix for rpm builds, submitted by RA | |
3369 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! |
|
3382 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! | |
3370 |
|
3383 | |||
3371 | * IPython/ipmaker.py (make_IPython): fixed lookup of default |
|
3384 | * IPython/ipmaker.py (make_IPython): fixed lookup of default | |
3372 | editor when set to '0'. Problem was, '0' evaluates to True (it's a |
|
3385 | editor when set to '0'. Problem was, '0' evaluates to True (it's a | |
3373 | string!). A. Schmolck caught this one. |
|
3386 | string!). A. Schmolck caught this one. | |
3374 |
|
3387 | |||
3375 | 2002-06-27 Fernando Perez <fperez@colorado.edu> |
|
3388 | 2002-06-27 Fernando Perez <fperez@colorado.edu> | |
3376 |
|
3389 | |||
3377 | * IPython/ipmaker.py (make_IPython): fixed bug when running user |
|
3390 | * IPython/ipmaker.py (make_IPython): fixed bug when running user | |
3378 | defined files at the cmd line. __name__ wasn't being set to |
|
3391 | defined files at the cmd line. __name__ wasn't being set to | |
3379 | __main__. |
|
3392 | __main__. | |
3380 |
|
3393 | |||
3381 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also |
|
3394 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also | |
3382 | regular lists and tuples besides Numeric arrays. |
|
3395 | regular lists and tuples besides Numeric arrays. | |
3383 |
|
3396 | |||
3384 | * IPython/Prompts.py (CachedOutput.__call__): Added output |
|
3397 | * IPython/Prompts.py (CachedOutput.__call__): Added output | |
3385 | supression for input ending with ';'. Similar to Mathematica and |
|
3398 | supression for input ending with ';'. Similar to Mathematica and | |
3386 | Matlab. The _* vars and Out[] list are still updated, just like |
|
3399 | Matlab. The _* vars and Out[] list are still updated, just like | |
3387 | Mathematica behaves. |
|
3400 | Mathematica behaves. | |
3388 |
|
3401 | |||
3389 | 2002-06-25 Fernando Perez <fperez@colorado.edu> |
|
3402 | 2002-06-25 Fernando Perez <fperez@colorado.edu> | |
3390 |
|
3403 | |||
3391 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of |
|
3404 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of | |
3392 | .ini extensions for profiels under Windows. |
|
3405 | .ini extensions for profiels under Windows. | |
3393 |
|
3406 | |||
3394 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of |
|
3407 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of | |
3395 | string form. Fix contributed by Alexander Schmolck |
|
3408 | string form. Fix contributed by Alexander Schmolck | |
3396 | <a.schmolck-AT-gmx.net> |
|
3409 | <a.schmolck-AT-gmx.net> | |
3397 |
|
3410 | |||
3398 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a |
|
3411 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a | |
3399 | pre-configured Gnuplot instance. |
|
3412 | pre-configured Gnuplot instance. | |
3400 |
|
3413 | |||
3401 | 2002-06-21 Fernando Perez <fperez@colorado.edu> |
|
3414 | 2002-06-21 Fernando Perez <fperez@colorado.edu> | |
3402 |
|
3415 | |||
3403 | * IPython/numutils.py (exp_safe): new function, works around the |
|
3416 | * IPython/numutils.py (exp_safe): new function, works around the | |
3404 | underflow problems in Numeric. |
|
3417 | underflow problems in Numeric. | |
3405 | (log2): New fn. Safe log in base 2: returns exact integer answer |
|
3418 | (log2): New fn. Safe log in base 2: returns exact integer answer | |
3406 | for exact integer powers of 2. |
|
3419 | for exact integer powers of 2. | |
3407 |
|
3420 | |||
3408 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' |
|
3421 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' | |
3409 | properly. |
|
3422 | properly. | |
3410 |
|
3423 | |||
3411 | 2002-06-20 Fernando Perez <fperez@colorado.edu> |
|
3424 | 2002-06-20 Fernando Perez <fperez@colorado.edu> | |
3412 |
|
3425 | |||
3413 | * IPython/genutils.py (timing): new function like |
|
3426 | * IPython/genutils.py (timing): new function like | |
3414 | Mathematica's. Similar to time_test, but returns more info. |
|
3427 | Mathematica's. Similar to time_test, but returns more info. | |
3415 |
|
3428 | |||
3416 | 2002-06-18 Fernando Perez <fperez@colorado.edu> |
|
3429 | 2002-06-18 Fernando Perez <fperez@colorado.edu> | |
3417 |
|
3430 | |||
3418 | * IPython/Magic.py (Magic.magic_save): modified @save and @r |
|
3431 | * IPython/Magic.py (Magic.magic_save): modified @save and @r | |
3419 | according to Mike Heeter's suggestions. |
|
3432 | according to Mike Heeter's suggestions. | |
3420 |
|
3433 | |||
3421 | 2002-06-16 Fernando Perez <fperez@colorado.edu> |
|
3434 | 2002-06-16 Fernando Perez <fperez@colorado.edu> | |
3422 |
|
3435 | |||
3423 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot |
|
3436 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot | |
3424 | system. GnuplotMagic is gone as a user-directory option. New files |
|
3437 | system. GnuplotMagic is gone as a user-directory option. New files | |
3425 | make it easier to use all the gnuplot stuff both from external |
|
3438 | make it easier to use all the gnuplot stuff both from external | |
3426 | programs as well as from IPython. Had to rewrite part of |
|
3439 | programs as well as from IPython. Had to rewrite part of | |
3427 | hardcopy() b/c of a strange bug: often the ps files simply don't |
|
3440 | hardcopy() b/c of a strange bug: often the ps files simply don't | |
3428 | get created, and require a repeat of the command (often several |
|
3441 | get created, and require a repeat of the command (often several | |
3429 | times). |
|
3442 | times). | |
3430 |
|
3443 | |||
3431 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to |
|
3444 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to | |
3432 | resolve output channel at call time, so that if sys.stderr has |
|
3445 | resolve output channel at call time, so that if sys.stderr has | |
3433 | been redirected by user this gets honored. |
|
3446 | been redirected by user this gets honored. | |
3434 |
|
3447 | |||
3435 | 2002-06-13 Fernando Perez <fperez@colorado.edu> |
|
3448 | 2002-06-13 Fernando Perez <fperez@colorado.edu> | |
3436 |
|
3449 | |||
3437 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to |
|
3450 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to | |
3438 | IPShell. Kept a copy with the old names to avoid breaking people's |
|
3451 | IPShell. Kept a copy with the old names to avoid breaking people's | |
3439 | embedded code. |
|
3452 | embedded code. | |
3440 |
|
3453 | |||
3441 | * IPython/ipython: simplified it to the bare minimum after |
|
3454 | * IPython/ipython: simplified it to the bare minimum after | |
3442 | Holger's suggestions. Added info about how to use it in |
|
3455 | Holger's suggestions. Added info about how to use it in | |
3443 | PYTHONSTARTUP. |
|
3456 | PYTHONSTARTUP. | |
3444 |
|
3457 | |||
3445 | * IPython/Shell.py (IPythonShell): changed the options passing |
|
3458 | * IPython/Shell.py (IPythonShell): changed the options passing | |
3446 | from a string with funky %s replacements to a straight list. Maybe |
|
3459 | from a string with funky %s replacements to a straight list. Maybe | |
3447 | a bit more typing, but it follows sys.argv conventions, so there's |
|
3460 | a bit more typing, but it follows sys.argv conventions, so there's | |
3448 | less special-casing to remember. |
|
3461 | less special-casing to remember. | |
3449 |
|
3462 | |||
3450 | 2002-06-12 Fernando Perez <fperez@colorado.edu> |
|
3463 | 2002-06-12 Fernando Perez <fperez@colorado.edu> | |
3451 |
|
3464 | |||
3452 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat |
|
3465 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat | |
3453 | command. Thanks to a suggestion by Mike Heeter. |
|
3466 | command. Thanks to a suggestion by Mike Heeter. | |
3454 | (Magic.magic_pfile): added behavior to look at filenames if given |
|
3467 | (Magic.magic_pfile): added behavior to look at filenames if given | |
3455 | arg is not a defined object. |
|
3468 | arg is not a defined object. | |
3456 | (Magic.magic_save): New @save function to save code snippets. Also |
|
3469 | (Magic.magic_save): New @save function to save code snippets. Also | |
3457 | a Mike Heeter idea. |
|
3470 | a Mike Heeter idea. | |
3458 |
|
3471 | |||
3459 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to |
|
3472 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to | |
3460 | plot() and replot(). Much more convenient now, especially for |
|
3473 | plot() and replot(). Much more convenient now, especially for | |
3461 | interactive use. |
|
3474 | interactive use. | |
3462 |
|
3475 | |||
3463 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to |
|
3476 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to | |
3464 | filenames. |
|
3477 | filenames. | |
3465 |
|
3478 | |||
3466 | 2002-06-02 Fernando Perez <fperez@colorado.edu> |
|
3479 | 2002-06-02 Fernando Perez <fperez@colorado.edu> | |
3467 |
|
3480 | |||
3468 | * IPython/Struct.py (Struct.__init__): modified to admit |
|
3481 | * IPython/Struct.py (Struct.__init__): modified to admit | |
3469 | initialization via another struct. |
|
3482 | initialization via another struct. | |
3470 |
|
3483 | |||
3471 | * IPython/genutils.py (SystemExec.__init__): New stateful |
|
3484 | * IPython/genutils.py (SystemExec.__init__): New stateful | |
3472 | interface to xsys and bq. Useful for writing system scripts. |
|
3485 | interface to xsys and bq. Useful for writing system scripts. | |
3473 |
|
3486 | |||
3474 | 2002-05-30 Fernando Perez <fperez@colorado.edu> |
|
3487 | 2002-05-30 Fernando Perez <fperez@colorado.edu> | |
3475 |
|
3488 | |||
3476 | * MANIFEST.in: Changed docfile selection to exclude all the lyx |
|
3489 | * MANIFEST.in: Changed docfile selection to exclude all the lyx | |
3477 | documents. This will make the user download smaller (it's getting |
|
3490 | documents. This will make the user download smaller (it's getting | |
3478 | too big). |
|
3491 | too big). | |
3479 |
|
3492 | |||
3480 | 2002-05-29 Fernando Perez <fperez@colorado.edu> |
|
3493 | 2002-05-29 Fernando Perez <fperez@colorado.edu> | |
3481 |
|
3494 | |||
3482 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to |
|
3495 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to | |
3483 | fix problems with shelve and pickle. Seems to work, but I don't |
|
3496 | fix problems with shelve and pickle. Seems to work, but I don't | |
3484 | know if corner cases break it. Thanks to Mike Heeter |
|
3497 | know if corner cases break it. Thanks to Mike Heeter | |
3485 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. |
|
3498 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. | |
3486 |
|
3499 | |||
3487 | 2002-05-24 Fernando Perez <fperez@colorado.edu> |
|
3500 | 2002-05-24 Fernando Perez <fperez@colorado.edu> | |
3488 |
|
3501 | |||
3489 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in |
|
3502 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in | |
3490 | macros having broken. |
|
3503 | macros having broken. | |
3491 |
|
3504 | |||
3492 | 2002-05-21 Fernando Perez <fperez@colorado.edu> |
|
3505 | 2002-05-21 Fernando Perez <fperez@colorado.edu> | |
3493 |
|
3506 | |||
3494 | * IPython/Magic.py (Magic.magic_logstart): fixed recently |
|
3507 | * IPython/Magic.py (Magic.magic_logstart): fixed recently | |
3495 | introduced logging bug: all history before logging started was |
|
3508 | introduced logging bug: all history before logging started was | |
3496 | being written one character per line! This came from the redesign |
|
3509 | being written one character per line! This came from the redesign | |
3497 | of the input history as a special list which slices to strings, |
|
3510 | of the input history as a special list which slices to strings, | |
3498 | not to lists. |
|
3511 | not to lists. | |
3499 |
|
3512 | |||
3500 | 2002-05-20 Fernando Perez <fperez@colorado.edu> |
|
3513 | 2002-05-20 Fernando Perez <fperez@colorado.edu> | |
3501 |
|
3514 | |||
3502 | * IPython/Prompts.py (CachedOutput.__init__): made the color table |
|
3515 | * IPython/Prompts.py (CachedOutput.__init__): made the color table | |
3503 | be an attribute of all classes in this module. The design of these |
|
3516 | be an attribute of all classes in this module. The design of these | |
3504 | classes needs some serious overhauling. |
|
3517 | classes needs some serious overhauling. | |
3505 |
|
3518 | |||
3506 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug |
|
3519 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug | |
3507 | which was ignoring '_' in option names. |
|
3520 | which was ignoring '_' in option names. | |
3508 |
|
3521 | |||
3509 | * IPython/ultraTB.py (FormattedTB.__init__): Changed |
|
3522 | * IPython/ultraTB.py (FormattedTB.__init__): Changed | |
3510 | 'Verbose_novars' to 'Context' and made it the new default. It's a |
|
3523 | 'Verbose_novars' to 'Context' and made it the new default. It's a | |
3511 | bit more readable and also safer than verbose. |
|
3524 | bit more readable and also safer than verbose. | |
3512 |
|
3525 | |||
3513 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of |
|
3526 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of | |
3514 | triple-quoted strings. |
|
3527 | triple-quoted strings. | |
3515 |
|
3528 | |||
3516 | * IPython/OInspect.py (__all__): new module exposing the object |
|
3529 | * IPython/OInspect.py (__all__): new module exposing the object | |
3517 | introspection facilities. Now the corresponding magics are dummy |
|
3530 | introspection facilities. Now the corresponding magics are dummy | |
3518 | wrappers around this. Having this module will make it much easier |
|
3531 | wrappers around this. Having this module will make it much easier | |
3519 | to put these functions into our modified pdb. |
|
3532 | to put these functions into our modified pdb. | |
3520 | This new object inspector system uses the new colorizing module, |
|
3533 | This new object inspector system uses the new colorizing module, | |
3521 | so source code and other things are nicely syntax highlighted. |
|
3534 | so source code and other things are nicely syntax highlighted. | |
3522 |
|
3535 | |||
3523 | 2002-05-18 Fernando Perez <fperez@colorado.edu> |
|
3536 | 2002-05-18 Fernando Perez <fperez@colorado.edu> | |
3524 |
|
3537 | |||
3525 | * IPython/ColorANSI.py: Split the coloring tools into a separate |
|
3538 | * IPython/ColorANSI.py: Split the coloring tools into a separate | |
3526 | module so I can use them in other code easier (they were part of |
|
3539 | module so I can use them in other code easier (they were part of | |
3527 | ultraTB). |
|
3540 | ultraTB). | |
3528 |
|
3541 | |||
3529 | 2002-05-17 Fernando Perez <fperez@colorado.edu> |
|
3542 | 2002-05-17 Fernando Perez <fperez@colorado.edu> | |
3530 |
|
3543 | |||
3531 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3544 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
3532 | fixed it to set the global 'g' also to the called instance, as |
|
3545 | fixed it to set the global 'g' also to the called instance, as | |
3533 | long as 'g' was still a gnuplot instance (so it doesn't overwrite |
|
3546 | long as 'g' was still a gnuplot instance (so it doesn't overwrite | |
3534 | user's 'g' variables). |
|
3547 | user's 'g' variables). | |
3535 |
|
3548 | |||
3536 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out |
|
3549 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out | |
3537 | global variables (aliases to _ih,_oh) so that users which expect |
|
3550 | global variables (aliases to _ih,_oh) so that users which expect | |
3538 | In[5] or Out[7] to work aren't unpleasantly surprised. |
|
3551 | In[5] or Out[7] to work aren't unpleasantly surprised. | |
3539 | (InputList.__getslice__): new class to allow executing slices of |
|
3552 | (InputList.__getslice__): new class to allow executing slices of | |
3540 | input history directly. Very simple class, complements the use of |
|
3553 | input history directly. Very simple class, complements the use of | |
3541 | macros. |
|
3554 | macros. | |
3542 |
|
3555 | |||
3543 | 2002-05-16 Fernando Perez <fperez@colorado.edu> |
|
3556 | 2002-05-16 Fernando Perez <fperez@colorado.edu> | |
3544 |
|
3557 | |||
3545 | * setup.py (docdirbase): make doc directory be just doc/IPython |
|
3558 | * setup.py (docdirbase): make doc directory be just doc/IPython | |
3546 | without version numbers, it will reduce clutter for users. |
|
3559 | without version numbers, it will reduce clutter for users. | |
3547 |
|
3560 | |||
3548 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to |
|
3561 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to | |
3549 | execfile call to prevent possible memory leak. See for details: |
|
3562 | execfile call to prevent possible memory leak. See for details: | |
3550 | http://mail.python.org/pipermail/python-list/2002-February/088476.html |
|
3563 | http://mail.python.org/pipermail/python-list/2002-February/088476.html | |
3551 |
|
3564 | |||
3552 | 2002-05-15 Fernando Perez <fperez@colorado.edu> |
|
3565 | 2002-05-15 Fernando Perez <fperez@colorado.edu> | |
3553 |
|
3566 | |||
3554 | * IPython/Magic.py (Magic.magic_psource): made the object |
|
3567 | * IPython/Magic.py (Magic.magic_psource): made the object | |
3555 | introspection names be more standard: pdoc, pdef, pfile and |
|
3568 | introspection names be more standard: pdoc, pdef, pfile and | |
3556 | psource. They all print/page their output, and it makes |
|
3569 | psource. They all print/page their output, and it makes | |
3557 | remembering them easier. Kept old names for compatibility as |
|
3570 | remembering them easier. Kept old names for compatibility as | |
3558 | aliases. |
|
3571 | aliases. | |
3559 |
|
3572 | |||
3560 | 2002-05-14 Fernando Perez <fperez@colorado.edu> |
|
3573 | 2002-05-14 Fernando Perez <fperez@colorado.edu> | |
3561 |
|
3574 | |||
3562 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood |
|
3575 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood | |
3563 | what the mouse problem was. The trick is to use gnuplot with temp |
|
3576 | what the mouse problem was. The trick is to use gnuplot with temp | |
3564 | files and NOT with pipes (for data communication), because having |
|
3577 | files and NOT with pipes (for data communication), because having | |
3565 | both pipes and the mouse on is bad news. |
|
3578 | both pipes and the mouse on is bad news. | |
3566 |
|
3579 | |||
3567 | 2002-05-13 Fernando Perez <fperez@colorado.edu> |
|
3580 | 2002-05-13 Fernando Perez <fperez@colorado.edu> | |
3568 |
|
3581 | |||
3569 | * IPython/Magic.py (Magic._ofind): fixed namespace order search |
|
3582 | * IPython/Magic.py (Magic._ofind): fixed namespace order search | |
3570 | bug. Information would be reported about builtins even when |
|
3583 | bug. Information would be reported about builtins even when | |
3571 | user-defined functions overrode them. |
|
3584 | user-defined functions overrode them. | |
3572 |
|
3585 | |||
3573 | 2002-05-11 Fernando Perez <fperez@colorado.edu> |
|
3586 | 2002-05-11 Fernando Perez <fperez@colorado.edu> | |
3574 |
|
3587 | |||
3575 | * IPython/__init__.py (__all__): removed FlexCompleter from |
|
3588 | * IPython/__init__.py (__all__): removed FlexCompleter from | |
3576 | __all__ so that things don't fail in platforms without readline. |
|
3589 | __all__ so that things don't fail in platforms without readline. | |
3577 |
|
3590 | |||
3578 | 2002-05-10 Fernando Perez <fperez@colorado.edu> |
|
3591 | 2002-05-10 Fernando Perez <fperez@colorado.edu> | |
3579 |
|
3592 | |||
3580 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c |
|
3593 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c | |
3581 | it requires Numeric, effectively making Numeric a dependency for |
|
3594 | it requires Numeric, effectively making Numeric a dependency for | |
3582 | IPython. |
|
3595 | IPython. | |
3583 |
|
3596 | |||
3584 | * Released 0.2.13 |
|
3597 | * Released 0.2.13 | |
3585 |
|
3598 | |||
3586 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the |
|
3599 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the | |
3587 | profiler interface. Now all the major options from the profiler |
|
3600 | profiler interface. Now all the major options from the profiler | |
3588 | module are directly supported in IPython, both for single |
|
3601 | module are directly supported in IPython, both for single | |
3589 | expressions (@prun) and for full programs (@run -p). |
|
3602 | expressions (@prun) and for full programs (@run -p). | |
3590 |
|
3603 | |||
3591 | 2002-05-09 Fernando Perez <fperez@colorado.edu> |
|
3604 | 2002-05-09 Fernando Perez <fperez@colorado.edu> | |
3592 |
|
3605 | |||
3593 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of |
|
3606 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of | |
3594 | magic properly formatted for screen. |
|
3607 | magic properly formatted for screen. | |
3595 |
|
3608 | |||
3596 | * setup.py (make_shortcut): Changed things to put pdf version in |
|
3609 | * setup.py (make_shortcut): Changed things to put pdf version in | |
3597 | doc/ instead of doc/manual (had to change lyxport a bit). |
|
3610 | doc/ instead of doc/manual (had to change lyxport a bit). | |
3598 |
|
3611 | |||
3599 | * IPython/Magic.py (Profile.string_stats): made profile runs go |
|
3612 | * IPython/Magic.py (Profile.string_stats): made profile runs go | |
3600 | through pager (they are long and a pager allows searching, saving, |
|
3613 | through pager (they are long and a pager allows searching, saving, | |
3601 | etc.) |
|
3614 | etc.) | |
3602 |
|
3615 | |||
3603 | 2002-05-08 Fernando Perez <fperez@colorado.edu> |
|
3616 | 2002-05-08 Fernando Perez <fperez@colorado.edu> | |
3604 |
|
3617 | |||
3605 | * Released 0.2.12 |
|
3618 | * Released 0.2.12 | |
3606 |
|
3619 | |||
3607 | 2002-05-06 Fernando Perez <fperez@colorado.edu> |
|
3620 | 2002-05-06 Fernando Perez <fperez@colorado.edu> | |
3608 |
|
3621 | |||
3609 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently |
|
3622 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently | |
3610 | introduced); 'hist n1 n2' was broken. |
|
3623 | introduced); 'hist n1 n2' was broken. | |
3611 | (Magic.magic_pdb): added optional on/off arguments to @pdb |
|
3624 | (Magic.magic_pdb): added optional on/off arguments to @pdb | |
3612 | (Magic.magic_run): added option -i to @run, which executes code in |
|
3625 | (Magic.magic_run): added option -i to @run, which executes code in | |
3613 | the IPython namespace instead of a clean one. Also added @irun as |
|
3626 | the IPython namespace instead of a clean one. Also added @irun as | |
3614 | an alias to @run -i. |
|
3627 | an alias to @run -i. | |
3615 |
|
3628 | |||
3616 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
3629 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
3617 | fixed (it didn't really do anything, the namespaces were wrong). |
|
3630 | fixed (it didn't really do anything, the namespaces were wrong). | |
3618 |
|
3631 | |||
3619 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 |
|
3632 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 | |
3620 |
|
3633 | |||
3621 | * IPython/__init__.py (__all__): Fixed package namespace, now |
|
3634 | * IPython/__init__.py (__all__): Fixed package namespace, now | |
3622 | 'import IPython' does give access to IPython.<all> as |
|
3635 | 'import IPython' does give access to IPython.<all> as | |
3623 | expected. Also renamed __release__ to Release. |
|
3636 | expected. Also renamed __release__ to Release. | |
3624 |
|
3637 | |||
3625 | * IPython/Debugger.py (__license__): created new Pdb class which |
|
3638 | * IPython/Debugger.py (__license__): created new Pdb class which | |
3626 | functions like a drop-in for the normal pdb.Pdb but does NOT |
|
3639 | functions like a drop-in for the normal pdb.Pdb but does NOT | |
3627 | import readline by default. This way it doesn't muck up IPython's |
|
3640 | import readline by default. This way it doesn't muck up IPython's | |
3628 | readline handling, and now tab-completion finally works in the |
|
3641 | readline handling, and now tab-completion finally works in the | |
3629 | debugger -- sort of. It completes things globally visible, but the |
|
3642 | debugger -- sort of. It completes things globally visible, but the | |
3630 | completer doesn't track the stack as pdb walks it. That's a bit |
|
3643 | completer doesn't track the stack as pdb walks it. That's a bit | |
3631 | tricky, and I'll have to implement it later. |
|
3644 | tricky, and I'll have to implement it later. | |
3632 |
|
3645 | |||
3633 | 2002-05-05 Fernando Perez <fperez@colorado.edu> |
|
3646 | 2002-05-05 Fernando Perez <fperez@colorado.edu> | |
3634 |
|
3647 | |||
3635 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for |
|
3648 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for | |
3636 | magic docstrings when printed via ? (explicit \'s were being |
|
3649 | magic docstrings when printed via ? (explicit \'s were being | |
3637 | printed). |
|
3650 | printed). | |
3638 |
|
3651 | |||
3639 | * IPython/ipmaker.py (make_IPython): fixed namespace |
|
3652 | * IPython/ipmaker.py (make_IPython): fixed namespace | |
3640 | identification bug. Now variables loaded via logs or command-line |
|
3653 | identification bug. Now variables loaded via logs or command-line | |
3641 | files are recognized in the interactive namespace by @who. |
|
3654 | files are recognized in the interactive namespace by @who. | |
3642 |
|
3655 | |||
3643 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in |
|
3656 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in | |
3644 | log replay system stemming from the string form of Structs. |
|
3657 | log replay system stemming from the string form of Structs. | |
3645 |
|
3658 | |||
3646 | * IPython/Magic.py (Macro.__init__): improved macros to properly |
|
3659 | * IPython/Magic.py (Macro.__init__): improved macros to properly | |
3647 | handle magic commands in them. |
|
3660 | handle magic commands in them. | |
3648 | (Magic.magic_logstart): usernames are now expanded so 'logstart |
|
3661 | (Magic.magic_logstart): usernames are now expanded so 'logstart | |
3649 | ~/mylog' now works. |
|
3662 | ~/mylog' now works. | |
3650 |
|
3663 | |||
3651 | * IPython/iplib.py (complete): fixed bug where paths starting with |
|
3664 | * IPython/iplib.py (complete): fixed bug where paths starting with | |
3652 | '/' would be completed as magic names. |
|
3665 | '/' would be completed as magic names. | |
3653 |
|
3666 | |||
3654 | 2002-05-04 Fernando Perez <fperez@colorado.edu> |
|
3667 | 2002-05-04 Fernando Perez <fperez@colorado.edu> | |
3655 |
|
3668 | |||
3656 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to |
|
3669 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to | |
3657 | allow running full programs under the profiler's control. |
|
3670 | allow running full programs under the profiler's control. | |
3658 |
|
3671 | |||
3659 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars |
|
3672 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars | |
3660 | mode to report exceptions verbosely but without formatting |
|
3673 | mode to report exceptions verbosely but without formatting | |
3661 | variables. This addresses the issue of ipython 'freezing' (it's |
|
3674 | variables. This addresses the issue of ipython 'freezing' (it's | |
3662 | not frozen, but caught in an expensive formatting loop) when huge |
|
3675 | not frozen, but caught in an expensive formatting loop) when huge | |
3663 | variables are in the context of an exception. |
|
3676 | variables are in the context of an exception. | |
3664 | (VerboseTB.text): Added '--->' markers at line where exception was |
|
3677 | (VerboseTB.text): Added '--->' markers at line where exception was | |
3665 | triggered. Much clearer to read, especially in NoColor modes. |
|
3678 | triggered. Much clearer to read, especially in NoColor modes. | |
3666 |
|
3679 | |||
3667 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been |
|
3680 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been | |
3668 | implemented in reverse when changing to the new parse_options(). |
|
3681 | implemented in reverse when changing to the new parse_options(). | |
3669 |
|
3682 | |||
3670 | 2002-05-03 Fernando Perez <fperez@colorado.edu> |
|
3683 | 2002-05-03 Fernando Perez <fperez@colorado.edu> | |
3671 |
|
3684 | |||
3672 | * IPython/Magic.py (Magic.parse_options): new function so that |
|
3685 | * IPython/Magic.py (Magic.parse_options): new function so that | |
3673 | magics can parse options easier. |
|
3686 | magics can parse options easier. | |
3674 | (Magic.magic_prun): new function similar to profile.run(), |
|
3687 | (Magic.magic_prun): new function similar to profile.run(), | |
3675 | suggested by Chris Hart. |
|
3688 | suggested by Chris Hart. | |
3676 | (Magic.magic_cd): fixed behavior so that it only changes if |
|
3689 | (Magic.magic_cd): fixed behavior so that it only changes if | |
3677 | directory actually is in history. |
|
3690 | directory actually is in history. | |
3678 |
|
3691 | |||
3679 | * IPython/usage.py (__doc__): added information about potential |
|
3692 | * IPython/usage.py (__doc__): added information about potential | |
3680 | slowness of Verbose exception mode when there are huge data |
|
3693 | slowness of Verbose exception mode when there are huge data | |
3681 | structures to be formatted (thanks to Archie Paulson). |
|
3694 | structures to be formatted (thanks to Archie Paulson). | |
3682 |
|
3695 | |||
3683 | * IPython/ipmaker.py (make_IPython): Changed default logging |
|
3696 | * IPython/ipmaker.py (make_IPython): Changed default logging | |
3684 | (when simply called with -log) to use curr_dir/ipython.log in |
|
3697 | (when simply called with -log) to use curr_dir/ipython.log in | |
3685 | rotate mode. Fixed crash which was occuring with -log before |
|
3698 | rotate mode. Fixed crash which was occuring with -log before | |
3686 | (thanks to Jim Boyle). |
|
3699 | (thanks to Jim Boyle). | |
3687 |
|
3700 | |||
3688 | 2002-05-01 Fernando Perez <fperez@colorado.edu> |
|
3701 | 2002-05-01 Fernando Perez <fperez@colorado.edu> | |
3689 |
|
3702 | |||
3690 | * Released 0.2.11 for these fixes (mainly the ultraTB one which |
|
3703 | * Released 0.2.11 for these fixes (mainly the ultraTB one which | |
3691 | was nasty -- though somewhat of a corner case). |
|
3704 | was nasty -- though somewhat of a corner case). | |
3692 |
|
3705 | |||
3693 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to |
|
3706 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to | |
3694 | text (was a bug). |
|
3707 | text (was a bug). | |
3695 |
|
3708 | |||
3696 | 2002-04-30 Fernando Perez <fperez@colorado.edu> |
|
3709 | 2002-04-30 Fernando Perez <fperez@colorado.edu> | |
3697 |
|
3710 | |||
3698 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add |
|
3711 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add | |
3699 | a print after ^D or ^C from the user so that the In[] prompt |
|
3712 | a print after ^D or ^C from the user so that the In[] prompt | |
3700 | doesn't over-run the gnuplot one. |
|
3713 | doesn't over-run the gnuplot one. | |
3701 |
|
3714 | |||
3702 | 2002-04-29 Fernando Perez <fperez@colorado.edu> |
|
3715 | 2002-04-29 Fernando Perez <fperez@colorado.edu> | |
3703 |
|
3716 | |||
3704 | * Released 0.2.10 |
|
3717 | * Released 0.2.10 | |
3705 |
|
3718 | |||
3706 | * IPython/__release__.py (version): get date dynamically. |
|
3719 | * IPython/__release__.py (version): get date dynamically. | |
3707 |
|
3720 | |||
3708 | * Misc. documentation updates thanks to Arnd's comments. Also ran |
|
3721 | * Misc. documentation updates thanks to Arnd's comments. Also ran | |
3709 | a full spellcheck on the manual (hadn't been done in a while). |
|
3722 | a full spellcheck on the manual (hadn't been done in a while). | |
3710 |
|
3723 | |||
3711 | 2002-04-27 Fernando Perez <fperez@colorado.edu> |
|
3724 | 2002-04-27 Fernando Perez <fperez@colorado.edu> | |
3712 |
|
3725 | |||
3713 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where |
|
3726 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where | |
3714 | starting a log in mid-session would reset the input history list. |
|
3727 | starting a log in mid-session would reset the input history list. | |
3715 |
|
3728 | |||
3716 | 2002-04-26 Fernando Perez <fperez@colorado.edu> |
|
3729 | 2002-04-26 Fernando Perez <fperez@colorado.edu> | |
3717 |
|
3730 | |||
3718 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not |
|
3731 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not | |
3719 | all files were being included in an update. Now anything in |
|
3732 | all files were being included in an update. Now anything in | |
3720 | UserConfig that matches [A-Za-z]*.py will go (this excludes |
|
3733 | UserConfig that matches [A-Za-z]*.py will go (this excludes | |
3721 | __init__.py) |
|
3734 | __init__.py) | |
3722 |
|
3735 | |||
3723 | 2002-04-25 Fernando Perez <fperez@colorado.edu> |
|
3736 | 2002-04-25 Fernando Perez <fperez@colorado.edu> | |
3724 |
|
3737 | |||
3725 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ |
|
3738 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ | |
3726 | to __builtins__ so that any form of embedded or imported code can |
|
3739 | to __builtins__ so that any form of embedded or imported code can | |
3727 | test for being inside IPython. |
|
3740 | test for being inside IPython. | |
3728 |
|
3741 | |||
3729 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): |
|
3742 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): | |
3730 | changed to GnuplotMagic because it's now an importable module, |
|
3743 | changed to GnuplotMagic because it's now an importable module, | |
3731 | this makes the name follow that of the standard Gnuplot module. |
|
3744 | this makes the name follow that of the standard Gnuplot module. | |
3732 | GnuplotMagic can now be loaded at any time in mid-session. |
|
3745 | GnuplotMagic can now be loaded at any time in mid-session. | |
3733 |
|
3746 | |||
3734 | 2002-04-24 Fernando Perez <fperez@colorado.edu> |
|
3747 | 2002-04-24 Fernando Perez <fperez@colorado.edu> | |
3735 |
|
3748 | |||
3736 | * IPython/numutils.py: removed SIUnits. It doesn't properly set |
|
3749 | * IPython/numutils.py: removed SIUnits. It doesn't properly set | |
3737 | the globals (IPython has its own namespace) and the |
|
3750 | the globals (IPython has its own namespace) and the | |
3738 | PhysicalQuantity stuff is much better anyway. |
|
3751 | PhysicalQuantity stuff is much better anyway. | |
3739 |
|
3752 | |||
3740 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot |
|
3753 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot | |
3741 | embedding example to standard user directory for |
|
3754 | embedding example to standard user directory for | |
3742 | distribution. Also put it in the manual. |
|
3755 | distribution. Also put it in the manual. | |
3743 |
|
3756 | |||
3744 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot |
|
3757 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot | |
3745 | instance as first argument (so it doesn't rely on some obscure |
|
3758 | instance as first argument (so it doesn't rely on some obscure | |
3746 | hidden global). |
|
3759 | hidden global). | |
3747 |
|
3760 | |||
3748 | * IPython/UserConfig/ipythonrc.py: put () back in accepted |
|
3761 | * IPython/UserConfig/ipythonrc.py: put () back in accepted | |
3749 | delimiters. While it prevents ().TAB from working, it allows |
|
3762 | delimiters. While it prevents ().TAB from working, it allows | |
3750 | completions in open (... expressions. This is by far a more common |
|
3763 | completions in open (... expressions. This is by far a more common | |
3751 | case. |
|
3764 | case. | |
3752 |
|
3765 | |||
3753 | 2002-04-23 Fernando Perez <fperez@colorado.edu> |
|
3766 | 2002-04-23 Fernando Perez <fperez@colorado.edu> | |
3754 |
|
3767 | |||
3755 | * IPython/Extensions/InterpreterPasteInput.py: new |
|
3768 | * IPython/Extensions/InterpreterPasteInput.py: new | |
3756 | syntax-processing module for pasting lines with >>> or ... at the |
|
3769 | syntax-processing module for pasting lines with >>> or ... at the | |
3757 | start. |
|
3770 | start. | |
3758 |
|
3771 | |||
3759 | * IPython/Extensions/PhysicalQ_Interactive.py |
|
3772 | * IPython/Extensions/PhysicalQ_Interactive.py | |
3760 | (PhysicalQuantityInteractive.__int__): fixed to work with either |
|
3773 | (PhysicalQuantityInteractive.__int__): fixed to work with either | |
3761 | Numeric or math. |
|
3774 | Numeric or math. | |
3762 |
|
3775 | |||
3763 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the |
|
3776 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the | |
3764 | provided profiles. Now we have: |
|
3777 | provided profiles. Now we have: | |
3765 | -math -> math module as * and cmath with its own namespace. |
|
3778 | -math -> math module as * and cmath with its own namespace. | |
3766 | -numeric -> Numeric as *, plus gnuplot & grace |
|
3779 | -numeric -> Numeric as *, plus gnuplot & grace | |
3767 | -physics -> same as before |
|
3780 | -physics -> same as before | |
3768 |
|
3781 | |||
3769 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where |
|
3782 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where | |
3770 | user-defined magics wouldn't be found by @magic if they were |
|
3783 | user-defined magics wouldn't be found by @magic if they were | |
3771 | defined as class methods. Also cleaned up the namespace search |
|
3784 | defined as class methods. Also cleaned up the namespace search | |
3772 | logic and the string building (to use %s instead of many repeated |
|
3785 | logic and the string building (to use %s instead of many repeated | |
3773 | string adds). |
|
3786 | string adds). | |
3774 |
|
3787 | |||
3775 | * IPython/UserConfig/example-magic.py (magic_foo): updated example |
|
3788 | * IPython/UserConfig/example-magic.py (magic_foo): updated example | |
3776 | of user-defined magics to operate with class methods (cleaner, in |
|
3789 | of user-defined magics to operate with class methods (cleaner, in | |
3777 | line with the gnuplot code). |
|
3790 | line with the gnuplot code). | |
3778 |
|
3791 | |||
3779 | 2002-04-22 Fernando Perez <fperez@colorado.edu> |
|
3792 | 2002-04-22 Fernando Perez <fperez@colorado.edu> | |
3780 |
|
3793 | |||
3781 | * setup.py: updated dependency list so that manual is updated when |
|
3794 | * setup.py: updated dependency list so that manual is updated when | |
3782 | all included files change. |
|
3795 | all included files change. | |
3783 |
|
3796 | |||
3784 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring |
|
3797 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring | |
3785 | the delimiter removal option (the fix is ugly right now). |
|
3798 | the delimiter removal option (the fix is ugly right now). | |
3786 |
|
3799 | |||
3787 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load |
|
3800 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load | |
3788 | all of the math profile (quicker loading, no conflict between |
|
3801 | all of the math profile (quicker loading, no conflict between | |
3789 | g-9.8 and g-gnuplot). |
|
3802 | g-9.8 and g-gnuplot). | |
3790 |
|
3803 | |||
3791 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default |
|
3804 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default | |
3792 | name of post-mortem files to IPython_crash_report.txt. |
|
3805 | name of post-mortem files to IPython_crash_report.txt. | |
3793 |
|
3806 | |||
3794 | * Cleanup/update of the docs. Added all the new readline info and |
|
3807 | * Cleanup/update of the docs. Added all the new readline info and | |
3795 | formatted all lists as 'real lists'. |
|
3808 | formatted all lists as 'real lists'. | |
3796 |
|
3809 | |||
3797 | * IPython/ipmaker.py (make_IPython): removed now-obsolete |
|
3810 | * IPython/ipmaker.py (make_IPython): removed now-obsolete | |
3798 | tab-completion options, since the full readline parse_and_bind is |
|
3811 | tab-completion options, since the full readline parse_and_bind is | |
3799 | now accessible. |
|
3812 | now accessible. | |
3800 |
|
3813 | |||
3801 | * IPython/iplib.py (InteractiveShell.init_readline): Changed |
|
3814 | * IPython/iplib.py (InteractiveShell.init_readline): Changed | |
3802 | handling of readline options. Now users can specify any string to |
|
3815 | handling of readline options. Now users can specify any string to | |
3803 | be passed to parse_and_bind(), as well as the delimiters to be |
|
3816 | be passed to parse_and_bind(), as well as the delimiters to be | |
3804 | removed. |
|
3817 | removed. | |
3805 | (InteractiveShell.__init__): Added __name__ to the global |
|
3818 | (InteractiveShell.__init__): Added __name__ to the global | |
3806 | namespace so that things like Itpl which rely on its existence |
|
3819 | namespace so that things like Itpl which rely on its existence | |
3807 | don't crash. |
|
3820 | don't crash. | |
3808 | (InteractiveShell._prefilter): Defined the default with a _ so |
|
3821 | (InteractiveShell._prefilter): Defined the default with a _ so | |
3809 | that prefilter() is easier to override, while the default one |
|
3822 | that prefilter() is easier to override, while the default one | |
3810 | remains available. |
|
3823 | remains available. | |
3811 |
|
3824 | |||
3812 | 2002-04-18 Fernando Perez <fperez@colorado.edu> |
|
3825 | 2002-04-18 Fernando Perez <fperez@colorado.edu> | |
3813 |
|
3826 | |||
3814 | * Added information about pdb in the docs. |
|
3827 | * Added information about pdb in the docs. | |
3815 |
|
3828 | |||
3816 | 2002-04-17 Fernando Perez <fperez@colorado.edu> |
|
3829 | 2002-04-17 Fernando Perez <fperez@colorado.edu> | |
3817 |
|
3830 | |||
3818 | * IPython/ipmaker.py (make_IPython): added rc_override option to |
|
3831 | * IPython/ipmaker.py (make_IPython): added rc_override option to | |
3819 | allow passing config options at creation time which may override |
|
3832 | allow passing config options at creation time which may override | |
3820 | anything set in the config files or command line. This is |
|
3833 | anything set in the config files or command line. This is | |
3821 | particularly useful for configuring embedded instances. |
|
3834 | particularly useful for configuring embedded instances. | |
3822 |
|
3835 | |||
3823 | 2002-04-15 Fernando Perez <fperez@colorado.edu> |
|
3836 | 2002-04-15 Fernando Perez <fperez@colorado.edu> | |
3824 |
|
3837 | |||
3825 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could |
|
3838 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could | |
3826 | crash embedded instances because of the input cache falling out of |
|
3839 | crash embedded instances because of the input cache falling out of | |
3827 | sync with the output counter. |
|
3840 | sync with the output counter. | |
3828 |
|
3841 | |||
3829 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug |
|
3842 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug | |
3830 | mode which calls pdb after an uncaught exception in IPython itself. |
|
3843 | mode which calls pdb after an uncaught exception in IPython itself. | |
3831 |
|
3844 | |||
3832 | 2002-04-14 Fernando Perez <fperez@colorado.edu> |
|
3845 | 2002-04-14 Fernando Perez <fperez@colorado.edu> | |
3833 |
|
3846 | |||
3834 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up |
|
3847 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up | |
3835 | readline, fix it back after each call. |
|
3848 | readline, fix it back after each call. | |
3836 |
|
3849 | |||
3837 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private |
|
3850 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private | |
3838 | method to force all access via __call__(), which guarantees that |
|
3851 | method to force all access via __call__(), which guarantees that | |
3839 | traceback references are properly deleted. |
|
3852 | traceback references are properly deleted. | |
3840 |
|
3853 | |||
3841 | * IPython/Prompts.py (CachedOutput._display): minor fixes to |
|
3854 | * IPython/Prompts.py (CachedOutput._display): minor fixes to | |
3842 | improve printing when pprint is in use. |
|
3855 | improve printing when pprint is in use. | |
3843 |
|
3856 | |||
3844 | 2002-04-13 Fernando Perez <fperez@colorado.edu> |
|
3857 | 2002-04-13 Fernando Perez <fperez@colorado.edu> | |
3845 |
|
3858 | |||
3846 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit |
|
3859 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit | |
3847 | exceptions aren't caught anymore. If the user triggers one, he |
|
3860 | exceptions aren't caught anymore. If the user triggers one, he | |
3848 | should know why he's doing it and it should go all the way up, |
|
3861 | should know why he's doing it and it should go all the way up, | |
3849 | just like any other exception. So now @abort will fully kill the |
|
3862 | just like any other exception. So now @abort will fully kill the | |
3850 | embedded interpreter and the embedding code (unless that happens |
|
3863 | embedded interpreter and the embedding code (unless that happens | |
3851 | to catch SystemExit). |
|
3864 | to catch SystemExit). | |
3852 |
|
3865 | |||
3853 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag |
|
3866 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag | |
3854 | and a debugger() method to invoke the interactive pdb debugger |
|
3867 | and a debugger() method to invoke the interactive pdb debugger | |
3855 | after printing exception information. Also added the corresponding |
|
3868 | after printing exception information. Also added the corresponding | |
3856 | -pdb option and @pdb magic to control this feature, and updated |
|
3869 | -pdb option and @pdb magic to control this feature, and updated | |
3857 | the docs. After a suggestion from Christopher Hart |
|
3870 | the docs. After a suggestion from Christopher Hart | |
3858 | (hart-AT-caltech.edu). |
|
3871 | (hart-AT-caltech.edu). | |
3859 |
|
3872 | |||
3860 | 2002-04-12 Fernando Perez <fperez@colorado.edu> |
|
3873 | 2002-04-12 Fernando Perez <fperez@colorado.edu> | |
3861 |
|
3874 | |||
3862 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use |
|
3875 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use | |
3863 | the exception handlers defined by the user (not the CrashHandler) |
|
3876 | the exception handlers defined by the user (not the CrashHandler) | |
3864 | so that user exceptions don't trigger an ipython bug report. |
|
3877 | so that user exceptions don't trigger an ipython bug report. | |
3865 |
|
3878 | |||
3866 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme |
|
3879 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme | |
3867 | configurable (it should have always been so). |
|
3880 | configurable (it should have always been so). | |
3868 |
|
3881 | |||
3869 | 2002-03-26 Fernando Perez <fperez@colorado.edu> |
|
3882 | 2002-03-26 Fernando Perez <fperez@colorado.edu> | |
3870 |
|
3883 | |||
3871 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here |
|
3884 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here | |
3872 | and there to fix embedding namespace issues. This should all be |
|
3885 | and there to fix embedding namespace issues. This should all be | |
3873 | done in a more elegant way. |
|
3886 | done in a more elegant way. | |
3874 |
|
3887 | |||
3875 | 2002-03-25 Fernando Perez <fperez@colorado.edu> |
|
3888 | 2002-03-25 Fernando Perez <fperez@colorado.edu> | |
3876 |
|
3889 | |||
3877 | * IPython/genutils.py (get_home_dir): Try to make it work under |
|
3890 | * IPython/genutils.py (get_home_dir): Try to make it work under | |
3878 | win9x also. |
|
3891 | win9x also. | |
3879 |
|
3892 | |||
3880 | 2002-03-20 Fernando Perez <fperez@colorado.edu> |
|
3893 | 2002-03-20 Fernando Perez <fperez@colorado.edu> | |
3881 |
|
3894 | |||
3882 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave |
|
3895 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave | |
3883 | sys.displayhook untouched upon __init__. |
|
3896 | sys.displayhook untouched upon __init__. | |
3884 |
|
3897 | |||
3885 | 2002-03-19 Fernando Perez <fperez@colorado.edu> |
|
3898 | 2002-03-19 Fernando Perez <fperez@colorado.edu> | |
3886 |
|
3899 | |||
3887 | * Released 0.2.9 (for embedding bug, basically). |
|
3900 | * Released 0.2.9 (for embedding bug, basically). | |
3888 |
|
3901 | |||
3889 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit |
|
3902 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit | |
3890 | exceptions so that enclosing shell's state can be restored. |
|
3903 | exceptions so that enclosing shell's state can be restored. | |
3891 |
|
3904 | |||
3892 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize |
|
3905 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize | |
3893 | naming conventions in the .ipython/ dir. |
|
3906 | naming conventions in the .ipython/ dir. | |
3894 |
|
3907 | |||
3895 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' |
|
3908 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' | |
3896 | from delimiters list so filenames with - in them get expanded. |
|
3909 | from delimiters list so filenames with - in them get expanded. | |
3897 |
|
3910 | |||
3898 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with |
|
3911 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with | |
3899 | sys.displayhook not being properly restored after an embedded call. |
|
3912 | sys.displayhook not being properly restored after an embedded call. | |
3900 |
|
3913 | |||
3901 | 2002-03-18 Fernando Perez <fperez@colorado.edu> |
|
3914 | 2002-03-18 Fernando Perez <fperez@colorado.edu> | |
3902 |
|
3915 | |||
3903 | * Released 0.2.8 |
|
3916 | * Released 0.2.8 | |
3904 |
|
3917 | |||
3905 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where |
|
3918 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where | |
3906 | some files weren't being included in a -upgrade. |
|
3919 | some files weren't being included in a -upgrade. | |
3907 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous |
|
3920 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous | |
3908 | on' so that the first tab completes. |
|
3921 | on' so that the first tab completes. | |
3909 | (InteractiveShell.handle_magic): fixed bug with spaces around |
|
3922 | (InteractiveShell.handle_magic): fixed bug with spaces around | |
3910 | quotes breaking many magic commands. |
|
3923 | quotes breaking many magic commands. | |
3911 |
|
3924 | |||
3912 | * setup.py: added note about ignoring the syntax error messages at |
|
3925 | * setup.py: added note about ignoring the syntax error messages at | |
3913 | installation. |
|
3926 | installation. | |
3914 |
|
3927 | |||
3915 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished |
|
3928 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished | |
3916 | streamlining the gnuplot interface, now there's only one magic @gp. |
|
3929 | streamlining the gnuplot interface, now there's only one magic @gp. | |
3917 |
|
3930 | |||
3918 | 2002-03-17 Fernando Perez <fperez@colorado.edu> |
|
3931 | 2002-03-17 Fernando Perez <fperez@colorado.edu> | |
3919 |
|
3932 | |||
3920 | * IPython/UserConfig/magic_gnuplot.py: new name for the |
|
3933 | * IPython/UserConfig/magic_gnuplot.py: new name for the | |
3921 | example-magic_pm.py file. Much enhanced system, now with a shell |
|
3934 | example-magic_pm.py file. Much enhanced system, now with a shell | |
3922 | for communicating directly with gnuplot, one command at a time. |
|
3935 | for communicating directly with gnuplot, one command at a time. | |
3923 |
|
3936 | |||
3924 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent |
|
3937 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent | |
3925 | setting __name__=='__main__'. |
|
3938 | setting __name__=='__main__'. | |
3926 |
|
3939 | |||
3927 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added |
|
3940 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added | |
3928 | mini-shell for accessing gnuplot from inside ipython. Should |
|
3941 | mini-shell for accessing gnuplot from inside ipython. Should | |
3929 | extend it later for grace access too. Inspired by Arnd's |
|
3942 | extend it later for grace access too. Inspired by Arnd's | |
3930 | suggestion. |
|
3943 | suggestion. | |
3931 |
|
3944 | |||
3932 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when |
|
3945 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when | |
3933 | calling magic functions with () in their arguments. Thanks to Arnd |
|
3946 | calling magic functions with () in their arguments. Thanks to Arnd | |
3934 | Baecker for pointing this to me. |
|
3947 | Baecker for pointing this to me. | |
3935 |
|
3948 | |||
3936 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse |
|
3949 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse | |
3937 | infinitely for integer or complex arrays (only worked with floats). |
|
3950 | infinitely for integer or complex arrays (only worked with floats). | |
3938 |
|
3951 | |||
3939 | 2002-03-16 Fernando Perez <fperez@colorado.edu> |
|
3952 | 2002-03-16 Fernando Perez <fperez@colorado.edu> | |
3940 |
|
3953 | |||
3941 | * setup.py: Merged setup and setup_windows into a single script |
|
3954 | * setup.py: Merged setup and setup_windows into a single script | |
3942 | which properly handles things for windows users. |
|
3955 | which properly handles things for windows users. | |
3943 |
|
3956 | |||
3944 | 2002-03-15 Fernando Perez <fperez@colorado.edu> |
|
3957 | 2002-03-15 Fernando Perez <fperez@colorado.edu> | |
3945 |
|
3958 | |||
3946 | * Big change to the manual: now the magics are all automatically |
|
3959 | * Big change to the manual: now the magics are all automatically | |
3947 | documented. This information is generated from their docstrings |
|
3960 | documented. This information is generated from their docstrings | |
3948 | and put in a latex file included by the manual lyx file. This way |
|
3961 | and put in a latex file included by the manual lyx file. This way | |
3949 | we get always up to date information for the magics. The manual |
|
3962 | we get always up to date information for the magics. The manual | |
3950 | now also has proper version information, also auto-synced. |
|
3963 | now also has proper version information, also auto-synced. | |
3951 |
|
3964 | |||
3952 | For this to work, an undocumented --magic_docstrings option was added. |
|
3965 | For this to work, an undocumented --magic_docstrings option was added. | |
3953 |
|
3966 | |||
3954 | 2002-03-13 Fernando Perez <fperez@colorado.edu> |
|
3967 | 2002-03-13 Fernando Perez <fperez@colorado.edu> | |
3955 |
|
3968 | |||
3956 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors |
|
3969 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors | |
3957 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. |
|
3970 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. | |
3958 |
|
3971 | |||
3959 | 2002-03-12 Fernando Perez <fperez@colorado.edu> |
|
3972 | 2002-03-12 Fernando Perez <fperez@colorado.edu> | |
3960 |
|
3973 | |||
3961 | * IPython/ultraTB.py (TermColors): changed color escapes again to |
|
3974 | * IPython/ultraTB.py (TermColors): changed color escapes again to | |
3962 | fix the (old, reintroduced) line-wrapping bug. Basically, if |
|
3975 | fix the (old, reintroduced) line-wrapping bug. Basically, if | |
3963 | \001..\002 aren't given in the color escapes, lines get wrapped |
|
3976 | \001..\002 aren't given in the color escapes, lines get wrapped | |
3964 | weirdly. But giving those screws up old xterms and emacs terms. So |
|
3977 | weirdly. But giving those screws up old xterms and emacs terms. So | |
3965 | I added some logic for emacs terms to be ok, but I can't identify old |
|
3978 | I added some logic for emacs terms to be ok, but I can't identify old | |
3966 | xterms separately ($TERM=='xterm' for many terminals, like konsole). |
|
3979 | xterms separately ($TERM=='xterm' for many terminals, like konsole). | |
3967 |
|
3980 | |||
3968 | 2002-03-10 Fernando Perez <fperez@colorado.edu> |
|
3981 | 2002-03-10 Fernando Perez <fperez@colorado.edu> | |
3969 |
|
3982 | |||
3970 | * IPython/usage.py (__doc__): Various documentation cleanups and |
|
3983 | * IPython/usage.py (__doc__): Various documentation cleanups and | |
3971 | updates, both in usage docstrings and in the manual. |
|
3984 | updates, both in usage docstrings and in the manual. | |
3972 |
|
3985 | |||
3973 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for |
|
3986 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for | |
3974 | handling of caching. Set minimum acceptabe value for having a |
|
3987 | handling of caching. Set minimum acceptabe value for having a | |
3975 | cache at 20 values. |
|
3988 | cache at 20 values. | |
3976 |
|
3989 | |||
3977 | * IPython/iplib.py (InteractiveShell.user_setup): moved the |
|
3990 | * IPython/iplib.py (InteractiveShell.user_setup): moved the | |
3978 | install_first_time function to a method, renamed it and added an |
|
3991 | install_first_time function to a method, renamed it and added an | |
3979 | 'upgrade' mode. Now people can update their config directory with |
|
3992 | 'upgrade' mode. Now people can update their config directory with | |
3980 | a simple command line switch (-upgrade, also new). |
|
3993 | a simple command line switch (-upgrade, also new). | |
3981 |
|
3994 | |||
3982 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to |
|
3995 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to | |
3983 | @file (convenient for automagic users under Python >= 2.2). |
|
3996 | @file (convenient for automagic users under Python >= 2.2). | |
3984 | Removed @files (it seemed more like a plural than an abbrev. of |
|
3997 | Removed @files (it seemed more like a plural than an abbrev. of | |
3985 | 'file show'). |
|
3998 | 'file show'). | |
3986 |
|
3999 | |||
3987 | * IPython/iplib.py (install_first_time): Fixed crash if there were |
|
4000 | * IPython/iplib.py (install_first_time): Fixed crash if there were | |
3988 | backup files ('~') in .ipython/ install directory. |
|
4001 | backup files ('~') in .ipython/ install directory. | |
3989 |
|
4002 | |||
3990 | * IPython/ipmaker.py (make_IPython): fixes for new prompt |
|
4003 | * IPython/ipmaker.py (make_IPython): fixes for new prompt | |
3991 | system. Things look fine, but these changes are fairly |
|
4004 | system. Things look fine, but these changes are fairly | |
3992 | intrusive. Test them for a few days. |
|
4005 | intrusive. Test them for a few days. | |
3993 |
|
4006 | |||
3994 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of |
|
4007 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of | |
3995 | the prompts system. Now all in/out prompt strings are user |
|
4008 | the prompts system. Now all in/out prompt strings are user | |
3996 | controllable. This is particularly useful for embedding, as one |
|
4009 | controllable. This is particularly useful for embedding, as one | |
3997 | can tag embedded instances with particular prompts. |
|
4010 | can tag embedded instances with particular prompts. | |
3998 |
|
4011 | |||
3999 | Also removed global use of sys.ps1/2, which now allows nested |
|
4012 | Also removed global use of sys.ps1/2, which now allows nested | |
4000 | embeddings without any problems. Added command-line options for |
|
4013 | embeddings without any problems. Added command-line options for | |
4001 | the prompt strings. |
|
4014 | the prompt strings. | |
4002 |
|
4015 | |||
4003 | 2002-03-08 Fernando Perez <fperez@colorado.edu> |
|
4016 | 2002-03-08 Fernando Perez <fperez@colorado.edu> | |
4004 |
|
4017 | |||
4005 | * IPython/UserConfig/example-embed-short.py (ipshell): added |
|
4018 | * IPython/UserConfig/example-embed-short.py (ipshell): added | |
4006 | example file with the bare minimum code for embedding. |
|
4019 | example file with the bare minimum code for embedding. | |
4007 |
|
4020 | |||
4008 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added |
|
4021 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added | |
4009 | functionality for the embeddable shell to be activated/deactivated |
|
4022 | functionality for the embeddable shell to be activated/deactivated | |
4010 | either globally or at each call. |
|
4023 | either globally or at each call. | |
4011 |
|
4024 | |||
4012 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of |
|
4025 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of | |
4013 | rewriting the prompt with '--->' for auto-inputs with proper |
|
4026 | rewriting the prompt with '--->' for auto-inputs with proper | |
4014 | coloring. Now the previous UGLY hack in handle_auto() is gone, and |
|
4027 | coloring. Now the previous UGLY hack in handle_auto() is gone, and | |
4015 | this is handled by the prompts class itself, as it should. |
|
4028 | this is handled by the prompts class itself, as it should. | |
4016 |
|
4029 | |||
4017 | 2002-03-05 Fernando Perez <fperez@colorado.edu> |
|
4030 | 2002-03-05 Fernando Perez <fperez@colorado.edu> | |
4018 |
|
4031 | |||
4019 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to |
|
4032 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to | |
4020 | @logstart to avoid name clashes with the math log function. |
|
4033 | @logstart to avoid name clashes with the math log function. | |
4021 |
|
4034 | |||
4022 | * Big updates to X/Emacs section of the manual. |
|
4035 | * Big updates to X/Emacs section of the manual. | |
4023 |
|
4036 | |||
4024 | * Removed ipython_emacs. Milan explained to me how to pass |
|
4037 | * Removed ipython_emacs. Milan explained to me how to pass | |
4025 | arguments to ipython through Emacs. Some day I'm going to end up |
|
4038 | arguments to ipython through Emacs. Some day I'm going to end up | |
4026 | learning some lisp... |
|
4039 | learning some lisp... | |
4027 |
|
4040 | |||
4028 | 2002-03-04 Fernando Perez <fperez@colorado.edu> |
|
4041 | 2002-03-04 Fernando Perez <fperez@colorado.edu> | |
4029 |
|
4042 | |||
4030 | * IPython/ipython_emacs: Created script to be used as the |
|
4043 | * IPython/ipython_emacs: Created script to be used as the | |
4031 | py-python-command Emacs variable so we can pass IPython |
|
4044 | py-python-command Emacs variable so we can pass IPython | |
4032 | parameters. I can't figure out how to tell Emacs directly to pass |
|
4045 | parameters. I can't figure out how to tell Emacs directly to pass | |
4033 | parameters to IPython, so a dummy shell script will do it. |
|
4046 | parameters to IPython, so a dummy shell script will do it. | |
4034 |
|
4047 | |||
4035 | Other enhancements made for things to work better under Emacs' |
|
4048 | Other enhancements made for things to work better under Emacs' | |
4036 | various types of terminals. Many thanks to Milan Zamazal |
|
4049 | various types of terminals. Many thanks to Milan Zamazal | |
4037 | <pdm-AT-zamazal.org> for all the suggestions and pointers. |
|
4050 | <pdm-AT-zamazal.org> for all the suggestions and pointers. | |
4038 |
|
4051 | |||
4039 | 2002-03-01 Fernando Perez <fperez@colorado.edu> |
|
4052 | 2002-03-01 Fernando Perez <fperez@colorado.edu> | |
4040 |
|
4053 | |||
4041 | * IPython/ipmaker.py (make_IPython): added a --readline! option so |
|
4054 | * IPython/ipmaker.py (make_IPython): added a --readline! option so | |
4042 | that loading of readline is now optional. This gives better |
|
4055 | that loading of readline is now optional. This gives better | |
4043 | control to emacs users. |
|
4056 | control to emacs users. | |
4044 |
|
4057 | |||
4045 | * IPython/ultraTB.py (__date__): Modified color escape sequences |
|
4058 | * IPython/ultraTB.py (__date__): Modified color escape sequences | |
4046 | and now things work fine under xterm and in Emacs' term buffers |
|
4059 | and now things work fine under xterm and in Emacs' term buffers | |
4047 | (though not shell ones). Well, in emacs you get colors, but all |
|
4060 | (though not shell ones). Well, in emacs you get colors, but all | |
4048 | seem to be 'light' colors (no difference between dark and light |
|
4061 | seem to be 'light' colors (no difference between dark and light | |
4049 | ones). But the garbage chars are gone, and also in xterms. It |
|
4062 | ones). But the garbage chars are gone, and also in xterms. It | |
4050 | seems that now I'm using 'cleaner' ansi sequences. |
|
4063 | seems that now I'm using 'cleaner' ansi sequences. | |
4051 |
|
4064 | |||
4052 | 2002-02-21 Fernando Perez <fperez@colorado.edu> |
|
4065 | 2002-02-21 Fernando Perez <fperez@colorado.edu> | |
4053 |
|
4066 | |||
4054 | * Released 0.2.7 (mainly to publish the scoping fix). |
|
4067 | * Released 0.2.7 (mainly to publish the scoping fix). | |
4055 |
|
4068 | |||
4056 | * IPython/Logger.py (Logger.logstate): added. A corresponding |
|
4069 | * IPython/Logger.py (Logger.logstate): added. A corresponding | |
4057 | @logstate magic was created. |
|
4070 | @logstate magic was created. | |
4058 |
|
4071 | |||
4059 | * IPython/Magic.py: fixed nested scoping problem under Python |
|
4072 | * IPython/Magic.py: fixed nested scoping problem under Python | |
4060 | 2.1.x (automagic wasn't working). |
|
4073 | 2.1.x (automagic wasn't working). | |
4061 |
|
4074 | |||
4062 | 2002-02-20 Fernando Perez <fperez@colorado.edu> |
|
4075 | 2002-02-20 Fernando Perez <fperez@colorado.edu> | |
4063 |
|
4076 | |||
4064 | * Released 0.2.6. |
|
4077 | * Released 0.2.6. | |
4065 |
|
4078 | |||
4066 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' |
|
4079 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' | |
4067 | option so that logs can come out without any headers at all. |
|
4080 | option so that logs can come out without any headers at all. | |
4068 |
|
4081 | |||
4069 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for |
|
4082 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for | |
4070 | SciPy. |
|
4083 | SciPy. | |
4071 |
|
4084 | |||
4072 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so |
|
4085 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so | |
4073 | that embedded IPython calls don't require vars() to be explicitly |
|
4086 | that embedded IPython calls don't require vars() to be explicitly | |
4074 | passed. Now they are extracted from the caller's frame (code |
|
4087 | passed. Now they are extracted from the caller's frame (code | |
4075 | snatched from Eric Jones' weave). Added better documentation to |
|
4088 | snatched from Eric Jones' weave). Added better documentation to | |
4076 | the section on embedding and the example file. |
|
4089 | the section on embedding and the example file. | |
4077 |
|
4090 | |||
4078 | * IPython/genutils.py (page): Changed so that under emacs, it just |
|
4091 | * IPython/genutils.py (page): Changed so that under emacs, it just | |
4079 | prints the string. You can then page up and down in the emacs |
|
4092 | prints the string. You can then page up and down in the emacs | |
4080 | buffer itself. This is how the builtin help() works. |
|
4093 | buffer itself. This is how the builtin help() works. | |
4081 |
|
4094 | |||
4082 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with |
|
4095 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with | |
4083 | macro scoping: macros need to be executed in the user's namespace |
|
4096 | macro scoping: macros need to be executed in the user's namespace | |
4084 | to work as if they had been typed by the user. |
|
4097 | to work as if they had been typed by the user. | |
4085 |
|
4098 | |||
4086 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they |
|
4099 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they | |
4087 | execute automatically (no need to type 'exec...'). They then |
|
4100 | execute automatically (no need to type 'exec...'). They then | |
4088 | behave like 'true macros'. The printing system was also modified |
|
4101 | behave like 'true macros'. The printing system was also modified | |
4089 | for this to work. |
|
4102 | for this to work. | |
4090 |
|
4103 | |||
4091 | 2002-02-19 Fernando Perez <fperez@colorado.edu> |
|
4104 | 2002-02-19 Fernando Perez <fperez@colorado.edu> | |
4092 |
|
4105 | |||
4093 | * IPython/genutils.py (page_file): new function for paging files |
|
4106 | * IPython/genutils.py (page_file): new function for paging files | |
4094 | in an OS-independent way. Also necessary for file viewing to work |
|
4107 | in an OS-independent way. Also necessary for file viewing to work | |
4095 | well inside Emacs buffers. |
|
4108 | well inside Emacs buffers. | |
4096 | (page): Added checks for being in an emacs buffer. |
|
4109 | (page): Added checks for being in an emacs buffer. | |
4097 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed |
|
4110 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed | |
4098 | same bug in iplib. |
|
4111 | same bug in iplib. | |
4099 |
|
4112 | |||
4100 | 2002-02-18 Fernando Perez <fperez@colorado.edu> |
|
4113 | 2002-02-18 Fernando Perez <fperez@colorado.edu> | |
4101 |
|
4114 | |||
4102 | * IPython/iplib.py (InteractiveShell.init_readline): modified use |
|
4115 | * IPython/iplib.py (InteractiveShell.init_readline): modified use | |
4103 | of readline so that IPython can work inside an Emacs buffer. |
|
4116 | of readline so that IPython can work inside an Emacs buffer. | |
4104 |
|
4117 | |||
4105 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to |
|
4118 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to | |
4106 | method signatures (they weren't really bugs, but it looks cleaner |
|
4119 | method signatures (they weren't really bugs, but it looks cleaner | |
4107 | and keeps PyChecker happy). |
|
4120 | and keeps PyChecker happy). | |
4108 |
|
4121 | |||
4109 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP |
|
4122 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP | |
4110 | for implementing various user-defined hooks. Currently only |
|
4123 | for implementing various user-defined hooks. Currently only | |
4111 | display is done. |
|
4124 | display is done. | |
4112 |
|
4125 | |||
4113 | * IPython/Prompts.py (CachedOutput._display): changed display |
|
4126 | * IPython/Prompts.py (CachedOutput._display): changed display | |
4114 | functions so that they can be dynamically changed by users easily. |
|
4127 | functions so that they can be dynamically changed by users easily. | |
4115 |
|
4128 | |||
4116 | * IPython/Extensions/numeric_formats.py (num_display): added an |
|
4129 | * IPython/Extensions/numeric_formats.py (num_display): added an | |
4117 | extension for printing NumPy arrays in flexible manners. It |
|
4130 | extension for printing NumPy arrays in flexible manners. It | |
4118 | doesn't do anything yet, but all the structure is in |
|
4131 | doesn't do anything yet, but all the structure is in | |
4119 | place. Ultimately the plan is to implement output format control |
|
4132 | place. Ultimately the plan is to implement output format control | |
4120 | like in Octave. |
|
4133 | like in Octave. | |
4121 |
|
4134 | |||
4122 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic |
|
4135 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic | |
4123 | methods are found at run-time by all the automatic machinery. |
|
4136 | methods are found at run-time by all the automatic machinery. | |
4124 |
|
4137 | |||
4125 | 2002-02-17 Fernando Perez <fperez@colorado.edu> |
|
4138 | 2002-02-17 Fernando Perez <fperez@colorado.edu> | |
4126 |
|
4139 | |||
4127 | * setup_Windows.py (make_shortcut): documented. Cleaned up the |
|
4140 | * setup_Windows.py (make_shortcut): documented. Cleaned up the | |
4128 | whole file a little. |
|
4141 | whole file a little. | |
4129 |
|
4142 | |||
4130 | * ToDo: closed this document. Now there's a new_design.lyx |
|
4143 | * ToDo: closed this document. Now there's a new_design.lyx | |
4131 | document for all new ideas. Added making a pdf of it for the |
|
4144 | document for all new ideas. Added making a pdf of it for the | |
4132 | end-user distro. |
|
4145 | end-user distro. | |
4133 |
|
4146 | |||
4134 | * IPython/Logger.py (Logger.switch_log): Created this to replace |
|
4147 | * IPython/Logger.py (Logger.switch_log): Created this to replace | |
4135 | logon() and logoff(). It also fixes a nasty crash reported by |
|
4148 | logon() and logoff(). It also fixes a nasty crash reported by | |
4136 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. |
|
4149 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. | |
4137 |
|
4150 | |||
4138 | * IPython/iplib.py (complete): got auto-completion to work with |
|
4151 | * IPython/iplib.py (complete): got auto-completion to work with | |
4139 | automagic (I had wanted this for a long time). |
|
4152 | automagic (I had wanted this for a long time). | |
4140 |
|
4153 | |||
4141 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias |
|
4154 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias | |
4142 | to @file, since file() is now a builtin and clashes with automagic |
|
4155 | to @file, since file() is now a builtin and clashes with automagic | |
4143 | for @file. |
|
4156 | for @file. | |
4144 |
|
4157 | |||
4145 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All |
|
4158 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All | |
4146 | of this was previously in iplib, which had grown to more than 2000 |
|
4159 | of this was previously in iplib, which had grown to more than 2000 | |
4147 | lines, way too long. No new functionality, but it makes managing |
|
4160 | lines, way too long. No new functionality, but it makes managing | |
4148 | the code a bit easier. |
|
4161 | the code a bit easier. | |
4149 |
|
4162 | |||
4150 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version |
|
4163 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version | |
4151 | information to crash reports. |
|
4164 | information to crash reports. | |
4152 |
|
4165 | |||
4153 | 2002-02-12 Fernando Perez <fperez@colorado.edu> |
|
4166 | 2002-02-12 Fernando Perez <fperez@colorado.edu> | |
4154 |
|
4167 | |||
4155 | * Released 0.2.5. |
|
4168 | * Released 0.2.5. | |
4156 |
|
4169 | |||
4157 | 2002-02-11 Fernando Perez <fperez@colorado.edu> |
|
4170 | 2002-02-11 Fernando Perez <fperez@colorado.edu> | |
4158 |
|
4171 | |||
4159 | * Wrote a relatively complete Windows installer. It puts |
|
4172 | * Wrote a relatively complete Windows installer. It puts | |
4160 | everything in place, creates Start Menu entries and fixes the |
|
4173 | everything in place, creates Start Menu entries and fixes the | |
4161 | color issues. Nothing fancy, but it works. |
|
4174 | color issues. Nothing fancy, but it works. | |
4162 |
|
4175 | |||
4163 | 2002-02-10 Fernando Perez <fperez@colorado.edu> |
|
4176 | 2002-02-10 Fernando Perez <fperez@colorado.edu> | |
4164 |
|
4177 | |||
4165 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an |
|
4178 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an | |
4166 | os.path.expanduser() call so that we can type @run ~/myfile.py and |
|
4179 | os.path.expanduser() call so that we can type @run ~/myfile.py and | |
4167 | have thigs work as expected. |
|
4180 | have thigs work as expected. | |
4168 |
|
4181 | |||
4169 | * IPython/genutils.py (page): fixed exception handling so things |
|
4182 | * IPython/genutils.py (page): fixed exception handling so things | |
4170 | work both in Unix and Windows correctly. Quitting a pager triggers |
|
4183 | work both in Unix and Windows correctly. Quitting a pager triggers | |
4171 | an IOError/broken pipe in Unix, and in windows not finding a pager |
|
4184 | an IOError/broken pipe in Unix, and in windows not finding a pager | |
4172 | is also an IOError, so I had to actually look at the return value |
|
4185 | is also an IOError, so I had to actually look at the return value | |
4173 | of the exception, not just the exception itself. Should be ok now. |
|
4186 | of the exception, not just the exception itself. Should be ok now. | |
4174 |
|
4187 | |||
4175 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): |
|
4188 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): | |
4176 | modified to allow case-insensitive color scheme changes. |
|
4189 | modified to allow case-insensitive color scheme changes. | |
4177 |
|
4190 | |||
4178 | 2002-02-09 Fernando Perez <fperez@colorado.edu> |
|
4191 | 2002-02-09 Fernando Perez <fperez@colorado.edu> | |
4179 |
|
4192 | |||
4180 | * IPython/genutils.py (native_line_ends): new function to leave |
|
4193 | * IPython/genutils.py (native_line_ends): new function to leave | |
4181 | user config files with os-native line-endings. |
|
4194 | user config files with os-native line-endings. | |
4182 |
|
4195 | |||
4183 | * README and manual updates. |
|
4196 | * README and manual updates. | |
4184 |
|
4197 | |||
4185 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes |
|
4198 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes | |
4186 | instead of StringType to catch Unicode strings. |
|
4199 | instead of StringType to catch Unicode strings. | |
4187 |
|
4200 | |||
4188 | * IPython/genutils.py (filefind): fixed bug for paths with |
|
4201 | * IPython/genutils.py (filefind): fixed bug for paths with | |
4189 | embedded spaces (very common in Windows). |
|
4202 | embedded spaces (very common in Windows). | |
4190 |
|
4203 | |||
4191 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc |
|
4204 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc | |
4192 | files under Windows, so that they get automatically associated |
|
4205 | files under Windows, so that they get automatically associated | |
4193 | with a text editor. Windows makes it a pain to handle |
|
4206 | with a text editor. Windows makes it a pain to handle | |
4194 | extension-less files. |
|
4207 | extension-less files. | |
4195 |
|
4208 | |||
4196 | * IPython/iplib.py (InteractiveShell.init_readline): Made the |
|
4209 | * IPython/iplib.py (InteractiveShell.init_readline): Made the | |
4197 | warning about readline only occur for Posix. In Windows there's no |
|
4210 | warning about readline only occur for Posix. In Windows there's no | |
4198 | way to get readline, so why bother with the warning. |
|
4211 | way to get readline, so why bother with the warning. | |
4199 |
|
4212 | |||
4200 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ |
|
4213 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ | |
4201 | for __str__ instead of dir(self), since dir() changed in 2.2. |
|
4214 | for __str__ instead of dir(self), since dir() changed in 2.2. | |
4202 |
|
4215 | |||
4203 | * Ported to Windows! Tested on XP, I suspect it should work fine |
|
4216 | * Ported to Windows! Tested on XP, I suspect it should work fine | |
4204 | on NT/2000, but I don't think it will work on 98 et al. That |
|
4217 | on NT/2000, but I don't think it will work on 98 et al. That | |
4205 | series of Windows is such a piece of junk anyway that I won't try |
|
4218 | series of Windows is such a piece of junk anyway that I won't try | |
4206 | porting it there. The XP port was straightforward, showed a few |
|
4219 | porting it there. The XP port was straightforward, showed a few | |
4207 | bugs here and there (fixed all), in particular some string |
|
4220 | bugs here and there (fixed all), in particular some string | |
4208 | handling stuff which required considering Unicode strings (which |
|
4221 | handling stuff which required considering Unicode strings (which | |
4209 | Windows uses). This is good, but hasn't been too tested :) No |
|
4222 | Windows uses). This is good, but hasn't been too tested :) No | |
4210 | fancy installer yet, I'll put a note in the manual so people at |
|
4223 | fancy installer yet, I'll put a note in the manual so people at | |
4211 | least make manually a shortcut. |
|
4224 | least make manually a shortcut. | |
4212 |
|
4225 | |||
4213 | * IPython/iplib.py (Magic.magic_colors): Unified the color options |
|
4226 | * IPython/iplib.py (Magic.magic_colors): Unified the color options | |
4214 | into a single one, "colors". This now controls both prompt and |
|
4227 | into a single one, "colors". This now controls both prompt and | |
4215 | exception color schemes, and can be changed both at startup |
|
4228 | exception color schemes, and can be changed both at startup | |
4216 | (either via command-line switches or via ipythonrc files) and at |
|
4229 | (either via command-line switches or via ipythonrc files) and at | |
4217 | runtime, with @colors. |
|
4230 | runtime, with @colors. | |
4218 | (Magic.magic_run): renamed @prun to @run and removed the old |
|
4231 | (Magic.magic_run): renamed @prun to @run and removed the old | |
4219 | @run. The two were too similar to warrant keeping both. |
|
4232 | @run. The two were too similar to warrant keeping both. | |
4220 |
|
4233 | |||
4221 | 2002-02-03 Fernando Perez <fperez@colorado.edu> |
|
4234 | 2002-02-03 Fernando Perez <fperez@colorado.edu> | |
4222 |
|
4235 | |||
4223 | * IPython/iplib.py (install_first_time): Added comment on how to |
|
4236 | * IPython/iplib.py (install_first_time): Added comment on how to | |
4224 | configure the color options for first-time users. Put a <return> |
|
4237 | configure the color options for first-time users. Put a <return> | |
4225 | request at the end so that small-terminal users get a chance to |
|
4238 | request at the end so that small-terminal users get a chance to | |
4226 | read the startup info. |
|
4239 | read the startup info. | |
4227 |
|
4240 | |||
4228 | 2002-01-23 Fernando Perez <fperez@colorado.edu> |
|
4241 | 2002-01-23 Fernando Perez <fperez@colorado.edu> | |
4229 |
|
4242 | |||
4230 | * IPython/iplib.py (CachedOutput.update): Changed output memory |
|
4243 | * IPython/iplib.py (CachedOutput.update): Changed output memory | |
4231 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For |
|
4244 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For | |
4232 | input history we still use _i. Did this b/c these variable are |
|
4245 | input history we still use _i. Did this b/c these variable are | |
4233 | very commonly used in interactive work, so the less we need to |
|
4246 | very commonly used in interactive work, so the less we need to | |
4234 | type the better off we are. |
|
4247 | type the better off we are. | |
4235 | (Magic.magic_prun): updated @prun to better handle the namespaces |
|
4248 | (Magic.magic_prun): updated @prun to better handle the namespaces | |
4236 | the file will run in, including a fix for __name__ not being set |
|
4249 | the file will run in, including a fix for __name__ not being set | |
4237 | before. |
|
4250 | before. | |
4238 |
|
4251 | |||
4239 | 2002-01-20 Fernando Perez <fperez@colorado.edu> |
|
4252 | 2002-01-20 Fernando Perez <fperez@colorado.edu> | |
4240 |
|
4253 | |||
4241 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of |
|
4254 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of | |
4242 | extra garbage for Python 2.2. Need to look more carefully into |
|
4255 | extra garbage for Python 2.2. Need to look more carefully into | |
4243 | this later. |
|
4256 | this later. | |
4244 |
|
4257 | |||
4245 | 2002-01-19 Fernando Perez <fperez@colorado.edu> |
|
4258 | 2002-01-19 Fernando Perez <fperez@colorado.edu> | |
4246 |
|
4259 | |||
4247 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to |
|
4260 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to | |
4248 | display SyntaxError exceptions properly formatted when they occur |
|
4261 | display SyntaxError exceptions properly formatted when they occur | |
4249 | (they can be triggered by imported code). |
|
4262 | (they can be triggered by imported code). | |
4250 |
|
4263 | |||
4251 | 2002-01-18 Fernando Perez <fperez@colorado.edu> |
|
4264 | 2002-01-18 Fernando Perez <fperez@colorado.edu> | |
4252 |
|
4265 | |||
4253 | * IPython/iplib.py (InteractiveShell.safe_execfile): now |
|
4266 | * IPython/iplib.py (InteractiveShell.safe_execfile): now | |
4254 | SyntaxError exceptions are reported nicely formatted, instead of |
|
4267 | SyntaxError exceptions are reported nicely formatted, instead of | |
4255 | spitting out only offset information as before. |
|
4268 | spitting out only offset information as before. | |
4256 | (Magic.magic_prun): Added the @prun function for executing |
|
4269 | (Magic.magic_prun): Added the @prun function for executing | |
4257 | programs with command line args inside IPython. |
|
4270 | programs with command line args inside IPython. | |
4258 |
|
4271 | |||
4259 | 2002-01-16 Fernando Perez <fperez@colorado.edu> |
|
4272 | 2002-01-16 Fernando Perez <fperez@colorado.edu> | |
4260 |
|
4273 | |||
4261 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist |
|
4274 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist | |
4262 | to *not* include the last item given in a range. This brings their |
|
4275 | to *not* include the last item given in a range. This brings their | |
4263 | behavior in line with Python's slicing: |
|
4276 | behavior in line with Python's slicing: | |
4264 | a[n1:n2] -> a[n1]...a[n2-1] |
|
4277 | a[n1:n2] -> a[n1]...a[n2-1] | |
4265 | It may be a bit less convenient, but I prefer to stick to Python's |
|
4278 | It may be a bit less convenient, but I prefer to stick to Python's | |
4266 | conventions *everywhere*, so users never have to wonder. |
|
4279 | conventions *everywhere*, so users never have to wonder. | |
4267 | (Magic.magic_macro): Added @macro function to ease the creation of |
|
4280 | (Magic.magic_macro): Added @macro function to ease the creation of | |
4268 | macros. |
|
4281 | macros. | |
4269 |
|
4282 | |||
4270 | 2002-01-05 Fernando Perez <fperez@colorado.edu> |
|
4283 | 2002-01-05 Fernando Perez <fperez@colorado.edu> | |
4271 |
|
4284 | |||
4272 | * Released 0.2.4. |
|
4285 | * Released 0.2.4. | |
4273 |
|
4286 | |||
4274 | * IPython/iplib.py (Magic.magic_pdef): |
|
4287 | * IPython/iplib.py (Magic.magic_pdef): | |
4275 | (InteractiveShell.safe_execfile): report magic lines and error |
|
4288 | (InteractiveShell.safe_execfile): report magic lines and error | |
4276 | lines without line numbers so one can easily copy/paste them for |
|
4289 | lines without line numbers so one can easily copy/paste them for | |
4277 | re-execution. |
|
4290 | re-execution. | |
4278 |
|
4291 | |||
4279 | * Updated manual with recent changes. |
|
4292 | * Updated manual with recent changes. | |
4280 |
|
4293 | |||
4281 | * IPython/iplib.py (Magic.magic_oinfo): added constructor |
|
4294 | * IPython/iplib.py (Magic.magic_oinfo): added constructor | |
4282 | docstring printing when class? is called. Very handy for knowing |
|
4295 | docstring printing when class? is called. Very handy for knowing | |
4283 | how to create class instances (as long as __init__ is well |
|
4296 | how to create class instances (as long as __init__ is well | |
4284 | documented, of course :) |
|
4297 | documented, of course :) | |
4285 | (Magic.magic_doc): print both class and constructor docstrings. |
|
4298 | (Magic.magic_doc): print both class and constructor docstrings. | |
4286 | (Magic.magic_pdef): give constructor info if passed a class and |
|
4299 | (Magic.magic_pdef): give constructor info if passed a class and | |
4287 | __call__ info for callable object instances. |
|
4300 | __call__ info for callable object instances. | |
4288 |
|
4301 | |||
4289 | 2002-01-04 Fernando Perez <fperez@colorado.edu> |
|
4302 | 2002-01-04 Fernando Perez <fperez@colorado.edu> | |
4290 |
|
4303 | |||
4291 | * Made deep_reload() off by default. It doesn't always work |
|
4304 | * Made deep_reload() off by default. It doesn't always work | |
4292 | exactly as intended, so it's probably safer to have it off. It's |
|
4305 | exactly as intended, so it's probably safer to have it off. It's | |
4293 | still available as dreload() anyway, so nothing is lost. |
|
4306 | still available as dreload() anyway, so nothing is lost. | |
4294 |
|
4307 | |||
4295 | 2002-01-02 Fernando Perez <fperez@colorado.edu> |
|
4308 | 2002-01-02 Fernando Perez <fperez@colorado.edu> | |
4296 |
|
4309 | |||
4297 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, |
|
4310 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, | |
4298 | so I wanted an updated release). |
|
4311 | so I wanted an updated release). | |
4299 |
|
4312 | |||
4300 | 2001-12-27 Fernando Perez <fperez@colorado.edu> |
|
4313 | 2001-12-27 Fernando Perez <fperez@colorado.edu> | |
4301 |
|
4314 | |||
4302 | * IPython/iplib.py (InteractiveShell.interact): Added the original |
|
4315 | * IPython/iplib.py (InteractiveShell.interact): Added the original | |
4303 | code from 'code.py' for this module in order to change the |
|
4316 | code from 'code.py' for this module in order to change the | |
4304 | handling of a KeyboardInterrupt. This was necessary b/c otherwise |
|
4317 | handling of a KeyboardInterrupt. This was necessary b/c otherwise | |
4305 | the history cache would break when the user hit Ctrl-C, and |
|
4318 | the history cache would break when the user hit Ctrl-C, and | |
4306 | interact() offers no way to add any hooks to it. |
|
4319 | interact() offers no way to add any hooks to it. | |
4307 |
|
4320 | |||
4308 | 2001-12-23 Fernando Perez <fperez@colorado.edu> |
|
4321 | 2001-12-23 Fernando Perez <fperez@colorado.edu> | |
4309 |
|
4322 | |||
4310 | * setup.py: added check for 'MANIFEST' before trying to remove |
|
4323 | * setup.py: added check for 'MANIFEST' before trying to remove | |
4311 | it. Thanks to Sean Reifschneider. |
|
4324 | it. Thanks to Sean Reifschneider. | |
4312 |
|
4325 | |||
4313 | 2001-12-22 Fernando Perez <fperez@colorado.edu> |
|
4326 | 2001-12-22 Fernando Perez <fperez@colorado.edu> | |
4314 |
|
4327 | |||
4315 | * Released 0.2.2. |
|
4328 | * Released 0.2.2. | |
4316 |
|
4329 | |||
4317 | * Finished (reasonably) writing the manual. Later will add the |
|
4330 | * Finished (reasonably) writing the manual. Later will add the | |
4318 | python-standard navigation stylesheets, but for the time being |
|
4331 | python-standard navigation stylesheets, but for the time being | |
4319 | it's fairly complete. Distribution will include html and pdf |
|
4332 | it's fairly complete. Distribution will include html and pdf | |
4320 | versions. |
|
4333 | versions. | |
4321 |
|
4334 | |||
4322 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu |
|
4335 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu | |
4323 | (MayaVi author). |
|
4336 | (MayaVi author). | |
4324 |
|
4337 | |||
4325 | 2001-12-21 Fernando Perez <fperez@colorado.edu> |
|
4338 | 2001-12-21 Fernando Perez <fperez@colorado.edu> | |
4326 |
|
4339 | |||
4327 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a |
|
4340 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a | |
4328 | good public release, I think (with the manual and the distutils |
|
4341 | good public release, I think (with the manual and the distutils | |
4329 | installer). The manual can use some work, but that can go |
|
4342 | installer). The manual can use some work, but that can go | |
4330 | slowly. Otherwise I think it's quite nice for end users. Next |
|
4343 | slowly. Otherwise I think it's quite nice for end users. Next | |
4331 | summer, rewrite the guts of it... |
|
4344 | summer, rewrite the guts of it... | |
4332 |
|
4345 | |||
4333 | * Changed format of ipythonrc files to use whitespace as the |
|
4346 | * Changed format of ipythonrc files to use whitespace as the | |
4334 | separator instead of an explicit '='. Cleaner. |
|
4347 | separator instead of an explicit '='. Cleaner. | |
4335 |
|
4348 | |||
4336 | 2001-12-20 Fernando Perez <fperez@colorado.edu> |
|
4349 | 2001-12-20 Fernando Perez <fperez@colorado.edu> | |
4337 |
|
4350 | |||
4338 | * Started a manual in LyX. For now it's just a quick merge of the |
|
4351 | * Started a manual in LyX. For now it's just a quick merge of the | |
4339 | various internal docstrings and READMEs. Later it may grow into a |
|
4352 | various internal docstrings and READMEs. Later it may grow into a | |
4340 | nice, full-blown manual. |
|
4353 | nice, full-blown manual. | |
4341 |
|
4354 | |||
4342 | * Set up a distutils based installer. Installation should now be |
|
4355 | * Set up a distutils based installer. Installation should now be | |
4343 | trivially simple for end-users. |
|
4356 | trivially simple for end-users. | |
4344 |
|
4357 | |||
4345 | 2001-12-11 Fernando Perez <fperez@colorado.edu> |
|
4358 | 2001-12-11 Fernando Perez <fperez@colorado.edu> | |
4346 |
|
4359 | |||
4347 | * Released 0.2.0. First public release, announced it at |
|
4360 | * Released 0.2.0. First public release, announced it at | |
4348 | comp.lang.python. From now on, just bugfixes... |
|
4361 | comp.lang.python. From now on, just bugfixes... | |
4349 |
|
4362 | |||
4350 | * Went through all the files, set copyright/license notices and |
|
4363 | * Went through all the files, set copyright/license notices and | |
4351 | cleaned up things. Ready for release. |
|
4364 | cleaned up things. Ready for release. | |
4352 |
|
4365 | |||
4353 | 2001-12-10 Fernando Perez <fperez@colorado.edu> |
|
4366 | 2001-12-10 Fernando Perez <fperez@colorado.edu> | |
4354 |
|
4367 | |||
4355 | * Changed the first-time installer not to use tarfiles. It's more |
|
4368 | * Changed the first-time installer not to use tarfiles. It's more | |
4356 | robust now and less unix-dependent. Also makes it easier for |
|
4369 | robust now and less unix-dependent. Also makes it easier for | |
4357 | people to later upgrade versions. |
|
4370 | people to later upgrade versions. | |
4358 |
|
4371 | |||
4359 | * Changed @exit to @abort to reflect the fact that it's pretty |
|
4372 | * Changed @exit to @abort to reflect the fact that it's pretty | |
4360 | brutal (a sys.exit()). The difference between @abort and Ctrl-D |
|
4373 | brutal (a sys.exit()). The difference between @abort and Ctrl-D | |
4361 | becomes significant only when IPyhton is embedded: in that case, |
|
4374 | becomes significant only when IPyhton is embedded: in that case, | |
4362 | C-D closes IPython only, but @abort kills the enclosing program |
|
4375 | C-D closes IPython only, but @abort kills the enclosing program | |
4363 | too (unless it had called IPython inside a try catching |
|
4376 | too (unless it had called IPython inside a try catching | |
4364 | SystemExit). |
|
4377 | SystemExit). | |
4365 |
|
4378 | |||
4366 | * Created Shell module which exposes the actuall IPython Shell |
|
4379 | * Created Shell module which exposes the actuall IPython Shell | |
4367 | classes, currently the normal and the embeddable one. This at |
|
4380 | classes, currently the normal and the embeddable one. This at | |
4368 | least offers a stable interface we won't need to change when |
|
4381 | least offers a stable interface we won't need to change when | |
4369 | (later) the internals are rewritten. That rewrite will be confined |
|
4382 | (later) the internals are rewritten. That rewrite will be confined | |
4370 | to iplib and ipmaker, but the Shell interface should remain as is. |
|
4383 | to iplib and ipmaker, but the Shell interface should remain as is. | |
4371 |
|
4384 | |||
4372 | * Added embed module which offers an embeddable IPShell object, |
|
4385 | * Added embed module which offers an embeddable IPShell object, | |
4373 | useful to fire up IPython *inside* a running program. Great for |
|
4386 | useful to fire up IPython *inside* a running program. Great for | |
4374 | debugging or dynamical data analysis. |
|
4387 | debugging or dynamical data analysis. | |
4375 |
|
4388 | |||
4376 | 2001-12-08 Fernando Perez <fperez@colorado.edu> |
|
4389 | 2001-12-08 Fernando Perez <fperez@colorado.edu> | |
4377 |
|
4390 | |||
4378 | * Fixed small bug preventing seeing info from methods of defined |
|
4391 | * Fixed small bug preventing seeing info from methods of defined | |
4379 | objects (incorrect namespace in _ofind()). |
|
4392 | objects (incorrect namespace in _ofind()). | |
4380 |
|
4393 | |||
4381 | * Documentation cleanup. Moved the main usage docstrings to a |
|
4394 | * Documentation cleanup. Moved the main usage docstrings to a | |
4382 | separate file, usage.py (cleaner to maintain, and hopefully in the |
|
4395 | separate file, usage.py (cleaner to maintain, and hopefully in the | |
4383 | future some perlpod-like way of producing interactive, man and |
|
4396 | future some perlpod-like way of producing interactive, man and | |
4384 | html docs out of it will be found). |
|
4397 | html docs out of it will be found). | |
4385 |
|
4398 | |||
4386 | * Added @profile to see your profile at any time. |
|
4399 | * Added @profile to see your profile at any time. | |
4387 |
|
4400 | |||
4388 | * Added @p as an alias for 'print'. It's especially convenient if |
|
4401 | * Added @p as an alias for 'print'. It's especially convenient if | |
4389 | using automagic ('p x' prints x). |
|
4402 | using automagic ('p x' prints x). | |
4390 |
|
4403 | |||
4391 | * Small cleanups and fixes after a pychecker run. |
|
4404 | * Small cleanups and fixes after a pychecker run. | |
4392 |
|
4405 | |||
4393 | * Changed the @cd command to handle @cd - and @cd -<n> for |
|
4406 | * Changed the @cd command to handle @cd - and @cd -<n> for | |
4394 | visiting any directory in _dh. |
|
4407 | visiting any directory in _dh. | |
4395 |
|
4408 | |||
4396 | * Introduced _dh, a history of visited directories. @dhist prints |
|
4409 | * Introduced _dh, a history of visited directories. @dhist prints | |
4397 | it out with numbers. |
|
4410 | it out with numbers. | |
4398 |
|
4411 | |||
4399 | 2001-12-07 Fernando Perez <fperez@colorado.edu> |
|
4412 | 2001-12-07 Fernando Perez <fperez@colorado.edu> | |
4400 |
|
4413 | |||
4401 | * Released 0.1.22 |
|
4414 | * Released 0.1.22 | |
4402 |
|
4415 | |||
4403 | * Made initialization a bit more robust against invalid color |
|
4416 | * Made initialization a bit more robust against invalid color | |
4404 | options in user input (exit, not traceback-crash). |
|
4417 | options in user input (exit, not traceback-crash). | |
4405 |
|
4418 | |||
4406 | * Changed the bug crash reporter to write the report only in the |
|
4419 | * Changed the bug crash reporter to write the report only in the | |
4407 | user's .ipython directory. That way IPython won't litter people's |
|
4420 | user's .ipython directory. That way IPython won't litter people's | |
4408 | hard disks with crash files all over the place. Also print on |
|
4421 | hard disks with crash files all over the place. Also print on | |
4409 | screen the necessary mail command. |
|
4422 | screen the necessary mail command. | |
4410 |
|
4423 | |||
4411 | * With the new ultraTB, implemented LightBG color scheme for light |
|
4424 | * With the new ultraTB, implemented LightBG color scheme for light | |
4412 | background terminals. A lot of people like white backgrounds, so I |
|
4425 | background terminals. A lot of people like white backgrounds, so I | |
4413 | guess we should at least give them something readable. |
|
4426 | guess we should at least give them something readable. | |
4414 |
|
4427 | |||
4415 | 2001-12-06 Fernando Perez <fperez@colorado.edu> |
|
4428 | 2001-12-06 Fernando Perez <fperez@colorado.edu> | |
4416 |
|
4429 | |||
4417 | * Modified the structure of ultraTB. Now there's a proper class |
|
4430 | * Modified the structure of ultraTB. Now there's a proper class | |
4418 | for tables of color schemes which allow adding schemes easily and |
|
4431 | for tables of color schemes which allow adding schemes easily and | |
4419 | switching the active scheme without creating a new instance every |
|
4432 | switching the active scheme without creating a new instance every | |
4420 | time (which was ridiculous). The syntax for creating new schemes |
|
4433 | time (which was ridiculous). The syntax for creating new schemes | |
4421 | is also cleaner. I think ultraTB is finally done, with a clean |
|
4434 | is also cleaner. I think ultraTB is finally done, with a clean | |
4422 | class structure. Names are also much cleaner (now there's proper |
|
4435 | class structure. Names are also much cleaner (now there's proper | |
4423 | color tables, no need for every variable to also have 'color' in |
|
4436 | color tables, no need for every variable to also have 'color' in | |
4424 | its name). |
|
4437 | its name). | |
4425 |
|
4438 | |||
4426 | * Broke down genutils into separate files. Now genutils only |
|
4439 | * Broke down genutils into separate files. Now genutils only | |
4427 | contains utility functions, and classes have been moved to their |
|
4440 | contains utility functions, and classes have been moved to their | |
4428 | own files (they had enough independent functionality to warrant |
|
4441 | own files (they had enough independent functionality to warrant | |
4429 | it): ConfigLoader, OutputTrap, Struct. |
|
4442 | it): ConfigLoader, OutputTrap, Struct. | |
4430 |
|
4443 | |||
4431 | 2001-12-05 Fernando Perez <fperez@colorado.edu> |
|
4444 | 2001-12-05 Fernando Perez <fperez@colorado.edu> | |
4432 |
|
4445 | |||
4433 | * IPython turns 21! Released version 0.1.21, as a candidate for |
|
4446 | * IPython turns 21! Released version 0.1.21, as a candidate for | |
4434 | public consumption. If all goes well, release in a few days. |
|
4447 | public consumption. If all goes well, release in a few days. | |
4435 |
|
4448 | |||
4436 | * Fixed path bug (files in Extensions/ directory wouldn't be found |
|
4449 | * Fixed path bug (files in Extensions/ directory wouldn't be found | |
4437 | unless IPython/ was explicitly in sys.path). |
|
4450 | unless IPython/ was explicitly in sys.path). | |
4438 |
|
4451 | |||
4439 | * Extended the FlexCompleter class as MagicCompleter to allow |
|
4452 | * Extended the FlexCompleter class as MagicCompleter to allow | |
4440 | completion of @-starting lines. |
|
4453 | completion of @-starting lines. | |
4441 |
|
4454 | |||
4442 | * Created __release__.py file as a central repository for release |
|
4455 | * Created __release__.py file as a central repository for release | |
4443 | info that other files can read from. |
|
4456 | info that other files can read from. | |
4444 |
|
4457 | |||
4445 | * Fixed small bug in logging: when logging was turned on in |
|
4458 | * Fixed small bug in logging: when logging was turned on in | |
4446 | mid-session, old lines with special meanings (!@?) were being |
|
4459 | mid-session, old lines with special meanings (!@?) were being | |
4447 | logged without the prepended comment, which is necessary since |
|
4460 | logged without the prepended comment, which is necessary since | |
4448 | they are not truly valid python syntax. This should make session |
|
4461 | they are not truly valid python syntax. This should make session | |
4449 | restores produce less errors. |
|
4462 | restores produce less errors. | |
4450 |
|
4463 | |||
4451 | * The namespace cleanup forced me to make a FlexCompleter class |
|
4464 | * The namespace cleanup forced me to make a FlexCompleter class | |
4452 | which is nothing but a ripoff of rlcompleter, but with selectable |
|
4465 | which is nothing but a ripoff of rlcompleter, but with selectable | |
4453 | namespace (rlcompleter only works in __main__.__dict__). I'll try |
|
4466 | namespace (rlcompleter only works in __main__.__dict__). I'll try | |
4454 | to submit a note to the authors to see if this change can be |
|
4467 | to submit a note to the authors to see if this change can be | |
4455 | incorporated in future rlcompleter releases (Dec.6: done) |
|
4468 | incorporated in future rlcompleter releases (Dec.6: done) | |
4456 |
|
4469 | |||
4457 | * More fixes to namespace handling. It was a mess! Now all |
|
4470 | * More fixes to namespace handling. It was a mess! Now all | |
4458 | explicit references to __main__.__dict__ are gone (except when |
|
4471 | explicit references to __main__.__dict__ are gone (except when | |
4459 | really needed) and everything is handled through the namespace |
|
4472 | really needed) and everything is handled through the namespace | |
4460 | dicts in the IPython instance. We seem to be getting somewhere |
|
4473 | dicts in the IPython instance. We seem to be getting somewhere | |
4461 | with this, finally... |
|
4474 | with this, finally... | |
4462 |
|
4475 | |||
4463 | * Small documentation updates. |
|
4476 | * Small documentation updates. | |
4464 |
|
4477 | |||
4465 | * Created the Extensions directory under IPython (with an |
|
4478 | * Created the Extensions directory under IPython (with an | |
4466 | __init__.py). Put the PhysicalQ stuff there. This directory should |
|
4479 | __init__.py). Put the PhysicalQ stuff there. This directory should | |
4467 | be used for all special-purpose extensions. |
|
4480 | be used for all special-purpose extensions. | |
4468 |
|
4481 | |||
4469 | * File renaming: |
|
4482 | * File renaming: | |
4470 | ipythonlib --> ipmaker |
|
4483 | ipythonlib --> ipmaker | |
4471 | ipplib --> iplib |
|
4484 | ipplib --> iplib | |
4472 | This makes a bit more sense in terms of what these files actually do. |
|
4485 | This makes a bit more sense in terms of what these files actually do. | |
4473 |
|
4486 | |||
4474 | * Moved all the classes and functions in ipythonlib to ipplib, so |
|
4487 | * Moved all the classes and functions in ipythonlib to ipplib, so | |
4475 | now ipythonlib only has make_IPython(). This will ease up its |
|
4488 | now ipythonlib only has make_IPython(). This will ease up its | |
4476 | splitting in smaller functional chunks later. |
|
4489 | splitting in smaller functional chunks later. | |
4477 |
|
4490 | |||
4478 | * Cleaned up (done, I think) output of @whos. Better column |
|
4491 | * Cleaned up (done, I think) output of @whos. Better column | |
4479 | formatting, and now shows str(var) for as much as it can, which is |
|
4492 | formatting, and now shows str(var) for as much as it can, which is | |
4480 | typically what one gets with a 'print var'. |
|
4493 | typically what one gets with a 'print var'. | |
4481 |
|
4494 | |||
4482 | 2001-12-04 Fernando Perez <fperez@colorado.edu> |
|
4495 | 2001-12-04 Fernando Perez <fperez@colorado.edu> | |
4483 |
|
4496 | |||
4484 | * Fixed namespace problems. Now builtin/IPyhton/user names get |
|
4497 | * Fixed namespace problems. Now builtin/IPyhton/user names get | |
4485 | properly reported in their namespace. Internal namespace handling |
|
4498 | properly reported in their namespace. Internal namespace handling | |
4486 | is finally getting decent (not perfect yet, but much better than |
|
4499 | is finally getting decent (not perfect yet, but much better than | |
4487 | the ad-hoc mess we had). |
|
4500 | the ad-hoc mess we had). | |
4488 |
|
4501 | |||
4489 | * Removed -exit option. If people just want to run a python |
|
4502 | * Removed -exit option. If people just want to run a python | |
4490 | script, that's what the normal interpreter is for. Less |
|
4503 | script, that's what the normal interpreter is for. Less | |
4491 | unnecessary options, less chances for bugs. |
|
4504 | unnecessary options, less chances for bugs. | |
4492 |
|
4505 | |||
4493 | * Added a crash handler which generates a complete post-mortem if |
|
4506 | * Added a crash handler which generates a complete post-mortem if | |
4494 | IPython crashes. This will help a lot in tracking bugs down the |
|
4507 | IPython crashes. This will help a lot in tracking bugs down the | |
4495 | road. |
|
4508 | road. | |
4496 |
|
4509 | |||
4497 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names |
|
4510 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names | |
4498 | which were boud to functions being reassigned would bypass the |
|
4511 | which were boud to functions being reassigned would bypass the | |
4499 | logger, breaking the sync of _il with the prompt counter. This |
|
4512 | logger, breaking the sync of _il with the prompt counter. This | |
4500 | would then crash IPython later when a new line was logged. |
|
4513 | would then crash IPython later when a new line was logged. | |
4501 |
|
4514 | |||
4502 | 2001-12-02 Fernando Perez <fperez@colorado.edu> |
|
4515 | 2001-12-02 Fernando Perez <fperez@colorado.edu> | |
4503 |
|
4516 | |||
4504 | * Made IPython a package. This means people don't have to clutter |
|
4517 | * Made IPython a package. This means people don't have to clutter | |
4505 | their sys.path with yet another directory. Changed the INSTALL |
|
4518 | their sys.path with yet another directory. Changed the INSTALL | |
4506 | file accordingly. |
|
4519 | file accordingly. | |
4507 |
|
4520 | |||
4508 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now |
|
4521 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now | |
4509 | sorts its output (so @who shows it sorted) and @whos formats the |
|
4522 | sorts its output (so @who shows it sorted) and @whos formats the | |
4510 | table according to the width of the first column. Nicer, easier to |
|
4523 | table according to the width of the first column. Nicer, easier to | |
4511 | read. Todo: write a generic table_format() which takes a list of |
|
4524 | read. Todo: write a generic table_format() which takes a list of | |
4512 | lists and prints it nicely formatted, with optional row/column |
|
4525 | lists and prints it nicely formatted, with optional row/column | |
4513 | separators and proper padding and justification. |
|
4526 | separators and proper padding and justification. | |
4514 |
|
4527 | |||
4515 | * Released 0.1.20 |
|
4528 | * Released 0.1.20 | |
4516 |
|
4529 | |||
4517 | * Fixed bug in @log which would reverse the inputcache list (a |
|
4530 | * Fixed bug in @log which would reverse the inputcache list (a | |
4518 | copy operation was missing). |
|
4531 | copy operation was missing). | |
4519 |
|
4532 | |||
4520 | * Code cleanup. @config was changed to use page(). Better, since |
|
4533 | * Code cleanup. @config was changed to use page(). Better, since | |
4521 | its output is always quite long. |
|
4534 | its output is always quite long. | |
4522 |
|
4535 | |||
4523 | * Itpl is back as a dependency. I was having too many problems |
|
4536 | * Itpl is back as a dependency. I was having too many problems | |
4524 | getting the parametric aliases to work reliably, and it's just |
|
4537 | getting the parametric aliases to work reliably, and it's just | |
4525 | easier to code weird string operations with it than playing %()s |
|
4538 | easier to code weird string operations with it than playing %()s | |
4526 | games. It's only ~6k, so I don't think it's too big a deal. |
|
4539 | games. It's only ~6k, so I don't think it's too big a deal. | |
4527 |
|
4540 | |||
4528 | * Found (and fixed) a very nasty bug with history. !lines weren't |
|
4541 | * Found (and fixed) a very nasty bug with history. !lines weren't | |
4529 | getting cached, and the out of sync caches would crash |
|
4542 | getting cached, and the out of sync caches would crash | |
4530 | IPython. Fixed it by reorganizing the prefilter/handlers/logger |
|
4543 | IPython. Fixed it by reorganizing the prefilter/handlers/logger | |
4531 | division of labor a bit better. Bug fixed, cleaner structure. |
|
4544 | division of labor a bit better. Bug fixed, cleaner structure. | |
4532 |
|
4545 | |||
4533 | 2001-12-01 Fernando Perez <fperez@colorado.edu> |
|
4546 | 2001-12-01 Fernando Perez <fperez@colorado.edu> | |
4534 |
|
4547 | |||
4535 | * Released 0.1.19 |
|
4548 | * Released 0.1.19 | |
4536 |
|
4549 | |||
4537 | * Added option -n to @hist to prevent line number printing. Much |
|
4550 | * Added option -n to @hist to prevent line number printing. Much | |
4538 | easier to copy/paste code this way. |
|
4551 | easier to copy/paste code this way. | |
4539 |
|
4552 | |||
4540 | * Created global _il to hold the input list. Allows easy |
|
4553 | * Created global _il to hold the input list. Allows easy | |
4541 | re-execution of blocks of code by slicing it (inspired by Janko's |
|
4554 | re-execution of blocks of code by slicing it (inspired by Janko's | |
4542 | comment on 'macros'). |
|
4555 | comment on 'macros'). | |
4543 |
|
4556 | |||
4544 | * Small fixes and doc updates. |
|
4557 | * Small fixes and doc updates. | |
4545 |
|
4558 | |||
4546 | * Rewrote @history function (was @h). Renamed it to @hist, @h is |
|
4559 | * Rewrote @history function (was @h). Renamed it to @hist, @h is | |
4547 | much too fragile with automagic. Handles properly multi-line |
|
4560 | much too fragile with automagic. Handles properly multi-line | |
4548 | statements and takes parameters. |
|
4561 | statements and takes parameters. | |
4549 |
|
4562 | |||
4550 | 2001-11-30 Fernando Perez <fperez@colorado.edu> |
|
4563 | 2001-11-30 Fernando Perez <fperez@colorado.edu> | |
4551 |
|
4564 | |||
4552 | * Version 0.1.18 released. |
|
4565 | * Version 0.1.18 released. | |
4553 |
|
4566 | |||
4554 | * Fixed nasty namespace bug in initial module imports. |
|
4567 | * Fixed nasty namespace bug in initial module imports. | |
4555 |
|
4568 | |||
4556 | * Added copyright/license notes to all code files (except |
|
4569 | * Added copyright/license notes to all code files (except | |
4557 | DPyGetOpt). For the time being, LGPL. That could change. |
|
4570 | DPyGetOpt). For the time being, LGPL. That could change. | |
4558 |
|
4571 | |||
4559 | * Rewrote a much nicer README, updated INSTALL, cleaned up |
|
4572 | * Rewrote a much nicer README, updated INSTALL, cleaned up | |
4560 | ipythonrc-* samples. |
|
4573 | ipythonrc-* samples. | |
4561 |
|
4574 | |||
4562 | * Overall code/documentation cleanup. Basically ready for |
|
4575 | * Overall code/documentation cleanup. Basically ready for | |
4563 | release. Only remaining thing: licence decision (LGPL?). |
|
4576 | release. Only remaining thing: licence decision (LGPL?). | |
4564 |
|
4577 | |||
4565 | * Converted load_config to a class, ConfigLoader. Now recursion |
|
4578 | * Converted load_config to a class, ConfigLoader. Now recursion | |
4566 | control is better organized. Doesn't include the same file twice. |
|
4579 | control is better organized. Doesn't include the same file twice. | |
4567 |
|
4580 | |||
4568 | 2001-11-29 Fernando Perez <fperez@colorado.edu> |
|
4581 | 2001-11-29 Fernando Perez <fperez@colorado.edu> | |
4569 |
|
4582 | |||
4570 | * Got input history working. Changed output history variables from |
|
4583 | * Got input history working. Changed output history variables from | |
4571 | _p to _o so that _i is for input and _o for output. Just cleaner |
|
4584 | _p to _o so that _i is for input and _o for output. Just cleaner | |
4572 | convention. |
|
4585 | convention. | |
4573 |
|
4586 | |||
4574 | * Implemented parametric aliases. This pretty much allows the |
|
4587 | * Implemented parametric aliases. This pretty much allows the | |
4575 | alias system to offer full-blown shell convenience, I think. |
|
4588 | alias system to offer full-blown shell convenience, I think. | |
4576 |
|
4589 | |||
4577 | * Version 0.1.17 released, 0.1.18 opened. |
|
4590 | * Version 0.1.17 released, 0.1.18 opened. | |
4578 |
|
4591 | |||
4579 | * dot_ipython/ipythonrc (alias): added documentation. |
|
4592 | * dot_ipython/ipythonrc (alias): added documentation. | |
4580 | (xcolor): Fixed small bug (xcolors -> xcolor) |
|
4593 | (xcolor): Fixed small bug (xcolors -> xcolor) | |
4581 |
|
4594 | |||
4582 | * Changed the alias system. Now alias is a magic command to define |
|
4595 | * Changed the alias system. Now alias is a magic command to define | |
4583 | aliases just like the shell. Rationale: the builtin magics should |
|
4596 | aliases just like the shell. Rationale: the builtin magics should | |
4584 | be there for things deeply connected to IPython's |
|
4597 | be there for things deeply connected to IPython's | |
4585 | architecture. And this is a much lighter system for what I think |
|
4598 | architecture. And this is a much lighter system for what I think | |
4586 | is the really important feature: allowing users to define quickly |
|
4599 | is the really important feature: allowing users to define quickly | |
4587 | magics that will do shell things for them, so they can customize |
|
4600 | magics that will do shell things for them, so they can customize | |
4588 | IPython easily to match their work habits. If someone is really |
|
4601 | IPython easily to match their work habits. If someone is really | |
4589 | desperate to have another name for a builtin alias, they can |
|
4602 | desperate to have another name for a builtin alias, they can | |
4590 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but |
|
4603 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but | |
4591 | works. |
|
4604 | works. | |
4592 |
|
4605 | |||
4593 | 2001-11-28 Fernando Perez <fperez@colorado.edu> |
|
4606 | 2001-11-28 Fernando Perez <fperez@colorado.edu> | |
4594 |
|
4607 | |||
4595 | * Changed @file so that it opens the source file at the proper |
|
4608 | * Changed @file so that it opens the source file at the proper | |
4596 | line. Since it uses less, if your EDITOR environment is |
|
4609 | line. Since it uses less, if your EDITOR environment is | |
4597 | configured, typing v will immediately open your editor of choice |
|
4610 | configured, typing v will immediately open your editor of choice | |
4598 | right at the line where the object is defined. Not as quick as |
|
4611 | right at the line where the object is defined. Not as quick as | |
4599 | having a direct @edit command, but for all intents and purposes it |
|
4612 | having a direct @edit command, but for all intents and purposes it | |
4600 | works. And I don't have to worry about writing @edit to deal with |
|
4613 | works. And I don't have to worry about writing @edit to deal with | |
4601 | all the editors, less does that. |
|
4614 | all the editors, less does that. | |
4602 |
|
4615 | |||
4603 | * Version 0.1.16 released, 0.1.17 opened. |
|
4616 | * Version 0.1.16 released, 0.1.17 opened. | |
4604 |
|
4617 | |||
4605 | * Fixed some nasty bugs in the page/page_dumb combo that could |
|
4618 | * Fixed some nasty bugs in the page/page_dumb combo that could | |
4606 | crash IPython. |
|
4619 | crash IPython. | |
4607 |
|
4620 | |||
4608 | 2001-11-27 Fernando Perez <fperez@colorado.edu> |
|
4621 | 2001-11-27 Fernando Perez <fperez@colorado.edu> | |
4609 |
|
4622 | |||
4610 | * Version 0.1.15 released, 0.1.16 opened. |
|
4623 | * Version 0.1.15 released, 0.1.16 opened. | |
4611 |
|
4624 | |||
4612 | * Finally got ? and ?? to work for undefined things: now it's |
|
4625 | * Finally got ? and ?? to work for undefined things: now it's | |
4613 | possible to type {}.get? and get information about the get method |
|
4626 | possible to type {}.get? and get information about the get method | |
4614 | of dicts, or os.path? even if only os is defined (so technically |
|
4627 | of dicts, or os.path? even if only os is defined (so technically | |
4615 | os.path isn't). Works at any level. For example, after import os, |
|
4628 | os.path isn't). Works at any level. For example, after import os, | |
4616 | os?, os.path?, os.path.abspath? all work. This is great, took some |
|
4629 | os?, os.path?, os.path.abspath? all work. This is great, took some | |
4617 | work in _ofind. |
|
4630 | work in _ofind. | |
4618 |
|
4631 | |||
4619 | * Fixed more bugs with logging. The sanest way to do it was to add |
|
4632 | * Fixed more bugs with logging. The sanest way to do it was to add | |
4620 | to @log a 'mode' parameter. Killed two in one shot (this mode |
|
4633 | to @log a 'mode' parameter. Killed two in one shot (this mode | |
4621 | option was a request of Janko's). I think it's finally clean |
|
4634 | option was a request of Janko's). I think it's finally clean | |
4622 | (famous last words). |
|
4635 | (famous last words). | |
4623 |
|
4636 | |||
4624 | * Added a page_dumb() pager which does a decent job of paging on |
|
4637 | * Added a page_dumb() pager which does a decent job of paging on | |
4625 | screen, if better things (like less) aren't available. One less |
|
4638 | screen, if better things (like less) aren't available. One less | |
4626 | unix dependency (someday maybe somebody will port this to |
|
4639 | unix dependency (someday maybe somebody will port this to | |
4627 | windows). |
|
4640 | windows). | |
4628 |
|
4641 | |||
4629 | * Fixed problem in magic_log: would lock of logging out if log |
|
4642 | * Fixed problem in magic_log: would lock of logging out if log | |
4630 | creation failed (because it would still think it had succeeded). |
|
4643 | creation failed (because it would still think it had succeeded). | |
4631 |
|
4644 | |||
4632 | * Improved the page() function using curses to auto-detect screen |
|
4645 | * Improved the page() function using curses to auto-detect screen | |
4633 | size. Now it can make a much better decision on whether to print |
|
4646 | size. Now it can make a much better decision on whether to print | |
4634 | or page a string. Option screen_length was modified: a value 0 |
|
4647 | or page a string. Option screen_length was modified: a value 0 | |
4635 | means auto-detect, and that's the default now. |
|
4648 | means auto-detect, and that's the default now. | |
4636 |
|
4649 | |||
4637 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to |
|
4650 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to | |
4638 | go out. I'll test it for a few days, then talk to Janko about |
|
4651 | go out. I'll test it for a few days, then talk to Janko about | |
4639 | licences and announce it. |
|
4652 | licences and announce it. | |
4640 |
|
4653 | |||
4641 | * Fixed the length of the auto-generated ---> prompt which appears |
|
4654 | * Fixed the length of the auto-generated ---> prompt which appears | |
4642 | for auto-parens and auto-quotes. Getting this right isn't trivial, |
|
4655 | for auto-parens and auto-quotes. Getting this right isn't trivial, | |
4643 | with all the color escapes, different prompt types and optional |
|
4656 | with all the color escapes, different prompt types and optional | |
4644 | separators. But it seems to be working in all the combinations. |
|
4657 | separators. But it seems to be working in all the combinations. | |
4645 |
|
4658 | |||
4646 | 2001-11-26 Fernando Perez <fperez@colorado.edu> |
|
4659 | 2001-11-26 Fernando Perez <fperez@colorado.edu> | |
4647 |
|
4660 | |||
4648 | * Wrote a regexp filter to get option types from the option names |
|
4661 | * Wrote a regexp filter to get option types from the option names | |
4649 | string. This eliminates the need to manually keep two duplicate |
|
4662 | string. This eliminates the need to manually keep two duplicate | |
4650 | lists. |
|
4663 | lists. | |
4651 |
|
4664 | |||
4652 | * Removed the unneeded check_option_names. Now options are handled |
|
4665 | * Removed the unneeded check_option_names. Now options are handled | |
4653 | in a much saner manner and it's easy to visually check that things |
|
4666 | in a much saner manner and it's easy to visually check that things | |
4654 | are ok. |
|
4667 | are ok. | |
4655 |
|
4668 | |||
4656 | * Updated version numbers on all files I modified to carry a |
|
4669 | * Updated version numbers on all files I modified to carry a | |
4657 | notice so Janko and Nathan have clear version markers. |
|
4670 | notice so Janko and Nathan have clear version markers. | |
4658 |
|
4671 | |||
4659 | * Updated docstring for ultraTB with my changes. I should send |
|
4672 | * Updated docstring for ultraTB with my changes. I should send | |
4660 | this to Nathan. |
|
4673 | this to Nathan. | |
4661 |
|
4674 | |||
4662 | * Lots of small fixes. Ran everything through pychecker again. |
|
4675 | * Lots of small fixes. Ran everything through pychecker again. | |
4663 |
|
4676 | |||
4664 | * Made loading of deep_reload an cmd line option. If it's not too |
|
4677 | * Made loading of deep_reload an cmd line option. If it's not too | |
4665 | kosher, now people can just disable it. With -nodeep_reload it's |
|
4678 | kosher, now people can just disable it. With -nodeep_reload it's | |
4666 | still available as dreload(), it just won't overwrite reload(). |
|
4679 | still available as dreload(), it just won't overwrite reload(). | |
4667 |
|
4680 | |||
4668 | * Moved many options to the no| form (-opt and -noopt |
|
4681 | * Moved many options to the no| form (-opt and -noopt | |
4669 | accepted). Cleaner. |
|
4682 | accepted). Cleaner. | |
4670 |
|
4683 | |||
4671 | * Changed magic_log so that if called with no parameters, it uses |
|
4684 | * Changed magic_log so that if called with no parameters, it uses | |
4672 | 'rotate' mode. That way auto-generated logs aren't automatically |
|
4685 | 'rotate' mode. That way auto-generated logs aren't automatically | |
4673 | over-written. For normal logs, now a backup is made if it exists |
|
4686 | over-written. For normal logs, now a backup is made if it exists | |
4674 | (only 1 level of backups). A new 'backup' mode was added to the |
|
4687 | (only 1 level of backups). A new 'backup' mode was added to the | |
4675 | Logger class to support this. This was a request by Janko. |
|
4688 | Logger class to support this. This was a request by Janko. | |
4676 |
|
4689 | |||
4677 | * Added @logoff/@logon to stop/restart an active log. |
|
4690 | * Added @logoff/@logon to stop/restart an active log. | |
4678 |
|
4691 | |||
4679 | * Fixed a lot of bugs in log saving/replay. It was pretty |
|
4692 | * Fixed a lot of bugs in log saving/replay. It was pretty | |
4680 | broken. Now special lines (!@,/) appear properly in the command |
|
4693 | broken. Now special lines (!@,/) appear properly in the command | |
4681 | history after a log replay. |
|
4694 | history after a log replay. | |
4682 |
|
4695 | |||
4683 | * Tried and failed to implement full session saving via pickle. My |
|
4696 | * Tried and failed to implement full session saving via pickle. My | |
4684 | idea was to pickle __main__.__dict__, but modules can't be |
|
4697 | idea was to pickle __main__.__dict__, but modules can't be | |
4685 | pickled. This would be a better alternative to replaying logs, but |
|
4698 | pickled. This would be a better alternative to replaying logs, but | |
4686 | seems quite tricky to get to work. Changed -session to be called |
|
4699 | seems quite tricky to get to work. Changed -session to be called | |
4687 | -logplay, which more accurately reflects what it does. And if we |
|
4700 | -logplay, which more accurately reflects what it does. And if we | |
4688 | ever get real session saving working, -session is now available. |
|
4701 | ever get real session saving working, -session is now available. | |
4689 |
|
4702 | |||
4690 | * Implemented color schemes for prompts also. As for tracebacks, |
|
4703 | * Implemented color schemes for prompts also. As for tracebacks, | |
4691 | currently only NoColor and Linux are supported. But now the |
|
4704 | currently only NoColor and Linux are supported. But now the | |
4692 | infrastructure is in place, based on a generic ColorScheme |
|
4705 | infrastructure is in place, based on a generic ColorScheme | |
4693 | class. So writing and activating new schemes both for the prompts |
|
4706 | class. So writing and activating new schemes both for the prompts | |
4694 | and the tracebacks should be straightforward. |
|
4707 | and the tracebacks should be straightforward. | |
4695 |
|
4708 | |||
4696 | * Version 0.1.13 released, 0.1.14 opened. |
|
4709 | * Version 0.1.13 released, 0.1.14 opened. | |
4697 |
|
4710 | |||
4698 | * Changed handling of options for output cache. Now counter is |
|
4711 | * Changed handling of options for output cache. Now counter is | |
4699 | hardwired starting at 1 and one specifies the maximum number of |
|
4712 | hardwired starting at 1 and one specifies the maximum number of | |
4700 | entries *in the outcache* (not the max prompt counter). This is |
|
4713 | entries *in the outcache* (not the max prompt counter). This is | |
4701 | much better, since many statements won't increase the cache |
|
4714 | much better, since many statements won't increase the cache | |
4702 | count. It also eliminated some confusing options, now there's only |
|
4715 | count. It also eliminated some confusing options, now there's only | |
4703 | one: cache_size. |
|
4716 | one: cache_size. | |
4704 |
|
4717 | |||
4705 | * Added 'alias' magic function and magic_alias option in the |
|
4718 | * Added 'alias' magic function and magic_alias option in the | |
4706 | ipythonrc file. Now the user can easily define whatever names he |
|
4719 | ipythonrc file. Now the user can easily define whatever names he | |
4707 | wants for the magic functions without having to play weird |
|
4720 | wants for the magic functions without having to play weird | |
4708 | namespace games. This gives IPython a real shell-like feel. |
|
4721 | namespace games. This gives IPython a real shell-like feel. | |
4709 |
|
4722 | |||
4710 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit |
|
4723 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit | |
4711 | @ or not). |
|
4724 | @ or not). | |
4712 |
|
4725 | |||
4713 | This was one of the last remaining 'visible' bugs (that I know |
|
4726 | This was one of the last remaining 'visible' bugs (that I know | |
4714 | of). I think if I can clean up the session loading so it works |
|
4727 | of). I think if I can clean up the session loading so it works | |
4715 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first |
|
4728 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first | |
4716 | about licensing). |
|
4729 | about licensing). | |
4717 |
|
4730 | |||
4718 | 2001-11-25 Fernando Perez <fperez@colorado.edu> |
|
4731 | 2001-11-25 Fernando Perez <fperez@colorado.edu> | |
4719 |
|
4732 | |||
4720 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and |
|
4733 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and | |
4721 | there's a cleaner distinction between what ? and ?? show. |
|
4734 | there's a cleaner distinction between what ? and ?? show. | |
4722 |
|
4735 | |||
4723 | * Added screen_length option. Now the user can define his own |
|
4736 | * Added screen_length option. Now the user can define his own | |
4724 | screen size for page() operations. |
|
4737 | screen size for page() operations. | |
4725 |
|
4738 | |||
4726 | * Implemented magic shell-like functions with automatic code |
|
4739 | * Implemented magic shell-like functions with automatic code | |
4727 | generation. Now adding another function is just a matter of adding |
|
4740 | generation. Now adding another function is just a matter of adding | |
4728 | an entry to a dict, and the function is dynamically generated at |
|
4741 | an entry to a dict, and the function is dynamically generated at | |
4729 | run-time. Python has some really cool features! |
|
4742 | run-time. Python has some really cool features! | |
4730 |
|
4743 | |||
4731 | * Renamed many options to cleanup conventions a little. Now all |
|
4744 | * Renamed many options to cleanup conventions a little. Now all | |
4732 | are lowercase, and only underscores where needed. Also in the code |
|
4745 | are lowercase, and only underscores where needed. Also in the code | |
4733 | option name tables are clearer. |
|
4746 | option name tables are clearer. | |
4734 |
|
4747 | |||
4735 | * Changed prompts a little. Now input is 'In [n]:' instead of |
|
4748 | * Changed prompts a little. Now input is 'In [n]:' instead of | |
4736 | 'In[n]:='. This allows it the numbers to be aligned with the |
|
4749 | 'In[n]:='. This allows it the numbers to be aligned with the | |
4737 | Out[n] numbers, and removes usage of ':=' which doesn't exist in |
|
4750 | Out[n] numbers, and removes usage of ':=' which doesn't exist in | |
4738 | Python (it was a Mathematica thing). The '...' continuation prompt |
|
4751 | Python (it was a Mathematica thing). The '...' continuation prompt | |
4739 | was also changed a little to align better. |
|
4752 | was also changed a little to align better. | |
4740 |
|
4753 | |||
4741 | * Fixed bug when flushing output cache. Not all _p<n> variables |
|
4754 | * Fixed bug when flushing output cache. Not all _p<n> variables | |
4742 | exist, so their deletion needs to be wrapped in a try: |
|
4755 | exist, so their deletion needs to be wrapped in a try: | |
4743 |
|
4756 | |||
4744 | * Figured out how to properly use inspect.formatargspec() (it |
|
4757 | * Figured out how to properly use inspect.formatargspec() (it | |
4745 | requires the args preceded by *). So I removed all the code from |
|
4758 | requires the args preceded by *). So I removed all the code from | |
4746 | _get_pdef in Magic, which was just replicating that. |
|
4759 | _get_pdef in Magic, which was just replicating that. | |
4747 |
|
4760 | |||
4748 | * Added test to prefilter to allow redefining magic function names |
|
4761 | * Added test to prefilter to allow redefining magic function names | |
4749 | as variables. This is ok, since the @ form is always available, |
|
4762 | as variables. This is ok, since the @ form is always available, | |
4750 | but whe should allow the user to define a variable called 'ls' if |
|
4763 | but whe should allow the user to define a variable called 'ls' if | |
4751 | he needs it. |
|
4764 | he needs it. | |
4752 |
|
4765 | |||
4753 | * Moved the ToDo information from README into a separate ToDo. |
|
4766 | * Moved the ToDo information from README into a separate ToDo. | |
4754 |
|
4767 | |||
4755 | * General code cleanup and small bugfixes. I think it's close to a |
|
4768 | * General code cleanup and small bugfixes. I think it's close to a | |
4756 | state where it can be released, obviously with a big 'beta' |
|
4769 | state where it can be released, obviously with a big 'beta' | |
4757 | warning on it. |
|
4770 | warning on it. | |
4758 |
|
4771 | |||
4759 | * Got the magic function split to work. Now all magics are defined |
|
4772 | * Got the magic function split to work. Now all magics are defined | |
4760 | in a separate class. It just organizes things a bit, and now |
|
4773 | in a separate class. It just organizes things a bit, and now | |
4761 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it |
|
4774 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it | |
4762 | was too long). |
|
4775 | was too long). | |
4763 |
|
4776 | |||
4764 | * Changed @clear to @reset to avoid potential confusions with |
|
4777 | * Changed @clear to @reset to avoid potential confusions with | |
4765 | the shell command clear. Also renamed @cl to @clear, which does |
|
4778 | the shell command clear. Also renamed @cl to @clear, which does | |
4766 | exactly what people expect it to from their shell experience. |
|
4779 | exactly what people expect it to from their shell experience. | |
4767 |
|
4780 | |||
4768 | Added a check to the @reset command (since it's so |
|
4781 | Added a check to the @reset command (since it's so | |
4769 | destructive, it's probably a good idea to ask for confirmation). |
|
4782 | destructive, it's probably a good idea to ask for confirmation). | |
4770 | But now reset only works for full namespace resetting. Since the |
|
4783 | But now reset only works for full namespace resetting. Since the | |
4771 | del keyword is already there for deleting a few specific |
|
4784 | del keyword is already there for deleting a few specific | |
4772 | variables, I don't see the point of having a redundant magic |
|
4785 | variables, I don't see the point of having a redundant magic | |
4773 | function for the same task. |
|
4786 | function for the same task. | |
4774 |
|
4787 | |||
4775 | 2001-11-24 Fernando Perez <fperez@colorado.edu> |
|
4788 | 2001-11-24 Fernando Perez <fperez@colorado.edu> | |
4776 |
|
4789 | |||
4777 | * Updated the builtin docs (esp. the ? ones). |
|
4790 | * Updated the builtin docs (esp. the ? ones). | |
4778 |
|
4791 | |||
4779 | * Ran all the code through pychecker. Not terribly impressed with |
|
4792 | * Ran all the code through pychecker. Not terribly impressed with | |
4780 | it: lots of spurious warnings and didn't really find anything of |
|
4793 | it: lots of spurious warnings and didn't really find anything of | |
4781 | substance (just a few modules being imported and not used). |
|
4794 | substance (just a few modules being imported and not used). | |
4782 |
|
4795 | |||
4783 | * Implemented the new ultraTB functionality into IPython. New |
|
4796 | * Implemented the new ultraTB functionality into IPython. New | |
4784 | option: xcolors. This chooses color scheme. xmode now only selects |
|
4797 | option: xcolors. This chooses color scheme. xmode now only selects | |
4785 | between Plain and Verbose. Better orthogonality. |
|
4798 | between Plain and Verbose. Better orthogonality. | |
4786 |
|
4799 | |||
4787 | * Large rewrite of ultraTB. Much cleaner now, with a separation of |
|
4800 | * Large rewrite of ultraTB. Much cleaner now, with a separation of | |
4788 | mode and color scheme for the exception handlers. Now it's |
|
4801 | mode and color scheme for the exception handlers. Now it's | |
4789 | possible to have the verbose traceback with no coloring. |
|
4802 | possible to have the verbose traceback with no coloring. | |
4790 |
|
4803 | |||
4791 | 2001-11-23 Fernando Perez <fperez@colorado.edu> |
|
4804 | 2001-11-23 Fernando Perez <fperez@colorado.edu> | |
4792 |
|
4805 | |||
4793 | * Version 0.1.12 released, 0.1.13 opened. |
|
4806 | * Version 0.1.12 released, 0.1.13 opened. | |
4794 |
|
4807 | |||
4795 | * Removed option to set auto-quote and auto-paren escapes by |
|
4808 | * Removed option to set auto-quote and auto-paren escapes by | |
4796 | user. The chances of breaking valid syntax are just too high. If |
|
4809 | user. The chances of breaking valid syntax are just too high. If | |
4797 | someone *really* wants, they can always dig into the code. |
|
4810 | someone *really* wants, they can always dig into the code. | |
4798 |
|
4811 | |||
4799 | * Made prompt separators configurable. |
|
4812 | * Made prompt separators configurable. | |
4800 |
|
4813 | |||
4801 | 2001-11-22 Fernando Perez <fperez@colorado.edu> |
|
4814 | 2001-11-22 Fernando Perez <fperez@colorado.edu> | |
4802 |
|
4815 | |||
4803 | * Small bugfixes in many places. |
|
4816 | * Small bugfixes in many places. | |
4804 |
|
4817 | |||
4805 | * Removed the MyCompleter class from ipplib. It seemed redundant |
|
4818 | * Removed the MyCompleter class from ipplib. It seemed redundant | |
4806 | with the C-p,C-n history search functionality. Less code to |
|
4819 | with the C-p,C-n history search functionality. Less code to | |
4807 | maintain. |
|
4820 | maintain. | |
4808 |
|
4821 | |||
4809 | * Moved all the original ipython.py code into ipythonlib.py. Right |
|
4822 | * Moved all the original ipython.py code into ipythonlib.py. Right | |
4810 | now it's just one big dump into a function called make_IPython, so |
|
4823 | now it's just one big dump into a function called make_IPython, so | |
4811 | no real modularity has been gained. But at least it makes the |
|
4824 | no real modularity has been gained. But at least it makes the | |
4812 | wrapper script tiny, and since ipythonlib is a module, it gets |
|
4825 | wrapper script tiny, and since ipythonlib is a module, it gets | |
4813 | compiled and startup is much faster. |
|
4826 | compiled and startup is much faster. | |
4814 |
|
4827 | |||
4815 | This is a reasobably 'deep' change, so we should test it for a |
|
4828 | This is a reasobably 'deep' change, so we should test it for a | |
4816 | while without messing too much more with the code. |
|
4829 | while without messing too much more with the code. | |
4817 |
|
4830 | |||
4818 | 2001-11-21 Fernando Perez <fperez@colorado.edu> |
|
4831 | 2001-11-21 Fernando Perez <fperez@colorado.edu> | |
4819 |
|
4832 | |||
4820 | * Version 0.1.11 released, 0.1.12 opened for further work. |
|
4833 | * Version 0.1.11 released, 0.1.12 opened for further work. | |
4821 |
|
4834 | |||
4822 | * Removed dependency on Itpl. It was only needed in one place. It |
|
4835 | * Removed dependency on Itpl. It was only needed in one place. It | |
4823 | would be nice if this became part of python, though. It makes life |
|
4836 | would be nice if this became part of python, though. It makes life | |
4824 | *a lot* easier in some cases. |
|
4837 | *a lot* easier in some cases. | |
4825 |
|
4838 | |||
4826 | * Simplified the prefilter code a bit. Now all handlers are |
|
4839 | * Simplified the prefilter code a bit. Now all handlers are | |
4827 | expected to explicitly return a value (at least a blank string). |
|
4840 | expected to explicitly return a value (at least a blank string). | |
4828 |
|
4841 | |||
4829 | * Heavy edits in ipplib. Removed the help system altogether. Now |
|
4842 | * Heavy edits in ipplib. Removed the help system altogether. Now | |
4830 | obj?/?? is used for inspecting objects, a magic @doc prints |
|
4843 | obj?/?? is used for inspecting objects, a magic @doc prints | |
4831 | docstrings, and full-blown Python help is accessed via the 'help' |
|
4844 | docstrings, and full-blown Python help is accessed via the 'help' | |
4832 | keyword. This cleans up a lot of code (less to maintain) and does |
|
4845 | keyword. This cleans up a lot of code (less to maintain) and does | |
4833 | the job. Since 'help' is now a standard Python component, might as |
|
4846 | the job. Since 'help' is now a standard Python component, might as | |
4834 | well use it and remove duplicate functionality. |
|
4847 | well use it and remove duplicate functionality. | |
4835 |
|
4848 | |||
4836 | Also removed the option to use ipplib as a standalone program. By |
|
4849 | Also removed the option to use ipplib as a standalone program. By | |
4837 | now it's too dependent on other parts of IPython to function alone. |
|
4850 | now it's too dependent on other parts of IPython to function alone. | |
4838 |
|
4851 | |||
4839 | * Fixed bug in genutils.pager. It would crash if the pager was |
|
4852 | * Fixed bug in genutils.pager. It would crash if the pager was | |
4840 | exited immediately after opening (broken pipe). |
|
4853 | exited immediately after opening (broken pipe). | |
4841 |
|
4854 | |||
4842 | * Trimmed down the VerboseTB reporting a little. The header is |
|
4855 | * Trimmed down the VerboseTB reporting a little. The header is | |
4843 | much shorter now and the repeated exception arguments at the end |
|
4856 | much shorter now and the repeated exception arguments at the end | |
4844 | have been removed. For interactive use the old header seemed a bit |
|
4857 | have been removed. For interactive use the old header seemed a bit | |
4845 | excessive. |
|
4858 | excessive. | |
4846 |
|
4859 | |||
4847 | * Fixed small bug in output of @whos for variables with multi-word |
|
4860 | * Fixed small bug in output of @whos for variables with multi-word | |
4848 | types (only first word was displayed). |
|
4861 | types (only first word was displayed). | |
4849 |
|
4862 | |||
4850 | 2001-11-17 Fernando Perez <fperez@colorado.edu> |
|
4863 | 2001-11-17 Fernando Perez <fperez@colorado.edu> | |
4851 |
|
4864 | |||
4852 | * Version 0.1.10 released, 0.1.11 opened for further work. |
|
4865 | * Version 0.1.10 released, 0.1.11 opened for further work. | |
4853 |
|
4866 | |||
4854 | * Modified dirs and friends. dirs now *returns* the stack (not |
|
4867 | * Modified dirs and friends. dirs now *returns* the stack (not | |
4855 | prints), so one can manipulate it as a variable. Convenient to |
|
4868 | prints), so one can manipulate it as a variable. Convenient to | |
4856 | travel along many directories. |
|
4869 | travel along many directories. | |
4857 |
|
4870 | |||
4858 | * Fixed bug in magic_pdef: would only work with functions with |
|
4871 | * Fixed bug in magic_pdef: would only work with functions with | |
4859 | arguments with default values. |
|
4872 | arguments with default values. | |
4860 |
|
4873 | |||
4861 | 2001-11-14 Fernando Perez <fperez@colorado.edu> |
|
4874 | 2001-11-14 Fernando Perez <fperez@colorado.edu> | |
4862 |
|
4875 | |||
4863 | * Added the PhysicsInput stuff to dot_ipython so it ships as an |
|
4876 | * Added the PhysicsInput stuff to dot_ipython so it ships as an | |
4864 | example with IPython. Various other minor fixes and cleanups. |
|
4877 | example with IPython. Various other minor fixes and cleanups. | |
4865 |
|
4878 | |||
4866 | * Version 0.1.9 released, 0.1.10 opened for further work. |
|
4879 | * Version 0.1.9 released, 0.1.10 opened for further work. | |
4867 |
|
4880 | |||
4868 | * Added sys.path to the list of directories searched in the |
|
4881 | * Added sys.path to the list of directories searched in the | |
4869 | execfile= option. It used to be the current directory and the |
|
4882 | execfile= option. It used to be the current directory and the | |
4870 | user's IPYTHONDIR only. |
|
4883 | user's IPYTHONDIR only. | |
4871 |
|
4884 | |||
4872 | 2001-11-13 Fernando Perez <fperez@colorado.edu> |
|
4885 | 2001-11-13 Fernando Perez <fperez@colorado.edu> | |
4873 |
|
4886 | |||
4874 | * Reinstated the raw_input/prefilter separation that Janko had |
|
4887 | * Reinstated the raw_input/prefilter separation that Janko had | |
4875 | initially. This gives a more convenient setup for extending the |
|
4888 | initially. This gives a more convenient setup for extending the | |
4876 | pre-processor from the outside: raw_input always gets a string, |
|
4889 | pre-processor from the outside: raw_input always gets a string, | |
4877 | and prefilter has to process it. We can then redefine prefilter |
|
4890 | and prefilter has to process it. We can then redefine prefilter | |
4878 | from the outside and implement extensions for special |
|
4891 | from the outside and implement extensions for special | |
4879 | purposes. |
|
4892 | purposes. | |
4880 |
|
4893 | |||
4881 | Today I got one for inputting PhysicalQuantity objects |
|
4894 | Today I got one for inputting PhysicalQuantity objects | |
4882 | (from Scientific) without needing any function calls at |
|
4895 | (from Scientific) without needing any function calls at | |
4883 | all. Extremely convenient, and it's all done as a user-level |
|
4896 | all. Extremely convenient, and it's all done as a user-level | |
4884 | extension (no IPython code was touched). Now instead of: |
|
4897 | extension (no IPython code was touched). Now instead of: | |
4885 | a = PhysicalQuantity(4.2,'m/s**2') |
|
4898 | a = PhysicalQuantity(4.2,'m/s**2') | |
4886 | one can simply say |
|
4899 | one can simply say | |
4887 | a = 4.2 m/s**2 |
|
4900 | a = 4.2 m/s**2 | |
4888 | or even |
|
4901 | or even | |
4889 | a = 4.2 m/s^2 |
|
4902 | a = 4.2 m/s^2 | |
4890 |
|
4903 | |||
4891 | I use this, but it's also a proof of concept: IPython really is |
|
4904 | I use this, but it's also a proof of concept: IPython really is | |
4892 | fully user-extensible, even at the level of the parsing of the |
|
4905 | fully user-extensible, even at the level of the parsing of the | |
4893 | command line. It's not trivial, but it's perfectly doable. |
|
4906 | command line. It's not trivial, but it's perfectly doable. | |
4894 |
|
4907 | |||
4895 | * Added 'add_flip' method to inclusion conflict resolver. Fixes |
|
4908 | * Added 'add_flip' method to inclusion conflict resolver. Fixes | |
4896 | the problem of modules being loaded in the inverse order in which |
|
4909 | the problem of modules being loaded in the inverse order in which | |
4897 | they were defined in |
|
4910 | they were defined in | |
4898 |
|
4911 | |||
4899 | * Version 0.1.8 released, 0.1.9 opened for further work. |
|
4912 | * Version 0.1.8 released, 0.1.9 opened for further work. | |
4900 |
|
4913 | |||
4901 | * Added magics pdef, source and file. They respectively show the |
|
4914 | * Added magics pdef, source and file. They respectively show the | |
4902 | definition line ('prototype' in C), source code and full python |
|
4915 | definition line ('prototype' in C), source code and full python | |
4903 | file for any callable object. The object inspector oinfo uses |
|
4916 | file for any callable object. The object inspector oinfo uses | |
4904 | these to show the same information. |
|
4917 | these to show the same information. | |
4905 |
|
4918 | |||
4906 | * Version 0.1.7 released, 0.1.8 opened for further work. |
|
4919 | * Version 0.1.7 released, 0.1.8 opened for further work. | |
4907 |
|
4920 | |||
4908 | * Separated all the magic functions into a class called Magic. The |
|
4921 | * Separated all the magic functions into a class called Magic. The | |
4909 | InteractiveShell class was becoming too big for Xemacs to handle |
|
4922 | InteractiveShell class was becoming too big for Xemacs to handle | |
4910 | (de-indenting a line would lock it up for 10 seconds while it |
|
4923 | (de-indenting a line would lock it up for 10 seconds while it | |
4911 | backtracked on the whole class!) |
|
4924 | backtracked on the whole class!) | |
4912 |
|
4925 | |||
4913 | FIXME: didn't work. It can be done, but right now namespaces are |
|
4926 | FIXME: didn't work. It can be done, but right now namespaces are | |
4914 | all messed up. Do it later (reverted it for now, so at least |
|
4927 | all messed up. Do it later (reverted it for now, so at least | |
4915 | everything works as before). |
|
4928 | everything works as before). | |
4916 |
|
4929 | |||
4917 | * Got the object introspection system (magic_oinfo) working! I |
|
4930 | * Got the object introspection system (magic_oinfo) working! I | |
4918 | think this is pretty much ready for release to Janko, so he can |
|
4931 | think this is pretty much ready for release to Janko, so he can | |
4919 | test it for a while and then announce it. Pretty much 100% of what |
|
4932 | test it for a while and then announce it. Pretty much 100% of what | |
4920 | I wanted for the 'phase 1' release is ready. Happy, tired. |
|
4933 | I wanted for the 'phase 1' release is ready. Happy, tired. | |
4921 |
|
4934 | |||
4922 | 2001-11-12 Fernando Perez <fperez@colorado.edu> |
|
4935 | 2001-11-12 Fernando Perez <fperez@colorado.edu> | |
4923 |
|
4936 | |||
4924 | * Version 0.1.6 released, 0.1.7 opened for further work. |
|
4937 | * Version 0.1.6 released, 0.1.7 opened for further work. | |
4925 |
|
4938 | |||
4926 | * Fixed bug in printing: it used to test for truth before |
|
4939 | * Fixed bug in printing: it used to test for truth before | |
4927 | printing, so 0 wouldn't print. Now checks for None. |
|
4940 | printing, so 0 wouldn't print. Now checks for None. | |
4928 |
|
4941 | |||
4929 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c |
|
4942 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c | |
4930 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it |
|
4943 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it | |
4931 | reaches by hand into the outputcache. Think of a better way to do |
|
4944 | reaches by hand into the outputcache. Think of a better way to do | |
4932 | this later. |
|
4945 | this later. | |
4933 |
|
4946 | |||
4934 | * Various small fixes thanks to Nathan's comments. |
|
4947 | * Various small fixes thanks to Nathan's comments. | |
4935 |
|
4948 | |||
4936 | * Changed magic_pprint to magic_Pprint. This way it doesn't |
|
4949 | * Changed magic_pprint to magic_Pprint. This way it doesn't | |
4937 | collide with pprint() and the name is consistent with the command |
|
4950 | collide with pprint() and the name is consistent with the command | |
4938 | line option. |
|
4951 | line option. | |
4939 |
|
4952 | |||
4940 | * Changed prompt counter behavior to be fully like |
|
4953 | * Changed prompt counter behavior to be fully like | |
4941 | Mathematica's. That is, even input that doesn't return a result |
|
4954 | Mathematica's. That is, even input that doesn't return a result | |
4942 | raises the prompt counter. The old behavior was kind of confusing |
|
4955 | raises the prompt counter. The old behavior was kind of confusing | |
4943 | (getting the same prompt number several times if the operation |
|
4956 | (getting the same prompt number several times if the operation | |
4944 | didn't return a result). |
|
4957 | didn't return a result). | |
4945 |
|
4958 | |||
4946 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). |
|
4959 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). | |
4947 |
|
4960 | |||
4948 | * Fixed -Classic mode (wasn't working anymore). |
|
4961 | * Fixed -Classic mode (wasn't working anymore). | |
4949 |
|
4962 | |||
4950 | * Added colored prompts using Nathan's new code. Colors are |
|
4963 | * Added colored prompts using Nathan's new code. Colors are | |
4951 | currently hardwired, they can be user-configurable. For |
|
4964 | currently hardwired, they can be user-configurable. For | |
4952 | developers, they can be chosen in file ipythonlib.py, at the |
|
4965 | developers, they can be chosen in file ipythonlib.py, at the | |
4953 | beginning of the CachedOutput class def. |
|
4966 | beginning of the CachedOutput class def. | |
4954 |
|
4967 | |||
4955 | 2001-11-11 Fernando Perez <fperez@colorado.edu> |
|
4968 | 2001-11-11 Fernando Perez <fperez@colorado.edu> | |
4956 |
|
4969 | |||
4957 | * Version 0.1.5 released, 0.1.6 opened for further work. |
|
4970 | * Version 0.1.5 released, 0.1.6 opened for further work. | |
4958 |
|
4971 | |||
4959 | * Changed magic_env to *return* the environment as a dict (not to |
|
4972 | * Changed magic_env to *return* the environment as a dict (not to | |
4960 | print it). This way it prints, but it can also be processed. |
|
4973 | print it). This way it prints, but it can also be processed. | |
4961 |
|
4974 | |||
4962 | * Added Verbose exception reporting to interactive |
|
4975 | * Added Verbose exception reporting to interactive | |
4963 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose |
|
4976 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose | |
4964 | traceback. Had to make some changes to the ultraTB file. This is |
|
4977 | traceback. Had to make some changes to the ultraTB file. This is | |
4965 | probably the last 'big' thing in my mental todo list. This ties |
|
4978 | probably the last 'big' thing in my mental todo list. This ties | |
4966 | in with the next entry: |
|
4979 | in with the next entry: | |
4967 |
|
4980 | |||
4968 | * Changed -Xi and -Xf to a single -xmode option. Now all the user |
|
4981 | * Changed -Xi and -Xf to a single -xmode option. Now all the user | |
4969 | has to specify is Plain, Color or Verbose for all exception |
|
4982 | has to specify is Plain, Color or Verbose for all exception | |
4970 | handling. |
|
4983 | handling. | |
4971 |
|
4984 | |||
4972 | * Removed ShellServices option. All this can really be done via |
|
4985 | * Removed ShellServices option. All this can really be done via | |
4973 | the magic system. It's easier to extend, cleaner and has automatic |
|
4986 | the magic system. It's easier to extend, cleaner and has automatic | |
4974 | namespace protection and documentation. |
|
4987 | namespace protection and documentation. | |
4975 |
|
4988 | |||
4976 | 2001-11-09 Fernando Perez <fperez@colorado.edu> |
|
4989 | 2001-11-09 Fernando Perez <fperez@colorado.edu> | |
4977 |
|
4990 | |||
4978 | * Fixed bug in output cache flushing (missing parameter to |
|
4991 | * Fixed bug in output cache flushing (missing parameter to | |
4979 | __init__). Other small bugs fixed (found using pychecker). |
|
4992 | __init__). Other small bugs fixed (found using pychecker). | |
4980 |
|
4993 | |||
4981 | * Version 0.1.4 opened for bugfixing. |
|
4994 | * Version 0.1.4 opened for bugfixing. | |
4982 |
|
4995 | |||
4983 | 2001-11-07 Fernando Perez <fperez@colorado.edu> |
|
4996 | 2001-11-07 Fernando Perez <fperez@colorado.edu> | |
4984 |
|
4997 | |||
4985 | * Version 0.1.3 released, mainly because of the raw_input bug. |
|
4998 | * Version 0.1.3 released, mainly because of the raw_input bug. | |
4986 |
|
4999 | |||
4987 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed |
|
5000 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed | |
4988 | and when testing for whether things were callable, a call could |
|
5001 | and when testing for whether things were callable, a call could | |
4989 | actually be made to certain functions. They would get called again |
|
5002 | actually be made to certain functions. They would get called again | |
4990 | once 'really' executed, with a resulting double call. A disaster |
|
5003 | once 'really' executed, with a resulting double call. A disaster | |
4991 | in many cases (list.reverse() would never work!). |
|
5004 | in many cases (list.reverse() would never work!). | |
4992 |
|
5005 | |||
4993 | * Removed prefilter() function, moved its code to raw_input (which |
|
5006 | * Removed prefilter() function, moved its code to raw_input (which | |
4994 | after all was just a near-empty caller for prefilter). This saves |
|
5007 | after all was just a near-empty caller for prefilter). This saves | |
4995 | a function call on every prompt, and simplifies the class a tiny bit. |
|
5008 | a function call on every prompt, and simplifies the class a tiny bit. | |
4996 |
|
5009 | |||
4997 | * Fix _ip to __ip name in magic example file. |
|
5010 | * Fix _ip to __ip name in magic example file. | |
4998 |
|
5011 | |||
4999 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should |
|
5012 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should | |
5000 | work with non-gnu versions of tar. |
|
5013 | work with non-gnu versions of tar. | |
5001 |
|
5014 | |||
5002 | 2001-11-06 Fernando Perez <fperez@colorado.edu> |
|
5015 | 2001-11-06 Fernando Perez <fperez@colorado.edu> | |
5003 |
|
5016 | |||
5004 | * Version 0.1.2. Just to keep track of the recent changes. |
|
5017 | * Version 0.1.2. Just to keep track of the recent changes. | |
5005 |
|
5018 | |||
5006 | * Fixed nasty bug in output prompt routine. It used to check 'if |
|
5019 | * Fixed nasty bug in output prompt routine. It used to check 'if | |
5007 | arg != None...'. Problem is, this fails if arg implements a |
|
5020 | arg != None...'. Problem is, this fails if arg implements a | |
5008 | special comparison (__cmp__) which disallows comparing to |
|
5021 | special comparison (__cmp__) which disallows comparing to | |
5009 | None. Found it when trying to use the PhysicalQuantity module from |
|
5022 | None. Found it when trying to use the PhysicalQuantity module from | |
5010 | ScientificPython. |
|
5023 | ScientificPython. | |
5011 |
|
5024 | |||
5012 | 2001-11-05 Fernando Perez <fperez@colorado.edu> |
|
5025 | 2001-11-05 Fernando Perez <fperez@colorado.edu> | |
5013 |
|
5026 | |||
5014 | * Also added dirs. Now the pushd/popd/dirs family functions |
|
5027 | * Also added dirs. Now the pushd/popd/dirs family functions | |
5015 | basically like the shell, with the added convenience of going home |
|
5028 | basically like the shell, with the added convenience of going home | |
5016 | when called with no args. |
|
5029 | when called with no args. | |
5017 |
|
5030 | |||
5018 | * pushd/popd slightly modified to mimic shell behavior more |
|
5031 | * pushd/popd slightly modified to mimic shell behavior more | |
5019 | closely. |
|
5032 | closely. | |
5020 |
|
5033 | |||
5021 | * Added env,pushd,popd from ShellServices as magic functions. I |
|
5034 | * Added env,pushd,popd from ShellServices as magic functions. I | |
5022 | think the cleanest will be to port all desired functions from |
|
5035 | think the cleanest will be to port all desired functions from | |
5023 | ShellServices as magics and remove ShellServices altogether. This |
|
5036 | ShellServices as magics and remove ShellServices altogether. This | |
5024 | will provide a single, clean way of adding functionality |
|
5037 | will provide a single, clean way of adding functionality | |
5025 | (shell-type or otherwise) to IP. |
|
5038 | (shell-type or otherwise) to IP. | |
5026 |
|
5039 | |||
5027 | 2001-11-04 Fernando Perez <fperez@colorado.edu> |
|
5040 | 2001-11-04 Fernando Perez <fperez@colorado.edu> | |
5028 |
|
5041 | |||
5029 | * Added .ipython/ directory to sys.path. This way users can keep |
|
5042 | * Added .ipython/ directory to sys.path. This way users can keep | |
5030 | customizations there and access them via import. |
|
5043 | customizations there and access them via import. | |
5031 |
|
5044 | |||
5032 | 2001-11-03 Fernando Perez <fperez@colorado.edu> |
|
5045 | 2001-11-03 Fernando Perez <fperez@colorado.edu> | |
5033 |
|
5046 | |||
5034 | * Opened version 0.1.1 for new changes. |
|
5047 | * Opened version 0.1.1 for new changes. | |
5035 |
|
5048 | |||
5036 | * Changed version number to 0.1.0: first 'public' release, sent to |
|
5049 | * Changed version number to 0.1.0: first 'public' release, sent to | |
5037 | Nathan and Janko. |
|
5050 | Nathan and Janko. | |
5038 |
|
5051 | |||
5039 | * Lots of small fixes and tweaks. |
|
5052 | * Lots of small fixes and tweaks. | |
5040 |
|
5053 | |||
5041 | * Minor changes to whos format. Now strings are shown, snipped if |
|
5054 | * Minor changes to whos format. Now strings are shown, snipped if | |
5042 | too long. |
|
5055 | too long. | |
5043 |
|
5056 | |||
5044 | * Changed ShellServices to work on __main__ so they show up in @who |
|
5057 | * Changed ShellServices to work on __main__ so they show up in @who | |
5045 |
|
5058 | |||
5046 | * Help also works with ? at the end of a line: |
|
5059 | * Help also works with ? at the end of a line: | |
5047 | ?sin and sin? |
|
5060 | ?sin and sin? | |
5048 | both produce the same effect. This is nice, as often I use the |
|
5061 | both produce the same effect. This is nice, as often I use the | |
5049 | tab-complete to find the name of a method, but I used to then have |
|
5062 | tab-complete to find the name of a method, but I used to then have | |
5050 | to go to the beginning of the line to put a ? if I wanted more |
|
5063 | to go to the beginning of the line to put a ? if I wanted more | |
5051 | info. Now I can just add the ? and hit return. Convenient. |
|
5064 | info. Now I can just add the ? and hit return. Convenient. | |
5052 |
|
5065 | |||
5053 | 2001-11-02 Fernando Perez <fperez@colorado.edu> |
|
5066 | 2001-11-02 Fernando Perez <fperez@colorado.edu> | |
5054 |
|
5067 | |||
5055 | * Python version check (>=2.1) added. |
|
5068 | * Python version check (>=2.1) added. | |
5056 |
|
5069 | |||
5057 | * Added LazyPython documentation. At this point the docs are quite |
|
5070 | * Added LazyPython documentation. At this point the docs are quite | |
5058 | a mess. A cleanup is in order. |
|
5071 | a mess. A cleanup is in order. | |
5059 |
|
5072 | |||
5060 | * Auto-installer created. For some bizarre reason, the zipfiles |
|
5073 | * Auto-installer created. For some bizarre reason, the zipfiles | |
5061 | module isn't working on my system. So I made a tar version |
|
5074 | module isn't working on my system. So I made a tar version | |
5062 | (hopefully the command line options in various systems won't kill |
|
5075 | (hopefully the command line options in various systems won't kill | |
5063 | me). |
|
5076 | me). | |
5064 |
|
5077 | |||
5065 | * Fixes to Struct in genutils. Now all dictionary-like methods are |
|
5078 | * Fixes to Struct in genutils. Now all dictionary-like methods are | |
5066 | protected (reasonably). |
|
5079 | protected (reasonably). | |
5067 |
|
5080 | |||
5068 | * Added pager function to genutils and changed ? to print usage |
|
5081 | * Added pager function to genutils and changed ? to print usage | |
5069 | note through it (it was too long). |
|
5082 | note through it (it was too long). | |
5070 |
|
5083 | |||
5071 | * Added the LazyPython functionality. Works great! I changed the |
|
5084 | * Added the LazyPython functionality. Works great! I changed the | |
5072 | auto-quote escape to ';', it's on home row and next to '. But |
|
5085 | auto-quote escape to ';', it's on home row and next to '. But | |
5073 | both auto-quote and auto-paren (still /) escapes are command-line |
|
5086 | both auto-quote and auto-paren (still /) escapes are command-line | |
5074 | parameters. |
|
5087 | parameters. | |
5075 |
|
5088 | |||
5076 |
|
5089 | |||
5077 | 2001-11-01 Fernando Perez <fperez@colorado.edu> |
|
5090 | 2001-11-01 Fernando Perez <fperez@colorado.edu> | |
5078 |
|
5091 | |||
5079 | * Version changed to 0.0.7. Fairly large change: configuration now |
|
5092 | * Version changed to 0.0.7. Fairly large change: configuration now | |
5080 | is all stored in a directory, by default .ipython. There, all |
|
5093 | is all stored in a directory, by default .ipython. There, all | |
5081 | config files have normal looking names (not .names) |
|
5094 | config files have normal looking names (not .names) | |
5082 |
|
5095 | |||
5083 | * Version 0.0.6 Released first to Lucas and Archie as a test |
|
5096 | * Version 0.0.6 Released first to Lucas and Archie as a test | |
5084 | run. Since it's the first 'semi-public' release, change version to |
|
5097 | run. Since it's the first 'semi-public' release, change version to | |
5085 | > 0.0.6 for any changes now. |
|
5098 | > 0.0.6 for any changes now. | |
5086 |
|
5099 | |||
5087 | * Stuff I had put in the ipplib.py changelog: |
|
5100 | * Stuff I had put in the ipplib.py changelog: | |
5088 |
|
5101 | |||
5089 | Changes to InteractiveShell: |
|
5102 | Changes to InteractiveShell: | |
5090 |
|
5103 | |||
5091 | - Made the usage message a parameter. |
|
5104 | - Made the usage message a parameter. | |
5092 |
|
5105 | |||
5093 | - Require the name of the shell variable to be given. It's a bit |
|
5106 | - Require the name of the shell variable to be given. It's a bit | |
5094 | of a hack, but allows the name 'shell' not to be hardwire in the |
|
5107 | of a hack, but allows the name 'shell' not to be hardwire in the | |
5095 | magic (@) handler, which is problematic b/c it requires |
|
5108 | magic (@) handler, which is problematic b/c it requires | |
5096 | polluting the global namespace with 'shell'. This in turn is |
|
5109 | polluting the global namespace with 'shell'. This in turn is | |
5097 | fragile: if a user redefines a variable called shell, things |
|
5110 | fragile: if a user redefines a variable called shell, things | |
5098 | break. |
|
5111 | break. | |
5099 |
|
5112 | |||
5100 | - magic @: all functions available through @ need to be defined |
|
5113 | - magic @: all functions available through @ need to be defined | |
5101 | as magic_<name>, even though they can be called simply as |
|
5114 | as magic_<name>, even though they can be called simply as | |
5102 | @<name>. This allows the special command @magic to gather |
|
5115 | @<name>. This allows the special command @magic to gather | |
5103 | information automatically about all existing magic functions, |
|
5116 | information automatically about all existing magic functions, | |
5104 | even if they are run-time user extensions, by parsing the shell |
|
5117 | even if they are run-time user extensions, by parsing the shell | |
5105 | instance __dict__ looking for special magic_ names. |
|
5118 | instance __dict__ looking for special magic_ names. | |
5106 |
|
5119 | |||
5107 | - mainloop: added *two* local namespace parameters. This allows |
|
5120 | - mainloop: added *two* local namespace parameters. This allows | |
5108 | the class to differentiate between parameters which were there |
|
5121 | the class to differentiate between parameters which were there | |
5109 | before and after command line initialization was processed. This |
|
5122 | before and after command line initialization was processed. This | |
5110 | way, later @who can show things loaded at startup by the |
|
5123 | way, later @who can show things loaded at startup by the | |
5111 | user. This trick was necessary to make session saving/reloading |
|
5124 | user. This trick was necessary to make session saving/reloading | |
5112 | really work: ideally after saving/exiting/reloading a session, |
|
5125 | really work: ideally after saving/exiting/reloading a session, | |
5113 | *everythin* should look the same, including the output of @who. I |
|
5126 | *everythin* should look the same, including the output of @who. I | |
5114 | was only able to make this work with this double namespace |
|
5127 | was only able to make this work with this double namespace | |
5115 | trick. |
|
5128 | trick. | |
5116 |
|
5129 | |||
5117 | - added a header to the logfile which allows (almost) full |
|
5130 | - added a header to the logfile which allows (almost) full | |
5118 | session restoring. |
|
5131 | session restoring. | |
5119 |
|
5132 | |||
5120 | - prepend lines beginning with @ or !, with a and log |
|
5133 | - prepend lines beginning with @ or !, with a and log | |
5121 | them. Why? !lines: may be useful to know what you did @lines: |
|
5134 | them. Why? !lines: may be useful to know what you did @lines: | |
5122 | they may affect session state. So when restoring a session, at |
|
5135 | they may affect session state. So when restoring a session, at | |
5123 | least inform the user of their presence. I couldn't quite get |
|
5136 | least inform the user of their presence. I couldn't quite get | |
5124 | them to properly re-execute, but at least the user is warned. |
|
5137 | them to properly re-execute, but at least the user is warned. | |
5125 |
|
5138 | |||
5126 | * Started ChangeLog. |
|
5139 | * Started ChangeLog. |
General Comments 0
You need to be logged in to leave comments.
Login now