本文整理汇总了Python中google.protobuf.internal.encoder.py方法的典型用法代码示例。如果您正苦于以下问题:Python encoder.py方法的具体用法?Python encoder.py怎么用?Python encoder.py使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.protobuf.internal.encoder
的用法示例。
在下文中一共展示了encoder.py方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _SkipVarint
# 需要导入模块: from google.protobuf.internal import encoder [as 别名]
# 或者: from google.protobuf.internal.encoder import py [as 别名]
def _SkipVarint(buffer, pos, end):
"""Skip a varint value. Returns the new position."""
# Previously ord(buffer[pos]) raised IndexError when pos is out of range.
# With this code, ord(b'') raises TypeError. Both are handled in
# python_message.py to generate a 'Truncated message' error.
while ord(buffer[pos:pos+1]) & 0x80:
pos += 1
pos += 1
if pos > end:
raise _DecodeError('Truncated message.')
return pos
示例2: _SkipVarint
# 需要导入模块: from google.protobuf.internal import encoder [as 别名]
# 或者: from google.protobuf.internal.encoder import py [as 别名]
def _SkipVarint(buffer, pos, end):
"""Skip a varint value. Returns the new position."""
# Previously ord(buffer[pos]) raised IndexError when pos is out of range.
# With this code, ord(b'') raises TypeError. Both are handled in
# python_message.py to generate a 'Truncated message' error.
while ord(buffer[pos:pos+1].tobytes()) & 0x80:
pos += 1
pos += 1
if pos > end:
raise _DecodeError('Truncated message.')
return pos