本文整理汇总了Python中google.protobuf.internal.wire_format.UnpackTag方法的典型用法代码示例。如果您正苦于以下问题:Python wire_format.UnpackTag方法的具体用法?Python wire_format.UnpackTag怎么用?Python wire_format.UnpackTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.protobuf.internal.wire_format
的用法示例。
在下文中一共展示了wire_format.UnpackTag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReadFieldNumberAndWireType
# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import UnpackTag [as 别名]
def ReadFieldNumberAndWireType(self):
return wire_format.UnpackTag(self.ReadVarint())
示例2: testUnpackTag
# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import UnpackTag [as 别名]
def testUnpackTag(self):
# Test field numbers that will require various varint sizes.
for expected_field_number in (1, 15, 16, 2047, 2048):
for expected_wire_type in range(6): # Highest-numbered wiretype is 5.
field_number, wire_type = wire_format.UnpackTag(
wire_format.PackTag(expected_field_number, expected_wire_type))
self.assertEqual(expected_field_number, field_number)
self.assertEqual(expected_wire_type, wire_type)
self.assertRaises(TypeError, wire_format.UnpackTag, None)
self.assertRaises(TypeError, wire_format.UnpackTag, 'abc')
self.assertRaises(TypeError, wire_format.UnpackTag, 0.0)
self.assertRaises(TypeError, wire_format.UnpackTag, object())
示例3: _DecodeUnknownFieldSet
# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import UnpackTag [as 别名]
def _DecodeUnknownFieldSet(buffer, pos, end_pos=None):
"""Decode UnknownFieldSet. Returns the UnknownFieldSet and new position."""
unknown_field_set = containers.UnknownFieldSet()
while end_pos is None or pos < end_pos:
(tag_bytes, pos) = ReadTag(buffer, pos)
(tag, _) = _DecodeVarint(tag_bytes, 0)
field_number, wire_type = wire_format.UnpackTag(tag)
if wire_type == wire_format.WIRETYPE_END_GROUP:
break
(data, pos) = _DecodeUnknownField(buffer, pos, wire_type)
# pylint: disable=protected-access
unknown_field_set._add(field_number, wire_type, data)
return (unknown_field_set, pos)