# -*- coding: utf-8 -*-
import io

G = r"D:/work buddy/2026-11-05-14-15-52/gen_details.py"
H = r"D:/work buddy/2026-11-05-14-15-52/index_main.html"

CUR = "https://www.cmu.edu/tepper/programs/master-business-analytics/curriculum"
FT = "https://www.cmu.edu/tepper/programs/master-business-analytics/full-time"
SFS = "https://www.cmu.edu/sfs/tuition/graduate/tepper/full-msba.html"
PAY = "https://www.cmu.edu/tepper/programs/master-business-analytics/careers/compensation-highlights"

entry = '''
P["cmu-msba"] = dict(
 cn="商业分析硕士", en="Master of Science in Business Analytics (MSBA)",
 sch="cmu", dept="Tepper 商学院（STEM）",
 ranks=[("学制", "9 个月 / 4 个 mini"), ("班级规模（2026 届）", "120 人")],
 req=[
  ("申请截止（2027 秋入学）", "第一轮 <b>2026-10-14</b>（12-10 出结果）；第二轮 <b>2027-01-13</b>（03-11 出结果）；第三轮 <b>2027-03-03</b>（04-22 出结果）—— <b>国际生最后一轮</b>；第四轮优先 <b>2027-05-05</b>、最终 <b>2027-06-16</b>（滚动出结果）。", "%(ft)s"),
  ("录取画像（2026 届全日制）", "班级 <b>120</b> 人；平均工作年限 <b>1.1 年</b>；本科 GPA 均值 <b>3.54</b>；GRE 中段 80%% 为 <b>163–170</b>；国际生占比 <b>73%%</b>。", "%(ft)s"),
  ("授课形式", "全日制 <b>仅线下</b>，CMU 匹兹堡主校区；另有 20 个月非全日制线上版本（本项目库只收线下，故仅列全日制）。", "%(ft)s"),
 ],
 fees=[
  ("学费（2026-27 官方费率）", "<b>$743 / unit</b>（全日制 MSBA）。课程以 units 计：核心课与选修课多为 6 units／门，四个 mini 修完；总 units 以官网 Curriculum Map 为准。", "%(sfs)s"),
  ("大学杂费", "<b>$1,040</b>（2026-27）。", "%(sfs)s"),
 ],
 curricula=[
  "<b>结构</b>：9 个月分 4 个 mini（Mini 1–4），核心课 + 选修课 + 贯穿 Mini 3–4 的 Capstone。",
  "<b>Mini 1</b>：46-881 Programming in R and Python（6 units）；46-880 Introduction to Probability and Statistics（6 units）；46-890 Managing People and Teams（6 units）；46-882 Business Fundamentals（6 units）；46-991 Experiential Learning（3 units）。",
  "<b>Mini 2</b>：46-897 Business Communication（6 units）；46-883 Statistical Foundations of Business Analytics（6 units）；Machine Learning Fundamentals（6 units）；46-884 Modern Data Management（6 units）；46-991 Experiential Learning（3 units）。",
  "<b>Mini 3</b>：46-888 Optimization（6 units）；46-885 Data Exploration（6 units）；选修 2 门；Capstone。",
  "<b>Mini 4</b>：46-889 Business Value for Integrative Analytics（6 units）；46-887 Machine Learning for Business Applications（6 units）；选修 2 门；Capstone。",
  "<b>选修与配套课（官网课程库）</b>：46-892 Data Analytics in Finance；46-893 Operations and Supply Chain Analytics；46-894 Analytical Marketing；46-898 Ethics and AI。",
 ],
 train="9 个月全日制线下（匹兹堡 Tepper Quad）；STEM 认定；Capstone 与企业真实数据项目，向公司高管与教授做最终汇报；小班 + Masters Career Center 一对一职业辅导。",
 outcomes=[
  ("平均基本工资", "<b>$90,753</b>（官网 Full-Time MSBA 页面，2023–2025 届毕业生口径）。", "%(ft)s"),
  ("平均 accepted salary", "<b>$94,731</b>（北美，Full-Time MSBA Class of 2025，官网项目主页口径）。", "https://www.cmu.edu/tepper/programs/master-business-analytics"),
  ("主要雇主（2023–2025）", "Amazon、American Express、Ant Group、BNY、BCG、Capital One、Deloitte、Eli Lilly、EY、Goldman Sachs、Google、J.P. Morgan、McKinsey &amp; Company、TSMC、TikTok、Uber。", "%(ft)s"),
  ("就业率", "__BLANK__", ""),
 ],
 links=[
  ("项目官方主页", "https://www.cmu.edu/tepper/programs/master-business-analytics"),
  ("全日制 MSBA 页面（含班级画像）", "%(ft)s"),
  ("课程设置（逐门课程 + units）", "%(cur)s"),
  ("学费（CMU SFS · 2026-27）", "%(sfs)s"),
  ("薪资与就业亮点", "%(pay)s"),
 ],
 badges=["STEM · OPT 36 个月", "9 个月", "仅线下全日制"],)
''' % {"ft": FT, "cur": CUR, "sfs": SFS, "pay": PAY}

g = io.open(G, encoding="utf-8").read()
anchor = "\ndef build(pid, d):"
if 'P["cmu-msba"]' not in g:
    g = g.replace(anchor, entry + anchor, 1)
io.open(G, "w", encoding="utf-8").write(g)
print("gen updated")

h = io.open(H, encoding="utf-8").read()
if 'id:"cmu-msba"' not in h:
    newp = ('{id:"cmu-msba",s:"cmu",n:"商业分析硕士",en:"M.S. in Business Analytics (MSBA)",'
            'dept:"Tepper 商学院",college:"Tepper 商学院",disc:"biz",lvl:"m",deg:"MS",'
            'dur:"9 个月（4 个 mini）",stem:1,rank:"",\n'
            ' test:{cls:""},ddl:"2027 秋：10-14 / 01-13 / 03-03（国际生末轮）；04 轮 05-05 / 06-16",'
            'lang:"",tui:"$743/unit + 杂费 $1,040（2026-27 官方）",\n'
            ' url:"details/cmu-msba.html"},\n')
    a2 = "];\n\n/* ============ 目录层"
    h = h.replace(a2, newp + a2, 1)
    io.open(H, "w", encoding="utf-8").write(h)
    print("index updated")
