From 49b34faa6a97f8451d3d21435739ca6875fa79f6 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 15 Aug 2025 10:42:49 -0600 Subject: [PATCH] Format tools/download_tool.py --- tools/download_tool.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/download_tool.py b/tools/download_tool.py index 7adbf0d..381b170 100644 --- a/tools/download_tool.py +++ b/tools/download_tool.py @@ -91,6 +91,7 @@ TOOLS: Dict[str, Callable[[str], str]] = { "wibo": wibo_url, } + def download(url, response, output) -> None: if url.endswith(".zip"): data = io.BytesIO(response.read()) @@ -107,6 +108,7 @@ def download(url, response, output) -> None: st = os.stat(output) os.chmod(output, st.st_mode | stat.S_IEXEC) + def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("tool", help="Tool name") @@ -128,12 +130,17 @@ def main() -> None: try: import certifi import ssl - except: - print("\"certifi\" module not found. Please install it using \"python -m pip install certifi\".") + except ImportError: + print( + '"certifi" module not found. Please install it using "python -m pip install certifi".' + ) return - - with urllib.request.urlopen(req, context=ssl.create_default_context(cafile=certifi.where())) as response: + + with urllib.request.urlopen( + req, context=ssl.create_default_context(cafile=certifi.where()) + ) as response: download(url, response, output) + if __name__ == "__main__": main()