##// END OF EJS Templates
Rename pre/post_execute_explicit events to pre/post_run_cell
Thomas Kluyver -
Show More
@@ -106,7 +106,7 b' def pre_execute():'
106 pass
106 pass
107
107
108 @_collect
108 @_collect
109 def pre_execute_explicit():
109 def pre_run_cell():
110 """Fires before user-entered code runs."""
110 """Fires before user-entered code runs."""
111 pass
111 pass
112
112
@@ -118,7 +118,7 b' def post_execute():'
118 pass
118 pass
119
119
120 @_collect
120 @_collect
121 def post_execute_explicit():
121 def post_run_cell():
122 """Fires after user-entered code runs."""
122 """Fires after user-entered code runs."""
123 pass
123 pass
124
124
@@ -49,7 +49,7 b" __all__ = ['editor', 'fix_error_editor', 'synchronize_with_editor',"
49 'show_in_pager','pre_prompt_hook',
49 'show_in_pager','pre_prompt_hook',
50 'pre_run_code_hook', 'clipboard_get']
50 'pre_run_code_hook', 'clipboard_get']
51
51
52 deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_execute_explicit' event",
52 deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_run_cell' event",
53 'late_startup_hook': "a callback for the 'shell_initialised' event",
53 'late_startup_hook': "a callback for the 'shell_initialised' event",
54 'shutdown_hook': "the atexit module",
54 'shutdown_hook': "the atexit module",
55 }
55 }
@@ -844,13 +844,13 b' class InteractiveShell(SingletonConfigurable):'
844 self.events = EventManager(self, available_events)
844 self.events = EventManager(self, available_events)
845
845
846 def register_post_execute(self, func):
846 def register_post_execute(self, func):
847 """DEPRECATED: Use ip.callbacks.register('post_execute_explicit', func)
847 """DEPRECATED: Use ip.callbacks.register('post_run_cell', func)
848
848
849 Register a function for calling after code execution.
849 Register a function for calling after code execution.
850 """
850 """
851 warn("ip.register_post_execute is deprecated, use "
851 warn("ip.register_post_execute is deprecated, use "
852 "ip.callbacks.register('post_execute_explicit', func) instead.")
852 "ip.callbacks.register('post_run_cell', func) instead.")
853 self.events.register('post_execute_explicit', func)
853 self.events.register('post_run_cell', func)
854
854
855 #-------------------------------------------------------------------------
855 #-------------------------------------------------------------------------
856 # Things related to the "main" module
856 # Things related to the "main" module
@@ -2669,7 +2669,7 b' class InteractiveShell(SingletonConfigurable):'
2669
2669
2670 self.events.trigger('pre_execute')
2670 self.events.trigger('pre_execute')
2671 if not silent:
2671 if not silent:
2672 self.events.trigger('pre_execute_explicit')
2672 self.events.trigger('pre_run_cell')
2673
2673
2674 # If any of our input transformation (input_transformer_manager or
2674 # If any of our input transformation (input_transformer_manager or
2675 # prefilter_manager) raises an exception, we store it in this variable
2675 # prefilter_manager) raises an exception, we store it in this variable
@@ -2742,7 +2742,7 b' class InteractiveShell(SingletonConfigurable):'
2742
2742
2743 self.events.trigger('post_execute')
2743 self.events.trigger('post_execute')
2744 if not silent:
2744 if not silent:
2745 self.events.trigger('post_execute_explicit')
2745 self.events.trigger('post_run_cell')
2746
2746
2747 if store_history:
2747 if store_history:
2748 # Write output to the database. Does nothing unless
2748 # Write output to the database. Does nothing unless
@@ -282,15 +282,15 b' class InteractiveShellTestCase(unittest.TestCase):'
282 self.assertEqual(ip.var_expand(u"{1/0}"), u"{1/0}")
282 self.assertEqual(ip.var_expand(u"{1/0}"), u"{1/0}")
283
283
284 def test_silent_postexec(self):
284 def test_silent_postexec(self):
285 """run_cell(silent=True) doesn't invoke pre/post_execute_explicit callbacks"""
285 """run_cell(silent=True) doesn't invoke pre/post_run_cell callbacks"""
286 pre_explicit = mock.Mock()
286 pre_explicit = mock.Mock()
287 pre_always = mock.Mock()
287 pre_always = mock.Mock()
288 post_explicit = mock.Mock()
288 post_explicit = mock.Mock()
289 post_always = mock.Mock()
289 post_always = mock.Mock()
290
290
291 ip.events.register('pre_execute_explicit', pre_explicit)
291 ip.events.register('pre_run_cell', pre_explicit)
292 ip.events.register('pre_execute', pre_always)
292 ip.events.register('pre_execute', pre_always)
293 ip.events.register('post_execute_explicit', post_explicit)
293 ip.events.register('post_run_cell', post_explicit)
294 ip.events.register('post_execute', post_always)
294 ip.events.register('post_execute', post_always)
295
295
296 try:
296 try:
@@ -490,7 +490,7 b' class AutoreloadMagics(Magics):'
490 # Inject module to user namespace
490 # Inject module to user namespace
491 self.shell.push({top_name: top_module})
491 self.shell.push({top_name: top_module})
492
492
493 def pre_execute_explicit(self):
493 def pre_run_cell(self):
494 if self._reloader.enabled:
494 if self._reloader.enabled:
495 try:
495 try:
496 self._reloader.check()
496 self._reloader.check()
@@ -502,4 +502,4 b' def load_ipython_extension(ip):'
502 """Load the extension in IPython."""
502 """Load the extension in IPython."""
503 auto_reload = AutoreloadMagics(ip)
503 auto_reload = AutoreloadMagics(ip)
504 ip.register_magics(auto_reload)
504 ip.register_magics(auto_reload)
505 ip.events.register('pre_execute_explicit', auto_reload.pre_execute_explicit)
505 ip.events.register('pre_run_cell', auto_reload.pre_run_cell)
@@ -23,7 +23,7 b' import nose.tools as nt'
23 import IPython.testing.tools as tt
23 import IPython.testing.tools as tt
24
24
25 from IPython.extensions.autoreload import AutoreloadMagics
25 from IPython.extensions.autoreload import AutoreloadMagics
26 from IPython.core.events import EventManager, pre_execute_explicit
26 from IPython.core.events import EventManager, pre_run_cell
27 from IPython.utils.py3compat import PY3
27 from IPython.utils.py3compat import PY3
28
28
29 if PY3:
29 if PY3:
@@ -41,14 +41,14 b' class FakeShell(object):'
41
41
42 def __init__(self):
42 def __init__(self):
43 self.ns = {}
43 self.ns = {}
44 self.events = EventManager(self, {'pre_execute_explicit', pre_execute_explicit})
44 self.events = EventManager(self, {'pre_run_cell', pre_run_cell})
45 self.auto_magics = AutoreloadMagics(shell=self)
45 self.auto_magics = AutoreloadMagics(shell=self)
46 self.events.register('pre_execute_explicit', self.auto_magics.pre_execute_explicit)
46 self.events.register('pre_run_cell', self.auto_magics.pre_run_cell)
47
47
48 register_magics = set_hook = noop
48 register_magics = set_hook = noop
49
49
50 def run_code(self, code):
50 def run_code(self, code):
51 self.events.trigger('pre_execute_explicit')
51 self.events.trigger('pre_run_cell')
52 exec(code, self.ns)
52 exec(code, self.ns)
53
53
54 def push(self, items):
54 def push(self, items):
General Comments 0
You need to be logged in to leave comments. Login now