MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / readlines

Method readlines

gridfs/synchronous/grid_file.py:1551–1568  ·  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

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:

Callers 5

test_readlinesMethod · 0.95
get_total_timeFunction · 0.45
process_filesFunction · 0.45
process_fileFunction · 0.45

Calls 2

openMethod · 0.95
_read_size_or_lineMethod · 0.95

Tested by 2

test_readlinesMethod · 0.76
process_fileFunction · 0.36