class documentation

class OperationBuffer(object):

Constructor: OperationBuffer(zim)

View In Hierarchy

The OperationBuffer is responsible for buffering ZIM write operations until they can be completed.

Due to the way compression works, it is possible that some operations like pyzim.archive.Zim.add_full_url_redirect can only be completed after a new cluster has been written. As force-flushing the compression strategy every time this happens would lead to potentially suboptimal compression, we have to buffer these operations until they can be completed. This class is responsible for this.

Method __init__ The default constructor.
Method buffer_add_redirect Buffer an add_redirect operation.
Method buffer_set_mainpage_url Buffer a set_mainpage_url operation.
Method finalize_entry_dependent_operations Finalize all operations that require other entries to be written first.
Instance Variable zim ZIM archiveto buffer operations for
Method _apply_redirects Apply previously buffered add_redirect operations.
Method _apply_set_mainpage_url Apply any previously buffered set_mainpage_url operation.
Instance Variable _buffered_mainpage_url the buffered value for the next mainpage url setting (or False if none buffered)
Instance Variable _buffered_redirects a list of (source full url, target full url, title) of redirects that need yet to be written
def __init__(self, zim):

The default constructor.

Parameters
zim:pyzim.archive.ZimZIM archiveto buffer operations for
def buffer_add_redirect(self, source, target, title=None):

Buffer an add_redirect operation.

Parameters
source:strsource full url of the redirect
target:strtarget full url of the redirect
title:str or Nonetitle of redirect to add
def buffer_set_mainpage_url(self, url):

Buffer a set_mainpage_url operation.

See pyzim.archive.Zim.set_mainpage_url for details.

Any such previously buffered operations are replaced.

Parameters
url:str or Nonenon-full url of mainpage to set (or None to disable mainapge)
def finalize_entry_dependent_operations(self):

Finalize all operations that require other entries to be written first.

NOTE: currently, access to the title pointer list entries is not available.

Raises
pyzim.exceptions.UnresolvedRedirectwhen a redirect target could not be resolved

ZIM archiveto buffer operations for

def _apply_redirects(self):

Apply previously buffered add_redirect operations.

Raises
pyzim.exceptions.UnresolvedRedirectwhen a redirect target can not be resolved
def _apply_set_mainpage_url(self):

Apply any previously buffered set_mainpage_url operation.

Raises
pyzim.exceptions.UnresolvedRedirectIf the redirect for the mainpage can not be resolved.
_buffered_mainpage_url: str or None or False =

the buffered value for the next mainpage url setting (or False if none buffered)

_buffered_redirects: list of tuple of (str, str, str or None) =

a list of (source full url, target full url, title) of redirects that need yet to be written