macOS / Tests (AppleSilicon) (push) Canceled after 0s
macOS / Tests (Intel) (push) Canceled after 0s
macOS / Build (AppleSilicon) (push) Canceled after 0s
macOS / Build (Intel) (push) Canceled after 0s
macOS / Publish the GitHub Release (push) Canceled after 0s
27 lines
588 B
Python
27 lines
588 B
Python
import json
|
|
from pathlib import Path
|
|
|
|
from lintunes import paths
|
|
|
|
|
|
def config_path() -> Path:
|
|
return paths.config_dir() / "config.json"
|
|
|
|
|
|
def load_config() -> dict:
|
|
path = config_path()
|
|
if path.exists():
|
|
try:
|
|
with open(path, "r", encoding="utf-8") as f:
|
|
return json.load(f)
|
|
except (ValueError, OSError):
|
|
pass
|
|
return {}
|
|
|
|
|
|
def save_config(config: dict):
|
|
path = config_path()
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
json.dump(config, f, indent=2)
|