We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ac0caf commit c0e9492Copy full SHA for c0e9492
1 file changed
src/store/data_store.py
@@ -0,0 +1,26 @@
1
+from abc import ABC
2
+from typing import Any, List
3
+
4
5
+class Store(ABC):
6
+ def __init__(
7
+ self,
8
+ payload_identifier: str,
9
+ ):
10
+ self.payload_identifier = payload_identifier
11
+ self.data = []
12
13
+ def insert(self, data: Any):
14
+ self.data.append(data)
15
16
+ def find(self, identifier: str) -> Any:
17
+ for entry in self.data:
18
+ if getattr(entry, self.payload_identifier) == identifier:
19
+ return entry
20
+ return None
21
22
+ def find_all(self, identifier: List[str]) -> List[Any]:
23
+ return [entry for entry in self.data if getattr(entry, self.payload_identifier) in identifier]
24
25
+ def get_all(self) -> List[Any]:
26
+ return self.data if self.data else []
0 commit comments