[extensions-web] Ignore micro versions when doing a query lookup
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Ignore micro versions when doing a query lookup
- Date: Tue, 14 Feb 2012 18:37:27 +0000 (UTC)
commit 49aadae53956cfb654f49e89a09963fd17b535d5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Feb 14 13:36:43 2012 -0500
Ignore micro versions when doing a query lookup
sweettooth/extensions/models.py | 15 ++++++++++-----
sweettooth/extensions/views.py | 2 +-
2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 6e5b4d5..c76018a 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -158,7 +158,7 @@ class InvalidShellVersion(Exception):
pass
class ShellVersionManager(models.Manager):
- def parse_version_string(self, version_string):
+ def parse_version_string(self, version_string, ignore_micro):
version = version_string.split('.')
major, minor = version[:2]
@@ -167,7 +167,12 @@ class ShellVersionManager(models.Manager):
except ValueError, e:
raise InvalidShellVersion()
- if len(version) == 3:
+ if ignore_micro:
+ valid_lengths = (3, 4)
+ else:
+ valid_lengths = (3,)
+
+ if len(version) in valid_lengths:
# 3.0.1, 3.1.4
try:
point = int(version[2])
@@ -183,15 +188,15 @@ class ShellVersionManager(models.Manager):
return major, minor, point
- def lookup_for_version_string(self, version_string):
- major, minor, point = self.parse_version_string(version_string)
+ def lookup_for_version_string(self, version_string, ignore_micro=False):
+ major, minor, point = self.parse_version_string(version_string, ignore_micro)
try:
return self.get(major=major, minor=minor, point=point)
except self.model.DoesNotExist:
return None
def get_for_version_string(self, version_string):
- major, minor, point = self.parse_version_string(version_string)
+ major, minor, point = self.parse_version_string(version_string, ignore_micro=False)
obj, created = self.get_or_create(major=major, minor=minor, point=point)
return obj
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 35afea0..8db311b 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -74,7 +74,7 @@ def shell_update(request):
def get_versions_for_version_strings(version_strings):
for version_string in version_strings:
- version = models.ShellVersion.objects.lookup_for_version_string(version_string)
+ version = models.ShellVersion.objects.lookup_for_version_string(version_string, ignore_micro=True)
if version is None:
continue
yield version
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]