INNER CODE UNIT · Python
import_original
WenyuChiou/awesome-agentic-ai-zh · scripts/build-role-map.py:75
def import_original(locale):
from PIL import Image
relative = asset_path(locale, "png").relative_to(ROOT).as_posix()
data = subprocess.check_output(["git", "show", f"{SOURCE_COMMIT}:{relative}"], cwd=ROOT)
if hashlib.sha256(data).hexdigest() != SOURCE_HASHES[locale]:
raise ValueError(f"Unexpected source artwork: {locale}")
with Image.open(io.BytesIO(data)) as source:
if source.size != LOCALES[locale][1]:
raise ValueError("Unexpected source canvas")
output = io.BytesIO()
source.save(output, format="WEBP", quality=95, method=6)
return output.getvalue()
def read_art(locale):
root = ET.fromstring(asset_path(locale, "svg").read_text(encoding="utf-8"))
art = root.find(NS + "image")