# -*- coding: utf-8 -*-
import io,sys,os
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8")
b=r"D:\work buddy\2026-11-05-14-15-52"
f=os.path.join(b,"index_main.html")
r=open(f,encoding="utf-8").read()

PID="stanford-symbo-ms"; PAGE="details/stanford-symbo-ms.html"
if ('"'+PID+'"') in r:
    print(PID,"已存在，跳过"); sys.exit(0)

dur=("跨学科研究型；共 45 units 在校课程，课程编号 100 级及以上；45 units 不得与本科已修学分重复，课程可经项目办评审豁免（B 及以上同等课），豁免课不计入 45 units；"
     "Breadth 四技能领域各修一门 3 units 以上课程：Formal 逻辑与计算理论 / Empirical 实验观察数据方法 / Computational CS 系课 / Philosophical 哲学，跨 CS、Linguistics、Philosophy、Psychology 至少三系，尽量 letter grade，一门课最多计一个领域；"
     "研究项目以 MS Thesis 呈现（通常三季以上）；前置 Project Area Statement（含导师承诺，毕业年前一年 5/1 前）、Qualifying Research Paper（毕业年前一夏季末）、Program Proposal 首季末前审批、Individual Development Plan 经主论文导师批准")
rank="bulletin 未单列硬性整体先修清单；Computational 领域隐含 CS 106B/X 编程基础及数学/形式方法先修；录取背景以计算机、语言学、哲学、心理学、数学及相关定量/人文交叉学科为主（录取分布，非最低门槛）"

entry=(
 '{id:"'+PID+'",s:"stanford",n:"符号系统硕士（MS）",'
 'en:"MS in Symbolic Systems, Symbolic Systems Interdisciplinary Program",'
 'dept:"Symbolic Systems 跨学科项目（横跨哲学/计算机/语言学/心理学/统计/神经生物/传播）",college:"Stanford University · School of Humanities and Sciences",disc:"cs",lvl:"m",deg:"MS",'
 'dur:"'+dur+'",stem:0,rank:"'+rank+'",'
 ' test:{cls:""},ddl:"",lang:"",tui:"",'
 ' url:"'+PAGE+'"},'
)

anchor='url:"details/stanford-mgtsc-ms.html"},];'
assert anchor in r, "PROGRAMS 锚点未找到"
r=r.replace(anchor, 'url:"details/stanford-mgtsc-ms.html"},\n'+entry+'];', 1)

vd_marker='const VERIFIED_DETAILS=new Set(["'
assert vd_marker in r
vd_part=r.split("VERIFIED_DETAILS",1)[1].split("]",1)[0]
if ('"'+PAGE+'"') not in vd_part:
    r=r.replace(vd_marker, 'const VERIFIED_DETAILS=new Set(["'+PAGE+'","', 1)

assert '"'+PAGE+'"' in r, PAGE+" 未在主文件中出现"
open(f,"w",encoding="utf-8",newline="").write(r)
print("入库完成：PROGRAMS +1；VD 已登记；CATD det 已指向核验页")
print("  +", PID, PAGE)
