# -*- coding: utf-8 -*-
import sys, io, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
BASE = r"D:\work buddy\2026-11-05-14-15-52"
s = open(BASE + r"\index_main.html", encoding="utf-8").read()
a = s.index("const PROGRAMS=["); b = s.index("const CATD=["); seg = s[a:b]
blocks = re.findall(r'\{id:"([^"]+)"([\s\S]*?)(?=\}\s*,?\s*\{id:"|\}\s*\]|,?\s*\];)', seg)

def f(t, k):
    m = re.search(k + r':"([^"]*)"', t); return m.group(1) if m else ""

stat = {}
for pid, body in blocks:
    sc = f(body, "s")
    d = stat.setdefault(sc, [0,0,0,0,0])  # total, tui缺, test缺, ddl缺, lang缺
    d[0] += 1
    tui = f(body, "tui"); test = f(body, "test"); ddl = f(body, "ddl"); lang = f(body, "lang")
    if (not tui) or ("待补" in tui): d[1] += 1
    if (not test) or ("待补" in test): d[2] += 1
    if (not ddl) or ("待补" in ddl): d[3] += 1
    if (not lang) or ("待补" in lang): d[4] += 1

print("校 | 总数 | tui缺 | test缺 | ddl缺 | lang缺")
for sc, d in sorted(stat.items(), key=lambda x: -(x[1][1] + x[1][2])):
    print(sc, "|", d[0], "|", d[1], "|", d[2], "|", d[3], "|", d[4])
