#
# Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
-from bt2 import native_bt, utils
+from bt2 import native_bt
+from bt2 import utils as bt2_utils
from bt2 import object as bt2_object
from bt2 import packet as bt2_packet
from bt2 import stream_class as bt2_stream_class
class _StreamConst(bt2_object._SharedObject):
- _get_ref = staticmethod(native_bt.stream_get_ref)
- _put_ref = staticmethod(native_bt.stream_put_ref)
+ @staticmethod
+ def _get_ref(ptr):
+ native_bt.stream_get_ref(ptr)
+
+ @staticmethod
+ def _put_ref(ptr):
+ native_bt.stream_put_ref(ptr)
+
_borrow_class_ptr = staticmethod(native_bt.stream_borrow_class_const)
_borrow_user_attributes_ptr = staticmethod(
native_bt.stream_borrow_user_attributes_const
def create_packet(self):
if not self.cls.supports_packets:
raise ValueError(
- 'cannot create packet: stream class does not support packets'
+ "cannot create packet: stream class does not support packets"
)
packet_ptr = native_bt.packet_create(self._ptr)
if packet_ptr is None:
- raise bt2._MemoryError('cannot create packet object')
+ raise bt2._MemoryError("cannot create packet object")
return bt2_packet._Packet._create_from_ptr(packet_ptr)
def _user_attributes(self, user_attributes):
value = bt2_value.create_value(user_attributes)
- utils._check_type(value, bt2_value.MapValue)
+ bt2_utils._check_type(value, bt2_value.MapValue)
native_bt.stream_set_user_attributes(self._ptr, value._ptr)
_user_attributes = property(
)
def _name(self, name):
- utils._check_str(name)
+ bt2_utils._check_str(name)
native_bt.stream_set_name(self._ptr, name)
_name = property(fget=_StreamConst.name.fget, fset=_name)