mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +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.
|
project_settings (dict[str, Any]): Project settings.
|
||||||
create_context (CreateContext): Context which initialized creator.
|
create_context (CreateContext): Context which initialized creator.
|
||||||
headless (bool): Running in headless mode.
|
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 shown in UI
|
||||||
label = None
|
label = None
|
||||||
group_label = None
|
group_label = None
|
||||||
|
|
@ -642,7 +650,7 @@ class Creator(BaseCreator):
|
||||||
|
|
||||||
Creation requires prepared product name and instance data.
|
Creation requires prepared product name and instance data.
|
||||||
"""
|
"""
|
||||||
|
skip_discovery = True
|
||||||
# GUI Purposes
|
# GUI Purposes
|
||||||
# - default_variants may not be used if `get_default_variants`
|
# - default_variants may not be used if `get_default_variants`
|
||||||
# is overridden
|
# is overridden
|
||||||
|
|
@ -931,6 +939,8 @@ class Creator(BaseCreator):
|
||||||
|
|
||||||
|
|
||||||
class HiddenCreator(BaseCreator):
|
class HiddenCreator(BaseCreator):
|
||||||
|
skip_discovery = True
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def create(self, instance_data, source_data):
|
def create(self, instance_data, source_data):
|
||||||
pass
|
pass
|
||||||
|
|
@ -941,6 +951,7 @@ class AutoCreator(BaseCreator):
|
||||||
|
|
||||||
Can be used e.g. for `workfile`.
|
Can be used e.g. for `workfile`.
|
||||||
"""
|
"""
|
||||||
|
skip_discovery = True
|
||||||
|
|
||||||
def remove_instances(self, instances):
|
def remove_instances(self, instances):
|
||||||
"""Skip removal."""
|
"""Skip removal."""
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,13 @@ from .utils import get_representation_path_from_context
|
||||||
class LoaderPlugin(list):
|
class LoaderPlugin(list):
|
||||||
"""Load representation into host application"""
|
"""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_types: set[str] = set()
|
||||||
product_base_types: Optional[set[str]] = None
|
product_base_types: Optional[set[str]] = None
|
||||||
representations = set()
|
representations = set()
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,14 @@ def discover_plugins(
|
||||||
for item in modules:
|
for item in modules:
|
||||||
filepath, module = item
|
filepath, module = item
|
||||||
result.add_module(module)
|
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:
|
if base_class not in ignored_classes:
|
||||||
ignored_classes.append(base_class)
|
ignored_classes.append(base_class)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue