diff options
Diffstat (limited to 'grc/core')
-rw-r--r-- | grc/core/Block.py | 16 | ||||
-rw-r--r-- | grc/core/Element.py | 5 | ||||
-rw-r--r-- | grc/core/FlowGraph.py | 18 |
3 files changed, 21 insertions, 18 deletions
diff --git a/grc/core/Block.py b/grc/core/Block.py index c2111fe1bb..ab4174ce66 100644 --- a/grc/core/Block.py +++ b/grc/core/Block.py @@ -30,7 +30,6 @@ from . Constants import ( BLOCK_ENABLED, BLOCK_BYPASSED, BLOCK_DISABLED ) from . Element import Element -from . FlowGraph import _variable_matcher def _get_keys(lst): @@ -149,15 +148,16 @@ class Block(Element): # indistinguishable from normal GR blocks. Make explicit # checks for them here since they have no work function or # buffers to manage. - is_virtual_or_pad = self._key in ( + self.is_virtual_or_pad = self._key in ( "virtual_source", "virtual_sink", "pad_source", "pad_sink") - is_variable = self._key.startswith('variable') + self.is_variable = self._key.startswith('variable') + self.is_import = (self._key == 'import') # Disable blocks that are virtual/pads or variables - if is_virtual_or_pad or is_variable: + if self.is_virtual_or_pad or self.is_variable: self._flags += BLOCK_FLAG_DISABLE_BYPASS - if not (is_virtual_or_pad or is_variable or self._key == 'options'): + if not (self.is_virtual_or_pad or self.is_variable or self._key == 'options'): self.get_params().append(self.get_parent().get_parent().Param( block=self, n=odict({'name': 'Block Alias', @@ -168,7 +168,7 @@ class Block(Element): }) )) - if (len(sources) or len(sinks)) and not is_virtual_or_pad: + if (len(sources) or len(sinks)) and not self.is_virtual_or_pad: self.get_params().append(self.get_parent().get_parent().Param( block=self, n=odict({'name': 'Core Affinity', @@ -178,7 +178,7 @@ class Block(Element): 'tab': ADVANCED_PARAM_TAB }) )) - if len(sources) and not is_virtual_or_pad: + if len(sources) and not self.is_virtual_or_pad: self.get_params().append(self.get_parent().get_parent().Param( block=self, n=odict({'name': 'Min Output Buffer', @@ -253,7 +253,7 @@ class Block(Element): self.add_error_message('Check "{}" did not evaluate.'.format(check)) # For variables check the value (only if var_value is used - if _variable_matcher.match(self.get_key()) and self._var_value != '$value': + if self.is_variable and self._var_value != '$value': value = self._var_value try: value = self.get_var_value() diff --git a/grc/core/Element.py b/grc/core/Element.py index b96edb0a72..67c36e12b4 100644 --- a/grc/core/Element.py +++ b/grc/core/Element.py @@ -100,6 +100,7 @@ class Element(object): is_flow_graph = False is_block = False + is_dummy_block = False is_connection = False @@ -107,3 +108,7 @@ class Element(object): is_port = False is_param = False + + is_variable = False + + is_import = False diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py index 2f33baf8d0..949eecaa71 100644 --- a/grc/core/FlowGraph.py +++ b/grc/core/FlowGraph.py @@ -18,7 +18,7 @@ import imp import time from itertools import ifilter, chain -from operator import methodcaller +from operator import methodcaller, attrgetter import re @@ -27,7 +27,6 @@ from .Constants import FLOW_GRAPH_FILE_FORMAT_VERSION from .Element import Element from .utils import odict, expr_utils -_variable_matcher = re.compile('^(variable\w*)$') _parameter_matcher = re.compile('^(parameter)$') _monitors_searcher = re.compile('(ctrlport_monitor)') _bussink_searcher = re.compile('^(bus_sink)$') @@ -72,32 +71,31 @@ class FlowGraph(Element): ############################################## def get_imports(self): """ - Get a set of all import statments in this flow graph namespace. + Get a set of all import statements in this flow graph namespace. Returns: a set of import statements """ - imports = sum([block.get_imports() for block in self.get_enabled_blocks()], []) - imports = sorted(set(imports)) - return imports + imports = sum([block.get_imports() for block in self.iter_enabled_blocks()], []) + return sorted(set(imports)) def get_variables(self): """ Get a list of all variables in this flow graph namespace. - Exclude paramterized variables. + Exclude parameterized variables. Returns: a sorted list of variable blocks in order of dependency (indep -> dep) """ - variables = filter(lambda b: _variable_matcher.match(b.get_key()), self.iter_enabled_blocks()) + variables = filter(attrgetter('is_variable'), self.iter_enabled_blocks()) return expr_utils.sort_objects(variables, methodcaller('get_id'), methodcaller('get_var_make')) def get_parameters(self): """ - Get a list of all paramterized variables in this flow graph namespace. + Get a list of all parameterized variables in this flow graph namespace. Returns: - a list of paramterized variables + a list of parameterized variables """ parameters = filter(lambda b: _parameter_matcher.match(b.get_key()), self.iter_enabled_blocks()) return parameters |