# -*- coding: utf-8 -*-
import io, sys, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

idx = open("index_main.html", encoding="utf-8").read()

# 5 new PROGRAMS entries
new_progs = """
{id:"up-msrs",s:"up",n:"监管科学理学硕士",en:"MS in Regulatory Science",dept:"Perelman 医学院",college:"Perelman School of Medicine",disc:"med",lvl:"m",deg:"MSRS",dur:"12 CU",stem:0,rank:"医药监管/政策类，Perelman 医学院",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-msrs.html"},
{id:"up-msmp",s:"up",n:"医学物理理学硕士",en:"MS in Medical Physics",dept:"Perelman 医学院 · 放射肿瘤学系",college:"Perelman School of Medicine",disc:"med",lvl:"m",deg:"MSMP",dur:"15 CU · 含 Thesis",stem:1,rank:"医学物理/放射物理类 STEM-designated",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-msmp.html"},
{id:"up-msnpl",s:"up",n:"非营利/NGO 领导力理学硕士",en:"MS in Nonprofit/NGO Leadership",dept:"SAS LPS 学院",college:"College of Liberal and Professional Studies",disc:"soc",lvl:"m",deg:"MSNPL",dur:"LPS 专业硕士，on-campus/online 双路径",stem:0,rank:"非营利组织管理类，LPS 学院",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-msnpl.html"},
{id:"up-crim-ms",s:"up",n:"犯罪学理学硕士",en:"MS in Criminology",dept:"SAS 文理学院 · 社会学系",college:"School of Arts and Sciences",disc:"soc",lvl:"m",deg:"MS",dur:"8 CU · 研究型",stem:0,rank:"犯罪学/刑事司法类，SAS 文理学院",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-crim-ms.html"},
{id:"up-mstr",s:"up",n:"转化研究理学硕士",en:"MS in Translational Research",dept:"Perelman 医学院 · 转化医学研究所",college:"Perelman School of Medicine",disc:"med",lvl:"m",deg:"MSTR",dur:"12 CU",stem:1,rank:"转化医学/生物医学类 STEM-designated",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-mstr.html"},"""

# 5 new CATD entries
new_catd = """
["up","Perelman 医学院","MS in Regulatory Science","监管科学理学硕士","MSRS","https://catalog.upenn.edu/graduate/programs/regulatory-science-msrs/","med","details/up-msrs.html"],
["up","Perelman 医学院 · 放射肿瘤学系","MS in Medical Physics","医学物理理学硕士","MSMP","https://catalog.upenn.edu/graduate/programs/medical-physics-mmp/","med","details/up-msmp.html"],
["up","SAS LPS 学院","MS in Nonprofit/NGO Leadership","非营利/NGO 领导力理学硕士","MSNPL","https://catalog.upenn.edu/graduate/programs/nonprofit-ngo-leadership-msnpl/","soc","details/up-msnpl.html"],
["up","SAS 文理学院 · 社会学系","MS in Criminology","犯罪学理学硕士","MS","https://catalog.upenn.edu/graduate/programs/criminology-ms/","soc","details/up-crim-ms.html"],
["up","Perelman 医学院 · 转化医学研究所","MS in Translational Research","转化研究理学硕士","MSTR","https://catalog.upenn.edu/graduate/programs/translational-research-mstr/","med","details/up-mstr.html"],"""

# 1. PROGRAMS anchor
prog_anchor = 'url:"details/up-mshp.html"},\n];'
prog_replacement = 'url:"details/up-mshp.html"},' + new_progs + '\n];'
assert prog_anchor in idx, "PROGRAMS anchor not found"
idx = idx.replace(prog_anchor, prog_replacement, 1)

# 2. CATD anchor
catd_anchor = '"details/up-mshp.html"],\n];'
catd_replacement = '"details/up-mshp.html"],' + new_catd + '\n];'
assert catd_anchor in idx, "CATD anchor not found"
idx = idx.replace(catd_anchor, catd_replacement, 1)

# 3. VD anchor
vd_anchor = '"details/up-mshp.html"]);'
vd_replacement = '"details/up-mshp.html", "details/up-msrs.html", "details/up-msmp.html", "details/up-msnpl.html", "details/up-crim-ms.html", "details/up-mstr.html"]);'
assert vd_anchor in idx, "VD anchor not found"
idx = idx.replace(vd_anchor, vd_replacement, 1)

open("index_main.html", "w", encoding="utf-8").write(idx)
print("APPENDED 5 PROGRAMS + 5 CATD + 5 VD")
