buildzr 0.0.16__py3-none-any.whl → 0.0.18__py3-none-any.whl

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/__about__.py CHANGED
@@ -1 +1 @@
1
- VERSION = "0.0.16"
1
+ VERSION = "0.0.18"
buildzr/dsl/dsl.py CHANGED
@@ -133,12 +133,24 @@ class Workspace(DslWorkspaceElement):
133
133
  self,
134
134
  ) -> None:
135
135
 
136
+ """
137
+ Process implied relationships:
138
+ If we have relationship s >> do >> a.b, then create s >> do >> a.
139
+ If we have relationship s.ss >> do >> a.b.c, then create s.ss >> do >> a.b and s.ss >> do >> a.
140
+ And so on...
141
+
142
+ Relationships of `SoftwareSystemInstance`s and `ContainerInstance`s are
143
+ skipped.
144
+
145
+ This process is idempotent, which means this can be called multiple times
146
+ without duplicating similar relationships.
147
+ """
148
+
149
+ if not self._use_implied_relationships:
150
+ return
151
+
136
152
  from buildzr.dsl.explorer import Explorer
137
153
 
138
- # Process implied relationships:
139
- # If we have relationship s >> do >> a.b, then create s >> do >> a.
140
- # If we have relationship s.ss >> do >> a.b.c, then create s.ss >> do >> a.b and s.ss >> do >> a.
141
- # And so on...
142
154
  explorer = Explorer(self)
143
155
  relationships = list(explorer.walk_relationships())
144
156
  for relationship in relationships:
@@ -146,6 +158,10 @@ class Workspace(DslWorkspaceElement):
146
158
  destination = relationship.destination
147
159
  destination_parent = destination.parent
148
160
 
161
+ if isinstance(source, (SoftwareSystemInstance, ContainerInstance)) or \
162
+ isinstance(destination, (SoftwareSystemInstance, ContainerInstance)):
163
+ continue
164
+
149
165
  while destination_parent is not None and \
150
166
  isinstance(source, DslElement) and \
151
167
  not isinstance(source.model, buildzr.models.Workspace) and \
@@ -201,8 +217,7 @@ class Workspace(DslWorkspaceElement):
201
217
  else:
202
218
  raise ValueError('Invalid element type: Trying to add an element of type {} to a workspace.'.format(type(model)))
203
219
 
204
- def apply_view(
205
- self,
220
+ def apply_view( self,
206
221
  view: Union[
207
222
  'SystemLandscapeView',
208
223
  'SystemContextView',
@@ -212,6 +227,8 @@ class Workspace(DslWorkspaceElement):
212
227
  ]
213
228
  ) -> None:
214
229
 
230
+ self._imply_relationships()
231
+
215
232
  view._on_added(self)
216
233
 
217
234
  if not self.model.views:
@@ -269,10 +286,14 @@ class Workspace(DslWorkspaceElement):
269
286
  else:
270
287
  self.model.views.configuration.styles.relationships = style.model
271
288
 
272
- def to_json(self, path: str) -> None:
289
+ def to_json(self, path: str, pretty: bool=False) -> None:
290
+
291
+ self._imply_relationships()
292
+
273
293
  from buildzr.sinks.json_sink import JsonSink, JsonSinkConfig
274
294
  sink = JsonSink()
275
- sink.write(workspace=self.model, config=JsonSinkConfig(path=path))
295
+ sink.write(workspace=self.model, config=JsonSinkConfig(path=path, pretty=pretty))
296
+
276
297
 
277
298
  def _add_dynamic_attr(self, name: str, model: Union['Person', 'SoftwareSystem']) -> None:
278
299
  if isinstance(model, Person):
@@ -9,13 +9,15 @@ from buildzr.sinks.interfaces import Sink
9
9
  @dataclass
10
10
  class JsonSinkConfig:
11
11
  path: str
12
+ pretty: bool = False
12
13
 
13
14
  class JsonSink(Sink[JsonSinkConfig]):
14
15
 
15
16
  def write(self, workspace: Workspace, config: Optional[JsonSinkConfig]=None) -> None:
16
17
  if config is not None:
18
+ indent = 2 if config.pretty else None
17
19
  with open(config.path, 'w') as file:
18
- file.write(JsonEncoder().encode(workspace))
20
+ file.write(JsonEncoder(indent=indent).encode(workspace))
19
21
  else:
20
22
  import os
21
23
  workspace_name = workspace.name.replace(' ', '_').lower()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: buildzr
3
- Version: 0.0.16
3
+ Version: 0.0.18
4
4
  Summary: Structurizr for the `buildzr`s 🧱⚒️
5
5
  Project-URL: homepage, https://github.com/amirulmenjeni/buildzr
6
6
  Project-URL: issues, https://github.com/amirulmenjeni/buildzr/issues
@@ -1,8 +1,8 @@
1
- buildzr/__about__.py,sha256=MvdGbpTmBIYK5dBscl7yWMU6yLCpXFydvlTVcC84S3Y,19
1
+ buildzr/__about__.py,sha256=1LKzsaMbuDHBcCQ6ItSCPh_aBbnriHkKXEDMLVVsZJQ,19
2
2
  buildzr/__init__.py,sha256=hY-cOdjBQcz0v2m8cBF1oEJFIbcR3sWI-xww--0RKSo,99
3
3
  buildzr/dsl/__init__.py,sha256=qJ41IXcabKUjvwMzgfUCFdmDnSBBK7VFADpoVdOYLKQ,538
4
4
  buildzr/dsl/color.py,sha256=at5lo3WgLEDCjrnbu37ra1p1TjzdB51sxeW7pBMC_7U,4019
5
- buildzr/dsl/dsl.py,sha256=qqKlz8KNzAxdwsdPM5YhVE2JhwYMRJ9o7KbMMarQGlw,83579
5
+ buildzr/dsl/dsl.py,sha256=Z7dr0RLGMY5XKMtBTZJ9Kj1m6CAuA3TTTzLnpxR2SsE,84194
6
6
  buildzr/dsl/explorer.py,sha256=m1nI0Rd0bXGj1uXDgTC4DJhc2FMma522IepPNvQF07E,1853
7
7
  buildzr/dsl/expression.py,sha256=TLSe-uGlHhNqMPQU_5IRLIP-ZGsQ_ts3DquBMcYlwBg,11777
8
8
  buildzr/dsl/relations.py,sha256=GBs5epr9uuExU_H6VcP4XY76iJPQ__rz_d8tZlhhWQ4,11891
@@ -17,8 +17,8 @@ buildzr/models/generate.sh,sha256=EJ63d4cYmRnMFzc3hIR6bro44PXYEOt3EE9BxY4F8cU,16
17
17
  buildzr/models/models.py,sha256=NJOFYiRQ2i_1gP2ajPNpEfVLAz-1iCqqt1gPOHDPIks,42587
18
18
  buildzr/sinks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  buildzr/sinks/interfaces.py,sha256=LOZekP4WNjomD5J5f3FnZTwGj0aXMr6RbrvyFV5zn0E,383
20
- buildzr/sinks/json_sink.py,sha256=onKOZTpwOQfeMEj1ONkuIEHBAQhx4yQSqqI_lgZBaP8,777
21
- buildzr-0.0.16.dist-info/METADATA,sha256=3vLIL0l-KKsgnZN75CRzB-RfljV5HhpRLs6vdej8Dm4,6596
22
- buildzr-0.0.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- buildzr-0.0.16.dist-info/licenses/LICENSE.md,sha256=e8e6W6tL4MbBY-c-gXMgDbaMf_BnaQDQv4Yoy42b-CI,1070
24
- buildzr-0.0.16.dist-info/RECORD,,
20
+ buildzr/sinks/json_sink.py,sha256=w_16ulQl2s-J-Yokp6GvDhAhuqN8XggXyEHCUNETLu4,865
21
+ buildzr-0.0.18.dist-info/METADATA,sha256=naP5ylRsLZTmqIQkQay09BL7PKo8t_Cns3WzFJCTdhE,6596
22
+ buildzr-0.0.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ buildzr-0.0.18.dist-info/licenses/LICENSE.md,sha256=e8e6W6tL4MbBY-c-gXMgDbaMf_BnaQDQv4Yoy42b-CI,1070
24
+ buildzr-0.0.18.dist-info/RECORD,,