From 7aab4998882319e668bf48be2279dcbbec4022b9 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 17 Mar 2013 15:36:54 -0700 Subject: [PATCH] portageq: emulate subset of Pkgcore's pquery Pkgcore pquery compatible options: Repository matching options: --repo=REPO repo to use (default is PORTDIR if omitted) --all-repos search all repos Package matching options: --herd=HERD exact match on a herd --maintainer-email=MAINTAINER_EMAIL comma-separated list of maintainer email regexes to search for Output formatting: -n, --no-version collapse multiple matching versions together --- bin/portageq | 156 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 145 insertions(+), 11 deletions(-) diff --git a/bin/portageq b/bin/portageq index 48e765143..d48277239 100755 --- a/bin/portageq +++ b/bin/portageq @@ -20,6 +20,7 @@ try: except KeyboardInterrupt: sys.exit(128 + signal.SIGINT) +import optparse import os import types @@ -41,11 +42,13 @@ from portage import os from portage.eapi import eapi_has_repo_deps from portage.util import writemsg, writemsg_stdout portage.proxy.lazyimport.lazyimport(globals(), + 're', 'subprocess', '_emerge.Package:Package', '_emerge.RootConfig:RootConfig', 'portage.dbapi._expand_new_virt:expand_new_virt', 'portage._sets.base:InternalPackageSet', + 'portage.xml.metadata:MetaDataXML' ) def eval_atom_use(atom): @@ -874,11 +877,11 @@ list_preserved_libs.uses_eroot = True # DO NOT CHANGE CODE BEYOND THIS POINT - IT'S NOT NEEDED! # -non_commands = frozenset(['elog', 'eval_atom_use', 'exithandler', 'main', 'usage']) +non_commands = frozenset(['elog', 'eval_atom_use', 'exithandler', 'main', 'pquery', 'usage']) commands = sorted(k for k, v in globals().items() \ if k not in non_commands and isinstance(v, types.FunctionType) and v.__module__ == "__main__") -def usage(argv): +def usage(argv, parser=None, pquery_option_groups=None): print(">>> Portage information query tool") print(">>> %s" % portage.VERSION) print(">>> Usage: portageq [