summaryrefslogtreecommitdiff
path: root/kvmd/validators
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-08-31 09:01:40 +0300
committerDevaev Maxim <[email protected]>2020-08-31 09:01:40 +0300
commit77826689446750021a8051b86343739e2766a368 (patch)
tree87af438fe0c6c90e7c676129fd3786acd56ed441 /kvmd/validators
parent9feb3531506706c358e2701a0df1f7cd3b7684c3 (diff)
gpio view and refactoring
Diffstat (limited to 'kvmd/validators')
-rw-r--r--kvmd/validators/hw.py9
-rw-r--r--kvmd/validators/kvm.py18
2 files changed, 18 insertions, 9 deletions
diff --git a/kvmd/validators/hw.py b/kvmd/validators/hw.py
index e37eeda8..82d1221a 100644
--- a/kvmd/validators/hw.py
+++ b/kvmd/validators/hw.py
@@ -23,7 +23,6 @@
from typing import Any
from . import check_in_list
-from . import check_string_in_list
from . import check_re_match
from .basic import valid_number
@@ -44,14 +43,6 @@ def valid_gpio_pin_optional(arg: Any) -> int:
return int(valid_number(arg, min=-1, name="optional GPIO pin"))
-def valid_gpio_mode(arg: Any) -> str:
- return check_string_in_list(arg, "GPIO mode", ["input", "output"])
-
-
-def valid_gpio_channel(arg: Any) -> str:
- return check_re_match(arg, "GPIO channel", r"^[a-zA-Z_][a-zA-Z0-9_-]*$")[:255]
-
-
def valid_otg_gadget(arg: Any) -> str:
return check_re_match(arg, "OTG gadget name", r"^[a-z_][a-z0-9_-]*$")[:255]
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py
index 140c282c..7ff96055 100644
--- a/kvmd/validators/kvm.py
+++ b/kvmd/validators/kvm.py
@@ -20,12 +20,14 @@
# ========================================================================== #
+from typing import List
from typing import Any
from ..keyboard.mappings import KEYMAP
from . import raise_error
from . import check_string_in_list
+from . import check_re_match
from .basic import valid_stripped_string_not_empty
from .basic import valid_number
@@ -86,3 +88,19 @@ def valid_hid_mouse_button(arg: Any) -> str:
def valid_hid_mouse_wheel(arg: Any) -> int:
arg = valid_number(arg, name="HID mouse wheel")
return min(max(-127, arg), 127)
+
+
+# =====
+def valid_ugpio_mode(arg: Any) -> str:
+ return check_string_in_list(arg, "GPIO mode", ["input", "output"])
+
+
+def valid_ugpio_channel(arg: Any) -> str:
+ return check_re_match(arg, "GPIO channel", r"^[a-zA-Z_][a-zA-Z0-9_-]*$")[:255]
+
+
+def valid_ugpio_view_table(arg: Any) -> List[List[str]]:
+ try:
+ return list(map(str, list(arg))) # type: ignore
+ except Exception:
+ raise_error("<skipped>", "GPIO view table")