Beispiel #1
0
def make_properties_links(properties):
    if properties is None:
        return []

    response = base.make_notes(properties.notes)

    response.extend([
        {
            "type":
            "exceptions",  # type should be 'exception' but retrocompatibility...
            "rel": "exceptions",
            "id": exception.uri,
            "date": exception.date,
            "except_type": exception.type,
            "internal": True
        } for exception in properties.exceptions
    ])

    if properties.HasField(
            str("destination")) and properties.destination.HasField(
                str("uri")):
        response.append({
            "type": "notes",
            "rel": "notes",
            "category": "terminus",
            "id": properties.destination.uri,
            "value": properties.destination.destination,
            "internal": True
        })

    if properties.HasField(str("vehicle_journey_id")):
        response.append({
            "type": "vehicle_journey",
            "rel": "vehicle_journeys",
            "value": properties.vehicle_journey_id,  # to remove for the v2
            "id": properties.vehicle_journey_id
        })

    return response
Beispiel #2
0
    def output(self, key, obj):
        links = None
        try:
            if obj.HasField(str("uris")):
                links = obj.uris.ListFields()
        except ValueError:
            return None
        response = []
        if links:
            for type_, value in links:
                response.append({"type": type_.name, "id": value})

        if obj.HasField(str('pt_display_informations')):
            response.extend(base.make_notes(obj.pt_display_informations.notes))

        if obj.HasField(str('ridesharing_information')):
            response.extend([{
                "type": "ridesharing_ad",
                "rel": l.key,
                "href": l.href,
                "internal": False
            } for l in obj.ridesharing_information.links])
        return response