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


Python FileUtils.checkSource方法代码示例

本文整理汇总了Python中FileUtils.checkSource方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.checkSource方法的具体用法?Python FileUtils.checkSource怎么用?Python FileUtils.checkSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileUtils的用法示例。


在下文中一共展示了FileUtils.checkSource方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     try:
         if uni.getBoolValue("isForceOpenWithDefaultApplication"):
             _path = fu.checkSource(_filePath)
             Execute.openWith([_path])
         else:
             _path = fu.checkSource(_filePath, "file", False)
             if _path is not None:
                 isOpened = False
                 mtype = fu.getMimeType(_path)
                 if mtype[0] is not None:
                     if mtype[0].split("/")[0] == "text":
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif mtype[0].split("/")[0] == "audio":
                         if Taggers.getTagger(True) is not None:
                             MusicDetails.MusicDetails(_path, _isOpenDetailsOnNewWindow)
                             isOpened = True
                     elif mtype[0].split("/")[0] == "image":
                         ImageDetails.ImageDetails(_path, "file", _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 else:
                     if fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 if isOpened is False:
                     if uni.getBoolValue("isOpenWithDefaultApplication"):
                         Execute.openWith([_path])
                     else:
                         Dialogs.showError(translate("Details", "File Is Not Supported"),
                                           str(translate("Details",
                                                         "\"%s\" couldn't opened. This file is not supported.")) % Organizer.getLink(
                                               str(_path)))
             elif fu.isDir(_filePath):
                 if uni.getBoolValue("isOpenWithDefaultApplication"):
                     Execute.openWith([_filePath])
                 else:
                     Dialogs.showError(translate("Details", "Directories Is Not Supported"),
                                       str(translate("Details",
                                                     "\"%s\" couldn't opened. Directories is not supported to show details.")) % Organizer.getLink(
                                           str(_filePath)))
             else:
                 Dialogs.showError(translate("Details", "File Is Not Exist"),
                                   str(translate("Details",
                                                 "\"%s\" couldn't opened. This file is not exist.")) % Organizer.getLink(
                                       str(_filePath)))
     except:
         answer = Dialogs.askSpecial(translate("Details", "File Couldn't Opened"),
                                     str(translate("Details",
                                                   "\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us.")) % Organizer.getLink(
                                         str(_filePath)),
                                     translate("QuickMake", "Report This Bug"), translate("QuickMake", "OK"), None)
         if answer == translate("QuickMake", "Report This Bug"):
             ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:59,代码来源:__init__.py

示例2: checkSource

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
 def checkSource(self, _oldPath, _objectType="fileAndDirectory", _isCheckWritable=True):
     _path = fu.checkSource(_oldPath, _objectType, False)
     if _path is None:
         if _objectType == "file":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         elif _objectType == "directory":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a folder with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         else:
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File Or Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file or directory with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
     if _isCheckWritable:
         if fu.isWritableFileOrDir(_oldPath) is False:
             return None
     return _path
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:33,代码来源:QuickMake.py

示例3: hash

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
 def hash(self):
     sourceFile = str(self.lePathOfPackage.text())
     sourceFile = fu.checkSource(sourceFile, "file")
     if sourceFile is not None:
         hashType = str(self.cbHash.currentText())
         if hashType is not None:
             hashDigestContent = fu.getHashDigest(sourceFile, hashType)
             if hashDigestContent is not False:
                 self.teHashDigest.setText(str(hashDigestContent))
                 if self.cbHashOutput.currentIndex() == 1:
                     if fu.createHashDigestFile(sourceFile, str(self.leHashDigestFile.text()), hashType, False,
                                                hashDigestContent):
                         Dialogs.show(translate("Hasher", "Hash Digest File Created"),
                                      str(translate("Hasher", "Hash digest writed into %s")) % str(
                                          self.leHashDigestFile.text()))
                     else:
                         Dialogs.showError(translate("Hasher", "Hash Digest File Is Not Created"),
                                           translate("Hasher", "Hash digest file not cteated."))
                 elif self.cbHashOutput.currentIndex() == 2:
                     MApplication.clipboard().setText(str(hashDigestContent))
                     Dialogs.show(translate("Hasher", "Hash Digest Copied To Clipboard"),
                                  str(translate("Hasher",
                                                "Hash digest copied to clipboard.Hash digest is : <br>%s")) % hashDigestContent)
             else:
                 Dialogs.showError(translate("Hasher", "Hash Digest Is Not Created"),
                                   translate("Hasher", "Hash digest not cteated."))
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:28,代码来源:Hasher.py

示例4: setSourceToSearch

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
 def setSourceToSearch(self, _isReload=True, _isLoadFromCache=False):
     try:
         if self.sourceToSearch is None or _isReload:
             sourceToSearch = ""
             self.isMultipleSource = False
             pathToSearchs = str(self.lePathToSeach.text())
             if fu.isExist(pathToSearchs) is False and pathToSearchs.find(";") != -1:
                 self.isMultipleSource = True
             for pathToSearch in uni.getListFromListString(pathToSearchs, ";"):
                 if pathToSearch in self.sourceToSearchCache and _isLoadFromCache:
                     sourceToSearch += self.sourceToSearchCache[pathToSearch]
                 else:
                     pathToSearch = fu.checkSource(pathToSearch)
                     if pathToSearch is not None:
                         if fu.isReadableFileOrDir(pathToSearch):
                             if fu.isFile(pathToSearch) and fu.isBinary(pathToSearch) is False:
                                 sts = fu.readFromFile(pathToSearch) + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
                             elif fu.isDir(pathToSearch):
                                 sts = fu.getFileTree(pathToSearch, -1, "return", "plainText", "fileList") + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
             self.sourceToSearch = sourceToSearch
             if sourceToSearch != "":
                 return True
             return False
         else:
             return True
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:33,代码来源:Searcher.py

示例5: __init__

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     global currentDialogs
     _filePath = fu.checkSource(_filePath, "file")
     if _filePath is not None:
         if _isOpenDetailsOnNewWindow is False:
             isHasOpenedDialog = False
             for dialog in currentDialogs:
                 if dialog.isVisible():
                     isHasOpenedDialog = True
                     dialog.changeFile(_filePath)
                     dialog.activateWindow()
                     dialog.raise_()
                     break
             if isHasOpenedDialog is False:
                 _isOpenDetailsOnNewWindow = True
         if _isOpenDetailsOnNewWindow:
             currentDialogs.append(self)
             MDialog.__init__(self, MApplication.activeWindow())
             if isActivePyKDE4:
                 self.setButtons(MDialog.NoDefault)
             self.charSet = MComboBox()
             self.charSet.addItems(uni.getCharSets())
             self.charSet.setCurrentIndex(self.charSet.findText(uni.MySettings["fileSystemEncoding"]))
             self.infoLabels = {}
             self.infoValues = {}
             self.fileValues = {}
             pbtnClose = MPushButton(translate("TextDetails", "Close"))
             pbtnSave = MPushButton(translate("TextDetails", "Save Changes"))
             pbtnSave.setIcon(MIcon("Images:save.png"))
             MObject.connect(pbtnClose, SIGNAL("clicked()"), self.close)
             MObject.connect(pbtnSave, SIGNAL("clicked()"), self.save)
             self.labels = [translate("TextDetails", "File Path : "),
                            translate("TextDetails", "Content : ")]
             self.pnlMain = MWidget()
             self.vblMain = MVBoxLayout(self.pnlMain)
             self.pnlClearable = None
             self.changeFile(_filePath, True)
             HBOXs, VBOXs = [], []
             VBOXs.append(MVBoxLayout())
             HBOXs.append(MHBoxLayout())
             HBOXs[-1].addWidget(self.charSet, 1)
             HBOXs[-1].addWidget(pbtnSave, 4)
             VBOXs[0].addLayout(HBOXs[-1])
             VBOXs[0].addWidget(pbtnClose)
             self.vblMain.addLayout(VBOXs[0], 1)
             if isActivePyKDE4:
                 self.setMainWidget(self.pnlMain)
             else:
                 self.setLayout(self.vblMain)
             self.show()
             self.setMinimumWidth(700)
             self.setMinimumHeight(500)
     else:
         Dialogs.showError(translate("TextDetails", "File Does Not Exist"),
                           str(translate("TextDetails",
                                         "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
                           ) % Organizer.getLink(str(_filePath)))
         if hasattr(getMainWindow(),
                    "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:61,代码来源:TextDetails.py

示例6: makeRefresh

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
 def makeRefresh(self, _newDirectoryPath="", _isOnlyBrowser=False):
     try:
         if _newDirectoryPath != "" and _newDirectoryPath is not True and _newDirectoryPath is not False:
             self.goTo(_newDirectoryPath, False)
         else:
             sourcePath = fu.checkSource(str(self.currentDirectory), "directory")
             if sourcePath is not None:
                 if self.currentDirectory != str(sourcePath):
                     self.goTo(sourcePath, False)
                 else:
                     self.makeRefreshOnlyFileList()
                     self.makeRefreshOnlyFileListByTree()
                     if _isOnlyBrowser is False:
                         self.showInTable()
             else:
                 self.goTo(fu.getRealDirName(str(self.currentDirectory)), False)
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:20,代码来源:FileManager.py

示例7: play

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
    def play(self, _filePath="", _isPlayNow=True):
        try:
            MApplication.processEvents()
            playerName = uni.MySettings["playerName"]
            if self.Player is None or self.PlayerName != playerName:
                self.stop()
                self.PlayerName = playerName
                if playerName == "Phonon":
                    self.Player = M_Phonon()
                elif playerName == "Phonon (PySide)":
                    self.Player = M_Phonon_PySide()
                elif playerName == "tkSnack":
                    self.Player = M_tkSnack()
                else:
                    self.Player = M_MPlayer()
            self.stop()
            if _filePath == "":
                _filePath = getMainTable().values[getMainTable().currentRow()]["path"]
            if _filePath == "" and self.file != "":
                _filePath = self.file
            else:
                self.file = _filePath
            _filePath = fu.checkSource(_filePath, "file")
            if _filePath is not None:
                import Taggers

                if Taggers.getTagger(True) is not None:
                    self.musicTags = Musics.readMusicFile(_filePath, False)
                    self.setInfoText(str(("%s - %s (%s)") % (
                        self.musicTags["artist"], self.musicTags["title"], self.musicTags["album"])))
                else:
                    self.musicTags = None
                    self.setInfoText(str("- - -"))
                if _isPlayNow:
                    if self.Player.play(_filePath):
                        self.tbPause.setEnabled(True)
                        self.tbMute.setEnabled(True)
                        self.tbStop.setEnabled(True)
                        self.tbPlay.setEnabled(False)
        except:
            ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:43,代码来源:MusicPlayer.py

示例8: goTo

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
    def goTo(self, _path, _isRemember=True, _isOnlyBrowser=False):
        try:
            _path = fu.checkSource(str(_path))
            if _path is not None:
                if fu.isReadableFileOrDir(_path):
                    if fu.isDir(_path):
                        if _isRemember:
                            self.future = []
                            self.history.append(self.currentDirectory)
                        if len(_path) > 1 and _path[-1] == fu.sep:
                            _path = _path[:-1]
                        self.currentDirectory = str(_path)
                        if isActivePyKDE4:
                            self.dirLister.openUrl(MUrl(self.currentDirectory))
                            self.trvFileManager.setCurrentIndex(self.dirModelForTree.index(_path))
                            self.isGoToFromUrlNavigator = False
                            self.urlNavigator.setUrl(MUrl(self.currentDirectory))
                            self.isGoToFromUrlNavigator = True
                            self.isGoToFromDirOperator = False
                            self.dirOperator.setUrl(MUrl(self.currentDirectory), False)
                            self.isGoToFromDirOperator = True
                        else:
                            self.lstvFileManager.setRootIndex(self.dirModel.index(_path))
                            self.trvFileManager.setCurrentIndex(self.dirModelForTree.index(_path))
                        self.actForward.setEnabled(False)
                        if _isOnlyBrowser is False:
                            self.showInTable()
                        self.actBack.setEnabled(True)
                        if str(self.currentDirectory) == fu.sep:
                            self.actUp.setEnabled(False)
                        else:
                            self.actUp.setEnabled(True)
                    elif fu.isFile(_path):
                        from Details import Details

                        Details(str(_path), uni.getBoolValue("isOpenDetailsInNewWindow"))
        except:
            ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:40,代码来源:FileManager.py

示例9: writeContents

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        startRowNo, rowStep = 0, 1
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), 0, allItemNumber, True)
        for rowNo in range(startRowNo, self.rowCount(), rowStep):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            pathOfParentDirectory = str(
                                self.values[rowNo]["pathOfParentDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            if self.isChangeableItem(rowNo, "sourceCover") or self.isChangeableItem(rowNo, "destinationCover"):
                                sourcePath = self.values[rowNo]["sourceCover"]
                                destinationPath = self.values[rowNo]["destinationCover"]
                                if self.isChangeableItem(rowNo, "sourceCover"):
                                    sourcePath = str(self.item(rowNo, 3).text()).strip()
                                if self.isChangeableItem(rowNo, "destinationCover"):
                                    destinationPath = str(self.item(rowNo, 4).text()).strip()
                                if (str(self.item(rowNo,
                                                  2).text()) != sourcePath or sourcePath != destinationPath or str(
                                    self.item(rowNo, 2).text()) != destinationPath) or (
                                            str(self.item(rowNo, 2).text()) !=
                                            self.values[rowNo]["currentCover"] and (
                                                str(self.item(rowNo, 2).text()) != sourcePath and str(
                                            self.item(rowNo, 2).text()) != destinationPath)):
                                    if str(self.item(rowNo, 3).text()).strip() != "":
                                        sourcePath = fu.getRealPath(sourcePath,
                                                                    self.values[rowNo]["path"])
                                        sourcePath = fu.checkSource(sourcePath, "file")
                                        if sourcePath is not None:
                                            if destinationPath != "":
                                                destinationPath = fu.getRealPath(destinationPath,
                                                                                 self.values[
                                                                                     rowNo]["path"])
                                                if sourcePath != destinationPath:
                                                    destinationPath = fu.moveOrChange(sourcePath, destinationPath)
                                            else:
                                                destinationPath = sourcePath
                                            fu.setIconToDirectory(self.values[rowNo]["path"],
                                                                  destinationPath)
                                            self.changedValueNumber += 1
                                    else:
                                        fu.setIconToDirectory(self.values[rowNo]["path"], "")
                                        self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", pathOfParentDirectory):
                                pathOfParentDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(pathOfParentDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "directory")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), rowNo + 1, allItemNumber,
                              True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if len(oldAndNewPathValues) > 0:
            from Amarok import Operations

            Operations.changePaths(oldAndNewPathValues)
        return True
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:87,代码来源:AmarokCoverTable.py

示例10: __init__

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
    def __init__(self, _filePath, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        MDialog.__init__(self, MApplication.activeWindow())
        self.currenctImageDialogs = []
        _filePath = fu.checkSource(_filePath, "file")
        if _filePath is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.closeCurrenctImageDialogs()
                        dialog.changeFile(_filePath)
                        dialog.activateWindow()
                        dialog.raise_()
                        dialog.player.play(_filePath, dialog.isPlayNow.isChecked())
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.isActiveAddImage = False
                self.infoLabels = {}
                self.infoValues = {}
                self.musicValues = {}
                self.pbtnClose = MPushButton(translate("MusicDetails", "Close"))
                self.pbtnSave = MPushButton(translate("MusicDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"), self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [translate("MusicDetails", "Directory: "),
                               translate("MusicDetails", "File Name: "),
                               translate("MusicDetails", "Artist: "),
                               translate("MusicDetails", "Title: "),
                               translate("MusicDetails", "Album: "),
                               translate("MusicDetails", "Album Artist: "),
                               translate("MusicDetails", "Track: "),
                               translate("MusicDetails", "Year: "),
                               translate("MusicDetails", "Genre: ")]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeFile(_filePath)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.player.play(_filePath, self.isPlayNow.isChecked())
        else:
            Dialogs.showError(translate("MusicDetails", "File Does Not Exist"),
                              str(translate("MusicDetails",
                                            "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
                              ) % Organizer.getLink(str(_filePath)))
            if hasattr(getMainWindow(),
                       "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:65,代码来源:MusicDetails.py

示例11: writeContents

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import checkSource [as 别名]
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     startRowNo, rowStep = 0, 1
     uni.startThreadAction()
     allItemNumber = len(self.values)
     Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), 0, allItemNumber, True)
     for rowNo in range(startRowNo, self.rowCount(), rowStep):
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             try:
                 if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                     if self.isRowHidden(rowNo):
                         fu.removeFileOrDir(self.values[rowNo]["path"])
                         self.changedValueNumber += 1
                     else:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         baseName = str(self.values[rowNo]["baseName"])
                         if (self.isChangeableItem(rowNo, "sourceCover") or
                                 self.isChangeableItem(rowNo, "destinationCover")):
                             sourcePath = self.values[rowNo]["sourceCover"]
                             destinationPath = self.values[rowNo]["destinationCover"]
                             if self.isChangeableItem(rowNo, "sourceCover"):
                                 sourcePath = str(self.item(rowNo, 3).text()).strip()
                             if self.isChangeableItem(rowNo, "destinationCover"):
                                 destinationPath = str(self.item(rowNo, 4).text()).strip()
                             if (str(self.item(rowNo,
                                               2).text()) != sourcePath or sourcePath != destinationPath or str(
                                 self.item(rowNo, 2).text()) != destinationPath) or (
                                         str(self.item(rowNo, 2).text()) !=
                                         self.values[rowNo]["currentCover"] and (
                                             str(self.item(rowNo, 2).text()) != sourcePath and str(
                                         self.item(rowNo, 2).text()) != destinationPath)):
                                 if str(self.item(rowNo, 3).text()).strip() != "":
                                     sourcePath = fu.getRealPath(sourcePath,
                                                                 self.values[rowNo]["path"])
                                     sourcePath = fu.checkSource(sourcePath, "file")
                                     if sourcePath is not None:
                                         if destinationPath != "":
                                             destinationPath = fu.getRealPath(destinationPath,
                                                                              self.values[
                                                                                  rowNo]["path"])
                                             if sourcePath != destinationPath:
                                                 destinationPath = fu.moveOrChange(sourcePath, destinationPath)
                                         else:
                                             destinationPath = sourcePath
                                         fu.setIconToDirectory(self.values[rowNo]["path"],
                                                               destinationPath)
                                         self.changedValueNumber += 1
                                 else:
                                     fu.setIconToDirectory(self.values[rowNo]["path"], "")
                                     self.changedValueNumber += 1
                         if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                             baseNameOfDirectory = str(self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName", baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, baseName)
                         oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                         newFilePath = fu.getRealPath(newFilePath)
                         if oldFilePath != newFilePath:
                             oldAndNewPaths = {}
                             oldAndNewPaths["oldPath"] = oldFilePath
                             oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "directory")
                             if oldFilePath != oldAndNewPaths["newPath"]:
                                 oldAndNewPathValues.append(oldAndNewPaths)
                                 oldDirName = fu.getDirName(oldFilePath)
                                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                     fu.checkEmptyDirectories(oldDirName, True, True,
                                                              uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
             except:
                 ReportBug.ReportBug()
         else:
             allItemNumber = rowNo + 1
         Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), rowNo + 1, allItemNumber,
                           True)
         if isContinueThreadAction is False:
             break
     uni.finishThreadAction()
     if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
         if len(otherFileNames) > 0:
#.........这里部分代码省略.........
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:103,代码来源:CoverTable.py


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