summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
Diffstat (limited to 'grc')
-rw-r--r--grc/base/Param.py13
-rw-r--r--grc/base/Port.py13
-rw-r--r--grc/python/Param.py31
-rw-r--r--grc/python/Port.py8
4 files changed, 35 insertions, 30 deletions
diff --git a/grc/base/Param.py b/grc/base/Param.py
index d1b22454f..21d306592 100644
--- a/grc/base/Param.py
+++ b/grc/base/Param.py
@@ -128,14 +128,12 @@ class Option(Element):
class Param(Element):
- def __init__(self, block, n, types):
+ def __init__(self, block, n):
"""
Make a new param from nested data.
@param block the parent element
@param n the nested odict
- @param types a list of possible types
"""
- self._types = types
#grab the data
self._name = n.find('name')
self._key = n.find('key')
@@ -183,7 +181,7 @@ class Param(Element):
The value must be evaluated and type must a possible type.
"""
Element.validate(self)
- try: assert self.get_type() in self._types
+ try: assert self.get_type() in self.get_types()
except AssertionError: self.add_error_message('Type "%s" is not a possible type.'%self.get_type())
def get_evaluated(self): raise NotImplementedError
@@ -195,6 +193,13 @@ class Param(Element):
"""
raise NotImplementedError
+ def get_types(self):
+ """
+ Get a list of all possible param types.
+ @throw NotImplementedError
+ """
+ raise NotImplementedError
+
def get_color(self): return '#FFFFFF'
def __str__(self): return 'Param - %s(%s)'%(self.get_name(), self.get_key())
def is_param(self): return True
diff --git a/grc/base/Port.py b/grc/base/Port.py
index 81076684a..494ea894f 100644
--- a/grc/base/Port.py
+++ b/grc/base/Port.py
@@ -21,15 +21,13 @@ from Element import Element
class Port(Element):
- def __init__(self, block, n, dir, types):
+ def __init__(self, block, n, dir):
"""
Make a new port from nested data.
@param block the parent element
@param n the nested odict
@param dir the direction source or sink
- @param types a list of possible types
"""
- self._types = types
#build the port
Element.__init__(self, block)
#grab the data
@@ -44,7 +42,7 @@ class Port(Element):
The port must be non-empty and type must a possible type.
"""
Element.validate(self)
- try: assert self.get_type() in self._types
+ try: assert self.get_type() in self.get_types()
except AssertionError: self.add_error_message('Type "%s" is not a possible type.'%self.get_type())
def __str__(self):
@@ -53,6 +51,13 @@ class Port(Element):
if self.is_sink():
return 'Sink - %s(%s)'%(self.get_name(), self.get_key())
+ def get_types(self):
+ """
+ Get a list of all possible port types.
+ @throw NotImplementedError
+ """
+ raise NotImplementedError
+
def is_port(self): return True
def get_color(self): return '#FFFFFF'
def get_name(self): return self._name
diff --git a/grc/python/Param.py b/grc/python/Param.py
index dd18d1c44..d574b513e 100644
--- a/grc/python/Param.py
+++ b/grc/python/Param.py
@@ -83,30 +83,27 @@ COMPLEX_TYPES = tuple(COMPLEX_TYPES + REAL_TYPES + INT_TYPES)
REAL_TYPES = tuple(REAL_TYPES + INT_TYPES)
INT_TYPES = tuple(INT_TYPES)
-##possible param types
-TYPES = [
- 'raw', 'enum',
- 'complex', 'real', 'int',
- 'complex_vector', 'real_vector', 'int_vector',
- 'hex', 'string', 'bool',
- 'file_open', 'file_save',
- 'id', 'stream_id',
- 'grid_pos', 'notebook',
- 'import',
-]
-
class Param(_Param):
- _init = False
- _hostage_cells = list()
-
- def __init__(self, block, n, **kwargs):
+ def __init__(self, block, n):
_Param.__init__(
self,
block=block,
n=n,
- types=TYPES,
)
+ self._init = False
+ self._hostage_cells = list()
+
+ def get_types(self): return (
+ 'raw', 'enum',
+ 'complex', 'real', 'int',
+ 'complex_vector', 'real_vector', 'int_vector',
+ 'hex', 'string', 'bool',
+ 'file_open', 'file_save',
+ 'id', 'stream_id',
+ 'grid_pos', 'notebook',
+ 'import',
+ )
def __repr__(self):
"""
diff --git a/grc/python/Port.py b/grc/python/Port.py
index 3214d937a..a714844ef 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -49,12 +49,9 @@ def _get_source_from_virtual_source_port(vsp, traversed=[]):
)
except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp
-##possible port types
-TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg', '']
-
class Port(_Port):
- def __init__(self, block, n, dir, **kwargs):
+ def __init__(self, block, n, dir):
"""
Make a new port from nested data.
@param block the parent element
@@ -75,12 +72,13 @@ class Port(_Port):
block=block,
n=n,
dir=dir,
- types=TYPES,
)
self._nports = n.find('nports') or ''
self._vlen = n.find('vlen') or ''
self._optional = bool(n.find('optional'))
+ def get_types(self): return ('complex', 'float', 'int', 'short', 'byte', 'msg', '')
+
def validate(self):
_Port.validate(self)
try: assert self.get_enabled_connections() or self.get_optional()