From 95b71bb91147ac88fa10fed3385ce2f0307fe13c Mon Sep 17 00:00:00 2001 From: duplo Date: Mon, 26 Apr 2010 13:48:10 +0000 Subject: [PATCH] Change SOURCES_PATH in BERTOS_PATH. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3515 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BCreationPage.py | 2 +- wizard/BEditingDialog.py | 14 +++++------ wizard/BProject.py | 36 +++++++++++++-------------- wizard/BVersionPage.py | 6 ++--- wizard/_wizard_version.py | 2 +- wizard/bertos.py | 2 +- wizard/bertos_utils.py | 20 +++++++-------- wizard/test/testCpuTagsImport.py | 2 +- wizard/test/testLoadProjectPresets.py | 2 +- wizard/test/testModulePage.py | 2 +- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/wizard/BCreationPage.py b/wizard/BCreationPage.py index 1d48ac30..225aa2e2 100644 --- a/wizard/BCreationPage.py +++ b/wizard/BCreationPage.py @@ -65,7 +65,7 @@ class BCreationPage(BWizardPage): folder_item = QTreeWidgetItem(folder_title, QStringList([os.path.normpath(self.projectInfo("PROJECT_PATH"))])) top_level.append(folder_title) version_title = QTreeWidgetItem(QStringList([self.tr("BeRTOS version")])) - sources_path = self.projectInfo("SOURCES_PATH") + sources_path = self.projectInfo("BERTOS_PATH") version = QTreeWidgetItem(version_title, QStringList([self.tr("version: ") + bertos_utils.bertosVersion(sources_path)])) source_path = QTreeWidgetItem(version_title, QStringList([self.tr("path: ") + os.path.normpath(sources_path)])) top_level.append(version_title) diff --git a/wizard/BEditingDialog.py b/wizard/BEditingDialog.py index 2a0b9798..f4cb468f 100644 --- a/wizard/BEditingDialog.py +++ b/wizard/BEditingDialog.py @@ -118,7 +118,7 @@ class BEditingDialog(QDialog): dialog.toolchain_page.setProjectInfo("TOOLCHAIN", toolchain) def changeBertosVersion(self): - current_version = self.module_page.projectInfo("SOURCES_PATH") + current_version = self.module_page.projectInfo("BERTOS_PATH") dialog = BVersionDialog() if dialog.exec_(): version = qvariant_converter.getString(dialog.version_page.currentItem().data(Qt.UserRole)) @@ -130,8 +130,8 @@ class BEditingDialog(QDialog): ) == QMessageBox.Ok: try: qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) - dialog.version_page.setProjectInfo("SOURCES_PATH", version) - dialog.version_page.setProjectInfo("OLD_SOURCES_PATH", current_version) + dialog.version_page.setProjectInfo("BERTOS_PATH", version) + dialog.version_page.setProjectInfo("OLD_BERTOS_PATH", current_version) enabled_modules = bertos_utils.enabledModules(dialog.version_page.project) old_configuration = dialog.version_page.projectInfo("CONFIGURATIONS") dialog.version_page.project.loadSourceTree() @@ -152,7 +152,7 @@ class BEditingDialog(QDialog): qApp.restoreOverrideCursor() else: # Rollback version to the previous selected one. - dialog.version_page.setProjectInfo("SOURCES_PATH", current_version) + dialog.version_page.setProjectInfo("BERTOS_PATH", current_version) def apply(self): try: @@ -175,10 +175,10 @@ class BEditingDialog(QDialog): return self.module_page.versions() def currentVersion(self): - return self.module_page.projectInfo("SOURCES_PATH") + return self.module_page.projectInfo("BERTOS_PATH") def setCurrentVersion(self, version): - self.module_page.setProjectInfo("SOURCES_PATH", version) + self.module_page.setProjectInfo("BERTOS_PATH", version) class BToolchainDialog(QDialog): def __init__(self): @@ -228,7 +228,7 @@ class BVersionDialog(QDialog): layout.addLayout(button_layout) self.setLayout(layout) self.connect(ok_button, SIGNAL("clicked()"), self.accept) - current_version = version_page.projectInfo("SOURCES_PATH") + current_version = version_page.projectInfo("BERTOS_PATH") self.setWindowTitle(self.tr("Change BeRTOS version")) diff --git a/wizard/BProject.py b/wizard/BProject.py index 3129857e..decb6468 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -93,14 +93,14 @@ class BProject(object): wizard_version = project_data.get("WIZARD_VERSION", 0) if wizard_version < 1: - # Ignore the SOURCES_PATH inside the project file for older project - project_data["SOURCES_PATH"] = project_dir + # Ignore the BERTOS_PATH inside the project file for older project + project_data["BERTOS_PATH"] = project_dir else: - linked_sources_path = project_data["SOURCES_PATH"] + linked_sources_path = project_data["BERTOS_PATH"] sources_abspath = os.path.abspath(os.path.join(project_dir, linked_sources_path)) - project_data["SOURCES_PATH"] = sources_abspath + project_data["BERTOS_PATH"] = sources_abspath - self._loadBertosSourceStuff(project_data["SOURCES_PATH"], info_dict.get("SOURCES_PATH", None)) + self._loadBertosSourceStuff(project_data["BERTOS_PATH"], info_dict.get("BERTOS_PATH", None)) self.infos["PRESET"] = project_data.get("PRESET", False) @@ -120,7 +120,7 @@ class BProject(object): if forced_version: sources_path = forced_version if os.path.exists(sources_path): - self.infos["SOURCES_PATH"] = sources_path + self.infos["BERTOS_PATH"] = sources_path else: raise VersionException(self) @@ -193,7 +193,7 @@ class BProject(object): Load the default presets (into the const.PREDEFINED_BOARDS_DIR). """ # NOTE: this method does nothing (for now). - preset_path = os.path.join(self.infos["SOURCES_PATH"], const.PREDEFINED_BOARDS_DIR) + preset_path = os.path.join(self.infos["BERTOS_PATH"], const.PREDEFINED_BOARDS_DIR) preset_tree = {} if os.path.exists(preset_path): preset_tree = self._loadProjectPresetTree(preset_path) @@ -246,9 +246,9 @@ class BProject(object): if "configuration" in information and len(information["configuration"]): configuration = module_dict[module]["configuration"] try: - configuration_info[configuration] = loadConfigurationInfos(self.infos["SOURCES_PATH"] + "/" + configuration) + configuration_info[configuration] = loadConfigurationInfos(self.infos["BERTOS_PATH"] + "/" + configuration) except ParseError, err: - raise DefineException.ConfigurationDefineException(self.infos["SOURCES_PATH"] + "/" + configuration, err.line_number, err.line) + raise DefineException.ConfigurationDefineException(self.infos["BERTOS_PATH"] + "/" + configuration, err.line_number, err.line) if edit: try: path = self.infos["PROJECT_SRC_PATH"] @@ -277,8 +277,8 @@ class BProject(object): """ Index BeRTOS source and load it in memory. """ - # Index only the SOURCES_PATH/bertos content - bertos_sources_dir = os.path.join(self.info("SOURCES_PATH"), "bertos") + # Index only the BERTOS_PATH/bertos content + bertos_sources_dir = os.path.join(self.info("BERTOS_PATH"), "bertos") file_dict = {} if os.path.exists(bertos_sources_dir): for element in os.walk(bertos_sources_dir): @@ -490,11 +490,11 @@ class BProject(object): @property def old_srcdir(self): - return self.infos.get("OLD_SOURCES_PATH", None) + return self.infos.get("OLD_BERTOS_PATH", None) @property def sources_dir(self): - return self.infos.get("SOURCES_PATH", None) + return self.infos.get("BERTOS_PATH", None) @property def from_preset(self): @@ -541,8 +541,8 @@ class BProject(object): return [(filename, dirname) for dirname in file_dict.get(filename, [])] def findDefinitions(self, ftype): - # Maintain a cache for every scanned SOURCES_PATH - definitions_dict = self._cached_queries.get(self.infos["SOURCES_PATH"], {}) + # Maintain a cache for every scanned BERTOS_PATH + definitions_dict = self._cached_queries.get(self.infos["BERTOS_PATH"], {}) definitions = definitions_dict.get(ftype, None) if definitions is not None: return definitions @@ -552,11 +552,11 @@ class BProject(object): if fnmatch.fnmatch(filename, ftype): definitions += [(filename, dirname) for dirname in file_dict.get(filename, [])] - # If no cache for the current SOURCES_PATH create an empty one + # If no cache for the current BERTOS_PATH create an empty one if not definitions_dict: - self._cached_queries[self.infos["SOURCES_PATH"]] = {} + self._cached_queries[self.infos["BERTOS_PATH"]] = {} # Fill the empty cache with the result - self._cached_queries[self.infos["SOURCES_PATH"]][ftype] = definitions + self._cached_queries[self.infos["BERTOS_PATH"]][ftype] = definitions return definitions def setEnabledModules(self, enabled_modules): diff --git a/wizard/BVersionPage.py b/wizard/BVersionPage.py index 452e8a94..7c205554 100644 --- a/wizard/BVersionPage.py +++ b/wizard/BVersionPage.py @@ -65,7 +65,7 @@ class BVersionPage(BWizardPage): # Remove the trailing slash if sources_path.endswith(os.sep): sources_path = sources_path[:-1] - self.setProjectInfo("SOURCES_PATH", sources_path) + self.setProjectInfo("BERTOS_PATH", sources_path) return True else: return False @@ -193,12 +193,12 @@ class BVersionPage(BWizardPage): """ versions = set([]) if self._edit: - versions.add(self.projectInfo("SOURCES_PATH")) + versions.add(self.projectInfo("BERTOS_PATH")) if os.name == "nt": import winreg_importer versions |= set([os.path.normpath(dir) for dir in winreg_importer.getBertosDirs()]) versions |= set([os.path.normpath(dir) for dir in self.versions()]) - selected = self.projectInfo("SOURCES_PATH") + selected = self.projectInfo("BERTOS_PATH") for directory in versions: item = self.insertListElement(directory) if selected and selected == directory: diff --git a/wizard/_wizard_version.py b/wizard/_wizard_version.py index da574507..c262e383 100644 --- a/wizard/_wizard_version.py +++ b/wizard/_wizard_version.py @@ -39,7 +39,7 @@ # Previous versions: # 0 - the project file doesn't contain the version number. # When the current Wizard is opening project done with this version of -# the Wizard it has to change the origina SOURCES_PATH to the local path +# the Wizard it has to change the origina BERTOS_PATH to the local path # 1 - this is the current version. No special behaviours needed. diff --git a/wizard/bertos.py b/wizard/bertos.py index ce6bd30f..c53674a9 100755 --- a/wizard/bertos.py +++ b/wizard/bertos.py @@ -96,7 +96,7 @@ def editProject(project_file): dialog = BVersionDialog() if dialog.exec_(): version = dialog.version_page.currentVersion() - info_dict["SOURCES_PATH"] = version + info_dict["BERTOS_PATH"] = version continue except ToolchainException, exc: QMessageBox.critical( diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 972438df..d65a39b0 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -111,13 +111,13 @@ def projectFileGenerator(project_info): enabled_modules.append(module) project_data["ENABLED_MODULES"] = enabled_modules if project_info.info("PRESET"): - # For presets save again the SOURCES_PATH into project file + # For presets save again the BERTOS_PATH into project file project_data["PRESET"] = True - project_data["SOURCES_PATH"] = project_info.info("SOURCES_PATH") + project_data["BERTOS_PATH"] = project_info.info("BERTOS_PATH") else: # Use the local BeRTOS version instead of the original one - # project_data["SOURCES_PATH"] = project_info.info("SOURCES_PATH") - project_data["SOURCES_PATH"] = directory + # project_data["BERTOS_PATH"] = project_info.info("BERTOS_PATH") + project_data["BERTOS_PATH"] = directory project_data["PROJECT_NAME"] = project_info.info("PROJECT_NAME", os.path.basename(directory)) project_data["PROJECT_SRC_PATH"] = project_info.info("PROJECT_SRC_PATH") project_data["TOOLCHAIN"] = project_info.info("TOOLCHAIN") @@ -134,7 +134,7 @@ def loadPlugin(plugin): return getattr(__import__("plugins", {}, {}, [plugin]), plugin) def versionFileGenerator(project_info, version_file): - version = bertosVersion(project_info.info("SOURCES_PATH")) + version = bertosVersion(project_info.info("BERTOS_PATH")) return version_file.replace('$version', version) def userMkGenerator(project_info, makefile): @@ -252,13 +252,13 @@ def findModuleFiles(module, project_info): sfiles = [] # .c files related to the module and the cpu architecture for filename, path in project_info.searchFiles(module + ".c"): - path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + path = path.replace(project_info.info("BERTOS_PATH") + os.sep, "") path = replaceSeparators(path) cfiles.append(path + "/" + filename) # .s files related to the module and the cpu architecture for filename, path in project_info.searchFiles(module + ".s") + \ project_info.searchFiles(module + ".S"): - path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + path = path.replace(project_info.info("BERTOS_PATH") + os.sep, "") path = replaceSeparators(path) sfiles.append(path + "/" + filename) # .c and .s files related to the module and the cpu tags @@ -267,7 +267,7 @@ def findModuleFiles(module, project_info): # Awful, but secure check for version # TODO: split me in a method/function try: - version_string = bertosVersion(project_info.info("SOURCES_PATH")) + version_string = bertosVersion(project_info.info("BERTOS_PATH")) version_list = [int(i) for i in version_string.split()[-1].split('.')] if version_list < [2, 5]: # For older versions of BeRTOS add the toolchain to the tags @@ -278,13 +278,13 @@ def findModuleFiles(module, project_info): for tag in tags: for filename, path in project_info.searchFiles(module + "_" + tag + ".c"): - path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + path = path.replace(project_info.info("BERTOS_PATH") + os.sep, "") if os.sep != "/": path = replaceSeparators(path) cfiles.append(path + "/" + filename) for filename, path in project_info.searchFiles(module + "_" + tag + ".s") + \ project_info.searchFiles(module + "_" + tag + ".S"): - path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + path = path.replace(project_info.info("BERTOS_PATH") + os.sep, "") path = replaceSeparators(path) sfiles.append(path + "/" + filename) return cfiles, sfiles diff --git a/wizard/test/testCpuTagsImport.py b/wizard/test/testCpuTagsImport.py index 79e3c774..df7491a1 100644 --- a/wizard/test/testCpuTagsImport.py +++ b/wizard/test/testCpuTagsImport.py @@ -44,7 +44,7 @@ from bertos_utils import * def main(): p = BProject.BProject() - p.setInfo("SOURCES_PATH", "../../") + p.setInfo("BERTOS_PATH", "../../") p.loadSourceTree() info = p.getCpuInfos() tags = getTagSet(info) diff --git a/wizard/test/testLoadProjectPresets.py b/wizard/test/testLoadProjectPresets.py index 8076e9cc..7167f39d 100644 --- a/wizard/test/testLoadProjectPresets.py +++ b/wizard/test/testLoadProjectPresets.py @@ -44,7 +44,7 @@ from bertos_utils import * def main(): p = BProject.BProject() - p.setInfo("SOURCES_PATH", "../../") + p.setInfo("BERTOS_PATH", "../../") p.loadProjectPresets() diff --git a/wizard/test/testModulePage.py b/wizard/test/testModulePage.py index ce23fade..6b355984 100644 --- a/wizard/test/testModulePage.py +++ b/wizard/test/testModulePage.py @@ -52,7 +52,7 @@ def main(): app = QApplication([]) app.project = BProject.BProject() page = BModulePage.BModulePage() - page.setProjectInfo("SOURCES_PATH", "../../") + page.setProjectInfo("BERTOS_PATH", "../../") page.setProjectInfo("CPU_INFOS", {"TOOLCHAIN": "avr", "CPU_TAGS": []}) page.project().loadSourceTree() page.reloadData() -- 2.25.1