Rename extra variable to part for consistency
This commit is contained in:
parent
c22c42e722
commit
d6d0d2a486
@ -16,13 +16,13 @@ def get_additional_component_table(harness: "Harness", component: Union[Connecto
|
|||||||
rows = []
|
rows = []
|
||||||
if component.additional_components:
|
if component.additional_components:
|
||||||
rows.append(["Additional components"])
|
rows.append(["Additional components"])
|
||||||
for extra in component.additional_components:
|
for part in component.additional_components:
|
||||||
qty = extra.qty * component.get_qty_multiplier(extra.qty_multiplier)
|
qty = part.qty * component.get_qty_multiplier(part.qty_multiplier)
|
||||||
if harness.mini_bom_mode:
|
if harness.mini_bom_mode:
|
||||||
id = get_bom_index(harness.bom(), extra)
|
id = get_bom_index(harness.bom(), part)
|
||||||
rows.append(component_table_entry(f'#{id} ({extra.type.rstrip()})', qty, extra.unit))
|
rows.append(component_table_entry(f'#{id} ({part.type.rstrip()})', qty, part.unit))
|
||||||
else:
|
else:
|
||||||
rows.append(component_table_entry(extra.description, qty, extra.unit, extra.pn, extra.manufacturer, extra.mpn))
|
rows.append(component_table_entry(part.description, qty, part.unit, part.pn, part.manufacturer, part.mpn))
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOMEntry]:
|
def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOMEntry]:
|
||||||
@ -116,10 +116,10 @@ def generate_bom(harness: "Harness") -> List[BOMEntry]:
|
|||||||
# add an incrementing id to each bom item
|
# add an incrementing id to each bom item
|
||||||
return [{**entry, 'id': index} for index, entry in enumerate(bom, 1)]
|
return [{**entry, 'id': index} for index, entry in enumerate(bom, 1)]
|
||||||
|
|
||||||
def get_bom_index(bom: List[BOMEntry], extra: AdditionalComponent) -> int:
|
def get_bom_index(bom: List[BOMEntry], part: AdditionalComponent) -> int:
|
||||||
"""Return id of BOM entry or raise StopIteration if not found."""
|
"""Return id of BOM entry or raise StopIteration if not found."""
|
||||||
# Remove linebreaks and clean whitespace of values in search
|
# Remove linebreaks and clean whitespace of values in search
|
||||||
target = tuple(clean_whitespace(v) for v in bom_types_group({**asdict(extra), 'item': extra.description}))
|
target = tuple(clean_whitespace(v) for v in bom_types_group({**asdict(part), 'item': part.description}))
|
||||||
return next(entry['id'] for entry in bom if bom_types_group(entry) == target)
|
return next(entry['id'] for entry in bom if bom_types_group(entry) == target)
|
||||||
|
|
||||||
def bom_list(bom: List[BOMEntry]) -> List[List[str]]:
|
def bom_list(bom: List[BOMEntry]) -> List[List[str]]:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user