Fix 3-col calculator labelling and add lint
This commit is contained in:
20
migrate.py
20
migrate.py
@@ -187,6 +187,11 @@ def process():
|
||||
except:
|
||||
pass
|
||||
|
||||
# Give 3-col calculators honest display names instead of "A to B"
|
||||
if c_type in ['3col', '3col-mul'] and split_conversion_name(display_name):
|
||||
op = '*' if c_type == '3col-mul' else '/'
|
||||
display_name = f"{in1} {op} {in2}"
|
||||
|
||||
# Avoid escaping single quotes by using JSON or dict
|
||||
entry = {
|
||||
'slug': slug,
|
||||
@@ -200,11 +205,16 @@ def process():
|
||||
# Determine labels
|
||||
labels = {'in1': in1, 'in2': in2}
|
||||
if c_type in ['3col', '3col-mul']:
|
||||
# generic 3rd label
|
||||
if 'watts' in slug and 'amps' in slug: labels['in3'] = 'Volts'
|
||||
elif 'lumens' in slug: labels['in3'] = 'Area (sq m)'
|
||||
elif 'moles' in slug: labels['in3'] = 'Molar Mass'
|
||||
else: labels['in3'] = 'Result'
|
||||
# generic 3rd label; make it descriptive instead of the vague "Result"
|
||||
if 'watts' in slug and 'amps' in slug:
|
||||
labels['in3'] = 'Volts'
|
||||
elif 'lumens' in slug:
|
||||
labels['in3'] = 'Area (sq m)'
|
||||
elif 'moles' in slug:
|
||||
labels['in3'] = 'Molar Mass'
|
||||
else:
|
||||
op = '*' if c_type == '3col-mul' else '/'
|
||||
labels['in3'] = f"{in1} {op} {in2}"
|
||||
|
||||
if custom_labels:
|
||||
labels = custom_labels
|
||||
|
||||
Reference in New Issue
Block a user