Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Add 'parents' to folder template data #778

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions client/ayon_core/pipeline/template_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,13 @@ def get_folder_template_data(folder_entity, project_name):
"""

path = folder_entity["path"]
hierarchy_parts = path.split("/")
# Remove empty string from the beginning
hierarchy_parts.pop(0)
# Remove empty string from the beginning and split by '/'
parents = path.lstrip("/").split("/")
# Remove last part which is folder name
folder_name = hierarchy_parts.pop(-1)
hierarchy = "/".join(hierarchy_parts)
if hierarchy_parts:
parent_name = hierarchy_parts[-1]
folder_name = parents.pop(-1)
hierarchy = "/".join(parents)
if parents:
parent_name = parents[-1]
else:
parent_name = project_name

Expand All @@ -103,6 +102,7 @@ def get_folder_template_data(folder_entity, project_name):
"name": folder_name,
"type": folder_entity["folderType"],
"path": path,
"parents": parents,
},
"asset": folder_name,
"hierarchy": hierarchy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@ def _fill_folder_data(self, instance, project_entity, anatomy_data):
anatomy_data["hierarchy"] = hierarchy

parent_name = project_entity["name"]
parents = []
Copy link
Member

@jakubjezek001 jakubjezek001 Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems valid to always have parents filled with at least project, right? Since we are converting parent_name from project name in case there is no parent at all it would be fair to also add it. In this case {folder[parent[-1]]} would always work.

Copy link
Member Author

@iLLiCiTiT iLLiCiTiT Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't think project should be there. But the use-case is that they would like to be able to use {folder[parents][0]} and {folder[parents][1]} not really -1. For -1 you can use {parent}.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think project name should be there too - the reason why is that you should be explicit enough if you want to have project name there (and you can access it with another key).

So if you have asset folder directly under project, {folder[parents][0]} will not work if I am not mistaken.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if you have asset folder directly under project, {folder[parents][0]} will not work if I am not mistaken.

Yes, it won't.

if hierarchy:
parent_name = hierarchy.split("/")[-1]
parents = hierarchy.split("/")
parent_name = parents[-1]

folder_name = instance.data["folderPath"].split("/")[-1]
anatomy_data.update({
Expand All @@ -422,6 +424,7 @@ def _fill_folder_data(self, instance, project_entity, anatomy_data):
# Using 'Shot' is current default behavior of editorial
# (or 'newHierarchyIntegration') publishing.
"type": "Shot",
"parents": parents,
},
})

Expand Down