From c9e34b2a5e34a522747ce381a69d464769ebb423 Mon Sep 17 00:00:00 2001 From: Lucidiot Date: Wed, 22 Jan 2020 19:21:12 +0100 Subject: [PATCH] Add PhySlot field --- pylspci/device.py | 9 ++++++++- pylspci/parsers/verbose.py | 1 + pylspci/tests/parsers/test_verbose.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pylspci/device.py b/pylspci/device.py index 3955a29..050944b 100644 --- a/pylspci/device.py +++ b/pylspci/device.py @@ -79,7 +79,14 @@ class Device(NamedTuple): numa_node: Optional[int] = None """ - NUMA Node this device is connected to (Linux only). + NUMA node this device is connected to (Linux only). + + :type: int or None + """ + + physical_slot: Optional[int] = None + """ + The device's physical slot number (Linux only). :type: int or None """ diff --git a/pylspci/parsers/verbose.py b/pylspci/parsers/verbose.py index 67b004a..e300efe 100644 --- a/pylspci/parsers/verbose.py +++ b/pylspci/parsers/verbose.py @@ -73,6 +73,7 @@ class VerboseParser(Parser): many=True, ), 'NUMANode': FieldMapping(field_name='numa_node', field_type=int), + 'PhySlot': FieldMapping(field_name='physical_slot', field_type=int), } def _parse_device(self, device_data: Union[str, Iterable[str]]) -> Device: diff --git a/pylspci/tests/parsers/test_verbose.py b/pylspci/tests/parsers/test_verbose.py index e4268f3..8dfd851 100644 --- a/pylspci/tests/parsers/test_verbose.py +++ b/pylspci/tests/parsers/test_verbose.py @@ -17,6 +17,7 @@ Driver: pcieport Module: nouveau Module: nvidia NUMANode: 0 +PhySlot: 4 """ @@ -52,6 +53,7 @@ class TestVerboseParser(TestCase): self.assertEqual(dev.driver, 'pcieport') self.assertListEqual(dev.kernel_modules, ['nouveau', 'nvidia']) self.assertEqual(dev.numa_node, 0) + self.assertEqual(dev.physical_slot, 4) def test_parse_str(self) -> None: devices: List[Device] = self.parser.parse(SAMPLE_DEVICE)