Skip to content

validate_containers

ValidateOutdatedContainers

Bases: OptionalPyblishPluginMixin, ContextPlugin

Containers are must be updated to latest version on publish.

Source code in client/ayon_core/plugins/publish/validate_containers.py
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
73
74
75
76
class ValidateOutdatedContainers(
    OptionalPyblishPluginMixin,
    pyblish.api.ContextPlugin
):
    """Containers are must be updated to latest version on publish."""

    label = "Validate Outdated Containers"
    order = pyblish.api.ValidatorOrder

    optional = True
    actions = [ShowInventory]

    @classmethod
    def apply_settings(cls, settings):
        # Disable plugin if host does not inherit from 'ILoadHost'
        # - not a host that can load containers
        host = registered_host()
        if not isinstance(host, ILoadHost):
            cls.enabled = False
            return

        # Disable if no profile is found for the current host
        profiles = (
            settings
            ["core"]
            ["publish"]
            ["ValidateOutdatedContainers"]
            ["plugin_state_profiles"]
        )
        profile = filter_profiles(
            profiles, {"host_names": get_current_host_name()}
        )
        if not profile:
            cls.enabled = False
            return

        # Apply settings from profile
        for attr_name in {
            "enabled",
            "optional",
            "active",
        }:
            setattr(cls, attr_name, profile[attr_name])

    def process(self, context):
        if not self.is_active(context.data):
            return

        if any_outdated_containers():
            msg = "There are outdated containers in the scene."
            raise PublishXmlValidationError(self, msg)