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


Python type_checkers.FIELD_TYPE_TO_WIRE_TYPE属性代码示例

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


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

示例1: CheckUnknownField

# 需要导入模块: from google.protobuf.internal import type_checkers [as 别名]
# 或者: from google.protobuf.internal.type_checkers import FIELD_TYPE_TO_WIRE_TYPE [as 别名]
def CheckUnknownField(self, name, expected_value):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.empty_message._unknown_fields:
      if tag_bytes == field_tag:
        decoder = unittest_pb2.TestAllTypes._decoders_by_tag[tag_bytes][0]
        decoder(value, 0, len(value), self.all_fields, result_dict)
    self.assertEqual(expected_value, result_dict[field_descriptor]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,代码来源:unknown_fields_test.py

示例2: GetUnknownField

# 需要导入模块: from google.protobuf.internal import type_checkers [as 别名]
# 或者: from google.protobuf.internal.type_checkers import FIELD_TYPE_TO_WIRE_TYPE [as 别名]
def GetUnknownField(self, name):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.empty_message._unknown_fields:
      if tag_bytes == field_tag:
        decoder = unittest_pb2.TestAllTypes._decoders_by_tag[tag_bytes][0]
        decoder(value, 0, len(value), self.all_fields, result_dict)
    return result_dict[field_descriptor] 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:12,代码来源:unknown_fields_test.py

示例3: GetField

# 需要导入模块: from google.protobuf.internal import type_checkers [as 别名]
# 或者: from google.protobuf.internal.type_checkers import FIELD_TYPE_TO_WIRE_TYPE [as 别名]
def GetField(self, name):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.unknown_fields:
      if tag_bytes == field_tag:
        decoder = unittest_pb2.TestAllTypes._decoders_by_tag[tag_bytes][0]
        decoder(value, 0, len(value), self.all_fields, result_dict)
    return result_dict[field_descriptor] 
开发者ID:sklearn-theano,项目名称:sklearn-theano,代码行数:12,代码来源:unknown_fields_test.py

示例4: _AttachFieldHelpers

# 需要导入模块: from google.protobuf.internal import type_checkers [as 别名]
# 或者: from google.protobuf.internal.type_checkers import FIELD_TYPE_TO_WIRE_TYPE [as 别名]
def _AttachFieldHelpers(cls, field_descriptor):
  is_repeated = (field_descriptor.label == _FieldDescriptor.LABEL_REPEATED)
  is_packed = (field_descriptor.has_options and
               field_descriptor.GetOptions().packed)

  if _IsMessageSetExtension(field_descriptor):
    field_encoder = encoder.MessageSetItemEncoder(field_descriptor.number)
    sizer = encoder.MessageSetItemSizer(field_descriptor.number)
  else:
    field_encoder = type_checkers.TYPE_TO_ENCODER[field_descriptor.type](
        field_descriptor.number, is_repeated, is_packed)
    sizer = type_checkers.TYPE_TO_SIZER[field_descriptor.type](
        field_descriptor.number, is_repeated, is_packed)

  field_descriptor._encoder = field_encoder
  field_descriptor._sizer = sizer
  field_descriptor._default_constructor = _DefaultValueConstructorForField(
      field_descriptor)

  def AddDecoder(wiretype, is_packed):
    tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)
    cls._decoders_by_tag[tag_bytes] = (
        type_checkers.TYPE_TO_DECODER[field_descriptor.type](
            field_descriptor.number, is_repeated, is_packed,
            field_descriptor, field_descriptor._default_constructor))

  AddDecoder(type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type],
             False)

  if is_repeated and wire_format.IsTypePackable(field_descriptor.type):
    # To support wire compatibility of adding packed = true, add a decoder for
    # packed values regardless of the field's options.
    AddDecoder(wire_format.WIRETYPE_LENGTH_DELIMITED, True) 
开发者ID:katharosada,项目名称:botchallenge,代码行数:35,代码来源:python_message.py

示例5: GetField

# 需要导入模块: from google.protobuf.internal import type_checkers [as 别名]
# 或者: from google.protobuf.internal.type_checkers import FIELD_TYPE_TO_WIRE_TYPE [as 别名]
def GetField(self, name):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.unknown_fields:
      if tag_bytes == field_tag:
        decoder = unittest_pb2.TestAllTypes._decoders_by_tag[tag_bytes]
        decoder(value, 0, len(value), self.all_fields, result_dict)
    return result_dict[field_descriptor] 
开发者ID:katharosada,项目名称:botchallenge,代码行数:12,代码来源:unknown_fields_test.py


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