"""Re-check the fixed colours in the live tool: usage verify-fixed.py tool-fixed.json fixed.json"""
import sys, json
from wcag import *
tool = {o['input'].upper(): o for o in json.load(open(sys.argv[1]))}
fixed = json.load(open(sys.argv[2])); ok = 0; lines = ['\nTEST B2: fixed colours read back from the live tool (text on white)', 'name\tfixed_hex\tscript\ttool_white\tpasses_4.5']
for n, h in fixed.items():
    t = tool[h.upper()]; p = float(t['onWhite']) >= 4.5; ok += p
    lines.append('%s\t%s\t%.2f\t%s\t%s' % (n, h, ratio(hex_rgb(h), (255,255,255)), t['onWhite'], 'yes' if p else 'NO'))
lines.append('B2: %d of %d fixed colours read 4.5 or more in the tool' % (ok, len(fixed)))
print('\n'.join(lines)); open('test-results.txt', 'a').write('\n'.join(lines) + '\n')
