| Revision 2166,
952 bytes
checked in by pablo, 13 months ago
(diff) |
|
Branch for v6 dev work
|
| Line | |
|---|
| 1 | import base64 |
|---|
| 2 | from xml.dom import minidom |
|---|
| 3 | import re |
|---|
| 4 | |
|---|
| 5 | basePath = '../../../skins' |
|---|
| 6 | skinName = 'five' |
|---|
| 7 | skinPath = basePath + '/' + skinName + '/' + skinName + '.xml' |
|---|
| 8 | skinFile = open(skinPath,'r') |
|---|
| 9 | skin = minidom.parse(skinFile) |
|---|
| 10 | components = skin.getElementsByTagName('component') |
|---|
| 11 | for component in components: |
|---|
| 12 | componentName = component.attributes['name'] |
|---|
| 13 | elements = component.getElementsByTagName('element') |
|---|
| 14 | for element in elements: |
|---|
| 15 | elementPath = basePath + '/' + skinName + '/' + componentName.value + '/' + element.attributes['src'].value |
|---|
| 16 | imageText = base64.b64encode(open(elementPath,'rb').read()) |
|---|
| 17 | element.attributes['src'].value = 'data:image/png;base64,' + imageText |
|---|
| 18 | skinText = '\''+skin.toxml()+'\'' |
|---|
| 19 | whiteSpace = re.compile('>(.*?)<', re.S) |
|---|
| 20 | skinText = whiteSpace.sub('><', skinText) |
|---|
| 21 | |
|---|
| 22 | outputPath = skinPath = basePath + '/' + skinName + '/' + skinName + '-min.xml' |
|---|
| 23 | outputFile = open(outputPath,'w') |
|---|
| 24 | outputFile.write(skinText) |
|---|
| 25 | outputFile.close() |
|---|
Note: See
TracBrowser
for help on using the repository browser.