Mercurial > hg > cc > cirrus_work
changeset 358:22a952de4b91 plus
_out no longer used
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Mon, 16 Mar 2026 19:06:17 +0000 |
| parents | 2874da240b73 |
| children | 3a7604314cc0 |
| files | lib/python/cc/warc.py |
| diffstat | 1 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/python/cc/warc.py Mon Mar 16 13:18:51 2026 +0000 +++ b/lib/python/cc/warc.py Mon Mar 16 19:06:17 2026 +0000 @@ -29,7 +29,8 @@ Q.append((b,e)) def warc(filename: str, - callback: typing.Callable[[bytes, typing.ByteString, int], typing.BinaryIO], + callback: typing.Callable[[bytes, typing.ByteString, int, tuple[int, int]], + None], types: typing.List[int] = [RESP], whole: bool = False, parts: int = 7, debug: bool = False, block = False): '''parts is a bit-mask: @@ -118,13 +119,13 @@ if whole: args = (wtype,bufView[start_1:bp+length], 7, brange) if block \ else (wtype,bufView[start_1:bp+length], 7) - _out = callback(*args) + callback(*args) else: if (parts & 1): bp = eol + 2 args = (wtype, bufView[start_1:bp], 1, brange) if block \ else (wtype, bufView[start_1:bp], 1) - _out = callback(*args) + callback(*args) if parts != 1: while buf.startswith(b'\r\n', bp): bp += 2 @@ -139,12 +140,12 @@ eo2 = buf.index(b'\r\n\r\n', start_2) args = (wtype, bufView[start_2:eo2 + 2], 2, brange) if block \ else (wtype, bufView[start_2:eo2 + 2], 2) - _out = callback(*args) + callback(*args) else: # rest of the part args = (wtype, bufView[start_2:eob], 2, brange) if block \ else (wtype, bufView[start_2:eob], 2) - _out = callback(*args) + callback(*args) if parts & 4: raise ValueError("Not implemented: body part (4): %s"%parts) #bp += length @@ -176,7 +177,7 @@ import zlib, gzip, struct from isal import isal_zlib -def decompOneBlock(data: char[::1], bl: int, bp: int = 0) -> tuple(bytes, int): +def decompOneBlock(data: char[::1], bl: int, bp: int = 0) -> tuple[bytes, int]: """Decompress one block of a gzip compressed stream in one shot. Return the decompressed string and the stream repositioned at the start of the next block.
