summaryrefslogtreecommitdiff
path: root/gr-utils/modtool/core/makeyaml.py
diff options
context:
space:
mode:
authorSolomon <solomonbstoner@yahoo.com.au>2021-06-25 20:27:32 +0800
committerGitHub <noreply@github.com>2021-06-25 08:27:32 -0400
commitac738e2a6db48f13929c780d89a87ba5e916e2d3 (patch)
treeb598981e7001780661808b404576caa60f7192c6 /gr-utils/modtool/core/makeyaml.py
parent5ed43ed63b20d74a2641c8d1e547f84cd98179e4 (diff)
modtool: Fix `rm`, `disable`, `rename` and `makeyml` similar naming
* modtool: Fix issue #2672 for `rm` In the event that the user specifies only one specific block to delete, this PR ensures that the files for said block is not confused with files of similarly named blocks. Signed-off-by: Solomon Tan <solomonbstoner@yahoo.com.au> * modtool: Fix issue #2672 for `rename` and more This commit fixes the following for the `rename` command. 1. Issue #2672 that also affects `rename` 2. Fixes errorneous replacement of similarly named blocks in CMakeLists 3. Replaced the file search in `_run_file_rename` from `file.find` to `re.search` so that block names will not be confused with names with one or two prefix characters (e.g. "decoder" vs "adecoder"). 4. Renames the bind function in `python_bindings.cc` as well. Signed-off-by: Solomon Tan <solomonbstoner@yahoo.com.au> * modtool: Fix Issue #2672 for `disable` & more When the user specifies a block name, only the block with that specific blockname should be disabled. Prior to this PR, all blocks matching said specified block name are disabled. This PR fixes it. This PR also fixes what appears to be a spelling error `self._info`. The error is thrown for OOT module version 38: Attribute error `'ModToolDisable' object has no attribute '_info'` Signed-off-by: Solomon Tan <solomonbstoner@yahoo.com.au> * modtool: Fix Issue #2672 for `makeyaml` This PR fixes issue #2672 which also affects the `makeyaml` command. Signed-off-by: Solomon Tan <solomonbstoner@yahoo.com.au>
Diffstat (limited to 'gr-utils/modtool/core/makeyaml.py')
-rw-r--r--gr-utils/modtool/core/makeyaml.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/gr-utils/modtool/core/makeyaml.py b/gr-utils/modtool/core/makeyaml.py
index 1117dd3664..bd4fd7b535 100644
--- a/gr-utils/modtool/core/makeyaml.py
+++ b/gr-utils/modtool/core/makeyaml.py
@@ -93,9 +93,29 @@ class ModToolMakeYAML(ModTool):
files = sorted(glob.glob(f"{path}/{path_glob}"))
files_filt = []
logger.info(f"Searching for matching files in {path}/:")
- for f in files:
- if re.search(self.info['pattern'], os.path.basename(f)) is not None:
- files_filt.append(f)
+ if self.info['blockname']:
+ # ensure the blockname given is not confused with similarly named blocks
+ blockname_pattern = ''
+ if path == 'python':
+ blockname_pattern = f"^(qa_)?{self.info['blockname']}.py$"
+ elif path == 'python/bindings':
+ blockname_pattern = f"^{self.info['blockname']}_python.cc$"
+ elif path == 'python/bindings/docstrings':
+ blockname_pattern = f"^{self.info['blockname']}_pydoc_template.h$"
+ elif path == 'lib':
+ blockname_pattern = f"^{self.info['blockname']}_impl(\\.h|\\.cc)$"
+ elif path == self.info['includedir']:
+ blockname_pattern = f"^{self.info['blockname']}.h$"
+ elif path == 'grc':
+ blockname_pattern = f"^{self.info['modname']}_{self.info['blockname']}.block.yml$"
+ for f in files:
+ if re.search(blockname_pattern, os.path.basename(f)) is not None:
+ files_filt.append(f)
+ elif self.info['pattern']:
+ # search for block names matching a given regex pattern
+ for f in files:
+ if re.search(self.info['pattern'], os.path.basename(f)) is not None:
+ files_filt.append(f)
if len(files_filt) == 0:
logger.info("None found.")
return files_filt