public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/basepm/
Date: Thu,  7 Jul 2011 19:55:42 +0000 (UTC)	[thread overview]
Message-ID: <a23f4f0a03bb3a09aa588c6f819bad94e1e27e67.mgorny@gentoo> (raw)

commit:     a23f4f0a03bb3a09aa588c6f819bad94e1e27e67
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  7 19:55:50 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul  7 19:55:50 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=a23f4f0a

Support checking for matching atoms through 'atom in pkgset'.

---
 gentoopm/basepm/pkg.py    |   13 +++++++++++++
 gentoopm/portagepm/pkg.py |    2 +-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index f7e534a..2e801e0 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -67,6 +67,19 @@ class PMPackageSet(ABCObject):
 		except KeyError:
 			raise ValueError('Ambiguous filter (matches more than a single package name).')
 
+	def __contains__(self, arg):
+		"""
+		Check whether the package set contains at least a single package
+		matching the filter or package atom passed as an argument.
+		"""
+
+		i = iter(self.filter(arg))
+		try:
+			next(i)
+		except StopIteration:
+			return False
+		return True
+
 class PMFilteredPackageSet(PMPackageSet):
 	def __init__(self, it, args, kwargs):
 		self._iter = it

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index ca2c054..d2ea1ad 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -52,7 +52,7 @@ class PortageCPV(PortageDBCPV):
 	def __cmp__(self, other):
 		if not isinstance(other, PortageCPV):
 			raise TypeError('Unable to compare %s against %s' % \
-					self, other)
+					(self, other))
 		return cmp(cpv_getkey(self._cpv), cpv_getkey(other._cpv)) \
 				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) \
 				or cmp(self._repo_prio, other._repo_prio)



             reply	other threads:[~2011-07-07 19:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-07 19:55 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-07-12  8:43 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/basepm/ 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=a23f4f0a03bb3a09aa588c6f819bad94e1e27e67.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