# Copyright (C) 2022 Yuchen Pei. # # This file is part of ptvtt. # # ptvtt is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # ptvtt is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General # Public License for more details. # You should have received a copy of the GNU Affero General Public # License along with ptvtt. If not, see . import util import ptv_client def format_stop_and_route_name(stop_and_route): stop, route = stop_and_route return 'Stop: {}, Route: {} {} {}'.format( stop['stop_name'], ptv_client.get_route_type(route['route_type']), route['route_number'], route['route_name']) def format_stop_and_route_names(stop_and_routes): return '\n'.join(f'[{i}] {result}' for i, result in enumerate( map(format_stop_and_route_name, stop_and_routes))) def format_departures(departures, direction_names): return '\n'.join(['estimated: {}; scheduled: {}; direction: {}'.format( util.format_time(util.parse_time(dep['estimated_departure_utc'])), util.format_time(util.parse_time(dep['scheduled_departure_utc'])), direction_names[dep['direction_id']]) for dep in departures])