Apply black code formatter on all Python code
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 18 Jul 2019 14:11:55 +0000 (10:11 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 20 Jul 2019 12:42:46 +0000 (08:42 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I2b66d32d12c93d353097b25d80050e4dcfe5b1ff
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1642
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
55 files changed:
doc/bindings/python/source/conf.py
src/bindings/python/bt2/bt2/__init__.py.in
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/connection.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/message.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/object.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/utils.py
src/bindings/python/bt2/bt2/value.py
src/bindings/python/bt2/setup.py.in
tests/bindings/python/bt2/test_clock_class.py
tests/bindings/python/bt2/test_component_class.py
tests/bindings/python/bt2/test_connection.py
tests/bindings/python/bt2/test_ctf_writer_clock.py
tests/bindings/python/bt2/test_event.py
tests/bindings/python/bt2/test_event_class.py
tests/bindings/python/bt2/test_field.py
tests/bindings/python/bt2/test_field_class.py
tests/bindings/python/bt2/test_graph.py
tests/bindings/python/bt2/test_integer_range_set.py
tests/bindings/python/bt2/test_message.py
tests/bindings/python/bt2/test_message_iterator.py
tests/bindings/python/bt2/test_packet.py
tests/bindings/python/bt2/test_plugin.py
tests/bindings/python/bt2/test_port.py
tests/bindings/python/bt2/test_query_executor.py
tests/bindings/python/bt2/test_stream_class.py
tests/bindings/python/bt2/test_trace_class.py
tests/bindings/python/bt2/test_trace_collection_message_iterator.py
tests/bindings/python/bt2/test_value.py
tests/bindings/python/bt2/utils.py
tests/data/plugins/flt.utils.trimmer/bt_plugin_trimmer_test.py
tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.py
tests/plugins/src.ctf.fs/query/test_query_trace_info.py
tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py
tests/utils/python/testrunner.py

index e39de7c66dcbc0ea6de9e4a10dda74d2af70ebfb..84c05bbc902497fa34119e61e7a3522970eab5e2 100644 (file)
@@ -6,10 +6,7 @@ import os
 
 # general configuration
 needs_sphinx = '1.2'
-extensions = [
-    'sphinx.ext.autodoc',
-    'sphinx.ext.ifconfig',
-]
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.ifconfig']
 templates_path = ['_templates']
 source_suffix = '.rst'
 source_encoding = 'utf-8-sig'
index 1e5b8ee38c848c5081260361df6f7bd0bcbd9d62..49e02d4a3f296e30b9b0cbc7833cea831a9d6a97 100644 (file)
@@ -126,8 +126,12 @@ def _init_and_register_exit():
     import atexit
 
     atexit.register(_native_bt.bt2_cc_exit_handler)
-    version = (_native_bt.version_get_major(), _native_bt.version_get_minor(),
-               _native_bt.version_get_patch(), _native_bt.version_get_extra())
+    version = (
+        _native_bt.version_get_major(),
+        _native_bt.version_get_minor(),
+        _native_bt.version_get_patch(),
+        _native_bt.version_get_extra(),
+    )
     _native_bt.bt2_cc_init_from_bt2()
 
 
index 6d0ff72a6cecfe4136d4adb4669d0d0fe7d38382..932a26635bf97b29fe0fb1f720074836de3b0264 100644 (file)
@@ -59,8 +59,7 @@ class _ClockClass(object._SharedObject):
     def _name(self, name):
         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")
+        utils._handle_func_status(status, "cannot set clock class object's name")
 
     _name = property(fset=_name)
 
@@ -71,8 +70,7 @@ class _ClockClass(object._SharedObject):
     def _description(self, description):
         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")
+        utils._handle_func_status(status, "cannot set clock class object's description")
 
     _description = property(fset=_description)
 
@@ -114,7 +112,9 @@ class _ClockClass(object._SharedObject):
 
     def _origin_is_unix_epoch(self, origin_is_unix_epoch):
         utils._check_bool(origin_is_unix_epoch)
-        native_bt.clock_class_set_origin_is_unix_epoch(self._ptr, int(origin_is_unix_epoch))
+        native_bt.clock_class_set_origin_is_unix_epoch(
+            self._ptr, int(origin_is_unix_epoch)
+        )
 
     _origin_is_unix_epoch = property(fset=_origin_is_unix_epoch)
 
index adf03e3938623794d4e1abd6a5c95d2a95f129d8..5c53fdd7087798457b40d05b1afa3b16cd46b6ea 100644 (file)
@@ -41,8 +41,9 @@ class _ClockSnapshot(object._UniqueObject):
     @property
     def ns_from_origin(self):
         status, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr)
-        utils._handle_func_status(status,
-                                  "cannot get clock snapshot's nanoseconds from origin")
+        utils._handle_func_status(
+            status, "cannot get clock snapshot's nanoseconds from origin"
+        )
         return ns
 
     def __eq__(self, other):
index 18b502ac6c1e150fbb328bab9f7bac0451061678..ef86bbcf50f1f42028e4789208e6222c6e90601b 100644 (file)
@@ -41,6 +41,7 @@ import os
 #   - _bt_as_component_class_ptr: static method, convert the passed component class
 #     pointer to a 'bt_component_class *'.
 
+
 class _GenericComponentClass(object._SharedObject):
     @property
     def name(self):
@@ -76,19 +77,25 @@ class _GenericComponentClass(object._SharedObject):
 class _GenericSourceComponentClass(_GenericComponentClass):
     _get_ref = staticmethod(native_bt.component_class_source_get_ref)
     _put_ref = staticmethod(native_bt.component_class_source_put_ref)
-    _bt_as_component_class_ptr = staticmethod(native_bt.component_class_source_as_component_class)
+    _bt_as_component_class_ptr = staticmethod(
+        native_bt.component_class_source_as_component_class
+    )
 
 
 class _GenericFilterComponentClass(_GenericComponentClass):
     _get_ref = staticmethod(native_bt.component_class_filter_get_ref)
     _put_ref = staticmethod(native_bt.component_class_filter_put_ref)
-    _bt_as_component_class_ptr = staticmethod(native_bt.component_class_filter_as_component_class)
+    _bt_as_component_class_ptr = staticmethod(
+        native_bt.component_class_filter_as_component_class
+    )
 
 
 class _GenericSinkComponentClass(_GenericComponentClass):
     _get_ref = staticmethod(native_bt.component_class_sink_get_ref)
     _put_ref = staticmethod(native_bt.component_class_sink_put_ref)
-    _bt_as_component_class_ptr = staticmethod(native_bt.component_class_sink_as_component_class)
+    _bt_as_component_class_ptr = staticmethod(
+        native_bt.component_class_sink_as_component_class
+    )
 
 
 class _PortIterator(collections.abc.Iterator):
@@ -119,11 +126,14 @@ class _ComponentPorts(collections.abc.Mapping):
     # bt_component_sink *.  Its type must match the type expected by the
     # functions passed as arguments.
 
-    def __init__(self, component_ptr,
-                 borrow_port_ptr_by_name,
-                 borrow_port_ptr_at_index,
-                 get_port_count,
-                 port_pycls):
+    def __init__(
+        self,
+        component_ptr,
+        borrow_port_ptr_by_name,
+        borrow_port_ptr_at_index,
+        get_port_count,
+        port_pycls,
+    ):
         self._component_ptr = component_ptr
         self._borrow_port_ptr_by_name = borrow_port_ptr_by_name
         self._borrow_port_ptr_at_index = borrow_port_ptr_at_index
@@ -161,6 +171,7 @@ class _ComponentPorts(collections.abc.Mapping):
 #   - _bt_as_component_ptr: static method, must return the passed specialized
 #     component pointer (e.g. 'bt_component_sink *') as a 'bt_component *'.
 
+
 class _Component:
     @property
     def name(self):
@@ -178,7 +189,9 @@ class _Component:
     def cls(self):
         cc_ptr = self._bt_borrow_component_class_ptr(self._ptr)
         assert cc_ptr is not None
-        return _create_component_class_from_ptr_and_get_ref(cc_ptr, self._bt_comp_cls_type)
+        return _create_component_class_from_ptr_and_get_ref(
+            cc_ptr, self._bt_comp_cls_type
+        )
 
     def __eq__(self, other):
         if not hasattr(other, 'addr'):
@@ -188,23 +201,35 @@ class _Component:
 
 
 class _SourceComponent(_Component):
-    _bt_borrow_component_class_ptr = staticmethod(native_bt.component_source_borrow_class_const)
+    _bt_borrow_component_class_ptr = staticmethod(
+        native_bt.component_source_borrow_class_const
+    )
     _bt_comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_SOURCE
-    _bt_as_component_class_ptr = staticmethod(native_bt.component_class_source_as_component_class)
+    _bt_as_component_class_ptr = staticmethod(
+        native_bt.component_class_source_as_component_class
+    )
     _bt_as_component_ptr = staticmethod(native_bt.component_source_as_component_const)
 
 
 class _FilterComponent(_Component):
-    _bt_borrow_component_class_ptr = staticmethod(native_bt.component_filter_borrow_class_const)
+    _bt_borrow_component_class_ptr = staticmethod(
+        native_bt.component_filter_borrow_class_const
+    )
     _bt_comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_FILTER
-    _bt_as_component_class_ptr = staticmethod(native_bt.component_class_filter_as_component_class)
+    _bt_as_component_class_ptr = staticmethod(
+        native_bt.component_class_filter_as_component_class
+    )
     _bt_as_component_ptr = staticmethod(native_bt.component_filter_as_component_const)
 
 
 class _SinkComponent(_Component):
-    _bt_borrow_component_class_ptr = staticmethod(native_bt.component_sink_borrow_class_const)
+    _bt_borrow_component_class_ptr = staticmethod(
+        native_bt.component_sink_borrow_class_const
+    )
     _bt_comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_SINK
-    _bt_as_component_class_ptr = staticmethod(native_bt.component_class_sink_as_component_class)
+    _bt_as_component_class_ptr = staticmethod(
+        native_bt.component_class_sink_as_component_class
+    )
     _bt_as_component_ptr = staticmethod(native_bt.component_sink_as_component_const)
 
 
@@ -216,11 +241,13 @@ class _GenericSourceComponent(object._SharedObject, _SourceComponent):
 
     @property
     def output_ports(self):
-        return _ComponentPorts(self._ptr,
-                               native_bt.component_source_borrow_output_port_by_name_const,
-                               native_bt.component_source_borrow_output_port_by_index_const,
-                               native_bt.component_source_get_output_port_count,
-                               bt2.port._OutputPort)
+        return _ComponentPorts(
+            self._ptr,
+            native_bt.component_source_borrow_output_port_by_name_const,
+            native_bt.component_source_borrow_output_port_by_index_const,
+            native_bt.component_source_get_output_port_count,
+            bt2.port._OutputPort,
+        )
 
 
 # This is analogous to _GenericFilterComponentClass, but for filter
@@ -231,19 +258,23 @@ class _GenericFilterComponent(object._SharedObject, _FilterComponent):
 
     @property
     def output_ports(self):
-        return _ComponentPorts(self._ptr,
-                               native_bt.component_filter_borrow_output_port_by_name_const,
-                               native_bt.component_filter_borrow_output_port_by_index_const,
-                               native_bt.component_filter_get_output_port_count,
-                               bt2.port._OutputPort)
+        return _ComponentPorts(
+            self._ptr,
+            native_bt.component_filter_borrow_output_port_by_name_const,
+            native_bt.component_filter_borrow_output_port_by_index_const,
+            native_bt.component_filter_get_output_port_count,
+            bt2.port._OutputPort,
+        )
 
     @property
     def input_ports(self):
-        return _ComponentPorts(self._ptr,
-                               native_bt.component_filter_borrow_input_port_by_name_const,
-                               native_bt.component_filter_borrow_input_port_by_index_const,
-                               native_bt.component_filter_get_input_port_count,
-                               bt2.port._InputPort)
+        return _ComponentPorts(
+            self._ptr,
+            native_bt.component_filter_borrow_input_port_by_name_const,
+            native_bt.component_filter_borrow_input_port_by_index_const,
+            native_bt.component_filter_get_input_port_count,
+            bt2.port._InputPort,
+        )
 
 
 # This is analogous to _GenericSinkComponentClass, but for sink
@@ -254,11 +285,13 @@ class _GenericSinkComponent(object._SharedObject, _SinkComponent):
 
     @property
     def input_ports(self):
-        return _ComponentPorts(self._ptr,
-                               native_bt.component_sink_borrow_input_port_by_name_const,
-                               native_bt.component_sink_borrow_input_port_by_index_const,
-                               native_bt.component_sink_get_input_port_count,
-                               bt2.port._InputPort)
+        return _ComponentPorts(
+            self._ptr,
+            native_bt.component_sink_borrow_input_port_by_name_const,
+            native_bt.component_sink_borrow_input_port_by_index_const,
+            native_bt.component_sink_get_input_port_count,
+            bt2.port._InputPort,
+        )
 
 
 _COMP_CLS_TYPE_TO_GENERIC_COMP_PYCLS = {
@@ -281,6 +314,7 @@ _COMP_CLS_TYPE_TO_GENERIC_COMP_CLS_PYCLS = {
 #
 #    Steals the reference to ptr from the caller.
 
+
 def _create_component_from_ptr(ptr, comp_cls_type):
     return _COMP_CLS_TYPE_TO_GENERIC_COMP_PYCLS[comp_cls_type]._create_from_ptr(ptr)
 
@@ -288,8 +322,11 @@ def _create_component_from_ptr(ptr, comp_cls_type):
 # Same as the above, but acquire a new reference instead of stealing the
 # reference from the caller.
 
+
 def _create_component_from_ptr_and_get_ref(ptr, comp_cls_type):
-    return _COMP_CLS_TYPE_TO_GENERIC_COMP_PYCLS[comp_cls_type]._create_from_ptr_and_get_ref(ptr)
+    return _COMP_CLS_TYPE_TO_GENERIC_COMP_PYCLS[
+        comp_cls_type
+    ]._create_from_ptr_and_get_ref(ptr)
 
 
 # Create a component class Python object of type
@@ -298,8 +335,11 @@ def _create_component_from_ptr_and_get_ref(ptr, comp_cls_type):
 #
 # Acquires a new reference to ptr.
 
+
 def _create_component_class_from_ptr_and_get_ref(ptr, comp_cls_type):
-    return _COMP_CLS_TYPE_TO_GENERIC_COMP_CLS_PYCLS[comp_cls_type]._create_from_ptr_and_get_ref(ptr)
+    return _COMP_CLS_TYPE_TO_GENERIC_COMP_CLS_PYCLS[
+        comp_cls_type
+    ]._create_from_ptr_and_get_ref(ptr)
 
 
 def _trim_docstring(docstring):
@@ -432,32 +472,43 @@ class _UserComponentType(type):
 
         if _UserSourceComponent in bases:
             _UserComponentType._bt_set_iterator_class(cls, iter_cls)
-            cc_ptr = native_bt.bt2_component_class_source_create(cls,
-                                                                 comp_cls_name,
-                                                                 comp_cls_descr,
-                                                                 comp_cls_help)
+            cc_ptr = native_bt.bt2_component_class_source_create(
+                cls, comp_cls_name, comp_cls_descr, comp_cls_help
+            )
         elif _UserFilterComponent in bases:
             _UserComponentType._bt_set_iterator_class(cls, iter_cls)
-            cc_ptr = native_bt.bt2_component_class_filter_create(cls,
-                                                                 comp_cls_name,
-                                                                 comp_cls_descr,
-                                                                 comp_cls_help)
+            cc_ptr = native_bt.bt2_component_class_filter_create(
+                cls, comp_cls_name, comp_cls_descr, comp_cls_help
+            )
         elif _UserSinkComponent in bases:
             if not hasattr(cls, '_graph_is_configured'):
-                raise bt2.IncompleteUserClass("cannot create component class '{}': missing a _graph_is_configured() method".format(class_name))
+                raise bt2.IncompleteUserClass(
+                    "cannot create component class '{}': missing a _graph_is_configured() method".format(
+                        class_name
+                    )
+                )
 
             if not hasattr(cls, '_consume'):
-                raise bt2.IncompleteUserClass("cannot create component class '{}': missing a _consume() method".format(class_name))
-
-            cc_ptr = native_bt.bt2_component_class_sink_create(cls,
-                                                               comp_cls_name,
-                                                               comp_cls_descr,
-                                                               comp_cls_help)
+                raise bt2.IncompleteUserClass(
+                    "cannot create component class '{}': missing a _consume() method".format(
+                        class_name
+                    )
+                )
+
+            cc_ptr = native_bt.bt2_component_class_sink_create(
+                cls, comp_cls_name, comp_cls_descr, comp_cls_help
+            )
         else:
-            raise bt2.IncompleteUserClass("cannot find a known component class base in the bases of '{}'".format(class_name))
+            raise bt2.IncompleteUserClass(
+                "cannot find a known component class base in the bases of '{}'".format(
+                    class_name
+                )
+            )
 
         if cc_ptr is None:
-            raise bt2.CreationError("cannot create component class '{}'".format(class_name))
+            raise bt2.CreationError(
+                "cannot create component class '{}'".format(class_name)
+            )
 
         cls._bt_cc_ptr = cc_ptr
 
@@ -478,18 +529,32 @@ class _UserComponentType(type):
         return self
 
     def __call__(cls, *args, **kwargs):
-        raise bt2.Error('cannot directly instantiate a user component from a Python module')
+        raise bt2.Error(
+            'cannot directly instantiate a user component from a Python module'
+        )
 
     @staticmethod
     def _bt_set_iterator_class(cls, iter_cls):
         if iter_cls is None:
-            raise bt2.IncompleteUserClass("cannot create component class '{}': missing message iterator class".format(cls.__name__))
+            raise bt2.IncompleteUserClass(
+                "cannot create component class '{}': missing message iterator class".format(
+                    cls.__name__
+                )
+            )
 
         if not issubclass(iter_cls, bt2.message_iterator._UserMessageIterator):
-            raise bt2.IncompleteUserClass("cannot create component class '{}': message iterator class does not inherit bt2._UserMessageIterator".format(cls.__name__))
+            raise bt2.IncompleteUserClass(
+                "cannot create component class '{}': message iterator class does not inherit bt2._UserMessageIterator".format(
+                    cls.__name__
+                )
+            )
 
         if not hasattr(iter_cls, '__next__'):
-            raise bt2.IncompleteUserClass("cannot create component class '{}': message iterator class is missing a __next__() method".format(cls.__name__))
+            raise bt2.IncompleteUserClass(
+                "cannot create component class '{}': message iterator class is missing a __next__() method".format(
+                    cls.__name__
+                )
+            )
 
         cls._iter_cls = iter_cls
 
@@ -520,8 +585,7 @@ class _UserComponentType(type):
         else:
             params = None
 
-        query_exec = bt2.QueryExecutor._create_from_ptr_and_get_ref(
-            query_exec_ptr)
+        query_exec = bt2.QueryExecutor._create_from_ptr_and_get_ref(query_exec_ptr)
 
         # this can raise, but the native side checks the exception
         results = cls._query(query_exec, obj, params, log_level)
@@ -551,6 +615,7 @@ class _UserComponentType(type):
             cc_ptr = cls._bt_as_component_class_ptr(cls._bt_cc_ptr)
             native_bt.component_class_put_ref(cc_ptr)
 
+
 # Subclasses must provide these methods or property:
 #
 #   - _bt_as_not_self_specific_component_ptr: static method, must return the passed
@@ -562,6 +627,7 @@ class _UserComponentType(type):
 #   - _bt_comp_cls_type: property, one of the native_bt.COMPONENT_CLASS_TYPE_*
 #     constants.
 
+
 class _UserComponent(metaclass=_UserComponentType):
     @property
     def name(self):
@@ -581,7 +647,9 @@ class _UserComponent(metaclass=_UserComponentType):
     def cls(self):
         comp_ptr = self._bt_as_not_self_specific_component_ptr(self._bt_ptr)
         cc_ptr = self._bt_borrow_component_class_ptr(comp_ptr)
-        return _create_component_class_from_ptr_and_get_ref(cc_ptr, self._bt_comp_cls_type)
+        return _create_component_class_from_ptr_and_get_ref(
+            cc_ptr, self._bt_comp_cls_type
+        )
 
     @property
     def addr(self):
@@ -596,9 +664,10 @@ class _UserComponent(metaclass=_UserComponentType):
     def _port_connected(self, port, other_port):
         pass
 
-    def _bt_port_connected_from_native(self, self_port_ptr, self_port_type, other_port_ptr):
-        port = bt2.port._create_self_from_ptr_and_get_ref(
-            self_port_ptr, self_port_type)
+    def _bt_port_connected_from_native(
+        self, self_port_ptr, self_port_type, other_port_ptr
+    ):
+        port = bt2.port._create_self_from_ptr_and_get_ref(self_port_ptr, self_port_type)
 
         if self_port_type == native_bt.PORT_TYPE_OUTPUT:
             other_port_type = native_bt.PORT_TYPE_INPUT
@@ -606,7 +675,8 @@ class _UserComponent(metaclass=_UserComponentType):
             other_port_type = native_bt.PORT_TYPE_OUTPUT
 
         other_port = bt2.port._create_from_ptr_and_get_ref(
-            other_port_ptr, other_port_type)
+            other_port_ptr, other_port_type
+        )
         self._port_connected(port, other_port)
 
     def _bt_graph_is_configured_from_native(self):
@@ -624,9 +694,16 @@ class _UserComponent(metaclass=_UserComponentType):
 
         return tc
 
-    def _create_clock_class(self, frequency=None, name=None, description=None,
-                            precision=None, offset=None, origin_is_unix_epoch=True,
-                            uuid=None):
+    def _create_clock_class(
+        self,
+        frequency=None,
+        name=None,
+        description=None,
+        precision=None,
+        offset=None,
+        origin_is_unix_epoch=True,
+        uuid=None,
+    ):
         ptr = self._bt_as_self_component_ptr(self._bt_ptr)
         cc_ptr = native_bt.clock_class_create(ptr)
 
@@ -659,8 +736,12 @@ class _UserComponent(metaclass=_UserComponentType):
 
 
 class _UserSourceComponent(_UserComponent, _SourceComponent):
-    _bt_as_not_self_specific_component_ptr = staticmethod(native_bt.self_component_source_as_component_source)
-    _bt_as_self_component_ptr = staticmethod(native_bt.self_component_source_as_self_component)
+    _bt_as_not_self_specific_component_ptr = staticmethod(
+        native_bt.self_component_source_as_component_source
+    )
+    _bt_as_self_component_ptr = staticmethod(
+        native_bt.self_component_source_as_self_component
+    )
 
     @property
     def _output_ports(self):
@@ -668,25 +749,32 @@ class _UserSourceComponent(_UserComponent, _SourceComponent):
             ptr = self._bt_as_not_self_specific_component_ptr(self_ptr)
             return native_bt.component_source_get_output_port_count(ptr)
 
-        return _ComponentPorts(self._bt_ptr,
-                               native_bt.self_component_source_borrow_output_port_by_name,
-                               native_bt.self_component_source_borrow_output_port_by_index,
-                               get_output_port_count,
-                               bt2.port._UserComponentOutputPort)
+        return _ComponentPorts(
+            self._bt_ptr,
+            native_bt.self_component_source_borrow_output_port_by_name,
+            native_bt.self_component_source_borrow_output_port_by_index,
+            get_output_port_count,
+            bt2.port._UserComponentOutputPort,
+        )
 
     def _add_output_port(self, name, user_data=None):
         utils._check_str(name)
         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(comp_status,
-                                  'cannot add output port to source component object')
+        utils._handle_func_status(
+            comp_status, 'cannot add output port to source component object'
+        )
         assert self_port_ptr is not None
         return bt2.port._UserComponentOutputPort._create_from_ptr(self_port_ptr)
 
 
 class _UserFilterComponent(_UserComponent, _FilterComponent):
-    _bt_as_not_self_specific_component_ptr = staticmethod(native_bt.self_component_filter_as_component_filter)
-    _bt_as_self_component_ptr = staticmethod(native_bt.self_component_filter_as_self_component)
+    _bt_as_not_self_specific_component_ptr = staticmethod(
+        native_bt.self_component_filter_as_component_filter
+    )
+    _bt_as_self_component_ptr = staticmethod(
+        native_bt.self_component_filter_as_self_component
+    )
 
     @property
     def _output_ports(self):
@@ -694,11 +782,13 @@ class _UserFilterComponent(_UserComponent, _FilterComponent):
             ptr = self._bt_as_not_self_specific_component_ptr(self_ptr)
             return native_bt.component_filter_get_output_port_count(ptr)
 
-        return _ComponentPorts(self._bt_ptr,
-                               native_bt.self_component_filter_borrow_output_port_by_name,
-                               native_bt.self_component_filter_borrow_output_port_by_index,
-                               get_output_port_count,
-                               bt2.port._UserComponentOutputPort)
+        return _ComponentPorts(
+            self._bt_ptr,
+            native_bt.self_component_filter_borrow_output_port_by_name,
+            native_bt.self_component_filter_borrow_output_port_by_index,
+            get_output_port_count,
+            bt2.port._UserComponentOutputPort,
+        )
 
     @property
     def _input_ports(self):
@@ -706,18 +796,21 @@ class _UserFilterComponent(_UserComponent, _FilterComponent):
             ptr = self._bt_as_not_self_specific_component_ptr(self_ptr)
             return native_bt.component_filter_get_input_port_count(ptr)
 
-        return _ComponentPorts(self._bt_ptr,
-                               native_bt.self_component_filter_borrow_input_port_by_name,
-                               native_bt.self_component_filter_borrow_input_port_by_index,
-                               get_input_port_count,
-                               bt2.port._UserComponentInputPort)
+        return _ComponentPorts(
+            self._bt_ptr,
+            native_bt.self_component_filter_borrow_input_port_by_name,
+            native_bt.self_component_filter_borrow_input_port_by_index,
+            get_input_port_count,
+            bt2.port._UserComponentInputPort,
+        )
 
     def _add_output_port(self, name, user_data=None):
         utils._check_str(name)
         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(comp_status,
-                                  'cannot add output port to filter component object')
+        utils._handle_func_status(
+            comp_status, 'cannot add output port to filter component object'
+        )
         assert self_port_ptr
         return bt2.port._UserComponentOutputPort._create_from_ptr(self_port_ptr)
 
@@ -725,15 +818,20 @@ class _UserFilterComponent(_UserComponent, _FilterComponent):
         utils._check_str(name)
         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(comp_status,
-                                  'cannot add input port to filter component object')
+        utils._handle_func_status(
+            comp_status, 'cannot add input port to filter component object'
+        )
         assert self_port_ptr
         return bt2.port._UserComponentInputPort._create_from_ptr(self_port_ptr)
 
 
 class _UserSinkComponent(_UserComponent, _SinkComponent):
-    _bt_as_not_self_specific_component_ptr = staticmethod(native_bt.self_component_sink_as_component_sink)
-    _bt_as_self_component_ptr = staticmethod(native_bt.self_component_sink_as_self_component)
+    _bt_as_not_self_specific_component_ptr = staticmethod(
+        native_bt.self_component_sink_as_component_sink
+    )
+    _bt_as_self_component_ptr = staticmethod(
+        native_bt.self_component_sink_as_self_component
+    )
 
     @property
     def _input_ports(self):
@@ -741,17 +839,20 @@ class _UserSinkComponent(_UserComponent, _SinkComponent):
             ptr = self._bt_as_not_self_specific_component_ptr(self_ptr)
             return native_bt.component_sink_get_input_port_count(ptr)
 
-        return _ComponentPorts(self._bt_ptr,
-                               native_bt.self_component_sink_borrow_input_port_by_name,
-                               native_bt.self_component_sink_borrow_input_port_by_index,
-                               get_input_port_count,
-                               bt2.port._UserComponentInputPort)
+        return _ComponentPorts(
+            self._bt_ptr,
+            native_bt.self_component_sink_borrow_input_port_by_name,
+            native_bt.self_component_sink_borrow_input_port_by_index,
+            get_input_port_count,
+            bt2.port._UserComponentInputPort,
+        )
 
     def _add_input_port(self, name, user_data=None):
         utils._check_str(name)
         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(comp_status,
-                                  'cannot add input port to sink component object')
+        utils._handle_func_status(
+            comp_status, 'cannot add input port to sink component object'
+        )
         assert self_port_ptr
         return bt2.port._UserComponentInputPort._create_from_ptr(self_port_ptr)
index 4c52a776b32d38c81f5429fd1198f09e9ba487a4..9ffd7bb1ed3b4d19697d4cf2ce48161ab1eb3b31 100644 (file)
@@ -33,11 +33,19 @@ class _Connection(bt2.object._SharedObject):
     @property
     def downstream_port(self):
         port_ptr = native_bt.connection_borrow_downstream_port_const(self._ptr)
-        utils._handle_ptr(port_ptr, "cannot get connection object's downstream port object")
-        return bt2.port._create_from_ptr_and_get_ref(port_ptr, native_bt.PORT_TYPE_INPUT)
+        utils._handle_ptr(
+            port_ptr, "cannot get connection object's downstream port object"
+        )
+        return bt2.port._create_from_ptr_and_get_ref(
+            port_ptr, native_bt.PORT_TYPE_INPUT
+        )
 
     @property
     def upstream_port(self):
         port_ptr = native_bt.connection_borrow_upstream_port_const(self._ptr)
-        utils._handle_ptr(port_ptr, "cannot get connection object's upstream port object")
-        return bt2.port._create_from_ptr_and_get_ref(port_ptr, native_bt.PORT_TYPE_OUTPUT)
+        utils._handle_ptr(
+            port_ptr, "cannot get connection object's upstream port object"
+        )
+        return bt2.port._create_from_ptr_and_get_ref(
+            port_ptr, native_bt.PORT_TYPE_OUTPUT
+        )
index 8864b1dfda33c5a5c21acf3968e3f8d5d7c2e0dc..c8a7d32074d258baf734992cb5a05b4314bda0c1 100644 (file)
@@ -67,9 +67,9 @@ class _Event(object._UniqueObject):
         if field_ptr is None:
             return
 
-        return bt2.field._create_field_from_ptr(field_ptr, self._owner_ptr,
-                                                self._owner_get_ref,
-                                                self._owner_put_ref)
+        return bt2.field._create_field_from_ptr(
+            field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+        )
 
     @property
     def specific_context_field(self):
@@ -78,9 +78,9 @@ class _Event(object._UniqueObject):
         if field_ptr is None:
             return
 
-        return bt2.field._create_field_from_ptr(field_ptr, self._owner_ptr,
-                                                self._owner_get_ref,
-                                                self._owner_put_ref)
+        return bt2.field._create_field_from_ptr(
+            field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+        )
 
     @property
     def payload_field(self):
@@ -89,9 +89,9 @@ class _Event(object._UniqueObject):
         if field_ptr is None:
             return
 
-        return bt2.field._create_field_from_ptr(field_ptr, self._owner_ptr,
-                                                self._owner_get_ref,
-                                                self._owner_put_ref)
+        return bt2.field._create_field_from_ptr(
+            field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+        )
 
     def __getitem__(self, key):
         utils._check_str(key)
index cb7cc73fcdd4442b32503e0591a0b451bc587867..00aae1b1def18a490ede769621f317e9d7db5753 100644 (file)
@@ -113,14 +113,15 @@ class _EventClass(object._SharedObject):
     def _emf_uri(self, emf_uri):
         utils._check_str(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")
+        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
@@ -130,9 +131,12 @@ class _EventClass(object._SharedObject):
     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)
-            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")
+            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)
 
@@ -148,9 +152,12 @@ class _EventClass(object._SharedObject):
     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)
-            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")
+            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)
 
index a1c2bf32c25fd0a96dfb8fe6973697f9d997bacd..bb35300c72ac5222c4e00cb39330e3c7610298cb 100644 (file)
@@ -34,7 +34,8 @@ def _create_field_from_ptr(ptr, owner_ptr, owner_get_ref, owner_put_ref):
     utils._handle_ptr(field_class_ptr, "cannot get field object's class")
     typeid = native_bt.field_class_get_type(field_class_ptr)
     field = _TYPE_ID_TO_OBJ[typeid]._create_from_ptr_and_get_ref(
-        ptr, owner_ptr, owner_get_ref, owner_put_ref)
+        ptr, owner_ptr, owner_get_ref, owner_put_ref
+    )
     return field
 
 
@@ -42,6 +43,7 @@ def _create_field_from_ptr(ptr, owner_ptr, owner_get_ref, owner_put_ref):
 # currently selected field.  If `field` is of any other type, return `field`
 # directly.
 
+
 def _get_leaf_field(field):
     if not isinstance(field, _VariantField):
         return field
@@ -83,7 +85,9 @@ class _NumericField(_Field):
         if isinstance(other, numbers.Complex):
             return complex(other)
 
-        raise TypeError("'{}' object is not a number object".format(other.__class__.__name__))
+        raise TypeError(
+            "'{}' object is not a number object".format(other.__class__.__name__)
+        )
 
     def __int__(self):
         return int(self._value)
@@ -96,8 +100,11 @@ class _NumericField(_Field):
 
     def __lt__(self, other):
         if not isinstance(other, numbers.Number):
-            raise TypeError('unorderable types: {}() < {}()'.format(self.__class__.__name__,
-                                                                    other.__class__.__name__))
+            raise TypeError(
+                'unorderable types: {}() < {}()'.format(
+                    self.__class__.__name__, other.__class__.__name__
+                )
+            )
 
         return self._value < self._extract_value(other)
 
@@ -280,8 +287,7 @@ class _EnumerationField(_IntegerField):
     @property
     def labels(self):
         status, labels = self._get_mapping_labels(self._ptr)
-        utils._handle_func_status(status,
-                                  "cannot get label for enumeration field")
+        utils._handle_func_status(status, "cannot get label for enumeration field")
 
         assert labels is not None
         return labels
@@ -289,12 +295,16 @@ class _EnumerationField(_IntegerField):
 
 class _UnsignedEnumerationField(_EnumerationField, _UnsignedIntegerField):
     _NAME = 'Unsigned Enumeration'
-    _get_mapping_labels = staticmethod(native_bt.field_unsigned_enumeration_get_mapping_labels)
+    _get_mapping_labels = staticmethod(
+        native_bt.field_unsigned_enumeration_get_mapping_labels
+    )
 
 
 class _SignedEnumerationField(_EnumerationField, _SignedIntegerField):
     _NAME = 'Signed Enumeration'
-    _get_mapping_labels = staticmethod(native_bt.field_signed_enumeration_get_mapping_labels)
+    _get_mapping_labels = staticmethod(
+        native_bt.field_signed_enumeration_get_mapping_labels
+    )
 
 
 @functools.total_ordering
@@ -347,8 +357,9 @@ class _StringField(_Field):
     def __iadd__(self, value):
         value = self._value_to_str(value)
         status = native_bt.field_string_append(self._ptr, value)
-        utils._handle_func_status(status,
-                                  "cannot append to string field object's value")
+        utils._handle_func_status(
+            status, "cannot append to string field object's value"
+        )
         return self
 
 
@@ -415,14 +426,16 @@ class _StructureField(_ContainerField, collections.abc.MutableMapping):
 
     def __getitem__(self, key):
         utils._check_str(key)
-        field_ptr = native_bt.field_structure_borrow_member_field_by_name(self._ptr, key)
+        field_ptr = native_bt.field_structure_borrow_member_field_by_name(
+            self._ptr, key
+        )
 
         if field_ptr is None:
             raise KeyError(key)
 
-        return _create_field_from_ptr(field_ptr, self._owner_ptr,
-                                      self._owner_get_ref,
-                                      self._owner_put_ref)
+        return _create_field_from_ptr(
+            field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+        )
 
     def member_at_index(self, index):
         utils._check_uint64(index)
@@ -430,11 +443,13 @@ class _StructureField(_ContainerField, collections.abc.MutableMapping):
         if index >= len(self):
             raise IndexError
 
-        field_ptr = native_bt.field_structure_borrow_member_field_by_index(self._ptr, index)
+        field_ptr = native_bt.field_structure_borrow_member_field_by_index(
+            self._ptr, index
+        )
         assert field_ptr is not None
-        return _create_field_from_ptr(field_ptr, self._owner_ptr,
-                                      self._owner_get_ref,
-                                      self._owner_put_ref)
+        return _create_field_from_ptr(
+            field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+        )
 
 
 class _VariantField(_ContainerField, _Field):
@@ -453,9 +468,9 @@ class _VariantField(_ContainerField, _Field):
         field_ptr = native_bt.field_variant_borrow_selected_option_field(self._ptr)
         utils._handle_ptr(field_ptr, "cannot get variant field's selected option")
 
-        return _create_field_from_ptr(field_ptr, self._owner_ptr,
-                                      self._owner_get_ref,
-                                      self._owner_put_ref)
+        return _create_field_from_ptr(
+            field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+        )
 
     def _spec_eq(self, other):
         return _get_leaf_field(self) == other
@@ -483,18 +498,24 @@ class _ArrayField(_ContainerField, _Field, collections.abc.MutableSequence):
 
     def __getitem__(self, index):
         if not isinstance(index, numbers.Integral):
-            raise TypeError("'{}' is not an integral number object: invalid index".format(index.__class__.__name__))
+            raise TypeError(
+                "'{}' is not an integral number object: invalid index".format(
+                    index.__class__.__name__
+                )
+            )
 
         index = int(index)
 
         if index < 0 or index >= len(self):
             raise IndexError('{} field object index is out of range'.format(self._NAME))
 
-        field_ptr = native_bt.field_array_borrow_element_field_by_index(self._ptr, index)
-        assert(field_ptr)
-        return _create_field_from_ptr(field_ptr, self._owner_ptr,
-                                      self._owner_get_ref,
-                                      self._owner_put_ref)
+        field_ptr = native_bt.field_array_borrow_element_field_by_index(
+            self._ptr, index
+        )
+        assert field_ptr
+        return _create_field_from_ptr(
+            field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+        )
 
     def __setitem__(self, index, value):
         # raises if index is somehow invalid
@@ -536,8 +557,7 @@ class _StaticArrayField(_ArrayField, _Field):
 
     def _set_value(self, values):
         if len(self) != len(values):
-            raise ValueError(
-                'expected length of value and array field to match')
+            raise ValueError('expected length of value and array field to match')
 
         for index, value in enumerate(values):
             if value is not None:
index 80936539379c02cc00c9d640a553c9d73277dfba..1128e4df689ef56e8eb1c76061d680e4ba52a2f5 100644 (file)
@@ -46,14 +46,16 @@ class _FieldClass(object._SharedObject):
 
     def _check_create_status(self, ptr):
         if ptr is None:
-            raise bt2.CreationError('cannot create {} field class object'.format(self._NAME.lower()))
+            raise bt2.CreationError(
+                'cannot create {} field class object'.format(self._NAME.lower())
+            )
 
 
 class _IntegerFieldClass(_FieldClass):
     @property
     def field_value_range(self):
         size = native_bt.field_class_integer_get_field_value_range(self._ptr)
-        assert(size >= 1)
+        assert size >= 1
         return size
 
     def _field_value_range(self, size):
@@ -65,22 +67,22 @@ class _IntegerFieldClass(_FieldClass):
 
     @property
     def preferred_display_base(self):
-        base = native_bt.field_class_integer_get_preferred_display_base(
-            self._ptr)
-        assert(base >= 0)
+        base = native_bt.field_class_integer_get_preferred_display_base(self._ptr)
+        assert base >= 0
         return base
 
     def _preferred_display_base(self, base):
         utils._check_uint64(base)
 
-        if base not in (IntegerDisplayBase.BINARY,
-                        IntegerDisplayBase.OCTAL,
-                        IntegerDisplayBase.DECIMAL,
-                        IntegerDisplayBase.HEXADECIMAL):
+        if base not in (
+            IntegerDisplayBase.BINARY,
+            IntegerDisplayBase.OCTAL,
+            IntegerDisplayBase.DECIMAL,
+            IntegerDisplayBase.HEXADECIMAL,
+        ):
             raise ValueError("Display base is not a valid IntegerDisplayBase value")
 
-        native_bt.field_class_integer_set_preferred_display_base(
-            self._ptr, base)
+        native_bt.field_class_integer_set_preferred_display_base(self._ptr, base)
 
     _preferred_display_base = property(fset=_preferred_display_base)
 
@@ -103,7 +105,8 @@ class _RealFieldClass(_FieldClass):
     def _is_single_precision(self, is_single_precision):
         utils._check_bool(is_single_precision)
         native_bt.field_class_real_set_is_single_precision(
-            self._ptr, is_single_precision)
+            self._ptr, is_single_precision
+        )
 
     _is_single_precision = property(fset=_is_single_precision)
 
@@ -113,7 +116,9 @@ class _RealFieldClass(_FieldClass):
 class _EnumerationFieldClassMapping:
     def __init__(self, mapping_ptr):
         base_mapping_ptr = self._as_enumeration_field_class_mapping_ptr(mapping_ptr)
-        self._label = native_bt.field_class_enumeration_mapping_get_label(base_mapping_ptr)
+        self._label = native_bt.field_class_enumeration_mapping_get_label(
+            base_mapping_ptr
+        )
         assert self._label is not None
         ranges_ptr = self._mapping_borrow_ranges_ptr(mapping_ptr)
         assert ranges_ptr is not None
@@ -130,14 +135,22 @@ class _EnumerationFieldClassMapping:
 
 class _UnsignedEnumerationFieldClassMapping(_EnumerationFieldClassMapping):
     _ranges_type = bt2.integer_range_set.UnsignedIntegerRangeSet
-    _as_enumeration_field_class_mapping_ptr = staticmethod(native_bt.field_class_unsigned_enumeration_mapping_as_mapping_const)
-    _mapping_borrow_ranges_ptr = staticmethod(native_bt.field_class_unsigned_enumeration_mapping_borrow_ranges_const)
+    _as_enumeration_field_class_mapping_ptr = staticmethod(
+        native_bt.field_class_unsigned_enumeration_mapping_as_mapping_const
+    )
+    _mapping_borrow_ranges_ptr = staticmethod(
+        native_bt.field_class_unsigned_enumeration_mapping_borrow_ranges_const
+    )
 
 
 class _SignedEnumerationFieldClassMapping(_EnumerationFieldClassMapping):
     _ranges_type = bt2.integer_range_set.SignedIntegerRangeSet
-    _as_enumeration_field_class_mapping_ptr = staticmethod(native_bt.field_class_signed_enumeration_mapping_as_mapping_const)
-    _mapping_borrow_ranges_ptr = staticmethod(native_bt.field_class_signed_enumeration_mapping_borrow_ranges_const)
+    _as_enumeration_field_class_mapping_ptr = staticmethod(
+        native_bt.field_class_signed_enumeration_mapping_as_mapping_const
+    )
+    _mapping_borrow_ranges_ptr = staticmethod(
+        native_bt.field_class_signed_enumeration_mapping_borrow_ranges_const
+    )
 
 
 class _EnumerationFieldClass(_IntegerFieldClass, collections.abc.Mapping):
@@ -154,12 +167,15 @@ class _EnumerationFieldClass(_IntegerFieldClass, collections.abc.Mapping):
             raise bt2.Error("duplicate mapping label '{}'".format(label))
 
         status = self._add_mapping(self._ptr, label, ranges._ptr)
-        utils._handle_func_status(status,
-                                  'cannot add mapping to enumeration field class object')
+        utils._handle_func_status(
+            status, 'cannot add mapping to enumeration field class object'
+        )
 
     def mappings_for_value(self, value):
         status, labels = self._get_mapping_labels_for_value(self._ptr, value)
-        utils._handle_func_status(status, 'cannot get mapping labels for value {}'.format(value))
+        utils._handle_func_status(
+            status, 'cannot get mapping labels for value {}'.format(value)
+        )
         return [self[label] for label in labels]
 
     def __iter__(self):
@@ -183,20 +199,26 @@ class _EnumerationFieldClass(_IntegerFieldClass, collections.abc.Mapping):
         return self
 
 
-class _UnsignedEnumerationFieldClass(_EnumerationFieldClass, _UnsignedIntegerFieldClass):
+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)
 
     @staticmethod
     def _get_mapping_by_index(enum_ptr, index):
-        mapping_ptr = native_bt.field_class_unsigned_enumeration_borrow_mapping_by_index_const(enum_ptr, index)
+        mapping_ptr = native_bt.field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+            enum_ptr, index
+        )
         assert mapping_ptr is not None
         return _UnsignedEnumerationFieldClassMapping(mapping_ptr)
 
     @staticmethod
     def _get_mapping_by_label(enum_ptr, label):
-        mapping_ptr = native_bt.field_class_unsigned_enumeration_borrow_mapping_by_label_const(enum_ptr, label)
+        mapping_ptr = native_bt.field_class_unsigned_enumeration_borrow_mapping_by_label_const(
+            enum_ptr, label
+        )
 
         if mapping_ptr is None:
             return
@@ -206,7 +228,9 @@ class _UnsignedEnumerationFieldClass(_EnumerationFieldClass, _UnsignedIntegerFie
     @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(enum_ptr, value)
+        return native_bt.field_class_unsigned_enumeration_get_mapping_labels_for_value(
+            enum_ptr, value
+        )
 
 
 class _SignedEnumerationFieldClass(_EnumerationFieldClass, _SignedIntegerFieldClass):
@@ -216,13 +240,17 @@ class _SignedEnumerationFieldClass(_EnumerationFieldClass, _SignedIntegerFieldCl
 
     @staticmethod
     def _get_mapping_by_index(enum_ptr, index):
-        mapping_ptr = native_bt.field_class_signed_enumeration_borrow_mapping_by_index_const(enum_ptr, index)
+        mapping_ptr = native_bt.field_class_signed_enumeration_borrow_mapping_by_index_const(
+            enum_ptr, index
+        )
         assert mapping_ptr is not None
         return _SignedEnumerationFieldClassMapping(mapping_ptr)
 
     @staticmethod
     def _get_mapping_by_label(enum_ptr, label):
-        mapping_ptr = native_bt.field_class_signed_enumeration_borrow_mapping_by_label_const(enum_ptr, label)
+        mapping_ptr = native_bt.field_class_signed_enumeration_borrow_mapping_by_label_const(
+            enum_ptr, label
+        )
 
         if mapping_ptr is None:
             return
@@ -232,7 +260,9 @@ 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(enum_ptr, value)
+        return native_bt.field_class_signed_enumeration_get_mapping_labels_for_value(
+            enum_ptr, value
+        )
 
 
 class _StringFieldClass(_FieldClass):
@@ -263,9 +293,12 @@ class _StructureFieldClass(_FieldClass, collections.abc.Mapping):
         if name in self:
             raise bt2.Error("duplicate member name '{}'".format(name))
 
-        status = native_bt.field_class_structure_append_member(self._ptr, name, field_class._ptr)
-        utils._handle_func_status(status,
-                                  'cannot append member to structure field class object')
+        status = native_bt.field_class_structure_append_member(
+            self._ptr, name, field_class._ptr
+        )
+        utils._handle_func_status(
+            status, 'cannot append member to structure field class object'
+        )
 
     def __len__(self):
         count = native_bt.field_class_structure_get_member_count(self._ptr)
@@ -276,16 +309,22 @@ class _StructureFieldClass(_FieldClass, collections.abc.Mapping):
     def _create_member_from_ptr(member_ptr):
         name = native_bt.field_class_structure_member_get_name(member_ptr)
         assert name is not None
-        fc_ptr = native_bt.field_class_structure_member_borrow_field_class_const(member_ptr)
+        fc_ptr = native_bt.field_class_structure_member_borrow_field_class_const(
+            member_ptr
+        )
         assert fc_ptr is not None
         fc = _create_field_class_from_ptr_and_get_ref(fc_ptr)
         return _StructureFieldClassMember(name, fc)
 
     def __getitem__(self, key):
         if not isinstance(key, str):
-            raise TypeError("key must be a 'str' object, got '{}'".format(key.__class__.__name__))
+            raise TypeError(
+                "key must be a 'str' object, got '{}'".format(key.__class__.__name__)
+            )
 
-        member_ptr = native_bt.field_class_structure_borrow_member_by_name_const(self._ptr, key)
+        member_ptr = native_bt.field_class_structure_borrow_member_by_name_const(
+            self._ptr, key
+        )
 
         if member_ptr is None:
             raise KeyError(key)
@@ -294,7 +333,9 @@ class _StructureFieldClass(_FieldClass, collections.abc.Mapping):
 
     def __iter__(self):
         for idx in range(len(self)):
-            member_ptr = native_bt.field_class_structure_borrow_member_by_index_const(self._ptr, idx)
+            member_ptr = native_bt.field_class_structure_borrow_member_by_index_const(
+                self._ptr, idx
+            )
             assert member_ptr is not None
             yield native_bt.field_class_structure_member_get_name(member_ptr)
 
@@ -310,7 +351,9 @@ class _StructureFieldClass(_FieldClass, collections.abc.Mapping):
         if index >= len(self):
             raise IndexError
 
-        member_ptr = native_bt.field_class_structure_borrow_member_by_index_const(self._ptr, index)
+        member_ptr = native_bt.field_class_structure_borrow_member_by_index_const(
+            self._ptr, index
+        )
         assert member_ptr is not None
         return self._create_member_from_ptr(member_ptr)
 
@@ -341,8 +384,12 @@ class _VariantFieldClassWithSelectorOption(_VariantFieldClassOption):
 
 class _VariantFieldClass(_FieldClass, collections.abc.Mapping):
     _NAME = 'Variant'
-    _borrow_option_by_name_ptr = staticmethod(native_bt.field_class_variant_borrow_option_by_name_const)
-    _borrow_member_by_index_ptr = staticmethod(native_bt.field_class_variant_borrow_option_by_index_const)
+    _borrow_option_by_name_ptr = staticmethod(
+        native_bt.field_class_variant_borrow_option_by_name_const
+    )
+    _borrow_member_by_index_ptr = staticmethod(
+        native_bt.field_class_variant_borrow_option_by_index_const
+    )
 
     @staticmethod
     def _as_option_ptr(opt_ptr):
@@ -363,7 +410,9 @@ class _VariantFieldClass(_FieldClass, collections.abc.Mapping):
 
     def __getitem__(self, key):
         if not isinstance(key, str):
-            raise TypeError("key must be a 'str' object, got '{}'".format(key.__class__.__name__))
+            raise TypeError(
+                "key must be a 'str' object, got '{}'".format(key.__class__.__name__)
+            )
 
         opt_ptr = self._borrow_option_by_name_ptr(self._ptr, key)
 
@@ -400,9 +449,12 @@ class _VariantFieldClassWithoutSelector(_VariantFieldClass):
         if name in self:
             raise bt2.Error("duplicate option name '{}'".format(name))
 
-        status = native_bt.field_class_variant_without_selector_append_option(self._ptr, name, field_class._ptr)
-        utils._handle_func_status(status,
-                                  'cannot append option to variant field class object')
+        status = native_bt.field_class_variant_without_selector_append_option(
+            self._ptr, name, field_class._ptr
+        )
+        utils._handle_func_status(
+            status, 'cannot append option to variant field class object'
+        )
 
     def __iadd__(self, options):
         for name, field_class in options:
@@ -418,7 +470,9 @@ class _VariantFieldClassWithSelector(_VariantFieldClass):
         base_opt_ptr = self._as_option_ptr(opt_ptr)
         name = native_bt.field_class_variant_option_get_name(base_opt_ptr)
         assert name is not None
-        fc_ptr = native_bt.field_class_variant_option_borrow_field_class_const(base_opt_ptr)
+        fc_ptr = native_bt.field_class_variant_option_borrow_field_class_const(
+            base_opt_ptr
+        )
         assert fc_ptr is not None
         fc = _create_field_class_from_ptr_and_get_ref(fc_ptr)
         range_set_ptr = self._option_borrow_ranges_ptr(opt_ptr)
@@ -428,7 +482,9 @@ class _VariantFieldClassWithSelector(_VariantFieldClass):
 
     @property
     def selector_field_path(self):
-        ptr = native_bt.field_class_variant_with_selector_borrow_selector_field_path_const(self._ptr)
+        ptr = native_bt.field_class_variant_with_selector_borrow_selector_field_path_const(
+            self._ptr
+        )
 
         if ptr is None:
             return
@@ -449,8 +505,9 @@ class _VariantFieldClassWithSelector(_VariantFieldClass):
         # TODO: check overlaps (precondition of self._append_option())
 
         status = self._append_option(self._ptr, name, field_class._ptr, ranges._ptr)
-        utils._handle_func_status(status,
-                                  'cannot append option to variant field class object')
+        utils._handle_func_status(
+            status, 'cannot append option to variant field class object'
+        )
 
     def __iadd__(self, options):
         for name, field_class, ranges in options:
@@ -461,28 +518,50 @@ 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)
-    _borrow_member_by_index_ptr = staticmethod(native_bt.field_class_variant_with_unsigned_selector_borrow_option_by_index_const)
-    _as_option_ptr = staticmethod(native_bt.field_class_variant_with_unsigned_selector_option_as_option_const)
-    _append_option = staticmethod(native_bt.field_class_variant_with_unsigned_selector_append_option)
-    _option_borrow_ranges_ptr = staticmethod(native_bt.field_class_variant_with_unsigned_selector_option_borrow_ranges_const)
+    _borrow_option_by_name_ptr = staticmethod(
+        native_bt.field_class_variant_with_unsigned_selector_borrow_option_by_name_const
+    )
+    _borrow_member_by_index_ptr = staticmethod(
+        native_bt.field_class_variant_with_unsigned_selector_borrow_option_by_index_const
+    )
+    _as_option_ptr = staticmethod(
+        native_bt.field_class_variant_with_unsigned_selector_option_as_option_const
+    )
+    _append_option = staticmethod(
+        native_bt.field_class_variant_with_unsigned_selector_append_option
+    )
+    _option_borrow_ranges_ptr = staticmethod(
+        native_bt.field_class_variant_with_unsigned_selector_option_borrow_ranges_const
+    )
     _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)
-    _borrow_member_by_index_ptr = staticmethod(native_bt.field_class_variant_with_signed_selector_borrow_option_by_index_const)
-    _as_option_ptr = staticmethod(native_bt.field_class_variant_with_signed_selector_option_as_option_const)
-    _append_option = staticmethod(native_bt.field_class_variant_with_signed_selector_append_option)
-    _option_borrow_ranges_ptr = staticmethod(native_bt.field_class_variant_with_signed_selector_option_borrow_ranges_const)
+    _borrow_option_by_name_ptr = staticmethod(
+        native_bt.field_class_variant_with_signed_selector_borrow_option_by_name_const
+    )
+    _borrow_member_by_index_ptr = staticmethod(
+        native_bt.field_class_variant_with_signed_selector_borrow_option_by_index_const
+    )
+    _as_option_ptr = staticmethod(
+        native_bt.field_class_variant_with_signed_selector_option_as_option_const
+    )
+    _append_option = staticmethod(
+        native_bt.field_class_variant_with_signed_selector_append_option
+    )
+    _option_borrow_ranges_ptr = staticmethod(
+        native_bt.field_class_variant_with_signed_selector_option_borrow_ranges_const
+    )
     _range_set_type = bt2.integer_range_set.SignedIntegerRangeSet
 
 
 class _ArrayFieldClass(_FieldClass):
     @property
     def element_field_class(self):
-        elem_fc_ptr = native_bt.field_class_array_borrow_element_field_class_const(self._ptr)
+        elem_fc_ptr = native_bt.field_class_array_borrow_element_field_class_const(
+            self._ptr
+        )
         return _create_field_class_from_ptr_and_get_ref(elem_fc_ptr)
 
 
@@ -495,7 +574,9 @@ class _StaticArrayFieldClass(_ArrayFieldClass):
 class _DynamicArrayFieldClass(_ArrayFieldClass):
     @property
     def length_field_path(self):
-        ptr = native_bt.field_class_dynamic_array_borrow_length_field_path_const(self._ptr)
+        ptr = native_bt.field_class_dynamic_array_borrow_length_field_path_const(
+            self._ptr
+        )
         if ptr is None:
             return
 
index 2191171e02055317cc331551888bf32c45a4dc37..2df37015be0c946e3d23e89d6d3234d11698c5d1 100644 (file)
@@ -69,7 +69,7 @@ class _FieldPath(object._SharedObject, collections.abc.Iterable):
                 idx = native_bt.field_path_item_index_get_index(item_ptr)
                 yield _IndexFieldPathItem(idx)
             elif item_type == native_bt.FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
-                yield  _CurrentArrayElementFieldPathItem()
+                yield _CurrentArrayElementFieldPathItem()
             else:
                 assert False
 
@@ -78,5 +78,5 @@ _SCOPE_TO_OBJ = {
     native_bt.SCOPE_PACKET_CONTEXT: Scope.PACKET_CONTEXT,
     native_bt.SCOPE_EVENT_COMMON_CONTEXT: Scope.EVENT_COMMON_CONTEXT,
     native_bt.SCOPE_EVENT_SPECIFIC_CONTEXT: Scope.EVENT_SPECIFIC_CONTEXT,
-    native_bt.SCOPE_EVENT_PAYLOAD: Scope.EVENT_PAYLOAD
+    native_bt.SCOPE_EVENT_PAYLOAD: Scope.EVENT_PAYLOAD,
 }
index 9e30c18f2645ccd45a9d4cf8e975402ffb4acf9a..1f280ba119ff4de691398980b9c4cd6e54f9eb2c 100644 (file)
@@ -29,28 +29,40 @@ import bt2.logging
 import bt2
 
 
-def _graph_port_added_listener_from_native(user_listener,
-                                           component_ptr, component_type,
-                                           port_ptr, port_type):
-    component = bt2.component._create_component_from_ptr_and_get_ref(component_ptr, component_type)
+def _graph_port_added_listener_from_native(
+    user_listener, component_ptr, component_type, port_ptr, port_type
+):
+    component = bt2.component._create_component_from_ptr_and_get_ref(
+        component_ptr, component_type
+    )
     port = bt2.port._create_from_ptr_and_get_ref(port_ptr, port_type)
     user_listener(component, port)
 
 
-def _graph_ports_connected_listener_from_native(user_listener,
-                                                upstream_component_ptr, upstream_component_type,
-                                                upstream_port_ptr,
-                                                downstream_component_ptr, downstream_component_type,
-                                                downstream_port_ptr):
+def _graph_ports_connected_listener_from_native(
+    user_listener,
+    upstream_component_ptr,
+    upstream_component_type,
+    upstream_port_ptr,
+    downstream_component_ptr,
+    downstream_component_type,
+    downstream_port_ptr,
+):
     upstream_component = bt2.component._create_component_from_ptr_and_get_ref(
-        upstream_component_ptr, upstream_component_type)
+        upstream_component_ptr, upstream_component_type
+    )
     upstream_port = bt2.port._create_from_ptr_and_get_ref(
-        upstream_port_ptr, native_bt.PORT_TYPE_OUTPUT)
+        upstream_port_ptr, native_bt.PORT_TYPE_OUTPUT
+    )
     downstream_component = bt2.component._create_component_from_ptr_and_get_ref(
-        downstream_component_ptr, downstream_component_type)
+        downstream_component_ptr, downstream_component_type
+    )
     downstream_port = bt2.port._create_from_ptr_and_get_ref(
-        downstream_port_ptr, native_bt.PORT_TYPE_INPUT)
-    user_listener(upstream_component, upstream_port, downstream_component, downstream_port)
+        downstream_port_ptr, native_bt.PORT_TYPE_INPUT
+    )
+    user_listener(
+        upstream_component, upstream_port, downstream_component, downstream_port
+    )
 
 
 class Graph(object._SharedObject):
@@ -65,9 +77,13 @@ class Graph(object._SharedObject):
 
         super().__init__(ptr)
 
-
-    def add_component(self, component_class, name, params=None,
-                      logging_level=bt2.logging.LoggingLevel.NONE):
+    def add_component(
+        self,
+        component_class,
+        name,
+        params=None,
+        logging_level=bt2.logging.LoggingLevel.NONE,
+    ):
         if isinstance(component_class, bt2.component._GenericSourceComponentClass):
             cc_ptr = component_class._ptr
             add_fn = native_bt.graph_add_source_component
@@ -93,8 +109,11 @@ class Graph(object._SharedObject):
             add_fn = native_bt.graph_add_filter_component
             cc_type = native_bt.COMPONENT_CLASS_TYPE_FILTER
         else:
-            raise TypeError("'{}' is not a component class".format(
-                component_class.__class__.__name__))
+            raise TypeError(
+                "'{}' is not a component class".format(
+                    component_class.__class__.__name__
+                )
+            )
 
         utils._check_str(name)
         utils._check_log_level(logging_level)
@@ -102,8 +121,7 @@ class Graph(object._SharedObject):
 
         params_ptr = params._ptr if params is not None else None
 
-        status, comp_ptr = add_fn(self._ptr, cc_ptr, name,
-                                  params_ptr, logging_level)
+        status, comp_ptr = add_fn(self._ptr, cc_ptr, name, params_ptr, logging_level)
         utils._handle_func_status(status, 'cannot add component to graph')
         assert comp_ptr
         return bt2.component._create_component_from_ptr(comp_ptr, cc_type)
@@ -111,12 +129,11 @@ class Graph(object._SharedObject):
     def connect_ports(self, upstream_port, downstream_port):
         utils._check_type(upstream_port, bt2.port._OutputPort)
         utils._check_type(downstream_port, bt2.port._InputPort)
-        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')
-        assert(conn_ptr)
+        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')
+        assert conn_ptr
         return bt2.connection._Connection._create_from_ptr(conn_ptr)
 
     def add_port_added_listener(self, listener):
@@ -124,8 +141,9 @@ class Graph(object._SharedObject):
             raise TypeError("'listener' parameter is not callable")
 
         fn = native_bt.bt2_graph_add_port_added_listener
-        listener_from_native = functools.partial(_graph_port_added_listener_from_native,
-                                                 listener)
+        listener_from_native = functools.partial(
+            _graph_port_added_listener_from_native, listener
+        )
 
         listener_ids = fn(self._ptr, listener_from_native)
         if listener_ids is None:
@@ -137,8 +155,9 @@ class Graph(object._SharedObject):
             raise TypeError("'listener' parameter is not callable")
 
         fn = native_bt.bt2_graph_add_ports_connected_listener
-        listener_from_native = functools.partial(_graph_ports_connected_listener_from_native,
-                                                 listener)
+        listener_from_native = functools.partial(
+            _graph_ports_connected_listener_from_native, listener
+        )
 
         listener_ids = fn(self._ptr, listener_from_native)
         if listener_ids is None:
@@ -149,8 +168,9 @@ class Graph(object._SharedObject):
         status = native_bt.graph_run(self._ptr)
 
         try:
-            utils._handle_func_status(status,
-                                      'graph object stopped running because of an unexpected error')
+            utils._handle_func_status(
+                status, 'graph object stopped running because of an unexpected error'
+            )
         except bt2.Stop:
             # done
             return
@@ -164,12 +184,14 @@ class Graph(object._SharedObject):
     @property
     def is_canceled(self):
         is_canceled = native_bt.graph_is_canceled(self._ptr)
-        assert(is_canceled >= 0)
+        assert is_canceled >= 0
         return is_canceled > 0
 
     def create_output_port_message_iterator(self, output_port):
         utils._check_type(output_port, bt2.port._OutputPort)
-        msg_iter_ptr = native_bt.port_output_message_iterator_create(self._ptr, output_port._ptr)
+        msg_iter_ptr = native_bt.port_output_message_iterator_create(
+            self._ptr, output_port._ptr
+        )
 
         if msg_iter_ptr is None:
             raise bt2.CreationError('cannot create output port message iterator')
index 2e79da04a3d3f39d2dd772a04bed6b73600191a5..f7222fefbbe1e9e5bb0eb2077e896b78249f9b08 100644 (file)
@@ -31,7 +31,11 @@ class _IntegerRange:
         self._check_type(upper)
 
         if lower > upper:
-            raise ValueError("range's lower bound ({}) is greater than its upper bound ({})".format(lower, upper))
+            raise ValueError(
+                "range's lower bound ({}) is greater than its upper bound ({})".format(
+                    lower, upper
+                )
+            )
 
         self._lower = lower
         self._upper = upper
@@ -117,8 +121,7 @@ class _IntegerRangeSet(object._SharedObject, collections.abc.MutableSet):
             rg = self._range_type(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')
+        utils._handle_func_status(status, 'cannot add range to range set object')
 
     def discard(self, rg):
         raise NotImplementedError
@@ -127,9 +130,13 @@ class _IntegerRangeSet(object._SharedObject, collections.abc.MutableSet):
 class SignedIntegerRangeSet(_IntegerRangeSet):
     _get_ref = staticmethod(native_bt.integer_range_set_signed_get_ref)
     _put_ref = staticmethod(native_bt.integer_range_set_signed_put_ref)
-    _as_range_set_ptr = staticmethod(native_bt.integer_range_set_signed_as_range_set_const)
+    _as_range_set_ptr = staticmethod(
+        native_bt.integer_range_set_signed_as_range_set_const
+    )
     _create_range_set = staticmethod(native_bt.integer_range_set_signed_create)
-    _borrow_range_by_index_ptr = staticmethod(native_bt.integer_range_set_signed_borrow_range_by_index_const)
+    _borrow_range_by_index_ptr = staticmethod(
+        native_bt.integer_range_set_signed_borrow_range_by_index_const
+    )
     _range_get_lower = staticmethod(native_bt.integer_range_signed_get_lower)
     _range_get_upper = staticmethod(native_bt.integer_range_signed_get_upper)
     _add_range = staticmethod(native_bt.integer_range_set_signed_add_range)
@@ -140,9 +147,13 @@ class SignedIntegerRangeSet(_IntegerRangeSet):
 class UnsignedIntegerRangeSet(_IntegerRangeSet):
     _get_ref = staticmethod(native_bt.integer_range_set_unsigned_get_ref)
     _put_ref = staticmethod(native_bt.integer_range_set_unsigned_put_ref)
-    _as_range_set_ptr = staticmethod(native_bt.integer_range_set_unsigned_as_range_set_const)
+    _as_range_set_ptr = staticmethod(
+        native_bt.integer_range_set_unsigned_as_range_set_const
+    )
     _create_range_set = staticmethod(native_bt.integer_range_set_unsigned_create)
-    _borrow_range_by_index_ptr = staticmethod(native_bt.integer_range_set_unsigned_borrow_range_by_index_const)
+    _borrow_range_by_index_ptr = staticmethod(
+        native_bt.integer_range_set_unsigned_borrow_range_by_index_const
+    )
     _range_get_lower = staticmethod(native_bt.integer_range_unsigned_get_lower)
     _range_get_upper = staticmethod(native_bt.integer_range_unsigned_get_upper)
     _add_range = staticmethod(native_bt.integer_range_set_unsigned_add_range)
index a2e885b8208bdd8dfc994d5359bbe7bc5f83cf07..35cb1bbe6b2886b88cd5d4a0852b3a22636bf02a 100644 (file)
@@ -44,7 +44,9 @@ class _Message(object._SharedObject):
     @staticmethod
     def _check_has_default_clock_class(clock_class):
         if clock_class is None:
-            raise bt2.NonexistentClockSnapshot('cannot get default clock snapshot: stream class has no default clock class')
+            raise bt2.NonexistentClockSnapshot(
+                'cannot get default clock snapshot: stream class has no default clock class'
+            )
 
 
 class _MessageWithDefaultClockSnapshot:
@@ -52,11 +54,14 @@ class _MessageWithDefaultClockSnapshot:
         snapshot_ptr = borrow_clock_snapshot_ptr(self._ptr)
 
         return bt2.clock_snapshot._ClockSnapshot._create_from_ptr_and_get_ref(
-            snapshot_ptr, self._ptr, self._get_ref, self._put_ref)
+            snapshot_ptr, self._ptr, self._get_ref, self._put_ref
+        )
 
 
 class _EventMessage(_Message, _MessageWithDefaultClockSnapshot):
-    _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_event_borrow_default_clock_snapshot_const)
+    _borrow_default_clock_snapshot_ptr = staticmethod(
+        native_bt.message_event_borrow_default_clock_snapshot_const
+    )
 
     @property
     def default_clock_snapshot(self):
@@ -68,7 +73,8 @@ class _EventMessage(_Message, _MessageWithDefaultClockSnapshot):
         event_ptr = native_bt.message_event_borrow_event(self._ptr)
         assert event_ptr is not None
         return bt2.event._Event._create_from_ptr_and_get_ref(
-            event_ptr, self._ptr, self._get_ref, self._put_ref)
+            event_ptr, self._ptr, self._get_ref, self._put_ref
+        )
 
 
 class _PacketMessage(_Message, _MessageWithDefaultClockSnapshot):
@@ -86,12 +92,16 @@ class _PacketMessage(_Message, _MessageWithDefaultClockSnapshot):
 
 class _PacketBeginningMessage(_PacketMessage):
     _borrow_packet_ptr = staticmethod(native_bt.message_packet_beginning_borrow_packet)
-    _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_packet_beginning_borrow_default_clock_snapshot_const)
+    _borrow_default_clock_snapshot_ptr = staticmethod(
+        native_bt.message_packet_beginning_borrow_default_clock_snapshot_const
+    )
 
 
 class _PacketEndMessage(_PacketMessage):
     _borrow_packet_ptr = staticmethod(native_bt.message_packet_end_borrow_packet)
-    _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_packet_end_borrow_default_clock_snapshot_const)
+    _borrow_default_clock_snapshot_ptr = staticmethod(
+        native_bt.message_packet_end_borrow_default_clock_snapshot_const
+    )
 
 
 class _StreamMessage(_Message, _MessageWithDefaultClockSnapshot):
@@ -111,7 +121,8 @@ class _StreamMessage(_Message, _MessageWithDefaultClockSnapshot):
             return bt2.clock_snapshot._UnknownClockSnapshot()
 
         return bt2.clock_snapshot._ClockSnapshot._create_from_ptr_and_get_ref(
-            snapshot_ptr, self._ptr, self._get_ref, self._put_ref)
+            snapshot_ptr, self._ptr, self._get_ref, self._put_ref
+        )
 
     def _default_clock_snapshot(self, raw_value):
         utils._check_uint64(raw_value)
@@ -122,18 +133,28 @@ class _StreamMessage(_Message, _MessageWithDefaultClockSnapshot):
 
 class _StreamBeginningMessage(_StreamMessage):
     _borrow_stream_ptr = staticmethod(native_bt.message_stream_beginning_borrow_stream)
-    _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_beginning_borrow_default_clock_snapshot_const)
-    _set_default_clock_snapshot = staticmethod(native_bt.message_stream_beginning_set_default_clock_snapshot)
+    _borrow_default_clock_snapshot_ptr = staticmethod(
+        native_bt.message_stream_beginning_borrow_default_clock_snapshot_const
+    )
+    _set_default_clock_snapshot = staticmethod(
+        native_bt.message_stream_beginning_set_default_clock_snapshot
+    )
 
 
 class _StreamEndMessage(_StreamMessage):
     _borrow_stream_ptr = staticmethod(native_bt.message_stream_end_borrow_stream)
-    _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_end_borrow_default_clock_snapshot_const)
-    _set_default_clock_snapshot = staticmethod(native_bt.message_stream_end_set_default_clock_snapshot)
+    _borrow_default_clock_snapshot_ptr = staticmethod(
+        native_bt.message_stream_end_borrow_default_clock_snapshot_const
+    )
+    _set_default_clock_snapshot = staticmethod(
+        native_bt.message_stream_end_set_default_clock_snapshot
+    )
 
 
 class _MessageIteratorInactivityMessage(_Message, _MessageWithDefaultClockSnapshot):
-    _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_message_iterator_inactivity_borrow_default_clock_snapshot_const)
+    _borrow_default_clock_snapshot_ptr = staticmethod(
+        native_bt.message_message_iterator_inactivity_borrow_default_clock_snapshot_const
+    )
 
     @property
     def default_clock_snapshot(self):
@@ -163,12 +184,16 @@ class _DiscardedMessage(_Message, _MessageWithDefaultClockSnapshot):
 
     def _check_has_default_clock_snapshots(self):
         if not self._has_default_clock_snapshots:
-            raise bt2.NonexistentClockSnapshot('cannot get default clock snapshot: such a message has no clock snapshots for this stream class')
+            raise bt2.NonexistentClockSnapshot(
+                'cannot get default clock snapshot: such a message has no clock snapshots for this stream class'
+            )
 
     @property
     def beginning_default_clock_snapshot(self):
         self._check_has_default_clock_snapshots()
-        return self._get_default_clock_snapshot(self._borrow_beginning_clock_snapshot_ptr)
+        return self._get_default_clock_snapshot(
+            self._borrow_beginning_clock_snapshot_ptr
+        )
 
     @property
     def end_default_clock_snapshot(self):
@@ -177,11 +202,17 @@ class _DiscardedMessage(_Message, _MessageWithDefaultClockSnapshot):
 
 
 class _DiscardedEventsMessage(_DiscardedMessage):
-    _borrow_stream_ptr = staticmethod(native_bt.message_discarded_events_borrow_stream_const)
+    _borrow_stream_ptr = staticmethod(
+        native_bt.message_discarded_events_borrow_stream_const
+    )
     _get_count = staticmethod(native_bt.message_discarded_events_get_count)
     _set_count = staticmethod(native_bt.message_discarded_events_set_count)
-    _borrow_beginning_clock_snapshot_ptr = staticmethod(native_bt.message_discarded_events_borrow_beginning_default_clock_snapshot_const)
-    _borrow_end_clock_snapshot_ptr = staticmethod(native_bt.message_discarded_events_borrow_end_default_clock_snapshot_const)
+    _borrow_beginning_clock_snapshot_ptr = staticmethod(
+        native_bt.message_discarded_events_borrow_beginning_default_clock_snapshot_const
+    )
+    _borrow_end_clock_snapshot_ptr = staticmethod(
+        native_bt.message_discarded_events_borrow_end_default_clock_snapshot_const
+    )
 
     @property
     def _has_default_clock_snapshots(self):
@@ -189,11 +220,17 @@ class _DiscardedEventsMessage(_DiscardedMessage):
 
 
 class _DiscardedPacketsMessage(_DiscardedMessage):
-    _borrow_stream_ptr = staticmethod(native_bt.message_discarded_packets_borrow_stream_const)
+    _borrow_stream_ptr = staticmethod(
+        native_bt.message_discarded_packets_borrow_stream_const
+    )
     _get_count = staticmethod(native_bt.message_discarded_packets_get_count)
     _set_count = staticmethod(native_bt.message_discarded_packets_set_count)
-    _borrow_beginning_clock_snapshot_ptr = staticmethod(native_bt.message_discarded_packets_borrow_beginning_default_clock_snapshot_const)
-    _borrow_end_clock_snapshot_ptr = staticmethod(native_bt.message_discarded_packets_borrow_end_default_clock_snapshot_const)
+    _borrow_beginning_clock_snapshot_ptr = staticmethod(
+        native_bt.message_discarded_packets_borrow_beginning_default_clock_snapshot_const
+    )
+    _borrow_end_clock_snapshot_ptr = staticmethod(
+        native_bt.message_discarded_packets_borrow_end_default_clock_snapshot_const
+    )
 
     @property
     def _has_default_clock_snapshots(self):
index eb22dfb4edec32c4afd14612d744cb618248319d..9d3a4d22f1bda9e6c3dbfeac6cea0bc3b3402f53 100644 (file)
@@ -34,15 +34,16 @@ class _MessageIterator(collections.abc.Iterator):
 
 class _GenericMessageIterator(object._SharedObject, _MessageIterator):
     def __init__(self, ptr):
-            self._current_msgs = []
-            self._at = 0
-            super().__init__(ptr)
+        self._current_msgs = []
+        self._at = 0
+        super().__init__(ptr)
 
     def __next__(self):
         if len(self._current_msgs) == self._at:
             status, msgs = self._get_msg_range(self._ptr)
-            utils._handle_func_status(status,
-                                      'unexpected error: cannot advance the message iterator')
+            utils._handle_func_status(
+                status, 'unexpected error: cannot advance the message iterator'
+            )
             self._current_msgs = msgs
             self._at = 0
 
@@ -62,17 +63,24 @@ class _GenericMessageIterator(object._SharedObject, _MessageIterator):
         self._at = 0
 
         status = self._seek_beginning(self._ptr)
-        utils._handle_func_status(status,
-                                  'cannot seek message iterator beginning')
+        utils._handle_func_status(status, 'cannot seek message iterator beginning')
 
 
 # This is created when a component wants to iterate on one of its input ports.
 class _UserComponentInputPortMessageIterator(_GenericMessageIterator):
     _get_msg_range = staticmethod(native_bt.bt2_self_component_port_input_get_msg_range)
-    _get_ref = staticmethod(native_bt.self_component_port_input_message_iterator_get_ref)
-    _put_ref = staticmethod(native_bt.self_component_port_input_message_iterator_put_ref)
-    _can_seek_beginning = staticmethod(native_bt.self_component_port_input_message_iterator_can_seek_beginning)
-    _seek_beginning = staticmethod(native_bt.self_component_port_input_message_iterator_seek_beginning)
+    _get_ref = staticmethod(
+        native_bt.self_component_port_input_message_iterator_get_ref
+    )
+    _put_ref = staticmethod(
+        native_bt.self_component_port_input_message_iterator_put_ref
+    )
+    _can_seek_beginning = staticmethod(
+        native_bt.self_component_port_input_message_iterator_can_seek_beginning
+    )
+    _seek_beginning = staticmethod(
+        native_bt.self_component_port_input_message_iterator_seek_beginning
+    )
 
 
 # This is created when the user wants to iterate on a component's output port,
@@ -81,8 +89,12 @@ class _OutputPortMessageIterator(_GenericMessageIterator):
     _get_msg_range = staticmethod(native_bt.bt2_port_output_get_msg_range)
     _get_ref = staticmethod(native_bt.port_output_message_iterator_get_ref)
     _put_ref = staticmethod(native_bt.port_output_message_iterator_put_ref)
-    _can_seek_beginning = staticmethod(native_bt.port_output_message_iterator_can_seek_beginning)
-    _seek_beginning = staticmethod(native_bt.port_output_message_iterator_seek_beginning)
+    _can_seek_beginning = staticmethod(
+        native_bt.port_output_message_iterator_can_seek_beginning
+    )
+    _seek_beginning = staticmethod(
+        native_bt.port_output_message_iterator_seek_beginning
+    )
 
 
 # This is extended by the user to implement component classes in Python.  It
@@ -110,7 +122,8 @@ class _UserMessageIterator(_MessageIterator):
 
     def _bt_init_from_native(self, self_output_port_ptr):
         self_output_port = bt2.port._create_self_from_ptr_and_get_ref(
-            self_output_port_ptr, native_bt.PORT_TYPE_OUTPUT)
+            self_output_port_ptr, native_bt.PORT_TYPE_OUTPUT
+        )
         self.__init__(self_output_port)
 
     def __init__(self, output_port):
@@ -165,8 +178,9 @@ class _UserMessageIterator(_MessageIterator):
     def _bt_seek_beginning_from_native(self):
         self._seek_beginning()
 
-    def _create_event_message(self, event_class, parent=None,
-                              default_clock_snapshot=None):
+    def _create_event_message(
+        self, event_class, parent=None, default_clock_snapshot=None
+    ):
         utils._check_type(event_class, bt2.event_class._EventClass)
 
         if event_class.stream_class.supports_packets:
@@ -176,26 +190,34 @@ class _UserMessageIterator(_MessageIterator):
 
         if default_clock_snapshot is not None:
             if event_class.stream_class.default_clock_class is None:
-                raise ValueError('event messages in this stream must not have a default clock snapshot')
+                raise ValueError(
+                    'event messages in this stream must not have a default clock snapshot'
+                )
 
             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(
-                    self._bt_ptr, event_class._ptr, parent._ptr, default_clock_snapshot)
+                    self._bt_ptr, event_class._ptr, parent._ptr, default_clock_snapshot
+                )
             else:
                 ptr = native_bt.message_event_create_with_default_clock_snapshot(
-                    self._bt_ptr, event_class._ptr, parent._ptr, default_clock_snapshot)
+                    self._bt_ptr, event_class._ptr, parent._ptr, default_clock_snapshot
+                )
         else:
             if event_class.stream_class.default_clock_class is not None:
-                raise ValueError('event messages in this stream must have a default clock snapshot')
+                raise ValueError(
+                    'event messages in this stream must have a default clock snapshot'
+                )
 
             if event_class.stream_class.supports_packets:
                 ptr = native_bt.message_event_create_with_packet(
-                    self._bt_ptr, event_class._ptr, parent._ptr)
+                    self._bt_ptr, event_class._ptr, parent._ptr
+                )
             else:
                 ptr = native_bt.message_event_create(
-                    self._bt_ptr, event_class._ptr, parent._ptr)
+                    self._bt_ptr, event_class._ptr, parent._ptr
+                )
 
         if ptr is None:
             raise bt2.CreationError('cannot create event message object')
@@ -205,7 +227,8 @@ class _UserMessageIterator(_MessageIterator):
     def _create_message_iterator_inactivity_message(self, clock_class, clock_snapshot):
         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)
+            self._bt_ptr, clock_class._ptr, clock_snapshot
+        )
 
         if ptr is None:
             raise bt2.CreationError('cannot create inactivity message object')
@@ -245,14 +268,19 @@ class _UserMessageIterator(_MessageIterator):
 
         if packet.stream.cls.packets_have_beginning_default_clock_snapshot:
             if default_clock_snapshot is None:
-                raise ValueError("packet beginning messages in this stream must have a default clock snapshot")
+                raise ValueError(
+                    "packet beginning messages in this stream must have a default clock snapshot"
+                )
 
             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)
+                self._bt_ptr, packet._ptr, default_clock_snapshot
+            )
         else:
             if default_clock_snapshot is not None:
-                raise ValueError("packet beginning messages in this stream must not have a default clock snapshot")
+                raise ValueError(
+                    "packet beginning messages in this stream must not have a default clock snapshot"
+                )
 
             ptr = native_bt.message_packet_beginning_create(self._bt_ptr, packet._ptr)
 
@@ -266,14 +294,19 @@ class _UserMessageIterator(_MessageIterator):
 
         if packet.stream.cls.packets_have_end_default_clock_snapshot:
             if default_clock_snapshot is None:
-                raise ValueError("packet end messages in this stream must have a default clock snapshot")
+                raise ValueError(
+                    "packet end messages in this stream must have a default clock snapshot"
+                )
 
             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)
+                self._bt_ptr, packet._ptr, default_clock_snapshot
+            )
         else:
             if default_clock_snapshot is not None:
-                raise ValueError("packet end messages in this stream must not have a default clock snapshot")
+                raise ValueError(
+                    "packet end messages in this stream must not have a default clock snapshot"
+                )
 
             ptr = native_bt.message_packet_end_create(self._bt_ptr, packet._ptr)
 
@@ -282,9 +315,9 @@ class _UserMessageIterator(_MessageIterator):
 
         return bt2.message._PacketEndMessage(ptr)
 
-    def _create_discarded_events_message(self, stream, count=None,
-                                         beg_clock_snapshot=None,
-                                         end_clock_snapshot=None):
+    def _create_discarded_events_message(
+        self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None
+    ):
         utils._check_type(stream, bt2.stream._Stream)
 
         if not stream.cls.supports_discarded_events:
@@ -292,18 +325,22 @@ class _UserMessageIterator(_MessageIterator):
 
         if stream.cls.discarded_events_have_default_clock_snapshots:
             if beg_clock_snapshot is None or end_clock_snapshot is None:
-                raise ValueError('discarded events have default clock snapshots for this stream class')
+                raise ValueError(
+                    'discarded events have default clock snapshots for this stream class'
+                )
 
             utils._check_uint64(beg_clock_snapshot)
             utils._check_uint64(end_clock_snapshot)
             ptr = native_bt.message_discarded_events_create_with_default_clock_snapshots(
-                self._bt_ptr, stream._ptr, beg_clock_snapshot, end_clock_snapshot)
+                self._bt_ptr, stream._ptr, beg_clock_snapshot, end_clock_snapshot
+            )
         else:
             if beg_clock_snapshot is not None or end_clock_snapshot is not None:
-                raise ValueError('discarded events have no default clock snapshots for this stream class')
+                raise ValueError(
+                    'discarded events have no default clock snapshots for this stream class'
+                )
 
-            ptr = native_bt.message_discarded_events_create(
-                self._bt_ptr, stream._ptr)
+            ptr = native_bt.message_discarded_events_create(self._bt_ptr, stream._ptr)
 
         if ptr is None:
             raise bt2.CreationError('cannot discarded events message object')
@@ -315,7 +352,9 @@ class _UserMessageIterator(_MessageIterator):
 
         return msg
 
-    def _create_discarded_packets_message(self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None):
+    def _create_discarded_packets_message(
+        self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None
+    ):
         utils._check_type(stream, bt2.stream._Stream)
 
         if not stream.cls.supports_discarded_packets:
@@ -323,18 +362,22 @@ class _UserMessageIterator(_MessageIterator):
 
         if stream.cls.discarded_packets_have_default_clock_snapshots:
             if beg_clock_snapshot is None or end_clock_snapshot is None:
-                raise ValueError('discarded packets have default clock snapshots for this stream class')
+                raise ValueError(
+                    'discarded packets have default clock snapshots for this stream class'
+                )
 
             utils._check_uint64(beg_clock_snapshot)
             utils._check_uint64(end_clock_snapshot)
             ptr = native_bt.message_discarded_packets_create_with_default_clock_snapshots(
-                self._bt_ptr, stream._ptr, beg_clock_snapshot, end_clock_snapshot)
+                self._bt_ptr, stream._ptr, beg_clock_snapshot, end_clock_snapshot
+            )
         else:
             if beg_clock_snapshot is not None or end_clock_snapshot is not None:
-                raise ValueError('discarded packets have no default clock snapshots for this stream class')
+                raise ValueError(
+                    'discarded packets have no default clock snapshots for this stream class'
+                )
 
-            ptr = native_bt.message_discarded_packets_create(
-                self._bt_ptr, stream._ptr)
+            ptr = native_bt.message_discarded_packets_create(self._bt_ptr, stream._ptr)
 
         if ptr is None:
             raise bt2.CreationError('cannot discarded packets message object')
@@ -345,4 +388,3 @@ class _UserMessageIterator(_MessageIterator):
             msg._count = count
 
         return msg
-
index f73ec04bb67074573de5ee189e7a07f749c4e748..290f3febe5b3368da05f86501af635764e3d5ffa 100644 (file)
@@ -38,9 +38,9 @@ class _BaseObject:
         return int(self._ptr)
 
     def __repr__(self):
-        return '<{}.{} object @ {}>'.format(self.__class__.__module__,
-                                            self.__class__.__name__,
-                                            hex(self.addr))
+        return '<{}.{} object @ {}>'.format(
+            self.__class__.__module__, self.__class__.__name__, hex(self.addr)
+        )
 
     def __copy__(self):
         raise NotImplementedError
@@ -58,6 +58,7 @@ class _BaseObject:
 # of unique objects, we make it so acquiring a reference on a unique object
 # acquires a reference on its owner.
 
+
 class _UniqueObject(_BaseObject):
 
     # Create a _UniqueObject.
@@ -69,8 +70,7 @@ class _UniqueObject(_BaseObject):
     #   - owner_put_ref: Callback to put a reference on the owner.
 
     @classmethod
-    def _create_from_ptr_and_get_ref(cls, ptr, owner_ptr,
-                                     owner_get_ref, owner_put_ref):
+    def _create_from_ptr_and_get_ref(cls, ptr, owner_ptr, owner_get_ref, owner_put_ref):
         obj = cls.__new__(cls)
 
         obj._ptr = ptr
index 93e9ac8f79419d10d21af7d1a707e5dbad7a348e..266f7bcbb7c0f84566ace21334e9f9e5fa8e162a 100644 (file)
@@ -42,6 +42,6 @@ class _Packet(object._SharedObject):
         if field_ptr is None:
             return
 
-        return bt2.field._create_field_from_ptr(field_ptr, self._ptr,
-                                                self._get_ref,
-                                                self._put_ref)
+        return bt2.field._create_field_from_ptr(
+            field_ptr, self._ptr, self._get_ref, self._put_ref
+        )
index 620bd76ad4156a27e9335433dacdd7ddb7721f67..86612920fde281b4b8a2cf8338ab876eb2b47ef7 100644 (file)
@@ -34,9 +34,13 @@ def find_plugins(path, recurse=True, fail_on_load_error=False):
     plugin_set_ptr = None
 
     if os.path.isfile(path):
-        status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_file(path, fail_on_load_error)
+        status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_file(
+            path, fail_on_load_error
+        )
     elif os.path.isdir(path):
-        status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_dir(path, int(recurse), int(fail_on_load_error))
+        status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_dir(
+            path, int(recurse), int(fail_on_load_error)
+        )
     else:
         raise bt2.Error("invalid path: '{}'".format(path))
 
@@ -67,7 +71,7 @@ class _PluginSet(object._SharedObject, collections.abc.Sequence):
 
     def __len__(self):
         count = native_bt.plugin_set_get_plugin_count(self._ptr)
-        assert(count >= 0)
+        assert count >= 0
         return count
 
     def __getitem__(self, index):
@@ -125,12 +129,16 @@ class _PluginComponentClassesIterator(collections.abc.Iterator):
         if self._at == total:
             raise StopIteration
 
-        comp_cls_ptr = self._plugin_comp_cls._borrow_component_class_by_index(plugin_ptr, self._at)
+        comp_cls_ptr = self._plugin_comp_cls._borrow_component_class_by_index(
+            plugin_ptr, self._at
+        )
         assert comp_cls_ptr is not None
         self._at += 1
 
         comp_cls_type = self._plugin_comp_cls._comp_cls_type
-        comp_cls_pycls = bt2.component._COMP_CLS_TYPE_TO_GENERIC_COMP_CLS_PYCLS[comp_cls_type]
+        comp_cls_pycls = bt2.component._COMP_CLS_TYPE_TO_GENERIC_COMP_CLS_PYCLS[
+            comp_cls_type
+        ]
         comp_cls_ptr = comp_cls_pycls._bt_as_component_class_ptr(comp_cls_ptr)
         name = native_bt.component_class_get_name(comp_cls_ptr)
         assert name is not None
@@ -148,7 +156,9 @@ class _PluginComponentClasses(collections.abc.Mapping):
         if cc_ptr is None:
             raise KeyError(key)
 
-        return bt2.component._create_component_class_from_ptr_and_get_ref(cc_ptr, self._comp_cls_type)
+        return bt2.component._create_component_class_from_ptr_and_get_ref(
+            cc_ptr, self._comp_cls_type
+        )
 
     def __len__(self):
         return self._component_class_count(self._plugin._ptr)
@@ -158,23 +168,41 @@ class _PluginComponentClasses(collections.abc.Mapping):
 
 
 class _PluginSourceComponentClasses(_PluginComponentClasses):
-    _component_class_count = staticmethod(native_bt.plugin_get_source_component_class_count)
-    _borrow_component_class_by_name = staticmethod(native_bt.plugin_borrow_source_component_class_by_name_const)
-    _borrow_component_class_by_index = staticmethod(native_bt.plugin_borrow_source_component_class_by_index_const)
+    _component_class_count = staticmethod(
+        native_bt.plugin_get_source_component_class_count
+    )
+    _borrow_component_class_by_name = staticmethod(
+        native_bt.plugin_borrow_source_component_class_by_name_const
+    )
+    _borrow_component_class_by_index = staticmethod(
+        native_bt.plugin_borrow_source_component_class_by_index_const
+    )
     _comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_SOURCE
 
 
 class _PluginFilterComponentClasses(_PluginComponentClasses):
-    _component_class_count = staticmethod(native_bt.plugin_get_filter_component_class_count)
-    _borrow_component_class_by_name = staticmethod(native_bt.plugin_borrow_filter_component_class_by_name_const)
-    _borrow_component_class_by_index = staticmethod(native_bt.plugin_borrow_filter_component_class_by_index_const)
+    _component_class_count = staticmethod(
+        native_bt.plugin_get_filter_component_class_count
+    )
+    _borrow_component_class_by_name = staticmethod(
+        native_bt.plugin_borrow_filter_component_class_by_name_const
+    )
+    _borrow_component_class_by_index = staticmethod(
+        native_bt.plugin_borrow_filter_component_class_by_index_const
+    )
     _comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_FILTER
 
 
 class _PluginSinkComponentClasses(_PluginComponentClasses):
-    _component_class_count = staticmethod(native_bt.plugin_get_sink_component_class_count)
-    _borrow_component_class_by_name = staticmethod(native_bt.plugin_borrow_sink_component_class_by_name_const)
-    _borrow_component_class_by_index = staticmethod(native_bt.plugin_borrow_sink_component_class_by_index_const)
+    _component_class_count = staticmethod(
+        native_bt.plugin_get_sink_component_class_count
+    )
+    _borrow_component_class_by_name = staticmethod(
+        native_bt.plugin_borrow_sink_component_class_by_name_const
+    )
+    _borrow_component_class_by_index = staticmethod(
+        native_bt.plugin_borrow_sink_component_class_by_index_const
+    )
     _comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_SINK
 
 
@@ -185,7 +213,7 @@ class _Plugin(object._SharedObject):
     @property
     def name(self):
         name = native_bt.plugin_get_name(self._ptr)
-        assert(name is not None)
+        assert name is not None
         return name
 
     @property
index 4ba59f066df4c230e4b3ef92389f1ae7b50ad102..1d649b35d72f4a6ec8a15a871cfec5400e8e5185 100644 (file)
@@ -110,10 +110,14 @@ class _UserComponentPort(_Port):
 
 
 class _UserComponentInputPort(_UserComponentPort, _InputPort):
-    _as_self_port_ptr = staticmethod(native_bt.self_component_port_input_as_self_component_port)
+    _as_self_port_ptr = staticmethod(
+        native_bt.self_component_port_input_as_self_component_port
+    )
 
     def create_message_iterator(self):
-        msg_iter_ptr = native_bt.self_component_port_input_message_iterator_create(self._ptr)
+        msg_iter_ptr = native_bt.self_component_port_input_message_iterator_create(
+            self._ptr
+        )
         if msg_iter_ptr is None:
             raise bt2.CreationError('cannot create message iterator object')
 
@@ -121,7 +125,9 @@ class _UserComponentInputPort(_UserComponentPort, _InputPort):
 
 
 class _UserComponentOutputPort(_UserComponentPort, _OutputPort):
-    _as_self_port_ptr = staticmethod(native_bt.self_component_port_output_as_self_component_port)
+    _as_self_port_ptr = staticmethod(
+        native_bt.self_component_port_output_as_self_component_port
+    )
 
 
 _PORT_TYPE_TO_PYCLS = {
index b845030863ce224582406af5698e840a3d70465c..5f620ab794ad20321c219c5eadd4e01c0e6d1b55 100644 (file)
@@ -32,12 +32,15 @@ def plugin_component_class(component_class):
     return component_class
 
 
-def register_plugin(module_name, name, description=None, author=None,
-                    license=None, version=None):
+def register_plugin(
+    module_name, name, description=None, author=None, license=None, version=None
+):
     import sys
 
     if module_name not in sys.modules:
-        raise RuntimeError("cannot find module '{}' in loaded modules".format(module_name))
+        raise RuntimeError(
+            "cannot find module '{}' in loaded modules".format(module_name)
+        )
 
     utils._check_str(name)
 
@@ -52,11 +55,13 @@ def register_plugin(module_name, name, description=None, author=None,
 
     if version is not None:
         if not _validate_version(version):
-            raise ValueError('wrong version: expecting a tuple: (major, minor, patch) or (major, minor, patch, extra)')
+            raise ValueError(
+                'wrong version: expecting a tuple: (major, minor, patch) or (major, minor, patch, extra)'
+            )
 
-    sys.modules[module_name]._bt_plugin_info = _PluginInfo(name, description,
-                                                           author, license,
-                                                           version)
+    sys.modules[module_name]._bt_plugin_info = _PluginInfo(
+        name, description, author, license, version
+    )
 
 
 def _validate_version(version):
index f734609e1ff6d2d99c875a34be4a6fa99f70cead..17ddd97e86fd3d86563ad618266acf540637a1ce 100644 (file)
@@ -40,17 +40,21 @@ class QueryExecutor(object._SharedObject):
 
     def cancel(self):
         status = native_bt.query_executor_cancel(self._ptr)
-        utils._handle_func_status(status,
-                                  'cannot cancel query executor object')
+        utils._handle_func_status(status, 'cannot cancel query executor object')
 
     @property
     def is_canceled(self):
         is_canceled = native_bt.query_executor_is_canceled(self._ptr)
-        assert(is_canceled >= 0)
+        assert is_canceled >= 0
         return is_canceled > 0
 
-    def query(self, component_class, object, params=None,
-              logging_level=bt2.logging.LoggingLevel.NONE):
+    def query(
+        self,
+        component_class,
+        object,
+        params=None,
+        logging_level=bt2.logging.LoggingLevel.NONE,
+    ):
         if self.is_canceled:
             raise bt2.Canceled
 
@@ -78,9 +82,9 @@ class QueryExecutor(object._SharedObject):
         utils._check_log_level(logging_level)
         cc_ptr = component_class._bt_component_class_ptr()
 
-        status, result_ptr = native_bt.query_executor_query(self._ptr, cc_ptr,
-                                                            object, params_ptr,
-                                                            logging_level)
+        status, result_ptr = native_bt.query_executor_query(
+            self._ptr, cc_ptr, object, params_ptr, logging_level
+        )
         utils._handle_func_status(status, 'cannot query component class')
-        assert(result_ptr)
+        assert result_ptr
         return bt2.value._create_from_ptr(result_ptr)
index eb780b0ee6ab02c9d0c78ff6502f0037a9593597..451ad6c996122ba2c25f7a0f8557ece05e4b1674 100644 (file)
@@ -34,7 +34,9 @@ class _Stream(bt2.object._SharedObject):
     def cls(self):
         stream_class_ptr = native_bt.stream_borrow_class(self._ptr)
         assert stream_class_ptr is not None
-        return bt2.stream_class._StreamClass._create_from_ptr_and_get_ref(stream_class_ptr)
+        return bt2.stream_class._StreamClass._create_from_ptr_and_get_ref(
+            stream_class_ptr
+        )
 
     @property
     def name(self):
@@ -53,7 +55,9 @@ class _Stream(bt2.object._SharedObject):
 
     def create_packet(self):
         if not self.cls.supports_packets:
-            raise bt2.Error('cannot create packet: stream class does not support packets')
+            raise bt2.Error(
+                'cannot create packet: stream class does not support packets'
+            )
 
         packet_ptr = native_bt.packet_create(self._ptr)
 
index cf34cf4c05f285808619724aed60f2d43f89394d..08186333f1257f7591edcfe367d09f062c47b3a4 100644 (file)
@@ -48,7 +48,9 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     def __iter__(self):
         for idx in range(len(self)):
-            ec_ptr = native_bt.stream_class_borrow_event_class_by_index_const(self._ptr, idx)
+            ec_ptr = native_bt.stream_class_borrow_event_class_by_index_const(
+                self._ptr, idx
+            )
             assert ec_ptr is not None
 
             id = native_bt.event_class_get_id(ec_ptr)
@@ -56,17 +58,27 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
             yield id
 
-    def create_event_class(self, id=None, name=None, log_level=None, emf_uri=None,
-                           specific_context_field_class=None,
-                           payload_field_class=None):
+    def create_event_class(
+        self,
+        id=None,
+        name=None,
+        log_level=None,
+        emf_uri=None,
+        specific_context_field_class=None,
+        payload_field_class=None,
+    ):
         if self.assigns_automatic_event_class_id:
             if id is not None:
-                raise ValueError('id provided, but stream class assigns automatic event class ids')
+                raise ValueError(
+                    'id provided, but stream class assigns automatic event class ids'
+                )
 
             ec_ptr = native_bt.event_class_create(self._ptr)
         else:
             if id is None:
-                raise ValueError('id not provided, but stream class does not assign automatic event class ids')
+                raise ValueError(
+                    'id not provided, but stream class does not assign automatic event class ids'
+                )
 
             utils._check_uint64(id)
             ec_ptr = native_bt.event_class_create_with_id(self._ptr, id)
@@ -104,8 +116,7 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
     def _name(self, name):
         utils._check_str(name)
         status = native_bt.stream_class_set_name(self._ptr, name)
-        utils._handle_func_status(status,
-                                  "cannot set stream class object's name")
+        utils._handle_func_status(status, "cannot set stream class object's name")
 
     _name = property(fset=_name)
 
@@ -115,7 +126,9 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     def _assigns_automatic_event_class_id(self, auto_id):
         utils._check_bool(auto_id)
-        return native_bt.stream_class_set_assigns_automatic_event_class_id(self._ptr, auto_id)
+        return native_bt.stream_class_set_assigns_automatic_event_class_id(
+            self._ptr, auto_id
+        )
 
     _assigns_automatic_event_class_id = property(fset=_assigns_automatic_event_class_id)
 
@@ -125,7 +138,9 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     def _assigns_automatic_stream_id(self, auto_id):
         utils._check_bool(auto_id)
-        return native_bt.stream_class_set_assigns_automatic_stream_id(self._ptr, auto_id)
+        return native_bt.stream_class_set_assigns_automatic_stream_id(
+            self._ptr, auto_id
+        )
 
     _assigns_automatic_stream_id = property(fset=_assigns_automatic_stream_id)
 
@@ -135,7 +150,9 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     @property
     def packets_have_beginning_default_clock_snapshot(self):
-        return native_bt.stream_class_packets_have_beginning_default_clock_snapshot(self._ptr)
+        return native_bt.stream_class_packets_have_beginning_default_clock_snapshot(
+            self._ptr
+        )
 
     @property
     def packets_have_end_default_clock_snapshot(self):
@@ -147,12 +164,16 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
         utils._check_bool(with_end_cs)
 
         if not supports and (with_begin_cs or with_end_cs):
-            raise ValueError('cannot not support packets, but have default clock snapshots')
+            raise ValueError(
+                'cannot not support packets, but have default clock snapshots'
+            )
 
         if not supports and self.packet_context_field_class is not None:
             raise ValueError('stream class already has a packet context field class')
 
-        native_bt.stream_class_set_supports_packets(self._ptr, supports, with_begin_cs, with_end_cs)
+        native_bt.stream_class_set_supports_packets(
+            self._ptr, supports, with_begin_cs, with_end_cs
+        )
 
     @property
     def supports_discarded_events(self):
@@ -163,13 +184,19 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
         utils._check_bool(with_cs)
 
         if not supports and with_cs:
-            raise ValueError('cannot not support discarded events, but have default clock snapshots')
+            raise ValueError(
+                'cannot not support discarded events, but have default clock snapshots'
+            )
 
-        native_bt.stream_class_set_supports_discarded_events(self._ptr, supports, with_cs)
+        native_bt.stream_class_set_supports_discarded_events(
+            self._ptr, supports, with_cs
+        )
 
     @property
     def discarded_events_have_default_clock_snapshots(self):
-        return native_bt.stream_class_discarded_events_have_default_clock_snapshots(self._ptr)
+        return native_bt.stream_class_discarded_events_have_default_clock_snapshots(
+            self._ptr
+        )
 
     @property
     def supports_discarded_packets(self):
@@ -180,16 +207,24 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
         utils._check_bool(with_cs)
 
         if supports and not self.supports_packets:
-            raise ValueError('cannot support discarded packets, but not support packets')
+            raise ValueError(
+                'cannot support discarded packets, but not support packets'
+            )
 
         if not supports and with_cs:
-            raise ValueError('cannot not support discarded packets, but have default clock snapshots')
+            raise ValueError(
+                'cannot not support discarded packets, but have default clock snapshots'
+            )
 
-        native_bt.stream_class_set_supports_discarded_packets(self._ptr, supports, with_cs)
+        native_bt.stream_class_set_supports_discarded_packets(
+            self._ptr, supports, with_cs
+        )
 
     @property
     def discarded_packets_have_default_clock_snapshots(self):
-        return native_bt.stream_class_discarded_packets_have_default_clock_snapshots(self._ptr)
+        return native_bt.stream_class_discarded_packets_have_default_clock_snapshots(
+            self._ptr
+        )
 
     @property
     def id(self):
@@ -208,7 +243,9 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     @property
     def packet_context_field_class(self):
-        fc_ptr = native_bt.stream_class_borrow_packet_context_field_class_const(self._ptr)
+        fc_ptr = native_bt.stream_class_borrow_packet_context_field_class_const(
+            self._ptr
+        )
 
         if fc_ptr is None:
             return
@@ -217,22 +254,27 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     def _packet_context_field_class(self, packet_context_field_class):
         if packet_context_field_class is not None:
-            utils._check_type(packet_context_field_class,
-                              bt2.field_class._StructureFieldClass)
+            utils._check_type(
+                packet_context_field_class, bt2.field_class._StructureFieldClass
+            )
 
             if not self.supports_packets:
                 raise ValueError('stream class does not support packets')
 
-            status = native_bt.stream_class_set_packet_context_field_class(self._ptr,
-                                                                           packet_context_field_class._ptr)
-            utils._handle_func_status(status,
-                                      "cannot set stream class' packet context field class")
+            status = native_bt.stream_class_set_packet_context_field_class(
+                self._ptr, packet_context_field_class._ptr
+            )
+            utils._handle_func_status(
+                status, "cannot set stream class' packet context field class"
+            )
 
     _packet_context_field_class = property(fset=_packet_context_field_class)
 
     @property
     def event_common_context_field_class(self):
-        fc_ptr = native_bt.stream_class_borrow_event_common_context_field_class_const(self._ptr)
+        fc_ptr = native_bt.stream_class_borrow_event_common_context_field_class_const(
+            self._ptr
+        )
 
         if fc_ptr is None:
             return
@@ -241,13 +283,15 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     def _event_common_context_field_class(self, event_common_context_field_class):
         if event_common_context_field_class is not None:
-            utils._check_type(event_common_context_field_class,
-                              bt2.field_class._StructureFieldClass)
+            utils._check_type(
+                event_common_context_field_class, bt2.field_class._StructureFieldClass
+            )
 
             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(status,
-                                      "cannot set stream class' event context field type")
+            utils._handle_func_status(
+                status, "cannot set stream class' event context field type"
+            )
 
     _event_common_context_field_class = property(fset=_event_common_context_field_class)
 
@@ -261,7 +305,6 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping):
 
     def _default_clock_class(self, clock_class):
         utils._check_type(clock_class, bt2.clock_class._ClockClass)
-        native_bt.stream_class_set_default_clock_class(
-            self._ptr, clock_class._ptr)
+        native_bt.stream_class_set_default_clock_class(self._ptr, clock_class._ptr)
 
     _default_clock_class = property(fset=_default_clock_class)
index d7f03cb5d11e4f698d9c2bbe485ebd76c56ffaee..5ddcbad29719123404c7ffc8d09c3ce878c77b54 100644 (file)
@@ -55,8 +55,7 @@ class _TraceEnv(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")
+        utils._handle_func_status(status, "cannot set trace object's environment entry")
 
     def __delitem__(self, key):
         raise NotImplementedError
@@ -123,8 +122,7 @@ class _Trace(object._SharedObject, collections.abc.Mapping):
     def _name(self, name):
         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")
+        utils._handle_func_status(status, "cannot set trace class object's name")
 
     _name = property(fset=_name)
 
@@ -151,15 +149,21 @@ class _Trace(object._SharedObject, collections.abc.Mapping):
 
         if stream_class.assigns_automatic_stream_id:
             if id is not None:
-                raise ValueError("id provided, but stream class assigns automatic stream ids")
+                raise ValueError(
+                    "id provided, but stream class assigns automatic stream ids"
+                )
 
             stream_ptr = native_bt.stream_create(stream_class._ptr, self._ptr)
         else:
             if id is None:
-                raise ValueError("id not provided, but stream class does not assign automatic stream ids")
+                raise ValueError(
+                    "id not provided, but stream class does not assign automatic stream ids"
+                )
 
             utils._check_uint64(id)
-            stream_ptr = native_bt.stream_create_with_id(stream_class._ptr, self._ptr, id)
+            stream_ptr = native_bt.stream_create_with_id(
+                stream_class._ptr, self._ptr, id
+            )
 
         if stream_ptr is None:
             raise bt2.CreationError('cannot create stream object')
@@ -177,8 +181,9 @@ class _Trace(object._SharedObject, collections.abc.Mapping):
             raise TypeError("'listener' parameter is not callable")
 
         fn = native_bt.bt2_trace_add_destruction_listener
-        listener_from_native = functools.partial(_trace_destruction_listener_from_native,
-                                                 listener)
+        listener_from_native = functools.partial(
+            _trace_destruction_listener_from_native, listener
+        )
 
         listener_id = fn(self._ptr, listener_from_native)
         if listener_id is None:
index fb0eb543f10793b425b94dbb5d9d58350e06009d..d480b819b4da9ed434bca596d61208a9b7f2e37a 100644 (file)
@@ -41,7 +41,9 @@ class _StreamClassIterator(collections.abc.Iterator):
         if self._at == len(self._trace_class):
             raise StopIteration
 
-        borrow_stream_class_fn = native_bt.trace_class_borrow_stream_class_by_index_const
+        borrow_stream_class_fn = (
+            native_bt.trace_class_borrow_stream_class_by_index_const
+        )
         sc_ptr = borrow_stream_class_fn(self._trace_class._ptr, self._at)
         assert sc_ptr
         id = native_bt.stream_class_get_id(sc_ptr)
@@ -51,7 +53,9 @@ class _StreamClassIterator(collections.abc.Iterator):
 
 
 def _trace_class_destruction_listener_from_native(user_listener, trace_class_ptr):
-    trace_class = bt2.trace_class._TraceClass._create_from_ptr_and_get_ref(trace_class_ptr)
+    trace_class = bt2.trace_class._TraceClass._create_from_ptr_and_get_ref(
+        trace_class_ptr
+    )
     user_listener(trace_class)
 
 
@@ -101,7 +105,9 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
 
     def __iter__(self):
         for idx in range(len(self)):
-            sc_ptr = native_bt.trace_class_borrow_stream_class_by_index_const(self._ptr, idx)
+            sc_ptr = native_bt.trace_class_borrow_stream_class_by_index_const(
+                self._ptr, idx
+            )
             assert sc_ptr is not None
 
             id = native_bt.stream_class_get_id(sc_ptr)
@@ -109,29 +115,36 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
 
             yield id
 
-    def create_stream_class(self, id=None,
-                            name=None,
-                            packet_context_field_class=None,
-                            event_common_context_field_class=None,
-                            default_clock_class=None,
-                            assigns_automatic_event_class_id=True,
-                            assigns_automatic_stream_id=True,
-                            supports_packets=False,
-                            packets_have_beginning_default_clock_snapshot=False,
-                            packets_have_end_default_clock_snapshot=False,
-                            supports_discarded_events=False,
-                            discarded_events_have_default_clock_snapshots=False,
-                            supports_discarded_packets=False,
-                            discarded_packets_have_default_clock_snapshots=False):
+    def create_stream_class(
+        self,
+        id=None,
+        name=None,
+        packet_context_field_class=None,
+        event_common_context_field_class=None,
+        default_clock_class=None,
+        assigns_automatic_event_class_id=True,
+        assigns_automatic_stream_id=True,
+        supports_packets=False,
+        packets_have_beginning_default_clock_snapshot=False,
+        packets_have_end_default_clock_snapshot=False,
+        supports_discarded_events=False,
+        discarded_events_have_default_clock_snapshots=False,
+        supports_discarded_packets=False,
+        discarded_packets_have_default_clock_snapshots=False,
+    ):
 
         if self.assigns_automatic_stream_class_id:
             if id is not None:
-                raise ValueError('id provided, but trace class assigns automatic stream class ids')
+                raise ValueError(
+                    'id provided, but trace class assigns automatic stream class ids'
+                )
 
             sc_ptr = native_bt.stream_class_create(self._ptr)
         else:
             if id is None:
-                raise ValueError('id not provided, but trace class does not assign automatic stream class ids')
+                raise ValueError(
+                    'id not provided, but trace class does not assign automatic stream class ids'
+                )
 
             utils._check_uint64(id)
             sc_ptr = native_bt.stream_class_create_with_id(self._ptr, id)
@@ -151,9 +164,11 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
         # `packets_have_beginning_default_clock_snapshot` or
         # `packets_have_end_default_clock_snapshot` is true, then this
         # stream class needs a default clock class already.
-        sc._set_supports_packets(supports_packets,
-                                 packets_have_beginning_default_clock_snapshot,
-                                 packets_have_end_default_clock_snapshot)
+        sc._set_supports_packets(
+            supports_packets,
+            packets_have_beginning_default_clock_snapshot,
+            packets_have_end_default_clock_snapshot,
+        )
 
         # call after sc._set_supports_packets() because, if
         # `packet_context_field_class` is not `None`, then this stream
@@ -163,10 +178,12 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
 
         sc._assigns_automatic_event_class_id = assigns_automatic_event_class_id
         sc._assigns_automatic_stream_id = assigns_automatic_stream_id
-        sc._set_supports_discarded_events(supports_discarded_events,
-                                          discarded_events_have_default_clock_snapshots)
-        sc._set_supports_discarded_packets(supports_discarded_packets,
-                                           discarded_packets_have_default_clock_snapshots)
+        sc._set_supports_discarded_events(
+            supports_discarded_events, discarded_events_have_default_clock_snapshots
+        )
+        sc._set_supports_discarded_packets(
+            supports_discarded_packets, discarded_packets_have_default_clock_snapshots
+        )
         return sc
 
     @property
@@ -175,18 +192,23 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
 
     def _assigns_automatic_stream_class_id(self, auto_id):
         utils._check_bool(auto_id)
-        return native_bt.trace_class_set_assigns_automatic_stream_class_id(self._ptr, auto_id)
+        return native_bt.trace_class_set_assigns_automatic_stream_class_id(
+            self._ptr, auto_id
+        )
 
-    _assigns_automatic_stream_class_id = property(fset=_assigns_automatic_stream_class_id)
+    _assigns_automatic_stream_class_id = property(
+        fset=_assigns_automatic_stream_class_id
+    )
 
     # Field class creation methods.
 
     def _check_create_status(self, ptr, type_name):
         if ptr is None:
-            raise bt2.CreationError(
-                'cannot create {} field class'.format(type_name))
+            raise bt2.CreationError('cannot create {} field class'.format(type_name))
 
-    def _create_integer_field_class(self, create_func, py_cls, type_name, field_value_range, preferred_display_base):
+    def _create_integer_field_class(
+        self, create_func, py_cls, type_name, field_value_range, preferred_display_base
+    ):
         field_class_ptr = create_func(self._ptr)
         self._check_create_status(field_class_ptr, type_name)
 
@@ -200,25 +222,49 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
 
         return field_class
 
-    def create_signed_integer_field_class(self, field_value_range=None, preferred_display_base=None):
-        return self._create_integer_field_class(native_bt.field_class_signed_integer_create,
-                                                bt2.field_class._SignedIntegerFieldClass,
-                                                'signed integer', field_value_range, preferred_display_base)
-
-    def create_unsigned_integer_field_class(self, field_value_range=None, preferred_display_base=None):
-        return self._create_integer_field_class(native_bt.field_class_unsigned_integer_create,
-                                                bt2.field_class._UnsignedIntegerFieldClass,
-                                                'unsigned integer', field_value_range, preferred_display_base)
-
-    def create_signed_enumeration_field_class(self, field_value_range=None, preferred_display_base=None):
-        return self._create_integer_field_class(native_bt.field_class_signed_enumeration_create,
-                                                bt2.field_class._SignedEnumerationFieldClass,
-                                                'signed enumeration', field_value_range, preferred_display_base)
-
-    def create_unsigned_enumeration_field_class(self, field_value_range=None, preferred_display_base=None):
-        return self._create_integer_field_class(native_bt.field_class_unsigned_enumeration_create,
-                                                bt2.field_class._UnsignedEnumerationFieldClass,
-                                                'unsigned enumeration', field_value_range, preferred_display_base)
+    def create_signed_integer_field_class(
+        self, field_value_range=None, preferred_display_base=None
+    ):
+        return self._create_integer_field_class(
+            native_bt.field_class_signed_integer_create,
+            bt2.field_class._SignedIntegerFieldClass,
+            'signed integer',
+            field_value_range,
+            preferred_display_base,
+        )
+
+    def create_unsigned_integer_field_class(
+        self, field_value_range=None, preferred_display_base=None
+    ):
+        return self._create_integer_field_class(
+            native_bt.field_class_unsigned_integer_create,
+            bt2.field_class._UnsignedIntegerFieldClass,
+            'unsigned integer',
+            field_value_range,
+            preferred_display_base,
+        )
+
+    def create_signed_enumeration_field_class(
+        self, field_value_range=None, preferred_display_base=None
+    ):
+        return self._create_integer_field_class(
+            native_bt.field_class_signed_enumeration_create,
+            bt2.field_class._SignedEnumerationFieldClass,
+            'signed enumeration',
+            field_value_range,
+            preferred_display_base,
+        )
+
+    def create_unsigned_enumeration_field_class(
+        self, field_value_range=None, preferred_display_base=None
+    ):
+        return self._create_integer_field_class(
+            native_bt.field_class_unsigned_enumeration_create,
+            bt2.field_class._UnsignedEnumerationFieldClass,
+            'unsigned enumeration',
+            field_value_range,
+            preferred_display_base,
+        )
 
     def create_real_field_class(self, is_single_precision=False):
         field_class_ptr = native_bt.field_class_real_create(self._ptr)
@@ -258,7 +304,9 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
             utils._check_type(length_fc, bt2.field_class._UnsignedIntegerFieldClass)
             length_fc_ptr = length_fc._ptr
 
-        ptr = native_bt.field_class_dynamic_array_create(self._ptr, elem_fc._ptr, length_fc_ptr)
+        ptr = native_bt.field_class_dynamic_array_create(
+            self._ptr, elem_fc._ptr, length_fc_ptr
+        )
         self._check_create_status(ptr, 'dynamic array')
         return bt2.field_class._DynamicArrayFieldClass._create_from_ptr(ptr)
 
@@ -281,11 +329,14 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping):
             raise TypeError("'listener' parameter is not callable")
 
         fn = native_bt.bt2_trace_class_add_destruction_listener
-        listener_from_native = functools.partial(_trace_class_destruction_listener_from_native,
-                                                 listener)
+        listener_from_native = functools.partial(
+            _trace_class_destruction_listener_from_native, listener
+        )
 
         listener_id = fn(self._ptr, listener_from_native)
         if listener_id is None:
-            utils._raise_bt2_error('cannot add destruction listener to trace class object')
+            utils._raise_bt2_error(
+                'cannot add destruction listener to trace class object'
+            )
 
         return bt2._ListenerHandle(listener_id, self)
index 25778fccaa7fbc636fc5f8f82b31000e311b5d3c..592c7f157ab9827b88fe02a8dbb4b7544c072652 100644 (file)
@@ -34,8 +34,13 @@ _ComponentAndSpec = namedtuple('_ComponentAndSpec', ['comp', 'spec'])
 
 
 class ComponentSpec:
-    def __init__(self, plugin_name, class_name, params=None,
-                 logging_level=bt2.logging.LoggingLevel.NONE):
+    def __init__(
+        self,
+        plugin_name,
+        class_name,
+        params=None,
+        logging_level=bt2.logging.LoggingLevel.NONE,
+    ):
         utils._check_str(plugin_name)
         utils._check_str(class_name)
         utils._check_log_level(logging_level)
@@ -77,7 +82,9 @@ def _get_ns(obj):
         # s -> ns
         s = obj.timestamp()
     else:
-        raise TypeError('"{}" is not an integral number or a datetime.datetime object'.format(obj))
+        raise TypeError(
+            '"{}" is not an integral number or a datetime.datetime object'.format(obj)
+        )
 
     return int(s * 1e9)
 
@@ -88,8 +95,14 @@ class _CompClsType:
 
 
 class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
-    def __init__(self, source_component_specs, filter_component_specs=None,
-                 stream_intersection_mode=False, begin=None, end=None):
+    def __init__(
+        self,
+        source_component_specs,
+        filter_component_specs=None,
+        stream_intersection_mode=False,
+        begin=None,
+        end=None,
+    ):
         utils._check_bool(stream_intersection_mode)
         self._stream_intersection_mode = stream_intersection_mode
         self._begin_ns = _get_ns(begin)
@@ -119,7 +132,9 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
     def _validate_component_specs(self, comp_specs):
         for comp_spec in comp_specs:
             if type(comp_spec) is not ComponentSpec:
-                raise TypeError('"{}" object is not a ComponentSpec'.format(type(comp_spec)))
+                raise TypeError(
+                    '"{}" object is not a ComponentSpec'.format(type(comp_spec))
+                )
 
     def __next__(self):
         return next(self._msg_iter)
@@ -134,7 +149,9 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
         try:
             paths = src_comp_and_spec.spec.params['paths']
         except Exception as e:
-            raise bt2.Error('all source components must be created with a "paths" parameter in stream intersection mode') from e
+            raise bt2.Error(
+                'all source components must be created with a "paths" parameter in stream intersection mode'
+            ) from e
 
         params = {'paths': paths}
 
@@ -142,8 +159,9 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
         # contains the stream intersection range for each exposed
         # trace
         query_exec = bt2.QueryExecutor()
-        trace_info_res = query_exec.query(src_comp_and_spec.comp.cls,
-                                          'trace-info', params)
+        trace_info_res = query_exec.query(
+            src_comp_and_spec.comp.cls, 'trace-info', params
+        )
         begin = None
         end = None
 
@@ -160,7 +178,9 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
             pass
 
         if begin is None or end is None:
-            raise bt2.Error('cannot find stream intersection range for port "{}"'.format(port.name))
+            raise bt2.Error(
+                'cannot find stream intersection range for port "{}"'.format(port.name)
+            )
 
         name = 'trimmer-{}-{}'.format(src_comp_and_spec.comp.name, port.name)
         return self._create_trimmer(begin, end, name)
@@ -172,7 +192,9 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
             raise bt2.Error('cannot find "utils" plugin (needed for the muxer)')
 
         if 'muxer' not in plugin.filter_component_classes:
-            raise bt2.Error('cannot find "muxer" filter component class in "utils" plugin')
+            raise bt2.Error(
+                'cannot find "muxer" filter component class in "utils" plugin'
+            )
 
         comp_cls = plugin.filter_component_classes['muxer']
         return self._graph.add_component(comp_cls, 'muxer')
@@ -184,7 +206,9 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
             raise bt2.Error('cannot find "utils" plugin (needed for the trimmer)')
 
         if 'trimmer' not in plugin.filter_component_classes:
-            raise bt2.Error('cannot find "trimmer" filter component class in "utils" plugin')
+            raise bt2.Error(
+                'cannot find "trimmer" filter component class in "utils" plugin'
+            )
 
         params = {}
 
@@ -203,10 +227,10 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
         return self._graph.add_component(comp_cls, name, params)
 
     def _get_unique_comp_name(self, comp_spec):
-        name = '{}-{}'.format(comp_spec.plugin_name,
-                              comp_spec.class_name)
-        comps_and_specs = itertools.chain(self._src_comps_and_specs,
-                                          self._flt_comps_and_specs)
+        name = '{}-{}'.format(comp_spec.plugin_name, comp_spec.class_name)
+        comps_and_specs = itertools.chain(
+            self._src_comps_and_specs, self._flt_comps_and_specs
+        )
 
         if name in [comp_and_spec.comp.name for comp_and_spec in comps_and_specs]:
             name += '-{}'.format(self._next_suffix)
@@ -227,14 +251,17 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
 
         if comp_spec.class_name not in comp_classes:
             cc_type = 'source' if comp_cls_type == _CompClsType.SOURCE else 'filter'
-            raise bt2.Error('no such {} component class in "{}" plugin: {}'.format(cc_type,
-                                                                                   comp_spec.plugin_name,
-                                                                                   comp_spec.class_name))
+            raise bt2.Error(
+                'no such {} component class in "{}" plugin: {}'.format(
+                    cc_type, comp_spec.plugin_name, comp_spec.class_name
+                )
+            )
 
         comp_cls = comp_classes[comp_spec.class_name]
         name = self._get_unique_comp_name(comp_spec)
-        comp = self._graph.add_component(comp_cls, name, comp_spec.params,
-                                         comp_spec.logging_level)
+        comp = self._graph.add_component(
+            comp_cls, name, comp_spec.params, comp_spec.logging_level
+        )
         return comp
 
     def _get_free_muxer_input_port(self):
@@ -279,10 +306,10 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
         self._muxer_comp = self._create_muxer()
 
         if self._begin_ns is not None or self._end_ns is not None:
-            trimmer_comp = self._create_trimmer(self._begin_ns,
-                                                self._end_ns, 'trimmer')
-            self._graph.connect_ports(self._muxer_comp.output_ports['out'],
-                                      trimmer_comp.input_ports['in'])
+            trimmer_comp = self._create_trimmer(self._begin_ns, self._end_ns, 'trimmer')
+            self._graph.connect_ports(
+                self._muxer_comp.output_ports['out'], trimmer_comp.input_ports['in']
+            )
             msg_iter_port = trimmer_comp.output_ports['out']
         else:
             msg_iter_port = self._muxer_comp.output_ports['out']
index 6d80fea283b59a45814233e7bfb335bee5885020..1d983215eac26e4ad800d08885fdcc5b09fffc62 100644 (file)
@@ -47,13 +47,14 @@ def _check_str(o):
 
 def _check_type(o, expected_type):
     if not isinstance(o, expected_type):
-        raise TypeError("'{}' is not a '{}' object".format(o.__class__.__name__,
-                                                           expected_type))
+        raise TypeError(
+            "'{}' is not a '{}' object".format(o.__class__.__name__, expected_type)
+        )
 
 
 def _is_in_int64_range(v):
-    assert(isinstance(v, int))
-    return v >= -(2**63) and v <= (2**63 - 1)
+    assert isinstance(v, int)
+    return v >= -(2 ** 63) and v <= (2 ** 63 - 1)
 
 
 def _is_int64(v):
@@ -64,8 +65,8 @@ def _is_int64(v):
 
 
 def _is_in_uint64_range(v):
-    assert(isinstance(v, int))
-    return v >= 0 and v <= (2**64 - 1)
+    assert isinstance(v, int)
+    return v >= 0 and v <= (2 ** 64 - 1)
 
 
 def _is_uint64(v):
@@ -146,7 +147,10 @@ def _handle_func_status(status, msg=None):
         # no error
         return
 
-    if status == native_bt.__BT_FUNC_STATUS_ERROR or status == native_bt.__BT_FUNC_STATUS_MEMORY_ERROR:
+    if (
+        status == native_bt.__BT_FUNC_STATUS_ERROR
+        or status == native_bt.__BT_FUNC_STATUS_MEMORY_ERROR
+    ):
         if msg is None:
             raise bt2.Error
         else:
index 2710d90330c8fa0849e055713d569fc8cf9f591f..3c883f76e6189c42583c57b80b09a5062f3ecfb7 100644 (file)
@@ -78,7 +78,9 @@ def create_value(value):
     if isinstance(value, collections.abc.Mapping):
         return MapValue(value)
 
-    raise TypeError("cannot create value object from '{}' object".format(value.__class__.__name__))
+    raise TypeError(
+        "cannot create value object from '{}' object".format(value.__class__.__name__)
+    )
 
 
 class _Value(object._SharedObject, metaclass=abc.ABCMeta):
@@ -91,7 +93,8 @@ class _Value(object._SharedObject, metaclass=abc.ABCMeta):
     def _check_create_status(self, ptr):
         if ptr is None:
             raise bt2.CreationError(
-                'cannot create {} value object'.format(self._NAME.lower()))
+                'cannot create {} value object'.format(self._NAME.lower())
+            )
 
 
 @functools.total_ordering
@@ -110,7 +113,9 @@ class _NumericValue(_Value):
         if isinstance(other, numbers.Complex):
             return complex(other)
 
-        raise TypeError("'{}' object is not a number object".format(other.__class__.__name__))
+        raise TypeError(
+            "'{}' object is not a number object".format(other.__class__.__name__)
+        )
 
     def __int__(self):
         return int(self._value)
@@ -253,7 +258,11 @@ class BoolValue(_IntegralValue):
             value = value._value
 
         if not isinstance(value, bool):
-            raise TypeError("'{}' object is not a 'bool' or 'BoolValue' object".format(value.__class__))
+            raise TypeError(
+                "'{}' object is not a 'bool' or 'BoolValue' object".format(
+                    value.__class__
+                )
+            )
 
         return value
 
@@ -440,13 +449,17 @@ class ArrayValue(_Container, collections.abc.MutableSequence, _Value):
 
     def __len__(self):
         size = native_bt.value_array_get_size(self._ptr)
-        assert(size >= 0)
+        assert size >= 0
         return size
 
     def _check_index(self, index):
         # TODO: support slices also
         if not isinstance(index, numbers.Integral):
-            raise TypeError("'{}' object is not an integral number object: invalid index".format(index.__class__.__name__))
+            raise TypeError(
+                "'{}' object is not an integral number object: invalid index".format(
+                    index.__class__.__name__
+                )
+            )
 
         index = int(index)
 
@@ -456,7 +469,7 @@ class ArrayValue(_Container, collections.abc.MutableSequence, _Value):
     def __getitem__(self, index):
         self._check_index(index)
         ptr = native_bt.value_array_borrow_element_by_index(self._ptr, index)
-        assert(ptr)
+        assert ptr
         return _create_from_ptr_and_get_ref(ptr)
 
     def __setitem__(self, index, value):
@@ -468,8 +481,7 @@ class ArrayValue(_Container, collections.abc.MutableSequence, _Value):
         else:
             ptr = value._ptr
 
-        status = native_bt.value_array_set_element_by_index(
-            self._ptr, index, ptr)
+        status = native_bt.value_array_set_element_by_index(self._ptr, index, ptr)
         utils._handle_func_status(status)
 
     def append(self, value):
@@ -554,7 +566,7 @@ class MapValue(_Container, collections.abc.MutableMapping, _Value):
 
     def __len__(self):
         size = native_bt.value_map_get_size(self._ptr)
-        assert(size >= 0)
+        assert size >= 0
         return size
 
     def __contains__(self, key):
@@ -571,7 +583,7 @@ class MapValue(_Container, collections.abc.MutableMapping, _Value):
     def __getitem__(self, key):
         self._check_key(key)
         ptr = native_bt.value_map_borrow_entry_value(self._ptr, key)
-        assert(ptr)
+        assert ptr
         return _create_from_ptr_and_get_ref(ptr)
 
     def __iter__(self):
index 0182305dd6c73947b08775eda7c75dd4f0954268..8172839cc1a5be99829e21465aa8c867bcbc33d6 100644 (file)
@@ -34,46 +34,46 @@ following command to your .bashrc/.zshrc:
 --------------------------------------------------------------------------------
 """
 
+
 def main():
-    babeltrace_ext = Extension('bt2._native_bt',
-                        sources=['bt2/native_bt.c', '@srcdir@/bt2/logging.c'],
-                        libraries=['babeltrace2', 'glib-2.0'],
-                        extra_objects=['@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a',
-                            '@top_builddir@/src/common/.libs/libbabeltrace2-common.a',
-                            '@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a'])
+    babeltrace_ext = Extension(
+        'bt2._native_bt',
+        sources=['bt2/native_bt.c', '@srcdir@/bt2/logging.c'],
+        libraries=['babeltrace2', 'glib-2.0'],
+        extra_objects=[
+            '@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a',
+            '@top_builddir@/src/common/.libs/libbabeltrace2-common.a',
+            '@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a',
+        ],
+    )
 
-    dist = setup(name='bt2',
-            version='@PACKAGE_VERSION@',
-            description='Babeltrace 2 Python Bindings',
-            packages=['bt2'],
-            package_dir={'bt2': 'bt2'},
-            options={'build':
-                {
-                    'build_base': 'build',
-                    'build_lib': 'build/build_lib'
-                },
-                'build_ext':
-                {
-                    'build_lib': 'build/build_lib'
-                }
-            },
-            url='http://diamon.org/babeltrace',
-            ext_modules=[babeltrace_ext],
-            license='MIT',
-            classifiers=[
-                'Development Status :: 5 - Production/Stable',
-                'Intended Audience :: Developers',
-                'License :: OSI Approved :: The MIT License',
-                'Programming Language :: Python :: 3'
-                'Topic :: System :: Logging',
-                ])
+    dist = setup(
+        name='bt2',
+        version='@PACKAGE_VERSION@',
+        description='Babeltrace 2 Python Bindings',
+        packages=['bt2'],
+        package_dir={'bt2': 'bt2'},
+        options={
+            'build': {'build_base': 'build', 'build_lib': 'build/build_lib'},
+            'build_ext': {'build_lib': 'build/build_lib'},
+        },
+        url='http://diamon.org/babeltrace',
+        ext_modules=[babeltrace_ext],
+        license='MIT',
+        classifiers=[
+            'Development Status :: 5 - Production/Stable',
+            'Intended Audience :: Developers',
+            'License :: OSI Approved :: The MIT License',
+            'Programming Language :: Python :: 3' 'Topic :: System :: Logging',
+        ],
+    )
 
-# After the installation, we check that the install directory is included in
-# the Python search path and we print a warning message when it's not.
-# We need to do this because Python search path differs depending on the distro
-# and some distros don't include any /usr/local/ in the search path. This is
-# also useful for out-of-tree installs and tests.
-# It's only relevant to make this check on the `install` command.
+    # After the installation, we check that the install directory is included in
+    # the Python search path and we print a warning message when it's not.
+    # We need to do this because Python search path differs depending on the distro
+    # and some distros don't include any /usr/local/ in the search path. This is
+    # also useful for out-of-tree installs and tests.
+    # It's only relevant to make this check on the `install` command.
 
     if 'install' in dist.command_obj:
         install_dir = dist.command_obj['install'].install_libbase
@@ -83,5 +83,6 @@ def main():
             # extra configuration is needed to use the bindings
             print(PY_PATH_WARN_MSG.format(install_dir, install_dir))
 
+
 if __name__ == "__main__":
     main()
index 53487c655370a9695064eba568894489f33832ac..c8828ebfc5d1105be52c2dfe3ff960d3069a4144 100644 (file)
@@ -169,7 +169,9 @@ class ClockClassTestCase(unittest.TestCase):
 
     def test_cycles_to_ns_from_origin(self):
         def f(comp_self):
-            return comp_self._create_clock_class(frequency=10**8, origin_is_unix_epoch=True)
+            return comp_self._create_clock_class(
+                frequency=10 ** 8, origin_is_unix_epoch=True
+            )
 
         cc = run_in_component_init(f)
         self.assertEqual(cc.cycles_to_ns_from_origin(112), 1120)
@@ -180,11 +182,13 @@ class ClockClassTestCase(unittest.TestCase):
 
         cc = run_in_component_init(f)
         with self.assertRaises(bt2.OverflowError):
-            cc.cycles_to_ns_from_origin(2**63)
+            cc.cycles_to_ns_from_origin(2 ** 63)
 
     def test_create_uuid(self):
         def f(comp_self):
-            return comp_self._create_clock_class(uuid=uuid.UUID('b43372c32ef0be28444dfc1c5cdafd33'))
+            return comp_self._create_clock_class(
+                uuid=uuid.UUID('b43372c32ef0be28444dfc1c5cdafd33')
+            )
 
         cc = run_in_component_init(f)
         self.assertEqual(cc.uuid, uuid.UUID('b43372c32ef0be28444dfc1c5cdafd33'))
@@ -199,8 +203,9 @@ class ClockClassTestCase(unittest.TestCase):
 class ClockSnapshotTestCase(unittest.TestCase):
     def setUp(self):
         def f(comp_self):
-            cc = comp_self._create_clock_class(1000, 'my_cc',
-                                               offset=bt2.ClockClassOffset(45, 354))
+            cc = comp_self._create_clock_class(
+                1000, 'my_cc', offset=bt2.ClockClassOffset(45, 354)
+            )
             tc = comp_self._create_trace_class()
 
             return (cc, tc)
@@ -224,7 +229,7 @@ class ClockSnapshotTestCase(unittest.TestCase):
                 elif self._at == 1:
                     notif = self._create_event_message(_ec, _stream, 123)
                 elif self._at == 2:
-                    notif = self._create_event_message(_ec, _stream, 2**63)
+                    notif = self._create_event_message(_ec, _stream, 2 ** 63)
                 elif self._at == 3:
                     notif = self._create_stream_end_message(_stream)
                 else:
@@ -240,7 +245,8 @@ class ClockSnapshotTestCase(unittest.TestCase):
         self._graph = bt2.Graph()
         self._src_comp = self._graph.add_component(MySrc, 'my_source')
         self._msg_iter = self._graph.create_output_port_message_iterator(
-            self._src_comp.output_ports['out'])
+            self._src_comp.output_ports['out']
+        )
 
         for i, msg in enumerate(self._msg_iter):
             if i == 1:
@@ -255,18 +261,21 @@ class ClockSnapshotTestCase(unittest.TestCase):
 
     def test_create_default(self):
         self.assertEqual(
-            self._msg.default_clock_snapshot.clock_class.addr, self._cc.addr)
+            self._msg.default_clock_snapshot.clock_class.addr, self._cc.addr
+        )
         self.assertEqual(self._msg.default_clock_snapshot.value, 123)
 
     def test_clock_class(self):
         self.assertEqual(
-            self._msg.default_clock_snapshot.clock_class.addr, self._cc.addr)
+            self._msg.default_clock_snapshot.clock_class.addr, self._cc.addr
+        )
 
     def test_ns_from_origin(self):
         s_from_origin = 45 + ((354 + 123) / 1000)
         ns_from_origin = int(s_from_origin * 1e9)
         self.assertEqual(
-            self._msg.default_clock_snapshot.ns_from_origin, ns_from_origin)
+            self._msg.default_clock_snapshot.ns_from_origin, ns_from_origin
+        )
 
     def test_ns_from_origin_overflow(self):
         with self.assertRaises(bt2.OverflowError):
index cece1a56b39aed8e1fa7a218f12dfa65720674b0..857d15270dd3312dc5ee56960daa75d31499a57c 100644 (file)
@@ -31,8 +31,7 @@ class UserComponentClassTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             pass
 
         self._test_no_init(MySource)
@@ -42,8 +41,7 @@ class UserComponentClassTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             pass
 
         self._test_no_init(MyFilter)
@@ -63,6 +61,7 @@ class UserComponentClassTestCase(unittest.TestCase):
             pass
 
         with self.assertRaises(bt2.IncompleteUserClass):
+
             class MySource(bt2._UserSourceComponent):
                 pass
 
@@ -71,8 +70,8 @@ class UserComponentClassTestCase(unittest.TestCase):
             pass
 
         with self.assertRaises(bt2.IncompleteUserClass):
-            class MySource(bt2._UserSourceComponent,
-                           message_iterator_class=int):
+
+            class MySource(bt2._UserSourceComponent, message_iterator_class=int):
                 pass
 
     def test_incomplete_filter_no_msg_iter_cls(self):
@@ -80,6 +79,7 @@ class UserComponentClassTestCase(unittest.TestCase):
             pass
 
         with self.assertRaises(bt2.IncompleteUserClass):
+
             class MyFilter(bt2._UserFilterComponent):
                 pass
 
@@ -88,6 +88,7 @@ class UserComponentClassTestCase(unittest.TestCase):
             pass
 
         with self.assertRaises(bt2.IncompleteUserClass):
+
             class MySink(bt2._UserSinkComponent):
                 pass
 
@@ -95,16 +96,14 @@ class UserComponentClassTestCase(unittest.TestCase):
         class MyIter(bt2._UserMessageIterator):
             pass
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             pass
 
     def test_minimal_filter(self):
         class MyIter(bt2._UserMessageIterator):
             pass
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             pass
 
     def test_minimal_sink(self):
@@ -137,6 +136,7 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_invalid_custom_name(self):
         with self.assertRaises(TypeError):
+
             class MySink(bt2._UserSinkComponent, name=23):
                 def _consume(self):
                     pass
@@ -282,8 +282,7 @@ class UserComponentClassTestCase(unittest.TestCase):
                 query_log_level = log_level
 
         query_log_level = None
-        res = bt2.QueryExecutor().query(MySink, 'obj', None,
-                                        bt2.LoggingLevel.WARNING)
+        res = bt2.QueryExecutor().query(MySink, 'obj', None, bt2.LoggingLevel.WARNING)
         self.assertEqual(query_log_level, bt2.LoggingLevel.WARNING)
         del query_log_level
 
@@ -335,28 +334,18 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
                 query_params = params
-                return {
-                    'null': None,
-                    'bt2': 'BT2',
-                }
+                return {'null': None, 'bt2': 'BT2'}
 
         query_params = None
         params = {
             'array': ['coucou', 23, None],
-            'other_map': {
-                'yes': 'yeah',
-                '19': 19,
-                'minus 1.5': -1.5,
-            },
+            'other_map': {'yes': 'yeah', '19': 19, 'minus 1.5': -1.5},
             'null': None,
         }
 
         res = bt2.QueryExecutor().query(MySink, 'obj', params)
         self.assertEqual(query_params, params)
-        self.assertEqual(res, {
-            'null': None,
-            'bt2': 'BT2',
-        })
+        self.assertEqual(res, {'null': None, 'bt2': 'BT2'})
         del query_params
 
     def test_eq(self):
@@ -378,6 +367,7 @@ class GenericComponentClassTestCase(unittest.TestCase):
 
             The help.
             '''
+
             def _consume(self):
                 pass
 
@@ -392,8 +382,9 @@ class GenericComponentClassTestCase(unittest.TestCase):
         graph = bt2.Graph()
         comp = graph.add_component(MySink, 'salut')
         self._comp_cls = comp.cls
-        self.assertTrue(issubclass(type(self._comp_cls),
-                                   bt2.component._GenericComponentClass))
+        self.assertTrue(
+            issubclass(type(self._comp_cls), bt2.component._GenericComponentClass)
+        )
 
     def tearDown(self):
         del self._py_comp_cls
@@ -420,7 +411,8 @@ class GenericComponentClassTestCase(unittest.TestCase):
         self.assertEqual(self._py_comp_cls, self._comp_cls)
 
     def test_query(self):
-        res = bt2.QueryExecutor().query(self._comp_cls, 'an object',
-                                        {'yes': 'no', 'book': -17})
+        res = bt2.QueryExecutor().query(
+            self._comp_cls, 'an object', {'yes': 'no', 'book': -17}
+        )
         expected = ['an object', {'yes': 'no', 'book': -17}, 23]
         self.assertEqual(res, expected)
index 7c1cbe5715de45e2e2d8e61dd064ab0930c6eba0..686a75f7b2863e9cacb334f512437c3fd4adeba9 100644 (file)
@@ -26,8 +26,7 @@ class ConnectionTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -44,8 +43,7 @@ class ConnectionTestCase(unittest.TestCase):
         graph = bt2.Graph()
         src = graph.add_component(MySource, 'src')
         sink = graph.add_component(MySink, 'sink')
-        conn = graph.connect_ports(src.output_ports['out'],
-                                   sink.input_ports['in'])
+        conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in'])
         self.assertIsInstance(conn, bt2._Connection)
 
     def test_downstream_port(self):
@@ -53,8 +51,7 @@ class ConnectionTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -71,8 +68,7 @@ class ConnectionTestCase(unittest.TestCase):
         graph = bt2.Graph()
         src = graph.add_component(MySource, 'src')
         sink = graph.add_component(MySink, 'sink')
-        conn = graph.connect_ports(src.output_ports['out'],
-                                   sink.input_ports['in'])
+        conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in'])
         self.assertEqual(conn.downstream_port.addr, sink.input_ports['in'].addr)
 
     def test_upstream_port(self):
@@ -80,8 +76,7 @@ class ConnectionTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -98,6 +93,5 @@ class ConnectionTestCase(unittest.TestCase):
         graph = bt2.Graph()
         src = graph.add_component(MySource, 'src')
         sink = graph.add_component(MySink, 'sink')
-        conn = graph.connect_ports(src.output_ports['out'],
-                                   sink.input_ports['in'])
+        conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in'])
         self.assertEqual(conn.upstream_port.addr, src.output_ports['out'].addr)
index d666579d32fcdd9aff8bbfbdf11295753623c5a0..2653d7df7d7e8b949fe47e0a40c4fcb56e7516d4 100644 (file)
@@ -39,10 +39,15 @@ class CtfWriterClockTestCase(unittest.TestCase):
 
     def test_create_full(self):
         my_uuid = uuid.uuid1()
-        cc = bt2.CtfWriterClock(name='name', description='some description',
-                                frequency=1001, precision=176,
-                                offset=bt2.ClockClassOffset(45, 3003),
-                                is_absolute=True, uuid=my_uuid)
+        cc = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
         self.assertEqual(cc.name, 'name')
         self.assertEqual(cc.description, 'some description')
         self.assertEqual(cc.frequency, 1001)
@@ -122,97 +127,177 @@ class CtfWriterClockTestCase(unittest.TestCase):
 
     def test_eq(self):
         my_uuid = uuid.uuid1()
-        cc1 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
+        cc1 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
         self.assertEqual(cc1, cc2)
 
     def test_ne_name(self):
         my_uuid = uuid.uuid1()
-        cc1 = bt2.CtfWriterClock(name='mane', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
+        cc1 = bt2.CtfWriterClock(
+            name='mane',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
         self.assertNotEqual(cc1, cc2)
 
     def test_ne_description(self):
         my_uuid = uuid.uuid1()
-        cc1 = bt2.CtfWriterClock(name='name', description='some descripti2',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
+        cc1 = bt2.CtfWriterClock(
+            name='name',
+            description='some descripti2',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
         self.assertNotEqual(cc1, cc2)
 
     def test_ne_frequency(self):
         my_uuid = uuid.uuid1()
-        cc1 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1003, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
+        cc1 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1003,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
         self.assertNotEqual(cc1, cc2)
 
     def test_ne_precision(self):
         my_uuid = uuid.uuid1()
-        cc1 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=171,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
+        cc1 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=171,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
         self.assertNotEqual(cc1, cc2)
 
     def test_ne_offset(self):
         my_uuid = uuid.uuid1()
-        cc1 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3001),
-                                 is_absolute=True, uuid=my_uuid)
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
+        cc1 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3001),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
         self.assertNotEqual(cc1, cc2)
 
     def test_ne_absolute(self):
         my_uuid = uuid.uuid1()
-        cc1 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=my_uuid)
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=False, uuid=my_uuid)
+        cc1 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=my_uuid,
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=False,
+            uuid=my_uuid,
+        )
         self.assertNotEqual(cc1, cc2)
 
     def test_ne_uuid(self):
-        cc1 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=uuid.uuid1())
-        cc2 = bt2.CtfWriterClock(name='name', description='some description',
-                                 frequency=1001, precision=176,
-                                 offset=bt2.ClockClassOffset(45, 3003),
-                                 is_absolute=True, uuid=uuid.uuid1())
+        cc1 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=uuid.uuid1(),
+        )
+        cc2 = bt2.CtfWriterClock(
+            name='name',
+            description='some description',
+            frequency=1001,
+            precision=176,
+            offset=bt2.ClockClassOffset(45, 3003),
+            is_absolute=True,
+            uuid=uuid.uuid1(),
+        )
         self.assertNotEqual(cc1, cc2)
 
     def test_eq_invalid(self):
index 774150008ff3a1a3f3e1262c150f5a23edc40c7c..74fe7cff1e374d4e044fda296b5748f3dedfdbf7 100644 (file)
@@ -22,22 +22,26 @@ import bt2
 
 
 class EventTestCase(unittest.TestCase):
-    def _create_test_event_message(self, packet_fields_config=None,
-                                   event_fields_config=None,
-                                   with_clockclass=False,
-                                   with_cc=False, with_sc=False,
-                                   with_ep=False, with_packet=False):
-
+    def _create_test_event_message(
+        self,
+        packet_fields_config=None,
+        event_fields_config=None,
+        with_clockclass=False,
+        with_cc=False,
+        with_sc=False,
+        with_ep=False,
+        with_packet=False,
+    ):
         class MyIter(bt2._UserMessageIterator):
             def __init__(self, self_output_port):
                 self._at = 0
-                self._msgs = [
-                    self._create_stream_beginning_message(test_obj.stream),
-                ]
+                self._msgs = [self._create_stream_beginning_message(test_obj.stream)]
 
                 if with_packet:
                     assert test_obj.packet
-                    self._msgs.append(self._create_packet_beginning_message(test_obj.packet))
+                    self._msgs.append(
+                        self._create_packet_beginning_message(test_obj.packet)
+                    )
 
                 default_clock_snapshot = 789 if with_clockclass else None
 
@@ -48,7 +52,9 @@ class EventTestCase(unittest.TestCase):
                     assert test_obj.stream
                     ev_parent = test_obj.stream
 
-                msg = self._create_event_message(test_obj.event_class, ev_parent, default_clock_snapshot)
+                msg = self._create_event_message(
+                    test_obj.event_class, ev_parent, default_clock_snapshot
+                )
 
                 if event_fields_config is not None:
                     event_fields_config(msg.event)
@@ -96,10 +102,12 @@ class EventTestCase(unittest.TestCase):
                         ('something_else', tc.create_real_field_class()),
                     ]
 
-                stream_class = tc.create_stream_class(default_clock_class=clock_class,
-                                                      event_common_context_field_class=cc,
-                                                      packet_context_field_class=pc,
-                                                      supports_packets=with_packet)
+                stream_class = tc.create_stream_class(
+                    default_clock_class=clock_class,
+                    event_common_context_field_class=cc,
+                    packet_context_field_class=pc,
+                    supports_packets=with_packet,
+                )
 
                 # specific context (event-class-defined)
                 sc = None
@@ -120,9 +128,11 @@ class EventTestCase(unittest.TestCase):
                         ('mosquito', tc.create_signed_integer_field_class(8)),
                     ]
 
-                event_class = stream_class.create_event_class(name='garou',
-                                                              specific_context_field_class=sc,
-                                                              payload_field_class=ep)
+                event_class = stream_class.create_event_class(
+                    name='garou',
+                    specific_context_field_class=sc,
+                    payload_field_class=ep,
+                )
 
                 trace = tc()
                 stream = trace.create_stream(stream_class)
@@ -143,7 +153,9 @@ class EventTestCase(unittest.TestCase):
         test_obj = self
         self._graph = bt2.Graph()
         self._src_comp = self._graph.add_component(MySrc, 'my_source')
-        self._msg_iter = self._graph.create_output_port_message_iterator(self._src_comp.output_ports['out'])
+        self._msg_iter = self._graph.create_output_port_message_iterator(
+            self._src_comp.output_ports['out']
+        )
 
         for msg in self._msg_iter:
             if type(msg) is bt2._EventMessage:
@@ -166,7 +178,9 @@ class EventTestCase(unittest.TestCase):
             event.common_context_field['cpu_id'] = 1
             event.common_context_field['stuff'] = 13.194
 
-        msg = self._create_test_event_message(event_fields_config=event_fields_config, with_cc=True)
+        msg = self._create_test_event_message(
+            event_fields_config=event_fields_config, with_cc=True
+        )
 
         self.assertEqual(msg.event.common_context_field['cpu_id'], 1)
         self.assertEqual(msg.event.common_context_field['stuff'], 13.194)
@@ -180,7 +194,9 @@ class EventTestCase(unittest.TestCase):
             event.specific_context_field['ant'] = -1
             event.specific_context_field['msg'] = 'hellooo'
 
-        msg = self._create_test_event_message(event_fields_config=event_fields_config, with_sc=True)
+        msg = self._create_test_event_message(
+            event_fields_config=event_fields_config, with_sc=True
+        )
 
         self.assertEqual(msg.event.specific_context_field['ant'], -1)
         self.assertEqual(msg.event.specific_context_field['msg'], 'hellooo')
@@ -195,7 +211,9 @@ class EventTestCase(unittest.TestCase):
             event.payload_field['gnu'] = 23
             event.payload_field['mosquito'] = 42
 
-        msg = self._create_test_event_message(event_fields_config=event_fields_config, with_ep=True)
+        msg = self._create_test_event_message(
+            event_fields_config=event_fields_config, with_ep=True
+        )
 
         self.assertEqual(msg.event.payload_field['giraffe'], 1)
         self.assertEqual(msg.event.payload_field['gnu'], 23)
@@ -232,10 +250,14 @@ class EventTestCase(unittest.TestCase):
             packet.context_field['something'] = 154
             packet.context_field['something_else'] = 17.2
 
-        msg = self._create_test_event_message(packet_fields_config=packet_fields_config,
-                                              event_fields_config=event_fields_config,
-                                              with_cc=True, with_sc=True, with_ep=True,
-                                              with_packet=True)
+        msg = self._create_test_event_message(
+            packet_fields_config=packet_fields_config,
+            event_fields_config=event_fields_config,
+            with_cc=True,
+            with_sc=True,
+            with_ep=True,
+            with_packet=True,
+        )
         ev = msg.event
 
         # Test event fields
index beab05cb95096febe7a95bd29692d9fa0c51c8c0..10d58a7fd03852005e77493c488ac41e3f614662 100644 (file)
@@ -27,12 +27,16 @@ class EventClassTestCase(unittest.TestCase):
 
         self._context_fc = self._tc.create_structure_field_class()
         self._context_fc.append_member('allo', self._tc.create_string_field_class())
-        self._context_fc.append_member('zola', self._tc.create_signed_integer_field_class(18))
+        self._context_fc.append_member(
+            'zola', self._tc.create_signed_integer_field_class(18)
+        )
 
         self._payload_fc = self._tc.create_structure_field_class()
         self._payload_fc.append_member('zoom', self._tc.create_string_field_class())
 
-        self._stream_class = self._tc.create_stream_class(assigns_automatic_event_class_id=True)
+        self._stream_class = self._tc.create_stream_class(
+            assigns_automatic_event_class_id=True
+        )
 
     def test_create_default(self):
         ec = self._stream_class.create_event_class()
@@ -84,7 +88,9 @@ class EventClassTestCase(unittest.TestCase):
             self._stream_class.create_event_class(emf_uri=23)
 
     def test_create_log_level(self):
-        ec = self._stream_class.create_event_class(log_level=bt2.EventClassLogLevel.EMERGENCY)
+        ec = self._stream_class.create_event_class(
+            log_level=bt2.EventClassLogLevel.EMERGENCY
+        )
         self.assertEqual(ec.log_level, bt2.EventClassLogLevel.EMERGENCY)
 
     def test_create_invalid_log_level(self):
index f92142bc13518b3f5c8e18fc0ce4c24b8f1fee96..b17c175bca363c5b624e7a24286abf2e26f9f6fd 100644 (file)
@@ -27,10 +27,7 @@ import bt2
 from utils import get_default_trace_class
 
 
-_COMP_BINOPS = (
-    operator.eq,
-    operator.ne,
-)
+_COMP_BINOPS = (operator.eq, operator.ne)
 
 
 # Create and return a stream with the field classes part of its stream packet
@@ -38,14 +35,16 @@ _COMP_BINOPS = (
 #
 # The stream is part of a dummy trace created from trace class `tc`.
 
+
 def _create_stream(tc, ctx_field_classes):
     packet_context_fc = tc.create_structure_field_class()
     for name, fc in ctx_field_classes:
         packet_context_fc.append_member(name, fc)
 
     trace = tc()
-    stream_class = tc.create_stream_class(packet_context_field_class=packet_context_fc,
-                                          supports_packets=True)
+    stream_class = tc.create_stream_class(
+        packet_context_field_class=packet_context_fc, supports_packets=True
+    )
 
     stream = trace.create_stream(stream_class)
     return stream
@@ -56,6 +55,7 @@ def _create_stream(tc, ctx_field_classes):
 # The field is part of a dummy stream, itself part of a dummy trace created
 # from trace class `tc`.
 
+
 def _create_field(tc, field_class):
     field_name = 'field'
     stream = _create_stream(tc, [(field_name, field_class)])
@@ -68,6 +68,7 @@ def _create_field(tc, field_class):
 # The field is part of a dummy stream, itself part of a dummy trace created
 # from trace class `tc`.  It is made out of a dummy string field class.
 
+
 def _create_string_field(tc):
     field_name = 'string_field'
     stream = _create_stream(tc, [(field_name, tc.create_string_field_class())])
@@ -81,6 +82,7 @@ def _create_string_field(tc):
 # from trace class `tc`.  It is made out of a dummy static array field class,
 # with a dummy integer field class as element class.
 
+
 def _create_int_array_field(tc, length):
     elem_fc = tc.create_signed_integer_field_class(32)
     fc = tc.create_static_array_field_class(elem_fc, length)
@@ -96,6 +98,7 @@ def _create_int_array_field(tc, length):
 # from trace class `tc`.  It is made out of a dummy static array field class,
 # with a dummy integer field class as element and length classes.
 
+
 def _create_dynamic_array(tc):
     elem_fc = tc.create_signed_integer_field_class(32)
     len_fc = tc.create_signed_integer_field_class(32)
@@ -113,6 +116,7 @@ def _create_dynamic_array(tc):
 # from trace class `tc`.  It is made out of a dummy static array field class,
 # with a dummy struct field class as element class.
 
+
 def _create_struct_array_field(tc, length):
     elem_fc = tc.create_structure_field_class()
     fc = tc.create_static_array_field_class(elem_fc, length)
@@ -354,7 +358,7 @@ class _TestNumericField:
         test_cb(op, bt2.create_value(0.0))
 
     def _test_binop_rhs_complex(self, test_cb, op):
-        test_cb(op, -23+19j)
+        test_cb(op, -23 + 19j)
 
     def _test_binop_rhs_zero_complex(self, test_cb, op):
         test_cb(op, 0j)
@@ -570,13 +574,13 @@ class _TestNumericField:
         # Ignore this lint error:
         #   E711 comparison to None should be 'if cond is None:'
         # since this is what we want to test (even though not good practice).
-        self.assertFalse(self._def == None) # noqa: E711
+        self.assertFalse(self._def == None)  # noqa: E711
 
     def test_ne_none(self):
         # Ignore this lint error:
         #   E711 comparison to None should be 'if cond is not None:'
         # since this is what we want to test (even though not good practice).
-        self.assertTrue(self._def != None) # noqa: E711
+        self.assertTrue(self._def != None)  # noqa: E711
 
 
 # This is a list of binary operators used for
@@ -662,79 +666,415 @@ def _inject_numeric_testing_methods(cls):
 
     # inject testing methods for each binary operation
     for name, binop in _BINOPS:
-        setattr(cls, test_binop_name('invalid_unknown'), partialmethod(_TestNumericField._test_binop_invalid_unknown, op=binop))
-        setattr(cls, test_binop_name('invalid_none'), partialmethod(_TestNumericField._test_binop_invalid_none, op=binop))
-        setattr(cls, test_binop_name('type_true'), partialmethod(_TestNumericField._test_binop_type_true, op=binop))
-        setattr(cls, test_binop_name('type_pos_int'), partialmethod(_TestNumericField._test_binop_type_pos_int, op=binop))
-        setattr(cls, test_binop_name('type_pos_vint'), partialmethod(_TestNumericField._test_binop_type_pos_vint, op=binop))
-        setattr(cls, test_binop_name('value_true'), partialmethod(_TestNumericField._test_binop_value_true, op=binop))
-        setattr(cls, test_binop_name('value_pos_int'), partialmethod(_TestNumericField._test_binop_value_pos_int, op=binop))
-        setattr(cls, test_binop_name('value_pos_vint'), partialmethod(_TestNumericField._test_binop_value_pos_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_true'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_true, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_int'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_pos_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_vint'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_pos_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_true'), partialmethod(_TestNumericField._test_binop_lhs_value_same_true, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_int'), partialmethod(_TestNumericField._test_binop_lhs_value_same_pos_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_vint'), partialmethod(_TestNumericField._test_binop_lhs_value_same_pos_vint, op=binop))
-        setattr(cls, test_binop_name('type_neg_int'), partialmethod(_TestNumericField._test_binop_type_neg_int, op=binop))
-        setattr(cls, test_binop_name('type_neg_vint'), partialmethod(_TestNumericField._test_binop_type_neg_vint, op=binop))
-        setattr(cls, test_binop_name('value_neg_int'), partialmethod(_TestNumericField._test_binop_value_neg_int, op=binop))
-        setattr(cls, test_binop_name('value_neg_vint'), partialmethod(_TestNumericField._test_binop_value_neg_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_int'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_neg_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_vint'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_neg_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_int'), partialmethod(_TestNumericField._test_binop_lhs_value_same_neg_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_vint'), partialmethod(_TestNumericField._test_binop_lhs_value_same_neg_vint, op=binop))
-        setattr(cls, test_binop_name('type_false'), partialmethod(_TestNumericField._test_binop_type_false, op=binop))
-        setattr(cls, test_binop_name('type_zero_int'), partialmethod(_TestNumericField._test_binop_type_zero_int, op=binop))
-        setattr(cls, test_binop_name('type_zero_vint'), partialmethod(_TestNumericField._test_binop_type_zero_vint, op=binop))
-        setattr(cls, test_binop_name('value_false'), partialmethod(_TestNumericField._test_binop_value_false, op=binop))
-        setattr(cls, test_binop_name('value_zero_int'), partialmethod(_TestNumericField._test_binop_value_zero_int, op=binop))
-        setattr(cls, test_binop_name('value_zero_vint'), partialmethod(_TestNumericField._test_binop_value_zero_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_false'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_false, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_int'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_zero_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_vint'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_zero_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_false'), partialmethod(_TestNumericField._test_binop_lhs_value_same_false, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_int'), partialmethod(_TestNumericField._test_binop_lhs_value_same_zero_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_vint'), partialmethod(_TestNumericField._test_binop_lhs_value_same_zero_vint, op=binop))
-        setattr(cls, test_binop_name('type_pos_float'), partialmethod(_TestNumericField._test_binop_type_pos_float, op=binop))
-        setattr(cls, test_binop_name('type_neg_float'), partialmethod(_TestNumericField._test_binop_type_neg_float, op=binop))
-        setattr(cls, test_binop_name('type_pos_vfloat'), partialmethod(_TestNumericField._test_binop_type_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_neg_vfloat'), partialmethod(_TestNumericField._test_binop_type_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_pos_float'), partialmethod(_TestNumericField._test_binop_value_pos_float, op=binop))
-        setattr(cls, test_binop_name('value_neg_float'), partialmethod(_TestNumericField._test_binop_value_neg_float, op=binop))
-        setattr(cls, test_binop_name('value_pos_vfloat'), partialmethod(_TestNumericField._test_binop_value_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_neg_vfloat'), partialmethod(_TestNumericField._test_binop_value_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_float'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_float'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_neg_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_vfloat'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_vfloat'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_float'), partialmethod(_TestNumericField._test_binop_lhs_value_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_float'), partialmethod(_TestNumericField._test_binop_lhs_value_same_neg_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_vfloat'), partialmethod(_TestNumericField._test_binop_lhs_value_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_vfloat'), partialmethod(_TestNumericField._test_binop_lhs_value_same_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_zero_float'), partialmethod(_TestNumericField._test_binop_type_zero_float, op=binop))
-        setattr(cls, test_binop_name('type_zero_vfloat'), partialmethod(_TestNumericField._test_binop_type_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_zero_float'), partialmethod(_TestNumericField._test_binop_value_zero_float, op=binop))
-        setattr(cls, test_binop_name('value_zero_vfloat'), partialmethod(_TestNumericField._test_binop_value_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_float'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_zero_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_vfloat'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_float'), partialmethod(_TestNumericField._test_binop_lhs_value_same_zero_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_vfloat'), partialmethod(_TestNumericField._test_binop_lhs_value_same_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_complex'), partialmethod(_TestNumericField._test_binop_type_complex, op=binop))
-        setattr(cls, test_binop_name('type_zero_complex'), partialmethod(_TestNumericField._test_binop_type_zero_complex, op=binop))
-        setattr(cls, test_binop_name('value_complex'), partialmethod(_TestNumericField._test_binop_value_complex, op=binop))
-        setattr(cls, test_binop_name('value_zero_complex'), partialmethod(_TestNumericField._test_binop_value_zero_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_complex'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_complex'), partialmethod(_TestNumericField._test_binop_lhs_addr_same_zero_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_complex'), partialmethod(_TestNumericField._test_binop_lhs_value_same_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_complex'), partialmethod(_TestNumericField._test_binop_lhs_value_same_zero_complex, op=binop))
+        setattr(
+            cls,
+            test_binop_name('invalid_unknown'),
+            partialmethod(_TestNumericField._test_binop_invalid_unknown, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('invalid_none'),
+            partialmethod(_TestNumericField._test_binop_invalid_none, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_true'),
+            partialmethod(_TestNumericField._test_binop_type_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_int'),
+            partialmethod(_TestNumericField._test_binop_type_pos_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_vint'),
+            partialmethod(_TestNumericField._test_binop_type_pos_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_true'),
+            partialmethod(_TestNumericField._test_binop_value_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_int'),
+            partialmethod(_TestNumericField._test_binop_value_pos_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_vint'),
+            partialmethod(_TestNumericField._test_binop_value_pos_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_true'),
+            partialmethod(_TestNumericField._test_binop_lhs_addr_same_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_int'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_pos_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_vint'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_pos_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_true'),
+            partialmethod(_TestNumericField._test_binop_lhs_value_same_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_int'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_pos_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_vint'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_pos_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_int'),
+            partialmethod(_TestNumericField._test_binop_type_neg_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_vint'),
+            partialmethod(_TestNumericField._test_binop_type_neg_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_int'),
+            partialmethod(_TestNumericField._test_binop_value_neg_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_vint'),
+            partialmethod(_TestNumericField._test_binop_value_neg_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_int'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_neg_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_vint'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_neg_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_int'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_neg_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_vint'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_neg_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_false'),
+            partialmethod(_TestNumericField._test_binop_type_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_int'),
+            partialmethod(_TestNumericField._test_binop_type_zero_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_vint'),
+            partialmethod(_TestNumericField._test_binop_type_zero_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_false'),
+            partialmethod(_TestNumericField._test_binop_value_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_int'),
+            partialmethod(_TestNumericField._test_binop_value_zero_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_vint'),
+            partialmethod(_TestNumericField._test_binop_value_zero_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_false'),
+            partialmethod(_TestNumericField._test_binop_lhs_addr_same_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_int'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_zero_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_vint'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_zero_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_false'),
+            partialmethod(_TestNumericField._test_binop_lhs_value_same_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_int'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_zero_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_vint'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_zero_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_float'),
+            partialmethod(_TestNumericField._test_binop_type_pos_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_float'),
+            partialmethod(_TestNumericField._test_binop_type_neg_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_vfloat'),
+            partialmethod(_TestNumericField._test_binop_type_pos_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_vfloat'),
+            partialmethod(_TestNumericField._test_binop_type_neg_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_float'),
+            partialmethod(_TestNumericField._test_binop_value_pos_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_float'),
+            partialmethod(_TestNumericField._test_binop_value_neg_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_vfloat'),
+            partialmethod(_TestNumericField._test_binop_value_pos_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_vfloat'),
+            partialmethod(_TestNumericField._test_binop_value_neg_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_float'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_pos_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_float'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_neg_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_vfloat'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_pos_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_vfloat'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_neg_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_float'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_pos_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_float'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_neg_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_vfloat'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_pos_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_vfloat'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_neg_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_float'),
+            partialmethod(_TestNumericField._test_binop_type_zero_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_vfloat'),
+            partialmethod(_TestNumericField._test_binop_type_zero_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_float'),
+            partialmethod(_TestNumericField._test_binop_value_zero_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_vfloat'),
+            partialmethod(_TestNumericField._test_binop_value_zero_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_float'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_zero_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_vfloat'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_zero_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_float'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_zero_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_vfloat'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_zero_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_complex'),
+            partialmethod(_TestNumericField._test_binop_type_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_complex'),
+            partialmethod(_TestNumericField._test_binop_type_zero_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_complex'),
+            partialmethod(_TestNumericField._test_binop_value_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_complex'),
+            partialmethod(_TestNumericField._test_binop_value_zero_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_complex'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_complex'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_addr_same_zero_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_complex'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_complex'),
+            partialmethod(
+                _TestNumericField._test_binop_lhs_value_same_zero_complex, op=binop
+            ),
+        )
 
     # inject testing methods for each unary operation
     for name, unaryop in _UNARYOPS:
-        setattr(cls, test_unaryop_name('type'), partialmethod(_TestNumericField._test_unaryop_type, op=unaryop))
-        setattr(cls, test_unaryop_name('value'), partialmethod(_TestNumericField._test_unaryop_value, op=unaryop))
-        setattr(cls, test_unaryop_name('addr_same'), partialmethod(_TestNumericField._test_unaryop_addr_same, op=unaryop))
-        setattr(cls, test_unaryop_name('value_same'), partialmethod(_TestNumericField._test_unaryop_value_same, op=unaryop))
+        setattr(
+            cls,
+            test_unaryop_name('type'),
+            partialmethod(_TestNumericField._test_unaryop_type, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name('value'),
+            partialmethod(_TestNumericField._test_unaryop_value, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name('addr_same'),
+            partialmethod(_TestNumericField._test_unaryop_addr_same, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name('value_same'),
+            partialmethod(_TestNumericField._test_unaryop_value_same, op=unaryop),
+        )
 
 
 class _TestIntegerFieldCommon(_TestNumericField):
@@ -781,8 +1121,8 @@ class _TestIntegerFieldCommon(_TestNumericField):
         field = _create_field(self._tc, uint_fc)
         # Larger than the IEEE 754 double-precision exact representation of
         # integers.
-        raw = (2**53) + 1
-        field.value = (2**53) + 1
+        raw = (2 ** 53) + 1
+        field.value = (2 ** 53) + 1
         self.assertEqual(field, raw)
 
     def test_assign_uint_invalid_neg(self):
@@ -819,7 +1159,9 @@ class SignedEnumerationFieldTestCase(_TestIntegerFieldCommon, unittest.TestCase)
         fc.add_mapping('something', bt2.SignedIntegerRangeSet([(17, 17)]))
         fc.add_mapping('speaker', bt2.SignedIntegerRangeSet([(12, 16)]))
         fc.add_mapping('can', bt2.SignedIntegerRangeSet([(18, 2540)]))
-        fc.add_mapping('whole range', bt2.SignedIntegerRangeSet([(-(2 ** 31), (2 ** 31) - 1)]))
+        fc.add_mapping(
+            'whole range', bt2.SignedIntegerRangeSet([(-(2 ** 31), (2 ** 31) - 1)])
+        )
         fc.add_mapping('zip', bt2.SignedIntegerRangeSet([(-45, 1001)]))
         return fc
 
@@ -838,8 +1180,7 @@ class SignedEnumerationFieldTestCase(_TestIntegerFieldCommon, unittest.TestCase)
         # Establish all permutations of the three expected matches since
         # the order in which mappings are enumerated is not explicitly part of
         # the API.
-        for p in itertools.permutations(['whole range', 'something',
-                                         'zip']):
+        for p in itertools.permutations(['whole range', 'something', 'zip']):
             candidate = '{} ({})'.format(self._def_value, ', '.join(p))
             if candidate == s:
                 expected_string_found = True
@@ -1147,21 +1488,9 @@ class _TestArrayFieldCommon:
         array_fc = self._tc.create_static_array_field_class(struct_fc, 3)
         stream = _create_stream(self._tc, [('array_field', array_fc)])
         values = [
-            {
-                'an_int': 42,
-                'a_string': 'hello',
-                'another_int': 66
-            },
-            {
-                'an_int': 1,
-                'a_string': 'goodbye',
-                'another_int': 488
-            },
-            {
-                'an_int': 156,
-                'a_string': 'or not',
-                'another_int': 4648
-            },
+            {'an_int': 42, 'a_string': 'hello', 'another_int': 66},
+            {'an_int': 1, 'a_string': 'goodbye', 'another_int': 488},
+            {'an_int': 156, 'a_string': 'or not', 'another_int': 4648},
         ]
 
         array = stream.create_packet().context_field['array_field']
@@ -1173,8 +1502,7 @@ class _TestArrayFieldCommon:
 
     def test_str_op(self):
         s = str(self._def)
-        expected_string = '[{}]'.format(', '.join(
-            [repr(v) for v in self._def_value]))
+        expected_string = '[{}]'.format(', '.join([repr(v) for v in self._def_value]))
         self.assertEqual(expected_string, s)
 
 
@@ -1254,7 +1582,7 @@ class StructureFieldTestCase(unittest.TestCase):
             'C': 17.5,
             'D': 16497,
             'E': {},
-            'F': {'F_1': 52}
+            'F': {'F_1': 52},
         }
 
     def _modify_def(self):
@@ -1280,7 +1608,7 @@ class StructureFieldTestCase(unittest.TestCase):
             self._def.member_at_index(len(self._def_value))
 
     def test_eq(self):
-        field = _create_field(self._tc, self._create_fc(self._tc))
+        field = _create_field(self._tc, self._create_fc(self._tc))
         field['A'] = -1872
         field['B'] = 'salut'
         field['C'] = 17.5
@@ -1391,7 +1719,7 @@ class StructureFieldTestCase(unittest.TestCase):
             'C': 17.5,
             'D': 16497,
             'E': {},
-            'F': {'F_1': 52}
+            'F': {'F_1': 52},
         }
 
         for vkey, vval in self._def.items():
@@ -1405,7 +1733,7 @@ class StructureFieldTestCase(unittest.TestCase):
             'C': 17.5,
             'D': 16497,
             'E': {},
-            'F': {'F_1': 52}
+            'F': {'F_1': 52},
         }
         self.assertEqual(self._def, orig_values)
 
@@ -1417,11 +1745,7 @@ class StructureFieldTestCase(unittest.TestCase):
         struct_fc.append_member(field_class=int_fc, name='an_int')
         struct_fc.append_member(field_class=str_fc, name='a_string')
         struct_fc.append_member(field_class=another_int_fc, name='another_int')
-        values = {
-            'an_int': 42,
-            'a_string': 'hello',
-            'another_int': 66
-        }
+        values = {'an_int': 42, 'a_string': 'hello', 'another_int': 66}
 
         struct = _create_field(self._tc, struct_fc)
         struct.value = values
index 09303363698e2f66b772c1f64bcc3315c066a845..2b05f0096cfab2bc8213d98834c6bc2033e0b377 100644 (file)
@@ -50,7 +50,9 @@ class _TestIntegerFieldClassProps:
             self._create_func(field_value_range=0)
 
     def test_create_base(self):
-        fc = self._create_func(preferred_display_base=bt2.IntegerDisplayBase.HEXADECIMAL)
+        fc = self._create_func(
+            preferred_display_base=bt2.IntegerDisplayBase.HEXADECIMAL
+        )
         self.assertEqual(fc.preferred_display_base, bt2.IntegerDisplayBase.HEXADECIMAL)
 
     def test_create_invalid_base_type(self):
@@ -94,6 +96,7 @@ class RealFieldClassTestCase(unittest.TestCase):
 #
 #    [(lower0, upper0), (lower1, upper1), ...]
 
+
 def enum_mapping_to_set(mapping):
     return {(x.lower, x.upper) for x in mapping.ranges}
 
@@ -140,10 +143,7 @@ class _EnumerationFieldClassTestCase(_TestIntegerFieldClassProps):
     def test_iadd(self):
         self._fc.add_mapping('c', self._ranges1)
 
-        self._fc += [
-            ('d', self._ranges2),
-            ('e', self._ranges3),
-        ]
+        self._fc += [('d', self._ranges2), ('e', self._ranges3)]
 
         self.assertEqual(len(self._fc), 3)
         self.assertEqual(self._fc['c'].label, 'c')
@@ -196,7 +196,9 @@ class _EnumerationFieldClassTestCase(_TestIntegerFieldClassProps):
         self.assertEqual(labels, expected_labels)
 
 
-class UnsignedEnumerationFieldClassTestCase(_EnumerationFieldClassTestCase, unittest.TestCase):
+class UnsignedEnumerationFieldClassTestCase(
+    _EnumerationFieldClassTestCase, unittest.TestCase
+):
     def _spec_set_up(self):
         self._ranges1 = bt2.UnsignedIntegerRangeSet([(1, 4), (18, 47)])
         self._ranges2 = bt2.UnsignedIntegerRangeSet([(5, 5)])
@@ -206,7 +208,9 @@ class UnsignedEnumerationFieldClassTestCase(_EnumerationFieldClassTestCase, unit
         self._create_func = self._tc.create_unsigned_enumeration_field_class
 
 
-class SignedEnumerationFieldClassTestCase(_EnumerationFieldClassTestCase, unittest.TestCase):
+class SignedEnumerationFieldClassTestCase(
+    _EnumerationFieldClassTestCase, unittest.TestCase
+):
     def _spec_set_up(self):
         self._ranges1 = bt2.SignedIntegerRangeSet([(-10, -4), (18, 47)])
         self._ranges2 = bt2.SignedIntegerRangeSet([(-3, -3)])
@@ -225,7 +229,7 @@ class StringFieldClassTestCase(unittest.TestCase):
         self.assertIsNotNone(self._fc)
 
 
-class _TestElementContainer():
+class _TestElementContainer:
     def setUp(self):
         self._tc = get_default_trace_class()
         self._fc = self._create_default_fc()
@@ -270,7 +274,9 @@ class _TestElementContainer():
         self._append_element_method(self._fc, 'a_float', a_field_class)
         self._append_element_method(self._fc, 'b_int', b_field_class)
         c_field_class = self._tc.create_string_field_class()
-        d_field_class = self._tc.create_signed_enumeration_field_class(field_value_range=32)
+        d_field_class = self._tc.create_signed_enumeration_field_class(
+            field_value_range=32
+        )
         e_field_class = self._tc.create_structure_field_class()
         self._fc += [
             ('c_string', c_field_class),
@@ -326,11 +332,7 @@ class _TestElementContainer():
         a_fc = self._tc.create_signed_integer_field_class(32)
         b_fc = self._tc.create_string_field_class()
         c_fc = self._tc.create_real_field_class()
-        elements = (
-            ('a', a_fc),
-            ('b', b_fc),
-            ('c', c_fc),
-        )
+        elements = (('a', a_fc), ('b', b_fc), ('c', c_fc))
 
         for elem in elements:
             self._append_element_method(self._fc, *elem)
@@ -352,29 +354,43 @@ class _TestElementContainer():
         self.assertEqual(elem.name, 'a')
 
     def test_at_index_invalid(self):
-        self._append_element_method(self._fc, 'c', self._tc.create_signed_integer_field_class(32))
+        self._append_element_method(
+            self._fc, 'c', self._tc.create_signed_integer_field_class(32)
+        )
 
         with self.assertRaises(TypeError):
             self._at_index_method(self._fc, 'yes')
 
     def test_at_index_out_of_bounds_after(self):
-        self._append_element_method(self._fc, 'c', self._tc.create_signed_integer_field_class(32))
+        self._append_element_method(
+            self._fc, 'c', self._tc.create_signed_integer_field_class(32)
+        )
 
         with self.assertRaises(IndexError):
             self._at_index_method(self._fc, len(self._fc))
 
 
 class StructureFieldClassTestCase(_TestElementContainer, unittest.TestCase):
-    _append_element_method = staticmethod(bt2.field_class._StructureFieldClass.append_member)
-    _at_index_method = staticmethod(bt2.field_class._StructureFieldClass.member_at_index)
+    _append_element_method = staticmethod(
+        bt2.field_class._StructureFieldClass.append_member
+    )
+    _at_index_method = staticmethod(
+        bt2.field_class._StructureFieldClass.member_at_index
+    )
 
     def _create_default_fc(self):
         return self._tc.create_structure_field_class()
 
 
-class VariantFieldClassWithoutSelectorTestCase(_TestElementContainer, unittest.TestCase):
-    _append_element_method = staticmethod(bt2.field_class._VariantFieldClassWithoutSelector.append_option)
-    _at_index_method = staticmethod(bt2.field_class._VariantFieldClassWithoutSelector.option_at_index)
+class VariantFieldClassWithoutSelectorTestCase(
+    _TestElementContainer, unittest.TestCase
+):
+    _append_element_method = staticmethod(
+        bt2.field_class._VariantFieldClassWithoutSelector.append_option
+    )
+    _at_index_method = staticmethod(
+        bt2.field_class._VariantFieldClassWithoutSelector.option_at_index
+    )
 
     def _create_default_fc(self):
         return self._tc.create_variant_field_class()
@@ -402,8 +418,9 @@ class _VariantFieldClassWithSelectorTestCase:
 
     def test_append_element_kwargs(self):
         int_field_class = self._tc.create_signed_integer_field_class(32)
-        self._fc.append_option(name='int32', field_class=int_field_class,
-                               ranges=self._ranges1)
+        self._fc.append_option(
+            name='int32', field_class=int_field_class, ranges=self._ranges1
+        )
         opt = self._fc['int32']
         self.assertEqual(opt.field_class.addr, int_field_class.addr)
         self.assertEqual(opt.name, 'int32')
@@ -444,7 +461,9 @@ class _VariantFieldClassWithSelectorTestCase:
         a_field_class = self._tc.create_real_field_class()
         self._fc.append_option('a_float', a_field_class, self._ranges1)
         c_field_class = self._tc.create_string_field_class()
-        d_field_class = self._tc.create_signed_enumeration_field_class(field_value_range=32)
+        d_field_class = self._tc.create_signed_enumeration_field_class(
+            field_value_range=32
+        )
         self._fc += [
             ('c_string', c_field_class, self._ranges2),
             ('d_enum', d_field_class, self._ranges3),
@@ -525,13 +544,17 @@ class _VariantFieldClassWithSelectorTestCase:
         self.assertEqual(self._fc.option_at_index(1).ranges.addr, self._ranges2.addr)
 
     def test_at_index_invalid(self):
-        self._fc.append_option('c', self._tc.create_signed_integer_field_class(32), self._ranges3)
+        self._fc.append_option(
+            'c', self._tc.create_signed_integer_field_class(32), self._ranges3
+        )
 
         with self.assertRaises(TypeError):
             self._fc.option_at_index('yes')
 
     def test_at_index_out_of_bounds_after(self):
-        self._fc.append_option('c', self._tc.create_signed_integer_field_class(32), self._ranges3)
+        self._fc.append_option(
+            'c', self._tc.create_signed_integer_field_class(32), self._ranges3
+        )
 
         with self.assertRaises(IndexError):
             self._fc.option_at_index(len(self._fc))
@@ -553,8 +576,12 @@ class _VariantFieldClassWithSelectorTestCase:
         #   } inner_struct[2];
         # };
         self._fc.append_option('a', self._tc.create_real_field_class(), self._ranges1)
-        self._fc.append_option('b', self._tc.create_signed_integer_field_class(21), self._ranges2)
-        self._fc.append_option('c', self._tc.create_unsigned_integer_field_class(34), self._ranges3)
+        self._fc.append_option(
+            'b', self._tc.create_signed_integer_field_class(21), self._ranges2
+        )
+        self._fc.append_option(
+            'c', self._tc.create_unsigned_integer_field_class(34), self._ranges3
+        )
 
         foo_fc = self._tc.create_real_field_class()
         bar_fc = self._tc.create_string_field_class()
@@ -566,7 +593,9 @@ class _VariantFieldClassWithSelectorTestCase:
         inner_struct_fc.append_member('baz', baz_fc)
         inner_struct_fc.append_member('variant', self._fc)
 
-        inner_struct_array_fc = self._tc.create_static_array_field_class(inner_struct_fc, 2)
+        inner_struct_array_fc = self._tc.create_static_array_field_class(
+            inner_struct_fc, 2
+        )
 
         outer_struct_fc = self._tc.create_structure_field_class()
         outer_struct_fc.append_member('foo', foo_fc)
@@ -574,8 +603,9 @@ class _VariantFieldClassWithSelectorTestCase:
 
         # The path to the selector field is resolved when the sequence is
         # actually used, for example in a packet context.
-        self._tc.create_stream_class(supports_packets=True,
-                                     packet_context_field_class=outer_struct_fc)
+        self._tc.create_stream_class(
+            supports_packets=True, packet_context_field_class=outer_struct_fc
+        )
 
     def test_selector_field_path_length(self):
         self._fill_default_fc_for_field_path_test()
@@ -590,17 +620,23 @@ class _VariantFieldClassWithSelectorTestCase:
         self.assertIsInstance(path_items[0], bt2.field_path._IndexFieldPathItem)
         self.assertEqual(path_items[0].index, 1)
 
-        self.assertIsInstance(path_items[1], bt2.field_path._CurrentArrayElementFieldPathItem)
+        self.assertIsInstance(
+            path_items[1], bt2.field_path._CurrentArrayElementFieldPathItem
+        )
 
         self.assertIsInstance(path_items[2], bt2.field_path._IndexFieldPathItem)
         self.assertEqual(path_items[2].index, 0)
 
     def test_selector_field_path_root_scope(self):
         self._fill_default_fc_for_field_path_test()
-        self.assertEqual(self._fc.selector_field_path.root_scope, bt2.field_path.Scope.PACKET_CONTEXT)
+        self.assertEqual(
+            self._fc.selector_field_path.root_scope, bt2.field_path.Scope.PACKET_CONTEXT
+        )
 
 
-class VariantFieldClassWithUnsignedSelectorTestCase(_VariantFieldClassWithSelectorTestCase, unittest.TestCase):
+class VariantFieldClassWithUnsignedSelectorTestCase(
+    _VariantFieldClassWithSelectorTestCase, unittest.TestCase
+):
     def _spec_set_up(self):
         self._ranges1 = bt2.UnsignedIntegerRangeSet([(1, 4), (18, 47)])
         self._ranges2 = bt2.UnsignedIntegerRangeSet([(5, 5)])
@@ -609,7 +645,9 @@ class VariantFieldClassWithUnsignedSelectorTestCase(_VariantFieldClassWithSelect
         self._selector_fc = self._tc.create_unsigned_integer_field_class()
 
 
-class VariantFieldClassWithSignedSelectorTestCase(_VariantFieldClassWithSelectorTestCase, unittest.TestCase):
+class VariantFieldClassWithSignedSelectorTestCase(
+    _VariantFieldClassWithSelectorTestCase, unittest.TestCase
+):
     def _spec_set_up(self):
         self._ranges1 = bt2.SignedIntegerRangeSet([(-10, -4), (18, 47)])
         self._ranges2 = bt2.SignedIntegerRangeSet([(-3, -3)])
@@ -634,11 +672,15 @@ class StaticArrayFieldClassTestCase(unittest.TestCase):
 
     def test_create_invalid_length(self):
         with self.assertRaises(ValueError):
-            self._tc.create_static_array_field_class(self._tc.create_string_field_class(), -17)
+            self._tc.create_static_array_field_class(
+                self._tc.create_string_field_class(), -17
+            )
 
     def test_create_invalid_length_type(self):
         with self.assertRaises(TypeError):
-            self._tc.create_static_array_field_class(self._tc.create_string_field_class(), 'the length')
+            self._tc.create_static_array_field_class(
+                self._tc.create_string_field_class(), 'the length'
+            )
 
 
 class DynamicArrayFieldClassTestCase(unittest.TestCase):
@@ -677,7 +719,9 @@ class DynamicArrayFieldClassTestCase(unittest.TestCase):
         inner_struct_fc.append_member('len', self._len_fc)
         inner_struct_fc.append_member('dyn_array', fc)
 
-        inner_struct_array_fc = self._tc.create_static_array_field_class(inner_struct_fc, 2)
+        inner_struct_array_fc = self._tc.create_static_array_field_class(
+            inner_struct_fc, 2
+        )
 
         outer_struct_fc = self._tc.create_structure_field_class()
         outer_struct_fc.append_member('foo', foo_fc)
@@ -685,8 +729,9 @@ class DynamicArrayFieldClassTestCase(unittest.TestCase):
 
         # The path to the length field is resolved when the sequence is
         # actually used, for example in a packet context.
-        self._tc.create_stream_class(packet_context_field_class=outer_struct_fc,
-                                     supports_packets=True)
+        self._tc.create_stream_class(
+            packet_context_field_class=outer_struct_fc, supports_packets=True
+        )
 
         return fc
 
@@ -703,14 +748,18 @@ class DynamicArrayFieldClassTestCase(unittest.TestCase):
         self.assertIsInstance(path_items[0], bt2.field_path._IndexFieldPathItem)
         self.assertEqual(path_items[0].index, 1)
 
-        self.assertIsInstance(path_items[1], bt2.field_path._CurrentArrayElementFieldPathItem)
+        self.assertIsInstance(
+            path_items[1], bt2.field_path._CurrentArrayElementFieldPathItem
+        )
 
         self.assertIsInstance(path_items[2], bt2.field_path._IndexFieldPathItem)
         self.assertEqual(path_items[2].index, 2)
 
     def test_field_path_root_scope(self):
         fc = self._create_field_class_for_field_path_test()
-        self.assertEqual(fc.length_field_path.root_scope, bt2.field_path.Scope.PACKET_CONTEXT)
+        self.assertEqual(
+            fc.length_field_path.root_scope, bt2.field_path.Scope.PACKET_CONTEXT
+        )
 
     def test_create_invalid_field_class(self):
         with self.assertRaises(TypeError):
@@ -718,7 +767,9 @@ class DynamicArrayFieldClassTestCase(unittest.TestCase):
 
     def test_create_invalid_length_type(self):
         with self.assertRaises(TypeError):
-            self._tc.create_dynamic_array_field_class(self._tc.create_string_field_class(), 17)
+            self._tc.create_dynamic_array_field_class(
+                self._tc.create_string_field_class(), 17
+            )
 
 
 if __name__ == "__main__":
index da9c209ff68e44b76c7896df01321e127fdb0821..1c183c9bf1861be1103c1e56b41fabd3840d7b0b 100644 (file)
@@ -35,9 +35,7 @@ class _MyIter(bt2._UserMessageIterator):
         self._ec = self._sc.create_event_class(name='salut')
         self._my_int_ft = self._tc.create_signed_integer_field_class(32)
         payload_ft = self._tc.create_structure_field_class()
-        payload_ft += [
-            ('my_int', self._my_int_ft),
-        ]
+        payload_ft += [('my_int', self._my_int_ft)]
         self._ec.payload_field_type = payload_ft
         self._stream = self._t.create_stream(self._sc)
         self._packet = self._stream.create_packet()
@@ -63,6 +61,7 @@ class GraphTestCase(unittest.TestCase):
         class MySink(bt2._UserSinkComponent):
             def _consume(self):
                 pass
+
             def _graph_is_configured(self):
                 pass
 
@@ -73,6 +72,7 @@ class GraphTestCase(unittest.TestCase):
         class MySink(bt2._UserSinkComponent):
             def _consume(self):
                 pass
+
             def _graph_is_configured(self):
                 pass
 
@@ -91,6 +91,7 @@ class GraphTestCase(unittest.TestCase):
 
             def _consume(self):
                 pass
+
             def _graph_is_configured(self):
                 pass
 
@@ -107,6 +108,7 @@ class GraphTestCase(unittest.TestCase):
         class MySink(bt2._UserSinkComponent):
             def _consume(self):
                 pass
+
             def _graph_is_configured(self):
                 pass
 
@@ -117,6 +119,7 @@ class GraphTestCase(unittest.TestCase):
         class MySink(bt2._UserSinkComponent):
             def _consume(self):
                 pass
+
             def _graph_is_configured(self):
                 pass
 
@@ -127,11 +130,13 @@ class GraphTestCase(unittest.TestCase):
         class MySink(bt2._UserSinkComponent):
             def _consume(self):
                 pass
+
             def _graph_is_configured(self):
                 pass
 
-        comp = self._graph.add_component(MySink, 'salut',
-                                         logging_level=bt2.LoggingLevel.DEBUG)
+        comp = self._graph.add_component(
+            MySink, 'salut', logging_level=bt2.LoggingLevel.DEBUG
+        )
         self.assertEqual(comp.logging_level, bt2.LoggingLevel.DEBUG)
 
     def test_connect_ports(self):
@@ -139,8 +144,7 @@ class GraphTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -157,8 +161,9 @@ class GraphTestCase(unittest.TestCase):
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
 
-        conn = self._graph.connect_ports(src.output_ports['out'],
-                                         sink.input_ports['in'])
+        conn = self._graph.connect_ports(
+            src.output_ports['out'], sink.input_ports['in']
+        )
         self.assertTrue(src.output_ports['out'].is_connected)
         self.assertTrue(sink.input_ports['in'].is_connected)
         self.assertEqual(src.output_ports['out'].connection.addr, conn.addr)
@@ -169,8 +174,7 @@ class GraphTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -188,8 +192,9 @@ class GraphTestCase(unittest.TestCase):
         sink = self._graph.add_component(MySink, 'sink')
 
         with self.assertRaises(TypeError):
-            conn = self._graph.connect_ports(sink.input_ports['in'],
-                                             src.output_ports['out'])
+            conn = self._graph.connect_ports(
+                sink.input_ports['in'], src.output_ports['out']
+            )
 
     def test_cancel(self):
         self.assertFalse(self._graph.is_canceled)
@@ -203,8 +208,7 @@ class GraphTestCase(unittest.TestCase):
             def __next__(self):
                 return self._create_stream_beginning_message(self._stream)
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -249,8 +253,7 @@ class GraphTestCase(unittest.TestCase):
                 self._at += 1
                 return msg
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -281,8 +284,9 @@ class GraphTestCase(unittest.TestCase):
 
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
-        conn = self._graph.connect_ports(src.output_ports['out'],
-                                         sink.input_ports['in'])
+        conn = self._graph.connect_ports(
+            src.output_ports['out'], sink.input_ports['in']
+        )
         self._graph.run()
 
     def test_run_again(self):
@@ -301,8 +305,7 @@ class GraphTestCase(unittest.TestCase):
                 self._at += 1
                 return msg
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -330,8 +333,9 @@ class GraphTestCase(unittest.TestCase):
 
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
-        conn = self._graph.connect_ports(src.output_ports['out'],
-                                         sink.input_ports['in'])
+        conn = self._graph.connect_ports(
+            src.output_ports['out'], sink.input_ports['in']
+        )
 
         with self.assertRaises(bt2.TryAgain):
             self._graph.run()
@@ -357,8 +361,7 @@ class GraphTestCase(unittest.TestCase):
                 self._at += 1
                 return msg
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -387,8 +390,9 @@ class GraphTestCase(unittest.TestCase):
 
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
-        conn = self._graph.connect_ports(src.output_ports['out'],
-                                         sink.input_ports['in'])
+        conn = self._graph.connect_ports(
+            src.output_ports['out'], sink.input_ports['in']
+        )
 
         with self.assertRaises(bt2.Error):
             self._graph.run()
@@ -398,8 +402,7 @@ class GraphTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
                 self._add_output_port('zero')
@@ -421,20 +424,26 @@ class GraphTestCase(unittest.TestCase):
             nonlocal calls
             calls.append((port_added_listener, component, port))
 
-        def ports_connected_listener(upstream_component, upstream_port,
-                                     downstream_component, downstream_port):
+        def ports_connected_listener(
+            upstream_component, upstream_port, downstream_component, downstream_port
+        ):
             nonlocal calls
-            calls.append((ports_connected_listener,
-                          upstream_component, upstream_port,
-                          downstream_component, downstream_port))
+            calls.append(
+                (
+                    ports_connected_listener,
+                    upstream_component,
+                    upstream_port,
+                    downstream_component,
+                    downstream_port,
+                )
+            )
 
         calls = []
         self._graph.add_port_added_listener(port_added_listener)
         self._graph.add_ports_connected_listener(ports_connected_listener)
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
-        self._graph.connect_ports(src.output_ports['out'],
-                                  sink.input_ports['in'])
+        self._graph.connect_ports(src.output_ports['out'], sink.input_ports['in'])
 
         self.assertEqual(len(calls), 5)
 
@@ -465,8 +474,7 @@ class GraphTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
                 self._add_output_port('zero')
@@ -530,8 +538,7 @@ class GraphTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -545,8 +552,9 @@ class GraphTestCase(unittest.TestCase):
             def _graph_is_configured(self):
                 pass
 
-        def ports_connected_listener(upstream_component, upstream_port,
-                                     downstream_component, downstream_port):
+        def ports_connected_listener(
+            upstream_component, upstream_port, downstream_component, downstream_port
+        ):
             raise ValueError('oh noes!')
 
         graph = bt2.Graph()
index 2a9c5f61bb7cf1c0bca5d9fca543885906b989e5..9188025add4983f3ec719b11535289bf37b12328 100644 (file)
@@ -110,11 +110,13 @@ class _IntegerRangeSetTestCase:
         self.assertIn(self._range3, self._rs)
 
     def test_create_tuples(self):
-        rs = self._CLS((
-            (self._range1.lower, self._range1.upper),
-            (self._range2.lower, self._range2.upper),
-            (self._range3.lower, self._range3.upper),
-        ))
+        rs = self._CLS(
+            (
+                (self._range1.lower, self._range1.upper),
+                (self._range2.lower, self._range2.upper),
+                (self._range3.lower, self._range3.upper),
+            )
+        )
         self.assertEqual(len(rs), 3)
         self.assertIn(self._range1, rs)
         self.assertIn(self._range2, rs)
index a432ec71db6de421ef5931c9e9015e722cd96ada..5b513361ded29b500cf1591e625380e1aa536170 100644 (file)
@@ -23,34 +23,53 @@ import bt2
 
 class AllMessagesTestCase(unittest.TestCase):
     def setUp(self):
-
         class MyIter(bt2._UserMessageIterator):
             def __init__(self, self_port_output):
                 self._at = 0
-                self._with_stream_msgs_clock_snapshots = self_port_output.user_data.get('with_stream_msgs_clock_snapshots', False)
+                self._with_stream_msgs_clock_snapshots = self_port_output.user_data.get(
+                    'with_stream_msgs_clock_snapshots', False
+                )
 
             def __next__(self):
                 if test_obj._clock_class:
                     if self._at == 0:
                         if self._with_stream_msgs_clock_snapshots:
-                            msg = self._create_stream_beginning_message(test_obj._stream, default_clock_snapshot=self._at)
+                            msg = self._create_stream_beginning_message(
+                                test_obj._stream, default_clock_snapshot=self._at
+                            )
                         else:
-                            msg = self._create_stream_beginning_message(test_obj._stream)
+                            msg = self._create_stream_beginning_message(
+                                test_obj._stream
+                            )
                     elif self._at == 1:
-                        msg = self._create_packet_beginning_message(test_obj._packet, self._at)
+                        msg = self._create_packet_beginning_message(
+                            test_obj._packet, self._at
+                        )
                     elif self._at == 2:
-                        msg = self._create_event_message(test_obj._event_class, test_obj._packet, self._at)
+                        msg = self._create_event_message(
+                            test_obj._event_class, test_obj._packet, self._at
+                        )
                     elif self._at == 3:
-                        msg = self._create_message_iterator_inactivity_message(test_obj._clock_class, self._at)
+                        msg = self._create_message_iterator_inactivity_message(
+                            test_obj._clock_class, self._at
+                        )
                     elif self._at == 4:
-                        msg = self._create_discarded_events_message(test_obj._stream, 890, self._at, self._at)
+                        msg = self._create_discarded_events_message(
+                            test_obj._stream, 890, self._at, self._at
+                        )
                     elif self._at == 5:
-                        msg = self._create_packet_end_message(test_obj._packet, self._at)
+                        msg = self._create_packet_end_message(
+                            test_obj._packet, self._at
+                        )
                     elif self._at == 6:
-                        msg = self._create_discarded_packets_message(test_obj._stream, 678, self._at, self._at)
+                        msg = self._create_discarded_packets_message(
+                            test_obj._stream, 678, self._at, self._at
+                        )
                     elif self._at == 7:
                         if self._with_stream_msgs_clock_snapshots:
-                            msg = self._create_stream_end_message(test_obj._stream, default_clock_snapshot=self._at)
+                            msg = self._create_stream_end_message(
+                                test_obj._stream, default_clock_snapshot=self._at
+                            )
                         else:
                             msg = self._create_stream_end_message(test_obj._stream)
                     elif self._at >= 8:
@@ -61,13 +80,19 @@ class AllMessagesTestCase(unittest.TestCase):
                     elif self._at == 1:
                         msg = self._create_packet_beginning_message(test_obj._packet)
                     elif self._at == 2:
-                        msg = self._create_event_message(test_obj._event_class, test_obj._packet)
+                        msg = self._create_event_message(
+                            test_obj._event_class, test_obj._packet
+                        )
                     elif self._at == 3:
-                        msg = self._create_discarded_events_message(test_obj._stream, 890)
+                        msg = self._create_discarded_events_message(
+                            test_obj._stream, 890
+                        )
                     elif self._at == 4:
                         msg = self._create_packet_end_message(test_obj._packet)
                     elif self._at == 5:
-                        msg = self._create_discarded_packets_message(test_obj._stream, 678)
+                        msg = self._create_discarded_packets_message(
+                            test_obj._stream, 678
+                        )
                     elif self._at == 6:
                         msg = self._create_stream_end_message(test_obj._stream)
                     elif self._at >= 7:
@@ -87,21 +112,21 @@ class AllMessagesTestCase(unittest.TestCase):
                 else:
                     cc = None
 
-                sc = tc.create_stream_class(default_clock_class=cc,
-                                            supports_packets=True,
-                                            packets_have_beginning_default_clock_snapshot=with_cc,
-                                            packets_have_end_default_clock_snapshot=with_cc,
-                                            supports_discarded_events=True,
-                                            discarded_events_have_default_clock_snapshots=with_cc,
-                                            supports_discarded_packets=True,
-                                            discarded_packets_have_default_clock_snapshots=with_cc)
+                sc = tc.create_stream_class(
+                    default_clock_class=cc,
+                    supports_packets=True,
+                    packets_have_beginning_default_clock_snapshot=with_cc,
+                    packets_have_end_default_clock_snapshot=with_cc,
+                    supports_discarded_events=True,
+                    discarded_events_have_default_clock_snapshots=with_cc,
+                    supports_discarded_packets=True,
+                    discarded_packets_have_default_clock_snapshots=with_cc,
+                )
 
                 # Create payload field class
                 my_int_fc = tc.create_signed_integer_field_class(32)
                 payload_fc = tc.create_structure_field_class()
-                payload_fc += [
-                    ('my_int', my_int_fc),
-                ]
+                payload_fc += [('my_int', my_int_fc)]
 
                 ec = sc.create_event_class(name='salut', payload_field_class=payload_fc)
 
@@ -123,13 +148,17 @@ class AllMessagesTestCase(unittest.TestCase):
     def test_all_msg_with_cc(self):
         params = {'with_cc': True}
         self._src_comp = self._graph.add_component(self._src, 'my_source', params)
-        self._msg_iter = self._graph.create_output_port_message_iterator(self._src_comp.output_ports['out'])
+        self._msg_iter = self._graph.create_output_port_message_iterator(
+            self._src_comp.output_ports['out']
+        )
 
         for i, msg in enumerate(self._msg_iter):
             if i == 0:
                 self.assertIsInstance(msg, bt2.message._StreamBeginningMessage)
                 self.assertEqual(msg.stream.addr, self._stream.addr)
-                self.assertIsInstance(msg.default_clock_snapshot, bt2.clock_snapshot._UnknownClockSnapshot)
+                self.assertIsInstance(
+                    msg.default_clock_snapshot, bt2.clock_snapshot._UnknownClockSnapshot
+                )
             elif i == 1:
                 self.assertIsInstance(msg, bt2.message._PacketBeginningMessage)
                 self.assertEqual(msg.packet.addr, self._packet.addr)
@@ -139,13 +168,17 @@ class AllMessagesTestCase(unittest.TestCase):
                 self.assertEqual(msg.event.cls.addr, self._event_class.addr)
                 self.assertEqual(msg.default_clock_snapshot.value, i)
             elif i == 3:
-                self.assertIsInstance(msg, bt2.message._MessageIteratorInactivityMessage)
+                self.assertIsInstance(
+                    msg, bt2.message._MessageIteratorInactivityMessage
+                )
                 self.assertEqual(msg.default_clock_snapshot.value, i)
             elif i == 4:
                 self.assertIsInstance(msg, bt2.message._DiscardedEventsMessage)
                 self.assertEqual(msg.stream.addr, self._stream.addr)
                 self.assertEqual(msg.count, 890)
-                self.assertEqual(msg.stream.cls.default_clock_class.addr, self._clock_class.addr)
+                self.assertEqual(
+                    msg.stream.cls.default_clock_class.addr, self._clock_class.addr
+                )
                 self.assertEqual(msg.beginning_default_clock_snapshot.value, i)
                 self.assertEqual(msg.end_default_clock_snapshot.value, i)
             elif i == 5:
@@ -156,20 +189,26 @@ class AllMessagesTestCase(unittest.TestCase):
                 self.assertIsInstance(msg, bt2.message._DiscardedPacketsMessage)
                 self.assertEqual(msg.stream.addr, self._stream.addr)
                 self.assertEqual(msg.count, 678)
-                self.assertEqual(msg.stream.cls.default_clock_class.addr, self._clock_class.addr)
+                self.assertEqual(
+                    msg.stream.cls.default_clock_class.addr, self._clock_class.addr
+                )
                 self.assertEqual(msg.beginning_default_clock_snapshot.value, i)
                 self.assertEqual(msg.end_default_clock_snapshot.value, i)
             elif i == 7:
                 self.assertIsInstance(msg, bt2.message._StreamEndMessage)
                 self.assertEqual(msg.stream.addr, self._stream.addr)
-                self.assertIsInstance(msg.default_clock_snapshot, bt2.clock_snapshot._UnknownClockSnapshot)
+                self.assertIsInstance(
+                    msg.default_clock_snapshot, bt2.clock_snapshot._UnknownClockSnapshot
+                )
             else:
                 raise Exception
 
     def test_all_msg_without_cc(self):
         params = {'with_cc': False}
         self._src_comp = self._graph.add_component(self._src, 'my_source', params)
-        self._msg_iter = self._graph.create_output_port_message_iterator(self._src_comp.output_ports['out'])
+        self._msg_iter = self._graph.create_output_port_message_iterator(
+            self._src_comp.output_ports['out']
+        )
 
         for i, msg in enumerate(self._msg_iter):
             if i == 0:
@@ -215,13 +254,12 @@ class AllMessagesTestCase(unittest.TestCase):
                 raise Exception
 
     def test_msg_stream_with_clock_snapshots(self):
-        params = {
-            'with_cc': True,
-            'with_stream_msgs_clock_snapshots': True,
-        }
+        params = {'with_cc': True, 'with_stream_msgs_clock_snapshots': True}
 
         self._src_comp = self._graph.add_component(self._src, 'my_source', params)
-        self._msg_iter = self._graph.create_output_port_message_iterator(self._src_comp.output_ports['out'])
+        self._msg_iter = self._graph.create_output_port_message_iterator(
+            self._src_comp.output_ports['out']
+        )
         msgs = list(self._msg_iter)
 
         msg_stream_beg = msgs[0]
index 84912983cb3db7ed133dd0f8f0762e3fc64e971a..869c072c6f508028d33e71a94ba47685305c56cf 100644 (file)
@@ -1,4 +1,3 @@
-
 #
 # Copyright (C) 2019 EfficiOS Inc.
 #
@@ -40,8 +39,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
         graph = bt2.Graph()
         src_comp = graph.add_component(src_comp_cls, 'src')
         sink_comp = graph.add_component(MySink, 'sink')
-        graph.connect_ports(src_comp.output_ports['out'],
-                            sink_comp.input_ports['in'])
+        graph.connect_ports(src_comp.output_ports['out'], sink_comp.input_ports['in'])
         return graph
 
     def test_init(self):
@@ -55,8 +53,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
                 initialized = True
                 the_output_port_from_iter = self_port_output
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 nonlocal the_output_port_from_source
                 the_output_port_from_source = self._add_output_port('out', 'user data')
@@ -65,7 +62,9 @@ class UserMessageIteratorTestCase(unittest.TestCase):
         graph = self._create_graph(MySource)
         graph.run()
         self.assertTrue(initialized)
-        self.assertEqual(the_output_port_from_source.addr, the_output_port_from_iter.addr)
+        self.assertEqual(
+            the_output_port_from_source.addr, the_output_port_from_iter.addr
+        )
         self.assertEqual(the_output_port_from_iter.user_data, 'user data')
 
     def test_finalize(self):
@@ -74,8 +73,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
                 nonlocal finalized
                 finalized = True
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -91,8 +89,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
                 nonlocal salut
                 salut = self._component._salut
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
                 self._salut = 23
@@ -108,8 +105,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
                 nonlocal addr
                 addr = self.addr
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -201,8 +197,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
                 else:
                     raise StopIteration
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MySourceIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MySourceIter):
             def __init__(self, params):
                 tc = self._create_trace_class()
                 sc = tc.create_stream_class(supports_packets=True)
@@ -230,7 +225,6 @@ class UserMessageIteratorTestCase(unittest.TestCase):
                 input_port = self._add_input_port('in')
                 self._add_output_port('out', input_port)
 
-
         graph = bt2.Graph()
         src = graph.add_component(MySource, 'src')
         flt = graph.add_component(MyFilter, 'flt')
@@ -299,7 +293,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
         it, MySourceIter = self._setup_seek_beginning_test()
 
         def _seek_beginning_error(self):
-           raise ValueError('ouch')
+            raise ValueError('ouch')
 
         MySourceIter._seek_beginning = _seek_beginning_error
 
@@ -307,7 +301,6 @@ class UserMessageIteratorTestCase(unittest.TestCase):
             it.seek_beginning()
 
 
-
 class OutputPortMessageIteratorTestCase(unittest.TestCase):
     def test_component(self):
         class MyIter(bt2._UserMessageIterator):
@@ -327,14 +320,15 @@ class OutputPortMessageIteratorTestCase(unittest.TestCase):
                 elif self._at == 6:
                     msg = self._create_stream_end_message(test_obj._stream)
                 else:
-                    msg = self._create_event_message(test_obj._event_class, test_obj._packet)
+                    msg = self._create_event_message(
+                        test_obj._event_class, test_obj._packet
+                    )
                     msg.event.payload_field['my_int'] = self._at * 3
 
                 self._at += 1
                 return msg
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(self, params):
                 self._add_output_port('out')
 
@@ -344,11 +338,11 @@ class OutputPortMessageIteratorTestCase(unittest.TestCase):
                 # Create payload field class
                 my_int_ft = trace_class.create_signed_integer_field_class(32)
                 payload_ft = trace_class.create_structure_field_class()
-                payload_ft += [
-                    ('my_int', my_int_ft),
-                ]
+                payload_ft += [('my_int', my_int_ft)]
 
-                event_class = stream_class.create_event_class(name='salut', payload_field_class=payload_ft)
+                event_class = stream_class.create_event_class(
+                    name='salut', payload_field_class=payload_ft
+                )
 
                 trace = trace_class()
                 stream = trace.create_stream(stream_class)
@@ -378,5 +372,6 @@ class OutputPortMessageIteratorTestCase(unittest.TestCase):
                 field = msg.event.payload_field['my_int']
                 self.assertEqual(field, at * 3)
 
+
 if __name__ == '__main__':
     unittest.main()
index 0b2a85b94f7541428ceca55b6fd73e2dde6c7b84..59fa2b451695183843f3f521bc91ef1f47fdfe45 100644 (file)
@@ -50,10 +50,12 @@ class PacketTestCase(unittest.TestCase):
             ]
 
         # stream class
-        sc = tc.create_stream_class(default_clock_class=clock_class,
-                                    event_common_context_field_class=sec,
-                                    packet_context_field_class=pc,
-                                    supports_packets=True)
+        sc = tc.create_stream_class(
+            default_clock_class=clock_class,
+            event_common_context_field_class=sec,
+            packet_context_field_class=pc,
+            supports_packets=True,
+        )
 
         # event context
         ec = tc.create_structure_field_class()
index 2096d84b2301e49d88a00c0cab443fea05e5ed85..e0bf945112d4760691f895953d8051f12cf49be7 100644 (file)
@@ -50,7 +50,9 @@ class PluginSetTestCase(unittest.TestCase):
 class FindPluginsTestCase(unittest.TestCase):
     def test_find_nonexistent_dir(self):
         with self.assertRaises(bt2.Error):
-            bt2.find_plugins('/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41')
+            bt2.find_plugins(
+                '/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41'
+            )
 
     def test_find_none_existing_dir(self):
         plugins = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH, recurse=False)
@@ -61,7 +63,9 @@ class FindPluginsTestCase(unittest.TestCase):
         self.assertTrue(len(pset) >= 3)
 
     def test_find_file(self):
-        extension = _TEST_PLUGIN_PLUGIN_EXTENSION_BY_OS.get(os.environ['BT_OS_TYPE'], 'so')
+        extension = _TEST_PLUGIN_PLUGIN_EXTENSION_BY_OS.get(
+            os.environ['BT_OS_TYPE'], 'so'
+        )
         plugin_name = 'babeltrace-plugin-utils.{}'.format(extension)
         path = os.path.join(_TEST_PLUGIN_PLUGINS_PATH, 'utils', '.libs', plugin_name)
         pset = bt2.find_plugins(path)
@@ -70,7 +74,9 @@ class FindPluginsTestCase(unittest.TestCase):
 
 class FindPluginTestCase(unittest.TestCase):
     def test_find_none(self):
-        plugin = bt2.find_plugin('this-does-not-exist-246703df-cb85-46d5-8406-5e8dc4a88b41')
+        plugin = bt2.find_plugin(
+            'this-does-not-exist-246703df-cb85-46d5-8406-5e8dc4a88b41'
+        )
         self.assertIsNone(plugin)
 
     def test_find_existing(self):
index c94bb920ac197393768b9d0845e8fc7d0451944a..35d8797e8973036f66479b6e9653487ff3dce023 100644 (file)
@@ -35,8 +35,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port = comp_self._add_output_port('out')
                 self.assertEqual(port.name, 'out')
@@ -49,8 +48,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port = comp_self._add_output_port('out')
                 self.assertEqual(port.name, 'out')
@@ -63,8 +61,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port = comp_self._add_input_port('in')
                 self.assertEqual(port.name, 'in')
@@ -92,8 +89,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port1 = comp_self._add_output_port('clear')
                 port2 = comp_self._add_output_port('print')
@@ -109,8 +105,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port1 = comp_self._add_output_port('clear')
                 port2 = comp_self._add_output_port('print')
@@ -126,8 +121,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port1 = comp_self._add_input_port('clear')
                 port2 = comp_self._add_input_port('print')
@@ -161,8 +155,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -178,8 +171,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -195,8 +187,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_input_port('clear')
                 comp_self._add_input_port('print')
@@ -230,8 +221,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -245,8 +235,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -260,8 +249,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_input_port('clear')
                 comp_self._add_input_port('print')
@@ -291,8 +279,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port1 = comp_self._add_output_port('clear')
                 port2 = comp_self._add_output_port('print')
@@ -316,8 +303,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port1 = comp_self._add_output_port('clear')
                 port2 = comp_self._add_output_port('print')
@@ -341,8 +327,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 port1 = comp_self._add_input_port('clear')
                 port2 = comp_self._add_input_port('print')
@@ -396,8 +381,7 @@ class PortTestCase(unittest.TestCase):
         port2 = None
         port3 = None
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal port1, port2, port3
                 port1 = comp_self._add_output_port('clear')
@@ -421,8 +405,7 @@ class PortTestCase(unittest.TestCase):
         port2 = None
         port3 = None
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal port1, port2, port3
                 port1 = comp_self._add_output_port('clear')
@@ -446,8 +429,7 @@ class PortTestCase(unittest.TestCase):
         port2 = None
         port3 = None
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal port1, port2, port3
                 port1 = comp_self._add_input_port('clear')
@@ -493,8 +475,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -510,8 +491,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -527,8 +507,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_input_port('clear')
                 comp_self._add_input_port('print')
@@ -565,8 +544,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -580,8 +558,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_output_port('clear')
                 comp_self._add_output_port('print')
@@ -595,8 +572,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 comp_self._add_input_port('clear')
                 comp_self._add_input_port('print')
@@ -630,8 +606,7 @@ class PortTestCase(unittest.TestCase):
         port2 = None
         port3 = None
 
-        class MySource(bt2._UserSourceComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal port1, port2, port3
                 port1 = comp_self._add_output_port('clear')
@@ -663,8 +638,7 @@ class PortTestCase(unittest.TestCase):
         port2 = None
         port3 = None
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal port1, port2, port3
                 port1 = comp_self._add_output_port('clear')
@@ -696,8 +670,7 @@ class PortTestCase(unittest.TestCase):
         port2 = None
         port3 = None
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal port1, port2, port3
                 port1 = comp_self._add_input_port('clear')
@@ -843,8 +816,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySource(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MySource(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal user_datas
 
@@ -863,8 +835,7 @@ class PortTestCase(unittest.TestCase):
             def __next__(self):
                 raise bt2.Stop
 
-        class MyFilter(bt2._UserFilterComponent,
-                       message_iterator_class=MyIter):
+        class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal user_datas
 
@@ -881,16 +852,16 @@ class PortTestCase(unittest.TestCase):
         user_datas = []
 
         comp = self._create_comp(MyFilter)
-        self.assertEqual(user_datas,
-                         [None, 'user data string', None, {'user data': 'dict'}])
+        self.assertEqual(
+            user_datas, [None, 'user data string', None, {'user data': 'dict'}]
+        )
 
     def test_sink_self_port_user_data(self):
         class MyIter(bt2._UserMessageIterator):
             def __next__(self):
                 raise bt2.Stop
 
-        class MySink(bt2._UserFilterComponent,
-                     message_iterator_class=MyIter):
+        class MySink(bt2._UserFilterComponent, message_iterator_class=MyIter):
             def __init__(comp_self, params):
                 nonlocal user_datas
 
index 3c4ba62fb264292111d865f50b6021eb68371368..f313b173b6bc5c83c3046b108fb59e4a47cfe855 100644 (file)
@@ -35,28 +35,18 @@ class QueryExecutorTestCase(unittest.TestCase):
             def _query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
                 query_params = params
-                return {
-                    'null': None,
-                    'bt2': 'BT2',
-                }
+                return {'null': None, 'bt2': 'BT2'}
 
         query_params = None
         params = {
             'array': ['coucou', 23, None],
-            'other_map': {
-                'yes': 'yeah',
-                '19': 19,
-                'minus 1.5': -1.5,
-            },
+            'other_map': {'yes': 'yeah', '19': 19, 'minus 1.5': -1.5},
             'null': None,
         }
 
         res = bt2.QueryExecutor().query(MySink, 'obj', params)
         self.assertEqual(query_params, params)
-        self.assertEqual(res, {
-            'null': None,
-            'bt2': 'BT2',
-        })
+        self.assertEqual(res, {'null': None, 'bt2': 'BT2'})
         del query_params
 
     def test_query_params_none(self):
@@ -91,8 +81,7 @@ class QueryExecutorTestCase(unittest.TestCase):
                 query_log_level = log_level
 
         query_log_level = None
-        res = bt2.QueryExecutor().query(MySink, 'obj', None,
-                                        bt2.LoggingLevel.INFO)
+        res = bt2.QueryExecutor().query(MySink, 'obj', None, bt2.LoggingLevel.INFO)
         self.assertEqual(query_log_level, bt2.LoggingLevel.INFO)
         del query_log_level
 
index 55cdb3109304a0158a1121e31f4aedae14d8bbbe..f8d6446c0fa0a39793a7651be4081138279db9fc 100644 (file)
@@ -58,8 +58,9 @@ class StreamClassTestCase(unittest.TestCase):
 
     def test_create_packet_context_field_class(self):
         fc = self._tc.create_structure_field_class()
-        sc = self._tc.create_stream_class(packet_context_field_class=fc,
-                                          supports_packets=True)
+        sc = self._tc.create_stream_class(
+            packet_context_field_class=fc, supports_packets=True
+        )
         self.assertEqual(sc.packet_context_field_class, fc)
 
     def test_create_invalid_packet_context_field_class(self):
@@ -146,118 +147,150 @@ class StreamClassTestCase(unittest.TestCase):
             sc.create_event_class()
 
     def test_supports_packets_without_cs(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_packets=True)
+        sc = self._tc.create_stream_class(
+            default_clock_class=self._cc, supports_packets=True
+        )
         self.assertTrue(sc.supports_packets)
         self.assertFalse(sc.packets_have_beginning_default_clock_snapshot)
         self.assertFalse(sc.packets_have_end_default_clock_snapshot)
 
     def test_supports_packets_with_begin_cs(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_packets=True,
-                                          packets_have_beginning_default_clock_snapshot=True)
+        sc = self._tc.create_stream_class(
+            default_clock_class=self._cc,
+            supports_packets=True,
+            packets_have_beginning_default_clock_snapshot=True,
+        )
         self.assertTrue(sc.supports_packets)
         self.assertTrue(sc.packets_have_beginning_default_clock_snapshot)
         self.assertFalse(sc.packets_have_end_default_clock_snapshot)
 
     def test_supports_packets_with_end_cs(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_packets=True,
-                                          packets_have_end_default_clock_snapshot=True)
+        sc = self._tc.create_stream_class(
+            default_clock_class=self._cc,
+            supports_packets=True,
+            packets_have_end_default_clock_snapshot=True,
+        )
         self.assertTrue(sc.supports_packets)
         self.assertFalse(sc.packets_have_beginning_default_clock_snapshot)
         self.assertTrue(sc.packets_have_end_default_clock_snapshot)
 
     def test_supports_packets_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              supports_packets=23)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc, supports_packets=23
+            )
 
     def test_packets_have_begin_default_cs_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              packets_have_beginning_default_clock_snapshot=23)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                packets_have_beginning_default_clock_snapshot=23,
+            )
 
     def test_packets_have_end_default_cs_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              packets_have_end_default_clock_snapshot=23)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc, packets_have_end_default_clock_snapshot=23
+            )
 
     def test_does_not_support_packets_raises_with_begin_cs(self):
         with self.assertRaises(ValueError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              packets_have_beginning_default_clock_snapshot=True)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                packets_have_beginning_default_clock_snapshot=True,
+            )
 
     def test_does_not_support_packets_raises_with_end_cs(self):
         with self.assertRaises(ValueError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              packets_have_end_default_clock_snapshot=True)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                packets_have_end_default_clock_snapshot=True,
+            )
 
     def test_supports_discarded_events_without_cs(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_discarded_events=True)
+        sc = self._tc.create_stream_class(
+            default_clock_class=self._cc, supports_discarded_events=True
+        )
         self.assertTrue(sc.supports_discarded_events)
         self.assertFalse(sc.discarded_events_have_default_clock_snapshots)
 
     def test_supports_discarded_events_with_cs(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_discarded_events=True,
-                                          discarded_events_have_default_clock_snapshots=True)
+        sc = self._tc.create_stream_class(
+            default_clock_class=self._cc,
+            supports_discarded_events=True,
+            discarded_events_have_default_clock_snapshots=True,
+        )
         self.assertTrue(sc.supports_discarded_events)
         self.assertTrue(sc.discarded_events_have_default_clock_snapshots)
 
     def test_supports_discarded_events_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              supports_discarded_events=23)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc, supports_discarded_events=23
+            )
 
     def test_discarded_events_have_default_cs_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              discarded_events_have_default_clock_snapshots=23)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                discarded_events_have_default_clock_snapshots=23,
+            )
 
     def test_does_not_support_discarded_events_raises_with_cs(self):
         with self.assertRaises(ValueError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              discarded_events_have_default_clock_snapshots=True)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                discarded_events_have_default_clock_snapshots=True,
+            )
 
     def test_supports_discarded_packets_without_cs(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_discarded_packets=True,
-                                          supports_packets=True)
+        sc = self._tc.create_stream_class(
+            default_clock_class=self._cc,
+            supports_discarded_packets=True,
+            supports_packets=True,
+        )
         self.assertTrue(sc.supports_discarded_packets)
         self.assertFalse(sc.discarded_packets_have_default_clock_snapshots)
 
     def test_supports_discarded_packets_with_cs(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_discarded_packets=True,
-                                          discarded_packets_have_default_clock_snapshots=True,
-                                          supports_packets=True)
+        sc = self._tc.create_stream_class(
+            default_clock_class=self._cc,
+            supports_discarded_packets=True,
+            discarded_packets_have_default_clock_snapshots=True,
+            supports_packets=True,
+        )
         self.assertTrue(sc.supports_discarded_packets)
         self.assertTrue(sc.discarded_packets_have_default_clock_snapshots)
 
     def test_supports_discarded_packets_raises_without_packet_support(self):
         with self.assertRaises(ValueError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              supports_discarded_packets=True)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc, supports_discarded_packets=True
+            )
 
     def test_supports_discarded_packets_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              supports_discarded_packets=23,
-                                              supports_packets=True)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                supports_discarded_packets=23,
+                supports_packets=True,
+            )
 
     def test_discarded_packets_have_default_cs_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              discarded_packets_have_default_clock_snapshots=23,
-                                              supports_packets=True)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                discarded_packets_have_default_clock_snapshots=23,
+                supports_packets=True,
+            )
 
     def test_does_not_support_discarded_packets_raises_with_cs(self):
         with self.assertRaises(ValueError):
-            sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              discarded_packets_have_default_clock_snapshots=True,
-                                              supports_packets=True)
+            sc = self._tc.create_stream_class(
+                default_clock_class=self._cc,
+                discarded_packets_have_default_clock_snapshots=True,
+                supports_packets=True,
+            )
 
     def test_trace_class(self):
         sc = self._tc.create_stream_class()
index 1b4b2a7ee30a939d48c2163786f0d9d08a3cbff5..cf286658f4938c5c22ed2c8b47662e97ba73b56d 100644 (file)
@@ -22,7 +22,6 @@ from utils import run_in_component_init, get_default_trace_class
 
 
 class TraceClassTestCase(unittest.TestCase):
-
     def test_create_default(self):
         def f(comp_self):
             return comp_self._create_trace_class()
@@ -57,7 +56,9 @@ class TraceClassTestCase(unittest.TestCase):
 
     def test_no_assigns_automatic_stream_class_id(self):
         def f(comp_self):
-            return comp_self._create_trace_class(assigns_automatic_stream_class_id=False)
+            return comp_self._create_trace_class(
+                assigns_automatic_stream_class_id=False
+            )
 
         tc = run_in_component_init(f)
         self.assertFalse(tc.assigns_automatic_stream_class_id)
@@ -67,7 +68,9 @@ class TraceClassTestCase(unittest.TestCase):
 
     def test_no_assigns_automatic_stream_class_id_raises(self):
         def f(comp_self):
-            return comp_self._create_trace_class(assigns_automatic_stream_class_id=False)
+            return comp_self._create_trace_class(
+                assigns_automatic_stream_class_id=False
+            )
 
         tc = run_in_component_init(f)
         self.assertFalse(tc.assigns_automatic_stream_class_id)
@@ -79,7 +82,9 @@ class TraceClassTestCase(unittest.TestCase):
     @staticmethod
     def _create_trace_class_with_some_stream_classes():
         def f(comp_self):
-            return comp_self._create_trace_class(assigns_automatic_stream_class_id=False)
+            return comp_self._create_trace_class(
+                assigns_automatic_stream_class_id=False
+            )
 
         tc = run_in_component_init(f)
         sc1 = tc.create_stream_class(id=12)
index e804a4f232ab2fa6b3a62f063a779eaa4178e7f4..f3b337639a17322da7128c71aac4bc944d307ea3 100644 (file)
@@ -24,9 +24,9 @@ import os.path
 
 
 _BT_CTF_TRACES_PATH = os.environ['BT_CTF_TRACES_PATH']
-_3EVENTS_INTERSECT_TRACE_PATH = os.path.join(_BT_CTF_TRACES_PATH,
-                                             'intersection',
-                                             '3eventsintersect')
+_3EVENTS_INTERSECT_TRACE_PATH = os.path.join(
+    _BT_CTF_TRACES_PATH, 'intersection', '3eventsintersect'
+)
 
 
 class ComponentSpecTestCase(unittest.TestCase):
@@ -55,6 +55,7 @@ class ComponentSpecTestCase(unittest.TestCase):
 
 # Return a map, msg type -> number of messages of this type.
 
+
 def _count_msgs_by_type(msgs):
     res = {}
 
@@ -126,16 +127,16 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase):
 
     def test_iter_custom_filter(self):
         src_spec = bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)
-        flt_spec = bt2.ComponentSpec('utils', 'trimmer', {
-            'end': '13515309.000000075',
-        })
+        flt_spec = bt2.ComponentSpec('utils', 'trimmer', {'end': '13515309.000000075'})
         msg_iter = bt2.TraceCollectionMessageIterator(src_spec, flt_spec)
         hist = _count_msgs_by_type(msg_iter)
         self.assertEqual(hist[bt2.message._EventMessage], 5)
 
     def test_iter_intersection(self):
         specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)]
-        msg_iter = bt2.TraceCollectionMessageIterator(specs, stream_intersection_mode=True)
+        msg_iter = bt2.TraceCollectionMessageIterator(
+            specs, stream_intersection_mode=True
+        )
         msgs = list(msg_iter)
         self.assertEqual(len(msgs), 15)
         hist = _count_msgs_by_type(msgs)
index 3521eb05b4fd37c02479734d750a7ee24fb491f7..f1bd4949ef69bfcad945333dd58d664f9e4532ac 100644 (file)
@@ -39,10 +39,7 @@ class _TestCopySimple:
             copy.deepcopy(self._def)
 
 
-_COMP_BINOPS = (
-    operator.eq,
-    operator.ne,
-)
+_COMP_BINOPS = (operator.eq, operator.ne)
 
 
 # Base class for numeric value test cases.
@@ -264,7 +261,7 @@ class _TestNumericValue(_TestCopySimple):
         test_cb(op, 0.0)
 
     def _test_binop_rhs_complex(self, test_cb, op):
-        test_cb(op, -23+19j)
+        test_cb(op, -23 + 19j)
 
     def _test_binop_rhs_zero_complex(self, test_cb, op):
         test_cb(op, 0j)
@@ -575,79 +572,415 @@ def _inject_numeric_testing_methods(cls):
 
     # inject testing methods for each binary operation
     for name, binop in _BINOPS:
-        setattr(cls, test_binop_name('invalid_unknown'), partialmethod(_TestNumericValue._test_binop_invalid_unknown, op=binop))
-        setattr(cls, test_binop_name('invalid_none'), partialmethod(_TestNumericValue._test_binop_invalid_none, op=binop))
-        setattr(cls, test_binop_name('type_true'), partialmethod(_TestNumericValue._test_binop_type_true, op=binop))
-        setattr(cls, test_binop_name('type_pos_int'), partialmethod(_TestNumericValue._test_binop_type_pos_int, op=binop))
-        setattr(cls, test_binop_name('type_pos_vint'), partialmethod(_TestNumericValue._test_binop_type_pos_vint, op=binop))
-        setattr(cls, test_binop_name('value_true'), partialmethod(_TestNumericValue._test_binop_value_true, op=binop))
-        setattr(cls, test_binop_name('value_pos_int'), partialmethod(_TestNumericValue._test_binop_value_pos_int, op=binop))
-        setattr(cls, test_binop_name('value_pos_vint'), partialmethod(_TestNumericValue._test_binop_value_pos_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_true'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_true, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_true'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_true, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_vint, op=binop))
-        setattr(cls, test_binop_name('type_neg_int'), partialmethod(_TestNumericValue._test_binop_type_neg_int, op=binop))
-        setattr(cls, test_binop_name('type_neg_vint'), partialmethod(_TestNumericValue._test_binop_type_neg_vint, op=binop))
-        setattr(cls, test_binop_name('value_neg_int'), partialmethod(_TestNumericValue._test_binop_value_neg_int, op=binop))
-        setattr(cls, test_binop_name('value_neg_vint'), partialmethod(_TestNumericValue._test_binop_value_neg_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vint, op=binop))
-        setattr(cls, test_binop_name('type_false'), partialmethod(_TestNumericValue._test_binop_type_false, op=binop))
-        setattr(cls, test_binop_name('type_zero_int'), partialmethod(_TestNumericValue._test_binop_type_zero_int, op=binop))
-        setattr(cls, test_binop_name('type_zero_vint'), partialmethod(_TestNumericValue._test_binop_type_zero_vint, op=binop))
-        setattr(cls, test_binop_name('value_false'), partialmethod(_TestNumericValue._test_binop_value_false, op=binop))
-        setattr(cls, test_binop_name('value_zero_int'), partialmethod(_TestNumericValue._test_binop_value_zero_int, op=binop))
-        setattr(cls, test_binop_name('value_zero_vint'), partialmethod(_TestNumericValue._test_binop_value_zero_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_false'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_false, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_false'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_false, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_vint, op=binop))
-        setattr(cls, test_binop_name('type_neg_float'), partialmethod(_TestNumericValue._test_binop_type_neg_float, op=binop))
-        setattr(cls, test_binop_name('type_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_type_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_neg_float'), partialmethod(_TestNumericValue._test_binop_value_neg_float, op=binop))
-        setattr(cls, test_binop_name('value_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_value_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_pos_float'), partialmethod(_TestNumericValue._test_binop_type_pos_float, op=binop))
-        setattr(cls, test_binop_name('type_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_type_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_pos_float'), partialmethod(_TestNumericValue._test_binop_value_pos_float, op=binop))
-        setattr(cls, test_binop_name('value_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_value_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_zero_float'), partialmethod(_TestNumericValue._test_binop_type_zero_float, op=binop))
-        setattr(cls, test_binop_name('type_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_type_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_zero_float'), partialmethod(_TestNumericValue._test_binop_value_zero_float, op=binop))
-        setattr(cls, test_binop_name('value_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_value_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_complex'), partialmethod(_TestNumericValue._test_binop_type_complex, op=binop))
-        setattr(cls, test_binop_name('type_zero_complex'), partialmethod(_TestNumericValue._test_binop_type_zero_complex, op=binop))
-        setattr(cls, test_binop_name('value_complex'), partialmethod(_TestNumericValue._test_binop_value_complex, op=binop))
-        setattr(cls, test_binop_name('value_zero_complex'), partialmethod(_TestNumericValue._test_binop_value_zero_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_complex'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_complex'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_complex'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_complex, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_complex'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_complex, op=binop))
+        setattr(
+            cls,
+            test_binop_name('invalid_unknown'),
+            partialmethod(_TestNumericValue._test_binop_invalid_unknown, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('invalid_none'),
+            partialmethod(_TestNumericValue._test_binop_invalid_none, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_true'),
+            partialmethod(_TestNumericValue._test_binop_type_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_int'),
+            partialmethod(_TestNumericValue._test_binop_type_pos_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_vint'),
+            partialmethod(_TestNumericValue._test_binop_type_pos_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_true'),
+            partialmethod(_TestNumericValue._test_binop_value_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_int'),
+            partialmethod(_TestNumericValue._test_binop_value_pos_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_vint'),
+            partialmethod(_TestNumericValue._test_binop_value_pos_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_true'),
+            partialmethod(_TestNumericValue._test_binop_lhs_addr_same_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_int'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_vint'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_true'),
+            partialmethod(_TestNumericValue._test_binop_lhs_value_same_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_int'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_vint'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_int'),
+            partialmethod(_TestNumericValue._test_binop_type_neg_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_vint'),
+            partialmethod(_TestNumericValue._test_binop_type_neg_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_int'),
+            partialmethod(_TestNumericValue._test_binop_value_neg_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_vint'),
+            partialmethod(_TestNumericValue._test_binop_value_neg_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_int'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_vint'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_int'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_vint'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_false'),
+            partialmethod(_TestNumericValue._test_binop_type_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_int'),
+            partialmethod(_TestNumericValue._test_binop_type_zero_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_vint'),
+            partialmethod(_TestNumericValue._test_binop_type_zero_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_false'),
+            partialmethod(_TestNumericValue._test_binop_value_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_int'),
+            partialmethod(_TestNumericValue._test_binop_value_zero_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_vint'),
+            partialmethod(_TestNumericValue._test_binop_value_zero_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_false'),
+            partialmethod(_TestNumericValue._test_binop_lhs_addr_same_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_int'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_vint'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_false'),
+            partialmethod(_TestNumericValue._test_binop_lhs_value_same_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_int'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_vint'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_float'),
+            partialmethod(_TestNumericValue._test_binop_type_neg_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_neg_vfloat'),
+            partialmethod(_TestNumericValue._test_binop_type_neg_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_float'),
+            partialmethod(_TestNumericValue._test_binop_value_neg_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_neg_vfloat'),
+            partialmethod(_TestNumericValue._test_binop_value_neg_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_float'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_neg_vfloat'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_float'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_neg_vfloat'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_float'),
+            partialmethod(_TestNumericValue._test_binop_type_pos_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_pos_vfloat'),
+            partialmethod(_TestNumericValue._test_binop_type_pos_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_float'),
+            partialmethod(_TestNumericValue._test_binop_value_pos_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_pos_vfloat'),
+            partialmethod(_TestNumericValue._test_binop_value_pos_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_float'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_pos_vfloat'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_float'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_pos_vfloat'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_float'),
+            partialmethod(_TestNumericValue._test_binop_type_zero_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_vfloat'),
+            partialmethod(_TestNumericValue._test_binop_type_zero_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_float'),
+            partialmethod(_TestNumericValue._test_binop_value_zero_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_vfloat'),
+            partialmethod(_TestNumericValue._test_binop_value_zero_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_float'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_vfloat'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_float'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_vfloat'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_complex'),
+            partialmethod(_TestNumericValue._test_binop_type_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('type_zero_complex'),
+            partialmethod(_TestNumericValue._test_binop_type_zero_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_complex'),
+            partialmethod(_TestNumericValue._test_binop_value_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('value_zero_complex'),
+            partialmethod(_TestNumericValue._test_binop_value_zero_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_complex'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_addr_same_zero_complex'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_complex'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name('lhs_value_same_zero_complex'),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_complex, op=binop
+            ),
+        )
 
     # inject testing methods for each unary operation
     for name, unaryop in _UNARYOPS:
-        setattr(cls, test_unaryop_name('type'), partialmethod(_TestNumericValue._test_unaryop_type, op=unaryop))
-        setattr(cls, test_unaryop_name('value'), partialmethod(_TestNumericValue._test_unaryop_value, op=unaryop))
-        setattr(cls, test_unaryop_name('addr_same'), partialmethod(_TestNumericValue._test_unaryop_addr_same, op=unaryop))
-        setattr(cls, test_unaryop_name('value_same'), partialmethod(_TestNumericValue._test_unaryop_value_same, op=unaryop))
+        setattr(
+            cls,
+            test_unaryop_name('type'),
+            partialmethod(_TestNumericValue._test_unaryop_type, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name('value'),
+            partialmethod(_TestNumericValue._test_unaryop_value, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name('addr_same'),
+            partialmethod(_TestNumericValue._test_unaryop_addr_same, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name('value_same'),
+            partialmethod(_TestNumericValue._test_unaryop_value_same, op=unaryop),
+        )
 
 
 class CreateValueFuncTestCase(unittest.TestCase):
@@ -748,7 +1081,9 @@ class CreateValueFuncTestCase(unittest.TestCase):
 
         a = A()
 
-        with self.assertRaisesRegex(TypeError, "cannot create value object from 'A' object") as cm:
+        with self.assertRaisesRegex(
+            TypeError, "cannot create value object from 'A' object"
+        ) as cm:
             v = bt2.create_value(a)
 
 
@@ -864,10 +1199,14 @@ class _TestIntegerValue(_TestNumericValue):
         return self.assertRaisesRegex(TypeError, r'expecting an integral number object')
 
     def _assert_expecting_int64(self):
-        return self.assertRaisesRegex(ValueError, r"expecting a signed 64-bit integral value")
+        return self.assertRaisesRegex(
+            ValueError, r"expecting a signed 64-bit integral value"
+        )
 
     def _assert_expecting_uint64(self):
-        return self.assertRaisesRegex(ValueError, r"expecting an unsigned 64-bit integral value")
+        return self.assertRaisesRegex(
+            ValueError, r"expecting an unsigned 64-bit integral value"
+        )
 
     def test_create_default(self):
         i = self._CLS()
@@ -955,7 +1294,7 @@ class SignedIntegerValueTestCase(_TestIntegerValue, unittest.TestCase):
     def test_compare_big_int(self):
         # Larger than the IEEE 754 double-precision exact representation of
         # integers.
-        raw = (2**53) + 1
+        raw = (2 ** 53) + 1
         v = bt2.create_value(raw)
         self.assertEqual(v, raw)
 
@@ -1378,7 +1717,7 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase):
             'pos-int': 42,
             'neg-float': -42.4,
             'pos-float': 23.17,
-            'str': 'yes'
+            'str': 'yes',
         }
         self._def = bt2.MapValue(copy.deepcopy(self._def_value))
 
@@ -1435,11 +1774,7 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase):
         self.assertNotEqual(a1, a2)
 
     def test_eq_same_content_same_len(self):
-        raw = {
-            '3': 3,
-            'True': True,
-            'array': [1, 2.5, None, {'a': 17.6, 'b': None}]
-        }
+        raw = {'3': 3, 'True': True, 'array': [1, 2.5, None, {'a': 17.6, 'b': None}]}
         a1 = bt2.MapValue(raw)
         a2 = bt2.MapValue(copy.deepcopy(raw))
         self.assertEqual(a1, a2)
index 873a6514aa0f0034505de112c080d3a8d80de8fc..fb4003a3e76a452ce6a5e121a26083bae67e330f 100644 (file)
@@ -23,6 +23,7 @@ import bt2
 #
 # The value returned by the callable is returned by run_in_component_init.
 
+
 def run_in_component_init(func):
     class MySink(bt2._UserSinkComponent):
         def __init__(self, params):
@@ -52,8 +53,10 @@ def run_in_component_init(func):
     del res_bound
     return res
 
+
 # Create an empty trace class with default values.
 
+
 def get_default_trace_class():
     def f(comp_self):
         return comp_self._create_trace_class()
index e1db25edb3239686795557e2c8886f455b3533f0..0fdb78f9f56ff4f94b5cdfff10c69ec67200b83f 100644 (file)
@@ -44,9 +44,11 @@ class TheIteratorOfAllEvil(bt2._UserMessageIterator):
         else:
             raise StopIteration
 
+
 @bt2.plugin_component_class
-class TheSourceOfAllEvil(bt2._UserSourceComponent,
-        message_iterator_class=TheIteratorOfAllEvil):
+class TheSourceOfAllEvil(
+    bt2._UserSourceComponent, message_iterator_class=TheIteratorOfAllEvil
+):
     def __init__(self, params):
         tc = self._create_trace_class()
 
@@ -54,10 +56,12 @@ class TheSourceOfAllEvil(bt2._UserSourceComponent,
         # smaller than this offset (in other words, a time that it's not
         # possible to represent with this clock class).
         cc = self._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(10000))
-        sc = tc.create_stream_class(default_clock_class=cc,
-                                    supports_packets=True,
-                                    packets_have_beginning_default_clock_snapshot=True,
-                                    packets_have_end_default_clock_snapshot=True)
+        sc = tc.create_stream_class(
+            default_clock_class=cc,
+            supports_packets=True,
+            packets_have_beginning_default_clock_snapshot=True,
+            packets_have_end_default_clock_snapshot=True,
+        )
         ec1 = sc.create_event_class(name='event 1')
         ec2 = sc.create_event_class(name='event 2')
         self._add_output_port('out', (tc, sc, ec1, ec2, params))
index 31bd4ecdd4e62af42a79b177463314364106a780..a79ca479273e567807af6d899f76c0ebd87b127b 100644 (file)
@@ -29,11 +29,10 @@ class LttngUtilsDebugInfoTestCase(unittest.TestCase):
         trace_path = os.path.join(debug_info_data_path, 'trace')
         target_prefix = os.path.join(debug_info_data_path, '..', '..')
         src = bt2.ComponentSpec('ctf', 'fs', trace_path)
-        flt = bt2.ComponentSpec('lttng-utils', 'debug-info', {
-            'target-prefix': target_prefix,
-        })
-        it = bt2.TraceCollectionNotificationIterator(src, flt,
-                                                     [bt2.EventNotification])
+        flt = bt2.ComponentSpec(
+            'lttng-utils', 'debug-info', {'target-prefix': target_prefix}
+        )
+        it = bt2.TraceCollectionNotificationIterator(src, flt, [bt2.EventNotification])
         notifs = list(it)
         debug_info = notifs[2].event['debug_info']
         self.assertEqual(debug_info['bin'], 'libhello_so+0x14d4')
index 0698975a60d442473eb476c402369dc376ff5fc2..c1e87e3976de29e1402f39529b6cc366eb6e8a61 100644 (file)
@@ -32,19 +32,24 @@ def sort_predictably(stream):
 
 
 class QueryTraceInfoClockOffsetTestCase(unittest.TestCase):
-
     def setUp(self):
         ctf = bt2.find_plugin('ctf')
         self._fs = ctf.source_component_classes['fs']
 
-        self._paths = [os.path.join(test_ctf_traces_path, 'intersection', '3eventsintersect')]
+        self._paths = [
+            os.path.join(test_ctf_traces_path, 'intersection', '3eventsintersect')
+        ]
         self._executor = bt2.QueryExecutor()
 
     def _check(self, trace, offset):
         self.assertEqual(trace['range-ns']['begin'], 13515309000000000 + offset)
         self.assertEqual(trace['range-ns']['end'], 13515309000000120 + offset)
-        self.assertEqual(trace['intersection-range-ns']['begin'], 13515309000000070 + offset)
-        self.assertEqual(trace['intersection-range-ns']['end'], 13515309000000100 + offset)
+        self.assertEqual(
+            trace['intersection-range-ns']['begin'], 13515309000000070 + offset
+        )
+        self.assertEqual(
+            trace['intersection-range-ns']['end'], 13515309000000100 + offset
+        )
 
         streams = sorted(trace['streams'], key=sort_predictably)
         self.assertEqual(streams[0]['range-ns']['begin'], 13515309000000000 + offset)
@@ -58,70 +63,74 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase):
     # Without clock class offset
 
     def test_no_clock_class_offset(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-        })
+        res = self._executor.query(self._fs, 'trace-info', {'paths': self._paths})
         trace = res[0]
         self._check(trace, 0)
 
     # With clock-class-offset-s
 
     def test_clock_class_offset_s(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-            'clock-class-offset-s': 2,
-        })
+        res = self._executor.query(
+            self._fs, 'trace-info', {'paths': self._paths, 'clock-class-offset-s': 2}
+        )
         trace = res[0]
         self._check(trace, 2000000000)
 
     # With clock-class-offset-ns
 
     def test_clock_class_offset_ns(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-            'clock-class-offset-ns': 2,
-        })
+        res = self._executor.query(
+            self._fs, 'trace-info', {'paths': self._paths, 'clock-class-offset-ns': 2}
+        )
         trace = res[0]
         self._check(trace, 2)
 
     # With both, negative
 
     def test_clock_class_offset_both(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-            'clock-class-offset-s': -2,
-            'clock-class-offset-ns': -2,
-        })
+        res = self._executor.query(
+            self._fs,
+            'trace-info',
+            {
+                'paths': self._paths,
+                'clock-class-offset-s': -2,
+                'clock-class-offset-ns': -2,
+            },
+        )
         trace = res[0]
         self._check(trace, -2000000002)
 
     def test_clock_class_offset_s_wrong_type(self):
         with self.assertRaises(bt2.InvalidParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-s': "2",
-            })
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-s': "2"},
+            )
 
     def test_clock_class_offset_s_wrong_type_none(self):
         with self.assertRaises(bt2.InvalidParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-s': None,
-            })
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-s': None},
+            )
 
     def test_clock_class_offset_ns_wrong_type(self):
         with self.assertRaises(bt2.InvalidParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-ns': "2",
-            })
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-ns': "2"},
+            )
 
     def test_clock_class_offset_ns_wrong_type_none(self):
         with self.assertRaises(bt2.InvalidParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-ns': None,
-            })
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-ns': None},
+            )
 
 
 class QueryTraceInfoPortNameTestCase(unittest.TestCase):
index d5274ae49d3cef72591ea88526fedf1b2d2db83c..77bf3613c3ebc752d9d2e9ca6a5f4091dba85053 100644 (file)
@@ -24,14 +24,12 @@ class MyIter(bt2._UserMessageIterator):
 
 
 @bt2.plugin_component_class
-class MySource(bt2._UserSourceComponent,
-               message_iterator_class=MyIter):
+class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
     pass
 
 
 @bt2.plugin_component_class
-class MyFilter(bt2._UserFilterComponent,
-               message_iterator_class=MyIter):
+class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
     pass
 
 
@@ -44,7 +42,11 @@ class MySink(bt2._UserSinkComponent):
         pass
 
 
-bt2.register_plugin(__name__, 'sparkling', author='Philippe Proulx',
-                    description='A delicious plugin.',
-                    version=(1, 2, 3, 'EXTRA'),
-                    license='MIT')
+bt2.register_plugin(
+    __name__,
+    'sparkling',
+    author='Philippe Proulx',
+    description='A delicious plugin.',
+    version=(1, 2, 3, 'EXTRA'),
+    license='MIT',
+)
index d3879b6a00ab9ff36e6f2b8b5409e43cca3587a7..6606246a0377e5c07d6ba30b7cff97c9d35d231a 100644 (file)
@@ -28,27 +28,31 @@ import argparse
 
 if __name__ == '__main__':
     argparser = argparse.ArgumentParser()
-    argparser.add_argument('-f', '--failfast',
-                           help='Stop on first fail or error',
-                           action='store_true')
+    argparser.add_argument(
+        '-f', '--failfast', help='Stop on first fail or error', action='store_true'
+    )
 
-    argparser.add_argument('start_dir',
-                           help='Base directory where to search for tests',
-                           type=str)
+    argparser.add_argument(
+        'start_dir', help='Base directory where to search for tests', type=str
+    )
 
     mut_exclu_group = argparser.add_mutually_exclusive_group(required=True)
 
-    mut_exclu_group.add_argument('-p', '--pattern',
-                           help='Glob-style pattern of test files to run '
-                           '(e.g. test_event*.py)',
-                           type=str)
-
-    mut_exclu_group.add_argument('-t', '--test-case',
-                           help='Run a specfic test module name, test class '
-                           'name, or test method name '
-                           '(e.g. test_event.EventTestCase.test_clock_value)',
-                           type=str)
+    mut_exclu_group.add_argument(
+        '-p',
+        '--pattern',
+        help='Glob-style pattern of test files to run ' '(e.g. test_event*.py)',
+        type=str,
+    )
 
+    mut_exclu_group.add_argument(
+        '-t',
+        '--test-case',
+        help='Run a specfic test module name, test class '
+        'name, or test method name '
+        '(e.g. test_event.EventTestCase.test_clock_value)',
+        type=str,
+    )
 
     args = argparser.parse_args()
 
@@ -70,7 +74,6 @@ if __name__ == '__main__':
         # else it will fail to parse.
         sys.exit(1)
 
-
     if tests.countTestCases() < 1:
         print("No tests matching '%s' found in '%s'" % (pattern, start_dir))
         sys.exit(1)
This page took 0.162993 seconds and 4 git commands to generate.