"""Read-only full numerical reproduction of T909 (own-draft key on stdin).
Run: sage -python readback_check.py, with generate.py beside it.
The separate check_math.py must also be run on the downloaded stored number.
"""
import json,sys
import numberdb.sage as numberdb
from generate import GelfondSchneider
key=sys.stdin.read().strip()
if '=' in key and key.split('=',1)[0].isupper():key=key.split('=',1)[1].strip().strip('\'"')
numberdb.configure(api_key=key)
g=GelfondSchneider();r=g.verify(sample=None)
d=numberdb.table(g.table)
assert r.ok and r.checked==1 and r.matched==1
assert d.get('Parameters')=={} and len(d['Numbers'])==1 and type(d['Numbers'][0]) is str
print(json.dumps({'table':g.table,'checked':r.checked,'matched':r.matched,'ok':r.ok,'numbers':d['Numbers']}))
