From: duplo Date: Mon, 20 Apr 2009 08:19:09 +0000 (+0000) Subject: Remove the invalid use of keys() dict method X-Git-Tag: 2.1.0~124 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=912352d333ac869de55ea4945c03a49d163f6da4;p=bertos.git Remove the invalid use of keys() dict method git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2558 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BCreationPage.py b/wizard/BCreationPage.py index e40db963..c6c74a4e 100644 --- a/wizard/BCreationPage.py +++ b/wizard/BCreationPage.py @@ -50,14 +50,14 @@ class BCreationPage(BWizardPage): top_level.append(cpu_title) toolchain_title = QTreeWidgetItem(QStringList([self.tr("Toolchain")])) toolchain_info = self.projectInfo("TOOLCHAIN") - if "target" in toolchain_info.keys(): + if "target" in toolchain_info: toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([self.tr("target: " + toolchain_info["target"])])) version = "" - if "version" in toolchain_info.keys(): + if "version" in toolchain_info: version += "version: " + "GCC " + toolchain_info["version"] + " " - if "build" in toolchain_info.keys(): + if "build" in toolchain_info: version += "(" + toolchain_info["build"] + ")" - if "version" in toolchain_info.keys(): + if "version" in toolchain_info: toolchain_target = QTreeWidgetItem(toolchain_title, QStringList([version])) toolchain_path = QTreeWidgetItem(toolchain_title, QStringList([self.tr("path: " + os.path.normpath(toolchain_info["path"]))])) top_level.append(toolchain_title) @@ -66,7 +66,7 @@ class BCreationPage(BWizardPage): module_categories = {} for module, information in self.projectInfo("MODULES").items(): if information["enabled"]: - if information["category"] not in module_categories.keys(): + if information["category"] not in module_categories: module_categories[information["category"]] = [] moduleItem = QTreeWidgetItem(QStringList([module + " - " + information["description"]])) module_categories[information["category"]].append(moduleItem) diff --git a/wizard/BModulePage.py b/wizard/BModulePage.py index e0bcd9db..6fb43624 100644 --- a/wizard/BModulePage.py +++ b/wizard/BModulePage.py @@ -118,9 +118,9 @@ class BModulePage(BWizardPage): item = QTableWidgetItem(configurations[property]["brief"]) item.setData(Qt.UserRole, qvariant_converter.convertString(property)) self.pageContent.propertyTable.setItem(index, 0, item) - if "type" in configurations[property]["informations"].keys() and configurations[property]["informations"]["type"] == "boolean": + if "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "boolean": self.insertCheckBox(index, configurations[property]["value"]) - elif "type" in configurations[property]["informations"].keys() and configurations[property]["informations"]["type"] == "enum": + elif "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "enum": self.insertComboBox(index, configurations[property]["value"], configurations[property]["informations"]["value_list"]) elif "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "int": self.insertSpinBox(index, configurations[property]["value"], configurations[property]["informations"]) @@ -152,7 +152,7 @@ class BModulePage(BWizardPage): """ self.resetPropertyDescription() configurations = self.currentModuleConfigurations() - if self.currentProperty() in configurations.keys(): + if self.currentProperty() in configurations: description = configurations[self.currentProperty()]["brief"] name = self.currentProperty() self.currentPropertyItem().setText(description + "\n" + name) @@ -164,7 +164,7 @@ class BModulePage(BWizardPage): property = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole)) configuration = self.projectInfo("MODULES")[self.currentModule()]["configuration"] configurations = self.projectInfo("CONFIGURATIONS") - if "type" not in configurations[configuration][property]["informations"].keys() or configurations[configuration][property]["informations"]["type"] == "int": + if "type" not in configurations[configuration][property]["informations"] or configurations[configuration][property]["informations"]["type"] == "int": configurations[configuration][property]["value"] = str(int(self.pageContent.propertyTable.cellWidget(index, 1).value())) elif configurations[configuration][property]["informations"]["type"] == "enum": configurations[configuration][property]["value"] = unicode(self.pageContent.propertyTable.cellWidget(index, 1).currentText()) @@ -203,7 +203,7 @@ class BModulePage(BWizardPage): return categories = {} for module, information in modules.items(): - if information["category"] not in categories.keys(): + if information["category"] not in categories: categories[information["category"]] = [] categories[information["category"]].append(module) for category, module_list in categories.items(): @@ -284,9 +284,9 @@ class BModulePage(BWizardPage): minimum = 0 maximum = 4294967295 suff = "UL" - if "min" in informations.keys(): + if "min" in informations: minimum = int(informations["min"]) - if "max" in informations.keys(): + if "max" in informations: maximum = int(informations["max"]) spin_box.setRange(minimum, maximum) spin_box.setSuffix(suff) @@ -340,7 +340,7 @@ class BModulePage(BWizardPage): for index in range(self.pageContent.propertyTable.rowCount()): property_name = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole)) # Awful solution! Needed because if the user change the module, the selection changed... - if property_name not in self.currentModuleConfigurations().keys(): + if property_name not in self.currentModuleConfigurations(): break self.pageContent.propertyTable.item(index, 0).setText(self.currentModuleConfigurations()[property_name]['brief']) diff --git a/wizard/BProject.py b/wizard/BProject.py index 54db258a..95e514c1 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -4,7 +4,7 @@ # Copyright 2008 Develer S.r.l. (http://www.develer.com/) # All rights reserved. # -# $Id:$ +# $Id$ # # Author: Lorenzo Berni # @@ -27,7 +27,7 @@ class BProject(object): """ Retrieve the value associated with the name key. """ - if key in self.infos.keys(): + if key in self.infos: return self.infos[key] return None diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index 3c5ab357..9d575a13 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -163,7 +163,7 @@ class BToolchainPage(BWizardPage): toolchain_list = bertos_utils.findToolchains(dir_list) stored_toolchains = self.toolchains() for element in toolchain_list: - if not element in stored_toolchains.keys(): + if not element in stored_toolchains: item = QListWidgetItem(element) item.setData(Qt.UserRole, qvariant_converter.convertStringDict({"path": element})) self.pageContent.toolchainList.addItem(item) @@ -179,11 +179,11 @@ class BToolchainPage(BWizardPage): new_data.update(infos) item.setData(Qt.UserRole, qvariant_converter.convertStringDict(new_data)) needed = self.projectInfo("CPU_INFOS") - if "target" in infos.keys() and infos["target"].find(needed["TOOLCHAIN"]) != -1: + if "target" in infos and infos["target"].find(needed["TOOLCHAIN"]) != -1: item.setIcon(QIcon(":/images/ok.png")) else: item.setIcon(QIcon(":/images/warning.png")) - if "version" in infos.keys() and "target" in infos.keys(): + if "version" in infos and "target" in infos: item.setText("GCC " + infos["version"] + " - " + infos["target"].strip()) def _invalidItem(self, index): @@ -215,7 +215,7 @@ class BToolchainPage(BWizardPage): if self._validation_process.waitForFinished(200): description = str(self._validation_process.readAllStandardError()) info = bertos_utils.getToolchainInfo(description) - if len(info.keys()) >= 4: + if len(info) >= 4: valid = True else: self._validation_process.kill() diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index e6c2380a..17794579 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -79,9 +79,9 @@ def createBertosProject(project_info): for start, parameter in information["paramlist"]: infos = information[parameter] value = infos["value"] - if "unsigned" in infos["informations"].keys() and infos["informations"]["unsigned"]: + if "unsigned" in infos["informations"] and infos["informations"]["unsigned"]: value += "U" - if "long" in infos["informations"].keys() and infos["informations"]["long"]: + if "long" in infos["informations"] and infos["informations"]["long"]: value += "L" string = sub(string, parameter, value) f = open(cfgdir + "/" + os.path.basename(configuration), "w") @@ -342,11 +342,11 @@ def loadModuleDefinition(first_comment): elif line.find("\\brief") != -1: module_definition["module_description"] = line[line.find("\\brief") + len("\\brief "):] module_dict = {} - if "module_name" in module_definition.keys(): + if "module_name" in module_definition: module_name = module_definition[const.MODULE_DEFINITION["module_name"]] del module_definition[const.MODULE_DEFINITION["module_name"]] module_dict[module_name] = {} - if const.MODULE_DEFINITION["module_depends"] in module_definition.keys(): + if const.MODULE_DEFINITION["module_depends"] in module_definition: depends = module_definition[const.MODULE_DEFINITION["module_depends"]] del module_definition[const.MODULE_DEFINITION["module_depends"]] if type(depends) == str: @@ -354,20 +354,20 @@ def loadModuleDefinition(first_comment): module_dict[module_name]["depends"] = depends else: module_dict[module_name]["depends"] = () - if const.MODULE_DEFINITION["module_configuration"] in module_definition.keys(): + if const.MODULE_DEFINITION["module_configuration"] in module_definition: module_dict[module_name]["configuration"] = module_definition[const.MODULE_DEFINITION["module_configuration"]] del module_definition[const.MODULE_DEFINITION["module_configuration"]] else: module_dict[module_name]["configuration"] = "" - if "module_description" in module_definition.keys(): + if "module_description" in module_definition: module_dict[module_name]["description"] = module_definition["module_description"] del module_definition["module_description"] - if const.MODULE_DEFINITION["module_harvard"] in module_definition.keys(): + 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 del module_definition[const.MODULE_DEFINITION["module_harvard"]] - if const.MODULE_DEFINITION["module_hw"] in module_definition.keys(): + if const.MODULE_DEFINITION["module_hw"] in module_definition: hw = module_definition[const.MODULE_DEFINITION["module_hw"]] del module_definition[const.MODULE_DEFINITION["module_hw"]] if type(hw) == str: @@ -375,7 +375,7 @@ def loadModuleDefinition(first_comment): module_dict[module_name]["hw"] = hw else: module_dict[module_name]["hw"] = () - if const.MODULE_DEFINITION["module_supports"] in module_definition.keys(): + if const.MODULE_DEFINITION["module_supports"] in module_definition: supports = module_definition[const.MODULE_DEFINITION["module_supports"]] del module_definition[const.MODULE_DEFINITION["module_supports"]] module_dict[module_name]["supports"] = supports @@ -485,7 +485,7 @@ def loadModuleData(project): information["depends"] = () information["depends"] += (filename.split(".")[0],) information["category"] = os.path.basename(path) - if "configuration" in information.keys() and len(information["configuration"]): + if "configuration" in information and len(information["configuration"]): configuration = module_dict[module]["configuration"] try: configuration_info[configuration] = loadConfigurationInfos(project.info("SOURCES_PATH") + "/" + configuration) @@ -544,12 +544,12 @@ def loadConfigurationInfos(path): configuration_infos[name]["informations"] = informations if not "type" in configuration_infos[name]["informations"]: configuration_infos[name]["informations"]["type"] = findParameterType(configuration_infos[name]) - if ("type" in configuration_infos[name]["informations"].keys() and + if ("type" in configuration_infos[name]["informations"] and configuration_infos[name]["informations"]["type"] == "int" and configuration_infos[name]["value"].find("L") != -1): configuration_infos[name]["informations"]["long"] = True configuration_infos[name]["value"] = configuration_infos[name]["value"].replace("L", "") - if ("type" in configuration_infos[name]["informations"].keys() and + if ("type" in configuration_infos[name]["informations"] and configuration_infos[name]["informations"]["type"] == "int" and configuration_infos[name]["value"].find("U") != -1): configuration_infos[name]["informations"]["unsigned"] = True @@ -574,7 +574,7 @@ def isInt(informations): """ Return True if the value is a simple int. """ - if ("long" not in informatios.keys() or not informations["long"]) and ("unsigned" not in informations.keys() or informations["unsigned"]): + if ("long" not in informatios or not informations["long"]) and ("unsigned" not in informations or informations["unsigned"]): return True else: return False @@ -583,7 +583,7 @@ def isLong(informations): """ Return True if the value is a long. """ - if "long" in informations.keys() and informations["long"] and "unsigned" not in informations.keys(): + if "long" in informations and informations["long"] and "unsigned" not in informations: return True else: return False @@ -592,7 +592,7 @@ def isUnsigned(informations): """ Return True if the value is an unsigned. """ - if "unsigned" in informations.keys() and informations["unsigned"] and "long" not in informations.keys(): + if "unsigned" in informations and informations["unsigned"] and "long" not in informations: return True else: return False @@ -601,7 +601,7 @@ def isUnsignedLong(informations): """ Return True if the value is an unsigned long. """ - if "unsigned" in informations.keys() and "long" in informations.keys() and informations["unsigned"] and informations["long"]: + if "unsigned" in informations and "long" in informations and informations["unsigned"] and informations["long"]: return True else: return False