"""triage.py KEY STATUS COMMENT: sets a reference entity record's triage and comment (file formatting kept).""" import json, sys p = 'tools/reference/rebirth/entities.json' text = open(p).read() records = json.loads(text) key, status, comment = sys.argv[1:4] record = next(r for r in records if r.get('key') == key) record['triage'] = status record['comment'] = comment indent = 1 if '\n "' in text[:200] or '\n {' in text[:20] else 2 open(p, 'w').write(json.dumps(records, indent=1, ensure_ascii=False) + ('\n' if text.endswith('\n') else ''))