summaryrefslogtreecommitdiff
path: root/gr-utils/modtool/core/rename.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/rename.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/rename.py')
-rw-r--r--gr-utils/modtool/core/rename.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/gr-utils/modtool/core/rename.py b/gr-utils/modtool/core/rename.py
index 5f5bd933ae..183b3a2694 100644
--- a/gr-utils/modtool/core/rename.py
+++ b/gr-utils/modtool/core/rename.py
@@ -13,7 +13,7 @@ import os
import re
import logging
-from .base import get_block_candidates, ModTool, ModToolException
+from .base import get_block_candidates, ModTool, ModToolException, validate_name
logger = logging.getLogger(__name__)
@@ -33,8 +33,7 @@ class ModToolRename(ModTool):
ModTool._validate(self)
if not self.info['oldname']:
raise ModToolException('Old block name (blockname) not specified.')
- if not re.match('[a-zA-Z0-9_]+', self.info['oldname']):
- raise ModToolException('Invalid block name.')
+ validate_name('old block', self.info['oldname'])
block_candidates = get_block_candidates()
if self.info['oldname'] not in block_candidates:
choices = [x for x in block_candidates if self.info['oldname'] in x]
@@ -43,8 +42,7 @@ class ModToolRename(ModTool):
raise ModToolException("Blockname for renaming does not exists!")
if not self.info['newname']:
raise ModToolException('New blockname (new_name) not specified.')
- if not re.match('[a-zA-Z0-9_]+', self.info['newname']):
- raise ModToolException('Invalid new block name.')
+ validate_name('new block', self.info['newname'])
def assign(self):
self.info['fullnewname'] = self.info['modname'] + '_' + self.info['newname']