Browse Source

Refactor with autopep8

pull/2/head
Ali Hatami Tajik 2 years ago
parent
commit
a62a616898
  1. 5
      src/scripts/python/xutil/common.py
  2. 8
      src/scripts/python/xutil/pointer.py

5
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()))
return list(map(int, completed.stdout.decode(ENCODING).split()))

8
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.

Loading…
Cancel
Save