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):
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."""
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
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:
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: