buildzr 0.0.16__py3-none-any.whl → 0.0.17__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.17"
buildzr/dsl/dsl.py CHANGED
@@ -133,12 +133,21 @@ 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
+ This process is idempotent, which means this can be called multiple times
143
+ without duplicating similar relationships.
144
+ """
145
+
146
+ if not self._use_implied_relationships:
147
+ return
148
+
136
149
  from buildzr.dsl.explorer import Explorer
137
150
 
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
151
  explorer = Explorer(self)
143
152
  relationships = list(explorer.walk_relationships())
144
153
  for relationship in relationships:
@@ -201,8 +210,7 @@ class Workspace(DslWorkspaceElement):
201
210
  else:
202
211
  raise ValueError('Invalid element type: Trying to add an element of type {} to a workspace.'.format(type(model)))
203
212
 
204
- def apply_view(
205
- self,
213
+ def apply_view( self,
206
214
  view: Union[
207
215
  'SystemLandscapeView',
208
216
  'SystemContextView',
@@ -212,6 +220,8 @@ class Workspace(DslWorkspaceElement):
212
220
  ]
213
221
  ) -> None:
214
222
 
223
+ self._imply_relationships()
224
+
215
225
  view._on_added(self)
216
226
 
217
227
  if not self.model.views:
@@ -269,10 +279,14 @@ class Workspace(DslWorkspaceElement):
269
279
  else:
270
280
  self.model.views.configuration.styles.relationships = style.model
271
281
 
272
- def to_json(self, path: str) -> None:
282
+ def to_json(self, path: str, pretty: bool=False) -> None:
283
+
284
+ self._imply_relationships()
285
+
273
286
  from buildzr.sinks.json_sink import JsonSink, JsonSinkConfig
274
287
  sink = JsonSink()
275
- sink.write(workspace=self.model, config=JsonSinkConfig(path=path))
288
+ sink.write(workspace=self.model, config=JsonSinkConfig(path=path, pretty=pretty))
289
+
276
290
 
277
291
  def _add_dynamic_attr(self, name: str, model: Union['Person', 'SoftwareSystem']) -> None:
278
292
  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.17
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=FuXai4m-tgRgZ8KBZ-0FvcOhuA5UBAazPvu_4YgO1kY,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=l3eM3WtcBMcoroXgn2gKaMluFb4rQUrFSRx89kuGshc,83901
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.17.dist-info/METADATA,sha256=hHN9k8oQtuVu0hKASmJpvvoXl7GP1ZbfDdquEWbWlcU,6596
22
+ buildzr-0.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ buildzr-0.0.17.dist-info/licenses/LICENSE.md,sha256=e8e6W6tL4MbBY-c-gXMgDbaMf_BnaQDQv4Yoy42b-CI,1070
24
+ buildzr-0.0.17.dist-info/RECORD,,