From 7562a56b7a5a762f4b958eda8c4464127bfb21e2 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 21 Dec 2007 11:14:44 +0000 Subject: Enhance the portageq match command to list all installed packages when given an empty string. svn path=/main/trunk/; revision=9033 --- bin/portageq | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'bin/portageq') diff --git a/bin/portageq b/bin/portageq index f23598f75..bf1852f55 100755 --- a/bin/portageq +++ b/bin/portageq @@ -238,17 +238,22 @@ all_best_visible.uses_root = True def match(argv): - """ - Returns \n seperated list of category/package-version + """ + Returns a \\n separated list of category/package-version. + When given an empty string, all installed packages will + be listed. """ - if (len(argv) < 2): - print "ERROR: insufficient parameters!" + if len(argv) != 2: + print "ERROR: expected 2 parameters, got %d!" % len(argv) sys.exit(2) - try: - print "\n".join(portage.db[argv[0]]["vartree"].dbapi.match(argv[1])) - except KeyError, e: - portage.writemsg("%s\n" % str(e), noiselevel=-1) - sys.exit(1) + root, atom = argv + if atom: + results = portage.db[root]["vartree"].dbapi.match(atom) + else: + results = portage.db[root]["vartree"].dbapi.cpv_all(atom) + results.sort() + for cpv in results: + print cpv match.uses_root = True -- cgit v1.2.3-1-g7c22