Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_data(path, parser='PyYAML'):
from . import readers
raw_data = readers.parse_file(path, parser)
return [(d, path) for d in raw_data]
def make_schema(path, parser='PyYAML', validators=None):
# validators = None means use default.
# Import readers here so we can get version information in setup.py.
from . import readers
raw_schemas = readers.parse_file(path, parser)
if not raw_schemas:
raise ValueError('{} is an empty file!'.format(path))
# First document is the base schema
try:
s = Schema(raw_schemas[0], path, validators=validators)
# Additional documents contain Includes.
for raw_schema in raw_schemas[1:]:
s.add_include(raw_schema)
except (TypeError, SyntaxError) as e:
error = 'Schema error in file %s\n' % path
error += str(e)
if PY2:
error.encode('utf-8')
raise SyntaxError(error)
return s