Skip to content

collect_workfile

CollectWorkfile

Bases: InstancePlugin

Collect current script for publish.

Source code in client/ayon_nuke/plugins/publish/collect_workfile.py
 6
 7
 8
 9
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
40
41
42
43
44
class CollectWorkfile(pyblish.api.InstancePlugin):
    """Collect current script for publish."""

    order = pyblish.api.CollectorOrder
    label = "Collect Workfile"
    hosts = ['nuke']
    families = ["workfile"]

    settings_category = "nuke"

    def process(self, instance):  # sourcery skip: avoid-builtin-shadow

        script_data = instance.context.data["scriptData"]
        current_file = os.path.normpath(nuke.root().name())

        # creating instances per write node
        staging_dir = os.path.dirname(current_file)
        base_name = os.path.basename(current_file)

        # creating representation
        representation = {
            'name': 'nk',
            'ext': 'nk',
            'files': base_name,
            "stagingDir": staging_dir,
        }

        # creating instance data
        instance.data.update({
            "name": base_name,
            "representations": [representation]
        })

        # adding basic script data
        instance.data.update(script_data)

        self.log.debug(
            "Collected current script version: {}".format(current_file)
        )