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