-
Notifications
You must be signed in to change notification settings - Fork 227
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
Filter object #155
Filter object #155
Conversation
@@ -0,0 +1,79 @@ | |||
import copy |
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 we should consider this core functionality so I'd place it under nornir/core/filter.py
@@ -0,0 +1,43 @@ | |||
from nornir.plugins.inventory.helpers.filters import F |
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.
As per above comment this should be "tests/core/test_filter.py".
Also, please, follow the same pattern as with the rest of the tests, please.
Overall looks great, I have to do some more testing of my own and play a bit with yet but I think this is the right direction :) |
I moved the filter to nornir/core.
|
Awesome work! :D I am going to merge it into a branch and play a bit with it as I add a note in the tutorial about this :) |
Thanks for doing this work @targuan ! |
As discussed in #152, this is a basic implementation of Django's Q object filtering schema.
In order to use it, one have to construct a filtering object F which will represent how one want to filter.
The objects can be combined with the logicals operators
&
which allow object matching the conditions of both F object|
which allow object matching the conditions of one of the F object~
which allow object matching none of the conditions of the F objectTests are quite explicit I think but I can clarify if needed.
I have integrated the others django operators (mostly the contains operator) as in #152.
This implementation is done in the plugins section as I think as this as a helper to filter with more granularity than the basic
key=value
method.If for consistency reason (or other reasons) the F filtering method should be kept as the only method (by converting the **kwargs to a F object) it can be moved to the core.