From: duplo Date: Mon, 24 May 2010 14:22:26 +0000 (+0000) Subject: Extract _cmp function. X-Git-Tag: 2.5.0~108 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=46cd7a45ea505ac9bb18d410e349b9553c95457a;p=bertos.git Extract _cmp function. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3809 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 69a732e5..301d46b7 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -46,7 +46,7 @@ from BRoutePage import BRoutePage import const import qvariant_converter -from bertos_utils import presetList +from bertos_utils import presetList, _cmp class BBoardPage(BWizardPage): """ @@ -96,8 +96,6 @@ class BBoardPage(BWizardPage): """ preset_list = self.projectInfo("PRESET_TREE") preset_list = preset_list["children"] - def _cmp(x, y): - return cmp(x["info"].get('ord', 0), y["info"].get('ord', 0)) preset_list = sorted(preset_list.values(), _cmp) self.setItems(preset_list) diff --git a/wizard/BProjectPresets.py b/wizard/BProjectPresets.py index 1934c2da..efb04d54 100644 --- a/wizard/BProjectPresets.py +++ b/wizard/BProjectPresets.py @@ -42,6 +42,8 @@ from PyQt4.QtGui import * from BWizardPage import BWizardPage +from bertos_utils import _cmp + import const import qvariant_converter @@ -60,8 +62,6 @@ class BProjectPresetsPage(QWidget): def setupUi(self): self.pageContent.presetList.clear() - def _cmp(x, y): - return cmp(x["info"].get('ord', 0), y["info"].get('ord', 0)) for preset in sorted(self.preset_data["children"].values(), _cmp): item_name = preset["info"].get("name", preset["info"]["filename"]) item_icon = os.path.join(preset["info"]["path"], const.PREDEFINED_BOARD_ICON_FILE) @@ -123,8 +123,6 @@ class BProjectPresets(BWizardPage): preset_path = self.projectInfo("PROJECT_BOARD") preset_tree = self.projectInfo("PRESET_TREE") preset_list = preset_tree["children"][preset_path]["children"] - def _cmp(x, y): - return cmp(x["info"].get('ord', 0), y["info"].get('ord', 0)) preset_list = sorted(preset_list.values(), _cmp) self.setupTabs(preset_list) diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index f10d7dc5..465808aa 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -51,6 +51,9 @@ from _wizard_version import WIZARD_VERSION from LoadException import VersionException, ToolchainException +def _cmp(x, y): + return cmp(x["info"].get('ord', 0), y["info"].get('ord', 0)) + def isBertosDir(directory): return os.path.exists(directory + "/VERSION")