Skip to content

increment_workfile

IncrementWorkfile

Bases: InstancePlugin

Increment the current workfile.

Saves the current scene with an increased version number.

Source code in client/ayon_harmony/plugins/publish/increment_workfile.py
 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
class IncrementWorkfile(pyblish.api.InstancePlugin):
    """Increment the current workfile.

    Saves the current scene with an increased version number.
    """

    label = "Increment Workfile"
    order = pyblish.api.IntegratorOrder + 9.0
    hosts = ["harmony"]
    families = ["workfile"]
    optional = True

    def process(self, instance):
        errored_plugins = get_errored_plugins_from_context(instance.context)
        if errored_plugins:
            raise RuntimeError(
                "Skipping incrementing current file because publishing failed."
            )

        scene_dir = version_up(
            os.path.dirname(instance.context.data["currentFile"])
        )
        scene_path = os.path.join(
            scene_dir, os.path.basename(scene_dir) + ".xstage"
        )

        harmony.save_scene_as(scene_path)

        self.log.info("Incremented workfile to: {}".format(scene_path))