diff --git a/colorbleed/lib.py b/colorbleed/lib.py index c0bff9d2e3..1297aba606 100644 --- a/colorbleed/lib.py +++ b/colorbleed/lib.py @@ -16,22 +16,20 @@ def is_latest(representation): """Return whether the representation is from latest version Args: - representation (str or io.ObjectId): The representation id. + representation (dict): The representation document from the database. Returns: bool: Whether the representation is of latest version. """ - rep = io.find_one({"_id": io.ObjectId(representation), - "type": "representation"}) - version = io.find_one({"_id": rep['parent']}) + version = io.find_one({"_id": representation['parent']}) # Get highest version under the parent highest_version = io.find_one({ "type": "version", "parent": version["parent"] - }, sort=[("name", -1)]) + }, sort=[("name", -1)], projection={"name": True}) if version['name'] == highest_version['name']: return True @@ -49,8 +47,15 @@ def any_outdated(): if representation in checked: continue - if not is_latest(container['representation']): + 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: + log.debug("Container '{objectName}' has an invalid " + "representation, it is missing in the " + "database".format(**container)) checked.add(representation) return False diff --git a/colorbleed/maya/plugin.py b/colorbleed/maya/plugin.py index d89bfd092f..21a074e874 100644 --- a/colorbleed/maya/plugin.py +++ b/colorbleed/maya/plugin.py @@ -91,8 +91,8 @@ class ReferenceLoader(api.Loader): references = set() for ref in cmds.ls(members, exactType="reference", objectsOnly=True): - # Ignore any `sharedReferenceNode` - if ref.startswith("sharedReference"): + # Ignore any `:sharedReferenceNode` + if ref.rsplit(":", 1)[-1].startswith("sharedReferenceNode"): continue references.add(ref) diff --git a/colorbleed/plugins/maya/publish/validate_shape_render_stats.py b/colorbleed/plugins/maya/publish/validate_shape_render_stats.py index 87b716650d..9a3067badb 100644 --- a/colorbleed/plugins/maya/publish/validate_shape_render_stats.py +++ b/colorbleed/plugins/maya/publish/validate_shape_render_stats.py @@ -10,8 +10,6 @@ class ValidateShapeRenderStats(pyblish.api.Validator): order = colorbleed.api.ValidateMeshOrder hosts = ['maya'] families = ['colorbleed.model'] - category = 'model' - version = (0, 1, 0) label = 'Shape Default Render Stats' actions = [colorbleed.api.SelectInvalidAction, colorbleed.api.RepairAction] @@ -26,19 +24,17 @@ class ValidateShapeRenderStats(pyblish.api.Validator): 'doubleSided': 1, 'opposite': 0} - @staticmethod - def get_invalid(instance): + @classmethod + def get_invalid(cls, instance): # It seems the "surfaceShape" and those derived from it have # `renderStat` attributes. shapes = cmds.ls(instance, long=True, type='surfaceShape') invalid = [] for shape in shapes: - for attr, requiredValue in \ - ValidateShapeRenderStats.defaults.iteritems(): - + for attr, default_value in cls.defaults.iteritems(): if cmds.attributeQuery(attr, node=shape, exists=True): value = cmds.getAttr('{}.{}'.format(shape, attr)) - if value != requiredValue: + if value != default_value: invalid.append(shape) return invalid @@ -48,14 +44,13 @@ class ValidateShapeRenderStats(pyblish.api.Validator): invalid = self.get_invalid(instance) if invalid: - raise ValueError("Shapes with non-standard renderStats " + raise ValueError("Shapes with non-default renderStats " "found: {0}".format(invalid)) - @staticmethod - def repair(instance): - shape_render_defaults = ValidateShapeRenderStats.defaults - for shape in ValidateShapeRenderStats.get_invalid(instance): - for attr, default_value in shape_render_defaults.iteritems(): + @classmethod + def repair(cls, instance): + for shape in cls.get_invalid(instance): + for attr, default_value in cls.defaults.iteritems(): if cmds.attributeQuery(attr, node=shape, exists=True): plug = '{0}.{1}'.format(shape, attr) diff --git a/colorbleed/plugins/maya/publish/validate_transfers.py b/colorbleed/plugins/maya/publish/validate_transfers.py index 7fb50567c1..5f1f5b3f41 100644 --- a/colorbleed/plugins/maya/publish/validate_transfers.py +++ b/colorbleed/plugins/maya/publish/validate_transfers.py @@ -28,22 +28,21 @@ class ValidateTransfers(pyblish.api.InstancePlugin): for source, destination in transfers: collected[destination.lower()].add(source.lower()) - invalid = False invalid_destinations = list() for destination, sources in collected.items(): if len(sources) > 1: + invalid_destinations.append(destination) + if verbose: self.log.error("Non-unique file transfer for resources: " "{0} (sources: {1})".format(destination, sources)) - invalid = True - invalid_destinations.append(destination) - if invalid: + if invalid_destinations: if not verbose: # If not verbose then still log the resource destination as # opposed to every individual file transfer self.log.error("Non-unique file transfers to destinations: " - "%s" % invalid_destinations) + "%s" % "\n".join(invalid_destinations)) raise RuntimeError("Invalid transfers in queue.")