Bases: BlenderContextPlugin
, OptionalPyblishPluginMixin
Validate that the workfile has been saved.
Source code in client/ayon_blender/plugins/publish/validate_file_saved.py
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 | class ValidateFileSaved(
plugin.BlenderContextPlugin,
OptionalPyblishPluginMixin
):
"""Validate that the workfile has been saved."""
order = pyblish.api.ValidatorOrder - 0.01
hosts = ["blender"]
label = "Validate File Saved"
optional = False
# TODO rename to 'exclude_product_types'
exclude_families = []
actions = [SaveWorkfileAction]
def process(self, context):
if not self.is_active(context.data):
return
if not context.data["currentFile"]:
# File has not been saved at all and has no filename
raise PublishValidationError(
"Current workfile has not been saved yet.\n"
"Save the workfile before continuing."
)
# Do not validate workfile has unsaved changes if only instances
# present of families that should be excluded
product_types = {
instance.data["productType"] for instance in context
# Consider only enabled instances
if instance.data.get("publish", True)
and instance.data.get("active", True)
}
def is_excluded(family):
return any(family in exclude_family
for exclude_family in self.exclude_families)
if all(is_excluded(product_type) for product_type in product_types):
self.log.debug("Only excluded families found, skipping workfile "
"unsaved changes validation..")
return
if bpy.data.is_dirty:
raise PublishValidationError("Workfile has unsaved changes.")
|