pyudev / pyudev

Python bindings to libudev (with support for PyQt4, PySide, pygobject and wx)
http://pyudev.readthedocs.org
GNU Lesser General Public License v2.1
165 stars 50 forks source link

Consider a strict mode for devices #142

Open mulkieran opened 8 years ago

mulkieran commented 8 years ago

In a strict mode, an exception would be raised if a device that no longer existed was queried for an attribute value or for a udev value. Currently, attribute values may be NULL if not looked up when the device did exist, but will have a value if they had a value when the device did exist and was looked up. A similar behavior holds for udev properties and presumably for tags as well.

The correct way to check its existance is to check the existance of its sysfs path.

It is possible that the pyudev context could by used to configure strictness or non-strictness (the default behavior).

It might be possible to do this all by means of a class decorator.

mulkieran commented 8 years ago

What happens if a device dissappears and a new device with the same sysfs path is added. Does libudev supply the old information?

mulkieran commented 8 years ago

Perhaps is_initialized is the better choice. But, is_initialized may remain true about the device even after it is removed. Needs work to figure out if is_initialized is adequate. Maybe a combination of both checks.