diff --git a/jrnl/Journal.py b/jrnl/Journal.py index d7c74431..d389963b 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -448,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() @@ -460,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/commands.py b/jrnl/commands.py index 726b8a92..c483861c 100644 --- a/jrnl/commands.py +++ b/jrnl/commands.py @@ -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 .config import update_config - from .EncryptedJournal import EncryptedJournal - from .install import save_config - from .Journal import open_journal + from jrnl.config import update_config + from jrnl.EncryptedJournal import EncryptedJournal + from jrnl.install import save_config + from jrnl.Journal import jrnlopen_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 .config import update_config - from .install import save_config - from .Journal import PlainJournal - from .Journal import open_journal + 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/messages/Message.py b/jrnl/messages/Message.py index e8abe2f9..3008db3b 100644 --- a/jrnl/messages/Message.py +++ b/jrnl/messages/Message.py @@ -4,8 +4,8 @@ from typing import Mapping from typing import NamedTuple -from .MsgStyle import MsgStyle -from .MsgText import MsgText +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 577149b2..c4a001d1 100644 --- a/jrnl/messages/MsgStyle.py +++ b/jrnl/messages/MsgStyle.py @@ -8,7 +8,7 @@ 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 4d918667..78a1da24 100644 --- a/jrnl/output.py +++ b/jrnl/output.py @@ -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/plugins/__init__.py b/jrnl/plugins/__init__.py index 12d81bcc..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 .dates_exporter import DatesExporter -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 .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 89fea09a..b9567bfd 100644 --- a/jrnl/plugins/fancy_exporter.py +++ b/jrnl/plugins/fancy_exporter.py @@ -7,8 +7,7 @@ from jrnl.exception import JrnlException from jrnl.messages import Message from jrnl.messages import MsgStyle from jrnl.messages import MsgText - -from .text_exporter import TextExporter +from jrnl.plugins.text_exporter import TextExporter class FancyExporter(TextExporter): 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 aac569f3..29e07bc1 100644 --- a/jrnl/plugins/markdown_exporter.py +++ b/jrnl/plugins/markdown_exporter.py @@ -8,8 +8,7 @@ from jrnl.messages import Message from jrnl.messages import MsgStyle from jrnl.messages import MsgText from jrnl.output import print_msg - -from .text_exporter import TextExporter +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/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 5dd8d4eb..a9ff958b 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -9,8 +9,7 @@ from jrnl.messages import Message from jrnl.messages import MsgStyle from jrnl.messages import MsgText from jrnl.output import print_msg - -from .text_exporter import TextExporter +from jrnl.plugins.text_exporter import TextExporter class YAMLExporter(TextExporter): diff --git a/jrnl/prompt.py b/jrnl/prompt.py index 77350a9c..803a5214 100644 --- a/jrnl/prompt.py +++ b/jrnl/prompt.py @@ -35,7 +35,7 @@ def create_password(journal_name: str) -> str: print_msg(Message(MsgText.PasswordDidNotMatch, MsgStyle.ERROR)) if yesno(Message(MsgText.PasswordStoreInKeychain), default=True): - from .EncryptedJournal import set_keychain + from jrnl.EncryptedJournal import set_keychain set_keychain(journal_name, pw) diff --git a/pyproject.toml b/pyproject.toml index 14c11e99..d93ceae0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,7 +111,7 @@ test = [ [tool.isort] profile = "black" force_single_line = true -known_first_party = ["jrnl"] +known_first_party = ["jrnl", "tests"] [tool.pytest.ini_options] minversion = "6.0" diff --git a/tests/lib/then_steps.py b/tests/lib/then_steps.py index 7102019a..4efde7a5 100644 --- a/tests/lib/then_steps.py +++ b/tests/lib/then_steps.py @@ -11,11 +11,10 @@ from pytest_bdd.parsers import parse from ruamel.yaml import YAML from jrnl.config import scope_config - -from .helpers import assert_equal_tags_ignoring_order -from .helpers import does_directory_contain_files -from .helpers import get_nested_val -from .helpers import parse_should_or_should_not +from tests.lib.helpers import assert_equal_tags_ignoring_order +from tests.lib.helpers import does_directory_contain_files +from tests.lib.helpers import get_nested_val +from tests.lib.helpers import parse_should_or_should_not @then("we should get no error")