mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge branch 'develop' into mkdocs
This commit is contained in:
commit
2c832ffc13
2 changed files with 63 additions and 50 deletions
|
|
@ -839,7 +839,7 @@ class CreateContext:
|
|||
publish_attributes.update(output)
|
||||
|
||||
for plugin in self.plugins_with_defs:
|
||||
attr_defs = plugin.get_attr_defs_for_context (self)
|
||||
attr_defs = plugin.get_attr_defs_for_context(self)
|
||||
if not attr_defs:
|
||||
continue
|
||||
self._publish_attributes.set_publish_plugin_attr_defs(
|
||||
|
|
@ -1259,50 +1259,6 @@ class CreateContext:
|
|||
with self._bulk_context("add", sender) as bulk_info:
|
||||
yield bulk_info
|
||||
|
||||
# Set publish attributes before bulk context is exited
|
||||
for instance in bulk_info.get_data():
|
||||
publish_attributes = instance.publish_attributes
|
||||
# Prepare publish plugin attributes and set it on instance
|
||||
for plugin in self.plugins_with_defs:
|
||||
try:
|
||||
if is_func_signature_supported(
|
||||
plugin.convert_attribute_values, self, instance
|
||||
):
|
||||
plugin.convert_attribute_values(self, instance)
|
||||
|
||||
elif plugin.__instanceEnabled__:
|
||||
output = plugin.convert_attribute_values(
|
||||
publish_attributes
|
||||
)
|
||||
if output:
|
||||
publish_attributes.update(output)
|
||||
|
||||
except Exception:
|
||||
self.log.error(
|
||||
"Failed to convert attribute values of"
|
||||
f" plugin '{plugin.__name__}'",
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
for plugin in self.plugins_with_defs:
|
||||
attr_defs = None
|
||||
try:
|
||||
attr_defs = plugin.get_attr_defs_for_instance(
|
||||
self, instance
|
||||
)
|
||||
except Exception:
|
||||
self.log.error(
|
||||
"Failed to get attribute definitions"
|
||||
f" from plugin '{plugin.__name__}'.",
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
if not attr_defs:
|
||||
continue
|
||||
instance.set_publish_plugin_attr_defs(
|
||||
plugin.__name__, attr_defs
|
||||
)
|
||||
|
||||
@contextmanager
|
||||
def bulk_instances_collection(self, sender=None):
|
||||
"""DEPRECATED use 'bulk_add_instances' instead."""
|
||||
|
|
@ -2251,6 +2207,50 @@ class CreateContext:
|
|||
if not instances_to_validate:
|
||||
return
|
||||
|
||||
# Set publish attributes before bulk callbacks are triggered
|
||||
for instance in instances_to_validate:
|
||||
publish_attributes = instance.publish_attributes
|
||||
# Prepare publish plugin attributes and set it on instance
|
||||
for plugin in self.plugins_with_defs:
|
||||
try:
|
||||
if is_func_signature_supported(
|
||||
plugin.convert_attribute_values, self, instance
|
||||
):
|
||||
plugin.convert_attribute_values(self, instance)
|
||||
|
||||
elif plugin.__instanceEnabled__:
|
||||
output = plugin.convert_attribute_values(
|
||||
publish_attributes
|
||||
)
|
||||
if output:
|
||||
publish_attributes.update(output)
|
||||
|
||||
except Exception:
|
||||
self.log.error(
|
||||
"Failed to convert attribute values of"
|
||||
f" plugin '{plugin.__name__}'",
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
for plugin in self.plugins_with_defs:
|
||||
attr_defs = None
|
||||
try:
|
||||
attr_defs = plugin.get_attr_defs_for_instance(
|
||||
self, instance
|
||||
)
|
||||
except Exception:
|
||||
self.log.error(
|
||||
"Failed to get attribute definitions"
|
||||
f" from plugin '{plugin.__name__}'.",
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
if not attr_defs:
|
||||
continue
|
||||
instance.set_publish_plugin_attr_defs(
|
||||
plugin.__name__, attr_defs
|
||||
)
|
||||
|
||||
# Cache folder and task entities for all instances at once
|
||||
self.get_instances_context_info(instances_to_validate)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import annotations
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
from typing import Any, Union
|
||||
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.lib import Logger
|
||||
|
|
@ -9,7 +11,7 @@ from .anatomy import Anatomy
|
|||
from .template_data import get_project_template_data
|
||||
|
||||
|
||||
def concatenate_splitted_paths(split_paths, anatomy):
|
||||
def concatenate_splitted_paths(split_paths, anatomy: Anatomy):
|
||||
log = Logger.get_logger("concatenate_splitted_paths")
|
||||
pattern_array = re.compile(r"\[.*\]")
|
||||
output = []
|
||||
|
|
@ -47,7 +49,7 @@ def concatenate_splitted_paths(split_paths, anatomy):
|
|||
return output
|
||||
|
||||
|
||||
def fill_paths(path_list, anatomy):
|
||||
def fill_paths(path_list: list[str], anatomy: Anatomy):
|
||||
format_data = get_project_template_data(project_name=anatomy.project_name)
|
||||
format_data["root"] = anatomy.roots
|
||||
filled_paths = []
|
||||
|
|
@ -59,7 +61,7 @@ def fill_paths(path_list, anatomy):
|
|||
return filled_paths
|
||||
|
||||
|
||||
def create_project_folders(project_name, basic_paths=None):
|
||||
def create_project_folders(project_name: str, basic_paths=None):
|
||||
log = Logger.get_logger("create_project_folders")
|
||||
anatomy = Anatomy(project_name)
|
||||
if basic_paths is None:
|
||||
|
|
@ -80,8 +82,19 @@ def create_project_folders(project_name, basic_paths=None):
|
|||
os.makedirs(path)
|
||||
|
||||
|
||||
def _list_path_items(folder_structure):
|
||||
def _list_path_items(
|
||||
folder_structure: Union[dict[str, Any], list[str]]):
|
||||
output = []
|
||||
|
||||
# Allow leaf folders of the `project_folder_structure` to use a list of
|
||||
# strings instead of a dictionary of keys with empty values.
|
||||
if isinstance(folder_structure, list):
|
||||
if not all(isinstance(item, str) for item in folder_structure):
|
||||
raise ValueError(
|
||||
f"List items must all be strings. Got: {folder_structure}")
|
||||
return [[path] for path in folder_structure]
|
||||
|
||||
# Process key, value as key for folder names and value its subfolders
|
||||
for key, value in folder_structure.items():
|
||||
if not value:
|
||||
output.append(key)
|
||||
|
|
@ -99,7 +112,7 @@ def _list_path_items(folder_structure):
|
|||
return output
|
||||
|
||||
|
||||
def get_project_basic_paths(project_name):
|
||||
def get_project_basic_paths(project_name: str):
|
||||
project_settings = get_project_settings(project_name)
|
||||
folder_structure = (
|
||||
project_settings["core"]["project_folder_structure"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue