本文整理汇总了Python中FileUtils.getBaseName方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.getBaseName方法的具体用法?Python FileUtils.getBaseName怎么用?Python FileUtils.getBaseName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.getBaseName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: changeFile
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [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"])
示例2: readMusicFile
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [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
示例3: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [as 别名]
def refreshTable(self, _path):
self.values = []
fileAndDirectoryNames = fu.readDirectory(_path, "fileAndDirectory",
uni.getBoolValue("isShowHiddensInFolderTable"))
allItemNumber = len(fileAndDirectoryNames)
uni.startThreadAction()
baseNameOfDirectory = fu.getBaseName(_path)
rowNo = 0
self.setRowCount(allItemNumber)
for baseName in fileAndDirectoryNames:
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True):
details = fu.getExtendedDetails(fu.joinPath(_path, baseName))
content = {}
content["path"] = fu.joinPath(_path, baseName)
content["baseNameOfDirectory"] = baseNameOfDirectory
content["baseName"] = 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"], fu.getObjectType(self.values[rowNo]["path"]))
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
示例4: getColorSchemesAndPath
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [as 别名]
def getColorSchemesAndPath():
from Core import Settings
colorSchemes, colorSchemePaths = [], []
colorSchemes.append("Default")
colorSchemePaths.append("")
if isActivePyKDE4:
from PyKDE4.kdecore import KStandardDirs, KGlobal
schemeFiles = KGlobal.dirs().findAllResources("data", "color-schemes/*.colors", KStandardDirs.NoDuplicates)
for scheme in schemeFiles:
sets = Settings.getSettings(scheme)
colorSchemes.append(trStr(sets.value("Name", fu.getBaseName(scheme))))
colorSchemePaths.append(scheme)
return colorSchemes, colorSchemePaths
示例5: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [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
示例6: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [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:
#.........这里部分代码省略.........
示例7: install
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [as 别名]
def install(self):
try:
MApplication.processEvents()
self.installationDirectory = str(self.leInstallationDirectory.text())
if len(self.installationDirectory) > 0:
if self.installationDirectory[-1] == fu.sep:
self.installationDirectory = self.installationDirectory[:-1]
if self.installationDirectory == fu.HamsiManagerDirectory:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path is Hamsi Manager source directory.<br>Please choose a valid installation path."))
elif fu.isFile(self.installationDirectory) is False:
isMakeInstall = True
if fu.isDir(self.installationDirectory) is False:
self.lblActions.setText(translate("Install", "Creating Installation Folder..."))
fu.makeDirs(self.installationDirectory)
elif len(fu.listDir(self.installationDirectory)) > 0:
currenctAnswer = Dialogs.askSpecial(
translate("Install", "The Installation Path You Selected Is Not Empty."),
translate("Install",
"If the path you selected is an \"Hamsi Manager\" installation path, <b>I recommend you to delete the older files.</b><br>Do you want me to clear the installation path/folder for you?<br><b>Note: </b> Your personal settings are <b>never deleted</b>."),
translate("Install", "Yes (Recommended)"),
translate("Install", "No (Overwrite)"),
translate("Install", "Cancel"))
if currenctAnswer == translate("Install", "Yes (Recommended)"):
self.lblActions.setText(translate("Install", "Clearing Installation Path..."))
try:fu.removeFileOrDir(self.installationDirectory)
except:pass
fu.makeDirs(self.installationDirectory)
isMakeInstall = True
elif currenctAnswer == translate("Install", "No (Overwrite)"):
isMakeInstall = True
else:
isMakeInstall = False
if isMakeInstall:
Settings.setUniversalSetting("pathOfInstallationDirectory", self.installationDirectory)
directoriesAndFiles = fu.readDirectoryWithSubDirectories(fu.HamsiManagerDirectory)
self.prgbState.setRange(0, len(directoriesAndFiles))
self.lblActions.setText(translate("Install", "Copying Files And Folders..."))
installFileName = Execute.findExecutableBaseName("HamsiManagerInstaller")
for fileNo, fileName in enumerate(directoriesAndFiles):
MApplication.processEvents()
newFileName = self.installationDirectory + fileName.replace(fu.HamsiManagerDirectory,"")
if fu.isDir(fileName) and fileName.find(".svn") == -1:
try: fu.makeDirs(newFileName)
except: pass
elif (fu.isFile(fileName) and fu.getBaseName(fileName) != "install.py" and
fu.getBaseName(fileName) != installFileName and fileName.find(".svn") == -1):
try:
fu.copyFileOrDir(fileName, newFileName)
except:
fileContent = fu.readFromBinaryFile(fileName)
fu.writeToBinaryFile(newFileName, fileContent)
self.prgbState.setValue(fileNo + 1)
self.pageNo += 1
MyConfigure.installKDE4Languages()
else:
self.pageNo -= 1
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
self.pageChanged(True)
except:
from Core import ReportBug
ReportBug.ReportBug()
示例8: changeFile
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [as 别名]
def changeFile(self, _filePath, _readFrom="tag"):
self.musicFile = _filePath
self.musicValues = None
self.isPlayNow = MToolButton()
self.isPlayNow.setToolTip(translate("MusicDetails", "Play Suddenly Music When Open"))
self.isPlayNow.setText(translate("MusicDetails", "Play When Open"))
self.isPlayNow.setCheckable(True)
self.isPlayNow.setChecked(uni.getBoolValue("isPlayNow"))
self.isGetFromAmarok = MToolButton()
self.isGetFromAmarok.setToolTip(translate("MusicDetails", "Get Values From Amarok"))
self.isGetFromAmarok.setText(translate("MusicDetails", "Get From Amarok"))
self.isGetFromAmarok.setCheckable(True)
if _readFrom.count("Amarok") > 0:
import Amarok
uni.startThreadAction()
Dialogs.showState(translate("MusicDetails", "Getting Values From Amarok"), 0, 1)
if Amarok.checkAmarok():
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
from Amarok import Operations
musicFileRows = Operations.getAllMusicFileValuesWithNames("filename:\"" + _filePath + "\"")
Dialogs.showState(translate("MusicDetails", "Values Are Being Processed"), 1, 1)
if len(musicFileRows)>0:
musicFileRow = musicFileRows[0]
content = {}
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"]
content["images"] = []
if _readFrom == "Amarok (Smart)":
tagger = Taggers.getTagger()
try:
tagger.loadFile(musicFileRow["filePath"])
except:
pass
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()
content["images"] = tagger.getImages()
self.isGetFromAmarok.setChecked(True)
self.musicValues = content
else:
Dialogs.show(translate("MusicDetails", "Not Exist In Amarok"),
translate("MusicDetails", "This music file not exist in Amarok DB."))
uni.finishThreadAction()
if self.musicValues is None:
self.isGetFromAmarok.setChecked(False)
self.musicValues = Musics.readMusicFile(self.musicFile)
self.setWindowTitle(str(fu.getBaseName(self.musicFile)))
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.player = MusicPlayer.MusicPlayer(self, "dialog", _filePath)
self.infoLabels["baseNameOfDirectory"] = MLabel(self.labels[0])
self.infoLabels["baseName"] = MLabel(self.labels[1])
self.infoLabels["artist"] = MLabel(self.labels[2])
self.infoLabels["title"] = MLabel(self.labels[3])
self.infoLabels["album"] = MLabel(self.labels[4])
self.infoLabels["albumArtist"] = MLabel(self.labels[5])
self.infoLabels["trackNum"] = MLabel(self.labels[6])
self.infoLabels["year"] = MLabel(self.labels[7])
self.infoLabels["genre"] = MLabel(self.labels[8])
self.infoValues["baseNameOfDirectory"] = MLineEdit(
str(Organizer.emend(self.musicValues["baseNameOfDirectory"], "directory", False)))
self.infoValues["baseName"] = MLineEdit(str(Organizer.emend(self.musicValues["baseName"], "file")))
self.infoValues["artist"] = MLineEdit(str(Organizer.emend(self.musicValues["artist"])))
self.infoValues["title"] = MLineEdit(str(Organizer.emend(self.musicValues["title"])))
self.infoValues["album"] = MLineEdit(str(Organizer.emend(self.musicValues["album"])))
self.infoValues["albumArtist"] = MLineEdit(str(Organizer.emend(self.musicValues["albumArtist"])))
self.infoValues["trackNum"] = MLineEdit(str(Organizer.emend(self.musicValues["trackNum"])))
#.........这里部分代码省略.........
示例9: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [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"]))
#.........这里部分代码省略.........
示例10: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getBaseName [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