feat: structure changes to artwork and collection objects
This commit is contained in:
parent
05ee09e25f
commit
d51e3a56fb
@ -19,7 +19,8 @@ class ArtworkVariant(TypedDict):
|
|||||||
|
|
||||||
|
|
||||||
class Artwork:
|
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.parent_artworks: Set[Artwork] = parent_artworks or set()
|
||||||
|
|
||||||
self._variant_mapping: Dict[str, ArtworkVariant] = {}
|
self._variant_mapping: Dict[str, ArtworkVariant] = {}
|
||||||
|
@ -19,19 +19,18 @@ class AppendHookArguments:
|
|||||||
The best explanation is with an examples:
|
The best explanation is with an examples:
|
||||||
|
|
||||||
```
|
```
|
||||||
# this is the action that triggers the append hook
|
album = Album()
|
||||||
album = Album()
|
song = Song()
|
||||||
song = Song()
|
album.song_collection.append(song)
|
||||||
album.song_collection.append(song)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
In this case, the append hook is triggered with the following arguments:
|
In this case, the append hook is triggered with the following arguments:
|
||||||
```
|
```
|
||||||
AppendHookArguments(
|
AppendHookArguments(
|
||||||
collection=album.song_collection,
|
collection=album.song_collection,
|
||||||
new_object=song,
|
new_object=song,
|
||||||
collection_root_objects=[album]
|
collection_root_objects=[album]
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ class Collection(Generic[T]):
|
|||||||
sync_on_append: Dict[str, Collection] = None,
|
sync_on_append: Dict[str, Collection] = None,
|
||||||
append_object_to_attribute: Dict[str, T] = None,
|
append_object_to_attribute: Dict[str, T] = None,
|
||||||
extend_object_to_attribute: Dict[str, Collection] = None,
|
extend_object_to_attribute: Dict[str, Collection] = None,
|
||||||
append_callbacks: List[Callable[[AppendHookArguments], None]] = None,
|
append_callbacks: Set[Callable[[AppendHookArguments], None]] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self._collection_for: dict = dict()
|
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.sync_on_append: Dict[str, Collection] = sync_on_append or {}
|
||||||
self.pull_from: List[Collection] = []
|
self.pull_from: List[Collection] = []
|
||||||
self.push_to: 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
|
# This is to cleanly unmap previously mapped items by their id
|
||||||
self._indexed_from_id: Dict[int, Dict[str, Any]] = defaultdict(dict)
|
self._indexed_from_id: Dict[int, Dict[str, Any]] = defaultdict(dict)
|
||||||
|
Loading…
Reference in New Issue
Block a user