Skip to content

Commit 2bdc518

Browse files
committed
Calculate paths with one less assumption -- still assuming that we're operating
in a checkout-like layout, but no assuming what path we're operating from.
1 parent 0adcd10 commit 2bdc518

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

scripts/buildout.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
develop = .
33
bin-directory = ./bin
44
parts = cc.image_tools
5+
prefer-final=true
56

67
[cc.image_tools]
78
recipe = zc.recipe.egg

scripts/cc/image_tools/imgsplat.py

+22-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
NS_CC = Namespace("http://creativecommons.org/ns#")
1818
NS_RDF = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
1919

20+
def checkout_base():
21+
"""Return the base destination path. Note that this assumes you're
22+
running the tool from a Subversion checkout (or that your filesystem
23+
layout is the same as our repository)."""
24+
25+
26+
return os.path.abspath(
27+
os.path.join(os.path.dirname(__file__), '..', '..', '..')
28+
)
29+
2030
def load_graph(filename):
2131
"""Load the specified filename; return a graph."""
2232

@@ -33,10 +43,13 @@ def load_graph(filename):
3343
def copyto(source, dest, code, size, jurisdiction, money):
3444
if (not os.access(dest, os.F_OK)):
3545
os.makedirs(dest)
36-
dest += size+'.png'
46+
47+
dest = os.path.join(dest, size + '.png')
48+
3749
if string.find(code, 'nc') != -1 and money.has_key(jurisdiction):
3850
source += '_'+money[jurisdiction]
3951
source += '.png'
52+
4053
try:
4154
shutil.copy2(source, dest)
4255
except:
@@ -65,7 +78,9 @@ def splat(license_graph):
6578
code = m.group(1)
6679
version = m.group(3)
6780
jurisdiction = m.group(5)
68-
dest = '../www/l/'+code+'/'
81+
82+
dest = os.path.join(checkout_base(), 'www', 'l', code)
83+
6984
code2 = code
7085
size = '88x31'
7186
if (code == 'by-nd-nc'):
@@ -75,12 +90,13 @@ def splat(license_graph):
7590
elif (code == 'LGPL' or code == 'GPL'):
7691
size = '88x62'
7792
if (version):
78-
dest += version+'/'
93+
dest = os.path.join(dest, version)
7994
if (jurisdiction):
80-
dest += jurisdiction+'/'
81-
source = '../base-images/'+size+'/'+code2
95+
dest = os.path.join(dest, jurisdiction)
96+
97+
source = os.path.join(checkout_base(), 'base-images', size, code2)
8298
copyto(source, dest, code, size, jurisdiction, money)
83-
source = '../base-images/'+'80x15'+'/'+code2
99+
source = os.path.join(checkout_base(), 'base-images', '80x15', code2)
84100
copyto(source, dest, code, '80x15', '', money)
85101

86102
def cli():

0 commit comments

Comments
 (0)