Files
libretro/scripts/fetch_site_images.py
Abdessamad Derraz ab7e300c19 refactor: tidy the repository root
README.md and CONTRIBUTING.md open with a comment naming their
generator, generate_readme.py --check fails on a hand edit in
validate.yml and pr_checks.py, and .gitattributes marks the pipeline
outputs as generated, held equal to core/generated.py by a test.

_mame_clones.json becomes mame_clones.json, still written beside the
scanned bios/ tree, and now triggers both workflows (coverage reads it).
docs_assets/ moves to website/assets/, which Astro does not read as
content. ACCESSIBILITY.md becomes wiki/accessibility.md, linked from the
README and the installer page. The screenshot list moves to
wiki/images-wanted.md: nothing read docs_assets/screens/.

The architecture map names every root entry (test_repository_map),
platforms/README.md keeps only what this folder holds, the reference
index lists archive-recipes and measurements, and reference-terms no
longer defines Profile twice nor repeats the glossary's Pack.
2026-11-24 10:40:25 +01:00

48 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Download the platform logos and system icons the site shows, once.
The site served these from other hosts: GitHub avatars and files on the
``master`` branch of upstream repositories. A rename upstream broke an image
in silence, and every page view hit third-party hosts. This tool copies them
into ``website/assets/logos/`` and ``website/assets/system-icons/``, which are
committed, and records where each came from in a ``sources.json`` beside
them. The site build only reads those copies (``sitegen.pageprep.localize_images``).
Raster logos are normalised to an 80 px square WebP, twice the 40 px they
are shown at, and system icons to a 48 px PNG, so every tile has the same
weight. SVG is minified by svgo, and a raster an SVG embeds is cut to the
tile size.
Normalising needs Pillow. This is a maintenance tool run by hand when a
logo changes, not a build step: the build stays on the standard library
and PyYAML.
python scripts/fetch_site_images.py # logos and icons
python scripts/fetch_site_images.py --only logos
"""
from __future__ import annotations
import argparse
from sitegen.imagefetch import fetch_icons, fetch_logos
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0], allow_abbrev=False)
parser.add_argument("--only", choices=("logos", "icons"), help="fetch one kind only")
args = parser.parse_args()
if args.only in (None, "logos"):
print("Platform logos:")
for file_name, url in fetch_logos():
print(f" {file_name} from {url}")
if args.only in (None, "icons"):
print("System icons:")
for file_name in fetch_icons():
print(f" {file_name}")
if __name__ == "__main__":
from core.cli import run_cli
run_cli(main)