本文整理汇总了Python中FileUtils.getIconFromDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.getIconFromDirectory方法的具体用法?Python FileUtils.getIconFromDirectory怎么用?Python FileUtils.getIconFromDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.getIconFromDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getIconFromDirectory [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
示例2: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getIconFromDirectory [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