From 07c83d29a133d9ce4e4c22245cc65672b343f10b Mon Sep 17 00:00:00 2001 From: duplo Date: Fri, 23 Apr 2010 10:14:07 +0000 Subject: [PATCH] Creating a new project from a preset the Wizard copy also the files contained into the preset project dir. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3503 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BProject.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/wizard/BProject.py b/wizard/BProject.py index 7d80236f..b5617ee2 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -160,6 +160,8 @@ class BProject(object): self.setEnabledModules(project_data["ENABLED_MODULES"]) self.infos["PROJECT_NAME"] = old_project_name self.infos["PROJECT_PATH"] = old_project_path + self.infos["PRESET_NAME"] = project_data.get("PROJECT_NAME", os.path.basename(preset)) + self.infos["PRESET_PATH"] = preset def loadProjectPresets(self): """ @@ -310,14 +312,10 @@ class BProject(object): def _newBertosProjectFromPreset(self): # Create/write/copy the common things self._newBertosProject() - - # Copy the sources files - # TODO: implement it! - - # Copy the user mk predefined file - # TODO: implement it! - - # Copy the main.c file (if the user doesn't check the empty main checkbox) + + # Copy all the files and dirs except cfg/hw/*_wiz.mk + self._writeCustomSrcFiles() + # Override the main.c with the empty one if requested by the user # TODO: implement it! # Create project files for selected plugins @@ -405,6 +403,19 @@ class BProject(object): f.write(string) f.close() + def _writeCustomSrcFiles(self): + preset = self.infos["PRESET_PATH"] + preset_name = self.infos["PRESET_NAME"] + origin = os.path.join(preset, preset_name) + project_related_stuff = ("cfg", "hw", self.infos["PROJECT_NAME"] + "_wiz.mk") + const.IGNORE_LIST + for element in os.listdir(origin): + if element not in project_related_stuff: + element = os.path.join(origin, element) + if os.path.isdir(element): + copytree.copytree(element, self.prjdir, ignore_list=const.IGNORE_LIST) + else: + shutil.copy(element, self.prjdir) + def _setupAutoenabledParameters(self): for module, information in self.infos["MODULES"].items(): if "configuration" in information and information["configuration"] != "": -- 2.25.1