##// END OF EJS Templates
remove deprecated hooks
Matthias Bussonnier -
Show More
@@ -44,10 +44,13 b' from .error import TryNext'
44 # List here all the default hooks. For now it's just the editor functions
44 # List here all the default hooks. For now it's just the editor functions
45 # but over time we'll move here all the public API for user-accessible things.
45 # but over time we'll move here all the public API for user-accessible things.
46
46
47 __all__ = ['editor', 'synchronize_with_editor',
47 __all__ = [
48 'shutdown_hook', 'late_startup_hook',
48 "editor",
49 'show_in_pager','pre_prompt_hook',
49 "synchronize_with_editor",
50 'pre_run_code_hook', 'clipboard_get']
50 "show_in_pager",
51 "pre_prompt_hook",
52 "clipboard_get",
53 ]
51
54
52 deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_run_cell' event",
55 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_initialized' event",
56 'late_startup_hook': "a callback for the 'shell_initialized' event",
@@ -132,23 +135,6 b' class CommandChainDispatcher:'
132 return iter(self.chain)
135 return iter(self.chain)
133
136
134
137
135 def shutdown_hook(self):
136 """ default shutdown hook
137
138 Typically, shutdown hooks should raise TryNext so all shutdown ops are done
139 """
140
141 #print "default shutdown hook ok" # dbg
142 return
143
144
145 def late_startup_hook(self):
146 """ Executed after ipython has been constructed and configured
147
148 """
149 #print "default startup hook ok" # dbg
150
151
152 def show_in_pager(self, data, start, screen_lines):
138 def show_in_pager(self, data, start, screen_lines):
153 """ Run a string through pager """
139 """ Run a string through pager """
154 # raising TryNext here will use the default paging functionality
140 # raising TryNext here will use the default paging functionality
@@ -165,11 +151,6 b' def pre_prompt_hook(self):'
165 return None
151 return None
166
152
167
153
168 def pre_run_code_hook(self):
169 """ Executed before running the (prefiltered) code in IPython """
170 return None
171
172
173 def clipboard_get(self):
154 def clipboard_get(self):
174 """ Get text from the clipboard.
155 """ Get text from the clipboard.
175 """
156 """
@@ -561,7 +561,6 b' class InteractiveShell(SingletonConfigurable):'
561 self.init_pdb()
561 self.init_pdb()
562 self.init_extension_manager()
562 self.init_extension_manager()
563 self.init_payload()
563 self.init_payload()
564 self.hooks.late_startup_hook()
565 self.events.trigger('shell_initialized', self)
564 self.events.trigger('shell_initialized', self)
566 atexit.register(self.atexit_operations)
565 atexit.register(self.atexit_operations)
567
566
@@ -868,13 +867,12 b' class InteractiveShell(SingletonConfigurable):'
868 for hook_name in hooks.__all__:
867 for hook_name in hooks.__all__:
869 # default hooks have priority 100, i.e. low; user hooks should have
868 # default hooks have priority 100, i.e. low; user hooks should have
870 # 0-100 priority
869 # 0-100 priority
871 self.set_hook(hook_name,getattr(hooks,hook_name), 100, _warn_deprecated=False)
870 self.set_hook(hook_name, getattr(hooks, hook_name), 100)
872
871
873 if self.display_page:
872 if self.display_page:
874 self.set_hook('show_in_pager', page.as_hook(page.display_page), 90)
873 self.set_hook('show_in_pager', page.as_hook(page.display_page), 90)
875
874
876 def set_hook(self,name,hook, priority=50, str_key=None, re_key=None,
875 def set_hook(self, name, hook, priority=50, str_key=None, re_key=None):
877 _warn_deprecated=True):
878 """set_hook(name,hook) -> sets an internal IPython hook.
876 """set_hook(name,hook) -> sets an internal IPython hook.
879
877
880 IPython exposes some of its internal API as user-modifiable hooks. By
878 IPython exposes some of its internal API as user-modifiable hooks. By
@@ -904,7 +902,7 b' class InteractiveShell(SingletonConfigurable):'
904 print("Warning! Hook '%s' is not one of %s" % \
902 print("Warning! Hook '%s' is not one of %s" % \
905 (name, IPython.core.hooks.__all__ ))
903 (name, IPython.core.hooks.__all__ ))
906
904
907 if _warn_deprecated and (name in IPython.core.hooks.deprecated):
905 if name in IPython.core.hooks.deprecated:
908 alternative = IPython.core.hooks.deprecated[name]
906 alternative = IPython.core.hooks.deprecated[name]
909 raise ValueError(
907 raise ValueError(
910 "Hook {} has been deprecated since IPython 5.0. Use {} instead.".format(
908 "Hook {} has been deprecated since IPython 5.0. Use {} instead.".format(
@@ -3247,7 +3245,6 b' class InteractiveShell(SingletonConfigurable):'
3247 outflag = True # happens in more places, so it's easier as default
3245 outflag = True # happens in more places, so it's easier as default
3248 try:
3246 try:
3249 try:
3247 try:
3250 self.hooks.pre_run_code_hook()
3251 if async_:
3248 if async_:
3252 await eval(code_obj, self.user_global_ns, self.user_ns)
3249 await eval(code_obj, self.user_global_ns, self.user_ns)
3253 else:
3250 else:
@@ -3631,9 +3628,6 b' class InteractiveShell(SingletonConfigurable):'
3631 del self.tempdirs
3628 del self.tempdirs
3632
3629
3633
3630
3634 # Run user hooks
3635 self.hooks.shutdown_hook()
3636
3637 def cleanup(self):
3631 def cleanup(self):
3638 self.restore_sys_module_state()
3632 self.restore_sys_module_state()
3639
3633
General Comments 0
You need to be logged in to leave comments. Login now