本文整理汇总了Python中Controller.Controller.sanitize_check方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.sanitize_check方法的具体用法?Python Controller.sanitize_check怎么用?Python Controller.sanitize_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller.Controller
的用法示例。
在下文中一共展示了Controller.sanitize_check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NoGuiAnalysis
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import sanitize_check [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
'''
#.........这里部分代码省略.........