mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #1122 from ynput/enhancement/helper-template-data-method
Create: Add helper 'get_template_data' to create context
This commit is contained in:
commit
c92f8651e8
1 changed files with 31 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ from ayon_core.lib.events import QueuedEventSystem
|
|||
from ayon_core.lib.attribute_definitions import get_default_values
|
||||
from ayon_core.host import IPublishHost, IWorkfileHost
|
||||
from ayon_core.pipeline import Anatomy
|
||||
from ayon_core.pipeline.template_data import get_template_data
|
||||
from ayon_core.pipeline.plugin_discover import DiscoverResult
|
||||
|
||||
from .exceptions import (
|
||||
|
|
@ -480,6 +481,36 @@ class CreateContext:
|
|||
self.get_current_project_name())
|
||||
return self._current_project_settings
|
||||
|
||||
def get_template_data(
|
||||
self, folder_path: Optional[str], task_name: Optional[str]
|
||||
) -> Dict[str, Any]:
|
||||
"""Prepare template data for given context.
|
||||
|
||||
Method is using cached entities and settings to prepare template data.
|
||||
|
||||
Args:
|
||||
folder_path (Optional[str]): Folder path.
|
||||
task_name (Optional[str]): Task name.
|
||||
|
||||
Returns:
|
||||
dict[str, Any]: Template data.
|
||||
|
||||
"""
|
||||
project_entity = self.get_current_project_entity()
|
||||
folder_entity = task_entity = None
|
||||
if folder_path:
|
||||
folder_entity = self.get_folder_entity(folder_path)
|
||||
if task_name and folder_entity:
|
||||
task_entity = self.get_task_entity(folder_path, task_name)
|
||||
|
||||
return get_template_data(
|
||||
project_entity,
|
||||
folder_entity,
|
||||
task_entity,
|
||||
host_name=self.host_name,
|
||||
settings=self.get_current_project_settings(),
|
||||
)
|
||||
|
||||
@property
|
||||
def context_has_changed(self):
|
||||
"""Host context has changed.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue