File size: 421 Bytes
1108401 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from pathlib import Path
import os, yaml, json
def load_config(path='config.yaml'):
p = Path(path)
if not p.exists():
raise FileNotFoundError(f'Config not found: {path}')
return yaml.safe_load(p.read_text())
def ensure_dir(path):
os.makedirs(path, exist_ok=True)
def save_json(obj, path):
ensure_dir(Path(path).parent)
Path(path).write_text(json.dumps(obj, indent=2), encoding='utf-8')
|