* 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:
+6
-3
@@ -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))
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user