diff options
-rw-r--r-- | grc/core/Block.py | 49 | ||||
-rw-r--r-- | grc/core/Connection.py | 4 | ||||
-rw-r--r-- | grc/core/FlowGraph.py | 24 | ||||
-rw-r--r-- | grc/core/Param.py | 45 | ||||
-rw-r--r-- | grc/core/Platform.py | 4 | ||||
-rw-r--r-- | grc/core/Port.py | 23 | ||||
-rw-r--r-- | grc/core/generator/FlowGraphProxy.py | 6 | ||||
-rw-r--r-- | grc/core/generator/Generator.py | 4 | ||||
-rw-r--r-- | grc/core/generator/flow_graph.tmpl | 4 | ||||
-rw-r--r-- | grc/core/utils/complexity.py | 2 | ||||
-rw-r--r-- | grc/gui/ActionHandler.py | 4 | ||||
-rw-r--r-- | grc/gui/Block.py | 4 | ||||
-rw-r--r-- | grc/gui/BlockTreeWindow.py | 4 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 2 | ||||
-rw-r--r-- | grc/gui/MainWindow.py | 2 | ||||
-rw-r--r-- | grc/gui/Param.py | 4 | ||||
-rw-r--r-- | grc/gui/ParamWidgets.py | 2 | ||||
-rw-r--r-- | grc/gui/PropsDialog.py | 2 | ||||
-rw-r--r-- | grc/gui/VariableEditor.py | 8 |
19 files changed, 90 insertions, 107 deletions
diff --git a/grc/core/Block.py b/grc/core/Block.py index 503f1e66d4..be685ad65b 100644 --- a/grc/core/Block.py +++ b/grc/core/Block.py @@ -38,7 +38,7 @@ from . Element import Element def _get_keys(lst): - return [elem.get_key() for elem in lst] + return [elem.key for elem in lst] def _get_elem(lst, key): @@ -69,7 +69,7 @@ class Block(Element): Element.__init__(self, parent=flow_graph) self.name = n['name'] - self._key = n['key'] + self.key = n['key'] self.category = [cat.strip() for cat in n.get('category', '').split('/') if cat.strip()] self._flags = n.get('flags', '') self._doc = n.get('doc', '').strip('\n').replace('\\\n', '') @@ -124,16 +124,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. - self.is_virtual_or_pad = is_virtual_or_pad = self._key in ( + self.is_virtual_or_pad = is_virtual_or_pad = self.key in ( "virtual_source", "virtual_sink", "pad_source", "pad_sink") - self.is_variable = is_variable = self._key.startswith('variable') - self.is_import = (self._key == 'import') + self.is_variable = is_variable = self.key.startswith('variable') + self.is_import = (self.key == 'import') # Disable blocks that are virtual/pads or variables 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 (is_virtual_or_pad or is_variable or self.key == 'options'): self._add_param(key='alias', name='Block Alias', type='string', hide='part', tab=ADVANCED_PARAM_TAB) @@ -147,10 +147,10 @@ class Block(Element): self._add_param(key='maxoutbuf', name='Max Output Buffer', type='int', hide='part', value='0', tab=ADVANCED_PARAM_TAB) - param_keys = set(param.get_key() for param in self._params) + param_keys = set(param.key for param in self._params) for param_n in params_n: param = self.parent_platform.Param(block=self, n=param_n) - key = param.get_key() + key = param.key if key in param_keys: raise Exception('Key "{}" already exists in params'.format(key)) param_keys.add(key) @@ -165,7 +165,7 @@ class Block(Element): port_keys = set() for port_n in ports_n: port = port_cls(block=self, n=port_n, dir=direction) - key = port.get_key() + key = port.key if key in port_keys: raise Exception('Key "{}" already exists in {}'.format(key, direction)) port_keys.add(key) @@ -227,7 +227,7 @@ class Block(Element): """ Element.rewrite(self) # Check and run any custom rewrite function for this block - getattr(self, 'rewrite_' + self._key, lambda: None)() + getattr(self, 'rewrite_' + self.key, lambda: None)() # Adjust nports, disconnect hidden ports for ports in (self.get_sources(), self.get_sinks()): @@ -254,9 +254,9 @@ class Block(Element): self.back_ofthe_bus(ports) # Renumber non-message/message ports domain_specific_port_index = collections.defaultdict(int) - for port in [p for p in ports if p.get_key().isdigit()]: + for port in [p for p in ports if p.key.isdigit()]: domain = port.get_domain() - port._key = str(domain_specific_port_index[domain]) + port.key = str(domain_specific_port_index[domain]) domain_specific_port_index[domain] += 1 def get_imports(self, raw=False): @@ -300,10 +300,10 @@ class Block(Element): return [make_callback(c) for c in self._callbacks] def is_virtual_sink(self): - return self.get_key() == 'virtual_sink' + return self.key == 'virtual_sink' def is_virtual_source(self): - return self.get_key() == 'virtual_source' + return self.key == 'virtual_source' ########################################################################### # Custom rewrite functions @@ -349,7 +349,7 @@ class Block(Element): params = {} for param in list(self._params): if hasattr(param, '__epy_param__'): - params[param.get_key()] = param + params[param.key] = param self._params.remove(param) for key, value in blk_io.params: @@ -372,7 +372,7 @@ class Block(Element): reuse_port = ( port_current is not None and port_current.get_type() == port_type and - (key.isdigit() or port_current.get_key() == key) + (key.isdigit() or port_current.key == key) ) if reuse_port: ports_to_remove.remove(port_current) @@ -398,7 +398,7 @@ class Block(Element): @property def documentation(self): - documentation = self.parent_platform.block_docstrings.get(self.get_key(), {}) + documentation = self.parent_platform.block_docstrings.get(self.key, {}) from_xml = self._doc.strip() if from_xml: documentation[''] = from_xml @@ -492,14 +492,11 @@ class Block(Element): return True def __str__(self): - return 'Block - {} - {}({})'.format(self.get_id(), self.name, self.get_key()) + return 'Block - {} - {}({})'.format(self.get_id(), self.name, self.key) def get_id(self): return self.get_param('id').get_value() - def get_key(self): - return self._key - def get_ports(self): return self.get_sources() + self.get_sinks() @@ -597,7 +594,7 @@ class Block(Element): tmpl = str(tmpl) if '$' not in tmpl: return tmpl - n = dict((param.get_key(), param.template_arg) + n = dict((param.key, param.template_arg) for param in self.get_params()) # TODO: cache that try: return str(Template(tmpl, n)) @@ -622,7 +619,7 @@ class Block(Element): for param in [p for p in self.get_params() if p.is_enum()]: children = self.get_ports() + self.get_params() # Priority to the type controller - if param.get_key() in ' '.join([p._type for p in children]): type_param = param + if param.key in ' '.join([p._type for p in children]): type_param = param # Use param if type param is unset if not type_param: type_param = param @@ -653,7 +650,7 @@ class Block(Element): nports_str = ' '.join([port._nports for port in self.get_ports()]) # Modify all params whose keys appear in the nports string for param in self.get_params(): - if param.is_enum() or param.get_key() not in nports_str: + if param.is_enum() or param.key not in nports_str: continue # Try to increment the port controller by direction try: @@ -677,7 +674,7 @@ class Block(Element): a nested data odict """ n = collections.OrderedDict() - n['key'] = self.get_key() + n['key'] = self.key n['param'] = [p.export_data() for p in sorted(self.get_params(), key=str)] if 'bus' in [a.get_type() for a in self.get_sinks()]: n['bus_sink'] = str(1) @@ -698,7 +695,7 @@ class Block(Element): n: the nested data odict """ params_n = n.get('param', []) - params = dict((param.get_key(), param) for param in self._params) + params = dict((param.key, param) for param in self._params) def get_hash(): return hash(tuple(map(hash, self._params))) diff --git a/grc/core/Connection.py b/grc/core/Connection.py index 52cba4257c..44e3b6b5d8 100644 --- a/grc/core/Connection.py +++ b/grc/core/Connection.py @@ -152,8 +152,8 @@ class Connection(Element): n = collections.OrderedDict() n['source_block_id'] = self.source_block.get_id() n['sink_block_id'] = self.sink_block.get_id() - n['source_key'] = self.source_port.get_key() - n['sink_key'] = self.sink_port.get_key() + n['source_key'] = self.source_port.key + n['sink_key'] = self.sink_port.key return n def _make_bus_connect(self): diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py index 67e86f3e6e..03a08baacc 100644 --- a/grc/core/FlowGraph.py +++ b/grc/core/FlowGraph.py @@ -96,24 +96,24 @@ class FlowGraph(Element): Returns: a list of parameterized variables """ - parameters = [b for b in self.iter_enabled_blocks() if _parameter_matcher.match(b.get_key())] + parameters = [b for b in self.iter_enabled_blocks() if _parameter_matcher.match(b.key)] return parameters def get_monitors(self): """ Get a list of all ControlPort monitors """ - monitors = [b for b in self.iter_enabled_blocks() if _monitors_searcher.search(b.get_key())] + monitors = [b for b in self.iter_enabled_blocks() if _monitors_searcher.search(b.key)] return monitors def get_python_modules(self): """Iterate over custom code block ID and Source""" for block in self.iter_enabled_blocks(): - if block.get_key() == 'epy_module': + if block.key == 'epy_module': yield block.get_id(), block.get_param('source_code').get_value() def get_bussink(self): - bussink = [b for b in self.get_enabled_blocks() if _bussink_searcher.search(b.get_key())] + bussink = [b for b in self.get_enabled_blocks() if _bussink_searcher.search(b.key)] for i in bussink: for j in i.get_params(): @@ -122,7 +122,7 @@ class FlowGraph(Element): return False def get_bussrc(self): - bussrc = [b for b in self.get_enabled_blocks() if _bussrc_searcher.search(b.get_key())] + bussrc = [b for b in self.get_enabled_blocks() if _bussrc_searcher.search(b.key)] for i in bussrc: for j in i.get_params(): @@ -131,11 +131,11 @@ class FlowGraph(Element): return False def get_bus_structure_sink(self): - bussink = [b for b in self.get_enabled_blocks() if _bus_struct_sink_searcher.search(b.get_key())] + bussink = [b for b in self.get_enabled_blocks() if _bus_struct_sink_searcher.search(b.key)] return bussink def get_bus_structure_src(self): - bussrc = [b for b in self.get_enabled_blocks() if _bus_struct_src_searcher.search(b.get_key())] + bussrc = [b for b in self.get_enabled_blocks() if _bus_struct_src_searcher.search(b.key)] return bussrc def iter_enabled_blocks(self): @@ -346,8 +346,8 @@ class FlowGraph(Element): """ # sort blocks and connections for nicer diffs blocks = sorted(self.blocks, key=lambda b: ( - b.get_key() != 'options', # options to the front - not b.get_key().startswith('variable'), # then vars + b.key != 'options', # options to the front + not b.key.startswith('variable'), # then vars str(b) )) connections = sorted(self.connections, key=str) @@ -416,7 +416,7 @@ class FlowGraph(Element): def verify_and_get_port(key, block, dir): ports = block.get_sinks() if dir == 'sink' else block.get_sources() for port in ports: - if key == port.get_key(): + if key == port.key: break if not key.isdigit() and port.get_type() == '' and key == port.get_name(): break @@ -527,7 +527,7 @@ def _update_old_message_port_keys(source_key, sink_key, source_block, sink_block source_port = source_block.get_sources()[int(source_key)] sink_port = sink_block.get_sinks()[int(sink_key)] if source_port.get_type() == "message" and sink_port.get_type() == "message": - source_key, sink_key = source_port.get_key(), sink_port.get_key() + source_key, sink_key = source_port.key, sink_port.key except (ValueError, IndexError): pass return source_key, sink_key # do nothing @@ -555,7 +555,7 @@ def _initialize_dummy_block(block, block_n): Modify block object to get the behaviour for a missing block """ - block._key = block_n.get('key') + block.key = block_n.get('key') block.is_dummy_block = lambda: True block.is_valid = lambda: False block.get_enabled = lambda: False diff --git a/grc/core/Param.py b/grc/core/Param.py index 35bb176744..23e9daa656 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -41,17 +41,6 @@ _check_id_matcher = re.compile('^[a-z|A-Z]\w*$') _show_id_matcher = re.compile('^(variable\w*|parameter|options|notebook)$') -def _get_keys(lst): - return [elem.get_key() for elem in lst] - - -def _get_elem(lst, key): - try: - return lst[_get_keys(lst).index(key)] - except ValueError: - raise ValueError('Key "{}" not found in {}.'.format(key, _get_keys(lst))) - - def num_to_str(num): """ Display logic for numbers """ def eng_notation(value, fmt='g'): @@ -80,7 +69,7 @@ class Option(Element): def __init__(self, param, n): Element.__init__(self, param) self._name = n.get('name') - self._key = n.get('key') + self.key = n.get('key') self._opts = dict() opts = n.get('opt', []) # Test against opts when non enum @@ -100,13 +89,13 @@ class Option(Element): self._opts[key] = value def __str__(self): - return 'Option {}({})'.format(self.get_name(), self.get_key()) + return 'Option {}({})'.format(self.get_name(), self.key) def get_name(self): return self._name def get_key(self): - return self._key + return self.key ############################################## # Access Opts @@ -164,7 +153,7 @@ class Param(Element): self._n = n # Parse the data self._name = n['name'] - self._key = n['key'] + self.key = n['key'] value = n.get('value', '') self._type = n.get('type', 'raw') self._hide = n.get('hide', '') @@ -178,7 +167,7 @@ class Param(Element): self._evaluated = None for o_n in n.get('option', []): option = Option(param=self, n=o_n) - key = option.get_key() + key = option.key # Test against repeated keys if key in self.get_option_keys(): raise Exception('Key "{}" already exists in options'.format(key)) @@ -291,7 +280,7 @@ class Param(Element): return self.get_value() def __str__(self): - return 'Param - {}({})'.format(self.get_name(), self.get_key()) + return 'Param - {}({})'.format(self.get_name(), self.key) def get_hide(self): """ @@ -308,20 +297,20 @@ class Param(Element): if hide: return hide # Hide ID in non variable blocks - if self.get_key() == 'id' and not _show_id_matcher.match(self.parent.get_key()): + if self.key == 'id' and not _show_id_matcher.match(self.parent.key): return 'part' # Hide port controllers for type and nports - if self.get_key() in ' '.join([' '.join([p._type, p._nports]) for p in self.parent.get_ports()]): + if self.key in ' '.join([' '.join([p._type, p._nports]) for p in self.parent.get_ports()]): return 'part' # Hide port controllers for vlen, when == 1 - if self.get_key() in ' '.join(p._vlen for p in self.parent.get_ports()): + if self.key in ' '.join(p._vlen for p in self.parent.get_ports()): try: if int(self.get_evaluated()) == 1: return 'part' except: pass # Hide empty grid positions - if self.get_key() in ('grid_pos', 'notebook') and not self.get_value(): + if self.key in ('grid_pos', 'notebook') and not self.get_value(): return 'part' return hide @@ -558,7 +547,7 @@ class Param(Element): return '' # Get a list of all notebooks - notebook_blocks = [b for b in self.parent_flowgraph.get_enabled_blocks() if b.get_key() == 'notebook'] + notebook_blocks = [b for b in self.parent_flowgraph.get_enabled_blocks() if b.key == 'notebook'] # Check for notebook param syntax try: notebook_id, page_index = map(str.strip, v.split(',')) @@ -666,17 +655,17 @@ class Param(Element): def get_name(self): return self.parent.resolve_dependencies(self._name).strip() - def get_key(self): - return self._key - ############################################## # Access Options ############################################## def get_option_keys(self): - return _get_keys(self.get_options()) + return [elem.key for elem in self._options] def get_option(self, key): - return _get_elem(self.get_options(), key) + for option in self._options: + if option.key == key: + return option + return ValueError('Key "{}" not found in {}.'.format(key, self.get_option_keys())) def get_options(self): return self._options @@ -704,6 +693,6 @@ class Param(Element): a nested data odict """ n = collections.OrderedDict() - n['key'] = self.get_key() + n['key'] = self.key n['value'] = self.get_value() return n diff --git a/grc/core/Platform.py b/grc/core/Platform.py index 844693d14b..10e75d797d 100644 --- a/grc/core/Platform.py +++ b/grc/core/Platform.py @@ -199,7 +199,7 @@ class Platform(Element): n['block_wrapper_path'] = xml_file # inject block wrapper path # Get block instance and add it to the list of blocks block = self.Block(self._flow_graph, n) - key = block.get_key() + key = block.key if key in self.blocks: print('Warning: Block with key "{}" already exists.\n\tIgnoring: {}'.format(key, xml_file), file=sys.stderr) else: # Store the block @@ -207,7 +207,7 @@ class Platform(Element): self._blocks_n[key] = n self._docstring_extractor.query( - block.get_key(), + block.key, block.get_imports(raw=True), block.get_make(raw=True) ) diff --git a/grc/core/Port.py b/grc/core/Port.py index 4ba516d5fe..28988cd51e 100644 --- a/grc/core/Port.py +++ b/grc/core/Port.py @@ -131,7 +131,7 @@ class Port(Element): Element.__init__(self, parent=block) # Grab the data self._name = n['name'] - self._key = n['key'] + self.key = n['key'] self._type = n.get('type', '') self._domain = n.get('domain') self._hide = n.get('hide', '') @@ -146,9 +146,9 @@ class Port(Element): def __str__(self): if self.is_source: - return 'Source - {}({})'.format(self.get_name(), self.get_key()) + return 'Source - {}({})'.format(self.get_name(), self.key) if self.is_sink: - return 'Sink - {}({})'.format(self.get_name(), self.get_key()) + return 'Sink - {}({})'.format(self.get_name(), self.key) def get_types(self): return list(Constants.TYPE_TO_SIZEOF.keys()) @@ -195,10 +195,10 @@ class Port(Element): type_ = self.get_type() if self._domain == Constants.GR_STREAM_DOMAIN and type_ == "message": self._domain = Constants.GR_MESSAGE_DOMAIN - self._key = self._name + self.key = self._name if self._domain == Constants.GR_MESSAGE_DOMAIN and type_ != "message": self._domain = Constants.GR_STREAM_DOMAIN - self._key = '0' # Is rectified in rewrite() + self.key = '0' # Is rectified in rewrite() def resolve_virtual_source(self): if self.parent.is_virtual_sink(): @@ -286,8 +286,8 @@ class Port(Element): if not self._clones: self._name = self._n['name'] + '0' # Also update key for none stream ports - if not self._key.isdigit(): - self._key = self._name + if not self.key.isdigit(): + self.key = self._name # Prepare a copy of the odict for the clone n = self._n.copy() @@ -296,7 +296,7 @@ class Port(Element): n.pop('nports') n['name'] = self._n['name'] + str(len(self._clones) + 1) # Dummy value 99999 will be fixed later - n['key'] = '99999' if self._key.isdigit() else n['name'] + n['key'] = '99999' if self.key.isdigit() else n['name'] # Clone port = self.__class__(self.parent, n, self._dir) @@ -313,8 +313,8 @@ class Port(Element): if not self._clones: self._name = self._n['name'] # Also update key for none stream ports - if not self._key.isdigit(): - self._key = self._name + if not self.key.isdigit(): + self.key = self._name def get_name(self): number = '' @@ -323,9 +323,6 @@ class Port(Element): number = str(busses.index(self)) + '#' + str(len(self.get_associated_ports())) return self._name + number - def get_key(self): - return self._key - @property def is_sink(self): return self._dir == 'sink' diff --git a/grc/core/generator/FlowGraphProxy.py b/grc/core/generator/FlowGraphProxy.py index a23c6d84ab..d5d31c0dce 100644 --- a/grc/core/generator/FlowGraphProxy.py +++ b/grc/core/generator/FlowGraphProxy.py @@ -90,7 +90,7 @@ class FlowGraphProxy(object): Returns: a list of pad source blocks in this flow graph """ - pads = [b for b in self.get_enabled_blocks() if b.get_key() == 'pad_source'] + pads = [b for b in self.get_enabled_blocks() if b.key == 'pad_source'] return sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id())) def get_pad_sinks(self): @@ -100,7 +100,7 @@ class FlowGraphProxy(object): Returns: a list of pad sink blocks in this flow graph """ - pads = [b for b in self.get_enabled_blocks() if b.get_key() == 'pad_sink'] + pads = [b for b in self.get_enabled_blocks() if b.key == 'pad_sink'] return sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id())) def get_pad_port_global_key(self, port): @@ -121,7 +121,7 @@ class FlowGraphProxy(object): if is_message_pad: key = pad.get_param('label').get_value() else: - key = str(key_offset + int(port.get_key())) + key = str(key_offset + int(port.key)) return key else: # assuming we have either only sources or sinks diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py index 9c7d07e76b..3664d083e9 100644 --- a/grc/core/generator/Generator.py +++ b/grc/core/generator/Generator.py @@ -98,7 +98,7 @@ class TopBlockGenerator(object): "Add a Misc->Throttle block to your flow " "graph to avoid CPU congestion.") if len(throttling_blocks) > 1: - keys = set([b.get_key() for b in throttling_blocks]) + keys = set([b.key for b in throttling_blocks]) if len(keys) > 1 and 'blocks_throttle' in keys: Messages.send_warning("This flow graph contains a throttle " "block and another rate limiting block, " @@ -156,7 +156,7 @@ class TopBlockGenerator(object): blocks = [b for b in blocks_all if b not in imports and b not in parameters] for block in blocks: - key = block.get_key() + key = block.key file_path = os.path.join(self._dirname, block.get_id() + '.py') if key == 'epy_block': src = block.get_param('_source_code').get_value() diff --git a/grc/core/generator/flow_graph.tmpl b/grc/core/generator/flow_graph.tmpl index 5eef3d2042..34178ebc66 100644 --- a/grc/core/generator/flow_graph.tmpl +++ b/grc/core/generator/flow_graph.tmpl @@ -241,12 +241,12 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))]) ## However, port names for IO pads should be self. ######################################################## #def make_port_sig($port) - #if $port.parent.get_key() in ('pad_source', 'pad_sink') + #if $port.parent.key in ('pad_source', 'pad_sink') #set block = 'self' #set key = $flow_graph.get_pad_port_global_key($port) #else #set block = 'self.' + $port.parent.get_id() - #set key = $port.get_key() + #set key = $port.key #end if #if not $key.isdigit() #set key = repr($key) diff --git a/grc/core/utils/complexity.py b/grc/core/utils/complexity.py index d72db9b3dd..6864603a0a 100644 --- a/grc/core/utils/complexity.py +++ b/grc/core/utils/complexity.py @@ -4,7 +4,7 @@ def calculate_flowgraph_complexity(flowgraph): dbal = 0 for block in flowgraph.blocks: # Skip options block - if block.get_key() == 'options': + if block.key == 'options': continue # Don't worry about optional sinks? diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index d188030c62..b135efdce9 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -245,10 +245,10 @@ class ActionHandler: # If connected block is not in the list of selected blocks create a pad for it if flow_graph.get_block(source_id) not in flow_graph.get_selected_blocks(): - pads.append({'key': connection.sink_port.get_key(), 'coord': connection.source_port.get_coordinate(), 'block_id' : block.get_id(), 'direction': 'source'}) + pads.append({'key': connection.sink_port.key, 'coord': connection.source_port.get_coordinate(), 'block_id' : block.get_id(), 'direction': 'source'}) if flow_graph.get_block(sink_id) not in flow_graph.get_selected_blocks(): - pads.append({'key': connection.source_port.get_key(), 'coord': connection.sink_port.get_coordinate(), 'block_id' : block.get_id(), 'direction': 'sink'}) + pads.append({'key': connection.source_port.key, 'coord': connection.sink_port.get_coordinate(), 'block_id' : block.get_id(), 'direction': 'sink'}) # Copy the selected blocks and paste them into a new page diff --git a/grc/gui/Block.py b/grc/gui/Block.py index fd6612b8c2..0d9bd3e09b 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -134,7 +134,7 @@ class Block(Element, _Block): #display the params if self.is_dummy_block: markups = ['<span foreground="black" font_desc="{font}"><b>key: </b>{key}</span>'.format( - font=PARAM_FONT, key=self._key + font=PARAM_FONT, key=self.key )] else: markups = [param.format_block_surface_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')] @@ -180,7 +180,7 @@ class Block(Element, _Block): markups = [] # Show the flow graph complexity on the top block if enabled - if Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY.get_active() and self.get_key() == "options": + if Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY.get_active() and self.key == "options": complexity = calculate_flowgraph_complexity(self.parent) markups.append( '<span foreground="#444" size="medium" font_desc="{font}">' diff --git a/grc/gui/BlockTreeWindow.py b/grc/gui/BlockTreeWindow.py index 8522390fc1..f0f81b3757 100644 --- a/grc/gui/BlockTreeWindow.py +++ b/grc/gui/BlockTreeWindow.py @@ -176,7 +176,7 @@ class BlockTreeWindow(Gtk.VBox): categories[parent_category] = iter_ # add block iter_ = treestore.insert_before(categories[category], None) - treestore.set_value(iter_, KEY_INDEX, block.get_key()) + treestore.set_value(iter_, KEY_INDEX, block.key) treestore.set_value(iter_, NAME_INDEX, block.name) treestore.set_value(iter_, DOC_INDEX, _format_doc(block.documentation)) @@ -230,7 +230,7 @@ class BlockTreeWindow(Gtk.VBox): self.expand_module_in_tree() else: matching_blocks = [b for b in list(self.platform.blocks.values()) - if key in b.get_key().lower() or key in b.name.lower()] + if key in b.key.lower() or key in b.name.lower()] self.treestore_search.clear() self._categories_search = {tuple(): None} diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index d7745a529d..1c4960fed4 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -88,7 +88,7 @@ class FlowGraph(Element, _Flowgraph): return block_id def install_external_editor(self, param): - target = (param.parent_block.get_id(), param.get_key()) + target = (param.parent_block.get_id(), param.key) if target in self._external_updaters: editor = self._external_updaters[target] diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py index 3236768969..bd07a667d4 100644 --- a/grc/gui/MainWindow.py +++ b/grc/gui/MainWindow.py @@ -60,7 +60,7 @@ class MainWindow(Gtk.Window): gen_opts = platform.blocks['options'].get_param('generate_options') generate_mode_default = gen_opts.get_value() generate_modes = [ - (o.get_key(), o.get_name(), o.get_key() == generate_mode_default) + (o.key, o.get_name(), o.key == generate_mode_default) for o in gen_opts.get_options()] # Load preferences diff --git a/grc/gui/Param.py b/grc/gui/Param.py index a630f5faa3..c888b9ebc0 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -66,7 +66,7 @@ class Param(Element, _Param): # fixme: using non-public attribute here has_callback = \ hasattr(block, 'get_callbacks') and \ - any(self.get_key() in callback for callback in block._callbacks) + any(self.key in callback for callback in block._callbacks) return '<span underline="{line}" foreground="{color}" font_desc="Sans 9">{label}</span>'.format( line='low' if has_callback else 'none', @@ -78,7 +78,7 @@ class Param(Element, _Param): def format_tooltip_text(self): errors = self.get_error_messages() - tooltip_lines = ['Key: ' + self.get_key(), 'Type: ' + self.get_type()] + tooltip_lines = ['Key: ' + self.key, 'Type: ' + self.get_type()] if self.is_valid(): value = str(self.get_evaluated()) if len(value) > 100: diff --git a/grc/gui/ParamWidgets.py b/grc/gui/ParamWidgets.py index fbbfa93d1d..3ee4c7761d 100644 --- a/grc/gui/ParamWidgets.py +++ b/grc/gui/ParamWidgets.py @@ -270,7 +270,7 @@ class FileParam(EntryParam): file_path = self.param.is_valid() and self.param.get_evaluated() or '' (dirname, basename) = os.path.isfile(file_path) and os.path.split(file_path) or (file_path, '') # check for qss theme default directory - if self.param.get_key() == 'qt_qss_theme': + if self.param.key == 'qt_qss_theme': dirname = os.path.dirname(dirname) # trim filename if not os.path.exists(dirname): config = self.param.parent_platform.config diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index d7722adff7..1244db3537 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -226,7 +226,7 @@ class PropsDialog(Gtk.Dialog): buf = self._code_text_display.get_buffer() block = self._block - key = block.get_key() + key = block.key if key == 'epy_block': src = block.get_param('_source_code').get_value() diff --git a/grc/gui/VariableEditor.py b/grc/gui/VariableEditor.py index 399e4ec475..11284f5708 100644 --- a/grc/gui/VariableEditor.py +++ b/grc/gui/VariableEditor.py @@ -177,9 +177,9 @@ class VariableEditor(Gtk.VBox): # Block specific values if block: - if block.get_key() == 'import': + if block.key == 'import': value = block.get_param('import').get_value() - elif block.get_key() != "variable": + elif block.key != "variable": value = "<Open Properties>" sp('editable', False) sp('foreground', '#0D47A1') @@ -195,7 +195,7 @@ class VariableEditor(Gtk.VBox): self.set_tooltip_text(error_message[-1]) else: # Evaluate and show the value (if it is a variable) - if block.get_key() == "variable": + if block.key == "variable": evaluated = str(block.get_param('value').evaluate()) self.set_tooltip_text(evaluated) # Always set the text value. @@ -300,7 +300,7 @@ class VariableEditor(Gtk.VBox): # Make sure this has a block (not the import/variable rows) if self._block and event.type == Gdk.EventType._2BUTTON_PRESS: # Open the advanced dialog if it is a gui variable - if self._block.get_key() not in ("variable", "import"): + if self._block.key not in ("variable", "import"): self.handle_action(None, self.OPEN_PROPERTIES, event=event) return True if event.type == Gdk.EventType.BUTTON_PRESS: |