Show More
@@ -2,7 +2,7 b'' | |||||
2 | """ |
|
2 | """ | |
3 | Logger class for IPython's logging facilities. |
|
3 | Logger class for IPython's logging facilities. | |
4 |
|
4 | |||
5 |
$Id: Logger.py 9 |
|
5 | $Id: Logger.py 984 2005-12-31 08:40:31Z fperez $ | |
6 | """ |
|
6 | """ | |
7 |
|
7 | |||
8 | #***************************************************************************** |
|
8 | #***************************************************************************** | |
@@ -181,6 +181,7 b' which already exists. But you must first start the logging process with' | |||||
181 | self._i00 = line+'\n' |
|
181 | self._i00 = line+'\n' | |
182 | #print 'Logging input:<%s>' % line # dbg |
|
182 | #print 'Logging input:<%s>' % line # dbg | |
183 | input_hist.append(self._i00) |
|
183 | input_hist.append(self._i00) | |
|
184 | #print '---[%s]' % (len(input_hist)-1,) # dbg | |||
184 |
|
185 | |||
185 | # hackish access to top-level namespace to create _i1,_i2... dynamically |
|
186 | # hackish access to top-level namespace to create _i1,_i2... dynamically | |
186 | to_main = {'_i':self._i,'_ii':self._ii,'_iii':self._iii} |
|
187 | to_main = {'_i':self._i,'_ii':self._ii,'_iii':self._iii} | |
@@ -191,6 +192,12 b' which already exists. But you must first start the logging process with' | |||||
191 | # get resumed. |
|
192 | # get resumed. | |
192 | while in_num >= len(input_hist): |
|
193 | while in_num >= len(input_hist): | |
193 | input_hist.append('\n') |
|
194 | input_hist.append('\n') | |
|
195 | # but if the opposite is true (a macro can produce multiple inputs | |||
|
196 | # with no output display called), then bring the output counter in | |||
|
197 | # sync: | |||
|
198 | last_num = len(input_hist)-1 | |||
|
199 | if in_num != last_num: | |||
|
200 | in_num = self.shell.outputcache.prompt_count = last_num | |||
194 | new_i = '_i%s' % in_num |
|
201 | new_i = '_i%s' % in_num | |
195 | if continuation: |
|
202 | if continuation: | |
196 | self._i00 = '%s%s\n' % (self.shell.user_ns[new_i],line) |
|
203 | self._i00 = '%s%s\n' % (self.shell.user_ns[new_i],line) |
@@ -1,7 +1,7 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 9 |
|
4 | $Id: Magic.py 984 2005-12-31 08:40:31Z fperez $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and | |
@@ -451,17 +451,19 b' Currently the magic system has the following functions:\\n"""' | |||||
451 |
|
451 | |||
452 | This feature is only available if numbered prompts are in use.""" |
|
452 | This feature is only available if numbered prompts are in use.""" | |
453 |
|
453 | |||
454 | if not self.shell.outputcache.do_full_cache: |
|
454 | shell = self.shell | |
|
455 | if not shell.outputcache.do_full_cache: | |||
455 | print 'This feature is only available if numbered prompts are in use.' |
|
456 | print 'This feature is only available if numbered prompts are in use.' | |
456 | return |
|
457 | return | |
457 | opts,args = self.parse_options(parameter_s,'n',mode='list') |
|
458 | opts,args = self.parse_options(parameter_s,'n',mode='list') | |
458 |
|
459 | |||
|
460 | input_hist = shell.input_hist | |||
459 | default_length = 40 |
|
461 | default_length = 40 | |
460 | if len(args) == 0: |
|
462 | if len(args) == 0: | |
461 | final = self.shell.outputcache.prompt_count |
|
463 | final = len(input_hist) | |
462 | init = max(1,final-default_length) |
|
464 | init = max(1,final-default_length) | |
463 | elif len(args) == 1: |
|
465 | elif len(args) == 1: | |
464 | final = self.shell.outputcache.prompt_count |
|
466 | final = len(input_hist) | |
465 | init = max(1,final-int(args[0])) |
|
467 | init = max(1,final-int(args[0])) | |
466 | elif len(args) == 2: |
|
468 | elif len(args) == 2: | |
467 | init,final = map(int,args) |
|
469 | init,final = map(int,args) | |
@@ -471,18 +473,13 b' Currently the magic system has the following functions:\\n"""' | |||||
471 | return |
|
473 | return | |
472 | width = len(str(final)) |
|
474 | width = len(str(final)) | |
473 | line_sep = ['','\n'] |
|
475 | line_sep = ['','\n'] | |
474 | input_hist = self.shell.input_hist |
|
|||
475 | print_nums = not opts.has_key('n') |
|
476 | print_nums = not opts.has_key('n') | |
476 | for in_num in range(init,final): |
|
477 | for in_num in range(init,final): | |
477 | inline = input_hist[in_num] |
|
478 | inline = input_hist[in_num] | |
478 | multiline = inline.count('\n') > 1 |
|
479 | multiline = int(inline.count('\n') > 1) | |
479 | if print_nums: |
|
480 | if print_nums: | |
480 |
print str(in_num).ljust(width) |
|
481 | print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), | |
481 | if inline.startswith('#'+self.shell.ESC_MAGIC) or \ |
|
482 | print inline, | |
482 | inline.startswith('#!'): |
|
|||
483 | print inline[1:], |
|
|||
484 | else: |
|
|||
485 | print inline, |
|
|||
486 |
|
483 | |||
487 | def magic_hist(self, parameter_s=''): |
|
484 | def magic_hist(self, parameter_s=''): | |
488 | """Alternate name for %history.""" |
|
485 | """Alternate name for %history.""" | |
@@ -1356,7 +1353,13 b' Currently the magic system has the following functions:\\n"""' | |||||
1356 | name = '__main__' |
|
1353 | name = '__main__' | |
1357 | prog_ns = {'__name__':name} |
|
1354 | prog_ns = {'__name__':name} | |
1358 |
|
1355 | |||
1359 | # pickle fix. See iplib for an explanation |
|
1356 | # pickle fix. See iplib for an explanation. But we need to make sure | |
|
1357 | # that, if we overwrite __main__, we replace it at the end | |||
|
1358 | if prog_ns['__name__'] == '__main__': | |||
|
1359 | restore_main = sys.modules['__main__'] | |||
|
1360 | else: | |||
|
1361 | restore_main = False | |||
|
1362 | ||||
1360 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) |
|
1363 | sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) | |
1361 |
|
1364 | |||
1362 | stats = None |
|
1365 | stats = None | |
@@ -1444,6 +1447,8 b' Currently the magic system has the following functions:\\n"""' | |||||
1444 | self.shell.user_ns.update(prog_ns) |
|
1447 | self.shell.user_ns.update(prog_ns) | |
1445 | finally: |
|
1448 | finally: | |
1446 | sys.argv = save_argv |
|
1449 | sys.argv = save_argv | |
|
1450 | if restore_main: | |||
|
1451 | sys.modules['__main__'] = restore_main | |||
1447 | return stats |
|
1452 | return stats | |
1448 |
|
1453 | |||
1449 | def magic_runlog(self, parameter_s =''): |
|
1454 | def magic_runlog(self, parameter_s =''): |
@@ -1,7 +1,7 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Release data for the IPython project. |
|
2 | """Release data for the IPython project. | |
3 |
|
3 | |||
4 |
$Id: Release.py 98 |
|
4 | $Id: Release.py 984 2005-12-31 08:40:31Z fperez $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu> |
|
7 | # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu> | |
@@ -22,9 +22,9 b" name = 'ipython'" | |||||
22 | # because bdist_rpm does not accept dashes (an RPM) convention, and |
|
22 | # because bdist_rpm does not accept dashes (an RPM) convention, and | |
23 | # bdist_deb does not accept underscores (a Debian convention). |
|
23 | # bdist_deb does not accept underscores (a Debian convention). | |
24 |
|
24 | |||
25 |
version = '0.7.0.rc |
|
25 | version = '0.7.0.rc4' | |
26 |
|
26 | |||
27 |
revision = '$Revision: 98 |
|
27 | revision = '$Revision: 984 $' | |
28 |
|
28 | |||
29 | description = "An enhanced interactive Python shell." |
|
29 | description = "An enhanced interactive Python shell." | |
30 |
|
30 |
@@ -6,7 +6,7 b' Requires Python 2.1 or newer.' | |||||
6 |
|
6 | |||
7 | This file contains all the classes and helper functions specific to IPython. |
|
7 | This file contains all the classes and helper functions specific to IPython. | |
8 |
|
8 | |||
9 |
$Id: iplib.py 98 |
|
9 | $Id: iplib.py 984 2005-12-31 08:40:31Z fperez $ | |
10 | """ |
|
10 | """ | |
11 |
|
11 | |||
12 | #***************************************************************************** |
|
12 | #***************************************************************************** | |
@@ -237,7 +237,7 b' class SyntaxTB(ultraTB.ListTB):' | |||||
237 | # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell', |
|
237 | # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell', | |
238 | # 'self.value'] |
|
238 | # 'self.value'] | |
239 |
|
239 | |||
240 | class InteractiveShell(Magic): |
|
240 | class InteractiveShell(object,Magic): | |
241 | """An enhanced console for Python.""" |
|
241 | """An enhanced console for Python.""" | |
242 |
|
242 | |||
243 | # class attribute to indicate whether the class supports threads or not. |
|
243 | # class attribute to indicate whether the class supports threads or not. | |
@@ -388,6 +388,7 b' class InteractiveShell(Magic):' | |||||
388 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' |
|
388 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' | |
389 | else: |
|
389 | else: | |
390 | #print "pickle hack in place" # dbg |
|
390 | #print "pickle hack in place" # dbg | |
|
391 | #print 'main_name:',main_name # dbg | |||
391 | sys.modules[main_name] = FakeModule(self.user_ns) |
|
392 | sys.modules[main_name] = FakeModule(self.user_ns) | |
392 |
|
393 | |||
393 | # List of input with multi-line handling. |
|
394 | # List of input with multi-line handling. | |
@@ -717,10 +718,7 b' class InteractiveShell(Magic):' | |||||
717 |
|
718 | |||
718 |
|
719 | |||
719 | self.user_ns[key] = obj |
|
720 | self.user_ns[key] = obj | |
720 |
|
721 | |||
721 |
|
||||
722 |
|
||||
723 |
|
||||
724 | def set_hook(self,name,hook): |
|
722 | def set_hook(self,name,hook): | |
725 | """set_hook(name,hook) -> sets an internal IPython hook. |
|
723 | """set_hook(name,hook) -> sets an internal IPython hook. | |
726 |
|
724 |
@@ -1,5 +1,31 b'' | |||||
|
1 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> | |||
|
2 | ||||
|
3 | * IPython/Logger.py (Logger.log): fix a history handling bug. I | |||
|
4 | don't know if this is the end of it, but the behavior now is | |||
|
5 | certainly much more correct. Note that coupled with macros, | |||
|
6 | slightly surprising (at first) behavior may occur: a macro will in | |||
|
7 | general expand to multiple lines of input, so upon exiting, the | |||
|
8 | in/out counters will both be bumped by the corresponding amount | |||
|
9 | (as if the macro's contents had been typed interactively). Typing | |||
|
10 | %hist will reveal the intermediate (silently processed) lines. | |||
|
11 | ||||
|
12 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause | |||
|
13 | pickle to fail (%run was overwriting __main__ and not restoring | |||
|
14 | it, but pickle relies on __main__ to operate). | |||
|
15 | ||||
|
16 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now | |||
|
17 | using properties, but forgot to make the main InteractiveShell | |||
|
18 | class a new-style class. Properties fail silently, and | |||
|
19 | misteriously, with old-style class (getters work, but | |||
|
20 | setters don't do anything). | |||
|
21 | ||||
1 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> |
|
22 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
23 | |||
|
24 | * IPython/Magic.py (magic_history): fix history reporting bug (I | |||
|
25 | know some nasties are still there, I just can't seem to find a | |||
|
26 | reproducible test case to track them down; the input history is | |||
|
27 | falling out of sync...) | |||
|
28 | ||||
3 | * IPython/iplib.py (handle_shell_escape): fix bug where both |
|
29 | * IPython/iplib.py (handle_shell_escape): fix bug where both | |
4 | aliases and system accesses where broken for indented code (such |
|
30 | aliases and system accesses where broken for indented code (such | |
5 | as loops). |
|
31 | as loops). |
General Comments 0
You need to be logged in to leave comments.
Login now