Reload an IPython extension by calling reload. If the module has not been loaded before, :meth:`InteractiveShell.load_extension` is called. Otherwise :func:`reload` is called and then the :func:`load_ipython_extension` function of the module, if it exists is called.
(self, module_str)
| 110 | return "no unload function" |
| 111 | |
| 112 | def reload_extension(self, module_str): |
| 113 | """Reload an IPython extension by calling reload. |
| 114 | |
| 115 | If the module has not been loaded before, |
| 116 | :meth:`InteractiveShell.load_extension` is called. Otherwise |
| 117 | :func:`reload` is called and then the :func:`load_ipython_extension` |
| 118 | function of the module, if it exists is called. |
| 119 | """ |
| 120 | from IPython.utils.syspathcontext import prepended_to_syspath |
| 121 | |
| 122 | if (module_str in self.loaded) and (module_str in sys.modules): |
| 123 | self.unload_extension(module_str) |
| 124 | mod = sys.modules[module_str] |
| 125 | with prepended_to_syspath(self.ipython_extension_dir): |
| 126 | reload(mod) |
| 127 | if self._call_load_ipython_extension(mod): |
| 128 | self.loaded.add(module_str) |
| 129 | else: |
| 130 | self.load_extension(module_str) |
| 131 | |
| 132 | def _call_load_ipython_extension(self, mod): |
| 133 | if hasattr(mod, 'load_ipython_extension'): |