Example #1
0
 def validate(self, validator=None):
     validator = super(Agency, self).validate(validator)
     # Required
     with validator(self):
         assert self.get('agency_name'), \
           "Required: agency_name"
     with validator(self):
         assert self.get('agency_url'), "Required: agency_url"
         assert validation.valid_url(self.get('agency_url')), \
           "Invalid agency_url"
     with validator(self):
         assert self.get('agency_timezone'), "Required: agency_timezone"
         assert validation.valid_tz(self.get('agency_timezone')), \
           "Invalid agency_timezone"
     # Optional
     with validator(self):
         if self.get('agency_lang'):
             assert validation.valid_language(self.get('agency_lang')), \
               "Invalid language"
     with validator(self):
         if self.get('agency_fare_url'):
             assert validation.valid_url(self.get('agency_fare_url')), \
               "Invalid agency_fare_url"
     with validator(self):
         if self.get('agency_id'):
             pass
     with validator(self):
         if self.get('agency_phone'):
             pass
     return validator
Example #2
0
 def validate(self, validator=None):
   validator = super(Agency, self).validate(validator)
   # Required
   with validator(self): 
     assert self.get('agency_name'), \
       "Required: agency_name"
   with validator(self): 
     assert self.get('agency_url'), "Required: agency_url"
     assert validation.valid_url(self.get('agency_url')), \
       "Invalid agency_url"
   with validator(self):
     assert self.get('agency_timezone'), "Required: agency_timezone"
     assert validation.valid_tz(self.get('agency_timezone')), \
       "Invalid agency_timezone"
   # Optional
   with validator(self): 
     if self.get('agency_lang'):
       assert validation.valid_language(self.get('agency_lang')), \
         "Invalid language"
   with validator(self): 
     if self.get('agency_fare_url'):
       assert validation.valid_url(self.get('agency_fare_url')), \
         "Invalid agency_fare_url"
   with validator(self):
     if self.get('agency_id'): 
       pass
   with validator(self):
     if self.get('agency_phone'):
       pass
   return validator
Example #3
0
 def validate(self, validator=None):
   validator = super(Route, self).validate(validator)
   # Required
   with validator(self):
     assert self.get('route_id'), "Required: route_id"
   with validator(self):
     assert self.get('route_type'), "Required: route_type"
     assert self.vehicle(), "Invalid route_type"
   with validator(self):
     assert self.get('route_short_name') or self.get('route_long_name'), \
       "Must provide either route_short_name or route_long_name"
   # TODO: Warnings:
   #   short name too long
   #   short name == long name
   #   route_desc != route name
   # Optional
   with validator(self):
     if self.get('agency_id'): pass
   with validator(self):
     if self.get('route_desc'): pass
   with validator(self):
     if self.get('route_url'):
       assert validation.valid_url(self.get('route_url')), \
         "Invalid route_url"
   with validator(self):
     if self.get('route_color'):
       assert validation.valid_color(self.get('route_color')), \
         "Invalid route_color"
   with validator(self):
     if self.get('route_text_color'):
       assert validation.valid_color(self.get('route_text_color')), \
         "Invalid route_text_color"
   return validator
Example #4
0
    def validate(self, validator=None):
        validator = super(FeedInfo, self).validate(validator)
        # Required
        with validator(self):
            assert self.get('feed_publisher_name'), \
                "Required: feed_publisher_name"

        with validator(self):
            assert self.get(
                'feed_publisher_url'), "Required: feed_publisher_url"
            assert validation.valid_url(self.get('feed_publisher_url')), \
                "Invalid agency_url"

        with validator(self):
            assert validation.valid_language(self.get('feed_lang')), \
            "Invalid language"

        with validator(self):
            if self.get('feed_start_date'):
                assert validation.valid_language(self.get('feed_start_date')), \
                "Invalid start date"

        with validator(self):
            if self.get('feed_end_date'):
                assert validation.valid_language(self.get('feed_end_date')), \
                "Invalid end date"
Example #5
0
 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
Example #6
0
 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