diff options
Diffstat (limited to 'meta/common/__init__.py')
| -rw-r--r-- | meta/common/__init__.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/meta/common/__init__.py b/meta/common/__init__.py index 585a3e12f7..d7ee49ac4a 100644 --- a/meta/common/__init__.py +++ b/meta/common/__init__.py @@ -1,4 +1,5 @@ import os +import os.path import datetime from urllib.parse import urlparse from typing import Any, Optional @@ -17,25 +18,25 @@ def serialize_datetime(dt: datetime.datetime): return dt.isoformat() +def cache_path(): + if "META_CACHE_DIR" in os.environ: + return os.environ["META_CACHE_DIR"] + return "cache" + + def launcher_path(): - if "LAUNCHER_DIR" in os.environ: - return os.environ["LAUNCHER_DIR"] + if "META_LAUNCHER_DIR" in os.environ: + return os.environ["META_LAUNCHER_DIR"] return "launcher" def upstream_path(): - if "UPSTREAM_DIR" in os.environ: - return os.environ["UPSTREAM_DIR"] + if "META_UPSTREAM_DIR" in os.environ: + return os.environ["META_UPSTREAM_DIR"] return "upstream" -def static_path(): - if "STATIC_DIR" in os.environ: - return os.environ["STATIC_DIR"] - return "static" - - -def ensure_upstream_dir(path: str): +def ensure_upstream_dir(path): path = os.path.join(upstream_path(), path) if not os.path.exists(path): os.makedirs(path) @@ -79,7 +80,7 @@ def merge_dict(base: dict[Any, Any], overlay: dict[Any, Any]): def default_session(): - forever_cache = FileCache("caches/http_cache", forever=True) + forever_cache = FileCache(os.path.join(cache_path(), "http_cache"), forever=True) sess = CacheControl(requests.Session(), forever_cache) sess.headers.update({"User-Agent": "PrismLauncherMeta/1.0"}) |
