in pci_lib/pci_lib.py [0:0]
def expand_pci_addr(pci_addr):
'''
Convert a possibly shortened PCI address to its expanded form, including
normalizing the formatting of long addresses
'''
m1 = LONG_PCI_ADDR_REGEX.match(pci_addr)
m2 = SHORT_PCI_ADDR_REGEX.match(pci_addr)
if m1:
domain, bus, device, function = \
map(lambda n: int(n, 16), m1.groups())
return '{:04x}:{:02x}:{:02x}.{:x}'.format(
domain, bus, device, function)
if m2:
bus, device, function = \
map(lambda n: int(n, 16), m2.groups())
return '{:04x}:{:02x}:{:02x}.{:x}'.format(
0, bus, device, function)
return None