Apply suggestions from code review

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
This commit is contained in:
Robin De Lillo 2024-11-25 10:14:38 -05:00 committed by GitHub
parent b8ba7f47b0
commit 463ad79a06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
from ayon_core.lib import Logger, filter_profiles, StringTemplate from ayon_core.lib import Logger, filter_profiles, StringTemplate
from ayon_core.settings import get_project_settings from ayon_core.settings import get_project_settings
from ayon_core.pipeline.template_data import get_template_data
from .template_data import get_template_data
from .anatomy import Anatomy from .anatomy import Anatomy
from .tempdir import get_temp_dir from .tempdir import get_temp_dir
@ -71,7 +71,7 @@ def get_staging_dir_config(
template_name = profile["template_name"] template_name = profile["template_name"]
_validate_template_name(project_name, template_name, anatomy) _validate_template_name(project_name, template_name, anatomy)
template = anatomy.templates[STAGING_DIR_TEMPLATES][template_name] template = anatomy.get_template_item("staging", template_name)
if not template: if not template:
# template should always be found either from anatomy or from profile # template should always be found either from anatomy or from profile
@ -93,7 +93,7 @@ def _validate_template_name(project_name, template_name, anatomy):
Raises: Raises:
ValueError - if misconfigured template ValueError - if misconfigured template
""" """
if template_name not in anatomy.templates[STAGING_DIR_TEMPLATES]: if template_name not in anatomy.templates["staging"]:
raise ValueError( raise ValueError(
( (
'Anatomy of project "{}" does not have set' 'Anatomy of project "{}" does not have set'
@ -195,23 +195,25 @@ def get_staging_dir_info(
log=log, log=log,
) )
if not staging_dir_config: if staging_dir_config:
if always_return_path: # no config found but force an output return {
return { "stagingDir": StringTemplate.format_template(
"stagingDir": get_temp_dir( staging_dir_config["template"]["directory"],
project_name=project_entity["name"], ctx_data
anatomy=anatomy, ),
prefix=prefix, "stagingDir_persistent": staging_dir_config["persistence"],
suffix=suffix, }
),
"stagingDir_persistent": False,
}
else:
return None
return { # no config found but force an output
"stagingDir": StringTemplate.format_template( if always_return_path:
staging_dir_config["template"]["directory"], ctx_data return {
), "stagingDir": get_temp_dir(
"stagingDir_persistent": staging_dir_config["persistence"], project_name=project_entity["name"],
} anatomy=anatomy,
prefix=prefix,
suffix=suffix,
),
"stagingDir_persistent": False,
}
return None