[Sugar-devel] [PATCH] Adopt to new numbering scheme #2425

Simon Schampijer simon at schampijer.de
Mon Nov 1 14:01:47 EDT 2010


- the activities list view is changed to use a string for the version
- the comparisons in the bundleregistry is changed to use the new
numbering scheme
---
 src/jarabe/desktop/activitieslist.py |    2 +-
 src/jarabe/model/bundleregistry.py   |   17 ++++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/jarabe/desktop/activitieslist.py b/src/jarabe/desktop/activitieslist.py
index 56b3b5f..1d42282 100644
--- a/src/jarabe/desktop/activitieslist.py
+++ b/src/jarabe/desktop/activitieslist.py
@@ -167,7 +167,7 @@ class ListModel(gtk.TreeModelSort):
     COLUMN_DATE_TEXT = 7
 
     def __init__(self):
-        self._model = gtk.ListStore(str, bool, str, str, int, str, int, str)
+        self._model = gtk.ListStore(str, bool, str, str, str, str, int, str)
         self._model_filter = self._model.filter_new()
         gtk.TreeModelSort.__init__(self, self._model_filter)
 
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index 699e339..329a121 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -26,6 +26,7 @@ import simplejson
 
 from sugar.bundle.activitybundle import ActivityBundle
 from sugar.bundle.contentbundle import ContentBundle
+from sugar.bundle.bundleversion import NormalizedVersion
 from jarabe.journal.journalentrybundle import JournalEntryBundle
 from sugar.bundle.bundle import MalformedBundleException, \
     AlreadyInstalledException, RegistrationException
@@ -153,14 +154,16 @@ class BundleRegistry(gobject.GObject):
             return
 
         for bundle_id in default_activities:
-            max_version = -1
+            max_version = '0'
             for bundle in self._bundles:
                 if bundle.get_bundle_id() == bundle_id and \
-                        max_version < bundle.get_activity_version():
+                        NormalizedVersion(max_version) < \
+                        NormalizedVersion(bundle.get_activity_version()):
                     max_version = bundle.get_activity_version()
 
             key = self._get_favorite_key(bundle_id, max_version)
-            if max_version > -1 and key not in self._favorite_bundles:
+            if NormalizedVersion(max_version) > NormalizedVersion('0') and \
+                    key not in self._favorite_bundles:
                 self._favorite_bundles[key] = None
 
         logging.debug('After merging: %r', self._favorite_bundles)
@@ -243,8 +246,8 @@ class BundleRegistry(gobject.GObject):
         installed = self.get_bundle(bundle_id)
 
         if installed is not None:
-            if installed.get_activity_version() >= \
-                    bundle.get_activity_version():
+            if NormalizedVersion(installed.get_activity_version()) >= \
+                    NormalizedVersion(bundle.get_activity_version()):
                 logging.debug('Skip old version for %s', bundle_id)
                 return None
             else:
@@ -378,8 +381,8 @@ class BundleRegistry(gobject.GObject):
 
         for installed_bundle in self._bundles:
             if bundle.get_bundle_id() == installed_bundle.get_bundle_id() and \
-                    bundle.get_activity_version() <= \
-                        installed_bundle.get_activity_version():
+                    NormalizedVersion(bundle.get_activity_version()) <= \
+                        NormalizedVersion(installed_bundle.get_activity_version()):
                 raise AlreadyInstalledException
             elif bundle.get_bundle_id() == installed_bundle.get_bundle_id():
                 self.uninstall(installed_bundle, force=True)
-- 
1.7.2.3



More information about the Sugar-devel mailing list