Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 4 additions & 5 deletions meshroom/core/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import re
import weakref
import types
import logging

from collections.abc import Iterable, Sequence
Expand Down Expand Up @@ -158,7 +157,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 +215,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 +281,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 +342,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
3 changes: 1 addition & 2 deletions meshroom/core/desc/attribute.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ast
import distutils.util
import os
import types
from collections.abc import Iterable

from meshroom.common import BaseObject, JSValue, Property, Variant, VariantList
Expand Down Expand Up @@ -29,7 +28,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
3 changes: 1 addition & 2 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import re
import shutil
import time
import types
import uuid
from collections import namedtuple, OrderedDict
from enum import Enum, auto
Expand Down Expand Up @@ -963,7 +962,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