bt2: rename `_Generic*ComponentClass` -> `_*ComponentClass`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 18:04:07 +0000 (14:04 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 25 Jul 2019 18:04:47 +0000 (14:04 -0400)
Those are public names, in that they exist within the `bt2` package, so
those simpler names feel more natural.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9f762e44a8cb1560194c33a3f0be17eb3475f97c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1767
Tested-by: jenkins <jenkins@lttng.org>
src/bindings/python/bt2/bt2/__init__.py.in
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/graph.py
src/bindings/python/bt2/bt2/query_executor.py
tests/bindings/python/bt2/test_component_class.py

index b3a83a981cace0847402bd713f4245ae5e831474..76e8e9b99d2805a105ef04c59e2df04732cf26da 100644 (file)
@@ -28,9 +28,9 @@ from bt2.clock_class import *
 from bt2.clock_snapshot import *
 from bt2.component import *
 from bt2.component import _FilterComponent
-from bt2.component import _GenericFilterComponentClass
-from bt2.component import _GenericSinkComponentClass
-from bt2.component import _GenericSourceComponentClass
+from bt2.component import _FilterComponentClass
+from bt2.component import _SinkComponentClass
+from bt2.component import _SourceComponentClass
 from bt2.component import _SinkComponent
 from bt2.component import _SourceComponent
 from bt2.component import _UserFilterComponent
index 43e3ce1645bb90fe4c4a80f9e4b853ea70640af1..3557445681c0cb5dee1adb43cced1a0205888e4c 100644 (file)
@@ -42,7 +42,7 @@ import os
 #     pointer to a 'bt_component_class *'.
 
 
-class _GenericComponentClass(object._SharedObject):
+class _ComponentClass(object._SharedObject):
     @property
     def name(self):
         ptr = self._bt_as_component_class_ptr(self._ptr)
@@ -64,7 +64,7 @@ class _GenericComponentClass(object._SharedObject):
         return self._bt_as_component_class_ptr(self._ptr)
 
     def __eq__(self, other):
-        if not isinstance(other, _GenericComponentClass):
+        if not isinstance(other, _ComponentClass):
             try:
                 if not issubclass(other, _UserComponent):
                     return False
@@ -74,7 +74,7 @@ class _GenericComponentClass(object._SharedObject):
         return self.addr == other.addr
 
 
-class _GenericSourceComponentClass(_GenericComponentClass):
+class _SourceComponentClass(_ComponentClass):
     _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(
@@ -82,7 +82,7 @@ class _GenericSourceComponentClass(_GenericComponentClass):
     )
 
 
-class _GenericFilterComponentClass(_GenericComponentClass):
+class _FilterComponentClass(_ComponentClass):
     _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(
@@ -90,7 +90,7 @@ class _GenericFilterComponentClass(_GenericComponentClass):
     )
 
 
-class _GenericSinkComponentClass(_GenericComponentClass):
+class _SinkComponentClass(_ComponentClass):
     _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(
@@ -233,7 +233,7 @@ class _SinkComponent(_Component):
     _bt_as_component_ptr = staticmethod(native_bt.component_sink_as_component_const)
 
 
-# This is analogous to _GenericSourceComponentClass, but for source
+# This is analogous to _SourceComponentClass, but for source
 # component objects.
 class _GenericSourceComponent(object._SharedObject, _SourceComponent):
     _get_ref = staticmethod(native_bt.component_source_get_ref)
@@ -250,7 +250,7 @@ class _GenericSourceComponent(object._SharedObject, _SourceComponent):
         )
 
 
-# This is analogous to _GenericFilterComponentClass, but for filter
+# This is analogous to _FilterComponentClass, but for filter
 # component objects.
 class _GenericFilterComponent(object._SharedObject, _FilterComponent):
     _get_ref = staticmethod(native_bt.component_filter_get_ref)
@@ -277,7 +277,7 @@ class _GenericFilterComponent(object._SharedObject, _FilterComponent):
         )
 
 
-# This is analogous to _GenericSinkComponentClass, but for sink
+# This is analogous to _SinkComponentClass, but for sink
 # component objects.
 class _GenericSinkComponent(object._SharedObject, _SinkComponent):
     _get_ref = staticmethod(native_bt.component_sink_get_ref)
@@ -302,9 +302,9 @@ _COMP_CLS_TYPE_TO_GENERIC_COMP_PYCLS = {
 
 
 _COMP_CLS_TYPE_TO_GENERIC_COMP_CLS_PYCLS = {
-    native_bt.COMPONENT_CLASS_TYPE_SOURCE: _GenericSourceComponentClass,
-    native_bt.COMPONENT_CLASS_TYPE_FILTER: _GenericFilterComponentClass,
-    native_bt.COMPONENT_CLASS_TYPE_SINK: _GenericSinkComponentClass,
+    native_bt.COMPONENT_CLASS_TYPE_SOURCE: _SourceComponentClass,
+    native_bt.COMPONENT_CLASS_TYPE_FILTER: _FilterComponentClass,
+    native_bt.COMPONENT_CLASS_TYPE_SINK: _SinkComponentClass,
 }
 
 
@@ -330,8 +330,8 @@ def _create_component_from_ptr_and_get_ref(ptr, comp_cls_type):
 
 
 # Create a component class Python object of type
-# _GenericSourceComponentClass, _GenericFilterComponentClass or
-# _GenericSinkComponentClass, depending on comp_cls_type.
+# _SourceComponentClass, _FilterComponentClass or
+# _SinkComponentClass, depending on comp_cls_type.
 #
 # Acquires a new reference to ptr.
 
@@ -379,7 +379,7 @@ def _trim_docstring(docstring):
 # creates a native BT component class of the corresponding type and
 # associates it with this user-defined class. The metaclass also defines
 # class methods like the `name` and `description` properties to match
-# the _GenericComponentClass interface.
+# the _ComponentClass interface.
 #
 # The component class name which is used is either:
 #
index 6d083228ba3c6e951a6d09bb024cbb94496144c1..575747af1ee68096bcbb001c4d47a18c4ca16493 100644 (file)
@@ -85,15 +85,15 @@ class Graph(object._SharedObject):
         params=None,
         logging_level=bt2.logging.LoggingLevel.NONE,
     ):
-        if isinstance(component_class, bt2.component._GenericSourceComponentClass):
+        if isinstance(component_class, bt2.component._SourceComponentClass):
             cc_ptr = component_class._ptr
             add_fn = native_bt.graph_add_source_component
             cc_type = native_bt.COMPONENT_CLASS_TYPE_SOURCE
-        elif isinstance(component_class, bt2.component._GenericFilterComponentClass):
+        elif isinstance(component_class, bt2.component._FilterComponentClass):
             cc_ptr = component_class._ptr
             add_fn = native_bt.graph_add_filter_component
             cc_type = native_bt.COMPONENT_CLASS_TYPE_FILTER
-        elif isinstance(component_class, bt2.component._GenericSinkComponentClass):
+        elif isinstance(component_class, bt2.component._SinkComponentClass):
             cc_ptr = component_class._ptr
             add_fn = native_bt.graph_add_sink_component
             cc_type = native_bt.COMPONENT_CLASS_TYPE_SINK
index e9d3d761b16fba6f0a251598412737193c303cea..2a99ef961a1299fddda2c45c2873bdc54f21a9bb 100644 (file)
@@ -58,7 +58,7 @@ class QueryExecutor(object._SharedObject):
         params=None,
         logging_level=bt2.logging.LoggingLevel.NONE,
     ):
-        if not isinstance(component_class, bt2.component._GenericComponentClass):
+        if not isinstance(component_class, bt2.component._ComponentClass):
             err = False
 
             try:
index 7ed554d674256677723f6c1a8211b4d9b72ec238..58e5a863d76bbf8b5d8f4c221dcabfb53b496c71 100644 (file)
@@ -359,7 +359,7 @@ class UserComponentClassTestCase(unittest.TestCase):
         self.assertEqual(MySink, MySink)
 
 
-class GenericComponentClassTestCase(unittest.TestCase):
+class ComponentClassTestCase(unittest.TestCase):
     def setUp(self):
         class MySink(bt2._UserSinkComponent):
             '''
@@ -382,9 +382,7 @@ 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._ComponentClass))
 
     def tearDown(self):
         del self._py_comp_cls
This page took 0.029417 seconds and 4 git commands to generate.