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


Python QFileInfo.mkpath方法代码示例

本文整理汇总了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()))
#.........这里部分代码省略.........
开发者ID:pycom,项目名称:EricShort,代码行数:103,代码来源:DownloadItem.py


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