Skip to content

Instantly share code, notes, and snippets.

@Resisty
Created February 11, 2016 00:48
Show Gist options
  • Save Resisty/3e2ceb03ecee18cdc90a to your computer and use it in GitHub Desktop.
Save Resisty/3e2ceb03ecee18cdc90a to your computer and use it in GitHub Desktop.
Yam lint
#!/usr/bin/python
import sys
try:
import yaml
except:
print 'You must first install pyyaml: `pip install pyyaml`'
sys.exit(1)
from argparse import ArgumentParser
def main():
parser = ArgumentParser('Yam Lint. Mmm.')
parser.add_argument('yamlfile', help = 'The YAML file which needs linting.')
args = parser.parse_args()
msg = '{} is {}yaml{}'
try:
with open(args.yamlfile, 'r') as fptr:
yamlint = yaml.load(fptr.read())
except:
print msg.format(args.yamlfile, 'not ', '.')
return
print msg.format(args.yamlfile, '', '!')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment