Example #1
0
            return marshal(place, geocode_stop_area)

        return place


geocodejson = {
    "places": fields.List(GeocodejsonFeature, attribute='features'),
    "warnings": ListLit([fields.Nested(beta_endpoint)]),
}

#instance marshal
places = {
    "places":
    NonNullList(NonNullNested(place)),
    "error":
    PbField(error, attribute='error'),
    "disruptions":
    fields.List(NonNullNested(disruption_marshaller), attribute="impacts"),
    "feed_publishers":
    fields.List(NonNullNested(feed_publisher))
}


class Places(ResourceUri):
    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,
Example #2
0
    "total": Integer(),
    "available": Integer(),
}

individual_rating = {
    "value": fields.Raw,
    "count": Integer(),
    "scale_min": fields.Raw,
    "scale_max": fields.Raw,
}

individual_information = {
    "alias": fields.String(),
    "image": fields.String(),
    "gender": enum_type(attribute="gender"),
    "rating": PbField(individual_rating, attribute="rating"),
}

ridesharing_information = {
    "operator": fields.String(),
    "network": fields.String(),
    "driver": PbField(individual_information, attribute="driver"),
    "seats": PbField(seats_description, attribute="seats"),
}

section = {
    "type":
    section_type(),
    "id":
    fields.String(),
    "mode":
Example #3
0
        }
        if hasattr(obj, 'internal_id'):
            debug['internal_id'] = obj.internal_id

        return debug


section = {
    "type": section_type(),
    "id": fields.String(),
    "mode": enum_type(attribute="street_network.mode"),
    "duration": Integer(),
    "from": section_place(place, attribute="origin"),
    "to": section_place(place, attribute="destination"),
    "links": SectionLinks(attribute="uris"),
    "display_informations": PbField(display_informations_vj,
                                    attribute='pt_display_informations'),
    "additional_informations": NonNullList(PbEnum(response_pb2.SectionAdditionalInformationType)),
    "geojson": SectionGeoJson(),
    "path": NonNullList(NonNullNested({"length": Integer(),
                                       "name": fields.String(),
                                       "duration": Integer(),
                                       "direction": fields.Integer()}),
                        attribute="street_network.path_items"),
    "transfer_type": enum_type(),
    "stop_date_times": NonNullList(NonNullNested(stop_date_time)),
    "departure_date_time": DateTime(attribute="begin_date_time"),
    "base_departure_date_time": DateTime(attribute="base_begin_date_time"),
    "arrival_date_time": DateTime(attribute="end_date_time"),
    "base_arrival_date_time": DateTime(attribute="base_end_date_time"),
    "co2_emission": NonNullNested({
        'value': fields.Raw,
Example #4
0
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Stay tuned using
# twitter @navitia
# IRC #navitia on freenode
# https://groups.google.com/d/forum/navitia
# www.navitia.io
from __future__ import absolute_import, print_function, unicode_literals, division

from jormungandr.interfaces.v1.Calendars import calendar
from jormungandr.interfaces.v1 import fields
from jormungandr.interfaces.v1.fields import NonNullList, NonNullNested, NonNullProtobufNested, PbField, FirstComment, \
    comment, DisruptionLinks

vehicle_journey = {
    "id": fields.fields.String(attribute="uri"),
    "name": fields.fields.String(),
    "disruptions": DisruptionLinks(),
    "journey_pattern": PbField(fields.journey_pattern),
    "stop_times": NonNullList(NonNullNested(fields.stop_time)),
    "comment": FirstComment(),
    # for compatibility issue we keep a 'comment' field where we output the first comment (TODO v2)
    "comments": NonNullList(NonNullNested(comment)),
    "codes": NonNullList(NonNullNested(fields.code)),
    "validity_pattern": NonNullProtobufNested(fields.validity_pattern),
    "calendars": NonNullList(NonNullNested(calendar)),
    "trip": NonNullProtobufNested(fields.trip),
}
Example #5
0
from jormungandr.interfaces.v1.fields import disruption_marshaller
from jormungandr.interfaces.v1.fields import NonNullList, NonNullNested, PbField, error, pt_object, feed_publisher
from jormungandr.interfaces.v1.ResourceUri import ResourceUri
from jormungandr.interfaces.argument import ArgumentDoc
from jormungandr.interfaces.parsers import depth_argument, default_count_arg_type, DateTimeFormat
import datetime
import six
from navitiacommon.parser_args_type import BooleanType, OptionValue

pt_objects = {
    "pt_objects":
    NonNullList(NonNullNested(pt_object), attribute='places'),
    "disruptions":
    fields.List(NonNullNested(disruption_marshaller), attribute="impacts"),
    "error":
    PbField(error, attribute='error'),
    "feed_publishers":
    fields.List(NonNullNested(feed_publisher))
}

pt_object_type_values = [
    "network", "commercial_mode", "line", "line_group", "route", "stop_area"
]


class Ptobjects(ResourceUri):
    def __init__(self, *args, **kwargs):
        ResourceUri.__init__(self, *args, **kwargs)
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
Example #6
0
            for uri in obj.impact_uris
        ]
        properties_links = pt.make_properties_links(obj.properties)
        return properties_links + disruption_links


date_time = {
    "date_time": SplitDateTime(date='date', time='time'),
    "base_date_time": DateTime(),
    "additional_informations": additional_informations(),
    "links": date_time_links(),
    'data_freshness': enum_type(attribute='realtime_level'),
}

row = {
    "stop_point": PbField(stop_point),
    "date_times": fields.List(fields.Nested(date_time))
}

header = {
    "display_informations":
    PbField(display_informations_vj, attribute='pt_display_informations'),
    "additional_informations":
    NonNullList(PbEnum(response_pb2.SectionAdditionalInformationType)),
    "links":
    UrisToLinks(),
}
table_field = {
    "rows": fields.List(fields.Nested(row)),
    "headers": fields.List(fields.Nested(header))
}
    feed_publisher, Links, JsonString, place, \
    ListLit, beta_endpoint
from jormungandr.timezone import set_request_timezone
from jormungandr.interfaces.v1.errors import ManageError
from jormungandr.utils import date_to_timestamp
from jormungandr.interfaces.parsers import UnsignedInteger
from jormungandr.interfaces.v1.journey_common import JourneyCommon
from jormungandr.interfaces.v1.fields import DateTime
from jormungandr.interfaces.v1.serializer.api import GraphicalIsrochoneSerializer
from jormungandr.interfaces.v1.decorators import get_serializer

graphical_isochrone = {
    "geojson": JsonString(),
    "max_duration": fields.Integer(),
    "min_duration": fields.Integer(),
    'from': PbField(place, attribute='origin'),
    "to": PbField(place, attribute="destination"),
    'requested_date_time': DateTime(),
    'min_date_time': DateTime(),
    'max_date_time': DateTime()
}

graphical_isochrones = {
    "isochrones":
    NonNullList(NonNullNested(graphical_isochrone),
                attribute="graphical_isochrones"),
    "error":
    PbField(error, attribute='error'),
    "feed_publishers":
    fields.List(NonNullNested(feed_publisher)),
    "links":
Example #8
0
from flask.globals import g
from jormungandr import i_manager, timezone
from jormungandr.interfaces.v1.fields import PbField, error, network, line,\
    NonNullList, NonNullNested, pagination, stop_area
from jormungandr.interfaces.v1.VehicleJourney import vehicle_journey
from jormungandr.interfaces.v1.ResourceUri import ResourceUri
from jormungandr.interfaces.argument import ArgumentDoc
from jormungandr.interfaces.parsers import DateTimeFormat, default_count_arg_type
from jormungandr.interfaces.v1.errors import ManageError
from datetime import datetime
from jormungandr.interfaces.v1.fields import disruption_marshaller
import six
from navitiacommon.parser_args_type import BooleanType

disruption = {
    "network": PbField(network, attribute='network'),
    "lines": NonNullList(NonNullNested(line)),
    "stop_areas": NonNullList(NonNullNested(stop_area)),
    "vehicle_journeys": NonNullList(NonNullNested(vehicle_journey))
}

traffic = {
    "traffic_reports":
    NonNullList(NonNullNested(disruption)),
    "error":
    PbField(error, attribute='error'),
    "pagination":
    NonNullNested(pagination),
    "disruptions":
    fields.List(NonNullNested(disruption_marshaller), attribute="impacts"),
}
Example #9
0
from jormungandr.interfaces.argument import ArgumentDoc
from jormungandr.interfaces.parsers import DateTimeFormat, default_count_arg_type
from jormungandr.interfaces.v1.decorators import get_obj_serializer
from jormungandr.interfaces.v1.errors import ManageError
from jormungandr.interfaces.v1.fields import PbField, line, pt_object, NonNullList, NonNullNested,\
    pagination, disruption_marshaller, error, ListLit, beta_endpoint
from jormungandr.interfaces.v1.ResourceUri import ResourceUri
from jormungandr.interfaces.v1.serializer import api

from flask.ext.restful import fields, reqparse
from flask.globals import g
from datetime import datetime
import six

line_report = {
    "line": PbField(line),
    "pt_objects": NonNullList(NonNullNested(pt_object)),
}

line_reports = {
    "line_reports":
    NonNullList(NonNullNested(line_report)),
    "error":
    PbField(error, attribute='error'),
    "pagination":
    NonNullNested(pagination),
    "disruptions":
    fields.List(NonNullNested(disruption_marshaller), attribute="impacts"),
    "warnings":
    ListLit([fields.Nested(beta_endpoint)]),
}
Example #10
0
from copy import deepcopy
from jormungandr.interfaces.v1.transform_id import transform_id
from jormungandr.exceptions import TechnicalError, InvalidArguments
from datetime import datetime
from jormungandr.parking_space_availability.parking_places_manager import ManageParkingPlaces
import ujson as json
from jormungandr.scenarios.utils import places_type
from navitiacommon.parser_args_type import TypeSchema, CoordFormat, CustomSchemaType, BooleanType, \
    OptionValue
from jormungandr.interfaces.common import add_poi_infos_types, handle_poi_infos
import six


places = {
    "places": NonNullList(NonNullNested(place)),
    "error": PbField(error, attribute='error'),
    "disruptions": fields.List(NonNullNested(disruption_marshaller), attribute="impacts"),
    "feed_publishers": fields.List(NonNullNested(feed_publisher))
}


class geojson_argument(CustomSchemaType):
    def __call__(self, value):
        decoded = json.loads(value)
        if not decoded:
            raise ValueError('invalid shape')

        return parser_args_type.geojson_argument(decoded)

    def schema(self):
        return TypeSchema(type=str)  # TODO a better description of the geojson