4 # This file defines source component classes that can print (depending the on
7 # - Parameter names and values, for parameter whose name starts with `test-`.
8 # - Component log levels as integers
11 class TestIter(bt2
._UserMessageIterator
):
17 def _print_test_params(cls
, params
):
18 items
= sorted([str(x
) for x
in params
.items() if x
[0].startswith('test-')])
19 print('{}: {}'.format(cls
.__name
__, ', '.join(items
)))
21 def _print_log_level(self
):
22 cls_name
= self
.__class
__.__name
__
23 log_level
= self
.logging_level
24 print('{}: {}'.format(cls_name
, log_level
))
26 def _print_info(self
, params
):
27 what
= params
['print']
28 if what
== 'test-params':
29 self
._print
_test
_params
(params
)
30 elif what
== 'log-level':
31 self
._print
_log
_level
()
36 @bt2.plugin_component_class
37 class TestSourceA(Base
, bt2
._UserSourceComponent
, message_iterator_class
=TestIter
):
38 def __init__(self
, params
):
39 self
._print
_info
(params
)
42 def _user_query(priv_query_exec
, obj
, params
, method_obj
):
43 # Match files starting with 'aaa'.
45 if obj
== 'babeltrace.support-info':
46 if params
['type'] != 'file':
49 name
= os
.path
.basename(str(params
['input']))
51 if name
.startswith('aaa'):
52 return {'weight': 1, 'group': 'aaa'}
56 raise bt2
.UnknownObject
59 @bt2.plugin_component_class
60 class TestSourceB(Base
, bt2
._UserSourceComponent
, message_iterator_class
=TestIter
):
61 def __init__(self
, params
):
62 self
._print
_info
(params
)
65 def _user_query(priv_query_exec
, obj
, params
, method_obj
):
66 # Match files starting with 'bbb'.
68 if obj
== 'babeltrace.support-info':
69 if params
['type'] != 'file':
72 name
= os
.path
.basename(str(params
['input']))
74 if name
.startswith('bbb'):
75 return {'weight': 1, 'group': 'bbb'}
79 raise bt2
.UnknownObject
82 bt2
.register_plugin(module_name
=__name__
, name
="test")
This page took 0.031483 seconds and 4 git commands to generate.