import yaml


def read_yaml(fname):
    """Parse yaml file and return a dict."""

    metadict = {}
    try:
        with open(fname, 'r') as yaml_file:
            metadict = yaml.safe_load(yaml_file)
    except Exception as e:
        print("Error loading {file}\n{error}".format(file=fname, error=e))

    return metadict