diff --git a/Script/formatCode.py b/Script/formatCode.py index 95abb675..600c775f 100644 --- a/Script/formatCode.py +++ b/Script/formatCode.py @@ -3,13 +3,15 @@ import os import os.path +import subprocess path = os.getcwd() +excluded_directories = ["pybind11", "/openssl", "/zlib", "/build/generated/", "cmake-build-debug/", "cmake-build-release", "CMakeFiles"] for root, dirs, files in os.walk(path): - if (root.find("pybind11") != -1) or root.endswith("/openssl") or root.endswith("/zlib") or (root.find("/build/generated/") != -1) or (root.find("cmake-build-debug/") != -1) or (root.find("cmake-build-release") != -1) or (root.find("CMakeFiles") != -1): - continue - for name in files: - if (name.endswith(".h") or name.endswith(".m") or name.endswith(".mm") or name.endswith(".hpp") or name.endswith(".cpp") or name.endswith(".java")): - localpath = root + '/' + name - print localpath - os.system("clang-format -i %s -style=File" %(localpath)) + if any(excluded_dir in root for excluded_dir in excluded_directories): + continue + for name in files: + if name.endswith((".h", ".m", ".mm", ".hpp", ".cpp", ".java")): + localpath = os.path.join(root, name) + print(localpath) + subprocess.run(["clang-format", "-i", localpath, "-style=File"], check=True)