File: stroke-width.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (16 lines) | stat: -rw-r--r-- 493 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

import sys
# Add viewBox attr to SVGs lacking it, so IE scales properly.

import lxml.etree
import glob


for name in sys.argv[1:]:  # glob.glob('*/*.svg'): #+ glob.glob('images/ansible/*.svg'):
    doc = lxml.etree.parse(open(name))
    svg = doc.getroot()
    for elem in svg.cssselect('[stroke-width]'):
        if elem.attrib['stroke-width'] < '2':
            elem.attrib['stroke-width'] = '2'

    open(name, 'w').write(lxml.etree.tostring(svg, xml_declaration=True, encoding='UTF-8'))