From a62a6168986f49416e1e6c40dba962b7f44040e5 Mon Sep 17 00:00:00 2001 From: Ali Hatami Tajik Date: Mon, 27 Feb 2023 11:35:04 +0330 Subject: [PATCH] Refactor with autopep8 --- src/scripts/python/xutil/common.py | 5 +++-- src/scripts/python/xutil/pointer.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/scripts/python/xutil/common.py b/src/scripts/python/xutil/common.py index fc02c23..ec8d9c5 100644 --- a/src/scripts/python/xutil/common.py +++ b/src/scripts/python/xutil/common.py @@ -4,6 +4,7 @@ from multipledispatch import dispatch ENCODING = 'utf-8' + @dispatch() def get_list_short(): """Returns string output of the `xinput --list --short` command encoded as @@ -25,7 +26,7 @@ def get_list_short(id): """ completed = subprocess.run( ['xinput', '--list', '--short', str(id)], capture_output=True) - + if completed.returncode == 0: return completed.stdout.decode(ENCODING) else: @@ -36,4 +37,4 @@ def get_ids() -> List[int]: """returns list of ids registered in xinput""" completed = subprocess.run( ['xinput', '--list', '--id-only'], capture_output=True) - return list(map(int, completed.stdout.decode(ENCODING).split())) \ No newline at end of file + return list(map(int, completed.stdout.decode(ENCODING).split())) diff --git a/src/scripts/python/xutil/pointer.py b/src/scripts/python/xutil/pointer.py index 9ae405b..8330b7a 100644 --- a/src/scripts/python/xutil/pointer.py +++ b/src/scripts/python/xutil/pointer.py @@ -1,6 +1,7 @@ import xutil.common as com import re + class XInput: """Base XInput class @@ -25,7 +26,7 @@ class XInput: class Pointer(XInput): """Pointer class - + This class is a wrapper around xinput commandline --list output. @@ -36,6 +37,7 @@ class Pointer(XInput): def __init__(self, name, id, is_master: bool) -> None: super().__init__(name, id, is_master) + def get_short_pointer(id) -> Pointer: """Generates Pointer object corresponding to id (short attrs) @@ -54,7 +56,7 @@ def get_short_pointer(id) -> Pointer: if "pointer" in props: is_master = "master" in props return Pointer( - name.strip(), + name.strip(), props.split(maxsplit=1), is_master) else: @@ -63,7 +65,7 @@ def get_short_pointer(id) -> Pointer: def get_pointers(is_short=True): """Wraps pointers in `xinput --list` in Pointer class - + Creation of the pointer is done by getting the list description of each id. if the is_short arg is True, then short list description will be used which will provide the class `name`, `is_master` and `id` values.