From 2b2c682b4a2f7bd49fc9f9f3a0d00d27d8d4f63b Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Thu, 6 Jan 2022 17:46:22 -0300 Subject: [PATCH] pcireg: Update pciutil to match bios-tools --- pcireg/pciutil.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pcireg/pciutil.py b/pcireg/pciutil.py index bab1541..4007841 100644 --- a/pcireg/pciutil.py +++ b/pcireg/pciutil.py @@ -28,7 +28,7 @@ clean_device_abbr = [ ('1000Base-T', 'GbE'), ('Accelerat(?:ion|or)', 'Accel.'), ('Alert on LAN', 'AoL'), - ('\((.+) applications?\)', '\\2'), # 8086:105e + ('\((.+) applications?\)', '(\\2)'), # 8086:105e ('Chipset Family', 'Chipset'), ('Chipset Graphics', 'iGPU'), ('Connection', 'Conn.'), @@ -45,8 +45,8 @@ clean_device_abbr = [ ('Host Bus Adapter', 'HBA'), ('Host Controller', 'HC'), ('Input/Output', 'I/O'), - ('Integrated ([^\s]+) Graphics', '\\2 iGPU'), # VIA CLE266 - ('Integrated Graphics', 'iGPU'), + ('Integrated ([^\s]+) (?:Graphics|GPU)', '\\2 iGPU'), # VIA CLE266 + ('Integrated (?:Graphics|GPU)', 'iGPU'), ('([0-9]) (lane|port)', '\\2-\\3'), ('Local Area Network', 'LAN'), ('Low Pin Count', 'LPC'), @@ -54,7 +54,7 @@ clean_device_abbr = [ ('Network (?:Interface )?(?:Adapter|Card|Controller)', 'NIC'), ('NVM Express', 'NVMe'), ('Parallel ATA', 'PATA'), - ('PCI(?:-E| Express)', 'PCIe'), + ('PCI(?:-E|[- ]Express)', 'PCIe'), ('([^- ]+)[- ]to[- ]([^- ]+)', '\\2-\\3'), ('Platform Controller Hub', 'PCH'), ('Processor Graphics', 'iGPU'), @@ -245,10 +245,13 @@ def load_pci_db(): # Debugging feature. if __name__ == '__main__': s = input() - if len(s) == 8 and ' ' not in s: - vendor, device = get_pci_id(int(s[:4], 16), int(s[4:], 16)) - vendor = clean_vendor(vendor) - print(vendor) - print(clean_device(device, vendor)) - else: + try: + if len(s) in (8, 9): + vendor, device = get_pci_id(int(s[:4], 16), int(s[-4:], 16)) + vendor = clean_vendor(vendor) + print(vendor) + print(clean_device(device, vendor)) + else: + raise Exception('not id') + except: print(clean_device(s))