From 2704ad32c257471e0d992c3e4034e30ab980e146 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 14 Dec 2019 15:00:20 -0700 Subject: [PATCH] [Dayone] Brings back extended Dayone attributes to YAML export c.f. 7d3afd811ba2c32463391b709331019e3cbfc40f reverse fd46ffea23eb1cb98121bde3a3993a4fa56e1afb --- jrnl/plugins/yaml_exporter.py | 46 ++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 0fa172d2..6ef791c7 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -58,25 +58,43 @@ class YAMLExporter(TextExporter): newbody = newbody + previous_line # add very last line if warn_on_heading_level is True: - print("{}WARNING{}: Headings increased past H6 on export - {} {}" \ - .format(WARNING_COLOR, RESET_COLOR, date_str, entry.title), file=sys.stderr) + print("{}WARNING{}: Headings increased past H6 on export - {} {}" + .format(WARNING_COLOR, RESET_COLOR, date_str, entry.title), file=sys.stderr) dayone_attributes = '' if hasattr(entry, "uuid"): dayone_attributes += 'uuid: ' + entry.uuid + '\n' - # TODO: copy over pictures, if present - # source directory is entry.journal.config['journal'] - # output directory is...? + 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'): + dayone_attributes += 'creator:\n' + if hasattr(entry, 'creator_device_agent'): + dayone_attributes += ' device agent: {}\n'.format(entry.creator_device_agent) + if hasattr(entry, 'creator_generation_date'): + dayone_attributes += ' generation date: {}\n'.format(str(entry.creator_generation_date)) + if hasattr(entry, 'creator_host_name'): + dayone_attributes += ' host name: {}\n'.format(entry.creator_host_name) + if hasattr(entry, 'creator_os_agent'): + dayone_attributes += ' os agent: {}\n'.format(entry.creator_os_agent) + if hasattr(entry, 'creator_software_agent'): + dayone_attributes += ' software agent: {}\n'.format(entry.creator_software_agent) - return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}".format( - date = date_str, - title = entry.title, - stared = entry.starred, - tags = ', '.join([tag[1:] for tag in entry.tags]), - dayone = dayone_attributes, - body = newbody, - space="" - ) + # TODO: copy over pictures, if present + # source directory is entry.journal.config['journal'] + # output directory is...? + + return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}" \ + .format( + date=date_str, + title=entry.title, + stared=entry.starred, + tags=', '.join([tag[1:] for tag in entry.tags]), + dayone=dayone_attributes, + body=newbody, + space="" + ) @classmethod def export_journal(cls, journal):