mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
[Dayone] Brings back extended Dayone attributes to YAML export
c.f.7d3afd811b
reversefd46ffea23
This commit is contained in:
parent
5adf0aee05
commit
2704ad32c2
1 changed files with 32 additions and 14 deletions
|
@ -58,25 +58,43 @@ class YAMLExporter(TextExporter):
|
||||||
newbody = newbody + previous_line # add very last line
|
newbody = newbody + previous_line # add very last line
|
||||||
|
|
||||||
if warn_on_heading_level is True:
|
if warn_on_heading_level is True:
|
||||||
print("{}WARNING{}: Headings increased past H6 on export - {} {}" \
|
print("{}WARNING{}: Headings increased past H6 on export - {} {}"
|
||||||
.format(WARNING_COLOR, RESET_COLOR, date_str, entry.title), file=sys.stderr)
|
.format(WARNING_COLOR, RESET_COLOR, date_str, entry.title), file=sys.stderr)
|
||||||
|
|
||||||
dayone_attributes = ''
|
dayone_attributes = ''
|
||||||
if hasattr(entry, "uuid"):
|
if hasattr(entry, "uuid"):
|
||||||
dayone_attributes += 'uuid: ' + entry.uuid + '\n'
|
dayone_attributes += 'uuid: ' + entry.uuid + '\n'
|
||||||
# TODO: copy over pictures, if present
|
if hasattr(entry, 'creator_device_agent') or \
|
||||||
# source directory is entry.journal.config['journal']
|
hasattr(entry, 'creator_generation_date') or \
|
||||||
# output directory is...?
|
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(
|
# TODO: copy over pictures, if present
|
||||||
date = date_str,
|
# source directory is entry.journal.config['journal']
|
||||||
title = entry.title,
|
# output directory is...?
|
||||||
stared = entry.starred,
|
|
||||||
tags = ', '.join([tag[1:] for tag in entry.tags]),
|
return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}" \
|
||||||
dayone = dayone_attributes,
|
.format(
|
||||||
body = newbody,
|
date=date_str,
|
||||||
space=""
|
title=entry.title,
|
||||||
)
|
stared=entry.starred,
|
||||||
|
tags=', '.join([tag[1:] for tag in entry.tags]),
|
||||||
|
dayone=dayone_attributes,
|
||||||
|
body=newbody,
|
||||||
|
space=""
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export_journal(cls, journal):
|
def export_journal(cls, journal):
|
||||||
|
|
Loading…
Add table
Reference in a new issue