Skip to content

validate_assembly_namespaces

ValidateAssemblyNamespaces

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

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

Source code in client/ayon_maya/plugins/publish/validate_assembly_namespaces.py
10
11
12
13
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
class ValidateAssemblyNamespaces(plugin.MayaInstancePlugin,
                                 OptionalPyblishPluginMixin):
    """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 Assembly Namespaces"
    order = pyblish.api.ValidatorOrder
    families = ["assembly"]
    actions = [ayon_maya.api.action.SelectInvalidAction]
    optional = False

    def process(self, instance):
        if not self.is_active(instance.data):
            return
        self.log.debug("Checking namespace for %s" % instance.name)
        if self.get_invalid(instance):
            raise PublishValidationError("Nested namespaces found")

    @classmethod
    def get_invalid(cls, instance):

        from maya import cmds

        invalid = []
        for item in cmds.ls(instance):
            item_parts = item.split("|", 1)[0].rsplit(":")
            if len(item_parts[:-1]) > 1:
                invalid.append(item)

        return invalid