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
 5
 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
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"""

        current_file = instance.context.data["currentFile"]
        folder, file = os.path.split(current_file)
        filename, ext = os.path.splitext(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
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def process(self, instance):
    """Inject the current working file"""

    current_file = instance.context.data["currentFile"]
    folder, file = os.path.split(current_file)
    filename, ext = os.path.splitext(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,
    }]