From c830a02fecce0e1b71959313bbdbb7142a2a534e Mon Sep 17 00:00:00 2001 From: nojhan Date: Thu, 24 Apr 2014 09:54:30 +0200 Subject: [PATCH] bugfix: return text if no color, more debug infos use global colormap_idx --- colout/colout.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/colout/colout.py b/colout/colout.py index 3eaba66..00c6b01 100755 --- a/colout/colout.py +++ b/colout/colout.py @@ -351,7 +351,7 @@ def color_scale( name, text ): # if out of scale, do not color if f < scale[0] or f > scale[1]: - return text + return None # normalize and scale over the nb of colors in cmap colormap = colormaps[name] @@ -448,7 +448,6 @@ def colorin(text, color="red", style="normal"): assert( type(color) is str ) - global colormap_idx global debug # Special characters. @@ -518,14 +517,20 @@ def colorin(text, color="red", style="normal"): else: raise UnknownColor(color) - if not debug: - return start + style_code + endmarks[m] + color_code + "m" + text + stop + if color_code is not None: + if not debug: + return start + style_code + endmarks[m] + color_code + "m" + text + stop + else: + return start + style_code + endmarks[m] + color_code + "m" \ + + "" \ + + text + "" + stop else: - return start + style_code + endmarks[m] + color_code + "m" \ - + "" \ - + text + "" + stop + if not debug: + return text + else: + return "" + text + "" def colorout(text, match, prev_end, color="red", style="normal", group=0):