INNER CODE UNIT · Python

load_json

nielsfaber/scheduler-card · scripts/cleanup_translations.py:29

def load_json(path: str) -> dict:
    with open(path, encoding="utf-8") as f:
        return json.load(f)


def cleanup(reference: dict, translation: dict) -> tuple[dict, int, int]:
    """Return *(cleaned, removed_count, added_count)*.

    *cleaned* contains all keys from *reference*, ordered exactly like
    *reference*.  Keys missing in *translation* are added using the English
    value as a fallback.  *removed_count* is the number of keys discarded from
    *translation*.  *added_count* is the number of leaf keys added as English
    fallback.
    """
    cleaned: dict = {}
    removed = 0
    added = 0

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…