Return a list of directories to search for data files JUPYTER_PATH environment variable has highest priority. If the JUPYTER_PREFER_ENV_PATH environment variable is set, the environment-level directories will have priority over user-level directories. If the Python
(*subdirs)
| 115 | ENV_JUPYTER_PATH = [__vscode_os.path.join(__vscode_sys.prefix, "share", "jupyter")] |
| 116 | |
| 117 | def jupyter_path(*subdirs): |
| 118 | """Return a list of directories to search for data files |
| 119 | |
| 120 | JUPYTER_PATH environment variable has highest priority. |
| 121 | |
| 122 | If the JUPYTER_PREFER_ENV_PATH environment variable is set, the environment-level |
| 123 | directories will have priority over user-level directories. |
| 124 | |
| 125 | If the Python __vscode_site.ENABLE_USER_SITE variable is True, we also add the |
| 126 | appropriate Python user site subdirectory to the user-level directories. |
| 127 | |
| 128 | |
| 129 | If ``*subdirs`` are given, that subdirectory will be added to each element. |
| 130 | |
| 131 | Examples: |
| 132 | |
| 133 | >>> jupyter_path() |
| 134 | ['~/.local/jupyter', '/usr/local/share/jupyter'] |
| 135 | >>> jupyter_path('kernels') |
| 136 | ['~/.local/jupyter/kernels', '/usr/local/share/jupyter/kernels'] |
| 137 | """ |
| 138 | |
| 139 | paths: list = [] |
| 140 | |
| 141 | # highest priority is explicit environment variable |
| 142 | if __vscode_os.environ.get("JUPYTER_PATH"): |
| 143 | paths.extend( |
| 144 | p.rstrip(__vscode_os.sep) |
| 145 | for p in __vscode_os.environ["JUPYTER_PATH"].split(__vscode_os.pathsep) |
| 146 | ) |
| 147 | |
| 148 | # Next is environment or user, depending on the JUPYTER_PREFER_ENV_PATH flag |
| 149 | user = [jupyter_data_dir()] |
| 150 | if __vscode_site.ENABLE_USER_SITE: |
| 151 | # Check if __vscode_site.getuserbase() exists to be compatible with virtualenv, |
| 152 | # which often does not have this method. |
| 153 | if hasattr(__vscode_site, "getuserbase"): |
| 154 | userbase = __vscode_site.getuserbase() |
| 155 | else: |
| 156 | userbase = __vscode_site.USER_BASE |
| 157 | |
| 158 | if userbase: |
| 159 | userdir = __vscode_os.path.join(userbase, "share", "jupyter") |
| 160 | if userdir not in user: |
| 161 | user.append(userdir) |
| 162 | |
| 163 | env = [p for p in ENV_JUPYTER_PATH if p not in SYSTEM_JUPYTER_PATH] |
| 164 | |
| 165 | if envset("JUPYTER_PREFER_ENV_PATH"): |
| 166 | paths.extend(env) |
| 167 | paths.extend(user) |
| 168 | else: |
| 169 | paths.extend(user) |
| 170 | paths.extend(env) |
| 171 | |
| 172 | # finally, system |
| 173 | paths.extend(SYSTEM_JUPYTER_PATH) |
| 174 |
no test coverage detected