mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-30 14:58:37 +02:00
[core] Check existence of group or list attributes correctly
"hasAttribute" was previously never called before attempting to access an attribute. With the addition of internal attributes, we want to check the attribute's/internal attribute's before accessing it to avoid KeyError exceptions. "hasAttribute" (and the newly added "hasInternalAttribute") would not parse the attribute's name before checking for its existence, meaning that errors could be generated for list or group attributes as their checked name could contain other elements (e.g. "featuresFolder[0]" for a ListAttribute named "featuresFolder").
This commit is contained in:
parent
1015ea448a
commit
3689c12e9c
1 changed files with 8 additions and 0 deletions
|
@ -611,10 +611,18 @@ class BaseNode(BaseObject):
|
|||
|
||||
@Slot(str, result=bool)
|
||||
def hasAttribute(self, name):
|
||||
# Complex name indicating group or list attribute: parse it and get the
|
||||
# first output element to check for the attribute's existence
|
||||
if "[" in name or "." in name:
|
||||
p = self.attributeRE.findall(name)
|
||||
return p[0][0] in self._attributes.keys() or p[0][1] in self._attributes.keys()
|
||||
return name in self._attributes.keys()
|
||||
|
||||
@Slot(str, result=bool)
|
||||
def hasInternalAttribute(self, name):
|
||||
if "[" in name or "." in name:
|
||||
p = self.attributeRE.findall(name)
|
||||
return p[0][0] in self._internalAttributes.keys() or p[0][1] in self._internalAttributes.keys()
|
||||
return name in self._internalAttributes.keys()
|
||||
|
||||
def _applyExpr(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue