mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
parent
53958cf328
commit
4301927b72
5 changed files with 19 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
from . import Entry
|
from . import Entry
|
||||||
from . import Journal
|
from . import Journal
|
||||||
import os
|
import os
|
||||||
|
@ -75,7 +75,7 @@ class DayOne(Journal.Journal):
|
||||||
def editable_str(self):
|
def editable_str(self):
|
||||||
"""Turns the journal into a string of entries that can be edited
|
"""Turns the journal into a string of entries that can be edited
|
||||||
manually and later be parsed with eslf.parse_editable_str."""
|
manually and later be parsed with eslf.parse_editable_str."""
|
||||||
return u"\n".join([u"# {0}\n{1}".format(e.uuid, e.__unicode__()) for e in self.entries])
|
return "\n".join(["# {0}\n{1}".format(e.uuid, e.__unicode__()) for e in self.entries])
|
||||||
|
|
||||||
def parse_editable_str(self, edited):
|
def parse_editable_str(self, edited):
|
||||||
"""Parses the output of self.editable_str and updates it's entries."""
|
"""Parses the output of self.editable_str and updates it's entries."""
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
import re
|
import re
|
||||||
import textwrap
|
import textwrap
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -34,7 +35,7 @@ class Entry:
|
||||||
title = date_str + " " + self.title.rstrip("\n ")
|
title = date_str + " " + self.title.rstrip("\n ")
|
||||||
if self.starred:
|
if self.starred:
|
||||||
title += " *"
|
title += " *"
|
||||||
return u"{title}{sep}{body}\n".format(
|
return "{title}{sep}{body}\n".format(
|
||||||
title=title,
|
title=title,
|
||||||
sep="\n" if self.body.rstrip("\n ") else "",
|
sep="\n" if self.body.rstrip("\n ") else "",
|
||||||
body=self.body.rstrip("\n ")
|
body=self.body.rstrip("\n ")
|
||||||
|
@ -64,7 +65,7 @@ class Entry:
|
||||||
if short:
|
if short:
|
||||||
return title
|
return title
|
||||||
else:
|
else:
|
||||||
return u"{title}{sep}{body}\n".format(
|
return "{title}{sep}{body}\n".format(
|
||||||
title=title,
|
title=title,
|
||||||
sep="\n" if has_body else "",
|
sep="\n" if has_body else "",
|
||||||
body=body if has_body else "",
|
body=body if has_body else "",
|
||||||
|
@ -101,7 +102,7 @@ class Entry:
|
||||||
space = "\n"
|
space = "\n"
|
||||||
md_head = "###"
|
md_head = "###"
|
||||||
|
|
||||||
return u"{md} {date}, {title} {body} {space}".format(
|
return "{md} {date}, {title} {body} {space}".format(
|
||||||
md=md_head,
|
md=md_head,
|
||||||
date=date_str,
|
date=date_str,
|
||||||
title=self.title,
|
title=self.title,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
from . import Entry
|
from . import Entry
|
||||||
from . import util
|
from . import util
|
||||||
from . import time
|
from . import time
|
||||||
|
@ -176,7 +176,7 @@ class Journal(object):
|
||||||
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 = u"\n".join([e.__unicode__() for e in self.entries])
|
journal = "\n".join([e.__unicode__() for e in self.entries])
|
||||||
if self.config['encrypt']:
|
if self.config['encrypt']:
|
||||||
journal = self._encrypt(journal)
|
journal = self._encrypt(journal)
|
||||||
with open(filename, 'wb') as journal_file:
|
with open(filename, 'wb') as journal_file:
|
||||||
|
@ -269,7 +269,7 @@ class Journal(object):
|
||||||
def editable_str(self):
|
def editable_str(self):
|
||||||
"""Turns the journal into a string of entries that can be edited
|
"""Turns the journal into a string of entries that can be edited
|
||||||
manually and later be parsed with eslf.parse_editable_str."""
|
manually and later be parsed with eslf.parse_editable_str."""
|
||||||
return u"\n".join([e.__unicode__() for e in self.entries])
|
return "\n".join([e.__unicode__() for e in self.entries])
|
||||||
|
|
||||||
def parse_editable_str(self, edited):
|
def parse_editable_str(self, edited):
|
||||||
"""Parses the output of self.editable_str and updates it's entries."""
|
"""Parses the output of self.editable_str and updates it's entries."""
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
license: MIT, see LICENSE for more details.
|
license: MIT, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
from . import Journal
|
from . import Journal
|
||||||
from . import DayOneJournal
|
from . import DayOneJournal
|
||||||
from . import util
|
from . import util
|
||||||
|
@ -61,7 +61,7 @@ def guess_mode(args, config):
|
||||||
elif any((args.start_date, args.end_date, args.on_date, args.limit, args.strict, args.starred)):
|
elif any((args.start_date, args.end_date, args.on_date, args.limit, args.strict, args.starred)):
|
||||||
# Any sign of displaying stuff?
|
# Any sign of displaying stuff?
|
||||||
compose = False
|
compose = False
|
||||||
elif args.text and all(word[0] in config['tagsymbols'] for word in u" ".join(args.text).split()):
|
elif args.text and all(word[0] in config['tagsymbols'] for word in " ".join(args.text).split()):
|
||||||
# No date and only tags?
|
# No date and only tags?
|
||||||
compose = False
|
compose = False
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ def run(manual_args=None):
|
||||||
"entries" in os.listdir(config['journal']):
|
"entries" in os.listdir(config['journal']):
|
||||||
journal = DayOneJournal.DayOne(**config)
|
journal = DayOneJournal.DayOne(**config)
|
||||||
else:
|
else:
|
||||||
util.prompt(u"[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
|
util.prompt("[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
journal = Journal.Journal(journal_name, **config)
|
journal = Journal.Journal(journal_name, **config)
|
||||||
|
@ -246,7 +246,7 @@ def run(manual_args=None):
|
||||||
|
|
||||||
elif args.edit:
|
elif args.edit:
|
||||||
if not config['editor']:
|
if not config['editor']:
|
||||||
util.prompt(u"[You need to specify an editor in {0} to use the --edit function.]".format(CONFIG_PATH))
|
util.prompt("[You need to specify an editor in {0} to use the --edit function.]".format(CONFIG_PATH))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
other_entries = [e for e in old_entries if e not in journal.entries]
|
other_entries = [e for e in old_entries if e not in journal.entries]
|
||||||
# Edit
|
# Edit
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from .util import u, slugify
|
from .util import u, slugify
|
||||||
|
@ -29,7 +29,7 @@ def to_tag_list(journal):
|
||||||
elif min(tag_counts)[0] == 0:
|
elif min(tag_counts)[0] == 0:
|
||||||
tag_counts = filter(lambda x: x[0] > 1, tag_counts)
|
tag_counts = filter(lambda x: x[0] > 1, tag_counts)
|
||||||
result += '[Removed tags that appear only once.]\n'
|
result += '[Removed tags that appear only once.]\n'
|
||||||
result += "\n".join(u"{0:20} : {1}".format(tag, n) for n, tag in sorted(tag_counts, reverse=True))
|
result += "\n".join("{0:20} : {1}".format(tag, n) for n, tag in sorted(tag_counts, reverse=True))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ def export(journal, format, output=None):
|
||||||
"markdown": to_md
|
"markdown": to_md
|
||||||
}
|
}
|
||||||
if format not in maps:
|
if format not in maps:
|
||||||
return u"[ERROR: can't export to '{0}'. Valid options are 'md', 'txt', and 'json']".format(format)
|
return "[ERROR: can't export to '{0}'. Valid options are 'md', 'txt', and 'json']".format(format)
|
||||||
if output and os.path.isdir(output): # multiple files
|
if output and os.path.isdir(output): # multiple files
|
||||||
return write_files(journal, output, format)
|
return write_files(journal, output, format)
|
||||||
else:
|
else:
|
||||||
|
@ -90,9 +90,9 @@ def export(journal, format, output=None):
|
||||||
try:
|
try:
|
||||||
with codecs.open(output, "w", "utf-8") as f:
|
with codecs.open(output, "w", "utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
return u"[Journal exported to {0}]".format(output)
|
return "[Journal exported to {0}]".format(output)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
return u"[ERROR: {0} {1}]".format(e.filename, e.strerror)
|
return "[ERROR: {0} {1}]".format(e.filename, e.strerror)
|
||||||
else:
|
else:
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
@ -111,4 +111,4 @@ def write_files(journal, path, format):
|
||||||
content = e.__unicode__()
|
content = e.__unicode__()
|
||||||
with codecs.open(full_path, "w", "utf-8") as f:
|
with codecs.open(full_path, "w", "utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
return u"[Journal exported individual files in {0}]".format(path)
|
return "[Journal exported individual files in {0}]".format(path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue