diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-09-24 12:15:13 +0900 |
|---|---|---|
| committer | Gustaf Lundh <gustaf.lundh@sonymobile.com> | 2012-10-09 12:45:30 +0200 |
| commit | 8a68ff96057ec58e524a3e41a2d8dca7b5d016bc (patch) | |
| tree | 22f6971e8d3c4a90d11d3704602d073a852328b4 /color.py | |
| parent | e3b1c45aebed329cbc9ad172b1d8e812cf208117 (diff) | |
| download | git-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.py | 21 |
1 files changed, 13 insertions, 8 deletions
| @@ -38,8 +38,11 @@ ATTRS = {None :-1, | |||
| 38 | 38 | ||
| 39 | RESET = "\033[m" | 39 | RESET = "\033[m" |
| 40 | 40 | ||
| 41 | def is_color(s): return s in COLORS | 41 | def is_color(s): |
| 42 | def is_attr(s): return s in ATTRS | 42 | return s in COLORS |
| 43 | |||
| 44 | def is_attr(s): | ||
| 45 | return s in ATTRS | ||
| 43 | 46 | ||
| 44 | def _Color(fg = None, bg = None, attr = None): | 47 | def _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 | ||
| 82 | class Coloring(object): | 85 | class 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 | ||
