Add the sub function for replace the default value of the cfg file with the user...
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 28 Jan 2009 10:27:28 +0000 (10:27 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 28 Jan 2009 10:27:28 +0000 (10:27 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2231 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py

index df26613f66785a662666a44edb5a076719566775..52d8acea59240d509949a1d550d20334158f0f5a 100644 (file)
@@ -29,9 +29,19 @@ def createBertosProject(directory, sources_dir, projectInfos):
     f = open(directory + "/project.bertos", "w")
     f.write(repr(projectInfos))
     f.close()
-    shutil.rmtree(directory + "/bertos", True)
-    shutil.copytree(sources_dir + "/bertos", directory + "/bertos")
-    shutil.copy(sources_dir + "/Makefile", directory + "/Makefile")
+    ## Destination source dir
+    srcdir = directory + "/bertos"
+    shutil.rmtree(srcdir, True)
+    shutil.copytree(sources_dir + "/bertos", srcdir)
+    ## Destination makefile
+    makefile = directory + "/Makefile"
+    if os.path.exists(makefile):
+        os.remove(makefile)
+    shutil.copy(sources_dir + "/Makefile", makefile)
+    ## Destination project dir
+    prjdir = directory + "/" + os.path.basename(directory)
+    shutil.rmtree(prjdir, True)
+    os.mkdir(prjdir)
 
 def getSystemPath():
     path = os.environ["PATH"]
@@ -213,4 +223,10 @@ def loadDefineListsDict(path):
     defineListsDict = {}
     for filename, path in findDefinitions("*.h", path):
         defineListsDict.update(loadDefineLists(path + "/" + filename))
-    return defineListsDict
\ No newline at end of file
+    return defineListsDict
+
+def sub(string, parameter, value):
+    """
+    Substitute the given value at the given parameter define in the given string
+    """
+    return re.sub(r"(?P<define>#define\s+" + parameter + r"\s+)([^\s]+)", r"\g<define>" + value, string)