本文整理汇总了Python中PyQt5.QtCore.QFileInfo.mkpath方法的典型用法代码示例。如果您正苦于以下问题:Python QFileInfo.mkpath方法的具体用法?Python QFileInfo.mkpath怎么用?Python QFileInfo.mkpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QFileInfo
的用法示例。
在下文中一共展示了QFileInfo.mkpath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getFileName
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import mkpath [as 别名]
def __getFileName(self):
"""
Private method to get the file name to save to from the user.
"""
if self.__gettingFileName:
return
import Helpviewer.HelpWindow
downloadDirectory = Helpviewer.HelpWindow.HelpWindow\
.downloadManager().downloadDirectory()
if self.__fileName:
fileName = self.__fileName
originalFileName = self.__originalFileName
self.__toDownload = True
ask = False
else:
defaultFileName, originalFileName = \
self.__saveFileName(downloadDirectory)
fileName = defaultFileName
self.__originalFileName = originalFileName
ask = True
self.__autoOpen = False
if not self.__toDownload:
from .DownloadAskActionDialog import DownloadAskActionDialog
url = self.__reply.url()
dlg = DownloadAskActionDialog(
QFileInfo(originalFileName).fileName(),
self.__reply.header(QNetworkRequest.ContentTypeHeader),
"{0}://{1}".format(url.scheme(), url.authority()),
self)
if dlg.exec_() == QDialog.Rejected or dlg.getAction() == "cancel":
self.progressBar.setVisible(False)
self.__reply.close()
self.on_stopButton_clicked()
self.filenameLabel.setText(
self.tr("Download canceled: {0}").format(
QFileInfo(defaultFileName).fileName()))
self.__canceledFileSelect = True
return
if dlg.getAction() == "scan":
self.__mainWindow.requestVirusTotalScan(url)
self.progressBar.setVisible(False)
self.__reply.close()
self.on_stopButton_clicked()
self.filenameLabel.setText(
self.tr("VirusTotal scan scheduled: {0}").format(
QFileInfo(defaultFileName).fileName()))
self.__canceledFileSelect = True
return
self.__autoOpen = dlg.getAction() == "open"
if PYQT_VERSION_STR >= "5.0.0":
from PyQt5.QtCore import QStandardPaths
tempLocation = QStandardPaths.standardLocations(
QStandardPaths.TempLocation)[0]
else:
from PyQt5.QtGui import QDesktopServices
tempLocation = QDesktopServices.storageLocation(
QDesktopServices.TempLocation)
fileName = tempLocation + '/' + \
QFileInfo(fileName).completeBaseName()
if ask and not self.__autoOpen and self.__requestFilename:
self.__gettingFileName = True
fileName = E5FileDialog.getSaveFileName(
None,
self.tr("Save File"),
defaultFileName,
"")
self.__gettingFileName = False
if not fileName:
self.progressBar.setVisible(False)
self.__reply.close()
self.on_stopButton_clicked()
self.filenameLabel.setText(
self.tr("Download canceled: {0}")
.format(QFileInfo(defaultFileName).fileName()))
self.__canceledFileSelect = True
return
fileInfo = QFileInfo(fileName)
Helpviewer.HelpWindow.HelpWindow.downloadManager()\
.setDownloadDirectory(fileInfo.absoluteDir().absolutePath())
self.filenameLabel.setText(fileInfo.fileName())
self.__output.setFileName(fileName + ".part")
self.__fileName = fileName
# check file path for saving
saveDirPath = QFileInfo(self.__fileName).dir()
if not saveDirPath.exists():
if not saveDirPath.mkpath(saveDirPath.absolutePath()):
self.progressBar.setVisible(False)
self.on_stopButton_clicked()
self.infoLabel.setText(self.tr(
"Download directory ({0}) couldn't be created.")
.format(saveDirPath.absolutePath()))
#.........这里部分代码省略.........