improvements

This commit is contained in:
Hellow 2023-08-30 21:14:03 +02:00
parent 4bce29d288
commit 80c4117629
3 changed files with 11 additions and 11 deletions

View File

@ -1,10 +1,12 @@
from typing import Tuple, Type, Dict, List, Set from typing import Tuple, Type, Dict, Set
from .results import SearchResults from .results import SearchResults
from ..objects import DatabaseObject, Source from ..objects import DatabaseObject, Source
from ..utils.enums.source import SourcePages from ..utils.enums.source import SourcePages
from ..utils.support_classes import Query, DownloadResult from ..utils.support_classes import Query, DownloadResult
from ..utils.exception.download import UrlNotFoundException from ..utils.exception.download import UrlNotFoundException
from ..pages import Page, EncyclopaediaMetallum, Musify, YouTube, YoutubeMusic, INDEPENDENT_DB_OBJECTS from ..pages import Page, EncyclopaediaMetallum, Musify, YouTube, YoutubeMusic, INDEPENDENT_DB_OBJECTS
DEBUGGING_PAGE = YoutubeMusic DEBUGGING_PAGE = YoutubeMusic

View File

@ -1,4 +1,4 @@
from typing import List, Iterable, Dict, TypeVar, Generic from typing import List, Iterable, Dict, TypeVar, Generic, Iterator
from collections import defaultdict from collections import defaultdict
from dataclasses import dataclass from dataclasses import dataclass
@ -125,7 +125,7 @@ class Collection(Generic[T]):
for element in element_list: for element in element_list:
self.append(element, merge_on_conflict=merge_on_conflict, merge_into_existing=merge_into_existing) self.append(element, merge_on_conflict=merge_on_conflict, merge_into_existing=merge_into_existing)
def __iter__(self): def __iter__(self) -> Iterator[T]:
for element in self.shallow_list: for element in self.shallow_list:
yield element yield element
@ -135,7 +135,7 @@ class Collection(Generic[T]):
def __len__(self) -> int: def __len__(self) -> int:
return len(self._data) return len(self._data)
def __getitem__(self, key): def __getitem__(self, key) -> T:
if type(key) != int: if type(key) != int:
return ValueError("key needs to be an integer") return ValueError("key needs to be an integer")

View File

@ -18,7 +18,8 @@ from .parents import MainObject, DatabaseObject
from .source import Source, SourceCollection from .source import Source, SourceCollection
from .target import Target from .target import Target
from ..utils.string_processing import unify from ..utils.string_processing import unify
from ..utils.shared import SORT_BY_ALBUM_TYPE, SORT_BY_DATE
from ..utils import settings
""" """
All Objects dependent All Objects dependent
@ -473,10 +474,7 @@ class Artist(MainObject):
i mean do as you want but there is no strict rule about em so good luck i mean do as you want but there is no strict rule about em so good luck
""" """
self.notes: FormattedText = notes or FormattedText() self.notes: FormattedText = notes or FormattedText()
"""
TODO
implement in db
"""
self.lyrical_themes: List[str] = lyrical_themes or [] self.lyrical_themes: List[str] = lyrical_themes or []
self.general_genre = general_genre self.general_genre = general_genre
@ -515,7 +513,7 @@ class Artist(MainObject):
AlbumType.STUDIO_ALBUM: 0, AlbumType.STUDIO_ALBUM: 0,
AlbumType.EP: 0, AlbumType.EP: 0,
AlbumType.SINGLE: 1 AlbumType.SINGLE: 1
}) if SORT_BY_ALBUM_TYPE else defaultdict(lambda: 0) }) if settings["sort_album_by_type"] else defaultdict(lambda: 0)
sections = defaultdict(list) sections = defaultdict(list)
@ -528,7 +526,7 @@ class Artist(MainObject):
# album is just a value used in loops # album is just a value used in loops
nonlocal album nonlocal album
if SORT_BY_DATE: if settings["sort_by_date"]:
_section.sort(key=lambda _album: _album.date, reverse=True) _section.sort(key=lambda _album: _album.date, reverse=True)
new_last_albumsort = last_albumsort new_last_albumsort = last_albumsort