MCPcopy
hub / github.com/scrapy/scrapy / _unzstd

Function _unzstd

scrapy/utils/_compression.py:79–90  ·  view source on GitHub ↗
(data: bytes, *, max_size: int = 0)

Source from the content-addressed store, hash-verified

77
78
79def _unzstd(data: bytes, *, max_size: int = 0) -> bytes:
80 decompressor = zstandard.ZstdDecompressor()
81 stream_reader = decompressor.stream_reader(BytesIO(data))
82 output_stream = BytesIO()
83 output_chunk = b"."
84 decompressed_size = 0
85 while output_chunk:
86 output_chunk = stream_reader.read(_CHUNK_SIZE)
87 decompressed_size += len(output_chunk)
88 _check_max_size(decompressed_size, max_size)
89 output_stream.write(output_chunk)
90 return output_stream.getvalue()

Callers 1

_decodeMethod · 0.90

Calls 3

_check_max_sizeFunction · 0.85
readMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected