code: def write(self, data):
      
      block_remaining = _BLOCK_SIZE - self.__position % _BLOCK_SIZE
  
      if block_remaining < _HEADER_LENGTH:
        # Header won't fit into remainder
        self.__writer.write('\x00' * block_remaining)
        self.__position += block_remaining
        block_remaining = _BLOCK_SIZE
  
      if block_remaining < len(data) + _HEADER_LENGTH:
        first_chunk = data[:block_remaining - _HEADER_LENGTH]
        self.__write_record(_RECORD_TYPE_FIRST, first_chunk)
        data = data[len(first_chunk):]
  
        while True:
          block_remaining = _BLOCK_SIZE - self.__position % _BLOCK_SIZE
          if block_remaining >= len(data) + _HEADER_LENGTH:
            self.__write_record(_RECORD_TYPE_LAST, data)
            break
          else:
            chunk = data[:block_remaining - _HEADER_LENGTH]
            self.__write_record(_RECORD_TYPE_MIDDLE, chunk)
            data = data[len(chunk):]
      else:
        self.__write_record(_RECORD_TYPE_FULL, data)
docs: Write single record.
  
      Args:
        data: record data to write as string, byte array or byte sequence.