Bases: InstancePlugin
Validate layer names for publishing are unique for whole workfile.
Source code in client/ayon_tvpaint/plugins/publish/validate_duplicated_layer_names.py
5
6
7
8
9
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
47
48
49
50
51
52
53
54
55 | class ValidateLayersGroup(pyblish.api.InstancePlugin):
"""Validate layer names for publishing are unique for whole workfile."""
label = "Validate Duplicated Layers Names"
order = pyblish.api.ValidatorOrder
families = ["renderPass"]
settings_category = "tvpaint"
def process(self, instance):
# Prepare layers
layers_by_name = instance.context.data["layersByName"]
# Layers ids of an instance
layer_names = instance.data["layer_names"]
# Check if all layers from render pass are in right group
duplicated_layer_names = []
for layer_name in layer_names:
layers = layers_by_name.get(layer_name)
# It is not job of this validator to handle missing layers
if layers is None:
continue
if len(layers) > 1:
duplicated_layer_names.append(layer_name)
# Everything is OK and skip exception
if not duplicated_layer_names:
return
layers_msg = ", ".join([
"\"{}\"".format(layer_name)
for layer_name in duplicated_layer_names
])
detail_lines = [
"- {}".format(layer_name)
for layer_name in set(duplicated_layer_names)
]
raise PublishXmlValidationError(
self,
(
"Layers have duplicated names for instance {}."
# Description what's wrong
" There are layers with same name and one of them is marked"
" for publishing so it is not possible to know which should"
" be published. Please look for layers with names: {}"
).format(instance.data["label"], layers_msg),
formatting_data={
"layer_names": "<br/>".join(detail_lines)
}
)
|