Skip to content

Commit 83ee61a

Browse files
Sebastian Wagnerwaldbauer-certat
authored andcommitted
BUG: lib/utils: list_all_bots: exclude Bot paramers
exclude parameters of the parent Bot class if the values are not different (i.e. global defaults).
1 parent 296822b commit 83ee61a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

intelmq/lib/utils.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,13 +822,26 @@ def file_name_from_response(response: requests.Response) -> str:
822822

823823

824824
def list_all_bots() -> dict:
825+
"""
826+
Compile a dictionary with all bots and their parameters.
827+
828+
Includes
829+
* the bots' names
830+
* the description from the docstring
831+
* parameters including default values.
832+
833+
For the parameters, parameters of the Bot class are excluded if they have the same value.
834+
"""
825835
bots = {
826836
'Collector': {},
827837
'Parser': {},
828838
'Expert': {},
829839
'Output': {},
830840
}
831841

842+
from intelmq.lib.bot import Bot # noqa: prevents circular import
843+
bot_parameters = dir(Bot)
844+
832845
base_path = resource_filename('intelmq', 'bots')
833846

834847
botfiles = [botfile for botfile in pathlib.Path(base_path).glob('**/*.py') if botfile.is_file() and botfile.name != '__init__.py']
@@ -841,7 +854,9 @@ def list_all_bots() -> dict:
841854
variables = sorted((key) for key in dir(mod.BOT) if not key.isupper() and not key.startswith('_'))
842855
for variable in variables:
843856
value = getattr(mod.BOT, variable)
844-
if not inspect.ismethod(value) and not inspect.isfunction(value) and not inspect.isclass(value) and not inspect.isroutine(value):
857+
if (not inspect.ismethod(value) and not inspect.isfunction(value) and
858+
not inspect.isclass(value) and not inspect.isroutine(value) and
859+
not (variable in bot_parameters and getattr(Bot, variable) == value)):
845860
keys[variable] = value
846861

847862
for bot_type in ['CollectorBot', 'ParserBot', 'OutputBot', 'Bot']:

0 commit comments

Comments
 (0)