diff options
author | alekhgupta1441 <alekhgupta1441@gmail.com> | 2020-04-11 04:34:36 +0530 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-04-11 02:35:23 +0200 |
commit | 3cb8a09e065f39e2b6db444d62f756dc03bf332d (patch) | |
tree | 24f12875957c9e919e8074bd0b15e339f31d8d19 | |
parent | 46247fc461866d1ea30bd924491404216aa096dc (diff) |
modtool: Updated get_blockname function to prevent same name blocks
-rw-r--r-- | gr-utils/modtool/cli/add.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gr-utils/modtool/cli/add.py b/gr-utils/modtool/cli/add.py index e65bac1176..e174fcde43 100644 --- a/gr-utils/modtool/cli/add.py +++ b/gr-utils/modtool/cli/add.py @@ -12,6 +12,7 @@ from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals +import os import re import getpass @@ -94,7 +95,13 @@ def get_blockname(self): 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']): raise ModToolException('Invalid block name.') - + for block in os.scandir('./grc/'): + if block.is_file(): + s = block.name + present_block = self.info['modname'] + "_" + self.info['blockname'] + ".block.yml" + if s == present_block: + raise ModToolException('Block Already Present.') + def get_copyrightholder(self): """ Get the copyrightholder of the block to be added """ if not self.info['copyrightholder'] or self.info['copyrightholder'].isspace(): |