kolla-ansible/tools/validate-json.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
610 B
Python
Executable File

#!/usr/bin/python
import sys
import argparse
import json
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:
json.load(fd)
except ValueError as error:
res = 1
logging.error('%s failed validation: %s',
filename, error)
sys.exit(res)
if __name__ == '__main__':
main()