Validate layer names in trackpoints.
ValidateTrackpointLayers
Bases: Validator
Validate layer names in trackpoints.
Source code in client/ayon_mocha/plugins/publish/validate_trackpoints_layers.py
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
56
57
58
59
60
61
62
63
64
65
66
67 | class ValidateTrackpointLayers(pyblish.api.Validator):
"""Validate layer names in trackpoints."""
order = pyblish.api.Validator.order + 0.1
label = "Validate Trackpoint Layers"
hosts: ClassVar[list[str]] = ["mochapro"]
families: ClassVar[list[str]] = ["trackpoints"]
log: Logger
def process(self, instance: pyblish.api.Instance) -> None:
"""Process all the trackpoints.
Raises:
PublishValidationError: If the layer index is not found.
"""
if not instance.data.get("layer"):
msg = (
f"Specified layer index ({instance.data['layer']} "
"does not exist in the project"
)
raise PublishValidationError(
msg, description=self._missing_layer_description())
if len(instance.data["use_exporters"]) == 0:
msg = (
"Multiple exporters are not supported for trackpoints. "
"Please use only one exporter"
)
raise PublishValidationError(
msg, description=self._missing_exporter())
@classmethod
def _missing_layer_description(cls) -> str:
"""Return the description for missing layer."""
return inspect.cleandoc(
"""
### Issue
The instance is missing the layer attribute. Select the layer
in the publisher.
"""
)
@classmethod
def _missing_exporter(cls) -> str:
"""Return the description for missing layer."""
return inspect.cleandoc(
"""
### Issue
You need to select at least one exporter on the instance.
"""
)
|
process(instance)
Process all the trackpoints.
Raises:
Type | Description |
PublishValidationError | If the layer index is not found. |
Source code in client/ayon_mocha/plugins/publish/validate_trackpoints_layers.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 | def process(self, instance: pyblish.api.Instance) -> None:
"""Process all the trackpoints.
Raises:
PublishValidationError: If the layer index is not found.
"""
if not instance.data.get("layer"):
msg = (
f"Specified layer index ({instance.data['layer']} "
"does not exist in the project"
)
raise PublishValidationError(
msg, description=self._missing_layer_description())
if len(instance.data["use_exporters"]) == 0:
msg = (
"Multiple exporters are not supported for trackpoints. "
"Please use only one exporter"
)
raise PublishValidationError(
msg, description=self._missing_exporter())
|