Read one line or up to `size` bytes from the file. :param size: the maximum number of bytes to read
(self, size: int = -1)
| 1549 | return self._read_size_or_line(size=size, line=True) |
| 1550 | |
| 1551 | def readlines(self, size: int = -1) -> list[bytes]: |
| 1552 | """Read one line or up to `size` bytes from the file. |
| 1553 | |
| 1554 | :param size: the maximum number of bytes to read |
| 1555 | """ |
| 1556 | self.open() |
| 1557 | lines = [] |
| 1558 | remainder = int(self.length) - self._position |
| 1559 | bytes_read = 0 |
| 1560 | while remainder > 0: |
| 1561 | line = self._read_size_or_line(line=True) |
| 1562 | bytes_read += len(line) |
| 1563 | lines.append(line) |
| 1564 | remainder = int(self.length) - self._position |
| 1565 | if 0 < size < bytes_read: |
| 1566 | break |
| 1567 | |
| 1568 | return lines |
| 1569 | |
| 1570 | def open(self) -> None: |
| 1571 | if not self._file: |