[core] Check a graph exists before accessing its name

If the graph does not exist, return "UNDEFINED" as its name.
This commit is contained in:
Candice Bentéjac 2023-02-03 17:43:31 +01:00
parent 6579ed3797
commit 909f38ccb8

View file

@ -92,7 +92,8 @@ class Attribute(BaseObject):
def getFullNameToGraph(self):
""" Name inside the Graph: graphName.nodeName.groupName.name """
return '{}.{}'.format(self.node.graph.name, self.getFullNameToNode())
graphName = self.node.graph.name if self.node.graph else "UNDEFINED"
return '{}.{}'.format(graphName, self.getFullNameToNode())
def asLinkExpr(self):
""" Return link expression for this Attribute """
@ -124,7 +125,8 @@ class Attribute(BaseObject):
def getFullLabelToGraph(self):
""" Label inside the Graph: graphName nodeLabel groupLabel Label """
return '{} {}'.format(self.node.graph.name, self.getFullLabelToNode())
graphName = self.node.graph.name if self.node.graph else "UNDEFINED"
return '{} {}'.format(graphName, self.getFullLabelToNode())
def getEnabled(self):
if isinstance(self.desc.enabled, types.FunctionType):