Sophie

Sophie

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

sos-3.1-1.fc19.src.rpm

From e708041c050245bf05a7205e6661f8402e8e6a66 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Wed, 26 Mar 2014 12:22:29 +0000
Subject: [PATCH 40/72] Dead code removal: sos_relative_path()

The function is defined and even has test cases. But no callers..
Remove the function and the test cases that exercise it.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/__init__.py | 15 ---------------
 tests/plugin_tests.py   | 17 +----------------
 2 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index cf2a710..d420cd0 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -58,21 +58,6 @@ def common_prefix(l1, l2, common = None):
         return (common, [l1, l2])
     return common_prefix(l1[1:], l2[1:], common+[l1[0]])
 
-def sos_relative_path(path1, path2, sep=os.path.sep, pardir=os.path.pardir):
-    '''Return a relative path from path1 equivalent to path path2.  In
-    particular: the empty string, if path1 == path2; path2, if path1 and path2
-    have no common prefix.
-    '''
-    try:
-        common, (u1, u2) = common_prefix(path1.split(sep), path2.split(sep))
-    except AttributeError:
-        return path2
-
-    if not common:
-        return path2      # leave path absolute if nothing at all in common
-    return sep.join( [pardir]*len(u1) + u2 )
-
-
 def regex_findall(regex, fname):
     '''Return a list of all non overlapping matches in the string(s)'''
     try:
diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py
index 0f8ef5d..5eb1304 100644
--- a/tests/plugin_tests.py
+++ b/tests/plugin_tests.py
@@ -9,7 +9,7 @@ try:
 except:
     from io import StringIO
 
-from sos.plugins import Plugin, regex_findall, sos_relative_path, mangle_command
+from sos.plugins import Plugin, regex_findall, mangle_command
 from sos.archive import TarFileArchive, ZipFileArchive
 import sos.policies
 
@@ -114,21 +114,6 @@ class PluginToolTests(unittest.TestCase):
         matches = regex_findall(r".*", 1)
         self.assertEquals(matches, [])
 
-    def test_rel_path(self):
-        path1 = "/usr/lib/foo"
-        path2 = "/usr/lib/boo"
-        self.assertEquals(sos_relative_path(path1, path2), "../boo")
-
-    def test_abs_path(self):
-        path1 = "usr/lib/foo"
-        path2 = "foo/lib/boo"
-        self.assertEquals(sos_relative_path(path1, path2), "foo/lib/boo")
-
-    def test_bad_path(self):
-        path1 = None
-        path2 = "foo/lib/boo"
-        self.assertEquals(sos_relative_path(path1, path2), "foo/lib/boo")
-
     def test_mangle_command(self):
         self.assertEquals("foo", mangle_command("/usr/bin/foo"))
         self.assertEquals("foo_-x", mangle_command("/usr/bin/foo -x"))
-- 
1.9.3