def get_data_route_and_agency_tag(agency_tag, route_tag):
     final_url = global_vars.update_query_to_url_result(route_config_command,
                                                        {"a": agency_tag, "r": route_tag})
     xml_data = global_vars.read_xml_url(final_url)
     route_details = xml_data.find("route")
     if route_details is None:
         raise RouteDoesNotExistException("The xml url built up is bad")
     route_ele = Route(element=route_details)
     return route_ele
Esempio n. 2
0
 def get_routelist_by_agency_tag(agency_tag):
     xml_parsed = global_vars.read_xml_url(
         global_vars.update_query_to_url_result(command_url,
                                                {"a": agency_tag}))
     route_list = list(
         map(
             lambda x: RouteConfig.get_data_route_and_agency_tag(
                 agency_tag, x.get('tag')), xml_parsed.findall(".//route")))
     return route_list
 def get_predictions_by_route_and_stop_id(self, route_tag, stop_id):
     final_command = global_vars.update_query_to_url_result(
         prediction_command, {
             "a": self.agency_tag,
             "r": route_tag,
             "stopId": stop_id
         })
     xml_root = global_vars.read_xml_url(final_command)
     res = xml_root.findall("./predictions")
     predictions = list(map(lambda x: Predictions(x, final_command), res))
     return predictions
Esempio n. 4
0
 def __init__(self, element=None, url=None):
     if element is None:
         self.route_config_url = url
         self.xml_element = read_xml_url(
             self.route_config_url).find("route")
     else:
         self.xml_element = element
     self.route_tag, self.route_title, self.route_short_title, self.color = self.unpack_element(
         element)
     self._stops = None
     self.direction_elements = self.xml_element.findall("./direction")
     self.direction_type = self.__set_direction_type()
 def xml_element(self):
     return global_vars.read_xml_url(self.xml_url).find(
         "./predictions{}".format(
             Predictions.xpath_attrib_string_formatter(
                 self._xml_element.attrib)))
Esempio n. 6
0
 def __init__(self):
     self.complete_url = global_vars.add_query_to_nextbus(
         {"command": "agencyList"})
     self.xml_parsed = global_vars.read_xml_url(self.complete_url)
     self.agencies = self.get_agencies()