From be0209e4135bea83ffbda230aa23f33651e9cbd0 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 10 Feb 2023 11:34:05 +0100 Subject: [PATCH] refactor in favour of code changes from #4445 https://github.com/ynput/OpenPype/pull/4445 --- openpype/pipeline/publish/lib.py | 10 +--------- openpype/pipeline/tempdir.py | 19 ++++++------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/openpype/pipeline/publish/lib.py b/openpype/pipeline/publish/lib.py index 7d3c367c7a..2884dd495f 100644 --- a/openpype/pipeline/publish/lib.py +++ b/openpype/pipeline/publish/lib.py @@ -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( diff --git a/openpype/pipeline/tempdir.py b/openpype/pipeline/tempdir.py index c5805b2dc1..ff5c58bbc5 100644 --- a/openpype/pipeline/tempdir.py +++ b/openpype/pipeline/tempdir.py @@ -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()