Bases: InstancePlugin
Validate existence of source filepaths on instance.
Plugins looks into key 'sourceFilepaths' and validate if paths there actually exist on disk.
Also validate if the key is filled but is empty. In that case also crashes so do not fill the key if unfilled value should not cause error.
This is primarily created for Simple Creator instances.
Source code in client/ayon_traypublisher/plugins/publish/validate_filepaths.py
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
56
57
58
59
60
61
62
63
64
65
66
67 | class ValidateFilePath(pyblish.api.InstancePlugin):
"""Validate existence of source filepaths on instance.
Plugins looks into key 'sourceFilepaths' and validate if paths there
actually exist on disk.
Also validate if the key is filled but is empty. In that case also
crashes so do not fill the key if unfilled value should not cause error.
This is primarily created for Simple Creator instances.
"""
label = "Validate Filepaths"
order = pyblish.api.ValidatorOrder - 0.49
hosts = ["traypublisher"]
def process(self, instance):
if "sourceFilepaths" not in instance.data:
self.log.info((
"Skipped validation of source filepaths existence."
" Instance does not have collected 'sourceFilepaths'"
))
return
product_base_type = instance.data["productBaseType"]
label = instance.data["name"]
filepaths = instance.data["sourceFilepaths"]
error_title = "File not filled"
if not filepaths:
message = (
f"Source filepaths of '{product_base_type}'"
f" instance \"{label}\" are not filled"
)
description = (
"## Files were not filled"
"\nThis mean that you didn't enter any files into required"
" file input."
"\n- Please refresh publishing and check instance"
f" <b>{label}</b>"
)
raise PublishValidationError(message, error_title, description)
not_found_files = [
filepath
for filepath in filepaths
if not os.path.exists(filepath)
]
if not_found_files:
joined_paths = "\n".join(
f"- {filepath}"
for filepath in not_found_files
)
message = (
f"Filepath of '{product_base_type}' instance \"{label}\""
f" does not exist:\n{joined_paths}"
)
description = (
f"## Files were not found\nFiles\n{joined_paths}"
"\n\nCheck if the path is still available."
)
raise PublishValidationError(message, error_title, description)
|