From 6ca39d731ab09303c06d32206516306088c32f9e Mon Sep 17 00:00:00 2001 From: duplo Date: Tue, 21 Jul 2009 13:36:38 +0000 Subject: [PATCH] Add the project loader function in order to implement the editing non destructive mode git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2760 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/bertos_utils.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 567eeb70..fff47c6c 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -63,14 +63,11 @@ def loadBertosProject(project_file): project_info.setInfo("CPU_NAME", cpu_name) cpu_info = loadCpuInfos(project_info) for cpu in cpu_info: - print cpu["CPU_NAME"], cpu_name if cpu["CPU_NAME"] == cpu_name: - print "sono uguali" project_info.setInfo("CPU_INFOS", cpu) break - loadModuleData(project_info) - print project_info - + loadModuleData(project_info, True) + return project_info def projectFileGenerator(project_info): directory = project_info.info("PROJECT_PATH") @@ -83,7 +80,6 @@ def projectFileGenerator(project_info): project_data["SOURCES_PATH"] = project_info.info("SOURCES_PATH") project_data["TOOLCHAIN"] = project_info.info("TOOLCHAIN") project_data["CPU_NAME"] = project_info.info("CPU_NAME") - print project_info.info("CPU_NAME") project_data["SELECTED_FREQ"] = project_info.info("SELECTED_FREQ") return pickle.dumps(project_data) @@ -431,8 +427,7 @@ def loadModuleDefinition(first_comment): del module_definition["module_description"] if const.MODULE_DEFINITION["module_harvard"] in module_definition: harvard = module_definition[const.MODULE_DEFINITION["module_harvard"]] - if harvard == "both" or harvard == "pgm_memory": - module_dict[module_name]["harvard"] = harvard + module_dict[module_name]["harvard"] = harvard del module_definition[const.MODULE_DEFINITION["module_harvard"]] if const.MODULE_DEFINITION["module_hw"] in module_definition: hw = module_definition[const.MODULE_DEFINITION["module_hw"]] @@ -533,7 +528,7 @@ def getDefinitionBlocks(text): block.append(([comment], define, start)) return block -def loadModuleData(project): +def loadModuleData(project, edit=False): module_info_dict = {} list_info_dict = {} configuration_info_dict = {} @@ -558,6 +553,14 @@ def loadModuleData(project): configuration_info[configuration] = loadConfigurationInfos(project.info("SOURCES_PATH") + "/" + configuration) except ParseError, err: raise DefineException.ConfigurationDefineException(project.info("SOURCES_PATH") + "/" + configuration, err.line_number, err.line) + if edit: + try: + path = os.path.basename(project.info("PROJECT_PATH")) + directory = project.info("PROJECT_PATH") + user_configuration = loadConfigurationInfos(directory + "/" + configuration.replace("bertos", path)) + configuration_info[configuration] = updateConfigurationValues(configuration_info[configuration], user_configuration) + except ParseError, err: + raise DefineException.ConfigurationDefineException(directory + "/" + configuration.replace("bertos", path)) module_info_dict.update(module_dict) configuration_info_dict.update(configuration_info) if to_be_parsed: @@ -625,6 +628,11 @@ def loadConfigurationInfos(path): configuration_infos[name]["brief"] = brief return configuration_infos +def updateConfigurationValues(def_conf, user_conf): + for param in def_conf["paramlist"]: + def_conf[param[1]]["value"] = user_conf[param[1]]["value"] + return def_conf + def findParameterType(parameter): if "value_list" in parameter["informations"]: return "enum" -- 2.25.1