MCPcopy Index your code
hub / github.com/tensorflow/tensorboard / read

Method read

tensorboard/compat/tensorflow_stub/io/gfile.py:706–749  ·  view source on GitHub ↗

Reads contents of file to a string. Args: n: int, number of bytes or characters to read, otherwise read all the contents of the file Returns: Subset of the contents of the file as a string or bytes.

(self, n=None)

Source from the content-addressed store, hash-verified

704 return self.buff[old_buff_offset : old_buff_offset + read_size]
705
706 def read(self, n=None):
707 """Reads contents of file to a string.
708
709 Args:
710 n: int, number of bytes or characters to read, otherwise
711 read all the contents of the file
712
713 Returns:
714 Subset of the contents of the file as a string or bytes.
715 """
716 if self.write_mode:
717 raise errors.PermissionDeniedError(
718 None, None, "File not opened in read mode"
719 )
720
721 result = None
722 if self.buff and len(self.buff) > self.buff_offset:
723 # read from local buffer
724 if n is not None:
725 chunk = self._read_buffer_to_offset(self.buff_offset + n)
726 if len(chunk) == n:
727 return chunk
728 result = chunk
729 n -= len(chunk)
730 else:
731 # add all local buffer and update offsets
732 result = self._read_buffer_to_offset(len(self.buff))
733
734 # read from filesystem
735 read_size = max(self.buff_chunk_size, n) if n is not None else None
736 (self.buff, self.continuation_token) = self.fs.read(
737 self.filename, self.binary_mode, read_size, self.continuation_token
738 )
739 self.buff_offset = 0
740
741 # add from filesystem
742 if n is not None:
743 chunk = self._read_buffer_to_offset(n)
744 else:
745 # add all local buffer and update offsets
746 chunk = self._read_buffer_to_offset(len(self.buff))
747 result = result + chunk if result else chunk
748
749 return result
750
751 def write(self, file_content):
752 """Writes string file contents to file, clearing contents of the file

Callers 15

testEmptyFilenameMethod · 0.95
__next__Method · 0.95
_read_file_to_stringFunction · 0.95
_serve_sprite_imageMethod · 0.95
_assert_liveMethod · 0.45
test_timeoutMethod · 0.45
testMethod · 0.45
get_allFunction · 0.45
_maybe_read_fileFunction · 0.45
mainFunction · 0.45
convert_blob_valueFunction · 0.45

Calls 1

Tested by 15

testEmptyFilenameMethod · 0.76
_assert_liveMethod · 0.36
test_timeoutMethod · 0.36
testMethod · 0.36
testReadMethod · 0.36
testReadWithOffsetMethod · 0.36
testWriteMethod · 0.36
testOverwriteMethod · 0.36
testWriteMultipleMethod · 0.36
testWriteEmptyMethod · 0.36
testWriteBinaryMethod · 0.36