def __init__(self): Uri.__init__(self, is_collection, "poi_types") self.collections = [ ("poi_types", NonNullList(fields.Nested(poi_type, display_null=False))), ("pagination", PbField(pagination)), ("error", PbField(error)) ] collections = marshal_with(OrderedDict(self.collections), display_null=False) self.method_decorators.insert(1, collections)
def __init__(self): Uri.__init__(self, is_collection, "vehicle_journeys") self.collections = [ ("vehicle_journeys", NonNullList(fields.Nested(vehicle_journey, display_null=False))), ("pagination", PbField(pagination)), ("error", PbField(error)), ("disruptions", DisruptionsField), ] collections = marshal_with(OrderedDict(self.collections), display_null=False) self.method_decorators.insert(1, collections)
def __init__(self): Uri.__init__(self, is_collection, "companies") self.collections = [ ("companies", NonNullList(fields.Nested(company, display_null=False))), ("pagination", PbField(pagination)), ("error", PbField(error)), ("disruptions", DisruptionsField), ("feed_publishers", NonNullList(fields.Nested(feed_publisher, display_null=False))) ] collections = marshal_with(OrderedDict(self.collections), display_null=False) self.method_decorators.insert(1, collections)
def __init__(self, *args, **kwargs): Uri.__init__(self, is_collection, "stop_points", *args, **kwargs) self.collections = [ ("stop_points", NonNullList(fields.Nested(stop_point, display_null=False))), ("pagination", PbField(pagination)), ("error", PbField(error)) ] collections = marshal_with(OrderedDict(self.collections), display_null=False) self.method_decorators.insert(1, collections) self.parsers["get"].add_argument("original_id", type=unicode, description="original uri of the object you" "want to query")
def __init__(self): Uri.__init__(self, is_collection, "line_groups") self.collections = [ ("line_groups", NonNullList(fields.Nested(line_group, display_null=False))), ("pagination", PbField(pagination)), ("error", PbField(error)), ("disruptions", DisruptionsField), ] collections = marshal_with(OrderedDict(self.collections), display_null=False) self.method_decorators.insert(1, collections) self.parsers["get"].add_argument("original_id", type=unicode, description="original uri of the object you" "want to query")
from flask.ext.restful import marshal_with, reqparse from flask.globals import g from jormungandr import i_manager, timezone from fields import PbField, error, network, line,\ NonNullList, NonNullNested, pagination, stop_area from ResourceUri import ResourceUri from jormungandr.interfaces.argument import ArgumentDoc from jormungandr.interfaces.parsers import date_time_format from errors import ManageError from datetime import datetime import aniso8601 from datetime import timedelta from jormungandr.interfaces.v1.fields import DisruptionsField disruption = { "network": PbField(network, attribute='network'), "lines": NonNullList(NonNullNested(line)), "stop_areas": NonNullList(NonNullNested(stop_area)) } traffic = { "traffic_reports": NonNullList(NonNullNested(disruption), attribute='disruptions'), "error": PbField(error, attribute='error'), "pagination": NonNullNested(pagination), "disruptions": DisruptionsField, }
from flask.ext.restful import Resource, fields, marshal_with, reqparse, abort from flask.globals import g from jormungandr import i_manager, timezone from jormungandr.interfaces.v1.fields import use_old_disruptions_if_needed, DisruptionsField from make_links import add_id_links from fields import NonNullList, NonNullNested, PbField, error, pt_object from ResourceUri import ResourceUri from make_links import add_id_links from jormungandr.interfaces.argument import ArgumentDoc from jormungandr.interfaces.parsers import depth_argument, option_value from copy import deepcopy pt_objects = { "pt_objects": NonNullList(NonNullNested(pt_object), attribute='places'), "disruptions": DisruptionsField, "error": PbField(error, attribute='error'), } pt_object_type_values = [ "network", "commercial_mode", "line", "route", "stop_area" ] class Ptobjects(ResourceUri): parsers = {} def __init__(self, *args, **kwargs): ResourceUri.__init__(self, *args, **kwargs) self.parsers["get"] = reqparse.RequestParser( argument_class=ArgumentDoc) self.parsers["get"].add_argument("q",
self.endpoint = "previous" + self.endpoint[4:] self._register_interpreted_parameters(args) return i_manager.dispatch(args, self.endpoint, instance_name=self.region) date_time = { "date_time": SplitDateTime(date='date', time='time'), "additional_informations": additional_informations(), "links": stop_time_properties_links() } 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": additional_informations_vj(), "links": UrisToLinks() } table_field = { "rows": fields.List(fields.Nested(row)), "headers": fields.List(fields.Nested(header)) }
"type": section_type(), "id": fields.String(), "mode": enum_type(attribute="street_network.mode"), "duration": fields.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": additional_informations_vj(), "geojson": GeoJson(), "path": NonNullList(NonNullNested({ "length": fields.Integer(), "name": fields.String(), "duration": fields.Integer(), "direction": fields.Integer() }), attribute="street_network.path_items"), "transfer_type": enum_type(), "stop_date_times":
from jormungandr.exceptions import TechnicalError from functools import wraps from flask_restful import marshal class Lit(fields.Raw): def __init__(self, val): self.val = val def output(self, key, obj): return self.val places = { "places": NonNullList(NonNullNested(place)), "error": PbField(error, attribute='error'), "disruptions": DisruptionsField, } ww_admin = { "id": fields.String, #"insee": dict["id"][6:], #"coord": ?? "level": fields.Integer, "name": fields.String, "label": fields.String(attribute="name"), "zip_code": fields.String, } ww_address = { "embeded_type": Lit("address"),
args["uri"] = id.split(":")[-1] elif id[:5] == "admin": args["uri"] = "admin:" + id.split(":")[-1] if not "uri" in args.keys(): args["uri"] = id response = i_manager.dispatch(args, "place_uri", instance_name=self.region) return response, 200 place_nearby = deepcopy(place) place_nearby["distance"] = fields.Float() places_nearby = { "places_nearby": NonNullList(NonNullNested(place_nearby)), "pagination": PbField(pagination) } class PlacesNearby(ResourceUri): parsers = {} def __init__(self, *args, **kwargs): ResourceUri.__init__(self, *args, **kwargs) self.parsers["get"] = reqparse.RequestParser( argument_class=ArgumentDoc) parser_get = self.parsers["get"] self.parsers["get"].add_argument( "type[]", type=str, action="append",