From 95d6ed5e34d59b5ba42d36cfc3554296007d060b Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 21 Jan 2012 00:40:52 +0100 Subject: [PATCH] Print ::${repository} in output of `emerge -pv ${package}` by default. Add --quiet-repo-display option, which enables previous, more quiet output. --- pym/_emerge/main.py | 1 + pym/_emerge/resolver/output.py | 60 ++++++++++++++++++-------- pym/_emerge/resolver/output_helpers.py | 3 +- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index d02f2a605..65df99de8 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -66,6 +66,7 @@ options=[ "--nodeps", "--noreplace", "--nospinner", "--oneshot", "--onlydeps", "--pretend", +"--quiet-repo-display", "--quiet-unmerge-warn", "--resume", "--searchdesc", diff --git a/pym/_emerge/resolver/output.py b/pym/_emerge/resolver/output.py index bed5e44e8..15f922508 100644 --- a/pym/_emerge/resolver/output.py +++ b/pym/_emerge/resolver/output.py @@ -13,7 +13,7 @@ import sys from portage import os from portage import _unicode_decode from portage.dbapi.dep_expand import dep_expand -from portage.dep import cpvequal +from portage.dep import cpvequal, _repo_separator from portage.exception import InvalidDependString, SignatureException from portage.output import ( blue, bold, colorize, create_color_func, darkblue, darkgreen, green, nc_len, red, teal, turquoise, yellow ) @@ -339,6 +339,9 @@ class Display(object): self.counters.totalsize += mysize self.verboseadd += _format_size(mysize) + if not self.quiet_repo_display: + return + # overlay verbose # assign index for a previous version in the same slot slot_matches = self.vardb.match(pkg.slot_atom) @@ -368,8 +371,7 @@ class Display(object): repoadd_set.add(self.repoadd) - @staticmethod - def convert_myoldbest(myoldbest): + def convert_myoldbest(self, myoldbest): """converts and colorizes a version list to a string @param myoldbest: list @@ -384,6 +386,8 @@ class Display(object): "-" + catpkgsplit(pkg.cpv)[3] if key[-3:] == "-r0": key = key[:-3] + if self.conf.verbosity == 3 and not self.quiet_repo_display: + key += _repo_separator + pkg.repo versions.append(key) myoldbest_str = blue("["+", ".join(versions)+"]") return myoldbest_str @@ -412,10 +416,13 @@ class Display(object): @param pkg: _emerge.Package instance @rtype string """ + ver_str = pkg_info.ver + if self.conf.verbosity == 3 and not self.quiet_repo_display: + ver_str += _repo_separator + pkg.repo if self.conf.quiet: myprint = addl + " " + self.indent + \ self.pkgprint(pkg_info.cp, pkg_info) - myprint = myprint+darkblue(" "+pkg_info.ver)+" " + myprint = myprint+darkblue(" "+ver_str)+" " myprint = myprint+pkg_info.oldbest myprint = myprint+darkgreen("to "+pkg.root) self.verboseadd = None @@ -430,7 +437,7 @@ class Display(object): self.indent, self.pkgprint(pkg.cp, pkg_info)) if (self.newlp-nc_len(myprint)) > 0: myprint = myprint+(" "*(self.newlp-nc_len(myprint))) - myprint = myprint+"["+darkblue(pkg_info.ver)+"] " + myprint = myprint+"["+darkblue(ver_str)+"] " if (self.oldlp-nc_len(myprint)) > 0: myprint = myprint+" "*(self.oldlp-nc_len(myprint)) myprint = myprint+pkg_info.oldbest @@ -447,10 +454,13 @@ class Display(object): @rtype string Modifies self.verboseadd """ + ver_str = pkg_info.ver + if self.conf.verbosity == 3 and not self.quiet_repo_display: + ver_str += _repo_separator + pkg.repo if self.conf.quiet: myprint = addl + " " + self.indent + \ self.pkgprint(pkg_info.cp, pkg_info) - myprint = myprint+" "+green(pkg_info.ver)+" " + myprint = myprint+" "+green(ver_str)+" " myprint = myprint+pkg_info.oldbest self.verboseadd = None else: @@ -465,7 +475,7 @@ class Display(object): self.indent, self.pkgprint(pkg.cp, pkg_info)) if (self.newlp-nc_len(myprint)) > 0: myprint = myprint+(" "*(self.newlp-nc_len(myprint))) - myprint = myprint+green(" ["+pkg_info.ver+"] ") + myprint = myprint+green(" ["+ver_str+"] ") if (self.oldlp-nc_len(myprint)) > 0: myprint = myprint+(" "*(self.oldlp-nc_len(myprint))) myprint += pkg_info.oldbest @@ -480,18 +490,21 @@ class Display(object): @param addl: the current text to add for the next line to output @rtype the updated addl """ + pkg_str = pkg.cpv + if self.conf.verbosity == 3 and not self.quiet_repo_display: + pkg_str += _repo_separator + pkg.repo if not pkg_info.merge: addl = self.empty_space_in_brackets() myprint = "[%s%s] %s%s %s" % \ (self.pkgprint(pkg_info.operation.ljust(13), pkg_info), addl, - self.indent, self.pkgprint(pkg.cpv, pkg_info), + self.indent, self.pkgprint(pkg_str, pkg_info), pkg_info.oldbest) else: myprint = "[%s %s] %s%s %s" % \ (self.pkgprint(pkg.type_name, pkg_info), addl, self.indent, - self.pkgprint(pkg.cpv, pkg_info), pkg_info.oldbest) + self.pkgprint(pkg_str, pkg_info), pkg_info.oldbest) return myprint @@ -795,9 +808,12 @@ class Display(object): # files to fetch list - avoids counting a same file twice # in size display (verbose mode) self.myfetchlist = set() - # Use this set to detect when all the "repoadd" strings are "[0]" - # and disable the entire repo display in this case. - repoadd_set = set() + + self.quiet_repo_display = "--quiet-repo-display" in depgraph._frozen_config.myopts + if self.quiet_repo_display: + # Use this set to detect when all the "repoadd" strings are "[0]" + # and disable the entire repo display in this case. + repoadd_set = set() for mylist_index in range(len(mylist)): pkg, depth, ordered = mylist[mylist_index] @@ -814,11 +830,15 @@ class Display(object): addl, pkg_info.oldbest, myinslotlist = \ self._get_installed_best(pkg, pkg_info) self.verboseadd = "" - self.repoadd = None + if self.quiet_repo_display: + self.repoadd = None self._display_use(pkg, pkg_info.oldbest, myinslotlist) self.recheck_hidden(pkg) if self.conf.verbosity == 3: - self.verbose_size(pkg, repoadd_set, pkg_info) + if self.quiet_repo_display: + self.verbose_size(pkg, repoadd_set, pkg_info) + else: + self.verbose_size(pkg, None, pkg_info) pkg_info.cp = pkg.cp pkg_info.ver = self.get_ver_str(pkg) @@ -840,6 +860,9 @@ class Display(object): myprint = self._set_non_root_columns( addl, pkg_info, pkg) else: + pkg_str = pkg.cpv + if self.conf.verbosity == 3 and not self.quiet_repo_display: + pkg_str += _repo_separator + pkg.repo if not pkg_info.merge: addl = self.empty_space_in_brackets() myprint = "[%s%s] " % ( @@ -850,7 +873,7 @@ class Display(object): myprint = "[%s %s] " % ( self.pkgprint(pkg.type_name, pkg_info), addl) myprint += self.indent + \ - self.pkgprint(pkg.cpv, pkg_info) + " " + \ + self.pkgprint(pkg_str, pkg_info) + " " + \ pkg_info.oldbest + darkgreen("to " + pkg.root) else: if self.conf.columns: @@ -862,9 +885,12 @@ class Display(object): if self.conf.columns and pkg.operation == "uninstall": continue - self.print_msg.append((myprint, self.verboseadd, self.repoadd)) + if self.quiet_repo_display: + self.print_msg.append((myprint, self.verboseadd, self.repoadd)) + else: + self.print_msg.append((myprint, self.verboseadd, None)) - show_repos = repoadd_set and repoadd_set != set(["0"]) + show_repos = self.quiet_repo_display and repoadd_set and repoadd_set != set(["0"]) # now finally print out the messages self.print_messages(show_repos) diff --git a/pym/_emerge/resolver/output_helpers.py b/pym/_emerge/resolver/output_helpers.py index 45876611c..5e5e1066f 100644 --- a/pym/_emerge/resolver/output_helpers.py +++ b/pym/_emerge/resolver/output_helpers.py @@ -211,7 +211,8 @@ class _DisplayConfig(object): del e self.columnwidth = mywidth - self.repo_display = _RepoDisplay(frozen_config.roots) + if "--quiet-repo-display" in frozen_config.myopts: + self.repo_display = _RepoDisplay(frozen_config.roots) self.trees = frozen_config.trees self.pkgsettings = frozen_config.pkgsettings self.target_root = frozen_config.target_root -- 2.26.2