本文整理汇总了Python中utils.globals.GlobalData.getProjectDir方法的典型用法代码示例。如果您正苦于以下问题:Python GlobalData.getProjectDir方法的具体用法?Python GlobalData.getProjectDir怎么用?Python GlobalData.getProjectDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.globals.GlobalData
的用法示例。
在下文中一共展示了GlobalData.getProjectDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getProjectDir [as 别名]
def __init__( self, fileName = None, lineNumber = None, condition = "",
temporary = False, enabled = True, ignoreCount = 0 ):
if fileName is None:
self.__fileName = fileName
elif os.path.isabs( fileName ):
project = GlobalData().project
if project.isLoaded():
if project.isProjectFile( fileName ):
# This is a project file; strip the project dir
self.__fileName = fileName.replace( project.getProjectDir(),
"" )
else:
# Not a project file, save as is
self.__fileName = fileName
else:
# Pretty much impossible
self.__fileName = fileName
else:
# Relative path, i.e. a project file
self.__fileName = fileName
self.__lineNumber = lineNumber
self.__condition = condition
self.__temporary = temporary
self.__enabled = enabled
self.__ignoreCount = ignoreCount
return
示例2: getAbsoluteFileName
# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getProjectDir [as 别名]
def getAbsoluteFileName( self ):
" Provides the absolute file name "
if self.__fileName is None:
return None
if os.path.isabs( self.__fileName ):
return self.__fileName
project = GlobalData().project
if project.isLoaded():
return project.getProjectDir() + self.__fileName
return os.path.abspath( self.__fileName )
示例3: isValid
# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getProjectDir [as 别名]
def isValid( self ):
" True if the breakpoint is valid "
if self.__fileName is None:
return False
if os.path.isabs( self.__fileName ):
if not os.path.exists( self.__fileName ):
return False
else:
project = GlobalData().project
if project.isLoaded():
path = project.getProjectDir() + self.__fileName
if not os.path.exists( path ):
return False
else:
if not os.path.exists( self.__fileName ):
return False
return self.__lineNumber is not None and \
self.__lineNumber > 0
示例4: __viewProperties
# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getProjectDir [as 别名]
def __viewProperties( self ):
" Handles the 'view properties' context menu item "
if self.__projectContextItem is None:
return
if not self.__projectContextItem.isValid():
return
if self.__projectContextItem.isCurrent():
# This is the current project - it can be edited
project = GlobalData().project
dialog = ProjectPropertiesDialog( project )
if dialog.exec_() == QDialog.Accepted:
importDirs = []
for index in xrange( dialog.importDirList.count() ):
importDirs.append( dialog.importDirList.item( index ).text() )
scriptName = dialog.scriptEdit.text().strip()
relativePath = relpath( scriptName, project.getProjectDir() )
if not relativePath.startswith( '..' ):
scriptName = relativePath
project.updateProperties(
scriptName, importDirs,
dialog.creationDateEdit.text().strip(),
dialog.authorEdit.text().strip(),
dialog.licenseEdit.text().strip(),
dialog.copyrightEdit.text().strip(),
dialog.versionEdit.text().strip(),
dialog.emailEdit.text().strip(),
dialog.descriptionEdit.toPlainText().strip() )
else:
# This is not the current project - it can be viewed
fName = self.__projectContextItem.getFilename()
dialog = ProjectPropertiesDialog( fName )
dialog.exec_()
return
示例5: __selectFile
# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getProjectDir [as 别名]
def __selectFile( self, extension ):
" Picks a file of a certain extension "
dialog = QFileDialog( self, 'Save flowchart as' )
dialog.setFileMode( QFileDialog.AnyFile )
dialog.setLabelText( QFileDialog.Accept, "Save" )
dialog.setNameFilter( extension.upper() + " files (*." +
extension.lower() + ")" )
urls = []
for dname in QDir.drives():
urls.append( QUrl.fromLocalFile( dname.absoluteFilePath() ) )
urls.append( QUrl.fromLocalFile( QDir.homePath() ) )
project = GlobalData().project
if project.isLoaded():
urls.append( QUrl.fromLocalFile( project.getProjectDir() ) )
dialog.setSidebarUrls( urls )
suggestedFName = self.__parentWidget.getFileName()
if '.' in suggestedFName:
dotIndex = suggestedFName.rindex( '.' )
suggestedFName = suggestedFName[ : dotIndex ]
dialog.setDirectory( self.__getDefaultSaveDir() )
dialog.selectFile( suggestedFName + "." + extension.lower() )
dialog.setOption( QFileDialog.DontConfirmOverwrite, False )
if dialog.exec_() != QDialog.Accepted:
return None
fileNames = dialog.selectedFiles()
fileName = os.path.abspath( str( fileNames[0] ) )
if os.path.isdir( fileName ):
logging.error( "A file must be selected" )
return None
if "." not in fileName:
fileName += "." + extension.lower()
# Check permissions to write into the file or to a directory
if os.path.exists( fileName ):
# Check write permissions for the file
if not os.access( fileName, os.W_OK ):
logging.error( "There is no write permissions for " + fileName )
return None
else:
# Check write permissions to the directory
dirName = os.path.dirname( fileName )
if not os.access( dirName, os.W_OK ):
logging.error( "There is no write permissions for the "
"directory " + dirName )
return None
if os.path.exists( fileName ):
res = QMessageBox.warning( self, "Save flowchart as",
"<p>The file <b>" + fileName + "</b> already exists.</p>",
QMessageBox.StandardButtons( QMessageBox.Abort |
QMessageBox.Save ),
QMessageBox.Abort )
if res == QMessageBox.Abort or res == QMessageBox.Cancel:
return None
# All prerequisites are checked, return a file name
return fileName
示例6: __getDefaultSaveDir
# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getProjectDir [as 别名]
def __getDefaultSaveDir( self ):
" Provides the default directory to save files to "
project = GlobalData().project
if project.isLoaded():
return project.getProjectDir()
return QDir.currentPath()