mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
AYON: Handle staging templates category (#5905)
* do template replacements on all templates * handle and convert staging templates * use key 'staging' instead of 'staging_dir'
This commit is contained in:
parent
a3fc30b408
commit
7c86115b7e
1 changed files with 34 additions and 11 deletions
|
|
@ -138,16 +138,22 @@ def _template_replacements_to_v3(template):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _convert_template_item(template):
|
def _convert_template_item(template_item):
|
||||||
# Others won't have 'directory'
|
for key, value in tuple(template_item.items()):
|
||||||
if "directory" not in template:
|
template_item[key] = _template_replacements_to_v3(value)
|
||||||
return
|
|
||||||
folder = _template_replacements_to_v3(template.pop("directory"))
|
# Change 'directory' to 'folder'
|
||||||
template["folder"] = folder
|
if "directory" in template_item:
|
||||||
template["file"] = _template_replacements_to_v3(template["file"])
|
template_item["folder"] = template_item.pop("directory")
|
||||||
template["path"] = "/".join(
|
|
||||||
(folder, template["file"])
|
if (
|
||||||
)
|
"path" not in template_item
|
||||||
|
and "file" in template_item
|
||||||
|
and "folder" in template_item
|
||||||
|
):
|
||||||
|
template_item["path"] = "/".join(
|
||||||
|
(template_item["folder"], template_item["file"])
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _fill_template_category(templates, cat_templates, cat_key):
|
def _fill_template_category(templates, cat_templates, cat_key):
|
||||||
|
|
@ -212,10 +218,27 @@ def convert_v4_project_to_v3(project):
|
||||||
_convert_template_item(template)
|
_convert_template_item(template)
|
||||||
new_others_templates[name] = template
|
new_others_templates[name] = template
|
||||||
|
|
||||||
|
staging_templates = templates.pop("staging", None)
|
||||||
|
# Key 'staging_directories' is legacy key that changed
|
||||||
|
# to 'staging_dir'
|
||||||
|
_legacy_staging_templates = templates.pop("staging_directories", None)
|
||||||
|
if staging_templates is None:
|
||||||
|
staging_templates = _legacy_staging_templates
|
||||||
|
|
||||||
|
if staging_templates is None:
|
||||||
|
staging_templates = {}
|
||||||
|
|
||||||
|
# Prefix all staging template names with 'staging_' prefix
|
||||||
|
# and add them to 'others'
|
||||||
|
for name, template in staging_templates.items():
|
||||||
|
_convert_template_item(template)
|
||||||
|
new_name = "staging_{}".format(name)
|
||||||
|
new_others_templates[new_name] = template
|
||||||
|
|
||||||
for key in (
|
for key in (
|
||||||
"work",
|
"work",
|
||||||
"publish",
|
"publish",
|
||||||
"hero"
|
"hero",
|
||||||
):
|
):
|
||||||
cat_templates = templates.pop(key)
|
cat_templates = templates.pop(key)
|
||||||
_fill_template_category(templates, cat_templates, key)
|
_fill_template_category(templates, cat_templates, key)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue