From 3e0cf732435faba34aa16f315d8a47e924734589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 15 Nov 2023 14:47:17 +0100 Subject: [PATCH 1/3] meson: use ternary op for brevity --- test/fuzz/meson.build | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/fuzz/meson.build b/test/fuzz/meson.build index b6bcb52551..54cbb75532 100644 --- a/test/fuzz/meson.build +++ b/test/fuzz/meson.build @@ -46,11 +46,7 @@ else endif fuzz_c_args = get_option('c_args') -if cxx_cmd != '' - fuzz_cpp_args = get_option('cpp_args') -else - fuzz_cpp_args = [] -endif +fuzz_cpp_args = cxx_cmd != '' ? get_option('cpp_args') : [] sanitize_address_undefined = custom_target( 'sanitize-address-undefined-fuzzers', From 94113d5f19e5768c206176684e63525f679988d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 15 Nov 2023 15:21:26 +0100 Subject: [PATCH 2/3] hwdb: rename .html=>.csv The old suffix is now confusing. --- hwdb.d/acpi-update.py | 4 ++-- hwdb.d/{acpi_id_registry.html => acpi_id_registry.csv} | 0 hwdb.d/{pnp_id_registry.html => pnp_id_registry.csv} | 0 tools/update-hwdb.sh | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) rename hwdb.d/{acpi_id_registry.html => acpi_id_registry.csv} (100%) rename hwdb.d/{pnp_id_registry.html => pnp_id_registry.csv} (100%) diff --git a/hwdb.d/acpi-update.py b/hwdb.d/acpi-update.py index f65147c91d..386575067b 100755 --- a/hwdb.d/acpi-update.py +++ b/hwdb.d/acpi-update.py @@ -28,5 +28,5 @@ print('# This file is part of systemd.\n' '# https://uefi.org/uefi-pnp-export\n' '# https://uefi.org/uefi-acpi-export') -read_table("acpi_id_registry.html") -read_table("pnp_id_registry.html") +read_table('acpi_id_registry.csv') +read_table('pnp_id_registry.csv') diff --git a/hwdb.d/acpi_id_registry.html b/hwdb.d/acpi_id_registry.csv similarity index 100% rename from hwdb.d/acpi_id_registry.html rename to hwdb.d/acpi_id_registry.csv diff --git a/hwdb.d/pnp_id_registry.html b/hwdb.d/pnp_id_registry.csv similarity index 100% rename from hwdb.d/pnp_id_registry.html rename to hwdb.d/pnp_id_registry.csv diff --git a/tools/update-hwdb.sh b/tools/update-hwdb.sh index abbbb82f4b..096a10016b 100755 --- a/tools/update-hwdb.sh +++ b/tools/update-hwdb.sh @@ -21,8 +21,8 @@ if [ "${2:-}" != "-n" ]; then ( curl --fail -L -o ma-large.txt 'http://standards-oui.ieee.org/oui/oui.txt' curl --fail -L -o ma-medium.txt 'http://standards-oui.ieee.org/oui28/mam.txt' curl --fail -L -o ma-small.txt 'http://standards-oui.ieee.org/oui36/oui36.txt' - curl --fail -L -o pnp_id_registry.html 'https://uefi.org/uefi-pnp-export' - curl --fail -L -o acpi_id_registry.html 'https://uefi.org/uefi-acpi-export' + curl --fail -L -o pnp_id_registry.csv 'https://uefi.org/uefi-pnp-export' + curl --fail -L -o acpi_id_registry.csv 'https://uefi.org/uefi-acpi-export' ) fi set -x From a05bf18ed9cf427e56f86139aece0731f70f3e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 15 Nov 2023 15:24:34 +0100 Subject: [PATCH 3/3] hwdb/acpi-update.py: streamline python code Use f-strings and simplify the code a bit. When I call 'acpi-update.py' after those changes, the resulting .hwdb files are the same except for two additions that appeared in the meantime. I don't think it makes sense to update them again, because the ma-*.txt files changed and we don't want to store big blobs unnecessarilly. --- hwdb.d/acpi-update.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/hwdb.d/acpi-update.py b/hwdb.d/acpi-update.py index 386575067b..41670b32bb 100755 --- a/hwdb.d/acpi-update.py +++ b/hwdb.d/acpi-update.py @@ -2,31 +2,25 @@ # SPDX-License-Identifier: LGPL-2.1-or-later from csv import reader -from enum import Enum -def read_table(a): - - table = [] - - with open(a, newline='') as csvfile: - for row in reader(csvfile): - if row[0] == "Company": - # Skip header - continue - table.append(row) +# pylint: disable=consider-using-with +def read_table(filename): + table = list(reader(open(filename, newline=''))) + table = table[1:] # Skip header table.sort(key=lambda x: x[1]) for row in table: # Some IDs end with whitespace, while they didn't in the old HTML table, so it's probably # a mistake, strip it. - print("\nacpi:{0}*:\n ID_VENDOR_FROM_DATABASE={1}".format(row[1].strip(), row[0].strip())) + print(f'\nacpi:{row[1].strip()}*:\n ID_VENDOR_FROM_DATABASE={row[0].strip()}') -print('# This file is part of systemd.\n' - '#\n' - '# Data imported from:\n' - '# https://uefi.org/uefi-pnp-export\n' - '# https://uefi.org/uefi-acpi-export') +print('''\ +# This file is part of systemd. +# +# Data imported from: +# https://uefi.org/uefi-pnp-export +# https://uefi.org/uefi-acpi-export''') read_table('acpi_id_registry.csv') read_table('pnp_id_registry.csv')