kolla-ansible/tools/validate-yaml.py
Borne Mace 42c2419353 Fixed pep8 failures in all tools/ scripts
Change-Id: Ie6e77a4d45210122746b544a1aa8da563833e395
Partially-Implements: blueprint enable-flake8
2015-07-07 08:34:43 -07:00

33 lines
620 B
Python
Executable File

#!/usr/bin/python
import sys
import argparse
import yaml
import logging
def parse_args():
p = argparse.ArgumentParser()
p.add_argument('input', nargs='*')
return p.parse_args()
def main():
args = parse_args()
logging.basicConfig()
res = 0
for filename in args.input:
with open(filename) as fd:
try:
yaml.load(fd)
except yaml.error.YAMLError as error:
res = 1
logging.error('%s failed validation: %s',
filename, error)
sys.exit(res)
if __name__ == '__main__':
main()