• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.remove_trailing_spaces函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ninja_ide.gui.editor.helpers.remove_trailing_spaces函数的典型用法代码示例。如果您正苦于以下问题:Python remove_trailing_spaces函数的具体用法?Python remove_trailing_spaces怎么用?Python remove_trailing_spaces使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了remove_trailing_spaces函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: save_file_as

    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))
开发者ID:beefsack,项目名称:ninja-ide,代码行数:34,代码来源:main_container.py


示例2: save_file

    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!"))
开发者ID:dlitvakb,项目名称:ninja-ide,代码行数:35,代码来源:main_container.py


示例3: save_file

    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
开发者ID:pdorrell,项目名称:ninja-ide,代码行数:31,代码来源:main_container.py


示例4: save_file_as

    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
开发者ID:perrito666,项目名称:ninja-ide,代码行数:34,代码来源:main_container.py


示例5: save_file

    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
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:35,代码来源:__main_container.py


示例6: save_file_as

    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
开发者ID:pdorrell,项目名称:ninja-ide,代码行数:54,代码来源:main_container.py


示例7: save_file_as

    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
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:50,代码来源:main_container.py


示例8: save_file_as

    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
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:42,代码来源:__main_container.py


示例9: save_file

    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!"))
开发者ID:sanyaade,项目名称:ninja-ide,代码行数:23,代码来源:main_container.py


示例10: editor_remove_trailing_spaces

 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)
开发者ID:SlashRoot,项目名称:ninja-ide,代码行数:5,代码来源:actions.py


示例11: editor_remove_trailing_spaces

 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)
开发者ID:pdorrell,项目名称:ninja-ide,代码行数:5,代码来源:main_container.py


示例12: editor_remove_trailing_spaces

 def editor_remove_trailing_spaces(self):
     editorWidget = self.ide.mainContainer.get_actual_editor()
     if editorWidget:
         helpers.remove_trailing_spaces(editorWidget)
开发者ID:sanyaade,项目名称:ninja-ide,代码行数:4,代码来源:actions.py



注:本文中的ninja_ide.gui.editor.helpers.remove_trailing_spaces函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ide.IDE类代码示例发布时间:2022-05-27
下一篇:
Python editor.create_editor函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap