Esempio n. 1
0
 def __init__(self, is_collection, collection, *args, **kwargs):
     kwargs['authentication'] = False
     ResourceUri.__init__(self, *args, **kwargs)
     self.parsers["get"] = reqparse.RequestParser(
         argument_class=ArgumentDoc)
     parser = self.parsers["get"]
     parser.add_argument("start_page", type=int, default=0,
                         description="The page where you want to start")
     parser.add_argument("count", type=int, default=25,
                         description="Number of objects you want on a page")
     parser.add_argument("depth", type=depth_argument,
                         default=1,
                         description="The depth of your object")
     parser.add_argument("forbidden_id[]", type=unicode,
                         description="forbidden ids",
                         dest="forbidden_uris[]",
                         action="append")
     parser.add_argument("external_code", type=unicode,
                         description="An external code to query")
     parser.add_argument("show_codes", type=boolean, default=False,
                         description="show more identification codes")
     parser.add_argument("odt_level", type=option_value(odt_levels),
                                      default="all",
                                      description="odt level")
     if is_collection:
         parser.add_argument("filter", type=str, default="",
                             description="The filter parameter")
     self.collection = collection
     self.method_decorators.insert(0, ManageError())
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     ResourceUri.__init__(self, *args, **kwargs)
     self.parsers["get"] = reqparse.RequestParser(
         argument_class=ArgumentDoc)
     self.parsers["get"].add_argument("q",
                                      type=unicode,
                                      required=True,
                                      description="The data to search")
     self.parsers["get"].add_argument(
         "type[]",
         type=option_value(pt_object_type_values),
         action="append",
         default=pt_object_type_values,
         description="The type of data to\
                                      search")
     self.parsers["get"].add_argument("count",
                                      type=int,
                                      default=10,
                                      description="The maximum number of\
                                      ptobjects returned")
     self.parsers["get"].add_argument("search_type",
                                      type=int,
                                      default=0,
                                      description="Type of search:\
                                      firstletter or type error")
     self.parsers["get"].add_argument("admin_uri[]",
                                      type=str,
                                      action="append",
                                      description="If filled, will\
                                      restrained the search within the\
                                      given admin uris")
     self.parsers["get"].add_argument("depth",
                                      type=depth_argument,
                                      default=1,
                                      description="The depth of objects")
Esempio n. 3
0
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        parser = self.parsers["get"]
        parser.add_argument("start_page",
                            type=int,
                            default=0,
                            description="The page where you want to start")
        parser.add_argument("count",
                            type=int,
                            default=25,
                            description="Number of objects you want on a page")
        parser.add_argument("depth",
                            type=depth_argument,
                            default=1,
                            description="The depth of your object")
        parser.add_argument("forbidden_id[]",
                            type=unicode,
                            description="forbidden ids",
                            dest="forbidden_uris[]",
                            action="append")
        parser.add_argument("external_code",
                            type=unicode,
                            description="An external code to query")
        parser.add_argument("show_codes",
                            type=boolean,
                            default=False,
                            description="show more identification codes")
        parser.add_argument("odt_level",
                            type=option_value(odt_levels),
                            default="all",
                            description="odt level")
        parser.add_argument(
            "_current_datetime",
            type=date_time_format,
            default=datetime.utcnow(),
            description=
            "The datetime used to consider the state of the pt object"
            " Default is the current date and it is used for debug."
            " Note: it will mainly change the disruptions that concern the object"
            " The timezone should be specified in the format,"
            " else we consider it as UTC")
        parser.add_argument(
            "distance",
            type=int,
            default=200,
            description=
            "Distance range of the query. Used only if a coord is in the query"
        )

        if is_collection:
            parser.add_argument("filter",
                                type=str,
                                default="",
                                description="The filter parameter")
        self.collection = collection
        self.method_decorators.insert(0, ManageError())
Esempio n. 4
0
 def __init__(self, *args, **kwargs):
     ResourceUri.__init__(self, *args, **kwargs)
     self.parsers = {}
     self.parsers["get"] = reqparse.RequestParser(
         argument_class=ArgumentDoc)
     self.parsers["get"].add_argument("q",
                                      type=unicode,
                                      required=True,
                                      description="The data to search")
     self.parsers["get"].add_argument(
         "type[]",
         type=option_value(pt_object_type_values),
         action="append",
         default=pt_object_type_values,
         description="The type of data to\
                                      search")
     self.parsers["get"].add_argument("count",
                                      type=default_count_arg_type,
                                      default=10,
                                      description="The maximum number of\
                                      ptobjects returned")
     self.parsers["get"].add_argument("search_type",
                                      type=int,
                                      default=0,
                                      description="Type of search:\
                                      firstletter or type error")
     self.parsers["get"].add_argument("admin_uri[]",
                                      type=unicode,
                                      action="append",
                                      description="If filled, will\
                                      restrained the search within the\
                                      given admin uris")
     self.parsers["get"].add_argument("depth",
                                      type=depth_argument,
                                      default=1,
                                      description="The depth of objects")
     self.parsers["get"].add_argument(
         "_current_datetime",
         type=date_time_format,
         default=datetime.datetime.utcnow(),
         description=
         "The datetime used to consider the state of the pt object"
         " Default is the current date and it is used for debug."
         " Note: it will mainly change the disruptions that concern "
         "the object The timezone should be specified in the format,"
         " else we consider it as UTC")
     self.parsers['get'].add_argument(
         "disable_geojson",
         type=boolean,
         default=False,
         description="remove geojson from the response")
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     ResourceUri.__init__(self, *args, **kwargs)
     self.parsers["get"] = reqparse.RequestParser(
         argument_class=ArgumentDoc)
     self.parsers["get"].add_argument("q",
                                      type=unicode,
                                      required=True,
                                      description="The data to search")
     self.parsers["get"].add_argument(
         "type[]",
         type=option_value(pt_object_type_values),
         action="append",
         default=pt_object_type_values,
         description="The type of data to\
                                      search")
     self.parsers["get"].add_argument("count",
                                      type=int,
                                      default=10,
                                      description="The maximum number of\
                                      ptobjects returned")
     self.parsers["get"].add_argument("search_type",
                                      type=int,
                                      default=0,
                                      description="Type of search:\
                                      firstletter or type error")
     self.parsers["get"].add_argument("admin_uri[]",
                                      type=str,
                                      action="append",
                                      description="If filled, will\
                                      restrained the search within the\
                                      given admin uris")
     self.parsers["get"].add_argument("depth",
                                      type=depth_argument,
                                      default=1,
                                      description="The depth of objects")
     self.parsers["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)
Esempio n. 6
0
 def __init__(self):
     self.parsers = {}
     self.parsers["get"] = reqparse.RequestParser()
     parser_get = self.parsers["get"]
     parser_get.add_argument("origin", type=str, required=True)
     parser_get.add_argument("datetime", type=str, required=True)
     parser_get.add_argument("clockwise", type=true_false, default=True)
     parser_get.add_argument("max_duration", type=int, default=3600)
     parser_get.add_argument("max_transfers", type=int, default=10)
     parser_get.add_argument("origin_mode",
                             type=option_value(["walking", "car", "bike",
                                                "bss"]),
                             action="append", default=["walking"])
     parser_get.add_argument("max_duration_to_pt", type=int, default=10*60,
                             description="maximal duration of non public \
                             transport in second")
     parser_get.add_argument("walking_speed", type=float, default=1.68)
     parser_get.add_argument("bike_speed", type=float, default=8.8)
     parser_get.add_argument("bss_speed", type=float, default=8.8)
     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("wheelchair", type=boolean, default=False)
     parser_get.add_argument("debug", type=boolean, default=False,
                             hidden=True)
Esempio n. 7
0
 def __init__(self):
     super(Ptref, self).__init__()
     self.resource_type = "Unknown"
     self.parsers["get"] = reqparse.RequestParser(
         argument_class=ArgumentDoc)
     self.parsers["get"].add_argument(
         "start_page",
         type=int,
         default=0,
         description="The page where want to start")
     self.parsers["get"].add_argument(
         "count",
         type=int,
         default=25,
         description="The number of objects you want on the page")
     self.parsers["get"].add_argument("filter",
                                      type=str,
                                      default="",
                                      description="The filter parameter")
     self.parsers["get"].add_argument("depth",
                                      type=depth_argument,
                                      default=1,
                                      description="The depth of object")
     self.parsers["get"].add_argument("forbidden_uris[]",
                                      type=unicode,
                                      action="append",
                                      description="Uri to forbid")
     self.parsers["get"].add_argument(
         "show_codes",
         type=boolean,
         default=False,
         description="Either to show or not codes")
     self.parsers["get"].add_argument("odt_level",
                                      type=option_value(odt_levels),
                                      default="all",
                                      description="odt level")
Esempio n. 8
0
 def __init__(self, *args, **kwargs):
     types = ["all", "rapid"]
     self.parsers["get"] = reqparse.RequestParser(
         argument_class=ArgumentDoc)
     parser_get = self.parsers["get"]
     parser_get.add_argument("origin", type=str, required=True,
                             description="Origin's uri of your journey")
     parser_get.add_argument("destination", type=str, required=True,
                             description=
                             "Destination's uri of your journey")
     parser_get.add_argument("datetime", type=str, required=True,
                             description=
                             "Datetime's uri of your journey")
     parser_get.add_argument("clockwise", type=true_false, default=True,
                             description=
                             "Whether you want your journey to start"\
                             "after datetime or to end before datetime")
     parser_get.add_argument("max_duration", type=int, default=36000,
                             description="Maximum duration of your journey")
     parser_get.add_argument("max_transfers", type=int, default=10,
                             description=
                             "Maximum transfers you want in "\
                             "your journey")
     parser_get.add_argument("origin_mode",
                             type=option_value(["walking", "car", "bike",
                                                "bss"]),
                             action="append", default=['walking', 'bike',
                                                       'car'],
                             description=
                             "The list of modes you want at the "\
                             "beggining of your journey")
     parser_get.add_argument("destination_mode",
                             type=option_value(["walking", "car", "bike",
                                                "bss"]),
                             default=['walking', 'bike', 'car'],
                             action="append",
                             description=
                             "The list of modes you want at the"\
                             " end of your journey")
     parser_get.add_argument("max_duration_to_pt", type=int, default=10*60,
                             description=
                             "maximal duration of non public "\
                             "transport in second")
     parser_get.add_argument("walking_speed", type=float, default=1.68,
                             description=
                             "Walking speed in meter/second")
     parser_get.add_argument("bike_speed", type=float, default=8.8,
                             description="Bike speed in meter/second")
     parser_get.add_argument("bss_speed", type=float, default=8.8,
                             description="Bike rental speed in "\
                             "meter/second")
     parser_get.add_argument("car_speed", type=float, default=16.8,
                             description=
                             "Car speed in meter/second")
     parser_get.add_argument("forbidden_uris[]", type=str, action="append",
                             description="Uri you want to forbid")
     parser_get.add_argument("type", type=option_value(types),
                             default="all")
     parser_get.add_argument("wheelchair", type=boolean, default=False)
     parser_get.add_argument("disruption_active", type=boolean, default=False)
     parser_get.add_argument("count", type=int)
     parser_get.add_argument("debug", type=boolean, default=False,
                             hidden=True)
Esempio n. 9
0
    def __init__(self, endpoint):
        ResourceUri.__init__(self)
        ResourceUtc.__init__(self)
        self.endpoint = endpoint
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        parser_get = self.parsers["get"]
        parser_get.add_argument("filter", type=unicode)
        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=default_count_arg_type,
                                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="DEPRECATED, use items_per_schedule")
        parser_get.add_argument(
            "forbidden_id[]",
            type=unicode,
            description="DEPRECATED, replaced by forbidden_uris[]",
            dest="__temporary_forbidden_id[]",
            default=[],
            action='append')
        parser_get.add_argument("forbidden_uris[]",
                                type=unicode,
                                description="forbidden uris",
                                dest="forbidden_uris[]",
                                default=[],
                                action='append')

        parser_get.add_argument("calendar",
                                type=unicode,
                                description="Id of the calendar")
        parser_get.add_argument(
            "distance",
            type=int,
            default=200,
            description=
            "Distance range of the query. Used only if a coord is in the query"
        )
        parser_get.add_argument("show_codes",
                                type=boolean,
                                default=False,
                                description="show more identification codes")
        #Note: no default param for data freshness, the default depends on the API
        parser_get.add_argument(
            "data_freshness",
            description='freshness of the data. '
            'base_schedule is the long term planned schedule. '
            'adapted_schedule is for planned ahead disruptions (strikes, '
            'maintenances, ...). '
            'realtime is to have the freshest possible data',
            type=option_value(
                ['base_schedule', 'adapted_schedule', 'realtime']))
        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.")
        parser_get.add_argument(
            "items_per_schedule",
            type=natural,
            default=10000,
            description="maximum number of date_times per schedule")

        self.method_decorators.append(complete_links(self))
Esempio n. 10
0
    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=unicode, dest="origin")
        parser_get.add_argument("to", type=unicode, 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),
                                dest="origin_mode",
                                action="append")
        parser_get.add_argument("last_section_mode[]",
                                type=option_value(modes),
                                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_gt_0)
        parser_get.add_argument("bike_speed", type=float_gt_0)
        parser_get.add_argument("bss_speed", type=float_gt_0)
        parser_get.add_argument("car_speed", type=float_gt_0)
        parser_get.add_argument("forbidden_uris[]",
                                type=unicode,
                                action="append")
        parser_get.add_argument("count", type=default_count_arg_type)
        parser_get.add_argument("_min_journeys_calls", type=int)
        parser_get.add_argument("_final_line_filter", type=boolean)
        parser_get.add_argument("min_nb_journeys", type=int)
        parser_get.add_argument("max_nb_journeys", type=int)
        parser_get.add_argument("_max_extra_second_pass",
                                type=int,
                                dest="max_extra_second_pass")
        parser_get.add_argument("type",
                                type=option_value(types),
                                default="all")
        parser_get.add_argument("disruption_active",
                                type=boolean,
                                default=False)  # for retrocomp
        # no default value for data_freshness because we need to maintain retrocomp with disruption_active
        parser_get.add_argument("data_freshness",
                                type=option_value([
                                    'base_schedule', 'adapted_schedule',
                                    'realtime'
                                ]))

        parser_get.add_argument("max_duration", type=int)
        parser_get.add_argument("wheelchair", type=boolean, default=None)
        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(acceptable_traveler_types))
        parser_get.add_argument(
            "_override_scenario",
            type=unicode,
            description="debug param to specify a custom scenario")

        parser_get.add_argument("_walking_transfer_penalty", type=int)
        parser_get.add_argument("_night_bus_filter_base_factor", type=int)
        parser_get.add_argument("_night_bus_filter_max_factor", type=float)
        parser_get.add_argument("_min_car", type=int)
        parser_get.add_argument("_min_bike", type=int)
        parser_get.add_argument(
            "_current_datetime",
            type=date_time_format,
            default=datetime.utcnow(),
            description=
            "The datetime used to consider the state of the pt object"
            " Default is the current date and it is used for debug."
            " Note: it will mainly change the disruptions that concern "
            "the object The timezone should be specified in the format,"
            " else we consider it as UTC")

        self.method_decorators.append(complete_links(self))
Esempio n. 11
0
    def __init__(self):
        ResourceUri.__init__(self, authentication=False)
        ResourceUtc.__init__(self)

        modes = ["walking", "car", "bike", "bss"]
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        parser_get = self.parsers["get"]

        parser_get.add_argument("from", type=unicode, dest="origin")
        parser_get.add_argument("first_section_mode[]",
                                type=option_value(modes),
                                dest="origin_mode",
                                action="append")
        parser_get.add_argument("last_section_mode[]",
                                type=option_value(modes),
                                dest="destination_mode",
                                action="append")
        parser_get.add_argument("to", type=unicode, dest="destination")
        parser_get.add_argument("datetime", type=date_time_format)
        parser_get.add_argument("max_duration", type=unsigned_integer)
        parser_get.add_argument("min_duration",
                                type=unsigned_integer,
                                default=0)
        parser_get.add_argument("datetime_represents",
                                dest="clockwise",
                                type=dt_represents,
                                default=True)
        parser_get.add_argument("forbidden_uris[]",
                                type=unicode,
                                action="append")
        parser_get.add_argument("max_transfers", type=int, default=42)
        parser_get.add_argument(
            "_current_datetime",
            type=date_time_format,
            default=datetime.utcnow(),
            description=
            "The datetime used to consider the state of the pt object"
            " Default is the current date and it is used for debug."
            " Note: it will mainly change the disruptions that concern "
            "the object The timezone should be specified in the format,"
            " else we consider it as UTC")
        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_gt_0)
        parser_get.add_argument("bike_speed", type=float_gt_0)
        parser_get.add_argument("bss_speed", type=float_gt_0)
        parser_get.add_argument("car_speed", type=float_gt_0)
Esempio n. 12
0
    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))
Esempio n. 13
0
    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"
Esempio n. 14
0
    def __init__(self, *args, **kwargs):
        ResourceUri.__init__(self, authentication=False, *args, **kwargs)
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        self.parsers["get"].add_argument("q",
                                         type=unicode,
                                         required=True,
                                         description="The data to search")
        self.parsers["get"].add_argument(
            "type[]",
            type=option_value(pb_type),
            action="append",
            default=["stop_area", "address", "poi", "administrative_region"],
            description="The type of data to\
                                         search")
        self.parsers["get"].add_argument(
            "count",
            type=default_count_arg_type,
            default=10,
            description="The maximum number of places returned")
        self.parsers["get"].add_argument(
            "search_type",
            type=int,
            default=0,
            description="Type of search: firstletter or type error")
        self.parsers["get"].add_argument("admin_uri[]",
                                         type=unicode,
                                         action="append",
                                         description="If filled, will\
                                         restrained the search within the\
                                         given admin uris")
        self.parsers["get"].add_argument("depth",
                                         type=depth_argument,
                                         default=1,
                                         description="The depth of objects")
        self.parsers["get"].add_argument(
            "_current_datetime",
            type=date_time_format,
            default=datetime.datetime.utcnow(),
            description=
            "The datetime used to consider the state of the pt object"
            " Default is the current date and it is used for debug."
            " Note: it will mainly change the disruptions that concern "
            "the object The timezone should be specified in the format,"
            " else we consider it as UTC")
        self.parsers['get'].add_argument(
            "disable_geojson",
            type=boolean,
            default=False,
            description="remove geojson from the response")

        self.parsers['get'].add_argument(
            "from",
            type=coord_format,
            description="Coordinates longitude;latitude used to prioritize "
            "the objects around this coordinate")
        self.parsers['get'].add_argument(
            "_autocomplete",
            type=unicode,
            description="name of the autocomplete service"
            " used under the hood")