def compress_files(files, name, excluded):
    """Compress the package and returns the new dict (name => content) of files,
    only with the conanXX files and the compressed file"""

    tgz_contents = BytesIO()
    tgz = gzopen_without_timestamps(name, mode="w", fileobj=tgz_contents)

    def addfile(name, file_info, tar):
        info = tarfile.TarInfo(name=name)
        the_str = BytesIO(file_info["contents"])
        info.size = len(file_info["contents"])
        info.mode = file_info["mode"]
        tar.addfile(tarinfo=info, fileobj=the_str)

    for the_file, info in files.items():
        if the_file not in excluded:
            addfile(the_file, info, tgz)

    tgz.close()
    ret = {}
    for e in excluded:
        if e in files:
            ret[e] = files[e]["contents"]
    ret[name] = tgz_contents.getvalue()

    return ret
dataset/ETHPy150Open conan-io/conan/conans/client/remote_manager.py/compress_files/original