mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
Autoupdate roundtrips. Resolves #210
This commit is contained in:
parent
da7e85c851
commit
de33fad483
11 changed files with 78 additions and 98 deletions
|
|
@ -9,9 +9,9 @@ import sys
|
|||
import jsonschema
|
||||
import jsonschema.exceptions
|
||||
import pkg_resources
|
||||
import yaml
|
||||
|
||||
from pre_commit.jsonschema_extensions import apply_defaults
|
||||
from pre_commit.util import yaml_load
|
||||
|
||||
|
||||
def is_regex_valid(regex):
|
||||
|
|
@ -36,14 +36,14 @@ def get_validator(
|
|||
the object read from the file. The function should either raise
|
||||
exception_type on failure.
|
||||
"""
|
||||
def validate(filename, load_strategy=yaml.load):
|
||||
def validate(filename):
|
||||
if not os.path.exists(filename):
|
||||
raise exception_type('File {0} does not exist'.format(filename))
|
||||
|
||||
file_contents = open(filename, 'r').read()
|
||||
|
||||
try:
|
||||
obj = load_strategy(file_contents)
|
||||
obj = yaml_load(file_contents)
|
||||
except Exception as e:
|
||||
raise exception_type(
|
||||
'Invalid yaml: {0}\n{1}'.format(os.path.relpath(filename), e),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue