mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #1576 from ynput/enhancement/skip-base-classes
Chore: Skip base classes in plugin discovery
This commit is contained in:
commit
7ca1a67d82
3 changed files with 27 additions and 2 deletions
|
|
@ -146,7 +146,15 @@ class BaseCreator(ABC):
|
|||
project_settings (dict[str, Any]): Project settings.
|
||||
create_context (CreateContext): Context which initialized creator.
|
||||
headless (bool): Running in headless mode.
|
||||
|
||||
"""
|
||||
# Attribute 'skip_discovery' is used during discovery phase to skip
|
||||
# plugins, which can be used to mark base plugins that should not be
|
||||
# considered as plugins "to use". The discovery logic does NOT use
|
||||
# the attribute value from parent classes. Each base class has to define
|
||||
# the attribute again.
|
||||
skip_discovery = True
|
||||
|
||||
# Label shown in UI
|
||||
label = None
|
||||
group_label = None
|
||||
|
|
@ -642,7 +650,7 @@ class Creator(BaseCreator):
|
|||
|
||||
Creation requires prepared product name and instance data.
|
||||
"""
|
||||
|
||||
skip_discovery = True
|
||||
# GUI Purposes
|
||||
# - default_variants may not be used if `get_default_variants`
|
||||
# is overridden
|
||||
|
|
@ -931,6 +939,8 @@ class Creator(BaseCreator):
|
|||
|
||||
|
||||
class HiddenCreator(BaseCreator):
|
||||
skip_discovery = True
|
||||
|
||||
@abstractmethod
|
||||
def create(self, instance_data, source_data):
|
||||
pass
|
||||
|
|
@ -941,6 +951,7 @@ class AutoCreator(BaseCreator):
|
|||
|
||||
Can be used e.g. for `workfile`.
|
||||
"""
|
||||
skip_discovery = True
|
||||
|
||||
def remove_instances(self, instances):
|
||||
"""Skip removal."""
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ from .utils import get_representation_path_from_context
|
|||
class LoaderPlugin(list):
|
||||
"""Load representation into host application"""
|
||||
|
||||
# Attribute 'skip_discovery' is used during discovery phase to skip
|
||||
# plugins, which can be used to mark base plugins that should not be
|
||||
# considered as plugins "to use". The discovery logic does NOT use
|
||||
# the attribute value from parent classes. Each base class has to define
|
||||
# the attribute again.
|
||||
skip_discovery = True
|
||||
|
||||
product_types: set[str] = set()
|
||||
product_base_types: Optional[set[str]] = None
|
||||
representations = set()
|
||||
|
|
|
|||
|
|
@ -138,7 +138,14 @@ def discover_plugins(
|
|||
for item in modules:
|
||||
filepath, module = item
|
||||
result.add_module(module)
|
||||
all_plugins.extend(classes_from_module(base_class, module))
|
||||
for cls in classes_from_module(base_class, module):
|
||||
if cls is base_class:
|
||||
continue
|
||||
# Class has defined 'skip_discovery = True'
|
||||
skip_discovery = cls.__dict__.get("skip_discovery")
|
||||
if skip_discovery is True:
|
||||
continue
|
||||
all_plugins.append(cls)
|
||||
|
||||
if base_class not in ignored_classes:
|
||||
ignored_classes.append(base_class)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue