summaryrefslogtreecommitdiff
path: root/kvmd/validators/__init__.py
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-07-08 03:41:29 +0300
committerMaxim Devaev <[email protected]>2024-12-17 18:20:04 +0200
commit630610bc532299f15ff7ee12d40f617de450aae0 (patch)
treeca0a83f1aa5848a4605034c0394f1edfd0bea7ce /kvmd/validators/__init__.py
parente0bbf6968ef8295274793a564e717f95f42983d7 (diff)
switch
Diffstat (limited to 'kvmd/validators/__init__.py')
-rw-r--r--kvmd/validators/__init__.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/kvmd/validators/__init__.py b/kvmd/validators/__init__.py
index 39ff60aa..aa997ab9 100644
--- a/kvmd/validators/__init__.py
+++ b/kvmd/validators/__init__.py
@@ -99,3 +99,11 @@ def check_any(arg: Any, name: str, validators: list[Callable[[Any], Any]]) -> An
except Exception:
pass
raise_error(arg, name)
+
+
+# =====
+def filter_printable(arg: str, replace: str, limit: int) -> str:
+ return "".join(
+ (ch if ch.isprintable() else replace)
+ for ch in arg[:limit]
+ )