Changeset 860
- Timestamp:
- 09/19/05 16:15:39 (3 years ago)
- Files:
-
- nbshell/trunk/ChangeLog (modified) (1 diff)
- nbshell/trunk/nbshell/IPythonLog.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nbshell/trunk/ChangeLog
r852 r860 1 2005-09-19 Robert Kern <robert.kern@gmail.com> 2 3 * IPythonLog.py (IPythonLog.__init__, displayhook, __run): Restored 4 output cache and input history functionality via the In and Out 5 variables. 6 7 1 8 2005-09-18 Tzanko Matev <tsanko@gmail.com> 2 9 nbshell/trunk/nbshell/IPythonLog.py
r838 r860 17 17 import StringIO 18 18 import textwrap 19 import __builtin__ 20 import pprint 19 21 20 22 from wx.py.buffer import Buffer … … 28 30 29 31 from IPython import Shell 32 from IPython import genutils 33 from IPython.Magic import Macro 30 34 from notabene import notebook 31 35 … … 87 91 excepthook_orig = sys.excepthook 88 92 self.interp = Shell.IPShellGUI(argv=['-colors','NoColor'], user_ns=user_ns) 93 94 self.interp_log = self.interp.IP.log 95 def donothing(*args, **kwds): 96 pass 97 self.interp.IP.log = donothing 98 del self.interp.IP.input_hist[0] 99 89 100 self.excepthook_IP = sys.excepthook 90 101 sys.excepthook = excepthook_orig … … 241 252 #TODO:this could be prettier 242 253 self.currentcell = cell 254 255 # Add the whole input to the input history (ignoring the leading and 256 # trailing '\n') 257 self.interp_log(cell.input[1:-1], False) 258 243 259 #The first and last characters of cell.input are '\n' 244 260 retval = self.interp.runlines(cell.input[1:-1],\ … … 284 300 285 301 def displayhook(self, obj): 302 # RTK: modified from IPython.Prompts.CachedOutput.__call__() 303 304 slf = self.interp.IP.outputcache 305 slf.prompt_count = self.currentcell.number 306 286 307 #print >> self.stdout_orig, 'displayhook called' #dbg 287 308 # We want to keep only the last output 288 309 if obj is not None: 289 self.output = '\n%s\n' % obj 310 if slf.Pprint: 311 self.output = '\n%s\n' % pprint.pformat(obj) 312 else: 313 self.output = '\n%r\n' % obj 314 315 # If something injected a '_' variable in __builtin__, delete 316 # ipython's automatic one so we don't clobber that. gettext() in 317 # particular uses _, so we need to stay away from it. 318 if '_' in __builtin__.__dict__: 319 try: 320 del slf.user_ns['_'] 321 except KeyError: 322 pass 323 if obj is not None: 324 cout_write = genutils.Term.cout.write # fast lookup 325 # first handle the cache and counters 326 slf.update(obj) 327 # do not print output if input ends in ';' 328 if slf.input_hist[slf.prompt_count].endswith(';\n'): 329 return 330 # don't use print, puts an extra space 331 #cout_write(slf.output_sep) 332 #if slf.do_full_cache: 333 # cout_write(str(slf.prompt_out)) 334 335 if isinstance(obj,Macro): 336 print 'Executing Macro...' 337 # in case the macro takes a long time to execute 338 genutils.Term.cout.flush() 339 exec obj.value in slf.user_ns 340 return None 341 342 # and now call a possibly user-defined print mechanism 343 #slf.display(obj) 344 #cout_write(slf.output_sep2) 345 #genutils.Term.cout.flush() 346 347 348
