fixed exceptions
This commit is contained in:
@@ -15,7 +15,6 @@ ID3Timestamp = metadata.ID3Timestamp
|
||||
Source = source.Source
|
||||
SourceTypes = source.SourceTypes
|
||||
SourcePages = source.SourcePages
|
||||
SourceAttribute = source.SourceAttribute
|
||||
|
||||
Song = song.Song
|
||||
Artist = song.Artist
|
||||
|
@@ -34,7 +34,8 @@ class Collection:
|
||||
"""
|
||||
self._attribute_to_object_map: Dict[str, Dict[object, DatabaseObject]] = defaultdict(dict)
|
||||
|
||||
self.extend(data, merge_on_conflict=True)
|
||||
if data is not None:
|
||||
self.extend(data, merge_on_conflict=True)
|
||||
|
||||
def sort(self, reverse: bool = False, **kwargs):
|
||||
self._data.sort(reverse=reverse, **kwargs)
|
||||
@@ -51,7 +52,7 @@ class Collection:
|
||||
"""
|
||||
|
||||
# if the element type has been defined in the initializer it checks if the type matches
|
||||
if self.element_type is not None and isinstance(element, self.element_type):
|
||||
if self.element_type is not None and not isinstance(element, self.element_type):
|
||||
raise TypeError(f"{type(element)} is not the set type {self.element_type}")
|
||||
|
||||
for name, value in element.indexing_values:
|
||||
|
@@ -18,7 +18,7 @@ class Lyrics(DatabaseObject):
|
||||
source_list: List[Source] = None,
|
||||
**kwargs
|
||||
) -> None:
|
||||
DatabaseObject.__init__(_id=_id, dynamic=dynamic)
|
||||
DatabaseObject.__init__(self, _id=_id, dynamic=dynamic)
|
||||
|
||||
self.text: FormattedText = text
|
||||
self.language: pycountry.Languages = language
|
||||
|
@@ -20,7 +20,6 @@ from .source import (
|
||||
Source,
|
||||
SourceTypes,
|
||||
SourcePages,
|
||||
SourceAttribute,
|
||||
SourceCollection
|
||||
)
|
||||
from .formatted_text import FormattedText
|
||||
@@ -462,7 +461,7 @@ Label
|
||||
"""
|
||||
|
||||
|
||||
class Label(MainObject, SourceAttribute):
|
||||
class Label(MainObject):
|
||||
COLLECTION_ATTRIBUTES = ("album_collection", "current_artist_collection")
|
||||
SIMPLE_ATTRIBUTES = ("name",)
|
||||
|
||||
|
@@ -47,7 +47,7 @@ class SourcePages(Enum):
|
||||
return homepage_map[attribute]
|
||||
|
||||
|
||||
class Source(DatabaseObject, MetadataAttribute):
|
||||
class Source(DatabaseObject):
|
||||
"""
|
||||
create somehow like that
|
||||
```python
|
||||
@@ -95,14 +95,14 @@ class Source(DatabaseObject, MetadataAttribute):
|
||||
if url.startswith("https://twitter"):
|
||||
return cls(SourcePages.TWITTER, url)
|
||||
|
||||
def get_song_metadata(self) -> MetadataAttribute.Metadata:
|
||||
return MetadataAttribute.Metadata({
|
||||
def get_song_metadata(self) -> Metadata:
|
||||
return Metadata({
|
||||
Mapping.FILE_WEBPAGE_URL: [self.url],
|
||||
Mapping.SOURCE_WEBPAGE_URL: [self.homepage]
|
||||
})
|
||||
|
||||
def get_artist_metadata(self) -> MetadataAttribute.Metadata:
|
||||
return MetadataAttribute.Metadata({
|
||||
def get_artist_metadata(self) -> Metadata:
|
||||
return Metadata({
|
||||
Mapping.ARTIST_WEBPAGE_URL: [self.url]
|
||||
})
|
||||
|
||||
@@ -136,10 +136,11 @@ class Source(DatabaseObject, MetadataAttribute):
|
||||
|
||||
class SourceCollection(Collection):
|
||||
def __init__(self, source_list: List[Source]):
|
||||
super().__init__(data=source_list, element_type=Source)
|
||||
|
||||
self._page_to_source_list: Dict[SourcePages, List[Source]] = defaultdict(list)
|
||||
|
||||
super().__init__(data=source_list, element_type=Source)
|
||||
|
||||
|
||||
def map_element(self, source: Source):
|
||||
super().map_element(source)
|
||||
|
||||
|
@@ -2,7 +2,7 @@ from typing import (
|
||||
List
|
||||
)
|
||||
|
||||
from ..database import (
|
||||
from ..objects import (
|
||||
Song,
|
||||
Source,
|
||||
Album,
|
||||
|
Reference in New Issue
Block a user