1 |
Author: zmedico |
2 |
Date: 2009-06-17 19:27:20 +0000 (Wed, 17 Jun 2009) |
3 |
New Revision: 13647 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/output.py |
7 |
Log: |
8 |
Rename codes to _styles. |
9 |
|
10 |
|
11 |
Modified: main/trunk/pym/portage/output.py |
12 |
=================================================================== |
13 |
--- main/trunk/pym/portage/output.py 2009-06-17 18:59:14 UTC (rev 13646) |
14 |
+++ main/trunk/pym/portage/output.py 2009-06-17 19:27:20 UTC (rev 13647) |
15 |
@@ -25,7 +25,7 @@ |
16 |
havecolor=1 |
17 |
dotitles=1 |
18 |
|
19 |
-codes = {} |
20 |
+_styles = {} |
21 |
"""Maps style class to tuple of attribute names.""" |
22 |
|
23 |
color_codes = {} |
24 |
@@ -116,29 +116,29 @@ |
25 |
|
26 |
|
27 |
# Colors from /etc/init.d/functions.sh |
28 |
-codes["NORMAL"] = ( "normal", ) |
29 |
-codes["GOOD"] = ( "green", ) |
30 |
-codes["WARN"] = ( "yellow", ) |
31 |
-codes["BAD"] = ( "red", ) |
32 |
-codes["HILITE"] = ( "teal", ) |
33 |
-codes["BRACKET"] = ( "blue", ) |
34 |
+_styles["NORMAL"] = ( "normal", ) |
35 |
+_styles["GOOD"] = ( "green", ) |
36 |
+_styles["WARN"] = ( "yellow", ) |
37 |
+_styles["BAD"] = ( "red", ) |
38 |
+_styles["HILITE"] = ( "teal", ) |
39 |
+_styles["BRACKET"] = ( "blue", ) |
40 |
|
41 |
# Portage functions |
42 |
-codes["INFORM"] = ( "darkgreen", ) |
43 |
-codes["UNMERGE_WARN"] = ( "red", ) |
44 |
-codes["SECURITY_WARN"] = ( "red", ) |
45 |
-codes["MERGE_LIST_PROGRESS"] = ( "yellow", ) |
46 |
-codes["PKG_BLOCKER"] = ( "red", ) |
47 |
-codes["PKG_BLOCKER_SATISFIED"] = ( "darkblue", ) |
48 |
-codes["PKG_MERGE"] = ( "darkgreen", ) |
49 |
-codes["PKG_MERGE_SYSTEM"] = ( "darkgreen", ) |
50 |
-codes["PKG_MERGE_WORLD"] = ( "green", ) |
51 |
-codes["PKG_UNINSTALL"] = ( "red", ) |
52 |
-codes["PKG_NOMERGE"] = ( "darkblue", ) |
53 |
-codes["PKG_NOMERGE_SYSTEM"] = ( "darkblue", ) |
54 |
-codes["PKG_NOMERGE_WORLD"] = ( "blue", ) |
55 |
-codes["PROMPT_CHOICE_DEFAULT"] = ( "green", ) |
56 |
-codes["PROMPT_CHOICE_OTHER"] = ( "red", ) |
57 |
+_styles["INFORM"] = ( "darkgreen", ) |
58 |
+_styles["UNMERGE_WARN"] = ( "red", ) |
59 |
+_styles["SECURITY_WARN"] = ( "red", ) |
60 |
+_styles["MERGE_LIST_PROGRESS"] = ( "yellow", ) |
61 |
+_styles["PKG_BLOCKER"] = ( "red", ) |
62 |
+_styles["PKG_BLOCKER_SATISFIED"] = ( "darkblue", ) |
63 |
+_styles["PKG_MERGE"] = ( "darkgreen", ) |
64 |
+_styles["PKG_MERGE_SYSTEM"] = ( "darkgreen", ) |
65 |
+_styles["PKG_MERGE_WORLD"] = ( "green", ) |
66 |
+_styles["PKG_UNINSTALL"] = ( "red", ) |
67 |
+_styles["PKG_NOMERGE"] = ( "darkblue", ) |
68 |
+_styles["PKG_NOMERGE_SYSTEM"] = ( "darkblue", ) |
69 |
+_styles["PKG_NOMERGE_WORLD"] = ( "blue", ) |
70 |
+_styles["PROMPT_CHOICE_DEFAULT"] = ( "green", ) |
71 |
+_styles["PROMPT_CHOICE_OTHER"] = ( "red", ) |
72 |
|
73 |
def _parse_color_map(onerror=None): |
74 |
""" |
75 |
@@ -182,7 +182,7 @@ |
76 |
|
77 |
k = strip_quotes(split_line[0].strip()) |
78 |
v = strip_quotes(split_line[1].strip()) |
79 |
- if not k in codes and not k in color_codes: |
80 |
+ if not k in _styles and not k in color_codes: |
81 |
e = ParseError("'%s', line %s: %s'%s'" % ( |
82 |
myfile, lineno, |
83 |
"Unknown variable: ", k)) |
84 |
@@ -192,15 +192,15 @@ |
85 |
raise e |
86 |
continue |
87 |
if ansi_code_pattern.match(v): |
88 |
- if k in codes: |
89 |
- codes[k] = ( esc_seq + v, ) |
90 |
+ if k in _styles: |
91 |
+ _styles[k] = ( esc_seq + v, ) |
92 |
elif k in color_codes: |
93 |
color_codes[k] = esc_seq + v |
94 |
else: |
95 |
code_list = [] |
96 |
for x in v.split(): |
97 |
if x in color_codes: |
98 |
- if k in codes: |
99 |
+ if k in _styles: |
100 |
code_list.append(x) |
101 |
elif k in color_codes: |
102 |
code_list.append(color_codes[x]) |
103 |
@@ -212,8 +212,8 @@ |
104 |
onerror(e) |
105 |
else: |
106 |
raise e |
107 |
- if k in codes: |
108 |
- codes[k] = tuple(code_list) |
109 |
+ if k in _styles: |
110 |
+ _styles[k] = tuple(code_list) |
111 |
elif k in color_codes: |
112 |
color_codes[k] = "".join(code_list) |
113 |
except (IOError, OSError), e: |
114 |
@@ -299,7 +299,7 @@ |
115 |
used to render the given style. |
116 |
""" |
117 |
ret = "" |
118 |
- for color_code in codes[style]: |
119 |
+ for color_code in _styles[style]: |
120 |
# allow stuff that has found it's way through ansi_code_pattern |
121 |
ret += color_codes.get(color_code, color_code) |
122 |
return ret |
123 |
@@ -309,7 +309,7 @@ |
124 |
if havecolor: |
125 |
if color_key in color_codes: |
126 |
return color_codes[color_key] + text + color_codes["reset"] |
127 |
- elif color_key in codes: |
128 |
+ elif color_key in _styles: |
129 |
return style_to_ansi_code(color_key) + text + color_codes["reset"] |
130 |
else: |
131 |
return text |