mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
Merge pull request #72 from aardschok/setdress
Fixes issue with setdress namespace validator
This commit is contained in:
commit
14932e50bb
1 changed files with 17 additions and 13 deletions
|
|
@ -1,19 +1,29 @@
|
|||
import pyblish.api
|
||||
from collections import defaultdict
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class ValidateSetdressNamespaces(pyblish.api.InstancePlugin):
|
||||
"""Ensure namespaces are not nested"""
|
||||
"""Ensure namespaces are not nested
|
||||
|
||||
In the outliner an item in a normal namespace looks as following:
|
||||
props_desk_01_:modelDefault
|
||||
|
||||
Any namespace which diverts from that is illegal, example of an illegal
|
||||
namespace:
|
||||
room_study_01_:props_desk_01_:modelDefault
|
||||
|
||||
"""
|
||||
|
||||
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 +31,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