summaryrefslogtreecommitdiff
path: root/grc/core/Port.py
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-07-15 23:25:54 +0200
committerSebastian Koslowski <koslowski@kit.edu>2016-07-29 15:45:07 +0200
commit93ce3961a572da6ec3dbef1f24a22f4153acaa61 (patch)
tree274a78b5ce37f5305818c6ebab7ba495a2da4e12 /grc/core/Port.py
parent36f186bc46f528d95d9186955e91736d1fdb299e (diff)
grc: refactor: Port, Param, Options init clean-up
Diffstat (limited to 'grc/core/Port.py')
-rw-r--r--grc/core/Port.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/grc/core/Port.py b/grc/core/Port.py
index ef6a92c7b1..9030bef375 100644
--- a/grc/core/Port.py
+++ b/grc/core/Port.py
@@ -105,7 +105,7 @@ class Port(Element):
is_port = True
- def __init__(self, block, n, dir):
+ def __init__(self, block, direction, **n):
"""
Make a new port from nested data.
@@ -117,6 +117,7 @@ class Port(Element):
self._n = n
if n['type'] == 'message':
n['domain'] = Constants.GR_MESSAGE_DOMAIN
+
if 'domain' not in n:
n['domain'] = Constants.DEFAULT_DOMAIN
elif n['domain'] == Constants.GR_MESSAGE_DOMAIN:
@@ -125,8 +126,6 @@ class Port(Element):
if n['type'] == 'msg':
n['key'] = 'msg'
- n.setdefault('key', str(next(block.port_counters[dir == 'source'])))
-
# Build the port
Element.__init__(self, parent=block)
# Grab the data
@@ -135,13 +134,12 @@ class Port(Element):
self._type = n.get('type', '')
self.domain = n.get('domain')
self._hide = n.get('hide', '')
- self._dir = dir
+ self._dir = direction
self._hide_evaluated = False # Updated on rewrite()
self._nports = n.get('nports', '')
self._vlen = n.get('vlen', '')
self._optional = bool(n.get('optional'))
- self.di_optional = bool(n.get('optional'))
self._clones = [] # References to cloned ports (for nports > 1)
def __str__(self):
@@ -150,15 +148,12 @@ class Port(Element):
if self.is_sink:
return 'Sink - {}({})'.format(self.get_name(), self.key)
- def get_types(self):
- return list(Constants.TYPE_TO_SIZEOF.keys())
-
def is_type_empty(self):
return not self._n['type']
def validate(self):
Element.validate(self)
- if self.get_type() not in self.get_types():
+ if self.get_type() not in Constants.TYPE_TO_SIZEOF.keys():
self.add_error_message('Type "{}" is not a possible type.'.format(self.get_type()))
platform = self.parent.parent.parent
if self.domain not in platform.domains: