Code review comment for lp:~adeuring/launchpad/bug-457475-udev-device-id

Revision history for this message
Abel Deuring (adeuring) wrote :

This branch adds a missing property "id" to class UdevDevice.

Class UdevDevice represents a device from a HWDB report containing udev data. Such reports are submitted by the HWDB client in Karmic, while oder client version send reports containig HAL data instead.

The XML structure for the HAL data is much more fine-grained than the XML structure for udev data: The HAL data contains one XML node for each HAL device, and each node has an attribute "id" with a unique integer value. This value is used to set the value HALDevice.id (class HALDevice is a "sibling" of class UdevDevice). The HWDB submission processing script takes/expectes the value HALDevice.id or UdevDevice.id, respectively and uses it to as the value of the column hal_device_id of new records of the table HWSubmissionDevice. (this table tells us that a given device appears in a given submission). Only problem is that a property UdevDevice.id did not exist yet...

The udev data is simply the output from running "udevadm info --export-db" and hence does not provide any simple integer ID for the devices. But it is easy to increment a counter when SubmissionParser._parserUdev() detects a new device and to store this number in the dictionary where _parseUdev() stores the data of a device.

This dictionary item can then be used as the value of the the property UdevDevice.id.

tests: ./bin/test --test=test_hwdb_submission_parser

« Back to merge proposal