This commit is contained in:
dbxnr 2020-02-11 23:49:24 +00:00
parent 16a4e60582
commit 8268404bb2
3 changed files with 19 additions and 11 deletions

View file

@ -5,7 +5,7 @@
"creationDate": "2020-01-10T12:22:12Z",
"photos": [],
"starred": false,
"tags": [],
"tags": ["awesome", "great"],
"text": "Entry Number One.",
"timeZone": "Europe/London",
"uuid": "EBB5A5F4057F461E8F176E18AB7E0493"
@ -15,7 +15,7 @@
"creationDate": "2020-01-10T12:21:48Z",
"photos": [],
"starred": true,
"tags": [],
"tags": ["great"],
"text": "Entry Number Two.\n\nWith some body.",
"timeZone": "Europe/London",
"uuid": "EC61E5D4E66C44E6AC796E863E8BF7E7"

View file

@ -23,11 +23,18 @@ Feature: Day One 2.0 implementation details.
Scenario: Converted journal is validated
Given we use the config "basic.yaml"
When we run "jrnl --import dayone2 features/data/journals/dayone2.json"
When we run "jrnl dayone2 -n 10"
Then the output should contain
"""
10-01-2020 12:21 Entry Number Two.
| With some body.
Then we should get no error
When we run "jrnl dayone2 -n 2"
Then we should get no error
and the output should contain "10-01-2020 12:21 Entry Number Two."
10-01-2020 12:22 Entry Number One.
Scenario: Check tags are handled correctly
Given we use the config "basic.yaml"
When we run "jrnl --import dayone2 features/data/journals/dayone2.json"
When we run "jrnl dayone2 --tags"
Then we should get no error
and the output should contain
"""
@great : 2
@awesome : 1
"""

View file

@ -26,7 +26,7 @@ class DayOne2Importer(JSONImporter):
self.convert_journal()
def convert_journal(self):
print(self._convert())
self._convert()
def validate_schema(self):
try:
@ -42,13 +42,14 @@ class DayOne2Importer(JSONImporter):
def parse_json(self):
entries = []
print(self.json)
for entry in self.json["entries"]:
tags = " ".join(["@" + t for t in entry["tags"]])
entries.append(
Entry(
self,
date=datetime.strptime(entry["creationDate"], "%Y-%m-%dT%H:%M:%SZ"),
text=entry["text"],
text=f"{entry['text']} {tags}",
starred=entry["starred"],
)
)