def __rpow__(self, base):
return self._extract_value(base) ** self._value
- def __iadd__(self, other):
- self.value = self + other
- return self
-
- def __isub__(self, other):
- self.value = self - other
- return self
-
- def __imul__(self, other):
- self.value = self * other
- return self
-
- def __itruediv__(self, other):
- self.value = self / other
- return self
-
- def __ifloordiv__(self, other):
- self.value = self // other
- return self
-
- def __imod__(self, other):
- self.value = self % other
- return self
-
- def __ipow__(self, other):
- self.value = self ** other
- return self
-
class _IntegralField(_NumericField, numbers.Integral):
def __lshift__(self, other):
def __invert__(self):
return ~self._value
- def __ilshift__(self, other):
- self.value = self << other
- return self
-
- def __irshift__(self, other):
- self.value = self >> other
- return self
-
- def __iand__(self, other):
- self.value = self & other
- return self
-
- def __ixor__(self, other):
- self.value = self ^ other
- return self
-
- def __ior__(self, other):
- self.value = self | other
- return self
-
class _IntegerField(_IntegralField, _Field):
pass
_NAME = 'Unsigned integer'
def _value_to_int(self, value):
- if not isinstance(value, numbers.Real):
- raise TypeError('expecting a real number object')
+ if not isinstance(value, numbers.Integral):
+ raise TypeError('expecting an integral number object')
value = int(value)
utils._check_uint64(value)
_NAME = 'Signed integer'
def _value_to_int(self, value):
- if not isinstance(value, numbers.Real):
- raise TypeError('expecting a real number object')
+ if not isinstance(value, numbers.Integral):
+ raise TypeError('expecting an integral number object')
value = int(value)
utils._check_int64(value)
@property
def labels(self):
- ret, labels = self._get_mapping_labels(self._ptr)
- utils._handle_ret(ret, "cannot get label for enumeration field")
+ status, labels = self._get_mapping_labels(self._ptr)
+ utils._handle_func_status(status,
+ "cannot get label for enumeration field")
assert labels is not None
return labels
def __iadd__(self, value):
value = self._value_to_str(value)
- ret = native_bt.field_string_append(self._ptr, value)
- utils._handle_ret(ret, "cannot append to string field object's value")
+ status = native_bt.field_string_append(self._ptr, value)
+ utils._handle_func_status(status,
+ "cannot append to string field object's value")
return self
self._owner_put_ref)
def __setitem__(self, index, value):
- # we can only set numbers and strings
- if not isinstance(value, (numbers.Number, _StringField, str)):
- raise TypeError('expecting number or string object')
-
# raises if index is somehow invalid
field = self[index]
def _set_length(self, length):
utils._check_uint64(length)
- ret = native_bt.field_dynamic_array_set_length(self._ptr, length)
- utils._handle_ret(ret, "cannot set dynamic array length")
+ status = native_bt.field_dynamic_array_set_length(self._ptr, length)
+ utils._handle_func_status(status, "cannot set dynamic array length")
length = property(fget=_ArrayField._get_length, fset=_set_length)