From 7a6085559ccc2f5df8c033c30946b6b3fd0fe1d9 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 5 Dec 2019 12:18:30 +0100 Subject: [PATCH 1/6] dicts' keys in io methods calling start on the next row to keep same indentations if line lenght changes --- .../global/publish/collect_templates.py | 30 ++++++++++------- pype/plugins/global/publish/integrate.py | 25 ++++++++------ .../publish/integrate_assumed_destination.py | 30 ++++++++++------- .../publish/integrate_rendered_frames.py | 28 ++++++++-------- .../global/publish/submit_publish_job.py | 33 ++++++++++++------- pype/plugins/maya/load/load_look.py | 8 +++-- pype/plugins/maya/publish/extract_look.py | 33 ++++++++++++------- .../maya/publish/validate_node_ids_related.py | 7 ++-- .../maya/publish/validate_renderlayer_aovs.py | 9 ++--- .../nuke/publish/collect_asset_info.py | 6 ++-- .../plugins/nuke/publish/collect_instances.py | 7 ++-- .../nukestudio/publish/extract_effects.py | 33 ++++++++++++------- .../nukestudio/publish/validate_version.py | 17 ++++++---- .../publish/integrate_assumed_destination.py | 30 ++++++++++------- pype/scripts/fusion_switch_shot.py | 6 ++-- pype/setdress_api.py | 4 ++- 16 files changed, 187 insertions(+), 119 deletions(-) diff --git a/pype/plugins/global/publish/collect_templates.py b/pype/plugins/global/publish/collect_templates.py index b80ca4ae1b..429dbd8eea 100644 --- a/pype/plugins/global/publish/collect_templates.py +++ b/pype/plugins/global/publish/collect_templates.py @@ -31,32 +31,38 @@ class CollectTemplates(pyblish.api.InstancePlugin): asset_name = instance.data["asset"] project_name = api.Session["AVALON_PROJECT"] - project = io.find_one({"type": "project", - "name": project_name}, - projection={"config": True, "data": True}) + project = io.find_one( + {"type": "project", "name": project_name}, + projection={"config": True, "data": True} + ) template = project["config"]["template"]["publish"] anatomy = instance.context.data['anatomy'] - asset = io.find_one({"type": "asset", - "name": asset_name, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": asset_name, + "parent": project["_id"] + }) assert asset, ("No asset found by the name '{}' " "in project '{}'".format(asset_name, project_name)) silo = asset.get('silo') - subset = io.find_one({"type": "subset", - "name": subset_name, - "parent": asset["_id"]}) + subset = io.find_one({ + "type": "subset", + "name": subset_name, + "parent": asset["_id"] + }) # assume there is no version yet, we start at `1` version = None version_number = 1 if subset is not None: - version = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[("name", -1)]) + version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + sort=[("name", -1)] + ) # if there is a subset there ought to be version if version is not None: diff --git a/pype/plugins/global/publish/integrate.py b/pype/plugins/global/publish/integrate.py index 59e05ee2aa..33cb1862d0 100644 --- a/pype/plugins/global/publish/integrate.py +++ b/pype/plugins/global/publish/integrate.py @@ -84,9 +84,11 @@ class IntegrateAsset(pyblish.api.InstancePlugin): project = io.find_one({"type": "project"}) - asset = io.find_one({"type": "asset", - "name": ASSET, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": ASSET, + "parent": project["_id"] + }) assert all([project, asset]), ("Could not find current project or " "asset '%s'" % ASSET) @@ -94,10 +96,11 @@ class IntegrateAsset(pyblish.api.InstancePlugin): subset = self.get_subset(asset, instance) # get next version - latest_version = io.find_one({"type": "version", - "parent": subset["_id"]}, - {"name": True}, - sort=[("name", -1)]) + latest_version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + {"name": True}, + sort=[("name", -1)] + ) next_version = 1 if latest_version is not None: @@ -318,9 +321,11 @@ class IntegrateAsset(pyblish.api.InstancePlugin): def get_subset(self, asset, instance): - subset = io.find_one({"type": "subset", - "parent": asset["_id"], - "name": instance.data["subset"]}) + subset = io.find_one({ + "type": "subset", + "parent": asset["_id"], + "name": instance.data["subset"] + }) if subset is None: subset_name = instance.data["subset"] diff --git a/pype/plugins/global/publish/integrate_assumed_destination.py b/pype/plugins/global/publish/integrate_assumed_destination.py index a26529fc2c..25794a4498 100644 --- a/pype/plugins/global/publish/integrate_assumed_destination.py +++ b/pype/plugins/global/publish/integrate_assumed_destination.py @@ -82,31 +82,37 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): project_name = api.Session["AVALON_PROJECT"] a_template = anatomy.templates - project = io.find_one({"type": "project", - "name": project_name}, - projection={"config": True, "data": True}) + project = io.find_one( + {"type": "project", "name": project_name}, + projection={"config": True, "data": True} + ) template = a_template['publish']['path'] # anatomy = instance.context.data['anatomy'] - asset = io.find_one({"type": "asset", - "name": asset_name, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": asset_name, + "parent": project["_id"] + }) assert asset, ("No asset found by the name '{}' " "in project '{}'".format(asset_name, project_name)) - subset = io.find_one({"type": "subset", - "name": subset_name, - "parent": asset["_id"]}) + subset = io.find_one({ + "type": "subset", + "name": subset_name, + "parent": asset["_id"] + }) # assume there is no version yet, we start at `1` version = None version_number = 1 if subset is not None: - version = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[("name", -1)]) + version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + sort=[("name", -1)] + ) # if there is a subset there ought to be version if version is not None: diff --git a/pype/plugins/global/publish/integrate_rendered_frames.py b/pype/plugins/global/publish/integrate_rendered_frames.py index 086b03802e..69280d272d 100644 --- a/pype/plugins/global/publish/integrate_rendered_frames.py +++ b/pype/plugins/global/publish/integrate_rendered_frames.py @@ -88,9 +88,11 @@ class IntegrateFrames(pyblish.api.InstancePlugin): project = io.find_one({"type": "project"}) - asset = io.find_one({"type": "asset", - "name": ASSET, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": ASSET, + "parent": project["_id"] + }) assert all([project, asset]), ("Could not find current project or " "asset '%s'" % ASSET) @@ -98,10 +100,11 @@ class IntegrateFrames(pyblish.api.InstancePlugin): subset = self.get_subset(asset, instance) # get next version - latest_version = io.find_one({"type": "version", - "parent": subset["_id"]}, - {"name": True}, - sort=[("name", -1)]) + latest_version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + {"name": True}, + sort=[("name", -1)] + ) next_version = 1 if latest_version is not None: @@ -251,9 +254,6 @@ class IntegrateFrames(pyblish.api.InstancePlugin): self.log.debug("path_to_save: {}".format(path_to_save)) - - - representation = { "schema": "pype:representation-2.0", "type": "representation", @@ -332,9 +332,11 @@ class IntegrateFrames(pyblish.api.InstancePlugin): def get_subset(self, asset, instance): - subset = io.find_one({"type": "subset", - "parent": asset["_id"], - "name": instance.data["subset"]}) + subset = io.find_one({ + "type": "subset", + "parent": asset["_id"], + "name": instance.data["subset"] + }) if subset is None: subset_name = instance.data["subset"] diff --git a/pype/plugins/global/publish/submit_publish_job.py b/pype/plugins/global/publish/submit_publish_job.py index 2a254b015c..311f5274f6 100644 --- a/pype/plugins/global/publish/submit_publish_job.py +++ b/pype/plugins/global/publish/submit_publish_job.py @@ -27,14 +27,19 @@ def _get_script(): # Logic to retrieve latest files concerning extendFrames def get_latest_version(asset_name, subset_name, family): # Get asset - asset_name = io.find_one({"type": "asset", - "name": asset_name}, - projection={"name": True}) + asset_name = io.find_one( + {"type": "asset", "name": asset_name}, + projection={"name": True} + ) - subset = io.find_one({"type": "subset", - "name": subset_name, - "parent": asset_name["_id"]}, - projection={"_id": True, "name": True}) + subset = io.find_one( + { + "type": "subset", + "name": subset_name, + "parent": asset_name["_id"] + }, + projection={"_id": True, "name": True} + ) # Check if subsets actually exists (pre-run check) assert subset, "No subsets found, please publish with `extendFrames` off" @@ -45,11 +50,15 @@ def get_latest_version(asset_name, subset_name, family): "data.endFrame": True, "parent": True} - version = io.find_one({"type": "version", - "parent": subset["_id"], - "data.families": family}, - projection=version_projection, - sort=[("name", -1)]) + version = io.find_one( + { + "type": "version", + "parent": subset["_id"], + "data.families": family + }, + projection=version_projection, + sort=[("name", -1)] + ) assert version, "No version found, this is a bug" diff --git a/pype/plugins/maya/load/load_look.py b/pype/plugins/maya/load/load_look.py index b1c88bcd18..04ac9b23e4 100644 --- a/pype/plugins/maya/load/load_look.py +++ b/pype/plugins/maya/load/load_look.py @@ -116,9 +116,11 @@ class LookLoader(pype.maya.plugin.ReferenceLoader): shapes=True)) nodes = set(nodes_list) - json_representation = io.find_one({"type": "representation", - "parent": representation['parent'], - "name": "json"}) + json_representation = io.find_one({ + "type": "representation", + "parent": representation['parent'], + "name": "json" + }) # Load relationships shader_relation = api.get_representation_path(json_representation) diff --git a/pype/plugins/maya/publish/extract_look.py b/pype/plugins/maya/publish/extract_look.py index c7b8058852..02bd80cea2 100644 --- a/pype/plugins/maya/publish/extract_look.py +++ b/pype/plugins/maya/publish/extract_look.py @@ -417,32 +417,41 @@ class ExtractLook(pype.api.Extractor): project_name = api.Session["AVALON_PROJECT"] a_template = anatomy.templates - project = io.find_one({"type": "project", - "name": project_name}, - projection={"config": True, "data": True}) + project = io.find_one( + { + "type": "project", + "name": project_name + }, + projection={"config": True, "data": True + ) template = a_template['publish']['path'] # anatomy = instance.context.data['anatomy'] - asset = io.find_one({"type": "asset", - "name": asset_name, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": asset_name, + "parent": project["_id"] + }) assert asset, ("No asset found by the name '{}' " "in project '{}'".format(asset_name, project_name)) silo = asset.get('silo') - subset = io.find_one({"type": "subset", - "name": subset_name, - "parent": asset["_id"]}) + subset = io.find_one({ + "type": "subset", + "name": subset_name, + "parent": asset["_id"] + }) # assume there is no version yet, we start at `1` version = None version_number = 1 if subset is not None: - version = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[("name", -1)]) + version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + sort=[("name", -1)] + ) # if there is a subset there ought to be version if version is not None: diff --git a/pype/plugins/maya/publish/validate_node_ids_related.py b/pype/plugins/maya/publish/validate_node_ids_related.py index 4a154d0b71..9eee63c3ef 100644 --- a/pype/plugins/maya/publish/validate_node_ids_related.py +++ b/pype/plugins/maya/publish/validate_node_ids_related.py @@ -38,9 +38,10 @@ class ValidateNodeIDsRelated(pyblish.api.InstancePlugin): invalid = list() asset = instance.data['asset'] - asset_data = io.find_one({"name": asset, - "type": "asset"}, - projection={"_id": True}) + asset_data = io.find_one( + {"name": asset, "type": "asset"}, + projection={"_id": True} + ) asset_id = str(asset_data['_id']) # We do want to check the referenced nodes as we it might be diff --git a/pype/plugins/maya/publish/validate_renderlayer_aovs.py b/pype/plugins/maya/publish/validate_renderlayer_aovs.py index e14c92a8b4..686a11e906 100644 --- a/pype/plugins/maya/publish/validate_renderlayer_aovs.py +++ b/pype/plugins/maya/publish/validate_renderlayer_aovs.py @@ -49,9 +49,10 @@ class ValidateRenderLayerAOVs(pyblish.api.InstancePlugin): """Check if subset is registered in the database under the asset""" asset = io.find_one({"type": "asset", "name": asset_name}) - is_valid = io.find_one({"type": "subset", - "name": subset_name, - "parent": asset["_id"]}) + is_valid = io.find_one({ + "type": "subset", + "name": subset_name, + "parent": asset["_id"] + }) return is_valid - diff --git a/pype/plugins/nuke/publish/collect_asset_info.py b/pype/plugins/nuke/publish/collect_asset_info.py index 76b93ef3d0..8a8791ec36 100644 --- a/pype/plugins/nuke/publish/collect_asset_info.py +++ b/pype/plugins/nuke/publish/collect_asset_info.py @@ -13,8 +13,10 @@ class CollectAssetInfo(pyblish.api.ContextPlugin): ] def process(self, context): - asset_data = io.find_one({"type": "asset", - "name": api.Session["AVALON_ASSET"]}) + asset_data = io.find_one({ + "type": "asset", + "name": api.Session["AVALON_ASSET"] + }) self.log.info("asset_data: {}".format(asset_data)) context.data['handles'] = int(asset_data["data"].get("handles", 0)) diff --git a/pype/plugins/nuke/publish/collect_instances.py b/pype/plugins/nuke/publish/collect_instances.py index 483f260295..53a9383b39 100644 --- a/pype/plugins/nuke/publish/collect_instances.py +++ b/pype/plugins/nuke/publish/collect_instances.py @@ -15,9 +15,10 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): hosts = ["nuke", "nukeassist"] def process(self, context): - - asset_data = io.find_one({"type": "asset", - "name": api.Session["AVALON_ASSET"]}) + asset_data = io.find_one({ + "type": "asset", + "name": api.Session["AVALON_ASSET"] + }) self.log.debug("asset_data: {}".format(asset_data["data"])) instances = [] diff --git a/pype/plugins/nukestudio/publish/extract_effects.py b/pype/plugins/nukestudio/publish/extract_effects.py index 7aa79d6cc3..a337a5cd1d 100644 --- a/pype/plugins/nukestudio/publish/extract_effects.py +++ b/pype/plugins/nukestudio/publish/extract_effects.py @@ -169,32 +169,41 @@ class ExtractVideoTracksLuts(pyblish.api.InstancePlugin): project_name = api.Session["AVALON_PROJECT"] a_template = anatomy.templates - project = io.find_one({"type": "project", - "name": project_name}, - projection={"config": True, "data": True}) + project = io.find_one( + { + "type": "project", + "name": project_name + }, + projection={"config": True, "data": True} + ) template = a_template['publish']['path'] # anatomy = instance.context.data['anatomy'] - asset = io.find_one({"type": "asset", - "name": asset_name, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": asset_name, + "parent": project["_id"] + }) assert asset, ("No asset found by the name '{}' " "in project '{}'".format(asset_name, project_name)) silo = asset.get('silo') - subset = io.find_one({"type": "subset", - "name": subset_name, - "parent": asset["_id"]}) + subset = io.find_one({ + "type": "subset", + "name": subset_name, + "parent": asset["_id"] + }) # assume there is no version yet, we start at `1` version = None version_number = 1 if subset is not None: - version = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[("name", -1)]) + version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + sort=[("name", -1)] + ) # if there is a subset there ought to be version if version is not None: diff --git a/pype/plugins/nukestudio/publish/validate_version.py b/pype/plugins/nukestudio/publish/validate_version.py index 194b270d51..ebb8f357f8 100644 --- a/pype/plugins/nukestudio/publish/validate_version.py +++ b/pype/plugins/nukestudio/publish/validate_version.py @@ -3,6 +3,7 @@ from avalon import io from pype.action import get_errored_instances_from_context import pype.api as pype + @pyblish.api.log class RepairNukestudioVersionUp(pyblish.api.Action): label = "Version Up Workfile" @@ -53,13 +54,17 @@ class ValidateVersion(pyblish.api.InstancePlugin): io.install() project = io.find_one({"type": "project"}) - asset = io.find_one({"type": "asset", - "name": asset_name, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": asset_name, + "parent": project["_id"] + }) - subset = io.find_one({"type": "subset", - "parent": asset["_id"], - "name": subset_name}) + subset = io.find_one({ + "type": "subset", + "parent": asset["_id"], + "name": subset_name + }) version_db = io.find_one({ 'type': 'version', diff --git a/pype/plugins/premiere/publish/integrate_assumed_destination.py b/pype/plugins/premiere/publish/integrate_assumed_destination.py index c82b70c66f..a8862ff94c 100644 --- a/pype/plugins/premiere/publish/integrate_assumed_destination.py +++ b/pype/plugins/premiere/publish/integrate_assumed_destination.py @@ -77,32 +77,38 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): asset_name = instance.data["asset"] project_name = api.Session["AVALON_PROJECT"] - project = io.find_one({"type": "project", - "name": project_name}, - projection={"config": True, "data": True}) + project = io.find_one( + {"type": "project", "name": project_name}, + projection={"config": True, "data": True} + ) template = project["config"]["template"]["publish"] # anatomy = instance.context.data['anatomy'] - asset = io.find_one({"type": "asset", - "name": asset_name, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": asset_name, + "parent": project["_id"] + }) assert asset, ("No asset found by the name '{}' " "in project '{}'".format(asset_name, project_name)) silo = asset.get('silo') - subset = io.find_one({"type": "subset", - "name": subset_name, - "parent": asset["_id"]}) + subset = io.find_one({ + "type": "subset", + "name": subset_name, + "parent": asset["_id"] + }) # assume there is no version yet, we start at `1` version = None version_number = 1 if subset is not None: - version = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[("name", -1)]) + version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + sort=[("name", -1)] + ) # if there is a subset there ought to be version if version is not None: diff --git a/pype/scripts/fusion_switch_shot.py b/pype/scripts/fusion_switch_shot.py index 26a93b9b9a..539bcf4f68 100644 --- a/pype/scripts/fusion_switch_shot.py +++ b/pype/scripts/fusion_switch_shot.py @@ -170,8 +170,10 @@ def switch(asset_name, filepath=None, new=True): assert asset, "Could not find '%s' in the database" % asset_name # Get current project - self._project = io.find_one({"type": "project", - "name": api.Session["AVALON_PROJECT"]}) + self._project = io.find_one({ + "type": "project", + "name": api.Session["AVALON_PROJECT"] + }) # Go to comp if not filepath: diff --git a/pype/setdress_api.py b/pype/setdress_api.py index c6de0a4f74..c58f259676 100644 --- a/pype/setdress_api.py +++ b/pype/setdress_api.py @@ -463,7 +463,9 @@ def update_scene(set_container, containers, current_data, new_data, new_file): # Check whether the conversion can be done by the Loader. # They *must* use the same asset, subset and Loader for # `api.update` to make sense. - old = io.find_one({"_id": io.ObjectId(representation_current)}) + old = io.find_one( + {"_id": io.ObjectId(representation_current)} + ) new = io.find_one({"_id": io.ObjectId(representation_new)}) is_valid = compare_representations(old=old, new=new) if not is_valid: From 8b02fcebf78dd0a7b60d18a8c167f35f952d5f39 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 5 Dec 2019 12:20:08 +0100 Subject: [PATCH 2/6] another indentation change --- pype/lib.py | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/pype/lib.py b/pype/lib.py index e41f9eb8bc..72874bad76 100644 --- a/pype/lib.py +++ b/pype/lib.py @@ -181,9 +181,10 @@ def any_outdated(): if representation in checked: continue - representation_doc = io.find_one({"_id": io.ObjectId(representation), - "type": "representation"}, - projection={"parent": True}) + representation_doc = io.find_one( + {"_id": io.ObjectId(representation), "type": "representation"}, + projection={"parent": True} + ) if representation_doc and not is_latest(representation_doc): return True elif not representation_doc: @@ -297,23 +298,28 @@ def switch_item(container, assert asset, ("Could not find asset in the database with the name " "'%s'" % asset_name) - subset = io.find_one({"name": subset_name, - "type": "subset", - "parent": asset["_id"]}) + subset = io.find_one({ + "name": subset_name, + "type": "subset", + "parent": asset["_id"] + }) assert subset, ("Could not find subset in the database with the name " "'%s'" % subset_name) - version = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[('name', -1)]) + version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + sort=[('name', -1)] + ) assert version, "Could not find a version for {}.{}".format( asset_name, subset_name ) - representation = io.find_one({"name": representation_name, - "type": "representation", - "parent": version["_id"]}) + representation = io.find_one({ + "name": representation_name, + "type": "representation", + "parent": version["_id"]} + ) assert representation, ("Could not find representation in the database with" " the name '%s'" % representation_name) @@ -523,8 +529,7 @@ def get_subsets(asset_name, from avalon import io # query asset from db - asset_io = io.find_one({"type": "asset", - "name": asset_name}) + asset_io = io.find_one({"type": "asset", "name": asset_name}) # check if anything returned assert asset_io, "Asset not existing. \ @@ -548,14 +553,17 @@ def get_subsets(asset_name, # Process subsets for subset in subsets: if not version: - version_sel = io.find_one({"type": "version", - "parent": subset["_id"]}, - sort=[("name", -1)]) + version_sel = io.find_one( + {"type": "version", "parent": subset["_id"]}, + sort=[("name", -1)] + ) else: assert isinstance(version, int), "version needs to be `int` type" - version_sel = io.find_one({"type": "version", - "parent": subset["_id"], - "name": int(version)}) + version_sel = io.find_one({ + "type": "version", + "parent": subset["_id"], + "name": int(version) + }) find_dict = {"type": "representation", "parent": version_sel["_id"]} From 77a6ebc9fd8c7b958473776e3b693932ef625405 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 5 Dec 2019 12:21:38 +0100 Subject: [PATCH 3/6] integrate new indentation change --- pype/plugins/global/publish/integrate_new.py | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/pype/plugins/global/publish/integrate_new.py b/pype/plugins/global/publish/integrate_new.py index 5a00437a6f..bdcebeb5fe 100644 --- a/pype/plugins/global/publish/integrate_new.py +++ b/pype/plugins/global/publish/integrate_new.py @@ -150,9 +150,11 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): io.install() project = io.find_one({"type": "project"}) - asset = io.find_one({"type": "asset", - "name": ASSET, - "parent": project["_id"]}) + asset = io.find_one({ + "type": "asset", + "name": ASSET, + "parent": project["_id"] + }) assert all([project, asset]), ("Could not find current project or " "asset '%s'" % ASSET) @@ -160,10 +162,11 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): subset = self.get_subset(asset, instance) # get next version - latest_version = io.find_one({"type": "version", - "parent": subset["_id"]}, - {"name": True}, - sort=[("name", -1)]) + latest_version = io.find_one( + {"type": "version", "parent": subset["_id"]}, + {"name": True}, + sort=[("name", -1)] + ) next_version = 1 if latest_version is not None: @@ -500,9 +503,11 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): filelink.create(src, dst, filelink.HARDLINK) def get_subset(self, asset, instance): - subset = io.find_one({"type": "subset", - "parent": asset["_id"], - "name": instance.data["subset"]}) + subset = io.find_one({ + "type": "subset", + "parent": asset["_id"], + "name": instance.data["subset"] + }) if subset is None: subset_name = instance.data["subset"] From eea4df6b518414a5eed2ce3b818e4fc475a85b64 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 6 Dec 2019 18:34:00 +0100 Subject: [PATCH 4/6] changes to keep indentation consistent --- pype/lib.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pype/lib.py b/pype/lib.py index 72874bad76..62bdc02242 100644 --- a/pype/lib.py +++ b/pype/lib.py @@ -294,7 +294,10 @@ def switch_item(container, representation_name = representation["name"] # Find the new one - asset = io.find_one({"name": asset_name, "type": "asset"}) + asset = io.find_one({ + "name": asset_name, + "type": "asset" + }) assert asset, ("Could not find asset in the database with the name " "'%s'" % asset_name) @@ -307,7 +310,10 @@ def switch_item(container, "'%s'" % subset_name) version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, sort=[('name', -1)] ) @@ -357,7 +363,10 @@ def get_asset(asset_name=None): if not asset_name: asset_name = avalon.api.Session["AVALON_ASSET"] - asset_document = io.find_one({"name": asset_name, "type": "asset"}) + asset_document = io.find_one({ + "name": asset_name, + "type": "asset" + }) if not asset_document: raise TypeError("Entity \"{}\" was not found in DB".format(asset_name)) @@ -554,7 +563,10 @@ def get_subsets(asset_name, for subset in subsets: if not version: version_sel = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, sort=[("name", -1)] ) else: From 7f9a4e952832b73abdb006a9959c2bd6baf52b45 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 6 Dec 2019 18:41:54 +0100 Subject: [PATCH 5/6] changes to keep indentation consistend 2 --- pype/plugins/global/publish/collect_templates.py | 10 ++++++++-- pype/plugins/global/publish/integrate.py | 5 ++++- .../global/publish/integrate_assumed_destination.py | 5 ++++- pype/plugins/global/publish/integrate_new.py | 5 ++++- .../global/publish/integrate_rendered_frames.py | 5 ++++- pype/plugins/global/publish/submit_publish_job.py | 5 ++++- pype/plugins/maya/publish/extract_look.py | 5 ++++- pype/plugins/maya/publish/validate_node_ids_related.py | 5 ++++- pype/plugins/nukestudio/publish/extract_effects.py | 5 ++++- .../premiere/publish/integrate_assumed_destination.py | 10 ++++++++-- pype/setdress_api.py | 10 ++++++---- 11 files changed, 54 insertions(+), 16 deletions(-) diff --git a/pype/plugins/global/publish/collect_templates.py b/pype/plugins/global/publish/collect_templates.py index 429dbd8eea..42b547b4ef 100644 --- a/pype/plugins/global/publish/collect_templates.py +++ b/pype/plugins/global/publish/collect_templates.py @@ -32,7 +32,10 @@ class CollectTemplates(pyblish.api.InstancePlugin): project_name = api.Session["AVALON_PROJECT"] project = io.find_one( - {"type": "project", "name": project_name}, + { + "type": "project", + "name": project_name + }, projection={"config": True, "data": True} ) @@ -60,7 +63,10 @@ class CollectTemplates(pyblish.api.InstancePlugin): version_number = 1 if subset is not None: version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, sort=[("name", -1)] ) diff --git a/pype/plugins/global/publish/integrate.py b/pype/plugins/global/publish/integrate.py index 33cb1862d0..e24bad362d 100644 --- a/pype/plugins/global/publish/integrate.py +++ b/pype/plugins/global/publish/integrate.py @@ -97,7 +97,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin): # get next version latest_version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, {"name": True}, sort=[("name", -1)] ) diff --git a/pype/plugins/global/publish/integrate_assumed_destination.py b/pype/plugins/global/publish/integrate_assumed_destination.py index 25794a4498..d090e2711a 100644 --- a/pype/plugins/global/publish/integrate_assumed_destination.py +++ b/pype/plugins/global/publish/integrate_assumed_destination.py @@ -110,7 +110,10 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): version_number = 1 if subset is not None: version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, sort=[("name", -1)] ) diff --git a/pype/plugins/global/publish/integrate_new.py b/pype/plugins/global/publish/integrate_new.py index bdcebeb5fe..da2ce5b457 100644 --- a/pype/plugins/global/publish/integrate_new.py +++ b/pype/plugins/global/publish/integrate_new.py @@ -163,7 +163,10 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): # get next version latest_version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, {"name": True}, sort=[("name", -1)] ) diff --git a/pype/plugins/global/publish/integrate_rendered_frames.py b/pype/plugins/global/publish/integrate_rendered_frames.py index 69280d272d..5819051146 100644 --- a/pype/plugins/global/publish/integrate_rendered_frames.py +++ b/pype/plugins/global/publish/integrate_rendered_frames.py @@ -101,7 +101,10 @@ class IntegrateFrames(pyblish.api.InstancePlugin): # get next version latest_version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, {"name": True}, sort=[("name", -1)] ) diff --git a/pype/plugins/global/publish/submit_publish_job.py b/pype/plugins/global/publish/submit_publish_job.py index 311f5274f6..ddf1d948a3 100644 --- a/pype/plugins/global/publish/submit_publish_job.py +++ b/pype/plugins/global/publish/submit_publish_job.py @@ -28,7 +28,10 @@ def _get_script(): def get_latest_version(asset_name, subset_name, family): # Get asset asset_name = io.find_one( - {"type": "asset", "name": asset_name}, + { + "type": "asset", + "name": asset_name + }, projection={"name": True} ) diff --git a/pype/plugins/maya/publish/extract_look.py b/pype/plugins/maya/publish/extract_look.py index 02bd80cea2..4da28da2a1 100644 --- a/pype/plugins/maya/publish/extract_look.py +++ b/pype/plugins/maya/publish/extract_look.py @@ -449,7 +449,10 @@ class ExtractLook(pype.api.Extractor): version_number = 1 if subset is not None: version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, sort=[("name", -1)] ) diff --git a/pype/plugins/maya/publish/validate_node_ids_related.py b/pype/plugins/maya/publish/validate_node_ids_related.py index 9eee63c3ef..7e8565c297 100644 --- a/pype/plugins/maya/publish/validate_node_ids_related.py +++ b/pype/plugins/maya/publish/validate_node_ids_related.py @@ -39,7 +39,10 @@ class ValidateNodeIDsRelated(pyblish.api.InstancePlugin): asset = instance.data['asset'] asset_data = io.find_one( - {"name": asset, "type": "asset"}, + { + "name": asset, + "type": "asset" + }, projection={"_id": True} ) asset_id = str(asset_data['_id']) diff --git a/pype/plugins/nukestudio/publish/extract_effects.py b/pype/plugins/nukestudio/publish/extract_effects.py index a337a5cd1d..15d2a80a55 100644 --- a/pype/plugins/nukestudio/publish/extract_effects.py +++ b/pype/plugins/nukestudio/publish/extract_effects.py @@ -201,7 +201,10 @@ class ExtractVideoTracksLuts(pyblish.api.InstancePlugin): version_number = 1 if subset is not None: version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, sort=[("name", -1)] ) diff --git a/pype/plugins/premiere/publish/integrate_assumed_destination.py b/pype/plugins/premiere/publish/integrate_assumed_destination.py index a8862ff94c..a0393e8a43 100644 --- a/pype/plugins/premiere/publish/integrate_assumed_destination.py +++ b/pype/plugins/premiere/publish/integrate_assumed_destination.py @@ -78,7 +78,10 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): project_name = api.Session["AVALON_PROJECT"] project = io.find_one( - {"type": "project", "name": project_name}, + { + "type": "project", + "name": project_name + }, projection={"config": True, "data": True} ) @@ -106,7 +109,10 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): version_number = 1 if subset is not None: version = io.find_one( - {"type": "version", "parent": subset["_id"]}, + { + "type": "version", + "parent": subset["_id"] + }, sort=[("name", -1)] ) diff --git a/pype/setdress_api.py b/pype/setdress_api.py index c58f259676..63b3967828 100644 --- a/pype/setdress_api.py +++ b/pype/setdress_api.py @@ -463,10 +463,12 @@ def update_scene(set_container, containers, current_data, new_data, new_file): # Check whether the conversion can be done by the Loader. # They *must* use the same asset, subset and Loader for # `api.update` to make sense. - old = io.find_one( - {"_id": io.ObjectId(representation_current)} - ) - new = io.find_one({"_id": io.ObjectId(representation_new)}) + old = io.find_one({ + "_id": io.ObjectId(representation_current) + }) + new = io.find_one({ + "_id": io.ObjectId(representation_new) + }) is_valid = compare_representations(old=old, new=new) if not is_valid: log.error("Skipping: %s. See log for details.", From d0132a1fa055e07ae3780b7d900ea3eeebe19a54 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Sat, 7 Dec 2019 11:29:07 +0000 Subject: [PATCH 6/6] lib.py edited online with Bitbucket --- pype/lib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pype/lib.py b/pype/lib.py index 62bdc02242..cb238459d1 100644 --- a/pype/lib.py +++ b/pype/lib.py @@ -182,7 +182,10 @@ def any_outdated(): continue representation_doc = io.find_one( - {"_id": io.ObjectId(representation), "type": "representation"}, + { + "_id": io.ObjectId(representation), + "type": "representation" + }, projection={"parent": True} ) if representation_doc and not is_latest(representation_doc):