mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +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
|
import logging
|
||||||
|
|
||||||
from openpype.settings import get_system_settings, get_project_settings
|
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 (
|
from openpype.pipeline.plugin_discover import (
|
||||||
discover,
|
discover,
|
||||||
register_plugin,
|
register_plugin,
|
||||||
|
|
@ -79,6 +82,36 @@ class LoaderPlugin(list):
|
||||||
print(" - setting `{}`: `{}`".format(option, value))
|
print(" - setting `{}`: `{}`".format(option, value))
|
||||||
setattr(cls, 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
|
@classmethod
|
||||||
def get_representations(cls):
|
def get_representations(cls):
|
||||||
return cls.representations
|
return cls.representations
|
||||||
|
|
|
||||||
|
|
@ -748,25 +748,9 @@ def is_compatible_loader(Loader, context):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool
|
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"]
|
return Loader.is_compatible_loader(context)
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def loaders_from_repre_context(loaders, repre_context):
|
def loaders_from_repre_context(loaders, repre_context):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue