import json


def getmeta_ocred(fname, cfg):
    """ Get metadata info of fname.

    Args:
        fname (str): filename from which to get metadata.
        cfg (Config): configuration data.

    Return:
        dict: metadata info corresponding to fname.

    Raise:
        ValueError: metadata for fname not found.

    """

    allmeta = json.load(open(cfg.get('ocred', 'metadata file')))

    try:
        return allmeta[fname]
    except KeyError:
        raise ValueError('Error: metadata for document %s not found.' % fname)