diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-05-21 12:08:14 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-05-21 12:08:14 +0200 |
commit | 75eeb5f3515bf3416c98e4337d837cda4f9950e4 (patch) | |
tree | 97bea503f051e93eed6f7b5db32f6ee91eedf067 /textutils.py | |
parent | d1ccb0267612d42d78d8f5c3db9ac8d6123bc400 (diff) | |
download | logilab-common-75eeb5f3515bf3416c98e4337d837cda4f9950e4.tar.gz |
fix colorize_ansi w/ only style, no color
Diffstat (limited to 'textutils.py')
-rw-r--r-- | textutils.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/textutils.py b/textutils.py index ed79050..a01c733 100644 --- a/textutils.py +++ b/textutils.py @@ -418,11 +418,12 @@ def _get_ansi_code(color=None, style=None): style_attrs = splitstrip(style) for effect in style_attrs: ansi_code.append(ANSI_STYLES[effect]) - if color.isdigit(): - ansi_code.extend(['38','5']) - ansi_code.append(color) - else: - ansi_code.append(ANSI_COLORS[color]) + if color: + if color.isdigit(): + ansi_code.extend(['38','5']) + ansi_code.append(color) + else: + ansi_code.append(ANSI_COLORS[color]) if ansi_code: return ANSI_PREFIX + ';'.join(ansi_code) + ANSI_END return '' |