Fix post-merge bugs
This commit is contained in:
parent
5fbe3e6b7e
commit
94731cdf81
@ -145,7 +145,8 @@ class Harness:
|
|||||||
f'IPN: {cable.internal_part_number}' if (cable.internal_part_number and not isinstance(cable.internal_part_number, list)) else '']
|
f'IPN: {cable.internal_part_number}' if (cable.internal_part_number and not isinstance(cable.internal_part_number, list)) else '']
|
||||||
identification = list(filter(None, identification))
|
identification = list(filter(None, identification))
|
||||||
|
|
||||||
attributes = [f'{len(cable.colors)}x' if cable.show_wirecount else '',
|
attributes = [f'{cable.type}' if cable.type else '',
|
||||||
|
f'{len(cable.colors)}x' if cable.show_wirecount else '',
|
||||||
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else '',
|
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else '',
|
||||||
'+ S' if cable.shield else '',
|
'+ S' if cable.shield else '',
|
||||||
f'{cable.length} m' if cable.length > 0 else '']
|
f'{cable.length} m' if cable.length > 0 else '']
|
||||||
@ -343,7 +344,7 @@ class Harness:
|
|||||||
item['manufacturer part number'] = shared.manufacturer_part_number
|
item['manufacturer part number'] = shared.manufacturer_part_number
|
||||||
if shared.internal_part_number is not None: # set part number only if it exists
|
if shared.internal_part_number is not None: # set part number only if it exists
|
||||||
item['internal part number'] = shared.internal_part_number
|
item['internal part number'] = shared.internal_part_number
|
||||||
bom_cables.append(item)
|
bom_cables.append(item)
|
||||||
# bundles (ignores wirecount)
|
# bundles (ignores wirecount)
|
||||||
wirelist = []
|
wirelist = []
|
||||||
# list all cables again, since bundles are represented as wires internally, with the category='bundle' set
|
# list all cables again, since bundles are represented as wires internally, with the category='bundle' set
|
||||||
@ -354,14 +355,14 @@ class Harness:
|
|||||||
shared = next(iter(items.values()))
|
shared = next(iter(items.values()))
|
||||||
for bundle in items.values():
|
for bundle in items.values():
|
||||||
# add each wire from each bundle to the wirelist
|
# add each wire from each bundle to the wirelist
|
||||||
for color in bundle.colors:
|
for index, color in enumerate(bundle.colors, 0):
|
||||||
wireinfo = {'gauge': shared.gauge, 'gauge_unit': shared.gauge_unit, 'length': shared.length, 'color': color, 'designator': bundle.name}
|
wireinfo = {'gauge': shared.gauge, 'gauge_unit': shared.gauge_unit, 'length': shared.length, 'color': color, 'designator': bundle.name}
|
||||||
wireinfo['manufacturer'] = bundle.manufacturer[index] if isinstance(bundle.manufacturer, list) else None
|
wireinfo['manufacturer'] = bundle.manufacturer[index] if isinstance(bundle.manufacturer, list) else None
|
||||||
wireinfo['manufacturer part number'] = bundle.manufacturer_part_number[index] if isinstance(bundle.manufacturer_part_number, list) else None
|
wireinfo['manufacturer part number'] = bundle.manufacturer_part_number[index] if isinstance(bundle.manufacturer_part_number, list) else None
|
||||||
wireinfo['internal part number'] = bundle.internal_part_number[index] if isinstance(bundle.internal_part_number, list) else None
|
wireinfo['internal part number'] = bundle.internal_part_number[index] if isinstance(bundle.internal_part_number, list) else None
|
||||||
wirelist.append(wireinfo)
|
wirelist.append(wireinfo)
|
||||||
# join similar wires from all the bundles to a single BOM item
|
# join similar wires from all the bundles to a single BOM item
|
||||||
wire_group = lambda w: (w['type'], w['gauge'], w['gauge_unit'], w['color'], w['manufacturer'], w['manufacturer part number'], w['internal part number'])
|
wire_group = lambda w: (w.get('type', None), w['gauge'], w['gauge_unit'], w['color'], w['manufacturer'], w['manufacturer part number'], w['internal part number'])
|
||||||
groups = Counter([wire_group(v) for v in wirelist])
|
groups = Counter([wire_group(v) for v in wirelist])
|
||||||
for group in groups:
|
for group in groups:
|
||||||
items = [v for v in wirelist if wire_group(v) == group]
|
items = [v for v in wirelist if wire_group(v) == group]
|
||||||
@ -371,9 +372,9 @@ class Harness:
|
|||||||
designators = list(dict.fromkeys(designators))
|
designators = list(dict.fromkeys(designators))
|
||||||
designators.sort()
|
designators.sort()
|
||||||
total_length = sum(i['length'] for i in items)
|
total_length = sum(i['length'] for i in items)
|
||||||
wire_type = f', {shared["type"]}' if shared['type'] else ''
|
wire_type = f', {shared["type"]}' if 'type' in shared else ''
|
||||||
gauge_name = f', {shared["gauge"]} {shared["gauge_unit"]}' if shared['gauge'] else ''
|
gauge_name = f', {shared["gauge"]} {shared["gauge_unit"]}' if 'gauge' in shared else ''
|
||||||
gauge_color = f', {shared["color"]}' if shared['color'] != '' else ''
|
gauge_color = f', {shared["color"]}' if 'color' in shared != '' else ''
|
||||||
name = f'Wire{wire_type}{gauge_name}{gauge_color}'
|
name = f'Wire{wire_type}{gauge_name}{gauge_color}'
|
||||||
item = {'item': name, 'qty': round(total_length, 3), 'unit': 'm', 'designators': designators}
|
item = {'item': name, 'qty': round(total_length, 3), 'unit': 'm', 'designators': designators}
|
||||||
if shared['manufacturer'] is not None: # set manufacturer only if it exists
|
if shared['manufacturer'] is not None: # set manufacturer only if it exists
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user