mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-12 22:37:21 +02:00
[core] plugins: Support finding unregistered nodes in plugins
A `NodePlugin` may be part of a `Plugin` even if it has not been registered. `containsNode` allows to check whether a `NodePlugin` is contained within a `Plugin`, and `belongsToPlugin`
This commit is contained in:
parent
98d90dae81
commit
a8a54f67fb
1 changed files with 26 additions and 0 deletions
|
@ -148,6 +148,16 @@ class Plugin(BaseObject):
|
|||
if file.endswith(".mg"):
|
||||
self._templates[os.path.splitext(file)[0]] = os.path.join(self.path, file)
|
||||
|
||||
def containsNodePlugin(self, name: str) -> bool:
|
||||
"""
|
||||
Return whether the node plugin "name" is part of the plugin, independently from its
|
||||
status.
|
||||
|
||||
Args:
|
||||
name: the name of the node plugin to be checked.
|
||||
"""
|
||||
return name in self._nodePlugins
|
||||
|
||||
|
||||
class NodePlugin(BaseObject):
|
||||
"""
|
||||
|
@ -231,6 +241,22 @@ class NodePluginManager(BaseObject):
|
|||
"""
|
||||
return name in self._nodePlugins
|
||||
|
||||
def belongsToPlugin(self, name: str) -> Plugin:
|
||||
"""
|
||||
Check whether the node plugin belongs to a loaded plugin, independently from
|
||||
whether it has been registered or not.
|
||||
|
||||
Args:
|
||||
name: the name of the node plugin that needs to be searched for across plugins.
|
||||
|
||||
Returns:
|
||||
Plugin | None: the Plugin the node belongs to if it exists, None otherwise.
|
||||
"""
|
||||
for plugin in self._plugins.values():
|
||||
if plugin.containsNodePlugin(name):
|
||||
return plugin
|
||||
return None
|
||||
|
||||
def getPlugins(self) -> dict[str: Plugin]:
|
||||
"""
|
||||
Return a dictionary containing all the loaded Plugins, with {key, value} =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue