def read_file(path):

    # check if path has extension
    if '.' not in path:
        raise RuntimeError("File {path} has no extension".format(path=path))
    extension = path.split(".")[-1]

    # check if extension is json or yml
    extension_map = {"json": json, "yml": yaml, "yaml": yaml}
    if extension not in extension_map:
        raise RuntimeError(
            "File extension of {path} is not yaml/json".format(path=path))

    # do actual job
    with open(path) as descriptor:
        return extension_map.get(extension).load(descriptor)
This function reads yaml / json files
dataset/ETHPy150Open MirantisWorkloadMobility/CloudFerry/cloudferry/condensation/utils.py/read_file