##// END OF EJS Templates
Merge pull request #13194 from meysam81/meysam/remove-deprecated-stuff...
Matthias Bussonnier -
r26878:796ce7f0 merge
parent child Browse files
Show More
@@ -0,0 +1,8 b''
1 Remove Deprecated Stuff
2 ================================
3
4 We no longer need to add `extensions` to the PYTHONPATH because that is being
5 handled by `load_extension`.
6
7 We are also removing Cythonmagic, sympyprinting and rmagic as they are now in
8 other packages and no longer need to be inside IPython.
@@ -41,11 +41,6 b' See IPython `README.rst` file for more information:'
41 41
42 42 """)
43 43
44 # Make it easy to import extensions - they are always directly on pythonpath.
45 # Therefore, non-IPython modules can be added to extensions directory.
46 # This should probably be in ipapp.py.
47 sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))
48
49 44 #-----------------------------------------------------------------------------
50 45 # Setup the top level names
51 46 #-----------------------------------------------------------------------------
@@ -19,6 +19,9 b' from traitlets import Instance'
19 19 # Main class
20 20 #-----------------------------------------------------------------------------
21 21
22 BUILTINS_EXTS = {"storemagic": False, "autoreload": False}
23
24
22 25 class ExtensionManager(Configurable):
23 26 """A class to manage IPython extensions.
24 27
@@ -62,13 +65,22 b' class ExtensionManager(Configurable):'
62 65 def _on_ipython_dir_changed(self, change):
63 66 ensure_dir_exists(self.ipython_extension_dir)
64 67
65 def load_extension(self, module_str):
68 def load_extension(self, module_str: str):
66 69 """Load an IPython extension by its module name.
67 70
68 71 Returns the string "already loaded" if the extension is already loaded,
69 72 "no load function" if the module doesn't have a load_ipython_extension
70 73 function, or None if it succeeded.
71 74 """
75 try:
76 return self._load_extension(module_str)
77 except ModuleNotFoundError:
78 if module_str in BUILTINS_EXTS:
79 BUILTINS_EXTS[module_str] = True
80 return self._load_extension("IPython.extensions." + module_str)
81 raise
82
83 def _load_extension(self, module_str: str):
72 84 if module_str in self.loaded:
73 85 return "already loaded"
74 86
@@ -89,7 +101,7 b' class ExtensionManager(Configurable):'
89 101 else:
90 102 return "no load function"
91 103
92 def unload_extension(self, module_str):
104 def unload_extension(self, module_str: str):
93 105 """Unload an IPython extension by its module name.
94 106
95 107 This function looks up the extension's name in ``sys.modules`` and
@@ -99,6 +111,8 b' class ExtensionManager(Configurable):'
99 111 a function to unload itself, "not loaded" if the extension isn't loaded,
100 112 otherwise None.
101 113 """
114 if BUILTINS_EXTS.get(module_str, False) is True:
115 module_str = "IPython.extensions." + module_str
102 116 if module_str not in self.loaded:
103 117 return "not loaded"
104 118
@@ -109,7 +123,7 b' class ExtensionManager(Configurable):'
109 123 else:
110 124 return "no unload function"
111 125
112 def reload_extension(self, module_str):
126 def reload_extension(self, module_str: str):
113 127 """Reload an IPython extension by calling reload.
114 128
115 129 If the module has not been loaded before,
@@ -119,6 +133,9 b' class ExtensionManager(Configurable):'
119 133 """
120 134 from IPython.utils.syspathcontext import prepended_to_syspath
121 135
136 if BUILTINS_EXTS.get(module_str, False) is True:
137 module_str = "IPython.extensions." + module_str
138
122 139 if (module_str in self.loaded) and (module_str in sys.modules):
123 140 self.unload_extension(module_str)
124 141 mod = sys.modules[module_str]
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now