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


Python MetaData.intersection方法代码示例

本文整理汇总了Python中audiotools.MetaData.intersection方法的典型用法代码示例。如果您正苦于以下问题:Python MetaData.intersection方法的具体用法?Python MetaData.intersection怎么用?Python MetaData.intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在audiotools.MetaData的用法示例。


在下文中一共展示了MetaData.intersection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: intersection

# 需要导入模块: from audiotools import MetaData [as 别名]
# 或者: from audiotools.MetaData import intersection [as 别名]
    def intersection(self, metadata):
        """given a MetaData-compatible object,
        returns a new MetaData object which contains
        all the matching fields and images of this object and 'metadata'
        """

        def comment_present(comment):
            if u"=" in comment:
                key, value = comment.split(u"=", 1)
                try:
                    for other_value in metadata[key]:
                        if value == other_value:
                            return True
                    else:
                        return False
                except KeyError:
                    return False
            else:
                for other_comment in metadata.comment_strings:
                    if comment == other_comment:
                        return True
                else:
                    return False

        if isinstance(metadata, VorbisComment):
            return self.__class__([comment
                                   for comment in self.comment_strings
                                   if comment_present(comment)],
                                  self.vendor_string)
        else:
            return MetaData.intersection(self, metadata)
开发者ID:KristoforMaynard,项目名称:python-audio-tools,代码行数:33,代码来源:vorbiscomment.py

示例2: intersection

# 需要导入模块: from audiotools import MetaData [as 别名]
# 或者: from audiotools.MetaData import intersection [as 别名]
    def intersection(self, metadata):
        """given a MetaData-compatible object,
        returns a new MetaData object which contains
        all the matching fields and images of this object and 'metadata'
        """

        if type(metadata) is ID3v1Comment:
            return ID3v1Comment(
                genre=(self.__genre__ if
                       self.__genre__ == metadata.__genre__ else 0),
                **{arg: getattr(self, field)
                   for arg, field in ID3v1Comment.ID3v1_FIELDS.items()
                   if getattr(self, field) == getattr(metadata, field)})
        else:
            return MetaData.intersection(self, metadata)
开发者ID:KristoforMaynard,项目名称:python-audio-tools,代码行数:17,代码来源:id3v1.py

示例3: intersection

# 需要导入模块: from audiotools import MetaData [as 别名]
# 或者: from audiotools.MetaData import intersection [as 别名]
    def intersection(self, metadata):
        """given a MetaData-compatible object,
        returns a new MetaData object which contains
        all the matching fields and images of this object and 'metadata'
        """

        if type(metadata) is ApeTag:
            matching_keys = {key for key in
                             set(self.keys()) & set(metadata.keys())
                             if self[key] == metadata[key]}

            return ApeTag(
                [tag.copy() for tag in self.tags
                 if tag.key in matching_keys],
                contains_header=self.contains_header or
                                metadata.contains_header,
                contains_footer=self.contains_footer or
                                metadata.contains_footer)
        else:
            return MetaData.intersection(self, metadata)
开发者ID:brigittebigi,项目名称:sppas,代码行数:22,代码来源:ape.py


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