This commit is contained in:
parent
a7711761f9
commit
d9105fb55a
@ -4,9 +4,6 @@ from music_kraken.objects import Song, Album, Artist, Collection
|
||||
if __name__ == "__main__":
|
||||
song_1 = Song(
|
||||
title="song",
|
||||
main_artist_list=[Artist(
|
||||
name="main_artist"
|
||||
)],
|
||||
feature_artist_list=[Artist(
|
||||
name="main_artist"
|
||||
)]
|
||||
|
@ -166,41 +166,30 @@ class Collection(Generic[T]):
|
||||
|
||||
object_trace(f"Appending {other.option_string} to {self}")
|
||||
|
||||
push_to: Optional[Tuple[Collection, T]] = None
|
||||
for c in self.push_to:
|
||||
r = c._find_object(other)
|
||||
if r is not None:
|
||||
push_to_collection = (c, r)
|
||||
output("found push to", found, other, self, color=BColors.RED, sep="\t")
|
||||
break
|
||||
output("found push to", r, other, self, color=BColors.RED, sep="\t")
|
||||
return c.append(other, **kwargs)
|
||||
|
||||
|
||||
pull_from: Optional[Tuple[Collection, T]] = None
|
||||
for c in self.pull_from:
|
||||
r = c._find_object(other)
|
||||
if r is not None:
|
||||
pull_from_collection = (c, r)
|
||||
output("found pull from", found, other, self, color=BColors.RED, sep="\t")
|
||||
output("found pull from", r, other, self, color=BColors.RED, sep="\t")
|
||||
other.merge(r, **kwargs)
|
||||
c.remove(r, **kwargs)
|
||||
break
|
||||
|
||||
if pull_from is not None:
|
||||
pull_from[0].remove(pull_from[1])
|
||||
|
||||
existing_object = self._find_object(other, no_push_to=kwargs.get("no_push_to", False))
|
||||
|
||||
if existing_object is None:
|
||||
if push_to is None:
|
||||
self._append_new_object(other, **kwargs)
|
||||
else:
|
||||
push_to[0]._merge_into_contained_object(push_to[1], other, **kwargs)
|
||||
|
||||
if pull_from is not None:
|
||||
self._merge_into_contained_object(other if push_to is None else push_to[1], pull_from[1], **kwargs)
|
||||
self._append_new_object(other, **kwargs)
|
||||
else:
|
||||
self._merge_into_contained_object(existing_object, other, **kwargs)
|
||||
if pull_from is not None:
|
||||
self._merge_into_contained_object(existing_object, pull_from[1], **kwargs)
|
||||
existing_object.merge(other, **kwargs)
|
||||
|
||||
def remove(self, *other_list: List[T], silent: bool = False):
|
||||
def remove(self, *other_list: List[T], silent: bool = False, **kwargs):
|
||||
for other in other_list:
|
||||
existing: Optional[T] = self._indexed_values["id"].get(other.id, None)
|
||||
if existing is None:
|
||||
@ -208,11 +197,13 @@ class Collection(Generic[T]):
|
||||
raise ValueError(f"Object {other} not found in {self}")
|
||||
return other
|
||||
|
||||
"""
|
||||
for collection_attribute, generator in self.extend_object_to_attribute.items():
|
||||
other.__getattribute__(collection_attribute).remove(*generator, silent=silent, **kwargs)
|
||||
|
||||
for attribute, new_object in self.append_object_to_attribute.items():
|
||||
other.__getattribute__(attribute).remove(new_object, silent=silent, **kwargs)
|
||||
"""
|
||||
|
||||
self._data.remove(existing)
|
||||
self._unmap_element(existing)
|
||||
|
@ -15,7 +15,7 @@ __stage__ = os.getenv("STAGE", "prod")
|
||||
DEBUG = (__stage__ == "dev") and True
|
||||
DEBUG_LOGGING = DEBUG and False
|
||||
DEBUG_TRACE = DEBUG and True
|
||||
DEBUG_OBJECT_TRACE = DEBUG and True
|
||||
DEBUG_OBJECT_TRACE = DEBUG and False
|
||||
DEBUG_OBJECT_TRACE_CALLSTACK = DEBUG_OBJECT_TRACE and False
|
||||
DEBUG_YOUTUBE_INITIALIZING = DEBUG and False
|
||||
DEBUG_PAGES = DEBUG and False
|
||||
|
Loading…
Reference in New Issue
Block a user