Skip to content

validate_workfile_metadata

ValidateWorkfileMetadata

Bases: ContextPlugin

Validate if wokrfile contain required metadata for publising.

Source code in client/ayon_tvpaint/plugins/publish/validate_workfile_metadata.py
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
class ValidateWorkfileMetadata(pyblish.api.ContextPlugin):
    """Validate if wokrfile contain required metadata for publising."""

    label = "Validate Workfile Metadata"
    order = pyblish.api.ValidatorOrder

    families = ["workfile"]

    actions = [ValidateWorkfileMetadataRepair]

    settings_category = "tvpaint"

    required_keys = {"project_name", "folder_path", "task_name"}

    def process(self, context):
        workfile_context = context.data["workfile_context"]
        if not workfile_context:
            raise PublishValidationError(
                "Current workfile is missing whole metadata about context.",
                "Missing context",
                (
                    "Current workfile is missing metadata about task."
                    " To fix this issue save the file using Workfiles tool."
                )
            )

        missing_keys = []
        for key in self.required_keys:
            value = workfile_context.get(key)
            if not value:
                missing_keys.append(key)

        if missing_keys:
            raise PublishXmlValidationError(
                self,
                "Current workfile is missing metadata about {}.".format(
                    ", ".join(missing_keys)
                ),
                formatting_data={
                    "missing_metadata": ", ".join(missing_keys)
                }
            )

ValidateWorkfileMetadataRepair

Bases: Action

Store current context into workfile metadata.

Source code in client/ayon_tvpaint/plugins/publish/validate_workfile_metadata.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
class ValidateWorkfileMetadataRepair(pyblish.api.Action):
    """Store current context into workfile metadata."""

    label = "Use current context"
    icon = "wrench"
    on = "failed"

    def process(self, context, _plugin):
        """Save current workfile which should trigger storing of metadata."""
        current_file = context.data["currentFile"]
        host = registered_host()
        # Save file should trigger
        host.save_workfile(current_file)

process(context, _plugin)

Save current workfile which should trigger storing of metadata.

Source code in client/ayon_tvpaint/plugins/publish/validate_workfile_metadata.py
16
17
18
19
20
21
def process(self, context, _plugin):
    """Save current workfile which should trigger storing of metadata."""
    current_file = context.data["currentFile"]
    host = registered_host()
    # Save file should trigger
    host.save_workfile(current_file)