Add base conversions and refresh palette theme
This commit is contained in:
15
migrate.py
15
migrate.py
@@ -76,6 +76,8 @@ def guess_category(name):
|
||||
if any(x in name_l for x in ['binary', 'hex', 'octal', 'decimal', 'ascii', 'fraction']): return 'number-systems'
|
||||
if any(x in name_l for x in ['becquerel', 'curie', 'gray', 'rad', 'sievert', 'rem', 'roentgen', 'rutherford']): return 'radiation'
|
||||
if any(x in name_l for x in ['volt', 'amp', 'ohm', 'siemens', 'farad', 'henry', 'coulomb']): return 'electrical'
|
||||
if any(x in name_l for x in ['binary', 'hex', 'octal', 'decimal', 'base']):
|
||||
return 'number-systems'
|
||||
return 'other'
|
||||
|
||||
def process():
|
||||
@@ -193,6 +195,19 @@ def process():
|
||||
if 'decimal' in slug:
|
||||
if slug.startswith('decimal'): entry['fromBase'] = 10
|
||||
else: entry['toBase'] = 10
|
||||
if 'base-' in slug:
|
||||
parts = slug.split('-')
|
||||
if len(parts) >= 5 and parts[0] == 'base' and parts[2] == 'to' and parts[3] == 'base':
|
||||
try:
|
||||
entry.setdefault('fromBase', int(parts[1]))
|
||||
entry.setdefault('toBase', int(parts[4]))
|
||||
except ValueError:
|
||||
pass
|
||||
if 'base' in factor_raw.lower():
|
||||
match = re.search(r'base\\s*(\\d+)\\s*(?:→|to)\\s*(?:base\\s*)?(\\d+)', factor_raw, re.IGNORECASE)
|
||||
if match:
|
||||
entry.setdefault('fromBase', int(match.group(1)))
|
||||
entry.setdefault('toBase', int(match.group(2)))
|
||||
|
||||
if category == 'data' and c_type == 'standard':
|
||||
# Fix data scale names and factors
|
||||
|
||||
Reference in New Issue
Block a user