From d7dfba008c60a9d128a52a7b7bdc532e77c5b917 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 24 Jun 2013 12:48:23 +0200 Subject: [PATCH] Addresses unicode issues in Python 3 Fixes #79 --- .travis.yml | 2 -- CHANGELOG.md | 6 +++++- jrnl/Entry.py | 2 +- jrnl/Journal.py | 6 +++--- jrnl/__init__.py | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1ed5780..ecfc9bde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,10 @@ language: python python: - "2.6" - "2.7" - - "3.2" - "3.3" install: "pip install -r requirements.txt --use-mirrors" # command to run tests script: nosetests matrix: allow_failures: # python 3 support for travis is shaky.... - - python: 3.2 - python: 3.3 diff --git a/CHANGELOG.md b/CHANGELOG.md index c4de8d5f..4faef2fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ Changelog ========= -#### 1.1.0 +#### 1.1.1 + +* [Fixed] Unicode and Python3 issues resolved. + +### 1.1.0 * [New] JSON export exports tags as well. * [Improved] Nicer error message when there is a syntactical error in your config file. diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 624b6197..1d475501 100644 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -15,7 +15,7 @@ class Entry: def parse_tags(self): 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) def __unicode__(self): diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 9cbe41e2..193d89a6 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -170,13 +170,13 @@ class Journal(object): lambda match: self._colorize(match.group(0)), pp, re.UNICODE) 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)), pp) return pp def __repr__(self): - return "" % len(self.entries) + return "".format(len(self.entries)) def write(self, filename=None): """Dumps the journal into the config file, overwriting it""" @@ -229,7 +229,7 @@ class Journal(object): for m in matches: date = e.date.strftime(self.config['timeformat']) 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) else: for e in self.entries: diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 4c3a2b79..79103a7b 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line. """ __title__ = 'jrnl' -__version__ = '1.1.0' +__version__ = '1.1.1' __author__ = 'Manuel Ebert' __license__ = 'MIT License' __copyright__ = 'Copyright 2013 Manuel Ebert'