(lexicon: Dict[str, Any])
| 464 | |
| 465 | |
| 466 | def save_lexicon(lexicon: Dict[str, Any]) -> bool: |
| 467 | try: |
| 468 | normalized = { |
| 469 | key: _normalize_entry(key, value) |
| 470 | for key, value in (lexicon or {}).items() |
| 471 | if normalize_direction_key(key) |
| 472 | } |
| 473 | LEXICON_PATH.parent.mkdir(parents=True, exist_ok=True) |
| 474 | with LEXICON_PATH.open("w", encoding="utf-8") as handle: |
| 475 | json.dump(normalized, handle, indent=2, ensure_ascii=False, sort_keys=True) |
| 476 | return True |
| 477 | except Exception as exc: |
| 478 | print(f"Failed to save direction lexicon: {exc}") |
| 479 | return False |
| 480 | |
| 481 | |
| 482 | def get_direction_entry(direction_key: str, lexicon: Optional[Dict[str, Any]] = None) -> Optional[Dict[str, Any]]: |
no test coverage detected