#!/usr/bin/env python3 """Ad-hoc verification: contrast audit fix checker for koolhydraat-app.""" import re, sys FILES = [ "/Users/cas/projects/koolhydraat-app/index.html", "/Users/cas/projects/koolhydraat-app/docker/index.html", ] REQUIRED_SELECTORS = [ ".food-item-kh", ".eetmoment-kh", ".eetmoment-item-kh", ".total-carb-value", ".detail-kh-number", ".portion-preview-value", ".detail-info-link", ] errors = [] files_checked = 0 fixes_found = 0 for fp in FILES: try: text = open(fp, "r", encoding="utf-8").read() except FileNotFoundError: errors.append(f"MISSING: {fp}") continue files_checked += 1 lines = text.split("\n") for i, line in enumerate(lines, 1): stripped = line.strip() if re.search(r"(?= 0: chunk = text[idx:idx+300] if "color: var(--primary-dark)" in chunk: fixes_found += 1 else: errors.append(f"MISSING FIX: {sel} in {fp}") if errors: print("VERIFICATION FAILED") for e in errors: print(f" \u2717 {e}") sys.exit(1) else: print("VERIFICATION PASSED") print(f" Files checked: {files_checked}") print(f" Fixes confirmed: {fixes_found}") expected = len(REQUIRED_SELECTORS) * files_checked print(f" Expected fixes: {expected}") print(f" All contrast fixes applied to both files \u2713") print() print("--- CSS Variables ---") for fp in FILES: text = open(fp, "r", encoding="utf-8").read() for var in ["--primary-dark", "--primary", "--accent"]: m = re.search(rf"{var}:\s*(#[0-9A-Fa-f]+)", text) if m: label = fp.split("/")[-1] print(f" {label}: {var} = {m.group(1)}")