diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-07-22 10:08:54 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-07-29 15:45:08 +0200 |
commit | 6f067a5029baaf4be8fcb39c6b22729a0a9e946b (patch) | |
tree | 251b9d51f63210cc879254b185b205b608f85801 /grc/core/Connection.py | |
parent | 6b99b6fded94ae1ed8421c624246362e7925fb08 (diff) |
grc: various clean-ups and fixes
Diffstat (limited to 'grc/core/Connection.py')
-rw-r--r-- | grc/core/Connection.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/grc/core/Connection.py b/grc/core/Connection.py index 6be1ccb2aa..63c6a94571 100644 --- a/grc/core/Connection.py +++ b/grc/core/Connection.py @@ -31,7 +31,7 @@ class Connection(Element): is_connection = True - def __init__(self, flow_graph, porta, portb): + def __init__(self, parent, porta, portb): """ Make a new connection given the parent and 2 ports. @@ -44,7 +44,7 @@ class Connection(Element): Returns: a new connection """ - Element.__init__(self, flow_graph) + Element.__init__(self, parent) source, sink = self._get_sink_source(porta, portb) @@ -52,14 +52,16 @@ class Connection(Element): self.sink_port = sink # Ensure that this connection (source -> sink) is unique - for connection in flow_graph.connections: - if connection.source_port is source and connection.sink_port is sink: - raise LookupError('This connection between source and sink is not unique.') + if self in self.parent_flowgraph.connections: + raise LookupError('This connection between source and sink is not unique.') if self.is_bus(): self._make_bus_connect() - else: - self.parent_flowgraph.connect(source, sink) + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return self.source_port == other.source_port and self.sink_port == other.sink_port @staticmethod def _get_sink_source(porta, portb): @@ -68,7 +70,7 @@ class Connection(Element): for port in (porta, portb): if port.is_source: source = port - else: + if port.is_sink: sink = port if not source: raise ValueError('Connection could not isolate source') @@ -110,10 +112,6 @@ class Connection(Element): Validate the connections. The ports must match in io size. """ - """ - Validate the connections. - The ports must match in type. - """ Element.validate(self) platform = self.parent_platform |