From e57f6ded52a601b9a4dbfbf51d7850609d9c47a3 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Fri, 8 Nov 2024 10:05:54 +0000 Subject: [PATCH 1/2] Fix typing --- src/zimscraperlib/download.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zimscraperlib/download.py b/src/zimscraperlib/download.py index 7cfe6914..2f1d5163 100644 --- a/src/zimscraperlib/download.py +++ b/src/zimscraperlib/download.py @@ -177,13 +177,13 @@ def stream_file( fpath: pathlib.Path | None = None, byte_stream: IO[bytes] | None = None, block_size: int | None = 1024, - proxies: dict | None = None, + proxies: dict[str, str] | None = None, max_retries: int | None = 5, headers: dict[str, str] | None = None, session: requests.Session | None = None, *, only_first_block: bool | None = False, -) -> tuple[int, requests.structures.CaseInsensitiveDict]: +) -> tuple[int, requests.structures.CaseInsensitiveDict[str]]: """Stream data from a URL to either a BytesIO object or a file Arguments - fpath - Path of the file where data is sent From f5f04123088defd01c75e80325f493bc76cade89 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Fri, 8 Nov 2024 10:06:16 +0000 Subject: [PATCH 2/2] Add standard log format displaying thread name --- src/zimscraperlib/logging.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/zimscraperlib/logging.py b/src/zimscraperlib/logging.py index f2f12ce5..c60a3b25 100644 --- a/src/zimscraperlib/logging.py +++ b/src/zimscraperlib/logging.py @@ -13,6 +13,9 @@ from zimscraperlib.constants import NAME DEFAULT_FORMAT = "[%(name)s::%(asctime)s] %(levelname)s:%(message)s" +DEFAULT_FORMAT_WITH_THREADS = ( + "[%(name)s::%(threadName)s::%(asctime)s] %(levelname)s:%(message)s" +) VERBOSE_DEPENDENCIES = ["urllib3", "PIL", "boto3", "botocore", "s3transfer"]