...
 
Commits (3)
......@@ -54,7 +54,7 @@ It provides a Python interface to read and create XML files of
It also implements all methods inherited from :class:`~momotor.bundles.Bundle`
.. autoclass:: momotor.bundles.ProductBundle
:members: create, id, options, get_options, get_option_value, files, copy_files
:members: create, id, options, get_options, get_option_value, files, copy_files, get_properties, get_property_value
:class:`~momotor.bundles.RecipeBundle`
--------------------------------------
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,11 +10,12 @@ from momotor.bundles.const import BundleCategory
from momotor.bundles.elements.base import IdMixin
from momotor.bundles.elements.files import File, FilesMixin
from momotor.bundles.elements.options import Option, OptionsMixin
from momotor.bundles.elements.properties import Property, PropertiesMixin
__all__ = ['ProductBundle']
class ProductBundle(Bundle, IdMixin, OptionsMixin, FilesMixin):
class ProductBundle(Bundle, IdMixin, OptionsMixin, FilesMixin, PropertiesMixin):
""" A product bundle. This implements the interface to create and access Momotor product files
"""
def __init__(self, base: typing.Union[str, pathlib.Path] = None, zip_file: zipfile.ZipFile = None):
......@@ -22,12 +23,14 @@ class ProductBundle(Bundle, IdMixin, OptionsMixin, FilesMixin):
IdMixin.__init__(self)
OptionsMixin.__init__(self)
FilesMixin.__init__(self)
PropertiesMixin.__init__(self)
# noinspection PyShadowingBuiltins
def create(self, *,
id: str = None,
options: typing.List[Option] = None,
files: typing.List[File] = None) -> "ProductBundle":
files: typing.List[File] = None,
properties: typing.List[Property] = None) -> "ProductBundle":
""" Set all attributes for this ProductBundle
Usage:
......@@ -39,12 +42,14 @@ class ProductBundle(Bundle, IdMixin, OptionsMixin, FilesMixin):
:param id: `id` of the bundle (optional)
:param options: list of options (optional)
:param files: list of files (optional)
:param properties: list of properties (optional)
:return: self
"""
# TODO meta
self.id = id
self.options = options
self.files = files
self.properties = properties
return self
def recreate(self, target_bundle: "momotor.bundles.Bundle", target_basesrc: PurePosixPath = None) \
......@@ -59,7 +64,8 @@ class ProductBundle(Bundle, IdMixin, OptionsMixin, FilesMixin):
return self.create(
id=node.id,
options=self._collect_options(node, []),
files=self._collect_files(node, [])
files=self._collect_files(node, []),
properties=self._collect_properties(node),
)
def _construct_node(self) -> productComplexType:
......@@ -67,6 +73,7 @@ class ProductBundle(Bundle, IdMixin, OptionsMixin, FilesMixin):
id=self.id,
options=self._construct_options_nodes(self.options),
files=self._construct_files_nodes(self.files),
properties=self._construct_properties_nodes(self.properties),
)
@staticmethod
......
......@@ -185,6 +185,7 @@
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="meta" type="metaComplexType"/>
<xs:element name="options" type="optionsComplexType"/>
<xs:element name="properties" type="propertiesComplexType"/>
<xs:element name="files" type="filesComplexType"/>
</xs:choice>
<xs:attribute use="optional" name="id" type="xs:ID"/>
......