File size: 1,221 Bytes
9bc957e
7a1d414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Path configuration for sdgen.

All filesystem paths are resolved relative to the project root.
The project root is detected by walking upward until a marker
file (e.g., `pyproject.toml` or `.git`) is found.
"""

from __future__ import annotations

from pathlib import Path


def _detect_project_root() -> Path:
    """Return the project root by scanning upward for a marker file."""
    current = Path(__file__).resolve()

    for parent in current.parents:
        if (parent / "pyproject.toml").exists() or (parent / ".git").exists():
            return parent

    # Fallback: use the last resolved parent
    return current.parents[-1]


PROJECT_ROOT: Path = _detect_project_root()

ASSETS_ROOT: Path = PROJECT_ROOT / "src" / "assets"
ASSETS_ROOT.mkdir(parents=True, exist_ok=True)

HISTORY_ROOT: Path = ASSETS_ROOT / "history"
HISTORY_ENTRIES_DIR: Path = HISTORY_ROOT / "entries"
HISTORY_THUMBS_DIR: Path = HISTORY_ROOT / "thumbnails"
HISTORY_FULL_DIR: Path = HISTORY_ROOT / "full"

for p in [
    HISTORY_ROOT,
    HISTORY_ENTRIES_DIR,
    HISTORY_THUMBS_DIR,
    HISTORY_FULL_DIR,
]:
    p.mkdir(parents=True, exist_ok=True)

LOGS_ROOT: Path = PROJECT_ROOT / "logs"
LOGS_ROOT.mkdir(parents=True, exist_ok=True)