Exemplo n.º 1
0
    def verify(self):
        """
        Verify that the FareAttribute has at least the required keys, lat and lon are correct
        """
        # TODO: verify fare_id and agency_id
        if self.fare_id is None:
            raise MissingKeyError("fare_id")
        if self.price is None:
            raise MissingKeyError("price")
        if self.currency_type is None:
            raise MissingKeyError("currency_type")
        if self.payment_method is None:
            raise MissingKeyError("payment_method")

        if self.price < 0:
            raise InvalidValueError("price")

        if self.payment_method < 0 or self.payment_method >= len(
                ENUM_PAYMENT_METHOD):
            raise InvalidValueError("payment_method")

        if self.transfers is not None and (self.transfers < 0
                                           or self.transfers > 5):
            raise InvalidValueError("transfers")

        if self.transfer_duration is not None and self.transfer_duration < 0:
            raise InvalidValueError("transfer_duration")

        return True
Exemplo n.º 2
0
    def verify(self):
        """
        Verify that the Route has at least the required keys and correct values
        """
        # TODO: verify route_id, service_id, block_id, shape_id

        if self.route_id is None:
            raise MissingKeyError("route_id")

        if self.service_id is None:
            raise MissingKeyError("service_id")

        if self.trip_id is None:
            raise MissingKeyError("trip_id")

        if self.direction_id < 0 or self.direction_id >= len(
                ENUM_DIRECTION_ID):
            raise InvalidValueError("direction_id")

        if (self.wheelchair_accessible < 0 or
                self.wheelchair_accessible >= len(ENUM_WHEELCHAIR_ACCESSIBLE)):
            raise InvalidValueError("wheelchair_accessible")

        if self.bikes_allowed < 0 or self.bikes_allowed >= len(
                ENUM_BIKES_ALLOWED):
            raise InvalidValueError("bikes_allowed")

        if self.exceptional is not None and (
                self.exceptional < 0
                or self.exceptional >= len(ENUM_EXCEPTIONAL)):
            raise InvalidValueError("exceptional")

        return True
Exemplo n.º 3
0
    def verify(self):
        """
        Verify that the StopTime has at least the required keys, lat and lon are correct
        """
        # TODO: verify stop_id, trip_id, arrival_time and departure_time

        if self.trip_id is None:
            raise MissingKeyError("trip_id")

        if self.arrival_time is None and self.departure_time is None:
            raise MissingKeyError("arrival_time or departure_timee")

        if self.stop_id is None:
            raise MissingKeyError("stop_id")

        if self.stop_sequence is None:
            raise MissingKeyError("stop_sequence")

        if self.stop_sequence < 0:
            raise InvalidValueError("stop_sequence")

        if self.pickup_type < 0 or self.pickup_type >= len(ENUM_PICKUP_TYPE):
            raise InvalidValueError("pickup_type")

        if self.drop_off_type < 0 or self.drop_off_type >= len(
                ENUM_DROP_OFF_TYPE):
            raise InvalidValueError("drop_off_type")

        if self.shape_dist_traveled is not None and self.shape_dist_traveled < 0:
            raise InvalidValueError("shape_dist_traveled")

        if self.timepoint < 0 or self.timepoint >= len(ENUM_TIMEPOINT_TYPE):
            raise InvalidValueError("timepoint")

        return True
Exemplo n.º 4
0
    def verify(self):
        """
        Verify that the Transfer has at least the required keys, lat and lon are correct
        """
        # TODO: verify from_stop_id and to_stop_id
        if self.from_stop_id is None:
            raise MissingKeyError("from_stop_id")

        if self.to_stop_id is None:
            raise MissingKeyError("to_stop_id")

        if self.min_transfer_time is not None and self.min_transfer_time < 0:
            raise InvalidValueError("min_transfer_time")

        if self.transfer_type < 0 or self.transfer_type >= len(ENUM_TRANSFER_TYPE):
            raise InvalidValueError("transfer_type")

        return True
Exemplo n.º 5
0
    def verify(self):
        """
        Verify that the Frequency has at least the required keys, lat and lon are correct
        """
        # TODO: verify trip_id
        if self.trip_id is None:
            raise MissingKeyError("trip_id")
        if self.start_time is None:
            raise MissingKeyError("start_time")
        if self.end_time is None:
            raise MissingKeyError("end_time")
        if self.headway_secs is None:
            raise MissingKeyError("headway_secs")

        if self.headway_secs < 0:
            raise InvalidValueError("headway_secs")

        if self.exact_times < 0 or self.exact_times >= len(ENUM_EXACT_TIMES):
            raise InvalidValueError("exact_times")

        return True
Exemplo n.º 6
0
    def verify(self):
        """
        Verify that the Translation has at least the required keys, lat and lon are correct
        """
        # TODO: verify languages
        if self.table_name is None:
            raise MissingKeyError("table_name")
        if self.field_name is None:
            raise MissingKeyError("field_name")
        if self.language is None:
            raise MissingKeyError("language")
        if self.translation is None:
            raise MissingKeyError("translation")

        if self.table_name not in ENUM_TABLE_NAME:
            raise InvalidValueError("table_name")

        if self.record_id is not None and self.table_name == "feed_info":
            raise InvalidValueError("record_id: forbidden for feed_info")
        if self.record_id is not None and self.field_value is not None:
            raise InvalidValueError(
                "record_id: forbidden if field_value is set")
        if self.record_id is None and self.field_value is None:
            raise MissingKeyError(
                "record_id: required if field_value is not set")

        if self.record_sub_id is None and (self.table_name == "stop_times"
                                           and self.record_id is not None):
            raise MissingKeyError(
                "record_sub_id: required if"
                " table_name equals stop_times and record_id is set")
        if (self.record_sub_id is not None
                and self.table_name != "stop_times"):
            raise InvalidValueError(
                "record_sub_id: only allowed for stop_times")

        if self.field_value is not None and self.table_name == "feed_info":
            raise InvalidValueError("field_value: forbidden for feed_info")

        return True
Exemplo n.º 7
0
    def verify(self):
        """
        Verify that the ServiceException has at least the required keys and correct values
        """
        if self.service_id is None:
            raise MissingKeyError("service_id")
        if self.date is None:
            raise MissingKeyError("date")
        if self.exception_type is None:
            raise MissingKeyError("exception_type")

        if self.exception_type < 1 or self.exception_type >= len(
                ENUM_EXCEPTION_TYPE):
            raise InvalidValueError("exception_type")

        return True
Exemplo n.º 8
0
    def verify(self):
        """
        Verify that the Pathway has at least the required keys, lat and lon are correct
        """
        # TODO: verify pathway_id, from_stop_id and to_stop_id
        if self.pathway_id is None:
            raise MissingKeyError("pathway_id")
        if self.from_stop_id is None:
            raise MissingKeyError("from_stop_id")
        if self.to_stop_id is None:
            raise MissingKeyError("to_stop_id")
        if self.pathway_mode is None:
            raise MissingKeyError("pathway_mode")
        if self.is_bidirectional is None:
            raise MissingKeyError("is_bidirectional")

        if self.pathway_mode < 0 or self.pathway_mode >= len(ENUM_PATHWAY_MODE):
            raise InvalidValueError("pathway_mode")

        if self.is_bidirectional < 0 or self.is_bidirectional >= len(ENUM_IS_BIDIRECTIONAL):
            raise InvalidValueError("is_bidirectional")

        if self.length is not None and self.length < 0:
            raise InvalidValueError("length")

        if self.traversal_time is not None and self.traversal_time < 0:
            raise InvalidValueError("traversal_time")

        if self.stair_count is not None and self.stair_count == 0:
            raise InvalidValueError("stair_count")

        if self.is_bidirectional == 1 and (self.pathway_mode == 6 or self.pathway_mode == 7):
            raise InvalidValueError("is_bidirectional: fare/exit gates cannot be bidirectional")

        if self.max_slope is not None and (self.pathway_mode == 1 or self.pathway_mode == 3):
            raise InvalidValueError("max_slope: slope should only be used on (moving) walkways")

        if self.min_width is not None and self.min_width <= 0:
            raise InvalidValueError("min_width")

        return True
Exemplo n.º 9
0
    def verify(self):
        """
        Verify that the Service has at least the required keys and correct values
        """
        if self.service_id is None:
            raise MissingKeyError("service_id")
        if self.monday is None:
            raise MissingKeyError("monday")
        if self.tuesday is None:
            raise MissingKeyError("tuesday")
        if self.wednesday is None:
            raise MissingKeyError("wednesday")
        if self.thursday is None:
            raise MissingKeyError("thursday")
        if self.friday is None:
            raise MissingKeyError("friday")
        if self.saturday is None:
            raise MissingKeyError("saturday")
        if self.sunday is None:
            raise MissingKeyError("sunday")
        if self.start_date is None:
            raise MissingKeyError("start_date")
        if self.end_date is None:
            raise MissingKeyError("end_date")

        if self.monday < 0 or self.monday >= len(ENUM_AVAILABLE):
            raise InvalidValueError("monday")
        if self.tuesday < 0 or self.tuesday >= len(ENUM_AVAILABLE):
            raise InvalidValueError("tuesday")
        if self.wednesday < 0 or self.wednesday >= len(ENUM_AVAILABLE):
            raise InvalidValueError("wednesday")
        if self.thursday < 0 or self.thursday >= len(ENUM_AVAILABLE):
            raise InvalidValueError("thursday")
        if self.friday < 0 or self.friday >= len(ENUM_AVAILABLE):
            raise InvalidValueError("friday")
        if self.saturday < 0 or self.saturday >= len(ENUM_AVAILABLE):
            raise InvalidValueError("saturday")
        if self.sunday < 0 or self.sunday >= len(ENUM_AVAILABLE):
            raise InvalidValueError("sunday")

        return True
Exemplo n.º 10
0
    def verify(self):
        """
        Verify that the Stop has at least the required keys, lat and lon are correct
        """
        # TODO: verify zone_id, level_id, parent_station
        if self.stop_id is None:
            raise MissingKeyError("stop_id")
        if self.location_type <= 2:
            if self.stop_name is None:
                raise MissingKeyError("stop_name")
            if self.stop_lat is None:
                raise MissingKeyError("stop_lat")
            if self.stop_lon is None:
                raise MissingKeyError("stop_lon")
        if self.parent_station is None and self.location_type >= 2:
            raise MissingKeyError("parent_station")
        if (self.parent_station is not None and self.parent_station != ""
                and self.location_type == 1):
            raise MissingKeyError("parent_station")

        if self.stop_lon < -180 or self.stop_lon > 180:
            raise InvalidValueError("stop_lon")
        if self.stop_lat < -90 or self.stop_lat > 90:
            raise InvalidValueError("stop_lat")
        if self.location_type < 0 or self.location_type >= len(
                ENUM_LOCATION_TYPE):
            raise InvalidValueError("location_type")
        if (self.wheelchair_boarding < 0
                or self.wheelchair_boarding >= len(ENUM_WHEELCHAIR_BOARDING)):
            raise InvalidValueError("wheelchair_boarding")
        if self.vehicle_type is not None and self.vehicle_type not in ENUM_VEHICLE_TYPE:
            raise InvalidValueError("vehicle_type")

        if self.stop_timezone:
            try:
                pytz.timezone(self.stop_timezone)
            except pytz.exceptions.UnknownTimeZoneError:
                raise InvalidValueError("stop_timezone")

        return True
Exemplo n.º 11
0
    def verify(self):
        """
        Verify that the Route has at least the required keys and correct values
        """
        # TODO: verify agency_id,
        if self.route_id is None:
            raise MissingKeyError("route_id")

        if self.route_type is None:
            raise MissingKeyError("route_type")

        if ((self.route_short_name == "" or self.route_short_name is None) and
            (self.route_long_name == "" or self.route_long_name is None)):
            raise MissingKeyError("route_long_name or route_short_name")

        if self.route_type not in ENUM_ROUTE_TYPE:
            print(self.route_type)
            raise InvalidValueError("route_type")

        if len(self.route_color) != 6:
            raise InvalidValueError("route_color")

        if len(self.route_text_color) != 6:
            raise InvalidValueError("route_text_color")

        try:
            int(self.route_color, 16)
        except ValueError:
            raise InvalidValueError("route_color")

        try:
            int(self.route_text_color, 16)
        except ValueError:
            raise InvalidValueError("route_text_color")

        if self.route_sort_order < 0:
            raise InvalidValueError("route_sort_order")

        return True