summaryrefslogtreecommitdiff
path: root/tools/validate-yaml.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-11-09 14:44:05 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-11-09 14:44:05 -0800
commit0bd973791f05f1d7f94e91b354015789b6b608dc (patch)
tree5e9124a028bb4eb300cfdce04725d52072f9c327 /tools/validate-yaml.py
parent8c006684034c13719171672836edfc65bf02ebe9 (diff)
parentd8e82fb7bc9da6259b158804ae3d8343050c67aa (diff)
downloadvyos-cloud-init-0bd973791f05f1d7f94e91b354015789b6b608dc.tar.gz
vyos-cloud-init-0bd973791f05f1d7f94e91b354015789b6b608dc.zip
Merge the yaml/cloud config examples checking tool.
Diffstat (limited to 'tools/validate-yaml.py')
-rwxr-xr-xtools/validate-yaml.py26
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)