Created by: mulkieran
- from_device_number raises an exception if no device found, rather than returning None. So, instead of checking the result, catch the exception.
- Use Attributes.get() method instead of checking containment and using the index operator. This is really the only correct way, see rhbz#1267584.
Effect of the changes: Previously, if no device was found this method would raise an exception. Now it returns None instead. Previously, this method read a value for every key in what udev lists as its "available" attributes, which was expensive and potentially destructive. That was how the 'key in attributes' expression was implemented. Now, the method only reads the key of interest.
Reason for noticing all these problems: In pyudev-0.18 the Attributes class is fixed, and no longer has the [] operator or contains() method. This patch fixes several bugs while simultaneously avoiding these removed operators.
Signed-off-by: mulhern amulhern@redhat.com