bindings/python/bt2: Make the bt2 package importable
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 25 Apr 2019 21:10:31 +0000 (17:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:40 +0000 (18:19 -0400)
This patch changes the minimum necessary to make the bt2 package
importable.  In other words, for this command to succeed:

    $ tests/utils/test_python_bt2_env python3 -c "import bt2"

In some cases, I've replaced some references to concepts that don't
exist with the new concepts (e.g. some NOTIFICATION_TYPE_* to
MESSAGE_TYPE_*).  In other cases, (e.g. fields.py and field_types.py),
it was easier to remove the code, knowing we'll add it back when
tackling the tests that require these files.

After this milestone, we'll be able to at least run some tests that
import the bt2 package, so we'll be able to make sure we don't regress
things while we fix others.

Change-Id: I930d5a4dd129777cb40c607670e27002bb727e39
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452154
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
bindings/python/bt2/bt2/event_class.py
bindings/python/bt2/bt2/field_types.py
bindings/python/bt2/bt2/fields.py
bindings/python/bt2/bt2/notification.py
bindings/python/bt2/bt2/values.py

index d55113ae2c531ea6461e4e83583842ca928e13e9..b7a2c17e6f6b7ea9ed56d95fdb2c6f3ce82585fc 100644 (file)
@@ -30,8 +30,6 @@ import bt2
 
 
 class EventClassLogLevel:
-    UNKNOWN = native_bt.EVENT_CLASS_LOG_LEVEL_UNKNOWN
-    UNSPECIFIED = native_bt.EVENT_CLASS_LOG_LEVEL_UNSPECIFIED
     EMERGENCY = native_bt.EVENT_CLASS_LOG_LEVEL_EMERGENCY
     ALERT = native_bt.EVENT_CLASS_LOG_LEVEL_ALERT
     CRITICAL = native_bt.EVENT_CLASS_LOG_LEVEL_CRITICAL
index b6c68aaf9e19074ace5282ef35470f17f4dce96a..27a3746bde3f2175113a76daa905515a1c1e6391 100644 (file)
@@ -79,26 +79,6 @@ class _FieldType(object._Object, metaclass=abc.ABCMeta):
         return field
 
 
-class ByteOrder:
-    NATIVE = native_bt.BYTE_ORDER_NATIVE
-    LITTLE_ENDIAN = native_bt.BYTE_ORDER_LITTLE_ENDIAN
-    BIG_ENDIAN = native_bt.BYTE_ORDER_BIG_ENDIAN
-    NETWORK = native_bt.BYTE_ORDER_NETWORK
-
-
-class Encoding:
-    NONE = native_bt.STRING_ENCODING_NONE
-    UTF8 = native_bt.STRING_ENCODING_UTF8
-    ASCII = native_bt.STRING_ENCODING_ASCII
-
-
-class Base:
-    BINARY = native_bt.INTEGER_BASE_BINARY
-    OCTAL = native_bt.INTEGER_BASE_OCTAL
-    DECIMAL = native_bt.INTEGER_BASE_DECIMAL
-    HEXADECIMAL = native_bt.INTEGER_BASE_HEXADECIMAL
-
-
 class _AlignmentProp:
     @property
     def alignment(self):
@@ -691,12 +671,4 @@ class SequenceFieldType(_FieldType):
 
 
 _TYPE_ID_TO_OBJ = {
-    native_bt.FIELD_TYPE_ID_INTEGER: IntegerFieldType,
-    native_bt.FIELD_TYPE_ID_FLOAT: FloatingPointNumberFieldType,
-    native_bt.FIELD_TYPE_ID_ENUM: EnumerationFieldType,
-    native_bt.FIELD_TYPE_ID_STRING: StringFieldType,
-    native_bt.FIELD_TYPE_ID_STRUCT: StructureFieldType,
-    native_bt.FIELD_TYPE_ID_ARRAY: ArrayFieldType,
-    native_bt.FIELD_TYPE_ID_SEQUENCE: SequenceFieldType,
-    native_bt.FIELD_TYPE_ID_VARIANT: VariantFieldType,
 }
index 6ecd6958223d370659d0ef08007c299232a5cc56..9871bce88e6e847007e358c4836ebaf281396cff 100644 (file)
@@ -725,12 +725,4 @@ class _SequenceField(_ArraySequenceField):
 
 
 _TYPE_ID_TO_OBJ = {
-    native_bt.FIELD_TYPE_ID_INTEGER: _IntegerField,
-    native_bt.FIELD_TYPE_ID_FLOAT: _FloatingPointNumberField,
-    native_bt.FIELD_TYPE_ID_ENUM: _EnumerationField,
-    native_bt.FIELD_TYPE_ID_STRING: _StringField,
-    native_bt.FIELD_TYPE_ID_STRUCT: _StructureField,
-    native_bt.FIELD_TYPE_ID_ARRAY: _ArrayField,
-    native_bt.FIELD_TYPE_ID_SEQUENCE: _SequenceField,
-    native_bt.FIELD_TYPE_ID_VARIANT: _VariantField,
 }
index df22d71f22ce2c133f34cf7cb46e2e8481afbbb4..6ec9f16a139aace1910e87f5d2f769694b55d3b2 100644 (file)
@@ -69,7 +69,7 @@ class _CopyableNotification(_Notification):
 
 
 class EventNotification(_CopyableNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_EVENT
+    _TYPE = native_bt.MESSAGE_TYPE_EVENT
 
     def __init__(self, event, cc_prio_map=None):
         utils._check_type(event, bt2.event._Event)
@@ -125,7 +125,7 @@ class EventNotification(_CopyableNotification):
 
 
 class PacketBeginningNotification(_CopyableNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_PACKET_BEGIN
+    _TYPE = native_bt.MESSAGE_TYPE_PACKET_BEGINNING
 
     def __init__(self, packet):
         utils._check_type(packet, bt2.packet._Packet)
@@ -160,7 +160,7 @@ class PacketBeginningNotification(_CopyableNotification):
 
 
 class PacketEndNotification(_CopyableNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_PACKET_END
+    _TYPE = native_bt.MESSAGE_TYPE_PACKET_END
 
     def __init__(self, packet):
         utils._check_type(packet, bt2.packet._Packet)
@@ -195,7 +195,7 @@ class PacketEndNotification(_CopyableNotification):
 
 
 class StreamBeginningNotification(_CopyableNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_STREAM_BEGIN
+    _TYPE = native_bt.MESSAGE_TYPE_STREAM_BEGINNING
 
     def __init__(self, stream):
         utils._check_type(stream, bt2.stream._Stream)
@@ -230,7 +230,7 @@ class StreamBeginningNotification(_CopyableNotification):
 
 
 class StreamEndNotification(_CopyableNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_STREAM_END
+    _TYPE = native_bt.MESSAGE_TYPE_STREAM_END
 
     def __init__(self, stream):
         utils._check_type(stream, bt2.stream._Stream)
@@ -307,7 +307,7 @@ class _InactivityNotificationClockValues(collections.abc.Mapping):
 
 
 class InactivityNotification(_CopyableNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_INACTIVITY
+    _TYPE = native_bt.MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY
 
     def __init__(self, cc_prio_map=None):
         if cc_prio_map is not None:
@@ -422,7 +422,7 @@ class _DiscardedElementsNotification(_Notification):
 
 
 class _DiscardedPacketsNotification(_DiscardedElementsNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_DISCARDED_PACKETS
+    _TYPE = native_bt.MESSAGE_TYPE_DISCARDED_PACKETS
 
     @property
     def count(self):
@@ -458,7 +458,7 @@ class _DiscardedPacketsNotification(_DiscardedElementsNotification):
 
 
 class _DiscardedEventsNotification(_DiscardedElementsNotification):
-    _TYPE = native_bt.NOTIFICATION_TYPE_DISCARDED_EVENTS
+    _TYPE = native_bt.MESSAGE_TYPE_DISCARDED_EVENTS
 
     @property
     def count(self):
@@ -494,12 +494,12 @@ class _DiscardedEventsNotification(_DiscardedElementsNotification):
 
 
 _NOTIF_TYPE_TO_CLS = {
-    native_bt.NOTIFICATION_TYPE_EVENT: EventNotification,
-    native_bt.NOTIFICATION_TYPE_PACKET_BEGIN: PacketBeginningNotification,
-    native_bt.NOTIFICATION_TYPE_PACKET_END: PacketEndNotification,
-    native_bt.NOTIFICATION_TYPE_STREAM_BEGIN: StreamBeginningNotification,
-    native_bt.NOTIFICATION_TYPE_STREAM_END: StreamEndNotification,
-    native_bt.NOTIFICATION_TYPE_INACTIVITY: InactivityNotification,
-    native_bt.NOTIFICATION_TYPE_DISCARDED_PACKETS: _DiscardedPacketsNotification,
-    native_bt.NOTIFICATION_TYPE_DISCARDED_EVENTS: _DiscardedEventsNotification,
+    native_bt.MESSAGE_TYPE_EVENT: EventNotification,
+    native_bt.MESSAGE_TYPE_PACKET_BEGINNING: PacketBeginningNotification,
+    native_bt.MESSAGE_TYPE_PACKET_END: PacketEndNotification,
+    native_bt.MESSAGE_TYPE_STREAM_BEGINNING: StreamBeginningNotification,
+    native_bt.MESSAGE_TYPE_STREAM_END: StreamEndNotification,
+    native_bt.MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: InactivityNotification,
+    native_bt.MESSAGE_TYPE_DISCARDED_PACKETS: _DiscardedPacketsNotification,
+    native_bt.MESSAGE_TYPE_DISCARDED_EVENTS: _DiscardedEventsNotification,
 }
index 0db998d18588c0829275fe4e3ea0eb75bf25bfea..f36d2ea991728fcc62f910202a263d4425b2408b 100644 (file)
@@ -729,7 +729,7 @@ class MapValue(_Container, collections.abc.MutableMapping, _Value):
 _TYPE_TO_OBJ = {
     native_bt.VALUE_TYPE_BOOL: BoolValue,
     native_bt.VALUE_TYPE_INTEGER: IntegerValue,
-    native_bt.VALUE_TYPE_FLOAT: FloatValue,
+    native_bt.VALUE_TYPE_REAL: FloatValue,
     native_bt.VALUE_TYPE_STRING: StringValue,
     native_bt.VALUE_TYPE_ARRAY: ArrayValue,
     native_bt.VALUE_TYPE_MAP: MapValue,
This page took 0.030077 seconds and 4 git commands to generate.