Skip to content

Commit 5b793ef

Browse files
committed
python: add flux.util.FilterActionConcatenate
Problem: The flux-jobs(1) -f, --filter option is being updated to take a query string, but there is no "filter" based argparse action to handle this case. Add flux.util.FilterActionConcatenate which concatenates multiple --filter strings together, separated by space.
1 parent fefb5c0 commit 5b793ef

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/bindings/python/flux/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ def __call__(self, parser, namespace, values, option_string=None):
216216
getattr(namespace, self.dest).update(values)
217217

218218

219+
class FilterActionConcatenate(argparse.Action):
220+
"""Concatenate filter arguments separated with space"""
221+
222+
def __call__(self, parser, namespace, values, option_string=None):
223+
setattr(namespace, "filtered", True)
224+
current = getattr(namespace, self.dest)
225+
if current is not None:
226+
values = current + " " + values
227+
setattr(namespace, self.dest, values)
228+
229+
219230
# pylint: disable=redefined-builtin
220231
class FilterTrueAction(argparse.Action):
221232
def __init__(

0 commit comments

Comments
 (0)