33 lines
743 B
Python
33 lines
743 B
Python
#!/usr/bin/python3
|
|
|
|
import json
|
|
import sys
|
|
|
|
|
|
def loadColorTables(fn = 'colortables.json'):
|
|
with open(fn) as f:
|
|
return json.loads(f.read())
|
|
|
|
def readSrcSvg(fn = 'franconianNet.svg'):
|
|
with open(fn) as f:
|
|
return f.read()
|
|
|
|
def replaceColors(svg, table):
|
|
for mapping in table:
|
|
svg = svg.replace(mapping[0], mapping[1])
|
|
return svg
|
|
|
|
def genAll(srcFN = 'franconianNet.svg', tablesFN='colortables.json'):
|
|
tables = loadColorTables(tablesFN)
|
|
src = readSrcSvg(srcFN)
|
|
|
|
for name in tables:
|
|
repl = replaceColors(src , tables[name])
|
|
with open(srcFN.split(".")[0]+"_"+name+".svg", "w") as fo:
|
|
fo.write(repl)
|
|
|
|
if __name__ == "__main__":
|
|
genAll(sys.argv[1], sys.argv[2])
|
|
|
|
|