summaryrefslogtreecommitdiffstats
path: root/hacking/yamlcheck.py
blob: 68d796cb1a5f9004749f58d0a3bd6afa46554b32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env 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')