mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
refactor in favour of code changes from #4445
https://github.com/ynput/OpenPype/pull/4445
This commit is contained in:
parent
69937c6285
commit
be0209e413
2 changed files with 7 additions and 22 deletions
|
|
@ -642,18 +642,10 @@ def get_instance_staging_dir(instance):
|
||||||
if staging_dir:
|
if staging_dir:
|
||||||
return staging_dir
|
return staging_dir
|
||||||
|
|
||||||
anatomy_data = instance.data.get("anatomy_data")
|
|
||||||
anatomy = instance.context.data.get("anatomy")
|
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
|
# get customized tempdir path from `OPENPYPE_TMPDIR` env var
|
||||||
custom_temp_dir = tempdir.create_custom_tempdir(
|
custom_temp_dir = tempdir.create_custom_tempdir(anatomy)
|
||||||
project_name, anatomy=anatomy, formating_data=anatomy_data
|
|
||||||
)
|
|
||||||
|
|
||||||
if custom_temp_dir:
|
if custom_temp_dir:
|
||||||
staging_dir = os.path.normpath(
|
staging_dir = os.path.normpath(
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from openpype.lib import StringTemplate
|
||||||
from openpype.pipeline import Anatomy
|
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
|
""" Create custom tempdir
|
||||||
|
|
||||||
Template path formatting is supporting:
|
Template path formatting is supporting:
|
||||||
|
|
@ -17,9 +17,7 @@ def create_custom_tempdir(project_name, anatomy=None, formating_data=None):
|
||||||
- project[name | code]
|
- project[name | code]
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
project_name (str): name of project
|
|
||||||
anatomy (openpype.pipeline.Anatomy): Anatomy object
|
anatomy (openpype.pipeline.Anatomy): Anatomy object
|
||||||
formating_data (dict): formating data used for filling template.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool | str: formated path or None
|
bool | str: formated path or None
|
||||||
|
|
@ -31,20 +29,15 @@ def create_custom_tempdir(project_name, anatomy=None, formating_data=None):
|
||||||
custom_tempdir = None
|
custom_tempdir = None
|
||||||
if "{" in openpype_tempdir:
|
if "{" in openpype_tempdir:
|
||||||
if anatomy is None:
|
if anatomy is None:
|
||||||
anatomy = Anatomy(project_name)
|
anatomy = Anatomy()
|
||||||
# create base formate data
|
# create base formate data
|
||||||
data = {
|
data = {
|
||||||
"root": anatomy.roots
|
"root": anatomy.roots,
|
||||||
}
|
"project": {
|
||||||
if formating_data is None:
|
"name": anatomy.project_name,
|
||||||
# We still don't have `project_code` on Anatomy...
|
|
||||||
data["project"] = {
|
|
||||||
"name": project_name,
|
|
||||||
"code": anatomy.project_code,
|
"code": anatomy.project_code,
|
||||||
}
|
}
|
||||||
else:
|
}
|
||||||
data["project"] = formating_data["project"]
|
|
||||||
|
|
||||||
# path is anatomy template
|
# path is anatomy template
|
||||||
custom_tempdir = StringTemplate.format_template(
|
custom_tempdir = StringTemplate.format_template(
|
||||||
openpype_tempdir, data).normalized()
|
openpype_tempdir, data).normalized()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue