Skip to content

Commit bbaba5d

Browse files
author
mlinksva
committed
files for i.creativecommons.org
0 parents  commit bbaba5d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

scripts/imgsplat.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
imgsplat.py
3+
4+
Requires lxml (http://codespeak.net/lxml).
5+
6+
(c) 2006 Creative Commons.
7+
"""
8+
9+
__version__ = 0.1
10+
11+
import lxml.etree
12+
13+
import re
14+
import string
15+
16+
def splat(instream):
17+
18+
money = { 'es': 'euro', 'jp': 'yen' }
19+
20+
licenses = lxml.etree.parse(instream)
21+
uris = licenses.xpath('//jurisdiction/version/@uri')
22+
for uri in uris:
23+
print uri
24+
m = re.search('http://creativecommons.org/licenses/(.*?)/((.*?)/((.*?)/)?)?', uri)
25+
code = m.group(1)
26+
version = m.group(3)
27+
jurisdiction = m.group(5)
28+
dest = '../www/l/'+code+'/'
29+
source = code
30+
if (version):
31+
dest += version+'/'
32+
if (jurisdiction):
33+
dest += jurisdiction+'/'
34+
dest += '88x31.png'
35+
print dest
36+
#if string.find(code, 'nc') != -1 and money.has_key(jurisdiction):
37+
# source += '_'+money[jurisdiction]
38+
source += '.png'
39+
print source
40+
41+
if __name__ == '__main__':
42+
splat(file('api_xml/licenses.xml'))

0 commit comments

Comments
 (0)