# -*- 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-mapp",s:"up",n:"应用积极心理学硕士",en:"Master of Applied Positive Psychology (MAPP)",dept:"SAS/LPS 应用积极心理学",college:"School of Arts and Sciences · LPS",disc:"sci",lvl:"m",deg:"MAPP",dur:"9门课，1年全日制 Fall/Spring/Summer",stem:0,rank:"全球首个应用积极心理学学位项目",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-c4e6bf6.html"},
{id:"up-gampa",s:"up",n:"政府管理硕士（全日制）",en:"Master of Public Administration in Government Administration (Full-Time)",dept:"Fels 政府研究所",college:"School of Arts and Sciences",disc:"soc",lvl:"m",deg:"MPA",dur:"10 CU 全日制（含 Capstone 与实习）",stem:0,rank:"Fels 全日制 MPA，与 Exec 在职版对应",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-c250a59.html"},
{id:"up-impa",s:"up",n:"国际公共管理硕士",en:"International Master of Public Administration (I-MPA)",dept:"SAS/LPS 国际公共管理",college:"School of Arts and Sciences · LPS",disc:"soc",lvl:"m",deg:"I-MPA",dur:"12 CU，1年全日制 cohort",stem:0,rank:"全球治理/国际事务跨学科 cohort",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-impa.html"},
{id:"up-mph",s:"up",n:"公共卫生硕士",en:"Master of Public Health (MPH)",dept:"跨学院（Perelman 医学院/DBEI）",college:"Perelman School of Medicine",disc:"med",lvl:"m",deg:"MPH",dur:"14 CU + 125h APE，2年全日制",stem:0,rank:"跨学院 MPH，含 Generalist/Global Health/One Health/Epi 方向",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-mph.html"},
{id:"up-smart",s:"up",n:"统计、测量、评估与研究技术硕士",en:"M.S.Ed. in Statistics, Measurement, Assessment, and Research Technology (SMART)",dept:"GSE 教育学院",college:"Graduate School of Education",disc:"sci",lvl:"m",deg:"M.S.Ed.",dur:"10 CU，全日制或兼读",stem:1,rank:"教育统计/测量/量化研究方法，STEM",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-smart.html"},"""

new_catd = """
["up","SAS/LPS 国际公共管理","International Master of Public Administration (I-MPA)","国际公共管理硕士","I-MPA","https://catalog.upenn.edu/graduate/programs/international-mpa/","soc","details/up-impa.html"],
["up","跨学院（Perelman 医学院/DBEI）","Master of Public Health (MPH)","公共卫生硕士","MPH","https://catalog.upenn.edu/graduate/programs/public-health-mph/","med","details/up-mph.html"],
["up","GSE 教育学院","M.S.Ed. in Statistics, Measurement, Assessment, and Research Technology (SMART)","统计、测量、评估与研究技术硕士","M.S.Ed.","https://catalog.upenn.edu/graduate/programs/statistics-measurement-assessment-research-technology-msed/","sci","details/up-smart.html"],"""

prog_anchor = 'url:"details/up-mes.html"},\n];'
prog_replacement = 'url:"details/up-mes.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-mes.html"],\n];'
catd_replacement = '"details/up-mes.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-mes.html"]);'
vd_replacement = '"details/up-mes.html", "details/up-c4e6bf6.html", "details/up-c250a59.html", "details/up-impa.html", "details/up-mph.html", "details/up-smart.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 + 3 CATD (MAPP/GAMPA 已有占位) + 5 VD")
