fix error clobbering

This commit is contained in:
Buck Golemon
2014-10-01 14:38:05 -07:00
parent 7d546c1f81
commit cdf0dae90d
2 changed files with 8 additions and 5 deletions

View File

@@ -21,9 +21,9 @@ def is_regex_valid(regex):
def get_validator(
json_schema,
exception_type,
additional_validation_strategy=lambda obj: None,
json_schema,
exception_type,
additional_validation_strategy=lambda obj: None,
):
"""Returns a function which will validate a yaml file for correctness
@@ -44,14 +44,14 @@ def get_validator(
obj = load_strategy(file_contents)
except Exception as e:
raise exception_type(
'File {0} is not a valid yaml file'.format(filename), e,
'Invalid yaml: {0}\n{1}'.format(os.path.relpath(filename), e),
)
try:
jsonschema.validate(obj, json_schema)
except jsonschema.exceptions.ValidationError as e:
raise exception_type(
'File {0} is not a valid file'.format(filename), e,
'Invalid content: {0}\n{1}'.format(os.path.relpath(filename), e),
)
obj = apply_defaults(obj, json_schema)

View File

@@ -23,3 +23,6 @@ deps =
sphinx
changedir = docs
commands = sphinx-build -b html -d build/doctrees source build/html
[flake8]
max-line-length=131