#NEWLINE# def validate( self , schema ) : #NEWLINE# #INDENT# self . logger . info ( ( "Check labels based on schema in '%s'" % schema ) ) #NEWLINE# if os . path . exists ( schema ) : #NEWLINE# #INDENT# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for key in self . labels : #NEWLINE# #INDENT# if self . labels [ key ] . isdigit ( ) : #NEWLINE# #INDENT# data [ key ] = int ( self . labels [ key ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data [ key ] = self . labels [ key ] #NEWLINE# #UNINDENT# #UNINDENT# with open ( schema ) as schema_file : #NEWLINE# #INDENT# schema_data = json . load ( schema_file ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# jsonschema . validate ( data , schema_data ) #NEWLINE# #UNINDENT# except jsonschema . ValidationError as e : #NEWLINE# #INDENT# self . logger . error ( str ( e ) ) #NEWLINE# #UNINDENT# except jsonschema . SchemaError as e : #NEWLINE# #INDENT# self . logger . error ( str ( e ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . logger . error ( ( "Schema file '%s' not found" % schema ) ) #NEWLINE# raise SchemaNotFoundError