Fix for latest develop

This commit is contained in:
Toke Stuart Jepsen 2024-03-18 17:59:15 +00:00
parent 2d87f1b24c
commit ff081b0e50

View file

@ -2,17 +2,14 @@ from collections import defaultdict
from qtpy import QtWidgets, QtCore, QtGui from qtpy import QtWidgets, QtCore, QtGui
from ayon_core.client import ( from ayon_api import get_representations, get_folder_by_id
get_representations,
get_asset_name_identifier
)
from ayon_core.pipeline import load, Anatomy from ayon_core.pipeline import load, Anatomy
from ayon_core import resources, style from ayon_core import resources, style
from ayon_core.pipeline.load import get_representation_path_with_anatomy from ayon_core.pipeline.load import get_representation_path_with_anatomy
from ayon_core.tools.utils import show_message_dialog from ayon_core.tools.utils import show_message_dialog
class ExportOTIO(load.SubsetLoaderPlugin): class ExportOTIO(load.ProductLoaderPlugin):
"""Export selected versions to OpenTimelineIO.""" """Export selected versions to OpenTimelineIO."""
is_multiple_contexts_compatible = True is_multiple_contexts_compatible = True
@ -66,32 +63,30 @@ class ExportOTIOOptionsDialog(QtWidgets.QDialog):
all_representation_names = set() all_representation_names = set()
self._version_path_by_id = {} self._version_path_by_id = {}
version_docs_by_id = { version_docs_by_id = {
context["version"]["_id"]: context["version"] context["version"]["id"]: context["version"]
for context in contexts for context in contexts
} }
repre_docs = list(get_representations( repre_docs = list(get_representations(
self._project_name, version_ids=set(version_docs_by_id) self._project_name, version_ids=set(version_docs_by_id)
)) ))
self._version_by_representation_id = { self._version_by_representation_id = {
repre_doc["_id"]: version_docs_by_id[repre_doc["parent"]] repre_doc["id"]: version_docs_by_id[repre_doc["versionId"]]
for repre_doc in repre_docs for repre_doc in repre_docs
} }
self._version_path_by_id = {} self._version_path_by_id = {}
for context in contexts: for context in contexts:
version_doc = context["version"] version_id = context["version"]["id"]
version_id = version_doc["_id"]
if version_id in self._version_path_by_id: if version_id in self._version_path_by_id:
continue continue
asset_doc = context["asset"] self._version_path_by_id[version_id] = "/".join([
folder_path = get_asset_name_identifier(asset_doc) context["folder"]["path"],
subset_name = context["subset"]["name"] context["product"]["name"],
self._version_path_by_id[version_id] = "{}/{}/v{:03d}".format( context["version"]["name"]
folder_path, subset_name, version_doc["name"] ])
)
representations_by_version_id = defaultdict(list) representations_by_version_id = defaultdict(list)
for repre_doc in repre_docs: for repre_doc in repre_docs:
representations_by_version_id[repre_doc["parent"]].append( representations_by_version_id[repre_doc["versionId"]].append(
repre_doc repre_doc
) )
@ -209,9 +204,11 @@ class ExportOTIOOptionsDialog(QtWidgets.QDialog):
anatomy = Anatomy(self._project_name) anatomy = Anatomy(self._project_name)
clips_data = {} clips_data = {}
for representation in representations: for representation in representations:
version = self._version_by_representation_id[representation["_id"]] version = self._version_by_representation_id[
representation["id"]
]
name = "{}/{}".format( name = "{}/{}".format(
self._version_path_by_id[version["_id"]], self._version_path_by_id[version["id"]],
representation["name"] representation["name"]
) )
clips_data[name] = { clips_data[name] = {