(self, sources: Iterable[Dict])
| 310 | return record, None |
| 311 | |
| 312 | def screen_sources(self, sources: Iterable[Dict]) -> Tuple[List[Dict], List[Dict], Dict]: |
| 313 | source_list = list(sources) |
| 314 | accepted: List[Dict] = [] |
| 315 | rejected: List[Dict] = [] |
| 316 | reason_counter: Counter = Counter() |
| 317 | |
| 318 | for source in source_list: |
| 319 | valid, invalid = self.screen_source(source) |
| 320 | if valid: |
| 321 | accepted.append(valid) |
| 322 | elif invalid: |
| 323 | rejected.append(invalid) |
| 324 | reason_counter.update(invalid.get("reasons", [])) |
| 325 | |
| 326 | stats = { |
| 327 | "input": len(source_list), |
| 328 | "accepted": len(accepted), |
| 329 | "rejected": len(rejected), |
| 330 | "reasons": dict(reason_counter.most_common()), |
| 331 | } |
| 332 | return accepted, rejected, stats |
no test coverage detected