flow/network: better determination of plumbing layout

This commit is contained in:
Sebastien Bourdeauducq 2013-05-01 22:13:26 +02:00
parent 471393d0f9
commit 8ffa273719
1 changed files with 10 additions and 8 deletions

View File

@ -151,24 +151,26 @@ class DataFlowGraph(MultiDiGraph):
if not ap: if not ap:
break break
for a in ap: for a in ap:
if a.actor_class in plumbing.layout_sink: in_edges = self.in_edges(a, data=True)
edges = self.in_edges(a, data=True) out_edges = self.out_edges(a, data=True)
assert(len(edges) == 1) if a.actor_class in plumbing.layout_sink and len(in_edges) == 1:
other, me, data = edges[0] other, me, data = in_edges[0]
if isinstance(other, AbstractActor): if isinstance(other, AbstractActor):
continue continue
other_ep = data["source"] other_ep = data["source"]
if other_ep is None: if other_ep is None:
other_ep = get_single_ep(other, Source)[1] other_ep = get_single_ep(other, Source)[1]
elif a.actor_class in plumbing.layout_source: else:
edges = self.out_edges(a, data=True) other_ep = getattr(other, other_ep)
assert(len(edges) == 1) elif a.actor_class in plumbing.layout_source and len(out_edges) == 1:
me, other, data = edges[0] me, other, data = out_edges[0]
if isinstance(other, AbstractActor): if isinstance(other, AbstractActor):
continue continue
other_ep = data["sink"] other_ep = data["sink"]
if other_ep is None: if other_ep is None:
other_ep = get_single_ep(other, Sink)[1] other_ep = get_single_ep(other, Sink)[1]
else:
other_ep = getattr(other, other_ep)
else: else:
raise AssertionError raise AssertionError
layout = other_ep.payload.layout layout = other_ep.payload.layout