mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge pull request #257 from pypeclub/bugfix/maya-validator_fix-invalid-signature
Maya: validator: Suffix Name Conventions - invalid method signature
This commit is contained in:
commit
2529bb7345
1 changed files with 27 additions and 5 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""Plugin for validating naming conventions."""
|
||||||
from maya import cmds
|
from maya import cmds
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
@ -42,7 +44,8 @@ class ValidateTransformNamingSuffix(pyblish.api.InstancePlugin):
|
||||||
ALLOW_IF_NOT_IN_SUFFIX_TABLE = True
|
ALLOW_IF_NOT_IN_SUFFIX_TABLE = True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_valid_name(node_name, shape_type, SUFFIX_NAMING_TABLE, ALLOW_IF_NOT_IN_SUFFIX_TABLE):
|
def is_valid_name(node_name, shape_type,
|
||||||
|
SUFFIX_NAMING_TABLE, ALLOW_IF_NOT_IN_SUFFIX_TABLE):
|
||||||
"""Return whether node's name is correct.
|
"""Return whether node's name is correct.
|
||||||
|
|
||||||
The correctness for a transform's suffix is dependent on what
|
The correctness for a transform's suffix is dependent on what
|
||||||
|
|
@ -52,6 +55,12 @@ class ValidateTransformNamingSuffix(pyblish.api.InstancePlugin):
|
||||||
When `shape_type` is None the transform doesn't have any direct
|
When `shape_type` is None the transform doesn't have any direct
|
||||||
children shapes.
|
children shapes.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
node_name (str): Node name.
|
||||||
|
shape_type (str): Type of node.
|
||||||
|
SUFFIX_NAMING_TABLE (dict): Mapping dict for suffixes.
|
||||||
|
ALLOW_IF_NOT_IN_SUFFIX_TABLE (dict): Filter dict.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if shape_type not in SUFFIX_NAMING_TABLE:
|
if shape_type not in SUFFIX_NAMING_TABLE:
|
||||||
return ALLOW_IF_NOT_IN_SUFFIX_TABLE
|
return ALLOW_IF_NOT_IN_SUFFIX_TABLE
|
||||||
|
|
@ -63,7 +72,13 @@ class ValidateTransformNamingSuffix(pyblish.api.InstancePlugin):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_invalid(cls, instance, SUFFIX_NAMING_TABLE, ALLOW_IF_NOT_IN_SUFFIX_TABLE):
|
def get_invalid(cls, instance):
|
||||||
|
"""Get invalid nodes in instance.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
instance (:class:`pyblish.api.Instance`): published instance.
|
||||||
|
|
||||||
|
"""
|
||||||
transforms = cmds.ls(instance, type='transform', long=True)
|
transforms = cmds.ls(instance, type='transform', long=True)
|
||||||
|
|
||||||
invalid = []
|
invalid = []
|
||||||
|
|
@ -74,16 +89,23 @@ class ValidateTransformNamingSuffix(pyblish.api.InstancePlugin):
|
||||||
noIntermediate=True)
|
noIntermediate=True)
|
||||||
|
|
||||||
shape_type = cmds.nodeType(shapes[0]) if shapes else None
|
shape_type = cmds.nodeType(shapes[0]) if shapes else None
|
||||||
if not cls.is_valid_name(transform, shape_type, SUFFIX_NAMING_TABLE, ALLOW_IF_NOT_IN_SUFFIX_TABLE):
|
if not cls.is_valid_name(transform, shape_type,
|
||||||
|
cls.SUFFIX_NAMING_TABLE,
|
||||||
|
cls.ALLOW_IF_NOT_IN_SUFFIX_TABLE):
|
||||||
invalid.append(transform)
|
invalid.append(transform)
|
||||||
|
|
||||||
return invalid
|
return invalid
|
||||||
|
|
||||||
def process(self, instance):
|
def process(self, instance):
|
||||||
"""Process all the nodes in the instance"""
|
"""Process all the nodes in the instance.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
instance (:class:`pyblish.api.Instance`): published instance.
|
||||||
|
|
||||||
invalid = self.get_invalid(instance, self.SUFFIX_NAMING_TABLE, self.ALLOW_IF_NOT_IN_SUFFIX_TABLE)
|
"""
|
||||||
|
invalid = self.get_invalid(instance,
|
||||||
|
self.SUFFIX_NAMING_TABLE,
|
||||||
|
self.ALLOW_IF_NOT_IN_SUFFIX_TABLE)
|
||||||
if invalid:
|
if invalid:
|
||||||
raise ValueError("Incorrectly named geometry "
|
raise ValueError("Incorrectly named geometry "
|
||||||
"transforms: {0}".format(invalid))
|
"transforms: {0}".format(invalid))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue