Sophie

Sophie

distrib > Fedora > 19 > i386 > by-pkgid > 2183d0e55a8d454b8164909066cf1904 > files > 57

sos-3.1-1.fc19.src.rpm

From 81b06ca7406aee6ecb47f7afe33fc56caafee570 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Thu, 27 Mar 2014 20:33:40 +0000
Subject: [PATCH 57/72] 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>
---
 sos/plugins/__init__.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index de278d0..7b6180c 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):
-- 
1.9.3