##// END OF EJS Templates
merge remote
Fernando Perez -
r1226:c5dce4c7 merge
parent child Browse files
Show More
@@ -8,6 +8,7 b' $Id: iplib.py 1107 2006-01-30 19:02:20Z vivainio $'
8 """
8 """
9
9
10 import IPython.ipapi
10 import IPython.ipapi
11 from IPython.ipapi import UsageError
11 ip = IPython.ipapi.get()
12 ip = IPython.ipapi.get()
12
13
13 import pickleshare
14 import pickleshare
@@ -96,12 +97,12 b" def magic_store(self, parameter_s=''):"
96 try:
97 try:
97 todel = args[0]
98 todel = args[0]
98 except IndexError:
99 except IndexError:
99 error('You must provide the variable to forget')
100 raise UsageError('You must provide the variable to forget')
100 else:
101 else:
101 try:
102 try:
102 del db['autorestore/' + todel]
103 del db['autorestore/' + todel]
103 except:
104 except:
104 error("Can't delete variable '%s'" % todel)
105 raise UsageError("Can't delete variable '%s'" % todel)
105 # reset
106 # reset
106 elif opts.has_key('z'):
107 elif opts.has_key('z'):
107 for k in db.keys('autorestore/*'):
108 for k in db.keys('autorestore/*'):
@@ -165,7 +166,7 b" def magic_store(self, parameter_s=''):"
165 print "Alias stored:", args[0], self.alias_table[ args[0] ]
166 print "Alias stored:", args[0], self.alias_table[ args[0] ]
166 return
167 return
167 else:
168 else:
168 print "Error: unknown variable '%s'" % args[0]
169 raise UsageError("Unknown variable '%s'" % args[0])
169
170
170 else:
171 else:
171 if isinstance(inspect.getmodule(obj), FakeModule):
172 if isinstance(inspect.getmodule(obj), FakeModule):
@@ -21,15 +21,13 b' import re'
21 import sys
21 import sys
22 import os
22 import os
23 import locale
23 import locale
24 import time
25 import pydoc,__builtin__,site
26 from thread_ex import ThreadEx
24 from thread_ex import ThreadEx
27 from StringIO import StringIO
28
25
29 try:
26 try:
30 import IPython
27 import IPython
31 except Exception,e:
28 except Exception,e:
32 raise "Error importing IPython (%s)" % str(e)
29 print "Error importing IPython (%s)" % str(e)
30 raise Exception, e
33
31
34 ##############################################################################
32 ##############################################################################
35 class _Helper(object):
33 class _Helper(object):
@@ -46,10 +44,12 b' class _Helper(object):'
46
44
47 def __call__(self, *args, **kwds):
45 def __call__(self, *args, **kwds):
48 class DummyWriter(object):
46 class DummyWriter(object):
47 '''Dumy class to handle help output'''
49 def __init__(self,pager):
48 def __init__(self, pager):
50 self._pager = pager
49 self._pager = pager
51
50
52 def write(self,data):
51 def write(self, data):
52 '''hook to fill self._pager'''
53 self._pager(data)
53 self._pager(data)
54
54
55 import pydoc
55 import pydoc
@@ -61,13 +61,14 b' class _Helper(object):'
61
61
62 ##############################################################################
62 ##############################################################################
63 class _CodeExecutor(ThreadEx):
63 class _CodeExecutor(ThreadEx):
64
64 ''' Thread that execute ipython code '''
65 def __init__(self, instance, after):
65 def __init__(self, instance, after):
66 ThreadEx.__init__(self)
66 ThreadEx.__init__(self)
67 self.instance = instance
67 self.instance = instance
68 self._afterExecute=after
68 self._afterExecute = after
69
69
70 def run(self):
70 def run(self):
71 '''Thread main loop'''
71 try:
72 try:
72 self.instance._doc_text = None
73 self.instance._doc_text = None
73 self.instance._help_text = None
74 self.instance._help_text = None
@@ -112,6 +113,8 b' class NonBlockingIPShell(object):'
112 @type int
113 @type int
113 '''
114 '''
114 #ipython0 initialisation
115 #ipython0 initialisation
116 self._IP = None
117 self._term = None
115 self.initIpython0(argv, user_ns, user_global_ns,
118 self.initIpython0(argv, user_ns, user_global_ns,
116 cin, cout, cerr,
119 cin, cout, cerr,
117 ask_exit_handler)
120 ask_exit_handler)
@@ -134,6 +137,8 b' class NonBlockingIPShell(object):'
134 def initIpython0(self, argv=[], user_ns={}, user_global_ns=None,
137 def initIpython0(self, argv=[], user_ns={}, user_global_ns=None,
135 cin=None, cout=None, cerr=None,
138 cin=None, cout=None, cerr=None,
136 ask_exit_handler=None):
139 ask_exit_handler=None):
140 ''' Initialize an ithon0 instance '''
141
137 #first we redefine in/out/error functions of IPython
142 #first we redefine in/out/error functions of IPython
138 if cin:
143 if cin:
139 IPython.Shell.Term.cin = cin
144 IPython.Shell.Term.cin = cin
@@ -190,8 +195,8 b' class NonBlockingIPShell(object):'
190
195
191 self._line_to_execute = line
196 self._line_to_execute = line
192 #we launch the ipython line execution in a thread to make it interruptible
197 #we launch the ipython line execution in a thread to make it interruptible
193 self.ce = _CodeExecutor(self,self._afterExecute)
198 ce = _CodeExecutor(self, self._afterExecute)
194 self.ce.start()
199 ce.start()
195
200
196 #----------------------- IPython management section ----------------------
201 #----------------------- IPython management section ----------------------
197 def getDocText(self):
202 def getDocText(self):
@@ -321,7 +326,8 b' class NonBlockingIPShell(object):'
321 '''
326 '''
322 history = ''
327 history = ''
323 #the below while loop is used to suppress empty history lines
328 #the below while loop is used to suppress empty history lines
324 while((history == '' or history == '\n') and self._history_level <= self._getHistoryMaxIndex()):
329 while((history == '' or history == '\n') \
330 and self._history_level <= self._getHistoryMaxIndex()):
325 if self._history_level < self._getHistoryMaxIndex():
331 if self._history_level < self._getHistoryMaxIndex():
326 self._history_level += 1
332 self._history_level += 1
327 history = self._getHistory()
333 history = self._getHistory()
@@ -375,8 +381,8 b' class NonBlockingIPShell(object):'
375 '''
381 '''
376 This function is used as a callback replacment to IPython help pager function
382 This function is used as a callback replacment to IPython help pager function
377
383
378 It puts the 'text' value inside the self._help_text string that can be retrived via getHelpText
384 It puts the 'text' value inside the self._help_text string that can be retrived via
379 function.
385 getHelpText function.
380 '''
386 '''
381 if self._help_text == None:
387 if self._help_text == None:
382 self._help_text = text
388 self._help_text = text
@@ -387,8 +393,8 b' class NonBlockingIPShell(object):'
387 '''
393 '''
388 This function is used as a callback replacment to IPython pager function
394 This function is used as a callback replacment to IPython pager function
389
395
390 It puts the 'text' value inside the self._doc_text string that can be retrived via getDocText
396 It puts the 'text' value inside the self._doc_text string that can be retrived via
391 function.
397 getDocText function.
392 '''
398 '''
393 self._doc_text = text
399 self._doc_text = text
394
400
@@ -429,8 +435,7 b' class NonBlockingIPShell(object):'
429 self._IP.showtraceback()
435 self._IP.showtraceback()
430 else:
436 else:
431 self._iter_more = self._IP.push(line)
437 self._iter_more = self._IP.push(line)
432 if (self._IP.SyntaxTB.last_syntax_error and
438 if (self._IP.SyntaxTB.last_syntax_error and self._IP.rc.autoedit_syntax):
433 self._IP.rc.autoedit_syntax):
434 self._IP.edit_syntax_error()
439 self._IP.edit_syntax_error()
435 if self._iter_more:
440 if self._iter_more:
436 self._prompt = str(self._IP.outputcache.prompt2).strip()
441 self._prompt = str(self._IP.outputcache.prompt2).strip()
@@ -452,8 +457,8 b' class NonBlockingIPShell(object):'
452 '''
457 '''
453 stdin, stdout = os.popen4(cmd)
458 stdin, stdout = os.popen4(cmd)
454 result = stdout.read().decode('cp437').encode(locale.getpreferredencoding())
459 result = stdout.read().decode('cp437').encode(locale.getpreferredencoding())
455 #we use print command because the shell command is called inside IPython instance and thus is
460 #we use print command because the shell command is called
456 #redirected to thread cout
461 #inside IPython instance and thus is redirected to thread cout
457 #"\x01\x1b[1;36m\x02" <-- add colour to the text...
462 #"\x01\x1b[1;36m\x02" <-- add colour to the text...
458 print "\x01\x1b[1;36m\x02"+result
463 print "\x01\x1b[1;36m\x02"+result
459 stdout.close()
464 stdout.close()
@@ -28,13 +28,7 b' import wx'
28 import wx.stc as stc
28 import wx.stc as stc
29
29
30 import re
30 import re
31 import sys
32 import locale
33 from StringIO import StringIO
31 from StringIO import StringIO
34 try:
35 import IPython
36 except Exception,e:
37 raise "Error importing IPython (%s)" % str(e)
38
32
39 from ipshell_nonblocking import NonBlockingIPShell
33 from ipshell_nonblocking import NonBlockingIPShell
40
34
@@ -387,9 +381,7 b' class WxConsoleView(stc.StyledTextCtrl):'
387 max_symbol =' '*max_len
381 max_symbol = ' '*max_len
388
382
389 #now we check how much symbol we can put on a line...
383 #now we check how much symbol we can put on a line...
390 cursor_pos = self.getCursorPos()
391 test_buffer = max_symbol + ' '*4
384 test_buffer = max_symbol + ' '*4
392 current_lines = self.GetLineCount()
393
385
394 allowed_symbols = 80/len(test_buffer)
386 allowed_symbols = 80/len(test_buffer)
395 if allowed_symbols == 0:
387 if allowed_symbols == 0:
@@ -462,7 +454,8 b' class WxConsoleView(stc.StyledTextCtrl):'
462 return True
454 return True
463
455
464 if skip:
456 if skip:
465 if event.GetKeyCode() not in [wx.WXK_PAGEUP,wx.WXK_PAGEDOWN] and event.Modifiers == wx.MOD_NONE:
457 if event.GetKeyCode() not in [wx.WXK_PAGEUP, wx.WXK_PAGEDOWN]\
458 and event.Modifiers == wx.MOD_NONE:
466 self.moveCursorOnNewValidKey()
459 self.moveCursorOnNewValidKey()
467
460
468 event.Skip()
461 event.Skip()
@@ -1,9 +1,22 b''
1 2008-06-03 Ville Vainio <vivainio@gmail.com>
2
3 * ipython.rst, ipython.1: remove -twisted from man page,
4 add -pydb to both man page and manual.
5
6 * pspersistence.py: report UsageError on %store -w w/o arg,
7 and other usage pattern errors. Bug report by Johann Cohen-Tanugi.
8
1 2008-06-02 Fernando Perez <Fernando.Perez@berkeley.edu>
9 2008-06-02 Fernando Perez <Fernando.Perez@berkeley.edu>
2
10
3 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): add
11 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): add
4 numpy/np/pyplot/plt imports according to new conventions we're
12 numpy/np/pyplot/plt imports according to new conventions we're
5 trying to standardize on. This only affects the -pylab mode.
13 trying to standardize on. This only affects the -pylab mode.
6
14
15 2008-05-31 Fernando Perez <Fernando.Perez@berkeley.edu>
16
17 * IPython/ipmaker.py (make_IPython): The -twisted option is fully
18 disabled.
19
7 2008-05-31 *** Released version 0.8.4
20 2008-05-31 *** Released version 0.8.4
8
21
9 2008-05-31 Fernando Perez <Fernando.Perez@berkeley.edu>
22 2008-05-31 Fernando Perez <Fernando.Perez@berkeley.edu>
@@ -36,7 +36,7 b' The following special options are ONLY valid at the beginning of the command'
36 line, and not later. This is because they control the initialization of
36 line, and not later. This is because they control the initialization of
37 ipython itself, before the normal option-handling mechanism is active.
37 ipython itself, before the normal option-handling mechanism is active.
38 .TP
38 .TP
39 .B \-gthread, \-qthread, \-q4thread, \-wthread, \-pylab, \-twisted
39 .B \-gthread, \-qthread, \-q4thread, \-wthread, \-pylab
40 Only ONE of these can be given, and it can only be given as the first option
40 Only ONE of these can be given, and it can only be given as the first option
41 passed to IPython (it will have no effect in any other position). They provide
41 passed to IPython (it will have no effect in any other position). They provide
42 threading support for the GTK, QT3, QT4 and WXWidgets toolkits, for the
42 threading support for the GTK, QT3, QT4 and WXWidgets toolkits, for the
@@ -56,10 +56,6 b' request a specific version of wx to be used. This requires that you have the'
56 distributions.
56 distributions.
57 .br
57 .br
58 .sp 1
58 .sp 1
59 If \-twisted is given, IPython start a Twisted reactor and runs IPython mainloop
60 in a dedicated thread, passing commands to be run inside the Twisted reactor.
61 .br
62 .sp 1
63 If \-pylab is given, IPython loads special support for the matplotlib library
59 If \-pylab is given, IPython loads special support for the matplotlib library
64 (http://matplotlib.sourceforge.net), allowing interactive usage of any of its
60 (http://matplotlib.sourceforge.net), allowing interactive usage of any of its
65 backends as defined in the user's .matplotlibrc file. It automatically
61 backends as defined in the user's .matplotlibrc file. It automatically
@@ -245,6 +241,10 b' you are used to debugging using pdb, this puts you automatically'
245 inside of it after any call (either in IPython or in code called by
241 inside of it after any call (either in IPython or in code called by
246 it) which triggers an exception which goes uncaught.
242 it) which triggers an exception which goes uncaught.
247 .TP
243 .TP
244 .B \-pydb
245 Makes IPython use the third party "pydb" package as debugger,
246 instead of pdb. Requires that pydb is installed.
247 .TP
248 .B \-[no]pprint
248 .B \-[no]pprint
249 IPython can optionally use the pprint (pretty printer) module for
249 IPython can optionally use the pprint (pretty printer) module for
250 displaying results. pprint tends to give a nicer display of nested
250 displaying results. pprint tends to give a nicer display of nested
@@ -1227,6 +1227,10 b' All options with a [no] prepended can be specified in negated form'
1227 IPython or in code called by it) which triggers an exception
1227 IPython or in code called by it) which triggers an exception
1228 which goes uncaught.
1228 which goes uncaught.
1229
1229
1230 -pydb
1231 Makes IPython use the third party "pydb" package as debugger,
1232 instead of pdb. Requires that pydb is installed.
1233
1230 -[no]pprint
1234 -[no]pprint
1231 ipython can optionally use the pprint (pretty printer) module
1235 ipython can optionally use the pprint (pretty printer) module
1232 for displaying results. pprint tends to give a nicer display
1236 for displaying results. pprint tends to give a nicer display
General Comments 0
You need to be logged in to leave comments. Login now