def seek(self, offset, whence=os.SEEK_SET):
    """Seeks to an offset within the file-like object.

    Args:
      offset (int): offset to seek to.
      whence (Optional(int)): value that indicates whether offset is an absolute
          or relative position within the file.

    Raises:
      IOError: if the seek failed.
      OSError: if the seek failed.
    """
    if not self._is_open:
      raise IOError('Not opened.')

    if self._current_offset < 0:
      raise IOError(
          'Invalid current offset: {0:d} value less than zero.'.format(
              self._current_offset))

    if whence == os.SEEK_CUR:
      offset += self._current_offset

    elif whence == os.SEEK_END:
      if self._decoded_stream_size is None:
        self._decoded_stream_size = self._GetDecodedStreamSize()
        if self._decoded_stream_size is None:
          raise IOError('Invalid decoded stream size.')

      offset += self._decoded_stream_size

    elif whence != os.SEEK_SET:
      raise IOError('Unsupported whence.')

    if offset < 0:
      raise IOError('Invalid offset value less than zero.')

    if offset != self._current_offset:
      self._current_offset = offset
      self._realign_offset = True
def seek ( self , offset , whence = os . SEEK_SET ) : if not self . _is_open : raise IOError ( 'Not opened.' ) if self . _current_offset < 0 : raise IOError ( 'Invalid current offset: {0:d} value less than zero.' . format ( self . _current_offset ) ) if whence == os . SEEK_CUR : offset += self . _current_offset elif whence == os . SEEK_END : if self . _decoded_stream_size is None : self . _decoded_stream_size = self . _GetDecodedStreamSize ( ) if self . _decoded_stream_size is None : raise IOError ( 'Invalid decoded stream size.' ) offset += self . _decoded_stream_size elif whence != os . SEEK_SET : raise IOError ( 'Unsupported whence.' ) if offset < 0 : raise IOError ( 'Invalid offset value less than zero.' ) if offset != self . _current_offset : self . _current_offset = offset self . _realign_offset = True
Seeks to an offset within the file-like object.

    Args:
      offset (int): offset to seek to.
      whence (Optional(int)): value that indicates whether offset is an absolute
          or relative position within the file.

    Raises:
      IOError: if the seek failed.
      OSError: if the seek failed.