class documentation
class OffsetRememberingCluster(Cluster):
Known subclasses: pyzim.cluster.InMemoryCluster
Constructor: OffsetRememberingCluster(zim, offset)
A variation of Cluster that reads offsets only once, storing them in memory.
| Method | __init__ |
The default constructor. |
| Method | iter |
Read the blob offsets, yielding them as an iterator. |
| Method | reset |
Reset all internal state except the cluster offset, causing said offset to be read again the next time it is required. |
| Method | _read |
Read the offsets if they have not yet been read. |
| Instance Variable | _offsets |
the offsets in this cluster |
Inherited from Cluster:
| Method | generate |
Generate the infobyte for this cluster. |
| Method | get |
Get the size of a blob. |
| Method | get |
Return the content size of this cluster. |
| Method | get |
Return the number of blobs in this cluster. |
| Method | get |
Return the number of offsets in this cluster. |
| Method | get |
Return the offset with the specified index. |
| Method | get |
Return the total compressed size of the cluster. |
| Method | get |
Return the total decompressed size of this cluster. |
| Method | get |
Return the total size of the offsets. |
| Method | iter |
Iteratively read the specified blob. |
| Method | parse |
Parse the cluster information byte, setting the attributes of this cluster as necessary. |
| Method | read |
Read the entirety of the specified range in the specified blob and return the content. |
| Method | read |
Read the cluster information byte, returning it. |
| Method | read |
Read and parse the infobyte if this has not yet happened. |
| Instance Variable | compression |
compression to use, None when unknown |
| Instance Variable | is |
whether this cluster is extended, None if not set |
| Instance Variable | offset |
absolute offset of the cluster |
| Property | did |
True if the infobyte was already read and parsed. |
| Method | _get |
Return a compressor suitable to compress this cluster. |
| Method | _get |
Return a decompressing reader that can be sued to decompress the content. |
| Method | _get |
Return a decompressor suitable to decompress this cluster. |
| Method | _seek |
Seek to the specified position (relative to the cluster start) in the file only if it is needed. |
| Instance Variable | _decompressing |
Undocumented |
| Property | _pointer |
The pointer format. |
Inherited from BindableMixIn (via Cluster):
| Method | bind |
Bind this object to a ZIM file. |
| Method | unbind |
Unbind this object. Can be called multiple times. |
| Property | bound |
Whether this object is bound to a ZIM file or not. |
| Property | zim |
The bound ZIM archive, if any is bound. Otherwise None. |
| Instance Variable | _zim |
the bound ZIM archive or None |
overrides
pyzim.cluster.Cluster.__init__overridden in
pyzim.cluster.InMemoryClusterThe default constructor.
| Parameters | |
zim:pyzim.archive.Zim | if specified, bind this ZIM immediately. |
offset:int or None | absolute offset of the cluster |
| Raises | |
ValueError | if offset was specified but zim was not specified. |
overrides
pyzim.cluster.Cluster.iter_blob_offsetsRead the blob offsets, yielding them as an iterator.
The order of blob_numbers does not matter, all offsets are always yielded in regular order (offfset 1, offset 2, ...).
| Parameters | |
blobNone or list of int | if specified, load only these offsets |
| Yields | |
int | the offset of each blob in the decompressed body, relative to cluster start |
| Raises | |
pyzim.exceptions.BindRequired | if cluster is unbound |
overrides
pyzim.cluster.Cluster.resetoverridden in
pyzim.cluster.InMemoryClusterReset all internal state except the cluster offset, causing said offset to be read again the next time it is required.
Read the offsets if they have not yet been read.
| Raises | |
pyzim.exceptions.BindRequired | if cluster is unbound |