class documentation

Class to read a pack stream.

The pack is read from a ReceivableProtocol using read() or recv() as appropriate.

Method __init__ Initialize pack stream reader.
Method __len__ Return the number of objects in this pack.
Method read Read, blocking until size bytes are read.
Method read_objects Read the objects in this pack file.
Method recv Read up to size bytes, blocking until one byte is read.
Instance Variable hash_func Undocumented
Instance Variable read_all Undocumented
Instance Variable read_some Undocumented
Instance Variable sha Undocumented
Property offset Return current offset in the stream.
Method _buf_len Undocumented
Method _read Read up to size bytes using the given callback.
Instance Variable _hash_size Undocumented
Instance Variable _num_objects Undocumented
Instance Variable _offset Undocumented
Instance Variable _rbuf Undocumented
Instance Variable _trailer Undocumented
Instance Variable _zlib_bufsize Undocumented
def __init__(self, hash_func: Callable[[], HashObject], read_all: Callable[[int], bytes], read_some: Callable[[int], bytes] | None = None, zlib_bufsize: int = _ZLIB_BUFSIZE):

Initialize pack stream reader.

Parameters
hash_func:Callable[[], HashObject]Hash function to use for computing object IDs
read_all:Callable[[int], bytes]Function to read all requested bytes
read_some:Callable[[int], bytes] | NoneFunction to read some bytes (optional)
zlib_bufsize:intBuffer size for zlib decompression
def __len__(self) -> int:

Return the number of objects in this pack.

def read(self, size: int) -> bytes:

Read, blocking until size bytes are read.

def read_objects(self, compute_crc32: bool = False) -> Iterator[UnpackedObject]:

Read the objects in this pack file.

Returns: Iterator over UnpackedObjects with the following members set:
offset obj_type_num obj_chunks (for non-delta types) delta_base (for delta types) decomp_chunks decomp_len crc32 (if compute_crc32 is True)
Parameters
compute_crc32:boolIf True, compute the CRC32 of the compressed data. If False, the returned CRC32 will be None.
Returns
Iterator[UnpackedObject]Undocumented
Raises
ChecksumMismatchif the checksum of the pack contents does not match the checksum in the pack trailer.
zlib.errorif an error occurred during zlib decompression.
IOErrorif an error occurred writing to the output file.
def recv(self, size: int) -> bytes:

Read up to size bytes, blocking until one byte is read.

hash_func =

Undocumented

read_all =

Undocumented

read_some =

Undocumented

sha =

Undocumented

offset: int =

Return current offset in the stream.

def _buf_len(self) -> int:

Undocumented

def _read(self, read: Callable[[int], bytes], size: int) -> bytes:

Read up to size bytes using the given callback.

As a side effect, update the verifier's hash (excluding the last hash_size bytes read, which is the pack checksum).

Returns: Bytes read

Parameters
read:Callable[[int], bytes]The read callback to read from.
size:intThe maximum number of bytes to read; the particular behavior is callback-specific.
Returns
bytesUndocumented
_hash_size =

Undocumented

_num_objects =

Undocumented

_offset: int =

Undocumented

_rbuf =

Undocumented

_trailer: deque[int] =

Undocumented

_zlib_bufsize =

Undocumented