summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum2011-10-08 14:24:13 -0700
committerJosh Blum2011-10-12 15:55:15 -0700
commitbbee6d500f0e47e3543fbaffcef67f0fdbb71e37 (patch)
tree6790f286c73e21dd207813a1401f4e28c783b63e
parent71cb9ff97828abb1ff58916b6dc58e478ac0abd6 (diff)
downloadgnuradio-bbee6d500f0e47e3543fbaffcef67f0fdbb71e37.tar.gz
gnuradio-bbee6d500f0e47e3543fbaffcef67f0fdbb71e37.tar.bz2
gnuradio-bbee6d500f0e47e3543fbaffcef67f0fdbb71e37.zip
grc: append index to duplicated ports
-rw-r--r--grc/python/Block.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 424706d68..4baf36dc6 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -75,22 +75,28 @@ class Block(_Block, _GUIBlock):
"""
_Block.rewrite(self)
+ def rectify(ports):
+ #restore integer contiguity after insertion
+ #rectify the port names with the index
+ for i, port in enumerate(ports):
+ port._key = str(i)
+ port._name = port._n['name']
+ if len(ports) > 1: port._name += str(i)
+
def insert_port(get_ports, get_port, key):
prev_port = get_port(str(int(key)-1))
get_ports().insert(
get_ports().index(prev_port)+1,
prev_port.copy(new_key=key),
)
- #restore integer contiguity after insertion
- for i, port in enumerate(get_ports()): port._key = str(i)
+ rectify(get_ports())
def remove_port(get_ports, get_port, key):
port = get_port(key)
for connection in port.get_connections():
self.get_parent().remove_element(connection)
get_ports().remove(port)
- #restore integer contiguity after insertion
- for i, port in enumerate(get_ports()): port._key = str(i)
+ rectify(get_ports())
#adjust nports
for get_ports, get_port in (