diff --git a/LICENSE b/LICENSE index dc4571c0..58c70313 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Manuel Ebert +Copyright (c) 2014-2018 Manuel Ebert Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/features/environment.py b/features/environment.py index 3e974068..27f1bb6d 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,9 +1,12 @@ from __future__ import absolute_import, unicode_literals -from behave import * -import shutil import os +import shutil + +from behave import * + import jrnl + try: from io import StringIO except ImportError: diff --git a/features/steps/core.py b/features/steps/core.py index f0eb489b..8ca06f6e 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -1,16 +1,19 @@ -from __future__ import unicode_literals -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals -from behave import given, when, then -from jrnl import cli, install, Journal, util, plugins -from jrnl import __version__ -from dateutil import parser as date_parser -from collections import defaultdict -import os -import json -import yaml -import keyring import codecs +from collections import defaultdict +import json +import os +import shlex +import sys + +from behave import given, then, when +from dateutil import parser as date_parser +import keyring +import tzlocal +import yaml + +from jrnl import Journal, __version__, cli, install, plugins, util class TestKeyring(keyring.backend.KeyringBackend): @@ -36,9 +39,6 @@ try: from io import StringIO except ImportError: from cStringIO import StringIO -import tzlocal -import shlex -import sys def ushlex(command): diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index 94dd9b55..3fd0096a 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -2,20 +2,22 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals -from . import Entry -from . import Journal -from . import time as jrnl_time -import os -import re + from datetime import datetime, timedelta -import time import fnmatch +import os import plistlib -import pytz +import re +import time import uuid -import tzlocal from xml.parsers.expat import ExpatError +import pytz +import tzlocal + +from . import Entry, Journal +from . import time as jrnl_time + class DayOne(Journal.Journal): """A special Journal handling DayOne files""" diff --git a/jrnl/EncryptedJournal.py b/jrnl/EncryptedJournal.py index 0e26f1f0..65420743 100644 --- a/jrnl/EncryptedJournal.py +++ b/jrnl/EncryptedJournal.py @@ -1,13 +1,15 @@ from __future__ import absolute_import, unicode_literals -from . import Journal, util +import base64 +import hashlib + from cryptography.fernet import Fernet, InvalidToken +from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes, padding from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes -import hashlib from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC -from cryptography.hazmat.backends import default_backend -import base64 + +from . import Journal, util def make_key(password): diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 12bfb98f..2390bbaf 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -2,9 +2,11 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals + +from datetime import datetime import re import textwrap -from datetime import datetime + from .util import split_title diff --git a/jrnl/Journal.py b/jrnl/Journal.py index c36b3760..63e7b81e 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -2,15 +2,15 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals -from . import Entry -from . import util -from . import time -import os -import sys + import codecs -import re from datetime import datetime import logging +import os +import re +import sys + +from . import Entry, time, util log = logging.getLogger(__name__) diff --git a/jrnl/__main__.py b/jrnl/__main__.py index 73e08b33..17586891 100644 --- a/jrnl/__main__.py +++ b/jrnl/__main__.py @@ -1,8 +1,8 @@ #!/usr/bin/env python # encoding: utf-8 from __future__ import absolute_import, unicode_literals -from . import cli +from . import cli if __name__ == "__main__": cli.run() diff --git a/jrnl/cli.py b/jrnl/cli.py index b2f40285..1a038601 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -7,21 +7,17 @@ license: MIT, see LICENSE for more details. """ -from __future__ import unicode_literals -from __future__ import absolute_import -from . import Journal -from . import util -from . import install -from . import plugins -from .util import ERROR_COLOR, RESET_COLOR -import jrnl +from __future__ import absolute_import, unicode_literals + import argparse -import sys import logging import os -from . import DayOneJournal -from . import EncryptedJournal -from . import Journal +import sys + +import jrnl + +from . import DayOneJournal, EncryptedJournal, Journal, install, plugins, util +from .util import ERROR_COLOR, RESET_COLOR log = logging.getLogger(__name__) logging.getLogger("keyring.backend").setLevel(logging.ERROR) diff --git a/jrnl/export.py b/jrnl/export.py index d4873314..9331d84e 100644 --- a/jrnl/export.py +++ b/jrnl/export.py @@ -2,11 +2,12 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals -from .util import ERROR_COLOR, RESET_COLOR -from .util import slugify, u -from .template import Template -import os + import codecs +import os + +from .template import Template +from .util import ERROR_COLOR, RESET_COLOR, slugify, u class Exporter(object): diff --git a/jrnl/install.py b/jrnl/install.py index 17373661..62156e7c 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -2,18 +2,19 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals -import readline -import glob + import getpass -import os -import xdg.BaseDirectory -from . import util -from . import upgrade -from . import __version__ -from .Journal import PlainJournal -from .EncryptedJournal import EncryptedJournal -import yaml +import glob import logging +import os +import readline + +import xdg.BaseDirectory +import yaml + +from . import __version__, upgrade, util +from .EncryptedJournal import EncryptedJournal +from .Journal import PlainJournal DEFAULT_CONFIG_NAME = 'jrnl.yaml' DEFAULT_JOURNAL_NAME = 'journal.txt' diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py index 64d7b3ba..72ccbcc6 100644 --- a/jrnl/plugins/__init__.py +++ b/jrnl/plugins/__init__.py @@ -3,14 +3,14 @@ from __future__ import absolute_import, unicode_literals -from .text_exporter import TextExporter from .jrnl_importer import JRNLImporter from .json_exporter import JSONExporter from .markdown_exporter import MarkdownExporter from .tag_exporter import TagExporter +from .template_exporter import __all__ as template_exporters +from .text_exporter import TextExporter from .xml_exporter import XMLExporter from .yaml_exporter import YAMLExporter -from .template_exporter import __all__ as template_exporters __exporters =[JSONExporter, MarkdownExporter, TagExporter, TextExporter, XMLExporter, YAMLExporter] + template_exporters __importers =[JRNLImporter] diff --git a/jrnl/plugins/jrnl_importer.py b/jrnl/plugins/jrnl_importer.py index 85615e75..1a231944 100644 --- a/jrnl/plugins/jrnl_importer.py +++ b/jrnl/plugins/jrnl_importer.py @@ -2,10 +2,13 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals + import codecs import sys + from .. import util + class JRNLImporter(object): """This plugin imports entries from other jrnl files.""" names = ["jrnl"] diff --git a/jrnl/plugins/json_exporter.py b/jrnl/plugins/json_exporter.py index 5abaf916..e34b7853 100644 --- a/jrnl/plugins/json_exporter.py +++ b/jrnl/plugins/json_exporter.py @@ -2,8 +2,10 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals -from .text_exporter import TextExporter + import json + +from .text_exporter import TextExporter from .util import get_tags_count diff --git a/jrnl/plugins/markdown_exporter.py b/jrnl/plugins/markdown_exporter.py index 147e8ac5..18837f95 100644 --- a/jrnl/plugins/markdown_exporter.py +++ b/jrnl/plugins/markdown_exporter.py @@ -1,11 +1,13 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import absolute_import, unicode_literals, print_function -from .text_exporter import TextExporter +from __future__ import absolute_import, print_function, unicode_literals + import re import sys -from ..util import WARNING_COLOR, RESET_COLOR + +from ..util import RESET_COLOR, WARNING_COLOR +from .text_exporter import TextExporter class MarkdownExporter(TextExporter): diff --git a/jrnl/plugins/tag_exporter.py b/jrnl/plugins/tag_exporter.py index 439bac7c..cd633141 100644 --- a/jrnl/plugins/tag_exporter.py +++ b/jrnl/plugins/tag_exporter.py @@ -2,6 +2,7 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals + from .text_exporter import TextExporter from .util import get_tags_count diff --git a/jrnl/plugins/template.py b/jrnl/plugins/template.py index bbec852e..73a5fc9e 100644 --- a/jrnl/plugins/template.py +++ b/jrnl/plugins/template.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import re + import asteval import yaml diff --git a/jrnl/plugins/template_exporter.py b/jrnl/plugins/template_exporter.py index 85aa2236..ba8d32dc 100644 --- a/jrnl/plugins/template_exporter.py +++ b/jrnl/plugins/template_exporter.py @@ -3,10 +3,11 @@ from __future__ import absolute_import, unicode_literals -from .text_exporter import TextExporter -from .template import Template -import os from glob import glob +import os + +from .template import Template +from .text_exporter import TextExporter class GenericTemplateExporter(TextExporter): diff --git a/jrnl/plugins/text_exporter.py b/jrnl/plugins/text_exporter.py index dbb54d04..637caccb 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -2,10 +2,11 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals + import codecs -from ..util import u, slugify import os -from ..util import ERROR_COLOR, RESET_COLOR + +from ..util import ERROR_COLOR, RESET_COLOR, slugify, u class TextExporter(object): diff --git a/jrnl/plugins/util.py b/jrnl/plugins/util.py index 817c3a22..8d7f3278 100644 --- a/jrnl/plugins/util.py +++ b/jrnl/plugins/util.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals + def get_tags_count(journal): """Returns a set of tuples (count, tag) for all tags present in the journal.""" # Astute reader: should the following line leave you as puzzled as me the first time diff --git a/jrnl/plugins/xml_exporter.py b/jrnl/plugins/xml_exporter.py index 0af2ed47..f0a051af 100644 --- a/jrnl/plugins/xml_exporter.py +++ b/jrnl/plugins/xml_exporter.py @@ -2,10 +2,12 @@ # encoding: utf-8 from __future__ import absolute_import, unicode_literals + +from xml.dom import minidom + +from ..util import u from .json_exporter import JSONExporter from .util import get_tags_count -from ..util import u -from xml.dom import minidom class XMLExporter(JSONExporter): diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 1442adcc..574e9aad 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -1,11 +1,13 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import absolute_import, unicode_literals, print_function -from .text_exporter import TextExporter +from __future__ import absolute_import, print_function, unicode_literals + import re import sys -from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR + +from ..util import ERROR_COLOR, RESET_COLOR, WARNING_COLOR +from .text_exporter import TextExporter class YAMLExporter(TextExporter): diff --git a/jrnl/time.py b/jrnl/time.py index 3e6be59c..31d7aad0 100644 --- a/jrnl/time.py +++ b/jrnl/time.py @@ -1,6 +1,9 @@ from __future__ import absolute_import, unicode_literals + from datetime import datetime + from dateutil.parser import parse as dateparse + try: import parsedatetime.parsedatetime_consts as pdt except ImportError: diff --git a/jrnl/upgrade.py b/jrnl/upgrade.py index 3784c9f6..1d74635c 100644 --- a/jrnl/upgrade.py +++ b/jrnl/upgrade.py @@ -1,12 +1,11 @@ from __future__ import absolute_import, unicode_literals -from . import __version__ -from . import Journal -from . import util -from .EncryptedJournal import EncryptedJournal -import sys -import os import codecs +import os +import sys + +from . import Journal, __version__, util +from .EncryptedJournal import EncryptedJournal def backup(filename, binary=False): diff --git a/jrnl/util.py b/jrnl/util.py index 09c1048b..0e02434d 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -1,24 +1,25 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import unicode_literals -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals -import sys -import os +import codecs import getpass as gp +import logging +import os +import re +import shlex +import subprocess +import sys +import tempfile +import unicodedata + +from six import string_types import yaml + if "win32" in sys.platform: import colorama colorama.init() -import re -import tempfile -import subprocess -import codecs -import unicodedata -import shlex -import logging -from six import string_types log = logging.getLogger(__name__) diff --git a/setup.py b/setup.py index 49312a0b..5eda386a 100644 --- a/setup.py +++ b/setup.py @@ -37,13 +37,15 @@ Links """ +import os +import re +import sys + try: from setuptools import setup except ImportError: from distutils.core import setup -import os -import sys -import re + try: import readline # NOQA readline_available = True