refactor in favour of code changes from #4445

https://github.com/ynput/OpenPype/pull/4445
This commit is contained in:
Jakub Jezek 2023-02-10 11:34:05 +01:00
parent 69937c6285
commit be0209e413
No known key found for this signature in database
GPG key ID: 730D7C02726179A7
2 changed files with 7 additions and 22 deletions

View file

@ -642,18 +642,10 @@ def get_instance_staging_dir(instance):
if staging_dir:
return staging_dir
anatomy_data = instance.data.get("anatomy_data")
anatomy = instance.context.data.get("anatomy")
if anatomy_data:
project_name = anatomy_data["project"]["name"]
else:
project_name = instance.context.data["projectName"]
# get customized tempdir path from `OPENPYPE_TMPDIR` env var
custom_temp_dir = tempdir.create_custom_tempdir(
project_name, anatomy=anatomy, formating_data=anatomy_data
)
custom_temp_dir = tempdir.create_custom_tempdir(anatomy)
if custom_temp_dir:
staging_dir = os.path.normpath(

View file

@ -7,7 +7,7 @@ from openpype.lib import StringTemplate
from openpype.pipeline import Anatomy
def create_custom_tempdir(project_name, anatomy=None, formating_data=None):
def create_custom_tempdir(anatomy=None):
""" Create custom tempdir
Template path formatting is supporting:
@ -17,9 +17,7 @@ def create_custom_tempdir(project_name, anatomy=None, formating_data=None):
- project[name | code]
Args:
project_name (str): name of project
anatomy (openpype.pipeline.Anatomy): Anatomy object
formating_data (dict): formating data used for filling template.
Returns:
bool | str: formated path or None
@ -31,20 +29,15 @@ def create_custom_tempdir(project_name, anatomy=None, formating_data=None):
custom_tempdir = None
if "{" in openpype_tempdir:
if anatomy is None:
anatomy = Anatomy(project_name)
anatomy = Anatomy()
# create base formate data
data = {
"root": anatomy.roots
}
if formating_data is None:
# We still don't have `project_code` on Anatomy...
data["project"] = {
"name": project_name,
"root": anatomy.roots,
"project": {
"name": anatomy.project_name,
"code": anatomy.project_code,
}
else:
data["project"] = formating_data["project"]
}
# path is anatomy template
custom_tempdir = StringTemplate.format_template(
openpype_tempdir, data).normalized()