Skip to content

Instantly share code, notes, and snippets.

@JoaoCarabetta
Created September 19, 2019 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoaoCarabetta/061865466594f13154559dda0f009d5a to your computer and use it in GitHub Desktop.
Save JoaoCarabetta/061865466594f13154559dda0f009d5a to your computer and use it in GitHub Desktop.
Load config from yaml
def open_yaml(path):
"""
Load yaml file.
Parameters
----------
path: pathlib.PosixPath
Path to yaml file
Return
------
Dictionary
Dictionary with yaml file content
"""
with open(path) as stream:
try:
yaml_dict = yaml.safe_load(stream)
except yaml.YAMLError as exc:
logging.error('Error when opening YAML file.', exc_info=1)
return yaml_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment