Add a result to the collection.
(self, result: Result)
| 193 | ) |
| 194 | |
| 195 | def add(self, result: Result): |
| 196 | """Add a result to the collection.""" |
| 197 | if result.primary_key in self.results: |
| 198 | raise ValueError( |
| 199 | "An entry for {result.primary_key} does already " |
| 200 | "exist in this collection. Did you try to add the " |
| 201 | "same result twice?" |
| 202 | ) |
| 203 | if len(self) > 0: |
| 204 | if result.primary_key_names != self.primary_key_names: |
| 205 | raise ValueError("Incompatible result format.") |
| 206 | self.results[result.primary_key] = result |
| 207 | |
| 208 | @classmethod |
| 209 | def fromdicts(cls, data: Iterable[dict]): |
no outgoing calls