Exemplo n.º 1
0
    def save_file_as(self):
        editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            fileName = unicode(QFileDialog.getSaveFileName(
                self._parent, self.tr("Save File"), '', '(*.py);;(*.*)'))
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            newFile = file_manager.get_file_extension(fileName) == ''
            fileName = file_manager.store_file_content(
                fileName, editorWidget.get_text(),
                addExtension=True, newFile=newFile)
            self.actualTab.setTabText(self.actualTab.currentIndex(),
                file_manager.get_basename(fileName))
            editorWidget.register_syntax(
                file_manager.get_file_extension(fileName))
            editorWidget.ID = fileName
            self.emit(SIGNAL("fileSaved(QString)"),
                self.tr("File Saved: %1").arg(fileName))
            editorWidget._file_saved()
            return True
        except file_manager.NinjaFileExistsException, ex:
            QMessageBox.information(self, self.tr("File Already Exists"),
                self.tr("Invalid Path: the file '%s' already exists." % \
                    ex.filename))
Exemplo n.º 2
0
    def save_file(self, editorWidget=None):
        #FIXME: check how we handle this
        if not editorWidget:
            editorWidget = self.get_current_editor()
        if not editorWidget:
            return False
        try:
            #editorWidget.just_saved = True
            if (editorWidget.nfile.is_new_file
                    or not editorWidget.nfile.has_write_permission()):
                return self.save_file_as()

            self.emit(SIGNAL("beforeFileSaved(QString)"),
                      editorWidget.file_path)
            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            editorWidget.neditable.save_content()
            #file_manager.store_file_content(
            #fileName, content, addExtension=False)
            encoding = file_manager.get_file_encoding(editorWidget.text())
            editorWidget.encoding = encoding
            self.emit(SIGNAL("fileSaved(QString)"),
                      (self.tr("File Saved: %s") % editorWidget.file_path))
            return True
        except Exception as reason:
            logger.error('save_file: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                                    self.tr("The file couldn't be saved!"))
        return False
Exemplo n.º 3
0
 def save_file(self, editor_widget=None):
     if editor_widget is None:
         # This may return None if there is not editor present
         editor_widget = self.get_current_editor()
     if editor_widget is None:
         return False
     # Ok, we have an editor instance
     # Save to file only if editor really was modified
     if editor_widget.is_modified:
         try:
             if editor_widget.nfile.is_new_file or \
                     not editor_widget.nfile.has_write_permission():
                 return self.save_file_as(editor_widget)
             # FIXME: beforeFileSaved.emit
             if settings.REMOVE_TRAILING_SPACES:
                 helpers.remove_trailing_spaces(editor_widget)
             # FIXME: new line at end
             if settings.ADD_NEW_LINE_AT_EOF:
                 helpers.insert_block_at_end(editor_widget)
             # Save content
             editor_widget.neditable.save_content()
             # FIXME: encoding
             # FIXME: translations
             self.fileSaved.emit("File Saved: %s" % editor_widget.file_path)
             return True
         except Exception as reason:
             logger.error("Save file error: %s" % reason)
             QMessageBox.information(
                 self,
                 "Save Error",
                 "The file could't be saved!"
             )
         return False
Exemplo n.º 4
0
    def save_file_as(self):
        editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            filter = '(*.py);;(*.*)'
            if editorWidget.ID:
                ext = file_manager.get_file_extension(editorWidget.ID)
                if ext != 'py':
                    filter = '(*.%s);;(*.py);;(*.*)' % ext
            fileName = unicode(QFileDialog.getSaveFileName(
                self._parent, self.tr("Save File"), editorWidget.ID, filter))
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            newFile = file_manager.get_file_extension(fileName) == ''
            fileName = file_manager.store_file_content(
                fileName, editorWidget.get_text(),
                addExtension=True, newFile=newFile)
            self.actualTab.setTabText(self.actualTab.currentIndex(),
                file_manager.get_basename(fileName))
            editorWidget.register_syntax(
                file_manager.get_file_extension(fileName))
            editorWidget.ID = fileName
            self.emit(SIGNAL("fileSaved(QString)"),
                self.tr("File Saved: %1").arg(fileName))
            editorWidget._file_saved()
            return True
        except file_manager.NinjaFileExistsException, ex:
            QMessageBox.information(self, self.tr("File Already Exists"),
                self.tr("Invalid Path: the file '%s' already exists." % \
                    ex.filename))
Exemplo n.º 5
0
    def save_file(self, editorWidget=None):
        if not editorWidget:
            editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            if editorWidget.newDocument or \
            not file_manager.has_write_permission(editorWidget.ID):
                return self.save_file_as()

            fileName = editorWidget.ID
            self.emit(SIGNAL("beforeFileSaved(QString)"), fileName)
            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            content = editorWidget.get_text()
            file_manager.store_file_content(
                fileName, content, addExtension=False)
            editorWidget.ID = fileName
            encoding = file_manager._search_coding_line(content)
            editorWidget.encoding = encoding
            self.emit(SIGNAL("fileSaved(QString)"),
                self.tr("File Saved: %1").arg(fileName))
            editorWidget._file_saved()
            return True
        except Exception, reason:
            logger.error('save_file: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                self.tr("The file couldn't be saved!"))
Exemplo n.º 6
0
    def save_file(self, editorWidget=None):
        if not editorWidget:
            editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            editorWidget.just_saved = True
            if editorWidget.newDocument or \
            not file_manager.has_write_permission(editorWidget.ID):
                return self.save_file_as()

            fileName = editorWidget.ID
            self.emit(SIGNAL("beforeFileSaved(QString)"), fileName)
            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            content = editorWidget.get_text()
            file_manager.store_file_content(
                fileName, content, addExtension=False)
            self._file_watcher.allow_kill = False
            if editorWidget.ID != fileName:
                self.remove_standalone_watcher(editorWidget.ID)
            self.add_standalone_watcher(fileName)
            self._file_watcher.allow_kill = True
            editorWidget.ID = fileName
            encoding = file_manager.get_file_encoding(content)
            editorWidget.encoding = encoding
            self.emit(SIGNAL("fileSaved(QString)"),
                self.tr("File Saved: %1").arg(fileName))
            editorWidget._file_saved()
            return True
        except Exception, reason:
            editorWidget.just_saved = False
            logger.error('save_file: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                self.tr("The file couldn't be saved!"))
Exemplo n.º 7
0
    def save_file(self, editorWidget=None):
        # FIXME: check how we handle this
        if not editorWidget:
            editorWidget = self.get_current_editor()
        if editorWidget is None:
            return False
        # Ok, we have an editor instance
        # Save to file only if editor really was modified
        if editorWidget.is_modified:
            try:
                if (editorWidget.nfile.is_new_file
                        or not editorWidget.nfile.has_write_permission()):
                    return self.save_file_as()

                self.beforeFileSaved.emit(editorWidget.file_path)

                if settings.REMOVE_TRAILING_SPACES:
                    helpers.remove_trailing_spaces(editorWidget)
                # New line at end
                # FIXME: from settings
                helpers.insert_block_at_end(editorWidget)
                # Save convent
                editorWidget.neditable.save_content()
                encoding = file_manager.get_file_encoding(editorWidget.text)
                editorWidget.encoding = encoding

                self.fileSaved.emit(
                    self.tr("File Saved: {}".format(editorWidget.file_path)))

                return True
            except Exception as reason:
                logger.error('save_file: %s', reason)
                QMessageBox.information(self, self.tr("Save Error"),
                                        self.tr("The file couldn't be saved!"))
            return False
Exemplo n.º 8
0
    def save_file_as(self):
        editorWidget = self.get_current_editor()
        if not editorWidget:
            return False
        try:
            filters = "(*.py);;(*.*)"
            if editorWidget.file_path:
                ext = file_manager.get_file_extension(editorWidget.file_path)
                if ext != "py":
                    filters = "(*.%s);;(*.py);;(*.*)" % ext
            save_folder = self._get_save_folder(editorWidget.file_path)
            fileName = QFileDialog.getSaveFileName(self._parent, self.tr("Save File"), save_folder, filters)
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)

            editorWidget.neditable.save_content(path=fileName)
            editorWidget.register_syntax(file_manager.get_file_extension(fileName))

            self.emit(SIGNAL("fileSaved(QString)"), (self.tr("File Saved: %s") % fileName))
            self.emit(SIGNAL("currentEditorChanged(QString)"), fileName)
            return True
        except file_manager.NinjaFileExistsException as ex:
            QMessageBox.information(
                self,
                self.tr("File Already Exists"),
                (self.tr("Invalid Path: the file '%s' " " already exists.") % ex.filename),
            )
        except Exception as reason:
            logger.error("save_file_as: %s", reason)
            QMessageBox.information(self, self.tr("Save Error"), self.tr("The file couldn't be saved!"))
        return False
Exemplo n.º 9
0
    def save_file(self, editorWidget=None):
        # FIXME: check how we handle this
        if not editorWidget:
            editorWidget = self.get_current_editor()
        if editorWidget is None:
            return False
        # Ok, we have an editor instance
        # Save to file only if editor really was modified
        if editorWidget.is_modified:
            try:
                if (editorWidget.nfile.is_new_file or
                        not editorWidget.nfile.has_write_permission()):
                    return self.save_file_as()

                self.beforeFileSaved.emit(editorWidget.file_path)

                if settings.REMOVE_TRAILING_SPACES:
                    helpers.remove_trailing_spaces(editorWidget)
                # New line at end
                # FIXME: from settings
                helpers.insert_block_at_end(editorWidget)
                # Save convent
                editorWidget.neditable.save_content()
                encoding = file_manager.get_file_encoding(editorWidget.text)
                editorWidget.encoding = encoding

                self.fileSaved.emit(
                    self.tr("File Saved: {}".format(editorWidget.file_path)))

                return True
            except Exception as reason:
                logger.error('save_file: %s', reason)
                QMessageBox.information(self, self.tr("Save Error"),
                                        self.tr("The file couldn't be saved!"))
            return False
Exemplo n.º 10
0
    def save_file(self, editorWidget=None):
        #FIXME: check how we handle this
        if not editorWidget:
            editorWidget = self.get_current_editor()
        if not editorWidget:
            return False
        try:
            #editorWidget.just_saved = True
            nfile = editorWidget.nfile
            if nfile.is_new_file or not nfile.has_write_permission():
                return self.save_file_as()

            self.emit(SIGNAL("beforeFileSaved(QString)"), nfile.file_path)
            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            content = editorWidget.get_text()
            nfile.save(content)
            #file_manager.store_file_content(
                #fileName, content, addExtension=False)
            encoding = file_manager.get_file_encoding(content)
            editorWidget.encoding = encoding
            self.emit(SIGNAL("fileSaved(QString)"),
                (self.tr("File Saved: %s") % nfile.file_path))
            editorWidget._file_saved()
            return True
        except Exception as reason:
            #editorWidget.just_saved = False
            logger.error('save_file: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                self.tr("The file couldn't be saved!"))
        return False
Exemplo n.º 11
0
    def save_file_as(self):
        editorWidget = self.get_current_editor()
        if not editorWidget:
            return False
        try:
            #editorWidget.just_saved = True
            filters = '(*.py);;(*.*)'
            if editorWidget.file_path:
                ext = file_manager.get_file_extension(editorWidget.file_path)
                if ext != 'py':
                    filters = '(*.%s);;(*.py);;(*.*)' % ext
            save_folder = self._get_save_folder(editorWidget.file_path)
            fileName = QFileDialog.getSaveFileName(self._parent,
                                                   self.tr("Save File"),
                                                   save_folder, filters)
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            #newFile = file_manager.get_file_extension(fileName) == ''
            editorWidget.neditable.save_content(editorWidget.get_text(),
                                                path=fileName)
            #fileName = file_manager.store_file_content(
            #fileName, editorWidget.get_text(),
            #addExtension=True, newFile=newFile)
            #self.actualTab.setTabText(self.actualTab.currentIndex(),
            #file_manager.get_basename(fileName))
            editorWidget.register_syntax(
                file_manager.get_file_extension(fileName))
            #self._file_watcher.allow_kill = False
            #if editorWidget.ID != fileName:
            #self.remove_standalone_watcher(editorWidget.ID)
            #editorWidget.ID = fileName
            self.emit(SIGNAL("fileSaved(QString)"),
                      (self.tr("File Saved: %s") % fileName))
            self.emit(SIGNAL("currentEditorChanged(QString)"), fileName)
            editorWidget._file_saved()
            #self.add_standalone_watcher(fileName)
            #self._file_watcher.allow_kill = True
            return True
        except file_manager.NinjaFileExistsException as ex:
            #editorWidget.just_saved = False
            QMessageBox.information(
                self, self.tr("File Already Exists"),
                (self.tr("Invalid Path: the file '%s' already exists.") %
                 ex.filename))
        except Exception as reason:
            #editorWidget.just_saved = False
            logger.error('save_file_as: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                                    self.tr("The file couldn't be saved!"))
            self.actualTab.setTabText(self.actualTab.currentIndex(),
                                      self.tr("New Document"))
        return False
Exemplo n.º 12
0
    def save_file_as(self):
        editorWidget = self.get_current_editor()
        if not editorWidget:
            return False
        nfile = editorWidget.nfile
        try:
            #editorWidget.just_saved = True
            filters = '(*.py);;(*.*)'
            if nfile.file_path:
                ext = file_manager.get_file_extension(nfile.file_path)
                if ext != 'py':
                    filters = '(*.%s);;(*.py);;(*.*)' % ext
            save_folder = self._get_save_folder(nfile.file_path)
            fileName = QFileDialog.getSaveFileName(
                self._parent, self.tr("Save File"), save_folder, filters)
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            #newFile = file_manager.get_file_extension(fileName) == ''
            nfile.save(editorWidget.get_text(), path=fileName)
            print editorWidget.nfile._file_path
            #fileName = file_manager.store_file_content(
                #fileName, editorWidget.get_text(),
                #addExtension=True, newFile=newFile)
            #self.actualTab.setTabText(self.actualTab.currentIndex(),
                #file_manager.get_basename(fileName))
            editorWidget.register_syntax(
                file_manager.get_file_extension(fileName))
            #self._file_watcher.allow_kill = False
            #if editorWidget.ID != fileName:
                #self.remove_standalone_watcher(editorWidget.ID)
            #editorWidget.ID = fileName
            self.emit(SIGNAL("fileSaved(QString)"),
                (self.tr("File Saved: %s") % fileName))
            self.emit(SIGNAL("currentTabChanged(QString)"), fileName)
            editorWidget._file_saved()
            #self.add_standalone_watcher(fileName)
            #self._file_watcher.allow_kill = True
            return True
        except file_manager.NinjaFileExistsException as ex:
            #editorWidget.just_saved = False
            QMessageBox.information(self, self.tr("File Already Exists"),
                (self.tr("Invalid Path: the file '%s' already exists.") %
                    ex.filename))
        except Exception as reason:
            #editorWidget.just_saved = False
            logger.error('save_file_as: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                self.tr("The file couldn't be saved!"))
            self.actualTab.setTabText(self.actualTab.currentIndex(),
                self.tr("New Document"))
        return False
Exemplo n.º 13
0
    def save_file_as(self):
        editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            editorWidget.just_saved = True
            filters = '(*.py);;(*.*)'
            if editorWidget.ID:
                ext = file_manager.get_file_extension(editorWidget.ID)
                if ext != 'py':
                    filters = '(*.%s);;(*.py);;(*.*)' % ext
            save_folder = self._get_save_folder(editorWidget.ID)
            fileName = QFileDialog.getSaveFileName(
                self._parent, _translate("_s_MainContainer", "Save File"), save_folder, filters)
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            newFile = file_manager.get_file_extension(fileName) == ''
            fileName = file_manager.store_file_content(
                fileName, editorWidget.get_text(),
                addExtension=True, newFile=newFile)
            self.actualTab.setTabText(self.actualTab.currentIndex(),
                file_manager.get_basename(fileName))
            editorWidget.register_syntax(
                file_manager.get_file_extension(fileName))
            self._file_watcher.allow_kill = False
            if editorWidget.ID != fileName:
                self.remove_standalone_watcher(editorWidget.ID)
            editorWidget.ID = fileName
            self.fileSaved.emit((_translate("_s_MainContainer", "File Saved: %s") % fileName))
            self.currentTabChanged.emit(fileName)
            editorWidget._file_saved()
            self.add_standalone_watcher(fileName)
            self._file_watcher.allow_kill = True
            return True
        except file_manager.NinjaFileExistsException as ex:
            editorWidget.just_saved = False
            QMessageBox.information(self, _translate("_s_MainContainer", "File Already Exists"),
                (_translate("_s_MainContainer", "Invalid Path: the file '%s' already exists.") %
                    ex.filename))
        except Exception as reason:
            editorWidget.just_saved = False
            logger.error('save_file_as: %s', reason)
            QMessageBox.information(self, _translate("_s_MainContainer", "Save Error"),
                _translate("_s_MainContainer", "The file couldn't be saved!"))
            self.actualTab.setTabText(self.actualTab.currentIndex(),
                _translate("_s_MainContainer", "New Document"))
        return False
Exemplo n.º 14
0
    def save_file_as(self):
        editorWidget = self.get_current_editor()
        if not editorWidget:
            return False
        try:
            filters = '(*.py);;(*.*)'
            if editorWidget.file_path:  # existing file
                ext = file_manager.get_file_extension(editorWidget.file_path)
                if ext != 'py':
                    filters = '(*.%s);;(*.py);;(*.*)' % ext
            save_folder = self._get_save_folder(editorWidget.file_path)
            fileName = QFileDialog.getSaveFileName(self._parent,
                                                   self.tr("Save File"),
                                                   save_folder, filters)[0]
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)

            ext = file_manager.get_file_extension(fileName)
            if not ext:
                fileName = '%s.%s' % (
                    fileName,
                    'py',
                )

            editorWidget.neditable.save_content(path=fileName)
            # editorWidget.register_syntax(
            #     file_manager.get_file_extension(fileName))

            self.fileSaved.emit(self.tr("File Saved: {}".format(fileName)))

            self.currentEditorChanged.emit(fileName)

            return True
        except file_manager.NinjaFileExistsException as ex:
            QMessageBox.information(
                self, self.tr("File Already Exists"),
                (self.tr("Invalid Path: the file '%s' "
                         " already exists.") % ex.filename))
        except Exception as reason:
            logger.error('save_file_as: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                                    self.tr("The file couldn't be saved!"))
        return False
Exemplo n.º 15
0
    def save_file_as(self):
        editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            editorWidget.just_saved = True
            filters = '(*.py);;(*.*)'
            if editorWidget.ID:
                ext = file_manager.get_file_extension(editorWidget.ID)
                if ext != 'py':
                    filters = '(*.%s);;(*.py);;(*.*)' % ext
            save_folder = self._get_save_folder(editorWidget.ID)
            fileName = unicode(
                QFileDialog.getSaveFileName(self._parent, self.tr("Save File"),
                                            save_folder, filters))
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            newFile = file_manager.get_file_extension(fileName) == ''
            fileName = file_manager.store_file_content(fileName,
                                                       editorWidget.get_text(),
                                                       addExtension=True,
                                                       newFile=newFile)
            self.actualTab.setTabText(self.actualTab.currentIndex(),
                                      file_manager.get_basename(fileName))
            editorWidget.register_syntax(
                file_manager.get_file_extension(fileName))
            self._file_watcher.allow_kill = False
            if editorWidget.ID != fileName:
                self.remove_standalone_watcher(editorWidget.ID)
            editorWidget.ID = fileName
            self.emit(SIGNAL("fileSaved(QString)"),
                      self.tr("File Saved: %1").arg(fileName))
            editorWidget._file_saved()
            self.add_standalone_watcher(fileName)
            self._file_watcher.allow_kill = True
            return True
        except file_manager.NinjaFileExistsException, ex:
            editorWidget.just_saved = False
            QMessageBox.information(self, self.tr("File Already Exists"),
                self.tr("Invalid Path: the file '%s' already exists." % \
                    ex.filename))
Exemplo n.º 16
0
    def save_file_as(self):
        editorWidget = self.get_current_editor()
        if not editorWidget:
            return False
        try:
            filters = '(*.py);;(*.*)'
            if editorWidget.file_path:  # existing file
                ext = file_manager.get_file_extension(editorWidget.file_path)
                if ext != 'py':
                    filters = '(*.%s);;(*.py);;(*.*)' % ext
            save_folder = self._get_save_folder(editorWidget.file_path)
            fileName = QFileDialog.getSaveFileName(
                self._parent, self.tr("Save File"), save_folder, filters)[0]
            if not fileName:
                return False

            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)

            ext = file_manager.get_file_extension(fileName)
            if not ext:
                fileName = '%s.%s' % (fileName, 'py',)

            editorWidget.neditable.save_content(path=fileName)
            # editorWidget.register_syntax(
            #     file_manager.get_file_extension(fileName))

            self.fileSaved.emit(self.tr("File Saved: {}".format(fileName)))

            self.currentEditorChanged.emit(fileName)

            return True
        except file_manager.NinjaFileExistsException as ex:
            QMessageBox.information(self, self.tr("File Already Exists"),
                                    (self.tr("Invalid Path: the file '%s' "
                                             " already exists.") %
                                    ex.filename))
        except Exception as reason:
            logger.error('save_file_as: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                                    self.tr("The file couldn't be saved!"))
        return False
Exemplo n.º 17
0
    def save_file(self, editorWidget=None):
        if not editorWidget:
            editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            editorWidget.just_saved = True
            if editorWidget.newDocument or \
            not file_manager.has_write_permission(editorWidget.ID):
                return self.save_file_as()

            fileName = editorWidget.ID
            self.emit(SIGNAL("beforeFileSaved(QString)"), fileName)
            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            content = editorWidget.get_text()
            file_manager.store_file_content(fileName,
                                            content,
                                            addExtension=False)
            self._file_watcher.allow_kill = False
            if editorWidget.ID != fileName:
                self.remove_standalone_watcher(editorWidget.ID)
            self.add_standalone_watcher(fileName)
            self._file_watcher.allow_kill = True
            editorWidget.ID = fileName
            encoding = file_manager.get_file_encoding(content)
            editorWidget.encoding = encoding
            self.emit(SIGNAL("fileSaved(QString)"),
                      self.tr("File Saved: %s" % fileName))
            editorWidget._file_saved()
            return True
        except Exception as reason:
            print(reason)
            raise
            editorWidget.just_saved = False
            logger.error('save_file: %s', reason)
            QMessageBox.information(self, self.tr("Save Error"),
                                    self.tr("The file couldn't be saved!"))
        return False
Exemplo n.º 18
0
    def save_file(self, editorWidget=None):
        if not editorWidget:
            editorWidget = self.get_actual_editor()
        if not editorWidget:
            return False
        try:
            if editorWidget.newDocument or not file_manager.has_write_permission(editorWidget.ID):
                return self.save_file_as()

            fileName = editorWidget.ID
            if settings.REMOVE_TRAILING_SPACES:
                helpers.remove_trailing_spaces(editorWidget)
            content = editorWidget.get_text()
            file_manager.store_file_content(fileName, content, addExtension=False)
            editorWidget.ID = fileName
            encoding = file_manager._search_coding_line(content)
            editorWidget.encoding = encoding
            self.emit(SIGNAL("fileSaved(QString)"), self.tr("File Saved: %1").arg(fileName))
            editorWidget._file_saved()
            return True
        except Exception, reason:
            logger.error("save_file: %s", reason)
            QMessageBox.information(self, self.tr("Save Error"), self.tr("The file couldn't be saved!"))
Exemplo n.º 19
0
 def editor_remove_trailing_spaces(self):
     """Remove the trailing spaces in the current editor."""
     editorWidget = self.get_current_editor()
     if editorWidget:
         helpers.remove_trailing_spaces(editorWidget)
Exemplo n.º 20
0
 def editor_remove_trailing_spaces(self):
     editorWidget = self.ide.mainContainer.get_actual_editor()
     if editorWidget:
         helpers.remove_trailing_spaces(editorWidget)
Exemplo n.º 21
0
 def editor_remove_trailing_spaces(self):
     """Remove the trailing spaces in the current editor."""
     editorWidget = self.ide.mainContainer.get_actual_editor()
     if editorWidget:
         helpers.remove_trailing_spaces(editorWidget)
Exemplo n.º 22
0
 def editor_remove_trailing_spaces(self):
     """Remove the trailing spaces in the current editor."""
     editorWidget = self.get_current_editor()
     if editorWidget:
         helpers.remove_trailing_spaces(editorWidget)
Exemplo n.º 23
0
 def editor_remove_trailing_spaces(self):
     """Remove the trailing spaces in the current editor."""
     editorWidget = self.ide.mainContainer.get_actual_editor()
     if editorWidget:
         helpers.remove_trailing_spaces(editorWidget)
Exemplo n.º 24
0
 def editor_remove_trailing_spaces(self):
     editorWidget = self.ide.mainContainer.get_actual_editor()
     if editorWidget:
         helpers.remove_trailing_spaces(editorWidget)