feat: basic trainer support
This commit is contained in:
26
tool/import_trainer_catalog.py
Normal file
26
tool/import_trainer_catalog.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Import selectable profiles from the firmware's measured model matrix.
|
||||
|
||||
Usage: python3 tool/import_trainer_catalog.py ../kettler2ant-rs
|
||||
The catalog is bundled offline. It is not proof of installed firmware support.
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
source = Path(sys.argv[1]) / 'universal-shifters/trainer-build-matrix.md'
|
||||
profiles = []
|
||||
for line in source.read_text().splitlines():
|
||||
cells = [cell.strip() for cell in line.split('|')[1:-1]]
|
||||
if len(cells) != 6 or not cells[1].startswith('`'):
|
||||
continue
|
||||
family, profile_id, name, equipment, selection, bundles = cells
|
||||
if 'configured' in selection or profile_id.strip('`') in ('schwinn-170', 'ifit-model-97'):
|
||||
continue
|
||||
profiles.append(dict(id=profile_id.strip('`'), name=name.replace('_', ' '),
|
||||
family=family, equipment=equipment,
|
||||
manual=selection == 'manual', bundles=bundles.split(', ')))
|
||||
if len(profiles) != 128:
|
||||
raise SystemExit(f'Expected 128 selectable profiles, found {len(profiles)}. Review registry changes.')
|
||||
target = Path(__file__).resolve().parents[1] / 'assets/trainer_models.json'
|
||||
target.write_text(json.dumps(profiles, indent=2) + '\n')
|
||||
print(f'Imported {len(profiles)} profiles to {target}')
|
||||
Reference in New Issue
Block a user