summaryrefslogtreecommitdiffstats
path: root/color.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2012-09-24 12:15:13 +0900
committerGustaf Lundh <gustaf.lundh@sonymobile.com>2012-10-09 12:45:30 +0200
commit8a68ff96057ec58e524a3e41a2d8dca7b5d016bc (patch)
tree22f6971e8d3c4a90d11d3704602d073a852328b4 /color.py
parente3b1c45aebed329cbc9ad172b1d8e812cf208117 (diff)
downloadgit-repo-8a68ff96057ec58e524a3e41a2d8dca7b5d016bc.tar.gz
Coding style cleanup
Fix the following issues reported by pylint: C0321: More than one statement on a single line W0622: Redefining built-in 'name' W0612: Unused variable 'name' W0613: Unused argument 'name' W0102: Dangerous default value 'value' as argument W0105: String statement has no effect Also fixed a few cases of inconsistent indentation. Change-Id: Ie0db839e7c57d576cff12d8c055fe87030d00744
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