def __init__(self, endpoint): super(Schedules, self).__init__() self.endpoint = endpoint self.parsers["get"] = reqparse.RequestParser( argument_class=ArgumentDoc) parser_get = self.parsers["get"] parser_get.add_argument("filter", type=str) parser_get.add_argument("from_datetime", type=str, description="The datetime from which you want\ the schedules") parser_get.add_argument("duration", type=int, default=3600 * 24, description="Maximum duration between datetime\ and the retrieved stop time") parser_get.add_argument("depth", type=int, default=2) parser_get.add_argument("count", type=int, default=10, description="Number of schedules per page") parser_get.add_argument("start_page", type=int, default=0, description="The current page") parser_get.add_argument("max_date_times", type=natural, description="Maximum number of schedule per\ stop_point/route") parser_get.add_argument("forbidden_id[]", type=unicode, description="forbidden ids", dest="forbidden_uris[]", action="append") parser_get.add_argument("calendar", type=str, description="Id of the calendar") parser_get.add_argument("show_codes", type=boolean, default=False, description="show more identification codes") self.method_decorators.append(complete_links(self))
def __init__(self, endpoint): ResourceUri.__init__(self) ResourceUtc.__init__(self) self.endpoint = endpoint self.parsers["get"] = reqparse.RequestParser( argument_class=ArgumentDoc) parser_get = self.parsers["get"] parser_get.add_argument("filter", type=str) parser_get.add_argument("from_datetime", type=date_time_format, description="The datetime from which you want\ the schedules", default=None) parser_get.add_argument("until_datetime", type=date_time_format, description="The datetime until which you want\ the schedules", default=None) parser_get.add_argument("duration", type=int, default=3600 * 24, description="Maximum duration between datetime\ and the retrieved stop time") parser_get.add_argument("depth", type=int, default=2) parser_get.add_argument("count", type=int, default=10, description="Number of schedules per page") parser_get.add_argument("start_page", type=int, default=0, description="The current page") parser_get.add_argument("max_date_times", type=natural, default=10000, description="Maximum number of schedule per\ stop_point/route") parser_get.add_argument("forbidden_id[]", type=unicode, description="forbidden ids", dest="forbidden_uris[]", action="append") parser_get.add_argument("calendar", type=str, description="Id of the calendar") parser_get.add_argument("show_codes", type=boolean, default=False, description="show more identification codes") parser_get.add_argument( "_use_old_disruptions", type=bool, description="temporary boolean to use the old disruption interface. " "Will be deleted soon, just needed for synchronization with the front end", default=False) parser_get.add_argument( "_current_datetime", type=date_time_format, default=datetime.datetime.utcnow(), description="The datetime we want to publish the disruptions from." " Default is the current date and it is mainly used for debug.") self.method_decorators.append(complete_links(self))
def __init__(self): # journeys must have a custom authentication process ResourceUri.__init__(self, authentication=False) modes = ["walking", "car", "bike", "bss"] types = { "all": "All types", "best": "The best journey", "rapid": "A good trade off between duration, changes and constraint respect", 'no_train': "Journey without train", 'comfort': "A journey with less changes and walking", 'car': "A journey with car to get to the public transport", 'less_fallback_walk': "A journey with less walking", 'less_fallback_bike': "A journey with less biking", 'less_fallback_bss': "A journey with less bss", 'fastest': "A journey with minimum duration", 'non_pt_walk': "A journey without public transport, only walking", 'non_pt_bike': "A journey without public transport, only biking", 'non_pt_bss': "A journey without public transport, only bike sharing", } self.parsers = {} self.parsers["get"] = reqparse.RequestParser( argument_class=ArgumentDoc) parser_get = self.parsers["get"] parser_get.add_argument("from", type=str, dest="origin") parser_get.add_argument("to", type=str, dest="destination") parser_get.add_argument("datetime", type=str) parser_get.add_argument("datetime_represents", dest="clockwise", type=dt_represents, default=True) parser_get.add_argument("max_nb_transfers", type=int, default=10, dest="max_transfers") parser_get.add_argument("first_section_mode[]", type=option_value(modes), default=["walking"], dest="origin_mode", action="append") parser_get.add_argument("last_section_mode[]", type=option_value(modes), default=["walking"], dest="destination_mode", action="append") parser_get.add_argument("max_duration_to_pt", type=int, default=15 * 60, description="maximal duration of non public \ transport in second") parser_get.add_argument("walking_speed", type=float, default=1.12) parser_get.add_argument("bike_speed", type=float, default=4.1) parser_get.add_argument( "bss_speed", type=float, default=4.1, ) parser_get.add_argument("car_speed", type=float, default=16.8) parser_get.add_argument("forbidden_uris[]", type=str, action="append") parser_get.add_argument("count", type=int) parser_get.add_argument("min_nb_journeys", type=int) parser_get.add_argument("max_nb_journeys", type=int) parser_get.add_argument("type", type=option_value(types), default="all") parser_get.add_argument("disruption_active", type=boolean, default=False) # a supprimer parser_get.add_argument("max_duration", type=int, default=3600 * 24) parser_get.add_argument("wheelchair", type=boolean, default=False) parser_get.add_argument("debug", type=boolean, default=False, hidden=True) # for retrocompatibility purpose, we duplicate (without []): parser_get.add_argument("first_section_mode", type=option_value(modes), action="append") parser_get.add_argument("last_section_mode", type=option_value(modes), action="append") parser_get.add_argument("show_codes", type=boolean, default=False, description="show more identification codes") self.method_decorators.append(complete_links(self)) self.method_decorators.append(update_journeys_status(self))
def __init__(self): # journeys must have a custom authentication process ResourceUri.__init__(self, authentication=False) ResourceUtc.__init__(self) modes = ["walking", "car", "bike", "bss"] types = { "all": "All types", "best": "The best journey", "rapid": "A good trade off between duration, changes and constraint respect", 'no_train': "Journey without train", 'comfort': "A journey with less changes and walking", 'car': "A journey with car to get to the public transport", 'less_fallback_walk': "A journey with less walking", 'less_fallback_bike': "A journey with less biking", 'less_fallback_bss': "A journey with less bss", 'fastest': "A journey with minimum duration", 'non_pt_walk': "A journey without public transport, only walking", 'non_pt_bike': "A journey without public transport, only biking", 'non_pt_bss': "A journey without public transport, only bike sharing", } self.parsers = {} self.parsers["get"] = reqparse.RequestParser( argument_class=ArgumentDoc) parser_get = self.parsers["get"] parser_get.add_argument("from", type=str, dest="origin") parser_get.add_argument("to", type=str, dest="destination") parser_get.add_argument("datetime", type=date_time_format) parser_get.add_argument("datetime_represents", dest="clockwise", type=dt_represents, default=True) parser_get.add_argument("max_nb_transfers", type=int, dest="max_transfers") parser_get.add_argument("first_section_mode[]", type=option_value(modes), default=["walking"], dest="origin_mode", action="append") parser_get.add_argument("last_section_mode[]", type=option_value(modes), default=["walking"], dest="destination_mode", action="append") parser_get.add_argument("max_duration_to_pt", type=int, description="maximal duration of non public transport in second") parser_get.add_argument("max_walking_duration_to_pt", type=int, description="maximal duration of walking on public transport in second") parser_get.add_argument("max_bike_duration_to_pt", type=int, description="maximal duration of bike on public transport in second") parser_get.add_argument("max_bss_duration_to_pt", type=int, description="maximal duration of bss on public transport in second") parser_get.add_argument("max_car_duration_to_pt", type=int, description="maximal duration of car on public transport in second") parser_get.add_argument("walking_speed", type=float) parser_get.add_argument("bike_speed", type=float) parser_get.add_argument("bss_speed", type=float) parser_get.add_argument("car_speed", type=float) parser_get.add_argument("forbidden_uris[]", type=str, action="append") parser_get.add_argument("count", type=int) parser_get.add_argument("min_nb_journeys", type=int) parser_get.add_argument("max_nb_journeys", type=int) parser_get.add_argument("type", type=option_value(types), default="all") parser_get.add_argument("disruption_active", type=boolean, default=False) # a supprimer parser_get.add_argument("max_duration", type=int, default=3600*24) parser_get.add_argument("wheelchair", type=boolean, default=False) parser_get.add_argument("debug", type=boolean, default=False, hidden=True) # for retrocompatibility purpose, we duplicate (without []): parser_get.add_argument("first_section_mode", type=option_value(modes), action="append") parser_get.add_argument("last_section_mode", type=option_value(modes), action="append") parser_get.add_argument("show_codes", type=boolean, default=False, description="show more identification codes") parser_get.add_argument("traveler_type", type=option_value(travelers_profile.keys())) parser_get.add_argument("_override_scenario", type=str, description="debug param to specify a custom scenario") self.method_decorators.append(complete_links(self)) # manage post protocol (n-m calculation) self.parsers["post"] = deepcopy(parser_get) parser_post = self.parsers["post"] parser_post.add_argument("details", type=boolean, default=False, location="json") for index, elem in enumerate(parser_post.args): if elem.name in ["from", "to"]: parser_post.args[index].type = list parser_post.args[index].dest = elem.name parser_post.args[index].location = "json"