INNER CODE UNIT · Python

read_art

WenyuChiou/awesome-agentic-ai-zh · scripts/build-role-map.py:90

def read_art(locale):
    root = ET.fromstring(asset_path(locale, "svg").read_text(encoding="utf-8"))
    art = root.find(NS + "image")
    if art is None:
        raise ValueError("Missing original art")
    prefix, payload = art.attrib["href"].split(",", 1)
    if prefix != "data:image/webp;base64":
        raise ValueError("Expected embedded WebP")
    data = base64.b64decode(payload, validate=True)
    if hashlib.sha256(data).hexdigest() != ART_HASHES[locale]:
        raise ValueError(f"Changed original artwork: {locale}")
    return data


def build_svg(locale, art):
    from PIL import Image

    _, (width, height), title, description = LOCALES[locale]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…