diff options
author | Vlastimil Holer <vlastimil.holer@gmail.com> | 2012-12-19 18:03:03 +0100 |
---|---|---|
committer | Vlastimil Holer <vlastimil.holer@gmail.com> | 2012-12-19 18:03:03 +0100 |
commit | 8dd9678d97a822e477915c150d528096a83c9777 (patch) | |
tree | a9b5708edd9d448508abf00abdd9b7bdeba16541 /tools/validate-yaml.py | |
parent | a9939fe768e04d52fe530c7467357d79b78a21f4 (diff) | |
parent | 3569e71a1579b97f4e33fb46ab3fcef08a4ddad4 (diff) | |
download | vyos-cloud-init-8dd9678d97a822e477915c150d528096a83c9777.tar.gz vyos-cloud-init-8dd9678d97a822e477915c150d528096a83c9777.zip |
Merged trunk lp:cloud-init
Diffstat (limited to 'tools/validate-yaml.py')
-rwxr-xr-x | tools/validate-yaml.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/validate-yaml.py b/tools/validate-yaml.py new file mode 100755 index 00000000..eda59cb8 --- /dev/null +++ b/tools/validate-yaml.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +"""Try to read a YAML file and report any errors. +""" + +import sys + +import yaml + + +if __name__ == "__main__": + bads = 0 + for fn in sys.argv[1:]: + sys.stdout.write("%s" % (fn)) + try: + fh = open(fn, 'r') + yaml.safe_load(fh.read()) + fh.close() + sys.stdout.write(" - ok\n") + except Exception, e: + sys.stdout.write(" - bad (%s)\n" % (e)) + bads += 1 + if bads > 0: + sys.exit(1) + else: + sys.exit(0) |