summaryrefslogtreecommitdiffstats
path: root/color.py
diff options
context:
space:
mode:
authorConley Owens <cco3@android.com>2012-10-09 14:29:46 -0700
committerGerrit Code Review <noreply-gerritcodereview@google.com>2012-10-09 14:29:46 -0700
commit3a6cd4200e42fbb5a21b3fb8d3c9738c0320cc63 (patch)
tree68ae5094d6530453887fb35a73fd5fa55f55a034 /color.py
parent25f17682ca4ecd8acc887462d4bebc7c429cf110 (diff)
parent8a68ff96057ec58e524a3e41a2d8dca7b5d016bc (diff)
downloadgit-repo-3a6cd4200e42fbb5a21b3fb8d3c9738c0320cc63.tar.gz
Merge "Coding style cleanup"
Diffstat (limited to 'color.py')
-rw-r--r--color.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/color.py b/color.py
index 9b3365be..9200a298 100644
--- a/color.py
+++ b/color.py
@@ -38,8 +38,11 @@ ATTRS = {None :-1,
38 38
39RESET = "\033[m" 39RESET = "\033[m"
40 40
41def is_color(s): return s in COLORS 41def is_color(s):
42def is_attr(s): return s in ATTRS 42 return s in COLORS
43
44def is_attr(s):
45 return s in ATTRS
43 46
44def _Color(fg = None, bg = None, attr = None): 47def _Color(fg = None, bg = None, attr = None):
45 fg = COLORS[fg] 48 fg = COLORS[fg]
@@ -80,8 +83,8 @@ def _Color(fg = None, bg = None, attr = None):
80 83
81 84
82class Coloring(object): 85class Coloring(object):
83 def __init__(self, config, type): 86 def __init__(self, config, section_type):
84 self._section = 'color.%s' % type 87 self._section = 'color.%s' % section_type
85 self._config = config 88 self._config = config
86 self._out = sys.stdout 89 self._out = sys.stdout
87 90
@@ -126,8 +129,8 @@ class Coloring(object):
126 if self._on: 129 if self._on:
127 c = self._parse(opt, fg, bg, attr) 130 c = self._parse(opt, fg, bg, attr)
128 def f(fmt, *args): 131 def f(fmt, *args):
129 str = fmt % args 132 output = fmt % args
130 return ''.join([c, str, RESET]) 133 return ''.join([c, output, RESET])
131 return f 134 return f
132 else: 135 else:
133 def f(fmt, *args): 136 def f(fmt, *args):
@@ -151,8 +154,10 @@ class Coloring(object):
151 have_fg = False 154 have_fg = False
152 for a in v.split(' '): 155 for a in v.split(' '):
153 if is_color(a): 156 if is_color(a):
154 if have_fg: bg = a 157 if have_fg:
155 else: fg = a 158 bg = a
159 else:
160 fg = a
156 elif is_attr(a): 161 elif is_attr(a):
157 attr = a 162 attr = a
158 163