MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / save_lexicon

Function save_lexicon

config/direction_lexicon.py:466–479  ·  view source on GitHub ↗
(lexicon: Dict[str, Any])

Source from the content-addressed store, hash-verified

464
465
466def 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
482def get_direction_entry(direction_key: str, lexicon: Optional[Dict[str, Any]] = None) -> Optional[Dict[str, Any]]:

Callers 2

add_direction_aliasFunction · 0.85
add_new_directionFunction · 0.85

Calls 2

_normalize_entryFunction · 0.85
normalize_direction_keyFunction · 0.85

Tested by

no test coverage detected