Files
lintunes/lintunes/config.py
T
travandClaude Opus 4.8 f6d35fa594 Import existing LinTunes project
Snapshot of the existing codebase before working through the TASKS.md
backlog. Real library data (data/) and the iTunes import fixture
(itunes-test-library/) are gitignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 21:12:01 -04:00

27 lines
650 B
Python

import json
import os
from pathlib import Path
def config_path() -> Path:
base = os.environ.get("XDG_CONFIG_HOME", str(Path.home() / ".config"))
return Path(base) / "lintunes" / "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)