Changeset 4636 for exist/trunk/python/ndgUtils/lib/atomvalidator.py
- Timestamp:
- 15/12/08 11:54:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
exist/trunk/python/ndgUtils/lib/atomvalidator.py
r4589 r4636 23 23 Exception handling for validation. 24 24 """ 25 BASE_MESSAGE = 'Data validation error' 25 26 def __init__(self, errorDict): 26 msg = "Data validation error" 27 logging.error(msg) 28 Exception.__init__(self, msg) 27 logging.error(self.BASE_MESSAGE) 28 Exception.__init__(self, self.BASE_MESSAGE) 29 29 for val in errorDict.itervalues(): 30 30 logging.error(val) … … 53 53 54 54 NEW_LINE = "\n" 55 56 57 def __init__(self, atom, dbConfigFile, raiseException = False, \ 55 ILLEGAL_UNICODE_MESSAGE = 'Illegal unicode found in string' 56 57 58 def __init__(self, atom, dbConfigFile, raiseException = True, \ 58 59 newLineChar= NEW_LINE, loadAllCollections = False, \ 59 60 isDebug = False): … … 174 175 spatialError += "Incomplete spatial coverage data.%s" %self._nl 175 176 if incorrectFormat: 176 spatialError += "Spatial coverage data not in numerical format." 177 177 spatialError += "Spatial coverage data not in numerical format.%s" %self._nl 178 179 if not self.__isRangeValid(self._atom.minX ,self._atom.maxX): 180 spatialError += "Max longitude is less than min longitude.%s" %self._nl 181 182 if not self.__isRangeValid(self._atom.minY ,self._atom.maxY): 183 spatialError += "Max latitude is less than min latitude.%s" %self._nl 184 185 178 186 if spatialError: 179 187 self.__addError('spatialcoverage', spatialError) … … 207 215 208 216 217 def __isRangeValid(self, minVal, maxVal): 218 ''' 219 Check if two values adhere to being min/max of a range 220 @param minVal: start of the range 221 @param maxVal: end of the range 222 @return: True, if range is valid, or unknown (inputs may be badly defined), or False otherwise 223 ''' 224 try: 225 if float(minVal) <= float(maxVal): 226 return True 227 else: 228 return False 229 except: 230 logging.debug("Comparing invalid data: '%s' vs '%s'" %(minVal, maxVal)) 231 232 return False 233 209 234 def __validateUnicode(self): 210 235 ''' … … 219 244 if not self.errors.has_key(key): 220 245 self.errors[key] = '' 221 self.errors[key] += "Illegal unicode found in string: '%s'.'%s'" %(val, nl) 246 self.errors[key] += "%s: '%s'.'%s'" %(self.ILLEGAL_UNICODE_MESSAGE, \ 247 val, self._nl) 222 248 logging.info("Completed validating unicode UTF-8 compliance") 223 249
Note: See TracChangeset
for help on using the changeset viewer.