aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2019-03-25 12:16:33 +0000
committerBryn M. Reeves <bmr@redhat.com>2019-03-25 12:16:33 +0000
commitf31f7c3fb23a322f26ebfc8758be8a6b4ed1e7a6 (patch)
tree6e1840a989884fe01387c94720804dfdc05425c6
parent41d48770c0c34b58862be57b1aa14618b7422ae9 (diff)
downloadsos-f31f7c3fb23a322f26ebfc8758be8a6b4ed1e7a6.tar.gz
[Plugin] fix predicate precedence in get_predicate()
The get_predicate() method is responsible for evaluating the precedence of the three types of predicate: * Explicit predicate passed as `pred` keyword argument * Implicit command default predicate if processing a command * Implicit plugin default predicate Fix the ordering of checks in get_predicate() so that these rules are consistently followed. Related: #1616 Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 0d245013..a2c9ba6c 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -379,9 +379,11 @@ class Plugin(object):
If no default predicate is set and a `pred` value is passed
it will be returned.
"""
- if cmd and self.cmd_predicate:
+ if pred is not None:
+ return pred
+ if cmd and self.cmd_predicate is not None:
return self.cmd_predicate
- return pred or self.predicate
+ return self.predicate
def test_predicate(self, cmd=False, pred=None):
"""Test the current predicate and return its value.