From 56bb9d2598f80cf16bc25be86d9b462f196cd323 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 20 Dec 2023 01:31:11 -0800 Subject: [PATCH] less nested --- selfdrive/debug/format_fingerprints.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/debug/format_fingerprints.py b/selfdrive/debug/format_fingerprints.py index b2bcc8d378..ade0193ade 100755 --- a/selfdrive/debug/format_fingerprints.py +++ b/selfdrive/debug/format_fingerprints.py @@ -11,7 +11,7 @@ Ecu = car.CarParams.Ecu CARS = get_interface_attr('CAR') FW_VERSIONS = get_interface_attr('FW_VERSIONS') FINGERPRINTS = get_interface_attr('FINGERPRINTS') -PLATFORM_TO_PYTHON_CAR_NAME = {brand: {car.value: car.name for car in CARS[brand]} for brand in CARS} +PLATFORM_TO_ENUM_NAME = {car.value: car.name for brand in CARS for car in CARS[brand]} ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} FINGERPRINTS_PY_TEMPLATE = jinja2.Template(""" @@ -30,7 +30,7 @@ Ecu = car.CarParams.Ecu {% if FINGERPRINTS[brand] %} FINGERPRINTS = { {% for car, fingerprints in FINGERPRINTS[brand].items() %} - CAR.{{PLATFORM_TO_PYTHON_CAR_NAME[brand][car]}}: [ + CAR.{{PLATFORM_TO_ENUM_NAME[car]}}: [ {% for fingerprint in fingerprints %} { {% for key, value in fingerprint.items() %}{{key}}: {{value}}{% if not loop.last %}, {% endif %}{% endfor %} @@ -44,7 +44,7 @@ FINGERPRINTS = { {% if FW_VERSIONS[brand] %} FW_VERSIONS = { {% for car, _ in FW_VERSIONS[brand].items() %} - CAR.{{PLATFORM_TO_PYTHON_CAR_NAME[brand][car]}}: { + CAR.{{PLATFORM_TO_ENUM_NAME[car]}}: { {% for key, fw_versions in FW_VERSIONS[brand][car].items() %} (Ecu.{{ECU_NAME[key[0]]}}, 0x{{"%0x" | format(key[1] | int)}}, \ {% if key[2] %}0x{{"%0x" | format(key[2] | int)}}{% else %}{{key[2]}}{% endif %}): [ @@ -62,7 +62,7 @@ FW_VERSIONS = { def format_brand_fw_versions(brand): with open(os.path.join(BASEDIR, f"selfdrive/car/{brand}/fingerprints.py"), "w") as f: - f.write(FINGERPRINTS_PY_TEMPLATE.render(brand=brand, ECU_NAME=ECU_NAME, PLATFORM_TO_PYTHON_CAR_NAME=PLATFORM_TO_PYTHON_CAR_NAME, + f.write(FINGERPRINTS_PY_TEMPLATE.render(brand=brand, ECU_NAME=ECU_NAME, PLATFORM_TO_ENUM_NAME=PLATFORM_TO_ENUM_NAME, FINGERPRINTS=FINGERPRINTS, FW_VERSIONS=FW_VERSIONS))