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

Method read

gridfs/synchronous/grid_file.py:1673–1687  ·  view source on GitHub ↗

Read at most `size` bytes from the file (less if there isn't enough data). The bytes are returned as an instance of :class:`bytes` If `size` is negative or omitted all data is read. :param size: the number of bytes to read .. versionchanged:: 3.8

(self, size: int = -1)

Source from the content-addressed store, hash-verified

1671 return b"".join(data)
1672
1673 def read(self, size: int = -1) -> bytes:
1674 """Read at most `size` bytes from the file (less if there
1675 isn't enough data).
1676
1677 The bytes are returned as an instance of :class:`bytes`
1678 If `size` is negative or omitted all data is read.
1679
1680 :param size: the number of bytes to read
1681
1682 .. versionchanged:: 3.8
1683 This method now only checks for extra chunks after reading the
1684 entire file. Previously, this method would check for extra chunks
1685 on every call.
1686 """
1687 return self._read_size_or_line(size=size)
1688
1689 def tell(self) -> int:
1690 """Return the current position of this file."""

Callers 15

test_basicMethod · 0.95
test_write_file_likeMethod · 0.95
test_closedMethod · 0.95
test_multi_chunk_fileMethod · 0.95
helperMethod · 0.95
test_seekMethod · 0.95
test_tellMethod · 0.95
test_multiple_readsMethod · 0.95
test_readlineMethod · 0.95
test_readlinesMethod · 0.95

Calls 1

_read_size_or_lineMethod · 0.95

Tested by 15

test_basicMethod · 0.76
test_write_file_likeMethod · 0.76
test_closedMethod · 0.76
test_multi_chunk_fileMethod · 0.76
helperMethod · 0.76
test_seekMethod · 0.76
test_tellMethod · 0.76
test_multiple_readsMethod · 0.76
test_readlineMethod · 0.76
test_readlinesMethod · 0.76