data-vault/scripts/helpers/misc.py
2025-02-26 18:53:06 -05:00

20 lines
No EOL
542 B
Python

import json
import os
from pathlib import Path
CONFIG_PATH = (os.environ.get("XDG_CONFIG_HOME") or (Path.home() / ".config")) / "data-vault" / "config.json"
def load_config():
"""Load configuration from config file."""
if CONFIG_PATH.exists():
config = json.loads(CONFIG_PATH.read_text())
else:
config = {}
return config
def json_default(obj):
"""Default JSON encoder for serializing datetime objects."""
if hasattr(obj, 'isoformat'):
return obj.isoformat()
return super().default(obj)