Пример #1
0
  def test8BinText(self):
    bv = DataStructs.ExplicitBitVect(32)
    bv.SetBit(0)
    bv.SetBit(1)
    bv.SetBit(17)
    bv.SetBit(23)
    bv.SetBit(31)

    bv2 = DataStructs.CreateFromBinaryText(DataStructs.BitVectToBinaryText(bv))
    self.assertEqual(bv, bv2)

    bv2 = DataStructs.CreateFromBinaryText("")
    self.assertEqual(bv2.GetNumBits(), 0)
Пример #2
0
 def to_python(self, value):
     if value is None or isinstance(value, ExplicitBitVect):
         return value
     elif isinstance(value, six.buffer_types):
         return DataStructs.CreateFromBinaryText(bytes(value))
     else:
         raise ValidationError("Invalid input for a Bfp instance")
Пример #3
0
 def to_python(self, value):
     if value is None or isinstance(value, ExplicitBitVect):
         return value
     elif isinstance(value, (bytes, bytearray, memoryview)):
         return DataStructs.CreateFromBinaryText(bytes(value))
     else:
         raise ValidationError("Invalid input for a Bfp instance")
Пример #4
0
 def process(value):
     if value is None:
         return value
     elif isinstance(value, memoryview):
         return DataStructs.CreateFromBinaryText(bytes(value))
     else:
         raise RuntimeError(
             "Unexpected row value type for a Bfp instance")
Пример #5
0
 def from_db_value(self, value, expression, connection, context):
     if value is None:
         return value
     return DataStructs.CreateFromBinaryText(bytes(value))