From e0f7d235b148ad4525b6d082c829587bcb070a3f Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Wed, 17 Apr 2013 10:19:02 +0200 Subject: [PATCH] Uses colorama instead of clint --- CHANGELOG.md | 3 +++ README.md | 2 +- jrnl/Journal.py | 15 ++++++++------- jrnl/install.py | 6 +++--- setup.py | 6 ++++-- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b96c6de2..55ab9246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Changelog ========= +### 1.0.2 (April 17, 2013) + +* [Improved] Removed clint in favour of colorama ### 1.0.1 (March 12, 2013) * [Fixed] Requires parsedatetime 1.1.2 or newer diff --git a/README.md b/README.md index 3e581e08..55ef0d70 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ The configuration file is a simple JSON file with the following options. - `tagsymbols`: Symbols to be interpreted as tags. (__See note below__) - `default_hour` and `default_minute`: if you supply a date, such as `last thursday`, but no specific time, the entry will be created at this time - `timeformat`: how to format the timestamps in your journal, see the [python docs](http://docs.python.org/library/time.html#time.strftime) for reference -- `highlight`: if `true` and you have [clint](http://www.nicosphere.net/clint-command-line-library-for-python/) installed, tags will be highlighted in cyan. +- `highlight`: if `true`, tags will be highlighted in cyan. - `linewrap`: controls the width of the output. Set to `0` or `false` if you don't want to wrap long lines. > __Note on `tagsymbols`:__ Although it seems intuitive to use the `#` character for tags, there's a drawback: on most shells, this is interpreted as a meta-character starting a comment. This means that if you type diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 8147b536..29856975 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -19,9 +19,10 @@ except ImportError: import hashlib import getpass try: - import clint + import colorama + colorama.init() except ImportError: - clint = None + colorama = None import plistlib import uuid @@ -50,9 +51,9 @@ class Journal(object): self.entries = self.parse(journal_txt) self.sort() - def _colorize(self, string, color='red'): - if clint: - return str(clint.textui.colored.ColoredString(color.upper(), string)) + def _colorize(self, string): + if colorama: + return colorama.Fore.CYAN + string + colorama.Fore.RESET else: return string @@ -152,11 +153,11 @@ class Journal(object): for tag in self.search_tags: tagre = re.compile(re.escape(tag), re.IGNORECASE) pp = re.sub(tagre, - lambda match: self._colorize(match.group(0), 'cyan'), + lambda match: self._colorize(match.group(0)), pp) else: pp = re.sub(r"([%s]\w+)" % self.config['tagsymbols'], - lambda match: self._colorize(match.group(0), 'cyan'), + lambda match: self._colorize(match.group(0)), pp) return pp diff --git a/jrnl/install.py b/jrnl/install.py index 90b5939e..f0d7d48b 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -77,8 +77,8 @@ def install_jrnl(config_path='~/.jrnl_config'): print("PyCrypto not found. To encrypt your journal, install the PyCrypto package from http://www.pycrypto.org and run 'jrnl --encrypt'. For now, your journal will be stored in plain text.") # Use highlighting: - if module_exists("clint"): - print("clint not found. To turn on highlighting, install clint and set highlight to true in your .jrnl_conf.") + if module_exists("colorama"): + print("colorama not found. To turn on highlighting, install colorama and set highlight to true in your .jrnl_conf.") default_config['highlight'] = False open(default_config['journals']['default'], 'a').close() # Touch to make sure it's there @@ -91,4 +91,4 @@ def install_jrnl(config_path='~/.jrnl_config'): config['password'] = password return config - \ No newline at end of file + diff --git a/setup.py b/setup.py index ab80113b..eb1ac563 100644 --- a/setup.py +++ b/setup.py @@ -56,11 +56,13 @@ setup( version = "1.0.1", description = "A command line journal application that stores your journal in a plain text file", packages = ['jrnl'], - install_requires = ["parsedatetime >= 1.1.2"], extras_require = { 'encryption': ["pycrypto"], - 'highlight': ["clint"] }, + install_requires = [ + "parsedatetime >= 1.1.2", + "colorama >= 0.2.5", + ], long_description=__doc__, entry_points={ 'console_scripts': [