From c32b0ec7703e2821204667afb354a18186e36c13 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 4 Apr 2022 12:21:17 +0200 Subject: [PATCH] ftrack: simplification of logic --- .../publish/integrate_ftrack_instances.py | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/openpype/modules/ftrack/plugins/publish/integrate_ftrack_instances.py b/openpype/modules/ftrack/plugins/publish/integrate_ftrack_instances.py index f79bdb31d7..c11d5b9c68 100644 --- a/openpype/modules/ftrack/plugins/publish/integrate_ftrack_instances.py +++ b/openpype/modules/ftrack/plugins/publish/integrate_ftrack_instances.py @@ -169,7 +169,8 @@ class IntegrateFtrackInstance(pyblish.api.InstancePlugin): # Change asset name of each new component for review is_first_review_repre = True not_first_components = [] - extended_asset_name = False + extended_asset_name = "" + multiple_reviewable = len(review_representations) > 1 for repre in review_representations: # Create copy of base comp item and append it review_item = copy.deepcopy(base_component_item) @@ -178,8 +179,7 @@ class IntegrateFtrackInstance(pyblish.api.InstancePlugin): # expand name to better label componenst if ( not self.keep_first_subset_name_for_review - and is_first_review_repre - and len(review_representations) > 1 + and multiple_reviewable ): asset_name = review_item["asset_data"]["name"] # define new extended name @@ -187,18 +187,21 @@ class IntegrateFtrackInstance(pyblish.api.InstancePlugin): (asset_name, repre["name"]) ) review_item["asset_data"]["name"] = extended_asset_name - # and rename all already created components - for _ci in component_list: - _ci["asset_data"]["name"] = extended_asset_name - # and rename all already created src components - for _sci in src_components_to_add: - _sci["asset_data"]["name"] = extended_asset_name + # rename asset name only if multiple reviewable repre + if is_first_review_repre: + # and rename all already created components + for _ci in component_list: + _ci["asset_data"]["name"] = extended_asset_name - # rename also first thumbnail component if any - if first_thumbnail_component is not None: - first_thumbnail_component[ - "asset_data"]["name"] = extended_asset_name + # and rename all already created src components + for _sci in src_components_to_add: + _sci["asset_data"]["name"] = extended_asset_name + + # rename also first thumbnail component if any + if first_thumbnail_component is not None: + first_thumbnail_component[ + "asset_data"]["name"] = extended_asset_name frame_start = repre.get("frameStartFtrack") frame_end = repre.get("frameEndFtrack") @@ -230,15 +233,9 @@ class IntegrateFtrackInstance(pyblish.api.InstancePlugin): } } - # rename asset name only if multiple reviewable repre if is_first_review_repre: is_first_review_repre = False else: - # Add representation name to asset name of "not first" review - asset_name = review_item["asset_data"]["name"] - review_item["asset_data"]["name"] = "_".join( - (asset_name, repre["name"]) - ) not_first_components.append(review_item) # Create copy of item before setting location @@ -283,10 +280,7 @@ class IntegrateFtrackInstance(pyblish.api.InstancePlugin): other_item = copy.deepcopy(base_component_item) # add extended name if any - if ( - not self.keep_first_subset_name_for_review - and extended_asset_name is not False - ): + if extended_asset_name: other_item["asset_data"]["name"] = extended_asset_name other_item["component_data"] = {