Make colorama optional

This commit is contained in:
William Minchin 2014-01-02 18:25:24 -07:00
parent 60decf9fe0
commit 91ec39554b
7 changed files with 15 additions and 13 deletions

View file

@ -4,7 +4,7 @@ Changelog
### 1.7 (December 22, 2013)
* __1.7.5__ Return of colorama (for color on Windows), fixes editing (stops deleting entries instead of editing them), improves Windows documentation.
* __1.7.5__ Optional return of colorama (for color on Windows), fixes editing (stops deleting entries instead of editing them), improves Windows documentation.
* __1.7.4__ Gets rid of colorama.
* __1.7.3__ Touches temporary files before opening them to allow more external editors.
* __1.7.2__ Dateutil added to requirements.

View file

@ -104,6 +104,10 @@ Windows Usage
A couple of tips to get jrnl working better on Windows:
To get colored output on Windows, install ``colorama`` ::
pip install colorama
The configuration file is typically found at ``C:\Users\[Your Username\.jrnl_conf``. This is just a text file and so can be edited in a text editor (but don't use Notepad, it will mess with the line endings).
For editing entries, Notepad will technically work, but doesn't play nice with line endings. A good alternative is `Notepad++ <http://notepad-plus-plus.org/>`_. To set Notepad++ as your editor, edit the jrnl config file (``.jrnl_conf``) like this:

View file

@ -57,12 +57,6 @@ class Journal(object):
"""Returns the number of entries"""
return len(self.entries)
def _colorize(self, string):
if colorama:
return colorama.Fore.CYAN + string + colorama.Fore.RESET
else:
return string
def _decrypt(self, cipher):
"""Decrypts a cipher string using self.key as the key and the first 16 byte of the cipher as the IV"""
if not crypto_installed:
@ -174,11 +168,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)),
lambda match: util.colorize(match.group(0)),
pp, re.UNICODE)
else:
pp = re.sub(r"(?u)([{tags}]\w+)".format(tags=self.config['tagsymbols']),
lambda match: self._colorize(match.group(0)),
lambda match: util.colorize(match.group(0)),
pp)
return pp

View file

@ -7,10 +7,10 @@ jrnl is a simple journal application for your command line.
"""
__title__ = 'jrnl'
__version__ = '1.7.3'
__version__ = '1.7.5'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 Manuel Ebert'
__copyright__ = 'Copyright 2013-14 Manuel Ebert'
from . import Journal
from . import cli

View file

@ -139,3 +139,9 @@ def get_text_from_editor(config, template=""):
prompt('[Nothing saved to file]')
return raw
def colorize(string):
"""Returns the string wrapped in cyan ANSI escape"""
if os.name == "nt" and not colorama:
return string
else:
return u"\033[36m{}\033[39m".format(string)

View file

@ -1,6 +1,5 @@
parsedatetime >= 1.1.2
pytz >= 2013b
colorama >= 0.2.5
pycrypto >= 2.6
argparse==1.2.1
tzlocal == 1.0

View file

@ -75,7 +75,6 @@ setup(
"slugify>=0.0.1",
"keyring>=3.3",
"python-dateutil>=2.2"
"colorama>=0.2.5",
] + [p for p, cond in conditional_dependencies.items() if cond],
extras_require = {
"encrypted": "pycrypto>=2.6"