1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00
systemd/hwdb/acpi-update.py
Paul Menzel 55a37d7117 Update UEFI URLs (#12260)
* Use more secure https://www.uefi.org

http://www.uefi.org directs to https://uefi.org/, so this saves one
redirect.

    $ curl -I http://www.uefi.org
    HTTP/1.1 302 Found
    Server: nginx
    Date: Tue, 09 Apr 2019 14:54:46 GMT
    Content-Type: text/html; charset=iso-8859-1
    Connection: keep-alive
    X-Content-Type-Options: nosniff
    Location: https://uefi.org/
    Cache-Control: max-age=1209600
    Expires: Tue, 23 Apr 2019 14:54:46 GMT

Run the command below to update all occurrences.

    git grep -l http://www.uefi.org | xargs sed -i 's,http://www.uefi.org,https://www.uefi.org,'

* Use https://uefi.org to save redirect

Save one redirect by using the target location.

    $ curl -I https://www.uefi.org
    HTTP/1.1 301 Moved Permanently
    Server: nginx
    Date: Tue, 09 Apr 2019 14:55:42 GMT
    Content-Type: text/html; charset=iso-8859-1
    Connection: keep-alive
    X-Content-Type-Options: nosniff
    Location: https://uefi.org/
    Cache-Control: max-age=1209600
    Expires: Tue, 23 Apr 2019 14:55:42 GMT

Run the command below to update all occurrences.

    git grep -l https://www.uefi.org | xargs sed -i 's,https://www.uefi.org,https://uefi.org,'
2019-04-09 18:37:46 +02:00

80 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env 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 ValueError
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 ValueError
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'
'# https://uefi.org/uefi-pnp-export\n'
'# https://uefi.org/uefi-acpi-export')
read_table(a)
read_table(b)