mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
cleanup changes based on comments
This commit is contained in:
parent
1b7af3e2c6
commit
7a8aa123ff
1 changed files with 22 additions and 35 deletions
|
|
@ -29,10 +29,7 @@ class LoaderPlugin(list):
|
||||||
|
|
||||||
families = []
|
families = []
|
||||||
representations = []
|
representations = []
|
||||||
# Extensions filtering was not available until 20/2/2023
|
extensions = {"*"}
|
||||||
# - filtering by extensions is not enabled if is set to 'None'
|
|
||||||
# which is to keep backwards compatibility
|
|
||||||
extensions = None
|
|
||||||
order = 0
|
order = 0
|
||||||
is_multiple_contexts_compatible = False
|
is_multiple_contexts_compatible = False
|
||||||
enabled = True
|
enabled = True
|
||||||
|
|
@ -95,11 +92,8 @@ class LoaderPlugin(list):
|
||||||
bool: Representation has valid extension
|
bool: Representation has valid extension
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Empty list of extensions is considered as all representations are
|
if "*" in cls.extensions:
|
||||||
# invalid -> use '["*"]' to support all extensions
|
return True
|
||||||
valid_extensions = cls.extensions
|
|
||||||
if not valid_extensions:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Get representation main file extension from 'context'
|
# Get representation main file extension from 'context'
|
||||||
repre_context = repre_doc.get("context") or {}
|
repre_context = repre_doc.get("context") or {}
|
||||||
|
|
@ -114,22 +108,16 @@ class LoaderPlugin(list):
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
cls.log.info("Using legacy source of extension on representation.")
|
cls.log.info("Using legacy source of extension from path.")
|
||||||
ext = os.path.splitext(path)[-1]
|
ext = os.path.splitext(path)[-1].lstrip(".")
|
||||||
while ext.startswith("."):
|
|
||||||
ext = ext[1:]
|
|
||||||
|
|
||||||
# If representation does not have extension then can't be valid
|
# If representation does not have extension then can't be valid
|
||||||
if not ext:
|
if not ext:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if "*" in valid_extensions:
|
valid_extensions_low = {ext.lower() for ext in cls.extensions}
|
||||||
return True
|
|
||||||
|
|
||||||
valid_extensions_low = {ext.lower() for ext in valid_extensions}
|
|
||||||
return ext.lower() in valid_extensions_low
|
return ext.lower() in valid_extensions_low
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_compatible_loader(cls, context):
|
def is_compatible_loader(cls, context):
|
||||||
"""Return whether a loader is compatible with a context.
|
"""Return whether a loader is compatible with a context.
|
||||||
|
|
@ -149,7 +137,11 @@ class LoaderPlugin(list):
|
||||||
|
|
||||||
plugin_repre_names = cls.get_representations()
|
plugin_repre_names = cls.get_representations()
|
||||||
plugin_families = cls.families
|
plugin_families = cls.families
|
||||||
if not plugin_repre_names or not plugin_families:
|
if (
|
||||||
|
not plugin_repre_names
|
||||||
|
or not plugin_families
|
||||||
|
or not cls.extensions
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
repre_doc = context.get("representation")
|
repre_doc = context.get("representation")
|
||||||
|
|
@ -163,32 +155,27 @@ class LoaderPlugin(list):
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if (
|
if not cls.has_valid_extension(repre_doc):
|
||||||
cls.extensions is not None
|
|
||||||
and not cls.has_valid_extension(repre_doc)
|
|
||||||
):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
verison_doc = context["version"]
|
plugin_families = set(plugin_families)
|
||||||
|
if "*" in plugin_families:
|
||||||
|
return True
|
||||||
|
|
||||||
subset_doc = context["subset"]
|
subset_doc = context["subset"]
|
||||||
maj_version, _ = schema.get_schema_version(subset_doc["schema"])
|
maj_version, _ = schema.get_schema_version(subset_doc["schema"])
|
||||||
if maj_version < 3:
|
if maj_version < 3:
|
||||||
families = verison_doc["data"].get("families")
|
families = context["version"]["data"].get("families")
|
||||||
else:
|
else:
|
||||||
families = context["subset"]["data"].get("families")
|
families = subset_doc["data"].get("families")
|
||||||
if families is None:
|
if families is None:
|
||||||
family = context["subset"]["data"].get("family")
|
family = subset_doc["data"].get("family")
|
||||||
if family:
|
if family:
|
||||||
families = [family]
|
families = [family]
|
||||||
|
|
||||||
plugin_families = set(plugin_families)
|
if not families:
|
||||||
return (
|
return False
|
||||||
"*" in plugin_families
|
return any(family in plugin_families for family in families)
|
||||||
or any(
|
|
||||||
family in plugin_families
|
|
||||||
for family in (families or [])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_representations(cls):
|
def get_representations(cls):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue