Encode more types.
326104
def default(self, obj):
        """"""
        if isinstance(obj, UUID):
            return obj.hex
        elif isinstance(obj, datetime.datetime):
            return obj.isoformat()

        return super().default(obj)
210629
def _VarintEncoder():
  """"""

  def EncodeVarint(write, value):
    bits = value & 0x7f
    value >>= 7
    while value:
      write(six.int2byte(0x80|bits))
      bits = value & 0x7f
      value >>= 7
    return write(six.int2byte(bits))

  return EncodeVarint
587628
def encodePolymorphicNucleotide(polySeq) :
	"""'"""
	
	if type(polySeq) is types.StringType :
		if polySeq.find("/") < 0 :
			sseq = list(polySeq)
		else :
			sseq = polySeq.split('/')
			
	else :
		sseq = polySeq
	
	seq = []
	for n in sseq :
		try :
			for n2 in polymorphicNucleotides[n] :
				seq.append(n2)
		except KeyError :
			seq.append(n)
	
	seq = set(seq)
	
	if len(seq) == 4:
		return 'N'
	elif len(seq) == 3 :
		if 'T' not in seq :
			return 'V'
		elif 'G' not in seq :
			return 'H'
		elif 'C' not in seq :
			return 'D'
		elif 'A' not in seq :
			return 'B'
	elif len(seq) == 2 :
		if 'A' in seq and 'G' in seq :
			return 'R'
		elif 'C' in seq and 'T' in seq :
			return 'Y'
		elif 'A' in seq and 'C' in seq :
			return 'M'
		elif 'T' in seq and 'G' in seq :
			return 'K'
		elif 'A' in seq and 'T' in seq :
			return 'W'
		elif 'C' in seq and 'G' in seq :
			return 'S'
	elif polySeq[0] in nucleotides :
		return polySeq[0]
	else :
		raise UnknownNucleotide(polySeq)
444799
def _encode(self):
        """"""
        obj = {k: v for k, v in self.__dict__.items()
               if not k.startswith('_') and type(v) in SAFE_TYPES}
        obj.update({k: v._encode() for k, v in self.__dict__.items()
                   if isinstance(v, Ent)})
        return obj
67133
def _encode_numbers(self, obj):
        """"""

        # strict checks first - for speed
        if obj.__class__ is int:
            if abs(obj) > JAVASCRIPT_MAXINT:
                raise ValueError('Number out of range: {!r}'.format(obj))
            return str(obj)

        if obj.__class__ is float:
            if isnan(obj):
                raise ValueError('NaN is not supported')
            if isinf(obj):
                raise ValueError('Infinity is not supported')
            return repr(obj)

        # more in-depth class analysis last
        if isinstance(obj, int):
            obj = int(obj)
            if abs(obj) > JAVASCRIPT_MAXINT:
                raise ValueError('Number out of range: {!r}'.format(obj))
            return str(obj)

        if isinstance(obj, float):
            if isnan(obj):
                raise ValueError('NaN is not supported')
            if isinf(obj):
                raise ValueError('Infinity is not supported')
            return repr(obj)

        if isinstance(obj, Decimal):
            return '"' + str(obj) + '"'

        # for complex and other Numbers
        return self._encode(self.default(obj))
1127672
function(type){
  var regExp = /CV_([0-9]+)([A-Z]+)([0-9]+)/;
  for(var k in cv.Constants) if(cv.Constants.hasOwnProperty(k) && k.match(regExp) && cv.Constants[k] === type){
    var bytes, channels, dataType;
    k.replace(regExp, function(all, b, l, c){
      bytes = b;
      channels = c;
      dataType = l[0]
    });

    return {
      bytes : parseInt(bytes),
      channels : !isNaN(parseInt(channels)) && parseInt(channels),
      dataType : dataType,
      label : k
    };
  }
}
427070
def dump(type)
      get_many(type).map{|d|d.to_s}.sort.join("\n")
    end
64917
function encodeType($value, \Plasma\ColumnDefinitionInterface $column): \Plasma\Types\TypeExtensionResultInterface {
        $type = \gettype($value);
        if($type === 'double') {
            $type = 'float';
        }
        
        if($type === 'object') {
            $classes = \array_merge(
                array(\get_class($value)),
                \class_parents($value),
                \class_implements($value)
            );
            
            /** @var \Plasma\Types\TypeExtensionInterface  $encoder */
            foreach($this->classTypes as $key => $encoder) {
                if(\in_array($key, $classes, true)) {
                    return $encoder->encode($value, $column);
                }
            }
        }
        
        /** @var \Plasma\Types\TypeExtensionInterface  $encoder */
        foreach($this->regularTypes as $key => $encoder) {
            if($type === $key) {
                return $encoder->encode($value, $column);
            }
        }
        
        if($this->enabledFuzzySearch) {
            /** @var \Plasma\Types\TypeExtensionInterface  $encoder */
            foreach($this->classTypes as $key => $encoder) {
                if($encoder->canHandleType($value, $column)) {
                    return $encoder->encode($value, $column);
                }
            }
            
            /** @var \Plasma\Types\TypeExtensionInterface  $encoder */
            foreach($this->regularTypes as $key => $encoder) {
                if($encoder->canHandleType($value, $column)) {
                    return $encoder->encode($value, $column);
                }
            }
        }
        
        throw new \Plasma\Exception('Unable to encode given value');
    }
170824
function Encoder(options) {
  options = options || {};
  Transform.call(this, {objectMode: true});

  // string length chunk for bulk strings, strings large than this amount
  // are broken over process ticks so as not to block the event loop
  // note this is character length, not byte length
  this.strlen = options.strlen || 4096;

  // maximum array length before iterating using
  // setImmediate
  this.arrlen = 512;

  // allow buffers to be passed through untouched
  this.buffers = options.buffers;

  // treat buffers as bulk strings
  this.return_buffers = options.return_buffers;
}
143480
def encode_items(items):
    
    encoded = []
    for key, values in items:
        for value in values:
            encoded.append((key.encode('utf-8'), value.encode('utf-8')))
    return encoded
1225565
function serialize(type, source, options) {
  var codec = type.codec
  if (!codec)
    return postEncode(new Buffer([ type.byte ]), options)

  var buffer = codec.encode(source, bytewise)

  if (options && options.nested && codec.escape)
    buffer = codec.escape(buffer)

  var hint = typeof codec.length === 'number' ? (codec.length + 1) : void 0 
  var buffers = [ new Buffer([ type.byte ]), buffer ]
  return postEncode(Buffer.concat(buffers, hint), options)
}
187984
def encode(data, mime_type='', charset='utf-8', base64=True):
    
    if isinstance(data, six.text_type):
        data = data.encode(charset)
    else:
        charset = None
    if base64:
        data = utils.text(b64encode(data))
    else:
        data = utils.text(quote(data))

    result = ['data:', ]
    if mime_type:
        result.append(mime_type)
    if charset:
        result.append(';charset=')
        result.append(charset)
    if base64:
        result.append(';base64')
    result.append(',')
    result.append(data)

    return ''.join(result)
714518
def encode(self, value):
        '''
        
        '''
        kassert.is_of_types(value, Bits)
        remainder = len(value) % 8
        if remainder:
            value += Bits(bin='0' * (8 - remainder))
        return value
856827
function(data) {
      return proto.encodeStrict(data.a, data.b, data.c, data.d);
    }
981278
def Encode(self, attribute, value):
    """"""
    required_type = self._attribute_types.get(attribute, "bytes")

    if required_type == "integer":
      return rdf_structs.SignedVarintEncode(int(value))
    elif required_type == "unsigned_integer":
      return rdf_structs.VarintEncode(int(value))
    elif hasattr(value, "SerializeToString"):
      return value.SerializeToString()
    elif isinstance(value, bytes):
      return value
    elif isinstance(value, Text):
      return value.encode("utf-8")
    else:
      return str(value).encode("utf-8")
68108
private void encodeEnum(GeneratorAdapter mg, TypeToken<?> outputType,
                          int value, int encoder, int schemaLocal) {

    // encoder.writeInt(this.schema.getEnumIndex(value.name()));
    mg.loadArg(encoder);
    mg.loadArg(schemaLocal);
    mg.loadArg(value);
    mg.invokeVirtual(Type.getType(outputType.getRawType()), getMethod(String.class, "name"));
    mg.invokeVirtual(Type.getType(Schema.class), getMethod(int.class, "getEnumIndex", String.class));
    mg.invokeInterface(Type.getType(Encoder.class), getMethod(Encoder.class, "writeInt", int.class));
    mg.pop();
  }
1208607
def encode(self, *values):
        
        if not (values and all(_is_uint(x) for x in values)):
            return ''

        return _encode(values, self._salt, self._min_length, self._alphabet,
                       self._separators, self._guards)