From facaa2ae6a00ea3e3d44c5f1d158d0eac6377973 Mon Sep 17 00:00:00 2001 From: Fabien Benureau Date: Thu, 13 Jun 2013 12:30:14 +0200 Subject: [PATCH] deactivation mecanism for colors; 'colored' is now 'dye' --- papers/color.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/papers/color.py b/papers/color.py index 23871e0..3139557 100644 --- a/papers/color.py +++ b/papers/color.py @@ -1,4 +1,6 @@ -# display +""" +Small code to handle colored text +""" bold = '\033[1m' end = '\033[0m' @@ -18,7 +20,19 @@ normal = grey citekey = purple filepath = cyan -def colored(s, color=end, bold=False): +def dye(s, color=end, bold=False): + assert color[0] == '\033' if bold: s = '\033[1' + s[3:] return color + s + end + +_dye = dye +def _nodye(s, **kwargs): + return s + +def color_setup(config): + global dye + if config.getboolean(configs.MAIN_SECTION, 'color'): + dye = _dye + else: + dye = _nodye \ No newline at end of file