Elements#

The classes in this module are used to define the structure of a bundle. All these classes are immutable.

Creating a new instance of these classes is done using the create() method instead of the constructor, in the following way:

target_bundle = ...
checklet = Checklet(bundle).create(name='checklet', ...)
step = Step(bundle).create(id='step1', checklet=checklet, ...)

The recreate() and recreate_list() methods can be used to create a new instance of the class with the same attributes as the original instance, but with some of them replaced by new values.

Element base#

class momotor.bundles.elements.base.Element(bundle)#

Abstract base class for all elements of a Bundle, and Bundle itself.

Parameters:

bundle (Bundle) – The Bundle containing this element

abstract create(**kwargs)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[TypeVar(CT, bound= object)]

abstract recreate(target_bundle, **kwargs)#

Recreate this element in a target bundle

Parameters:

target_bundle (Bundle) – The target bundle

Return type:

Self

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

bundle: Final[Bundle]#

The Bundle containing this element

Checklet#

class momotor.bundles.elements.checklets.Checklet(bundle)#

A Checklet element encapsulating CheckletComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

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(...)
Return type:

Self

Returns:

self

get_dist_name()#

Return a distribution selector (ie. name, extras and version in a single string)

eg: “name[extra1,extra2]==1.0”

Return type:

str

static get_node_type()#

Get the xsData node type

Return type:

type[CheckletComplexType]

get_resources()#

Get the resources as a dictionary name -> Resource

Return type:

dict[str, FilterableTuple[Resource]]

recreate(target_bundle)#

Recreate this Checklet in a target bundle. No attributes can be changed.

Parameters:

target_bundle (Bundle) – The target bundle

Return type:

Checklet

Returns:

The newly created Checklet

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

bundle: typing.Final['momotor.bundles.Bundle']#

The Bundle containing this element

property entrypoint: str | None#

entrypoint attribute: Override the default package entrypoint

property extras: FilterableTuple[str] | None#

extras attribute: The Python package extras (eg. “requests”)

property indices: list[Link | None]#

indices attribute: (unused, untested)

link attribute: (unused, untested)

property name: NTG | None#

The name attribute

property package_versions: FilterableTuple[PackageVersion] | None#

package_versions attribute: (unused, untested)

property repository: Repository | None#

repository attribute: where to retrieve the package from

property resources: FilterableTuple[Resource]#

resources attribute

property version: str | None#

version attribute: A PEP 440 Python package version specifier (eg. “>=1.0”)

An immutable dataclass for a reference to a link

src: str#

The src of the link

class momotor.bundles.elements.checklets.PackageVersion(name, version)#

An immutable dataclass for a reference to a package with version

name: str#

The name of the package

version: str#

The version qualifier for the package

class momotor.bundles.elements.checklets.Repository(bundle)#
create(src, type_, revision=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[TypeVar(CT, bound= object)]

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. No attributes can be changed.

Parameters:

target_bundle (Bundle) – The target bundle

Return type:

Repository

Returns:

The recreated Repository

property revision: str#
property type_: str#

File#

class momotor.bundles.elements.files.File(bundle)#

A File element encapsulating FileComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

copy_to(destination, *, name=None, executable_attribute=False)#

Copy an attachment this element refers to, to given destination directory.

If the 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 the 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:
Return type:

PurePath

create(*, class_=None, name=None, src=None, content=<object object>, type_=None, executable=False, attrs=None)#

Set this file node’s attributes.

This creates an attachment for the bundle. The src or content parameters provide the content for the attachment. Only one of them can be set. When a file path is provided using src, the file must exist when the bundle is exported using one of the Bundle.to_* methods.

Note that the src parameter of this method is not directly related to the src attribute of the <file> node in the generated XML when exporting the bundle, and how the src attribute is generated is an implementation detail of this library that can change between versions. Do not rely on an attachment being exported to a specific location in a generated zip bundle.

Parameters:
  • class – The class attribute of the file node

  • name (str | PurePosixPath | None) – The name attribute of the file node

  • src (AttachmentSrc | PurePath | None) – The source of the file. See note above.

  • content (Union[str, bool, None, NewType(NoContentType, object)]) – The content of the file. Defaults to NO_CONTENT.

  • type – The type attribute of the file node

  • executable (bool) – The executable attribute of the file node

  • attrs (dict | None) – Additional attributes of the file node

Return type:

Self

file_ctime(path=None)#

Get file creation time for the attachment.

Return type:

struct_time | None

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 or is a directory.

Parameters:

hash_names (Iterable[str]) – Names of the hashes to calculate. Should be valid arguments to hashlib.new()

Return type:

dict[str, str]

Returns:

A dictionary hash-algorithm -> hash

file_size(path=None)#

Get file size for the content.

Return type:

int | None

Returns:

The file size

static get_node_type()#

Get the xsData node type

Return type:

type[FileComplexType]

has_attachment_content()#

Returns True if the element has an attachment with content

Return type:

bool

has_bundle()#

Returns True if src references a file associated with a bundle

Return type:

bool

has_inline_content()#

Returns True if element has inline content, without processing the content

Return type:

bool

has_inline_text_content()#

Returns True if value would return text content (either bytes or str), without actually converting the content.

Return type:

bool

has_text_content()#

Returns True if the element has text content, without processing the content

Return type:

bool

has_writable_content()#

Returns True if the element has an attachment with content that can be written to

has_zip_bundle()#

Returns True if src references a file associated with a zipped bundle

Return type:

bool

is_dir(path=None)#

Check if the attachment src refers to is a directory

Return type:

bool

iterdir(*, include_empty_root=False)#

Recursively iterate the contents of a directory attachment. The returned paths are relative to self.absolute_path

If the attachment is an empty directory and include_empty_root is True, a single None value is yielded

Return type:

Generator[PurePosixPath | None, None, None]

open(path=None)#

Open the attachment file for reading. Handles opening files directly from filesystem and from zipped bundles

Parameters:

path (str | PurePosixPath | None) – for directory attachments, path selects a file in that directory

Return type:

BinaryIO

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

  • IsADirectoryError – when it’s a directory

read(path=None)#

Read the contents of the attachment

Parameters:

path (str | PurePosixPath | None) – for directory attachments, path selects a file in that directory

Return type:

bytes

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.

Parameters:
  • target_bundle (Bundle) – The target bundle

  • class – New class for the file

  • name (str | PurePosixPath | None) – New name for the file

Return type:

Self

Returns:

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

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

Parameters:

expected_hashes (dict[str, str]) – A dictionary of hash-algorithm -> hash items

Return type:

bool

Returns:

True of the hashes are the expected values

HAS_ENCODING: typing.ClassVar[bool] = True#
MAX_VALUE_LENGTH: typing.ClassVar = 1000#
VALID_PROCESSED_TYPES: typing.ClassVar[tuple[type, ...]] = (<class 'str'>, <class 'bool'>, <class 'bytes'>, <class 'int'>, <class 'float'>, <class 'decimal.Decimal'>)#
property absolute_path: Path#

Get the absolute path of the attachment referenced by src

Raises:

ZippedAttachment – when the attachment is in a zipped bundle and therefor has no filesystem path

property attrs: ImmutableOrderedDict[str, str]#

Wildcard attributes

bundle: typing.Final['momotor.bundles.Bundle']#

The Bundle containing this element

property class_: str | None#

class attribute

property encoding: str | None#

encoding attribute: read-only, the encoding is automatically determined from the value

property executable: bool#

executable attribute

If this attribute is set to True, the file “Executable” mode bits (S_IXUSR, S_IXGRP and S_IXOTH) will be set when the file is copied using copy_to() with the executable_attribute parameter set to True.

property export_src: PurePosixPath | None#

The export path of the attachment, converted to be safe for use in ZIP files

property name: NTG | None#

The name attribute

property src: PurePath | None#

src attribute: file path of the content.

An absolute path (Path) when referencing a standalone file, or a relative path (PurePosixPath) when referencing a file in a bundle

property src_bundle: Bundle | None#

If src is a relative path, the Bundle src references to.

An src attribute with a relative path is always associated with a bundle, either the current bundle or another bundle from which this src was copied from using recreate(). The bundle provides the base path for the relative path.

property type_: str | None#

The type attribute.

property value: 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.

When accessing, raises NoContent if no content was set instead of returning NO_CONTENT, raises AttachmentContent if the node refers to an attachment using the src attribute instead of having inline content.

Meta#

class momotor.bundles.elements.meta.Meta(name=None, version=None, descriptions=<factory>, authors=<factory>, sources=<factory>, generators=<factory>)#

An frozen dataclass containing all meta-tag content. All fields are optional

authors: tuple[str, ...]#

a sequence of author strings.

descriptions: Sequence[Description]#

a FilterableTuple of Description elements.

generators: tuple[str, ...]#

a sequence of generator strings. indicates the tool that created the bundle

name: Optional[str] = None#

name string - only a single name value is allowed. if the bundle has multiple names, the first one is used.

sources: tuple[str, ...]#

a sequence of source strings. indicates the source of the bundle

version: Optional[str] = None#

version string - only a single version value is allowed. if the bundle has multiple versions, the first one is used.

class momotor.bundles.elements.meta.Description(bundle)#

A Description element encapsulating Description

create(*, text=None, lang=None, markup=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[TypeVar(CT, bound= object)]

recreate(target_bundle)#

Recreate this Description in a target bundle. No attributes can be changed.

Parameters:

target_bundle (Bundle) – The target bundle

Return type:

Description

Returns:

The recreated Description

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

bundle: Final[Bundle]#

The Bundle containing this element

property lang: str | None#

xml:lang attribute: language code of this description node

property markup: str | None#

markup attribute: markup of this description node, e.g. rst or text

property text: str | None#

The description text

Option#

class momotor.bundles.elements.options.Option(bundle)#

An Option element encapsulating OptionComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

create(*, name, domain=None, value=None, type_=None, description=None, attrs=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[OptionComplexType]

has_attachment_content()#

Returns True if this element has an existing attachment

Return type:

bool

has_inline_content()#

Returns True if element has inline content, without processing the content

Return type:

bool

has_inline_text_content()#

Returns True if value would return text content (either bytes or str), without actually converting the content.

Return type:

bool

has_text_content()#

Returns True if the element has text content, without processing the content

Return type:

bool

recreate(target_bundle, *, name=None, domain=None)#

Recreate this Option in a target bundle, optionally changing the name or domain. All other attributes are copied unchanged.

Parameters:
  • target_bundle (Bundle) – The target bundle

  • name (str | None) – New name for the option

  • domain (str | None) – New domain for the option

Return type:

Option

Returns:

The recreated Option

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

DEFAULT_DOMAIN: typing.ClassVar[str] = 'checklet'#
HAS_ENCODING: typing.ClassVar[bool] = True#
MAX_VALUE_LENGTH: typing.ClassVar = 1000#
VALID_PROCESSED_TYPES: typing.ClassVar[tuple[type, ...]] = (<class 'str'>, <class 'bool'>, <class 'bytes'>, <class 'int'>, <class 'float'>, <class 'decimal.Decimal'>)#
property attrs: ImmutableOrderedDict[str, str]#

Wildcard attributes

bundle: typing.Final['momotor.bundles.Bundle']#

The Bundle containing this element

property description: str | None#

description attribute

property domain: str#

domain attribute

property domain_parts: tuple[str, str | None]#

A tuple with the two parts of the domain.

If domain equals <main>#<sub> this is (<main>, <sub>). If domain does not contain a #, it equals (<domain>, None).

property encoding: str | None#

encoding attribute: read-only, the encoding is automatically determined from the value

property name: NTG | None#

The name attribute

property type_: str | None#

The type attribute. Indicates the type of the value attribute: string, integer or float

property value: 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.

When accessing, raises NoContent if no content was set instead of returning NO_CONTENT, raises AttachmentContent if the node refers to an attachment using the src attribute instead of having inline content.

Property#

class momotor.bundles.elements.properties.Property(bundle)#

A Property element encapsulating PropertyComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

create(*, name, value=None, type_=None, accept=None, attrs=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[PropertyComplexType]

has_attachment_content()#

Returns True if this element has an existing attachment

Return type:

bool

has_inline_content()#

Returns True if element has inline content, without processing the content

Return type:

bool

has_inline_text_content()#

Returns True if value would return text content (either bytes or str), without actually converting the content.

Return type:

bool

has_text_content()#

Returns True if the element has text content, without processing the content

Return type:

bool

recreate(target_bundle, *, name=None)#

Recreate this Property in a target bundle, optionally changing the name. All other attributes are copied unchanged.

Parameters:
  • target_bundle (Bundle) – The target bundle

  • name (str | None) – New name for the option

Return type:

Property

Returns:

The recreated Property

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

HAS_ENCODING: typing.ClassVar[bool] = True#
MAX_VALUE_LENGTH: typing.ClassVar = 1000#
VALID_PROCESSED_TYPES: typing.ClassVar[tuple[type, ...]] = (<class 'str'>, <class 'bool'>, <class 'bytes'>, <class 'int'>, <class 'float'>, <class 'decimal.Decimal'>)#
property accept: str | None#

accept attribute

property attrs: ImmutableOrderedDict[str, str]#

Wildcard attributes

bundle: typing.Final['momotor.bundles.Bundle']#

The Bundle containing this element

property encoding: str | None#

encoding attribute: read-only, the encoding is automatically determined from the value

property name: NTG | None#

The name attribute

property type_: str | None#

The type attribute. Indicates the type of the value attribute: string, integer or float

property value: 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.

When accessing, raises NoContent if no content was set instead of returning NO_CONTENT, raises AttachmentContent if the node refers to an attachment using the src attribute instead of having inline content.

Resource#

class momotor.bundles.elements.resources.Resource(bundle)#

A Resource element encapsulating ResourceComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

create(*, name, value=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[ResourceComplexType]

has_attachment_content()#

Returns True if this element has an existing attachment

Return type:

bool

has_inline_content()#

Returns True if element has inline content, without processing the content

Return type:

bool

has_inline_text_content()#

Returns True if value would return text content (either bytes or str), without actually converting the content.

Return type:

bool

has_text_content()#

Returns True if the element has text content, without processing the content

Return type:

bool

recreate(target_bundle, *, name=None)#

Recreate this Resource in a target bundle, optionally changing the name. All other attributes are copied unchanged.

Parameters:
  • target_bundle (Bundle) – The target bundle

  • name (str | None) – New name for the option

Return type:

Resource

Returns:

The recreated Resource

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

HAS_ENCODING: typing.ClassVar[bool] = False#
MAX_VALUE_LENGTH: typing.ClassVar = 1000#
VALID_PROCESSED_TYPES: typing.ClassVar[tuple[type, ...]] = (<class 'str'>, <class 'bool'>)#
bundle: typing.Final['momotor.bundles.Bundle']#

The Bundle containing this element

property name: NTG | None#

The name attribute

property value: 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.

When accessing, raises NoContent if no content was set instead of returning NO_CONTENT, raises AttachmentContent if the node refers to an attachment using the src attribute instead of having inline content.

Result#

class momotor.bundles.elements.result.Result(bundle)#

A Result element encapsulating ResultComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

copy_files_to(destination, *, files=None)#

Copy files attached using the files nodes to a directory

Parameters:
  • destination (Path) – destination for the files

  • files (Sequence[File] | None) – optionally a filtered list of files to copy

Return type:

None

create(*, step_id, outcome, properties=None, options=None, files=None, parent_id=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[ResultComplexType]

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.

Parameters:
  • name (str) – name of the option to get

  • domain (str) – domain of the option to get. Defaults to checklet

  • default – default value to return in case option is empty or undefined instead of raising an exception

Return type:

Any

Returns:

The option value

Raises:
  • KeyError – If no option with the given name exists and no default is provided

  • NoContent – If the option is empty

get_options(name, *, domain='checklet')#

Get options

Parameters:
  • name (str) – name of the options to get

  • domain (str) – domain of the options to get. Defaults to checklet

Return type:

FilterableTuple[Option]

Returns:

A filterable tuple of all matching options.

get_properties(name)#

Get properties

Parameters:

name (str) – name of the properties to get

Return type:

FilterableTuple[Property]

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

Parameters:
  • name (str) – name of the property to get

  • default – default value in case property is empty or undefined

Return type:

Any

Returns:

The property value

recreate(target_bundle, *, step_id=None)#

Recreate this Result in a target bundle, optionally changing the step_id. All other attributes are copied unchanged.

Parameters:
  • target_bundle (Bundle) – The target bundle

  • step_id (str | None) – New step_id for the result

Return type:

Result

Returns:

The recreated Result

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

set_parent_id(parent_id)#

Set the id of the result parent

bundle: typing.Final['momotor.bundles.Bundle']#

The Bundle containing this element

property erred: bool#

Returns True if outcome_enum is ERROR

property failed: bool#

Returns True if outcome_enum is FAIL

property files: FilterableTuple[File]#

files children

property options: FilterableTuple[Option]#

options children

property outcome: Literal['pass', 'fail', 'skip', 'error']#

outcome attribute as string value. Valid values are pass, fail, skip and error

property outcome_enum: Outcome#

outcome attribute as an Outcome enum

property passed: bool#

Returns True if outcome_enum is PASS

property properties: FilterableTuple[Property]#

properties children

property skipped: bool#

Returns True if outcome_enum is SKIP

property step_id: str#

step_id attribute

class momotor.bundles.elements.results.Results(bundle)#

A Results element encapsulating ResultsComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

create(*, id=None, meta=None, results=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[ResultsComplexType]

recreate(target_bundle)#

Recreate this element in a target bundle

Parameters:

target_bundle (Bundle) – The target bundle

Return type:

NoReturn

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

bundle: Final[Bundle]#

The Bundle containing this element

property id: str | None#

The id attribute

property meta: Meta#

meta attribute

property results: ResultKeyedTuple#

results children

class momotor.bundles.elements.result.Outcome(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

An enum for the Result.outcome. Mirrors OutcomeSimpleType

classmethod condition(state)#

Get outcome based on a condition

Return type:

Self

Returns:

returns Outcome.PASS if state is truthy, otherwise returns Outcome.FAIL

classmethod from_simpletype(st)#

Create an Outcome from an OutcomeSimpleType

Return type:

Self

to_simpletype()#

Convert into an OutcomeSimpleType

Return type:

OutcomeSimpleType

ERROR = 'error'#
FAIL = 'fail'#
PASS = 'pass'#
SKIP = 'skip'#
class momotor.bundles.elements.results.ResultKeyedTuple(results=None)#

The results as a KeyedTuple of Result 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

Parameters:

bundle (Bundle) – The Bundle containing this element

copy_files_to(destination, *, files=None)#

Copy files attached using the files nodes to a directory

Parameters:
  • destination (Path) – destination for the files

  • files (Sequence[File] | None) – optionally a filtered list of files to copy

Return type:

None

create(*, id, meta=None, priority='default', depends=None, checklet=None, options=None, files=None, resources=None)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

get_dependencies_ids()#

ids of the dependencies

Return type:

Generator[str, None, None]

static get_node_type()#

Get the xsData node type

Return type:

type[StepComplexType]

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.

Parameters:
  • name (str) – name of the option to get

  • domain (str) – domain of the option to get. Defaults to checklet

  • default – default value to return in case option is empty or undefined instead of raising an exception

Return type:

Any

Returns:

The option value

Raises:
  • KeyError – If no option with the given name exists and no default is provided

  • NoContent – If the option is empty

get_options(name, *, domain='checklet')#

Get options

Parameters:
  • name (str) – name of the options to get

  • domain (str) – domain of the options to get. Defaults to checklet

Return type:

FilterableTuple[Option]

Returns:

A filterable tuple of all matching options.

get_resources()#

get all resources needed by this step

Return type:

dict[str, FilterableTuple[Resource]]

recreate(target_bundle, *, id=None)#

Recreate this Step in a target bundle, optionally changing the id. All other attributes are copied unchanged.

Parameters:
  • target_bundle (Bundle) – The target bundle

  • id (str | None) – New id for the step

Return type:

Step

Returns:

The recreated Step

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

bundle: typing.Final['momotor.bundles.Bundle']#

The Bundle containing this element

property checklet: Checklet | None#

checklet

property depends: FilterableTuple[Depends] | None#

depends

property files: FilterableTuple[File]#

files children

property id: str | None#

The id attribute

property meta: Meta#

meta attribute

property options: FilterableTuple[Option]#

options children

property priority: str#

priority attribute

property priority_value: Priority#

priority attribute as Priority instance

property resources: FilterableTuple[Resource]#

resources attribute

class momotor.bundles.elements.steps.Depends(bundle)#

A Depends element encapsulating DependsComplexType

Parameters:

bundle (Bundle) – The Bundle containing this element

create(*, step)#

Set this element’s attributes

Usage:

element = Element(bundle).create(...)
Return type:

Self

Returns:

self

static get_node_type()#

Get the xsData node type

Return type:

type[DependsComplexType]

recreate(target_bundle)#

Recreate this Depends in a target bundle. All attributes are copied unchanged.

Parameters:

target_bundle (Bundle) – The target bundle

Return type:

Depends

Returns:

The recreated Depends

classmethod recreate_list(elements, target_bundle, filter=None, **kwargs)#

Recreate a list of elements using the recreate() method

Parameters:
  • elements (Iterable[Self] | None) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • filter (Callable[[Self], bool] | None) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean. Only elements for which the callable returns True will be recreated

  • kwargs – Additional keyword arguments are passed on to recreate()

Return type:

list[Self] | None

Returns:

a list of elements or None if elements param was None

bundle: Final[Bundle]#

The Bundle containing this element

property step: str#

step attribute

class momotor.bundles.elements.steps.Priority(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

An enum for the step priority

as_integer_ratio()#

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()#

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()#

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()#

Returns self, the complex conjugate of any int.

from_bytes(byteorder='big', *, signed=False)#

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

to_bytes(length=1, byteorder='big', *, signed=False)#

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

DEFAULT = 2#
HIGH = 1#
LOW = 3#
MUST_PASS = 0#
NORMAL = 2#
denominator#

the denominator of a rational number in lowest terms

imag#

the imaginary part of a complex number

numerator#

the numerator of a rational number in lowest terms

real#

the real part of a complex number