mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
simplified function, raises propper error, added selected action
This commit is contained in:
parent
aa5a8660c1
commit
a7215f5fc4
1 changed files with 7 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import pyblish.api
|
||||
from collections import defaultdict
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class ValidateSetdressNamespaces(pyblish.api.InstancePlugin):
|
||||
|
|
@ -8,12 +8,13 @@ class ValidateSetdressNamespaces(pyblish.api.InstancePlugin):
|
|||
label = "Validate Setdress Namespaces"
|
||||
order = pyblish.api.ValidatorOrder
|
||||
families = ["colorbleed.setdress"]
|
||||
actions = [colorbleed.api.SelectInvalidAction]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
self.log.info("Checking namespace for %s", instance.name)
|
||||
self.log.info("Checking namespace for %s" % instance.name)
|
||||
if self.get_invalid(instance):
|
||||
self.log.error("Nested namespaces found")
|
||||
raise RuntimeError("Nested namespaces found")
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
|
@ -21,15 +22,9 @@ class ValidateSetdressNamespaces(pyblish.api.InstancePlugin):
|
|||
from maya import cmds
|
||||
|
||||
invalid = []
|
||||
|
||||
namspace_lookup = defaultdict(list)
|
||||
for item in cmds.ls(instance):
|
||||
namespace, node = item.rsplit(":", 1)[0]
|
||||
namspace_lookup[namespace].append(node)
|
||||
|
||||
for namespace, nodes in namspace_lookup.items():
|
||||
parts = [p for p in namespace.split(":") if p != ""]
|
||||
if len(parts) > 1:
|
||||
invalid.extend(nodes)
|
||||
item_parts = item.split("|", 1)[0].rsplit(":")
|
||||
if len(item_parts[:-1]) > 1:
|
||||
invalid.append(item)
|
||||
|
||||
return invalid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue