Blame SOURCES/0024-archive-remove-all-references-to-ZipFileArchive.patch

0cd6dc
From f0ad2e331ce0524d36f59f3dee5cf85e6b22b089 Mon Sep 17 00:00:00 2001
0cd6dc
From: "Bryn M. Reeves" <bmr@redhat.com>
0cd6dc
Date: Thu, 11 Dec 2014 19:08:29 +0000
0cd6dc
Subject: [PATCH 24/93] [archive] remove all references to ZipFileArchive
0cd6dc
0cd6dc
Commit f342d39 removed ZipFileArchive and the test suite references
0cd6dc
but left several imports in other files. Remove them and attendant
0cd6dc
support functions.
0cd6dc
0cd6dc
Fixes #449.
0cd6dc
0cd6dc
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
0cd6dc
---
0cd6dc
 sos/archive.py   |  1 -
0cd6dc
 sos/sosreport.py |  2 +-
0cd6dc
 sos/utilities.py | 39 ++-------------------------------------
0cd6dc
 3 files changed, 3 insertions(+), 39 deletions(-)
0cd6dc
0cd6dc
diff --git a/sos/archive.py b/sos/archive.py
0cd6dc
index 1963898..6ef46a9 100644
0cd6dc
--- a/sos/archive.py
0cd6dc
+++ b/sos/archive.py
0cd6dc
@@ -18,7 +18,6 @@
0cd6dc
 import os
0cd6dc
 import time
0cd6dc
 import tarfile
0cd6dc
-import zipfile
0cd6dc
 import shutil
0cd6dc
 import logging
0cd6dc
 import shlex
0cd6dc
diff --git a/sos/sosreport.py b/sos/sosreport.py
0cd6dc
index a697380..0dd26ad 100644
0cd6dc
--- a/sos/sosreport.py
0cd6dc
+++ b/sos/sosreport.py
0cd6dc
@@ -37,7 +37,7 @@ import tempfile
0cd6dc
 from sos import _sos as _
0cd6dc
 from sos import __version__
0cd6dc
 import sos.policies
0cd6dc
-from sos.archive import TarFileArchive, ZipFileArchive
0cd6dc
+from sos.archive import TarFileArchive
0cd6dc
 from sos.reporting import (Report, Section, Command, CopiedFile, CreatedFile,
0cd6dc
                            Alert, Note, PlainTextReport)
0cd6dc
 
0cd6dc
diff --git a/sos/utilities.py b/sos/utilities.py
0cd6dc
index 8cb4ed6..51909c6 100644
0cd6dc
--- a/sos/utilities.py
0cd6dc
+++ b/sos/utilities.py
0cd6dc
@@ -18,7 +18,6 @@ import os
0cd6dc
 import re
0cd6dc
 import inspect
0cd6dc
 from subprocess import Popen, PIPE, STDOUT
0cd6dc
-import zipfile
0cd6dc
 import hashlib
0cd6dc
 import logging
0cd6dc
 import fnmatch
0cd6dc
@@ -191,8 +190,8 @@ def shell_out(cmd, runat=None):
0cd6dc
 class ImporterHelper(object):
0cd6dc
     """Provides a list of modules that can be imported in a package.
0cd6dc
     Importable modules are located along the module __path__ list and modules
0cd6dc
-    are files that end in .py. This class will read from PKZip archives as well
0cd6dc
-    for listing out jar and egg contents."""
0cd6dc
+    are files that end in .py.
0cd6dc
+    """
0cd6dc
 
0cd6dc
     def __init__(self, package):
0cd6dc
         """package is a package module
0cd6dc
@@ -223,38 +222,6 @@ class ImporterHelper(object):
0cd6dc
             else:
0cd6dc
                 return []
0cd6dc
 
0cd6dc
-    def _get_path_to_zip(self, path, tail_list=None):
0cd6dc
-        if not tail_list:
0cd6dc
-            tail_list = ['']
0cd6dc
-
0cd6dc
-        if path.endswith(('.jar', '.zip', '.egg')):
0cd6dc
-            return path, os.path.join(*tail_list)
0cd6dc
-
0cd6dc
-        head, tail = os.path.split(path)
0cd6dc
-        tail_list.insert(0, tail)
0cd6dc
-
0cd6dc
-        if head == path:
0cd6dc
-            raise Exception("not a zip file")
0cd6dc
-        else:
0cd6dc
-            return self._get_path_to_zip(head, tail_list)
0cd6dc
-
0cd6dc
-    def _find_plugins_in_zipfile(self, path):
0cd6dc
-        try:
0cd6dc
-            path_to_zip, tail = self._get_path_to_zip(path)
0cd6dc
-            zf = zipfile.ZipFile(path_to_zip)
0cd6dc
-            # the path will have os separators, but the zipfile will
0cd6dc
-            # always have '/'
0cd6dc
-            tail = tail.replace(os.path.sep, "/")
0cd6dc
-            root_names = [name for name in zf.namelist() if tail in name]
0cd6dc
-            candidates = self._get_plugins_from_list(root_names)
0cd6dc
-            zf.close()
0cd6dc
-            if candidates:
0cd6dc
-                return candidates
0cd6dc
-            else:
0cd6dc
-                return []
0cd6dc
-        except (IOError, Exception):
0cd6dc
-            return []
0cd6dc
-
0cd6dc
     def get_modules(self):
0cd6dc
         """Returns the list of importable modules in the configured python
0cd6dc
         package. """
0cd6dc
@@ -262,8 +229,6 @@ class ImporterHelper(object):
0cd6dc
         for path in self.package.__path__:
0cd6dc
             if os.path.isdir(path) or path == '':
0cd6dc
                 plugins.extend(self._find_plugins_in_dir(path))
0cd6dc
-            else:
0cd6dc
-                plugins.extend(self._find_plugins_in_zipfile(path))
0cd6dc
 
0cd6dc
         return plugins
0cd6dc
 
0cd6dc
-- 
0cd6dc
1.9.3
0cd6dc