当前位置: 首页>>代码示例>>Python>>正文


Python Controller.get_templates_dir方法代码示例

本文整理汇总了Python中Controller.Controller.get_templates_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.get_templates_dir方法的具体用法?Python Controller.get_templates_dir怎么用?Python Controller.get_templates_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Controller.Controller的用法示例。


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

示例1: MainWindow

# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import get_templates_dir [as 别名]

#.........这里部分代码省略.........
        self.tabWidget.setCurrentIndex(newIndex)
        self.ensure_tab_is_current()


    def _file_save(self,fileIndex):
        """
        lpEdits internal file save
        """

        fileName = self.controller.fileNameList[fileIndex]
        filePath = self.controller.filePathList[fileIndex]
        editor = self.controller.editorList[fileIndex]
        currentText = editor.get_text()
        fid = open(filePath,'w')
        
        ## remove carriage returns
        if re.search("\r",currentText):
            currentText = re.sub("\r+","",currentText)

        fid.write(currentText)
        fid.close()

    def file_save(self,display=True):
        '''
        saves the file in the current tab as itself
        '''

        self.ensure_tab_is_current()
        fileIndex = self.controller.currentFileIndex
        if self.controller.fileNameList[fileIndex] == None:
            self.display_info("A valid file must be loaded before saving")
            return

        templatesDir = self.controller.get_templates_dir()
        currentFilePath = self.controller.filePathList[fileIndex]
        currentFileName = self.controller.fileNameList[fileIndex]
        if os.path.join(templatesDir,currentFileName) == currentFilePath:
            self.display_info("Cannot overwrite template -- use 'Save As'")
            return

        self._file_save(fileIndex)

        fileName = self.controller.fileNameList[fileIndex]
        if fileName in self.unsaved:
            self.unsaved.remove(fileName)
            self.tabWidget.setTabText(fileIndex,fileName)

        if display == True:
            self.display_info("Progress saved")

    def file_save_as(self):
        """
        saves the file in the current tab as another file
        """

        self.ensure_tab_is_current()
        if self.controller.fileNameList[self.controller.currentFileIndex] == None:
            self.display_info("A valid file must be loaded before saving")
            return

        currentFilePath = self.controller.filePathList[self.controller.currentFileIndex]
        currentFileName = self.controller.fileNameList[self.controller.currentFileIndex]
        currentEditor = self.controller.editorList[self.controller.currentFileIndex]
        currentText = currentEditor.get_text()

        defaultDir = os.path.split(currentFilePath)[0]
开发者ID:lpedit-devs,项目名称:lpedit,代码行数:70,代码来源:MainWindow.py

示例2: NoGuiAnalysis

# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import get_templates_dir [as 别名]

#.........这里部分代码省略.........
                msg += includedFilePath
                if self.mainWindow != None:
                    self.mainWindow.display_warning(msg)
                else:
                    print msg
                return False

            if os.path.islink(newFilePath):
                os.remove(newFilePath)
            if os.path.exists(newFilePath):
                os.remove(newFilePath)

            self.output_text("INCLUDE: %s \n...%s"%(includedFilePath,newFilePath))

            os.symlink(includedFilePath,newFilePath)

        return True

    def is_active_project(self,currentFilePath):
        """
        check for an active project
        """
        if currentFilePath == '' or currentFilePath == None:
            msg = "Load or create a new file before compiling code"
            self.display_error(msg)
            return False

        return True

    def is_template(self):
        """
        checks to see if currentFile is a template or not
        """
        templatesDir = self.controller.get_templates_dir()
        currentFilePath = self.controller.filePathList[self.controller.currentFileIndex]
        currentFileName = self.controller.fileNameList[self.controller.currentFileIndex]

        if os.path.join(templatesDir,currentFileName) == currentFilePath:
            msg = "Use 'Save As' before trying to work with template"
            self.display_error(msg)
            return True

        return False

    def display_error(self,msg):
        """
        generic function to display an error
        """
        if self.mainWindow != None:
            self.mainWindow.display_warning(re.sub("\n","<p>",msg))
        else:
            print "ERROR: ", msg

    def build_nw(self,verbose=True):
        """
        uses system calls to compile nw or sweave code
        """

        ## variables
        templatesDir = self.controller.get_templates_dir()
        currentIdx = self.controller.currentFileIndex
        filePath = self.controller.filePathList[currentIdx]
        fileName = self.controller.fileNameList[currentIdx] 
        fileLanguage = self.controller.fileLangList[currentIdx]
        fileLanguage = fileLanguage.lower()
        filePathBase = os.path.split(filePath)[0]
开发者ID:lpedit-devs,项目名称:lpedit,代码行数:70,代码来源:NoGuiAnalysis.py


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