# Read a values file and print what it asks for.
# Run: python read_values.py my-values.json
import json
import sys

with open(sys.argv[1], encoding="utf-8") as f:
    file = json.load(f)

if file.get("format") != "open-values-passport":
    sys.exit("this is not a values file")
major, minor = (str(file["version"]).split(".") + ["", ""])[:2]
if (major, minor) != ("0", "1"):
    sys.exit(f"version {file['version']} is newer than this reader")

# A reader of 0.1 ignores fields it does not know, so a file with more in it still reads.
for value, weight in file["values"].items():
    print(f"{value:<10} {weight} of 5")
