mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
public 'discover' function can expect all possible arguments
This commit is contained in:
parent
02a895042d
commit
eef8990101
1 changed files with 31 additions and 5 deletions
|
|
@ -135,11 +135,12 @@ class PluginDiscoverContext(object):
|
||||||
allow_duplicates (bool): Validate class name duplications.
|
allow_duplicates (bool): Validate class name duplications.
|
||||||
ignore_classes (list): List of classes that will be ignored
|
ignore_classes (list): List of classes that will be ignored
|
||||||
and not added to result.
|
and not added to result.
|
||||||
|
return_report (bool): Output will be full report if set to 'True'.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
DiscoverResult: Object holding succesfully discovered plugins,
|
Union[DiscoverResult, list[Any]]: Object holding successfully
|
||||||
ignored plugins, plugins with missing abstract implementation
|
discovered plugins, ignored plugins, plugins with missing
|
||||||
and duplicated plugin.
|
abstract implementation and duplicated plugin.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not ignore_classes:
|
if not ignore_classes:
|
||||||
|
|
@ -268,9 +269,34 @@ class _GlobalDiscover:
|
||||||
return cls._context
|
return cls._context
|
||||||
|
|
||||||
|
|
||||||
def discover(superclass, allow_duplicates=True):
|
def discover(
|
||||||
|
superclass,
|
||||||
|
allow_duplicates=True,
|
||||||
|
ignore_classes=None,
|
||||||
|
return_report=False
|
||||||
|
):
|
||||||
|
"""Find and return subclasses of `superclass`
|
||||||
|
|
||||||
|
Args:
|
||||||
|
superclass (type): Class which determines discovered subclasses.
|
||||||
|
allow_duplicates (bool): Validate class name duplications.
|
||||||
|
ignore_classes (list): List of classes that will be ignored
|
||||||
|
and not added to result.
|
||||||
|
return_report (bool): Output will be full report if set to 'True'.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Union[DiscoverResult, list[Any]]: Object holding successfully
|
||||||
|
discovered plugins, ignored plugins, plugins with missing
|
||||||
|
abstract implementation and duplicated plugin.
|
||||||
|
"""
|
||||||
|
|
||||||
context = _GlobalDiscover.get_context()
|
context = _GlobalDiscover.get_context()
|
||||||
return context.discover(superclass, allow_duplicates)
|
return context.discover(
|
||||||
|
superclass,
|
||||||
|
allow_duplicates,
|
||||||
|
ignore_classes,
|
||||||
|
return_report
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_last_discovered_plugins(superclass):
|
def get_last_discovered_plugins(superclass):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue