From afe9b5c0562ae5e8ae167389dac8555a2182af07 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Wed, 29 Oct 2014 20:02:52 +0300 Subject: [PATCH] refactoring in pydev console --- .../pydev/{import_hook.py => pydev_import_hook.py} | 0 .../helpers/pydev/pydev_ipython/matplotlibtools.py | 13 ------------- python/helpers/pydev/pydevconsole.py | 9 +++++---- 3 files changed, 5 insertions(+), 17 deletions(-) rename python/helpers/pydev/{import_hook.py => pydev_import_hook.py} (100%) diff --git a/python/helpers/pydev/import_hook.py b/python/helpers/pydev/pydev_import_hook.py similarity index 100% rename from python/helpers/pydev/import_hook.py rename to python/helpers/pydev/pydev_import_hook.py diff --git a/python/helpers/pydev/pydev_ipython/matplotlibtools.py b/python/helpers/pydev/pydev_ipython/matplotlibtools.py index b11cd0c19e99..31a7f06fb994 100644 --- a/python/helpers/pydev/pydev_ipython/matplotlibtools.py +++ b/python/helpers/pydev/pydev_ipython/matplotlibtools.py @@ -1,6 +1,5 @@ import sys -from import_hook import import_hook_manager backends = {'tk': 'TkAgg', 'gtk': 'GTKAgg', @@ -87,10 +86,6 @@ def activate_matplotlib(interpreter): return activate_matplotlib_inner -def init_matplotlib(interpreter): - import_hook_manager.add_module_name("matplotlib", activate_matplotlib(interpreter)) - - def flag_calls(func): """Wrap a function to detect and flag when it gets called. @@ -127,17 +122,9 @@ def activate_pylab(): pylab.draw_if_interactive = flag_calls(pylab.draw_if_interactive) -def init_pylab(): - import_hook_manager.add_module_name("pylab", activate_pylab) - - def activate_pyplot(): pyplot = sys.modules['matplotlib.pyplot'] pyplot.show._needmain = False # We need to detect at runtime whether show() is called by the user. # For this, we wrap it into a decorator which adds a 'called' flag. pyplot.draw_if_interactive = flag_calls(pyplot.draw_if_interactive) - - -def init_pyplot(): - import_hook_manager.add_module_name("pyplot", activate_pyplot) \ No newline at end of file diff --git a/python/helpers/pydev/pydevconsole.py b/python/helpers/pydev/pydevconsole.py index b38847a82925..f48f975f703f 100644 --- a/python/helpers/pydev/pydevconsole.py +++ b/python/helpers/pydev/pydevconsole.py @@ -171,10 +171,11 @@ def process_exec_queue(interpreter): set_return_control_callback(return_control) - from pydev_ipython.matplotlibtools import init_matplotlib, init_pylab, init_pyplot - init_matplotlib(interpreter) - init_pylab() - init_pyplot() + from pydev_import_hook import import_hook_manager + from pydev_ipython.matplotlibtools import activate_matplotlib, activate_pylab, activate_pyplot + import_hook_manager.add_module_name("matplotlib", activate_matplotlib(interpreter)) + import_hook_manager.add_module_name("pylab", activate_pylab) + import_hook_manager.add_module_name("pyplot", activate_pyplot) while 1: # Running the request may have changed the inputhook in use