Repository Public
1#!/usr/bin/env python32# SP Wallet iOS3# File: Scripts/import-logos.py4# Description: Import the backend's sanitized logo set (apps/web/src/logos, provenance in its SOURCES.md / icons.json) into the5# asset catalog: SVG kept as vector, WebP converted to PNG with sips. Generated content — rerun, do not edit by hand.6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9import json, pathlib, shutil, subprocess, sys1011root = pathlib.Path(__file__).resolve().parent.parent12src = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else pathlib.Path.home() / "Desktop/Cluster/projets/sp-wallet/apps/web/src/logos")13out = root / "Resources/Assets.xcassets/Logos"14out.mkdir(parents=True, exist_ok=True)15(out / "Contents.json").write_text(json.dumps({"info": {"author": "xcode", "version": 1}, "properties": {"provides-namespace": False}}, indent=2))16count = 017for kind in ("asset", "network", "venue", "provider"):18 for f in sorted((src / kind).iterdir()):19 if f.suffix not in (".svg", ".webp", ".png"):20 continue21 name = f"logo-{kind}-{f.stem.lower()}"22 d = out / f"{name}.imageset"23 d.mkdir(exist_ok=True)24 for old in d.iterdir():25 old.unlink()26 if f.suffix == ".svg":27 target = d / f"{name}.svg"28 shutil.copyfile(f, target)29 props = {"preserves-vector-representation": True}30 else:31 target = d / f"{name}.png"32 subprocess.run(["sips", "-s", "format", "png", str(f), "--out", str(target)], check=True, capture_output=True)33 props = {}34 (d / "Contents.json").write_text(json.dumps({"images": [{"filename": target.name, "idiom": "universal"}], "info": {"author": "xcode", "version": 1}, "properties": props}, indent=2))35 count += 136shutil.copyfile(src / "SOURCES.md", root / "docs/LOGO_SOURCES.md")37shutil.copyfile(src / "icons.json", root / "docs/logo-licences.json")38print(f"{count} logos imported")39