summaryrefslogtreecommitdiff
path: root/hwdb/acpi-update.py
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2016-06-13 18:41:15 +0200
committerGitHub <noreply@github.com>2016-06-13 18:41:15 +0200
commit1be3f471e7b2c379b90207e02d95a3684329d5aa (patch)
tree66a38c81a64f244396f033797390c0883effa62e /hwdb/acpi-update.py
parent9ea8e2ce85303bba2a15c7508b1eb905433ad62c (diff)
parent3411164af3b765d1fc9f7bfa95be24e4e7acea2a (diff)
Merge pull request #3491 from poettering/hwdb-acpi
hwdb: update UEFI/ACPI/PNP/EISA/EDID database from UEFI web site
Diffstat (limited to 'hwdb/acpi-update.py')
-rwxr-xr-xhwdb/acpi-update.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/hwdb/acpi-update.py b/hwdb/acpi-update.py
new file mode 100755
index 0000000000..2dc8c7c064
--- /dev/null
+++ b/hwdb/acpi-update.py
@@ -0,0 +1,79 @@
+#!/usr/bin/python3
+
+from html.parser import HTMLParser
+from enum import Enum
+
+class State(Enum):
+ NOWHERE = 0
+ COMPANY = 1
+ AFTER_COMPANY = 2
+ PNPID = 3
+ AFTER_PNPID = 4
+ DATE = 5
+
+class PNPTableParser(HTMLParser):
+
+ def __init__(self):
+ HTMLParser.__init__(self)
+ self.state = State.NOWHERE
+ self.data = ""
+ self.pnpid = None
+ self.company = None
+ self.table = []
+
+ def handle_starttag(self, tag, attrs):
+
+ if tag == "td":
+ if self.state == State.NOWHERE:
+ self.state = State.COMPANY
+ elif self.state == State.AFTER_COMPANY:
+ self.state = State.PNPID
+ elif self.state == State.AFTER_PNPID:
+ self.state = State.DATE
+ else:
+ raise Error("Unexpected field")
+
+ self.data = ""
+
+ def handle_endtag(self, tag):
+
+ if tag == "td":
+ if self.state == State.COMPANY:
+ self.company = ' '.join(self.data.strip().split())
+ self.state = State.AFTER_COMPANY
+ elif self.state == State.PNPID:
+ self.pnpid = self.data.strip()
+ self.state = State.AFTER_PNPID
+ self.table.append((self.pnpid, self.company))
+ elif self.state == State.DATE:
+ self.state = State.NOWHERE
+ else:
+ raise Error("Unexpected field")
+
+ def handle_data(self, data):
+ self.data += data
+
+def read_table(a):
+
+ parser = PNPTableParser()
+
+ for line in a:
+ parser.feed(line)
+
+ parser.close()
+ parser.table.sort()
+
+ for pnpid, company in parser.table:
+ print("\nacpi:{0}*:\n ID_VENDOR_FROM_DATABASE={1}".format(pnpid, company))
+
+a = open("acpi_id_registry.html")
+b = open("pnp_id_registry.html")
+
+print('# This file is part of systemd.\n'
+ '#\n'
+ '# Data imported from:\n'
+ '# http://www.uefi.org/uefi-pnp-export\n'
+ '# http://www.uefi.org/uefi-acpi-export')
+
+read_table(a)
+read_table(b)