Show More
@@ -392,7 +392,6 b' def superreload(module, reload=reload, old_objects={}):' | |||
|
392 | 392 | # IPython connectivity |
|
393 | 393 | #------------------------------------------------------------------------------ |
|
394 | 394 | |
|
395 | from IPython.core.hooks import TryNext | |
|
396 | 395 | from IPython.core.magic import Magics, magics_class, line_magic |
|
397 | 396 | |
|
398 | 397 | @magics_class |
@@ -491,17 +490,16 b' class AutoreloadMagics(Magics):' | |||
|
491 | 490 | # Inject module to user namespace |
|
492 | 491 | self.shell.push({top_name: top_module}) |
|
493 | 492 | |
|
494 |
def pre_ |
|
|
495 |
if |
|
|
496 |
|
|
|
497 | try: | |
|
498 | self._reloader.check() | |
|
499 | except: | |
|
500 | pass | |
|
493 | def pre_execute_explicit(self): | |
|
494 | if self._reloader.enabled: | |
|
495 | try: | |
|
496 | self._reloader.check() | |
|
497 | except: | |
|
498 | pass | |
|
501 | 499 | |
|
502 | 500 | |
|
503 | 501 | def load_ipython_extension(ip): |
|
504 | 502 | """Load the extension in IPython.""" |
|
505 | 503 | auto_reload = AutoreloadMagics(ip) |
|
506 | 504 | ip.register_magics(auto_reload) |
|
507 | ip.set_hook('pre_run_code_hook', auto_reload.pre_run_code_hook) | |
|
505 | ip.callbacks.register('pre_execute_explicit', auto_reload.pre_execute_explicit) |
@@ -23,7 +23,7 b' import nose.tools as nt' | |||
|
23 | 23 | import IPython.testing.tools as tt |
|
24 | 24 | |
|
25 | 25 | from IPython.extensions.autoreload import AutoreloadMagics |
|
26 | from IPython.core.hooks import TryNext | |
|
26 | from IPython.core.callbacks import CallbackManager, pre_execute_explicit | |
|
27 | 27 | from IPython.utils.py3compat import PY3 |
|
28 | 28 | |
|
29 | 29 | if PY3: |
@@ -41,15 +41,14 b' class FakeShell(object):' | |||
|
41 | 41 | |
|
42 | 42 | def __init__(self): |
|
43 | 43 | self.ns = {} |
|
44 | self.callbacks = CallbackManager(self, {'pre_execute_explicit', pre_execute_explicit}) | |
|
44 | 45 | self.auto_magics = AutoreloadMagics(shell=self) |
|
46 | self.callbacks.register('pre_execute_explicit', self.auto_magics.pre_execute_explicit) | |
|
45 | 47 | |
|
46 | 48 | register_magics = set_hook = noop |
|
47 | 49 | |
|
48 | 50 | def run_code(self, code): |
|
49 | try: | |
|
50 | self.auto_magics.pre_run_code_hook(self) | |
|
51 | except TryNext: | |
|
52 | pass | |
|
51 | self.callbacks.fire('pre_execute_explicit') | |
|
53 | 52 | exec(code, self.ns) |
|
54 | 53 | |
|
55 | 54 | def push(self, items): |
General Comments 0
You need to be logged in to leave comments.
Login now