コード例 #1
0
 def validate(self, validator=None):
   validator = super(FareAttribute, self).validate(validator)
   # Required
   with validator(self):
     assert self.get('fare_id'), "Required: fare_id"
   with validator(self):
     assert self.get('price'), "Required: price"
   with validator(self):
     assert validation.valid_float(self.get('price')), "Invalid price"
   with validator(self):
     assert self.get('currency_type'), "Required: currency_type"
   with validator(self):
     assert self.get('payment_method'), "Required: payment_method"
   with validator(self):
     assert validation.valid_bool(self.get('payment_method')), \
       "Invalid payment_method"
   with validator(self):
     assert validation.valid_int(self.get('transfers'), vmin=0, vmax=2, empty=True), \
       "Invalid transfers"
   # Optional
   with validator(self):
     if self.get('transfer_duration'):
       assert validation.valid_int(self.get('transfer_duration'), vmin=0), \
         "Invalid transfer_duration"
   return validator
コード例 #2
0
ファイル: stoptime.py プロジェクト: andreyz/mapzen-gtfs
 def validate(self, validator=None):
   validator = super(StopTime, self).validate(validator)
   # Required
   with validator(self):
     assert self.get('trip_id'), "Required: trip_id"
   with validator(self):
     assert \
       (self.get('arrival_time') and self.get('departure_time')) or \
       (not self.get('arrival_time') and not self.get('departure_time')), \
       "Both arrival_time and departure_time must be set, or both must be empty."
   with validator(self):
     if self.get('arrival_time'):
       assert validation.valid_widetime(self.get('arrival_time')), \
         "Invalid arrival_time: %s"%self.get('arrival_time')
   with validator(self):
     if self.get('departure_time'):
       assert validation.valid_widetime(self.get('departure_time')), \
         "Invalid departure_time: %s"%self.get('departure_time')
   with validator(self): 
     assert self.arrive() <= self.depart(), \
       "Cannot depart before arriving!: %s -> %s"%(self.arrive(), self.depart())
   with validator(self):
     assert self.sequence() >= 0, \
       "Invalid stop_sequence: %s"%self.get('stop_sequence')
   # TODO: Warnings - useless stops (cant pickup or dropoff)
   # Optional
   with validator(self):
     if self.get('pickup_type'):
       assert validation.valid_int(self.get('pickup_type'), vmin=0, vmax=3), \
         "Invalid pickup_type, must be 0,1,2,3: %s"%self.get('pickup_type')
   with validator(self): 
     if self.get('drop_off_type'):
       assert validation.valid_int(self.get('drop_off_type'), vmin=0, vmax=3), \
         "Invalid drop_off_type, must be 0,1,2,3: %s"%self.get('drop_off_type')
   with validator(self):
     if self.get('timepoint'):
       assert validation.valid_bool(self.get('timepoint'), empty=True), \
         "Invalid timepoint"
   with validator(self):
     if int(self.get('timepoint',0)) == 1:
       assert self.arrive() and self.depart(), \
         "Exact timepoints require arrival_time and departure_time"
   with validator(self):
     if self.get('stop_headsign'):
       pass
   with validator(self):
     if self.get('shape_dist_traveled'):
       pass
   return validator
コード例 #3
0
ファイル: transfer.py プロジェクト: jcmartinmu/mapzen-gtfs
 def validate(self, validator=None):
     validator = super(Transfer, self).validate(validator)
     # Required
     with validator(self):
         assert self.get('from_stop_id'), "Required: from_stop_id"
     with validator(self):
         assert self.get('to_stop_id'), "Required: to_stop_id"
     with validator(self):
         # field required, blank allowed.
         assert validation.valid_int(self.get('transfer_type'), vmin=0, vmax=3, empty=True), \
           "Invalid transfer_type"
     with validator(self):
         if self.get('min_transfer_time'):
             assert validation.valid_int(self.get('min_transfer_time'), vmin=0), \
             "Invalid min_transfer_time"
     return validator
コード例 #4
0
ファイル: frequency.py プロジェクト: jcmartinmu/mapzen-gtfs
 def validate(self, validator=None):
     validator = super(Frequency, self).validate(validator)
     # Required
     with validator(self):
         assert self.get('trip_id'), "Required: trip_id"
     with validator(self):
         assert self.get('start_time'), "Required: start_time"
     with validator(self):
         assert self.get('end_time'), "Required: end_time"
     with validator(self):
         assert validation.valid_widetime(self.get('start_time')), \
           "Invalid start_time"
     with validator(self):
         assert validation.valid_widetime(self.get('end_time')), \
           "Invalid end_time"
     with validator(self):
         assert self.end() >= self.start(), \
           "Invalid end_time, must at least start_date"
     with validator(self):
         assert validation.valid_int(self.get('headway_secs'), vmin=1), \
           "Invalid headway_secs"
     # Optional
     with validator(self):
         if self.get('exact_times'):
             assert validation.valid_bool(self.get('exact_times'), empty=True), \
               "Invalid exact_times"
     return validator
コード例 #5
0
ファイル: transfer.py プロジェクト: andreyz/mapzen-gtfs
 def validate(self, validator=None):
   validator = super(Transfer, self).validate(validator)
   # Required
   with validator(self):
     assert self.get('from_stop_id'), "Required: from_stop_id"
   with validator(self):
     assert self.get('to_stop_id'), "Required: to_stop_id"
   with validator(self):
     # field required, blank allowed.
     assert validation.valid_int(self.get('transfer_type'), vmin=0, vmax=3, empty=True), \
       "Invalid transfer_type"
   with validator(self):
     if self.get('min_transfer_time'):
       assert validation.valid_int(self.get('min_transfer_time'), vmin=0), \
       "Invalid min_transfer_time"
   return validator
コード例 #6
0
ファイル: frequency.py プロジェクト: andreyz/mapzen-gtfs
 def validate(self, validator=None):
   validator = super(Frequency, self).validate(validator)
   # Required
   with validator(self):
     assert self.get('trip_id'), "Required: trip_id"
   with validator(self):
     assert self.get('start_time'), "Required: start_time"
   with validator(self):
     assert self.get('end_time'), "Required: end_time"
   with validator(self):
     assert validation.valid_widetime(self.get('start_time')), \
       "Invalid start_time"
   with validator(self):
     assert validation.valid_widetime(self.get('end_time')), \
       "Invalid end_time"
   with validator(self):
     assert self.end() >= self.start(), \
       "Invalid end_time, must at least start_date"
   with validator(self):
     assert validation.valid_int(self.get('headway_secs'), vmin=1), \
       "Invalid headway_secs"
   # Optional
   with validator(self):
     if self.get('exact_times'):
       assert validation.valid_bool(self.get('exact_times'), empty=True), \
         "Invalid exact_times"
   return validator
コード例 #7
0
ファイル: serviceperiod.py プロジェクト: andreyz/mapzen-gtfs
 def validate(self, validator=None):
   validator = super(ServiceDate, self).validate(validator)
   with validator(self):
     assert self.get('service_id'), "Required: service_id"
   with validator(self):
     assert self.get('date'), "Required: date"
   with validator(self):
     assert validation.valid_int(self.get('exception_type'), vmin=1, vmax=2), \
       "Invalid exception_type"
   return validator
コード例 #8
0
 def validate(self, validator=None):
     validator = super(ServiceDate, self).validate(validator)
     with validator(self):
         assert self.get('service_id'), "Required: service_id"
     with validator(self):
         assert self.get('date'), "Required: date"
     with validator(self):
         assert validation.valid_int(self.get('exception_type'), vmin=1, vmax=2), \
           "Invalid exception_type"
     return validator
コード例 #9
0
ファイル: stop.py プロジェクト: jcmartinmu/mapzen-gtfs
 def validate(self, validator=None):
     validator = super(Stop, self).validate(validator)
     # Required
     with validator(self):
         assert self.get('stop_id'), "Required: stop_id"
     with validator(self):
         assert self.get('stop_name'), "Required: stop_name"
     with validator(self):
         assert self.get('stop_lat'), "Required: stop_lat"
     with validator(self):
         assert self.get('stop_lon'), "Required: stop_lon"
     with validator(self):
         assert validation.valid_point(
             self.point()), "Invalid stop_lon/stop_lat"
     # TODO: Warnings:
     #  - stop too close to 0,0
     # Optional
     with validator(self):
         if self.get('stop_desc') == self.get('stop_name'):
             raise validation.ValidationWarning(
                 "stop_desc and stop_name are the same")
     with validator(self):
         if self.get('zone_id') and int(self.get('location_type') or 0):
             raise validation.ValidationWarning(
                 "A station cannot have a zone_id")
     with validator(self):
         if self.get('stop_url'):
             assert validation.valid_url(
                 self.get('stop_url')), "Invalid stop_url"
     with validator(self):
         if self.get('location_type'):
             assert validation.valid_bool(self.get('location_type'), empty=True), \
               "Invalid location_type"
     with validator(self):
         if int(self.get('location_type')
                or 0) and self.get('parent_station'):
             assert not self.get('parent_station'), \
               "A station cannot contain another station"
     with validator(self):
         if self.get('stop_timezone'):
             assert validation.valid_tz(
                 self.get('stop_timezone')), "Invalid timezone"
     with validator(self):
         if self.get('wheelchair_boarding'):
             assert validation.valid_int(self.get('wheelchair_boarding'), vmin=0, vmax=2, empty=True), \
               "Invalid wheelchair_boarding"
     with validator(self):
         if self.get('stop_code'):
             pass
     return validator
コード例 #10
0
ファイル: trip.py プロジェクト: jcmartinmu/mapzen-gtfs
 def validate(self, validator=None):
     validator = super(Trip, self).validate(validator)
     # Required
     with validator(self):
         assert self.get('route_id'), "Required: route_id"
     with validator(self):
         assert self.get('service_id'), "Required: service_id"
     with validator(self):
         assert self.get('trip_id'), "Required: trip_id"
     # TODO: Warnings:
     #   speed/vehicle_type
     #   duplicate trips
     # Optional
     with validator(self):
         if self.get('direction_id'):
             assert validation.valid_bool(
                 self.get('direction_id')), "Invalid direction_id"
     with validator(self):
         if self.get('wheelchair_accessible'):
             assert validation.valid_int(self.get('wheelchair_accessible'), vmin=0, vmax=2, empty=True), \
               "Invalid wheelchair_accessible"
     with validator(self):
         if self.get('bikes_allowed'):
             assert validation.valid_int(self.get('bikes_allowed'), vmin=0, vmax=2, empty=True), \
               "Invalid bikes_allowed"
     with validator(self):
         if self.get('trip_headsign'):
             pass
     with validator(self):
         if self.get('trip_short_name'):
             pass
     with validator(self):
         if self.get('block_id'):
             pass
     with validator(self):
         if self.get('shape_id'):
             pass
コード例 #11
0
ファイル: trip.py プロジェクト: andreyz/mapzen-gtfs
 def validate(self, validator=None):
   validator = super(Trip, self).validate(validator)
   # Required
   with validator(self):
     assert self.get('route_id'), "Required: route_id"
   with validator(self):
     assert self.get('service_id'), "Required: service_id"
   with validator(self):
     assert self.get('trip_id'), "Required: trip_id"
   # TODO: Warnings:
   #   speed/vehicle_type
   #   duplicate trips
   # Optional
   with validator(self):
     if self.get('direction_id'):
       assert validation.valid_bool(self.get('direction_id')), "Invalid direction_id"
   with validator(self):
     if self.get('wheelchair_accessible'):
       assert validation.valid_int(self.get('wheelchair_accessible'), vmin=0, vmax=2, empty=True), \
         "Invalid wheelchair_accessible"
   with validator(self):
     if self.get('bikes_allowed'):
       assert validation.valid_int(self.get('bikes_allowed'), vmin=0, vmax=2, empty=True), \
         "Invalid bikes_allowed"
   with validator(self):
     if self.get('trip_headsign'):
       pass
   with validator(self):
     if self.get('trip_short_name'):
       pass
   with validator(self):
     if self.get('block_id'):
       pass
   with validator(self):
     if self.get('shape_id'):
       pass
コード例 #12
0
ファイル: shape.py プロジェクト: jcmartinmu/mapzen-gtfs
 def validate(self, validator=None):
   validator = super(ShapeRow, self).validate(validator)
   # Required
   with validator(self):
     assert validation.valid_int(self.get('shape_pt_sequence'), vmin=0), \
       "Required: shape_pt_sequence"
   with validator(self): 
     assert self.get('shape_pt_lat'), "Required: shape_pt_lat"
   with validator(self): 
     assert self.get('shape_pt_lon'), "Required: shape_pt_lon"
   with validator(self): 
     assert validation.valid_point(self.point()), \
     "Invalid shape_pt_lon or shape_pt_lat"
   # Optional
   return validator
コード例 #13
0
ファイル: stop.py プロジェクト: andreyz/mapzen-gtfs
 def validate(self, validator=None):
   validator = super(Stop, self).validate(validator)
   # Required
   with validator(self): 
     assert self.get('stop_id'), "Required: stop_id"
   with validator(self): 
     assert self.get('stop_name'), "Required: stop_name"
   with validator(self): 
     assert self.get('stop_lat'), "Required: stop_lat"
   with validator(self): 
     assert self.get('stop_lon'), "Required: stop_lon"
   with validator(self): 
     assert validation.valid_point(self.point()), "Invalid stop_lon/stop_lat"
   # TODO: Warnings: 
   #  - stop too close to 0,0
   # Optional
   with validator(self):
     if self.get('stop_desc') == self.get('stop_name'):
       raise validation.ValidationWarning("stop_desc and stop_name are the same")        
   with validator(self):
     if self.get('zone_id') and int(self.get('location_type') or 0):
       raise validation.ValidationWarning("A station cannot have a zone_id")
   with validator(self): 
     if self.get('stop_url'):
       assert validation.valid_url(self.get('stop_url')), "Invalid stop_url"
   with validator(self): 
     if self.get('location_type'):
       assert validation.valid_bool(self.get('location_type'), empty=True), \
         "Invalid location_type"
   with validator(self):
     if int(self.get('location_type') or 0) and self.get('parent_station'):
       assert not self.get('parent_station'), \
         "A station cannot contain another station"          
   with validator(self):
     if self.get('stop_timezone'):
       assert validation.valid_tz(self.get('stop_timezone')), "Invalid timezone"
   with validator(self): 
     if self.get('wheelchair_boarding'):
       assert validation.valid_int(self.get('wheelchair_boarding'), vmin=0, vmax=2, empty=True), \
         "Invalid wheelchair_boarding"
   with validator(self):
     if self.get('stop_code'):
       pass
   return validator