From e84c9fd2d2534fe647d4d15c68d68376145e70ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20S=C3=BAkup?= Date: Fri, 21 Feb 2025 13:07:57 +0000 Subject: [PATCH] Remove unnecessary custom dict from downloader --- mtui/export/downloader.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/mtui/export/downloader.py b/mtui/export/downloader.py index 13b6b86..cd5fc81 100644 --- a/mtui/export/downloader.py +++ b/mtui/export/downloader.py @@ -1,4 +1,4 @@ -from collections.abc import Callable, Hashable +from collections.abc import Callable import concurrent.futures from logging import getLogger import os.path @@ -10,14 +10,6 @@ logger = getLogger("mtui.export.downloader") -class DownloaderDict(dict): - def __getitem__(self, item: Hashable) -> Callable[[str, dict, str, str, str], None]: - try: - return super().__getitem__(item) - except KeyError: - return _emptylog - - def _subdl(oqa_path: str, l_path: str, test: dict, errormode: str) -> None: try: logger.info("Downloading log %s", oqa_path) @@ -28,7 +20,7 @@ def _subdl(oqa_path: str, l_path: str, test: dict, errormode: str) -> None: raise ResultsMissingError(test["name"], test["arch"]) -def _emptylog(host, test, *args, **kwds): +def _emptylog(host, test, *args, **kwds) -> None: logger.debug("No log to download for test: %s on %s", test["name"], host) pass @@ -57,7 +49,10 @@ def _installlog(host, test, _, installlogsdir, errormode) -> None: _subdl(oqa_path, l_path, test, errormode) -downloader = DownloaderDict({"install": _installlog, "ltp": _resultlog}) +downloader: dict[str, Callable[[str, dict, str, str, str], None]] = { + "install": _installlog, + "ltp": _resultlog, +} def download_logs(oqa, resultsdir, installogsdir, errormode: str) -> None: @@ -71,5 +66,5 @@ def download_logs(oqa, resultsdir, installogsdir, errormode: str) -> None: with concurrent.futures.ThreadPoolExecutor() as e: for host, name, test_id, arch in results_matrix: test = {"name": name, "test_id": test_id, "arch": arch} - dl = downloader[name.split("_")[0]] + dl = downloader.get(name.split("_")[0], _emptylog) e.submit(dl, host, test, resultsdir, installogsdir, errormode)