summaryrefslogtreecommitdiff
path: root/grc/core
diff options
context:
space:
mode:
authorJosh Morman <jmorman@perspectalabs.com>2019-07-19 10:33:24 -0400
committerMarcus Müller <marcus@hostalia.de>2019-07-21 22:35:52 +0200
commit5033717a6d87b9806adc7a281b32cf60f0d66085 (patch)
tree97b09d60a62d4a7cc5196406456e10ac71721a36 /grc/core
parent94d5dacf372e92a5b3c79314392f29e9b209ff79 (diff)
grc: clean up todos from busports
Couple of leftover todos from the copy of busports code from 3.7
Diffstat (limited to 'grc/core')
-rw-r--r--grc/core/blocks/block.py10
-rw-r--r--grc/core/ports/port.py9
2 files changed, 10 insertions, 9 deletions
diff --git a/grc/core/blocks/block.py b/grc/core/blocks/block.py
index 29976af282..6fd2c68667 100644
--- a/grc/core/blocks/block.py
+++ b/grc/core/blocks/block.py
@@ -91,7 +91,7 @@ class Block(Element):
if 'cpp' in self.flags:
self.orig_cpp_templates = self.cpp_templates # The original template, in case we have to edit it when transpiling to C++
- self.current_bus_structure = {'source': '', 'sink': ''}
+ self.current_bus_structure = {'source': None, 'sink': None}
def get_bus_structure(self, direction):
if direction == 'source':
@@ -100,13 +100,13 @@ class Block(Element):
bus_structure = self.bus_structure_sink
if not bus_structure:
- return '' # TODO: Don't like empty strings. should change this to None eventually
+ return None
try:
clean_bus_structure = self.evaluate(bus_structure)
return clean_bus_structure
except:
- return ''
+ return None
# region Rewrite_and_Validation
@@ -147,12 +147,10 @@ class Block(Element):
if direc == 'source':
ports = self.sources
ports_gui = self.filter_bus_port(self.sources)
- bus_structure = self.get_bus_structure('source')
bus_state = self.bus_source
else:
ports = self.sinks
- ports_gui = self.filter_bus_port(self.sinks)
- bus_structure = self.get_bus_structure('sink')
+ ports_gui = self.filter_bus_port(self.sinks)
bus_state = self.bus_sink
# Remove the bus ports
diff --git a/grc/core/ports/port.py b/grc/core/ports/port.py
index dcaca5cbc5..c9d38fd9e0 100644
--- a/grc/core/ports/port.py
+++ b/grc/core/ports/port.py
@@ -48,12 +48,15 @@ class Port(Element):
if not label:
label = id if not id.isdigit() else {'sink': 'in', 'source': 'out'}[direction]
if dtype == 'bus':
- #TODO - add some error checking in here
+ # Look for existing busses to give proper index
busses = [p for p in self.parent.ports() if p._dir == self._dir and p.dtype == 'bus']
bus_structure = self.parent.current_bus_structure[self._dir]
bus_index = len(busses)
- number = str(len(busses)) + '#' + str(len(bus_structure[bus_index]))
- label = dtype + number
+ if len(bus_structure) > bus_index:
+ number = str(len(busses)) + '#' + str(len(bus_structure[bus_index]))
+ label = dtype + number
+ else:
+ raise ValueError('Could not initialize bus port due to incompatible bus structure')
self.name = self._base_name = label