Skip to content

validate_palette_location

ValidatePaletteLocation

Bases: InstancePlugin, OptionalPyblishPluginMixin

Validate that a palette is stored at scene level.

Palettes stored at 'environment' or 'job' level are not versioned with the scene.

Source code in client/ayon_harmony/plugins/publish/validate_palette_location.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
class ValidatePaletteLocation(
    pyblish.api.InstancePlugin,
    OptionalPyblishPluginMixin,
):
    """
    Validate that a palette is stored at scene level.

    Palettes stored at 'environment' or 'job' level
    are not versioned with the scene.
    """

    label = "Validate Palette Location"
    hosts = ["harmony"]
    families = ["harmony.palette"]
    order = ValidateContentsOrder
    optional = True

    invalid_storages = ["environment", "job"]

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

        storage = instance.data.get("paletteStorage")

        if storage in self.invalid_storages:
            msg = (
                f"Found invalid palette location '{instance.name}' "
                f"is stored at '{storage}'"
            )
            formatting_data = {
                "palette_name": instance.name,
                "palette_location": storage,
            }
            raise PublishXmlValidationError(
                self, msg, formatting_data=formatting_data
            )