diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-07-20 13:45:06 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-07-29 15:45:07 +0200 |
commit | 89b09aaf80b8210c2ea4b3da712bfcfbb571a60a (patch) | |
tree | 52f6473f4cfd384803dc6a38f686aad0ff1442cd /grc/core/Connection.py | |
parent | 3d322e9ce4083137377fe8798accc91c8dc8bb67 (diff) |
grc: refactor: some more bus ports stuff
Diffstat (limited to 'grc/core/Connection.py')
-rw-r--r-- | grc/core/Connection.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/grc/core/Connection.py b/grc/core/Connection.py index 7820603360..aec7a217b3 100644 --- a/grc/core/Connection.py +++ b/grc/core/Connection.py @@ -56,7 +56,10 @@ class Connection(Element): if connection.source_port is source and connection.sink_port is sink: raise LookupError('This connection between source and sink is not unique.') - self._make_bus_connect() + if self.is_bus(): + self._make_bus_connect() + else: + self.parent_flowgraph.connect(source, sink) @staticmethod def _get_sink_source(porta, portb): @@ -82,7 +85,7 @@ class Connection(Element): return self.source_port.get_type() == self.sink_port.get_type() == 'msg' def is_bus(self): - return self.source_port.get_type() == self.sink_port.get_type() == 'bus' + return self.source_port.get_type() == 'bus' def validate(self): """ @@ -159,18 +162,13 @@ class Connection(Element): def _make_bus_connect(self): source, sink = self.source_port, self.sink_port - if (source.get_type() == 'bus') != (sink.get_type() == 'bus'): + if source.get_type() == sink.get_type() == 'bus': raise ValueError('busses must get with busses') - if not len(source.get_associated_ports()) == len(sink.get_associated_ports()): + sources = source.get_associated_ports() + sinks = sink.get_associated_ports() + if len(sources) != len(sinks): raise ValueError('port connections must have same cardinality') - if source.get_type() == 'bus': - sources = source.get_associated_ports() - sinks = sink.get_associated_ports() - - for i in range(len(sources)): - try: - self.parent_flowgraph.connect(sources[i], sinks[i]) - except: - pass + for ports in zip(sources, sinks): + self.parent_flowgraph.connect(*ports) |