From d51e3a56fb64dfa7366e1c89237d133307a59d6a Mon Sep 17 00:00:00 2001 From: Kur01234 Date: Tue, 4 Jun 2024 11:04:00 +0200 Subject: [PATCH] feat: structure changes to artwork and collection objects --- music_kraken/objects/artwork.py | 3 ++- music_kraken/objects/collection.py | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/music_kraken/objects/artwork.py b/music_kraken/objects/artwork.py index 4421f05..1ff9edc 100644 --- a/music_kraken/objects/artwork.py +++ b/music_kraken/objects/artwork.py @@ -19,7 +19,8 @@ class ArtworkVariant(TypedDict): class Artwork: - def __init__(self, *variants: List[ArtworkVariant], parent_artworks: Set[Artwork] = None) -> None: + def __init__(self, *variants: List[ArtworkVariant], parent_artworks: Set[Artwork] = None, crop_images: bool = True) -> None: + self.crop_images: bool = crop_images self.parent_artworks: Set[Artwork] = parent_artworks or set() self._variant_mapping: Dict[str, ArtworkVariant] = {} diff --git a/music_kraken/objects/collection.py b/music_kraken/objects/collection.py index 0296c70..687b069 100644 --- a/music_kraken/objects/collection.py +++ b/music_kraken/objects/collection.py @@ -19,19 +19,18 @@ class AppendHookArguments: The best explanation is with an examples: ``` - # this is the action that triggers the append hook - album = Album() - song = Song() - album.song_collection.append(song) + album = Album() + song = Song() + album.song_collection.append(song) ``` In this case, the append hook is triggered with the following arguments: ``` - AppendHookArguments( - collection=album.song_collection, - new_object=song, - collection_root_objects=[album] - ) + AppendHookArguments( + collection=album.song_collection, + new_object=song, + collection_root_objects=[album] + ) ``` """ @@ -55,7 +54,7 @@ class Collection(Generic[T]): sync_on_append: Dict[str, Collection] = None, append_object_to_attribute: Dict[str, T] = None, extend_object_to_attribute: Dict[str, Collection] = None, - append_callbacks: List[Callable[[AppendHookArguments], None]] = None, + append_callbacks: Set[Callable[[AppendHookArguments], None]] = None, ) -> None: self._collection_for: dict = dict() @@ -70,7 +69,7 @@ class Collection(Generic[T]): self.sync_on_append: Dict[str, Collection] = sync_on_append or {} self.pull_from: List[Collection] = [] self.push_to: List[Collection] = [] - self.append_callbacks: List[Callable[[AppendHookArguments], None]] = append_callbacks or [] + self.append_callbacks: Set[Callable[[AppendHookArguments], None]] = append_callbacks or set() # This is to cleanly unmap previously mapped items by their id self._indexed_from_id: Dict[int, Dict[str, Any]] = defaultdict(dict)