# 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 ptv_client import cli_view import util def main(): stop_and_routes = list( ptv_client.get_stop_and_routes(ptv_client.search(input('Query: ')))) if not stop_and_routes: print("No results") return print(cli_view.format_stop_and_route_names(stop_and_routes)) idx = int(input('Choose a number: ')) print(cli_view.format_stop_and_route_name(stop_and_routes[idx])) departures = ptv_client.get_departures_from_stop_and_route( *stop_and_routes[idx]) filtered_deps = util.filter_departures(departures['departures']) print( cli_view.format_departures( filtered_deps, ptv_client.get_direction_names( stop_and_routes[idx][1]['route_id']))) if __name__ == "__main__": main()