Skip to content

extract_workfile

SilhouetteExtractWorkfile

Bases: Extractor

Source code in client/ayon_silhouette/plugins/publish/extract_workfile.py
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
class SilhouetteExtractWorkfile(publish.Extractor):
    label = "Extract Workfile"
    hosts = ["silhouette"]
    families = ["workfile"]

    def process(self, instance):
        """Extract the current working file as .zip"""
        # Note that Silhouette project workfiles are actually folders,
        # not files.

        current_file = instance.context.data["currentFile"]
        if not current_file:
            raise publish.PublishError("No current file found in context")

        # Save current file
        host = registered_host()
        host.save_workfile()

        # Zip current workfile (Silhouette workfiles are folders)
        staging_dir = self.staging_dir(instance)
        filename = f"{instance.name}.zip"
        lib.zip_folder(current_file, os.path.join(staging_dir, filename))

        # Add representation
        instance.data.setdefault("representations", []).append({
            "name": "sfx_zip",
            "ext": "zip",
            "files": filename,
            "stagingDir": staging_dir,
        })

process(instance)

Extract the current working file as .zip

Source code in client/ayon_silhouette/plugins/publish/extract_workfile.py
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
def process(self, instance):
    """Extract the current working file as .zip"""
    # Note that Silhouette project workfiles are actually folders,
    # not files.

    current_file = instance.context.data["currentFile"]
    if not current_file:
        raise publish.PublishError("No current file found in context")

    # Save current file
    host = registered_host()
    host.save_workfile()

    # Zip current workfile (Silhouette workfiles are folders)
    staging_dir = self.staging_dir(instance)
    filename = f"{instance.name}.zip"
    lib.zip_folder(current_file, os.path.join(staging_dir, filename))

    # Add representation
    instance.data.setdefault("representations", []).append({
        "name": "sfx_zip",
        "ext": "zip",
        "files": filename,
        "stagingDir": staging_dir,
    })