From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/pkgcorepm/, gentoopm/paludispm/, gentoopm/basepm/
Date: Sat, 23 Jul 2011 09:27:44 +0000 (UTC) [thread overview]
Message-ID: <d1fb230cde458c56a8251b5499987032226df8b3.mgorny@gentoo> (raw)
commit: d1fb230cde458c56a8251b5499987032226df8b3
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 23 09:12:35 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Jul 23 09:12:35 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=d1fb230c
Support comparing PMPackageVersions.
---
gentoopm/basepm/atom.py | 4 ++++
gentoopm/paludispm/atom.py | 3 +++
gentoopm/pkgcorepm/atom.py | 8 ++++++++
gentoopm/portagepm/atom.py | 5 ++++-
4 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py
index b37b46f..9fa2c39 100644
--- a/gentoopm/basepm/atom.py
+++ b/gentoopm/basepm/atom.py
@@ -93,6 +93,10 @@ class PMPackageVersion(ABCObject, StringCompat):
"""
pass
+ @abstractmethod
+ def __lt__(self, other):
+ pass
+
class PMAtom(ABCObject, StringifiedComparisons):
"""
A base class for PM-specific atom (dependency specification).
diff --git a/gentoopm/paludispm/atom.py b/gentoopm/paludispm/atom.py
index 3b54de3..c416cb1 100644
--- a/gentoopm/paludispm/atom.py
+++ b/gentoopm/paludispm/atom.py
@@ -51,6 +51,9 @@ class PaludisPackageVersion(PMPackageVersion):
def __str__(self):
return str(self._v)
+ def __lt__(self, other):
+ return self._v < other._v
+
class PaludisAtom(PMAtom):
def _init_atom(self, s, env, wildcards = False):
opts = paludis.UserPackageDepSpecOptions() \
diff --git a/gentoopm/pkgcorepm/atom.py b/gentoopm/pkgcorepm/atom.py
index c903131..698864e 100644
--- a/gentoopm/pkgcorepm/atom.py
+++ b/gentoopm/pkgcorepm/atom.py
@@ -67,6 +67,11 @@ class PkgCorePackageVersion(PMPackageVersion):
def __str__(self):
return self._atom.fullver
+ def __lt__(self, other):
+ if self._atom.key != other._atom.key:
+ raise NotImplementedError('Unable to compare versions of distinct packages')
+ return self._atom < other._atom
+
class PkgCoreIncompletePackageVersion(PMPackageVersion):
def __init__(self, r):
self._r = _find_res(r, VersionMatch)
@@ -81,6 +86,9 @@ class PkgCoreIncompletePackageVersion(PMPackageVersion):
def revision(self):
return self._r.rev or 0
+ def __lt__(self, other):
+ raise NotImplementedError('Unable to compare versions of incomplete atoms')
+
def __str__(self):
# XXX: ugly?
return str(self._r).split()[-1]
diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index e893033..28b273d 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -8,7 +8,7 @@ import collections
import portage.exception as pe
from portage.dbapi.dep_expand import dep_expand
from portage.dep import match_from_list
-from portage.versions import catsplit, pkgsplit, cpv_getversion
+from portage.versions import catsplit, pkgsplit, cpv_getversion, vercmp
from gentoopm.basepm.atom import PMAtom, PMPackageKey, PMPackageVersion, \
PMIncompletePackageKey
@@ -49,6 +49,9 @@ class PortagePackageVersion(PMPackageVersion):
def __str__(self):
return cpv_getversion(self._cpv)
+ def __lt__(self, other):
+ return vercmp(str(self), str(other)) < 0
+
class FakeSettings(object):
"""
Fake settings object, to satisfy cpv_expand().
next reply other threads:[~2011-07-23 9:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-23 9:27 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-09-16 7:39 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/pkgcorepm/, gentoopm/paludispm/, gentoopm/basepm/ Michał Górny
2011-08-15 9:01 Michał Górny
2011-08-15 8:48 Michał Górny
2011-08-15 7:57 Michał Górny
2011-08-14 14:22 Michał Górny
2011-08-12 8:24 Michał Górny
2011-08-01 17:14 Michał Górny
2011-07-30 18:39 Michał Górny
2011-07-30 8:13 Michał Górny
2011-07-28 19:54 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-27 21:32 Michał Górny
2011-07-27 16:24 Michał Górny
2011-07-27 16:24 Michał Górny
2011-07-21 8:47 Michał Górny
2011-07-20 18:02 Michał Górny
2011-07-20 9:41 Michał Górny
2011-07-19 11:53 Michał Górny
2011-07-18 17:54 Michał Górny
2011-07-18 14:40 Michał Górny
2011-07-15 22:24 Michał Górny
2011-07-15 22:24 Michał Górny
2011-07-14 14:05 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-14 12:19 Michał Górny
2011-07-13 16:09 Michał Górny
2011-07-13 16:09 Michał Górny
2011-07-12 8:31 Michał Górny
2011-07-07 12:52 Michał Górny
2011-07-07 9:51 Michał Górny
2011-07-06 20:54 Michał Górny
2011-07-06 16:03 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d1fb230cde458c56a8251b5499987032226df8b3.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox