bt2c::Logger: remove unused cLevel() method
[babeltrace.git] / src / bindings / python / bt2 / bt2 / stream_class.py
index 885ba746dae01ae37b9db9ae5a0873453fe58804..5c6faa07fd6c25c3bd1352ffcb94e9534646200f 100644 (file)
@@ -2,13 +2,16 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, 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
-from bt2 import value as bt2_value
 import collections.abc
 
+from bt2 import utils as bt2_utils
+from bt2 import value as bt2_value
+from bt2 import object as bt2_object
+from bt2 import native_bt
+from bt2 import clock_class as bt2_clock_class
+from bt2 import event_class as bt2_event_class
+from bt2 import field_class as bt2_field_class
+
 
 def _bt2_trace_class():
     from bt2 import trace_class as bt2_trace_class
@@ -16,9 +19,15 @@ def _bt2_trace_class():
     return bt2_trace_class
 
 
-class _StreamClassConst(object._SharedObject, collections.abc.Mapping):
-    _get_ref = staticmethod(native_bt.stream_class_get_ref)
-    _put_ref = staticmethod(native_bt.stream_class_put_ref)
+class _StreamClassConst(bt2_object._SharedObject, collections.abc.Mapping):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.stream_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.stream_class_put_ref(ptr)
+
     _borrow_event_class_ptr_by_id = staticmethod(
         native_bt.stream_class_borrow_event_class_by_id_const
     )
@@ -46,7 +55,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:
@@ -165,8 +174,14 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping):
 
 
 class _StreamClass(_StreamClassConst):
-    _get_ref = staticmethod(native_bt.stream_class_get_ref)
-    _put_ref = staticmethod(native_bt.stream_class_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.stream_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.stream_class_put_ref(ptr)
+
     _borrow_event_class_ptr_by_id = staticmethod(
         native_bt.stream_class_borrow_event_class_by_id
     )
@@ -224,7 +239,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)
@@ -257,7 +272,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)
 
@@ -294,7 +309,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"
         )
 
@@ -303,7 +318,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"
         )
 
@@ -334,12 +349,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:
@@ -348,30 +363,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:
@@ -384,8 +399,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:
@@ -399,8 +414,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(
This page took 0.026002 seconds and 4 git commands to generate.