from __future__ import annotations import sys from pathlib import Path import yaml ROOT = Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) def load_config(path: str | Path) -> dict: path = Path(path) with path.open("r", encoding="utf-8") as handle: config = yaml.safe_load(handle) config["_config_dir"] = str(path.resolve().parent) return config def resolve_path(value: str, config: dict) -> Path: path = Path(value).expanduser() if path.is_absolute(): return path return (Path(config["_config_dir"]).parent / path).resolve()