mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
New style class, new_entry returns entry
This commit is contained in:
parent
691c67b13b
commit
477fc1487f
1 changed files with 8 additions and 4 deletions
|
@ -24,7 +24,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
clint = None
|
clint = None
|
||||||
|
|
||||||
class Journal:
|
class Journal(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.config = {
|
self.config = {
|
||||||
'journal': "journal.txt",
|
'journal': "journal.txt",
|
||||||
|
@ -243,7 +243,7 @@ class Journal:
|
||||||
|
|
||||||
return date
|
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.
|
"""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."""
|
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.
|
if not date: # Still nothing? Meh, just live in the moment.
|
||||||
date = self.parse_date("now")
|
date = self.parse_date("now")
|
||||||
|
|
||||||
self.entries.append(Entry(self, date, title, body))
|
entry = Entry(self, date, title, body)
|
||||||
self.sort()
|
self.entries.append(entry)
|
||||||
|
if sort:
|
||||||
|
self.sort()
|
||||||
|
return entry
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue