예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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