radiaSVG/map_lines.py

28 lines
641 B
Python
Raw Normal View History

2011-06-27 13:53:03 +00:00
import json
def do():
data = json.loads(open("radia.json").read())
ids = json.loads(open("idmapping.json").read())
lines = {}
for i in ids.keys():
if not i.endswith("box"):
lines[i] = []
for d in data:
print d
if data[d].has_key('lines'):
linestring = data[d]['lines']
else:
linestring = ''
theseLines = linestring.split(",")
for t in theseLines:
t = t.strip()
if t != '':
if lines.has_key(t):
lines[t].append(d)
else:
print t
out = open("linemapping.js", "w")
out.write("LINES = " + json.dumps(lines, indent=2))
out.close()