# HG changeset patch # User Henry S. Thompson # Date 1773687977 0 # Node ID 22a952de4b91f933db71b7bca5e79886de9cd3c3 # Parent 2874da240b734033ad8ef6de90a39c297f3cf0fc _out no longer used diff -r 2874da240b73 -r 22a952de4b91 lib/python/cc/warc.py --- 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.