1
0
Fork 0
mirror of synced 2024-09-29 16:51:22 +13:00

fix: Re-add typings with conditional import to avoid circular import issue

This commit is contained in:
Cristian 2020-07-20 11:20:08 -05:00
parent 75e5a6fcdc
commit 834b33e6a8

View file

@ -11,7 +11,10 @@ from multiprocessing import Process
from datetime import datetime 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, TYPE_CHECKING
if TYPE_CHECKING:
from .index.schema import Link, ArchiveResult
from .util import enforce_types from .util import enforce_types
from .config import ( from .config import (
@ -282,7 +285,7 @@ def log_archiving_finished(num_links: int):
print(' archivebox server') print(' archivebox server')
def log_link_archiving_started(link, link_dir: str, is_new: bool): def log_link_archiving_started(link: "Link", link_dir: str, is_new: bool):
# [*] [2019-03-22 13:46:45] "Log Structured Merge Trees - ben stopford" # [*] [2019-03-22 13:46:45] "Log Structured Merge Trees - ben stopford"
# http://www.benstopford.com/2015/02/14/log-structured-merge-trees/ # http://www.benstopford.com/2015/02/14/log-structured-merge-trees/
# > output/archive/1478739709 # > output/archive/1478739709
@ -300,7 +303,7 @@ def log_link_archiving_started(link, link_dir: str, is_new: bool):
pretty_path(link_dir), pretty_path(link_dir),
)) ))
def log_link_archiving_finished(link, link_dir: str, is_new: bool, stats: dict): def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats: dict):
total = sum(stats.values()) total = sum(stats.values())
if stats['failed'] > 0 : if stats['failed'] > 0 :
@ -315,7 +318,7 @@ def log_archive_method_started(method: str):
print(' > {}'.format(method)) print(' > {}'.format(method))
def log_archive_method_finished(result): def log_archive_method_finished(result: "ArchiveResult"):
"""quote the argument with whitespace in a command so the user can """quote the argument with whitespace in a command so the user can
copy-paste the outputted string directly to run the cmd copy-paste the outputted string directly to run the cmd
""" """
@ -372,7 +375,7 @@ def log_list_finished(links):
print() print()
def log_removal_started(links, yes: bool, delete: bool): def log_removal_started(links: List["Link"], yes: bool, delete: bool):
print('{lightyellow}[i] Found {} matching URLs to remove.{reset}'.format(len(links), **ANSI)) print('{lightyellow}[i] Found {} matching URLs to remove.{reset}'.format(len(links), **ANSI))
if delete: if delete:
file_counts = [link.num_outputs for link in links if os.path.exists(link.link_dir)] file_counts = [link.num_outputs for link in links if os.path.exists(link.link_dir)]
@ -446,7 +449,7 @@ def printable_filesize(num_bytes: Union[int, float]) -> str:
@enforce_types @enforce_types
def printable_folders(folders, def printable_folders(folders: Dict[str, Optional["Link"]],
json: bool=False, json: bool=False,
csv: Optional[str]=None) -> str: csv: Optional[str]=None) -> str:
if json: if json: