From 43e147773352fcb7e7cf131e1178504208addf38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Tue, 14 Jun 2005 13:57:20 +0000 Subject: [PATCH] =?UTF-8?q?archive'i=20handle=20ederken=20targetDir=20para?= =?UTF-8?q?metresi=20ile=20nereye=20a=C3=A7=C4=B1laca=C4=9F=C4=B1na=20kara?= =?UTF-8?q?r=20veriyoruz=20(hen=C3=BCz=20bu=20=C3=B6zellik=20=C3=A7al?= =?UTF-8?q?=C4=B1=C5=9Fm=C4=B1yor).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Belki de targetDir'ı constructor'a değil unpac()'e vermeliyiz... Bu haline bir bakın yine de... --- src/pisi/archive.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pisi/archive.py b/src/pisi/archive.py index 84152269..b895cbbd 100644 --- a/src/pisi/archive.py +++ b/src/pisi/archive.py @@ -12,15 +12,15 @@ import zipfile import config class ArchiveBase(object): - def __init__(self, fileName, type): + def __init__(self, type, fileName, targetPath): self.type = type self.fileName = fileName - self.filePath = config.archives_dir() + '/' + self.fileName + self.targetPath = targetPath class ArchiveTarFile(ArchiveBase): - def __init__(self, fileName, type): - super(ArchiveTarFile, self).__init__(fileName, type) + def __init__(self, type, fileName, targetPath): + super(ArchiveTarFile, self).__init__(type, fileName, targetPath) def unpack(self): if self.type == 'targz': @@ -30,8 +30,8 @@ class ArchiveTarFile(ArchiveBase): tar.close() class ArchiveZip(ArchiveBase): - def __init__(self, fileName, type): - super(ArchiveZip, self).__init__(fileName, type) + def __init__(self, type, fileName, targetPath): + super(ArchiveZip, self).__init__(type, fileName, targetPath) def unpack(self): zip = zipfile.ZipFile(self.filePath, 'r') @@ -41,7 +41,7 @@ class ArchiveZip(ArchiveBase): if not os.path.exists(os.path.dirname(config.archives_dir() + '/' + file)): os.mkdir(os.path.dirname(config.archives_dir() + '/' + file)) continue - else: # directory is present, we should still continue (or delete?) + else: # directory is present, we should still continue (or delete and recreate?) continue buff = open (ofile, 'wb') fileContent = zip.read(file) @@ -52,7 +52,7 @@ class ArchiveZip(ArchiveBase): class Archive: """Unpack magic for Archive files...""" - def __init__(self, type, fileName): + def __init__(self, type, fileName, targetPath): """accepted archive types: targz, tarbz2, zip, tar""" @@ -63,7 +63,7 @@ class Archive: 'zip': ArchiveZip } - self.archive = actions.get(type)(fileName, type) + self.archive = actions.get(type)(type, fileName, targetPath) def unpack(self): self.archive.unpack()