# -*- 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()

new_progs = """
{id:"up-math-ma",s:"up",n:"数学文学硕士",en:"MA in Mathematics",dept:"SAS 文理学院 · 数学系",college:"School of Arts and Sciences",disc:"sci",lvl:"m",deg:"MA",dur:"8 CU 含硕士论文，Bridge to PhD",stem:1,rank:"数学类研究型硕士，博士预备",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-math-ma.html"},
{id:"up-ling-ma",s:"up",n:"语言学文学硕士",en:"MA in Linguistics",dept:"SAS 文理学院 · 语言学系",college:"School of Arts and Sciences",disc:"sci",lvl:"m",deg:"MA",dur:"8 CU 含学术论文/硕士论文",stem:1,rank:"语言学/认知科学类研究型硕士",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-ling-ma.html"},
{id:"up-arch-ms",s:"up",n:"建筑学理学硕士",en:"Master of Science in Architecture",dept:"Weitzman 设计学院 · 建筑系",college:"Stuart Weitzman School of Design",disc:"art",lvl:"m",deg:"MS",dur:"10 CU 自主学习",stem:0,rank:"面向已持建筑本科职业学位者",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-arch-ms.html"},
{id:"up-mci",s:"up",n:"临床信息学硕士",en:"Master of Clinical Informatics",dept:"Perelman 医学院",college:"Perelman School of Medicine",disc:"med",lvl:"m",deg:"MCI",dur:"10 CU 含 Capstone",stem:1,rank:"临床信息学/医疗信息类，含HIPAA/CITI培训",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-mci.html"},
{id:"up-mes",s:"up",n:"环境研究硕士",en:"Master of Environmental Studies",dept:"SAS/LPS 文理学院",college:"College of Liberal and Professional Studies",disc:"sci",lvl:"m",deg:"MES",dur:"12 CU 全日制或兼读",stem:1,rank:"环境科学/政策类研究型硕士",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-mes.html"},"""

new_catd = """
["up","SAS 文理学院 · 数学系","MA in Mathematics","数学文学硕士","MA","https://catalog.upenn.edu/graduate/programs/mathematics-ma/","sci","details/up-math-ma.html"],
["up","SAS 文理学院 · 语言学系","MA in Linguistics","语言学文学硕士","MA","https://catalog.upenn.edu/graduate/programs/linguistics-ma/","sci","details/up-ling-ma.html"],
["up","Weitzman 设计学院 · 建筑系","Master of Science in Architecture","建筑学理学硕士","MS","https://catalog.upenn.edu/graduate/programs/architecture-ms/","art","details/up-arch-ms.html"],
["up","Perelman 医学院","Master of Clinical Informatics","临床信息学硕士","MCI","https://catalog.upenn.edu/graduate/programs/clinical-informatics-mci/","med","details/up-mci.html"],
["up","SAS/LPS 文理学院","Master of Environmental Studies","环境研究硕士","MES","https://catalog.upenn.edu/graduate/programs/environmental-studies-mes/","sci","details/up-mes.html"],"""

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

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

vd_anchor = '"details/up-hista-ma.html"]);'
vd_replacement = '"details/up-hista-ma.html", "details/up-math-ma.html", "details/up-ling-ma.html", "details/up-arch-ms.html", "details/up-mci.html", "details/up-mes.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")
