mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
removed ftrackIntentLabel
This commit is contained in:
parent
053c2df59e
commit
cb3722552c
3 changed files with 20 additions and 82 deletions
|
|
@ -1,78 +0,0 @@
|
|||
"""
|
||||
Requires:
|
||||
context -> ftrackSession - connected ftrack.Session
|
||||
|
||||
Provides:
|
||||
context -> ftrackIntentLabel
|
||||
"""
|
||||
import json
|
||||
|
||||
import six
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class CollectFtrackIntentLabel(pyblish.api.ContextPlugin):
|
||||
""" Collects an ftrack session and the current task id. """
|
||||
|
||||
order = pyblish.api.CollectorOrder + 0.49991
|
||||
label = "Collect Ftrack Intent Label"
|
||||
|
||||
def process(self, context):
|
||||
intent = context.data.get("intent")
|
||||
if intent and isinstance(intent, dict):
|
||||
intent_val = intent.get("value")
|
||||
intent_label = intent.get("label")
|
||||
else:
|
||||
intent_val = intent_label = intent
|
||||
|
||||
session = context.data.get("ftrackSession")
|
||||
if session is None:
|
||||
context.data["ftrackIntentLabel"] = intent_label
|
||||
self.log.info("Ftrack session is not available. Skipping.")
|
||||
return
|
||||
|
||||
final_intent_label = None
|
||||
if intent_val:
|
||||
final_intent_label = self.get_intent_label(session, intent_val)
|
||||
|
||||
if final_intent_label is None:
|
||||
final_intent_label = intent_label
|
||||
|
||||
context.data["ftrackIntentLabel"] = final_intent_label
|
||||
|
||||
def get_intent_label(self, session, intent_value):
|
||||
if not intent_value:
|
||||
return
|
||||
|
||||
intent_configurations = session.query(
|
||||
"CustomAttributeConfiguration where key is intent"
|
||||
).all()
|
||||
if not intent_configurations:
|
||||
return
|
||||
|
||||
intent_configuration = intent_configurations[0]
|
||||
if len(intent_configuration) > 1:
|
||||
self.log.warning((
|
||||
"Found more than one `intent` custom attribute."
|
||||
" Using first found."
|
||||
))
|
||||
|
||||
config = intent_configuration.get("config")
|
||||
if not config:
|
||||
return
|
||||
|
||||
configuration = json.loads(config)
|
||||
items = configuration.get("data")
|
||||
if not items:
|
||||
return
|
||||
|
||||
if isinstance(items, six.string_types):
|
||||
items = json.loads(items)
|
||||
|
||||
intent_label = None
|
||||
for item in items:
|
||||
if item["value"] == intent_value:
|
||||
intent_label = item["menu"]
|
||||
break
|
||||
|
||||
return intent_label
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
Requires:
|
||||
context > comment
|
||||
context > ftrackSession
|
||||
context > ftrackIntentLabel
|
||||
instance > ftrackIntegratedAssetVersionsData
|
||||
"""
|
||||
|
||||
|
|
@ -41,7 +40,16 @@ class IntegrateFtrackDescription(pyblish.api.InstancePlugin):
|
|||
|
||||
session = instance.context.data["ftrackSession"]
|
||||
|
||||
intent_label = instance.context.data["ftrackIntentLabel"]
|
||||
intent = instance.context.data.get("intent")
|
||||
intent_label = None
|
||||
if intent and isinstance(intent, dict):
|
||||
intent_val = intent.get("value")
|
||||
intent_label = intent.get("label")
|
||||
else:
|
||||
intent_val = intent
|
||||
|
||||
if not intent_label:
|
||||
intent_label = intent_val or ""
|
||||
|
||||
# if intent label is set then format comment
|
||||
# - it is possible that intent_label is equal to "" (empty string)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ Requires:
|
|||
context > appLabel
|
||||
context > comment
|
||||
context > ftrackSession
|
||||
context > ftrackIntentLabel
|
||||
instance > ftrackIntegratedAssetVersionsData
|
||||
"""
|
||||
|
||||
|
|
@ -52,7 +51,16 @@ class IntegrateFtrackNote(pyblish.api.InstancePlugin):
|
|||
|
||||
session = context.data["ftrackSession"]
|
||||
|
||||
intent_label = context.data["ftrackIntentLabel"]
|
||||
intent = instance.context.data.get("intent")
|
||||
intent_label = None
|
||||
if intent and isinstance(intent, dict):
|
||||
intent_val = intent.get("value")
|
||||
intent_label = intent.get("label")
|
||||
else:
|
||||
intent_val = intent
|
||||
|
||||
if not intent_label:
|
||||
intent_label = intent_val or ""
|
||||
|
||||
# if intent label is set then format comment
|
||||
# - it is possible that intent_label is equal to "" (empty string)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue