class BaseCompressionStrategy(object):
Known subclasses: pyzim.compressionstrategy.MimetypeBasedCompressionStrategy, pyzim.compressionstrategy.SimpleCompressionStrategy
Constructor: BaseCompressionStrategy(zim)
Baseclass for compression strategies.
A compression strategy is responsible for deciding how blobs should# be bundled into clusters. For this, they take pyzim.item.Item instances (which also grants them additional informations like mimetype), decide which cluster they should belong to, instantiate entries and set the proper cluster and blob numbers.
BaseCompressionStrategy instances are supposed to be used in a recursive hierarchy. For example, one compression strategy could take an item, analyzes it for its mimetype, then entries of each mimetype grouped together to another compression strategy (instantiated once for each mimetype) that puts all items below a specific size into an uncompressed cluster.
| Method | __init__ |
The default constructor. |
| Method | add |
Handle the addition of an item (e.g. create entries, ...). |
| Method | flush |
Flush all current items. |
| Method | has |
True if this compression strategy still has items to be written. |
| Instance Variable | zim |
zim archive this compression strategy compresses for |
pyzim.compressionstrategy.MimetypeBasedCompressionStrategy, pyzim.compressionstrategy.SimpleCompressionStrategyThe default constructor.
| Parameters | |
zim:pyzim.archive.Zim | zim archive this compression strategy compresses for |
pyzim.compressionstrategy.MimetypeBasedCompressionStrategy, pyzim.compressionstrategy.SimpleCompressionStrategyHandle the addition of an item (e.g. create entries, ...).
| Parameters | |
item:pyzim.item.Item | item to add |
pyzim.compressionstrategy.MimetypeBasedCompressionStrategy, pyzim.compressionstrategy.SimpleCompressionStrategyFlush all current items.
This should create and flush all remaining clusters and entries.
pyzim.compressionstrategy.MimetypeBasedCompressionStrategy, pyzim.compressionstrategy.SimpleCompressionStrategyTrue if this compression strategy still has items to be written.
| Returns | |
bool | whether there are some items that still need to be written |