Load YAML config from config_path, merged with DEFAULT_CONFIG. If the file does not exist, returns a copy of the defaults.
(config_path: Path)
| 244 | |
| 245 | |
| 246 | def load_config(config_path: Path) -> dict[str, Any]: |
| 247 | """Load YAML config from config_path, merged with DEFAULT_CONFIG. |
| 248 | |
| 249 | If the file does not exist, returns a copy of the defaults. |
| 250 | """ |
| 251 | config = dict(DEFAULT_CONFIG) |
| 252 | if config_path.exists(): |
| 253 | with config_path.open("r", encoding="utf-8") as fh: |
| 254 | data = yaml.safe_load(fh) or {} |
| 255 | config.update(data) |
| 256 | return config |
| 257 | |
| 258 | |
| 259 | def save_config(config_path: Path, config: dict) -> None: |
no outgoing calls