Elements¶
Element
¶
- class momotor.bundles.elements.base.Element(bundle)¶
Abstract base class for all elements of a
Bundle
- create(**kwargs)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- recreate(target_bundle, **kwargs)¶
Recreate this element in a target bundle
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- bundle: Final[momotor.bundles.base.Bundle]¶
The
Bundle
containing this element
Checklet
¶
- class momotor.bundles.elements.checklets.Checklet(bundle)¶
A Checklet element encapsulating
checkletComplexType
- create(name=None, extras=None, version=None, entrypoint=None, repository=None, link=None, indices=None, package_versions=None, resources=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- get_dist_name()¶
Return a distribution selector (ie. name, extras and version in a single string)
eg: “name[extra1,extra2]==1.0”
- Return type
- static get_node_type()¶
Get the xsData node type
- Return type
- get_resources()¶
Get the resources as a dictionary name -> Resource
- Return type
- recreate(target_bundle)¶
Recreate this element in a target bundle
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- property extras: Optional[momotor.bundles.utils.filters.FilterableTuple[str]]¶
extras attribute: The Python package extras (eg. “requests”)
- Return type
- property indices: Optional[List[momotor.bundles.elements.checklets.Link]]¶
indices attribute: (unused, untested)
- property link: Optional[momotor.bundles.elements.checklets.Link]¶
link attribute: (unused, untested)
- property name: Optional[momotor.bundles.mixins.name.NTG]¶
The name attribute
- property package_versions: Optional[momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.checklets.PackageVersion]]¶
package_versions attribute: (unused, untested)
- Return type
- property repository: Optional[momotor.bundles.elements.checklets.Repository]¶
repository attribute: where to retrieve the package from
- Return type
- property resources: momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.resources.Resource]¶
resources attribute
- Return type
Depends
¶
- class momotor.bundles.elements.steps.Depends(bundle)¶
A Depends element encapsulating
DependsComplexType
- create(*, step)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- static get_node_type()¶
Get the xsData node type
- Return type
- recreate(target_bundle)¶
Recreate this element in a target bundle
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
File
¶
- class momotor.bundles.elements.files.File(bundle)¶
A File element encapsulating
fileComplexType
- copy_to(destination, *, name=None, executable_attribute=False)¶
Copy attachment to given directory
If attachment is a file, creates a new file in the given directory. If name is provided this will be the name of the new file, otherwise the name of the source file is used.
If attachment is a directory, copies the contents of the source directory to the destination directory. If name is provided it is created as a new directory inside the destination directory.
Will not overwrite an existing file or directory.
- Parameters
- Raises
ValueError – when the attachment is not writeable as a file
FileExistsError – when a file already exists
- Return type
- create(*, class_=None, name=None, src=None, content=<object object>, type=None, executable=False, attrs=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- file_ctime(path=None)¶
Get file creation time for the attachment.
Returns None if content is unsizeable or not found
- Return type
- file_hashes(hash_names)¶
Calculate the hashes of the file.
Only for file attachments. Will return an empty dictionary if the file does not exist.
- file_size(path=None)¶
Get file size for the content.
- static get_node_type()¶
Get the xsData node type
- Return type
- has_inline_content()¶
Returns True if element has inline content, without processing the content
- Return type
- has_inline_text_content()¶
Returns True if self.value would return text content (either bytes or str), without converting the content.
- Return type
- has_writable_content()¶
- iterdir()¶
Recursively iterate the contents of a directory attachment. The returned paths are relative to self.absolute_path
- Return type
- open(path=None)¶
Open the attachment file for reading. Handles opening files directly from filesystem and from zipped bundles
- Parameters
path (
Union
[str
,PurePosixPath
,None
]) – for directory attachments, path selects a file in that directory- Return type
- Returns
the opened file
- Raises
FileNotFoundError – if the element has no attachment (when src is None), or when it’s a directory and path does not exist in that directory
- read(path=None)¶
Read the contents of the attachment
- Parameters
path (
Union
[str
,PurePosixPath
,None
]) – for directory attachments, path selects a file in that directory- Return type
- Returns
A bytes object with the full file contents
- recreate(target_bundle, *, class_=None, name=None)¶
Recreate this File in a target bundle, optionally changing the class_ or name.
If the node has a src attachment, the target bundle will link to the same file, the file will not be copied.
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- validate_hashes(expected_hashes)¶
Validate hash values of the file.
Only for file attachments
- VALID_PROCESSED_TYPES: ClassVar = (<class 'str'>, <class 'bool'>, <class 'bytes'>, <class 'int'>, <class 'float'>, <class 'decimal.Decimal'>)¶
- property absolute_path: pathlib.Path¶
- Return type
- property attrs: momotor.bundles.utils.immutable.ImmutableOrderedDict[str, str]¶
Wildcard attributes
- Return type
- property encoding: Optional[str]¶
encoding attribute: read-only, the encoding is automatically determined from the value
- property export_src: Optional[pathlib.PurePosixPath]¶
- Return type
- property name: Optional[momotor.bundles.mixins.name.NTG]¶
The name attribute
- property src: Optional[pathlib.PurePath]¶
src attribute: file path of the content.
An absolute path (Path object) when referencing a standalone file, or a relative path (PurePosixPath object) when referencing a file in a bundle
- property src_bundle: Optional[momotor.bundles.base.Bundle]¶
The bundle src references to if it’s a relative path
- property value: momotor.bundles.elements.content.PT¶
value attribute: The content.
Setting value to None will generate a node with a <none/> tag. Set value to NO_CONTENT to create an empty content node.
Raises
NoContent
(a subclass of ValueError) if no content was set instead of returning NO_CONTENT, RaisesFileContent
(also a subclass of ValueError’) if the node refers to an external file.
Option
¶
- class momotor.bundles.elements.options.Option(bundle)¶
An Option element encapsulating
OptionComplexType
- create(*, name, domain=None, value=None, type=None, description=None, attrs=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- static get_node_type()¶
Get the xsData node type
- Return type
- has_inline_content()¶
Returns True if element has inline content, without processing the content
- Return type
- has_inline_text_content()¶
Returns True if self.value would return text content (either bytes or str), without converting the content.
- Return type
- recreate(target_bundle, *, name=None, domain=None)¶
Recreate this Option in a target bundle, optionally changing the name or domain.
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- VALID_PROCESSED_TYPES: ClassVar = (<class 'str'>, <class 'bool'>, <class 'bytes'>, <class 'int'>, <class 'float'>, <class 'decimal.Decimal'>)¶
- property attrs: momotor.bundles.utils.immutable.ImmutableOrderedDict[str, str]¶
Wildcard attributes
- Return type
- property domain_parts: Tuple[str, Optional[str]]¶
A tuple with the two parts of the
domain
.If
domain
equals <main>#<sub> this is (<main>, <sub>). Ifdomain
does not contain a#
, it equals (<domain>, None).
- property encoding: Optional[str]¶
encoding attribute: read-only, the encoding is automatically determined from the value
- property name: Optional[momotor.bundles.mixins.name.NTG]¶
The name attribute
- property type: Optional[str]¶
The type attribute. Indicates the type of the value attribute: string, integer or float
- property value: momotor.bundles.elements.content.PT¶
value attribute: The content.
Setting value to None will generate a node with a <none/> tag. Set value to NO_CONTENT to create an empty content node.
Raises
NoContent
(a subclass of ValueError) if no content was set instead of returning NO_CONTENT, RaisesFileContent
(also a subclass of ValueError’) if the node refers to an external file.
Property
¶
- class momotor.bundles.elements.properties.Property(bundle)¶
A Property element encapsulating
PropertyComplexType
- create(*, name, value=None, type=None, accept=None, attrs=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- static get_node_type()¶
Get the xsData node type
- Return type
- has_inline_content()¶
Returns True if element has inline content, without processing the content
- Return type
- has_inline_text_content()¶
Returns True if self.value would return text content (either bytes or str), without converting the content.
- Return type
- recreate(target_bundle, *, name=None)¶
Recreate this Property in a target bundle, optionally changing the name.
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- VALID_PROCESSED_TYPES: ClassVar = (<class 'str'>, <class 'bool'>, <class 'bytes'>, <class 'int'>, <class 'float'>, <class 'decimal.Decimal'>)¶
- property attrs: momotor.bundles.utils.immutable.ImmutableOrderedDict[str, str]¶
Wildcard attributes
- Return type
- property encoding: Optional[str]¶
encoding attribute: read-only, the encoding is automatically determined from the value
- property name: Optional[momotor.bundles.mixins.name.NTG]¶
The name attribute
- property type: Optional[str]¶
The type attribute. Indicates the type of the value attribute: string, integer or float
- property value: momotor.bundles.elements.content.PT¶
value attribute: The content.
Setting value to None will generate a node with a <none/> tag. Set value to NO_CONTENT to create an empty content node.
Raises
NoContent
(a subclass of ValueError) if no content was set instead of returning NO_CONTENT, RaisesFileContent
(also a subclass of ValueError’) if the node refers to an external file.
Resource
¶
- class momotor.bundles.elements.resources.Resource(bundle)¶
A Resource element encapsulating
ResourceComplexType
- create(*, name, value=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- static get_node_type()¶
Get the xsData node type
- Return type
- has_inline_content()¶
Returns True if element has inline content, without processing the content
- Return type
- has_inline_text_content()¶
Returns True if self.value would return text content (either bytes or str), without converting the content.
- Return type
- recreate(target_bundle, *, name=None)¶
Recreate this Resource in a target bundle, optionally changing the name.
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- VALID_PROCESSED_TYPES: ClassVar = (<class 'str'>, <class 'bool'>)¶
- property name: Optional[momotor.bundles.mixins.name.NTG]¶
The name attribute
- property value: momotor.bundles.elements.content.PT¶
value attribute: The content.
Setting value to None will generate a node with a <none/> tag. Set value to NO_CONTENT to create an empty content node.
Raises
NoContent
(a subclass of ValueError) if no content was set instead of returning NO_CONTENT, RaisesFileContent
(also a subclass of ValueError’) if the node refers to an external file.
Result
¶
- class momotor.bundles.elements.result.Result(bundle)¶
A Result element encapsulating
ResultComplexType
- copy_files_to(destination, *, files=None)¶
Copy files to a directory
- create(*, step_id, outcome, checklet=None, properties=None, options=None, files=None, parent_id=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- static get_node_type()¶
Get the xsData node type
- Return type
- get_option_value(name, *, domain='checklet', default=<object object>)¶
Get the value for a single option. If multiple options match, the value of the first one found will be returned
- get_options(name, *, domain='checklet')¶
Get options
- Parameters
- Return type
- Returns
A filterable tuple of all matching options.
- get_properties(name)¶
Get properties
- Parameters
name (
str
) – name of the properties to get- Return type
- Returns
A list of all matching properties.
- get_property_value(name, *, default=<object object>)¶
Get the value for a single property. If multiple properties match, the value of the first one found will be returned
- recreate(target_bundle, *, step_id=None)¶
Recreate this Result in a target bundle, optionally changing the step_id.
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- set_parent_id(parent_id)¶
Set the id of the result parent
- property checklet: Optional[momotor.bundles.elements.checklets.Checklet]¶
checklet
- property files: momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.files.File]¶
files children
- Return type
- property options: momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.options.Option]¶
options children
- Return type
- property outcome: Literal['pass', 'fail', 'skip', 'error']¶
outcome attribute as string value. Valid values are
pass
,fail
,skip
anderror
- Return type
Literal
[‘pass’, ‘fail’, ‘skip’, ‘error’]
- property outcome_enum: momotor.bundles.elements.result.Outcome¶
outcome attribute as an
Outcome
enum- Return type
- property properties: momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.properties.Property]¶
properties children
- Return type
Results
¶
- class momotor.bundles.elements.results.Results(bundle)¶
A Results element encapsulating
ResultsComplexType
- create(*, id=None, results=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- static get_node_type()¶
Get the xsData node type
- Return type
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- property results: momotor.bundles.elements.results.ResultKeyedTuple¶
results children
- Return type
- class momotor.bundles.elements.results.ResultKeyedTuple(results=None)¶
The results as a
KeyedTuple
ofResult
objects.The KeyedTuple allows access as a tuple or a mapping. Results are indexed by their step_id attribute
Step
¶
- class momotor.bundles.elements.steps.Step(bundle)¶
A Step element encapsulating
StepComplexType
- copy_files_to(destination, *, files=None)¶
Copy files to a directory
- create(*, id, priority='default', depends=None, checklet=None, options=None, files=None, resources=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- static get_node_type()¶
Get the xsData node type
- Return type
- get_option_value(name, *, domain='checklet', default=<object object>)¶
Get the value for a single option. If multiple options match, the value of the first one found will be returned
- get_options(name, *, domain='checklet')¶
Get options
- Parameters
- Return type
- Returns
A filterable tuple of all matching options.
- get_resources()¶
get all resources needed by this step
- Return type
- classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)¶
Recreate a list of elements
- Parameters
elements (
Optional
[Iterator
[TypeVar
(ET
, bound=Element
)]]) – List of elements to recreate (can be None)target_bundle (
Bundle
) – The target bundlefilter (
Optional
[Callable
[[TypeVar
(ET
, bound=Element
)],bool
]]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a booleankwargs – Additional keyword arguments are passed on to
recreate()
- Return type
- Returns
a list of elements or None if elements param was None
- property checklet: Optional[momotor.bundles.elements.checklets.Checklet]¶
checklet
- property depends: Optional[momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.steps.Depends]]¶
depends
- Return type
- property files: momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.files.File]¶
files children
- Return type
- property options: momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.options.Option]¶
options children
- Return type
- property priority_value: momotor.bundles.elements.steps.Priority¶
priority attribute as
Priority
instance- Return type
- property resources: momotor.bundles.utils.filters.FilterableTuple[momotor.bundles.elements.resources.Resource]¶
resources attribute
- Return type
Types¶
- class momotor.bundles.elements.checklets.Link(src)¶
An immutable dataclass for a reference to a link
- class momotor.bundles.elements.checklets.PackageVersion(name, version)¶
An immutable dataclass for a reference to a package with version
- class momotor.bundles.elements.checklets.Repository(bundle)¶
- create(src, type, revision=None)¶
Set this element’s attributes
Usage:
element = Element(bundle).create(...)
- recreate(target_bundle)¶
Recreate this Repository in a target bundle.
The target bundle will link to the same attachment in src, the attachment will not be copied.
- class momotor.bundles.elements.result.Outcome(value)¶
An enum for the
Result.outcome
. MirrorsOutcomeSimpleType
- classmethod condition(state)¶
Get outcome based on a condition
- Return type
TypeVar
(OT
)- Returns
returns
Outcome.PASS
if state is truthy, otherwise returnsOutcome.FAIL
- classmethod from_simpletype(st)¶
Create an
Outcome
from anOutcomeSimpleType
- Return type
TypeVar
(OT
)
- to_simpletype()¶
Convert into an
OutcomeSimpleType
- Return type
- ERROR = 'error'¶
- FAIL = 'fail'¶
- PASS = 'pass'¶
- SKIP = 'skip'¶