mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Add method to collect RequestIter into TotalList
This commit is contained in:
@@ -2,6 +2,8 @@ import abc
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from . import helpers
|
||||
|
||||
|
||||
# TODO There are two types of iterators for requests.
|
||||
# One has a limit of items to retrieve, and the
|
||||
@@ -95,6 +97,17 @@ class RequestIter(abc.ABC):
|
||||
|
||||
return self.__aiter__()
|
||||
|
||||
async def collect(self):
|
||||
"""
|
||||
Create a `self` iterator and collect it into a `TotalList`
|
||||
(a normal list with a `.total` attribute).
|
||||
"""
|
||||
result = helpers.TotalList()
|
||||
async for message in self:
|
||||
result.append(message)
|
||||
|
||||
return result
|
||||
|
||||
@abc.abstractmethod
|
||||
async def _load_next_chunk(self):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user