diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index d5649eb3..75336560 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from . import Entry from . import Journal import os @@ -75,7 +75,7 @@ class DayOne(Journal.Journal): def editable_str(self): """Turns the journal into a string of entries that can be edited 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): """Parses the output of self.editable_str and updates it's entries.""" diff --git a/jrnl/Entry.py b/jrnl/Entry.py index fa2650ca..66b32f6c 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 +from __future__ import unicode_literals import re import textwrap from datetime import datetime @@ -34,7 +35,7 @@ class Entry: title = date_str + " " + self.title.rstrip("\n ") if self.starred: title += " *" - return u"{title}{sep}{body}\n".format( + return "{title}{sep}{body}\n".format( title=title, sep="\n" if self.body.rstrip("\n ") else "", body=self.body.rstrip("\n ") @@ -64,7 +65,7 @@ class Entry: if short: return title else: - return u"{title}{sep}{body}\n".format( + return "{title}{sep}{body}\n".format( title=title, sep="\n" if has_body else "", body=body if has_body else "", @@ -101,7 +102,7 @@ class Entry: space = "\n" md_head = "###" - return u"{md} {date}, {title} {body} {space}".format( + return "{md} {date}, {title} {body} {space}".format( md=md_head, date=date_str, title=self.title, diff --git a/jrnl/Journal.py b/jrnl/Journal.py index b94a5d36..92a6774f 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from . import Entry from . import util from . import time @@ -176,7 +176,7 @@ class Journal(object): def write(self, filename=None): """Dumps the journal into the config file, overwriting it""" 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']: journal = self._encrypt(journal) with open(filename, 'wb') as journal_file: @@ -269,7 +269,7 @@ class Journal(object): def editable_str(self): """Turns the journal into a string of entries that can be edited 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): """Parses the output of self.editable_str and updates it's entries.""" diff --git a/jrnl/cli.py b/jrnl/cli.py index 47aa09d7..fe105e89 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -7,7 +7,7 @@ license: MIT, see LICENSE for more details. """ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from . import Journal from . import DayOneJournal 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)): # Any sign of displaying stuff? 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? compose = False @@ -189,7 +189,7 @@ def run(manual_args=None): "entries" in os.listdir(config['journal']): journal = DayOneJournal.DayOne(**config) 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) else: journal = Journal.Journal(journal_name, **config) @@ -246,7 +246,7 @@ def run(manual_args=None): elif args.edit: 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) other_entries = [e for e in old_entries if e not in journal.entries] # Edit diff --git a/jrnl/exporters.py b/jrnl/exporters.py index 71919f34..ad2c3186 100644 --- a/jrnl/exporters.py +++ b/jrnl/exporters.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import json from .util import u, slugify @@ -29,7 +29,7 @@ def to_tag_list(journal): elif min(tag_counts)[0] == 0: tag_counts = filter(lambda x: x[0] > 1, tag_counts) 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 @@ -81,7 +81,7 @@ def export(journal, format, output=None): "markdown": to_md } 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 return write_files(journal, output, format) else: @@ -90,9 +90,9 @@ def export(journal, format, output=None): try: with codecs.open(output, "w", "utf-8") as f: f.write(content) - return u"[Journal exported to {0}]".format(output) + return "[Journal exported to {0}]".format(output) except IOError as e: - return u"[ERROR: {0} {1}]".format(e.filename, e.strerror) + return "[ERROR: {0} {1}]".format(e.filename, e.strerror) else: return content @@ -111,4 +111,4 @@ def write_files(journal, path, format): content = e.__unicode__() with codecs.open(full_path, "w", "utf-8") as f: f.write(content) - return u"[Journal exported individual files in {0}]".format(path) + return "[Journal exported individual files in {0}]".format(path)