From 71a707fba54617f0c9276f42292307711cf44f15 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 18 May 2016 18:12:17 -0400 Subject: [PATCH] quick yaml syntax checker --- hacking/yamlcheck.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 hacking/yamlcheck.py diff --git a/hacking/yamlcheck.py b/hacking/yamlcheck.py new file mode 100755 index 00000000000..c66d70db134 --- /dev/null +++ b/hacking/yamlcheck.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +# long version of this one liner: python -c 'import yaml,sys;yaml.safe_load(sys.stdin)' < yamltest.txt +import yaml +import sys + +if len(sys.argv) > 1: + check_file = open(sys.argv[1]) +else: + check_file = sys.stdin + +try: + yaml.safe_load(check_file) +except yaml.scanner.ScannerError as e: + sys.exit('Invalid YAML:\n%s' % str(e)) + +print('valid YAML')