"""Minimal .env loader so local runs match the systemd EnvironmentFile. Never overwrites variables already set in the environment.""" import os import pathlib def load(path='.env'): file = pathlib.Path(path) if not file.is_file(): return for line in file.read_text().splitlines(): line = line.strip() if not line or line.startswith('#') or '=' not in line: continue key, _, value = line.partition('=') os.environ.setdefault(key.strip(), value.strip().strip('\'"')) def env_int(name, default): try: return int(os.environ.get(name, default)) except (TypeError, ValueError): return default