aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-04-26 12:43:47 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-04-26 12:43:47 +0100
commit899e97966bdd1484063360c7b1bdb03a005ed7fb (patch)
tree3aa97161ea594578055e6ba72f46437b8d3916e5
parent78851871666675f226e8b8886246107df343ab15 (diff)
downloadsos-899e97966bdd1484063360c7b1bdb03a005ed7fb.tar.gz
[Plugin] allow lists to be passed to add_forbidden_path()
In the same manner as add_copy_spec() and add_cmd_output(), allow add_forbidden_path() to accept either a single glob specification as a string, or a list of globs. This avoide the need for repeated calls to define a list of paths to exclude for a plugin. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 8f2abd41..ef41b611 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -464,14 +464,18 @@ class Plugin(object):
})
def add_forbidden_path(self, forbidden):
- """Specify a path to not copy, even if it's part of a copy_specs[]
- entry.
+ """Specify a path, or list of paths, to not copy, even if it's
+ part of a copy_specs[] entry.
"""
+ if isinstance(forbidden, six.string_types):
+ forbidden = [forbidden]
+
if self.use_sysroot():
- forbidden = self.join_sysroot(forbidden)
- # Glob case handling is such that a valid non-glob is a reduced glob
- for path in glob.glob(forbidden):
- self.forbidden_paths.append(path)
+ forbidden = [self.join_sysroot(f) for f in forbidden]
+
+ for forbid in forbidden:
+ for path in glob.glob(forbid):
+ self.forbidden_paths.append(path)
def get_all_options(self):
"""return a list of all options selected"""