diff --git a/timetabling/get-practical-groups.py b/timetabling/get-practical-groups.py index baf846ca00d554c1b6063d4ca8c29c7f4bed85a1..2ae4207cf170e4e26949fcd5857083737d0a6107 100644 --- a/timetabling/get-practical-groups.py +++ b/timetabling/get-practical-groups.py @@ -14,8 +14,6 @@ # USERNAME/PASSWORD -- to log into webtimetables. If you get your # password wrong it crashes.. # -# MODULE_CODE -- your module code -# # DEPARTMENTS -- all departments to look in for your students # # The script takes one command line argument: the name of a CSV file @@ -38,11 +36,12 @@ from getpass import getpass from typing import Dict, Optional -if len(sys.argv) < 2: - print("Usage: python get-practical-groups.py <student-list.csv>") +if len(sys.argv) < 3: + print("Usage: python get-practical-groups.py <mod_code> <student-list.csv>") exit(-1) -student_list_csv = sys.argv[1] +mod_code = sys.argv[1] +student_list_csv = sys.argv[2] ACADEMIC_YEAR = "2425" TT_HOST = "webtimetables.royalholloway.ac.uk" @@ -54,15 +53,8 @@ TT_DEFAULT_URL = f"{BASE_URL}/default.aspx" USER_AGENT \ = "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0" -MODULE_CODE = "CS1822" DEPARTMENTS = ["Computer Science", "Media Arts"] -GROUP_TIMES = { - "Group 01": "Monday 13:00", - "Group 02": "Monday 16:00", - "Group 03": "Friday 13:00" -} - GROUP_RE = re.compile(r".*(Group \d+).*", flags=re.DOTALL) GROUP_GRP = 1 @@ -227,7 +219,7 @@ def parse_timetable(students : Dict[str, Student], timetable : str): if current_student is None: continue for practical in tt_row.find_all("td", { "class": "Practical" }): - if MODULE_CODE in practical.text: + if mod_code in practical.text: if m := GROUP_RE.match(practical.text): current_student.group = m[GROUP_GRP]