Show More
@@ -83,15 +83,15 b' def _safe_is_tarfile(path):' | |||
|
83 | 83 | return False |
|
84 | 84 | |
|
85 | 85 | |
|
86 | def check_nbextension(files, nbextensions=None): | |
|
86 | def check_nbextension(files, nbextensions_dir=None): | |
|
87 | 87 | """Check whether nbextension files have been installed |
|
88 | 88 | |
|
89 | 89 | files should be a list of relative paths within nbextensions. |
|
90 | 90 | |
|
91 | 91 | Returns True if all files are found, False if any are missing. |
|
92 | 92 | """ |
|
93 | if nbextensions: | |
|
94 | nbext = nbextensions | |
|
93 | if nbextensions_dir: | |
|
94 | nbext = nbextensions_dir | |
|
95 | 95 | else: |
|
96 | 96 | nbext = pjoin(get_ipython_dir(), u'nbextensions') |
|
97 | 97 | # make sure nbextensions dir exists |
@@ -105,10 +105,10 b' def check_nbextension(files, nbextensions=None):' | |||
|
105 | 105 | return all(os.path.exists(pjoin(nbext, f)) for f in files) |
|
106 | 106 | |
|
107 | 107 | |
|
108 | def install_nbextension(files, overwrite=False, symlink=False, user=False, prefix=None, nbextensions=None, verbose=1): | |
|
108 | def install_nbextension(files, overwrite=False, symlink=False, user=False, prefix=None, nbextensions_dir=None, verbose=1): | |
|
109 | 109 | """Install a Javascript extension for the notebook |
|
110 | 110 | |
|
111 |
Stages files and/or directories into |
|
|
111 | Stages files and/or directories into the nbextensions directory. | |
|
112 | 112 | By default, this compares modification time, and only stages files that need updating. |
|
113 | 113 | If `overwrite` is specified, matching files are purged before proceeding. |
|
114 | 114 | |
@@ -133,21 +133,21 b' def install_nbextension(files, overwrite=False, symlink=False, user=False, prefi' | |||
|
133 | 133 | prefix : str [optional] |
|
134 | 134 | Specify install prefix, if it should differ from default (e.g. /usr/local). |
|
135 | 135 | Will install to prefix/share/jupyter/nbextensions |
|
136 | nbextensions : str [optional] | |
|
136 | nbextensions_dir : str [optional] | |
|
137 | 137 | Specify absolute path of nbextensions directory explicitly. |
|
138 | 138 | verbose : int [default: 1] |
|
139 | 139 | Set verbosity level. The default is 1, where file actions are printed. |
|
140 | 140 | set verbose=2 for more output, or verbose=0 for silence. |
|
141 | 141 | """ |
|
142 | if sum(map(bool, [user, prefix, nbextensions])) > 1: | |
|
143 | raise ValueError("Cannot specify more than one of user, prefix, or nbextensions.") | |
|
142 | if sum(map(bool, [user, prefix, nbextensions_dir])) > 1: | |
|
143 | raise ValueError("Cannot specify more than one of user, prefix, or nbextensions_dir.") | |
|
144 | 144 | if user: |
|
145 | 145 | nbext = pjoin(get_ipython_dir(), u'nbextensions') |
|
146 | 146 | else: |
|
147 | 147 | if prefix: |
|
148 | 148 | nbext = pjoin(prefix, 'share', 'jupyter', 'nbextensions') |
|
149 | elif nbextensions: | |
|
150 | nbext = nbextensions | |
|
149 | elif nbextensions_dir: | |
|
150 | nbext = nbextensions_dir | |
|
151 | 151 | else: |
|
152 | 152 | nbext = SYSTEM_NBEXTENSIONS_INSTALL_DIR |
|
153 | 153 | # make sure nbextensions dir exists |
@@ -170,7 +170,7 b' def install_nbextension(files, overwrite=False, symlink=False, user=False, prefi' | |||
|
170 | 170 | print("downloading %s to %s" % (path, local_path)) |
|
171 | 171 | urlretrieve(path, local_path) |
|
172 | 172 | # now install from the local copy |
|
173 | install_nbextension(local_path, overwrite=overwrite, symlink=symlink, nbextensions=nbext, verbose=verbose) | |
|
173 | install_nbextension(local_path, overwrite=overwrite, symlink=symlink, nbextensions_dir=nbext, verbose=verbose) | |
|
174 | 174 | continue |
|
175 | 175 | |
|
176 | 176 | # handle archives |
@@ -262,7 +262,7 b" flags['s'] = flags['symlink']" | |||
|
262 | 262 | aliases = { |
|
263 | 263 | "ipython-dir" : "NBExtensionApp.ipython_dir", |
|
264 | 264 | "prefix" : "NBExtensionApp.prefix", |
|
265 | "nbextensions" : "NBExtensionApp.nbextensions", | |
|
265 | "nbextensions" : "NBExtensionApp.nbextensions_dir", | |
|
266 | 266 | } |
|
267 | 267 | |
|
268 | 268 | class NBExtensionApp(BaseIPythonApplication): |
@@ -291,14 +291,14 b' class NBExtensionApp(BaseIPythonApplication):' | |||
|
291 | 291 | symlink = Bool(False, config=True, help="Create symlinks instead of copying files") |
|
292 | 292 | user = Bool(False, config=True, help="Whether to do a user install") |
|
293 | 293 | prefix = Unicode('', config=True, help="Installation prefix") |
|
294 | nbextensions = Unicode('', config=True, help="Full path to nbextensions (probably use prefix or user)") | |
|
294 | nbextensions_dir = Unicode('', config=True, help="Full path to nbextensions dir (probably use prefix or user)") | |
|
295 | 295 | verbose = Enum((0,1,2), default_value=1, config=True, |
|
296 | 296 | help="Verbosity level" |
|
297 | 297 | ) |
|
298 | 298 | |
|
299 | 299 | def check_install(): |
|
300 | if sum(map(bool, [user, prefix, nbextensions])) > 1: | |
|
301 | raise TraitError("Cannot specify more than one of user, prefix, or nbextensions.") | |
|
300 | if sum(map(bool, [user, prefix, nbextensions_dir])) > 1: | |
|
301 | raise TraitError("Cannot specify more than one of user, prefix, or nbextensions_dir.") | |
|
302 | 302 | |
|
303 | 303 | def install_extensions(self): |
|
304 | 304 | install_nbextension(self.extra_args, |
@@ -307,7 +307,7 b' class NBExtensionApp(BaseIPythonApplication):' | |||
|
307 | 307 | verbose=self.verbose, |
|
308 | 308 | user=self.user, |
|
309 | 309 | prefix=self.prefix, |
|
310 | nbextensions=self.nbextensions, | |
|
310 | nbextensions_dir=self.nbextensions_dir, | |
|
311 | 311 | ) |
|
312 | 312 | |
|
313 | 313 | def start(self): |
General Comments 0
You need to be logged in to leave comments.
Login now