當前位置: 首頁>>代碼示例>>Python>>正文


Python wire_format.UnpackTag方法代碼示例

本文整理匯總了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()) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:4,代碼來源:reflection_test.py

示例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()) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:15,代碼來源:wire_format_test.py

示例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) 
開發者ID:luci,項目名稱:luci-py,代碼行數:17,代碼來源:decoder.py


注:本文中的google.protobuf.internal.wire_format.UnpackTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。