2023-02-25 21:16:32 +00:00
|
|
|
from typing import Optional
|
2022-12-01 12:15:30 +00:00
|
|
|
import uuid
|
|
|
|
|
2023-03-02 06:59:53 +00:00
|
|
|
from ..utils.shared import (
|
2023-02-25 21:16:32 +00:00
|
|
|
SONG_LOGGER as LOGGER
|
2022-12-01 12:15:30 +00:00
|
|
|
)
|
|
|
|
|
2022-12-06 22:44:42 +00:00
|
|
|
|
2022-12-01 12:15:30 +00:00
|
|
|
class DatabaseObject:
|
2023-02-25 21:16:32 +00:00
|
|
|
def __init__(self, _id: str = None, dynamic: bool = False, **kwargs) -> None:
|
|
|
|
if _id is None and not dynamic:
|
|
|
|
"""
|
|
|
|
generates a random UUID
|
|
|
|
https://docs.python.org/3/library/uuid.html
|
|
|
|
"""
|
|
|
|
_id = str(uuid.uuid4())
|
|
|
|
LOGGER.info(f"id for {self.__name__} isn't set. Setting to {_id}")
|
|
|
|
|
|
|
|
# The id can only be None, if the object is dynamic (self.dynamic = True)
|
|
|
|
self.id: Optional[str] = _id
|
2023-02-10 12:52:18 +00:00
|
|
|
|
2022-12-12 18:30:18 +00:00
|
|
|
self.dynamic = dynamic
|
|
|
|
|
|
|
|
|
2023-02-25 21:16:32 +00:00
|
|
|
class MainObject(DatabaseObject):
|
|
|
|
"""
|
|
|
|
This is the parent class for all "main" data objects:
|
|
|
|
- Song
|
|
|
|
- Album
|
|
|
|
- Artist
|
|
|
|
- Label
|
2022-12-01 12:15:30 +00:00
|
|
|
|
2023-02-25 21:16:32 +00:00
|
|
|
It has all the functionality of the "DatabaseObject" (it inherits from said class)
|
|
|
|
but also some added functions as well.
|
|
|
|
"""
|
|
|
|
def __init__(self, _id: str = None, dynamic: bool = False, **kwargs):
|
|
|
|
super().__init__(_id=_id, dynamic=dynamic, **kwargs)
|
2022-12-01 12:15:30 +00:00
|
|
|
|
2023-02-25 21:16:32 +00:00
|
|
|
self.additional_arguments: dict = kwargs
|
2022-12-06 13:45:18 +00:00
|
|
|
|
2023-02-09 08:40:57 +00:00
|
|
|
def get_options(self) -> list:
|
|
|
|
return []
|
|
|
|
|
|
|
|
def get_option_string(self) -> str:
|
|
|
|
return ""
|
|
|
|
|
2023-02-10 12:52:18 +00:00
|
|
|
options = property(fget=get_options)
|
|
|
|
options_str = property(fget=get_option_string)
|