mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-16 04:33:59 +00:00
imagelist._add_images() -> Metadata.add_images()
This commit is contained in:
@@ -229,16 +229,14 @@ class MetadataItem(Item):
|
||||
Args:
|
||||
added_sources: List of child objects (`Track` or `File`) which's metadata images should be added to current object
|
||||
"""
|
||||
from picard.util.imagelist import _add_images
|
||||
|
||||
state = self._get_imagelist_state()
|
||||
(added_new_images, added_orig_images) = state.get_metadata_images(added_sources)
|
||||
changed = False
|
||||
|
||||
if state.update_new_metadata:
|
||||
changed |= _add_images(self.metadata, added_new_images)
|
||||
changed |= self.metadata.add_images(added_new_images)
|
||||
if state.update_orig_metadata:
|
||||
changed |= _add_images(self.orig_metadata, added_orig_images)
|
||||
changed |= self.orig_metadata.add_images(added_orig_images)
|
||||
|
||||
return changed
|
||||
|
||||
|
||||
@@ -586,6 +586,18 @@ class Metadata(MutableMapping):
|
||||
def __str__(self):
|
||||
return ("store: %r\ndeleted: %r\nimages: %r\nlength: %r" % (self._store, self.deleted_tags, [str(img) for img in self.images], self.length))
|
||||
|
||||
def add_images(self, added_images):
|
||||
if not added_images:
|
||||
return False
|
||||
|
||||
current_images = set(self.images)
|
||||
if added_images.isdisjoint(current_images):
|
||||
self.images = ImageList(current_images.union(added_images))
|
||||
self.has_common_images = False
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class MultiMetadataProxy:
|
||||
"""
|
||||
|
||||
@@ -149,19 +149,6 @@ class ImageListState:
|
||||
self.first_orig_obj = False
|
||||
|
||||
|
||||
def _add_images(metadata, added_images):
|
||||
if not added_images:
|
||||
return False
|
||||
|
||||
current_images = set(metadata.images)
|
||||
if added_images.isdisjoint(current_images):
|
||||
metadata.images = ImageList(current_images.union(added_images))
|
||||
metadata.has_common_images = False
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def _remove_images(metadata, sources, removed_images):
|
||||
"""Removes `removed_images` from metadata `images`, but only if they are not included in `sources`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user