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


Python Controller.load_file方法代码示例

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


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

示例1: NoGuiAnalysis

# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import load_file [as 别名]
class NoGuiAnalysis():

    def __init__(self,controller=None,mainWindow=None):
      
        ## input variables
        if controller == None:
            self.controller = Controller()
        else:
            self.controller = controller
        self.mainWindow = mainWindow
        self.validLanguages = ['r','python']
        self.sphinxLog = None
        self.goFlag = False
        self.reload_program_paths()
        
    def reload_program_paths(self):
        """
        function to update the paths to programs for system calls
        """
        
        ## ensure that the log file is loaded
        if len(self.controller.log.log.items()) < 1:
           self.controller.log = Logger() 

        self.rPath = self.controller.get_r_path(mainWindow=self.mainWindow)
        self.pythonPath = self.controller.get_python_path(mainWindow=self.mainWindow)
        self.sphinxPath = self.controller.get_sphinx_path(mainWindow=self.mainWindow)
        self.latexPath = self.controller.get_latex_path()
        self.parsePath = os.path.join(self.controller.baseDir,"ParseEmbedded.py")
        self.latex2htmlPath = self.controller.get_latex2html_path()

    def build(self,fileName=None,verbose=False):
        """
        generic command to build a rst,nw or rnw document
        """

        ## variables
        self.goFlag = False
        if self.mainWindow != None:
            self.mainWindow.ensure_tab_is_current()
        
        ## if a fileName is specified the set the current index
        if fileName != None and fileName in self.controller.fileNameList:
            currentIdx = self.controller.fileNameList.index(fileName)
            self.controller.currentFileIndex = currentIdx
        
        currentIdx = self.controller.currentFileIndex
        fileName = self.controller.fileNameList[currentIdx]
        filePath = self.controller.filePathList[currentIdx]

        fileLanguage = self.controller.fileLangList[currentIdx]
        self.reload_program_paths()
        goFlag = None

        if self.mainWindow != None:
            editor = self.mainWindow.controller.editorList[currentIdx] 
            editor.clear_messages()
        
        self.output_text("BUILDING... %s"%fileName)

        ## error checking
        isClean = self.controller.sanitize_check(filePath)
        if isClean == False:
            msg = "Invalid file/dir name\n"
            msg += "%s\nremove characters like '$','#' and '&' then try again"%(filePath) 
            self.display_error(msg)
            return

        isActive = self.is_active_project(filePath)
        if not isActive:
            return
        isTemplate = self.is_template()
        if isTemplate == True:
            return

        fileLanguage = fileLanguage.lower()
        if fileLanguage not in self.validLanguages:
            msg = "Valid languages are %s not %s"%(self.validLanguages,fileLanguage)
            self.display_error(msg)
            return

        ## save file
        if self.mainWindow != None:
            self.mainWindow.file_save(display=False)

        ## run the appropriate builder
        if re.search("\.rst",fileName,flags=re.IGNORECASE):
            self.build_rst(verbose=verbose)
        elif re.search("\.rnw|\.nw",fileName,flags=re.IGNORECASE):
            self.build_nw(verbose=verbose)
        else:
            msg = "Invalid file name extension\n"
            msg +="...lpEdit cannot build\n"
            msg +=filePath
            self.display_error(msg)

    def load_file(self,filePath,fileLang=None):
        '''
        use the controller to load a specified file
        '''
#.........这里部分代码省略.........
开发者ID:lpedit-devs,项目名称:lpedit,代码行数:103,代码来源:NoGuiAnalysis.py


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