本文整理汇总了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]
示例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]