From c8a24b0aa8c62304f7690faefa1cb2d0ee8d40c4 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Sat, 6 Apr 2013 20:58:15 -0400 Subject: [PATCH] correctly detect a numeric color argument --- colout.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/colout.py b/colout.py index 4ce0a2b..d40dbe6 100755 --- a/colout.py +++ b/colout.py @@ -197,7 +197,7 @@ def colorin(text, color="red", style="normal"): color_code = str(30 + colors[color]) # 256 colors mode - elif isinstance( color, int ): + elif color.isdigit(): mode = 256 color_nb = int(color) assert(0 <= color_nb <= 255) @@ -221,6 +221,10 @@ def colorin(text, color="red", style="normal"): # because Pygments adds a newline char. return highlight(text, lexer, formatter)[:-1] + # unrecognized + else: + raise Exception('Unrecognized color %s' % color) + return start + style_code + endmarks[mode] + color_code + "m" + text + stop