예제 #1
0
    def __init__(self, *args, **kwargs):
        ResourceUri.__init__(
            self, authentication=False, output_type_serializer=PlacesSerializer, *args, **kwargs
        )
        self.parsers["get"].add_argument("q", type=six.text_type, required=True, help="The data to search")
        self.parsers["get"].add_argument(
            "type[]",
            type=OptionValue(list(places_type)),
            action="append",
            default=["stop_area", "address", "poi", "administrative_region"],
            help="The type of data to search",
        )
        self.parsers["get"].add_argument(
            "count", type=default_count_arg_type, default=10, help="The maximum number of places returned"
        )
        self.parsers["get"].add_argument(
            "search_type", type=int, default=0, hidden=True, help="Type of search: firstletter or type error"
        )
        self.parsers["get"].add_argument(
            "_main_stop_area_weight_factor",
            type=float,
            default=1.0,
            hidden=True,
            help="multiplicator for the weight of main stop area",
        )
        self.parsers["get"].add_argument(
            "admin_uri[]",
            type=six.text_type,
            action="append",
            help="If filled, will restrain the search within the " "given admin uris",
        )
        self.parsers["get"].add_argument("depth", type=DepthArgument(), default=1, help="The depth of objects")
        self.parsers["get"].add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.utcnow(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.',
        )
        self.parsers['get'].add_argument(
            "disable_geojson", type=BooleanType(), default=False, help="remove geojson from the response"
        )

        self.parsers['get'].add_argument(
            "from",
            type=CoordFormat(nullable=True),
            help="Coordinates longitude;latitude used to prioritize " "the objects around this coordinate",
        )
        self.parsers['get'].add_argument(
            "_autocomplete",
            type=six.text_type,
            hidden=True,
            help="name of the autocomplete service, used under the hood",
        )
        self.parsers['get'].add_argument(
            'shape', type=geojson_argument(), help='Geographical shape to limit the search.'
        )
예제 #2
0
    def __init__(self):
        ResourceUri.__init__(self)
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth", type=int, default=1)
        parser_get.add_argument("count", type=default_count_arg_type, default=10,
                                description="Number of calendars per page")
        parser_get.add_argument("start_page", type=int, default=0,
                                description="The current page")
        parser_get.add_argument("start_date", type=unicode, default="",
                                description="Start date")
        parser_get.add_argument("end_date", type=unicode, default="",
                                description="End date")
        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("distance", type=int, default=200,
                                description="Distance range of the query. Used only if a coord is in the query")

        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")
예제 #3
0
    def __init__(self, endpoint, *args, **kwargs):
        ResourceUri.__init__(self, *args, **kwargs)
        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=six.text_type)
        parser_get.add_argument("from_datetime", type=DateTimeFormat(), default=None,
                                help="The datetime from which you want the schedules")
        parser_get.add_argument("until_datetime", type=DateTimeFormat(), default=None,
                                help="The datetime until which you want the schedules")
        parser_get.add_argument("duration", type=int, default=3600 * 24,
                                help="Maximum duration between datetime and the retrieved stop time")
        parser_get.add_argument("depth", type=depth_argument, default=2)
        parser_get.add_argument("count", type=default_count_arg_type, default=10,
                                help="Number of schedules per page")
        parser_get.add_argument("start_page", type=int, default=0,
                                help="The current page")
        parser_get.add_argument("max_date_times", type=UnsignedInteger(), deprecated=True,
                                help="DEPRECATED, replaced by `items_per_schedule`")
        parser_get.add_argument("forbidden_id[]", type=six.text_type, deprecated=True,
                                help="DEPRECATED, replaced by `forbidden_uris[]`",
                                dest="__temporary_forbidden_id[]",
                                default=[],
                                action='append',
                                schema_metadata={'format': 'pt-object'})
        parser_get.add_argument("forbidden_uris[]", type=six.text_type,
                                help="forbidden uris",
                                dest="forbidden_uris[]",
                                default=[],
                                action='append',
                                schema_metadata={'format': 'pt-object'})
        parser_get.add_argument("calendar", type=six.text_type,
                                help="Id of the calendar")
        parser_get.add_argument("distance", type=int, default=200,
                                help="Distance range of the query. Used only if a coord is in the query")
        parser_get.add_argument("show_codes", type=BooleanType(), default=False,
                                help="show more identification codes")
        #Note: no default param for data freshness, the default depends on the API
        parser_get.add_argument("data_freshness",
                                help='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=OptionValue(['base_schedule', 'adapted_schedule', 'realtime']))
        parser_get.add_argument("_current_datetime", type=DateTimeFormat(),
                                schema_metadata={'default': 'now'}, hidden=True,
                                default=datetime.utcnow(),
                                help='The datetime considered as "now". Used for debug, default is '
                                     'the moment of the request. It will mainly change the output '
                                     'of the disruptions.')
        parser_get.add_argument("items_per_schedule", type=UnsignedInteger(), default=10000,
                                help="maximum number of date_times per schedule")
        parser_get.add_argument("disable_geojson", type=BooleanType(), default=False,
                                help="remove geojson from the response")

        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
        self.get_decorators.append(complete_links(self))
예제 #4
0
    def __init__(self, **kwargs):
        ResourceUri.__init__(self, authentication=False, **kwargs)
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        self.parsers["get"].add_argument(
            "bss_stands",
            type=boolean,
            default=True,
            description="Show bss stands availability")
        self.parsers['get'].add_argument(
            "disable_geojson",
            type=boolean,
            default=False,
            description="remove geojson from the response")
        args = self.parsers["get"].parse_args()

        if args["bss_stands"]:
            self.method_decorators.insert(1, ManageStands(self, 'places'))

        if args['disable_geojson']:
            g.disable_geojson = True

        self.parsers['get'].add_argument(
            "_autocomplete",
            type=unicode,
            description="name of the autocomplete service"
            " used under the hood")
예제 #5
0
 def __init__(self, *args, **kwargs):
     ResourceUri.__init__(self,
                          output_type_serializer=api.PtObjectsSerializer,
                          *args,
                          **kwargs)
     self.parsers["get"].add_argument("q",
                                      type=six.text_type,
                                      required=True,
                                      help="The data to search")
     self.parsers["get"].add_argument(
         "type[]",
         type=OptionValue(pt_object_type_values),
         action="append",
         default=pt_object_type_default_values,
         help="The type of data to search",
     )
     self.parsers["get"].add_argument(
         "count",
         type=default_count_arg_type,
         default=10,
         help="The maximum number of ptobjects returned")
     self.parsers["get"].add_argument(
         "search_type",
         type=int,
         default=0,
         hidden=True,
         help="Type of search: firstletter or type error")
     self.parsers["get"].add_argument(
         "admin_uri[]",
         type=six.text_type,
         action="append",
         help="If filled, will restrain the search within "
         "the given admin uris",
     )
     self.parsers["get"].add_argument("depth",
                                      type=DepthArgument(),
                                      default=1,
                                      help="The depth of objects")
     self.parsers["get"].add_argument(
         "_current_datetime",
         type=DateTimeFormat(),
         schema_metadata={'default': 'now'},
         hidden=True,
         default=datetime.now(),
         help='The datetime considered as "now". Used for debug, default is '
         'the moment of the request. It will mainly change the output '
         'of the disruptions.',
     )
     self.parsers['get'].add_argument(
         "disable_geojson",
         type=BooleanType(),
         default=False,
         help="remove geojson from the response")
     self.parsers['get'].add_argument(
         "disable_disruption",
         type=BooleanType(),
         default=False,
         help="remove disruptions from the response")
     self.collection = 'pt_objects'
     self.get_decorators.insert(0, get_obj_serializer(self))
예제 #6
0
    def __init__(self):
        ResourceUri.__init__(self, output_type_serializer=api.LineReportsSerializer)
        ResourceUtc.__init__(self)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth", type=int, default=1, help="The depth of your object")
        parser_get.add_argument("count", type=default_count_arg_type, default=25,
                                help="Number of objects per page")
        parser_get.add_argument("start_page", type=int, default=0,
                                help="The current page")
        parser_get.add_argument("_current_datetime", type=DateTimeFormat(),
                                schema_metadata={'default': 'now'}, hidden=True,
                                default=datetime.utcnow(),
                                help='The datetime considered as "now". Used for debug, default is '
                                     'the moment of the request. It will mainly change the output '
                                     'of the disruptions.')
        parser_get.add_argument("forbidden_uris[]", type=six.text_type,
                                help="forbidden uris",
                                dest="forbidden_uris[]",
                                default=[],
                                action="append",
                                schema_metadata={'format': 'pt-object'})
        parser_get.add_argument("disable_geojson", type=BooleanType(), default=False,
                                help="remove geojson from the response")
        parser_get.add_argument("since", type=DateTimeFormat(),
                                help="use disruptions valid after this date")
        parser_get.add_argument("until", type=DateTimeFormat(),
                                help="use disruptions valid before this date")

        self.collection = 'line_reports'
        self.collections = line_reports
        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
예제 #7
0
 def __init__(self):
     ResourceUri.__init__(self,
                          output_type_serializer=api.CalendarsSerializer)
     parser_get = self.parsers["get"]
     parser_get.add_argument("depth",
                             type=depth_argument,
                             default=1,
                             help="The depth of your object")
     parser_get.add_argument("count",
                             type=default_count_arg_type,
                             default=10,
                             help="Number of calendars per page")
     parser_get.add_argument("start_page",
                             type=int,
                             default=0,
                             help="The current page")
     parser_get.add_argument("start_date",
                             type=six.text_type,
                             default="",
                             help="Start date")
     parser_get.add_argument("end_date",
                             type=six.text_type,
                             default="",
                             help="End date")
     parser_get.add_argument(
         "forbidden_id[]",
         type=six.text_type,
         deprecated=True,
         help="DEPRECATED, replaced by `forbidden_uris[]`",
         dest="__temporary_forbidden_id[]",
         default=[],
         action='append',
         schema_metadata={'format': 'pt-object'})
     parser_get.add_argument("forbidden_uris[]",
                             type=six.text_type,
                             help="forbidden uris",
                             dest="forbidden_uris[]",
                             default=[],
                             action="append",
                             schema_metadata={'format': 'pt-object'})
     parser_get.add_argument(
         "distance",
         type=int,
         default=200,
         help=
         "Distance range of the query. Used only if a coord is in the query"
     )
     parser_get.add_argument(
         "_current_datetime",
         type=DateTimeFormat(),
         schema_metadata={'default': 'now'},
         hidden=True,
         default=datetime.utcnow(),
         help='The datetime considered as "now". Used for debug, default is '
         'the moment of the request. It will mainly change the output '
         'of the disruptions.')
     self.collection = 'calendars'
     self.collections = calendars
     self.get_decorators.insert(0, ManageError())
     self.get_decorators.insert(1, get_obj_serializer(self))
예제 #8
0
    def __init__(self, **kwargs):
        ResourceUri.__init__(self, authentication=False, **kwargs)
        self.parsers["get"].add_argument("bss_stands",
                                         type=BooleanType(),
                                         default=True,
                                         help="Show bss stands availability")
        self.parsers["get"].add_argument(
            "add_poi_infos[]",
            type=OptionValue(add_poi_infos_types),
            default=['bss_stands', 'car_park'],
            dest="add_poi_infos",
            action="append",
            help=
            "Show more information about the poi if it's available, for instance, "
            "show BSS/car park availability in the pois(BSS/car park) of response"
        )
        self.parsers['get'].add_argument(
            "disable_geojson",
            type=BooleanType(),
            default=False,
            help="remove geojson from the response")
        args = self.parsers["get"].parse_args()

        if args["add_poi_infos"] or args["bss_stands"]:
            self.get_decorators.insert(1, ManageParkingPlaces(self, 'places'))

        if args['disable_geojson']:
            g.disable_geojson = True

        self.parsers['get'].add_argument(
            "_autocomplete",
            type=six.text_type,
            hidden=True,
            help="name of the autocomplete service, used under the hood")
예제 #9
0
    def __init__(self):
        ResourceUri.__init__(
            self, output_type_serializer=api.EquipmentReportsSerializer)
        ResourceUtc.__init__(self)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth",
                                type=DepthArgument(),
                                default=1,
                                help="The depth of your object")
        parser_get.add_argument("count",
                                type=default_count_arg_type,
                                default=25,
                                help="Number of objects per page")
        parser_get.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="Filter your objects")
        parser_get.add_argument("start_page",
                                type=int,
                                default=0,
                                help="The current page")
        parser_get.add_argument(
            "forbidden_uris[]",
            type=six.text_type,
            help="forbidden uris",
            dest="forbidden_uris[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )

        self.collection = 'equipment_reports'
        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
예제 #10
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(
            "type[]",
            type=unicode,
            action="append",
            default=["stop_area", "stop_point", "poi"],
            description="Type of the objects to\
                                         return")
        self.parsers["get"].add_argument("filter",
                                         type=unicode,
                                         default="",
                                         description="Filter your objects")
        self.parsers["get"].add_argument("distance",
                                         type=int,
                                         default=500,
                                         description="Distance range of the\
                                         query")
        self.parsers["get"].add_argument("count",
                                         type=default_count_arg_type,
                                         default=10,
                                         description="Elements per page")
        self.parsers["get"].add_argument("depth",
                                         type=depth_argument,
                                         default=1,
                                         description="Maximum depth on\
                                         objects")
        self.parsers["get"].add_argument("start_page",
                                         type=int,
                                         default=0,
                                         description="The page number of the\
                                         ptref result")
        self.parsers["get"].add_argument(
            "bss_stands",
            type=boolean,
            default=True,
            description="Show bss stands availability")

        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")
        args = self.parsers["get"].parse_args()
        if args["bss_stands"]:
            self.method_decorators.insert(1,
                                          ManageStands(self, 'places_nearby'))
예제 #11
0
 def __init__(self, *args, **kwargs):
     ResourceUri.__init__(self, output_type_serializer=PlacesNearbySerializer, *args, **kwargs)
     self.parsers["get"].add_argument("type[]", type=OptionValue(list(places_type.keys())),
                                      action="append",
                                      default=["stop_area", "stop_point", "poi"],
                                      help="Type of the objects to return")
     self.parsers["get"].add_argument("filter", type=six.text_type, default="",
                                      help="Filter your objects")
     self.parsers["get"].add_argument("distance", type=int, default=500,
                                      help="Distance range of the query in meters")
     self.parsers["get"].add_argument("count", type=default_count_arg_type, default=10,
                                      help="Elements per page")
     self.parsers["get"].add_argument("depth", type=depth_argument, default=1,
                                      help="Maximum depth on objects")
     self.parsers["get"].add_argument("start_page", type=int, default=0,
                                      help="The page number of the ptref result")
     self.parsers["get"].add_argument("bss_stands", type=BooleanType(), default=False, deprecated=True,
                                      help="DEPRECATED, Use add_poi_infos[]=bss_stands")
     self.parsers["get"].add_argument("add_poi_infos[]", type=OptionValue(add_poi_infos_types),
                                      default=['bss_stands', 'car_park'],
                                      dest="add_poi_infos", action="append",
                                      help="Show more information about the poi if it's available, for instance, "
                                           "show BSS/car park availability in the pois(BSS/car park) of the response")
     self.parsers["get"].add_argument("_current_datetime", type=DateTimeFormat(),
                                      schema_metadata={'default': 'now'}, hidden=True,
                                      default=datetime.utcnow(),
                                      help='The datetime considered as "now". Used for debug, default is '
                                           'the moment of the request. It will mainly change the output '
                                           'of the disruptions.')
     self.parsers['get'].add_argument("disable_geojson", type=BooleanType(), default=False,
                                      help="remove geojson from the response")
     args = self.parsers["get"].parse_args()
     if handle_poi_infos(args["add_poi_infos"], args["bss_stands"]):
         self.get_decorators.insert(1, ManageParkingPlaces(self, 'places_nearby'))
예제 #12
0
 def __init__(self, *args, **kwargs):
     ResourceUri.__init__(self, output_type_serializer=api.DictAddressesSerializer, *args, **kwargs)
     self.parsers['get'].add_argument(
         "_autocomplete",
         type=six.text_type,
         hidden=True,
         help="name of the autocomplete service, used under the hood",
     )
예제 #13
0
 def __init__(self):
     ResourceUri.__init__(self, output_type_serializer=api.TrafficReportsSerializer)
     parser_get = self.parsers["get"]
     parser_get.add_argument("depth", type=DepthArgument(), default=1, help="The depth of your object")
     parser_get.add_argument(
         "count", type=default_count_arg_type, default=10, help="Number of objects per page"
     )
     parser_get.add_argument("start_page", type=int, default=0, help="The current page")
     parser_get.add_argument(
         "_current_datetime",
         type=DateTimeFormat(),
         schema_metadata={'default': 'now'},
         hidden=True,
         default=datetime.utcnow(),
         help='The datetime considered as "now". Used for debug, default is '
         'the moment of the request. It will mainly change the output '
         'of the disruptions.',
     )
     parser_get.add_argument(
         "forbidden_id[]",
         type=six.text_type,
         deprecated=True,
         help="DEPRECATED, replaced by `forbidden_uris[]`",
         dest="__temporary_forbidden_id[]",
         default=[],
         action='append',
         schema_metadata={'format': 'pt-object'},
     )
     parser_get.add_argument(
         "forbidden_uris[]",
         type=six.text_type,
         help="forbidden uris",
         dest="forbidden_uris[]",
         default=[],
         action='append',
         schema_metadata={'format': 'pt-object'},
     )
     parser_get.add_argument(
         "distance",
         type=int,
         default=200,
         help="Distance range of the query. Used only if a coord is in the query",
     )
     parser_get.add_argument(
         "disable_geojson", type=BooleanType(), default=False, help="remove geojson from the response"
     )
     parser_get.add_argument(
         "tags[]",
         type=six.text_type,
         action="append",
         help="If filled, will restrain the search within the given disruption tags",
     )
     self.collection = 'traffic_reports'
     self.get_decorators.insert(0, ManageError())
     self.get_decorators.insert(1, get_obj_serializer(self))
예제 #14
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=six.text_type)
        parser_get.add_argument("from_datetime", type=DateTimeFormat(), default=None,
                                help="The datetime from which you want the schedules")
        parser_get.add_argument("until_datetime", type=DateTimeFormat(), default=None,
                                help="The datetime until which you want the schedules")
        parser_get.add_argument("duration", type=int, default=3600 * 24,
                                help="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,
                                help="Number of schedules per page")
        parser_get.add_argument("start_page", type=int, default=0,
                                help="The current page")
        parser_get.add_argument("max_date_times", type=natural,
                                help="DEPRECATED, replaced by `items_per_schedule`")
        parser_get.add_argument("forbidden_id[]", type=six.text_type,
                                help="DEPRECATED, replaced by `forbidden_uris[]`",
                                dest="__temporary_forbidden_id[]",
                                default=[],
                                action='append')
        parser_get.add_argument("forbidden_uris[]", type=six.text_type,
                                help="forbidden uris",
                                dest="forbidden_uris[]",
                                default=[],
                                action='append')

        parser_get.add_argument("calendar", type=six.text_type,
                                help="Id of the calendar")
        parser_get.add_argument("distance", type=int, default=200,
                                help="Distance range of the query. Used only if a coord is in the query")
        parser_get.add_argument("show_codes", type=BooleanType(), default=False,
                                help="show more identification codes")
        #Note: no default param for data freshness, the default depends on the API
        parser_get.add_argument("data_freshness",
                                help='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=OptionValue(['base_schedule', 'adapted_schedule', 'realtime']))
        parser_get.add_argument("_current_datetime", type=DateTimeFormat(), default=datetime.datetime.utcnow(),
                                help="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,
                                help="maximum number of date_times per schedule")
        parser_get.add_argument("disable_geojson", type=BooleanType(), default=False,
                                help="remove geojson from the response")

        self.get_decorators.append(complete_links(self))
예제 #15
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(
         "bss_stands",
         type=bool,
         default=True,
         description="Show bss stands availability")
     args = self.parsers["get"].parse_args()
     if args["bss_stands"]:
         self.method_decorators.insert(1, ManageStands(self, 'places'))
예제 #16
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")
예제 #17
0
파일: Places.py 프로젝트: xlqian/navitia
    def __init__(self, *args, **kwargs):
        ResourceUri.__init__(self,
                             authentication=False,
                             output_type_serializer=PlacesSerializer,
                             *args,
                             **kwargs)
        self.parsers["get"].add_argument(
            "bss_stands",
            type=BooleanType(),
            default=False,
            deprecated=True,
            help="DEPRECATED, Use add_poi_infos[]=bss_stands",
        )
        self.parsers["get"].add_argument(
            "add_poi_infos[]",
            type=OptionValue(add_poi_infos_types),
            default=['bss_stands', 'car_park'],
            dest="add_poi_infos",
            action="append",
            help=
            "Show more information about the poi if it's available, for instance, "
            "show BSS/car park availability in the pois(BSS/car park) of the response",
        )
        self.parsers['get'].add_argument(
            "disable_geojson",
            type=BooleanType(),
            default=False,
            help="remove geojson from the response")
        self.parsers['get'].add_argument(
            "disable_disruption",
            type=BooleanType(),
            default=False,
            help="remove disruptions from the response")
        args = self.parsers["get"].parse_args()

        if handle_poi_infos(args["add_poi_infos"], args["bss_stands"]):
            self.get_decorators.insert(1, ManageParkingPlaces(self, 'places'))

        if args['disable_geojson']:
            g.disable_geojson = True

        self.parsers['get'].add_argument(
            "_autocomplete",
            type=six.text_type,
            hidden=True,
            choices=['kraken', 'bragi', 'bragi7'],
            help="name of the autocomplete service, used under the hood",
        )
예제 #18
0
 def __init__(self, *args, **kwargs):
     ResourceUri.__init__(self, *args, **kwargs)
     parser_get = self.parsers["get"]
     parser_get.add_argument(
         "type[]",
         type=OptionValue(free_floatings_type),
         action="append",
         help="Type of free-floating objects to return",
     )
     parser_get.add_argument("distance", type=int, default=500, help="Distance range of the query in meters")
     parser_get.add_argument("count", type=default_count_arg_type, default=10, help="Elements per page")
     self.parsers['get'].add_argument(
         "coord",
         type=CoordFormat(nullable=True),
         help="Coordinates longitude;latitude used to search " "the objects around this coordinate",
     )
예제 #19
0
    def __init__(self, *args, **kwargs):
        ResourceUri.__init__(self, *args, **kwargs)
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        parser_get = self.parsers["get"]
        self.parsers["get"].add_argument(
            "type[]",
            type=unicode,
            action="append",
            default=["stop_area", "stop_point", "poi"],
            description="Type of the objects to\
                                         return")
        self.parsers["get"].add_argument("filter",
                                         type=unicode,
                                         default="",
                                         description="Filter your objects")
        self.parsers["get"].add_argument("distance",
                                         type=int,
                                         default=500,
                                         description="Distance range of the\
                                         query")
        self.parsers["get"].add_argument("count",
                                         type=default_count_arg_type,
                                         default=10,
                                         description="Elements per page")
        self.parsers["get"].add_argument("depth",
                                         type=depth_argument,
                                         default=1,
                                         description="Maximum depth on\
                                         objects")
        self.parsers["get"].add_argument("start_page",
                                         type=int,
                                         default=0,
                                         description="The page number of the\
                                         ptref result")

        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")
예제 #20
0
 def __init__(self):
     ResourceUri.__init__(self)
     self.parsers = {}
     self.parsers["get"] = reqparse.RequestParser(
         argument_class=ArgumentDoc)
     parser_get = self.parsers["get"]
     parser_get.add_argument("depth", type=int, default=1)
     parser_get.add_argument("count",
                             type=default_count_arg_type,
                             default=10,
                             description="Number of disruptions per page")
     parser_get.add_argument("start_page",
                             type=int,
                             default=0,
                             description="The current page")
     parser_get.add_argument(
         "_current_datetime",
         type=date_time_format,
         default=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(
         "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(
         "distance",
         type=int,
         default=200,
         description=
         "Distance range of the query. Used only if a coord is in the query"
     )
     parser_get.add_argument("disable_geojson",
                             type=boolean,
                             default=False,
                             description="remove geojson from the response")
     self.collection = 'traffic_reports'
예제 #21
0
    def __init__(self):
        ResourceUri.__init__(
            self, output_type_serializer=api.VehiclePositionsSerializer)
        ResourceUtc.__init__(self)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth",
                                type=DepthArgument(),
                                default=1,
                                help="The depth of your object")
        parser_get.add_argument("count",
                                type=default_count_arg_type,
                                default=25,
                                help="Number of objects per page")
        parser_get.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="Filter your objects")
        parser_get.add_argument("start_page",
                                type=int,
                                default=0,
                                help="The current page")
        parser_get.add_argument(
            "forbidden_uris[]",
            type=six.text_type,
            help="forbidden uris",
            dest="forbidden_uris[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )
        parser_get.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.utcnow(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.',
        )

        self.collection = 'vehicle_positions'
        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
예제 #22
0
파일: Places.py 프로젝트: ISI-nc/navitia
    def __init__(self, **kwargs):
        ResourceUri.__init__(self, authentication=False, **kwargs)
        self.parsers["get"].add_argument("bss_stands",
                                         type=BooleanType(),
                                         default=True,
                                         help="Show bss stands availability")
        self.parsers['get'].add_argument(
            "disable_geojson",
            type=BooleanType(),
            default=False,
            help="remove geojson from the response")
        args = self.parsers["get"].parse_args()

        if args["bss_stands"]:
            self.get_decorators.insert(1, ManageStands(self, 'places'))

        if args['disable_geojson']:
            g.disable_geojson = True

        self.parsers['get'].add_argument(
            "_autocomplete",
            type=six.text_type,
            hidden=True,
            help="name of the autocomplete service, used under the hood")
예제 #23
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)
예제 #24
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")
예제 #25
0
    def __init__(self, output_type_serializer):
        ResourceUri.__init__(self,
                             authentication=False,
                             output_type_serializer=output_type_serializer)
        ResourceUtc.__init__(self)

        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",
        }
        data_freshnesses = {
            'base_schedule':
            'Use theoric schedule information',
            'realtime':
            'Use all realtime information',
            'adapted_schedule':
            'Use of adapted schedule information (like strike adjusting, etc.). '
            'Prefer `realtime` for traveler information as it will also contain '
            'adapted information schedule.',
        }
        parser_get = self.parsers["get"]

        parser_get.add_argument(
            "from",
            type=six.text_type,
            dest="origin",
            help='The id of the departure of your journey. '
            'If not provided an isochrone is computed.',
            schema_metadata={'format': 'place'},
        )
        parser_get.add_argument(
            "to",
            type=six.text_type,
            dest="destination",
            help='The id of the arrival of your journey. '
            'If not provided an isochrone is computed.',
            schema_metadata={'format': 'place'},
        )
        parser_get.add_argument(
            "datetime",
            type=DateTimeFormat(),
            help='Date and time to go/arrive (see `datetime_represents`).\n'
            'Note: the datetime must be in the coverage’s publication period.',
        )
        parser_get.add_argument(
            "datetime_represents",
            dest="clockwise",
            type=DatetimeRepresents(),
            default=True,
            help="Determine how datetime is handled.\n\n"
            "Possible values:\n"
            " * 'departure' - Compute journeys starting after datetime\n"
            " * 'arrival' - Compute journeys arriving before datetime",
        )
        parser_get.add_argument("max_transfers",
                                type=int,
                                default=42,
                                hidden=True,
                                deprecated=True)
        parser_get.add_argument(
            "max_nb_transfers",
            type=int,
            dest="max_transfers",
            help='Maximum number of transfers in each journey',
        )
        parser_get.add_argument(
            "min_nb_transfers",
            type=int,
            default=0,
            help='Minimum number of transfers in each journey')
        parser_get.add_argument(
            "first_section_mode[]",
            type=OptionValue(fallback_modes.all_fallback_modes),
            dest="origin_mode",
            action="append",
            help='Force the first section mode '
            'if the first section is not a public transport one.\n'
            '`bss` stands for bike sharing system.\n'
            'Note 1: It’s an array, you can give multiple modes.\n'
            'Note 2: Choosing `bss` implicitly allows the walking mode since '
            'you might have to walk to the bss station.\n'
            'Note 3: The parameter is inclusive, not exclusive, '
            'so if you want to forbid a mode, you need to add all the other modes. '
            'Eg: If you never want to use a car, you need: '
            '`first_section_mode[]=walking&first_section_mode[]=bss&'
            'first_section_mode[]=bike&last_section_mode[]=walking&'
            'last_section_mode[]=bss&last_section_mode[]=bike`',
        )
        parser_get.add_argument(
            "last_section_mode[]",
            type=OptionValue(fallback_modes.all_fallback_modes),
            dest="destination_mode",
            action="append",
            help='Same as first_section_mode but for the last section.',
        )
        # for retrocompatibility purpose, we duplicate (without []):
        parser_get.add_argument(
            "first_section_mode",
            hidden=True,
            deprecated=True,
            type=OptionValue(fallback_modes.all_fallback_modes),
            action="append",
        )
        parser_get.add_argument(
            "last_section_mode",
            hidden=True,
            deprecated=True,
            type=OptionValue(fallback_modes.all_fallback_modes),
            action="append",
        )

        parser_get.add_argument(
            "max_duration_to_pt",
            type=int,
            help=
            "Maximum allowed duration to reach the public transport (same limit used before and "
            "after public transport).\n"
            "Use this to limit the walking/biking part.\n"
            "Unit is seconds",
        )
        parser_get.add_argument(
            "max_walking_duration_to_pt",
            type=int,
            help="Maximal duration of walking on public transport in second",
        )
        parser_get.add_argument(
            "max_bike_duration_to_pt",
            type=int,
            help="Maximal duration of bike on public transport in second")
        parser_get.add_argument(
            "max_bss_duration_to_pt",
            type=int,
            help="Maximal duration of bss on public transport in second")
        parser_get.add_argument(
            "max_car_duration_to_pt",
            type=int,
            help="Maximal duration of car on public transport in second")
        parser_get.add_argument(
            "max_ridesharing_duration_to_pt",
            type=int,
            dest="max_car_no_park_duration_to_pt",
            help=
            "Maximal duration of ridesharing on public transport in second",
        )
        parser_get.add_argument(
            "walking_speed",
            type=PositiveFloat(),
            help='Walking speed for the fallback sections.\n'
            'Speed unit must be in meter/second',
        )
        parser_get.add_argument(
            "bike_speed",
            type=PositiveFloat(),
            help='Biking speed for the fallback sections.\n'
            'Speed unit must be in meter/second',
        )
        parser_get.add_argument(
            "bss_speed",
            type=PositiveFloat(),
            help='Speed while using a bike from a bike sharing system for the '
            'fallback sections.\n'
            'Speed unit must be in meter/second',
        )
        parser_get.add_argument(
            "car_speed",
            type=PositiveFloat(),
            help='Driving speed for the fallback sections.\n'
            'Speed unit must be in meter/second',
        )
        parser_get.add_argument(
            "ridesharing_speed",
            type=PositiveFloat(),
            dest="car_no_park_speed",
            help='ridesharing speed for the fallback sections.\n'
            'Speed unit must be in meter/second',
        )
        parser_get.add_argument(
            "taxi_speed",
            type=PositiveFloat(),
            dest="taxi_speed",
            help='taxi speed speed for the fallback sections.\n'
            'Speed unit must be in meter/second',
        )
        parser_get.add_argument(
            "forbidden_uris[]",
            type=six.text_type,
            action="append",
            help='If you want to avoid lines, modes, networks, etc.\n'
            'Note: the forbidden_uris[] concern only the public transport objects. '
            'You can’t for example forbid the use of the bike with them, '
            'you have to set the fallback modes for this '
            '(first_section_mode[] and last_section_mode[])',
            schema_metadata={'format': 'pt-object'},
        )
        parser_get.add_argument(
            "allowed_id[]",
            type=six.text_type,
            action="append",
            help='If you want to use only a small subset of '
            'the public transport objects in your solution.\n'
            'Note: The constraint intersects with forbidden_uris[]. '
            'For example, if you ask for '
            '`allowed_id[]=line:A&forbidden_uris[]=physical_mode:Bus`, '
            'only vehicles of the line A that are not buses will be used.',
            schema_metadata={'format': 'pt-object'},
        )
        parser_get.add_argument(
            "type",
            type=DescribedOptionValue(types),
            default="all",
            deprecated=True,
            help='DEPRECATED, desired type of journey.',
            hidden=True,
        )
        parser_get.add_argument(
            "disruption_active",
            type=BooleanType(),
            default=False,
            deprecated=True,
            help='DEPRECATED, replaced by `data_freshness`.\n'
            'If true the algorithm takes the disruptions into account, '
            'and thus avoid disrupted public transport.\n'
            'Nota: `disruption_active=true` <=> `data_freshness=realtime`',
        )
        # no default value for data_freshness because we need to maintain retrocomp with disruption_active
        parser_get.add_argument(
            "data_freshness",
            type=DescribedOptionValue(data_freshnesses),
            help="Define the freshness of data to use to compute journeys.\n"
            "When using the following parameter `&data_freshness=base_schedule` "
            "you can get disrupted journeys in the response. "
            "You can then display the disruption message to the traveler and "
            "make a `realtime` request to get a new undisrupted solution.",
        )
        parser_get.add_argument(
            "max_duration",
            type=UnsignedInteger(),
            help=
            'Maximum duration of journeys in seconds (from `datetime` parameter).\n'
            'More usefull when computing an isochrone (only `from` or `to` is provided).\n'
            'On a classic journey (from-to), it will mostly speedup Navitia: You may have journeys a bit '
            'longer than that value (you would have to filter them).',
        )
        parser_get.add_argument(
            "wheelchair",
            type=BooleanType(),
            default=None,
            help='If true the traveler is considered to be using a wheelchair, '
            'thus only accessible public transport are used.\n'
            'Be warned: many data are currently too faint to provide '
            'acceptable answers with this parameter on.',
        )
        parser_get.add_argument(
            "traveler_type",
            type=OptionValue(acceptable_traveler_types),
            help=
            'Define speeds and accessibility values for different kind of people.\n'
            'Each profile also automatically determines appropriate first and '
            'last section modes to the covered area.\n'
            'Note: this means that you might get car, bike, etc. fallback routes '
            'even if you set `forbidden_uris[]`!\n'
            'You can overload all parameters '
            '(especially speeds, distances, first and last modes) by setting '
            'all of them specifically.\n'
            'We advise that you don’t rely on the traveler_type’s fallback modes '
            '(`first_section_mode[]` and `last_section_mode[]`) '
            'and set them yourself.',
        )
        parser_get.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.utcnow(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.',
        )
        parser_get.add_argument(
            "direct_path",
            type=OptionValue(['indifferent', 'only', 'none']),
            default='indifferent',
            help="Specify if direct path should be suggested",
        )

        parser_get.add_argument(
            "free_radius_from",
            type=int,
            default=0,
            help="Radius length (in meters) around the coordinates of departure "
            "in which the stop points are considered free to go (crowfly=0)",
        )
        parser_get.add_argument(
            "free_radius_to",
            type=int,
            default=0,
            help="Radius length (in meters) around the coordinates of arrival "
            "in which the stop points are considered free to go (crowfly=0)",
        )
예제 #26
0
파일: Uri.py 프로젝트: niko64fx/navitia
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        self.parsers = {}
        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=default_count_arg_type,
                            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="DEPRECATED, replaced by forbidden_uris[]",
            dest="__temporary_forbidden_id[]",
            default=[],
            action="append")
        parser.add_argument("forbidden_uris[]",
                            type=unicode,
                            description="forbidden uris",
                            dest="forbidden_uris[]",
                            default=[],
                            action="append")
        parser.add_argument("external_code",
                            type=unicode,
                            description="An external code to query")
        parser.add_argument("headsign",
                            type=unicode,
                            description="filter vehicle journeys on headsign")
        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"
        )
        parser.add_argument(
            "since",
            type=date_time_format,
            description="filters objects not valid before this date")
        parser.add_argument(
            "until",
            type=date_time_format,
            description="filters objects not valid after this date")

        if is_collection:
            parser.add_argument("filter",
                                type=unicode,
                                default="",
                                description="The filter parameter")
        self.collection = collection
        self.method_decorators.insert(0, ManageError())
예제 #27
0
파일: Uri.py 프로젝트: vmulard/navitia
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        parser = self.parsers["get"]
        parser.add_argument("start_page",
                            type=int,
                            default=0,
                            help="The page where you want to start")
        parser.add_argument("count",
                            type=default_count_arg_type,
                            default=25,
                            help="Number of objects you want on a page")
        parser.add_argument("depth",
                            type=depth_argument,
                            schema_type=int,
                            default=1,
                            help="The depth of your object")
        parser.add_argument("forbidden_id[]",
                            type=six.text_type,
                            help="DEPRECATED, replaced by `forbidden_uris[]`",
                            dest="__temporary_forbidden_id[]",
                            default=[],
                            action="append",
                            schema_metadata={'format': 'pt-object'})
        parser.add_argument("forbidden_uris[]",
                            type=six.text_type,
                            help="forbidden uris",
                            dest="forbidden_uris[]",
                            default=[],
                            action="append",
                            schema_metadata={'format': 'pt-object'})
        # for the top level collection apis (/v1/networks, /v1/lines, ...) the external_code is mandatory
        external_code_mandatory = '.external_codes' in self.endpoint
        parser.add_argument("external_code",
                            type=six.text_type,
                            help="An external code to query",
                            required=external_code_mandatory)
        parser.add_argument("headsign",
                            type=six.text_type,
                            help="filter vehicle journeys on headsign")
        parser.add_argument("show_codes",
                            type=BooleanType(),
                            default=False,
                            help="show more identification codes")
        parser.add_argument("odt_level",
                            type=OptionValue(odt_levels),
                            default="all",
                            schema_type=str,
                            schema_metadata={"enum": odt_levels},
                            help="odt level")
        parser.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.utcnow(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.')
        parser.add_argument(
            "distance",
            type=int,
            default=200,
            help=
            "Distance range of the query. Used only if a coord is in the query"
        )
        parser.add_argument("since",
                            type=DateTimeFormat(),
                            help="filters objects not valid before this date")
        parser.add_argument("until",
                            type=DateTimeFormat(),
                            help="filters objects not valid after this date")
        parser.add_argument("disable_geojson",
                            type=BooleanType(),
                            default=False,
                            help="remove geojson from the response")

        if is_collection:
            parser.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="The filter parameter")
        self.collection = collection
        self.get_decorators.insert(0, ManageError())
예제 #28
0
파일: Places.py 프로젝트: ISI-nc/navitia
    def __init__(self, *args, **kwargs):
        ResourceUri.__init__(self,
                             authentication=False,
                             output_type_serializer=PlacesSerializer,
                             *args,
                             **kwargs)
        self.parsers["get"].add_argument("q",
                                         type=six.text_type,
                                         required=True,
                                         help="The data to search")
        self.parsers["get"].add_argument(
            "type[]",
            type=OptionValue(list(pb_type.keys())),
            action="append",
            default=["stop_area", "address", "poi", "administrative_region"],
            help="The type of data to search")
        self.parsers["get"].add_argument(
            "count",
            type=default_count_arg_type,
            default=10,
            help="The maximum number of places returned")
        self.parsers["get"].add_argument(
            "search_type",
            type=int,
            default=0,
            hidden=True,
            help="Type of search: firstletter or type error")
        self.parsers["get"].add_argument(
            "admin_uri[]",
            type=six.text_type,
            action="append",
            help="If filled, will restrain the search within the "
            "given admin uris")
        self.parsers["get"].add_argument("depth",
                                         type=depth_argument,
                                         default=1,
                                         help="The depth of objects")
        self.parsers["get"].add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            default=datetime.datetime.utcnow(),
            help="The datetime used to consider the state of the pt object.\n"
            "Default is the current date and it is used for debug.\n"
            "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",
            schema_type='datetime',
            hidden=True)
        self.parsers['get'].add_argument(
            "disable_geojson",
            type=BooleanType(),
            default=False,
            help="remove geojson from the response")

        self.parsers['get'].add_argument(
            "from",
            type=CoordFormat(nullable=True),
            help="Coordinates longitude;latitude used to prioritize "
            "the objects around this coordinate")
        self.parsers['get'].add_argument(
            "_autocomplete",
            type=six.text_type,
            hidden=True,
            help="name of the autocomplete service, used under the hood")
        self.parsers['get'].add_argument(
            'shape',
            type=geojson_argument(),
            help='Geographical shape to limit the search.')
예제 #29
0
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        parser = self.parsers["get"]
        parser.add_argument("start_page",
                            type=int,
                            default=0,
                            help="The page where you want to start")
        parser.add_argument("count",
                            type=default_count_arg_type,
                            default=25,
                            help="Number of objects you want on a page")
        parser.add_argument("depth",
                            type=DepthArgument(),
                            schema_type=int,
                            default=1,
                            help="The depth of your object")
        parser.add_argument(
            "forbidden_id[]",
            type=six.text_type,
            help="DEPRECATED, replaced by `forbidden_uris[]`",
            dest="__temporary_forbidden_id[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )
        parser.add_argument(
            "forbidden_uris[]",
            type=six.text_type,
            help="forbidden uris",
            dest="forbidden_uris[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )
        # for the top level collection apis (/v1/networks, /v1/lines, ...) the external_code is mandatory
        external_code_mandatory = '.external_codes' in self.endpoint
        parser.add_argument(
            "external_code",
            type=six.text_type,
            help="An external code to query",
            required=external_code_mandatory,
        )
        parser.add_argument("headsign",
                            type=six.text_type,
                            help="filter vehicle journeys on headsign")
        parser.add_argument("show_codes",
                            type=BooleanType(),
                            default=False,
                            help="show more identification codes")
        parser.add_argument(
            "odt_level",
            type=OptionValue(odt_levels),
            default="all",
            schema_type=str,
            schema_metadata={"enum": odt_levels},
            help="odt level",
        )
        parser.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.now(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.',
        )
        parser.add_argument(
            "data_freshness",
            help=
            "Define the freshness of data to use to filter vehicle_journeys "
            "along with parameters &since and/or &until .\n"
            "Provides only the vehicle_journeys valid for the data freshness level requested.\n"
            "Using `&data_freshness=base_schedule` will return all original vehicle_journeys only"
            "whereas using `&data_freshness=realtime` will return vehicle_journeys after applying"
            "modifications by realtime (amended vehicle_journeys, and non-impacted original vehicle_journeys).",
            type=OptionValue(['base_schedule', 'adapted_schedule',
                              'realtime']),
            default='base_schedule',
        )
        parser.add_argument(
            "distance",
            type=int,
            default=200,
            help=
            "Distance range of the query. Used only if a coord is in the query",
        )
        parser.add_argument("since",
                            type=DateTimeFormat(),
                            help="filters objects not valid before this date")
        parser.add_argument("until",
                            type=DateTimeFormat(),
                            help="filters objects not valid after this date")
        parser.add_argument("disable_geojson",
                            type=BooleanType(),
                            default=False,
                            help="remove geojson from the response")
        parser.add_argument("disable_disruption",
                            type=BooleanType(),
                            default=False,
                            help="remove disruptions from the response")

        if is_collection:
            parser.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="The filter parameter")
        parser.add_argument(
            "tags[]",
            type=six.text_type,
            action="append",
            help=
            "If filled, will restrain the search within the given disruption tags",
        )
        self.collection = collection
        self.get_decorators.insert(0, ManageError())
예제 #30
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))