Skip to content

load_template_workfile

ImportTemplateLoader

Bases: LoaderPlugin

Import Harmony workfiles.

Source code in client/ayon_harmony/plugins/load/load_template_workfile.py
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
class ImportTemplateLoader(load.LoaderPlugin):
    """Import Harmony workfiles."""

    product_types = {"workfile"}
    representations = {"tpl"}
    label = "Import Template"

    def load(self, context, name=None, namespace=None, data=None):
        # Import template.
        temp_dir = tempfile.mkdtemp()
        zip_file = get_representation_path(context["representation"])
        template_path = os.path.join(temp_dir, "temp.tpl")
        with zipfile.ZipFile(zip_file, "r") as zip_ref:
            zip_ref.extractall(template_path)

        sig = harmony.signature("paste")
        func = """function %s(args)
        {
            var template_path = args[0];
            var drag_object = copyPaste.pasteTemplateIntoGroup(
                template_path, "Top", 1
            );
        }
        %s
        """ % (sig, sig)

        harmony.send({"function": func, "args": [template_path]})

        shutil.rmtree(temp_dir)

        product_name = context["product"]["name"]

        return harmony.containerise(
            product_name,
            namespace,
            product_name,
            context,
            self.__class__.__name__
        )

    def update(self, container, context):
        pass

    def remove(self, container):
        pass

ImportWorkfileLoader

Bases: ImportTemplateLoader

Import workfiles.

Source code in client/ayon_harmony/plugins/load/load_template_workfile.py
60
61
62
63
64
65
class ImportWorkfileLoader(ImportTemplateLoader):
    """Import workfiles."""

    product_types = {"workfile"}
    representations = {"zip"}
    label = "Import Workfile"