in pci_lib/pci_lib.py [0:0]
def location(self):
"""
A string describing how this device is connected to the system
None if this is a built-in device
"""
path = self.get_path()
slotmap = get_dmidecode_pci_slots()
connection = path[1:]
if connection:
pathels = []
for dev in connection:
pathpart = []
dmislot = slotmap.get(dev.device_name)
if dmislot:
pathels.append(dmislot['designation'])
continue
explink = dev.express_link
exptype = dev.express_type
slot = dev.express_slot
if slot:
pathpart.append('slot {}'.format(slot.slot))
if explink:
pathpart.append('{}'.format(exptype))
if pathpart:
pathels.append(', '.join(pathpart))
return ' -> '.join(pathels)
else:
return None