mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
[DayOne Exporter] apply black formatting
This commit is contained in:
parent
19c29dd614
commit
9085b2132b
1 changed files with 37 additions and 23 deletions
|
@ -76,31 +76,37 @@ class DayOne(Journal.Journal):
|
|||
|
||||
"""Extended DayOne attributes"""
|
||||
try:
|
||||
entry.creator_device_agent = dict_entry['Creator']['Device Agent']
|
||||
entry.creator_device_agent = dict_entry["Creator"][
|
||||
"Device Agent"
|
||||
]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
entry.creator_generation_date = dict_entry['Creator']['Generation Date']
|
||||
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']
|
||||
entry.creator_host_name = dict_entry["Creator"]["Host Name"]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
entry.creator_os_agent = dict_entry['Creator']['OS Agent']
|
||||
entry.creator_os_agent = dict_entry["Creator"]["OS Agent"]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
entry.creator_software_agent = dict_entry['Creator']['Software Agent']
|
||||
entry.creator_software_agent = dict_entry["Creator"][
|
||||
"Software Agent"
|
||||
]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
entry.location = dict_entry['Location']
|
||||
entry.location = dict_entry["Location"]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
entry.weather = dict_entry['Weather']
|
||||
entry.weather = dict_entry["Weather"]
|
||||
except:
|
||||
pass
|
||||
self.entries.append(entry)
|
||||
|
@ -118,15 +124,19 @@ class DayOne(Journal.Journal):
|
|||
if not hasattr(entry, "uuid"):
|
||||
entry.uuid = uuid.uuid1().hex
|
||||
if not hasattr(entry, "creator_device_agent"):
|
||||
entry.creator_device_agent = '' # iPhone/iPhone5,3
|
||||
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())
|
||||
entry.creator_os_agent = "{}/{}".format(
|
||||
platform.system(), platform.release()
|
||||
)
|
||||
if not hasattr(entry, "creator_software_agent"):
|
||||
entry.creator_software_agent = '{}/{}'.format(__title__, __version__)
|
||||
entry.creator_software_agent = "{}/{}".format(
|
||||
__title__, __version__
|
||||
)
|
||||
|
||||
fn = (
|
||||
Path(self.config["journal"])
|
||||
|
@ -144,16 +154,18 @@ class DayOne(Journal.Journal):
|
|||
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,
|
||||
'Software Agent': entry.creator_software_agent}
|
||||
"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,
|
||||
"Software Agent": entry.creator_software_agent,
|
||||
},
|
||||
}
|
||||
if hasattr(entry, 'location'):
|
||||
entry_plist['Location'] = entry.location
|
||||
if hasattr(entry, 'weather'):
|
||||
entry_plist['Weather'] = entry.weather
|
||||
if hasattr(entry, "location"):
|
||||
entry_plist["Location"] = entry.location
|
||||
if hasattr(entry, "weather"):
|
||||
entry_plist["Weather"] = entry.weather
|
||||
|
||||
# plistlib expects a binary object
|
||||
with fn.open(mode="wb") as f:
|
||||
|
@ -200,7 +212,7 @@ class DayOne(Journal.Journal):
|
|||
if line.endswith("*"):
|
||||
current_entry.starred = True
|
||||
line = line[:-1]
|
||||
current_entry.title = line[len(date_blob) - 1:].strip()
|
||||
current_entry.title = line[len(date_blob) - 1 :].strip()
|
||||
current_entry.date = new_date
|
||||
elif current_entry:
|
||||
current_entry.body += line + "\n"
|
||||
|
@ -212,7 +224,9 @@ class DayOne(Journal.Journal):
|
|||
# Now, update our current entries if they changed
|
||||
for entry in entries:
|
||||
entry._parse_text()
|
||||
matched_entries = [e for e in self.entries if e.uuid.lower() == entry.uuid.lower()]
|
||||
matched_entries = [
|
||||
e for e in self.entries if e.uuid.lower() == entry.uuid.lower()
|
||||
]
|
||||
# tags in entry body
|
||||
if matched_entries:
|
||||
# This entry is an existing entry
|
||||
|
@ -232,9 +246,9 @@ class DayOne(Journal.Journal):
|
|||
entry.creator_os_agent = match.creator_os_agent
|
||||
if hasattr(match, "creator_software_agent"):
|
||||
entry.creator_software_agent = match.creator_software_agent
|
||||
if hasattr(match, 'location'):
|
||||
if hasattr(match, "location"):
|
||||
entry.location = match.location
|
||||
if hasattr(match, 'weather'):
|
||||
if hasattr(match, "weather"):
|
||||
entry.weather = match.weather
|
||||
|
||||
if match != entry:
|
||||
|
|
Loading…
Add table
Reference in a new issue