diff options
author | Swapnil Negi <swapnil.negi09@gmail.com> | 2018-03-10 20:12:37 +0530 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-03-22 22:41:06 +0100 |
commit | 218ce76f2a0fd91acd957007d8806737a91d5191 (patch) | |
tree | 363929727ab110db9f7d79e8cd811cbc428708e6 | |
parent | 7edb8217a58027f1f80ea9404b0164721f812147 (diff) |
modtool: Avoid creation of same blockname
Fixes #1678
-rw-r--r-- | gr-utils/python/modtool/modtool_add.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py index 6719a02948..cc7e261c05 100644 --- a/gr-utils/python/modtool/modtool_add.py +++ b/gr-utils/python/modtool/modtool_add.py @@ -72,6 +72,18 @@ class ModToolAdd(ModTool): def setup(self, options, args): ModTool.setup(self, options, args) + if self._info['blockname'] is None: + if len(args) >= 2: + self._info['blockname'] = args[1] + else: + self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ") + if os.path.isfile("./lib/"+self._info['blockname']+"_impl.cc") or os.path.isfile("./python/"+self._info['blockname']+".py"): + raise ModToolException('The given blockname already exists!') + if not re.match('[a-zA-Z0-9_]+', self._info['blockname']): + raise ModToolException('Invalid block name.') + print "Block/code identifier: " + self._info['blockname'] + self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname'] + self._info['blocktype'] = options.block_type if self._info['blocktype'] is None: # Print list out of blocktypes to user for reference @@ -97,16 +109,7 @@ class ModToolAdd(ModTool): if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') or (self._skip_subdirs['python'] and self._info['lang'] == 'python')): raise ModToolException('Missing or skipping relevant subdir.') - - if self._info['blockname'] is None: - if len(args) >= 2: - self._info['blockname'] = args[1] - else: - self._info['blockname'] = raw_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.') - print "Block/code identifier: " + self._info['blockname'] - self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname'] + if not options.license_file: self._info['copyrightholder'] = options.copyright if self._info['copyrightholder'] is None: |