From: duplo Date: Wed, 28 Jan 2009 10:27:28 +0000 (+0000) Subject: Add the sub function for replace the default value of the cfg file with the user... X-Git-Tag: 2.1.0~451 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=3816a34bc452a608f5838ef5a4277f608ea4e313;p=bertos.git Add the sub function for replace the default value of the cfg file with the user choice git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2231 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index df26613f..52d8acea 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -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\s+" + parameter + r"\s+)([^\s]+)", r"\g" + value, string)