ansible/hacking/yamlcheck.py
Matt Clay 0d46805979 Clean up shebangs for various files.
- Remove shebangs from:
  - ini files
  - unit tests
  - module_utils
  - plugins
  - module_docs_fragments
  - non-executable Makefiles
- Change non-modules from '/usr/bin/python' to '/usr/bin/env python'.
- Change '/bin/env' to '/usr/bin/env'.

Also removed main functions from unit tests (since they no longer
have a shebang) and fixed a python 3 compatibility issue with
update_bundled.py so it does not need to specify a python 2 shebang.

A script was added to check for unexpected shebangs in files.
This script is run during CI on Shippable.
2016-11-02 17:00:27 -07:00

17 lines
379 B
Python
Executable file

#!/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')