]> git.ipfire.org Git - thirdparty/systemd.git/blame - hwdb.d/acpi-update.py
hwdb/acpi-update.py: streamline python code
[thirdparty/systemd.git] / hwdb.d / acpi-update.py
CommitLineData
3e67e5c9 1#!/usr/bin/env python3
703c70cc 2# SPDX-License-Identifier: LGPL-2.1-or-later
3411164a 3
9a86f084 4from csv import reader
3411164a 5
a05bf18e 6# pylint: disable=consider-using-with
3411164a 7
a05bf18e
ZJS
8def read_table(filename):
9 table = list(reader(open(filename, newline='')))
10 table = table[1:] # Skip header
9a86f084 11 table.sort(key=lambda x: x[1])
3411164a 12
9a86f084
LB
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.
a05bf18e
ZJS
16 print(f'\nacpi:{row[1].strip()}*:\n ID_VENDOR_FROM_DATABASE={row[0].strip()}')
17
18print('''\
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''')
3411164a 24
94113d5f
ZJS
25read_table('acpi_id_registry.csv')
26read_table('pnp_id_registry.csv')