本文整理汇总了Python中FileUtils.getMimeType方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.getMimeType方法的具体用法?Python FileUtils.getMimeType怎么用?Python FileUtils.getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.getMimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getMimeType [as 别名]
def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
try:
if uni.getBoolValue("isForceOpenWithDefaultApplication"):
_path = fu.checkSource(_filePath)
Execute.openWith([_path])
else:
_path = fu.checkSource(_filePath, "file", False)
if _path is not None:
isOpened = False
mtype = fu.getMimeType(_path)
if mtype[0] is not None:
if mtype[0].split("/")[0] == "text":
TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
elif mtype[0].split("/")[0] == "audio":
if Taggers.getTagger(True) is not None:
MusicDetails.MusicDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
elif mtype[0].split("/")[0] == "image":
ImageDetails.ImageDetails(_path, "file", _isOpenDetailsOnNewWindow)
isOpened = True
elif fu.isBinary(_path) is False:
TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
else:
if fu.isBinary(_path) is False:
TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
isOpened = True
if isOpened is False:
if uni.getBoolValue("isOpenWithDefaultApplication"):
Execute.openWith([_path])
else:
Dialogs.showError(translate("Details", "File Is Not Supported"),
str(translate("Details",
"\"%s\" couldn't opened. This file is not supported.")) % Organizer.getLink(
str(_path)))
elif fu.isDir(_filePath):
if uni.getBoolValue("isOpenWithDefaultApplication"):
Execute.openWith([_filePath])
else:
Dialogs.showError(translate("Details", "Directories Is Not Supported"),
str(translate("Details",
"\"%s\" couldn't opened. Directories is not supported to show details.")) % Organizer.getLink(
str(_filePath)))
else:
Dialogs.showError(translate("Details", "File Is Not Exist"),
str(translate("Details",
"\"%s\" couldn't opened. This file is not exist.")) % Organizer.getLink(
str(_filePath)))
except:
answer = Dialogs.askSpecial(translate("Details", "File Couldn't Opened"),
str(translate("Details",
"\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us.")) % Organizer.getLink(
str(_filePath)),
translate("QuickMake", "Report This Bug"), translate("QuickMake", "OK"), None)
if answer == translate("QuickMake", "Report This Bug"):
ReportBug.ReportBug()
示例2: addImage
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getMimeType [as 别名]
def addImage(self, _imageType, _imagePath, _description):
self.isSave = True
imageData = fu.readFromBinaryFile(_imagePath)
mimeType = fu.getMimeType(_imagePath)[0]
self.tags.add(id3.APIC(encoding=3, mime=mimeType, type=int(_imageType),
desc=uni.trUnicode(_description), data=imageData))
示例3: addImage
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import getMimeType [as 别名]
def addImage(self, _imageType, _imagePath, _description):
self.isSave = True
imageData = fu.readFromBinaryFile(_imagePath)
mimeType = fu.getMimeType(_imagePath)[0]
self.tag.images.set(int(_imageType), imageData, mimeType, uni.trUnicode(_description))