11import sys
2- from typing import Union
2+ from typing import Union , List
33from dataclasses import dataclass
44import requests
55from bs4 import BeautifulSoup
@@ -15,7 +15,7 @@ class Module:
1515 name : str
1616 credits : float
1717 status : str
18- semester : str
18+ semesters : List [ str ]
1919 id : str
2020 grade : Union [float , None ] = None
2121
@@ -160,15 +160,22 @@ def _get_modules(self):
160160 # getting id for this module
161161 exams_button = cells [5 ].find ("a" )
162162 exams_id = exams_button .get ("href" ).split (",-N" )[- 2 ]
163- modules .append (Module (
164- num = cells [0 ].text .strip (),
165- name = cells [1 ].text .strip (),
166- credits = float (cells [3 ].text .strip ().replace (',' , '.' )),
167- status = cells [4 ].text .strip (),
168- semester = semester ,
169- id = exams_id ,
170- grade = grade
171- ))
163+ num = cells [0 ].text .strip ()
164+ if not any (module .num == num for module in modules ):
165+ modules .append (Module (
166+ num = num ,
167+ name = cells [1 ].text .strip (),
168+ credits = float (cells [3 ].text .strip ().replace (',' , '.' )),
169+ status = cells [4 ].text .strip (),
170+ semesters = [semester ],
171+ id = exams_id ,
172+ grade = grade
173+ ))
174+ else :
175+ for module in modules :
176+ if module .num == num :
177+ module .semesters .append (semester )
178+ break
172179 elif len (cells ) != 0 :
173180 # FIXME: proper logging
174181 print ("Unexpected number of cells:" ,
0 commit comments