mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
Delete dayone2.py, fix small bug with import_file() error handling
This commit is contained in:
parent
c16afe1605
commit
a016aee7d4
2 changed files with 1 additions and 30 deletions
|
@ -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
|
|
|
@ -30,7 +30,7 @@ class JSONImporter(PlainJournal, TextExporter):
|
||||||
|
|
||||||
def import_file(self):
|
def import_file(self):
|
||||||
"""Reads a JSON file and returns a dict."""
|
"""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:
|
try:
|
||||||
with open(self.path) as f:
|
with open(self.path) as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
Loading…
Add table
Reference in a new issue