当前位置: 首页>>代码示例>>Python>>正文


Python File.get_extension方法代码示例

本文整理汇总了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)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:22,代码来源:metadata.py

示例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()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:102,代码来源:metadata.py


注:本文中的pyasm.biz.File.get_extension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。