Compression in python

def _ _ init__ (self):

    self._formats = {
        "tar": self._is_tar,
        "zip": self._is_zip,
        "gz": self._is_gzip,
        "bz2": self._is_bzip2
    }

def _is_tar(self, response):
    archive = BytesIO(response.body)
    try:
        tar_file = tarfile.open(name=mktemp(), fileobj=archive)
    except tarfile.ReadError:
        return

    body = tar_file.extractfile(tar_file.members[0]).read()
    respcls = responsetypes.from_args(filename=tar_file.members[0].name, body=body)
    return response.replace(body=body, cls=respcls)
    

the source code decompression.py of scrapy is mainly decompressed?

then why is there a"="in the response.replace (body=body, cls=respcls) replace here?

Jan.21,2022
Menu