Implement a modular vehicle decoding system
- Add Komatsu specific rules - Possibility to expand to any brand
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# File: vehicle/__init__.py
|
||||
# Copyright (C) 2026 Erick Ahmed
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import importlib
|
||||
|
||||
def get_vehicle_module(brand: str):
|
||||
"""
|
||||
Dynamically imports the correct decoder module based on the vehicle brand.
|
||||
Falls back to 'vehicle.generic' if a specific brand module is not found.
|
||||
"""
|
||||
if not brand:
|
||||
return importlib.import_module("vehicle.generic")
|
||||
|
||||
module_name = f"vehicle.{brand.lower().replace(' ', '_')}"
|
||||
try:
|
||||
return importlib.import_module(module_name)
|
||||
except ModuleNotFoundError:
|
||||
return importlib.import_module("vehicle.generic")
|
||||
Reference in New Issue
Block a user