class documentation

A compression strategy utilizing mimetypes.

Method __init__ The default constructor.
Method add_item Handle the addition of an item (e.g. create entries, ...).
Method flush Flush all current items.
Method has_items True if this compression strategy still has items to be written.
Instance Variable cs_class compression strategy to use for each mimetype
Instance Variable cs_kwargs kwargs to pass to each new instance of cs_class (ignoring "zim")
Instance Variable mimetype2cs a dict mapping mimetype -> compression strategy
Method _get_cs Get the compression strategy for the specified mimetype.
Instance Variable _lock thread safety lock

Inherited from BaseCompressionStrategy:

Instance Variable zim zim archive this compression strategy compresses for
def __init__(self, zim, cs_class=SimpleCompressionStrategy, cs_kwargs={}):

The default constructor.

Parameters
zim:pyzim.archive.Zimzim archive this compression strategy compresses for
cs_class:a subclass of BaseCompressionStrategycompression strategy to use for each mimetype
cs_kwargs:dictkwargs to pass to each new instance of cs_class
def add_item(self, item):

Handle the addition of an item (e.g. create entries, ...).

Parameters
item:pyzim.item.Itemitem to add
def flush(self):

Flush all current items.

This should create and flush all remaining clusters and entries.

def has_items(self):

True if this compression strategy still has items to be written.

Returns
boolwhether there are some items that still need to be written
cs_class: a subclass of BaseCompressionStrategy =

compression strategy to use for each mimetype

cs_kwargs: dict =

kwargs to pass to each new instance of cs_class (ignoring "zim")

mimetype2cs: dict of str -> BaseCompressionStrategy =

a dict mapping mimetype -> compression strategy

def _get_cs(self, mimetype):

Get the compression strategy for the specified mimetype.

Parameters
mimetype:strmimetype to get compression strategy for
Returns
BaseCompressionStrategythe compression strategy to use

thread safety lock