l.t.u.m.MozillaZipTraversal : class documentation

Part of lp.translations.utilities.mozilla_zip View In Hierarchy

Known subclasses: lp.translations.utilities.mozilla_xpi_importer.MozillaZipImportParser, lp.translations.utilities.tests.test_mozilla_zip.TraversalRecorder

Traversal of an XPI file, or a jar file inside an XPI file.

To traverse and process an XPI file, derive a class from this one and replace any hooks that you may need.

If an XPI manifest is provided, traversal will be restricted to directories it lists as containing localizable resources.

Method __init__ Open zip (or XPI, or jar) file and scan its contents.
Method _processEntry Read one zip archive entry, figure out what to do with it.
Method _begin Overridable hook: optional pre-traversal actions.
Method _processTranslatableFile Overridable hook: process a file entry.
Method _processNestedJar Overridable hook: handle a nested jar file.
Method _finish Overridable hook: post-traversal actions.
def __init__(self, filename, archive, xpi_path=None, manifest=None):
Open zip (or XPI, or jar) file and scan its contents.
ParametersfilenameName of this zip (XPI/jar) archive.
archiveFile-like object containing this zip archive.
xpi_pathFull path of this file inside the XPI archive. Leave out for the XPI archive itself.
manifestXpiManifest representing the XPI archive's manifest file, if any.
def _processEntry(self, entry, xpi_path):
Read one zip archive entry, figure out what to do with it.
def _begin(self):
Overridable hook: optional pre-traversal actions.
def _processTranslatableFile(self, entry, locale_code, xpi_path, chrome_path, filename_suffix):
Overridable hook: process a file entry.

Called only for files that may be localizable. If there is a manifest, that means the file must be in a location (or subtree) named by a "locale" entry.

ParametersentryFull name of file inside this zip archive, including path relative to the archive's root.
locale_codeCode for locale this file belongs to, e.g. "en-US".
xpi_pathFull path of this file inside the XPI archive, e.g. "jar:locale/en-US.jar!/data/messages.dtd".
chrome_pathFile's chrome path. This is a kind of "normalized" path used in XPI to describe a virtual directory hierarchy. The zip archive's actual layout (which the XPI paths describe) may be different.
filename_suffixFile name suffix or "extension" of the translatable file. This may be e.g. ".dtd" or ".xhtml," or the empty string if the filename does not contain a dot.
def _processNestedJar(self, zip_instance):
Overridable hook: handle a nested jar file.
Parameterszip_instanceAn instance of the same class as self, which has just parsed the nested jar file.
def _finish(self):
Overridable hook: post-traversal actions.
API Documentation for Launchpad, generated by pydoctor at 2018-08-19 00:00:03.