mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
add dict for task name short and type
This commit is contained in:
parent
3c1b04a110
commit
3c6d807df5
8 changed files with 74 additions and 26 deletions
|
|
@ -84,7 +84,7 @@ def override_toolbox_ui():
|
|||
log.warning("Could not import Loader tool")
|
||||
|
||||
try:
|
||||
from avalon.maya.pipeline import launch_workfiles_app
|
||||
from openpype.tools import workfiles as launch_workfiles_app
|
||||
except Exception:
|
||||
log.warning("Could not import Workfiles tool")
|
||||
|
||||
|
|
@ -142,7 +142,12 @@ def override_toolbox_ui():
|
|||
annotation="Work Files",
|
||||
label="Work Files",
|
||||
image=os.path.join(icons, "workfiles.png"),
|
||||
command=lambda: launch_workfiles_app(),
|
||||
command=lambda: launch_workfiles_app.show(
|
||||
os.path.join(
|
||||
mc.workspace(query=True, rootDirectory=True),
|
||||
mc.workspace(fileRuleEntry="scene")
|
||||
)
|
||||
),
|
||||
bgc=background_color,
|
||||
width=icon_size,
|
||||
height=icon_size,
|
||||
|
|
|
|||
|
|
@ -220,6 +220,10 @@ class ExtractHarmonyZip(openpype.api.Extractor):
|
|||
anatomy = openpype.api.Anatomy()
|
||||
project_entity = instance.context.data["projectEntity"]
|
||||
|
||||
task_name = instance.data.get("task")
|
||||
task_type = instance.data['tasks'].get(task_name, {}).get('type')
|
||||
task_short = project_entity['config']['tasks'][task_type]['short_name']
|
||||
|
||||
data = {
|
||||
"root": api.registered_root(),
|
||||
"project": {
|
||||
|
|
@ -229,14 +233,17 @@ class ExtractHarmonyZip(openpype.api.Extractor):
|
|||
"asset": instance.data["asset"],
|
||||
"hierarchy": openpype.api.get_hierarchy(instance.data["asset"]),
|
||||
"family": instance.data["family"],
|
||||
"task": instance.data.get("task"),
|
||||
"task": {
|
||||
"name": task_name,
|
||||
"type": task_type,
|
||||
"short": task_short,
|
||||
},
|
||||
"subset": instance.data["subset"],
|
||||
"version": 1,
|
||||
"ext": "zip",
|
||||
}
|
||||
host_name = "harmony"
|
||||
template_name = get_workfile_template_key_from_context(
|
||||
instance.data["asset"],
|
||||
instance.data.get("task"),
|
||||
host_name,
|
||||
project_name=project_entity["name"],
|
||||
|
|
|
|||
|
|
@ -989,6 +989,10 @@ class Templates:
|
|||
invalid_required = []
|
||||
missing_required = []
|
||||
replace_keys = []
|
||||
|
||||
if "{task[name]}" in orig_template and not isinstance(data["task"], dict):
|
||||
data['task']= {'name': data.get("task")}
|
||||
|
||||
for group in self.key_pattern.findall(template):
|
||||
orig_key = group[1:-1]
|
||||
key = str(orig_key)
|
||||
|
|
@ -1074,6 +1078,10 @@ class Templates:
|
|||
output = collections.defaultdict(dict)
|
||||
for key, orig_value in templates.items():
|
||||
if isinstance(orig_value, StringType):
|
||||
# Replace {task} by '{task[name]}' for backward compatibility
|
||||
if '{task}' in orig_value:
|
||||
orig_value = orig_value.replace('{task}', '{task[name]}')
|
||||
|
||||
output[key] = self._format(orig_value, data)
|
||||
continue
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import platform
|
|||
import logging
|
||||
import collections
|
||||
import functools
|
||||
import getpass
|
||||
|
||||
from openpype.settings import get_project_settings
|
||||
from .anatomy import Anatomy
|
||||
|
|
@ -346,7 +347,7 @@ def get_latest_version(asset_name, subset_name, dbcon=None, project_name=None):
|
|||
|
||||
|
||||
def get_workfile_template_key_from_context(
|
||||
asset_name, task_name, host_name, project_name=None,
|
||||
task_info, host_name, project_name=None,
|
||||
dbcon=None, project_settings=None
|
||||
):
|
||||
"""Helper function to get template key for workfile template.
|
||||
|
|
@ -358,9 +359,8 @@ def get_workfile_template_key_from_context(
|
|||
'project_name' arguments.
|
||||
|
||||
Args:
|
||||
asset_name(str): Name of asset document.
|
||||
task_name(str): Task name for which is template key retrieved.
|
||||
Must be available on asset document under `data.tasks`.
|
||||
task_info(dict): Information about the task is used to retrieve the
|
||||
`type` of the task.
|
||||
host_name(str): Name of host implementation for which is workfile
|
||||
used.
|
||||
project_name(str): Project name where asset and task is. Not required
|
||||
|
|
@ -387,17 +387,6 @@ def get_workfile_template_key_from_context(
|
|||
elif not project_name:
|
||||
project_name = dbcon.Session["AVALON_PROJECT"]
|
||||
|
||||
asset_doc = dbcon.find_one(
|
||||
{
|
||||
"type": "asset",
|
||||
"name": asset_name
|
||||
},
|
||||
{
|
||||
"data.tasks": 1
|
||||
}
|
||||
)
|
||||
asset_tasks = asset_doc.get("data", {}).get("tasks") or {}
|
||||
task_info = asset_tasks.get(task_name) or {}
|
||||
task_type = task_info.get("type")
|
||||
|
||||
return get_workfile_template_key(
|
||||
|
|
@ -479,15 +468,27 @@ def get_workdir_data(project_doc, asset_doc, task_name, host_name):
|
|||
"""
|
||||
hierarchy = "/".join(asset_doc["data"]["parents"])
|
||||
|
||||
task_type = asset_doc['data']['tasks'].get(task_name, {}).get('type')
|
||||
|
||||
if task_type:
|
||||
task_code = project_doc['config']['tasks'][task_type]['short_name']
|
||||
else:
|
||||
task_code = None
|
||||
|
||||
data = {
|
||||
"project": {
|
||||
"name": project_doc["name"],
|
||||
"code": project_doc["data"].get("code")
|
||||
},
|
||||
"task": task_name,
|
||||
"task": {
|
||||
"name": task_name,
|
||||
"type": task_type,
|
||||
"short": task_code,
|
||||
},
|
||||
"asset": asset_doc["name"],
|
||||
"app": host_name,
|
||||
"hierarchy": hierarchy
|
||||
"user": getpass.getuser(),
|
||||
"hierarchy": hierarchy,
|
||||
}
|
||||
return data
|
||||
|
||||
|
|
@ -530,7 +531,6 @@ def get_workdir_with_workdir_data(
|
|||
|
||||
if not template_key:
|
||||
template_key = get_workfile_template_key_from_context(
|
||||
workdir_data["asset"],
|
||||
workdir_data["task"],
|
||||
workdir_data["app"],
|
||||
project_name=workdir_data["project"]["name"],
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
"frame": "{frame:0>{@frame_padding}}"
|
||||
},
|
||||
"work": {
|
||||
"folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/work/{task}",
|
||||
"file": "{project[code]}_{asset}_{task}_{@version}<_{comment}>.{ext}",
|
||||
"folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/work/{task[user]}",
|
||||
"file": "{project[code]}_{asset}_{task[user]}_{@version}<_{comment}>.{ext}",
|
||||
"path": "{@folder}/{@file}"
|
||||
},
|
||||
"render": {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
"type": "dict",
|
||||
"key": "defaults",
|
||||
"children": [
|
||||
{
|
||||
"type": "label",
|
||||
"label": "The list of existing default placeholders for the construction of paths:<br> {root[`root_name`]}, {project[name]}, {project[short]}, {hierarchy}, {asset}, {task[name]}, {task[type]}, {task[code]}, {family}, {subset}, {output}, {ext}, {thumbnail_root}, {_id}, {thumbnail_type} "
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"key": "version_padding",
|
||||
|
|
|
|||
|
|
@ -856,6 +856,13 @@ def get_anatomy_settings(
|
|||
apply_local_settings_on_anatomy_settings(
|
||||
result, local_settings, project_name, site_name
|
||||
)
|
||||
|
||||
# Replace {task} by '{task[name]}' in all template for backward compatibility
|
||||
for template in result.get('templates', {}).values():
|
||||
for sub_template_name, sub_template_value in template.items():
|
||||
if isinstance(sub_template_value, str) and '{task}' in sub_template_value:
|
||||
template[sub_template_name] = sub_template_value.replace('{task}', '{task[name]}')
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,16 +65,33 @@ class NameWindow(QtWidgets.QDialog):
|
|||
{"type": "project"},
|
||||
{
|
||||
"name": True,
|
||||
"data.code": True
|
||||
"data.code": True,
|
||||
"config.tasks": True,
|
||||
}
|
||||
)
|
||||
asset_doc = io.find_one({
|
||||
"type": "asset",
|
||||
"name": asset_name
|
||||
})
|
||||
|
||||
task_type = asset_doc['data']['tasks'].get(session["AVALON_TASK"], {}).get('type')
|
||||
|
||||
if task_type:
|
||||
task_short = project_doc['config']['tasks'][task_type]['short_name']
|
||||
else:
|
||||
task_short = None
|
||||
|
||||
self.data = {
|
||||
"project": {
|
||||
"name": project_doc["name"],
|
||||
"code": project_doc["data"].get("code")
|
||||
},
|
||||
"asset": asset_name,
|
||||
"task": session["AVALON_TASK"],
|
||||
"task": {
|
||||
"name": session["AVALON_TASK"],
|
||||
"type": task_type,
|
||||
"short": task_short,
|
||||
},
|
||||
"version": 1,
|
||||
"user": getpass.getuser(),
|
||||
"comment": "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue