wiz.package¶
-
wiz.package.extract(requirement, definition_mapping, namespace_counter=None)[source]¶ Extract list of
Packageinstances from requirement.The best matching
Definitionversion instances corresponding to the requirement will be used.If this definition contains variants, a
Packageinstance will be returned for each combined variant.Parameters: - requirement – Instance of
packaging.requirements.Requirement. - definition_mapping – Mapping regrouping all available definitions associated with their unique identifier.
- namespace_counter – instance of
collections.Counterwhich indicates occurrence of namespaces used as hints for package identification. Default is None.
Returns: List of
Packageinstances.- requirement – Instance of
-
wiz.package.extract_context(packages, environ_mapping=None)[source]¶ Return combined mapping extracted from packages.
Example:
>>> extract_context(packages) { "command": { "app": "AppExe" ... }, "environ": { "KEY1": "value1", "KEY2": "value2", ... }, }
Parameters: - packages – List of
Packageinstances. it should be ordered from the less important to the most important so that the later are prioritized over the first. - environ_mapping – Mapping of environment variables which would be augmented. Default is None.
Returns: Context mapping.
- packages – List of
-
wiz.package.combine_environ_mapping(package_identifier, mapping1, mapping2)[source]¶ Return combined environ mapping from mapping1 and mapping2.
Each variable name from both mappings will be combined into a final value. If a variable is only contained in one of the mapping, its value will be kept in the combined mapping.
If the variable exists in both mappings, the value from mapping2 must reference the variable name for the value from mapping1 to be included in the combined mapping:
>>> combine_environ_mapping( ... "combined_package", ... {"key": "value2"}, ... {"key": "value1:${key}"} ... ) {"key": "value1:value2"}
Otherwise the value from mapping2 will override the value from mapping1:
>>> combine_environ_mapping( ... "combined_package", ... {"key": "value2"}, ... {"key": "value1"} ... ) warning: The 'key' variable is being overridden in 'combined_package'. {"key": "value1"}
If other variables from mapping1 are referenced in the value fetched from mapping2, they will be replaced as well:
>>> combine_environ_mapping( ... "combined_package", ... {"PLUGIN": "/path/to/settings", "HOME": "/usr/people/me"}, ... {"PLUGIN": "${HOME}/.app:${PLUGIN}"} ... ) { "HOME": "/usr/people/me", "PLUGIN": "/usr/people/me/.app:/path/to/settings" }
Parameters: - package_identifier – Identifier of the combined package. It will be used to indicate whether any variable is overridden in the combination process.
- mapping1 – Mapping containing environment variables.
- mapping2 – Mapping containing environment variables.
Returns: Combined environment mapping.
Warning
This process will stringify all variable values.
-
wiz.package.combine_command_mapping(package_identifier, mapping1, mapping2)[source]¶ Return combined command mapping from package1 and package2.
If the command exists in both mappings, the value from mapping2 will have priority over elements from mapping1:
>>> combine_command_mapping( ... "combined_package", ... {"app": "App1.1 --run"}, ... {"app": "App2.1"} ... ) {"app": "App2.1"}
Parameters: - package_identifier – Identifier of the combined package. It will be used to indicate whether any variable is overridden in the combination process.
- mapping1 – Mapping containing command aliased.
- mapping2 – Mapping containing command aliased.
Returns: Combined command alias mapping.
-
wiz.package.create(definition, variant_identifier=None)[source]¶ Create and return a package from definition.
Parameters: - definition – Instance of
wiz.definition.Definition. - variant_identifier – Unique identifier of variant in definition to create package from.
Returns: Instance of
Package.Raise: wiz.exception.RequestNotFoundif variant_identifier is not a valid variant identifier of definition.- definition – Instance of
-
class
wiz.package.Package(definition, variant_index=None)[source]¶ Package object.
-
__init__(definition, variant_index=None)[source]¶ Initialize package.
Parameters: - definition – Instance of
wiz.definition.Definition. - variant_index – Index number of the variant which will be used to create package instance if applicable. Default is None.
Raise: wiz.exception.PackageErrorif the variant index is missing or incorrect.- definition – Instance of
-
definition¶ Return definition used to create package.
Returns: Instance of wiz.definition.Definition.
-
identifier¶ Return package identifier.
Returns: String value (e.g. “namespace::foo[variant1]==0.1.0”). Note
The value is cached when accessed once to ensure faster access afterwards.
-
variant¶ Return variant instance if applicable.
Returns: Instance of wiz.definition.Variantor None.
-
variant_identifier¶ Return variant identifier if applicable.
Returns: String value (e.g. “variant1”) or None.
-
version¶ Return package version.
Returns: Instance of packaging.version.Versionor None.
-
description¶ Return package description.
Returns: String value or None.
-
namespace¶ Return package namespace.
Returns: String value or None.
-
install_location¶ Return installation path.
If a variant is used and if it defines an installation path, this value is returned. Otherwise, the installation path value from the initial definition is returned.
Returns: Directory path or None.
-
environ¶ Return environment variable mapping.
If a variant is used and if it defines an environment variable mapping, this value is
combinedwith the environment variable mapping defined in the initial definition.Returns: Dictionary value. Note
The value is cached when accessed once to ensure faster access afterwards.
-
command¶ Return command mapping.
If a variant is used and if it defines a command mapping, this value is
combinedwith the command mapping defined in the initial definition.Returns: Dictionary value. Note
The value is cached when accessed once to ensure faster access afterwards.
-
requirements¶ Return list of requirements.
If a variant is used and if it defines a list of requirements, this value is added to the requirement list defined in the initial definition.
Returns: List of packaging.requirements.Requirementinstances.Note
The value is cached when accessed once to ensure faster access afterwards.
-
conditions¶ Return list of conditions.
Returns: List of packaging.requirements.Requirementinstances.
-
conditions_processed¶ Indicate whether the package conditions have been processed.
Returns: Boolean value.
-
localized_environ()[source]¶ Return localized environ mapping.
The
INSTALL_ROOTandINSTALL_LOCATIONvalues within the environment variable mapping will be replaced respectfully by the values of the install-root and install-location keywords.Returns: Dictionary value.
-