Пример #1
0
def get_route_config(route):
    route_configs = utils.get_url_resource(MUNI_ROUTE_CONFIG_URL % route)
    if not (route_configs and 'body' in route_configs and 
        'route' in route_configs['body'] and
        'stop' in route_configs['body']['route']):
        return None
    return route_configs['body']['route'] 
Пример #2
0
def get_routes_info():
    """ get the information of the all routes """
    routes = utils.get_url_resource(BART_ROUTE_URL)
    if not (routes and 'root' in routes and
        'routes' in routes['root'] and 'route' in routes['root']['routes']):
        return None
    return routes['root']['routes']['route']
Пример #3
0
def get_stations():
    """ get the list of all stations """
    stations = utils.get_url_resource(BART_STATIONS_URL)
    if not (stations and 'root' in stations and 
        'stations' in stations['root'] and 'station' in stations['root']['stations']):
        return None
    return stations['root']['stations']['station']
Пример #4
0
def get_station_info(station_id):
    """ get the information of the given station """
    station_info = utils.get_url_resource(BART_STATION_URL % station_id)
    if not (station_info and 'root' in station_info and
        'stations' in station_info['root'] and 'station' in station_info['root']['stations']):
        return None
    return station_info['root']['stations']['station']
Пример #5
0
def get_route_list():
    routes = utils.get_url_resource(MUNI_ROUTE_LIST_URL)
    if not (routes and 'body' in routes and 'route' in routes['body']):
        return None
    return routes['body']['route']