Exemplo n.º 1
0
    def save(self, path, *args, **kwargs):
        """
        Submit the item for saving.

        :type path: str
        """
        path = path or self.path()

        if path and not path.endswith(self.Extension):
            path += self.Extension

        self.setPath(path)
        path = self.path()

        logger.debug(u'Item Saving: {0}'.format(path))
        self.saving.emit(self)

        if os.path.exists(path):
            self.showAlreadyExistsDialog()

        tempPath = studiolibrary.createTempPath(self.__class__.__name__)

        self.write(tempPath, *args, **kwargs)

        shutil.move(tempPath, path)

        self.saveItemData()

        if self.libraryWindow():
            self.libraryWindow().selectItems([self])

        self.saved.emit(self)
        logger.debug(u'Item Saved: {0}'.format(self.path()))
Exemplo n.º 2
0
    def save(self, path, *args, **kwargs):
        """
        Submit the item for saving.

        :type path: str
        """
        path = path or self.path()

        if path and not path.endswith(self.Extension):
            path += self.Extension

        self.setPath(path)
        path = self.path()

        logger.debug(u'Item Saving: {0}'.format(path))
        self.saving.emit(self)

        if os.path.exists(path):
            self.showAlreadyExistsDialog()

        tempPath = studiolibrary.createTempPath(self.__class__.__name__)

        self.write(tempPath, *args, **kwargs)

        shutil.move(tempPath, path)

        self.saveItemData()

        if self.libraryWindow():
            self.libraryWindow().selectItems([self])

        self.saved.emit(self)
        logger.debug(u'Item Saved: {0}'.format(self.path()))
Exemplo n.º 3
0
    def safeSave(self, *args, **kwargs):
        """
        Safe save the item.
        """
        dst = self.path()

        if dst and not dst.endswith(self.EXTENSION):
            dst += self.EXTENSION

        self.setPath(dst)

        logger.debug(u'Item Saving: {0}'.format(dst))
        self.saving.emit(self)

        if os.path.exists(dst):
            if self._ignoreExistsDialog:
                self._moveToTrash()
            else:
                self.showAlreadyExistsDialog()

        tmp = studiolibrary.createTempPath(os.path.basename(dst))

        self.setPath(tmp)
        logger.debug(u'Set Path: {0}'.format(tmp))

        self.save(*args, **kwargs)

        shutil.move(tmp, dst)
        logger.debug(u'Move TempFile: {0}'.format(dst))

        self.setPath(dst)
        self.syncItemData()

        if self.libraryWindow():
            self.libraryWindow().selectItems([self])

        self.saved.emit(self)
        logger.debug(u'Item Saved: {0}'.format(dst))