Skip to content

save_workfile

SaveCurrentWorkfile

Bases: ContextPlugin

Save current workfile

Source code in client/ayon_substancepainter/plugins/publish/save_workfile.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class SaveCurrentWorkfile(pyblish.api.ContextPlugin):
    """Save current workfile"""

    label = "Save current workfile"
    order = pyblish.api.ExtractorOrder - 0.49
    hosts = ["substancepainter"]

    def process(self, context):

        host = registered_host()
        current = host.get_current_workfile()
        if context.data["currentFile"] != current:
            raise KnownPublishError("Workfile has changed during publishing!")

        if host.workfile_has_unsaved_changes():
            self.log.info("Saving current file: {}".format(current))
            host.save_workfile()
        else:
            self.log.debug("Skipping workfile save because there are no "
                           "unsaved changes.")