import json DTYPES = { "float": "ai", "int": "longin", "bool": "bi", "str": "stringin" } def load_data(fn): try: with open(fn) as f: data = json.load(f) except FileNotFoundError: data = {} return data def save_data(data, fn): with open(fn, "w") as f: json.dump(data, f) def mk_db(data, fn): with open(fn, "w") as f: for name, dtyp in data.items(): dtyp = DTYPES[dtyp] entry = f'record({dtyp}, "$(SYSTEM):{name}") {{}}' f.write(entry) f.write("\n")