MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / read

Method read

tensorflow/python/lib/io/file_io.py:110–128  ·  view source on GitHub ↗

Returns the contents of a file as a string. Starts reading from current position in file. Args: n: Read 'n' bytes if n != -1. If n = -1, reads to end of file. Returns: 'n' bytes of the file (or whole file) in bytes mode or 'n' bytes of the string if in string (regula

(self, n=-1)

Source from the content-addressed store, hash-verified

108 compat.as_bytes(file_content), self._writable_file)
109
110 def read(self, n=-1):
111 """Returns the contents of a file as a string.
112
113 Starts reading from current position in file.
114
115 Args:
116 n: Read 'n' bytes if n != -1. If n = -1, reads to end of file.
117
118 Returns:
119 'n' bytes of the file (or whole file) in bytes mode or 'n' bytes of the
120 string if in string (regular) mode.
121 """
122 self._preread_check()
123 if n == -1:
124 length = self.size() - self.tell()
125 else:
126 length = n
127 return self._prepare_value(
128 pywrap_tensorflow.ReadFromStream(self._read_buf, length))
129
130 @deprecation.deprecated_args(
131 None, "position is deprecated in favor of the offset argument.",

Callers 15

testEmptyFilenameMethod · 0.95
testMultipleFilesMethod · 0.95
testCopyMethod · 0.95
testEofMethod · 0.95
read_file_to_stringFunction · 0.95
_ZlibCompressFileMethod · 0.45
_GzipCompressFileMethod · 0.45
_ZlibDecompressFileMethod · 0.45
_GzipDecompressFileMethod · 0.45
_AssertFilesEqualMethod · 0.45
testZLibFlushRecordMethod · 0.45
testBadFileMethod · 0.45

Calls 5

_preread_checkMethod · 0.95
sizeMethod · 0.95
tellMethod · 0.95
_prepare_valueMethod · 0.95
ReadFromStreamMethod · 0.80

Tested by 15

testEmptyFilenameMethod · 0.76
testMultipleFilesMethod · 0.76
testCopyMethod · 0.76
testEofMethod · 0.76
_ZlibCompressFileMethod · 0.36
_GzipCompressFileMethod · 0.36
_ZlibDecompressFileMethod · 0.36
_GzipDecompressFileMethod · 0.36
_AssertFilesEqualMethod · 0.36
testZLibFlushRecordMethod · 0.36
testBadFileMethod · 0.36
testReadBinaryModeMethod · 0.36