Same as pack but uses a user-defined serializer function to convert items
into longstr.
511428
def pack_own(self, serializer):
        
        return Zframe(lib.zhashx_pack_own(self._as_parameter_, serializer), True)
1168912
def serialize(self, private=False):
        
        if not self.priv_key and not self.pub_key:
            raise SerializationNotPossible()

        res = self.common()

        public_longs = list(set(self.public_members) & set(self.longs))
        for param in public_longs:
            item = getattr(self, param)
            if item:
                res[param] = item

        if private:
            for param in self.longs:
                if not private and param in ["d", "p", "q", "dp", "dq", "di",
                                             "qi"]:
                    continue
                item = getattr(self, param)
                if item:
                    res[param] = item
        if self.x5c:
            res['x5c'] = [x.decode('utf-8') for x in self.x5c]

        return res
978353
def pack_unicode(cls, value, charset="utf-8", errors="strict"):
        
        assert isinstance(value, unicode)

        try:
            value = value.encode(charset, errors)
        except UnicodeEncodeError as e:
            raise InvalidData("Error encoding unicode value '%s': %s" % (repr(value), e))

        value_len_packed = cls.pack_int_base128(len(value))
        return struct.pack("<%ds%ds" % (len(value_len_packed), len(value)), value_len_packed,  value)
35153
def GroupSizer(field_number, is_repeated, is_packed):
  """"""

  tag_size = _TagSize(field_number) * 2
  assert not is_packed
  if is_repeated:
    def RepeatedFieldSize(value):
      result = tag_size * len(value)
      for element in value:
        result += element.ByteSize()
      return result
    return RepeatedFieldSize
  else:
    def FieldSize(value):
      return tag_size + value.ByteSize()
    return FieldSize
51201
def _pack(self):
        """"""
        data = ByteBuffer()
        if not hasattr(self, '__fields__'):
            return data.array

        for field in self.__fields__:
            field.encode(self, data)
        return data.array
830571
def pack(self):
        '''
        
        '''
        reqdictf = {k.name.lower(): v for (k, v) in self.reqdict.items()}
        incunitf = None if self.incunit is None else self.incunit.name.lower()
        return (reqdictf, incunitf, self.incval)
565375
def pack_list(from_, pack_type):
    
    # We need from_ to not be empty
    if len(from_) == 0:
        return bytes()

    if pack_type == 'c':
        if isinstance(from_, bytes):
            # Catch Python 3 bytes and Python 2 strings
            # PY3 is "helpful" in that when you do tuple(b'foo') you get
            # (102, 111, 111) instead of something more reasonable like
            # (b'f', b'o', b'o'), so we rebuild from_ as a tuple of bytes
            from_ = [six.int2byte(b) for b in six.iterbytes(from_)]
        elif isinstance(from_, six.string_types):
            # Catch Python 3 strings and Python 2 unicode strings, both of
            # which we encode to bytes as utf-8
            # Here we create the tuple of bytes from the encoded string
            from_ = [six.int2byte(b) for b in bytearray(from_, 'utf-8')]
        elif isinstance(from_[0], six.integer_types):
            # Pack from_ as char array, where from_ may be an array of ints
            # possibly greater than 256
            def to_bytes(v):
                for _ in range(4):
                    v, r = divmod(v, 256)
                    yield r
            from_ = [six.int2byte(b) for i in from_ for b in to_bytes(i)]

    if isinstance(pack_type, six.string_types):
        return struct.pack("=" + pack_type * len(from_), *from_)
    else:
        buf = six.BytesIO()
        for item in from_:
            # If we can't pack it, you'd better have packed it yourself. But
            # let's not confuse things which aren't our Probobjs for packable
            # things.
            if isinstance(item, Protobj) and hasattr(item, "pack"):
                buf.write(item.pack())
            else:
                buf.write(item)
        return buf.getvalue()
714312
def _encode_long(name, value, dummy0, dummy1):
    """"""
    try:
        return b"\x12" + name + _PACK_LONG(value)
    except struct.error:
        raise OverflowError("BSON can only handle up to 8-byte ints")
1243403
def _convert_strls(self, data):
        """"""
        convert_cols = [
            col for i, col in enumerate(data)
            if self.typlist[i] == 32768 or col in self._convert_strl]

        if convert_cols:
            ssw = StataStrLWriter(data, convert_cols)
            tab, new_data = ssw.generate_table()
            data = new_data
            self._strl_blob = ssw.generate_blob(tab)
        return data
1000055
def serialize_list(self, tag):
        """"""
        separator, fmt = self.comma, '[{}]'

        with self.depth():
            if self.should_expand(tag):
                separator, fmt = self.expand(separator, fmt)

            return fmt.format(separator.join(map(self.serialize, tag)))
837742
public static long fromHeaderValue(String serialized) {
        checkArgument(!serialized.isEmpty(), "empty timeout");
        checkArgument(serialized.length() <= 9, "bad timeout format");
        final long value = Long.parseLong(serialized.substring(0, serialized.length() - 1));
        final char unit = serialized.charAt(serialized.length() - 1);
        switch (unit) {
            case 'n':
                return TimeUnit.NANOSECONDS.toNanos(value);
            case 'u':
                return TimeUnit.MICROSECONDS.toNanos(value);
            case 'm':
                return TimeUnit.MILLISECONDS.toNanos(value);
            case 'S':
                return TimeUnit.SECONDS.toNanos(value);
            case 'M':
                return TimeUnit.MINUTES.toNanos(value);
            case 'H':
                return TimeUnit.HOURS.toNanos(value);
            default:
                throw new IllegalArgumentException(String.format("Invalid timeout unit: %s", unit));
        }
    }
1083006
def _build_str_from_time_items(items):
    
    if not items:
        return None
    items = [int(item) for item in items if item]
    items = items + [0 for _ in xrange(6-len(items))]
    return '%d-%02d-%02d %02d:%02d:%02d' % (items[0], items[1], items[2], items[3], items[4], items[5])
573066
function serializeTags( lineNumber, tags ) {

        return tags.split( /\n/ )
        .reduce( function ( acc, line, index ) {

            if ( !index || rTagName.test( line ) ) {
                acc.push( `${line}\n` );
            }
            else {
                acc[ acc.length - 1 ] += `${line}\n`;
            }

            return acc;

        }, [] )
        .map( function ( block ) {

            const trimmed = block.trim();
            const tag = block.match( rTagName )[0];

            const result = {
                line: lineNumber,
                tag: tag.replace( patterns.tagPrefix, '' ),
                value: trimmed.replace( tag, '' ).replace( rLeadSpaces, '' ),
                valueParsed: [],
                source: trimmed
            };

            lineNumber = lineNumber + getLinesLength( block );

            return result;
        })
        .map( function ( tag ) {

            const parser = parsers[ tag.tag ];

            if ( parser ) {

                try {

                    tag.valueParsed = parser( tag.value );
                }
                catch ( err ) {

                    tag.error = err;
                }
            }

            return tag;
        });
    }
751034
static public long unpackLong(DataInput in) throws IOException {
        long ret = 0;
        byte v;
        do{
            v = in.readByte();
            ret = (ret<<7 ) | (v & 0x7F);
        }while((v&0x80)==0);

        return ret;
    }
1260009
private void pack(String data) {
        byte[] bytes = data.getBytes(Constants.UTF8);
        buffer.put(getLengthDescriptor(bytes.length));
        buffer.put(bytes);
    }
1064068
def wrap_as_stream(item):
    
    if not PY3:
        return StringIO(item)
    if isinstance(item, str):
        return StringIO(item)
    elif isinstance(item, bytes):
        return BytesIO(item)
    raise ValueError('{} is not wrappable!'.format(type(item).__name__))
570013
def pack(x: Any) -> bytes:
    """"""
    try:
        return msgpack.packb(x, default=encoders)
    except TypeError as exc:
        message = ('Serialization error, check the data passed to a do_ command. '
                   'Cannot serialize this object:\n') + str(exc)[16:]
        raise SerializationError(message)