* removepathprefix'de de yazdigim splitpath'i kullan, testini de yap guzelce

This commit is contained in:
Eray Özkural
2005-06-24 16:22:03 +00:00
parent 89fcb110af
commit 8617263c07
3 changed files with 8 additions and 6 deletions
+1 -3
View File
@@ -27,10 +27,8 @@ def install(package_fn):
util.clean_dir(config.install_dir())
package.extract_PISI_files(config.install_dir())
import sys
sys.exit(1)
# verify package
# check if we have all required files
metadata = MetaData()
+3 -3
View File
@@ -88,9 +88,9 @@ def subpath(a, b):
"find if path a is before b in the directory tree"
return prefix(splitpath(a), splitpath(b))
def removepathprefix(a, b):
"remove path prefix a from p, finding the pathname rooted at a"
comps = remove_prefix(os.path.split(a), os.path.split(b))
def removepathprefix(prefix, path):
"remove path prefix a from b, finding the pathname rooted at a"
comps = remove_prefix(splitpath(prefix), splitpath(path))
if len(comps) > 0:
return os.path.join(*tuple(comps))
else:
+4
View File
@@ -14,4 +14,8 @@ class UtilTestCase(unittest.TestCase):
self.assert_(subpath('usr', 'usr/local/src'))
self.assert_(not subpath('usr/local', 'usr'))
def testRemovePathPrefix(self):
a = removepathprefix('usr/local', 'usr/local/lib')
self.assertEqual(a, 'lib')
suite = unittest.makeSuite(UtilTestCase)