-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change to namespace package #2393
Conversation
It should change the bots folder to a namespace package. Now it should be easier to add new Bot. I used pkgutil-style namespace packages.
It should change the bots folder to a namespace package. Now it should be easier to add new Bot. I used pkgutil-style namespace packages. Implements certtools#2350
Fixed the 'intelmqctl list bots' funcionality, now it works for namespaces. Added documentation how to add a new bot. Added changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work so far. Would be very cool if we can get this feature done :)
botmodules = [] | ||
for path, name, is_pkg in iter_modules(pkg.__path__, pkg.__name__ + '.'): | ||
if is_pkg: | ||
botmodules = botmodules + iter_ns(importlib.import_module(name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line causes the current unit test failures (import of a SyntaxError-throwing-bot fails with a SyntaxError, which is not handled correctly here). An example of catching the exception is nine lines below.
@@ -0,0 +1 @@ | |||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing newlines missing here and in the other similar files
@@ -0,0 +1,33 @@ | |||
Metadata-Version: 2.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these files should be part of the repository, should they?
|
||
setup( | ||
name='intelmqExampleAddBot', | ||
version=3.1, # noqa: F821 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a string AFAIK. And let's use semantic versioning
version=3.1, # noqa: F821 | |
version='3.1.0', |
maintainer='Sebastian Wagner', | ||
maintainer_email='[email protected]', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to be responsible for code which I never wrote and never saw =)
maintainer='Sebastian Wagner', | |
maintainer_email='[email protected]', | |
maintainer='Your Name', | |
maintainer_email='[email protected]', |
version=3.1, # noqa: F821 | ||
maintainer='Sebastian Wagner', | ||
maintainer_email='[email protected]', | ||
python_requires='>=3.7', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python_requires='>=3.7', |
intelmq itself requires python >= 3.7 currently, that may not be true for bots. as the bots require the core library anyway, the requirement is active too without listing it here
└── your_bot.py | ||
|
||
The ``additional_bots`` folder needs to be defined e.g. with a ``setup.py``. Only the intelmq folder contains a ``__init__.py`` | ||
file and it must contain only this line. Any additional code in ``__init__.py`` after this line will be inaccessible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file and it must contain only this line. Any additional code in ``__init__.py`` after this line will be inaccessible. | |
file, which must have only the following line. Any additional code in ``__init__.py`` after this line will be inaccessible. |
botfiles = [botfile for botfile in pathlib.Path(base_path).glob('**/*.py') if botfile.is_file() and botfile.name != '__init__.py'] | ||
for file in botfiles: | ||
file = Path(file.as_posix().replace(base_path, 'intelmq/bots')) | ||
def iter_ns(pkg): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be move the function to the outer scope?
I'll take over the change and create a new PR as sebkuf is no longer available. |
It should change the
intelmq/bots
folder to a namespace package. Now it should be easier to add new Bots. Theintelmqctl list bots
functionality now also works with namespaces. Added a documentation how to add a new bot.Implements #2350