From 174db8b712c3b5d2b1ee136574f2dfe3c74ebb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Fri, 5 Feb 2010 14:53:02 +0000 Subject: [PATCH] Allow comparing Version objects with strings --- ChangeLog | 4 ++++ pisi/version.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 45fc86c8..dba61660 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-05 Fatih Aşıcı + * pisi/version.py (compare): Allow comparing Version objects + with strings. + 2010-02-04 Ozan Çağlayan * pisi/pxml/autoxml.py (format): Some optional elements may be None during formatting, handle those situations. We still have a formatting diff --git a/pisi/version.py b/pisi/version.py index f851bd91..da1deae7 100644 --- a/pisi/version.py +++ b/pisi/version.py @@ -182,6 +182,10 @@ class Version: not we use the comparison operator. And we iterate to the left. The result is, 0 if two are equal, -1 if self < rhs, and +1 if self>rhs""" + + if isinstance(ver, basestring): + ver = pisi.version.Version(ver) + lhs = self.comps rhs = ver.comps # pad the short version string with zeros