quick yaml syntax checker
This commit is contained in:
parent
16a3b69549
commit
71a707fba5
1 changed files with 16 additions and 0 deletions
16
hacking/yamlcheck.py
Executable file
16
hacking/yamlcheck.py
Executable file
|
@ -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')
|
Loading…
Reference in a new issue