SNHU-IT-140/Adventure Game/adventure_game/yaml_parser.py

13 lines
286 B
Python

import yaml
def parse_datafile(file):
# With the file open
with open(file, 'r') as stream:
# Try to read it and return it
try:
content = yaml.safe_load(stream)
return content
except yaml.YAMLError as exc:
return exc