Apply suggestions from code review

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
This commit is contained in:
Jakub Ježek 2024-10-24 14:00:36 +02:00 committed by GitHub
parent fedf8e60c7
commit ea23f355f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 24 deletions

View file

@ -721,8 +721,7 @@ def get_instance_staging_dir(instance):
# TODO: not sure if this is necessary
# path might be already created by get_staging_dir
if not os.path.exists(staging_dir_path):
os.makedirs(staging_dir_path)
os.makedirs(staging_dir_path, exist_ok=True)
instance.data.update(staging_dir_data)

View file

@ -1,9 +1,9 @@
from ayon_core.lib import Logger, filter_profiles, StringTemplate
from ayon_core.settings import get_project_settings
from .anatomy import Anatomy
from .tempdir import get_temp_dir
from ayon_core.pipeline.template_data import get_template_data
from .anatomy import Anatomy
from .tempdir import get_temp_dir
STAGING_DIR_TEMPLATES = "staging"
@ -34,8 +34,10 @@ def get_staging_dir_config(
Returns:
Dict or None: Data with directory template and is_persistent or None
Raises:
ValueError - if misconfigured template should be used
"""
settings = project_settings or get_project_settings(project_name)
@ -91,14 +93,6 @@ def _validate_template_name(project_name, template_name, anatomy):
Raises:
ValueError - if misconfigured template
"""
# TODO: only for backward compatibility of anatomy for older projects
if STAGING_DIR_TEMPLATES not in anatomy.templates:
raise ValueError(
(
'Anatomy of project "{}" does not have set' ' "{}" template section!'
).format(project_name, template_name)
)
if template_name not in anatomy.templates[STAGING_DIR_TEMPLATES]:
raise ValueError(
(
@ -147,9 +141,9 @@ def get_staging_dir(
template.
Returns:
Dict[str, Any]: Staging dir data
"""
Optional[Dict[str, Any]]: Staging dir data
"""
log = kwargs.get("log") or Logger.get_logger("get_staging_dir")
always_return_path = kwargs.get("always_return_path")
@ -209,7 +203,7 @@ def get_staging_dir(
),
"stagingDir_persistent": False,
}
elif not staging_dir_config:
if not staging_dir_config:
return None
return {

View file

@ -23,24 +23,21 @@ def get_temp_dir(
Template formatting is supported also with optional keys. Folder is
created in case it doesn't exists.
Available anatomy formatting keys:
- root[work | <root name key>]
- project[name | code]
Note:
Staging dir does not have to be necessarily in tempdir so be careful
about its usage.
Args:
project_name (str)[optional]: Name of project.
anatomy (openpype.pipeline.Anatomy)[optional]: Anatomy object.
make_local (bool)[optional]: If True, temp dir will be created in
project_name (str): Name of project.
anatomy (Optional[Anatomy]): Project Anatomy object.
suffix (Optional[str]): Suffix for tempdir.
prefix (Optional[str]): Prefix for tempdir.
make_local (Optional[bool]): If True, temp dir will be created in
local tempdir.
suffix (str)[optional]: Suffix for tempdir.
prefix (str)[optional]: Prefix for tempdir.
Returns:
str: Path to staging dir of instance.
"""
prefix = prefix or "ay_tmp_"
suffix = suffix or ""