mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 02:08:08 +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):
|
||||
# import node package
|
||||
package = importlib.import_module(packageName)
|
||||
packageName = package.packageName if hasattr(package, 'packageName') else package.__name__
|
||||
packageVersion = package.__version__
|
||||
|
||||
pysearchre = re.compile('.py$', re.IGNORECASE)
|
||||
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)]
|
||||
if not p:
|
||||
raise RuntimeError('No class defined in plugin: %s' % pluginModule)
|
||||
for a in p:
|
||||
a.packageName = packageName
|
||||
a.packageVersion = packageVersion
|
||||
nodeTypes.extend(p)
|
||||
except Exception as e:
|
||||
errors.append(' * Errors while loading "{}".\n File: {}\n {}'.format(pluginName, pluginFile, str(e)))
|
||||
|
|
|
@ -119,6 +119,8 @@ class Node(object):
|
|||
cpu = Level.NORMAL
|
||||
gpu = Level.NONE
|
||||
ram = Level.NORMAL
|
||||
packageName = ''
|
||||
packageVersion = ''
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
|
|
@ -323,6 +323,8 @@ class Node(BaseObject):
|
|||
self._name = None # type: str
|
||||
self.graph = None # type: Graph
|
||||
self.nodeDesc = meshroom.core.nodesDesc[nodeDesc]()
|
||||
self.packageName = self.nodeDesc.packageName
|
||||
self.packageVersion = self.nodeDesc.packageVersion
|
||||
self._cmdVars = {}
|
||||
self._attributes = DictModel(keyAttrName='name', parent=self)
|
||||
self.attributesPerUid = defaultdict(set)
|
||||
|
@ -348,6 +350,9 @@ class Node(BaseObject):
|
|||
def getName(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def packageFullName(self):
|
||||
return '-'.join([self.packageName, self.packageVersion])
|
||||
@Slot(str, result=Attribute)
|
||||
def attribute(self, name):
|
||||
att = None
|
||||
|
@ -411,6 +416,8 @@ class Node(BaseObject):
|
|||
attributes = {k: v.getExportValue() for k, v in self._attributes.objects.items()}
|
||||
return {
|
||||
'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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue