python: standardize intra-bt2 imports
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 19 Jun 2023 18:11:04 +0000 (14:11 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 21 Sep 2023 17:29:44 +0000 (13:29 -0400)
A subsequent patch wants to refer to `object` (the Python type), but it
is shadowed by our `from bt2 import object` import.  It seems like a
good time to standardize how we import intra-bt2 modules, to use the
pattern:

    from bt2 import potato as bt2_potato

Note that I didn't add the bt2_ prefix to the native_bt import, since it
would be a bit redundant.

Change-Id: Icdb4339075a1888463c4f84b292deb272ad49943
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10386
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
25 files changed:
src/bindings/python/bt2/bt2/clock_class.py
src/bindings/python/bt2/bt2/clock_snapshot.py
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/event.py
src/bindings/python/bt2/bt2/event_class.py
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/field_class.py
src/bindings/python/bt2/bt2/field_path.py
src/bindings/python/bt2/bt2/graph.py
src/bindings/python/bt2/bt2/integer_range_set.py
src/bindings/python/bt2/bt2/interrupter.py
src/bindings/python/bt2/bt2/message.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/mip.py
src/bindings/python/bt2/bt2/packet.py
src/bindings/python/bt2/bt2/plugin.py
src/bindings/python/bt2/bt2/port.py
src/bindings/python/bt2/bt2/py_plugin.py
src/bindings/python/bt2/bt2/query_executor.py
src/bindings/python/bt2/bt2/stream.py
src/bindings/python/bt2/bt2/stream_class.py
src/bindings/python/bt2/bt2/trace.py
src/bindings/python/bt2/bt2/trace_class.py
src/bindings/python/bt2/bt2/trace_collection_message_iterator.py
src/bindings/python/bt2/bt2/value.py

index 27e05f17d5adc02e9f3793a7d4acf87df400b791..576fb7cb6ba581a803b5fb57a612221dfb4764ce 100644 (file)
@@ -2,15 +2,17 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import value as bt2_value
 import uuid as uuidp
 
 
 class ClockClassOffset:
     def __init__(self, seconds=0, cycles=0):
-        utils._check_int64(seconds)
-        utils._check_int64(cycles)
+        bt2_utils._check_int64(seconds)
+        bt2_utils._check_int64(cycles)
         self._seconds = seconds
         self._cycles = cycles
 
@@ -30,7 +32,7 @@ class ClockClassOffset:
         return (self.seconds, self.cycles) == (other.seconds, other.cycles)
 
 
-class _ClockClassConst(object._SharedObject):
+class _ClockClassConst(bt2_object._SharedObject):
     @staticmethod
     def _get_ref(ptr):
         native_bt.clock_class_get_ref(ptr)
@@ -88,10 +90,10 @@ class _ClockClassConst(object._SharedObject):
         return uuidp.UUID(bytes=uuid_bytes)
 
     def cycles_to_ns_from_origin(self, cycles):
-        utils._check_uint64(cycles)
+        bt2_utils._check_uint64(cycles)
         status, ns = native_bt.clock_class_cycles_to_ns_from_origin(self._ptr, cycles)
         error_msg = "cannot convert clock value to nanoseconds from origin for given clock class"
-        utils._handle_func_status(status, error_msg)
+        bt2_utils._handle_func_status(status, error_msg)
         return ns
 
 
@@ -105,45 +107,47 @@ class _ClockClass(_ClockClassConst):
 
     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.clock_class_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
 
     def _name(self, name):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
         status = native_bt.clock_class_set_name(self._ptr, name)
-        utils._handle_func_status(status, "cannot set clock class object's name")
+        bt2_utils._handle_func_status(status, "cannot set clock class object's name")
 
     _name = property(fset=_name)
 
     def _description(self, description):
-        utils._check_str(description)
+        bt2_utils._check_str(description)
         status = native_bt.clock_class_set_description(self._ptr, description)
-        utils._handle_func_status(status, "cannot set clock class object's description")
+        bt2_utils._handle_func_status(
+            status, "cannot set clock class object's description"
+        )
 
     _description = property(fset=_description)
 
     def _frequency(self, frequency):
-        utils._check_uint64(frequency)
+        bt2_utils._check_uint64(frequency)
         native_bt.clock_class_set_frequency(self._ptr, frequency)
 
     _frequency = property(fset=_frequency)
 
     def _precision(self, precision):
-        utils._check_uint64(precision)
+        bt2_utils._check_uint64(precision)
         native_bt.clock_class_set_precision(self._ptr, precision)
 
     _precision = property(fset=_precision)
 
     def _offset(self, offset):
-        utils._check_type(offset, ClockClassOffset)
+        bt2_utils._check_type(offset, ClockClassOffset)
         native_bt.clock_class_set_offset(self._ptr, offset.seconds, offset.cycles)
 
     _offset = property(fset=_offset)
 
     def _origin_is_unix_epoch(self, origin_is_unix_epoch):
-        utils._check_bool(origin_is_unix_epoch)
+        bt2_utils._check_bool(origin_is_unix_epoch)
         native_bt.clock_class_set_origin_is_unix_epoch(
             self._ptr, int(origin_is_unix_epoch)
         )
@@ -151,7 +155,7 @@ class _ClockClass(_ClockClassConst):
     _origin_is_unix_epoch = property(fset=_origin_is_unix_epoch)
 
     def _uuid(self, uuid):
-        utils._check_type(uuid, uuidp.UUID)
+        bt2_utils._check_type(uuid, uuidp.UUID)
         native_bt.clock_class_set_uuid(self._ptr, uuid.bytes)
 
     _uuid = property(fset=_uuid)
index 6c2e3285e04ce13679dbcd817982a4384531a291..3118d996d1685c26259260368b29c648e8378a96 100644 (file)
@@ -2,14 +2,16 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 import numbers
 from bt2 import clock_class as bt2_clock_class
 import functools
 
 
 @functools.total_ordering
-class _ClockSnapshotConst(object._UniqueObject):
+class _ClockSnapshotConst(bt2_object._UniqueObject):
     @property
     def clock_class(self):
         cc_ptr = native_bt.clock_snapshot_borrow_clock_class_const(self._ptr)
@@ -23,7 +25,7 @@ class _ClockSnapshotConst(object._UniqueObject):
     @property
     def ns_from_origin(self):
         status, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot get clock snapshot's nanoseconds from origin"
         )
         return ns
index 1bb6763e1e79b916ac262fb0d21fb3e6cc22c0e3..7f907cc9beee92e1f7e9ce96a3ec5805d994eccd 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import message_iterator as bt2_message_iterator
 import collections.abc
 from bt2 import value as bt2_value
@@ -25,7 +27,7 @@ import bt2
 #     pointer to a 'bt_component_class *'.
 
 
-class _ComponentClassConst(object._SharedObject):
+class _ComponentClassConst(bt2_object._SharedObject):
     @property
     def name(self):
         ptr = self._bt_as_component_class_ptr(self._ptr)
@@ -141,7 +143,7 @@ class _ComponentPorts(collections.abc.Mapping):
         self._port_pycls = port_pycls
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         port_ptr = self._borrow_port_ptr_by_name(self._component_ptr, key)
 
         if port_ptr is None:
@@ -235,7 +237,7 @@ class _SinkComponentConst(_ComponentConst):
 
 # This is analogous to _SourceComponentClassConst, but for source
 # component objects.
-class _GenericSourceComponentConst(object._SharedObject, _SourceComponentConst):
+class _GenericSourceComponentConst(bt2_object._SharedObject, _SourceComponentConst):
     @staticmethod
     def _get_ref(ptr):
         native_bt.component_source_get_ref(ptr)
@@ -257,7 +259,7 @@ class _GenericSourceComponentConst(object._SharedObject, _SourceComponentConst):
 
 # This is analogous to _FilterComponentClassConst, but for filter
 # component objects.
-class _GenericFilterComponentConst(object._SharedObject, _FilterComponentConst):
+class _GenericFilterComponentConst(bt2_object._SharedObject, _FilterComponentConst):
     @staticmethod
     def _get_ref(ptr):
         native_bt.component_filter_get_ref(ptr)
@@ -289,7 +291,7 @@ class _GenericFilterComponentConst(object._SharedObject, _FilterComponentConst):
 
 # This is analogous to _SinkComponentClassConst, but for sink
 # component objects.
-class _GenericSinkComponentConst(object._SharedObject, _SinkComponentConst):
+class _GenericSinkComponentConst(bt2_object._SharedObject, _SinkComponentConst):
     @staticmethod
     def _get_ref(ptr):
         native_bt.component_sink_get_ref(ptr)
@@ -480,12 +482,12 @@ class _UserComponentType(type):
             return
 
         comp_cls_name = kwargs.get("name", class_name)
-        utils._check_str(comp_cls_name)
+        bt2_utils._check_str(comp_cls_name)
         comp_cls_descr = None
         comp_cls_help = None
 
         if hasattr(cls, "__doc__") and cls.__doc__ is not None:
-            utils._check_str(cls.__doc__)
+            bt2_utils._check_str(cls.__doc__)
             docstring = _trim_docstring(cls.__doc__)
             lines = docstring.splitlines()
 
@@ -864,7 +866,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst):
         )
 
     def _add_output_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._output_ports:
             raise ValueError(
@@ -875,7 +877,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst):
 
         fn = native_bt.self_component_source_add_output_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add output port to source component object"
         )
         assert self_port_ptr is not None
@@ -922,7 +924,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
         )
 
     def _add_output_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._output_ports:
             raise ValueError(
@@ -933,7 +935,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
 
         fn = native_bt.self_component_filter_add_output_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add output port to filter component object"
         )
         assert self_port_ptr
@@ -942,7 +944,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
         )
 
     def _add_input_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._input_ports:
             raise ValueError(
@@ -953,7 +955,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
 
         fn = native_bt.self_component_filter_add_input_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add input port to filter component object"
         )
         assert self_port_ptr
@@ -992,7 +994,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
         )
 
     def _add_input_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._input_ports:
             raise ValueError(
@@ -1003,7 +1005,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
 
         fn = native_bt.self_component_sink_add_input_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add input port to sink component object"
         )
         assert self_port_ptr
@@ -1012,7 +1014,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
         )
 
     def _create_message_iterator(self, input_port):
-        utils._check_type(input_port, bt2_port._UserComponentInputPort)
+        bt2_utils._check_type(input_port, bt2_port._UserComponentInputPort)
 
         if not input_port.is_connected:
             raise ValueError("input port is not connected")
@@ -1023,7 +1025,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
         ) = native_bt.bt2_message_iterator_create_from_sink_component(
             self._bt_ptr, input_port._ptr
         )
-        utils._handle_func_status(status, "cannot create message iterator object")
+        bt2_utils._handle_func_status(status, "cannot create message iterator object")
         assert msg_iter_ptr is not None
 
         return bt2_message_iterator._UserComponentInputPortMessageIterator(msg_iter_ptr)
index 81215a2069a1d398f0c61932a8d1f3a3a9868241..baec2aa57b429c2f8a19af4abc9dd6f26acbd9e4 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import event_class as bt2_event_class
 from bt2 import packet as bt2_packet
 from bt2 import stream as bt2_stream
@@ -10,7 +12,7 @@ from bt2 import field as bt2_field
 import collections.abc
 
 
-class _EventConst(object._UniqueObject, collections.abc.Mapping):
+class _EventConst(bt2_object._UniqueObject, collections.abc.Mapping):
     _borrow_class_ptr = staticmethod(native_bt.event_borrow_class_const)
     _borrow_packet_ptr = staticmethod(native_bt.event_borrow_packet_const)
     _borrow_stream_ptr = staticmethod(native_bt.event_borrow_stream_const)
@@ -90,7 +92,7 @@ class _EventConst(object._UniqueObject, collections.abc.Mapping):
         )
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         payload_field = self.payload_field
 
         if payload_field is not None and key in payload_field:
index 408af70b729abdf48b6356a31c9d2513a36b3f95..b36ab54c25235fd1c9d8d8672d205812ef9061f9 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import field_class as bt2_field_class
 from bt2 import value as bt2_value
 
@@ -31,7 +33,7 @@ class EventClassLogLevel:
     DEBUG = native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG
 
 
-class _EventClassConst(object._SharedObject):
+class _EventClassConst(bt2_object._SharedObject):
     @staticmethod
     def _get_ref(ptr):
         native_bt.event_class_get_ref(ptr)
@@ -151,7 +153,7 @@ class _EventClass(_EventClassConst):
 
     def _emf_uri(self, emf_uri):
         status = native_bt.event_class_set_emf_uri(self._ptr, emf_uri)
-        utils._handle_func_status(status, "cannot set event class object's EMF URI")
+        bt2_utils._handle_func_status(status, "cannot set event class object's EMF URI")
 
     _emf_uri = property(fset=_emf_uri)
 
@@ -159,7 +161,7 @@ class _EventClass(_EventClassConst):
         status = native_bt.event_class_set_specific_context_field_class(
             self._ptr, context_field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set event class object's context field class"
         )
 
@@ -169,7 +171,7 @@ class _EventClass(_EventClassConst):
         status = native_bt.event_class_set_payload_field_class(
             self._ptr, payload_field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set event class object's payload field class"
         )
 
@@ -185,11 +187,11 @@ class _EventClass(_EventClassConst):
         payload_field_class,
     ):
         if name is not None:
-            utils._check_str(name)
+            bt2_utils._check_str(name)
 
         if user_attributes is not None:
             value = bt2_value.create_value(user_attributes)
-            utils._check_type(value, bt2_value.MapValue)
+            bt2_utils._check_type(value, bt2_value.MapValue)
 
         if log_level is not None:
             log_levels = (
@@ -214,15 +216,17 @@ class _EventClass(_EventClassConst):
                 raise ValueError("'{}' is not a valid log level".format(log_level))
 
         if emf_uri is not None:
-            utils._check_str(emf_uri)
+            bt2_utils._check_str(emf_uri)
 
         if specific_context_field_class is not None:
-            utils._check_type(
+            bt2_utils._check_type(
                 specific_context_field_class, bt2_field_class._StructureFieldClass
             )
 
         if payload_field_class is not None:
-            utils._check_type(payload_field_class, bt2_field_class._StructureFieldClass)
+            bt2_utils._check_type(
+                payload_field_class, bt2_field_class._StructureFieldClass
+            )
 
 
 _EVENT_CLASS_LOG_LEVEL_TO_OBJ = {
index 06c8385efc63b5b0af64eec89b7d32717971f10b..b1f2f9d5c82f1a77dccf4cd75bbc2d0b9bfa2e3e 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import field_class as bt2_field_class
 import collections.abc
 import functools
@@ -49,7 +51,7 @@ def _get_leaf_field(field):
     return field
 
 
-class _FieldConst(object._UniqueObject):
+class _FieldConst(bt2_object._UniqueObject):
     _create_field_from_ptr = staticmethod(_create_field_from_const_ptr)
     _create_field_class_from_ptr_and_get_ref = staticmethod(
         bt2_field_class._create_field_class_from_const_ptr_and_get_ref
@@ -108,7 +110,7 @@ class _BitArrayField(_BitArrayFieldConst, _Field):
     _NAME = "Bit array"
 
     def _value_as_integer(self, value):
-        utils._check_uint64(value)
+        bt2_utils._check_uint64(value)
         native_bt.field_bit_array_set_value_as_integer(self._ptr, value)
 
     value_as_integer = property(
@@ -450,7 +452,7 @@ class _EnumerationFieldConst(_IntegerFieldConst):
     @property
     def labels(self):
         status, labels = self._get_mapping_labels(self._ptr)
-        utils._handle_func_status(status, "cannot get label for enumeration field")
+        bt2_utils._handle_func_status(status, "cannot get label for enumeration field")
 
         assert labels is not None
         return labels
@@ -546,7 +548,7 @@ class _StringField(_StringFieldConst, _Field):
     def __iadd__(self, value):
         value = self._value_to_str(value)
         status = native_bt.field_string_append(self._ptr, value)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append to string field object's value"
         )
         return self
@@ -620,7 +622,7 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping):
         return "{{{}}}".format(", ".join(items))
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         field_ptr = self._borrow_member_field_ptr_by_name(self._ptr, key)
 
         if field_ptr is None:
@@ -631,7 +633,7 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping):
         )
 
     def member_at_index(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -708,7 +710,7 @@ class _OptionField(_OptionFieldConst, _Field):
     _borrow_field_ptr = staticmethod(native_bt.field_option_borrow_field)
 
     def _has_field(self, value):
-        utils._check_bool(value)
+        bt2_utils._check_bool(value)
         native_bt.field_option_set_has_field(self._ptr, value)
 
     has_field = property(fget=_OptionFieldConst.has_field.fget, fset=_has_field)
@@ -886,9 +888,9 @@ class _DynamicArrayField(_DynamicArrayFieldConst, _ArrayField, _Field):
     _NAME = "Dynamic array"
 
     def _set_length(self, length):
-        utils._check_uint64(length)
+        bt2_utils._check_uint64(length)
         status = native_bt.field_array_dynamic_set_length(self._ptr, length)
-        utils._handle_func_status(status, "cannot set dynamic array length")
+        bt2_utils._handle_func_status(status, "cannot set dynamic array length")
 
     length = property(fget=_ArrayField._get_length, fset=_set_length)
 
index 2cd30c52205afbbc5a471eda8ff5e8eadf946b3c..3f81c47c6331acfdefd161c75d0f5361374f2d23 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 import collections.abc
 from bt2 import field_path as bt2_field_path
 from bt2 import integer_range_set as bt2_integer_range_set
@@ -44,7 +46,7 @@ class IntegerDisplayBase:
     HEXADECIMAL = native_bt.FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL
 
 
-class _FieldClassConst(object._SharedObject):
+class _FieldClassConst(bt2_object._SharedObject):
     @staticmethod
     def _get_ref(ptr):
         native_bt.field_class_get_ref(ptr)
@@ -83,7 +85,7 @@ class _FieldClass(_FieldClassConst):
 
     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.field_class_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
@@ -134,7 +136,7 @@ class _IntegerFieldClass(_FieldClass, _IntegerFieldClassConst):
     _field_value_range = property(fset=_field_value_range)
 
     def _preferred_display_base(self, base):
-        utils._check_uint64(base)
+        bt2_utils._check_uint64(base)
 
         if base not in (
             IntegerDisplayBase.BINARY,
@@ -245,7 +247,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi
         self._check_int_type(value)
 
         status, labels = self._get_mapping_labels_for_value(self._ptr, value)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot get mapping labels for value {}".format(value)
         )
         return [self[label] for label in labels]
@@ -256,7 +258,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi
             yield self._mapping_pycls(mapping_ptr).label
 
     def __getitem__(self, label):
-        utils._check_str(label)
+        bt2_utils._check_str(label)
         mapping_ptr = self._borrow_mapping_ptr_by_label(self._ptr, label)
 
         if mapping_ptr is None:
@@ -267,14 +269,14 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi
 
 class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass):
     def add_mapping(self, label, ranges):
-        utils._check_str(label)
-        utils._check_type(ranges, self._range_set_pycls)
+        bt2_utils._check_str(label)
+        bt2_utils._check_type(ranges, self._range_set_pycls)
 
         if label in self:
             raise ValueError("duplicate mapping label '{}'".format(label))
 
         status = self._add_mapping(self._ptr, label, ranges._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot add mapping to enumeration field class object"
         )
 
@@ -299,7 +301,7 @@ class _UnsignedEnumerationFieldClassConst(
     _get_mapping_labels_for_value = staticmethod(
         native_bt.field_class_enumeration_unsigned_get_mapping_labels_for_value
     )
-    _check_int_type = staticmethod(utils._check_uint64)
+    _check_int_type = staticmethod(bt2_utils._check_uint64)
 
 
 class _UnsignedEnumerationFieldClass(
@@ -326,7 +328,7 @@ class _SignedEnumerationFieldClassConst(
     _get_mapping_labels_for_value = staticmethod(
         native_bt.field_class_enumeration_signed_get_mapping_labels_for_value
     )
-    _check_int_type = staticmethod(utils._check_int64)
+    _check_int_type = staticmethod(bt2_utils._check_int64)
 
 
 class _SignedEnumerationFieldClass(
@@ -400,7 +402,7 @@ class _StructureFieldClassMember(_StructureFieldClassMemberConst):
 
     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.field_class_structure_member_set_user_attributes(
             self._ptr, value._ptr
         )
@@ -445,7 +447,7 @@ class _StructureFieldClassConst(_FieldClassConst, collections.abc.Mapping):
             yield native_bt.field_class_structure_member_get_name(member_ptr)
 
     def member_at_index(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -466,8 +468,8 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass):
     _structure_member_field_class_pycls = property(lambda _: _StructureFieldClassMember)
 
     def append_member(self, name, field_class, user_attributes=None):
-        utils._check_str(name)
-        utils._check_type(field_class, _FieldClass)
+        bt2_utils._check_str(name)
+        bt2_utils._check_type(field_class, _FieldClass)
 
         if name in self:
             raise ValueError("duplicate member name '{}'".format(name))
@@ -481,7 +483,7 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass):
         status = native_bt.field_class_structure_append_member(
             self._ptr, name, field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append member to structure field class object"
         )
 
@@ -588,7 +590,7 @@ class _OptionWithBoolSelectorFieldClass(
     _NAME = "Option (with boolean selector)"
 
     def _selector_is_reversed(self, selector_is_reversed):
-        utils._check_bool(selector_is_reversed)
+        bt2_utils._check_bool(selector_is_reversed)
         native_bt.field_class_option_with_selector_field_bool_set_selector_is_reversed(
             self._ptr, selector_is_reversed
         )
@@ -671,7 +673,7 @@ class _VariantFieldClassOption(_VariantFieldClassOptionConst):
 
     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.field_class_variant_option_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
@@ -776,7 +778,7 @@ class _VariantFieldClassConst(_FieldClassConst, collections.abc.Mapping):
             yield native_bt.field_class_variant_option_get_name(base_opt_ptr)
 
     def option_at_index(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -807,8 +809,8 @@ class _VariantFieldClassWithoutSelector(
     _NAME = "Variant (without selector)"
 
     def append_option(self, name, field_class, user_attributes=None):
-        utils._check_str(name)
-        utils._check_type(field_class, _FieldClass)
+        bt2_utils._check_str(name)
+        bt2_utils._check_type(field_class, _FieldClass)
 
         if name in self:
             raise ValueError("duplicate option name '{}'".format(name))
@@ -822,7 +824,7 @@ class _VariantFieldClassWithoutSelector(
         status = native_bt.field_class_variant_without_selector_append_option(
             self._ptr, name, field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append option to variant field class object"
         )
 
@@ -857,9 +859,9 @@ class _VariantFieldClassWithIntegerSelector(
     _NAME = "Variant (with selector)"
 
     def append_option(self, name, field_class, ranges, user_attributes=None):
-        utils._check_str(name)
-        utils._check_type(field_class, _FieldClass)
-        utils._check_type(ranges, self._variant_option_pycls._range_set_pycls)
+        bt2_utils._check_str(name)
+        bt2_utils._check_type(field_class, _FieldClass)
+        bt2_utils._check_type(ranges, self._variant_option_pycls._range_set_pycls)
 
         if name in self:
             raise ValueError("duplicate option name '{}'".format(name))
@@ -876,7 +878,7 @@ class _VariantFieldClassWithIntegerSelector(
         # TODO: check overlaps (precondition of self._append_option())
 
         status = self._append_option(self._ptr, name, field_class._ptr, ranges._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append option to variant field class object"
         )
 
index 9dbb2d8fc410e8624d38d5dac4aba69496fe66b7..d16f0f36f6f6130f6157f908e26abe0c5e9f2c7c 100644 (file)
@@ -3,7 +3,8 @@
 # Copyright (c) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
 
 import collections
-from bt2 import native_bt, object
+from bt2 import native_bt
+from bt2 import object as bt2_object
 
 
 class FieldPathScope:
@@ -34,7 +35,7 @@ class _CurrentOptionContentFieldPathItem(_FieldPathItem):
     pass
 
 
-class _FieldPathConst(object._SharedObject, collections.abc.Iterable):
+class _FieldPathConst(bt2_object._SharedObject, collections.abc.Iterable):
     @staticmethod
     def _get_ref(ptr):
         native_bt.field_path_get_ref(ptr)
index 3b0ce036984be36a374355383a41c1ad44c4c091..dc81e2810a3a4540759960a645e0a7c1f97ae565 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import interrupter as bt2_interrupter
 from bt2 import connection as bt2_connection
 from bt2 import component as bt2_component
@@ -22,7 +24,7 @@ def _graph_port_added_listener_from_native(
     user_listener(component, port)
 
 
-class Graph(object._SharedObject):
+class Graph(bt2_object._SharedObject):
     @staticmethod
     def _get_ref(ptr):
         native_bt.graph_get_ref(ptr)
@@ -32,7 +34,7 @@ class Graph(object._SharedObject):
         native_bt.graph_put_ref(ptr)
 
     def __init__(self, mip_version=0):
-        utils._check_uint64(mip_version)
+        bt2_utils._check_uint64(mip_version)
 
         if mip_version > bt2.get_maximal_mip_version():
             raise ValueError("unknown MIP version {}".format(mip_version))
@@ -87,8 +89,8 @@ class Graph(object._SharedObject):
                 )
             )
 
-        utils._check_str(name)
-        utils._check_log_level(logging_level)
+        bt2_utils._check_str(name)
+        bt2_utils._check_log_level(logging_level)
         base_cc_ptr = component_class._bt_component_class_ptr()
 
         if obj is not None and not native_bt.bt2_is_python_component_class(base_cc_ptr):
@@ -104,19 +106,21 @@ class Graph(object._SharedObject):
         status, comp_ptr = add_fn(
             self._ptr, cc_ptr, name, params_ptr, obj, logging_level
         )
-        utils._handle_func_status(status, "cannot add component to graph")
+        bt2_utils._handle_func_status(status, "cannot add component to graph")
         assert comp_ptr
         return bt2_component._create_component_from_const_ptr_and_get_ref(
             comp_ptr, cc_type
         )
 
     def connect_ports(self, upstream_port, downstream_port):
-        utils._check_type(upstream_port, bt2_port._OutputPortConst)
-        utils._check_type(downstream_port, bt2_port._InputPortConst)
+        bt2_utils._check_type(upstream_port, bt2_port._OutputPortConst)
+        bt2_utils._check_type(downstream_port, bt2_port._InputPortConst)
         status, conn_ptr = native_bt.graph_connect_ports(
             self._ptr, upstream_port._ptr, downstream_port._ptr
         )
-        utils._handle_func_status(status, "cannot connect component ports within graph")
+        bt2_utils._handle_func_status(
+            status, "cannot connect component ports within graph"
+        )
         assert conn_ptr
         return bt2_connection._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr)
 
@@ -138,14 +142,14 @@ class Graph(object._SharedObject):
 
     def run_once(self):
         status = native_bt.graph_run_once(self._ptr)
-        utils._handle_func_status(status, "graph object could not run once")
+        bt2_utils._handle_func_status(status, "graph object could not run once")
 
     def run(self):
         status = native_bt.graph_run(self._ptr)
-        utils._handle_func_status(status, "graph object stopped running")
+        bt2_utils._handle_func_status(status, "graph object stopped running")
 
     def add_interrupter(self, interrupter):
-        utils._check_type(interrupter, bt2_interrupter.Interrupter)
+        bt2_utils._check_type(interrupter, bt2_interrupter.Interrupter)
         native_bt.graph_add_interrupter(self._ptr, interrupter._ptr)
 
     @property
index 44f2f380c803cfecfda267fb2ce0b5e00344a3c6..7195e43883a57037c27d80ad5906f4d126141bbf 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 import collections.abc
 import bt2
 
@@ -51,8 +53,8 @@ class _IntegerRange(_IntegerRangeConst):
 
 
 class _SignedIntegerRangeConst(_IntegerRangeConst):
-    _is_type = staticmethod(utils._is_int64)
-    _check_type = staticmethod(utils._check_int64)
+    _is_type = staticmethod(bt2_utils._is_int64)
+    _check_type = staticmethod(bt2_utils._check_int64)
 
 
 class SignedIntegerRange(_SignedIntegerRangeConst, _IntegerRange):
@@ -60,15 +62,15 @@ class SignedIntegerRange(_SignedIntegerRangeConst, _IntegerRange):
 
 
 class _UnsignedIntegerRangeConst(_IntegerRangeConst):
-    _is_type = staticmethod(utils._is_uint64)
-    _check_type = staticmethod(utils._check_uint64)
+    _is_type = staticmethod(bt2_utils._is_uint64)
+    _check_type = staticmethod(bt2_utils._check_uint64)
 
 
 class UnsignedIntegerRange(_UnsignedIntegerRangeConst, _IntegerRange):
     pass
 
 
-class _IntegerRangeSetConst(object._SharedObject, collections.abc.Set):
+class _IntegerRangeSetConst(bt2_object._SharedObject, collections.abc.Set):
     def __len__(self):
         range_set_ptr = self._as_range_set_ptr(self._ptr)
         count = native_bt.integer_range_set_get_range_count(range_set_ptr)
@@ -127,7 +129,7 @@ class _IntegerRangeSet(_IntegerRangeSetConst, collections.abc.MutableSet):
                 rg = self._range_pycls(rg[0], rg[1])
 
         status = self._add_range(self._ptr, rg.lower, rg.upper)
-        utils._handle_func_status(status, "cannot add range to range set object")
+        bt2_utils._handle_func_status(status, "cannot add range to range set object")
 
     def discard(self, rg):
         raise NotImplementedError
index 6026097cb78ce96b5afa32400f0f0c143f013c82..658721add78659295a53dac9cd69987fbe2817de 100644 (file)
@@ -2,11 +2,12 @@
 #
 # Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object
+from bt2 import native_bt
+from bt2 import object as bt2_object
 import bt2
 
 
-class Interrupter(object._SharedObject):
+class Interrupter(bt2_object._SharedObject):
     @staticmethod
     def _get_ref(ptr):
         native_bt.interrupter_get_ref(ptr)
index e2d30a452762c484249855996728a066aa73f07e..9947dffb536565392d3b27c5d02d0bd20cbb8ecb 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import clock_snapshot as bt2_clock_snapshot
 from bt2 import packet as bt2_packet
 from bt2 import stream as bt2_stream
@@ -14,7 +16,7 @@ def _create_from_ptr(ptr):
     return _MESSAGE_TYPE_TO_CLS[msg_type]._create_from_ptr(ptr)
 
 
-class _MessageConst(object._SharedObject):
+class _MessageConst(bt2_object._SharedObject):
     @staticmethod
     def _get_ref(ptr):
         native_bt.message_get_ref(ptr)
@@ -139,7 +141,7 @@ class _StreamMessageConst(_MessageConst, _MessageWithDefaultClockSnapshot):
 
 class _StreamMessage(_StreamMessageConst, _Message):
     def _default_clock_snapshot(self, raw_value):
-        utils._check_uint64(raw_value)
+        bt2_utils._check_uint64(raw_value)
         self._set_default_clock_snapshot(self._ptr, raw_value)
 
     _default_clock_snapshot = property(
@@ -237,7 +239,7 @@ class _DiscardedMessage(_DiscardedMessageConst, _Message):
     _stream_pycls = property(lambda _: bt2_stream._Stream)
 
     def _set_count(self, count):
-        utils._check_uint64(count)
+        bt2_utils._check_uint64(count)
 
         if count == 0:
             raise ValueError("discarded {} count is 0".format(self._item_name))
index 670eaf80eabf2af9a6c1a9d4bd580c433564e5ff..f0a47ec72818dcce89071e8ec2ae203e0844d96f 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import message as bt2_message
 import collections.abc
 from bt2 import stream as bt2_stream
@@ -18,7 +20,9 @@ class _MessageIterator(collections.abc.Iterator):
         raise NotImplementedError
 
 
-class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageIterator):
+class _UserComponentInputPortMessageIterator(
+    bt2_object._SharedObject, _MessageIterator
+):
     @staticmethod
     def _get_ref(ptr):
         native_bt.message_iterator_get_ref(ptr)
@@ -37,7 +41,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
             status, msgs = native_bt.bt2_self_component_port_input_get_msg_range(
                 self._ptr
             )
-            utils._handle_func_status(
+            bt2_utils._handle_func_status(
                 status, "unexpected error: cannot advance the message iterator"
             )
             self._current_msgs = msgs
@@ -50,7 +54,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
 
     def can_seek_beginning(self):
         (status, res) = native_bt.message_iterator_can_seek_beginning(self._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status,
             "cannot check whether or not message iterator can seek its beginning",
         )
@@ -62,21 +66,21 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
         self._at = 0
 
         status = native_bt.message_iterator_seek_beginning(self._ptr)
-        utils._handle_func_status(status, "cannot seek message iterator beginning")
+        bt2_utils._handle_func_status(status, "cannot seek message iterator beginning")
 
     def can_seek_ns_from_origin(self, ns_from_origin):
-        utils._check_int64(ns_from_origin)
+        bt2_utils._check_int64(ns_from_origin)
         (status, res) = native_bt.message_iterator_can_seek_ns_from_origin(
             self._ptr, ns_from_origin
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status,
             "cannot check whether or not message iterator can seek given ns from origin",
         )
         return res != 0
 
     def seek_ns_from_origin(self, ns_from_origin):
-        utils._check_int64(ns_from_origin)
+        bt2_utils._check_int64(ns_from_origin)
 
         # Forget about buffered messages, they won't be valid after seeking.
         self._current_msgs.clear()
@@ -85,7 +89,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
         status = native_bt.message_iterator_seek_ns_from_origin(
             self._ptr, ns_from_origin
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "message iterator cannot seek given ns from origin"
         )
 
@@ -99,7 +103,7 @@ class _MessageIteratorConfiguration:
         self._ptr = ptr
 
     def can_seek_forward(self, value):
-        utils._check_bool(value)
+        bt2_utils._check_bool(value)
         native_bt.self_message_iterator_configuration_set_can_seek_forward(
             self._ptr, value
         )
@@ -174,7 +178,7 @@ class _UserMessageIterator(_MessageIterator):
         except Exception:
             raise
 
-        utils._check_type(msg, bt2_message._MessageConst)
+        bt2_utils._check_type(msg, bt2_message._MessageConst)
 
         # The reference we return will be given to the message array.
         # However, the `msg` Python object may stay alive, if the user has kept
@@ -191,7 +195,7 @@ class _UserMessageIterator(_MessageIterator):
         #   method indicates whether the iterator can seek beginning.
         if hasattr(self, "_user_can_seek_beginning"):
             can_seek_beginning = self._user_can_seek_beginning()
-            utils._check_bool(can_seek_beginning)
+            bt2_utils._check_bool(can_seek_beginning)
             return can_seek_beginning
         else:
             return hasattr(self, "_user_seek_beginning")
@@ -211,7 +215,7 @@ class _UserMessageIterator(_MessageIterator):
 
         if hasattr(self, "_user_can_seek_ns_from_origin"):
             can_seek_ns_from_origin = self._user_can_seek_ns_from_origin(ns_from_origin)
-            utils._check_bool(can_seek_ns_from_origin)
+            bt2_utils._check_bool(can_seek_ns_from_origin)
             return can_seek_ns_from_origin
         else:
             return hasattr(self, "_user_seek_ns_from_origin")
@@ -220,7 +224,7 @@ class _UserMessageIterator(_MessageIterator):
         self._user_seek_ns_from_origin(ns_from_origin)
 
     def _create_message_iterator(self, input_port):
-        utils._check_type(input_port, bt2_port._UserComponentInputPort)
+        bt2_utils._check_type(input_port, bt2_port._UserComponentInputPort)
 
         if not input_port.is_connected:
             raise ValueError("input port is not connected")
@@ -231,18 +235,18 @@ class _UserMessageIterator(_MessageIterator):
         ) = native_bt.bt2_message_iterator_create_from_message_iterator(
             self._bt_ptr, input_port._ptr
         )
-        utils._handle_func_status(status, "cannot create message iterator object")
+        bt2_utils._handle_func_status(status, "cannot create message iterator object")
         assert msg_iter_ptr is not None
 
         return _UserComponentInputPortMessageIterator(msg_iter_ptr)
 
     def _create_event_message(self, event_class, parent, default_clock_snapshot=None):
-        utils._check_type(event_class, bt2_event_class._EventClass)
+        bt2_utils._check_type(event_class, bt2_event_class._EventClass)
 
         if event_class.stream_class.supports_packets:
-            utils._check_type(parent, bt2_packet._Packet)
+            bt2_utils._check_type(parent, bt2_packet._Packet)
         else:
-            utils._check_type(parent, bt2_stream._Stream)
+            bt2_utils._check_type(parent, bt2_stream._Stream)
 
         if default_clock_snapshot is not None:
             if event_class.stream_class.default_clock_class is None:
@@ -250,7 +254,7 @@ class _UserMessageIterator(_MessageIterator):
                     "event messages in this stream must not have a default clock snapshot"
                 )
 
-            utils._check_uint64(default_clock_snapshot)
+            bt2_utils._check_uint64(default_clock_snapshot)
 
             if event_class.stream_class.supports_packets:
                 ptr = native_bt.message_event_create_with_packet_and_default_clock_snapshot(
@@ -281,7 +285,7 @@ class _UserMessageIterator(_MessageIterator):
         return bt2_message._EventMessage(ptr)
 
     def _create_message_iterator_inactivity_message(self, clock_class, clock_snapshot):
-        utils._check_type(clock_class, bt2_clock_class._ClockClass)
+        bt2_utils._check_type(clock_class, bt2_clock_class._ClockClass)
         ptr = native_bt.message_message_iterator_inactivity_create(
             self._bt_ptr, clock_class._ptr, clock_snapshot
         )
@@ -292,7 +296,7 @@ class _UserMessageIterator(_MessageIterator):
         return bt2_message._MessageIteratorInactivityMessage(ptr)
 
     def _create_stream_beginning_message(self, stream, default_clock_snapshot=None):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         ptr = native_bt.message_stream_beginning_create(self._bt_ptr, stream._ptr)
         if ptr is None:
@@ -306,7 +310,7 @@ class _UserMessageIterator(_MessageIterator):
         return msg
 
     def _create_stream_end_message(self, stream, default_clock_snapshot=None):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         ptr = native_bt.message_stream_end_create(self._bt_ptr, stream._ptr)
         if ptr is None:
@@ -320,7 +324,7 @@ class _UserMessageIterator(_MessageIterator):
         return msg
 
     def _create_packet_beginning_message(self, packet, default_clock_snapshot=None):
-        utils._check_type(packet, bt2_packet._Packet)
+        bt2_utils._check_type(packet, bt2_packet._Packet)
 
         if packet.stream.cls.packets_have_beginning_default_clock_snapshot:
             if default_clock_snapshot is None:
@@ -328,7 +332,7 @@ class _UserMessageIterator(_MessageIterator):
                     "packet beginning messages in this stream must have a default clock snapshot"
                 )
 
-            utils._check_uint64(default_clock_snapshot)
+            bt2_utils._check_uint64(default_clock_snapshot)
             ptr = native_bt.message_packet_beginning_create_with_default_clock_snapshot(
                 self._bt_ptr, packet._ptr, default_clock_snapshot
             )
@@ -346,7 +350,7 @@ class _UserMessageIterator(_MessageIterator):
         return bt2_message._PacketBeginningMessage(ptr)
 
     def _create_packet_end_message(self, packet, default_clock_snapshot=None):
-        utils._check_type(packet, bt2_packet._Packet)
+        bt2_utils._check_type(packet, bt2_packet._Packet)
 
         if packet.stream.cls.packets_have_end_default_clock_snapshot:
             if default_clock_snapshot is None:
@@ -354,7 +358,7 @@ class _UserMessageIterator(_MessageIterator):
                     "packet end messages in this stream must have a default clock snapshot"
                 )
 
-            utils._check_uint64(default_clock_snapshot)
+            bt2_utils._check_uint64(default_clock_snapshot)
             ptr = native_bt.message_packet_end_create_with_default_clock_snapshot(
                 self._bt_ptr, packet._ptr, default_clock_snapshot
             )
@@ -374,7 +378,7 @@ class _UserMessageIterator(_MessageIterator):
     def _create_discarded_events_message(
         self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None
     ):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         if not stream.cls.supports_discarded_events:
             raise ValueError("stream class does not support discarded events")
@@ -385,8 +389,8 @@ class _UserMessageIterator(_MessageIterator):
                     "discarded events have default clock snapshots for this stream class"
                 )
 
-            utils._check_uint64(beg_clock_snapshot)
-            utils._check_uint64(end_clock_snapshot)
+            bt2_utils._check_uint64(beg_clock_snapshot)
+            bt2_utils._check_uint64(end_clock_snapshot)
 
             if beg_clock_snapshot > end_clock_snapshot:
                 raise ValueError(
@@ -421,7 +425,7 @@ class _UserMessageIterator(_MessageIterator):
     def _create_discarded_packets_message(
         self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None
     ):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         if not stream.cls.supports_discarded_packets:
             raise ValueError("stream class does not support discarded packets")
@@ -432,8 +436,8 @@ class _UserMessageIterator(_MessageIterator):
                     "discarded packets have default clock snapshots for this stream class"
                 )
 
-            utils._check_uint64(beg_clock_snapshot)
-            utils._check_uint64(end_clock_snapshot)
+            bt2_utils._check_uint64(beg_clock_snapshot)
+            bt2_utils._check_uint64(end_clock_snapshot)
 
             if beg_clock_snapshot > end_clock_snapshot:
                 raise ValueError(
index 552c7b2aad5c0724e469fc4abbaab7429df9af12..96efc03286cd1a391c64123e823af3bbad84325d 100644 (file)
@@ -2,14 +2,15 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, utils
+from bt2 import native_bt
+from bt2 import utils as bt2_utils
 import bt2
 
 
 def get_greatest_operative_mip_version(
     component_descriptors, log_level=bt2.LoggingLevel.NONE
 ):
-    utils._check_log_level(log_level)
+    bt2_utils._check_log_level(log_level)
     comp_descr_set_ptr = native_bt.component_descriptor_set_create()
 
     if comp_descr_set_ptr is None:
@@ -32,7 +33,7 @@ def get_greatest_operative_mip_version(
             status = native_bt.bt2_component_descriptor_set_add_descriptor_with_initialize_method_data(
                 comp_descr_set_ptr, base_cc_ptr, params_ptr, descr.obj
             )
-            utils._handle_func_status(
+            bt2_utils._handle_func_status(
                 status, "cannot add descriptor to component descriptor set"
             )
 
@@ -43,7 +44,9 @@ def get_greatest_operative_mip_version(
         if status == native_bt.__BT_FUNC_STATUS_NO_MATCH:
             return None
 
-        utils._handle_func_status(status, "cannot get greatest operative MIP version")
+        bt2_utils._handle_func_status(
+            status, "cannot get greatest operative MIP version"
+        )
         return version
     finally:
         native_bt.component_descriptor_set_put_ref(comp_descr_set_ptr)
index 097614fe444900865d19cff39a13cdbc176cb282..9802d6581e002a44e1c9a0047875d3be4b3a370b 100644 (file)
@@ -2,7 +2,8 @@
 #
 # Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object
+from bt2 import native_bt
+from bt2 import object as bt2_object
 from bt2 import field as bt2_field
 
 
@@ -12,7 +13,7 @@ def _bt2_stream():
     return bt2_stream
 
 
-class _PacketConst(object._SharedObject):
+class _PacketConst(bt2_object._SharedObject):
     @staticmethod
     def _get_ref(ptr):
         native_bt.packet_get_ref(ptr)
index 7d3fff91403792f1d93358a36d552eba80666906..1a3a6de55ce6b9474c19454adfdacbf405f1b315 100644 (file)
@@ -2,16 +2,18 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 import collections.abc
 from bt2 import component as bt2_component
 import os.path
 
 
 def find_plugins_in_path(path, recurse=True, fail_on_load_error=False):
-    utils._check_str(path)
-    utils._check_bool(recurse)
-    utils._check_bool(fail_on_load_error)
+    bt2_utils._check_str(path)
+    bt2_utils._check_bool(recurse)
+    bt2_utils._check_bool(fail_on_load_error)
     plugin_set_ptr = None
 
     if os.path.isfile(path):
@@ -28,7 +30,7 @@ def find_plugins_in_path(path, recurse=True, fail_on_load_error=False):
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, "failed to find plugins")
+    bt2_utils._handle_func_status(status, "failed to find plugins")
     assert plugin_set_ptr is not None
     return _PluginSet._create_from_ptr(plugin_set_ptr)
 
@@ -40,11 +42,11 @@ def find_plugins(
     find_in_static=True,
     fail_on_load_error=False,
 ):
-    utils._check_bool(find_in_std_env_var)
-    utils._check_bool(find_in_user_dir)
-    utils._check_bool(find_in_sys_dir)
-    utils._check_bool(find_in_static)
-    utils._check_bool(fail_on_load_error)
+    bt2_utils._check_bool(find_in_std_env_var)
+    bt2_utils._check_bool(find_in_user_dir)
+    bt2_utils._check_bool(find_in_sys_dir)
+    bt2_utils._check_bool(find_in_static)
+    bt2_utils._check_bool(fail_on_load_error)
     plugin_set_ptr = None
 
     status, plugin_set_ptr = native_bt.bt2_plugin_find_all(
@@ -58,7 +60,7 @@ def find_plugins(
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, "failed to find plugins")
+    bt2_utils._handle_func_status(status, "failed to find plugins")
     assert plugin_set_ptr is not None
     return _PluginSet._create_from_ptr(plugin_set_ptr)
 
@@ -71,8 +73,8 @@ def find_plugin(
     find_in_static=True,
     fail_on_load_error=False,
 ):
-    utils._check_str(name)
-    utils._check_bool(fail_on_load_error)
+    bt2_utils._check_str(name)
+    bt2_utils._check_bool(fail_on_load_error)
     status, ptr = native_bt.bt2_plugin_find(
         name,
         int(find_in_std_env_var),
@@ -85,12 +87,12 @@ def find_plugin(
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, "failed to find plugin")
+    bt2_utils._handle_func_status(status, "failed to find plugin")
     assert ptr is not None
     return _Plugin._create_from_ptr(ptr)
 
 
-class _PluginSet(object._SharedObject, collections.abc.Sequence):
+class _PluginSet(bt2_object._SharedObject, collections.abc.Sequence):
     @staticmethod
     def _put_ref(ptr):
         native_bt.plugin_set_put_ref(ptr)
@@ -105,7 +107,7 @@ class _PluginSet(object._SharedObject, collections.abc.Sequence):
         return count
 
     def __getitem__(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -180,7 +182,7 @@ class _PluginComponentClasses(collections.abc.Mapping):
         self._plugin = plugin
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         cc_ptr = self._borrow_component_class_by_name(self._plugin._ptr, key)
 
         if cc_ptr is None:
@@ -236,7 +238,7 @@ class _PluginSinkComponentClasses(_PluginComponentClasses):
     _comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_SINK
 
 
-class _Plugin(object._SharedObject):
+class _Plugin(bt2_object._SharedObject):
     @staticmethod
     def _put_ref(ptr):
         native_bt.plugin_put_ref(ptr)
index 0d6484782b7f710698189c4d1d23e5083b1e0650..034e58d179cfa99bf1e57d2b9d73c8dfa065469e 100644 (file)
@@ -2,7 +2,8 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object
+from bt2 import native_bt
+from bt2 import object as bt2_object
 
 
 def _bt2_connection():
@@ -29,7 +30,7 @@ def _create_self_from_ptr_and_get_ref(ptr, port_type):
     return cls._create_from_ptr_and_get_ref(ptr)
 
 
-class _PortConst(object._SharedObject):
+class _PortConst(bt2_object._SharedObject):
     @classmethod
     def _get_ref(cls, ptr):
         ptr = cls._as_port_ptr(ptr)
index 6f067e8b4d59c4e794362372a05ccf8f008393ec..863ae7f0aa4cfe9149f0e79fa9acd53c14ad5659 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import utils
+from bt2 import utils as bt2_utils
 from bt2 import component as bt2_component
 import sys
 
@@ -27,16 +27,16 @@ def register_plugin(
             "cannot find module '{}' in loaded modules".format(module_name)
         )
 
-    utils._check_str(name)
+    bt2_utils._check_str(name)
 
     if description is not None:
-        utils._check_str(description)
+        bt2_utils._check_str(description)
 
     if author is not None:
-        utils._check_str(author)
+        bt2_utils._check_str(author)
 
     if license is not None:
-        utils._check_str(license)
+        bt2_utils._check_str(license)
 
     if version is not None:
         if not _validate_version(version):
index 840e0fdd867135bb4e00c06487494bb067c7b297..ebedffe8de242877eb7187ae3c01616f155c5594 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import interrupter as bt2_interrupter
 from bt2 import value as bt2_value
 import bt2
@@ -29,7 +31,7 @@ class _QueryExecutorCommon:
         return native_bt.query_executor_get_logging_level(self._common_ptr)
 
 
-class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
+class QueryExecutor(bt2_object._SharedObject, _QueryExecutorCommon):
     @staticmethod
     def _get_ref(ptr):
         native_bt.query_executor_get_ref(ptr)
@@ -55,7 +57,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
                 o = component_class
                 raise TypeError("'{}' is not a component class object".format(o))
 
-        utils._check_str(object_name)
+        bt2_utils._check_str(object_name)
 
         if params is None:
             params_ptr = native_bt.value_null
@@ -88,7 +90,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
         self._method_obj = method_obj
 
     def add_interrupter(self, interrupter):
-        utils._check_type(interrupter, bt2_interrupter.Interrupter)
+        bt2_utils._check_type(interrupter, bt2_interrupter.Interrupter)
         native_bt.query_executor_add_interrupter(self._ptr, interrupter._ptr)
 
     @property
@@ -97,9 +99,11 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
         return bt2_interrupter.Interrupter._create_from_ptr_and_get_ref(ptr)
 
     def _set_logging_level(self, log_level):
-        utils._check_log_level(log_level)
+        bt2_utils._check_log_level(log_level)
         status = native_bt.query_executor_set_logging_level(self._ptr, log_level)
-        utils._handle_func_status(status, "cannot set query executor's logging level")
+        bt2_utils._handle_func_status(
+            status, "cannot set query executor's logging level"
+        )
 
     logging_level = property(
         fget=_QueryExecutorCommon.logging_level, fset=_set_logging_level
@@ -112,7 +116,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
 
     def query(self):
         status, result_ptr = native_bt.query_executor_query(self._ptr)
-        utils._handle_func_status(status, "cannot query component class")
+        bt2_utils._handle_func_status(status, "cannot query component class")
         assert result_ptr is not None
         return bt2_value._create_from_const_ptr(result_ptr)
 
index cd456e9e210eb984f66b8442428d55fee0af7ba9..dae698d6abc70a531bb34d6ac8a1087ec64af50b 100644 (file)
@@ -2,7 +2,8 @@
 #
 # 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
@@ -89,7 +90,7 @@ class _Stream(_StreamConst):
 
     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(
@@ -97,7 +98,7 @@ class _Stream(_StreamConst):
     )
 
     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)
index c189a6eb32cf9e6864ecc582b78039a303b83161..e73b40e9d61604c78f7f5c272c9ccee2edbcaafa 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 from bt2 import field_class as bt2_field_class
 from bt2 import event_class as bt2_event_class
 from bt2 import clock_class as bt2_clock_class
@@ -16,7 +18,7 @@ def _bt2_trace_class():
     return bt2_trace_class
 
 
-class _StreamClassConst(object._SharedObject, collections.abc.Mapping):
+class _StreamClassConst(bt2_object._SharedObject, collections.abc.Mapping):
     @staticmethod
     def _get_ref(ptr):
         native_bt.stream_class_get_ref(ptr)
@@ -52,7 +54,7 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping):
     _clock_class_cls = property(lambda _: bt2_clock_class._ClockClassConst)
 
     def __getitem__(self, key):
-        utils._check_int64(key)
+        bt2_utils._check_int64(key)
         ec_ptr = self._borrow_event_class_ptr_by_id(self._ptr, key)
 
         if ec_ptr is None:
@@ -236,7 +238,7 @@ class _StreamClass(_StreamClassConst):
                     "id not provided, but stream class does not assign automatic event class ids"
                 )
 
-            utils._check_uint64(id)
+            bt2_utils._check_uint64(id)
             ec_ptr = native_bt.event_class_create_with_id(self._ptr, id)
 
         event_class = bt2_event_class._EventClass._create_from_ptr(ec_ptr)
@@ -269,7 +271,7 @@ class _StreamClass(_StreamClassConst):
 
     def _name(self, name):
         status = native_bt.stream_class_set_name(self._ptr, name)
-        utils._handle_func_status(status, "cannot set stream class object's name")
+        bt2_utils._handle_func_status(status, "cannot set stream class object's name")
 
     _name = property(fset=_name)
 
@@ -306,7 +308,7 @@ class _StreamClass(_StreamClassConst):
         status = native_bt.stream_class_set_packet_context_field_class(
             self._ptr, packet_context_field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set stream class' packet context field class"
         )
 
@@ -315,7 +317,7 @@ class _StreamClass(_StreamClassConst):
     def _event_common_context_field_class(self, event_common_context_field_class):
         set_context_fn = native_bt.stream_class_set_event_common_context_field_class
         status = set_context_fn(self._ptr, event_common_context_field_class._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set stream class' event context field type"
         )
 
@@ -346,12 +348,12 @@ class _StreamClass(_StreamClassConst):
     ):
         # Name
         if name is not None:
-            utils._check_str(name)
+            bt2_utils._check_str(name)
 
         # User attributes
         if user_attributes is not None:
             value = bt2_value.create_value(user_attributes)
-            utils._check_type(value, bt2_value.MapValue)
+            bt2_utils._check_type(value, bt2_value.MapValue)
 
         # Packet context field class
         if packet_context_field_class is not None:
@@ -360,30 +362,30 @@ class _StreamClass(_StreamClassConst):
                     "cannot have a packet context field class without supporting packets"
                 )
 
-            utils._check_type(
+            bt2_utils._check_type(
                 packet_context_field_class, bt2_field_class._StructureFieldClass
             )
 
         # Event common context field class
         if event_common_context_field_class is not None:
-            utils._check_type(
+            bt2_utils._check_type(
                 event_common_context_field_class, bt2_field_class._StructureFieldClass
             )
 
         # Default clock class
         if default_clock_class is not None:
-            utils._check_type(default_clock_class, bt2_clock_class._ClockClass)
+            bt2_utils._check_type(default_clock_class, bt2_clock_class._ClockClass)
 
         # Assigns automatic event class id
-        utils._check_bool(assigns_automatic_event_class_id)
+        bt2_utils._check_bool(assigns_automatic_event_class_id)
 
         # Assigns automatic stream id
-        utils._check_bool(assigns_automatic_stream_id)
+        bt2_utils._check_bool(assigns_automatic_stream_id)
 
         # Packets
-        utils._check_bool(supports_packets)
-        utils._check_bool(packets_have_beginning_default_clock_snapshot)
-        utils._check_bool(packets_have_end_default_clock_snapshot)
+        bt2_utils._check_bool(supports_packets)
+        bt2_utils._check_bool(packets_have_beginning_default_clock_snapshot)
+        bt2_utils._check_bool(packets_have_end_default_clock_snapshot)
 
         if not supports_packets:
             if packets_have_beginning_default_clock_snapshot:
@@ -396,8 +398,8 @@ class _StreamClass(_StreamClassConst):
                 )
 
         # Discarded events
-        utils._check_bool(supports_discarded_events)
-        utils._check_bool(discarded_events_have_default_clock_snapshots)
+        bt2_utils._check_bool(supports_discarded_events)
+        bt2_utils._check_bool(discarded_events_have_default_clock_snapshots)
 
         if discarded_events_have_default_clock_snapshots:
             if not supports_discarded_events:
@@ -411,8 +413,8 @@ class _StreamClass(_StreamClassConst):
                 )
 
         # Discarded packets
-        utils._check_bool(supports_discarded_packets)
-        utils._check_bool(discarded_packets_have_default_clock_snapshots)
+        bt2_utils._check_bool(supports_discarded_packets)
+        bt2_utils._check_bool(discarded_packets_have_default_clock_snapshots)
 
         if supports_discarded_packets and not supports_packets:
             raise ValueError(
index 373555298c1059d147db4ca2996e529e227cfb7e..5cbe82c64d6eda6f1e996a2b2071ede0bdab4cd8 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 import collections.abc
 from bt2 import value as bt2_value
 from bt2 import stream as bt2_stream
@@ -27,7 +29,7 @@ class _TraceEnvironmentConst(collections.abc.Mapping):
         self._trace = trace
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
 
         borrow_entry_fn = native_bt.trace_borrow_environment_entry_value_by_name_const
         value_ptr = borrow_entry_fn(self._trace._ptr, key)
@@ -66,13 +68,15 @@ class _TraceEnvironment(_TraceEnvironmentConst, collections.abc.MutableMapping):
             raise TypeError("expected str or int, got {}".format(type(value)))
 
         status = set_env_entry_fn(self._trace._ptr, key, value)
-        utils._handle_func_status(status, "cannot set trace object's environment entry")
+        bt2_utils._handle_func_status(
+            status, "cannot set trace object's environment entry"
+        )
 
     def __delitem__(self, key):
         raise NotImplementedError
 
 
-class _TraceConst(object._SharedObject, collections.abc.Mapping):
+class _TraceConst(bt2_object._SharedObject, collections.abc.Mapping):
     @staticmethod
     def _get_ref(ptr):
         native_bt.trace_get_ref(ptr)
@@ -102,7 +106,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         return count
 
     def __getitem__(self, id):
-        utils._check_uint64(id)
+        bt2_utils._check_uint64(id)
 
         stream_ptr = self._borrow_stream_ptr_by_id(self._ptr, id)
 
@@ -154,7 +158,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         if not callable(listener):
             raise TypeError("'listener' parameter is not callable")
 
-        handle = utils._ListenerHandle(self.addr)
+        handle = bt2_utils._ListenerHandle(self.addr)
 
         fn = native_bt.bt2_trace_add_destruction_listener
         listener_from_native = functools.partial(
@@ -162,7 +166,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         )
 
         status, listener_id = fn(self._ptr, listener_from_native)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot add destruction listener to trace object"
         )
 
@@ -171,7 +175,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         return handle
 
     def remove_destruction_listener(self, listener_handle):
-        utils._check_type(listener_handle, utils._ListenerHandle)
+        bt2_utils._check_type(listener_handle, bt2_utils._ListenerHandle)
 
         if listener_handle._addr != self.addr:
             raise ValueError(
@@ -184,7 +188,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         status = native_bt.trace_remove_destruction_listener(
             self._ptr, listener_handle._listener_id
         )
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
         listener_handle._invalidate()
 
 
@@ -201,27 +205,27 @@ class _Trace(_TraceConst):
     _trace_env_pycls = property(lambda _: _TraceEnvironment)
 
     def _name(self, name):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
         status = native_bt.trace_set_name(self._ptr, name)
-        utils._handle_func_status(status, "cannot set trace class object's name")
+        bt2_utils._handle_func_status(status, "cannot set trace class object's name")
 
     _name = property(fset=_name)
 
     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.trace_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
 
     def _uuid(self, uuid):
-        utils._check_type(uuid, uuidp.UUID)
+        bt2_utils._check_type(uuid, uuidp.UUID)
         native_bt.trace_set_uuid(self._ptr, uuid.bytes)
 
     _uuid = property(fset=_uuid)
 
     def create_stream(self, stream_class, id=None, name=None, user_attributes=None):
-        utils._check_type(stream_class, bt2_stream_class._StreamClass)
+        bt2_utils._check_type(stream_class, bt2_stream_class._StreamClass)
 
         if stream_class.assigns_automatic_stream_id:
             if id is not None:
@@ -236,7 +240,7 @@ class _Trace(_TraceConst):
                     "id not provided, but stream class does not assign automatic stream ids"
                 )
 
-            utils._check_uint64(id)
+            bt2_utils._check_uint64(id)
             stream_ptr = native_bt.stream_create_with_id(
                 stream_class._ptr, self._ptr, id
             )
index c89e9d21dda0d4df5858fc322436388abfe212b2..c25154e8f9d9f4fb1584c26f5a83638a3d317d88 100644 (file)
@@ -4,7 +4,9 @@
 # Copyright (c) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
 # Copyright (c) 2019 Simon Marchi <simon.marchi@efficios.com>
 
-from bt2 import native_bt, utils, object
+from bt2 import native_bt
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
 from bt2 import stream_class as bt2_stream_class
 from bt2 import field_class as bt2_field_class
 from bt2 import integer_range_set as bt2_integer_range_set
@@ -23,7 +25,7 @@ def _trace_class_destruction_listener_from_native(
     handle._invalidate()
 
 
-class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
+class _TraceClassConst(bt2_object._SharedObject, collections.abc.Mapping):
     @staticmethod
     def _get_ref(ptr):
         native_bt.trace_class_get_ref(ptr)
@@ -62,7 +64,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
     # Get a stream class by stream id.
 
     def __getitem__(self, key):
-        utils._check_uint64(key)
+        bt2_utils._check_uint64(key)
 
         sc_ptr = self._borrow_stream_class_ptr_by_id(self._ptr, key)
         if sc_ptr is None:
@@ -90,7 +92,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
         if not callable(listener):
             raise TypeError("'listener' parameter is not callable")
 
-        handle = utils._ListenerHandle(self.addr)
+        handle = bt2_utils._ListenerHandle(self.addr)
 
         listener_from_native = functools.partial(
             _trace_class_destruction_listener_from_native, listener, handle
@@ -98,7 +100,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
 
         fn = native_bt.bt2_trace_class_add_destruction_listener
         status, listener_id = fn(self._ptr, listener_from_native)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot add destruction listener to trace class object"
         )
 
@@ -107,7 +109,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
         return handle
 
     def remove_destruction_listener(self, listener_handle):
-        utils._check_type(listener_handle, utils._ListenerHandle)
+        bt2_utils._check_type(listener_handle, bt2_utils._ListenerHandle)
 
         if listener_handle._addr != self.addr:
             raise ValueError(
@@ -122,7 +124,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
         status = native_bt.trace_class_remove_destruction_listener(
             self._ptr, listener_handle._listener_id
         )
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
         listener_handle._invalidate()
 
 
@@ -215,7 +217,7 @@ class _TraceClass(_TraceClassConst):
                     "id not provided, but trace class does not assign automatic stream class ids"
                 )
 
-            utils._check_uint64(id)
+            bt2_utils._check_uint64(id)
             sc_ptr = native_bt.stream_class_create_with_id(self._ptr, id)
 
         sc = bt2_stream_class._StreamClass._create_from_ptr(sc_ptr)
@@ -260,13 +262,13 @@ class _TraceClass(_TraceClassConst):
 
     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.trace_class_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
 
     def _assigns_automatic_stream_class_id(self, auto_id):
-        utils._check_bool(auto_id)
+        bt2_utils._check_bool(auto_id)
         return native_bt.trace_class_set_assigns_automatic_stream_class_id(
             self._ptr, auto_id
         )
@@ -294,7 +296,7 @@ class _TraceClass(_TraceClassConst):
         return fc
 
     def create_bit_array_field_class(self, length, user_attributes=None):
-        utils._check_uint64(length)
+        bt2_utils._check_uint64(length)
 
         if length < 1 or length > 64:
             raise ValueError(
@@ -419,8 +421,8 @@ class _TraceClass(_TraceClassConst):
         return fc
 
     def create_static_array_field_class(self, elem_fc, length, user_attributes=None):
-        utils._check_type(elem_fc, bt2_field_class._FieldClass)
-        utils._check_uint64(length)
+        bt2_utils._check_type(elem_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_uint64(length)
         ptr = native_bt.field_class_array_static_create(self._ptr, elem_fc._ptr, length)
         self._check_field_class_create_status(ptr, "static array")
         fc = bt2_field_class._StaticArrayFieldClass._create_from_ptr(ptr)
@@ -430,11 +432,11 @@ class _TraceClass(_TraceClassConst):
     def create_dynamic_array_field_class(
         self, elem_fc, length_fc=None, user_attributes=None
     ):
-        utils._check_type(elem_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_type(elem_fc, bt2_field_class._FieldClass)
         length_fc_ptr = None
 
         if length_fc is not None:
-            utils._check_type(length_fc, bt2_field_class._UnsignedIntegerFieldClass)
+            bt2_utils._check_type(length_fc, bt2_field_class._UnsignedIntegerFieldClass)
             length_fc_ptr = length_fc._ptr
 
         ptr = native_bt.field_class_array_dynamic_create(
@@ -448,7 +450,7 @@ class _TraceClass(_TraceClassConst):
     def create_option_without_selector_field_class(
         self, content_fc, user_attributes=None
     ):
-        utils._check_type(content_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_type(content_fc, bt2_field_class._FieldClass)
         ptr = native_bt.field_class_option_without_selector_create(
             self._ptr, content_fc._ptr
         )
@@ -460,9 +462,9 @@ class _TraceClass(_TraceClassConst):
     def create_option_with_bool_selector_field_class(
         self, content_fc, selector_fc, selector_is_reversed=False, user_attributes=None
     ):
-        utils._check_type(content_fc, bt2_field_class._FieldClass)
-        utils._check_bool(selector_is_reversed)
-        utils._check_type(selector_fc, bt2_field_class._BoolFieldClass)
+        bt2_utils._check_type(content_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_bool(selector_is_reversed)
+        bt2_utils._check_type(selector_fc, bt2_field_class._BoolFieldClass)
         ptr = native_bt.field_class_option_with_selector_field_bool_create(
             self._ptr, content_fc._ptr, selector_fc._ptr
         )
@@ -475,19 +477,19 @@ class _TraceClass(_TraceClassConst):
     def create_option_with_integer_selector_field_class(
         self, content_fc, selector_fc, ranges, user_attributes=None
     ):
-        utils._check_type(content_fc, bt2_field_class._FieldClass)
-        utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
+        bt2_utils._check_type(content_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
 
         if len(ranges) == 0:
             raise ValueError("integer range set is empty")
 
         if isinstance(selector_fc, bt2_field_class._UnsignedIntegerFieldClass):
-            utils._check_type(ranges, bt2_integer_range_set.UnsignedIntegerRangeSet)
+            bt2_utils._check_type(ranges, bt2_integer_range_set.UnsignedIntegerRangeSet)
             ptr = native_bt.field_class_option_with_selector_field_integer_unsigned_create(
                 self._ptr, content_fc._ptr, selector_fc._ptr, ranges._ptr
             )
         else:
-            utils._check_type(ranges, bt2_integer_range_set.SignedIntegerRangeSet)
+            bt2_utils._check_type(ranges, bt2_integer_range_set.SignedIntegerRangeSet)
             ptr = (
                 native_bt.field_class_option_with_selector_field_integer_signed_create(
                     self._ptr, content_fc._ptr, selector_fc._ptr, ranges._ptr
@@ -503,7 +505,7 @@ class _TraceClass(_TraceClassConst):
         selector_fc_ptr = None
 
         if selector_fc is not None:
-            utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
+            bt2_utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
             selector_fc_ptr = selector_fc._ptr
 
         ptr = native_bt.field_class_variant_create(self._ptr, selector_fc_ptr)
index 79946290703b20106e0276f9c941b876387501ff..67a713b3a8838ff6e690bfe41a0e0a27bc646364 100644 (file)
@@ -2,7 +2,8 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import utils, native_bt
+from bt2 import native_bt
+from bt2 import utils as bt2_utils
 import bt2
 import itertools
 from bt2 import message_iterator as bt2_message_iterator
@@ -24,7 +25,7 @@ class _BaseComponentSpec:
     # TraceCollectionMessageIterator.
     def __init__(self, params, obj, logging_level):
         if logging_level is not None:
-            utils._check_log_level(logging_level)
+            bt2_utils._check_log_level(logging_level)
 
         self._params = bt2.create_value(params)
         self._obj = obj
@@ -129,7 +130,7 @@ def _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set):
     if plugin_set is None:
         plugin_set = bt2.find_plugins()
     else:
-        utils._check_type(plugin_set, bt2_plugin._PluginSet)
+        bt2_utils._check_type(plugin_set, bt2_plugin._PluginSet)
 
     res_ptr = native_bt.bt2_auto_discover_source_components(
         inputs._ptr, plugin_set._ptr
@@ -144,7 +145,7 @@ def _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set):
     assert "status" in res
 
     status = res["status"]
-    utils._handle_func_status(status, "cannot auto-discover source components")
+    bt2_utils._handle_func_status(status, "cannot auto-discover source components")
 
     comp_specs = []
     comp_specs_raw = res["results"]
@@ -264,7 +265,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator):
         end=None,
         plugin_set=None,
     ):
-        utils._check_bool(stream_intersection_mode)
+        bt2_utils._check_bool(stream_intersection_mode)
         self._stream_intersection_mode = stream_intersection_mode
         self._begin_ns = _get_ns(begin)
         self._end_ns = _get_ns(end)
index dcc0a2f350c4d573c5ca87c7cd634b3da5b697ab..7bdd512e1161685dea759c9873d72fc449308aff 100644 (file)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+from bt2 import native_bt
+from bt2 import object as bt2_object
+from bt2 import utils as bt2_utils
 import collections.abc
 import functools
 import numbers
@@ -81,7 +83,7 @@ def create_value(value):
     )
 
 
-class _ValueConst(object._SharedObject, metaclass=abc.ABCMeta):
+class _ValueConst(bt2_object._SharedObject, metaclass=abc.ABCMeta):
     @staticmethod
     def _get_ref(ptr):
         native_bt.value_get_ref(ptr)
@@ -337,7 +339,7 @@ class _UnsignedIntegerValueConst(_IntegerValueConst):
 
 class UnsignedIntegerValue(_UnsignedIntegerValueConst, _IntegerValue):
     _NAME = "Unsigned integer"
-    _check_int_range = staticmethod(utils._check_uint64)
+    _check_int_range = staticmethod(bt2_utils._check_uint64)
     _create_default_value = staticmethod(native_bt.value_integer_unsigned_create)
     _create_value = staticmethod(native_bt.value_integer_unsigned_create_init)
     _set_value = staticmethod(native_bt.value_integer_unsigned_set)
@@ -350,7 +352,7 @@ class _SignedIntegerValueConst(_IntegerValueConst):
 
 class SignedIntegerValue(_SignedIntegerValueConst, _IntegerValue):
     _NAME = "Signed integer"
-    _check_int_range = staticmethod(utils._check_int64)
+    _check_int_range = staticmethod(bt2_utils._check_int64)
     _create_default_value = staticmethod(native_bt.value_integer_signed_create)
     _create_value = staticmethod(native_bt.value_integer_signed_create_init)
     _set_value = staticmethod(native_bt.value_integer_signed_set)
@@ -399,7 +401,7 @@ class _StringValueConst(collections.abc.Sequence, _Value):
         if isinstance(value, _StringValueConst):
             value = value._value
 
-        utils._check_str(value)
+        bt2_utils._check_str(value)
         return value
 
     @property
@@ -448,7 +450,7 @@ class StringValue(_StringValueConst, _Value):
 
     def _set_value(self, value):
         status = native_bt.value_string_set(self._ptr, self._value_to_str(value))
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
 
     value = property(fset=_set_value)
 
@@ -546,7 +548,7 @@ class ArrayValue(_ArrayValueConst, _Container, collections.abc.MutableSequence,
             ptr = value._ptr
 
         status = native_bt.value_array_set_element_by_index(self._ptr, index, ptr)
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
 
     def append(self, value):
         value = create_value(value)
@@ -557,7 +559,7 @@ class ArrayValue(_ArrayValueConst, _Container, collections.abc.MutableSequence,
             ptr = value._ptr
 
         status = native_bt.value_array_append_element(self._ptr, ptr)
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
 
     def __iadd__(self, iterable):
         # Python will raise a TypeError if there's anything wrong with
@@ -625,7 +627,7 @@ class _MapValueConst(_ContainerConst, collections.abc.Mapping, _ValueConst):
         return native_bt.value_map_has_entry(self._ptr, key)
 
     def _check_key_type(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
 
     def _check_key(self, key):
         if key not in self:
@@ -670,7 +672,7 @@ class MapValue(_MapValueConst, _Container, collections.abc.MutableMapping, _Valu
             ptr = value._ptr
 
         status = native_bt.value_map_insert_entry(self._ptr, key, ptr)
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
 
 
 _TYPE_TO_OBJ = {
This page took 0.061036 seconds and 4 git commands to generate.