##// END OF EJS Templates
Add a set to track what extensions are loaded.
Thomas Kluyver -
Show More
@@ -63,6 +63,7 b' class ExtensionManager(Configurable):'
63 63 self.shell.on_trait_change(
64 64 self._on_ipython_dir_changed, 'ipython_dir'
65 65 )
66 self.loaded = set()
66 67
67 68 def __del__(self):
68 69 self.shell.on_trait_change(
@@ -89,7 +90,8 b' class ExtensionManager(Configurable):'
89 90 with prepended_to_syspath(self.ipython_extension_dir):
90 91 __import__(module_str)
91 92 mod = sys.modules[module_str]
92 return self._call_load_ipython_extension(mod)
93 if self._call_load_ipython_extension(mod):
94 self.loaded.add(module_str)
93 95
94 96 def unload_extension(self, module_str):
95 97 """Unload an IPython extension by its module name.
@@ -99,7 +101,8 b' class ExtensionManager(Configurable):'
99 101 """
100 102 if module_str in sys.modules:
101 103 mod = sys.modules[module_str]
102 self._call_unload_ipython_extension(mod)
104 if self._call_unload_ipython_extension(mod):
105 self.loaded.discard(module_str)
103 106
104 107 def reload_extension(self, module_str):
105 108 """Reload an IPython extension by calling reload.
@@ -121,11 +124,13 b' class ExtensionManager(Configurable):'
121 124
122 125 def _call_load_ipython_extension(self, mod):
123 126 if hasattr(mod, 'load_ipython_extension'):
124 return mod.load_ipython_extension(self.shell)
127 mod.load_ipython_extension(self.shell)
128 return True
125 129
126 130 def _call_unload_ipython_extension(self, mod):
127 131 if hasattr(mod, 'unload_ipython_extension'):
128 return mod.unload_ipython_extension(self.shell)
132 mod.unload_ipython_extension(self.shell)
133 return True
129 134
130 135 def install_extension(self, url, filename=None):
131 136 """Download and install an IPython extension.
@@ -59,7 +59,7 b' class ExtensionMagics(Magics):'
59 59 """Load an IPython extension by its module name."""
60 60 if not module_str:
61 61 raise UsageError('Missing module name.')
62 return self.shell.extension_manager.load_extension(module_str)
62 self.shell.extension_manager.load_extension(module_str)
63 63
64 64 @line_magic
65 65 def unload_ext(self, module_str):
General Comments 0
You need to be logged in to leave comments. Login now