summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Morman <mormjb@gmail.com>2020-05-29 13:27:54 -0400
committerJosh Morman <mormjb@gmail.com>2020-06-04 10:05:48 -0400
commit2af07cba8038587bc74abb0d9328a9284351f51c (patch)
tree8b8c25ba72f8e88a51b6fbbe0cffcf6340546724
parent13b6fc6435e21926977f33e90d93f6fb9530931c (diff)
pybind: update modtool rename
-rw-r--r--gr-utils/modtool/core/rename.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/gr-utils/modtool/core/rename.py b/gr-utils/modtool/core/rename.py
index 5888f8b1b8..61f98b3722 100644
--- a/gr-utils/modtool/core/rename.py
+++ b/gr-utils/modtool/core/rename.py
@@ -67,6 +67,7 @@ class ModToolRename(ModTool):
self._run_python(self.info['modname'], oldname, newname)
self._run_lib(self.info['modname'], oldname, newname)
self._run_include(self.info['modname'], oldname, newname)
+ self._run_pybind(self.info['modname'], oldname, newname)
return
def _run_lib(self, module, old, new):
@@ -117,6 +118,35 @@ class ModToolRename(ModTool):
else:
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'
+ self._run_file_replace(filename, old, new)
+ self._run_file_rename(path, old, new)
+ self._run_cmakelists(path, old, new)
+ # 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
+ with open(header_filename, 'rb') as file_in:
+ buf = file_in.read()
+ hasher.update(buf)
+ newhash = hasher.hexdigest()
+ newfilename = path + new + '_python.cc'
+ with open(newfilename) as f:
+ file_txt = f.read()
+ m = re.search(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)', file_txt)
+ if (m):
+ oldhash = m.group(1)
+ file_txt = re.sub(oldhash, newhash, file_txt)
+ with open(newfilename, "w") as f:
+ f.write(file_txt)
+
+ path = './python/bindings/docstrings/'
+ filename = path + old + '_pydoc_template.h'
+ self._run_file_replace(filename, old, new)
+ self._run_file_rename(path, old, new)
+
def _run_python_qa(self, module, old, new):
new = 'qa_' + new
old = 'qa_' + old