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


Python FileUtils.getDirName方法代码示例

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


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

示例1: getFromAmarok

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
    def getFromAmarok(self):
        try:
            import Amarok

            Dialogs.showState(translate("CoverTable", "Checking For Amarok..."), 0, 1)
            if Amarok.checkAmarok():
                from Amarok import Operations

                directoriesAndValues = Operations.getDirectoriesAndValues()
                Dialogs.showState(translate("CoverTable", "Values Are Being Processed"), 1, 1)
                if directoriesAndValues is not None:
                    for rowNo in range(self.rowCount()):
                        if (getMainWindow().checkHiddenColumn("sourceCover") and
                                getMainWindow().checkHiddenColumn("destinationCover")):
                            if self.isChangeableItem(rowNo, "sourceCover"):
                                directoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    str(self.item(rowNo, 0).text()), str(self.item(rowNo, 1).text()))
                                if directoryPath in directoriesAndValues:
                                    directoryAndValues = directoriesAndValues[directoryPath]
                                    self.item(rowNo, 3).setText(
                                        directoryAndValues["coverPath"][0].replace(directoryPath, "."))
                                    self.item(rowNo, 4).setText("./" + Organizer.getIconName(
                                        directoryAndValues["artist"][0],
                                        directoryAndValues["album"][0],
                                        directoryAndValues["genre"][0],
                                        directoryAndValues["year"][0]))
        except:
            ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:31,代码来源:CoverTable.py

示例2: changeFilePath

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
def changeFilePath(_oldPath, _newPath):
    _oldPath, _newPath = str(_oldPath), str(_newPath)
    withOutDevicePointValues, withOutDeviceValues = [], []
    for devicePoint in getDevices():
        if devicePoint[1] + "/" == _oldPath[:len(devicePoint[1]) + 1]:
            if devicePoint[1] + "/" == _newPath[:len(devicePoint[1]) + 1]:
                withOutDevicePointValues.append({"id": devicePoint[0],
                                                 "oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
                                                 "newPath": Databases.correctForSql(_newPath[len(devicePoint[1]):])
                })
            else:
                withOutDeviceValues.append({"id": devicePoint[0],
                                            "oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
                                            "newPath": Databases.correctForSql(_newPath)
                })
    _oldPath, _newPath = Databases.correctForSql(_oldPath), Databases.correctForSql(_newPath)
    _oldPathUrl, _newPathUrl = Databases.correctForSql(Organizer.quote(_oldPath)), Databases.correctForSql(Organizer.quote(_newPath))
    db = Amarok.checkAndGetDB()
    db.query("UPDATE urls SET rpath='.%s' WHERE rpath='.%s'" % (_newPath, _oldPath))
    for withOutDevice in withOutDeviceValues:
        directoryID = getOrInsertDirectory(fu.getDirName(withOutDevice["newPath"]), "-1")
        db.query("UPDATE urls SET rpath='.%s', directory=%s, deviceid = -1 WHERE deviceid = %s and rpath = '.%s' " % (
            withOutDevice["newPath"], directoryID, withOutDevice["id"], withOutDevice["oldPath"]))
    for withOutDevicePoint in withOutDevicePointValues:
        directoryID = getOrInsertDirectory(fu.getDirName(withOutDevicePoint["newPath"]), withOutDevicePoint["id"])
        db.query("UPDATE urls SET rpath='.%s', directory=%s WHERE deviceid = %s and rpath = '.%s'" % (
            withOutDevicePoint["newPath"], directoryID, withOutDevicePoint["id"], withOutDevicePoint["oldPath"]))
    db.query("UPDATE images SET path='%s' WHERE path='%s'" % (_newPath, _oldPath))
    db.query("UPDATE lyrics SET url='.%s' WHERE url='.%s'" % (_newPath, _oldPath))
    db.query("UPDATE statistics_permanent SET url='file://%s' WHERE url='file://%s'" % (_newPathUrl, _oldPathUrl))
    db.commit()
    return True
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:34,代码来源:Commands.py

示例3: changeFile

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
 def changeFile(self, _filePath, _isNew=False):
     self.fileValues = fu.readTextFile(_filePath, uni.MySettings["fileSystemEncoding"])
     self.setWindowTitle(str(fu.getBaseName(self.fileValues["path"])))
     if self.pnlClearable is not None:
         clearAllChildren(self.pnlClearable, True)
     self.pnlClearable = MWidget()
     self.vblMain.insertWidget(0, self.pnlClearable, 20)
     vblClearable = MVBoxLayout(self.pnlClearable)
     self.infoLabels["path"] = MLabel(self.labels[0])
     self.infoLabels["content"] = MLabel(self.labels[1])
     dirPath = fu.getDirName(self.fileValues["path"])
     baseName = fu.getBaseName(self.fileValues["path"])
     self.infoValues["path"] = MLineEdit(str(fu.joinPath(dirPath, Organizer.emend(baseName, "file"))))
     self.infoValues["content"] = MPlainTextEdit(
         str(Organizer.emend(self.fileValues["content"], "text", False, True)))
     self.infoValues["content"].setLineWrapMode(MPlainTextEdit.NoWrap)
     self.sourceCharSet = MComboBox()
     self.sourceCharSet.addItems(uni.getCharSets())
     self.sourceCharSet.setCurrentIndex(self.sourceCharSet.findText(uni.MySettings["fileSystemEncoding"]))
     MObject.connect(self.sourceCharSet, SIGNAL("currentIndexChanged(int)"), self.sourceCharSetChanged)
     HBOXs = []
     HBOXs.append(MHBoxLayout())
     HBOXs[-1].addWidget(self.infoLabels["path"])
     HBOXs[-1].addWidget(self.infoValues["path"])
     HBOXs[-1].addWidget(self.sourceCharSet)
     for hbox in HBOXs:
         vblClearable.addLayout(hbox)
     vblClearable.addWidget(self.infoLabels["content"])
     vblClearable.addWidget(self.infoValues["content"])
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:31,代码来源:TextDetails.py

示例4: willDownload

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
    def willDownload(self, _request):
        try:
            defaultFileName = str(MFileInfo(str(trStr(_request.url()))).fileName())
            fileDialogTitle = translate("UpdateControl", "You Can Click Cancel To Update Without Saving The Package.")
            if self.isNotInstall:
                fileDialogTitle = translate("UpdateControl", "Save New Version Of Hamsi Manager")
            fileName = Dialogs.getSaveFileName(fileDialogTitle,
                                               fu.joinPath(fu.getDirName(fu.HamsiManagerDirectory), defaultFileName))
            if self.isNotInstall is False or fileName is not None:
                if fileName is None:
                    import random

                    fileName = fu.joinPath(fu.getTempDir(), defaultFileName[:-7] + "-" + str(
                        random.randrange(0, 1000000)) + defaultFileName[-7:])
                self.pbtnDownloadAndInstall.setEnabled(False)
                newRequest = _request
                newRequest.setAttribute(MNetworkRequest.User, trQVariant(fileName))
                networkManager = self.wvWeb.page().networkAccessManager()
                reply = networkManager.get(newRequest)
                self.isFileExist = True
                self.connect(reply, SIGNAL("downloadProgress(qint64,qint64)"), self.downloading)
                self.connect(reply, SIGNAL("finished()"), self.downloaded)
                self.connect(reply, SIGNAL("error(QNetworkReply::NetworkError)"), self.errorOccurred)
        except:
            ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:27,代码来源:UpdateControl.py

示例5: readMusicFile

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
def readMusicFile(_filePath, _isAlertWhenNotAvailable=True):
    _directoryPath = fu.getDirName(_filePath)
    isCanNoncompatible = False
    if fu.isReadableFileOrDir(_filePath):
        tagger = Taggers.getTagger()
        try:
            tagger.loadFile(_filePath)
        except:
            Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                              str(translate("FileUtils/Musics",
                                            "\"%s\" : this file has the incorrect tag so can't read tags.")
                              ) % Organizer.getLink(_filePath))
        if tagger.isAvailableFile() is False:
            isCanNoncompatible = True
        content = {}
        content["path"] = _filePath
        content["baseNameOfDirectory"] = fu.getBaseName(_directoryPath)
        content["baseName"] = fu.getBaseName(_filePath)
        content["artist"] = tagger.getArtist()
        content["title"] = tagger.getTitle()
        content["album"] = tagger.getAlbum()
        content["albumArtist"] = tagger.getAlbumArtist()
        content["trackNum"] = tagger.getTrackNum()
        content["year"] = tagger.getYear()
        content["genre"] = tagger.getGenre()
        content["firstComment"] = tagger.getFirstComment()
        content["firstLyrics"] = tagger.getFirstLyrics()
        content["images"] = tagger.getImages()
        if isCanNoncompatible and _isAlertWhenNotAvailable:
            Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"),
                         translate("FileUtils/Musics",
                                   "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
        return content
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:35,代码来源:Musics.py

示例6: writeMusicFile

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
def writeMusicFile(_oldMusicTagsValues, _newMusicTagsValues, _isImageAction=False, _ImageType=False, _ImagePath=False,
                   _imageDescription=u""):
    if fu.isWritableFileOrDir(_oldMusicTagsValues["path"]):
        baseNameOfDirectory = _oldMusicTagsValues["baseNameOfDirectory"]
        baseName = _oldMusicTagsValues["baseName"]
        tagger = Taggers.getTagger()
        tagger.loadFileForWrite(_oldMusicTagsValues["path"])
        if _isImageAction is False:
            if _newMusicTagsValues["artist"] != _oldMusicTagsValues["artist"]:
                tagger.setArtist(str(_newMusicTagsValues["artist"]))
            if _newMusicTagsValues["title"] != _oldMusicTagsValues["title"]:
                tagger.setTitle(str(_newMusicTagsValues["title"]))
            if _newMusicTagsValues["album"] != _oldMusicTagsValues["album"]:
                tagger.setAlbum(str(_newMusicTagsValues["album"]))
            if _newMusicTagsValues["albumArtist"] != _oldMusicTagsValues["albumArtist"]:
                tagger.setAlbumArtist(str(_newMusicTagsValues["albumArtist"]))
            if _newMusicTagsValues["trackNum"] != _oldMusicTagsValues["trackNum"]:
                tagger.setTrackNum(_newMusicTagsValues["trackNum"])
            if _newMusicTagsValues["year"] != _oldMusicTagsValues["year"]:
                tagger.setDate(str(_newMusicTagsValues["year"]))
            if _newMusicTagsValues["genre"] != _oldMusicTagsValues["genre"]:
                tagger.setGenre(str(_newMusicTagsValues["genre"]))
            if _newMusicTagsValues["firstComment"] != _oldMusicTagsValues["firstComment"]:
                tagger.setFirstComment(str(_newMusicTagsValues["firstComment"]))
            if _newMusicTagsValues["firstLyrics"] != _oldMusicTagsValues["firstLyrics"]:
                tagger.setFirstLyrics(str(_newMusicTagsValues["firstLyrics"]))
            tagger.update()
            if _newMusicTagsValues["baseNameOfDirectory"] != _oldMusicTagsValues["baseNameOfDirectory"]:
                baseNameOfDirectory = str(_newMusicTagsValues["baseNameOfDirectory"])
            if _newMusicTagsValues["baseName"] != _oldMusicTagsValues["baseName"]:
                baseName = str(_newMusicTagsValues["baseName"])
            newFilePath = fu.joinPath(fu.getDirName(fu.getDirName(_oldMusicTagsValues["path"])), baseNameOfDirectory,
                                      baseName)
            if fu.getRealPath(_oldMusicTagsValues["path"]) != fu.getRealPath(newFilePath):
                return fu.moveOrChange(_oldMusicTagsValues["path"], newFilePath,
                                       fu.getObjectType(_oldMusicTagsValues["path"]))
        #Making changes on image files
        else:
            if _ImagePath is False:
                tagger.removeImage(_imageDescription)
            else:
                tagger.addImage(_ImageType, _ImagePath, _imageDescription)
            tagger.update()
            return None
    return _oldMusicTagsValues["path"]
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:47,代码来源:Musics.py

示例7: selectImage

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
 def selectImage(self):
     try:
         imagePath = Dialogs.getOpenFileName(translate("MusicDetails", "Choose Image"),
                                             fu.getDirName(self.musicValues["path"]), str(
                 translate("MusicDetails", "Images")) + " " + uni.imageExtStringOnlyPNGAndJPG, 0)
         if imagePath is not None:
             self.leImagePath.setText(imagePath)
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:11,代码来源:MusicDetails.py

示例8: saveAsImage

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
 def saveAsImage(self):
     try:
         if self.lstwImages.currentRow() != -1:
             imagePath = Dialogs.getSaveFileName(translate("MusicDetails", "Save As"),
                                                 fu.getDirName(self.musicValues["path"]),
                                                 str(translate("MusicDetails", "Images (*.%s)")) % (str(
                                                     self.musicValues["images"][self.lstwImages.currentRow()][
                                                         2]).split("/")[1]), 0)
             if imagePath is not None:
                 sourceFile = fu.joinPath(fu.getTempDir(), "HamsiManager-image-file." +
                                          self.musicValues["images"][self.lstwImages.currentRow()][2].split("/")[1])
                 fu.writeToBinaryFile(sourceFile, self.musicValues["images"][self.lstwImages.currentRow()][3])
                 fu.moveOrChange(sourceFile, imagePath)
     except:
         ReportBug.ReportBug()
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:17,代码来源:MusicDetails.py

示例9: createPage

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
        def createPage(self, _pageNo):
            pnlPage = MWidget()
            HBox = MHBoxLayout()
            pnlPage.setLayout(HBox)
            if _pageNo == 0:
                VBox = MVBoxLayout()
                self.lblAreYouSure = MLabel(translate("Uninstall", "Are you sure you want to uninstall Hamsi Manager?"))
                VBox.addStretch(10)
                VBox.addWidget(self.lblAreYouSure)
                VBox.addStretch(10)
                HBox.addLayout(VBox)
            if _pageNo == 1:
                lblPleaseSelect = MLabel(
                    translate("Uninstall", "Please Select Directory Of Hamsi Manager To Uninstall."))
                UninstallationDirPath = fu.getDirName(
                    str(Settings.getUniversalSetting("HamsiManagerPath", str(fu.HamsiManagerDirectory))))
                self.leUninstallationDirectory = MLineEdit(
                    str(Settings.getUniversalSetting("pathOfInstallationDirectory", str(UninstallationDirPath))))
                self.pbtnSelectUninstallationDirectory = MPushButton(translate("Uninstall", "Browse"))
                self.connect(self.pbtnSelectUninstallationDirectory, SIGNAL("clicked()"),
                             self.selectUninstallationDirectory)
                VBox = MVBoxLayout()
                VBox.addStretch(2)
                VBox.addWidget(lblPleaseSelect)
                HBox1 = MHBoxLayout()
                HBox1.addWidget(self.leUninstallationDirectory)
                HBox1.addWidget(self.pbtnSelectUninstallationDirectory)
                VBox.addLayout(HBox1)
                VBox.addStretch(2)
                HBox.addLayout(VBox)
            elif _pageNo == 2:
                import MyPlugins

                self.lblFinished = MLabel(translate("Uninstall", "Uninstallation Completed."))
                VBox = MVBoxLayout()
                VBox.addStretch(2)
                VBox.addWidget(self.lblFinished)
                VBox.addStretch(2)
                wPlugins = MyPlugins.MyPluginsForSystem(pnlPage, "uninstall")
                VBox.addWidget(wPlugins)
                VBox.addStretch(2)
                HBox.addLayout(VBox)
            return pnlPage
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:45,代码来源:uninstall.py

示例10: writeContents

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        if uni.isActiveAmarok and uni.getBoolValue("isSubFolderTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/SubFolders", "Writing File Informations"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            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, "baseNameOfDirectory", baseNameOfDirectory):
                                baseNameOfDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(str(self.values[rowNo]["path"]).replace(
                                fu.joinPath(str(self.values[rowNo]["baseNameOfDirectory"]),
                                            str(self.values[rowNo]["baseName"])), ""),
                                                      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, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                                    if (uni.isActiveDirectoryCover and
                                            uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                                            uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                                        fu.checkIcon(oldDirName)
                                        fu.checkIcon(fu.getDirName(oldAndNewPaths["newPath"]))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/SubFolders", "Writing File Informations"), rowNo + 1, allItemNumber,
                              True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if (uni.isActiveAmarok and
                uni.getBoolValue("isSubFolderTableValuesChangeInAmarokDB") and
                len(oldAndNewPathValues) > 0):
            import Amarok
            from Amarok import Operations

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

示例11: refreshTable

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
    def refreshTable(self, _path):
        self.values = []
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                directoriesAndValues = Operations.getDirectoriesAndValues(uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if directoriesAndValues is not None:
                        allItemNumber = len(directoriesAndValues)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for dirPath, dirRow in directoriesAndValues.items():
                            isContinueThreadAction = uni.isContinueThreadAction()
                            if isContinueThreadAction:
                                try:
                                    if fu.isReadableFileOrDir(dirPath, False, True) and fu.isReadableFileOrDir(
                                        fu.joinPath(dirPath, ".directory"), False, True):
                                        content = {}
                                        content["path"] = dirPath
                                        content["pathOfParentDirectory"] = fu.getDirName(dirPath)
                                        content["baseName"] = fu.getBaseName(dirPath)
                                        currentCover, isCorrectedFileContent = fu.getIconFromDirectory(dirPath)
                                        if currentCover is None:
                                            currentCover = ""
                                        content["currentCover"] = (currentCover)
                                        content["sourceCover"] = (dirRow["coverPath"][0].replace(dirPath, "."))
                                        content["destinationCover"] = ("./" + Organizer.getIconName(
                                            dirRow["artist"][0],
                                            dirRow["album"][0],
                                            dirRow["genre"][0],
                                            dirRow["year"][0]))
                                        content["flagColor"] = {}
                                        if isCorrectedFileContent is False:
                                            content["flagColor"]["currentCover"] = 255, 163, 163
                                        if fu.isFile(content["sourceCover"]) is False:
                                            content["flagColor"]["sourceCover"] = 255, 163, 163
                                        self.values.append(content)

                                        newPathOfParentDirectory = Organizer.emend(
                                            self.values[rowNo]["pathOfParentDirectory"], "directory")
                                        self.createItem(rowNo, "pathOfParentDirectory", newPathOfParentDirectory,
                                                        self.values[rowNo]["pathOfParentDirectory"])

                                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "directory")
                                        self.createItem(rowNo, "pathOfParentDirectory", newBaseName,
                                                        self.values[rowNo]["baseName"])

                                        newCurrentCover = fu.getShortPath(self.values[rowNo]["currentCover"],
                                                                          self.values[rowNo]["path"])
                                        itemCurrentCover = self.createItem(rowNo, "currentCover", newCurrentCover,
                                                                           newCurrentCover, True)
                                        self.setItemColor(itemCurrentCover, rowNo, 2, "currentCover")

                                        newSourceCover = fu.getShortPath(self.values[rowNo]["sourceCover"],
                                                                         self.values[rowNo]["path"])
                                        itemSourceCover = self.createItem(rowNo, "sourceCover", newSourceCover,
                                                                          fu.getShortPath(
                                                                              self.values[rowNo]["currentCover"],
                                                                              self.values[rowNo]["path"]))
                                        self.setItemColor(itemSourceCover, rowNo, 3, "sourceCover")

                                        newDestinationCover = Organizer.emend(
                                            fu.getShortPath(self.values[rowNo]["destinationCover"],
                                                            self.values[rowNo]["path"]), "file")
                                        itemDestinationCover = self.createItem(rowNo, "destinationCover",
                                                                               newDestinationCover,
                                                                               fu.getShortPath(
                                                                                   self.values[rowNo]["currentCover"],
                                                                                   self.values[rowNo]["path"]))
                                        self.setItemColor(itemDestinationCover, rowNo, 4, "destinationCover")
                                        rowNo += 1
                                    else:
                                        allItemNumber -= 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:93,代码来源:AmarokCoverTable.py

示例12: writeContents

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [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

示例13: refreshTable

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames(
                    uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if musicFileValuesWithNames is not None:
                        allItemNumber = len(musicFileValuesWithNames)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for musicFileRow in musicFileValuesWithNames:
                            isContinueThreadAction = uni.isContinueThreadAction()
                            if isContinueThreadAction:
                                try:
                                    if (fu.isFile(musicFileRow["filePath"]) and
                                            fu.isReadableFileOrDir(musicFileRow["filePath"], False, True)):
                                        details = fu.getDetails(musicFileRow["filePath"])
                                        content = {}
                                        if Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Amarok (Smart)":
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = fu.getBaseName(
                                                fu.getDirName(musicFileRow["filePath"]))
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = musicFileRow["artist"]
                                            content["title"] = musicFileRow["title"]
                                            content["album"] = musicFileRow["album"]
                                            content["albumArtist"] = musicFileRow["albumArtist"]
                                            content["trackNum"] = musicFileRow["trackNumber"]
                                            content["year"] = musicFileRow["year"]
                                            content["genre"] = musicFileRow["genre"]
                                            content["firstComment"] = musicFileRow["comment"]
                                            content["firstLyrics"] = musicFileRow["lyrics"]
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(musicFileRow["filePath"])
                                            except:
                                                if tagger.isSupportInfo:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                            else:
                                                if content["artist"].strip() == "":
                                                    content["artist"] = tagger.getArtist()
                                                if content["title"].strip() == "":
                                                    content["title"] = tagger.getTitle()
                                                if content["album"].strip() == "":
                                                    content["album"] = tagger.getAlbum()
                                                if content["albumArtist"].strip() == "":
                                                    content["albumArtist"] = tagger.getAlbumArtist()
                                                if str(content["trackNum"]).strip() == "":
                                                    content["trackNum"] = tagger.getTrackNum()
                                                if str(content["year"]).strip() == "":
                                                    content["year"] = tagger.getYear()
                                                if content["genre"].strip() == "":
                                                    content["genre"] = tagger.getGenre()
                                                if content["firstComment"].strip() == "":
                                                    content["firstComment"] = tagger.getFirstComment()
                                                if content["firstLyrics"].strip() == "":
                                                    content["firstLyrics"] = tagger.getFirstLyrics()
                                                if tagger.isSupportInfo:
                                                    content["length"] = tagger.getLength()
                                                    content["bitrate"] = tagger.getBitrate()
                                                    content["sampleRate"] = tagger.getSampleRate()
                                                    content["mode"] = tagger.getMode()
                                        elif Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Only Amarok":
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = ""
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = musicFileRow["artist"]
                                            content["title"] = musicFileRow["title"]
                                            content["album"] = musicFileRow["album"]
                                            content["albumArtist"] = musicFileRow["albumArtist"]
                                            content["trackNum"] = musicFileRow["trackNumber"]
                                            content["year"] = musicFileRow["year"]
                                            content["genre"] = musicFileRow["genre"]
                                            content["firstComment"] = musicFileRow["comment"]
                                            content["firstLyrics"] = musicFileRow["lyrics"]
                                            tagger = Taggers.getTagger()
                                            if tagger.isSupportInfo:
                                                try:
                                                    tagger.loadFile(musicFileRow["filePath"])
                                                except:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                                else:
#.........这里部分代码省略.........
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:103,代码来源:AmarokCopyTable.py

示例14: refreshTable

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
    def refreshTable(self, _path):
        self.values = []
        allFilesAndDirectories = fu.readDirectoryWithSubDirectoriesThread(_path,
                                                                          int(uni.MySettings["CoversSubDirectoryDeep"]),
                                                                          "directory",
                                                                          uni.getBoolValue("isShowHiddensInCoverTable"))
        allItemNumber = len(allFilesAndDirectories)
        uni.startThreadAction()
        rowNo = 0
        self.setRowCount(allItemNumber)
        for dirName in allFilesAndDirectories:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(dirName, False, True) and fu.isReadableFileOrDir(
                        fu.joinPath(dirName, ".directory"), False, True):
                        content = {}
                        content["path"] = dirName
                        content["baseNameOfDirectory"] = str(str(fu.getBaseName(_path)) +
                                                             str(fu.getDirName(dirName)).replace(_path, ""))
                        content["baseName"] = fu.getBaseName(dirName)

                        currentCover, isCorrectedFileContent = fu.getIconFromDirectory(dirName)
                        selectedName = None
                        if isCorrectedFileContent and currentCover is not None:
                            selectedName = fu.getBaseName(currentCover)
                        sourceCover = fu.getFirstImageInDirectory(dirName, selectedName, False, False)
                        if currentCover is None:
                            currentCover = ""
                        if sourceCover is None:
                            sourceCover = ""
                        else:
                            sourceCover = fu.joinPath(dirName, sourceCover)
                        content["currentCover"] = (currentCover)
                        content["sourceCover"] = (sourceCover)
                        content["destinationCover"] = (sourceCover)
                        content["isCorrectedFileContent"] = (isCorrectedFileContent)
                        self.values.append(content)

                        newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"],
                                                                 "directory")
                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                        self.values[rowNo]["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "directory")
                        self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])

                        newCurrentCover = str(self.values[rowNo]["currentCover"])
                        newCurrentCover = newCurrentCover.replace(self.values[rowNo]["path"], ".")
                        itemCurrentCover = self.createItem(rowNo, "currentCover", newCurrentCover, newCurrentCover,
                                                           True)
                        if self.values[rowNo]["isCorrectedFileContent"] is False:
                            itemCurrentCover.setBackground(MBrush(MColor(255, 163, 163)))

                        newSourceCover = str(self.values[rowNo]["sourceCover"])
                        newSourceCover = newSourceCover.replace(self.values[rowNo]["path"], ".")
                        oldSourceCover = self.values[rowNo]["currentCover"]
                        oldSourceCover = oldSourceCover.replace(self.values[rowNo]["path"], ".")
                        self.createItem(rowNo, "sourceCover", newSourceCover, oldSourceCover)

                        newDestinationCover = self.values[rowNo]["destinationCover"]
                        newDestinationCover = newDestinationCover.replace(self.values[rowNo]["path"], ".")
                        newDestinationCover = Organizer.emend(newDestinationCover, "file")
                        oldDestinationCover = self.values[rowNo]["currentCover"]
                        oldDestinationCover = oldDestinationCover.replace(self.values[rowNo]["path"], ".")
                        self.createItem(rowNo, "destinationCover", newDestinationCover, oldDestinationCover)
                        rowNo += 1
                    else:
                        allItemNumber -= 1
                except:
                    ReportBug.ReportBug()
                    allItemNumber -= 1
            else:
                allItemNumber = rowNo
            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:81,代码来源:CoverTable.py

示例15: refreshTable

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getDirName [as 别名]
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        musicFileNames = fu.readDirectoryWithSubDirectoriesThread(_path,
                                                                  int(uni.MySettings["subDirectoryDeep"]), "music",
                                                                  uni.getBoolValue(
                                                                      "isShowHiddensInSubFolderMusicTable"))
        isCanNoncompatible = False
        allItemNumber = len(musicFileNames)
        uni.startThreadAction()
        rowNo = 0
        self.setRowCount(allItemNumber)
        for filePath in musicFileNames:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(filePath, False, True):
                        tagger = Taggers.getTagger()
                        try:
                            tagger.loadFile(filePath)
                        except:
                            Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                                              str(translate("FileUtils/Musics",
                                                            "\"%s\" : this file has the incorrect tag so can't read tags.")
                                              ) % Organizer.getLink(filePath))
                        if tagger.isAvailableFile() is False:
                            isCanNoncompatible = True
                        details = fu.getDetails(filePath)
                        content = {}
                        content["path"] = filePath
                        content["baseNameOfDirectory"] = str(
                            str(fu.getBaseName(_path)) + str(fu.getDirName(filePath)).replace(_path, ""))
                        content["baseName"] = fu.getBaseName(filePath)
                        content["artist"] = tagger.getArtist()
                        content["title"] = tagger.getTitle()
                        content["album"] = tagger.getAlbum()
                        content["albumArtist"] = tagger.getAlbumArtist()
                        content["trackNum"] = tagger.getTrackNum()
                        content["year"] = tagger.getYear()
                        content["genre"] = tagger.getGenre()
                        content["firstComment"] = tagger.getFirstComment()
                        content["firstLyrics"] = tagger.getFirstLyrics()
                        if tagger.isSupportInfo:
                            content["length"] = tagger.getLength()
                            content["bitrate"] = tagger.getBitrate()
                            content["sampleRate"] = tagger.getSampleRate()
                            content["mode"] = tagger.getMode()
                        content["size"] = details[stat.ST_SIZE]
                        content["lastAccessed"] = details[stat.ST_ATIME]
                        content["lastModified"] = details[stat.ST_MTIME]
                        content["lastMetadataChanged"] = details[stat.ST_CTIME]
                        self.values.append(content)

                        newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"], "directory")
                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                        self.values[rowNo]["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file")
                        self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])

                        newArtist = Organizer.emend(self.values[rowNo]["artist"])
                        self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"])

                        newTitle = Organizer.emend(self.values[rowNo]["title"])
                        self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"])

                        newAlbum = Organizer.emend(self.values[rowNo]["album"])
                        self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"])

                        newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"])
                        self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"])

                        newTrackNum = str(self.values[rowNo]["trackNum"])
                        self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"])

                        newYear = Organizer.emend(self.values[rowNo]["year"])
                        self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"])

                        newGenre = Organizer.emend(self.values[rowNo]["genre"])
                        self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"])

                        newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"])
                        self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"])

                        newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"])
                        self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"])

                        if tagger.isSupportInfo:
                            self.createItem(rowNo, "length", content["length"])
                            self.createItem(rowNo, "bitrate", content["bitrate"])
                            self.createItem(rowNo, "sampleRate", content["sampleRate"])
                            self.createItem(rowNo, "mode", content["mode"])

                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                        self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))

                        self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))

#.........这里部分代码省略.........
开发者ID:supermurat,项目名称:hamsi-manager,代码行数:103,代码来源:SubFolderMusicTable.py


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