Skip to content

Commit 2f42edd

Browse files
authored
feat: check for emptyness of a cell before parsing it (#137)
1 parent 36fb6b7 commit 2f42edd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

timetable/extractor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def create_timings(_table: Tag | NavigableString) -> list[int]:
7474
course_duration: int = 0
7575
cells = [cell for cell in row.find_all('td') if cell.attrs.get('valign') != 'top']
7676
for index, cell in enumerate(cells):
77-
code = cell.get_text()[:7] if cell.get_text()[:7] != "CS10001" else "CS10003"
77+
code = cell.get_text()[:7].strip() if cell.get_text()[:7] != "CS10001" else "CS10003"
78+
if not code: continue # continue if cell has no course in it
7879
# CS10003 is the actual code, but it is written as CS10001 in the timetable
7980
location = cell.get_text()[7:]
8081
cell_duration = int(cell.attrs.get('colspan'))
81-
8282
# To reuse code, uses outer scope variables
8383
def append_prev():
8484
prev.duration = course_duration

0 commit comments

Comments
 (0)