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)
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)
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)
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)
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)
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)