本文整理匯總了Python中google.protobuf.internal.wire_format.ZigZagDecode方法的典型用法代碼示例。如果您正苦於以下問題:Python wire_format.ZigZagDecode方法的具體用法?Python wire_format.ZigZagDecode怎麽用?Python wire_format.ZigZagDecode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.protobuf.internal.wire_format
的用法示例。
在下文中一共展示了wire_format.ZigZagDecode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testZigZagDecode
# 需要導入模塊: from google.protobuf.internal import wire_format [as 別名]
# 或者: from google.protobuf.internal.wire_format import ZigZagDecode [as 別名]
def testZigZagDecode(self):
Z = wire_format.ZigZagDecode
self.assertEqual(0, Z(0))
self.assertEqual(-1, Z(1))
self.assertEqual(1, Z(2))
self.assertEqual(-2, Z(3))
self.assertEqual(2, Z(4))
self.assertEqual(0x7fffffff, Z(0xfffffffe))
self.assertEqual(-0x80000000, Z(0xffffffff))
self.assertEqual(0x7fffffffffffffff, Z(0xfffffffffffffffe))
self.assertEqual(-0x8000000000000000, Z(0xffffffffffffffff))
self.assertRaises(TypeError, Z, None)
self.assertRaises(TypeError, Z, 'abcd')
self.assertRaises(TypeError, Z, 0.0)
self.assertRaises(TypeError, Z, object())
示例2: _ModifiedDecoder
# 需要導入模塊: from google.protobuf.internal import wire_format [as 別名]
# 或者: from google.protobuf.internal.wire_format import ZigZagDecode [as 別名]
def _ModifiedDecoder(wire_type, decode_value, modify_value):
"""Like SimpleDecoder but additionally invokes modify_value on every value
before storing it. Usually modify_value is ZigZagDecode.
"""
# Reusing _SimpleDecoder is slightly slower than copying a bunch of code, but
# not enough to make a significant difference.
def InnerDecode(buffer, pos):
(result, new_pos) = decode_value(buffer, pos)
return (modify_value(result), new_pos)
return _SimpleDecoder(wire_type, InnerDecode)
示例3: ReadSInt64
# 需要導入模塊: from google.protobuf.internal import wire_format [as 別名]
# 或者: from google.protobuf.internal.wire_format import ZigZagDecode [as 別名]
def ReadSInt64(self):
return wire_format.ZigZagDecode(self.ReadVarint())
示例4: decode_svarint
# 需要導入模塊: from google.protobuf.internal import wire_format [as 別名]
# 或者: from google.protobuf.internal.wire_format import ZigZagDecode [as 別名]
def decode_svarint(buf, pos):
"""Decode bytearray into a long."""
output, pos = decode_uvarint(buf, pos)
# zigzag encode value
return wire_format.ZigZagDecode(output), pos