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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143 | class PSDWorkfileCreator(TrayPublishCreator):
"""Creates additional image publish instance for provided workfile."""
identifier = "io.ayon.creators.traypublisher.psd_workfile_image.workfile"
label = "PSD Workfile + Image"
group_label = "Workfile"
icon = "fa.file"
description = (
"Creates additional image publish instances for provided workfile."
)
product_base_type = "workfile"
product_type = product_base_type
settings_category = "traypublisher"
default_variants = ["Main"]
workfile_product_types = []
image_product_types = []
def get_detail_description(self):
return inspect.cleandoc("""# Workfile + Image
Basic creator that creates image publish instances alongside the main
workfile instance.
Matches existing workflow in WebPublisher
ayon+settings://webpublisher/publish/CollectPublishedFiles/task_type_to_product_type/0/value/0/additional_product_types
.psd workfile could be used both as `workfile` and `image` product.
Different combos are not currently expected.
""")
def create(self, product_name, instance_data, pre_create_data):
repr_file = pre_create_data.get("filepath")
if not repr_file:
raise CreatorError("No files specified")
instance_data["creator_attributes"] = {
"filepath": repr_file,
}
workfile_product_type = pre_create_data.get("workfile_product_type")
if not workfile_product_type:
workfile_product_type = "workfile"
image_product_type = pre_create_data.get("image_product_type")
if not image_product_type:
image_product_type = "image"
instance_data["default_variants"] = self.default_variants
workfile_instance = CreatedInstance(
product_base_type=self.product_base_type,
product_type=workfile_product_type,
product_name=product_name,
data=instance_data,
creator=self,
)
self._store_new_instance(workfile_instance)
image_creator = self._get_hidden_creator(
"io.ayon.creators.traypublisher.psd_workfile_image.image"
)
if not image_creator:
raise CreatorError("Image creator not found")
add_review_family = pre_create_data.get("add_review_family", False)
image_instance_data = copy.deepcopy(instance_data)
image_instance_data["creator_attributes"]["add_review_family"] = (
add_review_family
)
image_instance_data["productType"] = image_product_type
image_creator.create(image_instance_data)
def _get_hidden_creator(self, identifier):
creator = self.create_context.creators.get(identifier)
if creator is None:
self.log.debug(
"Creator '%s' not found in create_context.creators", identifier
)
return creator
def get_pre_create_attr_defs(self):
workfile_product_types = self.workfile_product_types
image_product_types = self.image_product_types
if not workfile_product_types:
workfile_product_types = ["workfile"]
if not image_product_types:
image_product_types = ["image"]
return [
FileDef(
"filepath",
folders=False,
extensions=[".psd"],
allow_sequences=False,
single_item=True,
label="PSD file",
),
BoolDef(
"add_review_family",
default=True,
label="Review"
),
EnumDef(
"workfile_product_type",
label="Workfile product type",
items=workfile_product_types,
),
EnumDef(
"image_product_type",
label="Image product type",
items=image_product_types,
),
]
def get_instance_attr_defs(self):
return [
FileDef(
"filepath",
folders=False,
extensions=[".psd"],
allow_sequences=False,
single_item=True,
label="PSD file",
)
]
|