mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Uses colorama instead of clint
This commit is contained in:
parent
f79f7cf849
commit
e0f7d235b1
5 changed files with 19 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
6
setup.py
6
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': [
|
||||
|
|
Loading…
Add table
Reference in a new issue