capella_rm_bridge package#

Subpackages#

Submodules#

capella_rm_bridge.auditing module#

Functionality for reporting changes during model modification.

class capella_rm_bridge.auditing.ChangeAuditor#

Bases: object

Audits changes to ModelElements via its Accessors.

Warning

This will permanently add an audit hook to the global hook table. The auditor will keep the model alive, which may consume excessive memory. To avoid this, call the auditor object’s detach() method once you are done with it. This is automatically done if you use it as a context manager.

Examples

>>> with ChangeAuditor(model) as changes:
...     comp = model.la.all_components.by_name("Hogwarts")
...     comp.name = "Not Hogwarts anymore"
...     comp.allocated_functions.insert(
...         0, model.la.all_functions[0]
...     )
...     del comp.components[0]
...
>>> changes
[
    Modification(
        module="853cb005-cba0-489b-8fe3-bb694ad4543b",
        parent="<LogicalComponent 'Hogwarts' (0d2edb8f-fa34-4e73-89e...)>",
        attribute="name",
        new="Not Hogwarts anymore",
        old="Hogwarts",
    ),
    Extension(
        module="853cb005-cba0-489b-8fe3-bb694ad4543b",
        parent="<LogicalComponent 'Hogwarts' (0d2edb8f-fa34-4e73-89e...)>",
        attribute="allocated_functions",
        element="<LogicalFunction 'Root Logical Function' (f2...)>",
        uuid="f28ec0f8-f3b3-43a0-8af7-79f194b29a2d",
    ),
    Deletion(
        module="853cb005-cba0-489b-8fe3-bb694ad4543b",
        parent="<LogicalComponent 'Hogwarts' (0d2edb8f-fa34-4e73-89e...)>",
        attribute="components",
        element="<LogicalComponent 'Campus' (6583b560-6d2f-...)>",
        uuid="6583b560-6d2f-4190-baa2-94eef179c8ea",
    )
]

Filtering the context by class-names:

>>> with ChangeAuditor(model, {"LogicalComponent"}) as changes:
...     comp = model.la.all_components.by_name("Hogwarts")
...     comp.name = "Not Hogwarts anymore"
...     fnc = model.la.all_functions[0]
...     fnc.name = "Not Hogwarts anymore"
...
>>> changes
[
    Modification(
        module="853cb005-cba0-489b-8fe3-bb694ad4543b",
        parent="<LogicalComponent 'Hogwarts' (0d2edb8f-fa34-4e73-89e...)>",
        attribute="name",
        new="Not Hogwarts anymore",
        old="Hogwarts",
    )
]

Securing writable context with the dump() function:

>>> with ChangeAuditor(model) as changes:
...     comp = model.la.all_components.by_name("Hogwarts")
...     comp.name = "Not Hogwarts anymore"
...     comp.allocated_functions.insert(
...         0, model.la.all_functions[0]
...     )
...     del comp.components[0]
...
>>> dump(changes)
[
    {
        "_type": "Modification,
        "module": "853cb005-cba0-489b-8fe3-bb694ad4543b",
        "parent": "<LogicalComponent 'Hogwarts' (0d2edb8f-fa34-4e73-...)>",
        "attribute": "name",
        "new": "Not Hogwarts anymore",
        "old": "Hogwarts"
    },
    {
        "_type": "Extension",
        "module": "853cb005-cba0-489b-8fe3-bb694ad4543b",
        "parent": "<LogicalComponent 'Hogwarts' (0d2edb8f-fa34-4e73-...)>",
        "attribute": "allocated_functions",
        "element": "<LogicalFunction 'Fnc' (f28ec0f8-f3b3-43a...)>",
        "uuid": "f28ec0f8-f3b3-43a0-8af7-79f194b29a2d"
    },
    {
        "_type": "Deletion",
        "module": "853cb005-cba0-489b-8fe3-bb694ad4543b",
        "parent": "<LogicalComponent 'Hogwarts' (0d2edb8f-fa34-4e73-...)>",
        "attribute": "components",
        "element": "<LogicalComponent 'Comp' (6583b560-6d2f-4...)>",
        "uuid": "6583b560-6d2f-4190-baa2-94eef179c8ea"
    }
]
__init__(model, classes=())#

Initialize a ChangeAuditor.

Parameters:
  • model (MelodyModel) – A model instance to audit changes for.

  • classes (Container[str]) – An optional class-name filter. Only changes to ModelObjects with matching class-type are stored in context.

Return type:

None

detach()#

Delete the reference to the model instance.

Return type:

None

class capella_rm_bridge.auditing.Deletion#

Bases: Extension

Data that describes the context for a deletion event.

class capella_rm_bridge.auditing.Extension#

Bases: _Change

Data that describes the context for an extension event.

__init__(module, parent, attribute, element, uuid)#
Parameters:
  • module (str) –

  • parent (str) –

  • attribute (str) –

  • element (str) –

  • uuid (str) –

Return type:

None

element: str#
uuid: str#
class capella_rm_bridge.auditing.Modification#

Bases: _Change

Data that describes the context for a modification event.

__init__(module, parent, attribute, new, old)#
Parameters:
  • module (str) –

  • parent (str) –

  • attribute (str) –

  • new (Any) –

  • old (Any) –

Return type:

None

new: Any#
old: Any#
class capella_rm_bridge.auditing.RMReporter#

Bases: object

Stores and reports on all changes that were made to a model.

__init__(model)#
Parameters:

model (MelodyModel) –

Return type:

None

categories: dict[str, int]#

A dictionary that maps the category name to its counter.

create_commit_message(tool_metadata)#

Return a commit message for all changes in the store.

Parameters:
  • config – Configuration dictionary for the RM Bridge

  • tool_metadata (dict[str, str]) – Metadata of the requirements management tool from the snapshot.

Return type:

commit_message

get_change_report()#

Return an audit report of all changes in the store.

Return type:

str

model: MelodyModel#

The model instance that was changed.

ptrn = re.compile('<(?P<ClassName>[A-Za-z]+)\\b.*?>')#

Regex for matching the class name from a short representation.

store: dict[str, list[Union[capella_rm_bridge.auditing.Modification, capella_rm_bridge.auditing.Extension, capella_rm_bridge.auditing.Deletion]]]#

A change-store that maps identifiers to a sequence of changes.

store_changes(changes, module_id, module_category)#

Assigns the CapellaModule to changes and stores them.

Parameters:
Return type:

None

capella_rm_bridge.auditing.dump(context)#

Convert a ChangeContext into something savely writable.

Parameters:

context (list[Union[capella_rm_bridge.auditing.Modification, capella_rm_bridge.auditing.Extension, capella_rm_bridge.auditing.Deletion]]) –

Return type:

list[dict[str, Any]]

capella_rm_bridge.auditing.formulate_statement(change, source)#

Return an audit statement about the given change.

Parameters:
Return type:

str

capella_rm_bridge.auditing.generate_main_message(categories)#

Return the main commit message corpus listing all categories.

Parameters:

categories (Iterable[tuple[str, int]]) –

Return type:

str

capella_rm_bridge.auditing.get_dependencies()#

Return all major dependencies with their current version.

Return type:

list[str]

capella_rm_bridge.load module#

capella_rm_bridge.load.load_yaml(config_path)#

Return Requirements Management (RM) Bridge YAML configuration.

Example for config_path.yaml#
trackers: # List all trackers for which a snapshot should be exported
  - external-id : 25093
    capella-uuid: 3be8d0fc-c693-4b9b-8fa1-d59a9eec6ea4
    fields:
      - Capella ID
      - Type
      - Status
      - Color
      - Submitted at

model:
    path: PATH/TO/YOUR_MODEL.aird

# Additional sections which configure the snapshot importer
# may also appear here
Returns:

The whole RM Bridge configuration.

Return type:

config

Parameters:

config_path (Path | str) –

Module contents#

The rm_bridge package.