summaryrefslogtreecommitdiff
path: root/kvmd/validators
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-09-25 03:15:20 +0300
committerDevaev Maxim <[email protected]>2019-09-25 03:15:20 +0300
commit5c4e8f7962fe89ee0dcdea9ba859f7045fa2d6d8 (patch)
tree785b2454f56480464d18c71c2221b262bb92eabb /kvmd/validators
parent5d437c58e342bcb9847e419e46c751b3ed70e747 (diff)
extended msd api for future otg
Diffstat (limited to 'kvmd/validators')
-rw-r--r--kvmd/validators/kvm.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py
index e99929af..29b45500 100644
--- a/kvmd/validators/kvm.py
+++ b/kvmd/validators/kvm.py
@@ -20,10 +20,13 @@
# ========================================================================== #
+import re
+
from typing import Any
from .. import keymap
+from . import check_not_none_string
from . import check_string_in_list
from .basic import valid_number
@@ -38,6 +41,18 @@ def valid_atx_button(arg: Any) -> str:
return check_string_in_list(arg, "ATX button", ["power", "power_long", "reset"])
+def valid_msd_image_name(arg: Any) -> str:
+ if len(str(arg).strip()) == 0:
+ arg = None
+ arg = check_not_none_string(arg, "MSD image name", strip=True)
+ arg = re.sub(r"[^\w\.+@()\[\]-]", "_", arg)
+ if arg == ".":
+ arg = "_"
+ if arg == "..":
+ arg = "__"
+ return arg[:255]
+
+
def valid_log_seek(arg: Any) -> int:
return int(valid_number(arg, min=0, name="log seek"))