~phroa/boat-map

3726040929944ff2f14d720efaf8dc0e728d428f — Jack Stratton 6 months ago 661a28b master
Show special columns in the schedule
1 files changed, 10 insertions(+), 2 deletions(-)

M make-map.py
M make-map.py => make-map.py +10 -2
@@ 142,12 142,15 @@ def draw_schedule():
        times = []
        for col in row.xpath('td'):
            cell_contents = ''.join(col.xpath('descendant::*/text()')).replace('\xa0', '').strip()
            # Track special cases in the schedule except for the "Indicates an arrival time" note
            extra = len(col.xpath('div/div/img[@title!="Indicates an arrival time"]')) > 0
            pm = len(col.xpath('div/div[@class="pm"]')) > 0 and ':' in cell_contents

            if '-' in cell_contents:
                cell_contents = ''
            if len(col.xpath('div/div[@class="pm"]')) > 0 and ':' in cell_contents:
            elif pm:
                hour, minute = map(int, cell_contents.split(':'))
                times.append(60 * ((hour if hour != 12 else 0) + 12) + minute)
                cell_contents += 'p'
            elif ':' in cell_contents:
                hour, minute = map(int, cell_contents.split(':'))
                times.append(60 * hour + minute)


@@ 155,6 158,11 @@ def draw_schedule():
                times.append(60 * 12)
            elif 'Midnight' in cell_contents:
                times.append(60 * 24)

            if extra:
                cell_contents += '*'
            elif pm:
                cell_contents += 'p'
            line.append(cell_contents)
        if (current_time.tm_hour + 1) * 60 + current_time.tm_min < max(times):
            schedule_lines[current_label].append('{}  {:6} {:6} {:6} {:6} {:6}'.format(*line))