From a8a54f67fb43a6eb6adbcee3061a0c9ff4f7d24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Thu, 22 May 2025 16:22:32 +0200 Subject: [PATCH] [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` --- meshroom/core/plugins.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/meshroom/core/plugins.py b/meshroom/core/plugins.py index ac8c92a9..e75af08c 100644 --- a/meshroom/core/plugins.py +++ b/meshroom/core/plugins.py @@ -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} =