Add next calculator batch incl molarity and SWG

This commit is contained in:
Codex Agent
2026-03-08 02:19:18 +00:00
parent 5e974ea9c7
commit 1e341f051f
4 changed files with 161 additions and 43 deletions

View File

@@ -104,6 +104,8 @@ def process():
in1, in2 = parsed
else:
in1, in2 = "From", "To"
custom_labels = None
category = normalize_category(category_raw)
if not category:
@@ -120,14 +122,23 @@ def process():
offset_val = "0"
# Special-case calculator families that require custom math beyond simple factors.
if 'ev-to-lux' in slug or 'lux-to-ev' in slug:
if 'molarity-to-grams-per-liter' == slug:
c_type = 'molarity'
custom_labels = {'in1': 'Molarity (mol/L)', 'in2': 'Grams per liter', 'in3': 'Molar mass (g/mol)'}
elif 'rockwell-c-to-vickers' == slug:
c_type = 'rockwell-vickers'
elif 'ev-to-lux' in slug or 'lux-to-ev' in slug:
c_type = 'ev-lux'
elif 'focal-length-to-angle-of-view' in slug:
c_type = 'aov'
elif 'awg' in slug:
c_type = 'awg'
elif 'swg-to' in slug or '-to-swg' in slug:
c_type = 'swg'
elif 'brinell-to-rockwell-c' == slug or 'rockwell-c-to-brinell' == slug:
c_type = 'brinell-rockwell'
elif 'saybolt-universal-seconds-to-centistokes' == slug:
c_type = 'sus-cst'
elif '1/x' in factor_raw:
c_type = 'inverse'
factor_val = "1"
@@ -194,6 +205,9 @@ def process():
elif 'lumens' in slug: labels['in3'] = 'Area (sq m)'
elif 'moles' in slug: labels['in3'] = 'Molar Mass'
else: labels['in3'] = 'Result'
if custom_labels:
labels = custom_labels
entry['labels'] = labels
@@ -305,7 +319,7 @@ def process():
# Ensure types are right
# write to TS
out = """// THIS FILE IS AUTO-GENERATED BY migrate.py
export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell' | 'ev-lux' | 'aov';
export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell' | 'ev-lux' | 'aov' | 'swg' | 'rockwell-vickers' | 'sus-cst' | 'molarity';
export interface CalculatorDef {
slug: string;