mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 22:02:15 +01:00
added collector to stored current context into publish context data
This commit is contained in:
parent
d4f96ae720
commit
0b88bc1fcd
1 changed files with 44 additions and 0 deletions
44
openpype/plugins/publish/collect_current_context.py
Normal file
44
openpype/plugins/publish/collect_current_context.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
"""
|
||||
Provides:
|
||||
context -> projectName (str)
|
||||
context -> asset (str)
|
||||
context -> task (str)
|
||||
"""
|
||||
|
||||
import pyblish.api
|
||||
from openpype.pipeline import legacy_io
|
||||
|
||||
|
||||
class CollectCurrentContext(pyblish.api.ContextPlugin):
|
||||
"""Collect project context into publish context data.
|
||||
|
||||
Plugin does not override any value if is already set.
|
||||
"""
|
||||
|
||||
order = pyblish.api.CollectorOrder - 0.5
|
||||
label = "Collect Current context"
|
||||
|
||||
def process(self, context):
|
||||
# Set project name in context data
|
||||
project_name = context.data.get("projectName")
|
||||
asset_name = context.data.get("asset")
|
||||
task_name = context.data.get("task")
|
||||
if not project_name:
|
||||
project_name = legacy_io.current_project()
|
||||
context.data["projectName"] = project_name
|
||||
|
||||
if not asset_name:
|
||||
asset_name = legacy_io.Session.get("AVALON_ASSET")
|
||||
context.data["asset"] = asset_name
|
||||
|
||||
if not task_name:
|
||||
task_name = legacy_io.Session.get("AVALON_TASK")
|
||||
context.data["task"] = task_name
|
||||
|
||||
# QUESTION should we be explicit with keys? (the same on instances)
|
||||
# - 'asset' -> 'assetName'
|
||||
# - 'task' -> 'taskName'
|
||||
|
||||
self.log.info((
|
||||
"Collected project context\nProject: {}\nAsset: {}\nTask: {}"
|
||||
).format(project_name, asset_name, task_name))
|
||||
Loading…
Add table
Add a link
Reference in a new issue