worked on metal archives

This commit is contained in:
Hellow2
2023-03-02 16:23:02 +01:00
parent 4c041ef7ff
commit 3fba46428d
8 changed files with 54 additions and 36 deletions

View File

@@ -64,6 +64,15 @@ class Collection:
if type(element) is not self.element_type and self.element_type is not None:
raise TypeError(f"{type(element)} is not the set type {self.element_type}")
for source_url in element.source_url_map:
if source_url in self._by_url:
return
for attr in self.map_attributes:
value = element.__getattribute__(attr)
if value in self._by_attribute[attr]:
return
self._data.append(element)
self.map_element(element)
@@ -72,7 +81,7 @@ class Collection:
yield element
def __str__(self) -> str:
return "\n".join([f"{str(j).zfill(2)}: {i}" for j, i in enumerate(self._data)])
return "\n".join([f"{str(j).zfill(2)}: {i.__repr__()}" for j, i in enumerate(self._data)])
def __len__(self) -> int:
return len(self._data)

View File

@@ -14,7 +14,7 @@ class DatabaseObject:
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}")
LOGGER.info(f"id for {type(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

View File

@@ -58,7 +58,6 @@ class Source(DatabaseObject, MetadataAttribute):
def __init__(self, page_enum, url: str, id_: str = None, type_enum=None) -> None:
DatabaseObject.__init__(self, id_=id_)
SongAttribute.__init__(self)
self.type_enum = type_enum
self.page_enum = page_enum