diff --git a/papers/color.py b/papers/color.py index 3139557..90e91b5 100644 --- a/papers/color.py +++ b/papers/color.py @@ -2,6 +2,7 @@ Small code to handle colored text """ + bold = '\033[1m' end = '\033[0m' @@ -30,9 +31,9 @@ _dye = dye def _nodye(s, **kwargs): return s -def color_setup(config): +def setup(enable = True): global dye - if config.getboolean(configs.MAIN_SECTION, 'color'): + if enable: dye = _dye else: dye = _nodye \ No newline at end of file diff --git a/papers/commands/init_cmd.py b/papers/commands/init_cmd.py index a50d165..a4ccba8 100644 --- a/papers/commands/init_cmd.py +++ b/papers/commands/init_cmd.py @@ -4,7 +4,7 @@ import os from ..repo import Repository from .. import configs - +from .. import color def parser(subparsers, config): parser = subparsers.add_parser('init', diff --git a/papers/commands/remove_cmd.py b/papers/commands/remove_cmd.py index c92365c..31d6985 100644 --- a/papers/commands/remove_cmd.py +++ b/papers/commands/remove_cmd.py @@ -1,5 +1,5 @@ from .. import repo -import color +from .. import color def parser(subparsers, config): parser = subparsers.add_parser('remove', help='removes a paper') diff --git a/papers/configs.py b/papers/configs.py index 5249477..e137456 100644 --- a/papers/configs.py +++ b/papers/configs.py @@ -49,11 +49,11 @@ def get_plugins(cfg): return cfg.get(MAIN_SECTION, 'plugins').split() -def get_boolean(value, default): +def get_boolean(value, default = False): value = str(value).lower() if value in ('yes', 'true', 't', 'y', '1'): return True elif value in ('no', 'false', 'f', 'n', '0'): return False else: - return 0 + return default diff --git a/papers/ui.py b/papers/ui.py index cb02153..50cd382 100644 --- a/papers/ui.py +++ b/papers/ui.py @@ -12,7 +12,8 @@ class UI: def __init__(self, config): self.encoding = _encoding(config) - color.setup(config) + color_enable = configs.get_boolean(config.get('papers', 'color')) + color.setup(color_enable) def print_(self, *strings): """Like print, but rather than raising an error when a character diff --git a/setup.py b/setup.py index cd1c63c..c9d0a64 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages setup(name='papers', version='1', - author='Fabien Benureau, Olivier Mangin', + author='Fabien Benureau, Olivier Mangin, Jonathan Grizou', author_email='fabien.benureau+inria@gmail.com', url='', description='research papers manager',