Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] portageq: add "colormap" helper
Date: Sun, 11 Mar 2012 09:07:16
Message-Id: CAAr7Pr8RvvuL-0UgQ1g-9i9CNzQxn2u1VSu25cNip4YeqkCyWQ@mail.gmail.com
In Reply to: [gentoo-portage-dev] [PATCH] portageq: add "colormap" helper by Mike Frysinger
1 On Sat, Mar 10, 2012 at 8:15 PM, Mike Frysinger <vapier@g.o> wrote:
2 > Signed-off-by: Mike Frysinger <vapier@g.o>
3 > ---
4 >  bin/isolated-functions.sh              |    2 +-
5 >  bin/portageq                           |    8 ++++++++
6 >  pym/portage/output.py                  |    6 ++++++
7 >  pym/portage/package/ebuild/doebuild.py |    8 ++------
8 >  4 files changed, 17 insertions(+), 7 deletions(-)
9 >
10 > diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
11 > index 9321ad5..98be41e 100644
12 > --- a/bin/isolated-functions.sh
13 > +++ b/bin/isolated-functions.sh
14 > @@ -431,8 +431,8 @@ set_colors() {
15 >                BAD=$'\e[31;01m'
16 >                HILITE=$'\e[36;01m'
17 >                BRACKET=$'\e[34;01m'
18 > +               NORMAL=$'\e[0m'
19 >        fi
20 > -       NORMAL=$'\e[0m'
21 >  }
22 >
23 >  RC_ENDCOL="yes"
24 > diff --git a/bin/portageq b/bin/portageq
25 > index 5ecbb21..fcdb9d9 100755
26 > --- a/bin/portageq
27 > +++ b/bin/portageq
28 > @@ -44,6 +44,7 @@ del pym_path
29 >  from portage import os
30 >  from portage.eapi import eapi_has_repo_deps
31 >  from portage.util import writemsg, writemsg_stdout
32 > +from portage.output import colormap
33 >  portage.proxy.lazyimport.lazyimport(globals(),
34 >        'subprocess',
35 >        '_emerge.Package:Package',
36 > @@ -685,6 +686,13 @@ def distdir(argv):
37 >        print(portage.settings["DISTDIR"])
38 >
39 >
40 > +def colormap(argv):
41 > +       """
42 > +       Display the color.map as environment variables.
43 > +       """
44 > +       print(portage.output.colormap())
45 > +
46 > +
47 >  def envvar(argv):
48 >        """<variable>+
49 >        Returns a specific environment variable as exists prior to ebuild.sh.
50 > diff --git a/pym/portage/output.py b/pym/portage/output.py
51 > index 43d7503..98bec81 100644
52 > --- a/pym/portage/output.py
53 > +++ b/pym/portage/output.py
54 > @@ -325,6 +325,12 @@ def style_to_ansi_code(style):
55 >                ret += codes.get(attr_name, attr_name)
56 >        return ret
57 >
58 > +def colormap():
59 > +       mycolors = []
60 > +       for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET", "NORMAL"):
61 > +               mycolors.append("%s=$'%s'" % (c, style_to_ansi_code(c)))
62 > +       return "\n".join(mycolors)
63 > +
64 >  def colorize(color_key, text):
65 >        global havecolor
66 >        if havecolor:
67 > diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
68 > index c45aa03..4ff3eea 100644
69 > --- a/pym/portage/package/ebuild/doebuild.py
70 > +++ b/pym/portage/package/ebuild/doebuild.py
71 > @@ -50,7 +50,7 @@ from portage.exception import DigestException, FileNotFound, \
72 >        IncorrectParameter, InvalidDependString, PermissionDenied, \
73 >        UnsupportedAPIException
74 >  from portage.localization import _
75 > -from portage.output import style_to_ansi_code
76 > +from portage.output import colormap
77
78 I assume style_to_ansi_code is unused?
79
80 >  from portage.package.ebuild.prepare_build_dirs import prepare_build_dirs
81 >  from portage.util import apply_recursive_permissions, \
82 >        apply_secpass_permissions, noiselimit, normalize_path, \
83 > @@ -300,11 +300,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
84 >                mysettings["PORTAGE_CONFIGROOT"], EBUILD_SH_ENV_DIR)
85 >
86 >        # Allow color.map to control colors associated with einfo, ewarn, etc...
87 > -       mycolors = []
88 > -       for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET"):
89 > -               mycolors.append("%s=$'%s'" % \
90 > -                       (c, style_to_ansi_code(c)))
91 > -       mysettings["PORTAGE_COLORMAP"] = "\n".join(mycolors)
92 > +       mysettings["PORTAGE_COLORMAP"] = colormap()
93 >
94 >        if "COLUMNS" not in mysettings:
95 >                # Set COLUMNS, in order to prevent unnecessary stty calls
96 > --
97 > 1.7.8.5
98 >
99 >

Replies

Subject Author
Re: [gentoo-portage-dev] [PATCH] portageq: add "colormap" helper Mike Frysinger <vapier@g.o>