Skip to content

Commit

Permalink
refactor: Apply changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Sep 19, 2024
1 parent e538f3a commit 9cb5b42
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions capellambse_context_diagrams/collectors/tree_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from __future__ import annotations

import collections
import collections.abc as cabc
import copy
import dataclasses
Expand Down Expand Up @@ -38,7 +39,7 @@ def __init__(self, data: _elkjs.ELKInputData) -> None:
self.data_types: set[str] = set()
self.legend_boxes: list[_elkjs.ELKInputChild] = []

self._edge_count: dict[str, int] = {}
self._edge_count: dict[str, int] = collections.defaultdict(int)

def __contains__(self, uuid: str) -> bool:
objects = self.data.children + self.data.edges # type: ignore[operator]
Expand All @@ -51,24 +52,21 @@ def process_class(self, cls: ClassInfo, params: dict[str, t.Any]):
assert cls.prop is not None
self._process_box(cls.target, cls.partition, params)

aggregation_kind_excludes = {
None,
modeltypes.AggregationKind.UNSET,
}
if cls.prop.association is not None:
edge_id = cls.prop.association.uuid
else:
logger.warning(
"No Association found for %s set on 'navigable_members'",
cls.prop._short_repr_(),
)
if cls.prop.kind not in aggregation_kind_excludes:
if cls.prop.kind != modeltypes.AggregationKind.UNSET:
styleclass = cls.prop.kind.name.capitalize()
else:
styleclass = "Association"

i = self._edge_count.setdefault(cls.prop.uuid, 0)
i += 1
self._edge_count.setdefault(cls.prop.uuid, 0)
self._edge_count[cls.prop.uuid] += 1
i = self._edge_count[cls.prop.uuid]
edge_id = f"__{styleclass}:{cls.prop.uuid}-{i}"

if edge_id not in self.made_edges:
Expand Down

0 comments on commit 9cb5b42

Please sign in to comment.