Skip to content

Commit a05bf18

Browse files
committed
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.
1 parent 94113d5 commit a05bf18

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

hwdb.d/acpi-update.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,25 @@
22
# SPDX-License-Identifier: LGPL-2.1-or-later
33

44
from csv import reader
5-
from enum import Enum
65

7-
def read_table(a):
8-
9-
table = []
10-
11-
with open(a, newline='') as csvfile:
12-
for row in reader(csvfile):
13-
if row[0] == "Company":
14-
# Skip header
15-
continue
16-
table.append(row)
6+
# pylint: disable=consider-using-with
177

8+
def read_table(filename):
9+
table = list(reader(open(filename, newline='')))
10+
table = table[1:] # Skip header
1811
table.sort(key=lambda x: x[1])
1912

2013
for row in table:
2114
# Some IDs end with whitespace, while they didn't in the old HTML table, so it's probably
2215
# a mistake, strip it.
23-
print("\nacpi:{0}*:\n ID_VENDOR_FROM_DATABASE={1}".format(row[1].strip(), row[0].strip()))
24-
25-
print('# This file is part of systemd.\n'
26-
'#\n'
27-
'# Data imported from:\n'
28-
'# https://uefi.org/uefi-pnp-export\n'
29-
'# https://uefi.org/uefi-acpi-export')
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''')
3024

3125
read_table('acpi_id_registry.csv')
3226
read_table('pnp_id_registry.csv')

0 commit comments

Comments
 (0)