for line_number, line in enumerate(udev_data):
if len(line) == 0:
@@ -518,9 +519,11 @@
key, value = record
if device is None:
+ device_id += 1 device = { 'E': {}, 'S': [],
+ 'id': device_id, } devices.append(device)
# Some attribute lines have a space character after the
@@ -2776,6 +2779,11 @@
return None
return controller
+ @property
+ def id(self):
+ return self.udev['id']
+
+
class ProcessingLoop(object):
"""An `ITunableLoop` for processing HWDB submissions."""
Sorry, forgot to write a test for UdevDevice.id. Now added.
The diff of the complete changes is now:
=== modified file 'lib/canonical/ launchpad/ scripts/ hwdbsubmissions .py' launchpad/ scripts/ hwdbsubmissions .py 2009-10-21 10:06:31 +0000 launchpad/ scripts/ hwdbsubmissions .py 2009-10-21 16:43:31 +0000
line_ number = 0
--- lib/canonical/
+++ lib/canonical/
@@ -503,6 +503,7 @@
devices = []
device = None
+ device_id = 0
for line_number, line in enumerate( udev_data) :
if len(line) == 0:
@@ -518,9 +519,11 @@
key, value = record
device = {
'E': {},
'S': [],
}
devices. append( device)
if device is None:
+ device_id += 1
+ 'id': device_id,
# Some attribute lines have a space character after the
@@ -2776,6 +2779,11 @@
return None
return controller
+ @property object) :
+ def id(self):
+ return self.udev['id']
+
+
class ProcessingLoop(
"""An `ITunableLoop` for processing HWDB submissions."""
=== modified file 'lib/canonical/ launchpad/ scripts/ tests/test_ hwdb_submission _parser. py' launchpad/ scripts/ tests/test_ hwdb_submission _parser. py 2009-10-12 14:50:22 +0000 launchpad/ scripts/ tests/test_ hwdb_submission _parser. py 2009-10-21 16:47:04 +0000
'MODALIAS' : 'acpi:LNXSYSTM:',
},
'S': [],
},
'P': '/devices/ pci0000: 00/0000: 00:1a.0' ,
'DEVPATH' : '/devices/ pci0000: 00/0000: 00:1a.0' ,
},
'S': ['char/189:256'],
},
result,
'E': {},
'S': [],
'W': '2',
},
result,
--- lib/canonical/
+++ lib/canonical/
@@ -635,6 +635,7 @@
+ 'id': 1,
{
@@ -643,6 +644,7 @@
+ 'id': 2,
],
@@ -704,6 +706,7 @@
+ 'id': 1,
],
=== modified file 'lib/canonical/ launchpad/ scripts/ tests/test_ hwdb_submission _processing. py' launchpad/ scripts/ tests/test_ hwdb_submission _processing. py 2009-10-21 10:06:31 +0000 launchpad/ scripts/ tests/test_ hwdb_submission _processing. py 2009-10-22 09:00:19 +0000
'DEVPATH' : '/devices/ LNXSYSTM: 00',
'MODALIAS' : 'acpi:LNXSYSTM:',
'SUBSYSTEM' : 'acpi',
--- lib/canonical/
+++ lib/canonical/
@@ -3036,7 +3036,8 @@
- }
+ },
+ 'id': 1,
}
@@ -4185,6 +4186,11 @@
'None None /devices/
+ def test_device_ id(self) :
+ """Each UdevDevice has a property 'id'."""
+ device = UdevDevice(None, self.root_device)
+ self.assertEqual(1, device.id)
+
class TestHWDBSubmiss ionTablePopulat ion(TestCaseHWD B):
"""Tests of the HWDB popoluation with submitted data."""