Skip to content

validate_product_attributes

ValidateProductAttributes

Bases: OptionalPyblishPluginMixin, InstancePlugin

Validate Product attributes.

Source code in client/ayon_flame/plugins/publish/validate_product_attributes.py
 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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
class ValidateProductAttributes(
    OptionalPyblishPluginMixin,
    pyblish.api.InstancePlugin
):
    """Validate Product attributes."""

    label = "Validate Product Attributes"
    order = pyblish.api.ValidatorOrder
    settings_category = "flame"

    optional = True
    active = False

    actions = [DeactivatePublishing]

    def process(self, instance):
        if not self.is_active(instance.data):
            self.log.info("Validation is disabled.")
            return

        if not instance.data.get("item"):
            self.log.info("Nothing to validate, no associated item.")
            return

        if not instance.data.get("failing"):
            self.log.info("No validation error flagged.")
            return

        # clip or segment
        item = instance.data["item"]
        shot_name = item.shot_name.get_value()
        segment_name = item.name.get_value()
        error = instance.data["failing"]

        clip_msg = (
            f"Clip name: '{segment_name}' with shot name: '{shot_name}'\n"
            f"Problem: '{error}'"
        )

        msg = "Product is failing validation due following reason:"
        msg += f"\n{clip_msg}"
        msg_html = self.get_description() + f"{clip_msg}"

        raise PublishValidationError(
            title="Failing Product Validation",
            message=msg,
            description=msg_html
        )

    def get_description(self):
        return inspect.cleandoc("""
            ## Product is failing validation:
            <br/>
            Make sure your clips on timeline are not converted to BatchFX<br/>
            or are not Hard Committed. This way they will lose their link <br/>
            to the original Media source file path and we are not able<br/>
            to publish them anymore.
            <br/><br/>
            Also make sure timeline clip has a standard name.
            <br/><br/>
            <b>Validation problem:</b>
            <br/>
        """)