Download env/lib/python3.12/site-packages/cached_path/common.py from laitkor/F5-TTS: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/laitkor/F5-TTS/resolve/main/env/lib/python3.12/site-packages/cached_path/common.py
- Command line
-
hf download hf://spaces/laitkor/F5-TTS/env/lib/python3.12/site-packages/cached_path/common.py
-
curl -L -o common.py https://huggingface.co/spaces/laitkor/F5-TTS/resolve/main/env/lib/python3.12/site-packages/cached_path/common.py
1.11 kB
| import os | |
| from os import PathLike | |
| from pathlib import Path | |
| from typing import Tuple, Union | |
| from urllib.parse import urlparse | |
| PathOrStr = Union[str, PathLike] | |
| CACHE_DIRECTORY: PathOrStr = Path( | |
| os.getenv("CACHED_PATH_CACHE_ROOT", Path.home() / ".cache" / "cached_path") | |
| ) | |
| """ | |
| The default global cache directory. | |
| """ | |
| def _split_cloud_path(url: str, provider: str) -> Tuple[str, str]: | |
| """Split a full s3 path into the bucket name and path.""" | |
| parsed = urlparse(url) | |
| if not parsed.netloc or not parsed.path: | |
| raise ValueError("bad {} path {}".format(provider, url)) | |
| bucket_name = parsed.netloc | |
| provider_path = parsed.path | |
| # Remove '/' at beginning of path. | |
| if provider_path.startswith("/"): | |
| provider_path = provider_path[1:] | |
| return bucket_name, provider_path | |
| def set_cache_dir(cache_dir: PathOrStr) -> None: | |
| """ | |
| Set the global default cache directory. | |
| """ | |
| global CACHE_DIRECTORY | |
| CACHE_DIRECTORY = Path(cache_dir) | |
| def get_cache_dir() -> Path: | |
| """ | |
| Get the global default cache directory. | |
| """ | |
| return Path(CACHE_DIRECTORY) | |