* 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...
This commit is contained in:
Eray Özkural
2005-06-20 15:21:44 +00:00
parent d311c28e6f
commit 2a3cd8eef4
2 changed files with 9 additions and 3 deletions
+6 -3
View File
@@ -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))
+3
View File
@@ -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,