Remove useless while loops
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 28 Apr 2010 08:42:03 +0000 (08:42 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 28 Apr 2010 08:42:03 +0000 (08:42 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3556 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py
wizard/compatibility.py
wizard/plugins/codelite.py

index 7c05a17c244f9cc959cb16072a0706ae38aae71b..a6bef914e904d6d989f74ba1282e645333c4176e 100644 (file)
@@ -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():
index 4d873f64b6969031e53662e574c1b4de42e7d48c..bf05c09345b993afae42ee037033fb9e980f4de8 100644 (file)
@@ -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):
index 7f4daac885cb8d067ece5c27c01bbf879663ebf2..1638823304d0ad243fc2c7127496c63f45795126 100644 (file)
@@ -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