Rename map_code_to_color_code() to style_to_ansi_code().
authorZac Medico <zmedico@gentoo.org>
Wed, 17 Jun 2009 18:59:14 +0000 (18:59 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 17 Jun 2009 18:59:14 +0000 (18:59 -0000)
svn path=/main/trunk/; revision=13646

pym/portage/__init__.py
pym/portage/output.py

index c1707287073b6cfca985909e0a55a3060954928d..7eb9dd69dd390580ea29a9d28953460dfa2459de 100644 (file)
@@ -5432,7 +5432,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
        mycolors = []
        for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET"):
                mycolors.append("%s=$'%s'" % \
-                       (c, portage.output.map_code_to_color_code(c)))
+                       (c, portage.output.style_to_ansi_code(c)))
        mysettings["PORTAGE_COLORMAP"] = "\n".join(mycolors)
 
 def prepare_build_dirs(myroot, mysettings, cleanup):
index a32a6e714eea0bcd0ed83e2a79d1a2081e0d25bf..39359b87fca011b39c8a21c1ae15047c0a0d1ce8 100644 (file)
@@ -26,7 +26,7 @@ havecolor=1
 dotitles=1
 
 codes = {}
-"""Maps color class to tuple of attribute names."""
+"""Maps style class to tuple of attribute names."""
 
 color_codes = {}
 """Maps attribute name to ansi code."""
@@ -290,9 +290,16 @@ def nocolor():
 def resetColor():
        return color_codes["reset"]
 
-def map_code_to_color_code(code):
+def style_to_ansi_code(style):
+       """
+       @param style: A style name
+       @type style: String
+       @rtype: String
+       @return: A string containing one or more ansi escape codes that are
+               used to render the given style.
+       """
        ret = ""
-       for color_code in codes[code]:
+       for color_code in codes[style]:
                # allow stuff that has found it's way through ansi_code_pattern
                ret += color_codes.get(color_code, color_code)
        return ret
@@ -303,7 +310,7 @@ def colorize(color_key, text):
                if color_key in color_codes:
                        return color_codes[color_key] + text + color_codes["reset"]
                elif color_key in codes:
-                       return map_code_to_color_code(color_key) + text + color_codes["reset"]
+                       return style_to_ansi_code(color_key) + text + color_codes["reset"]
                else:
                        return text
        else:
@@ -342,7 +349,7 @@ class ConsoleStyleFile(object):
                global havecolor
                if havecolor and self._styles:
                        for style in self._styles:
-                               self._file.write(map_code_to_color_code(style))
+                               self._file.write(style_to_ansi_code(style))
                        self._file.write(s)
                        self._file.write(color_codes["reset"])
                else: