Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions meshroom/core/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _setValue(self, value):
if isinstance(value, Attribute) or Attribute.isLinkExpression(value):
# if we set a link to another attribute
self._value = value
elif isinstance(value, types.FunctionType):
elif callable(value):
# evaluate the function
self._value = value(self)
else:
Expand Down Expand Up @@ -216,7 +216,7 @@ def getDefaultValue(self):
"""
Get the attribute default value.
"""
if isinstance(self._desc.value, types.FunctionType):
if callable(self._desc.value):
try:
return self._desc.value(self)
except Exception as e:
Expand Down Expand Up @@ -282,7 +282,7 @@ def _isValid(self):
- If it is a function, execute it and return the result
- Otherwise, simply return true
"""
if isinstance(self._desc.validValue, types.FunctionType):
if callable(self._desc.validValue):
try:
return self._desc.validValue(self.node)
except Exception:
Expand Down Expand Up @@ -343,7 +343,7 @@ def updateInternals(self):
self._setEnabled(self._getEnabled())

def _getEnabled(self) -> bool:
if isinstance(self._desc.enabled, types.FunctionType):
if callable(self._desc.enabled):
try:
return self._desc.enabled(self.node)
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion meshroom/core/desc/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, name, label, description, value, advanced, semantic, group, e
self._visible = visible
self._exposed = exposed
self._isExpression = (isinstance(self._value, str) and "{" in self._value) \
or isinstance(self._value, types.FunctionType)
or callable(self._value)
self._isDynamicValue = (self._value is None)
self._valueType = None

Expand Down
2 changes: 1 addition & 1 deletion meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def _buildCmdVars(self):
def _buildAttributeCmdVars(cmdVars, name, attr):
if attr.enabled:
group = attr.desc.group(attr.node) \
if isinstance(attr.desc.group, types.FunctionType) else attr.desc.group
if callable(attr.desc.group) else attr.desc.group
if group is not None:
# If there is a valid command line "group"
v = attr.getValueStr(withQuotes=True)
Expand Down
Loading