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-391815-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1REZwd-0005Jj-8v
	for garchives@archives.gentoo.org; Fri, 14 Oct 2011 05:04:31 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 7BEA621C089;
	Fri, 14 Oct 2011 05:04:23 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 4E3B921C089
	for <gentoo-commits@lists.gentoo.org>; Fri, 14 Oct 2011 05:04:23 +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 CF58C1B4013
	for <gentoo-commits@lists.gentoo.org>; Fri, 14 Oct 2011 05:04:22 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id EFB3A80042
	for <gentoo-commits@lists.gentoo.org>; Fri, 14 Oct 2011 05:04:21 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" <zmedico@gentoo.org>
Message-ID: <5a0344bffc31a171afe43092a088084c329320fb.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/portageq
X-VCS-Directories: bin/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: 5a0344bffc31a171afe43092a088084c329320fb
Date: Fri, 14 Oct 2011 05:04:21 +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: 786784a8e5ad9593bde62dc8d6b1195d

commit:     5a0344bffc31a171afe43092a088084c329320fb
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 14 05:04:04 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Oct 14 05:04:04 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a=
=3Dcommit;h=3D5a0344bf

portageq match: wildcard support

---
 bin/portageq |   43 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index b416b66..eaeca60 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -546,15 +546,42 @@ def match(argv):
 		print("ERROR: expected 2 parameters, got %d!" % len(argv))
 		sys.exit(2)
 	root, atom =3D argv
-	if atom:
-		if atom_validate_strict and not portage.isvalidatom(atom):
-			portage.writemsg("ERROR: Invalid atom: '%s'\n" % atom,
-				noiselevel=3D-1)
-			return 2
-		results =3D portage.db[root]["vartree"].dbapi.match(atom)
-	else:
-		results =3D portage.db[root]["vartree"].dbapi.cpv_all()
+	if not atom:
+		atom =3D "*/*"
+
+	vardb =3D portage.db[root]["vartree"].dbapi
+	try:
+		atom =3D portage.dep.Atom(atom, allow_wildcard=3DTrue, allow_repo=3DTr=
ue)
+	except portage.exception.InvalidAtom:
+		# maybe it's valid but missing category
+		atom =3D portage.dep_expand(atom, mydb=3Dvardb, settings=3Dvardb.setti=
ngs)
+
+	if atom.extended_syntax:
+		if atom =3D=3D "*/*":
+			results =3D vardb.cpv_all()
+		else:
+			results =3D []
+			require_metadata =3D atom.slot or atom.repo
+			for cpv in vardb.cpv_all():
+
+				if not portage.dep.extended_cp_match(
+					atom.cp, portage.cpv_getkey(cpv)):
+					continue
+
+				if require_metadata:
+					slot, repo =3D vardb.aux_get(cpv, ["SLOT", "repository"])
+
+					if atom.slot is not None and atom.slot !=3D slot:
+						continue
+
+					if atom.repo is not None and atom.repo !=3D repo:
+						continue
+
+				results.append(cpv)
+
 		results.sort()
+	else:
+		results =3D vardb.match(atom)
 	for cpv in results:
 		print(cpv)
 match.uses_root =3D True