Wrap write() to adapt return value for Python 2.

        Returns:
            Wrapper which is described below.
166068
def _write_wrapper(self, name):
        
        io_attr = getattr(self._io, name)

        def write_wrapper(*args, **kwargs):
            """Wrap all write calls to the stream object."""
            ret_value = io_attr(*args, **kwargs)
            if not IS_PY2:
                return ret_value

        return write_wrapper
710829
def strippen(function):
    ""
    def wrapper(*args, **kwargs):
        return strip_strings(function(*args, **kwargs))
    return wrapper
606864
def write_this(func):
        
        @wraps(func)
        def wrapper(self, *args, **kwargs):
            byte_array = func(self, *args, **kwargs)
            self.write_bytes(byte_array)
        return wrapper
1333598
def _wrap_tracebackexception_format(redact: Callable[[str], str]):
    
    original_format = getattr(TracebackException, '_original', None)
    if original_format is None:
        original_format = TracebackException.format
        setattr(TracebackException, '_original', original_format)

    @wraps(original_format)
    def tracebackexception_format(self, *, chain=True):
        for line in original_format(self, chain=chain):
            yield redact(line)

    setattr(TracebackException, 'format', tracebackexception_format)
308663
def _truncate_wrapper(self):
        
        io_attr = getattr(self._io, 'truncate')

        def truncate_wrapper(*args, **kwargs):
            """Wrap truncate call to call flush after truncate."""
            if self._append:
                self._io.seek(self._read_seek, self._read_whence)
            size = io_attr(*args, **kwargs)
            self.flush()
            if not self.is_stream:
                self.file_object.size = size
                buffer_size = len(self._io.getvalue())
                if buffer_size < size:
                    self._io.seek(buffer_size)
                    self._io.write('\0' * (size - buffer_size))
                    self.file_object.set_contents(
                        self._io.getvalue(), self._encoding)
                    self._flush_pos = size
                    if self._filesystem.is_macos or sys.version_info[0] > 2:
                        self._adapt_size_for_related_files(size - buffer_size)

            self.flush()
            if not IS_PY2:
                return size

        return truncate_wrapper
835011
def write(self):
        

        slist = []
        slist.append('{}/{}.{} {} {}'.format(
                        self.protocol,
                        self.version[0],
                        self.version[1],
                        self.code,
                        status_messages[self.code]))
        slist.extend(self.write_headers())
        slist.append('\r\n')
        return slist
411950
def _WriteRow(self, output_writer, values):
    
    maximum_row_width = self._MAXIMUM_WIDTH - self._column_width - 3

    # The format string of the first line of the column value.
    primary_format_string = '{{0:>{0:d}s}} : {{1:s}}\n'.format(
        self._column_width)

    # The format string of successive lines of the column value.
    secondary_format_string = '{{0:<{0:d}s}}{{1:s}}\n'.format(
        self._column_width + 3)

    if isinstance(values[1], py2to3.STRING_TYPES):
      value_string = values[1]
    else:
      value_string = '{0!s}'.format(values[1])

    if len(value_string) < maximum_row_width:
      output_writer.Write(primary_format_string.format(
          values[0], value_string))
      return

    # Split the column value in words.
    words = value_string.split()

    current = 0

    lines = []
    word_buffer = []
    for word in words:
      current += len(word) + 1
      if current >= maximum_row_width:
        current = len(word)
        lines.append(' '.join(word_buffer))
        word_buffer = [word]
      else:
        word_buffer.append(word)
    lines.append(' '.join(word_buffer))

    # Split the column value across multiple lines.
    output_writer.Write(
        primary_format_string.format(values[0], lines[0]))
    for line in lines[1:]:
      output_writer.Write(secondary_format_string.format('', line))
446636
def wraps(__fn, **kw):
        """"""
        kw['assigned'] = kw.get('assigned', WRAPPER_ASSIGNMENTS)
        return functools.wraps(__fn, **kw)
1294233
def wraps(self, f):
        
        @_utils.wraps(f)
        def wrapped_f(*args, **kw):
            return self.call(f, *args, **kw)

        def retry_with(*args, **kwargs):
            return self.copy(*args, **kwargs).wraps(f)

        wrapped_f.retry = self
        wrapped_f.retry_with = retry_with

        return wrapped_f
1018532
def wrap(anything: bytes, encoding: str) -> str:
    
    return json.dumps({
        "wrap": load_json(anything.decode(encoding))
    }, ensure_ascii=False)
501795
def write(self, s):
        
        b = s.encode(self.encoding)
        return super(PtyProcessUnicode, self).write(b)
418486
protected void wrappedWrite(int b) throws IOException
	{
		checkState();
		try
		{
			out.write(b);
		}
		catch(IOException e)
		{
			error = true;
			throw e;
		}
	}
33852
def wrap(self, func, delay=0):
        '''
        
        '''
        def wrapped():
            self.start()
            if delay:
                self.sleep(delay)
            x = None
            try:
                x = func()
            except OSError as oserror:
                log.debug('OSError exception:%s', oserror)
                self.oserror = oserror
                raise EasyProcessError(self, 'wrap error!')
            finally:
                self.stop()
            return x
        return wrapped
1361474
def encode_if_py2(func):
    
    if not PY2:
        return func
    def wrapped(*args, **kwargs):
        ret = func(*args, **kwargs)
        if not isinstance(ret, unicode):
            raise TypeError('Wrapped function must return `unicode`')
        return ret.encode('utf-8', 'ignore')
    return wrapped
764972
def wrap(self, wrapper):
        
        def wrapped(*args, **kwargs):

            if kwargs:
                kwargs["object"] = self.obj
            else:
                args = list(args)
                args.insert(0, self.obj)

            return wrapper(*args, **kwargs)

        return self._wrap(wrapped)
1019063
def _writable(method):
    
    @wraps(method)
    def wrapper(self, *args, **kwargs):
        """Send record for indexing.

        :returns: Execution result of the decorated method.

        :raises InvalidOperationError: It occurs when the bucket is locked or
            deleted.
        """
        if self.bucket.locked or self.bucket.deleted:
            raise InvalidOperationError()
        return method(self, *args, **kwargs)
    return wrapper
1328317
def wrap(self, methodName, types, skip=2):
        

        def handler(fields):
            try:
                args = [
                    field if typ is str else
                    int(field or 0) if typ is int else
                    float(field or 0) if typ is float else
                    bool(int(field or 0))
                    for (typ, field) in zip(types, fields[skip:])]
                method(*args)
            except Exception:
                self.logger.exception(f'Error for {methodName}:')

        method = getattr(self.wrapper, methodName, None)
        return handler if method else lambda *args: None