Skip to content

Commit 14310a5

Browse files
[FIX] setup.py load bots module-names dynamically
Signed-off-by: Sebastian Waldbauer <[email protected]>
1 parent 1a4b8cf commit 14310a5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import sys
6+
from pathlib import Path
67

78
from setuptools import find_packages, setup
89

@@ -19,11 +20,12 @@
1920
exec(open(os.path.join(os.path.dirname(__file__),
2021
'intelmq/version.py')).read()) # defines __version__
2122
BOTS = []
22-
bots = json.load(open(os.path.join(os.path.dirname(__file__), 'intelmq/bots/BOTS')))
23-
for bot_type, bots in bots.items():
24-
for bot_name, bot in bots.items():
25-
module = bot['module']
26-
BOTS.append('{0} = {0}:BOT.run'.format(module))
23+
24+
base_path = Path(__file__).parent / 'intelmq/bots'
25+
botfiles = [botfile for botfile in Path(base_path).glob('**/*.py') if botfile.is_file() and not botfile.name.startswith('_')]
26+
for file in botfiles:
27+
module = '.'.join(file.with_suffix('').parts)
28+
BOTS.append('{0} = {0}:BOT.run'.format(module))
2729

2830
with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as handle:
2931
README = handle.read()

0 commit comments

Comments
 (0)