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

BASE = "https://www.sgs.utoronto.ca/programs/"
RAW = """
Rotman 商学院|Business Administration (Full-Time MBA)|工商管理硕士（全日制）|MBA|master-of-business-administration-full-time-mba|biz
Rotman 商学院|Business Administration (One Year Full-Time MBA)|工商管理硕士（一年制全日制）|MBA|master-of-business-administration-one-year-full-time-mba|biz
Rotman 商学院|Business Administration (Extended Full-Time MBA)|工商管理硕士（延长制全日制）|MBA|master-of-business-administration-extended-full-time-mba|biz
Rotman 商学院|Business Administration (EMBA)|高级工商管理硕士|EMBA|executive-master-of-business-administration|biz
Rotman 商学院|Business Administration (GEMBA)|全球高级工商管理硕士（双学位）|GEMBA|global-executive-master-of-business-administration-dual-degree|biz
Rotman 商学院|Business Administration for Healthcare and the Life Sciences (GEMBA-HLS)|医疗与生命科学全球高级工商管理硕士|GEMBA|global-executive-master-of-business-administration-for-healthcare-and-the-life-sciences|biz
Rotman 商学院|Finance|金融硕士|MF|finance|biz
Rotman 商学院|Financial Risk Management|金融风险管理硕士|MFRM|financial-risk-management|biz
Rotman 商学院|Management Analytics|管理分析硕士|MMA|management-analytics|biz
Rotman 商学院|Management (MMgt)|管理学硕士|MMgt|master-of-management-mmgt|biz
文理学院（A&S）|Economics|经济学|MA|economics|soc
文理学院（A&S）|Financial Economics|金融经济学|MFE|financial-economics|biz
文理学院（A&S）|Political Science|政治学|MA|political-science|soc
文理学院（A&S）|Sociology|社会学|MA|sociology|soc
文理学院（A&S）|Anthropology|人类学|MA / MSc|anthropology|soc
文理学院（A&S）|History|历史学|MA|history|art
文理学院（A&S）|Philosophy|哲学|MA|philosophy|art
文理学院（A&S）|English|英语|MA|english|art
文理学院（A&S）|Comparative Literature|比较文学|MA|comparative-literature|art
文理学院（A&S）|Classics|古典学|MA|classics|art
文理学院（A&S）|Linguistics|语言学|MA|linguistics|art
文理学院（A&S）|Cinema Studies|电影研究|MA|cinema-studies|art
文理学院（A&S）|Drama, Theatre and Performance Studies|戏剧、剧场与表演研究|MA|drama-theatre-and-performance-studies|art
文理学院（A&S）|Art History|艺术史|MA|art-history|art
文理学院（A&S）|East Asian Studies|东亚研究|MA|east-asian-studies|art
文理学院（A&S）|European and Eurasian Studies|欧洲与欧亚研究|MA|european-and-russian-affairs|art
文理学院（A&S）|Near and Middle Eastern Civilizations|近东与中东文明|MA|near-and-middle-eastern-civilizations|art
文理学院（A&S）|Germanic Languages and Literatures|日耳曼语言与文学|MA|germanic-languages-and-literatures|art
文理学院（A&S）|Italian Studies|意大利研究|MA|italian-studies|art
文理学院（A&S）|French Language and Literature|法语语言与文学|MA|french-language-and-literature|art
文理学院（A&S）|Slavic and East European Languages and Cultures|斯拉夫与东欧语言文化|MA|slavic-and-east-european-languages-and-cultures|art
文理学院（A&S）|Spanish|西班牙语|MA|spanish|art
文理学院（A&S）|Religion|宗教学|MA|religion|art
文理学院（A&S）|Medieval Studies|中世纪研究|MA|medieval-studies|art
文理学院（A&S）|History and Philosophy of Science and Technology|科学技术史与哲学|MA|history-and-philosophy-of-science-and-technology|art
文理学院（A&S）|Women and Gender Studies|妇女与性别研究|MA|women-and-gender-studies|soc
文理学院（A&S）|Criminology and Sociolegal Studies|犯罪学与社会法律研究|MA|criminology-and-sociolegal-studies|soc
文理学院（A&S）|Geography|地理学|MA / MSc|geography|sci
文理学院（A&S）|Planning|规划学|MScPl|planning|soc
文理学院（A&S）|Statistics|统计学|MSc|statistics|sci
文理学院（A&S）|Mathematics|数学|MSc|mathematics|sci
文理学院（A&S）|Physics|物理学|MSc|physics|sci
文理学院（A&S）|Chemistry|化学|MSc|chemistry|sci
文理学院（A&S）|Computer Science|计算机科学|MSc|computer-science|cs
文理学院（A&S）|Applied Computing|应用计算（MScAC）|MScAC|applied-computing|cs
文理学院（A&S）|Astronomy and Astrophysics|天文学与天体物理|MSc|astronomy-and-astrophysics|sci
文理学院（A&S）|Biochemistry|生物化学|MSc|biochemistry|sci
文理学院（A&S）|Cell and Systems Biology|细胞与系统生物学|MSc|cell-and-systems-biology|sci
文理学院（A&S）|Ecology and Evolutionary Biology|生态与进化生物学|MSc|ecology-and-evolutionary-biology|sci
文理学院（A&S）|Immunology|免疫学|MSc|immunology|med
文理学院（A&S）|Molecular Genetics|分子遗传学|MSc|molecular-genetics|sci
文理学院（A&S）|Nutritional Sciences|营养科学|MSc|nutritional-sciences|med
文理学院（A&S）|Earth Sciences|地球科学|MSc / MASc|earth-sciences|sci
文理学院（A&S）|Environmental Science|环境科学|MEnvSc / MSc|environmental-science|sci
文理学院（A&S）|Environment and Sustainability|环境与可持续|MES|environment-and-sustainability|sci
文理学院（A&S）|Statistics – Financial Insurance|金融保险（统计系）|MFI|financial-insurance|biz
文理学院（A&S）|Mathematical Finance|数学金融|MMF|mathematical-finance|biz
应用科学与工程学院|Aerospace Science and Engineering|航空航天科学与工程|MASc / MEng|aerospace-and-engineering|eng
应用科学与工程学院|Biomedical Engineering|生物医学工程|MASc / MEng|biomedical-engineering|eng
应用科学与工程学院|Chemical Engineering and Applied Chemistry|化学工程与应用化学|MASc / MEng|chemical-engineering-and-applied-chemistry|eng
应用科学与工程学院|Civil & Mineral Engineering|土木与矿物工程|MASc / MEng|civil-engineering|eng
应用科学与工程学院|Cities Engineering & Management|城市工程与管理|MEngCEM|cities-engineering-and-management|eng
应用科学与工程学院|Electrical and Computer Engineering|电子与计算机工程|MASc / MEng|electrical-and-computer-engineering|eng
应用科学与工程学院|Mechanical and Industrial Engineering|机械与工业工程|MASc / MEng|mechanical-and-industrial-engineering|eng
应用科学与工程学院|Materials Science and Engineering|材料科学与工程|MASc / MEng|materials-science-and-engineering|eng
建筑、景观与设计学院|Architecture|建筑学|MArch|architecture|art
建筑、景观与设计学院|Landscape Architecture|景观建筑|MLA|landscape-architecture|art
建筑、景观与设计学院|Urban Design|城市设计|MUD|urban-design|art
建筑、景观与设计学院|Visual Studies|视觉研究|MVS|visual-studies|art
建筑、景观与设计学院|Forestry|林学|MScF|forestry|sci
建筑、景观与设计学院|Forest Conservation|森林保护|MFC|forest-conservation|sci
OISE 教育学院|Adult Education and Community Development|成人教育与社区发展|MA / MEd|adult-education-and-community-development|edu
OISE 教育学院|Counselling Psychology|心理咨询|MEd|counselling-psychology|edu
OISE 教育学院|Curriculum and Pedagogy|课程与教学法|MA / MEd|curriculum-and-pedagogy|edu
OISE 教育学院|Developmental Psychology and Education|发展心理学与教育|MA / MEd|developmental-psychology-and-education|edu
OISE 教育学院|Educational Leadership and Policy|教育领导与政策|MA / MEd|educational-leadership-and-policy|edu
OISE 教育学院|Higher Education|高等教育|MA / MEd|higher-education|edu
OISE 教育学院|Language and Literacies Education|语言与读写教育|MA / MEd|language-and-literacies-education|edu
OISE 教育学院|Social Justice Education|社会正义教育|MA / MEd|social-justice-education|edu
OISE 教育学院|Teaching|教学硕士|MT|teaching|edu
OISE 教育学院|Child Study and Education|儿童研究与教育|MA|child-study-and-education|edu
OISE 教育学院|Counselling and Clinical Psychology（临床与咨询心理）|临床与咨询心理学|MA|counselling-and-clinical-psychology-oise-field-clinical-and-counselling-psychology|edu
OISE 教育学院|School and Clinical Child Psychology|学校与临床儿童心理学|MA|school-and-clinical-child-psychology|edu
Dalla Lana 公共卫生学院|Public Health Sciences|公共卫生科学|MPH / MSc|public-health-sciences|med
Dalla Lana 公共卫生学院|Health Administration|卫生管理|MHSc|health-administration|med
Dalla Lana 公共卫生学院|Health Informatics|健康信息学|MHI|health-informatics|med
Dalla Lana 公共卫生学院|Health Policy, Management and Evaluation|卫生政策、管理与评估|MSc|health-policy-management-and-evaluation|med
Dalla Lana 公共卫生学院|Bioethics|生命伦理|MHSc|bioethics|med
Dalla Lana 公共卫生学院|Community Health|社区健康|MScCH|community-health|med
Temerty 医学院|Medical Science|医学科学|MSc|medical-science|med
Temerty 医学院|Medical Biophysics|医学生物物理|MSc|medical-biophysics|med
Temerty 医学院|Physiology|生理学|MHSc / MSc|physiology|med
Temerty 医学院|Medical Physiology|医学生理学|MHSc|medical-physiology|med
Temerty 医学院|Laboratory Medicine and Pathobiology|检验医学与病理生物学|MSc|laboratory-medicine-and-pathobiology|med
Temerty 医学院|Laboratory Medicine|检验医学|MHSc|laboratory-medicine|med
Temerty 医学院|Translational Research in the Health Sciences|健康科学转化研究|MHSc|translational-research-in-the-health-sciences|med
Temerty 医学院|Medical Genomics|医学基因组学|MHSc|medical-genomics|med
Temerty 医学院|Genetic Counselling|遗传咨询|MSc|genetic-counselling|med
Temerty 医学院|Biomedical Communications|生物医学传播|MScBMC|biomedical-communications|med
Temerty 医学院|Dentistry (Research)|牙医学（研究型）|MSc|dentistry-research|med
Temerty 医学院|Dentistry (with Specialty Training)|牙医学（含专科训练）|MSc|dentistry-with-specialty-training|med
Temerty 医学院|Speech-Language Pathology (Practitioner)|言语语言病理学|MHSc|speech-language-pathology-practitioner|med
Temerty 医学院|Physical Therapy|物理治疗|MScPT|physical-therapy|med
Temerty 医学院|Occupational Therapy|作业治疗|MScOT|occupational-therapy|med
Temerty 医学院|Rehabilitation Science|康复科学|MSc|rehabilitation-science|med
Temerty 医学院|Pharmaceutical Sciences|药学科学|MSc|pharmaceutical-sciences|med
Temerty 医学院|Pharmacy|药学|MScPhm|pharmacy|med
Temerty 医学院|Pharmacology|药理学|MSc|pharmacology|med
Lawrence S. Bloomberg 护理学院|Nursing Science|护理科学|MN|nursing-science|med
Factor-Inwentash 社会工作学院|Social Work|社会工作|MSW|social-work|soc
信息学院|Information|信息学|MI|information|cs
法学院|Law|法学|LLM / MSL|law|soc
法学院|Global Professional Law|全球职业法律|GPLLM|global-professional-law|soc
Munk 全球事务与公共政策学院|Global Affairs|全球事务|MGA|global-affairs|soc
Munk 全球事务与公共政策学院|Public Policy|公共政策|MPP|public-policy|soc
Rotman 管理学院（三校区）|Management (PhD)|管理学（博士）|PhD|management-phd|biz
密西沙加校区（UTM）|Management & Innovation|管理创新|MMI|management-of-innovation|biz
密西沙加校区（UTM）|Sustainability Management|可持续管理|MScSM|sustainability-management|biz
密西沙加校区（UTM）|Urban Innovation|城市创新|MUI|urban-innovation|soc
密西沙加校区（UTM）|Biotechnology|生物技术|MBiotech|biotechnology|sci
密西沙加校区（UTM）|Forensic Accounting|法务会计|MFAcc|forensic-accounting|biz
密西沙加校区（UTM）|Management and Professional Accounting|管理与专业会计|MMPA|management-and-professional-accounting|biz
士嘉堡校区（UTSC）|Accounting and Finance|会计与金融|MAccFin|accounting-and-finance|biz
士嘉堡校区（UTSC）|Counselling and Clinical Psychology（临床心理）|临床心理学|MA|counselling-and-clinical-psychology-utsc-field-clinical-psychology|edu
文理学院（A&S）|Museum Studies|博物馆研究|MMSt|museum-studies|art
文理学院（A&S）|Music|音乐学|MA|music|art
文理学院（A&S）|Music Performance|音乐表演|MMus|music-performance|art
文理学院（A&S）|Industrial Relations and Human Resources|劳动关系与人力资源|MIRHR|industrial-relations-and-human-resources|biz
文理学院（A&S）|Kinesiology|运动机能学|MA / MKin / MSc|kinesiology|med
"""

rows = []
for line in RAW.strip().split("\n"):
    c, en, cn, deg, slug, disc = line.split("|")
    rows.append(["ut", c, en, cn, deg, BASE + slug + "/", disc])

p = "index_main.html"
s = io.open(p, encoding="utf-8").read()
assert "MAccFin" not in s
body = ",\n".join(json.dumps(r, ensure_ascii=False) for r in rows)
s = s.replace("\n];\nconst CAT=CATD.map", ",\n" + body + "\n];\nconst CAT=CATD.map", 1)
io.open(p, "w", encoding="utf-8").write(s)
print("toronto added", len(rows))
