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 1Qeo40-0002vU-2j for garchives@archives.gentoo.org; Thu, 07 Jul 2011 12:52:16 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F350A21C0FD; Thu, 7 Jul 2011 12:52:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id C40D021C0FD for ; Thu, 7 Jul 2011 12:52:07 +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 57B461B403D for ; Thu, 7 Jul 2011 12:52:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 601748004A for ; Thu, 7 Jul 2011 12:52:06 +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: <079c751f832711fe8fd10e82ecf2cc5d6c9a6ab0.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: 079c751f832711fe8fd10e82ecf2cc5d6c9a6ab0 Date: Thu, 7 Jul 2011 12:52:06 +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: a9e198e207489fef52181e7ffba1c6e9 commit: 079c751f832711fe8fd10e82ecf2cc5d6c9a6ab0 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Thu Jul 7 12:50:41 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Thu Jul 7 12:52:42 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D079c751f Support applying the filters. --- gentoopm/basepm/pkg.py | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py index 1bb2447..f7e534a 100644 --- a/gentoopm/basepm/pkg.py +++ b/gentoopm/basepm/pkg.py @@ -5,6 +5,7 @@ =20 from abc import abstractmethod, abstractproperty =20 +from gentoopm.basepm.atom import PMAtom from gentoopm.util import ABCObject =20 class PMPackageSet(ABCObject): @@ -21,7 +22,7 @@ class PMPackageSet(ABCObject): evaluating to a number of PMPackages. =20 The positional arguments can provide a number of PMPackageMatchers (se= e - gentoopm.basepm.filter) and/or an atom string. The keyword arguments + gentoopm.basepm.filter) and/or a PMAtom instance. The keyword argument= s match metadata keys using '=3D=3D' comparison with passed string (or PMKeywordMatchers). =20 @@ -92,7 +93,15 @@ class PMPackage(ABCObject): If kwargs reference incorrect metadata keys, a KeyError will be raised= . """ =20 - # XXX: apply filters + for f in args: + if callable(f): # a matcher + if not f(self): + return False + elif isinstance(f, PMAtom): # an atom + if not self in f: + return False + else: + raise ValueError('Incorrect positional argument: %s' % f) =20 for k, m in kwargs.items(): try: