Jakub's comment

This commit is contained in:
Kayla Man 2023-06-08 21:15:30 +08:00
parent 8736370b4e
commit 82d18355c8

View file

@ -1,6 +1,7 @@
"""Host API required Work Files tool""" """Host API required Work Files tool"""
import os import os
import nuke import nuke
from qtpy import QtWidgets
def file_extensions(): def file_extensions():
@ -19,13 +20,14 @@ def save_file(filepath):
nuke.Root().setModified(False) nuke.Root().setModified(False)
def open_file(filepath, allow_autosave=True): def open_file(filepath):
filepath = filepath.replace("\\", "/") filepath = filepath.replace("\\", "/")
# To remain in the same window, we have to clear the script and read # To remain in the same window, we have to clear the script and read
# in the contents of the workfile. # in the contents of the workfile.
nuke.scriptClear() nuke.scriptClear()
if allow_autosave: headless = QtWidgets.QApplication.instance() is None
if not headless:
autosave = "{}.autosave".format(filepath) autosave = "{}.autosave".format(filepath)
autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa
if os.path.isfile(autosave) and nuke.ask(autosave_prmpt): if os.path.isfile(autosave) and nuke.ask(autosave_prmpt):