Show More
@@ -13,6 +13,7 b' from importlib import import_module' | |||
|
13 | 13 | |
|
14 | 14 | from traitlets.config.configurable import Configurable |
|
15 | 15 | from IPython.utils.path import ensure_dir_exists, compress_user |
|
16 | from IPython.utils.decorators import undoc | |
|
16 | 17 | from traitlets import Instance |
|
17 | 18 | |
|
18 | 19 | try: |
@@ -145,35 +146,12 b' class ExtensionManager(Configurable):' | |||
|
145 | 146 | mod.unload_ipython_extension(self.shell) |
|
146 | 147 | return True |
|
147 | 148 | |
|
149 | @undoc | |
|
148 | 150 | def install_extension(self, url, filename=None): |
|
149 | """Download and install an IPython extension. | |
|
150 | ||
|
151 | If filename is given, the file will be so named (inside the extension | |
|
152 | directory). Otherwise, the name from the URL will be used. The file must | |
|
153 | have a .py or .zip extension; otherwise, a ValueError will be raised. | |
|
154 | ||
|
155 | Returns the full path to the installed file. | |
|
151 | """ | |
|
152 | Deprecated. | |
|
156 | 153 | """ |
|
157 | 154 | # Ensure the extension directory exists |
|
158 | ensure_dir_exists(self.ipython_extension_dir) | |
|
159 | ||
|
160 | if os.path.isfile(url): | |
|
161 | src_filename = os.path.basename(url) | |
|
162 | copy = copyfile | |
|
163 | else: | |
|
164 | # Deferred imports | |
|
165 | from urllib.parse import urlparse | |
|
166 | from urllib.request import urlretrieve | |
|
167 | src_filename = urlparse(url).path.split('/')[-1] | |
|
168 | copy = urlretrieve | |
|
169 | ||
|
170 | if filename is None: | |
|
171 | filename = src_filename | |
|
172 | if os.path.splitext(filename)[1] not in ('.py', '.zip'): | |
|
173 | raise ValueError("The file must have a .py or .zip extension", filename) | |
|
174 | ||
|
175 | filename = os.path.join(self.ipython_extension_dir, filename) | |
|
176 | copy(url, filename) | |
|
177 | return filename | |
|
178 | ||
|
179 | ||
|
155 | raise DeprecationWarning( | |
|
156 | '`install_extension` and the `install_ext` magic have been deprecated since IPython 4.0' | |
|
157 | 'Use pip or other package managers to manage ipython extensions.') |
General Comments 0
You need to be logged in to leave comments.
Login now