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):
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.parent: None | LegoAssembly = None
self.layer: AggregationLayer = AggregationLayer.COMPONENT
self.properties: dict = {}
if name is not None:
self.properties['name'] = name
if label is not None:
self.properties['label'] = label
if datasheet is not None:
self.properties.update(datasheet)
self.properties[]
......@@ -68,7 +68,7 @@ class LegoComponent:
def to_dict(self) -> Dict:
ATTRIBUTES = [
"uuid",
"name",
"label",
"category",
"lego_id",
"cost",
......@@ -96,16 +96,16 @@ class LegoComponent:
# TODO good repr representation
def __repr__(self):
return f"LegoComponent {self.properties['name']} [{self.uuid}]"
return f"LegoComponent {self.properties['label']} [{self.uuid}]"
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.parent: None | LegoAssembly = None
self.properties: dict = {}
if name is not None:
self.properties['name'] = name
if label is not None:
self.properties['label'] = label
self.layer: AggregationLayer = layer
self.properties.update(properties)
self.components: List[LegoComponent] = []
......@@ -172,7 +172,7 @@ class LegoAssembly:
return False
def to_dict(self) -> Dict:
ATTRIBUTES = ["uuid", "name", "layer", "properties"]
ATTRIBUTES = ["uuid", "label", "layer", "properties"]
dict_ = {}
# store attributes
for attr in ATTRIBUTES:
......@@ -185,7 +185,7 @@ class LegoAssembly:
# TODO find good string representation
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):
......@@ -214,5 +214,5 @@ class KPIEncoder(json.JSONEncoder):
if isinstance(o, uuid.UUID):
return "kpi-" + str(o)
if isinstance(o, (AggregationLayer)):
return "kpi-" + o.name
return "kpi-" + o.label
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