summaryrefslogtreecommitdiff
path: root/gr-utils/modtool/core/base.py
diff options
context:
space:
mode:
authorFerenc Gerlits <fgerlits@gmail.com>2021-04-29 21:52:38 +0200
committermormj <34754695+mormj@users.noreply.github.com>2021-05-03 12:48:08 -0400
commitfaf786d57f48bc516c530bfd76e478b3748cd582 (patch)
treed0547b018122e2f196bdfa412c2ddc27bf23c53a /gr-utils/modtool/core/base.py
parent79d294331ca941cd16c42ddc07278c5ce749b938 (diff)
modtool: improve the 'invalid name' error message
also fix some validations which checked a prefix instead of the whole name Signed-off-by: Ferenc Gerlits <fgerlits@gmail.com>
Diffstat (limited to 'gr-utils/modtool/core/base.py')
-rw-r--r--gr-utils/modtool/core/base.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/gr-utils/modtool/core/base.py b/gr-utils/modtool/core/base.py
index 743758d2b6..d35bc63156 100644
--- a/gr-utils/modtool/core/base.py
+++ b/gr-utils/modtool/core/base.py
@@ -44,6 +44,12 @@ class ModToolException(Exception):
pass
+def validate_name(kind, name):
+ """ Checks that block, module etc names are alphanumeric. """
+ if not re.fullmatch('[a-zA-Z0-9_]+', name):
+ raise ModToolException("Invalid {} name '{}': names can only contain letters, numbers and underscores".format(kind, name))
+
+
class ModTool(object):
""" Base class for all modtool command classes. """
name = 'base'