Пример #1
0
 def _preread_check(self):
     if not self._read_buf:
         if not self._read_check_passed:
             raise errors.PermissionDeniedError(
                 None, None, "File isn't open for reading")
         self._read_buf = _pywrap_file_io.BufferedInputStream(
             compat.path_to_str(self.__name), 1024 * 512)
Пример #2
0
 def _prewrite_check(self):
   if not self._writable_file:
     if not self._write_check_passed:
       raise errors.PermissionDeniedError(None, None,
                                          "File isn't open for writing")
     self._writable_file = pywrap_tensorflow.CreateWritableFile(
         compat.as_bytes(self.__name), compat.as_bytes(self.__mode))
Пример #3
0
 def _preread_check(self):
   if not self._read_buf:
     if not self._read_check_passed:
       raise errors.PermissionDeniedError(None, None,
                                          "File isn't open for reading")
     self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(
         compat.as_bytes(self.__name), 1024 * 512)
Пример #4
0
 def _preread_check(self):
     if not self._read_buf:
         if not self._read_check_passed:
             raise errors.PermissionDeniedError(
                 None, None, "File isn't open for reading")
         with errors.raise_exception_on_not_ok_status() as status:
             self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(
                 compat.as_bytes(self.__name), 1024 * 512, status)
Пример #5
0
 def _prewrite_check(self):
   if not self._writable_file:
     if not self._write_check_passed:
       raise errors.PermissionDeniedError(None, None,
                                          "File isn't open for writing")
     with errors.raise_exception_on_not_ok_status() as status:
       self._writable_file = pywrap_tensorflow.CreateWritableFile(
           compat.as_bytes(self.__name), compat.as_bytes(self.__mode), status)
Пример #6
0
 def read(self):
     """Returns the contents of a file as a string."""
     if not self._read_check_passed:
         raise errors.PermissionDeniedError(None, None,
                                            "File isn't open for reading")
     with errors.raise_exception_on_not_ok_status() as status:
         return pywrap_tensorflow.ReadFileToString(
             compat.as_bytes(self.__name), status)
Пример #7
0
 def write(self, file_content):
     """Writes file_content to the file."""
     if not self._write_check_passed:
         raise errors.PermissionDeniedError(None, None,
                                            "File isn't open for writing")
     with errors.raise_exception_on_not_ok_status() as status:
         pywrap_tensorflow.WriteStringToFile(compat.as_bytes(self.__name),
                                             compat.as_bytes(file_content),
                                             status)
Пример #8
0
 def tell(self):
     """Returns the current position in the file."""
     if not self._read_check_passed:
         raise errors.PermissionDeniedError(None, None,
                                            "File isn't open for reading")
     return self._read_buf.Tell()