Skip to content

Commit

Permalink
Merge branch 'main' into feat-hide-direct-children
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger authored Oct 29, 2024
2 parents a6a5770 + 0e69afe commit f11c575
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 88 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_install_hook_types: [commit-msg, pre-commit]
default_stages: [commit, merge-commit]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -26,7 +26,7 @@ repos:
- id: fix-byte-order-marker
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
Expand Down
5 changes: 5 additions & 0 deletions capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
function), other elements use a white background color to distinguish
them.
"""

from __future__ import annotations

import collections.abc as cabc
Expand Down Expand Up @@ -199,6 +200,10 @@ def register_interface_context() -> None:
ATTR_NAME,
context.InterfaceContextAccessor(
{
sa.SystemComponentPkg: DiagramType.SAB.value,
sa.SystemComponent: DiagramType.SAB.value,
la.LogicalComponentPkg: DiagramType.LAB.value,
la.LogicalComponent: DiagramType.LAB.value,
pa.PhysicalComponentPkg: DiagramType.PAB.value,
pa.PhysicalComponent: DiagramType.PAB.value,
},
Expand Down
24 changes: 24 additions & 0 deletions capellambse_context_diagrams/collectors/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ def get_left_and_right(self) -> None:
self.data.children.append(self.left)
assert self.right is not None
self.data.children.append(self.right)
if self.left == self.right:
raise errors.CycleError(
"The interface is a cycle, connecting the same "
"source and target."
)

except AttributeError as error:
logger.exception("Interface collection failed: \n%r", str(error))

Expand Down Expand Up @@ -433,3 +439,21 @@ def is_hierarchical(
source_contained = src.uuid in objs or attr_getter(src) == box.id
target_contained = trg.uuid in objs or attr_getter(trg) == box.id
return source_contained and target_contained


def functional_context_collector(
diagram: context.FunctionalContextDiagram, pars: dict[str, t.Any]
) -> _elkjs.ELKInputData:
return get_elkdata_for_exchanges(diagram, FunctionalContextCollector, pars)


def interface_context_collector(
diagram: context.InterfaceContextDiagram, pars: dict[str, t.Any]
) -> _elkjs.ELKInputData:
collector: t.Type[ExchangeCollector]
if isinstance(diagram.target, cs.PhysicalLink):
collector = PhysicalLinkContextCollector
else:
collector = InterfaceContextCollector

return get_elkdata_for_exchanges(diagram, collector, pars)
Loading

0 comments on commit f11c575

Please sign in to comment.