Read one line or up to `size` bytes from the file. :param size: the maximum number of bytes to read
(self, size: int = -1)
| 1561 | return await self._read_size_or_line(size=size, line=True) |
| 1562 | |
| 1563 | async def readlines(self, size: int = -1) -> list[bytes]: |
| 1564 | """Read one line or up to `size` bytes from the file. |
| 1565 | |
| 1566 | :param size: the maximum number of bytes to read |
| 1567 | """ |
| 1568 | await self.open() |
| 1569 | lines = [] |
| 1570 | remainder = int(self.length) - self._position |
| 1571 | bytes_read = 0 |
| 1572 | while remainder > 0: |
| 1573 | line = await self._read_size_or_line(line=True) |
| 1574 | bytes_read += len(line) |
| 1575 | lines.append(line) |
| 1576 | remainder = int(self.length) - self._position |
| 1577 | if 0 < size < bytes_read: |
| 1578 | break |
| 1579 | |
| 1580 | return lines |
| 1581 | |
| 1582 | async def open(self) -> None: |
| 1583 | if not self._file: |