mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
[Dayone] cut extended attributes for now
This commit is contained in:
parent
eed1bd3cb3
commit
b8dbf84753
2 changed files with 1 additions and 69 deletions
|
@ -5,8 +5,6 @@ from __future__ import absolute_import, unicode_literals
|
||||||
from . import Entry
|
from . import Entry
|
||||||
from . import Journal
|
from . import Journal
|
||||||
from . import time as jrnl_time
|
from . import time as jrnl_time
|
||||||
from . import __title__ # 'jrnl'
|
|
||||||
from . import __version__
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -17,8 +15,6 @@ import pytz
|
||||||
import uuid
|
import uuid
|
||||||
import tzlocal
|
import tzlocal
|
||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError
|
||||||
import socket
|
|
||||||
import platform
|
|
||||||
|
|
||||||
|
|
||||||
class DayOne(Journal.Journal):
|
class DayOne(Journal.Journal):
|
||||||
|
@ -59,35 +55,6 @@ class DayOne(Journal.Journal):
|
||||||
entry.uuid = dict_entry["UUID"]
|
entry.uuid = dict_entry["UUID"]
|
||||||
entry.tags = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
|
entry.tags = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
|
||||||
|
|
||||||
"""Extended DayOne attributes"""
|
|
||||||
try:
|
|
||||||
entry.creator_device_agent = dict_entry['Creator']['Device Agent']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
entry.creator_generation_date = dict_entry['Creator']['Generation Date']
|
|
||||||
except:
|
|
||||||
entry.creator_generation_date = date
|
|
||||||
try:
|
|
||||||
entry.creator_host_name = dict_entry['Creator']['Host Name']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
entry.creator_os_agent = dict_entry['Creator']['OS Agent']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
entry.creator_software_agent = dict_entry['Creator']['Software Agent']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
entry.location = dict_entry['Location']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
entry.weather = dict_entry['Weather']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
self.entries.append(entry)
|
self.entries.append(entry)
|
||||||
self.sort()
|
self.sort()
|
||||||
return self
|
return self
|
||||||
|
@ -100,16 +67,6 @@ class DayOne(Journal.Journal):
|
||||||
|
|
||||||
if not hasattr(entry, "uuid"):
|
if not hasattr(entry, "uuid"):
|
||||||
entry.uuid = uuid.uuid1().hex
|
entry.uuid = uuid.uuid1().hex
|
||||||
if not hasattr(entry, "creator_device_agent"):
|
|
||||||
entry.creator_device_agent = '' # iPhone/iPhone5,3
|
|
||||||
if not hasattr(entry, "creator_generation_date"):
|
|
||||||
entry.creator_generation_date = utc_time
|
|
||||||
if not hasattr(entry, "creator_host_name"):
|
|
||||||
entry.creator_host_name = socket.gethostname()
|
|
||||||
if not hasattr(entry, "creator_os_agent"):
|
|
||||||
entry.creator_os_agent = '{}/{}'.format(platform.system(), platform.release())
|
|
||||||
if not hasattr(entry, "creator_software_agent"):
|
|
||||||
entry.creator_software_agent = '{}/{}'.format(__title__, __version__)
|
|
||||||
|
|
||||||
filename = os.path.join(self.config['journal'], "entries", entry.uuid.upper() + ".doentry")
|
filename = os.path.join(self.config['journal'], "entries", entry.uuid.upper() + ".doentry")
|
||||||
|
|
||||||
|
@ -119,17 +76,8 @@ class DayOne(Journal.Journal):
|
||||||
'Entry Text': entry.title + "\n" + entry.body,
|
'Entry Text': entry.title + "\n" + entry.body,
|
||||||
'Time Zone': str(tzlocal.get_localzone()),
|
'Time Zone': str(tzlocal.get_localzone()),
|
||||||
'UUID': entry.uuid.upper(),
|
'UUID': entry.uuid.upper(),
|
||||||
'Tags': [tag.strip(self.config['tagsymbols']).replace("_", " ") for tag in entry.tags],
|
'Tags': [tag.strip(self.config['tagsymbols']).replace("_", " ") for tag in entry.tags]
|
||||||
'Creator': {'Device Agent': entry.creator_device_agent,
|
|
||||||
'Generation Date': entry.creator_generation_date,
|
|
||||||
'Host Name': entry.creator_host_name,
|
|
||||||
'OS Agent': entry.creator_os_agent,
|
|
||||||
'Sofware Agent': entry.creator_software_agent}
|
|
||||||
}
|
}
|
||||||
if hasattr(entry, 'location'):
|
|
||||||
entry_plist['Location'] = entry.location
|
|
||||||
if hasattr(entry, 'weather'):
|
|
||||||
entry_plist['Weather'] = entry.weather
|
|
||||||
plistlib.writePlist(entry_plist, filename)
|
plistlib.writePlist(entry_plist, filename)
|
||||||
for entry in self._deleted_entries:
|
for entry in self._deleted_entries:
|
||||||
filename = os.path.join(self.config['journal'], "entries", entry.uuid + ".doentry")
|
filename = os.path.join(self.config['journal'], "entries", entry.uuid + ".doentry")
|
||||||
|
|
|
@ -61,22 +61,6 @@ class YAMLExporter(TextExporter):
|
||||||
dayone_attributes = ''
|
dayone_attributes = ''
|
||||||
if hasattr(entry, "uuid"):
|
if hasattr(entry, "uuid"):
|
||||||
dayone_attributes += 'uuid: ' + entry.uuid + '\n'
|
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: {}\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(
|
return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}".format(
|
||||||
date = date_str,
|
date = date_str,
|
||||||
|
|
Loading…
Add table
Reference in a new issue