mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 21:46:13 +02:00
Added support for importing entries.
This commit is contained in:
parent
6fed042b8b
commit
6258465f5d
5 changed files with 68 additions and 6 deletions
|
@ -33,6 +33,14 @@ class Journal(object):
|
|||
"""Returns the number of entries"""
|
||||
return len(self.entries)
|
||||
|
||||
def import_(self, other_journal_txt):
|
||||
other_entries = self._parse(other_journal_txt)
|
||||
entries_set = frozenset(self.entries)
|
||||
for other_entry in other_entries:
|
||||
if other_entry not in entries_set:
|
||||
self.entries.append(other_entry)
|
||||
self.sort()
|
||||
|
||||
def open(self, filename=None):
|
||||
"""Opens the journal file defined in the config and parses it into a list of Entries.
|
||||
Entries have the form (date, title, body)."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue