diff options
author | Jonathan Wren <jonathan@nowandwren.com> | 2022-06-25 14:43:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-25 14:43:32 -0700 |
commit | 0f2962a95f5eb580e1c0efe509799b4eaabea973 (patch) | |
tree | 6fd65957c73dec0d6225bb5ffed819d7cc7f57e3 | |
parent | 20254f7434d6821329646683ead7772f024b272e (diff) |
Add and run `isort` on Python files (#1520)
* add and run isort
* udpate more import statements
* fix typo
44 files changed, 220 insertions, 200 deletions
diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index 8034e36b..27ffef6d 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -4,22 +4,22 @@ import datetime import fnmatch import os -from pathlib import Path import platform import plistlib import re import socket import time import uuid +from pathlib import Path from xml.parsers.expat import ExpatError import pytz import tzlocal -from . import Entry -from . import Journal -from . import __title__ -from . import __version__ +from jrnl import Entry +from jrnl import Journal +from jrnl import __title__ +from jrnl import __version__ class DayOne(Journal.Journal): diff --git a/jrnl/EncryptedJournal.py b/jrnl/EncryptedJournal.py index e2aec8ed..fb1bd355 100644 --- a/jrnl/EncryptedJournal.py +++ b/jrnl/EncryptedJournal.py @@ -18,15 +18,14 @@ from cryptography.hazmat.primitives.ciphers import algorithms from cryptography.hazmat.primitives.ciphers import modes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC -from .Journal import Journal -from .Journal import LegacyJournal -from .prompt import create_password - from jrnl.exception import JrnlException +from jrnl.Journal import Journal +from jrnl.Journal import LegacyJournal from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText from jrnl.output import print_msg +from jrnl.prompt import create_password def make_key(password): diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 323eef73..73f26190 100644 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -6,8 +6,8 @@ import re import ansiwrap -from .color import colorize -from .color import highlight_tags_with_background_color +from jrnl.color import colorize +from jrnl.color import highlight_tags_with_background_color class Entry: diff --git a/jrnl/FolderJournal.py b/jrnl/FolderJournal.py index b5cf2e71..9362e269 100644 --- a/jrnl/FolderJournal.py +++ b/jrnl/FolderJournal.py @@ -5,8 +5,8 @@ import codecs import fnmatch import os -from . import Journal -from . import time +from jrnl import Journal +from jrnl import time def get_files(journal_config): diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 301bba76..d389963b 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -6,15 +6,14 @@ import logging import os import re -from . import Entry -from . import time -from .prompt import yesno -from .path import expand_path - -from jrnl.output import print_msg +from jrnl import Entry +from jrnl import time from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.output import print_msg +from jrnl.path import expand_path +from jrnl.prompt import yesno class Tag: @@ -449,11 +448,11 @@ def open_journal(journal_name, config, legacy=False): if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir( config["journal"] ): - from . import DayOneJournal + from jrnl import DayOneJournal return DayOneJournal.DayOne(**config).open() else: - from . import FolderJournal + from jrnl import FolderJournal return FolderJournal.Folder(journal_name, **config).open() @@ -461,12 +460,12 @@ def open_journal(journal_name, config, legacy=False): if legacy: return LegacyJournal(journal_name, **config).open() if config["journal"].endswith(os.sep): - from . import FolderJournal + from jrnl import FolderJournal return FolderJournal.Folder(journal_name, **config).open() return PlainJournal(journal_name, **config).open() - from . import EncryptedJournal + from jrnl import EncryptedJournal if legacy: return EncryptedJournal.LegacyEncryptedJournal(journal_name, **config).open() diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 2fc7e3bf..1328df2a 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -2,7 +2,7 @@ # License: https://www.gnu.org/licenses/gpl-3.0.html try: - from .__version__ import __version__ + from jrnl.__version__ import __version__ except ImportError: __version__ = "source" __title__ = "jrnl" diff --git a/jrnl/__main__.py b/jrnl/__main__.py index 06ffedaa..8017142e 100644 --- a/jrnl/__main__.py +++ b/jrnl/__main__.py @@ -3,7 +3,7 @@ import sys -from .cli import cli +from jrnl.cli import cli if __name__ == "__main__": sys.exit(cli()) diff --git a/jrnl/args.py b/jrnl/args.py index 5fd8e370..ed33325b 100644 --- a/jrnl/args.py +++ b/jrnl/args.py @@ -5,16 +5,16 @@ import argparse import re import textwrap -from .commands import postconfig_decrypt -from .commands import postconfig_encrypt -from .commands import postconfig_import -from .commands import postconfig_list -from .commands import preconfig_diagnostic -from .commands import preconfig_version -from .output import deprecated_cmd -from .plugins import EXPORT_FORMATS -from .plugins import IMPORT_FORMATS -from .plugins import util +from jrnl.commands import postconfig_decrypt +from jrnl.commands import postconfig_encrypt +from jrnl.commands import postconfig_import +from jrnl.commands import postconfig_list +from jrnl.commands import preconfig_diagnostic +from jrnl.commands import preconfig_version +from jrnl.output import deprecated_cmd +from jrnl.plugins import EXPORT_FORMATS +from jrnl.plugins import IMPORT_FORMATS +from jrnl.plugins import util class WrappingFormatter(argparse.RawTextHelpFormatter): diff --git a/jrnl/cli.py b/jrnl/cli.py index e81fb1ce..5941e02c 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -5,14 +5,13 @@ import logging import sys import traceback -from .jrnl import run -from .args import parse_args -from jrnl.output import print_msg - +from jrnl.args import parse_args from jrnl.exception import JrnlException +from jrnl.jrnl import run from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.output import print_msg def configure_logger(debug=False): diff --git a/jrnl/color.py b/jrnl/color.py index 7268d773..1970f487 100644 --- a/jrnl/color.py +++ b/jrnl/color.py @@ -7,7 +7,7 @@ from string import whitespace import colorama -from .os_compat import on_windows +from jrnl.os_compat import on_windows if on_windows(): colorama.init() diff --git a/jrnl/commands.py b/jrnl/commands.py index dd2ce52b..b03bbf60 100644 --- a/jrnl/commands.py +++ b/jrnl/commands.py @@ -17,11 +17,11 @@ avoid any possible overhead for these standalone commands. import platform import sys -from jrnl.output import print_msg from jrnl.exception import JrnlException from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.output import print_msg from jrnl.prompt import create_password @@ -50,14 +50,14 @@ conditions; for details, see: https://www.gnu.org/licenses/gpl-3.0.html""" def postconfig_list(config, **kwargs): - from .output import list_journals + from jrnl.output import list_journals print(list_journals(config)) def postconfig_import(args, config, **kwargs): - from .Journal import open_journal - from .plugins import get_importer + from jrnl.Journal import open_journal + from jrnl.plugins import get_importer # Requires opening the journal journal = open_journal(args.journal_name, config) @@ -70,10 +70,10 @@ def postconfig_encrypt(args, config, original_config, **kwargs): """ Encrypt a journal in place, or optionally to a new file """ - from .EncryptedJournal import EncryptedJournal - from .Journal import open_journal - from .config import update_config - from .install import save_config + from jrnl.config import update_config + from jrnl.EncryptedJournal import EncryptedJournal + from jrnl.install import save_config + from jrnl.Journal import open_journal # Open the journal journal = open_journal(args.journal_name, config) @@ -118,10 +118,10 @@ def postconfig_encrypt(args, config, original_config, **kwargs): def postconfig_decrypt(args, config, original_config, **kwargs): """Decrypts into new file. If filename is not set, we encrypt the journal file itself.""" - from .Journal import PlainJournal - from .Journal import open_journal - from .config import update_config - from .install import save_config + from jrnl.config import update_config + from jrnl.install import save_config + from jrnl.Journal import PlainJournal + from jrnl.Journal import open_journal journal = open_journal(args.journal_name, config) journal.config["encrypt"] = False diff --git a/jrnl/config.py b/jrnl/config.py index 40746d3e..045958c1 100644 --- a/jrnl/config.py +++ b/jrnl/config.py @@ -5,18 +5,17 @@ import logging import os import colorama -from ruamel.yaml import YAML import xdg.BaseDirectory +from ruamel.yaml import YAML -from . import __version__ -from jrnl.output import list_journals -from jrnl.output import print_msg +from jrnl import __version__ from jrnl.exception import JrnlException from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle - -from .path import home_dir +from jrnl.messages import MsgText +from jrnl.output import list_journals +from jrnl.output import print_msg +from jrnl.path import home_dir # Constants DEFAULT_CONFIG_NAME = "jrnl.yaml" diff --git a/jrnl/editor.py b/jrnl/editor.py index 1090f5d6..f5be8395 100644 --- a/jrnl/editor.py +++ b/jrnl/editor.py @@ -8,14 +8,13 @@ import sys import tempfile from pathlib import Path -from jrnl.os_compat import on_windows -from jrnl.os_compat import split_args -from jrnl.output import print_msg - from jrnl.exception import JrnlException from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.os_compat import on_windows +from jrnl.os_compat import split_args +from jrnl.output import print_msg def get_text_from_editor(config, template=""): diff --git a/jrnl/install.py b/jrnl/install.py index a7dc6318..d0ae4ac7 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -6,24 +6,23 @@ import logging import os import sys -from .path import home_dir -from .path import absolute_path -from .path import expand_path -from .config import DEFAULT_JOURNAL_KEY -from .config import get_config_path -from .config import get_default_config -from .config import get_default_journal_path -from .config import load_config -from .config import save_config -from .config import verify_config_colors -from .prompt import yesno -from .upgrade import is_old_version - -from jrnl.output import print_msg +from jrnl.config import DEFAULT_JOURNAL_KEY +from jrnl.config import get_config_path +from jrnl.config import get_default_config +from jrnl.config import get_default_journal_path +from jrnl.config import load_config +from jrnl.config import save_config +from jrnl.config import verify_config_colors from jrnl.exception import JrnlException from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.output import print_msg +from jrnl.path import absolute_path +from jrnl.path import expand_path +from jrnl.path import home_dir +from jrnl.prompt import yesno +from jrnl.upgrade import is_old_version def upgrade_config(config_data, alt_config_path=None): diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 68b061b2..b8f924bd 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -4,24 +4,23 @@ import logging import sys -from . import install -from . import plugins -from .Journal import open_journal -from .config import get_journal_name -from .config import scope_config -from .config import get_config_path -from .editor import get_text_from_editor -from .editor import get_text_from_stdin -from . import time -from .override import apply_overrides -from jrnl.output import print_msg -from jrnl.output import print_msgs -from .path import expand_path - +from jrnl import install +from jrnl import plugins +from jrnl import time +from jrnl.config import get_config_path +from jrnl.config import get_journal_name +from jrnl.config import scope_config +from jrnl.editor import get_text_from_editor +from jrnl.editor import get_text_from_stdin from jrnl.exception import JrnlException +from jrnl.Journal import open_journal from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.output import print_msg +from jrnl.output import print_msgs +from jrnl.override import apply_overrides +from jrnl.path import expand_path def run(args): diff --git a/jrnl/messages/Message.py b/jrnl/messages/Message.py index 86809192..3008db3b 100644 --- a/jrnl/messages/Message.py +++ b/jrnl/messages/Message.py @@ -1,11 +1,11 @@ # Copyright (C) 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -from typing import NamedTuple from typing import Mapping +from typing import NamedTuple -from .MsgText import MsgText -from .MsgStyle import MsgStyle +from jrnl.messages.MsgStyle import MsgStyle +from jrnl.messages.MsgText import MsgText class Message(NamedTuple): diff --git a/jrnl/messages/MsgStyle.py b/jrnl/messages/MsgStyle.py index b8e15316..c4a001d1 100644 --- a/jrnl/messages/MsgStyle.py +++ b/jrnl/messages/MsgStyle.py @@ -2,12 +2,13 @@ # License: https://www.gnu.org/licenses/gpl-3.0.html from enum import Enum -from typing import NamedTuple from typing import Callable -from rich.panel import Panel +from typing import NamedTuple + from rich import box +from rich.panel import Panel -from .MsgText import MsgText +from jrnl.messages.MsgText import MsgText class MsgStyle(Enum): diff --git a/jrnl/messages/__init__.py b/jrnl/messages/__init__.py index f2eaec4c..c452f08f 100644 --- a/jrnl/messages/__init__.py +++ b/jrnl/messages/__init__.py @@ -1,9 +1,9 @@ # Copyright (C) 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -from .Message import Message -from .MsgStyle import MsgStyle -from .MsgText import MsgText +from jrnl.messages.Message import Message +from jrnl.messages.MsgStyle import MsgStyle +from jrnl.messages.MsgText import MsgText Message = Message MsgStyle = MsgStyle diff --git a/jrnl/output.py b/jrnl/output.py index 3eae32cc..78a1da24 100644 --- a/jrnl/output.py +++ b/jrnl/output.py @@ -2,10 +2,10 @@ # License: https://www.gnu.org/licenses/gpl-3.0.html import textwrap - from typing import Union -from rich.text import Text + from rich.console import Console +from rich.text import Text from jrnl.messages import Message from jrnl.messages import MsgStyle @@ -26,7 +26,7 @@ def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs): def list_journals(configuration): - from . import config + from jrnl import config """List the journals specified in the configuration file""" result = f"Journals defined in config ({config.get_config_path()})\n" diff --git a/jrnl/override.py b/jrnl/override.py index 6ef378f4..7244fb8f 100644 --- a/jrnl/override.py +++ b/jrnl/override.py @@ -1,9 +1,12 @@ # Copyright (C) 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -from .config import update_config, make_yaml_valid_dict from argparse import Namespace +from jrnl.config import make_yaml_valid_dict +from jrnl.config import update_config + + # import logging def apply_overrides(args: Namespace, base_config: dict) -> dict: """Unpack CLI provided overrides into the configuration tree. diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py index f994e4fc..015725b2 100644 --- a/jrnl/plugins/__init__.py +++ b/jrnl/plugins/__init__.py @@ -1,15 +1,15 @@ # Copyright (C) 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -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 .dates_exporter import DatesExporter -from .text_exporter import TextExporter -from .xml_exporter import XMLExporter -from .yaml_exporter import YAMLExporter +from jrnl.plugins.dates_exporter import DatesExporter +from jrnl.plugins.fancy_exporter import FancyExporter +from jrnl.plugins.jrnl_importer import JRNLImporter +from jrnl.plugins.json_exporter import JSONExporter +from jrnl.plugins.markdown_exporter import MarkdownExporter +from jrnl.plugins.tag_exporter import TagExporter +from jrnl.plugins.text_exporter import TextExporter +from jrnl.plugins.xml_exporter import XMLExporter +from jrnl.plugins.yaml_exporter import YAMLExporter __exporters = [ JSONExporter, diff --git a/jrnl/plugins/dates_exporter.py b/jrnl/plugins/dates_exporter.py index c1c8fd0a..a5a7054f 100644 --- a/jrnl/plugins/dates_exporter.py +++ b/jrnl/plugins/dates_exporter.py @@ -3,7 +3,7 @@ from collections import Counter -from .text_exporter import TextExporter +from jrnl.plugins.text_exporter import TextExporter class DatesExporter(TextExporter): diff --git a/jrnl/plugins/fancy_exporter.py b/jrnl/plugins/fancy_exporter.py index cdbd4b08..b9567bfd 100644 --- a/jrnl/plugins/fancy_exporter.py +++ b/jrnl/plugins/fancy_exporter.py @@ -1,13 +1,13 @@ # Copyright (C) 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html +from textwrap import TextWrapper + from jrnl.exception import JrnlException from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle -from textwrap import TextWrapper - -from .text_exporter import TextExporter +from jrnl.messages import MsgText +from jrnl.plugins.text_exporter import TextExporter class FancyExporter(TextExporter): diff --git a/jrnl/plugins/jrnl_importer.py b/jrnl/plugins/jrnl_importer.py index 0468b476..813702d8 100644 --- a/jrnl/plugins/jrnl_importer.py +++ b/jrnl/plugins/jrnl_importer.py @@ -5,8 +5,8 @@ import sys from jrnl.exception import JrnlException from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText from jrnl.output import print_msg diff --git a/jrnl/plugins/json_exporter.py b/jrnl/plugins/json_exporter.py index abce6f50..6aa23434 100644 --- a/jrnl/plugins/json_exporter.py +++ b/jrnl/plugins/json_exporter.py @@ -3,8 +3,8 @@ import json -from .text_exporter import TextExporter -from .util import get_tags_count +from jrnl.plugins.text_exporter import TextExporter +from jrnl.plugins.util import get_tags_count class JSONExporter(TextExporter): diff --git a/jrnl/plugins/markdown_exporter.py b/jrnl/plugins/markdown_exporter.py index 30614746..29e07bc1 100644 --- a/jrnl/plugins/markdown_exporter.py +++ b/jrnl/plugins/markdown_exporter.py @@ -4,12 +4,11 @@ import os import re -from .text_exporter import TextExporter - -from jrnl.output import print_msg from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.output import print_msg +from jrnl.plugins.text_exporter import TextExporter class MarkdownExporter(TextExporter): diff --git a/jrnl/plugins/tag_exporter.py b/jrnl/plugins/tag_exporter.py index 9c2b7fb5..35b25fdd 100644 --- a/jrnl/plugins/tag_exporter.py +++ b/jrnl/plugins/tag_exporter.py @@ -1,8 +1,8 @@ # Copyright (C) 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -from .text_exporter import TextExporter -from .util import get_tags_count +from jrnl.plugins.text_exporter import TextExporter +from jrnl.plugins.util import get_tags_count class TagExporter(TextExporter): diff --git a/jrnl/plugins/text_exporter.py b/jrnl/plugins/text_exporter.py index 55c0d83a..cfd4a8ec 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -5,10 +5,10 @@ import os import re import unicodedata -from jrnl.output import print_msg from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle +from jrnl.messages import MsgText +from jrnl.output import print_msg class TextExporter: diff --git a/jrnl/plugins/xml_exporter.py b/jrnl/plugins/xml_exporter.py index 10050b50..02c8398a 100644 --- a/jrnl/plugins/xml_exporter.py +++ b/jrnl/plugins/xml_exporter.py @@ -3,8 +3,8 @@ from xml.dom import minidom -from .json_exporter import JSONExporter -from .util import get_tags_count +from jrnl.plugins.json_exporter import JSONExporter +from jrnl.plugins.util import get_tags_count class XMLExporter(JSONExporter): diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 00a4613b..a9ff958b 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -4,13 +4,12 @@ import os import re -from .text_exporter import TextExporter - from jrnl.exception import JrnlException from jrnl.messages import Message -from jrnl.messages import MsgText from jrnl.messages import MsgStyle |