From: Zdenek Behan Date: Fri, 13 Apr 2012 21:51:46 +0000 (-0700) Subject: portageq mass_best_visible: optional "type" arg X-Git-Tag: v2.2.0_alpha101~19 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0bb454d0aecba0be1dd197038eefc4be6be2580e;p=portage.git portageq mass_best_visible: optional "type" arg --- diff --git a/bin/portageq b/bin/portageq index fcdb9d963..dc465d211 100755 --- a/bin/portageq +++ b/bin/portageq @@ -504,21 +504,35 @@ def best_visible(argv): writemsg_stdout("%s\n" % (pkg.cpv,), noiselevel=-1) return os.EX_OK + # No package found, write out an empty line. + writemsg_stdout("\n", noiselevel=-1) + return 1 best_visible.uses_root = True def mass_best_visible(argv): - """ []+ + """ [] []+ Returns category/package-version (without .ebuild). + The pkgtype argument defaults to "ebuild" if unspecified, + otherwise it must be one of ebuild, binary, or installed. """ + type_map = { + "ebuild":"porttree", + "binary":"bintree", + "installed":"vartree"} + if (len(argv) < 2): print("ERROR: insufficient parameters!") sys.exit(2) try: - for pack in argv[1:]: - mylist=portage.db[argv[0]]["porttree"].dbapi.match(pack) - print(pack+":"+portage.best(mylist)) + root = argv.pop(0) + pkgtype = "ebuild" + if argv[0] in type_map: + pkgtype = argv.pop(0) + for pack in argv: + writemsg_stdout("%s:" % pack, noiselevel=-1) + best_visible([root, pkgtype, pack]) except KeyError: sys.exit(1) mass_best_visible.uses_root = True