[PATCH evemu 3/7] python: replace event_get_name with the C implementation
Peter Hutterer
peter.hutterer at who-t.net
Thu Aug 14 20:28:44 PDT 2014
On Thu, Aug 14, 2014 at 02:00:41PM -0400, Benjamin Tissoires wrote:
> No functional change, but relying on an external lib removes the
> pain to maintain our own input.h implementation.
see the instanceof() comment in 2/7
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>
> ---
> python/evemu/__init__.py | 23 +++++++++++++++++++----
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/python/evemu/__init__.py b/python/evemu/__init__.py
> index 0797d73..c50131c 100644
> --- a/python/evemu/__init__.py
> +++ b/python/evemu/__init__.py
> @@ -79,10 +79,25 @@ def event_get_name(event_type, event_code = None):
> If an event code is passed, the event type may be given as integer or
> string.
> """
> - try:
> - return evemu.event_names._event_get_name(event_type, event_code)
> - except KeyError:
> - return None
> + ev_type_num = ev_type_name = event_type
> + ev_code_num = ev_code_name = event_code
> +
> + if type(event_type) == int:
> + ev_type_name = _libevemu.evemu_event_type_get_name(event_type)
> + else:
> + ev_type_num = event_get_value(event_type)
> +
> + if event_code == None:
> + if type(event_type) == str:
> + raise TypeError("expected an int")
> + return ev_type_name
> +
> + if type(event_code) == str:
> + raise TypeError("expected an int")
> +
> + ev_code_name = _libevemu.evemu_event_code_get_name(ev_type_num, event_code)
> +
> + return ev_code_name
>
> def input_prop_get_name(prop):
> """
> --
> 2.0.4
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/input-tools
More information about the Input-tools
mailing list