From 2a3cd8eef460b127f7b7f0a9d2fa27f0e83b8ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 20 Jun 2005 15:21:44 +0000 Subject: [PATCH] * package.extract_file'in gerektirdigi seyleri archivezip'de yapmaya calis * gereken diger seyleri gormek ve nasil yapilacagini gormek icin genellestirilmis unpack_file_cond fonksiyonuna bakiniz... --- pisi/archive.py | 9 ++++++--- pisi/package.py | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pisi/archive.py b/pisi/archive.py index 4642486b..75e7720f 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -57,14 +57,17 @@ class ArchiveZip(ArchiveBase): def __init__(self, filepath, type="zip"): super(ArchiveZip, self).__init__(filepath, type) - def unpack_file_cond(self, pred, targetDir): + def unpack_file_cond(self, pred, targetDir, extractRoot=''): """ unpack file according to predicate function filename -> bool""" super(ArchiveTarFile, self).unpack(targetDir) zip = zipfile.ZipFile(self.filePath, 'r') for file in zip.namelist(): - if pred(file): # search for path - opath = os.path.join(targetDir, file) + if pred(file): # check if condition holds + if extractRoot=='': + ofile = os.path.join(targetDir, file) + else: + raise ArchiveError("changing extraction root not implemented yet") if os.path.isdir(ofile): continue util.check_dir(os.path.dirname(ofile)) diff --git a/pisi/package.py b/pisi/package.py index 0182b03d..b3886381 100644 --- a/pisi/package.py +++ b/pisi/package.py @@ -19,15 +19,18 @@ class Package: def extract_file(self, path, outdir): """extract file with path to outdir""" + impl.unpack_file(path, outdir) def extract_dir(self, dir, outdir): """extract directory recursively, this function copies the directory archiveroot/dir to outdir""" + impl.unpack_dir(path, outdir) def extract_dir_flat(self, dir, outdir): """extract directory recursively, this function unpacks the *contents* of directory archiveroot/dir inside outdir this is the function used by the installer""" + impl.unpack_dir_flat(dir, outdir) def extract_PISI_files(self, outdir): """extract PISI control files: metadata.xml, files.xml,