diff options
Diffstat (limited to 'grc')
-rw-r--r-- | grc/core/FlowGraph.py | 6 | ||||
-rw-r--r-- | grc/core/Param.py | 8 | ||||
-rw-r--r-- | grc/core/Port.py | 35 | ||||
-rw-r--r-- | grc/core/generator/Generator.py | 2 | ||||
-rw-r--r-- | grc/gui/Param.py | 6 | ||||
-rw-r--r-- | grc/gui/Port.py | 2 | ||||
-rw-r--r-- | grc/gui/PropsDialog.py | 2 |
7 files changed, 29 insertions, 32 deletions
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py index 83ab53a04b..08f24b8fe3 100644 --- a/grc/core/FlowGraph.py +++ b/grc/core/FlowGraph.py @@ -117,7 +117,7 @@ class FlowGraph(Element): for i in bussink: for j in i.params.values(): - if j.get_name() == 'On/Off' and j.get_value() == 'on': + if j.name == 'On/Off' and j.get_value() == 'on': return True return False @@ -126,7 +126,7 @@ class FlowGraph(Element): for i in bussrc: for j in i.params.values(): - if j.get_name() == 'On/Off' and j.get_value() == 'on': + if j.name == 'On/Off' and j.get_value() == 'on': return True return False @@ -418,7 +418,7 @@ class FlowGraph(Element): for port in ports: if key == port.key: break - if not key.isdigit() and port.get_type() == '' and key == port.get_name(): + if not key.isdigit() and port.get_type() == '' and key == port.name: break else: if block.is_dummy_block: diff --git a/grc/core/Param.py b/grc/core/Param.py index a2effad2f9..5ac1745f95 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -26,7 +26,7 @@ import collections from six.moves import builtins, filter, map, range, zip from . import Constants -from .Element import Element +from .Element import Element, nop_write # Blacklist certain ids, its not complete, but should help ID_BLACKLIST = ['self', 'options', 'gr', 'blks2', 'wxgui', 'wx', 'math', 'forms', 'firdes'] + dir(builtins) @@ -126,7 +126,7 @@ class Param(Element): # ''.format(self.get_value(), ', '.join(self.options))) def __str__(self): - return 'Param - {}({})'.format(self.get_name(), self.key) + return 'Param - {}({})'.format(self.name, self.key) def get_hide(self): """ @@ -498,7 +498,9 @@ class Param(Element): def get_tab_label(self): return self.tab_label - def get_name(self): + @nop_write + @property + def name(self): return self.parent.resolve_dependencies(self._name).strip() ############################################## diff --git a/grc/core/Port.py b/grc/core/Port.py index da8751b565..f7046ad8c8 100644 --- a/grc/core/Port.py +++ b/grc/core/Port.py @@ -130,10 +130,11 @@ class Port(Element): # Build the port Element.__init__(self, parent) # Grab the data - self._name = n['name'] + self.name = n['name'] self.key = n['key'] self.domain = n.get('domain') self._type = n.get('type', '') + self.inherit_type = not self._type self._hide = n.get('hide', '') self._dir = direction self._hide_evaluated = False # Updated on rewrite() @@ -145,12 +146,9 @@ class Port(Element): def __str__(self): if self.is_source: - return 'Source - {}({})'.format(self.get_name(), self.key) + return 'Source - {}({})'.format(self.name, self.key) if self.is_sink: - return 'Sink - {}({})'.format(self.get_name(), self.key) - - def is_type_empty(self): - return not self._n['type'] + return 'Sink - {}({})'.format(self.name, self.key) def validate(self): Element.validate(self) @@ -172,7 +170,7 @@ class Port(Element): """ Handle the port cloning for virtual blocks. """ - if self.is_type_empty(): + if self.inherit_type: try: # Clone type and vlen source = self.resolve_empty_type() @@ -191,7 +189,7 @@ 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() @@ -206,22 +204,22 @@ class Port(Element): if self.is_sink: try: src = _get_source_from_virtual_sink_port(self) - if not src.is_type_empty(): + if not src.inherit_type: return src except: pass sink = _get_sink_from_virtual_sink_port(self) - if not sink.is_type_empty(): + if not sink.inherit_type: return sink if self.is_source: try: src = _get_source_from_virtual_source_port(self) - if not src.is_type_empty(): + if not src.inherit_type: return src except: pass sink = _get_sink_from_virtual_source_port(self) - if not sink.is_type_empty(): + if not sink.inherit_type: return sink def get_vlen(self): @@ -271,10 +269,10 @@ class Port(Element): """ # Add index to master port name if there are no clones yet if not self.clones: - self._name = self._n['name'] + '0' + self.name = self._n['name'] + '0' # Also update key for none stream ports if not self.key.isdigit(): - self.key = self._name + self.key = self.name name = self._n['name'] + str(len(self.clones) + 1) # Dummy value 99999 will be fixed later @@ -297,13 +295,10 @@ class Port(Element): self.clones.remove(port) # Remove index from master port name if there are no more clones if not self.clones: - self._name = self._n['name'] + self.name = self._n['name'] # Also update key for none stream ports if not self.key.isdigit(): - self.key = self._name - - def get_name(self): - return self._name + self.key = self.name @lazy_property def is_sink(self): @@ -373,7 +368,7 @@ class PortClone(Port): """ Element.__init__(self, parent) self.master = master - self._name = name + self.name = name self._key = key self._nports = '1' diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py index 637cf9e9df..dcbf767835 100644 --- a/grc/core/generator/Generator.py +++ b/grc/core/generator/Generator.py @@ -148,7 +148,7 @@ class TopBlockGenerator(object): [b for b in fg.blocks if b.get_enabled() and not b.get_bypassed()], operator.methodcaller('get_id'), _get_block_sort_text ) - deprecated_block_keys = set(b.get_name() for b in blocks_all if b.is_deprecated) + deprecated_block_keys = set(b.name for b in blocks_all if b.is_deprecated) for key in deprecated_block_keys: Messages.send_warning("The block {!r} is deprecated.".format(key)) diff --git a/grc/gui/Param.py b/grc/gui/Param.py index f688d2aad4..fb62e3d9bb 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -72,7 +72,7 @@ class Param(_Param): color='blue' if have_pending_changes else 'black' if self.is_valid() else 'red', - label=Utils.encode(self.get_name()) + label=Utils.encode(self.name) ) def format_tooltip_text(self): @@ -101,7 +101,7 @@ class Param(_Param): # Truncate helper method ################################################## def _truncate(string, style=0): - max_len = max(27 - len(self.get_name()), 3) + max_len = max(27 - len(self.name), 3) if len(string) > max_len: if style < 0: # Front truncate string = '...' + string[3-max_len:] @@ -159,6 +159,6 @@ class Param(_Param): """ return '<span foreground="{color}" font_desc="{font}"><b>{label}:</b> {value}</span>'.format( color='black' if self.is_valid() else 'red', font=Constants.PARAM_FONT, - label=Utils.encode(self.get_name()), + label=Utils.encode(self.name), value=Utils.encode(self.pretty_print().replace('\n', ' ')) ) diff --git a/grc/gui/Port.py b/grc/gui/Port.py index 6ac216244d..991036cb99 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -103,7 +103,7 @@ class Port(_Port, Element): layout = self.label_layout layout.set_markup("""<span foreground="black" font_desc="{font}">{name}</span>""".format( - name=Utils.encode(self.get_name()), font=Constants.PORT_FONT + name=Utils.encode(self.name), font=Constants.PORT_FONT )) label_width, label_height = self.label_layout.get_pixel_size() diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index da79c0ef87..f2ba641bbf 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -140,7 +140,7 @@ class PropsDialog(Gtk.Dialog): """ old_hash = self._hash new_hash = self._hash = hash(tuple( - (hash(param), param.get_name(), param.get_type(), param.get_hide() == 'all',) + (hash(param), param.name, param.get_type(), param.get_hide() == 'all',) for param in self._block.params.values() )) return new_hash != old_hash |