mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04: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'
|
command.subcommand = 'version'
|
||||||
|
|
||||||
if command.subcommand not in ('help', 'version', 'status'):
|
if command.subcommand not in ('help', 'version', 'status'):
|
||||||
from ..cli.logging import log_cli_command
|
from ..logging import log_cli_command
|
||||||
|
|
||||||
log_cli_command(
|
log_cli_command(
|
||||||
subcommand=command.subcommand,
|
subcommand=command.subcommand,
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import List, Optional, IO
|
||||||
|
|
||||||
from ..main import add, docstring
|
from ..main import add, docstring
|
||||||
from ..config import OUTPUT_DIR, ONLY_NEW
|
from ..config import OUTPUT_DIR, ONLY_NEW
|
||||||
from .logging import SmartFormatter, accept_stdin, stderr
|
from ..logging import SmartFormatter, accept_stdin, stderr
|
||||||
|
|
||||||
|
|
||||||
@docstring(add.__doc__)
|
@docstring(add.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import config, docstring
|
from ..main import config, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, accept_stdin
|
from ..logging import SmartFormatter, accept_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(config.__doc__)
|
@docstring(config.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import help, docstring
|
from ..main import help, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, reject_stdin
|
from ..logging import SmartFormatter, reject_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(help.__doc__)
|
@docstring(help.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import init, docstring
|
from ..main import init, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, reject_stdin
|
from ..logging import SmartFormatter, reject_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(init.__doc__)
|
@docstring(init.__doc__)
|
||||||
|
|
|
@ -22,7 +22,7 @@ from ..index import (
|
||||||
get_corrupted_folders,
|
get_corrupted_folders,
|
||||||
get_unrecognized_folders,
|
get_unrecognized_folders,
|
||||||
)
|
)
|
||||||
from .logging import SmartFormatter, accept_stdin
|
from ..logging import SmartFormatter, accept_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(list_all.__doc__)
|
@docstring(list_all.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import remove, docstring
|
from ..main import remove, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, accept_stdin
|
from ..logging import SmartFormatter, accept_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(remove.__doc__)
|
@docstring(remove.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import schedule, docstring
|
from ..main import schedule, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, reject_stdin
|
from ..logging import SmartFormatter, reject_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(schedule.__doc__)
|
@docstring(schedule.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import server, docstring
|
from ..main import server, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, reject_stdin
|
from ..logging import SmartFormatter, reject_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(server.__doc__)
|
@docstring(server.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import shell, docstring
|
from ..main import shell, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, reject_stdin
|
from ..logging import SmartFormatter, reject_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(shell.__doc__)
|
@docstring(shell.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import status, docstring
|
from ..main import status, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, reject_stdin
|
from ..logging import SmartFormatter, reject_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(status.__doc__)
|
@docstring(status.__doc__)
|
||||||
|
|
|
@ -22,7 +22,7 @@ from ..index import (
|
||||||
get_corrupted_folders,
|
get_corrupted_folders,
|
||||||
get_unrecognized_folders,
|
get_unrecognized_folders,
|
||||||
)
|
)
|
||||||
from .logging import SmartFormatter, accept_stdin
|
from ..logging import SmartFormatter, accept_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(update.__doc__)
|
@docstring(update.__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Optional, List, IO
|
||||||
|
|
||||||
from ..main import version, docstring
|
from ..main import version, docstring
|
||||||
from ..config import OUTPUT_DIR
|
from ..config import OUTPUT_DIR
|
||||||
from .logging import SmartFormatter, reject_stdin
|
from ..logging import SmartFormatter, reject_stdin
|
||||||
|
|
||||||
|
|
||||||
@docstring(version.__doc__)
|
@docstring(version.__doc__)
|
||||||
|
|
|
@ -3,7 +3,7 @@ from django.utils.html import format_html
|
||||||
|
|
||||||
from util import htmldecode, urldecode
|
from util import htmldecode, urldecode
|
||||||
from core.models import Snapshot
|
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
|
# 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__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -12,7 +12,7 @@ from ..index import (
|
||||||
patch_main_index,
|
patch_main_index,
|
||||||
)
|
)
|
||||||
from ..util import enforce_types
|
from ..util import enforce_types
|
||||||
from ..cli.logging import (
|
from ..logging import (
|
||||||
log_archiving_started,
|
log_archiving_started,
|
||||||
log_archiving_paused,
|
log_archiving_paused,
|
||||||
log_archiving_finished,
|
log_archiving_finished,
|
||||||
|
|
|
@ -19,7 +19,7 @@ from ..config import (
|
||||||
CURL_VERSION,
|
CURL_VERSION,
|
||||||
CURL_USER_AGENT,
|
CURL_USER_AGENT,
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ from ..config import (
|
||||||
SAVE_DOM,
|
SAVE_DOM,
|
||||||
CHROME_VERSION,
|
CHROME_VERSION,
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from ..config import (
|
||||||
CHECK_SSL_VALIDITY,
|
CHECK_SSL_VALIDITY,
|
||||||
CURL_USER_AGENT,
|
CURL_USER_AGENT,
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
|
@ -22,7 +22,7 @@ from ..config import (
|
||||||
GIT_DOMAINS,
|
GIT_DOMAINS,
|
||||||
CHECK_SSL_VALIDITY
|
CHECK_SSL_VALIDITY
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ from ..config import (
|
||||||
YOUTUBEDL_VERSION,
|
YOUTUBEDL_VERSION,
|
||||||
CHECK_SSL_VALIDITY
|
CHECK_SSL_VALIDITY
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
|
@ -16,7 +16,7 @@ from ..config import (
|
||||||
SAVE_PDF,
|
SAVE_PDF,
|
||||||
CHROME_VERSION,
|
CHROME_VERSION,
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
|
@ -16,7 +16,7 @@ from ..config import (
|
||||||
SAVE_SCREENSHOT,
|
SAVE_SCREENSHOT,
|
||||||
CHROME_VERSION,
|
CHROME_VERSION,
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ from ..config import (
|
||||||
CURL_VERSION,
|
CURL_VERSION,
|
||||||
CURL_USER_AGENT,
|
CURL_USER_AGENT,
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
HTML_TITLE_REGEX = re.compile(
|
HTML_TITLE_REGEX = re.compile(
|
||||||
|
|
|
@ -31,7 +31,7 @@ from ..config import (
|
||||||
WGET_USER_AGENT,
|
WGET_USER_AGENT,
|
||||||
COOKIES_FILE,
|
COOKIES_FILE,
|
||||||
)
|
)
|
||||||
from ..cli.logging import TimedProgress
|
from ..logging import TimedProgress
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
|
@ -27,7 +27,7 @@ from ..config import (
|
||||||
ANSI,
|
ANSI,
|
||||||
stderr,
|
stderr,
|
||||||
)
|
)
|
||||||
from ..cli.logging import (
|
from ..logging import (
|
||||||
TimedProgress,
|
TimedProgress,
|
||||||
log_indexing_process_started,
|
log_indexing_process_started,
|
||||||
log_indexing_process_finished,
|
log_indexing_process_finished,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
__package__ = 'archivebox.cli'
|
__package__ = 'archivebox'
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
@ -13,11 +13,11 @@ from datetime import datetime
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, List, Dict, Union, IO
|
from typing import Optional, List, Dict, Union, IO
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult
|
from .index.schema import Link, ArchiveResult
|
||||||
from ..index.json import to_json
|
from .index.json import to_json
|
||||||
from ..index.csv import links_to_csv
|
from .index.csv import links_to_csv
|
||||||
from ..util import enforce_types
|
from .util import enforce_types
|
||||||
from ..config import (
|
from .config import (
|
||||||
ConfigDict,
|
ConfigDict,
|
||||||
PYTHON_ENCODING,
|
PYTHON_ENCODING,
|
||||||
ANSI,
|
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):
|
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))
|
cmd = ' '.join(('archivebox', subcommand, *subcommand_args))
|
||||||
stdin_hint = ' < /dev/stdin' if not stdin.isatty() else ''
|
stdin_hint = ' < /dev/stdin' if not stdin.isatty() else ''
|
||||||
stderr('{black}[i] [{now}] ArchiveBox v{VERSION}: {cmd}{stdin_hint}{reset}'.format(
|
stderr('{black}[i] [{now}] ArchiveBox v{VERSION}: {cmd}{stdin_hint}{reset}'.format(
|
|
@ -88,7 +88,7 @@ from .config import (
|
||||||
USER_CONFIG,
|
USER_CONFIG,
|
||||||
get_real_name,
|
get_real_name,
|
||||||
)
|
)
|
||||||
from .cli.logging import (
|
from .logging import (
|
||||||
TERM_WIDTH,
|
TERM_WIDTH,
|
||||||
TimedProgress,
|
TimedProgress,
|
||||||
log_importing_started,
|
log_importing_started,
|
||||||
|
|
|
@ -29,7 +29,7 @@ from ..util import (
|
||||||
URL_REGEX,
|
URL_REGEX,
|
||||||
)
|
)
|
||||||
from ..index.schema import Link
|
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 .pocket_html import parse_pocket_html_export
|
||||||
from .pinboard_rss import parse_pinboard_rss_export
|
from .pinboard_rss import parse_pinboard_rss_export
|
||||||
from .shaarli_rss import parse_shaarli_rss_export
|
from .shaarli_rss import parse_shaarli_rss_export
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue