diff --git a/pisi/archive.py b/pisi/archive.py index 074fffcd..8d30da72 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -139,3 +139,6 @@ class Archive: def unpack(self, targetDir): self.archive.unpack(targetDir) + + def unpack_file(self, targetDir): + self.archive.unpack(targetDir) diff --git a/pisi/util.py b/pisi/util.py index b5832671..8e10f101 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -37,7 +37,7 @@ def prefix(a, b): "check if sequence a is a prefix of sequence b" if len(a)>len(b): return False - for i in [0:len(a)-1): + for i in range(0,len(a)-1): if a[i]!=b[i]: return False return True @@ -55,7 +55,7 @@ def commonprefix(l): returns a list of path components""" common = [] comps = map(os.path.split, l) - for i in [0:min(len,l)-1]: + for i in range(0, min(len,l)-1): compi = map(lambda x: x[i], comps) # get ith slice if same(compi): common.append(compi[0]) diff --git a/tests/archivetests.py b/tests/archivetests.py index 617cb8b9..6f45224e 100644 --- a/tests/archivetests.py +++ b/tests/archivetests.py @@ -64,6 +64,19 @@ class ArchiveFileTestCase(unittest.TestCase): testfile = targetDir + "/sandbox/deneme/hed" assert islink(testfile) + def testUnpackZipCond(self): + ctx = context.Context("tests/sandbox/sandbox.pspec") + fetch = fetcher.Fetcher(ctx) + fetch.fetch() + targetDir = ctx.pkg_work_dir() + assert ctx.spec.source.archiveType == "zip" + fileName = os.path.basename(ctx.spec.source.archiveUri) + filePath = ctx.archives_dir() + '/' + fileName + achv = archive.Archive(filePath, ctx.spec.source.archiveType) + achv.unpack_file("sandbox/borek.cd") + assert pathexists(targetDir + "/sandbox") + testfile = targetDir + "/sandbox/borek.cs" + assert pathexists(testfile) suite = unittest.makeSuite(ArchiveFileTestCase)