コード例 #1
0
def unpackb(packed, object_hook=decode, **kwargs):
    """
    Unpack a packed object.
    """

    kwargs['object_hook'] = object_hook
    return _unpacker.unpackb(packed, **kwargs)
コード例 #2
0
def unpackb(packed, object_hook=decode, encoding='utf-8', **kwargs):
    """
    Unpack a packed object.
    """

    kwargs['object_hook'] = object_hook
    return _unpacker.unpackb(packed, encoding=encoding, **kwargs)
コード例 #3
0
ファイル: msgpack_numpy.py プロジェクト: smg000/slnt2
def unpackb(packed, object_hook=decode, encoding='utf-8', **kwargs):
    """
    Unpack a packed object.
    """

    kwargs['object_hook'] = object_hook
    return _unpacker.unpackb(packed, encoding=encoding, **kwargs)
コード例 #4
0
def unpackb(packed, object_hook=decode, **kwargs):
    """
    Unpack a packed object.
    """

    kwargs['object_hook'] = object_hook
    return _unpacker.unpackb(packed, **kwargs)
コード例 #5
0
def unpackb(packed, object_hook=decode, encoding="utf-8", **kwargs):
    """
    Unpack a packed object.
    """

    kwargs["object_hook"] = object_hook
    return _unpacker.unpackb(packed, encoding=encoding, **kwargs)
コード例 #6
0
def unpackb(packed, **kwargs):
    """
    Unpack a packed object.
    """

    object_hook = kwargs.get('object_hook')
    kwargs['object_hook'] = functools.partial(decode, chain=object_hook)
    return _unpacker.unpackb(packed, **kwargs)
コード例 #7
0
def unpack(stream, **kwargs):
    """
    Unpack an object from `stream`.

    Raises `ExtraData` when `packed` contains extra bytes.
    See :class:`Unpacker` for options.
    """
    return unpackb(stream.read(), **kwargs)
コード例 #8
0
ファイル: __init__.py プロジェクト: lmregus/Portfolio
def unpack(stream, **kwargs):
    """
    Unpack an object from `stream`.

    Raises `ExtraData` when `stream` contains extra bytes.
    See :class:`Unpacker` for options.
    """
    data = stream.read()
    return unpackb(data, **kwargs)
コード例 #9
0
ファイル: benchmark.py プロジェクト: zhurs/msgpack-python
def simple(name, data):
    if has_ext:
        profile("packing %s (ext)" % name, lambda: _packer.packb(data))
    profile('packing %s (fallback)' % name, lambda: fallback.packb(data))

    data = fallback.packb(data)
    if has_ext:
        profile('unpacking %s (ext)' % name, lambda: _unpacker.unpackb(data))
    profile('unpacking %s (fallback)' % name, lambda: fallback.unpackb(data))
コード例 #10
0
def simple(name, data):
    if has_ext:
        packer = _cmsgpack.Packer()
        profile("packing %s (ext)" % name, lambda: packer.pack(data))
    packer = fallback.Packer()
    profile("packing %s (fallback)" % name, lambda: packer.pack(data))

    data = packer.pack(data)
    if has_ext:
        profile("unpacking %s (ext)" % name, lambda: _cmsgpack.unpackb(data))
    profile("unpacking %s (fallback)" % name, lambda: fallback.unpackb(data))
コード例 #11
0
    def _read(self):
        while self._buffer_size > self._unpacker.tell():
            # map_start_indicator
            self._read_next()
            map_name = self._read_next_string()
            LOG.trace(f"Reading map {map_name}")
            records = {}
            self._tables[map_name] = records

            # read_version
            self._read_next()

            # read_count
            read_count = self._read_next()
            assert read_count == 0, f"Unexpected read count: {read_count}"

            write_count = self._read_next()
            if write_count:
                for _ in range(write_count):
                    k = self._read_next_entry()
                    val = self._read_next_entry()
                    if map_name in self._msgpacked_tables:
                        k = msgpack.unpackb(k, **UNPACK_ARGS)
                        val = msgpack.unpackb(val, **UNPACK_ARGS)
                    if map_name == NODES_TABLE_NAME:
                        k = str(k)
                    records[k] = val

            remove_count = self._read_next()
            if remove_count:
                for _ in range(remove_count):
                    k = self._read_next_entry()
                    if map_name in self._msgpacked_tables:
                        k = msgpack.unpackb(k, **UNPACK_ARGS)
                    records[k] = None

            LOG.trace(
                f"Found {read_count} reads, {write_count} writes, and {remove_count} removes"
            )
コード例 #12
0
def extract_msgpacked_data(data: bytes):
    return msgpack.unpackb(data, **UNPACK_ARGS)