From 53d22844f0d2db6d690b73a8cfa177d1e1cee937 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 2 Oct 2017 13:19:22 +0200 Subject: [PATCH] ids_parser: allow specifying which parts to run --- hwdb/ids_parser.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/hwdb/ids_parser.py b/hwdb/ids_parser.py index 691b7fa..cad77d2 100755 --- a/hwdb/ids_parser.py +++ b/hwdb/ids_parser.py @@ -290,20 +290,25 @@ def oui(p1, p2, p3): print(f'Wrote {out.name}') if __name__ == '__main__': - p = usb_ids_grammar().parseFile(open('usb.ids')) - usb_vendor_model(p) - usb_classes(p) - - p = pci_ids_grammar().parseFile(open('pci.ids')) - pci_vendor_model(p) - pci_classes(p) - - p = pci_ids_grammar().parseFile(open('sdio.ids')) - sdio_vendor_model(p) - sdio_classes(p) - - p = oui_grammar('small').parseFile(open('ma-small.txt')) - p2 = oui_grammar('medium').parseFile(open('ma-medium.txt')) - p3 = oui_grammar('large').parseFile(open('ma-large.txt')) - - oui(p, p2, p3) + args = sys.argv[1:] + + if not args or 'usb' in args: + p = usb_ids_grammar().parseFile(open('usb.ids')) + usb_vendor_model(p) + usb_classes(p) + + if not args or 'pci' in args: + p = pci_ids_grammar().parseFile(open('pci.ids')) + pci_vendor_model(p) + pci_classes(p) + + if not args or 'sdio' in args: + p = pci_ids_grammar().parseFile(open('sdio.ids')) + sdio_vendor_model(p) + sdio_classes(p) + + if not args or 'oui' in args: + p = oui_grammar('small').parseFile(open('ma-small.txt')) + p2 = oui_grammar('medium').parseFile(open('ma-medium.txt')) + p3 = oui_grammar('large').parseFile(open('ma-large.txt')) + oui(p, p2, p3) -- 2.7.4