Extract _cmp function.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 24 May 2010 14:22:26 +0000 (14:22 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 24 May 2010 14:22:26 +0000 (14:22 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3809 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BBoardPage.py
wizard/BProjectPresets.py
wizard/bertos_utils.py

index 69a732e515dbb639ca2c4c5f199a796be4884bc0..301d46b7c36383abe30aa6a5aa50c11375d88686 100644 (file)
@@ -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)
 
index 1934c2da821f7d46e78bf9ae85b2c6bea64044e3..efb04d546c83ef6fcaa142a443bc910baf1a6bf2 100644 (file)
@@ -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)
 
index f10d7dc59fafc11de78f98398a20763a83fed4d6..465808aaf657fb26f28240a7e85f44083f6c93e2 100644 (file)
@@ -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")