Skip to content
Snippets Groups Projects
Commit 67328284 authored by Hock, Martin's avatar Hock, Martin
Browse files

Fix some label in dict issues. Fix optional label parameter typing.

Fix Assembly property parameter options.
parent 33f28032
No related branches found
No related tags found
1 merge request!3Merge to main to create "WS2223" Version
Pipeline #928993 failed
...@@ -50,9 +50,9 @@ class LegoComponent: ...@@ -50,9 +50,9 @@ class LegoComponent:
def clone(self, new_label: str = None) -> LegoComponent: def clone(self, new_label: Optional[str] = None) -> LegoComponent:
if new_label is None: if new_label is None:
new_label = self.properties.label new_label = self.properties['label']
clone = LegoComponent(None, None, self.properties) clone = LegoComponent(None, None, self.properties)
clone.properties['label'] = new_label clone.properties['label'] = new_label
return clone return clone
...@@ -68,7 +68,6 @@ class LegoComponent: ...@@ -68,7 +68,6 @@ class LegoComponent:
def to_dict(self) -> Dict: def to_dict(self) -> Dict:
dict_ = { dict_ = {
"uuid": self.uuid, "uuid": self.uuid,
"label": self.label,
"properties": self.properties, "properties": self.properties,
"layer": self.layer, "layer": self.layer,
} }
...@@ -93,10 +92,16 @@ class LegoAssembly: ...@@ -93,10 +92,16 @@ class LegoAssembly:
self.uuid: uuid.UUID = uuid.uuid4() self.uuid: uuid.UUID = uuid.uuid4()
self.parent: None | LegoAssembly = None self.parent: None | LegoAssembly = None
self.properties: dict = {} self.properties: dict = {}
self.layer: AggregationLayer = layer
if label is not None: if label is not None:
self.properties['label'] = label self.properties['label'] = label
self.layer: AggregationLayer = layer for prop in properties:
self.properties.update(properties) if isinstance(prop, dict):
self.properties.update(prop)
else:
raise ValueError(f"Unexpected argument type: {type(properties)}")
for key, value in kwargs.items():
self.properties[key] = value
self.components: List[LegoComponent] = [] self.components: List[LegoComponent] = []
self.assemblies: List[LegoAssembly] = [] self.assemblies: List[LegoAssembly] = []
...@@ -249,6 +254,3 @@ class KPIEncoder(json.JSONEncoder): ...@@ -249,6 +254,3 @@ class KPIEncoder(json.JSONEncoder):
return "kpi-" + str(o) return "kpi-" + str(o)
if isinstance(o, (AggregationLayer)): if isinstance(o, (AggregationLayer)):
return "kpi-" + o.properties.label return "kpi-" + o.properties.label
return super().default(o)
pass
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment