Fix for Designators apearing across all colours of wires of a guage. (#37)

The wirelist for the bom now has individual designators added. this also 
alows for the removal of designator list merging later.
This commit is contained in:
Tyler Ward 2020-06-28 21:58:24 +01:00 committed by GitHub
parent 0a42b350c8
commit a3728f52ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -287,15 +287,13 @@ class Harness:
for bundle in items.values():
# add each wire from each bundle to the wirelist
for color in bundle.colors:
wirelist.append({'gauge': shared.gauge, 'gauge_unit': shared.gauge_unit, 'length': shared.length, 'color': color, 'designators': list(items.keys())})
wirelist.append({'gauge': shared.gauge, 'gauge_unit': shared.gauge_unit, 'length': shared.length, 'color': color, 'designator': bundle.name})
# join similar wires from all the bundles to a single BOM item
types = Counter([(v['gauge'], v['gauge_unit'], v['color']) for v in wirelist])
for type in types:
items = [v for v in wirelist if (v['gauge'], v['gauge_unit'], v['color']) == type]
shared = items[0]
designators = [i['designators'] for i in items]
# flatten nested list
designators = [item for sublist in designators for item in sublist] # https://stackoverflow.com/a/952952
designators = [i['designator'] for i in items]
# remove duplicates
designators = list(dict.fromkeys(designators))
designators.sort()