#!/usr/bin/env python3 """Print one case's record fields, contradictions, unsupported flags and notes. Usage: serve.py """ import json, sys bn, cid = int(sys.argv[1]), int(sys.argv[2]) db = {int(r['id']): r for r in json.load(open('../attacks-export-Gart-website.json', encoding='utf-8'))} c = [x for x in json.load(open(f'batches/batch-{bn:02d}.json', encoding='utf-8')) if x['id'] == cid][0] r = db[cid] keys = ('date','country','location','victim','scenario','description','notes','money_wanted','amount','coin_type','kidnappings','violence_torture','weapons','theft','drugs_alcohol','life_taken','arrests') print('RECORD', {k: r.get(k) for k in keys}) print('URLS', [r.get(k) for k in sorted(r) if k.startswith('url') and r.get(k)]) print('SEQ', c['sequence'], 'attempted', c['attempted'], '| v1 supported', c['v1_label_supported']) print('RATIONALE', c['rationale']); print('FACTS', c['facts']) for f, v in c['flags'].items(): if not v.get('supported'): print('FLAG', f, v) for ct in c['contradictions']: print('CT', ct) print('GAPS', c['gaps']); print('NOTE', c['notes_for_sofia'])