当前位置: 首页>>代码示例>>Python>>正文


Python msgpack.loads方法代码示例

本文整理汇总了Python中pip._vendor.msgpack.loads方法的典型用法代码示例。如果您正苦于以下问题:Python msgpack.loads方法的具体用法?Python msgpack.loads怎么用?Python msgpack.loads使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip._vendor.msgpack的用法示例。


在下文中一共展示了msgpack.loads方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _loads_v2

# 需要导入模块: from pip._vendor import msgpack [as 别名]
# 或者: from pip._vendor.msgpack import loads [as 别名]
def _loads_v2(self, request, data):
        try:
            cached = json.loads(zlib.decompress(data).decode("utf8"))
        except (ValueError, zlib.error):
            return

        # We need to decode the items that we've base64 encoded
        cached["response"]["body"] = _b64_decode_bytes(
            cached["response"]["body"]
        )
        cached["response"]["headers"] = dict(
            (_b64_decode_str(k), _b64_decode_str(v))
            for k, v in cached["response"]["headers"].items()
        )
        cached["response"]["reason"] = _b64_decode_str(
            cached["response"]["reason"],
        )
        cached["vary"] = dict(
            (_b64_decode_str(k), _b64_decode_str(v) if v is not None else v)
            for k, v in cached["vary"].items()
        )

        return self.prepare_response(request, cached) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:25,代码来源:serialize.py

示例2: _loads_v2

# 需要导入模块: from pip._vendor import msgpack [as 别名]
# 或者: from pip._vendor.msgpack import loads [as 别名]
def _loads_v2(self, request, data):
        try:
            cached = json.loads(zlib.decompress(data).decode("utf8"))
        except (ValueError, zlib.error):
            return

        # We need to decode the items that we've base64 encoded
        cached["response"]["body"] = _b64_decode_bytes(cached["response"]["body"])
        cached["response"]["headers"] = dict(
            (_b64_decode_str(k), _b64_decode_str(v))
            for k, v in cached["response"]["headers"].items()
        )
        cached["response"]["reason"] = _b64_decode_str(cached["response"]["reason"])
        cached["vary"] = dict(
            (_b64_decode_str(k), _b64_decode_str(v) if v is not None else v)
            for k, v in cached["vary"].items()
        )

        return self.prepare_response(request, cached) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:21,代码来源:serialize.py

示例3: loads

# 需要导入模块: from pip._vendor import msgpack [as 别名]
# 或者: from pip._vendor.msgpack import loads [as 别名]
def loads(self, request, data):
        # Short circuit if we've been given an empty set of data
        if not data:
            return

        # Determine what version of the serializer the data was serialized
        # with
        try:
            ver, data = data.split(b",", 1)
        except ValueError:
            ver = b"cc=0"

        # Make sure that our "ver" is actually a version and isn't a false
        # positive from a , being in the data stream.
        if ver[:3] != b"cc=":
            data = ver + data
            ver = b"cc=0"

        # Get the version number out of the cc=N
        ver = ver.split(b"=", 1)[-1].decode("ascii")

        # Dispatch to the actual load method for the given version
        try:
            return getattr(self, "_loads_v{0}".format(ver))(request, data)
        except AttributeError:
            # This is a version we don't have a loads function for, so we'll
            # just treat it as a miss and return None
            return 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:30,代码来源:serialize.py

示例4: _loads_v1

# 需要导入模块: from pip._vendor import msgpack [as 别名]
# 或者: from pip._vendor.msgpack import loads [as 别名]
def _loads_v1(self, request, data):
        try:
            cached = pickle.loads(data)
        except ValueError:
            return

        return self.prepare_response(request, cached) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:9,代码来源:serialize.py

示例5: _loads_v4

# 需要导入模块: from pip._vendor import msgpack [as 别名]
# 或者: from pip._vendor.msgpack import loads [as 别名]
def _loads_v4(self, request, data):
        try:
            cached = msgpack.loads(data, encoding='utf-8')
        except ValueError:
            return

        return self.prepare_response(request, cached) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:9,代码来源:serialize.py

示例6: loads

# 需要导入模块: from pip._vendor import msgpack [as 别名]
# 或者: from pip._vendor.msgpack import loads [as 别名]
def loads(self, request, data):
        # Short circuit if we've been given an empty set of data
        if not data:
            return

        # Determine what version of the serializer the data was serialized
        # with
        try:
            ver, data = data.split(b",", 1)
        except ValueError:
            ver = b"cc=0"

        # Make sure that our "ver" is actually a version and isn't a false
        # positive from a , being in the data stream.
        if ver[:3] != b"cc=":
            data = ver + data
            ver = b"cc=0"

        # Get the version number out of the cc=N
        ver = ver.split(b"=", 1)[-1].decode("ascii")

        # Dispatch to the actual load method for the given version
        try:
            return getattr(self, "_loads_v{}".format(ver))(request, data)

        except AttributeError:
            # This is a version we don't have a loads function for, so we'll
            # just treat it as a miss and return None
            return 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:31,代码来源:serialize.py


注:本文中的pip._vendor.msgpack.loads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。