File size: 652 Bytes
ed6bec6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# generator/dictionary_access.py
from pathlib import Path
from typing import Dict, Any
from .config import DICTIONARY_DIR
import json
def load_json(path: Path) -> Any:
with path.open("r", encoding="utf-8") as f:
return json.load(f)
def load_all_dictionaries() -> Dict[str, Any]:
"""
Loads all core Glyphic dictionaries into a single dict.
Keys will match filenames without extension, e.g. 'actions', 'actors', etc.
"""
dictionaries = {}
for path in DICTIONARY_DIR.glob("*.json"):
name = path.stem # e.g. actions.json -> "actions"
dictionaries[name] = load_json(path)
return dictionaries
|