From fe819dcbf4ecc58eba4b2e09e616439d9398ad90 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Mon, 25 May 2020 21:49:54 -0600 Subject: [PATCH] [JSON Exporter] add support for extended DayOne Metadata --- .gitignore | 1 + jrnl/plugins/json_exporter.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.gitignore b/.gitignore index db6df82b..afb0d874 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ obj env/ env*/ venv*/ +.venv*/ # PyCharm Project files .idea/ diff --git a/jrnl/plugins/json_exporter.py b/jrnl/plugins/json_exporter.py index 90a2059f..b30b77ad 100644 --- a/jrnl/plugins/json_exporter.py +++ b/jrnl/plugins/json_exporter.py @@ -23,6 +23,27 @@ class JSONExporter(TextExporter): } if hasattr(entry, "uuid"): entry_dict["uuid"] = entry.uuid + if ( + hasattr(entry, "creator_device_agent") + or hasattr(entry, "creator_generation_date") + or hasattr(entry, "creator_host_name") + or hasattr(entry, "creator_os_agent") + or hasattr(entry, "creator_software_agent") + ): + entry_dict["creator"] = {} + if hasattr(entry, "creator_device_agent"): + entry_dict["creator"]["device_agent"] = entry.creator_device_agent + if hasattr(entry, "creator_generation_date"): + entry_dict["creator"]["generation_date"] = str( + entry.creator_generation_date + ) + if hasattr(entry, "creator_host_name"): + entry_dict["creator"]["host_name"] = entry.creator_host_name + if hasattr(entry, "creator_os_agent"): + entry_dict["creator"]["os_agent"] = entry.creator_os_agent + if hasattr(entry, "creator_software_agent"): + entry_dict["creator"]["software_agent"] = entry.creator_software_agent + return entry_dict @classmethod