From a7215f5fc49bfccdf4fe4b0d6b5d353b5764c253 Mon Sep 17 00:00:00 2001 From: aardschok Date: Mon, 18 Dec 2017 11:10:28 +0100 Subject: [PATCH 1/2] simplified function, raises propper error, added selected action --- .../publish/validate_setdress_namespaces.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py b/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py index 90246c216c..afec765ac3 100644 --- a/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py +++ b/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py @@ -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 From a741a1150244673778fc7d5fffb75b3a12bdeb21 Mon Sep 17 00:00:00 2001 From: aardschok Date: Mon, 18 Dec 2017 11:16:09 +0100 Subject: [PATCH 2/2] updated docstrings --- .../maya/publish/validate_setdress_namespaces.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py b/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py index afec765ac3..1eda02cf74 100644 --- a/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py +++ b/colorbleed/plugins/maya/publish/validate_setdress_namespaces.py @@ -3,7 +3,16 @@ 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