diff options
author | crupest <crupest@outlook.com> | 2022-02-08 16:53:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-08 16:53:51 +0800 |
commit | 74bb9cd27242b9320f99ff4d2b50c3051576cc14 (patch) | |
tree | 744bac5799c593d1d6f81e7b09581bea626f2cde /tools | |
parent | b90c398de829d1ba5329651d75bae82f5e4085fe (diff) | |
download | cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.gz cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.bz2 cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.zip |
...
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/migrate-2/rename-hpp-to-h.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/migrate-2/rename-hpp-to-h.py b/tools/migrate-2/rename-hpp-to-h.py new file mode 100755 index 00000000..c72fb2e0 --- /dev/null +++ b/tools/migrate-2/rename-hpp-to-h.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import os.path + +project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +def rename_hpp_to_h(dir): + for root, dirs, files in os.walk(dir): + for file in files: + if file.endswith(".hpp"): + os.rename(os.path.join(root, file), os.path.join(root, file[:-4] + ".h")) + +rename_hpp_to_h(os.path.join(project_root, "include")) +rename_hpp_to_h(os.path.join(project_root, "src")) +rename_hpp_to_h(os.path.join(project_root, "test")) +rename_hpp_to_h(os.path.join(project_root, "demos")) + +def replace_hpp_with_h(file): + with open(file, "r") as f: + content = f.read() + content = content.replace(".hpp", ".h") + with open(file, "w") as f: + f.write(content) + +def replace_hpp_with_h_recursive(dir): + for root, dirs, files in os.walk(dir): + for file in files: + if file.endswith(".cpp") or file.endswith(".h") or file.endswith(".mm"): + replace_hpp_with_h(os.path.join(root, file)) + +replace_hpp_with_h_recursive(os.path.join(project_root, "include")) +replace_hpp_with_h_recursive(os.path.join(project_root, "src")) +replace_hpp_with_h_recursive(os.path.join(project_root, "test")) +replace_hpp_with_h_recursive(os.path.join(project_root, "demos")) |