Skip to content

create_psd_workfile

ImageComboCreator

Bases: HiddenTrayPublishCreator

Creates image instance.

Source code in client/ayon_traypublisher/plugins/create/create_psd_workfile.py
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
class ImageComboCreator(HiddenTrayPublishCreator):
    """Creates image instance."""

    identifier = "io.ayon.creators.traypublisher.psd_workfile_image.image"
    label = "Image"
    host_name = "traypublisher"
    product_type = "image"
    product_base_type = "image"

    def create(self, _product_name, instance_data):
        project_entity = self.create_context.get_current_project_entity()
        folder_path: str = instance_data["folderPath"]
        task_name: Optional[str] = instance_data.get("task")
        # get_current_folder_entity returns None
        folder_entity = self.create_context.get_folder_entity(folder_path)
        task_entity = self.create_context.get_task_entity(
            folder_path, task_name
        )

        project_name = project_entity["name"]
        host_name = self.create_context.host_name

        variant = (
            instance_data.get("variant") or
            next(iter(instance_data["default_variants"]), None)
        )

        product_name = self.get_product_name(
            project_name=project_name,
            project_entity=project_entity,
            folder_entity=folder_entity,
            task_entity=task_entity,
            host_name=host_name,
            variant=variant
        )
        new_instance = CreatedInstance(
            self.product_type, product_name, instance_data, self
        )

        self._store_new_instance(new_instance)

        return new_instance

    def get_instance_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"
            ),
        ]

PSDWorkfileCreator

Bases: TrayPublishCreator

Creates additional image publish instance for provided workfile.

Source code in client/ayon_traypublisher/plugins/create/create_psd_workfile.py
 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
 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
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",
            )
        ]