radiaSVG/map_lines.py

28 lines
662 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())
2011-06-27 17:17:39 +00:00
ids = json.loads(open("idmapping.js").read().replace("RIDS = ", ""))
2011-06-27 13:53:03 +00:00
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()