"""Known-positive reader for the file-type gate: answers every query from the frozen pairs file (the fasit itself). It reads no source file. A GREEN gate with it shows that the pairs, the manifest and the gate's scoring agree; it says nothing about any real reader. Usage: python3 gates/stubs/fasit_reader.py {file} {queries} """ from __future__ import annotations import json import sys from pathlib import Path def main() -> int: queries = json.loads(Path(sys.argv[2]).read_text(encoding="utf-8")) key = {p["id"]: p for p in json.loads(Path(sys.argv[3]).read_text(encoding="utf-8"))["pairs"]} answers = [{"id": q["id"], "found": [{"locator": key[q["id"]]["locator"], "hidden": key[q["id"]]["hidden"]}]} for q in queries["queries"] if q["id"] in key] print(json.dumps({"answers": answers})) return 0 if __name__ == "__main__": sys.exit(main())