]> git.ipfire.org Git - thirdparty/systemd.git/blob - hwdb.d/acpi-update.py
hwdb/acpi-update.py: streamline python code
[thirdparty/systemd.git] / hwdb.d / acpi-update.py
1 #!/usr/bin/env python3
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 from csv import reader
5
6 # pylint: disable=consider-using-with
7
8 def read_table(filename):
9 table = list(reader(open(filename, newline='')))
10 table = table[1:] # Skip header
11 table.sort(key=lambda x: x[1])
12
13 for row in table:
14 # Some IDs end with whitespace, while they didn't in the old HTML table, so it's probably
15 # a mistake, strip it.
16 print(f'\nacpi:{row[1].strip()}*:\n ID_VENDOR_FROM_DATABASE={row[0].strip()}')
17
18 print('''\
19 # This file is part of systemd.
20 #
21 # Data imported from:
22 # https://uefi.org/uefi-pnp-export
23 # https://uefi.org/uefi-acpi-export''')
24
25 read_table('acpi_id_registry.csv')
26 read_table('pnp_id_registry.csv')