GetPCI-SigVendorIDMap.py: format with black
flake8 was flagging too long of lines on this script, so reformat
with black to resolve.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iae47269005ee98773b6eddd2728bb2212f0e660d
diff --git a/utils/GetPCI-SIGVendorIDMap.py b/utils/GetPCI-SIGVendorIDMap.py
index 1a8132f..930b364 100644
--- a/utils/GetPCI-SIGVendorIDMap.py
+++ b/utils/GetPCI-SIGVendorIDMap.py
@@ -1,16 +1,21 @@
#!/usr/bin/python3
-import sys
-import requests
-import re
import argparse
+import re
+import sys
+
+import requests
from bs4 import BeautifulSoup
def parse_args(argv):
"""Parse the command-line arguments"""
- parser = argparse.ArgumentParser(description='Get the PCI-SIG Vendor IDs')
- parser.add_argument('--http-proxy', action='store', help="HTTP Proxy Address")
- parser.add_argument('--https-proxy', action='store', help="HTTPS Proxy Address")
+ parser = argparse.ArgumentParser(description="Get the PCI-SIG Vendor IDs")
+ parser.add_argument(
+ "--http-proxy", action="store", help="HTTP Proxy Address"
+ )
+ parser.add_argument(
+ "--https-proxy", action="store", help="HTTPS Proxy Address"
+ )
args = parser.parse_args(argv)
return args
@@ -20,11 +25,8 @@
dictionary of member companies to their Vendor IDs"""
args = parse_args(argv)
- proxyDict = {
- "http": args.http_proxy,
- "https": args.https_proxy
- }
- page = 'https://pcisig.com/membership/member-companies'
+ proxyDict = {"http": args.http_proxy, "https": args.https_proxy}
+ page = "https://pcisig.com/membership/member-companies"
pciVendorIDs = {}
while True:
r = requests.get(page, proxies=proxyDict)
@@ -33,24 +35,24 @@
for row in soup.table.tbody.find_all("tr"):
fields = row.find_all("td")
vendorID = fields[1].text.strip()
- if 'hex' in vendorID.lower():
- match = re.match(r'\w+ \((\w+) hex\)', vendorID, re.I)
+ if "hex" in vendorID.lower():
+ match = re.match(r"\w+ \((\w+) hex\)", vendorID, re.I)
if match is not None:
vendorID = match.group(1)
else:
- vendorID = ''
- if vendorID != '':
- vendorName = fields[0].text.replace('"', '').strip()
+ vendorID = ""
+ if vendorID != "":
+ vendorName = fields[0].text.replace('"', "").strip()
pciVendorIDs[vendorName] = vendorID
page = soup.find("a", title="Go to next page")
if page is None:
break
- page = 'https://pcisig.com' + page["href"]
+ page = "https://pcisig.com" + page["href"]
for name, vid in sorted(pciVendorIDs.items(), key=lambda x: x[0].lower()):
- print("{{0x{}, \"{}\"}},".format(vid, name))
+ print('{{0x{}, "{}"}},'.format(vid, name))
-if __name__ == '__main__':
+if __name__ == "__main__":
main(sys.argv[1:])