For bug #183861, allow a color class in color.map to specify a space separated list...
authorZac Medico <zmedico@gentoo.org>
Wed, 4 Jul 2007 11:48:57 +0000 (11:48 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 4 Jul 2007 11:48:57 +0000 (11:48 -0000)
svn path=/main/trunk/; revision=7146

pym/portage/output.py

index 2f64eaf60afa041cd804f88d0c9f22ad1d5e3818..fabfb4bdb56e1e9ce5b98686ed7cd6b28aeb99c1 100644 (file)
@@ -73,6 +73,7 @@ codes["standout"]  = esc_seq + "03m"
 codes["underline"] = esc_seq + "04m"
 codes["blink"]     = esc_seq + "05m"
 codes["overline"]  = esc_seq + "06m"  # Who made this up? Seriously.
+codes["reverse"]   = esc_seq + "07m"
 
 ansi_color_codes = []
 for x in xrange(30, 38):
@@ -119,6 +120,15 @@ codes["darkyellow"] = codes["0xAAAA00"]
 codes["fuscia"]     = codes["fuchsia"]
 codes["white"]      = codes["bold"]
 
+codes["bg_black"]   = esc_seq + "40m"
+codes["bg_red"]     = esc_seq + "41m"
+codes["bg_green"]   = esc_seq + "42m"
+codes["bg_brown"]   = esc_seq + "43m"
+codes["bg_blue"]    = esc_seq + "44m"
+codes["bg_magenta"] = esc_seq + "45m"
+codes["bg_cyan"]    = esc_seq + "46m"
+codes["bg_white"]   = esc_seq + "47m"
+
 # Colors from /sbin/functions.sh
 codes["GOOD"]       = codes["green"]
 codes["WARN"]       = codes["yellow"]
@@ -127,18 +137,22 @@ codes["HILITE"]     = codes["teal"]
 codes["BRACKET"]    = codes["blue"]
 
 # Portage functions
-codes["INFORM"] = codes["darkgreen"]
-codes["UNMERGE_WARN"] = codes["red"]
-codes["SECURITY_WARN"] = codes["red"]
-codes["MERGE_LIST_PROGRESS"] = codes["yellow"]
-codes["PKG_MERGE"]           = codes["darkgreen"]
-codes["PKG_MERGE_ARG"]       = codes["darkgreen"]
-codes["PKG_MERGE_SYSTEM"]    = codes["green"]
-codes["PKG_MERGE_WORLD"]     = codes["green"]
-codes["PKG_NOMERGE"]         = codes["darkblue"]
-codes["PKG_NOMERGE_ARG"]     = codes["darkblue"]
-codes["PKG_NOMERGE_SYSTEM"]  = codes["blue"]
-codes["PKG_NOMERGE_WORLD"]   = codes["blue"]
+codes["INFORM"]                  = codes["darkgreen"]
+codes["UNMERGE_WARN"]            = codes["red"]
+codes["SECURITY_WARN"]           = codes["red"]
+codes["MERGE_LIST_PROGRESS"]     = codes["yellow"]
+codes["PKG_MERGE"]               = codes["darkgreen"]
+codes["PKG_MERGE_ARG"]           = codes["darkgreen"]
+codes["PKG_MERGE_SYSTEM"]        = codes["green"]
+codes["PKG_MERGE_WORLD"]         = codes["green"]
+codes["PKG_MERGE_ARG_SYSTEM"]    = codes["green"]
+codes["PKG_MERGE_ARG_WORLD"]     = codes["green"]
+codes["PKG_NOMERGE"]             = codes["darkblue"]
+codes["PKG_NOMERGE_ARG"]         = codes["darkblue"]
+codes["PKG_NOMERGE_SYSTEM"]      = codes["blue"]
+codes["PKG_NOMERGE_WORLD"]       = codes["blue"]
+codes["PKG_NOMERGE_ARG_SYSTEM"]  = codes["blue"]
+codes["PKG_NOMERGE_ARG_WORLD"]   = codes["blue"]
 
 def parse_color_map():
        myfile = COLOR_MAP_FILE
@@ -159,13 +173,17 @@ def parse_color_map():
                                raise ParseError("%s%s'%s'" % (s.error_leader(myfile, s.lineno), "expected '=' operator: ", o))
                        k = strip_quotes(k, s.quotes)
                        v = strip_quotes(v, s.quotes)
+                       if not k in codes:
+                               print ParseError("%s%s'%s'" % (s.error_leader(myfile, s.lineno), "Unknown variable: ", k))
+                               continue
                        if ansi_code_pattern.match(v):
                                codes[k] = esc_seq + v
                        else:
-                               if v in codes:
-                                       codes[k] = codes[v]
-                               else:
-                                       raise ParseError("%s%s'%s'" % (s.error_leader(myfile, s.lineno), "Undefined: ", v))
+                               for x in v.split(" "):
+                                       if x in codes:
+                                               codes[k] = codes[k] + codes[x]
+                                       else:
+                                               print ParseError("%s%s'%s'" % (s.error_leader(myfile, s.lineno), "Undefined: ", x))
        except (IOError, OSError), e:
                if e.errno == errno.ENOENT:
                        raise FileNotFound(myfile)