Delete dayone2.py, fix small bug with import_file() error handling

This commit is contained in:
dbxnr 2020-01-21 17:22:18 +00:00
parent 6f84eec165
commit 01546672be
2 changed files with 1 additions and 30 deletions

View file

@ -1,29 +0,0 @@
import json
from datetime import datetime
from .Entry import Entry
from . import Journal
class DayOne2(Journal.PlainJournal):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def _parse(self, json_data):
entries = []
json_string = json.loads(json_data)
for entry in json_string["entries"]:
entries.append(
Entry(
self,
date=datetime.strptime(entry["creationDate"], "%Y-%m-%dT%H:%M:%SZ"),
text=entry["text"],
starred=entry["starred"],
)
)
return entries

View file

@ -30,7 +30,7 @@ class JSONImporter(PlainJournal, TextExporter):
def import_file(self):
"""Reads a JSON file and returns a dict."""
if os.path.exists(self.path):
if os.path.exists(self.path) and Path(self.path).suffix == '.json':
try:
with open(self.path) as f:
return json.load(f)