diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2014-03-26 12:22:29 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2014-03-26 12:22:29 +0000 |
commit | e708041c050245bf05a7205e6661f8402e8e6a66 (patch) | |
tree | 94f0d7ce2240763d2e8e3564ab4a599418990fd6 | |
parent | 4553f0942c00b47342deea7fc47bb9822484a65e (diff) | |
download | sos-e708041c050245bf05a7205e6661f8402e8e6a66.tar.gz |
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>
-rw-r--r-- | sos/plugins/__init__.py | 15 | ||||
-rw-r--r-- | tests/plugin_tests.py | 17 |
2 files changed, 1 insertions, 31 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index cf2a7101..d420cd00 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 0f8ef5da..5eb13049 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")) |