31 lines
877 B
Python
31 lines
877 B
Python
|
|
"""Where the TUI keeps its files. `DIORA_TUI_HOME` moves all of it into one folder (tests, the
|
||
|
|
smoke script and anyone who wants a second account side by side use it); platformdirs' own
|
||
|
|
answer on Windows doesn't follow the LOCALAPPDATA/APPDATA environment variables."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import os
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from platformdirs import user_cache_dir, user_config_dir, user_data_dir
|
||
|
|
|
||
|
|
|
||
|
|
def _home() -> Path | None:
|
||
|
|
h = os.environ.get("DIORA_TUI_HOME")
|
||
|
|
return Path(h) if h else None
|
||
|
|
|
||
|
|
|
||
|
|
def data_dir() -> Path:
|
||
|
|
h = _home()
|
||
|
|
return h / "data" if h else Path(user_data_dir("diora-tui", "diora"))
|
||
|
|
|
||
|
|
|
||
|
|
def config_dir() -> Path:
|
||
|
|
h = _home()
|
||
|
|
return h / "config" if h else Path(user_config_dir("diora-tui", "diora"))
|
||
|
|
|
||
|
|
|
||
|
|
def cache_dir() -> Path:
|
||
|
|
h = _home()
|
||
|
|
return h / "cache" if h else Path(user_cache_dir("diora-tui", "diora"))
|