|
|
@@ -4,34 +4,9 @@ |
|
|
|
__version__ = '$Change$' |
|
|
|
# $Id$ |
|
|
|
|
|
|
|
import tarfile |
|
|
|
from tarfile import * |
|
|
|
|
|
|
|
TAR_PLAIN = tarfile.TAR_PLAIN |
|
|
|
TAR_GZIPPED = tarfile.TAR_GZIPPED |
|
|
|
TAR_BZ2 = 'bz2' |
|
|
|
|
|
|
|
__all__ = tarfile.__all__ |
|
|
|
|
|
|
|
class TarFileCompat(tarfile.TarFileCompat): |
|
|
|
def __init__(self, file, mode="r", compression=TAR_PLAIN): |
|
|
|
if compression != TAR_BZ2: |
|
|
|
tarfile.TarFileCompat.__init__(self, file, mode, compression) |
|
|
|
return |
|
|
|
|
|
|
|
self.tarfile = TarFile.bz2open(file, mode) |
|
|
|
if mode[0:1] == "r": |
|
|
|
members = self.tarfile.getmembers() |
|
|
|
for i in xrange(len(members)): |
|
|
|
m = members[i] |
|
|
|
m.filename = m.name |
|
|
|
m.file_size = m.size |
|
|
|
m.date_time = time.gmtime(m.mtime)[:6] |
|
|
|
import rarfile |
|
|
|
from rarfile import * |
|
|
|
|
|
|
|
class RarFile(rarfile.RarFile): |
|
|
|
def readiter(self, name, blksize=16384): |
|
|
|
f = self.tarfile.extractfile(self.tarfile.getmember(name)) |
|
|
|
while True: |
|
|
|
data = f.read(blksize) |
|
|
|
if data == '': |
|
|
|
break |
|
|
|
yield data |
|
|
|
yield self.read(name) |