summaryrefslogtreecommitdiff
path: root/gr-utils/modtool/core/rename.py
diff options
context:
space:
mode:
authormormj <34754695+mormj@users.noreply.github.com>2021-11-24 11:48:10 -0500
committerGitHub <noreply@github.com>2021-11-24 11:48:10 -0500
commitd3e49a4e0c72ab81d18bf479d2f6cdccf443b616 (patch)
tree45576799fd50fe01dc894ce89c53682f8ddf680d /gr-utils/modtool/core/rename.py
parent6a4eef30b0ff16006ec31a901937619ff136737a (diff)
modtool: move OOTs equal to components for 3.10
* modtool: move OOTs equal to components for 3.10 Signed-off-by: Josh Morman <jmorman@gnuradio.org> * pybind: update some python dir references Signed-off-by: Josh Morman <jmorman@gnuradio.org> * cmake: have pybind address the correct header Signed-off-by: Josh Morman <jmorman@gnuradio.org> * runtime: extend the python search path allow OOT modules to be installed in other places in PYTHONPATH that have a gnuradio directory Signed-off-by: Josh Morman <jmorman@gnuradio.org> * modtool: update python paths for rm Signed-off-by: Josh Morman <jmorman@gnuradio.org> * modtool: minor fixes for new dir structure Signed-off-by: Josh Morman <jmorman@gnuradio.org> * modtool: update the installed cmake targets Signed-off-by: Josh Morman <jmorman@gnuradio.org> * modtool: add include(CMakePackageConfigHelpers) Signed-off-by: Josh Morman <jmorman@gnuradio.org> * modtool: test_modules dir under gnuradio Signed-off-by: Josh Morman <jmorman@gnuradio.org>
Diffstat (limited to 'gr-utils/modtool/core/rename.py')
-rw-r--r--gr-utils/modtool/core/rename.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/gr-utils/modtool/core/rename.py b/gr-utils/modtool/core/rename.py
index edae90389a..da032ed022 100644
--- a/gr-utils/modtool/core/rename.py
+++ b/gr-utils/modtool/core/rename.py
@@ -96,17 +96,17 @@ class ModToolRename(ModTool):
logger.info("No C++ QA code detected, skipping...")
def _run_include(self, module, old, new):
- path = './include/' + module + '/'
- filename = path + old + '.h'
+ path = self.info['includedir']
+ filename = os.path.join(path, old + '.h')
self._run_file_replace(filename, old, new)
self._run_file_replace(filename, old.upper(), new.upper()) # take care of include guards
self._run_cmakelists(path, old, new, '.h')
self._run_file_rename(path, old, new, '.h')
def _run_python(self, module, old, new):
- path = './python/'
+ path = self.info['pydir']
filename = '__init__.py'
- nsubs = self._run_file_replace(path + filename, old, new)
+ nsubs = self._run_file_replace(os.path.join(path, filename), old, new)
if nsubs > 0:
logger.info("Python block detected, renaming...")
filename = old + '.py'
@@ -117,20 +117,20 @@ class ModToolRename(ModTool):
logger.info("Not a Python block, nothing to do here...")
def _run_pybind(self, module, old, new):
- path = './python/bindings/'
- filename = path + old + '_python.cc'
+ path = os.path.join(self.info['pydir'],'bindings')
+ filename = os.path.join(path, old + '_python.cc')
self._run_file_replace(filename, old, new)
self._run_file_rename(path, old, new, '_python.cc')
self._run_cmakelists(path, old, new, '_python.cc')
# update the hash in the new file
import hashlib
hasher = hashlib.md5()
- header_filename = './include/' + module + '/' + new + '.h' # note this requires _run_pybind to be called after _run_include
+ header_filename = os.path.join(self.info['includedir'], new + '.h') # note this requires _run_pybind to be called after _run_include
with open(header_filename, 'rb') as file_in:
buf = file_in.read()
hasher.update(buf)
newhash = hasher.hexdigest()
- newfilename = path + new + '_python.cc'
+ newfilename = os.path.join(path, new + '_python.cc')
with open(newfilename) as f:
file_txt = f.read()
m = re.search(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)', file_txt)
@@ -143,18 +143,18 @@ class ModToolRename(ModTool):
filename = path + 'python_bindings.cc'
self._run_file_replace(filename, ' bind_' + old + '\\(', ' bind_' + new + '(')
- path = './python/bindings/docstrings/'
- filename = path + old + '_pydoc_template.h'
+ path = os.path.join(path, 'docstrings')
+ filename = os.path.join(path, old + '_pydoc_template.h')
self._run_file_replace(filename, old, new)
self._run_file_rename(path, old, new, '_pydoc_template.h')
def _run_python_qa(self, module, old, new):
new = 'qa_' + new
old = 'qa_' + old
- filename = './python/' + old + '.py'
+ filename = os.path.join(self.info['pydir'], old + '.py')
self._run_file_replace(filename, old, new)
- self._run_cmakelists('./python/', old, new, '.py')
- self._run_file_rename('./python/', old, new, '.py')
+ self._run_cmakelists(self.info['pydir'], old, new, '.py')
+ self._run_file_rename(self.info['pydir'], old, new, '.py')
def _run_grc_rename(self, module, old, new):
grcfile = './grc/' + module + '_' + old + '.block.yml'
@@ -163,7 +163,7 @@ class ModToolRename(ModTool):
self._run_file_rename('./grc/', module + '_' + old, module + '_' + new, '.block.yml')
def _run_cmakelists(self, path, first, second, suffix):
- filename = path + 'CMakeLists.txt'
+ filename = os.path.join(path, 'CMakeLists.txt')
# space character and suffix ensures similiarly named blocks are not mixed up
nsubs = self._run_file_replace(filename, ' ' + first + suffix, ' ' + second + suffix)
if nsubs < 1:
@@ -177,8 +177,8 @@ class ModToolRename(ModTool):
for file in files:
if re.search(old_regex, file):
nl = file.replace(old, new)
- src = path + file
- dst = path + nl
+ src = os.path.join(path, file)
+ dst = os.path.join(path, nl)
logger.info(f"Renaming file '{src}' to '{dst}'.")
os.rename(src, dst)