mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
laoder plugin has compatibility method on it's own
This commit is contained in:
parent
439a2b4781
commit
a91a980b1b
2 changed files with 35 additions and 18 deletions
|
|
@ -2,7 +2,10 @@ import os
|
|||
import logging
|
||||
|
||||
from openpype.settings import get_system_settings, get_project_settings
|
||||
from openpype.pipeline import legacy_io
|
||||
from openpype.pipeline import (
|
||||
schema,
|
||||
legacy_io,
|
||||
)
|
||||
from openpype.pipeline.plugin_discover import (
|
||||
discover,
|
||||
register_plugin,
|
||||
|
|
@ -79,6 +82,36 @@ class LoaderPlugin(list):
|
|||
print(" - setting `{}`: `{}`".format(option, value))
|
||||
setattr(cls, option, value)
|
||||
|
||||
@classmethod
|
||||
def is_compatible_loader(cls, context):
|
||||
"""Return whether a loader is compatible with a context.
|
||||
|
||||
This checks the version's families and the representation for the given
|
||||
Loader.
|
||||
|
||||
Returns:
|
||||
bool
|
||||
"""
|
||||
|
||||
maj_version, _ = schema.get_schema_version(context["subset"]["schema"])
|
||||
if maj_version < 3:
|
||||
families = context["version"]["data"].get("families", [])
|
||||
else:
|
||||
families = context["subset"]["data"]["families"]
|
||||
|
||||
representation = context["representation"]
|
||||
has_family = (
|
||||
"*" in cls.families or any(
|
||||
family in cls.families for family in families
|
||||
)
|
||||
)
|
||||
representations = cls.get_representations()
|
||||
has_representation = (
|
||||
"*" in representations
|
||||
or representation["name"] in representations
|
||||
)
|
||||
return has_family and has_representation
|
||||
|
||||
@classmethod
|
||||
def get_representations(cls):
|
||||
return cls.representations
|
||||
|
|
|
|||
|
|
@ -748,25 +748,9 @@ def is_compatible_loader(Loader, context):
|
|||
|
||||
Returns:
|
||||
bool
|
||||
|
||||
"""
|
||||
maj_version, _ = schema.get_schema_version(context["subset"]["schema"])
|
||||
if maj_version < 3:
|
||||
families = context["version"]["data"].get("families", [])
|
||||
else:
|
||||
families = context["subset"]["data"]["families"]
|
||||
|
||||
representation = context["representation"]
|
||||
has_family = (
|
||||
"*" in Loader.families or any(
|
||||
family in Loader.families for family in families
|
||||
)
|
||||
)
|
||||
representations = Loader.get_representations()
|
||||
has_representation = (
|
||||
"*" in representations or representation["name"] in representations
|
||||
)
|
||||
return has_family and has_representation
|
||||
return Loader.is_compatible_loader(context)
|
||||
|
||||
|
||||
def loaders_from_repre_context(loaders, repre_context):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue