mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
pass context to loader action plugins
This commit is contained in:
parent
afc1af7e95
commit
d0cb16a155
1 changed files with 10 additions and 10 deletions
|
|
@ -382,8 +382,9 @@ class LoaderActionPlugin(ABC):
|
|||
_log: Optional[logging.Logger] = None
|
||||
enabled: bool = True
|
||||
|
||||
def __init__(self, studio_settings: dict[str, Any]):
|
||||
self.apply_settings(studio_settings)
|
||||
def __init__(self, context: "LoaderActionsContext") -> None:
|
||||
self._context = context
|
||||
self.apply_settings(context.get_studio_settings())
|
||||
|
||||
def apply_settings(self, studio_settings: dict[str, Any]) -> None:
|
||||
"""Apply studio settings to the plugin.
|
||||
|
|
@ -473,10 +474,15 @@ class LoaderActionsContext:
|
|||
def get_addons_manager(self) -> AddonsManager:
|
||||
if self._addons_manager is None:
|
||||
self._addons_manager = AddonsManager(
|
||||
settings=self._get_studio_settings()
|
||||
settings=self.get_studio_settings()
|
||||
)
|
||||
return self._addons_manager
|
||||
|
||||
def get_studio_settings(self) -> dict[str, Any]:
|
||||
if self._studio_settings is None:
|
||||
self._studio_settings = get_studio_settings()
|
||||
return copy.deepcopy(self._studio_settings)
|
||||
|
||||
def get_action_items(
|
||||
self, selection: LoaderActionSelection
|
||||
) -> list[LoaderActionItem]:
|
||||
|
|
@ -515,11 +521,6 @@ class LoaderActionsContext:
|
|||
attribute_values,
|
||||
)
|
||||
|
||||
def _get_studio_settings(self) -> dict[str, Any]:
|
||||
if self._studio_settings is None:
|
||||
self._studio_settings = get_studio_settings()
|
||||
return copy.deepcopy(self._studio_settings)
|
||||
|
||||
def _get_plugins(self) -> dict[str, LoaderActionPlugin]:
|
||||
if self._plugins is None:
|
||||
addons_manager = self.get_addons_manager()
|
||||
|
|
@ -533,13 +534,12 @@ class LoaderActionsContext:
|
|||
if paths:
|
||||
all_paths.extend(paths)
|
||||
|
||||
studio_settings = self._get_studio_settings()
|
||||
result = discover_plugins(LoaderActionPlugin, all_paths)
|
||||
result.log_report()
|
||||
plugins = {}
|
||||
for cls in result.plugins:
|
||||
try:
|
||||
plugin = cls(studio_settings)
|
||||
plugin = cls(self)
|
||||
if not plugin.enabled:
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue