From 477fc1487fa5bd0dde7ebb59d5f54d864ef8bbcc Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Thu, 9 Aug 2012 17:54:17 +0200 Subject: [PATCH] New style class, new_entry returns entry --- jrnl/Journal.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 31f45ec0..4f411c98 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -24,7 +24,7 @@ try: except ImportError: clint = None -class Journal: +class Journal(object): def __init__(self, **kwargs): self.config = { 'journal': "journal.txt", @@ -243,7 +243,7 @@ class Journal: return date - def new_entry(self, raw, date=None): + def new_entry(self, raw, date=None, sort=True): """Constructs a new entry from some raw text input. If a date is given, it will parse and use this, otherwise scan for a date in the input first.""" @@ -265,5 +265,9 @@ class Journal: if not date: # Still nothing? Meh, just live in the moment. date = self.parse_date("now") - self.entries.append(Entry(self, date, title, body)) - self.sort() + entry = Entry(self, date, title, body) + self.entries.append(entry) + if sort: + self.sort() + return entry +