From 1062c7499fd28429a94343203cb8eff115d15b56 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 11 Apr 2020 12:24:26 -0600 Subject: [PATCH] Apply isort! --- features/environment.py | 2 +- features/steps/core.py | 28 ++++++++++++++-------------- features/steps/export_steps.py | 2 +- jrnl/DayOneJournal.py | 17 +++++++++-------- jrnl/EncryptedJournal.py | 21 +++++++++++---------- jrnl/Entry.py | 8 +++++--- jrnl/FolderJournal.py | 6 +++--- jrnl/Journal.py | 6 +++--- jrnl/__main__.py | 1 - jrnl/cli.py | 18 +++++++++--------- jrnl/install.py | 20 ++++++++++---------- jrnl/plugins/__init__.py | 6 +++--- jrnl/plugins/fancy_exporter.py | 3 ++- jrnl/plugins/jrnl_importer.py | 1 + jrnl/plugins/json_exporter.py | 3 ++- jrnl/plugins/markdown_exporter.py | 5 +++-- jrnl/plugins/template.py | 1 + jrnl/plugins/template_exporter.py | 7 ++++--- jrnl/plugins/text_exporter.py | 4 ++-- jrnl/plugins/xml_exporter.py | 3 ++- jrnl/plugins/yaml_exporter.py | 5 +++-- jrnl/time.py | 1 + jrnl/upgrade.py | 6 ++---- jrnl/util.py | 23 ++++++++++++----------- 24 files changed, 104 insertions(+), 93 deletions(-) diff --git a/features/environment.py b/features/environment.py index 02f2747e..eb30bc58 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 36b6573a..0c8d0271 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -1,24 +1,24 @@ +import ast +from codecs import decode, encode +from collections import defaultdict +import json +import os +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 +from behave import given, then, when +import keyring +import tzlocal +import yaml + +from jrnl import Journal, __version__, cli, install, plugins, util try: import parsedatetime.parsedatetime_consts as pdt except ImportError: import parsedatetime as pdt -import time -from codecs import encode, decode -import os -import ast -import json -import yaml -import keyring -import tzlocal -import shlex -import sys 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 b7965ab8..1c89740b 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 8e8b2cd0..505c0549 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -1,19 +1,20 @@ #!/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 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 cc5af748..9e6fa47f 100644 --- a/jrnl/EncryptedJournal.py +++ b/jrnl/EncryptedJournal.py @@ -1,17 +1,18 @@ -from . import util -from .Journal import Journal, LegacyJournal -from cryptography.fernet import Fernet, InvalidToken -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 hashlib import logging +import os +import sys from typing import Optional +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 +from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC + +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 098407d9..14288311 100644 --- a/jrnl/FolderJournal.py +++ b/jrnl/FolderJournal.py @@ -1,11 +1,11 @@ #!/usr/bin/env python # encoding: utf-8 -from . import Entry -from . import Journal import codecs -import os import fnmatch +import os + +from . import Entry, Journal def get_files(journal_config): diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 64b245ff..4c939047 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 3f331217..8ca19713 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -6,17 +6,17 @@ license: MIT, see LICENSE for more details. """ -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 d8b3255f..5070e018 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -1,19 +1,19 @@ #!/usr/bin/env python -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 -from .util import UserAbort, verify_config -import yaml +import glob import logging +import os import sys +import xdg.BaseDirectory +import yaml + +from . import __version__, upgrade, util +from .EncryptedJournal import EncryptedJournal +from .Journal import PlainJournal +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 beae33e5..7e3358d5 100644 --- a/jrnl/plugins/fancy_exporter.py +++ b/jrnl/plugins/fancy_exporter.py @@ -1,9 +1,10 @@ #!/usr/bin/env python # encoding: utf-8 -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/jrnl_importer.py b/jrnl/plugins/jrnl_importer.py index 972114d4..698ebbe3 100644 --- a/jrnl/plugins/jrnl_importer.py +++ b/jrnl/plugins/jrnl_importer.py @@ -2,6 +2,7 @@ # encoding: utf-8 import sys + from .. import util 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 14060ce9..7d5eacaf 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 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 ccb02442..8a3f4eb3 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 430b68f7..7606c8bc 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__)