##// END OF EJS Templates
Refactor the logic to get the nbextension directory...
Jason Grout -
Show More
@@ -90,17 +90,30 b' def _safe_is_tarfile(path):'
90 90 return False
91 91
92 92
93 def check_nbextension(files, nbextensions_dir=None):
93 def _get_nbext_dir(nbextensions_dir=None, user=False, prefix=None):
94 """Return the nbextension directory specified"""
95 if sum(map(bool, [user, prefix, nbextensions_dir])) > 1:
96 raise ArgumentConflict("Cannot specify more than one of user, prefix, or nbextensions_dir.")
97 if user:
98 nbext = pjoin(get_ipython_dir(), u'nbextensions')
99 else:
100 if prefix:
101 nbext = pjoin(prefix, 'share', 'jupyter', 'nbextensions')
102 elif nbextensions_dir:
103 nbext = nbextensions_dir
104 else:
105 nbext = SYSTEM_NBEXTENSIONS_INSTALL_DIR
106 return nbext
107
108
109 def check_nbextension(files, nbextensions_dir=None, user=False, prefix=None):
94 110 """Check whether nbextension files have been installed
95 111
96 112 files should be a list of relative paths within nbextensions.
97 113
98 114 Returns True if all files are found, False if any are missing.
99 115 """
100 if nbextensions_dir:
101 nbext = nbextensions_dir
102 else:
103 nbext = pjoin(get_ipython_dir(), u'nbextensions')
116 nbext = _get_nbext_dir(nbextensions_dir, user, prefix)
104 117 # make sure nbextensions dir exists
105 118 if not os.path.exists(nbext):
106 119 return False
@@ -147,17 +160,7 b' def install_nbextension(files, overwrite=False, symlink=False, user=False, prefi'
147 160 Set verbosity level. The default is 1, where file actions are printed.
148 161 set verbose=2 for more output, or verbose=0 for silence.
149 162 """
150 if sum(map(bool, [user, prefix, nbextensions_dir])) > 1:
151 raise ArgumentConflict("Cannot specify more than one of user, prefix, or nbextensions_dir.")
152 if user:
153 nbext = pjoin(get_ipython_dir(), u'nbextensions')
154 else:
155 if prefix:
156 nbext = pjoin(prefix, 'share', 'jupyter', 'nbextensions')
157 elif nbextensions_dir:
158 nbext = nbextensions_dir
159 else:
160 nbext = SYSTEM_NBEXTENSIONS_INSTALL_DIR
163 nbext = _get_nbext_dir(nbextensions_dir, user, prefix)
161 164 # make sure nbextensions dir exists
162 165 ensure_dir_exists(nbext)
163 166
General Comments 0
You need to be logged in to leave comments. Login now