fixed the merging of collections

This commit is contained in:
Hellow 2023-12-29 16:15:54 +01:00
parent aa139a7f73
commit 4cbbee26e4
6 changed files with 17 additions and 14 deletions

View File

@ -47,4 +47,5 @@ if __name__ == "__main__":
]
music_kraken.cli.download(genre="test", command_list=bandcamp_test, process_metadata_anyway=True)
music_kraken.cli.download(genre="test", command_list=bandcamp_test, process_metadata_anyway=True)
_ = "debug"

View File

@ -295,9 +295,6 @@ class Downloader:
page: Type[Page]
music_object: DatabaseObject
if self.current_results is not None:
self.current_results.delete_details(index)
try:
page, music_object = self.current_results.get_music_object_by_index(index)
except KeyError:
@ -307,7 +304,9 @@ class Downloader:
return
self.pages.fetch_details(music_object)
print(music_object)
print(music_object.options)
self.set_current_options(PageResults(page, music_object.options))
self.print_current_options()

View File

@ -29,11 +29,7 @@ class Results:
def get_music_object_by_index(self, index: int) -> Tuple[Type[Page], DatabaseObject]:
# if this throws a key error, either the formatted generator needs to be iterated, or the option doesn't exist.
return self._page_by_index[index], self._by_index[index]
def delete_details(self, exclude_index: int):
for index, music_object in self._by_index.items():
if index == exclude_index:
continue
class SearchResults(Results):
def __init__(

View File

@ -107,8 +107,6 @@ class Collection(Generic[T]):
if self._contained_in_self(__object):
return [self]
print(len(self.children), id(self), ";".join(str(id(i)) for i in self.children))
print()
for collection in self.children:
results.extend(collection._contained_in_sub(__object, break_at_first=break_at_first))
@ -186,11 +184,11 @@ class Collection(Generic[T]):
return len(self._contained_in_sub(__object)) > 0
def _append(self, __object: T, from_map: bool = False):
# print(self, __object)
self._map_element(__object, from_map=from_map)
self._data.append(__object)
def append(self, __object: Optional[T], already_is_parent: bool = False, from_map: bool = False):
print(__object)
if __object is None or __object.id in self._contains_ids:
return
@ -264,3 +262,6 @@ class Collection(Generic[T]):
def __iter__(self) -> Iterator[T]:
for element in self._data:
yield element
def __merge__(self, __other: Collection, override: bool = False):
self.extend(__other.shallow_list)

View File

@ -47,7 +47,7 @@ class InnerData:
# if the object of value implemented __merge__, it merges
existing = self.__getattribute__(key)
if hasattr(type(existing), "__merge__"):
existing.merge_into_self(value, override)
existing.__merge__(value, override)
continue
# override the existing value if requested

View File

@ -446,6 +446,12 @@ class Artist(Base):
"current_artist_collection": self
}
@property
def options(self) -> List[P]:
options = [self, *self.main_album_collection.shallow_list, *self.feature_album]
print(options)
return options
def update_albumsort(self):
"""
This updates the albumsort attributes, of the albums in