# -*- coding: utf-8 -*-
import io,sys,os
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8")
b=r"D:\work buddy\2026-11-05-14-15-52"
f=os.path.join(b,"index_main.html")
r=open(f,encoding="utf-8").read()

PID="jhu-finmath"; PAGE="details/jhu-c7e177c.html"
if ('"'+PID+'"') in r:
    print(PID,"已存在，跳过"); sys.exit(0)

dur=("至少两学期全日制在校注册；标准三学期完成（晚夏入学、12 月中结业）；共 41 学分；"
     "Area of Focus Track（可与导师定制）或 Legacy Track 两条路径；含暑期实习（通常第一学年后夏季）")
rank=("官网鼓励强量化本科背景申请者；项目在读要求：满足项目要求课程整体 GPA ≥3.0，最多两门 C/C+，其余 B- 及以上"
      "（在读学位要求，非录取最低门槛；录取分布，非最低门槛）")

entry=(
 '{id:"'+PID+'",s:"jhu",n:"金融数学工程硕士（MSE）",en:"M.S.E. in Financial Mathematics, Department of Applied Mathematics and Statistics (AMS)",'
 'dept:"应用数学与统计系（AMS）",college:"Johns Hopkins University · Whiting 工程学院",disc:"biz",lvl:"m",deg:"MSE",'
 'dur:"'+dur+'",stem:0,rank:"'+rank+'",'
 ' test:{cls:""},ddl:"",lang:"",tui:"",'
 ' url:"'+PAGE+'"},'
)

anchor='url:"details/uchicago-applied-ai.html"},];'
assert anchor in r, "PROGRAMS 锚点未找到"
r=r.replace(anchor, 'url:"details/uchicago-applied-ai.html"},\n'+entry+'];', 1)

vd_marker='const VERIFIED_DETAILS=new Set(["'
assert vd_marker in r
vd_part=r.split("VERIFIED_DETAILS",1)[1].split("]",1)[0]
if ('"'+PAGE+'"') not in vd_part:
    r=r.replace(vd_marker, 'const VERIFIED_DETAILS=new Set(["'+PAGE+'","', 1)

assert '"'+PAGE+'"' in r, PAGE+" 未在主文件中出现"
open(f,"w",encoding="utf-8",newline="").write(r)
print("入库完成：PROGRAMS +1；VD 已登记；CATD det 已指向核验页")
print("  +", PID, PAGE)
