def run_validator(filename=None): try: print 'Validating file \'%s\'\n' % filename validator = NeighbordbValidator() filename = filename or default_filename() validator.validate(load(filename, CONTENT_TYPE_YAML, 'validator')) print 'Valid Patterns (count: %d)' % len(validator.valid_patterns) print '--------------------------' for index, pattern in enumerate(sorted(validator.valid_patterns)): print '[%d] %s' % (index, pattern[1]) print print 'Failed Patterns (count: %d)' % len(validator.invalid_patterns) print '---------------------------' for index, pattern in enumerate(sorted(validator.invalid_patterns)): print '[%d] %s' % (index, pattern[1]) print except Exception as exc: #pylint: disable=W0703 log.exception(exc) print 'An unexpected error occurred trying to run the validator'
def validate_neighbordb(): # Validating neighbordb validator = NeighbordbValidator('N/A') neighbordb = neighbordb_path() print 'Validating neighbordb (\'%s\')...' % neighbordb try: validator.validate(load(neighbordb, CONTENT_TYPE_YAML, 'validator')) total_patterns = len(validator.valid_patterns) + \ len(validator.invalid_patterns) if validator.invalid_patterns: print '\nERROR: Failed to validate neighbordb patterns' print ' Invalid Patterns (count: %d/%d)' % \ (len(validator.invalid_patterns), total_patterns) print ' ---------------------------' for index, pattern in enumerate(sorted( validator.invalid_patterns)): print ' [%d] %s' % (index, pattern[1]) else: print 'Ok!' except Exception as exc: #pylint: disable=W0703 print 'ERROR: Failed to validate neighbordb\n%s' % exc
def _validate_neighbordb(self): validator = NeighbordbValidator(ID) validator.validate(self.ndb) return (validator.valid_patterns, validator.invalid_patterns)