From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qeufv-00065D-DJ for garchives@archives.gentoo.org; Thu, 07 Jul 2011 19:55:51 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A565021C04F; Thu, 7 Jul 2011 19:55:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 6958021C04F for ; Thu, 7 Jul 2011 19:55:43 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EBF8B2AC05E for ; Thu, 7 Jul 2011 19:55:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 0BAFB8003D for ; Thu, 7 Jul 2011 19:55:42 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/basepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/basepm/pkg.py gentoopm/portagepm/pkg.py X-VCS-Directories: gentoopm/portagepm/ gentoopm/basepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: a23f4f0a03bb3a09aa588c6f819bad94e1e27e67 Date: Thu, 7 Jul 2011 19:55:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 9e112e2c8b770a453e12c1beb4704d5e commit: a23f4f0a03bb3a09aa588c6f819bad94e1e27e67 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Thu Jul 7 19:55:50 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Thu Jul 7 19:55:50 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3Da23f4f0a 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 packag= e name).') =20 + 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 =3D iter(self.filter(arg)) + try: + next(i) + except StopIteration: + return False + return True + class PMFilteredPackageSet(PMPackageSet): def __init__(self, it, args, kwargs): self._iter =3D 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)