mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-10 06:34:16 +00:00
refactor: Move logging.py to main module to avoid circular import issues
This commit is contained in:
parent
f449e58239
commit
f4d1b5121e
29 changed files with 35 additions and 35 deletions
|
@ -110,7 +110,7 @@ def main(args: Optional[List[str]]=NotProvided, stdin: Optional[IO]=NotProvided,
|
|||
command.subcommand = 'version'
|
||||
|
||||
if command.subcommand not in ('help', 'version', 'status'):
|
||||
from ..cli.logging import log_cli_command
|
||||
from ..logging import log_cli_command
|
||||
|
||||
log_cli_command(
|
||||
subcommand=command.subcommand,
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import List, Optional, IO
|
|||
|
||||
from ..main import add, docstring
|
||||
from ..config import OUTPUT_DIR, ONLY_NEW
|
||||
from .logging import SmartFormatter, accept_stdin, stderr
|
||||
from ..logging import SmartFormatter, accept_stdin, stderr
|
||||
|
||||
|
||||
@docstring(add.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import config, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, accept_stdin
|
||||
from ..logging import SmartFormatter, accept_stdin
|
||||
|
||||
|
||||
@docstring(config.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import help, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, reject_stdin
|
||||
from ..logging import SmartFormatter, reject_stdin
|
||||
|
||||
|
||||
@docstring(help.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import init, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, reject_stdin
|
||||
from ..logging import SmartFormatter, reject_stdin
|
||||
|
||||
|
||||
@docstring(init.__doc__)
|
||||
|
|
|
@ -22,7 +22,7 @@ from ..index import (
|
|||
get_corrupted_folders,
|
||||
get_unrecognized_folders,
|
||||
)
|
||||
from .logging import SmartFormatter, accept_stdin
|
||||
from ..logging import SmartFormatter, accept_stdin
|
||||
|
||||
|
||||
@docstring(list_all.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import remove, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, accept_stdin
|
||||
from ..logging import SmartFormatter, accept_stdin
|
||||
|
||||
|
||||
@docstring(remove.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import schedule, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, reject_stdin
|
||||
from ..logging import SmartFormatter, reject_stdin
|
||||
|
||||
|
||||
@docstring(schedule.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import server, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, reject_stdin
|
||||
from ..logging import SmartFormatter, reject_stdin
|
||||
|
||||
|
||||
@docstring(server.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import shell, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, reject_stdin
|
||||
from ..logging import SmartFormatter, reject_stdin
|
||||
|
||||
|
||||
@docstring(shell.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import status, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, reject_stdin
|
||||
from ..logging import SmartFormatter, reject_stdin
|
||||
|
||||
|
||||
@docstring(status.__doc__)
|
||||
|
|
|
@ -22,7 +22,7 @@ from ..index import (
|
|||
get_corrupted_folders,
|
||||
get_unrecognized_folders,
|
||||
)
|
||||
from .logging import SmartFormatter, accept_stdin
|
||||
from ..logging import SmartFormatter, accept_stdin
|
||||
|
||||
|
||||
@docstring(update.__doc__)
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
|||
|
||||
from ..main import version, docstring
|
||||
from ..config import OUTPUT_DIR
|
||||
from .logging import SmartFormatter, reject_stdin
|
||||
from ..logging import SmartFormatter, reject_stdin
|
||||
|
||||
|
||||
@docstring(version.__doc__)
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.utils.html import format_html
|
|||
|
||||
from util import htmldecode, urldecode
|
||||
from core.models import Snapshot
|
||||
from cli.logging import printable_filesize
|
||||
from archivebox.logging import printable_filesize
|
||||
|
||||
# TODO: https://stackoverflow.com/questions/40760880/add-custom-button-to-django-admin-panel
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from cli.logging import log_shell_welcome_msg
|
||||
from archivebox.logging import log_shell_welcome_msg
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -12,7 +12,7 @@ from ..index import (
|
|||
patch_main_index,
|
||||
)
|
||||
from ..util import enforce_types
|
||||
from ..cli.logging import (
|
||||
from ..logging import (
|
||||
log_archiving_started,
|
||||
log_archiving_paused,
|
||||
log_archiving_finished,
|
||||
|
|
|
@ -19,7 +19,7 @@ from ..config import (
|
|||
CURL_VERSION,
|
||||
CURL_USER_AGENT,
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ from ..config import (
|
|||
SAVE_DOM,
|
||||
CHROME_VERSION,
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from ..config import (
|
|||
CHECK_SSL_VALIDITY,
|
||||
CURL_USER_AGENT,
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
@enforce_types
|
||||
|
|
|
@ -22,7 +22,7 @@ from ..config import (
|
|||
GIT_DOMAINS,
|
||||
CHECK_SSL_VALIDITY
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from ..config import (
|
|||
YOUTUBEDL_VERSION,
|
||||
CHECK_SSL_VALIDITY
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
@enforce_types
|
||||
|
|
|
@ -16,7 +16,7 @@ from ..config import (
|
|||
SAVE_PDF,
|
||||
CHROME_VERSION,
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
@enforce_types
|
||||
|
|
|
@ -16,7 +16,7 @@ from ..config import (
|
|||
SAVE_SCREENSHOT,
|
||||
CHROME_VERSION,
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from ..config import (
|
|||
CURL_VERSION,
|
||||
CURL_USER_AGENT,
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
HTML_TITLE_REGEX = re.compile(
|
||||
|
|
|
@ -31,7 +31,7 @@ from ..config import (
|
|||
WGET_USER_AGENT,
|
||||
COOKIES_FILE,
|
||||
)
|
||||
from ..cli.logging import TimedProgress
|
||||
from ..logging import TimedProgress
|
||||
|
||||
|
||||
@enforce_types
|
||||
|
|
|
@ -27,7 +27,7 @@ from ..config import (
|
|||
ANSI,
|
||||
stderr,
|
||||
)
|
||||
from ..cli.logging import (
|
||||
from ..logging import (
|
||||
TimedProgress,
|
||||
log_indexing_process_started,
|
||||
log_indexing_process_finished,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
__package__ = 'archivebox.cli'
|
||||
__package__ = 'archivebox'
|
||||
|
||||
import re
|
||||
import os
|
||||
|
@ -13,11 +13,11 @@ from datetime import datetime
|
|||
from dataclasses import dataclass
|
||||
from typing import Optional, List, Dict, Union, IO
|
||||
|
||||
from ..index.schema import Link, ArchiveResult
|
||||
from ..index.json import to_json
|
||||
from ..index.csv import links_to_csv
|
||||
from ..util import enforce_types
|
||||
from ..config import (
|
||||
from .index.schema import Link, ArchiveResult
|
||||
from .index.json import to_json
|
||||
from .index.csv import links_to_csv
|
||||
from .util import enforce_types
|
||||
from .config import (
|
||||
ConfigDict,
|
||||
PYTHON_ENCODING,
|
||||
ANSI,
|
||||
|
@ -153,7 +153,7 @@ def progress_bar(seconds: int, prefix: str='') -> None:
|
|||
|
||||
|
||||
def log_cli_command(subcommand: str, subcommand_args: List[str], stdin: Optional[str], pwd: str):
|
||||
from ..config import VERSION, ANSI
|
||||
from .config import VERSION, ANSI
|
||||
cmd = ' '.join(('archivebox', subcommand, *subcommand_args))
|
||||
stdin_hint = ' < /dev/stdin' if not stdin.isatty() else ''
|
||||
stderr('{black}[i] [{now}] ArchiveBox v{VERSION}: {cmd}{stdin_hint}{reset}'.format(
|
|
@ -88,7 +88,7 @@ from .config import (
|
|||
USER_CONFIG,
|
||||
get_real_name,
|
||||
)
|
||||
from .cli.logging import (
|
||||
from .logging import (
|
||||
TERM_WIDTH,
|
||||
TimedProgress,
|
||||
log_importing_started,
|
||||
|
|
|
@ -29,7 +29,7 @@ from ..util import (
|
|||
URL_REGEX,
|
||||
)
|
||||
from ..index.schema import Link
|
||||
from ..cli.logging import pretty_path, TimedProgress, log_source_saved
|
||||
from ..logging import pretty_path, TimedProgress, log_source_saved
|
||||
from .pocket_html import parse_pocket_html_export
|
||||
from .pinboard_rss import parse_pinboard_rss_export
|
||||
from .shaarli_rss import parse_shaarli_rss_export
|
||||
|
|
Loading…
Reference in a new issue