cvyxv
This commit is contained in:
parent
9eb7b66882
commit
191febd794
@ -53,7 +53,7 @@ class MainObject(DatabaseObject):
|
||||
"""
|
||||
|
||||
def __init__(self, _id: str = None, dynamic: bool = False, **kwargs):
|
||||
super().__init__(_id=_id, dynamic=dynamic, **kwargs)
|
||||
DatabaseObject.__init__(self, _id=_id, dynamic=dynamic, **kwargs)
|
||||
|
||||
self.additional_arguments: dict = kwargs
|
||||
|
||||
|
@ -167,6 +167,9 @@ class Song(MainObject, SourceAttribute, MetadataAttribute):
|
||||
album_list: List[Type['Album']] = property(fget=lambda self: self.album_collection.copy())
|
||||
lyrics_list: List[Type[Lyrics]] = property(fget=lambda self: self.lyrics_collection.copy())
|
||||
|
||||
COLLECTION_ATTRIBUTES = ("lyrics_collection", "album_collection", "main_artist_collection", "feature_artist_collection")
|
||||
SIMPLE_ATTRIBUTES = ("title", "isrc", "length", "tracksort", "genre")
|
||||
|
||||
|
||||
"""
|
||||
All objects dependent on Album
|
||||
@ -317,6 +320,10 @@ class Album(MainObject, SourceAttribute, MetadataAttribute):
|
||||
tracklist: List[Song] = property(fget=lambda self: self.song_collection.copy())
|
||||
|
||||
copyright = property(fget=get_copyright)
|
||||
|
||||
COLLECTION_ATTRIBUTES = ("label_collection", "artist_collection", "song_collection")
|
||||
SIMPLE_ATTRIBUTES = ("title", "album_status", "album_type", "language", "date", "barcode", "albumsort")
|
||||
|
||||
|
||||
"""
|
||||
All objects dependent on Artist
|
||||
@ -460,7 +467,7 @@ class Artist(MainObject, SourceAttribute, MetadataAttribute):
|
||||
|
||||
return flat_copy_discography
|
||||
|
||||
album_list: List[Album] = property(fget=lambda self: self.album_collection.copy())
|
||||
album_list: List[Album] = property(fget=lambda self: self.main_album_collection.copy())
|
||||
|
||||
complete_album_list: List[Album] = property(fget=get_discography)
|
||||
discography: List[Album] = property(fget=get_discography)
|
||||
@ -468,6 +475,9 @@ class Artist(MainObject, SourceAttribute, MetadataAttribute):
|
||||
feature_album: Album = property(fget=get_features)
|
||||
song_list: List[Song] = property(fget=get_all_songs)
|
||||
label_list: List[Type['Label']] = property(fget=lambda self: self.label_collection.copy())
|
||||
|
||||
COLLECTION_ATTRIBUTES = ("feature_song_collection", "main_album_collection", "label_collection")
|
||||
SIMPLE_ATTRIBUTES = ("name", "name", "country", "formed_in", "notes", "lyrical_themes", "general_genre")
|
||||
|
||||
|
||||
"""
|
||||
@ -511,3 +521,6 @@ class Label(MainObject, SourceAttribute, MetadataAttribute):
|
||||
@property
|
||||
def current_artist_list(self) -> List[Artist]:
|
||||
self.current_artist_collection.copy()
|
||||
|
||||
COLLECTION_ATTRIBUTES = ("album_collection", "current_artist_collection")
|
||||
SIMPLE_ATTRIBUTES = ("name",)
|
||||
|
@ -126,7 +126,7 @@ class Source(DatabaseObject, MetadataAttribute):
|
||||
homepage = property(fget=lambda self: SourcePages.get_homepage(self.page_enum))
|
||||
|
||||
|
||||
class SourceAttribute:
|
||||
class SourceAttribute(DatabaseObject):
|
||||
"""
|
||||
This is a class that is meant to be inherited from.
|
||||
it adds the source_list attribute to a class
|
||||
@ -187,6 +187,12 @@ class SourceAttribute:
|
||||
and the value is a List with all sources of according page
|
||||
"""
|
||||
return self._source_dict
|
||||
|
||||
def merge(self, other, override: bool = False):
|
||||
super().merge(other, override)
|
||||
|
||||
for source in other.source_list:
|
||||
self.add_source(source=source)
|
||||
|
||||
source_list: List[Source] = property(fget=get_source_list, fset=set_source_list)
|
||||
source_dict: Dict[object, List[Source]] = property(fget=get_source_dict)
|
||||
|
@ -237,17 +237,6 @@ class EncyclopaediaMetallum(Page):
|
||||
except ValueError():
|
||||
pass
|
||||
|
||||
|
||||
album_obj: Album = artist.main_album_collection.get_object_with_source(album_url) or artist.main_album_collection.get_object_with_attribute("title", album_name)
|
||||
|
||||
if album_obj is not None:
|
||||
album_obj.add_source(Source(SourcePages.ENCYCLOPAEDIA_METALLUM, album_url))
|
||||
album_obj.title = album_name
|
||||
album_obj.album_type = album_type
|
||||
if date_obj is not None:
|
||||
album_obj.date = date_obj
|
||||
continue
|
||||
|
||||
artist.main_album_collection.append(Album(
|
||||
id_=album_id,
|
||||
title=album_name,
|
||||
|
61
src/python.py
Normal file
61
src/python.py
Normal file
@ -0,0 +1,61 @@
|
||||
class SuperFoo:
|
||||
ATTRIBUTES: tuple = tuple()
|
||||
|
||||
class Foo(SuperFoo):
|
||||
def __init__(self, bar1, bar2, bar3) -> None:
|
||||
self.bar1 = bar1
|
||||
self.bar2 = bar2
|
||||
self.bar3 = bar3
|
||||
|
||||
ATTRIBUTES: tuple = ("bar1", "bar2", "bar3")
|
||||
|
||||
|
||||
def process(child_instance: SuperFoo):
|
||||
for attribute in child_instance.ATTRIBUTES:
|
||||
print(getattr(child_instance, attribute))
|
||||
|
||||
process(Foo(123, 456, 789))
|
||||
|
||||
"""
|
||||
Hi!
|
||||
|
||||
I got following code *(It is a very simplified and broken down example)*:
|
||||
|
||||
```python
|
||||
class SuperFoo:
|
||||
ATTRIBUTES: tuple = tuple()
|
||||
|
||||
class Foo(SuperFoo):
|
||||
def __init__(self, bar1, bar2, bar3) -> None:
|
||||
self.bar1 = bar1
|
||||
self.bar2 = bar2
|
||||
self.bar3 = bar3
|
||||
|
||||
ATTRIBUTES: tuple = (Foo.bar1, Foo.bar2, Foo.bar3)
|
||||
|
||||
|
||||
def process(child_instance: SuperFoo):
|
||||
for attribute in child_instance.ATTRIBUTES:
|
||||
print(getattr(child_instance, attribute))
|
||||
|
||||
process(Foo(123, 456, 789))
|
||||
```
|
||||
|
||||
the output I expect would be:
|
||||
|
||||
```
|
||||
> 123
|
||||
> 456
|
||||
> 789
|
||||
```
|
||||
|
||||
Obviously this doesn't work, instead the IDE warns me that `Foo` is not defined, and the error which is raised says so as well.
|
||||
|
||||
```
|
||||
ATTRIBUTES: tuple = (Foo.bar1, Foo.bar2, Foo.bar3)
|
||||
NameError: name 'Foo' is not defined
|
||||
```
|
||||
|
||||
While I completely get why this happens, I have no clue how to solve it.
|
||||
Any help would be appreciated.
|
||||
"""
|
Loading…
Reference in New Issue
Block a user