From d9ffc411a4d65559e436e7d220b8023c8eba5dc6 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 17 Feb 2020 16:48:36 +0100 Subject: [PATCH] integrate new's version override is ready to handle "append" method per instance --- pype/plugins/global/publish/integrate_new.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pype/plugins/global/publish/integrate_new.py b/pype/plugins/global/publish/integrate_new.py index b5b6b10aa2..2e2094dfc8 100644 --- a/pype/plugins/global/publish/integrate_new.py +++ b/pype/plugins/global/publish/integrate_new.py @@ -204,6 +204,9 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): data=version_data) self.log.debug("Creating version ...") + + new_repre_names_low = [_repre["name"].lower() for _repre in repres] + existing_version = io.find_one({ 'type': 'version', 'parent': subset["_id"], @@ -213,6 +216,10 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): if existing_version is None: version_id = io.insert_one(version).inserted_id else: + # Check if instance have set `append` mode which cause that + # only replicated representations are set to archive + append_repres = instance.data.get("append", False) + # Update version data io.update_many({ 'type': 'version', @@ -230,6 +237,10 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): })) bulk_writes = [] for repre in current_repres: + if append_repres: + # archive only duplicated representations + if repre["name"].lower() not in new_repre_names_low: + continue # Representation must change type, # `_id` must be stored to other key and replaced with new # - that is because new representations should have same ID @@ -284,7 +295,6 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): if 'transfers' not in instance.data: instance.data['transfers'] = [] - new_repre_names = [] for idx, repre in enumerate(instance.data["representations"]): # Collection @@ -454,9 +464,6 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): continue repre_context[key] = template_data[key] - repre_name = repre['name'] - new_repre_names.append(repre_name) - # Use previous representation's id if there are any repre_id = None for _repre in existing_repres: