File indexing completed on 2025-01-19 03:59:51
0001 from xml.dom import minidom 0002 from xml.etree import ElementTree 0003 0004 from .base import exporter 0005 from ..parsers.svg.builder import to_svg 0006 from ..utils.file import open_file 0007 0008 0009 def _print_ugly_xml(dom, file): 0010 return dom.write(file, "utf-8", True) 0011 0012 0013 def _print_pretty_xml(dom, file): 0014 with open_file(file) as fp: 0015 xmlstr = minidom.parseString(ElementTree.tostring(dom.getroot())).toprettyxml(indent=" ") 0016 fp.write(xmlstr) 0017 0018 0019 @exporter("SVG", ["svg"], [], {"pretty", "frame"}) 0020 def export_svg(animation, file, frame=0, pretty=True): 0021 _print_xml = _print_pretty_xml if pretty else _print_ugly_xml 0022 _print_xml(to_svg(animation, frame), file)