CoolFace
Apppublic

zhiyinya/AIStudioBuildWS

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
paths.py33 linesDownload Raw Back to utils
1import os2from functools import lru_cache3from pathlib import Path4 5 6@lru_cache(maxsize=1)7def project_root() -> Path:8    """9    Return the repository root so callers can build absolute paths that do not10    depend on the current working directory.11    """12    env_root = os.getenv("CAMOUFOX_PROJECT_ROOT")13    if env_root:14        return Path(env_root).expanduser().resolve()15 16    current = Path(__file__).resolve()17    for parent in current.parents:18        if (parent / "cookies").exists():19            return parent20 21    # Fallback to the original behaviour if the marker directory is missing.22    return current.parents[min(2, len(current.parents) - 1)]23 24 25def logs_dir() -> Path:26    """Root-level directory that stores log files and screenshots."""27    return project_root() / "logs"28 29 30def cookies_dir() -> Path:31    """Root-level directory that stores persistent cookie JSON files."""32    return project_root() / "cookies"33