udpate more import statements

This commit is contained in:
Jonathan Wren 2022-06-25 13:43:55 -07:00
parent f8d0467db8
commit 7c5af92eea
19 changed files with 49 additions and 53 deletions

View file

@ -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()

View file

@ -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"

View file

@ -3,7 +3,7 @@
import sys
from .cli import cli
from jrnl.cli import cli
if __name__ == "__main__":
sys.exit(cli())

View file

@ -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

View file

@ -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):

View file

@ -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):

View file

@ -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

View file

@ -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"

View file

@ -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,

View file

@ -3,7 +3,7 @@
from collections import Counter
from .text_exporter import TextExporter
from jrnl.plugins.text_exporter import TextExporter
class DatesExporter(TextExporter):

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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)

View file

@ -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"

View file

@ -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")