Convert numerical ids to hex strings. Strip empty pci_ids lists. Strip wildcard 0xFFFF ids.
(info: dict)
| 145 | |
| 146 | |
| 147 | def scrub_pci_ids(info: dict): |
| 148 | """ |
| 149 | Convert numerical ids to hex strings. |
| 150 | Strip empty pci_ids lists. |
| 151 | Strip wildcard 0xFFFF ids. |
| 152 | """ |
| 153 | pci_ids = [] |
| 154 | for pci_fields in info.pop("pci_ids"): |
| 155 | pci = {} |
| 156 | for name, value in zip(PCI_FIELDS, pci_fields): |
| 157 | if value != 0xFFFF: |
| 158 | pci[name] = f"{value:04x}" |
| 159 | if pci: |
| 160 | pci_ids.append(pci) |
| 161 | if pci_ids: |
| 162 | info["pci_ids"] = pci_ids |
| 163 | |
| 164 | |
| 165 | # ---------------------------------------------------------------------------- |