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_type = "workfile"
product_base_type = "workfile"
settings_category = "traypublisher"
default_variants = ["Main"]
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,
}
instance_data["default_variants"] = self.default_variants
workfile_instance = CreatedInstance(
self.product_type, product_name, instance_data, self
)
self._store_new_instance(workfile_instance)
add_review_family = pre_create_data.get("add_review_family", False)
instance_data["creator_attributes"]["add_review_family"] = (
add_review_family
)
image_creator = self._get_hidden_creator(
"io.ayon.creators.traypublisher.psd_workfile_image.image"
)
if not image_creator:
raise CreatorError("Image creator not found")
image_creator.create(None, 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):
return [
FileDef(
"filepath",
folders=False,
extensions=[".psd"],
allow_sequences=False,
single_item=True,
label="PSD file",
),
BoolDef(
"add_review_family",
default=True,
label="Review"
),
]
def get_instance_attr_defs(self):
return [
FileDef(
"filepath",
folders=False,
extensions=[".psd"],
allow_sequences=False,
single_item=True,
label="PSD file",
)
]