docs/images/ansible/pcaps/svg-boxify.py
raw| 1 | |
| 2 | # Add viewBox attr to SVGs lacking it, so IE scales properly. |
| 3 | |
| 4 | import lxml.etree |
| 5 | import glob |
| 6 | |
| 7 | |
| 8 | for name in glob.glob('images/*.svg') + glob.glob('images/ansible/*.svg'): |
| 9 | doc = lxml.etree.parse(open(name)) |
| 10 | svg = doc.getroot() |
| 11 | if 'viewBox' not in svg.attrib: |
| 12 | svg.attrib['viewBox'] = '0 0 %(width)s %(height)s' % svg.attrib |
| 13 | open(name, 'w').write(lxml.etree.tostring(svg, xml_declaration=True, encoding='UTF-8')) |