Skip to content

collect_workfile

Collect the current working file.

CollectWorkfileData

Bases: InstancePlugin

Collect Mocha workfile data.

Source code in client/ayon_mocha/plugins/publish/collect_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
class CollectWorkfileData(pyblish.api.InstancePlugin):
    """Collect Mocha workfile data."""

    order = pyblish.api.CollectorOrder - 0.01
    label = "Mocha Workfile"
    families: ClassVar[list[str]] = ["workfile"]

    def process(self, instance: pyblish.api.Instance) -> None:  # noqa: PLR6301
        """Inject the current working file."""
        context = instance.context
        current_file = instance.context.data["currentFile"]
        folder, file = os.path.split(current_file)
        _, ext = os.path.splitext(file)

        data = {
            "setMembers": [current_file],
            "frameStart": context.data["frameStart"],
            "frameEnd": context.data["frameEnd"],
            "handleStart": context.data["handleStart"],
            "handleEnd": context.data["handleEnd"],
            "representations": [{
                "name": ext.lstrip("."),
                "ext": ext.lstrip("."),
                "files": file,
                "stagingDir": folder,
            }]}

        instance.data.update(data)

process(instance)

Inject the current working file.

Source code in client/ayon_mocha/plugins/publish/collect_workfile.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def process(self, instance: pyblish.api.Instance) -> None:  # noqa: PLR6301
    """Inject the current working file."""
    context = instance.context
    current_file = instance.context.data["currentFile"]
    folder, file = os.path.split(current_file)
    _, ext = os.path.splitext(file)

    data = {
        "setMembers": [current_file],
        "frameStart": context.data["frameStart"],
        "frameEnd": context.data["frameEnd"],
        "handleStart": context.data["handleStart"],
        "handleEnd": context.data["handleEnd"],
        "representations": [{
            "name": ext.lstrip("."),
            "ext": ext.lstrip("."),
            "files": file,
            "stagingDir": folder,
        }]}

    instance.data.update(data)