Skip to content

collect_workfile

CollectWorkfile

Bases: InstancePlugin

Inject the current working file into context

Source code in client/ayon_openrv/plugins/publish/collect_workfile.py
 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
class CollectWorkfile(pyblish.api.InstancePlugin):
    """Inject the current working file into context"""

    order = pyblish.api.CollectorOrder - 0.49
    label = "OpenRV Session Workfile"
    hosts = ["openrv"]
    families = ["workfile"]

    def process(self, instance):
        """Inject the current working file"""

        host = registered_host()
        current_file = host.get_current_workfile() or ""

        folder, file = os.path.split(current_file)
        filename, ext = os.path.splitext(file)

        instance.context.data["currentFile"] = current_file

        if not current_file:
            self.log.error("No current filepath detected. "
                           "Make sure to save your OpenRV session")
            return

        instance.data["representations"] = [{
            "name": ext.lstrip("."),
            "ext": ext.lstrip("."),
            "files": file,
            "stagingDir": folder,
        }]

process(instance)

Inject the current working file

Source code in client/ayon_openrv/plugins/publish/collect_workfile.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def process(self, instance):
    """Inject the current working file"""

    host = registered_host()
    current_file = host.get_current_workfile() or ""

    folder, file = os.path.split(current_file)
    filename, ext = os.path.splitext(file)

    instance.context.data["currentFile"] = current_file

    if not current_file:
        self.log.error("No current filepath detected. "
                       "Make sure to save your OpenRV session")
        return

    instance.data["representations"] = [{
        "name": ext.lstrip("."),
        "ext": ext.lstrip("."),
        "files": file,
        "stagingDir": folder,
    }]