Format tools/download_tool.py

This commit is contained in:
Luke Street 2025-08-15 10:42:49 -06:00
parent b4be7cfa39
commit 49b34faa6a

View File

@ -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()