Added support for importing entries.

This commit is contained in:
Gregory Crosswhite 2014-10-24 15:21:10 -07:00
parent 6fed042b8b
commit 6258465f5d
5 changed files with 68 additions and 6 deletions

View file

@ -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)."""