mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge branch 'develop' into enhancement/save-next-version-reuse-comment
This commit is contained in:
commit
f7b4aca461
1 changed files with 17 additions and 6 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
import ayon_api
|
import ayon_api
|
||||||
import ayon_api.utils
|
import ayon_api.utils
|
||||||
|
|
||||||
|
from ayon_core.host import ILoadHost
|
||||||
from ayon_core.pipeline import registered_host
|
from ayon_core.pipeline import registered_host
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,16 +29,23 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
|
||||||
def process(self, context):
|
def process(self, context):
|
||||||
host = registered_host()
|
host = registered_host()
|
||||||
if host is None:
|
if host is None:
|
||||||
self.log.warn("No registered host.")
|
self.log.warning("No registered host.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not hasattr(host, "ls"):
|
if not isinstance(host, ILoadHost):
|
||||||
host_name = host.__name__
|
host_name = host.name
|
||||||
self.log.warn("Host %r doesn't have ls() implemented." % host_name)
|
self.log.warning(
|
||||||
|
f"Host {host_name} does not implement ILoadHost. "
|
||||||
|
"Skipping querying of loaded versions in scene."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
containers = list(host.get_containers())
|
||||||
|
if not containers:
|
||||||
|
# Opt out early if there are no containers
|
||||||
|
self.log.debug("No loaded containers found in scene.")
|
||||||
return
|
return
|
||||||
|
|
||||||
loaded_versions = []
|
|
||||||
containers = list(host.ls())
|
|
||||||
repre_ids = {
|
repre_ids = {
|
||||||
container["representation"]
|
container["representation"]
|
||||||
for container in containers
|
for container in containers
|
||||||
|
|
@ -61,6 +70,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
|
||||||
|
|
||||||
# QUESTION should we add same representation id when loaded multiple
|
# QUESTION should we add same representation id when loaded multiple
|
||||||
# times?
|
# times?
|
||||||
|
loaded_versions = []
|
||||||
for con in containers:
|
for con in containers:
|
||||||
repre_id = con["representation"]
|
repre_id = con["representation"]
|
||||||
repre_entity = repre_entities_by_id.get(repre_id)
|
repre_entity = repre_entities_by_id.get(repre_id)
|
||||||
|
|
@ -80,4 +90,5 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
|
||||||
}
|
}
|
||||||
loaded_versions.append(version)
|
loaded_versions.append(version)
|
||||||
|
|
||||||
|
self.log.debug(f"Collected {len(loaded_versions)} loaded versions.")
|
||||||
context.data["loadedVersions"] = loaded_versions
|
context.data["loadedVersions"] = loaded_versions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue