summaryrefslogtreecommitdiff
path: root/grc/python/Block.py
diff options
context:
space:
mode:
Diffstat (limited to 'grc/python/Block.py')
-rw-r--r--grc/python/Block.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 957fee18e..47fe13a3c 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -66,16 +66,16 @@ class Block(_Block):
except AssertionError: self.add_error_message('Check "%s" failed.'%check)
except: self.add_error_message('Check "%s" did not evaluate.'%check)
#adjust nports
- for ports, Port in (
- (self._sources, self.get_parent().get_parent().Source),
- (self._sinks, self.get_parent().get_parent().Sink),
+ for get_ports, get_port in (
+ (self.get_sources, self.get_source),
+ (self.get_sinks, self.get_sink),
):
- #how many ports?
- num_ports = len(ports)
+ #how many streaming (non-message) ports?
+ num_ports = len(filter(lambda p: p.get_type() != 'msg', get_ports()))
#do nothing for 0 ports
if not num_ports: continue
#get the nports setting
- port0 = ports[str(0)]
+ port0 = get_port(str(0))
nports = port0.get_nports()
#do nothing for no nports
if not nports: continue
@@ -85,19 +85,21 @@ class Block(_Block):
if nports < num_ports:
#remove the connections
for key in map(str, range(nports, num_ports)):
- port = ports[key]
+ port = get_port(key)
for connection in port.get_connections():
self.get_parent().remove_element(connection)
#remove the ports
- for key in map(str, range(nports, num_ports)): ports.pop(key)
+ for key in map(str, range(nports, num_ports)):
+ get_ports().remove(get_port(key))
continue
#add more ports
if nports > num_ports:
for key in map(str, range(num_ports, nports)):
- n = port0._n
- n['key'] = key
- port = Port(self, n)
- ports[key] = port
+ prev_port = get_port(str(int(key)-1))
+ get_ports().insert(
+ get_ports().index(prev_port)+1,
+ prev_port.copy(new_key=key),
+ )
continue
def port_controller_modify(self, direction):