mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
removed redudant modues, improved validate_unique_node_ids
This commit is contained in:
parent
6d7262d26b
commit
0e7999adb1
3 changed files with 17 additions and 84 deletions
|
|
@ -1,41 +0,0 @@
|
|||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class ValidateLookNodeIds(pyblish.api.InstancePlugin):
|
||||
"""Validate nodes have colorbleed id attributes
|
||||
|
||||
All look sets should have id attributes.
|
||||
|
||||
"""
|
||||
|
||||
order = colorbleed.api.ValidatePipelineOrder
|
||||
families = ['colorbleed.look']
|
||||
hosts = ['maya']
|
||||
label = 'Look Id Attributes'
|
||||
actions = [colorbleed.api.SelectInvalidAction,
|
||||
colorbleed.api.GenerateUUIDsOnInvalidAction]
|
||||
|
||||
@staticmethod
|
||||
def get_invalid(instance):
|
||||
import maya.cmds as cmds
|
||||
|
||||
nodes = instance.data["lookSets"]
|
||||
|
||||
# Ensure all nodes have a cbId
|
||||
invalid = list()
|
||||
for node in nodes:
|
||||
uuid = cmds.attributeQuery("mbId", node=node, exists=True)
|
||||
if not uuid:
|
||||
invalid.append(node)
|
||||
|
||||
return invalid
|
||||
|
||||
def process(self, instance):
|
||||
"""Process all meshes"""
|
||||
|
||||
invalid = self.get_invalid(instance)
|
||||
|
||||
if invalid:
|
||||
raise RuntimeError("Nodes found without "
|
||||
"asset IDs: {0}".format(invalid))
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
import re
|
||||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class ValidateNamingConvention(pyblish.api.InstancePlugin):
|
||||
|
||||
label = ""
|
||||
families = ["colorbleed.model"]
|
||||
host = ["maya"]
|
||||
actions = [colorbleed.api.SelectInvalidAction]
|
||||
|
||||
@staticmethod
|
||||
def get_invalid(instance):
|
||||
|
||||
invalid = []
|
||||
# todo: change pattern to company standard
|
||||
pattern = re.compile("[a-zA-Z]+_[A-Z]{3}")
|
||||
|
||||
nodes = list(instance)
|
||||
for node in nodes:
|
||||
match = pattern.match(node)
|
||||
if not match:
|
||||
invalid.append(node)
|
||||
|
||||
return invalid
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
self.log.error("Found invalid naming convention. Failed noted :\n"
|
||||
"%s" % invalid)
|
||||
|
|
@ -10,14 +10,17 @@ class ValidateUniqueNodeIds(pyblish.api.InstancePlugin):
|
|||
"""Validate nodes have colorbleed id attributes"""
|
||||
|
||||
order = colorbleed.api.ValidatePipelineOrder
|
||||
families = ['colorbleed.model']
|
||||
hosts = ['maya']
|
||||
label = 'Unique Id Attributes'
|
||||
hosts = ['maya']
|
||||
families = ['colorbleed.model',
|
||||
'colorbleed.lookdev',
|
||||
'colorbleed.rig']
|
||||
|
||||
actions = [colorbleed.api.SelectInvalidAction,
|
||||
colorbleed.api.GenerateUUIDsOnInvalidAction]
|
||||
|
||||
@staticmethod
|
||||
def get_invalid_dict(instance):
|
||||
@classmethod
|
||||
def get_invalid_dict(cls, instance):
|
||||
"""Return a dictionary mapping of id key to list of member nodes"""
|
||||
|
||||
uuid_attr = "cbId"
|
||||
|
|
@ -25,18 +28,21 @@ class ValidateUniqueNodeIds(pyblish.api.InstancePlugin):
|
|||
# Collect each id with their members
|
||||
ids = defaultdict(list)
|
||||
for member in instance:
|
||||
has_attr = cmds.attributeQuery(uuid_attr, node=member, exists=True)
|
||||
if not has_attr:
|
||||
try:
|
||||
object_id = cmds.getAttr("{}.{}".format(member, uuid_attr))
|
||||
except Exception as exception:
|
||||
# Object will node have the attribute so skip
|
||||
cls.log.debug(exception)
|
||||
continue
|
||||
mbid = cmds.getAttr("{}.{}".format(member, uuid_attr))
|
||||
ids[mbid].append(member)
|
||||
|
||||
ids[object_id].append(member)
|
||||
|
||||
# Skip those without IDs (if everything should have an ID that should
|
||||
# be another validation)
|
||||
ids.pop(None, None)
|
||||
|
||||
# Take only the ids with more than one member
|
||||
invalid = dict((id, members) for id, members in ids.iteritems() if
|
||||
invalid = dict((_id, members) for _id, members in ids.iteritems() if
|
||||
len(members) > 1)
|
||||
return invalid
|
||||
|
||||
|
|
@ -61,3 +67,5 @@ class ValidateUniqueNodeIds(pyblish.api.InstancePlugin):
|
|||
if invalid:
|
||||
raise RuntimeError("Nodes found with non-unique "
|
||||
"asset IDs: {0}".format(invalid))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue