Fix faulty conversion of non-(mm2,AWG) units
The parsing allows arbitrary units to be used for cable dimensions -- this might be valid units, e.g. square inches, or invalid, e.g. bananas. We only allow conversion between mm2 and AWG, so check that the gauge_unit is either of those before conversion. If not, pass through as is.
This commit is contained in:
parent
2b307b00ae
commit
625b21ea52
@ -114,13 +114,15 @@ class Harness:
|
||||
|
||||
for _, cable in self.cables.items():
|
||||
|
||||
awg_fmt = ''
|
||||
if cable.show_equiv:
|
||||
# Only convert units we actually know about, i.e. currently
|
||||
# mm2 and awg --- other units _are_ technically allowed,
|
||||
# and passed through as-is.
|
||||
if cable.gauge_unit =='mm\u00B2':
|
||||
awg_fmt = f' ({awg_equiv(cable.gauge)} AWG)'
|
||||
else:
|
||||
elif cable.gauge_unit.upper() == 'AWG':
|
||||
awg_fmt = f' ({mm2_equiv(cable.gauge)} mm\u00B2)'
|
||||
else:
|
||||
awg_fmt = ''
|
||||
|
||||
attributes = [f'{len(cable.colors)}x' if cable.show_wirecount else '',
|
||||
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else '',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user