Global: Optimize anatomy formatting by only formatting used templates instead (#4784)

* TemplatesDict can create different type of template

* anatomy templates can be formatted on their own

* return objected templates on get item

* '_rootless_path' is public classmethod 'rootless_path_from_result'

* 'AnatomyStringTemplate' expect anatomy templates

* remove key getters

* fix typo 'create_ojected_templates' -> 'create_objected_templates'

* Fix type of argument

* Fix long line

* Optimize formatting to use single template formatting instead of formatting full anatomy

* Optimize formatting to use single template formatting instead of formatting full anatomy

* Optimize formatting to use single template formatting instead of formatting full anatomy

* Optimize formatting to use single template formatting instead of formatting full anatomy

* Optimize formatting to use single template formatting instead of formatting full anatomy

* Optimize formatting to use single template formatting instead of formatting full anatomy

* Optimize formatting to use single template formatting instead of formatting full anatomy

* Use format strict + code cosmetics

* Get template from the formatted data

* Update openpype/plugins/publish/integrate_legacy.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

* Cosmetics

* Move template obj definition for path up + rename to `path_template_obj`

* Refactor more cases from `anatomy.format` to template obj `.format_strict`

* Refactor more cases from `anatomy.format` to template obj `.format_strict`

* Refactor more cases from `anatomy.format` to template obj `.format_strict`

---------

Co-authored-by: Jakub Trllo <jakub.trllo@gmail.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
This commit is contained in:
Roy Nieterau 2023-04-17 14:53:15 +02:00 committed by GitHub
parent dc82268165
commit b05afaa837
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 79 additions and 84 deletions

View file

@ -327,7 +327,8 @@ def get_usd_master_path(asset, subset, representation):
else:
asset_doc = get_asset_by_name(project_name, asset, fields=["name"])
formatted_result = anatomy.format(
template_obj = anatomy.templates_obj["publish"]["path"]
path = template_obj.format_strict(
{
"project": {
"name": project_name,
@ -340,7 +341,6 @@ def get_usd_master_path(asset, subset, representation):
}
)
path = formatted_result["publish"]["path"]
# Remove the version folder
subset_folder = os.path.dirname(os.path.dirname(path))
master_folder = os.path.join(subset_folder, "master")