~smoser/cloud-init/lp-1077700

« back to all changes in this revision

Viewing changes to tools/validate-yaml.py

  • Committer: Joshua Harlow
  • Date: 2012-11-08 05:00:33 UTC
  • mto: This revision was merged to the branch mainline in revision 706.
  • Revision ID: harlowja@yahoo-inc.com-20121108050033-ahyuopeskza34ph5
Add a makefile yaml checking target
and fix the cases where the cc yaml
is not correct.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
"""Try to read a YAML file and report any errors.
 
4
"""
 
5
 
 
6
import sys
 
7
 
 
8
import yaml
 
9
 
 
10
 
 
11
if __name__ == "__main__":
 
12
    for fn in sys.argv[1:]:
 
13
        sys.stdout.write("%s" % (fn))
 
14
        try:
 
15
            fh = open(fn, 'r')
 
16
            yaml.safe_load(fh.read())
 
17
            fh.close()
 
18
            sys.stdout.write(" - ok\n")
 
19
        except Exception, e:
 
20
            sys.stdout.write(" - bad (%s)\n" % (e))