implemented
DatabaseObject.indexing_values for each data objects
This commit is contained in:
parent
b53548e321
commit
38e7620fbd
@ -1,17 +1,15 @@
|
|||||||
from typing import List, Iterable, Dict, DefaultDict
|
from typing import List, Iterable, Dict
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from .source import SourceAttribute
|
|
||||||
from .parents import DatabaseObject
|
from .parents import DatabaseObject
|
||||||
from ..utils import string_processing
|
|
||||||
|
|
||||||
|
|
||||||
class Collection:
|
class Collection:
|
||||||
"""
|
"""
|
||||||
This an class for the iterables
|
This a class for the iterables
|
||||||
like tracklist or discography
|
like tracklist or discography
|
||||||
"""
|
"""
|
||||||
_data: List[SourceAttribute]
|
_data: List[DatabaseObject]
|
||||||
|
|
||||||
_by_url: dict
|
_by_url: dict
|
||||||
_by_attribute: dict
|
_by_attribute: dict
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from collections import defaultdict
|
||||||
from typing import Optional, Dict, Type, Tuple, List
|
from typing import Optional, Dict, Type, Tuple, List
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -23,6 +24,23 @@ class DatabaseObject:
|
|||||||
self.id: Optional[str] = _id
|
self.id: Optional[str] = _id
|
||||||
|
|
||||||
self.dynamic = dynamic
|
self.dynamic = dynamic
|
||||||
|
|
||||||
|
def __eq__(self, other) -> bool:
|
||||||
|
if not isinstance(other, type(self)):
|
||||||
|
return False
|
||||||
|
|
||||||
|
temp_attribute_map: Dict[str, set] = defaultdict(set)
|
||||||
|
|
||||||
|
# building map with sets
|
||||||
|
for name, value in self.indexing_values:
|
||||||
|
temp_attribute_map[name].add(value)
|
||||||
|
|
||||||
|
# check against the attributes of the other object
|
||||||
|
for name, other_value in other.indexing_values:
|
||||||
|
if other_value in temp_attribute_map[name]:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def indexing_values(self) -> List[Tuple[str, object]]:
|
def indexing_values(self) -> List[Tuple[str, object]]:
|
||||||
|
Loading…
Reference in New Issue
Block a user