Encodes arguments into redis bulk-strings array.

    Raises TypeError if any of args not of bytearray, bytes, float, int, or str
    type.
329603
def encode_command(*args, buf=None):
    
    if buf is None:
        buf = bytearray()
    buf.extend(b'*%d\r\n' % len(args))

    try:
        for arg in args:
            barg = _converters[type(arg)](arg)
            buf.extend(b'$%d\r\n%s\r\n' % (len(barg), barg))
    except KeyError:
        raise TypeError("Argument {!r} expected to be of bytearray, bytes,"
                        " float, int, or str type".format(arg))
    return buf
614978
def batch_encode(self, iterator, *args, **kwargs):
        
        return [self.encode(object_, *args, **kwargs) for object_ in iterator]
538311
def to_str(v, encode=None):
    
    if isinstance(v, basestring_type):
        return v

    if isinstance(v, dict):
        return to_dict_str(v, encode)

    if isinstance(v, Iterable):
        return to_list_str(v, encode)

    if encode:
        return encode(v)
    else:
        return default_encode(v)
144958
def encode(self, data, size):
        
        return return_fresh_string(lib.zarmour_encode(self._as_parameter_, data, size))
489199
def _floatify(str, increment = true)
      if (( inf = str.to_s.match(/^([+-])?inf/i) ))
        (inf[1] == "-" ? -1.0 : 1.0) / 0.0
      elsif (( number = str.to_s.match(/^\((\d+)/i) ))
        number[1].to_i + (increment ? 1 : -1)
      else
        Float str.to_s
      end
    rescue ArgumentError
      raise Redis::CommandError, "ERR value is not a valid float"
    end
1187658
def encode_params(self, data=None, **kwargs):
        
        if isinstance(data, basestring):
            raise ValueError("Data must not be a string.")
        if data is None:
            return b"", self.content_type

        fields = to_key_val_dict(data or "")
        try:
            body = json.dumps(fields)
        except:
            body = json.dumps(fields, encoding='latin-1')

        return str(body).encode(), self.content_type
640465
def encode(data):
    
    res = ""
    for i in range(0,len(data), 3):
        if (i+2==len(data)):
            res += _encode3bytes(ord(data[i]), ord(data[i+1]), 0)
        elif (i+1==len(data)):
            res += _encode3bytes(ord(data[i]), 0, 0)
        else:
            res += _encode3bytes(ord(data[i]), ord(data[i+1]), ord(data[i+2]))
    return res
1041770
def stringify(*args):
    
    if (len(args) == 1) and callable(args[0]):
        func = args[0]

        @wraps(func)
        def _inner(*args, **kwargs):
            return "".join([str(i) for i in func(*args, **kwargs)])
        return _inner
    else:
        return "".join([str(i) for i in args])
881277
def str_args(args):
    
    res = []
    for x in args:
        if isinstance(x, tuple) and len(x) == 2:
            key, value = x
            if value and str_arg(value):
                res += ["%s=%s" % (key, str_arg(value))]
        else:
            res += [str_arg(x)]
    return ', '.join(res)
768531
def encode_properties(parameters):
    
    result = []

    for param in iter(sorted(parameters)):
        if isinstance(parameters[param], (list, tuple)):
            value = ','.join([escape_chars(x) for x in parameters[param]])
        else:
            value = escape_chars(parameters[param])

        result.append("%s=%s" % (param, value))

    return '|'.join(result)
22474
def sinterstore(self, dest, keys, *args):
        """"""
        result = self.sinter(keys, *args)
        self.redis[self._encode(dest)] = result
        return len(result)
826356
def encode(self, input_str):
    """"""
    inputs = self.encoders["inputs"].encode(input_str) + [EOS_ID]
    batch_inputs = np.reshape(inputs, [1, -1, 1, 1])  # Make it 3D.
    return batch_inputs
870197
def encode(arg, delimiter=None, encodeseq=None, encoded=tuple()):
    ''''''
    arg = coerce_unicode(arg, _c.FSQ_CHARSET)
    new_arg = sep = u''
    delimiter, encodeseq = delimiter_encodeseq(
        _c.FSQ_DELIMITER if delimiter is None else delimiter,
        _c.FSQ_ENCODE if encodeseq is None else encodeseq,
        _c.FSQ_CHARSET)

    # validate encoded tuple
    for enc in encoded:
        enc = coerce_unicode(enc, _c.FSQ_CHARSET)
        try:
            enc = enc.encode('ascii')
        except UnicodeEncodeError:
            raise FSQEncodeError(errno.EINVAL, u'invalid encoded value: {0}'\
                                 u' non-ascii'.format(enc))
    # char-wise encode walk
    for seq in arg:
        if seq == delimiter or seq == encodeseq or seq in _ENCODED + encoded:
            h_val = hex(ord(seq))
            # front-pad with zeroes
            if 3 == len(h_val):
                h_val = sep.join([h_val[:2], u'0', h_val[2:]])
            if 4 != len(h_val):
                raise FSQEncodeError(errno.EINVAL, u'invalid hex ({0}) for'\
                                     ' encode-target: {1}'.format(h_val, seq))
            seq = sep.join([encodeseq, h_val[2:]])

        new_arg = sep.join([new_arg, seq])

    return new_arg
258090
function getString(cb) {
    getEncodedLen(function(err, encLen, isEncoded) {
      if(err) {
        return cb(err);
      }
      if (isEncoded) {
        switch(encLen) {
        case REDIS_RDB_ENC_INT8:
          getFixedBytes(1, function(err, buffers) {
            if(err) {
              cb(err);
            } else {
              cb(null, new Buffer(String(Buffer.concat(buffers).readInt8(0))));
            }
          });
          break;
        case REDIS_RDB_ENC_INT16:
          getFixedBytes(2, function(err, buffers) {
            if(err) {
              cb(err);
            } else {
              cb(null, new Buffer(String(Buffer.concat(buffers).readInt16LE(0))));
            }
          });
          break;
        case REDIS_RDB_ENC_INT32:
          getFixedBytes(4, function(err, buffers) {
            if(err) {
              cb(err);
            } else {
              cb(null, new Buffer(String(Buffer.concat(buffers).readInt32LE(0))));
            }
          });
          break;
        case REDIS_RDB_ENC_LZF:
          getEncodedLen(function(err, encLen) {
            if(err) {
              return cb(err);
            }
            getEncodedLen(function(err, len) {
              if(err) {
                return cb(err);
              }
              getFixedBytes(encLen, function(err, buffers) {
                if(err) {
                  return cb(err);
                }
                var compressed = Buffer.concat(buffers);
                var decompressed = lzf.decompress(compressed);
                cb(null, decompressed);
              });
            });
          });
          break;
        default:
          cb('unknown encoding');
        }
      } else {
        // FIXME can getFixedBytes be called inside a callback?
        getFixedBytes(encLen, function(err, buffers) {
          if(err) {
            cb(err);
          } else {
            cb(null, Buffer.concat(buffers));
          }
        });
      }
    });
  }
1352924
def bytes_to_char(arr):
    """"""
    if arr.dtype.kind != 'S':
        raise ValueError('argument must have a fixed-width bytes dtype')

    if isinstance(arr, dask_array_type):
        import dask.array as da
        return da.map_blocks(_numpy_bytes_to_char, arr,
                             dtype='S1',
                             chunks=arr.chunks + ((arr.dtype.itemsize,)),
                             new_axis=[arr.ndim])
    else:
        return _numpy_bytes_to_char(arr)
1342588
function (params, funAbi, callback) {
    var data = ''
    var dataHex = ''
    var funArgs
    if (params.indexOf('raw:0x') === 0) {
      // in that case we consider that the input is already encoded and *does not* contain the method signature
      dataHex = params.replace('raw:0x', '')
      data = Buffer.from(dataHex, 'hex')
    } else {
      try {
        params = params.replace(/(^|,\s+|,)(\d+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted number by quoted number
        params = params.replace(/(^|,\s+|,)(0[xX][0-9a-fA-F]+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted hex string by quoted hex string
        funArgs = JSON.parse('[' + params + ']')
      } catch (e) {
        callback('Error encoding arguments: ' + e)
        return
      }
      if (funArgs.length > 0) {
        try {
          data = helper.encodeParams(funAbi, funArgs)
          dataHex = data.toString('hex')
        } catch (e) {
          callback('Error encoding arguments: ' + e)
          return
        }
      }
      if (data.slice(0, 9) === 'undefined') {
        dataHex = data.slice(9)
      }
      if (data.slice(0, 2) === '0x') {
        dataHex = data.slice(2)
      }
    }
    callback(null, { data: data, dataHex: dataHex, funArgs: funArgs })
  }
875037
def _internal_write(out_stream, arr):
    

    if arr.size == 0:
        raise FormatError('Cannot encode empty array.')

    try:
        type_byte, struct_lib_type = _DATA_TYPES_NUMPY[str(arr.dtype)]
    except KeyError:
        raise FormatError('numpy ndarray type not supported by IDX format.')

    if arr.ndim > _MAX_IDX_DIMENSIONS:
        raise FormatError(
            'IDX format cannot encode array with dimensions > 255')

    if max(arr.shape) > _MAX_AXIS_LENGTH:
        raise FormatError('IDX format cannot encode array with more than ' +
                          str(_MAX_AXIS_LENGTH) + ' elements along any axis')

    # Write magic number
    out_stream.write(struct.pack('BBBB', 0, 0, type_byte, arr.ndim))

    # Write array dimensions
    out_stream.write(struct.pack('>' + 'I' * arr.ndim, *arr.shape))

    # Horrible hack to deal with horrible bug when using struct.pack to encode
    # unsigned ints in 2.7 and lower, see http://bugs.python.org/issue2263
    if sys.version_info < (2, 7) and str(arr.dtype) == 'uint8':
        arr_as_list = [int(i) for i in arr.reshape(-1)]
        out_stream.write(struct.pack('>' + struct_lib_type * arr.size,
                                     *arr_as_list))
    else:
        # Write array contents - note that the limit to number of arguments
        # doesn't apply to unrolled arguments
        out_stream.write(struct.pack('>' + struct_lib_type * arr.size,
                                     *arr.reshape(-1)))