python: fix all 'imported but unused' warnings
[babeltrace.git] / src / bindings / python / bt2 / bt2 / event_class.py
index d3141b86f0a79a0362c9cd3fc6ad18be343c41e2..afa42d03afee8b4d398fe0fc84db309cc9aff96b 100644 (file)
 # THE SOFTWARE.
 
 from bt2 import native_bt, object, utils
-import bt2.field_class
-import bt2.value
-import bt2.event
-import bt2
+from bt2 import field_class as bt2_field_class
+from bt2 import value as bt2_value
+from bt2 import stream_class as bt2_stream_class
 
 
 class EventClassLogLevel:
@@ -54,7 +53,20 @@ class _EventClass(object._SharedObject):
         sc_ptr = native_bt.event_class_borrow_stream_class(self._ptr)
 
         if sc_ptr is not None:
-            return bt2.stream_class._StreamClass._create_from_ptr_and_get_ref(sc_ptr)
+            return bt2_stream_class._StreamClass._create_from_ptr_and_get_ref(sc_ptr)
+
+    @property
+    def user_attributes(self):
+        ptr = native_bt.event_class_borrow_user_attributes(self._ptr)
+        assert ptr is not None
+        return bt2_value._create_from_ptr_and_get_ref(ptr)
+
+    def _user_attributes(self, user_attributes):
+        value = bt2_value.create_value(user_attributes)
+        utils._check_type(value, bt2_value.MapValue)
+        native_bt.event_class_set_user_attributes(self._ptr, value._ptr)
+
+    _user_attributes = property(fset=_user_attributes)
 
     @property
     def name(self):
@@ -112,25 +124,31 @@ class _EventClass(object._SharedObject):
 
     def _emf_uri(self, emf_uri):
         utils._check_str(emf_uri)
-        ret = native_bt.event_class_set_emf_uri(self._ptr, emf_uri)
-        utils._handle_ret(ret, "cannot set event class object's 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")
 
     _emf_uri = property(fset=_emf_uri)
 
     @property
     def specific_context_field_class(self):
-        fc_ptr = native_bt.event_class_borrow_specific_context_field_class_const(self._ptr)
+        fc_ptr = native_bt.event_class_borrow_specific_context_field_class_const(
+            self._ptr
+        )
 
         if fc_ptr is None:
             return
 
-        return bt2.field_class._create_field_class_from_ptr_and_get_ref(fc_ptr)
+        return bt2_field_class._create_field_class_from_ptr_and_get_ref(fc_ptr)
 
     def _specific_context_field_class(self, context_field_class):
         if context_field_class is not None:
-            utils._check_type(context_field_class, bt2.field_class._StructureFieldClass)
-            ret = native_bt.event_class_set_specific_context_field_class(self._ptr, context_field_class._ptr)
-            utils._handle_ret(ret, "cannot set event class object's context field class")
+            utils._check_type(context_field_class, bt2_field_class._StructureFieldClass)
+            status = native_bt.event_class_set_specific_context_field_class(
+                self._ptr, context_field_class._ptr
+            )
+            utils._handle_func_status(
+                status, "cannot set event class object's context field class"
+            )
 
     _specific_context_field_class = property(fset=_specific_context_field_class)
 
@@ -141,13 +159,17 @@ class _EventClass(object._SharedObject):
         if fc_ptr is None:
             return
 
-        return bt2.field_class._create_field_class_from_ptr_and_get_ref(fc_ptr)
+        return bt2_field_class._create_field_class_from_ptr_and_get_ref(fc_ptr)
 
     def _payload_field_class(self, payload_field_class):
         if payload_field_class is not None:
-            utils._check_type(payload_field_class, bt2.field_class._StructureFieldClass)
-            ret = native_bt.event_class_set_payload_field_class(self._ptr, payload_field_class._ptr)
-            utils._handle_ret(ret, "cannot set event class object's payload field class")
+            utils._check_type(payload_field_class, bt2_field_class._StructureFieldClass)
+            status = native_bt.event_class_set_payload_field_class(
+                self._ptr, payload_field_class._ptr
+            )
+            utils._handle_func_status(
+                status, "cannot set event class object's payload field class"
+            )
 
     _payload_field_class = property(fset=_payload_field_class)
 
This page took 0.026172 seconds and 4 git commands to generate.