diff options
author | Simon Schampijer <simon@schampijer.de> | 2010-11-09 10:57:05 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2010-11-09 10:57:05 (GMT) |
commit | 49232e552248e48063970ca67455462d11220468 (patch) | |
tree | f0f32befb0de040c4c1379c54a58821585cf35cb /src/jarabe/model/bundleregistry.py | |
parent | 2458e8d0e7695730e32e5d45bf753c0e7fbaf461 (diff) |
Adapt activity list and bundleregistry to new numbering scheme #2425
- the activities list view is changed to use a string for the version
- the comparisons in the bundleregistry have changed to use the new
numbering scheme
Diffstat (limited to 'src/jarabe/model/bundleregistry.py')
-rw-r--r-- | src/jarabe/model/bundleregistry.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py index 4de7e3f..846fce8 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: @@ -368,8 +371,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()): return True return False @@ -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()): if not force_downgrade: raise AlreadyInstalledException else: |