MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / readlines

Method readlines

gridfs/asynchronous/grid_file.py:1563–1580  ·  view source on GitHub ↗

Read one line or up to `size` bytes from the file. :param size: the maximum number of bytes to read

(self, size: int = -1)

Source from the content-addressed store, hash-verified

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:

Callers 1

test_readlinesMethod · 0.95

Calls 2

openMethod · 0.95
_read_size_or_lineMethod · 0.95

Tested by 1

test_readlinesMethod · 0.76