diff --git a/capellambse_context_diagrams/collectors/makers.py b/capellambse_context_diagrams/collectors/makers.py index 4d3dce15..469ae5b5 100644 --- a/capellambse_context_diagrams/collectors/makers.py +++ b/capellambse_context_diagrams/collectors/makers.py @@ -4,7 +4,6 @@ from __future__ import annotations import collections.abc as cabc -import typing as t import typing_extensions as te from capellambse import helpers diff --git a/capellambse_context_diagrams/serializers.py b/capellambse_context_diagrams/serializers.py index 8cbfb736..538cd944 100644 --- a/capellambse_context_diagrams/serializers.py +++ b/capellambse_context_diagrams/serializers.py @@ -128,7 +128,7 @@ class type that stores all previously named classes. size = (child["size"]["width"], child["size"]["height"]) # type: ignore features = [] if styleclass in decorations.needs_feature_line: - features = self._handle_features(child) # type: ignore[arg-type] + features = handle_features(child) # type: ignore[arg-type] element = diagram.Box( ref, @@ -203,18 +203,6 @@ class type that stores all previously named classes. for i in child.get("children", []): # type: ignore self.deserialize_child(i, ref, element) - def _handle_features(self, child: _elkjs.ELKOutputNode) -> list[str]: - features: list[str] = [] - if len(child["children"]) <= 1: - return features - - for c in child["children"][1:]: - if not c["type"] == "label": - continue - features.append(c["text"]) - child["children"] = child["children"][:1] - return features - def _is_hierarchical(self, uuid: str) -> bool: def is_contained(obj: diagram.Box) -> bool: if obj.port and obj.parent and obj.parent.parent: @@ -274,3 +262,17 @@ def order_children(self) -> None: new_diagram.add_element(element) self.diagram = new_diagram + + +def handle_features(child: _elkjs.ELKOutputNode) -> list[str]: + """Return all consecutive labels (without first) from the ``child``.""" + features: list[str] = [] + if len(child["children"]) <= 1: + return features + + for c in child["children"][1:]: + if not c["type"] == "label": + continue + features.append(c["text"]) + child["children"] = child["children"][:1] + return features