--- a/src/pyams_file/archive/gz.py Wed Jun 17 09:56:17 2015 +0200
+++ b/src/pyams_file/archive/gz.py Wed Jul 22 16:54:13 2015 +0200
@@ -33,8 +33,10 @@
def initialize(self, data):
if isinstance(data, tuple):
data = data[0]
+ if not hasattr(data, 'read'):
+ data = BytesIO(data)
self.data = data
- self.gzip_file = gzip.GzipFile(fileobj=BytesIO(data), mode='r')
+ self.gzip_file = gzip.GzipFile(fileobj=data, mode='r')
def get_contents(self):
gzip_data = self.gzip_file.read(4096)
--- a/src/pyams_file/archive/tar.py Wed Jun 17 09:56:17 2015 +0200
+++ b/src/pyams_file/archive/tar.py Wed Jul 22 16:54:13 2015 +0200
@@ -32,7 +32,9 @@
def initialize(self, data, mode='r'):
if isinstance(data, tuple):
data = data[0]
- self.tar = tarfile.open(fileobj=BytesIO(data), mode=mode)
+ if not hasattr(data, 'read'):
+ data = BytesIO(data)
+ self.tar = tarfile.open(fileobj=data, mode=mode)
def get_contents(self):
members = self.tar.getmembers()
--- a/src/pyams_file/archive/zip.py Wed Jun 17 09:56:17 2015 +0200
+++ b/src/pyams_file/archive/zip.py Wed Jul 22 16:54:13 2015 +0200
@@ -32,7 +32,9 @@
def initialize(self, data, mode='r'):
if isinstance(data, tuple):
data = data[0]
- self.zip_data = zipfile.ZipFile(BytesIO(data), mode=mode)
+ if not hasattr(data, 'read'):
+ data = BytesIO(data)
+ self.zip_data = zipfile.ZipFile(data, mode=mode)
def get_contents(self):
members = self.zip_data.infolist()