* removepathprefix'de de yazdigim splitpath'i kullan, testini de yap guzelce
This commit is contained in:
+1
-3
@@ -27,10 +27,8 @@ def install(package_fn):
|
|||||||
util.clean_dir(config.install_dir())
|
util.clean_dir(config.install_dir())
|
||||||
package.extract_PISI_files(config.install_dir())
|
package.extract_PISI_files(config.install_dir())
|
||||||
|
|
||||||
import sys
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# verify package
|
# verify package
|
||||||
|
|
||||||
# check if we have all required files
|
# check if we have all required files
|
||||||
|
|
||||||
metadata = MetaData()
|
metadata = MetaData()
|
||||||
|
|||||||
+3
-3
@@ -88,9 +88,9 @@ def subpath(a, b):
|
|||||||
"find if path a is before b in the directory tree"
|
"find if path a is before b in the directory tree"
|
||||||
return prefix(splitpath(a), splitpath(b))
|
return prefix(splitpath(a), splitpath(b))
|
||||||
|
|
||||||
def removepathprefix(a, b):
|
def removepathprefix(prefix, path):
|
||||||
"remove path prefix a from p, finding the pathname rooted at a"
|
"remove path prefix a from b, finding the pathname rooted at a"
|
||||||
comps = remove_prefix(os.path.split(a), os.path.split(b))
|
comps = remove_prefix(splitpath(prefix), splitpath(path))
|
||||||
if len(comps) > 0:
|
if len(comps) > 0:
|
||||||
return os.path.join(*tuple(comps))
|
return os.path.join(*tuple(comps))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -14,4 +14,8 @@ class UtilTestCase(unittest.TestCase):
|
|||||||
self.assert_(subpath('usr', 'usr/local/src'))
|
self.assert_(subpath('usr', 'usr/local/src'))
|
||||||
self.assert_(not subpath('usr/local', 'usr'))
|
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)
|
suite = unittest.makeSuite(UtilTestCase)
|
||||||
|
|||||||
Reference in New Issue
Block a user