[Dayone] Add Creator section to dayone import and YAML export

This commit is contained in:
MinchinWeb 2015-05-04 00:21:33 -06:00
parent 91368c7b63
commit 0fcf078c1c
3 changed files with 74 additions and 11 deletions

View file

@ -58,12 +58,33 @@ class YAMLExporter(TextExporter):
if warn_on_heading_level is True:
print("{}WARNING{}: Headings increased past H6 on export - {} {}".format("\033[33m", "\033[0m", date_str, entry.title), file=sys.stderr)
return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{body} {space}".format(
date=date_str,
title=entry.title,
stared=entry.starred,
tags=', '.join([tag[1:] for tag in entry.tags]),
body=newbody,
dayone_attributes = ''
if hasattr(entry, "uuid"):
dayone_attributes += 'uuid: ' + entry.uuid + '\n'
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: ' + entry.creator_device_agent + '\n'
if hasattr(entry, 'creator_generation_date'):
dayone_attributes += ' generation date: ' + str(entry.creator_generation_date) + '\n'
if hasattr(entry, 'creator_host_name'):
dayone_attributes += ' host name: ' + entry.creator_host_name + '\n'
if hasattr(entry, 'creator_os_agent'):
dayone_attributes += ' os agent: ' + entry.creator_os_agent + '\n'
if hasattr(entry, 'creator_software_agent'):
dayone_attributes += ' software agent: ' + entry.creator_software_agent + '\n'
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=""
)