From 4b60db7deaa89a998715b45e942fa0c69dd5be1a Mon Sep 17 00:00:00 2001
From: Sebastian Koslowski <koslowski@kit.edu>
Date: Sat, 18 Jun 2016 21:16:14 -0700
Subject: grc-refactor: the hopeless cause of bus ports...

---
 grc/core/Port.py | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

(limited to 'grc/core/Port.py')

diff --git a/grc/core/Port.py b/grc/core/Port.py
index d0362ffd78..bb1e1fa9f2 100644
--- a/grc/core/Port.py
+++ b/grc/core/Port.py
@@ -363,18 +363,17 @@ class Port(Element):
     def get_associated_ports(self):
         if not self.get_type() == 'bus':
             return [self]
+
+        block = self.parent_block
+        if self.is_source:
+            block_ports = block.sources
+            bus_structure = block.current_bus_structure['source']
         else:
-            flowgraph = self.parent_flowgraph
-            if self.is_source:
-                get_ports = flowgraph.get_sources
-                bus_structure = flowgraph.current_bus_structure['source']
-            else:
-                get_ports = flowgraph.get_sinks
-                bus_structure = flowgraph.current_bus_structure['sink']
-
-            ports = [i for i in get_ports() if not i.get_type() == 'bus']
-            if bus_structure:
-                busses = [i for i in get_ports() if i.get_type() == 'bus']
-                bus_index = busses.index(self)
-                ports = [a for a in ports if ports.index(a) in bus_structure[bus_index]]
-            return ports
+            block_ports = block.sinks
+            bus_structure = block.current_bus_structure['sink']
+
+        ports = [i for i in block_ports if not i.get_type() == 'bus']
+        if bus_structure:
+            bus_index = [i for i in block_ports if i.get_type() == 'bus'].index(self)
+            ports = [p for i, p in enumerate(ports) if i in bus_structure[bus_index]]
+        return ports
-- 
cgit v1.2.3