--- equery-1.38 2005-03-30 13:48:21.000000000 -0600 +++ equery 2005-03-30 14:45:25.000000000 -0600 @@ -1094,7 +1094,8 @@ "includePortTree": 0, "includeOverlayTree": 0, "includeMasked": 1, - "regex": 0 + "regex": 0, + "delimitedOutput": False } def parseArgs(self, args): @@ -1124,6 +1125,8 @@ opts["includeOverlayTree"] = 1 elif x in ["-m", "--exclude-masked"]: opts["includeMasked"] = 0 + elif x in ["-d", "--delimited-output"]: + opts["delimitedOutput"] = True else: query = x @@ -1184,13 +1187,13 @@ matches = package_finder(filter_fn) if opts["includeInstalled"]: - self._print_installed(matches, rx) + self._print_installed(matches, rx, opts) if opts["includePortTree"]: - self._print_porttree(matches, rx) + self._print_porttree(matches, rx, opts) if opts["includeOverlayTree"]: - self._print_overlay(matches, rx) + self._print_overlay(matches, rx, opts) def _get_mask_status(self, pkg): pkgmask = 0 @@ -1203,11 +1206,14 @@ pkgmask = pkgmask + 2 return pkgmask - def _generic_print(self, header, exclude, matches, rx, status): - print_info(1, header) + def _generic_print(self, header, exclude, matches, rx, status, opts): + if Config["verbosityLevel"] >= 3 and not opts["delimitedOutput"]: + print_info(1, header) pfxmodes = [ "---", "I--", "-P-", "--O" ] + delimitedpfxmodes = [ "", "I", "P", "O" ] maskmodes = [ " ", " ~", " -", "M ", "M~", "M-" ] + delimitedmaskmodes = [ " : ", " :~", " -", "M: ", "M:~", "M:-" ] for pkg in matches: if exclude(pkg): @@ -1218,28 +1224,28 @@ slot = pkg.get_env_var("SLOT") if rx.search(pkg.get_cpv()): - if Config["piping"]: - print_info(0, pkg.get_cpv()) + if Config["piping"] and opts["delimitedOutput"]: + print_info(0, pp.installedflag(delimitedpfxmodes[status]) + ":" + pp.maskflag(delimitedmaskmodes[pkgmask]) + ":" + pp.cpv(pkg.get_cpv()) + ":" + pp.slot(slot)) else: print_info(0, "[" + pp.installedflag(pfxmodes[status]) + "] [" + pp.maskflag(maskmodes[pkgmask]) + "] " + pp.cpv(pkg.get_cpv()) + " (" + pp.slot(slot) + ")") - def _print_overlay(self, matches, rx): + def _print_overlay(self, matches, rx, opts): self._generic_print( pp.section(" *") + " overlay tree (" + pp.path(gentoolkit.settings["PORTDIR_OVERLAY"]) + ")", lambda x: not x.is_overlay(), - matches, rx, 3) + matches, rx, 3, opts) - def _print_porttree(self, matches, rx): + def _print_porttree(self, matches, rx, opts): self._generic_print( pp.section(" *") + " Portage tree (" + pp.path(gentoolkit.settings["PORTDIR"]) + ")", lambda x: x.is_overlay() or x.is_installed(), - matches, rx, 2) + matches, rx, 2, opts) - def _print_installed(self, matches, rx): + def _print_installed(self, matches, rx, opts): self._generic_print( pp.section(" *") + " installed packages", lambda x: not x.is_installed(), - matches, rx, 1) + matches, rx, 1, opts) def shortHelp(self): return pp.localoption(" ") + pp.pkgquery("pkgspec") + " - list all packages matching " + pp.pkgquery("pkgspec")