Skip to content

validate_yeti_rig_cache_state

ValidateYetiRigCacheState

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Validate the I/O attributes of the node

Every pgYetiMaya cache node per instance should have
  1. Input Mode is set to None
  2. Input Cache File Name is empty
Source code in client/ayon_maya/plugins/publish/validate_yeti_rig_cache_state.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class ValidateYetiRigCacheState(plugin.MayaInstancePlugin,
                                OptionalPyblishPluginMixin):
    """Validate the I/O attributes of the node

    Every pgYetiMaya cache node per instance should have:
        1. Input Mode is set to `None`
        2. Input Cache File Name is empty

    """

    order = pyblish.api.ValidatorOrder
    label = "Yeti Rig Cache State"
    families = ["yetiRig"]
    actions = [RepairAction,
               ayon_maya.api.action.SelectInvalidAction]
    optional = False

    def process(self, instance):
        if not self.is_active(instance.data):
            return
        invalid = self.get_invalid(instance)
        if invalid:
            raise PublishValidationError(
                "Nodes have incorrect I/O settings",
                description=inspect.getdoc(self)
            )

    @classmethod
    def get_invalid(cls, instance):

        invalid = []

        yeti_nodes = cmds.ls(instance, type="pgYetiMaya")
        for node in yeti_nodes:
            # Check reading state
            state = cmds.getAttr("%s.fileMode" % node)
            if state == 1:
                cls.log.error("Node `%s` is set to mode `cache`" % node)
                invalid.append(node)
                continue

            # Check reading state
            has_cache = cmds.getAttr("%s.cacheFileName" % node)
            if has_cache:
                cls.log.error("Node `%s` has a cache file set" % node)
                invalid.append(node)
                continue

        return invalid

    @classmethod
    def repair(cls, instance):
        """Repair all errors"""

        # Create set to ensure all nodes only pass once
        invalid = cls.get_invalid(instance)
        for node in invalid:
            cmds.setAttr("%s.fileMode" % node, 0)
            cmds.setAttr("%s.cacheFileName" % node, "", type="string")

repair(instance) classmethod

Repair all errors

Source code in client/ayon_maya/plugins/publish/validate_yeti_rig_cache_state.py
64
65
66
67
68
69
70
71
72
@classmethod
def repair(cls, instance):
    """Repair all errors"""

    # Create set to ensure all nodes only pass once
    invalid = cls.get_invalid(instance)
    for node in invalid:
        cmds.setAttr("%s.fileMode" % node, 0)
        cmds.setAttr("%s.cacheFileName" % node, "", type="string")