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

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"

g = io.open(G, encoding="utf-8").read()

URL_MISM = "https://www.heinz.cmu.edu/programs/information-systems-management-master"
URL_APPLY = "https://www.heinz.cmu.edu/programs/information-systems-management-master/admissions-how-to-apply"
URL_CUR = "https://www.heinz.cmu.edu/programs/information-systems-management-master/right-for-me"
URL_COA = "https://www.cmu.edu/sfs/tuition/graduate/heinz/mism.html"
URL_CAREER = "https://www.heinz.cmu.edu/programs/information-systems-management-master/mism-career-outcomes"

entry = '''
P["cmu-mism"] = dict(
 cn="信息系统管理硕士", en="Master of Information Systems Management (MISM)",
 sch="cmu", dept="Heinz College 信息系统与公共政策学院（STEM）",
 ranks=[("学制", "16 个月 / 3 学期"), ("班级规模（3 年平均）", "281 人")],
 req=[
  ("申请截止（2027 秋入学）", "第一轮 <b>2026-12-01</b>；第二轮 <b>2027-01-10</b>；第三轮 <b>2027-02-01</b>。国际生官方<b>强烈建议</b>赶第一轮或第二轮，以留出 I-20 与签证办理时间；2027-06-15 申请系统对本届全日制硕士关闭。", "%(apply)s"),
  ("语言要求", "母语非英语者<b>必须</b>提交 TOEFL、IELTS 或 Duolingo 任一官方成绩，由考试机构直送。豁免仅限两类：① 在官网指定英语国家（美、英、加、澳、新、爱尔兰、南非等）<b>工作或学习累计满 5 年</b>；② 在美国完成<b>4 年本科</b>并取得学位。", "%(apply)s"),
  ("标化要求", "<b>GRE/GMAT：Required（必须提交）</b>—— 官网原文「Applicants are <b>REQUIRED</b> to submit GRE/GMAT scores」。<br>两条豁免路径：① 本科成绩单上有<b>大学学分制</b>的 Pre-Calculus（或更高阶数学）课程且成绩 <b>B 以上</b>，AP/IB 微积分须在成绩单上体现为大学学分；② 本科毕业于卡内基梅隆大学。<br>招生委员会保留在审核前要求补交 GRE/GMAT 的权利。", "%(apply)s"),
  ("录取画像（官网 3 年平均）", "班级规模 <b>281</b> 人；本科 GPA 均值 <b>3.66</b>；GRE 数学 <b>165–170</b>；生源 <b>33</b> 个国家。", "%(apply)s"),
  ("申请材料", "申请表 + Essay + 简历 + <b>2 封推荐信</b> + 本科官方成绩单／学历评估报告 + 官方标化成绩（如适用）。", "%(apply)s"),
  ("实习要求", "官网明确 <b>Internship: Required</b>；有 <b>3 年以上</b>全职工作经验者可申请豁免。", "%(mism)s"),
 ],
 fees=[
  ("学费（2026-27 官方 COA）", "Fall 2026 <b>$29,570</b> + Spring 2027 <b>$29,570</b> + Fall 2027 <b>$30,460</b> = <b>$89,600</b>（16 个月三学期，纯学费）。", "%(coa)s"),
  ("计费规则", "一学期修满 <b>36 units</b> 按全日制学期费率计；不足 36 units 按 <b>$825/unit</b>（2026-27 单价）计。CMU 以 units 计课：整学期课 12 units、半学期 mini 课 6 units，约 3 units ≈ 1 学分。", "%(coa)s"),
  ("大学杂费", "<b>$520／学期</b>（三学期合计 $1,560）。", "%(coa)s"),
  ("医疗保险", "<b>$3,352</b>（年度；已有同等保险可申请豁免）。", "%(coa)s"),
  ("生活成本（官网 COA 分项）", "住宿、餐饮与杂项 <b>$13,025／学期</b>；书本与耗材 <b>$625／学期</b>；交通 <b>$1,610／学期</b>；笔记本电脑一次性约 <b>$1,500</b>（官网列为必需项）。", "%(coa)s"),
 ],
 curricula=[
  "<b>学位结构（Traditional Track，16 个月三学期）</b>：全部为线下全日制；以 units 计，整学期课 12 units、半学期 mini 课 6 units。",
  "<b>方向二选一（2027 秋起）</b>：<br>Pathway 1（技术向）：Data Engineering &amp; Cloud Computing + Foundations of AI &amp; Machine Learning；<br>Pathway 2（系统向）：95-703 Database Management + 95-702 Distributed Systems for Information Systems Management。<br>同一 pathway 内两门必须都修，<b>不得跨 pathway 混修</b>。",
  "<b>核心课（Traditional Track）</b>：95-819 A/B Testing；94-700 Organizational Design and Implementation；95-896 Python for Software Development；95-710 Economic Analysis；95-760 Decision Making Under Uncertainty；95-867 Tech Strategy and Governance；95-796 Statistics for IT Managers；95-719 Accounting and Finance Analytics；95-877 Communicating with Data；95-843 Information Systems Management Professional Seminar；94-739 Capstone Project。",
  "<b>Capstone 替代选项</b>：94-891 Lean Innovation Lab 或 45-996 Corporate Start-Up Lab 可替代 94-739 Capstone。",
  "<b>选修方向（官网分类）</b>：<br>· 人工智能：94-879 Operationalizing AI／95-876 Practical Deep Learning: Models &amp; Applications／95-891 Intro to AI<br>· AI 评估：95-828 Machine Learning for Problem Solving／90-755 Optimization and Decision Modeling for Analytics／91-819 Optimization and Risk Modeling for Managers<br>· 技术、社会与政策：95-841 Responsible AI Governance／95-802 AI, Data, and Society",
  "<b>MISM-BIDA 方向差异</b>：在共享核心课基础上，必修 94-834 Applied Econometrics、95-828 Machine Learning for Problem Solving、95-865 Unstructured Data Analytics，并以 95-871 BIDA Professional Seminar 替代 95-843；Pathway 1 改为 Data Engineering &amp; Cloud Computing + Technology Strategy &amp; Governance。",
  "<b>可选 Concentration（5 个）</b>：AI Management／Health Informatics／Marketing and Social Media Analytics／Product Management／Tech Policy and Governance。",
  "<b>其他选修示例</b>：94-879 Fundamentals of Operationalizing AI；94-823 Measuring Social；95-885 Data Science and Big Data；95-835 Time Series Forecasting in Python；94-812 Applications of NL(X) and LLM；95-799 Linux and Open Source；94-833 Decision Analysis and Multicriteria Decision Making。",
 ],
 train="16 个月、三学期全日制线下授课（官网 Program Delivery: Full-time, in person）；STEM 认定，国际生可享 36 个月 OPT；毕业需完成 Capstone（真实客户项目）；实习为必修，3 年以上工作经验可豁免。",
 outcomes=[
  ("就业数据查询方式", "Heinz 官网设有 First Destination Outcomes 交互看板，可按 track 与毕业年份筛选岗位名称、雇主与起薪；数据以看板形式发布，未以静态数字列出，故此处不转述具体百分比，点右侧链接直接查看官方看板。", "%(career)s"),
  ("就业服务", "Mary Beth and Miles Reidy Career Center 提供一对一职业辅导、简历与面试准备、招聘会、雇主宣讲、校友导师与校内招聘；毕业后仍可终身使用。", "%(career)s"),
 ],
 links=[
  ("项目官方主页", "%(mism)s"),
  ("申请流程与材料清单", "%(apply)s"),
  ("课程设置（含课程代码）", "%(cur)s"),
  ("学费与生活成本 COA（CMU SFS）", "%(coa)s"),
  ("First Destination 就业看板", "%(career)s"),
  ("Heinz 课程目录（逐门查询）", "https://www.heinz.cmu.edu/current-students/courses/"),
 ],
 badges=["STEM · OPT 36 个月", "实习 Required", "16 个月 · 3 学期"],)
''' % {"mism": URL_MISM, "apply": URL_APPLY, "cur": URL_CUR, "coa": URL_COA, "career": URL_CAREER}

# 插入到 def build 之前
anchor = "\ndef build(pid, d):"
if "P[\"cmu-mism\"]" not in g:
    g = g.replace(anchor, entry + anchor, 1)
io.open(G, "w", encoding="utf-8").write(g)
print("gen_details.py updated")

# 主页面 PROGRAMS 增加条目
h = io.open(H, encoding="utf-8").read()
if 'id:"cmu-mism"' not in h:
    newp = ('{id:"cmu-mism",s:"cmu",n:"信息系统管理硕士",en:"Master of Information Systems Management (MISM)",'
            'dept:"Heinz College",college:"Heinz 信息系统与公共政策学院",disc:"cs",lvl:"m",deg:"MS",'
            'dur:"16 个月（3 学期）",stem:1,rank:"",\n'
            ' test:{cls:"req"},ddl:"2027 秋：12-01（R1）/ 01-10（R2）/ 02-01（R3）",'
            'lang:"TOEFL / IELTS / Duolingo（官网未公布最低分，须官方送分）",'
            'tui:"$29,570 + $29,570 + $30,460 = $89,600（16 个月，2026-27 官方 COA）",\n'
            ' url:"details/cmu-mism.html"},\n')
    a2 = "];\n\n/* ============ 目录层"
    assert a2 in h, "PROGRAMS anchor missing"
    h = h.replace(a2, newp + a2, 1)
    io.open(H, "w", encoding="utf-8").write(h)
    print("index_main.html updated")
else:
    print("already exists")
