From fca8030092e9e9fd165d2bdf2039b662be218499 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 20 Jul 2022 09:47:54 +0200 Subject: [PATCH 1/5] normalize path from get_workdir where needed --- .../hosts/flame/plugins/publish/integrate_batch_group.py | 6 ++++-- openpype/lib/applications.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/flame/plugins/publish/integrate_batch_group.py b/openpype/hosts/flame/plugins/publish/integrate_batch_group.py index da9553cc2a..032de99540 100644 --- a/openpype/hosts/flame/plugins/publish/integrate_batch_group.py +++ b/openpype/hosts/flame/plugins/publish/integrate_batch_group.py @@ -324,5 +324,7 @@ class IntegrateBatchGroup(pyblish.api.InstancePlugin): project_doc = instance.data["projectEntity"] asset_entity = instance.data["assetEntity"] - return get_workdir( - project_doc, asset_entity, task_data["name"], "flame") + workdir = get_workdir( + project_doc, asset_entity, task_data["name"], "flame" + ) + return os.path.normpath(workdir) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index f46197e15f..dafc3b479b 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1638,6 +1638,7 @@ def prepare_context_environments(data, env_group=None): "Error in anatomy.format: {}".format(str(exc)) ) + workdir = os.path.normpath(workdir) if not os.path.exists(workdir): log.debug( "Creating workdir folder: \"{}\"".format(workdir) From 37a02fe8e19e4faeaa2a63e3cced19efe5aa1fce Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 20 Jul 2022 09:48:21 +0200 Subject: [PATCH 2/5] 'get_workdir_with_workdir_data' returns 'TemplateResult' --- openpype/lib/avalon_context.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index 76ed6cbbd3..605ebb0b99 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -582,10 +582,7 @@ def get_workdir_with_workdir_data( anatomy_filled = anatomy.format(workdir_data) # Output is TemplateResult object which contain useful data - path = anatomy_filled[template_key]["folder"] - if path: - path = os.path.normpath(path) - return path + return anatomy_filled[template_key]["folder"] def get_workdir( From afd26a82e376a6445177d63d7769394c22b5efa6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 20 Jul 2022 09:48:42 +0200 Subject: [PATCH 3/5] pass anatomy to 'get_workdir' in flame integrator --- openpype/hosts/flame/plugins/publish/integrate_batch_group.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/flame/plugins/publish/integrate_batch_group.py b/openpype/hosts/flame/plugins/publish/integrate_batch_group.py index 032de99540..bf6e81523d 100644 --- a/openpype/hosts/flame/plugins/publish/integrate_batch_group.py +++ b/openpype/hosts/flame/plugins/publish/integrate_batch_group.py @@ -323,8 +323,9 @@ class IntegrateBatchGroup(pyblish.api.InstancePlugin): def _get_shot_task_dir_path(self, instance, task_data): project_doc = instance.data["projectEntity"] asset_entity = instance.data["assetEntity"] + anatomy = instance.context.data["anatomy"] workdir = get_workdir( - project_doc, asset_entity, task_data["name"], "flame" + project_doc, asset_entity, task_data["name"], "flame", anatomy ) return os.path.normpath(workdir) From 5963066a7e1ba2849092215697470e7e0ae734bd Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 20 Jul 2022 10:11:56 +0200 Subject: [PATCH 4/5] TemplateResult has 'normalized' method --- openpype/lib/path_templates.py | 13 +++++++++++++ openpype/pipeline/anatomy.py | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/openpype/lib/path_templates.py b/openpype/lib/path_templates.py index 5c40aa4549..c1282016ef 100644 --- a/openpype/lib/path_templates.py +++ b/openpype/lib/path_templates.py @@ -409,6 +409,19 @@ class TemplateResult(str): self.invalid_types ) + def normalized(self): + """Convert to normalized path.""" + + cls = self.__class__ + return cls( + os.path.normpath(self), + self.template, + self.solved, + self.used_values, + self.missing_keys, + self.invalid_types + ) + class TemplatesResultDict(dict): """Holds and wrap TemplateResults for easy bug report.""" diff --git a/openpype/pipeline/anatomy.py b/openpype/pipeline/anatomy.py index 73081f18fb..08db4749b3 100644 --- a/openpype/pipeline/anatomy.py +++ b/openpype/pipeline/anatomy.py @@ -380,6 +380,19 @@ class AnatomyTemplateResult(TemplateResult): ) return self.__class__(tmp, self.rootless) + def normalized(self): + """Convert to normalized path.""" + + tmp = TemplateResult( + os.path.normpath(self), + self.template, + self.solved, + self.used_values, + self.missing_keys, + self.invalid_types + ) + return self.__class__(tmp, self.rootless) + class AnatomyTemplates(TemplatesDict): inner_key_pattern = re.compile(r"(\{@.*?[^{}0]*\})") From ab34b6f1cf1b1e56b770dcac4191ca69c3a58a5b Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 20 Jul 2022 10:12:56 +0200 Subject: [PATCH 5/5] use normalized 'TemplateResult' output in 'get_workdir_with_workdir_data' --- .../hosts/flame/plugins/publish/integrate_batch_group.py | 3 +-- openpype/lib/applications.py | 1 - openpype/lib/avalon_context.py | 5 ++++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/flame/plugins/publish/integrate_batch_group.py b/openpype/hosts/flame/plugins/publish/integrate_batch_group.py index bf6e81523d..b59107f155 100644 --- a/openpype/hosts/flame/plugins/publish/integrate_batch_group.py +++ b/openpype/hosts/flame/plugins/publish/integrate_batch_group.py @@ -325,7 +325,6 @@ class IntegrateBatchGroup(pyblish.api.InstancePlugin): asset_entity = instance.data["assetEntity"] anatomy = instance.context.data["anatomy"] - workdir = get_workdir( + return get_workdir( project_doc, asset_entity, task_data["name"], "flame", anatomy ) - return os.path.normpath(workdir) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index dafc3b479b..f46197e15f 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1638,7 +1638,6 @@ def prepare_context_environments(data, env_group=None): "Error in anatomy.format: {}".format(str(exc)) ) - workdir = os.path.normpath(workdir) if not os.path.exists(workdir): log.debug( "Creating workdir folder: \"{}\"".format(workdir) diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index 605ebb0b99..2944b2506e 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -582,7 +582,10 @@ def get_workdir_with_workdir_data( anatomy_filled = anatomy.format(workdir_data) # Output is TemplateResult object which contain useful data - return anatomy_filled[template_key]["folder"] + output = anatomy_filled[template_key]["folder"] + if output: + return output.normalized() + return output def get_workdir(