From eafa2d050bc60c0cc8f6cc4b19a31960336ca0e0 Mon Sep 17 00:00:00 2001
From: Swapnil Negi <swapnil.negi09@gmail.com>
Date: Sat, 16 Nov 2019 20:41:01 +0530
Subject: gr-modtool: Update the validation in Modtool Add

---
 gr-utils/python/modtool/cli/add.py  | 7 +++----
 gr-utils/python/modtool/core/add.py | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

(limited to 'gr-utils/python')

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.')
-- 
cgit v1.2.3