Skip to content

validate_layers_and_exporters

Validate layers and exportes.

ValidateLayersAndExporters

Bases: InstancePlugin

Validate layers and exporters set.

Source code in client/ayon_mocha/plugins/publish/validate_layers_and_exporters.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
class ValidateLayersAndExporters(pyblish.api.InstancePlugin):
    """Validate layers and exporters set."""

    order = pyblish.api.Validator.order + 0.1
    label = "Validate Exporters and Layers"
    hosts: ClassVar[list[str]] = ["mochapro"]
    families: ClassVar[list[str]] = ["matteshapes", "trackpoints"]
    log: Logger

    def process(self, instance: pyblish.api.Instance) -> None:
        """Process all the trackpoints.

        Raises:
            PublishValidationError: If no layers or exporters are set.

        """
        self.log.debug("Validating layers and exporters")
        if not instance.data.get("layer"):
            msg = (
                f"No layers set for instance {instance.name}"
            )
            raise PublishValidationError(
                msg, description=self._missing_layer_description())

        if not instance.data.get("use_exporters"):
            msg = (
                f"No exporters set for instance {instance.name}"
            )
            raise PublishValidationError(
                msg, description=self._missing_exporter())

    @classmethod
    def _missing_layer_description(cls) -> str:
        """Return the description for missing layer."""
        return inspect.cleandoc(
            """
            ### Issue

            The instance doesn't have layers set. Please select the layer
            in the publisher,or set the layer mode to "All layers".
            """
        )

    @classmethod
    def _missing_exporter(cls) -> str:
        """Return the description for missing layer."""
        return inspect.cleandoc(
            """
            ### Issue

            You need to select at least one exporter.
            """
        )

process(instance)

Process all the trackpoints.

Raises:

Type Description
PublishValidationError

If no layers or exporters are set.

Source code in client/ayon_mocha/plugins/publish/validate_layers_and_exporters.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def process(self, instance: pyblish.api.Instance) -> None:
    """Process all the trackpoints.

    Raises:
        PublishValidationError: If no layers or exporters are set.

    """
    self.log.debug("Validating layers and exporters")
    if not instance.data.get("layer"):
        msg = (
            f"No layers set for instance {instance.name}"
        )
        raise PublishValidationError(
            msg, description=self._missing_layer_description())

    if not instance.data.get("use_exporters"):
        msg = (
            f"No exporters set for instance {instance.name}"
        )
        raise PublishValidationError(
            msg, description=self._missing_exporter())