-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_course_pages.py
66 lines (50 loc) · 1.78 KB
/
create_course_pages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from __future__ import print_function
import json
import argparse
import pywikibot
site = pywikibot.Site()
parser = argparse.ArgumentParser()
parser.add_argument("--outdir",
default=".",
help="Output directory")
args = parser.parse_args()
course_details = json.load(open('./syllabus.json', 'r'))
for course in course_details:
course = dict(course)
# NOTE: I have to double the braces to escape it as string formatting
# character
course_text = r"""
{{{{Infobox course
| course_code = {Code}
| course_name = {Name}
| department = [[{Department}]]
| credits = {Credits}
| ltp = {LTP}
| professor =
| venue =
}}}}
=Syllabus=
==Syllabus mentioned in ERP==
{Syllabus}
==Concepts taught in class==
===Student Opinion===
==How to Crack the Paper==
=Classroom resources=
=Additional Resources=
"""
course_text = course_text.format(**course)
course_page = pywikibot.Page(site, "{}: {}".format(course['Code'], course['Name']))
course_page.text = course_text
msg = "Created Page for {}".format(course['Name'])
course_page.save(msg)
print(msg)
"""
{
"Code": "ME41603",
"Credits": "3",
"Department": "Mechanical Engineering",
"LTP": "3-0-0",
"Name": "VIBRATION AND NOISE CONTROL",
"Syllabus": "Prerequisite \u00e2Design of Machine ElementsFundamentals of Vibration Theory; Force\nTransmissibility, Design of Vibration Isolators and Absorbers and other passive\ndampers; Active Vibration control; Torsional Vibration; Basics of Acoustics,\nSolution of 1-D and 3-D wave equation, Sound Field Characterization, Sound\nSources, Principles of Noise Control, Reflection and Transmission of Sound\nWaves, Noise Control Materials: Absorbers, Barriers and Damping Materials,\nSilencers."
}
"""