()
| 45 | |
| 46 | |
| 47 | def _load() -> dict: |
| 48 | try: |
| 49 | data = json.loads(_SETTINGS_PATH.read_text(encoding="utf-8")) |
| 50 | if isinstance(data, dict): |
| 51 | return data |
| 52 | except FileNotFoundError: |
| 53 | pass # no settings file yet — first run; use defaults |
| 54 | except Exception: |
| 55 | # Corrupt/unreadable file: fall back to defaults rather than crash. |
| 56 | _log.warning("could not read settings from %s", _SETTINGS_PATH, exc_info=True) |
| 57 | return {} |
| 58 | |
| 59 | |
| 60 | def _ensure() -> dict: |