[core] Node: add 'label' property

high-level label for nodes, without '_' and including index if > 1
This commit is contained in:
Yann Lanthony 2018-11-16 16:56:33 +01:00
parent 3dad1e3aac
commit d2aba176dc

View file

@ -362,6 +362,14 @@ class BaseNode(BaseObject):
def getName(self):
return self._name
def getLabel(self):
"""
Returns:
str: the high-level label of this node
"""
t, idx = self._name.split("_")
return "{}{}".format(t, idx if int(idx) > 1 else "")
@property
def packageFullName(self):
return '-'.join([self.packageName, self.packageVersion])
@ -615,6 +623,7 @@ class BaseNode(BaseObject):
return self.name
name = Property(str, getName, constant=True)
label = Property(str, getLabel, constant=True)
nodeType = Property(str, nodeType.fget, constant=True)
positionChanged = Signal()
position = Property(Variant, position.fget, position.fset, notify=positionChanged)