buildzr 0.0.12__tar.gz → 0.0.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {buildzr-0.0.12 → buildzr-0.0.13}/PKG-INFO +1 -1
- buildzr-0.0.13/buildzr/__about__.py +1 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/dsl.py +45 -45
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/expression.py +46 -20
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/groups.py +2 -2
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/implied_relationships.py +1 -1
- buildzr-0.0.12/buildzr/__about__.py +0 -1
- {buildzr-0.0.12 → buildzr-0.0.13}/.gitignore +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/CONTRIBUTING.md +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/LICENSE.md +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/README.md +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/color.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/explorer.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/factory/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/factory/gen_id.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/interfaces/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/interfaces/interfaces.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/dsl/relations.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/encoders/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/encoders/encoder.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/models/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/models/generate.sh +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/models/models.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/sinks/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/sinks/interfaces.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/buildzr/sinks/json_sink.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/pyproject.toml +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/abstract_builder.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/__init__.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/component_view.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/container_view.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/container_view_sugar.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/nested_groups.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/simple.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/simple_dsl.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/system_context_view.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/samples/system_landscape_view.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/test_dsl.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/test_explorer.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/test_expression.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/test_typehints.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/test_views.py +0 -0
- {buildzr-0.0.12 → buildzr-0.0.13}/tests/test_workspaces.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
VERSION = "0.0.13"
|
@@ -767,7 +767,7 @@ def _auto_layout_to_model(auto_layout: _AutoLayout) -> buildzr.models.AutomaticL
|
|
767
767
|
|
768
768
|
class SystemLandscapeView(DslViewElement):
|
769
769
|
|
770
|
-
from buildzr.dsl.expression import Expression,
|
770
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
771
771
|
|
772
772
|
@property
|
773
773
|
def model(self) -> buildzr.models.SystemLandscapeView:
|
@@ -779,10 +779,10 @@ class SystemLandscapeView(DslViewElement):
|
|
779
779
|
description: str,
|
780
780
|
auto_layout: _AutoLayout='tb',
|
781
781
|
title: Optional[str]=None,
|
782
|
-
include_elements: List[Union[DslElement, Callable[[
|
783
|
-
exclude_elements: List[Union[DslElement, Callable[[
|
784
|
-
include_relationships: List[Union[DslElement, Callable[[
|
785
|
-
exclude_relationships: List[Union[DslElement, Callable[[
|
782
|
+
include_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
783
|
+
exclude_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
784
|
+
include_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
785
|
+
exclude_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
786
786
|
properties: Optional[Dict[str, str]]=None,
|
787
787
|
) -> None:
|
788
788
|
self._m = buildzr.models.SystemLandscapeView()
|
@@ -805,7 +805,7 @@ class SystemLandscapeView(DslViewElement):
|
|
805
805
|
|
806
806
|
def _on_added(self, workspace: Workspace) -> None:
|
807
807
|
|
808
|
-
from buildzr.dsl.expression import Expression,
|
808
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
809
809
|
from buildzr.models import ElementView, RelationshipView
|
810
810
|
|
811
811
|
expression = Expression(
|
@@ -815,17 +815,17 @@ class SystemLandscapeView(DslViewElement):
|
|
815
815
|
exclude_relationships=self._exclude_relationships,
|
816
816
|
)
|
817
817
|
|
818
|
-
include_view_elements_filter: List[Union[DslElement, Callable[[
|
818
|
+
include_view_elements_filter: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]] = [
|
819
819
|
lambda w, e: e.type == Person,
|
820
820
|
lambda w, e: e.type == SoftwareSystem
|
821
821
|
]
|
822
822
|
|
823
|
-
exclude_view_elements_filter: List[Union[DslElement, Callable[[
|
823
|
+
exclude_view_elements_filter: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]] = [
|
824
824
|
lambda w, e: e.type == Container,
|
825
825
|
lambda w, e: e.type == Component,
|
826
826
|
]
|
827
827
|
|
828
|
-
include_view_relationships_filter: List[Union[DslElement, Callable[[
|
828
|
+
include_view_relationships_filter: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]] = [
|
829
829
|
lambda w, r: r.source.type == Person,
|
830
830
|
lambda w, r: r.source.type == SoftwareSystem,
|
831
831
|
lambda w, r: r.destination.type == Person,
|
@@ -864,7 +864,7 @@ class SystemContextView(DslViewElement):
|
|
864
864
|
relationship with the selected `SoftwareSystem`.
|
865
865
|
"""
|
866
866
|
|
867
|
-
from buildzr.dsl.expression import Expression,
|
867
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
868
868
|
|
869
869
|
@property
|
870
870
|
def model(self) -> buildzr.models.SystemContextView:
|
@@ -872,15 +872,15 @@ class SystemContextView(DslViewElement):
|
|
872
872
|
|
873
873
|
def __init__(
|
874
874
|
self,
|
875
|
-
software_system_selector: Union[SoftwareSystem, Callable[[
|
875
|
+
software_system_selector: Union[SoftwareSystem, Callable[[WorkspaceExpression], SoftwareSystem]],
|
876
876
|
key: str,
|
877
877
|
description: str,
|
878
878
|
auto_layout: _AutoLayout='tb',
|
879
879
|
title: Optional[str]=None,
|
880
|
-
include_elements: List[Union[DslElement, Callable[[
|
881
|
-
exclude_elements: List[Union[DslElement, Callable[[
|
882
|
-
include_relationships: List[Union[DslElement, Callable[[
|
883
|
-
exclude_relationships: List[Union[DslElement, Callable[[
|
880
|
+
include_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
881
|
+
exclude_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
882
|
+
include_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
883
|
+
exclude_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
884
884
|
properties: Optional[Dict[str, str]]=None,
|
885
885
|
) -> None:
|
886
886
|
self._m = buildzr.models.SystemContextView()
|
@@ -904,21 +904,21 @@ class SystemContextView(DslViewElement):
|
|
904
904
|
|
905
905
|
def _on_added(self, workspace: Workspace) -> None:
|
906
906
|
|
907
|
-
from buildzr.dsl.expression import Expression,
|
907
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
908
908
|
from buildzr.models import ElementView, RelationshipView
|
909
909
|
|
910
910
|
if isinstance(self._selector, SoftwareSystem):
|
911
911
|
software_system = self._selector
|
912
912
|
else:
|
913
|
-
software_system = self._selector(workspace)
|
913
|
+
software_system = self._selector(WorkspaceExpression(workspace))
|
914
914
|
self._m.softwareSystemId = software_system.model.id
|
915
|
-
view_elements_filter: List[Union[DslElement, Callable[[
|
915
|
+
view_elements_filter: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]] = [
|
916
916
|
lambda w, e: e == software_system,
|
917
917
|
lambda w, e: software_system.model.id in e.sources.ids,
|
918
918
|
lambda w, e: software_system.model.id in e.destinations.ids,
|
919
919
|
]
|
920
920
|
|
921
|
-
view_relationships_filter: List[Union[DslElement, Callable[[
|
921
|
+
view_relationships_filter: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]] = [
|
922
922
|
lambda w, r: software_system == r.source,
|
923
923
|
lambda w, r: software_system == r.destination,
|
924
924
|
]
|
@@ -950,7 +950,7 @@ class SystemContextView(DslViewElement):
|
|
950
950
|
|
951
951
|
class ContainerView(DslViewElement):
|
952
952
|
|
953
|
-
from buildzr.dsl.expression import Expression,
|
953
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
954
954
|
|
955
955
|
@property
|
956
956
|
def model(self) -> buildzr.models.ContainerView:
|
@@ -958,15 +958,15 @@ class ContainerView(DslViewElement):
|
|
958
958
|
|
959
959
|
def __init__(
|
960
960
|
self,
|
961
|
-
software_system_selector: Union[SoftwareSystem, Callable[[
|
961
|
+
software_system_selector: Union[SoftwareSystem, Callable[[WorkspaceExpression], SoftwareSystem]],
|
962
962
|
key: str,
|
963
963
|
description: str,
|
964
964
|
auto_layout: _AutoLayout='tb',
|
965
965
|
title: Optional[str]=None,
|
966
|
-
include_elements: List[Union[DslElement, Callable[[
|
967
|
-
exclude_elements: List[Union[DslElement, Callable[[
|
968
|
-
include_relationships: List[Union[DslElement, Callable[[
|
969
|
-
exclude_relationships: List[Union[DslElement, Callable[[
|
966
|
+
include_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
967
|
+
exclude_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
968
|
+
include_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
969
|
+
exclude_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
970
970
|
properties: Optional[Dict[str, str]]=None,
|
971
971
|
) -> None:
|
972
972
|
self._m = buildzr.models.ContainerView()
|
@@ -990,24 +990,24 @@ class ContainerView(DslViewElement):
|
|
990
990
|
|
991
991
|
def _on_added(self, workspace: Workspace) -> None:
|
992
992
|
|
993
|
-
from buildzr.dsl.expression import Expression,
|
993
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
994
994
|
from buildzr.models import ElementView, RelationshipView
|
995
995
|
|
996
996
|
if isinstance(self._selector, SoftwareSystem):
|
997
997
|
software_system = self._selector
|
998
998
|
else:
|
999
|
-
software_system = self._selector(workspace)
|
999
|
+
software_system = self._selector(WorkspaceExpression(workspace))
|
1000
1000
|
self._m.softwareSystemId = software_system.model.id
|
1001
1001
|
|
1002
1002
|
container_ids = { container.model.id for container in software_system.children}
|
1003
1003
|
|
1004
|
-
view_elements_filter: List[Union[DslElement, Callable[[
|
1004
|
+
view_elements_filter: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]] = [
|
1005
1005
|
lambda w, e: e.parent == software_system,
|
1006
1006
|
lambda w, e: any(container_ids.intersection({ id for id in e.sources.ids })),
|
1007
1007
|
lambda w, e: any(container_ids.intersection({ id for id in e.destinations.ids })),
|
1008
1008
|
]
|
1009
1009
|
|
1010
|
-
view_relationships_filter: List[Union[DslElement, Callable[[
|
1010
|
+
view_relationships_filter: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]] = [
|
1011
1011
|
lambda w, r: software_system == r.source.parent,
|
1012
1012
|
lambda w, r: software_system == r.destination.parent,
|
1013
1013
|
]
|
@@ -1039,7 +1039,7 @@ class ContainerView(DslViewElement):
|
|
1039
1039
|
|
1040
1040
|
class ComponentView(DslViewElement):
|
1041
1041
|
|
1042
|
-
from buildzr.dsl.expression import Expression,
|
1042
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
1043
1043
|
|
1044
1044
|
@property
|
1045
1045
|
def model(self) -> buildzr.models.ComponentView:
|
@@ -1047,15 +1047,15 @@ class ComponentView(DslViewElement):
|
|
1047
1047
|
|
1048
1048
|
def __init__(
|
1049
1049
|
self,
|
1050
|
-
container_selector: Union[Container, Callable[[
|
1050
|
+
container_selector: Union[Container, Callable[[WorkspaceExpression], Container]],
|
1051
1051
|
key: str,
|
1052
1052
|
description: str,
|
1053
1053
|
auto_layout: _AutoLayout='tb',
|
1054
1054
|
title: Optional[str]=None,
|
1055
|
-
include_elements: List[Union[DslElement, Callable[[
|
1056
|
-
exclude_elements: List[Union[DslElement, Callable[[
|
1057
|
-
include_relationships: List[Union[DslElement, Callable[[
|
1058
|
-
exclude_relationships: List[Union[DslElement, Callable[[
|
1055
|
+
include_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
1056
|
+
exclude_elements: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
1057
|
+
include_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
1058
|
+
exclude_relationships: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
1059
1059
|
properties: Optional[Dict[str, str]]=None,
|
1060
1060
|
) -> None:
|
1061
1061
|
self._m = buildzr.models.ComponentView()
|
@@ -1079,24 +1079,24 @@ class ComponentView(DslViewElement):
|
|
1079
1079
|
|
1080
1080
|
def _on_added(self, workspace: Workspace) -> None:
|
1081
1081
|
|
1082
|
-
from buildzr.dsl.expression import Expression,
|
1082
|
+
from buildzr.dsl.expression import Expression, WorkspaceExpression, ElementExpression, RelationshipExpression
|
1083
1083
|
from buildzr.models import ElementView, RelationshipView
|
1084
1084
|
|
1085
1085
|
if isinstance(self._selector, Container):
|
1086
1086
|
container = self._selector
|
1087
1087
|
else:
|
1088
|
-
container = self._selector(workspace)
|
1088
|
+
container = self._selector(WorkspaceExpression(workspace))
|
1089
1089
|
self._m.containerId = container.model.id
|
1090
1090
|
|
1091
1091
|
component_ids = { component.model.id for component in container.children }
|
1092
1092
|
|
1093
|
-
view_elements_filter: List[Union[DslElement, Callable[[
|
1093
|
+
view_elements_filter: List[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]] = [
|
1094
1094
|
lambda w, e: e.parent == container,
|
1095
1095
|
lambda w, e: any(component_ids.intersection({ id for id in e.sources.ids })),
|
1096
1096
|
lambda w, e: any(component_ids.intersection({ id for id in e.destinations.ids })),
|
1097
1097
|
]
|
1098
1098
|
|
1099
|
-
view_relationships_filter: List[Union[DslElement, Callable[[
|
1099
|
+
view_relationships_filter: List[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]] = [
|
1100
1100
|
lambda w, r: container == r.source.parent,
|
1101
1101
|
lambda w, r: container == r.destination.parent,
|
1102
1102
|
]
|
@@ -1128,7 +1128,7 @@ class ComponentView(DslViewElement):
|
|
1128
1128
|
|
1129
1129
|
class StyleElements:
|
1130
1130
|
|
1131
|
-
from buildzr.dsl.expression import
|
1131
|
+
from buildzr.dsl.expression import WorkspaceExpression, ElementExpression
|
1132
1132
|
|
1133
1133
|
Shapes = Union[
|
1134
1134
|
Literal['Box'],
|
@@ -1161,7 +1161,7 @@ class StyleElements:
|
|
1161
1161
|
on: List[Union[
|
1162
1162
|
DslElement,
|
1163
1163
|
Group,
|
1164
|
-
Callable[[
|
1164
|
+
Callable[[WorkspaceExpression, ElementExpression], bool],
|
1165
1165
|
Type[Union['Person', 'SoftwareSystem', 'Container', 'Component']],
|
1166
1166
|
str
|
1167
1167
|
]],
|
@@ -1204,7 +1204,7 @@ class StyleElements:
|
|
1204
1204
|
# item, not for each of `StyleElements` instance. This makes the styling
|
1205
1205
|
# makes more concise and flexible.
|
1206
1206
|
|
1207
|
-
from buildzr.dsl.expression import
|
1207
|
+
from buildzr.dsl.expression import ElementExpression
|
1208
1208
|
from uuid import uuid4
|
1209
1209
|
|
1210
1210
|
if background:
|
@@ -1277,7 +1277,7 @@ class StyleElements:
|
|
1277
1277
|
elif isinstance(element, str):
|
1278
1278
|
element_style.tag = element
|
1279
1279
|
elif callable(element):
|
1280
|
-
from buildzr.dsl.expression import
|
1280
|
+
from buildzr.dsl.expression import ElementExpression, Expression
|
1281
1281
|
if self._parent:
|
1282
1282
|
matched_elems = Expression(include_elements=[element]).elements(self._parent)
|
1283
1283
|
for e in matched_elems:
|
@@ -1293,7 +1293,7 @@ class StyleElements:
|
|
1293
1293
|
|
1294
1294
|
class StyleRelationships:
|
1295
1295
|
|
1296
|
-
from buildzr.dsl.expression import
|
1296
|
+
from buildzr.dsl.expression import WorkspaceExpression, RelationshipExpression
|
1297
1297
|
|
1298
1298
|
@property
|
1299
1299
|
def model(self) -> List[buildzr.models.RelationshipStyle]:
|
@@ -1308,7 +1308,7 @@ class StyleRelationships:
|
|
1308
1308
|
on: Optional[List[Union[
|
1309
1309
|
DslRelationship,
|
1310
1310
|
Group,
|
1311
|
-
Callable[[
|
1311
|
+
Callable[[WorkspaceExpression, RelationshipExpression], bool],
|
1312
1312
|
str
|
1313
1313
|
]]]=None,
|
1314
1314
|
thickness: Optional[int]=None,
|
@@ -10,6 +10,7 @@ from buildzr.dsl.dsl import (
|
|
10
10
|
SoftwareSystem,
|
11
11
|
Container,
|
12
12
|
Component,
|
13
|
+
TypedDynamicAttribute,
|
13
14
|
)
|
14
15
|
|
15
16
|
from buildzr.dsl.relations import _Relationship
|
@@ -47,12 +48,37 @@ class FlattenElement:
|
|
47
48
|
all_tags = all_tags.union(tags)
|
48
49
|
return all_tags
|
49
50
|
|
50
|
-
class
|
51
|
+
class WorkspaceExpression:
|
52
|
+
|
53
|
+
"""
|
54
|
+
A class used to filter the allowable methods and properties of the
|
55
|
+
`Structurizr DSL` workspace. This is used to filter the elements and
|
56
|
+
relationships in the workspace.
|
57
|
+
"""
|
58
|
+
|
59
|
+
def __init__(self, workspace: Workspace):
|
60
|
+
self._workspace = workspace
|
61
|
+
self._dynamic_attributes = self._workspace._dynamic_attrs
|
62
|
+
|
63
|
+
def software_system(self) -> TypedDynamicAttribute['SoftwareSystem']:
|
64
|
+
"""
|
65
|
+
Returns the software system of the workspace. This is used to filter the
|
66
|
+
elements and relationships in the workspace.
|
67
|
+
"""
|
68
|
+
return TypedDynamicAttribute['SoftwareSystem'](self._dynamic_attributes)
|
69
|
+
|
70
|
+
def person(self) -> TypedDynamicAttribute['Person']:
|
71
|
+
"""
|
72
|
+
Returns the person of the workspace. This is used to filter the elements
|
73
|
+
and relationships in the workspace.
|
74
|
+
"""
|
75
|
+
return TypedDynamicAttribute['Person'](self._dynamic_attributes)
|
76
|
+
|
77
|
+
class ElementExpression:
|
51
78
|
|
52
79
|
def __init__(self, element: DslElement):
|
53
80
|
self._element = element
|
54
81
|
|
55
|
-
# TODO: Make a test for this in `tests/test_expression.py`
|
56
82
|
@property
|
57
83
|
def id(self) -> str:
|
58
84
|
return cast(str, self._element.model.id)
|
@@ -102,7 +128,7 @@ class Element:
|
|
102
128
|
return isinstance(element, type(self._element)) and\
|
103
129
|
element.model.id == self._element.model.id
|
104
130
|
|
105
|
-
class
|
131
|
+
class RelationshipExpression:
|
106
132
|
|
107
133
|
def __init__(self, relationship: DslRelationship):
|
108
134
|
self._relationship = relationship
|
@@ -121,12 +147,12 @@ class Relationship:
|
|
121
147
|
return self._relationship.model.technology
|
122
148
|
|
123
149
|
@property
|
124
|
-
def source(self) ->
|
125
|
-
return
|
150
|
+
def source(self) -> ElementExpression:
|
151
|
+
return ElementExpression(self._relationship.source)
|
126
152
|
|
127
153
|
@property
|
128
|
-
def destination(self) ->
|
129
|
-
return
|
154
|
+
def destination(self) -> ElementExpression:
|
155
|
+
return ElementExpression(self._relationship.destination)
|
130
156
|
|
131
157
|
@property
|
132
158
|
def properties(self) -> Dict[str, Any]:
|
@@ -146,10 +172,10 @@ class Expression:
|
|
146
172
|
|
147
173
|
def __init__(
|
148
174
|
self,
|
149
|
-
include_elements: Iterable[Union[DslElement, Callable[[
|
150
|
-
exclude_elements: Iterable[Union[DslElement, Callable[[
|
151
|
-
include_relationships: Iterable[Union[DslElement, Callable[[
|
152
|
-
exclude_relationships: Iterable[Union[DslElement, Callable[[
|
175
|
+
include_elements: Iterable[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[lambda w, e: True],
|
176
|
+
exclude_elements: Iterable[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]]=[],
|
177
|
+
include_relationships: Iterable[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[lambda w, e: True],
|
178
|
+
exclude_relationships: Iterable[Union[DslElement, Callable[[WorkspaceExpression, RelationshipExpression], bool]]]=[],
|
153
179
|
) -> 'None':
|
154
180
|
self._include_elements = include_elements
|
155
181
|
self._exclude_elements = exclude_elements
|
@@ -171,12 +197,12 @@ class Expression:
|
|
171
197
|
if isinstance(f, DslElement):
|
172
198
|
includes.append(f == element)
|
173
199
|
else:
|
174
|
-
includes.append(f(workspace,
|
200
|
+
includes.append(f(WorkspaceExpression(workspace), ElementExpression(element)))
|
175
201
|
for f in self._exclude_elements:
|
176
202
|
if isinstance(f, DslElement):
|
177
203
|
excludes.append(f == element)
|
178
204
|
else:
|
179
|
-
excludes.append(f(workspace,
|
205
|
+
excludes.append(f(WorkspaceExpression(workspace), ElementExpression(element)))
|
180
206
|
if any(includes) and not any(excludes):
|
181
207
|
filtered_elements.append(element)
|
182
208
|
|
@@ -198,9 +224,9 @@ class Expression:
|
|
198
224
|
filtered_relationships: List[DslRelationship] = []
|
199
225
|
|
200
226
|
def _is_relationship_of_excluded_elements(
|
201
|
-
workspace:
|
202
|
-
relationship:
|
203
|
-
exclude_element_predicates: Iterable[Union[DslElement, Callable[[
|
227
|
+
workspace: WorkspaceExpression,
|
228
|
+
relationship: RelationshipExpression,
|
229
|
+
exclude_element_predicates: Iterable[Union[DslElement, Callable[[WorkspaceExpression, ElementExpression], bool]]],
|
204
230
|
) -> bool:
|
205
231
|
for f in exclude_element_predicates:
|
206
232
|
if isinstance(f, DslElement):
|
@@ -222,20 +248,20 @@ class Expression:
|
|
222
248
|
if isinstance(f, DslElement):
|
223
249
|
includes.append(f == relationship)
|
224
250
|
else:
|
225
|
-
includes.append(f(workspace,
|
251
|
+
includes.append(f(WorkspaceExpression(workspace), RelationshipExpression(relationship)))
|
226
252
|
|
227
253
|
for f in self._exclude_relationships:
|
228
254
|
if isinstance(f, DslElement):
|
229
255
|
excludes.append(f == relationship)
|
230
256
|
else:
|
231
|
-
excludes.append(f(workspace,
|
257
|
+
excludes.append(f(WorkspaceExpression(workspace), RelationshipExpression(relationship)))
|
232
258
|
|
233
259
|
# Also exclude relationships whose source or destination elements
|
234
260
|
# are excluded.
|
235
261
|
excludes.append(
|
236
262
|
_is_relationship_of_excluded_elements(
|
237
|
-
workspace,
|
238
|
-
|
263
|
+
WorkspaceExpression(workspace),
|
264
|
+
RelationshipExpression(relationship),
|
239
265
|
self._exclude_elements,
|
240
266
|
)
|
241
267
|
)
|
@@ -27,12 +27,12 @@ class GroupsSample(AbstractBuilder):
|
|
27
27
|
)
|
28
28
|
SystemContextView(
|
29
29
|
key='groups-sample-a',
|
30
|
-
software_system_selector=lambda w:
|
30
|
+
software_system_selector=lambda w: w.software_system().a,
|
31
31
|
description="Groups Sample - Software System A"
|
32
32
|
)
|
33
33
|
SystemContextView(
|
34
34
|
key='groups-sample-b',
|
35
|
-
software_system_selector=lambda w:
|
35
|
+
software_system_selector=lambda w: w.software_system().b,
|
36
36
|
description="Groups Sample - Software System B"
|
37
37
|
)
|
38
38
|
ContainerView(
|
@@ -24,7 +24,7 @@ class SampleImpliedRelationships(AbstractBuilder):
|
|
24
24
|
w.apply_view(
|
25
25
|
SystemContextView(
|
26
26
|
key='sample-implied-relationships',
|
27
|
-
software_system_selector=lambda w:
|
27
|
+
software_system_selector=lambda w: w.software_system().s,
|
28
28
|
description="Sample Implied Relationships"
|
29
29
|
)
|
30
30
|
)
|
@@ -1 +0,0 @@
|
|
1
|
-
VERSION = "0.0.12"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|