b.p.ContainerReader(BaseReader) : class documentation

Part of bzrlib.pack View In Hierarchy

A class for reading Bazaar's container format.
Method iter_records Iterate over the container, yielding each record as it is read.
Method iter_record_objects Iterate over the container, yielding each record as it is read.
Method validate Validate this container and its records.
Method _iter_records Undocumented
Method _iter_record_objects Undocumented
Method _read_format Undocumented

Inherited from BaseReader:

Method __init__ Constructor.
Method reader_func Undocumented
Method _read_line Undocumented
def iter_records(self):
Iterate over the container, yielding each record as it is read.

Each yielded record will be a 2-tuple of (names, callable), where names is a list and bytes is a function that takes one argument, max_length.

You must not call the callable after advancing the iterator to the next record. That is, this code is invalid:

record_iter = container.iter_records()
names1, callable1 = record_iter.next()
names2, callable2 = record_iter.next()
bytes1 = callable1(None)

As it will give incorrect results and invalidate the state of the ContainerReader.

RaisesContainerErrorif any sort of container corruption is detected, e.g. UnknownContainerFormatError is the format of the container is unrecognised.
See AlsoContainerReader.read
def iter_record_objects(self):
Iterate over the container, yielding each record as it is read.

Each yielded record will be an object with read and validate methods. Like with iter_records, it is not safe to use a record object after advancing the iterator to yield next record.

RaisesContainerErrorif any sort of container corruption is detected, e.g. UnknownContainerFormatError is the format of the container is unrecognised.
See Alsoiter_records
def _iter_records(self):
Undocumented
def _iter_record_objects(self):
Undocumented
def _read_format(self):
Undocumented
def validate(self):
Validate this container and its records.

Validating consumes the data stream just like iter_records and iter_record_objects, so you cannot call it after iter_records/iter_record_objects.

RaisesContainerErrorif something is invalid.
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.