bt2: remove unused imports
[babeltrace.git] / src / bindings / python / bt2 / bt2 / field_class.py
index 1128e4df689ef56e8eb1c76061d680e4ba52a2f5..18dbed930fc34437742755079ddaee23ca61bc3c 100644 (file)
@@ -22,9 +22,8 @@
 
 from bt2 import native_bt, object, utils
 import collections.abc
-import bt2.field
-import bt2.field_path
-import bt2.integer_range_set
+from bt2 import field_path as bt2_field_path
+from bt2 import integer_range_set as bt2_integer_range_set
 import bt2
 
 
@@ -46,7 +45,7 @@ class _FieldClass(object._SharedObject):
 
     def _check_create_status(self, ptr):
         if ptr is None:
-            raise bt2.CreationError(
+            raise bt2._MemoryError(
                 'cannot create {} field class object'.format(self._NAME.lower())
             )
 
@@ -134,22 +133,22 @@ class _EnumerationFieldClassMapping:
 
 
 class _UnsignedEnumerationFieldClassMapping(_EnumerationFieldClassMapping):
-    _ranges_type = bt2.integer_range_set.UnsignedIntegerRangeSet
+    _ranges_type = bt2_integer_range_set.UnsignedIntegerRangeSet
     _as_enumeration_field_class_mapping_ptr = staticmethod(
-        native_bt.field_class_unsigned_enumeration_mapping_as_mapping_const
+        native_bt.field_class_enumeration_unsigned_mapping_as_mapping_const
     )
     _mapping_borrow_ranges_ptr = staticmethod(
-        native_bt.field_class_unsigned_enumeration_mapping_borrow_ranges_const
+        native_bt.field_class_enumeration_unsigned_mapping_borrow_ranges_const
     )
 
 
 class _SignedEnumerationFieldClassMapping(_EnumerationFieldClassMapping):
-    _ranges_type = bt2.integer_range_set.SignedIntegerRangeSet
+    _ranges_type = bt2_integer_range_set.SignedIntegerRangeSet
     _as_enumeration_field_class_mapping_ptr = staticmethod(
-        native_bt.field_class_signed_enumeration_mapping_as_mapping_const
+        native_bt.field_class_enumeration_signed_mapping_as_mapping_const
     )
     _mapping_borrow_ranges_ptr = staticmethod(
-        native_bt.field_class_signed_enumeration_mapping_borrow_ranges_const
+        native_bt.field_class_enumeration_signed_mapping_borrow_ranges_const
     )
 
 
@@ -164,7 +163,7 @@ class _EnumerationFieldClass(_IntegerFieldClass, collections.abc.Mapping):
         utils._check_type(ranges, self._range_set_type)
 
         if label in self:
-            raise bt2.Error("duplicate mapping label '{}'".format(label))
+            raise ValueError("duplicate mapping label '{}'".format(label))
 
         status = self._add_mapping(self._ptr, label, ranges._ptr)
         utils._handle_func_status(
@@ -203,12 +202,12 @@ class _UnsignedEnumerationFieldClass(
     _EnumerationFieldClass, _UnsignedIntegerFieldClass
 ):
     _NAME = 'Unsigned enumeration'
-    _range_set_type = bt2.integer_range_set.UnsignedIntegerRangeSet
-    _add_mapping = staticmethod(native_bt.field_class_unsigned_enumeration_add_mapping)
+    _range_set_type = bt2_integer_range_set.UnsignedIntegerRangeSet
+    _add_mapping = staticmethod(native_bt.field_class_enumeration_unsigned_add_mapping)
 
     @staticmethod
     def _get_mapping_by_index(enum_ptr, index):
-        mapping_ptr = native_bt.field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+        mapping_ptr = native_bt.field_class_enumeration_unsigned_borrow_mapping_by_index_const(
             enum_ptr, index
         )
         assert mapping_ptr is not None
@@ -216,7 +215,7 @@ class _UnsignedEnumerationFieldClass(
 
     @staticmethod
     def _get_mapping_by_label(enum_ptr, label):
-        mapping_ptr = native_bt.field_class_unsigned_enumeration_borrow_mapping_by_label_const(
+        mapping_ptr = native_bt.field_class_enumeration_unsigned_borrow_mapping_by_label_const(
             enum_ptr, label
         )
 
@@ -228,19 +227,19 @@ class _UnsignedEnumerationFieldClass(
     @staticmethod
     def _get_mapping_labels_for_value(enum_ptr, value):
         utils._check_uint64(value)
-        return native_bt.field_class_unsigned_enumeration_get_mapping_labels_for_value(
+        return native_bt.field_class_enumeration_unsigned_get_mapping_labels_for_value(
             enum_ptr, value
         )
 
 
 class _SignedEnumerationFieldClass(_EnumerationFieldClass, _SignedIntegerFieldClass):
     _NAME = 'Signed enumeration'
-    _range_set_type = bt2.integer_range_set.SignedIntegerRangeSet
-    _add_mapping = staticmethod(native_bt.field_class_signed_enumeration_add_mapping)
+    _range_set_type = bt2_integer_range_set.SignedIntegerRangeSet
+    _add_mapping = staticmethod(native_bt.field_class_enumeration_signed_add_mapping)
 
     @staticmethod
     def _get_mapping_by_index(enum_ptr, index):
-        mapping_ptr = native_bt.field_class_signed_enumeration_borrow_mapping_by_index_const(
+        mapping_ptr = native_bt.field_class_enumeration_signed_borrow_mapping_by_index_const(
             enum_ptr, index
         )
         assert mapping_ptr is not None
@@ -248,7 +247,7 @@ class _SignedEnumerationFieldClass(_EnumerationFieldClass, _SignedIntegerFieldCl
 
     @staticmethod
     def _get_mapping_by_label(enum_ptr, label):
-        mapping_ptr = native_bt.field_class_signed_enumeration_borrow_mapping_by_label_const(
+        mapping_ptr = native_bt.field_class_enumeration_signed_borrow_mapping_by_label_const(
             enum_ptr, label
         )
 
@@ -260,7 +259,7 @@ class _SignedEnumerationFieldClass(_EnumerationFieldClass, _SignedIntegerFieldCl
     @staticmethod
     def _get_mapping_labels_for_value(enum_ptr, value):
         utils._check_int64(value)
-        return native_bt.field_class_signed_enumeration_get_mapping_labels_for_value(
+        return native_bt.field_class_enumeration_signed_get_mapping_labels_for_value(
             enum_ptr, value
         )
 
@@ -291,7 +290,7 @@ class _StructureFieldClass(_FieldClass, collections.abc.Mapping):
         utils._check_type(field_class, _FieldClass)
 
         if name in self:
-            raise bt2.Error("duplicate member name '{}'".format(name))
+            raise ValueError("duplicate member name '{}'".format(name))
 
         status = native_bt.field_class_structure_append_member(
             self._ptr, name, field_class._ptr
@@ -447,7 +446,7 @@ class _VariantFieldClassWithoutSelector(_VariantFieldClass):
         utils._check_type(field_class, _FieldClass)
 
         if name in self:
-            raise bt2.Error("duplicate option name '{}'".format(name))
+            raise ValueError("duplicate option name '{}'".format(name))
 
         status = native_bt.field_class_variant_without_selector_append_option(
             self._ptr, name, field_class._ptr
@@ -489,7 +488,7 @@ class _VariantFieldClassWithSelector(_VariantFieldClass):
         if ptr is None:
             return
 
-        return bt2.field_path._FieldPath._create_from_ptr_and_get_ref(ptr)
+        return bt2_field_path._FieldPath._create_from_ptr_and_get_ref(ptr)
 
     def append_option(self, name, field_class, ranges):
         utils._check_str(name)
@@ -497,7 +496,7 @@ class _VariantFieldClassWithSelector(_VariantFieldClass):
         utils._check_type(ranges, self._range_set_type)
 
         if name in self:
-            raise bt2.Error("duplicate option name '{}'".format(name))
+            raise ValueError("duplicate option name '{}'".format(name))
 
         if len(ranges) == 0:
             raise ValueError('range set is empty')
@@ -519,41 +518,41 @@ class _VariantFieldClassWithSelector(_VariantFieldClass):
 class _VariantFieldClassWithUnsignedSelector(_VariantFieldClassWithSelector):
     _NAME = 'Variant (with unsigned selector)'
     _borrow_option_by_name_ptr = staticmethod(
-        native_bt.field_class_variant_with_unsigned_selector_borrow_option_by_name_const
+        native_bt.field_class_variant_with_selector_unsigned_borrow_option_by_name_const
     )
     _borrow_member_by_index_ptr = staticmethod(
-        native_bt.field_class_variant_with_unsigned_selector_borrow_option_by_index_const
+        native_bt.field_class_variant_with_selector_unsigned_borrow_option_by_index_const
     )
     _as_option_ptr = staticmethod(
-        native_bt.field_class_variant_with_unsigned_selector_option_as_option_const
+        native_bt.field_class_variant_with_selector_unsigned_option_as_option_const
     )
     _append_option = staticmethod(
-        native_bt.field_class_variant_with_unsigned_selector_append_option
+        native_bt.field_class_variant_with_selector_unsigned_append_option
     )
     _option_borrow_ranges_ptr = staticmethod(
-        native_bt.field_class_variant_with_unsigned_selector_option_borrow_ranges_const
+        native_bt.field_class_variant_with_selector_unsigned_option_borrow_ranges_const
     )
-    _range_set_type = bt2.integer_range_set.UnsignedIntegerRangeSet
+    _range_set_type = bt2_integer_range_set.UnsignedIntegerRangeSet
 
 
 class _VariantFieldClassWithSignedSelector(_VariantFieldClassWithSelector):
     _NAME = 'Variant (with signed selector)'
     _borrow_option_by_name_ptr = staticmethod(
-        native_bt.field_class_variant_with_signed_selector_borrow_option_by_name_const
+        native_bt.field_class_variant_with_selector_signed_borrow_option_by_name_const
     )
     _borrow_member_by_index_ptr = staticmethod(
-        native_bt.field_class_variant_with_signed_selector_borrow_option_by_index_const
+        native_bt.field_class_variant_with_selector_signed_borrow_option_by_index_const
     )
     _as_option_ptr = staticmethod(
-        native_bt.field_class_variant_with_signed_selector_option_as_option_const
+        native_bt.field_class_variant_with_selector_signed_option_as_option_const
     )
     _append_option = staticmethod(
-        native_bt.field_class_variant_with_signed_selector_append_option
+        native_bt.field_class_variant_with_selector_signed_append_option
     )
     _option_borrow_ranges_ptr = staticmethod(
-        native_bt.field_class_variant_with_signed_selector_option_borrow_ranges_const
+        native_bt.field_class_variant_with_selector_signed_option_borrow_ranges_const
     )
-    _range_set_type = bt2.integer_range_set.SignedIntegerRangeSet
+    _range_set_type = bt2_integer_range_set.SignedIntegerRangeSet
 
 
 class _ArrayFieldClass(_FieldClass):
@@ -568,19 +567,19 @@ class _ArrayFieldClass(_FieldClass):
 class _StaticArrayFieldClass(_ArrayFieldClass):
     @property
     def length(self):
-        return native_bt.field_class_static_array_get_length(self._ptr)
+        return native_bt.field_class_array_static_get_length(self._ptr)
 
 
 class _DynamicArrayFieldClass(_ArrayFieldClass):
     @property
     def length_field_path(self):
-        ptr = native_bt.field_class_dynamic_array_borrow_length_field_path_const(
+        ptr = native_bt.field_class_array_dynamic_borrow_length_field_path_const(
             self._ptr
         )
         if ptr is None:
             return
 
-        return bt2.field_path._FieldPath._create_from_ptr_and_get_ref(ptr)
+        return bt2_field_path._FieldPath._create_from_ptr_and_get_ref(ptr)
 
 
 _FIELD_CLASS_TYPE_TO_OBJ = {
This page took 0.027409 seconds and 4 git commands to generate.