Add a hook for yaml files.

This commit is contained in:
Anthony Sottile
2014-04-03 21:36:03 -07:00
parent 212b3dc49d
commit 3e45f53e68
8 changed files with 59 additions and 3 deletions

View File

@ -0,0 +1,26 @@
import argparse
import sys
import yaml
from pre_commit_hooks.util import entry
@entry
def check_yaml(argv):
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='+', help='Filenames to check.')
args = parser.parse_args(argv)
retval = 0
for filename in args.filenames:
try:
yaml.load(open(filename))
except yaml.YAMLError as e:
print e
retval = 1
return retval
if __name__ == '__main__':
sys.exit(check_yaml())