Beispiel #1
0
    def add_fare_attribute(self, *args):
        fare_attribute = FareAttribute(*args)

        assert fare_attribute.fare_id not in \
            get('fare_id', self._fare_attributes), 'Dup!'

        assert valid_currency(fare_attribute.currency_type), 'Invalid ISO 4217'
        assert fare_attribute.payment_method in srange(2), 'Out of range'
        assert fare_attribute.transfers in srange(3), 'Out of range'

        self._fare_attributes.append(fare_attribute)
Beispiel #2
0
    def add_fare_attribute(self, *args):
        fare_attribute = FareAttribute(*args)

        assert fare_attribute.fare_id not in \
            get('fare_id', self._fare_attributes), 'Dup!'

        assert valid_currency(fare_attribute.currency_type), 'Invalid ISO 4217'
        assert fare_attribute.payment_method in srange(2), 'Out of range'
        assert fare_attribute.transfers in srange(3), 'Out of range'

        self._fare_attributes.append(fare_attribute)
Beispiel #3
0
    def add_trip(self, *args):
        trip = Trip(*args)

        assert trip.route_id in get('route_id', self._routes)
        assert trip.service_id in get('service_id', self._calendar)

        assert trip.trip_id not in get('trip_id', self._trips)

        if trip.direction_id:
            assert trip.direction_id in srange(2), 'Out of range'

        if trip.shape_id:
            assert trip.shape_id in get('shape_id', self._shapes)

        if trip.wheelchair_accessible:
            assert trip.wheelchair_accessible in srange(3), 'Out of range'

        if trip.bikes_allowed:
            assert trip.bikes_allowed in srange(3), 'Out of range'

        self._trips.append(trip)
Beispiel #4
0
    def add_stop(self, *args):
        stop = Stop(*args)

        assert stop.stop_id not in get('stop_id', self._stops)

        assert valid_coord(stop.stop_lat), 'Invalid coord'
        assert valid_coord(stop.stop_lon), 'Invalid coord'

        if stop.stop_url:
            assert valid_url(stop.stop_url), 'Invalid URL'

        if stop.location_type:
            assert stop.location_type in srange(2), 'Out of range'

        if stop.stop_timezone:
            assert valid_timezone(stop.stop_timezone), 'Invalid timezone'

        if stop.wheelchair_boarding:
            assert stop.wheelchair_boarding in srange(3), 'Out of range'

        self._stops.append(stop)
Beispiel #5
0
    def add_frequencies(self, *args):
        frequency = Frequency(*args)

        assert frequency.trip_id in get('trip_id', self._trips)

        assert valid_time(frequency.start_time), 'Invalid time'
        assert valid_time(frequency.end_time), 'Invalid time'
        assert valid_digit(frequency.headway_secs), 'Invalid digit'

        if frequency.exact_times:
            assert frequency.exact_times in srange(2), 'Out of range'

        self._frequencies.append(frequency)
Beispiel #6
0
    def add_calendar_date(self, *args):
        calendar_date = CalendarDate(*args)

        service_ids = get('service_id', self._calendar_dates)
        dates = get('date', self._calendar_dates)

        assert (calendar_date.service_id, calendar_date.date) not in \
            zip(service_ids, dates), 'Dup!'

        assert valid_date(calendar_date.date), 'Invalid date format'
        assert calendar_date.exception_type in srange(1, 3), 'Out of range'

        self._calendar_dates.append(calendar_date)
Beispiel #7
0
    def add_transfer(self, *args):
        transfer = Transfer(*args)

        stop_ids = get('stop_id', self._stops)
        assert transfer.from_stop_id in stop_ids
        assert transfer.to_stop_id in stop_ids

        assert transfer.transfer_type in srange(4), 'Out of range'

        if transfer.min_transfer_time:
            assert valid_signed_int(transfer.min_transfer_time), 'Invalid int'

        self._transfers.append(transfer)
Beispiel #8
0
    def add_frequencies(self, *args):
        frequency = Frequency(*args)

        assert frequency.trip_id in get('trip_id', self._trips)

        assert valid_time(frequency.start_time), 'Invalid time'
        assert valid_time(frequency.end_time), 'Invalid time'
        assert valid_digit(frequency.headway_secs), 'Invalid digit'

        if frequency.exact_times:
            assert frequency.exact_times in srange(2), 'Out of range'

        self._frequencies.append(frequency)
Beispiel #9
0
    def add_calendar_date(self, *args):
        calendar_date = CalendarDate(*args)

        service_ids = get('service_id', self._calendar_dates)
        dates = get('date', self._calendar_dates)

        assert (calendar_date.service_id, calendar_date.date) not in \
            zip(service_ids, dates), 'Dup!'

        assert valid_date(calendar_date.date), 'Invalid date format'
        assert calendar_date.exception_type in srange(1, 3), 'Out of range'

        self._calendar_dates.append(calendar_date)
Beispiel #10
0
    def add_stop_time(self, *args):
        stop_time = StopTime(*args)

        assert stop_time.trip_id in get('trip_id', self._trips)

        assert valid_time(stop_time.arrival_time), 'Invalid time'
        assert valid_time(stop_time.departure_time), 'Invalid time'

        assert stop_time.stop_id in get('stop_id', self._stops)
        assert valid_signed_int(stop_time.stop_sequence), 'Invalid int'

        if stop_time.pickup_type:
            assert stop_time.pickup_type in srange(4), 'Out of range'

        if stop_time.drop_off_type:
            assert stop_time.drop_off_type in srange(4), 'Out of range'

        if stop_time.shape_dist_traveled:
            assert valid_signed_int(stop_time.shape_dist_traveled), 'Invalid int'

        if stop_time.timepoint:
            assert stop_time.timepoint in srange(2), 'Out of range'

        self._stop_times.append(stop_time)
Beispiel #11
0
    def add_route(self, *args):
        route = Route(*args)

        assert route.route_id not in get('route_id', self._routes)
        # agency_id optional in agencies
        if route.agency_id:
            assert route.agency_id in get('agency_id', self._agency)

        assert route.route_type in srange(8), 'Out of range'

        if route.route_url:
            assert valid_url(route.route_url), 'Invalid URL'

        if route.route_text_color:
            assert valid_hex(route.route_text_color), 'Invalid hex color'

        self._routes.append(route)
Beispiel #12
0
    def add_calendar(self, *args):
        calendar = Calendar(*args)

        assert calendar.service_id not in get('service_id', self._calendar)

        assert calendar.monday in srange(2), 'Out of range'
        assert calendar.tuesday in srange(2), 'Out of range'
        assert calendar.wednesday in srange(2), 'Out of range'
        assert calendar.thursday in srange(2), 'Out of range'
        assert calendar.friday in srange(2), 'Out of range'
        assert calendar.saturday in srange(2), 'Out of range'
        assert calendar.sunday in srange(2), 'Out of range'
        assert valid_date(calendar.start_date), 'Invalid date format'
        assert valid_date(calendar.end_date), 'Invalid date format'

        self._calendar.append(calendar)
Beispiel #13
0
    def add_calendar(self, *args):
        calendar = Calendar(*args)

        assert calendar.service_id not in get('service_id', self._calendar)

        assert calendar.monday in srange(2), 'Out of range'
        assert calendar.tuesday in srange(2), 'Out of range'
        assert calendar.wednesday in srange(2), 'Out of range'
        assert calendar.thursday in srange(2), 'Out of range'
        assert calendar.friday in srange(2), 'Out of range'
        assert calendar.saturday in srange(2), 'Out of range'
        assert calendar.sunday in srange(2), 'Out of range'
        assert valid_date(calendar.start_date), 'Invalid date format'
        assert valid_date(calendar.end_date), 'Invalid date format'

        self._calendar.append(calendar)