Merge pull request #143 from maebert/dayone-tag-search

Adds the tag symbol to day one entries on load
This commit is contained in:
Manuel Ebert 2014-03-19 15:20:02 -07:00
commit c93174f4f4
2 changed files with 16 additions and 7 deletions

View file

@ -33,8 +33,8 @@ Feature: DayOne Ingetration
When we run "jrnl --tags"
Then the output should be
"""
work : 1
play : 1
@work : 1
@play : 1
"""
Scenario: Saving tags from a DayOne Journal
@ -43,6 +43,14 @@ Feature: DayOne Ingetration
and we run "jrnl --tags"
Then the output should be
"""
work : 2
play : 1
@work : 2
@play : 1
"""
Scenario: Filtering by tags from a DayOne Journal
Given we use the config "dayone.json"
When we run "jrnl @work"
Then the output should be
"""
2013-05-17 11:39 This entry has tags!
"""

View file

@ -25,6 +25,7 @@ import pytz
import uuid
import tzlocal
class Journal(object):
def __init__(self, name='default', **kwargs):
self.config = {
@ -318,6 +319,7 @@ class Journal(object):
entry.modified = not any(entry == old_entry for old_entry in self.entries)
self.entries = mod_entries
class DayOne(Journal):
"""A special Journal handling DayOne files"""
def __init__(self, **kwargs):
@ -342,7 +344,7 @@ class DayOne(Journal):
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
entry = Entry.Entry(self, date, title, body, starred=dict_entry["Starred"])
entry.uuid = dict_entry["UUID"]
entry.tags = dict_entry.get("Tags", [])
entry.tags = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
self.entries.append(entry)
self.sort()
@ -430,4 +432,3 @@ class DayOne(Journal):
self._deleted_entries = [e for e in self.entries if e.uuid not in edited_uuids]
self.entries[:] = [e for e in self.entries if e.uuid in edited_uuids]
return entries