Last active
August 29, 2015 14:18
-
-
Save rfairburn/30c250f49926cbfb104a to your computer and use it in GitHub Desktop.
yamltest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import yaml | |
from pprint import pprint | |
filename = sys.argv[1] | |
with open(filename, 'r') as yaml_file: | |
try: | |
yaml_data = yaml.load(yaml_file); | |
except Exception: | |
print('Invalid yaml detected.') | |
sys.exit(1) | |
pprint(yaml_data) | |
print('Yaml loaded successfully.') | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment