Skip to content

Commit

Permalink
fix(tree-view): Handle undefined cardinality
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Jun 5, 2024
1 parent 7fe3a45 commit 5744042
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions capellambse_context_diagrams/collectors/tree_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,11 @@ def _make_class_info(
partition: int,
generalizes: information.Class | None = None,
) -> ClassInfo:
converter = {math.inf: "*"}
multiplicity = None
target = None
if prop is not None:
start = converter.get(prop.min_card.value, str(prop.min_card.value))
end = converter.get(prop.max_card.value, str(prop.max_card.value))
start = getattr(prop.min_card, "value", "1")
end = getattr(prop.max_card, "value", "1")
multiplicity = (start, end)
target = prop.type

Expand Down Expand Up @@ -411,8 +410,11 @@ def _get_property_text(prop: information.Property) -> str:
"Property without abstract type found: %r", prop._short_repr_()
)

if prop.min_card.value != "1" or prop.max_card.value != "1":
text = f"[{prop.min_card.value}..{prop.max_card.value}] {text}"
min_card = getattr(prop.min_card, "value", "1")
max_card = getattr(prop.max_card, "value", "1")

if min_card != "1" or max_card != "1":
text = f"[{min_card}..{max_card}] {text}"
return text


Expand Down

0 comments on commit 5744042

Please sign in to comment.