simple-cpp-game-study/PPP3/stats.py

21 lines
519 B
Python

import sys
import re
import json
from datetime import datetime
err_re = re.compile("(?P<file>.*?):(?P<line>[0-9]+):(?P<col>[0-9]+): (?P<type>.*?): (?P<message>.*)\n")
stats = [];
for line in sys.stdin:
found = err_re.fullmatch(line)
print(line, end="")
if found:
stats.append(found.groupdict())
print("FOUND", found.groupdict())
with open("stats.json", "a+") as out:
out.write(json.dumps({"date": datetime.now().isoformat(),
"messages": stats}));
out.write("\n")