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


Python wire_format.WIRETYPE_END_GROUP属性代码示例

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


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

示例1: GroupEncoder

# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import WIRETYPE_END_GROUP [as 别名]
def GroupEncoder(field_number, is_repeated, is_packed):
  """Returns an encoder for a group field."""

  start_tag = TagBytes(field_number, wire_format.WIRETYPE_START_GROUP)
  end_tag = TagBytes(field_number, wire_format.WIRETYPE_END_GROUP)
  assert not is_packed
  if is_repeated:
    def EncodeRepeatedField(write, value, deterministic):
      for element in value:
        write(start_tag)
        element._InternalSerialize(write, deterministic)
        write(end_tag)
    return EncodeRepeatedField
  else:
    def EncodeField(write, value, deterministic):
      write(start_tag)
      value._InternalSerialize(write, deterministic)
      return write(end_tag)
    return EncodeField 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:encoder.py

示例2: GroupEncoder

# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import WIRETYPE_END_GROUP [as 别名]
def GroupEncoder(field_number, is_repeated, is_packed):
  """Returns an encoder for a group field."""

  start_tag = TagBytes(field_number, wire_format.WIRETYPE_START_GROUP)
  end_tag = TagBytes(field_number, wire_format.WIRETYPE_END_GROUP)
  assert not is_packed
  if is_repeated:
    def EncodeRepeatedField(write, value):
      for element in value:
        write(start_tag)
        element._InternalSerialize(write)
        write(end_tag)
    return EncodeRepeatedField
  else:
    def EncodeField(write, value):
      write(start_tag)
      value._InternalSerialize(write)
      return write(end_tag)
    return EncodeField 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:21,代码来源:encoder.py

示例3: _DecodeUnknownField

# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import WIRETYPE_END_GROUP [as 别名]
def _DecodeUnknownField(buffer, pos, wire_type):
  """Decode a unknown field.  Returns the UnknownField and new position."""

  if wire_type == wire_format.WIRETYPE_VARINT:
    (data, pos) = _DecodeVarint(buffer, pos)
  elif wire_type == wire_format.WIRETYPE_FIXED64:
    (data, pos) = _DecodeFixed64(buffer, pos)
  elif wire_type == wire_format.WIRETYPE_FIXED32:
    (data, pos) = _DecodeFixed32(buffer, pos)
  elif wire_type == wire_format.WIRETYPE_LENGTH_DELIMITED:
    (size, pos) = _DecodeVarint(buffer, pos)
    data = buffer[pos:pos+size].tobytes()
    pos += size
  elif wire_type == wire_format.WIRETYPE_START_GROUP:
    (data, pos) = _DecodeUnknownFieldSet(buffer, pos)
  elif wire_type == wire_format.WIRETYPE_END_GROUP:
    return (0, -1)
  else:
    raise _DecodeError('Wrong wire type in tag.')

  return (data, pos) 
开发者ID:luci,项目名称:luci-py,代码行数:23,代码来源:decoder.py

示例4: MessageSetItemEncoder

# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import WIRETYPE_END_GROUP [as 别名]
def MessageSetItemEncoder(field_number):
  """Encoder for extensions of MessageSet.

  The message set message looks like this:
    message MessageSet {
      repeated group Item = 1 {
        required int32 type_id = 2;
        required string message = 3;
      }
    }
  """
  start_bytes = b"".join([
      TagBytes(1, wire_format.WIRETYPE_START_GROUP),
      TagBytes(2, wire_format.WIRETYPE_VARINT),
      _VarintBytes(field_number),
      TagBytes(3, wire_format.WIRETYPE_LENGTH_DELIMITED)])
  end_bytes = TagBytes(1, wire_format.WIRETYPE_END_GROUP)
  local_EncodeVarint = _EncodeVarint

  def EncodeField(write, value, deterministic):
    write(start_bytes)
    local_EncodeVarint(write, value.ByteSize(), deterministic)
    value._InternalSerialize(write, deterministic)
    return write(end_bytes)

  return EncodeField


# --------------------------------------------------------------------
# As before, Map is special. 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:32,代码来源:encoder.py

示例5: MessageSetItemEncoder

# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import WIRETYPE_END_GROUP [as 别名]
def MessageSetItemEncoder(field_number):
  """Encoder for extensions of MessageSet.

  The message set message looks like this:
    message MessageSet {
      repeated group Item = 1 {
        required int32 type_id = 2;
        required string message = 3;
      }
    }
  """
  start_bytes = b"".join([
      TagBytes(1, wire_format.WIRETYPE_START_GROUP),
      TagBytes(2, wire_format.WIRETYPE_VARINT),
      _VarintBytes(field_number),
      TagBytes(3, wire_format.WIRETYPE_LENGTH_DELIMITED)])
  end_bytes = TagBytes(1, wire_format.WIRETYPE_END_GROUP)
  local_EncodeVarint = _EncodeVarint

  def EncodeField(write, value):
    write(start_bytes)
    local_EncodeVarint(write, value.ByteSize())
    value._InternalSerialize(write)
    return write(end_bytes)

  return EncodeField


# --------------------------------------------------------------------
# As before, Map is special. 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:32,代码来源:encoder.py

示例6: MessageSetItemEncoder

# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import WIRETYPE_END_GROUP [as 别名]
def MessageSetItemEncoder(field_number):
  """Encoder for extensions of MessageSet.

  The message set message looks like this:
    message MessageSet {
      repeated group Item = 1 {
        required int32 type_id = 2;
        required string message = 3;
      }
    }
  """
  start_bytes = "".encode("latin1").join([  ##PY25
##!PY25  start_bytes = b"".join([
      TagBytes(1, wire_format.WIRETYPE_START_GROUP),
      TagBytes(2, wire_format.WIRETYPE_VARINT),
      _VarintBytes(field_number),
      TagBytes(3, wire_format.WIRETYPE_LENGTH_DELIMITED)])
  end_bytes = TagBytes(1, wire_format.WIRETYPE_END_GROUP)
  local_EncodeVarint = _EncodeVarint

  def EncodeField(write, value):
    write(start_bytes)
    local_EncodeVarint(write, value.ByteSize())
    value._InternalSerialize(write)
    return write(end_bytes)

  return EncodeField 
开发者ID:katharosada,项目名称:botchallenge,代码行数:29,代码来源:encoder.py

示例7: _DecodeUnknownFieldSet

# 需要导入模块: from google.protobuf.internal import wire_format [as 别名]
# 或者: from google.protobuf.internal.wire_format import WIRETYPE_END_GROUP [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.WIRETYPE_END_GROUP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。