import gzip


def _open_config_file(filename, mode="r"):
    """Open a file respecting .gz file endings."""
    if filename[-3:] == ".gz":
        return gzip.open(filename, mode, encoding="UTF-8")
    else:
        return open(filename, mode, encoding="UTF-8")