TODO: explain template data format.
"""
- def __init__(self, template_dir='/usr/share/pyrisk/templates/'):
+ def __init__(self, template_dir='share/templates/'):
self.template_dir = os.path.abspath(os.path.expanduser(template_dir))
def get(self, name):
region_pointlists,route_pointlists = self._get_pointlists(name)
name,extension = filename.rsplit('.', 1)
if extension == 'reg':
region_pointlists[name] = self._read_file(path)
- elif extension == 'rt':
- route_pointlists[name] = self._read_file(path)
+ elif extension in ['rt', 'vrt']:
+ route_pointlists[name] = (self._read_file(path),
+ extension == 'vrt')
return (region_pointlists, route_pointlists)
def _read_file(self, filename):
pointlist = []
all_boundaries, pointlist)
regions.append(Region(name, boundaries, head_to_tail))
r = regions[-1]
- for name,pointlist in route_pointlists.items():
+ for name,v_pointlist in route_pointlists.items():
+ pointlist,virtual = v_pointlist
boundaries,head_to_tail = self._pointlist_to_array_of_boundaries(
all_boundaries, pointlist)
assert len(boundaries) == 1, boundaries
route = boundaries[0]
+ route.virtual = virtual
for terminal in [route[0], route[-1]]:
for r in regions:
for point in r.outline:
self.starts.append(pos)
for p in new:
points.append(pos+p)
- assert points[-1] == points[0], points
+ assert points[-1] == points[0], '%s: %s' % (self.name, points)
self.outline = points
def locate_routes(self):
self.route_starts = []
for p in r.outline[:-1]])
])
for rt,rt_start in zip(r.routes, r.route_starts):
- if id(rt) in drawn_rts:
+ if id(rt) in drawn_rts or rt.virtual == True:
continue
drawn_rts[id(rt)] = rt
lines.extend([