diff --git a/features/environment.py b/features/environment.py index a75bba4d..0032cf13 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,5 +1,5 @@ -import shutil import os +import shutil import sys diff --git a/features/steps/core.py b/features/steps/core.py index 30e0e101..b2e9e6a1 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -1,23 +1,23 @@ +import ast +from collections import defaultdict +import os +from pathlib import Path +import shlex +import sys +import time from unittest.mock import patch -from behave import given, when, then -from jrnl import cli, install, Journal, util, plugins -from jrnl import __version__ -from collections import defaultdict +import keyring +import toml +import yaml + +from behave import given, then, when +from jrnl import Journal, __version__, cli, install, plugins, util try: import parsedatetime.parsedatetime_consts as pdt except ImportError: import parsedatetime as pdt -import time -import os -import ast -import yaml -import keyring -import shlex -import sys -from pathlib import Path -import toml consts = pdt.Constants(usePyICU=False) consts.DOWParseStyle = -1 # Prefers past weekdays diff --git a/features/steps/export_steps.py b/features/steps/export_steps.py index c75cf331..0aa180fd 100644 --- a/features/steps/export_steps.py +++ b/features/steps/export_steps.py @@ -3,7 +3,7 @@ import os import shutil from xml.etree import ElementTree -from behave import then, given +from behave import given, then @then("the output should be parsable as json") diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index af82333c..1ee44b97 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -1,20 +1,21 @@ #!/usr/bin/env python -from . import Entry -from . import Journal -from . import time as jrnl_time -import os -import re from datetime import datetime -import time import fnmatch +import os from pathlib import Path 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 66693c7e..2a6df460 100644 --- a/jrnl/EncryptedJournal.py +++ b/jrnl/EncryptedJournal.py @@ -1,16 +1,17 @@ -from . import util -from .Journal import Journal, LegacyJournal +import base64 +import hashlib +import logging +import os +import sys + 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 sys -import os -import base64 -import logging +from . import util +from .Journal import Journal, LegacyJournal log = logging.getLogger() diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 02f7c468..1197e2f8 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -1,9 +1,11 @@ #!/usr/bin/env python -import re -import ansiwrap from datetime import datetime -from .util import split_title, colorize, highlight_tags_with_background_color +import re + +import ansiwrap + +from .util import colorize, highlight_tags_with_background_color, split_title class Entry: diff --git a/jrnl/FolderJournal.py b/jrnl/FolderJournal.py index dcf4cfd0..9a6ea3c0 100644 --- a/jrnl/FolderJournal.py +++ b/jrnl/FolderJournal.py @@ -1,11 +1,11 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import absolute_import, unicode_literals -from . import Journal import codecs -import os import fnmatch +import os + +from . import Journal def get_files(journal_config): diff --git a/jrnl/Journal.py b/jrnl/Journal.py index c5503392..23fa80a0 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -1,12 +1,12 @@ #!/usr/bin/env python +from datetime import datetime import logging import os -import sys import re +import sys -from datetime import datetime -from jrnl import Entry, util, time +from jrnl import Entry, time, util log = logging.getLogger(__name__) diff --git a/jrnl/__main__.py b/jrnl/__main__.py index 3ce86730..2b46147a 100644 --- a/jrnl/__main__.py +++ b/jrnl/__main__.py @@ -1,6 +1,5 @@ #!/usr/bin/env python from . import cli - if __name__ == "__main__": cli.run() diff --git a/jrnl/cli.py b/jrnl/cli.py index 2426e17c..070d134b 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -19,17 +19,17 @@ along with this program. If not, see . """ -from .Journal import PlainJournal, open_journal -from .EncryptedJournal import EncryptedJournal -from . import util -from . import install -from . import plugins -from .util import ERROR_COLOR, RESET_COLOR, UserAbort -import jrnl import argparse -import sys -import re import logging +import re +import sys + +import jrnl + +from . import install, plugins, util +from .EncryptedJournal import EncryptedJournal +from .Journal import PlainJournal, open_journal +from .util import ERROR_COLOR, RESET_COLOR, UserAbort log = logging.getLogger(__name__) logging.getLogger("keyring.backend").setLevel(logging.ERROR) diff --git a/jrnl/install.py b/jrnl/install.py index f95ce9f7..7844d3e2 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -1,16 +1,16 @@ #!/usr/bin/env python import glob -import os -import xdg.BaseDirectory -from . import util -from . import upgrade -from . import __version__ -from .util import UserAbort, verify_config -import yaml import logging +import os import sys +import xdg.BaseDirectory +import yaml + +from . import __version__, upgrade, util +from .util import UserAbort, verify_config + if "win32" not in sys.platform: # readline is not included in Windows Active Python import readline diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py index 00ee2498..9fcafca2 100644 --- a/jrnl/plugins/__init__.py +++ b/jrnl/plugins/__init__.py @@ -1,15 +1,15 @@ #!/usr/bin/env python # encoding: utf-8 -from .text_exporter import TextExporter +from .fancy_exporter import FancyExporter 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 -from .fancy_exporter import FancyExporter __exporters = [ JSONExporter, diff --git a/jrnl/plugins/fancy_exporter.py b/jrnl/plugins/fancy_exporter.py index f7ff491d..7e3358d5 100644 --- a/jrnl/plugins/fancy_exporter.py +++ b/jrnl/plugins/fancy_exporter.py @@ -1,10 +1,10 @@ #!/usr/bin/env python # encoding: utf-8 -from __future__ import absolute_import, unicode_literals, print_function -from .text_exporter import TextExporter from textwrap import TextWrapper +from .text_exporter import TextExporter + class FancyExporter(TextExporter): """This Exporter can convert entries and journals into text with unicode box drawing characters.""" diff --git a/jrnl/plugins/json_exporter.py b/jrnl/plugins/json_exporter.py index 90a2059f..a5c70b97 100644 --- a/jrnl/plugins/json_exporter.py +++ b/jrnl/plugins/json_exporter.py @@ -1,8 +1,9 @@ #!/usr/bin/env python # encoding: utf-8 -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 b1198f2b..65cba0fe 100644 --- a/jrnl/plugins/markdown_exporter.py +++ b/jrnl/plugins/markdown_exporter.py @@ -1,11 +1,12 @@ #!/usr/bin/env python # encoding: utf-8 -from .text_exporter import TextExporter -import re import os +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/template.py b/jrnl/plugins/template.py index c7b72772..d08ae6e8 100644 --- a/jrnl/plugins/template.py +++ b/jrnl/plugins/template.py @@ -1,4 +1,5 @@ import re + import yaml VAR_RE = r"[_a-zA-Z][a-zA-Z0-9_]*" diff --git a/jrnl/plugins/template_exporter.py b/jrnl/plugins/template_exporter.py index eb360f94..f8d704ef 100644 --- a/jrnl/plugins/template_exporter.py +++ b/jrnl/plugins/template_exporter.py @@ -1,10 +1,11 @@ #!/usr/bin/env python # encoding: utf-8 -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 6f2a4531..4fa781ab 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -1,9 +1,9 @@ #!/usr/bin/env python # encoding: utf-8 -from ..util import slugify import os -from ..util import ERROR_COLOR, RESET_COLOR + +from ..util import ERROR_COLOR, RESET_COLOR, slugify class TextExporter: diff --git a/jrnl/plugins/xml_exporter.py b/jrnl/plugins/xml_exporter.py index 07506cf2..065c929b 100644 --- a/jrnl/plugins/xml_exporter.py +++ b/jrnl/plugins/xml_exporter.py @@ -1,9 +1,10 @@ #!/usr/bin/env python # encoding: utf-8 +from xml.dom import minidom + from .json_exporter import JSONExporter from .util import get_tags_count -from xml.dom import minidom class XMLExporter(JSONExporter): diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 4d4ce03d..23fded65 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -1,11 +1,12 @@ #!/usr/bin/env python # encoding: utf-8 -from .text_exporter import TextExporter import os 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 ef6dd4d9..6dc9773e 100644 --- a/jrnl/time.py +++ b/jrnl/time.py @@ -1,4 +1,5 @@ from datetime import datetime + from dateutil.parser import parse as dateparse try: diff --git a/jrnl/upgrade.py b/jrnl/upgrade.py index fe0e0f4b..762970a1 100644 --- a/jrnl/upgrade.py +++ b/jrnl/upgrade.py @@ -1,11 +1,9 @@ +import os import sys -from . import __version__ -from . import Journal -from . import util +from . import Journal, __version__, util from .EncryptedJournal import EncryptedJournal from .util import UserAbort -import os def backup(filename, binary=False): diff --git a/jrnl/util.py b/jrnl/util.py index 154b0b28..0e50065f 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -1,21 +1,22 @@ #!/usr/bin/env python -import sys -import os import getpass as gp -import yaml +import logging +import os +import re +import shlex +from string import punctuation, whitespace +import subprocess +import sys +import tempfile +from typing import Callable, Optional +import unicodedata + import colorama +import yaml if "win32" in sys.platform: colorama.init() -import re -import tempfile -import subprocess -import unicodedata -import shlex -from string import punctuation, whitespace -import logging -from typing import Optional, Callable log = logging.getLogger(__name__) diff --git a/pyproject.toml b/pyproject.toml index 845489c9..094217d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,15 @@ pyflakes = "^2.2.0" [tool.poetry.scripts] jrnl = 'jrnl.cli:run' +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +line_length = 88 +known_first_party = ["jrnl", "behave"] +force_sort_within_sections = true + [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api"