wrappers.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:harbour-sailfinder 作者: DylanVanAssche 项目源码 文件源码
def parse_protobuf(self, proto_type):
        """Parse the data into an instance of proto_type."""
        if 'protobuf' not in self.environ.get('CONTENT_TYPE', ''):
            raise BadRequest('Not a Protobuf request')

        obj = proto_type()
        try:
            obj.ParseFromString(self.data)
        except Exception:
            raise BadRequest("Unable to parse Protobuf request")

        # Fail if not all required fields are set
        if self.protobuf_check_initialization and not obj.IsInitialized():
            raise BadRequest("Partial Protobuf request")

        return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号