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
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
### 1.0.2 (April 17, 2013)
|
||||||
|
|
||||||
|
* [Improved] Removed clint in favour of colorama
|
||||||
### 1.0.1 (March 12, 2013)
|
### 1.0.1 (March 12, 2013)
|
||||||
|
|
||||||
* [Fixed] Requires parsedatetime 1.1.2 or newer
|
* [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__)
|
- `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
|
- `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
|
- `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.
|
- `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
|
> __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 hashlib
|
||||||
import getpass
|
import getpass
|
||||||
try:
|
try:
|
||||||
import clint
|
import colorama
|
||||||
|
colorama.init()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
clint = None
|
colorama = None
|
||||||
import plistlib
|
import plistlib
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
@ -50,9 +51,9 @@ class Journal(object):
|
||||||
self.entries = self.parse(journal_txt)
|
self.entries = self.parse(journal_txt)
|
||||||
self.sort()
|
self.sort()
|
||||||
|
|
||||||
def _colorize(self, string, color='red'):
|
def _colorize(self, string):
|
||||||
if clint:
|
if colorama:
|
||||||
return str(clint.textui.colored.ColoredString(color.upper(), string))
|
return colorama.Fore.CYAN + string + colorama.Fore.RESET
|
||||||
else:
|
else:
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
@ -152,11 +153,11 @@ class Journal(object):
|
||||||
for tag in self.search_tags:
|
for tag in self.search_tags:
|
||||||
tagre = re.compile(re.escape(tag), re.IGNORECASE)
|
tagre = re.compile(re.escape(tag), re.IGNORECASE)
|
||||||
pp = re.sub(tagre,
|
pp = re.sub(tagre,
|
||||||
lambda match: self._colorize(match.group(0), 'cyan'),
|
lambda match: self._colorize(match.group(0)),
|
||||||
pp)
|
pp)
|
||||||
else:
|
else:
|
||||||
pp = re.sub(r"([%s]\w+)" % self.config['tagsymbols'],
|
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)
|
pp)
|
||||||
return 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.")
|
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:
|
# Use highlighting:
|
||||||
if module_exists("clint"):
|
if module_exists("colorama"):
|
||||||
print("clint not found. To turn on highlighting, install clint and set highlight to true in your .jrnl_conf.")
|
print("colorama not found. To turn on highlighting, install colorama and set highlight to true in your .jrnl_conf.")
|
||||||
default_config['highlight'] = False
|
default_config['highlight'] = False
|
||||||
|
|
||||||
open(default_config['journals']['default'], 'a').close() # Touch to make sure it's there
|
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
|
config['password'] = password
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
|
6
setup.py
6
setup.py
|
@ -56,11 +56,13 @@ setup(
|
||||||
version = "1.0.1",
|
version = "1.0.1",
|
||||||
description = "A command line journal application that stores your journal in a plain text file",
|
description = "A command line journal application that stores your journal in a plain text file",
|
||||||
packages = ['jrnl'],
|
packages = ['jrnl'],
|
||||||
install_requires = ["parsedatetime >= 1.1.2"],
|
|
||||||
extras_require = {
|
extras_require = {
|
||||||
'encryption': ["pycrypto"],
|
'encryption': ["pycrypto"],
|
||||||
'highlight': ["clint"]
|
|
||||||
},
|
},
|
||||||
|
install_requires = [
|
||||||
|
"parsedatetime >= 1.1.2",
|
||||||
|
"colorama >= 0.2.5",
|
||||||
|
],
|
||||||
long_description=__doc__,
|
long_description=__doc__,
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
|
Loading…
Add table
Reference in a new issue