Elements

Checklet

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

A Checklet element encapsulating checkletComplexType

Parameters

bundle (Bundle) – The element’s Bundle

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

Checklet

Returns

self

get_resources()

Get the resources as a dictionary name -> Resource

Return type

Dict[str, List[Resource]]

recreate(target_bundle, target_basesrc=None)

Recreate this element in a target bundle

Parameters
  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

Return type

Checklet

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

property entrypoint

entrypoint attribute: Override the default package entrypoint (unused, untested)

Return type

Optional[str]

property extras

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

Return type

Optional[List[str]]

property indices

indices attribute: (unused, untested)

Return type

Optional[List[Link]]

link attribute: (unused, untested)

Return type

Optional[Link]

property name

name attribute: The Python package name of the checklet

Return type

Optional[str]

property package_versions

package_versions attribute: (unused, untested)

Return type

Optional[List[PackageVersion]]

property repository

repository attribute: where to retrieve the package from

Return type

Optional[Repository]

property resources

resources attribute

Return type

Optional[List[Resource]]

property version

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

Return type

Optional[str]

Depends

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

A Depends element encapsulating dependsComplexType

Parameters

bundle (Bundle) – The element’s Bundle

create(*, step, options=None)

Set this element’s attributes

Usage:

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

Depends

Returns

self

get_option_value(name, *, domain='checklet')

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”

Return type

Any

Returns

The option value

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

List[Option]

Returns

A list of all matching options.

recreate(target_bundle, target_basesrc=None)

Recreate this element in a target bundle

Parameters
  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

Return type

Depends

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

property options

options children

Return type

Optional[List[Option]]

property step

step attribute

Return type

str

File

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

A File element encapsulating fileComplexType

Parameters

bundle (Bundle) – The element’s Bundle

copy_to(dest_dir)

Copy content to given directory

Parameters

dest_dir (Path) – base destination directory

The file is created relative to dest_dir. If the node has a src attribute this is used as the remaining path and file name, otherwise the name attribute is used.

So, if src is lorem/ipsum.txt and dest_dir is /tmp/, the content will be written to a file /tmp/lorem/ipsum.txt. Any missing intermediate directories will be created.

TODO: The final path is currently not validated, so make sure it cannot be used to

overwrite any important files!

create(*, class_=None, name=None, src=None, content=None, type=None, attrs=None)

Set this element’s attributes

Usage:

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

File

Returns

self

file_info()

Get file info for the content. For inline content, a time stamp of midnight January 1st, 1980 will be returned.

Return type

Optional[Tuple[int, struct_time]]

Returns

A tuple containing size and creation time timestamp.

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

Return type

bool

has_inline_text_content()

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

Return type

bool

has_text_content()

Returns True if the element has text content

Return type

bool

open()

Context manager to open the content

Return type

AbstractContextManager[BinaryIO]

recreate(target_bundle, target_basesrc=None)

Recreate this element in a target bundle

Parameters
  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

Return type

File

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

MAX_VALUE_LENGTH = 1000
property absolute_path
Return type

Optional[Path]

property attrs

Wildcard attributes

Return type

Dict[str, str]

property class_

class attribute

Return type

Optional[str]

property encoding

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

Return type

Optional[str]

property name

name attribute

Return type

Union[str, PurePath, None]

property relative_path
Return type

PurePosixPath

property src

src attribute: File path of the content. Mutually exclusive with value

Return type

Optional[PurePath]

property type

The type attribute. For nodes with a value attribute it indicates the type (string, integer or float), for nodes with child content or a src attribute, it is the content mime type.

Return type

Optional[str]

property value

value attribute: The literal content. Mutually exclusive with src

Return type

Any

Option

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

An Option element encapsulating optionComplexType

Parameters

bundle (Bundle) – The element’s Bundle

copy_to(dest_dir)

Copy content to given directory

Parameters

dest_dir (Path) – base destination directory

The file is created relative to dest_dir. If the node has a src attribute this is used as the remaining path and file name, otherwise the name attribute is used.

So, if src is lorem/ipsum.txt and dest_dir is /tmp/, the content will be written to a file /tmp/lorem/ipsum.txt. Any missing intermediate directories will be created.

TODO: The final path is currently not validated, so make sure it cannot be used to

overwrite any important files!

create(*, name, value=None, type=None, domain=None, external=None, description=None, attrs=None)

Set this element’s attributes

Usage:

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

Option

Returns

self

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

Return type

bool

has_inline_text_content()

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

Return type

bool

has_text_content()

Returns True if the element has text content

Return type

bool

open()

Context manager to open the content

Return type

AbstractContextManager[BinaryIO]

recreate(target_bundle, target_basesrc=None)

Recreate this element in a target bundle

Parameters
  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

Return type

Option

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

MAX_VALUE_LENGTH = 1000
property attrs

Wildcard attributes

Return type

Dict[str, str]

property description

description attribute

Return type

Optional[str]

property domain

domain attribute

Return type

str

property encoding

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

Return type

Optional[str]

property external

external attribute

Return type

Optional[bool]

property name

name attribute

Return type

Optional[str]

property type

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

Return type

Optional[str]

property value

value attribute: The content

Return type

Any

Property

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

A Property element encapsulating propertyComplexType

Parameters

bundle (Bundle) – The element’s Bundle

copy_to(dest_dir)

Copy content to given directory

Parameters

dest_dir (Path) – base destination directory

The file is created relative to dest_dir. If the node has a src attribute this is used as the remaining path and file name, otherwise the name attribute is used.

So, if src is lorem/ipsum.txt and dest_dir is /tmp/, the content will be written to a file /tmp/lorem/ipsum.txt. Any missing intermediate directories will be created.

TODO: The final path is currently not validated, so make sure it cannot be used to

overwrite any important files!

create(*, name, value=None, type=None, accept=None, attrs=None)

Set this element’s attributes

Usage:

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

Property

Returns

self

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

Return type

bool

has_inline_text_content()

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

Return type

bool

has_text_content()

Returns True if the element has text content

Return type

bool

open()

Context manager to open the content

Return type

AbstractContextManager[BinaryIO]

recreate(target_bundle, target_basesrc=None)

Recreate this element in a target bundle

Parameters
  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

Return type

Property

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

MAX_VALUE_LENGTH = 1000
property accept
Return type

Optional[str]

property attrs

Wildcard attributes

Return type

Dict[str, str]

property encoding

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

Return type

Optional[str]

property name

name attribute

Return type

Optional[str]

property type

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

Return type

Optional[str]

property value

value attribute: The content

Return type

Any

Resource

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

A Resource element encapsulating resourceComplexType

Parameters

bundle (Bundle) – The element’s Bundle

copy_to(dest_dir)

Copy content to given directory

Parameters

dest_dir (Path) – base destination directory

The file is created relative to dest_dir. If the node has a src attribute this is used as the remaining path and file name, otherwise the name attribute is used.

So, if src is lorem/ipsum.txt and dest_dir is /tmp/, the content will be written to a file /tmp/lorem/ipsum.txt. Any missing intermediate directories will be created.

TODO: The final path is currently not validated, so make sure it cannot be used to

overwrite any important files!

create(*, name, value=None)

Set this element’s attributes

Usage:

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

Resource

Returns

self

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

Return type

bool

has_inline_text_content()

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

Return type

bool

has_text_content()

Returns True if the element has text content

Return type

bool

open()

Context manager to open the content

Return type

AbstractContextManager[BinaryIO]

recreate(target_bundle, target_basesrc=None)

Recreate this element in a target bundle

Parameters
  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

Return type

Resource

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

MAX_VALUE_LENGTH = 1000
property encoding

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

Return type

Optional[str]

property name

name attribute

Return type

Optional[str]

property value

value attribute: The content

Return type

Any

Result

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

A Result element encapsulating resultComplexType

Parameters

bundle (Bundle) – The element’s Bundle

copy_files(dest_dir)

Copy the files to dest_dir

Return type

None

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

Result

Returns

self

get_option_value(name, *, domain='checklet')

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”

Return type

Any

Returns

The option value

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

List[Option]

Returns

A list of all matching options.

get_properties(name)

Get properties

Parameters

name (str) – name of the properties to get

Return type

List[Property]

Returns

A list of all matching properties.

get_property_value(name)

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

Return type

Any

Returns

The property value

recreate(target_bundle, target_basesrc=None)

Recreate this element in a target bundle

Parameters
  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

Return type

Result

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

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

checklet

Return type

Optional[Checklet]

property erred

Returns True if outcome is error

Return type

bool

property failed

Returns True if outcome is fail

Return type

bool

property files

The files

Return type

Optional[List[File]]

property options

options children

Return type

Optional[List[Option]]

property outcome

outcome attribute. Valid values are pass, fail and error

property passed

Returns True if outcome is pass

Return type

bool

property properties

properties children

Return type

Optional[List[Property]]

property step_id

step_id attribute

Return type

str

Results

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

A Results element encapsulating resultsComplexType

Parameters

bundle (Bundle) – The element’s Bundle

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

Set this element’s attributes

Usage:

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

~RT

Returns

self

recreate(target_bundle, target_basesrc=None)

not implemented

Return type

NoReturn

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

property id

The id attribute

Return type

Optional[str]

property results
Return type

ResultKeyedList

class momotor.bundles.elements.results.ResultKeyedList(results=None)

The results as a KeyedList of Result objects.

The KeyedList allows access as a list 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 element’s Bundle

copy_files(dest_dir)

Copy the files to dest_dir

Return type

None

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

Set this element’s attributes

Usage:

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

Step

Returns

self

get_dependencies_ids()

ids of the dependencies

Return type

List[str]

get_option_value(name, *, domain='checklet')

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”

Return type

Any

Returns

The option value

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

List[Option]

Returns

A list of all matching options.

get_resources()

get all resources needed by this step

Return type

Dict[str, List[Resource]]

recreate(target_bundle, target_basesrc=None)

not implemented

Return type

NoReturn

classmethod recreate_list(elements, target_bundle, target_basesrc=None, filter=None)

Recreate a list of elements

Parameters
  • elements (Optional[Iterator[~ET]]) – List of elements to recreate (can be None)

  • target_bundle (Bundle) – The target bundle

  • target_basesrc (PurePosixPath) – The base src of the target

  • filter (Callable[[~ET], bool]) – An optional callable to filter the list of elements before recreation. The callable receives an element and should return a boolean

Return type

Optional[List[~ET]]

Returns

a list of elements or None if elements param was None

property checklet

checklet

Return type

Optional[Checklet]

property depends

depends

Return type

Optional[List[Depends]]

property files

The files

Return type

Optional[List[File]]

property id

The id attribute

Return type

Optional[str]

property options

options children

Return type

Optional[List[Option]]

property priority

priority attribute

Return type

str

property priority_value

priority attribute as Priority instance

Return type

Priority

property resources

resources attribute

Return type

Optional[List[Resource]]

Types

A NamedTuple for a reference to a link

Parameters

src (str) – The src of the link

property src

Alias for field number 0

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

A NamedTuple for a reference to a package with version

Parameters
  • name (str) – The name of the package

  • version (str) – The version qualifier for the package

property name

Alias for field number 0

property version

Alias for field number 1

class momotor.bundles.elements.checklets.Repository(src: str, type: str, revision: str)

A NamedTuple for a reference to a repository

Parameters
  • src (str) – The src of the repository. Can be a url or a local path

  • type (str) – The type of the repository

  • revision (str) – The revision of the repository

property revision

Alias for field number 2

property src

Alias for field number 0

property type

Alias for field number 1

class momotor.bundles.elements.steps.Priority(value)

An enum for the step priority

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