# -*- 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-ipd-mse",s:"up",n:"集成产品设计工程硕士",en:"MSE in Integrated Product Design",dept:"SEAS · MEAM 系",college:"School of Engineering and Applied Science",disc:"eng",lvl:"m",deg:"MSE",dur:"10 CU · 6 核心 + 4 选修（设计/商学/工程）",stem:1,rank:"跨学科设计工程类，SEAS 工程学院",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-ipd-mse.html"},
{id:"up-musa",s:"up",n:"城市空间分析硕士",en:"Master of Urban Spatial Analytics",dept:"Weitzman 设计学院 · 城市规划系",college:"Weitzman School of Design",disc:"cs",lvl:"m",deg:"MUSA",dur:"9 CU · 1 学年全日制",stem:1,rank:"空间数据分析/GIS 类，城市数据方向",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-musa.html"},
{id:"up-qpa-mpa",s:"up",n:"量化政策分析公共管理硕士",en:"MPA in Quantitative Policy Analysis",dept:"Fels Institute of Government",college:"College of Liberal and Professional Studies",disc:"soc",lvl:"m",deg:"MPA",dur:"Fels MPA 量化政策分析方向",stem:0,rank:"公共管理/政策分析类，Fels 政府学院",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-qpa-mpa.html"},
{id:"up-mcp",s:"up",n:"城市与区域规划硕士",en:"Master of City and Regional Planning",dept:"Weitzman 设计学院 · 城市规划系",college:"Weitzman School of Design",disc:"soc",lvl:"m",deg:"MCP",dur:"18 CU · 2 年全日制",stem:0,rank:"城市规划类，Weitzman 设计学院",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-mcp.html"},
{id:"up-mshp",s:"up",n:"健康政策研究理学硕士",en:"MS in Health Policy Research",dept:"Perelman 医学院 · 医疗保健研究系",college:"Perelman School of Medicine",disc:"med",lvl:"m",deg:"MSHP",dur:"12 CU · 2 年全日制研究型，含 Master Thesis",stem:0,rank:"健康政策研究类，Perelman 医学院",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/up-mshp.html"},"""

# 5 new CATD entries
new_catd = """
["up","SEAS · MEAM 系","MSE in Integrated Product Design","集成产品设计工程硕士","MSE","https://catalog.upenn.edu/graduate/programs/integrated-product-design-mse/","eng","details/up-ipd-mse.html"],
["up","Weitzman 设计学院","Master of Urban Spatial Analytics","城市空间分析硕士","MUSA","https://catalog.upenn.edu/graduate/programs/urban-spatial-analytics-musa/","cs","details/up-musa.html"],
["up","Fels Institute of Government","MPA in Quantitative Policy Analysis","量化政策分析公共管理硕士","MPA","https://catalog.upenn.edu/graduate/programs/quantitative-policy-analysis-mpa/","soc","details/up-qpa-mpa.html"],
["up","Weitzman 设计学院","Master of City and Regional Planning","城市与区域规划硕士","MCP","https://catalog.upenn.edu/graduate/programs/city-and-regional-planning-mcp/","soc","details/up-mcp.html"],
["up","Perelman 医学院","MS in Health Policy Research","健康政策研究理学硕士","MSHP","https://catalog.upenn.edu/graduate/programs/health-policy-research-mshp/","med","details/up-mshp.html"],"""

# 1. PROGRAMS anchor
prog_anchor = 'url:"details/up-biostat-ms.html"},\n];'
prog_replacement = 'url:"details/up-biostat-ms.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-biostat-ms.html"],\n];'
catd_replacement = '"details/up-biostat-ms.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-biostat-ms.html"]);'
vd_replacement = '"details/up-biostat-ms.html", "details/up-ipd-mse.html", "details/up-musa.html", "details/up-qpa-mpa.html", "details/up-mcp.html", "details/up-mshp.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")
