Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
script per il tagging di <polygon> in un .svg
from xml.dom import minidom
SRC_FILE = "public/images/macchina.svg"
DST_FILE = "public/images/fuffa.svg"
with open(SRC_FILE) as source:
doc = minidom.parse(source)
svg_elem = doc.childNodes[0]
for index, child in enumerate(filter(lambda ch: ch.tagName == "polygon", svg_elem.childNodes)):
child.setAttribute("polygon_id", str(index))
with open(DST_FILE, "w") as destination:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.