from functools import lru_cache from pathlib import Path import json def get_app_root() -> Path: """Root di MyICR_Suite\ (parent di app\).""" return Path(__file__).parent.parent @lru_cache(maxsize=1) def load_config() -> dict: config_file = get_app_root() / "config.json" with open(config_file, "r", encoding="utf-8") as f: return json.load(f) def get_db_path(key: str) -> Path: """Risolve path relativo DB → assoluto rispetto a MyICR_Suite\.""" rel = load_config()["databases"][key] return get_app_root() / rel def is_debug() -> bool: return load_config().get("debug", False) def get_sync_config() -> dict: return load_config().get("shared_db_sync", {}) def get_version() -> str: return load_config().get("version", "")