def refreshTable(self, _path): self.values = [] allFilesAndDirectories = fu.readDirectoryWithSubDirectoriesThread(_path, int(uni.MySettings["subDirectoryDeep"]), "file", uni.getBoolValue( "isShowHiddensInSubFolderTable")) allItemNumber = len(allFilesAndDirectories) uni.startThreadAction() rowNo = 0 self.setRowCount(allItemNumber) for baseName in allFilesAndDirectories: isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if fu.isReadableFileOrDir(baseName, False, True): details = fu.getExtendedDetails(fu.joinPath(_path, baseName)) content = {} content["path"] = baseName content["baseNameOfDirectory"] = str( str(fu.getBaseName(_path)) + str(fu.getDirName(baseName)).replace(_path, "")) content["baseName"] = fu.getBaseName(baseName) content.update(details) self.values.append(content) newBaseNameOfDirectory = Organizer.emend(content["baseNameOfDirectory"], "directory") self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory, content["baseNameOfDirectory"]) newBaseName = Organizer.emend(content["baseName"], "file") self.createItem(rowNo, "baseName", newBaseName, content["baseName"]) self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"])) self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"])) self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"])) self.createItem(rowNo, "lastMetadataChanged", Organizer.getCorrectedTime(content["lastMetadataChanged"])) if not uni.isWindows: self.createItem(rowNo, "accessRights", content["accessRights"]) self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"]) self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"]) self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"]) 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
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
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
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"])) self.createItem(rowNo, "lastMetadataChanged", Organizer.getCorrectedTime(content["lastMetadataChanged"])) 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 if isCanNoncompatible: 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."))
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"])) self.createItem( rowNo, "lastMetadataChanged", Organizer.getCorrectedTime( content["lastMetadataChanged"])) 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 if isCanNoncompatible: 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." ))