本文整理汇总了Python中pyasm.biz.File.get_extension方法的典型用法代码示例。如果您正苦于以下问题:Python File.get_extension方法的具体用法?Python File.get_extension怎么用?Python File.get_extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.File
的用法示例。
在下文中一共展示了File.get_extension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_parser_by_path
# 需要导入模块: from pyasm.biz import File [as 别名]
# 或者: from pyasm.biz.File import get_extension [as 别名]
def get_parser_by_path(cls, path):
ext = File.get_extension(path)
parser_str = None
if ext in File.VIDEO_EXT:
if HAS_FFMPEG:
parser_str = "FFMPEG"
else:
parser_str = "PIL"
else:
if HAS_IMAGEMAGICK:
parser_str = "ImageMagick"
elif HAS_PIL:
parser_str = "PIL"
elif HAS_EXIF:
parser_str = "EXIF"
elif HAS_FFMPEG:
parser_str = "FFMPEG"
return cls.get_parser(parser_str, path)
示例2: execute
# 需要导入模块: from pyasm.biz import File [as 别名]
# 或者: from pyasm.biz.File import get_extension [as 别名]
def execute(my):
# extra data from the file check-in
commit = my.kwargs.get("commit")
if commit in ['false', False]:
commit = False
else:
commit = True
# metadata can only be associated with a single file on the
# snapshot.
files = my.kwargs.get("files")
file_objects = my.kwargs.get("file_objects")
snapshot_metadata = None
parser_type = my.kwargs.get("parser")
for i, file in enumerate(files):
path = file
ext = File.get_extension(path)
file_object = file_objects[i]
if not os.path.exists(path):
continue
elif parser_type != "auto" and parser_type != "true":
pass
elif ext in File.VIDEO_EXT:
parser_type = "FFMPEG"
elif ext in File.NORMAL_EXT:
continue
else:
if HAS_IMAGEMAGICK:
parser_type = "ImageMagick"
else:
parser_type = "PIL"
metadata = {}
if parser_type == "FFMPEG":
parser = FFProbeMetadataParser(path=path)
metadata = parser.get_metadata()
elif parser_type == "ImageMagick":
parser = ImageMagickMetadataParser(path=path)
metadata = parser.get_metadata()
else:
parser = PILMetadataParser(path=path)
metadata = parser.get_metadata()
metadata['__parser__'] = parser_type
"""
if os.path.exists(path):
try:
parser = ImageMagickMetadataParser(path=path)
metadata = parser.get_metadata()
except:
try:
#parser = PILMetadataParser(path=path)
parser = FFProbeMetadataParser(path=path)
metadata = parser.get_metadata()
except:
metadata = {}
else:
metadata = {}
"""
# add some default metadata
basename = os.path.basename(path)
path = file_object.get_lib_path()
dirname = os.path.dirname(path)
parts = basename.split(".")
ext = parts[-1]
try:
# occasionally, people will put frame numbers as the last
# part
ext = int(ext)
ext = parts[-2]
except:
pass
metadata['Ext'] = ext
metadata['Basename'] = basename
metadata['Dirname'] = dirname
if metadata and not file_object.get_value("metadata"):
file_object.add_metadata(metadata, replace=True)
searchable = my.get_searchable(metadata)
file_object.set_value("metadata_search", searchable)
file_object.commit()
if i == 0:
snapshot = my.kwargs.get("snapshot")
snapshot.add_metadata(metadata, replace=True)
if commit:
snapshot.commit()