From: duplo Date: Wed, 28 Apr 2010 08:42:03 +0000 (+0000) Subject: Remove useless while loops X-Git-Tag: 2.5.0~352 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=47219caf366ee98c051346d9e3fbdd30eca45827;p=bertos.git Remove useless while loops git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3556 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 7c05a17c..a6bef914 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -161,8 +161,7 @@ def userMkGenerator(project_info): mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH")) mk_data["$main"] = os.path.join("$(%s_SRC_PATH)" %project_info.info("PROJECT_NAME"), "main.c") for key in mk_data: - while makefile.find(key) != -1: - makefile = makefile.replace(key, mk_data[key]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def mkGenerator(project_info): @@ -184,8 +183,7 @@ def mkGenerator(project_info): mk_data["$prefix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[0]) mk_data["$suffix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[1]) for key in mk_data: - while makefile.find(key) != -1: - makefile = makefile.replace(key, mk_data[key]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def makefileGenerator(project_info): @@ -199,8 +197,7 @@ def makefileGenerator(project_info): mk_data["$pname"] = project_info.info("PROJECT_NAME") mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH")) for key in mk_data: - while makefile.find(key) != -1: - makefile = makefile.replace(key, mk_data[key]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def csrcGenerator(project_info): @@ -322,8 +319,7 @@ def replaceSeparators(path): Replace the separators in the given path with unix standard separator. """ if os.sep != "/": - while path.find(os.sep) != -1: - path = path.replace(os.sep, "/") + path = path.replace(os.sep, "/") return path def getSystemPath(): diff --git a/wizard/compatibility.py b/wizard/compatibility.py index 4d873f64..bf05c093 100644 --- a/wizard/compatibility.py +++ b/wizard/compatibility.py @@ -45,8 +45,7 @@ def _userMkGenerator(project_info): mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH")) mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c" for key in mk_data: - while makefile.find(key) != -1: - makefile = makefile.replace(key, mk_data[key]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def _mkGenerator(project_info): @@ -68,8 +67,7 @@ def _mkGenerator(project_info): mk_data["$suffix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[1]) mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c" for key in mk_data: - while makefile.find(key) != -1: - makefile = makefile.replace(key, mk_data[key]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def _makefileGenerator(project_info): @@ -79,8 +77,7 @@ def _makefileGenerator(project_info): makefile = open(os.path.join(const.DATA_DIR, "mktemplates/old/Makefile"), "r").read() destination = os.path.join(project_info.maindir, "Makefile") # TODO write a general function that works for both the mk file and the Makefile - while makefile.find("$pname") != -1: - makefile = makefile.replace("$pname", project_info.info("PROJECT_NAME")) + makefile = makefile.replace("$pname", project_info.info("PROJECT_NAME")) open(destination, "w").write(makefile) def updateProject(project_data): diff --git a/wizard/plugins/codelite.py b/wizard/plugins/codelite.py index 7f4daac8..16388233 100644 --- a/wizard/plugins/codelite.py +++ b/wizard/plugins/codelite.py @@ -103,15 +103,11 @@ def codeliteProjectGenerator(project_info): filelist = "\n".join(clFiles(findSources(project_info.info("PROJECT_PATH")), "")) debugger_path = project_info.info("TOOLCHAIN")["path"].replace("gcc", "gdb") init_script = project_info.info("CPU_INFOS")["GDB_INIT_SCRIPT"] - while template.find("$filelist") != -1: - template = template.replace("$filelist", filelist) + template = template.replace("$filelist", filelist) project_name = os.path.basename(project_info.info("PROJECT_PATH")) - while template.find("$project") != -1: - template = template.replace("$project", project_name) - while template.find("$debuggerpath") != -1: - template = template.replace("$debuggerpath", debugger_path) - while template.find("$initscript") != -1: - template = template.replace("$initscript", init_script) + template = template.replace("$project", project_name) + template = template.replace("$debuggerpath", debugger_path) + template = template.replace("$initscript", init_script) return template def codeliteWorkspaceGenerator(project_info): @@ -120,6 +116,5 @@ def codeliteWorkspaceGenerator(project_info): """ template = open(os.path.join(const.DATA_DIR, "cltemplates/bertos.workspace"), "r").read() project_name = os.path.basename(project_info.info("PROJECT_PATH")) - while template.find("$project") != -1: - template = template.replace("$project", project_name) + template = template.replace("$project", project_name) return template