From 16b760250a5dab18e7d59c331d83aea9a178468d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Fri, 1 Jul 2005 13:29:37 +0000 Subject: [PATCH] =?UTF-8?q?Kozmetik=20de=C4=9Fi=C5=9Fiklikler,=20self.add?= =?UTF-8?q?=5Ffile=20->=20self.add=5Fto=5Farchive,=20type=20->=20ArchType?= =?UTF-8?q?=20[=20type=20is=20a=20keyword!=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/archive.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/pisi/archive.py b/pisi/archive.py index 6a51f8da..95fa2e97 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -4,10 +4,8 @@ #standard lisbrary modules import os -import sys import tarfile import zipfile -from config import config #pisi modules import util @@ -35,8 +33,8 @@ class ArchiveTar(ArchiveBase): type. Provides access to tar, tar.gz and tar.bz2 files. This class provides the unpack magic for tar archives.""" - def __init__(self, filepath, type = "tar"): - super(ArchiveTar, self).__init__(filepath, type) + def __init__(self, filepath, ArchType = "tar"): + super(ArchiveTar, self).__init__(filepath, ArchType) def unpack(self, targetDir, cleanDir = False): """Unpack tar archive to a given target directory(targetDir).""" @@ -69,8 +67,8 @@ class ArchiveZip(ArchiveBase): symmagic = 2716663808 #long of hex val '0xA1ED0000L' - def __init__(self, filepath, type = "zip", mode = 'r'): - super(ArchiveZip, self).__init__(filepath, type) + def __init__(self, filepath, ArchType = "zip", mode = 'r'): + super(ArchiveZip, self).__init__(filepath, ArchType) self.zip = zipfile.ZipFile(self.filePath, mode) @@ -85,7 +83,7 @@ class ArchiveZip(ArchiveBase): if os.path.isdir(fileName) and not os.path.islink(fileName): self.zip.writestr(os.path.join(fileName, '')) for f in os.listdir(fileName): - self.add_to_archive(os.path.join(fileName, f)) + self.add_to_archive(os.path.join(fileName, f)) else: if os.path.islink(fileName): dest = os.readlink(fileName) @@ -107,7 +105,7 @@ class ArchiveZip(ArchiveBase): fileName = os.path.basename(fileName) if pathName: os.chdir(pathName) - self.add_file(fileName) + self.add_to_archive(fileName) os.chdir(cwd) def unpack_file_cond(self, pred, targetDir, archiveRoot = ''): @@ -121,7 +119,7 @@ class ArchiveZip(ArchiveBase): isdir = info.filename.endswith('/') # calculate output file name - if archiveRoot=='': + if archiveRoot == '': outpath = info.filename else: # change archiveRoot @@ -157,10 +155,10 @@ class ArchiveZip(ArchiveBase): self.unpack_file_cond(lambda f:f in paths, targetDir) def unpack_dir(self, path, targetDir): - self.unpack_file_cond(lambda f:util.subpath(path,f), targetDir) + self.unpack_file_cond(lambda f:util.subpath(path, f), targetDir) def unpack_dir_flat(self, path, targetDir): - self.unpack_file_cond(lambda f:util.subpath(path,f), targetDir, path) + self.unpack_file_cond(lambda f:util.subpath(path, f), targetDir, path) def unpack(self, targetDir, cleanDir=False): super(ArchiveZip, self).unpack(targetDir, cleanDir) @@ -173,7 +171,7 @@ class Archive: """Archive is the main factory for ArchiveClasses, regarding the Abstract Factory Pattern :).""" - def __init__(self, filepath, type): + def __init__(self, filepath, ArchType): """accepted archive types: targz, tarbz2, zip, tar""" @@ -184,7 +182,7 @@ class Archive: 'zip': ArchiveZip } - self.archive = handlers.get(type)(filepath, type) + self.archive = handlers.get(ArchType)(filepath, ArchType) def unpack(self, targetDir, cleanDir = False): self.archive.unpack(targetDir, cleanDir)