[PATCH evemu 2/3] python: switch from type() == str to not isinstance(int)
Peter Hutterer
peter.hutterer at who-t.net
Thu Nov 6 15:14:21 PST 2014
Switch to isinstance to be more liberal in what we can accept.
Anything that looks like an int should be used as such, anything else we
assume to be a string that needs parsing. event_get_value() would do that for
us but we can't call it unconditionally - some events don't have names so they
cannot resolve.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
python/evemu/__init__.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/python/evemu/__init__.py b/python/evemu/__init__.py
index 363e6ce..9bfbfec 100644
--- a/python/evemu/__init__.py
+++ b/python/evemu/__init__.py
@@ -352,46 +352,46 @@ class Device(object):
return self._libevemu.evemu_get_id_version(self._evemu_device)
def get_abs_minimum(self, event_code):
- if type(event_code) == str:
+ if not isinstance(event_code, int):
event_code = evemu.event_get_value("EV_ABS", event_code)
return self._libevemu.evemu_get_abs_minimum(self._evemu_device,
event_code)
def get_abs_maximum(self, event_code):
- if type(event_code) == str:
+ if not isinstance(event_code, int):
event_code = evemu.event_get_value("EV_ABS", event_code)
return self._libevemu.evemu_get_abs_maximum(self._evemu_device,
event_code)
def get_abs_fuzz(self, event_code):
- if type(event_code) == str:
+ if not isinstance(event_code, int):
event_code = evemu.event_get_value("EV_ABS", event_code)
return self._libevemu.evemu_get_abs_fuzz(self._evemu_device,
event_code)
def get_abs_flat(self, event_code):
- if type(event_code) == str:
+ if not isinstance(event_code, int):
event_code = evemu.event_get_value("EV_ABS", event_code)
return self._libevemu.evemu_get_abs_flat(self._evemu_device,
event_code)
def get_abs_resolution(self, event_code):
- if type(event_code) == str:
+ if not isinstance(event_code, int):
event_code = evemu.event_get_value("EV_ABS", event_code)
return self._libevemu.evemu_get_abs_resolution(self._evemu_device,
event_code)
# don't change 'event_code' to prop, it breaks API
def has_prop(self, event_code):
- if type(event_code) == str:
+ if not isinstance(event_code, int):
event_code = evemu.input_prop_get_value(event_code)
result = self._libevemu.evemu_has_prop(self._evemu_device, event_code)
return bool(result)
def has_event(self, event_type, event_code):
- if type(event_type) == str:
+ if not isinstance(event_type, int):
event_type = evemu.event_get_value(event_type)
- if type(event_code) == str:
+ if not isinstance(event_code, int):
event_code = evemu.event_get_value(event_type, event_code)
result = self._libevemu.evemu_has_event(self._evemu_device,
event_type,
--
2.1.0
More information about the Input-tools
mailing list