| 52 | ) |
| 53 | |
| 54 | def _bulk_generator( |
| 55 | self, redditors: list[Redditor | str], subreddits: list[Subreddit | str] |
| 56 | ) -> Iterator[models.ModNote]: |
| 57 | subreddits_iter = iter(subreddits) |
| 58 | redditors_iter = iter(redditors) |
| 59 | while True: |
| 60 | subreddits_chunk = list(islice(subreddits_iter, 500)) |
| 61 | users_chunk = list(islice(redditors_iter, 500)) |
| 62 | if not any([subreddits_chunk, users_chunk]): |
| 63 | break |
| 64 | params: dict[str, str | int] = { |
| 65 | "subreddits": ",".join(map(str, subreddits_chunk)), |
| 66 | "users": ",".join(map(str, users_chunk)), |
| 67 | } |
| 68 | response = self._reddit.get(API_PATH["mod_notes_bulk"], params=params) |
| 69 | for note_dict in response["mod_notes"]: |
| 70 | yield cast("models.ModNote", self._reddit._objector.objectify(data=note_dict)) |
| 71 | |
| 72 | def _ensure_attribute(self, error_message: str, **attributes: Any) -> Any: |
| 73 | attribute, value_ = attributes.popitem() |