Skip to content

Commit

Permalink
feat: check for emptyness of a cell before parsing it (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashsirvi authored Jul 29, 2024
1 parent 36fb6b7 commit 2f42edd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions timetable/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def create_timings(_table: Tag | NavigableString) -> list[int]:
course_duration: int = 0
cells = [cell for cell in row.find_all('td') if cell.attrs.get('valign') != 'top']
for index, cell in enumerate(cells):
code = cell.get_text()[:7] if cell.get_text()[:7] != "CS10001" else "CS10003"
code = cell.get_text()[:7].strip() if cell.get_text()[:7] != "CS10001" else "CS10003"
if not code: continue # continue if cell has no course in it
# CS10003 is the actual code, but it is written as CS10001 in the timetable
location = cell.get_text()[7:]
cell_duration = int(cell.attrs.get('colspan'))

# To reuse code, uses outer scope variables
def append_prev():
prev.duration = course_duration
Expand Down

0 comments on commit 2f42edd

Please sign in to comment.