Addresses unicode issues in Python 3

Fixes #79
This commit is contained in:
Manuel Ebert 2013-06-24 12:48:23 +02:00
parent d48a03a00e
commit 20fb701a1a
5 changed files with 10 additions and 8 deletions

View file

@ -2,12 +2,10 @@ language: python
python: python:
- "2.6" - "2.6"
- "2.7" - "2.7"
- "3.2"
- "3.3" - "3.3"
install: "pip install -r requirements.txt --use-mirrors" install: "pip install -r requirements.txt --use-mirrors"
# command to run tests # command to run tests
script: nosetests script: nosetests
matrix: matrix:
allow_failures: # python 3 support for travis is shaky.... allow_failures: # python 3 support for travis is shaky....
- python: 3.2
- python: 3.3 - python: 3.3

View file

@ -1,7 +1,11 @@
Changelog Changelog
========= =========
#### 1.1.0 #### 1.1.1
* [Fixed] Unicode and Python3 issues resolved.
### 1.1.0
* [New] JSON export exports tags as well. * [New] JSON export exports tags as well.
* [Improved] Nicer error message when there is a syntactical error in your config file. * [Improved] Nicer error message when there is a syntactical error in your config file.

View file

@ -15,7 +15,7 @@ class Entry:
def parse_tags(self): def parse_tags(self):
fulltext = " ".join([self.title, self.body]).lower() fulltext = " ".join([self.title, self.body]).lower()
tags = re.findall(ur'([{}]\w+)'.format(self.journal.config['tagsymbols']), fulltext, re.UNICODE) tags = re.findall(r'(?u)([{}]\w+)'.format(self.journal.config['tagsymbols']), fulltext, re.UNICODE)
self.tags = set(tags) self.tags = set(tags)
def __unicode__(self): def __unicode__(self):

View file

@ -170,13 +170,13 @@ class Journal(object):
lambda match: self._colorize(match.group(0)), lambda match: self._colorize(match.group(0)),
pp, re.UNICODE) pp, re.UNICODE)
else: else:
pp = re.sub(ur"(?u)([{}]\w+)".format(self.config['tagsymbols']), pp = re.sub(r"(?u)([{}]\w+)".format(self.config['tagsymbols']),
lambda match: self._colorize(match.group(0)), lambda match: self._colorize(match.group(0)),
pp) pp)
return pp return pp
def __repr__(self): def __repr__(self):
return "<Journal with %d entries>" % len(self.entries) return "<Journal with {} entries>".format(len(self.entries))
def write(self, filename=None): def write(self, filename=None):
"""Dumps the journal into the config file, overwriting it""" """Dumps the journal into the config file, overwriting it"""
@ -229,7 +229,7 @@ class Journal(object):
for m in matches: for m in matches:
date = e.date.strftime(self.config['timeformat']) date = e.date.strftime(self.config['timeformat'])
excerpt = e.body[m.start():min(len(e.body), m.end()+60)] excerpt = e.body[m.start():min(len(e.body), m.end()+60)]
res.append('%s %s ..' % (date, excerpt)) res.append('{} {} ..'.format(date, excerpt))
e.body = "\n".join(res) e.body = "\n".join(res)
else: else:
for e in self.entries: for e in self.entries:

View file

@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line.
""" """
__title__ = 'jrnl' __title__ = 'jrnl'
__version__ = '1.1.0' __version__ = '1.1.1'
__author__ = 'Manuel Ebert' __author__ = 'Manuel Ebert'
__license__ = 'MIT License' __license__ = 'MIT License'
__copyright__ = 'Copyright 2013 Manuel Ebert' __copyright__ = 'Copyright 2013 Manuel Ebert'