diff options
author | Swapnil Negi <swapnil.negi09@gmail.com> | 2019-11-16 20:41:01 +0530 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2020-01-03 22:34:21 -0800 |
commit | eafa2d050bc60c0cc8f6cc4b19a31960336ca0e0 (patch) | |
tree | bf3c38f013cd0660805a54d1a739537130004315 /gr-utils/python | |
parent | 590d73242d5755d3b98fc86e2f8f46ae4d9906a8 (diff) |
gr-modtool: Update the validation in Modtool Add
Diffstat (limited to 'gr-utils/python')
-rw-r--r-- | gr-utils/python/modtool/cli/add.py | 7 | ||||
-rw-r--r-- | gr-utils/python/modtool/core/add.py | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/gr-utils/python/modtool/cli/add.py b/gr-utils/python/modtool/cli/add.py index 694d49f5fe..af8b1f8c37 100644 --- a/gr-utils/python/modtool/cli/add.py +++ b/gr-utils/python/modtool/cli/add.py @@ -101,15 +101,15 @@ def get_lang(self): def get_blockname(self): """ Get the blockname""" - if self.info['blockname'] is None: + if not self.info['blockname'] or self.info['blockname'].isspace(): while not self.info['blockname'] or self.info['blockname'].isspace(): self.info['blockname'] = cli_input("Enter name of block/code (without module name prefix): ") - if not re.match('[a-zA-Z0-9_]+', self.info['blockname']): + if not re.match('^[a-zA-Z0-9_]+$', self.info['blockname']): raise ModToolException('Invalid block name.') def get_copyrightholder(self): """ Get the copyrightholder of the block to be added """ - if self.info['copyrightholder'] is None: + if not self.info['copyrightholder'] or self.info['copyrightholder'].isspace(): user = getpass.getuser() git_user = self.scm.get_gituser() if git_user: @@ -134,7 +134,6 @@ def get_arglist(self): default='', show_default=False) - def get_py_qa(self): """ Get a boolean value for addition of py_qa """ if not (self.info['blocktype'] in ('noblock') or self.skip_subdirs['python']): diff --git a/gr-utils/python/modtool/core/add.py b/gr-utils/python/modtool/core/add.py index 2ec57f4d2a..03587b28db 100644 --- a/gr-utils/python/modtool/core/add.py +++ b/gr-utils/python/modtool/core/add.py @@ -69,7 +69,7 @@ class ModToolAdd(ModTool): raise ModToolException('Invalid programming language.') if self.info['blockname'] is None: raise ModToolException('Blockname not specified.') - if not re.match('[a-zA-Z0-9_]+', self.info['blockname']): + if not re.match('^[a-zA-Z0-9_]+$', self.info['blockname']): raise ModToolException('Invalid block name.') if not isinstance(self.add_py_qa, bool): raise ModToolException('Expected a boolean value for add_python_qa.') |