summaryrefslogtreecommitdiff
path: root/kvmd/validators/os.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-10-24 03:09:06 +0300
committerDevaev Maxim <[email protected]>2019-10-24 03:09:06 +0300
commitb4ef91838e16cdb70ae1152c320a3973f07c5f89 (patch)
treea98b222952940dedb07cdb1ebe89025af3c50e46 /kvmd/validators/os.py
parentc124e63d6d6cdd07b6d0fa4439fed878ed164fbb (diff)
improved validation
Diffstat (limited to 'kvmd/validators/os.py')
-rw-r--r--kvmd/validators/os.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/kvmd/validators/os.py b/kvmd/validators/os.py
index 3fcca5c1..ec8d47fa 100644
--- a/kvmd/validators/os.py
+++ b/kvmd/validators/os.py
@@ -27,10 +27,10 @@ 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
+from .basic import valid_stripped_string_not_empty
# =====
@@ -51,9 +51,7 @@ def valid_abs_path(arg: Any, type: str="", name: str="") -> str: # pylint: disa
if not name:
name = "absolute path"
- if len(str(arg).strip()) == 0:
- arg = None
- arg = os.path.abspath(check_not_none_string(arg, name))
+ arg = os.path.abspath(valid_stripped_string_not_empty(arg, name))
if type:
try:
@@ -79,9 +77,7 @@ def valid_printable_filename(arg: Any, name: str="") -> str:
if not name:
name = "printable filename"
- if len(str(arg).strip()) == 0:
- arg = None
- arg = check_not_none_string(arg, name)
+ arg = valid_stripped_string_not_empty(arg, name)
if "/" in arg or "\0" in arg or arg in [".", ".."]:
raise_error(arg, name)