feat: default implementation for options that should be sufficient
This commit is contained in:
parent
a451a97e1c
commit
1ad62df0ab
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -16,6 +16,7 @@
|
|||||||
},
|
},
|
||||||
"python.formatting.provider": "none",
|
"python.formatting.provider": "none",
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"albumsort",
|
||||||
"APIC",
|
"APIC",
|
||||||
"Bandcamp",
|
"Bandcamp",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
@ -9,7 +9,7 @@ from pathlib import Path
|
|||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from .metadata import Metadata
|
from .metadata import Metadata
|
||||||
from ..utils import get_unix_time, object_trace
|
from ..utils import get_unix_time, object_trace, generate_id
|
||||||
from ..utils.config import logging_settings, main_settings
|
from ..utils.config import logging_settings, main_settings
|
||||||
from ..utils.shared import HIGHEST_ID
|
from ..utils.shared import HIGHEST_ID
|
||||||
from ..utils.hacking import MetaClass
|
from ..utils.hacking import MetaClass
|
||||||
@ -29,6 +29,10 @@ class InnerData:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
_refers_to_instances: set = None
|
_refers_to_instances: set = None
|
||||||
|
"""
|
||||||
|
Attribute versions keep track, of if the attribute has been changed.
|
||||||
|
"""
|
||||||
|
_attribute_versions: Dict[str, int] = None
|
||||||
|
|
||||||
def __init__(self, object_type, **kwargs):
|
def __init__(self, object_type, **kwargs):
|
||||||
self._refers_to_instances = set()
|
self._refers_to_instances = set()
|
||||||
@ -84,8 +88,6 @@ class OuterProxy:
|
|||||||
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
|
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
|
||||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
|
UPWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
|
||||||
|
|
||||||
TITEL = "id"
|
|
||||||
|
|
||||||
def __init__(self, _id: int = None, dynamic: bool = False, **kwargs):
|
def __init__(self, _id: int = None, dynamic: bool = False, **kwargs):
|
||||||
_automatic_id: bool = False
|
_automatic_id: bool = False
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ class OuterProxy:
|
|||||||
generates a random integer id
|
generates a random integer id
|
||||||
the range is defined in the config
|
the range is defined in the config
|
||||||
"""
|
"""
|
||||||
_id = random.randint(0, HIGHEST_ID)
|
_id = generate_id()
|
||||||
_automatic_id = True
|
_automatic_id = True
|
||||||
|
|
||||||
kwargs["automatic_id"] = _automatic_id
|
kwargs["automatic_id"] = _automatic_id
|
||||||
@ -235,7 +237,17 @@ class OuterProxy:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def options(self) -> List[P]:
|
def options(self) -> List[P]:
|
||||||
return [self]
|
r = []
|
||||||
|
|
||||||
|
for collection_string_attribute in self.UPWARDS_COLLECTION_STRING_ATTRIBUTES:
|
||||||
|
r.extend(self.__getattribute__(collection_string_attribute))
|
||||||
|
|
||||||
|
r.append(self)
|
||||||
|
|
||||||
|
for collection_string_attribute in self.DOWNWARDS_COLLECTION_STRING_ATTRIBUTES:
|
||||||
|
r.extend(self.__getattribute__(collection_string_attribute))
|
||||||
|
|
||||||
|
return r
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def indexing_values(self) -> List[Tuple[str, object]]:
|
def indexing_values(self) -> List[Tuple[str, object]]:
|
||||||
@ -267,6 +279,7 @@ class OuterProxy:
|
|||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
TITEL = "id"
|
||||||
@property
|
@property
|
||||||
def title_string(self) -> str:
|
def title_string(self) -> str:
|
||||||
return str(self.__getattribute__(self.TITEL))
|
return str(self.__getattribute__(self.TITEL))
|
||||||
|
@ -117,7 +117,7 @@ class Song(Base):
|
|||||||
|
|
||||||
Base.__init__(**locals())
|
Base.__init__(**locals())
|
||||||
|
|
||||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("album_collection", "main_artist_collection", "feature_artist_collection")
|
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("main_artist_collection", "feature_artist_collection", "album_collection")
|
||||||
TITEL = "title"
|
TITEL = "title"
|
||||||
|
|
||||||
def __init_collections__(self) -> None:
|
def __init_collections__(self) -> None:
|
||||||
@ -269,7 +269,7 @@ class Album(Base):
|
|||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("song_collection",)
|
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("song_collection",)
|
||||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("artist_collection", "label_collection")
|
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection", "artist_collection")
|
||||||
|
|
||||||
def __init_collections__(self):
|
def __init_collections__(self):
|
||||||
self.song_collection.append_object_to_attribute = {
|
self.song_collection.append_object_to_attribute = {
|
||||||
|
@ -71,6 +71,12 @@ def object_trace(obj):
|
|||||||
misc functions
|
misc functions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_auto_increment = 0
|
||||||
|
def generate_id() -> int:
|
||||||
|
global _auto_increment
|
||||||
|
_auto_increment += 1
|
||||||
|
return _auto_increment
|
||||||
|
|
||||||
def get_current_millis() -> int:
|
def get_current_millis() -> int:
|
||||||
dt = datetime.now()
|
dt = datetime.now()
|
||||||
return int(dt.microsecond / 1_000)
|
return int(dt.microsecond / 1_000)
|
||||||
|
Loading…
Reference in New Issue
Block a user