raise PublishXmlValidationError in validate missing layer names

This commit is contained in:
iLLiCiTiT 2021-12-22 12:59:09 +01:00
parent fba2191226
commit d17de8492d
2 changed files with 33 additions and 2 deletions

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Missing layers</title>
<description>## Missing layers for render pass
Render pass subset "{instance_name}" has stored layer names that belong to it's rendering scope but layers were not found in scene.
### Missing layer names
{layer_names}
### How to repair?
Find layers that belong to subset {instance_name} and rename them back to expected layer names or remove the subset and create new with right layers.
</description>
</error>
</root>

View file

@ -1,4 +1,5 @@
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
class ValidateMissingLayers(pyblish.api.InstancePlugin):
@ -30,13 +31,25 @@ class ValidateMissingLayers(pyblish.api.InstancePlugin):
"\"{}\"".format(layer_name)
for layer_name in missing_layer_names
])
instance_label = (
instance.data.get("label") or instance.data["name"]
)
description_layer_names = "<br/>".join([
"- {}".format(layer_name)
for layer_name in missing_layer_names
])
# Raise an error
raise AssertionError(
raise PublishXmlValidationError(
self,
(
"Layers were not found by name for instance \"{}\"."
# Description what's wrong
" Layer names marked for publishing are not available"
" in layers list. Missing layer names: {}"
).format(instance.data["label"], layers_msg)
).format(instance.data["label"], layers_msg),
formatting_data={
"instance_name": instance_label,
"layer_names": description_layer_names
}
)