def NormalizeModuleAPIMacro(filepath, macro): #RE_API_MACRO = r"(class|struct)\s*(\w+_API)\s+\w+" RE_API_MACRO = r"\s+([A-Z]+_API)\s+" if macro == "": return pass lines = FileUtils.GetAllLines(filepath) num = len(lines) changed = False for i in range(0, num): line = lines[i] match = re.search(RE_API_MACRO, line) if not match == None: old = match.group(1) if not old == macro: line = line.replace(old, macro) changed = True lines[i] = line pass pass pass if changed: logging.warning("NormalizeModuleAPIMacro: %s", filepath) f = open(filepath, "w", encoding="UTF-8") f.writelines(lines) f.close() else: logging.info("NormalizeModuleAPIMacro: %s, No Changed", filepath) pass
def NormalizeIncludeSlash(filepath): lines = FileUtils.GetAllLines(filepath) num = len(lines) changed = False for i in range(0, num): line = lines[i] if line.startswith("#include "): if line.find("\\") > 0: changed = True line = line.replace("\\", "/") lines[i] = line pass pass pass if changed: logging.warning("NormalizeIncludeSlash: %s", filepath) f = open(filepath, "w", encoding="UTF-8") f.writelines(lines) f.close() else: logging.info("NormalizeIncludeSlash: %s, No Changed", filepath) pass