diff options
Diffstat (limited to '')
-rw-r--r-- | quarg/main.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/quarg/main.py b/quarg/main.py index eeaf943..2973a2a 100644 --- a/quarg/main.py +++ b/quarg/main.py @@ -141,16 +141,25 @@ def collect_predicates(args): } for key, value in vars(args).items(): - # FIXME sadly the 'joined' namespace will contain a falsy value, so - # check against None or [] - if key in funs and value not in [None, []]: - fun = funs[key] - if args.debug: - print(f'{key}: {value}', file=sys.stderr) - if isinstance(value, list): - yield filters.any_filter(fun, value) - else: - yield fun(value) + # ignore unset or empty arguments + # Note: 'if not value' does not work here because 'joined' can be falsy + # but still needs to be passed to filters.joined + if value is None or value == []: + continue + + # ignore arguments that do not map to predicates + if key not in funs: + continue + + if args.debug: + print(f'{key}: {value}', file=sys.stderr) + + fun = funs[key] + + if isinstance(value, list): + yield filters.any_filter(fun, value) + else: + yield fun(value) def run_query(session, predicates): start = timer() |