From 29005c0e0799f5daac55231254e7c20bcf80fdb7 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Fri, 19 Jul 2013 13:03:27 +0200 Subject: [PATCH] Better Python2.6 compatibility --- features/steps/core.py | 1 - jrnl/Entry.py | 2 +- jrnl/Journal.py | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/steps/core.py b/features/steps/core.py index 5687e3c9..4b57b47e 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -46,7 +46,6 @@ def check_output(context): @then('the output should contain "{text}"') def check_output_inline(context, text): out = context.stdout_capture.getvalue() - print out assert text in out @then('the journal should contain "{text}"') diff --git a/jrnl/Entry.py b/jrnl/Entry.py index a8ec0557..e8da761b 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(r'(?u)([{}]\w+)'.format(self.journal.config['tagsymbols']), fulltext, re.UNICODE) + tags = re.findall(r'(?u)([{tags}]\w+)'.format(tags=self.journal.config['tagsymbols']), fulltext, re.UNICODE) return set(tags) def __unicode__(self): diff --git a/jrnl/Journal.py b/jrnl/Journal.py index d4e733ea..60118184 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -152,7 +152,8 @@ class Journal(object): except ValueError: # Happens when we can't parse the start of the line as an date. # In this case, just append line to our body. - current_entry.body += line + "\n" + if current_entry: + current_entry.body += line + "\n" # Append last entry if current_entry: @@ -173,7 +174,7 @@ class Journal(object): lambda match: self._colorize(match.group(0)), pp, re.UNICODE) else: - pp = re.sub(r"(?u)([{}]\w+)".format(self.config['tagsymbols']), + pp = re.sub(r"(?u)([{tags}]\w+)".format(tags=self.config['tagsymbols']), lambda match: self._colorize(match.group(0)), pp) return pp