archive: Import bz2 and gzip modules only when needed

This commit is contained in:
Fatih Aşıcı
2010-06-12 23:05:34 +00:00
parent 2e8d677f94
commit 6b7fffe952
+2 -2
View File
@@ -18,8 +18,6 @@ import stat
import shutil
import tarfile
import zipfile
import gzip
import bz2
import gettext
__trans = gettext.translation('pisi', fallback=True)
@@ -176,6 +174,7 @@ class ArchiveBzip2(ArchiveBase):
oldwd = os.getcwd()
os.chdir(target_dir)
import bz2
self.bzip2 = bz2.BZ2File(self.file_path, "r")
self.output = open(os.path.basename(self.file_path.rstrip(".bz2")), "w")
self.output.write(self.bzip2.read())
@@ -199,6 +198,7 @@ class ArchiveGzip(ArchiveBase):
oldwd = os.getcwd()
os.chdir(target_dir)
import gzip
self.gzip = gzip.GzipFile(self.file_path, "r")
self.output = open(os.path.basename(self.file_path.rstrip(".gz")), "w")
self.output.write(self.gzip.read())