mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 13:08:31 +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
|
||||
|
||||
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):
|
||||
|
|
Loading…
Add table
Reference in a new issue