mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-11 00:58:31 +02:00
Formatting
This commit is contained in:
parent
4528d9f612
commit
1417305c2e
1 changed files with 17 additions and 17 deletions
|
@ -31,6 +31,7 @@ except ImportError:
|
||||||
import plistlib
|
import plistlib
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
class Journal(object):
|
class Journal(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.config = {
|
self.config = {
|
||||||
|
@ -176,7 +177,7 @@ class Journal(object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Journal with %d entries>" % len(self.entries)
|
return "<Journal with %d entries>" % len(self.entries)
|
||||||
|
|
||||||
def write(self, filename = None):
|
def write(self, filename=None):
|
||||||
"""Dumps the journal into the config file, overwriting it"""
|
"""Dumps the journal into the config file, overwriting it"""
|
||||||
filename = filename or self.config['journal']
|
filename = filename or self.config['journal']
|
||||||
journal = "\n".join([str(e) for e in self.entries])
|
journal = "\n".join([str(e) for e in self.entries])
|
||||||
|
@ -268,7 +269,7 @@ class Journal(object):
|
||||||
|
|
||||||
# Split raw text into title and body
|
# Split raw text into title and body
|
||||||
title_end = len(raw)
|
title_end = len(raw)
|
||||||
for separator in ["\n",". ","? ","! "]:
|
for separator in ["\n", ". ", "? ", "! "]:
|
||||||
sep_pos = raw.find(separator)
|
sep_pos = raw.find(separator)
|
||||||
if 1 < sep_pos < title_end:
|
if 1 < sep_pos < title_end:
|
||||||
title_end = sep_pos
|
title_end = sep_pos
|
||||||
|
@ -288,6 +289,7 @@ class Journal(object):
|
||||||
self.sort()
|
self.sort()
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
|
||||||
class DayOne(Journal):
|
class DayOne(Journal):
|
||||||
"""A special Journal handling DayOne files"""
|
"""A special Journal handling DayOne files"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
@ -314,7 +316,6 @@ class DayOne(Journal):
|
||||||
# we're returning the obvious.
|
# we're returning the obvious.
|
||||||
return self.entries
|
return self.entries
|
||||||
|
|
||||||
|
|
||||||
def write(self):
|
def write(self):
|
||||||
"""Writes only the entries that have been modified into plist files."""
|
"""Writes only the entries that have been modified into plist files."""
|
||||||
for entry in self.entries:
|
for entry in self.entries:
|
||||||
|
@ -331,4 +332,3 @@ class DayOne(Journal):
|
||||||
'UUID': new_uuid
|
'UUID': new_uuid
|
||||||
}
|
}
|
||||||
plistlib.writePlist(entry_plist, filename)
|
plistlib.writePlist(entry_plist, filename)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue