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 <gentoo-commits+bounces-362706-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1Qhf4c-0007Zv-C5
	for garchives@archives.gentoo.org; Fri, 15 Jul 2011 09:52:42 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 6B7EE21C161;
	Fri, 15 Jul 2011 09:52:29 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 3822121C161
	for <gentoo-commits@lists.gentoo.org>; Fri, 15 Jul 2011 09:52:29 +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 B44D12AC2F9
	for <gentoo-commits@lists.gentoo.org>; Fri, 15 Jul 2011 09:52:28 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 8BDA18003F
	for <gentoo-commits@lists.gentoo.org>; Fri, 15 Jul 2011 09:52:27 +0000 (UTC)
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Message-ID: <03b5890a0ef8a714cff2c0a0c6aaf661eba69552.mgorny@gentoo>
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
X-VCS-Repository: proj/gentoopm
X-VCS-Files: gentoopm/basepm/pkg.py
X-VCS-Directories: gentoopm/basepm/
X-VCS-Committer: mgorny
X-VCS-Committer-Name: Michał Górny
X-VCS-Revision: 03b5890a0ef8a714cff2c0a0c6aaf661eba69552
Date: Fri, 15 Jul 2011 09:52:27 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: fa4ddde6908fcf3714483838046657fb

commit:     03b5890a0ef8a714cff2c0a0c6aaf661eba69552
Author:     Micha=C5=82 G=C3=B3rny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 09:41:05 2011 +0000
Commit:     Micha=C5=82 G=C3=B3rny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 09:41:05 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;=
a=3Dcommit;h=3D03b5890a

PackageSet: support checking for non-empty (__nonzero__()).

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

diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index dc0364b..77532aa 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -141,6 +141,19 @@ class PMPackageSet(ABCObject):
 			return False
 		return True
=20
+	def __nonzero__(self):
+		"""
+		Check whether the package set is non-empty.
+
+		@return: True if package set matches at least one package.
+		@rtype: bool
+		"""
+		try:
+			next(iter(self))
+		except StopIteration:
+			return False
+		return True
+
 class PMFilteredPackageSet(PMPackageSet):
 	def __init__(self, src, args, kwargs):
 		self._src =3D src