Skip to content

increment_current_file

FusionIncrementCurrentFile

Bases: ContextPlugin, OptionalPyblishPluginMixin

Increment the current file.

Saves the current file with an increased version number.

Source code in client/ayon_fusion/plugins/publish/increment_current_file.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class FusionIncrementCurrentFile(
    pyblish.api.ContextPlugin, OptionalPyblishPluginMixin
):
    """Increment the current file.

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

    label = "Increment workfile version"
    order = pyblish.api.IntegratorOrder + 9.0
    hosts = ["fusion"]
    optional = True

    def process(self, context):
        if not self.is_active(context.data):
            return

        comp = context.data.get("currentComp")
        if not comp:
            raise PublishError("Must have comp")

        # Fusion can have multiple compositions open at the same time, and
        # as a publish is running the user may switch to another comp
        # simultaneously. Hence, we need to ensure the active comp is the
        # one current publish session is for in the registered host.
        host: FusionHost = registered_host()
        with host.current_comp(comp):
            self.increment_workfile(context)

    def increment_workfile(self, context: pyblish.api.Context):
        """Increment the current workfile version using registered host."""
        current_filepath: str = context.data["currentFile"]

        current_filename = os.path.basename(current_filepath)
        save_next_version(
            description=(
                f"Incremented by publishing from {current_filename}"
            ),
            # Optimize the save by reducing needed queries for context
            prepared_data=SaveWorkfileOptionalData(
                project_entity=context.data["projectEntity"],
                project_settings=context.data["project_settings"],
                anatomy=context.data["anatomy"],
            )
        )

increment_workfile(context)

Increment the current workfile version using registered host.

Source code in client/ayon_fusion/plugins/publish/increment_current_file.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def increment_workfile(self, context: pyblish.api.Context):
    """Increment the current workfile version using registered host."""
    current_filepath: str = context.data["currentFile"]

    current_filename = os.path.basename(current_filepath)
    save_next_version(
        description=(
            f"Incremented by publishing from {current_filename}"
        ),
        # Optimize the save by reducing needed queries for context
        prepared_data=SaveWorkfileOptionalData(
            project_entity=context.data["projectEntity"],
            project_settings=context.data["project_settings"],
            anatomy=context.data["anatomy"],
        )
    )