コード例 #1
0
 def serialize(dec):
     sign, digits, exponent = dec.as_tuple()
     unscaled = int(''.join([str(digit) for digit in digits]))
     if sign:
         unscaled *= -1
     scale = int32_pack(-exponent)
     unscaled = varint_pack(unscaled)
     return scale + unscaled
コード例 #2
0
ファイル: cqltypes.py プロジェクト: JeremyOT/python-driver
 def serialize(dec):
     try:
         sign, digits, exponent = dec.as_tuple()
     except AttributeError:
         raise TypeError("Non-Decimal type received for Decimal value")
     unscaled = int(''.join([str(digit) for digit in digits]))
     if sign:
         unscaled *= -1
     scale = int32_pack(-exponent)
     unscaled = varint_pack(unscaled)
     return scale + unscaled
コード例 #3
0
 def serialize(dec, protocol_version):
     try:
         sign, digits, exponent = dec.as_tuple()
     except AttributeError:
         raise TypeError("Non-Decimal type received for Decimal value")
     unscaled = int(''.join([str(digit) for digit in digits]))
     if sign:
         unscaled *= -1
     scale = int32_pack(-exponent)
     unscaled = varint_pack(unscaled)
     return scale + unscaled
コード例 #4
0
ファイル: cqltypes.py プロジェクト: ShayanIshaq/Repo_test
 def serialize(dec, protocol_version):
     try:
         sign, digits, exponent = dec.as_tuple()
     except AttributeError:
         try:
             sign, digits, exponent = Decimal(dec).as_tuple()
         except Exception:
             raise TypeError("Invalid type for Decimal value: %r", dec)
     unscaled = int(''.join([str(digit) for digit in digits]))
     if sign:
         unscaled *= -1
     scale = int32_pack(-exponent)
     unscaled = varint_pack(unscaled)
     return scale + unscaled
コード例 #5
0
ファイル: cqltypes.py プロジェクト: pentve/python-driver
 def serialize(dec, protocol_version):
     try:
         sign, digits, exponent = dec.as_tuple()
     except AttributeError:
         try:
             sign, digits, exponent = Decimal(dec).as_tuple()
         except Exception:
             raise TypeError("Invalid type for Decimal value: %r", dec)
     unscaled = int("".join([str(digit) for digit in digits]))
     if sign:
         unscaled *= -1
     scale = int32_pack(-exponent)
     unscaled = varint_pack(unscaled)
     return scale + unscaled
コード例 #6
0
ファイル: cqltypes.py プロジェクト: sakura-sky/python-driver
 def serialize(byts, protocol_version):
     return varint_pack(byts)
コード例 #7
0
ファイル: cqltypes.py プロジェクト: ShayanIshaq/Repo_test
 def serialize(byts, protocol_version):
     return varint_pack(byts)