import yaml


def read_config(fname, keepers=None):
    """Reads a YAML file.

    If a list of keepers is provided, will look through the YAML and only
    return those keys.

    """
    with open(fname, "r", encoding="utf8") as fh:
        c = yaml.full_load(fh)

    if keepers is None:
        return c

    if isinstance(keepers, str):
        return c.get(keepers, None)

    config = {}
    for k in keepers:
        v = c.get(k, None)
        if v is not None:
            config[k] = v

    return config