# -*- coding: utf-8 -*-
"""r381 回填 PROGRAMS：7 条 Georgia Tech 热门条目的 ddl/lang/tui/dur/test.cls。"""
import io, re, shutil, sys

SRC = 'index_main.html'
BAK = 'index_main.html.bak_r381'
shutil.copyfile(SRC, BAK)
t = io.open(SRC, encoding='utf-8').read()

LANG = ('TOEFL 旧制 90（各项 ≥19）/ 2026-01-21 起新制 4.5（R/L/W ≥4、S ≥3.5）；IELTS 7.0（R/L/S ≥6.5、W ≥5.5）；'
        '机构码 5248；不接受 Duolingo/PTE/MyBest；2027 秋起不再以公民身份豁免')
TUI = ('USG FY2027（2026 秋生效）每学期：$7,280（州内）/$16,073（州外）/$16,540（境外）；不足 12 学分按学分 $607/$1,341/$1,379；'
       '两学期约 $14,560/$32,146')

F = {
 'gatech-ece-phd': {
  'ddl': 'Atlanta 秋季 2026-12-16 23:59 ET（全部 ECE PhD/MS）；MS Robotics 2027-02-01；GT-Europe 秋 MS 2027-03-01、春 MS 2026-10-01；Distance Learning 秋 2027-05-01、春 2026-09-01',
  'lang': LANG,
  'tui': TUI + '；博士资助按录取信 GTA/GRA 聘书，统一比例与 stipend 金额官网未披露',
  'dur': '43 学分（Group I 9/II 9/III 9/IV 14 + ECE 8022 1 + PHIL 6000 1）；两学期全日制驻校；GPA 3.0 且辅修 3.0；candidacy 后 7 年内完成；资格考 4 门课 3.5 GPA、第二年末前；提案第 7 学期末前',
  'test': 'opt',
 },
 'gatech-me-phd': {
  'ddl': '官网未披露（ME 系站未列申请截止）；研究生院论文节点 2026-12-11 / 2027-04-30 / 2027-12-10（12:00）；答辩距提案 ≥6 个月',
  'lang': LANG,
  'tui': TUI + '；约 90% 博士获 GRA/GTA（官网列 $2,500/月为 Fall 2022 档）',
  'dur': '36 学期学分（含 ≥6 学分辅修）+ Seminar 8014（22 场/学分）+ Teaching Practicum ME 7757（3 学分）；GPA 3.3 起评；资格考持硕士 1 年内/本科直博 2 年内，1 小时口试、可重考一次',
  'test': 'opt',
 },
 'gatech-msbinf': {
  'ddl': '2027-03-01 截止（仅秋季）；2026-12-01 前材料齐备进早申评估',
  'lang': LANG,
  'tui': TUI + '；第一学期后可申 Computational Biology Faculty GRA（含学费减免 + stipend）',
  'dur': '3 学期、36 学分（核心 15 + 统计 3 + Capstone 3 + 选修 15），含暑期全职实习；录取者 GPA 区间 3.3–4.0',
  'test': 'rec',
 },
 'gatech-mbid': {
  'ddl': '2027-01-15（全部材料；FAQ 另写材料 2026-12-31、可宽限至 2027-01-15）；仅秋季；2 月底放榜、答复 2027-04-15、候补答复 2027-04-07',
  'lang': 'TOEFL 100（各项 ≥19）/ IELTS 7.0（R/L/S ≥6.5、W ≥5.5）；GT 底线 IC 5248；项目自设更高分',
  'tui': TUI + '；项目页未列独立打包学费，按标准研究生档',
  'dur': '12 个月连续（8 月中至次年 7 月底）；36 学分（BMED 6501–6508 各 3 + BMED 6509 6 + 选修 6）；班额 25–35 人，仅秋季',
  'test': 'notreq',
 },
 'gatech-msbcfm': {
  'ddl': '秋季早 2027-01-15、国际生晚 2027-04-01、美国晚 2027-05-01；春季早 2026-07-15、国际生晚 2026-09-01、美国晚 2026-10-01；滚动评审，早交优先资助',
  'lang': LANG + '；另接受 GT Language Institute 评估 3 分或 IEP 700 级',
  'tui': TUI + '；GTA/GRA 名额有限，须早截止前完成申请',
  'dur': '30 学分：论文轨（核心 15 + 选修 6 + BC 7100 3 + 论文 6）或非论文轨（核心 15 + 方向 12 + 选修 3）；晚间授课，可 part-time；STEM',
  'test': 'rec',
 },
 'gatech-mseem': {
  'ddl': '优先 2027-02-15（含资助评审）、最终 2027-03-15；仅秋季（无春季）；放榜最迟 2027-05-01',
  'lang': LANG,
  'tui': '按标准研究生档、无 special designator：USG FY2027 每学期 $7,280/$16,073/$16,540，学分单价 $607/$1,341/$1,379；Byers Fellowship $90,000 stipend（每届至多 5 人）',
  'dur': '30 学分（必修 12 + 定量 6 + 方向 9 + 政策管理 3）；全日制 1 年（4-4-2 门）、在职 2 年（2-2-1）；班额约 30 人',
  'test': 'rec',
 },
 'gatech-chbe-phd': {
  'ddl': '官网未披露（ChBE 系站 403，catalog 不列系截止）；论文节点 2026-12-11/2027-04-30/2027-12-10；QE 第二学期、提案第二学年春、预审答辩前 ≥6 个月',
  'lang': LANG,
  'tui': TUI + '；系站 403，博士统一资助比例与 stipend 金额官网未披露',
  'dur': '约 5 年；五门 3 学分核心 GPA ≥3.2、累计 GPA ≥3.0；CHBE 6001 1 + CHBE 6003 1 + 五门核心 15 + 选修 3 + 辅修 9；Professional Preparation 10 单元、3 学期教学、第四年 Colloquium',
  'test': 'opt',
 },
}

cnt = 0
for pid, fields in F.items():
    marker = '{id:"%s"' % pid
    i = t.find(marker)
    if i < 0:
        print('MISSING BLOCK', pid)
        sys.exit(1)
    nxt = t.find('{id:"', i + len(marker))
    seg_end = nxt if nxt > 0 else len(t)
    blk = t[i:seg_end]
    new = blk
    for k in ('ddl', 'lang', 'tui', 'dur'):
        pat = re.compile(k + r':"([^"]*)"')
        ms = pat.findall(new)
        if len(ms) != 1:
            print('FIELD COUNT BAD', pid, k, len(ms))
            sys.exit(1)
        new = pat.sub(lambda m: '%s:"%s"' % (k, fields[k]), new, count=1)
        cnt += 1
    pat = re.compile(r'test:(\{cls:"[^"]*"\}|"[^"]*")')
    ms = pat.findall(new)
    if len(ms) != 1:
        print('TEST COUNT BAD', pid, ms)
        sys.exit(1)
    new = pat.sub('test:{cls:"%s"}' % fields['test'], new, count=1)
    cnt += 1
    t = t[:i] + new + t[seg_end:]

io.open(SRC, 'w', encoding='utf-8').write(t)
print('apply ok, fields =', cnt, 'chars', len(t), 'bytes', len(t.encode('utf-8')))
