From a016aee7d45c97a39217e4691b6ebee6c8e59865 Mon Sep 17 00:00:00 2001 From: dbxnr Date: Tue, 21 Jan 2020 17:22:18 +0000 Subject: [PATCH] Delete dayone2.py, fix small bug with import_file() error handling --- jrnl/dayone2.py | 29 ----------------------------- jrnl/plugins/json_importer.py | 2 +- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 jrnl/dayone2.py diff --git a/jrnl/dayone2.py b/jrnl/dayone2.py deleted file mode 100644 index ec8e6c9a..00000000 --- a/jrnl/dayone2.py +++ /dev/null @@ -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 diff --git a/jrnl/plugins/json_importer.py b/jrnl/plugins/json_importer.py index bff811fa..6ccb3b63 100644 --- a/jrnl/plugins/json_importer.py +++ b/jrnl/plugins/json_importer.py @@ -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)