diff options
| author | Trial97 <alexandru.tripon97@gmail.com> | 2024-04-27 23:19:54 +0300 |
|---|---|---|
| committer | Trial97 <alexandru.tripon97@gmail.com> | 2024-04-27 23:19:54 +0300 |
| commit | 2eecce37d3e8f16eeae1fbe51eb39f577e30b17b (patch) | |
| tree | f48e24203446ada81c736d3eb7ebc6a54c2fb320 /meta/common/__init__.py | |
| parent | d996dc2a20c8664b03259cead7c888fd85d9848c (diff) | |
| parent | d215ec0383ce130d2244a3bfe4567d56f3982701 (diff) | |
| download | Project-Tick-2eecce37d3e8f16eeae1fbe51eb39f577e30b17b.tar.gz Project-Tick-2eecce37d3e8f16eeae1fbe51eb39f577e30b17b.zip | |
Merge branch 'main' of https://github.com/PrismLauncher/meta into javas
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
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"}) |
