eight-hourr/backend/paths.py

21 lines
654 B
Python
Raw Permalink Normal View History

2026-07-17 06:55:36 +00:00
from __future__ import annotations
import os
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parent.parent
_PTS_DATA_DIR = os.environ.get("PTS_DATA_DIR", "").strip()
DATA_DIR = Path(_PTS_DATA_DIR) if _PTS_DATA_DIR else Path(__file__).resolve().parent / "data"
DATA_DIR.mkdir(parents=True, exist_ok=True)
EXTENSION_DIR = ROOT_DIR / "extension"
def get_env_files() -> tuple[str, ...]:
candidates = [DATA_DIR / ".env", ROOT_DIR / ".env"]
return tuple(str(path) for path in candidates if path.exists())
def get_dates_file_path() -> Path:
if _PTS_DATA_DIR:
return DATA_DIR / "dates.txt"
return ROOT_DIR / "dates.txt"