Show More
@@ -13,6 +13,7 b' from importlib import import_module' | |||||
13 |
|
13 | |||
14 | from traitlets.config.configurable import Configurable |
|
14 | from traitlets.config.configurable import Configurable | |
15 | from IPython.utils.path import ensure_dir_exists, compress_user |
|
15 | from IPython.utils.path import ensure_dir_exists, compress_user | |
|
16 | from IPython.utils.decorators import undoc | |||
16 | from traitlets import Instance |
|
17 | from traitlets import Instance | |
17 |
|
18 | |||
18 | try: |
|
19 | try: | |
@@ -145,35 +146,12 b' class ExtensionManager(Configurable):' | |||||
145 | mod.unload_ipython_extension(self.shell) |
|
146 | mod.unload_ipython_extension(self.shell) | |
146 | return True |
|
147 | return True | |
147 |
|
148 | |||
|
149 | @undoc | |||
148 | def install_extension(self, url, filename=None): |
|
150 | def install_extension(self, url, filename=None): | |
149 | """Download and install an IPython extension. |
|
151 | """ | |
150 |
|
152 | Deprecated. | ||
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. |
|
|||
156 | """ |
|
153 | """ | |
157 | # Ensure the extension directory exists |
|
154 | # Ensure the extension directory exists | |
158 | ensure_dir_exists(self.ipython_extension_dir) |
|
155 | raise DeprecationWarning( | |
159 |
|
156 | '`install_extension` and the `install_ext` magic have been deprecated since IPython 4.0' | ||
160 | if os.path.isfile(url): |
|
157 | 'Use pip or other package managers to manage ipython extensions.') | |
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 |
|
General Comments 0
You need to be logged in to leave comments.
Login now