Bases: OptionalPyblishPluginMixin
, ContextPlugin
Validate scene settings against database.
Source code in client/ayon_tvpaint/plugins/publish/validate_scene_settings.py
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
56
57
58
59
60 | class ValidateProjectSettings(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Validate scene settings against database."""
label = "Validate Scene Settings"
order = pyblish.api.ValidatorOrder
settings_category = "tvpaint"
optional = True
def process(self, context):
if not self.is_active(context.data):
return
task_attributes = context.data["taskEntity"]["attrib"]
scene_data = {
"fps": context.data.get("sceneFps"),
"resolutionWidth": context.data.get("sceneWidth"),
"resolutionHeight": context.data.get("sceneHeight"),
"pixelAspect": context.data.get("scenePixelAspect")
}
invalid = {}
for k in scene_data.keys():
expected_value = task_attributes[k]
if scene_data[k] != expected_value:
invalid[k] = {
"current": scene_data[k], "expected": expected_value
}
if not invalid:
return
raise PublishXmlValidationError(
self,
"Scene settings does not match database:\n{}".format(
json.dumps(invalid, sort_keys=True, indent=4)
),
formatting_data={
"expected_fps": task_attributes["fps"],
"current_fps": scene_data["fps"],
"expected_width": task_attributes["resolutionWidth"],
"expected_height": task_attributes["resolutionHeight"],
"current_width": scene_data["resolutionWidth"],
"current_height": scene_data["resolutionHeight"],
"expected_pixel_ratio": task_attributes["pixelAspect"],
"current_pixel_ratio": scene_data["pixelAspect"]
}
)
|