planet-wars/frontend/parse.py

18 lines
451 B
Python
Raw Permalink Normal View History

2019-09-24 15:31:21 +02:00
#!/usr/bin/python3
import sys
import json
for arg in sys.argv[1:]:
with open(arg, "r") as f:
with open("out/"+arg, "w+") as w:
print(arg)
for line in f.readlines():
obj = json.loads(line)
if "info" in obj:
w.write(json.dumps(obj["info"])+"\n")
if "state" in obj:
w.write(json.dumps(obj["state"])+"\n")
w.flush()