<s> import json <EOL> import jsonschema <EOL> import os <EOL> from bareon import errors <EOL> from bareon . openstack . common import log as logging <EOL> LOG = logging . getLogger ( __name__ ) <EOL> def validate ( data , schema_file = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> base_path = os . path . dirname ( __file__ ) <EOL> schemas_path = os . path . join ( base_path , '<STR_LIT>' ) <EOL> with open ( os . path . join ( schemas_path , '<STR_LIT>' % schema_file ) ) as file : <EOL> schema = json . load ( file ) <EOL> try : <EOL> checker = jsonschema . FormatChecker ( ) <EOL> jsonschema . validate ( data , schema , <EOL> format_checker = checker ) <EOL> except Exception as exc : <EOL> LOG . exception ( exc ) <EOL> raise errors . WrongPartitionSchemeError ( str ( exc ) ) <EOL> if not [ d for d in data if d [ '<STR_LIT:type>' ] == '<STR_LIT>' ] : <EOL> raise errors . WrongPartitionSchemeError ( <EOL> '<STR_LIT>' ) </s>
