style: Reformat dl_icons.py with consistent spacing

This commit is contained in:
Paul Gauthier (aider) 2025-03-24 16:23:05 -10:00
parent 5aeea0c228
commit 6c50645213

View file

@ -4,9 +4,10 @@ Download Material Design Icons SVGs used in the README and save to local assets.
""" """
import os import os
import requests
from pathlib import Path from pathlib import Path
import requests
# Create the directory if it doesn't exist # Create the directory if it doesn't exist
ICONS_DIR = Path("aider/website/assets/icons") ICONS_DIR = Path("aider/website/assets/icons")
ICONS_DIR.mkdir(parents=True, exist_ok=True) ICONS_DIR.mkdir(parents=True, exist_ok=True)
@ -24,33 +25,36 @@ ICONS = [
"content-copy", "content-copy",
] ]
def download_icon(icon_name): def download_icon(icon_name):
"""Download an SVG icon from Material Design Icons CDN.""" """Download an SVG icon from Material Design Icons CDN."""
url = f"https://cdn.jsdelivr.net/npm/@mdi/svg@latest/svg/{icon_name}.svg" url = f"https://cdn.jsdelivr.net/npm/@mdi/svg@latest/svg/{icon_name}.svg"
print(f"Downloading {url}...") print(f"Downloading {url}...")
response = requests.get(url) response = requests.get(url)
if response.status_code != 200: if response.status_code != 200:
print(f"Failed to download {icon_name}.svg: {response.status_code}") print(f"Failed to download {icon_name}.svg: {response.status_code}")
return False return False
# Save the SVG file # Save the SVG file
output_path = ICONS_DIR / f"{icon_name}.svg" output_path = ICONS_DIR / f"{icon_name}.svg"
with open(output_path, "wb") as f: with open(output_path, "wb") as f:
f.write(response.content) f.write(response.content)
print(f"Saved {icon_name}.svg to {output_path}") print(f"Saved {icon_name}.svg to {output_path}")
return True return True
def main(): def main():
print(f"Downloading icons to {ICONS_DIR}") print(f"Downloading icons to {ICONS_DIR}")
success_count = 0 success_count = 0
for icon in ICONS: for icon in ICONS:
if download_icon(icon): if download_icon(icon):
success_count += 1 success_count += 1
print(f"Successfully downloaded {success_count}/{len(ICONS)} icons") print(f"Successfully downloaded {success_count}/{len(ICONS)} icons")
if __name__ == "__main__": if __name__ == "__main__":
main() main()