Skip to content

Commit e020ca4

Browse files
committed
Slight adjustment to name of exams
1 parent 8bdcf6f commit e020ca4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CampusNet.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Module:
2222

2323
@dataclass
2424
class Exam:
25-
name: str
25+
name: Union[str, None]
2626
semester: str
2727
description: str
2828
grade: Union[float, None] = None
@@ -208,20 +208,20 @@ def get_exams_for_module(self, module: Module):
208208
soup = BeautifulSoup(response.text, 'html.parser')
209209
exam_table = soup.find('table', {'class': 'tb'})
210210
exams = []
211+
current_heading = None
211212
for row in exam_table.find_all("tr"):
212213
cells = row.find_all('td')
213214
if len(cells) == 1 and 'level02' in cells[0]["class"]:
214-
tempexamname = cells[0].text.strip() #temp variable to persist into the next for loops
215+
current_heading = cells[0].text.strip() #variable to persist header into the next iteration
215216
if len(cells) == 6 and all("tbdata" in cell["class"] for cell in cells):
216217
try:
217218
grade = float(cells[3].text.strip().replace(",", "."))
218219
except ValueError:
219220
grade = None
220221
exams.append(Exam(
221-
name=tempexamname,
222+
name=current_heading,
222223
semester=cells[0].text.strip(),
223224
description=cells[1].text.strip(),
224225
grade=grade,
225226
))
226-
del tempexamname #remove temp variable after using to avoid missatribution
227227
return exams

0 commit comments

Comments
 (0)