summaryrefslogtreecommitdiff
path: root/kvmd/validators/fs.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/validators/fs.py')
-rw-r--r--kvmd/validators/fs.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/kvmd/validators/fs.py b/kvmd/validators/fs.py
index ed895818..505df8e2 100644
--- a/kvmd/validators/fs.py
+++ b/kvmd/validators/fs.py
@@ -22,17 +22,20 @@
import os
+from typing import List
from typing import Any
from . import raise_error
from . import check_not_none_string
from .basic import valid_number
+from .basic import valid_string_list
# =====
-def valid_abs_path(arg: Any, exists: bool=False) -> str:
- name = ("existent absolute path" if exists else "absolute path")
+def valid_abs_path(arg: Any, exists: bool=False, name: str="") -> str:
+ if not name:
+ name = ("existent absolute path" if exists else "absolute path")
if len(str(arg).strip()) == 0:
arg = None
@@ -44,9 +47,17 @@ def valid_abs_path(arg: Any, exists: bool=False) -> str:
return arg
-def valid_abs_path_exists(arg: Any) -> str:
- return valid_abs_path(arg, exists=True)
+def valid_abs_path_exists(arg: Any, name: str="") -> str:
+ return valid_abs_path(arg, exists=True, name=name)
def valid_unix_mode(arg: Any) -> int:
return int(valid_number(arg, min=0, name="UNIX mode"))
+
+
+def valid_command(arg: Any) -> List[str]:
+ cmd = valid_string_list(arg, delim=r"[,\t]+", name="command")
+ if len(cmd) == 0:
+ raise_error(arg, "command")
+ cmd[0] = valid_abs_path_exists(cmd[0], name="command entry point")
+ return cmd