-
Notifications
You must be signed in to change notification settings - Fork 86
NodeSet: add special notation @@source to expand group names #468
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
Conversation
Interesting feature! I'm trying to have this match into the other feature we have for NodeSet syntax/arithmetic. So far, we supports various syntaxes to identify node name, or group names that will be mapped into node names. I like the idea of fetching the group list with a nodeset syntax, but I would like it to have a syntax that could be pointing to the current source without knowing its name.
|
Thanks! This patch implements your second point. Note that when listing group names from a source, only the source name is needed. For example, with this patch, With the Lastly, but I doubt it will be very useful in practice, we could implement Both last ideas are compatible with this patch. Let me know what you think. |
I like it the way it is right now, not only because the patch is just so tiny and elegant (which talks to the quality of the existing code), but also because I feel it's more intuitive for users. Listing the group names in group source I'm not sure implementing a And as for listing the groups in the current source without knowing its name, it works out the box already with:
Did I mention that patch was awesome? ;) |
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.
Ok, if you both think @@
is a clear enough syntax, i'm not against it. Just make that clear in the doc and the tests that this is an officially supported syntax.
Agreed that name filtering could be added later, if people asks for it.
@@ -916,6 +916,8 @@ def parse_group_string(self, nodegroup, namespace=None): | |||
namespace, group = grpstr.split(':', 1) | |||
if group == '*': # @* or @source:* magic | |||
reslist = self.all_nodes(namespace) | |||
elif group.startswith('@'): # @@source group name list | |||
reslist = self.grouplist(grpstr[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.
ok, no source name is supported because grpstr[1:]
will be expanded to ''
and we are testing namespace
as a boolean, so both None
(official value) and ''
will evaluate to False
.
12d2d00
to
715cdb3
Compare
This change allows access to all group names of a specific source in node set expressions. The special operator `@@` optionally followed by a source expands group names that can then be manipulated as a set. The default group source is used when `@@` is used alone. Note: In that case, group names are not prefixed with @ and as such, not further expanded into nodes by NodeSet.
715cdb3
to
e995f4c
Compare
done! |
This change allows access to all group names of a specific source in
node set expressions. The special operator
@@
followed by the sourceexpands group names that can then be manipulated as a set.
Note: In that case, group names are not prefixed with @ and as such, not
further expanded into nodes by NodeSet.