for j in range(7):
grid[-1].append(TimeCell(i, j))
- nonstop = [x for x in nonstops if i >= x[0] * 2 and i < x[1] * 2][0]
+ try:
+ nonstop = [x for x in nonstops if i >= x[0] * 2 and i < x[1] * 2][0]
+ except IndexError:
+ nonstop = [0, 24, '', '', None]
for time_cell in grid[-1]:
time_cell.nonstop = nonstop[2]
time_cell.nonstop_slug = nonstop[3]
- time_cell.redirect_path = nonstop[4].redirect_path
+ time_cell.redirect_path = nonstop[4].redirect_path if nonstop[4] else None
if nonstop[1] == Schedule.DAY_HOUR_START + Schedule.DAY_MINUTE_START / 60:
# the one ending at 4:30am will be cut down, so we inscribe
# its duration manually