diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2014-03-27 20:33:40 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2014-03-27 20:33:40 +0000 |
commit | 81b06ca7406aee6ecb47f7afe33fc56caafee570 (patch) | |
tree | 3e155ba34cfc53ff9902600873f36295f9b9eb53 | |
parent | f5be64704096d5bdf9f75cc78dc571c6d9325fcb (diff) | |
download | sos-81b06ca7406aee6ecb47f7afe33fc56caafee570.tar.gz |
Use a set for Plugin.copy_paths
We want to remove any duplicates from the list of paths to
collect. Use a set and update it with the expansion of each copy
spec as we add it. This avoids having to explictly test for
duplicates when we come to iterate over the set.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/__init__.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index de278d06..7b6180c6 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -99,7 +99,7 @@ class Plugin(object): self.opt_parms = [] self.commons = commons self.forbidden_paths = [] - self.copy_specs = [] + self.copy_paths = set() self.copy_strings = [] self.collect_cmds = [] @@ -402,11 +402,11 @@ class Plugin(object): copied into the sosreport by this module. """ if not (copyspec and len(copyspec)): - self.soslog.warning("%s added null or empty file path" - % self.name()) + self.soslog.warning("plugin %s %s" + % ("added null or empty copy spec", self.name())) return False - if copyspec not in self.copy_specs: - self.copy_specs.append(copyspec) + copy_paths = self.expand_copy_spec(copyspec) + self.copy_paths.update(copy_paths) def get_command_output(self, prog, timeout=300): (status, output, runtime) = sos_get_command_output(prog, timeout) @@ -523,9 +523,7 @@ class Plugin(object): return glob.glob(copyspec) def collect_copy_specs(self): - # Glob case handling is such that a valid non-glob is a reduced glob - for spec in self.copy_specs: - for path in self.expand_copy_spec(spec): + for path in self.copy_paths: self.do_copy_path(path) def collect_cmd_output(self): |