Exemplo n.º 1
0
class GeoStatusSerializer(serpy.Serializer):
    nb_addresses = Field(schema_type=int)
    nb_admins = Field(schema_type=int)
    nb_admins_from_cities = Field(schema_type=int)
    nb_pois = Field(schema_type=int)
    nb_ways = Field(schema_type=int)
    poi_sources = StringListField(display_none=True)
    street_network_sources = StringListField(display_none=True)
Exemplo n.º 2
0
class TravelerProfilesSerializer(serpy.Serializer):
    bike_speed = Field(schema_type=float)
    bss_speed = Field(schema_type=float)
    car_speed = Field(schema_type=float)
    first_section_mode = StringListField()
    is_from_db = Field(schema_type=bool)
    last_section_mode = StringListField()
    max_bike_duration_to_pt = Field(schema_type=int)
    max_bss_duration_to_pt = Field(schema_type=int)
    max_car_duration_to_pt = Field(schema_type=int)
    max_walking_duration_to_pt = Field(schema_type=int)
    traveler_type = Field(schema_type=str)
    walking_speed = Field(schema_type=float)
    wheelchair = Field(schema_type=bool)
Exemplo n.º 3
0
class JourneySerializer(PbNestedSerializer):
    duration = jsonschema.Field(schema_type=int, display_none=True,
                                description='Duration of the journey (seconds)')
    nb_transfers = jsonschema.Field(schema_type=int, display_none=True,
                                    description='Number of transfers along the journey')
    departure_date_time = DateTimeField(description='Departure date and time of the journey')
    arrival_date_time = DateTimeField(description='Arrival date and time of the journey')
    requested_date_time = DateTimeField(deprecated=True)
    to = PlaceSerializer(deprecated=True, attr='destination')
    _from = PlaceSerializer(deprecated=True, attr='origin', label='from')
    type = jsonschema.Field(schema_type=str, display_none=True,
                            description='Used to qualify the journey (can be "best", "comfort", "non_pt_walk", ...')
    status = jsonschema.Field(schema_type=str, attr="most_serious_disruption_effect", display_none=True,
                              description='Status from the whole journey taking into account the most '
                                          'disturbing information retrieved on every object used '
                                          '(can be "NO_SERVICE", "SIGNIFICANT_DELAYS", ...')
    tags = StringListField(display_none=True)
    co2_emission = AmountSerializer(display_none=True)
    durations = DurationsSerializer()
    fare = FareSerializer(display_none=True)
    calendars = CalendarSerializer(many=True, display_none=False)
    sections = SectionSerializer(many=True, display_none=False)
    debug = jsonschema.MethodField(schema_type=JourneyDebugSerializer(), display_none=False)

    def get_debug(self, obj):
        if not hasattr(g, 'debug') or not g.debug:
            return None
        return JourneyDebugSerializer(obj, display_none=False).data
Exemplo n.º 4
0
class CommonStatusSerializer(NullableDictSerializer):
    status = Field(schema_type=str, display_none=False)
    dataset_created_at = Field(schema_type=str, display_none=False)
    is_realtime_loaded = Field(schema_type=bool, display_none=False)
    data_version = Field(schema_type=int, display_none=False)
    nb_threads = Field(schema_type=int, display_none=False)
    is_open_service = Field(schema_type=bool, display_none=False)
    is_connected_to_rabbitmq = Field(schema_type=bool, display_none=False)
    autocomplete = AutocompleteSerializer(display_none=False)
    end_production_date = Field(schema_type=str, display_none=False)
    realtime_proxies = StringListField(display_none=True)
    last_load_at = Field(schema_type=str, display_none=False)
    publication_date = Field(schema_type=str, display_none=False)
    street_networks = StreetNetworkSerializer(many=True, display_none=False)
    ridesharing_services = RidesharingServicesSerializer(many=True, display_none=False)
    start_production_date = Field(schema_type=str, display_none=False)
    last_load_status = Field(schema_type=bool, display_none=False)
    is_open_data = Field(schema_type=bool, display_none=False)
    last_rt_data_loaded = Field(schema_type=str, display_none=False)
    kraken_version = MethodField(schema_type=str, display_none=False)
    region_id = Field(schema_type=str, display_none=False, description='Identifier of the coverage')
    error = CoverageErrorSerializer(display_none=False)

    def get_kraken_version(self, obj):
        if "navitia_version" in obj:
            return obj["navitia_version"]
        if "kraken_version" in obj:
            return obj["kraken_version"]
        return None
Exemplo n.º 5
0
class StreetNetworkSerializer(OutsideServiceCommon):
    modes = StringListField(display_none=True)
    timeout = MethodField(schema_type=float, display_none=False)
    backend_class = MethodField(schema_type=str, display_none=False)
    matrix_type = MethodField(schema_type=str, display_none=False)
    max_matrix_points = MethodField(schema_type=int, display_none=False)
    realtime_traffic = MethodField(schema_type=str, display_none=False)
    language = MethodField(schema_type=str, display_none=False)

    def get_timeout(self, obj):
        return obj.get('timeout', None)

    def get_backend_class(self, obj):
        return obj.get('backend_class', None)

    def get_matrix_type(self, obj):
        return obj.get('matrix_type', None)

    def get_max_matrix_points(self, obj):
        return obj.get('max_matrix_points', None)

    def get_realtime_traffic(self, obj):
        return obj.get('realtime_traffic', None)

    def get_language(self, obj):
        return obj.get('language', None)
Exemplo n.º 6
0
class StatusSerializer(serpy.DictSerializer):
    data_version = Field(schema_type=int)
    dataset_created_at = Field(schema_type=str)
    end_production_date = Field(schema_type=str)
    is_connected_to_rabbitmq = Field(schema_type=bool)
    is_open_data = Field(schema_type=bool)
    is_open_service = Field(schema_type=bool)
    is_realtime_loaded = Field(schema_type=bool)
    kraken_version = Field(schema_type=str, attr=str("navitia_version"))
    last_load_at = Field(schema_type=str)
    last_load_status = Field(schema_type=bool)
    last_rt_data_loaded = Field(schema_type=str)
    nb_threads = Field(schema_type=int)
    parameters = ParametersSerializer()
    publication_date = Field(schema_type=str)
    realtime_contributors = MethodField(schema_type=str,
                                        many=True,
                                        display_none=True)
    realtime_proxies = StringListField(display_none=True)
    start_production_date = Field(schema_type=str)
    status = Field(schema_type=str)
    traveler_profiles = TravelerProfilesSerializer(many=True)

    def get_realtime_contributors(self, obj):
        # so far, serpy cannot serialize an optional attr
        # this has to be done manually
        return obj.get('rt_contributors', [])
Exemplo n.º 7
0
class StreetNetworkSerializer(OutsideServiceCommon):
    modes = StringListField(display_none=True)
    timeout = MethodField(schema_type=float, display_none=False)
    backend_class = MethodField(schema_type=str, display_none=False)

    def get_timeout(self, obj):
        return obj.get('timeout', None)

    def get_backend_class(self, obj):
        return obj.get('backend_class', None)