Skip to content

Commit 12d87a8

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 95a817d commit 12d87a8

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
@@ -226,6 +226,17 @@ def __call__(self, parser, namespace, values, option_string=None):
226226
getattr(namespace, self.dest).update(values)
227227

228228

229+
class FilterActionConcatenate(argparse.Action):
230+
"""Concatenate filter arguments separated with space"""
231+
232+
def __call__(self, parser, namespace, values, option_string=None):
233+
setattr(namespace, "filtered", True)
234+
current = getattr(namespace, self.dest)
235+
if current is not None:
236+
values = current + " " + values
237+
setattr(namespace, self.dest, values)
238+
239+
229240
# pylint: disable=redefined-builtin
230241
class FilterTrueAction(argparse.Action):
231242
def __init__(

0 commit comments

Comments
 (0)