2015-10-04 18:56:26 +02:00
|
|
|
#!/usr/bin/env python2.7
|
2016-03-10 18:43:31 +01:00
|
|
|
from __future__ import absolute_import
|
2013-02-15 20:27:15 +01:00
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
import subprocess
|
2016-03-10 18:43:31 +01:00
|
|
|
from six.moves import range
|
2013-02-15 20:27:15 +01:00
|
|
|
|
|
|
|
# Generates the favicon images containing unread message counts.
|
|
|
|
|
|
|
|
# Open the SVG and find the number text elements using XPath
|
|
|
|
tree = ET.parse('orig.svg')
|
|
|
|
elems = [tree.getroot().findall(
|
|
|
|
".//*[@id='%s']/{http://www.w3.org/2000/svg}tspan" % (name,))[0]
|
|
|
|
for name in ('number_back', 'number_front')]
|
|
|
|
|
2016-03-10 18:43:31 +01:00
|
|
|
for i in range(1, 100):
|
2013-02-15 20:27:15 +01:00
|
|
|
# Prepare a modified SVG
|
|
|
|
s = '%2d' % (i,)
|
|
|
|
for e in elems:
|
|
|
|
e.text = s
|
|
|
|
with open('tmp.svg', 'w') as out:
|
|
|
|
tree.write(out)
|
|
|
|
|
|
|
|
# Convert to PNG
|
|
|
|
subprocess.check_call(['inkscape', '--without-gui', '--export-area-page',
|
2013-07-25 22:41:44 +02:00
|
|
|
'--export-png=../../static/images/favicon/favicon-%d.png' % (i,),
|
2013-02-15 20:27:15 +01:00
|
|
|
'tmp.svg'])
|