bt2: prepend `_user` to overridable protected methods
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 21:27:22 +0000 (17:27 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 25 Jul 2019 18:04:47 +0000 (14:04 -0400)
It is possible that, in the future, we add new, optional overridable
protected methods that the user can implement within a component class
or message iterator class to have new features.

There is the risk, however, that the user class already has a method
named as such. This would be considered a backward compatibility break
because the same user class with two different versions of Babeltrace 2
would not work the same way (and with the newest version, it probably
would not work at all).

To prevent this, this patch adds the `_user` namespace to all the
overridable protected methods. It will be documented that you cannot,
when you inherit one of the `bt2._User*` classes, have a method named
`_user_*()`, as this prefix is reserved for the future within the `bt2`
package.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I0c5ac29a21a83d6f644d0bb696f71d687ecfebae
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1777
Tested-by: jenkins <jenkins@lttng.org>
15 files changed:
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/native_bt_component_class.i
tests/bindings/python/bt2/test_component.py
tests/bindings/python/bt2/test_component_class.py
tests/bindings/python/bt2/test_connection.py
tests/bindings/python/bt2/test_error.py
tests/bindings/python/bt2/test_graph.py
tests/bindings/python/bt2/test_message_iterator.py
tests/bindings/python/bt2/test_port.py
tests/bindings/python/bt2/test_query_executor.py
tests/bindings/python/bt2/utils.py
tests/data/cli/auto-source-discovery/bt_plugin_test.py
tests/data/plugins/flt.utils.trimmer/bt_plugin_trimmer_test.py
tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py

index d26adc8f8b06081e63bf1251d4722af325426163..05ebe76114a36b6c79cdea1602d2255c7e2c8222 100644 (file)
@@ -484,9 +484,9 @@ class _UserComponentType(type):
                 cls, comp_cls_name, comp_cls_descr, comp_cls_help
             )
         elif _UserSinkComponent in bases:
-            if not hasattr(cls, '_consume'):
+            if not hasattr(cls, '_user_consume'):
                 raise bt2._IncompleteUserClass(
-                    "cannot create component class '{}': missing a _consume() method".format(
+                    "cannot create component class '{}': missing a _user_consume() method".format(
                         class_name
                     )
                 )
@@ -586,7 +586,7 @@ class _UserComponentType(type):
         )
 
         # this can raise, but the native side checks the exception
-        results = cls._query(query_exec, obj, params, log_level)
+        results = cls._user_query(query_exec, obj, params, log_level)
 
         # this can raise, but the native side checks the exception
         results = bt2.create_value(results)
@@ -602,7 +602,7 @@ class _UserComponentType(type):
 
         return int(results_ptr)
 
-    def _query(cls, query_executor, obj, params, log_level):
+    def _user_query(cls, query_executor, obj, params, log_level):
         raise NotImplementedError
 
     def _bt_component_class_ptr(self):
@@ -656,10 +656,10 @@ class _UserComponent(metaclass=_UserComponentType):
     def __init__(self, params=None):
         pass
 
-    def _finalize(self):
+    def _user_finalize(self):
         pass
 
-    def _port_connected(self, port, other_port):
+    def _user_port_connected(self, port, other_port):
         pass
 
     def _bt_port_connected_from_native(
@@ -675,7 +675,7 @@ class _UserComponent(metaclass=_UserComponentType):
         other_port = bt2_port._create_from_ptr_and_get_ref(
             other_port_ptr, other_port_type
         )
-        self._port_connected(port, other_port)
+        self._user_port_connected(port, other_port)
 
     def _create_trace_class(self, assigns_automatic_stream_class_id=True):
         ptr = self._bt_as_self_component_ptr(self._bt_ptr)
@@ -829,9 +829,9 @@ class _UserSinkComponent(_UserComponent, _SinkComponent):
     )
 
     def _bt_graph_is_configured_from_native(self):
-        self._graph_is_configured()
+        self._user_graph_is_configured()
 
-    def _graph_is_configured(self):
+    def _user_graph_is_configured(self):
         pass
 
     @property
index 8936c0dbfdf24c45d26e5708e4f4a23312ead8a2..c6c23dfd8b8848ea004f026036e86a3b48913925 100644 (file)
@@ -146,7 +146,7 @@ class _UserMessageIterator(_MessageIterator):
     def _is_interrupted(self):
         return bool(native_bt.self_message_iterator_is_interrupted(self._bt_ptr))
 
-    def _finalize(self):
+    def _user_finalize(self):
         pass
 
     def __next__(self):
@@ -173,19 +173,19 @@ class _UserMessageIterator(_MessageIterator):
     def _bt_can_seek_beginning_from_native(self):
         # Here, we mimic the behavior of the C API:
         #
-        # - If the iterator has a _can_seek_beginning attribute, read it and use
-        #   that result.
+        # - If the iterator has a _user_can_seek_beginning attribute,
+        #   read it and use that result.
         # - Otherwise, the presence or absence of a `_seek_beginning`
         #   method indicates whether the iterator can seek beginning.
-        if hasattr(self, '_can_seek_beginning'):
-            can_seek_beginning = self._can_seek_beginning
+        if hasattr(self, '_user_can_seek_beginning'):
+            can_seek_beginning = self._user_can_seek_beginning
             utils._check_bool(can_seek_beginning)
             return can_seek_beginning
         else:
-            return hasattr(self, '_seek_beginning')
+            return hasattr(self, '_user_seek_beginning')
 
     def _bt_seek_beginning_from_native(self):
-        self._seek_beginning()
+        self._user_seek_beginning()
 
     def _create_input_port_message_iterator(self, input_port):
         utils._check_type(input_port, bt2_port._UserComponentInputPort)
index bba59883329bf6afb1abef7de26c20ceb37003b1..e71e6bf8e7ed4d1f3e6328fe113ad6ef07e48569 100644 (file)
@@ -573,19 +573,19 @@ void component_class_finalize(bt_self_component *self_component)
        PyObject *py_comp = bt_self_component_get_data(self_component);
        BT_ASSERT(py_comp);
 
-       /* Call user's _finalize() method */
+       /* Call user's _user_finalize() method */
        PyObject *py_method_result = PyObject_CallMethod(py_comp,
-               "_finalize", NULL);
+               "_user_finalize", NULL);
 
        if (PyErr_Occurred()) {
-               BT_LOGW("User component's _finalize() method raised an exception: ignoring:");
+               BT_LOGW("User component's _user_finalize() method raised an exception: ignoring:");
                logw_exception();
        }
 
        /*
-        * Ignore any exception raised by the _finalize() method because
-        * it won't change anything at this point: the component is
-        * being destroyed anyway.
+        * Ignore any exception raised by the _user_finalize() method
+        * because it won't change anything at this point: the component
+        * is being destroyed anyway.
         */
        PyErr_Clear();
        Py_XDECREF(py_method_result);
@@ -1084,19 +1084,19 @@ void component_class_message_iterator_finalize(
 
        BT_ASSERT(py_message_iter);
 
-       /* Call user's _finalize() method */
+       /* Call user's _user_finalize() method */
        py_method_result = PyObject_CallMethod(py_message_iter,
-               "_finalize", NULL);
+               "_user_finalize", NULL);
 
        if (PyErr_Occurred()) {
-               BT_LOGW("User's _finalize() method raised an exception: ignoring:");
+               BT_LOGW("User's _user_finalize() method raised an exception: ignoring:");
                logw_exception();
        }
 
        /*
-        * Ignore any exception raised by the _finalize() method because
-        * it won't change anything at this point: the component is
-        * being destroyed anyway.
+        * Ignore any exception raised by the _user_finalize() method
+        * because it won't change anything at this point: the component
+        * is being destroyed anyway.
         */
        PyErr_Clear();
        Py_XDECREF(py_method_result);
@@ -1153,11 +1153,11 @@ component_class_sink_consume(bt_self_component_sink *self_component_sink)
 
        BT_ASSERT(py_comp);
        py_method_result = PyObject_CallMethod(py_comp,
-               "_consume", NULL);
+               "_user_consume", NULL);
        status = py_exc_to_status_component(self_component);
        if (!py_method_result && status == __BT_FUNC_STATUS_OK) {
                /* Pretty sure this should never happen, but just in case */
-               BT_LOGE("User's _consume() method failed without raising an exception: "
+               BT_LOGE("User's _user_consume() method failed without raising an exception: "
                        "status=%d", status);
                status = __BT_FUNC_STATUS_ERROR;
        }
index 69e5617b33808245ea0502f327fd699b1248da81..b61749ec58a28e0e54a6918f1fc7fb115429c139 100644 (file)
@@ -37,10 +37,7 @@ class UserComponentTestCase(unittest.TestCase):
             def __init__(comp_self, params):
                 self.assertEqual(comp_self.name, 'yaes')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink, 'yaes')
@@ -50,10 +47,7 @@ class UserComponentTestCase(unittest.TestCase):
             def __init__(comp_self, params):
                 self.assertEqual(comp_self.logging_level, bt2.LoggingLevel.INFO)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink, 'yaes', bt2.LoggingLevel.INFO)
@@ -63,10 +57,7 @@ class UserComponentTestCase(unittest.TestCase):
             def __init__(comp_self, params):
                 self.assertEqual(comp_self.cls, MySink)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -77,10 +68,7 @@ class UserComponentTestCase(unittest.TestCase):
                 self.assertIsInstance(comp_self.addr, int)
                 self.assertNotEqual(comp_self.addr, 0)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -89,13 +77,10 @@ class UserComponentTestCase(unittest.TestCase):
         finalized = False
 
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
-            def _finalize(comp_self):
+            def _user_finalize(comp_self):
                 nonlocal finalized
                 finalized = True
 
@@ -119,10 +104,7 @@ class GenericComponentTestCase(unittest.TestCase):
 
     def test_name(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink, 'yaes')
@@ -130,10 +112,7 @@ class GenericComponentTestCase(unittest.TestCase):
 
     def test_logging_level(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink, 'yaes', bt2.LoggingLevel.WARNING)
@@ -141,10 +120,7 @@ class GenericComponentTestCase(unittest.TestCase):
 
     def test_class(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -152,10 +128,7 @@ class GenericComponentTestCase(unittest.TestCase):
 
     def test_addr(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
index 909b2d642562c4d8b17ec98013529a1da3943a03..fd36d240ccce53284a8e05f30613bcc9fd98c199 100644 (file)
@@ -48,10 +48,7 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_no_init_sink(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._test_no_init(MySink)
@@ -108,28 +105,19 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_minimal_sink(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
     def test_default_name(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self.assertEqual(MySink.name, 'MySink')
 
     def test_custom_name(self):
         class MySink(bt2._UserSinkComponent, name='salut'):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self.assertEqual(MySink.name, 'salut')
@@ -138,10 +126,7 @@ class UserComponentClassTestCase(unittest.TestCase):
         with self.assertRaises(TypeError):
 
             class MySink(bt2._UserSinkComponent, name=23):
-                def _consume(self):
-                    pass
-
-                def _graph_is_configured(self):
+                def _user_consume(self):
                     pass
 
     def test_description(self):
@@ -156,10 +141,7 @@ class UserComponentClassTestCase(unittest.TestCase):
             cupim flank tenderloin.
             """
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self.assertEqual(MySink.description, 'The description.')
@@ -169,10 +151,7 @@ class UserComponentClassTestCase(unittest.TestCase):
             """
             """
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self.assertIsNone(MySink.description)
@@ -187,20 +166,14 @@ class UserComponentClassTestCase(unittest.TestCase):
             here.
             """
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self.assertEqual(MySink.help, 'The help\ntext is\nhere.')
 
     def test_addr(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self.assertIsInstance(MySink.addr, int)
@@ -208,10 +181,7 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_not_implemented(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         with self.assertRaises(bt2._Error):
@@ -219,14 +189,11 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_raises(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 raise ValueError
 
         with self.assertRaises(bt2._Error):
@@ -234,14 +201,11 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_wrong_return_type(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 return ...
 
         with self.assertRaises(bt2._Error):
@@ -249,14 +213,11 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_params_none(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
                 query_params = params
                 return None
@@ -270,14 +231,11 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_logging_level(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal query_log_level
                 query_log_level = log_level
 
@@ -288,14 +246,11 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_returns_none(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @staticmethod
-            def _query(query_exec, obj, params, log_level):
+            def _user_query(query_exec, obj, params, log_level):
                 return
 
         res = bt2.QueryExecutor().query(MySink, 'obj', None)
@@ -303,14 +258,11 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_simple(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
                 query_params = params
                 return 17.5
@@ -324,14 +276,11 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_query_complex(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
                 query_params = params
                 return {'null': None, 'bt2': 'BT2'}
@@ -350,10 +299,7 @@ class UserComponentClassTestCase(unittest.TestCase):
 
     def test_eq(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self.assertEqual(MySink, MySink)
@@ -368,14 +314,11 @@ class ComponentClassTestCase(unittest.TestCase):
             The help.
             '''
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 return [obj, params, 23]
 
         self._py_comp_cls = MySink
index fc5c546e5ae6315d709ebe6a48de861e20f58981..898c68711f7a936c92032802692685d0414883d4 100644 (file)
@@ -34,12 +34,9 @@ class ConnectionTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         graph = bt2.Graph()
         src = graph.add_component(MySource, 'src')
         sink = graph.add_component(MySink, 'sink')
@@ -58,12 +55,9 @@ class ConnectionTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         graph = bt2.Graph()
         src = graph.add_component(MySource, 'src')
         sink = graph.add_component(MySink, 'sink')
@@ -83,12 +77,9 @@ class ConnectionTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         graph = bt2.Graph()
         src = graph.add_component(MySource, 'src')
         sink = graph.add_component(MySink, 'sink')
index 9ae8b36c08090e51be8cde73893cc84d13ad5df8..ca750aea6cd4acfe80987d836eab1e4c07d1af23 100644 (file)
@@ -44,10 +44,10 @@ class WorkingSink(bt2._UserSinkComponent):
     def __init__(self, params):
         self._in = self._add_input_port('in')
 
-    def _graph_is_configured(self):
+    def _user_graph_is_configured(self):
         self._iter = self._create_input_port_message_iterator(self._in)
 
-    def _consume(self):
+    def _user_consume(self):
         next(self._iter)
 
 
@@ -55,10 +55,10 @@ class SinkWithExceptionChaining(bt2._UserSinkComponent):
     def __init__(self, params):
         self._in = self._add_input_port('in')
 
-    def _graph_is_configured(self):
+    def _user_graph_is_configured(self):
         self._iter = self._create_input_port_message_iterator(self._in)
 
-    def _consume(self):
+    def _user_consume(self):
         try:
             next(self._iter)
         except bt2._Error as e:
@@ -66,14 +66,11 @@ class SinkWithExceptionChaining(bt2._UserSinkComponent):
 
 
 class SinkWithFailingQuery(bt2._UserSinkComponent):
-    def _graph_is_configured(self):
-        pass
-
-    def _consume(self):
+    def _user_consume(self):
         pass
 
     @staticmethod
-    def _query(executor, obj, params, log_level):
+    def _user_query(executor, obj, params, log_level):
         raise ValueError('Query is failing')
 
 
index 453a62ed7a115f9f71ad8d72e93b89537473dde3..bda08de2ec874aecb0c016c7e171fd14bf73e3e9 100644 (file)
@@ -59,10 +59,7 @@ class GraphTestCase(unittest.TestCase):
 
     def test_add_component_user_cls(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._graph.add_component(MySink, 'salut')
@@ -70,10 +67,7 @@ class GraphTestCase(unittest.TestCase):
 
     def test_add_component_gen_cls(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._graph.add_component(MySink, 'salut')
@@ -89,10 +83,7 @@ class GraphTestCase(unittest.TestCase):
                 nonlocal comp_params
                 comp_params = params
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         params = {'hello': 23, 'path': '/path/to/stuff'}
@@ -106,10 +97,7 @@ class GraphTestCase(unittest.TestCase):
 
     def test_add_component_invalid_logging_level_type(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         with self.assertRaises(TypeError):
@@ -117,10 +105,7 @@ class GraphTestCase(unittest.TestCase):
 
     def test_add_component_invalid_logging_level_value(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         with self.assertRaises(ValueError):
@@ -128,10 +113,7 @@ class GraphTestCase(unittest.TestCase):
 
     def test_add_component_logging_level(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._graph.add_component(
@@ -152,12 +134,9 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
 
@@ -182,12 +161,9 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
 
@@ -209,10 +185,10 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 next(self._msg_iter)
 
-            def _graph_is_configured(self):
+            def _user_graph_is_configured(self):
                 self._msg_iter = self._create_input_port_message_iterator(
                     self._input_ports['in']
                 )
@@ -254,13 +230,13 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 # Pretend that somebody asynchronously interrupted the graph.
                 nonlocal graph
                 graph.interrupt()
                 return next(self._msg_iter)
 
-            def _graph_is_configured(self):
+            def _user_graph_is_configured(self):
                 self._msg_iter = self._create_input_port_message_iterator(
                     self._input_ports['in']
                 )
@@ -302,7 +278,7 @@ class GraphTestCase(unittest.TestCase):
                 self._input_port = self._add_input_port('in')
                 self._at = 0
 
-            def _consume(comp_self):
+            def _user_consume(comp_self):
                 msg = next(comp_self._msg_iter)
 
                 if comp_self._at == 0:
@@ -319,7 +295,7 @@ class GraphTestCase(unittest.TestCase):
 
                 comp_self._at += 1
 
-            def _graph_is_configured(self):
+            def _user_graph_is_configured(self):
                 self._msg_iter = self._create_input_port_message_iterator(
                     self._input_port
                 )
@@ -356,7 +332,7 @@ class GraphTestCase(unittest.TestCase):
                 self._input_port = self._add_input_port('in')
                 self._at = 0
 
-            def _consume(comp_self):
+            def _user_consume(comp_self):
                 msg = next(comp_self._msg_iter)
                 if comp_self._at == 0:
                     self.assertIsInstance(msg, bt2._StreamBeginningMessage)
@@ -370,7 +346,7 @@ class GraphTestCase(unittest.TestCase):
 
                 comp_self._at += 1
 
-            def _graph_is_configured(self):
+            def _user_graph_is_configured(self):
                 self._msg_iter = self._create_input_port_message_iterator(
                     self._input_port
                 )
@@ -414,7 +390,7 @@ class GraphTestCase(unittest.TestCase):
                 self._input_port = self._add_input_port('in')
                 self._at = 0
 
-            def _consume(comp_self):
+            def _user_consume(comp_self):
                 msg = next(comp_self._msg_iter)
                 if comp_self._at == 0:
                     self.assertIsInstance(msg, bt2._StreamBeginningMessage)
@@ -429,7 +405,7 @@ class GraphTestCase(unittest.TestCase):
 
                 comp_self._at += 1
 
-            def _graph_is_configured(self):
+            def _user_graph_is_configured(self):
                 self._msg_iter = self._create_input_port_message_iterator(
                     self._input_port
                 )
@@ -457,13 +433,10 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
-            def _port_connected(self, port, other_port):
+            def _user_port_connected(self, port, other_port):
                 self._add_input_port('taste')
 
         def port_added_listener(component, port):
@@ -529,13 +502,10 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
-            def _port_connected(self, port, other_port):
+            def _user_port_connected(self, port, other_port):
                 self._add_input_port('taste')
 
         with self.assertRaises(TypeError):
@@ -548,12 +518,9 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 raise ValueError('oops!')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         graph = bt2.Graph()
 
         with self.assertRaises(bt2._Error):
@@ -564,12 +531,9 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         def port_added_listener(component, port):
             raise ValueError('oh noes!')
 
@@ -592,12 +556,9 @@ class GraphTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 raise bt2.Stop
 
-            def _graph_is_configured(self):
-                pass
-
         def ports_connected_listener(
             upstream_component, upstream_port, downstream_component, downstream_port
         ):
index c8d2cf16806d22566149995ee8c97c9c15906f34..08be7d008dd908306dcc5581486618a516e80b88 100644 (file)
@@ -30,10 +30,10 @@ class UserMessageIteratorTestCase(unittest.TestCase):
             def __init__(self, params):
                 self._add_input_port('in')
 
-            def _consume(self):
+            def _user_consume(self):
                 next(self._msg_iter)
 
-            def _graph_is_configured(self):
+            def _user_graph_is_configured(self):
                 self._msg_iter = self._create_input_port_message_iterator(
                     self._input_ports['in']
                 )
@@ -118,7 +118,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
 
     def test_finalize(self):
         class MyIter(bt2._UserMessageIterator):
-            def _finalize(self):
+            def _user_finalize(self):
                 nonlocal finalized
                 finalized = True
 
@@ -235,7 +235,7 @@ class UserMessageIteratorTestCase(unittest.TestCase):
                 ]
                 self._at = 0
 
-            def _seek_beginning(self):
+            def _user_seek_beginning(self):
                 self._at = 0
 
             def __next__(self):
@@ -264,11 +264,11 @@ class UserMessageIteratorTestCase(unittest.TestCase):
             def __next__(self):
                 return next(self._upstream_iter)
 
-            def _seek_beginning(self):
+            def _user_seek_beginning(self):
                 self._upstream_iter.seek_beginning()
 
             @property
-            def _can_seek_beginning(self):
+            def _user_can_seek_beginning(self):
                 return self._upstream_iter.can_seek_beginning
 
         class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyFilterIter):
@@ -287,11 +287,11 @@ class UserMessageIteratorTestCase(unittest.TestCase):
     def test_can_seek_beginning(self):
         it, MySourceIter = self._setup_seek_beginning_test()
 
-        def _can_seek_beginning(self):
+        def _user_can_seek_beginning(self):
             nonlocal can_seek_beginning
             return can_seek_beginning
 
-        MySourceIter._can_seek_beginning = property(_can_seek_beginning)
+        MySourceIter._user_can_seek_beginning = property(_user_can_seek_beginning)
 
         can_seek_beginning = True
         self.assertTrue(it.can_seek_beginning)
@@ -305,10 +305,10 @@ class UserMessageIteratorTestCase(unittest.TestCase):
         # Remove the _can_seek_beginning method, we now rely on the presence of
         # a _seek_beginning method to know whether the iterator can seek to
         # beginning or not.
-        del MySourceIter._can_seek_beginning
+        del MySourceIter._user_can_seek_beginning
         self.assertTrue(it.can_seek_beginning)
 
-        del MySourceIter._seek_beginning
+        del MySourceIter._user_seek_beginning
         self.assertFalse(it.can_seek_beginning)
 
     def test_seek_beginning(self):
@@ -343,10 +343,10 @@ class UserMessageIteratorTestCase(unittest.TestCase):
     def test_seek_beginning_user_error(self):
         it, MySourceIter = self._setup_seek_beginning_test()
 
-        def _seek_beginning_error(self):
+        def _user_seek_beginning_error(self):
             raise ValueError('ouch')
 
-        MySourceIter._seek_beginning = _seek_beginning_error
+        MySourceIter._user_seek_beginning = _user_seek_beginning_error
 
         with self.assertRaises(bt2._Error):
             it.seek_beginning()
index 35d8797e8973036f66479b6e9653487ff3dce023..8be3f38cb2868ce3d691568e2a8e008797bec5c7 100644 (file)
@@ -75,10 +75,7 @@ class PortTestCase(unittest.TestCase):
                 port = comp_self._add_input_port('in')
                 self.assertEqual(port.name, 'in')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -142,10 +139,7 @@ class PortTestCase(unittest.TestCase):
                 self.assertEqual(port2.addr, comp_self._input_ports['print'].addr)
                 self.assertEqual(port1.addr, comp_self._input_ports['clear'].addr)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -208,10 +202,7 @@ class PortTestCase(unittest.TestCase):
                 with self.assertRaises(KeyError):
                     comp_self._input_ports['hello']
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -266,10 +257,7 @@ class PortTestCase(unittest.TestCase):
                 comp_self._add_input_port('insert')
                 self.assertEqual(len(comp_self._input_ports), 3)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -364,10 +352,7 @@ class PortTestCase(unittest.TestCase):
                 self.assertEqual(ports[2][0], 'insert')
                 self.assertEqual(ports[2][1].addr, port3.addr)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -456,10 +441,7 @@ class PortTestCase(unittest.TestCase):
                 port2 = comp_self._add_input_port('print')
                 port3 = comp_self._add_input_port('insert')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -528,10 +510,7 @@ class PortTestCase(unittest.TestCase):
                 with self.assertRaises(KeyError):
                     comp_self._input_ports['hello']
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -588,10 +567,7 @@ class PortTestCase(unittest.TestCase):
                 comp_self._add_input_port('print')
                 comp_self._add_input_port('insert')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -705,10 +681,7 @@ class PortTestCase(unittest.TestCase):
                 port2 = comp_self._add_input_port('print')
                 port3 = comp_self._add_input_port('insert')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -732,10 +705,7 @@ class PortTestCase(unittest.TestCase):
             def __init__(comp_self, params):
                 comp_self._add_input_port('clear')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -746,10 +716,7 @@ class PortTestCase(unittest.TestCase):
             def __init__(comp_self, params):
                 comp_self._add_input_port('clear')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -760,10 +727,7 @@ class PortTestCase(unittest.TestCase):
             def __init__(comp_self, params):
                 comp_self._add_input_port('clear')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         comp = self._create_comp(MySink)
@@ -775,10 +739,7 @@ class PortTestCase(unittest.TestCase):
                 port = comp_self._add_input_port('clear')
                 self.assertEqual(port.name, 'clear')
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -789,10 +750,7 @@ class PortTestCase(unittest.TestCase):
                 port = comp_self._add_input_port('clear')
                 self.assertIsNone(port.connection)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
@@ -803,10 +761,7 @@ class PortTestCase(unittest.TestCase):
                 port = comp_self._add_input_port('clear')
                 self.assertFalse(port.is_connected)
 
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
         self._create_comp(MySink)
index 52af46649eb9afa3ab3ebe277de928695b2da1c4..e4f1fa5b14e9a22c1a77f3d62ec12b063acdf703 100644 (file)
@@ -25,14 +25,11 @@ import bt2
 class QueryExecutorTestCase(unittest.TestCase):
     def test_query(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
                 query_params = params
                 return {'null': None, 'bt2': 'BT2'}
@@ -51,14 +48,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_params_none(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
                 query_params = params
 
@@ -69,14 +63,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_logging_level(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal query_log_level
                 query_log_level = log_level
 
@@ -87,14 +78,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_gen_error(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 raise ValueError
 
         with self.assertRaises(bt2._Error) as ctx:
@@ -110,14 +98,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_invalid_object(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 raise bt2.InvalidObject
 
         with self.assertRaises(bt2.InvalidObject):
@@ -125,14 +110,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_logging_level_invalid_type(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 pass
 
         with self.assertRaises(TypeError):
@@ -140,14 +122,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_logging_level_invalid_value(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 pass
 
         with self.assertRaises(ValueError):
@@ -155,14 +134,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_try_again(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 raise bt2.TryAgain
 
         with self.assertRaises(bt2.TryAgain):
@@ -170,14 +146,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_add_interrupter(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 nonlocal interrupter2
                 test_self.assertFalse(query_exec.is_interrupted)
                 interrupter2.set()
@@ -195,14 +168,11 @@ class QueryExecutorTestCase(unittest.TestCase):
 
     def test_query_interrupt(self):
         class MySink(bt2._UserSinkComponent):
-            def _consume(self):
-                pass
-
-            def _graph_is_configured(self):
+            def _user_consume(self):
                 pass
 
             @classmethod
-            def _query(cls, query_exec, obj, params, log_level):
+            def _user_query(cls, query_exec, obj, params, log_level):
                 test_self.assertFalse(query_exec.is_interrupted)
                 query_exec.interrupt()
                 test_self.assertTrue(query_exec.is_interrupted)
index fb4003a3e76a452ce6a5e121a26083bae67e330f..46be6fe22524ac369b5057616a671f4c873be668 100644 (file)
@@ -30,10 +30,7 @@ def run_in_component_init(func):
             nonlocal res_bound
             res_bound = func(self)
 
-        def _consume(self):
-            pass
-
-        def _graph_is_configured(self):
+        def _user_consume(self):
             pass
 
     g = bt2.Graph()
index 8d65b3d00882b1a044e155531cd60a3a796bf0c9..002e9c33e3474c82a41c7251f9ff1431069a6f26 100644 (file)
@@ -26,7 +26,7 @@ class TestSourceExt(Base, bt2._UserSourceComponent, message_iterator_class=TestI
         self._print_params(params)
 
     @staticmethod
-    def _query(query_exec, obj, params, log_level):
+    def _user_query(query_exec, obj, params, log_level):
         if obj == 'support-info':
             if params['type'] == 'file':
                 name = os.path.basename(str(params['input']))
@@ -64,7 +64,7 @@ class TestSourceSomeDir(
         self._print_params(params)
 
     @staticmethod
-    def _query(query_exec, obj, params, log_level):
+    def _user_query(query_exec, obj, params, log_level):
         if obj == 'support-info':
             if params['type'] == 'directory':
                 name = os.path.basename(str(params['input']))
@@ -83,7 +83,7 @@ class TestSourceABCDE(Base, bt2._UserSourceComponent, message_iterator_class=Tes
         self._print_params(params)
 
     @staticmethod
-    def _query(query_exec, obj, params, log_level):
+    def _user_query(query_exec, obj, params, log_level):
         if obj == 'support-info':
             return (
                 1.0
index 0fdb78f9f56ff4f94b5cdfff10c69ec67200b83f..69abd1aabb86450bfc4ba065c6a9884d0ffd7b4d 100644 (file)
@@ -33,7 +33,7 @@ class TheIteratorOfAllEvil(bt2._UserMessageIterator):
         ]
         self._at = 0
 
-    def _seek_beginning(self):
+    def _user_seek_beginning(self):
         self._at = 0
 
     def __next__(self):
index 77bf3613c3ebc752d9d2e9ca6a5f4091dba85053..cdac06702fe7bee8e6ada98240641caffbe9872a 100644 (file)
@@ -35,10 +35,7 @@ class MyFilter(bt2._UserFilterComponent, message_iterator_class=MyIter):
 
 @bt2.plugin_component_class
 class MySink(bt2._UserSinkComponent):
-    def _consume(self):
-        pass
-
-    def _graph_is_configured(self):
+    def _user_consume(self):
         pass
 
 
This page took 0.046078 seconds and 4 git commands to generate.