INNER CODE UNIT · Python
load
KSwordDEV/KSword · tools/acceptance_record.py:34
def load() -> dict:
with io.open(RECORD, encoding="utf-8") as handle:
return json.load(handle)
def save(document: dict) -> None:
with io.open(RECORD, "w", encoding="utf-8", newline="\n") as handle:
json.dump(document, handle, ensure_ascii=False, indent=2)
handle.write("\n")
def find(document: dict, item_id: str) -> dict:
for item in document["acceptance_items"]:
if item["id"] == item_id:
return item
raise SystemExit("unknown acceptance id: %s" % item_id)