mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-31 18:06:31 +02:00
[core] add package and package version notion
This commit is contained in:
parent
0bdad5a588
commit
0b0ef01997
3 changed files with 14 additions and 0 deletions
|
@ -37,6 +37,8 @@ def loadNodes(folder, packageName):
|
||||||
with add_to_path(folder):
|
with add_to_path(folder):
|
||||||
# import node package
|
# import node package
|
||||||
package = importlib.import_module(packageName)
|
package = importlib.import_module(packageName)
|
||||||
|
packageName = package.packageName if hasattr(package, 'packageName') else package.__name__
|
||||||
|
packageVersion = package.__version__
|
||||||
|
|
||||||
pysearchre = re.compile('.py$', re.IGNORECASE)
|
pysearchre = re.compile('.py$', re.IGNORECASE)
|
||||||
pluginFiles = filter(pysearchre.search, os.listdir(os.path.dirname(package.__file__)))
|
pluginFiles = filter(pysearchre.search, os.listdir(os.path.dirname(package.__file__)))
|
||||||
|
@ -51,6 +53,9 @@ def loadNodes(folder, packageName):
|
||||||
p = [a for a in m.__dict__.values() if inspect.isclass(a) and issubclass(a, desc.Node)]
|
p = [a for a in m.__dict__.values() if inspect.isclass(a) and issubclass(a, desc.Node)]
|
||||||
if not p:
|
if not p:
|
||||||
raise RuntimeError('No class defined in plugin: %s' % pluginModule)
|
raise RuntimeError('No class defined in plugin: %s' % pluginModule)
|
||||||
|
for a in p:
|
||||||
|
a.packageName = packageName
|
||||||
|
a.packageVersion = packageVersion
|
||||||
nodeTypes.extend(p)
|
nodeTypes.extend(p)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append(' * Errors while loading "{}".\n File: {}\n {}'.format(pluginName, pluginFile, str(e)))
|
errors.append(' * Errors while loading "{}".\n File: {}\n {}'.format(pluginName, pluginFile, str(e)))
|
||||||
|
|
|
@ -119,6 +119,8 @@ class Node(object):
|
||||||
cpu = Level.NORMAL
|
cpu = Level.NORMAL
|
||||||
gpu = Level.NONE
|
gpu = Level.NONE
|
||||||
ram = Level.NORMAL
|
ram = Level.NORMAL
|
||||||
|
packageName = ''
|
||||||
|
packageVersion = ''
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -323,6 +323,8 @@ class Node(BaseObject):
|
||||||
self._name = None # type: str
|
self._name = None # type: str
|
||||||
self.graph = None # type: Graph
|
self.graph = None # type: Graph
|
||||||
self.nodeDesc = meshroom.core.nodesDesc[nodeDesc]()
|
self.nodeDesc = meshroom.core.nodesDesc[nodeDesc]()
|
||||||
|
self.packageName = self.nodeDesc.packageName
|
||||||
|
self.packageVersion = self.nodeDesc.packageVersion
|
||||||
self._cmdVars = {}
|
self._cmdVars = {}
|
||||||
self._attributes = DictModel(keyAttrName='name', parent=self)
|
self._attributes = DictModel(keyAttrName='name', parent=self)
|
||||||
self.attributesPerUid = defaultdict(set)
|
self.attributesPerUid = defaultdict(set)
|
||||||
|
@ -348,6 +350,9 @@ class Node(BaseObject):
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def packageFullName(self):
|
||||||
|
return '-'.join([self.packageName, self.packageVersion])
|
||||||
@Slot(str, result=Attribute)
|
@Slot(str, result=Attribute)
|
||||||
def attribute(self, name):
|
def attribute(self, name):
|
||||||
att = None
|
att = None
|
||||||
|
@ -411,6 +416,8 @@ class Node(BaseObject):
|
||||||
attributes = {k: v.getExportValue() for k, v in self._attributes.objects.items()}
|
attributes = {k: v.getExportValue() for k, v in self._attributes.objects.items()}
|
||||||
return {
|
return {
|
||||||
'nodeType': self.nodeType,
|
'nodeType': self.nodeType,
|
||||||
|
'packageName': self.packageName,
|
||||||
|
'packageVersion': self.packageVersion,
|
||||||
'attributes': {k: v for k, v in attributes.items() if v is not None}, # filter empty values
|
'attributes': {k: v for k, v in attributes.items() if v is not None}, # filter empty values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue