Uses colorama instead of clint

This commit is contained in:
Manuel Ebert 2013-04-17 10:19:02 +02:00
parent f79f7cf849
commit e0f7d235b1
5 changed files with 19 additions and 13 deletions

View file

@ -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

View file

@ -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