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

rename name to label to make merge easier

parent acd86242
No related branches found
No related tags found
No related merge requests found
...@@ -29,13 +29,13 @@ class AggregationLayer(Enum): ...@@ -29,13 +29,13 @@ class AggregationLayer(Enum):
class LegoComponent: class LegoComponent:
def __init__(self, name: Optional[str] = None, datasheet: Optional[dict] = None, *more_properties: dict, **kwargs) -> None: def __init__(self, label: Optional[str] = None, datasheet: Optional[dict] = None, *more_properties: dict, **kwargs) -> None:
self.uuid: uuid.UUID = uuid.uuid4() self.uuid: uuid.UUID = uuid.uuid4()
self.parent: None | LegoAssembly = None self.parent: None | LegoAssembly = None
self.layer: AggregationLayer = AggregationLayer.COMPONENT self.layer: AggregationLayer = AggregationLayer.COMPONENT
self.properties: dict = {} self.properties: dict = {}
if name is not None: if label is not None:
self.properties['name'] = name self.properties['label'] = label
if datasheet is not None: if datasheet is not None:
self.properties.update(datasheet) self.properties.update(datasheet)
self.properties[] self.properties[]
...@@ -68,7 +68,7 @@ class LegoComponent: ...@@ -68,7 +68,7 @@ class LegoComponent:
def to_dict(self) -> Dict: def to_dict(self) -> Dict:
ATTRIBUTES = [ ATTRIBUTES = [
"uuid", "uuid",
"name", "label",
"category", "category",
"lego_id", "lego_id",
"cost", "cost",
...@@ -96,16 +96,16 @@ class LegoComponent: ...@@ -96,16 +96,16 @@ class LegoComponent:
# TODO good repr representation # TODO good repr representation
def __repr__(self): def __repr__(self):
return f"LegoComponent {self.properties['name']} [{self.uuid}]" return f"LegoComponent {self.properties['label']} [{self.uuid}]"
class LegoAssembly: class LegoAssembly:
def __init__(self, layer: AggregationLayer, name: Optional[str] = None, *properties: dict , **kwargs) -> None: def __init__(self, layer: AggregationLayer, label: Optional[str] = None, *properties: dict , **kwargs) -> None:
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 = {}
if name is not None: if label is not None:
self.properties['name'] = name self.properties['label'] = label
self.layer: AggregationLayer = layer self.layer: AggregationLayer = layer
self.properties.update(properties) self.properties.update(properties)
self.components: List[LegoComponent] = [] self.components: List[LegoComponent] = []
...@@ -172,7 +172,7 @@ class LegoAssembly: ...@@ -172,7 +172,7 @@ class LegoAssembly:
return False return False
def to_dict(self) -> Dict: def to_dict(self) -> Dict:
ATTRIBUTES = ["uuid", "name", "layer", "properties"] ATTRIBUTES = ["uuid", "label", "layer", "properties"]
dict_ = {} dict_ = {}
# store attributes # store attributes
for attr in ATTRIBUTES: for attr in ATTRIBUTES:
...@@ -185,7 +185,7 @@ class LegoAssembly: ...@@ -185,7 +185,7 @@ class LegoAssembly:
# TODO find good string representation # TODO find good string representation
def __repr__(self): def __repr__(self):
return f"LegoAssembly {self.properties['name']} [{self.uuid}]" return f"LegoAssembly {self.properties['label']} [{self.uuid}]"
def print_assembly_tree(root, level=0, is_last=False): def print_assembly_tree(root, level=0, is_last=False):
...@@ -214,5 +214,5 @@ class KPIEncoder(json.JSONEncoder): ...@@ -214,5 +214,5 @@ class KPIEncoder(json.JSONEncoder):
if isinstance(o, uuid.UUID): if isinstance(o, uuid.UUID):
return "kpi-" + str(o) return "kpi-" + str(o)
if isinstance(o, (AggregationLayer)): if isinstance(o, (AggregationLayer)):
return "kpi-" + o.name return "kpi-" + o.label
return super().default(o) return super().default(o)
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