mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Removed get_hook_loaders_by_identifier
Replaced by monkeypatch load method
This commit is contained in:
parent
4457a432cb
commit
ca768aeddf
5 changed files with 2 additions and 77 deletions
|
|
@ -293,7 +293,6 @@ def load_with_repre_context(
|
|||
namespace=None,
|
||||
name=None,
|
||||
options=None,
|
||||
hooks=None,
|
||||
**kwargs
|
||||
):
|
||||
|
||||
|
|
@ -338,7 +337,6 @@ def load_with_product_context(
|
|||
namespace=None,
|
||||
name=None,
|
||||
options=None,
|
||||
hooks=None,
|
||||
**kwargs
|
||||
):
|
||||
|
||||
|
|
@ -373,7 +371,6 @@ def load_with_product_contexts(
|
|||
namespace=None,
|
||||
name=None,
|
||||
options=None,
|
||||
hooks=None,
|
||||
**kwargs
|
||||
):
|
||||
|
||||
|
|
@ -1178,37 +1175,3 @@ def filter_containers(containers, project_name):
|
|||
uptodate_containers.append(container)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def get_hook_loaders_by_identifier():
|
||||
"""Discovers pre/post hooks for loader plugins.
|
||||
|
||||
Returns:
|
||||
(dict) {"LoaderName": {"pre": ["PreLoader1"], "post":["PreLoader2]}
|
||||
"""
|
||||
# beware of circular imports!
|
||||
from .plugins import PreLoadHookPlugin, PostLoadHookPlugin
|
||||
|
||||
hook_loaders_by_identifier = {}
|
||||
_get_hook_loaders(hook_loaders_by_identifier, PreLoadHookPlugin, "pre")
|
||||
_get_hook_loaders(hook_loaders_by_identifier, PostLoadHookPlugin, "post")
|
||||
return hook_loaders_by_identifier
|
||||
|
||||
|
||||
def _get_hook_loaders(hook_loaders_by_identifier, loader_plugin, loader_type):
|
||||
from ..plugin_discover import discover
|
||||
|
||||
load_hook_plugins = discover(loader_plugin)
|
||||
loaders_by_name = get_loaders_by_name()
|
||||
for hook_plugin_cls in load_hook_plugins:
|
||||
for load_plugin_name in hook_plugin_cls.loader_identifiers:
|
||||
load_plugin = loaders_by_name.get(load_plugin_name)
|
||||
if not load_plugin:
|
||||
continue
|
||||
if not load_plugin.enabled:
|
||||
continue
|
||||
identifier = get_loader_identifier(load_plugin)
|
||||
(hook_loaders_by_identifier.setdefault(identifier, {})
|
||||
.setdefault(loader_type, []).append(
|
||||
hook_plugin_cls)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ from ayon_core.pipeline.load import (
|
|||
load_with_product_contexts,
|
||||
LoadError,
|
||||
IncompatibleLoaderError,
|
||||
get_loaders_by_name,
|
||||
get_hook_loaders_by_identifier
|
||||
|
||||
)
|
||||
from ayon_core.tools.loader.abstract import ActionItem
|
||||
|
|
@ -149,14 +147,12 @@ class LoaderActionsModel:
|
|||
ACTIONS_MODEL_SENDER,
|
||||
)
|
||||
loader = self._get_loader_by_identifier(project_name, identifier)
|
||||
hooks = self._get_hook_loaders_by_identifier(project_name, identifier)
|
||||
if representation_ids is not None:
|
||||
error_info = self._trigger_representation_loader(
|
||||
loader,
|
||||
options,
|
||||
project_name,
|
||||
representation_ids,
|
||||
hooks
|
||||
)
|
||||
elif version_ids is not None:
|
||||
error_info = self._trigger_version_loader(
|
||||
|
|
@ -164,7 +160,6 @@ class LoaderActionsModel:
|
|||
options,
|
||||
project_name,
|
||||
version_ids,
|
||||
hooks
|
||||
)
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
|
|
@ -336,7 +331,6 @@ class LoaderActionsModel:
|
|||
available_loaders = self._filter_loaders_by_tool_name(
|
||||
project_name, discover_loader_plugins(project_name)
|
||||
)
|
||||
hook_loaders_by_identifier = get_hook_loaders_by_identifier()
|
||||
repre_loaders = []
|
||||
product_loaders = []
|
||||
loaders_by_identifier = {}
|
||||
|
|
@ -354,7 +348,6 @@ class LoaderActionsModel:
|
|||
loaders_by_identifier_c.update_data(loaders_by_identifier)
|
||||
product_loaders_c.update_data(product_loaders)
|
||||
repre_loaders_c.update_data(repre_loaders)
|
||||
hook_loaders_by_identifier_c.update_data(hook_loaders_by_identifier)
|
||||
|
||||
return product_loaders, repre_loaders
|
||||
|
||||
|
|
@ -365,13 +358,6 @@ class LoaderActionsModel:
|
|||
loaders_by_identifier = loaders_by_identifier_c.get_data()
|
||||
return loaders_by_identifier.get(identifier)
|
||||
|
||||
def _get_hook_loaders_by_identifier(self, project_name, identifier):
|
||||
if not self._hook_loaders_by_identifier[project_name].is_valid:
|
||||
self._get_loaders(project_name)
|
||||
hook_loaders_by_identifier_c = self._hook_loaders_by_identifier[project_name]
|
||||
hook_loaders_by_identifier_c = hook_loaders_by_identifier_c.get_data()
|
||||
return hook_loaders_by_identifier_c.get(identifier)
|
||||
|
||||
def _actions_sorter(self, action_item):
|
||||
"""Sort the Loaders by their order and then their name.
|
||||
|
||||
|
|
@ -629,7 +615,6 @@ class LoaderActionsModel:
|
|||
options,
|
||||
project_name,
|
||||
version_ids,
|
||||
hooks=None
|
||||
):
|
||||
"""Trigger version loader.
|
||||
|
||||
|
|
@ -679,7 +664,7 @@ class LoaderActionsModel:
|
|||
})
|
||||
|
||||
return self._load_products_by_loader(
|
||||
loader, product_contexts, options, hooks=hooks
|
||||
loader, product_contexts, options
|
||||
)
|
||||
|
||||
def _trigger_representation_loader(
|
||||
|
|
@ -688,7 +673,6 @@ class LoaderActionsModel:
|
|||
options,
|
||||
project_name,
|
||||
representation_ids,
|
||||
hooks
|
||||
):
|
||||
"""Trigger representation loader.
|
||||
|
||||
|
|
@ -741,7 +725,7 @@ class LoaderActionsModel:
|
|||
})
|
||||
|
||||
return self._load_representations_by_loader(
|
||||
loader, repre_contexts, options, hooks
|
||||
loader, repre_contexts, options
|
||||
)
|
||||
|
||||
def _load_representations_by_loader(
|
||||
|
|
@ -749,7 +733,6 @@ class LoaderActionsModel:
|
|||
loader,
|
||||
repre_contexts,
|
||||
options,
|
||||
hooks=None
|
||||
):
|
||||
"""Loops through list of repre_contexts and loads them with one loader
|
||||
|
||||
|
|
@ -773,7 +756,6 @@ class LoaderActionsModel:
|
|||
loader,
|
||||
repre_context,
|
||||
options=options,
|
||||
hooks=hooks
|
||||
)
|
||||
|
||||
except IncompatibleLoaderError as exc:
|
||||
|
|
@ -808,7 +790,6 @@ class LoaderActionsModel:
|
|||
loader,
|
||||
version_contexts,
|
||||
options,
|
||||
hooks=None
|
||||
):
|
||||
"""Triggers load with ProductLoader type of loaders.
|
||||
|
||||
|
|
@ -834,7 +815,6 @@ class LoaderActionsModel:
|
|||
loader,
|
||||
version_contexts,
|
||||
options=options,
|
||||
hooks=hooks
|
||||
)
|
||||
except Exception as exc:
|
||||
formatted_traceback = None
|
||||
|
|
@ -860,7 +840,6 @@ class LoaderActionsModel:
|
|||
loader,
|
||||
version_context,
|
||||
options=options,
|
||||
hooks=hooks
|
||||
)
|
||||
|
||||
except Exception as exc:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from ayon_core.host import HostBase
|
|||
from ayon_core.pipeline import (
|
||||
registered_host,
|
||||
get_current_context,
|
||||
get_hook_loaders_by_identifier
|
||||
)
|
||||
from ayon_core.tools.common_models import HierarchyModel, ProjectsModel
|
||||
|
||||
|
|
@ -36,8 +35,6 @@ class SceneInventoryController:
|
|||
self._projects_model = ProjectsModel(self)
|
||||
self._event_system = self._create_event_system()
|
||||
|
||||
self._hooks_by_identifier = None
|
||||
|
||||
def get_host(self) -> HostBase:
|
||||
return self._host
|
||||
|
||||
|
|
@ -118,16 +115,6 @@ class SceneInventoryController:
|
|||
return self._containers_model.get_version_items(
|
||||
project_name, product_ids)
|
||||
|
||||
def get_hook_loaders_by_identifier(self):
|
||||
"""Returns lists of pre|post hooks per Loader identifier.
|
||||
|
||||
Returns:
|
||||
(dict) {"LoaderName": {"pre": ["PreLoader1"], "post":["PreLoader2]}
|
||||
"""
|
||||
if self._hooks_by_identifier is None:
|
||||
self._hooks_by_identifier = get_hook_loaders_by_identifier()
|
||||
return self._hooks_by_identifier
|
||||
|
||||
# Site Sync methods
|
||||
def is_sitesync_enabled(self):
|
||||
return self._sitesync_model.is_sitesync_enabled()
|
||||
|
|
|
|||
|
|
@ -1339,13 +1339,11 @@ class SwitchAssetDialog(QtWidgets.QDialog):
|
|||
repre_entity = repres_by_name[container_repre_name]
|
||||
|
||||
error = None
|
||||
hook_loaders_by_id = self._controller.get_hook_loaders_by_identifier()
|
||||
try:
|
||||
switch_container(
|
||||
container,
|
||||
repre_entity,
|
||||
loader,
|
||||
hook_loaders_by_id
|
||||
)
|
||||
except (
|
||||
LoaderSwitchNotImplementedError,
|
||||
|
|
|
|||
|
|
@ -1100,7 +1100,6 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
|||
containers_by_id = self._controller.get_containers_by_item_ids(
|
||||
item_ids
|
||||
)
|
||||
hook_loaders_by_id = self._controller.get_hook_loaders_by_identifier()
|
||||
try:
|
||||
for item_id, item_version in zip(item_ids, versions):
|
||||
container = containers_by_id[item_id]
|
||||
|
|
@ -1108,7 +1107,6 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
|||
update_container(
|
||||
container,
|
||||
item_version,
|
||||
hook_loaders_by_id
|
||||
)
|
||||
except AssertionError:
|
||||
log.warning("Update failed", exc_info=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue