mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
clean up import statements
This commit is contained in:
parent
73a348b033
commit
9ccbcdcc7e
23 changed files with 66 additions and 50 deletions
|
@ -3,7 +3,6 @@ import shutil
|
||||||
|
|
||||||
from jrnl.os_compat import on_windows
|
from jrnl.os_compat import on_windows
|
||||||
|
|
||||||
|
|
||||||
CWD = os.getcwd()
|
CWD = os.getcwd()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,18 @@ import shlex
|
||||||
import time
|
import time
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from behave import given
|
||||||
|
from behave import then
|
||||||
|
from behave import when
|
||||||
import keyring
|
import keyring
|
||||||
import toml
|
import toml
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from behave import given, then, when
|
|
||||||
from jrnl import Journal
|
from jrnl import Journal
|
||||||
from jrnl import __version__
|
from jrnl import __version__
|
||||||
from jrnl import cli
|
from jrnl import cli
|
||||||
from jrnl import install
|
from jrnl import install
|
||||||
from jrnl import plugins
|
from jrnl import plugins
|
||||||
|
|
||||||
from jrnl.config import load_config
|
from jrnl.config import load_config
|
||||||
from jrnl.os_compat import on_windows
|
from jrnl.os_compat import on_windows
|
||||||
|
|
||||||
|
@ -398,9 +399,10 @@ def list_journal_directory(context, journal="default"):
|
||||||
|
|
||||||
@then("the Python version warning should appear if our version is below {version}")
|
@then("the Python version warning should appear if our version is below {version}")
|
||||||
def check_python_warning_if_version_low_enough(context, version):
|
def check_python_warning_if_version_low_enough(context, version):
|
||||||
import packaging.version
|
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
|
import packaging.version
|
||||||
|
|
||||||
if packaging.version.parse(platform.python_version()) < packaging.version.parse(
|
if packaging.version.parse(platform.python_version()) < packaging.version.parse(
|
||||||
version
|
version
|
||||||
):
|
):
|
||||||
|
|
|
@ -3,7 +3,8 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
|
|
||||||
from behave import given, then
|
from behave import given
|
||||||
|
from behave import then
|
||||||
|
|
||||||
|
|
||||||
@then("the output should be parsable as json")
|
@then("the output should be parsable as json")
|
||||||
|
|
|
@ -4,18 +4,21 @@ from datetime import datetime
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import platform
|
||||||
import plistlib
|
import plistlib
|
||||||
import re
|
import re
|
||||||
|
import socket
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError
|
||||||
import socket
|
|
||||||
import platform
|
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
import tzlocal
|
import tzlocal
|
||||||
|
|
||||||
from . import __title__, __version__, Entry, Journal
|
from . import Entry
|
||||||
|
from . import Journal
|
||||||
|
from . import __title__
|
||||||
|
from . import __version__
|
||||||
|
|
||||||
|
|
||||||
class DayOne(Journal.Journal):
|
class DayOne(Journal.Journal):
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
import base64
|
import base64
|
||||||
|
import getpass
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Callable, Optional
|
from typing import Callable
|
||||||
import getpass
|
from typing import Optional
|
||||||
|
|
||||||
from cryptography.fernet import Fernet, InvalidToken
|
from cryptography.fernet import Fernet
|
||||||
|
from cryptography.fernet import InvalidToken
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import hashes, padding
|
from cryptography.hazmat.primitives import hashes
|
||||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
from cryptography.hazmat.primitives import padding
|
||||||
|
from cryptography.hazmat.primitives.ciphers import Cipher
|
||||||
|
from cryptography.hazmat.primitives.ciphers import algorithms
|
||||||
|
from cryptography.hazmat.primitives.ciphers import modes
|
||||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
||||||
|
|
||||||
|
from .Journal import Journal
|
||||||
|
from .Journal import LegacyJournal
|
||||||
from .prompt import create_password
|
from .prompt import create_password
|
||||||
from .Journal import Journal, LegacyJournal
|
|
||||||
|
|
||||||
|
|
||||||
def make_key(password):
|
def make_key(password):
|
||||||
|
|
|
@ -19,14 +19,13 @@
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from . import jrnl
|
|
||||||
from . import install
|
from . import install
|
||||||
|
from . import jrnl
|
||||||
from .parse_args import parse_args
|
|
||||||
from .config import scope_config
|
|
||||||
from .exception import UserAbort
|
|
||||||
from .Journal import open_journal
|
from .Journal import open_journal
|
||||||
from .config import get_journal_name
|
from .config import get_journal_name
|
||||||
|
from .config import scope_config
|
||||||
|
from .exception import UserAbort
|
||||||
|
from .parse_args import parse_args
|
||||||
|
|
||||||
|
|
||||||
def configure_logger(debug=False):
|
def configure_logger(debug=False):
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import colorama
|
|
||||||
import re
|
import re
|
||||||
from string import punctuation
|
from string import punctuation
|
||||||
from string import whitespace
|
from string import whitespace
|
||||||
|
|
||||||
|
import colorama
|
||||||
|
|
||||||
from .os_compat import on_windows
|
from .os_compat import on_windows
|
||||||
|
|
||||||
if on_windows:
|
if on_windows:
|
||||||
|
|
|
@ -40,8 +40,8 @@ def postconfig_list(config, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def postconfig_import(args, config, **kwargs):
|
def postconfig_import(args, config, **kwargs):
|
||||||
from .plugins import get_importer
|
|
||||||
from .Journal import open_journal
|
from .Journal import open_journal
|
||||||
|
from .plugins import get_importer
|
||||||
|
|
||||||
# Requires opening the journal
|
# Requires opening the journal
|
||||||
journal = open_journal(args.journal_name, config)
|
journal = open_journal(args.journal_name, config)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import colorama
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import colorama
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from .color import ERROR_COLOR
|
from .color import ERROR_COLOR
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import tempfile
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from .color import ERROR_COLOR
|
from .color import ERROR_COLOR
|
||||||
|
|
|
@ -4,8 +4,10 @@ import glob
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import xdg.BaseDirectory
|
import xdg.BaseDirectory
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
from .config import load_config
|
from .config import load_config
|
||||||
from .config import verify_config
|
from .config import verify_config
|
||||||
|
|
|
@ -3,10 +3,9 @@ import sys
|
||||||
|
|
||||||
from . import install
|
from . import install
|
||||||
from . import plugins
|
from . import plugins
|
||||||
from .editor import get_text_from_editor
|
|
||||||
|
|
||||||
from .color import ERROR_COLOR
|
from .color import ERROR_COLOR
|
||||||
from .color import RESET_COLOR
|
from .color import RESET_COLOR
|
||||||
|
from .editor import get_text_from_editor
|
||||||
from .os_compat import on_windows
|
from .os_compat import on_windows
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ import logging
|
||||||
def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs):
|
def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs):
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
from .color import RESET_COLOR, WARNING_COLOR
|
|
||||||
|
from .color import RESET_COLOR
|
||||||
|
from .color import WARNING_COLOR
|
||||||
|
|
||||||
warning_msg = f"""
|
warning_msg = f"""
|
||||||
The command {old_cmd} is deprecated and will be removed from jrnl soon.
|
The command {old_cmd} is deprecated and will be removed from jrnl soon.
|
||||||
|
|
|
@ -2,16 +2,11 @@ import argparse
|
||||||
import re
|
import re
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from .plugins import util
|
from .commands import deprecated_cmd
|
||||||
from .plugins import IMPORT_FORMATS
|
from .commands import output
|
||||||
from .plugins import EXPORT_FORMATS
|
from .plugins import EXPORT_FORMATS
|
||||||
from .commands import preconfig_version
|
from .plugins import IMPORT_FORMATS
|
||||||
from .commands import preconfig_diagnostic
|
from .plugins import util
|
||||||
from .commands import postconfig_list
|
|
||||||
from .commands import postconfig_import
|
|
||||||
from .commands import postconfig_encrypt
|
|
||||||
from .commands import postconfig_decrypt
|
|
||||||
from .output import deprecated_cmd
|
|
||||||
|
|
||||||
|
|
||||||
class WrappingFormatter(argparse.RawTextHelpFormatter):
|
class WrappingFormatter(argparse.RawTextHelpFormatter):
|
||||||
|
|
|
@ -5,7 +5,9 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from jrnl.color import RESET_COLOR, WARNING_COLOR
|
from jrnl.color import RESET_COLOR
|
||||||
|
from jrnl.color import WARNING_COLOR
|
||||||
|
|
||||||
from .text_exporter import TextExporter
|
from .text_exporter import TextExporter
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ import os
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
from jrnl.color import ERROR_COLOR, RESET_COLOR
|
from jrnl.color import ERROR_COLOR
|
||||||
|
from jrnl.color import RESET_COLOR
|
||||||
|
|
||||||
|
|
||||||
class TextExporter:
|
class TextExporter:
|
||||||
|
|
|
@ -5,7 +5,10 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from jrnl.color import ERROR_COLOR, RESET_COLOR, WARNING_COLOR
|
from jrnl.color import ERROR_COLOR
|
||||||
|
from jrnl.color import RESET_COLOR
|
||||||
|
from jrnl.color import WARNING_COLOR
|
||||||
|
|
||||||
from .text_exporter import TextExporter
|
from .text_exporter import TextExporter
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import sys
|
|
||||||
import getpass
|
import getpass
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def create_password(
|
def create_password(
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
FAKE_YEAR = 9999
|
FAKE_YEAR = 9999
|
||||||
DEFAULT_FUTURE = datetime(FAKE_YEAR, 12, 31, 23, 59, 59)
|
DEFAULT_FUTURE = datetime(FAKE_YEAR, 12, 31, 23, 59, 59)
|
||||||
DEFAULT_PAST = datetime(FAKE_YEAR, 1, 1, 0, 0)
|
DEFAULT_PAST = datetime(FAKE_YEAR, 1, 1, 0, 0)
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from . import __version__
|
|
||||||
from . import Journal
|
from . import Journal
|
||||||
|
from . import __version__
|
||||||
|
from .EncryptedJournal import EncryptedJournal
|
||||||
from .config import is_config_json
|
from .config import is_config_json
|
||||||
from .config import load_config
|
from .config import load_config
|
||||||
from .config import scope_config
|
from .config import scope_config
|
||||||
from .exception import UpgradeValidationException
|
from .exception import UpgradeValidationException
|
||||||
from .exception import UserAbort
|
from .exception import UserAbort
|
||||||
from .prompt import yesno
|
from .prompt import yesno
|
||||||
from .EncryptedJournal import EncryptedJournal
|
|
||||||
|
|
||||||
|
|
||||||
def backup(filename, binary=False):
|
def backup(filename, binary=False):
|
||||||
|
|
|
@ -43,12 +43,10 @@ pytest = "^5.4.3"
|
||||||
jrnl = 'jrnl.cli:run'
|
jrnl = 'jrnl.cli:run'
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
multi_line_output = 3
|
multi_line_output = 7
|
||||||
include_trailing_comma = true
|
force_single_line = true
|
||||||
force_grid_wrap = 0
|
|
||||||
use_parentheses = true
|
|
||||||
line_length = 88
|
line_length = 88
|
||||||
known_first_party = ["jrnl", "behave"]
|
known_first_party = ["jrnl"]
|
||||||
force_sort_within_sections = true
|
force_sort_within_sections = true
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from jrnl.parse_args import parse_args
|
import shlex
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import shlex
|
|
||||||
|
from jrnl.parse_args import parse_args
|
||||||
|
|
||||||
|
|
||||||
def cli_as_dict(str):
|
def cli_as_dict(str):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from jrnl import time
|
from jrnl import time
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue