mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-12 01:18:31 +02:00
[Dayone] maintain existing tags stored in Dayone metadata
This commit is contained in:
parent
5a1a1e12fb
commit
50dfaf2f13
1 changed files with 6 additions and 4 deletions
|
@ -50,8 +50,7 @@ class DayOne(Journal.Journal):
|
||||||
date = date + timezone.utcoffset(date, is_dst=False)
|
date = date + timezone.utcoffset(date, is_dst=False)
|
||||||
entry = Entry.Entry(self, date, text=dict_entry['Entry Text'], starred=dict_entry["Starred"])
|
entry = Entry.Entry(self, date, text=dict_entry['Entry Text'], starred=dict_entry["Starred"])
|
||||||
entry.uuid = dict_entry["UUID"]
|
entry.uuid = dict_entry["UUID"]
|
||||||
entry._tags = [self.config['tagsymbols'][0] + tag.lower() for tag in dict_entry.get("Tags", [])]
|
entry._tags = [self.config['tagsymbols'][0] + tag.lower().replace(" ", "_") for tag in dict_entry.get("Tags", [])]
|
||||||
|
|
||||||
self.entries.append(entry)
|
self.entries.append(entry)
|
||||||
self.sort()
|
self.sort()
|
||||||
return self
|
return self
|
||||||
|
@ -66,7 +65,7 @@ class DayOne(Journal.Journal):
|
||||||
entry.uuid = uuid.uuid1().hex
|
entry.uuid = uuid.uuid1().hex
|
||||||
|
|
||||||
filename = os.path.join(self.config['journal'], "entries", entry.uuid.upper() + ".doentry")
|
filename = os.path.join(self.config['journal'], "entries", entry.uuid.upper() + ".doentry")
|
||||||
|
|
||||||
entry_plist = {
|
entry_plist = {
|
||||||
'Creation Date': utc_time,
|
'Creation Date': utc_time,
|
||||||
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
||||||
|
@ -126,11 +125,14 @@ class DayOne(Journal.Journal):
|
||||||
|
|
||||||
# Now, update our current entries if they changed
|
# Now, update our current entries if they changed
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
|
# tags in entry body
|
||||||
entry._parse_text()
|
entry._parse_text()
|
||||||
matched_entries = [e for e in self.entries if e.uuid.lower() == entry.uuid]
|
matched_entries = [e for e in self.entries if e.uuid.lower() == entry.uuid.lower()]
|
||||||
if matched_entries:
|
if matched_entries:
|
||||||
# This entry is an existing entry
|
# This entry is an existing entry
|
||||||
match = matched_entries[0]
|
match = matched_entries[0]
|
||||||
|
# merge existing tags with tags pulled from the entry body
|
||||||
|
entry.tags = list(set(entry.tags + match.tags))
|
||||||
if match != entry:
|
if match != entry:
|
||||||
self.entries.remove(match)
|
self.entries.remove(match)
|
||||||
entry.modified = True
|
entry.modified = True
|
||||||
|
|
Loading…
Add table
Reference in a new issue