Exemple #1
0
def step_impl(context, route_id, weekday):
    datetime = date_lib.day_to_use(weekday, "04h00")
    nav_call = call_navitia(context.base_url, context.coverage,
                            "routes/{}/route_schedules".format(route_id),
                            context.api_key, {'from_datetime': datetime})
    context.route_schedules = nav_call.json()
    context.url = nav_call.url
Exemple #2
0
def step_impl(context):
    from_text = [row['from'] for row in context.table][0]
    to_text = [row['to'] for row in context.table][0]

    places_from_call = call_navitia(context.base_url, context.coverage,
                                    "places", context.api_key,
                                    {'q': from_text})
    from_places = places_from_call.json()['places'][0]['id']

    places_to_call = call_navitia(context.base_url, context.coverage, "places",
                                  context.api_key, {'q': to_text})
    to_places = places_to_call.json()['places'][0]['id']

    datetime_represent = [row['datetime_represent']
                          for row in context.table][0]  #TODO
    if datetime_represent == "Arriver avant":
        datetime_represent = "arrival"
    else:
        datetime_represent = "departure"
    jour = [row['jour'] for row in context.table][0]
    heure = [row['heure'] for row in context.table][0]

    datetime = date_lib.day_to_use(jour, heure)

    params = {
        'from': from_places,
        "to": to_places,
        "datetime_represents": datetime_represent,
        "datetime": datetime
    }

    #gestion des éventuels profils
    if "profile" in context:
        params['traveler_type'] = context.profile

    journey_call = call_navitia(context.base_url, context.coverage, "journeys",
                                context.api_key, params)
    context.journey_result = journey_call.json()
    context.journey_url = journey_call.url

    nav_explo_url = "navitia-explorer/journey.html?ws_name={}&coverage={}".format(
        context.env, context.coverage)
    nav_explo_url += "&from_text={}&from={}".format(from_text, from_places)
    nav_explo_url += "&to_text={}&to={}".format(to_text, to_places)
    date = "{}/{}/{}".format(datetime[6:8], datetime[4:6], datetime[0:4])
    nav_explo_url += "&date={}&time={}&datetime_represents={}".format(
        date, heure, datetime_represent)
    if "profile" in context:
        nav_explo_url += "&traveler_type={}".format(context.profile)
    context.nav_explo = nav_explo_url
Exemple #3
0
def step_impl(context):
    from_text = [row['from'] for row in context.table][0]
    to_text = [row['to'] for row in context.table][0]

    places_from_call = call_navitia(context.base_url, context.coverage, "places", context.api_key, {'q' : from_text})
    from_places = places_from_call.json()['places'][0]['id']

    places_to_call = call_navitia(context.base_url, context.coverage, "places", context.api_key, {'q' : to_text})
    to_places = places_to_call.json()['places'][0]['id']

    datetime_represent = [row['datetime_represent'] for row in context.table][0] #TODO
    if datetime_represent == "Arriver avant":
        datetime_represent = "arrival"
    else :
        datetime_represent = "departure"
    jour = [row['jour'] for row in context.table][0]
    heure = [row['heure'] for row in context.table][0]

    datetime = date_lib.day_to_use(jour, heure)

    params = {'from' : from_places, "to" : to_places, "datetime_represents": datetime_represent, "datetime" : datetime}

    #gestion des éventuels profils
    if "profile" in context :
        params['traveler_type'] = context.profile

    #gestion des éventuels autres paramètres non habituels
    if "non_standard_parameters" in context :
        params.update(context.non_standard_parameters)

    journey_call = call_navitia(context.base_url, context.coverage, "journeys", context.api_key, params )
    context.journey_result = journey_call.json()
    context.journey_url = journey_call.url

    nav_explo_url = "navitia-explorer/journey.html?ws_name={}&coverage={}".format(context.env ,context.coverage)
    nav_explo_url += "&from_text={}&from={}".format(from_text, from_places)
    nav_explo_url += "&to_text={}&to={}".format(to_text, to_places)
    date = "{}/{}/{}".format(datetime[6:8], datetime[4:6],datetime[0:4] )
    nav_explo_url += "&date={}&time={}&datetime_represents={}".format(date, heure, datetime_represent)
    if "profile" in context :
        nav_explo_url += "&traveler_type={}".format(context.profile)
    context.nav_explo = nav_explo_url
Exemple #4
0
def step_impl(context, route_id, weekday):
    datetime = date_lib.day_to_use(weekday, "04h00")
    nav_call =  call_navitia(context.base_url, context.coverage, "routes/{}/route_schedules".format(route_id), context.api_key, {'from_datetime':datetime})
    context.explo_result = nav_call.json()
    context.url = nav_call.url