presentation_numbers.py

back to table · edit · history · where entries came from · files · download

791 bytes, as of the version from 2026-11-19 23:07 (current). Recorded here, not run.

import os,json,urllib.request,urllib.parse,hashlib
from pathlib import Path
w=Path(os.environ['TMPDIR']);D=json.load(open(w/'readback-document.json'));out=[]
for N,weights in D['Numbers'].items():
 doc={k:D[k] for k in ('Title','Parameters','Display properties','Tags','Keywords')};doc['Numbers']={N:weights}
 url='https://numberdb.org/preview?'+urllib.parse.urlencode({'table':json.dumps(doc,separators=(',',':'),ensure_ascii=False)})
 with urllib.request.urlopen(url,timeout=35) as r:b=r.read();status=r.status
 name='preview-numbers-N'+N+'.html';(w/name).write_bytes(b);out.append({'name':name,'status':status,'sha256':hashlib.sha256(b).hexdigest(),'url_bytes':len(url)})
 print('Numbers',N,status,len(b),flush=True)
(w/'number-preview-fetches.json').write_text(json.dumps(out,indent=2))