capellambse.extensions.reqif package

Tools for handling ReqIF Requirements.

class capellambse.extensions.reqif.AbstractRelation

Bases: ReqIFElement

relation_type_proxy

A POD containing arbitrary string data.

type

The type of this AbstractRelation.

class capellambse.extensions.reqif.AbstractType

Bases: ReqIFElement

attribute_definitions

The attribute definitions of this AbstractType.

attributes

The attributes of this AbstractType.

owner

The owner of this AbstractType.

class capellambse.extensions.reqif.Attribute

Bases: IdentifiableElement

definition

The definition of this Attribute.

definition_proxy

A POD containing arbitrary string data.

class capellambse.extensions.reqif.AttributeDefinition

Bases: ReqIFElement

data_type

The data type of this AttributeDefinition.

default_value

The default value of this AttributeDefinition.

definition_type

The definition type of this AttributeDefinition.

class capellambse.extensions.reqif.AttributeDefinitionEnumeration

Bases: AttributeDefinition

is_multi_valued

A POD containing a boolean.

property multi_valued: bool
class capellambse.extensions.reqif.AttributeOwner

Bases: ReqIFElement

attributes

The attributes of this AttributeOwner.

class capellambse.extensions.reqif.BooleanValueAttribute

Bases: Attribute

value

A POD containing a boolean.

class capellambse.extensions.reqif.CapellaIncomingRelation

Bases: CapellaRelation

source

The source of this CapellaIncomingRelation.

target

The target of this CapellaIncomingRelation.

class capellambse.extensions.reqif.CapellaModule

Bases: Module

property folders: ElementList[Folder]
to_reqif(to, *, metadata=None, pretty=False, compress=None)

Export this module as ReqIF XML.

You can override some auto-generated metadata placed in the header section by passing a dictionary as metadata. The following keys are supported. Unsupported keys are silently ignored.

  • creation_time: A datetime.datetime object that specifies this document’s creation time. Default to the current time.

  • comment: Override the ReqIF file’s comment. Defaults to a text derived from the model and module names.

  • title: Specify the document title. Defaults to the module’s long_name.

Parameters:
  • to (Union[str, PathLike, IO[bytes]]) – Where to export to. Can be the name of a file, or a file-like object opened in binary mode.

  • metadata (Mapping[str, Any] | None) – A dictionary with additional metadata (see above).

  • pretty (bool) – Format the XML human-readable.

  • compress (bool | None) – Write compressed data (*.reqifz). Defaults to True if target is a string or path-like and its name ends in .reqifz, otherwise defaults to False.

Return type:

None

class capellambse.extensions.reqif.CapellaOutgoingRelation

Bases: CapellaRelation

source

The source of this CapellaOutgoingRelation.

target

The target of this CapellaOutgoingRelation.

class capellambse.extensions.reqif.CapellaRelation

Bases: AbstractRelation

class capellambse.extensions.reqif.CapellaTypesFolder

Bases: TypesFolder

data_type_definitions

The data type definitions of this CapellaTypesFolder.

property module_types: ElementList[ModuleType]
property relation_types: ElementList[RelationType]
property requirement_types: ElementList[RequirementType]
class capellambse.extensions.reqif.DataTypeDefinition

Bases: ReqIFElement

class capellambse.extensions.reqif.DateValueAttribute

Bases: Attribute

value

A POD containing a timestamp.

The value stored in the XML will be formatted as required by Capella. This format is the ISO8601 format with millisecond precision, but no : in the time zone specification.

class capellambse.extensions.reqif.ElementRelationAccessor

Bases: WritableAccessor[ModelElement]

Provides access to RequirementsRelations of a ModelElement.

__init__()
Return type:

None

aslist: type[_obj.ElementListCouplingMixin] | None
purge_references(obj, target)

Do nothing.

This is a no-op, as this accessor provides a virtual relation.

The relation objects it handles are cleaned up by removing the source or target attribute.

Return type:

Generator[None, None, None]

Parameters:
class capellambse.extensions.reqif.EnumValue

Bases: ReqIFElement

class capellambse.extensions.reqif.EnumerationDataTypeDefinition

Bases: DataTypeDefinition

values

The values of this EnumerationDataTypeDefinition.

class capellambse.extensions.reqif.EnumerationValueAttribute

Bases: Attribute

definition

The definition of this EnumerationValueAttribute.

property value
values

The values of this EnumerationValueAttribute.

class capellambse.extensions.reqif.Folder

Bases: Requirement

property folders: ElementList[Folder]
requirements

The requirements of this Folder.

class capellambse.extensions.reqif.IdentifiableElement

Bases: ModelElement

class capellambse.extensions.reqif.IntegerValueAttribute

Bases: Attribute

value

A POD containing an integer number.

class capellambse.extensions.reqif.InternalRelation

Bases: AbstractRelation

source

The source of this InternalRelation.

target

The target of this InternalRelation.

class capellambse.extensions.reqif.Module

Bases: AttributeOwner, SharedDirectAttributes

requirements

The requirements of this Module.

type

The type of this Module.

class capellambse.extensions.reqif.ModuleType

Bases: AbstractType

class capellambse.extensions.reqif.RealValueAttribute

Bases: Attribute

value

A POD containing a floating-point number.

In Capella’s Java land, these are often called “real numbers”.

class capellambse.extensions.reqif.RelationType

Bases: AbstractType

class capellambse.extensions.reqif.RelationsList

Bases: ElementList[AbstractRelation]

__init__(model, elements, elemclass=None, *, source)
Parameters:
Return type:

None

by_relation_class(class_)
Return type:

RelationsList

Parameters:

class_ (Literal['incoming', 'outgoing', 'internal'])

by_relation_type(reltype)
Return type:

RelationsList

Parameters:

reltype (str)

class capellambse.extensions.reqif.ReqIFElement

Bases: IdentifiableElement

description

A POD containing arbitrary string data.

identifier

A POD containing arbitrary string data.

long_name

A POD containing arbitrary string data.

class capellambse.extensions.reqif.Requirement

Bases: AttributeOwner, SharedDirectAttributes

chapter_name

A POD containing arbitrary string data.

foreign_id

A POD containing an integer number.

owned_relations

The owned relations of this Requirement.

owner

The owner of this Requirement.

related: m.Accessor[m.ElementList[m.ModelElement]]

The related of this Requirement.

relations: m.Accessor[m.ElementList[AbstractRelation]]

The relations of this Requirement.

requirement_type_proxy

A POD containing arbitrary string data.

text

A POD containing a string with HTML inside.

type

The type of this Requirement.

class capellambse.extensions.reqif.RequirementType

Bases: AbstractType

class capellambse.extensions.reqif.RequirementsRelationAccessor

Bases: WritableAccessor[AbstractRelation]

Searches for requirement relations in the architecture layer.

__init__(*args, **kw)
Return type:

None

aslist: type[_obj.ElementListCouplingMixin] | None
create(elmlist, typehint=None, /, **kw)

Create and return a new element of type elmclass.

Parameters:
  • elmlist (ElementListCouplingMixin) – The (coupled) ElementList to insert the new object into.

  • typehint (str | None) – Hints for finding the correct type of element to create. Can either be a full or shortened xsi:type string, or an abbreviation defined by the specific Accessor instance.

  • kw (Any) – Initialize the properties of the new object. Depending on the object’s type, some attributes may be required.

Return type:

InternalRelation | CapellaIncomingRelation

delete(elmlist, obj)

Delete the obj from the model.

Return type:

None

insert(elmlist, index, value)

Insert the value object into the model.

The object must be inserted at an appropriate place, so that, if elmlist were to be created afresh, value would show up at index index.

Return type:

None

Parameters:
purge_references(obj, target)

Do nothing.

This is a no-op, as this accessor provides a virtual relation.

The relation objects it handles are cleaned up by removing the source or target attribute.

Return type:

Generator[None, None, None]

Parameters:
class capellambse.extensions.reqif.SharedDirectAttributes

Bases: ModelElement

name

A POD containing arbitrary string data.

prefix

A POD containing arbitrary string data.

class capellambse.extensions.reqif.StringValueAttribute

Bases: Attribute

value

A POD containing arbitrary string data.

class capellambse.extensions.reqif.TypesFolder

Bases: ReqIFElement

definition_types

The definition types of this TypesFolder.

types

The types of this TypesFolder.

Submodules

capellambse.extensions.reqif.capellarequirements module

class capellambse.extensions.reqif.capellarequirements.CapellaIncomingRelation

Bases: CapellaRelation

source

The source of this CapellaIncomingRelation.

target

The target of this CapellaIncomingRelation.

class capellambse.extensions.reqif.capellarequirements.CapellaModule

Bases: Module

property folders: ElementList[Folder]
to_reqif(to, *, metadata=None, pretty=False, compress=None)

Export this module as ReqIF XML.

You can override some auto-generated metadata placed in the header section by passing a dictionary as metadata. The following keys are supported. Unsupported keys are silently ignored.

  • creation_time: A datetime.datetime object that specifies this document’s creation time. Default to the current time.

  • comment: Override the ReqIF file’s comment. Defaults to a text derived from the model and module names.

  • title: Specify the document title. Defaults to the module’s long_name.

Parameters:
  • to (Union[str, PathLike, IO[bytes]]) – Where to export to. Can be the name of a file, or a file-like object opened in binary mode.

  • metadata (Mapping[str, Any] | None) – A dictionary with additional metadata (see above).

  • pretty (bool) – Format the XML human-readable.

  • compress (bool | None) – Write compressed data (*.reqifz). Defaults to True if target is a string or path-like and its name ends in .reqifz, otherwise defaults to False.

Return type:

None

class capellambse.extensions.reqif.capellarequirements.CapellaOutgoingRelation

Bases: CapellaRelation

source

The source of this CapellaOutgoingRelation.

target

The target of this CapellaOutgoingRelation.

class capellambse.extensions.reqif.capellarequirements.CapellaRelation

Bases: AbstractRelation

class capellambse.extensions.reqif.capellarequirements.CapellaTypesFolder

Bases: TypesFolder

data_type_definitions

The data type definitions of this CapellaTypesFolder.

property module_types: ElementList[ModuleType]
property relation_types: ElementList[RelationType]
property requirement_types: ElementList[RequirementType]
class capellambse.extensions.reqif.capellarequirements.ElementRelationAccessor

Bases: WritableAccessor[ModelElement]

Provides access to RequirementsRelations of a ModelElement.

__init__()
Return type:

None

aslist: type[_obj.ElementListCouplingMixin] | None
class_: type[T_co]
list_extra_args: cabc.Mapping[str, t.Any]
purge_references(obj, target)

Do nothing.

This is a no-op, as this accessor provides a virtual relation.

The relation objects it handles are cleaned up by removing the source or target attribute.

Return type:

Generator[None, None, None]

Parameters:
single_attr: str | None
class capellambse.extensions.reqif.capellarequirements.RelationsList

Bases: ElementList[AbstractRelation]

__init__(model, elements, elemclass=None, *, source)
Parameters:
Return type:

None

by_relation_class(class_)
Return type:

RelationsList

Parameters:

class_ (Literal['incoming', 'outgoing', 'internal'])

by_relation_type(reltype)
Return type:

RelationsList

Parameters:

reltype (str)

class capellambse.extensions.reqif.capellarequirements.RequirementsRelationAccessor

Bases: WritableAccessor[AbstractRelation]

Searches for requirement relations in the architecture layer.

__init__(*args, **kw)
Return type:

None

aslist: type[_obj.ElementListCouplingMixin] | None
class_: type[T_co]
create(elmlist, typehint=None, /, **kw)

Create and return a new element of type elmclass.

Parameters:
  • elmlist (ElementListCouplingMixin) – The (coupled) ElementList to insert the new object into.

  • typehint (str | None) – Hints for finding the correct type of element to create. Can either be a full or shortened xsi:type string, or an abbreviation defined by the specific Accessor instance.

  • kw (Any) – Initialize the properties of the new object. Depending on the object’s type, some attributes may be required.

Return type:

InternalRelation | CapellaIncomingRelation

delete(elmlist, obj)

Delete the obj from the model.

Return type:

None

insert(elmlist, index, value)

Insert the value object into the model.

The object must be inserted at an appropriate place, so that, if elmlist were to be created afresh, value would show up at index index.

Return type:

None

Parameters:
list_extra_args: cabc.Mapping[str, t.Any]
purge_references(obj, target)

Do nothing.

This is a no-op, as this accessor provides a virtual relation.

The relation objects it handles are cleaned up by removing the source or target attribute.

Return type:

Generator[None, None, None]

Parameters:
single_attr: str | None

capellambse.extensions.reqif.exporter module

Implementation of a ReqIF 1.1 and 1.2 exporter.

capellambse.extensions.reqif.exporter.export_module(module, target, *, metadata=None, pretty=False, compress=None)
Return type:

None

Parameters:

capellambse.extensions.reqif.requirements module

The ‘Requirements’ namespace.

class capellambse.extensions.reqif.requirements.AbstractRelation

Bases: ReqIFElement

relation_type_proxy

A POD containing arbitrary string data.

type

The type of this AbstractRelation.

class capellambse.extensions.reqif.requirements.AbstractType

Bases: ReqIFElement

attribute_definitions

The attribute definitions of this AbstractType.

attributes

The attributes of this AbstractType.

owner

The owner of this AbstractType.

class capellambse.extensions.reqif.requirements.Attribute

Bases: IdentifiableElement

definition

The definition of this Attribute.

definition_proxy

A POD containing arbitrary string data.

class capellambse.extensions.reqif.requirements.AttributeDefinition

Bases: ReqIFElement

data_type

The data type of this AttributeDefinition.

default_value

The default value of this AttributeDefinition.

definition_type

The definition type of this AttributeDefinition.

class capellambse.extensions.reqif.requirements.AttributeDefinitionEnumeration

Bases: AttributeDefinition

is_multi_valued

A POD containing a boolean.

property multi_valued: bool
class capellambse.extensions.reqif.requirements.AttributeOwner

Bases: ReqIFElement

attributes

The attributes of this AttributeOwner.

class capellambse.extensions.reqif.requirements.BooleanValueAttribute

Bases: Attribute

value

A POD containing a boolean.

class capellambse.extensions.reqif.requirements.DataTypeDefinition

Bases: ReqIFElement

class capellambse.extensions.reqif.requirements.DateValueAttribute

Bases: Attribute

value

A POD containing a timestamp.

The value stored in the XML will be formatted as required by Capella. This format is the ISO8601 format with millisecond precision, but no : in the time zone specification.

class capellambse.extensions.reqif.requirements.EnumValue

Bases: ReqIFElement

class capellambse.extensions.reqif.requirements.EnumerationDataTypeDefinition

Bases: DataTypeDefinition

values

The values of this EnumerationDataTypeDefinition.

class capellambse.extensions.reqif.requirements.EnumerationValueAttribute

Bases: Attribute

definition

The definition of this EnumerationValueAttribute.

property value
values

The values of this EnumerationValueAttribute.

class capellambse.extensions.reqif.requirements.Folder

Bases: Requirement

property folders: ElementList[Folder]
requirements

The requirements of this Folder.

class capellambse.extensions.reqif.requirements.IdentifiableElement

Bases: ModelElement

class capellambse.extensions.reqif.requirements.IntegerValueAttribute

Bases: Attribute

value

A POD containing an integer number.

class capellambse.extensions.reqif.requirements.InternalRelation

Bases: AbstractRelation

source

The source of this InternalRelation.

target

The target of this InternalRelation.

class capellambse.extensions.reqif.requirements.Module

Bases: AttributeOwner, SharedDirectAttributes

requirements

The requirements of this Module.

type

The type of this Module.

class capellambse.extensions.reqif.requirements.ModuleType

Bases: AbstractType

class capellambse.extensions.reqif.requirements.RealValueAttribute

Bases: Attribute

value

A POD containing a floating-point number.

In Capella’s Java land, these are often called “real numbers”.

class capellambse.extensions.reqif.requirements.RelationType

Bases: AbstractType

class capellambse.extensions.reqif.requirements.ReqIFElement

Bases: IdentifiableElement

description

A POD containing arbitrary string data.

identifier

A POD containing arbitrary string data.

long_name

A POD containing arbitrary string data.

class capellambse.extensions.reqif.requirements.Requirement

Bases: AttributeOwner, SharedDirectAttributes

chapter_name

A POD containing arbitrary string data.

foreign_id

A POD containing an integer number.

owned_relations

The owned relations of this Requirement.

owner

The owner of this Requirement.

related: m.Accessor[m.ElementList[m.ModelElement]]

The related of this Requirement.

relations: m.Accessor[m.ElementList[AbstractRelation]]

The relations of this Requirement.

requirement_type_proxy

A POD containing arbitrary string data.

text

A POD containing a string with HTML inside.

type

The type of this Requirement.

class capellambse.extensions.reqif.requirements.RequirementType

Bases: AbstractType

class capellambse.extensions.reqif.requirements.SharedDirectAttributes

Bases: ModelElement

name

A POD containing arbitrary string data.

prefix

A POD containing arbitrary string data.

class capellambse.extensions.reqif.requirements.StringValueAttribute

Bases: Attribute

value

A POD containing arbitrary string data.

class capellambse.extensions.reqif.requirements.TypesFolder

Bases: ReqIFElement

definition_types

The definition types of this TypesFolder.

types

The types of this TypesFolder.