import codecs
import yaml


def parse_yaml_or_json(path):
    """
    Return parsed YAML or JSON for a path to a file.
    """
    with codecs.open(path, mode='r', encoding='utf-8') as infile:
        doc = yaml.safe_load(infile)
    return doc