本文整理汇总了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)
示例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)
示例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)