This commit is contained in:
Roy Nieterau 2018-07-20 16:58:50 +02:00
commit aa7bf8c0b9
4 changed files with 26 additions and 27 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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.")