4 # This file defines source component classes that print the parameters they
5 # receive in their __init__ which start with 'test-'.
8 class TestIter(bt2
._UserMessageIterator
):
14 def _print_test_params(cls
, params
):
15 items
= sorted([str(x
) for x
in params
.items() if x
[0].startswith('test-')])
16 print('{}: {}'.format(cls
.__name
__, ', '.join(items
)))
19 @bt2.plugin_component_class
20 class TestSourceA(Base
, bt2
._UserSourceComponent
, message_iterator_class
=TestIter
):
21 def __init__(self
, params
):
22 self
._print
_test
_params
(params
)
25 def _user_query(priv_query_exec
, obj
, params
):
26 # Match files starting with 'aaa'.
28 if obj
== 'babeltrace.support-info':
29 if params
['type'] != 'file':
32 name
= os
.path
.basename(str(params
['input']))
34 if name
.startswith('aaa'):
35 return {'weight': 1, 'group': 'aaa'}
39 raise bt2
.UnknownObject
42 @bt2.plugin_component_class
43 class TestSourceB(Base
, bt2
._UserSourceComponent
, message_iterator_class
=TestIter
):
44 def __init__(self
, params
):
45 self
._print
_test
_params
(params
)
48 def _user_query(priv_query_exec
, obj
, params
):
49 # Match files starting with 'bbb'.
51 if obj
== 'babeltrace.support-info':
52 if params
['type'] != 'file':
55 name
= os
.path
.basename(str(params
['input']))
57 if name
.startswith('bbb'):
58 return {'weight': 1, 'group': 'bbb'}
62 raise bt2
.UnknownObject
65 bt2
.register_plugin(module_name
=__name__
, name
="test")
This page took 0.032868 seconds and 5 git commands to generate.