mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge branch 'hotfix/editorial_one_shot_publish' into 2.x/develop
This commit is contained in:
commit
ed5bb3e4e4
4 changed files with 72 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ import sys
|
|||
import six
|
||||
import pyblish.api
|
||||
from avalon import io
|
||||
from pprint import pformat
|
||||
|
||||
try:
|
||||
from pype.modules.ftrack.lib.avalon_sync import CUST_ATTR_AUTO_SYNC
|
||||
|
|
@ -40,9 +41,14 @@ class IntegrateHierarchyToFtrack(pyblish.api.ContextPlugin):
|
|||
|
||||
def process(self, context):
|
||||
self.context = context
|
||||
if "hierarchyContext" not in context.data:
|
||||
if "hierarchyContext" not in self.context.data:
|
||||
return
|
||||
|
||||
hierarchy_context = self.context.data["hierarchyContext"]
|
||||
|
||||
self.log.debug(
|
||||
f"__ hierarchy_context: `{pformat(hierarchy_context)}`")
|
||||
|
||||
self.session = self.context.data["ftrackSession"]
|
||||
project_name = self.context.data["projectEntity"]["name"]
|
||||
query = 'Project where full_name is "{}"'.format(project_name)
|
||||
|
|
@ -55,7 +61,7 @@ class IntegrateHierarchyToFtrack(pyblish.api.ContextPlugin):
|
|||
|
||||
self.ft_project = None
|
||||
|
||||
input_data = context.data["hierarchyContext"]
|
||||
input_data = hierarchy_context
|
||||
|
||||
# disable termporarily ftrack project's autosyncing
|
||||
if auto_sync_state:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class ExtractHierarchyToAvalon(pyblish.api.ContextPlugin):
|
|||
families = ["clip", "shot"]
|
||||
|
||||
def process(self, context):
|
||||
# processing starts here
|
||||
if "hierarchyContext" not in context.data:
|
||||
self.log.info("skipping IntegrateHierarchyToAvalon")
|
||||
return
|
||||
|
|
@ -17,7 +18,29 @@ class ExtractHierarchyToAvalon(pyblish.api.ContextPlugin):
|
|||
if not io.Session:
|
||||
io.install()
|
||||
|
||||
input_data = context.data["hierarchyContext"]
|
||||
active_assets = []
|
||||
hierarchy_context = context.data["hierarchyContext"]
|
||||
hierarchy_assets = self._get_assets(hierarchy_context)
|
||||
|
||||
# filter only the active publishing insatnces
|
||||
for instance in context:
|
||||
if instance.data.get("publish") is False:
|
||||
continue
|
||||
|
||||
if not instance.data.get("asset"):
|
||||
continue
|
||||
|
||||
active_assets.append(instance.data["asset"])
|
||||
|
||||
# filter out only assets which are activated as isntances
|
||||
new_hierarchy_assets = {k: v for k, v in hierarchy_assets.items()
|
||||
if k in active_assets}
|
||||
|
||||
# modify the hierarchy context so there are only fitred assets
|
||||
self._set_assets(hierarchy_context, new_hierarchy_assets)
|
||||
|
||||
input_data = context.data["hierarchyContext"] = hierarchy_context
|
||||
|
||||
self.project = None
|
||||
self.import_to_avalon(input_data)
|
||||
|
||||
|
|
@ -149,3 +172,41 @@ class ExtractHierarchyToAvalon(pyblish.api.ContextPlugin):
|
|||
entity_id = io.insert_one(item).inserted_id
|
||||
|
||||
return io.find_one({"_id": entity_id})
|
||||
|
||||
def _get_assets(self, input_dict):
|
||||
""" Returns only asset dictionary.
|
||||
Usually the last part of deep dictionary which
|
||||
is not having any children
|
||||
"""
|
||||
for key in input_dict.keys():
|
||||
# check if child key is available
|
||||
if input_dict[key].get("childs"):
|
||||
# loop deeper
|
||||
return self._get_assets(input_dict[key]["childs"])
|
||||
else:
|
||||
# give the dictionary with assets
|
||||
return input_dict
|
||||
|
||||
def _set_assets(self, input_dict, new_assets=None):
|
||||
""" Modify the hierarchy context dictionary.
|
||||
It will replace the asset dictionary with only the filtred one.
|
||||
"""
|
||||
for key in input_dict.keys():
|
||||
# check if child key is available
|
||||
if input_dict[key].get("childs"):
|
||||
# return if this is just for testing purpose and no
|
||||
# new_assets property is avalable
|
||||
if not new_assets:
|
||||
return True
|
||||
|
||||
# test for deeper inner children availabelity
|
||||
if self._set_assets(input_dict[key]["childs"]):
|
||||
# if one level deeper is still children available
|
||||
# then process farther
|
||||
self._set_assets(input_dict[key]["childs"], new_assets)
|
||||
else:
|
||||
# or just assign the filtred asset ditionary
|
||||
input_dict[key]["childs"] = new_assets
|
||||
else:
|
||||
# test didnt find more childs in input dictionary
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class CollectEditorial(pyblish.api.InstancePlugin):
|
|||
actions = []
|
||||
|
||||
# presets
|
||||
extensions = [".mov"]
|
||||
extensions = [".mov", ".mp4"]
|
||||
|
||||
def process(self, instance):
|
||||
# remove context test attribute
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "2.12.0"
|
||||
__version__ = "2.12.1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue