diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2021-06-24 17:53:27 +0200 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-06-24 12:44:04 -0400 |
commit | bd15dc764c9d4554d8e8f08163228d65ca099985 (patch) | |
tree | d35dbb88bf5339eae9b5cbd1f21219f9d35d62bb | |
parent | cc13f393cfbe018cd4596da6503d498aa9ad719c (diff) | |
download | sos-bd15dc764c9d4554d8e8f08163228d65ca099985.tar.gz |
[plugins] Allow add_forbidden_path to apply glob recursively
Add option to apply glob.glob to forbidden path recursively.
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r-- | sos/report/plugins/__init__.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py index 06923300..6fd1a3b2 100644 --- a/sos/report/plugins/__init__.py +++ b/sos/report/plugins/__init__.py @@ -1187,12 +1187,14 @@ class Plugin(object): 'symlink': "no" }) - def add_forbidden_path(self, forbidden): + def add_forbidden_path(self, forbidden, recursive=False): """Specify a path, or list of paths, to not copy, even if it's part of an ``add_copy_spec()`` call :param forbidden: A filepath to forbid collection from :type forbidden: ``str`` or a ``list`` of strings + + :param recursive: Should forbidden glob be applied recursively """ if isinstance(forbidden, str): forbidden = [forbidden] @@ -1202,7 +1204,7 @@ class Plugin(object): for forbid in forbidden: self._log_info("adding forbidden path '%s'" % forbid) - for path in glob.glob(forbid): + for path in glob.glob(forbid, recursive=recursive): self.forbidden_paths.append(path) def get_all_options(self): |