Files
art/scripts/download_resources.py
T

51 lines
3.4 KiB
Python

import os
import requests
from pathlib import Path
def download_font():
# Создаем директории если они не существуют
resources_dir = Path("resources")
fonts_dir = resources_dir / "fonts"
fonts_dir.mkdir(parents=True, exist_ok=True)
# URL для загрузки шрифта
font_url = "https://github.com/rsms/inter/raw/master/docs/font-files/InterVariable.ttf"
font_path = fonts_dir / "InterVariable.ttf"
# Загружаем шрифт если его еще нет
if not font_path.exists():
print("Загрузка шрифта Inter...")
response = requests.get(font_url)
if response.status_code == 200:
with open(font_path, "wb") as f:
f.write(response.content)
print(f"Шрифт успешно загружен в {font_path}")
else:
print(f"Ошибка при загрузке шрифта: {response.status_code}")
def download_icons():
# Создаем директорию для иконок
icons_dir = Path("resources/icons")
icons_dir.mkdir(parents=True, exist_ok=True)
# Словарь с иконками и их SVG содержимым
icons = {
"home.svg": """<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>""",
"image.svg": """<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>""",
"settings.svg": """<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>"""
}
# Сохраняем иконки
for filename, svg_content in icons.items():
icon_path = icons_dir / filename
if not icon_path.exists():
print(f"Создаем иконку {filename}...")
with open(icon_path, "w", encoding="utf-8") as f:
f.write(svg_content)
print(f"Иконка {filename} создана")
if __name__ == "__main__":
download_font()
download_icons()