mozpack.packager package¶
Submodules¶
mozpack.packager.formats module¶
- class mozpack.packager.formats.FlatFormatter(copier)¶
Bases:
mozpack.packager.formats.PiecemealFormatter
Formatter for the flat package format.
- class mozpack.packager.formats.FlatSubFormatter(copier)¶
Bases:
object
Sub-formatter for the flat package format.
- add(path, content)¶
- add_interfaces(path, content)¶
- add_manifest(entry)¶
- contains(path)¶
- class mozpack.packager.formats.JarFormatter(copier, compress=True)¶
Bases:
mozpack.packager.formats.PiecemealFormatter
Formatter for the jar package format. Assumes manifest entries related to chrome are registered before the chrome data files are added. Also assumes manifest entries for resources are registered after chrome manifest entries.
- class mozpack.packager.formats.JarSubFormatter(copier, compress=True)¶
Bases:
mozpack.packager.formats.PiecemealFormatter
Sub-formatter for the jar package format. It is a PiecemealFormatter that dispatches between further sub-formatter for each of the jar files it dispatches the chrome data to, and a FlatSubFormatter for the non-chrome files.
- add_manifest(entry)¶
- class mozpack.packager.formats.OmniJarFormatter(copier, omnijar_name, compress=True, non_resources=())¶
Bases:
mozpack.packager.formats.JarFormatter
Formatter for the omnijar package format.
- class mozpack.packager.formats.OmniJarSubFormatter(copier, omnijar_name, compress=True, non_resources=())¶
Bases:
mozpack.packager.formats.PiecemealFormatter
Sub-formatter for the omnijar package format. It is a PiecemealFormatter that dispatches between a FlatSubFormatter for the resources data and another FlatSubFormatter for the other files.
- add_manifest(entry)¶
- is_resource(path)¶
Return whether the given path corresponds to a resource to be put in an omnijar archive.
mozpack.packager.l10n module¶
- mozpack.packager.l10n.FlatFormatter¶
alias of
mozpack.packager.l10n.L10NRepackFormatter.<locals>.L10NRepackFormatter
- mozpack.packager.l10n.JarFormatter¶
alias of
mozpack.packager.l10n.L10NRepackFormatter.<locals>.L10NRepackFormatter
- mozpack.packager.l10n.L10NRepackFormatter(klass)¶
- class mozpack.packager.l10n.L10NRepackFormatterMixin(*args, **kwargs)¶
Bases:
object
- add(path, file)¶
- class mozpack.packager.l10n.LocaleManifestFinder(finder)¶
Bases:
object
- mozpack.packager.l10n.OmniJarFormatter¶
alias of
mozpack.packager.l10n.L10NRepackFormatter.<locals>.L10NRepackFormatter
- mozpack.packager.l10n.repack(source, l10n, extra_l10n={}, non_resources=[], non_chrome={})¶
Replace localized data from the source directory with localized data from l10n and extra_l10n.
The source argument points to a directory containing a packaged application (in omnijar, jar or flat form). The l10n argument points to a directory containing the main localized data (usually in the form of a language pack addon) to use to replace in the packaged application. The extra_l10n argument contains a dict associating relative paths in the source to separate directories containing localized data for them. This can be used to point at different language pack addons for different parts of the package application. The non_resources argument gives a list of relative paths in the source that should not be added in an omnijar in case the packaged application is in that format. The non_chrome argument gives a list of file/directory patterns for localized files that are not listed in a chrome.manifest.
mozpack.packager.unpack module¶
- class mozpack.packager.unpack.UnpackFinder(source, omnijar_name=None, unpack_xpi=True)¶
Bases:
mozpack.files.BaseFinder
Special Finder object that treats the source package directory as if it were in the flat chrome format, whatever chrome format it actually is in.
This means that for example, paths like chrome/browser/content/… match files under jar:chrome/browser.jar!/content/… in case of jar chrome format.
The only argument to the constructor is a Finder instance or a path. The UnpackFinder is populated with files from this Finder instance, or with files from a FileFinder using the given path as its root.
- find(path)¶
Yield path, BaseFile_instance pairs for all files under the base directory and its subdirectories that match the given pattern. See the mozpack.path.match documentation for a description of the handled patterns.
- mozpack.packager.unpack.unpack(source, omnijar_name=None)¶
Transform a jar chrome or omnijar packaged directory into a flat package.
- mozpack.packager.unpack.unpack_to_registry(source, registry, omnijar_name=None)¶
Transform a jar chrome or omnijar packaged directory into a flat package.
The given registry is filled with the flat package.
Module contents¶
- class mozpack.packager.CallDeque¶
Bases:
collections.deque
Queue of function calls to make.
- append(function, *args)¶
Add an element to the right side of the deque.
- execute()¶
- class mozpack.packager.Component(name, destdir='')¶
Bases:
object
Class that represents a component in a package manifest.
- KEY_VALUE_RE = re.compile('\n \\s* # optional whitespace.\n ([a-zA-Z0-9_]+) # key.\n \\s*=\\s* # optional space around =.\n "([^"]*)" # value without surrou, re.VERBOSE)¶
- property destdir¶
- static from_string(string)¶
Create a component from a string.
- property name¶
- class mozpack.packager.PackageManifestParser(sink)¶
Bases:
object
Class for parsing of a package manifest, after preprocessing.
- A package manifest is a list of file paths, with some syntaxic sugar:
[] designates a toplevel component. Example: [xpcom] - in front of a file specifies it to be removed * wildcard support ** expands to all files and zero or more directories ; file comment
The parser takes input from the preprocessor line by line, and pushes parsed information to a sink object.
The add and remove methods of the sink object are called with the current Component instance and a path.
- handle_line(str)¶
Handle a line of input and push the parsed information to the sink object.
- class mozpack.packager.PreprocessorOutputWrapper(preprocessor, parser)¶
Bases:
object
File-like helper to handle the preprocessor output and send it to a parser. The parser’s handle_line method is called in the relevant errors.context.
- write(str)¶
- class mozpack.packager.SimpleManifestSink(finder, formatter)¶
Bases:
object
Parser sink for “simple” package manifests. Simple package manifests use the format described in the PackageManifestParser documentation, but don’t support file removals, and require manifests, interfaces and chrome data to be explicitely listed. Entries starting with bin/ are searched under bin/ in the FileFinder, but are packaged without the bin/ prefix.
- add(component, pattern)¶
Add files with the given pattern in the given component.
- close(auto_root_manifest=True)¶
Add possibly missing bits and push all instructions to the formatter.
- static normalize_path(path)¶
Remove any bin/ prefix.
- remove(component, pattern)¶
Remove files with the given pattern in the given component.
- class mozpack.packager.SimplePackager(formatter)¶
Bases:
object
Helper used to translate and buffer instructions from the SimpleManifestSink to a formatter. Formatters expect some information to be given first that the simple manifest contents can’t guarantee before the end of the input.
- UNPACK_ADDON_RE = re.compile('(?:\n <em:unpack>true</em:unpack>\n |em:unpack=(?P<quote>["\']?)true(?P=quote)\n )', re.VERBOSE)¶
- add(path, file)¶
Add the given BaseFile instance with the given path.
- close()¶
Push all instructions to the formatter.
- get_bases(addons=True)¶
Return all paths under which root manifests have been found. Root manifests are manifests that are included in no other manifest. addons indicates whether to include addon bases as well.
- mozpack.packager.preprocess(input, parser, defines={})¶
Preprocess the file-like input with the given defines, and send the preprocessed output line by line to the given parser.
- mozpack.packager.preprocess_manifest(sink, manifest, defines={})¶
Preprocess the given file-like manifest with the given defines, and push the parsed information to a sink. See PackageManifestParser documentation for more details on the sink.